From patchwork Thu Oct 20 18:25:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 59227 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 650B4383EC5C for ; Thu, 20 Oct 2022 18:27:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 650B4383EC5C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1666290434; bh=SfZ1JLdeMlPTGpYrZl9/4ODxgDiVxf0aQ1iwJngEQxQ=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Help:List-Subscribe:From:Reply-To:From; b=fTGOHZyeRaQWfTCAhv5ygrQ67MKst7qhiyfMskR4Hwd0giC+7+z5CzHNacljY3P/s KJgaEvqLsJwD+1GnI4p56fyyBDhTmTD6CCTY8FTsZLfujEgrLKCKMwIvCXg8nBGKRF E21bGbu3/zSh+4n599zu+eE+ZUO/bVVMpeyLqKNg= X-Original-To: elfutils-devel@sourceware.org Delivered-To: elfutils-devel@sourceware.org Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by sourceware.org (Postfix) with ESMTPS id 478F6384C00B for ; Thu, 20 Oct 2022 18:26:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 478F6384C00B Received: by mail-pl1-x636.google.com with SMTP id f23so97942plr.6 for ; Thu, 20 Oct 2022 11:26:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SfZ1JLdeMlPTGpYrZl9/4ODxgDiVxf0aQ1iwJngEQxQ=; b=1Oh1OpyBLZwNuGRFd/W4eUMaGXEeQNHCR7tLBlMwT6QC1XdqTPvGUiaIuE4mHYeVNJ gvaLD53nKTs6ErbK7sRE+c/lD54Fmf9OF87eZD792xxLQd5Sk5EkJfllyQvnm05Y8dp7 xur2JDYaM7vK9Yra1TSF06ImbCZF0zsdN7rFDq6ZADtFLHTP9Es8rfEq0UVRIXkLGxzO h2//S4FzmxuHDnHe2xHI5wyNcJaD6JWj6O90Zy/vjpnQ2o7qBfKHCiRxFEingjE9zU6j QG5eHV7FQjju/XelwQPprKEUOKl+0K+5visqmP7VaEMZytA6iF8jbawWGNMXvGbyrDm9 ALMQ== X-Gm-Message-State: ACrzQf118b4HPel05KAKU0MXk/Z8AWb6iO8o1VT9LNwWdzZ/ocoGBbkP +uNLMPBigy/BYcx0hF75dMq61U1W1MirLw== X-Google-Smtp-Source: AMsMyM7RlN/RBwhrDRaThz30HFQs52kbpnIoX0TldoZfLRuZhyHTaL0iu8hO2N2x22sqrU/zmYY/Dw== X-Received: by 2002:a17:90b:3b47:b0:20d:a991:3f24 with SMTP id ot7-20020a17090b3b4700b0020da9913f24mr43551779pjb.108.1666290402626; Thu, 20 Oct 2022 11:26:42 -0700 (PDT) Received: from localhost.localdomain ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id w15-20020a17090a460f00b00202fbd9c21dsm115067pjg.48.2022.10.20.11.26.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Oct 2022 11:26:41 -0700 (PDT) To: elfutils-devel@sourceware.org Subject: [PATCH 10/25] libcpu: Remove the need of NMNES by using enum Date: Fri, 21 Oct 2022 02:25:49 +0800 Message-Id: <20221020182603.815-11-luoyonggang@gmail.com> X-Mailer: git-send-email 2.36.1.windows.1 In-Reply-To: <20221020182603.815-1-luoyonggang@gmail.com> References: <20221020182603.815-1-luoyonggang@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, 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 X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-Patchwork-Original-From: Yonggang Luo via Elfutils-devel From: Yonggang Luo Reply-To: Yonggang Luo Errors-To: elfutils-devel-bounces+patchwork=sourceware.org@sourceware.org Sender: "Elfutils-devel" Signed-off-by: Yonggang Luo --- libcpu/Makefile.am | 2 +- libcpu/i386_parse.y | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) 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 = ../lib/libeu.a i386_lex_CFLAGS = -Wno-unused-label -Wno-unused-function -Wno-sign-compare \ -Wno-implicit-fallthrough i386_parse.o: i386_parse.c i386.mnemonics -i386_parse_CFLAGS = -DNMNES="`wc -l < i386.mnemonics`" +i386_parse_CFLAGS = i386_lex.o: i386_parse.h i386_gendis_LDADD = $(libeu) -lm $(obstack_LIBS) 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, } -#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 + }; 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 = 0; i < 3; ++i)