Add back model_thread; it is still needed
[c11tester.git] / funcinst.h
1 #ifndef __FUNCINST_H__
2 #define __FUNCINST_H__
3
4 #include "action.h"
5 #include "classlist.h"
6 #include "hashtable.h"
7 #include "threads-model.h"
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         void add_to_collision(FuncInst * inst);
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 set_associated_read(thread_id_t tid, int index, uint32_t marker, uint64_t read_val);
43         uint64_t get_associated_read(thread_id_t tid, int index, uint32_t marker);
44
45         void print();
46
47         MEMALLOC
48 private:
49         const char * position;
50
51         /* Atomic operations with the same source line number may act at different
52          * memory locations, such as the next field of the head pointer in ms-queue.
53          * location only stores the memory location when this FuncInst was constructed.
54          */
55         void * location;
56
57         /* NOTE: for rmw actions, func_inst and act may have different
58          * action types because of action type conversion in ModelExecution */
59         action_type type;
60
61         memory_order order;
62         FuncNode * func_node;
63
64         bool single_location;
65         int execution_number;
66
67         ModelVector< ModelVector<uint64_t> * > associated_reads;
68         ModelVector< ModelVector<uint32_t> * > thrd_markers;
69
70         /**
71          * Collisions store a list of FuncInsts with the same position
72          * but different action types. For example,
73          * <code>volatile int x; x++;</code> produces read and write
74          * actions with the same position.
75          */
76         func_inst_list_mt collisions;
77
78         func_inst_list_mt predecessors;
79         func_inst_list_mt successors;
80 };
81
82 #endif  /* __FUNCINST_H__ */