Search in sources :

Example 61 with Event

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

the class VisitorLitmusC method visitNreWriteOnce.

@Override
public Object visitNreWriteOnce(LitmusCParser.NreWriteOnceContext ctx) {
    ExprInterface value = (ExprInterface) ctx.value.accept(this);
    Event event = EventFactory.newStore(getAddress(ctx.address), value, ctx.mo);
    return programBuilder.addChild(currentThread, event);
}
Also used : Event(com.dat3m.dartagnan.program.event.core.Event)

Example 62 with Event

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

the class VisitorLitmusC method visitReXchg.

@Override
public IExpr visitReXchg(LitmusCParser.ReXchgContext ctx) {
    Register register = getReturnRegister(true);
    IExpr value = (IExpr) ctx.value.accept(this);
    Event event = EventFactory.Linux.newRMWExchange(getAddress(ctx.address), register, value, ctx.mo);
    programBuilder.addChild(currentThread, event);
    return register;
}
Also used : Register(com.dat3m.dartagnan.program.Register) Event(com.dat3m.dartagnan.program.event.core.Event)

Example 63 with Event

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

the class VisitorLitmusC method visitNreAssignment.

@Override
public Object visitNreAssignment(LitmusCParser.NreAssignmentContext ctx) {
    ExprInterface variable = (ExprInterface) ctx.varName().accept(this);
    if (ctx.Ast() == null) {
        if (variable instanceof Register) {
            returnRegister = (Register) variable;
            ctx.re().accept(this);
            return null;
        }
        throw new ParsingException("Invalid syntax near " + ctx.getText());
    }
    ExprInterface value = (ExprInterface) ctx.re().accept(this);
    if (variable instanceof MemoryObject || variable instanceof Register) {
        Event event = EventFactory.newStore((IExpr) variable, value, "NA");
        return programBuilder.addChild(currentThread, event);
    }
    throw new ParsingException("Invalid syntax near " + ctx.getText());
}
Also used : Register(com.dat3m.dartagnan.program.Register) ParsingException(com.dat3m.dartagnan.exception.ParsingException) MemoryObject(com.dat3m.dartagnan.program.memory.MemoryObject) Event(com.dat3m.dartagnan.program.event.core.Event)

Example 64 with Event

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

the class PthreadsProcedures method pthread_create.

private static void pthread_create(VisitorBoogie visitor, Call_cmdContext ctx) {
    visitor.currentThread++;
    visitor.threadCallingValues.put(visitor.currentThread, new ArrayList<>());
    String namePtr = ctx.call_params().exprs().expr().get(0).getText();
    // This names are global so we don't use currentScope.getID(), but per thread.
    Register threadPtr = visitor.programBuilder.getOrCreateRegister(visitor.threadCount, namePtr, ARCH_PRECISION);
    String threadName = ctx.call_params().exprs().expr().get(2).getText();
    ExprInterface callingValue = (ExprInterface) ctx.call_params().exprs().expr().get(3).accept(visitor);
    visitor.threadCallingValues.get(visitor.currentThread).add(callingValue);
    visitor.pool.add(threadPtr, threadName, visitor.threadCount);
    Register reg = visitor.programBuilder.getOrCreateRegister(visitor.threadCount, visitor.currentScope.getID() + ":" + ctx.call_params().Ident(0).getText(), ARCH_PRECISION);
    // We assume pthread_create always succeeds
    visitor.programBuilder.addChild(visitor.threadCount, EventFactory.newLocal(reg, IValue.ZERO));
    MemoryObject object = visitor.programBuilder.getOrNewObject(String.format("%s(%s)_active", threadPtr, visitor.pool.getCreatorFromPtr(threadPtr)));
    Event child = EventFactory.Pthread.newCreate(threadPtr, threadName, object);
    child.setCLine(visitor.currentLine);
    visitor.programBuilder.addChild(visitor.threadCount, child);
}
Also used : ExprInterface(com.dat3m.dartagnan.expression.ExprInterface) Register(com.dat3m.dartagnan.program.Register) MemoryObject(com.dat3m.dartagnan.program.memory.MemoryObject) Event(com.dat3m.dartagnan.program.event.core.Event)

Example 65 with Event

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

the class BranchEquivalence method computeBranches.

// ========================== Branching Property =========================
private Branch computeBranches(Event start, Map<Event, Branch> branchMap, Map<Event, Branch> finalBranchMap) {
    if (branchMap.containsKey(start)) {
        // <start> was already visited
        return branchMap.get(start);
    }
    Branch b = new Branch(start);
    branchMap.put(start, b);
    Event succ = start;
    do {
        if (succ instanceof CondJump) {
            CondJump jump = (CondJump) succ;
            if (!alwaysSplitOnJump && jump.isGoto()) {
                // There is only one branch we can proceed on, so we don't need to split the current branch
                succ = jump.getLabel();
            } else {
                // Split into two branches...
                Branch b1 = computeBranches(jump.getSuccessor(), branchMap, finalBranchMap);
                Branch b2 = computeBranches(jump.getLabel(), branchMap, finalBranchMap);
                b1.parents.add(b);
                b.children.add(b1);
                b2.parents.add(b);
                b.children.add(b2);
                return b;
            }
        } else {
            // No branching happened, thus we stay on the current branch
            succ = succ.getSuccessor();
        }
        if (succ == null) {
            finalBranchMap.put(b.events.get(b.events.size() - 1), b);
            return b;
        } else if ((succ instanceof Label && !((Label) succ).getJumpSet().isEmpty()) || branchMap.containsKey(succ)) {
            // We ran into a merge point
            Branch b1 = computeBranches(succ, branchMap, finalBranchMap);
            b1.parents.add(b);
            b.children.add(b1);
            return b;
        } else {
            b.events.add(succ);
        }
    } while (true);
}
Also used : Label(com.dat3m.dartagnan.program.event.core.Label) Event(com.dat3m.dartagnan.program.event.core.Event) CondJump(com.dat3m.dartagnan.program.event.core.CondJump)

Aggregations

Event (com.dat3m.dartagnan.program.event.core.Event)104 Tuple (com.dat3m.dartagnan.wmm.utils.Tuple)34 Thread (com.dat3m.dartagnan.program.Thread)32 Register (com.dat3m.dartagnan.program.Register)25 TupleSet (com.dat3m.dartagnan.wmm.utils.TupleSet)25 MemEvent (com.dat3m.dartagnan.program.event.core.MemEvent)20 Tag (com.dat3m.dartagnan.program.event.Tag)16 Label (com.dat3m.dartagnan.program.event.core.Label)16 Collectors (java.util.stream.Collectors)16 BooleanFormula (org.sosy_lab.java_smt.api.BooleanFormula)16 BooleanFormulaManager (org.sosy_lab.java_smt.api.BooleanFormulaManager)16 LogManager (org.apache.logging.log4j.LogManager)15 Logger (org.apache.logging.log4j.Logger)15 Program (com.dat3m.dartagnan.program.Program)12 ExecutionAnalysis (com.dat3m.dartagnan.program.analysis.ExecutionAnalysis)12 RegWriter (com.dat3m.dartagnan.program.event.core.utils.RegWriter)12 java.util (java.util)12 SolverContext (org.sosy_lab.java_smt.api.SolverContext)12 FilterBasic (com.dat3m.dartagnan.program.filter.FilterBasic)11 CondJump (com.dat3m.dartagnan.program.event.core.CondJump)10