[llvm-commits] CVS: llvm/lib/VMCore/AsmWriter.cpp

Chris Lattner lattner at cs.uiuc.edu
Mon Jan 23 16:45:42 PST 2006



Changes in directory llvm/lib/VMCore:

AsmWriter.cpp updated: 1.187 -> 1.188
---
Log message:

Pretty print file-scope asm blocks.


---
Diffs of the changes:  (+15 -1)

 AsmWriter.cpp |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletion(-)


Index: llvm/lib/VMCore/AsmWriter.cpp
diff -u llvm/lib/VMCore/AsmWriter.cpp:1.187 llvm/lib/VMCore/AsmWriter.cpp:1.188
--- llvm/lib/VMCore/AsmWriter.cpp:1.187	Mon Jan 23 18:37:56 2006
+++ llvm/lib/VMCore/AsmWriter.cpp	Mon Jan 23 18:45:30 2006
@@ -776,8 +776,22 @@
     Out << "target triple = \"" << M->getTargetTriple() << "\"\n";
 
   if (!M->getInlineAsm().empty()) {
+    // Split the string into lines, to make it easier to read the .ll file.
+    std::string Asm = M->getInlineAsm();
+    size_t CurPos = 0;
+    size_t NewLine = Asm.find_first_of('\n', CurPos);
+    while (NewLine != std::string::npos) {
+      // We found a newline, print the portion of the asm string from the
+      // last newline up to this newline.
+      Out << "module asm \"";
+      PrintEscapedString(std::string(Asm.begin()+CurPos, Asm.begin()+NewLine),
+                         Out);
+      Out << "\"\n";
+      CurPos = NewLine+1;
+      NewLine = Asm.find_first_of('\n', CurPos);
+    }
     Out << "module asm \"";
-    PrintEscapedString(M->getInlineAsm(), Out);
+    PrintEscapedString(std::string(Asm.begin()+CurPos, Asm.end()), Out);
     Out << "\"\n";
   }
   






More information about the llvm-commits mailing list