Hi gcc-patches mailing list, Karl Meakin <[email protected]> has requested that the following forgejo pull request be published on the mailing list.
Created on: 2025-10-02 16:30:31+00:00 Latest update: 2026-01-08 13:18:12+00:00 Changes: 15 changed files, 570 additions, 515 deletions Head revision: karmea01/gcc-TEST ref km/aarch64-intrinsics-refactors/v1 commit 28546fe56aa80c5bfdf4a5f4ad2cf476a8ee4096 Base revision: gcc/gcc-TEST ref trunk commit 07da32d7e64673771ce121caf8dce24db510d8ff r16-6571-g07da32d7e64673 Merge base: 07da32d7e64673771ce121caf8dce24db510d8ff Full diff url: https://forge.sourceware.org/gcc/gcc-TEST/pulls/90.diff Discussion: https://forge.sourceware.org/gcc/gcc-TEST/pulls/90 Requested Reviewers: Minor refactors and documentation improvements. NFCI Testing done: `make check-gcc` and `make check-target` ChangeLog: * v1: Initial revision * v2: * Squash "aarch64: Remove redundant const from constexpr variables" and "aarch64: Reformat array initializers to be more readable" into "aarch64: Reformat array initializers" * v3: * Add "aarch64: Rename `ENTRY` to `DEF_SIMD_TYPE`" * Squash "aarch64: Delete duplicate enum aarch64_simd_type definition" into "aarch64: Rename `ENTRY` to `DEF_SIMD_TYPE`" * Add "aarch64: Make `NUM_VECTOR_TYPES` an enum member" * Add "aarch64: Use shifts in `aarch64_type_qualifiers` enum " * v4: Rebase against master * v5: Rebase against master * v6: Fix compile error in "aarch64: Reformat array initializers" * v7: remove `clang-format` directives * v8: rebase against master, add "aarch64: use `enum unspec` rather than `int`" * v9: rebase against master, split "aarch64: use `enum unspec` rather than `int`" into "use `unspec` type for unspec codes" and "Replace `UNSPEC_NONE` with optional arguments where possible". * v10: rebase against master. Change value of `UNSPEC_NONE` from `-1` to `0`. Changed files: - M: gcc/config/aarch64/aarch64-builtins.cc - M: gcc/config/aarch64/aarch64-builtins.h - M: gcc/config/aarch64/aarch64-neon-sve-bridge-builtins.def - M: gcc/config/aarch64/aarch64-simd-builtin-types.def - M: gcc/config/aarch64/aarch64-sve-builtins-base.cc - M: gcc/config/aarch64/aarch64-sve-builtins-base.def - M: gcc/config/aarch64/aarch64-sve-builtins-functions.h - M: gcc/config/aarch64/aarch64-sve-builtins-sme.cc - M: gcc/config/aarch64/aarch64-sve-builtins-sme.def - M: gcc/config/aarch64/aarch64-sve-builtins-sve2.cc - M: gcc/config/aarch64/aarch64-sve-builtins.cc - M: gcc/config/aarch64/aarch64-sve-builtins.def - M: gcc/config/aarch64/aarch64-sve-builtins.h - M: gcc/config/aarch64/aarch64.cc - M: gcc/config/aarch64/aarch64.md Karl Meakin (9): aarch64: Rename `ENTRY` to `DEF_SIMD_TYPE` aarch64: Document `DEF_*` macros aarch64: Define `DEF_SVE_TYPE_SUFFIX` in terms of `DEF_SVE_NEON_TYPE_SUFFIX` aarch64: Use variadic arguments aarch64: Reformat array initializers aarch64: Make `VECTOR_TYPE_none` an enum member aarch64: Use shifts in `aarch64_type_qualifiers` enum aarch64: use `unspec` type for unspec codes aarch64: Replace `UNSPEC_NONE` with optional arguments where possible gcc/config/aarch64/aarch64-builtins.cc | 22 +- gcc/config/aarch64/aarch64-builtins.h | 38 ++- .../aarch64-neon-sve-bridge-builtins.def | 4 +- .../aarch64/aarch64-simd-builtin-types.def | 80 ++--- .../aarch64/aarch64-sve-builtins-base.cc | 157 +++++----- .../aarch64/aarch64-sve-builtins-base.def | 18 ++ .../aarch64/aarch64-sve-builtins-functions.h | 132 ++++---- .../aarch64/aarch64-sve-builtins-sme.cc | 50 ++- .../aarch64/aarch64-sve-builtins-sme.def | 18 +- .../aarch64/aarch64-sve-builtins-sve2.cc | 296 ++++++++---------- gcc/config/aarch64/aarch64-sve-builtins.cc | 167 +++++----- gcc/config/aarch64/aarch64-sve-builtins.def | 47 ++- gcc/config/aarch64/aarch64-sve-builtins.h | 25 +- gcc/config/aarch64/aarch64.cc | 8 +- gcc/config/aarch64/aarch64.md | 1 + 15 files changed, 559 insertions(+), 504 deletions(-) Range-diff against v9: 1: 4184b9cec319 = 1: 16f382f4d705 aarch64: Rename `ENTRY` to `DEF_SIMD_TYPE` 2: 92a115819741 ! 2: 2e914d76f1de aarch64: Document `DEF_*` macros @@ gcc/config/aarch64/aarch64-sve-builtins-base.def ## gcc/config/aarch64/aarch64-sve-builtins-sme.def ## @@ - along with GCC; see the file COPYING3. If not see <http://www.gnu.org/licenses/>. */ --#ifndef DEF_SME_FUNCTION --#define DEF_SME_FUNCTION(NAME, SHAPE, TYPES, PREDS) \ -- DEF_SME_FUNCTION_GS (NAME, SHAPE, TYPES, none, PREDS) -+/* Define an SME function. -+ See `function_group_info` for the meaning of each argument. */ -+#ifndef DEF_SME_FUNCTION_GS -+#define DEF_SME_FUNCTION_GS(NAME, SHAPE, TYPES, GROUPS, PREDS) + ++/* Define an SME function group. ++ See `struct function_group_info` for the meaning of each argument. */ + #ifndef DEF_SME_FUNCTION_GS + #define DEF_SME_FUNCTION_GS(NAME, SHAPE, TYPES, GROUPS, PREDS) \ + DEF_SME_FUNCTION_GS_FPM (NAME, SHAPE, TYPES, GROUPS, PREDS, unused) #endif +-#ifndef DEF_SME_FUNCTION +-#define DEF_SME_FUNCTION(NAME, SHAPE, TYPES, PREDS) \ +- DEF_SME_FUNCTION_GS_FPM (NAME, SHAPE, TYPES, none, PREDS, unused) +-#endif +/* Same as `DEF_SME_FUNCTION_GS` above, but with GROUPS = none. */ +#define DEF_SME_FUNCTION(NAME, SHAPE, TYPES, PREDS) \ + DEF_SME_FUNCTION_GS (NAME, SHAPE, TYPES, none, PREDS) -+ + +/* Define an SME function that operates on ZA. + See `function_group_info` for the meaning of each argument. */ #ifndef DEF_SME_ZA_FUNCTION_GS #define DEF_SME_ZA_FUNCTION_GS(NAME, SHAPE, TYPES, GROUP, PREDS) \ -- DEF_SME_FUNCTION_GS (NAME, SHAPE, TYPES, GROUP, PREDS) -+ DEF_SME_FUNCTION_GS (NAME, SHAPE, TYPES, GROUP, PREDS) +- DEF_SME_ZA_FUNCTION_GS_FPM (NAME, SHAPE, TYPES, GROUP, PREDS, unused) ++ DEF_SME_ZA_FUNCTION_GS_FPM (NAME, SHAPE, TYPES, GROUP, PREDS, unused) #endif +/* Same as `DEF_SME_ZA_FUNCTION_GS` above, but with GROUPS = none. */ #ifndef DEF_SME_ZA_FUNCTION -#define DEF_SME_ZA_FUNCTION(NAME, SHAPE, TYPES, PREDS) \ -- DEF_SME_ZA_FUNCTION_GS (NAME, SHAPE, TYPES, none, PREDS) +- DEF_SME_ZA_FUNCTION_GS_FPM (NAME, SHAPE, TYPES, none, PREDS, unused) +#define DEF_SME_ZA_FUNCTION(NAME, SHAPE, TYPES, PREDS) \ -+ DEF_SME_ZA_FUNCTION_GS (NAME, SHAPE, TYPES, none, PREDS) ++DEF_SME_ZA_FUNCTION_GS_FPM (NAME, SHAPE, TYPES, none, PREDS, unused) #endif #define REQUIRED_EXTENSIONS streaming_compatible (0) 3: e698e4d68ca5 = 3: 850804752b77 aarch64: Define `DEF_SVE_TYPE_SUFFIX` in terms of `DEF_SVE_NEON_TYPE_SUFFIX` 4: 7aafe3ea2961 = 4: 5c68dc962e73 aarch64: Use variadic arguments 5: ee472c1c57e0 ! 5: 4b7f2cfe701f aarch64: Reformat array initializers @@ gcc/config/aarch64/aarch64-sve-builtins.cc: static const char *const pred_suffix #include "aarch64-sve-builtins.def" - { "", NUM_VECTOR_TYPES, TYPE_bool, 0, 0, false, false, false, false, - false, false, 0, VOIDmode, ARM_NEON_H_TYPES_LAST, ARM_NEON_H_TYPES_LAST } --}; -+ {"", NUM_VECTOR_TYPES, TYPE_bool, 0, 0, false, false, false, false, false, -+ false, 0, VOIDmode, ARM_NEON_H_TYPES_LAST, ARM_NEON_H_TYPES_LAST}}; ++ { "", NUM_VECTOR_TYPES, TYPE_bool, 0, 0, false, false, false, false, false, ++ false, 0, VOIDmode, ARM_NEON_H_TYPES_LAST, ARM_NEON_H_TYPES_LAST } + }; -CONSTEXPR const group_suffix_info group_suffixes[] = { +constexpr group_suffix_info group_suffixes[] = { @@ gcc/config/aarch64/aarch64-sve-builtins.cc: static const predication_index preds /* A list of all arm_sme.h functions. */ -static CONSTEXPR const function_group_info sme_function_groups[] = { --#define DEF_SME_FUNCTION_GS(NAME, SHAPE, TYPES, GROUPS, PREDS) \ ++static constexpr function_group_info sme_function_groups[] = { + #define DEF_SME_FUNCTION_GS_FPM(NAME, SHAPE, TYPES, GROUPS, PREDS, FPM_MODE) \ - { #NAME, &functions::NAME, &shapes::SHAPE, types_##TYPES, groups_##GROUPS, \ - preds_##PREDS, aarch64_required_extensions::REQUIRED_EXTENSIONS, \ -- FPM_unused }, -+static constexpr function_group_info sme_function_groups[] = { -+#define DEF_SME_FUNCTION_GS(NAME, SHAPE, TYPES, GROUPS, PREDS) \ +- FPM_##FPM_MODE }, + { /* .base_name = */ #NAME, \ + /* .base = */ &functions::NAME, \ + /* .shape = */ &shapes::SHAPE, \ @@ gcc/config/aarch64/aarch64-sve-builtins.cc: static const predication_index preds + /* .groups = */ groups_##GROUPS, \ + /* .preds = */ preds_##PREDS, \ + /* .extensions = */ aarch64_required_extensions::REQUIRED_EXTENSIONS, \ -+ /* .fpm_mode = */ FPM_unused }, - #define DEF_SME_ZA_FUNCTION_GS(NAME, SHAPE, TYPES, GROUPS, PREDS) \ ++ /* .fpm_mode = */ FPM_##FPM_MODE }, + #define DEF_SME_ZA_FUNCTION_GS_FPM(NAME, SHAPE, TYPES, GROUPS, PREDS, FPM_MODE) \ - { #NAME, &functions::NAME##_za, &shapes::SHAPE, types_##TYPES, \ - groups_##GROUPS, preds_##PREDS, \ - aarch64_required_extensions::REQUIRED_EXTENSIONS \ -- .and_also (AARCH64_FL_ZA_ON), FPM_unused }, +- .and_also (AARCH64_FL_ZA_ON), FPM_##FPM_MODE }, + { /* .base_name = */ #NAME, \ + /* .base = */ &functions::NAME##_za, \ + /* .shape = */ &shapes::SHAPE, \ @@ gcc/config/aarch64/aarch64-sve-builtins.cc: static const predication_index preds + /* .preds = */ preds_##PREDS, \ + /* .extensions = */ aarch64_required_extensions::REQUIRED_EXTENSIONS \ + .and_also (AARCH64_FL_ZA_ON), \ -+ /* .fpm_mode = */ FPM_unused }, ++ /* .fpm_mode = */ FPM_##FPM_MODE }, #include "aarch64-sve-builtins-sme.def" }; 6: 2b67386a06f5 ! 6: 9f15847a1c0c aarch64: Make `NUM_VECTOR_TYPES` an enum member @@ Metadata Author: Karl Meakin <[email protected]> ## Commit message ## - aarch64: Make `NUM_VECTOR_TYPES` an enum member + aarch64: Make `VECTOR_TYPE_none` an enum member - Change `NUM_VECTOR_TYPES` from a preprocessor macro to an enum member of + Change `VECTOR_TYPE_none` from a preprocessor macro to an enum member of `vector_type_index` gcc/ChangeLog: 7: a880de64a791 = 7: 26a6491514c9 aarch64: Use shifts in `aarch64_type_qualifiers` enum 8: 964f070c6fe3 ! 8: 4724f2005038 aarch64: use `unspec` type for unspec codes @@ gcc/config/aarch64/aarch64-sve-builtins-base.cc: public: : while_comparison (unspec_for_sint, unspec_for_uint), m_eq_p (eq_p) {} +@@ gcc/config/aarch64/aarch64-sve-builtins-base.cc: public: + expand (function_expander &e) const override + { + if (vectors_per_tuple (e) == 1) +- return e.map_to_unspecs (-1, -1, UNSPEC_COND_FSCALE); ++ return e.map_to_unspecs (UNSPEC_NONE, UNSPEC_NONE, UNSPEC_COND_FSCALE); + else + { + machine_mode mode = GET_MODE (e.args[0]); @@ gcc/config/aarch64/aarch64-sve-builtins-base.cc: FUNCTION (svand, rtx_code_function, (AND, AND)) FUNCTION (svandv, svandv_impl,) FUNCTION (svasr, rtx_code_function, (ASHIFTRT, ASHIFTRT)) @@ gcc/config/aarch64/aarch64-sve-builtins-base.cc: FUNCTION (svrintn, svrint_impl, FUNCTION (svrintz, svrint_impl, (btrunc_optab, UNSPEC_COND_FRINTZ)) -FUNCTION (svrsqrte, unspec_based_function, (-1, UNSPEC_RSQRTE, UNSPEC_RSQRTE)) -FUNCTION (svrsqrts, unspec_based_function, (-1, -1, UNSPEC_RSQRTS)) --FUNCTION (svscale, unspec_based_function, (-1, -1, UNSPEC_COND_FSCALE)) +FUNCTION (svrsqrte, unspec_based_function, (UNSPEC_NONE, UNSPEC_RSQRTE, UNSPEC_RSQRTE)) +FUNCTION (svrsqrts, unspec_based_function, (UNSPEC_NONE, UNSPEC_NONE, UNSPEC_RSQRTS)) -+FUNCTION (svscale, unspec_based_function, (UNSPEC_NONE, UNSPEC_NONE, UNSPEC_COND_FSCALE)) + FUNCTION (svscale, svscale_impl,) FUNCTION (svsel, svsel_impl,) FUNCTION (svset2, svset_impl, (2)) - FUNCTION (svset3, svset_impl, (3)) @@ gcc/config/aarch64/aarch64-sve-builtins-base.cc: FUNCTION (svstnt1, svstnt1_impl,) FUNCTION (svsub, svsub_impl,) FUNCTION (svsubr, rtx_code_function_rotated, (MINUS, MINUS, UNSPEC_COND_FSUB)) @@ gcc/config/aarch64/aarch64-sve-builtins-functions.h: class sme_2mode_function_t using parent = read_write_za<unspec_based_function_base>; - CONSTEXPR sme_2mode_function_t (int unspec_for_sint, int unspec_for_uint, -- int unspec_for_fp) -- : parent (unspec_for_sint, unspec_for_uint, unspec_for_fp, -1, 1) -+ CONSTEXPR sme_2mode_function_t (unspec unspec_for_sint, -+ unspec unspec_for_uint, unspec unspec_for_fp) -+ : parent (unspec_for_sint, unspec_for_uint, unspec_for_fp, UNSPEC_NONE, 1) +- int unspec_for_fp, int unspec_for_mfp8 = -1) ++ CONSTEXPR sme_2mode_function_t (unspec unspec_for_sint, unspec unspec_for_uint, ++ unspec unspec_for_fp, unspec unspec_for_mfp8 = UNSPEC_NONE) + : parent (unspec_for_sint, unspec_for_uint, unspec_for_fp, unspec_for_mfp8, + 1) {} +@@ gcc/config/aarch64/aarch64-sve-builtins-functions.h: class svvdot_half_impl : public read_write_za<unspec_based_function_base> + public: + using parent = read_write_za<unspec_based_function_base>; - rtx +- CONSTEXPR svvdot_half_impl (int unspec_for_sint, int unspec_for_uint, +- int unspec_for_fp, int unspec_for_mfp8) ++ CONSTEXPR svvdot_half_impl (unspec unspec_for_sint, unspec unspec_for_uint, ++ unspec unspec_for_fp, unspec unspec_for_mfp8) + : parent (unspec_for_sint, unspec_for_uint, unspec_for_fp, unspec_for_mfp8, + 1) + {} @@ gcc/config/aarch64/aarch64-sve-builtins-functions.h: public: rtx expand (function_expander &e) const override @@ gcc/config/aarch64/aarch64-sve-builtins-sme.cc: FUNCTION (svstr_zt, svstr_zt_imp +FUNCTION (svusmops_za, sme_2mode_function, (UNSPEC_NONE, UNSPEC_SME_USMOPS, UNSPEC_NONE)) FUNCTION (svvdot_lane_za, sme_2mode_lane_function, (UNSPEC_SME_SVDOT, UNSPEC_SME_UVDOT, - UNSPEC_SME_FVDOT)) + UNSPEC_SME_FVDOT, + UNSPEC_SME_FVDOT_FP8)) + FUNCTION (svvdotb_lane_za, svvdot_half_impl, +- (-1, -1, -1, UNSPEC_SME_FVDOTB_FP8)) ++ (UNSPEC_NONE, UNSPEC_NONE, UNSPEC_NONE, UNSPEC_SME_FVDOTB_FP8)) + FUNCTION (svvdott_lane_za, svvdot_half_impl, +- (-1, -1, -1, UNSPEC_SME_FVDOTT_FP8)) ++ (UNSPEC_NONE, UNSPEC_NONE, UNSPEC_NONE, UNSPEC_SME_FVDOTT_FP8)) + FUNCTION (svwrite_za, svwrite_za_impl,) + FUNCTION (svwrite_hor_za, svwrite_za_tile_impl, (UNSPEC_SME_WRITE_HOR)) + FUNCTION (svwrite_ver_za, svwrite_za_tile_impl, (UNSPEC_SME_WRITE_VER)) ## gcc/config/aarch64/aarch64-sve-builtins-sve2.cc ## +@@ gcc/config/aarch64/aarch64-sve-builtins-sve2.cc: using namespace aarch64_sve; + namespace { + + /* Return the UNSPEC_CDOT* unspec for rotation amount ROT. */ +-static int ++static unspec + unspec_cdot (int rot) + { + switch (rot) +@@ gcc/config/aarch64/aarch64-sve-builtins-sve2.cc: unspec_cdot (int rot) + } + + /* Return the UNSPEC_SQRDCMLAH* unspec for rotation amount ROT. */ +-static int ++static unspec + unspec_sqrdcmlah (int rot) + { + switch (rot) @@ gcc/config/aarch64/aarch64-sve-builtins-sve2.cc: class svcvt_fp8_impl : public function_base { public: @@ gcc/config/aarch64/aarch64-sve-builtins-sve2.cc: namespace aarch64_sve { FUNCTION (svbsl, CODE_FOR_MODE0 (aarch64_sve2_bsl),) FUNCTION (svbsl1n, CODE_FOR_MODE0 (aarch64_sve2_bsl1n),) FUNCTION (svbsl2n, CODE_FOR_MODE0 (aarch64_sve2_bsl2n),) -@@ gcc/config/aarch64/aarch64-sve-builtins-sve2.cc: FUNCTION (svcvt2, svcvt_fp8_impl, (UNSPEC_F2CVT)) - FUNCTION (svcvtl, svcvtl_impl,) +@@ gcc/config/aarch64/aarch64-sve-builtins-sve2.cc: FUNCTION (svcvtl1, svcvt_fp8_impl, (UNSPEC_F1CVTL)) + FUNCTION (svcvtl2, svcvt_fp8_impl, (UNSPEC_F2CVTL)) FUNCTION (svcvtlt1, svcvt_fp8_impl, (UNSPEC_F1CVTLT)) FUNCTION (svcvtlt2, svcvt_fp8_impl, (UNSPEC_F2CVTLT)) -FUNCTION (svcvtlt, unspec_based_function, (-1, -1, UNSPEC_COND_FCVTLT)) @@ gcc/config/aarch64/aarch64.md ) (define_c_enum "unspec" [ -+ (UNSPEC_NONE -1) ++ UNSPEC_NONE UNSPEC_AUTIA1716 UNSPEC_AUTIB1716 UNSPEC_AUTIASP 9: ccda394d17cf ! 9: 28546fe56aa8 aarch64: Replace `UNSPEC_NONE` with optional arguments where possible @@ gcc/config/aarch64/aarch64-sve-builtins-functions.h: class sme_1mode_function : : parent (unspec_for_sint, unspec_for_uint, unspec_for_fp, UNSPEC_NONE, 1) {} -@@ gcc/config/aarch64/aarch64-sve-builtins-functions.h: public: +@@ gcc/config/aarch64/aarch64-sve-builtins-functions.h: class sme_2mode_function_t : public read_write_za<unspec_based_function_base> + public: using parent = read_write_za<unspec_based_function_base>; - CONSTEXPR sme_2mode_function_t (unspec unspec_for_sint, -- unspec unspec_for_uint, unspec unspec_for_fp) +- CONSTEXPR sme_2mode_function_t (unspec unspec_for_sint, unspec unspec_for_uint, +- unspec unspec_for_fp, unspec unspec_for_mfp8 = UNSPEC_NONE) ++ CONSTEXPR sme_2mode_function_t (unspec unspec_for_sint, + unspec unspec_for_uint = UNSPEC_NONE, -+ unspec unspec_for_fp = UNSPEC_NONE) - : parent (unspec_for_sint, unspec_for_uint, unspec_for_fp, UNSPEC_NONE, 1) ++ unspec unspec_for_fp = UNSPEC_NONE, ++ unspec unspec_for_mfp8 = UNSPEC_NONE) + : parent (unspec_for_sint, unspec_for_uint, unspec_for_fp, unspec_for_mfp8, + 1) {} - @@ gcc/config/aarch64/aarch64-sve-builtins-functions.h: public: class integer_conversion : public function_base { @@ gcc/config/aarch64/aarch64-sve-builtins-sme.cc: FUNCTION (svstr_zt, svstr_zt_imp +FUNCTION (svusmops_za, sme_2mode_function, (UNSPEC_NONE, UNSPEC_SME_USMOPS)) FUNCTION (svvdot_lane_za, sme_2mode_lane_function, (UNSPEC_SME_SVDOT, UNSPEC_SME_UVDOT, - UNSPEC_SME_FVDOT)) + UNSPEC_SME_FVDOT, ## gcc/config/aarch64/aarch64-sve-builtins-sve2.cc ## @@ gcc/config/aarch64/aarch64-sve-builtins-sve2.cc: public: -- 2.52.0
