b1dca6
commit 875a50ff63b2c86af770949d563ee851d08eb46e
b1dca6
Author: H.J. Lu <hjl.tools@gmail.com>
b1dca6
Date:   Thu Oct 8 08:33:45 2020 -0700
b1dca6
b1dca6
    <sys/platform/x86.h>: Add AVX-VNNI support
b1dca6
    
b1dca6
    Add AVX-VNNI support to <sys/platform/x86.h>.
b1dca6
b1dca6
diff --git a/manual/platform.texi b/manual/platform.texi
b1dca6
index 4f5fdff9d9ef16fd..283f255679643d3e 100644
b1dca6
--- a/manual/platform.texi
b1dca6
+++ b/manual/platform.texi
b1dca6
@@ -198,6 +198,9 @@ The supported processor features are:
b1dca6
 @item
b1dca6
 @code{AVX2} -- The AVX2 instruction extensions.
b1dca6
 
b1dca6
+@item
b1dca6
+@code{AVX_VNNI} -- The AVX-VNNI instruction extensions.
b1dca6
+
b1dca6
 @item
b1dca6
 @code{AVX512_4FMAPS} -- The AVX512_4FMAPS instruction extensions.
b1dca6
 
b1dca6
diff --git a/sysdeps/x86/cpu-features.c b/sysdeps/x86/cpu-features.c
b1dca6
index 67f137259fccf4ad..3e5b9341c9756009 100644
b1dca6
--- a/sysdeps/x86/cpu-features.c
b1dca6
+++ b/sysdeps/x86/cpu-features.c
b1dca6
@@ -119,6 +119,8 @@ update_usable (struct cpu_features *cpu_features)
b1dca6
 		  cpu_features->preferred[index_arch_AVX_Fast_Unaligned_Load]
b1dca6
 		    |= bit_arch_AVX_Fast_Unaligned_Load;
b1dca6
 		}
b1dca6
+	      /* Determine if AVX-VNNI is usable.  */
b1dca6
+	      CPU_FEATURE_SET_USABLE (cpu_features, AVX_VNNI);
b1dca6
 	      /* Determine if FMA is usable.  */
b1dca6
 	      CPU_FEATURE_SET_USABLE (cpu_features, FMA);
b1dca6
 	      /* Determine if VAES is usable.  */
b1dca6
diff --git a/sysdeps/x86/sys/platform/x86.h b/sysdeps/x86/sys/platform/x86.h
b1dca6
index 0b18257e20105ea4..0942ad7a7f7d4ce2 100644
b1dca6
--- a/sysdeps/x86/sys/platform/x86.h
b1dca6
+++ b/sysdeps/x86/sys/platform/x86.h
b1dca6
@@ -311,6 +311,7 @@ extern const struct cpu_features *__x86_get_cpu_features (unsigned int)
b1dca6
 /* COMMON_CPUID_INDEX_7_ECX_1.  */
b1dca6
 
b1dca6
 /* EAX.  */
b1dca6
+#define bit_cpu_AVX_VNNI	(1u << 4)
b1dca6
 #define bit_cpu_AVX512_BF16	(1u << 5)
b1dca6
 
b1dca6
 /* COMMON_CPUID_INDEX_19.  */
b1dca6
@@ -530,6 +531,7 @@ extern const struct cpu_features *__x86_get_cpu_features (unsigned int)
b1dca6
 /* COMMON_CPUID_INDEX_7_ECX_1.  */
b1dca6
 
b1dca6
 /* EAX.  */
b1dca6
+#define index_cpu_AVX_VNNI	COMMON_CPUID_INDEX_7_ECX_1
b1dca6
 #define index_cpu_AVX512_BF16	COMMON_CPUID_INDEX_7_ECX_1
b1dca6
 
b1dca6
 /* COMMON_CPUID_INDEX_19.  */
b1dca6
@@ -749,6 +751,7 @@ extern const struct cpu_features *__x86_get_cpu_features (unsigned int)
b1dca6
 /* COMMON_CPUID_INDEX_7_ECX_1.  */
b1dca6
 
b1dca6
 /* EAX.  */
b1dca6
+#define reg_AVX_VNNI		eax
b1dca6
 #define reg_AVX512_BF16		eax
b1dca6
 
b1dca6
 /* COMMON_CPUID_INDEX_19.  */
b1dca6
diff --git a/sysdeps/x86/tst-get-cpu-features.c b/sysdeps/x86/tst-get-cpu-features.c
b1dca6
index bcdeb243a82c4adc..8894d9f08ac36633 100644
b1dca6
--- a/sysdeps/x86/tst-get-cpu-features.c
b1dca6
+++ b/sysdeps/x86/tst-get-cpu-features.c
b1dca6
@@ -219,6 +219,7 @@ do_test (void)
b1dca6
   CHECK_CPU_FEATURE (XFD);
b1dca6
   CHECK_CPU_FEATURE (INVARIANT_TSC);
b1dca6
   CHECK_CPU_FEATURE (WBNOINVD);
b1dca6
+  CHECK_CPU_FEATURE (AVX_VNNI);
b1dca6
   CHECK_CPU_FEATURE (AVX512_BF16);
b1dca6
   CHECK_CPU_FEATURE (AESKLE);
b1dca6
   CHECK_CPU_FEATURE (WIDE_KL);
b1dca6
@@ -374,6 +375,7 @@ do_test (void)
b1dca6
   CHECK_CPU_FEATURE_USABLE (XFD);
b1dca6
   CHECK_CPU_FEATURE_USABLE (INVARIANT_TSC);
b1dca6
   CHECK_CPU_FEATURE_USABLE (WBNOINVD);
b1dca6
+  CHECK_CPU_FEATURE_USABLE (AVX_VNNI);
b1dca6
   CHECK_CPU_FEATURE_USABLE (AVX512_BF16);
b1dca6
   CHECK_CPU_FEATURE_USABLE (AESKLE);
b1dca6
   CHECK_CPU_FEATURE_USABLE (WIDE_KL);