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) { exit = exit_pred; }
27 void add_backedge(Predicate * back_pred) { backedges.add(back_pred); }
28 void copy_predicate_expr(Predicate * other);
30 Predicate * get_single_child(FuncInst * inst);
31 ModelVector<Predicate *> * get_children() { return &children; }
32 Predicate * get_parent() { return parent; }
33 Predicate * get_exit() { return exit; }
34 PredSet * get_backedges() { return &backedges; }
36 bool is_entry_predicate() { return entry_predicate; }
37 void set_entry_predicate() { entry_predicate = true; }
39 /* Whether func_inst does write or not */
40 bool is_write() { return does_write; }
41 void set_write(bool is_write) { does_write = is_write; }
43 ConcretePredicate * evaluate(inst_act_map_t * inst_act_map, thread_id_t tid);
45 uint32_t get_expl_count() { return exploration_count; }
46 uint32_t get_store_visible_count() { return store_visible_count; }
47 uint32_t get_total_checking_count() { return total_checking_count; }
49 void incr_expl_count() { exploration_count++; }
50 void incr_store_visible_count() { store_visible_count++; }
51 void incr_total_checking_count() { total_checking_count++; }
53 uint32_t get_depth() { return depth; }
54 void set_depth(uint32_t depth_) { depth = depth_; }
56 void print_predicate();
57 void print_pred_subtree();
66 /* Height of this predicate node in the predicate tree */
69 uint32_t exploration_count;
70 uint32_t store_visible_count;
71 uint32_t total_checking_count; /* The number of times the store visibility is checked */
73 /* May have multiple predicate expressions */
74 PredExprSet pred_expressions;
75 ModelVector<Predicate *> children;
77 /* Only a single parent may exist */
81 /* May have multiple back edges, e.g. nested loops */
85 #endif /* __PREDICATE_H__ */