aboutsummaryrefslogtreecommitdiff
path: root/src/shader_recompiler
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2021-03-30 03:19:50 -0300
committerameerj <52414509+ameerj@users.noreply.github.com>2021-07-22 21:51:25 -0400
commit514a6b07eedace58b4a0c95282bdfc729623d1d9 (patch)
treeb384c882fa5e24ce9a0a2d287076d23949b3e266 /src/shader_recompiler
parentb0d5572abfe1f14e02d8219f0a4d7dd09ff36fd1 (diff)
shader: Store type of phi nodes in flags
This is needed because pseudo-instructions where invalidated.
Diffstat (limited to 'src/shader_recompiler')
-rw-r--r--src/shader_recompiler/backend/spirv/emit_spirv.cpp3
-rw-r--r--src/shader_recompiler/frontend/ir/microinstruction.cpp4
-rw-r--r--src/shader_recompiler/frontend/ir/value.cpp6
3 files changed, 11 insertions, 2 deletions
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv.cpp b/src/shader_recompiler/backend/spirv/emit_spirv.cpp
index 2e7e6bb0c9..6389d80bfb 100644
--- a/src/shader_recompiler/backend/spirv/emit_spirv.cpp
+++ b/src/shader_recompiler/backend/spirv/emit_spirv.cpp
@@ -288,7 +288,8 @@ Id EmitPhi(EmitContext& ctx, IR::Inst* inst) {
operands.push_back(PhiArgDef(ctx, inst, index));
operands.push_back(inst->PhiBlock(index)->Definition<Id>());
}
- const Id result_type{TypeId(ctx, inst->Arg(0).Type())};
+ // The type of a phi instruction is stored in its flags
+ const Id result_type{TypeId(ctx, inst->Flags<IR::Type>())};
return ctx.OpPhi(result_type, std::span(operands.data(), operands.size()));
}
diff --git a/src/shader_recompiler/frontend/ir/microinstruction.cpp b/src/shader_recompiler/frontend/ir/microinstruction.cpp
index c3ba6b5222..074c71d533 100644
--- a/src/shader_recompiler/frontend/ir/microinstruction.cpp
+++ b/src/shader_recompiler/frontend/ir/microinstruction.cpp
@@ -193,6 +193,10 @@ void Inst::AddPhiOperand(Block* predecessor, const Value& value) {
if (!value.IsImmediate()) {
Use(value);
}
+ if (Flags<IR::Type>() == IR::Type::Void) {
+ // Set the type of the phi node
+ SetFlags<IR::Type>(value.Type());
+ }
phi_args.emplace_back(predecessor, value);
}
diff --git a/src/shader_recompiler/frontend/ir/value.cpp b/src/shader_recompiler/frontend/ir/value.cpp
index e8e4662e7b..837c1b487f 100644
--- a/src/shader_recompiler/frontend/ir/value.cpp
+++ b/src/shader_recompiler/frontend/ir/value.cpp
@@ -56,7 +56,11 @@ bool Value::IsLabel() const noexcept {
}
IR::Type Value::Type() const noexcept {
- if (IsIdentity() || IsPhi()) {
+ if (IsPhi()) {
+ // The type of a phi node is stored in its flags
+ return inst->Flags<IR::Type>();
+ }
+ if (IsIdentity()) {
return inst->Arg(0).Type();
}
if (type == Type::Opaque) {