]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Add TARGET_MODE_CAN_TRANSFER_BITS
authorRichard Biener <rguenther@suse.de>
Mon, 29 Jul 2024 11:06:52 +0000 (13:06 +0200)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 1 Aug 2024 10:27:04 +0000 (12:27 +0200)
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.

* 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
gcc/doc/tm.texi.in
gcc/target.def
gcc/target.h

index c7535d07f4ddd16d55e0ab9b609a2bf95931a2f4..cc33084ed32253b6c6a5269f5dcf0183cbe0e924 100644 (file)
@@ -4545,6 +4545,17 @@ 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 of @code{GET_MODE_SIZE (mode)} units.  This might be
+because a register class allowed for @var{mode} has registers that do
+not transparently transfer every bit pattern or because the load or
+store patterns available for @var{mode} have this issue.
+
+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
index 64cea3b1edaf8ec818c0e8095ab50b00ae0cb857..8af3f41450585532335d6cb54098c0bb550f6ae1 100644 (file)
@@ -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
index 3de1aad4c84d3df0b171a411f97e1ce70b6f63b5..1d0ea6f30caf03f8d1e46195e0015390dbc64ce7 100644 (file)
@@ -3363,6 +3363,19 @@ 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 of @code{GET_MODE_SIZE (mode)} units.  This might be\n\
+because a register class allowed for @var{mode} has registers that do\n\
+not transparently transfer every bit pattern or because the load or\n\
+store patterns available for @var{mode} have this issue.\n\
+\n\
+The default is to assume modes with the same precision as size are fine\n\
+to be used.",
+ bool, (machine_mode mode),
+ NULL)
+
 /* Support for named address spaces.  */
 #undef HOOK_PREFIX
 #define HOOK_PREFIX "TARGET_ADDR_SPACE_"
index c1f99b97b8642e9329cf709bd73aeff47d460bb0..837651d273af48a9def1a8a25ca4acb91b1dfca4 100644 (file)
@@ -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