public override IArithmetic MulHi(IArithmetic r) { var a = context.MkZeroExt(expr.SortSize * 2, expr); var basemult = Eval(r); var b = context.MkZeroExt(basemult.SortSize * 2, basemult); var multed = context.MkBVMul(a, b); return(new BitVecWrapper(context.MkExtract(expr.SortSize * 2 - 1, expr.SortSize, multed), context)); }
protected BitVecExpr Eval(IArithmetic x) { if (x is BitVecWrapper a) { return(a.expr); } else { throw new ArgumentException("type mismatch"); } }
protected ulong Eval(IArithmetic x) { if (x is Arithmetic a) { return(a.expr); } else { throw new ArgumentException("type mismatch"); } }
public override object Equals(IArithmetic r) { if (r is BitVecWrapper x) { return(context.MkEq(expr, x.expr)); } else if (r is Arithmetic a) { return(context.MkEq(expr, context.MkBV((ulong)a.Expression, bits))); } else { throw new NotSupportedException(); } }
public override IArithmetic MulHi(IArithmetic r) { var mult = Eval(r); ulong al = (uint)expr, ah = expr >> 32, bl = (uint)mult, bh = mult >> 32; ulong ll = al * bl, lh = al * bh, hl = ah * bl, hh = ah * bh; ulong mid = hl + (ll >> 32) + (uint)lh; return(new Arithmetic(hh + (mid >> 32) + (lh >> 32))); }
public override IArithmetic Ror(IArithmetic sh) => new BitVecWrapper(context.MkBVRotateRight(expr, Eval(sh)), context);
public override IArithmetic Sar(IArithmetic sh) => new BitVecWrapper(context.MkBVASHR(expr, Eval(sh)), context);
public abstract IArithmetic Ror(IArithmetic sh);
public abstract IArithmetic Shl(IArithmetic sh);
public abstract IArithmetic And(IArithmetic r);
public abstract IArithmetic Sub(IArithmetic r);
public override object NotEquals(IArithmetic r) => expr != Eval(r);
public override IArithmetic Ror(IArithmetic sh) => new Arithmetic(expr >> (int)(Eval(sh) & 0x3f) | expr << (64 - (int)(Eval(sh) & 0x3f)));
public override IArithmetic Sar(IArithmetic sh) => new Arithmetic((ulong)((long)expr >> (int)(Eval(sh) & 0x3f)));
public override IArithmetic Shr(IArithmetic sh) => new Arithmetic(expr >> (int)(Eval(sh) & 0x3f));
public override IArithmetic Or(IArithmetic r) => new Arithmetic(expr | Eval(r));
public override IArithmetic And(IArithmetic r) => new Arithmetic(expr & Eval(r));
public override IArithmetic Xor(IArithmetic r) => new Arithmetic(expr ^ Eval(r));
public static IArithmetic Output(IArithmetic s) { return(s << 2 ^ s.Sar(19)); }
public static IArithmetic Output(IArithmetic s, IArithmetic c) { return((s + c).Rol(15) - s); }
public override object NotEquals(IArithmetic r) => context.MkNot(Equals(r) as BoolExpr);
public abstract IArithmetic MulHi(IArithmetic r);
public override IArithmetic Add(IArithmetic r) => new Arithmetic(expr + Eval(r));
public abstract IArithmetic Or(IArithmetic r);
public override IArithmetic Sub(IArithmetic r) => new Arithmetic(expr - Eval(r));
public abstract IArithmetic Sar(IArithmetic sh);
public override IArithmetic Or(IArithmetic r) => new BitVecWrapper(context.MkBVOR(expr, Eval(r)), context);
public abstract object NotEquals(IArithmetic r);
public override IArithmetic Mul(IArithmetic r) => new Arithmetic(expr * Eval(r));