LinearScanner hotspot.
[oota-llvm.git] / lib / CodeGen / IntrinsicLowering.cpp
index c47a107cc33310403b15ff67ff9f4806f1a06989..b5a03fc54d53e4aff1595a63a7803cf73067123b 100644 (file)
@@ -99,15 +99,18 @@ void DefaultIntrinsicLowering::AddPrototypes(Module &M) {
         EnsureFunctionExists(M, "abort", I->arg_end(), I->arg_end(),
                              Type::VoidTy);
         break;
-      case Intrinsic::memcpy:
+      case Intrinsic::memcpy_i32:
+      case Intrinsic::memcpy_i64:
         EnsureFunctionExists(M, "memcpy", I->arg_begin(), --I->arg_end(),
                              I->arg_begin()->getType());
         break;
-      case Intrinsic::memmove:
+      case Intrinsic::memmove_i32:
+      case Intrinsic::memmove_i64:
         EnsureFunctionExists(M, "memmove", I->arg_begin(), --I->arg_end(),
                              I->arg_begin()->getType());
         break;
-      case Intrinsic::memset:
+      case Intrinsic::memset_i32:
+      case Intrinsic::memset_i64:
         M.getOrInsertFunction("memset", PointerType::get(Type::SByteTy),
                               PointerType::get(Type::SByteTy),
                               Type::IntTy, (--(--I->arg_end()))->getType(),
@@ -163,10 +166,10 @@ static Value *LowerBSWAP(Value *V, Instruction *IP) {
     Value *Tmp1 = new ShiftInst(Instruction::Shr, V,
                               ConstantInt::get(Type::UByteTy,24),"bswap.1", IP);
     Tmp3 = BinaryOperator::createAnd(Tmp3, 
-                                     ConstantUInt::get(Type::UIntTy, 0xFF0000),
+                                     ConstantInt::get(Type::UIntTy, 0xFF0000),
                                      "bswap.and3", IP);
     Tmp2 = BinaryOperator::createAnd(Tmp2, 
-                                     ConstantUInt::get(Type::UIntTy, 0xFF00),
+                                     ConstantInt::get(Type::UIntTy, 0xFF00),
                                      "bswap.and2", IP);
     Tmp4 = BinaryOperator::createOr(Tmp4, Tmp3, "bswap.or1", IP);
     Tmp2 = BinaryOperator::createOr(Tmp2, Tmp1, "bswap.or2", IP);
@@ -191,23 +194,24 @@ static Value *LowerBSWAP(Value *V, Instruction *IP) {
     Value *Tmp1 = new ShiftInst(Instruction::Shr, V,
                               ConstantInt::get(Type::UByteTy,56),"bswap.1", IP);
     Tmp7 = BinaryOperator::createAnd(Tmp7,
-                          ConstantUInt::get(Type::ULongTy, 0xFF000000000000ULL),
-                          "bswap.and7", IP);
+                             ConstantInt::get(Type::ULongTy, 
+                               0xFF000000000000ULL),
+                             "bswap.and7", IP);
     Tmp6 = BinaryOperator::createAnd(Tmp6,
-                            ConstantUInt::get(Type::ULongTy, 0xFF0000000000ULL),
-                            "bswap.and6", IP);
+                             ConstantInt::get(Type::ULongTy, 0xFF0000000000ULL),
+                             "bswap.and6", IP);
     Tmp5 = BinaryOperator::createAnd(Tmp5,
-                              ConstantUInt::get(Type::ULongTy, 0xFF00000000ULL),
-                              "bswap.and5", IP);
+                             ConstantInt::get(Type::ULongTy, 0xFF00000000ULL),
+                             "bswap.and5", IP);
     Tmp4 = BinaryOperator::createAnd(Tmp4,
-                                ConstantUInt::get(Type::ULongTy, 0xFF000000ULL),
-                                "bswap.and4", IP);
+                             ConstantInt::get(Type::ULongTy, 0xFF000000ULL),
+                             "bswap.and4", IP);
     Tmp3 = BinaryOperator::createAnd(Tmp3,
-                                  ConstantUInt::get(Type::ULongTy, 0xFF0000ULL),
-                                  "bswap.and3", IP);
+                             ConstantInt::get(Type::ULongTy, 0xFF0000ULL),
+                             "bswap.and3", IP);
     Tmp2 = BinaryOperator::createAnd(Tmp2,
-                                    ConstantUInt::get(Type::ULongTy, 0xFF00ULL),
-                                    "bswap.and2", IP);
+                             ConstantInt::get(Type::ULongTy, 0xFF00ULL),
+                             "bswap.and2", IP);
     Tmp8 = BinaryOperator::createOr(Tmp8, Tmp7, "bswap.or1", IP);
     Tmp6 = BinaryOperator::createOr(Tmp6, Tmp5, "bswap.or2", IP);
     Tmp4 = BinaryOperator::createOr(Tmp4, Tmp3, "bswap.or3", IP);
@@ -244,8 +248,8 @@ static Value *LowerCTPOP(Value *V, Instruction *IP) {
   unsigned BitSize = V->getType()->getPrimitiveSizeInBits();
   for (unsigned i = 1, ct = 0; i != BitSize; i <<= 1, ++ct) {
     Value *MaskCst =
-      ConstantExpr::getCast(ConstantUInt::get(Type::ULongTy,
-                                              MaskValues[ct]), V->getType());
+      ConstantExpr::getCast(ConstantInt::get(Type::ULongTy, MaskValues[ct]),
+                                             V->getType());
     Value *LHS = BinaryOperator::createAnd(V, MaskCst, "cppop.and1", IP);
     Value *VShift = new ShiftInst(Instruction::Shr, V,
                       ConstantInt::get(Type::UByteTy, i), "ctpop.sh", IP);
@@ -392,20 +396,19 @@ void DefaultIntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
   case Intrinsic::readcyclecounter: {
     std::cerr << "WARNING: this target does not support the llvm.readcyclecoun"
               << "ter intrinsic.  It is being lowered to a constant 0\n";
-    CI->replaceAllUsesWith(ConstantUInt::get(Type::ULongTy, 0));
+    CI->replaceAllUsesWith(ConstantInt::get(Type::ULongTy, 0));
     break;
   }
 
   case Intrinsic::dbg_stoppoint:
   case Intrinsic::dbg_region_start:
   case Intrinsic::dbg_region_end:
-  case Intrinsic::dbg_declare:
   case Intrinsic::dbg_func_start:
-    if (CI->getType() != Type::VoidTy)
-      CI->replaceAllUsesWith(Constant::getNullValue(CI->getType()));
+  case Intrinsic::dbg_declare:
     break;    // Simply strip out debugging intrinsics
 
-  case Intrinsic::memcpy: {
+  case Intrinsic::memcpy_i32:
+  case Intrinsic::memcpy_i64: {
     // The memcpy intrinsic take an extra alignment argument that the memcpy
     // libc function does not.
     static Function *MemcpyFCache = 0;
@@ -413,7 +416,8 @@ void DefaultIntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
                     (*(CI->op_begin()+1))->getType(), MemcpyFCache);
     break;
   }
-  case Intrinsic::memmove: {
+  case Intrinsic::memmove_i32: 
+  case Intrinsic::memmove_i64: {
     // The memmove intrinsic take an extra alignment argument that the memmove
     // libc function does not.
     static Function *MemmoveFCache = 0;
@@ -421,7 +425,8 @@ void DefaultIntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
                     (*(CI->op_begin()+1))->getType(), MemmoveFCache);
     break;
   }
-  case Intrinsic::memset: {
+  case Intrinsic::memset_i32:
+  case Intrinsic::memset_i64: {
     // The memset intrinsic take an extra alignment argument that the memset
     // libc function does not.
     static Function *MemsetFCache = 0;