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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations