]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
arm: [MVE intrinsics] add unspec_mve_function_exact_insn
authorChristophe Lyon <christophe.lyon@arm.com>
Fri, 23 Sep 2022 14:50:26 +0000 (14:50 +0000)
committerChristophe Lyon <christophe.lyon@arm.com>
Wed, 3 May 2023 14:58:28 +0000 (16:58 +0200)
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

index 6d992b270b00d225749b756ded05088f5e2dd433..5abf913d18211ab5853ef4a41720f0b9b9ad5215 100644 (file)
@@ -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