summaryrefslogtreecommitdiffstats
path: root/src/shader_recompiler/frontend/ir/microinstruction.cpp
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2021-02-03 01:07:00 +0100
committerameerj <52414509+ameerj@users.noreply.github.com>2021-07-23 03:51:21 +0200
commit6c4cc0cd062fbbba5349da1108d3c23cb330ca8a (patch)
tree544291931da8a85fafcea71964c77d9278ec7f29 /src/shader_recompiler/frontend/ir/microinstruction.cpp
parentshader: Initial recompiler work (diff)
downloadyuzu-6c4cc0cd062fbbba5349da1108d3c23cb330ca8a.tar
yuzu-6c4cc0cd062fbbba5349da1108d3c23cb330ca8a.tar.gz
yuzu-6c4cc0cd062fbbba5349da1108d3c23cb330ca8a.tar.bz2
yuzu-6c4cc0cd062fbbba5349da1108d3c23cb330ca8a.tar.lz
yuzu-6c4cc0cd062fbbba5349da1108d3c23cb330ca8a.tar.xz
yuzu-6c4cc0cd062fbbba5349da1108d3c23cb330ca8a.tar.zst
yuzu-6c4cc0cd062fbbba5349da1108d3c23cb330ca8a.zip
Diffstat (limited to '')
-rw-r--r--src/shader_recompiler/frontend/ir/microinstruction.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/shader_recompiler/frontend/ir/microinstruction.cpp b/src/shader_recompiler/frontend/ir/microinstruction.cpp
index 553fec3b7..ecf76e23d 100644
--- a/src/shader_recompiler/frontend/ir/microinstruction.cpp
+++ b/src/shader_recompiler/frontend/ir/microinstruction.cpp
@@ -30,6 +30,11 @@ static void RemovePseudoInstruction(IR::Inst*& inst, IR::Opcode expected_opcode)
bool Inst::MayHaveSideEffects() const noexcept {
switch (op) {
+ case Opcode::Branch:
+ case Opcode::BranchConditional:
+ case Opcode::Exit:
+ case Opcode::Return:
+ case Opcode::Unreachable:
case Opcode::SetAttribute:
case Opcode::SetAttributeIndexed:
case Opcode::WriteGlobalU8:
@@ -113,6 +118,17 @@ void Inst::SetArg(size_t index, Value value) {
args[index] = value;
}
+std::span<const std::pair<Block*, Value>> Inst::PhiOperands() const noexcept {
+ return phi_operands;
+}
+
+void Inst::AddPhiOperand(Block* predecessor, const Value& value) {
+ if (!value.IsImmediate()) {
+ Use(value);
+ }
+ phi_operands.emplace_back(predecessor, value);
+}
+
void Inst::Invalidate() {
ClearArgs();
op = Opcode::Void;
@@ -125,6 +141,12 @@ void Inst::ClearArgs() {
}
value = {};
}
+ for (auto& [phi_block, phi_op] : phi_operands) {
+ if (!phi_op.IsImmediate()) {
+ UndoUse(phi_op);
+ }
+ }
+ phi_operands.clear();
}
void Inst::ReplaceUsesWith(Value replacement) {