Skip to content

Commit 1f057e3

Browse files
committed
[X86] AMD Zen 4 Initial enablement
Reviewed By: RKSimon Differential Revision: https://reviews.llvm.org/D139073
1 parent 2242611 commit 1f057e3

File tree

19 files changed

+199
-5
lines changed

19 files changed

+199
-5
lines changed

clang/lib/Basic/Targets/X86.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,9 @@ void X86TargetInfo::getTargetDefines(const LangOptions &Opts,
607607
case CK_ZNVER3:
608608
defineCPUMacros(Builder, "znver3");
609609
break;
610+
case CK_ZNVER4:
611+
defineCPUMacros(Builder, "znver4");
612+
break;
610613
case CK_Geode:
611614
defineCPUMacros(Builder, "geode");
612615
break;
@@ -1440,6 +1443,7 @@ Optional<unsigned> X86TargetInfo::getCPUCacheLineSize() const {
14401443
case CK_ZNVER1:
14411444
case CK_ZNVER2:
14421445
case CK_ZNVER3:
1446+
case CK_ZNVER4:
14431447
// Deprecated
14441448
case CK_x86_64:
14451449
case CK_x86_64_v2:

clang/test/CodeGen/target-builtin-noerror.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,4 +135,5 @@ void verifycpustrings(void) {
135135
(void)__builtin_cpu_is("znver1");
136136
(void)__builtin_cpu_is("znver2");
137137
(void)__builtin_cpu_is("znver3");
138+
(void)__builtin_cpu_is("znver4");
138139
}

clang/test/Driver/x86-march.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,10 @@
206206
// RUN: %clang -target x86_64-unknown-unknown -c -### %s -march=znver3 2>&1 \
207207
// RUN: | FileCheck %s -check-prefix=znver3
208208
// znver3: "-target-cpu" "znver3"
209+
//
210+
// RUN: %clang -target x86_64-unknown-unknown -c -### %s -march=znver4 2>&1 \
211+
// RUN: | FileCheck %s -check-prefix=znver4
212+
// znver4: "-target-cpu" "znver4"
209213

210214
// RUN: %clang -target x86_64 -c -### %s -march=x86-64 2>&1 | FileCheck %s --check-prefix=x86-64
211215
// x86-64: "-target-cpu" "x86-64"

clang/test/Frontend/x86-target-cpu.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,6 @@
3737
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu znver1 -verify %s
3838
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu znver2 -verify %s
3939
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu znver3 -verify %s
40+
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu znver4 -verify %s
4041
//
4142
// expected-no-diagnostics

clang/test/Misc/target-invalid-cpu-note.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@
1313

1414
// RUN: not %clang_cc1 -triple i386--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix X86
1515
// X86: error: unknown target CPU 'not-a-cpu'
16-
// X86-NEXT: note: valid target CPU values are: i386, i486, winchip-c6, winchip2, c3, i586, pentium, pentium-mmx, pentiumpro, i686, pentium2, pentium3, pentium3m, pentium-m, c3-2, yonah, pentium4, pentium4m, prescott, nocona, core2, penryn, bonnell, atom, silvermont, slm, goldmont, goldmont-plus, tremont, nehalem, corei7, westmere, sandybridge, corei7-avx, ivybridge, core-avx-i, haswell, core-avx2, broadwell, skylake, skylake-avx512, skx, cascadelake, cooperlake, cannonlake, icelake-client, rocketlake, icelake-server, tigerlake, sapphirerapids, alderlake, raptorlake, meteorlake, sierraforest, grandridge, graniterapids, knl, knm, lakemont, k6, k6-2, k6-3, athlon, athlon-tbird, athlon-xp, athlon-mp, athlon-4, k8, athlon64, athlon-fx, opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10, barcelona, btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1, znver2, znver3, x86-64, x86-64-v2, x86-64-v3, x86-64-v4, geode{{$}}
16+
// X86-NEXT: note: valid target CPU values are: i386, i486, winchip-c6, winchip2, c3, i586, pentium, pentium-mmx, pentiumpro, i686, pentium2, pentium3, pentium3m, pentium-m, c3-2, yonah, pentium4, pentium4m, prescott, nocona, core2, penryn, bonnell, atom, silvermont, slm, goldmont, goldmont-plus, tremont, nehalem, corei7, westmere, sandybridge, corei7-avx, ivybridge, core-avx-i, haswell, core-avx2, broadwell, skylake, skylake-avx512, skx, cascadelake, cooperlake, cannonlake, icelake-client, rocketlake, icelake-server, tigerlake, sapphirerapids, alderlake, raptorlake, meteorlake, sierraforest, grandridge, graniterapids, knl, knm, lakemont, k6, k6-2, k6-3, athlon, athlon-tbird, athlon-xp, athlon-mp, athlon-4, k8, athlon64, athlon-fx, opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10, barcelona, btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1, znver2, znver3, znver4, x86-64, x86-64-v2, x86-64-v3, x86-64-v4, geode{{$}}
1717

1818
// RUN: not %clang_cc1 -triple x86_64--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix X86_64
1919
// X86_64: error: unknown target CPU 'not-a-cpu'
20-
// X86_64-NEXT: note: valid target CPU values are: nocona, core2, penryn, bonnell, atom, silvermont, slm, goldmont, goldmont-plus, tremont, nehalem, corei7, westmere, sandybridge, corei7-avx, ivybridge, core-avx-i, haswell, core-avx2, broadwell, skylake, skylake-avx512, skx, cascadelake, cooperlake, cannonlake, icelake-client, rocketlake, icelake-server, tigerlake, sapphirerapids, alderlake, raptorlake, meteorlake, sierraforest, grandridge, graniterapids, knl, knm, k8, athlon64, athlon-fx, opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10, barcelona, btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1, znver2, znver3, x86-64, x86-64-v2, x86-64-v3, x86-64-v4{{$}}
20+
// X86_64-NEXT: note: valid target CPU values are: nocona, core2, penryn, bonnell, atom, silvermont, slm, goldmont, goldmont-plus, tremont, nehalem, corei7, westmere, sandybridge, corei7-avx, ivybridge, core-avx-i, haswell, core-avx2, broadwell, skylake, skylake-avx512, skx, cascadelake, cooperlake, cannonlake, icelake-client, rocketlake, icelake-server, tigerlake, sapphirerapids, alderlake, raptorlake, meteorlake, sierraforest, grandridge, graniterapids, knl, knm, k8, athlon64, athlon-fx, opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10, barcelona, btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1, znver2, znver3, znver4, x86-64, x86-64-v2, x86-64-v3, x86-64-v4{{$}}
2121

2222
// RUN: not %clang_cc1 -triple i386--- -tune-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix TUNE_X86
2323
// TUNE_X86: error: unknown target CPU 'not-a-cpu'
24-
// TUNE_X86-NEXT: note: valid target CPU values are: i386, i486, winchip-c6, winchip2, c3, i586, pentium, pentium-mmx, pentiumpro, i686, pentium2, pentium3, pentium3m, pentium-m, c3-2, yonah, pentium4, pentium4m, prescott, nocona, core2, penryn, bonnell, atom, silvermont, slm, goldmont, goldmont-plus, tremont, nehalem, corei7, westmere, sandybridge, corei7-avx, ivybridge, core-avx-i, haswell, core-avx2, broadwell, skylake, skylake-avx512, skx, cascadelake, cooperlake, cannonlake, icelake-client, rocketlake, icelake-server, tigerlake, sapphirerapids, alderlake, raptorlake, meteorlake, sierraforest, grandridge, graniterapids, knl, knm, lakemont, k6, k6-2, k6-3, athlon, athlon-tbird, athlon-xp, athlon-mp, athlon-4, k8, athlon64, athlon-fx, opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10, barcelona, btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1, znver2, znver3, x86-64, geode{{$}}
24+
// TUNE_X86-NEXT: note: valid target CPU values are: i386, i486, winchip-c6, winchip2, c3, i586, pentium, pentium-mmx, pentiumpro, i686, pentium2, pentium3, pentium3m, pentium-m, c3-2, yonah, pentium4, pentium4m, prescott, nocona, core2, penryn, bonnell, atom, silvermont, slm, goldmont, goldmont-plus, tremont, nehalem, corei7, westmere, sandybridge, corei7-avx, ivybridge, core-avx-i, haswell, core-avx2, broadwell, skylake, skylake-avx512, skx, cascadelake, cooperlake, cannonlake, icelake-client, rocketlake, icelake-server, tigerlake, sapphirerapids, alderlake, raptorlake, meteorlake, sierraforest, grandridge, graniterapids, knl, knm, lakemont, k6, k6-2, k6-3, athlon, athlon-tbird, athlon-xp, athlon-mp, athlon-4, k8, athlon64, athlon-fx, opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10, barcelona, btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1, znver2, znver3, znver4, x86-64, geode{{$}}
2525

2626
// RUN: not %clang_cc1 -triple x86_64--- -tune-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix TUNE_X86_64
2727
// TUNE_X86_64: error: unknown target CPU 'not-a-cpu'
28-
// TUNE_X86_64-NEXT: note: valid target CPU values are: i386, i486, winchip-c6, winchip2, c3, i586, pentium, pentium-mmx, pentiumpro, i686, pentium2, pentium3, pentium3m, pentium-m, c3-2, yonah, pentium4, pentium4m, prescott, nocona, core2, penryn, bonnell, atom, silvermont, slm, goldmont, goldmont-plus, tremont, nehalem, corei7, westmere, sandybridge, corei7-avx, ivybridge, core-avx-i, haswell, core-avx2, broadwell, skylake, skylake-avx512, skx, cascadelake, cooperlake, cannonlake, icelake-client, rocketlake, icelake-server, tigerlake, sapphirerapids, alderlake, raptorlake, meteorlake, sierraforest, grandridge, graniterapids, knl, knm, lakemont, k6, k6-2, k6-3, athlon, athlon-tbird, athlon-xp, athlon-mp, athlon-4, k8, athlon64, athlon-fx, opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10, barcelona, btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1, znver2, znver3, x86-64, geode{{$}}
28+
// TUNE_X86_64-NEXT: note: valid target CPU values are: i386, i486, winchip-c6, winchip2, c3, i586, pentium, pentium-mmx, pentiumpro, i686, pentium2, pentium3, pentium3m, pentium-m, c3-2, yonah, pentium4, pentium4m, prescott, nocona, core2, penryn, bonnell, atom, silvermont, slm, goldmont, goldmont-plus, tremont, nehalem, corei7, westmere, sandybridge, corei7-avx, ivybridge, core-avx-i, haswell, core-avx2, broadwell, skylake, skylake-avx512, skx, cascadelake, cooperlake, cannonlake, icelake-client, rocketlake, icelake-server, tigerlake, sapphirerapids, alderlake, raptorlake, meteorlake, sierraforest, grandridge, graniterapids, knl, knm, lakemont, k6, k6-2, k6-3, athlon, athlon-tbird, athlon-xp, athlon-mp, athlon-4, k8, athlon64, athlon-fx, opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10, barcelona, btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1, znver2, znver3, znver4, x86-64, geode{{$}}
2929

3030
// RUN: not %clang_cc1 -triple nvptx--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix NVPTX
3131
// NVPTX: error: unknown target CPU 'not-a-cpu'

clang/test/Preprocessor/predefined-arch-macros.c

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3832,6 +3832,138 @@
38323832
// CHECK_ZNVER3_M64: #define __znver3 1
38333833
// CHECK_ZNVER3_M64: #define __znver3__ 1
38343834

3835+
// RUN: %clang -march=znver4 -m32 -E -dM %s -o - 2>&1 \
3836+
// RUN: -target i386-unknown-linux \
3837+
// RUN: | FileCheck -match-full-lines %s -check-prefix=CHECK_ZNVER4_M32
3838+
// CHECK_ZNVER4_M32-NOT: #define __3dNOW_A__ 1
3839+
// CHECK_ZNVER4_M32-NOT: #define __3dNOW__ 1
3840+
// CHECK_ZNVER4_M32: #define __ADX__ 1
3841+
// CHECK_ZNVER4_M32: #define __AES__ 1
3842+
// CHECK_ZNVER4_M32: #define __AVX2__ 1
3843+
// CHECK_ZNVER4_M32: #define __AVX512BF16__ 1
3844+
// CHECK_ZNVER4_M32: #define __AVX512BITALG__ 1
3845+
// CHECK_ZNVER4_M32: #define __AVX512BW__ 1
3846+
// CHECK_ZNVER4_M32: #define __AVX512CD__ 1
3847+
// CHECK_ZNVER4_M32: #define __AVX512DQ__ 1
3848+
// CHECK_ZNVER4_M32: #define __AVX512F__ 1
3849+
// CHECK_ZNVER4_M32: #define __AVX512IFMA__ 1
3850+
// CHECK_ZNVER4_M32: #define __AVX512VBMI2__ 1
3851+
// CHECK_ZNVER4_M32: #define __AVX512VBMI__ 1
3852+
// CHECK_ZNVER4_M32: #define __AVX512VL__ 1
3853+
// CHECK_ZNVER4_M32: #define __AVX512VNNI__ 1
3854+
// CHECK_ZNVER4_M32: #define __AVX512VPOPCNTDQ__ 1
3855+
// CHECK_ZNVER4_M32: #define __AVX__ 1
3856+
// CHECK_ZNVER4_M32: #define __BMI2__ 1
3857+
// CHECK_ZNVER4_M32: #define __BMI__ 1
3858+
// CHECK_ZNVER4_M32: #define __CLFLUSHOPT__ 1
3859+
// CHECK_ZNVER4_M32: #define __CLWB__ 1
3860+
// CHECK_ZNVER4_M32: #define __CLZERO__ 1
3861+
// CHECK_ZNVER4_M32: #define __F16C__ 1
3862+
// CHECK_ZNVER4_M32-NOT: #define __FMA4__ 1
3863+
// CHECK_ZNVER4_M32: #define __FMA__ 1
3864+
// CHECK_ZNVER4_M32: #define __FSGSBASE__ 1
3865+
// CHECK_ZNVER4_M32: #define __GFNI__ 1
3866+
// CHECK_ZNVER4_M32: #define __LZCNT__ 1
3867+
// CHECK_ZNVER4_M32: #define __MMX__ 1
3868+
// CHECK_ZNVER4_M32: #define __PCLMUL__ 1
3869+
// CHECK_ZNVER4_M32: #define __PKU__ 1
3870+
// CHECK_ZNVER4_M32: #define __POPCNT__ 1
3871+
// CHECK_ZNVER4_M32: #define __PRFCHW__ 1
3872+
// CHECK_ZNVER4_M32: #define __RDPID__ 1
3873+
// CHECK_ZNVER4_M32: #define __RDPRU__ 1
3874+
// CHECK_ZNVER4_M32: #define __RDRND__ 1
3875+
// CHECK_ZNVER4_M32: #define __RDSEED__ 1
3876+
// CHECK_ZNVER4_M32: #define __SHA__ 1
3877+
// CHECK_ZNVER4_M32: #define __SSE2_MATH__ 1
3878+
// CHECK_ZNVER4_M32: #define __SSE2__ 1
3879+
// CHECK_ZNVER4_M32: #define __SSE3__ 1
3880+
// CHECK_ZNVER4_M32: #define __SSE4A__ 1
3881+
// CHECK_ZNVER4_M32: #define __SSE4_1__ 1
3882+
// CHECK_ZNVER4_M32: #define __SSE4_2__ 1
3883+
// CHECK_ZNVER4_M32: #define __SSE_MATH__ 1
3884+
// CHECK_ZNVER4_M32: #define __SSE__ 1
3885+
// CHECK_ZNVER4_M32: #define __SSSE3__ 1
3886+
// CHECK_ZNVER4_M32-NOT: #define __TBM__ 1
3887+
// CHECK_ZNVER4_M32: #define __WBNOINVD__ 1
3888+
// CHECK_ZNVER4_M32-NOT: #define __XOP__ 1
3889+
// CHECK_ZNVER4_M32: #define __XSAVEC__ 1
3890+
// CHECK_ZNVER4_M32: #define __XSAVEOPT__ 1
3891+
// CHECK_ZNVER4_M32: #define __XSAVES__ 1
3892+
// CHECK_ZNVER4_M32: #define __XSAVE__ 1
3893+
// CHECK_ZNVER4_M32: #define __i386 1
3894+
// CHECK_ZNVER4_M32: #define __i386__ 1
3895+
// CHECK_ZNVER4_M32: #define __tune_znver4__ 1
3896+
// CHECK_ZNVER4_M32: #define __znver4 1
3897+
// CHECK_ZNVER4_M32: #define __znver4__ 1
3898+
3899+
// RUN: %clang -march=znver4 -m64 -E -dM %s -o - 2>&1 \
3900+
// RUN: -target i386-unknown-linux \
3901+
// RUN: | FileCheck -match-full-lines %s -check-prefix=CHECK_ZNVER4_M64
3902+
// CHECK_ZNVER4_M64-NOT: #define __3dNOW_A__ 1
3903+
// CHECK_ZNVER4_M64-NOT: #define __3dNOW__ 1
3904+
// CHECK_ZNVER4_M64: #define __ADX__ 1
3905+
// CHECK_ZNVER4_M64: #define __AES__ 1
3906+
// CHECK_ZNVER4_M64: #define __AVX2__ 1
3907+
// CHECK_ZNVER4_M64: #define __AVX512BF16__ 1
3908+
// CHECK_ZNVER4_M64: #define __AVX512BITALG__ 1
3909+
// CHECK_ZNVER4_M64: #define __AVX512BW__ 1
3910+
// CHECK_ZNVER4_M64: #define __AVX512CD__ 1
3911+
// CHECK_ZNVER4_M64: #define __AVX512DQ__ 1
3912+
// CHECK_ZNVER4_M64: #define __AVX512F__ 1
3913+
// CHECK_ZNVER4_M64: #define __AVX512IFMA__ 1
3914+
// CHECK_ZNVER4_M64: #define __AVX512VBMI2__ 1
3915+
// CHECK_ZNVER4_M64: #define __AVX512VBMI__ 1
3916+
// CHECK_ZNVER4_M64: #define __AVX512VL__ 1
3917+
// CHECK_ZNVER4_M64: #define __AVX512VNNI__ 1
3918+
// CHECK_ZNVER4_M64: #define __AVX512VPOPCNTDQ__ 1
3919+
// CHECK_ZNVER4_M64: #define __AVX__ 1
3920+
// CHECK_ZNVER4_M64: #define __BMI2__ 1
3921+
// CHECK_ZNVER4_M64: #define __BMI__ 1
3922+
// CHECK_ZNVER4_M64: #define __CLFLUSHOPT__ 1
3923+
// CHECK_ZNVER4_M64: #define __CLWB__ 1
3924+
// CHECK_ZNVER4_M64: #define __CLZERO__ 1
3925+
// CHECK_ZNVER4_M64: #define __F16C__ 1
3926+
// CHECK_ZNVER4_M64-NOT: #define __FMA4__ 1
3927+
// CHECK_ZNVER4_M64: #define __FMA__ 1
3928+
// CHECK_ZNVER4_M64: #define __FSGSBASE__ 1
3929+
// CHECK_ZNVER4_M64: #define __GFNI__ 1
3930+
// CHECK_ZNVER4_M64: #define __LZCNT__ 1
3931+
// CHECK_ZNVER4_M64: #define __MMX__ 1
3932+
// CHECK_ZNVER4_M64: #define __PCLMUL__ 1
3933+
// CHECK_ZNVER4_M64: #define __PKU__ 1
3934+
// CHECK_ZNVER4_M64: #define __POPCNT__ 1
3935+
// CHECK_ZNVER4_M64: #define __PRFCHW__ 1
3936+
// CHECK_ZNVER4_M64: #define __RDPID__ 1
3937+
// CHECK_ZNVER4_M64: #define __RDPRU__ 1
3938+
// CHECK_ZNVER4_M64: #define __RDRND__ 1
3939+
// CHECK_ZNVER4_M64: #define __RDSEED__ 1
3940+
// CHECK_ZNVER4_M64: #define __SHA__ 1
3941+
// CHECK_ZNVER4_M64: #define __SSE2_MATH__ 1
3942+
// CHECK_ZNVER4_M64: #define __SSE2__ 1
3943+
// CHECK_ZNVER4_M64: #define __SSE3__ 1
3944+
// CHECK_ZNVER4_M64: #define __SSE4A__ 1
3945+
// CHECK_ZNVER4_M64: #define __SSE4_1__ 1
3946+
// CHECK_ZNVER4_M64: #define __SSE4_2__ 1
3947+
// CHECK_ZNVER4_M64: #define __SSE_MATH__ 1
3948+
// CHECK_ZNVER4_M64: #define __SSE__ 1
3949+
// CHECK_ZNVER4_M64: #define __SSSE3__ 1
3950+
// CHECK_ZNVER4_M64-NOT: #define __TBM__ 1
3951+
// CHECK_ZNVER4_M64: #define __VAES__ 1
3952+
// CHECK_ZNVER4_M64: #define __VPCLMULQDQ__ 1
3953+
// CHECK_ZNVER4_M64: #define __WBNOINVD__ 1
3954+
// CHECK_ZNVER4_M64-NOT: #define __XOP__ 1
3955+
// CHECK_ZNVER4_M64: #define __XSAVEC__ 1
3956+
// CHECK_ZNVER4_M64: #define __XSAVEOPT__ 1
3957+
// CHECK_ZNVER4_M64: #define __XSAVES__ 1
3958+
// CHECK_ZNVER4_M64: #define __XSAVE__ 1
3959+
// CHECK_ZNVER4_M64: #define __amd64 1
3960+
// CHECK_ZNVER4_M64: #define __amd64__ 1
3961+
// CHECK_ZNVER4_M64: #define __tune_znver4__ 1
3962+
// CHECK_ZNVER4_M64: #define __x86_64 1
3963+
// CHECK_ZNVER4_M64: #define __x86_64__ 1
3964+
// CHECK_ZNVER4_M64: #define __znver4 1
3965+
// CHECK_ZNVER4_M64: #define __znver4__ 1
3966+
38353967
// End X86/GCC/Linux tests ------------------
38363968

38373969
// Begin PPC/GCC/Linux tests ----------------

compiler-rt/lib/builtins/cpu_model.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,14 @@ getAMDProcessorTypeAndSubtype(unsigned Family, unsigned Model,
627627
*Subtype = AMDFAM19H_ZNVER3;
628628
break;
629629
}
630+
if ((Model >= 0x10 && Model <= 0x1f) ||
631+
(Model >= 0x60 && Model <= 0x74) ||
632+
(Model >= 0x78 && Model <= 0x7b) ||
633+
(Model >= 0xA0 && Model <= 0xAf)) {
634+
CPU = "znver4";
635+
*Subtype = AMDFAM19H_ZNVER4;
636+
break; // "znver4"
637+
}
630638
break;
631639
default:
632640
break; // Unknown AMD CPU.

llvm/include/llvm/Support/X86TargetParser.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ enum CPUKind {
129129
CK_ZNVER1,
130130
CK_ZNVER2,
131131
CK_ZNVER3,
132+
CK_ZNVER4,
132133
CK_x86_64,
133134
CK_x86_64_v2,
134135
CK_x86_64_v3,

llvm/lib/Support/Host.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1105,7 +1105,15 @@ getAMDProcessorTypeAndSubtype(unsigned Family, unsigned Model,
11051105
*Subtype = X86::AMDFAM19H_ZNVER3;
11061106
break;
11071107
}
1108-
break;
1108+
if ((Model >= 0x10 && Model <= 0x1f) ||
1109+
(Model >= 0x60 && Model <= 0x74) ||
1110+
(Model >= 0x78 && Model <= 0x7b) ||
1111+
(Model >= 0xA0 && Model <= 0xAf)) {
1112+
CPU = "znver4";
1113+
*Subtype = X86::AMDFAM19H_ZNVER4;
1114+
break; // "znver4"
1115+
}
1116+
break; // family 19h
11091117
default:
11101118
break; // Unknown AMD CPU.
11111119
}

llvm/lib/Support/X86TargetParser.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,12 @@ constexpr FeatureBitset FeaturesZNVER2 = FeaturesZNVER1 | FeatureCLWB |
298298
static constexpr FeatureBitset FeaturesZNVER3 = FeaturesZNVER2 |
299299
FeatureINVPCID | FeaturePKU |
300300
FeatureVAES | FeatureVPCLMULQDQ;
301+
static constexpr FeatureBitset FeaturesZNVER4 =
302+
FeaturesZNVER3 | FeatureAVX512F | FeatureAVX512CD | FeatureAVX512DQ |
303+
FeatureAVX512BW | FeatureAVX512VL | FeatureAVX512IFMA | FeatureAVX512VBMI |
304+
FeatureAVX512VBMI2 | FeatureAVX512VNNI | FeatureAVX512BITALG |
305+
FeatureAVX512VPOPCNTDQ | FeatureAVX512BF16 | FeatureGFNI |
306+
FeatureSHSTK;
301307

302308
constexpr ProcInfo Processors[] = {
303309
// Empty processor. Include X87 and CMPXCHG8 for backwards compatibility.
@@ -425,6 +431,7 @@ constexpr ProcInfo Processors[] = {
425431
{ {"znver1"}, CK_ZNVER1, FEATURE_AVX2, FeaturesZNVER1 },
426432
{ {"znver2"}, CK_ZNVER2, FEATURE_AVX2, FeaturesZNVER2 },
427433
{ {"znver3"}, CK_ZNVER3, FEATURE_AVX2, FeaturesZNVER3 },
434+
{ {"znver4"}, CK_ZNVER4, FEATURE_AVX512VBMI2, FeaturesZNVER4 },
428435
// Generic 64-bit processor.
429436
{ {"x86-64"}, CK_x86_64, ~0U, FeaturesX86_64 },
430437
{ {"x86-64-v2"}, CK_x86_64_v2, ~0U, FeaturesX86_64_V2 },

0 commit comments

Comments
 (0)