diff options
author | ReinUsesLisp <reinuseslisp@airmail.cc> | 2021-02-15 02:46:40 +0100 |
---|---|---|
committer | ameerj <52414509+ameerj@users.noreply.github.com> | 2021-07-23 03:51:22 +0200 |
commit | 1b0cf2309c760c1cb97a230a1572f8e87f84444a (patch) | |
tree | 6316825f65565b4c764b7851d061be0776a89974 /src/shader_recompiler/backend/spirv/emit_spirv.h | |
parent | shader: Support SSA loops on IR (diff) | |
download | yuzu-1b0cf2309c760c1cb97a230a1572f8e87f84444a.tar yuzu-1b0cf2309c760c1cb97a230a1572f8e87f84444a.tar.gz yuzu-1b0cf2309c760c1cb97a230a1572f8e87f84444a.tar.bz2 yuzu-1b0cf2309c760c1cb97a230a1572f8e87f84444a.tar.lz yuzu-1b0cf2309c760c1cb97a230a1572f8e87f84444a.tar.xz yuzu-1b0cf2309c760c1cb97a230a1572f8e87f84444a.tar.zst yuzu-1b0cf2309c760c1cb97a230a1572f8e87f84444a.zip |
Diffstat (limited to '')
-rw-r--r-- | src/shader_recompiler/backend/spirv/emit_spirv.h | 40 |
1 files changed, 1 insertions, 39 deletions
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv.h b/src/shader_recompiler/backend/spirv/emit_spirv.h index 6b09757d1..7d76377b5 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv.h +++ b/src/shader_recompiler/backend/spirv/emit_spirv.h @@ -6,8 +6,6 @@ #include <sirit/sirit.h> -#include <boost/container/flat_map.hpp> - #include "common/common_types.h" #include "shader_recompiler/frontend/ir/microinstruction.h" #include "shader_recompiler/frontend/ir/program.h" @@ -16,37 +14,6 @@ namespace Shader::Backend::SPIRV { using Sirit::Id; -class DefMap { -public: - void Define(IR::Inst* inst, Id def_id) { - const InstInfo info{.use_count{inst->UseCount()}, .def_id{def_id}}; - const auto it{map.insert(map.end(), std::make_pair(inst, info))}; - if (it == map.end()) { - throw LogicError("Defining already defined instruction"); - } - } - - [[nodiscard]] Id Consume(IR::Inst* inst) { - const auto it{map.find(inst)}; - if (it == map.end()) { - throw LogicError("Consuming undefined instruction"); - } - const Id def_id{it->second.def_id}; - if (--it->second.use_count == 0) { - map.erase(it); - } - return def_id; - } - -private: - struct InstInfo { - int use_count; - Id def_id; - }; - - boost::container::flat_map<IR::Inst*, InstInfo> map; -}; - class VectorTypes { public: void Define(Sirit::Module& sirit_ctx, Id base_type, std::string_view name) { @@ -76,7 +43,7 @@ public: [[nodiscard]] Id Def(const IR::Value& value) { if (!value.IsImmediate()) { - return def_map.Consume(value.Inst()); + return value.Inst()->Definition<Id>(); } switch (value.Type()) { case IR::Type::U1: @@ -90,10 +57,6 @@ public: } } - void Define(IR::Inst* inst, Id def_id) { - def_map.Define(inst, def_id); - } - [[nodiscard]] Id BlockLabel(IR::Block* block) const { const auto it{std::ranges::lower_bound(block_label_map, block, {}, &std::pair<IR::Block*, Id>::first)}; @@ -117,7 +80,6 @@ public: Id local_invocation_id{}; private: - DefMap def_map; std::vector<std::pair<IR::Block*, Id>> block_label_map; }; |