summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/X86/X86TargetMachine.cpp
diff options
context:
space:
mode:
authorAnton Korobeynikov <asl@math.spbu.ru>2007-01-12 19:20:47 +0000
committerAnton Korobeynikov <asl@math.spbu.ru>2007-01-12 19:20:47 +0000
commita0554d90e87f339b6c0d7482a3e47f4a85c588be (patch)
tree4e989acdda62e6f10c329ed2669c557c15ffb09b /llvm/lib/Target/X86/X86TargetMachine.cpp
parente759955c668b72ec15b5e35bdb07bb5b00e65172 (diff)
downloadbcm5719-llvm-a0554d90e87f339b6c0d7482a3e47f4a85c588be.tar.gz
bcm5719-llvm-a0554d90e87f339b6c0d7482a3e47f4a85c588be.zip
* PIC codegen for X86/Linux has been implemented
* PIC-aware internal structures in X86 Codegen have been refactored * Visibility (default/weak) has been added * Docs fixes (external weak linkage, visibility, formatting) llvm-svn: 33136
Diffstat (limited to 'llvm/lib/Target/X86/X86TargetMachine.cpp')
-rw-r--r--llvm/lib/Target/X86/X86TargetMachine.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/llvm/lib/Target/X86/X86TargetMachine.cpp b/llvm/lib/Target/X86/X86TargetMachine.cpp
index d92ae498cf0..8bcda9a290b 100644
--- a/llvm/lib/Target/X86/X86TargetMachine.cpp
+++ b/llvm/lib/Target/X86/X86TargetMachine.cpp
@@ -127,6 +127,25 @@ X86TargetMachine::X86TargetMachine(const Module &M, const std::string &FS, bool
if (getCodeModel() == CodeModel::Default)
setCodeModel(CodeModel::Small);
}
+
+ if (getRelocationModel() == Reloc::PIC_) {
+ if (Subtarget.isTargetDarwin()) {
+ if (Subtarget.is64Bit())
+ Subtarget.setPICStyle(PICStyle::RIPRel);
+ else
+ Subtarget.setPICStyle(PICStyle::Stub);
+ } else if (Subtarget.isTargetELF())
+ Subtarget.setPICStyle(PICStyle::GOT);
+ else
+ assert(0 && "Don't know how to generate PIC code for this target!");
+ } else if (getRelocationModel() == Reloc::DynamicNoPIC) {
+ if (Subtarget.isTargetDarwin())
+ Subtarget.setPICStyle(PICStyle::Stub);
+ else if (Subtarget.isTargetCygMing())
+ Subtarget.setPICStyle(PICStyle::WinPIC);
+ else
+ assert(0 && "Don't know how to generate PIC code for this target!");
+ }
}
//===----------------------------------------------------------------------===//
@@ -163,6 +182,8 @@ bool X86TargetMachine::addCodeEmitter(FunctionPassManager &PM, bool Fast,
MachineCodeEmitter &MCE) {
// FIXME: Move this to TargetJITInfo!
setRelocationModel(Reloc::Static);
+ Subtarget.setPICStyle(PICStyle::None);
+
// JIT cannot ensure globals are placed in the lower 4G of address.
if (Subtarget.is64Bit())
setCodeModel(CodeModel::Large);
OpenPOWER on IntegriCloud