From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gnu.wildebeest.org (gnu.wildebeest.org [45.83.234.184]) by sourceware.org (Postfix) with ESMTPS id 9868038983BC for ; Mon, 12 Dec 2022 12:37:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9868038983BC Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=klomp.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=klomp.org Received: from tarox.wildebeest.org (83-87-18-245.cable.dynamic.v4.ziggo.nl [83.87.18.245]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id 5BE1E3045FA6; Mon, 12 Dec 2022 13:37:26 +0100 (CET) Received: by tarox.wildebeest.org (Postfix, from userid 1000) id 897BF403DC81; Mon, 12 Dec 2022 13:37:25 +0100 (CET) Message-ID: <1a46e06ddb47fe88391b775138264bd67b5c81af.camel@klomp.org> Subject: Re: [PATCH 10/25] libcpu: Remove the need of NMNES by using enum From: Mark Wielaard To: Yonggang Luo , elfutils-devel@sourceware.org Date: Mon, 12 Dec 2022 13:37:25 +0100 In-Reply-To: <20221020182603.815-11-luoyonggang@gmail.com> References: <20221020182603.815-1-luoyonggang@gmail.com> <20221020182603.815-11-luoyonggang@gmail.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Evolution 3.28.5 (3.28.5-10.el7) Mime-Version: 1.0 X-Spam-Status: No, score=-3038.7 required=5.0 tests=BAYES_00,GIT_PATCH_0,JMQ_SPF_NEUTRAL,KAM_DMARC_STATUS,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 List-Id: Hi, On Fri, 2022-10-21 at 02:25 +0800, Yonggang Luo via Elfutils-devel wrote: > Signed-off-by: Yonggang Luo > --- > libcpu/Makefile.am | 2 +- > libcpu/i386_parse.y | 13 +++++++++---- > 2 files changed, 10 insertions(+), 5 deletions(-) >=20 > diff --git a/libcpu/Makefile.am b/libcpu/Makefile.am > index 57d0a164..259ed838 100644 > --- a/libcpu/Makefile.am > +++ b/libcpu/Makefile.am > @@ -92,7 +92,7 @@ libeu =3D ../lib/libeu.a > i386_lex_CFLAGS =3D -Wno-unused-label -Wno-unused-function -Wno-sign- > compare \ > -Wno-implicit-fallthrough > i386_parse.o: i386_parse.c i386.mnemonics > -i386_parse_CFLAGS =3D -DNMNES=3D"`wc -l < i386.mnemonics`" > +i386_parse_CFLAGS =3D > i386_lex.o: i386_parse.h > i386_gendis_LDADD =3D $(libeu) -lm $(obstack_LIBS) > =20 > diff --git a/libcpu/i386_parse.y b/libcpu/i386_parse.y > index d2236d59..5f31484c 100644 > --- a/libcpu/i386_parse.y > +++ b/libcpu/i386_parse.y > @@ -1108,9 +1108,14 @@ print_op_fct (const void *nodep, VISIT value, > } > =20 > =20 > -#if NMNES < 2 > -# error "bogus NMNES value" > -#endif > +/* The index can be stored in the instrtab. */ > +enum > + { > +#define MNE(name) MNE_##name, > +#include "i386.mnemonics" > +#undef MNE > + MNE_COUNT > + }; Since almost the same enum is defined in i386_disasm.c, just with MNE_COUNT =3D MNE_INVALID, can we define and use them in one place? > static void > instrtable_out (void) > @@ -1123,7 +1128,7 @@ instrtable_out (void) > fprintf (outfile, "#define MNEMONIC_BITS %zu\n", > best_mnemonic_bits); > #else > fprintf (outfile, "#define MNEMONIC_BITS %ld\n", > - lrint (ceil (log2 (NMNES)))); > + lrint (ceil (log2 (MNE_COUNT)))); > #endif > fprintf (outfile, "#define SUFFIX_BITS %d\n", nbitsuf); > for (int i =3D 0; i < 3; ++i)