[Mesa-dev] [PATCH 1/6] nir/validate: Validate ALU bit-size rules
Jason Ekstrand
jason at jlekstrand.net
Wed Mar 8 22:51:26 UTC 2017
---
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
More information about the mesa-dev
mailing list