@@ -56,9 +56,10 @@ const ISAs_by_family = Dict(
56
56
" aarch64" => [
57
57
# Implicit in all sets, because always required: fp, asimd
58
58
" armv8.0-a" => ISA (Set {UInt32} ()),
59
- " armv8.1-a" => ISA (Set ((JL_AArch64_lse, JL_AArch64_crc, JL_AArch64_rdm))),
60
- " armv8.2-a+crypto" => ISA (Set ((JL_AArch64_lse, JL_AArch64_crc, JL_AArch64_rdm, JL_AArch64_aes, JL_AArch64_sha2))),
61
- " armv8.4-a+crypto+sve" => ISA (Set ((JL_AArch64_lse, JL_AArch64_crc, JL_AArch64_rdm, JL_AArch64_fp16fml, JL_AArch64_aes, JL_AArch64_sha2, JL_AArch64_dotprod, JL_AArch64_sve))),
59
+ " armv8.1-a" => ISA (Set ((JL_AArch64_v8_1a, JL_AArch64_lse, JL_AArch64_crc, JL_AArch64_rdm))),
60
+ " armv8.2-a+crypto" => ISA (Set ((JL_AArch64_v8_2a, JL_AArch64_lse, JL_AArch64_crc, JL_AArch64_rdm, JL_AArch64_aes, JL_AArch64_sha2))),
61
+ " a64fx" => ISA (Set ((JL_AArch64_v8_2a, JL_AArch64_lse, JL_AArch64_crc, JL_AArch64_rdm, JL_AArch64_sha2, JL_AArch64_ccpp, JL_AArch64_complxnum, JL_AArch64_fullfp16, JL_AArch64_sve))),
62
+ " apple_m1" => ISA (Set ((JL_AArch64_v8_5a, JL_AArch64_lse, JL_AArch64_crc, JL_AArch64_rdm, JL_AArch64_aes, JL_AArch64_sha2, JL_AArch64_sha3, JL_AArch64_ccpp, JL_AArch64_complxnum, JL_AArch64_fp16fml, JL_AArch64_fullfp16, JL_AArch64_dotprod, JL_AArch64_rcpc, JL_AArch64_altnzcv))),
62
63
],
63
64
" powerpc64le" => [
64
65
# We have no way to test powerpc64le features yet, so we're only going to declare the lowest ISA:
@@ -88,14 +89,27 @@ function normalize_arch(arch::String)
88
89
return arch
89
90
end
90
91
92
+ let
93
+ # Collect all relevant features for the current architecture, if any.
94
+ FEATURES = UInt32[]
95
+ arch = normalize_arch (String (Sys. ARCH))
96
+ if arch in keys (ISAs_by_family)
97
+ for isa in ISAs_by_family[arch]
98
+ unique! (append! (FEATURES, last (isa). features))
99
+ end
100
+ end
101
+
102
+ # Use `@eval` to inline the list of features.
103
+ @eval function cpu_isa ()
104
+ return ISA (Set {UInt32} (feat for feat in $ (FEATURES) if test_cpu_feature (feat)))
105
+ end
106
+ end
107
+
91
108
"""
92
109
cpu_isa()
93
110
94
111
Return the [`ISA`](@ref) (instruction set architecture) of the current CPU.
95
112
"""
96
- function cpu_isa ()
97
- all_features = last (last (get (ISAs_by_family, normalize_arch (String (Sys. ARCH)), " " => [ISA (Set {UInt32} ())]))). features
98
- return ISA (Set {UInt32} (feat for feat in all_features if test_cpu_feature (feat)))
99
- end
113
+ cpu_isa
100
114
101
115
end # module CPUID
0 commit comments