mirror of
https://git.suyu.dev/suyu/sirit.git
synced 2026-03-08 03:32:56 +00:00
Remove Emit entry in favor of auto-emitting code
All instructions but OpVariable and OpLabel are automatically emitted. These functions have to call AddLocalVariable/AddGlobalVariable or AddLabel respectively.
This commit is contained in:
@@ -30,7 +30,7 @@ Id Module::OpSelectionMerge(Id merge_block, spv::SelectionControlMask selection_
|
||||
}
|
||||
|
||||
Id Module::OpLabel() {
|
||||
return AddCode(spv::Op::OpLabel, bound++);
|
||||
return code_store.emplace_back(std::make_unique<Op>(spv::Op::OpLabel, bound++)).get();
|
||||
}
|
||||
|
||||
Id Module::OpBranch(Id target_label) {
|
||||
|
||||
@@ -16,7 +16,7 @@ Id Module::OpVariable(Id result_type, spv::StorageClass storage_class, Id initia
|
||||
if (initializer) {
|
||||
op->Add(initializer);
|
||||
}
|
||||
return AddCode(std::move(op));
|
||||
return code_store.emplace_back(std::move(op)).get();
|
||||
}
|
||||
|
||||
Id Module::OpLoad(Id result_type, Id pointer, std::optional<spv::MemoryAccessMask> memory_access) {
|
||||
|
||||
@@ -98,22 +98,24 @@ void Module::AddExecutionMode(Id entry_point, spv::ExecutionMode mode,
|
||||
execution_modes.push_back(std::move(op));
|
||||
}
|
||||
|
||||
Id Module::Emit(Id op) {
|
||||
assert(op != nullptr);
|
||||
code.push_back(op);
|
||||
return op;
|
||||
Id Module::AddLabel(Id label) {
|
||||
assert(label != nullptr);
|
||||
return code.emplace_back(label);
|
||||
}
|
||||
|
||||
Id Module::AddLocalVariable(Id variable) {
|
||||
assert(variable != nullptr);
|
||||
return code.emplace_back(variable);
|
||||
}
|
||||
|
||||
Id Module::AddGlobalVariable(Id variable) {
|
||||
assert(variable);
|
||||
global_variables.push_back(variable);
|
||||
return variable;
|
||||
return global_variables.emplace_back(variable);
|
||||
}
|
||||
|
||||
Id Module::AddCode(std::unique_ptr<Op> op) {
|
||||
const auto id = op.get();
|
||||
code_store.push_back(std::move(op));
|
||||
return id;
|
||||
const Id id = code_store.emplace_back(std::move(op)).get();
|
||||
return code.emplace_back(id);
|
||||
}
|
||||
|
||||
Id Module::AddCode(spv::Op opcode, std::optional<u32> id) {
|
||||
|
||||
Reference in New Issue
Block a user