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