Add various accessors needed to read and edit SPIRV code.

This commit is contained in:
David Srbecky 2017-03-26 20:08:41 +01:00
parent 7fe8a57a5b
commit b85997a1df
4 changed files with 8 additions and 0 deletions

View File

@ -44,6 +44,8 @@ class BasicBlock {
void SetParent(Function* function) { function_ = function; }
// Appends an instruction to this basic block.
inline void AddInstruction(std::unique_ptr<Instruction> i);
// The label starting this basic block.
Instruction& Label() { return *label_; }
iterator begin() { return iterator(&insts_, insts_.begin()); }
iterator end() { return iterator(&insts_, insts_.end()); }

View File

@ -38,6 +38,8 @@ class Function {
// Creates a function instance declared by the given OpFunction instruction
// |def_inst|.
inline explicit Function(std::unique_ptr<Instruction> def_inst);
// The OpFunction instruction that begins the definition of this function.
Instruction& DefInst() { return *def_inst_; }
// Sets the enclosing module for this function.
void SetParent(Module* module) { module_ = module; }

View File

@ -52,6 +52,8 @@ class Module {
void SetHeader(const ModuleHeader& header) { header_ = header; }
// Sets the Id bound.
void SetIdBound(uint32_t bound) { header_.bound = bound; }
// Returns the Id bound.
uint32_t IdBound() { return header_.bound; }
// Appends a capability instruction to this module.
inline void AddCapability(std::unique_ptr<Instruction> c);
// Appends an extension instruction to this module.

View File

@ -231,6 +231,7 @@ class Array : public Type {
bool IsSame(Type* that) const override;
std::string str() const override;
const Type* element_type() const { return element_type_; }
uint32_t LengthId() const { return length_id_; }
Array* AsArray() override { return this; }
const Array* AsArray() const override { return this; }
@ -265,6 +266,7 @@ class Struct : public Type {
bool IsSame(Type* that) const override;
std::string str() const override;
const std::vector<Type*>& element_types() const { return element_types_; }
bool decoration_empty() const override {
return decorations_.empty() && element_decorations_.empty();
}