summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/builtins/cpu_model.c
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@intel.com>2019-02-26 21:51:05 +0000
committerCraig Topper <craig.topper@intel.com>2019-02-26 21:51:05 +0000
commit938d3f461bfff0d56d1b433a804528e8433df95e (patch)
tree2cae98a68c7fa417f03718ad398c6b6a3a509652 /compiler-rt/lib/builtins/cpu_model.c
parentda1628eb679d2921e5d683e51cc9ecf6e5750295 (diff)
downloadbcm5719-llvm-938d3f461bfff0d56d1b433a804528e8433df95e.tar.gz
bcm5719-llvm-938d3f461bfff0d56d1b433a804528e8433df95e.zip
[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. llvm-svn: 354927
Diffstat (limited to 'compiler-rt/lib/builtins/cpu_model.c')
-rw-r--r--compiler-rt/lib/builtins/cpu_model.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/compiler-rt/lib/builtins/cpu_model.c b/compiler-rt/lib/builtins/cpu_model.c
index b6be55a6673..fc578203097 100644
--- a/compiler-rt/lib/builtins/cpu_model.c
+++ b/compiler-rt/lib/builtins/cpu_model.c
@@ -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(unsigned EAX, unsigned *Family,
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 Family, unsigned Model,
// 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 Family, unsigned Model,
}
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 getAMDProcessorTypeAndSubtype(unsigned Family, unsigned Model,
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;
OpenPOWER on IntegriCloud