AArch64: Fix native detection in the presence of mandatory features which don't have...
commita2c848c92c3f13c2dd9bd92d22beb44c1ff848b4
authorTamar Christina <tamar.christina@arm.com>
Wed, 1 Feb 2023 18:31:41 +0000 (1 18:31 +0000)
committerTamar Christina <tamar.christina@arm.com>
Wed, 1 Feb 2023 18:31:41 +0000 (1 18:31 +0000)
tree60ffcc6e6ad3d1d0b44aaa3c40686c603f3ea4f5
parent9fadd8dec79876d3c393daccc62959f6f4853cc5
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.
gcc/common/config/aarch64/aarch64-common.cc
gcc/config/aarch64/aarch64.cc
gcc/testsuite/gcc.target/aarch64/cpunative/info_19 [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/cpunative/info_20 [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/cpunative/info_21 [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/cpunative/info_22 [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_19.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_20.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_21.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_22.c [new file with mode: 0644]