1 //===- llvm/Bytecode/WriteBytecodePass.h - Bytecode Writer Pass -*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
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.
8 //===----------------------------------------------------------------------===//
10 // This file defines a simple pass to write the working module to a file after
11 // pass processing is completed.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_BYTECODE_WRITEBYTECODEPASS_H
16 #define LLVM_BYTECODE_WRITEBYTECODEPASS_H
18 #include "llvm/Pass.h"
19 #include "llvm/Bytecode/Writer.h"
25 class WriteBytecodePass : public ModulePass {
26 llvm_ostream *Out; // ostream to print on
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) {}
35 inline ~WriteBytecodePass() {
36 if (DeleteStream) delete Out;
39 bool runOnModule(Module &M) {
40 WriteBytecodeToFile(&M, *Out, CompressFile);
45 } // End llvm namespace