No need to generate a lazy-linking stub for internal functions, they can be
[oota-llvm.git] / lib / Target / PowerPC / PPCAsmPrinter.cpp
1 //===-- PPC32/Printer.cpp - Convert X86 LLVM code to Intel assembly ---------===//
2 // 
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 // 
8 //===----------------------------------------------------------------------===//
9 //
10 // This file contains a printer that converts from our internal
11 // representation of machine-dependent LLVM code to Intel-format
12 // assembly language. This printer is the output mechanism used
13 // by `llc' and `lli -print-machineinstrs' on X86.
14 //
15 //===----------------------------------------------------------------------===//
16
17 #define DEBUG_TYPE "asmprinter"
18 #include "PowerPC.h"
19 #include "PowerPCInstrInfo.h"
20 #include "llvm/Constants.h"
21 #include "llvm/DerivedTypes.h"
22 #include "llvm/Module.h"
23 #include "llvm/Assembly/Writer.h"
24 #include "llvm/CodeGen/MachineConstantPool.h"
25 #include "llvm/CodeGen/MachineFunctionPass.h"
26 #include "llvm/CodeGen/MachineInstr.h"
27 #include "llvm/Target/TargetMachine.h"
28 #include "llvm/Support/Mangler.h"
29 #include "Support/CommandLine.h"
30 #include "Support/Debug.h"
31 #include "Support/Statistic.h"
32 #include "Support/StringExtras.h"
33 #include <set>
34
35 namespace llvm {
36
37 namespace {
38   Statistic<> EmittedInsts("asm-printer", "Number of machine instrs printed");
39
40   struct Printer : public MachineFunctionPass {
41     /// Output stream on which we're printing assembly code.
42     ///
43     std::ostream &O;
44
45     /// Target machine description which we query for reg. names, data
46     /// layout, etc.
47     ///
48     TargetMachine &TM;
49
50     /// Name-mangler for global names.
51     ///
52     Mangler *Mang;
53     std::set<std::string> Stubs;
54     std::set<std::string> Strings;
55
56     Printer(std::ostream &o, TargetMachine &tm) : O(o), TM(tm) { }
57
58     /// Cache of mangled name for current function. This is
59     /// recalculated at the beginning of each call to
60     /// runOnMachineFunction().
61     ///
62     std::string CurrentFnName;
63
64     virtual const char *getPassName() const {
65       return "PowerPC Assembly Printer";
66     }
67
68     void printMachineInstruction(const MachineInstr *MI);
69     void printOp(const MachineOperand &MO, bool elideOffsetKeyword = false);
70     void printConstantPool(MachineConstantPool *MCP);
71     bool runOnMachineFunction(MachineFunction &F);    
72     bool doInitialization(Module &M);
73     bool doFinalization(Module &M);
74     void emitGlobalConstant(const Constant* CV);
75     void emitConstantValueOnly(const Constant *CV);
76   };
77 } // end of anonymous namespace
78
79 /// createPPCCodePrinterPass - Returns a pass that prints the X86
80 /// assembly code for a MachineFunction to the given output stream,
81 /// using the given target machine description.  This should work
82 /// regardless of whether the function is in SSA form.
83 ///
84 FunctionPass *createPPCCodePrinterPass(std::ostream &o,TargetMachine &tm) {
85   return new Printer(o, tm);
86 }
87
88 /// isStringCompatible - Can we treat the specified array as a string?
89 /// Only if it is an array of ubytes or non-negative sbytes.
90 ///
91 static bool isStringCompatible(const ConstantArray *CVA) {
92   const Type *ETy = cast<ArrayType>(CVA->getType())->getElementType();
93   if (ETy == Type::UByteTy) return true;
94   if (ETy != Type::SByteTy) return false;
95
96   for (unsigned i = 0; i < CVA->getNumOperands(); ++i)
97     if (cast<ConstantSInt>(CVA->getOperand(i))->getValue() < 0)
98       return false;
99
100   return true;
101 }
102
103 /// toOctal - Convert the low order bits of X into an octal digit.
104 ///
105 static inline char toOctal(int X) {
106   return (X&7)+'0';
107 }
108
109 /// getAsCString - Return the specified array as a C compatible
110 /// string, only if the predicate isStringCompatible is true.
111 ///
112 static void printAsCString(std::ostream &O, const ConstantArray *CVA) {
113   assert(isStringCompatible(CVA) && "Array is not string compatible!");
114
115   O << "\"";
116   for (unsigned i = 0; i < CVA->getNumOperands(); ++i) {
117     unsigned char C = cast<ConstantInt>(CVA->getOperand(i))->getRawValue();
118
119     if (C == '"') {
120       O << "\\\"";
121     } else if (C == '\\') {
122       O << "\\\\";
123     } else if (isprint(C)) {
124       O << C;
125     } else {
126       switch(C) {
127       case '\b': O << "\\b"; break;
128       case '\f': O << "\\f"; break;
129       case '\n': O << "\\n"; break;
130       case '\r': O << "\\r"; break;
131       case '\t': O << "\\t"; break;
132       default:
133         O << '\\';
134         O << toOctal(C >> 6);
135         O << toOctal(C >> 3);
136         O << toOctal(C >> 0);
137         break;
138       }
139     }
140   }
141   O << "\"";
142 }
143
144 // Print out the specified constant, without a storage class.  Only the
145 // constants valid in constant expressions can occur here.
146 void Printer::emitConstantValueOnly(const Constant *CV) {
147   if (CV->isNullValue())
148     O << "0";
149   else if (const ConstantBool *CB = dyn_cast<ConstantBool>(CV)) {
150     assert(CB == ConstantBool::True);
151     O << "1";
152   } else if (const ConstantSInt *CI = dyn_cast<ConstantSInt>(CV))
153     O << CI->getValue();
154   else if (const ConstantUInt *CI = dyn_cast<ConstantUInt>(CV))
155     O << CI->getValue();
156   else if (const ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(CV))
157     // This is a constant address for a global variable or function.  Use the
158     // name of the variable or function as the address value.
159     O << Mang->getValueName(CPR->getValue());
160   else if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(CV)) {
161     const TargetData &TD = TM.getTargetData();
162     switch(CE->getOpcode()) {
163     case Instruction::GetElementPtr: {
164       // generate a symbolic expression for the byte address
165       const Constant *ptrVal = CE->getOperand(0);
166       std::vector<Value*> idxVec(CE->op_begin()+1, CE->op_end());
167       if (unsigned Offset = TD.getIndexedOffset(ptrVal->getType(), idxVec)) {
168         O << "(";
169         emitConstantValueOnly(ptrVal);
170         O << ") + " << Offset;
171       } else {
172         emitConstantValueOnly(ptrVal);
173       }
174       break;
175     }
176     case Instruction::Cast: {
177       // Support only non-converting or widening casts for now, that is, ones
178       // that do not involve a change in value.  This assertion is really gross,
179       // and may not even be a complete check.
180       Constant *Op = CE->getOperand(0);
181       const Type *OpTy = Op->getType(), *Ty = CE->getType();
182
183       // Remember, kids, pointers on x86 can be losslessly converted back and
184       // forth into 32-bit or wider integers, regardless of signedness. :-P
185       assert(((isa<PointerType>(OpTy)
186                && (Ty == Type::LongTy || Ty == Type::ULongTy
187                    || Ty == Type::IntTy || Ty == Type::UIntTy))
188               || (isa<PointerType>(Ty)
189                   && (OpTy == Type::LongTy || OpTy == Type::ULongTy
190                       || OpTy == Type::IntTy || OpTy == Type::UIntTy))
191               || (((TD.getTypeSize(Ty) >= TD.getTypeSize(OpTy))
192                    && OpTy->isLosslesslyConvertibleTo(Ty))))
193              && "FIXME: Don't yet support this kind of constant cast expr");
194       O << "(";
195       emitConstantValueOnly(Op);
196       O << ")";
197       break;
198     }
199     case Instruction::Add:
200       O << "(";
201       emitConstantValueOnly(CE->getOperand(0));
202       O << ") + (";
203       emitConstantValueOnly(CE->getOperand(1));
204       O << ")";
205       break;
206     default:
207       assert(0 && "Unsupported operator!");
208     }
209   } else {
210     assert(0 && "Unknown constant value!");
211   }
212 }
213
214 // Print a constant value or values, with the appropriate storage class as a
215 // prefix.
216 void Printer::emitGlobalConstant(const Constant *CV) {  
217   const TargetData &TD = TM.getTargetData();
218
219   if (CV->isNullValue()) {
220     O << "\t.space\t " << TD.getTypeSize(CV->getType()) << "\n";      
221     return;
222   } else if (const ConstantArray *CVA = dyn_cast<ConstantArray>(CV)) {
223     if (isStringCompatible(CVA)) {
224       O << ".ascii";
225       printAsCString(O, CVA);
226       O << "\n";
227     } else { // Not a string.  Print the values in successive locations
228       const std::vector<Use> &constValues = CVA->getValues();
229       for (unsigned i=0; i < constValues.size(); i++)
230         emitGlobalConstant(cast<Constant>(constValues[i].get()));
231     }
232     return;
233   } else if (const ConstantStruct *CVS = dyn_cast<ConstantStruct>(CV)) {
234     // Print the fields in successive locations. Pad to align if needed!
235     const StructLayout *cvsLayout = TD.getStructLayout(CVS->getType());
236     const std::vector<Use>& constValues = CVS->getValues();
237     unsigned sizeSoFar = 0;
238     for (unsigned i=0, N = constValues.size(); i < N; i++) {
239       const Constant* field = cast<Constant>(constValues[i].get());
240
241       // Check if padding is needed and insert one or more 0s.
242       unsigned fieldSize = TD.getTypeSize(field->getType());
243       unsigned padSize = ((i == N-1? cvsLayout->StructSize
244                            : cvsLayout->MemberOffsets[i+1])
245                           - cvsLayout->MemberOffsets[i]) - fieldSize;
246       sizeSoFar += fieldSize + padSize;
247
248       // Now print the actual field value
249       emitGlobalConstant(field);
250
251       // Insert the field padding unless it's zero bytes...
252       if (padSize)
253         O << "\t.space\t " << padSize << "\n";      
254     }
255     assert(sizeSoFar == cvsLayout->StructSize &&
256            "Layout of constant struct may be incorrect!");
257     return;
258   } else if (const ConstantFP *CFP = dyn_cast<ConstantFP>(CV)) {
259     // FP Constants are printed as integer constants to avoid losing
260     // precision...
261     double Val = CFP->getValue();
262     switch (CFP->getType()->getTypeID()) {
263     default: assert(0 && "Unknown floating point type!");
264     case Type::FloatTyID: {
265       union FU {                            // Abide by C TBAA rules
266         float FVal;
267         unsigned UVal;
268       } U;
269       U.FVal = Val;
270       O << ".long\t" << U.UVal << "\t# float " << Val << "\n";
271       return;
272     }
273     case Type::DoubleTyID: {
274       union DU {                            // Abide by C TBAA rules
275         double FVal;
276         uint64_t UVal;
277         struct {
278           uint32_t MSWord;
279           uint32_t LSWord;
280         } T;
281       } U;
282       U.FVal = Val;
283       
284       O << ".long\t" << U.T.MSWord << "\t# double most significant word " 
285         << Val << "\n";
286       O << ".long\t" << U.T.LSWord << "\t# double least significant word" 
287         << Val << "\n";
288       return;
289     }
290     }
291   } else if (CV->getType()->getPrimitiveSize() == 64) {
292     if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) {
293       union DU {                            // Abide by C TBAA rules
294         int64_t UVal;
295         struct {
296           uint32_t MSWord;
297           uint32_t LSWord;
298         } T;
299       } U;
300       U.UVal = CI->getRawValue();
301         
302       O << ".long\t" << U.T.MSWord << "\t# Double-word most significant word " 
303         << U.UVal << "\n";
304       O << ".long\t" << U.T.LSWord << "\t# Double-word least significant word" 
305         << U.UVal << "\n";
306       return;
307     }
308   }
309
310   const Type *type = CV->getType();
311   O << "\t";
312   switch (type->getTypeID()) {
313   case Type::UByteTyID: case Type::SByteTyID:
314     O << ".byte";
315     break;
316   case Type::UShortTyID: case Type::ShortTyID:
317     O << ".short";
318     break;
319   case Type::BoolTyID: 
320   case Type::PointerTyID:
321   case Type::UIntTyID: case Type::IntTyID:
322     O << ".long";
323     break;
324   case Type::ULongTyID: case Type::LongTyID:    
325     assert (0 && "Should have already output double-word constant.");
326   case Type::FloatTyID: case Type::DoubleTyID:
327     assert (0 && "Should have already output floating point constant.");
328   default:
329     assert (0 && "Can't handle printing this type of thing");
330     break;
331   }
332   O << "\t";
333   emitConstantValueOnly(CV);
334   O << "\n";
335 }
336
337 /// printConstantPool - Print to the current output stream assembly
338 /// representations of the constants in the constant pool MCP. This is
339 /// used to print out constants which have been "spilled to memory" by
340 /// the code generator.
341 ///
342 void Printer::printConstantPool(MachineConstantPool *MCP) {
343   const std::vector<Constant*> &CP = MCP->getConstants();
344   const TargetData &TD = TM.getTargetData();
345  
346   if (CP.empty()) return;
347
348   for (unsigned i = 0, e = CP.size(); i != e; ++i) {
349     O << "\t.const\n";
350     O << "\t.align " << (unsigned)TD.getTypeAlignment(CP[i]->getType())
351       << "\n";
352     O << ".CPI" << CurrentFnName << "_" << i << ":\t\t\t\t\t#"
353       << *CP[i] << "\n";
354     emitGlobalConstant(CP[i]);
355   }
356 }
357
358 /// runOnMachineFunction - This uses the printMachineInstruction()
359 /// method to print assembly for each instruction.
360 ///
361 bool Printer::runOnMachineFunction(MachineFunction &MF) {
362   // BBNumber is used here so that a given Printer will never give two
363   // BBs the same name. (If you have a better way, please let me know!)
364   static unsigned BBNumber = 0;
365
366   O << "\n\n";
367   // What's my mangled name?
368   CurrentFnName = Mang->getValueName(MF.getFunction());
369
370   // Print out constants referenced by the function
371   printConstantPool(MF.getConstantPool());
372
373   // Print out labels for the function.
374   O << "\t.text\n"; 
375   O << "\t.globl\t" << CurrentFnName << "\n";
376   O << "\t.align 5\n";
377   O << CurrentFnName << ":\n";
378
379   // Print out code for the function.
380   for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
381        I != E; ++I) {
382     // Print a label for the basic block.
383     O << ".LBB" << CurrentFnName << "_" << I->getNumber() << ":\t# "
384       << I->getBasicBlock()->getName() << "\n";
385     for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
386       II != E; ++II) {
387       // Print the assembly for the instruction.
388       O << "\t";
389       printMachineInstruction(II);
390     }
391   }
392
393   // We didn't modify anything.
394   return false;
395 }
396
397 void Printer::printOp(const MachineOperand &MO,
398                       bool elideOffsetKeyword /* = false */) {
399   const MRegisterInfo &RI = *TM.getRegisterInfo();
400   int new_symbol;
401   
402   switch (MO.getType()) {
403   case MachineOperand::MO_VirtualRegister:
404     if (Value *V = MO.getVRegValueOrNull()) {
405       O << "<" << V->getName() << ">";
406       return;
407     }
408     // FALLTHROUGH
409   case MachineOperand::MO_MachineRegister:
410     O << LowercaseString(RI.get(MO.getReg()).Name);
411     return;
412
413   case MachineOperand::MO_SignExtendedImmed:
414   case MachineOperand::MO_UnextendedImmed:
415     O << (int)MO.getImmedValue();
416     return;
417   case MachineOperand::MO_MachineBasicBlock: {
418     MachineBasicBlock *MBBOp = MO.getMachineBasicBlock();
419     O << ".LBB" << Mang->getValueName(MBBOp->getParent()->getFunction())
420       << "_" << MBBOp->getNumber() << "\t# "
421       << MBBOp->getBasicBlock()->getName();
422     return;
423   }
424   case MachineOperand::MO_PCRelativeDisp:
425     std::cerr << "Shouldn't use addPCDisp() when building PPC MachineInstrs";
426     abort();
427     return;
428   case MachineOperand::MO_GlobalAddress:
429     if (!elideOffsetKeyword) {
430       // Dynamically-resolved functions need a stub for the function
431       Function *F = dyn_cast<Function>(MO.getGlobal());
432       if (F && F->isExternal()) {
433         Stubs.insert(Mang->getValueName(MO.getGlobal()));
434         O << "L" << Mang->getValueName(MO.getGlobal()) << "$stub";
435       } else {
436         O << Mang->getValueName(MO.getGlobal());
437       }
438     }
439     return;
440   case MachineOperand::MO_ExternalSymbol:
441     O << MO.getSymbolName();
442     return;
443   default:
444     O << "<unknown operand type>";
445     return;
446   }
447 }
448
449 #if 0
450 static inline
451 unsigned int ValidOpcodes(const MachineInstr *MI, unsigned int ArgType[5]) {
452   int i;
453   unsigned int retval = 1;
454   
455   for(i = 0; i<5; i++) {
456     switch(ArgType[i]) {
457       case none:
458         break;
459       case Gpr:
460       case Gpr0:
461         Type::UIntTy
462       case Simm16:
463       case Zimm16:
464       case PCRelimm24:
465       case Imm24:
466       case Imm5:
467       case PCRelimm14:
468       case Imm14:
469       case Imm2:
470       case Crf:
471       case Imm3:
472       case Imm1:
473       case Fpr:
474       case Imm4:
475       case Imm8:
476       case Disimm16:
477       case Spr:
478       case Sgr:
479   };
480     
481     }
482   }
483 }
484 #endif
485
486 /// printMachineInstruction -- Print out a single PPC32 LLVM instruction
487 /// MI in Darwin syntax to the current output stream.
488 ///
489 void Printer::printMachineInstruction(const MachineInstr *MI) {
490   unsigned Opcode = MI->getOpcode();
491   const TargetInstrInfo &TII = *TM.getInstrInfo();
492   const TargetInstrDescriptor &Desc = TII.get(Opcode);
493   unsigned int i;
494
495   unsigned int ArgCount = Desc.TSFlags & PPC32II::ArgCountMask;
496   unsigned int ArgType[] = {
497     (Desc.TSFlags >> PPC32II::Arg0TypeShift) & PPC32II::ArgTypeMask,
498     (Desc.TSFlags >> PPC32II::Arg1TypeShift) & PPC32II::ArgTypeMask,
499     (Desc.TSFlags >> PPC32II::Arg2TypeShift) & PPC32II::ArgTypeMask,
500     (Desc.TSFlags >> PPC32II::Arg3TypeShift) & PPC32II::ArgTypeMask,
501     (Desc.TSFlags >> PPC32II::Arg4TypeShift) & PPC32II::ArgTypeMask
502   };
503   assert(((Desc.TSFlags & PPC32II::VMX) == 0) &&
504          "Instruction requires VMX support");
505   assert(((Desc.TSFlags & PPC32II::PPC64) == 0) &&
506          "Instruction requires 64 bit support");
507   //assert ( ValidOpcodes(MI, ArgType) && "Instruction has invalid inputs");
508   ++EmittedInsts;
509
510   if (Opcode == PPC32::MovePCtoLR) {
511     O << "mflr r0\n";
512     O << "\tbc 20,31,L" << CurrentFnName << "$pb\n";
513     O << "L" << CurrentFnName << "$pb:\n";
514     return;
515   }
516
517   O << TII.getName(MI->getOpcode()) << " ";
518   DEBUG(std::cerr << TII.getName(MI->getOpcode()) << " expects " 
519                   << ArgCount << " args\n");
520
521   if (Opcode == PPC32::LOADLoAddr) {
522     printOp(MI->getOperand(0));
523     O << ", ";
524     printOp(MI->getOperand(1));
525     O << ", lo16(";
526     printOp(MI->getOperand(2));
527     O << "-L" << CurrentFnName << "$pb)\n";
528   } else if (Opcode == PPC32::LOADHiAddr) {
529     printOp(MI->getOperand(0));
530     O << ", ";
531     printOp(MI->getOperand(1));
532     O << ", ha16(" ;
533     printOp(MI->getOperand(2));
534      O << "-L" << CurrentFnName << "$pb)\n";
535   } else if (ArgCount == 3 && ArgType[1] == PPC32II::Disimm16) {
536     printOp(MI->getOperand(0));
537     O << ", ";
538     printOp(MI->getOperand(1));
539     O << "(";
540     if (ArgType[2] == PPC32II::Gpr0 && MI->getOperand(2).getReg() == PPC32::R0)
541       O << "0";
542     else
543       printOp(MI->getOperand(2));
544     O << ")\n";
545   } else {
546     for (i = 0; i < ArgCount; ++i) {
547       if (ArgType[i] == PPC32II::Gpr0 && 
548           MI->getOperand(i).getReg() == PPC32::R0)
549         O << "0";
550       else {
551         //std::cout << "DEBUG " << (*(TM.getRegisterInfo())).get(MI->getOperand(i).getReg()).Name << "\n";
552         printOp(MI->getOperand(i));
553       }
554       if (ArgCount - 1 == i)
555         O << "\n";
556       else
557         O << ", ";
558     }
559   }
560 }
561
562 bool Printer::doInitialization(Module &M) {
563   Mang = new Mangler(M, true);
564   return false; // success
565 }
566
567 // SwitchSection - Switch to the specified section of the executable if we are
568 // not already in it!
569 //
570 static void SwitchSection(std::ostream &OS, std::string &CurSection,
571                           const char *NewSection) {
572   if (CurSection != NewSection) {
573     CurSection = NewSection;
574     if (!CurSection.empty())
575       OS << "\t" << NewSection << "\n";
576   }
577 }
578
579 bool Printer::doFinalization(Module &M) {
580   const TargetData &TD = TM.getTargetData();
581   std::string CurSection;
582
583   // Print out module-level global variables here.
584   for (Module::const_giterator I = M.gbegin(), E = M.gend(); I != E; ++I)
585     if (I->hasInitializer()) {   // External global require no code
586       O << "\n\n";
587       std::string name = Mang->getValueName(I);
588       Constant *C = I->getInitializer();
589       unsigned Size = TD.getTypeSize(C->getType());
590       unsigned Align = TD.getTypeAlignment(C->getType());
591
592       if (C->isNullValue() && 
593           (I->hasLinkOnceLinkage() || I->hasInternalLinkage() ||
594            I->hasWeakLinkage() /* FIXME: Verify correct */)) {
595         SwitchSection(O, CurSection, ".data");
596         if (I->hasInternalLinkage())
597           O << "\t.local " << name << "\n";
598         
599         O << "\t.comm " << name << "," << TD.getTypeSize(C->getType())
600           << "," << (unsigned)TD.getTypeAlignment(C->getType());
601         O << "\t\t# ";
602         WriteAsOperand(O, I, true, true, &M);
603         O << "\n";
604       } else {
605         switch (I->getLinkage()) {
606         case GlobalValue::LinkOnceLinkage:
607         case GlobalValue::WeakLinkage:   // FIXME: Verify correct for weak.
608           // Nonnull linkonce -> weak
609           O << "\t.weak " << name << "\n";
610           SwitchSection(O, CurSection, "");
611           O << "\t.section\t.llvm.linkonce.d." << name << ",\"aw\",@progbits\n";
612           break;
613         
614         case GlobalValue::AppendingLinkage:
615           // FIXME: appending linkage variables should go into a section of
616           // their name or something.  For now, just emit them as external.
617         case GlobalValue::ExternalLinkage:
618           // If external or appending, declare as a global symbol
619           O << "\t.globl " << name << "\n";
620           // FALL THROUGH
621         case GlobalValue::InternalLinkage:
622           if (C->isNullValue())
623             SwitchSection(O, CurSection, ".bss");
624           else
625             SwitchSection(O, CurSection, ".data");
626           break;
627         }
628
629         O << "\t.align " << Align << "\n";
630         O << name << ":\t\t\t\t# ";
631         WriteAsOperand(O, I, true, true, &M);
632         O << " = ";
633         WriteAsOperand(O, C, false, false, &M);
634         O << "\n";
635         emitGlobalConstant(C);
636       }
637     }
638         
639   for(std::set<std::string>::iterator i = Stubs.begin(); i != Stubs.end(); ++i)
640   {
641     O << ".data\n";     
642     O<<".section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32\n";
643     O << "\t.align 2\n";
644     O << "L" << *i << "$stub:\n";
645     O << "\t.indirect_symbol " << *i << "\n";
646     O << "\tmflr r0\n";
647     O << "\tbcl 20,31,L0$" << *i << "\n";
648     O << "L0$" << *i << ":\n";
649     O << "\tmflr r11\n";
650     O << "\taddis r11,r11,ha16(L" << *i << "$lazy_ptr-L0$" << *i << ")\n";
651     O << "\tmtlr r0\n";
652     O << "\tlwzu r12,lo16(L" << *i << "$lazy_ptr-L0$" << *i << ")(r11)\n";
653     O << "\tmtctr r12\n";
654     O << "\tbctr\n";
655     O << ".data\n";
656     O << ".lazy_symbol_pointer\n";
657     O << "L" << *i << "$lazy_ptr:\n";
658     O << ".indirect_symbol " << *i << "\n";
659     O << ".long dyld_stub_binding_helper\n";
660   }
661
662   delete Mang;
663   return false; // success
664 }
665
666 } // End llvm namespace