From 3923140a4d68ddc7ac34a2d973984da7be29ab55 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 18 Oct 2001 20:05:07 +0000 Subject: [PATCH] Pull bytecode writing out of Module writer pass. Prepare to move to seperate file git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@895 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Transforms/PrintModulePass.h | 36 +++++++++++++++-------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/include/llvm/Transforms/PrintModulePass.h b/include/llvm/Transforms/PrintModulePass.h index 9c3274edc51..142c2b08d1f 100644 --- a/include/llvm/Transforms/PrintModulePass.h +++ b/include/llvm/Transforms/PrintModulePass.h @@ -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