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));
}
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;
}
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;
}
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);
}
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;
}
Aggregations