Skip to content

Commit ae86870

Browse files
committed
Add more mappings to x86 features
1 parent c805a45 commit ae86870

2 files changed

Lines changed: 35 additions & 13 deletions

File tree

src/llvm_compat.cpp

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,32 +33,33 @@ static const std::set<std::string> aarch64_filter_out = {
3333
// ============================================================================
3434

3535
static const std::unordered_map<std::string, std::string> x86_64_feature_map = {
36-
// Most x86 features have the same name, but some differ
3736
{"sse4_1", "sse4.1"},
3837
{"sse4_2", "sse4.2"},
39-
{"avx512f", "avx512f"},
40-
{"avx512cd", "avx512cd"},
41-
{"avx512vl", "avx512vl"},
42-
{"avx512bw", "avx512bw"},
43-
{"avx512dq", "avx512dq"},
4438
{"avx512_vnni", "avx512vnni"},
4539
{"avx512_bf16", "avx512bf16"},
4640
{"avx512_vbmi", "avx512vbmi"},
4741
{"avx512_vbmi2", "avx512vbmi2"},
4842
{"avx512_ifma", "avx512ifma"},
4943
{"avx512_vpopcntdq", "avx512vpopcntdq"},
44+
{"avx512_vp2intersect", "avx512vp2intersect"},
5045
{"avx512_bitalg", "avx512bitalg"},
5146
{"avx_vnni", "avxvnni"},
52-
{"clflushopt", "clflushopt"},
53-
{"clwb", "clwb"},
54-
{"movdiri", "movdiri"},
55-
{"movdir64b", "movdir64b"},
56-
{"pconfig", "pconfig"},
47+
{"lahf_lm", "sahf"},
48+
{"pclmulqdq", "pclmul"},
49+
{"rdrand", "rdrnd"},
50+
{"abm", "lzcnt"},
51+
{"bmi1", "bmi"},
52+
{"sha_ni", "sha"},
53+
{"amx_bf16", "amx-bf16"},
54+
{"amx_int8", "amx-int8"},
55+
{"amx_tile", "amx-tile"},
5756
};
5857

59-
// x86 features to filter out
6058
static const std::set<std::string> x86_64_filter_out = {
61-
// Usually none need filtering on x86
59+
"3dnow",
60+
"3dnowext",
61+
"avx512er",
62+
"avx512pf",
6263
};
6364

6465
// ============================================================================

tests/test_llvm_compat.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,31 @@ void test_x86_feature_mapping() {
3939
assert(archspec::map_feature_to_llvm("x86_64", "sse4_2") == "sse4.2");
4040
assert(archspec::map_feature_to_llvm("x86_64", "avx512_vnni") == "avx512vnni");
4141

42+
// Test cpuinfo/archspec -> LLVM name mappings
43+
assert(archspec::map_feature_to_llvm("x86_64", "lahf_lm") == "sahf");
44+
assert(archspec::map_feature_to_llvm("x86_64", "pclmulqdq") == "pclmul");
45+
assert(archspec::map_feature_to_llvm("x86_64", "rdrand") == "rdrnd");
46+
assert(archspec::map_feature_to_llvm("x86_64", "abm") == "lzcnt");
47+
assert(archspec::map_feature_to_llvm("x86_64", "bmi1") == "bmi");
48+
assert(archspec::map_feature_to_llvm("x86_64", "sha_ni") == "sha");
49+
// AMX features use hyphens in LLVM
50+
assert(archspec::map_feature_to_llvm("x86_64", "amx_bf16") == "amx-bf16");
51+
assert(archspec::map_feature_to_llvm("x86_64", "amx_int8") == "amx-int8");
52+
assert(archspec::map_feature_to_llvm("x86_64", "amx_tile") == "amx-tile");
53+
// AVX-512 features
54+
assert(archspec::map_feature_to_llvm("x86_64", "avx512_vp2intersect") == "avx512vp2intersect");
55+
56+
// Test filter-out (features with no LLVM equivalent)
57+
assert(archspec::map_feature_to_llvm("x86_64", "3dnow") == "");
58+
assert(archspec::map_feature_to_llvm("x86_64", "avx512er") == "");
59+
assert(archspec::map_feature_to_llvm("x86_64", "avx512pf") == "");
60+
4261
// Test pass-through
4362
assert(archspec::map_feature_to_llvm("x86_64", "avx") == "avx");
4463
assert(archspec::map_feature_to_llvm("x86_64", "avx2") == "avx2");
4564
assert(archspec::map_feature_to_llvm("x86_64", "fma") == "fma");
65+
assert(archspec::map_feature_to_llvm("x86_64", "bmi2") == "bmi2");
66+
assert(archspec::map_feature_to_llvm("x86_64", "popcnt") == "popcnt");
4667

4768
printf(" PASS: x86_64 feature mapping\n");
4869
}

0 commit comments

Comments
 (0)