mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-13 22:58:50 +00:00
Simplify previous hack slightly.
llvm-svn: 3490
This commit is contained in:
parent
ced94f5f61
commit
da747e6066
@ -164,13 +164,11 @@ uint64_t TargetData::getIndexedOffset(const Type *ptrTy,
|
||||
|
||||
// Get the array index and the size of each array element.
|
||||
// Both must be known constants, or this will fail.
|
||||
// Also, the arrayIdx needs to be sign-extended from uint
|
||||
// to the machine register size if the reg. size > sizeof(uint).
|
||||
// Also, the arrayIdx needs to be sign-extended from 32 bits to uint64_t
|
||||
// since uint is not normally sign-extended when cast to uint64_t.
|
||||
uint64_t elementSize = this->getTypeSize(Ty);
|
||||
uint64_t arrayIdx = cast<ConstantUInt>(Idx[CurIDX])->getValue();
|
||||
if (getIntegerRegize() > sizeof(uint)) {
|
||||
arrayIdx = (uint64_t) (int) arrayIdx; // sign-extend from 32 to 64 bits
|
||||
}
|
||||
arrayIdx = (uint64_t) (int) arrayIdx; // sign-extend from 32 to 64 bits
|
||||
Result += arrayIdx * elementSize;
|
||||
|
||||
} else if (const StructType *STy = dyn_cast<const StructType>(Ty)) {
|
||||
|
Loading…
Reference in New Issue
Block a user