Search in sources :

Example 31 with Register

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

the class VisitorArm8 method visitJoin.

@Override
public List<Event> visitJoin(Join e) {
    Register resultRegister = e.getResultRegister();
    Load load = newLoad(resultRegister, e.getAddress(), e.getMo());
    load.addFilters(C11.PTHREAD);
    return eventSequence(load, AArch64.DMB.newISHBarrier(), newJumpUnless(new Atom(resultRegister, EQ, IValue.ZERO), (Label) e.getThread().getExit()));
}
Also used : Register(com.dat3m.dartagnan.program.Register)

Example 32 with Register

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

the class VisitorBase method visitRMW.

@Override
public List<Event> visitRMW(RMW e) {
    Register resultRegister = e.getResultRegister();
    IExpr address = e.getAddress();
    String mo = e.getMo();
    Register dummyReg = e.getThread().newRegister(resultRegister.getPrecision());
    Load load = newRMWLoad(dummyReg, address, mo);
    RMWStore store = newRMWStore(load, address, e.getMemValue(), mo);
    return eventSequence(load, store, newLocal(resultRegister, dummyReg));
}
Also used : Load(com.dat3m.dartagnan.program.event.core.Load) Register(com.dat3m.dartagnan.program.Register) RMWStore(com.dat3m.dartagnan.program.event.core.rmw.RMWStore) IExpr(com.dat3m.dartagnan.expression.IExpr)

Example 33 with Register

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

the class VisitorBase method visitLock.

@Override
public List<Event> visitLock(Lock e) {
    Register resultRegister = e.getResultRegister();
    String mo = e.getMo();
    List<Event> events = eventSequence(newLoad(resultRegister, e.getAddress(), mo), newJump(new Atom(resultRegister, NEQ, IValue.ZERO), (Label) e.getThread().getExit()), newStore(e.getAddress(), IValue.ONE, mo));
    for (Event child : events) {
        child.addFilters(C11.LOCK, RMW);
    }
    return events;
}
Also used : Register(com.dat3m.dartagnan.program.Register) Label(com.dat3m.dartagnan.program.event.core.Label) Event(com.dat3m.dartagnan.program.event.core.Event) Atom(com.dat3m.dartagnan.expression.Atom)

Example 34 with Register

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

the class VisitorC11 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 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 = 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 35 with Register

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

the class VisitorIMM method visitAtomicCmpXchg.

@Override
public List<Event> visitAtomicCmpXchg(AtomicCmpXchg e) {
    Register resultRegister = e.getResultRegister();
    IExpr address = e.getAddress();
    String mo = e.getMo();
    Fence optionalFenceLoad = mo.equals(Tag.C11.MO_SC) ? newFence(Tag.C11.MO_SC) : null;
    Fence optionalFenceStore = mo.equals(Tag.C11.MO_SC) ? newFence(Tag.C11.MO_SC) : null;
    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);
    loadExpected.addFilters(Tag.IMM.CASDEPORIGIN);
    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, extractLoadMo(mo));
    Store storeValue = newRMWStore(loadValue, address, e.getMemValue(), extractStoreMo(mo));
    return eventSequence(// Indentation shows the branching structure
    loadExpected, optionalFenceLoad, loadValue, casCmpResult, branchOnCasCmpResult, optionalFenceStore, storeValue, gotoCasEnd, casFail, storeExpected, casEnd);
}
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