From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id 9ADBA3856943 for ; Sun, 5 Nov 2023 18:48:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9ADBA3856943 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 9ADBA3856943 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699210112; cv=none; b=CAGJXGZu0Q/jC/3Mb9hcsRtHT1L+kwyadS6dlgt/9zMFdPyNQhP8PC7QjDTLH5mzDvC1/katlG5aXn10rkptsxzqX3Ev7P75zVw3qGREq6L67hzjjU+Bdx9tjevPGydxdnKFtVkb+ZhKuhSV9zAnLOg7hXmix3zwqPtJWhzqVFQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699210112; c=relaxed/simple; bh=i5vhLQVtM7W+fzUGxizUHvdV3xavEj0J1gsNHxXqJGE=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=jj6T2qnVR4rECFYgwCX0QX1slhufj5kHzJaFUCUsX/3oZj9E8pcymu2LjORxuXucAJb/bK/d0gQC0XbHhac/MfKG/Nzwp09Fm8yrvb5zyk8Ew6JdpSnNpQPRcWmlEk3syggzqOJ1mzwGwSO2UrTipHUzLiTyI3bwfyKrHkK39Bs= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 30C6EC15; Sun, 5 Nov 2023 10:49:15 -0800 (PST) Received: from localhost (e121540-lin.manchester.arm.com [10.32.110.72]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E1B7F3F703; Sun, 5 Nov 2023 10:48:30 -0800 (PST) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org,jlaw@ventanamicro.com, richard.sandiford@arm.com Cc: jlaw@ventanamicro.com Subject: [PATCH 07/12] mode-switching: Allow targets to set the mode for EH handlers References: Date: Sun, 05 Nov 2023 18:48:29 +0000 In-Reply-To: (Richard Sandiford's message of "Sun, 05 Nov 2023 18:45:29 +0000") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-23.4 required=5.0 tests=BAYES_00,GIT_PATCH_0,KAM_DMARC_NONE,KAM_DMARC_STATUS,KAM_LAZY_DOMAIN_SECURITY,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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