diff options
author | Chris Lattner <sabre@nondot.org> | 2011-02-15 00:14:00 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2011-02-15 00:14:00 +0000 |
commit | 2ca5c8644e6c35b3a7910a576ed89cddb7b82c3b (patch) | |
tree | 6f1f14dd87926e65a6beff9e41fb051e116d7f1c /lib/VMCore/Constants.cpp | |
parent | 04df049014396fe97a31bf3fa8951201b2ed8ffe (diff) |
convert ConstantVector::get to use ArrayRef.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125537 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Constants.cpp')
-rw-r--r-- | lib/VMCore/Constants.cpp | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp index 42c60769f5..cac37cbcc3 100644 --- a/lib/VMCore/Constants.cpp +++ b/lib/VMCore/Constants.cpp @@ -94,7 +94,7 @@ Constant *Constant::getAllOnesValue(const Type *Ty) { return ConstantInt::get(Ty->getContext(), APInt::getAllOnesValue(ITy->getBitWidth())); - std::vector<Constant*> Elts; + SmallVector<Constant*, 16> Elts; const VectorType *VTy = cast<VectorType>(Ty); Elts.resize(VTy->getNumElements(), getAllOnesValue(VTy->getElementType())); assert(Elts[0] && "Not a vector integer type!"); @@ -302,8 +302,8 @@ Constant *ConstantInt::get(const Type* Ty, uint64_t V, bool isSigned) { // For vectors, broadcast the value. if (const VectorType *VTy = dyn_cast<VectorType>(Ty)) - return ConstantVector::get( - std::vector<Constant *>(VTy->getNumElements(), C)); + return ConstantVector::get(SmallVector<Constant*, + 16>(VTy->getNumElements(), C)); return C; } @@ -329,7 +329,7 @@ Constant *ConstantInt::get(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)); + SmallVector<Constant *, 16>(VTy->getNumElements(), C)); return C; } @@ -372,7 +372,7 @@ Constant *ConstantFP::get(const Type* Ty, double V) { // For vectors, broadcast the value. if (const VectorType *VTy = dyn_cast<VectorType>(Ty)) return ConstantVector::get( - std::vector<Constant *>(VTy->getNumElements(), C)); + SmallVector<Constant *, 16>(VTy->getNumElements(), C)); return C; } @@ -387,7 +387,7 @@ Constant *ConstantFP::get(const Type* Ty, StringRef Str) { // For vectors, broadcast the value. if (const VectorType *VTy = dyn_cast<VectorType>(Ty)) return ConstantVector::get( - std::vector<Constant *>(VTy->getNumElements(), C)); + SmallVector<Constant *, 16>(VTy->getNumElements(), C)); return C; } @@ -404,9 +404,9 @@ ConstantFP* ConstantFP::getNegativeZero(const Type* Ty) { Constant *ConstantFP::getZeroValueForNegation(const Type* Ty) { if (const VectorType *PTy = dyn_cast<VectorType>(Ty)) if (PTy->getElementType()->isFloatingPointTy()) { - std::vector<Constant*> zeros(PTy->getNumElements(), + SmallVector<Constant*, 16> zeros(PTy->getNumElements(), getNegativeZero(PTy->getElementType())); - return ConstantVector::get(PTy, zeros); + return ConstantVector::get(zeros); } if (Ty->isFloatingPointTy()) @@ -601,13 +601,12 @@ ConstantVector::ConstantVector(const VectorType *T, } // ConstantVector accessors. -Constant *ConstantVector::get(const VectorType* T, - const std::vector<Constant*>& V) { +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; + LLVMContextImpl *pImpl = T->getContext().pImpl; - // If this is an all-undef or alll-zero vector, return a + // If this is an all-undef or all-zero vector, return a // ConstantAggregateZero or UndefValue. Constant *C = V[0]; bool isZero = C->isNullValue(); @@ -629,14 +628,10 @@ Constant *ConstantVector::get(const VectorType* T, 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) { +Constant *ConstantVector::get(ArrayRef<Constant*> V) { // FIXME: make this the primary ctor method. - return get(std::vector<Constant*>(Vals, Vals+NumVals)); + assert(!V.empty() && "Vectors cannot be empty"); + return get(VectorType::get(V.front()->getType(), V.size()), V.vec()); } // Utility function for determining if a ConstantExpr is a CastOp or not. This |