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"
20 #include "llvm/Support/Streams.h"
24 class WriteBytecodePass : public ModulePass {
25 OStream *Out; // ostream to print on
29 static const char ID; // Pass identifcation, replacement for typeid
31 : ModulePass((intptr_t) &ID), Out(&cout), DeleteStream(false),
32 CompressFile(false) {}
33 WriteBytecodePass(OStream *o, bool DS = false, bool CF = false)
34 : ModulePass((intptr_t) &ID), Out(o), DeleteStream(DS), CompressFile(CF) {}
36 inline ~WriteBytecodePass() {
37 if (DeleteStream) delete Out;
40 bool runOnModule(Module &M) {
41 WriteBytecodeToFile(&M, *Out, CompressFile);
46 } // End llvm namespace