From patchwork Sun Jul 14 11:02:14 2024 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: 93906 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CB7E8386182F for ; Sun, 14 Jul 2024 11:06:12 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from omggw7020-vm0.mail.djm.yahoo.co.jp (omggw7020-vm0.mail.djm.yahoo.co.jp [183.79.55.45]) by sourceware.org (Postfix) with ESMTPS id 15754385843B for ; Sun, 14 Jul 2024 11:05:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 15754385843B 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 ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 15754385843B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=183.79.55.45 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1720955137; cv=none; b=uEvoLrmcrby+lIoQhp+wX26VidHBnO/FO2r+bNwYfUtiTlbtXlBcXMeC2qNgpx4WUNPHahaBrQamkYg7EdonYyxrkjpDXofr0DuPDXHjRyi5sQOZIPbzROIswuO9kadrMHARSn4DSw+akRhRIJrdP6CLPhD0+q3hWe4a8x8mcNg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1720955137; c=relaxed/simple; bh=pZAjd/nJbqt3MlbhgLdwn4Cri3XtcOqj54izynYg99Y=; h=DKIM-Signature:Message-ID:Date:MIME-Version:To:From:Subject; b=qCM8DBpeqt8n4lMMFw17xIEy0+diKANGTKZix3UlcppnSJryQz3GK6c6r45KnSnwt1NTtAvsNK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Fh2mXV8nED_BOjbDVb8quRGz1NveV04ebjkfkYnPVJ6J9dtYjYyb2 c7IJ.uDxm8jFTBuJTIA02yMCgspr__ZnAV2V5g5Ni42biMXLh6sJJDLWr54rgfzQK104fQ5V2dzA Hop6qrh3fYME6Tf.Q1yfFxDUPSUY8Fwz7xn9hCt0D0TacI0QLjP6sHVb45r29gFUrLvb.EqSxrAN fZwYC2.pPoweIwiMohMlV0ICeUnkPvz.M7KqPm6bJVTv29ujPI_1Tb2y4rxWGmY3bmz6IJ1huKt8 3PvNE8hhQnIf3W98qN.r5 Received: from sonicgw.mail.yahoo.co.jp by sonicconh5001.mail.kks.yahoo.co.jp with HTTP; Sun, 14 Jul 2024 11:05:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1720954934; s=yj20110701; d=yahoo.co.jp; h=References:Content-Transfer-Encoding:Content-Type:Subject:From:Cc:To:MIME-Version:Date:Message-ID; bh=7qzXeQVV/mXw3RxFO+8YIApCTLtiyU3Qdez2DdaUE1s=; b=N2NaWDYL0mk/wfxA7FeLxZN3/NRiPcQLjRxOqng46Sfd+LonZdhwbZLDrFPDlxIb EnRrGo7qRp5SDTzMCexQRdkCKoHJ0Ra2u+7JMwa+M76ip/t2AzJkjwIvXvSjZRw8Sh2 CzugfCkL/6b2IpIZNrmWJvncPcLUSwVW9ErzGnvA= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=yj20110701; d=yahoo.co.jp; h=Message-ID:Date:MIME-Version:Cc:From:Content-Type:Content-Transfer-Encoding:References; b=bvLHXxiQkg8pNvQ4AiVBeFHL03q9bTFb1mgraTgbMloQfvBLocQekpCYkL7ABzcI FEAVl+4gzIjfUIGrhpL/zSmktUF7PB4cwm0DudQwjLVcIHQVzHeVHhRE3d6SuY5nmD4 ZH9Y06zjFFDEeDkUMWwRNk5lPE6aAwbXcSDTLMpI=; Received: by smtphe5006.mail.kks.ynwp.yahoo.co.jp (YJ Hermes SMTP Server) with ESMTPA ID a4f833217a8b1d6937e26585f0e18643; Sun, 14 Jul 2024 20:05:30 +0900 (JST) Message-ID: <37683bf9-4056-443b-9255-8a4168fa92c7@yahoo.co.jp> Date: Sun, 14 Jul 2024 20:02:14 +0900 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: gcc-patches@gcc.gnu.org Cc: Max Filippov From: Takayuki 'January June' Suwa Subject: [PATCH v2 1/3] xtensa: Resurrect LEAF_REGISTERS and LEAF_REG_REMAP References: <37683bf9-4056-443b-9255-8a4168fa92c7.ref@yahoo.co.jp> X-Spam-Status: No, score=-13.0 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, 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org They were once mistakenly removed with "xtensa: Remove old broken tweak for leaf function", but caused unwanted register spills. gcc/ChangeLog: * config/xtensa/xtensa.h (LEAF_REGISTERS, LEAF_REG_REMAP): Withdraw the removal. * config/xtensa/xtensa.cc (xtensa_leaf_regs): Ditto. --- gcc/config/xtensa/xtensa.cc | 11 +++++++++++ gcc/config/xtensa/xtensa.h | 12 ++++++++++++ 2 files changed, 23 insertions(+) diff --git a/gcc/config/xtensa/xtensa.cc b/gcc/config/xtensa/xtensa.cc index d49d224466a..099213f0994 100644 --- a/gcc/config/xtensa/xtensa.cc +++ b/gcc/config/xtensa/xtensa.cc @@ -113,6 +113,17 @@ struct GTY(()) machine_function hash_map *litpool_usage; }; +/* Vector, indexed by hard register number, which contains 1 for a + register that is allowable in a candidate for leaf function + treatment. */ +const char xtensa_leaf_regs[FIRST_PSEUDO_REGISTER] = +{ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1 +}; + static void xtensa_option_override (void); static enum internal_test map_test_to_internal_test (enum rtx_code); static rtx gen_int_relational (enum rtx_code, rtx, rtx); diff --git a/gcc/config/xtensa/xtensa.h b/gcc/config/xtensa/xtensa.h index 86802343152..3bff973fd88 100644 --- a/gcc/config/xtensa/xtensa.h +++ b/gcc/config/xtensa/xtensa.h @@ -253,6 +253,18 @@ along with GCC; see the file COPYING3. If not see } #define ADJUST_REG_ALLOC_ORDER xtensa_adjust_reg_alloc_order () +/* For Xtensa, the only point of this is to prevent GCC from otherwise + giving preference to call-used registers. To minimize window + overflows for the AR registers, we want to give preference to the + lower-numbered AR registers. For other register files, which are + not windowed, we still prefer call-used registers, if there are any. */ +extern const char xtensa_leaf_regs[FIRST_PSEUDO_REGISTER]; +#define LEAF_REGISTERS xtensa_leaf_regs + +/* For Xtensa, no remapping is necessary, but this macro must be + defined if LEAF_REGISTERS is defined. */ +#define LEAF_REG_REMAP(REGNO) ((int) (REGNO)) + /* Internal macros to classify a register number. */ /* 16 address registers + fake registers */