1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 20:23:11 +01:00

Add option to print as bytecode instead of assembly.

llvm-svn: 887
This commit is contained in:
Vikram S. Adve 2001-10-18 13:47:49 +00:00
parent 3b8499c02a
commit ec2a0b15bf

View File

@ -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;
}
};