Pull bytecode writing out of Module writer pass. Prepare to move to seperate file
authorChris Lattner <sabre@nondot.org>
Thu, 18 Oct 2001 20:05:07 +0000 (20:05 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 18 Oct 2001 20:05:07 +0000 (20:05 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@895 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Transforms/PrintModulePass.h

index 9c3274edc5171ad5fd7afa5725db8be2cd124787..142c2b08d1f2280db9546ff80fe7be487d6095d1 100644 (file)
@@ -17,19 +17,14 @@ class PrintModulePass : public Pass {
   ostream *Out;           // ostream to print on
   bool DeleteStream;      // Delete the ostream in our dtor?
   bool PrintPerMethod;    // Print one method at a time rather than the whole?
-  bool PrintAsBytecode;   // Print as bytecode rather than assembly?
 public:
   inline PrintModulePass(const string &B, ostream *o = &cout,
                          bool DS = false,
-                         bool printPerMethod = true,
-                         bool printAsBytecode = false)
-    : Banner(B), Out(o), DeleteStream(DS),
-      PrintPerMethod(printPerMethod), PrintAsBytecode(printAsBytecode) {
-    if (PrintAsBytecode)
-      PrintPerMethod = false;
+                         bool printPerMethod = true)
+    : Banner(B), Out(o), DeleteStream(DS), PrintPerMethod(printPerMethod) {
   }
   
-  ~PrintModulePass() {
+  inline ~PrintModulePass() {
     if (DeleteStream) delete Out;
   }
   
@@ -45,13 +40,28 @@ public:
   // doPassFinalization - Virtual method overriden by subclasses to do any post
   // processing needed after all passes have run.
   //
-  bool doPassFinalization(Module *module) {
-    if (PrintAsBytecode)
-      WriteBytecodeToFile(module, *Out);
-    else if (! PrintPerMethod)
-      (*Out) << Banner << module;
+  bool doPassFinalization(Module *M) {
+    if (! PrintPerMethod)
+      (*Out) << Banner << M;
     return false;
   }
 };
 
+class WriteModuleBytecode : public Pass {
+  ostream *Out;           // ostream to print on
+  bool DeleteStream;
+public:
+  inline WriteModuleBytecode(ostream *o = &cout, bool DS = false)
+    : Out(o), DeleteStream(DS) {
+  }
+
+  inline ~WriteModuleBytecode() {
+    if (DeleteStream) delete Out;
+  }
+  
+  bool doPassFinalization(Module *M) {
+    WriteBytecodeToFile(M, *Out);    
+  }
+};
+
 #endif