mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-25 00:24:26 +00:00
Teach DAGCombine to fold constant offsets into GlobalAddress nodes,
and add a TargetLowering hook for it to use to determine when this is legal (i.e. not in PIC mode, etc.) This allows instruction selection to emit folded constant offsets in more cases, such as the included testcase, eliminating the need for explicit arithmetic instructions. This eliminates the need for the C++ code in X86ISelDAGToDAG.cpp that attempted to achieve the same effect, but wasn't as effective. Also, fix handling of offsets in GlobalAddressSDNodes in several places, including changing GlobalAddressSDNode's offset from int to int64_t. The Mips, Alpha, Sparc, and CellSPU targets appear to be unaware of GlobalAddress offsets currently, so set the hook to false on those targets. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57748 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -656,6 +656,23 @@ SDValue TargetLowering::getPICJumpTableRelocBase(SDValue Table,
|
||||
return Table;
|
||||
}
|
||||
|
||||
bool
|
||||
TargetLowering::isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const {
|
||||
// Assume that everything is safe in static mode.
|
||||
if (getTargetMachine().getRelocationModel() == Reloc::Static)
|
||||
return true;
|
||||
|
||||
// In dynamic-no-pic mode, assume that known defined values are safe.
|
||||
if (getTargetMachine().getRelocationModel() == Reloc::DynamicNoPIC &&
|
||||
GA &&
|
||||
!GA->getGlobal()->isDeclaration() &&
|
||||
!GA->getGlobal()->mayBeOverridden())
|
||||
return true;
|
||||
|
||||
// Otherwise assume nothing is safe.
|
||||
return false;
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Optimization Methods
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
Reference in New Issue
Block a user