summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorMatthijs Kooijman <matthijs@stdin.nl>2008-07-29 08:46:11 +0000
committerMatthijs Kooijman <matthijs@stdin.nl>2008-07-29 08:46:11 +0000
commit0446862796f831459a93a55a817c80ec4641c6e2 (patch)
tree9dd0b4cbca91281991f1b195cb2c48dc5b56fdad /llvm/lib
parentbf83579b30e6bb8248c13cc166f87986465299c6 (diff)
downloadbcm5719-llvm-0446862796f831459a93a55a817c80ec4641c6e2.tar.gz
bcm5719-llvm-0446862796f831459a93a55a817c80ec4641c6e2.zip
Add a GetElementPtrInst::getIndexedType that accepts uint64_t's instead of just Value*'s.
llvm-svn: 54157
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/VMCore/Instructions.cpp24
1 files changed, 20 insertions, 4 deletions
diff --git a/llvm/lib/VMCore/Instructions.cpp b/llvm/lib/VMCore/Instructions.cpp
index 098560a549a..bedf74cd9cc 100644
--- a/llvm/lib/VMCore/Instructions.cpp
+++ b/llvm/lib/VMCore/Instructions.cpp
@@ -1026,12 +1026,16 @@ GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx,
// getIndexedType - Returns the type of the element that would be loaded with
// a load instruction with the specified parameters.
//
+// The Idxs pointer should point to a continuous piece of memory containing the
+// indices, either as Value* or uint64_t.
+//
// A null type is returned if the indices are invalid for the specified
// pointer type.
//
-const Type* GetElementPtrInst::getIndexedType(const Type *Ptr,
- Value* const *Idxs,
- unsigned NumIdx) {
+template <typename IndexTy>
+static const Type* getIndexedTypeInternal(const Type *Ptr,
+ IndexTy const *Idxs,
+ unsigned NumIdx) {
const PointerType *PTy = dyn_cast<PointerType>(Ptr);
if (!PTy) return 0; // Type isn't a pointer type!
const Type *Agg = PTy->getElementType();
@@ -1044,7 +1048,7 @@ const Type* GetElementPtrInst::getIndexedType(const Type *Ptr,
for (; CurIdx != NumIdx; ++CurIdx) {
const CompositeType *CT = dyn_cast<CompositeType>(Agg);
if (!CT || isa<PointerType>(CT)) return 0;
- Value *Index = Idxs[CurIdx];
+ IndexTy Index = Idxs[CurIdx];
if (!CT->indexValid(Index)) return 0;
Agg = CT->getTypeAtIndex(Index);
@@ -1058,6 +1062,18 @@ const Type* GetElementPtrInst::getIndexedType(const Type *Ptr,
return CurIdx == NumIdx ? Agg : 0;
}
+const Type* GetElementPtrInst::getIndexedType(const Type *Ptr,
+ Value* const *Idxs,
+ unsigned NumIdx) {
+ return getIndexedTypeInternal(Ptr, Idxs, NumIdx);
+}
+
+const Type* GetElementPtrInst::getIndexedType(const Type *Ptr,
+ uint64_t const *Idxs,
+ unsigned NumIdx) {
+ return getIndexedTypeInternal(Ptr, Idxs, NumIdx);
+}
+
const Type* GetElementPtrInst::getIndexedType(const Type *Ptr, Value *Idx) {
const PointerType *PTy = dyn_cast<PointerType>(Ptr);
if (!PTy) return 0; // Type isn't a pointer type!
OpenPOWER on IntegriCloud