4 FuncInst::FuncInst(ModelAction *act, FuncNode *func_node) :
12 this->position = act->get_position();
13 this->location = act->get_location();
14 this->type = act->get_type();
15 this->order = act->get_mo();
16 this->func_node = func_node;
19 /* @param other Preceding FuncInst in the same execution trace
20 * Add other to predecessors if it has been added
22 * @return false: other is already in predecessors
23 * true : other is added to precedessors
25 bool FuncInst::add_pred(FuncInst * other)
27 mllnode<FuncInst*> * it;
28 for (it = predecessors.begin();it != NULL;it=it->getNext()) {
29 FuncInst * inst = it->getVal();
34 predecessors.push_back(other);
38 bool FuncInst::add_succ(FuncInst * other)
40 mllnode<FuncInst*>* it;
41 for (it = successors.begin();it != NULL;it=it->getNext()) {
42 FuncInst * inst = it->getVal();
47 successors.push_back(other);
51 void FuncInst::set_associated_read(thread_id_t tid, int index, uint32_t marker, uint64_t read_val)
53 int thread_id = id_to_int(tid);
55 if (associated_reads.size() < (uint) thread_id + 1) {
56 int old_size = associated_reads.size();
57 int new_size = thread_id + 1;
59 associated_reads.resize(new_size);
60 thrd_markers.resize(new_size);
62 for (int i = old_size; i < new_size; i++ ) {
63 associated_reads[i] = new ModelVector<uint64_t>();
64 thrd_markers[i] = new ModelVector<uint32_t>();
68 ModelVector<uint64_t> * read_values = associated_reads[thread_id];
69 ModelVector<uint32_t> * markers = thrd_markers[thread_id];
70 if (read_values->size() < (uint) index + 1) {
71 int old_size = read_values->size();
73 for (int i = old_size; i < index + 1; i++) {
74 read_values->push_back(VALUE_NONE);
75 markers->push_back(0);
79 (*read_values)[index] = read_val;
80 (*markers)[index] = marker;
83 uint64_t FuncInst::get_associated_read(thread_id_t tid, int index, uint32_t marker)
85 int thread_id = id_to_int(tid);
87 if ( (*thrd_markers[thread_id])[index] == marker)
88 return (*associated_reads[thread_id])[index];
93 /* Search the FuncInst that has the same type as act in the collision list */
94 FuncInst * FuncInst::search_in_collision(ModelAction *act)
96 action_type type = act->get_type();
98 mllnode<FuncInst*> * it;
99 for (it = collisions.begin();it != NULL;it = it->getNext()) {
100 FuncInst * inst = it->getVal();
101 if (inst->get_type() == type)
107 void FuncInst::add_to_collision(FuncInst * inst)
109 collisions.push_back(inst);
112 /* Note: is_read() is equivalent to ModelAction::is_read() */
113 bool FuncInst::is_read() const
115 return type == ATOMIC_READ || type == ATOMIC_RMWR || type == ATOMIC_RMWRCAS || type == ATOMIC_RMW;
118 /* Note: because of action type conversion in ModelExecution
119 * is_write() <==> pure writes (excluding rmw) */
120 bool FuncInst::is_write() const
122 return type == ATOMIC_WRITE || type == ATOMIC_RMW || type == ATOMIC_INIT || type == NONATOMIC_WRITE;
125 void FuncInst::print()
127 model_print("func inst - pos: %s, loc: %p, type: %d,\n", position, location, type);