Search in sources :

Example 76 with Register

use of com.dat3m.dartagnan.program.Register in project Dat3M by hernanponcedeleon.

the class VisitorNone method visitRMWFetchOp.

@Override
public List<Event> visitRMWFetchOp(RMWFetchOp e) {
    Register resultRegister = e.getResultRegister();
    String mo = e.getMo();
    IExpr address = e.getAddress();
    ExprInterface value = e.getMemValue();
    Register dummy = resultRegister;
    if (resultRegister == value) {
        dummy = new Register(null, resultRegister.getThreadId(), resultRegister.getPrecision());
    }
    Fence optionalMbBefore = mo.equals(Tag.Linux.MO_MB) ? Linux.newMemoryBarrier() : null;
    Load load = newRMWLoad(dummy, address, Tag.Linux.loadMO(mo));
    Local optionalUpdateReg = dummy != resultRegister ? newLocal(resultRegister, dummy) : null;
    Fence optionalMbAfter = mo.equals(Tag.Linux.MO_MB) ? Linux.newMemoryBarrier() : null;
    return eventSequence(optionalMbBefore, load, newRMWStore(load, address, new IExprBin(dummy, e.getOp(), (IExpr) value), Tag.Linux.storeMO(mo)), optionalUpdateReg, optionalMbAfter);
}
Also used : Register(com.dat3m.dartagnan.program.Register)

Example 77 with Register

use of com.dat3m.dartagnan.program.Register in project Dat3M by hernanponcedeleon.

the class VisitorNone method visitDat3mCAS.

@Override
public List<Event> visitDat3mCAS(Dat3mCAS e) {
    Register resultRegister = e.getResultRegister();
    ExprInterface value = e.getMemValue();
    IExpr address = e.getAddress();
    String mo = e.getMo();
    ExprInterface expectedValue = e.getExpectedValue();
    Register regValue = new Register(null, resultRegister.getThreadId(), resultRegister.getPrecision());
    Local casCmpResult = newLocal(resultRegister, new Atom(regValue, EQ, expectedValue));
    Label casEnd = newLabel("CAS_end");
    CondJump branchOnCasCmpResult = newJump(new Atom(resultRegister, NEQ, IValue.ONE), casEnd);
    Load load = newRMWLoad(regValue, address, mo);
    Store store = newRMWStore(load, address, value, mo);
    return eventSequence(// Indentation shows the branching structure
    load, casCmpResult, branchOnCasCmpResult, store, casEnd);
}
Also used : Register(com.dat3m.dartagnan.program.Register)

Example 78 with Register

use of com.dat3m.dartagnan.program.Register in project Dat3M by hernanponcedeleon.

the class VisitorNone method visitRMWOpReturn.

@Override
public List<Event> visitRMWOpReturn(RMWOpReturn e) {
    Register resultRegister = e.getResultRegister();
    IExpr address = e.getAddress();
    String mo = e.getMo();
    Register dummy = new Register(null, resultRegister.getThreadId(), resultRegister.getPrecision());
    Fence optionalMbBefore = mo.equals(Tag.Linux.MO_MB) ? Linux.newMemoryBarrier() : null;
    Load load = newRMWLoad(dummy, address, Tag.Linux.loadMO(mo));
    Fence optionalMbAfter = mo.equals(Tag.Linux.MO_MB) ? Linux.newMemoryBarrier() : null;
    return eventSequence(optionalMbBefore, load, newLocal(resultRegister, new IExprBin(dummy, e.getOp(), (IExpr) e.getMemValue())), newRMWStore(load, address, resultRegister, Tag.Linux.storeMO(mo)), optionalMbAfter);
}
Also used : Register(com.dat3m.dartagnan.program.Register)

Example 79 with Register

use of com.dat3m.dartagnan.program.Register in project Dat3M by hernanponcedeleon.

the class VisitorNone method visitAtomicCmpXchg.

@Override
public List<Event> visitAtomicCmpXchg(AtomicCmpXchg e) {
    Register resultRegister = e.getResultRegister();
    IExpr address = e.getAddress();
    String mo = e.getMo();
    IExpr expectedAddr = e.getExpectedAddr();
    int threadId = resultRegister.getThreadId();
    int precision = resultRegister.getPrecision();
    Register regExpected = new Register(null, threadId, precision);
    Register regValue = new Register(null, threadId, 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 = newRMWLoad(regValue, address, mo);
    Store storeValue = newRMWStore(loadValue, address, e.getMemValue(), mo);
    return eventSequence(// Indentation shows the branching structure
    loadExpected, loadValue, casCmpResult, branchOnCasCmpResult, storeValue, gotoCasEnd, casFail, storeExpected, casEnd);
}
Also used : Register(com.dat3m.dartagnan.program.Register)

Example 80 with Register

use of com.dat3m.dartagnan.program.Register in project Dat3M by hernanponcedeleon.

the class VisitorNone method visitRMWOpAndTest.

@Override
public List<Event> visitRMWOpAndTest(RMWOpAndTest e) {
    Register resultRegister = e.getResultRegister();
    IExpr address = e.getAddress();
    int precision = resultRegister.getPrecision();
    Register dummy = new Register(null, resultRegister.getThreadId(), precision);
    Load load = newRMWLoad(dummy, address, Tag.Linux.MO_RELAXED);
    // TODO: Are the memory barriers really unconditional?
    return eventSequence(Linux.newMemoryBarrier(), load, newLocal(dummy, new IExprBin(dummy, e.getOp(), (IExpr) e.getMemValue())), newRMWStore(load, address, dummy, Tag.Linux.MO_RELAXED), newLocal(resultRegister, new Atom(dummy, EQ, new IValue(BigInteger.ZERO, precision))), Linux.newMemoryBarrier());
}
Also used : 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