1 #ifndef __PREDICATE_H__
2 #define __PREDICATE_H__
5 #include "predicatetypes.h"
8 #define MAX_DEPTH 0x7fffffff
10 unsigned int pred_expr_hash (struct pred_expr *);
11 bool pred_expr_equal(struct pred_expr *, struct pred_expr *);
12 typedef HashSet<struct pred_expr *, uintptr_t, 0, model_malloc, model_calloc, model_free, pred_expr_hash, pred_expr_equal> PredExprSet;
13 typedef HSIterator<struct pred_expr *, uintptr_t, 0, model_malloc, model_calloc, model_free, pred_expr_hash, pred_expr_equal> PredExprSetIter;
17 Predicate(FuncInst * func_inst, bool is_entry = false, bool is_exit = false);
20 FuncInst * get_func_inst() { return func_inst; }
21 PredExprSet * get_pred_expressions() { return &pred_expressions; }
23 void add_predicate_expr(token_t token, FuncInst * func_inst, bool value);
24 void add_child(Predicate * child);
25 void set_parent(Predicate * parent_pred);
26 void set_exit(Predicate * exit_pred);
27 void add_backedge(Predicate * back_pred) { backedges.add(back_pred); }
28 void set_weight(double weight_) { weight = weight_; }
29 void copy_predicate_expr(Predicate * other);
31 Predicate * get_single_child(FuncInst * inst);
32 ModelVector<Predicate *> * get_children() { return &children; }
33 Predicate * get_parent() { return parent; }
34 Predicate * get_exit() { return exit; }
35 PredSet * get_backedges() { return &backedges; }
36 double get_weight() { return weight; }
38 bool is_entry_predicate() { return entry_predicate; }
39 void set_entry_predicate() { entry_predicate = true; }
41 void alloc_pre_exit_predicates();
42 void add_pre_exit_predicate(Predicate * pred);
44 /* Whether func_inst does write or not */
45 bool is_write() { return does_write; }
46 void set_write(bool is_write) { does_write = is_write; }
48 ConcretePredicate * evaluate(inst_act_map_t * inst_act_map, thread_id_t tid);
50 uint32_t get_expl_count() { return exploration_count; }
51 uint32_t get_store_visible_count() { return store_visible_count; }
52 uint32_t get_total_checking_count() { return total_checking_count; }
54 void incr_expl_count() { exploration_count++; }
55 void incr_store_visible_count() { store_visible_count++; }
56 void incr_total_checking_count() { total_checking_count++; }
58 uint32_t get_depth() { return depth; }
59 void set_depth(uint32_t depth_) { depth = depth_; }
61 void print_predicate();
62 void print_pred_subtree();
71 /* Height of this predicate node in the predicate tree */
75 uint32_t exploration_count;
76 uint32_t store_visible_count;
77 uint32_t total_checking_count; /* The number of times the store visibility is checked */
79 /* May have multiple predicate expressions */
80 PredExprSet pred_expressions;
81 ModelVector<Predicate *> children;
83 /* Only a single parent may exist */
87 /* Predicates precede exit nodes. Only used by exit predicates */
88 ModelVector<Predicate *> * pre_exit_predicates;
90 /* May have multiple back edges, e.g. nested loops */
94 #endif /* __PREDICATE_H__ */