Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CPUID] Add ISA entries for A64FX and M1 #44194

Merged
merged 5 commits into from
Feb 20, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[CPUID] Simplify collection of full set of features for architecture
  • Loading branch information
giordano committed Feb 16, 2022
commit 22eb7a9973ada72159503ee566f42bbb7597d887
28 changes: 13 additions & 15 deletions base/cpuid.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,22 +89,20 @@ function normalize_arch(arch::String)
return arch
end

const ALL_FEATURES = let
get_features(prefix::String) =
getfield.(Ref(@__MODULE__), filter(n -> startswith(String(n), prefix), (names(@__MODULE__; all=true))))
Dict(
"i686" => get_features("JL_X86"),
"x86_64" => get_features("JL_X86"),
"armv6l" => get_features("JL_AArch32"),
"armv7l" => get_features("JL_AArch32"),
"aarch64" => get_features("JL_AArch64"),
"powerpc64le" => UInt32[],
)
end
let
# Collect all relevant features for the current architecture, if any.
FEATURES = UInt32[]
arch = normalize_arch(String(Sys.ARCH))
if arch in keys(ISAs_by_family)
for isa in ISAs_by_family[arch]
unique!(append!(FEATURES, last(isa).features))
end
end

# Use `@eval` to statically determine the list of features for the current architecture.
@eval function cpu_isa()
return ISA(Set{UInt32}(feat for feat in $(ALL_FEATURES[normalize_arch(String(Sys.ARCH))]) if test_cpu_feature(feat)))
# Use `@eval` to inline the list of features.
@eval function cpu_isa()
return ISA(Set{UInt32}(feat for feat in $(FEATURES) if test_cpu_feature(feat)))
end
end

"""
Expand Down