1 #ifndef __PREDICATE_H__
2 #define __PREDICATE_H__
5 #include "predicatetypes.h"
8 unsigned int pred_expr_hash (struct pred_expr *);
9 bool pred_expr_equal(struct pred_expr *, struct pred_expr *);
10 typedef HashSet<struct pred_expr *, uintptr_t, 0, model_malloc, model_calloc, model_free, pred_expr_hash, pred_expr_equal> PredExprSet;
11 typedef HSIterator<struct pred_expr *, uintptr_t, 0, model_malloc, model_calloc, model_free, pred_expr_hash, pred_expr_equal> PredExprSetIter;
15 Predicate(FuncInst * func_inst, bool is_entry = false, bool is_exit = false);
18 FuncInst * get_func_inst() { return func_inst; }
19 PredExprSet * get_pred_expressions() { return &pred_expressions; }
21 void add_predicate_expr(token_t token, FuncInst * func_inst, bool value);
22 void add_child(Predicate * child);
23 void set_parent(Predicate * parent_pred) { parent = parent_pred; }
24 void set_exit(Predicate * exit_pred) { exit = exit_pred; }
25 void add_backedge(Predicate * back_pred) { backedges.add(back_pred); }
26 void copy_predicate_expr(Predicate * other);
28 ModelVector<Predicate *> * get_children() { return &children; }
29 Predicate * get_parent() { return parent; }
30 Predicate * get_exit() { return exit; }
31 PredSet * get_backedges() { return &backedges; }
33 bool is_entry_predicate() { return entry_predicate; }
34 void set_entry_predicate() { entry_predicate = true; }
36 /* Whether func_inst does write or not */
37 bool is_write() { return does_write; }
38 void set_write(bool is_write) { does_write = is_write; }
40 ConcretePredicate * evaluate(inst_act_map_t * inst_act_map, thread_id_t tid);
42 uint32_t get_expl_count() { return exploration_count; }
43 uint32_t get_fail_count() { return failure_count; }
44 uint32_t get_scleep_score() { return sleep_score; }
45 void incr_expl_count();
46 void incr_fail_count();
47 void incr_sleep_score(uint32_t amount);
48 void decr_sleep_score(uint32_t amount);
50 void print_predicate();
51 void print_pred_subtree();
60 uint32_t exploration_count;
61 uint32_t failure_count;
62 uint32_t sleep_score; /* 0 <= sleep_score <= 100 */
64 /* May have multiple predicate expressions */
65 PredExprSet pred_expressions;
66 ModelVector<Predicate *> children;
68 /* Only a single parent may exist */
72 /* May have multiple back edges, e.g. nested loops */
76 #endif /* __PREDICATE_H__ */