Search in sources :

Example 16 with Label

use of com.dat3m.dartagnan.program.event.core.Label in project Dat3M by hernanponcedeleon.

the class VisitorLitmusLISA method visitJump.

@Override
public Object visitJump(LitmusLISAParser.JumpContext ctx) {
    Label label = programBuilder.getOrCreateLabel(ctx.labelName().getText());
    Register reg = (Register) ctx.register().accept(this);
    Atom cond = new Atom(reg, COpBin.EQ, IValue.ONE);
    programBuilder.addChild(mainThread, EventFactory.newJump(cond, label));
    return null;
}
Also used : Register(com.dat3m.dartagnan.program.Register) Label(com.dat3m.dartagnan.program.event.core.Label)

Example 17 with Label

use of com.dat3m.dartagnan.program.event.core.Label in project Dat3M by hernanponcedeleon.

the class VisitorLitmusLISA method visitLabel.

@Override
public Object visitLabel(LitmusLISAParser.LabelContext ctx) {
    String name = ctx.getText();
    Label label = programBuilder.getOrCreateLabel(name.substring(0, name.length() - 1));
    programBuilder.addChild(mainThread, label);
    return null;
}
Also used : Label(com.dat3m.dartagnan.program.event.core.Label)

Example 18 with Label

use of com.dat3m.dartagnan.program.event.core.Label in project Dat3M by hernanponcedeleon.

the class VisitorBoogie method visitLabel.

@Override
public Object visitLabel(LabelContext ctx) {
    // Since we "inline" procedures, label names might clash
    // thus we use currentScope.getID() + ":"
    String labelName = currentScope.getID() + ":" + ctx.children.get(0).getText();
    Label label = programBuilder.getOrCreateLabel(labelName);
    programBuilder.addChild(threadCount, label);
    currentLabel = label;
    return null;
}
Also used : Label(com.dat3m.dartagnan.program.event.core.Label)

Example 19 with Label

use of com.dat3m.dartagnan.program.event.core.Label in project Dat3M by hernanponcedeleon.

the class VisitorBoogie method visitGoto_cmd.

@Override
public Object visitGoto_cmd(Goto_cmdContext ctx) {
    String labelName = currentScope.getID() + ":" + ctx.idents().children.get(0).getText();
    boolean loop = programBuilder.hasLabel(labelName);
    Label l1 = programBuilder.getOrCreateLabel(labelName);
    programBuilder.addChild(threadCount, EventFactory.newGoto(l1));
    // SMACK will take care of another escape if the loop is completely unrolled.
    if (loop) {
        Label label = programBuilder.getOrCreateLabel("END_OF_" + currentScope.getID());
        programBuilder.addChild(threadCount, EventFactory.newGoto(label));
    }
    if (ctx.idents().children.size() > 1) {
        for (int index = 2; index < ctx.idents().children.size(); index = index + 2) {
            labelName = currentScope.getID() + ":" + ctx.idents().children.get(index - 2).getText();
            l1 = programBuilder.getOrCreateLabel(labelName);
            // We know there are 2 labels and a comma in the middle
            labelName = currentScope.getID() + ":" + ctx.idents().children.get(index).getText();
            Label l2 = programBuilder.getOrCreateLabel(labelName);
            pairLabels.put(l1, l2);
        }
    }
    return null;
}
Also used : Label(com.dat3m.dartagnan.program.event.core.Label)

Example 20 with Label

use of com.dat3m.dartagnan.program.event.core.Label in project Dat3M by hernanponcedeleon.

the class VisitorBoogie method visitAssume_cmd.

@Override
public Object visitAssume_cmd(Assume_cmdContext ctx) {
    if (ctx.getText().contains("sourceloc")) {
        String line = ctx.getText();
        sourceCodeFile = line.substring(line.lastIndexOf('/') + 1, line.indexOf(',') - 1);
        currentLine = Integer.parseInt(line.substring(line.indexOf(',') + 1, line.lastIndexOf(',')));
    }
    // We can get rid of all the "assume true" statements
    if (!ctx.proposition().expr().getText().equals("true")) {
        Label pairingLabel;
        if (!pairLabels.containsKey(currentLabel)) {
            // If the current label doesn't have a pairing label, we jump to the end of the program
            pairingLabel = programBuilder.getOrCreateLabel("END_OF_T" + threadCount);
        } else {
            pairingLabel = pairLabels.get(currentLabel);
        }
        BExpr c = (BExpr) ctx.proposition().expr().accept(this);
        if (c != null) {
            programBuilder.addChild(threadCount, EventFactory.newJumpUnless(c, pairingLabel));
        }
    }
    return null;
}
Also used : Label(com.dat3m.dartagnan.program.event.core.Label)

Aggregations

Label (com.dat3m.dartagnan.program.event.core.Label)33 Event (com.dat3m.dartagnan.program.event.core.Event)15 Register (com.dat3m.dartagnan.program.Register)11 CondJump (com.dat3m.dartagnan.program.event.core.CondJump)9 Atom (com.dat3m.dartagnan.expression.Atom)7 MemoryObject (com.dat3m.dartagnan.program.memory.MemoryObject)7 ProgramBuilder (com.dat3m.dartagnan.parsers.program.utils.ProgramBuilder)6 Test (org.junit.Test)6 LoopUnrolling (com.dat3m.dartagnan.program.processing.LoopUnrolling)5 ParsingException (com.dat3m.dartagnan.exception.ParsingException)4 Program (com.dat3m.dartagnan.program.Program)4 Thread (com.dat3m.dartagnan.program.Thread)4 Preconditions (com.google.common.base.Preconditions)4 HashMap (java.util.HashMap)4 LogManager (org.apache.logging.log4j.LogManager)4 Logger (org.apache.logging.log4j.Logger)4 Tag (com.dat3m.dartagnan.program.event.Tag)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Map (java.util.Map)3