Skip to content

Commit

Permalink
[X86] Attempt to make the Intel core CPU inheritance a little more re…
Browse files Browse the repository at this point in the history
…adable and maintainable

The recently added cooperlake CPU has made our already ugly switch statement even worse. There's a CPU exclusion list around the bf16 feature in the cooper lake block. I worry that we'll have to keep adding new CPUs to that until bf16 intercepts a client space CPU. We have several other exclusion lists in other parts of the switch due to skylakeserver, cascadelake, and cooperlake not having sgx. Another for cannonlake not having clwb but having all other features from skx.

This removes all these special ifs at the cost of some duplication of features and a goto. I've copied all of the skx features into either cannonlake or icelakeclient(for clwb). And pulled sklyakeserver, cascadelake, and cooperlake out of the main inheritance chain into their own chain. At the end of skylakeserver we merge back into the main chain at skylakeclient but below sgx. I think this is at least easier to follow.

Differential Revision: https://reviews.llvm.org/D63018

llvm-svn: 362965
  • Loading branch information
topperc committed Jun 10, 2019
1 parent c650a90 commit 8e1f3a0
Showing 1 changed file with 27 additions and 24 deletions.
51 changes: 27 additions & 24 deletions clang/lib/Basic/Targets/X86.cpp
Expand Up @@ -138,6 +138,25 @@ bool X86TargetInfo::initFeatureMap(
setFeatureEnabledImpl(Features, "mmx", true);
break;

case CK_Cooperlake:
// CPX inherits all CLX features plus AVX512BF16
setFeatureEnabledImpl(Features, "avx512bf16", true);
LLVM_FALLTHROUGH;
case CK_Cascadelake:
// CLX inherits all SKX features plus AVX512VNNI
setFeatureEnabledImpl(Features, "avx512vnni", true);
LLVM_FALLTHROUGH;
case CK_SkylakeServer:
setFeatureEnabledImpl(Features, "avx512f", true);
setFeatureEnabledImpl(Features, "avx512cd", true);
setFeatureEnabledImpl(Features, "avx512dq", true);
setFeatureEnabledImpl(Features, "avx512bw", true);
setFeatureEnabledImpl(Features, "avx512vl", true);
setFeatureEnabledImpl(Features, "clwb", true);
setFeatureEnabledImpl(Features, "pku", true);
// SkylakeServer cores inherits all SKL features, except SGX
goto SkylakeCommon;

case CK_IcelakeServer:
setFeatureEnabledImpl(Features, "pconfig", true);
setFeatureEnabledImpl(Features, "wbnoinvd", true);
Expand All @@ -148,45 +167,29 @@ bool X86TargetInfo::initFeatureMap(
setFeatureEnabledImpl(Features, "vpclmulqdq", true);
setFeatureEnabledImpl(Features, "avx512bitalg", true);
setFeatureEnabledImpl(Features, "avx512vbmi2", true);
setFeatureEnabledImpl(Features, "avx512vnni", true);
setFeatureEnabledImpl(Features, "avx512vpopcntdq", true);
setFeatureEnabledImpl(Features, "rdpid", true);
setFeatureEnabledImpl(Features, "clwb", true);
LLVM_FALLTHROUGH;
case CK_Cannonlake:
setFeatureEnabledImpl(Features, "avx512ifma", true);
setFeatureEnabledImpl(Features, "avx512vbmi", true);
setFeatureEnabledImpl(Features, "sha", true);
LLVM_FALLTHROUGH;
case CK_Cooperlake:
// Cannonlake, IcelakeClient and IcelakeServer have no AVX512BF16 feature
if (Kind != CK_Cannonlake && Kind != CK_IcelakeClient &&
Kind != CK_IcelakeServer)
// CPX inherits all CLX features plus AVX512BF16
setFeatureEnabledImpl(Features, "avx512bf16", true);
LLVM_FALLTHROUGH;
case CK_Cascadelake:
//Cannonlake has no VNNI feature inside while Icelake has
if (Kind != CK_Cannonlake)
// CLK inherits all SKX features plus AVX512_VNNI
setFeatureEnabledImpl(Features, "avx512vnni", true);
LLVM_FALLTHROUGH;
case CK_SkylakeServer:
setFeatureEnabledImpl(Features, "avx512f", true);
setFeatureEnabledImpl(Features, "avx512cd", true);
setFeatureEnabledImpl(Features, "avx512dq", true);
setFeatureEnabledImpl(Features, "avx512bw", true);
setFeatureEnabledImpl(Features, "avx512vl", true);
setFeatureEnabledImpl(Features, "avx512ifma", true);
setFeatureEnabledImpl(Features, "avx512vbmi", true);
setFeatureEnabledImpl(Features, "pku", true);
if (Kind != CK_Cannonlake) // CNL inherits all SKX features, except CLWB
setFeatureEnabledImpl(Features, "clwb", true);
setFeatureEnabledImpl(Features, "sha", true);
LLVM_FALLTHROUGH;
case CK_SkylakeClient:
setFeatureEnabledImpl(Features, "sgx", true);
// SkylakeServer cores inherits all SKL features, except SGX
SkylakeCommon:
setFeatureEnabledImpl(Features, "xsavec", true);
setFeatureEnabledImpl(Features, "xsaves", true);
setFeatureEnabledImpl(Features, "mpx", true);
if (Kind != CK_SkylakeServer && Kind != CK_Cascadelake &&
Kind != CK_Cooperlake)
// SKX/CLX/CPX inherits all SKL features, except SGX
setFeatureEnabledImpl(Features, "sgx", true);
setFeatureEnabledImpl(Features, "clflushopt", true);
setFeatureEnabledImpl(Features, "aes", true);
LLVM_FALLTHROUGH;
Expand Down

0 comments on commit 8e1f3a0

Please sign in to comment.