supplement CurrentFnName with CurrentFnSym, which will eventually
authorChris Lattner <sabre@nondot.org>
Fri, 15 Jan 2010 23:55:16 +0000 (23:55 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 15 Jan 2010 23:55:16 +0000 (23:55 +0000)
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

include/llvm/CodeGen/AsmPrinter.h
lib/CodeGen/AsmPrinter/AsmPrinter.cpp
lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp
lib/Target/Blackfin/AsmPrinter/BlackfinAsmPrinter.cpp
lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp

index 28f3e8bfa053fefee0ebb4d33837aff8bfa168d2..0ebb4b1ba16fbfb86ed034b7988cb1a2c715ded5 100644 (file)
@@ -134,7 +134,8 @@ namespace llvm {
     /// Cache of mangled name for current function. This is recalculated at the
     /// beginning of each call to runOnMachineFunction().
     ///
-    std::string CurrentFnName;
+    std::string CurrentFnName;  // FIXME: REMOVE.
+    const MCSymbol *CurrentFnSym;
     
     /// getCurrentSection() - Return the current section we are emitting to.
     const MCSection *getCurrentSection() const;
index 7293ec0ba9e6285f6c37c41835b4e69a27ac34d3..16eec0c44a35b5998ebf301712a90a4f2818c833 100644 (file)
@@ -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)
index 338057b453158bec4aa49cf8e8433726b4ae3be9..235b16da0633a5a87cbef823f27cdaa72612ab4b 100644 (file)
@@ -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';
index 09f8b0250a9d586d220553835e134bcf3e7851de..7fdf1e713c42ef6ffb1815638560f6bd7fad1f83 100644 (file)
@@ -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:
index dc9f81c488a14c0edba4817afd9299635c5fb407..6981fef3446e2e195411e441a4b695f7be698070 100644 (file)
@@ -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);