mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-29 10:25:12 +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:
@@ -365,11 +365,12 @@ FoldCmpLoadFromIndexedGlobal(GetElementPtrInst *GEP, GlobalVariable *GV,
|
||||
// order the state machines in complexity of the generated code.
|
||||
Value *Idx = GEP->getOperand(2);
|
||||
|
||||
unsigned AS = GEP->getPointerAddressSpace();
|
||||
// If the index is larger than the pointer size of the target, truncate the
|
||||
// index down like the GEP would do implicitly. We don't have to do this for
|
||||
// an inbounds GEP because the index can't be out of range.
|
||||
if (!GEP->isInBounds() &&
|
||||
Idx->getType()->getPrimitiveSizeInBits() > TD->getPointerSizeInBits())
|
||||
Idx->getType()->getPrimitiveSizeInBits() > TD->getPointerSizeInBits(AS))
|
||||
Idx = Builder->CreateTrunc(Idx, TD->getIntPtrType(Idx->getContext()));
|
||||
|
||||
// If the comparison is only true for one or two elements, emit direct
|
||||
@@ -528,10 +529,11 @@ static Value *EvaluateGEPOffsetExpression(User *GEP, InstCombiner &IC) {
|
||||
}
|
||||
}
|
||||
|
||||
unsigned AS = cast<GetElementPtrInst>(GEP)->getPointerAddressSpace();
|
||||
// Okay, we know we have a single variable index, which must be a
|
||||
// pointer/array/vector index. If there is no offset, life is simple, return
|
||||
// the index.
|
||||
unsigned IntPtrWidth = TD.getPointerSizeInBits();
|
||||
unsigned IntPtrWidth = TD.getPointerSizeInBits(AS);
|
||||
if (Offset == 0) {
|
||||
// Cast to intptrty in case a truncation occurs. If an extension is needed,
|
||||
// we don't need to bother extending: the extension won't affect where the
|
||||
@@ -1552,7 +1554,8 @@ Instruction *InstCombiner::visitICmpInstWithCastAndCast(ICmpInst &ICI) {
|
||||
// Turn icmp (ptrtoint x), (ptrtoint/c) into a compare of the input if the
|
||||
// integer type is the same size as the pointer type.
|
||||
if (TD && LHSCI->getOpcode() == Instruction::PtrToInt &&
|
||||
TD->getPointerSizeInBits() ==
|
||||
TD->getPointerSizeInBits(
|
||||
cast<PtrToIntInst>(LHSCI)->getPointerAddressSpace()) ==
|
||||
cast<IntegerType>(DestTy)->getBitWidth()) {
|
||||
Value *RHSOp = 0;
|
||||
if (Constant *RHSC = dyn_cast<Constant>(ICI.getOperand(1))) {
|
||||
|
Reference in New Issue
Block a user