[llvm-commits] [llvm] r93608 - in /llvm/trunk/lib/Target: PowerPC/AsmPrinter/PPCAsmPrinter.cpp Sparc/AsmPrinter/SparcAsmPrinter.cpp SystemZ/AsmPrinter/SystemZAsmPrinter.cpp

Chris Lattner sabre at nondot.org
Fri Jan 15 17:12:02 PST 2010


Author: lattner
Date: Fri Jan 15 19:12:01 2010
New Revision: 93608

URL: http://llvm.org/viewvc/llvm-project?rev=93608&view=rev
Log:
switch more stuff onto MCSymbols

Modified:
    llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp
    llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp
    llvm/trunk/lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp

Modified: llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp?rev=93608&r1=93607&r2=93608&view=diff

==============================================================================
--- llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp Fri Jan 15 19:12:01 2010
@@ -729,9 +729,9 @@
   if (EmitSpecialLLVMGlobal(GVar))
     return;
 
-  std::string name = Mang->getMangledName(GVar);
+  MCSymbol *GVarSym = GetGlobalValueSymbol(GVar);
 
-  printVisibility(name, GVar->getVisibility());
+  printVisibility(GVarSym, GVar->getVisibility());
 
   Constant *C = GVar->getInitializer();
   const Type *Type = C->getType();
@@ -748,14 +748,23 @@
       if (Size == 0) Size = 1;   // .comm Foo, 0 is undefined, avoid it.
 
       if (GVar->hasExternalLinkage()) {
-        O << "\t.global " << name << '\n';
-        O << "\t.type " << name << ", @object\n";
-        O << name << ":\n";
+        O << "\t.global ";
+        GVarSym->print(O, MAI);
+        O << '\n';
+        O << "\t.type ";
+        GVarSym->print(O, MAI);
+        O << ", @object\n";
+        GVarSym->print(O, MAI);
+        O  << ":\n";
         O << "\t.zero " << Size << '\n';
       } else if (GVar->hasLocalLinkage()) {
-        O << MAI->getLCOMMDirective() << name << ',' << Size;
+        O << MAI->getLCOMMDirective();
+        GVarSym->print(O, MAI);
+        O << ',' << Size;
       } else {
-        O << ".comm " << name << ',' << Size;
+        O << ".comm ";
+        GVarSym->print(O, MAI);
+        O  << ',' << Size;
       }
       if (VerboseAsm) {
         O << "\t\t" << MAI->getCommentString() << " '";
@@ -773,17 +782,24 @@
    case GlobalValue::WeakODRLinkage:
    case GlobalValue::CommonLinkage:
    case GlobalValue::LinkerPrivateLinkage:
-    O << "\t.global " << name << '\n'
-      << "\t.type " << name << ", @object\n"
-      << "\t.weak " << name << '\n';
+    O << "\t.global ";
+    GVarSym->print(O, MAI);
+    O << "\n\t.type ";
+    GVarSym->print(O, MAI);
+    O << ", @object\n\t.weak ";
+    GVarSym->print(O, MAI);
+    O << '\n';
     break;
    case GlobalValue::AppendingLinkage:
     // FIXME: appending linkage variables should go into a section of
     // their name or something.  For now, just emit them as external.
    case GlobalValue::ExternalLinkage:
     // If external or appending, declare as a global symbol
-    O << "\t.global " << name << '\n'
-      << "\t.type " << name << ", @object\n";
+    O << "\t.global ";
+    GVarSym->print(O, MAI);
+    O << "\n\t.type ";
+    GVarSym->print(O, MAI);
+    O << ", @object\n";
     // FALL THROUGH
    case GlobalValue::InternalLinkage:
    case GlobalValue::PrivateLinkage:
@@ -793,7 +809,8 @@
   }
 
   EmitAlignment(Align, GVar);
-  O << name << ":";
+  GVarSym->print(O, MAI);
+  O << ":";
   if (VerboseAsm) {
     O << "\t\t\t\t" << MAI->getCommentString() << " '";
     WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
@@ -967,8 +984,8 @@
     return;
   }
 
-  std::string name = Mang->getMangledName(GVar);
-  printVisibility(name, GVar->getVisibility());
+  MCSymbol *GVarSym = GetGlobalValueSymbol(GVar);
+  printVisibility(GVarSym, GVar->getVisibility());
 
   Constant *C = GVar->getInitializer();
   const Type *Type = C->getType();
@@ -989,16 +1006,25 @@
     if (Size == 0) Size = 1;   // .comm Foo, 0 is undefined, avoid it.
 
     if (GVar->hasExternalLinkage()) {
-      O << "\t.globl " << name << '\n';
-      O << "\t.zerofill __DATA, __common, " << name << ", "
-        << Size << ", " << Align;
+      O << "\t.globl ";
+      GVarSym->print(O, MAI);
+      O << '\n';
+      O << "\t.zerofill __DATA, __common, ";
+      GVarSym->print(O, MAI);
+      O << ", " << Size << ", " << Align;
     } else if (GVar->hasLocalLinkage()) {
-      O << MAI->getLCOMMDirective() << name << ',' << Size << ',' << Align;
+      O << MAI->getLCOMMDirective();
+      GVarSym->print(O, MAI);
+      O << ',' << Size << ',' << Align;
     } else if (!GVar->hasCommonLinkage()) {
-      O << "\t.globl " << name << '\n'
-        << MAI->getWeakDefDirective() << name << '\n';
+      O << "\t.globl ";
+      GVarSym->print(O, MAI);
+      O << '\n' << MAI->getWeakDefDirective();
+      GVarSym->print(O, MAI);
+      O << '\n';
       EmitAlignment(Align, GVar);
-      O << name << ":";
+      GVarSym->print(O, MAI);
+      O << ":";
       if (VerboseAsm) {
         O << "\t\t\t\t" << MAI->getCommentString() << " ";
         WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
@@ -1007,7 +1033,9 @@
       EmitGlobalConstant(C);
       return;
     } else {
-      O << ".comm " << name << ',' << Size;
+      O << ".comm ";
+      GVarSym->print(O, MAI);
+      O << ',' << Size;
       // Darwin 9 and above support aligned common data.
       if (Subtarget.isDarwin9())
         O << ',' << Align;
@@ -1022,31 +1050,37 @@
   }
 
   switch (GVar->getLinkage()) {
-   case GlobalValue::LinkOnceAnyLinkage:
-   case GlobalValue::LinkOnceODRLinkage:
-   case GlobalValue::WeakAnyLinkage:
-   case GlobalValue::WeakODRLinkage:
-   case GlobalValue::CommonLinkage:
-   case GlobalValue::LinkerPrivateLinkage:
-    O << "\t.globl " << name << '\n'
-      << "\t.weak_definition " << name << '\n';
+  case GlobalValue::LinkOnceAnyLinkage:
+  case GlobalValue::LinkOnceODRLinkage:
+  case GlobalValue::WeakAnyLinkage:
+  case GlobalValue::WeakODRLinkage:
+  case GlobalValue::CommonLinkage:
+  case GlobalValue::LinkerPrivateLinkage:
+    O << "\t.globl ";
+    GVarSym->print(O, MAI);
+    O << "\n\t.weak_definition ";
+    GVarSym->print(O, MAI);
+    O << '\n';
     break;
-   case GlobalValue::AppendingLinkage:
+  case GlobalValue::AppendingLinkage:
     // FIXME: appending linkage variables should go into a section of
     // their name or something.  For now, just emit them as external.
-   case GlobalValue::ExternalLinkage:
+  case GlobalValue::ExternalLinkage:
     // If external or appending, declare as a global symbol
-    O << "\t.globl " << name << '\n';
+    O << "\t.globl ";
+    GVarSym->print(O, MAI);
+    O << '\n';
     // FALL THROUGH
-   case GlobalValue::InternalLinkage:
-   case GlobalValue::PrivateLinkage:
+  case GlobalValue::InternalLinkage:
+  case GlobalValue::PrivateLinkage:
     break;
-   default:
+  default:
     llvm_unreachable("Unknown linkage type!");
   }
 
   EmitAlignment(Align, GVar);
-  O << name << ":";
+  GVarSym->print(O, MAI);
+  O << ":";
   if (VerboseAsm) {
     O << "\t\t\t\t" << MAI->getCommentString() << " '";
     WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());

Modified: llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp?rev=93608&r1=93607&r2=93608&view=diff

==============================================================================
--- llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp Fri Jan 15 19:12:01 2010
@@ -34,7 +34,6 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FormattedStream.h"
-#include "llvm/Support/Mangler.h"
 #include "llvm/Support/MathExtras.h"
 #include <cctype>
 #include <cstring>
@@ -299,12 +298,12 @@
     return;
 
   O << "\n\n";
-  std::string name = Mang->getMangledName(GVar);
+  MCSymbol *GVarSym = GetGlobalValueSymbol(GVar);
   Constant *C = GVar->getInitializer();
   unsigned Size = TD->getTypeAllocSize(C->getType());
   unsigned Align = TD->getPreferredAlignment(GVar);
 
-  printVisibility(name, GVar->getVisibility());
+  printVisibility(GVarSym, GVar->getVisibility());
 
   OutStreamer.SwitchSection(getObjFileLowering().SectionForGlobal(GVar, Mang,
                                                                   TM));
@@ -314,10 +313,15 @@
         (GVar->hasLocalLinkage() || GVar->isWeakForLinker())) {
       if (Size == 0) Size = 1;   // .comm Foo, 0 is undefined, avoid it.
 
-      if (GVar->hasLocalLinkage())
-        O << "\t.local " << name << '\n';
-
-      O << MAI->getCOMMDirective() << name << ',' << Size;
+      if (GVar->hasLocalLinkage()) {
+        O << "\t.local ";
+        GVarSym->print(O, MAI);
+        O << '\n';
+      }
+
+      O << MAI->getCOMMDirective();
+      GVarSym->print(O, MAI);
+      O << ',' << Size;
       if (MAI->getCOMMDirectiveTakesAlignment())
         O << ',' << (1 << Align);
 
@@ -333,14 +337,18 @@
    case GlobalValue::WeakAnyLinkage: // FIXME: Verify correct for weak.
    case GlobalValue::WeakODRLinkage: // FIXME: Verify correct for weak.
     // Nonnull linkonce -> weak
-    O << "\t.weak " << name << '\n';
+    O << "\t.weak ";
+    GVarSym->print(O, MAI);
+    O << '\n';
     break;
    case GlobalValue::AppendingLinkage:
     // FIXME: appending linkage variables should go into a section of
     // their name or something.  For now, just emit them as external.
    case GlobalValue::ExternalLinkage:
     // If external or appending, declare as a global symbol
-    O << MAI->getGlobalDirective() << name << '\n';
+    O << MAI->getGlobalDirective();
+    GVarSym->print(O, MAI);
+    O << '\n';
     // FALL THROUGH
    case GlobalValue::PrivateLinkage:
    case GlobalValue::LinkerPrivateLinkage:
@@ -359,11 +367,16 @@
   EmitAlignment(Align, GVar);
 
   if (MAI->hasDotTypeDotSizeDirective()) {
-    O << "\t.type " << name << ",#object\n";
-    O << "\t.size " << name << ',' << Size << '\n';
+    O << "\t.type ";
+    GVarSym->print(O, MAI);
+    O << ",#object\n";
+    O << "\t.size ";
+    GVarSym->print(O, MAI);
+    O << ',' << Size << '\n';
   }
 
-  O << name << ":\n";
+  GVarSym->print(O, MAI);
+  O  << ":\n";
   EmitGlobalConstant(C);
 }
 

Modified: llvm/trunk/lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp?rev=93608&r1=93607&r2=93608&view=diff

==============================================================================
--- llvm/trunk/lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp Fri Jan 15 19:12:01 2010
@@ -36,7 +36,6 @@
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FormattedStream.h"
 #include "llvm/Support/Mangler.h"
-
 using namespace llvm;
 
 STATISTIC(EmittedInsts, "Number of machine instrs printed");
@@ -326,14 +325,16 @@
   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 = std::max(1U, TD->getPreferredAlignmentLog(GVar));
 
-  printVisibility(name, GVar->getVisibility());
+  printVisibility(GVarSym, GVar->getVisibility());
 
-  O << "\t.type\t" << name << ", at object\n";
+  O << "\t.type\t";
+  GVarSym->print(O, MAI);
+  O << ", at object\n";
 
   OutStreamer.SwitchSection(getObjFileLowering().SectionForGlobal(GVar, Mang,
                                                                   TM));
@@ -344,10 +345,15 @@
 
     if (Size == 0) Size = 1;   // .comm Foo, 0 is undefined, avoid it.
 
-    if (GVar->hasLocalLinkage())
-      O << "\t.local\t" << name << '\n';
+    if (GVar->hasLocalLinkage()) {
+      O << "\t.local\t";
+      GVarSym->print(O, MAI);
+      O << '\n';
+    }
 
-    O << MAI->getCOMMDirective()  << name << ',' << Size;
+    O << MAI->getCOMMDirective();
+    GVarSym->print(O, MAI);
+    O << ',' << Size;
     if (MAI->getCOMMDirectiveTakesAlignment())
       O << ',' << (MAI->getAlignmentIsInBytes() ? (1 << Align) : Align);
 
@@ -365,7 +371,9 @@
   case GlobalValue::LinkOnceODRLinkage:
   case GlobalValue::WeakAnyLinkage:
   case GlobalValue::WeakODRLinkage:
-    O << "\t.weak\t" << name << '\n';
+    O << "\t.weak\t";
+    GVarSym->print(O, MAI);
+    O << '\n';
     break;
   case GlobalValue::DLLExportLinkage:
   case GlobalValue::AppendingLinkage:
@@ -373,7 +381,9 @@
     // their name or something.  For now, just emit them as external.
   case GlobalValue::ExternalLinkage:
     // If external or appending, declare as a global symbol
-    O << "\t.globl " << name << '\n';
+    O << "\t.globl ";
+    GVarSym->print(O, MAI);
+    O << '\n';
     // FALL THROUGH
   case GlobalValue::PrivateLinkage:
   case GlobalValue::LinkerPrivateLinkage:
@@ -385,14 +395,18 @@
 
   // Use 16-bit alignment by default to simplify bunch of stuff
   EmitAlignment(Align, GVar, 1);
-  O << name << ":";
+  GVarSym->print(O, MAI);
+  O << ":";
   if (VerboseAsm) {
     O << "\t\t\t\t" << MAI->getCommentString() << ' ';
     WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
   }
   O << '\n';
-  if (MAI->hasDotTypeDotSizeDirective())
-    O << "\t.size\t" << name << ", " << Size << '\n';
+  if (MAI->hasDotTypeDotSizeDirective()) {
+    O << "\t.size\t";
+    GVarSym->print(O, MAI);
+    O << ", " << Size << '\n';
+  }
 
   EmitGlobalConstant(C);
 }





More information about the llvm-commits mailing list