More of the Cell SPU code drop from "Team Aerospace".
[oota-llvm.git] / lib / Target / CellSPU / SPUAsmPrinter.cpp
1 //===-- SPUAsmPrinter.cpp - Print machine instrs to Cell SPU assembly -------=//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by a team from the Computer Systems Research
6 // Department at The Aerospace Corporation.
7 //
8 // See README.txt for details.
9 //
10 //===----------------------------------------------------------------------===//
11 //
12 // This file contains a printer that converts from our internal representation
13 // of machine-dependent LLVM code to Cell SPU assembly language. This printer
14 // is the output mechanism used by `llc'.
15 //
16 // Documentation at http://developer.apple.com/documentation/DeveloperTools/
17 // Reference/Assembler/ASMIntroduction/chapter_1_section_1.html
18 //
19 //===----------------------------------------------------------------------===//
20
21 #define DEBUG_TYPE "asmprinter"
22 #include "SPU.h"
23 #include "SPUTargetMachine.h"
24 #include "llvm/Constants.h"
25 #include "llvm/DerivedTypes.h"
26 #include "llvm/Module.h"
27 #include "llvm/Assembly/Writer.h"
28 #include "llvm/CodeGen/AsmPrinter.h"
29 #include "llvm/CodeGen/DwarfWriter.h"
30 #include "llvm/CodeGen/MachineModuleInfo.h"
31 #include "llvm/CodeGen/MachineFunctionPass.h"
32 #include "llvm/CodeGen/MachineInstr.h"
33 #include "llvm/Support/Mangler.h"
34 #include "llvm/Support/MathExtras.h"
35 #include "llvm/Support/CommandLine.h"
36 #include "llvm/Support/Debug.h"
37 #include "llvm/Support/Compiler.h"
38 #include "llvm/Target/TargetAsmInfo.h"
39 #include "llvm/Target/MRegisterInfo.h"
40 #include "llvm/Target/TargetInstrInfo.h"
41 #include "llvm/Target/TargetOptions.h"
42 #include "llvm/ADT/Statistic.h"
43 #include "llvm/ADT/StringExtras.h"
44 #include <set>
45 using namespace llvm;
46
47 namespace {
48   STATISTIC(EmittedInsts, "Number of machine instrs printed");
49
50   const std::string bss_section(".bss");
51
52   struct VISIBILITY_HIDDEN SPUAsmPrinter : public AsmPrinter {
53     std::set<std::string> FnStubs, GVStubs;
54
55     SPUAsmPrinter(std::ostream &O, TargetMachine &TM, const TargetAsmInfo *T) :
56       AsmPrinter(O, TM, T)
57     {
58     }
59
60     virtual const char *getPassName() const {
61       return "STI CBEA SPU Assembly Printer";
62     }
63
64     SPUTargetMachine &getTM() {
65       return static_cast<SPUTargetMachine&>(TM);
66     }
67
68     /// printInstruction - This method is automatically generated by tablegen
69     /// from the instruction set description.  This method returns true if the
70     /// machine instruction was sufficiently described to print it, otherwise it
71     /// returns false.
72     bool printInstruction(const MachineInstr *MI);
73
74     void printMachineInstruction(const MachineInstr *MI);
75     void printOp(const MachineOperand &MO);
76
77     /// printRegister - Print register according to target requirements.
78     ///
79     void printRegister(const MachineOperand &MO, bool R0AsZero) {
80       unsigned RegNo = MO.getReg();
81       assert(MRegisterInfo::isPhysicalRegister(RegNo) && "Not physreg??");
82       O << TM.getRegisterInfo()->get(RegNo).Name;
83     }
84
85     void printOperand(const MachineInstr *MI, unsigned OpNo) {
86       const MachineOperand &MO = MI->getOperand(OpNo);
87       if (MO.isRegister()) {
88         assert(MRegisterInfo::isPhysicalRegister(MO.getReg())&&"Not physreg??");
89         O << TM.getRegisterInfo()->get(MO.getReg()).Name;
90       } else if (MO.isImmediate()) {
91         O << MO.getImmedValue();
92       } else {
93         printOp(MO);
94       }
95     }
96     
97     bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
98                          unsigned AsmVariant, const char *ExtraCode);
99     bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
100                                unsigned AsmVariant, const char *ExtraCode);
101    
102    
103     void
104     printS7ImmOperand(const MachineInstr *MI, unsigned OpNo)
105     {
106       int value = MI->getOperand(OpNo).getImmedValue();
107       value = (value << (32 - 7)) >> (32 - 7);
108
109       assert((value >= -(1 << 8) && value <= (1 << 7) - 1)
110              && "Invalid s7 argument");
111       O << value;
112     }
113
114     void
115     printU7ImmOperand(const MachineInstr *MI, unsigned OpNo)
116     {
117       unsigned int value = MI->getOperand(OpNo).getImmedValue();
118       assert(value < (1 << 8) && "Invalid u7 argument");
119       O << value;
120     }
121  
122     void
123     printMemRegImmS7(const MachineInstr *MI, unsigned OpNo)
124     {
125       char value = MI->getOperand(OpNo).getImmedValue();
126       O << (int) value;
127       O << "(";
128       printOperand(MI, OpNo+1);
129       O << ")";
130     }
131
132     void
133     printS16ImmOperand(const MachineInstr *MI, unsigned OpNo)
134     {
135       O << (short) MI->getOperand(OpNo).getImmedValue();
136     }
137
138     void
139     printU16ImmOperand(const MachineInstr *MI, unsigned OpNo)
140     {
141       O << (unsigned short)MI->getOperand(OpNo).getImmedValue();
142     }
143
144     void
145     printU32ImmOperand(const MachineInstr *MI, unsigned OpNo)
146     {
147       O << (unsigned)MI->getOperand(OpNo).getImmedValue();
148     }
149     
150     void
151     printMemRegReg(const MachineInstr *MI, unsigned OpNo) {
152       // When used as the base register, r0 reads constant zero rather than
153       // the value contained in the register.  For this reason, the darwin
154       // assembler requires that we print r0 as 0 (no r) when used as the base.
155       const MachineOperand &MO = MI->getOperand(OpNo);
156       O << TM.getRegisterInfo()->get(MO.getReg()).Name;
157       O << ", ";
158       printOperand(MI, OpNo+1);
159     }
160
161     void
162     printU18ImmOperand(const MachineInstr *MI, unsigned OpNo)
163     {
164       unsigned int value = MI->getOperand(OpNo).getImmedValue();
165       assert(value <= (1 << 19) - 1 && "Invalid u18 argument");
166       O << value;
167     }
168
169     void
170     printS10ImmOperand(const MachineInstr *MI, unsigned OpNo)
171     {
172       short value = (short) (((int) MI->getOperand(OpNo).getImmedValue() << 16)
173                              >> 16);
174       assert((value >= -(1 << 9) && value <= (1 << 9) - 1)
175              && "Invalid s10 argument");
176       O << value;
177     }
178
179     void
180     printU10ImmOperand(const MachineInstr *MI, unsigned OpNo)
181     {
182       short value = (short) (((int) MI->getOperand(OpNo).getImmedValue() << 16)
183                              >> 16);
184       assert((value <= (1 << 10) - 1) && "Invalid u10 argument");
185       O << value;
186     }
187
188     void
189     printMemRegImmS10(const MachineInstr *MI, unsigned OpNo)
190     {
191       const MachineOperand &MO = MI->getOperand(OpNo);
192       assert(MO.isImmediate()
193              && "printMemRegImmS10 first operand is not immedate");
194       printS10ImmOperand(MI, OpNo);
195       O << "(";
196       printOperand(MI, OpNo+1);
197       O << ")";
198     }
199
200     void
201     printAddr256K(const MachineInstr *MI, unsigned OpNo)
202     {
203       /* Note: operand 1 is an offset or symbol name. Operand 2 is
204          ignored. */
205       if (MI->getOperand(OpNo).isImmediate()) {
206         printS16ImmOperand(MI, OpNo);
207       } else {
208         printOp(MI->getOperand(OpNo));
209       }
210     }
211
212     void printCallOperand(const MachineInstr *MI, unsigned OpNo) {
213       printOp(MI->getOperand(OpNo));
214     }
215
216     void printPCRelativeOperand(const MachineInstr *MI, unsigned OpNo) {
217       printOp(MI->getOperand(OpNo));
218       O << "-.";
219     }
220
221     void printSymbolHi(const MachineInstr *MI, unsigned OpNo) {
222       if (MI->getOperand(OpNo).isImmediate()) {
223         printS16ImmOperand(MI, OpNo);
224       } else {
225         printOp(MI->getOperand(OpNo));
226         O << "@h";
227       }
228     }
229
230     void printSymbolLo(const MachineInstr *MI, unsigned OpNo) {
231       if (MI->getOperand(OpNo).isImmediate()) {
232         printS16ImmOperand(MI, OpNo);
233       } else {
234         printOp(MI->getOperand(OpNo));
235         O << "@l";
236       }
237     }
238
239     /// Print local store address
240     void printSymbolLSA(const MachineInstr *MI, unsigned OpNo) {
241       printOp(MI->getOperand(OpNo));
242     }
243
244     void printROTHNeg7Imm(const MachineInstr *MI, unsigned OpNo) {
245       if (MI->getOperand(OpNo).isImmediate()) {
246         int value = (int) MI->getOperand(OpNo).getImmedValue();
247         assert((value >= 0 && value < 16)
248                && "Invalid negated immediate rotate 7-bit argument");
249         O << -value;
250       } else {
251         assert(0 && "Invalid/non-immediate rotate amount in printRotateNeg7Imm");
252       }
253     }
254
255     void printROTNeg7Imm(const MachineInstr *MI, unsigned OpNo) {
256       if (MI->getOperand(OpNo).isImmediate()) {
257         int value = (int) MI->getOperand(OpNo).getImmedValue();
258         assert((value >= 0 && value < 32)
259                && "Invalid negated immediate rotate 7-bit argument");
260         O << -value;
261       } else {
262         assert(0 && "Invalid/non-immediate rotate amount in printRotateNeg7Imm");
263       }
264     }
265
266     virtual bool runOnMachineFunction(MachineFunction &F) = 0;
267     virtual bool doFinalization(Module &M) = 0;
268   };
269
270   /// LinuxAsmPrinter - SPU assembly printer, customized for Linux
271   struct VISIBILITY_HIDDEN LinuxAsmPrinter : public SPUAsmPrinter {
272   
273     DwarfWriter DW;
274
275     LinuxAsmPrinter(std::ostream &O, SPUTargetMachine &TM,
276                     const TargetAsmInfo *T) :
277       SPUAsmPrinter(O, TM, T),
278       DW(O, this, T)
279     { }
280
281     virtual const char *getPassName() const {
282       return "STI CBEA SPU Assembly Printer";
283     }
284     
285     bool runOnMachineFunction(MachineFunction &F);
286     bool doInitialization(Module &M);
287     bool doFinalization(Module &M);
288     
289     void getAnalysisUsage(AnalysisUsage &AU) const {
290       AU.setPreservesAll();
291       AU.addRequired<MachineModuleInfo>();
292       SPUAsmPrinter::getAnalysisUsage(AU);
293     }
294
295     /// getSectionForFunction - Return the section that we should emit the
296     /// specified function body into.
297     virtual std::string getSectionForFunction(const Function &F) const;
298   };
299 } // end of anonymous namespace
300
301 // Include the auto-generated portion of the assembly writer
302 #include "SPUGenAsmWriter.inc"
303
304 void SPUAsmPrinter::printOp(const MachineOperand &MO) {
305   switch (MO.getType()) {
306   case MachineOperand::MO_Immediate:
307     cerr << "printOp() does not handle immediate values\n";
308     abort();
309     return;
310
311   case MachineOperand::MO_MachineBasicBlock:
312     printBasicBlockLabel(MO.getMachineBasicBlock());
313     return;
314   case MachineOperand::MO_JumpTableIndex:
315     O << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
316       << '_' << MO.getJumpTableIndex();
317     // FIXME: PIC relocation model
318     return;
319   case MachineOperand::MO_ConstantPoolIndex:
320     O << TAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber()
321       << '_' << MO.getConstantPoolIndex();
322     return;
323   case MachineOperand::MO_ExternalSymbol:
324     // Computing the address of an external symbol, not calling it.
325     if (TM.getRelocationModel() != Reloc::Static) {
326       std::string Name(TAI->getGlobalPrefix()); Name += MO.getSymbolName();
327       GVStubs.insert(Name);
328       O << "L" << Name << "$non_lazy_ptr";
329       return;
330     }
331     O << TAI->getGlobalPrefix() << MO.getSymbolName();
332     return;
333   case MachineOperand::MO_GlobalAddress: {
334     // Computing the address of a global symbol, not calling it.
335     GlobalValue *GV = MO.getGlobal();
336     std::string Name = Mang->getValueName(GV);
337
338     // External or weakly linked global variables need non-lazily-resolved
339     // stubs
340     if (TM.getRelocationModel() != Reloc::Static) {
341       if (((GV->isDeclaration() || GV->hasWeakLinkage() ||
342             GV->hasLinkOnceLinkage()))) {
343         GVStubs.insert(Name);
344         O << "L" << Name << "$non_lazy_ptr";
345         return;
346       }
347     }
348     O << Name;
349     
350     if (GV->hasExternalWeakLinkage())
351       ExtWeakSymbols.insert(GV);
352     return;
353   }
354
355   default:
356     O << "<unknown operand type: " << MO.getType() << ">";
357     return;
358   }
359 }
360
361 /// PrintAsmOperand - Print out an operand for an inline asm expression.
362 ///
363 bool SPUAsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
364                                     unsigned AsmVariant, 
365                                     const char *ExtraCode) {
366   // Does this asm operand have a single letter operand modifier?
367   if (ExtraCode && ExtraCode[0]) {
368     if (ExtraCode[1] != 0) return true; // Unknown modifier.
369     
370     switch (ExtraCode[0]) {
371     default: return true;  // Unknown modifier.
372     case 'L': // Write second word of DImode reference.  
373       // Verify that this operand has two consecutive registers.
374       if (!MI->getOperand(OpNo).isRegister() ||
375           OpNo+1 == MI->getNumOperands() ||
376           !MI->getOperand(OpNo+1).isRegister())
377         return true;
378       ++OpNo;   // Return the high-part.
379       break;
380     }
381   }
382   
383   printOperand(MI, OpNo);
384   return false;
385 }
386
387 bool SPUAsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI,
388                                           unsigned OpNo,
389                                           unsigned AsmVariant, 
390                                           const char *ExtraCode) {
391   if (ExtraCode && ExtraCode[0])
392     return true; // Unknown modifier.
393   printMemRegReg(MI, OpNo);
394   return false;
395 }
396
397 /// printMachineInstruction -- Print out a single PowerPC MI in Darwin syntax
398 /// to the current output stream.
399 ///
400 void SPUAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
401   ++EmittedInsts;
402   printInstruction(MI);
403 }
404
405
406
407 std::string LinuxAsmPrinter::getSectionForFunction(const Function &F) const {
408   switch (F.getLinkage()) {
409   default: assert(0 && "Unknown linkage type!");
410   case Function::ExternalLinkage:
411   case Function::InternalLinkage: return TAI->getTextSection();
412   case Function::WeakLinkage:
413   case Function::LinkOnceLinkage:
414     return ""; // Print nothing for the time being...
415   }
416 }
417
418 /// runOnMachineFunction - This uses the printMachineInstruction()
419 /// method to print assembly for each instruction.
420 ///
421 bool
422 LinuxAsmPrinter::runOnMachineFunction(MachineFunction &MF)
423 {
424   DW.SetModuleInfo(&getAnalysis<MachineModuleInfo>());
425
426   SetupMachineFunction(MF);
427   O << "\n\n";
428   
429   // Print out constants referenced by the function
430   EmitConstantPool(MF.getConstantPool());
431
432   // Print out labels for the function.
433   const Function *F = MF.getFunction();
434
435   SwitchToTextSection(getSectionForFunction(*F).c_str(), F);
436   EmitAlignment(3, F);
437
438   switch (F->getLinkage()) {
439   default: assert(0 && "Unknown linkage type!");
440   case Function::InternalLinkage:  // Symbols default to internal.
441     break;
442   case Function::ExternalLinkage:
443     O << "\t.global\t" << CurrentFnName << "\n"
444       << "\t.type\t" << CurrentFnName << ", @function\n";
445     break;
446   case Function::WeakLinkage:
447   case Function::LinkOnceLinkage:
448     O << "\t.global\t" << CurrentFnName << "\n";
449     O << "\t.weak_definition\t" << CurrentFnName << "\n";
450     break;
451   }
452   O << CurrentFnName << ":\n";
453
454   // Emit pre-function debug information.
455   DW.BeginFunction(&MF);
456
457   // Print out code for the function.
458   for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
459        I != E; ++I) {
460     // Print a label for the basic block.
461     if (I != MF.begin()) {
462       printBasicBlockLabel(I, true);
463       O << '\n';
464     }
465     for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
466          II != E; ++II) {
467       // Print the assembly for the instruction.
468       O << "\t";
469       printMachineInstruction(II);
470     }
471   }
472
473   O << "\t.size\t" << CurrentFnName << ",.-" << CurrentFnName << "\n";
474
475   // Print out jump tables referenced by the function.
476   EmitJumpTableInfo(MF.getJumpTableInfo(), MF);
477   
478   // Emit post-function debug information.
479   DW.EndFunction();
480   
481   // We didn't modify anything.
482   return false;
483 }
484
485
486 bool LinuxAsmPrinter::doInitialization(Module &M) {
487   bool Result = AsmPrinter::doInitialization(M);
488   SwitchToTextSection(TAI->getTextSection());
489   // Emit initial debug information.
490   DW.BeginModule(&M);
491   return Result;
492 }
493
494 bool LinuxAsmPrinter::doFinalization(Module &M) {
495   const TargetData *TD = TM.getTargetData();
496
497   // Print out module-level global variables here.
498   for (Module::const_global_iterator I = M.global_begin(), E = M.global_end();
499        I != E; ++I) {
500     if (!I->hasInitializer()) continue;   // External global require no code
501     
502     // Check to see if this is a special global used by LLVM, if so, emit it.
503     if (EmitSpecialLLVMGlobal(I))
504       continue;
505     
506     std::string name = Mang->getValueName(I);
507     Constant *C = I->getInitializer();
508     unsigned Size = TD->getTypeStoreSize(C->getType());
509     unsigned Align = TD->getPreferredAlignmentLog(I);
510
511     if (C->isNullValue() && /* FIXME: Verify correct */
512         (I->hasInternalLinkage() || I->hasWeakLinkage() ||
513          I->hasLinkOnceLinkage() ||
514          (I->hasExternalLinkage() && !I->hasSection()))) {
515       if (Size == 0) Size = 1;   // .comm Foo, 0 is undefined, avoid it.
516       if (I->hasExternalLinkage()) {
517         // External linkage globals -> .bss section
518         // FIXME: Want to set the global variable's section so that
519         // SwitchToDataSection emits the ".section" directive
520         SwitchToDataSection("\t.section\t.bss", I);
521         O << "\t.global\t" << name << '\n';
522         O << "\t.align\t" << Align << '\n';
523         O << "\t.type\t" << name << ", @object\n";
524         O << "\t.size\t" << name << ", " << Size << '\n';
525         O << name << ":\n";
526         O << "\t.zero\t" << Size;
527       } else if (I->hasInternalLinkage()) {
528         SwitchToDataSection("\t.data", I);
529         O << TAI->getLCOMMDirective() << name << "," << Size << "," << Align;
530       } else {
531         SwitchToDataSection("\t.data", I);
532         O << ".comm " << name << "," << Size;
533       }
534       O << "\t\t# '" << I->getName() << "'\n";
535     } else {
536       switch (I->getLinkage()) {
537       case GlobalValue::LinkOnceLinkage:
538       case GlobalValue::WeakLinkage:
539         O << "\t.global " << name << '\n'
540           << "\t.weak_definition " << name << '\n';
541         SwitchToDataSection(".section __DATA,__datacoal_nt,coalesced", I);
542         break;
543       case GlobalValue::AppendingLinkage:
544         // FIXME: appending linkage variables should go into a section of
545         // their name or something.  For now, just emit them as external.
546       case GlobalValue::ExternalLinkage:
547         // If external or appending, declare as a global symbol
548         O << "\t.global " << name << "\n";
549         // FALL THROUGH
550       case GlobalValue::InternalLinkage:
551         if (I->isConstant()) {
552           const ConstantArray *CVA = dyn_cast<ConstantArray>(C);
553           if (TAI->getCStringSection() && CVA && CVA->isCString()) {
554             SwitchToDataSection(TAI->getCStringSection(), I);
555             break;
556           }
557         }
558
559         SwitchToDataSection("\t.data", I);
560         break;
561       default:
562         cerr << "Unknown linkage type!";
563         abort();
564       }
565
566       EmitAlignment(Align, I);
567       O << name << ":\t\t\t\t# '" << I->getName() << "'\n";
568
569       // If the initializer is a extern weak symbol, remember to emit the weak
570       // reference!
571       if (const GlobalValue *GV = dyn_cast<GlobalValue>(C))
572         if (GV->hasExternalWeakLinkage())
573           ExtWeakSymbols.insert(GV);
574
575       EmitGlobalConstant(C);
576       O << '\n';
577     }
578   }
579
580   // Output stubs for dynamically-linked functions
581   if (TM.getRelocationModel() == Reloc::PIC_) {
582     for (std::set<std::string>::iterator i = FnStubs.begin(), e = FnStubs.end();
583          i != e; ++i) {
584       SwitchToTextSection(".section __TEXT,__picsymbolstub1,symbol_stubs,"
585                           "pure_instructions,32");
586       EmitAlignment(4);
587       O << "L" << *i << "$stub:\n";
588       O << "\t.indirect_symbol " << *i << "\n";
589       O << "\tmflr r0\n";
590       O << "\tbcl 20,31,L0$" << *i << "\n";
591       O << "L0$" << *i << ":\n";
592       O << "\tmflr r11\n";
593       O << "\taddis r11,r11,ha16(L" << *i << "$lazy_ptr-L0$" << *i << ")\n";
594       O << "\tmtlr r0\n";
595       O << "\tlwzu r12,lo16(L" << *i << "$lazy_ptr-L0$" << *i << ")(r11)\n";
596       O << "\tmtctr r12\n";
597       O << "\tbctr\n";
598       SwitchToDataSection(".lazy_symbol_pointer");
599       O << "L" << *i << "$lazy_ptr:\n";
600       O << "\t.indirect_symbol " << *i << "\n";
601       O << "\t.long dyld_stub_binding_helper\n";
602     }
603   } else {
604     for (std::set<std::string>::iterator i = FnStubs.begin(), e = FnStubs.end();
605          i != e; ++i) {
606       SwitchToTextSection(".section __TEXT,__symbol_stub1,symbol_stubs,"
607                           "pure_instructions,16");
608       EmitAlignment(4);
609       O << "L" << *i << "$stub:\n";
610       O << "\t.indirect_symbol " << *i << "\n";
611       O << "\tlis r11,ha16(L" << *i << "$lazy_ptr)\n";
612       O << "\tlwzu r12,lo16(L" << *i << "$lazy_ptr)(r11)\n";
613       O << "\tmtctr r12\n";
614       O << "\tbctr\n";
615       SwitchToDataSection(".lazy_symbol_pointer");
616       O << "L" << *i << "$lazy_ptr:\n";
617       O << "\t.indirect_symbol " << *i << "\n";
618       O << "\t.long dyld_stub_binding_helper\n";
619     }
620   }
621
622   O << "\n";
623
624   // Output stubs for external and common global variables.
625   if (GVStubs.begin() != GVStubs.end()) {
626     SwitchToDataSection(".non_lazy_symbol_pointer");
627     for (std::set<std::string>::iterator I = GVStubs.begin(),
628          E = GVStubs.end(); I != E; ++I) {
629       O << "L" << *I << "$non_lazy_ptr:\n";
630       O << "\t.indirect_symbol " << *I << "\n";
631       O << "\t.long\t0\n";
632     }
633   }
634
635   // Emit initial debug information.
636   DW.EndModule();
637
638   // Emit ident information
639   O << "\t.ident\t\"(llvm 1.9+) STI CBEA Cell SPU backend\"\n";
640
641   return AsmPrinter::doFinalization(M);
642 }
643
644
645
646 /// createSPUCodePrinterPass - Returns a pass that prints the Cell SPU
647 /// assembly code for a MachineFunction to the given output stream, in a format
648 /// that the Linux SPU assembler can deal with.
649 ///
650 FunctionPass *llvm::createSPUAsmPrinterPass(std::ostream &o,
651                                             SPUTargetMachine &tm) {
652   return new LinuxAsmPrinter(o, tm, tm.getTargetAsmInfo());
653 }
654