summaryrefslogtreecommitdiffstats
path: root/src/shader_recompiler/ir_opt
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2021-02-03 20:43:04 +0100
committerameerj <52414509+ameerj@users.noreply.github.com>2021-07-23 03:51:21 +0200
commitd24a16045f0f6b0b873d5e3b5bf187c1a8c4343f (patch)
tree0108a028b437bc59dfe7864f333cf4c50a46d3b5 /src/shader_recompiler/ir_opt
parentshader: SSA and dominance (diff)
downloadyuzu-d24a16045f0f6b0b873d5e3b5bf187c1a8c4343f.tar
yuzu-d24a16045f0f6b0b873d5e3b5bf187c1a8c4343f.tar.gz
yuzu-d24a16045f0f6b0b873d5e3b5bf187c1a8c4343f.tar.bz2
yuzu-d24a16045f0f6b0b873d5e3b5bf187c1a8c4343f.tar.lz
yuzu-d24a16045f0f6b0b873d5e3b5bf187c1a8c4343f.tar.xz
yuzu-d24a16045f0f6b0b873d5e3b5bf187c1a8c4343f.tar.zst
yuzu-d24a16045f0f6b0b873d5e3b5bf187c1a8c4343f.zip
Diffstat (limited to 'src/shader_recompiler/ir_opt')
-rw-r--r--src/shader_recompiler/ir_opt/get_set_elimination_pass.cpp87
-rw-r--r--src/shader_recompiler/ir_opt/passes.h1
2 files changed, 0 insertions, 88 deletions
diff --git a/src/shader_recompiler/ir_opt/get_set_elimination_pass.cpp b/src/shader_recompiler/ir_opt/get_set_elimination_pass.cpp
deleted file mode 100644
index 21b8526cd..000000000
--- a/src/shader_recompiler/ir_opt/get_set_elimination_pass.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
-// Copyright 2021 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
-
-#include <array>
-
-#include "shader_recompiler/frontend/ir/basic_block.h"
-#include "shader_recompiler/frontend/ir/microinstruction.h"
-#include "shader_recompiler/ir_opt/passes.h"
-
-namespace Shader::Optimization {
-namespace {
-using Iterator = IR::Block::iterator;
-
-enum class TrackingType {
- Reg,
-};
-
-struct RegisterInfo {
- IR::Value register_value;
- TrackingType tracking_type;
- Iterator last_set_instruction;
- bool set_instruction_present = false;
-};
-
-void DoSet(IR::Block& block, RegisterInfo& info, IR::Value value, Iterator set_inst,
- TrackingType tracking_type) {
- if (info.set_instruction_present) {
- info.last_set_instruction->Invalidate();
- block.Instructions().erase(info.last_set_instruction);
- }
- info.register_value = value;
- info.tracking_type = tracking_type;
- info.set_instruction_present = true;
- info.last_set_instruction = set_inst;
-}
-
-RegisterInfo Nothing(Iterator get_inst, TrackingType tracking_type) {
- RegisterInfo info{};
- info.register_value = IR::Value{&*get_inst};
- info.tracking_type = tracking_type;
- return info;
-}
-
-void DoGet(RegisterInfo& info, Iterator get_inst, TrackingType tracking_type) {
- if (info.register_value.IsEmpty()) {
- info = Nothing(get_inst, tracking_type);
- return;
- }
- if (info.tracking_type == tracking_type) {
- get_inst->ReplaceUsesWith(info.register_value);
- return;
- }
- info = Nothing(get_inst, tracking_type);
-}
-} // Anonymous namespace
-
-void GetSetElimination(IR::Block& block) {
- std::array<RegisterInfo, 255> reg_info;
-
- for (Iterator inst = block.begin(); inst != block.end(); ++inst) {
- switch (inst->Opcode()) {
- case IR::Opcode::GetRegister: {
- const IR::Reg reg{inst->Arg(0).Reg()};
- if (reg == IR::Reg::RZ) {
- break;
- }
- const size_t index{static_cast<size_t>(reg)};
- DoGet(reg_info.at(index), inst, TrackingType::Reg);
- break;
- }
- case IR::Opcode::SetRegister: {
- const IR::Reg reg{inst->Arg(0).Reg()};
- if (reg == IR::Reg::RZ) {
- break;
- }
- const size_t index{static_cast<size_t>(reg)};
- DoSet(block, reg_info.at(index), inst->Arg(1), inst, TrackingType::Reg);
- break;
- }
- default:
- break;
- }
- }
-}
-
-} // namespace Shader::Optimization
diff --git a/src/shader_recompiler/ir_opt/passes.h b/src/shader_recompiler/ir_opt/passes.h
index 83f094d73..7ed4005ed 100644
--- a/src/shader_recompiler/ir_opt/passes.h
+++ b/src/shader_recompiler/ir_opt/passes.h
@@ -17,7 +17,6 @@ void Invoke(Func&& func, IR::Function& function) {
}
void DeadCodeEliminationPass(IR::Block& block);
-void GetSetElimination(IR::Block& block);
void IdentityRemovalPass(IR::Block& block);
void SsaRewritePass(IR::Function& function);
void VerificationPass(const IR::Block& block);