1 //===-- llvm/Bitcode/ReaderWriter.h - Bitcode reader/writers ----*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This header defines interfaces to read and write LLVM bitcode files/streams.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_BITCODE_H
15 #define LLVM_BITCODE_H
27 /// getBitcodeModuleProvider - Read the header of the specified bitcode buffer
28 /// and prepare for lazy deserialization of function bodies. If successful,
29 /// this takes ownership of 'buffer' and returns a non-null pointer. On
30 /// error, this returns null, *does not* take ownership of Buffer, and fills
31 /// in *ErrMsg with an error description if ErrMsg is non-null.
32 ModuleProvider *getBitcodeModuleProvider(MemoryBuffer *Buffer,
33 std::string *ErrMsg = 0);
35 /// ParseBitcodeFile - Read the specified bitcode file, returning the module.
36 /// If an error occurs, this returns null and fills in *ErrMsg if it is
37 /// non-null. This method *never* takes ownership of Buffer.
38 Module *ParseBitcodeFile(MemoryBuffer *Buffer, std::string *ErrMsg = 0);
40 /// WriteBitcodeToFile - Write the specified module to the specified output
42 void WriteBitcodeToFile(const Module *M, std::ostream &Out);
44 /// WriteBitcodeToFile - Write the specified module to the specified
45 /// raw output stream.
46 void WriteBitcodeToFile(const Module *M, raw_ostream &Out);
48 /// CreateBitcodeWriterPass - Create and return a pass that writes the module
49 /// to the specified ostream.
50 ModulePass *CreateBitcodeWriterPass(std::ostream &Str);
52 /// createBitcodeWriterPass - Create and return a pass that writes the module
53 /// to the specified ostream.
54 ModulePass *createBitcodeWriterPass(raw_ostream &Str);
55 } // End llvm namespace