179894
commit e4933c8a92ea08eecdf3ab45e7f76c95dc3d20ac
179894
Author: Florian Weimer <fweimer@redhat.com>
179894
Date:   Tue Mar 2 14:58:05 2021 +0100
179894
179894
    x86: Automate generation of PREFERRED_FEATURE_INDEX_1 bitfield
179894
179894
    Use a .def file to define the bitfield layout, so that it is possible
179894
    to iterate over field members using the preprocessor.
179894
179894
Conflicts:
179894
	sysdeps/x86/include/cpu-features.h
179894
	  (re-did the change from scratch)
179894
	sysdeps/x86/include/cpu-features-preferred_feature_index_1.def
179894
	  (adjusted to the downstream bits)
179894
179894
diff --git a/sysdeps/x86/include/cpu-features-preferred_feature_index_1.def b/sysdeps/x86/include/cpu-features-preferred_feature_index_1.def
179894
new file mode 100644
179894
index 0000000000000000..17a5cc428c1dabea
179894
--- /dev/null
179894
+++ b/sysdeps/x86/include/cpu-features-preferred_feature_index_1.def
179894
@@ -0,0 +1,34 @@
179894
+/* Bits in the PREFERRED_FEATURE_INDEX_1 bitfield of <cpu-features.h>.
179894
+   Copyright (C) 2020-2021 Free Software Foundation, Inc.
179894
+   This file is part of the GNU C Library.
179894
+
179894
+   The GNU C Library is free software; you can redistribute it and/or
179894
+   modify it under the terms of the GNU Lesser General Public
179894
+   License as published by the Free Software Foundation; either
179894
+   version 2.1 of the License, or (at your option) any later version.
179894
+
179894
+   The GNU C Library is distributed in the hope that it will be useful,
179894
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
179894
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
179894
+   Lesser General Public License for more details.
179894
+
179894
+   You should have received a copy of the GNU Lesser General Public
179894
+   License along with the GNU C Library; if not, see
179894
+   <https://www.gnu.org/licenses/>.  */
179894
+
179894
+BIT (I586)
179894
+BIT (I686)
179894
+BIT (Fast_Rep_String)
179894
+BIT (Fast_Copy_Backward)
179894
+BIT (Fast_Unaligned_Load)
179894
+BIT (Fast_Unaligned_Copy)
179894
+BIT (Slow_BSF)
179894
+BIT (Slow_SSE4_2)
179894
+BIT (AVX_Fast_Unaligned_Load)
179894
+BIT (Prefer_MAP_32BIT_EXEC)
179894
+BIT (Prefer_PMINUB_for_stringop)
179894
+BIT (Prefer_No_VZEROUPPER)
179894
+BIT (Prefer_ERMS)
179894
+BIT (Prefer_FSRM)
179894
+BIT (Prefer_No_AVX512)
179894
+BIT (MathVec_Prefer_No_AVX512)
179894
diff --git a/sysdeps/x86/include/cpu-features.h b/sysdeps/x86/include/cpu-features.h
179894
index f62be0b9b3746675..f43e22f677b249a9 100644
179894
--- a/sysdeps/x86/include/cpu-features.h
179894
+++ b/sysdeps/x86/include/cpu-features.h
179894
@@ -80,40 +80,23 @@ enum
179894
 # define HAS_ARCH_FEATURE(name) \
179894
   CPU_FEATURE_PREFERRED (name)
179894
 
179894
-/* PREFERRED_FEATURE_INDEX_1.  */
179894
-# define bit_arch_I586				(1u << 0)
179894
-# define bit_arch_I686				(1u << 1)
179894
-# define bit_arch_Fast_Rep_String		(1u << 2)
179894
-# define bit_arch_Fast_Copy_Backward		(1u << 3)
179894
-# define bit_arch_Fast_Unaligned_Load		(1u << 4)
179894
-# define bit_arch_Fast_Unaligned_Copy		(1u << 5)
179894
-# define bit_arch_Slow_BSF			(1u << 6)
179894
-# define bit_arch_Slow_SSE4_2			(1u << 7)
179894
-# define bit_arch_AVX_Fast_Unaligned_Load	(1u << 8)
179894
-# define bit_arch_Prefer_MAP_32BIT_EXEC		(1u << 9)
179894
-# define bit_arch_Prefer_PMINUB_for_stringop	(1u << 10)
179894
-# define bit_arch_Prefer_No_VZEROUPPER		(1u << 11)
179894
-# define bit_arch_Prefer_ERMS			(1u << 12)
179894
-# define bit_arch_Prefer_FSRM			(1u << 13)
179894
-# define bit_arch_Prefer_No_AVX512		(1u << 14)
179894
-# define bit_arch_MathVec_Prefer_No_AVX512	(1u << 15)
179894
-
179894
-# define index_arch_Fast_Rep_String		PREFERRED_FEATURE_INDEX_1
179894
-# define index_arch_Fast_Copy_Backward		PREFERRED_FEATURE_INDEX_1
179894
-# define index_arch_Slow_BSF			PREFERRED_FEATURE_INDEX_1
179894
-# define index_arch_Fast_Unaligned_Load		PREFERRED_FEATURE_INDEX_1
179894
-# define index_arch_Prefer_PMINUB_for_stringop 	PREFERRED_FEATURE_INDEX_1
179894
-# define index_arch_Fast_Unaligned_Copy		PREFERRED_FEATURE_INDEX_1
179894
-# define index_arch_I586			PREFERRED_FEATURE_INDEX_1
179894
-# define index_arch_I686			PREFERRED_FEATURE_INDEX_1
179894
-# define index_arch_Slow_SSE4_2			PREFERRED_FEATURE_INDEX_1
179894
-# define index_arch_AVX_Fast_Unaligned_Load	PREFERRED_FEATURE_INDEX_1
179894
-# define index_arch_Prefer_MAP_32BIT_EXEC	PREFERRED_FEATURE_INDEX_1
179894
-# define index_arch_Prefer_No_VZEROUPPER	PREFERRED_FEATURE_INDEX_1
179894
-# define index_arch_Prefer_ERMS			PREFERRED_FEATURE_INDEX_1
179894
-# define index_arch_Prefer_No_AVX512		PREFERRED_FEATURE_INDEX_1
179894
-# define index_arch_MathVec_Prefer_No_AVX512	PREFERRED_FEATURE_INDEX_1
179894
-# define index_arch_Prefer_FSRM			PREFERRED_FEATURE_INDEX_1
179894
+/* PREFERRED_FEATURE_INDEX_1.  First define the bitindex values
179894
+   sequentially, then define the bit_arch* and index_arch_* lookup
179894
+   constants.  */
179894
+enum
179894
+  {
179894
+#define BIT(x) _bitindex_arch_##x ,
179894
+#include "cpu-features-preferred_feature_index_1.def"
179894
+#undef BIT
179894
+  };
179894
+enum
179894
+  {
179894
+#define BIT(x)                                 \
179894
+    bit_arch_##x = 1u << _bitindex_arch_##x ,  \
179894
+    index_arch_##x = PREFERRED_FEATURE_INDEX_1,
179894
+#include "cpu-features-preferred_feature_index_1.def"
179894
+#undef BIT
179894
+  };
179894
 
179894
 /* XCR0 Feature flags.  */
179894
 # define bit_XMM_state		(1u << 1)