diff options
author | Chris Lattner <sabre@nondot.org> | 2010-01-15 23:55:16 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-01-15 23:55:16 +0000 |
commit | d1947ed2f824d2e9f4923fb6efc2aec4a6e3e96d (patch) | |
tree | 5ce784b9179fd0aed2a0104f7fccdc0072b37eb6 /lib | |
parent | 263d989a719c1864862fc91f59193a6c2b55ca48 (diff) | |
download | external_llvm-d1947ed2f824d2e9f4923fb6efc2aec4a6e3e96d.zip external_llvm-d1947ed2f824d2e9f4923fb6efc2aec4a6e3e96d.tar.gz external_llvm-d1947ed2f824d2e9f4923fb6efc2aec4a6e3e96d.tar.bz2 |
supplement CurrentFnName with CurrentFnSym, which will eventually
replace it. Upgrade Alpha, Blackfin, and part of CellSPU to not
use mangler anymore. CellSPU needs more invasive surgery.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93589 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 1 | ||||
-rw-r--r-- | lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp | 58 | ||||
-rw-r--r-- | lib/Target/Blackfin/AsmPrinter/BlackfinAsmPrinter.cpp | 60 | ||||
-rw-r--r-- | lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp | 25 |
4 files changed, 92 insertions, 52 deletions
diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 7293ec0..16eec0c 100644 --- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -224,6 +224,7 @@ bool AsmPrinter::doFinalization(Module &M) { void AsmPrinter::SetupMachineFunction(MachineFunction &MF) { // What's my mangled name? CurrentFnName = Mang->getMangledName(MF.getFunction()); + CurrentFnSym = GetGlobalValueSymbol(MF.getFunction()); IncrementFunctionNumber(); if (VerboseAsm) diff --git a/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp b/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp index 338057b..235b16d 100644 --- a/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp +++ b/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp @@ -28,7 +28,6 @@ #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetRegistry.h" #include "llvm/Support/ErrorHandling.h" -#include "llvm/Support/Mangler.h" #include "llvm/Support/FormattedStream.h" #include "llvm/ADT/Statistic.h" using namespace llvm; @@ -108,7 +107,7 @@ void AlphaAsmPrinter::printOp(const MachineOperand &MO, bool IsCallOp) { return; case MachineOperand::MO_GlobalAddress: - O << Mang->getMangledName(MO.getGlobal()); + GetGlobalValueSymbol(MO.getGlobal())->print(O, MAI); return; case MachineOperand::MO_JumpTableIndex: @@ -208,7 +207,7 @@ void AlphaAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) { if (EmitSpecialLLVMGlobal(GVar)) return; - std::string name = Mang->getMangledName(GVar); + MCSymbol *GVarSym = GetGlobalValueSymbol(GVar); Constant *C = GVar->getInitializer(); unsigned Size = TD->getTypeAllocSize(C->getType()); unsigned Align = TD->getPreferredAlignmentLog(GVar); @@ -218,38 +217,47 @@ void AlphaAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) { TM)); // 1: Check visibility - printVisibility(name, GVar->getVisibility()); + printVisibility(GVarSym, GVar->getVisibility()); // 2: Kind switch (GVar->getLinkage()) { - case GlobalValue::LinkOnceAnyLinkage: - case GlobalValue::LinkOnceODRLinkage: - case GlobalValue::WeakAnyLinkage: - case GlobalValue::WeakODRLinkage: - case GlobalValue::CommonLinkage: - O << MAI->getWeakRefDirective() << name << '\n'; + case GlobalValue::LinkOnceAnyLinkage: + case GlobalValue::LinkOnceODRLinkage: + case GlobalValue::WeakAnyLinkage: + case GlobalValue::WeakODRLinkage: + case GlobalValue::CommonLinkage: + O << MAI->getWeakRefDirective(); + GVarSym->print(O, MAI); + O << '\n'; break; - case GlobalValue::AppendingLinkage: - case GlobalValue::ExternalLinkage: - O << MAI->getGlobalDirective() << name << "\n"; - break; - case GlobalValue::InternalLinkage: - case GlobalValue::PrivateLinkage: - case GlobalValue::LinkerPrivateLinkage: - break; - default: - llvm_unreachable("Unknown linkage type!"); - } + case GlobalValue::AppendingLinkage: + case GlobalValue::ExternalLinkage: + O << MAI->getGlobalDirective(); + GVarSym->print(O, MAI); + O << '\n'; + break; + case GlobalValue::InternalLinkage: + case GlobalValue::PrivateLinkage: + case GlobalValue::LinkerPrivateLinkage: + break; + default: + llvm_unreachable("Unknown linkage type!"); + } // 3: Type, Size, Align if (MAI->hasDotTypeDotSizeDirective()) { - O << "\t.type\t" << name << ", @object\n"; - O << "\t.size\t" << name << ", " << Size << "\n"; + O << "\t.type\t"; + GVarSym->print(O, MAI); + O << ", @object\n"; + O << "\t.size\t"; + GVarSym->print(O, MAI); + O << ", " << Size << "\n"; } EmitAlignment(Align, GVar); - - O << name << ":\n"; + + GVarSym->print(O, MAI); + O << ":\n"; EmitGlobalConstant(C); O << '\n'; diff --git a/lib/Target/Blackfin/AsmPrinter/BlackfinAsmPrinter.cpp b/lib/Target/Blackfin/AsmPrinter/BlackfinAsmPrinter.cpp index 09f8b02..7fdf1e7 100644 --- a/lib/Target/Blackfin/AsmPrinter/BlackfinAsmPrinter.cpp +++ b/lib/Target/Blackfin/AsmPrinter/BlackfinAsmPrinter.cpp @@ -30,7 +30,6 @@ #include "llvm/Target/TargetData.h" #include "llvm/Target/TargetLoweringObjectFile.h" #include "llvm/Target/TargetRegistry.h" -#include "llvm/Support/Mangler.h" #include "llvm/ADT/Statistic.h" #include "llvm/ADT/SmallString.h" #include "llvm/Support/ErrorHandling.h" @@ -55,7 +54,7 @@ namespace { void printInstruction(const MachineInstr *MI); // autogenerated. static const char *getRegisterName(unsigned RegNo); - void emitLinkage(const std::string &n, GlobalValue::LinkageTypes l); + void emitLinkage(const MCSymbol *GVSym, GlobalValue::LinkageTypes l); bool runOnMachineFunction(MachineFunction &F); bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, unsigned AsmVariant, const char *ExtraCode); @@ -71,23 +70,29 @@ extern "C" void LLVMInitializeBlackfinAsmPrinter() { RegisterAsmPrinter<BlackfinAsmPrinter> X(TheBlackfinTarget); } -void BlackfinAsmPrinter::emitLinkage(const std::string &name, - GlobalValue::LinkageTypes l) { - switch (l) { +void BlackfinAsmPrinter::emitLinkage(const MCSymbol *GVSym, + GlobalValue::LinkageTypes L) { + switch (L) { default: llvm_unreachable("Unknown linkage type!"); case GlobalValue::InternalLinkage: // Symbols default to internal. case GlobalValue::PrivateLinkage: case GlobalValue::LinkerPrivateLinkage: break; case GlobalValue::ExternalLinkage: - O << MAI->getGlobalDirective() << name << "\n"; + O << MAI->getGlobalDirective(); + GVSym->print(O, MAI); + O << "\n"; break; case GlobalValue::LinkOnceAnyLinkage: case GlobalValue::LinkOnceODRLinkage: case GlobalValue::WeakAnyLinkage: case GlobalValue::WeakODRLinkage: - O << MAI->getGlobalDirective() << name << "\n"; - O << MAI->getWeakDefDirective() << name << "\n"; + O << MAI->getGlobalDirective(); + GVSym->print(O, MAI); + O << "\n"; + O << MAI->getWeakDefDirective(); + GVSym->print(O, MAI); + O << "\n"; break; } } @@ -98,18 +103,24 @@ void BlackfinAsmPrinter::PrintGlobalVariable(const GlobalVariable* GV) { if (!GV->hasInitializer() || EmitSpecialLLVMGlobal(GV)) return; - std::string name = Mang->getMangledName(GV); + MCSymbol *GVSym = GetGlobalValueSymbol(GV); Constant *C = GV->getInitializer(); OutStreamer.SwitchSection(getObjFileLowering().SectionForGlobal(GV, Mang, TM)); - emitLinkage(name, GV->getLinkage()); + emitLinkage(GVSym, GV->getLinkage()); EmitAlignment(TD->getPreferredAlignmentLog(GV), GV); - printVisibility(name, GV->getVisibility()); - - O << "\t.type " << name << ", STT_OBJECT\n"; - O << "\t.size " << name << ',' << TD->getTypeAllocSize(C->getType()) << '\n'; - O << name << ":\n"; + printVisibility(GVSym, GV->getVisibility()); + + O << "\t.type "; + GVSym->print(O, MAI); + O << ", STT_OBJECT\n"; + O << "\t.size "; + GVSym->print(O, MAI); + O << "\n"; + O << ',' << TD->getTypeAllocSize(C->getType()) << '\n'; + GVSym->print(O, MAI); + O << ":\n"; EmitGlobalConstant(C); } @@ -124,11 +135,14 @@ bool BlackfinAsmPrinter::runOnMachineFunction(MachineFunction &MF) { const Function *F = MF.getFunction(); OutStreamer.SwitchSection(getObjFileLowering().SectionForGlobal(F, Mang, TM)); EmitAlignment(2, F); - emitLinkage(CurrentFnName, F->getLinkage()); - printVisibility(CurrentFnName, F->getVisibility()); + emitLinkage(CurrentFnSym, F->getLinkage()); + printVisibility(CurrentFnSym, F->getVisibility()); - O << "\t.type\t" << CurrentFnName << ", STT_FUNC\n" - << CurrentFnName << ":\n"; + O << "\t.type\t"; + CurrentFnSym->print(O, MAI); + O << ", STT_FUNC\n"; + CurrentFnSym->print(O, MAI); + O << ":\n"; if (DW) DW->BeginFunction(&MF); @@ -154,7 +168,11 @@ bool BlackfinAsmPrinter::runOnMachineFunction(MachineFunction &MF) { } } - O << "\t.size " << CurrentFnName << ", .-" << CurrentFnName << "\n"; + O << "\t.size "; + CurrentFnSym->print(O, MAI); + O << ", .-"; + CurrentFnSym->print(O, MAI); + O << "\n"; if (DW) DW->EndFunction(&MF); @@ -178,7 +196,7 @@ void BlackfinAsmPrinter::printOperand(const MachineInstr *MI, int opNum) { GetMBBSymbol(MO.getMBB()->getNumber())->print(O, MAI); return; case MachineOperand::MO_GlobalAddress: - O << Mang->getMangledName(MO.getGlobal()); + GetGlobalValueSymbol(MO.getGlobal())->print(O, MAI); printOffset(MO.getOffset()); break; case MachineOperand::MO_ExternalSymbol: diff --git a/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp b/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp index dc9f81c..6981fef 100644 --- a/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp +++ b/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp @@ -437,18 +437,27 @@ bool LinuxAsmPrinter::runOnMachineFunction(MachineFunction &MF) { case Function::InternalLinkage: // Symbols default to internal. break; case Function::ExternalLinkage: - O << "\t.global\t" << CurrentFnName << "\n" - << "\t.type\t" << CurrentFnName << ", @function\n"; + O << "\t.global\t"; + CurrentFnSym->print(O, MAI); + O << "\n" << "\t.type\t"; + CurrentFnSym->print(O, MAI); + O << ", @function\n"; break; case Function::WeakAnyLinkage: case Function::WeakODRLinkage: case Function::LinkOnceAnyLinkage: case Function::LinkOnceODRLinkage: - O << "\t.global\t" << CurrentFnName << "\n"; - O << "\t.weak_definition\t" << CurrentFnName << "\n"; + O << "\t.global\t"; + CurrentFnSym->print(O, MAI); + O << "\n"; + O << "\t.weak_definition\t"; + CurrentFnSym->print(O, MAI); + O << "\n"; break; } - O << CurrentFnName << ":\n"; + + CurrentFnSym->print(O, MAI); + O << ":\n"; // Emit pre-function debug information. DW->BeginFunction(&MF); @@ -467,7 +476,11 @@ bool LinuxAsmPrinter::runOnMachineFunction(MachineFunction &MF) { } } - O << "\t.size\t" << CurrentFnName << ",.-" << CurrentFnName << "\n"; + O << "\t.size\t"; + CurrentFnSym->print(O, MAI); + O << ",.-"; + CurrentFnSym->print(O, MAI); + O << "\n"; // Print out jump tables referenced by the function. EmitJumpTableInfo(MF.getJumpTableInfo(), MF); |