1006cb6939af01c149bcae5be11b1b898f6c2ddd
[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 #include <iostream>
14
15 class WriteBytecodePass : public Pass {
16   std::ostream *Out;           // ostream to print on
17   bool DeleteStream;
18 public:
19   WriteBytecodePass() : Out(&std::cout), DeleteStream(false) {}
20   WriteBytecodePass(std::ostream *o, bool DS = false) 
21     : Out(o), DeleteStream(DS) {
22   }
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