[Mesa-dev] [PATCH 2.5/23] intel/eu: Define SET_BITS helper more easily reusable than SET_FIELD.
Kenneth Graunke
kenneth at whitecape.org
Wed Jun 27 06:05:50 UTC 2018
On Tuesday, June 26, 2018 6:22:08 PM PDT Francisco Jerez wrote:
> Allows to specify a bitfield based on its upper and lower bounds
> instead of a symbolic field definition, kind of what the current
> GET_BITS macro is to GET_FIELD.
> ---
> src/intel/compiler/brw_eu_defines.h | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/src/intel/compiler/brw_eu_defines.h b/src/intel/compiler/brw_eu_defines.h
> index ee306a6c2ce..565cba3d838 100644
> --- a/src/intel/compiler/brw_eu_defines.h
> +++ b/src/intel/compiler/brw_eu_defines.h
> @@ -46,6 +46,13 @@
> fieldval & field ## _MASK; \
> })
>
> +#define SET_BITS(value, high, low) \
> + ({ \
> + const uint32_t fieldval = (value) << (low); \
> + assert((fieldval & ~INTEL_MASK(high, low)) == 0); \
> + fieldval & INTEL_MASK(high, low); \
> + })
> +
> #define GET_BITS(data, high, low) ((data & INTEL_MASK((high), (low))) >> (low))
> #define GET_FIELD(word, field) (((word) & field ## _MASK) >> field ## _SHIFT)
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part.
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20180626/8c5f7f8e/attachment.sig>
More information about the mesa-dev
mailing list