[llvm-commits] [llvm] r81082 - /llvm/trunk/tools/opt/opt.cpp

Daniel Dunbar daniel at zuster.org
Sat Sep 5 04:34:54 PDT 2009


Author: ddunbar
Date: Sat Sep  5 06:34:53 2009
New Revision: 81082

URL: http://llvm.org/viewvc/llvm-project?rev=81082&view=rev
Log:
opt: Add -S option to print output as LLVM assembly.

Modified:
    llvm/trunk/tools/opt/opt.cpp

Modified: llvm/trunk/tools/opt/opt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/opt.cpp?rev=81082&r1=81081&r2=81082&view=diff

==============================================================================
--- llvm/trunk/tools/opt/opt.cpp (original)
+++ llvm/trunk/tools/opt/opt.cpp Sat Sep  5 06:34:53 2009
@@ -66,6 +66,10 @@
          cl::desc("Do not write result bitcode file"), cl::Hidden);
 
 static cl::opt<bool>
+OutputAssembly("S",
+         cl::desc("Write output as LLVM assembly"), cl::Hidden);
+
+static cl::opt<bool>
 NoVerify("disable-verify", cl::desc("Do not verify result module"), cl::Hidden);
 
 static cl::opt<bool>
@@ -375,8 +379,9 @@
     // If the output is set to be emitted to standard out, and standard out is a
     // console, print out a warning message and refuse to do it.  We don't
     // impress anyone by spewing tons of binary goo to a terminal.
-    if (!Force && !NoOutput && CheckBitcodeOutputToConsole(*Out, !Quiet))
-      NoOutput = true;
+    if (!Force && !NoOutput && !OutputAssembly)
+      if (CheckBitcodeOutputToConsole(*Out, !Quiet))
+        NoOutput = true;
 
     // Create a PassManager to hold and optimize the collection of passes we are
     // about to build...
@@ -495,9 +500,13 @@
     if (!NoVerify && !VerifyEach)
       Passes.add(createVerifierPass());
 
-    // Write bitcode out to disk or outs() as the last step...
-    if (!NoOutput && !AnalyzeOnly)
-      Passes.add(createBitcodeWriterPass(*Out));
+    // Write bitcode or assembly  out to disk or outs() as the last step...
+    if (!NoOutput && !AnalyzeOnly) {
+      if (OutputAssembly)
+        Passes.add(createPrintModulePass(Out));
+      else
+        Passes.add(createBitcodeWriterPass(*Out));
+    }
 
     // Now that we have all of the passes ready, run them.
     Passes.run(*M.get());





More information about the llvm-commits mailing list