diff options
Diffstat (limited to 'src/shader_recompiler')
| -rw-r--r-- | src/shader_recompiler/frontend/ir/basic_block.cpp | 5 | ||||
| -rw-r--r-- | src/shader_recompiler/frontend/ir/basic_block.h | 3 | ||||
| -rw-r--r-- | src/shader_recompiler/frontend/ir/microinstruction.cpp | 11 | ||||
| -rw-r--r-- | src/shader_recompiler/frontend/ir/value.h | 2 |
4 files changed, 20 insertions, 1 deletions
diff --git a/src/shader_recompiler/frontend/ir/basic_block.cpp b/src/shader_recompiler/frontend/ir/basic_block.cpp index 7c08b25ce..974efa4a0 100644 --- a/src/shader_recompiler/frontend/ir/basic_block.cpp +++ b/src/shader_recompiler/frontend/ir/basic_block.cpp | |||
| @@ -22,6 +22,11 @@ void Block::AppendNewInst(Opcode op, std::initializer_list<Value> args) { | |||
| 22 | PrependNewInst(end(), op, args); | 22 | PrependNewInst(end(), op, args); |
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | Block::iterator Block::PrependNewInst(iterator insertion_point, const Inst& base_inst) { | ||
| 26 | Inst* const inst{inst_pool->Create(base_inst)}; | ||
| 27 | return instructions.insert(insertion_point, *inst); | ||
| 28 | } | ||
| 29 | |||
| 25 | Block::iterator Block::PrependNewInst(iterator insertion_point, Opcode op, | 30 | Block::iterator Block::PrependNewInst(iterator insertion_point, Opcode op, |
| 26 | std::initializer_list<Value> args, u32 flags) { | 31 | std::initializer_list<Value> args, u32 flags) { |
| 27 | Inst* const inst{inst_pool->Create(op, flags)}; | 32 | Inst* const inst{inst_pool->Create(op, flags)}; |
diff --git a/src/shader_recompiler/frontend/ir/basic_block.h b/src/shader_recompiler/frontend/ir/basic_block.h index 9ce1ed07e..fbfe98266 100644 --- a/src/shader_recompiler/frontend/ir/basic_block.h +++ b/src/shader_recompiler/frontend/ir/basic_block.h | |||
| @@ -40,6 +40,9 @@ public: | |||
| 40 | /// Appends a new instruction to the end of this basic block. | 40 | /// Appends a new instruction to the end of this basic block. |
| 41 | void AppendNewInst(Opcode op, std::initializer_list<Value> args); | 41 | void AppendNewInst(Opcode op, std::initializer_list<Value> args); |
| 42 | 42 | ||
| 43 | /// Prepends a copy of an instruction to this basic block before the insertion point. | ||
| 44 | iterator PrependNewInst(iterator insertion_point, const Inst& base_inst); | ||
| 45 | |||
| 43 | /// Prepends a new instruction to this basic block before the insertion point. | 46 | /// Prepends a new instruction to this basic block before the insertion point. |
| 44 | iterator PrependNewInst(iterator insertion_point, Opcode op, | 47 | iterator PrependNewInst(iterator insertion_point, Opcode op, |
| 45 | std::initializer_list<Value> args = {}, u32 flags = 0); | 48 | std::initializer_list<Value> args = {}, u32 flags = 0); |
diff --git a/src/shader_recompiler/frontend/ir/microinstruction.cpp b/src/shader_recompiler/frontend/ir/microinstruction.cpp index 30b470bdd..97e2bf6af 100644 --- a/src/shader_recompiler/frontend/ir/microinstruction.cpp +++ b/src/shader_recompiler/frontend/ir/microinstruction.cpp | |||
| @@ -47,6 +47,17 @@ Inst::Inst(IR::Opcode op_, u32 flags_) noexcept : op{op_}, flags{flags_} { | |||
| 47 | } | 47 | } |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | Inst::Inst(const Inst& base) : op{base.op}, flags{base.flags} { | ||
| 51 | if (base.op == Opcode::Phi) { | ||
| 52 | throw NotImplementedException("Copying phi node"); | ||
| 53 | } | ||
| 54 | std::construct_at(&args); | ||
| 55 | const size_t num_args{base.NumArgs()}; | ||
| 56 | for (size_t index = 0; index < num_args; ++index) { | ||
| 57 | SetArg(index, base.Arg(index)); | ||
| 58 | } | ||
| 59 | } | ||
| 60 | |||
| 50 | Inst::~Inst() { | 61 | Inst::~Inst() { |
| 51 | if (op == Opcode::Phi) { | 62 | if (op == Opcode::Phi) { |
| 52 | std::destroy_at(&phi_args); | 63 | std::destroy_at(&phi_args); |
diff --git a/src/shader_recompiler/frontend/ir/value.h b/src/shader_recompiler/frontend/ir/value.h index 6c9ef6bdd..947579852 100644 --- a/src/shader_recompiler/frontend/ir/value.h +++ b/src/shader_recompiler/frontend/ir/value.h | |||
| @@ -116,10 +116,10 @@ public: | |||
| 116 | class Inst : public boost::intrusive::list_base_hook<> { | 116 | class Inst : public boost::intrusive::list_base_hook<> { |
| 117 | public: | 117 | public: |
| 118 | explicit Inst(IR::Opcode op_, u32 flags_) noexcept; | 118 | explicit Inst(IR::Opcode op_, u32 flags_) noexcept; |
| 119 | explicit Inst(const Inst& base); | ||
| 119 | ~Inst(); | 120 | ~Inst(); |
| 120 | 121 | ||
| 121 | Inst& operator=(const Inst&) = delete; | 122 | Inst& operator=(const Inst&) = delete; |
| 122 | Inst(const Inst&) = delete; | ||
| 123 | 123 | ||
| 124 | Inst& operator=(Inst&&) = delete; | 124 | Inst& operator=(Inst&&) = delete; |
| 125 | Inst(Inst&&) = delete; | 125 | Inst(Inst&&) = delete; |