> On 28 Aug 2024, at 11:22, saurabh....@arm.com wrote:
>
> External email: Use caution opening links or attachments
>
>
> The AArch64 FEAT_FAMINMAX extension is optional from Armv9.2-a and
> mandatory from Armv9.5-a. It introduces instructions for computing the
> floating point absolute maximum and minimum of the two vectors element-wise.
>
> This patch introduces AdvSIMD faminmax intrinsics. The intrinsics of
> this extension are implemented as the following builtin functions:
> * vamax_f16
> * vamaxq_f16
> * vamax_f32
> * vamaxq_f32
> * vamaxq_f64
> * vamin_f16
> * vaminq_f16
> * vamin_f32
> * vaminq_f32
> * vaminq_f64
>
> We are defining a new way to add AArch64 AdvSIMD intrinsics by listing
> all the intrinsics in a .def file and then using that .def file to
> initialise various data structures. This would lead to more concise code
> and easier addition of the new AdvSIMD intrinsics in future.
>
> The faminmax intrinsics are defined using the new approach
>
> gcc/ChangeLog:
>
> * config/aarch64/aarch64-builtins.cc
> (ENTRY): Macro to parse the contents of
> aarch64-simd-pragma-builtins.def.
> (enum aarch64_builtins): New enum values for faminmax builtins
> via aarch64-simd-pragma-builtins.def.
> (aarch64_init_pragma_builtins): New function to define pragma builtins.
> (handle_arm_neon_h): Modify to call
> aarch64_init_pragma_builtins.
> (aarch64_general_check_builtin_call): Modify to check whether
> required flag is being used for pragma builtins.
> (aarch64_expand_pragma_builtin): New function to emit
> instructions of pragma builtins.
> (aarch64_general_expand_builtin): Modify to call
> aarch64_expand_pragma_builtin.
> * config/aarch64/aarch64-option-extensions.def
> (AARCH64_OPT_EXTENSION): Introduce new flag for this
> extension.
> * config/aarch64/aarch64-simd.md
> (@aarch64_<faminmax_uns_op><mode>): Instruction pattern for
> faminmax intrinsics.
> * config/aarch64/aarch64.h
> (TARGET_FAMINMAX): Introduce new flag for this extension.
> * config/aarch64/iterators.md: New iterators and unspecs.
> * config/arm/types.md: Introduce neon_fp_aminmax<q> attributes.
> * doc/invoke.texi: Document extension in AArch64 Options.
> * config/aarch64/aarch64-simd-pragma-builtins.def: New file to
> list pragma builtins.
>
> gcc/testsuite/ChangeLog:
>
> * gcc.target/aarch64/simd/faminmax-builtins-no-flag.c: New test.
> * gcc.target/aarch64/simd/faminmax-builtins.c: New test.
> ---
> gcc/config/aarch64/aarch64-builtins.cc | 73 +++++++++++
> .../aarch64/aarch64-option-extensions.def | 2 +
> .../aarch64/aarch64-simd-pragma-builtins.def | 31 +++++
> gcc/config/aarch64/aarch64-simd.md | 11 ++
> gcc/config/aarch64/aarch64.h | 4 +
> gcc/config/aarch64/iterators.md | 9 ++
> gcc/config/arm/types.md | 6 +
> gcc/doc/invoke.texi | 2 +
> .../aarch64/simd/faminmax-builtins-no-flag.c | 10 ++
> .../aarch64/simd/faminmax-builtins.c | 115 ++++++++++++++++++
> 10 files changed, 263 insertions(+)
> create mode 100644 gcc/config/aarch64/aarch64-simd-pragma-builtins.def
> create mode 100644
> gcc/testsuite/gcc.target/aarch64/simd/faminmax-builtins-no-flag.c
> create mode 100644 gcc/testsuite/gcc.target/aarch64/simd/faminmax-builtins.c
>
> <v5-0001-aarch64-Add-AdvSIMD-faminmax-intrinsics.patch>
diff --git a/gcc/config/aarch64/aarch64-builtins.cc
b/gcc/config/aarch64/aarch64-builtins.cc
index eb878b933fe..e6b88a194d3 100644
--- a/gcc/config/aarch64/aarch64-builtins.cc
+++ b/gcc/config/aarch64/aarch64-builtins.cc
@@ -757,6 +757,10 @@ typedef struct
#define VAR1(T, N, MAP, FLAG, A) \
AARCH64_SIMD_BUILTIN_##T##_##N##A,
+#undef ENTRY
+#define ENTRY(N, M, U, F) \
+ AARCH64_##N,
+
enum aarch64_builtins
{
AARCH64_BUILTIN_MIN,
@@ -829,6 +833,8 @@ enum aarch64_builtins
AARCH64_RBIT,
AARCH64_RBITL,
AARCH64_RBITLL,
+ /* Pragma builtins. */
+#include "aarch64-simd-pragma-builtins.def"
/* System register builtins. */
AARCH64_RSR,
AARCH64_RSRP,
We should define AARCH64_PRAGMA_BUILTIN_START and AARCH64_PRAGMA_BUILTIN_MAX
values to here to denote the start and end of the values that come from
aarch64-simd-pragma-builtins.def.
That way we can avoid using AARCH64_vamax_f16 as a special value elsewhere in
the patch.
See how AARCH64_SIMD_PATTERN_START is define and used in this file for
inspiration.
Otherwise this looks okay.
Thanks for the revisions.
Kyrill