Search in sources :

Example 1 with IConst

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

the class AtomicProcedures method atomicFetchOp.

private static void atomicFetchOp(VisitorBoogie visitor, Call_cmdContext ctx) {
    Register reg = visitor.programBuilder.getOrCreateRegister(visitor.threadCount, visitor.currentScope.getID() + ":" + ctx.call_params().Ident(0).getText(), ARCH_PRECISION);
    IExpr add = (IExpr) ctx.call_params().exprs().expr().get(0).accept(visitor);
    IExpr value = (IExpr) ctx.call_params().exprs().expr().get(1).accept(visitor);
    String mo = null;
    IOpBin op;
    if (ctx.getText().contains("_add")) {
        op = IOpBin.PLUS;
    } else if (ctx.getText().contains("_sub")) {
        op = IOpBin.MINUS;
    } else if (ctx.getText().contains("_and")) {
        op = IOpBin.AND;
    } else if (ctx.getText().contains("_or")) {
        op = IOpBin.OR;
    } else if (ctx.getText().contains("_xor")) {
        op = IOpBin.XOR;
    } else {
        throw new RuntimeException("AtomicFetchOp operation cannot be handled");
    }
    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.newFetchOp(reg, add, value, op, mo)).setCLine(visitor.currentLine).setSourceCodeFile(visitor.sourceCodeFile);
}
Also used : IOpBin(com.dat3m.dartagnan.expression.op.IOpBin) Register(com.dat3m.dartagnan.program.Register) IExpr(com.dat3m.dartagnan.expression.IExpr) IConst(com.dat3m.dartagnan.expression.IConst)

Example 2 with IConst

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

the class AtomicProcedures method atomicXchg.

private static void atomicXchg(VisitorBoogie visitor, Call_cmdContext ctx) {
    Register reg = visitor.programBuilder.getOrCreateRegister(visitor.threadCount, visitor.currentScope.getID() + ":" + ctx.call_params().Ident(0).getText(), ARCH_PRECISION);
    IExpr add = (IExpr) ctx.call_params().exprs().expr().get(0).accept(visitor);
    IExpr value = (IExpr) 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.newExchange(reg, add, value, mo)).setCLine(visitor.currentLine).setSourceCodeFile(visitor.sourceCodeFile);
}
Also used : Register(com.dat3m.dartagnan.program.Register) IExpr(com.dat3m.dartagnan.expression.IExpr) IConst(com.dat3m.dartagnan.expression.IConst)

Example 3 with IConst

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

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

the class AtomicProcedures method atomicLoad.

private static void atomicLoad(VisitorBoogie visitor, Call_cmdContext ctx) {
    Register reg = visitor.programBuilder.getOrCreateRegister(visitor.threadCount, visitor.currentScope.getID() + ":" + ctx.call_params().Ident(0).getText(), ARCH_PRECISION);
    IExpr add = (IExpr) ctx.call_params().exprs().expr().get(0).accept(visitor);
    String mo = null;
    if (ctx.call_params().exprs().expr().size() > 1) {
        mo = intToMo(((IConst) ctx.call_params().exprs().expr().get(1).accept(visitor)).getValueAsInt());
    }
    visitor.programBuilder.addChild(visitor.threadCount, Atomic.newLoad(reg, add, mo)).setCLine(visitor.currentLine).setSourceCodeFile(visitor.sourceCodeFile);
}
Also used : Register(com.dat3m.dartagnan.program.Register) IExpr(com.dat3m.dartagnan.expression.IExpr) IConst(com.dat3m.dartagnan.expression.IConst)

Example 5 with IConst

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

the class AtomicProcedures method DAT3M_CAS.

private static void DAT3M_CAS(VisitorBoogie visitor, Call_cmdContext ctx) {
    Register reg = visitor.programBuilder.getOrCreateRegister(visitor.threadCount, visitor.currentScope.getID() + ":" + ctx.call_params().Ident(0).getText(), ARCH_PRECISION);
    List<BoogieParser.ExprContext> params = ctx.call_params().exprs().expr();
    IExpr addr = (IExpr) params.get(0).accept(visitor);
    IExpr expectedVal = (IExpr) params.get(1).accept(visitor);
    IExpr desiredVal = (IExpr) params.get(2).accept(visitor);
    String mo = null;
    if (params.size() > 3) {
        mo = intToMo(((IConst) params.get(3).accept(visitor)).getValueAsInt());
    }
    visitor.programBuilder.addChild(visitor.threadCount, Atomic.newDat3mCAS(reg, addr, expectedVal, desiredVal, mo)).setCLine(visitor.currentLine).setSourceCodeFile(visitor.sourceCodeFile);
}
Also used : Register(com.dat3m.dartagnan.program.Register) IExpr(com.dat3m.dartagnan.expression.IExpr) IConst(com.dat3m.dartagnan.expression.IConst)

Aggregations

IConst (com.dat3m.dartagnan.expression.IConst)8 IExpr (com.dat3m.dartagnan.expression.IExpr)7 Register (com.dat3m.dartagnan.program.Register)7 ExprInterface (com.dat3m.dartagnan.expression.ExprInterface)3 IExprBin (com.dat3m.dartagnan.expression.IExprBin)1 IOpBin (com.dat3m.dartagnan.expression.op.IOpBin)1 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 Local (com.dat3m.dartagnan.program.event.core.Local)1 RegWriter (com.dat3m.dartagnan.program.event.core.utils.RegWriter)1 FilterBasic (com.dat3m.dartagnan.program.filter.FilterBasic)1 MemoryObject (com.dat3m.dartagnan.program.memory.MemoryObject)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