Replacing std::iostreams with llvm iostreams. Some of these changes involve
[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
21 namespace llvm {
22
23 class llvm_ostream;
24
25 class WriteBytecodePass : public ModulePass {
26   llvm_ostream *Out;           // ostream to print on
27   bool DeleteStream;
28   bool CompressFile;
29 public:
30   WriteBytecodePass()
31     : Out(&llvm_cout), DeleteStream(false), CompressFile(true) {}
32   WriteBytecodePass(llvm_ostream *o, bool DS = false, bool CF = true)
33     : Out(o), DeleteStream(DS), CompressFile(CF) {}
34
35   inline ~WriteBytecodePass() {
36     if (DeleteStream) delete Out;
37   }
38
39   bool runOnModule(Module &M) {
40     WriteBytecodeToFile(&M, *Out, CompressFile);
41     return false;
42   }
43 };
44
45 } // End llvm namespace
46
47 #endif