toward building a naive predicate tree
[c11tester.git] / funcinst.h
1 #ifndef __FUNCINST_H__
2 #define __FUNCINST_H__
3
4 #include "action.h"
5 #include "hashtable.h"
6
7 class ModelAction;
8
9 typedef ModelList<FuncInst *> func_inst_list_mt;
10
11 class FuncInst {
12 public:
13         FuncInst(ModelAction *act, FuncNode *func_node);
14         ~FuncInst();
15
16         //ModelAction * get_action() const { return action; }
17         const char * get_position() const { return position; }
18         void * get_location() const { return location; }
19         action_type get_type() const { return type; }
20         memory_order get_mo() const { return order; }
21         FuncNode * get_func_node() const { return func_node; }
22
23         bool add_pred(FuncInst * other);
24         bool add_succ(FuncInst * other);
25
26         FuncInst * search_in_collision(ModelAction *act);
27
28         func_inst_list_mt * get_collisions() { return &collisions; }
29         func_inst_list_mt * get_preds() { return &predecessors; }
30         func_inst_list_mt * get_succs() { return &successors; }
31
32         bool is_read() const;
33         bool is_write() const;
34
35         void print();
36
37         MEMALLOC
38 private:
39         //ModelAction * const action;
40         const char * position;
41         void * location;
42         action_type type;
43         memory_order order;
44         FuncNode * func_node;
45
46         /* collisions store a list of FuncInsts with the same position
47          * but different action types. For example, CAS is broken down
48          * as three different atomic operations in cmodelint.cc */
49         func_inst_list_mt collisions;
50
51         func_inst_list_mt predecessors;
52         func_inst_list_mt successors;
53 };
54
55 #endif  /* __FUNCINST_H__ */
56