mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-13 22:24:07 +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:
@ -1293,15 +1293,16 @@ Instruction *InstCombiner::visitIntToPtr(IntToPtrInst &CI) {
|
||||
// If the source integer type is not the intptr_t type for this target, do a
|
||||
// trunc or zext to the intptr_t type, then inttoptr of it. This allows the
|
||||
// cast to be exposed to other transforms.
|
||||
unsigned AS = CI.getAddressSpace();
|
||||
if (TD) {
|
||||
if (CI.getOperand(0)->getType()->getScalarSizeInBits() >
|
||||
TD->getPointerSizeInBits()) {
|
||||
TD->getPointerSizeInBits(AS)) {
|
||||
Value *P = Builder->CreateTrunc(CI.getOperand(0),
|
||||
TD->getIntPtrType(CI.getContext()));
|
||||
return new IntToPtrInst(P, CI.getType());
|
||||
}
|
||||
if (CI.getOperand(0)->getType()->getScalarSizeInBits() <
|
||||
TD->getPointerSizeInBits()) {
|
||||
TD->getPointerSizeInBits(AS)) {
|
||||
Value *P = Builder->CreateZExt(CI.getOperand(0),
|
||||
TD->getIntPtrType(CI.getContext()));
|
||||
return new IntToPtrInst(P, CI.getType());
|
||||
@ -1368,13 +1369,14 @@ Instruction *InstCombiner::visitPtrToInt(PtrToIntInst &CI) {
|
||||
// If the destination integer type is not the intptr_t type for this target,
|
||||
// do a ptrtoint to intptr_t then do a trunc or zext. This allows the cast
|
||||
// to be exposed to other transforms.
|
||||
unsigned AS = CI.getPointerAddressSpace();
|
||||
if (TD) {
|
||||
if (CI.getType()->getScalarSizeInBits() < TD->getPointerSizeInBits()) {
|
||||
if (CI.getType()->getScalarSizeInBits() < TD->getPointerSizeInBits(AS)) {
|
||||
Value *P = Builder->CreatePtrToInt(CI.getOperand(0),
|
||||
TD->getIntPtrType(CI.getContext()));
|
||||
return new TruncInst(P, CI.getType());
|
||||
}
|
||||
if (CI.getType()->getScalarSizeInBits() > TD->getPointerSizeInBits()) {
|
||||
if (CI.getType()->getScalarSizeInBits() > TD->getPointerSizeInBits(AS)) {
|
||||
Value *P = Builder->CreatePtrToInt(CI.getOperand(0),
|
||||
TD->getIntPtrType(CI.getContext()));
|
||||
return new ZExtInst(P, CI.getType());
|
||||
|
Reference in New Issue
Block a user