Skip to content

Commit

Permalink
[BinaryPlatforms]: Add Base.show() override for Platform
Browse files Browse the repository at this point in the history
This should be a little more friendly to those just looking to inspect
some of these objects
  • Loading branch information
staticfloat committed Sep 24, 2020
1 parent 7c47638 commit 6cc1a9f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
13 changes: 12 additions & 1 deletion base/binaryplatforms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,17 @@ function Base.repr(p::Platform; context=nothing)
)
end

# Make showing the platform a bit more palatable
function Base.show(io::IO, p::Platform)
str = string(platform_name(p), " ", arch(p))
# Add on all the other tags not covered by os/arch:
other_tags = sort(collect(filter(kv -> kv[1] ("os", "arch"), tags(p))))
if !isempty(other_tags)
str = string(str, " {", join([string(k, "=", v) for (k, v) in other_tags], ", "), "}")
end
print(io, str)
end

# Simple equality definition; for compatibility testing, use `platforms_match()`
Base.:(==)(a::AbstractPlatform, b::AbstractPlatform) = tags(a) == tags(b)

Expand Down Expand Up @@ -577,7 +588,7 @@ const arch_march_isa_mapping = let
],
"armv7l" => [
"armv7l" => get_set("armv7l", "armv7l"),
"neonvfp4" => get_set("armv7l", "armv7l+neon+vfp4"),
"neonvfpv4" => get_set("armv7l", "armv7l+neon+vfpv4"),
],
"aarch64" => [
"armv8_0" => get_set("aarch64", "armv8.0-a"),
Expand Down
4 changes: 2 additions & 2 deletions base/cpuid.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const ISAs_by_family = Dict(
"armv7l" => [
"armv7l" => ISA(Set{UInt32}()),
"armv7l+neon" => ISA(Set((JL_AArch32_neon,))),
"armv7l+neon+vfp4" => ISA(Set((JL_AArch32_neon, JL_AArch32_vfp4))),
"armv7l+neon+vfpv4" => ISA(Set((JL_AArch32_neon, JL_AArch32_vfp4))),
],
"aarch64" => [
# Implicit in all sets, because always required: fp, asimd
Expand Down Expand Up @@ -91,7 +91,7 @@ end
Return the [`ISA`](@ref) (instruction set architecture) of the current CPU.
"""
function cpu_isa()
all_features = last(last(get(ISAs_by_family, normalize_arch(Sys.ARCH), "" => [ISA(Set{UInt32}())]))).features
all_features = last(last(get(ISAs_by_family, normalize_arch(String(Sys.ARCH)), "" => [ISA(Set{UInt32}())]))).features
return ISA(Set{UInt32}(feat for feat in all_features if test_cpu_feature(feat)))
end

Expand Down

0 comments on commit 6cc1a9f

Please sign in to comment.