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
25 class BitstreamWriter;
28 /// getBitcodeModuleProvider - Read the header of the specified bitcode buffer
29 /// and prepare for lazy deserialization of function bodies. If successful,
30 /// this takes ownership of 'buffer' and returns a non-null pointer. On
31 /// error, this returns null, *does not* take ownership of Buffer, and fills
32 /// in *ErrMsg with an error description if ErrMsg is non-null.
33 ModuleProvider *getBitcodeModuleProvider(MemoryBuffer *Buffer,
34 std::string *ErrMsg = 0);
36 /// ParseBitcodeFile - Read the specified bitcode file, returning the module.
37 /// If an error occurs, this returns null and fills in *ErrMsg if it is
38 /// non-null. This method *never* takes ownership of Buffer.
39 Module *ParseBitcodeFile(MemoryBuffer *Buffer, std::string *ErrMsg = 0);
41 /// WriteBitcodeToFile - Write the specified module to the specified output
43 void WriteBitcodeToFile(const Module *M, std::ostream &Out);
45 /// WriteBitcodeToFile - Write the specified module to the specified
46 /// raw output stream.
47 void WriteBitcodeToFile(const Module *M, raw_ostream &Out);
49 /// WriteBitcodeToStream - Write the specified module to the specified
50 /// raw output stream.
51 void WriteBitcodeToStream(const Module *M, BitstreamWriter &Stream);
53 /// CreateBitcodeWriterPass - Create and return a pass that writes the module
54 /// to the specified ostream.
55 ModulePass *CreateBitcodeWriterPass(std::ostream &Str);
57 /// createBitcodeWriterPass - Create and return a pass that writes the module
58 /// to the specified ostream.
59 ModulePass *createBitcodeWriterPass(raw_ostream &Str);
60 } // End llvm namespace