diff options
author | Chris Lattner <sabre@nondot.org> | 2007-01-31 04:40:28 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-01-31 04:40:28 +0000 |
commit | 302116a5ec74c8912e552b3dbc03045a585e6302 (patch) | |
tree | 9afd0313ae50f06d4670aca0c6551166f800f53e /llvm/lib/VMCore/Instructions.cpp | |
parent | 64488b1cc31baebbaa02f289033ec61b562a33fa (diff) | |
download | bcm5719-llvm-302116a5ec74c8912e552b3dbc03045a585e6302.tar.gz bcm5719-llvm-302116a5ec74c8912e552b3dbc03045a585e6302.zip |
Revise APIs for creating constantexpr GEPs to not require the use of vectors.
This allows us to eliminate many temporary vectors, and theirassociated malloc/free pairs.
llvm-svn: 33692
Diffstat (limited to 'llvm/lib/VMCore/Instructions.cpp')
-rw-r--r-- | llvm/lib/VMCore/Instructions.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/llvm/lib/VMCore/Instructions.cpp b/llvm/lib/VMCore/Instructions.cpp index f996ab88e53..ccd25de022f 100644 --- a/llvm/lib/VMCore/Instructions.cpp +++ b/llvm/lib/VMCore/Instructions.cpp @@ -765,12 +765,13 @@ GetElementPtrInst::~GetElementPtrInst() { // pointer type. // const Type* GetElementPtrInst::getIndexedType(const Type *Ptr, - const std::vector<Value*> &Idx, + Value* const *Idxs, + unsigned NumIdx, bool AllowCompositeLeaf) { if (!isa<PointerType>(Ptr)) return 0; // Type isn't a pointer type! // Handle the special case of the empty set index set... - if (Idx.empty()) + if (NumIdx == 0) if (AllowCompositeLeaf || cast<PointerType>(Ptr)->getElementType()->isFirstClassType()) return cast<PointerType>(Ptr)->getElementType(); @@ -779,12 +780,12 @@ const Type* GetElementPtrInst::getIndexedType(const Type *Ptr, unsigned CurIdx = 0; while (const CompositeType *CT = dyn_cast<CompositeType>(Ptr)) { - if (Idx.size() == CurIdx) { + if (NumIdx == CurIdx) { if (AllowCompositeLeaf || CT->isFirstClassType()) return Ptr; return 0; // Can't load a whole structure or array!?!? } - Value *Index = Idx[CurIdx++]; + Value *Index = Idxs[CurIdx++]; if (isa<PointerType>(CT) && CurIdx != 1) return 0; // Can only index into pointer types at the first index! if (!CT->indexValid(Index)) return 0; @@ -798,7 +799,7 @@ const Type* GetElementPtrInst::getIndexedType(const Type *Ptr, Ptr = Ty; } } - return CurIdx == Idx.size() ? Ptr : 0; + return CurIdx == NumIdx ? Ptr : 0; } const Type* GetElementPtrInst::getIndexedType(const Type *Ptr, |