From: Yonggang Luo Date: Sat, 17 Dec 2022 16:52:02 +0000 (+0800) Subject: libcpu: Remove the need of NMNES by using enum X-Git-Tag: elfutils-0.189~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4961f9ae2f11795022166698aa15a15f48ec8c5b;p=thirdparty%2Felfutils.git libcpu: Remove the need of NMNES by using enum Signed-off-by: Yonggang Luo Signed-off-by: Mark Wielaard --- diff --git a/libcpu/ChangeLog b/libcpu/ChangeLog index 6d4b717a6..d14cd237d 100644 --- a/libcpu/ChangeLog +++ b/libcpu/ChangeLog @@ -1,3 +1,12 @@ +2022-12-18 Yonggang Luo + + * i386_mne.h: New file, extracted from i386_disasm.c. + * Makefile.am (noinst_HEADERS): Add i386_mne.h. + (i386_parse_CFLAGS): Removed. + * i386_disasm.c: Include i386_mne.h. + * i386_parse.y: Include i386_mne.h. + (instrtable_out): Use MNE_COUNT instead of NMNES. + 2022-12-18 Yonggang Luo * i386_disasm.c (i386_disasm): Use __asm instead of asm. diff --git a/libcpu/Makefile.am b/libcpu/Makefile.am index 57d0a1641..4ba1be56d 100644 --- a/libcpu/Makefile.am +++ b/libcpu/Makefile.am @@ -40,7 +40,7 @@ AM_YFLAGS = -p$(. */ + +#ifndef _I386_MNE_H +#define _I386_MNE_H 1 + +#ifndef MNEFILE +# define MNEFILE "i386.mnemonics" +#endif + +/* The index can be stored in the instrtab. */ +enum + { +#define MNE(name) MNE_##name, +#include MNEFILE +#undef MNE + MNE_INVALID, + MNE_COUNT = MNE_INVALID, + }; + +#endif /* i386_mne.h */ diff --git a/libcpu/i386_parse.y b/libcpu/i386_parse.y index d2236d599..459684c6a 100644 --- a/libcpu/i386_parse.y +++ b/libcpu/i386_parse.y @@ -46,6 +46,8 @@ #include #include +#include "i386_mne.h" + #define obstack_chunk_alloc xmalloc #define obstack_chunk_free free @@ -1107,11 +1109,6 @@ print_op_fct (const void *nodep, VISIT value, } } - -#if NMNES < 2 -# error "bogus NMNES value" -#endif - static void instrtable_out (void) { @@ -1123,7 +1120,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 = 0; i < 3; ++i)