Pretty print file-scope asm blocks.
authorChris Lattner <sabre@nondot.org>
Tue, 24 Jan 2006 00:45:30 +0000 (00:45 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 24 Jan 2006 00:45:30 +0000 (00:45 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25568 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/AsmWriter.cpp

index d66497aed6a73e3169d2011c24bf5a8c5df60bd5..d0b8478f24c1862b20f1e3cb5524194025b81304 100644 (file)
@@ -776,8 +776,22 @@ void AssemblyWriter::printModule(const Module *M) {
     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";
   }