Fix utostr once and for all, by making there only be one function named
[oota-llvm.git] / include / llvm / Bytecode / Reader.h
1 //===-- llvm/Bytecode/Reader.h - Reader for VM bytecode files ---*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This functionality is implemented by the lib/Bytecode/Reader library.
11 // This library is used to read VM bytecode files from an iostream.
12 //
13 // Note that performance of this library is _crucial_ for performance of the
14 // JIT type applications, so we have designed the bytecode format to support
15 // quick reading.
16 //
17 //===----------------------------------------------------------------------===//
18
19 #ifndef LLVM_BYTECODE_READER_H
20 #define LLVM_BYTECODE_READER_H
21
22 #include "llvm/System/Path.h"
23 #include "llvm/ModuleProvider.h"
24 #include "llvm/Module.h"
25 #include <string>
26
27 namespace llvm {
28
29 // Forward declare the handler class
30 class BytecodeHandler;
31
32 /// getBytecodeModuleProvider - lazy function-at-a-time loading from a file
33 ///
34 ModuleProvider *getBytecodeModuleProvider(
35   const std::string &Filename, ///< Name of file to be read
36   BytecodeHandler* H = 0       ///< Optional handler for reader events
37 );
38
39 /// getBytecodeBufferModuleProvider - lazy function-at-a-time loading from a
40 /// buffer
41 ///
42 ModuleProvider *getBytecodeBufferModuleProvider(const unsigned char *Buffer,
43                                                 unsigned BufferSize,
44                                                 const std::string &ModuleID="",
45                                                 BytecodeHandler* H = 0);
46
47 /// @brief Parse the given bytecode file
48 Module* ParseBytecodeFile(const std::string &Filename,
49                           std::string *ErrorStr = 0);
50
51 /// @brief Parse a given bytecode buffer
52 Module* ParseBytecodeBuffer(const unsigned char *Buffer,
53                             unsigned BufferSize,
54                             const std::string &ModuleID = "",
55                             std::string *ErrorStr = 0);
56
57 /// This function will read only the necessary parts of a bytecode file in order
58 /// to determine the list of dependent libraries encoded within it. The \p
59 /// deplibs parameter will contain a vector of strings of the bytecode module's
60 /// dependent libraries.
61 /// @returns true on success, false otherwise
62 /// @brief Get the list of dependent libraries from a bytecode file.
63 bool GetBytecodeDependentLibraries(const std::string &fileName,
64                                    Module::LibraryListType& deplibs);
65
66 /// This function will read only the necessary parts of a bytecode file in order
67 /// to obtain a list of externally visible global symbols that the bytecode
68 /// module defines. This is used for archiving and linking when only the list
69 /// of symbols the module defines is needed.
70 /// @returns true on success, false otherwise
71 /// @brief Get a bytecode file's externally visibile defined global symbols.
72 bool GetBytecodeSymbols(const sys::Path& fileName,
73                         std::vector<std::string>& syms);
74
75 /// This function will read only the necessary parts of a bytecode buffer in
76 /// order to obtain a list of externally visible global symbols that the
77 /// bytecode module defines. This is used for archiving and linking when only
78 /// the list of symbols the module defines is needed and the bytecode is
79 /// already in memory.
80 /// @returns the ModuleProvider on success, 0 if the bytecode can't be parsed
81 /// @brief Get a bytecode file's externally visibile defined global symbols.
82 ModuleProvider* GetBytecodeSymbols(
83   const unsigned char*Buffer,        ///< The buffer to be parsed
84   unsigned Length,                   ///< The length of \p Buffer
85   const std::string& ModuleID,       ///< An identifier for the module
86   std::vector<std::string>& symbols  ///< The symbols defined in the module
87 );
88
89 } // End llvm namespace
90
91 #endif