Hi!

On Wed, Dec 18, 2019 at 05:15:21PM -0500, Michael Meissner wrote:
> In the patch:
> https://gcc.gnu.org/ml/gcc-patches/2019-12/msg01201.html
> 
> Segher Boessenkool asked me to submit a patch to rename the macros used to see
> if a number is a valid signed 16 or 34-bit value:
> 
> > Please follow up with a patch to not call random numbers "OFFSET".
> 
> This patch does this, renaming:
> 
>       SIGNED_34BIT_OFFSET_P   -> SIGNED_INTEGER_34BIT_P
>       SIGNED_16BIT_OFFSET_P   -> SIGNED_INTEGER_16BIT_P
> 
> I did not change the secondary macros (SIGNED_34BIT_OFFSET_EXTRA_P and
> SIGNED_16BIT_OFFSET_P), since those are exclusively used for offset
> calculations.  But I can if you prefer it that way.

No, that is fine.  It is also fine to keep the SIGNED_16BIT_OFFSET_P etc.
names around as well; that might be nicer code, too?  Names matter as well,
not just what the code does.

> @@ -24770,7 +24770,7 @@ address_to_insn_form (rtx addr,
>      return INSN_FORM_BAD;
>  
>    HOST_WIDE_INT offset = INTVAL (op1);
> -  if (!SIGNED_34BIT_OFFSET_P (offset))
> +  if (!SIGNED_INTEGER_34BIT_P (offset))
>      return INSN_FORM_BAD;

So you might want to keep this one?

> @@ -24789,7 +24789,7 @@ address_to_insn_form (rtx addr,
>      return INSN_FORM_BAD;
>  
>    /* Large offsets must be prefixed.  */
> -  if (!SIGNED_16BIT_OFFSET_P (offset))
> +  if (!SIGNED_INTEGER_16BIT_P (offset))

And this.

That is so few that this is fine, sure.

> +/* Whether a given VALUE is a valid 16 or 34-bit signed integer.  */
> +#define SIGNED_INTEGER_NBIT_P(VALUE, N)                                      
> \
>    IN_RANGE ((VALUE),                                                 \
> +         -(HOST_WIDE_INT_1 << ((N)-1)),                              \
> +         (HOST_WIDE_INT_1 << ((N)-1)) - 1)

(This evaluates N twice.  Macros are evil.)

Okay for trunk.  Thanks!


Segher

Reply via email to