pass machinemoduleinfo down into getSymbolForDwarfGlobalReference,
[llvm/avr.git] / lib / Target / PowerPC / PPCTargetMachine.cpp
blob3371954c30f1acddf4b8ffd5049be4a6a2625224
1 //===-- PPCTargetMachine.cpp - Define TargetMachine for PowerPC -----------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // Top-level implementation for the PowerPC target.
12 //===----------------------------------------------------------------------===//
14 #include "PPC.h"
15 #include "PPCMCAsmInfo.h"
16 #include "PPCTargetMachine.h"
17 #include "llvm/PassManager.h"
18 #include "llvm/Target/TargetOptions.h"
19 #include "llvm/Target/TargetRegistry.h"
20 #include "llvm/Support/FormattedStream.h"
21 using namespace llvm;
23 static const MCAsmInfo *createMCAsmInfo(const Target &T,
24 const StringRef &TT) {
25 Triple TheTriple(TT);
26 bool isPPC64 = TheTriple.getArch() == Triple::ppc64;
27 if (TheTriple.getOS() == Triple::Darwin)
28 return new PPCMCAsmInfoDarwin(isPPC64);
29 return new PPCLinuxMCAsmInfo(isPPC64);
33 extern "C" void LLVMInitializePowerPCTarget() {
34 // Register the targets
35 RegisterTargetMachine<PPC32TargetMachine> A(ThePPC32Target);
36 RegisterTargetMachine<PPC64TargetMachine> B(ThePPC64Target);
38 RegisterAsmInfoFn C(ThePPC32Target, createMCAsmInfo);
39 RegisterAsmInfoFn D(ThePPC64Target, createMCAsmInfo);
43 PPCTargetMachine::PPCTargetMachine(const Target &T, const std::string &TT,
44 const std::string &FS, bool is64Bit)
45 : LLVMTargetMachine(T, TT),
46 Subtarget(TT, FS, is64Bit),
47 DataLayout(Subtarget.getTargetDataString()), InstrInfo(*this),
48 FrameInfo(*this, is64Bit), JITInfo(*this, is64Bit), TLInfo(*this),
49 InstrItins(Subtarget.getInstrItineraryData()), MachOWriterInfo(*this) {
51 if (getRelocationModel() == Reloc::Default) {
52 if (Subtarget.isDarwin())
53 setRelocationModel(Reloc::DynamicNoPIC);
54 else
55 setRelocationModel(Reloc::Static);
59 /// Override this for PowerPC. Tail merging happily breaks up instruction issue
60 /// groups, which typically degrades performance.
61 bool PPCTargetMachine::getEnableTailMergeDefault() const { return false; }
63 PPC32TargetMachine::PPC32TargetMachine(const Target &T, const std::string &TT,
64 const std::string &FS)
65 : PPCTargetMachine(T, TT, FS, false) {
69 PPC64TargetMachine::PPC64TargetMachine(const Target &T, const std::string &TT,
70 const std::string &FS)
71 : PPCTargetMachine(T, TT, FS, true) {
75 //===----------------------------------------------------------------------===//
76 // Pass Pipeline Configuration
77 //===----------------------------------------------------------------------===//
79 bool PPCTargetMachine::addInstSelector(PassManagerBase &PM,
80 CodeGenOpt::Level OptLevel) {
81 // Install an instruction selector.
82 PM.add(createPPCISelDag(*this));
83 return false;
86 bool PPCTargetMachine::addPreEmitPass(PassManagerBase &PM,
87 CodeGenOpt::Level OptLevel) {
88 // Must run branch selection immediately preceding the asm printer.
89 PM.add(createPPCBranchSelectionPass());
90 return false;
93 bool PPCTargetMachine::addCodeEmitter(PassManagerBase &PM,
94 CodeGenOpt::Level OptLevel,
95 MachineCodeEmitter &MCE) {
96 // The JIT should use the static relocation model in ppc32 mode, PIC in ppc64.
97 // FIXME: This should be moved to TargetJITInfo!!
98 if (Subtarget.isPPC64()) {
99 // We use PIC codegen in ppc64 mode, because otherwise we'd have to use many
100 // instructions to materialize arbitrary global variable + function +
101 // constant pool addresses.
102 setRelocationModel(Reloc::PIC_);
103 // Temporary workaround for the inability of PPC64 JIT to handle jump
104 // tables.
105 DisableJumpTables = true;
106 } else {
107 setRelocationModel(Reloc::Static);
110 // Inform the subtarget that we are in JIT mode. FIXME: does this break macho
111 // writing?
112 Subtarget.SetJITMode();
114 // Machine code emitter pass for PowerPC.
115 PM.add(createPPCCodeEmitterPass(*this, MCE));
117 return false;
120 bool PPCTargetMachine::addCodeEmitter(PassManagerBase &PM,
121 CodeGenOpt::Level OptLevel,
122 JITCodeEmitter &JCE) {
123 // The JIT should use the static relocation model in ppc32 mode, PIC in ppc64.
124 // FIXME: This should be moved to TargetJITInfo!!
125 if (Subtarget.isPPC64()) {
126 // We use PIC codegen in ppc64 mode, because otherwise we'd have to use many
127 // instructions to materialize arbitrary global variable + function +
128 // constant pool addresses.
129 setRelocationModel(Reloc::PIC_);
130 // Temporary workaround for the inability of PPC64 JIT to handle jump
131 // tables.
132 DisableJumpTables = true;
133 } else {
134 setRelocationModel(Reloc::Static);
137 // Inform the subtarget that we are in JIT mode. FIXME: does this break macho
138 // writing?
139 Subtarget.SetJITMode();
141 // Machine code emitter pass for PowerPC.
142 PM.add(createPPCJITCodeEmitterPass(*this, JCE));
144 return false;
147 bool PPCTargetMachine::addCodeEmitter(PassManagerBase &PM,
148 CodeGenOpt::Level OptLevel,
149 ObjectCodeEmitter &OCE) {
150 // The JIT should use the static relocation model in ppc32 mode, PIC in ppc64.
151 // FIXME: This should be moved to TargetJITInfo!!
152 if (Subtarget.isPPC64()) {
153 // We use PIC codegen in ppc64 mode, because otherwise we'd have to use many
154 // instructions to materialize arbitrary global variable + function +
155 // constant pool addresses.
156 setRelocationModel(Reloc::PIC_);
157 // Temporary workaround for the inability of PPC64 JIT to handle jump
158 // tables.
159 DisableJumpTables = true;
160 } else {
161 setRelocationModel(Reloc::Static);
164 // Inform the subtarget that we are in JIT mode. FIXME: does this break macho
165 // writing?
166 Subtarget.SetJITMode();
168 // Machine code emitter pass for PowerPC.
169 PM.add(createPPCObjectCodeEmitterPass(*this, OCE));
171 return false;
174 bool PPCTargetMachine::addSimpleCodeEmitter(PassManagerBase &PM,
175 CodeGenOpt::Level OptLevel,
176 MachineCodeEmitter &MCE) {
177 // Machine code emitter pass for PowerPC.
178 PM.add(createPPCCodeEmitterPass(*this, MCE));
179 return false;
182 bool PPCTargetMachine::addSimpleCodeEmitter(PassManagerBase &PM,
183 CodeGenOpt::Level OptLevel,
184 JITCodeEmitter &JCE) {
185 // Machine code emitter pass for PowerPC.
186 PM.add(createPPCJITCodeEmitterPass(*this, JCE));
187 return false;
190 bool PPCTargetMachine::addSimpleCodeEmitter(PassManagerBase &PM,
191 CodeGenOpt::Level OptLevel,
192 ObjectCodeEmitter &OCE) {
193 // Machine code emitter pass for PowerPC.
194 PM.add(createPPCObjectCodeEmitterPass(*this, OCE));
195 return false;