initial checkin
[oota-llvm.git] / include / llvm / Bytecode / WriteBytecodePass.h
1 //===- llvm/Bytecode/WriteBytecodePass.h - Bytecode Writer Pass --*- C++ -*--=//
2 //
3 // This file defines a simple pass to write the working module to a file after
4 // pass processing is completed.
5 //
6 //===----------------------------------------------------------------------===//
7
8 #ifndef LLVM_BYTECODE_WRITEBYTECODEPASS_H
9 #define LLVM_BYTECODE_WRITEBYTECODEPASS_H
10
11 #include "llvm/Pass.h"
12 #include "llvm/Bytecode/Writer.h"
13
14 class WriteBytecodePass : public Pass {
15   ostream *Out;           // ostream to print on
16   bool DeleteStream;
17 public:
18   inline WriteBytecodePass(ostream *o = &cout, bool DS = false)
19     : Out(o), DeleteStream(DS) {
20   }
21
22   inline ~WriteBytecodePass() {
23     if (DeleteStream) delete Out;
24   }
25   
26   bool doPassFinalization(Module *M) {
27     WriteBytecodeToFile(M, *Out);    
28     return false;
29   }
30 };
31
32 #endif