[llvm-commits] [llvm] r77366 - in /llvm/trunk: include/llvm/ lib/Analysis/ lib/AsmParser/ lib/Bitcode/Reader/ lib/CodeGen/SelectionDAG/ lib/Linker/ lib/Target/CellSPU/ lib/Target/X86/ lib/Transforms/Scalar/ lib/Transforms/Utils/ lib/VMCore/

Owen Anderson resistor at mac.com
Tue Jul 28 14:19:27 PDT 2009


Author: resistor
Date: Tue Jul 28 16:19:26 2009
New Revision: 77366

URL: http://llvm.org/viewvc/llvm-project?rev=77366&view=rev
Log:
Return ConstantVector to 2.5 API.

Modified:
    llvm/trunk/include/llvm/Constants.h
    llvm/trunk/include/llvm/LLVMContext.h
    llvm/trunk/lib/Analysis/ConstantFolding.cpp
    llvm/trunk/lib/AsmParser/LLParser.cpp
    llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
    llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
    llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
    llvm/trunk/lib/Linker/LinkModules.cpp
    llvm/trunk/lib/Target/CellSPU/SPUISelDAGToDAG.cpp
    llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
    llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
    llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp
    llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp
    llvm/trunk/lib/VMCore/AutoUpgrade.cpp
    llvm/trunk/lib/VMCore/ConstantFold.cpp
    llvm/trunk/lib/VMCore/Constants.cpp
    llvm/trunk/lib/VMCore/Core.cpp
    llvm/trunk/lib/VMCore/Instructions.cpp
    llvm/trunk/lib/VMCore/LLVMContext.cpp
    llvm/trunk/lib/VMCore/LLVMContextImpl.cpp
    llvm/trunk/lib/VMCore/LLVMContextImpl.h

Modified: llvm/trunk/include/llvm/Constants.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Constants.h?rev=77366&r1=77365&r2=77366&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Constants.h (original)
+++ llvm/trunk/include/llvm/Constants.h Tue Jul 28 16:19:26 2009
@@ -448,6 +448,11 @@
 protected:
   ConstantVector(const VectorType *T, const std::vector<Constant*> &Val);
 public:
+  // ConstantVector accessors
+  static Constant* get(const VectorType* T, const std::vector<Constant*>& V);
+  static Constant* get(const std::vector<Constant*>& V);
+  static Constant* get(Constant* const* Vals, unsigned NumVals);
+  
   /// Transparently provide more efficient getOperand methods.
   DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant);
 

Modified: llvm/trunk/include/llvm/LLVMContext.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/LLVMContext.h?rev=77366&r1=77365&r2=77366&view=diff

==============================================================================
--- llvm/trunk/include/llvm/LLVMContext.h (original)
+++ llvm/trunk/include/llvm/LLVMContext.h Tue Jul 28 16:19:26 2009
@@ -59,6 +59,7 @@
   friend class ConstantFP;
   friend class ConstantStruct;
   friend class ConstantArray;
+  friend class ConstantVector;
 public:
   LLVMContext();
   ~LLVMContext();
@@ -160,12 +161,6 @@
   ///
   Constant* getConstantExprSizeOf(const Type* Ty);
   
-  // ConstantVector accessors
-  Constant* getConstantVector(const VectorType* T,
-                              const std::vector<Constant*>& V);
-  Constant* getConstantVector(const std::vector<Constant*>& V);
-  Constant* getConstantVector(Constant* const* Vals, unsigned NumVals);
-  
   // MDNode accessors
   MDNode* getMDNode(Value* const* Vals, unsigned NumVals);
   
@@ -211,7 +206,6 @@
   void erase(MDString *M);
   void erase(MDNode *M);
   void erase(ConstantAggregateZero *Z);
-  void erase(ConstantVector *V);
 };
 
 /// FOR BACKWARDS COMPATIBILITY - Returns a global context.

Modified: llvm/trunk/lib/Analysis/ConstantFolding.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ConstantFolding.cpp?rev=77366&r1=77365&r2=77366&view=diff

==============================================================================
--- llvm/trunk/lib/Analysis/ConstantFolding.cpp (original)
+++ llvm/trunk/lib/Analysis/ConstantFolding.cpp Tue Jul 28 16:19:26 2009
@@ -264,7 +264,7 @@
         }
       }
       
-      return Context.getConstantVector(Result.data(), Result.size());
+      return ConstantVector::get(Result.data(), Result.size());
     }
   }
   

Modified: llvm/trunk/lib/AsmParser/LLParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=77366&r1=77365&r2=77366&view=diff

==============================================================================
--- llvm/trunk/lib/AsmParser/LLParser.cpp (original)
+++ llvm/trunk/lib/AsmParser/LLParser.cpp Tue Jul 28 16:19:26 2009
@@ -1777,7 +1777,7 @@
                      "vector element #" + utostr(i) +
                     " is not of type '" + Elts[0]->getType()->getDescription());
     
-    ID.ConstantVal = Context.getConstantVector(Elts.data(), Elts.size());
+    ID.ConstantVal = ConstantVector::get(Elts.data(), Elts.size());
     ID.Kind = ValID::t_Constant;
     return false;
   }

Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=77366&r1=77365&r2=77366&view=diff

==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Tue Jul 28 16:19:26 2009
@@ -294,7 +294,7 @@
         NewC = ConstantStruct::get(&NewOps[0], NewOps.size(),
                                          UserCS->getType()->isPacked());
       } else if (isa<ConstantVector>(UserC)) {
-        NewC = Context.getConstantVector(&NewOps[0], NewOps.size());
+        NewC = ConstantVector::get(&NewOps[0], NewOps.size());
       } else {
         assert(isa<ConstantExpr>(UserC) && "Must be a ConstantExpr.");
         NewC = cast<ConstantExpr>(UserC)->getWithOperands(&NewOps[0],
@@ -935,7 +935,7 @@
         const Type *EltTy = VTy->getElementType();
         for (unsigned i = 0; i != Size; ++i)
           Elts.push_back(ValueList.getConstantFwdRef(Record[i], EltTy));
-        V = Context.getConstantVector(Elts);
+        V = ConstantVector::get(Elts);
       } else {
         V = Context.getUndef(CurTy);
       }

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp?rev=77366&r1=77365&r2=77366&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Tue Jul 28 16:19:26 2009
@@ -1849,7 +1849,7 @@
         CV.push_back(Context->getUndef(OpNTy));
       }
     }
-    Constant *CP = Context->getConstantVector(CV);
+    Constant *CP = ConstantVector::get(CV);
     SDValue CPIdx = DAG.getConstantPool(CP, TLI.getPointerTy());
     unsigned Alignment = cast<ConstantPoolSDNode>(CPIdx)->getAlignment();
     return DAG.getLoad(VT, dl, DAG.getEntryNode(), CPIdx,

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp?rev=77366&r1=77365&r2=77366&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp Tue Jul 28 16:19:26 2009
@@ -2149,7 +2149,7 @@
       const Type *ElTy = DestTy->getElementType();
       unsigned VL = DestTy->getNumElements();
       std::vector<Constant*> NZ(VL, ConstantFP::getNegativeZero(ElTy));
-      Constant *CNZ = DAG.getContext()->getConstantVector(&NZ[0], NZ.size());
+      Constant *CNZ = ConstantVector::get(&NZ[0], NZ.size());
       if (CV == CNZ) {
         SDValue Op2 = getValue(I.getOperand(1));
         setValue(&I, DAG.getNode(ISD::FNEG, getCurDebugLoc(),

Modified: llvm/trunk/lib/Linker/LinkModules.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Linker/LinkModules.cpp?rev=77366&r1=77365&r2=77366&view=diff

==============================================================================
--- llvm/trunk/lib/Linker/LinkModules.cpp (original)
+++ llvm/trunk/lib/Linker/LinkModules.cpp Tue Jul 28 16:19:26 2009
@@ -384,7 +384,7 @@
       for (unsigned i = 0, e = CP->getNumOperands(); i != e; ++i)
         Operands[i] = cast<Constant>(RemapOperand(CP->getOperand(i), ValueMap,
                                      Context));
-      Result = Context.getConstantVector(Operands);
+      Result = ConstantVector::get(Operands);
     } else if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(CPV)) {
       std::vector<Constant*> Ops;
       for (unsigned i = 0, e = CE->getNumOperands(); i != e; ++i)

Modified: llvm/trunk/lib/Target/CellSPU/SPUISelDAGToDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/SPUISelDAGToDAG.cpp?rev=77366&r1=77365&r2=77366&view=diff

==============================================================================
--- llvm/trunk/lib/Target/CellSPU/SPUISelDAGToDAG.cpp (original)
+++ llvm/trunk/lib/Target/CellSPU/SPUISelDAGToDAG.cpp Tue Jul 28 16:19:26 2009
@@ -306,7 +306,7 @@
         CV.push_back(const_cast<ConstantInt *> (V->getConstantIntValue()));
       }
 
-      Constant *CP = CurDAG->getContext()->getConstantVector(CV);
+      Constant *CP = ConstantVector::get(CV);
       SDValue CPIdx = CurDAG->getConstantPool(CP, SPUtli.getPointerTy());
       unsigned Alignment = cast<ConstantPoolSDNode>(CPIdx)->getAlignment();
       SDValue CGPoolOffset =

Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=77366&r1=77365&r2=77366&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Tue Jul 28 16:19:26 2009
@@ -4909,7 +4909,7 @@
   CV0.push_back(ConstantInt::get(*Context, APInt(32, 0x43300000)));
   CV0.push_back(ConstantInt::get(*Context, APInt(32, 0)));
   CV0.push_back(ConstantInt::get(*Context, APInt(32, 0)));
-  Constant *C0 = Context->getConstantVector(CV0);
+  Constant *C0 = ConstantVector::get(CV0);
   SDValue CPIdx0 = DAG.getConstantPool(C0, getPointerTy(), 16);
 
   std::vector<Constant*> CV1;
@@ -4917,7 +4917,7 @@
     ConstantFP::get(*Context, APFloat(APInt(64, 0x4530000000000000ULL))));
   CV1.push_back(
     ConstantFP::get(*Context, APFloat(APInt(64, 0x4330000000000000ULL))));
-  Constant *C1 = Context->getConstantVector(CV1);
+  Constant *C1 = ConstantVector::get(CV1);
   SDValue CPIdx1 = DAG.getConstantPool(C1, getPointerTy(), 16);
 
   SDValue XR1 = DAG.getNode(ISD::SCALAR_TO_VECTOR, dl, MVT::v4i32,
@@ -5139,7 +5139,7 @@
     CV.push_back(C);
     CV.push_back(C);
   }
-  Constant *C = Context->getConstantVector(CV);
+  Constant *C = ConstantVector::get(CV);
   SDValue CPIdx = DAG.getConstantPool(C, getPointerTy(), 16);
   SDValue Mask = DAG.getLoad(VT, dl, DAG.getEntryNode(), CPIdx,
                                PseudoSourceValue::getConstantPool(), 0,
@@ -5169,7 +5169,7 @@
     CV.push_back(C);
     CV.push_back(C);
   }
-  Constant *C = Context->getConstantVector(CV);
+  Constant *C = ConstantVector::get(CV);
   SDValue CPIdx = DAG.getConstantPool(C, getPointerTy(), 16);
   SDValue Mask = DAG.getLoad(VT, dl, DAG.getEntryNode(), CPIdx,
                                PseudoSourceValue::getConstantPool(), 0,
@@ -5218,7 +5218,7 @@
     CV.push_back(ConstantFP::get(*Context, APFloat(APInt(32, 0))));
     CV.push_back(ConstantFP::get(*Context, APFloat(APInt(32, 0))));
   }
-  Constant *C = Context->getConstantVector(CV);
+  Constant *C = ConstantVector::get(CV);
   SDValue CPIdx = DAG.getConstantPool(C, getPointerTy(), 16);
   SDValue Mask1 = DAG.getLoad(SrcVT, dl, DAG.getEntryNode(), CPIdx,
                                 PseudoSourceValue::getConstantPool(), 0,
@@ -5247,7 +5247,7 @@
     CV.push_back(ConstantFP::get(*Context, APFloat(APInt(32, 0))));
     CV.push_back(ConstantFP::get(*Context, APFloat(APInt(32, 0))));
   }
-  C = Context->getConstantVector(CV);
+  C = ConstantVector::get(CV);
   CPIdx = DAG.getConstantPool(C, getPointerTy(), 16);
   SDValue Mask2 = DAG.getLoad(VT, dl, DAG.getEntryNode(), CPIdx,
                                 PseudoSourceValue::getConstantPool(), 0,

Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=77366&r1=77365&r2=77366&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Tue Jul 28 16:19:26 2009
@@ -1458,7 +1458,7 @@
       }
 
     // If we changed the constant, return it.
-    Constant *NewCP = Context->getConstantVector(Elts);
+    Constant *NewCP = ConstantVector::get(Elts);
     return NewCP != CP ? NewCP : 0;
   } else if (isa<ConstantAggregateZero>(V)) {
     // Simplify the CAZ to a ConstantVector where the non-demanded elements are
@@ -1478,7 +1478,7 @@
       Elts.push_back(Elt);
     }
     UndefElts = DemandedElts ^ EltMask;
-    return Context->getConstantVector(Elts);
+    return ConstantVector::get(Elts);
   }
   
   // Limit search depth.
@@ -1597,7 +1597,7 @@
           Elts.push_back(ConstantInt::get(Type::Int32Ty,
                                           Shuffle->getMaskValue(i)));
       }
-      I->setOperand(2, Context->getConstantVector(Elts));
+      I->setOperand(2, ConstantVector::get(Elts));
       MadeChange = true;
     }
     break;
@@ -2926,7 +2926,7 @@
     if (const VectorType *Ty = dyn_cast<VectorType>(I.getType())) {
       Constant *CI = ConstantInt::get(Ty->getElementType(), 1);
       std::vector<Constant*> Elts(Ty->getNumElements(), CI);
-      return ReplaceInstUsesWith(I, Context->getConstantVector(Elts));
+      return ReplaceInstUsesWith(I, ConstantVector::get(Elts));
     }
 
     Constant *CI = ConstantInt::get(I.getType(), 1);
@@ -3259,7 +3259,7 @@
         }
       }
 
-      Constant *NewRHSV = Context->getConstantVector(Elts);
+      Constant *NewRHSV = ConstantVector::get(Elts);
       if (NewRHSV != RHSV) {
         AddUsesToWorkList(I);
         I.setOperand(1, NewRHSV);
@@ -12689,7 +12689,7 @@
         Mask[InsertedIdx] = 
                            ConstantInt::get(Type::Int32Ty, ExtractedIdx);
         return new ShuffleVectorInst(EI->getOperand(0), VecOp,
-                                     Context->getConstantVector(Mask));
+                                     ConstantVector::get(Mask));
       }
       
       // If this insertelement isn't used by some other insertelement, turn it
@@ -12701,7 +12701,7 @@
         if (RHS == 0) RHS = Context->getUndef(LHS->getType());
         // We now have a shuffle of LHS, RHS, Mask.
         return new ShuffleVectorInst(LHS, RHS,
-                                     Context->getConstantVector(Mask));
+                                     ConstantVector::get(Mask));
       }
     }
   }
@@ -12766,7 +12766,7 @@
     }
     SVI.setOperand(0, SVI.getOperand(1));
     SVI.setOperand(1, Context->getUndef(RHS->getType()));
-    SVI.setOperand(2, Context->getConstantVector(Elts));
+    SVI.setOperand(2, ConstantVector::get(Elts));
     LHS = SVI.getOperand(0);
     RHS = SVI.getOperand(1);
     MadeChange = true;
@@ -12823,7 +12823,7 @@
         }
         return new ShuffleVectorInst(LHSSVI->getOperand(0),
                                      LHSSVI->getOperand(1),
-                                     Context->getConstantVector(Elts));
+                                     ConstantVector::get(Elts));
       }
     }
   }

Modified: llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp?rev=77366&r1=77365&r2=77366&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp Tue Jul 28 16:19:26 2009
@@ -850,7 +850,7 @@
           if (EltTy != ValTy) {
             unsigned NumElts = cast<VectorType>(ValTy)->getNumElements();
             SmallVector<Constant*, 16> Elts(NumElts, StoreVal);
-            StoreVal = Context.getConstantVector(&Elts[0], NumElts);
+            StoreVal = ConstantVector::get(&Elts[0], NumElts);
           }
         }
         new StoreInst(StoreVal, EltPtr, MI);

Modified: llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp?rev=77366&r1=77365&r2=77366&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp Tue Jul 28 16:19:26 2009
@@ -101,7 +101,7 @@
           Values.push_back(cast<Constant>(MV));
           for (++i; i != e; ++i)
             Values.push_back(cast<Constant>(MapValue(*i, VM, Context)));
-          return VM[V] = Context.getConstantVector(Values);
+          return VM[V] = ConstantVector::get(Values);
         }
       }
       return VM[V] = C;

Modified: llvm/trunk/lib/VMCore/AutoUpgrade.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AutoUpgrade.cpp?rev=77366&r1=77365&r2=77366&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/AutoUpgrade.cpp (original)
+++ llvm/trunk/lib/VMCore/AutoUpgrade.cpp Tue Jul 28 16:19:26 2009
@@ -281,7 +281,7 @@
           Idxs.push_back(ConstantInt::get(Type::Int32Ty, 2));
           Idxs.push_back(ConstantInt::get(Type::Int32Ty, 1));
         }
-        Value *Mask = Context.getConstantVector(Idxs);
+        Value *Mask = ConstantVector::get(Idxs);
         SI = new ShuffleVectorInst(Op0, Op1, Mask, "upgraded.", CI);
       } else if (isMovL) {
         Constant *Zero = ConstantInt::get(Type::Int32Ty, 0);
@@ -289,14 +289,14 @@
         Idxs.push_back(Zero);
         Idxs.push_back(Zero);
         Idxs.push_back(Zero);
-        Value *ZeroV = Context.getConstantVector(Idxs);
+        Value *ZeroV = ConstantVector::get(Idxs);
 
         Idxs.clear(); 
         Idxs.push_back(ConstantInt::get(Type::Int32Ty, 4));
         Idxs.push_back(ConstantInt::get(Type::Int32Ty, 5));
         Idxs.push_back(ConstantInt::get(Type::Int32Ty, 2));
         Idxs.push_back(ConstantInt::get(Type::Int32Ty, 3));
-        Value *Mask = Context.getConstantVector(Idxs);
+        Value *Mask = ConstantVector::get(Idxs);
         SI = new ShuffleVectorInst(ZeroV, Op0, Mask, "upgraded.", CI);
       } else if (isMovSD ||
                  isUnpckhPD || isUnpcklPD || isPunpckhQPD || isPunpcklQPD) {
@@ -311,7 +311,7 @@
           Idxs.push_back(ConstantInt::get(Type::Int32Ty, 0));
           Idxs.push_back(ConstantInt::get(Type::Int32Ty, 2));
         }
-        Value *Mask = Context.getConstantVector(Idxs);
+        Value *Mask = ConstantVector::get(Idxs);
         SI = new ShuffleVectorInst(Op0, Op1, Mask, "upgraded.", CI);
       } else if (isShufPD) {
         Value *Op1 = CI->getOperand(2);
@@ -319,7 +319,7 @@
         Idxs.push_back(ConstantInt::get(Type::Int32Ty, MaskVal & 1));
         Idxs.push_back(ConstantInt::get(Type::Int32Ty,
                                                ((MaskVal >> 1) & 1)+2));
-        Value *Mask = Context.getConstantVector(Idxs);
+        Value *Mask = ConstantVector::get(Idxs);
         SI = new ShuffleVectorInst(Op0, Op1, Mask, "upgraded.", CI);
       }
 

Modified: llvm/trunk/lib/VMCore/ConstantFold.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/ConstantFold.cpp?rev=77366&r1=77365&r2=77366&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/ConstantFold.cpp (original)
+++ llvm/trunk/lib/VMCore/ConstantFold.cpp Tue Jul 28 16:19:26 2009
@@ -63,7 +63,7 @@
   for (unsigned i = 0; i != NumElts; ++i)
     Result.push_back(Context.getConstantExprBitCast(CV->getOperand(i),
                                                     DstEltTy));
-  return Context.getConstantVector(Result);
+  return ConstantVector::get(Result);
 }
 
 /// This function determines which opcode to use to fold two constant cast 
@@ -145,7 +145,7 @@
     // can only be handled by Analysis/ConstantFolding.cpp).
     if (isa<ConstantInt>(V) || isa<ConstantFP>(V))
       return Context.getConstantExprBitCast(
-                                     Context.getConstantVector(&V, 1), DestPTy);
+                                     ConstantVector::get(&V, 1), DestPTy);
   }
   
   // Finally, implement bitcast folding now.   The code below doesn't handle
@@ -228,7 +228,7 @@
       for (unsigned i = 0, e = CV->getType()->getNumElements(); i != e; ++i)
         res.push_back(Context.getConstantExprCast(opc,
                                             CV->getOperand(i), DstEltTy));
-      return Context.getConstantVector(DestVecTy, res);
+      return ConstantVector::get(DestVecTy, res);
     }
 
   // We actually have to do a cast now. Perform the cast according to the
@@ -374,7 +374,7 @@
         (idxVal == i) ? Elt : Context.getUndef(Elt->getType());
       Ops.push_back(const_cast<Constant*>(Op));
     }
-    return Context.getConstantVector(Ops);
+    return ConstantVector::get(Ops);
   }
   if (isa<ConstantAggregateZero>(Val)) {
     // Insertion of scalar constant into vector aggregate zero
@@ -392,7 +392,7 @@
         (idxVal == i) ? Elt : Context.getNullValue(Elt->getType());
       Ops.push_back(const_cast<Constant*>(Op));
     }
-    return Context.getConstantVector(Ops);
+    return ConstantVector::get(Ops);
   }
   if (const ConstantVector *CVal = dyn_cast<ConstantVector>(Val)) {
     // Insertion of scalar constant into vector constant
@@ -403,7 +403,7 @@
         (idxVal == i) ? Elt : cast<Constant>(CVal->getOperand(i));
       Ops.push_back(const_cast<Constant*>(Op));
     }
-    return Context.getConstantVector(Ops);
+    return ConstantVector::get(Ops);
   }
 
   return 0;
@@ -459,7 +459,7 @@
     Result.push_back(InElt);
   }
 
-  return Context.getConstantVector(&Result[0], Result.size());
+  return ConstantVector::get(&Result[0], Result.size());
 }
 
 Constant *llvm::ConstantFoldExtractValueInstruction(LLVMContext &Context,
@@ -829,7 +829,7 @@
           Res.push_back(Context.getConstantExprAdd(const_cast<Constant*>(C1),
                                                    const_cast<Constant*>(C2)));
         }
-        return Context.getConstantVector(Res);
+        return ConstantVector::get(Res);
       case Instruction::FAdd:
         for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
           C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy);
@@ -837,7 +837,7 @@
           Res.push_back(Context.getConstantExprFAdd(const_cast<Constant*>(C1),
                                                     const_cast<Constant*>(C2)));
         }
-        return Context.getConstantVector(Res);
+        return ConstantVector::get(Res);
       case Instruction::Sub:
         for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
           C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy);
@@ -845,7 +845,7 @@
           Res.push_back(Context.getConstantExprSub(const_cast<Constant*>(C1),
                                                    const_cast<Constant*>(C2)));
         }
-        return Context.getConstantVector(Res);
+        return ConstantVector::get(Res);
       case Instruction::FSub:
         for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
           C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy);
@@ -853,7 +853,7 @@
           Res.push_back(Context.getConstantExprFSub(const_cast<Constant*>(C1),
                                                     const_cast<Constant*>(C2)));
         }
-        return Context.getConstantVector(Res);
+        return ConstantVector::get(Res);
       case Instruction::Mul:
         for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
           C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy);
@@ -861,7 +861,7 @@
           Res.push_back(Context.getConstantExprMul(const_cast<Constant*>(C1),
                                                    const_cast<Constant*>(C2)));
         }
-        return Context.getConstantVector(Res);
+        return ConstantVector::get(Res);
       case Instruction::FMul:
         for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
           C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy);
@@ -869,7 +869,7 @@
           Res.push_back(Context.getConstantExprFMul(const_cast<Constant*>(C1),
                                                     const_cast<Constant*>(C2)));
         }
-        return Context.getConstantVector(Res);
+        return ConstantVector::get(Res);
       case Instruction::UDiv:
         for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
           C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy);
@@ -877,7 +877,7 @@
           Res.push_back(Context.getConstantExprUDiv(const_cast<Constant*>(C1),
                                                     const_cast<Constant*>(C2)));
         }
-        return Context.getConstantVector(Res);
+        return ConstantVector::get(Res);
       case Instruction::SDiv:
         for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
           C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy);
@@ -885,7 +885,7 @@
           Res.push_back(Context.getConstantExprSDiv(const_cast<Constant*>(C1),
                                                     const_cast<Constant*>(C2)));
         }
-        return Context.getConstantVector(Res);
+        return ConstantVector::get(Res);
       case Instruction::FDiv:
         for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
           C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy);
@@ -893,7 +893,7 @@
           Res.push_back(Context.getConstantExprFDiv(const_cast<Constant*>(C1),
                                                     const_cast<Constant*>(C2)));
         }
-        return Context.getConstantVector(Res);
+        return ConstantVector::get(Res);
       case Instruction::URem:
         for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
           C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy);
@@ -901,7 +901,7 @@
           Res.push_back(Context.getConstantExprURem(const_cast<Constant*>(C1),
                                                     const_cast<Constant*>(C2)));
         }
-        return Context.getConstantVector(Res);
+        return ConstantVector::get(Res);
       case Instruction::SRem:
         for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
           C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy);
@@ -909,7 +909,7 @@
           Res.push_back(Context.getConstantExprSRem(const_cast<Constant*>(C1),
                                                     const_cast<Constant*>(C2)));
         }
-        return Context.getConstantVector(Res);
+        return ConstantVector::get(Res);
       case Instruction::FRem:
         for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
           C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy);
@@ -917,7 +917,7 @@
           Res.push_back(Context.getConstantExprFRem(const_cast<Constant*>(C1),
                                                     const_cast<Constant*>(C2)));
         }
-        return Context.getConstantVector(Res);
+        return ConstantVector::get(Res);
       case Instruction::And: 
         for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
           C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy);
@@ -925,7 +925,7 @@
           Res.push_back(Context.getConstantExprAnd(const_cast<Constant*>(C1),
                                                    const_cast<Constant*>(C2)));
         }
-        return Context.getConstantVector(Res);
+        return ConstantVector::get(Res);
       case Instruction::Or:
         for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
           C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy);
@@ -933,7 +933,7 @@
           Res.push_back(Context.getConstantExprOr(const_cast<Constant*>(C1),
                                                   const_cast<Constant*>(C2)));
         }
-        return Context.getConstantVector(Res);
+        return ConstantVector::get(Res);
       case Instruction::Xor:
         for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
           C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy);
@@ -941,7 +941,7 @@
           Res.push_back(Context.getConstantExprXor(const_cast<Constant*>(C1),
                                                    const_cast<Constant*>(C2)));
         }
-        return Context.getConstantVector(Res);
+        return ConstantVector::get(Res);
       case Instruction::LShr:
         for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
           C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy);
@@ -949,7 +949,7 @@
           Res.push_back(Context.getConstantExprLShr(const_cast<Constant*>(C1),
                                                     const_cast<Constant*>(C2)));
         }
-        return Context.getConstantVector(Res);
+        return ConstantVector::get(Res);
       case Instruction::AShr:
         for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
           C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy);
@@ -957,7 +957,7 @@
           Res.push_back(Context.getConstantExprAShr(const_cast<Constant*>(C1),
                                                     const_cast<Constant*>(C2)));
         }
-        return Context.getConstantVector(Res);
+        return ConstantVector::get(Res);
       case Instruction::Shl:
         for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
           C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy);
@@ -965,7 +965,7 @@
           Res.push_back(Context.getConstantExprShl(const_cast<Constant*>(C1),
                                                    const_cast<Constant*>(C2)));
         }
-        return Context.getConstantVector(Res);
+        return ConstantVector::get(Res);
       }
     }
   }
@@ -1496,7 +1496,7 @@
       ResElts.push_back(
                     Context.getConstantExprCompare(pred, C1Elts[i], C2Elts[i]));
     }
-    return Context.getConstantVector(&ResElts[0], ResElts.size());
+    return ConstantVector::get(&ResElts[0], ResElts.size());
   }
 
   if (C1->getType()->isFloatingPoint()) {

Modified: llvm/trunk/lib/VMCore/Constants.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Constants.cpp?rev=77366&r1=77365&r2=77366&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Constants.cpp (original)
+++ llvm/trunk/lib/VMCore/Constants.cpp Tue Jul 28 16:19:26 2009
@@ -206,7 +206,7 @@
 
   // For vectors, broadcast the value.
   if (const VectorType *VTy = dyn_cast<VectorType>(Ty))
-    return Ty->getContext().getConstantVector(
+    return ConstantVector::get(
       std::vector<Constant *>(VTy->getNumElements(), C));
 
   return C;
@@ -232,7 +232,7 @@
 
   // For vectors, broadcast the value.
   if (const VectorType *VTy = dyn_cast<VectorType>(Ty))
-    return Ty->getContext().getConstantVector(
+    return ConstantVector::get(
       std::vector<Constant *>(VTy->getNumElements(), C));
 
   return C;
@@ -270,7 +270,7 @@
 
   // For vectors, broadcast the value.
   if (const VectorType *VTy = dyn_cast<VectorType>(Ty))
-    return Context.getConstantVector(
+    return ConstantVector::get(
       std::vector<Constant *>(VTy->getNumElements(), C));
 
   return C;
@@ -290,7 +290,7 @@
     if (PTy->getElementType()->isFloatingPoint()) {
       std::vector<Constant*> zeros(PTy->getNumElements(),
                            getNegativeZero(PTy->getElementType()));
-      return Context.getConstantVector(PTy, zeros);
+      return ConstantVector::get(PTy, zeros);
     }
 
   if (Ty->isFloatingPoint()) 
@@ -490,6 +490,46 @@
   }
 }
 
+// ConstantVector accessors.
+Constant* ConstantVector::get(const VectorType* T,
+                              const std::vector<Constant*>& V) {
+   assert(!V.empty() && "Vectors can't be empty");
+   LLVMContext &Context = T->getContext();
+   LLVMContextImpl *pImpl = Context.pImpl;
+   
+  // If this is an all-undef or alll-zero vector, return a
+  // ConstantAggregateZero or UndefValue.
+  Constant *C = V[0];
+  bool isZero = C->isNullValue();
+  bool isUndef = isa<UndefValue>(C);
+
+  if (isZero || isUndef) {
+    for (unsigned i = 1, e = V.size(); i != e; ++i)
+      if (V[i] != C) {
+        isZero = isUndef = false;
+        break;
+      }
+  }
+  
+  if (isZero)
+    return Context.getConstantAggregateZero(T);
+  if (isUndef)
+    return Context.getUndef(T);
+    
+  // Implicitly locked.
+  return pImpl->VectorConstants.getOrCreate(T, V);
+}
+
+Constant* ConstantVector::get(const std::vector<Constant*>& V) {
+  assert(!V.empty() && "Cannot infer type if V is empty");
+  return get(VectorType::get(V.front()->getType(),V.size()), V);
+}
+
+Constant* ConstantVector::get(Constant* const* Vals, unsigned NumVals) {
+  // FIXME: make this the primary ctor method.
+  return get(std::vector<Constant*>(Vals, Vals+NumVals));
+}
+
 
 namespace llvm {
 // We declare several classes private to this file, so use an anonymous
@@ -1064,7 +1104,7 @@
 //
 void ConstantVector::destroyConstant() {
   // Implicitly locked.
-  getType()->getContext().erase(this);
+  getType()->getContext().pImpl->VectorConstants.remove(this);
   destroyConstantImpl();
 }
 
@@ -2127,6 +2167,14 @@
   destroyConstant();
 }
 
+static std::vector<Constant*> getValType(ConstantVector *CP) {
+  std::vector<Constant*> Elements;
+  Elements.reserve(CP->getNumOperands());
+  for (unsigned i = 0, e = CP->getNumOperands(); i != e; ++i)
+    Elements.push_back(CP->getOperand(i));
+  return Elements;
+}
+
 void ConstantVector::replaceUsesOfWithOnConstant(Value *From, Value *To,
                                                  Use *U) {
   assert(isa<Constant>(To) && "Cannot make Constant refer to non-constant!");
@@ -2139,8 +2187,7 @@
     Values.push_back(Val);
   }
   
-  Constant *Replacement =
-    getType()->getContext().getConstantVector(getType(), Values);
+  Constant *Replacement = get(getType(), Values);
   assert(Replacement != this && "I didn't contain From!");
   
   // Everyone using this now uses the replacement.

Modified: llvm/trunk/lib/VMCore/Core.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Core.cpp?rev=77366&r1=77365&r2=77366&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Core.cpp (original)
+++ llvm/trunk/lib/VMCore/Core.cpp Tue Jul 28 16:19:26 2009
@@ -421,7 +421,7 @@
 }
 
 LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size) {
-  return wrap(getGlobalContext().getConstantVector(
+  return wrap(ConstantVector::get(
                             unwrap<Constant>(ScalarConstantVals, Size), Size));
 }
 

Modified: llvm/trunk/lib/VMCore/Instructions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instructions.cpp?rev=77366&r1=77365&r2=77366&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Instructions.cpp (original)
+++ llvm/trunk/lib/VMCore/Instructions.cpp Tue Jul 28 16:19:26 2009
@@ -1616,7 +1616,7 @@
   Constant *C;
   if (const VectorType *PTy = dyn_cast<VectorType>(Op->getType())) {
     C = Context.getAllOnesValue(PTy->getElementType());
-    C = Context.getConstantVector(
+    C = ConstantVector::get(
                               std::vector<Constant*>(PTy->getNumElements(), C));
   } else {
     C = Context.getAllOnesValue(Op->getType());
@@ -1633,7 +1633,7 @@
   if (const VectorType *PTy = dyn_cast<VectorType>(Op->getType())) {
     // Create a vector of all ones values.
     Constant *Elt = Context.getAllOnesValue(PTy->getElementType());
-    AllOnes = Context.getConstantVector(
+    AllOnes = ConstantVector::get(
                             std::vector<Constant*>(PTy->getNumElements(), Elt));
   } else {
     AllOnes = Context.getAllOnesValue(Op->getType());

Modified: llvm/trunk/lib/VMCore/LLVMContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/LLVMContext.cpp?rev=77366&r1=77365&r2=77366&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/LLVMContext.cpp (original)
+++ llvm/trunk/lib/VMCore/LLVMContext.cpp Tue Jul 28 16:19:26 2009
@@ -72,7 +72,7 @@
   const VectorType* VTy = cast<VectorType>(Ty);
   Elts.resize(VTy->getNumElements(), getAllOnesValue(VTy->getElementType()));
   assert(Elts[0] && "Not a vector integer type!");
-  return cast<ConstantVector>(getConstantVector(Elts));
+  return cast<ConstantVector>(ConstantVector::get(Elts));
 }
 
 // UndefValue accessors.
@@ -367,23 +367,6 @@
   return getConstantExprCast(Instruction::PtrToInt, GEP, Type::Int64Ty);
 }
 
-// ConstantVector accessors.
-Constant* LLVMContext::getConstantVector(const VectorType* T,
-                            const std::vector<Constant*>& V) {
-  return pImpl->getConstantVector(T, V);
-}
-
-Constant* LLVMContext::getConstantVector(const std::vector<Constant*>& V) {
-  assert(!V.empty() && "Cannot infer type if V is empty");
-  return getConstantVector(getVectorType(V.front()->getType(),V.size()), V);
-}
-
-Constant* LLVMContext::getConstantVector(Constant* const* Vals,
-                                         unsigned NumVals) {
-  // FIXME: make this the primary ctor method.
-  return getConstantVector(std::vector<Constant*>(Vals, Vals+NumVals));
-}
-
 // MDNode accessors
 MDNode* LLVMContext::getMDNode(Value* const* Vals, unsigned NumVals) {
   return pImpl->getMDNode(Vals, NumVals);
@@ -488,7 +471,3 @@
 void LLVMContext::erase(ConstantAggregateZero *Z) {
   pImpl->erase(Z);
 }
-
-void LLVMContext::erase(ConstantVector *V) {
-  pImpl->erase(V);
-}

Modified: llvm/trunk/lib/VMCore/LLVMContextImpl.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/LLVMContextImpl.cpp?rev=77366&r1=77365&r2=77366&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/LLVMContextImpl.cpp (original)
+++ llvm/trunk/lib/VMCore/LLVMContextImpl.cpp Tue Jul 28 16:19:26 2009
@@ -21,15 +21,6 @@
 
 static char getValType(ConstantAggregateZero *CPZ) { return 0; }
 
-static std::vector<Constant*> getValType(ConstantVector *CP) {
-  std::vector<Constant*> Elements;
-  Elements.reserve(CP->getNumOperands());
-  for (unsigned i = 0, e = CP->getNumOperands(); i != e; ++i)
-    Elements.push_back(CP->getOperand(i));
-  return Elements;
-}
-
-
 LLVMContextImpl::LLVMContextImpl(LLVMContext &C) :
     Context(C), TheTrueVal(0), TheFalseVal(0) { }
 
@@ -77,32 +68,6 @@
   return AggZeroConstants.getOrCreate(Ty, 0);
 }
 
-Constant *LLVMContextImpl::getConstantVector(const VectorType *Ty,
-                              const std::vector<Constant*> &V) {
-  assert(!V.empty() && "Vectors can't be empty");
-  // If this is an all-undef or alll-zero vector, return a
-  // ConstantAggregateZero or UndefValue.
-  Constant *C = V[0];
-  bool isZero = C->isNullValue();
-  bool isUndef = isa<UndefValue>(C);
-
-  if (isZero || isUndef) {
-    for (unsigned i = 1, e = V.size(); i != e; ++i)
-      if (V[i] != C) {
-        isZero = isUndef = false;
-        break;
-      }
-  }
-  
-  if (isZero)
-    return Context.getConstantAggregateZero(Ty);
-  if (isUndef)
-    return Context.getUndef(Ty);
-    
-  // Implicitly locked.
-  return VectorConstants.getOrCreate(Ty, V);
-}
-
 // *** erase methods ***
 
 void LLVMContextImpl::erase(MDString *M) {
@@ -118,7 +83,3 @@
 void LLVMContextImpl::erase(ConstantAggregateZero *Z) {
   AggZeroConstants.remove(Z);
 }
-
-void LLVMContextImpl::erase(ConstantVector *V) {
-  VectorConstants.remove(V);
-}

Modified: llvm/trunk/lib/VMCore/LLVMContextImpl.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/LLVMContextImpl.h?rev=77366&r1=77365&r2=77366&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/LLVMContextImpl.h (original)
+++ llvm/trunk/lib/VMCore/LLVMContextImpl.h Tue Jul 28 16:19:26 2009
@@ -117,7 +117,7 @@
     std::vector<Constant*> C;
     for (unsigned i = 0, e = OldC->getNumOperands(); i != e; ++i)
       C.push_back(cast<Constant>(OldC->getOperand(i)));
-    Constant *New = OldC->getContext().getConstantVector(NewTy, C);
+    Constant *New = ConstantVector::get(NewTy, C);
     assert(New != OldC && "Didn't replace constant??");
     OldC->uncheckedReplaceAllUsesWith(New);
     OldC->destroyConstant();    // This constant is now dead, destroy it.
@@ -460,6 +460,7 @@
   friend class ConstantFP;
   friend class ConstantStruct;
   friend class ConstantArray;
+  friend class ConstantVector;
 public:
   LLVMContextImpl(LLVMContext &C);
   
@@ -469,9 +470,6 @@
   
   ConstantAggregateZero *getConstantAggregateZero(const Type *Ty);
   
-  Constant *getConstantVector(const VectorType *Ty,
-                              const std::vector<Constant*> &V);
-  
   ConstantInt *getTrue() {
     if (TheTrueVal)
       return TheTrueVal;





More information about the llvm-commits mailing list