Skip to content

Commit

Permalink
[X86] AMD Zen 5 Initial enablement
Browse files Browse the repository at this point in the history
  • Loading branch information
ganeshgit authored and tru committed Sep 16, 2024
1 parent 82e85b6 commit 149a150
Show file tree
Hide file tree
Showing 30 changed files with 238 additions and 4 deletions.
4 changes: 4 additions & 0 deletions clang/lib/Basic/Targets/X86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,9 @@ void X86TargetInfo::getTargetDefines(const LangOptions &Opts,
case CK_ZNVER4:
defineCPUMacros(Builder, "znver4");
break;
case CK_ZNVER5:
defineCPUMacros(Builder, "znver5");
break;
case CK_Geode:
defineCPUMacros(Builder, "geode");
break;
Expand Down Expand Up @@ -1613,6 +1616,7 @@ std::optional<unsigned> X86TargetInfo::getCPUCacheLineSize() const {
case CK_ZNVER2:
case CK_ZNVER3:
case CK_ZNVER4:
case CK_ZNVER5:
// Deprecated
case CK_x86_64:
case CK_x86_64_v2:
Expand Down
1 change: 1 addition & 0 deletions clang/test/CodeGen/target-builtin-noerror.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,4 +205,5 @@ void verifycpustrings(void) {
(void)__builtin_cpu_is("znver2");
(void)__builtin_cpu_is("znver3");
(void)__builtin_cpu_is("znver4");
(void)__builtin_cpu_is("znver5");
}
4 changes: 4 additions & 0 deletions clang/test/Driver/x86-march.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,10 @@
// RUN: %clang -target x86_64-unknown-unknown -c -### %s -march=znver4 2>&1 \
// RUN: | FileCheck %s -check-prefix=znver4
// znver4: "-target-cpu" "znver4"
//
// RUN: %clang -target x86_64-unknown-unknown -c -### %s -march=znver5 2>&1 \
// RUN: | FileCheck %s -check-prefix=znver5
// znver5: "-target-cpu" "znver5"

// RUN: %clang -target x86_64 -c -### %s -march=x86-64 2>&1 | FileCheck %s --check-prefix=x86-64
// x86-64: "-target-cpu" "x86-64"
Expand Down
1 change: 1 addition & 0 deletions clang/test/Frontend/x86-target-cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu znver2 -verify %s
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu znver3 -verify %s
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu znver4 -verify %s
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu znver5 -verify %s
//
// expected-no-diagnostics
8 changes: 4 additions & 4 deletions clang/test/Misc/target-invalid-cpu-note.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@

// RUN: not %clang_cc1 -triple i386--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix X86
// X86: error: unknown target CPU 'not-a-cpu'
// 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, arrowlake, arrowlake-s, lunarlake, gracemont, pantherlake, sierraforest, grandridge, graniterapids, graniterapids-d, emeraldrapids, clearwaterforest, 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{{$}}
// 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, arrowlake, arrowlake-s, lunarlake, gracemont, pantherlake, sierraforest, grandridge, graniterapids, graniterapids-d, emeraldrapids, clearwaterforest, 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, znver5, x86-64, x86-64-v2, x86-64-v3, x86-64-v4, geode{{$}}

// RUN: not %clang_cc1 -triple x86_64--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix X86_64
// X86_64: error: unknown target CPU 'not-a-cpu'
// 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, arrowlake, arrowlake-s, lunarlake, gracemont, pantherlake, sierraforest, grandridge, graniterapids, graniterapids-d, emeraldrapids, clearwaterforest, 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{{$}}
// 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, arrowlake, arrowlake-s, lunarlake, gracemont, pantherlake, sierraforest, grandridge, graniterapids, graniterapids-d, emeraldrapids, clearwaterforest, 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, znver5, x86-64, x86-64-v2, x86-64-v3, x86-64-v4{{$}}

// RUN: not %clang_cc1 -triple i386--- -tune-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix TUNE_X86
// TUNE_X86: error: unknown target CPU 'not-a-cpu'
// 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, arrowlake, arrowlake-s, lunarlake, gracemont, pantherlake, sierraforest, grandridge, graniterapids, graniterapids-d, emeraldrapids, clearwaterforest, 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{{$}}
// 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, arrowlake, arrowlake-s, lunarlake, gracemont, pantherlake, sierraforest, grandridge, graniterapids, graniterapids-d, emeraldrapids, clearwaterforest, 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, znver5, x86-64, geode{{$}}

// RUN: not %clang_cc1 -triple x86_64--- -tune-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix TUNE_X86_64
// TUNE_X86_64: error: unknown target CPU 'not-a-cpu'
// 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, arrowlake, arrowlake-s, lunarlake, gracemont, pantherlake, sierraforest, grandridge, graniterapids, graniterapids-d, emeraldrapids, clearwaterforest, 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{{$}}
// 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, arrowlake, arrowlake-s, lunarlake, gracemont, pantherlake, sierraforest, grandridge, graniterapids, graniterapids-d, emeraldrapids, clearwaterforest, 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, znver5, x86-64, geode{{$}}

// RUN: not %clang_cc1 -triple nvptx--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix NVPTX
// NVPTX: error: unknown target CPU 'not-a-cpu'
Expand Down
142 changes: 142 additions & 0 deletions clang/test/Preprocessor/predefined-arch-macros.c
Original file line number Diff line number Diff line change
Expand Up @@ -3923,6 +3923,148 @@
// CHECK_ZNVER4_M64: #define __znver4 1
// CHECK_ZNVER4_M64: #define __znver4__ 1

// RUN: %clang -march=znver5 -m32 -E -dM %s -o - 2>&1 \
// RUN: -target i386-unknown-linux \
// RUN: | FileCheck -match-full-lines %s -check-prefix=CHECK_ZNVER5_M32
// CHECK_ZNVER5_M32-NOT: #define __3dNOW_A__ 1
// CHECK_ZNVER5_M32-NOT: #define __3dNOW__ 1
// CHECK_ZNVER5_M32: #define __ADX__ 1
// CHECK_ZNVER5_M32: #define __AES__ 1
// CHECK_ZNVER5_M32: #define __AVX2__ 1
// CHECK_ZNVER5_M32: #define __AVX512BF16__ 1
// CHECK_ZNVER5_M32: #define __AVX512BITALG__ 1
// CHECK_ZNVER5_M32: #define __AVX512BW__ 1
// CHECK_ZNVER5_M32: #define __AVX512CD__ 1
// CHECK_ZNVER5_M32: #define __AVX512DQ__ 1
// CHECK_ZNVER5_M32: #define __AVX512F__ 1
// CHECK_ZNVER5_M32: #define __AVX512IFMA__ 1
// CHECK_ZNVER5_M32: #define __AVX512VBMI2__ 1
// CHECK_ZNVER5_M32: #define __AVX512VBMI__ 1
// CHECK_ZNVER5_M32: #define __AVX512VL__ 1
// CHECK_ZNVER5_M32: #define __AVX512VNNI__ 1
// CHECK_ZNVER5_M32: #define __AVX512VP2INTERSECT__ 1
// CHECK_ZNVER5_M32: #define __AVX512VPOPCNTDQ__ 1
// CHECK_ZNVER5_M32: #define __AVXVNNI__ 1
// CHECK_ZNVER5_M32: #define __AVX__ 1
// CHECK_ZNVER5_M32: #define __BMI2__ 1
// CHECK_ZNVER5_M32: #define __BMI__ 1
// CHECK_ZNVER5_M32: #define __CLFLUSHOPT__ 1
// CHECK_ZNVER5_M32: #define __CLWB__ 1
// CHECK_ZNVER5_M32: #define __CLZERO__ 1
// CHECK_ZNVER5_M32: #define __F16C__ 1
// CHECK_ZNVER5_M32-NOT: #define __FMA4__ 1
// CHECK_ZNVER5_M32: #define __FMA__ 1
// CHECK_ZNVER5_M32: #define __FSGSBASE__ 1
// CHECK_ZNVER5_M32: #define __GFNI__ 1
// CHECK_ZNVER5_M32: #define __LZCNT__ 1
// CHECK_ZNVER5_M32: #define __MMX__ 1
// CHECK_ZNVER5_M32: #define __MOVDIR64B__ 1
// CHECK_ZNVER5_M32: #define __MOVDIRI__ 1
// CHECK_ZNVER5_M32: #define __PCLMUL__ 1
// CHECK_ZNVER5_M32: #define __PKU__ 1
// CHECK_ZNVER5_M32: #define __POPCNT__ 1
// CHECK_ZNVER5_M32: #define __PREFETCHI__ 1
// CHECK_ZNVER5_M32: #define __PRFCHW__ 1
// CHECK_ZNVER5_M32: #define __RDPID__ 1
// CHECK_ZNVER5_M32: #define __RDPRU__ 1
// CHECK_ZNVER5_M32: #define __RDRND__ 1
// CHECK_ZNVER5_M32: #define __RDSEED__ 1
// CHECK_ZNVER5_M32: #define __SHA__ 1
// CHECK_ZNVER5_M32: #define __SSE2_MATH__ 1
// CHECK_ZNVER5_M32: #define __SSE2__ 1
// CHECK_ZNVER5_M32: #define __SSE3__ 1
// CHECK_ZNVER5_M32: #define __SSE4A__ 1
// CHECK_ZNVER5_M32: #define __SSE4_1__ 1
// CHECK_ZNVER5_M32: #define __SSE4_2__ 1
// CHECK_ZNVER5_M32: #define __SSE_MATH__ 1
// CHECK_ZNVER5_M32: #define __SSE__ 1
// CHECK_ZNVER5_M32: #define __SSSE3__ 1
// CHECK_ZNVER5_M32-NOT: #define __TBM__ 1
// CHECK_ZNVER5_M32: #define __WBNOINVD__ 1
// CHECK_ZNVER5_M32-NOT: #define __XOP__ 1
// CHECK_ZNVER5_M32: #define __XSAVEC__ 1
// CHECK_ZNVER5_M32: #define __XSAVEOPT__ 1
// CHECK_ZNVER5_M32: #define __XSAVES__ 1
// CHECK_ZNVER5_M32: #define __XSAVE__ 1
// CHECK_ZNVER5_M32: #define __i386 1
// CHECK_ZNVER5_M32: #define __i386__ 1
// CHECK_ZNVER5_M32: #define __tune_znver5__ 1
// CHECK_ZNVER5_M32: #define __znver5 1
// CHECK_ZNVER5_M32: #define __znver5__ 1

// RUN: %clang -march=znver5 -m64 -E -dM %s -o - 2>&1 \
// RUN: -target i386-unknown-linux \
// RUN: | FileCheck -match-full-lines %s -check-prefix=CHECK_ZNVER5_M64
// CHECK_ZNVER5_M64-NOT: #define __3dNOW_A__ 1
// CHECK_ZNVER5_M64-NOT: #define __3dNOW__ 1
// CHECK_ZNVER5_M64: #define __ADX__ 1
// CHECK_ZNVER5_M64: #define __AES__ 1
// CHECK_ZNVER5_M64: #define __AVX2__ 1
// CHECK_ZNVER5_M64: #define __AVX512BF16__ 1
// CHECK_ZNVER5_M64: #define __AVX512BITALG__ 1
// CHECK_ZNVER5_M64: #define __AVX512BW__ 1
// CHECK_ZNVER5_M64: #define __AVX512CD__ 1
// CHECK_ZNVER5_M64: #define __AVX512DQ__ 1
// CHECK_ZNVER5_M64: #define __AVX512F__ 1
// CHECK_ZNVER5_M64: #define __AVX512IFMA__ 1
// CHECK_ZNVER5_M64: #define __AVX512VBMI2__ 1
// CHECK_ZNVER5_M64: #define __AVX512VBMI__ 1
// CHECK_ZNVER5_M64: #define __AVX512VL__ 1
// CHECK_ZNVER5_M64: #define __AVX512VNNI__ 1
// CHECK_ZNVER5_M64: #define __AVX512VP2INTERSECT__ 1
// CHECK_ZNVER5_M64: #define __AVX512VPOPCNTDQ__ 1
// CHECK_ZNVER5_M64: #define __AVXVNNI__ 1
// CHECK_ZNVER5_M64: #define __AVX__ 1
// CHECK_ZNVER5_M64: #define __BMI2__ 1
// CHECK_ZNVER5_M64: #define __BMI__ 1
// CHECK_ZNVER5_M64: #define __CLFLUSHOPT__ 1
// CHECK_ZNVER5_M64: #define __CLWB__ 1
// CHECK_ZNVER5_M64: #define __CLZERO__ 1
// CHECK_ZNVER5_M64: #define __F16C__ 1
// CHECK_ZNVER5_M64-NOT: #define __FMA4__ 1
// CHECK_ZNVER5_M64: #define __FMA__ 1
// CHECK_ZNVER5_M64: #define __FSGSBASE__ 1
// CHECK_ZNVER5_M64: #define __GFNI__ 1
// CHECK_ZNVER5_M64: #define __LZCNT__ 1
// CHECK_ZNVER5_M64: #define __MMX__ 1
// CHECK_ZNVER5_M64: #define __MOVDIR64B__ 1
// CHECK_ZNVER5_M64: #define __MOVDIRI__ 1
// CHECK_ZNVER5_M64: #define __PCLMUL__ 1
// CHECK_ZNVER5_M64: #define __PKU__ 1
// CHECK_ZNVER5_M64: #define __POPCNT__ 1
// CHECK_ZNVER5_M64: #define __PREFETCHI__ 1
// CHECK_ZNVER5_M64: #define __PRFCHW__ 1
// CHECK_ZNVER5_M64: #define __RDPID__ 1
// CHECK_ZNVER5_M64: #define __RDPRU__ 1
// CHECK_ZNVER5_M64: #define __RDRND__ 1
// CHECK_ZNVER5_M64: #define __RDSEED__ 1
// CHECK_ZNVER5_M64: #define __SHA__ 1
// CHECK_ZNVER5_M64: #define __SSE2_MATH__ 1
// CHECK_ZNVER5_M64: #define __SSE2__ 1
// CHECK_ZNVER5_M64: #define __SSE3__ 1
// CHECK_ZNVER5_M64: #define __SSE4A__ 1
// CHECK_ZNVER5_M64: #define __SSE4_1__ 1
// CHECK_ZNVER5_M64: #define __SSE4_2__ 1
// CHECK_ZNVER5_M64: #define __SSE_MATH__ 1
// CHECK_ZNVER5_M64: #define __SSE__ 1
// CHECK_ZNVER5_M64: #define __SSSE3__ 1
// CHECK_ZNVER5_M64-NOT: #define __TBM__ 1
// CHECK_ZNVER5_M64: #define __VAES__ 1
// CHECK_ZNVER5_M64: #define __VPCLMULQDQ__ 1
// CHECK_ZNVER5_M64: #define __WBNOINVD__ 1
// CHECK_ZNVER5_M64-NOT: #define __XOP__ 1
// CHECK_ZNVER5_M64: #define __XSAVEC__ 1
// CHECK_ZNVER5_M64: #define __XSAVEOPT__ 1
// CHECK_ZNVER5_M64: #define __XSAVES__ 1
// CHECK_ZNVER5_M64: #define __XSAVE__ 1
// CHECK_ZNVER5_M64: #define __amd64 1
// CHECK_ZNVER5_M64: #define __amd64__ 1
// CHECK_ZNVER5_M64: #define __tune_znver5__ 1
// CHECK_ZNVER5_M64: #define __x86_64 1
// CHECK_ZNVER5_M64: #define __x86_64__ 1
// CHECK_ZNVER5_M64: #define __znver5 1
// CHECK_ZNVER5_M64: #define __znver5__ 1

// End X86/GCC/Linux tests ------------------

// Begin PPC/GCC/Linux tests ----------------
Expand Down
20 changes: 20 additions & 0 deletions compiler-rt/lib/builtins/cpu_model/x86.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ enum ProcessorTypes {
INTEL_SIERRAFOREST,
INTEL_GRANDRIDGE,
INTEL_CLEARWATERFOREST,
AMDFAM1AH,
CPU_TYPE_MAX
};

Expand Down Expand Up @@ -97,6 +98,7 @@ enum ProcessorSubtypes {
INTEL_COREI7_ARROWLAKE,
INTEL_COREI7_ARROWLAKE_S,
INTEL_COREI7_PANTHERLAKE,
AMDFAM1AH_ZNVER5,
CPU_SUBTYPE_MAX
};

Expand Down Expand Up @@ -803,6 +805,24 @@ static const char *getAMDProcessorTypeAndSubtype(unsigned Family,
break; // "znver4"
}
break; // family 19h
case 26:
CPU = "znver5";
*Type = AMDFAM1AH;
if (Model <= 0x77) {
// Models 00h-0Fh (Breithorn).
// Models 10h-1Fh (Breithorn-Dense).
// Models 20h-2Fh (Strix 1).
// Models 30h-37h (Strix 2).
// Models 38h-3Fh (Strix 3).
// Models 40h-4Fh (Granite Ridge).
// Models 50h-5Fh (Weisshorn).
// Models 60h-6Fh (Krackan1).
// Models 70h-77h (Sarlak).
CPU = "znver5";
*Subtype = AMDFAM1AH_ZNVER5;
break; // "znver5"
}
break;
default:
break; // Unknown AMD CPU.
}
Expand Down
3 changes: 3 additions & 0 deletions llvm/include/llvm/TargetParser/X86TargetParser.def
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,13 @@ X86_CPU_TYPE(ZHAOXIN_FAM7H, "zhaoxin_fam7h")
X86_CPU_TYPE(INTEL_SIERRAFOREST, "sierraforest")
X86_CPU_TYPE(INTEL_GRANDRIDGE, "grandridge")
X86_CPU_TYPE(INTEL_CLEARWATERFOREST, "clearwaterforest")
X86_CPU_TYPE(AMDFAM1AH, "amdfam1ah")

// Alternate names supported by __builtin_cpu_is and target multiversioning.
X86_CPU_TYPE_ALIAS(INTEL_BONNELL, "atom")
X86_CPU_TYPE_ALIAS(AMDFAM10H, "amdfam10")
X86_CPU_TYPE_ALIAS(AMDFAM15H, "amdfam15")
X86_CPU_TYPE_ALIAS(AMDFAM1AH, "amdfam1a")
X86_CPU_TYPE_ALIAS(INTEL_SILVERMONT, "slm")

#undef X86_CPU_TYPE_ALIAS
Expand Down Expand Up @@ -104,6 +106,7 @@ X86_CPU_SUBTYPE(INTEL_COREI7_GRANITERAPIDS_D,"graniterapids-d")
X86_CPU_SUBTYPE(INTEL_COREI7_ARROWLAKE, "arrowlake")
X86_CPU_SUBTYPE(INTEL_COREI7_ARROWLAKE_S, "arrowlake-s")
X86_CPU_SUBTYPE(INTEL_COREI7_PANTHERLAKE, "pantherlake")
X86_CPU_SUBTYPE(AMDFAM1AH_ZNVER5, "znver5")

// Alternate names supported by __builtin_cpu_is and target multiversioning.
X86_CPU_SUBTYPE_ALIAS(INTEL_COREI7_ALDERLAKE, "raptorlake")
Expand Down
1 change: 1 addition & 0 deletions llvm/include/llvm/TargetParser/X86TargetParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ enum CPUKind {
CK_x86_64_v3,
CK_x86_64_v4,
CK_Geode,
CK_ZNVER5,
};

/// Parse \p CPU string into a CPUKind. Will only accept 64-bit capable CPUs if
Expand Down
Loading

0 comments on commit 149a150

Please sign in to comment.