merge
[c11tester.git] / predicate.h
1 #ifndef __PREDICTAE_H__
2 #define __PREDICATE_H__
3
4 #include "funcinst.h"
5
6 unsigned int pred_expr_hash (struct pred_expr *);
7 bool pred_expr_equal(struct pred_expr *, struct pred_expr *);
8 typedef HashSet<struct pred_expr *, uintptr_t, 0, model_malloc, model_calloc, model_free, pred_expr_hash, pred_expr_equal> PredicateSet;
9
10 typedef enum predicate_token {
11         EQUALITY, NULLITY
12 } token_t;
13
14 /* If token is EQUALITY, then the predicate asserts whether
15  * this load should read the same value as the last value
16  * read at memory location specified in predicate_expr.
17  */
18 struct pred_expr {
19         token_t token;
20         void * location;
21         bool value;
22 };
23
24
25 class Predicate {
26 public:
27         Predicate(FuncInst * func_inst);
28         ~Predicate();
29
30         FuncInst * get_func_inst() { return func_inst; }
31         PredicateSet * get_predicates() { return &predicates; }
32         void add_predicate(token_t token, void * location, bool value);
33
34         MEMALLOC
35 private:
36         FuncInst * func_inst;
37         /* may have multiple precicates */
38         PredicateSet predicates;
39         ModelVector<Predicate *> children;
40 };
41
42 #endif /* __PREDICATE_H__ */