blob: dbb7279a55356c6cd7c950c4dd70b7e5798aea75 [file] [log] [blame]
Chris Lattnerbf4b6a82009-09-20 07:41:30 +00001//===-- X86AsmPrinter.cpp - Convert X86 LLVM code to AT&T assembly --------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002//
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//
Chris Lattnerbf4b6a82009-09-20 07:41:30 +000010// 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'.
Dan Gohmanf17a25c2007-07-18 16:29:46 +000013//
14//===----------------------------------------------------------------------===//
15
Chris Lattnerbf4b6a82009-09-20 07:41:30 +000016#define DEBUG_TYPE "asm-printer"
17#include "X86AsmPrinter.h"
18#include "X86ATTInstPrinter.h"
19#include "X86IntelInstPrinter.h"
20#include "X86MCInstLower.h"
21#include "X86.h"
22#include "X86COFF.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"
Chris Lattnerbf4b6a82009-09-20 07:41:30 +000039#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"
45using namespace llvm;
46
47STATISTIC(EmittedInsts, "Number of machine instrs printed");
48
49//===----------------------------------------------------------------------===//
50// Primitive Helper Functions.
51//===----------------------------------------------------------------------===//
52
53void X86AsmPrinter::printMCInst(const MCInst *MI) {
54 if (MAI->getAssemblerDialect() == 0)
55 X86ATTInstPrinter(O, *MAI).printInstruction(MI);
56 else
57 X86IntelInstPrinter(O, *MAI).printInstruction(MI);
58}
59
60void X86AsmPrinter::PrintPICBaseSymbol() const {
61 // FIXME: Gross const cast hack.
62 X86AsmPrinter *AP = const_cast<X86AsmPrinter*>(this);
63 X86MCInstLower(OutContext, 0, *AP).GetPICBaseSymbol()->print(O, MAI);
64}
65
66void X86AsmPrinter::emitFunctionHeader(const MachineFunction &MF) {
67 unsigned FnAlign = MF.getAlignment();
68 const Function *F = MF.getFunction();
69
70 if (Subtarget->isTargetCygMing()) {
71 X86COFFMachineModuleInfo &COFFMMI =
72 MMI->getObjFileInfo<X86COFFMachineModuleInfo>();
Chris Lattnerc53c24c2010-01-16 00:51:39 +000073 COFFMMI.DecorateCygMingName(CurrentFnSym, OutContext, F,
74 *TM.getTargetData());
Chris Lattnerbf4b6a82009-09-20 07:41:30 +000075 }
76
77 OutStreamer.SwitchSection(getObjFileLowering().SectionForGlobal(F, Mang, TM));
78 EmitAlignment(FnAlign, F);
79
80 switch (F->getLinkage()) {
81 default: llvm_unreachable("Unknown linkage type!");
82 case Function::InternalLinkage: // Symbols default to internal.
83 case Function::PrivateLinkage:
84 break;
85 case Function::DLLExportLinkage:
86 case Function::ExternalLinkage:
Chris Lattner86ec9712010-01-16 00:32:38 +000087 O << "\t.globl\t";
88 CurrentFnSym->print(O, MAI);
89 O << '\n';
Chris Lattnerbf4b6a82009-09-20 07:41:30 +000090 break;
91 case Function::LinkerPrivateLinkage:
92 case Function::LinkOnceAnyLinkage:
93 case Function::LinkOnceODRLinkage:
94 case Function::WeakAnyLinkage:
95 case Function::WeakODRLinkage:
96 if (Subtarget->isTargetDarwin()) {
Chris Lattner86ec9712010-01-16 00:32:38 +000097 O << "\t.globl\t";
98 CurrentFnSym->print(O, MAI);
99 O << '\n';
100 O << MAI->getWeakDefDirective();
101 CurrentFnSym->print(O, MAI);
102 O << '\n';
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000103 } else if (Subtarget->isTargetCygMing()) {
Chris Lattner86ec9712010-01-16 00:32:38 +0000104 O << "\t.globl\t";
105 CurrentFnSym->print(O, MAI);
106 O << "\n\t.linkonce discard\n";
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000107 } else {
Chris Lattner86ec9712010-01-16 00:32:38 +0000108 O << "\t.weak\t";
109 CurrentFnSym->print(O, MAI);
110 O << '\n';
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000111 }
112 break;
113 }
114
Chris Lattner86ec9712010-01-16 00:32:38 +0000115 printVisibility(CurrentFnSym, F->getVisibility());
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000116
Chris Lattner86ec9712010-01-16 00:32:38 +0000117 if (Subtarget->isTargetELF()) {
118 O << "\t.type\t";
119 CurrentFnSym->print(O, MAI);
120 O << ",@function\n";
121 } else if (Subtarget->isTargetCygMing()) {
122 O << "\t.def\t ";
123 CurrentFnSym->print(O, MAI);
124 O << ";\t.scl\t" <<
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000125 (F->hasInternalLinkage() ? COFF::C_STAT : COFF::C_EXT)
126 << ";\t.type\t" << (COFF::DT_FCN << COFF::N_BTSHFT)
127 << ";\t.endef\n";
128 }
129
Chris Lattner86ec9712010-01-16 00:32:38 +0000130 CurrentFnSym->print(O, MAI);
131 O << ':';
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000132 if (VerboseAsm) {
133 O.PadToColumn(MAI->getCommentColumn());
134 O << MAI->getCommentString() << ' ';
135 WriteAsOperand(O, F, /*PrintType=*/false, F->getParent());
136 }
137 O << '\n';
138
139 // Add some workaround for linkonce linkage on Cygwin\MinGW
140 if (Subtarget->isTargetCygMing() &&
Chris Lattner86ec9712010-01-16 00:32:38 +0000141 (F->hasLinkOnceLinkage() || F->hasWeakLinkage())) {
142 O << "Lllvm$workaround$fake$stub$";
143 CurrentFnSym->print(O, MAI);
144 O << ":\n";
145 }
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000146}
147
148/// runOnMachineFunction - This uses the printMachineInstruction()
149/// method to print assembly for each instruction.
150///
151bool X86AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
152 const Function *F = MF.getFunction();
153 this->MF = &MF;
154 CallingConv::ID CC = F->getCallingConv();
155
156 SetupMachineFunction(MF);
157 O << "\n\n";
158
159 if (Subtarget->isTargetCOFF()) {
160 X86COFFMachineModuleInfo &COFFMMI =
161 MMI->getObjFileInfo<X86COFFMachineModuleInfo>();
162
163 // Populate function information map. Don't want to populate
164 // non-stdcall or non-fastcall functions' information right now.
165 if (CC == CallingConv::X86_StdCall || CC == CallingConv::X86_FastCall)
166 COFFMMI.AddFunctionInfo(F, *MF.getInfo<X86MachineFunctionInfo>());
167 }
168
169 // Print out constants referenced by the function
170 EmitConstantPool(MF.getConstantPool());
171
172 // Print the 'header' of function
173 emitFunctionHeader(MF);
174
175 // Emit pre-function debug and/or EH information.
176 if (MAI->doesSupportDebugInformation() || MAI->doesSupportExceptionHandling())
177 DW->BeginFunction(&MF);
178
179 // Print out code for the function.
180 bool hasAnyRealCode = false;
181 for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
182 I != E; ++I) {
183 // Print a label for the basic block.
Dan Gohman5fda4342009-10-06 17:38:38 +0000184 EmitBasicBlockStart(I);
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000185 for (MachineBasicBlock::const_iterator II = I->begin(), IE = I->end();
186 II != IE; ++II) {
187 // Print the assembly for the instruction.
188 if (!II->isLabel())
189 hasAnyRealCode = true;
190 printMachineInstruction(II);
191 }
192 }
193
194 if (Subtarget->isTargetDarwin() && !hasAnyRealCode) {
195 // If the function is empty, then we need to emit *something*. Otherwise,
196 // the function's label might be associated with something that it wasn't
197 // meant to be associated with. We emit a noop in this situation.
198 // We are assuming inline asms are code.
199 O << "\tnop\n";
200 }
201
Chris Lattner86ec9712010-01-16 00:32:38 +0000202 if (MAI->hasDotTypeDotSizeDirective()) {
203 O << "\t.size\t";
204 CurrentFnSym->print(O, MAI);
205 O << ", .-";
206 CurrentFnSym->print(O, MAI);
207 O << '\n';
208 }
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000209
210 // Emit post-function debug information.
211 if (MAI->doesSupportDebugInformation() || MAI->doesSupportExceptionHandling())
212 DW->EndFunction(&MF);
213
214 // Print out jump tables referenced by the function.
215 EmitJumpTableInfo(MF.getJumpTableInfo(), MF);
216
217 // We didn't modify anything.
218 return false;
219}
220
221/// printSymbolOperand - Print a raw symbol reference operand. This handles
222/// jump tables, constant pools, global address and external symbols, all of
223/// which print to a label with various suffixes for relocation types etc.
224void X86AsmPrinter::printSymbolOperand(const MachineOperand &MO) {
225 switch (MO.getType()) {
226 default: llvm_unreachable("unknown symbol type!");
227 case MachineOperand::MO_JumpTableIndex:
228 O << MAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber() << '_'
229 << MO.getIndex();
230 break;
231 case MachineOperand::MO_ConstantPoolIndex:
232 O << MAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << '_'
233 << MO.getIndex();
234 printOffset(MO.getOffset());
235 break;
236 case MachineOperand::MO_GlobalAddress: {
237 const GlobalValue *GV = MO.getGlobal();
238
Chris Lattnerc53c24c2010-01-16 00:51:39 +0000239 const MCSymbol *GVSym;
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000240 if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB)
Chris Lattnera6f2a102010-01-16 18:37:32 +0000241 GVSym = GetSymbolWithGlobalValueBase(GV, "$stub");
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000242 else if (MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY ||
243 MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY_PIC_BASE ||
244 MO.getTargetFlags() == X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE)
Chris Lattnera6f2a102010-01-16 18:37:32 +0000245 GVSym = GetSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
Chris Lattnerc53c24c2010-01-16 00:51:39 +0000246 else
247 GVSym = GetGlobalValueSymbol(GV);
248
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000249 if (Subtarget->isTargetCygMing()) {
Anton Korobeynikovd5fcb1d2009-10-15 22:36:18 +0000250 X86COFFMachineModuleInfo &COFFMMI =
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000251 MMI->getObjFileInfo<X86COFFMachineModuleInfo>();
Chris Lattnerc53c24c2010-01-16 00:51:39 +0000252 COFFMMI.DecorateCygMingName(GVSym, OutContext, GV, *TM.getTargetData());
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000253 }
254
255 // Handle dllimport linkage.
256 if (MO.getTargetFlags() == X86II::MO_DLLIMPORT)
Chris Lattnerc53c24c2010-01-16 00:51:39 +0000257 GVSym = OutContext.GetOrCreateSymbol(Twine("__imp_") + GVSym->getName());
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000258
259 if (MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY ||
260 MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY_PIC_BASE) {
Chris Lattnera6f2a102010-01-16 18:37:32 +0000261 MCSymbol *Sym = GetSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000262
263 const MCSymbol *&StubSym =
264 MMI->getObjFileInfo<MachineModuleInfoMachO>().getGVStubEntry(Sym);
Chris Lattner178a9322010-01-16 01:00:27 +0000265 if (StubSym == 0)
266 StubSym = GetGlobalValueSymbol(GV);
267
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000268 } else if (MO.getTargetFlags() == X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE){
Chris Lattnera6f2a102010-01-16 18:37:32 +0000269 MCSymbol *Sym = GetSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000270 const MCSymbol *&StubSym =
271 MMI->getObjFileInfo<MachineModuleInfoMachO>().getHiddenGVStubEntry(Sym);
Chris Lattner178a9322010-01-16 01:00:27 +0000272 if (StubSym == 0)
273 StubSym = GetGlobalValueSymbol(GV);
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000274 } else if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB) {
Chris Lattnera6f2a102010-01-16 18:37:32 +0000275 MCSymbol *Sym = GetSymbolWithGlobalValueBase(GV, "$stub");
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000276 const MCSymbol *&StubSym =
277 MMI->getObjFileInfo<MachineModuleInfoMachO>().getFnStubEntry(Sym);
Chris Lattner178a9322010-01-16 01:00:27 +0000278 if (StubSym == 0)
279 StubSym = GetGlobalValueSymbol(GV);
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000280 }
281
282 // If the name begins with a dollar-sign, enclose it in parens. We do this
283 // to avoid having it look like an integer immediate to the assembler.
Chris Lattnerc53c24c2010-01-16 00:51:39 +0000284 if (GVSym->getName()[0] != '$')
285 GVSym->print(O, MAI);
286 else {
287 O << '(';
288 GVSym->print(O, MAI);
289 O << ')';
290 }
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000291 printOffset(MO.getOffset());
292 break;
293 }
294 case MachineOperand::MO_ExternalSymbol: {
Chris Lattnerf80743e2010-01-13 07:56:59 +0000295 const MCSymbol *SymToPrint;
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000296 if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB) {
Chris Lattner178a9322010-01-16 01:00:27 +0000297 SmallString<128> TempNameStr;
298 TempNameStr += StringRef(MO.getSymbolName());
299 TempNameStr += StringRef("$stub");
300
301 const MCSymbol *Sym = GetExternalSymbolSymbol(TempNameStr.str());
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000302 const MCSymbol *&StubSym =
303 MMI->getObjFileInfo<MachineModuleInfoMachO>().getFnStubEntry(Sym);
304 if (StubSym == 0) {
Chris Lattnera38b2872010-01-13 06:38:18 +0000305 TempNameStr.erase(TempNameStr.end()-5, TempNameStr.end());
306 StubSym = OutContext.GetOrCreateSymbol(TempNameStr.str());
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000307 }
Chris Lattnerf80743e2010-01-13 07:56:59 +0000308 SymToPrint = StubSym;
309 } else {
Chris Lattner178a9322010-01-16 01:00:27 +0000310 SymToPrint = GetExternalSymbolSymbol(MO.getSymbolName());
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000311 }
312
313 // If the name begins with a dollar-sign, enclose it in parens. We do this
314 // to avoid having it look like an integer immediate to the assembler.
Chris Lattnerf80743e2010-01-13 07:56:59 +0000315 if (SymToPrint->getName()[0] != '$')
316 SymToPrint->print(O, MAI);
317 else {
318 O << '(';
319 SymToPrint->print(O, MAI);
320 O << '(';
321 }
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000322 break;
323 }
324 }
325
326 switch (MO.getTargetFlags()) {
327 default:
328 llvm_unreachable("Unknown target flag on GV operand");
329 case X86II::MO_NO_FLAG: // No flag.
330 break;
331 case X86II::MO_DARWIN_NONLAZY:
332 case X86II::MO_DLLIMPORT:
333 case X86II::MO_DARWIN_STUB:
334 // These affect the name of the symbol, not any suffix.
335 break;
336 case X86II::MO_GOT_ABSOLUTE_ADDRESS:
337 O << " + [.-";
338 PrintPICBaseSymbol();
339 O << ']';
340 break;
341 case X86II::MO_PIC_BASE_OFFSET:
342 case X86II::MO_DARWIN_NONLAZY_PIC_BASE:
343 case X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE:
344 O << '-';
345 PrintPICBaseSymbol();
346 break;
347 case X86II::MO_TLSGD: O << "@TLSGD"; break;
348 case X86II::MO_GOTTPOFF: O << "@GOTTPOFF"; break;
349 case X86II::MO_INDNTPOFF: O << "@INDNTPOFF"; break;
350 case X86II::MO_TPOFF: O << "@TPOFF"; break;
351 case X86II::MO_NTPOFF: O << "@NTPOFF"; break;
352 case X86II::MO_GOTPCREL: O << "@GOTPCREL"; break;
353 case X86II::MO_GOT: O << "@GOT"; break;
354 case X86II::MO_GOTOFF: O << "@GOTOFF"; break;
355 case X86II::MO_PLT: O << "@PLT"; break;
356 }
357}
358
359/// print_pcrel_imm - This is used to print an immediate value that ends up
360/// being encoded as a pc-relative value. These print slightly differently, for
361/// example, a $ is not emitted.
362void X86AsmPrinter::print_pcrel_imm(const MachineInstr *MI, unsigned OpNo) {
363 const MachineOperand &MO = MI->getOperand(OpNo);
364 switch (MO.getType()) {
365 default: llvm_unreachable("Unknown pcrel immediate operand");
366 case MachineOperand::MO_Immediate:
367 O << MO.getImm();
368 return;
369 case MachineOperand::MO_MachineBasicBlock:
370 GetMBBSymbol(MO.getMBB()->getNumber())->print(O, MAI);
371 return;
372 case MachineOperand::MO_GlobalAddress:
373 case MachineOperand::MO_ExternalSymbol:
374 printSymbolOperand(MO);
375 return;
376 }
377}
378
379
380void X86AsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
381 const char *Modifier) {
382 const MachineOperand &MO = MI->getOperand(OpNo);
383 switch (MO.getType()) {
384 default: llvm_unreachable("unknown operand type!");
385 case MachineOperand::MO_Register: {
386 O << '%';
387 unsigned Reg = MO.getReg();
388 if (Modifier && strncmp(Modifier, "subreg", strlen("subreg")) == 0) {
389 EVT VT = (strcmp(Modifier+6,"64") == 0) ?
390 MVT::i64 : ((strcmp(Modifier+6, "32") == 0) ? MVT::i32 :
391 ((strcmp(Modifier+6,"16") == 0) ? MVT::i16 : MVT::i8));
392 Reg = getX86SubSuperRegister(Reg, VT);
393 }
394 O << X86ATTInstPrinter::getRegisterName(Reg);
395 return;
396 }
397
398 case MachineOperand::MO_Immediate:
399 O << '$' << MO.getImm();
400 return;
401
402 case MachineOperand::MO_JumpTableIndex:
403 case MachineOperand::MO_ConstantPoolIndex:
404 case MachineOperand::MO_GlobalAddress:
405 case MachineOperand::MO_ExternalSymbol: {
406 O << '$';
407 printSymbolOperand(MO);
408 break;
409 }
410 }
411}
412
413void X86AsmPrinter::printSSECC(const MachineInstr *MI, unsigned Op) {
414 unsigned char value = MI->getOperand(Op).getImm();
415 assert(value <= 7 && "Invalid ssecc argument!");
416 switch (value) {
417 case 0: O << "eq"; break;
418 case 1: O << "lt"; break;
419 case 2: O << "le"; break;
420 case 3: O << "unord"; break;
421 case 4: O << "neq"; break;
422 case 5: O << "nlt"; break;
423 case 6: O << "nle"; break;
424 case 7: O << "ord"; break;
425 }
426}
427
428void X86AsmPrinter::printLeaMemReference(const MachineInstr *MI, unsigned Op,
429 const char *Modifier) {
430 const MachineOperand &BaseReg = MI->getOperand(Op);
431 const MachineOperand &IndexReg = MI->getOperand(Op+2);
432 const MachineOperand &DispSpec = MI->getOperand(Op+3);
433
434 // If we really don't want to print out (rip), don't.
435 bool HasBaseReg = BaseReg.getReg() != 0;
436 if (HasBaseReg && Modifier && !strcmp(Modifier, "no-rip") &&
437 BaseReg.getReg() == X86::RIP)
438 HasBaseReg = false;
439
440 // HasParenPart - True if we will print out the () part of the mem ref.
441 bool HasParenPart = IndexReg.getReg() || HasBaseReg;
442
443 if (DispSpec.isImm()) {
444 int DispVal = DispSpec.getImm();
445 if (DispVal || !HasParenPart)
446 O << DispVal;
447 } else {
448 assert(DispSpec.isGlobal() || DispSpec.isCPI() ||
449 DispSpec.isJTI() || DispSpec.isSymbol());
450 printSymbolOperand(MI->getOperand(Op+3));
451 }
452
453 if (HasParenPart) {
454 assert(IndexReg.getReg() != X86::ESP &&
455 "X86 doesn't allow scaling by ESP");
456
457 O << '(';
458 if (HasBaseReg)
459 printOperand(MI, Op, Modifier);
460
461 if (IndexReg.getReg()) {
462 O << ',';
463 printOperand(MI, Op+2, Modifier);
464 unsigned ScaleVal = MI->getOperand(Op+1).getImm();
465 if (ScaleVal != 1)
466 O << ',' << ScaleVal;
467 }
468 O << ')';
469 }
470}
471
472void X86AsmPrinter::printMemReference(const MachineInstr *MI, unsigned Op,
473 const char *Modifier) {
474 assert(isMem(MI, Op) && "Invalid memory reference!");
475 const MachineOperand &Segment = MI->getOperand(Op+4);
476 if (Segment.getReg()) {
477 printOperand(MI, Op+4, Modifier);
478 O << ':';
479 }
480 printLeaMemReference(MI, Op, Modifier);
481}
482
483void X86AsmPrinter::printPICJumpTableSetLabel(unsigned uid,
484 const MachineBasicBlock *MBB) const {
485 if (!MAI->getSetDirective())
486 return;
487
488 // We don't need .set machinery if we have GOT-style relocations
489 if (Subtarget->isPICStyleGOT())
490 return;
491
492 O << MAI->getSetDirective() << ' ' << MAI->getPrivateGlobalPrefix()
493 << getFunctionNumber() << '_' << uid << "_set_" << MBB->getNumber() << ',';
494
495 GetMBBSymbol(MBB->getNumber())->print(O, MAI);
496
497 if (Subtarget->isPICStyleRIPRel())
498 O << '-' << MAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
499 << '_' << uid << '\n';
500 else {
501 O << '-';
502 PrintPICBaseSymbol();
503 O << '\n';
504 }
505}
506
507
508void X86AsmPrinter::printPICLabel(const MachineInstr *MI, unsigned Op) {
509 PrintPICBaseSymbol();
510 O << '\n';
511 PrintPICBaseSymbol();
512 O << ':';
513}
514
515void X86AsmPrinter::printPICJumpTableEntry(const MachineJumpTableInfo *MJTI,
516 const MachineBasicBlock *MBB,
517 unsigned uid) const {
518 const char *JTEntryDirective = MJTI->getEntrySize() == 4 ?
519 MAI->getData32bitsDirective() : MAI->getData64bitsDirective();
520
521 O << JTEntryDirective << ' ';
522
523 if (Subtarget->isPICStyleRIPRel() || Subtarget->isPICStyleStubPIC()) {
524 O << MAI->getPrivateGlobalPrefix() << getFunctionNumber()
525 << '_' << uid << "_set_" << MBB->getNumber();
526 } else if (Subtarget->isPICStyleGOT()) {
527 GetMBBSymbol(MBB->getNumber())->print(O, MAI);
528 O << "@GOTOFF";
529 } else
530 GetMBBSymbol(MBB->getNumber())->print(O, MAI);
531}
532
533bool X86AsmPrinter::printAsmMRegister(const MachineOperand &MO, char Mode) {
534 unsigned Reg = MO.getReg();
535 switch (Mode) {
536 default: return true; // Unknown mode.
537 case 'b': // Print QImode register
538 Reg = getX86SubSuperRegister(Reg, MVT::i8);
539 break;
540 case 'h': // Print QImode high register
541 Reg = getX86SubSuperRegister(Reg, MVT::i8, true);
542 break;
543 case 'w': // Print HImode register
544 Reg = getX86SubSuperRegister(Reg, MVT::i16);
545 break;
546 case 'k': // Print SImode register
547 Reg = getX86SubSuperRegister(Reg, MVT::i32);
548 break;
549 case 'q': // Print DImode register
550 Reg = getX86SubSuperRegister(Reg, MVT::i64);
551 break;
552 }
553
554 O << '%' << X86ATTInstPrinter::getRegisterName(Reg);
555 return false;
556}
557
558/// PrintAsmOperand - Print out an operand for an inline asm expression.
559///
560bool X86AsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
561 unsigned AsmVariant,
562 const char *ExtraCode) {
563 // Does this asm operand have a single letter operand modifier?
564 if (ExtraCode && ExtraCode[0]) {
565 if (ExtraCode[1] != 0) return true; // Unknown modifier.
566
567 const MachineOperand &MO = MI->getOperand(OpNo);
568
569 switch (ExtraCode[0]) {
570 default: return true; // Unknown modifier.
571 case 'a': // This is an address. Currently only 'i' and 'r' are expected.
572 if (MO.isImm()) {
573 O << MO.getImm();
574 return false;
575 }
576 if (MO.isGlobal() || MO.isCPI() || MO.isJTI() || MO.isSymbol()) {
577 printSymbolOperand(MO);
578 return false;
579 }
580 if (MO.isReg()) {
581 O << '(';
582 printOperand(MI, OpNo);
583 O << ')';
584 return false;
585 }
586 return true;
587
588 case 'c': // Don't print "$" before a global var name or constant.
589 if (MO.isImm())
590 O << MO.getImm();
591 else if (MO.isGlobal() || MO.isCPI() || MO.isJTI() || MO.isSymbol())
592 printSymbolOperand(MO);
593 else
594 printOperand(MI, OpNo);
595 return false;
596
597 case 'A': // Print '*' before a register (it must be a register)
598 if (MO.isReg()) {
599 O << '*';
600 printOperand(MI, OpNo);
601 return false;
602 }
603 return true;
604
605 case 'b': // Print QImode register
606 case 'h': // Print QImode high register
607 case 'w': // Print HImode register
608 case 'k': // Print SImode register
609 case 'q': // Print DImode register
610 if (MO.isReg())
611 return printAsmMRegister(MO, ExtraCode[0]);
612 printOperand(MI, OpNo);
613 return false;
614
615 case 'P': // This is the operand of a call, treat specially.
616 print_pcrel_imm(MI, OpNo);
617 return false;
618
619 case 'n': // Negate the immediate or print a '-' before the operand.
620 // Note: this is a temporary solution. It should be handled target
621 // independently as part of the 'MC' work.
622 if (MO.isImm()) {
623 O << -MO.getImm();
624 return false;
625 }
626 O << '-';
627 }
628 }
629
630 printOperand(MI, OpNo);
631 return false;
632}
633
634bool X86AsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI,
635 unsigned OpNo, unsigned AsmVariant,
636 const char *ExtraCode) {
637 if (ExtraCode && ExtraCode[0]) {
638 if (ExtraCode[1] != 0) return true; // Unknown modifier.
639
640 switch (ExtraCode[0]) {
641 default: return true; // Unknown modifier.
642 case 'b': // Print QImode register
643 case 'h': // Print QImode high register
644 case 'w': // Print HImode register
645 case 'k': // Print SImode register
646 case 'q': // Print SImode register
647 // These only apply to registers, ignore on mem.
648 break;
649 case 'P': // Don't print @PLT, but do print as memory.
650 printMemReference(MI, OpNo, "no-rip");
651 return false;
652 }
653 }
654 printMemReference(MI, OpNo);
655 return false;
656}
657
658
659
660/// printMachineInstruction -- Print out a single X86 LLVM instruction MI in
661/// AT&T syntax to the current output stream.
662///
663void X86AsmPrinter::printMachineInstruction(const MachineInstr *MI) {
664 ++EmittedInsts;
665
Devang Patel5450fc12009-10-06 02:19:11 +0000666 processDebugLoc(MI, true);
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000667
668 printInstructionThroughMCStreamer(MI);
669
David Greeneca9b04b2009-11-13 21:34:57 +0000670 if (VerboseAsm)
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000671 EmitComments(*MI);
672 O << '\n';
Devang Patel5450fc12009-10-06 02:19:11 +0000673
674 processDebugLoc(MI, false);
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000675}
676
677void X86AsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
678 if (!GVar->hasInitializer())
679 return; // External global require no code
680
681 // Check to see if this is a special global used by LLVM, if so, emit it.
682 if (EmitSpecialLLVMGlobal(GVar)) {
683 if (Subtarget->isTargetDarwin() &&
684 TM.getRelocationModel() == Reloc::Static) {
685 if (GVar->getName() == "llvm.global_ctors")
686 O << ".reference .constructors_used\n";
687 else if (GVar->getName() == "llvm.global_dtors")
688 O << ".reference .destructors_used\n";
689 }
690 return;
691 }
692
693 const TargetData *TD = TM.getTargetData();
694
Chris Lattner178a9322010-01-16 01:00:27 +0000695 MCSymbol *GVSym = GetGlobalValueSymbol(GVar);
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000696 Constant *C = GVar->getInitializer();
697 const Type *Type = C->getType();
698 unsigned Size = TD->getTypeAllocSize(Type);
699 unsigned Align = TD->getPreferredAlignmentLog(GVar);
700
Chris Lattner178a9322010-01-16 01:00:27 +0000701 printVisibility(GVSym, GVar->getVisibility());
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000702
Chris Lattner178a9322010-01-16 01:00:27 +0000703 if (Subtarget->isTargetELF()) {
704 O << "\t.type\t";
705 GVSym->print(O, MAI);
706 O << ",@object\n";
707 }
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000708
709
710 SectionKind GVKind = TargetLoweringObjectFile::getKindForGlobal(GVar, TM);
711 const MCSection *TheSection =
712 getObjFileLowering().SectionForGlobal(GVar, GVKind, Mang, TM);
713 OutStreamer.SwitchSection(TheSection);
714
715 // FIXME: get this stuff from section kind flags.
716 if (C->isNullValue() && !GVar->hasSection() &&
717 // Don't put things that should go in the cstring section into "comm".
718 !TheSection->getKind().isMergeableCString()) {
719 if (GVar->hasExternalLinkage()) {
720 if (const char *Directive = MAI->getZeroFillDirective()) {
Chris Lattner178a9322010-01-16 01:00:27 +0000721 O << "\t.globl ";
722 GVSym->print(O, MAI);
723 O << '\n';
724 O << Directive << "__DATA, __common, ";
725 GVSym->print(O, MAI);
726 O << ", " << Size << ", " << Align << '\n';
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000727 return;
728 }
729 }
730
731 if (!GVar->isThreadLocal() &&
732 (GVar->hasLocalLinkage() || GVar->isWeakForLinker())) {
733 if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
734
735 if (MAI->getLCOMMDirective() != NULL) {
736 if (GVar->hasLocalLinkage()) {
Chris Lattner178a9322010-01-16 01:00:27 +0000737 O << MAI->getLCOMMDirective();
738 GVSym->print(O, MAI);
739 O << ',' << Size;
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000740 if (Subtarget->isTargetDarwin())
741 O << ',' << Align;
742 } else if (Subtarget->isTargetDarwin() && !GVar->hasCommonLinkage()) {
Chris Lattner178a9322010-01-16 01:00:27 +0000743 O << "\t.globl ";
744 GVSym->print(O, MAI);
745 O << '\n' << MAI->getWeakDefDirective();
746 GVSym->print(O, MAI);
747 O << '\n';
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000748 EmitAlignment(Align, GVar);
Chris Lattner178a9322010-01-16 01:00:27 +0000749 GVSym->print(O, MAI);
750 O << ":";
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000751 if (VerboseAsm) {
752 O.PadToColumn(MAI->getCommentColumn());
753 O << MAI->getCommentString() << ' ';
754 WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
755 }
756 O << '\n';
757 EmitGlobalConstant(C);
758 return;
759 } else {
Chris Lattner178a9322010-01-16 01:00:27 +0000760 O << MAI->getCOMMDirective();
761 GVSym->print(O, MAI);
762 O << ',' << Size;
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000763 if (MAI->getCOMMDirectiveTakesAlignment())
764 O << ',' << (MAI->getAlignmentIsInBytes() ? (1 << Align) : Align);
765 }
766 } else {
767 if (!Subtarget->isTargetCygMing()) {
Chris Lattner178a9322010-01-16 01:00:27 +0000768 if (GVar->hasLocalLinkage()) {
769 O << "\t.local\t";
770 GVSym->print(O, MAI);
771 O << '\n';
772 }
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000773 }
Chris Lattner178a9322010-01-16 01:00:27 +0000774 O << MAI->getCOMMDirective();
775 GVSym->print(O, MAI);
776 O << ',' << Size;
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000777 if (MAI->getCOMMDirectiveTakesAlignment())
778 O << ',' << (MAI->getAlignmentIsInBytes() ? (1 << Align) : Align);
779 }
780 if (VerboseAsm) {
781 O.PadToColumn(MAI->getCommentColumn());
782 O << MAI->getCommentString() << ' ';
783 WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
784 }
785 O << '\n';
786 return;
787 }
788 }
789
790 switch (GVar->getLinkage()) {
791 case GlobalValue::CommonLinkage:
792 case GlobalValue::LinkOnceAnyLinkage:
793 case GlobalValue::LinkOnceODRLinkage:
794 case GlobalValue::WeakAnyLinkage:
795 case GlobalValue::WeakODRLinkage:
796 case GlobalValue::LinkerPrivateLinkage:
797 if (Subtarget->isTargetDarwin()) {
Chris Lattner178a9322010-01-16 01:00:27 +0000798 O << "\t.globl ";
799 GVSym->print(O, MAI);
800 O << '\n' << MAI->getWeakDefDirective();
801 GVSym->print(O, MAI);
802 O << '\n';
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000803 } else if (Subtarget->isTargetCygMing()) {
Chris Lattner178a9322010-01-16 01:00:27 +0000804 O << "\t.globl\t";
805 GVSym->print(O, MAI);
806 O << "\n\t.linkonce same_size\n";
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000807 } else {
Chris Lattner178a9322010-01-16 01:00:27 +0000808 O << "\t.weak\t";
809 GVSym->print(O, MAI);
810 O << '\n';
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000811 }
812 break;
813 case GlobalValue::DLLExportLinkage:
814 case GlobalValue::AppendingLinkage:
815 // FIXME: appending linkage variables should go into a section of
816 // their name or something. For now, just emit them as external.
817 case GlobalValue::ExternalLinkage:
818 // If external or appending, declare as a global symbol
Chris Lattner178a9322010-01-16 01:00:27 +0000819 O << "\t.globl ";
820 GVSym->print(O, MAI);
821 O << '\n';
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000822 // FALL THROUGH
823 case GlobalValue::PrivateLinkage:
824 case GlobalValue::InternalLinkage:
825 break;
826 default:
827 llvm_unreachable("Unknown linkage type!");
828 }
829
830 EmitAlignment(Align, GVar);
Chris Lattner178a9322010-01-16 01:00:27 +0000831 GVSym->print(O, MAI);
832 O << ":";
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000833 if (VerboseAsm){
834 O.PadToColumn(MAI->getCommentColumn());
835 O << MAI->getCommentString() << ' ';
836 WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
837 }
838 O << '\n';
839
840 EmitGlobalConstant(C);
841
Chris Lattner178a9322010-01-16 01:00:27 +0000842 if (MAI->hasDotTypeDotSizeDirective()) {
843 O << "\t.size\t";
844 GVSym->print(O, MAI);
845 O << ", " << Size << '\n';
846 }
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000847}
848
849void X86AsmPrinter::EmitEndOfAsmFile(Module &M) {
850 if (Subtarget->isTargetDarwin()) {
851 // All darwin targets use mach-o.
852 TargetLoweringObjectFileMachO &TLOFMacho =
853 static_cast<TargetLoweringObjectFileMachO &>(getObjFileLowering());
854
855 MachineModuleInfoMachO &MMIMacho =
856 MMI->getObjFileInfo<MachineModuleInfoMachO>();
857
858 // Output stubs for dynamically-linked functions.
859 MachineModuleInfoMachO::SymbolListTy Stubs;
860
861 Stubs = MMIMacho.GetFnStubList();
862 if (!Stubs.empty()) {
863 const MCSection *TheSection =
864 TLOFMacho.getMachOSection("__IMPORT", "__jump_table",
865 MCSectionMachO::S_SYMBOL_STUBS |
866 MCSectionMachO::S_ATTR_SELF_MODIFYING_CODE |
867 MCSectionMachO::S_ATTR_PURE_INSTRUCTIONS,
868 5, SectionKind::getMetadata());
869 OutStreamer.SwitchSection(TheSection);
870
871 for (unsigned i = 0, e = Stubs.size(); i != e; ++i) {
872 Stubs[i].first->print(O, MAI);
873 O << ":\n" << "\t.indirect_symbol ";
874 // Get the MCSymbol without the $stub suffix.
875 Stubs[i].second->print(O, MAI);
876 O << "\n\thlt ; hlt ; hlt ; hlt ; hlt\n";
877 }
878 O << '\n';
879
880 Stubs.clear();
881 }
882
883 // Output stubs for external and common global variables.
884 Stubs = MMIMacho.GetGVStubList();
885 if (!Stubs.empty()) {
886 const MCSection *TheSection =
887 TLOFMacho.getMachOSection("__IMPORT", "__pointers",
888 MCSectionMachO::S_NON_LAZY_SYMBOL_POINTERS,
889 SectionKind::getMetadata());
890 OutStreamer.SwitchSection(TheSection);
891
892 for (unsigned i = 0, e = Stubs.size(); i != e; ++i) {
893 Stubs[i].first->print(O, MAI);
894 O << ":\n\t.indirect_symbol ";
895 Stubs[i].second->print(O, MAI);
896 O << "\n\t.long\t0\n";
897 }
898 Stubs.clear();
899 }
900
901 Stubs = MMIMacho.GetHiddenGVStubList();
902 if (!Stubs.empty()) {
903 OutStreamer.SwitchSection(getObjFileLowering().getDataSection());
904 EmitAlignment(2);
905
906 for (unsigned i = 0, e = Stubs.size(); i != e; ++i) {
907 Stubs[i].first->print(O, MAI);
908 O << ":\n" << MAI->getData32bitsDirective();
909 Stubs[i].second->print(O, MAI);
910 O << '\n';
911 }
912 Stubs.clear();
913 }
914
915 // Funny Darwin hack: This flag tells the linker that no global symbols
916 // contain code that falls through to other global symbols (e.g. the obvious
917 // implementation of multiple entry points). If this doesn't occur, the
918 // linker can safely perform dead code stripping. Since LLVM never
919 // generates code that does this, it is always safe to set.
Chris Lattnerfe284f72009-10-19 18:03:08 +0000920 OutStreamer.EmitAssemblerFlag(MCStreamer::SubsectionsViaSymbols);
Anton Korobeynikovd5fcb1d2009-10-15 22:36:18 +0000921 }
922
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000923 if (Subtarget->isTargetCOFF()) {
Anton Korobeynikovd5fcb1d2009-10-15 22:36:18 +0000924 X86COFFMachineModuleInfo &COFFMMI =
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000925 MMI->getObjFileInfo<X86COFFMachineModuleInfo>();
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000926
Anton Korobeynikovd5fcb1d2009-10-15 22:36:18 +0000927 // Emit type information for external functions
928 for (X86COFFMachineModuleInfo::stub_iterator I = COFFMMI.stub_begin(),
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000929 E = COFFMMI.stub_end(); I != E; ++I) {
Anton Korobeynikovd5fcb1d2009-10-15 22:36:18 +0000930 O << "\t.def\t " << I->getKeyData()
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000931 << ";\t.scl\t" << COFF::C_EXT
932 << ";\t.type\t" << (COFF::DT_FCN << COFF::N_BTSHFT)
933 << ";\t.endef\n";
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000934 }
Anton Korobeynikovd5fcb1d2009-10-15 22:36:18 +0000935
936 if (Subtarget->isTargetCygMing()) {
937 // Necessary for dllexport support
Chris Lattnerc53c24c2010-01-16 00:51:39 +0000938 std::vector<const MCSymbol*> DLLExportedFns, DLLExportedGlobals;
Anton Korobeynikovd5fcb1d2009-10-15 22:36:18 +0000939
940 TargetLoweringObjectFileCOFF &TLOFCOFF =
941 static_cast<TargetLoweringObjectFileCOFF&>(getObjFileLowering());
942
943 for (Module::const_iterator I = M.begin(), E = M.end(); I != E; ++I)
944 if (I->hasDLLExportLinkage()) {
Chris Lattnerc53c24c2010-01-16 00:51:39 +0000945 const MCSymbol *Sym = GetGlobalValueSymbol(I);
946 COFFMMI.DecorateCygMingName(Sym, OutContext, I, *TM.getTargetData());
947 DLLExportedFns.push_back(Sym);
Anton Korobeynikovd5fcb1d2009-10-15 22:36:18 +0000948 }
949
950 for (Module::const_global_iterator I = M.global_begin(),
951 E = M.global_end(); I != E; ++I)
Chris Lattnerc53c24c2010-01-16 00:51:39 +0000952 if (I->hasDLLExportLinkage())
953 DLLExportedGlobals.push_back(GetGlobalValueSymbol(I));
Anton Korobeynikovd5fcb1d2009-10-15 22:36:18 +0000954
955 // Output linker support code for dllexported globals on windows.
956 if (!DLLExportedGlobals.empty() || !DLLExportedFns.empty()) {
957 OutStreamer.SwitchSection(TLOFCOFF.getCOFFSection(".section .drectve",
958 true,
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000959 SectionKind::getMetadata()));
Chris Lattnerc53c24c2010-01-16 00:51:39 +0000960 for (unsigned i = 0, e = DLLExportedGlobals.size(); i != e; ++i) {
961 O << "\t.ascii \" -export:";
962 DLLExportedGlobals[i]->print(O, MAI);
963 O << ",data\"\n";
964 }
Anton Korobeynikovd5fcb1d2009-10-15 22:36:18 +0000965
Chris Lattnerc53c24c2010-01-16 00:51:39 +0000966 for (unsigned i = 0, e = DLLExportedFns.size(); i != e; ++i) {
967 O << "\t.ascii \" -export:";
968 DLLExportedFns[i]->print(O, MAI);
969 O << "\"\n";
970 }
Anton Korobeynikovd5fcb1d2009-10-15 22:36:18 +0000971 }
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000972 }
973 }
974}
975
976
977//===----------------------------------------------------------------------===//
978// Target Registry Stuff
979//===----------------------------------------------------------------------===//
980
981static MCInstPrinter *createX86MCInstPrinter(const Target &T,
982 unsigned SyntaxVariant,
983 const MCAsmInfo &MAI,
984 raw_ostream &O) {
985 if (SyntaxVariant == 0)
986 return new X86ATTInstPrinter(O, MAI);
987 if (SyntaxVariant == 1)
988 return new X86IntelInstPrinter(O, MAI);
989 return 0;
990}
991
992// Force static initialization.
993extern "C" void LLVMInitializeX86AsmPrinter() {
994 RegisterAsmPrinter<X86AsmPrinter> X(TheX86_32Target);
995 RegisterAsmPrinter<X86AsmPrinter> Y(TheX86_64Target);
996
997 TargetRegistry::RegisterMCInstPrinter(TheX86_32Target,createX86MCInstPrinter);
998 TargetRegistry::RegisterMCInstPrinter(TheX86_64Target,createX86MCInstPrinter);
999}