summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/X86/X86TargetMachine.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-07-09 03:32:31 +0000
committerChris Lattner <sabre@nondot.org>2009-07-09 03:32:31 +0000
commit7e3abf1ab04825cc8003c942fe6887fa6e43dda6 (patch)
tree4df1bc3a500d138dc75f3f95bf3f462865dc3f79 /llvm/lib/Target/X86/X86TargetMachine.cpp
parent821084a356df68f8a99e464c63bd1a41d938cfaa (diff)
downloadbcm5719-llvm-7e3abf1ab04825cc8003c942fe6887fa6e43dda6.tar.gz
bcm5719-llvm-7e3abf1ab04825cc8003c942fe6887fa6e43dda6.zip
many more cleanups, for example if in the "none" pic-style,
make sure we're set to static codegen. Simplify the decision tree of target->picstyle/picmode settings. llvm-svn: 75094
Diffstat (limited to 'llvm/lib/Target/X86/X86TargetMachine.cpp')
-rw-r--r--llvm/lib/Target/X86/X86TargetMachine.cpp52
1 files changed, 26 insertions, 26 deletions
diff --git a/llvm/lib/Target/X86/X86TargetMachine.cpp b/llvm/lib/Target/X86/X86TargetMachine.cpp
index 1909986165a..99fbad67b86 100644
--- a/llvm/lib/Target/X86/X86TargetMachine.cpp
+++ b/llvm/lib/Target/X86/X86TargetMachine.cpp
@@ -128,7 +128,7 @@ X86_64TargetMachine::X86_64TargetMachine(const Module &M, const std::string &FS)
: X86TargetMachine(M, FS, true) {
}
-/// X86TargetMachine ctor - Create an ILP32 architecture model
+/// X86TargetMachine ctor - Create an X86 target.
///
X86TargetMachine::X86TargetMachine(const Module &M, const std::string &FS,
bool is64Bit)
@@ -138,36 +138,37 @@ X86TargetMachine::X86TargetMachine(const Module &M, const std::string &FS,
Subtarget.getStackAlignment(), Subtarget.is64Bit() ? -8 : -4),
InstrInfo(*this), JITInfo(*this), TLInfo(*this), ELFWriterInfo(*this) {
DefRelocModel = getRelocationModel();
- // FIXME: Correctly select PIC model for Win64 stuff
+
+ // If no relocation model was picked, default as appropriate for the target.
if (getRelocationModel() == Reloc::Default) {
- if (Subtarget.isTargetDarwin() ||
- (Subtarget.isTargetCygMing() && !Subtarget.isTargetWin64()))
- setRelocationModel(Reloc::DynamicNoPIC);
- else
+ if (!Subtarget.isTargetDarwin())
setRelocationModel(Reloc::Static);
+ else if (Subtarget.is64Bit())
+ setRelocationModel(Reloc::PIC_);
+ else
+ setRelocationModel(Reloc::DynamicNoPIC);
}
assert(getRelocationModel() != Reloc::Default &&
"Relocation mode not picked");
- // 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)
+ // If no code model is picked, default to small.
+ if (getCodeModel() == CodeModel::Default)
+ setCodeModel(CodeModel::Small);
+
+ // ELF and X86-64 don'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 these systems we just
+ // compile in -static mode.
+ if (getRelocationModel() == Reloc::DynamicNoPIC &&
+ !Subtarget.isTargetDarwin())
setRelocationModel(Reloc::Static);
- if (Subtarget.is64Bit()) {
- // No DynamicNoPIC support under X86-64.
- if (getRelocationModel() == Reloc::DynamicNoPIC)
- setRelocationModel(Reloc::PIC_);
- // Default X86-64 code model is small.
- if (getCodeModel() == CodeModel::Default)
- setCodeModel(CodeModel::Small);
- }
-
- if (Subtarget.isTargetCygMing()) {
+ // Determine the PICStyle based on the target selected.
+ if (getRelocationModel() == Reloc::Static) {
+ // Unless we're in PIC or DynamicNoPIC mode, set the PIC style to None.
+ Subtarget.setPICStyle(PICStyles::None);
+ } else if (Subtarget.isTargetCygMing()) {
Subtarget.setPICStyle(PICStyles::None);
} else if (Subtarget.isTargetDarwin()) {
if (Subtarget.is64Bit())
@@ -181,10 +182,9 @@ X86TargetMachine::X86TargetMachine(const Module &M, const std::string &FS,
Subtarget.setPICStyle(PICStyles::GOT);
}
- // Finally, unless we're in PIC or DynamicNoPIC mode, set the PIC style to
- // None.
- if (getRelocationModel() == Reloc::Static)
- Subtarget.setPICStyle(PICStyles::None);
+ // Finally, if we have "none" as our PIC style, force to static mode.
+ if (Subtarget.getPICStyle() == PICStyles::None)
+ setRelocationModel(Reloc::Static);
}
//===----------------------------------------------------------------------===//
OpenPOWER on IntegriCloud