[PATCH 2/6] sframe.h: make some macros more precise

Hans-Peter Nilsson hp@bitrange.com
Wed Dec 7 23:52:09 GMT 2022


On Wed, 7 Dec 2022, Indu Bhagat via Binutils wrote:
> include/ChangeLog:
> 
> 	* sframe.h (SFRAME_V1_FUNC_INFO): Use specific bits only.
> 	(SFRAME_V1_FRE_INFO): Likewise.
> ---
>  include/sframe.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/include/sframe.h b/include/sframe.h
> index 7e31284e4d8..ba557b7bf7a 100644
> --- a/include/sframe.h
> +++ b/include/sframe.h
> @@ -192,7 +192,7 @@ typedef struct sframe_func_desc_entry
>  /* Macros to compose and decompose function info in FDE.  */
>  
>  #define SFRAME_V1_FUNC_INFO(fde_type, fre_enc_type) \
> -  (((fde_type) & 0x1) << 4 | (fre_enc_type))
> +  (((fde_type) & 0x1) << 4 | (fre_enc_type & 0xf))

Random comment:  you removed the full parenthesisation (sp?) of 
macro arguments here; compare to handling fde_type.  ITYM:
+ (((fde_type) & 0x1) << 4 | ((fre_enc_type) & 0xf))

Looks like the SFframe code "has improvement potential" in this 
regard, because right in the context of your patch, there's:

>  #define SFRAME_V1_FUNC_FRE_TYPE(data)	  ((data) & 0xf)
>  #define SFRAME_V1_FUNC_FDE_TYPE(data)	  ((data >> 4) & 0x1)

(Pre-existing badness for SFRAME_V1_FUNC_FDE_TYPE compared to 
the goodness for SFRAME_V1_FUNC_FRE_TYPE.)

> @@ -240,7 +240,7 @@ typedef struct sframe_fre_info
>  /* Macros to compose and decompose FRE info.  */
>  
>  #define SFRAME_V1_FRE_INFO(base_reg_id, offset_num, offset_size) \
> -  ((offset_size << 5) | (offset_num << 1) | (base_reg_id))
> +  (((offset_size & 0x3) << 5) | ((offset_num & 0xf) << 1) | (base_reg_id & 0x1))

Also, here too, you just added one more.  But better improve it 
than making it ever so slightly worse.

brgds, H-P


More information about the Binutils mailing list