]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
arm: [MVE intrinsics add unspec_mve_function_exact_insn_pred_p
authorChristophe Lyon <christophe.lyon@arm.com>
Mon, 13 Feb 2023 17:02:36 +0000 (17:02 +0000)
committerChristophe Lyon <christophe.lyon@arm.com>
Tue, 9 May 2023 18:31:15 +0000 (20:31 +0200)
Introduce a function that will be used to build intrinsics that use p
predication.

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

gcc/
* config/arm/arm-mve-builtins-functions.h (class
unspec_mve_function_exact_insn_pred_p): New.

gcc/config/arm/arm-mve-builtins-functions.h

index 533fd1159c606e57accef92c2767821162360ac3..bf4e209a720670b9e082c3cdc51cb40931f0c700 100644 (file)
@@ -376,6 +376,70 @@ public:
   }
 };
 
+/* Map the function directly to CODE (UNSPEC), when there is a
+   non-predicated version and one with the "_p" predicate.  */
+class unspec_mve_function_exact_insn_pred_p : public function_base
+{
+public:
+  CONSTEXPR unspec_mve_function_exact_insn_pred_p (int unspec_for_sint,
+                                                  int unspec_for_uint,
+                                                  int unspec_for_fp,
+                                                  int unspec_for_p_sint,
+                                                  int unspec_for_p_uint,
+                                                  int unspec_for_p_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_p_sint (unspec_for_p_sint),
+      m_unspec_for_p_uint (unspec_for_p_uint),
+      m_unspec_for_p_fp (unspec_for_p_fp)
+  {}
+
+  /* The unspec code associated with signed-integer and unsigned-integer
+     operations, with no predicate, or with "_p" predicate.  */
+  int m_unspec_for_sint;
+  int m_unspec_for_uint;
+  int m_unspec_for_fp;
+  int m_unspec_for_p_sint;
+  int m_unspec_for_p_uint;
+  int m_unspec_for_p_fp;
+
+  rtx
+  expand (function_expander &e) const override
+  {
+    insn_code code;
+    switch (e.pred)
+      {
+      case PRED_none:
+       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));
+
+       return e.use_exact_insn (code);
+
+      case PRED_p:
+       if (e.type_suffix (0).integer_p)
+         if (e.type_suffix (0).unsigned_p)
+           code = code_for_mve_q_p (m_unspec_for_p_uint, m_unspec_for_p_uint, e.vector_mode (0));
+         else
+           code = code_for_mve_q_p (m_unspec_for_p_sint, m_unspec_for_p_sint, e.vector_mode (0));
+       else
+         gcc_unreachable ();  /* Will be fixed later in the series.  */
+
+       return e.use_exact_insn (code);
+
+      default:
+       gcc_unreachable ();
+      }
+
+    gcc_unreachable ();
+  }
+};
+
 /* Map the function directly to CODE (UNSPEC, M) for vshl-like
    builtins. The difference with unspec_mve_function_exact_insn is
    that this function handles MODE_r and the related unspecs..  */