use of com.dat3m.dartagnan.utils.printer.Printer 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("=====================================");
}
}
Aggregations