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 | 32 |
1 files changed, 2 insertions, 30 deletions
diff --git a/src/shader_recompiler/ir_opt/ssa_rewrite_pass.cpp b/src/shader_recompiler/ir_opt/ssa_rewrite_pass.cpp index fff25c4a2..dcaced83f 100644 --- a/src/shader_recompiler/ir_opt/ssa_rewrite_pass.cpp +++ b/src/shader_recompiler/ir_opt/ssa_rewrite_pass.cpp | |||
| @@ -48,22 +48,12 @@ struct GotoVariable : FlagTag { | |||
| 48 | u32 index; | 48 | u32 index; |
| 49 | }; | 49 | }; |
| 50 | 50 | ||
| 51 | struct LoopSafetyVariable { | ||
| 52 | LoopSafetyVariable() = default; | ||
| 53 | explicit LoopSafetyVariable(u32 index_) : index{index_} {} | ||
| 54 | |||
| 55 | auto operator<=>(const LoopSafetyVariable&) const noexcept = default; | ||
| 56 | |||
| 57 | u32 index; | ||
| 58 | }; | ||
| 59 | |||
| 60 | struct IndirectBranchVariable { | 51 | struct IndirectBranchVariable { |
| 61 | auto operator<=>(const IndirectBranchVariable&) const noexcept = default; | 52 | auto operator<=>(const IndirectBranchVariable&) const noexcept = default; |
| 62 | }; | 53 | }; |
| 63 | 54 | ||
| 64 | using Variant = | 55 | using Variant = std::variant<IR::Reg, IR::Pred, ZeroFlagTag, SignFlagTag, CarryFlagTag, |
| 65 | std::variant<IR::Reg, IR::Pred, ZeroFlagTag, SignFlagTag, CarryFlagTag, OverflowFlagTag, | 56 | OverflowFlagTag, GotoVariable, IndirectBranchVariable>; |
| 66 | GotoVariable, LoopSafetyVariable, IndirectBranchVariable>; | ||
| 67 | using ValueMap = boost::container::flat_map<IR::Block*, IR::Value>; | 57 | using ValueMap = boost::container::flat_map<IR::Block*, IR::Value>; |
| 68 | 58 | ||
| 69 | struct DefTable { | 59 | struct DefTable { |
| @@ -88,13 +78,6 @@ struct DefTable { | |||
| 88 | goto_vars[variable.index].insert_or_assign(block, value); | 78 | goto_vars[variable.index].insert_or_assign(block, value); |
| 89 | } | 79 | } |
| 90 | 80 | ||
| 91 | const IR::Value& Def(IR::Block* block, LoopSafetyVariable variable) { | ||
| 92 | return loop_safety_vars[variable.index][block]; | ||
| 93 | } | ||
| 94 | void SetDef(IR::Block* block, LoopSafetyVariable variable, const IR::Value& value) { | ||
| 95 | loop_safety_vars[variable.index].insert_or_assign(block, value); | ||
| 96 | } | ||
| 97 | |||
| 98 | const IR::Value& Def(IR::Block* block, IndirectBranchVariable) { | 81 | const IR::Value& Def(IR::Block* block, IndirectBranchVariable) { |
| 99 | return indirect_branch_var[block]; | 82 | return indirect_branch_var[block]; |
| 100 | } | 83 | } |
| @@ -132,7 +115,6 @@ struct DefTable { | |||
| 132 | 115 | ||
| 133 | std::array<ValueMap, IR::NUM_USER_PREDS> preds; | 116 | std::array<ValueMap, IR::NUM_USER_PREDS> preds; |
| 134 | boost::container::flat_map<u32, ValueMap> goto_vars; | 117 | boost::container::flat_map<u32, ValueMap> goto_vars; |
| 135 | boost::container::flat_map<u32, ValueMap> loop_safety_vars; | ||
| 136 | ValueMap indirect_branch_var; | 118 | ValueMap indirect_branch_var; |
| 137 | ValueMap zero_flag; | 119 | ValueMap zero_flag; |
| 138 | ValueMap sign_flag; | 120 | ValueMap sign_flag; |
| @@ -152,10 +134,6 @@ IR::Opcode UndefOpcode(const FlagTag&) noexcept { | |||
| 152 | return IR::Opcode::UndefU1; | 134 | return IR::Opcode::UndefU1; |
| 153 | } | 135 | } |
| 154 | 136 | ||
| 155 | IR::Opcode UndefOpcode(const LoopSafetyVariable&) noexcept { | ||
| 156 | return IR::Opcode::UndefU32; | ||
| 157 | } | ||
| 158 | |||
| 159 | IR::Opcode UndefOpcode(IndirectBranchVariable) noexcept { | 137 | IR::Opcode UndefOpcode(IndirectBranchVariable) noexcept { |
| 160 | return IR::Opcode::UndefU32; | 138 | return IR::Opcode::UndefU32; |
| 161 | } | 139 | } |
| @@ -337,9 +315,6 @@ void VisitInst(Pass& pass, IR::Block* block, IR::Inst& inst) { | |||
| 337 | case IR::Opcode::SetGotoVariable: | 315 | case IR::Opcode::SetGotoVariable: |
| 338 | pass.WriteVariable(GotoVariable{inst.Arg(0).U32()}, block, inst.Arg(1)); | 316 | pass.WriteVariable(GotoVariable{inst.Arg(0).U32()}, block, inst.Arg(1)); |
| 339 | break; | 317 | break; |
| 340 | case IR::Opcode::SetLoopSafetyVariable: | ||
| 341 | pass.WriteVariable(LoopSafetyVariable{inst.Arg(0).U32()}, block, inst.Arg(1)); | ||
| 342 | break; | ||
| 343 | case IR::Opcode::SetIndirectBranchVariable: | 318 | case IR::Opcode::SetIndirectBranchVariable: |
| 344 | pass.WriteVariable(IndirectBranchVariable{}, block, inst.Arg(0)); | 319 | pass.WriteVariable(IndirectBranchVariable{}, block, inst.Arg(0)); |
| 345 | break; | 320 | break; |
| @@ -368,9 +343,6 @@ void VisitInst(Pass& pass, IR::Block* block, IR::Inst& inst) { | |||
| 368 | case IR::Opcode::GetGotoVariable: | 343 | case IR::Opcode::GetGotoVariable: |
| 369 | inst.ReplaceUsesWith(pass.ReadVariable(GotoVariable{inst.Arg(0).U32()}, block)); | 344 | inst.ReplaceUsesWith(pass.ReadVariable(GotoVariable{inst.Arg(0).U32()}, block)); |
| 370 | break; | 345 | break; |
| 371 | case IR::Opcode::GetLoopSafetyVariable: | ||
| 372 | inst.ReplaceUsesWith(pass.ReadVariable(LoopSafetyVariable{inst.Arg(0).U32()}, block)); | ||
| 373 | break; | ||
| 374 | case IR::Opcode::GetIndirectBranchVariable: | 346 | case IR::Opcode::GetIndirectBranchVariable: |
| 375 | inst.ReplaceUsesWith(pass.ReadVariable(IndirectBranchVariable{}, block)); | 347 | inst.ReplaceUsesWith(pass.ReadVariable(IndirectBranchVariable{}, block)); |
| 376 | break; | 348 | break; |