[Mesa-dev] [PATCH 1/6] nir/validate: Validate ALU bit-size rules
Connor Abbott
cwabbott0 at gmail.com
Thu Mar 9 06:35:07 UTC 2017
We already try to validate these rules in validate_alu_src() and
validate_alu_dest(), but it seems like we don't handle the case where
the sources are unsized but the destination isn't -- we don't
currently check that the source's sizes match each other. Maybe delete
that code at the same time and update the commit message?
On Wed, Mar 8, 2017 at 5:51 PM, Jason Ekstrand <jason at jlekstrand.net> wrote:
> ---
> src/compiler/nir/nir_validate.c | 21 +++++++++++++++++++++
> 1 file changed, 21 insertions(+)
>
> diff --git a/src/compiler/nir/nir_validate.c b/src/compiler/nir/nir_validate.c
> index 16efcb2..cad578c 100644
> --- a/src/compiler/nir/nir_validate.c
> +++ b/src/compiler/nir/nir_validate.c
> @@ -388,10 +388,31 @@ validate_alu_instr(nir_alu_instr *instr, validate_state *state)
> {
> validate_assert(state, instr->op < nir_num_opcodes);
>
> + unsigned instr_bit_size = 0;
> for (unsigned i = 0; i < nir_op_infos[instr->op].num_inputs; i++) {
> + nir_alu_type src_type = nir_op_infos[instr->op].input_types[i];
> + unsigned src_bit_size = nir_src_bit_size(instr->src[i].src);
> + if (nir_alu_type_get_type_size(src_type)) {
> + validate_assert(state, src_bit_size == nir_alu_type_get_type_size(src_type));
> + } else if (instr_bit_size) {
> + validate_assert(state, src_bit_size == instr_bit_size);
> + } else {
> + instr_bit_size = src_bit_size;
> + }
> +
> validate_alu_src(instr, i, state);
> }
>
> + nir_alu_type dest_type = nir_op_infos[instr->op].output_type;
> + unsigned dest_bit_size = nir_dest_bit_size(instr->dest.dest);
> + if (nir_alu_type_get_type_size(dest_type)) {
> + validate_assert(state, dest_bit_size == nir_alu_type_get_type_size(dest_type));
> + } else if (instr_bit_size) {
> + validate_assert(state, dest_bit_size == instr_bit_size);
> + } else {
> + /* The only unsized thing is the destination so it's vacuously valid */
> + }
> +
> validate_alu_dest(instr, state);
> }
>
> --
> 2.5.0.400.gff86faf
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list