Search in sources :

Example 1 with Cmp

use of com.dat3m.dartagnan.program.event.core.Cmp 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 2 with Cmp

use of com.dat3m.dartagnan.program.event.core.Cmp 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)

Aggregations

ParsingException (com.dat3m.dartagnan.exception.ParsingException)2 Atom (com.dat3m.dartagnan.expression.Atom)2 Cmp (com.dat3m.dartagnan.program.event.core.Cmp)2 Event (com.dat3m.dartagnan.program.event.core.Event)2 Label (com.dat3m.dartagnan.program.event.core.Label)2