LLVM API Documentation

BitcodeWriterPass.h
Go to the documentation of this file.
00001 //===-- BitcodeWriterPass.h - Bitcode writing pass --------------*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 /// \file
00010 ///
00011 /// This file provides a bitcode writing pass.
00012 ///
00013 //===----------------------------------------------------------------------===//
00014 
00015 #ifndef LLVM_BITCODE_BITCODEWRITERPASS_H
00016 #define LLVM_BITCODE_BITCODEWRITERPASS_H
00017 
00018 #include "llvm/ADT/StringRef.h"
00019 
00020 namespace llvm {
00021 class Module;
00022 class ModulePass;
00023 class raw_ostream;
00024 class PreservedAnalyses;
00025 
00026 /// \brief Create and return a pass that writes the module to the specified
00027 /// ostream. Note that this pass is designed for use with the legacy pass
00028 /// manager.
00029 ModulePass *createBitcodeWriterPass(raw_ostream &Str);
00030 
00031 /// \brief Pass for writing a module of IR out to a bitcode file.
00032 ///
00033 /// Note that this is intended for use with the new pass manager. To construct
00034 /// a pass for the legacy pass manager, use the function above.
00035 class BitcodeWriterPass {
00036   raw_ostream &OS;
00037 
00038 public:
00039   /// \brief Construct a bitcode writer pass around a particular output stream.
00040   explicit BitcodeWriterPass(raw_ostream &OS) : OS(OS) {}
00041 
00042   /// \brief Run the bitcode writer pass, and output the module to the selected
00043   /// output stream.
00044   PreservedAnalyses run(Module *M);
00045 
00046   static StringRef name() { return "BitcodeWriterPass"; }
00047 };
00048 
00049 }
00050 
00051 #endif