Talvos
0.1
SPIR-V interpreter and dynamic analysis framework
|
This class represents a SPIR-V module. More...
#include <talvos/Module.h>
Public Member Functions | |
Module (uint32_t IdBound) | |
Create an empty module. More... | |
~Module () | |
void | addEntryPoint (EntryPoint *EP) |
Add an entry point to the module. More... | |
void | addFunction (std::unique_ptr< Function > Func) |
Add a function to this module. More... | |
void | addLocalSize (uint32_t Entry, Dim3 LocalSize) |
Add a local size execution mode to an entry point. More... | |
void | addObject (uint32_t Id, const Object &Obj) |
Add an object to this module. More... | |
void | addSpecConstant (uint32_t SpecId, uint32_t ResultId) |
Add a specialization constant ID mapping. More... | |
void | addSpecConstantOp (Instruction *Op) |
Add a specialization constant operation instruction to this module. More... | |
void | addType (uint32_t Id, std::unique_ptr< Type > Ty) |
Add a type to this module. More... | |
void | addVariable (Variable *Var) |
Add a variable to this module, transferring ownership to the module. More... | |
const EntryPoint * | getEntryPoint (const std::string &Name, uint32_t ExecutionModel) const |
Get the entry point with the specified name and SPIR-V execution model. More... | |
const Function * | getFunction (uint32_t Id) const |
Returns the function with the specified ID. More... | |
uint32_t | getIdBound () const |
Returns the ID bound of the results in this module. More... | |
Dim3 | getLocalSize (uint32_t Entry) const |
Returns the LocalSize execution mode for an entry point. More... | |
const Object & | getObject (uint32_t Id) const |
Returns the object with the specified ID. More... | |
const std::vector< Object > & | getObjects () const |
Returns a list of all result objects in this module. More... | |
uint32_t | getSpecConstant (uint32_t SpecId) const |
Returns the result ID for the given specialization constant ID. More... | |
const std::vector< Instruction * > & | getSpecConstantOps () const |
Returns the list of specialization constant operation instructions. More... | |
const Type * | getType (uint32_t Id) const |
Returns the type with the specified ID. More... | |
const VariableList & | getVariables () const |
Returns the list of module scope variables. More... | |
uint32_t | getWorkgroupSizeId () const |
Returns the ID of the object decorated with WorkgroupSize. More... | |
void | setWorkgroupSizeId (uint32_t Id) |
Set the ID of the object decorated with WorkgroupSize. More... | |
Module (const Module &)=delete | |
Module & | operator= (const Module &)=delete |
Static Public Member Functions | |
static std::shared_ptr< Module > | load (const uint32_t *Words, size_t NumWords) |
Create a new module from the supplied SPIR-V binary data. More... | |
static std::shared_ptr< Module > | load (const std::string &FileName) |
Create a new module from the given SPIR-V binary filename. More... | |
Private Types | |
typedef std::map< uint32_t, std::unique_ptr< Type > > | TypeMap |
Map from SPIR-V result ID to talvos::Type. More... | |
typedef std::map< uint32_t, std::unique_ptr< Function > > | FunctionMap |
Map from SPIR-V result ID to talvos::Function. More... | |
Private Attributes | |
uint32_t | IdBound |
The ID bound of the module. More... | |
std::vector< Object > | Objects |
Constant instruction results. More... | |
TypeMap | Types |
Type mapping. More... | |
FunctionMap | Functions |
Function mapping. More... | |
std::vector< EntryPoint * > | EntryPoints |
List of entry points. More... | |
std::map< uint32_t, Dim3 > | LocalSizes |
LocalSize execution modes. More... | |
std::map< uint32_t, uint32_t > | SpecConstants |
Map specialization constant IDs to result IDs. More... | |
std::vector< Instruction * > | SpecConstantOps |
List of specialization constant operation instructions. More... | |
uint32_t | WorkgroupSizeId |
The ID of the object decorated with WorkgroupSize. More... | |
VariableList | Variables |
Module scope variables. More... | |
This class represents a SPIR-V module.
This class contains types, functions, global variables, and constant instruction results. Factory methods are provided to create a module from a SPIR-V binary filename or from data in memory.
|
private |
Map from SPIR-V result ID to talvos::Function.
|
private |
Map from SPIR-V result ID to talvos::Type.
talvos::Module::Module | ( | uint32_t | IdBound | ) |
Create an empty module.
Definition at line 695 of file Module.cpp.
talvos::Module::~Module | ( | ) |
Definition at line 702 of file Module.cpp.
|
delete |
void talvos::Module::addEntryPoint | ( | EntryPoint * | EP | ) |
Add an entry point to the module.
The function and input/output variables must all exist in this module. Transfers ownership of EP
to the module.
Definition at line 714 of file Module.cpp.
void talvos::Module::addFunction | ( | std::unique_ptr< Function > | Func | ) |
Add a function to this module.
Definition at line 720 of file Module.cpp.
void talvos::Module::addLocalSize | ( | uint32_t | Entry, |
Dim3 | LocalSize | ||
) |
Add a local size execution mode to an entry point.
Definition at line 726 of file Module.cpp.
void talvos::Module::addObject | ( | uint32_t | Id, |
const Object & | Obj | ||
) |
Add an object to this module.
Definition at line 732 of file Module.cpp.
void talvos::Module::addSpecConstant | ( | uint32_t | SpecId, |
uint32_t | ResultId | ||
) |
Add a specialization constant ID mapping.
Definition at line 738 of file Module.cpp.
void talvos::Module::addSpecConstantOp | ( | Instruction * | Op | ) |
Add a specialization constant operation instruction to this module.
Transfers ownership of Op
to the module.
Definition at line 745 of file Module.cpp.
void talvos::Module::addType | ( | uint32_t | Id, |
std::unique_ptr< Type > | Ty | ||
) |
Add a type to this module.
Definition at line 750 of file Module.cpp.
|
inline |
const EntryPoint * talvos::Module::getEntryPoint | ( | const std::string & | Name, |
uint32_t | ExecutionModel | ||
) | const |
Get the entry point with the specified name and SPIR-V execution model.
Returns nullptr if no entry point called Name
with a matching execution model is found.
Definition at line 756 of file Module.cpp.
const Function * talvos::Module::getFunction | ( | uint32_t | Id | ) | const |
Returns the function with the specified ID.
Definition at line 767 of file Module.cpp.
|
inline |
Dim3 talvos::Module::getLocalSize | ( | uint32_t | Entry | ) | const |
Returns the LocalSize execution mode for an entry point.
This will return (1,1,1) if it has not been explicitly set for Entry
.
Definition at line 774 of file Module.cpp.
const Object & talvos::Module::getObject | ( | uint32_t | Id | ) | const |
Returns the object with the specified ID.
Id
must be valid constant instruction result.
Definition at line 782 of file Module.cpp.
const std::vector< Object > & talvos::Module::getObjects | ( | ) | const |
Returns a list of all result objects in this module.
Definition at line 784 of file Module.cpp.
uint32_t talvos::Module::getSpecConstant | ( | uint32_t | SpecId | ) | const |
Returns the result ID for the given specialization constant ID.
Returns 0 if no specialization constants with this ID are present.
Definition at line 786 of file Module.cpp.
const std::vector< Instruction * > & talvos::Module::getSpecConstantOps | ( | ) | const |
Returns the list of specialization constant operation instructions.
Definition at line 793 of file Module.cpp.
const Type * talvos::Module::getType | ( | uint32_t | Id | ) | const |
Returns the type with the specified ID.
Definition at line 798 of file Module.cpp.
|
inline |
|
inline |
|
static |
Create a new module from the supplied SPIR-V binary data.
Returns nullptr on failure.
Definition at line 805 of file Module.cpp.
|
static |
Create a new module from the given SPIR-V binary filename.
Returns nullptr on failure.
Definition at line 830 of file Module.cpp.
|
inline |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |