Search in sources :

Example 11 with IExpr

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

the class VisitorLitmusAArch64 method visitExpressionImmediate.

@Override
public IExpr visitExpressionImmediate(LitmusAArch64Parser.ExpressionImmediateContext ctx) {
    IExpr expr = new IValue(new BigInteger(ctx.immediate().constant().getText()), ARCH_PRECISION);
    if (ctx.shift() != null) {
        IValue val = new IValue(new BigInteger(ctx.shift().immediate().constant().getText()), ARCH_PRECISION);
        expr = new IExprBin(expr, ctx.shift().shiftOperator().op, val);
    }
    return expr;
}
Also used : IExprBin(com.dat3m.dartagnan.expression.IExprBin) IValue(com.dat3m.dartagnan.expression.IValue) BigInteger(java.math.BigInteger) IExpr(com.dat3m.dartagnan.expression.IExpr)

Example 12 with IExpr

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

the class VisitorLitmusAArch64 method visitCmp.

@Override
public Object visitCmp(LitmusAArch64Parser.CmpContext ctx) {
    Register register = programBuilder.getOrCreateRegister(mainThread, ctx.rD, ARCH_PRECISION);
    IExpr expr = ctx.expr32() != null ? (IExpr) ctx.expr32().accept(this) : (IExpr) ctx.expr64().accept(this);
    return programBuilder.addChild(mainThread, EventFactory.newCompare(register, expr));
}
Also used : Register(com.dat3m.dartagnan.program.Register) IExpr(com.dat3m.dartagnan.expression.IExpr)

Example 13 with IExpr

use of com.dat3m.dartagnan.expression.IExpr 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)

Example 14 with IExpr

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

the class AtomicProcedures method atomicCmpXchg.

private static void atomicCmpXchg(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);
    // NOTE: We assume a register here
    IExpr expectedAddr = (IExpr) params.get(1).accept(visitor);
    IExpr desiredVal = (IExpr) params.get(2).accept(visitor);
    String mo = null;
    boolean strong = ctx.getText().contains("strong");
    if (params.size() > 3) {
        mo = intToMo(((IConst) params.get(3).accept(visitor)).getValueAsInt());
    // NOTE: We forget about the 5th parameter (MO on fail) because it is never used
    // (see issue #123 for an explanation)
    }
    visitor.programBuilder.addChild(visitor.threadCount, Atomic.newCompareExchange(reg, addr, expectedAddr, desiredVal, mo, strong)).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 15 with IExpr

use of com.dat3m.dartagnan.expression.IExpr 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)

Aggregations

IExpr (com.dat3m.dartagnan.expression.IExpr)23 Register (com.dat3m.dartagnan.program.Register)16 IConst (com.dat3m.dartagnan.expression.IConst)7 IExprBin (com.dat3m.dartagnan.expression.IExprBin)6 ExprInterface (com.dat3m.dartagnan.expression.ExprInterface)4 IValue (com.dat3m.dartagnan.expression.IValue)4 BigInteger (java.math.BigInteger)4 ExprsContext (com.dat3m.dartagnan.parsers.BoogieParser.ExprsContext)2 Event (com.dat3m.dartagnan.program.event.core.Event)2 RegWriter (com.dat3m.dartagnan.program.event.core.utils.RegWriter)2 MemoryObject (com.dat3m.dartagnan.program.memory.MemoryObject)2 ParsingException (com.dat3m.dartagnan.exception.ParsingException)1 Atom (com.dat3m.dartagnan.expression.Atom)1 IOpBin (com.dat3m.dartagnan.expression.op.IOpBin)1 PLUS (com.dat3m.dartagnan.expression.op.IOpBin.PLUS)1 ExprContext (com.dat3m.dartagnan.parsers.BoogieParser.ExprContext)1 Program (com.dat3m.dartagnan.program.Program)1 AliasAnalysis (com.dat3m.dartagnan.program.analysis.AliasAnalysis)1 Tag (com.dat3m.dartagnan.program.event.Tag)1 com.dat3m.dartagnan.program.event.core (com.dat3m.dartagnan.program.event.core)1