From patchwork Tue Mar 2 14:23:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 42199 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 A4DAA3870897; Tue, 2 Mar 2021 14:23:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A4DAA3870897 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1614695032; bh=pjmSW9RZIQywwidlM/98kwlaO6b79gt+6s2mRxW5X0g=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=BpACopIscdFYWUa+wy/vTF9/xjdrfzeCmN//y46k5URy8rESqixz41Lvoti9HAH41 Z5WsNVhd6Ey7geP0/UP4fCn24oaorppCv99I/vufkO7uRQhSOLzFABBImwEdSflnnS 8VaGexCC8z8pGsQG4eFGmJXRyG/CyJNWJVjZJ/rQ= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org 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 4B5833854835 for ; Tue, 2 Mar 2021 14:23:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4B5833854835 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-602-gmPqrUedM1alh4e7qHB24w-1; Tue, 02 Mar 2021 09:23:45 -0500 X-MC-Unique: gmPqrUedM1alh4e7qHB24w-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 445BE84E241; Tue, 2 Mar 2021 14:23:44 +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 8C79E19D9D; Tue, 2 Mar 2021 14:23:43 +0000 (UTC) To: libc-alpha@sourceware.org Subject: [PATCH 1/2] x86: Automate generation of PREFERRED_FEATURE_INDEX_1 bitfield Date: Tue, 02 Mar 2021 15:23:47 +0100 Message-ID: <87k0qpzlak.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.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.3 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-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Florian Weimer via Libc-alpha From: Florian Weimer Reply-To: Florian Weimer Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" Use a .def file to define the bitfield layout, so that it is possible to iterate over field members using the preprocessor. --- .../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 ae5cb24be5..0fb988ead0 100644 --- a/sysdeps/x86/include/cpu-features.h +++ b/sysdeps/x86/include/cpu-features.h @@ -772,40 +772,23 @@ enum /* EBX. */ #define reg_PTWRITE 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)