From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from sonicconh6001-vm0.mail.ssk.yahoo.co.jp (sonicconh6001-vm0.mail.ssk.yahoo.co.jp [182.22.37.9]) by sourceware.org (Postfix) with ESMTPS id DC2A63A1EE49 for ; Fri, 21 Oct 2022 22:46:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DC2A63A1EE49 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=yahoo.co.jp Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=yahoo.co.jp X-YMail-OSG: FuE_mikVM1m.wDdXjG603i782D.yZkU_NoYPtA2rtQJWZJ5JPDSq7tqeQLpozqY GQ6p5eT5k320N65A_lCN_R2FrbRn0O_ZuTTy87M1gmyRmxf20ooSqIT7peoQ4g_tk6cFD_IorsG0 z6gvV9wSF01XBXnU3lxatqC7X4EroTZDWZ8aiKPAuz7wbq5UXMGBK58H1_Hfrc_O.jr8axLH36Kb _jqupxl628WruoWCalVKe8vbytAcqsIbqzs4Vhx5AFBFp7tnhYs3eqq3bi0RvetttBc7GqiCJwFR aNVNllZPFsaDEty0VyM_85Z4hHzCq2VOh24logP8q8eOXv_xK9C8PYFQrwmvpQs3gTDsjomEgvVl O_eoBmTtCkFjWTLNDpkPCcY5i3W33I5Ilex6V2dxpeKbQdRVG4fJ1sYLxJIQqqpThK_udAZl.wv3 vbjpytdJyYCakuNAM.1zE6TGR066HggsyJAttBoYxsUc7vT3OkDK5kbFp9nTc5BPljFrFE4CugAr C6SAGbaCBroVJp4udbOdpCWz13eyOIRIdSRSVvQvLEl2QR8TZG9y2btiXnKtu3oKr5yP6jK6XQJO A0t8sZt_yhGVZJ1QY5GBSD4pA37lITFqGq5AzUQFy..kG2HrBpvbyPJgX4W5.Z4wzv2UFFCaefLV vYPfaYzMorQ5eMj5_cL2SpDfFhGakrCT5sC5ExtbR1t8zR.qY930.kFKKZTegOV5Jaw2kcZSL9qj OyeoZ6gmNDkGNuVXTLH_BupC18gkuR3nOklLvwebvpQ1Lu5bg9x8foE3siV9ij0h9W.XUyoqMH.c dXt9Fn8QRPXM8XfJuGpn7i04nMOACMdC7m8H7QPSqkShrRt8TuNvfBlnSZDcLmJsoDwY3u7fv2xQ sPX0qvSIB6i6u711boefLwwf_r3weZpZE1xEn.pDMapfS94M2XMyTIawAt3j7B8_cpniDhNgO3vj V Received: from sonicgw.mail.yahoo.co.jp by sonicconh6001.mail.ssk.yahoo.co.jp with HTTP; Fri, 21 Oct 2022 22:46:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1666392379; s=yj20110701; d=yahoo.co.jp; h=Message-ID:Date:MIME-Version:Subject:To:References:Cc:From:In-Reply-To:Content-Type:Content-Transfer-Encoding; bh=cJgLbbakmWug4weFMQ5EJJ5ymNM/lmf/iSbQ+n4A2VA=; b=mg9KuGEWXyR+qAjl61tWT/VDufJNf4GE4v9Dyu5ZHxhDjLvorLAVnhrQgdMOOFZj lGNcbbAHQb5LlR6PqVXuqDq5REanPg6rML+rfbir49Iq+TjuZPU4JeTEwCXQDitQA0D 1h/WJAFekmlIHGt22W4O4QXbLHtGRH9C/6wedi6s= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=yj20110701; d=yahoo.co.jp; h=Message-ID:Date:MIME-Version:References:Cc:From:In-Reply-To:Content-Type:Content-Transfer-Encoding; b=nIw1GYKBjzU93FWxgLLKKd/C7t7v6FdhpsdUsDZxMqDE0f8Ld5LPqkGly3mDsDu5 imB2lYBnJ2a0GQwNgrM8Gg5ZaTE1OdYmNdcyGzFfvycmyu4TwxL1lhWj8W8RkbF7WQ9 wglrnT40oRzFmJHbRQ3AfCfr+1vVvtFsn52+oUnI=; Received: by smtphe6004.mail.ssk.ynwp.yahoo.co.jp (YJ Hermes SMTP Server) with ESMTPA ID 6c038af2e170f346891c5dd14ba782b1; Sat, 22 Oct 2022 07:46:15 +0900 (JST) Message-ID: Date: Sat, 22 Oct 2022 07:46:13 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.4.0 Subject: [PATCH v2] xtensa: Make register A0 allocable for the CALL0 ABI To: GCC Patches References: Cc: Max Filippov From: Takayuki 'January June' Suwa In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP 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: This patch offers an additional allocable register by RA for the CALL0 ABI. > Register a0 holds the return address upon entry to a function, but > unlike the windowed register ABI, it is not reserved for this purpose > and may hold other values after the return address has been saved. - Xtensa ISA Reference Manual, 8.1.2 "CALL0 Register Usage and Stack Layout" [p.589] gcc/ChangeLog: * config/xtensa/xtensa.cc (xtensa_conditional_register_usage): Remove register A0 from FIXED_REGS if the CALL0 ABI. (xtensa_expand_epilogue): Change to emit '(use (reg:SI A0_REG))' unconditionally after restoring callee-saved registers for sibling-call functions, in order to prevent misleading that register A0 is free to use. --- gcc/config/xtensa/xtensa.cc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/gcc/config/xtensa/xtensa.cc b/gcc/config/xtensa/xtensa.cc index 950eb5a59be..94a98c25f8c 100644 --- a/gcc/config/xtensa/xtensa.cc +++ b/gcc/config/xtensa/xtensa.cc @@ -3471,15 +3471,14 @@ xtensa_expand_epilogue (bool sibcall_p) if (xtensa_call_save_reg(regno)) { rtx x = gen_rtx_PLUS (Pmode, stack_pointer_rtx, GEN_INT (offset)); - rtx reg; offset -= UNITS_PER_WORD; - emit_move_insn (reg = gen_rtx_REG (SImode, regno), + emit_move_insn (gen_rtx_REG (SImode, regno), gen_frame_mem (SImode, x)); - if (regno == A0_REG && sibcall_p) - emit_use (reg); } } + if (sibcall_p) + emit_use (gen_rtx_REG (SImode, A0_REG)); if (cfun->machine->current_frame_size > 0) { @@ -4970,6 +4969,13 @@ xtensa_conditional_register_usage (void) /* Remove hard FP register from the preferred reload registers set. */ CLEAR_HARD_REG_BIT (reg_class_contents[(int)RL_REGS], HARD_FRAME_POINTER_REGNUM); + + /* Register A0 holds the return address upon entry to a function + for the CALL0 ABI, but unlike the windowed register ABI, it is + not reserved for this purpose and may hold other values after + the return address has been saved. */ + if (!TARGET_WINDOWED_ABI) + fixed_regs[A0_REG] = 0; } /* Map hard register number to register class */ -- 2.30.2