Search in sources :

Example 1 with Memory

use of com.dat3m.dartagnan.program.memory.Memory in project Dat3M by hernanponcedeleon.

the class ProgramEncoder method encodeMemory.

// Assigns each Address a fixed memory address.
public BooleanFormula encodeMemory(SolverContext ctx) {
    checkInitialized();
    logger.info("Encoding fixed memory");
    Memory memory = program.getMemory();
    FormulaManager fmgr = ctx.getFormulaManager();
    BooleanFormula[] addrExprs;
    if (ARCH_PRECISION > -1) {
        BitvectorFormulaManager bvmgr = fmgr.getBitvectorFormulaManager();
        addrExprs = memory.getObjects().stream().map(addr -> bvmgr.equal((BitvectorFormula) addr.toIntFormula(ctx), bvmgr.makeBitvector(ARCH_PRECISION, addr.getValue().intValue()))).toArray(BooleanFormula[]::new);
    } else {
        IntegerFormulaManager imgr = fmgr.getIntegerFormulaManager();
        addrExprs = memory.getObjects().stream().map(addr -> imgr.equal((IntegerFormula) addr.toIntFormula(ctx), imgr.makeNumber(addr.getValue().intValue()))).toArray(BooleanFormula[]::new);
    }
    return fmgr.getBooleanFormulaManager().and(addrExprs);
}
Also used : Memory(com.dat3m.dartagnan.program.memory.Memory) IntegerFormula(org.sosy_lab.java_smt.api.NumeralFormula.IntegerFormula)

Aggregations

Memory (com.dat3m.dartagnan.program.memory.Memory)1 IntegerFormula (org.sosy_lab.java_smt.api.NumeralFormula.IntegerFormula)1