diff options
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/nir/nir.h | 22 | ||||
-rw-r--r-- | src/compiler/nir/nir_opt_copy_propagate.c | 5 | ||||
-rw-r--r-- | src/compiler/nir/nir_validate.c | 10 | ||||
-rw-r--r-- | src/compiler/spirv/spirv_to_nir.c | 3 |
4 files changed, 26 insertions, 14 deletions
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index cc7c401b40e..f33049d7134 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -1146,6 +1146,28 @@ typedef struct { extern const nir_intrinsic_info nir_intrinsic_infos[nir_num_intrinsics]; +static inline unsigned +nir_intrinsic_src_components(nir_intrinsic_instr *intr, unsigned srcn) +{ + const nir_intrinsic_info *info = &nir_intrinsic_infos[intr->intrinsic]; + assert(srcn < info->num_srcs); + if (info->src_components[srcn]) + return info->src_components[srcn]; + else + return intr->num_components; +} + +static inline unsigned +nir_intrinsic_dest_components(nir_intrinsic_instr *intr) +{ + const nir_intrinsic_info *info = &nir_intrinsic_infos[intr->intrinsic]; + if (!info->has_dest) + return 0; + else if (info->dest_components) + return info->dest_components; + else + return intr->num_components; +} #define INTRINSIC_IDX_ACCESSORS(name, flag, type) \ static inline type \ diff --git a/src/compiler/nir/nir_opt_copy_propagate.c b/src/compiler/nir/nir_opt_copy_propagate.c index c4001fa73f5..3cd476a1b97 100644 --- a/src/compiler/nir/nir_opt_copy_propagate.c +++ b/src/compiler/nir/nir_opt_copy_propagate.c @@ -257,10 +257,7 @@ copy_prop_instr(nir_instr *instr) nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr); for (unsigned i = 0; i < nir_intrinsic_infos[intrin->intrinsic].num_srcs; i++) { - unsigned num_components = - nir_intrinsic_infos[intrin->intrinsic].src_components[i]; - if (!num_components) - num_components = intrin->num_components; + unsigned num_components = nir_intrinsic_src_components(intrin, i); while (copy_prop_src(&intrin->src[i], instr, NULL, num_components)) progress = true; diff --git a/src/compiler/nir/nir_validate.c b/src/compiler/nir/nir_validate.c index 5566ceb2985..eee737e8069 100644 --- a/src/compiler/nir/nir_validate.c +++ b/src/compiler/nir/nir_validate.c @@ -483,10 +483,7 @@ validate_intrinsic_instr(nir_intrinsic_instr *instr, validate_state *state) unsigned num_srcs = nir_intrinsic_infos[instr->intrinsic].num_srcs; for (unsigned i = 0; i < num_srcs; i++) { - unsigned components_read = - nir_intrinsic_infos[instr->intrinsic].src_components[i]; - if (components_read == 0) - components_read = instr->num_components; + unsigned components_read = nir_intrinsic_src_components(instr, i); validate_assert(state, components_read > 0); @@ -499,10 +496,7 @@ validate_intrinsic_instr(nir_intrinsic_instr *instr, validate_state *state) } if (nir_intrinsic_infos[instr->intrinsic].has_dest) { - unsigned components_written = - nir_intrinsic_infos[instr->intrinsic].dest_components; - if (components_written == 0) - components_written = instr->num_components; + unsigned components_written = nir_intrinsic_dest_components(instr); validate_assert(state, components_written > 0); diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c index 72ab426e805..b7c07064d9d 100644 --- a/src/compiler/spirv/spirv_to_nir.c +++ b/src/compiler/spirv/spirv_to_nir.c @@ -2434,8 +2434,7 @@ vtn_handle_image(struct vtn_builder *b, SpvOp opcode, struct vtn_value *val = vtn_push_value(b, w[2], vtn_value_type_ssa); struct vtn_type *type = vtn_value(b, w[1], vtn_value_type_type)->type; - unsigned dest_components = - nir_intrinsic_infos[intrin->intrinsic].dest_components; + unsigned dest_components = nir_intrinsic_dest_components(intrin); if (intrin->intrinsic == nir_intrinsic_image_var_size) { dest_components = intrin->num_components = glsl_get_vector_elements(type->type); |