From patchwork Fri Oct 14 11:06:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Takayuki 'January June' Suwa X-Patchwork-Id: 2653 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp125566wrs; Fri, 14 Oct 2022 04:20:09 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5dpQF5TtfkTFn4ZVzpVRPMyIUKAs8jGHKM797TYCwAtWdKX1Tg0aqrXtOp0AThSAaVS2Vl X-Received: by 2002:a17:907:d8e:b0:783:a4f0:1052 with SMTP id go14-20020a1709070d8e00b00783a4f01052mr3150247ejc.41.1665746398399; Fri, 14 Oct 2022 04:19:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665746398; cv=none; d=google.com; s=arc-20160816; b=ZJabImYu8jU+PiyLqjyRsr5O3iKdOJrytaIu0zemhG2Kh5JDWSBKMRWTiO656UpEqy sMfaN8hyF7/C6TaFFkqliIaEpfPv0Mzc78opNjhahNZX3UCAW8Hebw/uPzbMQWV49Khi ffIjUISvUl6+VEBK0mdfjr7yl89azsHXKDKB/orvDFY/4ZW2wDwfLJWnx0Uyk42+gbXT giNsxfLdHmTZ7+vEZw2PZRQI1eASq774oIeDdOhz5Pt/rgE2m8KEI0imoXMnHl7a0fZ/ M8X3uOgusAnr6NX+FXPLUKVhQoMiWnIamtZh/BZXlNPtdW3y6RcjDtyzuQidni4rl9NL m3Iw== 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=G2wSr/8dDZP1xizCzup/jFcRK3wXfxv52lgg+DvtzKw=; b=EbmKfS1ub+gNy3tU8b6IotxDp57GbwwJ5ShHA6eXeLlB8ehvHl8RngImWCzXmarjaB YwHUzsw9CaOyD7LJzWYSlxf/w6hhgFoX28BJT5L9MNDBFvKuYo/+6dP2Fj8UBsMoPp4C wIIZ+6Hl9M02N108vTS1JiCT5UxQidRjMVi8D2mxz9Gv4FOdzKKMkUy8b2EjyHCUiw+3 BDR0IO2x+76xZFwSJ9i0LFS4Jv5W9ubcPoulwuz7PN5jWxyUXefSGjZpxUYXMbK3zjV7 3i+C7LmZmZSoIh1FATR9ncqzxAnIQYToJ6hlcsTNxSiN3KiB//xjbb/ChW5Ksnvf6xhv WlQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="vb/cNe3b"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id h18-20020a056402281200b0044e9f8ecd96si2055387ede.609.2022.10.14.04.19.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 04:19:58 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="vb/cNe3b"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 4B4833857038 for ; Fri, 14 Oct 2022 11:19:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4B4833857038 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665746397; bh=G2wSr/8dDZP1xizCzup/jFcRK3wXfxv52lgg+DvtzKw=; 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=vb/cNe3b+bVGc+nrvo1t2/xcMRkIM+6ooBR38OFCHrDkv9q5duSWNDwT4jkY36iSt Revoj12Sbn0VmknrtYRIQqYamcS3x402MyTbGeYurtL65KnFYhnS2S6MqbImHQ2DJE NtXakBWEPkahsJoC7VuDNfOCuE5OBwfUEwnvfjek= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from sonicconh6003-vm4.mail.ssk.yahoo.co.jp (sonicconh6003-vm4.mail.ssk.yahoo.co.jp [182.22.37.45]) by sourceware.org (Postfix) with ESMTPS id A06E53858429 for ; Fri, 14 Oct 2022 11:19:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A06E53858429 X-YMail-OSG: q3V0EQEVM1llc4M8NiGpUztiODqY4MbHtpDtzF2U7Ay9tAsEQeHgt4ZrLzbrN4V hiKOV9wMJTyACnBeDakXZeR.ai13gTgZ6k0w7ym4R.APye284ZWlzvEV4GZpeJ1S5iCa9hy3D8x1 l_Yj3oiks9EC8Sb.jdmq495O7NREpAtbk2CilEEY8dP6fJGsAKNIR4aWADJNRNFeOK9hmxXOVfaV aW25pQ.Fn4bu8.3OqCEcU3BG4wkFCdKdaw7E9DffISSalEBXMyiz2xk7ZkjFv06ZKsZVB1o4NyrQ 1yBuaPvHK1wVEe1iIudmYr5fHXBOIoCeEres58ZX4dncwV3amuYxYkwi.xY7.jVOvUAu6CUnbH.l mCMlcAeprgzZYP824qULk5V4QfkrzUD5F5bhRh0srQMxW9rhZA.as.QDYAH_u48dHiU_FqPtamIP ESfpA5vKsL44Z.Xpp1lCs_n0JTScG4ZSYmWaeZStuDOnYkAX7qKMd26BQ7WeCu4TzpaipxK0rv9V RK8lkLOYRIQKuKBlc27_4knXa52akZhlvFgEyQDLznKbGWldC_97QvHlqRbhNWdx4GsYQ4b0WPC8 fgZTdbMJuKQeIAaUUPClhf2fi7oTHQiLQt9KXBssVnpJJF86jVE_6hQaKzsth4kZ2WZ7uVgjJkX2 O0VdmLnYfXVf3QsxsRKKiLdXFi.hBFt9ERo1__NzxEep64XtqC45rU0kafjee4WX9R3fjjHC8F0o WURSOVhAWK4TW20tS8H4lKbZ1KUAgm4BxFEYyplOLWSMs0frsMbhMDhpvIPDAqdZ1as0bsyBz1Md jeyyDzVhlpTfmuDOTyzz_xje6QqguJpih97q1Qx0YYfWS0VXQ7z27jc5D.VoJes_lmiA.NbLF8DP fSmdxYJRIwzHODNoitv0DPiAal5Vhqk1Qau49hDBUcjYtiXwUKtXSin.w8NJpCdtHKaWwMGmRHd3 vO7ynEho- Received: from sonicgw.mail.yahoo.co.jp by sonicconh6003.mail.ssk.yahoo.co.jp with HTTP; Fri, 14 Oct 2022 11:19:05 +0000 Received: by smtphe5005.mail.kks.ynwp.yahoo.co.jp (YJ Hermes SMTP Server) with ESMTPA ID 96405fc0c7c552530bb448adb7260445; Fri, 14 Oct 2022 20:19:01 +0900 (JST) Message-ID: <3296b387-083a-40cf-1bb5-40269e804f52@yahoo.co.jp> Date: Fri, 14 Oct 2022 20:06:08 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.3.3 Subject: [PATCH] xtensa: Prepare the transition from Reload to LRA To: GCC Patches References: <7e3fe210-6dbc-fc29-dbb8-b951e89cf7e9@yahoo.co.jp> <87f124f0-8a10-6c3b-6b12-cabf855e2e4b@yahoo.co.jp> In-Reply-To: X-Spam-Status: No, score=-9.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_INVALID, DKIM_SIGNED, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_0, KAM_DMARC_STATUS, NML_ADSP_CUSTOM_MED, 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?1746661695533076011?= X-GMAIL-MSGID: =?utf-8?q?1746661695533076011?= On 2022/08/06 1:20, Jeff Law via Gcc-patches wrote: >>> Ah, hadn't realised that.  If you have time to work on it, it would be >>> really good to move over to LRA.  There are plans to remove old reload. >> Alas you do overestimate me :) I've only been working about the GCC development for a little over a year. >> Well it's a lie that I'm not interested in it, but too much for me. > It may actually be trivial -- change TARGET_LRA_P to be hook_bool_void_true in the xtensa port, then rebuild & test. In the couple conversions I've done it's exposed a very small number of issues that were trivially resolved.  Given the what I've seen from you I would expect it's within your capabilities and there's folks here that can help if you do run into problems. I was flattered, so I decided to go along with the offer :) === This patch provides the first step in the transition from Reload to LRA in Xtensa. gcc/ChangeLog: * config/xtensa/xtensa-proto.h (xtensa_split1_is_finished_p): New prototype. * config/xtensa/xtensa.cc (xtensa_split1_is_finished_p, xtensa_lra_p): New functions. (TARGET_LRA_P): Replace the dummy hook with xtensa_lra_p. (xt_true_regnum): Rework. * gcc/config/xtensa/xtensa.h (CALL_REALLY_USED_REGISTERS): Rename from CALL_USED_REGISTERS, and remove what correspond to FIXED_REGISTERS. * gcc/config/xtensa/constraints.md (Y): Use !xtensa_split1_is_finished_p() instead of can_create_pseudo_p(). * gcc/config/xtensa/predicates.md (move_operand): Ditto. * gcc/config/xtensa/xtensa.md: Add new split pattern that puts out-of-constraint integer constants into the constant pool. * gcc/config/xtensa/xtensa.opt (-mlra): New target-specific option for testing purpose. --- gcc/config/xtensa/constraints.md | 2 +- gcc/config/xtensa/predicates.md | 2 +- gcc/config/xtensa/xtensa-protos.h | 1 + gcc/config/xtensa/xtensa.cc | 48 ++++++++++++++++++++++++------- gcc/config/xtensa/xtensa.h | 6 ++-- gcc/config/xtensa/xtensa.md | 12 ++++++++ gcc/config/xtensa/xtensa.opt | 4 +++ 7 files changed, 60 insertions(+), 15 deletions(-) diff --git a/gcc/config/xtensa/constraints.md b/gcc/config/xtensa/constraints.md index e4c314b267c..111e5f29fd2 100644 --- a/gcc/config/xtensa/constraints.md +++ b/gcc/config/xtensa/constraints.md @@ -121,7 +121,7 @@ (ior (and (match_code "const_int,const_double,const,symbol_ref,label_ref") (match_test "TARGET_AUTO_LITPOOLS")) (and (match_code "const_int") - (match_test "can_create_pseudo_p ()")))) + (match_test "! xtensa_split1_is_finished_p ()")))) ;; Memory constraints. Do not use define_memory_constraint here. Doing so ;; causes reload to force some constants into the constant pool, but since diff --git a/gcc/config/xtensa/predicates.md b/gcc/config/xtensa/predicates.md index 0590c0f81a9..fc9de01fd71 100644 --- a/gcc/config/xtensa/predicates.md +++ b/gcc/config/xtensa/predicates.md @@ -149,7 +149,7 @@ (ior (and (match_code "const_int") (match_test "(GET_MODE_CLASS (mode) == MODE_INT && xtensa_simm12b (INTVAL (op))) - || can_create_pseudo_p ()")) + || ! xtensa_split1_is_finished_p ()")) (and (match_code "const_int,const_double,const,symbol_ref,label_ref") (match_test "(TARGET_CONST16 || TARGET_AUTO_LITPOOLS) && CONSTANT_P (op) diff --git a/gcc/config/xtensa/xtensa-protos.h b/gcc/config/xtensa/xtensa-protos.h index 459e2aac9fc..55779f9d199 100644 --- a/gcc/config/xtensa/xtensa-protos.h +++ b/gcc/config/xtensa/xtensa-protos.h @@ -58,6 +58,7 @@ extern char *xtensa_emit_call (int, rtx *); extern char *xtensa_emit_sibcall (int, rtx *); extern bool xtensa_tls_referenced_p (rtx); extern enum rtx_code xtensa_shlrd_which_direction (rtx, rtx); +extern bool xtensa_split1_is_finished_p (void); #ifdef TREE_CODE extern void init_cumulative_args (CUMULATIVE_ARGS *, int); diff --git a/gcc/config/xtensa/xtensa.cc b/gcc/config/xtensa/xtensa.cc index 828c7642b7c..ce2aab673df 100644 --- a/gcc/config/xtensa/xtensa.cc +++ b/gcc/config/xtensa/xtensa.cc @@ -56,6 +56,7 @@ along with GCC; see the file COPYING3. If not see #include "hw-doloop.h" #include "rtl-iter.h" #include "insn-attr.h" +#include "tree-pass.h" /* This file should be included last. */ #include "target-def.h" @@ -199,6 +200,7 @@ static void xtensa_output_mi_thunk (FILE *file, tree thunk ATTRIBUTE_UNUSED, HOST_WIDE_INT delta, HOST_WIDE_INT vcall_offset, tree function); +static bool xtensa_lra_p (void); static rtx xtensa_delegitimize_address (rtx); @@ -295,7 +297,7 @@ static rtx xtensa_delegitimize_address (rtx); #define TARGET_CANNOT_FORCE_CONST_MEM xtensa_cannot_force_const_mem #undef TARGET_LRA_P -#define TARGET_LRA_P hook_bool_void_false +#define TARGET_LRA_P xtensa_lra_p #undef TARGET_LEGITIMATE_ADDRESS_P #define TARGET_LEGITIMATE_ADDRESS_P xtensa_legitimate_address_p @@ -492,21 +494,30 @@ xtensa_mask_immediate (HOST_WIDE_INT v) int xt_true_regnum (rtx x) { - if (GET_CODE (x) == REG) + if (REG_P (x)) { - if (reg_renumber - && REGNO (x) >= FIRST_PSEUDO_REGISTER - && reg_renumber[REGNO (x)] >= 0) + if (HARD_REGISTER_P (x) + && reg_renumber + && (lra_in_progress || reg_renumber[REGNO (x)] >= 0)) return reg_renumber[REGNO (x)]; return REGNO (x); } - if (GET_CODE (x) == SUBREG) + if (SUBREG_P (x)) { int base = xt_true_regnum (SUBREG_REG (x)); - if (base >= 0 && base < FIRST_PSEUDO_REGISTER) - return base + subreg_regno_offset (REGNO (SUBREG_REG (x)), - GET_MODE (SUBREG_REG (x)), - SUBREG_BYTE (x), GET_MODE (x)); + + if (base >= 0 + && HARD_REGISTER_NUM_P (base)) + { + struct subreg_info info; + + subreg_get_info (lra_in_progress + ? (unsigned) base : REGNO (SUBREG_REG (x)), + GET_MODE (SUBREG_REG (x)), + SUBREG_BYTE (x), GET_MODE (x), &info); + if (info.representable_p) + return base + info.offset; + } } return -1; } @@ -2477,6 +2488,15 @@ xtensa_shlrd_which_direction (rtx op0, rtx op1) } +/* Return true after "split1" pass is finished. */ + +bool +xtensa_split1_is_finished_p (void) +{ + return cfun && (cfun->curr_properties & PROP_rtl_split_insns); +} + + /* Implement TARGET_CANNOT_FORCE_CONST_MEM. */ static bool @@ -5119,4 +5139,12 @@ xtensa_delegitimize_address (rtx op) return op; } +/* Implement TARGET_LRA_P. */ + +static bool +xtensa_lra_p (void) +{ + return TARGET_LRA; +} + #include "gt-xtensa.h" diff --git a/gcc/config/xtensa/xtensa.h b/gcc/config/xtensa/xtensa.h index 16e3d55e896..6b60e596062 100644 --- a/gcc/config/xtensa/xtensa.h +++ b/gcc/config/xtensa/xtensa.h @@ -242,10 +242,10 @@ along with GCC; see the file COPYING3. If not see Proper values are computed in TARGET_CONDITIONAL_REGISTER_USAGE. */ -#define CALL_USED_REGISTERS \ +#define CALL_REALLY_USED_REGISTERS \ { \ - 1, 1, 4, 4, 4, 4, 4, 4, 1, 1, 1, 1, 2, 2, 2, 2, \ - 1, 1, 1, \ + 0, 0, 4, 4, 4, 4, 4, 4, 1, 1, 1, 1, 2, 2, 2, 2, \ + 0, 0, 1, \ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \ 1, \ } diff --git a/gcc/config/xtensa/xtensa.md b/gcc/config/xtensa/xtensa.md index 608110c20bc..3b37f01e117 100644 --- a/gcc/config/xtensa/xtensa.md +++ b/gcc/config/xtensa/xtensa.md @@ -1017,6 +1017,18 @@ (set_attr "mode" "SI") (set_attr "length" "2,2,2,2,2,2,3,3,3,3,6,3,3,3,3,3")]) +(define_split + [(set (match_operand:SI 0 "register_operand") + (match_operand:SI 1 "const_int_operand"))] + "!TARGET_CONST16 && !TARGET_AUTO_LITPOOLS + && ! xtensa_split1_is_finished_p () + && ! xtensa_simm12b (INTVAL (operands[1]))" + [(set (match_dup 0) + (match_dup 1))] +{ + operands[1] = force_const_mem (SImode, operands[1]); +}) + (define_split [(set (match_operand:SI 0 "register_operand") (match_operand:SI 1 "constantpool_operand"))] diff --git a/gcc/config/xtensa/xtensa.opt b/gcc/config/xtensa/xtensa.opt index 08338e39060..00d2db4eae1 100644 --- a/gcc/config/xtensa/xtensa.opt +++ b/gcc/config/xtensa/xtensa.opt @@ -34,6 +34,10 @@ mextra-l32r-costs= Target RejectNegative Joined UInteger Var(xtensa_extra_l32r_costs) Init(0) Set extra memory access cost for L32R instruction, in clock-cycle units. +mlra +Target Mask(LRA) +Use LRA instead of reload (transitional). + mtarget-align Target Automatically align branch targets to reduce branch penalties.