78983857ae6e7be6b50ee075761e8d8f29410659
[oota-llvm.git] / include / llvm / Bitcode / ReaderWriter.h
1 //===-- llvm/Bitcode/ReaderWriter.h - Bitcode reader/writers ----*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by Chris Lattner and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This header defines interfaces to read and write LLVM bitcode files/streams.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_BITCODE_H
15 #define LLVM_BITCODE_H
16
17 #include <iosfwd>
18 #include <string>
19
20 namespace llvm {
21   class Module;
22   class ModuleProvider;
23   class MemoryBuffer;
24   class ModulePass;
25   
26   /// getBitcodeModuleProvider - Read the header of the specified bitcode buffer
27   /// and prepare for lazy deserialization of function bodies.  If successful,
28   /// this takes ownership of 'buffer' and returns a non-null pointer.  On
29   /// error, this returns null, *does not* take ownership of Buffer, and fills
30   /// in *ErrMsg with an error description if ErrMsg is non-null.
31   ModuleProvider *getBitcodeModuleProvider(MemoryBuffer *Buffer,
32                                            std::string *ErrMsg = 0);
33
34   /// ParseBitcodeFile - Read the specified bitcode file, returning the module.
35   /// If an error occurs, this returns null and fills in *ErrMsg if it is
36   /// non-null.  This method *never* takes ownership of Buffer.
37   Module *ParseBitcodeFile(MemoryBuffer *Buffer, std::string *ErrMsg = 0);
38   
39   /// WriteBitcodeToFile - Write the specified module to the specified output
40   /// stream.
41   void WriteBitcodeToFile(const Module *M, std::ostream &Out);
42   
43   /// CreateBitcodeWriterPass - Create and return a pass that writes the module
44   /// to the specified ostream.
45   ModulePass *CreateBitcodeWriterPass(std::ostream &Str);
46 } // End llvm namespace
47
48 #endif