2003-09-30 18:37:50 +00:00
|
|
|
//===-- llvm/Bytecode/Reader.h - Reader for VM bytecode files ---*- C++ -*-===//
|
2005-04-21 20:39:54 +00:00
|
|
|
//
|
2003-10-20 20:19:47 +00:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file was developed by the LLVM research group and is distributed under
|
|
|
|
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
2005-04-21 20:39:54 +00:00
|
|
|
//
|
2003-10-20 20:19:47 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2001-06-06 20:29:01 +00:00
|
|
|
//
|
2002-10-25 22:53:56 +00:00
|
|
|
// This functionality is implemented by the lib/Bytecode/Reader library.
|
2001-06-06 20:29:01 +00:00
|
|
|
// This library is used to read VM bytecode files from an iostream.
|
|
|
|
//
|
|
|
|
// Note that performance of this library is _crucial_ for performance of the
|
|
|
|
// JIT type applications, so we have designed the bytecode format to support
|
|
|
|
// quick reading.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_BYTECODE_READER_H
|
|
|
|
#define LLVM_BYTECODE_READER_H
|
|
|
|
|
2003-09-22 23:36:33 +00:00
|
|
|
#include "llvm/ModuleProvider.h"
|
2004-09-11 04:29:13 +00:00
|
|
|
#include "llvm/Module.h"
|
2007-02-07 21:41:02 +00:00
|
|
|
#include "llvm/Support/Compressor.h"
|
|
|
|
#include "llvm/System/Path.h"
|
2001-06-06 20:29:01 +00:00
|
|
|
|
2003-11-11 22:41:34 +00:00
|
|
|
namespace llvm {
|
|
|
|
|
2004-06-29 23:20:03 +00:00
|
|
|
// Forward declare the handler class
|
|
|
|
class BytecodeHandler;
|
|
|
|
|
2007-02-07 21:41:02 +00:00
|
|
|
typedef size_t BCDecompressor_t(const char *, size_t, char*&, std::string*);
|
|
|
|
|
2006-08-25 17:43:11 +00:00
|
|
|
/// 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
|
|
|
|
/// @returns ModuleProvider* if successful
|
|
|
|
/// @brief Get a ModuleProvide for a bytecode file.
|
2004-06-29 23:20:03 +00:00
|
|
|
ModuleProvider *getBytecodeModuleProvider(
|
2006-08-25 17:43:11 +00:00
|
|
|
const std::string &Filename, ///< Name of file to be read
|
2007-02-07 21:41:02 +00:00
|
|
|
BCDecompressor_t *BCDC = Compressor::decompressToNewBuffer,
|
2006-08-30 20:47:48 +00:00
|
|
|
std::string* ErrMsg = 0, ///< Optional error message holder
|
2006-08-25 17:43:11 +00:00
|
|
|
BytecodeHandler* H = 0 ///< Optional handler for reader events
|
2004-06-29 23:20:03 +00:00
|
|
|
);
|
2001-06-06 20:29:01 +00:00
|
|
|
|
2006-08-25 17:43:11 +00:00
|
|
|
/// This function returns a ModuleProvider that can be used to do lazy
|
|
|
|
/// function function-at-a-time loading from a bytecode buffer.
|
|
|
|
/// @returns NULL on error
|
|
|
|
/// @returns ModuleProvider* if successful
|
|
|
|
/// @brief Get a ModuleProvider for a bytecode buffer.
|
|
|
|
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
|
2007-02-07 21:41:02 +00:00
|
|
|
BCDecompressor_t *BCDC = Compressor::decompressToNewBuffer,
|
2006-08-30 20:47:48 +00:00
|
|
|
std::string* ErrMsg = 0, ///< Optional place to return an error message
|
|
|
|
BytecodeHandler* H = 0 ///< Optional handler for reader events
|
2006-08-25 17:43:11 +00:00
|
|
|
);
|
2003-09-22 23:36:33 +00:00
|
|
|
|
2006-08-25 17:43:11 +00:00
|
|
|
/// This is the main interface to bytecode parsing. It opens the file specified
|
|
|
|
/// by \p Filename and parses the entire file, returing the corresponding Module
|
|
|
|
/// object if successful.
|
|
|
|
/// @returns NULL on error
|
|
|
|
/// @returns the module corresponding to the bytecode file, if successful
|
2004-08-24 22:49:07 +00:00
|
|
|
/// @brief Parse the given bytecode file
|
2006-08-25 17:43:11 +00:00
|
|
|
Module* ParseBytecodeFile(
|
|
|
|
const std::string &Filename, ///< Name of file to parse
|
2007-02-07 21:41:02 +00:00
|
|
|
BCDecompressor_t *BCDC = Compressor::decompressToNewBuffer,
|
2006-08-25 17:43:11 +00:00
|
|
|
std::string *ErrMsg = 0 ///< Optional place to return an error message
|
|
|
|
);
|
2003-09-22 23:36:33 +00:00
|
|
|
|
2006-08-25 17:43:11 +00:00
|
|
|
/// Parses a bytecode buffer specified by \p Buffer and \p BufferSize.
|
|
|
|
/// @returns NULL on error
|
|
|
|
/// @returns the module corresponding to the bytecode buffer, if successful
|
2004-08-24 22:49:07 +00:00
|
|
|
/// @brief Parse a given bytecode buffer
|
2006-08-25 17:43:11 +00:00
|
|
|
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
|
2007-02-07 21:41:02 +00:00
|
|
|
BCDecompressor_t *BCDC = Compressor::decompressToNewBuffer,
|
2006-08-25 17:43:11 +00:00
|
|
|
std::string *ErrMsg = 0 ///< Optional place to return an error message
|
|
|
|
);
|
2001-06-06 20:29:01 +00:00
|
|
|
|
2003-11-11 22:41:34 +00:00
|
|
|
} // End llvm namespace
|
|
|
|
|
2001-06-06 20:29:01 +00:00
|
|
|
#endif
|