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
diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 2cb4d01..0d6a2e2 100644
--- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -125,14 +125,12 @@
   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 @@
     }
 }
 
+/// 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
 //