use of com.dat3m.dartagnan.parsers.program.utils.ProgramBuilder in project Dat3M by hernanponcedeleon.
the class AnalysisTest method program4.
private void program4(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, mult(x, 0)));
b.addChild(0, newLocal(r0, y));
Store e0 = newStore(r0);
b.addChild(0, e0);
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);
}
use of com.dat3m.dartagnan.parsers.program.utils.ProgramBuilder 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.parsers.program.utils.ProgramBuilder in project Dat3M by hernanponcedeleon.
the class AnalysisTest method program0.
private void program0(Alias method, Result... expect) throws InvalidConfigurationException {
ProgramBuilder b = new ProgramBuilder(SourceLanguage.LITMUS);
MemoryObject x = b.newObject("x", 2);
MemoryObject y = b.getOrNewObject("y");
b.initThread(0);
Register r0 = b.getOrCreateRegister(0, "r0", ARCH_PRECISION);
// this is undefined behavior in C11
// the expression does not match a sum, but x occurs in it
b.addChild(0, newLocal(r0, mult(x, 1)));
Store e0 = newStore(r0);
b.addChild(0, e0);
Store e1 = newStore(plus(r0, 1));
b.addChild(0, e1);
Store e2 = newStore(x);
b.addChild(0, e2);
Store e3 = newStore(y);
b.addChild(0, e3);
AliasAnalysis a = analyze(b, method);
// precisely no
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);
}
use of com.dat3m.dartagnan.parsers.program.utils.ProgramBuilder in project Dat3M by hernanponcedeleon.
the class AnalysisTest method program3.
private void program3(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);
Register r0 = b.getOrCreateRegister(0, "r0", ARCH_PRECISION);
Load e0 = newLoad(r0, x);
b.addChild(0, e0);
Store e1 = newStore(x, plus(r0, 1));
b.addChild(0, e1);
Store e2 = newStore(plus(x, 2));
b.addChild(0, e2);
Store e3 = newStore(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);
// precisely no
assertAlias(expect[5], a, e2, e3);
}
use of com.dat3m.dartagnan.parsers.program.utils.ProgramBuilder in project Dat3M by hernanponcedeleon.
the class ExceptionsTest method unrollBeforeReorderException.
@Test(expected = IllegalArgumentException.class)
public void unrollBeforeReorderException() throws Exception {
ProgramBuilder pb = new ProgramBuilder(SourceLanguage.LITMUS);
pb.initThread(0);
Program p = pb.build();
LoopUnrolling.newInstance().run(p);
// Reordering cannot be called after unrolling
BranchReordering.newInstance().run(p);
}
Aggregations