use of com.dat3m.dartagnan.program.event.core.Event in project Dat3M by hernanponcedeleon.
the class Simplifier method simplifyJump.
private boolean simplifyJump(CondJump jump) {
Label label = jump.getLabel();
Event successor = jump.getSuccessor();
BExpr expr = jump.getGuard();
if (label.equals(successor) && expr instanceof BConst) {
jump.delete();
return true;
}
return false;
}
use of com.dat3m.dartagnan.program.event.core.Event in project Dat3M by hernanponcedeleon.
the class SymmetryReduction method run.
public void run(Program program) {
ThreadSymmetry symm = ThreadSymmetry.withoutMappings(program);
Set<? extends EquivalenceClass<Thread>> symmClasses = symm.getNonTrivialClasses();
if (symmClasses.isEmpty()) {
return;
}
for (EquivalenceClass<Thread> c : symmClasses) {
Thread rep = c.getRepresentative();
if (rep.getEvents().stream().noneMatch(x -> x.is(Tag.ASSERTION))) {
continue;
}
rep.setName(rep.getName() + "__symm_unique");
for (Thread t : c.stream().filter(x -> x != rep).collect(Collectors.toList())) {
for (Event e : t.getEvents()) {
if (e.is(Tag.ASSERTION)) {
e.getSuccessor().delete();
e.delete();
}
}
t.clearCache();
}
}
logger.info("Reduced symmetry of {} many symmetry classes", symmClasses.size());
}
use of com.dat3m.dartagnan.program.event.core.Event in project Dat3M by hernanponcedeleon.
the class Compilation method compileThread.
private int compileThread(Thread thread, int nextId, EventVisitor<List<Event>> visitor) {
Event pred = thread.getEntry();
Event toBeCompiled = pred.getSuccessor();
pred.setCId(nextId++);
while (toBeCompiled != null) {
List<Event> compiledEvents = toBeCompiled.accept(visitor);
for (Event e : compiledEvents) {
e.setOId(toBeCompiled.getOId());
e.setUId(toBeCompiled.getUId());
e.setCId(nextId++);
e.setThread(thread);
e.setCLine(toBeCompiled.getCLine());
e.setSourceCodeFile(toBeCompiled.getSourceCodeFile());
pred.setSuccessor(e);
pred = e;
}
toBeCompiled = toBeCompiled.getSuccessor();
}
thread.updateExit(thread.getEntry());
thread.clearCache();
return nextId;
}
use of com.dat3m.dartagnan.program.event.core.Event in project Dat3M by hernanponcedeleon.
the class Compilation method run.
@Override
public void run(Program program) {
if (program.isCompiled()) {
logger.warn("Skipped compilation: Program is already compiled to {}", program.getArch());
return;
}
Preconditions.checkArgument(program.isUnrolled(), "The program needs to be unrolled before compilation.");
EventVisitor<List<Event>> visitor;
switch(target) {
case C11:
visitor = new VisitorC11();
break;
case LKMM:
visitor = new VisitorLKMM();
break;
case TSO:
visitor = new VisitorTso();
break;
case POWER:
visitor = new VisitorPower();
break;
case ARM8:
visitor = new VisitorArm8();
break;
case IMM:
visitor = new VisitorIMM();
break;
default:
throw new UnsupportedOperationException(String.format("Compilation to %s is not supported.", target));
}
int nextId = 0;
for (Thread thread : program.getThreads()) {
nextId = compileThread(thread, nextId, visitor);
int fId = 0;
for (Event e : thread.getEvents()) {
e.setFId(fId++);
}
}
program.setArch(target);
program.clearCache(false);
program.markAsCompiled();
logger.info("Program compiled to {}", target);
if (print) {
System.out.println("===== Program after compilation =====");
System.out.println(new Printer().print(program));
System.out.println("=====================================");
}
}
use of com.dat3m.dartagnan.program.event.core.Event in project Dat3M by hernanponcedeleon.
the class VisitorBase method visitUnlock.
@Override
public List<Event> visitUnlock(Unlock e) {
Register resultRegister = e.getResultRegister();
IExpr address = e.getAddress();
String mo = e.getMo();
List<Event> events = eventSequence(newLoad(resultRegister, address, mo), newJump(new Atom(resultRegister, NEQ, IValue.ONE), (Label) e.getThread().getExit()), newStore(address, IValue.ZERO, mo));
for (Event child : events) {
child.addFilters(C11.LOCK, RMW);
}
return events;
}
Aggregations