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