Add new option to leave asm names alone
authorChris Lattner <sabre@nondot.org>
Thu, 7 Sep 2006 18:20:41 +0000 (18:20 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 7 Sep 2006 18:20:41 +0000 (18:20 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30149 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Support/Mangler.h
lib/VMCore/Mangler.cpp

index ac7deadf8bdca26723187ff1be65e2f4f2296d0a..b6f9839fab2ef9a9f035cd552ddd441bc91b74cd 100644 (file)
@@ -35,6 +35,10 @@ class Mangler {
   /// the space character.  By default, this is false.
   bool UseQuotes;
   
+  /// PreserveAsmNames - If this is set, the asm escape character is not removed
+  /// from names with 'asm' specifiers. 
+  bool PreserveAsmNames;
+  
   /// Memo - This is used to remember the name that we assign a value.
   ///
   std::map<const Value*, std::string> Memo;
@@ -66,6 +70,10 @@ public:
   /// strings for assembler labels.
   void setUseQuotes(bool Val) { UseQuotes = Val; }
   
+  /// setPreserveAsmNames - If the mangler should not strip off the asm name
+  /// identifier (\001), this should be set.
+  void setPreserveAsmNames(bool Val) { PreserveAsmNames = Val; }
+  
   /// Acceptable Characters - This allows the target to specify which characters
   /// are acceptable to the assembler without being mangled.  By default we
   /// allow letters, numbers, '_', '$', and '.', which is what GAS accepts.
index 53719aff2cc1405a5461269adc461cfbf1a4f7b5..8715498b9cd54acd87afd28b4bab947ce7e16665 100644 (file)
@@ -33,6 +33,10 @@ std::string Mangler::makeNameProper(const std::string &X, const char *Prefix) {
   std::string Result;
   if (X.empty()) return X;  // Empty names are uniqued by the caller.
   
+  // If PreserveAsmNames is set, names with asm identifiers are not modified. 
+  if (PreserveAsmNames && X[0] == 1)
+    return X;
+  
   if (!UseQuotes) {
     // If X does not start with (char)1, add the prefix.
     std::string::const_iterator I = X.begin();
@@ -174,7 +178,8 @@ void Mangler::InsertName(GlobalValue *GV,
 
 
 Mangler::Mangler(Module &M, const char *prefix)
-  : Prefix(prefix), UseQuotes(false), Count(0), TypeCounter(0) {
+  : Prefix(prefix), UseQuotes(false), PreserveAsmNames(false),
+    Count(0), TypeCounter(0) {
   std::fill(AcceptableChars, 
           AcceptableChars+sizeof(AcceptableChars)/sizeof(AcceptableChars[0]),
             0);