Richard Biener <rguent...@suse.de> writes:
> The following adds a target hook to specify whether regs of MODE can be
> used to transfer bits.  The hook is supposed to be used for value-numbering
> to decide whether a value loaded in such mode can be punned to another
> mode instead of re-loading the value in the other mode and for SRA to
> decide whether MODE is suitable as container holding a value to be
> used in different modes.
>
> Bootstrapped and tested on x86_64-unknown-linux-gnu, OK this way?

LGTM FWIW.

Richard

>
> Thanks,
> Richard.
>
>       * target.def (mode_can_transfer_bits): New target hook.
>       * target.h (mode_can_transfer_bits): New function wrapping the
>       hook and providing default behavior.
>       * doc/tm.texi.in: Update.
>       * doc/tm.texi: Re-generate.
> ---
>  gcc/doc/tm.texi    |  6 ++++++
>  gcc/doc/tm.texi.in |  2 ++
>  gcc/target.def     |  8 ++++++++
>  gcc/target.h       | 16 ++++++++++++++++
>  4 files changed, 32 insertions(+)
>
> diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
> index c7535d07f4d..fa53c23f1de 100644
> --- a/gcc/doc/tm.texi
> +++ b/gcc/doc/tm.texi
> @@ -4545,6 +4545,12 @@ is either a declaration of type int or accessed by 
> dereferencing
>  a pointer to int.
>  @end deftypefn
>  
> +@deftypefn {Target Hook} bool TARGET_MODE_CAN_TRANSFER_BITS (machine_mode 
> @var{mode})
> +Define this to return false if the mode @var{mode} cannot be used
> +for memory copying.  The default is to assume modes with the same
> +precision as size are fine to be used.
> +@end deftypefn
> +
>  @deftypefn {Target Hook} machine_mode TARGET_TRANSLATE_MODE_ATTRIBUTE 
> (machine_mode @var{mode})
>  Define this hook if during mode attribute processing, the port should
>  translate machine_mode @var{mode} to another mode.  For example, rs6000's
> diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
> index 64cea3b1eda..8af3f414505 100644
> --- a/gcc/doc/tm.texi.in
> +++ b/gcc/doc/tm.texi.in
> @@ -3455,6 +3455,8 @@ stack.
>  
>  @hook TARGET_REF_MAY_ALIAS_ERRNO
>  
> +@hook TARGET_MODE_CAN_TRANSFER_BITS
> +
>  @hook TARGET_TRANSLATE_MODE_ATTRIBUTE
>  
>  @hook TARGET_SCALAR_MODE_SUPPORTED_P
> diff --git a/gcc/target.def b/gcc/target.def
> index 3de1aad4c84..4356ef2f974 100644
> --- a/gcc/target.def
> +++ b/gcc/target.def
> @@ -3363,6 +3363,14 @@ a pointer to int.",
>   bool, (ao_ref *ref),
>   default_ref_may_alias_errno)
>  
> +DEFHOOK
> +(mode_can_transfer_bits,
> + "Define this to return false if the mode @var{mode} cannot be used\n\
> +for memory copying.  The default is to assume modes with the same\n\
> +precision as size are fine to be used.",
> + bool, (machine_mode mode),
> + NULL)
> +
>  /* Support for named address spaces.  */
>  #undef HOOK_PREFIX
>  #define HOOK_PREFIX "TARGET_ADDR_SPACE_"
> diff --git a/gcc/target.h b/gcc/target.h
> index c1f99b97b86..837651d273a 100644
> --- a/gcc/target.h
> +++ b/gcc/target.h
> @@ -312,6 +312,22 @@ estimated_poly_value (poly_int64 x,
>      return targetm.estimated_poly_value (x, kind);
>  }
>  
> +/* Return true when MODE can be used to copy GET_MODE_BITSIZE bits
> +   unchanged.  */
> +
> +inline bool
> +mode_can_transfer_bits (machine_mode mode)
> +{
> +  if (mode == BLKmode)
> +    return true;
> +  if (maybe_ne (GET_MODE_BITSIZE (mode),
> +             GET_MODE_UNIT_PRECISION (mode) * GET_MODE_NUNITS (mode)))
> +    return false;
> +  if (targetm.mode_can_transfer_bits)
> +    return targetm.mode_can_transfer_bits (mode);
> +  return true;
> +}
> +
>  #ifdef GCC_TM_H
>  
>  #ifndef CUMULATIVE_ARGS_MAGIC

Reply via email to