summaryrefslogtreecommitdiff
path: root/src/shader_recompiler/frontend/ir/microinstruction.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/shader_recompiler/frontend/ir/microinstruction.cpp')
-rw-r--r--src/shader_recompiler/frontend/ir/microinstruction.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/shader_recompiler/frontend/ir/microinstruction.cpp b/src/shader_recompiler/frontend/ir/microinstruction.cpp
index b4ae371bd..9279b9692 100644
--- a/src/shader_recompiler/frontend/ir/microinstruction.cpp
+++ b/src/shader_recompiler/frontend/ir/microinstruction.cpp
@@ -143,19 +143,21 @@ Value Inst::Arg(size_t index) const {
143} 143}
144 144
145void Inst::SetArg(size_t index, Value value) { 145void Inst::SetArg(size_t index, Value value) {
146 if (op == Opcode::Phi) { 146 if (index >= NumArgs()) {
147 throw LogicError("Setting argument on a phi instruction");
148 }
149 if (index >= NumArgsOf(op)) {
150 throw InvalidArgument("Out of bounds argument index {} in opcode {}", index, op); 147 throw InvalidArgument("Out of bounds argument index {} in opcode {}", index, op);
151 } 148 }
152 if (!args[index].IsImmediate()) { 149 const IR::Value arg{Arg(index)};
153 UndoUse(args[index]); 150 if (!arg.IsImmediate()) {
151 UndoUse(arg);
154 } 152 }
155 if (!value.IsImmediate()) { 153 if (!value.IsImmediate()) {
156 Use(value); 154 Use(value);
157 } 155 }
158 args[index] = value; 156 if (op == Opcode::Phi) {
157 phi_args[index].second = value;
158 } else {
159 args[index] = value;
160 }
159} 161}
160 162
161Block* Inst::PhiBlock(size_t index) const { 163Block* Inst::PhiBlock(size_t index) const {