From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id 18E433857835 for ; Mon, 3 Apr 2023 14:03:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 18E433857835 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 490221063; Mon, 3 Apr 2023 07:04:08 -0700 (PDT) Received: from localhost (e121540-lin.manchester.arm.com [10.32.110.72]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DE37F3F73F; Mon, 3 Apr 2023 07:03:22 -0700 (PDT) From: Richard Sandiford To: YunQiang Su Mail-Followup-To: YunQiang Su ,binutils@sourceware.org, syq@debian.org, macro@orcam.me.uk, xry111@xry111.site, jiaxun.yang@flygoat.com, richard.sandiford@arm.com Cc: binutils@sourceware.org, syq@debian.org, macro@orcam.me.uk, xry111@xry111.site, jiaxun.yang@flygoat.com Subject: Re: [PATCH v2] MIPS: make mipsisa32 and mipsisa64 link more systematic References: <20230221040650.2337395-1-yunqiang.su@cipunited.com> <20230302015222.291088-1-yunqiang.su@cipunited.com> Date: Mon, 03 Apr 2023 15:03:21 +0100 In-Reply-To: <20230302015222.291088-1-yunqiang.su@cipunited.com> (YunQiang Su's message of "Thu, 2 Mar 2023 09:52:22 +0800") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-31.4 required=5.0 tests=BAYES_00,GIT_PATCH_0,KAM_DMARC_NONE,KAM_DMARC_STATUS,KAM_LAZY_DOMAIN_SECURITY,SPF_HELO_NONE,SPF_NONE,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 List-Id: YunQiang Su writes: > Introduce `static const struct mips_mach_extension mips_mach_32_64[]` > and `mips_mach_extends_32_64 (unsigned long base, unsigned long extension= )`, > to make mipsisa32 and mipsisa64 interlink more systemtic. > > Normally, the ISA mipsisa64rN has two subset: mipsisa64r(N-1) and > mipsisa32rN. `mips_mach_extensions` can hold only mipsisa64r(N-1), > so we need to introduce a new instruction `mips_mach_32_64`, which holds = the pair 32vs64. > > Note: R6 is not compatible with pre-R6. > > bfd/ChangeLog: > > * elfxx-mips.c (mips_mach_extends_p): make mipsisa32 and > mipsisa64 interlink more systematic. > (mips_mach_32_64): new struct added. > (mips_mach_extends_32_64): new function added. Sorry for the delay in pushing this. Could you check whether it's the right version though? When I build locally I get: > --- > bfd/elfxx-mips.c | 40 +++++++++++++++++++++++++++++----------- > 1 file changed, 29 insertions(+), 11 deletions(-) > > diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c > index 35bbd86044b..21e6396609b 100644 > --- a/bfd/elfxx-mips.c > +++ b/bfd/elfxx-mips.c > @@ -14524,6 +14524,16 @@ struct mips_mach_extension > unsigned long extension, base; > }; >=20=20 > +/* An array that maps 64-bit architectures to the corresponding 32-bit > + architectures. */ > +static const struct mips_mach_extension mips_mach_32_64[] =3D > +{ > + { bfd_mach_mipsisa64r6, bfd_mach_mipsisa32r6 }, > + { bfd_mach_mipsisa64r5, bfd_mach_mipsisa32r5 }, > + { bfd_mach_mipsisa64r3, bfd_mach_mipsisa32r3 }, > + { bfd_mach_mipsisa64r2, bfd_mach_mipsisa32r2 }, > + { bfd_mach_mipsisa64, bfd_mach_mipsisa32 } > +}; >=20=20 > /* An array describing how BFD machines relate to one another. The entr= ies > are ordered topologically with MIPS I extensions listed last. */ > @@ -14601,29 +14611,37 @@ static const struct mips_mach_extension mips_ma= ch_extensions[] =3D > { bfd_mach_mips3900, bfd_mach_mips3000 } > }; >=20=20 > -/* Return true if bfd machine EXTENSION is an extension of machine BASE.= */ > +/* Return true if bfd machine EXTENSION is the same as BASE, or if > + EXTENSION is the 64-bit equivalent of a 32-bit BASE. */ > + > +static bool > +mips_mach_extends_32_64 (unsigned long base, unsigned long extension) > +{ > + size_t i; > + > + if (extension =3D=3D base) > + return true; > + > + for (i =3D 0; i < ARRAY_SIZE (mips_mach_64_32); i++) error: =E2=80=98mips_mach_64_32=E2=80=99 undeclared (first use in this func= tion); did you mean =E2=80=98mips_mach_32_64=E2=80=99? It looks like the previous patch had the same thing (sorry for not noticing). Obviously it's a simple fix, but it would be good to have some reassurance that the patch has been tested beyond my crude sanity checks. Thanks, Richard > + if (extension =3D=3D mips_mach_32_64[i].extension) > + return base =3D=3D mips_mach_32_64[i].base; > + > + return false; > +} >=20=20 > static bool > mips_mach_extends_p (unsigned long base, unsigned long extension) > { > size_t i; >=20=20 > - if (extension =3D=3D base) > - return true; > - > - if (base =3D=3D bfd_mach_mipsisa32 > - && mips_mach_extends_p (bfd_mach_mipsisa64, extension)) > - return true; > - > - if (base =3D=3D bfd_mach_mipsisa32r2 > - && mips_mach_extends_p (bfd_mach_mipsisa64r2, extension)) > + if (mips_mach_extends_32_64 (base, extension)) > return true; >=20=20 > for (i =3D 0; i < ARRAY_SIZE (mips_mach_extensions); i++) > if (extension =3D=3D mips_mach_extensions[i].extension) > { > extension =3D mips_mach_extensions[i].base; > - if (extension =3D=3D base) > + if (mips_mach_extends_32_64 (base, extension)) > return true; > }