From 20b962232b71c8f5931ddb585386725804dbd4e0 Mon Sep 17 00:00:00 2001 From: Francisco Jerez Date: Mon, 25 Jun 2018 12:06:50 -0700 Subject: [PATCH] intel/eu: Define SET_BITS helper more easily reusable than SET_FIELD. 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. Reviewed-by: Kenneth Graunke --- 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 f6d771d1534..fb8caa60715 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) -- 2.30.2