use of com.dat3m.dartagnan.program.event.core.Label in project Dat3M by hernanponcedeleon.
the class SvcompProcedures method __VERIFIER_assert.
private static void __VERIFIER_assert(VisitorBoogie visitor, Call_cmdContext ctx) {
IExpr expr = (IExpr) ctx.call_params().exprs().accept(visitor);
Register ass = visitor.programBuilder.getOrCreateRegister(visitor.threadCount, "assert_" + visitor.assertionIndex, expr.getPrecision());
visitor.assertionIndex++;
if (expr instanceof IConst && ((IConst) expr).getValue().equals(BigInteger.ONE)) {
return;
}
Local event = EventFactory.newLocal(ass, expr);
event.addFilters(Tag.ASSERTION);
visitor.programBuilder.addChild(visitor.threadCount, event);
Label end = visitor.programBuilder.getOrCreateLabel("END_OF_T" + visitor.threadCount);
visitor.programBuilder.addChild(visitor.threadCount, EventFactory.newJump(new Atom(ass, NEQ, expr), end));
}
use of com.dat3m.dartagnan.program.event.core.Label in project Dat3M by hernanponcedeleon.
the class SvcompProcedures method __VERIFIER_atomic.
public static void __VERIFIER_atomic(VisitorBoogie visitor, boolean begin) {
Register register = visitor.programBuilder.getOrCreateRegister(visitor.threadCount, null, ARCH_PRECISION);
MemoryObject lockAddress = visitor.programBuilder.getOrNewObject("__VERIFIER_atomic");
Label label = visitor.programBuilder.getOrCreateLabel("END_OF_T" + visitor.threadCount);
LinkedList<Event> events = new LinkedList<>();
events.add(EventFactory.newLoad(register, lockAddress, null));
events.add(EventFactory.newJump(new Atom(register, NEQ, begin ? IValue.ZERO : IValue.ONE), label));
events.add(EventFactory.newStore(lockAddress, begin ? IValue.ONE : IValue.ZERO, null));
for (Event e : events) {
e.addFilters(Tag.C11.LOCK, Tag.RMW);
visitor.programBuilder.addChild(visitor.threadCount, e);
}
}
use of com.dat3m.dartagnan.program.event.core.Label in project Dat3M by hernanponcedeleon.
the class VisitorBoogie method visitAssert_cmd.
@Override
public Object visitAssert_cmd(Assert_cmdContext ctx) {
// In boogie transformation, assertions result in "assert false".
// The control flow checks the corresponding expression, thus
// we cannot just add the expression to the AbstractAssertion.
// We need to create an event carrying the value of the expression
// and see if this event can be executed.
IExpr expr = (IExpr) ctx.proposition().expr().accept(this);
Register ass = programBuilder.getOrCreateRegister(threadCount, "assert_" + assertionIndex, expr.getPrecision());
assertionIndex++;
programBuilder.addChild(threadCount, EventFactory.newLocal(ass, expr)).setCLine(currentLine).setSourceCodeFile(sourceCodeFile).addFilters(Tag.ASSERTION);
Label end = programBuilder.getOrCreateLabel("END_OF_T" + threadCount);
programBuilder.addChild(threadCount, EventFactory.newJump(new Atom(ass, COpBin.NEQ, IValue.ONE), end));
return null;
}
use of com.dat3m.dartagnan.program.event.core.Label in project Dat3M by hernanponcedeleon.
the class VisitorBoogie method visitProc_decl.
private void visitProc_decl(Proc_declContext ctx, boolean create, List<ExprInterface> callingValues) {
currentLine = -1;
if (ctx.proc_sign().proc_sign_out() != null) {
for (Attr_typed_idents_whereContext atiwC : ctx.proc_sign().proc_sign_out().attr_typed_idents_wheres().attr_typed_idents_where()) {
for (ParseTree ident : atiwC.typed_idents_where().typed_idents().idents().Ident()) {
currentReturnName = ident.getText();
}
}
}
if (create) {
threadCount++;
String name = ctx.proc_sign().Ident().getText();
programBuilder.initThread(name, threadCount);
if (threadCount != 1) {
// Used to allow execution of threads after they have been created (pthread_create)
MemoryObject object = programBuilder.getOrNewObject(String.format("%s(%s)_active", pool.getPtrFromInt(threadCount), pool.getCreatorFromPtr(pool.getPtrFromInt(threadCount))));
Register reg = programBuilder.getOrCreateRegister(threadCount, null, ARCH_PRECISION);
programBuilder.addChild(threadCount, EventFactory.Pthread.newStart(reg, object));
}
}
currentScope = new Scope(nextScopeID, currentScope);
nextScopeID++;
Impl_bodyContext body = ctx.impl_body();
if (body == null) {
throw new ParsingException(ctx.proc_sign().Ident().getText() + " cannot be handled");
}
if (ctx.proc_sign().proc_sign_in() != null) {
int index = 0;
for (Attr_typed_idents_whereContext atiwC : ctx.proc_sign().proc_sign_in().attr_typed_idents_wheres().attr_typed_idents_where()) {
for (ParseTree ident : atiwC.typed_idents_where().typed_idents().idents().Ident()) {
// To deal with references passed to created threads
if (index < callingValues.size()) {
String type = atiwC.typed_idents_where().typed_idents().type().getText();
int precision = type.contains("bv") ? Integer.parseInt(type.split("bv")[1]) : ARCH_PRECISION;
Register register = programBuilder.getOrCreateRegister(threadCount, currentScope.getID() + ":" + ident.getText(), precision);
ExprInterface value = callingValues.get(index);
programBuilder.addChild(threadCount, EventFactory.newLocal(register, value)).setCLine(currentLine).setSourceCodeFile(sourceCodeFile);
index++;
}
}
}
}
for (Local_varsContext localVarContext : body.local_vars()) {
visitLocal_vars(localVarContext, threadCount);
}
visitChildren(body.stmt_list());
Label label = programBuilder.getOrCreateLabel("END_OF_" + currentScope.getID());
programBuilder.addChild(threadCount, label);
currentScope = currentScope.getParent();
if (create) {
if (threadCount != 1) {
// Used to mark the end of the execution of a thread (used by pthread_join)
MemoryObject object = programBuilder.getOrNewObject(String.format("%s(%s)_active", pool.getPtrFromInt(threadCount), pool.getCreatorFromPtr(pool.getPtrFromInt(threadCount))));
programBuilder.addChild(threadCount, EventFactory.Pthread.newEnd(object));
}
}
}
use of com.dat3m.dartagnan.program.event.core.Label in project Dat3M by hernanponcedeleon.
the class VisitorBase method visitLock.
@Override
public List<Event> visitLock(Lock e) {
Register resultRegister = e.getResultRegister();
String mo = e.getMo();
List<Event> events = eventSequence(newLoad(resultRegister, e.getAddress(), mo), newJump(new Atom(resultRegister, NEQ, IValue.ZERO), (Label) e.getThread().getExit()), newStore(e.getAddress(), IValue.ONE, mo));
for (Event child : events) {
child.addFilters(C11.LOCK, RMW);
}
return events;
}
Aggregations