blob: cdfc7ac2f553e2e6bbb5e74383f6b0b681fcb493 [file] [log] [blame]
Chris Lattner02a3d832002-10-29 22:37:54 +00001//===-- X86TargetMachine.cpp - Define TargetMachine for the X86 -----------===//
Misha Brukmanc88330a2005-04-21 23:38:14 +00002//
John Criswell482202a2003-10-20 19:43:21 +00003// The LLVM Compiler Infrastructure
4//
Chris Lattnerf3ebc3f2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Misha Brukmanc88330a2005-04-21 23:38:14 +00007//
John Criswell482202a2003-10-20 19:43:21 +00008//===----------------------------------------------------------------------===//
Misha Brukmanc88330a2005-04-21 23:38:14 +00009//
Chris Lattner02a3d832002-10-29 22:37:54 +000010// This file defines the X86 specific subclass of TargetMachine.
11//
12//===----------------------------------------------------------------------===//
13
Jim Laskeyae92ce82006-09-07 23:39:26 +000014#include "X86TargetAsmInfo.h"
Chris Lattner02a3d832002-10-29 22:37:54 +000015#include "X86TargetMachine.h"
Chris Lattnera32b4052002-12-24 00:04:01 +000016#include "X86.h"
Chris Lattner4fd144a2003-08-24 19:49:48 +000017#include "llvm/Module.h"
Chris Lattner524608a2003-04-23 16:24:55 +000018#include "llvm/PassManager.h"
Chris Lattnerd7a85562002-10-30 00:47:49 +000019#include "llvm/CodeGen/MachineFunction.h"
Chris Lattner962d5be2003-01-13 00:51:23 +000020#include "llvm/CodeGen/Passes.h"
Owen Anderson93719642008-08-21 00:14:44 +000021#include "llvm/Support/raw_ostream.h"
Chris Lattnerc2726e62004-07-11 04:17:10 +000022#include "llvm/Target/TargetOptions.h"
Chris Lattner4266f802004-07-11 02:48:49 +000023#include "llvm/Target/TargetMachineRegistry.h"
Chris Lattner833c3c22003-12-20 01:22:19 +000024using namespace llvm;
Brian Gaeke960707c2003-11-11 22:41:34 +000025
Jeff Cohen68f28732005-01-03 16:34:19 +000026/// X86TargetMachineModule - Note that this is used on hosts that cannot link
27/// in a library unless there are references into the library. In particular,
28/// it seems that it is not possible to get things to work on Win32 without
29/// this. Though it is unused, do not remove it.
30extern "C" int X86TargetMachineModule;
31int X86TargetMachineModule = 0;
32
Dan Gohmand78c4002008-05-13 00:00:25 +000033// Register the target.
34static RegisterTarget<X86_32TargetMachine>
Dan Gohman9c4b7d52008-10-14 20:25:08 +000035X("x86", "32-bit X86: Pentium-Pro and above");
Dan Gohmand78c4002008-05-13 00:00:25 +000036static RegisterTarget<X86_64TargetMachine>
Dan Gohman9c4b7d52008-10-14 20:25:08 +000037Y("x86-64", "64-bit X86: EM64T and AMD64");
Chris Lattnere0c25aa2002-12-16 16:15:51 +000038
Bob Wilson5a495fe2009-06-23 23:59:40 +000039// Force static initialization.
40extern "C" void LLVMInitializeX86Target() { }
Douglas Gregor1b731d52009-06-16 20:12:29 +000041
Anton Korobeynikovc5faeb82008-08-17 13:53:59 +000042// No assembler printer by default
43X86TargetMachine::AsmPrinterCtorFn X86TargetMachine::AsmPrinterCtor = 0;
44
Jim Laskeyae92ce82006-09-07 23:39:26 +000045const TargetAsmInfo *X86TargetMachine::createTargetAsmInfo() const {
Anton Korobeynikov9a6ed372008-07-09 13:20:48 +000046 if (Subtarget.isFlavorIntel())
47 return new X86WinTargetAsmInfo(*this);
48 else
49 switch (Subtarget.TargetType) {
50 case X86Subtarget::isDarwin:
51 return new X86DarwinTargetAsmInfo(*this);
52 case X86Subtarget::isELF:
53 return new X86ELFTargetAsmInfo(*this);
54 case X86Subtarget::isMingw:
55 case X86Subtarget::isCygwin:
56 return new X86COFFTargetAsmInfo(*this);
57 case X86Subtarget::isWindows:
58 return new X86WinTargetAsmInfo(*this);
59 default:
Anton Korobeynikov87001fd2008-09-25 21:00:33 +000060 return new X86GenericTargetAsmInfo(*this);
Anton Korobeynikov9a6ed372008-07-09 13:20:48 +000061 }
Jim Laskeyae92ce82006-09-07 23:39:26 +000062}
63
Evan Cheng11b0a5d2006-09-08 06:48:29 +000064unsigned X86_32TargetMachine::getJITMatchQuality() {
Chris Lattnerfbc070b2004-10-18 15:54:17 +000065#if defined(i386) || defined(__i386__) || defined(__x86__) || defined(_M_IX86)
Chris Lattner4266f802004-07-11 02:48:49 +000066 return 10;
Chris Lattner4266f802004-07-11 02:48:49 +000067#endif
Evan Cheng11b0a5d2006-09-08 06:48:29 +000068 return 0;
Chris Lattner4266f802004-07-11 02:48:49 +000069}
70
Evan Cheng11b0a5d2006-09-08 06:48:29 +000071unsigned X86_64TargetMachine::getJITMatchQuality() {
Anton Korobeynikova3476632008-03-23 13:43:47 +000072#if defined(__x86_64__) || defined(_M_AMD64)
Evan Cheng11b0a5d2006-09-08 06:48:29 +000073 return 10;
74#endif
75 return 0;
76}
77
78unsigned X86_32TargetMachine::getModuleMatchQuality(const Module &M) {
Chris Lattner17550c42004-12-12 17:40:28 +000079 // We strongly match "i[3-9]86-*".
80 std::string TT = M.getTargetTriple();
81 if (TT.size() >= 5 && TT[0] == 'i' && TT[2] == '8' && TT[3] == '6' &&
82 TT[4] == '-' && TT[1] - '3' < 6)
83 return 20;
Chris Lattner517290a2007-07-09 17:25:29 +000084 // If the target triple is something non-X86, we don't match.
85 if (!TT.empty()) return 0;
Chris Lattner17550c42004-12-12 17:40:28 +000086
Chris Lattner4266f802004-07-11 02:48:49 +000087 if (M.getEndianness() == Module::LittleEndian &&
88 M.getPointerSize() == Module::Pointer32)
Chris Lattner17550c42004-12-12 17:40:28 +000089 return 10; // Weak match
Chris Lattner4266f802004-07-11 02:48:49 +000090 else if (M.getEndianness() != Module::AnyEndianness ||
91 M.getPointerSize() != Module::AnyPointerSize)
92 return 0; // Match for some other target
93
94 return getJITMatchQuality()/2;
95}
Chris Lattner02a3d832002-10-29 22:37:54 +000096
Evan Cheng11b0a5d2006-09-08 06:48:29 +000097unsigned X86_64TargetMachine::getModuleMatchQuality(const Module &M) {
98 // We strongly match "x86_64-*".
99 std::string TT = M.getTargetTriple();
100 if (TT.size() >= 7 && TT[0] == 'x' && TT[1] == '8' && TT[2] == '6' &&
101 TT[3] == '_' && TT[4] == '6' && TT[5] == '4' && TT[6] == '-')
102 return 20;
103
Chris Lattner68f62b52006-12-19 19:40:09 +0000104 // We strongly match "amd64-*".
105 if (TT.size() >= 6 && TT[0] == 'a' && TT[1] == 'm' && TT[2] == 'd' &&
106 TT[3] == '6' && TT[4] == '4' && TT[5] == '-')
107 return 20;
108
Chris Lattner517290a2007-07-09 17:25:29 +0000109 // If the target triple is something non-X86-64, we don't match.
110 if (!TT.empty()) return 0;
111
Evan Cheng11b0a5d2006-09-08 06:48:29 +0000112 if (M.getEndianness() == Module::LittleEndian &&
113 M.getPointerSize() == Module::Pointer64)
114 return 10; // Weak match
115 else if (M.getEndianness() != Module::AnyEndianness ||
116 M.getPointerSize() != Module::AnyPointerSize)
117 return 0; // Match for some other target
118
119 return getJITMatchQuality()/2;
120}
121
Bruno Cardoso Lopes9fd794b2009-06-01 19:57:37 +0000122X86_32TargetMachine::X86_32TargetMachine(const Module &M, const std::string &FS)
Evan Cheng11b0a5d2006-09-08 06:48:29 +0000123 : X86TargetMachine(M, FS, false) {
124}
125
126
127X86_64TargetMachine::X86_64TargetMachine(const Module &M, const std::string &FS)
128 : X86TargetMachine(M, FS, true) {
129}
130
Chris Lattner7e3abf12009-07-09 03:32:31 +0000131/// X86TargetMachine ctor - Create an X86 target.
Chris Lattner02a3d832002-10-29 22:37:54 +0000132///
Evan Chengd00d3442007-02-23 03:03:16 +0000133X86TargetMachine::X86TargetMachine(const Module &M, const std::string &FS,
134 bool is64Bit)
Evan Cheng11b0a5d2006-09-08 06:48:29 +0000135 : Subtarget(M, FS, is64Bit),
Dale Johannesend1822ea2007-08-06 21:48:35 +0000136 DataLayout(Subtarget.getDataLayout()),
Nate Begemanf26625e2005-07-12 01:41:54 +0000137 FrameInfo(TargetFrameInfo::StackGrowsDown,
Evan Cheng11b0a5d2006-09-08 06:48:29 +0000138 Subtarget.getStackAlignment(), Subtarget.is64Bit() ? -8 : -4),
Bruno Cardoso Lopes16563662009-06-11 19:16:03 +0000139 InstrInfo(*this), JITInfo(*this), TLInfo(*this), ELFWriterInfo(*this) {
Evan Cheng345a00b2007-12-22 09:40:20 +0000140 DefRelocModel = getRelocationModel();
Chris Lattner7e3abf12009-07-09 03:32:31 +0000141
142 // If no relocation model was picked, default as appropriate for the target.
Anton Korobeynikov40d67c52008-02-20 11:22:39 +0000143 if (getRelocationModel() == Reloc::Default) {
Chris Lattner7e3abf12009-07-09 03:32:31 +0000144 if (!Subtarget.isTargetDarwin())
Evan Cheng0c2a74a2006-12-04 18:07:10 +0000145 setRelocationModel(Reloc::Static);
Chris Lattner7e3abf12009-07-09 03:32:31 +0000146 else if (Subtarget.is64Bit())
147 setRelocationModel(Reloc::PIC_);
148 else
149 setRelocationModel(Reloc::DynamicNoPIC);
Anton Korobeynikov40d67c52008-02-20 11:22:39 +0000150 }
Dan Gohman2fe6bee2008-10-18 02:06:02 +0000151
Chris Lattner1c5bf9d2009-07-09 03:15:51 +0000152 assert(getRelocationModel() != Reloc::Default &&
153 "Relocation mode not picked");
154
Chris Lattner7e3abf12009-07-09 03:32:31 +0000155 // If no code model is picked, default to small.
156 if (getCodeModel() == CodeModel::Default)
157 setCodeModel(CodeModel::Small);
158
Chris Lattner0b0c5cc2009-07-09 03:37:30 +0000159 // ELF and X86-64 don't have a distinct DynamicNoPIC model. DynamicNoPIC
Chris Lattner7e3abf12009-07-09 03:32:31 +0000160 // is defined as a model for code which may be used in static or dynamic
161 // executables but not necessarily a shared library. On these systems we just
162 // compile in -static mode.
163 if (getRelocationModel() == Reloc::DynamicNoPIC &&
164 !Subtarget.isTargetDarwin())
Dan Gohman2fe6bee2008-10-18 02:06:02 +0000165 setRelocationModel(Reloc::Static);
166
Chris Lattner0b0c5cc2009-07-09 03:37:30 +0000167 // If we are on Darwin, disallow static relocation model in X86-64 mode, since
168 // the Mach-O file format doesn't support it.
169 if (getRelocationModel() == Reloc::Static &&
170 Subtarget.isTargetDarwin() &&
171 is64Bit)
172 setRelocationModel(Reloc::PIC_);
173
Chris Lattner7e3abf12009-07-09 03:32:31 +0000174 // Determine the PICStyle based on the target selected.
175 if (getRelocationModel() == Reloc::Static) {
176 // Unless we're in PIC or DynamicNoPIC mode, set the PIC style to None.
177 Subtarget.setPICStyle(PICStyles::None);
178 } else if (Subtarget.isTargetCygMing()) {
Chris Lattner1c5bf9d2009-07-09 03:15:51 +0000179 Subtarget.setPICStyle(PICStyles::None);
180 } else if (Subtarget.isTargetDarwin()) {
Evan Cheng97057f32007-01-18 22:27:12 +0000181 if (Subtarget.is64Bit())
Duncan Sands595a4422008-11-28 09:29:37 +0000182 Subtarget.setPICStyle(PICStyles::RIPRel);
Anton Korobeynikova0554d92007-01-12 19:20:47 +0000183 else
Duncan Sands595a4422008-11-28 09:29:37 +0000184 Subtarget.setPICStyle(PICStyles::Stub);
Anton Korobeynikov40d67c52008-02-20 11:22:39 +0000185 } else if (Subtarget.isTargetELF()) {
Evan Cheng97057f32007-01-18 22:27:12 +0000186 if (Subtarget.is64Bit())
Duncan Sands595a4422008-11-28 09:29:37 +0000187 Subtarget.setPICStyle(PICStyles::RIPRel);
Anton Korobeynikova0554d92007-01-12 19:20:47 +0000188 else
Duncan Sands595a4422008-11-28 09:29:37 +0000189 Subtarget.setPICStyle(PICStyles::GOT);
Anton Korobeynikov40d67c52008-02-20 11:22:39 +0000190 }
Chris Lattner1c5bf9d2009-07-09 03:15:51 +0000191
Chris Lattner7e3abf12009-07-09 03:32:31 +0000192 // Finally, if we have "none" as our PIC style, force to static mode.
193 if (Subtarget.getPICStyle() == PICStyles::None)
194 setRelocationModel(Reloc::Static);
Chris Lattnera1d312c2006-02-03 18:59:39 +0000195}
Chris Lattner02a3d832002-10-29 22:37:54 +0000196
Chris Lattner12e97302006-09-04 04:14:57 +0000197//===----------------------------------------------------------------------===//
198// Pass Pipeline Configuration
199//===----------------------------------------------------------------------===//
Chris Lattner1d6ba3e2003-08-05 16:34:44 +0000200
Bill Wendling026e5d72009-04-29 23:29:43 +0000201bool X86TargetMachine::addInstSelector(PassManagerBase &PM,
202 CodeGenOpt::Level OptLevel) {
Nate Begemanbe1f3142005-08-18 23:53:15 +0000203 // Install an instruction selector.
Bill Wendling084669a2009-04-29 00:15:41 +0000204 PM.add(createX86ISelDag(*this, OptLevel));
Dan Gohman19145312008-10-25 17:46:52 +0000205
206 // If we're using Fast-ISel, clean up the mess.
207 if (EnableFastISel)
208 PM.add(createDeadMachineInstructionElimPass());
209
Dan Gohman88ba5f02008-11-12 22:55:05 +0000210 // Install a pass to insert x87 FP_REG_KILL instructions, as needed.
211 PM.add(createX87FPRegKillInserterPass());
212
Chris Lattner12e97302006-09-04 04:14:57 +0000213 return false;
Brian Gaekeac94bab2003-06-18 21:43:21 +0000214}
215
Bill Wendling026e5d72009-04-29 23:29:43 +0000216bool X86TargetMachine::addPreRegAlloc(PassManagerBase &PM,
217 CodeGenOpt::Level OptLevel) {
Anton Korobeynikovc1534dc2008-04-23 18:23:30 +0000218 // Calculate and set max stack object alignment early, so we can decide
219 // whether we will need stack realignment (and thus FP).
Anton Korobeynikov26590112008-04-23 18:23:05 +0000220 PM.add(createX86MaxStackAlignmentCalculatorPass());
221 return false; // -print-machineinstr shouldn't print after this.
222}
223
Bill Wendling026e5d72009-04-29 23:29:43 +0000224bool X86TargetMachine::addPostRegAlloc(PassManagerBase &PM,
225 CodeGenOpt::Level OptLevel) {
Chris Lattner962d5be2003-01-13 00:51:23 +0000226 PM.add(createX86FloatingPointStackifierPass());
Chris Lattner12e97302006-09-04 04:14:57 +0000227 return true; // -print-machineinstr should print after this.
Chris Lattner02a3d832002-10-29 22:37:54 +0000228}
229
Bill Wendling084669a2009-04-29 00:15:41 +0000230bool X86TargetMachine::addAssemblyEmitter(PassManagerBase &PM,
Bill Wendling026e5d72009-04-29 23:29:43 +0000231 CodeGenOpt::Level OptLevel,
Bill Wendling084669a2009-04-29 00:15:41 +0000232 bool Verbose,
233 raw_ostream &Out) {
Anton Korobeynikovc5faeb82008-08-17 13:53:59 +0000234 assert(AsmPrinterCtor && "AsmPrinter was not linked in");
235 if (AsmPrinterCtor)
Daniel Dunbar75c12e12009-07-01 01:48:54 +0000236 PM.add(AsmPrinterCtor(Out, *this, Verbose));
Chris Lattner12e97302006-09-04 04:14:57 +0000237 return false;
238}
239
Bill Wendling026e5d72009-04-29 23:29:43 +0000240bool X86TargetMachine::addCodeEmitter(PassManagerBase &PM,
241 CodeGenOpt::Level OptLevel,
Bruno Cardoso Lopes9fd794b2009-06-01 19:57:37 +0000242 bool DumpAsm,
243 MachineCodeEmitter &MCE) {
Chris Lattner49c45d32006-09-04 18:48:41 +0000244 // FIXME: Move this to TargetJITInfo!
Dale Johannesen30e5dbb2008-08-12 21:02:08 +0000245 // On Darwin, do not override 64-bit setting made in X86TargetMachine().
246 if (DefRelocModel == Reloc::Default &&
Chris Lattner0b0c5cc2009-07-09 03:37:30 +0000247 (!Subtarget.isTargetDarwin() || !Subtarget.is64Bit())) {
Evan Cheng345a00b2007-12-22 09:40:20 +0000248 setRelocationModel(Reloc::Static);
Chris Lattner0b0c5cc2009-07-09 03:37:30 +0000249 Subtarget.setPICStyle(PICStyles::None);
250 }
Anton Korobeynikova0554d92007-01-12 19:20:47 +0000251
Dale Johannesendafdbf72008-08-11 23:46:25 +0000252 // 64-bit JIT places everything in the same buffer except external functions.
Dale Johannesen30e5dbb2008-08-12 21:02:08 +0000253 // On Darwin, use small code model but hack the call instruction for
254 // externals. Elsewhere, do not assume globals are in the lower 4G.
255 if (Subtarget.is64Bit()) {
256 if (Subtarget.isTargetDarwin())
257 setCodeModel(CodeModel::Small);
258 else
259 setCodeModel(CodeModel::Large);
260 }
Anton Korobeynikov93acb492006-12-20 01:03:20 +0000261
Evan Chengf6acb342006-07-25 20:40:54 +0000262 PM.add(createX86CodeEmitterPass(*this, MCE));
Anton Korobeynikovc5faeb82008-08-17 13:53:59 +0000263 if (DumpAsm) {
264 assert(AsmPrinterCtor && "AsmPrinter was not linked in");
265 if (AsmPrinterCtor)
Daniel Dunbar75c12e12009-07-01 01:48:54 +0000266 PM.add(AsmPrinterCtor(errs(), *this, true));
Anton Korobeynikovc5faeb82008-08-17 13:53:59 +0000267 }
Evan Cheng9d5df0a2007-07-20 21:56:13 +0000268
Chris Lattnerd8312092005-07-11 05:17:48 +0000269 return false;
270}
Bill Wendling2aa9a422007-02-08 01:39:44 +0000271
Bruno Cardoso Lopesa194c3a2009-05-30 20:51:52 +0000272bool X86TargetMachine::addCodeEmitter(PassManagerBase &PM,
273 CodeGenOpt::Level OptLevel,
Bruno Cardoso Lopes9fd794b2009-06-01 19:57:37 +0000274 bool DumpAsm,
275 JITCodeEmitter &JCE) {
Bruno Cardoso Lopesa194c3a2009-05-30 20:51:52 +0000276 // FIXME: Move this to TargetJITInfo!
277 // On Darwin, do not override 64-bit setting made in X86TargetMachine().
278 if (DefRelocModel == Reloc::Default &&
Chris Lattner0b0c5cc2009-07-09 03:37:30 +0000279 (!Subtarget.isTargetDarwin() || !Subtarget.is64Bit())) {
Bruno Cardoso Lopesa194c3a2009-05-30 20:51:52 +0000280 setRelocationModel(Reloc::Static);
Chris Lattner0b0c5cc2009-07-09 03:37:30 +0000281 Subtarget.setPICStyle(PICStyles::None);
282 }
Bruno Cardoso Lopesa194c3a2009-05-30 20:51:52 +0000283
284 // 64-bit JIT places everything in the same buffer except external functions.
285 // On Darwin, use small code model but hack the call instruction for
286 // externals. Elsewhere, do not assume globals are in the lower 4G.
287 if (Subtarget.is64Bit()) {
288 if (Subtarget.isTargetDarwin())
289 setCodeModel(CodeModel::Small);
290 else
291 setCodeModel(CodeModel::Large);
292 }
293
294 PM.add(createX86JITCodeEmitterPass(*this, JCE));
295 if (DumpAsm) {
296 assert(AsmPrinterCtor && "AsmPrinter was not linked in");
297 if (AsmPrinterCtor)
Daniel Dunbar75c12e12009-07-01 01:48:54 +0000298 PM.add(AsmPrinterCtor(errs(), *this, true));
Bruno Cardoso Lopesa194c3a2009-05-30 20:51:52 +0000299 }
300
301 return false;
302}
303
Bruno Cardoso Lopes5661ea62009-07-06 05:09:34 +0000304bool X86TargetMachine::addCodeEmitter(PassManagerBase &PM,
305 CodeGenOpt::Level OptLevel,
306 bool DumpAsm,
307 ObjectCodeEmitter &OCE) {
308 // FIXME: Move this to TargetJITInfo!
309 // On Darwin, do not override 64-bit setting made in X86TargetMachine().
310 if (DefRelocModel == Reloc::Default &&
Chris Lattner0b0c5cc2009-07-09 03:37:30 +0000311 (!Subtarget.isTargetDarwin() || !Subtarget.is64Bit())) {
Bruno Cardoso Lopes5661ea62009-07-06 05:09:34 +0000312 setRelocationModel(Reloc::Static);
Chris Lattner0b0c5cc2009-07-09 03:37:30 +0000313 Subtarget.setPICStyle(PICStyles::None);
314 }
Bruno Cardoso Lopes5661ea62009-07-06 05:09:34 +0000315
316 // 64-bit JIT places everything in the same buffer except external functions.
317 // On Darwin, use small code model but hack the call instruction for
318 // externals. Elsewhere, do not assume globals are in the lower 4G.
319 if (Subtarget.is64Bit()) {
320 if (Subtarget.isTargetDarwin())
321 setCodeModel(CodeModel::Small);
322 else
323 setCodeModel(CodeModel::Large);
324 }
325
326 PM.add(createX86ObjectCodeEmitterPass(*this, OCE));
327 if (DumpAsm) {
328 assert(AsmPrinterCtor && "AsmPrinter was not linked in");
329 if (AsmPrinterCtor)
330 PM.add(AsmPrinterCtor(errs(), *this, true));
331 }
332
333 return false;
334}
335
Bill Wendling084669a2009-04-29 00:15:41 +0000336bool X86TargetMachine::addSimpleCodeEmitter(PassManagerBase &PM,
Bill Wendling026e5d72009-04-29 23:29:43 +0000337 CodeGenOpt::Level OptLevel,
338 bool DumpAsm,
Bill Wendling084669a2009-04-29 00:15:41 +0000339 MachineCodeEmitter &MCE) {
Bill Wendling2aa9a422007-02-08 01:39:44 +0000340 PM.add(createX86CodeEmitterPass(*this, MCE));
Anton Korobeynikovc5faeb82008-08-17 13:53:59 +0000341 if (DumpAsm) {
342 assert(AsmPrinterCtor && "AsmPrinter was not linked in");
343 if (AsmPrinterCtor)
Daniel Dunbar75c12e12009-07-01 01:48:54 +0000344 PM.add(AsmPrinterCtor(errs(), *this, true));
Anton Korobeynikovc5faeb82008-08-17 13:53:59 +0000345 }
346
Bill Wendling2aa9a422007-02-08 01:39:44 +0000347 return false;
348}
Dan Gohman007a6bb2008-09-26 19:15:30 +0000349
Bruno Cardoso Lopesa194c3a2009-05-30 20:51:52 +0000350bool X86TargetMachine::addSimpleCodeEmitter(PassManagerBase &PM,
351 CodeGenOpt::Level OptLevel,
352 bool DumpAsm,
353 JITCodeEmitter &JCE) {
354 PM.add(createX86JITCodeEmitterPass(*this, JCE));
355 if (DumpAsm) {
356 assert(AsmPrinterCtor && "AsmPrinter was not linked in");
357 if (AsmPrinterCtor)
Daniel Dunbar75c12e12009-07-01 01:48:54 +0000358 PM.add(AsmPrinterCtor(errs(), *this, true));
Bruno Cardoso Lopesa194c3a2009-05-30 20:51:52 +0000359 }
360
361 return false;
362}
363
Bruno Cardoso Lopes5661ea62009-07-06 05:09:34 +0000364bool X86TargetMachine::addSimpleCodeEmitter(PassManagerBase &PM,
365 CodeGenOpt::Level OptLevel,
366 bool DumpAsm,
367 ObjectCodeEmitter &OCE) {
368 PM.add(createX86ObjectCodeEmitterPass(*this, OCE));
369 if (DumpAsm) {
370 assert(AsmPrinterCtor && "AsmPrinter was not linked in");
371 if (AsmPrinterCtor)
372 PM.add(AsmPrinterCtor(errs(), *this, true));
373 }
374
375 return false;
376}