1
0
Fork 0
mirror of https://git.suyu.dev/suyu/sirit.git synced 2024-12-22 12:12:05 +00:00

Rename Ref alias to Id

This commit is contained in:
ReinUsesLisp 2018-10-31 22:20:49 -03:00
parent b8188f5ec4
commit 63ca1b5243
12 changed files with 121 additions and 121 deletions

View file

@ -23,7 +23,7 @@ class Operand;
using Literal = std::variant<std::uint32_t, std::uint64_t, std::int32_t,
std::int64_t, float, double>;
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<Ref>& interfaces = {});
const std::vector<Id>& 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<spv::AccessQualifier> 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<Ref>& members = {});
Id OpTypeStruct(const std::vector<Id>& 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<Ref>& arguments = {});
Id OpTypeFunction(Id return_type, const std::vector<Id>& 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<Ref>& constituents);
Id OpConstantComposite(Id result_type,
const std::vector<Id>& 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<Ref>& literals = {});
const std::vector<Id>& 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<spv::MemoryAccessMask> memory_access = {});
/// Store through a pointer.
Ref OpStore(Ref pointer, Ref object,
Id OpStore(Id pointer, Id object,
std::optional<spv::MemoryAccessMask> 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<Ref>& indexes = {});
Id OpAccessChain(Id result_type, Id base,
const std::vector<Id>& 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<Literal>& indexes = {});
// Annotation
/// Add a decoration to target.
Ref Decorate(Ref target, spv::Decoration decoration,
Id Decorate(Id target, spv::Decoration decoration,
const std::vector<Literal>& literals = {});
Ref MemberDecorate(Ref structure_type, Literal member,
Id MemberDecorate(Id structure_type, Literal member,
spv::Decoration decoration,
const std::vector<Literal>& 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<std::uint32_t> id = {});
Id AddCode(spv::Op opcode, std::optional<std::uint32_t> 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<std::unique_ptr<Op>> declarations;
std::vector<Ref> global_variables;
std::vector<Id> global_variables;
std::vector<Ref> code;
std::vector<Id> code;
std::vector<std::unique_ptr<Op>> code_store;
};

View file

@ -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<Literal>& 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<Literal>& literals) {
auto op{new Op(spv::Op::OpMemberDecorate)};

View file

@ -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<Ref>& constituents) {
Id Module::OpConstantComposite(Id result_type,
const std::vector<Id>& 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));
}

View file

@ -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);

View file

@ -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<Ref>& literals) {
const std::vector<Id>& 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

View file

@ -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<u32>(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

View file

@ -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<spv::MemoryAccessMask> 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<spv::MemoryAccessMask> 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<Ref>& indexes) {
Id Module::OpAccessChain(Id result_type, Id base,
const std::vector<Id>& 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<Literal>& indexes) {
auto op{new Op(spv::Op::OpCompositeInsert, bound++, result_type)};
op->Add(object);

View file

@ -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));
}

View file

@ -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<spv::AccessQualifier> 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<Ref>& members) {
Id Module::OpTypeStruct(const std::vector<Id>& 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<Ref>& arguments) {
Id Module::OpTypeFunction(Id return_type, const std::vector<Id>& 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<u32>(access_qualifier));

View file

@ -14,7 +14,7 @@
namespace Sirit {
Op::Op(spv::Op opcode, std::optional<u32> id, Ref result_type)
Op::Op(spv::Op opcode, std::optional<u32> 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<u32>(integer)); }
void Op::Add(const std::string& string) { Sink(new LiteralString(string)); }
void Op::Add(const std::vector<Ref>& ids) {
for (Ref op : ids) {
void Op::Add(const std::vector<Id>& ids) {
for (Id op : ids) {
Add(op);
}
}

View file

@ -17,7 +17,7 @@ namespace Sirit {
class Op : public Operand {
public:
explicit Op(spv::Op opcode, std::optional<u32> 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<Ref>& ids);
void Add(const std::vector<Id>& ids);
private:
u16 WordCount() const;
spv::Op opcode;
Ref result_type;
Id result_type;
std::optional<u32> id;

View file

@ -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<Ref>& interfaces) {
const std::vector<Id>& interfaces) {
auto const op{new Op(spv::Op::OpEntryPoint)};
op->Add(static_cast<u32>(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>(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>(op));
return op;
}
Ref Module::AddCode(spv::Op opcode, std::optional<u32> id) {
Id Module::AddCode(spv::Op opcode, std::optional<u32> 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>(op));
return op;