LLVM API Documentation
00001 //===-- llvm/Bitcode/ReaderWriter.h - Bitcode reader/writers ----*- 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 // 00010 // This header defines interfaces to read and write LLVM bitcode files/streams. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 #ifndef LLVM_BITCODE_H 00015 #define LLVM_BITCODE_H 00016 00017 #include <iosfwd> 00018 #include <string> 00019 00020 namespace llvm { 00021 class Module; 00022 class ModuleProvider; 00023 class MemoryBuffer; 00024 class ModulePass; 00025 class BitstreamWriter; 00026 class raw_ostream; 00027 00028 /// getBitcodeModuleProvider - Read the header of the specified bitcode buffer 00029 /// and prepare for lazy deserialization of function bodies. If successful, 00030 /// this takes ownership of 'buffer' and returns a non-null pointer. On 00031 /// error, this returns null, *does not* take ownership of Buffer, and fills 00032 /// in *ErrMsg with an error description if ErrMsg is non-null. 00033 ModuleProvider *getBitcodeModuleProvider(MemoryBuffer *Buffer, 00034 std::string *ErrMsg = 0); 00035 00036 /// ParseBitcodeFile - Read the specified bitcode file, returning the module. 00037 /// If an error occurs, this returns null and fills in *ErrMsg if it is 00038 /// non-null. This method *never* takes ownership of Buffer. 00039 Module *ParseBitcodeFile(MemoryBuffer *Buffer, std::string *ErrMsg = 0); 00040 00041 /// WriteBitcodeToFile - Write the specified module to the specified output 00042 /// stream. 00043 void WriteBitcodeToFile(const Module *M, std::ostream &Out); 00044 00045 /// WriteBitcodeToFile - Write the specified module to the specified 00046 /// raw output stream. 00047 void WriteBitcodeToFile(const Module *M, raw_ostream &Out); 00048 00049 /// WriteBitcodeToStream - Write the specified module to the specified 00050 /// raw output stream. 00051 void WriteBitcodeToStream(const Module *M, BitstreamWriter &Stream); 00052 00053 /// CreateBitcodeWriterPass - Create and return a pass that writes the module 00054 /// to the specified ostream. 00055 ModulePass *CreateBitcodeWriterPass(std::ostream &Str); 00056 00057 /// createBitcodeWriterPass - Create and return a pass that writes the module 00058 /// to the specified ostream. 00059 ModulePass *createBitcodeWriterPass(raw_ostream &Str); 00060 } // End llvm namespace 00061 00062 #endif