Validate that num_components is only set for vectorized instructions, to
prevent other nir passes or driver backends from mistakenly relying on
num_components for non-vectorized instructions.
Signed-off-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5371>
}
}
+static bool
+vectorized_intrinsic(nir_intrinsic_instr *intr)
+{
+ const nir_intrinsic_info *info = &nir_intrinsic_infos[intr->intrinsic];
+
+ if (info->dest_components == 0)
+ return true;
+
+ for (unsigned i = 0; i < info->num_srcs; i++)
+ if (info->src_components[i] == 0)
+ return true;
+
+ return false;
+}
+
static void
validate_intrinsic_instr(nir_intrinsic_instr *instr, validate_state *state)
{
validate_dest(&instr->dest, state, dest_bit_size, components_written);
}
+
+ if (!vectorized_intrinsic(instr))
+ validate_assert(state, instr->num_components == 0);
}
static void