1 #ifndef __PREDICTAE_H__
2 #define __PREDICATE_H__
7 unsigned int pred_expr_hash (struct pred_expr *);
8 bool pred_expr_equal(struct pred_expr *, struct pred_expr *);
9 typedef HashSet<struct pred_expr *, uintptr_t, 0, model_malloc, model_calloc, model_free, pred_expr_hash, pred_expr_equal> PredExprSet;
10 typedef HSIterator<struct pred_expr *, uintptr_t, 0, model_malloc, model_calloc, model_free, pred_expr_hash, pred_expr_equal> PredExprSetIter;
12 typedef enum predicate_token {
13 NOPREDICATE, EQUALITY, NULLITY
16 /* If token is EQUALITY, then the predicate asserts whether
17 * this load should read the same value as the last value
18 * read at memory location specified in predicate_expr.
21 pred_expr(token_t token, FuncInst * inst, bool value) :
34 /* Used by predicate generator */
35 struct half_pred_expr {
36 half_pred_expr(token_t token, FuncInst * inst) :
50 Predicate(FuncInst * func_inst, bool is_entry = false);
53 FuncInst * get_func_inst() { return func_inst; }
54 PredExprSet * get_pred_expressions() { return &pred_expressions; }
56 void add_predicate_expr(token_t token, FuncInst * func_inst, bool value);
57 void add_child(Predicate * child);
58 void set_parent(Predicate * parent_pred) { parent = parent_pred; }
59 void add_backedge(Predicate * back_pred) { backedges.add(back_pred); }
60 void copy_predicate_expr(Predicate * other);
62 ModelVector<Predicate *> * get_children() { return &children; }
63 Predicate * get_parent() { return parent; }
64 PredSet * get_backedges() { return &backedges; }
66 bool is_entry_predicate() { return entry_predicate; }
67 void set_entry_predicate() { entry_predicate = true; }
69 /* Whether func_inst does write or not */
70 bool is_write() { return does_write; }
71 void set_write(bool is_write) { does_write = is_write; }
73 void print_predicate();
74 void print_pred_subtree();
82 /* May have multiple predicate expressions */
83 PredExprSet pred_expressions;
84 ModelVector<Predicate *> children;
86 /* Only a single parent may exist */
89 /* May have multiple back edges, e.g. nested loops */
93 #endif /* __PREDICATE_H__ */