MC-ize PPC's asm printing of stubs.

llvm-svn: 98300
This commit is contained in:
Bill Wendling 2010-03-11 23:39:44 +00:00
parent e7594305bc
commit faec0815a3
1 changed files with 20 additions and 9 deletions

View File

@ -34,6 +34,7 @@
#include "llvm/CodeGen/TargetLoweringObjectFileImpl.h" #include "llvm/CodeGen/TargetLoweringObjectFileImpl.h"
#include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCContext.h" #include "llvm/MC/MCContext.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCSectionMachO.h" #include "llvm/MC/MCSectionMachO.h"
#include "llvm/MC/MCStreamer.h" #include "llvm/MC/MCStreamer.h"
#include "llvm/MC/MCSymbol.h" #include "llvm/MC/MCSymbol.h"
@ -806,11 +807,16 @@ bool PPCDarwinAsmPrinter::doFinalization(Module &M) {
EmitAlignment(isPPC64 ? 3 : 2); EmitAlignment(isPPC64 ? 3 : 2);
for (unsigned i = 0, e = Stubs.size(); i != e; ++i) { for (unsigned i = 0, e = Stubs.size(); i != e; ++i) {
O << *Stubs[i].first << ":\n"; // L_foo$stub:
O << "\t.indirect_symbol " << *Stubs[i].second.getPointer() << '\n'; OutStreamer.EmitLabel(Stubs[i].first);
// FIXME: This should use the "GV is external" bit. // .indirect_symbol _foo
O << (isPPC64 ? "\t.quad\t0\n" : "\t.long\t0\n"); MachineModuleInfoImpl::StubValueTy &MCSym = Stubs[i].second;
OutStreamer.EmitSymbolAttribute(MCSym.getPointer(), MCSA_IndirectSymbol);
OutStreamer.EmitIntValue(0, isPPC64 ? 8 : 4/*size*/, 0/*addrspace*/);
} }
Stubs.clear();
OutStreamer.AddBlankLine();
} }
Stubs = MMIMacho.GetHiddenGVStubList(); Stubs = MMIMacho.GetHiddenGVStubList();
@ -819,10 +825,17 @@ bool PPCDarwinAsmPrinter::doFinalization(Module &M) {
EmitAlignment(isPPC64 ? 3 : 2); EmitAlignment(isPPC64 ? 3 : 2);
for (unsigned i = 0, e = Stubs.size(); i != e; ++i) { for (unsigned i = 0, e = Stubs.size(); i != e; ++i) {
O << *Stubs[i].first << ":\n"; // L_foo$stub:
O << (isPPC64 ? "\t.quad\t" : "\t.long\t") OutStreamer.EmitLabel(Stubs[i].first);
<< *Stubs[i].second.getPointer() << '\n'; // .long _foo
OutStreamer.EmitValue(MCSymbolRefExpr::
Create(Stubs[i].second.getPointer(),
OutContext),
isPPC64 ? 8 : 4/*size*/, 0/*addrspace*/);
} }
Stubs.clear();
OutStreamer.AddBlankLine();
} }
// Funny Darwin hack: This flag tells the linker that no global symbols // Funny Darwin hack: This flag tells the linker that no global symbols
@ -835,8 +848,6 @@ bool PPCDarwinAsmPrinter::doFinalization(Module &M) {
return AsmPrinter::doFinalization(M); return AsmPrinter::doFinalization(M);
} }
/// createPPCAsmPrinterPass - Returns a pass that prints the PPC assembly code /// createPPCAsmPrinterPass - Returns a pass that prints the PPC assembly code
/// for a MachineFunction to the given output stream, in a format that the /// for a MachineFunction to the given output stream, in a format that the
/// Darwin assembler can deal with. /// Darwin assembler can deal with.