diff options
author | Owen Anderson <resistor@mac.com> | 2009-07-27 22:29:26 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2009-07-27 22:29:26 +0000 |
commit | 8fa3338ed2400c1352b137613d2c2c70d1ead695 (patch) | |
tree | 4e170be384fe7fcc54a6f686a6087729fc52ac0c /lib/VMCore/LLVMContextImpl.cpp | |
parent | f08583b5323801b001175c2a62ac3e3d258723ac (diff) | |
download | llvm-8fa3338ed2400c1352b137613d2c2c70d1ead695.tar.gz llvm-8fa3338ed2400c1352b137613d2c2c70d1ead695.tar.bz2 llvm-8fa3338ed2400c1352b137613d2c2c70d1ead695.tar.xz |
Move ConstantStruct back to 2.5 API.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77266 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/LLVMContextImpl.cpp')
-rw-r--r-- | lib/VMCore/LLVMContextImpl.cpp | 89 |
1 files changed, 1 insertions, 88 deletions
diff --git a/lib/VMCore/LLVMContextImpl.cpp b/lib/VMCore/LLVMContextImpl.cpp index 5315e23f8e..858ed15d9b 100644 --- a/lib/VMCore/LLVMContextImpl.cpp +++ b/lib/VMCore/LLVMContextImpl.cpp @@ -29,14 +29,6 @@ static std::vector<Constant*> getValType(ConstantArray *CA) { return Elements; } -static std::vector<Constant*> getValType(ConstantStruct *CS) { - std::vector<Constant*> Elements; - Elements.reserve(CS->getNumOperands()); - for (unsigned i = 0, e = CS->getNumOperands(); i != e; ++i) - Elements.push_back(cast<Constant>(CS->getOperand(i))); - return Elements; -} - static std::vector<Constant*> getValType(ConstantVector *CP) { std::vector<Constant*> Elements; Elements.reserve(CP->getNumOperands()); @@ -112,17 +104,6 @@ Constant *LLVMContextImpl::getConstantArray(const ArrayType *Ty, return Context.getConstantAggregateZero(Ty); } -Constant *LLVMContextImpl::getConstantStruct(const StructType *Ty, - const std::vector<Constant*> &V) { - // Create a ConstantAggregateZero value if all elements are zeros... - for (unsigned i = 0, e = V.size(); i != e; ++i) - if (!V[i]->isNullValue()) - // Implicitly locked. - return StructConstants.getOrCreate(Ty, V); - - return Context.getConstantAggregateZero(Ty); -} - Constant *LLVMContextImpl::getConstantVector(const VectorType *Ty, const std::vector<Constant*> &V) { assert(!V.empty() && "Vectors can't be empty"); @@ -169,10 +150,6 @@ void LLVMContextImpl::erase(ConstantArray *C) { ArrayConstants.remove(C); } -void LLVMContextImpl::erase(ConstantStruct *S) { - StructConstants.remove(S); -} - void LLVMContextImpl::erase(ConstantVector *V) { VectorConstants.remove(V); } @@ -255,68 +232,4 @@ Constant *LLVMContextImpl::replaceUsesOfWithOnConstant(ConstantArray *CA, } return Replacement; -} - -Constant *LLVMContextImpl::replaceUsesOfWithOnConstant(ConstantStruct *CS, - Value *From, Value *To, Use *U) { - assert(isa<Constant>(To) && "Cannot make Constant refer to non-constant!"); - Constant *ToC = cast<Constant>(To); - - unsigned OperandToUpdate = U - CS->OperandList; - assert(CS->getOperand(OperandToUpdate) == From && - "ReplaceAllUsesWith broken!"); - - std::pair<StructConstantsTy::MapKey, Constant*> Lookup; - Lookup.first.first = CS->getType(); - Lookup.second = CS; - std::vector<Constant*> &Values = Lookup.first.second; - Values.reserve(CS->getNumOperands()); // Build replacement struct. - - - // Fill values with the modified operands of the constant struct. Also, - // compute whether this turns into an all-zeros struct. - bool isAllZeros = false; - if (!ToC->isNullValue()) { - for (Use *O = CS->OperandList, *E = CS->OperandList + CS->getNumOperands(); - O != E; ++O) - Values.push_back(cast<Constant>(O->get())); - } else { - isAllZeros = true; - for (Use *O = CS->OperandList, *E = CS->OperandList + CS->getNumOperands(); - O != E; ++O) { - Constant *Val = cast<Constant>(O->get()); - Values.push_back(Val); - if (isAllZeros) isAllZeros = Val->isNullValue(); - } - } - Values[OperandToUpdate] = ToC; - - Constant *Replacement = 0; - if (isAllZeros) { - Replacement = Context.getConstantAggregateZero(CS->getType()); - } else { - // Check to see if we have this array type already. - sys::SmartScopedWriter<true> Writer(ConstantsLock); - bool Exists; - StructConstantsTy::MapTy::iterator I = - StructConstants.InsertOrGetItem(Lookup, Exists); - - if (Exists) { - Replacement = I->second; - } else { - // Okay, the new shape doesn't exist in the system yet. Instead of - // creating a new constant struct, inserting it, replaceallusesof'ing the - // old with the new, then deleting the old... just update the current one - // in place! - StructConstants.MoveConstantToNewSlot(CS, I); - - // Update to the new value. - CS->setOperand(OperandToUpdate, ToC); - return 0; - } - } - - assert(Replacement != CS && "I didn't contain From!"); - - return Replacement; -} +}
\ No newline at end of file |