1 //===-- X86AsmPrinter.cpp - Convert X86 LLVM code to AT&T assembly --------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains a printer that converts from our internal representation
11 // of machine-dependent LLVM code to AT&T format assembly
12 // language. This printer is the output mechanism used by `llc'.
14 //===----------------------------------------------------------------------===//
16 #define DEBUG_TYPE "asm-printer"
17 #include "X86AsmPrinter.h"
18 #include "X86ATTInstPrinter.h"
19 #include "X86IntelInstPrinter.h"
20 #include "X86MCInstLower.h"
23 #include "X86COFFMachineModuleInfo.h"
24 #include "X86MachineFunctionInfo.h"
25 #include "X86TargetMachine.h"
26 #include "llvm/CallingConv.h"
27 #include "llvm/DerivedTypes.h"
28 #include "llvm/Module.h"
29 #include "llvm/Type.h"
30 #include "llvm/Assembly/Writer.h"
31 #include "llvm/MC/MCContext.h"
32 #include "llvm/MC/MCSectionMachO.h"
33 #include "llvm/MC/MCStreamer.h"
34 #include "llvm/MC/MCSymbol.h"
35 #include "llvm/CodeGen/MachineJumpTableInfo.h"
36 #include "llvm/CodeGen/MachineModuleInfoImpls.h"
37 #include "llvm/Support/ErrorHandling.h"
38 #include "llvm/Support/FormattedStream.h"
39 #include "llvm/MC/MCAsmInfo.h"
40 #include "llvm/Target/TargetLoweringObjectFile.h"
41 #include "llvm/Target/TargetOptions.h"
42 #include "llvm/Target/TargetRegistry.h"
43 #include "llvm/ADT/SmallString.h"
44 #include "llvm/ADT/Statistic.h"
47 STATISTIC(EmittedInsts, "Number of machine instrs printed");
49 //===----------------------------------------------------------------------===//
50 // Primitive Helper Functions.
51 //===----------------------------------------------------------------------===//
53 void X86AsmPrinter::printMCInst(const MCInst *MI) {
54 if (MAI->getAssemblerDialect() == 0)
55 X86ATTInstPrinter(O, *MAI).printInstruction(MI);
57 X86IntelInstPrinter(O, *MAI).printInstruction(MI);
60 void X86AsmPrinter::PrintPICBaseSymbol() const {
61 const TargetLowering *TLI = TM.getTargetLowering();
62 O << *static_cast<const X86TargetLowering*>(TLI)->getPICBaseSymbol(MF,
66 /// runOnMachineFunction - This uses the printMachineInstruction()
67 /// method to print assembly for each instruction.
69 bool X86AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
70 SetupMachineFunction(MF);
73 // COFF and Cygwin specific mangling stuff. This should be moved out to the
74 // mangler or handled some other way?
75 if (Subtarget->isTargetCOFF()) {
76 X86COFFMachineModuleInfo &COFFMMI =
77 MMI->getObjFileInfo<X86COFFMachineModuleInfo>();
79 // Populate function information map. Don't want to populate
80 // non-stdcall or non-fastcall functions' information right now.
81 const Function *F = MF.getFunction();
82 CallingConv::ID CC = F->getCallingConv();
83 if (CC == CallingConv::X86_StdCall || CC == CallingConv::X86_FastCall)
84 COFFMMI.AddFunctionInfo(F, *MF.getInfo<X86MachineFunctionInfo>());
86 if (Subtarget->isTargetCygMing()) {
87 const Function *F = MF.getFunction();
88 X86COFFMachineModuleInfo &COFFMMI =
89 MMI->getObjFileInfo<X86COFFMachineModuleInfo>();
90 COFFMMI.DecorateCygMingName(CurrentFnSym, OutContext,F,*TM.getTargetData());
92 O << "\t.def\t " << *CurrentFnSym;
94 (F->hasInternalLinkage() ? COFF::C_STAT : COFF::C_EXT)
95 << ";\t.type\t" << (COFF::DT_FCN << COFF::N_BTSHFT)
99 // Have common code print out the function header with linkage info etc.
100 EmitFunctionHeader();
103 // Print out code for the function.
104 bool hasAnyRealCode = false;
105 for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
107 // Print a label for the basic block.
108 EmitBasicBlockStart(I);
109 for (MachineBasicBlock::const_iterator II = I->begin(), IE = I->end();
111 // Print the assembly for the instruction.
113 hasAnyRealCode = true;
114 printMachineInstruction(II);
118 if (Subtarget->isTargetDarwin() && !hasAnyRealCode) {
119 // If the function is empty, then we need to emit *something*. Otherwise,
120 // the function's label might be associated with something that it wasn't
121 // meant to be associated with. We emit a noop in this situation.
125 if (MAI->hasDotTypeDotSizeDirective())
126 O << "\t.size\t" << *CurrentFnSym << ", .-" << *CurrentFnSym << '\n';
128 // Emit post-function debug information.
129 if (MAI->doesSupportDebugInformation() || MAI->doesSupportExceptionHandling())
130 DW->EndFunction(&MF);
132 // Print out jump tables referenced by the function.
133 EmitJumpTableInfo(MF);
135 // We didn't modify anything.
139 /// printSymbolOperand - Print a raw symbol reference operand. This handles
140 /// jump tables, constant pools, global address and external symbols, all of
141 /// which print to a label with various suffixes for relocation types etc.
142 void X86AsmPrinter::printSymbolOperand(const MachineOperand &MO) {
143 switch (MO.getType()) {
144 default: llvm_unreachable("unknown symbol type!");
145 case MachineOperand::MO_JumpTableIndex:
146 O << *GetJTISymbol(MO.getIndex());
148 case MachineOperand::MO_ConstantPoolIndex:
149 O << *GetCPISymbol(MO.getIndex());
150 printOffset(MO.getOffset());
152 case MachineOperand::MO_GlobalAddress: {
153 const GlobalValue *GV = MO.getGlobal();
156 if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB)
157 GVSym = GetSymbolWithGlobalValueBase(GV, "$stub");
158 else if (MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY ||
159 MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY_PIC_BASE ||
160 MO.getTargetFlags() == X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE)
161 GVSym = GetSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
163 GVSym = GetGlobalValueSymbol(GV);
165 if (Subtarget->isTargetCygMing()) {
166 X86COFFMachineModuleInfo &COFFMMI =
167 MMI->getObjFileInfo<X86COFFMachineModuleInfo>();
168 COFFMMI.DecorateCygMingName(GVSym, OutContext, GV, *TM.getTargetData());
171 // Handle dllimport linkage.
172 if (MO.getTargetFlags() == X86II::MO_DLLIMPORT)
173 GVSym = OutContext.GetOrCreateSymbol(Twine("__imp_") + GVSym->getName());
175 if (MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY ||
176 MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY_PIC_BASE) {
177 MCSymbol *Sym = GetSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
179 const MCSymbol *&StubSym =
180 MMI->getObjFileInfo<MachineModuleInfoMachO>().getGVStubEntry(Sym);
182 StubSym = GetGlobalValueSymbol(GV);
184 } else if (MO.getTargetFlags() == X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE){
185 MCSymbol *Sym = GetSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
186 const MCSymbol *&StubSym =
187 MMI->getObjFileInfo<MachineModuleInfoMachO>().getHiddenGVStubEntry(Sym);
189 StubSym = GetGlobalValueSymbol(GV);
190 } else if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB) {
191 MCSymbol *Sym = GetSymbolWithGlobalValueBase(GV, "$stub");
192 const MCSymbol *&StubSym =
193 MMI->getObjFileInfo<MachineModuleInfoMachO>().getFnStubEntry(Sym);
195 StubSym = GetGlobalValueSymbol(GV);
198 // If the name begins with a dollar-sign, enclose it in parens. We do this
199 // to avoid having it look like an integer immediate to the assembler.
200 if (GVSym->getName()[0] != '$')
203 O << '(' << *GVSym << ')';
204 printOffset(MO.getOffset());
207 case MachineOperand::MO_ExternalSymbol: {
208 const MCSymbol *SymToPrint;
209 if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB) {
210 SmallString<128> TempNameStr;
211 TempNameStr += StringRef(MO.getSymbolName());
212 TempNameStr += StringRef("$stub");
214 const MCSymbol *Sym = GetExternalSymbolSymbol(TempNameStr.str());
215 const MCSymbol *&StubSym =
216 MMI->getObjFileInfo<MachineModuleInfoMachO>().getFnStubEntry(Sym);
218 TempNameStr.erase(TempNameStr.end()-5, TempNameStr.end());
219 StubSym = OutContext.GetOrCreateSymbol(TempNameStr.str());
221 SymToPrint = StubSym;
223 SymToPrint = GetExternalSymbolSymbol(MO.getSymbolName());
226 // If the name begins with a dollar-sign, enclose it in parens. We do this
227 // to avoid having it look like an integer immediate to the assembler.
228 if (SymToPrint->getName()[0] != '$')
231 O << '(' << *SymToPrint << '(';
236 switch (MO.getTargetFlags()) {
238 llvm_unreachable("Unknown target flag on GV operand");
239 case X86II::MO_NO_FLAG: // No flag.
241 case X86II::MO_DARWIN_NONLAZY:
242 case X86II::MO_DLLIMPORT:
243 case X86II::MO_DARWIN_STUB:
244 // These affect the name of the symbol, not any suffix.
246 case X86II::MO_GOT_ABSOLUTE_ADDRESS:
248 PrintPICBaseSymbol();
251 case X86II::MO_PIC_BASE_OFFSET:
252 case X86II::MO_DARWIN_NONLAZY_PIC_BASE:
253 case X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE:
255 PrintPICBaseSymbol();
257 case X86II::MO_TLSGD: O << "@TLSGD"; break;
258 case X86II::MO_GOTTPOFF: O << "@GOTTPOFF"; break;
259 case X86II::MO_INDNTPOFF: O << "@INDNTPOFF"; break;
260 case X86II::MO_TPOFF: O << "@TPOFF"; break;
261 case X86II::MO_NTPOFF: O << "@NTPOFF"; break;
262 case X86II::MO_GOTPCREL: O << "@GOTPCREL"; break;
263 case X86II::MO_GOT: O << "@GOT"; break;
264 case X86II::MO_GOTOFF: O << "@GOTOFF"; break;
265 case X86II::MO_PLT: O << "@PLT"; break;
269 /// print_pcrel_imm - This is used to print an immediate value that ends up
270 /// being encoded as a pc-relative value. These print slightly differently, for
271 /// example, a $ is not emitted.
272 void X86AsmPrinter::print_pcrel_imm(const MachineInstr *MI, unsigned OpNo) {
273 const MachineOperand &MO = MI->getOperand(OpNo);
274 switch (MO.getType()) {
275 default: llvm_unreachable("Unknown pcrel immediate operand");
276 case MachineOperand::MO_Immediate:
279 case MachineOperand::MO_MachineBasicBlock:
280 O << *MO.getMBB()->getSymbol(OutContext);
282 case MachineOperand::MO_GlobalAddress:
283 case MachineOperand::MO_ExternalSymbol:
284 printSymbolOperand(MO);
290 void X86AsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
291 const char *Modifier) {
292 const MachineOperand &MO = MI->getOperand(OpNo);
293 switch (MO.getType()) {
294 default: llvm_unreachable("unknown operand type!");
295 case MachineOperand::MO_Register: {
297 unsigned Reg = MO.getReg();
298 if (Modifier && strncmp(Modifier, "subreg", strlen("subreg")) == 0) {
299 EVT VT = (strcmp(Modifier+6,"64") == 0) ?
300 MVT::i64 : ((strcmp(Modifier+6, "32") == 0) ? MVT::i32 :
301 ((strcmp(Modifier+6,"16") == 0) ? MVT::i16 : MVT::i8));
302 Reg = getX86SubSuperRegister(Reg, VT);
304 O << X86ATTInstPrinter::getRegisterName(Reg);
308 case MachineOperand::MO_Immediate:
309 O << '$' << MO.getImm();
312 case MachineOperand::MO_JumpTableIndex:
313 case MachineOperand::MO_ConstantPoolIndex:
314 case MachineOperand::MO_GlobalAddress:
315 case MachineOperand::MO_ExternalSymbol: {
317 printSymbolOperand(MO);
323 void X86AsmPrinter::printSSECC(const MachineInstr *MI, unsigned Op) {
324 unsigned char value = MI->getOperand(Op).getImm();
325 assert(value <= 7 && "Invalid ssecc argument!");
327 case 0: O << "eq"; break;
328 case 1: O << "lt"; break;
329 case 2: O << "le"; break;
330 case 3: O << "unord"; break;
331 case 4: O << "neq"; break;
332 case 5: O << "nlt"; break;
333 case 6: O << "nle"; break;
334 case 7: O << "ord"; break;
338 void X86AsmPrinter::printLeaMemReference(const MachineInstr *MI, unsigned Op,
339 const char *Modifier) {
340 const MachineOperand &BaseReg = MI->getOperand(Op);
341 const MachineOperand &IndexReg = MI->getOperand(Op+2);
342 const MachineOperand &DispSpec = MI->getOperand(Op+3);
344 // If we really don't want to print out (rip), don't.
345 bool HasBaseReg = BaseReg.getReg() != 0;
346 if (HasBaseReg && Modifier && !strcmp(Modifier, "no-rip") &&
347 BaseReg.getReg() == X86::RIP)
350 // HasParenPart - True if we will print out the () part of the mem ref.
351 bool HasParenPart = IndexReg.getReg() || HasBaseReg;
353 if (DispSpec.isImm()) {
354 int DispVal = DispSpec.getImm();
355 if (DispVal || !HasParenPart)
358 assert(DispSpec.isGlobal() || DispSpec.isCPI() ||
359 DispSpec.isJTI() || DispSpec.isSymbol());
360 printSymbolOperand(MI->getOperand(Op+3));
364 assert(IndexReg.getReg() != X86::ESP &&
365 "X86 doesn't allow scaling by ESP");
369 printOperand(MI, Op, Modifier);
371 if (IndexReg.getReg()) {
373 printOperand(MI, Op+2, Modifier);
374 unsigned ScaleVal = MI->getOperand(Op+1).getImm();
376 O << ',' << ScaleVal;
382 void X86AsmPrinter::printMemReference(const MachineInstr *MI, unsigned Op,
383 const char *Modifier) {
384 assert(isMem(MI, Op) && "Invalid memory reference!");
385 const MachineOperand &Segment = MI->getOperand(Op+4);
386 if (Segment.getReg()) {
387 printOperand(MI, Op+4, Modifier);
390 printLeaMemReference(MI, Op, Modifier);
393 void X86AsmPrinter::printPICLabel(const MachineInstr *MI, unsigned Op) {
394 PrintPICBaseSymbol();
396 PrintPICBaseSymbol();
400 bool X86AsmPrinter::printAsmMRegister(const MachineOperand &MO, char Mode) {
401 unsigned Reg = MO.getReg();
403 default: return true; // Unknown mode.
404 case 'b': // Print QImode register
405 Reg = getX86SubSuperRegister(Reg, MVT::i8);
407 case 'h': // Print QImode high register
408 Reg = getX86SubSuperRegister(Reg, MVT::i8, true);
410 case 'w': // Print HImode register
411 Reg = getX86SubSuperRegister(Reg, MVT::i16);
413 case 'k': // Print SImode register
414 Reg = getX86SubSuperRegister(Reg, MVT::i32);
416 case 'q': // Print DImode register
417 Reg = getX86SubSuperRegister(Reg, MVT::i64);
421 O << '%' << X86ATTInstPrinter::getRegisterName(Reg);
425 /// PrintAsmOperand - Print out an operand for an inline asm expression.
427 bool X86AsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
429 const char *ExtraCode) {
430 // Does this asm operand have a single letter operand modifier?
431 if (ExtraCode && ExtraCode[0]) {
432 if (ExtraCode[1] != 0) return true; // Unknown modifier.
434 const MachineOperand &MO = MI->getOperand(OpNo);
436 switch (ExtraCode[0]) {
437 default: return true; // Unknown modifier.
438 case 'a': // This is an address. Currently only 'i' and 'r' are expected.
443 if (MO.isGlobal() || MO.isCPI() || MO.isJTI() || MO.isSymbol()) {
444 printSymbolOperand(MO);
449 printOperand(MI, OpNo);
455 case 'c': // Don't print "$" before a global var name or constant.
458 else if (MO.isGlobal() || MO.isCPI() || MO.isJTI() || MO.isSymbol())
459 printSymbolOperand(MO);
461 printOperand(MI, OpNo);
464 case 'A': // Print '*' before a register (it must be a register)
467 printOperand(MI, OpNo);
472 case 'b': // Print QImode register
473 case 'h': // Print QImode high register
474 case 'w': // Print HImode register
475 case 'k': // Print SImode register
476 case 'q': // Print DImode register
478 return printAsmMRegister(MO, ExtraCode[0]);
479 printOperand(MI, OpNo);
482 case 'P': // This is the operand of a call, treat specially.
483 print_pcrel_imm(MI, OpNo);
486 case 'n': // Negate the immediate or print a '-' before the operand.
487 // Note: this is a temporary solution. It should be handled target
488 // independently as part of the 'MC' work.
497 printOperand(MI, OpNo);
501 bool X86AsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI,
502 unsigned OpNo, unsigned AsmVariant,
503 const char *ExtraCode) {
504 if (ExtraCode && ExtraCode[0]) {
505 if (ExtraCode[1] != 0) return true; // Unknown modifier.
507 switch (ExtraCode[0]) {
508 default: return true; // Unknown modifier.
509 case 'b': // Print QImode register
510 case 'h': // Print QImode high register
511 case 'w': // Print HImode register
512 case 'k': // Print SImode register
513 case 'q': // Print SImode register
514 // These only apply to registers, ignore on mem.
516 case 'P': // Don't print @PLT, but do print as memory.
517 printMemReference(MI, OpNo, "no-rip");
521 printMemReference(MI, OpNo);
527 /// printMachineInstruction -- Print out a single X86 LLVM instruction MI in
528 /// AT&T syntax to the current output stream.
530 void X86AsmPrinter::printMachineInstruction(const MachineInstr *MI) {
533 processDebugLoc(MI, true);
535 printInstructionThroughMCStreamer(MI);
541 processDebugLoc(MI, false);
544 void X86AsmPrinter::EmitEndOfAsmFile(Module &M) {
545 if (Subtarget->isTargetDarwin()) {
546 // All darwin targets use mach-o.
547 TargetLoweringObjectFileMachO &TLOFMacho =
548 static_cast<TargetLoweringObjectFileMachO &>(getObjFileLowering());
550 MachineModuleInfoMachO &MMIMacho =
551 MMI->getObjFileInfo<MachineModuleInfoMachO>();
553 // Output stubs for dynamically-linked functions.
554 MachineModuleInfoMachO::SymbolListTy Stubs;
556 Stubs = MMIMacho.GetFnStubList();
557 if (!Stubs.empty()) {
558 const MCSection *TheSection =
559 TLOFMacho.getMachOSection("__IMPORT", "__jump_table",
560 MCSectionMachO::S_SYMBOL_STUBS |
561 MCSectionMachO::S_ATTR_SELF_MODIFYING_CODE |
562 MCSectionMachO::S_ATTR_PURE_INSTRUCTIONS,
563 5, SectionKind::getMetadata());
564 OutStreamer.SwitchSection(TheSection);
566 for (unsigned i = 0, e = Stubs.size(); i != e; ++i) {
567 O << *Stubs[i].first << ":\n";
568 // Get the MCSymbol without the $stub suffix.
569 O << "\t.indirect_symbol " << *Stubs[i].second;
570 O << "\n\thlt ; hlt ; hlt ; hlt ; hlt\n";
577 // Output stubs for external and common global variables.
578 Stubs = MMIMacho.GetGVStubList();
579 if (!Stubs.empty()) {
580 const MCSection *TheSection =
581 TLOFMacho.getMachOSection("__IMPORT", "__pointers",
582 MCSectionMachO::S_NON_LAZY_SYMBOL_POINTERS,
583 SectionKind::getMetadata());
584 OutStreamer.SwitchSection(TheSection);
586 for (unsigned i = 0, e = Stubs.size(); i != e; ++i) {
587 O << *Stubs[i].first << ":\n\t.indirect_symbol " << *Stubs[i].second;
588 O << "\n\t.long\t0\n";
593 Stubs = MMIMacho.GetHiddenGVStubList();
594 if (!Stubs.empty()) {
595 OutStreamer.SwitchSection(getObjFileLowering().getDataSection());
598 for (unsigned i = 0, e = Stubs.size(); i != e; ++i) {
599 O << *Stubs[i].first << ":\n" << MAI->getData32bitsDirective();
600 O << *Stubs[i].second << '\n';
605 // Funny Darwin hack: This flag tells the linker that no global symbols
606 // contain code that falls through to other global symbols (e.g. the obvious
607 // implementation of multiple entry points). If this doesn't occur, the
608 // linker can safely perform dead code stripping. Since LLVM never
609 // generates code that does this, it is always safe to set.
610 OutStreamer.EmitAssemblerFlag(MCAF_SubsectionsViaSymbols);
613 if (Subtarget->isTargetCOFF()) {
614 X86COFFMachineModuleInfo &COFFMMI =
615 MMI->getObjFileInfo<X86COFFMachineModuleInfo>();
617 // Emit type information for external functions
618 for (X86COFFMachineModuleInfo::stub_iterator I = COFFMMI.stub_begin(),
619 E = COFFMMI.stub_end(); I != E; ++I) {
620 O << "\t.def\t " << I->getKeyData()
621 << ";\t.scl\t" << COFF::C_EXT
622 << ";\t.type\t" << (COFF::DT_FCN << COFF::N_BTSHFT)
626 if (Subtarget->isTargetCygMing()) {
627 // Necessary for dllexport support
628 std::vector<const MCSymbol*> DLLExportedFns, DLLExportedGlobals;
630 TargetLoweringObjectFileCOFF &TLOFCOFF =
631 static_cast<TargetLoweringObjectFileCOFF&>(getObjFileLowering());
633 for (Module::const_iterator I = M.begin(), E = M.end(); I != E; ++I)
634 if (I->hasDLLExportLinkage()) {
635 MCSymbol *Sym = GetGlobalValueSymbol(I);
636 COFFMMI.DecorateCygMingName(Sym, OutContext, I, *TM.getTargetData());
637 DLLExportedFns.push_back(Sym);
640 for (Module::const_global_iterator I = M.global_begin(),
641 E = M.global_end(); I != E; ++I)
642 if (I->hasDLLExportLinkage())
643 DLLExportedGlobals.push_back(GetGlobalValueSymbol(I));
645 // Output linker support code for dllexported globals on windows.
646 if (!DLLExportedGlobals.empty() || !DLLExportedFns.empty()) {
647 OutStreamer.SwitchSection(TLOFCOFF.getCOFFSection(".section .drectve",
649 SectionKind::getMetadata()));
650 for (unsigned i = 0, e = DLLExportedGlobals.size(); i != e; ++i)
651 O << "\t.ascii \" -export:" << *DLLExportedGlobals[i] << ",data\"\n";
653 for (unsigned i = 0, e = DLLExportedFns.size(); i != e; ++i)
654 O << "\t.ascii \" -export:" << *DLLExportedFns[i] << "\"\n";
661 //===----------------------------------------------------------------------===//
662 // Target Registry Stuff
663 //===----------------------------------------------------------------------===//
665 static MCInstPrinter *createX86MCInstPrinter(const Target &T,
666 unsigned SyntaxVariant,
667 const MCAsmInfo &MAI,
669 if (SyntaxVariant == 0)
670 return new X86ATTInstPrinter(O, MAI);
671 if (SyntaxVariant == 1)
672 return new X86IntelInstPrinter(O, MAI);
676 // Force static initialization.
677 extern "C" void LLVMInitializeX86AsmPrinter() {
678 RegisterAsmPrinter<X86AsmPrinter> X(TheX86_32Target);
679 RegisterAsmPrinter<X86AsmPrinter> Y(TheX86_64Target);
681 TargetRegistry::RegisterMCInstPrinter(TheX86_32Target,createX86MCInstPrinter);
682 TargetRegistry::RegisterMCInstPrinter(TheX86_64Target,createX86MCInstPrinter);