'Pass' should now not be derived from by clients. Instead, they should derive
[oota-llvm.git] / include / llvm / Bytecode / WriteBytecodePass.h
1 //===- llvm/Bytecode/WriteBytecodePass.h - Bytecode Writer Pass -*- C++ -*-===//
2 // 
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 // 
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines a simple pass to write the working module to a file after
11 // pass processing is completed.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_BYTECODE_WRITEBYTECODEPASS_H
16 #define LLVM_BYTECODE_WRITEBYTECODEPASS_H
17
18 #include "llvm/Pass.h"
19 #include "llvm/Bytecode/Writer.h"
20 #include <iostream>
21
22 namespace llvm {
23
24 class WriteBytecodePass : public ModulePass {
25   std::ostream *Out;           // ostream to print on
26   bool DeleteStream;
27 public:
28   WriteBytecodePass() : Out(&std::cout), DeleteStream(false) {}
29   WriteBytecodePass(std::ostream *o, bool DS = false) 
30     : Out(o), DeleteStream(DS) {
31   }
32
33   inline ~WriteBytecodePass() {
34     if (DeleteStream) delete Out;
35   }
36   
37   bool runOnModule(Module &M) {
38     WriteBytecodeToFile(&M, *Out);    
39     return false;
40   }
41 };
42
43 } // End llvm namespace
44
45 #endif