use of com.dat3m.dartagnan.program.Register in project Dat3M by hernanponcedeleon.
the class VisitorBoogie method visitVar_expr.
@Override
public Object visitVar_expr(Var_exprContext ctx) {
String name = ctx.getText();
if (currentCall != null && currentCall.getFunction().getBody() != null) {
return currentCall.replaceVarsByExprs(ctx);
}
if (constantsMap.containsKey(name)) {
return constantsMap.get(name);
}
if (constantsTypeMap.containsKey(name)) {
// Dummy register needed to parse axioms
return new Register(name, Register.NO_THREAD, constantsTypeMap.get(name));
}
Register register = programBuilder.getRegister(threadCount, currentScope.getID() + ":" + name);
if (register != null) {
return register;
}
MemoryObject object = programBuilder.getObject(name);
if (object != null) {
return object;
}
throw new ParsingException("Variable " + name + " is not defined");
}
use of com.dat3m.dartagnan.program.Register in project Dat3M by hernanponcedeleon.
the class VisitorBoogie method visitMain.
@Override
public Object visitMain(MainContext ctx) {
visitLine_comment(ctx.line_comment(0));
for (Func_declContext funDecContext : ctx.func_decl()) {
visitFunc_decl(funDecContext);
}
for (Proc_declContext procDecContext : ctx.proc_decl()) {
preProc_decl(procDecContext);
}
for (Const_declContext constDecContext : ctx.const_decl()) {
visitConst_decl(constDecContext);
}
for (Axiom_declContext axiomDecContext : ctx.axiom_decl()) {
visitAxiom_decl(axiomDecContext);
}
for (Var_declContext varDecContext : ctx.var_decl()) {
visitVar_decl(varDecContext);
}
if (!procedures.containsKey("main")) {
throw new ParsingException("Program shall have a main procedure");
}
Register next = programBuilder.getOrCreateRegister(threadCount, currentScope.getID() + ":" + "ptrMain", ARCH_PRECISION);
pool.add(next, "main", -1);
while (pool.canCreate()) {
next = pool.next();
String nextName = pool.getNameFromPtr(next);
pool.addIntPtr(threadCount + 1, next);
visitProc_decl(procedures.get(nextName), true, threadCallingValues.get(threadCount));
}
return programBuilder.build();
}
use of com.dat3m.dartagnan.program.Register in project Dat3M by hernanponcedeleon.
the class VisitorArm8 method visitAtomicCmpXchg.
@Override
public List<Event> visitAtomicCmpXchg(AtomicCmpXchg e) {
Register resultRegister = e.getResultRegister();
IExpr address = e.getAddress();
ExprInterface value = e.getMemValue();
String mo = e.getMo();
IExpr expectedAddr = e.getExpectedAddr();
int precision = resultRegister.getPrecision();
Register regExpected = e.getThread().newRegister(precision);
Register regValue = e.getThread().newRegister(precision);
Load loadExpected = newLoad(regExpected, expectedAddr, null);
Store storeExpected = newStore(expectedAddr, regValue, null);
Label casFail = newLabel("CAS_fail");
Label casEnd = newLabel("CAS_end");
Local casCmpResult = newLocal(resultRegister, new Atom(regValue, EQ, regExpected));
CondJump branchOnCasCmpResult = newJump(new Atom(resultRegister, NEQ, IValue.ONE), casFail);
CondJump gotoCasEnd = newGoto(casEnd);
Load loadValue = newRMWLoadExclusive(regValue, address, Tag.ARMv8.extractLoadMoFromCMo(mo));
Store storeValue = newRMWStoreExclusive(address, value, Tag.ARMv8.extractStoreMoFromCMo(mo), e.is(STRONG));
ExecutionStatus optionalExecStatus = null;
Local optionalUpdateCasCmpResult = null;
if (!e.is(STRONG)) {
Register statusReg = e.getThread().newRegister("status(" + e.getUId() + ")", precision);
optionalExecStatus = newExecutionStatus(statusReg, storeValue);
optionalUpdateCasCmpResult = newLocal(resultRegister, new BExprUn(BOpUn.NOT, statusReg));
}
return eventSequence(// Indentation shows the branching structure
loadExpected, loadValue, casCmpResult, branchOnCasCmpResult, storeValue, optionalExecStatus, optionalUpdateCasCmpResult, gotoCasEnd, casFail, storeExpected, casEnd);
}
use of com.dat3m.dartagnan.program.Register in project Dat3M by hernanponcedeleon.
the class VisitorArm8 method visitAtomicXchg.
@Override
public List<Event> visitAtomicXchg(AtomicXchg e) {
Register resultRegister = e.getResultRegister();
ExprInterface value = e.getMemValue();
IExpr address = e.getAddress();
String mo = e.getMo();
Load load = newRMWLoadExclusive(resultRegister, address, Tag.ARMv8.extractLoadMoFromCMo(mo));
Store store = newRMWStoreExclusive(address, value, Tag.ARMv8.extractStoreMoFromCMo(mo), true);
Label label = newLabel("FakeDep");
Event fakeCtrlDep = newFakeCtrlDep(resultRegister, label);
return eventSequence(load, fakeCtrlDep, label, store);
}
use of com.dat3m.dartagnan.program.Register in project Dat3M by hernanponcedeleon.
the class VisitorArm8 method visitAtomicFetchOp.
@Override
public List<Event> visitAtomicFetchOp(AtomicFetchOp e) {
Register resultRegister = e.getResultRegister();
IOpBin op = e.getOp();
IExpr value = (IExpr) e.getMemValue();
IExpr address = e.getAddress();
String mo = e.getMo();
Register dummyReg = e.getThread().newRegister(resultRegister.getPrecision());
Local localOp = newLocal(dummyReg, new IExprBin(resultRegister, op, value));
Load load = newRMWLoadExclusive(resultRegister, address, Tag.ARMv8.extractLoadMoFromCMo(mo));
Store store = newRMWStoreExclusive(address, dummyReg, Tag.ARMv8.extractStoreMoFromCMo(mo), true);
Label label = newLabel("FakeDep");
Event fakeCtrlDep = newFakeCtrlDep(resultRegister, label);
return eventSequence(load, fakeCtrlDep, label, localOp, store);
}
Aggregations