[compiler-rt] r354927 - [X86] Add 'znver2' and 'cascadelake' support to __cpu_indicator_init.

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 26 13:51:05 PST 2019


Author: ctopper
Date: Tue Feb 26 13:51:05 2019
New Revision: 354927

URL: http://llvm.org/viewvc/llvm-project?rev=354927&view=rev
Log:
[X86] Add 'znver2' and 'cascadelake' support to __cpu_indicator_init.

For 'cascadelake' this is adding a 'avx512vnni' feature check to the 0x55 skylake-avx512 model check. These CPUs use the same model number and only differ in the stepping number. But the feature flag is simpler than collecting all the stepping numbers.

For 'znver2' this is just syncing with LLVM's Host.cpp.

Modified:
    compiler-rt/trunk/lib/builtins/cpu_model.c

Modified: compiler-rt/trunk/lib/builtins/cpu_model.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/builtins/cpu_model.c?rev=354927&r1=354926&r2=354927&view=diff
==============================================================================
--- compiler-rt/trunk/lib/builtins/cpu_model.c (original)
+++ compiler-rt/trunk/lib/builtins/cpu_model.c Tue Feb 26 13:51:05 2019
@@ -80,6 +80,8 @@ enum ProcessorSubtypes {
   INTEL_COREI7_CANNONLAKE,
   INTEL_COREI7_ICELAKE_CLIENT,
   INTEL_COREI7_ICELAKE_SERVER,
+  AMDFAM17H_ZNVER2,
+  INTEL_COREI7_CASCADELAKE,
   CPU_SUBTYPE_MAX
 };
 
@@ -268,7 +270,8 @@ static void detectX86FamilyModel(unsigne
 static void
 getIntelProcessorTypeAndSubtype(unsigned Family, unsigned Model,
                                 unsigned Brand_id, unsigned Features,
-                                unsigned *Type, unsigned *Subtype) {
+                                unsigned Features2, unsigned *Type,
+                                unsigned *Subtype) {
   if (Brand_id != 0)
     return;
   switch (Family) {
@@ -347,7 +350,10 @@ getIntelProcessorTypeAndSubtype(unsigned
     // Skylake Xeon:
     case 0x55:
       *Type = INTEL_COREI7;
-      *Subtype = INTEL_COREI7_SKYLAKE_AVX512; // "skylake-avx512"
+      if (Features2 & (1 << (FEATURE_AVX512VNNI - 32)))
+        *Subtype = INTEL_COREI7_CASCADELAKE; // "cascadelake"
+      else
+        *Subtype = INTEL_COREI7_SKYLAKE_AVX512; // "skylake-avx512"
       break;
 
     // Cannonlake:
@@ -400,8 +406,8 @@ getIntelProcessorTypeAndSubtype(unsigned
 }
 
 static void getAMDProcessorTypeAndSubtype(unsigned Family, unsigned Model,
-                                          unsigned Features, unsigned *Type,
-                                          unsigned *Subtype) {
+                                          unsigned Features, unsigned Features2,
+                                          unsigned *Type, unsigned *Subtype) {
   // FIXME: this poorly matches the generated SubtargetFeatureKV table.  There
   // appears to be no way to generate the wide variety of AMD-specific targets
   // from the information returned from CPUID.
@@ -447,7 +453,14 @@ static void getAMDProcessorTypeAndSubtyp
     break; // "btver2"
   case 23:
     *Type = AMDFAM17H;
-    *Subtype = AMDFAM17H_ZNVER1;
+    if (Model >= 0x30 && Model <= 0x3f) {
+      *Subtype = AMDFAM17H_ZNVER2;
+      break; // "znver2"; 30h-3fh: Zen2
+    }
+    if (Model <= 0x0f) {
+      *Subtype = AMDFAM17H_ZNVER1;
+      break; // "znver1"; 00h-0Fh: Zen1
+    }
     break;
   default:
     break; // "generic"
@@ -628,12 +641,13 @@ __cpu_indicator_init(void) {
   if (Vendor == SIG_INTEL) {
     /* Get CPU type.  */
     getIntelProcessorTypeAndSubtype(Family, Model, Brand_id, Features,
+                                    Features2,
                                     &(__cpu_model.__cpu_type),
                                     &(__cpu_model.__cpu_subtype));
     __cpu_model.__cpu_vendor = VENDOR_INTEL;
   } else if (Vendor == SIG_AMD) {
     /* Get CPU type.  */
-    getAMDProcessorTypeAndSubtype(Family, Model, Features,
+    getAMDProcessorTypeAndSubtype(Family, Model, Features, Features2,
                                   &(__cpu_model.__cpu_type),
                                   &(__cpu_model.__cpu_subtype));
     __cpu_model.__cpu_vendor = VENDOR_AMD;




More information about the llvm-commits mailing list