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
This commit is contained in:
Chris Lattner
2010-04-03 21:35:55 +00:00
parent 47b7e5dae9
commit 91bead7905
5 changed files with 64 additions and 9 deletions

View File

@@ -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
//