[llvm-branch-commits] [llvm-gcc-branch] r84877 - /llvm-gcc-4.2/branches/Apple/Leela/gcc/config/arm/llvm-arm.cpp

Bill Wendling isanbard at gmail.com
Thu Oct 22 10:39:01 PDT 2009


Author: void
Date: Thu Oct 22 12:39:01 2009
New Revision: 84877

URL: http://llvm.org/viewvc/llvm-project?rev=84877&view=rev
Log:
$ svn merge -c 84677 https://llvm.org/svn/llvm-project/llvm-gcc-4.2/trunk
--- Merging r84677 into '.':
U    gcc/config/arm/llvm-arm.cpp
$ svn merge -c 84678 https://llvm.org/svn/llvm-project/llvm-gcc-4.2/trunk
--- Merging r84678 into '.':
G    gcc/config/arm/llvm-arm.cpp


Modified:
    llvm-gcc-4.2/branches/Apple/Leela/gcc/config/arm/llvm-arm.cpp

Modified: llvm-gcc-4.2/branches/Apple/Leela/gcc/config/arm/llvm-arm.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Leela/gcc/config/arm/llvm-arm.cpp?rev=84877&r1=84876&r2=84877&view=diff

==============================================================================
--- llvm-gcc-4.2/branches/Apple/Leela/gcc/config/arm/llvm-arm.cpp (original)
+++ llvm-gcc-4.2/branches/Apple/Leela/gcc/config/arm/llvm-arm.cpp Thu Oct 22 12:39:01 2009
@@ -47,6 +47,10 @@
   (int fcode, neon_itype *itype, enum neon_builtins *neon_code);
 }
 
+static ConstantInt *getInt32Const(int c) {
+  return ConstantInt::get(Type::getInt32Ty(Context), c);
+}
+
 /// UnexpectedError - Report errors about unexpected uses of builtins.  The
 /// msg argument should begin with a "%H" so that the location of the
 /// expression is printed in the error message.
@@ -131,8 +135,6 @@
 /// element of a vector.
 static Value *BuildDup(const Type *ResultType, Value *Val,
                        LLVMBuilder &Builder) {
-  LLVMContext &Context = getGlobalContext();
-
   // GCC may promote the scalar argument; cast it back.
   const VectorType *VTy = dyn_cast<const VectorType>(ResultType);
   assert(VTy && "expected a vector type");
@@ -145,16 +147,14 @@
 
   // Insert the value into lane 0 of an undef vector.
   Value *Undef = UndefValue::get(ResultType);
-  Value *Result =
-    Builder.CreateInsertElement(Undef, Val,
-                                ConstantInt::get(Type::getInt32Ty(Context), 0));
+  Value *Result = Builder.CreateInsertElement(Undef, Val, getInt32Const(0));
 
   // Use a shuffle to move the value into the other lanes.
   unsigned NUnits = VTy->getNumElements();
   if (NUnits > 1) {
     std::vector<Constant*> Idxs;
     for (unsigned i = 0; i != NUnits; ++i)
-      Idxs.push_back(ConstantInt::get(Type::getInt32Ty(Context), 0));
+      Idxs.push_back(getInt32Const(0));
     Result = Builder.CreateShuffleVector(Result, Undef,
                                          ConstantVector::get(Idxs));
   }
@@ -167,9 +167,8 @@
                            LLVMBuilder &Builder) {
   // Translate this to a vector shuffle.
   std::vector<Constant*> Idxs;
-  LLVMContext &Context = getGlobalContext();
   for (unsigned i = 0; i != NUnits; ++i)
-    Idxs.push_back(ConstantInt::get(Type::getInt32Ty(Context), LaneVal));
+    Idxs.push_back(getInt32Const(LaneVal));
   return Builder.CreateShuffleVector(Vec, UndefValue::get(Vec->getType()),
                                      ConstantVector::get(Idxs));
 }
@@ -217,7 +216,6 @@
     return false;
 
   // Right shifts are represented in NEON intrinsics by a negative shift count.
-  LLVMContext &Context = getGlobalContext();
   Cnt = ConstantInt::get(IntegerType::get(Context, ElemBits),
                          NegateRightShift ? -CntVal : CntVal);
   Op = BuildConstantSplatVector(GET_MODE_NUNITS(Mode), Cnt);
@@ -259,8 +257,6 @@
   if (FnCode < ARM_BUILTIN_NEON_BASE)
     return false;
 
-  LLVMContext &Context = getGlobalContext();
-
   neon_builtins neon_code;
   enum insn_code icode = locate_neon_builtin_icode (FnCode, 0, &neon_code);
 
@@ -1686,7 +1682,7 @@
     unsigned NUnits = GET_MODE_NUNITS(insn_data[icode].operand[0].mode);
     std::vector<Constant*> Idxs;
     for (unsigned i = 0; i != NUnits; ++i)
-      Idxs.push_back(ConstantInt::get(Type::getInt32Ty(Context), i));
+      Idxs.push_back(getInt32Const(i));
     Result = Builder.CreateShuffleVector(Ops[0], Ops[1],
                                          ConstantVector::get(Idxs));
     break;
@@ -1694,14 +1690,11 @@
 
   case NEON_BUILTIN_vget_high:
   case NEON_BUILTIN_vget_low: {
-    unsigned NUnits = GET_MODE_NUNITS(insn_data[icode].operand[0].mode);
-    std::vector<Constant*> Idxs;
-    unsigned Idx = (neon_code == NEON_BUILTIN_vget_low ? 0 : NUnits);
-    for (unsigned i = 0; i != NUnits; ++i)
-      Idxs.push_back(ConstantInt::get(Type::getInt32Ty(Context), Idx++));
-    Result = Builder.CreateShuffleVector(Ops[0],
-                                         UndefValue::get(Ops[0]->getType()),
-                                         ConstantVector::get(Idxs));
+    const Type *v2f64Ty = VectorType::get(Type::getDoubleTy(Context), 2);
+    unsigned Idx = (neon_code == NEON_BUILTIN_vget_low ? 0 : 1);
+    Result = Builder.CreateBitCast(Ops[0], v2f64Ty);
+    Result = Builder.CreateExtractElement(Result, getInt32Const(Idx));
+    Result = Builder.CreateBitCast(Result, ResultType);
     break;
   }
 
@@ -1762,7 +1755,7 @@
     // Translate to a vector shuffle.
     std::vector<Constant*> Idxs;
     for (unsigned i = 0; i != NUnits; ++i)
-      Idxs.push_back(ConstantInt::get(Type::getInt32Ty(Context), i + ImmVal));
+      Idxs.push_back(getInt32Const(i + ImmVal));
     Result = Builder.CreateShuffleVector(Ops[0], Ops[1],
                                          ConstantVector::get(Idxs));
     break;
@@ -1788,7 +1781,7 @@
     unsigned NUnits = VTy->getNumElements();
     for (unsigned c = ChunkElts; c <= NUnits; c += ChunkElts) {
       for (unsigned i = 0; i != ChunkElts; ++i) {
-        Idxs.push_back(ConstantInt::get(Type::getInt32Ty(Context), c - i - 1));
+        Idxs.push_back(getInt32Const(c - i - 1));
       }
     }
     Result = Builder.CreateShuffleVector(Ops[0], UndefValue::get(ResultType),
@@ -1934,12 +1927,11 @@
   case NEON_BUILTIN_vtrn: {
     // Translate this to a pair of vector shuffles.
     unsigned NUnits = GET_MODE_NUNITS(insn_data[icode].operand[1].mode);
-    const Type *Int32Ty = Type::getInt32Ty(Context);
     for (unsigned Elt = 0; Elt != 2; ++Elt) {
       std::vector<Constant*> Idxs;
       for (unsigned i = 0; i < NUnits; i += 2) {
-        Idxs.push_back(ConstantInt::get(Int32Ty, i + Elt));
-        Idxs.push_back(ConstantInt::get(Int32Ty, i + NUnits + Elt));
+        Idxs.push_back(getInt32Const(i + Elt));
+        Idxs.push_back(getInt32Const(i + NUnits + Elt));
       }
       Result = Builder.CreateShuffleVector(Ops[0], Ops[1],
                                            ConstantVector::get(Idxs));
@@ -1953,13 +1945,12 @@
   case NEON_BUILTIN_vzip: {
     // Translate this to a pair of vector shuffles.
     unsigned NUnits = GET_MODE_NUNITS(insn_data[icode].operand[1].mode);
-    const Type *Int32Ty = Type::getInt32Ty(Context);
     unsigned Idx = 0;
     for (unsigned Elt = 0; Elt != 2; ++Elt) {
       std::vector<Constant*> Idxs;
       for (unsigned i = 0; i != NUnits; i += 2) {
-        Idxs.push_back(ConstantInt::get(Int32Ty, Idx));
-        Idxs.push_back(ConstantInt::get(Int32Ty, Idx + NUnits));
+        Idxs.push_back(getInt32Const(Idx));
+        Idxs.push_back(getInt32Const(Idx + NUnits));
         Idx += 1;
       }
       Result = Builder.CreateShuffleVector(Ops[0], Ops[1],
@@ -1974,11 +1965,10 @@
   case NEON_BUILTIN_vuzp: {
     // Translate this to a pair of vector shuffles.
     unsigned NUnits = GET_MODE_NUNITS(insn_data[icode].operand[1].mode);
-    const Type *Int32Ty = Type::getInt32Ty(Context);
     for (unsigned Elt = 0; Elt != 2; ++Elt) {
       std::vector<Constant*> Idxs;
       for (unsigned i = 0; i != NUnits; ++i)
-        Idxs.push_back(ConstantInt::get(Int32Ty, 2 * i + Elt));
+        Idxs.push_back(getInt32Const(2 * i + Elt));
       Result = Builder.CreateShuffleVector(Ops[0], Ops[1],
                                            ConstantVector::get(Idxs));
       Value *Addr = Builder.CreateConstInBoundsGEP2_32(DestLoc->Ptr, 0, Elt);
@@ -2109,7 +2099,7 @@
     for (unsigned n = 0; n != NumVecs; ++n) {
       Args.push_back(UndefValue::get(VTy));
     }
-    Args.push_back(ConstantInt::get(Type::getInt32Ty(Context), 0));
+    Args.push_back(getInt32Const(0));
     Result = Builder.CreateCall(intFn, Args.begin(), Args.end());
 
     // Now splat the values in lane 0 to the rest of the elements.





More information about the llvm-branch-commits mailing list