diff options
author | Owen Anderson <resistor@mac.com> | 2009-07-30 23:03:37 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2009-07-30 23:03:37 +0000 |
commit | 9e9a0d5fc26878e51a58a8b57900fcbf952c2691 (patch) | |
tree | 477eb7b58abe6134ff6accc805279396a77892e8 /lib/VMCore/Constants.cpp | |
parent | 124e6eb09d47674a4bac48a522e83e4513a970e5 (diff) |
Move more code back to 2.5 APIs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77635 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Constants.cpp')
-rw-r--r-- | lib/VMCore/Constants.cpp | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp index 1ff596fb71..f7d6946f18 100644 --- a/lib/VMCore/Constants.cpp +++ b/lib/VMCore/Constants.cpp @@ -153,7 +153,7 @@ void Constant::getVectorElements(LLVMContext &Context, } if (isa<UndefValue>(this)) { - Elts.assign(VT->getNumElements(), Context.getUndef(VT->getElementType())); + Elts.assign(VT->getNumElements(), UndefValue::get(VT->getElementType())); return; } @@ -391,7 +391,7 @@ Constant *ConstantArray::get(const ArrayType *Ty, } } - return Ty->getContext().getConstantAggregateZero(Ty); + return ConstantAggregateZero::get(Ty); } @@ -455,7 +455,7 @@ Constant* ConstantStruct::get(const StructType* T, // Implicitly locked. return pImpl->StructConstants.getOrCreate(T, V); - return T->getContext().getConstantAggregateZero(T); + return ConstantAggregateZero::get(T); } Constant* ConstantStruct::get(const std::vector<Constant*>& V, bool packed) { @@ -511,9 +511,9 @@ Constant* ConstantVector::get(const VectorType* T, } if (isZero) - return Context.getConstantAggregateZero(T); + return ConstantAggregateZero::get(T); if (isUndef) - return Context.getUndef(T); + return UndefValue::get(T); // Implicitly locked. return pImpl->VectorConstants.getOrCreate(T, V); @@ -1018,11 +1018,22 @@ bool ConstantFP::isValueValidForType(const Type *Ty, const APFloat& Val) { //===----------------------------------------------------------------------===// // Factory Function Implementation +static char getValType(ConstantAggregateZero *CPZ) { return 0; } + +ConstantAggregateZero* ConstantAggregateZero::get(const Type* Ty) { + assert((isa<StructType>(Ty) || isa<ArrayType>(Ty) || isa<VectorType>(Ty)) && + "Cannot create an aggregate zero of non-aggregate type!"); + + LLVMContextImpl *pImpl = Ty->getContext().pImpl; + // Implicitly locked. + return pImpl->AggZeroConstants.getOrCreate(Ty, 0); +} + /// destroyConstant - Remove the constant from the constant table... /// void ConstantAggregateZero::destroyConstant() { // Implicitly locked. - getType()->getContext().erase(this); + getType()->getContext().pImpl->AggZeroConstants.remove(this); destroyConstantImpl(); } @@ -2154,7 +2165,7 @@ void ConstantArray::replaceUsesOfWithOnConstant(Value *From, Value *To, Constant *Replacement = 0; if (isAllZeros) { - Replacement = Context.getConstantAggregateZero(getType()); + Replacement = ConstantAggregateZero::get(getType()); } else { // Check to see if we have this array type already. sys::SmartScopedWriter<true> Writer(pImpl->ConstantsLock); @@ -2241,7 +2252,7 @@ void ConstantStruct::replaceUsesOfWithOnConstant(Value *From, Value *To, Constant *Replacement = 0; if (isAllZeros) { - Replacement = Context.getConstantAggregateZero(getType()); + Replacement = ConstantAggregateZero::get(getType()); } else { // Check to see if we have this array type already. sys::SmartScopedWriter<true> Writer(pImpl->ConstantsLock); |