@@ -80,6 +80,8 @@ enum ProcessorSubtypes {
80
80
INTEL_COREI7_CANNONLAKE ,
81
81
INTEL_COREI7_ICELAKE_CLIENT ,
82
82
INTEL_COREI7_ICELAKE_SERVER ,
83
+ AMDFAM17H_ZNVER2 ,
84
+ INTEL_COREI7_CASCADELAKE ,
83
85
CPU_SUBTYPE_MAX
84
86
};
85
87
@@ -268,7 +270,8 @@ static void detectX86FamilyModel(unsigned EAX, unsigned *Family,
268
270
static void
269
271
getIntelProcessorTypeAndSubtype (unsigned Family , unsigned Model ,
270
272
unsigned Brand_id , unsigned Features ,
271
- unsigned * Type , unsigned * Subtype ) {
273
+ unsigned Features2 , unsigned * Type ,
274
+ unsigned * Subtype ) {
272
275
if (Brand_id != 0 )
273
276
return ;
274
277
switch (Family ) {
@@ -347,7 +350,10 @@ getIntelProcessorTypeAndSubtype(unsigned Family, unsigned Model,
347
350
// Skylake Xeon:
348
351
case 0x55 :
349
352
* Type = INTEL_COREI7 ;
350
- * Subtype = INTEL_COREI7_SKYLAKE_AVX512 ; // "skylake-avx512"
353
+ if (Features2 & (1 << (FEATURE_AVX512VNNI - 32 )))
354
+ * Subtype = INTEL_COREI7_CASCADELAKE ; // "cascadelake"
355
+ else
356
+ * Subtype = INTEL_COREI7_SKYLAKE_AVX512 ; // "skylake-avx512"
351
357
break ;
352
358
353
359
// Cannonlake:
@@ -400,8 +406,8 @@ getIntelProcessorTypeAndSubtype(unsigned Family, unsigned Model,
400
406
}
401
407
402
408
static void getAMDProcessorTypeAndSubtype (unsigned Family , unsigned Model ,
403
- unsigned Features , unsigned * Type ,
404
- unsigned * Subtype ) {
409
+ unsigned Features , unsigned Features2 ,
410
+ unsigned * Type , unsigned * Subtype ) {
405
411
// FIXME: this poorly matches the generated SubtargetFeatureKV table. There
406
412
// appears to be no way to generate the wide variety of AMD-specific targets
407
413
// from the information returned from CPUID.
@@ -447,7 +453,14 @@ static void getAMDProcessorTypeAndSubtype(unsigned Family, unsigned Model,
447
453
break ; // "btver2"
448
454
case 23 :
449
455
* Type = AMDFAM17H ;
450
- * Subtype = AMDFAM17H_ZNVER1 ;
456
+ if (Model >= 0x30 && Model <= 0x3f ) {
457
+ * Subtype = AMDFAM17H_ZNVER2 ;
458
+ break ; // "znver2"; 30h-3fh: Zen2
459
+ }
460
+ if (Model <= 0x0f ) {
461
+ * Subtype = AMDFAM17H_ZNVER1 ;
462
+ break ; // "znver1"; 00h-0Fh: Zen1
463
+ }
451
464
break ;
452
465
default :
453
466
break ; // "generic"
@@ -628,12 +641,13 @@ __cpu_indicator_init(void) {
628
641
if (Vendor == SIG_INTEL ) {
629
642
/* Get CPU type. */
630
643
getIntelProcessorTypeAndSubtype (Family , Model , Brand_id , Features ,
644
+ Features2 ,
631
645
& (__cpu_model .__cpu_type ),
632
646
& (__cpu_model .__cpu_subtype ));
633
647
__cpu_model .__cpu_vendor = VENDOR_INTEL ;
634
648
} else if (Vendor == SIG_AMD ) {
635
649
/* Get CPU type. */
636
- getAMDProcessorTypeAndSubtype (Family , Model , Features ,
650
+ getAMDProcessorTypeAndSubtype (Family , Model , Features , Features2 ,
637
651
& (__cpu_model .__cpu_type ),
638
652
& (__cpu_model .__cpu_subtype ));
639
653
__cpu_model .__cpu_vendor = VENDOR_AMD ;
0 commit comments