aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Target/X86/X86TargetMachine.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2008-10-18 02:06:02 +0000
committerDan Gohman <gohman@apple.com>2008-10-18 02:06:02 +0000
commit6520e20e4fb31f2e65e25c38b372b19d33a83df4 (patch)
treebdd9f9d2f77e38a304c7abc38e87b8f734f06da8 /lib/Target/X86/X86TargetMachine.cpp
parent95915730de69342d3733f5c391779ae007eb3efa (diff)
downloadexternal_llvm-6520e20e4fb31f2e65e25c38b372b19d33a83df4.zip
external_llvm-6520e20e4fb31f2e65e25c38b372b19d33a83df4.tar.gz
external_llvm-6520e20e4fb31f2e65e25c38b372b19d33a83df4.tar.bz2
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
Diffstat (limited to 'lib/Target/X86/X86TargetMachine.cpp')
-rw-r--r--lib/Target/X86/X86TargetMachine.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/Target/X86/X86TargetMachine.cpp b/lib/Target/X86/X86TargetMachine.cpp
index 923823b..ef4f897 100644
--- a/lib/Target/X86/X86TargetMachine.cpp
+++ b/lib/Target/X86/X86TargetMachine.cpp
@@ -143,6 +143,15 @@ X86TargetMachine::X86TargetMachine(const Module &M, const std::string &FS,
else
setRelocationModel(Reloc::Static);
}
+
+ // ELF doesn't have a distinct dynamic-no-PIC model. Dynamic-no-PIC
+ // is defined as a model for code which may be used in static or
+ // dynamic executables but not necessarily a shared library. On ELF
+ // implement this by using the Static model.
+ if (Subtarget.isTargetELF() &&
+ getRelocationModel() == Reloc::DynamicNoPIC)
+ setRelocationModel(Reloc::Static);
+
if (Subtarget.is64Bit()) {
// No DynamicNoPIC support under X86-64.
if (getRelocationModel() == Reloc::DynamicNoPIC)