diff options
author | Richard Sandiford <richard.sandiford@arm.com> | 2023-11-11 17:28:57 +0000 |
---|---|---|
committer | Richard Sandiford <richard.sandiford@arm.com> | 2023-11-11 17:28:57 +0000 |
commit | 4b803fbf839439b1deca660e32d5ced211111dfa (patch) | |
tree | 94f0afe9e4cadef16f7e6d4c4e6f5a9ddea25f14 | |
parent | e59ec35276599805cdc6c3979d8a167b027d286e (diff) | |
download | gcc-4b803fbf839439b1deca660e32d5ced211111dfa.zip gcc-4b803fbf839439b1deca660e32d5ced211111dfa.tar.gz gcc-4b803fbf839439b1deca660e32d5ced211111dfa.tar.bz2 |
mode-switching: Allow targets to set the mode for EH handlers
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.
-rw-r--r-- | gcc/doc/tm.texi | 6 | ||||
-rw-r--r-- | gcc/doc/tm.texi.in | 2 | ||||
-rw-r--r-- | gcc/mode-switching.cc | 5 | ||||
-rw-r--r-- | gcc/target.def | 7 |
4 files changed, 19 insertions, 1 deletions
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index 759331a..1a825c5 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 a7b7aa2..5360c1b 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 1145350..b8a887d 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 3dae335..a70275b 100644 --- a/gcc/target.def +++ b/gcc/target.def @@ -7071,6 +7071,13 @@ 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\ are processed. 0 is the highest priority,\n\ |