public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Sandiford <richard.sandiford@arm.com>
To: gcc-patches@gcc.gnu.org
Cc: jlaw@ventanamicro.com
Subject: [PATCH 07/12] mode-switching: Allow targets to set the mode for EH handlers
Date: Sun, 05 Nov 2023 18:48:29 +0000	[thread overview]
Message-ID: <mpty1fc6npe.fsf@arm.com> (raw)
In-Reply-To: <mpt34xk9gza.fsf@arm.com> (Richard Sandiford's message of "Sun, 05 Nov 2023 18:45:29 +0000")

The mode-switching pass already had hooks to say what mode
an entity is in on entry to a function and what mode it must
be in on return.  For SME, we also want to say what mode an
entity is guaranteed to be in on entry to an exception handler.

gcc/
	* target.def (mode_switching.eh_handler): New hook.
	* doc/tm.texi.in (TARGET_MODE_EH_HANDLER): New @hook.
	* doc/tm.texi: Regenerate.
	* mode-switching.cc (optimize_mode_switching): Use eh_handler
	to get the mode on entry to an exception handler.
---
 gcc/doc/tm.texi       | 6 ++++++
 gcc/doc/tm.texi.in    | 2 ++
 gcc/mode-switching.cc | 5 ++++-
 gcc/target.def        | 7 +++++++
 4 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index 759331a2c96..1a825c5004e 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -10455,6 +10455,12 @@ If @code{TARGET_MODE_EXIT} is defined then @code{TARGET_MODE_ENTRY}
 must be defined.
 @end deftypefn
 
+@deftypefn {Target Hook} int TARGET_MODE_EH_HANDLER (int @var{entity})
+If this hook is defined, it should return the mode that @var{entity} is
+guaranteed to be in on entry to an exception handler, or the number of modes
+if there is no such guarantee.
+@end deftypefn
+
 @deftypefn {Target Hook} int TARGET_MODE_PRIORITY (int @var{entity}, int @var{n})
 This hook specifies the order in which modes for @var{entity}
 are processed. 0 is the highest priority,
diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
index a7b7aa289d8..5360c1bb2d8 100644
--- a/gcc/doc/tm.texi.in
+++ b/gcc/doc/tm.texi.in
@@ -6979,6 +6979,8 @@ mode or ``no mode'', depending on context.
 
 @hook TARGET_MODE_EXIT
 
+@hook TARGET_MODE_EH_HANDLER
+
 @hook TARGET_MODE_PRIORITY
 
 @node Target Attributes
diff --git a/gcc/mode-switching.cc b/gcc/mode-switching.cc
index 1145350ca26..b8a887d81f7 100644
--- a/gcc/mode-switching.cc
+++ b/gcc/mode-switching.cc
@@ -597,7 +597,10 @@ optimize_mode_switching (void)
 		gcc_assert (NOTE_INSN_BASIC_BLOCK_P (ins_pos));
 		if (ins_pos != BB_END (bb))
 		  ins_pos = NEXT_INSN (ins_pos);
-		ptr = new_seginfo (no_mode, no_mode, ins_pos, live_now);
+		if (bb_has_eh_pred (bb)
+		    && targetm.mode_switching.eh_handler)
+		  last_mode = targetm.mode_switching.eh_handler (e);
+		ptr = new_seginfo (no_mode, last_mode, ins_pos, live_now);
 		add_seginfo (&tail_ptr, ptr);
 		bitmap_clear_bit (transp_all, bb->index);
 	      }
diff --git a/gcc/target.def b/gcc/target.def
index 3dae33522f1..a70275b8abd 100644
--- a/gcc/target.def
+++ b/gcc/target.def
@@ -7070,6 +7070,13 @@ If @code{TARGET_MODE_EXIT} is defined then @code{TARGET_MODE_ENTRY}\n\
 must be defined.",
  int, (int entity), NULL)
 
+DEFHOOK
+(eh_handler,
+ "If this hook is defined, it should return the mode that @var{entity} is\n\
+guaranteed to be in on entry to an exception handler, or the number of modes\n\
+if there is no such guarantee.",
+ int, (int entity), NULL)
+
 DEFHOOK
 (priority,
  "This hook specifies the order in which modes for @var{entity}\n\
-- 
2.25.1


  parent reply	other threads:[~2023-11-05 18:48 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-05 18:45 [PATCH 00/12] Tweaks and extensions to the mode-switching pass Richard Sandiford
2023-11-05 18:46 ` [PATCH 01/12] mode-switching: Tweak the macro/hook documentation Richard Sandiford
2023-11-07  0:10   ` Jeff Law
2023-11-05 18:46 ` [PATCH 02/12] mode-switching: Add note problem Richard Sandiford
2023-11-07  0:11   ` Jeff Law
2023-11-05 18:47 ` [PATCH 03/12] mode-switching: Avoid quadractic list operation Richard Sandiford
2023-11-07  0:47   ` Jeff Law
2023-11-05 18:47 ` [PATCH 04/12] mode-switching: Fix the mode passed to the emit hook Richard Sandiford
2023-11-07  0:51   ` Jeff Law
2023-11-05 18:47 ` [PATCH 05/12] mode-switching: Simplify recording of transparency Richard Sandiford
2023-11-07  0:52   ` Jeff Law
2023-11-05 18:48 ` [PATCH 06/12] mode-switching: Tweak entry/exit handling Richard Sandiford
2023-11-07  1:01   ` Jeff Law
2023-11-05 18:48 ` Richard Sandiford [this message]
2023-11-07  1:07   ` [PATCH 07/12] mode-switching: Allow targets to set the mode for EH handlers Jeff Law
2023-11-08  0:15     ` Richard Sandiford
2023-11-08  2:24       ` Jeff Law
2023-11-05 18:48 ` [PATCH 08/12] mode-switching: Pass set of live registers to the needed hook Richard Sandiford
2023-11-07  1:11   ` Jeff Law
2023-11-05 18:49 ` [PATCH 09/12] mode-switching: Pass the set of live registers to the after hook Richard Sandiford
2023-11-07  1:12   ` Jeff Law
2023-11-05 18:49 ` [PATCH 10/12] mode-switching: Use 1-based edge aux fields Richard Sandiford
2023-11-07  2:53   ` Jeff Law
2023-11-08  0:35     ` Richard Sandiford
2023-11-08  2:22       ` Jeff Law
2023-11-11 15:51         ` Richard Sandiford
2023-11-11 16:19           ` Jeff Law
2023-11-05 18:50 ` [PATCH 11/12] mode-switching: Add a target-configurable confluence operator Richard Sandiford
2023-11-07  3:04   ` Jeff Law
2023-11-11 15:54     ` Richard Sandiford
2023-11-11 16:19       ` Jeff Law
2023-11-11 17:29         ` Richard Sandiford
2023-11-05 18:50 ` [PATCH 12/12] mode-switching: Add a backprop hook Richard Sandiford
2023-11-10  1:18   ` Jeff Law

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=mpty1fc6npe.fsf@arm.com \
    --to=richard.sandiford@arm.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jlaw@ventanamicro.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).