From 7e097e463314baa3c964a977408aa51ecabe7796 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 27 Jun 2006 01:02:25 +0000 Subject: Print darwin stub stuff correctly in 64-bit mode. With this, treeadd works in ppc64 mode! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28923 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/PowerPC/PPCAsmPrinter.cpp | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'lib/Target/PowerPC') diff --git a/lib/Target/PowerPC/PPCAsmPrinter.cpp b/lib/Target/PowerPC/PPCAsmPrinter.cpp index c4f19fe..512a4cc 100644 --- a/lib/Target/PowerPC/PPCAsmPrinter.cpp +++ b/lib/Target/PowerPC/PPCAsmPrinter.cpp @@ -268,13 +268,17 @@ namespace { DarwinDwarfWriter DW; - DarwinAsmPrinter(std::ostream &O, TargetMachine &TM) + DarwinAsmPrinter(std::ostream &O, PPCTargetMachine &TM) : PPCAsmPrinter(O, TM), DW(O, this) { + bool isPPC64 = TM.getSubtargetImpl()->isPPC64(); CommentString = ";"; GlobalPrefix = "_"; PrivateGlobalPrefix = "L"; // Marker for constant pool idxs ZeroDirective = "\t.space\t"; // ".space N" emits N zeros. - Data64bitsDirective = 0; // we can't emit a 64-bit unit + if (isPPC64) + Data64bitsDirective = ".quad"; // we can't emit a 64-bit unit + else + Data64bitsDirective = 0; // we can't emit a 64-bit unit AlignmentIsInBytes = false; // Alignment is by power of 2. ConstantPoolSection = "\t.const\t"; // FIXME: Conditionalize jump table section based on PIC @@ -625,13 +629,15 @@ bool DarwinAsmPrinter::doFinalization(Module &M) { } } + bool isPPC64 = TD->getPointerSizeInBits() == 64; + // Output stubs for dynamically-linked functions if (TM.getRelocationModel() == Reloc::PIC) { for (std::set::iterator i = FnStubs.begin(), e = FnStubs.end(); i != e; ++i) { SwitchToTextSection(".section __TEXT,__picsymbolstub1,symbol_stubs," "pure_instructions,32", 0); - EmitAlignment(2); + EmitAlignment(4); O << "L" << *i << "$stub:\n"; O << "\t.indirect_symbol " << *i << "\n"; O << "\tmflr r0\n"; @@ -640,13 +646,19 @@ bool DarwinAsmPrinter::doFinalization(Module &M) { O << "\tmflr r11\n"; O << "\taddis r11,r11,ha16(L" << *i << "$lazy_ptr-L0$" << *i << ")\n"; O << "\tmtlr r0\n"; - O << "\tlwzu r12,lo16(L" << *i << "$lazy_ptr-L0$" << *i << ")(r11)\n"; + if (isPPC64) + O << "\tldu r12,lo16(L" << *i << "$lazy_ptr-L0$" << *i << ")(r11)\n"; + else + O << "\tlwzu r12,lo16(L" << *i << "$lazy_ptr-L0$" << *i << ")(r11)\n"; O << "\tmtctr r12\n"; O << "\tbctr\n"; SwitchToDataSection(".lazy_symbol_pointer", 0); O << "L" << *i << "$lazy_ptr:\n"; O << "\t.indirect_symbol " << *i << "\n"; - O << "\t.long dyld_stub_binding_helper\n"; + if (isPPC64) + O << "\t.quad dyld_stub_binding_helper\n"; + else + O << "\t.long dyld_stub_binding_helper\n"; } } else { for (std::set::iterator i = FnStubs.begin(), e = FnStubs.end(); @@ -657,13 +669,19 @@ bool DarwinAsmPrinter::doFinalization(Module &M) { O << "L" << *i << "$stub:\n"; O << "\t.indirect_symbol " << *i << "\n"; O << "\tlis r11,ha16(L" << *i << "$lazy_ptr)\n"; - O << "\tlwzu r12,lo16(L" << *i << "$lazy_ptr)(r11)\n"; + if (isPPC64) + O << "\tldu r12,lo16(L" << *i << "$lazy_ptr)(r11)\n"; + else + O << "\tlwzu r12,lo16(L" << *i << "$lazy_ptr)(r11)\n"; O << "\tmtctr r12\n"; O << "\tbctr\n"; SwitchToDataSection(".lazy_symbol_pointer", 0); O << "L" << *i << "$lazy_ptr:\n"; O << "\t.indirect_symbol " << *i << "\n"; - O << "\t.long dyld_stub_binding_helper\n"; + if (isPPC64) + O << "\t.quad dyld_stub_binding_helper\n"; + else + O << "\t.long dyld_stub_binding_helper\n"; } } -- cgit v1.1