use of com.dat3m.dartagnan.program.event.core.Event in project Dat3M by hernanponcedeleon.
the class VisitorLitmusC method visitNreWriteOnce.
@Override
public Object visitNreWriteOnce(LitmusCParser.NreWriteOnceContext ctx) {
ExprInterface value = (ExprInterface) ctx.value.accept(this);
Event event = EventFactory.newStore(getAddress(ctx.address), value, ctx.mo);
return programBuilder.addChild(currentThread, event);
}
use of com.dat3m.dartagnan.program.event.core.Event in project Dat3M by hernanponcedeleon.
the class VisitorLitmusC method visitReXchg.
@Override
public IExpr visitReXchg(LitmusCParser.ReXchgContext ctx) {
Register register = getReturnRegister(true);
IExpr value = (IExpr) ctx.value.accept(this);
Event event = EventFactory.Linux.newRMWExchange(getAddress(ctx.address), register, value, ctx.mo);
programBuilder.addChild(currentThread, event);
return register;
}
use of com.dat3m.dartagnan.program.event.core.Event in project Dat3M by hernanponcedeleon.
the class VisitorLitmusC method visitNreAssignment.
@Override
public Object visitNreAssignment(LitmusCParser.NreAssignmentContext ctx) {
ExprInterface variable = (ExprInterface) ctx.varName().accept(this);
if (ctx.Ast() == null) {
if (variable instanceof Register) {
returnRegister = (Register) variable;
ctx.re().accept(this);
return null;
}
throw new ParsingException("Invalid syntax near " + ctx.getText());
}
ExprInterface value = (ExprInterface) ctx.re().accept(this);
if (variable instanceof MemoryObject || variable instanceof Register) {
Event event = EventFactory.newStore((IExpr) variable, value, "NA");
return programBuilder.addChild(currentThread, event);
}
throw new ParsingException("Invalid syntax near " + ctx.getText());
}
use of com.dat3m.dartagnan.program.event.core.Event in project Dat3M by hernanponcedeleon.
the class PthreadsProcedures method pthread_create.
private static void pthread_create(VisitorBoogie visitor, Call_cmdContext ctx) {
visitor.currentThread++;
visitor.threadCallingValues.put(visitor.currentThread, new ArrayList<>());
String namePtr = ctx.call_params().exprs().expr().get(0).getText();
// This names are global so we don't use currentScope.getID(), but per thread.
Register threadPtr = visitor.programBuilder.getOrCreateRegister(visitor.threadCount, namePtr, ARCH_PRECISION);
String threadName = ctx.call_params().exprs().expr().get(2).getText();
ExprInterface callingValue = (ExprInterface) ctx.call_params().exprs().expr().get(3).accept(visitor);
visitor.threadCallingValues.get(visitor.currentThread).add(callingValue);
visitor.pool.add(threadPtr, threadName, visitor.threadCount);
Register reg = visitor.programBuilder.getOrCreateRegister(visitor.threadCount, visitor.currentScope.getID() + ":" + ctx.call_params().Ident(0).getText(), ARCH_PRECISION);
// We assume pthread_create always succeeds
visitor.programBuilder.addChild(visitor.threadCount, EventFactory.newLocal(reg, IValue.ZERO));
MemoryObject object = visitor.programBuilder.getOrNewObject(String.format("%s(%s)_active", threadPtr, visitor.pool.getCreatorFromPtr(threadPtr)));
Event child = EventFactory.Pthread.newCreate(threadPtr, threadName, object);
child.setCLine(visitor.currentLine);
visitor.programBuilder.addChild(visitor.threadCount, child);
}
use of com.dat3m.dartagnan.program.event.core.Event in project Dat3M by hernanponcedeleon.
the class BranchEquivalence method computeBranches.
// ========================== Branching Property =========================
private Branch computeBranches(Event start, Map<Event, Branch> branchMap, Map<Event, Branch> finalBranchMap) {
if (branchMap.containsKey(start)) {
// <start> was already visited
return branchMap.get(start);
}
Branch b = new Branch(start);
branchMap.put(start, b);
Event succ = start;
do {
if (succ instanceof CondJump) {
CondJump jump = (CondJump) succ;
if (!alwaysSplitOnJump && jump.isGoto()) {
// There is only one branch we can proceed on, so we don't need to split the current branch
succ = jump.getLabel();
} else {
// Split into two branches...
Branch b1 = computeBranches(jump.getSuccessor(), branchMap, finalBranchMap);
Branch b2 = computeBranches(jump.getLabel(), branchMap, finalBranchMap);
b1.parents.add(b);
b.children.add(b1);
b2.parents.add(b);
b.children.add(b2);
return b;
}
} else {
// No branching happened, thus we stay on the current branch
succ = succ.getSuccessor();
}
if (succ == null) {
finalBranchMap.put(b.events.get(b.events.size() - 1), b);
return b;
} else if ((succ instanceof Label && !((Label) succ).getJumpSet().isEmpty()) || branchMap.containsKey(succ)) {
// We ran into a merge point
Branch b1 = computeBranches(succ, branchMap, finalBranchMap);
b1.parents.add(b);
b.children.add(b1);
return b;
} else {
b.events.add(succ);
}
} while (true);
}
Aggregations