diff options
author | Chris Lattner <sabre@nondot.org> | 2002-09-11 01:21:33 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-09-11 01:21:33 +0000 |
commit | 3cac88ac9e32070d46de011b01e62e316276d527 (patch) | |
tree | af3c44318c2b67446d422bcfe2ea1d93572ed166 /lib/Target/TargetData.cpp | |
parent | 106ff4551c9c35bb6bcbdd6ca50543b100a7658e (diff) |
- Change getelementptr instruction to use long indexes instead of uint
indexes for sequential types.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3682 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/TargetData.cpp')
-rw-r--r-- | lib/Target/TargetData.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/Target/TargetData.cpp b/lib/Target/TargetData.cpp index 7c55f6730e..761ae00ae3 100644 --- a/lib/Target/TargetData.cpp +++ b/lib/Target/TargetData.cpp @@ -157,17 +157,17 @@ uint64_t TargetData::getIndexedOffset(const Type *ptrTy, assert(isa<PointerType>(Ty) && "Illegal argument for getIndexedOffset()"); uint64_t Result = 0; - for (unsigned CurIDX = 0; CurIDX < Idx.size(); ++CurIDX) { - if (Idx[CurIDX]->getType() == Type::UIntTy) { + for (unsigned CurIDX = 0; CurIDX != Idx.size(); ++CurIDX) { + if (Idx[CurIDX]->getType() == Type::LongTy) { // Update Ty to refer to current element Ty = cast<SequentialType>(Ty)->getElementType(); // Get the array index and the size of each array element. // Both must be known constants, or this will fail. // Also, the product needs to be sign-extended from 32 to 64 bits. - uint64_t elementSize = this->getTypeSize(Ty); - uint64_t arrayIdx = cast<ConstantUInt>(Idx[CurIDX])->getValue(); - Result += (uint64_t) (int) (arrayIdx * elementSize); // sign-extend + int64_t elementSize = (int64_t)getTypeSize(Ty); + int64_t arrayIdx = cast<ConstantSInt>(Idx[CurIDX])->getValue(); + Result += (uint64_t)(arrayIdx * elementSize); } else if (const StructType *STy = dyn_cast<const StructType>(Ty)) { assert(Idx[CurIDX]->getType() == Type::UByteTy && "Illegal struct idx"); |