diff options
author | Owen Anderson <resistor@mac.com> | 2009-07-15 21:51:10 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2009-07-15 21:51:10 +0000 |
commit | f945a9ed07773d9f2f9d631d7540b18f8ebccb04 (patch) | |
tree | be301ffe0d5fba090f05d008ffcb2bef131b2ebc /llvm/lib/VMCore/LLVMContext.cpp | |
parent | d098c5a0fc9273fda89a50c4fc4bc4210ffb947d (diff) | |
download | bcm5719-llvm-f945a9ed07773d9f2f9d631d7540b18f8ebccb04.tar.gz bcm5719-llvm-f945a9ed07773d9f2f9d631d7540b18f8ebccb04.zip |
Move a few more convenience factory functions from Constant to LLVMContext.
llvm-svn: 75840
Diffstat (limited to 'llvm/lib/VMCore/LLVMContext.cpp')
-rw-r--r-- | llvm/lib/VMCore/LLVMContext.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/llvm/lib/VMCore/LLVMContext.cpp b/llvm/lib/VMCore/LLVMContext.cpp index e359ae33df8..73c93a2d6e5 100644 --- a/llvm/lib/VMCore/LLVMContext.cpp +++ b/llvm/lib/VMCore/LLVMContext.cpp @@ -128,7 +128,7 @@ Constant* LLVMContext::getConstantInt(const Type* Ty, const APInt& V) { // For vectors, broadcast the value. if (const VectorType *VTy = dyn_cast<VectorType>(Ty)) return - ConstantVector::get(std::vector<Constant *>(VTy->getNumElements(), C)); + getConstantVector(std::vector<Constant *>(VTy->getNumElements(), C)); return C; } @@ -176,7 +176,8 @@ Constant* LLVMContext::getConstantArray(const ArrayType* T, Constant* LLVMContext::getConstantArray(const ArrayType* T, Constant* const* Vals, unsigned NumVals) { - return ConstantArray::get(T, Vals, NumVals); + // FIXME: make this the primary ctor method. + return getConstantArray(T, std::vector<Constant*>(Vals, Vals+NumVals)); } /// ConstantArray::get(const string&) - Return an array that is initialized to @@ -530,12 +531,14 @@ Constant* LLVMContext::getConstantVector(const VectorType* T, } Constant* LLVMContext::getConstantVector(const std::vector<Constant*>& V) { - return ConstantVector::get(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) { - return ConstantVector::get(Vals, NumVals); + // FIXME: make this the primary ctor method. + return getConstantVector(std::vector<Constant*>(Vals, Vals+NumVals)); } // MDNode accessors |