Give clients of MachineFunctionPrinter the ability to specify a banner and
authorBrian Gaeke <gaeke@uiuc.edu>
Fri, 30 Jan 2004 21:53:46 +0000 (21:53 +0000)
committerBrian Gaeke <gaeke@uiuc.edu>
Fri, 30 Jan 2004 21:53:46 +0000 (21:53 +0000)
choose an ostream.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11016 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/Passes.h
lib/CodeGen/MachineFunction.cpp

index 409f900a13790f659cc6b642a81910255baf18c0..01638691cfb41d2ad0feeedbe2e2f2f4d23a4c4c 100644 (file)
@@ -15,6 +15,8 @@
 #ifndef LLVM_CODEGEN_PASSES_H
 #define LLVM_CODEGEN_PASSES_H
 
+#include <iostream>
+
 namespace llvm {
 
   class FunctionPass;
@@ -23,8 +25,9 @@ namespace llvm {
   
   /// MachineFunctionPrinter pass - This pass prints out the machine function to
   /// standard error, as a debugging tool.
-  FunctionPass *createMachineFunctionPrinterPass();
-    
+  FunctionPass *createMachineFunctionPrinterPass(std::ostream *OS = &std::cerr,
+                                                 const std::string &Banner ="");
+
   /// PHIElimination pass - This pass eliminates machine instruction PHI nodes
   /// by inserting copy instructions.  This destroys SSA information, but is the
   /// desired input for some register allocators.  This pass is "required" by
index fa77906332b88998a0ccc344206cad79568b651d..e25fe8d5885aa60a0f2cc61928d4e2c06b680390 100644 (file)
@@ -34,6 +34,12 @@ static AnnotationID MF_AID(
 
 namespace {
   struct Printer : public MachineFunctionPass {
+    std::ostream *OS;
+    const std::string &Banner;
+
+    Printer (std::ostream *_OS, const std::string &_Banner) :
+      OS (_OS), Banner (_Banner) { }
+
     const char *getPassName() const { return "MachineFunction Printer"; }
 
     virtual void getAnalysisUsage(AnalysisUsage &AU) const {
@@ -41,14 +47,19 @@ namespace {
     }
 
     bool runOnMachineFunction(MachineFunction &MF) {
-      MF.dump();
+      (*OS) << Banner;
+      MF.print (*OS);
       return false;
     }
   };
 }
 
-FunctionPass *llvm::createMachineFunctionPrinterPass() {
-  return new Printer();
+/// Returns a newly-created MachineFunction Printer pass. The default output
+/// stream is std::cerr; the default banner is empty.
+///
+FunctionPass *llvm::createMachineFunctionPrinterPass(std::ostream *OS,
+                                                     const std::string &Banner) {
+  return new Printer(OS, Banner);
 }
 
 namespace {