mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-26 20:26: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:
@@ -916,10 +916,11 @@ Constant *llvm::ConstantFoldInstOperands(unsigned Opcode, Type *DestTy,
|
||||
if (TD && CE->getOpcode() == Instruction::IntToPtr) {
|
||||
Constant *Input = CE->getOperand(0);
|
||||
unsigned InWidth = Input->getType()->getScalarSizeInBits();
|
||||
if (TD->getPointerSizeInBits() < InWidth) {
|
||||
unsigned AS = cast<PointerType>(CE->getType())->getAddressSpace();
|
||||
if (TD->getPointerSizeInBits(AS) < InWidth) {
|
||||
Constant *Mask =
|
||||
ConstantInt::get(CE->getContext(), APInt::getLowBitsSet(InWidth,
|
||||
TD->getPointerSizeInBits()));
|
||||
TD->getPointerSizeInBits(AS)));
|
||||
Input = ConstantExpr::getAnd(Input, Mask);
|
||||
}
|
||||
// Do a zext or trunc to get to the dest size.
|
||||
@@ -932,9 +933,10 @@ Constant *llvm::ConstantFoldInstOperands(unsigned Opcode, Type *DestTy,
|
||||
// the int size is >= the ptr size. This requires knowing the width of a
|
||||
// pointer, so it can't be done in ConstantExpr::getCast.
|
||||
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(Ops[0]))
|
||||
if (TD &&
|
||||
TD->getPointerSizeInBits() <= CE->getType()->getScalarSizeInBits() &&
|
||||
CE->getOpcode() == Instruction::PtrToInt)
|
||||
if (TD && CE->getOpcode() == Instruction::PtrToInt &&
|
||||
TD->getPointerSizeInBits(
|
||||
cast<PointerType>(CE->getOperand(0)->getType())->getAddressSpace())
|
||||
<= CE->getType()->getScalarSizeInBits())
|
||||
return FoldBitCast(CE->getOperand(0), DestTy, *TD);
|
||||
|
||||
return ConstantExpr::getCast(Opcode, Ops[0], DestTy);
|
||||
|
Reference in New Issue
Block a user