[Mesa-dev] [RFC PATCH 1/2] nir: Silently bail on regs for gather_ssa_types
Alyssa Rosenzweig
alyssa at rosenzweig.io
Mon May 13 03:48:00 UTC 2019
In the future, we'll really need to implement register support for
nir_gather_ssa_types, but at present, for some limited applications it
can be ok to just bail on these and set neither int_types nor
float_types, rather than assert'ing out and crashing. It's not correct,
per se, but existing users will not be regressed, and for the limited
use in Panfrost following the imov/fmov merge, it'll hold us over until
this pass can be extended.
Signed-off-by: Alyssa Rosenzweig <alyssa at rosenzweig.io>
Cc: Jason Ekstrand <jason at jlekstrand.net>
---
src/compiler/nir/nir_gather_ssa_types.c | 60 ++++++++++++++++++-------
1 file changed, 43 insertions(+), 17 deletions(-)
diff --git a/src/compiler/nir/nir_gather_ssa_types.c b/src/compiler/nir/nir_gather_ssa_types.c
index 73bd0f9bc6a..a63e9295d27 100644
--- a/src/compiler/nir/nir_gather_ssa_types.c
+++ b/src/compiler/nir/nir_gather_ssa_types.c
@@ -99,7 +99,11 @@ nir_gather_ssa_types(nir_function_impl *impl,
switch (instr->type) {
case nir_instr_type_alu: {
nir_alu_instr *alu = nir_instr_as_alu(instr);
- assert(alu->dest.dest.is_ssa);
+
+ /* TODO: registers */
+ if (!alu->dest.dest.is_ssa)
+ continue;
+
const nir_op_info *info = &nir_op_infos[alu->op];
switch (alu->op) {
case nir_op_imov:
@@ -108,7 +112,9 @@ nir_gather_ssa_types(nir_function_impl *impl,
case nir_op_vec3:
case nir_op_vec4:
for (unsigned i = 0; i < info->num_inputs; i++) {
- assert(alu->src[i].src.is_ssa);
+ if (!alu->src[i].src.is_ssa)
+ continue;
+
copy_types(alu->src[i].src.ssa->index,
alu->dest.dest.ssa.index,
float_types, int_types, &progress);
@@ -117,19 +123,26 @@ nir_gather_ssa_types(nir_function_impl *impl,
case nir_op_bcsel:
case nir_op_b32csel:
- set_type(alu->src[0].src.ssa->index, nir_type_bool,
- float_types, int_types, &progress);
- copy_types(alu->src[1].src.ssa->index,
- alu->dest.dest.ssa.index,
- float_types, int_types, &progress);
- copy_types(alu->src[2].src.ssa->index,
- alu->dest.dest.ssa.index,
- float_types, int_types, &progress);
+ if (alu->src[0].src.is_ssa)
+ set_type(alu->src[0].src.ssa->index, nir_type_bool,
+ float_types, int_types, &progress);
+
+ if (alu->src[1].src.is_ssa)
+ copy_types(alu->src[1].src.ssa->index,
+ alu->dest.dest.ssa.index,
+ float_types, int_types, &progress);
+
+ if (alu->src[2].src.is_ssa)
+ copy_types(alu->src[2].src.ssa->index,
+ alu->dest.dest.ssa.index,
+ float_types, int_types, &progress);
break;
default:
for (unsigned i = 0; i < info->num_inputs; i++) {
- assert(alu->src[i].src.is_ssa);
+ if (!alu->src[i].src.is_ssa)
+ continue;
+
set_type(alu->src[i].src.ssa->index, info->input_types[i],
float_types, int_types, &progress);
}
@@ -142,12 +155,17 @@ nir_gather_ssa_types(nir_function_impl *impl,
case nir_instr_type_tex: {
nir_tex_instr *tex = nir_instr_as_tex(instr);
for (unsigned i = 0; i < tex->num_srcs; i++) {
- assert(tex->src[i].src.is_ssa);
+ if (!tex->src[i].src.is_ssa)
+ continue;
+
set_type(tex->src[i].src.ssa->index,
nir_tex_instr_src_type(tex, i),
float_types, int_types, &progress);
}
- assert(tex->dest.is_ssa);
+
+ if (!tex->dest.is_ssa)
+ continue;
+
set_type(tex->dest.ssa.index, tex->dest_type,
float_types, int_types, &progress);
break;
@@ -162,7 +180,9 @@ nir_gather_ssa_types(nir_function_impl *impl,
case nir_intrinsic_load_deref: {
nir_deref_instr *deref = nir_src_as_deref(intrin->src[0]);
- assert(intrin->dest.is_ssa);
+ if (!intrin->dest.is_ssa)
+ break;
+
set_type(intrin->dest.ssa.index,
nir_get_nir_type_for_glsl_type(deref->type),
float_types, int_types, &progress);
@@ -172,7 +192,9 @@ nir_gather_ssa_types(nir_function_impl *impl,
case nir_intrinsic_store_deref: {
nir_deref_instr *deref = nir_src_as_deref(intrin->src[0]);
- assert(intrin->src[1].is_ssa);
+ if (!intrin->src[1].is_ssa)
+ break;
+
set_type(intrin->src[1].ssa->index,
nir_get_nir_type_for_glsl_type(deref->type),
float_types, int_types, &progress);
@@ -187,7 +209,9 @@ nir_gather_ssa_types(nir_function_impl *impl,
*/
nir_src *offset_src = nir_get_io_offset_src(intrin);
if (offset_src) {
- assert(offset_src->is_ssa);
+ if (!offset_src->is_ssa)
+ break;
+
set_type(offset_src->ssa->index, nir_type_int,
float_types, int_types, &progress);
}
@@ -201,7 +225,9 @@ nir_gather_ssa_types(nir_function_impl *impl,
nir_phi_instr *phi = nir_instr_as_phi(instr);
assert(phi->dest.is_ssa);
nir_foreach_phi_src(src, phi) {
- assert(src->src.is_ssa);
+ if (!src->src.is_ssa)
+ continue;
+
copy_types(src->src.ssa->index, phi->dest.ssa.index,
float_types, int_types, &progress);
}
--
2.20.1
More information about the mesa-dev
mailing list