1 //===-- PPCAsmPrinter.cpp - Print machine instrs to PowerPC assembly ------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // 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 "InstPrinter/PPCInstPrinter.h"
22 #include "MCTargetDesc/PPCPredicates.h"
23 #include "MCTargetDesc/PPCMCExpr.h"
24 #include "PPCSubtarget.h"
25 #include "PPCTargetMachine.h"
26 #include "PPCTargetStreamer.h"
27 #include "llvm/ADT/MapVector.h"
28 #include "llvm/ADT/SmallString.h"
29 #include "llvm/ADT/StringExtras.h"
30 #include "llvm/Assembly/Writer.h"
31 #include "llvm/CodeGen/AsmPrinter.h"
32 #include "llvm/CodeGen/MachineFunctionPass.h"
33 #include "llvm/CodeGen/MachineInstr.h"
34 #include "llvm/CodeGen/MachineInstrBuilder.h"
35 #include "llvm/CodeGen/MachineModuleInfoImpls.h"
36 #include "llvm/CodeGen/TargetLoweringObjectFileImpl.h"
37 #include "llvm/DebugInfo.h"
38 #include "llvm/IR/Constants.h"
39 #include "llvm/IR/DerivedTypes.h"
40 #include "llvm/IR/Module.h"
41 #include "llvm/MC/MCAsmInfo.h"
42 #include "llvm/MC/MCContext.h"
43 #include "llvm/MC/MCExpr.h"
44 #include "llvm/MC/MCInst.h"
45 #include "llvm/MC/MCInstBuilder.h"
46 #include "llvm/MC/MCSectionELF.h"
47 #include "llvm/MC/MCSectionMachO.h"
48 #include "llvm/MC/MCStreamer.h"
49 #include "llvm/MC/MCSymbol.h"
50 #include "llvm/Support/CommandLine.h"
51 #include "llvm/Support/Debug.h"
52 #include "llvm/Support/ELF.h"
53 #include "llvm/Support/ErrorHandling.h"
54 #include "llvm/Support/MathExtras.h"
55 #include "llvm/Support/TargetRegistry.h"
56 #include "llvm/Support/raw_ostream.h"
57 #include "llvm/Target/Mangler.h"
58 #include "llvm/Target/TargetInstrInfo.h"
59 #include "llvm/Target/TargetOptions.h"
60 #include "llvm/Target/TargetRegisterInfo.h"
64 class PPCAsmPrinter : public AsmPrinter {
66 MapVector<MCSymbol*, MCSymbol*> TOC;
67 const PPCSubtarget &Subtarget;
70 explicit PPCAsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
71 : AsmPrinter(TM, Streamer),
72 Subtarget(TM.getSubtarget<PPCSubtarget>()), TOCLabelID(0) {}
74 virtual const char *getPassName() const {
75 return "PowerPC Assembly Printer";
78 MCSymbol *lookUpOrCreateTOCEntry(MCSymbol *Sym);
80 virtual void EmitInstruction(const MachineInstr *MI);
82 void printOperand(const MachineInstr *MI, unsigned OpNo, raw_ostream &O);
84 bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
85 unsigned AsmVariant, const char *ExtraCode,
87 bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
88 unsigned AsmVariant, const char *ExtraCode,
92 /// PPCLinuxAsmPrinter - PowerPC assembly printer, customized for Linux
93 class PPCLinuxAsmPrinter : public PPCAsmPrinter {
95 explicit PPCLinuxAsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
96 : PPCAsmPrinter(TM, Streamer) {}
98 virtual const char *getPassName() const {
99 return "Linux PPC Assembly Printer";
102 bool doFinalization(Module &M);
104 virtual void EmitFunctionEntryLabel();
106 void EmitFunctionBodyEnd();
109 /// PPCDarwinAsmPrinter - PowerPC assembly printer, customized for Darwin/Mac
111 class PPCDarwinAsmPrinter : public PPCAsmPrinter {
113 explicit PPCDarwinAsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
114 : PPCAsmPrinter(TM, Streamer) {}
116 virtual const char *getPassName() const {
117 return "Darwin PPC Assembly Printer";
120 bool doFinalization(Module &M);
121 void EmitStartOfAsmFile(Module &M);
123 void EmitFunctionStubs(const MachineModuleInfoMachO::SymbolListTy &Stubs);
125 } // end of anonymous namespace
127 /// stripRegisterPrefix - This method strips the character prefix from a
128 /// register name so that only the number is left. Used by for linux asm.
129 static const char *stripRegisterPrefix(const char *RegName) {
130 switch (RegName[0]) {
133 case 'v': return RegName + 1;
134 case 'c': if (RegName[1] == 'r') return RegName + 2;
140 void PPCAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
142 const MachineOperand &MO = MI->getOperand(OpNo);
144 switch (MO.getType()) {
145 case MachineOperand::MO_Register: {
146 const char *RegName = PPCInstPrinter::getRegisterName(MO.getReg());
147 // Linux assembler (Others?) does not take register mnemonics.
148 // FIXME - What about special registers used in mfspr/mtspr?
149 if (!Subtarget.isDarwin()) RegName = stripRegisterPrefix(RegName);
153 case MachineOperand::MO_Immediate:
157 case MachineOperand::MO_MachineBasicBlock:
158 O << *MO.getMBB()->getSymbol();
160 case MachineOperand::MO_JumpTableIndex:
161 O << MAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
162 << '_' << MO.getIndex();
163 // FIXME: PIC relocation model
165 case MachineOperand::MO_ConstantPoolIndex:
166 O << MAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber()
167 << '_' << MO.getIndex();
169 case MachineOperand::MO_BlockAddress:
170 O << *GetBlockAddressSymbol(MO.getBlockAddress());
172 case MachineOperand::MO_ExternalSymbol: {
173 // Computing the address of an external symbol, not calling it.
174 if (TM.getRelocationModel() == Reloc::Static) {
175 O << *GetExternalSymbolSymbol(MO.getSymbolName());
180 OutContext.GetOrCreateSymbol(StringRef(MAI->getGlobalPrefix())+
181 MO.getSymbolName()+"$non_lazy_ptr");
182 MachineModuleInfoImpl::StubValueTy &StubSym =
183 MMI->getObjFileInfo<MachineModuleInfoMachO>().getGVStubEntry(NLPSym);
184 if (StubSym.getPointer() == 0)
185 StubSym = MachineModuleInfoImpl::
186 StubValueTy(GetExternalSymbolSymbol(MO.getSymbolName()), true);
191 case MachineOperand::MO_GlobalAddress: {
192 // Computing the address of a global symbol, not calling it.
193 const GlobalValue *GV = MO.getGlobal();
194 MCSymbol *SymToPrint;
196 // External or weakly linked global variables need non-lazily-resolved stubs
197 if (TM.getRelocationModel() != Reloc::Static &&
198 (GV->isDeclaration() || GV->isWeakForLinker())) {
199 if (!GV->hasHiddenVisibility()) {
200 SymToPrint = GetSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
201 MachineModuleInfoImpl::StubValueTy &StubSym =
202 MMI->getObjFileInfo<MachineModuleInfoMachO>()
203 .getGVStubEntry(SymToPrint);
204 if (StubSym.getPointer() == 0)
205 StubSym = MachineModuleInfoImpl::
206 StubValueTy(getSymbol(GV), !GV->hasInternalLinkage());
207 } else if (GV->isDeclaration() || GV->hasCommonLinkage() ||
208 GV->hasAvailableExternallyLinkage()) {
209 SymToPrint = GetSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
211 MachineModuleInfoImpl::StubValueTy &StubSym =
212 MMI->getObjFileInfo<MachineModuleInfoMachO>().
213 getHiddenGVStubEntry(SymToPrint);
214 if (StubSym.getPointer() == 0)
215 StubSym = MachineModuleInfoImpl::
216 StubValueTy(getSymbol(GV), !GV->hasInternalLinkage());
218 SymToPrint = getSymbol(GV);
221 SymToPrint = getSymbol(GV);
226 printOffset(MO.getOffset(), O);
231 O << "<unknown operand type: " << MO.getType() << ">";
236 /// PrintAsmOperand - Print out an operand for an inline asm expression.
238 bool PPCAsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
240 const char *ExtraCode, raw_ostream &O) {
241 // Does this asm operand have a single letter operand modifier?
242 if (ExtraCode && ExtraCode[0]) {
243 if (ExtraCode[1] != 0) return true; // Unknown modifier.
245 switch (ExtraCode[0]) {
247 // See if this is a generic print operand
248 return AsmPrinter::PrintAsmOperand(MI, OpNo, AsmVariant, ExtraCode, O);
249 case 'c': // Don't print "$" before a global var name or constant.
250 break; // PPC never has a prefix.
251 case 'L': // Write second word of DImode reference.
252 // Verify that this operand has two consecutive registers.
253 if (!MI->getOperand(OpNo).isReg() ||
254 OpNo+1 == MI->getNumOperands() ||
255 !MI->getOperand(OpNo+1).isReg())
257 ++OpNo; // Return the high-part.
260 // Write 'i' if an integer constant, otherwise nothing. Used to print
262 if (MI->getOperand(OpNo).isImm())
268 printOperand(MI, OpNo, O);
272 // At the moment, all inline asm memory operands are a single register.
273 // In any case, the output of this routine should always be just one
274 // assembler operand.
276 bool PPCAsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
278 const char *ExtraCode,
280 if (ExtraCode && ExtraCode[0]) {
281 if (ExtraCode[1] != 0) return true; // Unknown modifier.
283 switch (ExtraCode[0]) {
284 default: return true; // Unknown modifier.
285 case 'y': // A memory reference for an X-form instruction
287 const char *RegName = "r0";
288 if (!Subtarget.isDarwin()) RegName = stripRegisterPrefix(RegName);
289 O << RegName << ", ";
290 printOperand(MI, OpNo, O);
296 assert(MI->getOperand(OpNo).isReg());
298 printOperand(MI, OpNo, O);
304 /// lookUpOrCreateTOCEntry -- Given a symbol, look up whether a TOC entry
305 /// exists for it. If not, create one. Then return a symbol that references
307 MCSymbol *PPCAsmPrinter::lookUpOrCreateTOCEntry(MCSymbol *Sym) {
309 MCSymbol *&TOCEntry = TOC[Sym];
311 // To avoid name clash check if the name already exists.
312 while (TOCEntry == 0) {
313 if (OutContext.LookupSymbol(Twine(MAI->getPrivateGlobalPrefix()) +
314 "C" + Twine(TOCLabelID++)) == 0) {
315 TOCEntry = GetTempSymbol("C", TOCLabelID);
323 /// EmitInstruction -- Print out a single PowerPC MI in Darwin syntax to
324 /// the current output stream.
326 void PPCAsmPrinter::EmitInstruction(const MachineInstr *MI) {
329 // Lower multi-instruction pseudo operations.
330 switch (MI->getOpcode()) {
332 case TargetOpcode::DBG_VALUE:
333 llvm_unreachable("Should be handled target independently");
334 case PPC::MovePCtoLR:
335 case PPC::MovePCtoLR8: {
336 // Transform %LR = MovePCtoLR
337 // Into this, where the label is the PIC base:
340 MCSymbol *PICBase = MF->getPICBaseSymbol();
343 OutStreamer.EmitInstruction(MCInstBuilder(PPC::BL)
344 // FIXME: We would like an efficient form for this, so we don't have to do
345 // a lot of extra uniquing.
346 .addExpr(MCSymbolRefExpr::Create(PICBase, OutContext)));
349 OutStreamer.EmitLabel(PICBase);
355 // Transform %X3 = LDtoc <ga:@min1>, %X2
356 LowerPPCMachineInstrToMCInst(MI, TmpInst, *this, Subtarget.isDarwin());
358 // Change the opcode to LD, and the global address operand to be a
359 // reference to the TOC entry we will synthesize later.
360 TmpInst.setOpcode(PPC::LD);
361 const MachineOperand &MO = MI->getOperand(1);
363 // Map symbol -> label of TOC entry
364 assert(MO.isGlobal() || MO.isCPI() || MO.isJTI());
365 MCSymbol *MOSymbol = 0;
367 MOSymbol = getSymbol(MO.getGlobal());
369 MOSymbol = GetCPISymbol(MO.getIndex());
371 MOSymbol = GetJTISymbol(MO.getIndex());
373 MCSymbol *TOCEntry = lookUpOrCreateTOCEntry(MOSymbol);
376 MCSymbolRefExpr::Create(TOCEntry, MCSymbolRefExpr::VK_PPC_TOC,
378 TmpInst.getOperand(1) = MCOperand::CreateExpr(Exp);
379 OutStreamer.EmitInstruction(TmpInst);
383 case PPC::ADDIStocHA: {
384 // Transform %Xd = ADDIStocHA %X2, <ga:@sym>
385 LowerPPCMachineInstrToMCInst(MI, TmpInst, *this, Subtarget.isDarwin());
387 // Change the opcode to ADDIS8. If the global address is external,
388 // has common linkage, is a function address, or is a jump table
389 // address, then generate a TOC entry and reference that. Otherwise
390 // reference the symbol directly.
391 TmpInst.setOpcode(PPC::ADDIS8);
392 const MachineOperand &MO = MI->getOperand(2);
393 assert((MO.isGlobal() || MO.isCPI() || MO.isJTI()) &&
394 "Invalid operand for ADDIStocHA!");
395 MCSymbol *MOSymbol = 0;
396 bool IsExternal = false;
397 bool IsFunction = false;
398 bool IsCommon = false;
399 bool IsAvailExt = false;
402 const GlobalValue *GValue = MO.getGlobal();
403 const GlobalAlias *GAlias = dyn_cast<GlobalAlias>(GValue);
404 const GlobalValue *RealGValue = GAlias ?
405 GAlias->resolveAliasedGlobal(false) : GValue;
406 MOSymbol = getSymbol(RealGValue);
407 const GlobalVariable *GVar = dyn_cast<GlobalVariable>(RealGValue);
408 IsExternal = GVar && !GVar->hasInitializer();
409 IsCommon = GVar && RealGValue->hasCommonLinkage();
411 IsAvailExt = GVar && RealGValue->hasAvailableExternallyLinkage();
412 } else if (MO.isCPI())
413 MOSymbol = GetCPISymbol(MO.getIndex());
415 MOSymbol = GetJTISymbol(MO.getIndex());
417 if (IsExternal || IsFunction || IsCommon || IsAvailExt || MO.isJTI() ||
418 TM.getCodeModel() == CodeModel::Large)
419 MOSymbol = lookUpOrCreateTOCEntry(MOSymbol);
422 MCSymbolRefExpr::Create(MOSymbol, MCSymbolRefExpr::VK_PPC_TOC_HA,
424 TmpInst.getOperand(2) = MCOperand::CreateExpr(Exp);
425 OutStreamer.EmitInstruction(TmpInst);
429 // Transform %Xd = LDtocL <ga:@sym>, %Xs
430 LowerPPCMachineInstrToMCInst(MI, TmpInst, *this, Subtarget.isDarwin());
432 // Change the opcode to LD. If the global address is external, has
433 // common linkage, or is a jump table address, then reference the
434 // associated TOC entry. Otherwise reference the symbol directly.
435 TmpInst.setOpcode(PPC::LD);
436 const MachineOperand &MO = MI->getOperand(1);
437 assert((MO.isGlobal() || MO.isJTI() || MO.isCPI()) &&
438 "Invalid operand for LDtocL!");
439 MCSymbol *MOSymbol = 0;
442 MOSymbol = lookUpOrCreateTOCEntry(GetJTISymbol(MO.getIndex()));
443 else if (MO.isCPI()) {
444 MOSymbol = GetCPISymbol(MO.getIndex());
445 if (TM.getCodeModel() == CodeModel::Large)
446 MOSymbol = lookUpOrCreateTOCEntry(MOSymbol);
448 else if (MO.isGlobal()) {
449 const GlobalValue *GValue = MO.getGlobal();
450 const GlobalAlias *GAlias = dyn_cast<GlobalAlias>(GValue);
451 const GlobalValue *RealGValue = GAlias ?
452 GAlias->resolveAliasedGlobal(false) : GValue;
453 MOSymbol = getSymbol(RealGValue);
454 const GlobalVariable *GVar = dyn_cast<GlobalVariable>(RealGValue);
456 if (!GVar || !GVar->hasInitializer() || RealGValue->hasCommonLinkage() ||
457 RealGValue->hasAvailableExternallyLinkage() ||
458 TM.getCodeModel() == CodeModel::Large)
459 MOSymbol = lookUpOrCreateTOCEntry(MOSymbol);
463 MCSymbolRefExpr::Create(MOSymbol, MCSymbolRefExpr::VK_PPC_TOC_LO,
465 TmpInst.getOperand(1) = MCOperand::CreateExpr(Exp);
466 OutStreamer.EmitInstruction(TmpInst);
469 case PPC::ADDItocL: {
470 // Transform %Xd = ADDItocL %Xs, <ga:@sym>
471 LowerPPCMachineInstrToMCInst(MI, TmpInst, *this, Subtarget.isDarwin());
473 // Change the opcode to ADDI8. If the global address is external, then
474 // generate a TOC entry and reference that. Otherwise reference the
476 TmpInst.setOpcode(PPC::ADDI8);
477 const MachineOperand &MO = MI->getOperand(2);
478 assert((MO.isGlobal() || MO.isCPI()) && "Invalid operand for ADDItocL");
479 MCSymbol *MOSymbol = 0;
480 bool IsExternal = false;
481 bool IsFunction = false;
484 const GlobalValue *GValue = MO.getGlobal();
485 const GlobalAlias *GAlias = dyn_cast<GlobalAlias>(GValue);
486 const GlobalValue *RealGValue = GAlias ?
487 GAlias->resolveAliasedGlobal(false) : GValue;
488 MOSymbol = getSymbol(RealGValue);
489 const GlobalVariable *GVar = dyn_cast<GlobalVariable>(RealGValue);
490 IsExternal = GVar && !GVar->hasInitializer();
492 } else if (MO.isCPI())
493 MOSymbol = GetCPISymbol(MO.getIndex());
495 if (IsFunction || IsExternal || TM.getCodeModel() == CodeModel::Large)
496 MOSymbol = lookUpOrCreateTOCEntry(MOSymbol);
499 MCSymbolRefExpr::Create(MOSymbol, MCSymbolRefExpr::VK_PPC_TOC_LO,
501 TmpInst.getOperand(2) = MCOperand::CreateExpr(Exp);
502 OutStreamer.EmitInstruction(TmpInst);
505 case PPC::ADDISgotTprelHA: {
506 // Transform: %Xd = ADDISgotTprelHA %X2, <ga:@sym>
507 // Into: %Xd = ADDIS8 %X2, sym@got@tlsgd@ha
508 assert(Subtarget.isPPC64() && "Not supported for 32-bit PowerPC");
509 const MachineOperand &MO = MI->getOperand(2);
510 const GlobalValue *GValue = MO.getGlobal();
511 MCSymbol *MOSymbol = getSymbol(GValue);
512 const MCExpr *SymGotTprel =
513 MCSymbolRefExpr::Create(MOSymbol, MCSymbolRefExpr::VK_PPC_GOT_TPREL_HA,
515 OutStreamer.EmitInstruction(MCInstBuilder(PPC::ADDIS8)
516 .addReg(MI->getOperand(0).getReg())
518 .addExpr(SymGotTprel));
521 case PPC::LDgotTprelL: {
522 // Transform %Xd = LDgotTprelL <ga:@sym>, %Xs
523 LowerPPCMachineInstrToMCInst(MI, TmpInst, *this, Subtarget.isDarwin());
525 // Change the opcode to LD.
526 TmpInst.setOpcode(PPC::LD);
527 const MachineOperand &MO = MI->getOperand(1);
528 const GlobalValue *GValue = MO.getGlobal();
529 MCSymbol *MOSymbol = getSymbol(GValue);
531 MCSymbolRefExpr::Create(MOSymbol, MCSymbolRefExpr::VK_PPC_GOT_TPREL_LO,
533 TmpInst.getOperand(1) = MCOperand::CreateExpr(Exp);
534 OutStreamer.EmitInstruction(TmpInst);
537 case PPC::ADDIStlsgdHA: {
538 // Transform: %Xd = ADDIStlsgdHA %X2, <ga:@sym>
539 // Into: %Xd = ADDIS8 %X2, sym@got@tlsgd@ha
540 assert(Subtarget.isPPC64() && "Not supported for 32-bit PowerPC");
541 const MachineOperand &MO = MI->getOperand(2);
542 const GlobalValue *GValue = MO.getGlobal();
543 MCSymbol *MOSymbol = getSymbol(GValue);
544 const MCExpr *SymGotTlsGD =
545 MCSymbolRefExpr::Create(MOSymbol, MCSymbolRefExpr::VK_PPC_GOT_TLSGD_HA,
547 OutStreamer.EmitInstruction(MCInstBuilder(PPC::ADDIS8)
548 .addReg(MI->getOperand(0).getReg())
550 .addExpr(SymGotTlsGD));
553 case PPC::ADDItlsgdL: {
554 // Transform: %Xd = ADDItlsgdL %Xs, <ga:@sym>
555 // Into: %Xd = ADDI8 %Xs, sym@got@tlsgd@l
556 assert(Subtarget.isPPC64() && "Not supported for 32-bit PowerPC");
557 const MachineOperand &MO = MI->getOperand(2);
558 const GlobalValue *GValue = MO.getGlobal();
559 MCSymbol *MOSymbol = getSymbol(GValue);
560 const MCExpr *SymGotTlsGD =
561 MCSymbolRefExpr::Create(MOSymbol, MCSymbolRefExpr::VK_PPC_GOT_TLSGD_LO,
563 OutStreamer.EmitInstruction(MCInstBuilder(PPC::ADDI8)
564 .addReg(MI->getOperand(0).getReg())
565 .addReg(MI->getOperand(1).getReg())
566 .addExpr(SymGotTlsGD));
569 case PPC::GETtlsADDR: {
570 // Transform: %X3 = GETtlsADDR %X3, <ga:@sym>
571 // Into: BL8_NOP_TLS __tls_get_addr(sym@tlsgd)
572 assert(Subtarget.isPPC64() && "Not supported for 32-bit PowerPC");
574 StringRef Name = "__tls_get_addr";
575 MCSymbol *TlsGetAddr = OutContext.GetOrCreateSymbol(Name);
576 const MCSymbolRefExpr *TlsRef =
577 MCSymbolRefExpr::Create(TlsGetAddr, MCSymbolRefExpr::VK_None, OutContext);
578 const MachineOperand &MO = MI->getOperand(2);
579 const GlobalValue *GValue = MO.getGlobal();
580 MCSymbol *MOSymbol = getSymbol(GValue);
581 const MCExpr *SymVar =
582 MCSymbolRefExpr::Create(MOSymbol, MCSymbolRefExpr::VK_PPC_TLSGD,
584 OutStreamer.EmitInstruction(MCInstBuilder(PPC::BL8_NOP_TLS)
589 case PPC::ADDIStlsldHA: {
590 // Transform: %Xd = ADDIStlsldHA %X2, <ga:@sym>
591 // Into: %Xd = ADDIS8 %X2, sym@got@tlsld@ha
592 assert(Subtarget.isPPC64() && "Not supported for 32-bit PowerPC");
593 const MachineOperand &MO = MI->getOperand(2);
594 const GlobalValue *GValue = MO.getGlobal();
595 MCSymbol *MOSymbol = getSymbol(GValue);
596 const MCExpr *SymGotTlsLD =
597 MCSymbolRefExpr::Create(MOSymbol, MCSymbolRefExpr::VK_PPC_GOT_TLSLD_HA,
599 OutStreamer.EmitInstruction(MCInstBuilder(PPC::ADDIS8)
600 .addReg(MI->getOperand(0).getReg())
602 .addExpr(SymGotTlsLD));
605 case PPC::ADDItlsldL: {
606 // Transform: %Xd = ADDItlsldL %Xs, <ga:@sym>
607 // Into: %Xd = ADDI8 %Xs, sym@got@tlsld@l
608 assert(Subtarget.isPPC64() && "Not supported for 32-bit PowerPC");
609 const MachineOperand &MO = MI->getOperand(2);
610 const GlobalValue *GValue = MO.getGlobal();
611 MCSymbol *MOSymbol = getSymbol(GValue);
612 const MCExpr *SymGotTlsLD =
613 MCSymbolRefExpr::Create(MOSymbol, MCSymbolRefExpr::VK_PPC_GOT_TLSLD_LO,
615 OutStreamer.EmitInstruction(MCInstBuilder(PPC::ADDI8)
616 .addReg(MI->getOperand(0).getReg())
617 .addReg(MI->getOperand(1).getReg())
618 .addExpr(SymGotTlsLD));
621 case PPC::GETtlsldADDR: {
622 // Transform: %X3 = GETtlsldADDR %X3, <ga:@sym>
623 // Into: BL8_NOP_TLS __tls_get_addr(sym@tlsld)
624 assert(Subtarget.isPPC64() && "Not supported for 32-bit PowerPC");
626 StringRef Name = "__tls_get_addr";
627 MCSymbol *TlsGetAddr = OutContext.GetOrCreateSymbol(Name);
628 const MCSymbolRefExpr *TlsRef =
629 MCSymbolRefExpr::Create(TlsGetAddr, MCSymbolRefExpr::VK_None, OutContext);
630 const MachineOperand &MO = MI->getOperand(2);
631 const GlobalValue *GValue = MO.getGlobal();
632 MCSymbol *MOSymbol = getSymbol(GValue);
633 const MCExpr *SymVar =
634 MCSymbolRefExpr::Create(MOSymbol, MCSymbolRefExpr::VK_PPC_TLSLD,
636 OutStreamer.EmitInstruction(MCInstBuilder(PPC::BL8_NOP_TLS)
641 case PPC::ADDISdtprelHA: {
642 // Transform: %Xd = ADDISdtprelHA %X3, <ga:@sym>
643 // Into: %Xd = ADDIS8 %X3, sym@dtprel@ha
644 assert(Subtarget.isPPC64() && "Not supported for 32-bit PowerPC");
645 const MachineOperand &MO = MI->getOperand(2);
646 const GlobalValue *GValue = MO.getGlobal();
647 MCSymbol *MOSymbol = getSymbol(GValue);
648 const MCExpr *SymDtprel =
649 MCSymbolRefExpr::Create(MOSymbol, MCSymbolRefExpr::VK_PPC_DTPREL_HA,
651 OutStreamer.EmitInstruction(MCInstBuilder(PPC::ADDIS8)
652 .addReg(MI->getOperand(0).getReg())
654 .addExpr(SymDtprel));
657 case PPC::ADDIdtprelL: {
658 // Transform: %Xd = ADDIdtprelL %Xs, <ga:@sym>
659 // Into: %Xd = ADDI8 %Xs, sym@dtprel@l
660 assert(Subtarget.isPPC64() && "Not supported for 32-bit PowerPC");
661 const MachineOperand &MO = MI->getOperand(2);
662 const GlobalValue *GValue = MO.getGlobal();
663 MCSymbol *MOSymbol = getSymbol(GValue);
664 const MCExpr *SymDtprel =
665 MCSymbolRefExpr::Create(MOSymbol, MCSymbolRefExpr::VK_PPC_DTPREL_LO,
667 OutStreamer.EmitInstruction(MCInstBuilder(PPC::ADDI8)
668 .addReg(MI->getOperand(0).getReg())
669 .addReg(MI->getOperand(1).getReg())
670 .addExpr(SymDtprel));
675 if (!Subtarget.hasMFOCRF()) {
676 // Transform: %R3 = MFOCRF %CR7
677 // Into: %R3 = MFCR ;; cr7
679 MI->getOpcode() == PPC::MFOCRF ? PPC::MFCR : PPC::MFCR8;
680 OutStreamer.AddComment(PPCInstPrinter::
681 getRegisterName(MI->getOperand(1).getReg()));
682 OutStreamer.EmitInstruction(MCInstBuilder(NewOpcode)
683 .addReg(MI->getOperand(0).getReg()));
689 if (!Subtarget.hasMFOCRF()) {
690 // Transform: %CR7 = MTOCRF %R3
691 // Into: MTCRF mask, %R3 ;; cr7
693 MI->getOpcode() == PPC::MTOCRF ? PPC::MTCRF : PPC::MTCRF8;
694 unsigned Mask = 0x80 >> OutContext.getRegisterInfo()
695 ->getEncodingValue(MI->getOperand(0).getReg());
696 OutStreamer.AddComment(PPCInstPrinter::
697 getRegisterName(MI->getOperand(0).getReg()));
698 OutStreamer.EmitInstruction(MCInstBuilder(NewOpcode)
700 .addReg(MI->getOperand(1).getReg()));
705 // In Book E sync is called msync, handle this special case here...
706 if (Subtarget.isBookE()) {
707 OutStreamer.EmitRawText(StringRef("\tmsync"));
715 // Verify alignment is legal, so we don't create relocations
716 // that can't be supported.
717 // FIXME: This test is currently disabled for Darwin. The test
718 // suite shows a handful of test cases that fail this check for
719 // Darwin. Those need to be investigated before this sanity test
720 // can be enabled for those subtargets.
721 if (!Subtarget.isDarwin()) {
722 unsigned OpNum = (MI->getOpcode() == PPC::STD) ? 2 : 1;
723 const MachineOperand &MO = MI->getOperand(OpNum);
724 if (MO.isGlobal() && MO.getGlobal()->getAlignment() < 4)
725 llvm_unreachable("Global must be word-aligned for LD, STD, LWA!");
727 // Now process the instruction normally.
732 LowerPPCMachineInstrToMCInst(MI, TmpInst, *this, Subtarget.isDarwin());
733 OutStreamer.EmitInstruction(TmpInst);
736 void PPCLinuxAsmPrinter::EmitFunctionEntryLabel() {
737 if (!Subtarget.isPPC64()) // linux/ppc32 - Normal entry label.
738 return AsmPrinter::EmitFunctionEntryLabel();
740 // Emit an official procedure descriptor.
741 MCSectionSubPair Current = OutStreamer.getCurrentSection();
742 const MCSectionELF *Section = OutStreamer.getContext().getELFSection(".opd",
743 ELF::SHT_PROGBITS, ELF::SHF_WRITE | ELF::SHF_ALLOC,
744 SectionKind::getReadOnly());
745 OutStreamer.SwitchSection(Section);
746 OutStreamer.EmitLabel(CurrentFnSym);
747 OutStreamer.EmitValueToAlignment(8);
749 OutContext.GetOrCreateSymbol(".L." + Twine(CurrentFnSym->getName()));
750 // Generates a R_PPC64_ADDR64 (from FK_DATA_8) relocation for the function
752 OutStreamer.EmitValue(MCSymbolRefExpr::Create(Symbol1, OutContext),
754 MCSymbol *Symbol2 = OutContext.GetOrCreateSymbol(StringRef(".TOC."));
755 // Generates a R_PPC64_TOC relocation for TOC base insertion.
756 OutStreamer.EmitValue(MCSymbolRefExpr::Create(Symbol2,
757 MCSymbolRefExpr::VK_PPC_TOCBASE, OutContext),
759 // Emit a null environment pointer.
760 OutStreamer.EmitIntValue(0, 8 /* size */);
761 OutStreamer.SwitchSection(Current.first, Current.second);
763 MCSymbol *RealFnSym = OutContext.GetOrCreateSymbol(
764 ".L." + Twine(CurrentFnSym->getName()));
765 OutStreamer.EmitLabel(RealFnSym);
766 CurrentFnSymForSize = RealFnSym;
770 bool PPCLinuxAsmPrinter::doFinalization(Module &M) {
771 const DataLayout *TD = TM.getDataLayout();
773 bool isPPC64 = TD->getPointerSizeInBits() == 64;
775 PPCTargetStreamer &TS =
776 static_cast<PPCTargetStreamer &>(OutStreamer.getTargetStreamer());
778 if (isPPC64 && !TOC.empty()) {
779 const MCSectionELF *Section = OutStreamer.getContext().getELFSection(".toc",
780 ELF::SHT_PROGBITS, ELF::SHF_WRITE | ELF::SHF_ALLOC,
781 SectionKind::getReadOnly());
782 OutStreamer.SwitchSection(Section);
784 for (MapVector<MCSymbol*, MCSymbol*>::iterator I = TOC.begin(),
785 E = TOC.end(); I != E; ++I) {
786 OutStreamer.EmitLabel(I->second);
787 MCSymbol *S = OutContext.GetOrCreateSymbol(I->first->getName());
792 MachineModuleInfoELF &MMIELF =
793 MMI->getObjFileInfo<MachineModuleInfoELF>();
795 MachineModuleInfoELF::SymbolListTy Stubs = MMIELF.GetGVStubList();
796 if (!Stubs.empty()) {
797 OutStreamer.SwitchSection(getObjFileLowering().getDataSection());
798 for (unsigned i = 0, e = Stubs.size(); i != e; ++i) {
800 OutStreamer.EmitLabel(Stubs[i].first);
802 OutStreamer.EmitValue(MCSymbolRefExpr::Create(Stubs[i].second.getPointer(),
804 isPPC64 ? 8 : 4/*size*/);
808 OutStreamer.AddBlankLine();
811 return AsmPrinter::doFinalization(M);
814 /// EmitFunctionBodyEnd - Print the traceback table before the .size
817 void PPCLinuxAsmPrinter::EmitFunctionBodyEnd() {
818 // Only the 64-bit target requires a traceback table. For now,
819 // we only emit the word of zeroes that GDB requires to find
820 // the end of the function, and zeroes for the eight-byte
822 // FIXME: We should fill in the eight-byte mandatory fields as described in
823 // the PPC64 ELF ABI (this is a low-priority item because GDB does not
824 // currently make use of these fields).
825 if (Subtarget.isPPC64()) {
826 OutStreamer.EmitIntValue(0, 4/*size*/);
827 OutStreamer.EmitIntValue(0, 8/*size*/);
831 void PPCDarwinAsmPrinter::EmitStartOfAsmFile(Module &M) {
832 static const char *const CPUDirectives[] = {
856 unsigned Directive = Subtarget.getDarwinDirective();
857 if (Subtarget.hasMFOCRF() && Directive < PPC::DIR_970)
858 Directive = PPC::DIR_970;
859 if (Subtarget.hasAltivec() && Directive < PPC::DIR_7400)
860 Directive = PPC::DIR_7400;
861 if (Subtarget.isPPC64() && Directive < PPC::DIR_64)
862 Directive = PPC::DIR_64;
863 assert(Directive <= PPC::DIR_64 && "Directive out of range.");
865 // FIXME: This is a total hack, finish mc'izing the PPC backend.
866 if (OutStreamer.hasRawTextSupport()) {
867 assert(Directive < array_lengthof(CPUDirectives) &&
868 "CPUDirectives[] might not be up-to-date!");
869 OutStreamer.EmitRawText("\t.machine " + Twine(CPUDirectives[Directive]));
872 // Prime text sections so they are adjacent. This reduces the likelihood a
873 // large data or debug section causes a branch to exceed 16M limit.
874 const TargetLoweringObjectFileMachO &TLOFMacho =
875 static_cast<const TargetLoweringObjectFileMachO &>(getObjFileLowering());
876 OutStreamer.SwitchSection(TLOFMacho.getTextCoalSection());
877 if (TM.getRelocationModel() == Reloc::PIC_) {
878 OutStreamer.SwitchSection(
879 OutContext.getMachOSection("__TEXT", "__picsymbolstub1",
880 MCSectionMachO::S_SYMBOL_STUBS |
881 MCSectionMachO::S_ATTR_PURE_INSTRUCTIONS,
882 32, SectionKind::getText()));
883 } else if (TM.getRelocationModel() == Reloc::DynamicNoPIC) {
884 OutStreamer.SwitchSection(
885 OutContext.getMachOSection("__TEXT","__symbol_stub1",
886 MCSectionMachO::S_SYMBOL_STUBS |
887 MCSectionMachO::S_ATTR_PURE_INSTRUCTIONS,
888 16, SectionKind::getText()));
890 OutStreamer.SwitchSection(getObjFileLowering().getTextSection());
893 static MCSymbol *GetLazyPtr(MCSymbol *Sym, MCContext &Ctx) {
894 // Remove $stub suffix, add $lazy_ptr.
895 StringRef NoStub = Sym->getName().substr(0, Sym->getName().size()-5);
896 return Ctx.GetOrCreateSymbol(NoStub + "$lazy_ptr");
899 static MCSymbol *GetAnonSym(MCSymbol *Sym, MCContext &Ctx) {
900 // Add $tmp suffix to $stub, yielding $stub$tmp.
901 return Ctx.GetOrCreateSymbol(Sym->getName() + "$tmp");
904 void PPCDarwinAsmPrinter::
905 EmitFunctionStubs(const MachineModuleInfoMachO::SymbolListTy &Stubs) {
906 bool isPPC64 = TM.getDataLayout()->getPointerSizeInBits() == 64;
907 bool isDarwin = Subtarget.isDarwin();
909 const TargetLoweringObjectFileMachO &TLOFMacho =
910 static_cast<const TargetLoweringObjectFileMachO &>(getObjFileLowering());
912 // .lazy_symbol_pointer
913 const MCSection *LSPSection = TLOFMacho.getLazySymbolPointerSection();
915 // Output stubs for dynamically-linked functions
916 if (TM.getRelocationModel() == Reloc::PIC_) {
917 const MCSection *StubSection =
918 OutContext.getMachOSection("__TEXT", "__picsymbolstub1",
919 MCSectionMachO::S_SYMBOL_STUBS |
920 MCSectionMachO::S_ATTR_PURE_INSTRUCTIONS,
921 32, SectionKind::getText());
922 for (unsigned i = 0, e = Stubs.size(); i != e; ++i) {
923 OutStreamer.SwitchSection(StubSection);
926 MCSymbol *Stub = Stubs[i].first;
927 MCSymbol *RawSym = Stubs[i].second.getPointer();
928 MCSymbol *LazyPtr = GetLazyPtr(Stub, OutContext);
929 MCSymbol *AnonSymbol = GetAnonSym(Stub, OutContext);
931 OutStreamer.EmitLabel(Stub);
932 OutStreamer.EmitSymbolAttribute(RawSym, MCSA_IndirectSymbol);
934 const MCExpr *Anon = MCSymbolRefExpr::Create(AnonSymbol, OutContext);
935 const MCExpr *LazyPtrExpr = MCSymbolRefExpr::Create(LazyPtr, OutContext);
937 MCBinaryExpr::CreateSub(LazyPtrExpr, Anon, OutContext);
940 OutStreamer.EmitInstruction(MCInstBuilder(PPC::MFLR).addReg(PPC::R0));
941 // bcl 20, 31, AnonSymbol
942 OutStreamer.EmitInstruction(MCInstBuilder(PPC::BCLalways).addExpr(Anon));
943 OutStreamer.EmitLabel(AnonSymbol);
945 OutStreamer.EmitInstruction(MCInstBuilder(PPC::MFLR).addReg(PPC::R11));
946 // addis r11, r11, ha16(LazyPtr - AnonSymbol)
947 const MCExpr *SubHa16 = PPCMCExpr::CreateHa(Sub, isDarwin, OutContext);
948 OutStreamer.EmitInstruction(MCInstBuilder(PPC::ADDIS)
953 OutStreamer.EmitInstruction(MCInstBuilder(PPC::MTLR).addReg(PPC::R0));
955 // ldu r12, lo16(LazyPtr - AnonSymbol)(r11)
956 // lwzu r12, lo16(LazyPtr - AnonSymbol)(r11)
957 const MCExpr *SubLo16 = PPCMCExpr::CreateLo(Sub, isDarwin, OutContext);
958 OutStreamer.EmitInstruction(MCInstBuilder(isPPC64 ? PPC::LDU : PPC::LWZU)
960 .addExpr(SubLo16).addExpr(SubLo16)
963 OutStreamer.EmitInstruction(MCInstBuilder(PPC::MTCTR).addReg(PPC::R12));
965 OutStreamer.EmitInstruction(MCInstBuilder(PPC::BCTR));
967 OutStreamer.SwitchSection(LSPSection);
968 OutStreamer.EmitLabel(LazyPtr);
969 OutStreamer.EmitSymbolAttribute(RawSym, MCSA_IndirectSymbol);
971 MCSymbol *DyldStubBindingHelper =
972 OutContext.GetOrCreateSymbol(StringRef("dyld_stub_binding_helper"));
974 // .quad dyld_stub_binding_helper
975 OutStreamer.EmitSymbolValue(DyldStubBindingHelper, 8);
977 // .long dyld_stub_binding_helper
978 OutStreamer.EmitSymbolValue(DyldStubBindingHelper, 4);
981 OutStreamer.AddBlankLine();
985 const MCSection *StubSection =
986 OutContext.getMachOSection("__TEXT","__symbol_stub1",
987 MCSectionMachO::S_SYMBOL_STUBS |
988 MCSectionMachO::S_ATTR_PURE_INSTRUCTIONS,
989 16, SectionKind::getText());
990 for (unsigned i = 0, e = Stubs.size(); i != e; ++i) {
991 MCSymbol *Stub = Stubs[i].first;
992 MCSymbol *RawSym = Stubs[i].second.getPointer();
993 MCSymbol *LazyPtr = GetLazyPtr(Stub, OutContext);
994 const MCExpr *LazyPtrExpr = MCSymbolRefExpr::Create(LazyPtr, OutContext);
996 OutStreamer.SwitchSection(StubSection);
998 OutStreamer.EmitLabel(Stub);
999 OutStreamer.EmitSymbolAttribute(RawSym, MCSA_IndirectSymbol);
1001 // lis r11, ha16(LazyPtr)
1002 const MCExpr *LazyPtrHa16 =
1003 PPCMCExpr::CreateHa(LazyPtrExpr, isDarwin, OutContext);
1004 OutStreamer.EmitInstruction(MCInstBuilder(PPC::LIS)
1006 .addExpr(LazyPtrHa16));
1008 // ldu r12, lo16(LazyPtr)(r11)
1009 // lwzu r12, lo16(LazyPtr)(r11)
1010 const MCExpr *LazyPtrLo16 =
1011 PPCMCExpr::CreateLo(LazyPtrExpr, isDarwin, OutContext);
1012 OutStreamer.EmitInstruction(MCInstBuilder(isPPC64 ? PPC::LDU : PPC::LWZU)
1014 .addExpr(LazyPtrLo16).addExpr(LazyPtrLo16)
1018 OutStreamer.EmitInstruction(MCInstBuilder(PPC::MTCTR).addReg(PPC::R12));
1020 OutStreamer.EmitInstruction(MCInstBuilder(PPC::BCTR));
1022 OutStreamer.SwitchSection(LSPSection);
1023 OutStreamer.EmitLabel(LazyPtr);
1024 OutStreamer.EmitSymbolAttribute(RawSym, MCSA_IndirectSymbol);
1026 MCSymbol *DyldStubBindingHelper =
1027 OutContext.GetOrCreateSymbol(StringRef("dyld_stub_binding_helper"));
1029 // .quad dyld_stub_binding_helper
1030 OutStreamer.EmitSymbolValue(DyldStubBindingHelper, 8);
1032 // .long dyld_stub_binding_helper
1033 OutStreamer.EmitSymbolValue(DyldStubBindingHelper, 4);
1037 OutStreamer.AddBlankLine();
1041 bool PPCDarwinAsmPrinter::doFinalization(Module &M) {
1042 bool isPPC64 = TM.getDataLayout()->getPointerSizeInBits() == 64;
1044 // Darwin/PPC always uses mach-o.
1045 const TargetLoweringObjectFileMachO &TLOFMacho =
1046 static_cast<const TargetLoweringObjectFileMachO &>(getObjFileLowering());
1047 MachineModuleInfoMachO &MMIMacho =
1048 MMI->getObjFileInfo<MachineModuleInfoMachO>();
1050 MachineModuleInfoMachO::SymbolListTy Stubs = MMIMacho.GetFnStubList();
1052 EmitFunctionStubs(Stubs);
1054 if (MAI->doesSupportExceptionHandling() && MMI) {
1055 // Add the (possibly multiple) personalities to the set of global values.
1056 // Only referenced functions get into the Personalities list.
1057 const std::vector<const Function*> &Personalities = MMI->getPersonalities();
1058 for (std::vector<const Function*>::const_iterator I = Personalities.begin(),
1059 E = Personalities.end(); I != E; ++I) {
1061 MCSymbol *NLPSym = GetSymbolWithGlobalValueBase(*I, "$non_lazy_ptr");
1062 MachineModuleInfoImpl::StubValueTy &StubSym =
1063 MMIMacho.getGVStubEntry(NLPSym);
1064 StubSym = MachineModuleInfoImpl::StubValueTy(getSymbol(*I), true);
1069 // Output stubs for dynamically-linked functions.
1070 Stubs = MMIMacho.GetGVStubList();
1072 // Output macho stubs for external and common global variables.
1073 if (!Stubs.empty()) {
1074 // Switch with ".non_lazy_symbol_pointer" directive.
1075 OutStreamer.SwitchSection(TLOFMacho.getNonLazySymbolPointerSection());
1076 EmitAlignment(isPPC64 ? 3 : 2);
1078 for (unsigned i = 0, e = Stubs.size(); i != e; ++i) {
1080 OutStreamer.EmitLabel(Stubs[i].first);
1081 // .indirect_symbol _foo
1082 MachineModuleInfoImpl::StubValueTy &MCSym = Stubs[i].second;
1083 OutStreamer.EmitSymbolAttribute(MCSym.getPointer(), MCSA_IndirectSymbol);
1086 // External to current translation unit.
1087 OutStreamer.EmitIntValue(0, isPPC64 ? 8 : 4/*size*/);
1089 // Internal to current translation unit.
1091 // When we place the LSDA into the TEXT section, the type info pointers
1092 // need to be indirect and pc-rel. We accomplish this by using NLPs.
1093 // However, sometimes the types are local to the file. So we need to
1094 // fill in the value for the NLP in those cases.
1095 OutStreamer.EmitValue(MCSymbolRefExpr::Create(MCSym.getPointer(),
1097 isPPC64 ? 8 : 4/*size*/);
1101 OutStreamer.AddBlankLine();
1104 Stubs = MMIMacho.GetHiddenGVStubList();
1105 if (!Stubs.empty()) {
1106 OutStreamer.SwitchSection(getObjFileLowering().getDataSection());
1107 EmitAlignment(isPPC64 ? 3 : 2);
1109 for (unsigned i = 0, e = Stubs.size(); i != e; ++i) {
1111 OutStreamer.EmitLabel(Stubs[i].first);
1113 OutStreamer.EmitValue(MCSymbolRefExpr::
1114 Create(Stubs[i].second.getPointer(),
1116 isPPC64 ? 8 : 4/*size*/);
1120 OutStreamer.AddBlankLine();
1123 // Funny Darwin hack: This flag tells the linker that no global symbols
1124 // contain code that falls through to other global symbols (e.g. the obvious
1125 // implementation of multiple entry points). If this doesn't occur, the
1126 // linker can safely perform dead code stripping. Since LLVM never generates
1127 // code that does this, it is always safe to set.
1128 OutStreamer.EmitAssemblerFlag(MCAF_SubsectionsViaSymbols);
1130 return AsmPrinter::doFinalization(M);
1133 /// createPPCAsmPrinterPass - Returns a pass that prints the PPC assembly code
1134 /// for a MachineFunction to the given output stream, in a format that the
1135 /// Darwin assembler can deal with.
1137 static AsmPrinter *createPPCAsmPrinterPass(TargetMachine &tm,
1138 MCStreamer &Streamer) {
1139 const PPCSubtarget *Subtarget = &tm.getSubtarget<PPCSubtarget>();
1141 if (Subtarget->isDarwin())
1142 return new PPCDarwinAsmPrinter(tm, Streamer);
1143 return new PPCLinuxAsmPrinter(tm, Streamer);
1146 // Force static initialization.
1147 extern "C" void LLVMInitializePowerPCAsmPrinter() {
1148 TargetRegistry::RegisterAsmPrinter(ThePPC32Target, createPPCAsmPrinterPass);
1149 TargetRegistry::RegisterAsmPrinter(ThePPC64Target, createPPCAsmPrinterPass);