diff options
| author | 2021-02-02 21:07:00 -0300 | |
|---|---|---|
| committer | 2021-07-22 21:51:21 -0400 | |
| commit | 6c4cc0cd062fbbba5349da1108d3c23cb330ca8a (patch) | |
| tree | 544291931da8a85fafcea71964c77d9278ec7f29 /src/shader_recompiler/frontend/ir/microinstruction.cpp | |
| parent | shader: Initial recompiler work (diff) | |
| download | yuzu-6c4cc0cd062fbbba5349da1108d3c23cb330ca8a.tar.gz yuzu-6c4cc0cd062fbbba5349da1108d3c23cb330ca8a.tar.xz yuzu-6c4cc0cd062fbbba5349da1108d3c23cb330ca8a.zip | |
shader: SSA and dominance
Diffstat (limited to 'src/shader_recompiler/frontend/ir/microinstruction.cpp')
| -rw-r--r-- | src/shader_recompiler/frontend/ir/microinstruction.cpp | 22 |
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) | |||
| 30 | 30 | ||
| 31 | bool Inst::MayHaveSideEffects() const noexcept { | 31 | bool Inst::MayHaveSideEffects() const noexcept { |
| 32 | switch (op) { | 32 | switch (op) { |
| 33 | case Opcode::Branch: | ||
| 34 | case Opcode::BranchConditional: | ||
| 35 | case Opcode::Exit: | ||
| 36 | case Opcode::Return: | ||
| 37 | case Opcode::Unreachable: | ||
| 33 | case Opcode::SetAttribute: | 38 | case Opcode::SetAttribute: |
| 34 | case Opcode::SetAttributeIndexed: | 39 | case Opcode::SetAttributeIndexed: |
| 35 | case Opcode::WriteGlobalU8: | 40 | case Opcode::WriteGlobalU8: |
| @@ -113,6 +118,17 @@ void Inst::SetArg(size_t index, Value value) { | |||
| 113 | args[index] = value; | 118 | args[index] = value; |
| 114 | } | 119 | } |
| 115 | 120 | ||
| 121 | std::span<const std::pair<Block*, Value>> Inst::PhiOperands() const noexcept { | ||
| 122 | return phi_operands; | ||
| 123 | } | ||
| 124 | |||
| 125 | void Inst::AddPhiOperand(Block* predecessor, const Value& value) { | ||
| 126 | if (!value.IsImmediate()) { | ||
| 127 | Use(value); | ||
| 128 | } | ||
| 129 | phi_operands.emplace_back(predecessor, value); | ||
| 130 | } | ||
| 131 | |||
| 116 | void Inst::Invalidate() { | 132 | void Inst::Invalidate() { |
| 117 | ClearArgs(); | 133 | ClearArgs(); |
| 118 | op = Opcode::Void; | 134 | op = Opcode::Void; |
| @@ -125,6 +141,12 @@ void Inst::ClearArgs() { | |||
| 125 | } | 141 | } |
| 126 | value = {}; | 142 | value = {}; |
| 127 | } | 143 | } |
| 144 | for (auto& [phi_block, phi_op] : phi_operands) { | ||
| 145 | if (!phi_op.IsImmediate()) { | ||
| 146 | UndoUse(phi_op); | ||
| 147 | } | ||
| 148 | } | ||
| 149 | phi_operands.clear(); | ||
| 128 | } | 150 | } |
| 129 | 151 | ||
| 130 | void Inst::ReplaceUsesWith(Value replacement) { | 152 | void Inst::ReplaceUsesWith(Value replacement) { |