From: Karl Meakin <[email protected]>

Use `enum unspec` rather than `int` for unspec codes.
This makes inspecting unspecs in GDB easier: unspec
values will print as their enum names rather than
their raw numeric values.

gcc/ChangeLog:

        * config/aarch64/aarch64-builtins.cc (aarch64_pragma_builtins_data):
        change type of local variable `unspec` to `enum unspec`.
        (aarch64_get_low_unspec): change return type to `enum unspec`.
        (aarch64_get_low_unspec): change type of `unspec` parameter to `enum
        unspec`.
        (aarch64_expand_tbl_tbx): change type of `unspec` parameter to
        `enum unspec`.
        (aarch64_expand_pragma_builtin): Add `default` switch branch to silence
        compiler warning.
        (aarch64_expand_fpsr_fpcr_setter): change type of `unspec` parameter to
        `enum unspecv`.
        * config/aarch64/aarch64-sve-builtins-base.cc
        (unspec_cmla): change return type to `enum unspec`.
        (unspec_fcmla): likewise.
        (unspec_cond_fcmla): likewise.
        (expand_mla_mls_lane): change type of `unspec` parameter to `enum
        unspec`.
        (svac_impl::svac_impl): change type of `unspec` parameter to `enum
        unspec`.
        (svac_impl::m_unspec): change type of `m_unspec` member to `enum
        unspec`.
        (svbic_impl::expand): delete trailing `-1` arguments to
        `map_to_rtx_codes`.
        (svbrk_binary_impl::svbrk_binary_impl): change type of `unspec`
        parameter to `enum unspec`.
        (svbrk_binary_impl::m_unspec): change type of `m_unspec` member to `enum
        unspec`.
        (svbrk_unary_impl::svbrk_unary_impl): change type of `unspec` parameter
        to `enum unspec`.
        (svbrk_unary_impl::m_unspec): change type of `m_unspec` member to `enum
        unspec`.
        (svclast_impl::svclast_impl): change type of `unspec` parameter to `enum
        unspec`.
        (svclast_impl::m_unspec): change type of `m_unspec` member to `enum
        unspec`.
        (svcmla_impl::expand): change `-1` arguments to `map_to_unspecs` to
        `UNSPEC_NONE`, and change type of `unspec` local variable to `enum
        unspec`.
        (svcmp_impl::svcmp_impl): change type of `unspec_for_fp` parameter to
        `enum unspec`.
        (svcmp_impl::m_unspec_for_fp): change type of `m_unspec_for_fp` member
        to `enum unspec`.
        (svcmp_wide_impl::svcmp_wide_impl): change type of `unspec_for_fp`
        parameter to `enum unspec`.
        (svcmp_wide_impl): change type of members to `enum unspec`.
        (svcvt_impl::expand): change type of `unspec` local variable to `enum
        unspec`.
        (svdotprod_lane_impl::expand): change type of `unspec` local variable to
        `enum unspec`.
        (svext_bhw_impl::expand): change `-1` arguments to `map_to_rtx_codes` to
        `UNSPEC_NONE`.
        (svlast_impl::svlast_impl): change type of `unspec` parameter to `enum
        unspec`.
        (svlast_impl::m_unspec): change type of `m_unspec` member to `enum
        unspec`.
        (svldxf1_impl::svldxf1_impl): change type of `unspec` parameter to `enum
        unspec`.
        (svldxf1_impl::m_unspec): change type of `m_unspec` member to `enum
        unspec`.
        (svldxf1_extend_impl::svldxf1_impl): change type of `unspec` parameter
        to `enum unspec`.
        (svldxf1_extend_impl::m_unspec): change type of `m_unspec` member to
        `enum unspec`.
        (svnot_impl): delete trailing `-1` argument to `map_to_rtx_codes`.
        (svpfirst_svpnext_impl::svpfirst_svpnext_impl): change type of `unspec`
        parameter to `enum unspec`.
        (svpfirst_svpnext_impl::m_unspec): change type of `m_unspec`
        member to `enum unspec`.
        (svrint_impl::svrint_impl): change type of `cond_unspec` parameter to
        `enum unspec`.
        (svrint_impl::expand): change `-1` arguments to `map_to_unspecs` to
        `UNSPEC_NONE`.
        (svrint_impl::m_cond_unspec): change type of `m_cond_unspec` parameter
        to `enum unspec`.
        (svsub_impl::svsub_impl): delete trailing `-1` argument to 
`map_to_rtx_codes`.
        (svunpk_impl::expand): change type of local variables `unpacku`,
        `unpacks` and `unspec` to `enum unspec`.
        (svwhilelx_impl::svwhilelx_impl): change type of parameters
        `unspec_for_sint` and `unspec_for_uint` to `enum unspec`.
        (svasrd): delete trailing `-1` arguments.
        (sveor): delete trailing `-1` arguments.
        (svexpa): change `-1` arguments to `UNSPEC_NONE`.
        (svmulh): change `-1` arguments to `UNSPEC_NONE` and delete trailing
        trailing `-1` argument.
        (svmulx): change `-1` arguments to `UNSPEC_NONE`.
        (svnmad): change `-1` arguments to `UNSPEC_NONE`.
        (svnmla): change `-1` arguments to `UNSPEC_NONE`.
        (svnmls): change `-1` arguments to `UNSPEC_NONE`.
        (svnmsb): change `-1` arguments to `UNSPEC_NONE`.
        (svqadd): delete trailing `-1` arguments.
        (svqsub): delete trailing `-1` arguments.
        (svrbit): delete trailing `-1` arguments.
        (svrecpe): change `-1` arguments to `UNSPEC_NONE`.
        (svrecps): change `-1` arguments to `UNSPEC_NONE`.
        (svrecpx): change `-1` arguments to `UNSPEC_NONE`.
        (svrevb): delete trailing `-1` arguments.
        (svrevh): delete trailing `-1` arguments.
        (svrevw): delete trailing `-1` arguments.
        (svrsqrte): change `-1` arguments to `UNSPEC_NONE`.
        (svrsqrts): change `-1` arguments to `UNSPEC_NONE`.
        (svscale): change `-1` arguments to `UNSPEC_NONE`.
        (svsudot_lane): delete trailing `-1` arguments.
        (svtsmul): change `-1` arguments to `UNSPEC_NONE`.
        (svtssel): change `-1` arguments to `UNSPEC_NONE`.
        (svsudot_lane): delete trailing `-1` arguments.
        (svusmmla): delete trailing `-1` arguments.
        * config/aarch64/aarch64-sve-builtins-functions.h:
        (rtx_code_function_base::rtx_code_function_base): change type of
        `unspec_for_cond_fp` and `unspec_for_uncond_fp` parameters to `enum
        unspec`.
        (rtx_code_function_base): change type of `m_unspec_for_cond_fp` and
        `m_unspec_for_uncond_fp` members to `enum unspec`.
        (unspec_based_function_base::unspec_based_function_base): change type of
        `unspec_for_sint`, `unspec_for_uint`, `unspec_for_fp`, and
        `unspec_for_mfp8` parameters to `enum unspec`.
        (unspec_based_function_base::unspec_for): change return type to `enum
        unspec`.
        (unspec_based_function_base): change type of `m_unspec_for_sint`,
        `m_unspec_for_uint`, `m_unspec_for_fp`, and `m_unspec_for_mfp8` members
        to `enum unspec`.
        (cond_or_uncond_unspec_function::cond_or_uncond_unspec_function): change
        type of `cond_unspec` and `uncond_unspec` parameters to `enum unspec`.
        (cond_or_uncond_unspec_function): change type of `m_cond_unspec` and
        `m_uncond_unspec` members to `enum unspec`.
        (sme_1mode_function::sme_1mode_function): change type of
        `unspec_for_sint`, `unspec_for_uint` and `unspec_for_fp` parameters to
        `enum unspec`.
        (sme_2mode_function_t::sme_2mode_function_t): change type of
        `unspec_for_sint`, `unspec_for_uint` and `unspec_for_fp` parameters to
        `enum unspec`.
        (unspec_based_fused_function::expand): change type of local variable
        `unspec` to `enum unspec`.
        (unspec_based_fused_lane_function::expand): change type of local
        variable `unspec` to `enum unspec`.
        (binary_permute::binary_permute): change type of `unspec` parameter to
        `enum unspec unspec`.
        (binary_permute): change type of `m_unspec` member to `enum unspec`.
        (multireg_permute::multireg_permute): change type of `unspec` parameter
        to `enum unspec`.
        (multireg_permute): change type of `m_unspec` member to `enum unspec`.
        (integer_conversion): change type of `unspec_for_sint`,
        `unspec_for_sintu`, `unspec_for_uint` and `unspec_for_uints` parameters
        to `enum unspec`.
        (integer_conversion): change type of `m_unspec_for_sint`,
        `m_unspec_for_sintu`, `m_unspec_for_uint` and `m_unspec_for_uints`
        members to `enum unspec`.
        (integer_conversion::integer_conversion): change type of
        `unspec_for_sint`, `unspec_for_sintu`, `unspec_for_uint` and
        `unspec_for_uints` parameters to `enum unspec`.
        (integer_conversion::expand): change type of `unspec` local variable to
        `enum unspec`.
        (integer_conversion): change type of `m_unspec_for_sint`,
        `m_unspec_for_sintu`, `m_unspec_for_uint` and `m_unspec_for_uints`
        members to `enum unspec`.
        (reduction::reduction): change type of parameter `unspec` to `enum
        unspec`.  (reduction::reduction): change type of parameters
        `unspec_for_sint`, `unspec_for_uint` and `unspec_for_fp` to `enum
        unspec`.
        (reduction::expand): change type of local variable `unspec` to `enum
        unspec`.
        (reduction): change type of members `m_unspec_for_sint`,
        `m_unspec_for_uint` and `m_unspec_for_fp` to `enum unspec`.
        (shift_wide::expand): remove trailing `-1` arguments to
        `map_to_rtx_codes`.
        (while_comparison::while_comparison): change type of parameters
        `unspec_for_sint` and `unspec_for_uint` to `enum unspec`.
        (while_comparison::expand): change type of local variable `unspec`.
        (while_comparison): change type of members `m_unspec_for_sint` and
        `m_unspec_for_uint` to `enum unspec`.
        * config/aarch64/aarch64-sve-builtins-sme.cc
        (read_write_za_base::read_write_za_base): change type of `unspec`
        parameter to `enum unspec`.
        (expand_ld1_st1): change type of `unspec` parameter to `enum unspec`.
        (svld1_za_impl::svld1_za_impl): change type of `unspec` parameter to
        `enum unspec`.
        (svld1_za_impl): change type of `m_unspec` member to
        `enum unspec`.
        (svst1_za_impl::svst1_za_impl): change type of `unspec` parameter to
        `enum unspec`.
        (svst1_za_impl): change type of `m_unspec` member to
        `enum unspec`.
        (svadd_write_za): remove trailing `-1` arguments.
        (svaddha_za): likewise.
        (svaddva_za): likewise.
        (svbmopa_za): likewise.
        (svbmops_za): likewise.
        (svsub_write_za): likewise.
        (svsudot_lane_za): likewise.
        (svsuvdot_lane_za): likewise.
        (svsumopa_za): likewise.
        (svsumops_za): likewise.
        (svusdot_za): likewise
        (svusdot_lane_za): likewise.
        (svusvdot_lane_za): likwise.
        (svusmopa_za): change `-1` argument to `UNSPEC_NONE` and remove trailing
        `-1` arguments.
        (svusmops_za): likewise.
        * config/aarch64/aarch64-sve-builtins-sve2.cc
        (svcvt_fp8_impl::svcvt_fp8_impl): change type of parameter `unspec` to
        `enum unspec`.
        (svmatch_svnmatch_impl::svmatch_svnmatch_impl): likewise.
        (svqcadd_impl::expand): delete trailing `-1` arguments to
        `map_to_unspecs`.
        (svqrshl_impl::svqrshl_impl): delete trailing `-1` argument to
        `unspec_based_function`.
        (svqshl_impl::svqshl_impl): delete trailing `-1` argument to
        `unspec_based_function`.
        (svrshl_impl::svrshl_impl): delete trailing `-1` argument to
        `unspec_based_function`.
        (svsqadd_impl::expand): delete trailing `-1` arguments to
        `map_to_rtx_codes` and change `-1` arguments to `map_to_unspecs` to
        `UNSPEC_NONE`.
        (svuqadd_impl::expand): delete trailing `-1` arguments to
        `map_to_unspecs`.
        (svwhilerw_svwhilewr_impl::svwhilerw_svwhilewr_impl): change type of
        parameter `unspec` to `enum unspec`.
        (svwhilerw_svwhilewr_impl): change type of member `m_unspec` to `enum
        unspec`.
        (faminmaximpl::faminmaximpl): change type of parameters `cond_unspec`
        and `uncond_unspec` to `enum unspec`.
        (faminmaximpl): change type of members `m_cond_unspec` and
        `m_uncond_unspec` to `enum unspec`.
        (svabalb): remove trailing `-1` arguments.
        (svabalt): likewise.
        (svabdlb): likewise.
        (svabdlt): likewise.
        (svabdlp): likewise.
        (svabclb): change `-1` arguments to `UNSPEC_NONE` and remove trailing
        `-1` arguments.
        (svabclt): likewise.
        (svaddhnb): remove trailing `-1` arguments..
        (svaddhnt): likewise.
        (svaddlb): likewise.
        (svaddlbt): likewise.
        (svaddlt): likewise.
        (svaddwb): likewise.
        (svaddwt): likewise.
        (svandqv): likewise.
        (svbdep): likewise.
        (svbdep): likewise.
        (svbext): likewise.
        (svbgrp): likewise.
        (svcvtlt): change `-1` arguments to `UNSPEC_NONE`.
        (svcvtx): likewise.
        (sveorbt): remove trailing `-1` arguments.
        (sveorqv): likewise.
        (sveortb): likewise.
        (svhadd): likewise.
        (svhsub): likewise.
        (svhsubr): likewise.
        (svlogb): change `-1` arguments to `UNSPEC_NONE`.
        (svmaxnmp): likewise.
        (svmaxnmqv): likewise.
        (svminnmp): likewise.
        (svminnmqv): likewise.
        (svmlallbb_lane): likewise.
        (svmlallbb): likewise.
        (svmlallbt_lane): likewise.
        (svmlallbt): likewise.
        (svmlalltb_lane): likewise.
        (svmlalltb): likewise.
        (svmlalltt_lane): likewise.
        (svmlalltt): likewise.
        (svmovlb): delete trailing `-1` arguments.
        (svmovlt): likewise.
        (svmullb): likewise.
        (svmullb_lane): likewise.
        (svmullt): likewise.
        (svmullt_lane): likewise.
        (svorqv): likewise.
        (svpmullb): change `-1` arguments to `UNSPEC_NONE` and delete trailing
        `-1` arguments.
        (svpmullb_pair): likewise.
        (svpmullt): likewise.
        (svpmullt_pair): likewise.
        (svqcvt): delete trailing `-1` arguments.
        (svqcvtn): likewise.
        (svqdmlalb): likewise.
        (svqdmlalb_lane): likewise.
        (svqdmlalbt): likewise.
        (svqdmlalt): likewise.
        (svqdmlalt_lane): likewise.
        (svqdmlslb): likewise.
        (svqdmlslb_lane): likewise.
        (svqdmlslt): likewise.
        (svqdmlslt_lane): likewise.
        (svqdmulh): likewise.
        (svqdmulh_lane): likewise.
        (svqdmullb): likewise.
        (svqdmullb_lane): likewise.
        (svqdmullt): likewise.
        (svqdmullt_lane): likewise.
        (svqneg): likewise.
        (svqrdmlah): likewise.
        (svqrdmlah_lane): likewise.
        (svqrdmlsh): likewise.
        (svqrdmlsh_lane): likewise.
        (svqrdmulh): likewise.
        (svqrdmulh_lane): likewise.
        (svqrshr): likewise.
        (svqrshrn): likewise.
        (svqrshrnb): likewise.
        (svqrshrnt): likewise.
        (svqrshru): likewise.
        (svqrshrun): likewise.
        (svqrshrunb): likewise.
        (svqrshrunt): likewise.
        (svqshlu): likewise.
        (svqshrnb): likewise.
        (svqshrnt): likewise.
        (svqshrunb): likewise.
        (svqshrunt): likewise.
        (svqsubr): likewise.
        (svqxtnb): likewise.
        (svqxtnt): likewise.
        (svqxtunb): likewise.
        (svqxtunt): likewise.
        (svraddhnb): likewise.
        (svraddhnt): likewise.
        (svrhadd): likewise.
        (svrshr): likewise.
        (svrshrnb): likewise.
        (svrshrnt): likewise.
        (svrsra): likewise.
        (svrsubhnb): likewise.
        (svrsubhnt): likewise.
        (svsbclb): change `-1` arguments to `UNSPEC_NONE` and delete trailing
        `-1` arguments.
        (svsbclt): likewise.
        (svshllb): delete trailing `-1` arguments.
        (svshllt): likewise.
        (svshrnb): likewise.
        (svshrnt): likewise.
        (svsli): likewise.
        (svsri): likewise.
        (svsubhnb): likewise.
        (svsubhnt): likewise.
        (svsublb): likewise.
        (svsublbt): likewise.
        (svsublt): likewise.
        (svsubltb): likewise.
        (svsubwb): likewise.
        (svsubwt): likewise.
        * config/aarch64/aarch64-sve-builtins.cc
        (function_expander::map_to_rtx_codes): change type of
        `unspec_for_cond_fp` and `unspec_for_uncond_fp` parameters to `enum
        unspec`.
        (function_expander::map_to_unspecs): change type of `unspec_for_sint`
        and `unspec_for_uint`, `unspec_for_fp` parameters to `enum unspec`.
        (function_expander::map_to_unspecs): change type local variable `unspec`
        to `enum unspec`.
        * config/aarch64/aarch64-sve-builtins.h
        (function_expander::map_to_rtx_codes): change type of parameters to
        `enum unspec`.
        (function_expander::map_to_unspecs): change type of parameters to `enum
        unspec`.
        * config/aarch64/aarch64.cc (aarch64_split_sve_subreg_move): change
        return type to `enum unspec` and change type of local variable `unspec`
        to `enum unspec`.
        (aarch64_evpc_tbl): change type of parameter `unspec.`
        * config/aarch64/aarch64.md(UNSPEC_NONE): New enum member.
---
 gcc/config/aarch64/aarch64-builtins.cc        |  14 +-
 .../aarch64/aarch64-sve-builtins-base.cc      | 185 +++++-----
 .../aarch64/aarch64-sve-builtins-functions.h  | 138 ++++----
 .../aarch64/aarch64-sve-builtins-sme.cc       |  55 +--
 .../aarch64/aarch64-sve-builtins-sve2.cc      | 316 +++++++++---------
 gcc/config/aarch64/aarch64-sve-builtins.cc    |  16 +-
 gcc/config/aarch64/aarch64-sve-builtins.h     |   9 +-
 gcc/config/aarch64/aarch64.cc                 |   8 +-
 gcc/config/aarch64/aarch64.md                 |   1 +
 9 files changed, 391 insertions(+), 351 deletions(-)

diff --git a/gcc/config/aarch64/aarch64-builtins.cc b/gcc/config/aarch64/aarch64-builtins.cc
index c1de0892d0ca..ff959904cc2e 100644
--- a/gcc/config/aarch64/aarch64-builtins.cc
+++ b/gcc/config/aarch64/aarch64-builtins.cc
@@ -1728,7 +1728,7 @@ struct aarch64_pragma_builtins_data
   const char *name;
   aarch64_builtin_signatures signature;
   simd_type types[4];
-  int unspec;
+  enum unspec unspec;
   aarch64_required_extensions required_extensions;
   unsigned int flags;
 };
@@ -3836,8 +3836,8 @@ aarch64_pack_into_v128s (expand_operand *op)
 
 /* UNSPEC is a high unspec, indicated by "2" in mnemonics and "_high" in
    intrinsic names.  Return the equivalent low unspec.  */
-static int
-aarch64_get_low_unspec (int unspec)
+static enum unspec
+aarch64_get_low_unspec (enum unspec unspec)
 {
   switch (unspec)
     {
@@ -3876,7 +3876,7 @@ aarch64_expand_permute_pair (vec<expand_operand> &ops, int permute1,
    UNSPEC is either UNSPEC_TBL or UNSPEC_TBX.  The inputs must already be in
    registers.  */
 static rtx
-aarch64_expand_tbl_tbx (vec<rtx> &inputs, int unspec, machine_mode mode)
+aarch64_expand_tbl_tbx (vec<rtx> &inputs, enum unspec unspec, machine_mode mode)
 {
   rtx result = gen_reg_rtx (mode);
   rtvec vec = gen_rtvec_v (inputs.length (), inputs.address ());
@@ -3889,7 +3889,7 @@ aarch64_expand_tbl_tbx (vec<rtx> &inputs, int unspec, machine_mode mode)
 
    UNSPEC is either UNSPEC_TBL or UNSPEC_TBX.  */
 static rtx
-aarch64_expand_tbl_tbx (vec<expand_operand> &ops, int unspec)
+aarch64_expand_tbl_tbx (vec<expand_operand> &ops, enum unspec unspec)
 {
   for (unsigned int i = 1; i < ops.length (); ++i)
     ops[i].value = force_reg (ops[i].mode, ops[i].value);
@@ -3979,6 +3979,7 @@ aarch64_expand_pragma_builtin (tree exp, rtx target,
 	 halves don't actually matter.  */
       aarch64_convert_to_v64 (&ops[1]);
       break;
+    default:;
     }
 
   insn_code icode;
@@ -4224,7 +4225,8 @@ aarch64_expand_pragma_builtin (tree exp, rtx target,
 /* Expand an expression EXP as fpsr or fpcr setter (depending on
    UNSPEC) using MODE.  */
 static void
-aarch64_expand_fpsr_fpcr_setter (int unspec, machine_mode mode, tree exp)
+aarch64_expand_fpsr_fpcr_setter (enum unspecv unspec, machine_mode mode,
+				 tree exp)
 {
   tree arg = CALL_EXPR_ARG (exp, 0);
   rtx op = force_reg (mode, expand_normal (arg));
diff --git a/gcc/config/aarch64/aarch64-sve-builtins-base.cc b/gcc/config/aarch64/aarch64-sve-builtins-base.cc
index ecc06877cac5..3713b3d4a496 100644
--- a/gcc/config/aarch64/aarch64-sve-builtins-base.cc
+++ b/gcc/config/aarch64/aarch64-sve-builtins-base.cc
@@ -73,7 +73,7 @@ is_undef (tree val)
 }
 
 /* Return the UNSPEC_CMLA* unspec for rotation amount ROT.  */
-static int
+static enum unspec
 unspec_cmla (int rot)
 {
   switch (rot)
@@ -87,7 +87,7 @@ unspec_cmla (int rot)
 }
 
 /* Return the UNSPEC_FCMLA* unspec for rotation amount ROT.  */
-static int
+static enum unspec
 unspec_fcmla (int rot)
 {
   switch (rot)
@@ -101,7 +101,7 @@ unspec_fcmla (int rot)
 }
 
 /* Return the UNSPEC_COND_FCMLA* unspec for rotation amount ROT.  */
-static int
+static enum unspec
 unspec_cond_fcmla (int rot)
 {
   switch (rot)
@@ -137,7 +137,7 @@ expand_mad (function_expander &e,
 /* Expand a call to svmla_lane or svmls_lane using floating-point unspec
    UNSPEC.  */
 static rtx
-expand_mla_mls_lane (function_expander &e, int unspec)
+expand_mla_mls_lane (function_expander &e, enum unspec unspec)
 {
   /* Put the operands in the normal (fma ...) order, with the accumulator
      last.  This fits naturally since that's also the unprinted operand
@@ -199,7 +199,8 @@ public:
 class svac_impl : public function_base
 {
 public:
-  CONSTEXPR svac_impl (int unspec) : m_unspec (unspec) {}
+  CONSTEXPR svac_impl (enum unspec unspec) : m_unspec (unspec)
+  {}
 
   gimple *
   fold (gimple_folder &f) const override
@@ -220,7 +221,7 @@ public:
   }
 
   /* The unspec code for the underlying comparison.  */
-  int m_unspec;
+  enum unspec m_unspec;
 };
 
 class svadda_impl : public function_base
@@ -308,7 +309,7 @@ public:
       {
 	machine_mode mode = GET_MODE_INNER (e.vector_mode (0));
 	e.args[2] = simplify_unary_operation (NOT, mode, e.args[2], mode);
-	return e.map_to_rtx_codes (AND, AND, -1, -1);
+	return e.map_to_rtx_codes (AND, AND);
       }
 
     if (e.type_suffix_ids[0] == TYPE_SUFFIX_b)
@@ -328,7 +329,8 @@ public:
 class svbrk_binary_impl : public function_base
 {
 public:
-  CONSTEXPR svbrk_binary_impl (int unspec) : m_unspec (unspec) {}
+  CONSTEXPR svbrk_binary_impl (enum unspec unspec) : m_unspec (unspec)
+  {}
 
   rtx
   expand (function_expander &e) const override
@@ -337,14 +339,15 @@ public:
   }
 
   /* The unspec code associated with the operation.  */
-  int m_unspec;
+  enum unspec m_unspec;
 };
 
 /* Implements svbrka and svbrkb.  */
 class svbrk_unary_impl : public function_base
 {
 public:
-  CONSTEXPR svbrk_unary_impl (int unspec) : m_unspec (unspec) {}
+  CONSTEXPR svbrk_unary_impl (enum unspec unspec) : m_unspec (unspec)
+  {}
 
   rtx
   expand (function_expander &e) const override
@@ -353,7 +356,7 @@ public:
   }
 
   /* The unspec code associated with the operation.  */
-  int m_unspec;
+  enum unspec m_unspec;
 };
 
 class svcadd_impl : public function_base
@@ -378,7 +381,8 @@ public:
 class svclast_impl : public quiet<function_base>
 {
 public:
-  CONSTEXPR svclast_impl (int unspec) : m_unspec (unspec) {}
+  CONSTEXPR svclast_impl (enum unspec unspec) : m_unspec (unspec)
+  {}
 
   gimple *
   fold (gimple_folder &f) const override
@@ -403,7 +407,7 @@ public:
   }
 
   /* The unspec code associated with the operation.  */
-  int m_unspec;
+  enum unspec m_unspec;
 };
 
 class svcmla_impl : public function_base
@@ -419,12 +423,13 @@ public:
 	/* Make the operand order the same as the one used by the fma optabs,
 	   with the accumulator last.  */
 	e.rotate_inputs_left (1, 4);
-	return e.map_to_unspecs (-1, -1, unspec_cond_fcmla (rot), 3);
+	return e.map_to_unspecs (UNSPEC_NONE, UNSPEC_NONE,
+				 unspec_cond_fcmla (rot), 3);
       }
     else
       {
-	int cmla = unspec_cmla (rot);
-	return e.map_to_unspecs (cmla, cmla, -1);
+	enum unspec cmla = unspec_cmla (rot);
+	return e.map_to_unspecs (cmla, cmla);
       }
   }
 };
@@ -458,8 +463,9 @@ public:
 class svcmp_impl : public function_base
 {
 public:
-  CONSTEXPR svcmp_impl (tree_code code, int unspec_for_fp)
-    : m_code (code), m_unspec_for_fp (unspec_for_fp) {}
+  CONSTEXPR svcmp_impl (tree_code code, enum unspec unspec_for_fp)
+    : m_code (code), m_unspec_for_fp (unspec_for_fp)
+  {}
 
   gimple *
   fold (gimple_folder &f) const override
@@ -509,17 +515,18 @@ public:
   tree_code m_code;
 
   /* The unspec code to use for floating-point comparisons.  */
-  int m_unspec_for_fp;
+  enum unspec m_unspec_for_fp;
 };
 
 /* Implements svcmp<cc>_wide.  */
 class svcmp_wide_impl : public function_base
 {
 public:
-  CONSTEXPR svcmp_wide_impl (tree_code code, int unspec_for_sint,
-			     int unspec_for_uint)
+  CONSTEXPR svcmp_wide_impl (tree_code code, enum unspec unspec_for_sint,
+			     enum unspec unspec_for_uint)
     : m_code (code), m_unspec_for_sint (unspec_for_sint),
-      m_unspec_for_uint (unspec_for_uint) {}
+      m_unspec_for_uint (unspec_for_uint)
+  {}
 
   gimple *
   fold (gimple_folder &f) const override
@@ -552,7 +559,7 @@ public:
 	return e.use_exact_insn (icode);
       }
 
-    int unspec = (unsigned_p ? m_unspec_for_uint : m_unspec_for_sint);
+    enum unspec unspec = (unsigned_p ? m_unspec_for_uint : m_unspec_for_sint);
     return e.use_exact_insn (code_for_aarch64_pred_cmp_wide (unspec, mode));
   }
 
@@ -561,8 +568,8 @@ public:
 
   /* The unspec codes for signed and unsigned wide comparisons
      respectively.  */
-  int m_unspec_for_sint;
-  int m_unspec_for_uint;
+  enum unspec m_unspec_for_sint;
+  enum unspec m_unspec_for_uint;
 };
 
 class svcmpuo_impl : public quiet<function_base>
@@ -816,9 +823,9 @@ public:
        the source mode before the destination mode.  */
     if (e.type_suffix (1).integer_p)
       {
-	int unspec = (e.type_suffix (1).unsigned_p
-		      ? UNSPEC_COND_UCVTF
-		      : UNSPEC_COND_SCVTF);
+	enum unspec unspec = (e.type_suffix (1).unsigned_p
+				? UNSPEC_COND_UCVTF
+				: UNSPEC_COND_SCVTF);
 	if (e.type_suffix (0).element_bytes <= e.type_suffix (1).element_bytes)
 	  icode = (e.pred == PRED_x
 		   ? code_for_aarch64_sve_nonextend (unspec, mode1, mode0)
@@ -830,9 +837,10 @@ public:
       }
     else
       {
-	int unspec = (!e.type_suffix (0).integer_p ? UNSPEC_COND_FCVT
-		      : e.type_suffix (0).unsigned_p ? UNSPEC_COND_FCVTZU
-		      : UNSPEC_COND_FCVTZS);
+	enum unspec unspec
+	  = (!e.type_suffix (0).integer_p   ? UNSPEC_COND_FCVT
+	     : e.type_suffix (0).unsigned_p ? UNSPEC_COND_FCVTZU
+					    : UNSPEC_COND_FCVTZS);
 	if (e.type_suffix (0).element_bytes >= e.type_suffix (1).element_bytes)
 	  icode = (e.pred == PRED_x
 		   ? code_for_aarch64_sve_nontrunc (unspec, mode1, mode0)
@@ -994,7 +1002,7 @@ public:
 	/* Use the same ordering as the dot_prod_optab, with the
 	   accumulator last.  */
 	e.rotate_inputs_left (0, 4);
-	int unspec = unspec_for (e);
+	enum unspec unspec = unspec_for (e);
 	if (unspec == UNSPEC_FDOT)
 	  icode = CODE_FOR_aarch64_fdot_prod_lanevnx4sfvnx8hf;
 	else
@@ -1318,7 +1326,7 @@ public:
 	     with an extra argument on the end.  Take the inactive elements
 	     from this extra argument.  */
 	  e.rotate_inputs_left (0, 4);
-	return e.map_to_rtx_codes (AND, AND, -1, -1, 3);
+	return e.map_to_rtx_codes (AND, AND, UNSPEC_NONE, UNSPEC_NONE, 3);
       }
 
     machine_mode wide_mode = e.vector_mode (0);
@@ -1530,7 +1538,8 @@ public:
 class svlast_impl : public quiet<function_base>
 {
 public:
-  CONSTEXPR svlast_impl (int unspec) : m_unspec (unspec) {}
+  CONSTEXPR svlast_impl (enum unspec unspec) : m_unspec (unspec)
+  {}
 
   bool is_lasta () const { return m_unspec == UNSPEC_LASTA; }
   bool is_lastb () const { return m_unspec == UNSPEC_LASTB; }
@@ -1660,7 +1669,7 @@ public:
   }
 
   /* The unspec code associated with the operation.  */
-  int m_unspec;
+  enum unspec m_unspec;
 };
 
 class svld1_impl : public full_width_access
@@ -2019,7 +2028,8 @@ public:
 class svldxf1_impl : public full_width_access
 {
 public:
-  CONSTEXPR svldxf1_impl (int unspec) : m_unspec (unspec) {}
+  CONSTEXPR svldxf1_impl (enum unspec unspec) : m_unspec (unspec)
+  {}
 
   unsigned int
   call_properties (const function_instance &) const override
@@ -2039,15 +2049,17 @@ public:
   }
 
   /* The unspec associated with the load.  */
-  int m_unspec;
+  enum unspec m_unspec;
 };
 
 /* Implements extending contiguous forms of svldff1 and svldnf1.  */
 class svldxf1_extend_impl : public extending_load
 {
 public:
-  CONSTEXPR svldxf1_extend_impl (type_suffix_index memory_type, int unspec)
-    : extending_load (memory_type), m_unspec (unspec) {}
+  CONSTEXPR svldxf1_extend_impl (type_suffix_index memory_type,
+				 enum unspec unspec)
+    : extending_load (memory_type), m_unspec (unspec)
+  {}
 
   unsigned int
   call_properties (const function_instance &) const override
@@ -2069,7 +2081,7 @@ public:
   }
 
   /* The unspec associated with the load.  */
-  int m_unspec;
+  enum unspec m_unspec;
 };
 
 class svlen_impl : public quiet<function_base>
@@ -2425,7 +2437,8 @@ public:
 class svnot_impl : public rtx_code_function
 {
 public:
-  CONSTEXPR svnot_impl () : rtx_code_function (NOT, NOT, -1) {}
+  CONSTEXPR svnot_impl () : rtx_code_function (NOT, NOT)
+  {}
 
   rtx
   expand (function_expander &e) const override
@@ -2490,7 +2503,8 @@ public:
 class svpfirst_svpnext_impl : public function_base
 {
 public:
-  CONSTEXPR svpfirst_svpnext_impl (int unspec) : m_unspec (unspec) {}
+  CONSTEXPR svpfirst_svpnext_impl (enum unspec unspec) : m_unspec (unspec)
+  {}
   gimple *
   fold (gimple_folder &f) const override
   {
@@ -2511,7 +2525,7 @@ public:
   }
 
   /* The unspec associated with the operation.  */
-  int m_unspec;
+  enum unspec m_unspec;
 };
 
 /* Implements contiguous forms of svprf[bhwd].  */
@@ -2885,7 +2899,7 @@ public:
 class svrint_impl : public function_base
 {
 public:
-  CONSTEXPR svrint_impl (optab_tag optab, int cond_unspec)
+  CONSTEXPR svrint_impl (optab_tag optab, enum unspec cond_unspec)
     : m_optab (optab), m_cond_unspec (cond_unspec)
   {}
 
@@ -2897,11 +2911,11 @@ public:
 	auto icode = direct_optab_handler (m_optab, e.tuple_mode (0));
 	return e.use_exact_insn (icode);
       }
-    return e.map_to_unspecs (-1, -1, m_cond_unspec);
+    return e.map_to_unspecs (UNSPEC_NONE, UNSPEC_NONE, m_cond_unspec);
   }
 
   optab_tag m_optab;
-  int m_cond_unspec;
+  enum unspec m_cond_unspec;
 };
 
 class svsel_impl : public quiet<function_base>
@@ -3193,7 +3207,7 @@ public:
     /* Canonicalize subtractions of constants to additions.  */
     machine_mode mode = e.vector_mode (0);
     if (e.try_negating_argument (2, mode))
-      return e.map_to_rtx_codes (PLUS, PLUS, UNSPEC_COND_FADD, -1);
+      return e.map_to_rtx_codes (PLUS, PLUS, UNSPEC_COND_FADD);
 
     return rtx_code_function::expand (e);
   }
@@ -3265,14 +3279,14 @@ public:
   expand (function_expander &e) const override
   {
     machine_mode mode = GET_MODE (e.args[0]);
-    unsigned int unpacku = m_high_p ? UNSPEC_UNPACKUHI : UNSPEC_UNPACKULO;
-    unsigned int unpacks = m_high_p ? UNSPEC_UNPACKSHI : UNSPEC_UNPACKSLO;
+    enum unspec unpacku = m_high_p ? UNSPEC_UNPACKUHI : UNSPEC_UNPACKULO;
+    enum unspec unpacks = m_high_p ? UNSPEC_UNPACKSHI : UNSPEC_UNPACKSLO;
     insn_code icode;
     if (GET_MODE_CLASS (mode) == MODE_VECTOR_BOOL)
       icode = code_for_aarch64_sve_punpk_acle (unpacku);
     else
       {
-	int unspec = e.type_suffix (0).unsigned_p ? unpacku : unpacks;
+	enum unspec unspec = e.type_suffix (0).unsigned_p ? unpacku : unpacks;
 	icode = code_for_aarch64_sve_unpk (unspec, unspec, mode);
       }
     return e.use_exact_insn (icode);
@@ -3337,7 +3351,8 @@ public:
 class svwhilelx_impl : public while_comparison
 {
 public:
-  CONSTEXPR svwhilelx_impl (int unspec_for_sint, int unspec_for_uint, bool eq_p)
+  CONSTEXPR svwhilelx_impl (enum unspec unspec_for_sint,
+			    enum unspec unspec_for_uint, bool eq_p)
     : while_comparison (unspec_for_sint, unspec_for_uint), m_eq_p (eq_p)
   {}
 
@@ -3480,7 +3495,7 @@ FUNCTION (svand, rtx_code_function, (AND, AND))
 FUNCTION (svandv, svandv_impl,)
 FUNCTION (svasr, rtx_code_function, (ASHIFTRT, ASHIFTRT))
 FUNCTION (svasr_wide, shift_wide, (ASHIFTRT, UNSPEC_ASHIFTRT_WIDE))
-FUNCTION (svasrd, unspec_based_function, (UNSPEC_ASRD, -1, -1))
+FUNCTION (svasrd, unspec_based_function, (UNSPEC_ASRD))
 FUNCTION (svbfdot, fixed_insn_function, (CODE_FOR_aarch64_sve_bfdotvnx4sf))
 FUNCTION (svbfdot_lane, fixed_insn_function,
 	  (CODE_FOR_aarch64_sve_bfdot_lanevnx4sf))
@@ -3549,9 +3564,10 @@ FUNCTION (svdup, svdup_impl,)
 FUNCTION (svdup_lane, svdup_lane_impl,)
 FUNCTION (svdupq, svdupq_impl,)
 FUNCTION (svdupq_lane, svdupq_lane_impl,)
-FUNCTION (sveor, rtx_code_function, (XOR, XOR, -1))
+FUNCTION (sveor, rtx_code_function, (XOR, XOR))
 FUNCTION (sveorv, sveorv_impl,)
-FUNCTION (svexpa, unspec_based_function, (-1, -1, UNSPEC_FEXPA))
+FUNCTION (svexpa, unspec_based_function,
+	  (UNSPEC_NONE, UNSPEC_NONE, UNSPEC_FEXPA))
 FUNCTION (svext, QUIET_CODE_FOR_MODE0 (aarch64_sve_ext),)
 FUNCTION (svextb, svext_bhw_impl, (QImode))
 FUNCTION (svexth, svext_bhw_impl, (HImode))
@@ -3631,15 +3647,20 @@ FUNCTION (svmov, svmov_impl,)
 FUNCTION (svmsb, svmsb_impl,)
 FUNCTION (svmul, svmul_impl,)
 FUNCTION (svmul_lane, CODE_FOR_MODE0 (aarch64_mul_lane),)
-FUNCTION (svmulh, unspec_based_function, (UNSPEC_SMUL_HIGHPART,
-					  UNSPEC_UMUL_HIGHPART, -1))
-FUNCTION (svmulx, unspec_based_function, (-1, -1, UNSPEC_COND_FMULX))
+FUNCTION (svmulh, unspec_based_function,
+	  (UNSPEC_SMUL_HIGHPART, UNSPEC_UMUL_HIGHPART))
+FUNCTION (svmulx, unspec_based_function,
+	  (UNSPEC_NONE, UNSPEC_NONE, UNSPEC_COND_FMULX))
 FUNCTION (svnand, svnand_impl,)
 FUNCTION (svneg, quiet<rtx_code_function>, (NEG, NEG, UNSPEC_COND_FNEG))
-FUNCTION (svnmad, unspec_based_function, (-1, -1, UNSPEC_COND_FNMLA))
-FUNCTION (svnmla, unspec_based_function_rotated, (-1, -1, UNSPEC_COND_FNMLA))
-FUNCTION (svnmls, unspec_based_function_rotated, (-1, -1, UNSPEC_COND_FNMLS))
-FUNCTION (svnmsb, unspec_based_function, (-1, -1, UNSPEC_COND_FNMLS))
+FUNCTION (svnmad, unspec_based_function,
+	  (UNSPEC_NONE, UNSPEC_NONE, UNSPEC_COND_FNMLA))
+FUNCTION (svnmla, unspec_based_function_rotated,
+	  (UNSPEC_NONE, UNSPEC_NONE, UNSPEC_COND_FNMLA))
+FUNCTION (svnmls, unspec_based_function_rotated,
+	  (UNSPEC_NONE, UNSPEC_NONE, UNSPEC_COND_FNMLS))
+FUNCTION (svnmsb, unspec_based_function,
+	  (UNSPEC_NONE, UNSPEC_NONE, UNSPEC_COND_FNMLS))
 FUNCTION (svnor, svnor_impl,)
 FUNCTION (svnot, svnot_impl,)
 FUNCTION (svorn, svorn_impl,)
@@ -3661,7 +3682,7 @@ FUNCTION (svptest_first, svptest_impl, (LT))
 FUNCTION (svptest_last, svptest_impl, (LTU))
 FUNCTION (svptrue, svptrue_impl,)
 FUNCTION (svptrue_pat, svptrue_pat_impl,)
-FUNCTION (svqadd, rtx_code_function, (SS_PLUS, US_PLUS, -1))
+FUNCTION (svqadd, rtx_code_function, (SS_PLUS, US_PLUS))
 FUNCTION (svqdecb, svqdec_bhwd_impl, (QImode))
 FUNCTION (svqdecb_pat, svqdec_bhwd_impl, (QImode))
 FUNCTION (svqdecd, svqdec_bhwd_impl, (DImode))
@@ -3680,17 +3701,20 @@ FUNCTION (svqinch_pat, svqinc_bhwd_impl, (HImode))
 FUNCTION (svqincp, svqdecp_svqincp_impl, (SS_PLUS, US_PLUS))
 FUNCTION (svqincw, svqinc_bhwd_impl, (SImode))
 FUNCTION (svqincw_pat, svqinc_bhwd_impl, (SImode))
-FUNCTION (svqsub, rtx_code_function, (SS_MINUS, US_MINUS, -1))
-FUNCTION (svrbit, rtx_code_function, (BITREVERSE, BITREVERSE, -1))
+FUNCTION (svqsub, rtx_code_function, (SS_MINUS, US_MINUS))
+FUNCTION (svrbit, rtx_code_function, (BITREVERSE, BITREVERSE))
 FUNCTION (svrdffr, svrdffr_impl,)
-FUNCTION (svrecpe, unspec_based_function, (-1, UNSPEC_URECPE, UNSPEC_FRECPE))
-FUNCTION (svrecps, unspec_based_function, (-1, -1, UNSPEC_FRECPS))
-FUNCTION (svrecpx, unspec_based_function, (-1, -1, UNSPEC_COND_FRECPX))
+FUNCTION (svrecpe, unspec_based_function,
+	  (UNSPEC_NONE, UNSPEC_URECPE, UNSPEC_FRECPE))
+FUNCTION (svrecps, unspec_based_function,
+	  (UNSPEC_NONE, UNSPEC_NONE, UNSPEC_FRECPS))
+FUNCTION (svrecpx, unspec_based_function,
+	  (UNSPEC_NONE, UNSPEC_NONE, UNSPEC_COND_FRECPX))
 FUNCTION (svreinterpret, svreinterpret_impl,)
 FUNCTION (svrev, svrev_impl,)
-FUNCTION (svrevb, unspec_based_function, (UNSPEC_REVB, UNSPEC_REVB, -1))
-FUNCTION (svrevh, unspec_based_function, (UNSPEC_REVH, UNSPEC_REVH, -1))
-FUNCTION (svrevw, unspec_based_function, (UNSPEC_REVW, UNSPEC_REVW, -1))
+FUNCTION (svrevb, unspec_based_function, (UNSPEC_REVB, UNSPEC_REVB))
+FUNCTION (svrevh, unspec_based_function, (UNSPEC_REVH, UNSPEC_REVH))
+FUNCTION (svrevw, unspec_based_function, (UNSPEC_REVW, UNSPEC_REVW))
 FUNCTION (svrinta, svrint_impl, (round_optab, UNSPEC_COND_FRINTA))
 FUNCTION (svrinti, svrint_impl, (nearbyint_optab, UNSPEC_COND_FRINTI))
 FUNCTION (svrintm, svrint_impl, (floor_optab, UNSPEC_COND_FRINTM))
@@ -3698,9 +3722,12 @@ FUNCTION (svrintn, svrint_impl, (roundeven_optab, UNSPEC_COND_FRINTN))
 FUNCTION (svrintp, svrint_impl, (ceil_optab, UNSPEC_COND_FRINTP))
 FUNCTION (svrintx, svrint_impl, (rint_optab, UNSPEC_COND_FRINTX))
 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 (svsel, svsel_impl,)
 FUNCTION (svset2, svset_impl, (2))
 FUNCTION (svset3, svset_impl, (3))
@@ -3723,7 +3750,7 @@ FUNCTION (svstnt1, svstnt1_impl,)
 FUNCTION (svsub, svsub_impl,)
 FUNCTION (svsubr, rtx_code_function_rotated, (MINUS, MINUS, UNSPEC_COND_FSUB))
 FUNCTION (svsudot, svusdot_impl, (true))
-FUNCTION (svsudot_lane, svdotprod_lane_impl, (UNSPEC_SUDOT, -1, -1))
+FUNCTION (svsudot_lane, svdotprod_lane_impl, (UNSPEC_SUDOT))
 FUNCTION (svtbl, quiet<unspec_based_uncond_function>, (UNSPEC_TBL, UNSPEC_TBL,
 						       UNSPEC_TBL))
 FUNCTION (svtmad, CODE_FOR_MODE0 (aarch64_sve_tmad),)
@@ -3733,8 +3760,10 @@ FUNCTION (svtrn1q, unspec_based_function, (UNSPEC_TRN1Q, UNSPEC_TRN1Q,
 FUNCTION (svtrn2, svtrn_impl, (1))
 FUNCTION (svtrn2q, unspec_based_function, (UNSPEC_TRN2Q, UNSPEC_TRN2Q,
 					   UNSPEC_TRN2Q))
-FUNCTION (svtsmul, unspec_based_function, (-1, -1, UNSPEC_FTSMUL))
-FUNCTION (svtssel, unspec_based_function, (-1, -1, UNSPEC_FTSSEL))
+FUNCTION (svtsmul, unspec_based_function,
+	  (UNSPEC_NONE, UNSPEC_NONE, UNSPEC_FTSMUL))
+FUNCTION (svtssel, unspec_based_function,
+	  (UNSPEC_NONE, UNSPEC_NONE, UNSPEC_FTSSEL))
 FUNCTION (svundef, svundef_impl, (1))
 FUNCTION (svundef2, svundef_impl, (2))
 FUNCTION (svundef3, svundef_impl, (3))
@@ -3742,8 +3771,8 @@ FUNCTION (svundef4, svundef_impl, (4))
 FUNCTION (svunpkhi, svunpk_impl, (true))
 FUNCTION (svunpklo, svunpk_impl, (false))
 FUNCTION (svusdot, svusdot_impl, (false))
-FUNCTION (svusdot_lane, svdotprod_lane_impl, (UNSPEC_USDOT, -1, -1))
-FUNCTION (svusmmla, unspec_based_add_function, (UNSPEC_USMATMUL, -1, -1))
+FUNCTION (svusdot_lane, svdotprod_lane_impl, (UNSPEC_USDOT))
+FUNCTION (svusmmla, unspec_based_add_function, (UNSPEC_USMATMUL))
 FUNCTION (svuzp1, svuzp_impl, (0))
 FUNCTION (svuzp1q, unspec_based_function, (UNSPEC_UZP1Q, UNSPEC_UZP1Q,
 					   UNSPEC_UZP1Q))
diff --git a/gcc/config/aarch64/aarch64-sve-builtins-functions.h b/gcc/config/aarch64/aarch64-sve-builtins-functions.h
index c05946d4ec73..64e95b78f772 100644
--- a/gcc/config/aarch64/aarch64-sve-builtins-functions.h
+++ b/gcc/config/aarch64/aarch64-sve-builtins-functions.h
@@ -201,13 +201,15 @@ public:
 class rtx_code_function_base : public function_base
 {
 public:
-  CONSTEXPR rtx_code_function_base (rtx_code code_for_sint,
-				    rtx_code code_for_uint,
-				    int unspec_for_cond_fp = -1,
-				    int unspec_for_uncond_fp = -1)
+  CONSTEXPR
+  rtx_code_function_base (rtx_code code_for_sint,
+			  rtx_code code_for_uint,
+			  enum unspec unspec_for_cond_fp = UNSPEC_NONE,
+			  enum unspec unspec_for_uncond_fp = UNSPEC_NONE)
     : m_code_for_sint (code_for_sint), m_code_for_uint (code_for_uint),
       m_unspec_for_cond_fp (unspec_for_cond_fp),
-      m_unspec_for_uncond_fp (unspec_for_uncond_fp) {}
+      m_unspec_for_uncond_fp (unspec_for_uncond_fp)
+  {}
 
   /* The rtx code to use for signed and unsigned integers respectively.
      Can be UNKNOWN for functions that don't have integer forms.  */
@@ -216,11 +218,11 @@ public:
 
   /* The UNSPEC_COND_* to use for floating-point operations.  Can be -1
      for functions that only operate on integers.  */
-  int m_unspec_for_cond_fp;
+  enum unspec m_unspec_for_cond_fp;
 
   /* The UNSPEC_* to use for unpredicated floating-point operations.
      Can be -1 if there is no such operation.  */
-  int m_unspec_for_uncond_fp;
+  enum unspec m_unspec_for_uncond_fp;
 };
 
 /* A function_base for functions that have an associated rtx code.
@@ -267,21 +269,19 @@ public:
 class unspec_based_function_base : public function_base
 {
 public:
-  CONSTEXPR unspec_based_function_base (int unspec_for_sint,
-					int unspec_for_uint,
-					int unspec_for_fp,
-					int unspec_for_mfp8 = -1,
-					unsigned int suffix_index = 0)
-    : m_unspec_for_sint (unspec_for_sint),
-      m_unspec_for_uint (unspec_for_uint),
-      m_unspec_for_fp (unspec_for_fp),
-      m_unspec_for_mfp8 (unspec_for_mfp8),
+  CONSTEXPR unspec_based_function_base (
+    enum unspec unspec_for_sint,
+    enum unspec unspec_for_uint = UNSPEC_NONE,
+    enum unspec unspec_for_fp = UNSPEC_NONE,
+    enum unspec unspec_for_mfp8 = UNSPEC_NONE,
+    unsigned int suffix_index = 0)
+    : m_unspec_for_sint (unspec_for_sint), m_unspec_for_uint (unspec_for_uint),
+      m_unspec_for_fp (unspec_for_fp), m_unspec_for_mfp8 (unspec_for_mfp8),
       m_suffix_index (suffix_index)
   {}
 
   /* Return the unspec code to use for INSTANCE, based on type suffix 0.  */
-  int
-  unspec_for (const function_instance &instance) const
+  enum unspec unspec_for (const function_instance &instance) const
   {
     if (instance.fpm_mode == FPM_set)
       return m_unspec_for_mfp8;
@@ -294,10 +294,10 @@ public:
 
   /* The unspec code associated with signed-integer, unsigned-integer
      and floating-point operations respectively.  */
-  int m_unspec_for_sint;
-  int m_unspec_for_uint;
-  int m_unspec_for_fp;
-  int m_unspec_for_mfp8;
+  enum unspec m_unspec_for_sint;
+  enum unspec m_unspec_for_uint;
+  enum unspec m_unspec_for_fp;
+  enum unspec m_unspec_for_mfp8;
 
   /* Which type suffix is used to choose between the unspecs.  */
   unsigned int m_suffix_index;
@@ -402,8 +402,10 @@ typedef unspec_based_function_exact_insn<code_for_aarch64_sve_sub_lane>
 class cond_or_uncond_unspec_function : public function_base
 {
 public:
-  CONSTEXPR cond_or_uncond_unspec_function (int cond_unspec, int uncond_unspec)
-    : m_cond_unspec (cond_unspec), m_uncond_unspec (uncond_unspec) {}
+  CONSTEXPR cond_or_uncond_unspec_function (enum unspec cond_unspec,
+					    enum unspec uncond_unspec)
+    : m_cond_unspec (cond_unspec), m_uncond_unspec (uncond_unspec)
+  {}
 
   rtx
   expand (function_expander &e) const override
@@ -421,8 +423,8 @@ public:
 
   /* The unspecs for the conditional and unconditional instructions,
      respectively.  */
-  int m_cond_unspec;
-  int m_uncond_unspec;
+  enum unspec m_cond_unspec;
+  enum unspec m_uncond_unspec;
 };
 
 /* General SME unspec-based functions, parameterized on the vector mode.  */
@@ -431,9 +433,10 @@ class sme_1mode_function : public read_write_za<unspec_based_function_base>
 public:
   using parent = read_write_za<unspec_based_function_base>;
 
-  CONSTEXPR sme_1mode_function (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_1mode_function (enum unspec unspec_for_sint,
+				enum unspec unspec_for_uint = UNSPEC_NONE,
+				enum unspec unspec_for_fp = UNSPEC_NONE)
+    : parent (unspec_for_sint, unspec_for_uint, unspec_for_fp)
   {}
 
   rtx
@@ -461,9 +464,10 @@ 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 (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 (enum unspec unspec_for_sint,
+				  enum unspec unspec_for_uint = UNSPEC_NONE,
+				  enum unspec unspec_for_fp = UNSPEC_NONE)
+    : parent (unspec_for_sint, unspec_for_uint, unspec_for_fp, UNSPEC_NONE, 1)
   {}
 
   rtx
@@ -500,7 +504,7 @@ public:
   rtx
   expand (function_expander &e) const override
   {
-    int unspec = unspec_for (e);
+    enum unspec unspec = unspec_for (e);
     insn_code icode;
     if (e.type_suffix (m_suffix_index).float_p
 	&& e.fpm_mode != FPM_set)
@@ -531,7 +535,7 @@ public:
   rtx
   expand (function_expander &e) const override
   {
-    int unspec = unspec_for (e);
+    enum unspec unspec = unspec_for (e);
     insn_code icode;
     if (e.type_suffix (m_suffix_index).float_p
 	&& e.fpm_mode != FPM_set)
@@ -625,7 +629,8 @@ public:
 class binary_permute : public permute
 {
 public:
-  CONSTEXPR binary_permute (int unspec) : m_unspec (unspec) {}
+  CONSTEXPR binary_permute (enum unspec unspec) : m_unspec (unspec)
+  {}
 
   rtx
   expand (function_expander &e) const override
@@ -638,7 +643,7 @@ public:
   }
 
   /* The unspec code associated with the operation.  */
-  int m_unspec;
+  enum unspec m_unspec;
 };
 
 /* A function that implements a x2 or x4 permute instruction.  Both forms
@@ -647,7 +652,8 @@ public:
 class multireg_permute : public function_base
 {
 public:
-  CONSTEXPR multireg_permute (int unspec) : m_unspec (unspec) {}
+  CONSTEXPR multireg_permute (enum unspec unspec) : m_unspec (unspec)
+  {}
 
   rtx
   expand (function_expander &e) const override
@@ -665,7 +671,7 @@ public:
   }
 
   /* The unspec associated with the permutation.  */
-  int m_unspec;
+  enum unspec m_unspec;
 };
 
 /* A function that has two type integer type suffixes, which might agree
@@ -674,12 +680,15 @@ public:
 class integer_conversion : public function_base
 {
 public:
-  CONSTEXPR integer_conversion (int unspec_for_sint, int unspec_for_sintu,
-				int unspec_for_uint, int unspec_for_uints)
+  CONSTEXPR
+  integer_conversion (enum unspec unspec_for_sint,
+		      enum unspec unspec_for_sintu,
+		      enum unspec unspec_for_uint,
+		      enum unspec unspec_for_uints = UNSPEC_NONE)
     : m_unspec_for_sint (unspec_for_sint),
       m_unspec_for_sintu (unspec_for_sintu),
       m_unspec_for_uint (unspec_for_uint),
-      m_unspec_for_uints (unspec_for_uints)
+       m_unspec_for_uints (unspec_for_uints)
   {}
 
   rtx
@@ -687,7 +696,7 @@ public:
   {
     machine_mode mode0 = e.vector_mode (0);
     machine_mode mode1 = GET_MODE (e.args[0]);
-    int unspec;
+    enum unspec unspec;
     if (e.type_suffix (0).unsigned_p == e.type_suffix (1).unsigned_p)
       unspec = (e.type_suffix (0).unsigned_p
 		? m_unspec_for_uint
@@ -700,30 +709,31 @@ public:
   }
 
   /* The unspec for signed -> signed.  */
-  int m_unspec_for_sint;
+  enum unspec m_unspec_for_sint;
 
   /* The unspec for signed -> unsigned.  */
-  int m_unspec_for_sintu;
+  enum unspec m_unspec_for_sintu;
 
   /* The unspec for unsigned -> signed.  */
-  int m_unspec_for_uint;
+  enum unspec m_unspec_for_uint;
 
   /* The unspec for unsigned -> unsigned.  */
-  int m_unspec_for_uints;
+  enum unspec m_unspec_for_uints;
 };
 
 /* A function_base for functions that reduce a vector to a scalar.  */
 class reduction : public function_base
 {
 public:
-  CONSTEXPR reduction (int unspec)
+  CONSTEXPR reduction (enum unspec unspec)
     : m_unspec_for_sint (unspec),
       m_unspec_for_uint (unspec),
       m_unspec_for_fp (unspec)
   {}
 
-  CONSTEXPR reduction (int unspec_for_sint, int unspec_for_uint,
-		       int unspec_for_fp)
+  CONSTEXPR reduction (enum unspec unspec_for_sint,
+		       enum unspec unspec_for_uint,
+		       enum unspec unspec_for_fp = UNSPEC_NONE)
     : m_unspec_for_sint (unspec_for_sint),
       m_unspec_for_uint (unspec_for_uint),
       m_unspec_for_fp (unspec_for_fp)
@@ -733,9 +743,9 @@ public:
   expand (function_expander &e) const override
   {
     machine_mode mode = e.vector_mode (0);
-    int unspec = (!e.type_suffix (0).integer_p ? m_unspec_for_fp
-		  : e.type_suffix (0).unsigned_p ? m_unspec_for_uint
-		  : m_unspec_for_sint);
+    enum unspec unspec = (!e.type_suffix (0).integer_p	 ? m_unspec_for_fp
+			  : e.type_suffix (0).unsigned_p ? m_unspec_for_uint
+							 : m_unspec_for_sint);
     /* There's no distinction between SADDV and UADDV for 64-bit elements;
        the signed versions only exist for narrower elements.  */
     if (GET_MODE_UNIT_BITSIZE (mode) == 64 && unspec == UNSPEC_SADDV)
@@ -745,9 +755,9 @@ public:
 
   /* The unspec code associated with signed-integer, unsigned-integer
      and floating-point operations respectively.  */
-  int m_unspec_for_sint;
-  int m_unspec_for_uint;
-  int m_unspec_for_fp;
+  enum unspec m_unspec_for_sint;
+  enum unspec m_unspec_for_uint;
+  enum unspec m_unspec_for_fp;
 };
 
 /* A function_base for functions that shift narrower-than-64-bit values
@@ -770,7 +780,7 @@ public:
     if (aarch64_simd_shift_imm_p (shift, elem_mode, m_code == ASHIFT))
       {
 	e.args.last () = shift;
-	return e.map_to_rtx_codes (m_code, m_code, -1, -1);
+	return e.map_to_rtx_codes (m_code, m_code);
       }
 
     if (e.pred == PRED_x)
@@ -813,9 +823,9 @@ public:
 class while_comparison : public function_base
 {
 public:
-  CONSTEXPR while_comparison (int unspec_for_sint, int unspec_for_uint)
-    : m_unspec_for_sint (unspec_for_sint),
-      m_unspec_for_uint (unspec_for_uint)
+  CONSTEXPR while_comparison (enum unspec unspec_for_sint,
+			      enum unspec unspec_for_uint)
+    : m_unspec_for_sint (unspec_for_sint), m_unspec_for_uint (unspec_for_uint)
   {}
 
   rtx
@@ -823,9 +833,9 @@ public:
   {
     /* Suffix 0 determines the predicate mode, suffix 1 determines the
        scalar mode and signedness.  */
-    int unspec = (e.type_suffix (1).unsigned_p
-		  ? m_unspec_for_uint
-		  : m_unspec_for_sint);
+    enum unspec unspec = (e.type_suffix (1).unsigned_p
+			  ? m_unspec_for_uint
+			  : m_unspec_for_sint);
     if (e.vectors_per_tuple () > 1)
       {
 	auto bits = e.type_suffix (0).element_bits;
@@ -847,8 +857,8 @@ public:
 
   /* The unspec codes associated with signed and unsigned operations
      respectively.  */
-  int m_unspec_for_sint;
-  int m_unspec_for_uint;
+  enum unspec m_unspec_for_sint;
+  enum unspec m_unspec_for_uint;
 };
 
 }
diff --git a/gcc/config/aarch64/aarch64-sve-builtins-sme.cc b/gcc/config/aarch64/aarch64-sve-builtins-sme.cc
index 4657e29ad64b..11522f59a445 100644
--- a/gcc/config/aarch64/aarch64-sve-builtins-sme.cc
+++ b/gcc/config/aarch64/aarch64-sve-builtins-sme.cc
@@ -60,7 +60,8 @@ public:
 class read_write_za_base : public function_base
 {
 public:
-  constexpr read_write_za_base (int unspec) : m_unspec (unspec) {}
+  constexpr read_write_za_base (enum unspec unspec) : m_unspec (unspec)
+  {}
 
   rtx
   expand (function_expander &e) const override
@@ -176,7 +177,7 @@ expand_ldr_str_zt0 (function_expander &e, insn_code icode)
    IS_LOAD is true if E is a load, false if it is a store.  */
 
 static rtx
-expand_ld1_st1 (function_expander &e, int unspec, bool is_load)
+expand_ld1_st1 (function_expander &e, enum unspec unspec, bool is_load)
 {
   bool is_vnum = has_in_range_vnum_arg (e, e.vector_mode (0), 4);
   auto icode = (is_vnum
@@ -298,7 +299,8 @@ public:
 class svld1_za_impl : public load_za_base
 {
 public:
-  constexpr svld1_za_impl (int unspec) : m_unspec (unspec) {}
+  constexpr svld1_za_impl (enum unspec unspec) : m_unspec (unspec)
+  {}
 
   rtx
   expand (function_expander &e) const override
@@ -306,7 +308,7 @@ public:
     return expand_ld1_st1 (e, m_unspec, true);
   }
 
-  int m_unspec;
+  enum unspec m_unspec;
 };
 
 class svldr_za_impl : public load_za_base
@@ -404,7 +406,8 @@ using svreadz_za_tile_impl = add_call_properties<read_write_za_base,
 class svst1_za_impl : public store_za_base
 {
 public:
-  constexpr svst1_za_impl (int unspec) : m_unspec (unspec) {}
+  constexpr svst1_za_impl (enum unspec unspec) : m_unspec (unspec)
+  {}
 
   rtx
   expand (function_expander &e) const override
@@ -412,7 +415,7 @@ public:
     return expand_ld1_st1 (e, m_unspec, false);
   }
 
-  int m_unspec;
+  enum unspec m_unspec;
 };
 
 class svstr_za_impl : public store_za_base
@@ -615,14 +618,12 @@ FUNCTION (arm_has_sme, arm_has_sme_impl, )
 FUNCTION (arm_in_streaming_mode, arm_in_streaming_mode_impl, )
 FUNCTION (svadd_za, sme_1mode_function, (UNSPEC_SME_ADD, UNSPEC_SME_ADD,
 					 UNSPEC_SME_FADD))
-FUNCTION (svadd_write_za, sme_1mode_function, (UNSPEC_SME_ADD_WRITE,
-					       UNSPEC_SME_ADD_WRITE, -1))
-FUNCTION (svaddha_za, sme_1mode_function, (UNSPEC_SME_ADDHA,
-					   UNSPEC_SME_ADDHA, -1))
-FUNCTION (svaddva_za, sme_1mode_function, (UNSPEC_SME_ADDVA,
-					  UNSPEC_SME_ADDVA, -1))
-FUNCTION (svbmopa_za, sme_2mode_function, (-1, UNSPEC_SME_BMOPA, -1))
-FUNCTION (svbmops_za, sme_2mode_function, (-1, UNSPEC_SME_BMOPS, -1))
+FUNCTION (svadd_write_za, sme_1mode_function,
+	  (UNSPEC_SME_ADD_WRITE, UNSPEC_SME_ADD_WRITE))
+FUNCTION (svaddha_za, sme_1mode_function, (UNSPEC_SME_ADDHA, UNSPEC_SME_ADDHA))
+FUNCTION (svaddva_za, sme_1mode_function, (UNSPEC_SME_ADDVA, UNSPEC_SME_ADDVA))
+FUNCTION (svbmopa_za, sme_2mode_function, (UNSPEC_NONE, UNSPEC_SME_BMOPA))
+FUNCTION (svbmops_za, sme_2mode_function, (UNSPEC_NONE, UNSPEC_SME_BMOPS))
 FUNCTION (svcntsb, svcnts_bhwd_impl, (VNx16QImode))
 FUNCTION (svcntsd, svcnts_bhwd_impl, (VNx2DImode))
 FUNCTION (svcntsh, svcnts_bhwd_impl, (VNx8HImode))
@@ -665,21 +666,21 @@ FUNCTION (svstr_za, svstr_za_impl, )
 FUNCTION (svstr_zt, svstr_zt_impl, )
 FUNCTION (svsub_za, sme_1mode_function, (UNSPEC_SME_SUB, UNSPEC_SME_SUB,
 					 UNSPEC_SME_FSUB))
-FUNCTION (svsub_write_za, sme_1mode_function, (UNSPEC_SME_SUB_WRITE,
-					       UNSPEC_SME_SUB_WRITE, -1))
+FUNCTION (svsub_write_za, sme_1mode_function,
+	  (UNSPEC_SME_SUB_WRITE, UNSPEC_SME_SUB_WRITE))
 FUNCTION (svsudot_za, svsudot_za_impl,)
-FUNCTION (svsudot_lane_za, sme_2mode_lane_function, (UNSPEC_SME_SUDOT, -1, -1))
-FUNCTION (svsuvdot_lane_za, sme_2mode_lane_function, (UNSPEC_SME_SUVDOT,
-						      -1, -1))
-FUNCTION (svsumopa_za, sme_2mode_function, (UNSPEC_SME_SUMOPA, -1, -1))
-FUNCTION (svsumops_za, sme_2mode_function, (UNSPEC_SME_SUMOPS, -1, -1))
+FUNCTION (svsudot_lane_za, sme_2mode_lane_function, (UNSPEC_SME_SUDOT))
+FUNCTION (svsuvdot_lane_za, sme_2mode_lane_function, (UNSPEC_SME_SUVDOT))
+FUNCTION (svsumopa_za, sme_2mode_function, (UNSPEC_SME_SUMOPA))
+FUNCTION (svsumops_za, sme_2mode_function, (UNSPEC_SME_SUMOPS))
 FUNCTION (svundef_za, svundef_za_impl, )
-FUNCTION (svusdot_za, sme_2mode_function, (-1, UNSPEC_SME_USDOT, -1))
-FUNCTION (svusdot_lane_za, sme_2mode_lane_function, (-1, UNSPEC_SME_USDOT, -1))
-FUNCTION (svusvdot_lane_za, sme_2mode_lane_function, (-1, UNSPEC_SME_USVDOT,
-						      -1))
-FUNCTION (svusmopa_za, sme_2mode_function, (-1, UNSPEC_SME_USMOPA, -1))
-FUNCTION (svusmops_za, sme_2mode_function, (-1, UNSPEC_SME_USMOPS, -1))
+FUNCTION (svusdot_za, sme_2mode_function, (UNSPEC_NONE, UNSPEC_SME_USDOT))
+FUNCTION (svusdot_lane_za, sme_2mode_lane_function,
+	  (UNSPEC_NONE, UNSPEC_SME_USDOT))
+FUNCTION (svusvdot_lane_za, sme_2mode_lane_function,
+	  (UNSPEC_NONE, UNSPEC_SME_USVDOT))
+FUNCTION (svusmopa_za, sme_2mode_function, (UNSPEC_NONE, UNSPEC_SME_USMOPA))
+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))
diff --git a/gcc/config/aarch64/aarch64-sve-builtins-sve2.cc b/gcc/config/aarch64/aarch64-sve-builtins-sve2.cc
index 95c5ed81d610..f417b2288cfb 100644
--- a/gcc/config/aarch64/aarch64-sve-builtins-sve2.cc
+++ b/gcc/config/aarch64/aarch64-sve-builtins-sve2.cc
@@ -225,7 +225,8 @@ class svcvt_fp8_impl : public function_base
 {
 public:
   CONSTEXPR
-  svcvt_fp8_impl (int unspec) : m_unspec (unspec) {}
+  svcvt_fp8_impl (enum unspec unspec) : m_unspec (unspec)
+  {}
 
   rtx
   expand (function_expander &e) const override
@@ -234,7 +235,7 @@ public:
     return e.use_exact_insn (icode);
   }
 
-  int m_unspec;
+  enum unspec m_unspec;
 };
 
 class svcvtn_impl : public function_base
@@ -401,7 +402,8 @@ public:
 class svmatch_svnmatch_impl : public function_base
 {
 public:
-  CONSTEXPR svmatch_svnmatch_impl (int unspec) : m_unspec (unspec) {}
+  CONSTEXPR svmatch_svnmatch_impl (enum unspec unspec) : m_unspec (unspec)
+  {}
   gimple *
   fold (gimple_folder &f) const override
   {
@@ -504,9 +506,9 @@ public:
     /* Convert the rotation amount into a specific unspec.  */
     int rot = INTVAL (e.args.pop ());
     if (rot == 90)
-      return e.map_to_unspecs (UNSPEC_SQCADD90, -1, -1);
+      return e.map_to_unspecs (UNSPEC_SQCADD90);
     if (rot == 270)
-      return e.map_to_unspecs (UNSPEC_SQCADD270, -1, -1);
+      return e.map_to_unspecs (UNSPEC_SQCADD270);
     gcc_unreachable ();
   }
 };
@@ -541,7 +543,8 @@ class svqrshl_impl : public unspec_based_function
 {
 public:
   CONSTEXPR svqrshl_impl ()
-    : unspec_based_function (UNSPEC_SQRSHL, UNSPEC_UQRSHL, -1) {}
+    : unspec_based_function (UNSPEC_SQRSHL, UNSPEC_UQRSHL)
+    {}
 
   gimple *
   fold (gimple_folder &f) const override
@@ -576,8 +579,8 @@ public:
 class svqshl_impl : public unspec_based_function
 {
 public:
-  CONSTEXPR svqshl_impl ()
-    : unspec_based_function (UNSPEC_SQSHL, UNSPEC_UQSHL, -1) {}
+  CONSTEXPR svqshl_impl () : unspec_based_function (UNSPEC_SQSHL, UNSPEC_UQSHL)
+  {}
 
   gimple *
   fold (gimple_folder &f) const override
@@ -613,8 +616,8 @@ public:
 class svrshl_impl : public unspec_based_function
 {
 public:
-  CONSTEXPR svrshl_impl ()
-    : unspec_based_function (UNSPEC_SRSHL, UNSPEC_URSHL, -1) {}
+  CONSTEXPR svrshl_impl () : unspec_based_function (UNSPEC_SRSHL, UNSPEC_URSHL)
+  {}
 
   gimple *
   fold (gimple_folder &f) const override
@@ -664,8 +667,8 @@ public:
     machine_mode mode = e.vector_mode (0);
     if (e.pred == PRED_x
 	&& aarch64_sve_sqadd_sqsub_immediate_p (mode, e.args[2], false))
-      return e.map_to_rtx_codes (UNKNOWN, US_PLUS, -1, -1);
-    return e.map_to_unspecs (-1, UNSPEC_USQADD, -1);
+      return e.map_to_rtx_codes (UNKNOWN, US_PLUS);
+    return e.map_to_unspecs (UNSPEC_NONE, UNSPEC_USQADD);
   }
 };
 
@@ -837,7 +840,7 @@ public:
     if (e.pred == PRED_x
 	&& aarch64_sve_arith_immediate_p (mode, e.args[2], false))
       return e.use_unpred_insn (code_for_aarch64_sve_suqadd_const (mode));
-    return e.map_to_unspecs (UNSPEC_SUQADD, -1, -1);
+    return e.map_to_unspecs (UNSPEC_SUQADD);
   }
 };
 
@@ -874,7 +877,8 @@ public:
 class svwhilerw_svwhilewr_impl : public full_width_access
 {
 public:
-  CONSTEXPR svwhilerw_svwhilewr_impl (int unspec) : m_unspec (unspec) {}
+  CONSTEXPR svwhilerw_svwhilewr_impl (enum unspec unspec) : m_unspec (unspec)
+  {}
 
   rtx
   expand (function_expander &e) const override
@@ -886,7 +890,7 @@ public:
     return e.use_exact_insn (icode);
   }
 
-  int m_unspec;
+  enum unspec m_unspec;
 };
 
 /* Implements svzipq1 and svzipq2.  */
@@ -937,7 +941,7 @@ public:
 class faminmaximpl : public function_base
 {
 public:
-  CONSTEXPR faminmaximpl (int cond_unspec, int uncond_unspec)
+  CONSTEXPR faminmaximpl (enum unspec cond_unspec, enum unspec uncond_unspec)
     : m_cond_unspec (cond_unspec), m_uncond_unspec (uncond_unspec)
     {}
 
@@ -966,8 +970,8 @@ public:
 
   /* The unspecs for the conditional and unconditional instructions,
      respectively.  */
-  int m_cond_unspec;
-  int m_uncond_unspec;
+  enum unspec m_cond_unspec;
+  enum unspec m_uncond_unspec;
 };
 
 } /* end anonymous namespace */
@@ -975,42 +979,40 @@ public:
 namespace aarch64_sve {
 
 FUNCTION (svaba, svaba_impl,)
-FUNCTION (svabalb, unspec_based_add_function, (UNSPEC_SABDLB,
-					       UNSPEC_UABDLB, -1))
-FUNCTION (svabalt, unspec_based_add_function, (UNSPEC_SABDLT,
-					       UNSPEC_UABDLT, -1))
-FUNCTION (svabdlb, unspec_based_function, (UNSPEC_SABDLB, UNSPEC_UABDLB, -1))
-FUNCTION (svabdlt, unspec_based_function, (UNSPEC_SABDLT, UNSPEC_UABDLT, -1))
-FUNCTION (svadalp, unspec_based_function, (UNSPEC_SADALP, UNSPEC_UADALP, -1))
-FUNCTION (svadclb, unspec_based_function, (-1, UNSPEC_ADCLB, -1))
-FUNCTION (svadclt, unspec_based_function, (-1, UNSPEC_ADCLT, -1))
-FUNCTION (svaddhnb, unspec_based_function, (UNSPEC_ADDHNB, UNSPEC_ADDHNB, -1))
-FUNCTION (svaddhnt, unspec_based_function, (UNSPEC_ADDHNT, UNSPEC_ADDHNT, -1))
-FUNCTION (svaddlb, unspec_based_function, (UNSPEC_SADDLB, UNSPEC_UADDLB, -1))
-FUNCTION (svaddlbt, unspec_based_function, (UNSPEC_SADDLBT, -1, -1))
-FUNCTION (svaddlt, unspec_based_function, (UNSPEC_SADDLT, UNSPEC_UADDLT, -1))
+FUNCTION (svabalb, unspec_based_add_function, (UNSPEC_SABDLB, UNSPEC_UABDLB))
+FUNCTION (svabalt, unspec_based_add_function, (UNSPEC_SABDLT, UNSPEC_UABDLT))
+FUNCTION (svabdlb, unspec_based_function, (UNSPEC_SABDLB, UNSPEC_UABDLB))
+FUNCTION (svabdlt, unspec_based_function, (UNSPEC_SABDLT, UNSPEC_UABDLT))
+FUNCTION (svadalp, unspec_based_function, (UNSPEC_SADALP, UNSPEC_UADALP))
+FUNCTION (svadclb, unspec_based_function, (UNSPEC_NONE, UNSPEC_ADCLB))
+FUNCTION (svadclt, unspec_based_function, (UNSPEC_NONE, UNSPEC_ADCLT))
+FUNCTION (svaddhnb, unspec_based_function, (UNSPEC_ADDHNB, UNSPEC_ADDHNB))
+FUNCTION (svaddhnt, unspec_based_function, (UNSPEC_ADDHNT, UNSPEC_ADDHNT))
+FUNCTION (svaddlb, unspec_based_function, (UNSPEC_SADDLB, UNSPEC_UADDLB))
+FUNCTION (svaddlbt, unspec_based_function, (UNSPEC_SADDLBT))
+FUNCTION (svaddlt, unspec_based_function, (UNSPEC_SADDLT, UNSPEC_UADDLT))
 FUNCTION (svaddp, unspec_based_pred_function, (UNSPEC_ADDP, UNSPEC_ADDP,
 					       UNSPEC_FADDP))
 FUNCTION (svaddqv, reduction, (UNSPEC_ADDQV, UNSPEC_ADDQV, UNSPEC_FADDQV))
-FUNCTION (svaddwb, unspec_based_function, (UNSPEC_SADDWB, UNSPEC_UADDWB, -1))
-FUNCTION (svaddwt, unspec_based_function, (UNSPEC_SADDWT, UNSPEC_UADDWT, -1))
+FUNCTION (svaddwb, unspec_based_function, (UNSPEC_SADDWB, UNSPEC_UADDWB))
+FUNCTION (svaddwt, unspec_based_function, (UNSPEC_SADDWT, UNSPEC_UADDWT))
 FUNCTION (svaesd, fixed_insn_function, (CODE_FOR_aarch64_sve2_aesd))
 FUNCTION (svaese, fixed_insn_function, (CODE_FOR_aarch64_sve2_aese))
 FUNCTION (svaesimc, fixed_insn_function, (CODE_FOR_aarch64_sve2_aesimc))
 FUNCTION (svaesmc, fixed_insn_function, (CODE_FOR_aarch64_sve2_aesmc))
 FUNCTION (svamax, faminmaximpl, (UNSPEC_COND_FAMAX, UNSPEC_FAMAX))
 FUNCTION (svamin, faminmaximpl, (UNSPEC_COND_FAMIN, UNSPEC_FAMIN))
-FUNCTION (svandqv, reduction, (UNSPEC_ANDQV, UNSPEC_ANDQV, -1))
+FUNCTION (svandqv, reduction, (UNSPEC_ANDQV, UNSPEC_ANDQV))
 FUNCTION (svbcax, CODE_FOR_MODE0 (aarch64_sve2_bcax),)
-FUNCTION (svbdep, unspec_based_function, (UNSPEC_BDEP, UNSPEC_BDEP, -1))
-FUNCTION (svbext, unspec_based_function, (UNSPEC_BEXT, UNSPEC_BEXT, -1))
+FUNCTION (svbdep, unspec_based_function, (UNSPEC_BDEP, UNSPEC_BDEP))
+FUNCTION (svbext, unspec_based_function, (UNSPEC_BEXT, UNSPEC_BEXT))
 FUNCTION (svbfmlslb, fixed_insn_function, (CODE_FOR_aarch64_sve_bfmlslbvnx4sf))
 FUNCTION (svbfmlslb_lane, fixed_insn_function,
 	  (CODE_FOR_aarch64_sve_bfmlslb_lanevnx4sf))
 FUNCTION (svbfmlslt, fixed_insn_function, (CODE_FOR_aarch64_sve_bfmlsltvnx4sf))
 FUNCTION (svbfmlslt_lane, fixed_insn_function,
 	  (CODE_FOR_aarch64_sve_bfmlslt_lanevnx4sf))
-FUNCTION (svbgrp, unspec_based_function, (UNSPEC_BGRP, UNSPEC_BGRP, -1))
+FUNCTION (svbgrp, unspec_based_function, (UNSPEC_BGRP, UNSPEC_BGRP))
 FUNCTION (svbsl, CODE_FOR_MODE0 (aarch64_sve2_bsl),)
 FUNCTION (svbsl1n, CODE_FOR_MODE0 (aarch64_sve2_bsl1n),)
 FUNCTION (svbsl2n, CODE_FOR_MODE0 (aarch64_sve2_bsl2n),)
@@ -1022,23 +1024,24 @@ FUNCTION (svcvt2, svcvt_fp8_impl, (UNSPEC_F2CVT))
 FUNCTION (svcvtl, svcvtl_impl,)
 FUNCTION (svcvtlt1, svcvt_fp8_impl, (UNSPEC_F1CVTLT))
 FUNCTION (svcvtlt2, svcvt_fp8_impl, (UNSPEC_F2CVTLT))
-FUNCTION (svcvtlt, unspec_based_function, (-1, -1, UNSPEC_COND_FCVTLT))
+FUNCTION (svcvtlt, unspec_based_function,
+	  (UNSPEC_NONE, UNSPEC_NONE, UNSPEC_COND_FCVTLT))
 FUNCTION (svcvtn, svcvtn_impl,)
 FUNCTION (svcvtnb, fixed_insn_function, (CODE_FOR_aarch64_sve2_fp8_cvtnbvnx16qi))
-FUNCTION (svcvtx, unspec_based_function, (-1, -1, UNSPEC_COND_FCVTX))
+FUNCTION (svcvtx, unspec_based_function,
+	  (UNSPEC_NONE, UNSPEC_NONE, UNSPEC_COND_FCVTX))
 FUNCTION (svcvtxnt, svcvtxnt_impl,)
 FUNCTION (svdup_laneq, svdup_laneq_impl,)
 FUNCTION (sveor3, CODE_FOR_MODE0 (aarch64_sve2_eor3),)
-FUNCTION (sveorbt, unspec_based_function, (UNSPEC_EORBT, UNSPEC_EORBT, -1))
-FUNCTION (sveorqv, reduction, (UNSPEC_EORQV, UNSPEC_EORQV, -1))
-FUNCTION (sveortb, unspec_based_function, (UNSPEC_EORTB, UNSPEC_EORTB, -1))
+FUNCTION (sveorbt, unspec_based_function, (UNSPEC_EORBT, UNSPEC_EORBT))
+FUNCTION (sveorqv, reduction, (UNSPEC_EORQV, UNSPEC_EORQV))
+FUNCTION (sveortb, unspec_based_function, (UNSPEC_EORTB, UNSPEC_EORTB))
 FUNCTION (svextq, svextq_impl,)
-FUNCTION (svhadd, unspec_based_function, (UNSPEC_SHADD, UNSPEC_UHADD, -1))
-FUNCTION (svhsub, unspec_based_function, (UNSPEC_SHSUB, UNSPEC_UHSUB, -1))
+FUNCTION (svhadd, unspec_based_function, (UNSPEC_SHADD, UNSPEC_UHADD))
+FUNCTION (svhsub, unspec_based_function, (UNSPEC_SHSUB, UNSPEC_UHSUB))
 FUNCTION (svhistcnt, CODE_FOR_MODE0 (aarch64_sve2_histcnt),)
 FUNCTION (svhistseg, CODE_FOR_MODE0 (aarch64_sve2_histseg),)
-FUNCTION (svhsubr, unspec_based_function_rotated, (UNSPEC_SHSUB,
-						   UNSPEC_UHSUB, -1))
+FUNCTION (svhsubr, unspec_based_function_rotated, (UNSPEC_SHSUB, UNSPEC_UHSUB))
 FUNCTION (svld1q_gather, svld1q_gather_impl,)
 FUNCTION (svld1udq, svld1uxq_impl, (VNx1DImode))
 FUNCTION (svld1uwq, svld1uxq_impl, (VNx1SImode))
@@ -1052,15 +1055,18 @@ FUNCTION (svldnt1sw_gather, svldnt1_gather_extend_impl, (TYPE_SUFFIX_s32))
 FUNCTION (svldnt1ub_gather, svldnt1_gather_extend_impl, (TYPE_SUFFIX_u8))
 FUNCTION (svldnt1uh_gather, svldnt1_gather_extend_impl, (TYPE_SUFFIX_u16))
 FUNCTION (svldnt1uw_gather, svldnt1_gather_extend_impl, (TYPE_SUFFIX_u32))
-FUNCTION (svlogb, unspec_based_function, (-1, -1, UNSPEC_COND_FLOGB))
+FUNCTION (svlogb, unspec_based_function,
+	  (UNSPEC_NONE, UNSPEC_NONE, UNSPEC_COND_FLOGB))
 FUNCTION (svmatch, svmatch_svnmatch_impl, (UNSPEC_MATCH))
-FUNCTION (svmaxnmp, unspec_based_pred_function, (-1, -1, UNSPEC_FMAXNMP))
-FUNCTION (svmaxnmqv, reduction, (-1, -1, UNSPEC_FMAXNMQV))
+FUNCTION (svmaxnmp, unspec_based_pred_function,
+	  (UNSPEC_NONE, UNSPEC_NONE, UNSPEC_FMAXNMP))
+FUNCTION (svmaxnmqv, reduction, (UNSPEC_NONE, UNSPEC_NONE, UNSPEC_FMAXNMQV))
 FUNCTION (svmaxp, unspec_based_pred_function, (UNSPEC_SMAXP, UNSPEC_UMAXP,
 					       UNSPEC_FMAXP))
 FUNCTION (svmaxqv, reduction, (UNSPEC_SMAXQV, UNSPEC_UMAXQV, UNSPEC_FMAXQV))
-FUNCTION (svminnmp, unspec_based_pred_function, (-1, -1, UNSPEC_FMINNMP))
-FUNCTION (svminnmqv, reduction, (-1, -1, UNSPEC_FMINNMQV))
+FUNCTION (svminnmp, unspec_based_pred_function,
+	  (UNSPEC_NONE, UNSPEC_NONE, UNSPEC_FMINNMP))
+FUNCTION (svminnmqv, reduction, (UNSPEC_NONE, UNSPEC_NONE, UNSPEC_FMINNMQV))
 FUNCTION (svminp, unspec_based_pred_function, (UNSPEC_SMINP, UNSPEC_UMINP,
 					       UNSPEC_FMINP))
 FUNCTION (svminqv, reduction, (UNSPEC_SMINQV, UNSPEC_UMINQV, UNSPEC_FMINQV))
@@ -1071,21 +1077,21 @@ FUNCTION (svmlalb, unspec_based_mla_function,
 	  (UNSPEC_SMULLB, UNSPEC_UMULLB, UNSPEC_FMLALB,
 	   UNSPEC_FMLALB_FP8))
 FUNCTION (svmlallbb_lane, unspec_based_mla_lane_function,
-	  (-1, -1, -1, UNSPEC_FMLALLBB_FP8))
+	  (UNSPEC_NONE, UNSPEC_NONE, UNSPEC_NONE, UNSPEC_FMLALLBB_FP8))
 FUNCTION (svmlallbb, unspec_based_mla_function,
-	  (-1, -1, -1, UNSPEC_FMLALLBB_FP8))
+	  (UNSPEC_NONE, UNSPEC_NONE, UNSPEC_NONE, UNSPEC_FMLALLBB_FP8))
 FUNCTION (svmlallbt_lane, unspec_based_mla_lane_function,
-	  (-1, -1, -1, UNSPEC_FMLALLBT_FP8))
+	  (UNSPEC_NONE, UNSPEC_NONE, UNSPEC_NONE, UNSPEC_FMLALLBT_FP8))
 FUNCTION (svmlallbt, unspec_based_mla_function,
-	  (-1, -1, -1, UNSPEC_FMLALLBT_FP8))
+	  (UNSPEC_NONE, UNSPEC_NONE, UNSPEC_NONE, UNSPEC_FMLALLBT_FP8))
 FUNCTION (svmlalltb_lane, unspec_based_mla_lane_function,
-	  (-1, -1, -1, UNSPEC_FMLALLTB_FP8))
+	  (UNSPEC_NONE, UNSPEC_NONE, UNSPEC_NONE, UNSPEC_FMLALLTB_FP8))
 FUNCTION (svmlalltb, unspec_based_mla_function,
-	  (-1, -1, -1, UNSPEC_FMLALLTB_FP8))
+	  (UNSPEC_NONE, UNSPEC_NONE, UNSPEC_NONE, UNSPEC_FMLALLTB_FP8))
 FUNCTION (svmlalltt_lane, unspec_based_mla_lane_function,
-	  (-1, -1, -1, UNSPEC_FMLALLTT_FP8))
+	  (UNSPEC_NONE, UNSPEC_NONE, UNSPEC_NONE, UNSPEC_FMLALLTT_FP8))
 FUNCTION (svmlalltt, unspec_based_mla_function,
-	  (-1, -1, -1, UNSPEC_FMLALLTT_FP8))
+	  (UNSPEC_NONE, UNSPEC_NONE, UNSPEC_NONE, UNSPEC_FMLALLTT_FP8))
 FUNCTION (svmlalt_lane, unspec_based_mla_lane_function,
 	  (UNSPEC_SMULLT, UNSPEC_UMULLT, UNSPEC_FMLALT,
 	   UNSPEC_FMLALT_FP8))
@@ -1102,121 +1108,105 @@ FUNCTION (svmlslt, unspec_based_mls_function, (UNSPEC_SMULLT,
 FUNCTION (svmlslt_lane, unspec_based_mls_lane_function, (UNSPEC_SMULLT,
 							 UNSPEC_UMULLT,
 							 UNSPEC_FMLSLT))
-FUNCTION (svmovlb, svmovl_lb_impl, (UNSPEC_SSHLLB, UNSPEC_USHLLB, -1))
-FUNCTION (svmovlt, svmovl_lb_impl, (UNSPEC_SSHLLT, UNSPEC_USHLLT, -1))
-FUNCTION (svmullb, unspec_based_function, (UNSPEC_SMULLB, UNSPEC_UMULLB, -1))
-FUNCTION (svmullb_lane, unspec_based_lane_function, (UNSPEC_SMULLB,
-						     UNSPEC_UMULLB, -1))
-FUNCTION (svmullt, unspec_based_function, (UNSPEC_SMULLT, UNSPEC_UMULLT, -1))
-FUNCTION (svmullt_lane, unspec_based_lane_function, (UNSPEC_SMULLT,
-						     UNSPEC_UMULLT, -1))
+FUNCTION (svmovlb, svmovl_lb_impl, (UNSPEC_SSHLLB, UNSPEC_USHLLB))
+FUNCTION (svmovlt, svmovl_lb_impl, (UNSPEC_SSHLLT, UNSPEC_USHLLT))
+FUNCTION (svmullb, unspec_based_function, (UNSPEC_SMULLB, UNSPEC_UMULLB))
+FUNCTION (svmullb_lane, unspec_based_lane_function,
+	  (UNSPEC_SMULLB, UNSPEC_UMULLB))
+FUNCTION (svmullt, unspec_based_function, (UNSPEC_SMULLT, UNSPEC_UMULLT))
+FUNCTION (svmullt_lane, unspec_based_lane_function,
+	  (UNSPEC_SMULLT, UNSPEC_UMULLT))
 FUNCTION (svnbsl, CODE_FOR_MODE0 (aarch64_sve2_nbsl),)
 FUNCTION (svnmatch, svmatch_svnmatch_impl, (UNSPEC_NMATCH))
-FUNCTION (svorqv, reduction, (UNSPEC_ORQV, UNSPEC_ORQV, -1))
+FUNCTION (svorqv, reduction, (UNSPEC_ORQV, UNSPEC_ORQV))
 FUNCTION (svpext_lane, svpext_lane_impl,)
 FUNCTION (svpmov, svpmov_impl,)
 FUNCTION (svpmov_lane, svpmov_lane_impl,)
 FUNCTION (svpmul, CODE_FOR_MODE0 (aarch64_sve2_pmul),)
-FUNCTION (svpmullb, unspec_based_function, (-1, UNSPEC_PMULLB, -1))
-FUNCTION (svpmullb_pair, unspec_based_function, (-1, UNSPEC_PMULLB_PAIR, -1))
-FUNCTION (svpmullt, unspec_based_function, (-1, UNSPEC_PMULLT, -1))
-FUNCTION (svpmullt_pair, unspec_based_function, (-1, UNSPEC_PMULLT_PAIR, -1))
+FUNCTION (svpmullb, unspec_based_function, (UNSPEC_PMULLB))
+FUNCTION (svpmullb_pair, unspec_based_function,
+	  (UNSPEC_NONE, UNSPEC_PMULLB_PAIR))
+FUNCTION (svpmullt, unspec_based_function, (UNSPEC_NONE, UNSPEC_PMULLT))
+FUNCTION (svpmullt_pair, unspec_based_function,
+	  (UNSPEC_NONE, UNSPEC_PMULLT_PAIR))
 FUNCTION (svpsel_lane, svpsel_lane_impl,)
-FUNCTION (svqabs, rtx_code_function, (SS_ABS, UNKNOWN, UNKNOWN))
+FUNCTION (svqabs, rtx_code_function, (SS_ABS,UNKNOWN))
 FUNCTION (svqcadd, svqcadd_impl,)
-FUNCTION (svqcvt, integer_conversion, (UNSPEC_SQCVT, UNSPEC_SQCVTU,
-				       UNSPEC_UQCVT, -1))
-FUNCTION (svqcvtn, integer_conversion, (UNSPEC_SQCVTN, UNSPEC_SQCVTUN,
-					UNSPEC_UQCVTN, -1))
-FUNCTION (svqdmlalb, unspec_based_qadd_function, (UNSPEC_SQDMULLB, -1, -1))
-FUNCTION (svqdmlalb_lane, unspec_based_qadd_lane_function, (UNSPEC_SQDMULLB,
-							    -1, -1))
-FUNCTION (svqdmlalbt, unspec_based_qadd_function, (UNSPEC_SQDMULLBT, -1, -1))
-FUNCTION (svqdmlalt, unspec_based_qadd_function, (UNSPEC_SQDMULLT, -1, -1))
-FUNCTION (svqdmlalt_lane, unspec_based_qadd_lane_function, (UNSPEC_SQDMULLT,
-							    -1, -1))
-FUNCTION (svqdmlslb, unspec_based_qsub_function, (UNSPEC_SQDMULLB, -1, -1))
-FUNCTION (svqdmlslb_lane, unspec_based_qsub_lane_function, (UNSPEC_SQDMULLB,
-							    -1, -1))
-FUNCTION (svqdmlslbt, unspec_based_qsub_function, (UNSPEC_SQDMULLBT, -1, -1))
-FUNCTION (svqdmlslt, unspec_based_qsub_function, (UNSPEC_SQDMULLT, -1, -1))
-FUNCTION (svqdmlslt_lane, unspec_based_qsub_lane_function, (UNSPEC_SQDMULLT,
-							    -1, -1))
-FUNCTION (svqdmulh, unspec_based_function, (UNSPEC_SQDMULH, -1, -1))
-FUNCTION (svqdmulh_lane, unspec_based_lane_function, (UNSPEC_SQDMULH, -1, -1))
-FUNCTION (svqdmullb, unspec_based_function, (UNSPEC_SQDMULLB, -1, -1))
-FUNCTION (svqdmullb_lane, unspec_based_lane_function, (UNSPEC_SQDMULLB,
-						       -1, -1))
-FUNCTION (svqdmullt, unspec_based_function, (UNSPEC_SQDMULLT, -1, -1))
-FUNCTION (svqdmullt_lane, unspec_based_lane_function, (UNSPEC_SQDMULLT,
-						       -1, -1))
-FUNCTION (svqneg, rtx_code_function, (SS_NEG, UNKNOWN, UNKNOWN))
+FUNCTION (svqcvt, integer_conversion,
+	  (UNSPEC_SQCVT, UNSPEC_SQCVTU, UNSPEC_UQCVT))
+FUNCTION (svqcvtn, integer_conversion,
+	  (UNSPEC_SQCVTN, UNSPEC_SQCVTUN, UNSPEC_UQCVTN))
+FUNCTION (svqdmlalb, unspec_based_qadd_function, (UNSPEC_SQDMULLB))
+FUNCTION (svqdmlalb_lane, unspec_based_qadd_lane_function, (UNSPEC_SQDMULLB))
+FUNCTION (svqdmlalbt, unspec_based_qadd_function, (UNSPEC_SQDMULLBT))
+FUNCTION (svqdmlalt, unspec_based_qadd_function, (UNSPEC_SQDMULLT))
+FUNCTION (svqdmlalt_lane, unspec_based_qadd_lane_function, (UNSPEC_SQDMULLT))
+FUNCTION (svqdmlslb, unspec_based_qsub_function, (UNSPEC_SQDMULLB))
+FUNCTION (svqdmlslb_lane, unspec_based_qsub_lane_function, (UNSPEC_SQDMULLB))
+FUNCTION (svqdmlslbt, unspec_based_qsub_function, (UNSPEC_SQDMULLBT))
+FUNCTION (svqdmlslt, unspec_based_qsub_function, (UNSPEC_SQDMULLT))
+FUNCTION (svqdmlslt_lane, unspec_based_qsub_lane_function, (UNSPEC_SQDMULLT))
+FUNCTION (svqdmulh, unspec_based_function, (UNSPEC_SQDMULH))
+FUNCTION (svqdmulh_lane, unspec_based_lane_function, (UNSPEC_SQDMULH))
+FUNCTION (svqdmullb, unspec_based_function, (UNSPEC_SQDMULLB))
+FUNCTION (svqdmullb_lane, unspec_based_lane_function, (UNSPEC_SQDMULLB))
+FUNCTION (svqdmullt, unspec_based_function, (UNSPEC_SQDMULLT))
+FUNCTION (svqdmullt_lane, unspec_based_lane_function, (UNSPEC_SQDMULLT))
+FUNCTION (svqneg, rtx_code_function, (SS_NEG, UNKNOWN))
 FUNCTION (svqrdcmlah, svqrdcmlah_impl,)
 FUNCTION (svqrdcmlah_lane, svqrdcmlah_lane_impl,)
-FUNCTION (svqrdmlah, unspec_based_function, (UNSPEC_SQRDMLAH, -1, -1))
-FUNCTION (svqrdmlah_lane, unspec_based_lane_function, (UNSPEC_SQRDMLAH,
-						       -1, -1))
-FUNCTION (svqrdmlsh, unspec_based_function, (UNSPEC_SQRDMLSH, -1, -1))
-FUNCTION (svqrdmlsh_lane, unspec_based_lane_function, (UNSPEC_SQRDMLSH,
-						       -1, -1))
-FUNCTION (svqrdmulh, unspec_based_function, (UNSPEC_SQRDMULH, -1, -1))
-FUNCTION (svqrdmulh_lane, unspec_based_lane_function, (UNSPEC_SQRDMULH,
-						       -1, -1))
+FUNCTION (svqrdmlah, unspec_based_function, (UNSPEC_SQRDMLAH))
+FUNCTION (svqrdmlah_lane, unspec_based_lane_function, (UNSPEC_SQRDMLAH))
+FUNCTION (svqrdmlsh, unspec_based_function, (UNSPEC_SQRDMLSH))
+FUNCTION (svqrdmlsh_lane, unspec_based_lane_function, (UNSPEC_SQRDMLSH))
+FUNCTION (svqrdmulh, unspec_based_function, (UNSPEC_SQRDMULH))
+FUNCTION (svqrdmulh_lane, unspec_based_lane_function, (UNSPEC_SQRDMULH))
 FUNCTION (svqrshl, svqrshl_impl,)
-FUNCTION (svqrshr, unspec_based_uncond_function, (UNSPEC_SQRSHR,
-						  UNSPEC_UQRSHR, -1, -1, 1))
-FUNCTION (svqrshrn, unspec_based_uncond_function, (UNSPEC_SQRSHRN,
-						   UNSPEC_UQRSHRN, -1, -1, 1))
-FUNCTION (svqrshrnb, unspec_based_function, (UNSPEC_SQRSHRNB,
-					     UNSPEC_UQRSHRNB, -1))
-FUNCTION (svqrshrnt, unspec_based_function, (UNSPEC_SQRSHRNT,
-					     UNSPEC_UQRSHRNT, -1))
-FUNCTION (svqrshru, unspec_based_uncond_function, (UNSPEC_SQRSHRU, -1, -1, -1, 1))
-FUNCTION (svqrshrun, unspec_based_uncond_function, (UNSPEC_SQRSHRUN, -1, -1, -1, 1))
-FUNCTION (svqrshrunb, unspec_based_function, (UNSPEC_SQRSHRUNB, -1, -1))
-FUNCTION (svqrshrunt, unspec_based_function, (UNSPEC_SQRSHRUNT, -1, -1))
+FUNCTION (svqrshr, unspec_based_uncond_function, (UNSPEC_SQRSHR, UNSPEC_UQRSHR))
+FUNCTION (svqrshrn, unspec_based_uncond_function,
+	  (UNSPEC_SQRSHRN, UNSPEC_UQRSHRN))
+FUNCTION (svqrshrnb, unspec_based_function, (UNSPEC_SQRSHRNB, UNSPEC_UQRSHRNB))
+FUNCTION (svqrshrnt, unspec_based_function, (UNSPEC_SQRSHRNT, UNSPEC_UQRSHRNT))
+FUNCTION (svqrshru, unspec_based_uncond_function, (UNSPEC_SQRSHRU))
+FUNCTION (svqrshrun, unspec_based_uncond_function, (UNSPEC_SQRSHRUN))
+FUNCTION (svqrshrunb, unspec_based_function, (UNSPEC_SQRSHRUNB))
+FUNCTION (svqrshrunt, unspec_based_function, (UNSPEC_SQRSHRUNT))
 FUNCTION (svqshl, svqshl_impl,)
-FUNCTION (svqshlu, unspec_based_function, (UNSPEC_SQSHLU, -1, -1))
-FUNCTION (svqshrnb, unspec_based_function, (UNSPEC_SQSHRNB,
-					    UNSPEC_UQSHRNB, -1))
-FUNCTION (svqshrnt, unspec_based_function, (UNSPEC_SQSHRNT,
-					    UNSPEC_UQSHRNT, -1))
-FUNCTION (svqshrunb, unspec_based_function, (UNSPEC_SQSHRUNB, -1, -1))
-FUNCTION (svqshrunt, unspec_based_function, (UNSPEC_SQSHRUNT, -1, -1))
-FUNCTION (svqsubr, rtx_code_function_rotated, (SS_MINUS, US_MINUS, -1))
-FUNCTION (svqxtnb, unspec_based_function, (UNSPEC_SQXTNB, UNSPEC_UQXTNB, -1))
-FUNCTION (svqxtnt, unspec_based_function, (UNSPEC_SQXTNT, UNSPEC_UQXTNT, -1))
-FUNCTION (svqxtunb, unspec_based_function, (UNSPEC_SQXTUNB, -1, -1))
-FUNCTION (svqxtunt, unspec_based_function, (UNSPEC_SQXTUNT, -1, -1))
-FUNCTION (svraddhnb, unspec_based_function, (UNSPEC_RADDHNB,
-					     UNSPEC_RADDHNB, -1))
-FUNCTION (svraddhnt, unspec_based_function, (UNSPEC_RADDHNT,
-					     UNSPEC_RADDHNT, -1))
+FUNCTION (svqshlu, unspec_based_function, (UNSPEC_SQSHLU))
+FUNCTION (svqshrnb, unspec_based_function, (UNSPEC_SQSHRNB, UNSPEC_UQSHRNB))
+FUNCTION (svqshrnt, unspec_based_function, (UNSPEC_SQSHRNT, UNSPEC_UQSHRNT))
+FUNCTION (svqshrunb, unspec_based_function, (UNSPEC_SQSHRUNB))
+FUNCTION (svqshrunt, unspec_based_function, (UNSPEC_SQSHRUNT))
+FUNCTION (svqsubr, rtx_code_function_rotated, (SS_MINUS, US_MINUS))
+FUNCTION (svqxtnb, unspec_based_function, (UNSPEC_SQXTNB, UNSPEC_UQXTNB))
+FUNCTION (svqxtnt, unspec_based_function, (UNSPEC_SQXTNT, UNSPEC_UQXTNT))
+FUNCTION (svqxtunb, unspec_based_function, (UNSPEC_SQXTUNB))
+FUNCTION (svqxtunt, unspec_based_function, (UNSPEC_SQXTUNT))
+FUNCTION (svraddhnb, unspec_based_function, (UNSPEC_RADDHNB, UNSPEC_RADDHNB))
+FUNCTION (svraddhnt, unspec_based_function, (UNSPEC_RADDHNT, UNSPEC_RADDHNT))
 FUNCTION (svrax1, fixed_insn_function, (CODE_FOR_aarch64_sve2_rax1))
 FUNCTION (svrevd, unspec_based_function, (UNSPEC_REVD, UNSPEC_REVD,
 					  UNSPEC_REVD))
-FUNCTION (svrhadd, unspec_based_function, (UNSPEC_SRHADD, UNSPEC_URHADD, -1))
+FUNCTION (svrhadd, unspec_based_function, (UNSPEC_SRHADD, UNSPEC_URHADD))
 FUNCTION (svrshl, svrshl_impl,)
-FUNCTION (svrshr, unspec_based_function, (UNSPEC_SRSHR, UNSPEC_URSHR, -1))
-FUNCTION (svrshrnb, unspec_based_function, (UNSPEC_RSHRNB, UNSPEC_RSHRNB, -1))
-FUNCTION (svrshrnt, unspec_based_function, (UNSPEC_RSHRNT, UNSPEC_RSHRNT, -1))
-FUNCTION (svrsra, unspec_based_add_function, (UNSPEC_SRSHR, UNSPEC_URSHR, -1))
-FUNCTION (svrsubhnb, unspec_based_function, (UNSPEC_RSUBHNB,
-					     UNSPEC_RSUBHNB, -1))
-FUNCTION (svrsubhnt, unspec_based_function, (UNSPEC_RSUBHNT,
-					     UNSPEC_RSUBHNT, -1))
-FUNCTION (svsbclb, unspec_based_function, (-1, UNSPEC_SBCLB, -1))
-FUNCTION (svsbclt, unspec_based_function, (-1, UNSPEC_SBCLT, -1))
-FUNCTION (svshllb, unspec_based_function, (UNSPEC_SSHLLB, UNSPEC_USHLLB, -1))
-FUNCTION (svshllt, unspec_based_function, (UNSPEC_SSHLLT, UNSPEC_USHLLT, -1))
-FUNCTION (svshrnb, unspec_based_function, (UNSPEC_SHRNB, UNSPEC_SHRNB, -1))
-FUNCTION (svshrnt, unspec_based_function, (UNSPEC_SHRNT, UNSPEC_SHRNT, -1))
-FUNCTION (svsli, unspec_based_function, (UNSPEC_SLI, UNSPEC_SLI, -1))
+FUNCTION (svrshr, unspec_based_function, (UNSPEC_SRSHR, UNSPEC_URSHR))
+FUNCTION (svrshrnb, unspec_based_function, (UNSPEC_RSHRNB, UNSPEC_RSHRNB))
+FUNCTION (svrshrnt, unspec_based_function, (UNSPEC_RSHRNT, UNSPEC_RSHRNT))
+FUNCTION (svrsra, unspec_based_add_function, (UNSPEC_SRSHR, UNSPEC_URSHR))
+FUNCTION (svrsubhnb, unspec_based_function, (UNSPEC_RSUBHNB, UNSPEC_RSUBHNB))
+FUNCTION (svrsubhnt, unspec_based_function, (UNSPEC_RSUBHNT, UNSPEC_RSUBHNT))
+FUNCTION (svsbclb, unspec_based_function, (UNSPEC_NONE, UNSPEC_SBCLB))
+FUNCTION (svsbclt, unspec_based_function, (UNSPEC_NONE, UNSPEC_SBCLT))
+FUNCTION (svshllb, unspec_based_function, (UNSPEC_SSHLLB, UNSPEC_USHLLB))
+FUNCTION (svshllt, unspec_based_function, (UNSPEC_SSHLLT, UNSPEC_USHLLT))
+FUNCTION (svshrnb, unspec_based_function, (UNSPEC_SHRNB, UNSPEC_SHRNB))
+FUNCTION (svshrnt, unspec_based_function, (UNSPEC_SHRNT, UNSPEC_SHRNT))
+FUNCTION (svsli, unspec_based_function, (UNSPEC_SLI, UNSPEC_SLI))
 FUNCTION (svsm4e, fixed_insn_function, (CODE_FOR_aarch64_sve2_sm4e))
 FUNCTION (svsm4ekey, fixed_insn_function, (CODE_FOR_aarch64_sve2_sm4ekey))
 FUNCTION (svsqadd, svsqadd_impl,)
 FUNCTION (svsra, svsra_impl,)
-FUNCTION (svsri, unspec_based_function, (UNSPEC_SRI, UNSPEC_SRI, -1))
+FUNCTION (svsri, unspec_based_function, (UNSPEC_SRI, UNSPEC_SRI))
 FUNCTION (svst1dq, svst1xq_impl, (VNx1DImode))
 FUNCTION (svst1q_scatter, svst1q_scatter_impl,)
 FUNCTION (svst1wq, svst1xq_impl, (VNx1SImode))
@@ -1227,14 +1217,14 @@ FUNCTION (svstnt1_scatter, svstnt1_scatter_impl,)
 FUNCTION (svstnt1b_scatter, svstnt1_scatter_truncate_impl, (QImode))
 FUNCTION (svstnt1h_scatter, svstnt1_scatter_truncate_impl, (HImode))
 FUNCTION (svstnt1w_scatter, svstnt1_scatter_truncate_impl, (SImode))
-FUNCTION (svsubhnb, unspec_based_function, (UNSPEC_SUBHNB, UNSPEC_SUBHNB, -1))
-FUNCTION (svsubhnt, unspec_based_function, (UNSPEC_SUBHNT, UNSPEC_SUBHNT, -1))
-FUNCTION (svsublb, unspec_based_function, (UNSPEC_SSUBLB, UNSPEC_USUBLB, -1))
-FUNCTION (svsublbt, unspec_based_function, (UNSPEC_SSUBLBT, -1, -1))
-FUNCTION (svsublt, unspec_based_function, (UNSPEC_SSUBLT, UNSPEC_USUBLT, -1))
-FUNCTION (svsubltb, unspec_based_function, (UNSPEC_SSUBLTB, -1, -1))
-FUNCTION (svsubwb, unspec_based_function, (UNSPEC_SSUBWB, UNSPEC_USUBWB, -1))
-FUNCTION (svsubwt, unspec_based_function, (UNSPEC_SSUBWT, UNSPEC_USUBWT, -1))
+FUNCTION (svsubhnb, unspec_based_function, (UNSPEC_SUBHNB, UNSPEC_SUBHNB))
+FUNCTION (svsubhnt, unspec_based_function, (UNSPEC_SUBHNT, UNSPEC_SUBHNT))
+FUNCTION (svsublb, unspec_based_function, (UNSPEC_SSUBLB, UNSPEC_USUBLB))
+FUNCTION (svsublbt, unspec_based_function, (UNSPEC_SSUBLBT))
+FUNCTION (svsublt, unspec_based_function, (UNSPEC_SSUBLT, UNSPEC_USUBLT))
+FUNCTION (svsubltb, unspec_based_function, (UNSPEC_SSUBLTB))
+FUNCTION (svsubwb, unspec_based_function, (UNSPEC_SSUBWB, UNSPEC_USUBWB))
+FUNCTION (svsubwt, unspec_based_function, (UNSPEC_SSUBWT, UNSPEC_USUBWT))
 FUNCTION (svtbl2, svtbl2_impl,)
 FUNCTION (svtblq, quiet<unspec_based_uncond_function>, (UNSPEC_TBLQ,
 							UNSPEC_TBLQ,
diff --git a/gcc/config/aarch64/aarch64-sve-builtins.cc b/gcc/config/aarch64/aarch64-sve-builtins.cc
index 668228c33e94..f19d13f0b8b9 100644
--- a/gcc/config/aarch64/aarch64-sve-builtins.cc
+++ b/gcc/config/aarch64/aarch64-sve-builtins.cc
@@ -4494,8 +4494,8 @@ function_expander::use_contiguous_store_insn (insn_code icode)
 rtx
 function_expander::map_to_rtx_codes (rtx_code code_for_sint,
 				     rtx_code code_for_uint,
-				     int unspec_for_cond_fp,
-				     int unspec_for_uncond_fp,
+				     enum unspec unspec_for_cond_fp,
+				     enum unspec unspec_for_uncond_fp,
 				     unsigned int merge_argno)
 {
   machine_mode mode = tuple_mode (0);
@@ -4571,13 +4571,15 @@ function_expander::map_to_rtx_codes (rtx_code code_for_sint,
    MERGE_ARGNO is the argument that provides the values of inactive lanes for
    _m functions, or DEFAULT_MERGE_ARGNO if we should apply the usual rules.  */
 rtx
-function_expander::map_to_unspecs (int unspec_for_sint, int unspec_for_uint,
-				   int unspec_for_fp, unsigned int merge_argno)
+function_expander::map_to_unspecs (enum unspec unspec_for_sint,
+				   enum unspec unspec_for_uint,
+				   enum unspec unspec_for_fp,
+				   unsigned int merge_argno)
 {
   machine_mode mode = tuple_mode (0);
-  int unspec = (!type_suffix (0).integer_p ? unspec_for_fp
-		: type_suffix (0).unsigned_p ? unspec_for_uint
-		: unspec_for_sint);
+  enum unspec unspec = (!type_suffix (0).integer_p  ? unspec_for_fp
+		       : type_suffix (0).unsigned_p ? unspec_for_uint
+						      : unspec_for_sint);
 
   if (mode_suffix_id == MODE_single)
     {
diff --git a/gcc/config/aarch64/aarch64-sve-builtins.h b/gcc/config/aarch64/aarch64-sve-builtins.h
index 628f1788f03e..b7c7ccad73a0 100644
--- a/gcc/config/aarch64/aarch64-sve-builtins.h
+++ b/gcc/config/aarch64/aarch64-sve-builtins.h
@@ -722,9 +722,14 @@ public:
   rtx use_contiguous_prefetch_insn (insn_code);
   rtx use_contiguous_store_insn (insn_code);
 
-  rtx map_to_rtx_codes (rtx_code, rtx_code, int, int,
+  rtx map_to_rtx_codes (rtx_code, rtx_code,
+			enum unspec = UNSPEC_NONE,
+			enum unspec = UNSPEC_NONE,
 			unsigned int = DEFAULT_MERGE_ARGNO);
-  rtx map_to_unspecs (int, int, int, unsigned int = DEFAULT_MERGE_ARGNO);
+  rtx map_to_unspecs (enum unspec,
+		      enum unspec = UNSPEC_NONE,
+		      enum unspec = UNSPEC_NONE,
+		      unsigned int = DEFAULT_MERGE_ARGNO);
 
   /* The function call expression.  */
   tree call_expr;
diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
index d8c99d8e3c27..9d18f92bdaac 100644
--- a/gcc/config/aarch64/aarch64.cc
+++ b/gcc/config/aarch64/aarch64.cc
@@ -6804,7 +6804,7 @@ aarch64_replace_reg_mode (rtx x, machine_mode mode)
 /* Return the SVE REV[BHW] unspec for reversing quantites of mode MODE
    stored in wider integer containers.  */
 
-static unsigned int
+static enum unspec
 aarch64_sve_rev_unspec (machine_mode mode)
 {
   switch (GET_MODE_UNIT_SIZE (mode))
@@ -6831,7 +6831,7 @@ aarch64_split_sve_subreg_move (rtx dest, rtx ptrue, rtx src)
       < GET_MODE_UNIT_SIZE (mode_with_narrower_elts))
     std::swap (mode_with_wider_elts, mode_with_narrower_elts);
 
-  unsigned int unspec = aarch64_sve_rev_unspec (mode_with_narrower_elts);
+  enum unspec unspec = aarch64_sve_rev_unspec (mode_with_narrower_elts);
   machine_mode pred_mode = aarch64_sve_pred_mode (mode_with_wider_elts);
 
   /* Get the operands in the appropriate modes and emit the instruction.  */
@@ -9075,7 +9075,7 @@ aarch_pac_insn_p (rtx x)
       rtx sub = *iter;
       if (sub && GET_CODE (sub) == UNSPEC)
 	{
-	  int unspec_val = XINT (sub, 1);
+	  enum unspec unspec_val = (enum unspec)XINT (sub, 1);
 	  switch (unspec_val)
 	    {
 	    case UNSPEC_PACIASP:
@@ -27150,7 +27150,7 @@ aarch64_evpc_hvla (struct expand_vec_perm_d *d)
       return false;
 
   /* Used once we have verified that we can use UNSPEC to do the operation.  */
-  auto use_binary = [&](int unspec) -> bool
+  auto use_binary = [&](enum unspec unspec) -> bool
     {
       if (!d->testing_p)
 	{
diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md
index fde4fabb7ef4..057b04d555fe 100644
--- a/gcc/config/aarch64/aarch64.md
+++ b/gcc/config/aarch64/aarch64.md
@@ -202,6 +202,7 @@
 )
 
 (define_c_enum "unspec" [
+    (UNSPEC_NONE -1)
     UNSPEC_AUTIA1716
     UNSPEC_AUTIB1716
     UNSPEC_AUTIASP

Reply via email to