blob: 72958cb568271a290119602fe0590fd88c44186f [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"
Devang Patele4c0c0f2009-06-25 00:47:42 +000026#include "llvm/MDNode.h"
Anton Korobeynikov75b68822008-06-28 11:08:27 +000027#include "llvm/Type.h"
28#include "llvm/ADT/Statistic.h"
29#include "llvm/ADT/StringExtras.h"
Chris Lattner40e3c7a2009-06-24 05:46:28 +000030#include "llvm/MC/MCContext.h"
Chris Lattner475370b2009-06-19 00:47:33 +000031#include "llvm/MC/MCInst.h"
Chris Lattner40e3c7a2009-06-24 05:46:28 +000032#include "llvm/MC/MCStreamer.h"
Bill Wendlingcb819f12009-02-18 23:12:06 +000033#include "llvm/CodeGen/DwarfWriter.h"
Anton Korobeynikov75b68822008-06-28 11:08:27 +000034#include "llvm/CodeGen/MachineJumpTableInfo.h"
Chris Lattner475370b2009-06-19 00:47:33 +000035#include "llvm/Support/CommandLine.h"
Chris Lattnerb36cbd02005-07-01 22:44:09 +000036#include "llvm/Support/Mangler.h"
Owen Andersoncb371882008-08-21 00:14:44 +000037#include "llvm/Support/raw_ostream.h"
Jim Laskeya0f3d172006-09-07 22:06:40 +000038#include "llvm/Target/TargetAsmInfo.h"
Evan Cheng7ccced62006-02-18 00:15:05 +000039#include "llvm/Target/TargetOptions.h"
Chris Lattnerb36cbd02005-07-01 22:44:09 +000040using namespace llvm;
Chris Lattnerb36cbd02005-07-01 22:44:09 +000041
Chris Lattner95b2c7d2006-12-19 22:59:26 +000042STATISTIC(EmittedInsts, "Number of machine instrs printed");
43
Chris Lattner475370b2009-06-19 00:47:33 +000044static cl::opt<bool> NewAsmPrinter("experimental-asm-printer",
45 cl::Hidden);
46
Chris Lattnerab162992009-06-24 19:44:36 +000047//===----------------------------------------------------------------------===//
48// Primitive Helper Functions.
49//===----------------------------------------------------------------------===//
Chris Lattnerb5299dd2009-06-24 19:19:16 +000050
51void X86ATTAsmPrinter::PrintPICBaseSymbol() const {
Evan Cheng071b9d52007-01-18 01:49:58 +000052 if (Subtarget->isTargetDarwin())
Chris Lattnerb5299dd2009-06-24 19:19:16 +000053 O << "\"L" << getFunctionNumber() << "$pb\"";
Evan Cheng071b9d52007-01-18 01:49:58 +000054 else if (Subtarget->isTargetELF())
Chris Lattner8529d282009-07-08 23:09:14 +000055 O << ".Lllvm$" << getFunctionNumber() << ".$piclabel";
Evan Cheng071b9d52007-01-18 01:49:58 +000056 else
Anton Korobeynikov7f705592007-01-12 19:20:47 +000057 assert(0 && "Don't know how to print PIC label!\n");
Anton Korobeynikov7f705592007-01-12 19:20:47 +000058}
59
Chris Lattnerab162992009-06-24 19:44:36 +000060/// PrintUnmangledNameSafely - Print out the printable characters in the name.
61/// Don't print things like \\n or \\0.
62static void PrintUnmangledNameSafely(const Value *V, raw_ostream &OS) {
63 for (const char *Name = V->getNameStart(), *E = Name+V->getNameLen();
64 Name != E; ++Name)
65 if (isprint(*Name))
66 OS << *Name;
67}
Chris Lattnerb5299dd2009-06-24 19:19:16 +000068
Anton Korobeynikov75b68822008-06-28 11:08:27 +000069static X86MachineFunctionInfo calculateFunctionInfo(const Function *F,
70 const TargetData *TD) {
71 X86MachineFunctionInfo Info;
72 uint64_t Size = 0;
73
74 switch (F->getCallingConv()) {
75 case CallingConv::X86_StdCall:
76 Info.setDecorationStyle(StdCall);
77 break;
78 case CallingConv::X86_FastCall:
79 Info.setDecorationStyle(FastCall);
80 break;
81 default:
82 return Info;
83 }
84
85 unsigned argNum = 1;
86 for (Function::const_arg_iterator AI = F->arg_begin(), AE = F->arg_end();
87 AI != AE; ++AI, ++argNum) {
88 const Type* Ty = AI->getType();
89
90 // 'Dereference' type in case of byval parameter attribute
Devang Patel05988662008-09-25 21:00:45 +000091 if (F->paramHasAttr(argNum, Attribute::ByVal))
Anton Korobeynikov75b68822008-06-28 11:08:27 +000092 Ty = cast<PointerType>(Ty)->getElementType();
93
94 // Size should be aligned to DWORD boundary
Duncan Sands777d2302009-05-09 07:06:46 +000095 Size += ((TD->getTypeAllocSize(Ty) + 3)/4)*4;
Anton Korobeynikov75b68822008-06-28 11:08:27 +000096 }
97
98 // We're not supporting tooooo huge arguments :)
99 Info.setBytesToPopOnReturn((unsigned int)Size);
100 return Info;
101}
102
Anton Korobeynikov75b68822008-06-28 11:08:27 +0000103/// decorateName - Query FunctionInfoMap and use this information for various
104/// name decoration.
105void X86ATTAsmPrinter::decorateName(std::string &Name,
106 const GlobalValue *GV) {
107 const Function *F = dyn_cast<Function>(GV);
108 if (!F) return;
109
110 // We don't want to decorate non-stdcall or non-fastcall functions right now
111 unsigned CC = F->getCallingConv();
112 if (CC != CallingConv::X86_StdCall && CC != CallingConv::X86_FastCall)
113 return;
114
115 // Decorate names only when we're targeting Cygwin/Mingw32 targets
116 if (!Subtarget->isTargetCygMing())
117 return;
118
119 FMFInfoMap::const_iterator info_item = FunctionInfoMap.find(F);
120
121 const X86MachineFunctionInfo *Info;
122 if (info_item == FunctionInfoMap.end()) {
123 // Calculate apropriate function info and populate map
124 FunctionInfoMap[F] = calculateFunctionInfo(F, TM.getTargetData());
125 Info = &FunctionInfoMap[F];
126 } else {
127 Info = &info_item->second;
128 }
129
130 const FunctionType *FT = F->getFunctionType();
131 switch (Info->getDecorationStyle()) {
132 case None:
133 break;
134 case StdCall:
135 // "Pure" variadic functions do not receive @0 suffix.
136 if (!FT->isVarArg() || (FT->getNumParams() == 0) ||
137 (FT->getNumParams() == 1 && F->hasStructRetAttr()))
138 Name += '@' + utostr_32(Info->getBytesToPopOnReturn());
139 break;
140 case FastCall:
141 // "Pure" variadic functions do not receive @0 suffix.
142 if (!FT->isVarArg() || (FT->getNumParams() == 0) ||
143 (FT->getNumParams() == 1 && F->hasStructRetAttr()))
144 Name += '@' + utostr_32(Info->getBytesToPopOnReturn());
145
146 if (Name[0] == '_') {
147 Name[0] = '@';
148 } else {
149 Name = '@' + Name;
150 }
151 break;
152 default:
153 assert(0 && "Unsupported DecorationStyle");
154 }
155}
156
Anton Korobeynikov1ecf0ee2008-06-28 11:09:01 +0000157void X86ATTAsmPrinter::emitFunctionHeader(const MachineFunction &MF) {
Bill Wendling20c568f2009-06-30 22:38:32 +0000158 unsigned FnAlign = MF.getAlignment();
Evan Cheng2338c5c2006-02-07 08:38:37 +0000159 const Function *F = MF.getFunction();
Anton Korobeynikovf8248682006-09-20 22:03:51 +0000160
Anton Korobeynikov75b68822008-06-28 11:08:27 +0000161 decorateName(CurrentFnName, F);
Anton Korobeynikovf8248682006-09-20 22:03:51 +0000162
Anton Korobeynikovc25e1ea2008-09-24 22:14:23 +0000163 SwitchToSection(TAI->SectionForGlobal(F));
Evan Cheng2338c5c2006-02-07 08:38:37 +0000164 switch (F->getLinkage()) {
165 default: assert(0 && "Unknown linkage type!");
166 case Function::InternalLinkage: // Symbols default to internal.
Rafael Espindolabb46f522009-01-15 20:18:42 +0000167 case Function::PrivateLinkage:
Evan Chenge22e62b2008-03-25 22:29:46 +0000168 EmitAlignment(FnAlign, F);
Evan Cheng2338c5c2006-02-07 08:38:37 +0000169 break;
Anton Korobeynikovb74ed072006-09-14 18:23:27 +0000170 case Function::DLLExportLinkage:
Evan Cheng2338c5c2006-02-07 08:38:37 +0000171 case Function::ExternalLinkage:
Evan Chenge22e62b2008-03-25 22:29:46 +0000172 EmitAlignment(FnAlign, F);
Dan Gohmand19a53b2008-06-30 22:03:41 +0000173 O << "\t.globl\t" << CurrentFnName << '\n';
Evan Cheng2338c5c2006-02-07 08:38:37 +0000174 break;
Duncan Sands667d4b82009-03-07 15:45:40 +0000175 case Function::LinkOnceAnyLinkage:
176 case Function::LinkOnceODRLinkage:
177 case Function::WeakAnyLinkage:
178 case Function::WeakODRLinkage:
Evan Chenge22e62b2008-03-25 22:29:46 +0000179 EmitAlignment(FnAlign, F);
Jim Laskeyea348582006-07-27 02:05:13 +0000180 if (Subtarget->isTargetDarwin()) {
Dan Gohmand19a53b2008-06-30 22:03:41 +0000181 O << "\t.globl\t" << CurrentFnName << '\n';
182 O << TAI->getWeakDefDirective() << CurrentFnName << '\n';
Anton Korobeynikov317848f2007-01-03 11:43:14 +0000183 } else if (Subtarget->isTargetCygMing()) {
Dan Gohmand19a53b2008-06-30 22:03:41 +0000184 O << "\t.globl\t" << CurrentFnName << "\n"
185 "\t.linkonce discard\n";
Anton Korobeynikovb7188b12006-10-17 20:29:49 +0000186 } else {
Dan Gohmand19a53b2008-06-30 22:03:41 +0000187 O << "\t.weak\t" << CurrentFnName << '\n';
Anton Korobeynikovb7188b12006-10-17 20:29:49 +0000188 }
189 break;
Evan Cheng2338c5c2006-02-07 08:38:37 +0000190 }
Anton Korobeynikovf5b6a472008-08-08 18:25:07 +0000191
192 printVisibility(CurrentFnName, F->getVisibility());
Anton Korobeynikovd05ca652007-01-16 16:41:57 +0000193
194 if (Subtarget->isTargetELF())
Dan Gohman825811d2007-07-30 15:08:02 +0000195 O << "\t.type\t" << CurrentFnName << ",@function\n";
Anton Korobeynikovd05ca652007-01-16 16:41:57 +0000196 else if (Subtarget->isTargetCygMing()) {
197 O << "\t.def\t " << CurrentFnName
198 << ";\t.scl\t" <<
Rafael Espindolabb46f522009-01-15 20:18:42 +0000199 (F->hasInternalLinkage() ? COFF::C_STAT : COFF::C_EXT)
Anton Korobeynikovd05ca652007-01-16 16:41:57 +0000200 << ";\t.type\t" << (COFF::DT_FCN << COFF::N_BTSHFT)
201 << ";\t.endef\n";
202 }
203
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000204 O << CurrentFnName << ":\n";
Anton Korobeynikovb1c88022006-10-18 09:12:29 +0000205 // Add some workaround for linkonce linkage on Cygwin\MinGW
Anton Korobeynikov317848f2007-01-03 11:43:14 +0000206 if (Subtarget->isTargetCygMing() &&
Duncan Sands667d4b82009-03-07 15:45:40 +0000207 (F->hasLinkOnceLinkage() || F->hasWeakLinkage()))
Anton Korobeynikov7f705592007-01-12 19:20:47 +0000208 O << "Lllvm$workaround$fake$stub$" << CurrentFnName << ":\n";
Anton Korobeynikov1ecf0ee2008-06-28 11:09:01 +0000209}
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000210
Anton Korobeynikov1ecf0ee2008-06-28 11:09:01 +0000211/// runOnMachineFunction - This uses the printMachineInstruction()
212/// method to print assembly for each instruction.
213///
214bool X86ATTAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
215 const Function *F = MF.getFunction();
Bill Wendlingac06d002009-02-06 21:45:08 +0000216 this->MF = &MF;
Anton Korobeynikov1ecf0ee2008-06-28 11:09:01 +0000217 unsigned CC = F->getCallingConv();
218
Anton Korobeynikov1ecf0ee2008-06-28 11:09:01 +0000219 SetupMachineFunction(MF);
220 O << "\n\n";
221
222 // Populate function information map. Actually, We don't want to populate
223 // non-stdcall or non-fastcall functions' information right now.
224 if (CC == CallingConv::X86_StdCall || CC == CallingConv::X86_FastCall)
225 FunctionInfoMap[F] = *MF.getInfo<X86MachineFunctionInfo>();
226
227 // Print out constants referenced by the function
228 EmitConstantPool(MF.getConstantPool());
229
230 if (F->hasDLLExportLinkage())
231 DLLExportedFns.insert(Mang->makeNameProper(F->getName(), ""));
232
233 // Print the 'header' of function
234 emitFunctionHeader(MF);
235
236 // Emit pre-function debug and/or EH information.
237 if (TAI->doesSupportDebugInformation() || TAI->doesSupportExceptionHandling())
Devang Pateleb3fc282009-01-08 23:40:34 +0000238 DW->BeginFunction(&MF);
Anton Korobeynikov1ecf0ee2008-06-28 11:09:01 +0000239
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000240 // Print out code for the function.
Dale Johannesenf2247cf2008-04-08 00:37:56 +0000241 bool hasAnyRealCode = false;
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000242 for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
243 I != E; ++I) {
244 // Print a label for the basic block.
Dan Gohman968dc7a2009-03-31 18:39:13 +0000245 if (!VerboseAsm && (I->pred_empty() || I->isOnlyReachableByFallthrough())) {
246 // This is an entry block or a block that's only reachable via a
247 // fallthrough edge. In non-VerboseAsm mode, don't print the label.
248 } else {
Evan Chengf1c0ae92009-03-24 00:17:40 +0000249 printBasicBlockLabel(I, true, true, VerboseAsm);
Nate Begemancdf38c42006-05-02 05:37:32 +0000250 O << '\n';
251 }
Bill Wendling824a7212008-01-26 09:03:52 +0000252 for (MachineBasicBlock::const_iterator II = I->begin(), IE = I->end();
253 II != IE; ++II) {
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000254 // Print the assembly for the instruction.
Dan Gohman44066042008-07-01 00:05:16 +0000255 if (!II->isLabel())
Dale Johannesenf2247cf2008-04-08 00:37:56 +0000256 hasAnyRealCode = true;
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000257 printMachineInstruction(II);
258 }
259 }
Evan Cheng67afece2006-08-28 22:14:16 +0000260
Dale Johannesenf2247cf2008-04-08 00:37:56 +0000261 if (Subtarget->isTargetDarwin() && !hasAnyRealCode) {
262 // If the function is empty, then we need to emit *something*. Otherwise,
263 // the function's label might be associated with something that it wasn't
264 // meant to be associated with. We emit a noop in this situation.
265 // We are assuming inline asms are code.
266 O << "\tnop\n";
267 }
268
Jim Laskey563321a2006-09-06 18:34:40 +0000269 if (TAI->hasDotTypeDotSizeDirective())
Dan Gohmand19a53b2008-06-30 22:03:41 +0000270 O << "\t.size\t" << CurrentFnName << ", .-" << CurrentFnName << '\n';
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000271
Anton Korobeynikov1ecf0ee2008-06-28 11:09:01 +0000272 // Emit post-function debug information.
Devang Patel5090f192009-06-19 23:21:20 +0000273 if (TAI->doesSupportDebugInformation() || TAI->doesSupportExceptionHandling())
Devang Pateleb3fc282009-01-08 23:40:34 +0000274 DW->EndFunction(&MF);
Evan Cheng3c992d22006-03-07 02:02:57 +0000275
Anton Korobeynikov2a07e2f2007-05-05 09:04:50 +0000276 // Print out jump tables referenced by the function.
277 EmitJumpTableInfo(MF.getJumpTableInfo(), MF);
Anton Korobeynikov91364382008-06-28 11:08:09 +0000278
Dan Gohmane5f4de42008-11-07 19:49:17 +0000279 O.flush();
280
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000281 // We didn't modify anything.
282 return false;
283}
284
Chris Lattner7680e732009-06-20 19:34:09 +0000285/// print_pcrel_imm - This is used to print an immediate value that ends up
286/// being encoded as a pc-relative value. These print slightly differently, for
287/// example, a $ is not emitted.
288void X86ATTAsmPrinter::print_pcrel_imm(const MachineInstr *MI, unsigned OpNo) {
289 const MachineOperand &MO = MI->getOperand(OpNo);
290 switch (MO.getType()) {
291 default: assert(0 && "Unknown pcrel immediate operand");
292 case MachineOperand::MO_Immediate:
293 O << MO.getImm();
294 return;
295 case MachineOperand::MO_MachineBasicBlock:
296 printBasicBlockLabel(MO.getMBB(), false, false, VerboseAsm);
297 return;
298
299 case MachineOperand::MO_GlobalAddress: {
300 const GlobalValue *GV = MO.getGlobal();
301 std::string Name = Mang->getValueName(GV);
302 decorateName(Name, GV);
303
304 bool needCloseParen = false;
305 if (Name[0] == '$') {
306 // The name begins with a dollar-sign. In order to avoid having it look
307 // like an integer immediate to the assembler, enclose it in parens.
308 O << '(';
309 needCloseParen = true;
310 }
311
Chris Lattnerfb37d952009-07-09 04:43:12 +0000312 if (Subtarget->isPICStyleStub()) {
Chris Lattner2b0de6a2009-06-25 17:58:52 +0000313 // DARWIN/X86-32 in != static mode.
314
Chris Lattner7680e732009-06-20 19:34:09 +0000315 // Link-once, declaration, or Weakly-linked global variables need
316 // non-lazily-resolved stubs
317 if (GV->isDeclaration() || GV->isWeakForLinker()) {
318 // Dynamically-resolved functions need a stub for the function.
319 if (isa<Function>(GV)) {
320 // Function stubs are no longer needed for Mac OS X 10.5 and up.
321 if (Subtarget->isTargetDarwin() && Subtarget->getDarwinVers() >= 9) {
322 O << Name;
323 } else {
324 FnStubs.insert(Name);
325 printSuffixedName(Name, "$stub");
326 }
Chris Lattner033bcee2009-07-09 00:47:59 +0000327 assert(MO.getTargetFlags() == 0);
Chris Lattner7680e732009-06-20 19:34:09 +0000328 } else if (GV->hasHiddenVisibility()) {
329 if (!GV->isDeclaration() && !GV->hasCommonLinkage())
330 // Definition is not definitely in the current translation unit.
331 O << Name;
332 else {
333 HiddenGVStubs.insert(Name);
334 printSuffixedName(Name, "$non_lazy_ptr");
Chris Lattner033bcee2009-07-09 00:47:59 +0000335 assert(MO.getTargetFlags() == 0);
Chris Lattner7680e732009-06-20 19:34:09 +0000336 }
337 } else {
338 GVStubs.insert(Name);
339 printSuffixedName(Name, "$non_lazy_ptr");
Chris Lattner033bcee2009-07-09 00:47:59 +0000340 assert(MO.getTargetFlags() == 0);
Chris Lattner7680e732009-06-20 19:34:09 +0000341 }
342 } else {
Chris Lattner7680e732009-06-20 19:34:09 +0000343 O << Name;
344 }
345 } else {
Chris Lattner4aa21aa2009-07-09 00:58:53 +0000346 // Handle dllimport linkage.
347 if (MO.getTargetFlags() == X86II::MO_DLLIMPORT)
Chris Lattner7680e732009-06-20 19:34:09 +0000348 O << "__imp_";
Chris Lattner7680e732009-06-20 19:34:09 +0000349 O << Name;
350
Chris Lattner48a7d022009-07-09 05:02:21 +0000351 // Assemble call via PLT for externally visible symbols.
352 if (MO.getTargetFlags() == X86II::MO_PLT)
353 O << "@PLT";
Chris Lattner48a7d022009-07-09 05:02:21 +0000354
Chris Lattner7680e732009-06-20 19:34:09 +0000355 if (Subtarget->isTargetCygMing() && GV->isDeclaration())
356 // Save function name for later type emission
Chris Lattner1ebd3bf2009-07-09 05:09:24 +0000357 CygMingStubs.insert(Name);
Chris Lattner7680e732009-06-20 19:34:09 +0000358 }
359
Chris Lattner7680e732009-06-20 19:34:09 +0000360 printOffset(MO.getOffset());
361
362 if (needCloseParen)
363 O << ')';
364 return;
365 }
366
367 case MachineOperand::MO_ExternalSymbol: {
368 bool needCloseParen = false;
369 std::string Name(TAI->getGlobalPrefix());
370 Name += MO.getSymbolName();
371 // Print function stub suffix unless it's Mac OS X 10.5 and up.
Chris Lattnerfb37d952009-07-09 04:43:12 +0000372 if (Subtarget->isPICStyleStub() &&
Chris Lattner2b0de6a2009-06-25 17:58:52 +0000373 // DARWIN/X86-32 in != static mode.
Chris Lattnerfb37d952009-07-09 04:43:12 +0000374 Subtarget->getDarwinVers() < 9) {
Chris Lattner7680e732009-06-20 19:34:09 +0000375 FnStubs.insert(Name);
376 printSuffixedName(Name, "$stub");
377 return;
378 }
379
380 if (Name[0] == '$') {
381 // The name begins with a dollar-sign. In order to avoid having it look
382 // like an integer immediate to the assembler, enclose it in parens.
383 O << '(';
384 needCloseParen = true;
385 }
386
387 O << Name;
388
Chris Lattnerac5e8872009-06-25 17:38:33 +0000389 if (MO.getTargetFlags() == X86II::MO_GOT_ABSOLUTE_ADDRESS) {
390 O << " + [.-";
391 PrintPICBaseSymbol();
392 O << ']';
Chris Lattner7680e732009-06-20 19:34:09 +0000393 }
394
Chris Lattner48a7d022009-07-09 05:02:21 +0000395 if (MO.getTargetFlags() == X86II::MO_PLT)
Chris Lattnerac5e8872009-06-25 17:38:33 +0000396 O << "@PLT";
397
Chris Lattner7680e732009-06-20 19:34:09 +0000398 if (needCloseParen)
399 O << ')';
400
401 return;
402 }
403 }
404}
405
Chris Lattnera3b8c572006-02-06 23:41:19 +0000406void X86ATTAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
Chris Lattner18c59872009-06-27 04:16:01 +0000407 const char *Modifier) {
Chris Lattnera3b8c572006-02-06 23:41:19 +0000408 const MachineOperand &MO = MI->getOperand(OpNo);
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000409 switch (MO.getType()) {
Chris Lattnerf7789c72009-06-27 05:46:24 +0000410 default: assert(0 && "unknown operand type!");
Evan Cheng8f7f7122006-05-05 05:40:20 +0000411 case MachineOperand::MO_Register: {
Dan Gohman6f0d0242008-02-10 18:45:23 +0000412 assert(TargetRegisterInfo::isPhysicalRegister(MO.getReg()) &&
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000413 "Virtual registers should not make it this far!");
414 O << '%';
Evan Cheng8f7f7122006-05-05 05:40:20 +0000415 unsigned Reg = MO.getReg();
Evan Chengcbe70e12006-05-31 22:34:26 +0000416 if (Modifier && strncmp(Modifier, "subreg", strlen("subreg")) == 0) {
Duncan Sands83ec4b62008-06-06 12:08:01 +0000417 MVT VT = (strcmp(Modifier+6,"64") == 0) ?
Evan Cheng25ab6902006-09-08 06:48:29 +0000418 MVT::i64 : ((strcmp(Modifier+6, "32") == 0) ? MVT::i32 :
419 ((strcmp(Modifier+6,"16") == 0) ? MVT::i16 : MVT::i8));
Evan Cheng8f7f7122006-05-05 05:40:20 +0000420 Reg = getX86SubSuperRegister(Reg, VT);
421 }
Evan Chengae270f62008-07-07 22:21:06 +0000422 O << TRI->getAsmName(Reg);
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000423 return;
Evan Cheng8f7f7122006-05-05 05:40:20 +0000424 }
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000425
Chris Lattner63b3d712006-05-04 17:21:20 +0000426 case MachineOperand::MO_Immediate:
Chris Lattner44f7bbd2009-07-09 00:39:19 +0000427 if (!Modifier || (strcmp(Modifier, "debug") && strcmp(Modifier, "mem")))
Evan Cheng3c992d22006-03-07 02:02:57 +0000428 O << '$';
Chris Lattner9a1ceae2007-12-30 20:49:49 +0000429 O << MO.getImm();
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000430 return;
Nate Begeman37efe672006-04-22 18:53:45 +0000431 case MachineOperand::MO_JumpTableIndex: {
Chris Lattner44f7bbd2009-07-09 00:39:19 +0000432 bool isMemOp = Modifier && !strcmp(Modifier, "mem");
Nate Begeman37efe672006-04-22 18:53:45 +0000433 if (!isMemOp) O << '$';
Dan Gohmand19a53b2008-06-30 22:03:41 +0000434 O << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber() << '_'
Chris Lattner8aa797a2007-12-30 23:10:15 +0000435 << MO.getIndex();
Chris Lattnerf7789c72009-06-27 05:46:24 +0000436 break;
Nate Begeman37efe672006-04-22 18:53:45 +0000437 }
Evan Chenga09bd812006-02-26 08:28:12 +0000438 case MachineOperand::MO_ConstantPoolIndex: {
Chris Lattner44f7bbd2009-07-09 00:39:19 +0000439 bool isMemOp = Modifier && !strcmp(Modifier, "mem");
Evan Chenga09bd812006-02-26 08:28:12 +0000440 if (!isMemOp) O << '$';
Dan Gohmand19a53b2008-06-30 22:03:41 +0000441 O << TAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << '_'
Chris Lattner8aa797a2007-12-30 23:10:15 +0000442 << MO.getIndex();
Anton Korobeynikov7f705592007-01-12 19:20:47 +0000443
Chris Lattner03a597f2009-06-26 20:00:05 +0000444 printOffset(MO.getOffset());
Chris Lattnerf7789c72009-06-27 05:46:24 +0000445 break;
Evan Chenga09bd812006-02-26 08:28:12 +0000446 }
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000447 case MachineOperand::MO_GlobalAddress: {
Chris Lattner44f7bbd2009-07-09 00:39:19 +0000448 bool isMemOp = Modifier && !strcmp(Modifier, "mem");
Anton Korobeynikov4d86e2a2008-03-11 22:38:53 +0000449 const GlobalValue *GV = MO.getGlobal();
Evan Cheng25ab6902006-09-08 06:48:29 +0000450 std::string Name = Mang->getValueName(GV);
Anton Korobeynikov75b68822008-06-28 11:08:27 +0000451 decorateName(Name, GV);
Anton Korobeynikov91364382008-06-28 11:08:09 +0000452
Chris Lattnerf7789c72009-06-27 05:46:24 +0000453 bool needCloseParen = false;
Chris Lattner7680e732009-06-20 19:34:09 +0000454 if (!isMemOp)
Dan Gohman2a3250c2007-04-26 21:07:05 +0000455 O << '$';
456 else if (Name[0] == '$') {
457 // The name begins with a dollar-sign. In order to avoid having it look
458 // like an integer immediate to the assembler, enclose it in parens.
459 O << '(';
460 needCloseParen = true;
461 }
462
Chris Lattnerfb37d952009-07-09 04:43:12 +0000463 if (Subtarget->isPICStyleStub()) {
Chris Lattner2b0de6a2009-06-25 17:58:52 +0000464 // DARWIN/X86-32 in != static mode.
465
Evan Cheng111354f2007-06-04 18:54:57 +0000466 // Link-once, declaration, or Weakly-linked global variables need
Evan Cheng2338c5c2006-02-07 08:38:37 +0000467 // non-lazily-resolved stubs
Duncan Sands667d4b82009-03-07 15:45:40 +0000468 if (GV->isDeclaration() || GV->isWeakForLinker()) {
Chris Lattner44f7bbd2009-07-09 00:39:19 +0000469 if (GV->hasHiddenVisibility()) {
Evan Chengae94e592008-12-05 01:06:39 +0000470 if (!GV->isDeclaration() && !GV->hasCommonLinkage())
471 // Definition is not definitely in the current translation unit.
472 O << Name;
473 else {
474 HiddenGVStubs.insert(Name);
475 printSuffixedName(Name, "$non_lazy_ptr");
Chris Lattner9f44b3a2009-07-09 00:27:29 +0000476 assert(MO.getTargetFlags() == 0);
Evan Chengae94e592008-12-05 01:06:39 +0000477 }
Evan Cheng2338c5c2006-02-07 08:38:37 +0000478 } else {
479 GVStubs.insert(Name);
Dale Johannesenc215b3e2008-05-19 21:38:18 +0000480 printSuffixedName(Name, "$non_lazy_ptr");
Chris Lattner9f44b3a2009-07-09 00:27:29 +0000481 assert(MO.getTargetFlags() == 0);
Evan Cheng2338c5c2006-02-07 08:38:37 +0000482 }
Anton Korobeynikovb74ed072006-09-14 18:23:27 +0000483 } else {
Evan Cheng25ab6902006-09-08 06:48:29 +0000484 O << Name;
Anton Korobeynikovb74ed072006-09-14 18:23:27 +0000485 }
Anton Korobeynikov91364382008-06-28 11:08:09 +0000486
Chris Lattner44f7bbd2009-07-09 00:39:19 +0000487 if (TM.getRelocationModel() == Reloc::PIC_) {
Chris Lattnerb5299dd2009-06-24 19:19:16 +0000488 O << '-';
489 PrintPICBaseSymbol();
490 }
Anton Korobeynikovb74ed072006-09-14 18:23:27 +0000491 } else {
Chris Lattner4aa21aa2009-07-09 00:58:53 +0000492 // Handle dllimport linkage.
493 if (MO.getTargetFlags() == X86II::MO_DLLIMPORT)
Anton Korobeynikov91364382008-06-28 11:08:09 +0000494 O << "__imp_";
Evan Cheng25ab6902006-09-08 06:48:29 +0000495 O << Name;
Anton Korobeynikovb74ed072006-09-14 18:23:27 +0000496 }
Anton Korobeynikov78ee7b72006-12-01 00:25:12 +0000497
Anton Korobeynikov7751ad92008-11-22 16:15:34 +0000498 printOffset(MO.getOffset());
Evan Cheng25ab6902006-09-08 06:48:29 +0000499
Chris Lattnere3723332009-06-21 02:22:53 +0000500 if (needCloseParen)
501 O << ')';
502
Chris Lattnerf7789c72009-06-27 05:46:24 +0000503 break;
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000504 }
Chris Lattnerf7789c72009-06-27 05:46:24 +0000505 case MachineOperand::MO_ExternalSymbol:
Chris Lattnerd8220e52009-06-26 21:47:27 +0000506 /// NOTE: MO_ExternalSymbol in a non-pcrel_imm context is *only* generated
507 /// by _GLOBAL_OFFSET_TABLE_ on X86-32. All others are call operands, which
508 /// are pcrel_imm's.
509 assert(!Subtarget->is64Bit() && !Subtarget->isPICStyleRIPRel());
510 // These are never used as memory operands.
Chris Lattner44f7bbd2009-07-09 00:39:19 +0000511 assert(Modifier == 0 || strcmp(Modifier, "mem"));
Chris Lattnerd8220e52009-06-26 21:47:27 +0000512 O << '$';
513 O << TAI->getGlobalPrefix();
514 O << MO.getSymbolName();
Chris Lattnerf7789c72009-06-27 05:46:24 +0000515 break;
Chris Lattnera3b8c572006-02-06 23:41:19 +0000516 }
Chris Lattnerf7789c72009-06-27 05:46:24 +0000517
518 switch (MO.getTargetFlags()) {
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000519 default:
Chris Lattnerf7789c72009-06-27 05:46:24 +0000520 assert(0 && "Unknown target flag on GV operand");
Chris Lattner4aa21aa2009-07-09 00:58:53 +0000521 case X86II::MO_NO_FLAG: // No flag.
522 case X86II::MO_DLLIMPORT: // Prefix, not a suffix.
Chris Lattnerf7789c72009-06-27 05:46:24 +0000523 break;
524 case X86II::MO_GOT_ABSOLUTE_ADDRESS:
525 O << " + [.-";
526 PrintPICBaseSymbol();
527 O << ']';
528 break;
529 case X86II::MO_PIC_BASE_OFFSET:
530 O << '-';
531 PrintPICBaseSymbol();
532 break;
533 case X86II::MO_TLSGD: O << "@TLSGD"; break;
534 case X86II::MO_GOTTPOFF: O << "@GOTTPOFF"; break;
535 case X86II::MO_INDNTPOFF: O << "@INDNTPOFF"; break;
536 case X86II::MO_TPOFF: O << "@TPOFF"; break;
537 case X86II::MO_NTPOFF: O << "@NTPOFF"; break;
538 case X86II::MO_GOTPCREL: O << "@GOTPCREL"; break;
539 case X86II::MO_GOT: O << "@GOT"; break;
540 case X86II::MO_GOTOFF: O << "@GOTOFF"; break;
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000541 }
542}
543
Nate Begeman391c5d22005-11-30 18:54:35 +0000544void X86ATTAsmPrinter::printSSECC(const MachineInstr *MI, unsigned Op) {
Chris Lattner9a1ceae2007-12-30 20:49:49 +0000545 unsigned char value = MI->getOperand(Op).getImm();
Nate Begeman6c7cb292005-07-14 22:52:25 +0000546 assert(value <= 7 && "Invalid ssecc argument!");
547 switch (value) {
548 case 0: O << "eq"; break;
549 case 1: O << "lt"; break;
550 case 2: O << "le"; break;
551 case 3: O << "unord"; break;
552 case 4: O << "neq"; break;
553 case 5: O << "nlt"; break;
554 case 6: O << "nle"; break;
555 case 7: O << "ord"; break;
556 }
557}
558
Rafael Espindola094fad32009-04-08 21:14:34 +0000559void X86ATTAsmPrinter::printLeaMemReference(const MachineInstr *MI, unsigned Op,
Chris Lattner18c59872009-06-27 04:16:01 +0000560 const char *Modifier) {
Chris Lattner9f44b3a2009-07-09 00:27:29 +0000561 const MachineOperand &BaseReg = MI->getOperand(Op);
562 const MachineOperand &IndexReg = MI->getOperand(Op+2);
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000563 const MachineOperand &DispSpec = MI->getOperand(Op+3);
564
Chris Lattner9f44b3a2009-07-09 00:27:29 +0000565 // If we really don't want to print out (rip), don't.
566 bool HasBaseReg = BaseReg.getReg() != 0;
567 if (HasBaseReg && Modifier && !strcmp(Modifier, "no-rip") &&
568 BaseReg.getReg() == X86::RIP)
569 HasBaseReg = false;
Chris Lattnerb172b0b2009-07-09 00:32:12 +0000570
571 // HasParenPart - True if we will print out the () part of the mem ref.
572 bool HasParenPart = IndexReg.getReg() || HasBaseReg;
573
574 if (DispSpec.isImm()) {
575 int DispVal = DispSpec.getImm();
576 if (DispVal || !HasParenPart)
577 O << DispVal;
578 } else {
579 assert(DispSpec.isGlobal() || DispSpec.isCPI() ||
580 DispSpec.isJTI() || DispSpec.isSymbol());
581 printOperand(MI, Op+3, "mem");
582 }
583
584 if (HasParenPart) {
Chris Lattner9f44b3a2009-07-09 00:27:29 +0000585 assert(IndexReg.getReg() != X86::ESP &&
586 "X86 doesn't allow scaling by ESP");
Anton Korobeynikov91364382008-06-28 11:08:09 +0000587
Dan Gohmand19a53b2008-06-30 22:03:41 +0000588 O << '(';
Chris Lattner9f44b3a2009-07-09 00:27:29 +0000589 if (HasBaseReg)
590 printOperand(MI, Op, Modifier);
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000591
592 if (IndexReg.getReg()) {
Dan Gohmand19a53b2008-06-30 22:03:41 +0000593 O << ',';
Chris Lattner9f44b3a2009-07-09 00:27:29 +0000594 printOperand(MI, Op+2, Modifier);
595 unsigned ScaleVal = MI->getOperand(Op+1).getImm();
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000596 if (ScaleVal != 1)
Dan Gohmand19a53b2008-06-30 22:03:41 +0000597 O << ',' << ScaleVal;
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000598 }
Dan Gohmand19a53b2008-06-30 22:03:41 +0000599 O << ')';
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000600 }
601}
602
Rafael Espindola094fad32009-04-08 21:14:34 +0000603void X86ATTAsmPrinter::printMemReference(const MachineInstr *MI, unsigned Op,
Chris Lattner18c59872009-06-27 04:16:01 +0000604 const char *Modifier) {
Rafael Espindola094fad32009-04-08 21:14:34 +0000605 assert(isMem(MI, Op) && "Invalid memory reference!");
Chris Lattner9f44b3a2009-07-09 00:27:29 +0000606 const MachineOperand &Segment = MI->getOperand(Op+4);
Rafael Espindola094fad32009-04-08 21:14:34 +0000607 if (Segment.getReg()) {
Chris Lattner9f44b3a2009-07-09 00:27:29 +0000608 printOperand(MI, Op+4, Modifier);
609 O << ':';
610 }
Chris Lattner18c59872009-06-27 04:16:01 +0000611 printLeaMemReference(MI, Op, Modifier);
Rafael Espindola094fad32009-04-08 21:14:34 +0000612}
613
Anton Korobeynikov91364382008-06-28 11:08:09 +0000614void X86ATTAsmPrinter::printPICJumpTableSetLabel(unsigned uid,
Evan Chengcc415862007-11-09 01:32:10 +0000615 const MachineBasicBlock *MBB) const {
616 if (!TAI->getSetDirective())
617 return;
Anton Korobeynikov9de19342007-11-14 09:18:41 +0000618
619 // We don't need .set machinery if we have GOT-style relocations
620 if (Subtarget->isPICStyleGOT())
621 return;
Anton Korobeynikov91364382008-06-28 11:08:09 +0000622
Evan Chengcc415862007-11-09 01:32:10 +0000623 O << TAI->getSetDirective() << ' ' << TAI->getPrivateGlobalPrefix()
624 << getFunctionNumber() << '_' << uid << "_set_" << MBB->getNumber() << ',';
Evan Chengfb8075d2008-02-28 00:43:03 +0000625 printBasicBlockLabel(MBB, false, false, false);
Evan Chenged2fc712007-11-09 19:11:23 +0000626 if (Subtarget->isPICStyleRIPRel())
Anton Korobeynikov91364382008-06-28 11:08:09 +0000627 O << '-' << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
Evan Chenged2fc712007-11-09 19:11:23 +0000628 << '_' << uid << '\n';
Chris Lattnerb5299dd2009-06-24 19:19:16 +0000629 else {
630 O << '-';
631 PrintPICBaseSymbol();
632 O << '\n';
633 }
Evan Chengcc415862007-11-09 01:32:10 +0000634}
635
Chris Lattnerb5299dd2009-06-24 19:19:16 +0000636
Evan Cheng7ccced62006-02-18 00:15:05 +0000637void X86ATTAsmPrinter::printPICLabel(const MachineInstr *MI, unsigned Op) {
Chris Lattnerb5299dd2009-06-24 19:19:16 +0000638 PrintPICBaseSymbol();
639 O << '\n';
640 PrintPICBaseSymbol();
641 O << ':';
Evan Cheng7ccced62006-02-18 00:15:05 +0000642}
643
Evan Cheng62f27002006-04-28 23:11:40 +0000644
Anton Korobeynikov9de19342007-11-14 09:18:41 +0000645void X86ATTAsmPrinter::printPICJumpTableEntry(const MachineJumpTableInfo *MJTI,
646 const MachineBasicBlock *MBB,
Anton Korobeynikov91364382008-06-28 11:08:09 +0000647 unsigned uid) const
648{
Anton Korobeynikov9de19342007-11-14 09:18:41 +0000649 const char *JTEntryDirective = MJTI->getEntrySize() == 4 ?
650 TAI->getData32bitsDirective() : TAI->getData64bitsDirective();
651
652 O << JTEntryDirective << ' ';
653
654 if (TM.getRelocationModel() == Reloc::PIC_) {
655 if (Subtarget->isPICStyleRIPRel() || Subtarget->isPICStyleStub()) {
656 O << TAI->getPrivateGlobalPrefix() << getFunctionNumber()
657 << '_' << uid << "_set_" << MBB->getNumber();
658 } else if (Subtarget->isPICStyleGOT()) {
Evan Chengfb8075d2008-02-28 00:43:03 +0000659 printBasicBlockLabel(MBB, false, false, false);
Anton Korobeynikov9de19342007-11-14 09:18:41 +0000660 O << "@GOTOFF";
661 } else
662 assert(0 && "Don't know how to print MBB label for this PIC mode");
663 } else
Evan Chengfb8075d2008-02-28 00:43:03 +0000664 printBasicBlockLabel(MBB, false, false, false);
Anton Korobeynikov9de19342007-11-14 09:18:41 +0000665}
666
Chris Lattner37710712009-06-15 04:42:32 +0000667bool X86ATTAsmPrinter::printAsmMRegister(const MachineOperand &MO, char Mode) {
Evan Cheng62f27002006-04-28 23:11:40 +0000668 unsigned Reg = MO.getReg();
Evan Cheng62f27002006-04-28 23:11:40 +0000669 switch (Mode) {
670 default: return true; // Unknown mode.
671 case 'b': // Print QImode register
Evan Cheng8f7f7122006-05-05 05:40:20 +0000672 Reg = getX86SubSuperRegister(Reg, MVT::i8);
Evan Cheng62f27002006-04-28 23:11:40 +0000673 break;
674 case 'h': // Print QImode high register
Evan Cheng8f7f7122006-05-05 05:40:20 +0000675 Reg = getX86SubSuperRegister(Reg, MVT::i8, true);
Evan Cheng62f27002006-04-28 23:11:40 +0000676 break;
677 case 'w': // Print HImode register
Evan Cheng8f7f7122006-05-05 05:40:20 +0000678 Reg = getX86SubSuperRegister(Reg, MVT::i16);
Evan Cheng62f27002006-04-28 23:11:40 +0000679 break;
680 case 'k': // Print SImode register
Evan Cheng8f7f7122006-05-05 05:40:20 +0000681 Reg = getX86SubSuperRegister(Reg, MVT::i32);
Evan Cheng62f27002006-04-28 23:11:40 +0000682 break;
Chris Lattnerfb7f3432007-10-29 03:09:07 +0000683 case 'q': // Print DImode register
684 Reg = getX86SubSuperRegister(Reg, MVT::i64);
685 break;
Evan Cheng62f27002006-04-28 23:11:40 +0000686 }
687
Evan Chengae270f62008-07-07 22:21:06 +0000688 O << '%'<< TRI->getAsmName(Reg);
Evan Cheng62f27002006-04-28 23:11:40 +0000689 return false;
690}
691
Evan Cheng3d48a902006-04-28 21:19:05 +0000692/// PrintAsmOperand - Print out an operand for an inline asm expression.
693///
Anton Korobeynikovf0302cd2008-06-28 11:09:48 +0000694bool X86ATTAsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
Anton Korobeynikov91364382008-06-28 11:08:09 +0000695 unsigned AsmVariant,
Evan Cheng3d48a902006-04-28 21:19:05 +0000696 const char *ExtraCode) {
697 // Does this asm operand have a single letter operand modifier?
698 if (ExtraCode && ExtraCode[0]) {
699 if (ExtraCode[1] != 0) return true; // Unknown modifier.
Anton Korobeynikov91364382008-06-28 11:08:09 +0000700
Evan Cheng3d48a902006-04-28 21:19:05 +0000701 switch (ExtraCode[0]) {
702 default: return true; // Unknown modifier.
Chris Lattnerb4828722007-01-25 02:53:24 +0000703 case 'c': // Don't print "$" before a global var name or constant.
Chris Lattner18c59872009-06-27 04:16:01 +0000704 printOperand(MI, OpNo, "mem");
Chris Lattner0d924992006-10-31 20:12:30 +0000705 return false;
Evan Cheng62f27002006-04-28 23:11:40 +0000706 case 'b': // Print QImode register
707 case 'h': // Print QImode high register
708 case 'w': // Print HImode register
709 case 'k': // Print SImode register
Chris Lattnerfb7f3432007-10-29 03:09:07 +0000710 case 'q': // Print DImode register
Dan Gohmand735b802008-10-03 15:45:36 +0000711 if (MI->getOperand(OpNo).isReg())
Chris Lattner14393522007-03-25 02:01:03 +0000712 return printAsmMRegister(MI->getOperand(OpNo), ExtraCode[0]);
713 printOperand(MI, OpNo);
714 return false;
Anton Korobeynikov91364382008-06-28 11:08:09 +0000715
Dale Johannesen9fcff042009-07-07 23:28:22 +0000716 case 'P': // This is the operand of a call, treat specially.
Chris Lattner44f7bbd2009-07-09 00:39:19 +0000717 print_pcrel_imm(MI, OpNo);
Chris Lattner7cd5e072007-03-25 01:44:57 +0000718 return false;
Evan Cheng2c2fb822009-06-26 22:00:19 +0000719
Dale Johannesen9fcff042009-07-07 23:28:22 +0000720 case 'n': { // Negate the immediate or print a '-' before the operand.
Evan Cheng2c2fb822009-06-26 22:00:19 +0000721 // Note: this is a temporary solution. It should be handled target
722 // independently as part of the 'MC' work.
723 const MachineOperand &MO = MI->getOperand(OpNo);
724 if (MO.isImm()) {
725 O << -MO.getImm();
726 return false;
727 }
728 O << '-';
729 }
Evan Cheng3d48a902006-04-28 21:19:05 +0000730 }
731 }
Anton Korobeynikov91364382008-06-28 11:08:09 +0000732
Evan Cheng3d48a902006-04-28 21:19:05 +0000733 printOperand(MI, OpNo);
734 return false;
735}
736
Anton Korobeynikov4d580652008-06-28 11:10:06 +0000737bool X86ATTAsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI,
Evan Cheng3d48a902006-04-28 21:19:05 +0000738 unsigned OpNo,
Anton Korobeynikov91364382008-06-28 11:08:09 +0000739 unsigned AsmVariant,
Evan Cheng3d48a902006-04-28 21:19:05 +0000740 const char *ExtraCode) {
Chris Lattnerfb7f3432007-10-29 03:09:07 +0000741 if (ExtraCode && ExtraCode[0]) {
742 if (ExtraCode[1] != 0) return true; // Unknown modifier.
Anton Korobeynikov91364382008-06-28 11:08:09 +0000743
Chris Lattnerfb7f3432007-10-29 03:09:07 +0000744 switch (ExtraCode[0]) {
745 default: return true; // Unknown modifier.
746 case 'b': // Print QImode register
747 case 'h': // Print QImode high register
748 case 'w': // Print HImode register
749 case 'k': // Print SImode register
750 case 'q': // Print SImode register
751 // These only apply to registers, ignore on mem.
752 break;
Chris Lattner91387de2009-01-23 22:33:40 +0000753 case 'P': // Don't print @PLT, but do print as memory.
Chris Lattner18c59872009-06-27 04:16:01 +0000754 printMemReference(MI, OpNo, "no-rip");
Chris Lattner91387de2009-01-23 22:33:40 +0000755 return false;
Chris Lattnerfb7f3432007-10-29 03:09:07 +0000756 }
757 }
Evan Cheng3d48a902006-04-28 21:19:05 +0000758 printMemReference(MI, OpNo);
759 return false;
760}
761
Chris Lattnerc1243062009-06-20 07:03:18 +0000762static void lower_lea64_32mem(MCInst *MI, unsigned OpNo) {
763 // Convert registers in the addr mode according to subreg64.
764 for (unsigned i = 0; i != 4; ++i) {
765 if (!MI->getOperand(i).isReg()) continue;
766
767 unsigned Reg = MI->getOperand(i).getReg();
768 if (Reg == 0) continue;
769
770 MI->getOperand(i).setReg(getX86SubSuperRegister(Reg, MVT::i64));
771 }
772}
773
Bill Wendlingac06d002009-02-06 21:45:08 +0000774/// printMachineInstruction -- Print out a single X86 LLVM instruction MI in
775/// AT&T syntax to the current output stream.
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000776///
777void X86ATTAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
778 ++EmittedInsts;
Evan Cheng67caa392006-01-26 02:27:43 +0000779
Chris Lattner475370b2009-06-19 00:47:33 +0000780 if (NewAsmPrinter) {
Chris Lattnerc1243062009-06-20 07:03:18 +0000781 if (MI->getOpcode() == TargetInstrInfo::INLINEASM) {
782 O << "\t";
783 printInlineAsm(MI);
784 return;
785 } else if (MI->isLabel()) {
786 printLabel(MI);
787 return;
788 } else if (MI->getOpcode() == TargetInstrInfo::DECLARE) {
789 printDeclare(MI);
790 return;
791 } else if (MI->getOpcode() == TargetInstrInfo::IMPLICIT_DEF) {
792 printImplicitDef(MI);
793 return;
794 }
795
Chris Lattnerd5fb7902009-06-19 23:59:57 +0000796 O << "NEW: ";
Chris Lattner475370b2009-06-19 00:47:33 +0000797 MCInst TmpInst;
Chris Lattnerf38c03af2009-06-20 00:49:26 +0000798
799 TmpInst.setOpcode(MI->getOpcode());
800
801 for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
802 const MachineOperand &MO = MI->getOperand(i);
803
804 MCOperand MCOp;
805 if (MO.isReg()) {
806 MCOp.MakeReg(MO.getReg());
807 } else if (MO.isImm()) {
808 MCOp.MakeImm(MO.getImm());
Chris Lattnerc1243062009-06-20 07:03:18 +0000809 } else if (MO.isMBB()) {
810 MCOp.MakeMBBLabel(getFunctionNumber(), MO.getMBB()->getNumber());
Chris Lattnerf38c03af2009-06-20 00:49:26 +0000811 } else {
812 assert(0 && "Unimp");
813 }
814
815 TmpInst.addOperand(MCOp);
816 }
817
Chris Lattnerdc479f62009-06-20 07:59:10 +0000818 switch (TmpInst.getOpcode()) {
819 case X86::LEA64_32r:
820 // Handle the 'subreg rewriting' for the lea64_32mem operand.
Chris Lattnerc1243062009-06-20 07:03:18 +0000821 lower_lea64_32mem(&TmpInst, 1);
Chris Lattnerdc479f62009-06-20 07:59:10 +0000822 break;
Chris Lattnerf38c03af2009-06-20 00:49:26 +0000823 }
824
Chris Lattner475370b2009-06-19 00:47:33 +0000825 // FIXME: Convert TmpInst.
Chris Lattnerd5fb7902009-06-19 23:59:57 +0000826 printInstruction(&TmpInst);
827 O << "OLD: ";
Chris Lattner475370b2009-06-19 00:47:33 +0000828 }
829
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000830 // Call the autogenerated instruction printer routines.
831 printInstruction(MI);
832}
833
Devang Patel66b4d3b2009-06-20 01:00:07 +0000834/// doInitialization
835bool X86ATTAsmPrinter::doInitialization(Module &M) {
Chris Lattner40e3c7a2009-06-24 05:46:28 +0000836 if (NewAsmPrinter) {
837 Context = new MCContext();
838 // FIXME: Send this to "O" instead of outs(). For now, we force it to
839 // stdout to make it easy to compare.
840 Streamer = createAsmStreamer(*Context, outs());
841 }
842
Devang Patel66b4d3b2009-06-20 01:00:07 +0000843 return AsmPrinter::doInitialization(M);
844}
845
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000846void X86ATTAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {
Anton Korobeynikov75b68822008-06-28 11:08:27 +0000847 const TargetData *TD = TM.getTargetData();
848
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000849 if (!GVar->hasInitializer())
850 return; // External global require no code
851
852 // Check to see if this is a special global used by LLVM, if so, emit it.
853 if (EmitSpecialLLVMGlobal(GVar)) {
854 if (Subtarget->isTargetDarwin() &&
855 TM.getRelocationModel() == Reloc::Static) {
856 if (GVar->getName() == "llvm.global_ctors")
857 O << ".reference .constructors_used\n";
858 else if (GVar->getName() == "llvm.global_dtors")
859 O << ".reference .destructors_used\n";
860 }
861 return;
862 }
863
864 std::string name = Mang->getValueName(GVar);
865 Constant *C = GVar->getInitializer();
Devang Patel0f05d222009-06-26 02:26:12 +0000866 if (isa<MDNode>(C) || isa<MDString>(C))
Devang Patele4c0c0f2009-06-25 00:47:42 +0000867 return;
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000868 const Type *Type = C->getType();
Duncan Sands777d2302009-05-09 07:06:46 +0000869 unsigned Size = TD->getTypeAllocSize(Type);
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000870 unsigned Align = TD->getPreferredAlignmentLog(GVar);
871
Anton Korobeynikovf5b6a472008-08-08 18:25:07 +0000872 printVisibility(name, GVar->getVisibility());
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000873
874 if (Subtarget->isTargetELF())
875 O << "\t.type\t" << name << ",@object\n";
876
Anton Korobeynikovc25e1ea2008-09-24 22:14:23 +0000877 SwitchToSection(TAI->SectionForGlobal(GVar));
Anton Korobeynikove87f52d2008-07-09 13:27:16 +0000878
Evan Chengcaa0c2c2009-02-18 02:19:52 +0000879 if (C->isNullValue() && !GVar->hasSection() &&
880 !(Subtarget->isTargetDarwin() &&
881 TAI->SectionKindForGlobal(GVar) == SectionKind::RODataMergeStr)) {
Anton Korobeynikove87f52d2008-07-09 13:27:16 +0000882 // FIXME: This seems to be pretty darwin-specific
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000883 if (GVar->hasExternalLinkage()) {
884 if (const char *Directive = TAI->getZeroFillDirective()) {
Dan Gohmand19a53b2008-06-30 22:03:41 +0000885 O << "\t.globl " << name << '\n';
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000886 O << Directive << "__DATA, __common, " << name << ", "
Dan Gohmand19a53b2008-06-30 22:03:41 +0000887 << Size << ", " << Align << '\n';
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000888 return;
889 }
890 }
891
892 if (!GVar->isThreadLocal() &&
Duncan Sands667d4b82009-03-07 15:45:40 +0000893 (GVar->hasLocalLinkage() || GVar->isWeakForLinker())) {
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000894 if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
Anton Korobeynikove87f52d2008-07-09 13:27:16 +0000895
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000896 if (TAI->getLCOMMDirective() != NULL) {
Rafael Espindolabb46f522009-01-15 20:18:42 +0000897 if (GVar->hasLocalLinkage()) {
Dan Gohmand19a53b2008-06-30 22:03:41 +0000898 O << TAI->getLCOMMDirective() << name << ',' << Size;
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000899 if (Subtarget->isTargetDarwin())
Dan Gohmand19a53b2008-06-30 22:03:41 +0000900 O << ',' << Align;
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000901 } else if (Subtarget->isTargetDarwin() && !GVar->hasCommonLinkage()) {
Dan Gohmand19a53b2008-06-30 22:03:41 +0000902 O << "\t.globl " << name << '\n'
903 << TAI->getWeakDefDirective() << name << '\n';
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000904 EmitAlignment(Align, GVar);
Evan Chengf1c0ae92009-03-24 00:17:40 +0000905 O << name << ":";
906 if (VerboseAsm) {
Evan Cheng7db860d2009-03-25 01:08:42 +0000907 O << "\t\t\t\t" << TAI->getCommentString() << ' ';
Evan Chengf1c0ae92009-03-24 00:17:40 +0000908 PrintUnmangledNameSafely(GVar, O);
909 }
Dan Gohmand19a53b2008-06-30 22:03:41 +0000910 O << '\n';
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000911 EmitGlobalConstant(C);
912 return;
913 } else {
Dan Gohmand19a53b2008-06-30 22:03:41 +0000914 O << TAI->getCOMMDirective() << name << ',' << Size;
Anton Korobeynikov16b7f512008-08-08 18:25:52 +0000915 if (TAI->getCOMMDirectiveTakesAlignment())
916 O << ',' << (TAI->getAlignmentIsInBytes() ? (1 << Align) : Align);
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000917 }
918 } else {
919 if (!Subtarget->isTargetCygMing()) {
Rafael Espindolabb46f522009-01-15 20:18:42 +0000920 if (GVar->hasLocalLinkage())
Dan Gohmand19a53b2008-06-30 22:03:41 +0000921 O << "\t.local\t" << name << '\n';
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000922 }
Dan Gohmand19a53b2008-06-30 22:03:41 +0000923 O << TAI->getCOMMDirective() << name << ',' << Size;
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000924 if (TAI->getCOMMDirectiveTakesAlignment())
Dan Gohmand19a53b2008-06-30 22:03:41 +0000925 O << ',' << (TAI->getAlignmentIsInBytes() ? (1 << Align) : Align);
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000926 }
Evan Chengf1c0ae92009-03-24 00:17:40 +0000927 if (VerboseAsm) {
928 O << "\t\t" << TAI->getCommentString() << ' ';
929 PrintUnmangledNameSafely(GVar, O);
930 }
Dan Gohmand19a53b2008-06-30 22:03:41 +0000931 O << '\n';
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000932 return;
933 }
934 }
935
936 switch (GVar->getLinkage()) {
Duncan Sands4dc2b392009-03-11 20:14:15 +0000937 case GlobalValue::CommonLinkage:
Duncan Sands667d4b82009-03-07 15:45:40 +0000938 case GlobalValue::LinkOnceAnyLinkage:
939 case GlobalValue::LinkOnceODRLinkage:
940 case GlobalValue::WeakAnyLinkage:
941 case GlobalValue::WeakODRLinkage:
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000942 if (Subtarget->isTargetDarwin()) {
Dan Gohmand19a53b2008-06-30 22:03:41 +0000943 O << "\t.globl " << name << '\n'
944 << TAI->getWeakDefDirective() << name << '\n';
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000945 } else if (Subtarget->isTargetCygMing()) {
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000946 O << "\t.globl\t" << name << "\n"
Dan Gohmand19a53b2008-06-30 22:03:41 +0000947 "\t.linkonce same_size\n";
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000948 } else {
Dan Gohmand19a53b2008-06-30 22:03:41 +0000949 O << "\t.weak\t" << name << '\n';
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000950 }
951 break;
Evan Cheng15621a22008-08-08 06:43:59 +0000952 case GlobalValue::DLLExportLinkage:
953 case GlobalValue::AppendingLinkage:
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000954 // FIXME: appending linkage variables should go into a section of
955 // their name or something. For now, just emit them as external.
Evan Cheng15621a22008-08-08 06:43:59 +0000956 case GlobalValue::ExternalLinkage:
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000957 // If external or appending, declare as a global symbol
Dan Gohmand19a53b2008-06-30 22:03:41 +0000958 O << "\t.globl " << name << '\n';
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000959 // FALL THROUGH
Rafael Espindolabb46f522009-01-15 20:18:42 +0000960 case GlobalValue::PrivateLinkage:
Evan Cheng15621a22008-08-08 06:43:59 +0000961 case GlobalValue::InternalLinkage:
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000962 break;
Evan Cheng15621a22008-08-08 06:43:59 +0000963 default:
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000964 assert(0 && "Unknown linkage type!");
965 }
966
967 EmitAlignment(Align, GVar);
Evan Chengf1c0ae92009-03-24 00:17:40 +0000968 O << name << ":";
969 if (VerboseAsm){
Evan Cheng7db860d2009-03-25 01:08:42 +0000970 O << "\t\t\t\t" << TAI->getCommentString() << ' ';
Evan Chengf1c0ae92009-03-24 00:17:40 +0000971 PrintUnmangledNameSafely(GVar, O);
972 }
Dan Gohmand19a53b2008-06-30 22:03:41 +0000973 O << '\n';
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000974 if (TAI->hasDotTypeDotSizeDirective())
Dan Gohmand19a53b2008-06-30 22:03:41 +0000975 O << "\t.size\t" << name << ", " << Size << '\n';
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000976
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000977 EmitGlobalConstant(C);
978}
979
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000980bool X86ATTAsmPrinter::doFinalization(Module &M) {
Anton Korobeynikov75b68822008-06-28 11:08:27 +0000981 // Print out module-level global variables here.
982 for (Module::const_global_iterator I = M.global_begin(), E = M.global_end();
Anton Korobeynikovf0302cd2008-06-28 11:09:48 +0000983 I != E; ++I) {
Anton Korobeynikove51ab442008-06-28 11:09:32 +0000984 printModuleLevelGV(I);
Anton Korobeynikov75b68822008-06-28 11:08:27 +0000985
Anton Korobeynikovf0302cd2008-06-28 11:09:48 +0000986 if (I->hasDLLExportLinkage())
987 DLLExportedGVs.insert(Mang->makeNameProper(I->getName(),""));
Anton Korobeynikovb5bd0262009-02-21 11:53:32 +0000988 }
989
Anton Korobeynikov75b68822008-06-28 11:08:27 +0000990 if (Subtarget->isTargetDarwin()) {
991 SwitchToDataSection("");
Chris Lattner8f61f982009-06-24 18:24:09 +0000992
Chris Lattner381d4fe2009-06-24 18:17:00 +0000993 // Add the (possibly multiple) personalities to the set of global value
994 // stubs. Only referenced functions get into the Personalities list.
Anton Korobeynikov75b68822008-06-28 11:08:27 +0000995 if (TAI->doesSupportExceptionHandling() && MMI && !Subtarget->is64Bit()) {
Chris Lattner381d4fe2009-06-24 18:17:00 +0000996 const std::vector<Function*> &Personalities = MMI->getPersonalities();
997 for (unsigned i = 0, e = Personalities.size(); i != e; ++i) {
998 if (Personalities[i] == 0)
Evan Cheng77c8f762008-07-08 00:55:58 +0000999 continue;
Chris Lattner381d4fe2009-06-24 18:17:00 +00001000 std::string Name = Mang->getValueName(Personalities[i]);
1001 decorateName(Name, Personalities[i]);
1002 GVStubs.insert(Name);
Evan Cheng77c8f762008-07-08 00:55:58 +00001003 }
Anton Korobeynikov75b68822008-06-28 11:08:27 +00001004 }
1005
Chris Lattner8f61f982009-06-24 18:24:09 +00001006 // Output stubs for dynamically-linked functions
1007 if (!FnStubs.empty()) {
1008 for (StringSet<>::iterator I = FnStubs.begin(), E = FnStubs.end();
1009 I != E; ++I) {
1010 SwitchToDataSection("\t.section __IMPORT,__jump_table,symbol_stubs,"
1011 "self_modifying_code+pure_instructions,5", 0);
1012 const char *Name = I->getKeyData();
1013 printSuffixedName(Name, "$stub");
1014 O << ":\n"
1015 "\t.indirect_symbol " << Name << "\n"
1016 "\thlt ; hlt ; hlt ; hlt ; hlt\n";
1017 }
1018 O << '\n';
1019 }
1020
Anton Korobeynikov75b68822008-06-28 11:08:27 +00001021 // Output stubs for external and common global variables.
Chris Lattner8f61f982009-06-24 18:24:09 +00001022 if (!GVStubs.empty()) {
Anton Korobeynikov75b68822008-06-28 11:08:27 +00001023 SwitchToDataSection(
1024 "\t.section __IMPORT,__pointers,non_lazy_symbol_pointers");
Chris Lattner8f61f982009-06-24 18:24:09 +00001025 for (StringSet<>::iterator I = GVStubs.begin(), E = GVStubs.end();
1026 I != E; ++I) {
1027 const char *Name = I->getKeyData();
1028 printSuffixedName(Name, "$non_lazy_ptr");
1029 O << ":\n\t.indirect_symbol " << Name << "\n\t.long\t0\n";
1030 }
1031 }
Anton Korobeynikov75b68822008-06-28 11:08:27 +00001032
Evan Chengae94e592008-12-05 01:06:39 +00001033 if (!HiddenGVStubs.empty()) {
1034 SwitchToSection(TAI->getDataSection());
Chris Lattner52cff832009-06-24 18:24:42 +00001035 EmitAlignment(2);
Chris Lattner8f61f982009-06-24 18:24:09 +00001036 for (StringSet<>::iterator I = HiddenGVStubs.begin(),
1037 E = HiddenGVStubs.end(); I != E; ++I) {
Chris Lattner8f61f982009-06-24 18:24:09 +00001038 const char *Name = I->getKeyData();
1039 printSuffixedName(Name, "$non_lazy_ptr");
1040 O << ":\n" << TAI->getData32bitsDirective() << Name << '\n';
1041 }
Evan Chengae94e592008-12-05 01:06:39 +00001042 }
1043
Anton Korobeynikov75b68822008-06-28 11:08:27 +00001044 // Funny Darwin hack: This flag tells the linker that no global symbols
1045 // contain code that falls through to other global symbols (e.g. the obvious
1046 // implementation of multiple entry points). If this doesn't occur, the
1047 // linker can safely perform dead code stripping. Since LLVM never
1048 // generates code that does this, it is always safe to set.
1049 O << "\t.subsections_via_symbols\n";
1050 } else if (Subtarget->isTargetCygMing()) {
1051 // Emit type information for external functions
Chris Lattner1ebd3bf2009-07-09 05:09:24 +00001052 for (StringSet<>::iterator i = CygMingStubs.begin(), e = CygMingStubs.end();
Anton Korobeynikov75b68822008-06-28 11:08:27 +00001053 i != e; ++i) {
1054 O << "\t.def\t " << i->getKeyData()
1055 << ";\t.scl\t" << COFF::C_EXT
1056 << ";\t.type\t" << (COFF::DT_FCN << COFF::N_BTSHFT)
1057 << ";\t.endef\n";
1058 }
Anton Korobeynikov75b68822008-06-28 11:08:27 +00001059 }
Chris Lattner974469d2009-06-24 05:47:59 +00001060
Chris Lattner0a7befa2009-06-24 18:52:01 +00001061
1062 // Output linker support code for dllexported globals on windows.
1063 if (!DLLExportedGVs.empty()) {
1064 SwitchToDataSection(".section .drectve");
1065
1066 for (StringSet<>::iterator i = DLLExportedGVs.begin(),
1067 e = DLLExportedGVs.end(); i != e; ++i)
1068 O << "\t.ascii \" -export:" << i->getKeyData() << ",data\"\n";
1069 }
1070
1071 if (!DLLExportedFns.empty()) {
1072 SwitchToDataSection(".section .drectve");
1073
1074 for (StringSet<>::iterator i = DLLExportedFns.begin(),
1075 e = DLLExportedFns.end();
1076 i != e; ++i)
1077 O << "\t.ascii \" -export:" << i->getKeyData() << "\"\n";
1078 }
1079
Chris Lattner0a7befa2009-06-24 18:52:01 +00001080 // Do common shutdown.
1081 bool Changed = AsmPrinter::doFinalization(M);
Chris Lattner974469d2009-06-24 05:47:59 +00001082
Chris Lattner40e3c7a2009-06-24 05:46:28 +00001083 if (NewAsmPrinter) {
1084 Streamer->Finish();
1085
1086 delete Streamer;
1087 delete Context;
1088 Streamer = 0;
1089 Context = 0;
1090 }
1091
Chris Lattner0a7befa2009-06-24 18:52:01 +00001092 return Changed;
Anton Korobeynikov75b68822008-06-28 11:08:27 +00001093}
1094
Chris Lattnerb36cbd02005-07-01 22:44:09 +00001095// Include the auto-generated portion of the assembly writer.
1096#include "X86GenAsmWriter.inc"