Search in sources :

Example 1 with Register

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

the class AliasAnalysisTest method program2.

private void program2(Alias method, Result... expect) throws InvalidConfigurationException {
    ProgramBuilder b = new ProgramBuilder();
    MemoryObject x = b.newObject("x", 3);
    b.initThread(0);
    Register r0 = b.getOrCreateRegister(0, "r0", -1);
    b.addChild(0, newLocal(r0, new INonDet(INonDetTypes.INT, -1)));
    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", -1);
    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 2 with Register

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

the class AliasAnalysisTest method program1.

private void program1(Alias method, Result... expect) throws InvalidConfigurationException {
    ProgramBuilder b = new ProgramBuilder();
    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", -1);
    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 3 with Register

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

the class AliasAnalysisTest method program4.

private void program4(Alias method, Result... expect) throws InvalidConfigurationException {
    ProgramBuilder b = new ProgramBuilder();
    MemoryObject x = b.getOrNewObject("x");
    MemoryObject y = b.getOrNewObject("y");
    MemoryObject z = b.getOrNewObject("z");
    b.initThread(0);
    Register r0 = b.getOrCreateRegister(0, "r0", -1);
    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);
}
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 4 with Register

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

the class AliasAnalysisTest method program5.

private void program5(Alias method, Result... expect) throws InvalidConfigurationException {
    ProgramBuilder b = new ProgramBuilder();
    MemoryObject x = b.getOrNewObject("x");
    MemoryObject y = b.getOrNewObject("y");
    MemoryObject z = b.getOrNewObject("z");
    b.initThread(0);
    Register r0 = b.getOrCreateRegister(0, "r0", -1);
    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 5 with Register

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

the class AliasAnalysisTest method program3.

private void program3(Alias method, Result... expect) throws InvalidConfigurationException {
    ProgramBuilder b = new ProgramBuilder();
    MemoryObject x = b.newObject("x", 3);
    x.setInitialValue(0, x);
    b.initThread(0);
    Register r0 = b.getOrCreateRegister(0, "r0", -1);
    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);
}
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)

Aggregations

Register (com.dat3m.dartagnan.program.Register)154 MemoryObject (com.dat3m.dartagnan.program.memory.MemoryObject)29 Event (com.dat3m.dartagnan.program.event.core.Event)25 IExpr (com.dat3m.dartagnan.expression.IExpr)16 RegWriter (com.dat3m.dartagnan.program.event.core.utils.RegWriter)15 ProgramBuilder (com.dat3m.dartagnan.parsers.program.utils.ProgramBuilder)13 AliasAnalysis (com.dat3m.dartagnan.program.analysis.AliasAnalysis)12 Label (com.dat3m.dartagnan.program.event.core.Label)11 ParsingException (com.dat3m.dartagnan.exception.ParsingException)10 BigInteger (java.math.BigInteger)8 IConst (com.dat3m.dartagnan.expression.IConst)7 IExprBin (com.dat3m.dartagnan.expression.IExprBin)6 IValue (com.dat3m.dartagnan.expression.IValue)6 IOpBin (com.dat3m.dartagnan.expression.op.IOpBin)6 Program (com.dat3m.dartagnan.program.Program)6 Dependency (com.dat3m.dartagnan.program.analysis.Dependency)6 ExprInterface (com.dat3m.dartagnan.expression.ExprInterface)5 Thread (com.dat3m.dartagnan.program.Thread)5 java.util (java.util)5 Atom (com.dat3m.dartagnan.expression.Atom)4