1 #ifndef __PREDICATE_H__
2 #define __PREDICATE_H__
6 #include "predicatetypes.h"
9 unsigned int pred_expr_hash (struct pred_expr *);
10 bool pred_expr_equal(struct pred_expr *, struct pred_expr *);
11 typedef HashSet<struct pred_expr *, uintptr_t, 0, model_malloc, model_calloc, model_free, pred_expr_hash, pred_expr_equal> PredExprSet;
12 typedef HSIterator<struct pred_expr *, uintptr_t, 0, model_malloc, model_calloc, model_free, pred_expr_hash, pred_expr_equal> PredExprSetIter;
16 Predicate(FuncInst * func_inst, bool is_entry = false);
19 FuncInst * get_func_inst() { return func_inst; }
20 PredExprSet * get_pred_expressions() { return &pred_expressions; }
22 void add_predicate_expr(token_t token, FuncInst * func_inst, bool value);
23 void add_child(Predicate * child);
24 void set_parent(Predicate * parent_pred) { parent = parent_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 PredSet * get_backedges() { return &backedges; }
32 bool is_entry_predicate() { return entry_predicate; }
33 void set_entry_predicate() { entry_predicate = true; }
35 /* Whether func_inst does write or not */
36 bool is_write() { return does_write; }
37 void set_write(bool is_write) { does_write = is_write; }
39 ConcretePredicate * evaluate(inst_act_map_t * inst_act_map, thread_id_t tid);
41 void print_predicate();
42 void print_pred_subtree();
50 /* May have multiple predicate expressions */
51 PredExprSet pred_expressions;
52 ModelVector<Predicate *> children;
54 /* Only a single parent may exist */
57 /* May have multiple back edges, e.g. nested loops */
61 #endif /* __PREDICATE_H__ */