From f2e292ce58ca07d9bbe3cad75f8baa35bd85964a Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 7 Feb 2007 21:41:02 +0000 Subject: push bytecode decompressor out through APIs. Now the bytecode reader api's look like this: ModuleProvider *getBytecodeModuleProvider( const std::string &Filename, ///< Name of file to be read BCDecompressor_t *BCDC = Compressor::decompressToNewBuffer, std::string* ErrMsg = 0, ///< Optional error message holder BytecodeHandler* H = 0 ///< Optional handler for reader events ); This is ugly, but allows a client to say: getBytecodeModuleProvider("foo", 0); If they do this, there is no dependency on the compression libraries, saving codesize. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34012 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Bytecode/Reader.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'include/llvm/Bytecode/Reader.h') diff --git a/include/llvm/Bytecode/Reader.h b/include/llvm/Bytecode/Reader.h index 3627186..f175745 100644 --- a/include/llvm/Bytecode/Reader.h +++ b/include/llvm/Bytecode/Reader.h @@ -19,16 +19,18 @@ #ifndef LLVM_BYTECODE_READER_H #define LLVM_BYTECODE_READER_H -#include "llvm/System/Path.h" #include "llvm/ModuleProvider.h" #include "llvm/Module.h" -#include +#include "llvm/Support/Compressor.h" +#include "llvm/System/Path.h" namespace llvm { // Forward declare the handler class class BytecodeHandler; +typedef size_t BCDecompressor_t(const char *, size_t, char*&, std::string*); + /// This function returns a ModuleProvider that can be used to do lazy /// function-at-a-time loading from a bytecode file. /// @returns NULL on error @@ -36,6 +38,7 @@ class BytecodeHandler; /// @brief Get a ModuleProvide for a bytecode file. ModuleProvider *getBytecodeModuleProvider( const std::string &Filename, ///< Name of file to be read + BCDecompressor_t *BCDC = Compressor::decompressToNewBuffer, std::string* ErrMsg = 0, ///< Optional error message holder BytecodeHandler* H = 0 ///< Optional handler for reader events ); @@ -49,6 +52,7 @@ ModuleProvider *getBytecodeBufferModuleProvider( const unsigned char *Buffer, ///< Start of buffer to parse unsigned BufferSize, ///< Size of the buffer const std::string &ModuleID, ///< Name to give the module + BCDecompressor_t *BCDC = Compressor::decompressToNewBuffer, std::string* ErrMsg = 0, ///< Optional place to return an error message BytecodeHandler* H = 0 ///< Optional handler for reader events ); @@ -61,6 +65,7 @@ ModuleProvider *getBytecodeBufferModuleProvider( /// @brief Parse the given bytecode file Module* ParseBytecodeFile( const std::string &Filename, ///< Name of file to parse + BCDecompressor_t *BCDC = Compressor::decompressToNewBuffer, std::string *ErrMsg = 0 ///< Optional place to return an error message ); @@ -72,6 +77,7 @@ Module* ParseBytecodeBuffer( const unsigned char *Buffer, ///< Start of buffer to parse unsigned BufferSize, ///< Size of the buffer const std::string &ModuleID="", ///< Name to give the module + BCDecompressor_t *BCDC = Compressor::decompressToNewBuffer, std::string *ErrMsg = 0 ///< Optional place to return an error message ); @@ -84,6 +90,7 @@ Module* ParseBytecodeBuffer( bool GetBytecodeDependentLibraries( const std::string &fileName, ///< File name to read bytecode from Module::LibraryListType& deplibs, ///< List of dependent libraries extracted + BCDecompressor_t *BCDC = Compressor::decompressToNewBuffer, std::string* ErrMsg = 0 ///< Optional error message holder ); @@ -96,6 +103,7 @@ bool GetBytecodeDependentLibraries( bool GetBytecodeSymbols( const sys::Path& fileName, ///< Filename to read bytecode from std::vector& syms, ///< Vector to return symbols in + BCDecompressor_t *BCDC = Compressor::decompressToNewBuffer, std::string* ErrMsg = 0 ///< Optional error message holder ); @@ -111,6 +119,7 @@ ModuleProvider* GetBytecodeSymbols( unsigned Length, ///< The length of \p Buffer const std::string& ModuleID, ///< An identifier for the module std::vector& symbols, ///< The symbols defined in the module + BCDecompressor_t *BCDC = Compressor::decompressToNewBuffer, std::string* ErrMsg = 0 ///< Optional error message holder ); -- cgit v1.1