diff --git a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCAsmInfo.h b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCAsmInfo.h --- a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCAsmInfo.h +++ b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCAsmInfo.h @@ -20,13 +20,6 @@ namespace llvm { class Triple; -class PPCMCAsmInfoDarwin : public MCAsmInfoDarwin { - virtual void anchor(); - -public: - explicit PPCMCAsmInfoDarwin(bool is64Bit, const Triple &); -}; - class PPCELFMCAsmInfo : public MCAsmInfoELF { void anchor() override; diff --git a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCAsmInfo.cpp b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCAsmInfo.cpp --- a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCAsmInfo.cpp +++ b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCAsmInfo.cpp @@ -15,33 +15,6 @@ using namespace llvm; -void PPCMCAsmInfoDarwin::anchor() { } - -PPCMCAsmInfoDarwin::PPCMCAsmInfoDarwin(bool is64Bit, const Triple& T) { - if (is64Bit) { - CodePointerSize = CalleeSaveStackSlotSize = 8; - } - IsLittleEndian = false; - - SeparatorString = "@"; - CommentString = ";"; - ExceptionsType = ExceptionHandling::DwarfCFI; - - if (!is64Bit) - Data64bitsDirective = nullptr; // We can't emit a 64-bit unit in PPC32 mode. - - AssemblerDialect = 1; // New-Style mnemonics. - SupportsDebugInformation= true; // Debug information. - - // The installed assembler for OSX < 10.6 lacks some directives. - // FIXME: this should really be a check on the assembler characteristics - // rather than OS version - if (T.isMacOSX() && T.isMacOSXVersionLT(10, 6)) - HasWeakDefCanBeHiddenDirective = false; - - UseIntegratedAssembler = true; -} - void PPCELFMCAsmInfo::anchor() { } PPCELFMCAsmInfo::PPCELFMCAsmInfo(bool is64Bit, const Triple& T) { diff --git a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp --- a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp +++ b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp @@ -83,9 +83,7 @@ TheTriple.getArch() == Triple::ppc64le); MCAsmInfo *MAI; - if (TheTriple.isOSDarwin()) - MAI = new PPCMCAsmInfoDarwin(isPPC64, TheTriple); - else if (TheTriple.isOSBinFormatXCOFF()) + if (TheTriple.isOSBinFormatXCOFF()) MAI = new PPCXCOFFMCAsmInfo(isPPC64, TheTriple); else MAI = new PPCELFMCAsmInfo(isPPC64, TheTriple); diff --git a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp --- a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp +++ b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp @@ -147,22 +147,6 @@ void EmitInstruction(const MachineInstr *MI) override; }; -/// PPCDarwinAsmPrinter - PowerPC assembly printer, customized for Darwin/Mac -/// OS X -class PPCDarwinAsmPrinter : public PPCAsmPrinter { -public: - explicit PPCDarwinAsmPrinter(TargetMachine &TM, - std::unique_ptr Streamer) - : PPCAsmPrinter(TM, std::move(Streamer)) {} - - StringRef getPassName() const override { - return "Darwin PPC Assembly Printer"; - } - - bool doFinalization(Module &M) override; - void EmitStartOfAsmFile(Module &M) override; -}; - class PPCAIXAsmPrinter : public PPCAsmPrinter { private: static void ValidateGV(const GlobalVariable *GV); @@ -1593,152 +1577,6 @@ } } -void PPCDarwinAsmPrinter::EmitStartOfAsmFile(Module &M) { - static const char *const CPUDirectives[] = { - "", - "ppc", - "ppc440", - "ppc601", - "ppc602", - "ppc603", - "ppc7400", - "ppc750", - "ppc970", - "ppcA2", - "ppce500", - "ppce500mc", - "ppce5500", - "power3", - "power4", - "power5", - "power5x", - "power6", - "power6x", - "power7", - // FIXME: why is power8 missing here? - "ppc64", - "ppc64le", - "power9", - "future" - }; - - // Get the numerically largest directive. - // FIXME: How should we merge darwin directives? - unsigned Directive = PPC::DIR_NONE; - for (const Function &F : M) { - const PPCSubtarget &STI = TM.getSubtarget(F); - unsigned FDir = STI.getCPUDirective(); - Directive = Directive > FDir ? FDir : STI.getCPUDirective(); - if (STI.hasMFOCRF() && Directive < PPC::DIR_970) - Directive = PPC::DIR_970; - if (STI.hasAltivec() && Directive < PPC::DIR_7400) - Directive = PPC::DIR_7400; - if (STI.isPPC64() && Directive < PPC::DIR_64) - Directive = PPC::DIR_64; - } - - assert(Directive <= PPC::DIR_64 && "Directive out of range."); - - assert(Directive < array_lengthof(CPUDirectives) && - "CPUDirectives[] might not be up-to-date!"); - PPCTargetStreamer &TStreamer = - *static_cast(OutStreamer->getTargetStreamer()); - TStreamer.emitMachine(CPUDirectives[Directive]); - - // Prime text sections so they are adjacent. This reduces the likelihood a - // large data or debug section causes a branch to exceed 16M limit. - const TargetLoweringObjectFileMachO &TLOFMacho = - static_cast(getObjFileLowering()); - OutStreamer->SwitchSection(TLOFMacho.getTextCoalSection()); - if (TM.getRelocationModel() == Reloc::PIC_) { - OutStreamer->SwitchSection( - OutContext.getMachOSection("__TEXT", "__picsymbolstub1", - MachO::S_SYMBOL_STUBS | - MachO::S_ATTR_PURE_INSTRUCTIONS, - 32, SectionKind::getText())); - } else if (TM.getRelocationModel() == Reloc::DynamicNoPIC) { - OutStreamer->SwitchSection( - OutContext.getMachOSection("__TEXT","__symbol_stub1", - MachO::S_SYMBOL_STUBS | - MachO::S_ATTR_PURE_INSTRUCTIONS, - 16, SectionKind::getText())); - } - OutStreamer->SwitchSection(getObjFileLowering().getTextSection()); -} - -bool PPCDarwinAsmPrinter::doFinalization(Module &M) { - bool isPPC64 = getDataLayout().getPointerSizeInBits() == 64; - - // Darwin/PPC always uses mach-o. - const TargetLoweringObjectFileMachO &TLOFMacho = - static_cast(getObjFileLowering()); - if (MMI) { - MachineModuleInfoMachO &MMIMacho = - MMI->getObjFileInfo(); - - if (MAI->doesSupportExceptionHandling()) { - // Add the (possibly multiple) personalities to the set of global values. - // Only referenced functions get into the Personalities list. - for (const Function *Personality : MMI->getPersonalities()) { - if (Personality) { - MCSymbol *NLPSym = - getSymbolWithGlobalValueBase(Personality, "$non_lazy_ptr"); - MachineModuleInfoImpl::StubValueTy &StubSym = - MMIMacho.getGVStubEntry(NLPSym); - StubSym = - MachineModuleInfoImpl::StubValueTy(getSymbol(Personality), true); - } - } - } - - // Output stubs for dynamically-linked functions. - MachineModuleInfoMachO::SymbolListTy Stubs = MMIMacho.GetGVStubList(); - - // Output macho stubs for external and common global variables. - if (!Stubs.empty()) { - // Switch with ".non_lazy_symbol_pointer" directive. - OutStreamer->SwitchSection(TLOFMacho.getNonLazySymbolPointerSection()); - EmitAlignment(isPPC64 ? Align(8) : Align(4)); - - for (unsigned i = 0, e = Stubs.size(); i != e; ++i) { - // L_foo$stub: - OutStreamer->EmitLabel(Stubs[i].first); - // .indirect_symbol _foo - MachineModuleInfoImpl::StubValueTy &MCSym = Stubs[i].second; - OutStreamer->EmitSymbolAttribute(MCSym.getPointer(), - MCSA_IndirectSymbol); - - if (MCSym.getInt()) - // External to current translation unit. - OutStreamer->EmitIntValue(0, isPPC64 ? 8 : 4 /*size*/); - else - // Internal to current translation unit. - // - // When we place the LSDA into the TEXT section, the type info - // pointers - // need to be indirect and pc-rel. We accomplish this by using NLPs. - // However, sometimes the types are local to the file. So we need to - // fill in the value for the NLP in those cases. - OutStreamer->EmitValue( - MCSymbolRefExpr::create(MCSym.getPointer(), OutContext), - isPPC64 ? 8 : 4 /*size*/); - } - - Stubs.clear(); - OutStreamer->AddBlankLine(); - } - } - - // Funny Darwin hack: This flag tells the linker that no global symbols - // contain code that falls through to other global symbols (e.g. the obvious - // implementation of multiple entry points). If this doesn't occur, the - // linker can safely perform dead code stripping. Since LLVM never generates - // code that does this, it is always safe to set. - OutStreamer->EmitAssemblerFlag(MCAF_SubsectionsViaSymbols); - - return AsmPrinter::doFinalization(M); -} - void PPCAIXAsmPrinter::SetupMachineFunction(MachineFunction &MF) { // Get the function descriptor symbol. CurrentFnDescSym = getSymbol(&MF.getFunction()); @@ -1936,8 +1774,6 @@ static AsmPrinter * createPPCAsmPrinterPass(TargetMachine &tm, std::unique_ptr &&Streamer) { - if (tm.getTargetTriple().isMacOSX()) - return new PPCDarwinAsmPrinter(tm, std::move(Streamer)); if (tm.getTargetTriple().isOSAIX()) return new PPCAIXAsmPrinter(tm, std::move(Streamer)); diff --git a/llvm/test/CodeGen/PowerPC/hello-reloc.s b/llvm/test/CodeGen/PowerPC/hello-reloc.s deleted file mode 100644 --- a/llvm/test/CodeGen/PowerPC/hello-reloc.s +++ /dev/null @@ -1,140 +0,0 @@ -; This tests for the basic implementation of PPCMachObjectWriter.cpp, -; which is responsible for writing mach-o relocation entries for (PIC) -; PowerPC objects. - -; RUN: llvm-mc -filetype=obj -mcpu=g4 -triple=powerpc-apple-darwin8 %s -o - | llvm-readobj -r --expand-relocs | FileCheck -check-prefix=DARWIN-G4-DUMP %s - - .machine ppc7400 - .section __TEXT,__textcoal_nt,coalesced,pure_instructions - .section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32 - .section __TEXT,__text,regular,pure_instructions - .globl _main - .align 4 -_main: ; @main -; %bb.0: ; %entry - mflr r0 - stw r31, -4(r1) - stw r0, 8(r1) - stwu r1, -80(r1) - bl L0$pb -L0$pb: - mr r31, r1 - li r5, 0 - mflr 2 - stw r3, 68(r31) - stw r5, 72(r31) - stw r4, 64(r31) - addis r2, r2, ha16(L_.str-L0$pb) - la r3, lo16(L_.str-L0$pb)(r2) - bl L_puts$stub - li r3, 0 - addi r1, r1, 80 - lwz r0, 8(r1) - lwz r31, -4(r1) - mtlr r0 - blr - - .section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32 - .align 4 -L_puts$stub: - .indirect_symbol _puts - mflr r0 - bcl 20, 31, L_puts$stub$tmp -L_puts$stub$tmp: - mflr r11 - addis r11, r11, ha16(L_puts$lazy_ptr-L_puts$stub$tmp) - mtlr r0 - lwzu r12, lo16(L_puts$lazy_ptr-L_puts$stub$tmp)(r11) - mtctr r12 - bctr - .section __DATA,__la_symbol_ptr,lazy_symbol_pointers -L_puts$lazy_ptr: - .indirect_symbol _puts - .long dyld_stub_binding_helper - -.subsections_via_symbols - .section __TEXT,__cstring,cstring_literals -L_.str: ; @.str - .asciz "Hello, world!" - -; DARWIN-G4-DUMP:Format: Mach-O 32-bit ppc -; DARWIN-G4-DUMP:Arch: powerpc -; DARWIN-G4-DUMP:AddressSize: 32bit -; DARWIN-G4-DUMP:Relocations [ -; DARWIN-G4-DUMP: Section __text { -; DARWIN-G4-DUMP: Relocation { -; DARWIN-G4-DUMP: Offset: 0x34 -; DARWIN-G4-DUMP: PCRel: 1 -; DARWIN-G4-DUMP: Length: 2 -; DARWIN-G4-DUMP: Type: PPC_RELOC_BR24 (3) -; DARWIN-G4-DUMP: Section: __picsymbolstub1 -; DARWIN-G4-DUMP: } -; DARWIN-G4-DUMP: Relocation { -; DARWIN-G4-DUMP: Offset: 0x30 -; DARWIN-G4-DUMP: PCRel: 0 -; DARWIN-G4-DUMP: Length: 2 -; DARWIN-G4-DUMP: Type: PPC_RELOC_LO16_SECTDIFF (11) -; DARWIN-G4-DUMP: Value: 0x74 -; DARWIN-G4-DUMP: } -; DARWIN-G4-DUMP: Relocation { -; DARWIN-G4-DUMP: Offset: 0x0 -; DARWIN-G4-DUMP: PCRel: 0 -; DARWIN-G4-DUMP: Length: 2 -; DARWIN-G4-DUMP: Type: PPC_RELOC_PAIR (1) -; DARWIN-G4-DUMP: Value: 0x14 -; DARWIN-G4-DUMP: } -; DARWIN-G4-DUMP: Relocation { -; DARWIN-G4-DUMP: Offset: 0x2C -; DARWIN-G4-DUMP: PCRel: 0 -; DARWIN-G4-DUMP: Length: 2 -; DARWIN-G4-DUMP: Type: PPC_RELOC_HA16_SECTDIFF (12) -; DARWIN-G4-DUMP: Value: 0x74 -; DARWIN-G4-DUMP: } -; DARWIN-G4-DUMP: Relocation { -; DARWIN-G4-DUMP: Offset: 0x60 -; DARWIN-G4-DUMP: PCRel: 0 -; DARWIN-G4-DUMP: Length: 2 -; DARWIN-G4-DUMP: Type: PPC_RELOC_PAIR (1) -; DARWIN-G4-DUMP: Value: 0x14 -; DARWIN-G4-DUMP: } -; DARWIN-G4-DUMP: } -; DARWIN-G4-DUMP: Section __picsymbolstub1 { -; DARWIN-G4-DUMP: Relocation { -; DARWIN-G4-DUMP: Offset: 0x14 -; DARWIN-G4-DUMP: PCRel: 0 -; DARWIN-G4-DUMP: Length: 2 -; DARWIN-G4-DUMP: Type: PPC_RELOC_LO16_SECTDIFF (11) -; DARWIN-G4-DUMP: Value: 0x70 -; DARWIN-G4-DUMP: } -; DARWIN-G4-DUMP: Relocation { -; DARWIN-G4-DUMP: Offset: 0x0 -; DARWIN-G4-DUMP: PCRel: 0 -; DARWIN-G4-DUMP: Length: 2 -; DARWIN-G4-DUMP: Type: PPC_RELOC_PAIR (1) -; DARWIN-G4-DUMP: Value: 0x58 -; DARWIN-G4-DUMP: } -; DARWIN-G4-DUMP: Relocation { -; DARWIN-G4-DUMP: Offset: 0xC -; DARWIN-G4-DUMP: PCRel: 0 -; DARWIN-G4-DUMP: Length: 2 -; DARWIN-G4-DUMP: Type: PPC_RELOC_HA16_SECTDIFF (12) -; DARWIN-G4-DUMP: Value: 0x70 -; DARWIN-G4-DUMP: } -; DARWIN-G4-DUMP: Relocation { -; DARWIN-G4-DUMP: Offset: 0x18 -; DARWIN-G4-DUMP: PCRel: 0 -; DARWIN-G4-DUMP: Length: 2 -; DARWIN-G4-DUMP: Type: PPC_RELOC_PAIR (1) -; DARWIN-G4-DUMP: Value: 0x58 -; DARWIN-G4-DUMP: } -; DARWIN-G4-DUMP: } -; DARWIN-G4-DUMP: Section __la_symbol_ptr { -; DARWIN-G4-DUMP: Relocation { -; DARWIN-G4-DUMP: Offset: 0x0 -; DARWIN-G4-DUMP: PCRel: 0 -; DARWIN-G4-DUMP: Length: 2 -; DARWIN-G4-DUMP: Type: PPC_RELOC_VANILLA (0) -; DARWIN-G4-DUMP: Symbol: dyld_stub_binding_helper -; DARWIN-G4-DUMP: } -; DARWIN-G4-DUMP: } -; DARWIN-G4-DUMP:] diff --git a/llvm/test/MC/PowerPC/ppc-separator.s b/llvm/test/MC/PowerPC/ppc-separator.s deleted file mode 100644 --- a/llvm/test/MC/PowerPC/ppc-separator.s +++ /dev/null @@ -1,10 +0,0 @@ -; RUN: llvm-mc -triple powerpc-apple-darwin -show-encoding -o - %s | FileCheck %s -; RUN: llvm-mc -triple powerpc64-apple-darwin -show-encoding -o - %s | FileCheck %s - -_label: - li r0, 0 @ li r1, 1 - -; CHECK: _label: -; CHECK: li r0, 0 ; encoding -; CHECK: li r1, 1 ; encoding -