diff options
| author | 2021-02-14 01:24:32 -0300 | |
|---|---|---|
| committer | 2021-07-22 21:51:22 -0400 | |
| commit | 8af9297f0972d0aaa8306369c5d04926b886a89e (patch) | |
| tree | 43bb3f50d694b615d2ae821eef84e417166d4890 /src/shader_recompiler/frontend/ir | |
| parent | shader: Initial implementation of an AST (diff) | |
| download | yuzu-8af9297f0972d0aaa8306369c5d04926b886a89e.tar.gz yuzu-8af9297f0972d0aaa8306369c5d04926b886a89e.tar.xz yuzu-8af9297f0972d0aaa8306369c5d04926b886a89e.zip | |
shader: Misc fixes
Diffstat (limited to 'src/shader_recompiler/frontend/ir')
| -rw-r--r-- | src/shader_recompiler/frontend/ir/basic_block.cpp | 4 | ||||
| -rw-r--r-- | src/shader_recompiler/frontend/ir/ir_emitter.cpp | 2 | ||||
| -rw-r--r-- | src/shader_recompiler/frontend/ir/microinstruction.cpp | 16 |
3 files changed, 13 insertions, 9 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 { |