split add_action_to_lists into to two functions and change the order of how things...
[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         const char * get_position() const { return position; }
17
18         void * get_location() const { return location; }
19         void set_location(void * loc) { location = loc; }
20         void unset_location() { location = NULL; }
21
22         action_type get_type() const { return type; }
23         memory_order get_mo() const { return order; }
24         FuncNode * get_func_node() const { return func_node; }
25
26         bool add_pred(FuncInst * other);
27         bool add_succ(FuncInst * other);
28
29         //FuncInst * search_in_collision(ModelAction *act);
30         //func_inst_list_mt * get_collisions() { return &collisions; }
31
32         func_inst_list_mt * get_preds() { return &predecessors; }
33         func_inst_list_mt * get_succs() { return &successors; }
34
35         bool is_read() const;
36         bool is_write() const;
37         bool is_single_location() { return single_location; }
38         void not_single_location() { single_location = false; }
39
40         void print();
41
42         MEMALLOC
43 private:
44         const char * position;
45
46         /* Atomic operations with the same source line number may act at different
47          * memory locations, such as the next field of the head pointer in ms-queue. 
48          * location only stores the memory location when this FuncInst was constructed.
49          */
50         void * location;
51         action_type type;
52         memory_order order;
53         FuncNode * func_node;
54
55         bool single_location;
56
57         /* Currently not in use. May remove this field later
58          *
59          * collisions store a list of FuncInsts with the same position
60          * but different action types. For example, CAS is broken down
61          * as three different atomic operations in cmodelint.cc */
62         // func_inst_list_mt collisions;
63
64         func_inst_list_mt predecessors;
65         func_inst_list_mt successors;
66 };
67
68 #endif  /* __FUNCINST_H__ */
69