From patchwork Thu Aug 18 10:03:51 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: 597 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6a10:38f:b0:2d5:3c95:9e21 with SMTP id 15csp173558pxh; Thu, 18 Aug 2022 03:07:28 -0700 (PDT) X-Google-Smtp-Source: AA6agR4bIkIwcAhwjGbNCXLAyfyQv26W/oo1YJKJpUPV0dfB8sevDYr7NePHUaCX4w+/t/49BRDm X-Received: by 2002:a17:907:3e01:b0:730:a690:a211 with SMTP id hp1-20020a1709073e0100b00730a690a211mr1411546ejc.596.1660817248290; Thu, 18 Aug 2022 03:07:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660817248; cv=none; d=google.com; s=arc-20160816; b=tgFIBxzCRYOMhJZo68so4wej3xb0IaGGrLnMhdaTUCEVbceoG81Ta84dtQvJw0hRRT UEU7uaH3KdNyqdBdbCA881poV6CEzozZ56jdId0+0aT8wV19H05YZwWyNsKDiUkAHSkP oGNsaOLUI1+MhdHYbCzkid3QtXaC5Kdpm9l0r26GQtLMY+QIPSPjGPYlzbZPYr+2t3v6 vAMk5vkCjSFkfuCqb0DRIdiULIaET3nvuWdjCs2Y2QS9ICGi4Ifw34sYmlRaCMY67zv1 p4tBKmj5B/pzsCqSe5imka2kTFBoNh/IkMhffyI+TkyWfOOxumvLgQuLRMutyStxnRMP h5HQ== 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:subject:to:user-agent:mime-version:date :message-id:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=/vTASgBxYvnceeo8xbFfVWm5w3GmOkpqD3ruSDiaohQ=; b=BAuppZgs4KmFjUANcg2hA4OCIvwyFx3Ff3seFL6mdPK4nCvpypOPghmkLA1LXYM5Ez l3ug0Xa0jb+AxTk4D0xvzho2wiXlCVUEv6raAyx02qrkPc8HDzw/S+g4AeSE6gxgPYSl 23vxHFcWwSJDE/u5xDdytESi6v5/U9i0ZR4yWtgoGBRuGr5yWhBLZ+Ykk17Wxw8aoRMV y+2Lyz3j43IhO3/8FxLiE4bagnkAcCES0pGX4xYgTS/8JnEUweFY/FRg1IoM+rO6Dgs1 cziNNCgDFSZA9osnDszetpACvmNAs+DXQfmQJJCItBT3340DmW+lw5ZQhkBqNbrZc/48 rISg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=rRw5RWHX; 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 r21-20020aa7d595000000b00445cdb58a8fsi862049edq.202.2022.08.18.03.07.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Aug 2022 03:07:28 -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=rRw5RWHX; 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 34DBB3858436 for ; Thu, 18 Aug 2022 10:07:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 34DBB3858436 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1660817247; bh=/vTASgBxYvnceeo8xbFfVWm5w3GmOkpqD3ruSDiaohQ=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=rRw5RWHXDKor6mI6rmxfJi7liEwp+FbROUwq4qtJlZ0Rotx8NpbRs0EET6N8sbgYL a+0s7ALTOHbQYFdoFaGGevijlN7opqUP9etxwvRk0LPwSLdAxmTwxHep3UrnjEskbQ Cz1bYr0h4SqlB+2t4bfBAar0LR3LsoGiWQTD+O9o= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from nh505-vm1.bullet.mail.kks.yahoo.co.jp (nh505-vm1.bullet.mail.kks.yahoo.co.jp [183.79.57.103]) by sourceware.org (Postfix) with SMTP id 914A23858C83 for ; Thu, 18 Aug 2022 10:06:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 914A23858C83 Received: from [183.79.100.138] by nh505.bullet.mail.kks.yahoo.co.jp with NNFMP; 18 Aug 2022 10:06:38 -0000 Received: from [183.79.100.133] by t501.bullet.mail.kks.yahoo.co.jp with NNFMP; 18 Aug 2022 10:06:38 -0000 Received: from [127.0.0.1] by omp502.mail.kks.yahoo.co.jp with NNFMP; 18 Aug 2022 10:06:38 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 127641.4010.bm@omp502.mail.kks.yahoo.co.jp Received: (qmail 51364 invoked by alias); 18 Aug 2022 10:06:37 -0000 Received: from unknown (HELO ?192.168.2.3?) (175.177.45.170 with ) by smtp6005.mail.ssk.ynwp.yahoo.co.jp with SMTP; 18 Aug 2022 10:06:37 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wPdm9iGH4lPXH7vYqKImRuhhtr_Ops6bCWfEIz54iLB mH7vnfOHp50ZVAIK2Sg-- Message-ID: <20e955d6-d517-c20a-605a-34082189e9ca@yahoo.co.jp> Date: Thu, 18 Aug 2022 19:03:51 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.1.2 To: GCC Patches Subject: [PATCH] xtensa: Improve indirect sibling call handling X-Spam-Status: No, score=-12.7 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, KAM_SHORT, RCVD_IN_DNSWL_NONE, 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.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?1741493107021935815?= X-GMAIL-MSGID: =?utf-8?q?1741493107021935815?= No longer needs the dedicated hard register (A11) for the address of the call and the split patterns for fixups, due to the introduction of appropriate register class and constraint. (Note: "ISC_REGS" contains a hard register A8 used as a "static chain" pointer for nested functions, but no problem; Pointer to nested function actually points to "trampoline", and trampoline itself doesn't receive "static chain" pointer to its parent's stack frame from the caller.) gcc/ChangeLog: * config/xtensa/xtensa.h (enum reg_class, REG_CLASS_NAMES, REG_CLASS_CONTENTS): Add new register class "ISC_REGS". * config/xtensa/constraints.md (c): Add new register constraint. * config/xtensa/xtensa.md (define_constants): Remove "A11_REG". (sibcall_internal, sibcall_value_internal): Change to use the new register constraint, and remove two split patterns for fixups that are no longer needed. gcc/testsuite/ChangeLog: * gcc.target/xtensa/sibcalls.c: Add a new test function to ensure that registers for arguments (occupy from A2 to A7) and for indirect sibcall (should be assigned to A8) neither conflict nor spill out. --- gcc/config/xtensa/constraints.md | 5 ++++ gcc/config/xtensa/xtensa.h | 3 +++ gcc/config/xtensa/xtensa.md | 29 ++-------------------- gcc/testsuite/gcc.target/xtensa/sibcalls.c | 5 ++++ 4 files changed, 15 insertions(+), 27 deletions(-) diff --git a/gcc/config/xtensa/constraints.md b/gcc/config/xtensa/constraints.md index 0b7dcd1440e..e4c314b267c 100644 --- a/gcc/config/xtensa/constraints.md +++ b/gcc/config/xtensa/constraints.md @@ -27,6 +27,11 @@ "Boolean registers @code{b0}-@code{b15}; only available if the Xtensa Boolean Option is configured.") +(define_register_constraint "c" "TARGET_WINDOWED_ABI ? NO_REGS : ISC_REGS" + "@internal + General-purpose AR registers for indirect sibling calls, @code{a2}- + @code{a8}.") + (define_register_constraint "d" "TARGET_DENSITY ? AR_REGS: NO_REGS" "@internal All AR registers, including sp, but only if the Xtensa Code Density diff --git a/gcc/config/xtensa/xtensa.h b/gcc/config/xtensa/xtensa.h index d027a777227..d51658afa89 100644 --- a/gcc/config/xtensa/xtensa.h +++ b/gcc/config/xtensa/xtensa.h @@ -378,6 +378,7 @@ enum reg_class FP_REGS, /* floating point registers */ ACC_REG, /* MAC16 accumulator */ SP_REG, /* sp register (aka a1) */ + ISC_REGS, /* registers for indirect sibling calls */ RL_REGS, /* preferred reload regs (not sp or fp) */ GR_REGS, /* integer registers except sp */ AR_REGS, /* all integer registers */ @@ -399,6 +400,7 @@ enum reg_class "FP_REGS", \ "ACC_REG", \ "SP_REG", \ + "ISC_REGS", \ "RL_REGS", \ "GR_REGS", \ "AR_REGS", \ @@ -415,6 +417,7 @@ enum reg_class { 0xfff80000, 0x00000007 }, /* floating-point registers */ \ { 0x00000000, 0x00000008 }, /* MAC16 accumulator */ \ { 0x00000002, 0x00000000 }, /* stack pointer register */ \ + { 0x000001fc, 0x00000000 }, /* registers for indirect sibling calls */ \ { 0x0000fffd, 0x00000000 }, /* preferred reload registers */ \ { 0x0000fffd, 0x00000000 }, /* general-purpose registers */ \ { 0x0003ffff, 0x00000000 }, /* integer registers */ \ diff --git a/gcc/config/xtensa/xtensa.md b/gcc/config/xtensa/xtensa.md index 1294aab6c5d..3ed269249a4 100644 --- a/gcc/config/xtensa/xtensa.md +++ b/gcc/config/xtensa/xtensa.md @@ -25,7 +25,6 @@ (A7_REG 7) (A8_REG 8) (A9_REG 9) - (A11_REG 11) (UNSPEC_NOP 2) (UNSPEC_PLT 3) @@ -2279,7 +2278,7 @@ }) (define_insn "sibcall_internal" - [(call (mem:SI (match_operand:SI 0 "call_insn_operand" "nir")) + [(call (mem:SI (match_operand:SI 0 "call_insn_operand" "nic")) (match_operand 1 "" "i"))] "!TARGET_WINDOWED_ABI && SIBLING_CALL_P (insn)" { @@ -2289,17 +2288,6 @@ (set_attr "mode" "none") (set_attr "length" "3")]) -(define_split - [(call (mem:SI (match_operand:SI 0 "register_operand")) - (match_operand 1 ""))] - "reload_completed - && !TARGET_WINDOWED_ABI && SIBLING_CALL_P (insn) - && ! call_used_or_fixed_reg_p (REGNO (operands[0]))" - [(set (reg:SI A11_REG) - (match_dup 0)) - (call (mem:SI (reg:SI A11_REG)) - (match_dup 1))]) - (define_expand "sibcall_value" [(set (match_operand 0 "register_operand" "") (call (match_operand 1 "memory_operand" "") @@ -2311,7 +2299,7 @@ (define_insn "sibcall_value_internal" [(set (match_operand 0 "register_operand" "=a") - (call (mem:SI (match_operand:SI 1 "call_insn_operand" "nir")) + (call (mem:SI (match_operand:SI 1 "call_insn_operand" "nic")) (match_operand 2 "" "i")))] "!TARGET_WINDOWED_ABI && SIBLING_CALL_P (insn)" { @@ -2321,19 +2309,6 @@ (set_attr "mode" "none") (set_attr "length" "3")]) -(define_split - [(set (match_operand 0 "register_operand") - (call (mem:SI (match_operand:SI 1 "register_operand")) - (match_operand 2 "")))] - "reload_completed - && !TARGET_WINDOWED_ABI && SIBLING_CALL_P (insn) - && ! call_used_or_fixed_reg_p (REGNO (operands[1]))" - [(set (reg:SI A11_REG) - (match_dup 1)) - (set (match_dup 0) - (call (mem:SI (reg:SI A11_REG)) - (match_dup 2)))]) - (define_insn "entry" [(set (reg:SI A1_REG) (unspec_volatile:SI [(match_operand:SI 0 "const_int_operand" "i")] diff --git a/gcc/testsuite/gcc.target/xtensa/sibcalls.c b/gcc/testsuite/gcc.target/xtensa/sibcalls.c index d2b3fccf1e5..dff6750e209 100644 --- a/gcc/testsuite/gcc.target/xtensa/sibcalls.c +++ b/gcc/testsuite/gcc.target/xtensa/sibcalls.c @@ -17,4 +17,9 @@ int test_2(int (*a)(void)) { return a(); } +_Complex double test_3(_Complex double a, _Complex double (*b)(_Complex double, double)) { + bar(-1); + return b(a, 3.141592653589795); +} + /* { dg-final { scan-assembler-not "ret" } } */