LLVM API Documentation
00001 //===-- llvm/Bytecode/Reader.h - Reader for VM bytecode files ---*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file was developed by the LLVM research group and is distributed under 00006 // the University of Illinois Open Source License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This functionality is implemented by the lib/Bytecode/Reader library. 00011 // This library is used to read VM bytecode files from an iostream. 00012 // 00013 // Note that performance of this library is _crucial_ for performance of the 00014 // JIT type applications, so we have designed the bytecode format to support 00015 // quick reading. 00016 // 00017 //===----------------------------------------------------------------------===// 00018 00019 #ifndef LLVM_BYTECODE_READER_H 00020 #define LLVM_BYTECODE_READER_H 00021 00022 #include "llvm/System/Path.h" 00023 #include "llvm/ModuleProvider.h" 00024 #include "llvm/Module.h" 00025 #include <string> 00026 00027 namespace llvm { 00028 00029 // Forward declare the handler class 00030 class BytecodeHandler; 00031 00032 /// getBytecodeModuleProvider - lazy function-at-a-time loading from a file 00033 /// 00034 ModuleProvider *getBytecodeModuleProvider( 00035 const std::string &Filename, ///< Name of file to be read 00036 BytecodeHandler* H = 0 ///< Optional handler for reader events 00037 ); 00038 00039 /// getBytecodeBufferModuleProvider - lazy function-at-a-time loading from a 00040 /// buffer 00041 /// 00042 ModuleProvider *getBytecodeBufferModuleProvider(const unsigned char *Buffer, 00043 unsigned BufferSize, 00044 const std::string &ModuleID="", 00045 BytecodeHandler* H = 0); 00046 00047 /// @brief Parse the given bytecode file 00048 Module* ParseBytecodeFile(const std::string &Filename, 00049 std::string *ErrorStr = 0); 00050 00051 /// @brief Parse a given bytecode buffer 00052 Module* ParseBytecodeBuffer(const unsigned char *Buffer, 00053 unsigned BufferSize, 00054 const std::string &ModuleID = "", 00055 std::string *ErrorStr = 0); 00056 00057 /// This function will read only the necessary parts of a bytecode file in order 00058 /// to determine the list of dependent libraries encoded within it. The \p 00059 /// deplibs parameter will contain a vector of strings of the bytecode module's 00060 /// dependent libraries. 00061 /// @returns true on success, false otherwise 00062 /// @brief Get the list of dependent libraries from a bytecode file. 00063 bool GetBytecodeDependentLibraries(const std::string &fileName, 00064 Module::LibraryListType& deplibs); 00065 00066 /// This function will read only the necessary parts of a bytecode file in order 00067 /// to obtain a list of externally visible global symbols that the bytecode 00068 /// module defines. This is used for archiving and linking when only the list 00069 /// of symbols the module defines is needed. 00070 /// @returns true on success, false otherwise 00071 /// @brief Get a bytecode file's externally visibile defined global symbols. 00072 bool GetBytecodeSymbols(const sys::Path& fileName, 00073 std::vector<std::string>& syms); 00074 00075 /// This function will read only the necessary parts of a bytecode buffer in 00076 /// order to obtain a list of externally visible global symbols that the 00077 /// bytecode module defines. This is used for archiving and linking when only 00078 /// the list of symbols the module defines is needed and the bytecode is 00079 /// already in memory. 00080 /// @returns the ModuleProvider on success, 0 if the bytecode can't be parsed 00081 /// @brief Get a bytecode file's externally visibile defined global symbols. 00082 ModuleProvider* GetBytecodeSymbols( 00083 const unsigned char*Buffer, ///< The buffer to be parsed 00084 unsigned Length, ///< The length of \p Buffer 00085 const std::string& ModuleID, ///< An identifier for the module 00086 std::vector<std::string>& symbols ///< The symbols defined in the module 00087 ); 00088 00089 } // End llvm namespace 00090 00091 #endif