public void UnsignedIntegerOverflow()
 {
     Debug.Assert(IntegerTwiddling.IsAddOverflow(ulong.MaxValue, 1ul));
     Debug.Assert(!IntegerTwiddling.IsAddOverflow(ulong.MaxValue, 0ul));
     Debug.Assert(!IntegerTwiddling.IsAddOverflow(0ul, 0ul));
     Debug.Assert(!IntegerTwiddling.IsAddOverflow(0ul, ulong.MaxValue));
 }
Beispiel #2
0
        public override void Transform(Context context, TransformContext transformContext)
        {
            var result  = context.Result;
            var result2 = context.Result2;

            var t1 = context.Operand1.ConstantUnsigned64;
            var t2 = context.Operand2.ConstantUnsigned64;

            var e1    = transformContext.CreateConstant(t1 + t2);
            var carry = IntegerTwiddling.IsAddOverflow(t1, t2);

            context.SetInstruction(IRInstruction.Move64, result, e1);
            context.AppendInstruction(IRInstruction.Move64, result2, carry ? transformContext.CreateConstant(1) : transformContext.ConstantZero64);
        }
 public void SignedIntegerOverflow()
 {
     Debug.Assert(IntegerTwiddling.IsAddOverflow(2147483640, 10));
     Debug.Assert(!IntegerTwiddling.IsAddOverflow(0, 0));
 }