LLVM API Documentation
00001 //===- llvm/Bytecode/WriteBytecodePass.h - Bytecode Writer Pass -*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file was developed by the LLVM research group and is distributed under 00006 // the University of Illinois Open Source License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file defines a simple pass to write the working module to a file after 00011 // pass processing is completed. 00012 // 00013 //===----------------------------------------------------------------------===// 00014 00015 #ifndef LLVM_BYTECODE_WRITEBYTECODEPASS_H 00016 #define LLVM_BYTECODE_WRITEBYTECODEPASS_H 00017 00018 #include "llvm/Pass.h" 00019 #include "llvm/Bytecode/Writer.h" 00020 #include <iostream> 00021 00022 namespace llvm { 00023 00024 class WriteBytecodePass : public ModulePass { 00025 std::ostream *Out; // ostream to print on 00026 bool DeleteStream; 00027 bool CompressFile; 00028 public: 00029 WriteBytecodePass() 00030 : Out(&std::cout), DeleteStream(false), CompressFile(true) {} 00031 WriteBytecodePass(std::ostream *o, bool DS = false, bool CF = true) 00032 : Out(o), DeleteStream(DS), CompressFile(CF) {} 00033 00034 inline ~WriteBytecodePass() { 00035 if (DeleteStream) delete Out; 00036 } 00037 00038 bool runOnModule(Module &M) { 00039 WriteBytecodeToFile(&M, *Out, CompressFile ); 00040 return false; 00041 } 00042 }; 00043 00044 } // End llvm namespace 00045 00046 #endif