Search in sources :

Example 26 with Register

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");
}
Also used : Register(com.dat3m.dartagnan.program.Register) ParsingException(com.dat3m.dartagnan.exception.ParsingException) MemoryObject(com.dat3m.dartagnan.program.memory.MemoryObject)

Example 27 with Register

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();
}
Also used : Register(com.dat3m.dartagnan.program.Register) ParsingException(com.dat3m.dartagnan.exception.ParsingException)

Example 28 with Register

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);
}
Also used : Register(com.dat3m.dartagnan.program.Register)

Example 29 with Register

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);
}
Also used : Register(com.dat3m.dartagnan.program.Register)

Example 30 with Register

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);
}
Also used : IOpBin(com.dat3m.dartagnan.expression.op.IOpBin) Register(com.dat3m.dartagnan.program.Register)

Aggregations

Register (com.dat3m.dartagnan.program.Register)154 MemoryObject (com.dat3m.dartagnan.program.memory.MemoryObject)29 Event (com.dat3m.dartagnan.program.event.core.Event)25 IExpr (com.dat3m.dartagnan.expression.IExpr)16 RegWriter (com.dat3m.dartagnan.program.event.core.utils.RegWriter)15 ProgramBuilder (com.dat3m.dartagnan.parsers.program.utils.ProgramBuilder)13 AliasAnalysis (com.dat3m.dartagnan.program.analysis.AliasAnalysis)12 Label (com.dat3m.dartagnan.program.event.core.Label)11 ParsingException (com.dat3m.dartagnan.exception.ParsingException)10 BigInteger (java.math.BigInteger)8 IConst (com.dat3m.dartagnan.expression.IConst)7 IExprBin (com.dat3m.dartagnan.expression.IExprBin)6 IValue (com.dat3m.dartagnan.expression.IValue)6 IOpBin (com.dat3m.dartagnan.expression.op.IOpBin)6 Program (com.dat3m.dartagnan.program.Program)6 Dependency (com.dat3m.dartagnan.program.analysis.Dependency)6 ExprInterface (com.dat3m.dartagnan.expression.ExprInterface)5 Thread (com.dat3m.dartagnan.program.Thread)5 java.util (java.util)5 Atom (com.dat3m.dartagnan.expression.Atom)4