LoadRF::LoadRF(EPRecord *_load, ConstGen *cg) : load(_load) {
RecordSet *mrfSet=cg->getMayReadFromSet(load);
uint numstores=mrfSet->getSize();
- numvars=NUMBITS(numstores-1);
+ numvars=NUMBITS(numstores);
vars=(Constraint **)model_malloc(numvars*sizeof(Constraint *));
cg->getArrayNewVars(numvars, vars);
}
StoreLoadSet * sls=cg->getStoreLoadSet(load);
uint numvalvars=sls->getNumValVars();
uint numaddrvars=sls->getNumAddrVars();
- Constraint ** loadvalvars=(load->getType()==RMW)?sls->getRMWRValVars(cg, load):sls->getValVars(cg, load);
+ Constraint ** loadvalvars=(load->getType()==RMW) ? sls->getRMWRValVars(cg, load) : sls->getValVars(cg, load);
Constraint ** loadaddrvars=sls->getAddrVars(cg, load);
RecordIterator *sri=mrfSet->iterator();
Constraint ** storevalvars=sls->getValVars(cg, store);
- Constraint *rfconst=(numvars==0)?&ctrue:generateConstraint(numvars, vars, storeindex);
+ Constraint *rfconst=(numvars==0) ? &ctrue : generateConstraint(numvars, vars, storeindex);
//if we read from a store, it should happen before us
#ifdef TSO
Constraint *storebeforeload;
//ordered between the load and store
RecordSet *conflictSet=cg->computeConflictSet(store, load, mrfSet);
- RecordIterator *sit=conflictSet!=NULL?conflictSet->iterator():mrfSet->iterator();
+ RecordIterator *sit=conflictSet!=NULL ? conflictSet->iterator() : mrfSet->iterator();
while(sit->hasNext()) {
EPRecord *conflictstore=sit->next();
Constraint * storebeforeconflict=cg->getOrderConstraint(store, conflictstore);
if (storebeforeconflict->isFalse())
continue;
- Constraint * conflictbeforeload=cg->getOrderConstraint(conflictstore, load);
+#ifdef TSO
+ //Have to cover the same thread case
+ Constraint *conflictbeforeload;
+ if (conflictstore->getEP()->get_tid()==load->getEP()->get_tid()) {
+ if (conflictstore->getEP()->compare(load->getEP())==CR_AFTER)
+ conflictbeforeload=&ctrue;
+ else
+ conflictbeforeload=&cfalse;
+ } else {
+ conflictbeforeload=cg->getOrderConstraint(conflictstore, load);
+ }
if (conflictbeforeload->isFalse()) {
storebeforeconflict->freerec();
continue;
}
-
+#else
+ Constraint * conflictbeforeload=cg->getOrderConstraint(conflictstore, load);
+ if (conflictbeforeload->isFalse()) {
+ storebeforeconflict->freerec();
+ continue;
+ }
+#endif
rfconst=generateConstraint(numvars, vars, storeindex);
Constraint *array[]={storebeforeconflict,
conflictbeforeload,
rfconst,
cg->getExecutionConstraint(conflictstore)};
- Constraint *confstore=new Constraint(IMPLIES,
+ Constraint *confstore=new Constraint(IMPLIES,
new Constraint(AND, 4, array),
generateEquivConstraint(numaddrvars, loadaddrvars, confstoreaddrvars)->negate());
-
+
ADDCONSTRAINT2(cg, confstore, "confstore");
}
delete sit;