[llvm-commits] [llvm] r66536 - in /llvm/branches/Apple/Dib: include/llvm/CodeGen/AsmPrinter.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp test/CodeGen/Generic/inline-asm-special-strings.ll

Bill Wendling isanbard at gmail.com
Mon Mar 9 23:57:22 PDT 2009


Author: void
Date: Tue Mar 10 01:57:22 2009
New Revision: 66536

URL: http://llvm.org/viewvc/llvm-project?rev=66536&view=rev
Log:
Merge r66527 into Dib:

wire up support for emitting "special" values from inline asm
format strings with the standard ${:foo} syntax.

Added:
    llvm/branches/Apple/Dib/test/CodeGen/Generic/inline-asm-special-strings.ll
      - copied unchanged from r66527, llvm/trunk/test/CodeGen/Generic/inline-asm-special-strings.ll
Modified:
    llvm/branches/Apple/Dib/include/llvm/CodeGen/AsmPrinter.h
    llvm/branches/Apple/Dib/lib/CodeGen/AsmPrinter/AsmPrinter.cpp

Modified: llvm/branches/Apple/Dib/include/llvm/CodeGen/AsmPrinter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/include/llvm/CodeGen/AsmPrinter.h?rev=66536&r1=66535&r2=66536&view=diff

==============================================================================
--- llvm/branches/Apple/Dib/include/llvm/CodeGen/AsmPrinter.h (original)
+++ llvm/branches/Apple/Dib/include/llvm/CodeGen/AsmPrinter.h Tue Mar 10 01:57:22 2009
@@ -176,7 +176,7 @@
     /// or other bits of target-specific knowledge into the asmstrings.  The
     /// syntax used is ${:comment}.  Targets can override this to add support
     /// for their own strange codes.
-    virtual void PrintSpecial(const MachineInstr *MI, const char *Code);
+    virtual void PrintSpecial(const MachineInstr *MI, const char *Code) const;
 
     /// PrintAsmOperand - Print the specified operand of MI, an INLINEASM
     /// instruction, using the specified assembler variant.  Targets should

Modified: llvm/branches/Apple/Dib/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=66536&r1=66535&r2=66536&view=diff

==============================================================================
--- llvm/branches/Apple/Dib/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/branches/Apple/Dib/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Tue Mar 10 01:57:22 2009
@@ -1189,7 +1189,7 @@
 /// or other bits of target-specific knowledge into the asmstrings.  The
 /// syntax used is ${:comment}.  Targets can override this to add support
 /// for their own strange codes.
-void AsmPrinter::PrintSpecial(const MachineInstr *MI, const char *Code) {
+void AsmPrinter::PrintSpecial(const MachineInstr *MI, const char *Code) const {
   if (!strcmp(Code, "private")) {
     O << TAI->getPrivateGlobalPrefix();
   } else if (!strcmp(Code, "comment")) {
@@ -1311,6 +1311,25 @@
         HasCurlyBraces = true;
       }
       
+      // If we have ${:foo}, then this is not a real operand reference, it is a
+      // "magic" string reference, just like in .td files.  Arrange to call
+      // PrintSpecial.
+      if (HasCurlyBraces && *LastEmitted == ':') {
+        ++LastEmitted;
+        const char *StrStart = LastEmitted;
+        const char *StrEnd = strchr(StrStart, '}');
+        if (StrEnd == 0) {
+          cerr << "Unterminated ${:foo} operand in inline asm string: '" 
+               << AsmStr << "'\n";
+          exit(1);
+        }
+        
+        std::string Val(StrStart, StrEnd);
+        PrintSpecial(MI, Val.c_str());
+        LastEmitted = StrEnd+1;
+        break;
+      }
+            
       const char *IDStart = LastEmitted;
       char *IDEnd;
       errno = 0;





More information about the llvm-commits mailing list