Skip to content

Commit 1fe6be8

Browse files
authored
[X86] Support APXF to enable __builtin_cpu_supports. (llvm#80636)
For referring, APX's spec: https://cdrdv2.intel.com/v1/dl/getContent/784266 APX's index in libgcc: https://github.com/gcc-mirror/gcc/blob/master/gcc/common/config/i386/i386-cpuinfo.h#L267
1 parent d7a28f7 commit 1fe6be8

File tree

5 files changed

+14
-2
lines changed

5 files changed

+14
-2
lines changed

clang/lib/Headers/cpuid.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@
219219
#define bit_PREFETCHI 0x00004000
220220
#define bit_USERMSR 0x00008000
221221
#define bit_AVX10 0x00080000
222+
#define bit_APXF 0x00200000
222223

223224
/* Features in %eax for leaf 13 sub-leaf 1 */
224225
#define bit_XSAVEOPT 0x00000001

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ void verifyfeaturestrings(void) {
141141
(void)__builtin_cpu_supports("sm3");
142142
(void)__builtin_cpu_supports("sha512");
143143
(void)__builtin_cpu_supports("sm4");
144+
(void)__builtin_cpu_supports("apxf");
144145
(void)__builtin_cpu_supports("usermsr");
145146
(void)__builtin_cpu_supports("avx10.1-256");
146147
(void)__builtin_cpu_supports("avx10.1-512");

compiler-rt/lib/builtins/cpu_model/x86.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,8 @@ enum ProcessorFeatures {
217217
FEATURE_SM3,
218218
FEATURE_SHA512,
219219
FEATURE_SM4,
220-
// FEATURE_APXF,
221-
FEATURE_USERMSR = 112,
220+
FEATURE_APXF,
221+
FEATURE_USERMSR,
222222
FEATURE_AVX10_1_256,
223223
FEATURE_AVX10_1_512,
224224
CPU_FEATURE_MAX
@@ -983,6 +983,8 @@ static void getAvailableFeatures(unsigned ECX, unsigned EDX, unsigned MaxLeaf,
983983
setFeature(FEATURE_USERMSR);
984984
if (HasLeaf7Subleaf1 && ((EDX >> 19) & 1))
985985
setFeature(FEATURE_AVX10_1_256);
986+
if (HasLeaf7Subleaf1 && ((EDX >> 21) & 1))
987+
setFeature(FEATURE_APXF);
986988

987989
unsigned MaxLevel;
988990
getX86CpuIDAndInfo(0, &MaxLevel, &EBX, &ECX, &EDX);

llvm/include/llvm/TargetParser/X86TargetParser.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ X86_MICROARCH_LEVEL(X86_64_BASELINE,"x86-64", 95)
265265
X86_MICROARCH_LEVEL(X86_64_V2, "x86-64-v2", 96)
266266
X86_MICROARCH_LEVEL(X86_64_V3, "x86-64-v3", 97)
267267
X86_MICROARCH_LEVEL(X86_64_V4, "x86-64-v4", 98)
268+
X86_MICROARCH_LEVEL(APXF, "apxf", 111)
268269
#undef X86_FEATURE_COMPAT
269270
#undef X86_FEATURE
270271
#undef X86_MICROARCH_LEVEL

llvm/lib/TargetParser/Host.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1846,6 +1846,13 @@ bool sys::getHostCPUFeatures(StringMap<bool> &Features) {
18461846
Features["prefetchi"] = HasLeaf7Subleaf1 && ((EDX >> 14) & 1);
18471847
Features["usermsr"] = HasLeaf7Subleaf1 && ((EDX >> 15) & 1);
18481848
Features["avx10.1-256"] = HasLeaf7Subleaf1 && ((EDX >> 19) & 1);
1849+
bool HasAPXF = HasLeaf7Subleaf1 && ((EDX >> 21) & 1);
1850+
Features["egpr"] = HasAPXF;
1851+
Features["push2pop2"] = HasAPXF;
1852+
Features["ppx"] = HasAPXF;
1853+
Features["ndd"] = HasAPXF;
1854+
Features["ccmp"] = HasAPXF;
1855+
Features["cf"] = HasAPXF;
18491856

18501857
bool HasLeafD = MaxLevel >= 0xd &&
18511858
!getX86CpuIDAndInfoEx(0xd, 0x1, &EAX, &EBX, &ECX, &EDX);

0 commit comments

Comments
 (0)