enable llvm intrinsic call usub_with_overflow funtion.
authorLuo Xionghu <xionghu.luo@intel.com>
Sun, 2 Nov 2014 21:22:03 +0000 (05:22 +0800)
committerZhigang Gong <zhigang.gong@intel.com>
Mon, 3 Nov 2014 09:23:48 +0000 (17:23 +0800)
implement usub_with_overflow without any optimization.

v2:
fix the wrong implementation:
change ctx.LT(dst0Type, overflow, dst0, src1)
to ctx.GT(unsignedType, overflow, dst0, src0)

Signed-off-by: Luo Xionghu <xionghu.luo@intel.com>
Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
backend/src/llvm/llvm_gen_backend.cpp

index bb2c1dd..feb881d 100644 (file)
@@ -2805,9 +2805,23 @@ namespace gbe
             ctx.LT(dst0Type, overflow, dst0, src1);
           }
           break;
+          case Intrinsic::usub_with_overflow:
+          {
+            Type *llvmDstType = I.getType();
+            GBE_ASSERT(llvmDstType->isStructTy());
+            ir::Type dst0Type = getType(ctx, llvmDstType->getStructElementType(0));
+            const ir::Register dst0  = this->getRegister(&I, 0);
+            const ir::Register src0 = this->getRegister(I.getOperand(0));
+            const ir::Register src1 = this->getRegister(I.getOperand(1));
+            ctx.SUB(dst0Type, dst0, src0, src1);
+
+            ir::Register overflow = this->getRegister(&I, 1);
+            const ir::Type unsignedType = makeTypeUnsigned(dst0Type);
+            ctx.GT(unsignedType, overflow, dst0, src0);
+          }
+          break;
           case Intrinsic::sadd_with_overflow:
           case Intrinsic::ssub_with_overflow:
-          case Intrinsic::usub_with_overflow:
           case Intrinsic::smul_with_overflow:
           case Intrinsic::umul_with_overflow:
           NOT_IMPLEMENTED;