summaryrefslogtreecommitdiff
path: root/lib/VMCore/LLVMContext.cpp
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2009-07-15 21:51:10 +0000
committerOwen Anderson <resistor@mac.com>2009-07-15 21:51:10 +0000
commita90b3dc2f1f70ab7102ec3f1fc57f199fd56d7cc (patch)
treeb54a5c3b507d9f5e051bdbdd587c6c6732ac837c /lib/VMCore/LLVMContext.cpp
parent7add5ff1d1257f6f09e66be42d459610f4693d68 (diff)
downloadllvm-a90b3dc2f1f70ab7102ec3f1fc57f199fd56d7cc.tar.gz
llvm-a90b3dc2f1f70ab7102ec3f1fc57f199fd56d7cc.tar.bz2
llvm-a90b3dc2f1f70ab7102ec3f1fc57f199fd56d7cc.tar.xz
Move a few more convenience factory functions from Constant to LLVMContext.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75840 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/LLVMContext.cpp')
-rw-r--r--lib/VMCore/LLVMContext.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/VMCore/LLVMContext.cpp b/lib/VMCore/LLVMContext.cpp
index e359ae33df..73c93a2d6e 100644
--- a/lib/VMCore/LLVMContext.cpp
+++ b/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