mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-25 13:24:46 +00:00
Resubmit the changes to llvm core to update the functions to support different pointer sizes on a per address space basis.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165941 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -447,6 +447,7 @@ protected:
|
||||
|
||||
bool computeConstantGEPOffset(GetElementPtrInst &GEPI, int64_t &GEPOffset) {
|
||||
GEPOffset = Offset;
|
||||
unsigned int AS = GEPI.getPointerAddressSpace();
|
||||
for (gep_type_iterator GTI = gep_type_begin(GEPI), GTE = gep_type_end(GEPI);
|
||||
GTI != GTE; ++GTI) {
|
||||
ConstantInt *OpC = dyn_cast<ConstantInt>(GTI.getOperand());
|
||||
@@ -476,7 +477,7 @@ protected:
|
||||
continue;
|
||||
}
|
||||
|
||||
APInt Index = OpC->getValue().sextOrTrunc(TD.getPointerSizeInBits());
|
||||
APInt Index = OpC->getValue().sextOrTrunc(TD.getPointerSizeInBits(AS));
|
||||
Index *= APInt(Index.getBitWidth(),
|
||||
TD.getTypeAllocSize(GTI.getIndexedType()));
|
||||
Index += APInt(Index.getBitWidth(), (uint64_t)GEPOffset,
|
||||
@@ -1784,7 +1785,9 @@ static Value *getNaturalGEPWithType(IRBuilder<> &IRB, const DataLayout &TD,
|
||||
break;
|
||||
if (SequentialType *SeqTy = dyn_cast<SequentialType>(ElementTy)) {
|
||||
ElementTy = SeqTy->getElementType();
|
||||
Indices.push_back(IRB.getInt(APInt(TD.getPointerSizeInBits(), 0)));
|
||||
Indices.push_back(IRB.getInt(APInt(TD.getPointerSizeInBits(
|
||||
ElementTy->isPointerTy() ?
|
||||
cast<PointerType>(ElementTy)->getAddressSpace(): 0), 0)));
|
||||
} else if (StructType *STy = dyn_cast<StructType>(ElementTy)) {
|
||||
if (STy->element_begin() == STy->element_end())
|
||||
break; // Nothing left to descend into.
|
||||
@@ -2322,7 +2325,8 @@ private:
|
||||
|
||||
Value *getAdjustedAllocaPtr(IRBuilder<> &IRB, Type *PointerTy) {
|
||||
assert(BeginOffset >= NewAllocaBeginOffset);
|
||||
APInt Offset(TD.getPointerSizeInBits(), BeginOffset - NewAllocaBeginOffset);
|
||||
unsigned AS = cast<PointerType>(PointerTy)->getAddressSpace();
|
||||
APInt Offset(TD.getPointerSizeInBits(AS), BeginOffset - NewAllocaBeginOffset);
|
||||
return getAdjustedPtr(IRB, TD, &NewAI, Offset, PointerTy, getName(""));
|
||||
}
|
||||
|
||||
@@ -2677,8 +2681,10 @@ private:
|
||||
const AllocaPartitioning::MemTransferOffsets &MTO
|
||||
= P.getMemTransferOffsets(II);
|
||||
|
||||
assert(OldPtr->getType()->isPointerTy() && "Must be a pointer type!");
|
||||
unsigned AS = cast<PointerType>(OldPtr->getType())->getAddressSpace();
|
||||
// Compute the relative offset within the transfer.
|
||||
unsigned IntPtrWidth = TD.getPointerSizeInBits();
|
||||
unsigned IntPtrWidth = TD.getPointerSizeInBits(AS);
|
||||
APInt RelOffset(IntPtrWidth, BeginOffset - (IsDest ? MTO.DestBegin
|
||||
: MTO.SourceBegin));
|
||||
|
||||
|
Reference in New Issue
Block a user