use of com.dat3m.dartagnan.program.Register in project Dat3M by hernanponcedeleon.
the class VisitorLitmusAArch64 method visitMov.
@Override
public Object visitMov(LitmusAArch64Parser.MovContext ctx) {
Register register = programBuilder.getOrCreateRegister(mainThread, ctx.rD, ARCH_PRECISION);
IExpr expr = ctx.expr32() != null ? (IExpr) ctx.expr32().accept(this) : (IExpr) ctx.expr64().accept(this);
return programBuilder.addChild(mainThread, EventFactory.newLocal(register, expr));
}
use of com.dat3m.dartagnan.program.Register in project Dat3M by hernanponcedeleon.
the class VisitorLitmusAArch64 method visitStore.
@Override
public Object visitStore(LitmusAArch64Parser.StoreContext ctx) {
Register register = programBuilder.getOrCreateRegister(mainThread, ctx.rV, ARCH_PRECISION);
Register address = programBuilder.getOrErrorRegister(mainThread, ctx.address().id);
if (ctx.offset() != null) {
address = visitOffset(ctx.offset(), address);
}
return programBuilder.addChild(mainThread, EventFactory.newStore(address, register, ctx.storeInstruction().mo));
}
use of com.dat3m.dartagnan.program.Register in project Dat3M by hernanponcedeleon.
the class VisitorLitmusAArch64 method visitLoadExclusive.
@Override
public Object visitLoadExclusive(LitmusAArch64Parser.LoadExclusiveContext ctx) {
Register register = programBuilder.getOrCreateRegister(mainThread, ctx.rD, ARCH_PRECISION);
Register address = programBuilder.getOrErrorRegister(mainThread, ctx.address().id);
if (ctx.offset() != null) {
address = visitOffset(ctx.offset(), address);
}
Load load = EventFactory.newRMWLoadExclusive(register, address, ctx.loadExclusiveInstruction().mo);
return programBuilder.addChild(mainThread, load);
}
use of com.dat3m.dartagnan.program.Register in project Dat3M by hernanponcedeleon.
the class VisitorLitmusAArch64 method visitCmp.
@Override
public Object visitCmp(LitmusAArch64Parser.CmpContext ctx) {
Register register = programBuilder.getOrCreateRegister(mainThread, ctx.rD, ARCH_PRECISION);
IExpr expr = ctx.expr32() != null ? (IExpr) ctx.expr32().accept(this) : (IExpr) ctx.expr64().accept(this);
return programBuilder.addChild(mainThread, EventFactory.newCompare(register, expr));
}
use of com.dat3m.dartagnan.program.Register in project Dat3M by hernanponcedeleon.
the class ConstantPropagation method evaluate.
// TODO Once we have a lattice class this should be moved there.
private ExprInterface evaluate(ExprInterface input, Map<Register, ExprInterface> map) {
ExprSimplifier simplifier = new ExprSimplifier();
if (input instanceof INonDet || input instanceof BNonDet) {
return TOP;
}
if (input instanceof IConst || input instanceof BConst) {
return input;
}
if (input instanceof Register) {
// have the key in the map.
return map.getOrDefault(input, input);
}
if (input instanceof IExprUn) {
IExprUn un = (IExprUn) input;
IOpUn op = un.getOp();
// These two can cause problems
if (op.equals(BV2INT) || op.equals(BV2UINT)) {
return input;
}
IExpr inner = (IExpr) evaluate(un.getInner(), map);
return inner == TOP ? inner : new IExprUn(op, inner).visit(simplifier);
}
if (input instanceof IExprBin) {
IExprBin bin = (IExprBin) input;
IExpr lhs = (IExpr) evaluate(bin.getLHS(), map);
IExpr rhs = (IExpr) evaluate(bin.getRHS(), map);
return lhs == TOP || rhs == TOP ? TOP : new IExprBin(lhs, bin.getOp(), rhs).visit(simplifier);
}
if (input instanceof IfExpr) {
IfExpr ife = (IfExpr) input;
ExprInterface guard = evaluate(ife.getGuard(), map);
IExpr tbranch = (IExpr) evaluate(ife.getTrueBranch(), map);
IExpr fbranch = (IExpr) evaluate(ife.getFalseBranch(), map);
return tbranch == TOP || fbranch == TOP || guard == TOP ? TOP : new IfExpr((BExpr) guard, tbranch, fbranch).visit(simplifier);
}
if (input instanceof Atom) {
Atom atom = (Atom) input;
ExprInterface lhs = evaluate(atom.getLHS(), map);
ExprInterface rhs = evaluate(atom.getRHS(), map);
return (lhs == TOP | rhs == TOP) ? TOP : new Atom(lhs, atom.getOp(), rhs).visit(simplifier);
}
if (input instanceof BExprUn) {
BExprUn un = (BExprUn) input;
BOpUn op = un.getOp();
ExprInterface inner = evaluate(un.getInner(), map);
return inner == TOP ? TOP : new BExprUn(op, inner).visit(simplifier);
}
if (input instanceof BExprBin) {
BExprBin bin = (BExprBin) input;
ExprInterface lhs = evaluate(bin.getLHS(), map);
ExprInterface rhs = evaluate(bin.getRHS(), map);
return (lhs == TOP | rhs == TOP) ? TOP : new BExprBin(lhs, bin.getOp(), rhs).visit(simplifier);
}
throw new UnsupportedOperationException(String.format("Expression %s not supported", input));
}
Aggregations