1 //===-- PPCAsmPrinter.cpp - Print machine instrs to PowerPC assembly --------=//
3 // The LLVM Compiler Infrastructure
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.
8 //===----------------------------------------------------------------------===//
10 // This file contains a printer that converts from our internal representation
11 // of machine-dependent LLVM code to PowerPC assembly language. This printer is
12 // the output mechanism used by `llc'.
14 // Documentation at http://developer.apple.com/documentation/DeveloperTools/
15 // Reference/Assembler/ASMIntroduction/chapter_1_section_1.html
17 //===----------------------------------------------------------------------===//
19 #define DEBUG_TYPE "asmprinter"
21 #include "PPCPredicates.h"
22 #include "PPCTargetMachine.h"
23 #include "PPCSubtarget.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/MachineDebugInfo.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"
49 Statistic<> EmittedInsts("asm-printer", "Number of machine instrs printed");
51 struct VISIBILITY_HIDDEN PPCAsmPrinter : public AsmPrinter {
52 std::set<std::string> FnStubs, GVStubs;
53 const PPCSubtarget &Subtarget;
55 PPCAsmPrinter(std::ostream &O, TargetMachine &TM, const TargetAsmInfo *T)
56 : AsmPrinter(O, TM, T), Subtarget(TM.getSubtarget<PPCSubtarget>()) {
59 virtual const char *getPassName() const {
60 return "PowerPC Assembly Printer";
63 PPCTargetMachine &getTM() {
64 return static_cast<PPCTargetMachine&>(TM);
67 unsigned enumRegToMachineReg(unsigned enumReg) {
69 default: assert(0 && "Unhandled register!"); break;
70 case PPC::CR0: return 0;
71 case PPC::CR1: return 1;
72 case PPC::CR2: return 2;
73 case PPC::CR3: return 3;
74 case PPC::CR4: return 4;
75 case PPC::CR5: return 5;
76 case PPC::CR6: return 6;
77 case PPC::CR7: return 7;
82 /// printInstruction - This method is automatically generated by tablegen
83 /// from the instruction set description. This method returns true if the
84 /// machine instruction was sufficiently described to print it, otherwise it
86 bool printInstruction(const MachineInstr *MI);
88 void printMachineInstruction(const MachineInstr *MI);
89 void printOp(const MachineOperand &MO);
91 void printOperand(const MachineInstr *MI, unsigned OpNo) {
92 const MachineOperand &MO = MI->getOperand(OpNo);
93 if (MO.isRegister()) {
94 assert(MRegisterInfo::isPhysicalRegister(MO.getReg())&&"Not physreg??");
95 O << TM.getRegisterInfo()->get(MO.getReg()).Name;
96 } else if (MO.isImmediate()) {
97 O << MO.getImmedValue();
103 bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
104 unsigned AsmVariant, const char *ExtraCode);
105 bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
106 unsigned AsmVariant, const char *ExtraCode);
109 void printS5ImmOperand(const MachineInstr *MI, unsigned OpNo) {
110 char value = MI->getOperand(OpNo).getImmedValue();
111 value = (value << (32-5)) >> (32-5);
114 void printU5ImmOperand(const MachineInstr *MI, unsigned OpNo) {
115 unsigned char value = MI->getOperand(OpNo).getImmedValue();
116 assert(value <= 31 && "Invalid u5imm argument!");
117 O << (unsigned int)value;
119 void printU6ImmOperand(const MachineInstr *MI, unsigned OpNo) {
120 unsigned char value = MI->getOperand(OpNo).getImmedValue();
121 assert(value <= 63 && "Invalid u6imm argument!");
122 O << (unsigned int)value;
124 void printS16ImmOperand(const MachineInstr *MI, unsigned OpNo) {
125 O << (short)MI->getOperand(OpNo).getImmedValue();
127 void printU16ImmOperand(const MachineInstr *MI, unsigned OpNo) {
128 O << (unsigned short)MI->getOperand(OpNo).getImmedValue();
130 void printS16X4ImmOperand(const MachineInstr *MI, unsigned OpNo) {
131 if (MI->getOperand(OpNo).isImmediate()) {
132 O << (short)(MI->getOperand(OpNo).getImmedValue()*4);
135 printOp(MI->getOperand(OpNo));
136 if (TM.getRelocationModel() == Reloc::PIC_)
137 O << "-\"L" << getFunctionNumber() << "$pb\")";
142 void printBranchOperand(const MachineInstr *MI, unsigned OpNo) {
143 // Branches can take an immediate operand. This is used by the branch
144 // selection pass to print $+8, an eight byte displacement from the PC.
145 if (MI->getOperand(OpNo).isImmediate()) {
146 O << "$+" << MI->getOperand(OpNo).getImmedValue()*4;
148 printOp(MI->getOperand(OpNo));
151 void printCallOperand(const MachineInstr *MI, unsigned OpNo) {
152 const MachineOperand &MO = MI->getOperand(OpNo);
153 if (TM.getRelocationModel() != Reloc::Static) {
154 if (MO.getType() == MachineOperand::MO_GlobalAddress) {
155 GlobalValue *GV = MO.getGlobal();
156 if (((GV->isExternal() || GV->hasWeakLinkage() ||
157 GV->hasLinkOnceLinkage()))) {
158 // Dynamically-resolved functions need a stub for the function.
159 std::string Name = Mang->getValueName(GV);
160 FnStubs.insert(Name);
161 O << "L" << Name << "$stub";
165 if (MO.getType() == MachineOperand::MO_ExternalSymbol) {
166 std::string Name(TAI->getGlobalPrefix()); Name += MO.getSymbolName();
167 FnStubs.insert(Name);
168 O << "L" << Name << "$stub";
173 printOp(MI->getOperand(OpNo));
175 void printAbsAddrOperand(const MachineInstr *MI, unsigned OpNo) {
176 O << (int)MI->getOperand(OpNo).getImmedValue()*4;
178 void printPICLabel(const MachineInstr *MI, unsigned OpNo) {
179 O << "\"L" << getFunctionNumber() << "$pb\"\n";
180 O << "\"L" << getFunctionNumber() << "$pb\":";
182 void printSymbolHi(const MachineInstr *MI, unsigned OpNo) {
183 if (MI->getOperand(OpNo).isImmediate()) {
184 printS16ImmOperand(MI, OpNo);
187 printOp(MI->getOperand(OpNo));
188 if (TM.getRelocationModel() == Reloc::PIC_)
189 O << "-\"L" << getFunctionNumber() << "$pb\")";
194 void printSymbolLo(const MachineInstr *MI, unsigned OpNo) {
195 if (MI->getOperand(OpNo).isImmediate()) {
196 printS16ImmOperand(MI, OpNo);
199 printOp(MI->getOperand(OpNo));
200 if (TM.getRelocationModel() == Reloc::PIC_)
201 O << "-\"L" << getFunctionNumber() << "$pb\")";
206 void printcrbitm(const MachineInstr *MI, unsigned OpNo) {
207 unsigned CCReg = MI->getOperand(OpNo).getReg();
208 unsigned RegNo = enumRegToMachineReg(CCReg);
209 O << (0x80 >> RegNo);
211 // The new addressing mode printers.
212 void printMemRegImm(const MachineInstr *MI, unsigned OpNo) {
213 printSymbolLo(MI, OpNo);
215 if (MI->getOperand(OpNo+1).isRegister() &&
216 MI->getOperand(OpNo+1).getReg() == PPC::R0)
219 printOperand(MI, OpNo+1);
222 void printMemRegImmShifted(const MachineInstr *MI, unsigned OpNo) {
223 if (MI->getOperand(OpNo).isImmediate())
224 printS16X4ImmOperand(MI, OpNo);
226 printSymbolLo(MI, OpNo);
228 if (MI->getOperand(OpNo+1).isRegister() &&
229 MI->getOperand(OpNo+1).getReg() == PPC::R0)
232 printOperand(MI, OpNo+1);
236 void printMemRegReg(const MachineInstr *MI, unsigned OpNo) {
237 // When used as the base register, r0 reads constant zero rather than
238 // the value contained in the register. For this reason, the darwin
239 // assembler requires that we print r0 as 0 (no r) when used as the base.
240 const MachineOperand &MO = MI->getOperand(OpNo);
241 if (MO.getReg() == PPC::R0)
244 O << TM.getRegisterInfo()->get(MO.getReg()).Name;
246 printOperand(MI, OpNo+1);
249 void printPredicateOperand(const MachineInstr *MI, unsigned OpNo,
250 const char *Modifier);
252 virtual bool runOnMachineFunction(MachineFunction &F) = 0;
253 virtual bool doFinalization(Module &M) = 0;
256 /// DarwinAsmPrinter - PowerPC assembly printer, customized for Darwin/Mac OS
258 struct VISIBILITY_HIDDEN DarwinAsmPrinter : public PPCAsmPrinter {
262 DarwinAsmPrinter(std::ostream &O, PPCTargetMachine &TM,
263 const TargetAsmInfo *T)
264 : PPCAsmPrinter(O, TM, T), DW(O, this, T) {
267 virtual const char *getPassName() const {
268 return "Darwin PPC Assembly Printer";
271 bool runOnMachineFunction(MachineFunction &F);
272 bool doInitialization(Module &M);
273 bool doFinalization(Module &M);
275 void getAnalysisUsage(AnalysisUsage &AU) const {
276 AU.setPreservesAll();
277 AU.addRequired<MachineDebugInfo>();
278 PPCAsmPrinter::getAnalysisUsage(AU);
281 /// getSectionForFunction - Return the section that we should emit the
282 /// specified function body into.
283 virtual std::string getSectionForFunction(const Function &F) const;
285 } // end of anonymous namespace
287 // Include the auto-generated portion of the assembly writer
288 #include "PPCGenAsmWriter.inc"
290 void PPCAsmPrinter::printOp(const MachineOperand &MO) {
291 switch (MO.getType()) {
292 case MachineOperand::MO_Immediate:
293 std::cerr << "printOp() does not handle immediate values\n";
297 case MachineOperand::MO_MachineBasicBlock:
298 printBasicBlockLabel(MO.getMachineBasicBlock());
300 case MachineOperand::MO_JumpTableIndex:
301 O << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
302 << '_' << MO.getJumpTableIndex();
303 // FIXME: PIC relocation model
305 case MachineOperand::MO_ConstantPoolIndex:
306 O << TAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber()
307 << '_' << MO.getConstantPoolIndex();
309 case MachineOperand::MO_ExternalSymbol:
310 // Computing the address of an external symbol, not calling it.
311 if (TM.getRelocationModel() != Reloc::Static) {
312 std::string Name(TAI->getGlobalPrefix()); Name += MO.getSymbolName();
313 GVStubs.insert(Name);
314 O << "L" << Name << "$non_lazy_ptr";
317 O << TAI->getGlobalPrefix() << MO.getSymbolName();
319 case MachineOperand::MO_GlobalAddress: {
320 // Computing the address of a global symbol, not calling it.
321 GlobalValue *GV = MO.getGlobal();
322 std::string Name = Mang->getValueName(GV);
324 // External or weakly linked global variables need non-lazily-resolved stubs
325 if (TM.getRelocationModel() != Reloc::Static) {
326 if (((GV->isExternal() || GV->hasWeakLinkage() ||
327 GV->hasLinkOnceLinkage()))) {
328 GVStubs.insert(Name);
329 O << "L" << Name << "$non_lazy_ptr";
339 O << "<unknown operand type: " << MO.getType() << ">";
344 /// PrintAsmOperand - Print out an operand for an inline asm expression.
346 bool PPCAsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
348 const char *ExtraCode) {
349 // Does this asm operand have a single letter operand modifier?
350 if (ExtraCode && ExtraCode[0]) {
351 if (ExtraCode[1] != 0) return true; // Unknown modifier.
353 switch (ExtraCode[0]) {
354 default: return true; // Unknown modifier.
355 case 'L': // Write second word of DImode reference.
356 // Verify that this operand has two consecutive registers.
357 if (!MI->getOperand(OpNo).isRegister() ||
358 OpNo+1 == MI->getNumOperands() ||
359 !MI->getOperand(OpNo+1).isRegister())
361 ++OpNo; // Return the high-part.
366 printOperand(MI, OpNo);
370 bool PPCAsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
372 const char *ExtraCode) {
373 if (ExtraCode && ExtraCode[0])
374 return true; // Unknown modifier.
375 printMemRegReg(MI, OpNo);
379 void PPCAsmPrinter::printPredicateOperand(const MachineInstr *MI, unsigned OpNo,
380 const char *Modifier) {
381 assert(Modifier && "Must specify 'cc' or 'reg' as predicate op modifier!");
382 unsigned Code = MI->getOperand(OpNo).getImm();
383 if (!strcmp(Modifier, "cc")) {
384 switch ((PPC::Predicate)Code) {
385 case PPC::PRED_ALWAYS: return; // Don't print anything for always.
386 case PPC::PRED_LT: O << "lt"; return;
387 case PPC::PRED_LE: O << "le"; return;
388 case PPC::PRED_EQ: O << "eq"; return;
389 case PPC::PRED_GE: O << "ge"; return;
390 case PPC::PRED_GT: O << "gt"; return;
391 case PPC::PRED_NE: O << "ne"; return;
392 case PPC::PRED_UN: O << "un"; return;
393 case PPC::PRED_NU: O << "nu"; return;
397 assert(!strcmp(Modifier, "reg") &&
398 "Need to specify 'cc' or 'reg' as predicate op modifier!");
399 // Don't print the register for 'always'.
400 if (Code == PPC::PRED_ALWAYS) return;
401 printOperand(MI, OpNo+1);
406 /// printMachineInstruction -- Print out a single PowerPC MI in Darwin syntax to
407 /// the current output stream.
409 void PPCAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
412 // Check for slwi/srwi mnemonics.
413 if (MI->getOpcode() == PPC::RLWINM) {
414 bool FoundMnemonic = false;
415 unsigned char SH = MI->getOperand(2).getImmedValue();
416 unsigned char MB = MI->getOperand(3).getImmedValue();
417 unsigned char ME = MI->getOperand(4).getImmedValue();
418 if (SH <= 31 && MB == 0 && ME == (31-SH)) {
419 O << "slwi "; FoundMnemonic = true;
421 if (SH <= 31 && MB == (32-SH) && ME == 31) {
422 O << "srwi "; FoundMnemonic = true;
429 O << ", " << (unsigned int)SH << "\n";
432 } else if (MI->getOpcode() == PPC::OR || MI->getOpcode() == PPC::OR8) {
433 if (MI->getOperand(1).getReg() == MI->getOperand(2).getReg()) {
441 } else if (MI->getOpcode() == PPC::RLDICR) {
442 unsigned char SH = MI->getOperand(2).getImmedValue();
443 unsigned char ME = MI->getOperand(3).getImmedValue();
444 // rldicr RA, RS, SH, 63-SH == sldi RA, RS, SH
450 O << ", " << (unsigned int)SH << "\n";
455 if (printInstruction(MI))
456 return; // Printer was automatically generated
458 assert(0 && "Unhandled instruction in asm writer!");
465 std::string DarwinAsmPrinter::getSectionForFunction(const Function &F) const {
466 switch (F.getLinkage()) {
467 default: assert(0 && "Unknown linkage type!");
468 case Function::ExternalLinkage:
469 case Function::InternalLinkage: return TAI->getTextSection();
470 case Function::WeakLinkage:
471 case Function::LinkOnceLinkage:
472 return ".section __TEXT,__textcoal_nt,coalesced,pure_instructions";
476 /// runOnMachineFunction - This uses the printMachineInstruction()
477 /// method to print assembly for each instruction.
479 bool DarwinAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
480 DW.SetDebugInfo(&getAnalysis<MachineDebugInfo>());
482 SetupMachineFunction(MF);
485 // Print out constants referenced by the function
486 EmitConstantPool(MF.getConstantPool());
488 // Print out labels for the function.
489 const Function *F = MF.getFunction();
490 SwitchToTextSection(getSectionForFunction(*F).c_str(), F);
492 switch (F->getLinkage()) {
493 default: assert(0 && "Unknown linkage type!");
494 case Function::InternalLinkage: // Symbols default to internal.
496 case Function::ExternalLinkage:
497 O << "\t.globl\t" << CurrentFnName << "\n";
499 case Function::WeakLinkage:
500 case Function::LinkOnceLinkage:
501 O << "\t.globl\t" << CurrentFnName << "\n";
502 O << "\t.weak_definition\t" << CurrentFnName << "\n";
506 O << CurrentFnName << ":\n";
508 // Emit pre-function debug information.
509 DW.BeginFunction(&MF);
511 // Print out code for the function.
512 for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
514 // Print a label for the basic block.
515 if (I != MF.begin()) {
516 printBasicBlockLabel(I, true);
519 for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
521 // Print the assembly for the instruction.
523 printMachineInstruction(II);
527 // Print out jump tables referenced by the function.
528 EmitJumpTableInfo(MF.getJumpTableInfo(), MF);
530 // Emit post-function debug information.
533 // We didn't modify anything.
538 bool DarwinAsmPrinter::doInitialization(Module &M) {
539 if (Subtarget.isGigaProcessor())
540 O << "\t.machine ppc970\n";
541 AsmPrinter::doInitialization(M);
543 // Darwin wants symbols to be quoted if they have complex names.
544 Mang->setUseQuotes(true);
546 // Prime text sections so they are adjacent. This reduces the likelihood a
547 // large data or debug section causes a branch to exceed 16M limit.
548 SwitchToTextSection(".section __TEXT,__textcoal_nt,coalesced,"
549 "pure_instructions");
550 if (TM.getRelocationModel() == Reloc::PIC_) {
551 SwitchToTextSection(".section __TEXT,__picsymbolstub1,symbol_stubs,"
552 "pure_instructions,32");
553 } else if (TM.getRelocationModel() == Reloc::DynamicNoPIC) {
554 SwitchToTextSection(".section __TEXT,__symbol_stub1,symbol_stubs,"
555 "pure_instructions,16");
557 SwitchToTextSection(TAI->getTextSection());
559 // Emit initial debug information.
564 bool DarwinAsmPrinter::doFinalization(Module &M) {
565 const TargetData *TD = TM.getTargetData();
567 // Print out module-level global variables here.
568 for (Module::const_global_iterator I = M.global_begin(), E = M.global_end();
570 if (!I->hasInitializer()) continue; // External global require no code
572 // Check to see if this is a special global used by LLVM, if so, emit it.
573 if (EmitSpecialLLVMGlobal(I))
576 std::string name = Mang->getValueName(I);
577 Constant *C = I->getInitializer();
578 unsigned Size = TD->getTypeSize(C->getType());
579 unsigned Align = TD->getPreferredAlignmentLog(I);
581 if (C->isNullValue() && /* FIXME: Verify correct */
582 (I->hasInternalLinkage() || I->hasWeakLinkage() ||
583 I->hasLinkOnceLinkage() ||
584 (I->hasExternalLinkage() && !I->hasSection()))) {
585 if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
586 if (I->hasExternalLinkage()) {
587 O << "\t.globl " << name << '\n';
588 O << "\t.zerofill __DATA, __common, " << name << ", "
589 << Size << ", " << Align;
590 } else if (I->hasInternalLinkage()) {
591 SwitchToDataSection("\t.data", I);
592 O << TAI->getLCOMMDirective() << name << "," << Size << "," << Align;
594 SwitchToDataSection("\t.data", I);
595 O << ".comm " << name << "," << Size;
597 O << "\t\t; '" << I->getName() << "'\n";
599 switch (I->getLinkage()) {
600 case GlobalValue::LinkOnceLinkage:
601 case GlobalValue::WeakLinkage:
602 O << "\t.globl " << name << '\n'
603 << "\t.weak_definition " << name << '\n';
604 SwitchToDataSection(".section __DATA,__datacoal_nt,coalesced", I);
606 case GlobalValue::AppendingLinkage:
607 // FIXME: appending linkage variables should go into a section of
608 // their name or something. For now, just emit them as external.
609 case GlobalValue::ExternalLinkage:
610 // If external or appending, declare as a global symbol
611 O << "\t.globl " << name << "\n";
613 case GlobalValue::InternalLinkage:
614 if (I->isConstant()) {
615 const ConstantArray *CVA = dyn_cast<ConstantArray>(C);
616 if (TAI->getCStringSection() && CVA && CVA->isCString()) {
617 SwitchToDataSection(TAI->getCStringSection(), I);
622 SwitchToDataSection("\t.data", I);
625 std::cerr << "Unknown linkage type!";
629 EmitAlignment(Align, I);
630 O << name << ":\t\t\t\t; '" << I->getName() << "'\n";
631 EmitGlobalConstant(C);
636 bool isPPC64 = TD->getPointerSizeInBits() == 64;
638 // Output stubs for dynamically-linked functions
639 if (TM.getRelocationModel() == Reloc::PIC_) {
640 for (std::set<std::string>::iterator i = FnStubs.begin(), e = FnStubs.end();
642 SwitchToTextSection(".section __TEXT,__picsymbolstub1,symbol_stubs,"
643 "pure_instructions,32");
645 O << "L" << *i << "$stub:\n";
646 O << "\t.indirect_symbol " << *i << "\n";
648 O << "\tbcl 20,31,L0$" << *i << "\n";
649 O << "L0$" << *i << ":\n";
651 O << "\taddis r11,r11,ha16(L" << *i << "$lazy_ptr-L0$" << *i << ")\n";
654 O << "\tldu r12,lo16(L" << *i << "$lazy_ptr-L0$" << *i << ")(r11)\n";
656 O << "\tlwzu r12,lo16(L" << *i << "$lazy_ptr-L0$" << *i << ")(r11)\n";
657 O << "\tmtctr r12\n";
659 SwitchToDataSection(".lazy_symbol_pointer");
660 O << "L" << *i << "$lazy_ptr:\n";
661 O << "\t.indirect_symbol " << *i << "\n";
663 O << "\t.quad dyld_stub_binding_helper\n";
665 O << "\t.long dyld_stub_binding_helper\n";
668 for (std::set<std::string>::iterator i = FnStubs.begin(), e = FnStubs.end();
670 SwitchToTextSection(".section __TEXT,__symbol_stub1,symbol_stubs,"
671 "pure_instructions,16");
673 O << "L" << *i << "$stub:\n";
674 O << "\t.indirect_symbol " << *i << "\n";
675 O << "\tlis r11,ha16(L" << *i << "$lazy_ptr)\n";
677 O << "\tldu r12,lo16(L" << *i << "$lazy_ptr)(r11)\n";
679 O << "\tlwzu r12,lo16(L" << *i << "$lazy_ptr)(r11)\n";
680 O << "\tmtctr r12\n";
682 SwitchToDataSection(".lazy_symbol_pointer");
683 O << "L" << *i << "$lazy_ptr:\n";
684 O << "\t.indirect_symbol " << *i << "\n";
686 O << "\t.quad dyld_stub_binding_helper\n";
688 O << "\t.long dyld_stub_binding_helper\n";
694 // Output stubs for external and common global variables.
695 if (GVStubs.begin() != GVStubs.end()) {
696 SwitchToDataSection(".non_lazy_symbol_pointer");
697 for (std::set<std::string>::iterator I = GVStubs.begin(),
698 E = GVStubs.end(); I != E; ++I) {
699 O << "L" << *I << "$non_lazy_ptr:\n";
700 O << "\t.indirect_symbol " << *I << "\n";
709 // Emit initial debug information.
712 // Funny Darwin hack: This flag tells the linker that no global symbols
713 // contain code that falls through to other global symbols (e.g. the obvious
714 // implementation of multiple entry points). If this doesn't occur, the
715 // linker can safely perform dead code stripping. Since LLVM never generates
716 // code that does this, it is always safe to set.
717 O << "\t.subsections_via_symbols\n";
719 AsmPrinter::doFinalization(M);
720 return false; // success
725 /// createDarwinCodePrinterPass - Returns a pass that prints the PPC assembly
726 /// code for a MachineFunction to the given output stream, in a format that the
727 /// Darwin assembler can deal with.
729 FunctionPass *llvm::createPPCAsmPrinterPass(std::ostream &o,
730 PPCTargetMachine &tm) {
731 return new DarwinAsmPrinter(o, tm, tm.getTargetAsmInfo());