aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-02-10 19:33:15 +0000
committerChris Lattner <sabre@nondot.org>2007-02-10 19:33:15 +0000
commitddce8d21ea7088b9e6dd0f26e658a150614ca42a (patch)
tree7a8143025f0f589a9341929220781b0fefb48c8b
parente463fc809872959d33b5da9549dbe96416dded30 (diff)
downloadexternal_llvm-ddce8d21ea7088b9e6dd0f26e658a150614ca42a.zip
external_llvm-ddce8d21ea7088b9e6dd0f26e658a150614ca42a.tar.gz
external_llvm-ddce8d21ea7088b9e6dd0f26e658a150614ca42a.tar.bz2
Change TargetData::getIndexedOffset interface to not require indices
in a vector. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34153 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/Target/TargetData.h7
-rw-r--r--lib/Target/TargetData.cpp16
2 files changed, 14 insertions, 9 deletions
diff --git a/include/llvm/Target/TargetData.h b/include/llvm/Target/TargetData.h
index e462814..d577de7 100644
--- a/include/llvm/Target/TargetData.h
+++ b/include/llvm/Target/TargetData.h
@@ -247,7 +247,12 @@ public:
/// specified indices. This is used to implement getelementptr.
///
uint64_t getIndexedOffset(const Type *Ty,
- const std::vector<Value*> &Indices) const;
+ Value* const* Indices, unsigned NumIndices) const;
+
+ uint64_t getIndexedOffset(const Type *Ty,
+ const std::vector<Value*> &Indices) const {
+ return getIndexedOffset(Ty, &Indices[0], Indices.size());
+ }
/// getStructLayout - Return a StructLayout object, indicating the alignment
/// of the struct, its size, and the offsets of its fields. Note that this
diff --git a/lib/Target/TargetData.cpp b/lib/Target/TargetData.cpp
index aa32530..139ab00 100644
--- a/lib/Target/TargetData.cpp
+++ b/lib/Target/TargetData.cpp
@@ -452,18 +452,18 @@ const Type *TargetData::getIntPtrType() const {
}
-uint64_t TargetData::getIndexedOffset(const Type *ptrTy,
- const std::vector<Value*> &Idx) const {
+uint64_t TargetData::getIndexedOffset(const Type *ptrTy, Value* const* Indices,
+ unsigned NumIndices) const {
const Type *Ty = ptrTy;
assert(isa<PointerType>(Ty) && "Illegal argument for getIndexedOffset()");
uint64_t Result = 0;
- generic_gep_type_iterator<std::vector<Value*>::const_iterator>
- TI = gep_type_begin(ptrTy, Idx.begin(), Idx.end());
- for (unsigned CurIDX = 0; CurIDX != Idx.size(); ++CurIDX, ++TI) {
+ generic_gep_type_iterator<Value* const*>
+ TI = gep_type_begin(ptrTy, Indices, Indices+NumIndices);
+ for (unsigned CurIDX = 0; CurIDX != NumIndices; ++CurIDX, ++TI) {
if (const StructType *STy = dyn_cast<StructType>(*TI)) {
- assert(Idx[CurIDX]->getType() == Type::Int32Ty && "Illegal struct idx");
- unsigned FieldNo = cast<ConstantInt>(Idx[CurIDX])->getZExtValue();
+ assert(Indices[CurIDX]->getType() == Type::Int32Ty &&"Illegal struct idx");
+ unsigned FieldNo = cast<ConstantInt>(Indices[CurIDX])->getZExtValue();
// Get structure layout information...
const StructLayout *Layout = getStructLayout(STy);
@@ -479,7 +479,7 @@ uint64_t TargetData::getIndexedOffset(const Type *ptrTy,
Ty = cast<SequentialType>(Ty)->getElementType();
// Get the array index and the size of each array element.
- int64_t arrayIdx = cast<ConstantInt>(Idx[CurIDX])->getSExtValue();
+ int64_t arrayIdx = cast<ConstantInt>(Indices[CurIDX])->getSExtValue();
Result += arrayIdx * (int64_t)getTypeSize(Ty);
}
}