]> git.ipfire.org Git - thirdparty/gcc.git/commit
aarch64: Add front-end argument type checking for target builtins
authorVictor Do Nascimento <victor.donascimento@arm.com>
Mon, 10 Jul 2023 19:16:07 +0000 (20:16 +0100)
committerVictor Do Nascimento <victor.donascimento@arm.com>
Wed, 6 Dec 2023 10:39:14 +0000 (10:39 +0000)
commit5af697d72d79db7ad5713c18dea8f52cfc79612f
tree43682a7b91b33a4a6ff413813844ec07428d9593
parentfc42900d21abd5eacb7537c3c8ffc5278d510195
aarch64: Add front-end argument type checking for target builtins

In implementing the ACLE read/write system register builtins it was
observed that leaving argument type checking to be done at expand-time
meant that poorly-formed function calls were being "fixed" by certain
optimization passes, meaning bad code wasn't being properly picked up
in checking.

Example:

  const char *regname = "amcgcr_el0";
  long long a = __builtin_aarch64_rsr64 (regname);

is reduced by the ccp1 pass to

  long long a = __builtin_aarch64_rsr64 ("amcgcr_el0");

As these functions require an argument of STRING_CST type, there needs
to be a check carried out by the front-end capable of picking this up.

The introduced `check_general_builtin_call' function will be called by
the TARGET_CHECK_BUILTIN_CALL hook whenever a call to a builtin
belonging to the AARCH64_BUILTIN_GENERAL category is encountered,
carrying out any appropriate checks associated with a particular
builtin function code.

gcc/ChangeLog:

* config/aarch64/aarch64-builtins.cc (aarch64_general_check_builtin_call):
New.
* config/aarch64/aarch64-c.cc (aarch64_check_builtin_call):
Add `aarch64_general_check_builtin_call' call.
* config/aarch64/aarch64-protos.h (aarch64_general_check_builtin_call):
New.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/acle/rwsr-3.c: New.
gcc/config/aarch64/aarch64-builtins.cc
gcc/config/aarch64/aarch64-c.cc
gcc/config/aarch64/aarch64-protos.h
gcc/testsuite/gcc.target/aarch64/acle/rwsr-3.c [new file with mode: 0644]