diff options
Diffstat (limited to 'src/shader_recompiler/frontend/ir')
| -rw-r--r-- | src/shader_recompiler/frontend/ir/ir_emitter.cpp | 18 | ||||
| -rw-r--r-- | src/shader_recompiler/frontend/ir/ir_emitter.h | 4 | ||||
| -rw-r--r-- | src/shader_recompiler/frontend/ir/microinstruction.cpp | 3 | ||||
| -rw-r--r-- | src/shader_recompiler/frontend/ir/opcodes.inc | 3 | ||||
| -rw-r--r-- | src/shader_recompiler/frontend/ir/value.h | 4 |
5 files changed, 25 insertions, 7 deletions
diff --git a/src/shader_recompiler/frontend/ir/ir_emitter.cpp b/src/shader_recompiler/frontend/ir/ir_emitter.cpp index eb45aa477..def29143e 100644 --- a/src/shader_recompiler/frontend/ir/ir_emitter.cpp +++ b/src/shader_recompiler/frontend/ir/ir_emitter.cpp | |||
| @@ -61,6 +61,14 @@ F64 IREmitter::Imm64(f64 value) const { | |||
| 61 | return F64{Value{value}}; | 61 | return F64{Value{value}}; |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | void IREmitter::DummyReference(const Value& value) { | ||
| 65 | Inst(Opcode::DummyReference, value); | ||
| 66 | } | ||
| 67 | |||
| 68 | void IREmitter::PhiMove(IR::Inst& phi, const Value& value) { | ||
| 69 | Inst(Opcode::PhiMove, Value{&phi}, value); | ||
| 70 | } | ||
| 71 | |||
| 64 | void IREmitter::Prologue() { | 72 | void IREmitter::Prologue() { |
| 65 | Inst(Opcode::Prologue); | 73 | Inst(Opcode::Prologue); |
| 66 | } | 74 | } |
| @@ -69,10 +77,6 @@ void IREmitter::Epilogue() { | |||
| 69 | Inst(Opcode::Epilogue); | 77 | Inst(Opcode::Epilogue); |
| 70 | } | 78 | } |
| 71 | 79 | ||
| 72 | void IREmitter::BranchConditionRef(const U1& cond) { | ||
| 73 | Inst(Opcode::BranchConditionRef, cond); | ||
| 74 | } | ||
| 75 | |||
| 76 | void IREmitter::DemoteToHelperInvocation() { | 80 | void IREmitter::DemoteToHelperInvocation() { |
| 77 | Inst(Opcode::DemoteToHelperInvocation); | 81 | Inst(Opcode::DemoteToHelperInvocation); |
| 78 | } | 82 | } |
| @@ -106,6 +110,9 @@ void IREmitter::SetReg(IR::Reg reg, const U32& value) { | |||
| 106 | } | 110 | } |
| 107 | 111 | ||
| 108 | U1 IREmitter::GetPred(IR::Pred pred, bool is_negated) { | 112 | U1 IREmitter::GetPred(IR::Pred pred, bool is_negated) { |
| 113 | if (pred == Pred::PT) { | ||
| 114 | return Imm1(!is_negated); | ||
| 115 | } | ||
| 109 | const U1 value{Inst<U1>(Opcode::GetPred, pred)}; | 116 | const U1 value{Inst<U1>(Opcode::GetPred, pred)}; |
| 110 | if (is_negated) { | 117 | if (is_negated) { |
| 111 | return Inst<U1>(Opcode::LogicalNot, value); | 118 | return Inst<U1>(Opcode::LogicalNot, value); |
| @@ -264,6 +271,9 @@ static U1 GetFlowTest(IREmitter& ir, FlowTest flow_test) { | |||
| 264 | U1 IREmitter::Condition(IR::Condition cond) { | 271 | U1 IREmitter::Condition(IR::Condition cond) { |
| 265 | const FlowTest flow_test{cond.GetFlowTest()}; | 272 | const FlowTest flow_test{cond.GetFlowTest()}; |
| 266 | const auto [pred, is_negated]{cond.GetPred()}; | 273 | const auto [pred, is_negated]{cond.GetPred()}; |
| 274 | if (flow_test == FlowTest::T) { | ||
| 275 | return GetPred(pred, is_negated); | ||
| 276 | } | ||
| 267 | return LogicalAnd(GetPred(pred, is_negated), GetFlowTest(*this, flow_test)); | 277 | return LogicalAnd(GetPred(pred, is_negated), GetFlowTest(*this, flow_test)); |
| 268 | } | 278 | } |
| 269 | 279 | ||
diff --git a/src/shader_recompiler/frontend/ir/ir_emitter.h b/src/shader_recompiler/frontend/ir/ir_emitter.h index 7a83c33d3..4f7c820fe 100644 --- a/src/shader_recompiler/frontend/ir/ir_emitter.h +++ b/src/shader_recompiler/frontend/ir/ir_emitter.h | |||
| @@ -32,9 +32,11 @@ public: | |||
| 32 | [[nodiscard]] U64 Imm64(s64 value) const; | 32 | [[nodiscard]] U64 Imm64(s64 value) const; |
| 33 | [[nodiscard]] F64 Imm64(f64 value) const; | 33 | [[nodiscard]] F64 Imm64(f64 value) const; |
| 34 | 34 | ||
| 35 | void DummyReference(const Value& value); | ||
| 36 | void PhiMove(IR::Inst& phi, const Value& value); | ||
| 37 | |||
| 35 | void Prologue(); | 38 | void Prologue(); |
| 36 | void Epilogue(); | 39 | void Epilogue(); |
| 37 | void BranchConditionRef(const U1& cond); | ||
| 38 | void DemoteToHelperInvocation(); | 40 | void DemoteToHelperInvocation(); |
| 39 | void EmitVertex(const U32& stream); | 41 | void EmitVertex(const U32& stream); |
| 40 | void EndPrimitive(const U32& stream); | 42 | void EndPrimitive(const U32& stream); |
diff --git a/src/shader_recompiler/frontend/ir/microinstruction.cpp b/src/shader_recompiler/frontend/ir/microinstruction.cpp index 364574240..267aebc61 100644 --- a/src/shader_recompiler/frontend/ir/microinstruction.cpp +++ b/src/shader_recompiler/frontend/ir/microinstruction.cpp | |||
| @@ -56,9 +56,10 @@ Inst::~Inst() { | |||
| 56 | 56 | ||
| 57 | bool Inst::MayHaveSideEffects() const noexcept { | 57 | bool Inst::MayHaveSideEffects() const noexcept { |
| 58 | switch (op) { | 58 | switch (op) { |
| 59 | case Opcode::DummyReference: | ||
| 60 | case Opcode::PhiMove: | ||
| 59 | case Opcode::Prologue: | 61 | case Opcode::Prologue: |
| 60 | case Opcode::Epilogue: | 62 | case Opcode::Epilogue: |
| 61 | case Opcode::BranchConditionRef: | ||
| 62 | case Opcode::Join: | 63 | case Opcode::Join: |
| 63 | case Opcode::DemoteToHelperInvocation: | 64 | case Opcode::DemoteToHelperInvocation: |
| 64 | case Opcode::Barrier: | 65 | case Opcode::Barrier: |
diff --git a/src/shader_recompiler/frontend/ir/opcodes.inc b/src/shader_recompiler/frontend/ir/opcodes.inc index 75ddb6b6f..6196b867d 100644 --- a/src/shader_recompiler/frontend/ir/opcodes.inc +++ b/src/shader_recompiler/frontend/ir/opcodes.inc | |||
| @@ -6,11 +6,12 @@ | |||
| 6 | OPCODE(Phi, Opaque, ) | 6 | OPCODE(Phi, Opaque, ) |
| 7 | OPCODE(Identity, Opaque, Opaque, ) | 7 | OPCODE(Identity, Opaque, Opaque, ) |
| 8 | OPCODE(Void, Void, ) | 8 | OPCODE(Void, Void, ) |
| 9 | OPCODE(DummyReference, Void, Opaque, ) | ||
| 10 | OPCODE(PhiMove, Void, Opaque, Opaque, ) | ||
| 9 | 11 | ||
| 10 | // Special operations | 12 | // Special operations |
| 11 | OPCODE(Prologue, Void, ) | 13 | OPCODE(Prologue, Void, ) |
| 12 | OPCODE(Epilogue, Void, ) | 14 | OPCODE(Epilogue, Void, ) |
| 13 | OPCODE(BranchConditionRef, Void, U1, ) | ||
| 14 | OPCODE(Join, Void, ) | 15 | OPCODE(Join, Void, ) |
| 15 | OPCODE(DemoteToHelperInvocation, Void, ) | 16 | OPCODE(DemoteToHelperInvocation, Void, ) |
| 16 | OPCODE(EmitVertex, Void, U32, ) | 17 | OPCODE(EmitVertex, Void, U32, ) |
diff --git a/src/shader_recompiler/frontend/ir/value.h b/src/shader_recompiler/frontend/ir/value.h index 2ce49f953..0c6bf684d 100644 --- a/src/shader_recompiler/frontend/ir/value.h +++ b/src/shader_recompiler/frontend/ir/value.h | |||
| @@ -391,4 +391,8 @@ inline f64 Value::F64() const { | |||
| 391 | return imm_f64; | 391 | return imm_f64; |
| 392 | } | 392 | } |
| 393 | 393 | ||
| 394 | [[nodiscard]] inline bool IsPhi(const Inst& inst) { | ||
| 395 | return inst.GetOpcode() == Opcode::Phi; | ||
| 396 | } | ||
| 397 | |||
| 394 | } // namespace Shader::IR | 398 | } // namespace Shader::IR |