From 63ca1b5243f5e81697ce3fa10a9820f7dce04ebe Mon Sep 17 00:00:00 2001 From: ReinUsesLisp Date: Wed, 31 Oct 2018 22:20:49 -0300 Subject: [PATCH] Rename Ref alias to Id --- include/sirit/sirit.h | 118 +++++++++++++++++++-------------------- src/insts/annotation.cpp | 4 +- src/insts/constant.cpp | 14 ++--- src/insts/debug.cpp | 2 +- src/insts/flow.cpp | 14 ++--- src/insts/function.cpp | 6 +- src/insts/memory.cpp | 14 ++--- src/insts/misc.cpp | 2 +- src/insts/type.cpp | 40 ++++++------- src/op.cpp | 6 +- src/op.h | 6 +- src/sirit.cpp | 16 +++--- 12 files changed, 121 insertions(+), 121 deletions(-) diff --git a/include/sirit/sirit.h b/include/sirit/sirit.h index fe22c4e..2fa1d24 100644 --- a/include/sirit/sirit.h +++ b/include/sirit/sirit.h @@ -23,7 +23,7 @@ class Operand; using Literal = std::variant; -using Ref = const Op*; +using Id = const Op*; class Module { public: @@ -46,9 +46,9 @@ class Module { spv::MemoryModel memory_model); /// Adds an entry point. - void AddEntryPoint(spv::ExecutionModel execution_model, Ref entry_point, + void AddEntryPoint(spv::ExecutionModel execution_model, Id entry_point, const std::string& name, - const std::vector& interfaces = {}); + const std::vector& interfaces = {}); /** * Adds an instruction to module's code @@ -56,190 +56,190 @@ class Module { * be emitted. * @return Returns op. */ - Ref Emit(Ref op); + Id Emit(Id op); /** * Adds a global variable * @param variable Global variable to add. * @return Returns variable. */ - Ref AddGlobalVariable(Ref variable); + Id AddGlobalVariable(Id variable); // Types /// Returns type void. - Ref OpTypeVoid(); + Id OpTypeVoid(); /// Returns type bool. - Ref OpTypeBool(); + Id OpTypeBool(); /// Returns type integer. - Ref OpTypeInt(int width, bool is_signed); + Id OpTypeInt(int width, bool is_signed); /// Returns type float. - Ref OpTypeFloat(int width); + Id OpTypeFloat(int width); /// Returns type vector. - Ref OpTypeVector(Ref component_type, int component_count); + Id OpTypeVector(Id component_type, int component_count); /// Returns type matrix. - Ref OpTypeMatrix(Ref column_type, int column_count); + Id OpTypeMatrix(Id column_type, int column_count); /// Returns type image. - Ref OpTypeImage(Ref sampled_type, spv::Dim dim, int depth, bool arrayed, + Id OpTypeImage(Id sampled_type, spv::Dim dim, int depth, bool arrayed, bool ms, int sampled, spv::ImageFormat image_format, std::optional access_qualifier = {}); /// Returns type sampler. - Ref OpTypeSampler(); + Id OpTypeSampler(); /// Returns type sampled image. - Ref OpTypeSampledImage(Ref image_type); + Id OpTypeSampledImage(Id image_type); /// Returns type array. - Ref OpTypeArray(Ref element_type, Ref length); + Id OpTypeArray(Id element_type, Id length); /// Returns type runtime array. - Ref OpTypeRuntimeArray(Ref element_type); + Id OpTypeRuntimeArray(Id element_type); /// Returns type struct. - Ref OpTypeStruct(const std::vector& members = {}); + Id OpTypeStruct(const std::vector& members = {}); /// Returns type opaque. - Ref OpTypeOpaque(const std::string& name); + Id OpTypeOpaque(const std::string& name); /// Returns type pointer. - Ref OpTypePointer(spv::StorageClass storage_class, Ref type); + Id OpTypePointer(spv::StorageClass storage_class, Id type); /// Returns type function. - Ref OpTypeFunction(Ref return_type, const std::vector& arguments = {}); + Id OpTypeFunction(Id return_type, const std::vector& arguments = {}); /// Returns type event. - Ref OpTypeEvent(); + Id OpTypeEvent(); /// Returns type device event. - Ref OpTypeDeviceEvent(); + Id OpTypeDeviceEvent(); /// Returns type reserve id. - Ref OpTypeReserveId(); + Id OpTypeReserveId(); /// Returns type queue. - Ref OpTypeQueue(); + Id OpTypeQueue(); /// Returns type pipe. - Ref OpTypePipe(spv::AccessQualifier access_qualifier); + Id OpTypePipe(spv::AccessQualifier access_qualifier); // Constant /// Returns a true scalar constant. - Ref OpConstantTrue(Ref result_type); + Id OpConstantTrue(Id result_type); /// Returns a false scalar constant. - Ref OpConstantFalse(Ref result_type); + Id OpConstantFalse(Id result_type); /// Returns a numeric scalar constant. - Ref OpConstant(Ref result_type, const Literal& literal); + Id OpConstant(Id result_type, const Literal& literal); /// Returns a numeric scalar constant. - Ref OpConstantComposite(Ref result_type, - const std::vector& constituents); + Id OpConstantComposite(Id result_type, + const std::vector& constituents); /// Returns a sampler constant. - Ref OpConstantSampler(Ref result_type, + Id OpConstantSampler(Id result_type, spv::SamplerAddressingMode addressing_mode, bool normalized, spv::SamplerFilterMode filter_mode); /// Returns a null constant value. - Ref OpConstantNull(Ref result_type); + Id OpConstantNull(Id result_type); // Function /// Declares a function. - Ref OpFunction(Ref result_type, spv::FunctionControlMask function_control, - Ref function_type); + Id OpFunction(Id result_type, spv::FunctionControlMask function_control, + Id function_type); /// Ends a function. - Ref OpFunctionEnd(); + Id OpFunctionEnd(); // Flow /// Declare a structured loop. - Ref OpLoopMerge(Ref merge_block, Ref continue_target, + Id OpLoopMerge(Id merge_block, Id continue_target, spv::LoopControlMask loop_control, - const std::vector& literals = {}); + const std::vector& literals = {}); /// Declare a structured selection. - Ref OpSelectionMerge(Ref merge_block, + Id OpSelectionMerge(Id merge_block, spv::SelectionControlMask selection_control); /// The block label instruction: Any reference to a block is through this /// ref. - Ref OpLabel(); + Id OpLabel(); /// Unconditional jump to label. - Ref OpBranch(Ref target_label); + Id OpBranch(Id target_label); /// If condition is true branch to true_label, otherwise branch to /// false_label. - Ref OpBranchConditional(Ref condition, Ref true_label, Ref false_label, + Id OpBranchConditional(Id condition, Id true_label, Id false_label, std::uint32_t true_weight = 0, std::uint32_t false_weight = 0); /// Returns with no value from a function with void return type. - Ref OpReturn(); + Id OpReturn(); // Debug /// Assign a name string to a reference. /// @return target - Ref Name(Ref target, const std::string& name); + Id Name(Id target, const std::string& name); // Memory /// Allocate an object in memory, resulting in a copy to it. - Ref OpVariable(Ref result_type, spv::StorageClass storage_class, - Ref initializer = nullptr); + Id OpVariable(Id result_type, spv::StorageClass storage_class, + Id initializer = nullptr); /// Load through a pointer. - Ref OpLoad(Ref result_type, Ref pointer, + Id OpLoad(Id result_type, Id pointer, std::optional memory_access = {}); /// Store through a pointer. - Ref OpStore(Ref pointer, Ref object, + Id OpStore(Id pointer, Id object, std::optional memory_access = {}); /// Create a pointer into a composite object that can be used with OpLoad /// and OpStore. - Ref OpAccessChain(Ref result_type, Ref base, - const std::vector& indexes = {}); + Id OpAccessChain(Id result_type, Id base, + const std::vector& indexes = {}); /// Make a copy of a composite object, while modifying one part of it. - Ref OpCompositeInsert(Ref result_type, Ref object, Ref composite, + Id OpCompositeInsert(Id result_type, Id object, Id composite, const std::vector& indexes = {}); // Annotation /// Add a decoration to target. - Ref Decorate(Ref target, spv::Decoration decoration, + Id Decorate(Id target, spv::Decoration decoration, const std::vector& literals = {}); - Ref MemberDecorate(Ref structure_type, Literal member, + Id MemberDecorate(Id structure_type, Literal member, spv::Decoration decoration, const std::vector& literals = {}); // Misc /// Make an intermediate object whose value is undefined. - Ref OpUndef(Ref result_type); + Id OpUndef(Id result_type); private: - Ref AddCode(Op* op); + Id AddCode(Op* op); - Ref AddCode(spv::Op opcode, std::optional id = {}); + Id AddCode(spv::Op opcode, std::optional id = {}); - Ref AddDeclaration(Op* op); + Id AddDeclaration(Op* op); - Ref AddAnnotation(Op* op); + Id AddAnnotation(Op* op); std::uint32_t bound{1}; @@ -262,9 +262,9 @@ class Module { std::vector> declarations; - std::vector global_variables; + std::vector global_variables; - std::vector code; + std::vector code; std::vector> code_store; }; diff --git a/src/insts/annotation.cpp b/src/insts/annotation.cpp index 485ad6b..7fe9d37 100644 --- a/src/insts/annotation.cpp +++ b/src/insts/annotation.cpp @@ -9,7 +9,7 @@ namespace Sirit { -Ref Module::Decorate(Ref target, spv::Decoration decoration, +Id Module::Decorate(Id target, spv::Decoration decoration, const std::vector& literals) { auto op{new Op(spv::Op::OpDecorate)}; op->Add(target); @@ -18,7 +18,7 @@ Ref Module::Decorate(Ref target, spv::Decoration decoration, return AddAnnotation(op); } -Ref Module::MemberDecorate(Ref structure_type, Literal member, +Id Module::MemberDecorate(Id structure_type, Literal member, spv::Decoration decoration, const std::vector& literals) { auto op{new Op(spv::Op::OpMemberDecorate)}; diff --git a/src/insts/constant.cpp b/src/insts/constant.cpp index e3fe473..ec0c730 100644 --- a/src/insts/constant.cpp +++ b/src/insts/constant.cpp @@ -10,28 +10,28 @@ namespace Sirit { -Ref Module::OpConstantTrue(Ref result_type) { +Id Module::OpConstantTrue(Id result_type) { return AddDeclaration(new Op(spv::Op::OpConstantTrue, bound, result_type)); } -Ref Module::OpConstantFalse(Ref result_type) { +Id Module::OpConstantFalse(Id result_type) { return AddDeclaration(new Op(spv::Op::OpConstantFalse, bound, result_type)); } -Ref Module::OpConstant(Ref result_type, const Literal& literal) { +Id Module::OpConstant(Id result_type, const Literal& literal) { auto op{new Op(spv::Op::OpConstant, bound, result_type)}; op->Add(literal); return AddDeclaration(op); } -Ref Module::OpConstantComposite(Ref result_type, - const std::vector& constituents) { +Id Module::OpConstantComposite(Id result_type, + const std::vector& constituents) { auto op{new Op(spv::Op::OpConstantComposite, bound, result_type)}; op->Add(constituents); return AddDeclaration(op); } -Ref Module::OpConstantSampler(Ref result_type, +Id Module::OpConstantSampler(Id result_type, spv::SamplerAddressingMode addressing_mode, bool normalized, spv::SamplerFilterMode filter_mode) { @@ -44,7 +44,7 @@ Ref Module::OpConstantSampler(Ref result_type, return AddDeclaration(op); } -Ref Module::OpConstantNull(Ref result_type) { +Id Module::OpConstantNull(Id result_type) { return AddDeclaration(new Op(spv::Op::OpConstantNull, bound, result_type)); } diff --git a/src/insts/debug.cpp b/src/insts/debug.cpp index 3822dcc..04b544a 100644 --- a/src/insts/debug.cpp +++ b/src/insts/debug.cpp @@ -9,7 +9,7 @@ namespace Sirit { -Ref Module::Name(Ref target, const std::string& name) { +Id Module::Name(Id target, const std::string& name) { auto op{new Op(spv::Op::OpName)}; op->Add(target); op->Add(name); diff --git a/src/insts/flow.cpp b/src/insts/flow.cpp index d6dd9c5..f956d0c 100644 --- a/src/insts/flow.cpp +++ b/src/insts/flow.cpp @@ -9,9 +9,9 @@ namespace Sirit { -Ref Module::OpLoopMerge(Ref merge_block, Ref continue_target, +Id Module::OpLoopMerge(Id merge_block, Id continue_target, spv::LoopControlMask loop_control, - const std::vector& literals) { + const std::vector& literals) { auto op{new Op(spv::Op::OpLoopMerge)}; op->Add(merge_block); op->Add(continue_target); @@ -20,7 +20,7 @@ Ref Module::OpLoopMerge(Ref merge_block, Ref continue_target, return AddCode(op); } -Ref Module::OpSelectionMerge(Ref merge_block, +Id Module::OpSelectionMerge(Id merge_block, spv::SelectionControlMask selection_control) { auto op{new Op(spv::Op::OpSelectionMerge)}; op->Add(merge_block); @@ -28,15 +28,15 @@ Ref Module::OpSelectionMerge(Ref merge_block, return AddCode(op); } -Ref Module::OpLabel() { return AddCode(spv::Op::OpLabel, bound++); } +Id Module::OpLabel() { return AddCode(spv::Op::OpLabel, bound++); } -Ref Module::OpBranch(Ref target_label) { +Id Module::OpBranch(Id target_label) { auto op{new Op(spv::Op::OpBranch)}; op->Add(target_label); return AddCode(op); } -Ref Module::OpBranchConditional(Ref condition, Ref true_label, Ref false_label, +Id Module::OpBranchConditional(Id condition, Id true_label, Id false_label, std::uint32_t true_weight, std::uint32_t false_weight) { auto op{new Op(spv::Op::OpBranchConditional)}; @@ -50,6 +50,6 @@ Ref Module::OpBranchConditional(Ref condition, Ref true_label, Ref false_label, return AddCode(op); } -Ref Module::OpReturn() { return AddCode(spv::Op::OpReturn); } +Id Module::OpReturn() { return AddCode(spv::Op::OpReturn); } } // namespace Sirit diff --git a/src/insts/function.cpp b/src/insts/function.cpp index a7857ea..f686d64 100644 --- a/src/insts/function.cpp +++ b/src/insts/function.cpp @@ -9,15 +9,15 @@ namespace Sirit { -Ref Module::OpFunction(Ref result_type, +Id Module::OpFunction(Id result_type, spv::FunctionControlMask function_control, - Ref function_type) { + Id function_type) { auto op{new Op{spv::Op::OpFunction, bound++, result_type}}; op->Add(static_cast(function_control)); op->Add(function_type); return AddCode(op); } -Ref Module::OpFunctionEnd() { return AddCode(spv::Op::OpFunctionEnd); } +Id Module::OpFunctionEnd() { return AddCode(spv::Op::OpFunctionEnd); } } // namespace Sirit diff --git a/src/insts/memory.cpp b/src/insts/memory.cpp index 139a04c..d7fc3ff 100644 --- a/src/insts/memory.cpp +++ b/src/insts/memory.cpp @@ -10,8 +10,8 @@ namespace Sirit { -Ref Module::OpVariable(Ref result_type, spv::StorageClass storage_class, - Ref initializer) { +Id Module::OpVariable(Id result_type, spv::StorageClass storage_class, + Id initializer) { auto op{new Op(spv::Op::OpVariable, bound++, result_type)}; AddEnum(op, storage_class); if (initializer) { @@ -20,7 +20,7 @@ Ref Module::OpVariable(Ref result_type, spv::StorageClass storage_class, return AddCode(op); } -Ref Module::OpLoad(Ref result_type, Ref pointer, +Id Module::OpLoad(Id result_type, Id pointer, std::optional memory_access) { auto op{new Op(spv::Op::OpLoad, bound++, result_type)}; op->Add(pointer); @@ -30,7 +30,7 @@ Ref Module::OpLoad(Ref result_type, Ref pointer, return AddCode(op); } -Ref Module::OpStore(Ref pointer, Ref object, +Id Module::OpStore(Id pointer, Id object, std::optional memory_access) { auto op{new Op(spv::Op::OpStore)}; op->Add(pointer); @@ -41,8 +41,8 @@ Ref Module::OpStore(Ref pointer, Ref object, return AddCode(op); } -Ref Module::OpAccessChain(Ref result_type, Ref base, - const std::vector& indexes) { +Id Module::OpAccessChain(Id result_type, Id base, + const std::vector& indexes) { assert(indexes.size() > 0); auto op{new Op(spv::Op::OpAccessChain, bound++, result_type)}; op->Add(base); @@ -50,7 +50,7 @@ Ref Module::OpAccessChain(Ref result_type, Ref base, return AddCode(op); } -Ref Module::OpCompositeInsert(Ref result_type, Ref object, Ref composite, +Id Module::OpCompositeInsert(Id result_type, Id object, Id composite, const std::vector& indexes) { auto op{new Op(spv::Op::OpCompositeInsert, bound++, result_type)}; op->Add(object); diff --git a/src/insts/misc.cpp b/src/insts/misc.cpp index 38674dc..2cd544d 100644 --- a/src/insts/misc.cpp +++ b/src/insts/misc.cpp @@ -10,7 +10,7 @@ namespace Sirit { -Ref Module::OpUndef(Ref result_type) { +Id Module::OpUndef(Id result_type) { return AddCode(new Op(spv::Op::OpUndef, bound++, result_type)); } diff --git a/src/insts/type.cpp b/src/insts/type.cpp index 5c70a3f..290b1ff 100644 --- a/src/insts/type.cpp +++ b/src/insts/type.cpp @@ -12,15 +12,15 @@ namespace Sirit { -Ref Module::OpTypeVoid() { +Id Module::OpTypeVoid() { return AddDeclaration(new Op(spv::Op::OpTypeVoid, bound)); } -Ref Module::OpTypeBool() { +Id Module::OpTypeBool() { return AddDeclaration(new Op(spv::Op::OpTypeBool, bound)); } -Ref Module::OpTypeInt(int width, bool is_signed) { +Id Module::OpTypeInt(int width, bool is_signed) { if (width == 8) { AddCapability(spv::Capability::Int8); } else if (width == 16) { @@ -34,7 +34,7 @@ Ref Module::OpTypeInt(int width, bool is_signed) { return AddDeclaration(op); } -Ref Module::OpTypeFloat(int width) { +Id Module::OpTypeFloat(int width) { if (width == 16) { AddCapability(spv::Capability::Float16); } else if (width == 64) { @@ -45,7 +45,7 @@ Ref Module::OpTypeFloat(int width) { return AddDeclaration(op); } -Ref Module::OpTypeVector(Ref component_type, int component_count) { +Id Module::OpTypeVector(Id component_type, int component_count) { assert(component_count >= 2); auto op{new Op(spv::Op::OpTypeVector, bound)}; op->Add(component_type); @@ -53,7 +53,7 @@ Ref Module::OpTypeVector(Ref component_type, int component_count) { return AddDeclaration(op); } -Ref Module::OpTypeMatrix(Ref column_type, int column_count) { +Id Module::OpTypeMatrix(Id column_type, int column_count) { assert(column_count >= 2); AddCapability(spv::Capability::Matrix); Op* op{new Op(spv::Op::OpTypeMatrix, bound)}; @@ -62,7 +62,7 @@ Ref Module::OpTypeMatrix(Ref column_type, int column_count) { return AddDeclaration(op); } -Ref Module::OpTypeImage(Ref sampled_type, spv::Dim dim, int depth, bool arrayed, +Id Module::OpTypeImage(Id sampled_type, spv::Dim dim, int depth, bool arrayed, bool ms, int sampled, spv::ImageFormat image_format, std::optional access_qualifier) { switch (dim) { @@ -140,44 +140,44 @@ Ref Module::OpTypeImage(Ref sampled_type, spv::Dim dim, int depth, bool arrayed, return AddDeclaration(op); } -Ref Module::OpTypeSampler() { +Id Module::OpTypeSampler() { return AddDeclaration(new Op(spv::Op::OpTypeSampler, bound)); } -Ref Module::OpTypeSampledImage(Ref image_type) { +Id Module::OpTypeSampledImage(Id image_type) { auto op{new Op(spv::Op::OpTypeSampledImage, bound)}; op->Add(image_type); return AddDeclaration(op); } -Ref Module::OpTypeArray(Ref element_type, Ref length) { +Id Module::OpTypeArray(Id element_type, Id length) { auto op{new Op(spv::Op::OpTypeArray, bound)}; op->Add(element_type); op->Add(length); return AddDeclaration(op); } -Ref Module::OpTypeRuntimeArray(Ref element_type) { +Id Module::OpTypeRuntimeArray(Id element_type) { AddCapability(spv::Capability::Shader); auto op{new Op(spv::Op::OpTypeRuntimeArray, bound)}; op->Add(element_type); return AddDeclaration(op); } -Ref Module::OpTypeStruct(const std::vector& members) { +Id Module::OpTypeStruct(const std::vector& members) { auto op{new Op(spv::Op::OpTypeStruct, bound)}; op->Add(members); return AddDeclaration(op); } -Ref Module::OpTypeOpaque(const std::string& name) { +Id Module::OpTypeOpaque(const std::string& name) { AddCapability(spv::Capability::Kernel); auto op{new Op(spv::Op::OpTypeOpaque, bound)}; op->Add(name); return AddDeclaration(op); } -Ref Module::OpTypePointer(spv::StorageClass storage_class, Ref type) { +Id Module::OpTypePointer(spv::StorageClass storage_class, Id type) { switch (storage_class) { case spv::StorageClass::Uniform: case spv::StorageClass::Output: @@ -199,34 +199,34 @@ Ref Module::OpTypePointer(spv::StorageClass storage_class, Ref type) { return AddDeclaration(op); } -Ref Module::OpTypeFunction(Ref return_type, const std::vector& arguments) { +Id Module::OpTypeFunction(Id return_type, const std::vector& arguments) { auto op{new Op(spv::Op::OpTypeFunction, bound)}; op->Add(return_type); op->Add(arguments); return AddDeclaration(op); } -Ref Module::OpTypeEvent() { +Id Module::OpTypeEvent() { AddCapability(spv::Capability::Kernel); return AddDeclaration(new Op(spv::Op::OpTypeEvent, bound)); } -Ref Module::OpTypeDeviceEvent() { +Id Module::OpTypeDeviceEvent() { AddCapability(spv::Capability::DeviceEnqueue); return AddDeclaration(new Op(spv::Op::OpTypeDeviceEvent, bound)); } -Ref Module::OpTypeReserveId() { +Id Module::OpTypeReserveId() { AddCapability(spv::Capability::Pipes); return AddDeclaration(new Op(spv::Op::OpTypeReserveId, bound)); } -Ref Module::OpTypeQueue() { +Id Module::OpTypeQueue() { AddCapability(spv::Capability::DeviceEnqueue); return AddDeclaration(new Op(spv::Op::OpTypeQueue, bound)); } -Ref Module::OpTypePipe(spv::AccessQualifier access_qualifier) { +Id Module::OpTypePipe(spv::AccessQualifier access_qualifier) { AddCapability(spv::Capability::Pipes); auto op{new Op(spv::Op::OpTypePipe, bound)}; op->Add(static_cast(access_qualifier)); diff --git a/src/op.cpp b/src/op.cpp index ed65977..86a4126 100644 --- a/src/op.cpp +++ b/src/op.cpp @@ -14,7 +14,7 @@ namespace Sirit { -Op::Op(spv::Op opcode, std::optional id, Ref result_type) +Op::Op(spv::Op opcode, std::optional id, Id result_type) : opcode(opcode), id(id), result_type(result_type) { operand_type = OperandType::Op; } @@ -106,8 +106,8 @@ void Op::Add(u32 integer) { Sink(LiteralNumber::Create(integer)); } void Op::Add(const std::string& string) { Sink(new LiteralString(string)); } -void Op::Add(const std::vector& ids) { - for (Ref op : ids) { +void Op::Add(const std::vector& ids) { + for (Id op : ids) { Add(op); } } diff --git a/src/op.h b/src/op.h index 0e13cdd..4f5f479 100644 --- a/src/op.h +++ b/src/op.h @@ -17,7 +17,7 @@ namespace Sirit { class Op : public Operand { public: explicit Op(spv::Op opcode, std::optional id = {}, - Ref result_type = nullptr); + Id result_type = nullptr); ~Op(); virtual void Fetch(Stream& stream) const; @@ -41,14 +41,14 @@ class Op : public Operand { void Add(const std::string& string); - void Add(const std::vector& ids); + void Add(const std::vector& ids); private: u16 WordCount() const; spv::Op opcode; - Ref result_type; + Id result_type; std::optional id; diff --git a/src/sirit.cpp b/src/sirit.cpp index 9132958..bb92a13 100644 --- a/src/sirit.cpp +++ b/src/sirit.cpp @@ -72,9 +72,9 @@ void Module::SetMemoryModel(spv::AddressingModel addressing_model, this->memory_model = memory_model; } -void Module::AddEntryPoint(spv::ExecutionModel execution_model, Ref entry_point, +void Module::AddEntryPoint(spv::ExecutionModel execution_model, Id entry_point, const std::string& name, - const std::vector& interfaces) { + const std::vector& interfaces) { auto const op{new Op(spv::Op::OpEntryPoint)}; op->Add(static_cast(execution_model)); op->Add(entry_point); @@ -83,29 +83,29 @@ void Module::AddEntryPoint(spv::ExecutionModel execution_model, Ref entry_point, entry_points.push_back(std::unique_ptr(op)); } -Ref Module::Emit(Ref op) { +Id Module::Emit(Id op) { assert(op); code.push_back(op); return op; } -Ref Module::AddGlobalVariable(Ref variable) { +Id Module::AddGlobalVariable(Id variable) { assert(variable); global_variables.push_back(variable); return variable; } -Ref Module::AddCode(Op* op) { +Id Module::AddCode(Op* op) { assert(op); code_store.push_back(std::unique_ptr(op)); return op; } -Ref Module::AddCode(spv::Op opcode, std::optional id) { +Id Module::AddCode(spv::Op opcode, std::optional id) { return AddCode(new Op(opcode, id)); } -Ref Module::AddDeclaration(Op* op) { +Id Module::AddDeclaration(Op* op) { const auto& found{ std::find_if(declarations.begin(), declarations.end(), [&op](const auto& other) { return *other == *op; })}; @@ -119,7 +119,7 @@ Ref Module::AddDeclaration(Op* op) { } } -Ref Module::AddAnnotation(Op* op) { +Id Module::AddAnnotation(Op* op) { assert(op); annotations.push_back(std::unique_ptr(op)); return op;