From 51888bf07dd2f9942708f9a265b18a129ee625f1 Mon Sep 17 00:00:00 2001 From: Rob Clark Date: Wed, 28 Mar 2018 08:32:10 -0400 Subject: nir+drivers: add helpers to get # of src/dest components Add helpers to get the number of src/dest components for an intrinsic, and update spots that were open-coding this logic to use the helpers instead. Signed-off-by: Rob Clark Reviewed-by: Eric Anholt --- src/compiler/nir/nir.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/compiler/nir/nir.h') 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 \ -- cgit v1.2.3