Do not unset FuncInst locations when new executions start; check if execution numbers...
[c11tester.git] / funcinst.cc
1 #include "funcinst.h"
2 #include "model.h"
3
4 FuncInst::FuncInst(ModelAction *act, FuncNode *func_node) :
5         single_location(true),
6         execution_number(model->get_execution_number())
7 {
8         ASSERT(act);
9         ASSERT(func_node);
10         this->position = act->get_position();
11         this->location = act->get_location();
12         this->type = act->get_type();
13         this->order = act->get_mo();
14         this->func_node = func_node;
15 }
16
17 /* @param other Preceding FuncInst in the same execution trace
18  * Add other to predecessors if it has been added
19  *
20  * @return false: other is already in predecessors
21  *         true : other is added to precedessors
22  */
23 bool FuncInst::add_pred(FuncInst * other)
24 {
25         mllnode<FuncInst*> * it;
26         for (it = predecessors.begin();it != NULL;it=it->getNext()) {
27                 FuncInst * inst = it->getVal();
28                 if (inst == other)
29                         return false;
30         }
31
32         predecessors.push_back(other);
33         return true;
34 }
35
36 bool FuncInst::add_succ(FuncInst * other)
37 {
38         mllnode<FuncInst*>* it;
39         for (it = successors.begin();it != NULL;it=it->getNext()) {
40                 FuncInst * inst = it->getVal();
41                 if ( inst == other )
42                         return false;
43         }
44
45         successors.push_back(other);
46         return true;
47 }
48
49 /*
50 FuncInst * FuncInst::search_in_collision(ModelAction *act)
51 {
52         action_type type = act->get_type();
53
54         mllnode<FuncInst*> * it;
55         for (it = collisions.begin(); it != NULL; it = it->getNext()) {
56                 FuncInst * inst = it->getVal();
57                 if (inst->get_type() == type)
58                         return inst;
59         }
60         return NULL;
61 }
62 */
63
64 /* Note: is_read() is equivalent to ModelAction::is_read() */
65 bool FuncInst::is_read() const
66 {
67         return type == ATOMIC_READ || type == ATOMIC_RMWR || type == ATOMIC_RMWRCAS || type == ATOMIC_RMW;
68 }
69
70 /* Note: because of action type conversion in ModelExecution
71  * is_write() <==> pure writes (excluding rmw) */
72 bool FuncInst::is_write() const
73 {
74         return type == ATOMIC_WRITE || type == ATOMIC_RMW || type == ATOMIC_INIT || type == ATOMIC_UNINIT || type == NONATOMIC_WRITE;
75 }
76
77 void FuncInst::print()
78 {
79         model_print("func inst - pos: %s, loc: %p, type: %d,\n", position, location, type);
80 }