[llvm-commits] CVS: llvm/lib/CodeGen/AsmPrinter.cpp

Chris Lattner sabre at nondot.org
Tue Oct 3 16:27:23 PDT 2006



Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.102 -> 1.103
---
Log message:

Use $( $| $) to represent alternatives in asm blocks instead of {|}.  This
is needed to support targets where {|} aren't special symbols.


---
Diffs of the changes:  (+34 -28)

 AsmPrinter.cpp |   62 +++++++++++++++++++++++++++++++--------------------------
 1 files changed, 34 insertions(+), 28 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.102 llvm/lib/CodeGen/AsmPrinter.cpp:1.103
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.102	Thu Sep 28 18:17:41 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp	Tue Oct  3 18:27:09 2006
@@ -694,12 +694,45 @@
       break;
     case '$': {
       ++LastEmitted;   // Consume '$' character.
-      if (*LastEmitted == '$') { // $$ -> $
+      bool Done = true;
+
+      // Handle escapes.
+      switch (*LastEmitted) {
+      default: Done = false; break;
+      case '$':     // $$ -> $
         if (CurVariant == -1 || CurVariant == AsmPrinterVariant)
           O << '$';
         ++LastEmitted;  // Consume second '$' character.
         break;
+      case '(':             // $( -> same as GCC's { character.
+        ++LastEmitted;      // Consume '(' character.
+        if (CurVariant != -1) {
+          std::cerr << "Nested variants found in inline asm string: '"
+          << AsmStr << "'\n";
+          exit(1);
+        }
+        CurVariant = 0;     // We're in the first variant now.
+        break;
+      case '|':
+        ++LastEmitted;  // consume '|' character.
+        if (CurVariant == -1) {
+          std::cerr << "Found '|' character outside of variant in inline asm "
+          << "string: '" << AsmStr << "'\n";
+          exit(1);
+        }
+        ++CurVariant;   // We're in the next variant.
+        break;
+      case ')':         // $) -> same as GCC's } char.
+        ++LastEmitted;  // consume ')' character.
+        if (CurVariant == -1) {
+          std::cerr << "Found '}' character outside of variant in inline asm "
+                    << "string: '" << AsmStr << "'\n";
+          exit(1);
+        }
+        CurVariant = -1;
+        break;
       }
+      if (Done) break;
       
       bool HasCurlyBraces = false;
       if (*LastEmitted == '{') {     // ${variable}
@@ -786,33 +819,6 @@
       }
       break;
     }
-    case '{':
-      ++LastEmitted;      // Consume '{' character.
-      if (CurVariant != -1) {
-        std::cerr << "Nested variants found in inline asm string: '"
-                  << AsmStr << "'\n";
-        exit(1);
-      }
-      CurVariant = 0;     // We're in the first variant now.
-      break;
-    case '|':
-      ++LastEmitted;  // consume '|' character.
-      if (CurVariant == -1) {
-        std::cerr << "Found '|' character outside of variant in inline asm "
-                  << "string: '" << AsmStr << "'\n";
-        exit(1);
-      }
-      ++CurVariant;   // We're in the next variant.
-      break;
-    case '}':
-      ++LastEmitted;  // consume '}' character.
-      if (CurVariant == -1) {
-        std::cerr << "Found '}' character outside of variant in inline asm "
-                  << "string: '" << AsmStr << "'\n";
-        exit(1);
-      }
-      CurVariant = -1;
-      break;
     }
   }
   O << "\n\t" << TAI->getInlineAsmEnd() << "\n";






More information about the llvm-commits mailing list