summaryrefslogtreecommitdiff
path: root/0138-Backport-SME-mode-switching-Allow-targets-to-set-the.patch
diff options
context:
space:
mode:
Diffstat (limited to '0138-Backport-SME-mode-switching-Allow-targets-to-set-the.patch')
-rw-r--r--0138-Backport-SME-mode-switching-Allow-targets-to-set-the.patch93
1 files changed, 93 insertions, 0 deletions
diff --git a/0138-Backport-SME-mode-switching-Allow-targets-to-set-the.patch b/0138-Backport-SME-mode-switching-Allow-targets-to-set-the.patch
new file mode 100644
index 0000000..8d066b2
--- /dev/null
+++ b/0138-Backport-SME-mode-switching-Allow-targets-to-set-the.patch
@@ -0,0 +1,93 @@
+From 9505464aec8f95125293c64e2eea9577e9be4700 Mon Sep 17 00:00:00 2001
+From: Richard Sandiford <richard.sandiford@arm.com>
+Date: Sat, 11 Nov 2023 17:28:57 +0000
+Subject: [PATCH 039/157] [Backport][SME] mode-switching: Allow targets to set
+ the mode for EH handlers
+
+Reference: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=4b803fbf839439b1deca660e32d5ced211111dfa
+
+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 553aa4cf2..4788b3f7a 100644
+--- a/gcc/doc/tm.texi
++++ b/gcc/doc/tm.texi
+@@ -10321,6 +10321,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 9ec11b15c..ad343504f 100644
+--- a/gcc/doc/tm.texi.in
++++ b/gcc/doc/tm.texi.in
+@@ -6926,6 +6926,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 4761c2ff0..9a6ba6cca 100644
+--- a/gcc/mode-switching.cc
++++ b/gcc/mode-switching.cc
+@@ -596,7 +596,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 b87b0f927..bbb482de6 100644
+--- a/gcc/target.def
++++ b/gcc/target.def
+@@ -7042,6 +7042,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.33.0
+