Search in sources :

Example 21 with ProgramBuilder

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

the class UnrollExceptionsTest method FenceCond.

@Test(expected = ProgramProcessingException.class)
public void FenceCond() throws Exception {
    ProgramBuilder pb = new ProgramBuilder(SourceLanguage.LITMUS);
    pb.initThread(0);
    MemoryObject object = pb.getOrNewObject("X");
    Label start = pb.getOrCreateLabel("loopStart");
    pb.addChild(0, start);
    RMWReadCond load = Linux.newRMWReadCondCmp(pb.getOrCreateRegister(0, "r1", 32), BConst.TRUE, object, null);
    pb.addChild(0, Linux.newConditionalBarrier(load, null));
    pb.addChild(0, EventFactory.newGoto(start));
    LoopUnrolling processor = LoopUnrolling.newInstance();
    processor.setUnrollingBound(2);
    processor.run(pb.build());
}
Also used : RMWReadCond(com.dat3m.dartagnan.program.event.lang.linux.cond.RMWReadCond) ProgramBuilder(com.dat3m.dartagnan.parsers.program.utils.ProgramBuilder) MemoryObject(com.dat3m.dartagnan.program.memory.MemoryObject) Label(com.dat3m.dartagnan.program.event.core.Label) LoopUnrolling(com.dat3m.dartagnan.program.processing.LoopUnrolling) Test(org.junit.Test)

Example 22 with ProgramBuilder

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

the class AliasAnalysisTest method program0.

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

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

the class ExceptionsTest method JumpWithNullExpr.

@Test(expected = NullPointerException.class)
public void JumpWithNullExpr() throws Exception {
    ProgramBuilder pb = new ProgramBuilder();
    pb.initThread(0);
    Label end = pb.getOrCreateLabel("END");
    // The expr cannot be null
    pb.addChild(0, new CondJump(null, end));
}
Also used : ProgramBuilder(com.dat3m.dartagnan.parsers.program.utils.ProgramBuilder) Label(com.dat3m.dartagnan.program.event.core.Label) CondJump(com.dat3m.dartagnan.program.event.core.CondJump) Test(org.junit.Test)

Example 24 with ProgramBuilder

use of com.dat3m.dartagnan.parsers.program.utils.ProgramBuilder 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 25 with ProgramBuilder

use of com.dat3m.dartagnan.parsers.program.utils.ProgramBuilder 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)

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