Change the return type of Predicate::evaluate
[c11tester.git] / predicate.h
1 #ifndef __PREDICATE_H__
2 #define __PREDICATE_H__
3
4 #include "funcinst.h"
5 #include "hashset.h"
6 #include "predicatetypes.h"
7 #include "classlist.h"
8
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;
13
14 class Predicate {
15 public:
16         Predicate(FuncInst * func_inst, bool is_entry = false);
17         ~Predicate();
18
19         FuncInst * get_func_inst() { return func_inst; }
20         PredExprSet * get_pred_expressions() { return &pred_expressions; }
21
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);
27
28         ModelVector<Predicate *> * get_children() { return &children; }
29         Predicate * get_parent() { return parent; }
30         PredSet * get_backedges() { return &backedges; }
31
32         bool is_entry_predicate() { return entry_predicate; }
33         void set_entry_predicate() { entry_predicate = true; }
34
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; }
38
39         ConcretePredicate * evaluate(inst_act_map_t * inst_act_map, thread_id_t tid);
40
41         void print_predicate();
42         void print_pred_subtree();
43
44         MEMALLOC
45 private:
46         FuncInst * func_inst;
47         bool entry_predicate;
48         bool does_write;
49
50         /* May have multiple predicate expressions */
51         PredExprSet pred_expressions;
52         ModelVector<Predicate *> children;
53
54         /* Only a single parent may exist */
55         Predicate * parent;
56
57         /* May have multiple back edges, e.g. nested loops */
58         PredSet backedges;
59 };
60
61 #endif /* __PREDICATE_H__ */