diff options
author | Vikram S. Adve <vadve@cs.uiuc.edu> | 2001-10-18 13:47:49 +0000 |
---|---|---|
committer | Vikram S. Adve <vadve@cs.uiuc.edu> | 2001-10-18 13:47:49 +0000 |
commit | 07b877eb5d542876043969148593b456ff1187be (patch) | |
tree | ef404d811711b2d7e7d700a05e1dc951a48b85a3 /include/llvm/Transforms | |
parent | 73e11d77aaa09d5b126aef0b600c31ebd1206c3d (diff) | |
download | external_llvm-07b877eb5d542876043969148593b456ff1187be.zip external_llvm-07b877eb5d542876043969148593b456ff1187be.tar.gz external_llvm-07b877eb5d542876043969148593b456ff1187be.tar.bz2 |
Add option to print as bytecode instead of assembly.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@887 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Transforms')
-rw-r--r-- | include/llvm/Transforms/PrintModulePass.h | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/include/llvm/Transforms/PrintModulePass.h b/include/llvm/Transforms/PrintModulePass.h index 98948d8..c8fb08f 100644 --- a/include/llvm/Transforms/PrintModulePass.h +++ b/include/llvm/Transforms/PrintModulePass.h @@ -10,14 +10,17 @@ #include "llvm/Transforms/Pass.h" #include "llvm/Assembly/Writer.h" +#include "llvm/Bytecode/Writer.h" class PrintModulePass : public Pass { string Banner; // String to print before each method ostream *Out; // ostream to print on bool DeleteStream; // Delete the ostream in our dtor? + bool PrintAsBytecode; // Print as bytecode rather than assembly? public: - inline PrintModulePass(const string &B, ostream *o = &cout, bool DS = false) - : Banner(B), Out(o), DeleteStream(DS) {} + inline PrintModulePass(const string &B, ostream *o = &cout, bool DS = false, + bool printAsBytecode = false) + : Banner(B), Out(o), DeleteStream(DS), PrintAsBytecode(printAsBytecode) {} ~PrintModulePass() { if (DeleteStream) delete Out; @@ -27,7 +30,17 @@ public: // it's processed. // bool doPerMethodWork(Method *M) { - (*Out) << Banner << M; + if (! PrintAsBytecode) + (*Out) << Banner << M; + return false; + } + + // doPassFinalization - Virtual method overriden by subclasses to do any post + // processing needed after all passes have run. + // + bool doPassFinalization(Module *M) { + if (PrintAsBytecode) + WriteBytecodeToFile(M, *Out); return false; } }; |