*** empty log message ***
[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   const char *getPassName() const { return "Bytecode Writer"; }
23
24   inline ~WriteBytecodePass() {
25     if (DeleteStream) delete Out;
26   }
27   
28   bool run(Module &M) {
29     WriteBytecodeToFile(&M, *Out);    
30     return false;
31   }
32 };
33
34 #endif