summaryrefslogtreecommitdiffstats
path: root/src/shader_recompiler/ir_opt
diff options
context:
space:
mode:
authorFernandoS27 <fsahmkow27@gmail.com>2021-04-03 01:48:39 +0200
committerameerj <52414509+ameerj@users.noreply.github.com>2021-07-23 03:51:26 +0200
commitbaec84247fe815199595d9e8077b71f3b5c8317e (patch)
tree84195625ffb43922ba87b25296057bdeb9f22a2c /src/shader_recompiler/ir_opt
parentshader: Implement SR_LaneId (diff)
downloadyuzu-baec84247fe815199595d9e8077b71f3b5c8317e.tar
yuzu-baec84247fe815199595d9e8077b71f3b5c8317e.tar.gz
yuzu-baec84247fe815199595d9e8077b71f3b5c8317e.tar.bz2
yuzu-baec84247fe815199595d9e8077b71f3b5c8317e.tar.lz
yuzu-baec84247fe815199595d9e8077b71f3b5c8317e.tar.xz
yuzu-baec84247fe815199595d9e8077b71f3b5c8317e.tar.zst
yuzu-baec84247fe815199595d9e8077b71f3b5c8317e.zip
Diffstat (limited to '')
-rw-r--r--src/shader_recompiler/ir_opt/constant_propagation_pass.cpp9
-rw-r--r--src/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp10
-rw-r--r--src/shader_recompiler/ir_opt/ssa_rewrite_pass.cpp50
3 files changed, 9 insertions, 60 deletions
diff --git a/src/shader_recompiler/ir_opt/constant_propagation_pass.cpp b/src/shader_recompiler/ir_opt/constant_propagation_pass.cpp
index 8999c3a3d..1720d7a09 100644
--- a/src/shader_recompiler/ir_opt/constant_propagation_pass.cpp
+++ b/src/shader_recompiler/ir_opt/constant_propagation_pass.cpp
@@ -374,17 +374,14 @@ std::optional<IR::Value> FoldCompositeExtractImpl(IR::Value inst_value, IR::Opco
if (inst->Opcode() == construct) {
return inst->Arg(first_index);
}
-
if (inst->Opcode() != insert) {
return std::nullopt;
}
-
IR::Value value_index{inst->Arg(2)};
if (!value_index.IsImmediate()) {
return std::nullopt;
}
-
- const u32 second_index = value_index.U32();
+ const u32 second_index{value_index.U32()};
if (first_index != second_index) {
IR::Value value_composite{inst->Arg(0)};
if (value_composite.IsImmediate()) {
@@ -404,8 +401,8 @@ void FoldCompositeExtract(IR::Inst& inst, IR::Opcode construct, IR::Opcode inser
if (!value_2.IsImmediate()) {
return;
}
- const u32 first_index = value_2.U32();
- auto result = FoldCompositeExtractImpl(value_1, insert, construct, first_index);
+ const u32 first_index{value_2.U32()};
+ const std::optional result{FoldCompositeExtractImpl(value_1, insert, construct, first_index)};
if (!result) {
return;
}
diff --git a/src/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp b/src/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp
index d4bae249b..8876a5c33 100644
--- a/src/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp
+++ b/src/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp
@@ -4,9 +4,9 @@
#include <algorithm>
#include <compare>
+#include <map>
#include <optional>
#include <ranges>
-#include <map>
#include <boost/container/flat_set.hpp>
#include <boost/container/small_vector.hpp>
@@ -295,12 +295,12 @@ void CollectStorageBuffers(IR::Block& block, IR::Inst& inst, StorageBufferSet& s
}
}
// Collect storage buffer and the instruction
- const bool is_a_write = IsGlobalMemoryWrite(inst);
- auto it = writes_map.find(*storage_buffer);
+ const bool is_a_write{IsGlobalMemoryWrite(inst)};
+ auto it{writes_map.find(*storage_buffer)};
if (it == writes_map.end()) {
- writes_map[*storage_buffer] = is_a_write;
+ writes_map[*storage_buffer] = is_a_write;
} else {
- it->second = it->second || is_a_write;
+ it->second = it->second || is_a_write;
}
storage_buffer_set.insert(*storage_buffer);
to_replace.push_back(StorageInst{
diff --git a/src/shader_recompiler/ir_opt/ssa_rewrite_pass.cpp b/src/shader_recompiler/ir_opt/ssa_rewrite_pass.cpp
index 7dab33034..72d4abb77 100644
--- a/src/shader_recompiler/ir_opt/ssa_rewrite_pass.cpp
+++ b/src/shader_recompiler/ir_opt/ssa_rewrite_pass.cpp
@@ -38,10 +38,6 @@ struct ZeroFlagTag : FlagTag {};
struct SignFlagTag : FlagTag {};
struct CarryFlagTag : FlagTag {};
struct OverflowFlagTag : FlagTag {};
-struct FCSMFlagTag : FlagTag {};
-struct TAFlagTag : FlagTag {};
-struct TRFlagTag : FlagTag {};
-struct MXFlagTag : FlagTag {};
struct GotoVariable : FlagTag {
GotoVariable() = default;
@@ -57,8 +53,7 @@ struct IndirectBranchVariable {
};
using Variant = std::variant<IR::Reg, IR::Pred, ZeroFlagTag, SignFlagTag, CarryFlagTag,
- OverflowFlagTag, FCSMFlagTag, TAFlagTag, TRFlagTag, MXFlagTag,
- GotoVariable, IndirectBranchVariable>;
+ OverflowFlagTag, GotoVariable, IndirectBranchVariable>;
using ValueMap = boost::container::flat_map<IR::Block*, IR::Value, std::less<IR::Block*>>;
struct DefTable {
@@ -94,22 +89,6 @@ struct DefTable {
return overflow_flag;
}
- [[nodiscard]] ValueMap& operator[](FCSMFlagTag) noexcept {
- return fcsm_flag;
- }
-
- [[nodiscard]] ValueMap& operator[](TAFlagTag) noexcept {
- return ta_flag;
- }
-
- [[nodiscard]] ValueMap& operator[](TRFlagTag) noexcept {
- return tr_flag;
- }
-
- [[nodiscard]] ValueMap& operator[](MXFlagTag) noexcept {
- return mr_flag;
- }
-
std::array<ValueMap, IR::NUM_USER_REGS> regs;
std::array<ValueMap, IR::NUM_USER_PREDS> preds;
boost::container::flat_map<u32, ValueMap> goto_vars;
@@ -118,10 +97,6 @@ struct DefTable {
ValueMap sign_flag;
ValueMap carry_flag;
ValueMap overflow_flag;
- ValueMap fcsm_flag;
- ValueMap ta_flag;
- ValueMap tr_flag;
- ValueMap mr_flag;
};
IR::Opcode UndefOpcode(IR::Reg) noexcept {
@@ -272,18 +247,6 @@ void VisitInst(Pass& pass, IR::Block* block, IR::Inst& inst) {
case IR::Opcode::SetOFlag:
pass.WriteVariable(OverflowFlagTag{}, block, inst.Arg(0));
break;
- case IR::Opcode::SetFCSMFlag:
- pass.WriteVariable(FCSMFlagTag{}, block, inst.Arg(0));
- break;
- case IR::Opcode::SetTAFlag:
- pass.WriteVariable(TAFlagTag{}, block, inst.Arg(0));
- break;
- case IR::Opcode::SetTRFlag:
- pass.WriteVariable(TRFlagTag{}, block, inst.Arg(0));
- break;
- case IR::Opcode::SetMXFlag:
- pass.WriteVariable(MXFlagTag{}, block, inst.Arg(0));
- break;
case IR::Opcode::GetRegister:
if (const IR::Reg reg{inst.Arg(0).Reg()}; reg != IR::Reg::RZ) {
inst.ReplaceUsesWith(pass.ReadVariable(reg, block));
@@ -312,17 +275,6 @@ void VisitInst(Pass& pass, IR::Block* block, IR::Inst& inst) {
case IR::Opcode::GetOFlag:
inst.ReplaceUsesWith(pass.ReadVariable(OverflowFlagTag{}, block));
break;
- case IR::Opcode::GetFCSMFlag:
- inst.ReplaceUsesWith(pass.ReadVariable(FCSMFlagTag{}, block));
- break;
- case IR::Opcode::GetTAFlag:
- inst.ReplaceUsesWith(pass.ReadVariable(TAFlagTag{}, block));
- break;
- case IR::Opcode::GetTRFlag:
- inst.ReplaceUsesWith(pass.ReadVariable(TRFlagTag{}, block));
- break;
- case IR::Opcode::GetMXFlag:
- inst.ReplaceUsesWith(pass.ReadVariable(MXFlagTag{}, block));
break;
default:
break;