From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from xry111.site (xry111.site [89.208.246.23]) by sourceware.org (Postfix) with ESMTPS id BAE913858C41 for ; Tue, 14 Nov 2023 20:26:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BAE913858C41 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=xry111.site Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=xry111.site ARC-Filter: OpenARC Filter v1.0.0 sourceware.org BAE913858C41 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=89.208.246.23 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699993593; cv=none; b=h5CgjGqkoJ6OBMaILp5hFNQphPLlA238znaZecCvXkapGh5OOLlSk4B78ApKqIub5j8G6uKZz2ybAJIFIvYuqNv1ZaxuHwuEC+NA8REoRA8++vxtDKbKL+z5bFsYgxk+M48X9k/xfehRrNkXNom4krx6s3M0vaIs5LE6kGu8s5o= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699993593; c=relaxed/simple; bh=rbS007blJKCX67xwvioZFEk1RTgD7E/hhmDCOPkC+Qw=; h=DKIM-Signature:Message-ID:Subject:From:To:Date:MIME-Version; b=FZFCFJkcf0Glj/NXKP5MpBq2sOUe7avs0rHrxdjoeRt5nRsJMoAfCvWZbOYS9blF7Q3p3cmbByntWFQ7w0gZcwF4MsowjTH/fqB4XW4dt5IqPblzJBTKYYIpXpq9cedARAYEgJV0uJXyjx+iGpnGeoiT2syIxcfzInOwlEJIt6w= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xry111.site; s=default; t=1699993586; bh=rbS007blJKCX67xwvioZFEk1RTgD7E/hhmDCOPkC+Qw=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=WJxxYoGm50yfoeu2fpj036wpT41oNYpxkZCIZ13VKo34iuzczCVmswyisWLvEAuhE 3bQjie7L+NDZ4hJotuKrDDnYx59oxemcMKsKKycIUKiAe2nHb3qsAQSW23N7T8XAQ+ 0O2gEZhPyM8UpIHDc0eEXbUx6F0pw/85bshXb8oc= Received: from [IPv6:240e:358:11dd:4400:dc73:854d:832e:2] (unknown [IPv6:240e:358:11dd:4400:dc73:854d:832e:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) (Authenticated sender: xry111@xry111.site) by xry111.site (Postfix) with ESMTPSA id ADF7E66A03; Tue, 14 Nov 2023 15:26:24 -0500 (EST) Message-ID: <086495273b4f2a721c3b6e15859781cdc8134966.camel@xry111.site> Subject: Re: [PATCH v1] LoongArch: Added code generation support for call36 function calls. From: Xi Ruoyao To: chenglulu , gcc-patches@gcc.gnu.org Cc: i@xen0n.name, xuchenghua@loongson.cn Date: Wed, 15 Nov 2023 04:26:19 +0800 In-Reply-To: <4969dd47-01d9-0b79-e7ac-6683ed166eac@loongson.cn> References: <20231114094500.8160-1-chenglulu@loongson.cn> <4030bb00a356a8e8bb801f92951d444117d4dba0.camel@xry111.site> <4969dd47-01d9-0b79-e7ac-6683ed166eac@loongson.cn> Autocrypt: addr=xry111@xry111.site; prefer-encrypt=mutual; keydata=mDMEYnkdPhYJKwYBBAHaRw8BAQdAsY+HvJs3EVKpwIu2gN89cQT/pnrbQtlvd6Yfq7egugi0HlhpIFJ1b3lhbyA8eHJ5MTExQHhyeTExMS5zaXRlPoiTBBMWCgA7FiEEkdD1djAfkk197dzorKrSDhnnEOMFAmJ5HT4CGwMFCwkIBwICIgIGFQoJCAsCBBYCAwECHgcCF4AACgkQrKrSDhnnEOPHFgD8D9vUToTd1MF5bng9uPJq5y3DfpcxDp+LD3joA3U2TmwA/jZtN9xLH7CGDHeClKZK/ZYELotWfJsqRcthOIGjsdAPuDgEYnkdPhIKKwYBBAGXVQEFAQEHQG+HnNiPZseiBkzYBHwq/nN638o0NPwgYwH70wlKMZhRAwEIB4h4BBgWCgAgFiEEkdD1djAfkk197dzorKrSDhnnEOMFAmJ5HT4CGwwACgkQrKrSDhnnEOPjXgD/euD64cxwqDIqckUaisT3VCst11RcnO5iRHm6meNIwj0BALLmWplyi7beKrOlqKfuZtCLbiAPywGfCNg8LOTt4iMD Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.50.1 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,LIKELY_SPAM_FROM,SPF_HELO_PASS,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 List-Id: On Tue, 2023-11-14 at 20:46 +0800, chenglulu wrote: >=20 > =E5=9C=A8 2023/11/14 =E4=B8=8B=E5=8D=885:55, Xi Ruoyao =E5=86=99=E9=81=93= : > > On Tue, 2023-11-14 at 17:45 +0800, Lulu Cheng wrote: > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* When function calls are made throu= gh call36, t0 register > > > will be > > > + implicitly modified, so '-fno-ipa-ra' needs to be set > > > here.=C2=A0 */ > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 case CMODEL_MEDIUM: > > > + if (HAVE_AS_SUPPORT_CALL36) > > > + =C2=A0 opts->x_flag_ipa_ra =3D 0; > > > + break; > > Maybe we can add a (clobber (reg:P 12)) to the related insns > > instead? > >=20 > Sorry, this was modified in accordance with the call36 macro > instruction=20 > during the test. > I will use clobber, and add test cases. There seems a better solution as suggested by the GCC internal doc.=20 Section 18.9.16 mentions -fipa-ra: -- Target Hook: bool TARGET_CALL_FUSAGE_CONTAINS_NON_CALLEE_CLOBBERS Set to true if each call that binds to a local definition explicitly clobbers or sets all non-fixed registers modified by performing the call. That is, by the call pattern itself, or by code that might be inserted by the linker (e.g. stubs, veneers, branch islands), but not including those modifiable by the callee. The affected registers may be mentioned explicitly in the call pattern, or included as clobbers in CALL_INSN_FUNCTION_USAGE. The default version of this hook is set to false. The purpose of this hook is to enable the fipa-ra optimization. So we can add t0 into CALL_INSN_FUNCTION_USAGE of the call insn, like: diff --git a/gcc/config/loongarch/loongarch.md b/gcc/config/loongarch/loong= arch.md index ea36542b1c3..96e7e98e6b3 100644 --- a/gcc/config/loongarch/loongarch.md +++ b/gcc/config/loongarch/loongarch.md @@ -3274,7 +3274,14 @@ (define_expand "sibcall" XEXP (target, 1), operands[1])); else - emit_call_insn (gen_sibcall_internal (target, operands[1])); + { + rtx call =3D gen_sibcall_internal (target, operands[1]); + + if (TARGET_CMODEL_MEDIUM && !REG_P (target)) + clobber_reg (&CALL_INSN_FUNCTION_USAGE (call), + gen_rtx_REG (Pmode, T0_REGNUM)); + emit_call_insn (call); + } DONE; }) Likewise for sibcall_value. By the way we'd better have a command line switch to override the build- time check for assembler call36 support, because it makes writing test cases and inter-operating with different versions of assembler easier. --=20 Xi Ruoyao School of Aerospace Science and Technology, Xidian University