fix merge issue
[c11tester.git] / funcnode.cc
index 843e1c94a2d6616af8cd446df74dfee318d20a2e..e07ab9e22b13c9775e591e35ca81eba44fc43252 100644 (file)
@@ -4,10 +4,11 @@ FuncNode::FuncNode() :
        func_inst_map(),
        inst_list(),
        entry_insts(),
+       thrd_read_map(),
        read_locations()
 {}
 
-/* Check whether FuncInst with the same type, position, and location 
+/* Check whether FuncInst with the same type, position, and location
  * as act has been added to func_inst_map or not. If so, return it;
  * if not, add it and return it.
  *
@@ -61,7 +62,7 @@ void FuncNode::add_entry_inst(FuncInst * inst)
                return;
 
        func_inst_list_mt::iterator it;
-       for (it = entry_insts.begin(); it != entry_insts.end(); it++) {
+       for (it = entry_insts.begin();it != entry_insts.end();it++) {
                if (inst == *it)
                        return;
        }
@@ -69,6 +70,39 @@ void FuncNode::add_entry_inst(FuncInst * inst)
        entry_insts.push_back(inst);
 }
 
+/* @param inst_list a list of FuncInsts; this argument comes from ModelExecution
+ * Link FuncInsts in a list - add one FuncInst to another's predecessors and successors
+ */
+void FuncNode::link_insts(func_inst_list_t * inst_list)
+{
+       if (inst_list == NULL)
+               return;
+
+       func_inst_list_t::iterator it = inst_list->begin();
+       func_inst_list_t::iterator prev;
+
+       if (inst_list->size() == 0)
+               return;
+
+       /* add the first instruction to the list of entry insts */
+       FuncInst * entry_inst = *it;
+       add_entry_inst(entry_inst);
+
+       it++;
+       while (it != inst_list->end()) {
+               prev = it;
+               prev--;
+
+               FuncInst * prev_inst = *prev;
+               FuncInst * curr_inst = *it;
+
+               prev_inst->add_succ(curr_inst);
+               curr_inst->add_pred(prev_inst);
+
+               it++;
+       }
+}
+
 /* @param tid thread id
  * Store the values read by atomic read actions into thrd_read_map */
 void FuncNode::store_read(ModelAction * act, uint32_t tid)
@@ -130,7 +164,7 @@ void FuncNode::clear_read_map(uint32_t tid)
 }
 
 /* @param tid thread id
- * Print the values read by the last read actions per memory location
+ * Print the values read by the last read actions for each memory location
  */
 void FuncNode::print_last_read(uint32_t tid)
 {