Search in sources :

Example 1 with IValue

use of com.dat3m.dartagnan.expression.IValue in project Dat3M by hernanponcedeleon.

the class VisitorLitmusX86 method visitLoadValueToRegister.

@Override
public Object visitLoadValueToRegister(LitmusX86Parser.LoadValueToRegisterContext ctx) {
    Register register = programBuilder.getOrCreateRegister(mainThread, ctx.register().getText(), ARCH_PRECISION);
    IValue constant = new IValue(new BigInteger(ctx.constant().getText()), ARCH_PRECISION);
    return programBuilder.addChild(mainThread, EventFactory.newLocal(register, constant));
}
Also used : IValue(com.dat3m.dartagnan.expression.IValue) Register(com.dat3m.dartagnan.program.Register) BigInteger(java.math.BigInteger)

Example 2 with IValue

use of com.dat3m.dartagnan.expression.IValue in project Dat3M by hernanponcedeleon.

the class VisitorLitmusAArch64 method visitExpressionRegister64.

@Override
public IExpr visitExpressionRegister64(LitmusAArch64Parser.ExpressionRegister64Context ctx) {
    IExpr expr = programBuilder.getOrCreateRegister(mainThread, ctx.register64().id, ARCH_PRECISION);
    if (ctx.shift() != null) {
        IValue val = new IValue(new BigInteger(ctx.shift().immediate().constant().getText()), ARCH_PRECISION);
        expr = new IExprBin(expr, ctx.shift().shiftOperator().op, val);
    }
    return expr;
}
Also used : IExprBin(com.dat3m.dartagnan.expression.IExprBin) IValue(com.dat3m.dartagnan.expression.IValue) BigInteger(java.math.BigInteger) IExpr(com.dat3m.dartagnan.expression.IExpr)

Example 3 with IValue

use of com.dat3m.dartagnan.expression.IValue in project Dat3M by hernanponcedeleon.

the class VisitorLitmusAArch64 method visitExpressionImmediate.

@Override
public IExpr visitExpressionImmediate(LitmusAArch64Parser.ExpressionImmediateContext ctx) {
    IExpr expr = new IValue(new BigInteger(ctx.immediate().constant().getText()), ARCH_PRECISION);
    if (ctx.shift() != null) {
        IValue val = new IValue(new BigInteger(ctx.shift().immediate().constant().getText()), ARCH_PRECISION);
        expr = new IExprBin(expr, ctx.shift().shiftOperator().op, val);
    }
    return expr;
}
Also used : IExprBin(com.dat3m.dartagnan.expression.IExprBin) IValue(com.dat3m.dartagnan.expression.IValue) BigInteger(java.math.BigInteger) IExpr(com.dat3m.dartagnan.expression.IExpr)

Example 4 with IValue

use of com.dat3m.dartagnan.expression.IValue in project Dat3M by hernanponcedeleon.

the class ExecutionStatus method encodeExec.

@Override
public BooleanFormula encodeExec(SolverContext ctx) {
    BooleanFormulaManager bmgr = ctx.getFormulaManager().getBooleanFormulaManager();
    int precision = register.getPrecision();
    BooleanFormula enc = bmgr.and(bmgr.implication(event.exec(), generalEqual(regResultExpr, new IValue(BigInteger.ZERO, precision).toIntFormula(this, ctx), ctx)), bmgr.implication(bmgr.not(event.exec()), generalEqual(regResultExpr, new IValue(BigInteger.ONE, precision).toIntFormula(this, ctx), ctx)));
    return bmgr.and(super.encodeExec(ctx), enc);
}
Also used : BooleanFormulaManager(org.sosy_lab.java_smt.api.BooleanFormulaManager) IValue(com.dat3m.dartagnan.expression.IValue) BooleanFormula(org.sosy_lab.java_smt.api.BooleanFormula)

Example 5 with IValue

use of com.dat3m.dartagnan.expression.IValue in project Dat3M by hernanponcedeleon.

the class BasicRegRelation method doEncodeApprox.

BooleanFormula doEncodeApprox(Collection<Event> regReaders, SolverContext ctx) {
    FormulaManager fmgr = ctx.getFormulaManager();
    BooleanFormulaManager bmgr = fmgr.getBooleanFormulaManager();
    BooleanFormula enc = bmgr.makeTrue();
    ImmutableMap<Register, ImmutableList<Event>> regWriterMap = task.getProgram().getCache().getRegWriterMap();
    for (Event regReader : regReaders) {
        Set<Tuple> writerReaders = maxTupleSet.getBySecond(regReader);
        for (Register register : getRegisters(regReader)) {
            List<Event> writers = regWriterMap.getOrDefault(register, ImmutableList.of());
            List<Event> possibleWriters = writers.stream().filter(x -> writerReaders.contains(new Tuple(x, regReader))).collect(Collectors.toList());
            if (writers.isEmpty() || writers.get(0).getCId() >= regReader.getCId()) {
                BooleanFormula equal = generalEqual(register.toIntFormula(regReader, ctx), new IValue(BigInteger.ZERO, register.getPrecision()).toIntFormula(ctx), ctx);
                enc = bmgr.and(enc, equal);
            } else {
                for (int i = 0; i < possibleWriters.size(); i++) {
                    Event regWriter = possibleWriters.get(i);
                    // RegReader uses the value of RegWriter if it is executed ..
                    BooleanFormula clause = getExecPair(regWriter, regReader, ctx);
                    BooleanFormula edge = this.getSMTVar(regWriter, regReader, ctx);
                    // .. and no other write to the same register is executed in between
                    for (int j = i + 1; j < possibleWriters.size(); j++) {
                        clause = bmgr.and(clause, bmgr.not(possibleWriters.get(j).exec()));
                    }
                    // Encode edge and value binding
                    enc = bmgr.and(enc, bmgr.equivalence(edge, clause));
                    BooleanFormula equal = generalEqual(((RegWriter) regWriter).getResultRegisterExpr(), register.toIntFormula(regReader, ctx), ctx);
                    enc = bmgr.and(enc, bmgr.implication(edge, equal));
                }
            }
        }
    }
    return enc;
}
Also used : FormulaManager(org.sosy_lab.java_smt.api.FormulaManager) ImmutableMap(com.google.common.collect.ImmutableMap) ExecutionAnalysis(com.dat3m.dartagnan.program.analysis.ExecutionAnalysis) Collection(java.util.Collection) BooleanFormula(org.sosy_lab.java_smt.api.BooleanFormula) Set(java.util.Set) Collectors(java.util.stream.Collectors) BooleanFormulaManager(org.sosy_lab.java_smt.api.BooleanFormulaManager) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) TupleSet(com.dat3m.dartagnan.wmm.utils.TupleSet) SolverContext(org.sosy_lab.java_smt.api.SolverContext) IValue(com.dat3m.dartagnan.expression.IValue) Event(com.dat3m.dartagnan.program.event.core.Event) Tuple(com.dat3m.dartagnan.wmm.utils.Tuple) BigInteger(java.math.BigInteger) Register(com.dat3m.dartagnan.program.Register) RegWriter(com.dat3m.dartagnan.program.event.core.utils.RegWriter) StaticRelation(com.dat3m.dartagnan.wmm.relation.base.stat.StaticRelation) Utils.generalEqual(com.dat3m.dartagnan.expression.utils.Utils.generalEqual) BooleanFormulaManager(org.sosy_lab.java_smt.api.BooleanFormulaManager) ImmutableList(com.google.common.collect.ImmutableList) IValue(com.dat3m.dartagnan.expression.IValue) FormulaManager(org.sosy_lab.java_smt.api.FormulaManager) BooleanFormulaManager(org.sosy_lab.java_smt.api.BooleanFormulaManager) Register(com.dat3m.dartagnan.program.Register) Event(com.dat3m.dartagnan.program.event.core.Event) BooleanFormula(org.sosy_lab.java_smt.api.BooleanFormula) Tuple(com.dat3m.dartagnan.wmm.utils.Tuple)

Aggregations

IValue (com.dat3m.dartagnan.expression.IValue)11 BigInteger (java.math.BigInteger)10 IExprBin (com.dat3m.dartagnan.expression.IExprBin)5 Register (com.dat3m.dartagnan.program.Register)5 IExpr (com.dat3m.dartagnan.expression.IExpr)4 MemoryObject (com.dat3m.dartagnan.program.memory.MemoryObject)2 BooleanFormula (org.sosy_lab.java_smt.api.BooleanFormula)2 BooleanFormulaManager (org.sosy_lab.java_smt.api.BooleanFormulaManager)2 Utils.generalEqual (com.dat3m.dartagnan.expression.utils.Utils.generalEqual)1 ExecutionAnalysis (com.dat3m.dartagnan.program.analysis.ExecutionAnalysis)1 Event (com.dat3m.dartagnan.program.event.core.Event)1 RegWriter (com.dat3m.dartagnan.program.event.core.utils.RegWriter)1 Location (com.dat3m.dartagnan.program.memory.Location)1 StaticRelation (com.dat3m.dartagnan.wmm.relation.base.stat.StaticRelation)1 Tuple (com.dat3m.dartagnan.wmm.utils.Tuple)1 TupleSet (com.dat3m.dartagnan.wmm.utils.TupleSet)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Collection (java.util.Collection)1 List (java.util.List)1