LLVM API Documentation
#include <Reader.h>
Inheritance diagram for llvm::BytecodeReader:
Public Types | |
Types | |
typedef const unsigned char * | BufPtr |
A convenience type for the buffer pointer. | |
typedef std::vector< PATypeHolder > | TypeListTy |
The type used for a vector of potentially abstract types. | |
typedef std::vector< ValueList * > | ValueTable |
A 2 dimensional table of values. | |
typedef std::map< std::pair< const Type *, unsigned >, Constant * > | ConstantRefsType |
A mapping of a Type/slot pair to a Constant*. | |
typedef std::map< Function *, LazyFunctionInfo > | LazyFunctionMap |
A mapping of functions to their LazyFunctionInfo for lazy reading. | |
typedef std::vector< std::pair< GlobalVariable *, unsigned > > | GlobalInitsList |
A list of global variables and the slot number that initializes them. | |
typedef std::map< std::pair< unsigned, unsigned >, Value * > | ForwardReferenceMap |
A map for dealing with forward references of values. | |
Public Member Functions | |
Constructors | |
BytecodeReader (BytecodeHandler *h=0) | |
Default constructor. By default, no handler is used. | |
~BytecodeReader () | |
Methods | |
void | ParseBytecode (const unsigned char *Buf, unsigned Length, const std::string &ModuleID) |
Main interface to parsing a bytecode buffer. | |
void | ParseAllFunctionBodies () |
Parse all function bodies. | |
void | ParseFunction (Function *Func) |
Parse the next function of specific type. | |
virtual void | materializeFunction (Function *F) |
Make a specific function materialize. | |
virtual Module * | materializeModule () |
Make the whole module materialize. | |
Module * | releaseModule () |
Release our hold on the generated module. | |
Protected Member Functions | |
Parsing Units For Subclasses | |
void | ParseModule () |
Parse whole module scope. | |
void | ParseVersionInfo () |
Parse the version information block. | |
void | ParseModuleGlobalInfo () |
Parse the ModuleGlobalInfo block. | |
void | ParseSymbolTable (Function *Func, SymbolTable *ST) |
Parse a symbol table. | |
void | ParseFunctionLazily () |
Parse functions lazily. | |
void | ParseFunctionBody (Function *Func) |
Parse a function body. | |
void | ParseCompactionTypes (unsigned NumEntries) |
Parse the type list portion of a compaction table. | |
void | ParseCompactionTable () |
Parse a compaction table. | |
void | ParseGlobalTypes () |
Parse global types. | |
BasicBlock * | ParseBasicBlock (unsigned BlockNo) |
Parse a basic block (for LLVM 1.0 basic block blocks). | |
unsigned | ParseInstructionList (Function *F) |
parse an instruction list (for post LLVM 1.0 instruction lists with blocks differentiated by terminating instructions. | |
void | ParseInstruction (std::vector< unsigned > &Args, BasicBlock *BB) |
Parse a single instruction. | |
void | ParseConstantPool (ValueTable &Values, TypeListTy &Types, bool isFunction) |
Parse the whole constant pool. | |
Constant * | ParseConstantValue (unsigned TypeID) |
Parse a single constant value. | |
void | ParseTypes (TypeListTy &Tab, unsigned NumEntries) |
Parse a block of types constants. | |
const Type * | ParseType () |
Parse a single type constant. | |
void | ParseStringConstants (unsigned NumEntries, ValueTable &Tab) |
Parse a string constants block. | |
Classes | |
struct | LazyFunctionInfo |
Keeps pointers to function contents for later use. More... | |
struct | ValueList |
A list of values as a User of those Values. More... |
This class defines the interface for parsing a buffer of bytecode. The parser itself takes no action except to call the various functions of the handler interface. The parser's sole responsibility is the correct interpretation of the bytecode buffer. The handler is responsible for instantiating and keeping track of all values. As a convenience, the parser is responsible for materializing types and will pass them through the handler interface as necessary.
Definition at line 41 of file lib/Bytecode/Reader/Reader.h.
|
A convenience type for the buffer pointer.
Definition at line 66 of file lib/Bytecode/Reader/Reader.h. |
|
A mapping of a Type/slot pair to a Constant*. This map is needed so that forward references to constants can be looked up by Type and slot number when resolving those references. Definition at line 105 of file lib/Bytecode/Reader/Reader.h. |
|
A map for dealing with forward references of values. This type maps a typeslot/valueslot pair to the corresponding Value*. It is used for dealing with forward references as values are read in. Definition at line 128 of file lib/Bytecode/Reader/Reader.h. |
|
A list of global variables and the slot number that initializes them.
Definition at line 123 of file lib/Bytecode/Reader/Reader.h. |
|
A mapping of functions to their LazyFunctionInfo for lazy reading.
Definition at line 119 of file lib/Bytecode/Reader/Reader.h. |
|
The type used for a vector of potentially abstract types.
Definition at line 69 of file lib/Bytecode/Reader/Reader.h. |
|
A 2 dimensional table of values.
Definition at line 100 of file lib/Bytecode/Reader/Reader.h. |
|
Default constructor. By default, no handler is used.
Definition at line 47 of file lib/Bytecode/Reader/Reader.h. |
|
Definition at line 52 of file lib/Bytecode/Reader/Reader.h. |
|
Make a specific function materialize. This method is abstract in the parent ModuleProvider class. Its implementation is identical to the ParseFunction method.
Implements llvm::ModuleProvider. Definition at line 151 of file lib/Bytecode/Reader/Reader.h. References ParseFunction(). |
|
Make the whole module materialize. This method is abstract in the parent ModuleProvider class. Its implementation is identical to ParseAllFunctionBodies.
Implements llvm::ModuleProvider. Definition at line 161 of file lib/Bytecode/Reader/Reader.h. References ParseAllFunctionBodies(), and llvm::ModuleProvider::TheModule. |
|
Parse all function bodies. The ParseAllFunctionBodies method parses through all the previously unparsed functions in the bytecode file. If you want to completely parse a bytecode file, this method should be called after Parsebytecode because Parsebytecode only records the locations in the bytecode file of where the function definitions are located. This function uses that information to materialize the functions.
Definition at line 1792 of file Reader.cpp. References ParseFunctionBody(). Referenced by materializeModule(). |
|
Parse a basic block (for LLVM 1.0 basic block blocks). In LLVM 1.0 bytecode files, we used to output one basicblock at a time. This method reads in one of the basicblock packets. This method is not used for bytecode files after LLVM 1.0
Definition at line 953 of file Reader.cpp. References llvm::ISD::BasicBlock, and ParseInstruction(). Referenced by ParseFunctionBody(). |
|
Main interface to parsing a bytecode buffer.
|
|
Parse a compaction table.
Definition at line 1088 of file Reader.cpp. References llvm::Constant::getNullValue(), and ParseCompactionTypes(). Referenced by ParseFunctionBody(). |
|
Parse the type list portion of a compaction table.
Definition at line 1076 of file Reader.cpp. Referenced by ParseCompactionTable(). |
|
Parse the whole constant pool. In LLVM 1.3 Type does not derive from Value so the types do not occupy a plane. Consequently, we read the types first in the constant pool. In LLVM 1.2 and before, Types were written to the bytecode file in the "Type Type" plane (#12). In 1.3 plane 12 is now the label plane. Handle this here. Use of Type::VoidTyID is a misnomer. It actually means that the following plane is constant strings Definition at line 1527 of file Reader.cpp. References llvm::Type::getDescription(), llvm::Value::getName(), ParseConstantValue(), ParseStringConstants(), ParseTypes(), llvm::utostr(), and llvm::Type::VoidTyID. Referenced by ParseFunctionBody(), and ParseModule(). |
|
|
Parse the next function of specific type. The ParserFunction method lazily parses one function. Use this method to casue the parser to parse a specific function in the module. Note that this will remove the function from what is to be included by ParseAllFunctionBodies.
Definition at line 1766 of file Reader.cpp. References llvm::Type::getDescription(), llvm::GlobalValue::getType(), and ParseFunctionBody(). Referenced by materializeFunction(). |
|
Parse a function body. Parse the contents of a function. Note that this function can be called lazily by materializeFunction
Definition at line 1592 of file Reader.cpp. References llvm::GlobalValue::AppendingLinkage, llvm::BytecodeFormat::BasicBlock, llvm::BytecodeFormat::CompactionTableBlockID, llvm::BytecodeFormat::ConstantPoolBlockID, E, llvm::GlobalValue::ExternalLinkage, llvm::BytecodeFormat::InstructionListBlockID, llvm::GlobalValue::InternalLinkage, llvm::GlobalValue::LinkOnceLinkage, ParseBasicBlock(), ParseCompactionTable(), ParseConstantPool(), ParseInstructionList(), ParseSymbolTable(), llvm::GlobalValue::setLinkage(), llvm::BytecodeFormat::SymbolTableBlockID, and llvm::GlobalValue::WeakLinkage. Referenced by ParseAllFunctionBodies(), and ParseFunction(). |
|
Parse functions lazily. This function parses LLVM functions lazily. It obtains the type of the function and records where the body of the function is in the bytecode buffer. The caller can then use the ParseNextFunction and ParseAllFunctionBodies to get handler events for the functions. Definition at line 1742 of file Reader.cpp. References llvm::GlobalValue::GhostLinkage, and llvm::GlobalValue::setLinkage(). Referenced by ParseModule(). |
|
Parse global types.
Definition at line 1806 of file Reader.cpp. References ParseTypes(). Referenced by ParseModule(). |
|
|
parse an instruction list (for post LLVM 1.0 instruction lists with blocks differentiated by terminating instructions. Parse all of the BasicBlock's & Instruction's in the body of a function. In post 1.0 bytecode files, we no longer emit basic block individually, in order to avoid per-basic-block overhead.
Definition at line 977 of file Reader.cpp. References llvm::ISD::BasicBlock, llvm::Function::getBasicBlockList(), llvm::BasicBlock::getTerminator(), and ParseInstruction(). Referenced by ParseFunctionBody(). |
|
Parse whole module scope. Make sure we pulled them all out. If we didn't then there's a declaration but a missing body. That's not allowed. Definition at line 2093 of file Reader.cpp. References llvm::BytecodeFormat::ConstantPoolBlockID, llvm::BytecodeFormat::FunctionBlockID, llvm::SequentialType::getElementType(), llvm::Module::getSymbolTable(), llvm::GlobalValue::getType(), llvm::BytecodeFormat::GlobalTypePlaneBlockID, llvm::GlobalVariable::hasInitializer(), llvm::BytecodeFormat::ModuleGlobalInfoBlockID, ParseConstantPool(), ParseFunctionLazily(), ParseGlobalTypes(), ParseModuleGlobalInfo(), ParseSymbolTable(), ParseVersionInfo(), llvm::BytecodeFormat::SymbolTableBlockID, llvm::ModuleProvider::TheModule, and llvm::utostr(). |
|
Parse the ModuleGlobalInfo block.
Definition at line 1818 of file Reader.cpp. References llvm::Module::addLibrary(), llvm::GlobalValue::AppendingLinkage, llvm::GlobalValue::ExternalLinkage, llvm::GlobalValue::InternalLinkage, llvm::GlobalValue::LinkOnceLinkage, llvm::Module::setTargetTriple(), llvm::ModuleProvider::TheModule, llvm::utostr(), llvm::Type::VoidTyID, and llvm::GlobalValue::WeakLinkage. Referenced by ParseModule(). |
|
Parse a string constants block.
Definition at line 1492 of file Reader.cpp. References llvm::ConstantArray::get(), llvm::ConstantUInt::get(), llvm::ConstantSInt::get(), llvm::SequentialType::getElementType(), llvm::ArrayType::getNumElements(), llvm::Type::SByteTy, and llvm::Type::UByteTy. Referenced by ParseConstantPool(). |
|
Parse a symbol table. Parse a symbol table. This works for both module level and function level symbol tables. For function level symbol tables, the CurrentFunction parameter must be non-zero and the ST parameter must correspond to CurrentFunction's symbol table. For Module level symbol tables, the CurrentFunction argument must be zero. In LLVM 1.3 we write types separately from values so The types are always first in the symbol table. This is because Type no longer derives from Value. Definition at line 1011 of file Reader.cpp. References E, llvm::SymbolTable::insert(), llvm::Type::LabelTyID, and llvm::Value::setName(). Referenced by ParseFunctionBody(), and ParseModule(). |
|
Parse a single type constant.
Definition at line 1164 of file Reader.cpp. References llvm::Type::ArrayTyID, llvm::Type::FunctionTyID, llvm::OpaqueType::get(), llvm::PointerType::get(), llvm::StructType::get(), llvm::PackedType::get(), llvm::ArrayType::get(), llvm::FunctionType::get(), llvm::Type::getPrimitiveType(), llvm::Type::OpaqueTyID, llvm::Type::PackedTyID, llvm::Type::PointerTyID, llvm::Type::StructTyID, llvm::utostr(), and llvm::Type::VoidTy. Referenced by ParseTypes(). |
|
Parse a block of types constants.
Definition at line 1244 of file Reader.cpp. References llvm::OpaqueType::get(), and ParseType(). Referenced by ParseConstantPool(), and ParseGlobalTypes(). |
|
Parse the version information block. Parse the version information and decode it by setting flags on the Reader that enable backward compatibility of the reader. Definition at line 1956 of file Reader.cpp. References llvm::Module::AnyEndianness, llvm::Module::AnyPointerSize, llvm::Module::BigEndian, llvm::itostr(), llvm::Module::LittleEndian, llvm::Module::Pointer32, llvm::Module::Pointer64, llvm::DS::PointerSize, llvm::Module::setEndianness(), llvm::Module::setPointerSize(), and llvm::ModuleProvider::TheModule. Referenced by ParseModule(). |
|
Release our hold on the generated module. This method is provided by the parent ModuleProvde class and overriden here. It simply releases the module from its provided and frees up our state. Reimplemented from llvm::ModuleProvider. Definition at line 170 of file lib/Bytecode/Reader/Reader.h. References M, and llvm::ModuleProvider::releaseModule(). |