diff options
author | Chris Lattner <sabre@nondot.org> | 2001-10-18 20:05:07 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2001-10-18 20:05:07 +0000 |
commit | 3923140a4d68ddc7ac34a2d973984da7be29ab55 (patch) | |
tree | b0bcd888bd9023b9a252f0ad7d81cf4e554b79e8 /include/llvm/Transforms | |
parent | c148d4e073a4da750ba91304b68c340119dfa901 (diff) | |
download | external_llvm-3923140a4d68ddc7ac34a2d973984da7be29ab55.zip external_llvm-3923140a4d68ddc7ac34a2d973984da7be29ab55.tar.gz external_llvm-3923140a4d68ddc7ac34a2d973984da7be29ab55.tar.bz2 |
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
Diffstat (limited to 'include/llvm/Transforms')
-rw-r--r-- | include/llvm/Transforms/PrintModulePass.h | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/include/llvm/Transforms/PrintModulePass.h b/include/llvm/Transforms/PrintModulePass.h index 9c3274e..142c2b0 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 |