Toward computing which threads a paused thread may wait for
[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
21         action_type get_type() const { return type; }
22         memory_order get_mo() const { return order; }
23         FuncNode * get_func_node() const { return func_node; }
24
25         bool add_pred(FuncInst * other);
26         bool add_succ(FuncInst * other);
27
28         //FuncInst * search_in_collision(ModelAction *act);
29         //func_inst_list_mt * get_collisions() { return &collisions; }
30
31         func_inst_list_mt * get_preds() { return &predecessors; }
32         func_inst_list_mt * get_succs() { return &successors; }
33
34         bool is_read() const;
35         bool is_write() const;
36         bool is_single_location() { return single_location; }
37         void not_single_location() { single_location = false; }
38
39         void set_execution_number(int new_number) { execution_number = new_number; }
40         int get_execution_number() { return execution_number; }
41
42         void print();
43
44         MEMALLOC
45 private:
46         const char * position;
47
48         /* Atomic operations with the same source line number may act at different
49          * memory locations, such as the next field of the head pointer in ms-queue. 
50          * location only stores the memory location when this FuncInst was constructed.
51          */
52         void * location;
53
54         /* NOTE: for rmw actions, func_inst and act may have different
55          * action types because of action type conversion in ModelExecution */
56         action_type type;
57
58         memory_order order;
59         FuncNode * func_node;
60
61         bool single_location;
62         int execution_number;
63
64         /* Currently not in use. May remove this field later
65          *
66          * collisions store a list of FuncInsts with the same position
67          * but different action types. For example, CAS is broken down
68          * as three different atomic operations in cmodelint.cc */
69         // func_inst_list_mt collisions;
70
71         func_inst_list_mt predecessors;
72         func_inst_list_mt successors;
73 };
74
75 #endif  /* __FUNCINST_H__ */