From patchwork Fri Oct 21 22:46:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takayuki 'January June' Suwa X-Patchwork-Id: 7022 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp943774wrr; Fri, 21 Oct 2022 16:10:16 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6eVv+W3HF2MdWscRs0vA80yANWhfWJj2GzcFxNpSR/R1D7IXvu3jVd9qEVIY1IEKfWADK9 X-Received: by 2002:a05:6402:278c:b0:45c:da8e:837d with SMTP id b12-20020a056402278c00b0045cda8e837dmr19810894ede.18.1666393816661; Fri, 21 Oct 2022 16:10:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666393816; cv=none; d=google.com; s=arc-20160816; b=Lny67AD8to+LZ8MYBnOiVepcKAc+LCHBQv4b4OdwVqwkA1f+6H8pRSKkooiSaiZz2O 9NBCUaE8aqTglTGR4A3/ebMZHnShVTVFHQtmxVaiuZNRbfgz4MNOxzCaM7ceb5jM6RY8 KaRze57nGvWzE9L7i/zxgnzpgxOL+TkLOB8PBcA7yx/+x2uXKikJhZlLETHP8QQ1tSoD 4Ck/+gNAd4dUoBDSq7LgEH9DY2a/1qQ89F6C80+CkmK+7VbnJ5kWIBEbyYFUAE2O+zid UL43xA4LCJVf1IzTDRgg+C/E9Gjzy8Bwn8FLj/DofuGXYw/B9PRnB0XisOEtDL683Zyq FFCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:in-reply-to:references:to:subject :user-agent:mime-version:date:message-id:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=cJgLbbakmWug4weFMQ5EJJ5ymNM/lmf/iSbQ+n4A2VA=; b=diBGz4mGlEJfbG43JZwnXG4UTCFFy2slvnD2Lt0qpBNQYCI6cnNQt4q/rAWUZk85/Y hWviejXkyA0deUEX32XqGDeeSp7P+mkPP0HIOFvuPKZtK7lDb77yBRPEehxQYhC9YSzi e8y/+BLXa6Euy9jO0lq/YFxJJLFRBdsHiWhz/V6p3PpSgS1yAqzZwHBQJho7sVxhSVU5 rYk8BmOldRnNnYdCLfMz5FjF13XberCnCE+jWEndq980titrYqnjJkWjQJvKv36xKUjS XSt/33JQD5EqtaiWttwP3d6rzIXL/ztZtQ6l8Jn8HBJL8kQTO4gixpM8WNtM2L4hHiCo Ozfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="wjyH/f27"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id qa44-20020a17090786ac00b0078a10c159b4si21428632ejc.290.2022.10.21.16.10.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 16:10:16 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="wjyH/f27"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 69AB3392F2F7 for ; Fri, 21 Oct 2022 23:06:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 69AB3392F2F7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666393571; bh=cJgLbbakmWug4weFMQ5EJJ5ymNM/lmf/iSbQ+n4A2VA=; h=Date:Subject:To:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=wjyH/f27+3/wwu0J9bEWY6R/39ocPpJkK6bmhQyN9+cKqdsAEbrEhbx7zJ+D2WtaE btv1GFo5zQMaiOP7Rt0yImQOleM0ixjxPylwveIhOSMWhxWGKsMPLnR3pL1hRLvgg0 GC5ZYmOtM3pBavgwZaPAhcL9O7jMtH7dgTdAt8Dc= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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 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 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: In-Reply-To: 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Takayuki 'January June' Suwa via Gcc-patches From: Takayuki 'January June' Suwa Reply-To: Takayuki 'January June' Suwa Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747264388992400225?= X-GMAIL-MSGID: =?utf-8?q?1747340562847932752?= 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 */