blob: 08b45ea86f934f047811c6cab32a4f55baa413a5 [file] [log] [blame]
pingbakddfd8692008-11-08 18:59:02 +00001//===-- SPUAsmPrinter.cpp - Print machine instrs to Cell SPU assembly -------=//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file contains a printer that converts from our internal representation
11// of machine-dependent LLVM code to Cell SPU assembly language. This printer
12// is the output mechanism used by `llc'.
13//
14//===----------------------------------------------------------------------===//
15
16#define DEBUG_TYPE "asmprinter"
17#include "SPU.h"
18#include "SPUTargetMachine.h"
19#include "llvm/Constants.h"
20#include "llvm/DerivedTypes.h"
21#include "llvm/Module.h"
22#include "llvm/Assembly/Writer.h"
23#include "llvm/CodeGen/AsmPrinter.h"
24#include "llvm/CodeGen/DwarfWriter.h"
25#include "llvm/CodeGen/MachineModuleInfo.h"
26#include "llvm/CodeGen/MachineFunctionPass.h"
27#include "llvm/CodeGen/MachineInstr.h"
Chris Lattner73266f92009-08-19 05:49:37 +000028#include "llvm/MC/MCStreamer.h"
Chris Lattner621c44d2009-08-22 20:48:53 +000029#include "llvm/MC/MCAsmInfo.h"
Chris Lattnerc6f802d2009-09-13 17:14:04 +000030#include "llvm/MC/MCSymbol.h"
Chris Lattnerc4c40a92009-07-28 03:13:23 +000031#include "llvm/Target/TargetLoweringObjectFile.h"
pingbakddfd8692008-11-08 18:59:02 +000032#include "llvm/Target/TargetInstrInfo.h"
33#include "llvm/Target/TargetOptions.h"
Chris Lattnerc4c40a92009-07-28 03:13:23 +000034#include "llvm/Target/TargetRegisterInfo.h"
Daniel Dunbarfe5939f2009-07-15 20:24:03 +000035#include "llvm/Target/TargetRegistry.h"
pingbakddfd8692008-11-08 18:59:02 +000036#include "llvm/ADT/Statistic.h"
37#include "llvm/ADT/StringExtras.h"
Chris Lattner73266f92009-08-19 05:49:37 +000038#include "llvm/Support/CommandLine.h"
Chris Lattner73266f92009-08-19 05:49:37 +000039#include "llvm/Support/Debug.h"
40#include "llvm/Support/ErrorHandling.h"
41#include "llvm/Support/FormattedStream.h"
Chris Lattner73266f92009-08-19 05:49:37 +000042#include "llvm/Support/MathExtras.h"
pingbakddfd8692008-11-08 18:59:02 +000043using namespace llvm;
44
45namespace {
46 STATISTIC(EmittedInsts, "Number of machine instrs printed");
47
48 const std::string bss_section(".bss");
49
Nick Lewycky492d06e2009-10-25 06:33:48 +000050 class SPUAsmPrinter : public AsmPrinter {
Bill Wendling4f405312009-02-24 08:30:20 +000051 public:
David Greene302008d2009-07-14 20:18:05 +000052 explicit SPUAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM,
Chris Lattner621c44d2009-08-22 20:48:53 +000053 const MCAsmInfo *T, bool V) :
Daniel Dunbarb10d2222009-07-01 01:48:54 +000054 AsmPrinter(O, TM, T, V) {}
pingbakddfd8692008-11-08 18:59:02 +000055
56 virtual const char *getPassName() const {
57 return "STI CBEA SPU Assembly Printer";
58 }
59
60 SPUTargetMachine &getTM() {
61 return static_cast<SPUTargetMachine&>(TM);
62 }
63
64 /// printInstruction - This method is automatically generated by tablegen
Chris Lattner92221692009-09-13 20:08:00 +000065 /// from the instruction set description.
Chris Lattnerddb259a2009-08-08 01:32:19 +000066 void printInstruction(const MachineInstr *MI);
Chris Lattner213703c2009-09-13 20:19:22 +000067 static const char *getRegisterName(unsigned RegNo);
Chris Lattner92221692009-09-13 20:08:00 +000068
pingbakddfd8692008-11-08 18:59:02 +000069
70 void printMachineInstruction(const MachineInstr *MI);
71 void printOp(const MachineOperand &MO);
72
73 /// printRegister - Print register according to target requirements.
74 ///
75 void printRegister(const MachineOperand &MO, bool R0AsZero) {
76 unsigned RegNo = MO.getReg();
77 assert(TargetRegisterInfo::isPhysicalRegister(RegNo) &&
78 "Not physreg??");
Chris Lattnerf0a25de2009-09-13 20:31:40 +000079 O << getRegisterName(RegNo);
pingbakddfd8692008-11-08 18:59:02 +000080 }
81
82 void printOperand(const MachineInstr *MI, unsigned OpNo) {
83 const MachineOperand &MO = MI->getOperand(OpNo);
84 if (MO.isReg()) {
Chris Lattnerf0a25de2009-09-13 20:31:40 +000085 O << getRegisterName(MO.getReg());
pingbakddfd8692008-11-08 18:59:02 +000086 } else if (MO.isImm()) {
87 O << MO.getImm();
88 } else {
89 printOp(MO);
90 }
91 }
Scott Michelc899a122009-01-26 22:33:37 +000092
pingbakddfd8692008-11-08 18:59:02 +000093 bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
94 unsigned AsmVariant, const char *ExtraCode);
95 bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
96 unsigned AsmVariant, const char *ExtraCode);
Scott Michelc899a122009-01-26 22:33:37 +000097
98
pingbakddfd8692008-11-08 18:59:02 +000099 void
100 printS7ImmOperand(const MachineInstr *MI, unsigned OpNo)
101 {
102 int value = MI->getOperand(OpNo).getImm();
103 value = (value << (32 - 7)) >> (32 - 7);
104
105 assert((value >= -(1 << 8) && value <= (1 << 7) - 1)
106 && "Invalid s7 argument");
107 O << value;
108 }
109
110 void
111 printU7ImmOperand(const MachineInstr *MI, unsigned OpNo)
112 {
113 unsigned int value = MI->getOperand(OpNo).getImm();
114 assert(value < (1 << 8) && "Invalid u7 argument");
115 O << value;
116 }
Scott Michelc899a122009-01-26 22:33:37 +0000117
pingbakddfd8692008-11-08 18:59:02 +0000118 void
Scott Michel06eabde2008-12-27 04:51:36 +0000119 printShufAddr(const MachineInstr *MI, unsigned OpNo)
pingbakddfd8692008-11-08 18:59:02 +0000120 {
121 char value = MI->getOperand(OpNo).getImm();
122 O << (int) value;
123 O << "(";
124 printOperand(MI, OpNo+1);
125 O << ")";
126 }
127
128 void
129 printS16ImmOperand(const MachineInstr *MI, unsigned OpNo)
130 {
131 O << (short) MI->getOperand(OpNo).getImm();
132 }
133
134 void
135 printU16ImmOperand(const MachineInstr *MI, unsigned OpNo)
136 {
137 O << (unsigned short)MI->getOperand(OpNo).getImm();
138 }
139
140 void
141 printU32ImmOperand(const MachineInstr *MI, unsigned OpNo)
142 {
143 O << (unsigned)MI->getOperand(OpNo).getImm();
144 }
Scott Michelc899a122009-01-26 22:33:37 +0000145
pingbakddfd8692008-11-08 18:59:02 +0000146 void
147 printMemRegReg(const MachineInstr *MI, unsigned OpNo) {
148 // When used as the base register, r0 reads constant zero rather than
149 // the value contained in the register. For this reason, the darwin
150 // assembler requires that we print r0 as 0 (no r) when used as the base.
151 const MachineOperand &MO = MI->getOperand(OpNo);
Chris Lattnerf0a25de2009-09-13 20:31:40 +0000152 O << getRegisterName(MO.getReg()) << ", ";
pingbakddfd8692008-11-08 18:59:02 +0000153 printOperand(MI, OpNo+1);
154 }
155
156 void
157 printU18ImmOperand(const MachineInstr *MI, unsigned OpNo)
158 {
159 unsigned int value = MI->getOperand(OpNo).getImm();
160 assert(value <= (1 << 19) - 1 && "Invalid u18 argument");
161 O << value;
162 }
163
164 void
165 printS10ImmOperand(const MachineInstr *MI, unsigned OpNo)
166 {
167 short value = (short) (((int) MI->getOperand(OpNo).getImm() << 16)
168 >> 16);
169 assert((value >= -(1 << 9) && value <= (1 << 9) - 1)
170 && "Invalid s10 argument");
171 O << value;
172 }
173
174 void
175 printU10ImmOperand(const MachineInstr *MI, unsigned OpNo)
176 {
177 short value = (short) (((int) MI->getOperand(OpNo).getImm() << 16)
178 >> 16);
179 assert((value <= (1 << 10) - 1) && "Invalid u10 argument");
180 O << value;
181 }
182
183 void
Scott Michel06eabde2008-12-27 04:51:36 +0000184 printDFormAddr(const MachineInstr *MI, unsigned OpNo)
pingbakddfd8692008-11-08 18:59:02 +0000185 {
Chris Lattner4c4fb3a2009-01-21 18:38:18 +0000186 assert(MI->getOperand(OpNo).isImm() &&
187 "printDFormAddr first operand is not immediate");
pingbakddfd8692008-11-08 18:59:02 +0000188 int64_t value = int64_t(MI->getOperand(OpNo).getImm());
Scott Michelffca41d2008-11-20 05:01:09 +0000189 int16_t value16 = int16_t(value);
190 assert((value16 >= -(1 << (9+4)) && value16 <= (1 << (9+4)) - 1)
pingbakddfd8692008-11-08 18:59:02 +0000191 && "Invalid dform s10 offset argument");
Scott Michel06eabde2008-12-27 04:51:36 +0000192 O << (value16 & ~0xf) << "(";
pingbakddfd8692008-11-08 18:59:02 +0000193 printOperand(MI, OpNo+1);
194 O << ")";
195 }
196
197 void
198 printAddr256K(const MachineInstr *MI, unsigned OpNo)
199 {
200 /* Note: operand 1 is an offset or symbol name. */
201 if (MI->getOperand(OpNo).isImm()) {
202 printS16ImmOperand(MI, OpNo);
203 } else {
204 printOp(MI->getOperand(OpNo));
205 if (MI->getOperand(OpNo+1).isImm()) {
206 int displ = int(MI->getOperand(OpNo+1).getImm());
207 if (displ > 0)
208 O << "+" << displ;
209 else if (displ < 0)
210 O << displ;
211 }
212 }
213 }
214
215 void printCallOperand(const MachineInstr *MI, unsigned OpNo) {
216 printOp(MI->getOperand(OpNo));
217 }
218
219 void printPCRelativeOperand(const MachineInstr *MI, unsigned OpNo) {
Scott Michel61895fe2008-12-10 00:15:19 +0000220 // Used to generate a ".-<target>", but it turns out that the assembler
221 // really wants the target.
222 //
223 // N.B.: This operand is used for call targets. Branch hints are another
224 // animal entirely.
225 printOp(MI->getOperand(OpNo));
226 }
227
228 void printHBROperand(const MachineInstr *MI, unsigned OpNo) {
229 // HBR operands are generated in front of branches, hence, the
230 // program counter plus the target.
231 O << ".+";
pingbakddfd8692008-11-08 18:59:02 +0000232 printOp(MI->getOperand(OpNo));
pingbakddfd8692008-11-08 18:59:02 +0000233 }
234
235 void printSymbolHi(const MachineInstr *MI, unsigned OpNo) {
236 if (MI->getOperand(OpNo).isImm()) {
237 printS16ImmOperand(MI, OpNo);
238 } else {
239 printOp(MI->getOperand(OpNo));
240 O << "@h";
241 }
242 }
243
244 void printSymbolLo(const MachineInstr *MI, unsigned OpNo) {
245 if (MI->getOperand(OpNo).isImm()) {
246 printS16ImmOperand(MI, OpNo);
247 } else {
248 printOp(MI->getOperand(OpNo));
249 O << "@l";
250 }
251 }
252
253 /// Print local store address
254 void printSymbolLSA(const MachineInstr *MI, unsigned OpNo) {
255 printOp(MI->getOperand(OpNo));
256 }
257
258 void printROTHNeg7Imm(const MachineInstr *MI, unsigned OpNo) {
259 if (MI->getOperand(OpNo).isImm()) {
260 int value = (int) MI->getOperand(OpNo).getImm();
261 assert((value >= 0 && value < 16)
262 && "Invalid negated immediate rotate 7-bit argument");
263 O << -value;
264 } else {
Edwin Törökbd448e32009-07-14 16:55:14 +0000265 llvm_unreachable("Invalid/non-immediate rotate amount in printRotateNeg7Imm");
pingbakddfd8692008-11-08 18:59:02 +0000266 }
267 }
268
269 void printROTNeg7Imm(const MachineInstr *MI, unsigned OpNo) {
270 if (MI->getOperand(OpNo).isImm()) {
271 int value = (int) MI->getOperand(OpNo).getImm();
Scott Michelc630c412008-11-24 17:11:17 +0000272 assert((value >= 0 && value <= 32)
pingbakddfd8692008-11-08 18:59:02 +0000273 && "Invalid negated immediate rotate 7-bit argument");
274 O << -value;
275 } else {
Edwin Törökbd448e32009-07-14 16:55:14 +0000276 llvm_unreachable("Invalid/non-immediate rotate amount in printRotateNeg7Imm");
pingbakddfd8692008-11-08 18:59:02 +0000277 }
278 }
279
280 virtual bool runOnMachineFunction(MachineFunction &F) = 0;
pingbakddfd8692008-11-08 18:59:02 +0000281 };
282
283 /// LinuxAsmPrinter - SPU assembly printer, customized for Linux
Nick Lewycky492d06e2009-10-25 06:33:48 +0000284 class LinuxAsmPrinter : public SPUAsmPrinter {
Bill Wendling4f405312009-02-24 08:30:20 +0000285 public:
Daniel Dunbarfe5939f2009-07-15 20:24:03 +0000286 explicit LinuxAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM,
Chris Lattner621c44d2009-08-22 20:48:53 +0000287 const MCAsmInfo *T, bool V)
Bob Wilsoncd8cb7f2009-09-30 21:24:45 +0000288 : SPUAsmPrinter(O, TM, T, V) {}
pingbakddfd8692008-11-08 18:59:02 +0000289
290 virtual const char *getPassName() const {
291 return "STI CBEA SPU Assembly Printer";
292 }
Scott Michelc899a122009-01-26 22:33:37 +0000293
pingbakddfd8692008-11-08 18:59:02 +0000294 bool runOnMachineFunction(MachineFunction &F);
Scott Michelc899a122009-01-26 22:33:37 +0000295
pingbakddfd8692008-11-08 18:59:02 +0000296 void getAnalysisUsage(AnalysisUsage &AU) const {
297 AU.setPreservesAll();
298 AU.addRequired<MachineModuleInfo>();
Devang Patelaa1e8432009-01-08 23:40:34 +0000299 AU.addRequired<DwarfWriter>();
pingbakddfd8692008-11-08 18:59:02 +0000300 SPUAsmPrinter::getAnalysisUsage(AU);
301 }
pingbakddfd8692008-11-08 18:59:02 +0000302 };
303} // end of anonymous namespace
304
305// Include the auto-generated portion of the assembly writer
306#include "SPUGenAsmWriter.inc"
307
308void SPUAsmPrinter::printOp(const MachineOperand &MO) {
309 switch (MO.getType()) {
310 case MachineOperand::MO_Immediate:
Edwin Török4d9756a2009-07-08 20:53:28 +0000311 llvm_report_error("printOp() does not handle immediate values");
pingbakddfd8692008-11-08 18:59:02 +0000312 return;
313
314 case MachineOperand::MO_MachineBasicBlock:
Chris Lattnerce409842010-01-17 21:43:43 +0000315 O << *GetMBBSymbol(MO.getMBB()->getNumber());
pingbakddfd8692008-11-08 18:59:02 +0000316 return;
317 case MachineOperand::MO_JumpTableIndex:
Chris Lattnera5ef4d32009-08-22 21:43:10 +0000318 O << MAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
pingbakddfd8692008-11-08 18:59:02 +0000319 << '_' << MO.getIndex();
320 return;
321 case MachineOperand::MO_ConstantPoolIndex:
Chris Lattnera5ef4d32009-08-22 21:43:10 +0000322 O << MAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber()
pingbakddfd8692008-11-08 18:59:02 +0000323 << '_' << MO.getIndex();
324 return;
325 case MachineOperand::MO_ExternalSymbol:
326 // Computing the address of an external symbol, not calling it.
327 if (TM.getRelocationModel() != Reloc::Static) {
Chris Lattner651adf32010-01-16 00:21:18 +0000328 O << "L" << MAI->getGlobalPrefix() << MO.getSymbolName()
329 << "$non_lazy_ptr";
pingbakddfd8692008-11-08 18:59:02 +0000330 return;
331 }
Chris Lattnerce409842010-01-17 21:43:43 +0000332 O << *GetExternalSymbolSymbol(MO.getSymbolName());
pingbakddfd8692008-11-08 18:59:02 +0000333 return;
Chris Lattner651adf32010-01-16 00:21:18 +0000334 case MachineOperand::MO_GlobalAddress:
pingbakddfd8692008-11-08 18:59:02 +0000335 // External or weakly linked global variables need non-lazily-resolved
336 // stubs
337 if (TM.getRelocationModel() != Reloc::Static) {
Chris Lattner651adf32010-01-16 00:21:18 +0000338 GlobalValue *GV = MO.getGlobal();
pingbakddfd8692008-11-08 18:59:02 +0000339 if (((GV->isDeclaration() || GV->hasWeakLinkage() ||
340 GV->hasLinkOnceLinkage() || GV->hasCommonLinkage()))) {
Chris Lattnerce409842010-01-17 21:43:43 +0000341 O << *GetSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
pingbakddfd8692008-11-08 18:59:02 +0000342 return;
343 }
344 }
Chris Lattnerce409842010-01-17 21:43:43 +0000345 O << *GetGlobalValueSymbol(MO.getGlobal());
pingbakddfd8692008-11-08 18:59:02 +0000346 return;
pingbakddfd8692008-11-08 18:59:02 +0000347 default:
348 O << "<unknown operand type: " << MO.getType() << ">";
349 return;
350 }
351}
352
353/// PrintAsmOperand - Print out an operand for an inline asm expression.
354///
355bool SPUAsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
Scott Michelc899a122009-01-26 22:33:37 +0000356 unsigned AsmVariant,
pingbakddfd8692008-11-08 18:59:02 +0000357 const char *ExtraCode) {
358 // Does this asm operand have a single letter operand modifier?
359 if (ExtraCode && ExtraCode[0]) {
360 if (ExtraCode[1] != 0) return true; // Unknown modifier.
Scott Michelc899a122009-01-26 22:33:37 +0000361
pingbakddfd8692008-11-08 18:59:02 +0000362 switch (ExtraCode[0]) {
363 default: return true; // Unknown modifier.
Scott Michelc899a122009-01-26 22:33:37 +0000364 case 'L': // Write second word of DImode reference.
pingbakddfd8692008-11-08 18:59:02 +0000365 // Verify that this operand has two consecutive registers.
366 if (!MI->getOperand(OpNo).isReg() ||
367 OpNo+1 == MI->getNumOperands() ||
368 !MI->getOperand(OpNo+1).isReg())
369 return true;
370 ++OpNo; // Return the high-part.
371 break;
372 }
373 }
Scott Michelc899a122009-01-26 22:33:37 +0000374
pingbakddfd8692008-11-08 18:59:02 +0000375 printOperand(MI, OpNo);
376 return false;
377}
378
379bool SPUAsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI,
380 unsigned OpNo,
Scott Michelc899a122009-01-26 22:33:37 +0000381 unsigned AsmVariant,
pingbakddfd8692008-11-08 18:59:02 +0000382 const char *ExtraCode) {
383 if (ExtraCode && ExtraCode[0])
384 return true; // Unknown modifier.
385 printMemRegReg(MI, OpNo);
386 return false;
387}
388
389/// printMachineInstruction -- Print out a single PowerPC MI in Darwin syntax
390/// to the current output stream.
391///
392void SPUAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
393 ++EmittedInsts;
Devang Patel5450fc12009-10-06 02:19:11 +0000394 processDebugLoc(MI, true);
pingbakddfd8692008-11-08 18:59:02 +0000395 printInstruction(MI);
David Greeneca9b04b2009-11-13 21:34:57 +0000396 if (VerboseAsm)
Chris Lattner32d4cc72009-09-09 23:14:36 +0000397 EmitComments(*MI);
Devang Patel5450fc12009-10-06 02:19:11 +0000398 processDebugLoc(MI, false);
Chris Lattner32d4cc72009-09-09 23:14:36 +0000399 O << '\n';
pingbakddfd8692008-11-08 18:59:02 +0000400}
401
402/// runOnMachineFunction - This uses the printMachineInstruction()
403/// method to print assembly for each instruction.
404///
Chris Lattnere34788c2009-09-09 20:34:59 +0000405bool LinuxAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
pingbakddfd8692008-11-08 18:59:02 +0000406 SetupMachineFunction(MF);
407 O << "\n\n";
Scott Michelc899a122009-01-26 22:33:37 +0000408
pingbakddfd8692008-11-08 18:59:02 +0000409 // Print out constants referenced by the function
410 EmitConstantPool(MF.getConstantPool());
411
412 // Print out labels for the function.
413 const Function *F = MF.getFunction();
414
Chris Lattner73266f92009-08-19 05:49:37 +0000415 OutStreamer.SwitchSection(getObjFileLowering().SectionForGlobal(F, Mang, TM));
Bill Wendling25a8ae32009-06-30 22:38:32 +0000416 EmitAlignment(MF.getAlignment(), F);
pingbakddfd8692008-11-08 18:59:02 +0000417
418 switch (F->getLinkage()) {
Edwin Törökbd448e32009-07-14 16:55:14 +0000419 default: llvm_unreachable("Unknown linkage type!");
Rafael Espindolaa168fc92009-01-15 20:18:42 +0000420 case Function::PrivateLinkage:
Bill Wendling41a07852009-07-20 01:03:30 +0000421 case Function::LinkerPrivateLinkage:
pingbakddfd8692008-11-08 18:59:02 +0000422 case Function::InternalLinkage: // Symbols default to internal.
423 break;
424 case Function::ExternalLinkage:
Chris Lattnerce409842010-01-17 21:43:43 +0000425 O << "\t.global\t" << *CurrentFnSym << "\n" << "\t.type\t";
426 O << *CurrentFnSym << ", @function\n";
pingbakddfd8692008-11-08 18:59:02 +0000427 break;
Duncan Sands19d161f2009-03-07 15:45:40 +0000428 case Function::WeakAnyLinkage:
429 case Function::WeakODRLinkage:
430 case Function::LinkOnceAnyLinkage:
431 case Function::LinkOnceODRLinkage:
Chris Lattnerce409842010-01-17 21:43:43 +0000432 O << "\t.global\t" << *CurrentFnSym << "\n";
433 O << "\t.weak_definition\t" << *CurrentFnSym << "\n";
pingbakddfd8692008-11-08 18:59:02 +0000434 break;
435 }
Chris Lattner8d656d92010-01-15 23:55:16 +0000436
Chris Lattnerce409842010-01-17 21:43:43 +0000437 O << *CurrentFnSym << ":\n";
pingbakddfd8692008-11-08 18:59:02 +0000438
439 // Emit pre-function debug information.
Devang Patelaa1e8432009-01-08 23:40:34 +0000440 DW->BeginFunction(&MF);
pingbakddfd8692008-11-08 18:59:02 +0000441
442 // Print out code for the function.
443 for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
444 I != E; ++I) {
445 // Print a label for the basic block.
446 if (I != MF.begin()) {
Chris Lattner2faa4ef2009-09-13 18:25:37 +0000447 EmitBasicBlockStart(I);
pingbakddfd8692008-11-08 18:59:02 +0000448 }
449 for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
450 II != E; ++II) {
451 // Print the assembly for the instruction.
452 printMachineInstruction(II);
453 }
454 }
455
Chris Lattnerce409842010-01-17 21:43:43 +0000456 O << "\t.size\t" << *CurrentFnSym << ",.-" << *CurrentFnSym << "\n";
pingbakddfd8692008-11-08 18:59:02 +0000457
458 // Print out jump tables referenced by the function.
Chris Lattner1f8c8922010-01-25 22:41:33 +0000459 EmitJumpTableInfo(MF);
Scott Michelc899a122009-01-26 22:33:37 +0000460
pingbakddfd8692008-11-08 18:59:02 +0000461 // Emit post-function debug information.
Devang Patelaa1e8432009-01-08 23:40:34 +0000462 DW->EndFunction(&MF);
Scott Michelc899a122009-01-26 22:33:37 +0000463
pingbakddfd8692008-11-08 18:59:02 +0000464 // We didn't modify anything.
465 return false;
466}
467
Daniel Dunbarfe5939f2009-07-15 20:24:03 +0000468// Force static initialization.
469extern "C" void LLVMInitializeCellSPUAsmPrinter() {
Daniel Dunbarc680b012009-07-25 06:49:55 +0000470 RegisterAsmPrinter<LinuxAsmPrinter> X(TheCellSPUTarget);
Daniel Dunbarfe5939f2009-07-15 20:24:03 +0000471}