[PATCH] MC: Allow targets to stop symbol name quoting

Matt Arsenault Matthew.Arsenault at amd.com
Wed Apr 22 13:43:28 PDT 2015


Add change from missing file in first patch


http://reviews.llvm.org/D9207

Files:
  include/llvm/MC/MCAsmInfo.h
  include/llvm/MC/MCSymbol.h
  lib/MC/MCAsmInfo.cpp
  lib/MC/MCContext.cpp
  lib/MC/MCSymbol.cpp

Index: include/llvm/MC/MCAsmInfo.h
===================================================================
--- include/llvm/MC/MCAsmInfo.h
+++ include/llvm/MC/MCAsmInfo.h
@@ -155,6 +155,9 @@
   /// Defaults to false.
   bool AllowAtInName;
 
+  /// If this is true, symbol names will not attempt to be quoted when printed.
+  bool NoSymbolNameQuoting;
+
   /// This is true if data region markers should be printed as
   /// ".data_region/.end_data_region" directives. If false, use "$d/$a" labels
   /// instead.
@@ -452,6 +455,7 @@
   const char *getCode64Directive() const { return Code64Directive; }
   unsigned getAssemblerDialect() const { return AssemblerDialect; }
   bool doesAllowAtInName() const { return AllowAtInName; }
+  bool noSymbolNameQuoting() const { return NoSymbolNameQuoting; }
   bool doesSupportDataRegionDirectives() const {
     return UseDataRegionDirectives;
   }
Index: include/llvm/MC/MCSymbol.h
===================================================================
--- include/llvm/MC/MCSymbol.h
+++ include/llvm/MC/MCSymbol.h
@@ -55,6 +55,10 @@
     /// "Lfoo" or ".foo".
     unsigned IsTemporary : 1;
 
+    /// True if the name should be quoted if "unacceptable" characters are used
+    /// in the name.
+    unsigned NoQuoting : 1;
+
     /// \brief True if this symbol can be redefined.
     unsigned IsRedefinable : 1;
 
@@ -64,9 +68,10 @@
   private:  // MCContext creates and uniques these.
     friend class MCExpr;
     friend class MCContext;
-    MCSymbol(StringRef name, bool isTemporary)
+    MCSymbol(StringRef name, bool isTemporary, bool noQuoting)
       : Name(name), Section(nullptr), Value(nullptr),
-        IsTemporary(isTemporary), IsRedefinable(false), IsUsed(false) {}
+        IsTemporary(isTemporary), NoQuoting(noQuoting),
+        IsRedefinable(false), IsUsed(false) {}
 
     MCSymbol(const MCSymbol&) = delete;
     void operator=(const MCSymbol&) = delete;
Index: lib/MC/MCAsmInfo.cpp
===================================================================
--- lib/MC/MCAsmInfo.cpp
+++ lib/MC/MCAsmInfo.cpp
@@ -50,6 +50,7 @@
   Code64Directive = ".code64";
   AssemblerDialect = 0;
   AllowAtInName = false;
+  NoSymbolNameQuoting = false;
   UseDataRegionDirectives = false;
   ZeroDirective = "\t.zero\t";
   AsciiDirective = "\t.ascii\t";
Index: lib/MC/MCContext.cpp
===================================================================
--- lib/MC/MCContext.cpp
+++ lib/MC/MCContext.cpp
@@ -125,7 +125,8 @@
   }
 
   auto NameIter = UsedNames.insert(std::make_pair(Name, true)).first;
-  Sym = new (*this) MCSymbol(NameIter->getKey(), /*isTemporary*/ false);
+  Sym = new (*this) MCSymbol(NameIter->getKey(), /*isTemporary*/ false,
+                             MAI->noSymbolNameQuoting());
 
   if (!OldSym)
     OldSym = Sym;
@@ -163,7 +164,8 @@
       // Ok, we found a name. Have the MCSymbol object itself refer to the copy
       // of the string that is embedded in the UsedNames entry.
       MCSymbol *Result =
-          new (*this) MCSymbol(NameEntry.first->getKey(), IsTemporary);
+        new (*this) MCSymbol(NameEntry.first->getKey(), IsTemporary,
+                             MAI->noSymbolNameQuoting());
       return Result;
     }
     assert(IsTemporary && "Cannot rename non-temporary symbols");
Index: lib/MC/MCSymbol.cpp
===================================================================
--- lib/MC/MCSymbol.cpp
+++ lib/MC/MCSymbol.cpp
@@ -51,7 +51,7 @@
   // some targets support quoting names with funny characters.  If the name
   // contains a funny character, then print it quoted.
   StringRef Name = getName();
-  if (!NameNeedsQuoting(Name)) {
+  if (NoQuoting || !NameNeedsQuoting(Name)) {
     OS << Name;
     return;
   }

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9207.24256.patch
Type: text/x-patch
Size: 3717 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150422/da980956/attachment.bin>


More information about the llvm-commits mailing list