blob: e0bd6a3e34487bc61d741c148e65bd6e88e7e7e9 [file] [log] [blame]
Dan Gohman8bc49c22007-06-25 15:11:25 +00001//===-- X86ATTAsmPrinter.cpp - Convert X86 LLVM code to AT&T assembly -----===//
Chris Lattnerb36cbd02005-07-01 22:44:09 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Chris Lattnerb36cbd02005-07-01 22:44:09 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file contains a printer that converts from our internal representation
11// of machine-dependent LLVM code to AT&T format assembly
12// language. This printer is the output mechanism used by `llc'.
13//
14//===----------------------------------------------------------------------===//
15
Chris Lattner95b2c7d2006-12-19 22:59:26 +000016#define DEBUG_TYPE "asm-printer"
Chris Lattnerb36cbd02005-07-01 22:44:09 +000017#include "X86ATTAsmPrinter.h"
Cedric Venetd85f51a2008-08-24 12:30:46 +000018#include "X86.h"
19#include "X86COFF.h"
20#include "X86MachineFunctionInfo.h"
21#include "X86TargetMachine.h"
22#include "X86TargetAsmInfo.h"
Anton Korobeynikovf8248682006-09-20 22:03:51 +000023#include "llvm/CallingConv.h"
Anton Korobeynikov75b68822008-06-28 11:08:27 +000024#include "llvm/DerivedTypes.h"
Chris Lattnerb36cbd02005-07-01 22:44:09 +000025#include "llvm/Module.h"
Anton Korobeynikov75b68822008-06-28 11:08:27 +000026#include "llvm/Type.h"
27#include "llvm/ADT/Statistic.h"
28#include "llvm/ADT/StringExtras.h"
Bill Wendlingcb819f12009-02-18 23:12:06 +000029#include "llvm/CodeGen/DwarfWriter.h"
Anton Korobeynikov75b68822008-06-28 11:08:27 +000030#include "llvm/CodeGen/MachineJumpTableInfo.h"
Chris Lattnerb36cbd02005-07-01 22:44:09 +000031#include "llvm/Support/Mangler.h"
Owen Andersoncb371882008-08-21 00:14:44 +000032#include "llvm/Support/raw_ostream.h"
Jim Laskeya0f3d172006-09-07 22:06:40 +000033#include "llvm/Target/TargetAsmInfo.h"
Evan Cheng7ccced62006-02-18 00:15:05 +000034#include "llvm/Target/TargetOptions.h"
Chris Lattnerb36cbd02005-07-01 22:44:09 +000035using namespace llvm;
Chris Lattnerb36cbd02005-07-01 22:44:09 +000036
Chris Lattner95b2c7d2006-12-19 22:59:26 +000037STATISTIC(EmittedInsts, "Number of machine instrs printed");
38
Evan Cheng0475ab52008-01-05 00:41:47 +000039static std::string getPICLabelString(unsigned FnNum,
40 const TargetAsmInfo *TAI,
41 const X86Subtarget* Subtarget) {
Anton Korobeynikov7f705592007-01-12 19:20:47 +000042 std::string label;
Evan Cheng071b9d52007-01-18 01:49:58 +000043 if (Subtarget->isTargetDarwin())
Evan Cheng347d39f2007-10-14 05:57:21 +000044 label = "\"L" + utostr_32(FnNum) + "$pb\"";
Evan Cheng071b9d52007-01-18 01:49:58 +000045 else if (Subtarget->isTargetELF())
Dan Gohmand19a53b2008-06-30 22:03:41 +000046 label = ".Lllvm$" + utostr_32(FnNum) + "." "$piclabel";
Evan Cheng071b9d52007-01-18 01:49:58 +000047 else
Anton Korobeynikov7f705592007-01-12 19:20:47 +000048 assert(0 && "Don't know how to print PIC label!\n");
49
50 return label;
51}
52
Anton Korobeynikov75b68822008-06-28 11:08:27 +000053static X86MachineFunctionInfo calculateFunctionInfo(const Function *F,
54 const TargetData *TD) {
55 X86MachineFunctionInfo Info;
56 uint64_t Size = 0;
57
58 switch (F->getCallingConv()) {
59 case CallingConv::X86_StdCall:
60 Info.setDecorationStyle(StdCall);
61 break;
62 case CallingConv::X86_FastCall:
63 Info.setDecorationStyle(FastCall);
64 break;
65 default:
66 return Info;
67 }
68
69 unsigned argNum = 1;
70 for (Function::const_arg_iterator AI = F->arg_begin(), AE = F->arg_end();
71 AI != AE; ++AI, ++argNum) {
72 const Type* Ty = AI->getType();
73
74 // 'Dereference' type in case of byval parameter attribute
Devang Patel05988662008-09-25 21:00:45 +000075 if (F->paramHasAttr(argNum, Attribute::ByVal))
Anton Korobeynikov75b68822008-06-28 11:08:27 +000076 Ty = cast<PointerType>(Ty)->getElementType();
77
78 // Size should be aligned to DWORD boundary
Duncan Sandsceb4d1a2009-01-12 20:38:59 +000079 Size += ((TD->getTypePaddedSize(Ty) + 3)/4)*4;
Anton Korobeynikov75b68822008-06-28 11:08:27 +000080 }
81
82 // We're not supporting tooooo huge arguments :)
83 Info.setBytesToPopOnReturn((unsigned int)Size);
84 return Info;
85}
86
87/// PrintUnmangledNameSafely - Print out the printable characters in the name.
88/// Don't print things like \n or \0.
Owen Andersoncb371882008-08-21 00:14:44 +000089static void PrintUnmangledNameSafely(const Value *V, raw_ostream &OS) {
Anton Korobeynikov75b68822008-06-28 11:08:27 +000090 for (const char *Name = V->getNameStart(), *E = Name+V->getNameLen();
91 Name != E; ++Name)
92 if (isprint(*Name))
93 OS << *Name;
94}
95
96/// decorateName - Query FunctionInfoMap and use this information for various
97/// name decoration.
98void X86ATTAsmPrinter::decorateName(std::string &Name,
99 const GlobalValue *GV) {
100 const Function *F = dyn_cast<Function>(GV);
101 if (!F) return;
102
103 // We don't want to decorate non-stdcall or non-fastcall functions right now
104 unsigned CC = F->getCallingConv();
105 if (CC != CallingConv::X86_StdCall && CC != CallingConv::X86_FastCall)
106 return;
107
108 // Decorate names only when we're targeting Cygwin/Mingw32 targets
109 if (!Subtarget->isTargetCygMing())
110 return;
111
112 FMFInfoMap::const_iterator info_item = FunctionInfoMap.find(F);
113
114 const X86MachineFunctionInfo *Info;
115 if (info_item == FunctionInfoMap.end()) {
116 // Calculate apropriate function info and populate map
117 FunctionInfoMap[F] = calculateFunctionInfo(F, TM.getTargetData());
118 Info = &FunctionInfoMap[F];
119 } else {
120 Info = &info_item->second;
121 }
122
123 const FunctionType *FT = F->getFunctionType();
124 switch (Info->getDecorationStyle()) {
125 case None:
126 break;
127 case StdCall:
128 // "Pure" variadic functions do not receive @0 suffix.
129 if (!FT->isVarArg() || (FT->getNumParams() == 0) ||
130 (FT->getNumParams() == 1 && F->hasStructRetAttr()))
131 Name += '@' + utostr_32(Info->getBytesToPopOnReturn());
132 break;
133 case FastCall:
134 // "Pure" variadic functions do not receive @0 suffix.
135 if (!FT->isVarArg() || (FT->getNumParams() == 0) ||
136 (FT->getNumParams() == 1 && F->hasStructRetAttr()))
137 Name += '@' + utostr_32(Info->getBytesToPopOnReturn());
138
139 if (Name[0] == '_') {
140 Name[0] = '@';
141 } else {
142 Name = '@' + Name;
143 }
144 break;
145 default:
146 assert(0 && "Unsupported DecorationStyle");
147 }
148}
149
Anton Korobeynikov1ecf0ee2008-06-28 11:09:01 +0000150void X86ATTAsmPrinter::emitFunctionHeader(const MachineFunction &MF) {
Evan Cheng2338c5c2006-02-07 08:38:37 +0000151 const Function *F = MF.getFunction();
Anton Korobeynikovf8248682006-09-20 22:03:51 +0000152
Anton Korobeynikov75b68822008-06-28 11:08:27 +0000153 decorateName(CurrentFnName, F);
Anton Korobeynikovf8248682006-09-20 22:03:51 +0000154
Anton Korobeynikovc25e1ea2008-09-24 22:14:23 +0000155 SwitchToSection(TAI->SectionForGlobal(F));
Anton Korobeynikov91364382008-06-28 11:08:09 +0000156
Devang Patel4ae641f2008-10-01 23:18:38 +0000157 unsigned FnAlign = 4;
Devang Patele4d4b8c2008-10-06 17:30:07 +0000158 if (F->hasFnAttr(Attribute::OptimizeForSize))
Devang Pateldb100332008-09-04 21:03:41 +0000159 FnAlign = 1;
Evan Cheng2338c5c2006-02-07 08:38:37 +0000160 switch (F->getLinkage()) {
161 default: assert(0 && "Unknown linkage type!");
162 case Function::InternalLinkage: // Symbols default to internal.
Rafael Espindolabb46f522009-01-15 20:18:42 +0000163 case Function::PrivateLinkage:
Evan Chenge22e62b2008-03-25 22:29:46 +0000164 EmitAlignment(FnAlign, F);
Evan Cheng2338c5c2006-02-07 08:38:37 +0000165 break;
Anton Korobeynikovb74ed072006-09-14 18:23:27 +0000166 case Function::DLLExportLinkage:
Evan Cheng2338c5c2006-02-07 08:38:37 +0000167 case Function::ExternalLinkage:
Evan Chenge22e62b2008-03-25 22:29:46 +0000168 EmitAlignment(FnAlign, F);
Dan Gohmand19a53b2008-06-30 22:03:41 +0000169 O << "\t.globl\t" << CurrentFnName << '\n';
Evan Cheng2338c5c2006-02-07 08:38:37 +0000170 break;
Evan Cheng2338c5c2006-02-07 08:38:37 +0000171 case Function::LinkOnceLinkage:
Anton Korobeynikovb1c88022006-10-18 09:12:29 +0000172 case Function::WeakLinkage:
Evan Chenge22e62b2008-03-25 22:29:46 +0000173 EmitAlignment(FnAlign, F);
Jim Laskeyea348582006-07-27 02:05:13 +0000174 if (Subtarget->isTargetDarwin()) {
Dan Gohmand19a53b2008-06-30 22:03:41 +0000175 O << "\t.globl\t" << CurrentFnName << '\n';
176 O << TAI->getWeakDefDirective() << CurrentFnName << '\n';
Anton Korobeynikov317848f2007-01-03 11:43:14 +0000177 } else if (Subtarget->isTargetCygMing()) {
Dan Gohmand19a53b2008-06-30 22:03:41 +0000178 O << "\t.globl\t" << CurrentFnName << "\n"
179 "\t.linkonce discard\n";
Anton Korobeynikovb7188b12006-10-17 20:29:49 +0000180 } else {
Dan Gohmand19a53b2008-06-30 22:03:41 +0000181 O << "\t.weak\t" << CurrentFnName << '\n';
Anton Korobeynikovb7188b12006-10-17 20:29:49 +0000182 }
183 break;
Evan Cheng2338c5c2006-02-07 08:38:37 +0000184 }
Anton Korobeynikovf5b6a472008-08-08 18:25:07 +0000185
186 printVisibility(CurrentFnName, F->getVisibility());
Anton Korobeynikovd05ca652007-01-16 16:41:57 +0000187
188 if (Subtarget->isTargetELF())
Dan Gohman825811d2007-07-30 15:08:02 +0000189 O << "\t.type\t" << CurrentFnName << ",@function\n";
Anton Korobeynikovd05ca652007-01-16 16:41:57 +0000190 else if (Subtarget->isTargetCygMing()) {
191 O << "\t.def\t " << CurrentFnName
192 << ";\t.scl\t" <<
Rafael Espindolabb46f522009-01-15 20:18:42 +0000193 (F->hasInternalLinkage() ? COFF::C_STAT : COFF::C_EXT)
Anton Korobeynikovd05ca652007-01-16 16:41:57 +0000194 << ";\t.type\t" << (COFF::DT_FCN << COFF::N_BTSHFT)
195 << ";\t.endef\n";
196 }
197
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000198 O << CurrentFnName << ":\n";
Anton Korobeynikovb1c88022006-10-18 09:12:29 +0000199 // Add some workaround for linkonce linkage on Cygwin\MinGW
Anton Korobeynikov317848f2007-01-03 11:43:14 +0000200 if (Subtarget->isTargetCygMing() &&
Anton Korobeynikovb1c88022006-10-18 09:12:29 +0000201 (F->getLinkage() == Function::LinkOnceLinkage ||
202 F->getLinkage() == Function::WeakLinkage))
Anton Korobeynikov7f705592007-01-12 19:20:47 +0000203 O << "Lllvm$workaround$fake$stub$" << CurrentFnName << ":\n";
Anton Korobeynikov1ecf0ee2008-06-28 11:09:01 +0000204}
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000205
Anton Korobeynikov1ecf0ee2008-06-28 11:09:01 +0000206/// runOnMachineFunction - This uses the printMachineInstruction()
207/// method to print assembly for each instruction.
208///
209bool X86ATTAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
210 const Function *F = MF.getFunction();
Bill Wendlingac06d002009-02-06 21:45:08 +0000211 this->MF = &MF;
Anton Korobeynikov1ecf0ee2008-06-28 11:09:01 +0000212 unsigned CC = F->getCallingConv();
213
Anton Korobeynikov1ecf0ee2008-06-28 11:09:01 +0000214 SetupMachineFunction(MF);
215 O << "\n\n";
216
217 // Populate function information map. Actually, We don't want to populate
218 // non-stdcall or non-fastcall functions' information right now.
219 if (CC == CallingConv::X86_StdCall || CC == CallingConv::X86_FastCall)
220 FunctionInfoMap[F] = *MF.getInfo<X86MachineFunctionInfo>();
221
222 // Print out constants referenced by the function
223 EmitConstantPool(MF.getConstantPool());
224
225 if (F->hasDLLExportLinkage())
226 DLLExportedFns.insert(Mang->makeNameProper(F->getName(), ""));
227
228 // Print the 'header' of function
229 emitFunctionHeader(MF);
230
231 // Emit pre-function debug and/or EH information.
232 if (TAI->doesSupportDebugInformation() || TAI->doesSupportExceptionHandling())
Devang Pateleb3fc282009-01-08 23:40:34 +0000233 DW->BeginFunction(&MF);
Anton Korobeynikov1ecf0ee2008-06-28 11:09:01 +0000234
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000235 // Print out code for the function.
Dale Johannesenf2247cf2008-04-08 00:37:56 +0000236 bool hasAnyRealCode = false;
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000237 for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
238 I != E; ++I) {
239 // Print a label for the basic block.
Dan Gohmancb406c22007-10-03 19:26:29 +0000240 if (!I->pred_empty()) {
Evan Chengfb8075d2008-02-28 00:43:03 +0000241 printBasicBlockLabel(I, true, true);
Nate Begemancdf38c42006-05-02 05:37:32 +0000242 O << '\n';
243 }
Bill Wendling824a7212008-01-26 09:03:52 +0000244 for (MachineBasicBlock::const_iterator II = I->begin(), IE = I->end();
245 II != IE; ++II) {
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000246 // Print the assembly for the instruction.
Dan Gohman44066042008-07-01 00:05:16 +0000247 if (!II->isLabel())
Dale Johannesenf2247cf2008-04-08 00:37:56 +0000248 hasAnyRealCode = true;
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000249 printMachineInstruction(II);
250 }
251 }
Evan Cheng67afece2006-08-28 22:14:16 +0000252
Dale Johannesenf2247cf2008-04-08 00:37:56 +0000253 if (Subtarget->isTargetDarwin() && !hasAnyRealCode) {
254 // If the function is empty, then we need to emit *something*. Otherwise,
255 // the function's label might be associated with something that it wasn't
256 // meant to be associated with. We emit a noop in this situation.
257 // We are assuming inline asms are code.
258 O << "\tnop\n";
259 }
260
Jim Laskey563321a2006-09-06 18:34:40 +0000261 if (TAI->hasDotTypeDotSizeDirective())
Dan Gohmand19a53b2008-06-30 22:03:41 +0000262 O << "\t.size\t" << CurrentFnName << ", .-" << CurrentFnName << '\n';
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000263
Anton Korobeynikov1ecf0ee2008-06-28 11:09:01 +0000264 // Emit post-function debug information.
265 if (TAI->doesSupportDebugInformation())
Devang Pateleb3fc282009-01-08 23:40:34 +0000266 DW->EndFunction(&MF);
Evan Cheng3c992d22006-03-07 02:02:57 +0000267
Anton Korobeynikov2a07e2f2007-05-05 09:04:50 +0000268 // Print out jump tables referenced by the function.
269 EmitJumpTableInfo(MF.getJumpTableInfo(), MF);
Anton Korobeynikov91364382008-06-28 11:08:09 +0000270
Dan Gohmane5f4de42008-11-07 19:49:17 +0000271 O.flush();
272
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000273 // We didn't modify anything.
274 return false;
275}
276
Rafael Espindolad674b4e2008-06-09 09:52:31 +0000277static inline bool shouldPrintGOT(TargetMachine &TM, const X86Subtarget* ST) {
Evan Chengae19abc2007-01-18 22:27:12 +0000278 return ST->isPICStyleGOT() && TM.getRelocationModel() == Reloc::PIC_;
279}
280
Rafael Espindolad674b4e2008-06-09 09:52:31 +0000281static inline bool shouldPrintPLT(TargetMachine &TM, const X86Subtarget* ST) {
282 return ST->isTargetELF() && TM.getRelocationModel() == Reloc::PIC_ &&
283 (ST->isPICStyleRIPRel() || ST->isPICStyleGOT());
284}
285
286static inline bool shouldPrintStub(TargetMachine &TM, const X86Subtarget* ST) {
Evan Chengae19abc2007-01-18 22:27:12 +0000287 return ST->isPICStyleStub() && TM.getRelocationModel() != Reloc::Static;
288}
289
Chris Lattnera3b8c572006-02-06 23:41:19 +0000290void X86ATTAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
Evan Cheng28b514392006-12-05 19:50:18 +0000291 const char *Modifier, bool NotRIPRel) {
Chris Lattnera3b8c572006-02-06 23:41:19 +0000292 const MachineOperand &MO = MI->getOperand(OpNo);
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000293 switch (MO.getType()) {
Evan Cheng8f7f7122006-05-05 05:40:20 +0000294 case MachineOperand::MO_Register: {
Dan Gohman6f0d0242008-02-10 18:45:23 +0000295 assert(TargetRegisterInfo::isPhysicalRegister(MO.getReg()) &&
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000296 "Virtual registers should not make it this far!");
297 O << '%';
Evan Cheng8f7f7122006-05-05 05:40:20 +0000298 unsigned Reg = MO.getReg();
Evan Chengcbe70e12006-05-31 22:34:26 +0000299 if (Modifier && strncmp(Modifier, "subreg", strlen("subreg")) == 0) {
Duncan Sands83ec4b62008-06-06 12:08:01 +0000300 MVT VT = (strcmp(Modifier+6,"64") == 0) ?
Evan Cheng25ab6902006-09-08 06:48:29 +0000301 MVT::i64 : ((strcmp(Modifier+6, "32") == 0) ? MVT::i32 :
302 ((strcmp(Modifier+6,"16") == 0) ? MVT::i16 : MVT::i8));
Evan Cheng8f7f7122006-05-05 05:40:20 +0000303 Reg = getX86SubSuperRegister(Reg, VT);
304 }
Evan Chengae270f62008-07-07 22:21:06 +0000305 O << TRI->getAsmName(Reg);
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000306 return;
Evan Cheng8f7f7122006-05-05 05:40:20 +0000307 }
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000308
Chris Lattner63b3d712006-05-04 17:21:20 +0000309 case MachineOperand::MO_Immediate:
Chris Lattnerb4828722007-01-25 02:53:24 +0000310 if (!Modifier ||
311 (strcmp(Modifier, "debug") && strcmp(Modifier, "mem")))
Evan Cheng3c992d22006-03-07 02:02:57 +0000312 O << '$';
Chris Lattner9a1ceae2007-12-30 20:49:49 +0000313 O << MO.getImm();
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000314 return;
Nate Begeman37efe672006-04-22 18:53:45 +0000315 case MachineOperand::MO_MachineBasicBlock:
Chris Lattner8aa797a2007-12-30 23:10:15 +0000316 printBasicBlockLabel(MO.getMBB());
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000317 return;
Nate Begeman37efe672006-04-22 18:53:45 +0000318 case MachineOperand::MO_JumpTableIndex: {
319 bool isMemOp = Modifier && !strcmp(Modifier, "mem");
320 if (!isMemOp) O << '$';
Dan Gohmand19a53b2008-06-30 22:03:41 +0000321 O << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber() << '_'
Chris Lattner8aa797a2007-12-30 23:10:15 +0000322 << MO.getIndex();
Anton Korobeynikov7f705592007-01-12 19:20:47 +0000323
324 if (TM.getRelocationModel() == Reloc::PIC_) {
325 if (Subtarget->isPICStyleStub())
Evan Cheng347d39f2007-10-14 05:57:21 +0000326 O << "-\"" << TAI->getPrivateGlobalPrefix() << getFunctionNumber()
327 << "$pb\"";
Anton Korobeynikov7f705592007-01-12 19:20:47 +0000328 else if (Subtarget->isPICStyleGOT())
329 O << "@GOTOFF";
330 }
Anton Korobeynikov91364382008-06-28 11:08:09 +0000331
Evan Chengae19abc2007-01-18 22:27:12 +0000332 if (isMemOp && Subtarget->isPICStyleRIPRel() && !NotRIPRel)
Evan Cheng25ab6902006-09-08 06:48:29 +0000333 O << "(%rip)";
Nate Begeman37efe672006-04-22 18:53:45 +0000334 return;
335 }
Evan Chenga09bd812006-02-26 08:28:12 +0000336 case MachineOperand::MO_ConstantPoolIndex: {
337 bool isMemOp = Modifier && !strcmp(Modifier, "mem");
338 if (!isMemOp) O << '$';
Dan Gohmand19a53b2008-06-30 22:03:41 +0000339 O << TAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << '_'
Chris Lattner8aa797a2007-12-30 23:10:15 +0000340 << MO.getIndex();
Anton Korobeynikov7f705592007-01-12 19:20:47 +0000341
342 if (TM.getRelocationModel() == Reloc::PIC_) {
343 if (Subtarget->isPICStyleStub())
Evan Cheng347d39f2007-10-14 05:57:21 +0000344 O << "-\"" << TAI->getPrivateGlobalPrefix() << getFunctionNumber()
345 << "$pb\"";
Evan Chengae19abc2007-01-18 22:27:12 +0000346 else if (Subtarget->isPICStyleGOT())
Anton Korobeynikov7f705592007-01-12 19:20:47 +0000347 O << "@GOTOFF";
348 }
Anton Korobeynikov91364382008-06-28 11:08:09 +0000349
Anton Korobeynikov7751ad92008-11-22 16:15:34 +0000350 printOffset(MO.getOffset());
Evan Cheng25ab6902006-09-08 06:48:29 +0000351
Evan Chengae19abc2007-01-18 22:27:12 +0000352 if (isMemOp && Subtarget->isPICStyleRIPRel() && !NotRIPRel)
Evan Cheng25ab6902006-09-08 06:48:29 +0000353 O << "(%rip)";
Evan Chenga09bd812006-02-26 08:28:12 +0000354 return;
355 }
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000356 case MachineOperand::MO_GlobalAddress: {
Chris Lattnera3b8c572006-02-06 23:41:19 +0000357 bool isCallOp = Modifier && !strcmp(Modifier, "call");
Evan Cheng2338c5c2006-02-07 08:38:37 +0000358 bool isMemOp = Modifier && !strcmp(Modifier, "mem");
Dan Gohman2a3250c2007-04-26 21:07:05 +0000359 bool needCloseParen = false;
Evan Cheng25ab6902006-09-08 06:48:29 +0000360
Anton Korobeynikov4d86e2a2008-03-11 22:38:53 +0000361 const GlobalValue *GV = MO.getGlobal();
362 const GlobalVariable *GVar = dyn_cast<GlobalVariable>(GV);
363 if (!GVar) {
Anton Korobeynikovc73ede02008-03-22 07:53:40 +0000364 // If GV is an alias then use the aliasee for determining
365 // thread-localness.
Anton Korobeynikov4d86e2a2008-03-11 22:38:53 +0000366 if (const GlobalAlias *GA = dyn_cast<GlobalAlias>(GV))
Anton Korobeynikov19e861a2008-09-09 20:05:04 +0000367 GVar = dyn_cast_or_null<GlobalVariable>(GA->resolveAliasedGlobal(false));
Anton Korobeynikov4d86e2a2008-03-11 22:38:53 +0000368 }
369
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +0000370 bool isThreadLocal = GVar && GVar->isThreadLocal();
371
Evan Cheng25ab6902006-09-08 06:48:29 +0000372 std::string Name = Mang->getValueName(GV);
Anton Korobeynikov75b68822008-06-28 11:08:27 +0000373 decorateName(Name, GV);
Anton Korobeynikov91364382008-06-28 11:08:09 +0000374
Dan Gohman2a3250c2007-04-26 21:07:05 +0000375 if (!isMemOp && !isCallOp)
376 O << '$';
377 else if (Name[0] == '$') {
378 // The name begins with a dollar-sign. In order to avoid having it look
379 // like an integer immediate to the assembler, enclose it in parens.
380 O << '(';
381 needCloseParen = true;
382 }
383
Rafael Espindolad674b4e2008-06-09 09:52:31 +0000384 if (shouldPrintStub(TM, Subtarget)) {
Evan Cheng111354f2007-06-04 18:54:57 +0000385 // Link-once, declaration, or Weakly-linked global variables need
Evan Cheng2338c5c2006-02-07 08:38:37 +0000386 // non-lazily-resolved stubs
Duncan Sands5df31862008-09-29 11:25:42 +0000387 if (GV->isDeclaration() || GV->mayBeOverridden()) {
Evan Cheng2338c5c2006-02-07 08:38:37 +0000388 // Dynamically-resolved functions need a stub for the function.
Evan Cheng25ab6902006-09-08 06:48:29 +0000389 if (isCallOp && isa<Function>(GV)) {
Evan Cheng91a23c82008-09-20 00:13:45 +0000390 // Function stubs are no longer needed for Mac OS X 10.5 and up.
391 if (Subtarget->isTargetDarwin() && Subtarget->getDarwinVers() >= 9) {
392 O << Name;
393 } else {
394 FnStubs.insert(Name);
395 printSuffixedName(Name, "$stub");
396 }
Evan Chengae94e592008-12-05 01:06:39 +0000397 } else if (GV->hasHiddenVisibility()) {
398 if (!GV->isDeclaration() && !GV->hasCommonLinkage())
399 // Definition is not definitely in the current translation unit.
400 O << Name;
401 else {
402 HiddenGVStubs.insert(Name);
403 printSuffixedName(Name, "$non_lazy_ptr");
404 }
Evan Cheng2338c5c2006-02-07 08:38:37 +0000405 } else {
406 GVStubs.insert(Name);
Dale Johannesenc215b3e2008-05-19 21:38:18 +0000407 printSuffixedName(Name, "$non_lazy_ptr");
Evan Cheng2338c5c2006-02-07 08:38:37 +0000408 }
Anton Korobeynikovb74ed072006-09-14 18:23:27 +0000409 } else {
Evan Chengae19abc2007-01-18 22:27:12 +0000410 if (GV->hasDLLImportLinkage())
Anton Korobeynikov91364382008-06-28 11:08:09 +0000411 O << "__imp_";
Evan Cheng25ab6902006-09-08 06:48:29 +0000412 O << Name;
Anton Korobeynikovb74ed072006-09-14 18:23:27 +0000413 }
Anton Korobeynikov91364382008-06-28 11:08:09 +0000414
Chris Lattner35d86fe2006-07-26 21:12:04 +0000415 if (!isCallOp && TM.getRelocationModel() == Reloc::PIC_)
Evan Cheng0475ab52008-01-05 00:41:47 +0000416 O << '-' << getPICLabelString(getFunctionNumber(), TAI, Subtarget);
Anton Korobeynikovb74ed072006-09-14 18:23:27 +0000417 } else {
418 if (GV->hasDLLImportLinkage()) {
Anton Korobeynikov91364382008-06-28 11:08:09 +0000419 O << "__imp_";
420 }
Evan Cheng25ab6902006-09-08 06:48:29 +0000421 O << Name;
Anton Korobeynikov7f705592007-01-12 19:20:47 +0000422
Rafael Espindolad674b4e2008-06-09 09:52:31 +0000423 if (isCallOp) {
424 if (shouldPrintPLT(TM, Subtarget)) {
425 // Assemble call via PLT for externally visible symbols
426 if (!GV->hasHiddenVisibility() && !GV->hasProtectedVisibility() &&
Rafael Espindolabb46f522009-01-15 20:18:42 +0000427 !GV->hasLocalLinkage())
Anton Korobeynikovd05ca652007-01-16 16:41:57 +0000428 O << "@PLT";
429 }
Reid Spencer5cbf9852007-01-30 20:08:39 +0000430 if (Subtarget->isTargetCygMing() && GV->isDeclaration())
Anton Korobeynikovd05ca652007-01-16 16:41:57 +0000431 // Save function name for later type emission
432 FnStubs.insert(Name);
Anton Korobeynikov7f705592007-01-12 19:20:47 +0000433 }
Anton Korobeynikovb74ed072006-09-14 18:23:27 +0000434 }
Anton Korobeynikov78ee7b72006-12-01 00:25:12 +0000435
Evan Cheng6d7d3102006-12-01 07:38:23 +0000436 if (GV->hasExternalWeakLinkage())
Rafael Espindola15404d02006-12-18 03:37:18 +0000437 ExtWeakSymbols.insert(GV);
Anton Korobeynikov6625eff2008-05-04 21:36:32 +0000438
Anton Korobeynikov7751ad92008-11-22 16:15:34 +0000439 printOffset(MO.getOffset());
Evan Cheng25ab6902006-09-08 06:48:29 +0000440
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +0000441 if (isThreadLocal) {
Rafael Espindola9a580232009-02-27 13:37:18 +0000442 TLSModel::Model model = getTLSModel(GVar, TM.getRelocationModel());
443 switch (model) {
444 case TLSModel::GeneralDynamic:
445 O << "@TLSGD";
446 break;
447 case TLSModel::LocalDynamic:
448 // O << "@TLSLD"; // local dynamic not implemented
449 O << "@TLSGD";
450 break;
451 case TLSModel::InitialExec:
452 if (Subtarget->is64Bit())
453 O << "@TLSGD"; // 64 bit intial exec not implemented
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +0000454 else
Rafael Espindola9a580232009-02-27 13:37:18 +0000455 O << "@INDNTPOFF";
456 break;
457 case TLSModel::LocalExec:
458 if (Subtarget->is64Bit())
459 O << "@TLSGD"; // 64 bit local exec not implemented
460 else
461 O << "@NTPOFF";
462 break;
463 default:
464 assert (0 && "Unknown TLS model");
465 }
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +0000466 } else if (isMemOp) {
Rafael Espindolad674b4e2008-06-09 09:52:31 +0000467 if (shouldPrintGOT(TM, Subtarget)) {
Anton Korobeynikov5032e5a2007-01-17 10:33:08 +0000468 if (Subtarget->GVRequiresExtraLoad(GV, TM, false))
Anton Korobeynikov7f705592007-01-12 19:20:47 +0000469 O << "@GOT";
Anton Korobeynikov5032e5a2007-01-17 10:33:08 +0000470 else
Anton Korobeynikov7f705592007-01-12 19:20:47 +0000471 O << "@GOTOFF";
Chris Lattnerfe6575c2007-11-04 19:23:28 +0000472 } else if (Subtarget->isPICStyleRIPRel() && !NotRIPRel &&
473 TM.getRelocationModel() != Reloc::Static) {
Anton Korobeynikov99e635c2008-01-20 13:59:37 +0000474 if (Subtarget->GVRequiresExtraLoad(GV, TM, false))
Evan Chengae19abc2007-01-18 22:27:12 +0000475 O << "@GOTPCREL";
Dan Gohman2a3250c2007-04-26 21:07:05 +0000476
477 if (needCloseParen) {
478 needCloseParen = false;
479 O << ')';
480 }
481
Evan Chengae19abc2007-01-18 22:27:12 +0000482 // Use rip when possible to reduce code size, except when
483 // index or base register are also part of the address. e.g.
484 // foo(%rip)(%rcx,%rax,4) is not legal
485 O << "(%rip)";
486 }
Evan Cheng25ab6902006-09-08 06:48:29 +0000487 }
488
Dan Gohman2a3250c2007-04-26 21:07:05 +0000489 if (needCloseParen)
490 O << ')';
491
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000492 return;
493 }
Chris Lattnera3b8c572006-02-06 23:41:19 +0000494 case MachineOperand::MO_ExternalSymbol: {
495 bool isCallOp = Modifier && !strcmp(Modifier, "call");
Dan Gohman2a3250c2007-04-26 21:07:05 +0000496 bool needCloseParen = false;
Anton Korobeynikov7f705592007-01-12 19:20:47 +0000497 std::string Name(TAI->getGlobalPrefix());
498 Name += MO.getSymbolName();
Evan Cheng91a23c82008-09-20 00:13:45 +0000499 // Print function stub suffix unless it's Mac OS X 10.5 and up.
500 if (isCallOp && shouldPrintStub(TM, Subtarget) &&
501 !(Subtarget->isTargetDarwin() && Subtarget->getDarwinVers() >= 9)) {
Nate Begeman72b286b2005-07-08 00:23:26 +0000502 FnStubs.insert(Name);
Dale Johannesenc215b3e2008-05-19 21:38:18 +0000503 printSuffixedName(Name, "$stub");
Nate Begeman72b286b2005-07-08 00:23:26 +0000504 return;
505 }
Dan Gohman2a3250c2007-04-26 21:07:05 +0000506 if (!isCallOp)
507 O << '$';
508 else if (Name[0] == '$') {
509 // The name begins with a dollar-sign. In order to avoid having it look
510 // like an integer immediate to the assembler, enclose it in parens.
511 O << '(';
512 needCloseParen = true;
513 }
514
Anton Korobeynikov7f705592007-01-12 19:20:47 +0000515 O << Name;
516
Rafael Espindolad674b4e2008-06-09 09:52:31 +0000517 if (shouldPrintPLT(TM, Subtarget)) {
Anton Korobeynikov7f705592007-01-12 19:20:47 +0000518 std::string GOTName(TAI->getGlobalPrefix());
519 GOTName+="_GLOBAL_OFFSET_TABLE_";
520 if (Name == GOTName)
Evan Chengae19abc2007-01-18 22:27:12 +0000521 // HACK! Emit extra offset to PC during printing GOT offset to
522 // compensate for the size of popl instruction. The resulting code
523 // should look like:
Anton Korobeynikov7f705592007-01-12 19:20:47 +0000524 // call .piclabel
525 // piclabel:
526 // popl %some_register
527 // addl $_GLOBAL_ADDRESS_TABLE_ + [.-piclabel], %some_register
Evan Cheng071b9d52007-01-18 01:49:58 +0000528 O << " + [.-"
Dan Gohmand19a53b2008-06-30 22:03:41 +0000529 << getPICLabelString(getFunctionNumber(), TAI, Subtarget) << ']';
Evan Chengae19abc2007-01-18 22:27:12 +0000530
531 if (isCallOp)
532 O << "@PLT";
Anton Korobeynikov7f705592007-01-12 19:20:47 +0000533 }
534
Dan Gohman2a3250c2007-04-26 21:07:05 +0000535 if (needCloseParen)
536 O << ')';
537
Evan Chengae19abc2007-01-18 22:27:12 +0000538 if (!isCallOp && Subtarget->isPICStyleRIPRel())
Evan Cheng25ab6902006-09-08 06:48:29 +0000539 O << "(%rip)";
540
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000541 return;
Chris Lattnera3b8c572006-02-06 23:41:19 +0000542 }
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000543 default:
544 O << "<unknown operand type>"; return;
545 }
546}
547
Nate Begeman391c5d22005-11-30 18:54:35 +0000548void X86ATTAsmPrinter::printSSECC(const MachineInstr *MI, unsigned Op) {
Chris Lattner9a1ceae2007-12-30 20:49:49 +0000549 unsigned char value = MI->getOperand(Op).getImm();
Nate Begeman6c7cb292005-07-14 22:52:25 +0000550 assert(value <= 7 && "Invalid ssecc argument!");
551 switch (value) {
552 case 0: O << "eq"; break;
553 case 1: O << "lt"; break;
554 case 2: O << "le"; break;
555 case 3: O << "unord"; break;
556 case 4: O << "neq"; break;
557 case 5: O << "nlt"; break;
558 case 6: O << "nle"; break;
559 case 7: O << "ord"; break;
560 }
561}
562
Evan Cheng25ab6902006-09-08 06:48:29 +0000563void X86ATTAsmPrinter::printMemReference(const MachineInstr *MI, unsigned Op,
564 const char *Modifier){
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000565 assert(isMem(MI, Op) && "Invalid memory reference!");
Chris Lattner32c9a452007-01-14 00:13:07 +0000566 MachineOperand BaseReg = MI->getOperand(Op);
567 MachineOperand IndexReg = MI->getOperand(Op+2);
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000568 const MachineOperand &DispSpec = MI->getOperand(Op+3);
569
Evan Cheng28b514392006-12-05 19:50:18 +0000570 bool NotRIPRel = IndexReg.getReg() || BaseReg.getReg();
Dan Gohmand735b802008-10-03 15:45:36 +0000571 if (DispSpec.isGlobal() ||
572 DispSpec.isCPI() ||
573 DispSpec.isJTI()) {
Evan Cheng28b514392006-12-05 19:50:18 +0000574 printOperand(MI, Op+3, "mem", NotRIPRel);
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000575 } else {
Chris Lattner9a1ceae2007-12-30 20:49:49 +0000576 int DispVal = DispSpec.getImm();
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000577 if (DispVal || (!IndexReg.getReg() && !BaseReg.getReg()))
578 O << DispVal;
579 }
580
581 if (IndexReg.getReg() || BaseReg.getReg()) {
Chris Lattner9a1ceae2007-12-30 20:49:49 +0000582 unsigned ScaleVal = MI->getOperand(Op+1).getImm();
Chris Lattner32c9a452007-01-14 00:13:07 +0000583 unsigned BaseRegOperand = 0, IndexRegOperand = 2;
Anton Korobeynikov91364382008-06-28 11:08:09 +0000584
Chris Lattner32c9a452007-01-14 00:13:07 +0000585 // There are cases where we can end up with ESP/RSP in the indexreg slot.
586 // If this happens, swap the base/index register to support assemblers that
587 // don't work when the index is *SP.
588 if (IndexReg.getReg() == X86::ESP || IndexReg.getReg() == X86::RSP) {
589 assert(ScaleVal == 1 && "Scale not supported for stack pointer!");
590 std::swap(BaseReg, IndexReg);
591 std::swap(BaseRegOperand, IndexRegOperand);
Evan Cheng25ab6902006-09-08 06:48:29 +0000592 }
Anton Korobeynikov91364382008-06-28 11:08:09 +0000593
Dan Gohmand19a53b2008-06-30 22:03:41 +0000594 O << '(';
Chris Lattner32c9a452007-01-14 00:13:07 +0000595 if (BaseReg.getReg())
596 printOperand(MI, Op+BaseRegOperand, Modifier);
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000597
598 if (IndexReg.getReg()) {
Dan Gohmand19a53b2008-06-30 22:03:41 +0000599 O << ',';
Chris Lattner32c9a452007-01-14 00:13:07 +0000600 printOperand(MI, Op+IndexRegOperand, Modifier);
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000601 if (ScaleVal != 1)
Dan Gohmand19a53b2008-06-30 22:03:41 +0000602 O << ',' << ScaleVal;
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000603 }
Dan Gohmand19a53b2008-06-30 22:03:41 +0000604 O << ')';
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000605 }
606}
607
Anton Korobeynikov91364382008-06-28 11:08:09 +0000608void X86ATTAsmPrinter::printPICJumpTableSetLabel(unsigned uid,
Evan Chengcc415862007-11-09 01:32:10 +0000609 const MachineBasicBlock *MBB) const {
610 if (!TAI->getSetDirective())
611 return;
Anton Korobeynikov9de19342007-11-14 09:18:41 +0000612
613 // We don't need .set machinery if we have GOT-style relocations
614 if (Subtarget->isPICStyleGOT())
615 return;
Anton Korobeynikov91364382008-06-28 11:08:09 +0000616
Evan Chengcc415862007-11-09 01:32:10 +0000617 O << TAI->getSetDirective() << ' ' << TAI->getPrivateGlobalPrefix()
618 << getFunctionNumber() << '_' << uid << "_set_" << MBB->getNumber() << ',';
Evan Chengfb8075d2008-02-28 00:43:03 +0000619 printBasicBlockLabel(MBB, false, false, false);
Evan Chenged2fc712007-11-09 19:11:23 +0000620 if (Subtarget->isPICStyleRIPRel())
Anton Korobeynikov91364382008-06-28 11:08:09 +0000621 O << '-' << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
Evan Chenged2fc712007-11-09 19:11:23 +0000622 << '_' << uid << '\n';
623 else
Evan Cheng0475ab52008-01-05 00:41:47 +0000624 O << '-' << getPICLabelString(getFunctionNumber(), TAI, Subtarget) << '\n';
Evan Chengcc415862007-11-09 01:32:10 +0000625}
626
Evan Cheng7ccced62006-02-18 00:15:05 +0000627void X86ATTAsmPrinter::printPICLabel(const MachineInstr *MI, unsigned Op) {
Evan Cheng0475ab52008-01-05 00:41:47 +0000628 std::string label = getPICLabelString(getFunctionNumber(), TAI, Subtarget);
Dan Gohmand19a53b2008-06-30 22:03:41 +0000629 O << label << '\n' << label << ':';
Evan Cheng7ccced62006-02-18 00:15:05 +0000630}
631
Evan Cheng62f27002006-04-28 23:11:40 +0000632
Anton Korobeynikov9de19342007-11-14 09:18:41 +0000633void X86ATTAsmPrinter::printPICJumpTableEntry(const MachineJumpTableInfo *MJTI,
634 const MachineBasicBlock *MBB,
Anton Korobeynikov91364382008-06-28 11:08:09 +0000635 unsigned uid) const
636{
Anton Korobeynikov9de19342007-11-14 09:18:41 +0000637 const char *JTEntryDirective = MJTI->getEntrySize() == 4 ?
638 TAI->getData32bitsDirective() : TAI->getData64bitsDirective();
639
640 O << JTEntryDirective << ' ';
641
642 if (TM.getRelocationModel() == Reloc::PIC_) {
643 if (Subtarget->isPICStyleRIPRel() || Subtarget->isPICStyleStub()) {
644 O << TAI->getPrivateGlobalPrefix() << getFunctionNumber()
645 << '_' << uid << "_set_" << MBB->getNumber();
646 } else if (Subtarget->isPICStyleGOT()) {
Evan Chengfb8075d2008-02-28 00:43:03 +0000647 printBasicBlockLabel(MBB, false, false, false);
Anton Korobeynikov9de19342007-11-14 09:18:41 +0000648 O << "@GOTOFF";
649 } else
650 assert(0 && "Don't know how to print MBB label for this PIC mode");
651 } else
Evan Chengfb8075d2008-02-28 00:43:03 +0000652 printBasicBlockLabel(MBB, false, false, false);
Anton Korobeynikov9de19342007-11-14 09:18:41 +0000653}
654
Anton Korobeynikov4d580652008-06-28 11:10:06 +0000655bool X86ATTAsmPrinter::printAsmMRegister(const MachineOperand &MO,
Evan Cheng62f27002006-04-28 23:11:40 +0000656 const char Mode) {
Evan Cheng62f27002006-04-28 23:11:40 +0000657 unsigned Reg = MO.getReg();
Evan Cheng62f27002006-04-28 23:11:40 +0000658 switch (Mode) {
659 default: return true; // Unknown mode.
660 case 'b': // Print QImode register
Evan Cheng8f7f7122006-05-05 05:40:20 +0000661 Reg = getX86SubSuperRegister(Reg, MVT::i8);
Evan Cheng62f27002006-04-28 23:11:40 +0000662 break;
663 case 'h': // Print QImode high register
Evan Cheng8f7f7122006-05-05 05:40:20 +0000664 Reg = getX86SubSuperRegister(Reg, MVT::i8, true);
Evan Cheng62f27002006-04-28 23:11:40 +0000665 break;
666 case 'w': // Print HImode register
Evan Cheng8f7f7122006-05-05 05:40:20 +0000667 Reg = getX86SubSuperRegister(Reg, MVT::i16);
Evan Cheng62f27002006-04-28 23:11:40 +0000668 break;
669 case 'k': // Print SImode register
Evan Cheng8f7f7122006-05-05 05:40:20 +0000670 Reg = getX86SubSuperRegister(Reg, MVT::i32);
Evan Cheng62f27002006-04-28 23:11:40 +0000671 break;
Chris Lattnerfb7f3432007-10-29 03:09:07 +0000672 case 'q': // Print DImode register
673 Reg = getX86SubSuperRegister(Reg, MVT::i64);
674 break;
Evan Cheng62f27002006-04-28 23:11:40 +0000675 }
676
Evan Chengae270f62008-07-07 22:21:06 +0000677 O << '%'<< TRI->getAsmName(Reg);
Evan Cheng62f27002006-04-28 23:11:40 +0000678 return false;
679}
680
Evan Cheng3d48a902006-04-28 21:19:05 +0000681/// PrintAsmOperand - Print out an operand for an inline asm expression.
682///
Anton Korobeynikovf0302cd2008-06-28 11:09:48 +0000683bool X86ATTAsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
Anton Korobeynikov91364382008-06-28 11:08:09 +0000684 unsigned AsmVariant,
Evan Cheng3d48a902006-04-28 21:19:05 +0000685 const char *ExtraCode) {
686 // Does this asm operand have a single letter operand modifier?
687 if (ExtraCode && ExtraCode[0]) {
688 if (ExtraCode[1] != 0) return true; // Unknown modifier.
Anton Korobeynikov91364382008-06-28 11:08:09 +0000689
Evan Cheng3d48a902006-04-28 21:19:05 +0000690 switch (ExtraCode[0]) {
691 default: return true; // Unknown modifier.
Chris Lattnerb4828722007-01-25 02:53:24 +0000692 case 'c': // Don't print "$" before a global var name or constant.
Chris Lattner0d924992006-10-31 20:12:30 +0000693 printOperand(MI, OpNo, "mem");
694 return false;
Evan Cheng62f27002006-04-28 23:11:40 +0000695 case 'b': // Print QImode register
696 case 'h': // Print QImode high register
697 case 'w': // Print HImode register
698 case 'k': // Print SImode register
Chris Lattnerfb7f3432007-10-29 03:09:07 +0000699 case 'q': // Print DImode register
Dan Gohmand735b802008-10-03 15:45:36 +0000700 if (MI->getOperand(OpNo).isReg())
Chris Lattner14393522007-03-25 02:01:03 +0000701 return printAsmMRegister(MI->getOperand(OpNo), ExtraCode[0]);
702 printOperand(MI, OpNo);
703 return false;
Anton Korobeynikov91364382008-06-28 11:08:09 +0000704
Chris Lattner7cd5e072007-03-25 01:44:57 +0000705 case 'P': // Don't print @PLT, but do print as memory.
706 printOperand(MI, OpNo, "mem");
707 return false;
Evan Cheng3d48a902006-04-28 21:19:05 +0000708 }
709 }
Anton Korobeynikov91364382008-06-28 11:08:09 +0000710
Evan Cheng3d48a902006-04-28 21:19:05 +0000711 printOperand(MI, OpNo);
712 return false;
713}
714
Anton Korobeynikov4d580652008-06-28 11:10:06 +0000715bool X86ATTAsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI,
Evan Cheng3d48a902006-04-28 21:19:05 +0000716 unsigned OpNo,
Anton Korobeynikov91364382008-06-28 11:08:09 +0000717 unsigned AsmVariant,
Evan Cheng3d48a902006-04-28 21:19:05 +0000718 const char *ExtraCode) {
Chris Lattnerfb7f3432007-10-29 03:09:07 +0000719 if (ExtraCode && ExtraCode[0]) {
720 if (ExtraCode[1] != 0) return true; // Unknown modifier.
Anton Korobeynikov91364382008-06-28 11:08:09 +0000721
Chris Lattnerfb7f3432007-10-29 03:09:07 +0000722 switch (ExtraCode[0]) {
723 default: return true; // Unknown modifier.
724 case 'b': // Print QImode register
725 case 'h': // Print QImode high register
726 case 'w': // Print HImode register
727 case 'k': // Print SImode register
728 case 'q': // Print SImode register
729 // These only apply to registers, ignore on mem.
730 break;
Chris Lattner91387de2009-01-23 22:33:40 +0000731 case 'P': // Don't print @PLT, but do print as memory.
732 printOperand(MI, OpNo, "mem");
733 return false;
Chris Lattnerfb7f3432007-10-29 03:09:07 +0000734 }
735 }
Evan Cheng3d48a902006-04-28 21:19:05 +0000736 printMemReference(MI, OpNo);
737 return false;
738}
739
Bill Wendlingac06d002009-02-06 21:45:08 +0000740/// printMachineInstruction -- Print out a single X86 LLVM instruction MI in
741/// AT&T syntax to the current output stream.
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000742///
743void X86ATTAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
744 ++EmittedInsts;
Evan Cheng67caa392006-01-26 02:27:43 +0000745
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000746 // Call the autogenerated instruction printer routines.
747 printInstruction(MI);
748}
749
Anton Korobeynikov75b68822008-06-28 11:08:27 +0000750/// doInitialization
751bool X86ATTAsmPrinter::doInitialization(Module &M) {
Anton Korobeynikov75b68822008-06-28 11:08:27 +0000752
Evan Cheng526be702008-07-09 06:36:53 +0000753 bool Result = AsmPrinter::doInitialization(M);
754
Dale Johannesen7bc39e22008-07-09 20:55:35 +0000755 if (TAI->doesSupportDebugInformation()) {
756 // Let PassManager know we need debug information and relay
757 // the MachineModuleInfo address on to DwarfWriter.
758 // AsmPrinter::doInitialization did this analysis.
Duncan Sands1465d612009-01-28 13:14:17 +0000759 MMI = getAnalysisIfAvailable<MachineModuleInfo>();
760 DW = getAnalysisIfAvailable<DwarfWriter>();
Devang Pateleb3fc282009-01-08 23:40:34 +0000761 DW->BeginModule(&M, MMI, O, this, TAI);
Dale Johannesen7bc39e22008-07-09 20:55:35 +0000762 }
763
Anton Korobeynikov75b68822008-06-28 11:08:27 +0000764 // Darwin wants symbols to be quoted if they have complex names.
765 if (Subtarget->isTargetDarwin())
766 Mang->setUseQuotes(true);
767
768 return Result;
769}
770
771
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000772void X86ATTAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {
Anton Korobeynikov75b68822008-06-28 11:08:27 +0000773 const TargetData *TD = TM.getTargetData();
774
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000775 if (!GVar->hasInitializer())
776 return; // External global require no code
777
778 // Check to see if this is a special global used by LLVM, if so, emit it.
779 if (EmitSpecialLLVMGlobal(GVar)) {
780 if (Subtarget->isTargetDarwin() &&
781 TM.getRelocationModel() == Reloc::Static) {
782 if (GVar->getName() == "llvm.global_ctors")
783 O << ".reference .constructors_used\n";
784 else if (GVar->getName() == "llvm.global_dtors")
785 O << ".reference .destructors_used\n";
786 }
787 return;
788 }
789
790 std::string name = Mang->getValueName(GVar);
791 Constant *C = GVar->getInitializer();
792 const Type *Type = C->getType();
Duncan Sandsceb4d1a2009-01-12 20:38:59 +0000793 unsigned Size = TD->getTypePaddedSize(Type);
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000794 unsigned Align = TD->getPreferredAlignmentLog(GVar);
795
Anton Korobeynikovf5b6a472008-08-08 18:25:07 +0000796 printVisibility(name, GVar->getVisibility());
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000797
798 if (Subtarget->isTargetELF())
799 O << "\t.type\t" << name << ",@object\n";
800
Anton Korobeynikovc25e1ea2008-09-24 22:14:23 +0000801 SwitchToSection(TAI->SectionForGlobal(GVar));
Anton Korobeynikove87f52d2008-07-09 13:27:16 +0000802
Evan Chengcaa0c2c2009-02-18 02:19:52 +0000803 if (C->isNullValue() && !GVar->hasSection() &&
804 !(Subtarget->isTargetDarwin() &&
805 TAI->SectionKindForGlobal(GVar) == SectionKind::RODataMergeStr)) {
Anton Korobeynikove87f52d2008-07-09 13:27:16 +0000806 // FIXME: This seems to be pretty darwin-specific
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000807 if (GVar->hasExternalLinkage()) {
808 if (const char *Directive = TAI->getZeroFillDirective()) {
Dan Gohmand19a53b2008-06-30 22:03:41 +0000809 O << "\t.globl " << name << '\n';
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000810 O << Directive << "__DATA, __common, " << name << ", "
Dan Gohmand19a53b2008-06-30 22:03:41 +0000811 << Size << ", " << Align << '\n';
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000812 return;
813 }
814 }
815
816 if (!GVar->isThreadLocal() &&
Rafael Espindolabb46f522009-01-15 20:18:42 +0000817 (GVar->hasLocalLinkage() || GVar->mayBeOverridden())) {
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000818 if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
Anton Korobeynikove87f52d2008-07-09 13:27:16 +0000819
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000820 if (TAI->getLCOMMDirective() != NULL) {
Rafael Espindolabb46f522009-01-15 20:18:42 +0000821 if (GVar->hasLocalLinkage()) {
Dan Gohmand19a53b2008-06-30 22:03:41 +0000822 O << TAI->getLCOMMDirective() << name << ',' << Size;
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000823 if (Subtarget->isTargetDarwin())
Dan Gohmand19a53b2008-06-30 22:03:41 +0000824 O << ',' << Align;
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000825 } else if (Subtarget->isTargetDarwin() && !GVar->hasCommonLinkage()) {
Dan Gohmand19a53b2008-06-30 22:03:41 +0000826 O << "\t.globl " << name << '\n'
827 << TAI->getWeakDefDirective() << name << '\n';
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000828 EmitAlignment(Align, GVar);
Dan Gohmand19a53b2008-06-30 22:03:41 +0000829 O << name << ":\t\t\t\t" << TAI->getCommentString() << ' ';
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000830 PrintUnmangledNameSafely(GVar, O);
Dan Gohmand19a53b2008-06-30 22:03:41 +0000831 O << '\n';
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000832 EmitGlobalConstant(C);
833 return;
834 } else {
Dan Gohmand19a53b2008-06-30 22:03:41 +0000835 O << TAI->getCOMMDirective() << name << ',' << Size;
Anton Korobeynikov16b7f512008-08-08 18:25:52 +0000836 if (TAI->getCOMMDirectiveTakesAlignment())
837 O << ',' << (TAI->getAlignmentIsInBytes() ? (1 << Align) : Align);
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000838 }
839 } else {
840 if (!Subtarget->isTargetCygMing()) {
Rafael Espindolabb46f522009-01-15 20:18:42 +0000841 if (GVar->hasLocalLinkage())
Dan Gohmand19a53b2008-06-30 22:03:41 +0000842 O << "\t.local\t" << name << '\n';
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000843 }
Dan Gohmand19a53b2008-06-30 22:03:41 +0000844 O << TAI->getCOMMDirective() << name << ',' << Size;
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000845 if (TAI->getCOMMDirectiveTakesAlignment())
Dan Gohmand19a53b2008-06-30 22:03:41 +0000846 O << ',' << (TAI->getAlignmentIsInBytes() ? (1 << Align) : Align);
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000847 }
Dan Gohmand19a53b2008-06-30 22:03:41 +0000848 O << "\t\t" << TAI->getCommentString() << ' ';
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000849 PrintUnmangledNameSafely(GVar, O);
Dan Gohmand19a53b2008-06-30 22:03:41 +0000850 O << '\n';
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000851 return;
852 }
853 }
854
855 switch (GVar->getLinkage()) {
Evan Cheng15621a22008-08-08 06:43:59 +0000856 case GlobalValue::CommonLinkage:
857 case GlobalValue::LinkOnceLinkage:
858 case GlobalValue::WeakLinkage:
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000859 if (Subtarget->isTargetDarwin()) {
Dan Gohmand19a53b2008-06-30 22:03:41 +0000860 O << "\t.globl " << name << '\n'
861 << TAI->getWeakDefDirective() << name << '\n';
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000862 } else if (Subtarget->isTargetCygMing()) {
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000863 O << "\t.globl\t" << name << "\n"
Dan Gohmand19a53b2008-06-30 22:03:41 +0000864 "\t.linkonce same_size\n";
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000865 } else {
Dan Gohmand19a53b2008-06-30 22:03:41 +0000866 O << "\t.weak\t" << name << '\n';
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000867 }
868 break;
Evan Cheng15621a22008-08-08 06:43:59 +0000869 case GlobalValue::DLLExportLinkage:
870 case GlobalValue::AppendingLinkage:
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000871 // FIXME: appending linkage variables should go into a section of
872 // their name or something. For now, just emit them as external.
Evan Cheng15621a22008-08-08 06:43:59 +0000873 case GlobalValue::ExternalLinkage:
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000874 // If external or appending, declare as a global symbol
Dan Gohmand19a53b2008-06-30 22:03:41 +0000875 O << "\t.globl " << name << '\n';
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000876 // FALL THROUGH
Rafael Espindolabb46f522009-01-15 20:18:42 +0000877 case GlobalValue::PrivateLinkage:
Evan Cheng15621a22008-08-08 06:43:59 +0000878 case GlobalValue::InternalLinkage:
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000879 break;
Evan Cheng15621a22008-08-08 06:43:59 +0000880 default:
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000881 assert(0 && "Unknown linkage type!");
882 }
883
884 EmitAlignment(Align, GVar);
Dan Gohmand19a53b2008-06-30 22:03:41 +0000885 O << name << ":\t\t\t\t" << TAI->getCommentString() << ' ';
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000886 PrintUnmangledNameSafely(GVar, O);
Dan Gohmand19a53b2008-06-30 22:03:41 +0000887 O << '\n';
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000888 if (TAI->hasDotTypeDotSizeDirective())
Dan Gohmand19a53b2008-06-30 22:03:41 +0000889 O << "\t.size\t" << name << ", " << Size << '\n';
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000890
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000891 EmitGlobalConstant(C);
892}
893
Evan Cheng77c8f762008-07-08 00:55:58 +0000894/// printGVStub - Print stub for a global value.
895///
896void X86ATTAsmPrinter::printGVStub(const char *GV, const char *Prefix) {
Evan Chengab8faba2008-07-08 16:40:43 +0000897 printSuffixedName(GV, "$non_lazy_ptr", Prefix);
Evan Cheng77c8f762008-07-08 00:55:58 +0000898 O << ":\n\t.indirect_symbol ";
899 if (Prefix) O << Prefix;
900 O << GV << "\n\t.long\t0\n";
901}
902
Evan Chengae94e592008-12-05 01:06:39 +0000903/// printHiddenGVStub - Print stub for a hidden global value.
904///
905void X86ATTAsmPrinter::printHiddenGVStub(const char *GV, const char *Prefix) {
906 EmitAlignment(2);
907 printSuffixedName(GV, "$non_lazy_ptr", Prefix);
908 if (Prefix) O << Prefix;
909 O << ":\n" << TAI->getData32bitsDirective() << GV << '\n';
910}
911
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000912
913bool X86ATTAsmPrinter::doFinalization(Module &M) {
Anton Korobeynikov75b68822008-06-28 11:08:27 +0000914 // Print out module-level global variables here.
915 for (Module::const_global_iterator I = M.global_begin(), E = M.global_end();
Anton Korobeynikovf0302cd2008-06-28 11:09:48 +0000916 I != E; ++I) {
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000917 printModuleLevelGV(I);
Anton Korobeynikov75b68822008-06-28 11:08:27 +0000918
Anton Korobeynikovf0302cd2008-06-28 11:09:48 +0000919 if (I->hasDLLExportLinkage())
920 DLLExportedGVs.insert(Mang->makeNameProper(I->getName(),""));
Anton Korobeynikovb5bd0262009-02-21 11:53:32 +0000921
922 // If the global is a extern weak symbol, remember to emit the weak
923 // reference!
924 // FIXME: This is rather hacky, since we'll emit references to ALL weak stuff,
925 // not used. But currently it's the only way to deal with extern weak
926 // initializers hidden deep inside constant expressions.
927 if (I->hasExternalWeakLinkage())
928 ExtWeakSymbols.insert(I);
929 }
930
931 for (Module::const_iterator I = M.begin(), E = M.end();
932 I != E; ++I) {
933 // If the global is a extern weak symbol, remember to emit the weak
934 // reference!
935 // FIXME: This is rather hacky, since we'll emit references to ALL weak stuff,
936 // not used. But currently it's the only way to deal with extern weak
937 // initializers hidden deep inside constant expressions.
938 if (I->hasExternalWeakLinkage())
939 ExtWeakSymbols.insert(I);
Anton Korobeynikovf0302cd2008-06-28 11:09:48 +0000940 }
941
Anton Korobeynikov75b68822008-06-28 11:08:27 +0000942 // Output linker support code for dllexported globals
Anton Korobeynikov36a57012008-06-28 11:08:44 +0000943 if (!DLLExportedGVs.empty())
Anton Korobeynikov75b68822008-06-28 11:08:27 +0000944 SwitchToDataSection(".section .drectve");
Anton Korobeynikov75b68822008-06-28 11:08:27 +0000945
946 for (StringSet<>::iterator i = DLLExportedGVs.begin(),
947 e = DLLExportedGVs.end();
Anton Korobeynikov36a57012008-06-28 11:08:44 +0000948 i != e; ++i)
Anton Korobeynikov75b68822008-06-28 11:08:27 +0000949 O << "\t.ascii \" -export:" << i->getKeyData() << ",data\"\n";
Anton Korobeynikov75b68822008-06-28 11:08:27 +0000950
951 if (!DLLExportedFns.empty()) {
952 SwitchToDataSection(".section .drectve");
953 }
954
955 for (StringSet<>::iterator i = DLLExportedFns.begin(),
956 e = DLLExportedFns.end();
Anton Korobeynikov36a57012008-06-28 11:08:44 +0000957 i != e; ++i)
Anton Korobeynikov75b68822008-06-28 11:08:27 +0000958 O << "\t.ascii \" -export:" << i->getKeyData() << "\"\n";
Anton Korobeynikov75b68822008-06-28 11:08:27 +0000959
960 if (Subtarget->isTargetDarwin()) {
961 SwitchToDataSection("");
962
963 // Output stubs for dynamically-linked functions
Anton Korobeynikov75b68822008-06-28 11:08:27 +0000964 for (StringSet<>::iterator i = FnStubs.begin(), e = FnStubs.end();
Evan Chengae94e592008-12-05 01:06:39 +0000965 i != e; ++i) {
Anton Korobeynikov75b68822008-06-28 11:08:27 +0000966 SwitchToDataSection("\t.section __IMPORT,__jump_table,symbol_stubs,"
967 "self_modifying_code+pure_instructions,5", 0);
Evan Cheng77c8f762008-07-08 00:55:58 +0000968 const char *p = i->getKeyData();
Anton Korobeynikov75b68822008-06-28 11:08:27 +0000969 printSuffixedName(p, "$stub");
Dan Gohmand19a53b2008-06-30 22:03:41 +0000970 O << ":\n"
971 "\t.indirect_symbol " << p << "\n"
972 "\thlt ; hlt ; hlt ; hlt ; hlt\n";
Anton Korobeynikov75b68822008-06-28 11:08:27 +0000973 }
974
Dan Gohmand19a53b2008-06-30 22:03:41 +0000975 O << '\n';
Anton Korobeynikov75b68822008-06-28 11:08:27 +0000976
Evan Cheng77c8f762008-07-08 00:55:58 +0000977 // Print global value stubs.
978 bool InStubSection = false;
Anton Korobeynikov75b68822008-06-28 11:08:27 +0000979 if (TAI->doesSupportExceptionHandling() && MMI && !Subtarget->is64Bit()) {
980 // Add the (possibly multiple) personalities to the set of global values.
981 // Only referenced functions get into the Personalities list.
982 const std::vector<Function *>& Personalities = MMI->getPersonalities();
Anton Korobeynikov75b68822008-06-28 11:08:27 +0000983 for (std::vector<Function *>::const_iterator I = Personalities.begin(),
Evan Cheng77c8f762008-07-08 00:55:58 +0000984 E = Personalities.end(); I != E; ++I) {
985 if (!*I)
986 continue;
987 if (!InStubSection) {
988 SwitchToDataSection(
989 "\t.section __IMPORT,__pointers,non_lazy_symbol_pointers");
990 InStubSection = true;
991 }
992 printGVStub((*I)->getNameStart(), "_");
993 }
Anton Korobeynikov75b68822008-06-28 11:08:27 +0000994 }
995
996 // Output stubs for external and common global variables.
Evan Cheng77c8f762008-07-08 00:55:58 +0000997 if (!InStubSection && !GVStubs.empty())
Anton Korobeynikov75b68822008-06-28 11:08:27 +0000998 SwitchToDataSection(
999 "\t.section __IMPORT,__pointers,non_lazy_symbol_pointers");
1000 for (StringSet<>::iterator i = GVStubs.begin(), e = GVStubs.end();
Evan Cheng77c8f762008-07-08 00:55:58 +00001001 i != e; ++i)
1002 printGVStub(i->getKeyData());
Anton Korobeynikov75b68822008-06-28 11:08:27 +00001003
Evan Chengae94e592008-12-05 01:06:39 +00001004 if (!HiddenGVStubs.empty()) {
1005 SwitchToSection(TAI->getDataSection());
1006 for (StringSet<>::iterator i = HiddenGVStubs.begin(), e = HiddenGVStubs.end();
1007 i != e; ++i)
1008 printHiddenGVStub(i->getKeyData());
1009 }
1010
Anton Korobeynikov75b68822008-06-28 11:08:27 +00001011 // Emit final debug information.
Duncan Sands1465d612009-01-28 13:14:17 +00001012 DwarfWriter *DW = getAnalysisIfAvailable<DwarfWriter>();
Devang Pateleb3fc282009-01-08 23:40:34 +00001013 DW->EndModule();
Anton Korobeynikov75b68822008-06-28 11:08:27 +00001014
1015 // Funny Darwin hack: This flag tells the linker that no global symbols
1016 // contain code that falls through to other global symbols (e.g. the obvious
1017 // implementation of multiple entry points). If this doesn't occur, the
1018 // linker can safely perform dead code stripping. Since LLVM never
1019 // generates code that does this, it is always safe to set.
1020 O << "\t.subsections_via_symbols\n";
1021 } else if (Subtarget->isTargetCygMing()) {
1022 // Emit type information for external functions
1023 for (StringSet<>::iterator i = FnStubs.begin(), e = FnStubs.end();
1024 i != e; ++i) {
1025 O << "\t.def\t " << i->getKeyData()
1026 << ";\t.scl\t" << COFF::C_EXT
1027 << ";\t.type\t" << (COFF::DT_FCN << COFF::N_BTSHFT)
1028 << ";\t.endef\n";
1029 }
1030
1031 // Emit final debug information.
Duncan Sands1465d612009-01-28 13:14:17 +00001032 DwarfWriter *DW = getAnalysisIfAvailable<DwarfWriter>();
Devang Pateleb3fc282009-01-08 23:40:34 +00001033 DW->EndModule();
Anton Korobeynikov75b68822008-06-28 11:08:27 +00001034 } else if (Subtarget->isTargetELF()) {
1035 // Emit final debug information.
Duncan Sands1465d612009-01-28 13:14:17 +00001036 DwarfWriter *DW = getAnalysisIfAvailable<DwarfWriter>();
Devang Pateleb3fc282009-01-08 23:40:34 +00001037 DW->EndModule();
Anton Korobeynikov75b68822008-06-28 11:08:27 +00001038 }
1039
1040 return AsmPrinter::doFinalization(M);
1041}
1042
Chris Lattnerb36cbd02005-07-01 22:44:09 +00001043// Include the auto-generated portion of the assembly writer.
1044#include "X86GenAsmWriter.inc"