From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by sourceware.org (Postfix) with ESMTP id E9D283854816 for ; Tue, 2 Mar 2021 15:55:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E9D283854816 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-548-MP1gBs0JNKO67w9mmCAfPw-1; Tue, 02 Mar 2021 10:55:48 -0500 X-MC-Unique: MP1gBs0JNKO67w9mmCAfPw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8BBEB1005501 for ; Tue, 2 Mar 2021 15:55:47 +0000 (UTC) Received: from oldenburg.str.redhat.com (ovpn-112-51.ams2.redhat.com [10.36.112.51]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DEBAC5C1BB for ; Tue, 2 Mar 2021 15:55:46 +0000 (UTC) From: Florian Weimer To: libc-stable@sourceware.org Subject: [PATCH 2.33 COMMITTED] x86: Automate generation of PREFERRED_FEATURE_INDEX_1 bitfield Date: Tue, 02 Mar 2021 16:55:50 +0100 Message-ID: <87wnupy2gp.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-stable@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-stable mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Mar 2021 15:55:52 -0000 Use a .def file to define the bitfield layout, so that it is possible to iterate over field members using the preprocessor. (cherry picked from commit e4933c8a92ea08eecdf3ab45e7f76c95dc3d20ac) --- .../cpu-features-preferred_feature_index_1.def | 34 +++++++++++++++ sysdeps/x86/include/cpu-features.h | 51 ++++++++-------------- 2 files changed, 51 insertions(+), 34 deletions(-) diff --git a/sysdeps/x86/include/cpu-features-preferred_feature_index_1.def b/sysdeps/x86/include/cpu-features-preferred_feature_index_1.def new file mode 100644 index 0000000000..06af1a8dd5 --- /dev/null +++ b/sysdeps/x86/include/cpu-features-preferred_feature_index_1.def @@ -0,0 +1,34 @@ +/* Bits in the PREFERRED_FEATURE_INDEX_1 bitfield of . + Copyright (C) 2020-2021 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +BIT (Fast_Rep_String) +BIT (Fast_Copy_Backward) +BIT (Slow_BSF) +BIT (Fast_Unaligned_Load) +BIT (Prefer_PMINUB_for_stringop) +BIT (Fast_Unaligned_Copy) +BIT (I586) +BIT (I686) +BIT (Slow_SSE4_2) +BIT (AVX_Fast_Unaligned_Load) +BIT (Prefer_MAP_32BIT_EXEC) +BIT (Prefer_No_VZEROUPPER) +BIT (Prefer_ERMS) +BIT (Prefer_No_AVX512) +BIT (MathVec_Prefer_No_AVX512) +BIT (Prefer_FSRM) diff --git a/sysdeps/x86/include/cpu-features.h b/sysdeps/x86/include/cpu-features.h index 624736b40e..e7f314657c 100644 --- a/sysdeps/x86/include/cpu-features.h +++ b/sysdeps/x86/include/cpu-features.h @@ -757,40 +757,23 @@ enum #define reg_AESKLE ebx #define reg_WIDE_KL ebx -/* PREFERRED_FEATURE_INDEX_1. */ -#define bit_arch_I586 (1u << 0) -#define bit_arch_I686 (1u << 1) -#define bit_arch_Fast_Rep_String (1u << 2) -#define bit_arch_Fast_Copy_Backward (1u << 3) -#define bit_arch_Fast_Unaligned_Load (1u << 4) -#define bit_arch_Fast_Unaligned_Copy (1u << 5) -#define bit_arch_Slow_BSF (1u << 6) -#define bit_arch_Slow_SSE4_2 (1u << 7) -#define bit_arch_AVX_Fast_Unaligned_Load (1u << 8) -#define bit_arch_Prefer_MAP_32BIT_EXEC (1u << 9) -#define bit_arch_Prefer_PMINUB_for_stringop (1u << 10) -#define bit_arch_Prefer_No_VZEROUPPER (1u << 11) -#define bit_arch_Prefer_ERMS (1u << 12) -#define bit_arch_Prefer_FSRM (1u << 13) -#define bit_arch_Prefer_No_AVX512 (1u << 14) -#define bit_arch_MathVec_Prefer_No_AVX512 (1u << 15) - -#define index_arch_Fast_Rep_String PREFERRED_FEATURE_INDEX_1 -#define index_arch_Fast_Copy_Backward PREFERRED_FEATURE_INDEX_1 -#define index_arch_Slow_BSF PREFERRED_FEATURE_INDEX_1 -#define index_arch_Fast_Unaligned_Load PREFERRED_FEATURE_INDEX_1 -#define index_arch_Prefer_PMINUB_for_stringop PREFERRED_FEATURE_INDEX_1 -#define index_arch_Fast_Unaligned_Copy PREFERRED_FEATURE_INDEX_1 -#define index_arch_I586 PREFERRED_FEATURE_INDEX_1 -#define index_arch_I686 PREFERRED_FEATURE_INDEX_1 -#define index_arch_Slow_SSE4_2 PREFERRED_FEATURE_INDEX_1 -#define index_arch_AVX_Fast_Unaligned_Load PREFERRED_FEATURE_INDEX_1 -#define index_arch_Prefer_MAP_32BIT_EXEC PREFERRED_FEATURE_INDEX_1 -#define index_arch_Prefer_No_VZEROUPPER PREFERRED_FEATURE_INDEX_1 -#define index_arch_Prefer_ERMS PREFERRED_FEATURE_INDEX_1 -#define index_arch_Prefer_No_AVX512 PREFERRED_FEATURE_INDEX_1 -#define index_arch_MathVec_Prefer_No_AVX512 PREFERRED_FEATURE_INDEX_1 -#define index_arch_Prefer_FSRM PREFERRED_FEATURE_INDEX_1 +/* PREFERRED_FEATURE_INDEX_1. First define the bitindex values + sequentially, then define the bit_arch* and index_arch_* lookup + constants. */ +enum + { +#define BIT(x) _bitindex_arch_##x , +#include "cpu-features-preferred_feature_index_1.def" +#undef BIT + }; +enum + { +#define BIT(x) \ + bit_arch_##x = 1u << _bitindex_arch_##x , \ + index_arch_##x = PREFERRED_FEATURE_INDEX_1, +#include "cpu-features-preferred_feature_index_1.def" +#undef BIT + }; /* XCR0 Feature flags. */ #define bit_XMM_state (1u << 1)