diff options
author | Chris Lattner <sabre@nondot.org> | 2009-07-15 02:28:57 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-07-15 02:28:57 +0000 |
commit | 9ec8facd10e48d1ec62c7c91cbd5f003771764d8 (patch) | |
tree | 2f28783d0577611739896673a55e2e2794ee30ad | |
parent | b7b179ead9a5daff00a6ee1034be4dee2b5b462d (diff) | |
download | external_llvm-9ec8facd10e48d1ec62c7c91cbd5f003771764d8.zip external_llvm-9ec8facd10e48d1ec62c7c91cbd5f003771764d8.tar.gz external_llvm-9ec8facd10e48d1ec62c7c91cbd5f003771764d8.tar.bz2 |
convert FnStubs to using a more structured form, eliminating
a couple instances of printSuffixedName (in favor of having
the mangler do stuff).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75729 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp | 40 |
1 files changed, 31 insertions, 9 deletions
diff --git a/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp b/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp index b8b1516..7fdaae8 100644 --- a/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp +++ b/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp @@ -53,7 +53,29 @@ STATISTIC(EmittedInsts, "Number of machine instrs printed"); namespace { class VISIBILITY_HIDDEN PPCAsmPrinter : public AsmPrinter { protected: - StringSet<> FnStubs; + struct FnStubInfo { + std::string Stub, LazyPtr, AnonSymbol; + + FnStubInfo() {} + + void Init(const GlobalValue *GV, Mangler *Mang) { + // Already initialized. + if (!Stub.empty()) return; + Stub = Mang->getMangledName(GV, "$stub", true); + LazyPtr = Mang->getMangledName(GV, "$lazy_ptr", true); + AnonSymbol = Mang->getMangledName(GV, "$stub$tmp", true); + } + + void Init(const std::string &GV, Mangler *Mang) { + // Already initialized. + if (!Stub.empty()) return; + Stub = Mang->makeNameProper(GV+"$stub", true); + LazyPtr = Mang->makeNameProper(GV+"$lazy_ptr", true); + AnonSymbol = Mang->makeNameProper(GV+"$stub$tmp", true); + } + }; + + StringMap<FnStubInfo> FnStubs; StringMap<std::string> GVStubs, HiddenGVStubs; const PPCSubtarget &Subtarget; public: @@ -192,16 +214,16 @@ namespace { GlobalValue *GV = MO.getGlobal(); if (GV->isDeclaration() || GV->isWeakForLinker()) { // Dynamically-resolved functions need a stub for the function. - std::string Name = Mang->getMangledName(GV); - FnStubs.insert(Name); - printSuffixedName(Name, "$stub"); + FnStubInfo &FnInfo = FnStubs[Mang->getMangledName(GV)]; + FnInfo.Init(GV, Mang); + O << FnInfo.Stub; return; } } if (MO.getType() == MachineOperand::MO_ExternalSymbol) { - std::string Name(TAI->getGlobalPrefix()); Name += MO.getSymbolName(); - FnStubs.insert(Name); - printSuffixedName(Name, "$stub"); + FnStubInfo &FnInfo =FnStubs[Mang->makeNameProper(MO.getSymbolName())]; + FnInfo.Init(MO.getSymbolName(), Mang); + O << FnInfo.Stub; return; } } @@ -963,7 +985,7 @@ bool PPCDarwinAsmPrinter::doFinalization(Module &M) { if (TM.getRelocationModel() == Reloc::PIC_ && !FnStubs.empty()) { SwitchToTextSection("\t.section __TEXT,__picsymbolstub1,symbol_stubs," "pure_instructions,32"); - for (StringSet<>::iterator I = FnStubs.begin(), E = FnStubs.end(); + for (StringMap<FnStubInfo>::iterator I = FnStubs.begin(), E = FnStubs.end(); I != E; ++I) { EmitAlignment(4); const char *p = I->getKeyData(); @@ -1018,7 +1040,7 @@ bool PPCDarwinAsmPrinter::doFinalization(Module &M) { } else if (!FnStubs.empty()) { SwitchToTextSection("\t.section __TEXT,__symbol_stub1,symbol_stubs," "pure_instructions,16"); - for (StringSet<>::iterator I = FnStubs.begin(), E = FnStubs.end(); + for (StringMap<FnStubInfo>::iterator I = FnStubs.begin(), E = FnStubs.end(); I != E; ++I) { EmitAlignment(4); const char *p = I->getKeyData(); |