blob: 92a98a065b4b25f1b3072d22b4b24dead1cfa23b [file] [log] [blame]
Chris Lattnerb4f68ed2002-10-29 22:37:54 +00001//===-- X86TargetMachine.cpp - Define TargetMachine for the X86 -----------===//
Misha Brukman0e0a7a452005-04-21 23:38:14 +00002//
John Criswellb576c942003-10-20 19:43:21 +00003// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-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 Brukman0e0a7a452005-04-21 23:38:14 +00007//
John Criswellb576c942003-10-20 19:43:21 +00008//===----------------------------------------------------------------------===//
Misha Brukman0e0a7a452005-04-21 23:38:14 +00009//
Chris Lattnerb4f68ed2002-10-29 22:37:54 +000010// This file defines the X86 specific subclass of TargetMachine.
11//
12//===----------------------------------------------------------------------===//
13
Jim Laskeyfde1b3b2006-09-07 23:39:26 +000014#include "X86TargetAsmInfo.h"
Chris Lattnerb4f68ed2002-10-29 22:37:54 +000015#include "X86TargetMachine.h"
Chris Lattner5bcd95c2002-12-24 00:04:01 +000016#include "X86.h"
Chris Lattnerbb144a82003-08-24 19:49:48 +000017#include "llvm/Module.h"
Chris Lattner155e68f2003-04-23 16:24:55 +000018#include "llvm/PassManager.h"
Chris Lattner3dffa792002-10-30 00:47:49 +000019#include "llvm/CodeGen/MachineFunction.h"
Chris Lattnerd91d86f2003-01-13 00:51:23 +000020#include "llvm/CodeGen/Passes.h"
Owen Andersoncb371882008-08-21 00:14:44 +000021#include "llvm/Support/raw_ostream.h"
Chris Lattner0cf0c372004-07-11 04:17:10 +000022#include "llvm/Target/TargetOptions.h"
Chris Lattnerd36c9702004-07-11 02:48:49 +000023#include "llvm/Target/TargetMachineRegistry.h"
Chris Lattner1e60a912003-12-20 01:22:19 +000024using namespace llvm;
Brian Gaeked0fde302003-11-11 22:41:34 +000025
Jeff Cohen1c32f792005-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 Gohman844731a2008-05-13 00:00:25 +000033// Register the target.
34static RegisterTarget<X86_32TargetMachine>
Dan Gohmanb8cab922008-10-14 20:25:08 +000035X("x86", "32-bit X86: Pentium-Pro and above");
Dan Gohman844731a2008-05-13 00:00:25 +000036static RegisterTarget<X86_64TargetMachine>
Dan Gohmanb8cab922008-10-14 20:25:08 +000037Y("x86-64", "64-bit X86: EM64T and AMD64");
Chris Lattner439a27a2002-12-16 16:15:51 +000038
Bob Wilsona96751f2009-06-23 23:59:40 +000039// Force static initialization.
40extern "C" void LLVMInitializeX86Target() { }
Douglas Gregor1555a232009-06-16 20:12:29 +000041
Anton Korobeynikov3c3bc482008-08-17 13:53:59 +000042// No assembler printer by default
43X86TargetMachine::AsmPrinterCtorFn X86TargetMachine::AsmPrinterCtor = 0;
44
Jim Laskeyfde1b3b2006-09-07 23:39:26 +000045const TargetAsmInfo *X86TargetMachine::createTargetAsmInfo() const {
Anton Korobeynikov4468b7a2008-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 Korobeynikov32b952a2008-09-25 21:00:33 +000060 return new X86GenericTargetAsmInfo(*this);
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000061 }
Jim Laskeyfde1b3b2006-09-07 23:39:26 +000062}
63
Evan Cheng25ab6902006-09-08 06:48:29 +000064unsigned X86_32TargetMachine::getJITMatchQuality() {
Chris Lattner7d0974b2004-10-18 15:54:17 +000065#if defined(i386) || defined(__i386__) || defined(__x86__) || defined(_M_IX86)
Chris Lattnerd36c9702004-07-11 02:48:49 +000066 return 10;
Chris Lattnerd36c9702004-07-11 02:48:49 +000067#endif
Evan Cheng25ab6902006-09-08 06:48:29 +000068 return 0;
Chris Lattnerd36c9702004-07-11 02:48:49 +000069}
70
Evan Cheng25ab6902006-09-08 06:48:29 +000071unsigned X86_64TargetMachine::getJITMatchQuality() {
Anton Korobeynikov8c278292008-03-23 13:43:47 +000072#if defined(__x86_64__) || defined(_M_AMD64)
Evan Cheng25ab6902006-09-08 06:48:29 +000073 return 10;
74#endif
75 return 0;
76}
77
78unsigned X86_32TargetMachine::getModuleMatchQuality(const Module &M) {
Chris Lattner3ea78c42004-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 Lattner87bdba62007-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 Lattner3ea78c42004-12-12 17:40:28 +000086
Chris Lattnerd36c9702004-07-11 02:48:49 +000087 if (M.getEndianness() == Module::LittleEndian &&
88 M.getPointerSize() == Module::Pointer32)
Chris Lattner3ea78c42004-12-12 17:40:28 +000089 return 10; // Weak match
Chris Lattnerd36c9702004-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 Lattnerb4f68ed2002-10-29 22:37:54 +000096
Evan Cheng25ab6902006-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 Lattner21847f42006-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 Lattner87bdba62007-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 Cheng25ab6902006-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 Lopes434dd4f2009-06-01 19:57:37 +0000122X86_32TargetMachine::X86_32TargetMachine(const Module &M, const std::string &FS)
Evan Cheng25ab6902006-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 Lattner11348ee2009-07-09 03:32:31 +0000131/// X86TargetMachine ctor - Create an X86 target.
Chris Lattnerb4f68ed2002-10-29 22:37:54 +0000132///
Evan Chengcdc69442007-02-23 03:03:16 +0000133X86TargetMachine::X86TargetMachine(const Module &M, const std::string &FS,
134 bool is64Bit)
Evan Cheng25ab6902006-09-08 06:48:29 +0000135 : Subtarget(M, FS, is64Bit),
Dale Johannesen27f92be2007-08-06 21:48:35 +0000136 DataLayout(Subtarget.getDataLayout()),
Nate Begemanfb5792f2005-07-12 01:41:54 +0000137 FrameInfo(TargetFrameInfo::StackGrowsDown,
Evan Cheng25ab6902006-09-08 06:48:29 +0000138 Subtarget.getStackAlignment(), Subtarget.is64Bit() ? -8 : -4),
Bruno Cardoso Lopesc997d452009-06-11 19:16:03 +0000139 InstrInfo(*this), JITInfo(*this), TLInfo(*this), ELFWriterInfo(*this) {
Evan Chengaabe38b2007-12-22 09:40:20 +0000140 DefRelocModel = getRelocationModel();
Chris Lattner11348ee2009-07-09 03:32:31 +0000141
142 // If no relocation model was picked, default as appropriate for the target.
Anton Korobeynikov7c1c2612008-02-20 11:22:39 +0000143 if (getRelocationModel() == Reloc::Default) {
Chris Lattner11348ee2009-07-09 03:32:31 +0000144 if (!Subtarget.isTargetDarwin())
Evan Cheng2c312ad2006-12-04 18:07:10 +0000145 setRelocationModel(Reloc::Static);
Chris Lattner11348ee2009-07-09 03:32:31 +0000146 else if (Subtarget.is64Bit())
147 setRelocationModel(Reloc::PIC_);
148 else
149 setRelocationModel(Reloc::DynamicNoPIC);
Anton Korobeynikov7c1c2612008-02-20 11:22:39 +0000150 }
Dan Gohman6520e202008-10-18 02:06:02 +0000151
Chris Lattnere4df7562009-07-09 03:15:51 +0000152 assert(getRelocationModel() != Reloc::Default &&
153 "Relocation mode not picked");
154
Chris Lattner11348ee2009-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 Lattnerb2fc55b2009-07-09 03:37:30 +0000159 // ELF and X86-64 don't have a distinct DynamicNoPIC model. DynamicNoPIC
Chris Lattner11348ee2009-07-09 03:32:31 +0000160 // is defined as a model for code which may be used in static or dynamic
Chris Lattner88e1fd52009-07-09 04:24:46 +0000161 // executables but not necessarily a shared library. On X86-32 we just
162 // compile in -static mode, in x86-64 we use PIC.
163 if (getRelocationModel() == Reloc::DynamicNoPIC) {
164 if (is64Bit)
165 setRelocationModel(Reloc::PIC_);
166 else if (!Subtarget.isTargetDarwin())
167 setRelocationModel(Reloc::Static);
168 }
Dan Gohman6520e202008-10-18 02:06:02 +0000169
Chris Lattnerb2fc55b2009-07-09 03:37:30 +0000170 // If we are on Darwin, disallow static relocation model in X86-64 mode, since
171 // the Mach-O file format doesn't support it.
172 if (getRelocationModel() == Reloc::Static &&
173 Subtarget.isTargetDarwin() &&
174 is64Bit)
175 setRelocationModel(Reloc::PIC_);
176
Chris Lattner11348ee2009-07-09 03:32:31 +0000177 // Determine the PICStyle based on the target selected.
178 if (getRelocationModel() == Reloc::Static) {
179 // Unless we're in PIC or DynamicNoPIC mode, set the PIC style to None.
180 Subtarget.setPICStyle(PICStyles::None);
181 } else if (Subtarget.isTargetCygMing()) {
Chris Lattnere4df7562009-07-09 03:15:51 +0000182 Subtarget.setPICStyle(PICStyles::None);
183 } else if (Subtarget.isTargetDarwin()) {
Evan Chengae19abc2007-01-18 22:27:12 +0000184 if (Subtarget.is64Bit())
Duncan Sandsf9a67a82008-11-28 09:29:37 +0000185 Subtarget.setPICStyle(PICStyles::RIPRel);
Chris Lattner8097b652009-07-10 20:58:47 +0000186 else if (getRelocationModel() == Reloc::PIC_)
187 Subtarget.setPICStyle(PICStyles::StubPIC);
188 else {
189 assert(getRelocationModel() == Reloc::DynamicNoPIC);
190 Subtarget.setPICStyle(PICStyles::StubDynamicNoPIC);
191 }
Anton Korobeynikov7c1c2612008-02-20 11:22:39 +0000192 } else if (Subtarget.isTargetELF()) {
Evan Chengae19abc2007-01-18 22:27:12 +0000193 if (Subtarget.is64Bit())
Duncan Sandsf9a67a82008-11-28 09:29:37 +0000194 Subtarget.setPICStyle(PICStyles::RIPRel);
Anton Korobeynikov7f705592007-01-12 19:20:47 +0000195 else
Duncan Sandsf9a67a82008-11-28 09:29:37 +0000196 Subtarget.setPICStyle(PICStyles::GOT);
Anton Korobeynikov7c1c2612008-02-20 11:22:39 +0000197 }
Chris Lattnere4df7562009-07-09 03:15:51 +0000198
Chris Lattner11348ee2009-07-09 03:32:31 +0000199 // Finally, if we have "none" as our PIC style, force to static mode.
200 if (Subtarget.getPICStyle() == PICStyles::None)
201 setRelocationModel(Reloc::Static);
Chris Lattner4efab052006-02-03 18:59:39 +0000202}
Chris Lattnerb4f68ed2002-10-29 22:37:54 +0000203
Chris Lattner1911fd42006-09-04 04:14:57 +0000204//===----------------------------------------------------------------------===//
205// Pass Pipeline Configuration
206//===----------------------------------------------------------------------===//
Chris Lattnerc9bbfbc2003-08-05 16:34:44 +0000207
Bill Wendling98a366d2009-04-29 23:29:43 +0000208bool X86TargetMachine::addInstSelector(PassManagerBase &PM,
209 CodeGenOpt::Level OptLevel) {
Nate Begeman73bfa712005-08-18 23:53:15 +0000210 // Install an instruction selector.
Bill Wendlingbe8cc2a2009-04-29 00:15:41 +0000211 PM.add(createX86ISelDag(*this, OptLevel));
Dan Gohman71b7f642008-10-25 17:46:52 +0000212
213 // If we're using Fast-ISel, clean up the mess.
214 if (EnableFastISel)
215 PM.add(createDeadMachineInstructionElimPass());
216
Dan Gohmanbc5cbb82008-11-12 22:55:05 +0000217 // Install a pass to insert x87 FP_REG_KILL instructions, as needed.
218 PM.add(createX87FPRegKillInserterPass());
219
Chris Lattner1911fd42006-09-04 04:14:57 +0000220 return false;
Brian Gaekede3aa4f2003-06-18 21:43:21 +0000221}
222
Bill Wendling98a366d2009-04-29 23:29:43 +0000223bool X86TargetMachine::addPreRegAlloc(PassManagerBase &PM,
224 CodeGenOpt::Level OptLevel) {
Anton Korobeynikovd52bdaf2008-04-23 18:23:30 +0000225 // Calculate and set max stack object alignment early, so we can decide
226 // whether we will need stack realignment (and thus FP).
Anton Korobeynikov856914f2008-04-23 18:23:05 +0000227 PM.add(createX86MaxStackAlignmentCalculatorPass());
228 return false; // -print-machineinstr shouldn't print after this.
229}
230
Bill Wendling98a366d2009-04-29 23:29:43 +0000231bool X86TargetMachine::addPostRegAlloc(PassManagerBase &PM,
232 CodeGenOpt::Level OptLevel) {
Chris Lattnerd91d86f2003-01-13 00:51:23 +0000233 PM.add(createX86FloatingPointStackifierPass());
Chris Lattner1911fd42006-09-04 04:14:57 +0000234 return true; // -print-machineinstr should print after this.
Chris Lattnerb4f68ed2002-10-29 22:37:54 +0000235}
236
Bill Wendlingbe8cc2a2009-04-29 00:15:41 +0000237bool X86TargetMachine::addAssemblyEmitter(PassManagerBase &PM,
Bill Wendling98a366d2009-04-29 23:29:43 +0000238 CodeGenOpt::Level OptLevel,
Bill Wendlingbe8cc2a2009-04-29 00:15:41 +0000239 bool Verbose,
240 raw_ostream &Out) {
Anton Korobeynikov3c3bc482008-08-17 13:53:59 +0000241 assert(AsmPrinterCtor && "AsmPrinter was not linked in");
242 if (AsmPrinterCtor)
Daniel Dunbar5bcc8bd2009-07-01 01:48:54 +0000243 PM.add(AsmPrinterCtor(Out, *this, Verbose));
Chris Lattner1911fd42006-09-04 04:14:57 +0000244 return false;
245}
246
Bill Wendling98a366d2009-04-29 23:29:43 +0000247bool X86TargetMachine::addCodeEmitter(PassManagerBase &PM,
248 CodeGenOpt::Level OptLevel,
Bruno Cardoso Lopes434dd4f2009-06-01 19:57:37 +0000249 bool DumpAsm,
250 MachineCodeEmitter &MCE) {
Chris Lattner2130b992006-09-04 18:48:41 +0000251 // FIXME: Move this to TargetJITInfo!
Dale Johannesen5f777192008-08-12 21:02:08 +0000252 // On Darwin, do not override 64-bit setting made in X86TargetMachine().
253 if (DefRelocModel == Reloc::Default &&
Chris Lattnerb2fc55b2009-07-09 03:37:30 +0000254 (!Subtarget.isTargetDarwin() || !Subtarget.is64Bit())) {
Evan Chengaabe38b2007-12-22 09:40:20 +0000255 setRelocationModel(Reloc::Static);
Chris Lattnerb2fc55b2009-07-09 03:37:30 +0000256 Subtarget.setPICStyle(PICStyles::None);
257 }
Anton Korobeynikov7f705592007-01-12 19:20:47 +0000258
Dale Johannesen50dd1d02008-08-11 23:46:25 +0000259 // 64-bit JIT places everything in the same buffer except external functions.
Dale Johannesen5f777192008-08-12 21:02:08 +0000260 // On Darwin, use small code model but hack the call instruction for
261 // externals. Elsewhere, do not assume globals are in the lower 4G.
262 if (Subtarget.is64Bit()) {
263 if (Subtarget.isTargetDarwin())
264 setCodeModel(CodeModel::Small);
265 else
266 setCodeModel(CodeModel::Large);
267 }
Anton Korobeynikov15fccf12006-12-20 01:03:20 +0000268
Evan Cheng55fc2802006-07-25 20:40:54 +0000269 PM.add(createX86CodeEmitterPass(*this, MCE));
Anton Korobeynikov3c3bc482008-08-17 13:53:59 +0000270 if (DumpAsm) {
271 assert(AsmPrinterCtor && "AsmPrinter was not linked in");
272 if (AsmPrinterCtor)
Daniel Dunbar5bcc8bd2009-07-01 01:48:54 +0000273 PM.add(AsmPrinterCtor(errs(), *this, true));
Anton Korobeynikov3c3bc482008-08-17 13:53:59 +0000274 }
Evan Cheng8bd60352007-07-20 21:56:13 +0000275
Chris Lattner81b6ed72005-07-11 05:17:48 +0000276 return false;
277}
Bill Wendlingeb1ac332007-02-08 01:39:44 +0000278
Bruno Cardoso Lopesa3f99f92009-05-30 20:51:52 +0000279bool X86TargetMachine::addCodeEmitter(PassManagerBase &PM,
280 CodeGenOpt::Level OptLevel,
Bruno Cardoso Lopes434dd4f2009-06-01 19:57:37 +0000281 bool DumpAsm,
282 JITCodeEmitter &JCE) {
Bruno Cardoso Lopesa3f99f92009-05-30 20:51:52 +0000283 // FIXME: Move this to TargetJITInfo!
284 // On Darwin, do not override 64-bit setting made in X86TargetMachine().
285 if (DefRelocModel == Reloc::Default &&
Chris Lattnerb2fc55b2009-07-09 03:37:30 +0000286 (!Subtarget.isTargetDarwin() || !Subtarget.is64Bit())) {
Bruno Cardoso Lopesa3f99f92009-05-30 20:51:52 +0000287 setRelocationModel(Reloc::Static);
Chris Lattnerb2fc55b2009-07-09 03:37:30 +0000288 Subtarget.setPICStyle(PICStyles::None);
289 }
Bruno Cardoso Lopesa3f99f92009-05-30 20:51:52 +0000290
291 // 64-bit JIT places everything in the same buffer except external functions.
292 // On Darwin, use small code model but hack the call instruction for
293 // externals. Elsewhere, do not assume globals are in the lower 4G.
294 if (Subtarget.is64Bit()) {
295 if (Subtarget.isTargetDarwin())
296 setCodeModel(CodeModel::Small);
297 else
298 setCodeModel(CodeModel::Large);
299 }
300
301 PM.add(createX86JITCodeEmitterPass(*this, JCE));
302 if (DumpAsm) {
303 assert(AsmPrinterCtor && "AsmPrinter was not linked in");
304 if (AsmPrinterCtor)
Daniel Dunbar5bcc8bd2009-07-01 01:48:54 +0000305 PM.add(AsmPrinterCtor(errs(), *this, true));
Bruno Cardoso Lopesa3f99f92009-05-30 20:51:52 +0000306 }
307
308 return false;
309}
310
Bruno Cardoso Lopesac57e6e2009-07-06 05:09:34 +0000311bool X86TargetMachine::addCodeEmitter(PassManagerBase &PM,
312 CodeGenOpt::Level OptLevel,
313 bool DumpAsm,
314 ObjectCodeEmitter &OCE) {
Bruno Cardoso Lopesac57e6e2009-07-06 05:09:34 +0000315 PM.add(createX86ObjectCodeEmitterPass(*this, OCE));
316 if (DumpAsm) {
317 assert(AsmPrinterCtor && "AsmPrinter was not linked in");
318 if (AsmPrinterCtor)
319 PM.add(AsmPrinterCtor(errs(), *this, true));
320 }
321
322 return false;
323}
324
Bill Wendlingbe8cc2a2009-04-29 00:15:41 +0000325bool X86TargetMachine::addSimpleCodeEmitter(PassManagerBase &PM,
Bill Wendling98a366d2009-04-29 23:29:43 +0000326 CodeGenOpt::Level OptLevel,
327 bool DumpAsm,
Bill Wendlingbe8cc2a2009-04-29 00:15:41 +0000328 MachineCodeEmitter &MCE) {
Bill Wendlingeb1ac332007-02-08 01:39:44 +0000329 PM.add(createX86CodeEmitterPass(*this, MCE));
Anton Korobeynikov3c3bc482008-08-17 13:53:59 +0000330 if (DumpAsm) {
331 assert(AsmPrinterCtor && "AsmPrinter was not linked in");
332 if (AsmPrinterCtor)
Daniel Dunbar5bcc8bd2009-07-01 01:48:54 +0000333 PM.add(AsmPrinterCtor(errs(), *this, true));
Anton Korobeynikov3c3bc482008-08-17 13:53:59 +0000334 }
335
Bill Wendlingeb1ac332007-02-08 01:39:44 +0000336 return false;
337}
Dan Gohman97135e12008-09-26 19:15:30 +0000338
Bruno Cardoso Lopesa3f99f92009-05-30 20:51:52 +0000339bool X86TargetMachine::addSimpleCodeEmitter(PassManagerBase &PM,
340 CodeGenOpt::Level OptLevel,
341 bool DumpAsm,
342 JITCodeEmitter &JCE) {
343 PM.add(createX86JITCodeEmitterPass(*this, JCE));
344 if (DumpAsm) {
345 assert(AsmPrinterCtor && "AsmPrinter was not linked in");
346 if (AsmPrinterCtor)
Daniel Dunbar5bcc8bd2009-07-01 01:48:54 +0000347 PM.add(AsmPrinterCtor(errs(), *this, true));
Bruno Cardoso Lopesa3f99f92009-05-30 20:51:52 +0000348 }
349
350 return false;
351}
352
Bruno Cardoso Lopesac57e6e2009-07-06 05:09:34 +0000353bool X86TargetMachine::addSimpleCodeEmitter(PassManagerBase &PM,
354 CodeGenOpt::Level OptLevel,
355 bool DumpAsm,
356 ObjectCodeEmitter &OCE) {
357 PM.add(createX86ObjectCodeEmitterPass(*this, OCE));
358 if (DumpAsm) {
359 assert(AsmPrinterCtor && "AsmPrinter was not linked in");
360 if (AsmPrinterCtor)
361 PM.add(AsmPrinterCtor(errs(), *this, true));
362 }
363
364 return false;
365}