Search in sources :

Example 1 with ExprInterface

use of com.dat3m.dartagnan.expression.ExprInterface in project Dat3M by hernanponcedeleon.

the class AtomicProcedures method atomicStore.

private static void atomicStore(VisitorBoogie visitor, Call_cmdContext ctx) {
    IExpr add = (IExpr) ctx.call_params().exprs().expr().get(0).accept(visitor);
    ExprInterface value = (ExprInterface) ctx.call_params().exprs().expr().get(1).accept(visitor);
    String mo = null;
    if (ctx.call_params().exprs().expr().size() > 2) {
        mo = intToMo(((IConst) ctx.call_params().exprs().expr().get(2).accept(visitor)).getValueAsInt());
    }
    visitor.programBuilder.addChild(visitor.threadCount, Atomic.newStore(add, value, mo)).setCLine(visitor.currentLine).setSourceCodeFile(visitor.sourceCodeFile);
}
Also used : ExprInterface(com.dat3m.dartagnan.expression.ExprInterface) IExpr(com.dat3m.dartagnan.expression.IExpr) IConst(com.dat3m.dartagnan.expression.IConst)

Example 2 with ExprInterface

use of com.dat3m.dartagnan.expression.ExprInterface in project Dat3M by hernanponcedeleon.

the class AtomicProcedures method atomicInit.

private static void atomicInit(VisitorBoogie visitor, Call_cmdContext ctx) {
    IExpr add = (IExpr) ctx.call_params().exprs().expr().get(0).accept(visitor);
    ExprInterface value = (ExprInterface) ctx.call_params().exprs().expr().get(1).accept(visitor);
    visitor.programBuilder.addChild(visitor.threadCount, newStore(add, value, null)).setCLine(visitor.currentLine).setSourceCodeFile(visitor.sourceCodeFile);
}
Also used : ExprInterface(com.dat3m.dartagnan.expression.ExprInterface) IExpr(com.dat3m.dartagnan.expression.IExpr)

Example 3 with ExprInterface

use of com.dat3m.dartagnan.expression.ExprInterface 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 4 with ExprInterface

use of com.dat3m.dartagnan.expression.ExprInterface in project Dat3M by hernanponcedeleon.

the class StdProcedures method __assert.

private static void __assert(VisitorBoogie visitor, Call_cmdContext ctx) {
    Register ass = visitor.programBuilder.getOrCreateRegister(visitor.threadCount, "assert_" + visitor.assertionIndex, ARCH_PRECISION);
    visitor.assertionIndex++;
    ExprInterface expr = (ExprInterface) ctx.call_params().exprs().accept(visitor);
    if (expr instanceof IConst && ((IConst) expr).getValue().compareTo(BigInteger.ONE) == 0) {
        return;
    }
    Local event = EventFactory.newLocal(ass, expr);
    event.addFilters(Tag.ASSERTION);
    visitor.programBuilder.addChild(visitor.threadCount, event);
}
Also used : ExprInterface(com.dat3m.dartagnan.expression.ExprInterface) Register(com.dat3m.dartagnan.program.Register) Local(com.dat3m.dartagnan.program.event.core.Local) IConst(com.dat3m.dartagnan.expression.IConst)

Example 5 with ExprInterface

use of com.dat3m.dartagnan.expression.ExprInterface in project Dat3M by hernanponcedeleon.

the class AndersenAliasAnalysis method processRegs.

private void processRegs(Program program) {
    for (Event ev : program.getCache().getEvents(FilterBasic.get(Tag.LOCAL))) {
        if (ev instanceof Local) {
            Local e = (Local) ev;
            Register register = e.getResultRegister();
            ExprInterface expr = e.getExpr();
            if (expr instanceof Register) {
                // r1 = r2 -> add edge r2 --> r1
                graph.addEdge(expr, register);
            } else if (expr instanceof IExprBin && ((IExprBin) expr).getBase() instanceof Register) {
                graph.addAllAddresses(register, maxAddressSet);
                variables.add(register);
            } else if (expr instanceof MemoryObject) {
                // r = &a
                graph.addAddress(register, new Location((MemoryObject) expr, 0));
                variables.add(register);
            }
        // FIXME if the expression is too complicated, the register should receive maxAddressSet
        }
    }
}
Also used : IExprBin(com.dat3m.dartagnan.expression.IExprBin) ExprInterface(com.dat3m.dartagnan.expression.ExprInterface) Register(com.dat3m.dartagnan.program.Register) MemoryObject(com.dat3m.dartagnan.program.memory.MemoryObject)

Aggregations

ExprInterface (com.dat3m.dartagnan.expression.ExprInterface)7 Register (com.dat3m.dartagnan.program.Register)5 IExpr (com.dat3m.dartagnan.expression.IExpr)4 IConst (com.dat3m.dartagnan.expression.IConst)3 MemoryObject (com.dat3m.dartagnan.program.memory.MemoryObject)3 IExprBin (com.dat3m.dartagnan.expression.IExprBin)2 RegWriter (com.dat3m.dartagnan.program.event.core.utils.RegWriter)2 PLUS (com.dat3m.dartagnan.expression.op.IOpBin.PLUS)1 Program (com.dat3m.dartagnan.program.Program)1 Tag (com.dat3m.dartagnan.program.event.Tag)1 com.dat3m.dartagnan.program.event.core (com.dat3m.dartagnan.program.event.core)1 Event (com.dat3m.dartagnan.program.event.core.Event)1 Local (com.dat3m.dartagnan.program.event.core.Local)1 FilterBasic (com.dat3m.dartagnan.program.filter.FilterBasic)1 Preconditions (com.google.common.base.Preconditions)1 Verify (com.google.common.base.Verify)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Sets (com.google.common.collect.Sets)1 java.util (java.util)1 BiConsumer (java.util.function.BiConsumer)1