[14/22] arm: [MVE intrinsics] add unspec_mve_function_exact_insn

Message ID 20230418134608.244751-15-christophe.lyon@arm.com
State Accepted
Headers
Series arm: New framework for MVE intrinsics |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Christophe Lyon April 18, 2023, 1:46 p.m. UTC
  Introduce a function that will be used to build intrinsics which use
UNSPECS for the versions.

2022-09-08  Christophe Lyon <christophe.lyon@arm.com>

	gcc/
	* config/arm/arm-mve-builtins-functions.h (class
	unspec_mve_function_exact_insn): New.
---
 gcc/config/arm/arm-mve-builtins-functions.h | 151 ++++++++++++++++++++
 1 file changed, 151 insertions(+)
  

Comments

Kyrylo Tkachov May 3, 2023, 8:40 a.m. UTC | #1
> -----Original Message-----
> From: Christophe Lyon <christophe.lyon@arm.com>
> Sent: Tuesday, April 18, 2023 2:46 PM
> To: gcc-patches@gcc.gnu.org; Kyrylo Tkachov <Kyrylo.Tkachov@arm.com>;
> Richard Earnshaw <Richard.Earnshaw@arm.com>; Richard Sandiford
> <Richard.Sandiford@arm.com>
> Cc: Christophe Lyon <Christophe.Lyon@arm.com>
> Subject: [PATCH 14/22] arm: [MVE intrinsics] add
> unspec_mve_function_exact_insn
> 
> Introduce a function that will be used to build intrinsics which use
> UNSPECS for the versions.
> 

Ok.
Thanks,
Kyrill

> 2022-09-08  Christophe Lyon <christophe.lyon@arm.com>
> 
> 	gcc/
> 	* config/arm/arm-mve-builtins-functions.h (class
> 	unspec_mve_function_exact_insn): New.
> ---
>  gcc/config/arm/arm-mve-builtins-functions.h | 151 ++++++++++++++++++++
>  1 file changed, 151 insertions(+)
> 
> diff --git a/gcc/config/arm/arm-mve-builtins-functions.h
> b/gcc/config/arm/arm-mve-builtins-functions.h
> index 6d992b270b0..5abf913d182 100644
> --- a/gcc/config/arm/arm-mve-builtins-functions.h
> +++ b/gcc/config/arm/arm-mve-builtins-functions.h
> @@ -225,6 +225,157 @@ public:
>    }
>  };
> 
> +/* Map the function directly to CODE (UNSPEC, M) where M is the vector
> +   mode associated with type suffix 0.  */
> +class unspec_mve_function_exact_insn : public function_base
> +{
> +public:
> +  CONSTEXPR unspec_mve_function_exact_insn (int unspec_for_sint,
> +					    int unspec_for_uint,
> +					    int unspec_for_fp,
> +					    int unspec_for_n_sint,
> +					    int unspec_for_n_uint,
> +					    int unspec_for_n_fp,
> +					    int unspec_for_m_sint,
> +					    int unspec_for_m_uint,
> +					    int unspec_for_m_fp,
> +					    int unspec_for_m_n_sint,
> +					    int unspec_for_m_n_uint,
> +					    int unspec_for_m_n_fp)
> +    : m_unspec_for_sint (unspec_for_sint),
> +      m_unspec_for_uint (unspec_for_uint),
> +      m_unspec_for_fp (unspec_for_fp),
> +      m_unspec_for_n_sint (unspec_for_n_sint),
> +      m_unspec_for_n_uint (unspec_for_n_uint),
> +      m_unspec_for_n_fp (unspec_for_n_fp),
> +      m_unspec_for_m_sint (unspec_for_m_sint),
> +      m_unspec_for_m_uint (unspec_for_m_uint),
> +      m_unspec_for_m_fp (unspec_for_m_fp),
> +      m_unspec_for_m_n_sint (unspec_for_m_n_sint),
> +      m_unspec_for_m_n_uint (unspec_for_m_n_uint),
> +      m_unspec_for_m_n_fp (unspec_for_m_n_fp)
> +  {}
> +
> +  /* The unspec code associated with signed-integer, unsigned-integer
> +     and floating-point operations respectively.  It covers the cases
> +     with the _n suffix, and/or the _m predicate.  */
> +  int m_unspec_for_sint;
> +  int m_unspec_for_uint;
> +  int m_unspec_for_fp;
> +  int m_unspec_for_n_sint;
> +  int m_unspec_for_n_uint;
> +  int m_unspec_for_n_fp;
> +  int m_unspec_for_m_sint;
> +  int m_unspec_for_m_uint;
> +  int m_unspec_for_m_fp;
> +  int m_unspec_for_m_n_sint;
> +  int m_unspec_for_m_n_uint;
> +  int m_unspec_for_m_n_fp;
> +
> +  rtx
> +  expand (function_expander &e) const override
> +  {
> +    insn_code code;
> +    switch (e.pred)
> +      {
> +      case PRED_none:
> +	switch (e.mode_suffix_id)
> +	  {
> +	  case MODE_none:
> +	    /* No predicate, no suffix.  */
> +	    if (e.type_suffix (0).integer_p)
> +	      if (e.type_suffix (0).unsigned_p)
> +		code = code_for_mve_q (m_unspec_for_uint,
> m_unspec_for_uint, e.vector_mode (0));
> +	      else
> +		code = code_for_mve_q (m_unspec_for_sint,
> m_unspec_for_sint, e.vector_mode (0));
> +	    else
> +	      code = code_for_mve_q_f (m_unspec_for_fp, e.vector_mode (0));
> +	    break;
> +
> +	  case MODE_n:
> +	    /* No predicate, _n suffix.  */
> +	    if (e.type_suffix (0).integer_p)
> +	      if (e.type_suffix (0).unsigned_p)
> +		code = code_for_mve_q_n (m_unspec_for_n_uint,
> m_unspec_for_n_uint, e.vector_mode (0));
> +	      else
> +		code = code_for_mve_q_n (m_unspec_for_n_sint,
> m_unspec_for_n_sint, e.vector_mode (0));
> +	    else
> +	      code = code_for_mve_q_n_f (m_unspec_for_n_fp, e.vector_mode
> (0));
> +	    break;
> +
> +	  default:
> +	    gcc_unreachable ();
> +	  }
> +	return e.use_exact_insn (code);
> +
> +      case PRED_m:
> +	switch (e.mode_suffix_id)
> +	  {
> +	  case MODE_none:
> +	    /* No suffix, "m" predicate.  */
> +	    if (e.type_suffix (0).integer_p)
> +	      if (e.type_suffix (0).unsigned_p)
> +		code = code_for_mve_q_m (m_unspec_for_m_uint,
> m_unspec_for_m_uint, e.vector_mode (0));
> +	      else
> +		code = code_for_mve_q_m (m_unspec_for_m_sint,
> m_unspec_for_m_sint, e.vector_mode (0));
> +	    else
> +	      code = code_for_mve_q_m_f (m_unspec_for_m_fp,
> e.vector_mode (0));
> +	    break;
> +
> +	  case MODE_n:
> +	    /* _n suffix, "m" predicate.  */
> +	    if (e.type_suffix (0).integer_p)
> +	      if (e.type_suffix (0).unsigned_p)
> +		code = code_for_mve_q_m_n (m_unspec_for_m_n_uint,
> m_unspec_for_m_n_uint, e.vector_mode (0));
> +	      else
> +		code = code_for_mve_q_m_n (m_unspec_for_m_n_sint,
> m_unspec_for_m_n_sint, e.vector_mode (0));
> +	    else
> +	      code = code_for_mve_q_m_n_f (m_unspec_for_m_n_fp,
> e.vector_mode (0));
> +	    break;
> +
> +	  default:
> +	    gcc_unreachable ();
> +	  }
> +	return e.use_cond_insn (code, 0);
> +
> +      case PRED_x:
> +	switch (e.mode_suffix_id)
> +	  {
> +	  case MODE_none:
> +	    /* No suffix, "x" predicate.  */
> +	    if (e.type_suffix (0).integer_p)
> +	      if (e.type_suffix (0).unsigned_p)
> +		code = code_for_mve_q_m (m_unspec_for_m_uint,
> m_unspec_for_m_uint, e.vector_mode (0));
> +	      else
> +		code = code_for_mve_q_m (m_unspec_for_m_sint,
> m_unspec_for_m_sint, e.vector_mode (0));
> +	    else
> +	      code = code_for_mve_q_m_f (m_unspec_for_m_fp,
> e.vector_mode (0));
> +	    break;
> +
> +	  case MODE_n:
> +	    /* _n suffix, "x" predicate.  */
> +	    if (e.type_suffix (0).integer_p)
> +	      if (e.type_suffix (0).unsigned_p)
> +		code = code_for_mve_q_m_n (m_unspec_for_m_n_uint,
> m_unspec_for_m_n_uint, e.vector_mode (0));
> +	      else
> +		code = code_for_mve_q_m_n (m_unspec_for_m_n_sint,
> m_unspec_for_m_n_sint, e.vector_mode (0));
> +	    else
> +	      code = code_for_mve_q_m_n_f (m_unspec_for_m_n_fp,
> e.vector_mode (0));
> +	    break;
> +
> +	  default:
> +	    gcc_unreachable ();
> +	  }
> +	return e.use_pred_x_insn (code);
> +
> +      default:
> +	gcc_unreachable ();
> +      }
> +
> +    gcc_unreachable ();
> +  }
> +};
> +
>  } /* end namespace arm_mve */
> 
>  /* Declare the global function base NAME, creating it from an instance
> --
> 2.34.1
  

Patch

diff --git a/gcc/config/arm/arm-mve-builtins-functions.h b/gcc/config/arm/arm-mve-builtins-functions.h
index 6d992b270b0..5abf913d182 100644
--- a/gcc/config/arm/arm-mve-builtins-functions.h
+++ b/gcc/config/arm/arm-mve-builtins-functions.h
@@ -225,6 +225,157 @@  public:
   }
 };
 
+/* Map the function directly to CODE (UNSPEC, M) where M is the vector
+   mode associated with type suffix 0.  */
+class unspec_mve_function_exact_insn : public function_base
+{
+public:
+  CONSTEXPR unspec_mve_function_exact_insn (int unspec_for_sint,
+					    int unspec_for_uint,
+					    int unspec_for_fp,
+					    int unspec_for_n_sint,
+					    int unspec_for_n_uint,
+					    int unspec_for_n_fp,
+					    int unspec_for_m_sint,
+					    int unspec_for_m_uint,
+					    int unspec_for_m_fp,
+					    int unspec_for_m_n_sint,
+					    int unspec_for_m_n_uint,
+					    int unspec_for_m_n_fp)
+    : m_unspec_for_sint (unspec_for_sint),
+      m_unspec_for_uint (unspec_for_uint),
+      m_unspec_for_fp (unspec_for_fp),
+      m_unspec_for_n_sint (unspec_for_n_sint),
+      m_unspec_for_n_uint (unspec_for_n_uint),
+      m_unspec_for_n_fp (unspec_for_n_fp),
+      m_unspec_for_m_sint (unspec_for_m_sint),
+      m_unspec_for_m_uint (unspec_for_m_uint),
+      m_unspec_for_m_fp (unspec_for_m_fp),
+      m_unspec_for_m_n_sint (unspec_for_m_n_sint),
+      m_unspec_for_m_n_uint (unspec_for_m_n_uint),
+      m_unspec_for_m_n_fp (unspec_for_m_n_fp)
+  {}
+
+  /* The unspec code associated with signed-integer, unsigned-integer
+     and floating-point operations respectively.  It covers the cases
+     with the _n suffix, and/or the _m predicate.  */
+  int m_unspec_for_sint;
+  int m_unspec_for_uint;
+  int m_unspec_for_fp;
+  int m_unspec_for_n_sint;
+  int m_unspec_for_n_uint;
+  int m_unspec_for_n_fp;
+  int m_unspec_for_m_sint;
+  int m_unspec_for_m_uint;
+  int m_unspec_for_m_fp;
+  int m_unspec_for_m_n_sint;
+  int m_unspec_for_m_n_uint;
+  int m_unspec_for_m_n_fp;
+
+  rtx
+  expand (function_expander &e) const override
+  {
+    insn_code code;
+    switch (e.pred)
+      {
+      case PRED_none:
+	switch (e.mode_suffix_id)
+	  {
+	  case MODE_none:
+	    /* No predicate, no suffix.  */
+	    if (e.type_suffix (0).integer_p)
+	      if (e.type_suffix (0).unsigned_p)
+		code = code_for_mve_q (m_unspec_for_uint, m_unspec_for_uint, e.vector_mode (0));
+	      else
+		code = code_for_mve_q (m_unspec_for_sint, m_unspec_for_sint, e.vector_mode (0));
+	    else
+	      code = code_for_mve_q_f (m_unspec_for_fp, e.vector_mode (0));
+	    break;
+
+	  case MODE_n:
+	    /* No predicate, _n suffix.  */
+	    if (e.type_suffix (0).integer_p)
+	      if (e.type_suffix (0).unsigned_p)
+		code = code_for_mve_q_n (m_unspec_for_n_uint, m_unspec_for_n_uint, e.vector_mode (0));
+	      else
+		code = code_for_mve_q_n (m_unspec_for_n_sint, m_unspec_for_n_sint, e.vector_mode (0));
+	    else
+	      code = code_for_mve_q_n_f (m_unspec_for_n_fp, e.vector_mode (0));
+	    break;
+
+	  default:
+	    gcc_unreachable ();
+	  }
+	return e.use_exact_insn (code);
+
+      case PRED_m:
+	switch (e.mode_suffix_id)
+	  {
+	  case MODE_none:
+	    /* No suffix, "m" predicate.  */
+	    if (e.type_suffix (0).integer_p)
+	      if (e.type_suffix (0).unsigned_p)
+		code = code_for_mve_q_m (m_unspec_for_m_uint, m_unspec_for_m_uint, e.vector_mode (0));
+	      else
+		code = code_for_mve_q_m (m_unspec_for_m_sint, m_unspec_for_m_sint, e.vector_mode (0));
+	    else
+	      code = code_for_mve_q_m_f (m_unspec_for_m_fp, e.vector_mode (0));
+	    break;
+
+	  case MODE_n:
+	    /* _n suffix, "m" predicate.  */
+	    if (e.type_suffix (0).integer_p)
+	      if (e.type_suffix (0).unsigned_p)
+		code = code_for_mve_q_m_n (m_unspec_for_m_n_uint, m_unspec_for_m_n_uint, e.vector_mode (0));
+	      else
+		code = code_for_mve_q_m_n (m_unspec_for_m_n_sint, m_unspec_for_m_n_sint, e.vector_mode (0));
+	    else
+	      code = code_for_mve_q_m_n_f (m_unspec_for_m_n_fp, e.vector_mode (0));
+	    break;
+
+	  default:
+	    gcc_unreachable ();
+	  }
+	return e.use_cond_insn (code, 0);
+
+      case PRED_x:
+	switch (e.mode_suffix_id)
+	  {
+	  case MODE_none:
+	    /* No suffix, "x" predicate.  */
+	    if (e.type_suffix (0).integer_p)
+	      if (e.type_suffix (0).unsigned_p)
+		code = code_for_mve_q_m (m_unspec_for_m_uint, m_unspec_for_m_uint, e.vector_mode (0));
+	      else
+		code = code_for_mve_q_m (m_unspec_for_m_sint, m_unspec_for_m_sint, e.vector_mode (0));
+	    else
+	      code = code_for_mve_q_m_f (m_unspec_for_m_fp, e.vector_mode (0));
+	    break;
+
+	  case MODE_n:
+	    /* _n suffix, "x" predicate.  */
+	    if (e.type_suffix (0).integer_p)
+	      if (e.type_suffix (0).unsigned_p)
+		code = code_for_mve_q_m_n (m_unspec_for_m_n_uint, m_unspec_for_m_n_uint, e.vector_mode (0));
+	      else
+		code = code_for_mve_q_m_n (m_unspec_for_m_n_sint, m_unspec_for_m_n_sint, e.vector_mode (0));
+	    else
+	      code = code_for_mve_q_m_n_f (m_unspec_for_m_n_fp, e.vector_mode (0));
+	    break;
+
+	  default:
+	    gcc_unreachable ();
+	  }
+	return e.use_pred_x_insn (code);
+
+      default:
+	gcc_unreachable ();
+      }
+
+    gcc_unreachable ();
+  }
+};
+
 } /* end namespace arm_mve */
 
 /* Declare the global function base NAME, creating it from an instance