diff options
Diffstat (limited to 'src/shader_recompiler/frontend')
5 files changed, 17 insertions, 13 deletions
diff --git a/src/shader_recompiler/frontend/ir/basic_block.cpp b/src/shader_recompiler/frontend/ir/basic_block.cpp index b5616f394..c97626712 100644 --- a/src/shader_recompiler/frontend/ir/basic_block.cpp +++ b/src/shader_recompiler/frontend/ir/basic_block.cpp | |||
| @@ -113,7 +113,7 @@ static std::string ArgToIndex(const std::map<const Block*, size_t>& block_to_ind | |||
| 113 | if (arg.IsLabel()) { | 113 | if (arg.IsLabel()) { |
| 114 | return BlockToIndex(block_to_index, arg.Label()); | 114 | return BlockToIndex(block_to_index, arg.Label()); |
| 115 | } | 115 | } |
| 116 | if (!arg.IsImmediate()) { | 116 | if (!arg.IsImmediate() || arg.IsIdentity()) { |
| 117 | return fmt::format("%{}", InstIndex(inst_to_index, inst_index, arg.Inst())); | 117 | return fmt::format("%{}", InstIndex(inst_to_index, inst_index, arg.Inst())); |
| 118 | } | 118 | } |
| 119 | switch (arg.Type()) { | 119 | switch (arg.Type()) { |
| @@ -166,7 +166,7 @@ std::string DumpBlock(const Block& block, const std::map<const Block*, size_t>& | |||
| 166 | const std::string arg_str{ArgToIndex(block_to_index, inst_to_index, inst_index, arg)}; | 166 | const std::string arg_str{ArgToIndex(block_to_index, inst_to_index, inst_index, arg)}; |
| 167 | ret += arg_index != 0 ? ", " : " "; | 167 | ret += arg_index != 0 ? ", " : " "; |
| 168 | if (op == Opcode::Phi) { | 168 | if (op == Opcode::Phi) { |
| 169 | ret += fmt::format("[ {}, {} ]", arg_index, | 169 | ret += fmt::format("[ {}, {} ]", arg_str, |
| 170 | BlockToIndex(block_to_index, inst.PhiBlock(arg_index))); | 170 | BlockToIndex(block_to_index, inst.PhiBlock(arg_index))); |
| 171 | } else { | 171 | } else { |
| 172 | ret += arg_str; | 172 | ret += arg_str; |
diff --git a/src/shader_recompiler/frontend/ir/ir_emitter.cpp b/src/shader_recompiler/frontend/ir/ir_emitter.cpp index 30932043f..f42489d41 100644 --- a/src/shader_recompiler/frontend/ir/ir_emitter.cpp +++ b/src/shader_recompiler/frontend/ir/ir_emitter.cpp | |||
| @@ -46,10 +46,12 @@ F64 IREmitter::Imm64(f64 value) const { | |||
| 46 | 46 | ||
| 47 | void IREmitter::Branch(Block* label) { | 47 | void IREmitter::Branch(Block* label) { |
| 48 | label->AddImmediatePredecessor(block); | 48 | label->AddImmediatePredecessor(block); |
| 49 | block->SetBranch(label); | ||
| 49 | Inst(Opcode::Branch, label); | 50 | Inst(Opcode::Branch, label); |
| 50 | } | 51 | } |
| 51 | 52 | ||
| 52 | void IREmitter::BranchConditional(const U1& condition, Block* true_label, Block* false_label) { | 53 | void IREmitter::BranchConditional(const U1& condition, Block* true_label, Block* false_label) { |
| 54 | block->SetBranches(IR::Condition{true}, true_label, false_label); | ||
| 53 | true_label->AddImmediatePredecessor(block); | 55 | true_label->AddImmediatePredecessor(block); |
| 54 | false_label->AddImmediatePredecessor(block); | 56 | false_label->AddImmediatePredecessor(block); |
| 55 | Inst(Opcode::BranchConditional, condition, true_label, false_label); | 57 | Inst(Opcode::BranchConditional, condition, true_label, false_label); |
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 | ||
| 145 | void Inst::SetArg(size_t index, Value value) { | 145 | void 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 | ||
| 161 | Block* Inst::PhiBlock(size_t index) const { | 163 | Block* Inst::PhiBlock(size_t index) const { |
diff --git a/src/shader_recompiler/frontend/maxwell/translate/impl/integer_add.cpp b/src/shader_recompiler/frontend/maxwell/translate/impl/integer_add.cpp index 60f79b160..623e78ff8 100644 --- a/src/shader_recompiler/frontend/maxwell/translate/impl/integer_add.cpp +++ b/src/shader_recompiler/frontend/maxwell/translate/impl/integer_add.cpp | |||
| @@ -76,8 +76,8 @@ void IADD(TranslatorVisitor& v, u64 insn, IR::U32 op_b) { | |||
| 76 | } | 76 | } |
| 77 | } // Anonymous namespace | 77 | } // Anonymous namespace |
| 78 | 78 | ||
| 79 | void TranslatorVisitor::IADD_reg(u64) { | 79 | void TranslatorVisitor::IADD_reg(u64 insn) { |
| 80 | throw NotImplementedException("IADD (reg)"); | 80 | IADD(*this, insn, GetReg20(insn)); |
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | void TranslatorVisitor::IADD_cbuf(u64 insn) { | 83 | void TranslatorVisitor::IADD_cbuf(u64 insn) { |
diff --git a/src/shader_recompiler/frontend/maxwell/translate/impl/integer_set_predicate.cpp b/src/shader_recompiler/frontend/maxwell/translate/impl/integer_set_predicate.cpp index 76c6b5291..1bc9ef363 100644 --- a/src/shader_recompiler/frontend/maxwell/translate/impl/integer_set_predicate.cpp +++ b/src/shader_recompiler/frontend/maxwell/translate/impl/integer_set_predicate.cpp | |||
| @@ -92,8 +92,8 @@ void TranslatorVisitor::ISETP_cbuf(u64 insn) { | |||
| 92 | ISETP(*this, insn, GetCbuf(insn)); | 92 | ISETP(*this, insn, GetCbuf(insn)); |
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | void TranslatorVisitor::ISETP_imm(u64) { | 95 | void TranslatorVisitor::ISETP_imm(u64 insn) { |
| 96 | throw NotImplementedException("ISETP_imm"); | 96 | ISETP(*this, insn, GetImm20(insn)); |
| 97 | } | 97 | } |
| 98 | 98 | ||
| 99 | } // namespace Shader::Maxwell | 99 | } // namespace Shader::Maxwell |