4 FuncInst::FuncInst(ModelAction *act, FuncNode *func_node) :
8 thrd_marker() /* The marker for FuncNode starts from 1 */
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, uint64_t read_val, uint32_t marker)
53 int thread_id = id_to_int(tid);
54 int old_size = associated_reads.size();
56 if (old_size < thread_id + 1) {
57 for (int i = old_size; i < thread_id + 1; i++ ) {
58 associated_reads.push_back(VALUE_NONE);
59 thrd_marker.push_back(0);
63 thrd_marker[thread_id] = marker;
64 associated_reads[thread_id] = read_val;
67 uint64_t FuncInst::get_associated_read(thread_id_t tid, uint32_t marker)
69 int thread_id = id_to_int(tid);
71 if (thrd_marker[thread_id] == marker)
72 return associated_reads[thread_id];
77 /* Search the FuncInst that has the same type as act in the collision list */
78 FuncInst * FuncInst::search_in_collision(ModelAction *act)
80 action_type type = act->get_type();
82 mllnode<FuncInst*> * it;
83 for (it = collisions.begin();it != NULL;it = it->getNext()) {
84 FuncInst * inst = it->getVal();
85 if (inst->get_type() == type)
91 void FuncInst::add_to_collision(FuncInst * inst)
93 collisions.push_back(inst);
96 /* Note: is_read() is equivalent to ModelAction::is_read() */
97 bool FuncInst::is_read() const
99 return type == ATOMIC_READ || type == ATOMIC_RMWR || type == ATOMIC_RMWRCAS || type == ATOMIC_RMW;
102 /* Note: because of action type conversion in ModelExecution
103 * is_write() <==> pure writes (excluding rmw) */
104 bool FuncInst::is_write() const
106 return type == ATOMIC_WRITE || type == ATOMIC_RMW || type == ATOMIC_INIT || type == NONATOMIC_WRITE;
109 void FuncInst::print()
111 model_print("func inst - pos: %s, loc: %p, type: %d,\n", position, location, type);