Exemple #1
0
        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));
        }
Exemple #2
0
 protected BitVecExpr Eval(IArithmetic x)
 {
     if (x is BitVecWrapper a)
     {
         return(a.expr);
     }
     else
     {
         throw new ArgumentException("type mismatch");
     }
 }
Exemple #3
0
 protected ulong Eval(IArithmetic x)
 {
     if (x is Arithmetic a)
     {
         return(a.expr);
     }
     else
     {
         throw new ArgumentException("type mismatch");
     }
 }
Exemple #4
0
 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();
     }
 }
Exemple #5
0
        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)));
        }
Exemple #6
0
 public override IArithmetic Ror(IArithmetic sh) => new BitVecWrapper(context.MkBVRotateRight(expr, Eval(sh)), context);
Exemple #7
0
 public override IArithmetic Sar(IArithmetic sh) => new BitVecWrapper(context.MkBVASHR(expr, Eval(sh)), context);
Exemple #8
0
 public abstract IArithmetic Ror(IArithmetic sh);
Exemple #9
0
 public abstract IArithmetic Shl(IArithmetic sh);
Exemple #10
0
 public abstract IArithmetic And(IArithmetic r);
Exemple #11
0
 public abstract IArithmetic Sub(IArithmetic r);
Exemple #12
0
 public override object NotEquals(IArithmetic r) => expr != Eval(r);
Exemple #13
0
 public override IArithmetic Ror(IArithmetic sh) => new Arithmetic(expr >> (int)(Eval(sh) & 0x3f) | expr << (64 - (int)(Eval(sh) & 0x3f)));
Exemple #14
0
 public override IArithmetic Sar(IArithmetic sh) => new Arithmetic((ulong)((long)expr >> (int)(Eval(sh) & 0x3f)));
Exemple #15
0
 public override IArithmetic Shr(IArithmetic sh) => new Arithmetic(expr >> (int)(Eval(sh) & 0x3f));
Exemple #16
0
 public override IArithmetic Or(IArithmetic r) => new Arithmetic(expr | Eval(r));
Exemple #17
0
 public override IArithmetic And(IArithmetic r) => new Arithmetic(expr & Eval(r));
Exemple #18
0
 public override IArithmetic Xor(IArithmetic r) => new Arithmetic(expr ^ Eval(r));
Exemple #19
0
 public static IArithmetic Output(IArithmetic s)
 {
     return(s << 2 ^ s.Sar(19));
 }
Exemple #20
0
 public static IArithmetic Output(IArithmetic s, IArithmetic c)
 {
     return((s + c).Rol(15) - s);
 }
Exemple #21
0
 public override object NotEquals(IArithmetic r) => context.MkNot(Equals(r) as BoolExpr);
Exemple #22
0
 public abstract IArithmetic MulHi(IArithmetic r);
Exemple #23
0
 public override IArithmetic Add(IArithmetic r) => new Arithmetic(expr + Eval(r));
Exemple #24
0
 public abstract IArithmetic Or(IArithmetic r);
Exemple #25
0
 public override IArithmetic Sub(IArithmetic r) => new Arithmetic(expr - Eval(r));
Exemple #26
0
 public abstract IArithmetic Sar(IArithmetic sh);
Exemple #27
0
 public override IArithmetic Or(IArithmetic r) => new BitVecWrapper(context.MkBVOR(expr, Eval(r)), context);
Exemple #28
0
 public abstract object NotEquals(IArithmetic r);
Exemple #29
0
 public override IArithmetic Mul(IArithmetic r) => new Arithmetic(expr * Eval(r));