blob: 977d32164506364610954f1a4ba3476458b7ba81 [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);
Chris Lattnerce409842010-01-17 21:43:43 +000063 O << *X86MCInstLower(OutContext, 0, *AP).GetPICBaseSymbol();
Chris Lattnerbf4b6a82009-09-20 07:41:30 +000064}
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 Lattnerce409842010-01-17 21:43:43 +000087 O << "\t.globl\t" << *CurrentFnSym << '\n';
Chris Lattnerbf4b6a82009-09-20 07:41:30 +000088 break;
89 case Function::LinkerPrivateLinkage:
90 case Function::LinkOnceAnyLinkage:
91 case Function::LinkOnceODRLinkage:
92 case Function::WeakAnyLinkage:
93 case Function::WeakODRLinkage:
94 if (Subtarget->isTargetDarwin()) {
Chris Lattnerce409842010-01-17 21:43:43 +000095 O << "\t.globl\t" << *CurrentFnSym << '\n';
96 O << MAI->getWeakDefDirective() << *CurrentFnSym << '\n';
Chris Lattnerbf4b6a82009-09-20 07:41:30 +000097 } else if (Subtarget->isTargetCygMing()) {
Chris Lattnerce409842010-01-17 21:43:43 +000098 O << "\t.globl\t" << *CurrentFnSym;
Chris Lattner86ec9712010-01-16 00:32:38 +000099 O << "\n\t.linkonce discard\n";
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000100 } else {
Chris Lattnerce409842010-01-17 21:43:43 +0000101 O << "\t.weak\t" << *CurrentFnSym << '\n';
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000102 }
103 break;
104 }
105
Chris Lattner86ec9712010-01-16 00:32:38 +0000106 printVisibility(CurrentFnSym, F->getVisibility());
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000107
Chris Lattner86ec9712010-01-16 00:32:38 +0000108 if (Subtarget->isTargetELF()) {
Chris Lattnerce409842010-01-17 21:43:43 +0000109 O << "\t.type\t" << *CurrentFnSym << ",@function\n";
Chris Lattner86ec9712010-01-16 00:32:38 +0000110 } else if (Subtarget->isTargetCygMing()) {
Chris Lattnerce409842010-01-17 21:43:43 +0000111 O << "\t.def\t " << *CurrentFnSym;
Chris Lattner86ec9712010-01-16 00:32:38 +0000112 O << ";\t.scl\t" <<
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000113 (F->hasInternalLinkage() ? COFF::C_STAT : COFF::C_EXT)
114 << ";\t.type\t" << (COFF::DT_FCN << COFF::N_BTSHFT)
115 << ";\t.endef\n";
116 }
117
Chris Lattnerce409842010-01-17 21:43:43 +0000118 O << *CurrentFnSym << ':';
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000119 if (VerboseAsm) {
120 O.PadToColumn(MAI->getCommentColumn());
121 O << MAI->getCommentString() << ' ';
122 WriteAsOperand(O, F, /*PrintType=*/false, F->getParent());
123 }
124 O << '\n';
125
126 // Add some workaround for linkonce linkage on Cygwin\MinGW
127 if (Subtarget->isTargetCygMing() &&
Chris Lattnerce409842010-01-17 21:43:43 +0000128 (F->hasLinkOnceLinkage() || F->hasWeakLinkage()))
129 O << "Lllvm$workaround$fake$stub$" << *CurrentFnSym << ":\n";
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000130}
131
132/// runOnMachineFunction - This uses the printMachineInstruction()
133/// method to print assembly for each instruction.
134///
135bool X86AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
136 const Function *F = MF.getFunction();
137 this->MF = &MF;
138 CallingConv::ID CC = F->getCallingConv();
139
140 SetupMachineFunction(MF);
141 O << "\n\n";
142
143 if (Subtarget->isTargetCOFF()) {
144 X86COFFMachineModuleInfo &COFFMMI =
145 MMI->getObjFileInfo<X86COFFMachineModuleInfo>();
146
147 // Populate function information map. Don't want to populate
148 // non-stdcall or non-fastcall functions' information right now.
149 if (CC == CallingConv::X86_StdCall || CC == CallingConv::X86_FastCall)
150 COFFMMI.AddFunctionInfo(F, *MF.getInfo<X86MachineFunctionInfo>());
151 }
152
153 // Print out constants referenced by the function
154 EmitConstantPool(MF.getConstantPool());
155
156 // Print the 'header' of function
157 emitFunctionHeader(MF);
158
159 // Emit pre-function debug and/or EH information.
160 if (MAI->doesSupportDebugInformation() || MAI->doesSupportExceptionHandling())
161 DW->BeginFunction(&MF);
162
163 // Print out code for the function.
164 bool hasAnyRealCode = false;
165 for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
166 I != E; ++I) {
167 // Print a label for the basic block.
Dan Gohman5fda4342009-10-06 17:38:38 +0000168 EmitBasicBlockStart(I);
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000169 for (MachineBasicBlock::const_iterator II = I->begin(), IE = I->end();
170 II != IE; ++II) {
171 // Print the assembly for the instruction.
172 if (!II->isLabel())
173 hasAnyRealCode = true;
174 printMachineInstruction(II);
175 }
176 }
177
178 if (Subtarget->isTargetDarwin() && !hasAnyRealCode) {
179 // If the function is empty, then we need to emit *something*. Otherwise,
180 // the function's label might be associated with something that it wasn't
181 // meant to be associated with. We emit a noop in this situation.
182 // We are assuming inline asms are code.
183 O << "\tnop\n";
184 }
185
Chris Lattnerce409842010-01-17 21:43:43 +0000186 if (MAI->hasDotTypeDotSizeDirective())
187 O << "\t.size\t" << *CurrentFnSym << ", .-" << *CurrentFnSym << '\n';
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000188
189 // Emit post-function debug information.
190 if (MAI->doesSupportDebugInformation() || MAI->doesSupportExceptionHandling())
191 DW->EndFunction(&MF);
192
193 // Print out jump tables referenced by the function.
194 EmitJumpTableInfo(MF.getJumpTableInfo(), MF);
195
196 // We didn't modify anything.
197 return false;
198}
199
200/// printSymbolOperand - Print a raw symbol reference operand. This handles
201/// jump tables, constant pools, global address and external symbols, all of
202/// which print to a label with various suffixes for relocation types etc.
203void X86AsmPrinter::printSymbolOperand(const MachineOperand &MO) {
204 switch (MO.getType()) {
205 default: llvm_unreachable("unknown symbol type!");
206 case MachineOperand::MO_JumpTableIndex:
207 O << MAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber() << '_'
208 << MO.getIndex();
209 break;
210 case MachineOperand::MO_ConstantPoolIndex:
211 O << MAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << '_'
212 << MO.getIndex();
213 printOffset(MO.getOffset());
214 break;
215 case MachineOperand::MO_GlobalAddress: {
216 const GlobalValue *GV = MO.getGlobal();
217
Chris Lattnerc53c24c2010-01-16 00:51:39 +0000218 const MCSymbol *GVSym;
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000219 if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB)
Chris Lattnera6f2a102010-01-16 18:37:32 +0000220 GVSym = GetSymbolWithGlobalValueBase(GV, "$stub");
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000221 else if (MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY ||
222 MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY_PIC_BASE ||
223 MO.getTargetFlags() == X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE)
Chris Lattnera6f2a102010-01-16 18:37:32 +0000224 GVSym = GetSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
Chris Lattnerc53c24c2010-01-16 00:51:39 +0000225 else
226 GVSym = GetGlobalValueSymbol(GV);
227
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000228 if (Subtarget->isTargetCygMing()) {
Anton Korobeynikovd5fcb1d2009-10-15 22:36:18 +0000229 X86COFFMachineModuleInfo &COFFMMI =
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000230 MMI->getObjFileInfo<X86COFFMachineModuleInfo>();
Chris Lattnerc53c24c2010-01-16 00:51:39 +0000231 COFFMMI.DecorateCygMingName(GVSym, OutContext, GV, *TM.getTargetData());
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000232 }
233
234 // Handle dllimport linkage.
235 if (MO.getTargetFlags() == X86II::MO_DLLIMPORT)
Chris Lattnerc53c24c2010-01-16 00:51:39 +0000236 GVSym = OutContext.GetOrCreateSymbol(Twine("__imp_") + GVSym->getName());
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000237
238 if (MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY ||
239 MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY_PIC_BASE) {
Chris Lattnera6f2a102010-01-16 18:37:32 +0000240 MCSymbol *Sym = GetSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000241
242 const MCSymbol *&StubSym =
243 MMI->getObjFileInfo<MachineModuleInfoMachO>().getGVStubEntry(Sym);
Chris Lattner178a9322010-01-16 01:00:27 +0000244 if (StubSym == 0)
245 StubSym = GetGlobalValueSymbol(GV);
246
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000247 } else if (MO.getTargetFlags() == X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE){
Chris Lattnera6f2a102010-01-16 18:37:32 +0000248 MCSymbol *Sym = GetSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000249 const MCSymbol *&StubSym =
250 MMI->getObjFileInfo<MachineModuleInfoMachO>().getHiddenGVStubEntry(Sym);
Chris Lattner178a9322010-01-16 01:00:27 +0000251 if (StubSym == 0)
252 StubSym = GetGlobalValueSymbol(GV);
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000253 } else if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB) {
Chris Lattnera6f2a102010-01-16 18:37:32 +0000254 MCSymbol *Sym = GetSymbolWithGlobalValueBase(GV, "$stub");
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000255 const MCSymbol *&StubSym =
256 MMI->getObjFileInfo<MachineModuleInfoMachO>().getFnStubEntry(Sym);
Chris Lattner178a9322010-01-16 01:00:27 +0000257 if (StubSym == 0)
258 StubSym = GetGlobalValueSymbol(GV);
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000259 }
260
261 // If the name begins with a dollar-sign, enclose it in parens. We do this
262 // to avoid having it look like an integer immediate to the assembler.
Chris Lattnerc53c24c2010-01-16 00:51:39 +0000263 if (GVSym->getName()[0] != '$')
Chris Lattnerce409842010-01-17 21:43:43 +0000264 O << *GVSym;
265 else
266 O << '(' << *GVSym << ')';
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000267 printOffset(MO.getOffset());
268 break;
269 }
270 case MachineOperand::MO_ExternalSymbol: {
Chris Lattnerf80743e2010-01-13 07:56:59 +0000271 const MCSymbol *SymToPrint;
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000272 if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB) {
Chris Lattner178a9322010-01-16 01:00:27 +0000273 SmallString<128> TempNameStr;
274 TempNameStr += StringRef(MO.getSymbolName());
275 TempNameStr += StringRef("$stub");
276
277 const MCSymbol *Sym = GetExternalSymbolSymbol(TempNameStr.str());
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000278 const MCSymbol *&StubSym =
279 MMI->getObjFileInfo<MachineModuleInfoMachO>().getFnStubEntry(Sym);
280 if (StubSym == 0) {
Chris Lattnera38b2872010-01-13 06:38:18 +0000281 TempNameStr.erase(TempNameStr.end()-5, TempNameStr.end());
282 StubSym = OutContext.GetOrCreateSymbol(TempNameStr.str());
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000283 }
Chris Lattnerf80743e2010-01-13 07:56:59 +0000284 SymToPrint = StubSym;
285 } else {
Chris Lattner178a9322010-01-16 01:00:27 +0000286 SymToPrint = GetExternalSymbolSymbol(MO.getSymbolName());
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000287 }
288
289 // If the name begins with a dollar-sign, enclose it in parens. We do this
290 // to avoid having it look like an integer immediate to the assembler.
Chris Lattnerf80743e2010-01-13 07:56:59 +0000291 if (SymToPrint->getName()[0] != '$')
Chris Lattnerce409842010-01-17 21:43:43 +0000292 O << *SymToPrint;
293 else
294 O << '(' << *SymToPrint << '(';
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000295 break;
296 }
297 }
298
299 switch (MO.getTargetFlags()) {
300 default:
301 llvm_unreachable("Unknown target flag on GV operand");
302 case X86II::MO_NO_FLAG: // No flag.
303 break;
304 case X86II::MO_DARWIN_NONLAZY:
305 case X86II::MO_DLLIMPORT:
306 case X86II::MO_DARWIN_STUB:
307 // These affect the name of the symbol, not any suffix.
308 break;
309 case X86II::MO_GOT_ABSOLUTE_ADDRESS:
310 O << " + [.-";
311 PrintPICBaseSymbol();
312 O << ']';
313 break;
314 case X86II::MO_PIC_BASE_OFFSET:
315 case X86II::MO_DARWIN_NONLAZY_PIC_BASE:
316 case X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE:
317 O << '-';
318 PrintPICBaseSymbol();
319 break;
320 case X86II::MO_TLSGD: O << "@TLSGD"; break;
321 case X86II::MO_GOTTPOFF: O << "@GOTTPOFF"; break;
322 case X86II::MO_INDNTPOFF: O << "@INDNTPOFF"; break;
323 case X86II::MO_TPOFF: O << "@TPOFF"; break;
324 case X86II::MO_NTPOFF: O << "@NTPOFF"; break;
325 case X86II::MO_GOTPCREL: O << "@GOTPCREL"; break;
326 case X86II::MO_GOT: O << "@GOT"; break;
327 case X86II::MO_GOTOFF: O << "@GOTOFF"; break;
328 case X86II::MO_PLT: O << "@PLT"; break;
329 }
330}
331
332/// print_pcrel_imm - This is used to print an immediate value that ends up
333/// being encoded as a pc-relative value. These print slightly differently, for
334/// example, a $ is not emitted.
335void X86AsmPrinter::print_pcrel_imm(const MachineInstr *MI, unsigned OpNo) {
336 const MachineOperand &MO = MI->getOperand(OpNo);
337 switch (MO.getType()) {
338 default: llvm_unreachable("Unknown pcrel immediate operand");
339 case MachineOperand::MO_Immediate:
340 O << MO.getImm();
341 return;
342 case MachineOperand::MO_MachineBasicBlock:
Chris Lattnerce409842010-01-17 21:43:43 +0000343 O << *GetMBBSymbol(MO.getMBB()->getNumber());
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000344 return;
345 case MachineOperand::MO_GlobalAddress:
346 case MachineOperand::MO_ExternalSymbol:
347 printSymbolOperand(MO);
348 return;
349 }
350}
351
352
353void X86AsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
354 const char *Modifier) {
355 const MachineOperand &MO = MI->getOperand(OpNo);
356 switch (MO.getType()) {
357 default: llvm_unreachable("unknown operand type!");
358 case MachineOperand::MO_Register: {
359 O << '%';
360 unsigned Reg = MO.getReg();
361 if (Modifier && strncmp(Modifier, "subreg", strlen("subreg")) == 0) {
362 EVT VT = (strcmp(Modifier+6,"64") == 0) ?
363 MVT::i64 : ((strcmp(Modifier+6, "32") == 0) ? MVT::i32 :
364 ((strcmp(Modifier+6,"16") == 0) ? MVT::i16 : MVT::i8));
365 Reg = getX86SubSuperRegister(Reg, VT);
366 }
367 O << X86ATTInstPrinter::getRegisterName(Reg);
368 return;
369 }
370
371 case MachineOperand::MO_Immediate:
372 O << '$' << MO.getImm();
373 return;
374
375 case MachineOperand::MO_JumpTableIndex:
376 case MachineOperand::MO_ConstantPoolIndex:
377 case MachineOperand::MO_GlobalAddress:
378 case MachineOperand::MO_ExternalSymbol: {
379 O << '$';
380 printSymbolOperand(MO);
381 break;
382 }
383 }
384}
385
386void X86AsmPrinter::printSSECC(const MachineInstr *MI, unsigned Op) {
387 unsigned char value = MI->getOperand(Op).getImm();
388 assert(value <= 7 && "Invalid ssecc argument!");
389 switch (value) {
390 case 0: O << "eq"; break;
391 case 1: O << "lt"; break;
392 case 2: O << "le"; break;
393 case 3: O << "unord"; break;
394 case 4: O << "neq"; break;
395 case 5: O << "nlt"; break;
396 case 6: O << "nle"; break;
397 case 7: O << "ord"; break;
398 }
399}
400
401void X86AsmPrinter::printLeaMemReference(const MachineInstr *MI, unsigned Op,
402 const char *Modifier) {
403 const MachineOperand &BaseReg = MI->getOperand(Op);
404 const MachineOperand &IndexReg = MI->getOperand(Op+2);
405 const MachineOperand &DispSpec = MI->getOperand(Op+3);
406
407 // If we really don't want to print out (rip), don't.
408 bool HasBaseReg = BaseReg.getReg() != 0;
409 if (HasBaseReg && Modifier && !strcmp(Modifier, "no-rip") &&
410 BaseReg.getReg() == X86::RIP)
411 HasBaseReg = false;
412
413 // HasParenPart - True if we will print out the () part of the mem ref.
414 bool HasParenPart = IndexReg.getReg() || HasBaseReg;
415
416 if (DispSpec.isImm()) {
417 int DispVal = DispSpec.getImm();
418 if (DispVal || !HasParenPart)
419 O << DispVal;
420 } else {
421 assert(DispSpec.isGlobal() || DispSpec.isCPI() ||
422 DispSpec.isJTI() || DispSpec.isSymbol());
423 printSymbolOperand(MI->getOperand(Op+3));
424 }
425
426 if (HasParenPart) {
427 assert(IndexReg.getReg() != X86::ESP &&
428 "X86 doesn't allow scaling by ESP");
429
430 O << '(';
431 if (HasBaseReg)
432 printOperand(MI, Op, Modifier);
433
434 if (IndexReg.getReg()) {
435 O << ',';
436 printOperand(MI, Op+2, Modifier);
437 unsigned ScaleVal = MI->getOperand(Op+1).getImm();
438 if (ScaleVal != 1)
439 O << ',' << ScaleVal;
440 }
441 O << ')';
442 }
443}
444
445void X86AsmPrinter::printMemReference(const MachineInstr *MI, unsigned Op,
446 const char *Modifier) {
447 assert(isMem(MI, Op) && "Invalid memory reference!");
448 const MachineOperand &Segment = MI->getOperand(Op+4);
449 if (Segment.getReg()) {
450 printOperand(MI, Op+4, Modifier);
451 O << ':';
452 }
453 printLeaMemReference(MI, Op, Modifier);
454}
455
456void X86AsmPrinter::printPICJumpTableSetLabel(unsigned uid,
457 const MachineBasicBlock *MBB) const {
458 if (!MAI->getSetDirective())
459 return;
460
461 // We don't need .set machinery if we have GOT-style relocations
462 if (Subtarget->isPICStyleGOT())
463 return;
464
465 O << MAI->getSetDirective() << ' ' << MAI->getPrivateGlobalPrefix()
466 << getFunctionNumber() << '_' << uid << "_set_" << MBB->getNumber() << ',';
467
Chris Lattnerce409842010-01-17 21:43:43 +0000468 O << GetMBBSymbol(MBB->getNumber());
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000469
470 if (Subtarget->isPICStyleRIPRel())
471 O << '-' << MAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
472 << '_' << uid << '\n';
473 else {
474 O << '-';
475 PrintPICBaseSymbol();
476 O << '\n';
477 }
478}
479
480
481void X86AsmPrinter::printPICLabel(const MachineInstr *MI, unsigned Op) {
482 PrintPICBaseSymbol();
483 O << '\n';
484 PrintPICBaseSymbol();
485 O << ':';
486}
487
488void X86AsmPrinter::printPICJumpTableEntry(const MachineJumpTableInfo *MJTI,
489 const MachineBasicBlock *MBB,
490 unsigned uid) const {
491 const char *JTEntryDirective = MJTI->getEntrySize() == 4 ?
492 MAI->getData32bitsDirective() : MAI->getData64bitsDirective();
493
494 O << JTEntryDirective << ' ';
495
496 if (Subtarget->isPICStyleRIPRel() || Subtarget->isPICStyleStubPIC()) {
497 O << MAI->getPrivateGlobalPrefix() << getFunctionNumber()
498 << '_' << uid << "_set_" << MBB->getNumber();
Chris Lattnerce409842010-01-17 21:43:43 +0000499 } else if (Subtarget->isPICStyleGOT())
500 O << *GetMBBSymbol(MBB->getNumber()) << "@GOTOFF";
501 else
502 O << *GetMBBSymbol(MBB->getNumber());
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000503}
504
505bool X86AsmPrinter::printAsmMRegister(const MachineOperand &MO, char Mode) {
506 unsigned Reg = MO.getReg();
507 switch (Mode) {
508 default: return true; // Unknown mode.
509 case 'b': // Print QImode register
510 Reg = getX86SubSuperRegister(Reg, MVT::i8);
511 break;
512 case 'h': // Print QImode high register
513 Reg = getX86SubSuperRegister(Reg, MVT::i8, true);
514 break;
515 case 'w': // Print HImode register
516 Reg = getX86SubSuperRegister(Reg, MVT::i16);
517 break;
518 case 'k': // Print SImode register
519 Reg = getX86SubSuperRegister(Reg, MVT::i32);
520 break;
521 case 'q': // Print DImode register
522 Reg = getX86SubSuperRegister(Reg, MVT::i64);
523 break;
524 }
525
526 O << '%' << X86ATTInstPrinter::getRegisterName(Reg);
527 return false;
528}
529
530/// PrintAsmOperand - Print out an operand for an inline asm expression.
531///
532bool X86AsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
533 unsigned AsmVariant,
534 const char *ExtraCode) {
535 // Does this asm operand have a single letter operand modifier?
536 if (ExtraCode && ExtraCode[0]) {
537 if (ExtraCode[1] != 0) return true; // Unknown modifier.
538
539 const MachineOperand &MO = MI->getOperand(OpNo);
540
541 switch (ExtraCode[0]) {
542 default: return true; // Unknown modifier.
543 case 'a': // This is an address. Currently only 'i' and 'r' are expected.
544 if (MO.isImm()) {
545 O << MO.getImm();
546 return false;
547 }
548 if (MO.isGlobal() || MO.isCPI() || MO.isJTI() || MO.isSymbol()) {
549 printSymbolOperand(MO);
550 return false;
551 }
552 if (MO.isReg()) {
553 O << '(';
554 printOperand(MI, OpNo);
555 O << ')';
556 return false;
557 }
558 return true;
559
560 case 'c': // Don't print "$" before a global var name or constant.
561 if (MO.isImm())
562 O << MO.getImm();
563 else if (MO.isGlobal() || MO.isCPI() || MO.isJTI() || MO.isSymbol())
564 printSymbolOperand(MO);
565 else
566 printOperand(MI, OpNo);
567 return false;
568
569 case 'A': // Print '*' before a register (it must be a register)
570 if (MO.isReg()) {
571 O << '*';
572 printOperand(MI, OpNo);
573 return false;
574 }
575 return true;
576
577 case 'b': // Print QImode register
578 case 'h': // Print QImode high register
579 case 'w': // Print HImode register
580 case 'k': // Print SImode register
581 case 'q': // Print DImode register
582 if (MO.isReg())
583 return printAsmMRegister(MO, ExtraCode[0]);
584 printOperand(MI, OpNo);
585 return false;
586
587 case 'P': // This is the operand of a call, treat specially.
588 print_pcrel_imm(MI, OpNo);
589 return false;
590
591 case 'n': // Negate the immediate or print a '-' before the operand.
592 // Note: this is a temporary solution. It should be handled target
593 // independently as part of the 'MC' work.
594 if (MO.isImm()) {
595 O << -MO.getImm();
596 return false;
597 }
598 O << '-';
599 }
600 }
601
602 printOperand(MI, OpNo);
603 return false;
604}
605
606bool X86AsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI,
607 unsigned OpNo, unsigned AsmVariant,
608 const char *ExtraCode) {
609 if (ExtraCode && ExtraCode[0]) {
610 if (ExtraCode[1] != 0) return true; // Unknown modifier.
611
612 switch (ExtraCode[0]) {
613 default: return true; // Unknown modifier.
614 case 'b': // Print QImode register
615 case 'h': // Print QImode high register
616 case 'w': // Print HImode register
617 case 'k': // Print SImode register
618 case 'q': // Print SImode register
619 // These only apply to registers, ignore on mem.
620 break;
621 case 'P': // Don't print @PLT, but do print as memory.
622 printMemReference(MI, OpNo, "no-rip");
623 return false;
624 }
625 }
626 printMemReference(MI, OpNo);
627 return false;
628}
629
630
631
632/// printMachineInstruction -- Print out a single X86 LLVM instruction MI in
633/// AT&T syntax to the current output stream.
634///
635void X86AsmPrinter::printMachineInstruction(const MachineInstr *MI) {
636 ++EmittedInsts;
637
Devang Patel5450fc12009-10-06 02:19:11 +0000638 processDebugLoc(MI, true);
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000639
640 printInstructionThroughMCStreamer(MI);
641
David Greeneca9b04b2009-11-13 21:34:57 +0000642 if (VerboseAsm)
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000643 EmitComments(*MI);
644 O << '\n';
Devang Patel5450fc12009-10-06 02:19:11 +0000645
646 processDebugLoc(MI, false);
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000647}
648
649void X86AsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
650 if (!GVar->hasInitializer())
651 return; // External global require no code
652
653 // Check to see if this is a special global used by LLVM, if so, emit it.
654 if (EmitSpecialLLVMGlobal(GVar)) {
655 if (Subtarget->isTargetDarwin() &&
656 TM.getRelocationModel() == Reloc::Static) {
657 if (GVar->getName() == "llvm.global_ctors")
658 O << ".reference .constructors_used\n";
659 else if (GVar->getName() == "llvm.global_dtors")
660 O << ".reference .destructors_used\n";
661 }
662 return;
663 }
664
665 const TargetData *TD = TM.getTargetData();
666
Chris Lattner178a9322010-01-16 01:00:27 +0000667 MCSymbol *GVSym = GetGlobalValueSymbol(GVar);
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000668 Constant *C = GVar->getInitializer();
669 const Type *Type = C->getType();
670 unsigned Size = TD->getTypeAllocSize(Type);
671 unsigned Align = TD->getPreferredAlignmentLog(GVar);
672
Chris Lattner178a9322010-01-16 01:00:27 +0000673 printVisibility(GVSym, GVar->getVisibility());
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000674
Chris Lattnerce409842010-01-17 21:43:43 +0000675 if (Subtarget->isTargetELF())
676 O << "\t.type\t" << *GVSym << ",@object\n";
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000677
678 SectionKind GVKind = TargetLoweringObjectFile::getKindForGlobal(GVar, TM);
679 const MCSection *TheSection =
680 getObjFileLowering().SectionForGlobal(GVar, GVKind, Mang, TM);
681 OutStreamer.SwitchSection(TheSection);
682
683 // FIXME: get this stuff from section kind flags.
684 if (C->isNullValue() && !GVar->hasSection() &&
685 // Don't put things that should go in the cstring section into "comm".
686 !TheSection->getKind().isMergeableCString()) {
687 if (GVar->hasExternalLinkage()) {
688 if (const char *Directive = MAI->getZeroFillDirective()) {
Chris Lattnerce409842010-01-17 21:43:43 +0000689 O << "\t.globl " << *GVSym << '\n';
690 O << Directive << "__DATA, __common, " << *GVSym;
Chris Lattner178a9322010-01-16 01:00:27 +0000691 O << ", " << Size << ", " << Align << '\n';
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000692 return;
693 }
694 }
695
696 if (!GVar->isThreadLocal() &&
697 (GVar->hasLocalLinkage() || GVar->isWeakForLinker())) {
698 if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
699
700 if (MAI->getLCOMMDirective() != NULL) {
701 if (GVar->hasLocalLinkage()) {
Chris Lattnerce409842010-01-17 21:43:43 +0000702 O << MAI->getLCOMMDirective() << *GVSym << ',' << Size;
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000703 if (Subtarget->isTargetDarwin())
704 O << ',' << Align;
705 } else if (Subtarget->isTargetDarwin() && !GVar->hasCommonLinkage()) {
Chris Lattnerce409842010-01-17 21:43:43 +0000706 O << "\t.globl " << *GVSym << '\n';
707 O << MAI->getWeakDefDirective() << *GVSym << '\n';
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000708 EmitAlignment(Align, GVar);
Chris Lattnerce409842010-01-17 21:43:43 +0000709 O << *GVSym << ":";
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000710 if (VerboseAsm) {
711 O.PadToColumn(MAI->getCommentColumn());
712 O << MAI->getCommentString() << ' ';
713 WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
714 }
715 O << '\n';
716 EmitGlobalConstant(C);
717 return;
718 } else {
Chris Lattnerce409842010-01-17 21:43:43 +0000719 O << MAI->getCOMMDirective() << *GVSym << ',' << Size;
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000720 if (MAI->getCOMMDirectiveTakesAlignment())
721 O << ',' << (MAI->getAlignmentIsInBytes() ? (1 << Align) : Align);
722 }
723 } else {
724 if (!Subtarget->isTargetCygMing()) {
Chris Lattnerce409842010-01-17 21:43:43 +0000725 if (GVar->hasLocalLinkage())
726 O << "\t.local\t" << *GVSym << '\n';
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000727 }
Chris Lattnerce409842010-01-17 21:43:43 +0000728 O << MAI->getCOMMDirective() << *GVSym << ',' << Size;
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000729 if (MAI->getCOMMDirectiveTakesAlignment())
730 O << ',' << (MAI->getAlignmentIsInBytes() ? (1 << Align) : Align);
731 }
732 if (VerboseAsm) {
733 O.PadToColumn(MAI->getCommentColumn());
734 O << MAI->getCommentString() << ' ';
735 WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
736 }
737 O << '\n';
738 return;
739 }
740 }
741
742 switch (GVar->getLinkage()) {
743 case GlobalValue::CommonLinkage:
744 case GlobalValue::LinkOnceAnyLinkage:
745 case GlobalValue::LinkOnceODRLinkage:
746 case GlobalValue::WeakAnyLinkage:
747 case GlobalValue::WeakODRLinkage:
748 case GlobalValue::LinkerPrivateLinkage:
749 if (Subtarget->isTargetDarwin()) {
Chris Lattnerce409842010-01-17 21:43:43 +0000750 O << "\t.globl " << *GVSym << '\n';
751 O << MAI->getWeakDefDirective() << *GVSym << '\n';
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000752 } else if (Subtarget->isTargetCygMing()) {
Chris Lattnerce409842010-01-17 21:43:43 +0000753 O << "\t.globl\t" << *GVSym;
Chris Lattner178a9322010-01-16 01:00:27 +0000754 O << "\n\t.linkonce same_size\n";
Chris Lattnerce409842010-01-17 21:43:43 +0000755 } else
756 O << "\t.weak\t" << *GVSym << '\n';
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000757 break;
758 case GlobalValue::DLLExportLinkage:
759 case GlobalValue::AppendingLinkage:
760 // FIXME: appending linkage variables should go into a section of
761 // their name or something. For now, just emit them as external.
762 case GlobalValue::ExternalLinkage:
763 // If external or appending, declare as a global symbol
Chris Lattnerce409842010-01-17 21:43:43 +0000764 O << "\t.globl " << *GVSym << '\n';
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000765 // FALL THROUGH
766 case GlobalValue::PrivateLinkage:
767 case GlobalValue::InternalLinkage:
768 break;
769 default:
770 llvm_unreachable("Unknown linkage type!");
771 }
772
773 EmitAlignment(Align, GVar);
Chris Lattnerce409842010-01-17 21:43:43 +0000774 O << *GVSym << ":";
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000775 if (VerboseAsm){
776 O.PadToColumn(MAI->getCommentColumn());
777 O << MAI->getCommentString() << ' ';
778 WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
779 }
780 O << '\n';
781
782 EmitGlobalConstant(C);
783
Chris Lattnerce409842010-01-17 21:43:43 +0000784 if (MAI->hasDotTypeDotSizeDirective())
785 O << "\t.size\t" << *GVSym << ", " << Size << '\n';
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000786}
787
788void X86AsmPrinter::EmitEndOfAsmFile(Module &M) {
789 if (Subtarget->isTargetDarwin()) {
790 // All darwin targets use mach-o.
791 TargetLoweringObjectFileMachO &TLOFMacho =
792 static_cast<TargetLoweringObjectFileMachO &>(getObjFileLowering());
793
794 MachineModuleInfoMachO &MMIMacho =
795 MMI->getObjFileInfo<MachineModuleInfoMachO>();
796
797 // Output stubs for dynamically-linked functions.
798 MachineModuleInfoMachO::SymbolListTy Stubs;
799
800 Stubs = MMIMacho.GetFnStubList();
801 if (!Stubs.empty()) {
802 const MCSection *TheSection =
803 TLOFMacho.getMachOSection("__IMPORT", "__jump_table",
804 MCSectionMachO::S_SYMBOL_STUBS |
805 MCSectionMachO::S_ATTR_SELF_MODIFYING_CODE |
806 MCSectionMachO::S_ATTR_PURE_INSTRUCTIONS,
807 5, SectionKind::getMetadata());
808 OutStreamer.SwitchSection(TheSection);
809
810 for (unsigned i = 0, e = Stubs.size(); i != e; ++i) {
Chris Lattnerce409842010-01-17 21:43:43 +0000811 O << *Stubs[i].first << ":\n";
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000812 // Get the MCSymbol without the $stub suffix.
Chris Lattnerce409842010-01-17 21:43:43 +0000813 O << "\t.indirect_symbol " << *Stubs[i].second;
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000814 O << "\n\thlt ; hlt ; hlt ; hlt ; hlt\n";
815 }
816 O << '\n';
817
818 Stubs.clear();
819 }
820
821 // Output stubs for external and common global variables.
822 Stubs = MMIMacho.GetGVStubList();
823 if (!Stubs.empty()) {
824 const MCSection *TheSection =
825 TLOFMacho.getMachOSection("__IMPORT", "__pointers",
826 MCSectionMachO::S_NON_LAZY_SYMBOL_POINTERS,
827 SectionKind::getMetadata());
828 OutStreamer.SwitchSection(TheSection);
829
830 for (unsigned i = 0, e = Stubs.size(); i != e; ++i) {
Chris Lattnerce409842010-01-17 21:43:43 +0000831 O << *Stubs[i].first << ":\n\t.indirect_symbol " << *Stubs[i].second;
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000832 O << "\n\t.long\t0\n";
833 }
834 Stubs.clear();
835 }
836
837 Stubs = MMIMacho.GetHiddenGVStubList();
838 if (!Stubs.empty()) {
839 OutStreamer.SwitchSection(getObjFileLowering().getDataSection());
840 EmitAlignment(2);
841
842 for (unsigned i = 0, e = Stubs.size(); i != e; ++i) {
Chris Lattnerce409842010-01-17 21:43:43 +0000843 O << *Stubs[i].first << ":\n" << MAI->getData32bitsDirective();
844 O << *Stubs[i].second << '\n';
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000845 }
846 Stubs.clear();
847 }
848
849 // Funny Darwin hack: This flag tells the linker that no global symbols
850 // contain code that falls through to other global symbols (e.g. the obvious
851 // implementation of multiple entry points). If this doesn't occur, the
852 // linker can safely perform dead code stripping. Since LLVM never
853 // generates code that does this, it is always safe to set.
Chris Lattnerfe284f72009-10-19 18:03:08 +0000854 OutStreamer.EmitAssemblerFlag(MCStreamer::SubsectionsViaSymbols);
Anton Korobeynikovd5fcb1d2009-10-15 22:36:18 +0000855 }
856
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000857 if (Subtarget->isTargetCOFF()) {
Anton Korobeynikovd5fcb1d2009-10-15 22:36:18 +0000858 X86COFFMachineModuleInfo &COFFMMI =
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000859 MMI->getObjFileInfo<X86COFFMachineModuleInfo>();
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000860
Anton Korobeynikovd5fcb1d2009-10-15 22:36:18 +0000861 // Emit type information for external functions
862 for (X86COFFMachineModuleInfo::stub_iterator I = COFFMMI.stub_begin(),
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000863 E = COFFMMI.stub_end(); I != E; ++I) {
Anton Korobeynikovd5fcb1d2009-10-15 22:36:18 +0000864 O << "\t.def\t " << I->getKeyData()
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000865 << ";\t.scl\t" << COFF::C_EXT
866 << ";\t.type\t" << (COFF::DT_FCN << COFF::N_BTSHFT)
867 << ";\t.endef\n";
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000868 }
Anton Korobeynikovd5fcb1d2009-10-15 22:36:18 +0000869
870 if (Subtarget->isTargetCygMing()) {
871 // Necessary for dllexport support
Chris Lattnerc53c24c2010-01-16 00:51:39 +0000872 std::vector<const MCSymbol*> DLLExportedFns, DLLExportedGlobals;
Anton Korobeynikovd5fcb1d2009-10-15 22:36:18 +0000873
874 TargetLoweringObjectFileCOFF &TLOFCOFF =
875 static_cast<TargetLoweringObjectFileCOFF&>(getObjFileLowering());
876
877 for (Module::const_iterator I = M.begin(), E = M.end(); I != E; ++I)
878 if (I->hasDLLExportLinkage()) {
Chris Lattnerc53c24c2010-01-16 00:51:39 +0000879 const MCSymbol *Sym = GetGlobalValueSymbol(I);
880 COFFMMI.DecorateCygMingName(Sym, OutContext, I, *TM.getTargetData());
881 DLLExportedFns.push_back(Sym);
Anton Korobeynikovd5fcb1d2009-10-15 22:36:18 +0000882 }
883
884 for (Module::const_global_iterator I = M.global_begin(),
885 E = M.global_end(); I != E; ++I)
Chris Lattnerc53c24c2010-01-16 00:51:39 +0000886 if (I->hasDLLExportLinkage())
887 DLLExportedGlobals.push_back(GetGlobalValueSymbol(I));
Anton Korobeynikovd5fcb1d2009-10-15 22:36:18 +0000888
889 // Output linker support code for dllexported globals on windows.
890 if (!DLLExportedGlobals.empty() || !DLLExportedFns.empty()) {
891 OutStreamer.SwitchSection(TLOFCOFF.getCOFFSection(".section .drectve",
892 true,
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000893 SectionKind::getMetadata()));
Chris Lattnerce409842010-01-17 21:43:43 +0000894 for (unsigned i = 0, e = DLLExportedGlobals.size(); i != e; ++i)
895 O << "\t.ascii \" -export:" << *DLLExportedGlobals[i] << ",data\"\n";
Anton Korobeynikovd5fcb1d2009-10-15 22:36:18 +0000896
Chris Lattnerce409842010-01-17 21:43:43 +0000897 for (unsigned i = 0, e = DLLExportedFns.size(); i != e; ++i)
898 O << "\t.ascii \" -export:" << *DLLExportedFns[i] << "\"\n";
Anton Korobeynikovd5fcb1d2009-10-15 22:36:18 +0000899 }
Chris Lattnerbf4b6a82009-09-20 07:41:30 +0000900 }
901 }
902}
903
904
905//===----------------------------------------------------------------------===//
906// Target Registry Stuff
907//===----------------------------------------------------------------------===//
908
909static MCInstPrinter *createX86MCInstPrinter(const Target &T,
910 unsigned SyntaxVariant,
911 const MCAsmInfo &MAI,
912 raw_ostream &O) {
913 if (SyntaxVariant == 0)
914 return new X86ATTInstPrinter(O, MAI);
915 if (SyntaxVariant == 1)
916 return new X86IntelInstPrinter(O, MAI);
917 return 0;
918}
919
920// Force static initialization.
921extern "C" void LLVMInitializeX86AsmPrinter() {
922 RegisterAsmPrinter<X86AsmPrinter> X(TheX86_32Target);
923 RegisterAsmPrinter<X86AsmPrinter> Y(TheX86_64Target);
924
925 TargetRegistry::RegisterMCInstPrinter(TheX86_32Target,createX86MCInstPrinter);
926 TargetRegistry::RegisterMCInstPrinter(TheX86_64Target,createX86MCInstPrinter);
927}