9 #ifndef TALVOS_MODULE_H
10 #define TALVOS_MODULE_H
74 void addType(uint32_t Id, std::unique_ptr<Type> Ty);
83 uint32_t ExecutionModel)
const;
100 const std::vector<Object> &
getObjects()
const;
124 static std::shared_ptr<Module>
load(
const uint32_t *Words,
size_t NumWords);
128 static std::shared_ptr<Module>
load(
const std::string &FileName);
132 typedef std::map<uint32_t, std::unique_ptr<Type>>
TypeMap;
135 typedef std::map<uint32_t, std::unique_ptr<Function>>
FunctionMap;
This class represents a module-scope variable declaration.
Module(uint32_t IdBound)
Create an empty module.
const Type * getType(uint32_t Id) const
Returns the type with the specified ID.
std::vector< const Variable * > VariableList
A list of module scope variables.
std::vector< Instruction * > SpecConstantOps
List of specialization constant operation instructions.
const std::vector< Instruction * > & getSpecConstantOps() const
Returns the list of specialization constant operation instructions.
This class represents a SPIR-V module.
std::map< uint32_t, std::unique_ptr< Type > > TypeMap
Map from SPIR-V result ID to talvos::Type.
void addLocalSize(uint32_t Entry, Dim3 LocalSize)
Add a local size execution mode to an entry point.
void setWorkgroupSizeId(uint32_t Id)
Set the ID of the object decorated with WorkgroupSize.
const std::vector< Object > & getObjects() const
Returns a list of all result objects in this module.
This class represents a function in a SPIR-V Module.
std::vector< EntryPoint * > EntryPoints
List of entry points.
std::map< uint32_t, std::unique_ptr< Function > > FunctionMap
Map from SPIR-V result ID to talvos::Function.
std::vector< Object > Objects
Constant instruction results.
void addSpecConstant(uint32_t SpecId, uint32_t ResultId)
Add a specialization constant ID mapping.
const Function * getFunction(uint32_t Id) const
Returns the function with the specified ID.
uint32_t WorkgroupSizeId
The ID of the object decorated with WorkgroupSize.
VariableList Variables
Module scope variables.
uint32_t getWorkgroupSizeId() const
Returns the ID of the object decorated with WorkgroupSize.
void addVariable(Variable *Var)
Add a variable to this module, transferring ownership to the module.
Class representing a 3-dimensional size or ID.
void addEntryPoint(EntryPoint *EP)
Add an entry point to the module.
void addFunction(std::unique_ptr< Function > Func)
Add a function to this module.
const EntryPoint * getEntryPoint(const std::string &Name, uint32_t ExecutionModel) const
Get the entry point with the specified name and SPIR-V execution model.
This file declares the Dim3 class.
std::map< uint32_t, uint32_t > SpecConstants
Map specialization constant IDs to result IDs.
std::map< uint32_t, Dim3 > LocalSizes
LocalSize execution modes.
This file declares the Object class.
TypeMap Types
Type mapping.
uint32_t getIdBound() const
Returns the ID bound of the results in this module.
void addObject(uint32_t Id, const Object &Obj)
Add an object to this module.
uint32_t IdBound
The ID bound of the module.
Dim3 getLocalSize(uint32_t Entry) const
Returns the LocalSize execution mode for an entry point.
This class represents a SPIR-V type.
static std::shared_ptr< Module > load(const uint32_t *Words, size_t NumWords)
Create a new module from the supplied SPIR-V binary data.
Module & operator=(const Module &)=delete
This class represents an instruction result.
This class represents a SPIR-V instruction.
void addType(uint32_t Id, std::unique_ptr< Type > Ty)
Add a type to this module.
const Object & getObject(uint32_t Id) const
Returns the object with the specified ID.
void addSpecConstantOp(Instruction *Op)
Add a specialization constant operation instruction to this module.
uint32_t getSpecConstant(uint32_t SpecId) const
Returns the result ID for the given specialization constant ID.
FunctionMap Functions
Function mapping.
This class represents a shader entry point.
const VariableList & getVariables() const
Returns the list of module scope variables.