[llvm-commits] CVS: llvm/lib/Target/TargetData.cpp
Chris Lattner
lattner at cs.uiuc.edu
Tue Sep 10 20:21:10 PDT 2002
Changes in directory llvm/lib/Target:
TargetData.cpp updated: 1.21 -> 1.22
---
Log message:
- Change getelementptr instruction to use long indexes instead of uint
indexes for sequential types.
---
Diffs of the changes:
Index: llvm/lib/Target/TargetData.cpp
diff -u llvm/lib/Target/TargetData.cpp:1.21 llvm/lib/Target/TargetData.cpp:1.22
--- llvm/lib/Target/TargetData.cpp:1.21 Sat Aug 24 09:44:58 2002
+++ llvm/lib/Target/TargetData.cpp Tue Sep 10 20:20:05 2002
@@ -157,17 +157,17 @@
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");
More information about the llvm-commits
mailing list