blob: 9f3f76956dd41e357a716ca3a075d5bcfa5a7af2 [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001//===-- X86AsmPrinter.cpp - Convert X86 LLVM IR to X86 assembly -----------===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner081ce942007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file the shared super class printer that converts from our internal
11// representation of machine-dependent LLVM code to Intel and AT&T format
12// assembly language.
13// This printer is the output mechanism used by `llc'.
14//
15//===----------------------------------------------------------------------===//
16
17#include "X86AsmPrinter.h"
18#include "X86ATTAsmPrinter.h"
19#include "X86COFF.h"
20#include "X86IntelAsmPrinter.h"
21#include "X86MachineFunctionInfo.h"
22#include "X86Subtarget.h"
23#include "llvm/ADT/StringExtras.h"
24#include "llvm/CallingConv.h"
25#include "llvm/Constants.h"
26#include "llvm/Module.h"
27#include "llvm/DerivedTypes.h"
Anton Korobeynikovab46ce62008-01-20 14:00:07 +000028#include "llvm/ParameterAttributes.h"
Dan Gohmanf17a25c2007-07-18 16:29:46 +000029#include "llvm/Type.h"
30#include "llvm/Assembly/Writer.h"
31#include "llvm/Support/Mangler.h"
32#include "llvm/Target/TargetAsmInfo.h"
33#include "llvm/Target/TargetOptions.h"
34using namespace llvm;
35
36static X86MachineFunctionInfo calculateFunctionInfo(const Function *F,
37 const TargetData *TD) {
38 X86MachineFunctionInfo Info;
39 uint64_t Size = 0;
40
41 switch (F->getCallingConv()) {
42 case CallingConv::X86_StdCall:
43 Info.setDecorationStyle(StdCall);
44 break;
45 case CallingConv::X86_FastCall:
46 Info.setDecorationStyle(FastCall);
47 break;
48 default:
49 return Info;
50 }
51
Anton Korobeynikovab46ce62008-01-20 14:00:07 +000052 unsigned argNum = 1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000053 for (Function::const_arg_iterator AI = F->arg_begin(), AE = F->arg_end();
Anton Korobeynikovab46ce62008-01-20 14:00:07 +000054 AI != AE; ++AI, ++argNum) {
55 const Type* Ty = AI->getType();
56
57 // 'Dereference' type in case of byval parameter attribute
58 if (F->paramHasAttr(argNum, ParamAttr::ByVal))
59 Ty = cast<PointerType>(Ty)->getElementType();
60
Dan Gohmanf17a25c2007-07-18 16:29:46 +000061 // Size should be aligned to DWORD boundary
Anton Korobeynikovab46ce62008-01-20 14:00:07 +000062 Size += ((TD->getABITypeSize(Ty) + 3)/4)*4;
63 }
64
Dan Gohmanf17a25c2007-07-18 16:29:46 +000065 // We're not supporting tooooo huge arguments :)
66 Info.setBytesToPopOnReturn((unsigned int)Size);
67 return Info;
68}
69
70
71/// decorateName - Query FunctionInfoMap and use this information for various
72/// name decoration.
73void X86SharedAsmPrinter::decorateName(std::string &Name,
74 const GlobalValue *GV) {
75 const Function *F = dyn_cast<Function>(GV);
76 if (!F) return;
77
78 // We don't want to decorate non-stdcall or non-fastcall functions right now
79 unsigned CC = F->getCallingConv();
80 if (CC != CallingConv::X86_StdCall && CC != CallingConv::X86_FastCall)
81 return;
82
83 // Decorate names only when we're targeting Cygwin/Mingw32 targets
84 if (!Subtarget->isTargetCygMing())
85 return;
86
87 FMFInfoMap::const_iterator info_item = FunctionInfoMap.find(F);
88
89 const X86MachineFunctionInfo *Info;
90 if (info_item == FunctionInfoMap.end()) {
91 // Calculate apropriate function info and populate map
92 FunctionInfoMap[F] = calculateFunctionInfo(F, TM.getTargetData());
93 Info = &FunctionInfoMap[F];
94 } else {
95 Info = &info_item->second;
96 }
97
98 const FunctionType *FT = F->getFunctionType();
99 switch (Info->getDecorationStyle()) {
100 case None:
101 break;
102 case StdCall:
103 // "Pure" variadic functions do not receive @0 suffix.
104 if (!FT->isVarArg() || (FT->getNumParams() == 0) ||
Devang Patel949a4b72008-03-03 21:46:28 +0000105 (FT->getNumParams() == 1 && F->hasStructRetAttr()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000106 Name += '@' + utostr_32(Info->getBytesToPopOnReturn());
107 break;
108 case FastCall:
109 // "Pure" variadic functions do not receive @0 suffix.
110 if (!FT->isVarArg() || (FT->getNumParams() == 0) ||
Devang Patel949a4b72008-03-03 21:46:28 +0000111 (FT->getNumParams() == 1 && F->hasStructRetAttr()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000112 Name += '@' + utostr_32(Info->getBytesToPopOnReturn());
113
114 if (Name[0] == '_') {
115 Name[0] = '@';
116 } else {
117 Name = '@' + Name;
118 }
119 break;
120 default:
121 assert(0 && "Unsupported DecorationStyle");
122 }
123}
124
125/// doInitialization
126bool X86SharedAsmPrinter::doInitialization(Module &M) {
127 if (TAI->doesSupportDebugInformation()) {
128 // Emit initial debug information.
129 DW.BeginModule(&M);
130 }
131
Dan Gohman4a558a32007-07-25 19:33:14 +0000132 bool Result = AsmPrinter::doInitialization(M);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000133
134 // Darwin wants symbols to be quoted if they have complex names.
135 if (Subtarget->isTargetDarwin())
136 Mang->setUseQuotes(true);
137
Dan Gohman4a558a32007-07-25 19:33:14 +0000138 return Result;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000139}
140
Chris Lattner2b638a72008-02-15 19:04:54 +0000141/// PrintUnmangledNameSafely - Print out the printable characters in the name.
Chris Lattner453b39b2008-02-15 18:56:05 +0000142/// Don't print things like \n or \0.
Chris Lattner2b638a72008-02-15 19:04:54 +0000143static void PrintUnmangledNameSafely(const Value *V, std::ostream &OS) {
Chris Lattner453b39b2008-02-15 18:56:05 +0000144 for (const char *Name = V->getNameStart(), *E = Name+V->getNameLen();
145 Name != E; ++Name)
146 if (isprint(*Name))
147 OS << *Name;
148}
149
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000150bool X86SharedAsmPrinter::doFinalization(Module &M) {
151 // Note: this code is not shared by the Intel printer as it is too different
152 // from how MASM does things. When making changes here don't forget to look
153 // at X86IntelAsmPrinter::doFinalization().
154 const TargetData *TD = TM.getTargetData();
155
156 // Print out module-level global variables here.
157 for (Module::const_global_iterator I = M.global_begin(), E = M.global_end();
158 I != E; ++I) {
159 if (!I->hasInitializer())
160 continue; // External global require no code
161
162 // Check to see if this is a special global used by LLVM, if so, emit it.
163 if (EmitSpecialLLVMGlobal(I)) {
164 if (Subtarget->isTargetDarwin() &&
165 TM.getRelocationModel() == Reloc::Static) {
166 if (I->getName() == "llvm.global_ctors")
167 O << ".reference .constructors_used\n";
168 else if (I->getName() == "llvm.global_dtors")
169 O << ".reference .destructors_used\n";
170 }
171 continue;
172 }
173
174 std::string name = Mang->getValueName(I);
175 Constant *C = I->getInitializer();
176 const Type *Type = C->getType();
Duncan Sands8157ef42007-11-05 00:04:43 +0000177 unsigned Size = TD->getABITypeSize(Type);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000178 unsigned Align = TD->getPreferredAlignmentLog(I);
179
180 if (I->hasHiddenVisibility()) {
181 if (const char *Directive = TAI->getHiddenDirective())
182 O << Directive << name << "\n";
183 } else if (I->hasProtectedVisibility()) {
184 if (const char *Directive = TAI->getProtectedDirective())
185 O << Directive << name << "\n";
186 }
187
188 if (Subtarget->isTargetELF())
Dan Gohman721e6582007-07-30 15:08:02 +0000189 O << "\t.type\t" << name << ",@object\n";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000190
Evan Cheng65c0fbc2007-09-21 00:41:19 +0000191 if (C->isNullValue() && !I->hasSection()) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000192 if (I->hasExternalLinkage()) {
193 if (const char *Directive = TAI->getZeroFillDirective()) {
Dale Johannesen3c788322008-01-11 00:54:37 +0000194 O << "\t.globl " << name << "\n";
Dale Johannesen576dc022008-02-12 23:35:09 +0000195 O << Directive << "__DATA, __common, " << name << ", "
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000196 << Size << ", " << Align << "\n";
197 continue;
198 }
199 }
200
Evan Cheng65c0fbc2007-09-21 00:41:19 +0000201 if (!I->isThreadLocal() &&
Dale Johannesen50085da2008-01-17 23:04:07 +0000202 (I->hasInternalLinkage() || I->hasWeakLinkage() ||
Dale Johannesen49c44122008-05-14 20:12:51 +0000203 I->hasLinkOnceLinkage() || I->hasCommonLinkage())) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000204 if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
205 if (!NoZerosInBSS && TAI->getBSSSection())
206 SwitchToDataSection(TAI->getBSSSection(), I);
207 else
208 SwitchToDataSection(TAI->getDataSection(), I);
209 if (TAI->getLCOMMDirective() != NULL) {
210 if (I->hasInternalLinkage()) {
211 O << TAI->getLCOMMDirective() << name << "," << Size;
212 if (Subtarget->isTargetDarwin())
213 O << "," << Align;
Dale Johannesen7406f3d2008-05-16 00:52:06 +0000214 } else if (Subtarget->isTargetDarwin() && !I->hasCommonLinkage()) {
215 O << "\t.globl " << name << "\n"
216 << TAI->getWeakDefDirective() << name << "\n";
217 SwitchToDataSection("\t.section __DATA,__datacoal_nt,coalesced", I);
218 EmitAlignment(Align, I);
219 O << name << ":\t\t\t\t" << TAI->getCommentString() << " ";
220 PrintUnmangledNameSafely(I, O);
221 O << "\n";
222 EmitGlobalConstant(C);
223 continue;
Chris Lattner93a2d432008-01-02 19:44:55 +0000224 } else {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000225 O << TAI->getCOMMDirective() << name << "," << Size;
Chris Lattner93a2d432008-01-02 19:44:55 +0000226
227 // Leopard and above support aligned common symbols.
228 if (Subtarget->getDarwinVers() >= 9)
229 O << "," << Align;
230 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000231 } else {
232 if (!Subtarget->isTargetCygMing()) {
233 if (I->hasInternalLinkage())
234 O << "\t.local\t" << name << "\n";
235 }
236 O << TAI->getCOMMDirective() << name << "," << Size;
237 if (TAI->getCOMMDirectiveTakesAlignment())
238 O << "," << (TAI->getAlignmentIsInBytes() ? (1 << Align) : Align);
239 }
Chris Lattner453b39b2008-02-15 18:56:05 +0000240 O << "\t\t" << TAI->getCommentString() << " ";
Chris Lattner2b638a72008-02-15 19:04:54 +0000241 PrintUnmangledNameSafely(I, O);
Chris Lattner453b39b2008-02-15 18:56:05 +0000242 O << "\n";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000243 continue;
244 }
245 }
246
247 switch (I->getLinkage()) {
Dale Johannesen49c44122008-05-14 20:12:51 +0000248 case GlobalValue::CommonLinkage:
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000249 case GlobalValue::LinkOnceLinkage:
250 case GlobalValue::WeakLinkage:
251 if (Subtarget->isTargetDarwin()) {
Dale Johannesen3c788322008-01-11 00:54:37 +0000252 O << "\t.globl " << name << "\n"
Dale Johannesenfb3ac732007-11-20 23:24:42 +0000253 << TAI->getWeakDefDirective() << name << "\n";
Dale Johannesen969d12f2008-05-23 00:16:59 +0000254 if (!I->isConstant())
255 SwitchToDataSection("\t.section __DATA,__datacoal_nt,coalesced", I);
256 else {
257 const ArrayType *AT = dyn_cast<ArrayType>(Type);
258 if (AT && AT->getElementType()==Type::Int8Ty)
259 SwitchToDataSection("\t.section __TEXT,__const_coal,coalesced", I);
260 else
261 SwitchToDataSection("\t.section __DATA,__const_coal,coalesced", I);
262 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000263 } else if (Subtarget->isTargetCygMing()) {
264 std::string SectionName(".section\t.data$linkonce." +
265 name +
266 ",\"aw\"");
267 SwitchToDataSection(SectionName.c_str(), I);
Dan Gohman52443a82007-10-05 15:58:41 +0000268 O << "\t.globl\t" << name << "\n"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000269 << "\t.linkonce same_size\n";
270 } else {
271 std::string SectionName("\t.section\t.llvm.linkonce.d." +
272 name +
273 ",\"aw\",@progbits");
274 SwitchToDataSection(SectionName.c_str(), I);
Dan Gohman721e6582007-07-30 15:08:02 +0000275 O << "\t.weak\t" << name << "\n";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000276 }
277 break;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000278 case GlobalValue::DLLExportLinkage:
279 DLLExportedGVs.insert(Mang->makeNameProper(I->getName(),""));
280 // FALL THROUGH
Chris Lattner2f8ba292007-08-13 18:42:37 +0000281 case GlobalValue::AppendingLinkage:
282 // FIXME: appending linkage variables should go into a section of
283 // their name or something. For now, just emit them as external.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000284 case GlobalValue::ExternalLinkage:
285 // If external or appending, declare as a global symbol
Dale Johannesen3c788322008-01-11 00:54:37 +0000286 O << "\t.globl " << name << "\n";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000287 // FALL THROUGH
288 case GlobalValue::InternalLinkage: {
289 if (I->isConstant()) {
290 const ConstantArray *CVA = dyn_cast<ConstantArray>(C);
291 if (TAI->getCStringSection() && CVA && CVA->isCString()) {
292 SwitchToDataSection(TAI->getCStringSection(), I);
293 break;
294 }
295 }
296 // FIXME: special handling for ".ctors" & ".dtors" sections
297 if (I->hasSection() &&
298 (I->getSection() == ".ctors" ||
299 I->getSection() == ".dtors")) {
300 std::string SectionName = ".section " + I->getSection();
301
302 if (Subtarget->isTargetCygMing()) {
303 SectionName += ",\"aw\"";
304 } else {
305 assert(!Subtarget->isTargetDarwin());
306 SectionName += ",\"aw\",@progbits";
307 }
Dale Johannesenae4f62f2008-01-23 00:58:14 +0000308 SwitchToDataSection(SectionName.c_str());
309 } else if (I->hasSection() && Subtarget->isTargetDarwin()) {
310 // Honor all section names on Darwin; ObjC uses this
311 std::string SectionName = ".section " + I->getSection();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000312 SwitchToDataSection(SectionName.c_str());
313 } else {
314 if (C->isNullValue() && !NoZerosInBSS && TAI->getBSSSection())
315 SwitchToDataSection(I->isThreadLocal() ? TAI->getTLSBSSSection() :
316 TAI->getBSSSection(), I);
317 else if (!I->isConstant())
318 SwitchToDataSection(I->isThreadLocal() ? TAI->getTLSDataSection() :
319 TAI->getDataSection(), I);
320 else if (I->isThreadLocal())
321 SwitchToDataSection(TAI->getTLSDataSection());
322 else {
323 // Read-only data.
324 bool HasReloc = C->ContainsRelocations();
325 if (HasReloc &&
326 Subtarget->isTargetDarwin() &&
327 TM.getRelocationModel() != Reloc::Static)
328 SwitchToDataSection("\t.const_data\n");
329 else if (!HasReloc && Size == 4 &&
330 TAI->getFourByteConstantSection())
331 SwitchToDataSection(TAI->getFourByteConstantSection(), I);
332 else if (!HasReloc && Size == 8 &&
333 TAI->getEightByteConstantSection())
334 SwitchToDataSection(TAI->getEightByteConstantSection(), I);
335 else if (!HasReloc && Size == 16 &&
336 TAI->getSixteenByteConstantSection())
337 SwitchToDataSection(TAI->getSixteenByteConstantSection(), I);
338 else if (TAI->getReadOnlySection())
339 SwitchToDataSection(TAI->getReadOnlySection(), I);
340 else
341 SwitchToDataSection(TAI->getDataSection(), I);
342 }
343 }
344
345 break;
346 }
347 default:
348 assert(0 && "Unknown linkage type!");
349 }
350
351 EmitAlignment(Align, I);
Chris Lattner453b39b2008-02-15 18:56:05 +0000352 O << name << ":\t\t\t\t" << TAI->getCommentString() << " ";
Chris Lattner2b638a72008-02-15 19:04:54 +0000353 PrintUnmangledNameSafely(I, O);
Chris Lattner453b39b2008-02-15 18:56:05 +0000354 O << "\n";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000355 if (TAI->hasDotTypeDotSizeDirective())
Dan Gohman721e6582007-07-30 15:08:02 +0000356 O << "\t.size\t" << name << ", " << Size << "\n";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000357 // If the initializer is a extern weak symbol, remember to emit the weak
358 // reference!
359 if (const GlobalValue *GV = dyn_cast<GlobalValue>(C))
360 if (GV->hasExternalWeakLinkage())
361 ExtWeakSymbols.insert(GV);
362
363 EmitGlobalConstant(C);
364 }
365
366 // Output linker support code for dllexported globals
Dan Gohman3f7d94b2007-10-03 19:26:29 +0000367 if (!DLLExportedGVs.empty()) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000368 SwitchToDataSection(".section .drectve");
369 }
370
371 for (std::set<std::string>::iterator i = DLLExportedGVs.begin(),
372 e = DLLExportedGVs.end();
373 i != e; ++i) {
374 O << "\t.ascii \" -export:" << *i << ",data\"\n";
375 }
376
Dan Gohman3f7d94b2007-10-03 19:26:29 +0000377 if (!DLLExportedFns.empty()) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000378 SwitchToDataSection(".section .drectve");
379 }
380
381 for (std::set<std::string>::iterator i = DLLExportedFns.begin(),
382 e = DLLExportedFns.end();
383 i != e; ++i) {
384 O << "\t.ascii \" -export:" << *i << "\"\n";
385 }
386
387 if (Subtarget->isTargetDarwin()) {
388 SwitchToDataSection("");
389
390 // Output stubs for dynamically-linked functions
391 unsigned j = 1;
392 for (std::set<std::string>::iterator i = FnStubs.begin(), e = FnStubs.end();
393 i != e; ++i, ++j) {
Dale Johannesen3c788322008-01-11 00:54:37 +0000394 SwitchToDataSection("\t.section __IMPORT,__jump_table,symbol_stubs,"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000395 "self_modifying_code+pure_instructions,5", 0);
Dale Johannesena21b5202008-05-19 21:38:18 +0000396 std::string p = *i;
397 printSuffixedName(p, "$stub");
398 O << ":\n";
399 O << "\t.indirect_symbol " << p << "\n";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000400 O << "\thlt ; hlt ; hlt ; hlt ; hlt\n";
401 }
402
403 O << "\n";
404
Dale Johannesen85535762008-04-02 00:25:04 +0000405 if (TAI->doesSupportExceptionHandling() && MMI && !Subtarget->is64Bit()) {
Bill Wendlingd1bda4f2007-09-11 08:27:17 +0000406 // Add the (possibly multiple) personalities to the set of global values.
Dale Johannesen85535762008-04-02 00:25:04 +0000407 // Only referenced functions get into the Personalities list.
Bill Wendlingd1bda4f2007-09-11 08:27:17 +0000408 const std::vector<Function *>& Personalities = MMI->getPersonalities();
409
410 for (std::vector<Function *>::const_iterator I = Personalities.begin(),
411 E = Personalities.end(); I != E; ++I)
412 if (*I) GVStubs.insert("_" + (*I)->getName());
413 }
414
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000415 // Output stubs for external and common global variables.
Dan Gohman3f7d94b2007-10-03 19:26:29 +0000416 if (!GVStubs.empty())
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000417 SwitchToDataSection(
Dale Johannesen3c788322008-01-11 00:54:37 +0000418 "\t.section __IMPORT,__pointers,non_lazy_symbol_pointers");
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000419 for (std::set<std::string>::iterator i = GVStubs.begin(), e = GVStubs.end();
420 i != e; ++i) {
Dale Johannesena21b5202008-05-19 21:38:18 +0000421 std::string p = *i;
422 printSuffixedName(p, "$non_lazy_ptr");
423 O << ":\n";
424 O << "\t.indirect_symbol " << p << "\n";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000425 O << "\t.long\t0\n";
426 }
427
428 // Emit final debug information.
429 DW.EndModule();
430
431 // Funny Darwin hack: This flag tells the linker that no global symbols
432 // contain code that falls through to other global symbols (e.g. the obvious
433 // implementation of multiple entry points). If this doesn't occur, the
434 // linker can safely perform dead code stripping. Since LLVM never
435 // generates code that does this, it is always safe to set.
436 O << "\t.subsections_via_symbols\n";
437 } else if (Subtarget->isTargetCygMing()) {
438 // Emit type information for external functions
439 for (std::set<std::string>::iterator i = FnStubs.begin(), e = FnStubs.end();
440 i != e; ++i) {
441 O << "\t.def\t " << *i
442 << ";\t.scl\t" << COFF::C_EXT
443 << ";\t.type\t" << (COFF::DT_FCN << COFF::N_BTSHFT)
444 << ";\t.endef\n";
445 }
446
447 // Emit final debug information.
448 DW.EndModule();
449 } else if (Subtarget->isTargetELF()) {
450 // Emit final debug information.
451 DW.EndModule();
452 }
453
Dan Gohman4a558a32007-07-25 19:33:14 +0000454 return AsmPrinter::doFinalization(M);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000455}
456
457/// createX86CodePrinterPass - Returns a pass that prints the X86 assembly code
458/// for a MachineFunction to the given output stream, using the given target
459/// machine description.
460///
461FunctionPass *llvm::createX86CodePrinterPass(std::ostream &o,
462 X86TargetMachine &tm) {
463 const X86Subtarget *Subtarget = &tm.getSubtarget<X86Subtarget>();
464
465 if (Subtarget->isFlavorIntel()) {
466 return new X86IntelAsmPrinter(o, tm, tm.getTargetAsmInfo());
467 } else {
468 return new X86ATTAsmPrinter(o, tm, tm.getTargetAsmInfo());
469 }
470}