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 X86 machine code.
13 //===----------------------------------------------------------------------===//
15 #include "X86AsmPrinter.h"
16 #include "X86ATTInstPrinter.h"
17 #include "X86IntelInstPrinter.h"
18 #include "X86MCInstLower.h"
21 #include "X86COFFMachineModuleInfo.h"
22 #include "X86MachineFunctionInfo.h"
23 #include "X86TargetMachine.h"
24 #include "llvm/CallingConv.h"
25 #include "llvm/DerivedTypes.h"
26 #include "llvm/Module.h"
27 #include "llvm/Type.h"
28 #include "llvm/Assembly/Writer.h"
29 #include "llvm/MC/MCAsmInfo.h"
30 #include "llvm/MC/MCContext.h"
31 #include "llvm/MC/MCExpr.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/CodeGen/TargetLoweringObjectFileImpl.h"
38 #include "llvm/Support/ErrorHandling.h"
39 #include "llvm/Support/FormattedStream.h"
40 #include "llvm/Target/Mangler.h"
41 #include "llvm/Target/TargetOptions.h"
42 #include "llvm/Target/TargetRegistry.h"
43 #include "llvm/ADT/SmallString.h"
46 //===----------------------------------------------------------------------===//
47 // Primitive Helper Functions.
48 //===----------------------------------------------------------------------===//
50 void X86AsmPrinter::PrintPICBaseSymbol(raw_ostream &O) const {
51 const TargetLowering *TLI = TM.getTargetLowering();
52 O << *static_cast<const X86TargetLowering*>(TLI)->getPICBaseSymbol(MF,
56 /// runOnMachineFunction - Emit the function body.
58 bool X86AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
59 SetupMachineFunction(MF);
61 if (Subtarget->isTargetCOFF()) {
62 const Function *F = MF.getFunction();
63 OutStreamer.EmitRawText("\t.def\t " + Twine(CurrentFnSym->getName()) +
65 Twine(F->hasInternalLinkage() ? COFF::C_STAT : COFF::C_EXT) +
66 ";\t.type\t" + Twine(COFF::DT_FCN << COFF::N_BTSHFT)
70 // Have common code print out the function header with linkage info etc.
73 // Emit the rest of the function body.
76 // We didn't modify anything.
80 /// printSymbolOperand - Print a raw symbol reference operand. This handles
81 /// jump tables, constant pools, global address and external symbols, all of
82 /// which print to a label with various suffixes for relocation types etc.
83 void X86AsmPrinter::printSymbolOperand(const MachineOperand &MO,
85 switch (MO.getType()) {
86 default: llvm_unreachable("unknown symbol type!");
87 case MachineOperand::MO_JumpTableIndex:
88 O << *GetJTISymbol(MO.getIndex());
90 case MachineOperand::MO_ConstantPoolIndex:
91 O << *GetCPISymbol(MO.getIndex());
92 printOffset(MO.getOffset(), O);
94 case MachineOperand::MO_GlobalAddress: {
95 const GlobalValue *GV = MO.getGlobal();
98 if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB)
99 GVSym = GetSymbolWithGlobalValueBase(GV, "$stub");
100 else if (MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY ||
101 MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY_PIC_BASE ||
102 MO.getTargetFlags() == X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE)
103 GVSym = GetSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
105 GVSym = Mang->getSymbol(GV);
107 // Handle dllimport linkage.
108 if (MO.getTargetFlags() == X86II::MO_DLLIMPORT)
109 GVSym = OutContext.GetOrCreateSymbol(Twine("__imp_") + GVSym->getName());
111 if (MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY ||
112 MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY_PIC_BASE) {
113 MCSymbol *Sym = GetSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
114 MachineModuleInfoImpl::StubValueTy &StubSym =
115 MMI->getObjFileInfo<MachineModuleInfoMachO>().getGVStubEntry(Sym);
116 if (StubSym.getPointer() == 0)
117 StubSym = MachineModuleInfoImpl::
118 StubValueTy(Mang->getSymbol(GV), !GV->hasInternalLinkage());
119 } else if (MO.getTargetFlags() == X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE){
120 MCSymbol *Sym = GetSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
121 MachineModuleInfoImpl::StubValueTy &StubSym =
122 MMI->getObjFileInfo<MachineModuleInfoMachO>().getHiddenGVStubEntry(Sym);
123 if (StubSym.getPointer() == 0)
124 StubSym = MachineModuleInfoImpl::
125 StubValueTy(Mang->getSymbol(GV), !GV->hasInternalLinkage());
126 } else if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB) {
127 MCSymbol *Sym = GetSymbolWithGlobalValueBase(GV, "$stub");
128 MachineModuleInfoImpl::StubValueTy &StubSym =
129 MMI->getObjFileInfo<MachineModuleInfoMachO>().getFnStubEntry(Sym);
130 if (StubSym.getPointer() == 0)
131 StubSym = MachineModuleInfoImpl::
132 StubValueTy(Mang->getSymbol(GV), !GV->hasInternalLinkage());
135 // If the name begins with a dollar-sign, enclose it in parens. We do this
136 // to avoid having it look like an integer immediate to the assembler.
137 if (GVSym->getName()[0] != '$')
140 O << '(' << *GVSym << ')';
141 printOffset(MO.getOffset(), O);
144 case MachineOperand::MO_ExternalSymbol: {
145 const MCSymbol *SymToPrint;
146 if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB) {
147 SmallString<128> TempNameStr;
148 TempNameStr += StringRef(MO.getSymbolName());
149 TempNameStr += StringRef("$stub");
151 MCSymbol *Sym = GetExternalSymbolSymbol(TempNameStr.str());
152 MachineModuleInfoImpl::StubValueTy &StubSym =
153 MMI->getObjFileInfo<MachineModuleInfoMachO>().getFnStubEntry(Sym);
154 if (StubSym.getPointer() == 0) {
155 TempNameStr.erase(TempNameStr.end()-5, TempNameStr.end());
156 StubSym = MachineModuleInfoImpl::
157 StubValueTy(OutContext.GetOrCreateSymbol(TempNameStr.str()),
160 SymToPrint = StubSym.getPointer();
162 SymToPrint = GetExternalSymbolSymbol(MO.getSymbolName());
165 // If the name begins with a dollar-sign, enclose it in parens. We do this
166 // to avoid having it look like an integer immediate to the assembler.
167 if (SymToPrint->getName()[0] != '$')
170 O << '(' << *SymToPrint << '(';
175 switch (MO.getTargetFlags()) {
177 llvm_unreachable("Unknown target flag on GV operand");
178 case X86II::MO_NO_FLAG: // No flag.
180 case X86II::MO_DARWIN_NONLAZY:
181 case X86II::MO_DLLIMPORT:
182 case X86II::MO_DARWIN_STUB:
183 // These affect the name of the symbol, not any suffix.
185 case X86II::MO_GOT_ABSOLUTE_ADDRESS:
187 PrintPICBaseSymbol(O);
190 case X86II::MO_PIC_BASE_OFFSET:
191 case X86II::MO_DARWIN_NONLAZY_PIC_BASE:
192 case X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE:
194 PrintPICBaseSymbol(O);
196 case X86II::MO_TLSGD: O << "@TLSGD"; break;
197 case X86II::MO_GOTTPOFF: O << "@GOTTPOFF"; break;
198 case X86II::MO_INDNTPOFF: O << "@INDNTPOFF"; break;
199 case X86II::MO_TPOFF: O << "@TPOFF"; break;
200 case X86II::MO_NTPOFF: O << "@NTPOFF"; break;
201 case X86II::MO_GOTPCREL: O << "@GOTPCREL"; break;
202 case X86II::MO_GOT: O << "@GOT"; break;
203 case X86II::MO_GOTOFF: O << "@GOTOFF"; break;
204 case X86II::MO_PLT: O << "@PLT"; break;
208 /// print_pcrel_imm - This is used to print an immediate value that ends up
209 /// being encoded as a pc-relative value. These print slightly differently, for
210 /// example, a $ is not emitted.
211 void X86AsmPrinter::print_pcrel_imm(const MachineInstr *MI, unsigned OpNo,
213 const MachineOperand &MO = MI->getOperand(OpNo);
214 switch (MO.getType()) {
215 default: llvm_unreachable("Unknown pcrel immediate operand");
216 case MachineOperand::MO_Immediate:
219 case MachineOperand::MO_MachineBasicBlock:
220 O << *MO.getMBB()->getSymbol();
222 case MachineOperand::MO_GlobalAddress:
223 case MachineOperand::MO_ExternalSymbol:
224 printSymbolOperand(MO, O);
230 void X86AsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
231 raw_ostream &O, const char *Modifier) {
232 const MachineOperand &MO = MI->getOperand(OpNo);
233 switch (MO.getType()) {
234 default: llvm_unreachable("unknown operand type!");
235 case MachineOperand::MO_Register: {
237 unsigned Reg = MO.getReg();
238 if (Modifier && strncmp(Modifier, "subreg", strlen("subreg")) == 0) {
239 EVT VT = (strcmp(Modifier+6,"64") == 0) ?
240 MVT::i64 : ((strcmp(Modifier+6, "32") == 0) ? MVT::i32 :
241 ((strcmp(Modifier+6,"16") == 0) ? MVT::i16 : MVT::i8));
242 Reg = getX86SubSuperRegister(Reg, VT);
244 O << X86ATTInstPrinter::getRegisterName(Reg);
248 case MachineOperand::MO_Immediate:
249 O << '$' << MO.getImm();
252 case MachineOperand::MO_JumpTableIndex:
253 case MachineOperand::MO_ConstantPoolIndex:
254 case MachineOperand::MO_GlobalAddress:
255 case MachineOperand::MO_ExternalSymbol: {
257 printSymbolOperand(MO, O);
263 void X86AsmPrinter::printSSECC(const MachineInstr *MI, unsigned Op,
265 unsigned char value = MI->getOperand(Op).getImm();
266 assert(value <= 7 && "Invalid ssecc argument!");
268 case 0: O << "eq"; break;
269 case 1: O << "lt"; break;
270 case 2: O << "le"; break;
271 case 3: O << "unord"; break;
272 case 4: O << "neq"; break;
273 case 5: O << "nlt"; break;
274 case 6: O << "nle"; break;
275 case 7: O << "ord"; break;
279 void X86AsmPrinter::printLeaMemReference(const MachineInstr *MI, unsigned Op,
280 raw_ostream &O, const char *Modifier) {
281 const MachineOperand &BaseReg = MI->getOperand(Op);
282 const MachineOperand &IndexReg = MI->getOperand(Op+2);
283 const MachineOperand &DispSpec = MI->getOperand(Op+3);
285 // If we really don't want to print out (rip), don't.
286 bool HasBaseReg = BaseReg.getReg() != 0;
287 if (HasBaseReg && Modifier && !strcmp(Modifier, "no-rip") &&
288 BaseReg.getReg() == X86::RIP)
291 // HasParenPart - True if we will print out the () part of the mem ref.
292 bool HasParenPart = IndexReg.getReg() || HasBaseReg;
294 if (DispSpec.isImm()) {
295 int DispVal = DispSpec.getImm();
296 if (DispVal || !HasParenPart)
299 assert(DispSpec.isGlobal() || DispSpec.isCPI() ||
300 DispSpec.isJTI() || DispSpec.isSymbol());
301 printSymbolOperand(MI->getOperand(Op+3), O);
305 assert(IndexReg.getReg() != X86::ESP &&
306 "X86 doesn't allow scaling by ESP");
310 printOperand(MI, Op, O, Modifier);
312 if (IndexReg.getReg()) {
314 printOperand(MI, Op+2, O, Modifier);
315 unsigned ScaleVal = MI->getOperand(Op+1).getImm();
317 O << ',' << ScaleVal;
323 void X86AsmPrinter::printMemReference(const MachineInstr *MI, unsigned Op,
324 raw_ostream &O, const char *Modifier) {
325 assert(isMem(MI, Op) && "Invalid memory reference!");
326 const MachineOperand &Segment = MI->getOperand(Op+4);
327 if (Segment.getReg()) {
328 printOperand(MI, Op+4, O, Modifier);
331 printLeaMemReference(MI, Op, O, Modifier);
334 void X86AsmPrinter::printPICLabel(const MachineInstr *MI, unsigned Op,
336 PrintPICBaseSymbol(O);
338 PrintPICBaseSymbol(O);
342 bool X86AsmPrinter::printAsmMRegister(const MachineOperand &MO, char Mode,
344 unsigned Reg = MO.getReg();
346 default: return true; // Unknown mode.
347 case 'b': // Print QImode register
348 Reg = getX86SubSuperRegister(Reg, MVT::i8);
350 case 'h': // Print QImode high register
351 Reg = getX86SubSuperRegister(Reg, MVT::i8, true);
353 case 'w': // Print HImode register
354 Reg = getX86SubSuperRegister(Reg, MVT::i16);
356 case 'k': // Print SImode register
357 Reg = getX86SubSuperRegister(Reg, MVT::i32);
359 case 'q': // Print DImode register
360 Reg = getX86SubSuperRegister(Reg, MVT::i64);
364 O << '%' << X86ATTInstPrinter::getRegisterName(Reg);
368 /// PrintAsmOperand - Print out an operand for an inline asm expression.
370 bool X86AsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
372 const char *ExtraCode, raw_ostream &O) {
373 // Does this asm operand have a single letter operand modifier?
374 if (ExtraCode && ExtraCode[0]) {
375 if (ExtraCode[1] != 0) return true; // Unknown modifier.
377 const MachineOperand &MO = MI->getOperand(OpNo);
379 switch (ExtraCode[0]) {
380 default: return true; // Unknown modifier.
381 case 'a': // This is an address. Currently only 'i' and 'r' are expected.
386 if (MO.isGlobal() || MO.isCPI() || MO.isJTI() || MO.isSymbol()) {
387 printSymbolOperand(MO, O);
392 printOperand(MI, OpNo, O);
398 case 'c': // Don't print "$" before a global var name or constant.
401 else if (MO.isGlobal() || MO.isCPI() || MO.isJTI() || MO.isSymbol())
402 printSymbolOperand(MO, O);
404 printOperand(MI, OpNo, O);
407 case 'A': // Print '*' before a register (it must be a register)
410 printOperand(MI, OpNo, O);
415 case 'b': // Print QImode register
416 case 'h': // Print QImode high register
417 case 'w': // Print HImode register
418 case 'k': // Print SImode register
419 case 'q': // Print DImode register
421 return printAsmMRegister(MO, ExtraCode[0], O);
422 printOperand(MI, OpNo, O);
425 case 'P': // This is the operand of a call, treat specially.
426 print_pcrel_imm(MI, OpNo, O);
429 case 'n': // Negate the immediate or print a '-' before the operand.
430 // Note: this is a temporary solution. It should be handled target
431 // independently as part of the 'MC' work.
440 printOperand(MI, OpNo, O);
444 bool X86AsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI,
445 unsigned OpNo, unsigned AsmVariant,
446 const char *ExtraCode,
448 if (ExtraCode && ExtraCode[0]) {
449 if (ExtraCode[1] != 0) return true; // Unknown modifier.
451 switch (ExtraCode[0]) {
452 default: return true; // Unknown modifier.
453 case 'b': // Print QImode register
454 case 'h': // Print QImode high register
455 case 'w': // Print HImode register
456 case 'k': // Print SImode register
457 case 'q': // Print SImode register
458 // These only apply to registers, ignore on mem.
460 case 'P': // Don't print @PLT, but do print as memory.
461 printMemReference(MI, OpNo, O, "no-rip");
465 printMemReference(MI, OpNo, O);
469 void X86AsmPrinter::EmitStartOfAsmFile(Module &M) {
470 if (Subtarget->isTargetDarwin())
471 OutStreamer.SwitchSection(getObjFileLowering().getTextSection());
475 void X86AsmPrinter::EmitEndOfAsmFile(Module &M) {
476 if (Subtarget->isTargetDarwin()) {
477 // All darwin targets use mach-o.
478 TargetLoweringObjectFileMachO &TLOFMacho =
479 static_cast<TargetLoweringObjectFileMachO &>(getObjFileLowering());
481 MachineModuleInfoMachO &MMIMacho =
482 MMI->getObjFileInfo<MachineModuleInfoMachO>();
484 // Output stubs for dynamically-linked functions.
485 MachineModuleInfoMachO::SymbolListTy Stubs;
487 Stubs = MMIMacho.GetFnStubList();
488 if (!Stubs.empty()) {
489 const MCSection *TheSection =
490 TLOFMacho.getMachOSection("__IMPORT", "__jump_table",
491 MCSectionMachO::S_SYMBOL_STUBS |
492 MCSectionMachO::S_ATTR_SELF_MODIFYING_CODE |
493 MCSectionMachO::S_ATTR_PURE_INSTRUCTIONS,
494 5, SectionKind::getMetadata());
495 OutStreamer.SwitchSection(TheSection);
497 for (unsigned i = 0, e = Stubs.size(); i != e; ++i) {
499 OutStreamer.EmitLabel(Stubs[i].first);
500 // .indirect_symbol _foo
501 OutStreamer.EmitSymbolAttribute(Stubs[i].second.getPointer(),
502 MCSA_IndirectSymbol);
503 // hlt; hlt; hlt; hlt; hlt hlt = 0xf4 = -12.
504 const char HltInsts[] = { -12, -12, -12, -12, -12 };
505 OutStreamer.EmitBytes(StringRef(HltInsts, 5), 0/*addrspace*/);
509 OutStreamer.AddBlankLine();
512 // Output stubs for external and common global variables.
513 Stubs = MMIMacho.GetGVStubList();
514 if (!Stubs.empty()) {
515 const MCSection *TheSection =
516 TLOFMacho.getMachOSection("__IMPORT", "__pointers",
517 MCSectionMachO::S_NON_LAZY_SYMBOL_POINTERS,
518 SectionKind::getMetadata());
519 OutStreamer.SwitchSection(TheSection);
521 for (unsigned i = 0, e = Stubs.size(); i != e; ++i) {
522 // L_foo$non_lazy_ptr:
523 OutStreamer.EmitLabel(Stubs[i].first);
524 // .indirect_symbol _foo
525 MachineModuleInfoImpl::StubValueTy &MCSym = Stubs[i].second;
526 OutStreamer.EmitSymbolAttribute(MCSym.getPointer(),
527 MCSA_IndirectSymbol);
530 // External to current translation unit.
531 OutStreamer.EmitIntValue(0, 4/*size*/, 0/*addrspace*/);
533 // Internal to current translation unit.
535 // When we place the LSDA into the TEXT section, the type info
536 // pointers need to be indirect and pc-rel. We accomplish this by
537 // using NLPs. However, sometimes the types are local to the file. So
538 // we need to fill in the value for the NLP in those cases.
539 OutStreamer.EmitValue(MCSymbolRefExpr::Create(MCSym.getPointer(),
541 4/*size*/, 0/*addrspace*/);
544 OutStreamer.AddBlankLine();
547 Stubs = MMIMacho.GetHiddenGVStubList();
548 if (!Stubs.empty()) {
549 OutStreamer.SwitchSection(getObjFileLowering().getDataSection());
552 for (unsigned i = 0, e = Stubs.size(); i != e; ++i) {
553 // L_foo$non_lazy_ptr:
554 OutStreamer.EmitLabel(Stubs[i].first);
556 OutStreamer.EmitValue(MCSymbolRefExpr::
557 Create(Stubs[i].second.getPointer(),
559 4/*size*/, 0/*addrspace*/);
562 OutStreamer.AddBlankLine();
565 // Funny Darwin hack: This flag tells the linker that no global symbols
566 // contain code that falls through to other global symbols (e.g. the obvious
567 // implementation of multiple entry points). If this doesn't occur, the
568 // linker can safely perform dead code stripping. Since LLVM never
569 // generates code that does this, it is always safe to set.
570 OutStreamer.EmitAssemblerFlag(MCAF_SubsectionsViaSymbols);
573 if (Subtarget->isTargetCOFF()) {
574 X86COFFMachineModuleInfo &COFFMMI =
575 MMI->getObjFileInfo<X86COFFMachineModuleInfo>();
577 // Emit type information for external functions
578 for (X86COFFMachineModuleInfo::stub_iterator I = COFFMMI.stub_begin(),
579 E = COFFMMI.stub_end(); I != E; ++I) {
580 O << "\t.def\t " << I->getKeyData()
581 << ";\t.scl\t" << COFF::C_EXT
582 << ";\t.type\t" << (COFF::DT_FCN << COFF::N_BTSHFT)
586 if (Subtarget->isTargetCygMing()) {
587 // Necessary for dllexport support
588 std::vector<const MCSymbol*> DLLExportedFns, DLLExportedGlobals;
590 TargetLoweringObjectFileCOFF &TLOFCOFF =
591 static_cast<TargetLoweringObjectFileCOFF&>(getObjFileLowering());
593 for (Module::const_iterator I = M.begin(), E = M.end(); I != E; ++I)
594 if (I->hasDLLExportLinkage())
595 DLLExportedFns.push_back(Mang->getSymbol(I));
597 for (Module::const_global_iterator I = M.global_begin(),
598 E = M.global_end(); I != E; ++I)
599 if (I->hasDLLExportLinkage())
600 DLLExportedGlobals.push_back(Mang->getSymbol(I));
602 // Output linker support code for dllexported globals on windows.
603 if (!DLLExportedGlobals.empty() || !DLLExportedFns.empty()) {
604 OutStreamer.SwitchSection(TLOFCOFF.getCOFFSection(".section .drectve",
606 SectionKind::getMetadata()));
607 for (unsigned i = 0, e = DLLExportedGlobals.size(); i != e; ++i)
608 O << "\t.ascii \" -export:" << *DLLExportedGlobals[i] << ",data\"\n";
610 for (unsigned i = 0, e = DLLExportedFns.size(); i != e; ++i)
611 O << "\t.ascii \" -export:" << *DLLExportedFns[i] << "\"\n";
616 if (Subtarget->isTargetELF()) {
617 TargetLoweringObjectFileELF &TLOFELF =
618 static_cast<TargetLoweringObjectFileELF &>(getObjFileLowering());
620 MachineModuleInfoELF &MMIELF = MMI->getObjFileInfo<MachineModuleInfoELF>();
622 // Output stubs for external and common global variables.
623 MachineModuleInfoELF::SymbolListTy Stubs = MMIELF.GetGVStubList();
624 if (!Stubs.empty()) {
625 OutStreamer.SwitchSection(TLOFELF.getDataRelSection());
626 const TargetData *TD = TM.getTargetData();
628 for (unsigned i = 0, e = Stubs.size(); i != e; ++i)
629 O << *Stubs[i].first << ":\n"
630 << (TD->getPointerSize() == 8 ?
631 MAI->getData64bitsDirective() : MAI->getData32bitsDirective())
632 << *Stubs[i].second.getPointer() << '\n';
640 //===----------------------------------------------------------------------===//
641 // Target Registry Stuff
642 //===----------------------------------------------------------------------===//
644 static MCInstPrinter *createX86MCInstPrinter(const Target &T,
645 unsigned SyntaxVariant,
646 const MCAsmInfo &MAI) {
647 if (SyntaxVariant == 0)
648 return new X86ATTInstPrinter(MAI);
649 if (SyntaxVariant == 1)
650 return new X86IntelInstPrinter(MAI);
654 // Force static initialization.
655 extern "C" void LLVMInitializeX86AsmPrinter() {
656 RegisterAsmPrinter<X86AsmPrinter> X(TheX86_32Target);
657 RegisterAsmPrinter<X86AsmPrinter> Y(TheX86_64Target);
659 TargetRegistry::RegisterMCInstPrinter(TheX86_32Target,createX86MCInstPrinter);
660 TargetRegistry::RegisterMCInstPrinter(TheX86_64Target,createX86MCInstPrinter);