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 C7EEA3858415 for ; Mon, 8 Nov 2021 10:38:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C7EEA3858415 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 55D50D6E for ; Mon, 8 Nov 2021 02:38:14 -0800 (PST) Received: from localhost (e121540-lin.manchester.arm.com [10.32.98.88]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id F051B3F800 for ; Mon, 8 Nov 2021 02:38:13 -0800 (PST) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: [committed] genmodes: Define NUM_MODE_* macros Date: Mon, 08 Nov 2021 10:38:12 +0000 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Nov 2021 10:38:16 -0000 I was working on a patch that needed to calculate the number of modes in a particular class. It seemed better to have genmodes generate this directly rather than do the kind of dance that expmed.h had. Tested on aarch64-linux-gnu and x86_64-linux-gnu & pushed, counting the non-gen* bits as obvious. Richard gcc/ * genmodes.c (emit_insn_modes_h): Define NUM_MODE_* macros. * expmed.h (NUM_MODE_INT): Delete in favor of genmodes definitions. (NUM_MODE_PARTIAL_INT, NUM_MODE_VECTOR_INT): Likewise. * real.h (real_format_for_mode): Use NUM_MODE_FLOAT and NUM_MODE_DECIMAL_FLOAT. (REAL_MODE_FORMAT): Likewise. --- gcc/expmed.h | 9 --------- gcc/genmodes.c | 13 +++++++++++++ gcc/real.h | 5 ++--- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/gcc/expmed.h b/gcc/expmed.h index 93cd6316f0d..6b13ea96c49 100644 --- a/gcc/expmed.h +++ b/gcc/expmed.h @@ -133,15 +133,6 @@ struct alg_hash_entry { #define NUM_ALG_HASH_ENTRIES 307 #endif -#define NUM_MODE_INT \ - (MAX_MODE_INT - MIN_MODE_INT + 1) -#define NUM_MODE_PARTIAL_INT \ - (MIN_MODE_PARTIAL_INT == E_VOIDmode ? 0 \ - : MAX_MODE_PARTIAL_INT - MIN_MODE_PARTIAL_INT + 1) -#define NUM_MODE_VECTOR_INT \ - (MIN_MODE_VECTOR_INT == E_VOIDmode ? 0 \ - : MAX_MODE_VECTOR_INT - MIN_MODE_VECTOR_INT + 1) - #define NUM_MODE_IP_INT (NUM_MODE_INT + NUM_MODE_PARTIAL_INT) #define NUM_MODE_IPV_INT (NUM_MODE_IP_INT + NUM_MODE_VECTOR_INT) diff --git a/gcc/genmodes.c b/gcc/genmodes.c index c9af4efba46..ecc8b448406 100644 --- a/gcc/genmodes.c +++ b/gcc/genmodes.c @@ -1316,6 +1316,19 @@ enum machine_mode\n{"); NUM_MACHINE_MODES = MAX_MACHINE_MODE\n\ };\n"); + /* Define a NUM_* macro for each mode class, giving the number of modes + in the class. */ + for (c = 0; c < MAX_MODE_CLASS; c++) + { + printf ("#define NUM_%s ", mode_class_names[c]); + if (modes[c]) + printf ("(MAX_%s - MIN_%s + 1)\n", mode_class_names[c], + mode_class_names[c]); + else + printf ("0\n"); + } + printf ("\n"); + /* I can't think of a better idea, can you? */ printf ("#define CONST_MODE_NUNITS%s\n", adj_nunits ? "" : " const"); printf ("#define CONST_MODE_PRECISION%s\n", adj_nunits ? "" : " const"); diff --git a/gcc/real.h b/gcc/real.h index 015163d9917..39dd34e3971 100644 --- a/gcc/real.h +++ b/gcc/real.h @@ -178,13 +178,12 @@ struct real_format decimal float modes indexed by (MODE - first decimal float mode) + the number of float modes. */ extern const struct real_format * - real_format_for_mode[MAX_MODE_FLOAT - MIN_MODE_FLOAT + 1 - + MAX_MODE_DECIMAL_FLOAT - MIN_MODE_DECIMAL_FLOAT + 1]; + real_format_for_mode[NUM_MODE_FLOAT + NUM_MODE_DECIMAL_FLOAT]; #define REAL_MODE_FORMAT(MODE) \ (real_format_for_mode[DECIMAL_FLOAT_MODE_P (MODE) \ ? (((MODE) - MIN_MODE_DECIMAL_FLOAT) \ - + (MAX_MODE_FLOAT - MIN_MODE_FLOAT + 1)) \ + + NUM_MODE_FLOAT) \ : GET_MODE_CLASS (MODE) == MODE_FLOAT \ ? ((MODE) - MIN_MODE_FLOAT) \ : (gcc_unreachable (), 0)]) -- 2.25.1