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 D03E838582B2 for ; Fri, 5 Jan 2024 10:26:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D03E838582B2 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 D03E838582B2 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=1704450362; cv=none; b=XB/MX7cJYtssSNqgdZ2kVVz9ZSBid/6LgSoBtT/T6vc1Un1kjzxFuvYVNG8Ir1nf1VI6jpQN4RR+uM1avMc+mtnAg4N+zlAcI7obHNjYOjtsZSzinRV6y/0JqBvWdjDiCaadBelsb0+c15mi7Bug3A2NusTDIiV06ZkkxGW6FzM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704450362; c=relaxed/simple; bh=4VF7c97JFYWGseI6CgNJ6RbgfkKoKSfJxj6sR/1swDE=; h=DKIM-Signature:Message-ID:Subject:From:To:Date:MIME-Version; b=EyiWCNdg07uHYufrj0K/mZPzkP8TuDNtZp1uPauLbg57iYqeSBvWj6gpKCSJFTPRa89X0pUeyN9rRV3b+C6eptEnpqmS4iQJ+CZr8ICk3o6WoRxpCpvfF1h9hEcVehoI+4ltoPaNff55pASJlVuya5nbrlcTksB0ETP5RcFhdiw= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xry111.site; s=default; t=1704450357; bh=4VF7c97JFYWGseI6CgNJ6RbgfkKoKSfJxj6sR/1swDE=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=QwObcyybwDNh/TXL7TgLXxx8EBVLFRmeP5MZs9sWI1KmW7wx++ULGbYnZGlpDdhAJ rcFl37y8mesSTJaZ/NRcJKJIpE1M8bdSgiC/6xvMAKHT/TvQBqGOvH1eMED//xTeHX i0nTPFxOF0PTftEYGC4DJnEUvP+l4TH0Vrj0MMuk= Received: from [IPv6:240e:358:110e:ca00:dc73:854d:832e:2] (unknown [IPv6:240e:358:110e:ca00: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 3F36466DE5; Fri, 5 Jan 2024 05:25:53 -0500 (EST) Message-ID: <4cdfda6960e75ccc6ccea6263ac02e79c9dba572.camel@xry111.site> Subject: Re: [PATCH v2 2/2] LoongArch: When the code model is extreme, the symbol address is obtained through macro instructions regardless of the value of -mexplicit-relocs. From: Xi Ruoyao To: chenglulu , gcc-patches@gcc.gnu.org Cc: i@xen0n.name, xuchenghua@loongson.cn Date: Fri, 05 Jan 2024 18:25:48 +0800 In-Reply-To: <0fe0f370-a593-d060-d260-0e190986f833@loongson.cn> References: <20240105034021.30177-1-chenglulu@loongson.cn> <20240105034021.30177-3-chenglulu@loongson.cn> <0fe0f370-a593-d060-d260-0e190986f833@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.2 MIME-Version: 1.0 X-Spam-Status: No, score=-0.0 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,LIKELY_SPAM_FROM,SPF_HELO_PASS,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no 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 Fri, 2024-01-05 at 17:57 +0800, chenglulu wrote: >=20 > =E5=9C=A8 2024/1/5 =E4=B8=8B=E5=8D=884:37, Xi Ruoyao =E5=86=99=E9=81=93: > > On Fri, 2024-01-05 at 11:40 +0800, Lulu Cheng wrote: > > > =C2=A0=C2=A0bool > > > =C2=A0=C2=A0loongarch_explicit_relocs_p (enum loongarch_symbol_type t= ype) > > > =C2=A0=C2=A0{ > > > +=C2=A0 /* Instructions pcalau12i, addi.d, lu32i.d and lu52i.d must b= e adjancent > > > +=C2=A0=C2=A0=C2=A0=C2=A0 so that the linker can infer the PC of pcal= au12i to apply relocations > > > +=C2=A0=C2=A0=C2=A0=C2=A0 to lu32i.d and lu52i.d.=C2=A0 Otherwise, th= e results would be incorrect if > > > +=C2=A0=C2=A0=C2=A0=C2=A0 these four instructions are not in the same= 4KiB page. > > > +=C2=A0=C2=A0=C2=A0=C2=A0 Therefore, macro instructions are used when= cmodel=3Dextreme.=C2=A0 */ > > > +=C2=A0 if (loongarch_symbol_extreme_p (type)) > > > +=C2=A0=C2=A0=C2=A0 return false; > > I think this is a bit of strange.=C2=A0 With -mexplicit-relocs=3D{auto,= always} > > we should still use explicit relocs, but coding all 4 instructions > > altogether as > >=20 > > "pcalau12i.d\t%1,%pc64_hi12(%2)\n\taddi.d\t%0,$r0,%pclo12(%2)\n\tlu32i.= d\t%0,%pc64_lo20(%2)\n\tlu52i.d\t%0,%0,%pc64_hi12(%2)" > >=20 > > Give me several hours trying to implement this... > >=20 > I think there is no difference between macros and these instructions put= =20 > together. If implement it in a split form, I think I can try it through= =20 > TARGET_SCHED_MACRO_FUSION_PAIR_P There is a difference: int x; int t() { return x; } pcalau12i.d t0, %pc_hi20(x) addi.d t1, r0, %pc_lo12(x) lu32i.d t1, %pc64_lo20(x) lu52i.d t1, t1, %pc64_hi12(x) ldx.w a0, t0, t1 is slightly better than pcalau12i.d t0, %pc_hi20(x) addi.d t1, r0, %pc_lo12(x) lu32i.d t1, %pc64_lo20(x) lu52i.d t1, t1, %pc64_hi12(x) addi.d t0, t0, t1 ld.w a0, t0, 0 And generating macros when -mexplicit-relocs=3Dalways can puzzle people (it says "always" :-\ ). --=20 Xi Ruoyao School of Aerospace Science and Technology, Xidian University