Search in sources :

Example 11 with ProgramBuilder

use of com.dat3m.dartagnan.parsers.program.utils.ProgramBuilder in project Dat3M by hernanponcedeleon.

the class AnalysisTest method program2.

private void program2(Alias method, Result... expect) throws InvalidConfigurationException {
    ProgramBuilder b = new ProgramBuilder(SourceLanguage.LITMUS);
    MemoryObject x = b.newObject("x", 3);
    b.initThread(0);
    Register r0 = b.getOrCreateRegister(0, "r0", ARCH_PRECISION);
    b.addChild(0, newLocal(r0, new INonDet(INonDetTypes.INT, ARCH_PRECISION)));
    Label l0 = b.getOrCreateLabel("l0");
    b.addChild(0, newJump(new BExprBin(new Atom(r0, GT, ONE), BOpBin.OR, new Atom(r0, LT, ZERO)), l0));
    Store e0 = newStore(x);
    b.addChild(0, e0);
    Store e1 = newStore(plus(x, 1));
    b.addChild(0, e1);
    Store e2 = newStore(plus(x, 2));
    b.addChild(0, e2);
    Register r1 = b.getOrCreateRegister(0, "r1", ARCH_PRECISION);
    b.addChild(0, newLocal(r1, ZERO));
    Store e3 = newStore(new IExprBin(new IExprBin(x, PLUS, mult(r0, 2)), PLUS, mult(r1, 4)));
    b.addChild(0, e3);
    b.addChild(0, l0);
    AliasAnalysis a = analyze(b, method);
    assertAlias(expect[0], a, e0, e1);
    assertAlias(expect[1], a, e0, e2);
    assertAlias(expect[2], a, e1, e2);
    assertAlias(expect[3], a, e0, e3);
    assertAlias(expect[4], a, e1, e3);
    assertAlias(expect[5], a, e2, e3);
}
Also used : Register(com.dat3m.dartagnan.program.Register) ProgramBuilder(com.dat3m.dartagnan.parsers.program.utils.ProgramBuilder) MemoryObject(com.dat3m.dartagnan.program.memory.MemoryObject) AliasAnalysis(com.dat3m.dartagnan.program.analysis.AliasAnalysis)

Example 12 with ProgramBuilder

use of com.dat3m.dartagnan.parsers.program.utils.ProgramBuilder in project Dat3M by hernanponcedeleon.

the class AnalysisTest method program5.

private void program5(Alias method, Result... expect) throws InvalidConfigurationException {
    ProgramBuilder b = new ProgramBuilder(SourceLanguage.LITMUS);
    MemoryObject x = b.getOrNewObject("x");
    MemoryObject y = b.getOrNewObject("y");
    MemoryObject z = b.getOrNewObject("z");
    b.initThread(0);
    Register r0 = b.getOrCreateRegister(0, "r0", ARCH_PRECISION);
    b.addChild(0, newLocal(r0, y));
    Store e0 = newStore(r0);
    b.addChild(0, e0);
    b.addChild(0, newLocal(r0, mult(x, 0)));
    Store e1 = newStore(x);
    b.addChild(0, e1);
    Store e2 = newStore(y);
    b.addChild(0, e2);
    Store e3 = newStore(z);
    b.addChild(0, e3);
    AliasAnalysis a = analyze(b, method);
    // precisely no
    assertAlias(expect[0], a, e0, e1);
    // precisely must
    assertAlias(expect[1], a, e0, e2);
    assertAlias(expect[2], a, e1, e2);
    assertAlias(expect[3], a, e0, e3);
    assertAlias(expect[4], a, e1, e3);
    assertAlias(expect[5], a, e2, e3);
}
Also used : Register(com.dat3m.dartagnan.program.Register) ProgramBuilder(com.dat3m.dartagnan.parsers.program.utils.ProgramBuilder) MemoryObject(com.dat3m.dartagnan.program.memory.MemoryObject) AliasAnalysis(com.dat3m.dartagnan.program.analysis.AliasAnalysis)

Example 13 with ProgramBuilder

use of com.dat3m.dartagnan.parsers.program.utils.ProgramBuilder in project Dat3M by hernanponcedeleon.

the class AnalysisTest method program1.

private void program1(Alias method, Result... expect) throws InvalidConfigurationException {
    ProgramBuilder b = new ProgramBuilder(SourceLanguage.LITMUS);
    MemoryObject x = b.newObject("x", 3);
    x.setInitialValue(0, x);
    b.initThread(0);
    Store e0 = newStore(plus(x, 1));
    b.addChild(0, e0);
    Register r0 = b.getOrCreateRegister(0, "r0", ARCH_PRECISION);
    Load e1 = newLoad(r0, x);
    b.addChild(0, e1);
    Store e2 = newStore(r0);
    b.addChild(0, e2);
    Store e3 = newStore(plus(r0, 1), r0);
    b.addChild(0, e3);
    AliasAnalysis a = analyze(b, method);
    assertAlias(expect[0], a, e0, e1);
    assertAlias(expect[1], a, e0, e2);
    assertAlias(expect[2], a, e1, e2);
    assertAlias(expect[3], a, e0, e3);
    assertAlias(expect[4], a, e1, e3);
    assertAlias(expect[5], a, e2, e3);
}
Also used : Register(com.dat3m.dartagnan.program.Register) ProgramBuilder(com.dat3m.dartagnan.parsers.program.utils.ProgramBuilder) MemoryObject(com.dat3m.dartagnan.program.memory.MemoryObject) AliasAnalysis(com.dat3m.dartagnan.program.analysis.AliasAnalysis)

Example 14 with ProgramBuilder

use of com.dat3m.dartagnan.parsers.program.utils.ProgramBuilder in project Dat3M by hernanponcedeleon.

the class ExceptionsTest method initializedBeforeCompileException.

@Test(expected = IllegalArgumentException.class)
public void initializedBeforeCompileException() throws Exception {
    ProgramBuilder pb = new ProgramBuilder(SourceLanguage.LITMUS);
    pb.initThread(0);
    Program p = pb.build();
    Wmm cat = new ParserCat().parse(new File(ResourceHelper.CAT_RESOURCE_PATH + "cat/tso.cat"));
    Configuration config = Configuration.defaultConfiguration();
    VerificationTask task = VerificationTask.builder().withConfig(config).build(p, cat, EnumSet.of(Property.getDefault()));
    // The program must be compiled before being able to construct an Encoder for it
    ProgramEncoder.fromConfig(task.getProgram(), Context.create(), config);
}
Also used : Program(com.dat3m.dartagnan.program.Program) VerificationTask(com.dat3m.dartagnan.verification.VerificationTask) Configuration(org.sosy_lab.common.configuration.Configuration) ProgramBuilder(com.dat3m.dartagnan.parsers.program.utils.ProgramBuilder) Wmm(com.dat3m.dartagnan.wmm.Wmm) ParserCat(com.dat3m.dartagnan.parsers.cat.ParserCat) File(java.io.File) Test(org.junit.Test)

Example 15 with ProgramBuilder

use of com.dat3m.dartagnan.parsers.program.utils.ProgramBuilder in project Dat3M by hernanponcedeleon.

the class ExceptionsTest method noThread.

@Test(expected = MalformedProgramException.class)
public void noThread() throws Exception {
    ProgramBuilder pb = new ProgramBuilder(SourceLanguage.LITMUS);
    // Thread 1 does not exists
    pb.addChild(1, new Skip());
}
Also used : ProgramBuilder(com.dat3m.dartagnan.parsers.program.utils.ProgramBuilder) Skip(com.dat3m.dartagnan.program.event.core.Skip) Test(org.junit.Test)

Aggregations

ProgramBuilder (com.dat3m.dartagnan.parsers.program.utils.ProgramBuilder)32 MemoryObject (com.dat3m.dartagnan.program.memory.MemoryObject)16 Test (org.junit.Test)14 Register (com.dat3m.dartagnan.program.Register)13 AliasAnalysis (com.dat3m.dartagnan.program.analysis.AliasAnalysis)12 Program (com.dat3m.dartagnan.program.Program)10 Label (com.dat3m.dartagnan.program.event.core.Label)6 ParserErrorListener (com.dat3m.dartagnan.exception.ParserErrorListener)5 LoopUnrolling (com.dat3m.dartagnan.program.processing.LoopUnrolling)5 CondJump (com.dat3m.dartagnan.program.event.core.CondJump)2 RMWReadCond (com.dat3m.dartagnan.program.event.lang.linux.cond.RMWReadCond)2 Configuration (org.sosy_lab.common.configuration.Configuration)2 BoogieLexer (com.dat3m.dartagnan.parsers.BoogieLexer)1 BoogieParser (com.dat3m.dartagnan.parsers.BoogieParser)1 LitmusAArch64Lexer (com.dat3m.dartagnan.parsers.LitmusAArch64Lexer)1 LitmusAArch64Parser (com.dat3m.dartagnan.parsers.LitmusAArch64Parser)1 LitmusCLexer (com.dat3m.dartagnan.parsers.LitmusCLexer)1 LitmusCParser (com.dat3m.dartagnan.parsers.LitmusCParser)1 LitmusLISALexer (com.dat3m.dartagnan.parsers.LitmusLISALexer)1 LitmusLISAParser (com.dat3m.dartagnan.parsers.LitmusLISAParser)1