Search in sources :

Example 1 with IfAsJump

use of com.dat3m.dartagnan.program.event.core.IfAsJump in project Dat3M by hernanponcedeleon.

the class VisitorLitmusC method visitIfExpression.

@Override
public Object visitIfExpression(LitmusCParser.IfExpressionContext ctx) {
    ExprInterface expr = (ExprInterface) ctx.re().accept(this);
    ifId++;
    Label elseL = programBuilder.getOrCreateLabel("else_" + ifId);
    Label endL = programBuilder.getOrCreateLabel("end_" + ifId);
    IfAsJump ifEvent = EventFactory.newIfJumpUnless(expr, elseL, endL);
    programBuilder.addChild(currentThread, ifEvent);
    for (LitmusCParser.ExpressionContext expressionContext : ctx.expression()) expressionContext.accept(this);
    CondJump jumpToEnd = EventFactory.newGoto(endL);
    jumpToEnd.addFilters(Tag.IFI);
    programBuilder.addChild(currentThread, jumpToEnd);
    programBuilder.addChild(currentThread, elseL);
    if (ctx.elseExpression() != null) {
        ctx.elseExpression().accept(this);
    }
    programBuilder.addChild(currentThread, endL);
    return null;
}
Also used : LitmusCParser(com.dat3m.dartagnan.parsers.LitmusCParser) Label(com.dat3m.dartagnan.program.event.core.Label) IfAsJump(com.dat3m.dartagnan.program.event.core.IfAsJump) CondJump(com.dat3m.dartagnan.program.event.core.CondJump)

Example 2 with IfAsJump

use of com.dat3m.dartagnan.program.event.core.IfAsJump in project Dat3M by hernanponcedeleon.

the class RelCtrlDirect method getMaxTupleSet.

@Override
public TupleSet getMaxTupleSet() {
    if (maxTupleSet == null) {
        maxTupleSet = new TupleSet();
        // NOTE: If's (under Linux) have different notion of ctrl dependency than conditional jumps!
        for (Thread thread : task.getProgram().getThreads()) {
            for (Event e1 : thread.getCache().getEvents(FilterBasic.get(Tag.CMP))) {
                for (Event e2 : ((IfAsJump) e1).getBranchesEvents()) {
                    maxTupleSet.add(new Tuple(e1, e2));
                }
            }
            // Relates jumps (except those implementing Ifs and their internal jump to end) with all later events
            List<Event> condJumps = thread.getCache().getEvents(FilterMinus.get(FilterBasic.get(Tag.JUMP), FilterUnion.get(FilterBasic.get(Tag.CMP), FilterBasic.get(Tag.IFI))));
            if (!condJumps.isEmpty()) {
                for (Event e2 : thread.getCache().getEvents(FilterBasic.get(Tag.ANY))) {
                    for (Event e1 : condJumps) {
                        if (e1.getCId() < e2.getCId()) {
                            maxTupleSet.add(new Tuple(e1, e2));
                        }
                    }
                }
            }
        }
        removeMutuallyExclusiveTuples(maxTupleSet);
    }
    return maxTupleSet;
}
Also used : TupleSet(com.dat3m.dartagnan.wmm.utils.TupleSet) Event(com.dat3m.dartagnan.program.event.core.Event) IfAsJump(com.dat3m.dartagnan.program.event.core.IfAsJump) Tuple(com.dat3m.dartagnan.wmm.utils.Tuple) Thread(com.dat3m.dartagnan.program.Thread)

Aggregations

IfAsJump (com.dat3m.dartagnan.program.event.core.IfAsJump)2 LitmusCParser (com.dat3m.dartagnan.parsers.LitmusCParser)1 Thread (com.dat3m.dartagnan.program.Thread)1 CondJump (com.dat3m.dartagnan.program.event.core.CondJump)1 Event (com.dat3m.dartagnan.program.event.core.Event)1 Label (com.dat3m.dartagnan.program.event.core.Label)1 Tuple (com.dat3m.dartagnan.wmm.utils.Tuple)1 TupleSet (com.dat3m.dartagnan.wmm.utils.TupleSet)1