[llvm-commits] [llvm] r100492 - in /llvm/trunk: include/llvm/MC/MCParser/AsmParser.h lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp lib/MC/MCParser/AsmParser.cpp

Chris Lattner sabre at nondot.org
Mon Apr 5 16:15:42 PDT 2010


Author: lattner
Date: Mon Apr  5 18:15:42 2010
New Revision: 100492

URL: http://llvm.org/viewvc/llvm-project?rev=100492&view=rev
Log:
Give AsmParser an option to control whether it finalizes
the stream.  New demo:

$ clang asm.c -S -o - -emit-llvm | llc -filetype=obj -o t.o
$ otool -tv t.o
t.o:
(__TEXT,__text) section
_foo:
0000000000000000	subq	$0x08,%rsp
0000000000000004	movl	%edi,(%rsp)
0000000000000007	movl	%edi,%eax
0000000000000009	incl	%eax
000000000000000b	movl	%eax,(%rsp)
000000000000000e	movl	%eax,0x04(%rsp)
0000000000000012	addq	$0x08,%rsp
0000000000000016	ret


Modified:
    llvm/trunk/include/llvm/MC/MCParser/AsmParser.h
    llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
    llvm/trunk/lib/MC/MCParser/AsmParser.cpp

Modified: llvm/trunk/include/llvm/MC/MCParser/AsmParser.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCParser/AsmParser.h?rev=100492&r1=100491&r2=100492&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCParser/AsmParser.h (original)
+++ llvm/trunk/include/llvm/MC/MCParser/AsmParser.h Mon Apr  5 18:15:42 2010
@@ -64,7 +64,7 @@
             const MCAsmInfo &MAI);
   ~AsmParser();
 
-  bool Run(bool NoInitialTextSection);
+  bool Run(bool NoInitialTextSection, bool NoFinalize = false);
 
   
   void AddDirectiveHandler(StringRef Directive,

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp?rev=100492&r1=100491&r2=100492&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp Mon Apr  5 18:15:42 2010
@@ -66,7 +66,8 @@
   Parser.setTargetParser(*TAP.get());
 
   // Don't implicitly switch to the text section before the asm.
-  int Res = Parser.Run(/*NoInitialTextSection*/ true);
+  int Res = Parser.Run(/*NoInitialTextSection*/ true,
+                       /*NoFinalize*/ true);
   if (Res)
     llvm_report_error("Error parsing inline asm\n");
 }

Modified: llvm/trunk/lib/MC/MCParser/AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmParser.cpp?rev=100492&r1=100491&r2=100492&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/AsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp Mon Apr  5 18:15:42 2010
@@ -138,7 +138,7 @@
   return *tok;
 }
 
-bool AsmParser::Run(bool NoInitialTextSection) {
+bool AsmParser::Run(bool NoInitialTextSection, bool NoFinalize) {
   // Create the initial section, if requested.
   //
   // FIXME: Target hook & command line option for initial section.
@@ -190,7 +190,9 @@
       TheCondState.Ignore != StartingCondState.Ignore)
     return TokError("unmatched .ifs or .elses");
   
-  if (!HadError)  
+  // Finalize the output stream if there are no errors and if the client wants
+  // us to.
+  if (!HadError && !NoFinalize)  
     Out.Finish();
 
   return HadError;





More information about the llvm-commits mailing list