Search in sources :

Example 16 with MemEvent

use of dartagnan.program.MemEvent in project Dat3M by hernanponcedeleon.

the class Encodings method encodeReachedState.

public static BoolExpr encodeReachedState(Program p, Model model, Context ctx) {
    Set<Location> locs = p.getEvents().stream().filter(e -> e instanceof MemEvent).map(e -> e.getLoc()).collect(Collectors.toSet());
    BoolExpr reachedState = ctx.mkTrue();
    for (Location loc : locs) {
        reachedState = ctx.mkAnd(reachedState, ctx.mkEq(lastValueLoc(loc, ctx), model.getConstInterp(lastValueLoc(loc, ctx))));
    }
    Set<Event> executedEvents = p.getEvents().stream().filter(e -> model.getConstInterp(e.executes(ctx)).isTrue()).collect(Collectors.toSet());
    Set<Register> regs = executedEvents.stream().filter(e -> e instanceof Local | e instanceof Load).map(e -> e.getReg()).collect(Collectors.toSet());
    for (Register reg : regs) {
        reachedState = ctx.mkAnd(reachedState, ctx.mkEq(lastValueReg(reg, ctx), model.getConstInterp(lastValueReg(reg, ctx))));
    }
    return reachedState;
}
Also used : HighLocation(dartagnan.program.HighLocation) Utils.lastValueReg(dartagnan.utils.Utils.lastValueReg) Utils.uniqueValue(dartagnan.utils.Utils.uniqueValue) com.microsoft.z3(com.microsoft.z3) Event(dartagnan.program.Event) Set(java.util.Set) If(dartagnan.program.If) Collectors(java.util.stream.Collectors) Utils.initValue(dartagnan.utils.Utils.initValue) Init(dartagnan.program.Init) Register(dartagnan.program.Register) Utils.initValue2(dartagnan.utils.Utils.initValue2) Local(dartagnan.program.Local) Load(dartagnan.program.Load) MemEvent(dartagnan.program.MemEvent) Utils.ssaReg(dartagnan.utils.Utils.ssaReg) Program(dartagnan.program.Program) Utils.edge(dartagnan.utils.Utils.edge) Utils.lastValueLoc(dartagnan.utils.Utils.lastValueLoc) Store(dartagnan.program.Store) MapSSA(dartagnan.utils.MapSSA) Location(dartagnan.program.Location) Load(dartagnan.program.Load) Register(dartagnan.program.Register) MemEvent(dartagnan.program.MemEvent) Event(dartagnan.program.Event) MemEvent(dartagnan.program.MemEvent) Local(dartagnan.program.Local) HighLocation(dartagnan.program.HighLocation) Location(dartagnan.program.Location)

Aggregations

Event (dartagnan.program.Event)16 MemEvent (dartagnan.program.MemEvent)16 Program (dartagnan.program.Program)15 Collectors (java.util.stream.Collectors)15 Local (dartagnan.program.Local)14 Set (java.util.Set)14 com.microsoft.z3 (com.microsoft.z3)11 Init (dartagnan.program.Init)11 Load (dartagnan.program.Load)11 Location (dartagnan.program.Location)11 Register (dartagnan.program.Register)11 Store (dartagnan.program.Store)11 Utils.edge (dartagnan.utils.Utils.edge)10 Utils (dartagnan.utils.Utils)6 Utils.lastValueLoc (dartagnan.utils.Utils.lastValueLoc)6 Utils.lastValueReg (dartagnan.utils.Utils.lastValueReg)6 Utils.ssaReg (dartagnan.utils.Utils.ssaReg)6 HighLocation (dartagnan.program.HighLocation)5 If (dartagnan.program.If)5 MapSSA (dartagnan.utils.MapSSA)5