//===-- llvm/Bytecode/Analyzer.h - Analyzer for Bytecode files --*- C++ -*-===//
-//
+//
// The LLVM Compiler Infrastructure
//
-// This file was developed by Reid Spencer and is distributed under the
+// This file was developed by Reid Spencer and is distributed under the
// University of Illinois Open Source License. See LICENSE.TXT for details.
-//
+//
//===----------------------------------------------------------------------===//
//
// This functionality is implemented by the lib/Bytecode/Reader library.
// It is used to read VM bytecode files from a file or memory buffer
-// and print out a diagnostic analysis of the contents of the file. It is
-// intended for three uses: (a) understanding the bytecode format, (b) ensuring
-// correctness of bytecode format, (c) statistical analysis of generated
+// and print out a diagnostic analysis of the contents of the file. It is
+// intended for three uses: (a) understanding the bytecode format, (b) ensuring
+// correctness of bytecode format, (c) statistical analysis of generated
// bytecode files.
//
//===----------------------------------------------------------------------===//
#define LLVM_BYTECODE_ANALYZER_H
#include "llvm/Bytecode/Format.h"
+#include "llvm/Bytecode/Reader.h"
#include <string>
#include <map>
+#include <iosfwd>
namespace llvm {
class Function;
class Module;
-/// This structure is used to contain the output of the Bytecode Analysis
-/// library. It simply contains fields to hold each item of the analysis
+/// This structure is used to contain the output of the Bytecode Analysis
+/// library. It simply contains fields to hold each item of the analysis
/// results.
/// @brief Bytecode Analysis results structure
struct BytecodeAnalysis {
double functionDensity; ///< Average density of functions (bytes/function)
unsigned instructionSize; ///< Size of instructions in bytes
unsigned longInstructions;///< Number of instructions > 4 bytes
- unsigned vbrCount32; ///< Number of 32-bit vbr values
- unsigned vbrCount64; ///< Number of 64-bit vbr values
- unsigned vbrCompBytes; ///< Number of vbr bytes (compressed)
- unsigned vbrExpdBytes; ///< Number of vbr bytes (expanded)
- typedef std::map<BytecodeFormat::CompressedBytecodeBlockIdentifiers,unsigned>
+ typedef std::map<BytecodeFormat::BytecodeBlockIdentifiers,unsigned>
BlockSizeMap;
BlockSizeMap BlockSizes;
double density; ///< Density of function
unsigned instructionSize; ///< Size of instructions in bytes
unsigned longInstructions;///< Number of instructions > 4 bytes
- unsigned vbrCount32; ///< Number of 32-bit vbr values
- unsigned vbrCount64; ///< Number of 64-bit vbr values
- unsigned vbrCompBytes; ///< Number of vbr bytes (compressed)
- unsigned vbrExpdBytes; ///< Number of vbr bytes (expanded)
};
- /// A mapping of function slot numbers to the collected information about
+ /// A mapping of function slot numbers to the collected information about
/// the function.
- std::map<const Function*,BytecodeFunctionInfo> FunctionInfo;
+ std::map<const Function*,BytecodeFunctionInfo> FunctionInfo;
/// The content of the progressive verification
std::string VerifyInfo;
/// Flags for what should be done
- bool detailedResults; ///< If true, FunctionInfo has contents
+ bool detailedResults; ///< If true, FunctionInfo has contents
bool progressiveVerify; ///< If true, VerifyInfo has contents
};
/// This function is the main entry point into the bytecode analysis library. It
-/// allows you to simply provide a \p filename and storage for the \p Results
+/// allows you to simply provide a \p filename and storage for the \p Results
/// that will be filled in with the analysis results.
/// @brief Analyze contents of a bytecode File
Module* AnalyzeBytecodeFile(
const std::string& Filename, ///< The name of the bytecode file to read
BytecodeAnalysis& Results, ///< The results of the analysis
+ BCDecompressor_t *BCDC = 0, ///< Optional decompressor to use.
std::string* ErrorStr = 0, ///< Errors, if any.
std::ostream* output = 0 ///< Stream for dump output, if wanted
);
-/// This function is an alternate entry point into the bytecode analysis
-/// library. It allows you to provide an arbitrary memory buffer which is
-/// assumed to contain a complete bytecode file. The \p Buffer is analyzed and
-/// the \p Results are filled in.
-/// @brief Analyze contents of a bytecode buffer.
-Module* AnalyzeBytecodeBuffer(
- const unsigned char* Buffer, ///< Pointer to start of bytecode buffer
- unsigned BufferSize, ///< Size of the bytecode buffer
- const std::string& ModuleID, ///< Identifier for the module
- BytecodeAnalysis& Results, ///< The results of the analysis
- std::string* ErrorStr = 0, ///< Errors, if any.
- std::ostream* output = 0 ///< Stream for dump output, if wanted
- );
/// This function prints the contents of rhe BytecodeAnalysis structure in
/// a human legible form.