@@ -147,22 +147,6 @@ class PPCLinuxAsmPrinter : public PPCAsmPrinter {
147147 void EmitInstruction (const MachineInstr *MI) override ;
148148};
149149
150- // / PPCDarwinAsmPrinter - PowerPC assembly printer, customized for Darwin/Mac
151- // / OS X
152- class PPCDarwinAsmPrinter : public PPCAsmPrinter {
153- public:
154- explicit PPCDarwinAsmPrinter (TargetMachine &TM,
155- std::unique_ptr<MCStreamer> Streamer)
156- : PPCAsmPrinter(TM, std::move(Streamer)) {}
157-
158- StringRef getPassName () const override {
159- return " Darwin PPC Assembly Printer" ;
160- }
161-
162- bool doFinalization (Module &M) override ;
163- void EmitStartOfAsmFile (Module &M) override ;
164- };
165-
166150class PPCAIXAsmPrinter : public PPCAsmPrinter {
167151private:
168152 static void ValidateGV (const GlobalVariable *GV);
@@ -1595,152 +1579,6 @@ void PPCLinuxAsmPrinter::EmitFunctionBodyEnd() {
15951579 }
15961580}
15971581
1598- void PPCDarwinAsmPrinter::EmitStartOfAsmFile (Module &M) {
1599- static const char *const CPUDirectives[] = {
1600- " " ,
1601- " ppc" ,
1602- " ppc440" ,
1603- " ppc601" ,
1604- " ppc602" ,
1605- " ppc603" ,
1606- " ppc7400" ,
1607- " ppc750" ,
1608- " ppc970" ,
1609- " ppcA2" ,
1610- " ppce500" ,
1611- " ppce500mc" ,
1612- " ppce5500" ,
1613- " power3" ,
1614- " power4" ,
1615- " power5" ,
1616- " power5x" ,
1617- " power6" ,
1618- " power6x" ,
1619- " power7" ,
1620- // FIXME: why is power8 missing here?
1621- " ppc64" ,
1622- " ppc64le" ,
1623- " power9" ,
1624- " future"
1625- };
1626-
1627- // Get the numerically largest directive.
1628- // FIXME: How should we merge darwin directives?
1629- unsigned Directive = PPC::DIR_NONE;
1630- for (const Function &F : M) {
1631- const PPCSubtarget &STI = TM.getSubtarget <PPCSubtarget>(F);
1632- unsigned FDir = STI.getCPUDirective ();
1633- Directive = Directive > FDir ? FDir : STI.getCPUDirective ();
1634- if (STI.hasMFOCRF () && Directive < PPC::DIR_970)
1635- Directive = PPC::DIR_970;
1636- if (STI.hasAltivec () && Directive < PPC::DIR_7400)
1637- Directive = PPC::DIR_7400;
1638- if (STI.isPPC64 () && Directive < PPC::DIR_64)
1639- Directive = PPC::DIR_64;
1640- }
1641-
1642- assert (Directive <= PPC::DIR_64 && " Directive out of range." );
1643-
1644- assert (Directive < array_lengthof (CPUDirectives) &&
1645- " CPUDirectives[] might not be up-to-date!" );
1646- PPCTargetStreamer &TStreamer =
1647- *static_cast <PPCTargetStreamer *>(OutStreamer->getTargetStreamer ());
1648- TStreamer.emitMachine (CPUDirectives[Directive]);
1649-
1650- // Prime text sections so they are adjacent. This reduces the likelihood a
1651- // large data or debug section causes a branch to exceed 16M limit.
1652- const TargetLoweringObjectFileMachO &TLOFMacho =
1653- static_cast <const TargetLoweringObjectFileMachO &>(getObjFileLowering ());
1654- OutStreamer->SwitchSection (TLOFMacho.getTextCoalSection ());
1655- if (TM.getRelocationModel () == Reloc::PIC_) {
1656- OutStreamer->SwitchSection (
1657- OutContext.getMachOSection (" __TEXT" , " __picsymbolstub1" ,
1658- MachO::S_SYMBOL_STUBS |
1659- MachO::S_ATTR_PURE_INSTRUCTIONS,
1660- 32 , SectionKind::getText ()));
1661- } else if (TM.getRelocationModel () == Reloc::DynamicNoPIC) {
1662- OutStreamer->SwitchSection (
1663- OutContext.getMachOSection (" __TEXT" ," __symbol_stub1" ,
1664- MachO::S_SYMBOL_STUBS |
1665- MachO::S_ATTR_PURE_INSTRUCTIONS,
1666- 16 , SectionKind::getText ()));
1667- }
1668- OutStreamer->SwitchSection (getObjFileLowering ().getTextSection ());
1669- }
1670-
1671- bool PPCDarwinAsmPrinter::doFinalization (Module &M) {
1672- bool isPPC64 = getDataLayout ().getPointerSizeInBits () == 64 ;
1673-
1674- // Darwin/PPC always uses mach-o.
1675- const TargetLoweringObjectFileMachO &TLOFMacho =
1676- static_cast <const TargetLoweringObjectFileMachO &>(getObjFileLowering ());
1677- if (MMI) {
1678- MachineModuleInfoMachO &MMIMacho =
1679- MMI->getObjFileInfo <MachineModuleInfoMachO>();
1680-
1681- if (MAI->doesSupportExceptionHandling ()) {
1682- // Add the (possibly multiple) personalities to the set of global values.
1683- // Only referenced functions get into the Personalities list.
1684- for (const Function *Personality : MMI->getPersonalities ()) {
1685- if (Personality) {
1686- MCSymbol *NLPSym =
1687- getSymbolWithGlobalValueBase (Personality, " $non_lazy_ptr" );
1688- MachineModuleInfoImpl::StubValueTy &StubSym =
1689- MMIMacho.getGVStubEntry (NLPSym);
1690- StubSym =
1691- MachineModuleInfoImpl::StubValueTy (getSymbol (Personality), true );
1692- }
1693- }
1694- }
1695-
1696- // Output stubs for dynamically-linked functions.
1697- MachineModuleInfoMachO::SymbolListTy Stubs = MMIMacho.GetGVStubList ();
1698-
1699- // Output macho stubs for external and common global variables.
1700- if (!Stubs.empty ()) {
1701- // Switch with ".non_lazy_symbol_pointer" directive.
1702- OutStreamer->SwitchSection (TLOFMacho.getNonLazySymbolPointerSection ());
1703- EmitAlignment (isPPC64 ? Align (8 ) : Align (4 ));
1704-
1705- for (unsigned i = 0 , e = Stubs.size (); i != e; ++i) {
1706- // L_foo$stub:
1707- OutStreamer->EmitLabel (Stubs[i].first );
1708- // .indirect_symbol _foo
1709- MachineModuleInfoImpl::StubValueTy &MCSym = Stubs[i].second ;
1710- OutStreamer->EmitSymbolAttribute (MCSym.getPointer (),
1711- MCSA_IndirectSymbol);
1712-
1713- if (MCSym.getInt ())
1714- // External to current translation unit.
1715- OutStreamer->EmitIntValue (0 , isPPC64 ? 8 : 4 /* size*/ );
1716- else
1717- // Internal to current translation unit.
1718- //
1719- // When we place the LSDA into the TEXT section, the type info
1720- // pointers
1721- // need to be indirect and pc-rel. We accomplish this by using NLPs.
1722- // However, sometimes the types are local to the file. So we need to
1723- // fill in the value for the NLP in those cases.
1724- OutStreamer->EmitValue (
1725- MCSymbolRefExpr::create (MCSym.getPointer (), OutContext),
1726- isPPC64 ? 8 : 4 /* size*/ );
1727- }
1728-
1729- Stubs.clear ();
1730- OutStreamer->AddBlankLine ();
1731- }
1732- }
1733-
1734- // Funny Darwin hack: This flag tells the linker that no global symbols
1735- // contain code that falls through to other global symbols (e.g. the obvious
1736- // implementation of multiple entry points). If this doesn't occur, the
1737- // linker can safely perform dead code stripping. Since LLVM never generates
1738- // code that does this, it is always safe to set.
1739- OutStreamer->EmitAssemblerFlag (MCAF_SubsectionsViaSymbols);
1740-
1741- return AsmPrinter::doFinalization (M);
1742- }
1743-
17441582void PPCAIXAsmPrinter::SetupMachineFunction (MachineFunction &MF) {
17451583 // Get the function descriptor symbol.
17461584 CurrentFnDescSym = getSymbol (&MF.getFunction ());
@@ -1957,8 +1795,6 @@ PPCAIXAsmPrinter::getMCSymbolForTOCPseudoMO(const MachineOperand &MO) {
19571795static AsmPrinter *
19581796createPPCAsmPrinterPass (TargetMachine &tm,
19591797 std::unique_ptr<MCStreamer> &&Streamer) {
1960- if (tm.getTargetTriple ().isMacOSX ())
1961- return new PPCDarwinAsmPrinter (tm, std::move (Streamer));
19621798 if (tm.getTargetTriple ().isOSAIX ())
19631799 return new PPCAIXAsmPrinter (tm, std::move (Streamer));
19641800
0 commit comments