diff options
author | ReinUsesLisp <[email protected]> | 2019-10-18 04:25:57 -0300 |
---|---|---|
committer | ReinUsesLisp <[email protected]> | 2019-10-18 04:27:52 -0300 |
commit | 42248408a970f11d0c256fe5d33dee8d03fb3982 (patch) | |
tree | 8529e9ec1e5e17a7a0b957bbef583947c763677a /src/sirit.cpp | |
parent | 8cf3d225db622cc150951ce56dd4cb774be410a7 (diff) | |
download | sirit-42248408a970f11d0c256fe5d33dee8d03fb3982.tar.gz sirit-42248408a970f11d0c256fe5d33dee8d03fb3982.zip |
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.
Diffstat (limited to 'src/sirit.cpp')
-rw-r--r-- | src/sirit.cpp | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/sirit.cpp b/src/sirit.cpp index 6e28bdf..2fb8580 100644 --- a/src/sirit.cpp +++ b/src/sirit.cpp @@ -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) { |