diff options
author | Rob Clark <[email protected]> | 2018-03-28 08:32:10 -0400 |
---|---|---|
committer | Rob Clark <[email protected]> | 2018-04-03 06:08:56 -0400 |
commit | 51888bf07dd2f9942708f9a265b18a129ee625f1 (patch) | |
tree | 980aa77e4a11fc7360cb734cd252a62fa13c8787 /src/compiler/nir/nir.h | |
parent | 91f9450b3222469d93c270b8ca5fb4bf2ef584f2 (diff) |
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 <[email protected]>
Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/compiler/nir/nir.h')
-rw-r--r-- | src/compiler/nir/nir.h | 22 |
1 files changed, 22 insertions, 0 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 \ |