Search in sources :

Example 1 with Atom

use of com.dat3m.dartagnan.expression.Atom 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 2 with Atom

use of com.dat3m.dartagnan.expression.Atom in project Dat3M by hernanponcedeleon.

the class VisitorLitmusPPC method visitBranchCond.

@Override
public Object visitBranchCond(LitmusPPCParser.BranchCondContext ctx) {
    Label label = programBuilder.getOrCreateLabel(ctx.Label().getText());
    Event lastEvent = programBuilder.getLastEvent(mainThread);
    if (!(lastEvent instanceof Cmp)) {
        throw new ParsingException("Invalid syntax near " + ctx.getText());
    }
    Cmp cmp = (Cmp) lastEvent;
    Atom expr = new Atom(cmp.getLeft(), ctx.cond().op, cmp.getRight());
    return programBuilder.addChild(mainThread, EventFactory.newJump(expr, label));
}
Also used : Cmp(com.dat3m.dartagnan.program.event.core.Cmp) ParsingException(com.dat3m.dartagnan.exception.ParsingException) Label(com.dat3m.dartagnan.program.event.core.Label) Event(com.dat3m.dartagnan.program.event.core.Event) Atom(com.dat3m.dartagnan.expression.Atom)

Example 3 with Atom

use of com.dat3m.dartagnan.expression.Atom in project Dat3M by hernanponcedeleon.

the class VisitorLitmusAArch64 method visitBranch.

@Override
public Object visitBranch(LitmusAArch64Parser.BranchContext ctx) {
    Label label = programBuilder.getOrCreateLabel(ctx.label().getText());
    if (ctx.branchCondition() == null) {
        return programBuilder.addChild(mainThread, EventFactory.newGoto(label));
    }
    Event lastEvent = programBuilder.getLastEvent(mainThread);
    if (!(lastEvent instanceof Cmp)) {
        throw new ParsingException("Invalid syntax near " + ctx.getText());
    }
    Cmp cmp = (Cmp) lastEvent;
    Atom expr = new Atom(cmp.getLeft(), ctx.branchCondition().op, cmp.getRight());
    return programBuilder.addChild(mainThread, EventFactory.newJump(expr, label));
}
Also used : Cmp(com.dat3m.dartagnan.program.event.core.Cmp) ParsingException(com.dat3m.dartagnan.exception.ParsingException) Label(com.dat3m.dartagnan.program.event.core.Label) Event(com.dat3m.dartagnan.program.event.core.Event) Atom(com.dat3m.dartagnan.expression.Atom)

Example 4 with Atom

use of com.dat3m.dartagnan.expression.Atom in project Dat3M by hernanponcedeleon.

the class RemoveDeadCondJumps method mutuallyExclusiveIfs.

private boolean mutuallyExclusiveIfs(CondJump jump, Event e) {
    if (!(e instanceof CondJump)) {
        return false;
    }
    CondJump jump2 = (CondJump) e;
    if (jump.getGuard() instanceof BExprUn && ((BExprUn) jump.getGuard()).getInner().equals(jump2.getGuard()) || jump2.getGuard() instanceof BExprUn && ((BExprUn) jump2.getGuard()).getInner().equals(jump.getGuard())) {
        return true;
    }
    if (jump.getGuard() instanceof Atom && jump2.getGuard() instanceof Atom) {
        Atom a1 = (Atom) jump.getGuard();
        Atom a2 = (Atom) jump2.getGuard();
        return a1.getOp().inverted() == a2.getOp() && a1.getLHS().equals(a2.getLHS()) && a1.getRHS().equals(a2.getRHS());
    }
    return false;
}
Also used : BExprUn(com.dat3m.dartagnan.expression.BExprUn) CondJump(com.dat3m.dartagnan.program.event.core.CondJump) Atom(com.dat3m.dartagnan.expression.Atom)

Example 5 with Atom

use of com.dat3m.dartagnan.expression.Atom in project Dat3M by hernanponcedeleon.

the class VisitorLitmusAArch64 method visitBranchRegister.

@Override
public Object visitBranchRegister(LitmusAArch64Parser.BranchRegisterContext ctx) {
    Register register = programBuilder.getOrErrorRegister(mainThread, ctx.rV);
    Atom expr = new Atom(register, ctx.branchRegInstruction().op, IValue.ZERO);
    Label label = programBuilder.getOrCreateLabel(ctx.label().getText());
    return programBuilder.addChild(mainThread, EventFactory.newJump(expr, label));
}
Also used : Register(com.dat3m.dartagnan.program.Register) Label(com.dat3m.dartagnan.program.event.core.Label) Atom(com.dat3m.dartagnan.expression.Atom)

Aggregations

Atom (com.dat3m.dartagnan.expression.Atom)7 Label (com.dat3m.dartagnan.program.event.core.Label)6 Event (com.dat3m.dartagnan.program.event.core.Event)5 Register (com.dat3m.dartagnan.program.Register)4 ParsingException (com.dat3m.dartagnan.exception.ParsingException)2 Cmp (com.dat3m.dartagnan.program.event.core.Cmp)2 BExprUn (com.dat3m.dartagnan.expression.BExprUn)1 IExpr (com.dat3m.dartagnan.expression.IExpr)1 EventFactory.newLabel (com.dat3m.dartagnan.program.event.EventFactory.newLabel)1 CondJump (com.dat3m.dartagnan.program.event.core.CondJump)1 BeginAtomic (com.dat3m.dartagnan.program.event.lang.svcomp.BeginAtomic)1 EndAtomic (com.dat3m.dartagnan.program.event.lang.svcomp.EndAtomic)1