Search in sources :

Example 11 with Printer

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("=====================================");
    }
}
Also used : Printer(com.dat3m.dartagnan.utils.printer.Printer) Thread(com.dat3m.dartagnan.program.Thread) Event(com.dat3m.dartagnan.program.event.core.Event) List(java.util.List)

Aggregations

Printer (com.dat3m.dartagnan.utils.printer.Printer)11 ProgramParser (com.dat3m.dartagnan.parsers.program.ProgramParser)8 Program (com.dat3m.dartagnan.program.Program)8 File (java.io.File)8 Test (org.junit.Test)8 Thread (com.dat3m.dartagnan.program.Thread)3 Event (com.dat3m.dartagnan.program.event.core.Event)1 List (java.util.List)1