aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-01-24 00:45:30 +0000
committerChris Lattner <sabre@nondot.org>2006-01-24 00:45:30 +0000
commit42a162ed8023088e7a4a7d81325381bd8d437bb7 (patch)
tree371478dab8db29c65732b6a9d21a05974a86c639
parent71cdba31774ce18ed32e89f1c6f7716ab923aa46 (diff)
downloadexternal_llvm-42a162ed8023088e7a4a7d81325381bd8d437bb7.tar.gz
external_llvm-42a162ed8023088e7a4a7d81325381bd8d437bb7.tar.bz2
external_llvm-42a162ed8023088e7a4a7d81325381bd8d437bb7.zip
Pretty print file-scope asm blocks.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25568 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/VMCore/AsmWriter.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp
index d66497aed6..d0b8478f24 100644
--- a/lib/VMCore/AsmWriter.cpp
+++ b/lib/VMCore/AsmWriter.cpp
@@ -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";
}