Search in sources :

Example 81 with Event

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;
}
Also used : BExpr(com.dat3m.dartagnan.expression.BExpr) BConst(com.dat3m.dartagnan.expression.BConst) Label(com.dat3m.dartagnan.program.event.core.Label) Event(com.dat3m.dartagnan.program.event.core.Event)

Example 82 with Event

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());
}
Also used : Tag(com.dat3m.dartagnan.program.event.Tag) EquivalenceClass(com.dat3m.dartagnan.utils.equivalence.EquivalenceClass) ThreadSymmetry(com.dat3m.dartagnan.program.analysis.ThreadSymmetry) Logger(org.apache.logging.log4j.Logger) Configuration(org.sosy_lab.common.configuration.Configuration) Program(com.dat3m.dartagnan.program.Program) Event(com.dat3m.dartagnan.program.event.core.Event) Set(java.util.Set) Thread(com.dat3m.dartagnan.program.Thread) LogManager(org.apache.logging.log4j.LogManager) Collectors(java.util.stream.Collectors) InvalidConfigurationException(org.sosy_lab.common.configuration.InvalidConfigurationException) Event(com.dat3m.dartagnan.program.event.core.Event) ThreadSymmetry(com.dat3m.dartagnan.program.analysis.ThreadSymmetry) Thread(com.dat3m.dartagnan.program.Thread)

Example 83 with Event

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;
}
Also used : Event(com.dat3m.dartagnan.program.event.core.Event)

Example 84 with Event

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("=====================================");
    }
}
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)

Example 85 with Event

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;
}
Also used : Register(com.dat3m.dartagnan.program.Register) Label(com.dat3m.dartagnan.program.event.core.Label) Event(com.dat3m.dartagnan.program.event.core.Event) IExpr(com.dat3m.dartagnan.expression.IExpr) Atom(com.dat3m.dartagnan.expression.Atom)

Aggregations

Event (com.dat3m.dartagnan.program.event.core.Event)104 Tuple (com.dat3m.dartagnan.wmm.utils.Tuple)34 Thread (com.dat3m.dartagnan.program.Thread)32 Register (com.dat3m.dartagnan.program.Register)25 TupleSet (com.dat3m.dartagnan.wmm.utils.TupleSet)25 MemEvent (com.dat3m.dartagnan.program.event.core.MemEvent)20 Tag (com.dat3m.dartagnan.program.event.Tag)16 Label (com.dat3m.dartagnan.program.event.core.Label)16 Collectors (java.util.stream.Collectors)16 BooleanFormula (org.sosy_lab.java_smt.api.BooleanFormula)16 BooleanFormulaManager (org.sosy_lab.java_smt.api.BooleanFormulaManager)16 LogManager (org.apache.logging.log4j.LogManager)15 Logger (org.apache.logging.log4j.Logger)15 Program (com.dat3m.dartagnan.program.Program)12 ExecutionAnalysis (com.dat3m.dartagnan.program.analysis.ExecutionAnalysis)12 RegWriter (com.dat3m.dartagnan.program.event.core.utils.RegWriter)12 java.util (java.util)12 SolverContext (org.sosy_lab.java_smt.api.SolverContext)12 FilterBasic (com.dat3m.dartagnan.program.filter.FilterBasic)11 CondJump (com.dat3m.dartagnan.program.event.core.CondJump)10