aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-04-03 21:35:55 +0000
committerChris Lattner <sabre@nondot.org>2010-04-03 21:35:55 +0000
commit91bead790518fcf5cb26019fb1ebf2372e8a5b3f (patch)
tree069591723216e18906bac6c3117502c73a56bf0b /lib/CodeGen
parent47b7e5dae911bc98aa76fa5d2ee506c9304f941a (diff)
add a new EmitInlineAsm function to asmprinter to handle inline asm.
If we have an MCAsmStreamer, we continue to emit asm textually, otherwise we (currently) emit an error to errs and ignore it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100289 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/AsmPrinter/AsmPrinter.cpp24
1 files changed, 19 insertions, 5 deletions
diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 2cb4d01574..0d6a2e2999 100644
--- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -125,14 +125,12 @@ bool AsmPrinter::doInitialization(Module &M) {
for (GCModuleInfo::iterator I = MI->begin(), E = MI->end(); I != E; ++I)
if (GCMetadataPrinter *MP = GetOrCreateGCPrinter(*I))
MP->beginAssembly(O, *this, *MAI);
-
+
+ // Emit module-level inline asm if it exists.
if (!M.getModuleInlineAsm().empty()) {
OutStreamer.AddComment("Start of file scope inline assembly");
OutStreamer.AddBlankLine();
- O << M.getModuleInlineAsm();
-
- if (*M.getModuleInlineAsm().rbegin() != '\n')
- OutStreamer.AddBlankLine();
+ EmitInlineAsm(M.getModuleInlineAsm());
OutStreamer.AddComment("End of file scope inline assembly");
OutStreamer.AddBlankLine();
}
@@ -879,6 +877,22 @@ void AsmPrinter::EmitXXStructorList(Constant *List) {
}
}
+/// EmitInlineAsm - Emit a blob of inline asm to the output streamer.
+void AsmPrinter::EmitInlineAsm(StringRef Str) {
+ assert(!Str.empty() && "Can't emit empty inline asm block");
+
+ // If the output streamer is actually a .s file, just emit the blob textually.
+ // This is useful in case the asm parser doesn't handle something but the
+ // system assembler does.
+ if (OutStreamer.hasRawTextSupport()) {
+ OutStreamer.EmitRawText(Str);
+ return;
+ }
+
+ errs() << "Inline asm not supported by this streamer!\n";
+}
+
+
//===--------------------------------------------------------------------===//
// Emission and print routines
//