LLVM API Documentation
#include <BytecodeHandler.h>
Constructors And Operators | |
BytecodeHandler () | |
Default constructor (empty). | |
virtual | ~BytecodeHandler () |
Virtual destructor (empty). | |
Public Member Functions | |
Handler Methods | |
virtual void | handleError (const std::string &str) |
Handle parsing errors. | |
virtual void | handleStart (Module *Mod, unsigned byteSize) |
Handle the start of a bytecode parse. | |
virtual void | handleFinish () |
Handle the end of a bytecode parse. | |
virtual void | handleModuleBegin (const std::string &moduleId) |
Handle the start of a module. | |
virtual void | handleModuleEnd (const std::string &moduleId) |
Handle the end of a module. | |
virtual void | handleVersionInfo (unsigned char RevisionNum, Module::Endianness Endianness, Module::PointerSize PointerSize) |
Handle the bytecode prolog. | |
virtual void | handleModuleGlobalsBegin () |
virtual void | handleGlobalVariable (const Type *ElemType, bool isConstant, GlobalValue::LinkageTypes, unsigned SlotNum, unsigned initSlot) |
Handle a non-initialized global variable. | |
virtual void | handleTypeList (unsigned numEntries) |
Handle a type. | |
virtual void | handleType (const Type *Ty) |
Handle a type. | |
virtual void | handleFunctionDeclaration (Function *Func) |
virtual void | handleGlobalInitializer (GlobalVariable *, Constant *) |
virtual void | handleDependentLibrary (const std::string &libName) |
virtual void | handleTargetTriple (const std::string &triple) |
virtual void | handleModuleGlobalsEnd () |
Handle end of module globals block. | |
virtual void | handleCompactionTableBegin () |
Handle start of compaction table. | |
virtual void | handleCompactionTablePlane (unsigned Ty, unsigned NumEntries) |
Handle start of a compaction table plane. | |
virtual void | handleCompactionTableType (unsigned i, unsigned TypSlot, const Type *) |
Handle a type entry in the compaction table. | |
virtual void | handleCompactionTableValue (unsigned i, unsigned TypSlot, unsigned ValSlot) |
Handle a value entry in the compaction table. | |
virtual void | handleCompactionTableEnd () |
Handle end of a compaction table. | |
virtual void | handleSymbolTableBegin (Function *Func, SymbolTable *ST) |
Handle start of a symbol table. | |
virtual void | handleSymbolTablePlane (unsigned TySlot, unsigned NumEntries, const Type *Typ) |
Handle start of a symbol table plane. | |
virtual void | handleSymbolTableType (unsigned i, unsigned slot, const std::string &name) |
Handle a named type in the symbol table. | |
virtual void | handleSymbolTableValue (unsigned i, unsigned slot, const std::string &name) |
Handle a named value in the symbol table. | |
virtual void | handleSymbolTableEnd () |
Handle the end of a symbol table. | |
virtual void | handleFunctionBegin (Function *Func, unsigned Size) |
Handle the beginning of a function body. | |
virtual void | handleFunctionEnd (Function *Func) |
Handle the end of a function body. | |
virtual void | handleBasicBlockBegin (unsigned blocknum) |
Handle the beginning of a basic block. | |
virtual bool | handleInstruction (unsigned Opcode, const Type *iType, std::vector< unsigned > &Operands, unsigned Length) |
Handle an instruction. | |
virtual void | handleBasicBlockEnd (unsigned blocknum) |
Handle the end of a basic block. | |
virtual void | handleGlobalConstantsBegin () |
Handle start of global constants block. | |
virtual void | handleConstantExpression (unsigned Opcode, std::vector< Constant * > ArgVec, Constant *C) |
Handle a constant expression. | |
virtual void | handleConstantArray (const ArrayType *AT, std::vector< Constant * > &ElementSlots, unsigned TypeSlot, Constant *Val) |
Handle a constant array. | |
virtual void | handleConstantStruct (const StructType *ST, std::vector< Constant * > &ElementSlots, Constant *Val) |
Handle a constant structure. | |
virtual void | handleConstantPacked (const PackedType *PT, std::vector< Constant * > &ElementSlots, unsigned TypeSlot, Constant *Val) |
Handle a constant packed. | |
virtual void | handleConstantPointer (const PointerType *PT, unsigned Slot, GlobalValue *GV) |
Handle a constant pointer. | |
virtual void | handleConstantString (const ConstantArray *CA) |
Handle a constant strings (array special case). | |
virtual void | handleConstantValue (Constant *c) |
Handle a primitive constant value. | |
virtual void | handleGlobalConstantsEnd () |
Handle the end of the global constants. | |
virtual void | handleAlignment (unsigned numBytes) |
Handle an alignment event. | |
virtual void | handleBlock (unsigned BType, const unsigned char *StartPtr, unsigned Size) |
Handle a bytecode block. | |
virtual void | handleVBR32 (unsigned Size) |
Handle a variable bit rate 32 bit unsigned. | |
virtual void | handleVBR64 (unsigned Size) |
Handle a variable bit rate 64 bit unsigned. |
This class provides the interface for handling bytecode events during reading of bytecode. The methods on this interface are invoked by the BytecodeReader as it discovers the content of a bytecode stream. This class provides a a clear separation of concerns between recognizing the semantic units of a bytecode file (the Reader) and deciding what to do with them (the Handler).
The BytecodeReader recognizes the content of the bytecode file and calls the BytecodeHandler methods to let it perform additional tasks. This arrangement allows Bytecode files to be read and handled for a number of purposes simply by creating a subclass of BytecodeHandler. None of the parsing details need to be understood, only the meaning of the calls made on this interface.
Definition at line 46 of file BytecodeHandler.h.
llvm::BytecodeHandler::BytecodeHandler | ( | ) | [inline] |
BytecodeHandler::~BytecodeHandler | ( | ) | [virtual] |
virtual void llvm::BytecodeHandler::handleError | ( | const std::string & | str | ) | [inline, virtual] |
Handle parsing errors.
This method is called whenever the parser detects an error in the bytecode formatting. It gives the handler a chance to do something with the error message before the parser throws an exception to terminate the parsing.
Definition at line 70 of file BytecodeHandler.h.
virtual void llvm::BytecodeHandler::handleStart | ( | Module * | Mod, | |
unsigned | byteSize | |||
) | [inline, virtual] |
Handle the start of a bytecode parse.
This method is called at the beginning of a parse before anything is read in order to give the handler a chance to initialize.
Definition at line 75 of file BytecodeHandler.h.
virtual void llvm::BytecodeHandler::handleFinish | ( | ) | [inline, virtual] |
Handle the end of a bytecode parse.
This method is called at the end of a parse after everything has been read in order to give the handler a chance to terminate.
Definition at line 80 of file BytecodeHandler.h.
virtual void llvm::BytecodeHandler::handleModuleBegin | ( | const std::string & | moduleId | ) | [inline, virtual] |
Handle the start of a module.
This method is called at the start of a module to indicate that a module is being parsed.
Definition at line 85 of file BytecodeHandler.h.
virtual void llvm::BytecodeHandler::handleModuleEnd | ( | const std::string & | moduleId | ) | [inline, virtual] |
Handle the end of a module.
This method is called at the end of a module to indicate that the module previously being parsed has concluded.
moduleId | An identifier for the module |
Definition at line 90 of file BytecodeHandler.h.
virtual void llvm::BytecodeHandler::handleVersionInfo | ( | unsigned char | RevisionNum, | |
Module::Endianness | Endianness, | |||
Module::PointerSize | PointerSize | |||
) | [inline, virtual] |
Handle the bytecode prolog.
This method is called once the version information has been parsed. It provides the information about the version of the bytecode file being read.
RevisionNum | Byte code revision number |
Endianness | Endianness indicator |
PointerSize | PointerSize indicator |
Definition at line 98 of file BytecodeHandler.h.
virtual void llvm::BytecodeHandler::handleModuleGlobalsBegin | ( | ) | [inline, virtual] |
This method is called at the start of a module globals block which contains the global variables and the function placeholders
Definition at line 106 of file BytecodeHandler.h.
virtual void llvm::BytecodeHandler::handleGlobalVariable | ( | const Type * | ElemType, | |
bool | isConstant, | |||
GlobalValue::LinkageTypes | , | |||
unsigned | SlotNum, | |||
unsigned | initSlot | |||
) | [inline, virtual] |
Handle a non-initialized global variable.
This method is called when a non-initialized global variable is recognized. Its type, constness, and linkage type are provided.
ElemType | The type of the global variable |
isConstant | Whether the GV is constant or not |
SlotNum | Slot number of GV |
initSlot | Slot number of GV's initializer (0 if none) |
Definition at line 111 of file BytecodeHandler.h.
virtual void llvm::BytecodeHandler::handleTypeList | ( | unsigned | numEntries | ) | [inline, virtual] |
Handle a type.
This method is called when a type list is recognized. It simply provides the number of types that the list contains. The handler should expect that number of calls to handleType.
numEntries | The number of entries in the type list |
Definition at line 123 of file BytecodeHandler.h.
virtual void llvm::BytecodeHandler::handleType | ( | const Type * | Ty | ) | [inline, virtual] |
Handle a type.
This method is called when a new type is recognized. The type is converted from the bytecode and passed to this method.
Ty | The type that was just recognized |
Definition at line 130 of file BytecodeHandler.h.
virtual void llvm::BytecodeHandler::handleFunctionDeclaration | ( | Function * | Func | ) | [inline, virtual] |
This method is called when the function prototype for a function is encountered in the module globals block.
Func | The function being declared |
Definition at line 136 of file BytecodeHandler.h.
virtual void llvm::BytecodeHandler::handleGlobalInitializer | ( | GlobalVariable * | , | |
Constant * | ||||
) | [inline, virtual] |
This method is called when a global variable is initialized with its constant value. Because of forward referencing, etc. this is done towards the end of the module globals block
Definition at line 143 of file BytecodeHandler.h.
virtual void llvm::BytecodeHandler::handleDependentLibrary | ( | const std::string & | libName | ) | [inline, virtual] |
This method is called for each dependent library name found in the module globals block.
Definition at line 147 of file BytecodeHandler.h.
virtual void llvm::BytecodeHandler::handleTargetTriple | ( | const std::string & | triple | ) | [inline, virtual] |
This method is called if the module globals has a non-empty target triple
Definition at line 151 of file BytecodeHandler.h.
virtual void llvm::BytecodeHandler::handleModuleGlobalsEnd | ( | ) | [inline, virtual] |
Handle end of module globals block.
This method is called at the end of the module globals block.
Definition at line 155 of file BytecodeHandler.h.
virtual void llvm::BytecodeHandler::handleCompactionTableBegin | ( | ) | [inline, virtual] |
Handle start of compaction table.
This method is called at the beginning of a compaction table.
Definition at line 159 of file BytecodeHandler.h.
virtual void llvm::BytecodeHandler::handleCompactionTablePlane | ( | unsigned | Ty, | |
unsigned | NumEntries | |||
) | [inline, virtual] |
Handle start of a compaction table plane.
Ty | The type of the plane (slot number) |
NumEntries | The number of entries in the plane |
Definition at line 162 of file BytecodeHandler.h.
virtual void llvm::BytecodeHandler::handleCompactionTableType | ( | unsigned | i, | |
unsigned | TypSlot, | |||
const Type * | ||||
) | [inline, virtual] |
Handle a type entry in the compaction table.
i | Index in the plane of this type |
TypSlot | Slot number for this type |
Definition at line 168 of file BytecodeHandler.h.
virtual void llvm::BytecodeHandler::handleCompactionTableValue | ( | unsigned | i, | |
unsigned | TypSlot, | |||
unsigned | ValSlot | |||
) | [inline, virtual] |
Handle a value entry in the compaction table.
i | Index in the compaction table's type plane |
TypSlot | The slot (plane) of the type of this value |
ValSlot | The global value slot of the value |
Definition at line 175 of file BytecodeHandler.h.
virtual void llvm::BytecodeHandler::handleCompactionTableEnd | ( | ) | [inline, virtual] |
virtual void llvm::BytecodeHandler::handleSymbolTableBegin | ( | Function * | Func, | |
SymbolTable * | ST | |||
) | [inline, virtual] |
Handle start of a symbol table.
Func | The function to which the ST belongs |
ST | The symbol table being filled |
Definition at line 185 of file BytecodeHandler.h.
virtual void llvm::BytecodeHandler::handleSymbolTablePlane | ( | unsigned | TySlot, | |
unsigned | NumEntries, | |||
const Type * | Typ | |||
) | [inline, virtual] |
Handle start of a symbol table plane.
TySlot | The slotnum of the type plane |
NumEntries | Number of entries in the plane |
Typ | The type of this type plane |
Definition at line 191 of file BytecodeHandler.h.
virtual void llvm::BytecodeHandler::handleSymbolTableType | ( | unsigned | i, | |
unsigned | slot, | |||
const std::string & | name | |||
) | [inline, virtual] |
Handle a named type in the symbol table.
i | The index of the type in this plane |
slot | Slot number of the named type |
name | Name of the type |
Definition at line 198 of file BytecodeHandler.h.
virtual void llvm::BytecodeHandler::handleSymbolTableValue | ( | unsigned | i, | |
unsigned | slot, | |||
const std::string & | name | |||
) | [inline, virtual] |
Handle a named value in the symbol table.
i | The index of the value in this plane |
slot | Slot number of the named value |
name | Name of the value. |
Definition at line 205 of file BytecodeHandler.h.
virtual void llvm::BytecodeHandler::handleSymbolTableEnd | ( | ) | [inline, virtual] |
virtual void llvm::BytecodeHandler::handleFunctionBegin | ( | Function * | Func, | |
unsigned | Size | |||
) | [inline, virtual] |
Handle the beginning of a function body.
Func | The function being defined |
Size | The size (in bytes) of the function's bytecode |
Definition at line 215 of file BytecodeHandler.h.
virtual void llvm::BytecodeHandler::handleFunctionEnd | ( | Function * | Func | ) | [inline, virtual] |
Handle the end of a function body.
Func | The function whose definition has just finished. |
Definition at line 221 of file BytecodeHandler.h.
virtual void llvm::BytecodeHandler::handleBasicBlockBegin | ( | unsigned | blocknum | ) | [inline, virtual] |
Handle the beginning of a basic block.
blocknum | The block number of the block |
Definition at line 226 of file BytecodeHandler.h.
virtual bool llvm::BytecodeHandler::handleInstruction | ( | unsigned | Opcode, | |
const Type * | iType, | |||
std::vector< unsigned > & | Operands, | |||
unsigned | Length | |||
) | [inline, virtual] |
Handle an instruction.
This method is called for each instruction that is parsed.
Opcode | Opcode of the instruction |
iType | Instruction type |
Operands | Vector of slot # operands |
Length | Length of instruction in bc bytes |
Definition at line 233 of file BytecodeHandler.h.
virtual void llvm::BytecodeHandler::handleBasicBlockEnd | ( | unsigned | blocknum | ) | [inline, virtual] |
Handle the end of a basic block.
blocknum | The block number of the block just finished |
Definition at line 241 of file BytecodeHandler.h.
virtual void llvm::BytecodeHandler::handleGlobalConstantsBegin | ( | ) | [inline, virtual] |
virtual void llvm::BytecodeHandler::handleConstantExpression | ( | unsigned | Opcode, | |
std::vector< Constant * > | ArgVec, | |||
Constant * | C | |||
) | [inline, virtual] |
Handle a constant expression.
Opcode | Opcode of primary expression operator |
ArgVec | expression args |
C | The constant value |
Definition at line 249 of file BytecodeHandler.h.
virtual void llvm::BytecodeHandler::handleConstantArray | ( | const ArrayType * | AT, | |
std::vector< Constant * > & | ElementSlots, | |||
unsigned | TypeSlot, | |||
Constant * | Val | |||
) | [inline, virtual] |
Handle a constant array.
AT | Type of the array |
ElementSlots | Slot nums for array values |
TypeSlot | Slot # of type |
Val | The constant value |
Definition at line 256 of file BytecodeHandler.h.
virtual void llvm::BytecodeHandler::handleConstantStruct | ( | const StructType * | ST, | |
std::vector< Constant * > & | ElementSlots, | |||
Constant * | Val | |||
) | [inline, virtual] |
Handle a constant structure.
ST | Type of the struct |
ElementSlots | Slot nums for struct values |
Val | The constant value |
Definition at line 264 of file BytecodeHandler.h.
virtual void llvm::BytecodeHandler::handleConstantPacked | ( | const PackedType * | PT, | |
std::vector< Constant * > & | ElementSlots, | |||
unsigned | TypeSlot, | |||
Constant * | Val | |||
) | [inline, virtual] |
Handle a constant packed.
PT | Type of the array |
ElementSlots | Slot nums for packed values |
TypeSlot | Slot # of type |
Val | The constant value |
Definition at line 271 of file BytecodeHandler.h.
virtual void llvm::BytecodeHandler::handleConstantPointer | ( | const PointerType * | PT, | |
unsigned | Slot, | |||
GlobalValue * | GV | |||
) | [inline, virtual] |
Handle a constant pointer.
PT | Type of the pointer |
Slot | Slot num of initializer value |
GV | Referenced global value |
Definition at line 279 of file BytecodeHandler.h.
virtual void llvm::BytecodeHandler::handleConstantString | ( | const ConstantArray * | CA | ) | [inline, virtual] |
Handle a constant strings (array special case).
CA | Type of the string array |
Definition at line 286 of file BytecodeHandler.h.
virtual void llvm::BytecodeHandler::handleConstantValue | ( | Constant * | c | ) | [inline, virtual] |
Handle a primitive constant value.
c | The constant just defined |
Definition at line 291 of file BytecodeHandler.h.
virtual void llvm::BytecodeHandler::handleGlobalConstantsEnd | ( | ) | [inline, virtual] |
virtual void llvm::BytecodeHandler::handleAlignment | ( | unsigned | numBytes | ) | [inline, virtual] |
Handle an alignment event.
numBytes | The number of bytes added for alignment |
Definition at line 299 of file BytecodeHandler.h.
virtual void llvm::BytecodeHandler::handleBlock | ( | unsigned | BType, | |
const unsigned char * | StartPtr, | |||
unsigned | Size | |||
) | [inline, virtual] |
Handle a bytecode block.
BType | The type of block |
StartPtr | The start of the block |
Size | The size of the block |
Definition at line 304 of file BytecodeHandler.h.
virtual void llvm::BytecodeHandler::handleVBR32 | ( | unsigned | Size | ) | [inline, virtual] |
Handle a variable bit rate 32 bit unsigned.
Size | Number of bytes the vbr_uint took up |
Definition at line 311 of file BytecodeHandler.h.
virtual void llvm::BytecodeHandler::handleVBR64 | ( | unsigned | Size | ) | [inline, virtual] |
Handle a variable bit rate 64 bit unsigned.
Size | Number of byte sthe vbr_uint64 took up |
Definition at line 316 of file BytecodeHandler.h.