summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/shader_recompiler/frontend/ir/basic_block.cpp5
-rw-r--r--src/shader_recompiler/frontend/ir/basic_block.h3
-rw-r--r--src/shader_recompiler/frontend/ir/microinstruction.cpp11
-rw-r--r--src/shader_recompiler/frontend/ir/value.h2
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
25Block::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
25Block::iterator Block::PrependNewInst(iterator insertion_point, Opcode op, 30Block::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
50Inst::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
50Inst::~Inst() { 61Inst::~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:
116class Inst : public boost::intrusive::list_base_hook<> { 116class Inst : public boost::intrusive::list_base_hook<> {
117public: 117public:
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;