Search in sources :

Example 26 with Program

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

the class ParserLitmusAArch64 method parse.

@Override
public Program parse(CharStream charStream) {
    LitmusAArch64Lexer lexer = new LitmusAArch64Lexer(charStream);
    CommonTokenStream tokenStream = new CommonTokenStream(lexer);
    LitmusAArch64Parser parser = new LitmusAArch64Parser(tokenStream);
    parser.addErrorListener(new DiagnosticErrorListener(true));
    parser.addErrorListener(new ParserErrorListener());
    ProgramBuilder pb = new ProgramBuilder(SourceLanguage.LITMUS);
    ParserRuleContext parserEntryPoint = parser.main();
    VisitorLitmusAArch64 visitor = new VisitorLitmusAArch64(pb);
    Program program = (Program) parserEntryPoint.accept(visitor);
    program.setArch(Arch.ARM8);
    return program;
}
Also used : VisitorLitmusAArch64(com.dat3m.dartagnan.parsers.program.visitors.VisitorLitmusAArch64) Program(com.dat3m.dartagnan.program.Program) LitmusAArch64Parser(com.dat3m.dartagnan.parsers.LitmusAArch64Parser) ProgramBuilder(com.dat3m.dartagnan.parsers.program.utils.ProgramBuilder) LitmusAArch64Lexer(com.dat3m.dartagnan.parsers.LitmusAArch64Lexer) ParserErrorListener(com.dat3m.dartagnan.exception.ParserErrorListener)

Example 27 with Program

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

the class ParserLitmusX86 method parse.

@Override
public Program parse(CharStream charStream) {
    LitmusX86Lexer lexer = new LitmusX86Lexer(charStream);
    CommonTokenStream tokenStream = new CommonTokenStream(lexer);
    LitmusX86Parser parser = new LitmusX86Parser(tokenStream);
    parser.addErrorListener(new DiagnosticErrorListener(true));
    parser.addErrorListener(new ParserErrorListener());
    ProgramBuilder pb = new ProgramBuilder(SourceLanguage.LITMUS);
    ParserRuleContext parserEntryPoint = parser.main();
    VisitorLitmusX86 visitor = new VisitorLitmusX86(pb);
    Program program = (Program) parserEntryPoint.accept(visitor);
    program.setArch(Arch.TSO);
    return program;
}
Also used : LitmusX86Lexer(com.dat3m.dartagnan.parsers.LitmusX86Lexer) Program(com.dat3m.dartagnan.program.Program) VisitorLitmusX86(com.dat3m.dartagnan.parsers.program.visitors.VisitorLitmusX86) ProgramBuilder(com.dat3m.dartagnan.parsers.program.utils.ProgramBuilder) LitmusX86Parser(com.dat3m.dartagnan.parsers.LitmusX86Parser) ParserErrorListener(com.dat3m.dartagnan.exception.ParserErrorListener)

Example 28 with Program

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

the class Dat3M method runTest.

private void runTest() {
    UiOptions options = optionsPane.getOptions();
    testResult = null;
    try {
        Editor programEditor = editorsPane.getEditor(EditorCode.PROGRAM);
        Program program = new ProgramParser().parse(programEditor.getEditorPane().getText(), programEditor.getLoadedFormat());
        try {
            Wmm targetModel = new ParserCat().parse(editorsPane.getEditor(EditorCode.TARGET_MM).getEditorPane().getText());
            testResult = new ReachabilityResult(program, targetModel, options);
        } catch (Exception e) {
            String msg = e.getMessage() == null ? "Memory model cannot be parsed" : e.getMessage();
            showError(msg, "Target memory model error");
        }
    } catch (Exception e) {
        String msg = e.getMessage() == null ? "Program cannot be parsed" : e.getMessage();
        Throwable cause = e.getCause();
        if (cause instanceof InputMismatchException) {
            Token token = ((InputMismatchException) cause).getOffendingToken();
            msg = "Problem with \"" + token.getText() + "\" at line " + token.getLine();
        }
        showError(msg, "Program error");
    }
}
Also used : ReachabilityResult(com.dat3m.ui.result.ReachabilityResult) Program(com.dat3m.dartagnan.program.Program) ProgramParser(com.dat3m.dartagnan.parsers.program.ProgramParser) Wmm(com.dat3m.dartagnan.wmm.Wmm) UiOptions(com.dat3m.ui.utils.UiOptions) Token(org.antlr.v4.runtime.Token) ParserCat(com.dat3m.dartagnan.parsers.cat.ParserCat) Editor(com.dat3m.ui.editor.Editor) InputMismatchException(org.antlr.v4.runtime.InputMismatchException) InputMismatchException(org.antlr.v4.runtime.InputMismatchException)

Example 29 with Program

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

the class AnalysisTest method dependencyMustOverride.

@Test
public void dependencyMustOverride() throws InvalidConfigurationException {
    ProgramBuilder b = new ProgramBuilder(SourceLanguage.LITMUS);
    b.initThread(0);
    Register r0 = b.getOrCreateRegister(0, "r0", ARCH_PRECISION);
    Register r1 = b.getOrCreateRegister(0, "r1", ARCH_PRECISION);
    Register r2 = b.getOrCreateRegister(0, "r2", ARCH_PRECISION);
    Label alt = b.getOrCreateLabel("alt");
    b.addChild(0, newJump(new BNonDet(ARCH_PRECISION), alt));
    Local e0 = newLocal(r0, value(1));
    b.addChild(0, e0);
    Local e1 = newLocal(r1, r0);
    b.addChild(0, e1);
    Label join = b.getOrCreateLabel("join");
    b.addChild(0, newGoto(join));
    b.addChild(0, alt);
    Local e2 = newLocal(r1, value(2));
    b.addChild(0, e2);
    b.addChild(0, join);
    Local e3 = newLocal(r2, r0);
    b.addChild(0, e3);
    Local e4 = newLocal(r2, r1);
    b.addChild(0, e4);
    Local e5 = newLocal(r0, r2);
    b.addChild(0, e5);
    Program program = b.build();
    LoopUnrolling.newInstance().run(program);
    Compilation.newInstance().run(program);
    Configuration config = Configuration.defaultConfiguration();
    Context context = Context.create();
    context.register(BranchEquivalence.class, BranchEquivalence.fromConfig(program, config));
    context.register(ExecutionAnalysis.class, ExecutionAnalysis.fromConfig(program, context, config));
    Dependency dep = Dependency.fromConfig(program, context, config);
    assertTrue(dep.of(e1, r0).initialized);
    assertList(dep.of(e1, r0).may, e0);
    assertList(dep.of(e1, r0).must, e0);
    assertFalse(dep.of(e3, r0).initialized);
    assertList(dep.of(e3, r0).may, e0);
    assertList(dep.of(e3, r0).must, e0);
    assertTrue(dep.of(e4, r1).initialized);
    assertList(dep.of(e4, r1).may, e1, e2);
    assertList(dep.of(e4, r1).must, e1, e2);
    assertTrue(dep.of(e5, r2).initialized);
    assertList(dep.of(e5, r2).may, e4);
    assertList(dep.of(e5, r2).must, e4);
}
Also used : Context(com.dat3m.dartagnan.verification.Context) Program(com.dat3m.dartagnan.program.Program) Configuration(org.sosy_lab.common.configuration.Configuration) Register(com.dat3m.dartagnan.program.Register) ProgramBuilder(com.dat3m.dartagnan.parsers.program.utils.ProgramBuilder) Dependency(com.dat3m.dartagnan.program.analysis.Dependency) Test(org.junit.Test)

Example 30 with Program

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

the class BranchTest method test.

@Test
public void test() {
    try (SolverContext ctx = TestHelper.createContext();
        ProverEnvironment prover1 = ctx.newProverEnvironment(ProverOptions.GENERATE_MODELS);
        ProverEnvironment prover2 = ctx.newProverEnvironment(ProverOptions.GENERATE_MODELS)) {
        Program program = new ProgramParser().parse(new File(path));
        VerificationTask task = VerificationTask.builder().withSolverTimeout(60).withTarget(Arch.LKMM).build(program, wmm, EnumSet.of(Property.getDefault()));
        assertEquals(expected, TwoSolvers.run(ctx, prover1, prover2, task));
    } catch (Exception e) {
        fail("Missing resource file");
    }
}
Also used : SolverContext(org.sosy_lab.java_smt.api.SolverContext) Program(com.dat3m.dartagnan.program.Program) VerificationTask(com.dat3m.dartagnan.verification.VerificationTask) ProgramParser(com.dat3m.dartagnan.parsers.program.ProgramParser) ProverEnvironment(org.sosy_lab.java_smt.api.ProverEnvironment) File(java.io.File) IOException(java.io.IOException) Test(org.junit.Test)

Aggregations

Program (com.dat3m.dartagnan.program.Program)41 Test (org.junit.Test)22 File (java.io.File)21 ProgramParser (com.dat3m.dartagnan.parsers.program.ProgramParser)20 ProgramBuilder (com.dat3m.dartagnan.parsers.program.utils.ProgramBuilder)10 Printer (com.dat3m.dartagnan.utils.printer.Printer)8 VerificationTask (com.dat3m.dartagnan.verification.VerificationTask)6 Configuration (org.sosy_lab.common.configuration.Configuration)6 ParserErrorListener (com.dat3m.dartagnan.exception.ParserErrorListener)5 Compilation (com.dat3m.dartagnan.program.processing.compilation.Compilation)5 Collectors (java.util.stream.Collectors)5 SolverContext (org.sosy_lab.java_smt.api.SolverContext)5 ParserCat (com.dat3m.dartagnan.parsers.cat.ParserCat)4 Tag (com.dat3m.dartagnan.program.event.Tag)4 Event (com.dat3m.dartagnan.program.event.core.Event)4 Result (com.dat3m.dartagnan.utils.Result)4 Wmm (com.dat3m.dartagnan.wmm.Wmm)4 InvalidConfigurationException (org.sosy_lab.common.configuration.InvalidConfigurationException)4 ProverEnvironment (org.sosy_lab.java_smt.api.ProverEnvironment)4 FilterBasic (com.dat3m.dartagnan.program.filter.FilterBasic)3