Search in sources :

Example 41 with Register

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

the class VisitorLKMM method visitRMWAddUnless.

@Override
public List<Event> visitRMWAddUnless(RMWAddUnless e) {
    Register resultRegister = e.getResultRegister();
    Register dummy = e.getThread().newRegister(resultRegister.getPrecision());
    RMWReadCondUnless load = Linux.newRMWReadCondUnless(dummy, e.getCmp(), e.getAddress(), Tag.Linux.MO_ONCE);
    return eventSequence(Linux.newConditionalMemoryBarrier(load), load, Linux.newRMWStoreCond(load, e.getAddress(), new IExprBin(dummy, IOpBin.PLUS, (IExpr) e.getMemValue()), Tag.Linux.MO_ONCE), newLocal(resultRegister, new Atom(dummy, NEQ, e.getCmp())), Linux.newConditionalMemoryBarrier(load));
}
Also used : Register(com.dat3m.dartagnan.program.Register) RMWReadCondUnless(com.dat3m.dartagnan.program.event.lang.linux.cond.RMWReadCondUnless)

Example 42 with Register

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

the class VisitorPower 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 = e.getThread().newRegister(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 = newRMWLoadExclusive(regValue, address, null);
    Store store = newRMWStoreExclusive(address, value, null, true);
    Fence optionalMemoryBarrier = mo.equals(Tag.C11.MO_SC) ? Power.newSyncBarrier() : mo.equals(C11.MO_RELEASE) || mo.equals(C11.MO_ACQUIRE_RELEASE) ? Power.newLwSyncBarrier() : null;
    Fence optionalISyncBarrier = mo.equals(C11.MO_SC) || mo.equals(C11.MO_ACQUIRE) || mo.equals(C11.MO_ACQUIRE_RELEASE) ? Power.newISyncBarrier() : null;
    // --- Add success events ---
    return eventSequence(// Indentation shows the branching structure
    optionalMemoryBarrier, load, casCmpResult, branchOnCasCmpResult, store, optionalISyncBarrier, casEnd);
}
Also used : Register(com.dat3m.dartagnan.program.Register)

Example 43 with Register

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

the class VisitorTso 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, newJumpUnless(new Atom(resultRegister, EQ, IValue.ZERO), (Label) e.getThread().getExit()));
}
Also used : Register(com.dat3m.dartagnan.program.Register)

Example 44 with Register

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

the class VisitorTso method visitDat3mCAS.

@Override
public List<Event> visitDat3mCAS(Dat3mCAS e) {
    Register resultRegister = e.getResultRegister();
    IExpr address = e.getAddress();
    String mo = e.getMo();
    Register regValue = e.getThread().newRegister(resultRegister.getPrecision());
    Local casCmpResult = newLocal(resultRegister, new Atom(regValue, EQ, e.getExpectedValue()));
    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, e.getMemValue(), mo);
    return eventSequence(// Indentation shows the branching structure
    load, casCmpResult, branchOnCasCmpResult, store, casEnd);
}
Also used : Register(com.dat3m.dartagnan.program.Register) RMWStore(com.dat3m.dartagnan.program.event.core.rmw.RMWStore)

Example 45 with Register

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

the class VisitorLitmusC method visitReLoad.

@Override
public IExpr visitReLoad(LitmusCParser.ReLoadContext ctx) {
    Register register = getReturnRegister(true);
    Event event = EventFactory.newLoad(register, getAddress(ctx.address), ctx.mo);
    programBuilder.addChild(currentThread, event);
    return register;
}
Also used : Register(com.dat3m.dartagnan.program.Register) Event(com.dat3m.dartagnan.program.event.core.Event)

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