From patchwork Wed Jun 5 01:50:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fei Gao X-Patchwork-Id: 1943613 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Vv9Zh4RShz20Tb for ; Wed, 5 Jun 2024 11:57:32 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4034E383A499 for ; Wed, 5 Jun 2024 01:57:29 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from azure-sdnproxy.icoremail.net (azure-sdnproxy.icoremail.net [20.231.56.155]) by sourceware.org (Postfix) with ESMTP id 786B0383A489 for ; Wed, 5 Jun 2024 01:55:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 786B0383A489 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=eswincomputing.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=eswincomputing.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 786B0383A489 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=20.231.56.155 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1717552531; cv=none; b=JU3mz8nZxQQl+u5UAYVgZOkKKWwc7Vo4MvKvEuL4+u5/RSOWKT8ZPYEuRFelA6MBuyn9CelKHbl8KTUfHk6rTNaVzho+TxIQwNby2gjm1e84sw2Zav8uPrySrlRyj1Nqdko1P3i4NByj9wDpInkSF9gDRMmWFE+spOMIIcL5G9k= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1717552531; c=relaxed/simple; bh=zClbfHa0jQBzDyl91E7b4uFB1NsnJ4/1gtN7NRMXnGw=; h=From:To:Subject:Date:Message-Id; b=sIS6iFI3T4XEN/lZdqM9eAhshKx5/360N8eKcU2b28jTYuc/ykbyA5yIFVfzRr31MGIqM1XKCr54POtOZXUKzIA19+6WAE7KsvJeTKog9RU73RT+msVGW6uGvglHtPcMyTocUEjE4tyrkZed7BfzDaX3lZnZu4xzW6mOCNYbbnA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from localhost.localdomain (unknown [10.12.130.31]) by app2 (Coremail) with SMTP id TQJkCgAXKrzyxF9mZ10OAA--.38358S5; Wed, 05 Jun 2024 09:52:52 +0800 (CST) From: Fei Gao To: gcc-patches@gcc.gnu.org Cc: kito.cheng@gmail.com, palmer@dabbelt.com, jeffreyalaw@gmail.com, gaofei@eswincomputing.com Subject: [PATCH 1/2] target hooks: allow post processing after epilogue inserted. Date: Wed, 5 Jun 2024 01:50:23 +0000 Message-Id: <20240605015024.7845-2-gaofei@eswincomputing.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240605015024.7845-1-gaofei@eswincomputing.com> References: <20240605015024.7845-1-gaofei@eswincomputing.com> X-CM-TRANSID: TQJkCgAXKrzyxF9mZ10OAA--.38358S5 X-Coremail-Antispam: 1UD129KBjvJXoWxur4fAFW7KryrXw17WFW5Awb_yoWrWF43pa 18Ar15Zrn5GrZYgryftF4xXF4fGrZ3WrWUGFZrXa47Cw1DWryfJFZ8KFWYkw43Xws8Crn3 ZF42vFy7Za15ua7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUBF14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_Jr4l82xGYIkIc2 x26xkF7I0E14v26r1Y6r1xM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJw A2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq3wAS 0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2 IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0 Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCY02Avz4vE-syl42xK82IYc2 Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s02 6x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0x vE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r1j6r4UMIIF0xvE 42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6x kF7I0E14v26r1j6r4UYxBIdaVFxhVjvjDU0xZFpf9x0JUHHq7UUUUU= X-CM-SenderInfo: xjdrwv3l6h245lqf0zpsxwx03jof0z/ X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Define TARGET_POST_EPILOGUE_PROC if you have additional processing after epilogue is inserted into a basic block. gcc/ChangeLog: * doc/tm.texi: Regenerate. * doc/tm.texi.in: Document TARGET_POST_EPILOGUE_PROC. * function.cc (thread_prologue_and_epilogue_insns): Allow targets to have additional processingafter epilogue is inserted into a basic block. * hooks.cc (hook_void_rtx_insn): Define default handler. * hooks.h (hook_void_rtx_insn): Declare. * target.def: New hook. Signed-off-by: Fei Gao --- gcc/doc/tm.texi | 5 +++++ gcc/doc/tm.texi.in | 2 ++ gcc/function.cc | 2 ++ gcc/hooks.cc | 7 +++++++ gcc/hooks.h | 1 + gcc/target.def | 8 ++++++++ 6 files changed, 25 insertions(+) diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index cd50078227d..666a08c0406 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -5299,6 +5299,11 @@ This hook should add additional registers that are computed by the prologue to the hard regset for shrink-wrapping optimization purposes. @end deftypefn +@deftypefn {Target Hook} void TARGET_POST_EPILOGUE_PROC (rtx_insn *@var{}) +Define this hook if you have additional processing after epilogue is +inserted into a basic block. +@end deftypefn + @deftypefn {Target Hook} bool TARGET_WARN_FUNC_RETURN (tree) True if a function's return statements should be checked for matching the function's return type. This includes checking for falling off the end diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in index 058bd56487a..218e5d9dc20 100644 --- a/gcc/doc/tm.texi.in +++ b/gcc/doc/tm.texi.in @@ -3754,6 +3754,8 @@ the function prologue. Normally, the profiling code comes after. @hook TARGET_SET_UP_BY_PROLOGUE +@hook TARGET_POST_EPILOGUE_PROC + @hook TARGET_WARN_FUNC_RETURN @node Shrink-wrapping separate components diff --git a/gcc/function.cc b/gcc/function.cc index 4edd4da1247..6f3027972ee 100644 --- a/gcc/function.cc +++ b/gcc/function.cc @@ -6258,6 +6258,8 @@ thread_prologue_and_epilogue_insns (void) } } + targetm.post_epilogue_proc (epilogue_seq); + /* Threading the prologue and epilogue changes the artificial refs in the entry and exit blocks, and may invalidate DF info for tail calls. */ if (optimize diff --git a/gcc/hooks.cc b/gcc/hooks.cc index 28769074222..40844dd3593 100644 --- a/gcc/hooks.cc +++ b/gcc/hooks.cc @@ -501,6 +501,13 @@ hook_bool_rtx_insn_int_false (rtx_insn *, int) return false; } +/* Generic hook that takes a rtx_insn * and returns void. */ + +void +hook_void_rtx_insn (rtx_insn *) +{ +} + /* Generic hook that takes a rtx_insn * and an int and returns void. */ void diff --git a/gcc/hooks.h b/gcc/hooks.h index 924748420e6..4b2f47c61c1 100644 --- a/gcc/hooks.h +++ b/gcc/hooks.h @@ -60,6 +60,7 @@ extern bool hook_bool_const_tree_hwi_hwi_const_tree_true (const_tree, extern bool hook_bool_rtx_insn_true (rtx_insn *); extern bool hook_bool_rtx_false (rtx); extern bool hook_bool_rtx_insn_int_false (rtx_insn *, int); +extern void hook_void_rtx_insn (rtx_insn *); extern bool hook_bool_uintp_uintp_false (unsigned int *, unsigned int *); extern bool hook_bool_reg_class_t_false (reg_class_t regclass); extern bool hook_bool_mode_mode_reg_class_t_true (machine_mode, machine_mode, diff --git a/gcc/target.def b/gcc/target.def index c27df8095be..cd23f569e0b 100644 --- a/gcc/target.def +++ b/gcc/target.def @@ -6840,6 +6840,14 @@ to the hard regset for shrink-wrapping optimization purposes.", void, (struct hard_reg_set_container *), NULL) +/* Post epilogue processing. */ +DEFHOOK +(post_epilogue_proc, + "Define this hook if you have additional processing after epilogue is\n\ +inserted into a basic block.", + void, (rtx_insn *), + hook_void_rtx_insn) + /* For targets that have attributes that can affect whether a function's return statements need checking. For instance a 'naked' function attribute. */