patch adds the binary_orrq shape description.

MODE_n intrinsics use a set of predicates (preds_m_or_none) different
the MODE_none ones, so we explicitly reference preds_m_or_none from
the shape, thus we need to make it a global array.

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

        gcc/
        * config/arm/arm-mve-builtins-shapes.cc (binary_orrq): New.
        * config/arm/arm-mve-builtins-shapes.h (binary_orrq): New.
        * config/arm/arm-mve-builtins.cc (preds_m_or_none): Remove static.
        * config/arm/arm-mve-builtins.h (preds_m_or_none): Declare.
---
 gcc/config/arm/arm-mve-builtins-shapes.cc | 61 +++++++++++++++++++++++
 gcc/config/arm/arm-mve-builtins-shapes.h  |  1 +
 gcc/config/arm/arm-mve-builtins.cc        |  2 +-
 gcc/config/arm/arm-mve-builtins.h         |  3 ++
 4 files changed, 66 insertions(+), 1 deletion(-)

diff --git a/gcc/config/arm/arm-mve-builtins-shapes.cc 
b/gcc/config/arm/arm-mve-builtins-shapes.cc
index e69faae4e2c..83410bbc51a 100644
--- a/gcc/config/arm/arm-mve-builtins-shapes.cc
+++ b/gcc/config/arm/arm-mve-builtins-shapes.cc
@@ -397,6 +397,67 @@ struct binary_opt_n_def : public overloaded_base<0>
 };
 SHAPE (binary_opt_n)
 
+/* <T0>_t vfoo[t0](<T0>_t, <T0>_t)
+   <T0>_t vfoo[_n_t0](<T0>_t, <S0>_t)
+
+   Where the _n form has only supports s16/s32/u16/u32 types as for vorrq.
+
+   Example: vorrq.
+   int16x8_t [__arm_]vorrq[_s16](int16x8_t a, int16x8_t b)
+   int16x8_t [__arm_]vorrq_m[_s16](int16x8_t inactive, int16x8_t a, int16x8_t 
b, mve_pred16_t p)
+   int16x8_t [__arm_]vorrq_x[_s16](int16x8_t a, int16x8_t b, mve_pred16_t p)
+   int16x8_t [__arm_]vorrq[_n_s16](int16x8_t a, const int16_t imm)
+   int16x8_t [__arm_]vorrq_m_n[_s16](int16x8_t a, const int16_t imm, 
mve_pred16_t p)  */
+struct binary_orrq_def : public overloaded_base<0>
+{
+  bool
+  explicit_mode_suffix_p (enum predication_index pred, enum mode_suffix_index 
mode) const override
+  {
+    return (mode == MODE_n
+           && pred == PRED_m);
+  }
+
+  bool
+  skip_overload_p (enum predication_index pred, enum mode_suffix_index mode) 
const override
+  {
+    switch (mode)
+      {
+      case MODE_none:
+       return false;
+
+       /* For MODE_n, share the overloaded instance with MODE_none, except for 
PRED_m.  */
+      case MODE_n:
+       return pred != PRED_m;
+
+      default:
+       gcc_unreachable ();
+      }
+  }
+
+  void
+  build (function_builder &b, const function_group_info &group,
+        bool preserve_user_namespace) const override
+  {
+    b.add_overloaded_functions (group, MODE_none, preserve_user_namespace);
+    b.add_overloaded_functions (group, MODE_n, preserve_user_namespace);
+    build_all (b, "v0,v0,v0", group, MODE_none, preserve_user_namespace);
+    build_16_32 (b, "v0,v0,s0", group, MODE_n, preserve_user_namespace, false, 
preds_m_or_none);
+  }
+
+  tree
+  resolve (function_resolver &r) const override
+  {
+    unsigned int i, nargs;
+    type_suffix_index type;
+    if (!r.check_gp_argument (2, i, nargs)
+       || (type = r.infer_vector_type (0)) == NUM_TYPE_SUFFIXES)
+      return error_mark_node;
+
+    return r.finish_opt_n_resolution (i, 0, type);
+  }
+};
+SHAPE (binary_orrq)
+
 /* <T0>[xN]_t vfoo_t0().
 
    Example: vuninitializedq.
diff --git a/gcc/config/arm/arm-mve-builtins-shapes.h 
b/gcc/config/arm/arm-mve-builtins-shapes.h
index b00ee5eb57a..618b3226050 100644
--- a/gcc/config/arm/arm-mve-builtins-shapes.h
+++ b/gcc/config/arm/arm-mve-builtins-shapes.h
@@ -36,6 +36,7 @@ namespace arm_mve
 
     extern const function_shape *const binary;
     extern const function_shape *const binary_opt_n;
+    extern const function_shape *const binary_orrq;
     extern const function_shape *const inherent;
     extern const function_shape *const unary_convert;
 
diff --git a/gcc/config/arm/arm-mve-builtins.cc 
b/gcc/config/arm/arm-mve-builtins.cc
index e409a029346..c74e890bd3d 100644
--- a/gcc/config/arm/arm-mve-builtins.cc
+++ b/gcc/config/arm/arm-mve-builtins.cc
@@ -285,7 +285,7 @@ static const predication_index preds_none[] = { PRED_none, 
NUM_PREDS };
 
 /* Used by functions that have the m (merging) predicated form, and in
    addition have an unpredicated form.  */
-static const predication_index preds_m_or_none[] = {
+const predication_index preds_m_or_none[] = {
   PRED_m, PRED_none, NUM_PREDS
 };
 
diff --git a/gcc/config/arm/arm-mve-builtins.h 
b/gcc/config/arm/arm-mve-builtins.h
index a20d2fb5d86..c9b51a0c77b 100644
--- a/gcc/config/arm/arm-mve-builtins.h
+++ b/gcc/config/arm/arm-mve-builtins.h
@@ -135,6 +135,9 @@ enum predication_index
   NUM_PREDS
 };
 
+/* Some shapes need access to some predicate sets.  */
+extern const predication_index preds_m_or_none[];
+
 /* Classifies element types, based on type suffixes with the bit count
    removed.  */
 enum type_class_index
-- 
2.34.1

Reply via email to