diff options
Diffstat (limited to 'src/shader_recompiler/ir_opt/ssa_rewrite_pass.cpp')
| -rw-r--r-- | src/shader_recompiler/ir_opt/ssa_rewrite_pass.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/shader_recompiler/ir_opt/ssa_rewrite_pass.cpp b/src/shader_recompiler/ir_opt/ssa_rewrite_pass.cpp index 13f9c914a..19d35b1f8 100644 --- a/src/shader_recompiler/ir_opt/ssa_rewrite_pass.cpp +++ b/src/shader_recompiler/ir_opt/ssa_rewrite_pass.cpp | |||
| @@ -109,11 +109,13 @@ IR::Opcode UndefOpcode(const FlagTag&) noexcept { | |||
| 109 | 109 | ||
| 110 | class Pass { | 110 | class Pass { |
| 111 | public: | 111 | public: |
| 112 | void WriteVariable(auto variable, IR::Block* block, const IR::Value& value) { | 112 | template <typename Type> |
| 113 | void WriteVariable(Type variable, IR::Block* block, const IR::Value& value) { | ||
| 113 | current_def[variable].insert_or_assign(block, value); | 114 | current_def[variable].insert_or_assign(block, value); |
| 114 | } | 115 | } |
| 115 | 116 | ||
| 116 | IR::Value ReadVariable(auto variable, IR::Block* block) { | 117 | template <typename Type> |
| 118 | IR::Value ReadVariable(Type variable, IR::Block* block) { | ||
| 117 | const ValueMap& def{current_def[variable]}; | 119 | const ValueMap& def{current_def[variable]}; |
| 118 | if (const auto it{def.find(block)}; it != def.end()) { | 120 | if (const auto it{def.find(block)}; it != def.end()) { |
| 119 | return it->second; | 121 | return it->second; |
| @@ -132,7 +134,8 @@ public: | |||
| 132 | } | 134 | } |
| 133 | 135 | ||
| 134 | private: | 136 | private: |
| 135 | IR::Value ReadVariableRecursive(auto variable, IR::Block* block) { | 137 | template <typename Type> |
| 138 | IR::Value ReadVariableRecursive(Type variable, IR::Block* block) { | ||
| 136 | IR::Value val; | 139 | IR::Value val; |
| 137 | if (!sealed_blocks.contains(block)) { | 140 | if (!sealed_blocks.contains(block)) { |
| 138 | // Incomplete CFG | 141 | // Incomplete CFG |
| @@ -154,7 +157,8 @@ private: | |||
| 154 | return val; | 157 | return val; |
| 155 | } | 158 | } |
| 156 | 159 | ||
| 157 | IR::Value AddPhiOperands(auto variable, IR::Inst& phi, IR::Block* block) { | 160 | template <typename Type> |
| 161 | IR::Value AddPhiOperands(Type variable, IR::Inst& phi, IR::Block* block) { | ||
| 158 | for (IR::Block* const imm_pred : block->ImmediatePredecessors()) { | 162 | for (IR::Block* const imm_pred : block->ImmediatePredecessors()) { |
| 159 | phi.AddPhiOperand(imm_pred, ReadVariable(variable, imm_pred)); | 163 | phi.AddPhiOperand(imm_pred, ReadVariable(variable, imm_pred)); |
| 160 | } | 164 | } |