]> git.ipfire.org Git - thirdparty/gcc.git/commit
aarch64: Add system register duplication check selftest
authorVictor Do Nascimento <victor.donascimento@arm.com>
Tue, 10 Oct 2023 09:28:56 +0000 (10:28 +0100)
committerVictor Do Nascimento <victor.donascimento@arm.com>
Wed, 6 Dec 2023 10:39:55 +0000 (10:39 +0000)
commit9a8fdade94a1910000755a5023c0de962e0d3ba2
tree8ba041b7ecb2b2fd28dda74521c7de7cca0291f7
parent5af697d72d79db7ad5713c18dea8f52cfc79612f
aarch64: Add system register duplication check selftest

Add a build-time test to check whether system register data, as
imported from `aarch64-sys-reg.def' has any duplicate entries.

Duplicate entries are defined as any two SYSREG entries in the .def
file which share the same encoding values (as specified by its `CPENC'
field) and where the relationship amongst the two does not fit into
one of the following categories:

  * Simple aliasing: In some cases, it is observed that one
  register name serves as an alias to another.  One example of
  this is where TRCEXTINSELR aliases TRCEXTINSELR0.
  * Expressing intent: It is possible that when a given register
  serves two distinct functions depending on how it is used, it
  is given two distinct names whose use should match the context
  under which it is being used.  Example:  Debug Data Transfer
  Register. When used to receive data, it should be accessed as
  DBGDTRRX_EL0 while when transmitting data it should be
  accessed via DBGDTRTX_EL0.
  * Register depreciation: Some register names have been
  deprecated and should no longer be used, but backwards-
  compatibility requires that such names continue to be
  recognized, as is the case for the SPSR_EL1 register, whose
  access via the SPSR_SVC name is now deprecated.
  * Same encoding different target: Some encodings are given
  different meaning depending on the target architecture and, as
  such, are given different names in each of theses contexts.
  We see an example of this for CPENC(3,4,2,0,0), which
  corresponds to TTBR0_EL2 for Armv8-A targets and VSCTLR_EL2
  in Armv8-R targets.

A consequence of these observations is that `CPENC' duplication is
acceptable iff at least one of the `properties' or `arch_reqs' fields
of the `sysreg_t' structs associated with the two registers in
question differ and it's this condition that is checked by the new
`aarch64_test_sysreg_encoding_clashes' function.

gcc/ChangeLog:

* config/aarch64/aarch64.cc
(aarch64_test_sysreg_encoding_clashes): New.
(aarch64_run_selftests): add call to
aarch64_test_sysreg_encoding_clashes selftest.
gcc/config/aarch64/aarch64.cc