diff --git a/include/sirit/sirit.h b/include/sirit/sirit.h index 7061621..272362c 100644 --- a/include/sirit/sirit.h +++ b/include/sirit/sirit.h @@ -68,154 +68,154 @@ class Module { // Types /// Returns type void. - Ref TypeVoid(); + Ref OpTypeVoid(); /// Returns type bool. - Ref TypeBool(); + Ref OpTypeBool(); /// Returns type integer. - Ref TypeInt(int width, bool is_signed); + Ref OpTypeInt(int width, bool is_signed); /// Returns type float. - Ref TypeFloat(int width); + Ref OpTypeFloat(int width); /// Returns type vector. - Ref TypeVector(Ref component_type, int component_count); + Ref OpTypeVector(Ref component_type, int component_count); /// Returns type matrix. - Ref TypeMatrix(Ref column_type, int column_count); + Ref OpTypeMatrix(Ref column_type, int column_count); /// Returns type image. - Ref TypeImage(Ref sampled_type, spv::Dim dim, int depth, bool arrayed, - bool ms, int sampled, spv::ImageFormat image_format, - std::optional access_qualifier = {}); + Ref OpTypeImage(Ref 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 TypeSampler(); + Ref OpTypeSampler(); /// Returns type sampled image. - Ref TypeSampledImage(Ref image_type); + Ref OpTypeSampledImage(Ref image_type); /// Returns type array. - Ref TypeArray(Ref element_type, Ref length); + Ref OpTypeArray(Ref element_type, Ref length); /// Returns type runtime array. - Ref TypeRuntimeArray(Ref element_type); + Ref OpTypeRuntimeArray(Ref element_type); /// Returns type struct. - Ref TypeStruct(const std::vector& members = {}); + Ref OpTypeStruct(const std::vector& members = {}); /// Returns type opaque. - Ref TypeOpaque(const std::string& name); + Ref OpTypeOpaque(const std::string& name); /// Returns type pointer. - Ref TypePointer(spv::StorageClass storage_class, Ref type); + Ref OpTypePointer(spv::StorageClass storage_class, Ref type); /// Returns type function. - Ref TypeFunction(Ref return_type, const std::vector& arguments = {}); + Ref OpTypeFunction(Ref return_type, const std::vector& arguments = {}); /// Returns type event. - Ref TypeEvent(); + Ref OpTypeEvent(); /// Returns type device event. - Ref TypeDeviceEvent(); + Ref OpTypeDeviceEvent(); /// Returns type reserve id. - Ref TypeReserveId(); + Ref OpTypeReserveId(); /// Returns type queue. - Ref TypeQueue(); + Ref OpTypeQueue(); /// Returns type pipe. - Ref TypePipe(spv::AccessQualifier access_qualifier); + Ref OpTypePipe(spv::AccessQualifier access_qualifier); // Constant /// Returns a true scalar constant. - Ref ConstantTrue(Ref result_type); + Ref OpConstantTrue(Ref result_type); /// Returns a false scalar constant. - Ref ConstantFalse(Ref result_type); + Ref OpConstantFalse(Ref result_type); /// Returns a numeric scalar constant. - Ref Constant(Ref result_type, const Literal& literal); + Ref OpConstant(Ref result_type, const Literal& literal); /// Returns a numeric scalar constant. - Ref ConstantComposite(Ref result_type, - const std::vector& constituents); + Ref OpConstantComposite(Ref result_type, + const std::vector& constituents); /// Returns a sampler constant. - Ref ConstantSampler(Ref result_type, - spv::SamplerAddressingMode addressing_mode, - bool normalized, spv::SamplerFilterMode filter_mode); + Ref OpConstantSampler(Ref result_type, + spv::SamplerAddressingMode addressing_mode, + bool normalized, spv::SamplerFilterMode filter_mode); /// Returns a null constant value. - Ref ConstantNull(Ref result_type); + Ref OpConstantNull(Ref result_type); // Function /// Declares a function. - Ref Function(Ref result_type, spv::FunctionControlMask function_control, - Ref function_type); + Ref OpFunction(Ref result_type, spv::FunctionControlMask function_control, + Ref function_type); /// Ends a function. - Ref FunctionEnd(); + Ref OpFunctionEnd(); // Flow /// Declare a structured loop. - Ref LoopMerge(Ref merge_block, Ref continue_target, - spv::LoopControlMask loop_control, - const std::vector& literals = {}); + Ref OpLoopMerge(Ref merge_block, Ref continue_target, + spv::LoopControlMask loop_control, + const std::vector& literals = {}); /// Declare a structured selection. - Ref SelectionMerge(Ref merge_block, - spv::SelectionControlMask selection_control); + Ref OpSelectionMerge(Ref merge_block, + spv::SelectionControlMask selection_control); /// The block label instruction: Any reference to a block is through this /// ref. - Ref Label(); + Ref OpLabel(); /// Unconditional jump to label. - Ref Branch(Ref target_label); + Ref OpBranch(Ref target_label); /// If condition is true branch to true_label, otherwise branch to /// false_label. - Ref BranchConditional(Ref condition, Ref true_label, Ref false_label, - std::uint32_t true_weight = 0, - std::uint32_t false_weight = 0); + Ref OpBranchConditional(Ref condition, Ref true_label, Ref 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 Return(); + Ref OpReturn(); // Debug /// Assign a name string to a reference. /// @return target - Ref Name(Ref target, const std::string& name); + Ref OpName(Ref target, const std::string& name); // Memory /// Allocate an object in memory, resulting in a copy to it. - Ref Variable(Ref result_type, spv::StorageClass storage_class, - Ref initializer = nullptr); + Ref OpVariable(Ref result_type, spv::StorageClass storage_class, + Ref initializer = nullptr); /// Load through a pointer. - Ref Load(Ref result_type, Ref pointer, - std::optional memory_access = {}); + Ref OpLoad(Ref result_type, Ref pointer, + std::optional memory_access = {}); /// Store through a pointer. - Ref Store(Ref pointer, Ref object, - std::optional memory_access = {}); + Ref OpStore(Ref pointer, Ref object, + std::optional memory_access = {}); /// Create a pointer into a composite object that can be used with OpLoad /// and OpStore. - Ref AccessChain(Ref result_type, Ref base, - const std::vector& indexes = {}); + Ref OpAccessChain(Ref result_type, Ref base, + const std::vector& indexes = {}); /// Make a copy of a composite object, while modifying one part of it. - Ref CompositeInsert(Ref result_type, Ref object, Ref composite, - const std::vector& indexes = {}); + Ref OpCompositeInsert(Ref result_type, Ref object, Ref composite, + const std::vector& indexes = {}); // Annotation @@ -230,7 +230,7 @@ class Module { // Misc /// Make an intermediate object whose value is undefined. - Ref Undef(Ref result_type); + Ref OpUndef(Ref result_type); private: Ref AddCode(Op* op); diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 08fa9be..86e33d3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -7,10 +7,10 @@ add_library(sirit stream.h operand.cpp operand.h - literal-number.cpp - literal-number.h - literal-string.cpp - literal-string.h + literal_number.cpp + literal_number.h + literal_string.cpp + literal_string.h common_types.h insts.h insts/type.cpp diff --git a/src/insts/constant.cpp b/src/insts/constant.cpp index d5e8802..e3fe473 100644 --- a/src/insts/constant.cpp +++ b/src/insts/constant.cpp @@ -10,31 +10,31 @@ namespace Sirit { -Ref Module::ConstantTrue(Ref result_type) { +Ref Module::OpConstantTrue(Ref result_type) { return AddDeclaration(new Op(spv::Op::OpConstantTrue, bound, result_type)); } -Ref Module::ConstantFalse(Ref result_type) { +Ref Module::OpConstantFalse(Ref result_type) { return AddDeclaration(new Op(spv::Op::OpConstantFalse, bound, result_type)); } -Ref Module::Constant(Ref result_type, const Literal& literal) { +Ref Module::OpConstant(Ref result_type, const Literal& literal) { auto op{new Op(spv::Op::OpConstant, bound, result_type)}; op->Add(literal); return AddDeclaration(op); } -Ref Module::ConstantComposite(Ref result_type, - const std::vector& constituents) { +Ref Module::OpConstantComposite(Ref result_type, + const std::vector& constituents) { auto op{new Op(spv::Op::OpConstantComposite, bound, result_type)}; op->Add(constituents); return AddDeclaration(op); } -Ref Module::ConstantSampler(Ref result_type, - spv::SamplerAddressingMode addressing_mode, - bool normalized, - spv::SamplerFilterMode filter_mode) { +Ref Module::OpConstantSampler(Ref result_type, + spv::SamplerAddressingMode addressing_mode, + bool normalized, + spv::SamplerFilterMode filter_mode) { AddCapability(spv::Capability::LiteralSampler); AddCapability(spv::Capability::Kernel); auto op{new Op(spv::Op::OpConstantSampler, bound, result_type)}; @@ -44,7 +44,7 @@ Ref Module::ConstantSampler(Ref result_type, return AddDeclaration(op); } -Ref Module::ConstantNull(Ref result_type) { +Ref Module::OpConstantNull(Ref 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..26b1f2a 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) { +Ref Module::OpName(Ref 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 c88df40..d6dd9c5 100644 --- a/src/insts/flow.cpp +++ b/src/insts/flow.cpp @@ -9,9 +9,9 @@ namespace Sirit { -Ref Module::LoopMerge(Ref merge_block, Ref continue_target, - spv::LoopControlMask loop_control, - const std::vector& literals) { +Ref Module::OpLoopMerge(Ref merge_block, Ref continue_target, + spv::LoopControlMask loop_control, + const std::vector& literals) { auto op{new Op(spv::Op::OpLoopMerge)}; op->Add(merge_block); op->Add(continue_target); @@ -20,25 +20,25 @@ Ref Module::LoopMerge(Ref merge_block, Ref continue_target, return AddCode(op); } -Ref Module::SelectionMerge(Ref merge_block, - spv::SelectionControlMask selection_control) { +Ref Module::OpSelectionMerge(Ref merge_block, + spv::SelectionControlMask selection_control) { auto op{new Op(spv::Op::OpSelectionMerge)}; op->Add(merge_block); AddEnum(op, selection_control); return AddCode(op); } -Ref Module::Label() { return AddCode(spv::Op::OpLabel, bound++); } +Ref Module::OpLabel() { return AddCode(spv::Op::OpLabel, bound++); } -Ref Module::Branch(Ref target_label) { +Ref Module::OpBranch(Ref target_label) { auto op{new Op(spv::Op::OpBranch)}; op->Add(target_label); return AddCode(op); } -Ref Module::BranchConditional(Ref condition, Ref true_label, Ref false_label, - std::uint32_t true_weight, - std::uint32_t false_weight) { +Ref Module::OpBranchConditional(Ref condition, Ref true_label, Ref false_label, + std::uint32_t true_weight, + std::uint32_t false_weight) { auto op{new Op(spv::Op::OpBranchConditional)}; op->Add(condition); op->Add(true_label); @@ -50,6 +50,6 @@ Ref Module::BranchConditional(Ref condition, Ref true_label, Ref false_label, return AddCode(op); } -Ref Module::Return() { return AddCode(spv::Op::OpReturn); } +Ref Module::OpReturn() { return AddCode(spv::Op::OpReturn); } } // namespace Sirit diff --git a/src/insts/function.cpp b/src/insts/function.cpp index efcc2c6..a7857ea 100644 --- a/src/insts/function.cpp +++ b/src/insts/function.cpp @@ -9,14 +9,15 @@ namespace Sirit { -Ref Module::Function(Ref result_type, spv::FunctionControlMask function_control, - Ref function_type) { +Ref Module::OpFunction(Ref result_type, + spv::FunctionControlMask function_control, + Ref 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::FunctionEnd() { return AddCode(spv::Op::OpFunctionEnd); } +Ref Module::OpFunctionEnd() { return AddCode(spv::Op::OpFunctionEnd); } } // namespace Sirit diff --git a/src/insts/memory.cpp b/src/insts/memory.cpp index de1373d..139a04c 100644 --- a/src/insts/memory.cpp +++ b/src/insts/memory.cpp @@ -10,8 +10,8 @@ namespace Sirit { -Ref Module::Variable(Ref result_type, spv::StorageClass storage_class, - Ref initializer) { +Ref Module::OpVariable(Ref result_type, spv::StorageClass storage_class, + Ref initializer) { auto op{new Op(spv::Op::OpVariable, bound++, result_type)}; AddEnum(op, storage_class); if (initializer) { @@ -20,8 +20,8 @@ Ref Module::Variable(Ref result_type, spv::StorageClass storage_class, return AddCode(op); } -Ref Module::Load(Ref result_type, Ref pointer, - std::optional memory_access) { +Ref Module::OpLoad(Ref result_type, Ref pointer, + std::optional memory_access) { auto op{new Op(spv::Op::OpLoad, bound++, result_type)}; op->Add(pointer); if (memory_access) { @@ -30,8 +30,8 @@ Ref Module::Load(Ref result_type, Ref pointer, return AddCode(op); } -Ref Module::Store(Ref pointer, Ref object, - std::optional memory_access) { +Ref Module::OpStore(Ref pointer, Ref object, + std::optional memory_access) { auto op{new Op(spv::Op::OpStore)}; op->Add(pointer); op->Add(object); @@ -41,8 +41,8 @@ Ref Module::Store(Ref pointer, Ref object, return AddCode(op); } -Ref Module::AccessChain(Ref result_type, Ref base, - const std::vector& indexes) { +Ref Module::OpAccessChain(Ref result_type, Ref base, + const std::vector& indexes) { assert(indexes.size() > 0); auto op{new Op(spv::Op::OpAccessChain, bound++, result_type)}; op->Add(base); @@ -50,8 +50,8 @@ Ref Module::AccessChain(Ref result_type, Ref base, return AddCode(op); } -Ref Module::CompositeInsert(Ref result_type, Ref object, Ref composite, - const std::vector& indexes) { +Ref Module::OpCompositeInsert(Ref result_type, Ref object, Ref composite, + const std::vector& indexes) { auto op{new Op(spv::Op::OpCompositeInsert, bound++, result_type)}; op->Add(object); op->Add(composite); diff --git a/src/insts/misc.cpp b/src/insts/misc.cpp index e21d00e..38674dc 100644 --- a/src/insts/misc.cpp +++ b/src/insts/misc.cpp @@ -10,7 +10,7 @@ namespace Sirit { -Ref Module::Undef(Ref result_type) { +Ref Module::OpUndef(Ref 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 2587ff4..5c70a3f 100644 --- a/src/insts/type.cpp +++ b/src/insts/type.cpp @@ -12,15 +12,15 @@ namespace Sirit { -Ref Module::TypeVoid() { +Ref Module::OpTypeVoid() { return AddDeclaration(new Op(spv::Op::OpTypeVoid, bound)); } -Ref Module::TypeBool() { +Ref Module::OpTypeBool() { return AddDeclaration(new Op(spv::Op::OpTypeBool, bound)); } -Ref Module::TypeInt(int width, bool is_signed) { +Ref Module::OpTypeInt(int width, bool is_signed) { if (width == 8) { AddCapability(spv::Capability::Int8); } else if (width == 16) { @@ -34,7 +34,7 @@ Ref Module::TypeInt(int width, bool is_signed) { return AddDeclaration(op); } -Ref Module::TypeFloat(int width) { +Ref Module::OpTypeFloat(int width) { if (width == 16) { AddCapability(spv::Capability::Float16); } else if (width == 64) { @@ -45,7 +45,7 @@ Ref Module::TypeFloat(int width) { return AddDeclaration(op); } -Ref Module::TypeVector(Ref component_type, int component_count) { +Ref Module::OpTypeVector(Ref 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::TypeVector(Ref component_type, int component_count) { return AddDeclaration(op); } -Ref Module::TypeMatrix(Ref column_type, int column_count) { +Ref Module::OpTypeMatrix(Ref column_type, int column_count) { assert(column_count >= 2); AddCapability(spv::Capability::Matrix); Op* op{new Op(spv::Op::OpTypeMatrix, bound)}; @@ -62,9 +62,9 @@ Ref Module::TypeMatrix(Ref column_type, int column_count) { return AddDeclaration(op); } -Ref Module::TypeImage(Ref sampled_type, spv::Dim dim, int depth, bool arrayed, - bool ms, int sampled, spv::ImageFormat image_format, - std::optional access_qualifier) { +Ref Module::OpTypeImage(Ref sampled_type, spv::Dim dim, int depth, bool arrayed, + bool ms, int sampled, spv::ImageFormat image_format, + std::optional access_qualifier) { switch (dim) { case spv::Dim::Dim1D: AddCapability(spv::Capability::Sampled1D); @@ -140,44 +140,44 @@ Ref Module::TypeImage(Ref sampled_type, spv::Dim dim, int depth, bool arrayed, return AddDeclaration(op); } -Ref Module::TypeSampler() { +Ref Module::OpTypeSampler() { return AddDeclaration(new Op(spv::Op::OpTypeSampler, bound)); } -Ref Module::TypeSampledImage(Ref image_type) { +Ref Module::OpTypeSampledImage(Ref image_type) { auto op{new Op(spv::Op::OpTypeSampledImage, bound)}; op->Add(image_type); return AddDeclaration(op); } -Ref Module::TypeArray(Ref element_type, Ref length) { +Ref Module::OpTypeArray(Ref element_type, Ref length) { auto op{new Op(spv::Op::OpTypeArray, bound)}; op->Add(element_type); op->Add(length); return AddDeclaration(op); } -Ref Module::TypeRuntimeArray(Ref element_type) { +Ref Module::OpTypeRuntimeArray(Ref element_type) { AddCapability(spv::Capability::Shader); auto op{new Op(spv::Op::OpTypeRuntimeArray, bound)}; op->Add(element_type); return AddDeclaration(op); } -Ref Module::TypeStruct(const std::vector& members) { +Ref Module::OpTypeStruct(const std::vector& members) { auto op{new Op(spv::Op::OpTypeStruct, bound)}; op->Add(members); return AddDeclaration(op); } -Ref Module::TypeOpaque(const std::string& name) { +Ref 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::TypePointer(spv::StorageClass storage_class, Ref type) { +Ref Module::OpTypePointer(spv::StorageClass storage_class, Ref type) { switch (storage_class) { case spv::StorageClass::Uniform: case spv::StorageClass::Output: @@ -199,34 +199,34 @@ Ref Module::TypePointer(spv::StorageClass storage_class, Ref type) { return AddDeclaration(op); } -Ref Module::TypeFunction(Ref return_type, const std::vector& arguments) { +Ref Module::OpTypeFunction(Ref 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::TypeEvent() { +Ref Module::OpTypeEvent() { AddCapability(spv::Capability::Kernel); return AddDeclaration(new Op(spv::Op::OpTypeEvent, bound)); } -Ref Module::TypeDeviceEvent() { +Ref Module::OpTypeDeviceEvent() { AddCapability(spv::Capability::DeviceEnqueue); return AddDeclaration(new Op(spv::Op::OpTypeDeviceEvent, bound)); } -Ref Module::TypeReserveId() { +Ref Module::OpTypeReserveId() { AddCapability(spv::Capability::Pipes); return AddDeclaration(new Op(spv::Op::OpTypeReserveId, bound)); } -Ref Module::TypeQueue() { +Ref Module::OpTypeQueue() { AddCapability(spv::Capability::DeviceEnqueue); return AddDeclaration(new Op(spv::Op::OpTypeQueue, bound)); } -Ref Module::TypePipe(spv::AccessQualifier access_qualifier) { +Ref 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/literal-number.cpp b/src/literal_number.cpp similarity index 97% rename from src/literal-number.cpp rename to src/literal_number.cpp index 8c8a56a..b630093 100644 --- a/src/literal-number.cpp +++ b/src/literal_number.cpp @@ -4,7 +4,7 @@ * Lesser General Public License version 2.1 or any later version. */ -#include "literal-number.h" +#include "literal_number.h" #include namespace Sirit { diff --git a/src/literal-number.h b/src/literal_number.h similarity index 97% rename from src/literal-number.h rename to src/literal_number.h index 8beb169..a20b223 100644 --- a/src/literal-number.h +++ b/src/literal_number.h @@ -24,6 +24,7 @@ class LiteralNumber : public Operand { template static LiteralNumber* Create(T value) { static_assert(sizeof(T) == 4 || sizeof(T) == 8); + LiteralNumber* number = new LiteralNumber(std::type_index(typeid(T))); if (number->is_32 = sizeof(T) == 4; number->is_32) { number->raw = *reinterpret_cast(&value); @@ -34,7 +35,7 @@ class LiteralNumber : public Operand { } private: - std::type_index type; + const std::type_index type; bool is_32; u64 raw; }; diff --git a/src/literal-string.cpp b/src/literal_string.cpp similarity index 93% rename from src/literal-string.cpp rename to src/literal_string.cpp index 65e376c..b11a212 100644 --- a/src/literal-string.cpp +++ b/src/literal_string.cpp @@ -4,7 +4,9 @@ * Lesser General Public License version 2.1 or any later version. */ -#include "literal-string.h" +#include "literal_string.h" +#include "common_types.h" +#include namespace Sirit { diff --git a/src/literal-string.h b/src/literal_string.h similarity index 95% rename from src/literal-string.h rename to src/literal_string.h index 76fd75b..0905bce 100644 --- a/src/literal-string.h +++ b/src/literal_string.h @@ -23,7 +23,7 @@ class LiteralString : public Operand { virtual bool operator==(const Operand& other) const; private: - std::string string; + const std::string string; }; } // namespace Sirit diff --git a/src/op.cpp b/src/op.cpp index ea228ee..ed65977 100644 --- a/src/op.cpp +++ b/src/op.cpp @@ -7,8 +7,8 @@ #include #include "common_types.h" -#include "literal-number.h" -#include "literal-string.h" +#include "literal_number.h" +#include "literal_string.h" #include "op.h" #include "operand.h" @@ -88,6 +88,7 @@ void Op::Add(const Literal& literal) { return LiteralNumber::Create(std::get<5>(literal)); default: assert(!"invalid literal type"); + abort(); } }(); Sink(operand); diff --git a/tests/main.cpp b/tests/main.cpp index 5d87096..5258920 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -19,20 +19,20 @@ public: AddCapability(spv::Capability::Shader); SetMemoryModel(spv::AddressingModel::Logical, spv::MemoryModel::GLSL450); - const auto t_void = Name(TypeVoid(), "void"); - const auto t_uint = Name(TypeInt(32, false), "uint"); - const auto t_float = Name(TypeFloat(32), "float"); + const auto t_void = OpName(OpTypeVoid(), "void"); + const auto t_uint = OpName(OpTypeInt(32, false), "uint"); + const auto t_float = OpName(OpTypeFloat(32), "float"); - const auto float4 = Name(TypeVector(t_float, 4), "float4"); - const auto in_float = Name(TypePointer(spv::StorageClass::Input, t_float), "in_float"); - const auto in_float4 = Name(TypePointer(spv::StorageClass::Input, float4), "in_float4"); - const auto out_float4 = Name(TypePointer(spv::StorageClass::Output, float4), "out_float4"); + const auto float4 = OpName(OpTypeVector(t_float, 4), "float4"); + const auto in_float = OpName(OpTypePointer(spv::StorageClass::Input, t_float), "in_float"); + const auto in_float4 = OpName(OpTypePointer(spv::StorageClass::Input, float4), "in_float4"); + const auto out_float4 = OpName(OpTypePointer(spv::StorageClass::Output, float4), "out_float4"); - const auto gl_per_vertex = Name(TypeStruct({float4}), "gl_PerVertex"); - const auto gl_per_vertex_ptr = Name(TypePointer(spv::StorageClass::Output, gl_per_vertex), "out_gl_PerVertex"); + const auto gl_per_vertex = OpName(OpTypeStruct({float4}), "gl_PerVertex"); + const auto gl_per_vertex_ptr = OpName(OpTypePointer(spv::StorageClass::Output, gl_per_vertex), "out_gl_PerVertex"); - const auto in_pos = Name(Variable(in_float4, spv::StorageClass::Input), "in_pos"); - const auto per_vertex = Name(Variable(gl_per_vertex_ptr, spv::StorageClass::Output), "per_vertex"); + const auto in_pos = OpName(OpVariable(in_float4, spv::StorageClass::Input), "in_pos"); + const auto per_vertex = OpName(OpVariable(gl_per_vertex_ptr, spv::StorageClass::Output), "per_vertex"); Decorate(in_pos, spv::Decoration::Location, {0}); Decorate(gl_per_vertex, spv::Decoration::Block); @@ -41,22 +41,22 @@ public: AddGlobalVariable(in_pos); AddGlobalVariable(per_vertex); - const auto main_func = Emit(Name(Function(t_void, spv::FunctionControlMask::MaskNone, TypeFunction(t_void)), "main")); + const auto main_func = Emit(OpName(OpFunction(t_void, spv::FunctionControlMask::MaskNone, TypeFunction(t_void)), "main")); Emit(Label()); - const auto ptr_pos_x = Emit(AccessChain(in_float, in_pos, {Constant(t_uint, 0u)})); - const auto ptr_pos_y = Emit(AccessChain(in_float, in_pos, {Constant(t_uint, 1u)})); + const auto ptr_pos_x = Emit(OpAccessChain(in_float, in_pos, {OpConstant(t_uint, 0u)})); + const auto ptr_pos_y = Emit(OpAccessChain(in_float, in_pos, {OpConstant(t_uint, 1u)})); const auto pos_x = Emit(Load(t_float, ptr_pos_x)); const auto pos_y = Emit(Load(t_float, ptr_pos_y)); auto tmp_position = Emit(Undef(float4)); - tmp_position = Emit(CompositeInsert(float4, pos_x, tmp_position, {0})); - tmp_position = Emit(CompositeInsert(float4, pos_y, tmp_position, {1})); - tmp_position = Emit(CompositeInsert(float4, Constant(t_float, 0.f), tmp_position, {2})); - tmp_position = Emit(CompositeInsert(float4, Constant(t_float, 1.f), tmp_position, {3})); + tmp_position = Emit(OpCompositeInsert(float4, pos_x, tmp_position, {0})); + tmp_position = Emit(OpCompositeInsert(float4, pos_y, tmp_position, {1})); + tmp_position = Emit(OpCompositeInsert(float4, OpConstant(t_float, 0.f), tmp_position, {2})); + tmp_position = Emit(OpCompositeInsert(float4, OpConstant(t_float, 1.f), tmp_position, {3})); - const auto gl_position = Emit(AccessChain(out_float4, per_vertex, {Constant(t_uint, 0u)})); + const auto gl_position = Emit(OpAccessChain(out_float4, per_vertex, {OpConstant(t_uint, 0u)})); Emit(Store(gl_position, tmp_position)); Emit(Return());