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;
}
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;
}
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");
}
}
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);
}
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");
}
}
Aggregations