AArch64: Fix native detection in the presence of mandatory features which don't have midr values
aarch64-option-extensions.def explicitly defines the semantics for an empty midr
field as being:
In that case this field
should contain a space (" ") separated list of the strings in 'Features'
that are required. Their order is not important. An empty string means
do not detect this feature during auto detection.
That is to say, an empty string means that we don't know the midr value for this
feature and so it just shouldn't be taken into account for native features
detection. However this meaning seems to have gotten lost at some point.
This results in e.g. -mcpu=native on a Neoverse N2 disabling features it does
have. Essentially we disabled any mandatory feature for which there is no midr
entry.
The rationale for having -mcpu=native being able to disable features at all, is
because the kernel is able to disable a mandatory feature for correctness
issues. Unfortunately we can't distinguish between "old kernel"
and "kernel disabled".
This patch adds a new field that indicates whether the midr field has any value
at all. If there's no value we skip the extension when determining the "off"
flags.
gcc/ChangeLog:
* common/config/aarch64/aarch64-common.cc
(struct aarch64_option_extension): Add native_detect and document struct
a bit more.
(all_extensions): Set new field native_detect.
* config/aarch64/aarch64.cc (struct aarch64_option_extension): Delete
unused struct.
gcc/testsuite/ChangeLog:
* gcc.target/aarch64/cpunative/info_19: New test.
* gcc.target/aarch64/cpunative/info_20: New test.
* gcc.target/aarch64/cpunative/info_21: New test.
* gcc.target/aarch64/cpunative/info_22: New test.
* gcc.target/aarch64/cpunative/native_cpu_19.c: New test.
* gcc.target/aarch64/cpunative/native_cpu_20.c: New test.
* gcc.target/aarch64/cpunative/native_cpu_21.c: New test.
* gcc.target/aarch64/cpunative/native_cpu_22.c: New test.