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