]> git.ipfire.org Git - thirdparty/gcc.git/commit
aarch64: Implement the ACLE instruction/data prefetch functions.
authorVictor Do Nascimento <victor.donascimento@arm.com>
Wed, 10 May 2023 11:03:58 +0000 (12:03 +0100)
committerVictor Do Nascimento <victor.donascimento@arm.com>
Wed, 13 Dec 2023 02:49:56 +0000 (02:49 +0000)
commit9fba6637687a197cb37c3c76110eb5d81dc56e60
tree5c69c2fd70f078d8b02df796a06de5040eeef0f2
parentfda8e2f8292a90dac9fcaf952bad6fff3aa7fff2
aarch64: Implement the ACLE instruction/data prefetch functions.

Implement the ACLE data and instruction prefetch functions[1] with the
following signatures:

  1. Data prefetch intrinsics:
  ----------------------------
  void __pldx (/*constant*/ unsigned int /*access_kind*/,
               /*constant*/ unsigned int /*cache_level*/,
               /*constant*/ unsigned int /*retention_policy*/,
               void const volatile *addr);

  void __pld (void const volatile *addr);

  2. Instruction prefetch intrinsics:
  -----------------------------------
  void __plix (/*constant*/ unsigned int /*cache_level*/,
               /*constant*/ unsigned int /*retention_policy*/,
               void const volatile *addr);

  void __pli (void const volatile *addr);

`__pldx' affords the programmer more fine-grained control over the
data prefetch behaviour than the analogous GCC builtin
`__builtin_prefetch', and allows access to the "SLC" cache level.

While `__builtin_prefetch' chooses both cache-level and retention
policy automatically via the optional `locality' parameter, `__pldx'
expects 2 (mandatory) arguments to explicitly define the desired
cache-level and retention policies.

`__plix' on the other hand, generates a code prefetch instruction and
so extends functionality on aarch64 targets beyond that which is
exposed by `builtin_prefetch'.

`__pld' and `__pli' do prefetch of data and instructions,
respectively, using default values for both cache-level and retention
policies.

Bootstrapped and tested on aarch64-none-linux-gnu.

[1] https://arm-software.github.io/acle/main/acle.html#memory-prefetch-intrinsics

gcc/ChangeLog:

* config/aarch64/aarch64-builtins.cc:
(AARCH64_PLD): New enum aarch64_builtins entry.
(AARCH64_PLDX): Likewise.
(AARCH64_PLI): Likewise.
(AARCH64_PLIX): Likewise.
(aarch64_init_prefetch_builtin): New.
(aarch64_general_init_builtins): Call prefetch init function.
(aarch64_expand_prefetch_builtin): New.
(aarch64_general_expand_builtin):  Add prefetch expansion.
(require_const_argument): New.
* config/aarch64/aarch64.md (UNSPEC_PLDX): New.
(aarch64_pldx): Likewise.
* config/aarch64/arm_acle.h (__pld): Likewise.
(__pli): Likewise.
(__plix): Likewise.
(__pldx): Likewise.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/builtin_pld_pli.c: New.
* gcc.target/aarch64/builtin_pld_pli_illegal.c: New.
gcc/config/aarch64/aarch64-builtins.cc
gcc/config/aarch64/aarch64.md
gcc/config/aarch64/arm_acle.h
gcc/testsuite/gcc.target/aarch64/builtin_pld_pli.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/builtin_pld_pli_illegal.c [new file with mode: 0644]