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

Chris Lattner lattner at cs.uiuc.edu
Fri May 5 14:47:18 PDT 2006



Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.66 -> 1.67
---
Log message:

Indent multiline asm strings more nicely


---
Diffs of the changes:  (+9 -5)

 AsmPrinter.cpp |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.66 llvm/lib/CodeGen/AsmPrinter.cpp:1.67
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.66	Tue May  2 20:29:56 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp	Fri May  5 16:47:05 2006
@@ -34,8 +34,8 @@
   GlobalVarAddrSuffix(""),
   FunctionAddrPrefix(""),
   FunctionAddrSuffix(""),
-  InlineAsmStart("#APP\n\t"),
-  InlineAsmEnd("\t#NO_APP\n"),
+  InlineAsmStart("#APP"),
+  InlineAsmEnd("#NO_APP"),
   ZeroDirective("\t.zero\t"),
   ZeroDirectiveSuffix(0),
   AsciiDirective("\t.ascii\t"),
@@ -558,7 +558,7 @@
 /// printInlineAsm - This method formats and prints the specified machine
 /// instruction that is an inline asm.
 void AsmPrinter::printInlineAsm(const MachineInstr *MI) const {
-  O << InlineAsmStart;
+  O << InlineAsmStart << "\n\t";
   unsigned NumOperands = MI->getNumOperands();
   
   // Count the number of register definitions.
@@ -583,13 +583,17 @@
       // Not a special case, emit the string section literally.
       const char *LiteralEnd = LastEmitted+1;
       while (*LiteralEnd && *LiteralEnd != '{' && *LiteralEnd != '|' &&
-             *LiteralEnd != '}' && *LiteralEnd != '$')
+             *LiteralEnd != '}' && *LiteralEnd != '$' && *LiteralEnd != '\n')
         ++LiteralEnd;
       if (CurVariant == -1 || CurVariant == AsmPrinterVariant)
         O.write(LastEmitted, LiteralEnd-LastEmitted);
       LastEmitted = LiteralEnd;
       break;
     }
+    case '\n':
+      ++LastEmitted;   // Consume newline character.
+      O << "\n\t";     // Indent code with newline.
+      break;
     case '$': {
       ++LastEmitted;   // Consume '$' character.
       if (*LastEmitted == '$') { // $$ -> $
@@ -707,7 +711,7 @@
       break;
     }
   }
-  O << "\n" << InlineAsmEnd;
+  O << "\n\t" << InlineAsmEnd << "\n";
 }
 
 /// PrintAsmOperand - Print the specified operand of MI, an INLINEASM






More information about the llvm-commits mailing list