]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
arm: [MVE intrinsics] add binary_rshift_narrow_unsigned shape
authorChristophe Lyon <christophe.lyon@arm.com>
Thu, 9 Feb 2023 14:26:44 +0000 (14:26 +0000)
committerChristophe Lyon <christophe.lyon@arm.com>
Fri, 5 May 2023 14:12:01 +0000 (16:12 +0200)
This patch adds the binary_rshift_narrow_unsigned shape description.

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

gcc/
* config/arm/arm-mve-builtins-shapes.cc
(binary_rshift_narrow_unsigned): New.
* config/arm/arm-mve-builtins-shapes.h
(binary_rshift_narrow_unsigned): New.

gcc/config/arm/arm-mve-builtins-shapes.cc
gcc/config/arm/arm-mve-builtins-shapes.h

index 88934e1ca15f491705aad30f77faaba7e24a7198..e3bf586565c80ee39d78858dc7cd4db605d33486 100644 (file)
@@ -664,6 +664,54 @@ struct binary_rshift_narrow_def : public overloaded_base<0>
 };
 SHAPE (binary_rshift_narrow)
 
+/* <uT0:half>_t vfoo[_n_t0](<uT0:half>_t, <T0>_t, const int)
+
+   Vector saturating rounding shift right and narrow.
+   Check that 'imm' is in the [1..#bits/2] range.
+
+   Example: vqshrunbq.
+   uint8x16_t [__arm_]vqshrunbq[_n_s16](uint8x16_t a, int16x8_t b, const int imm)
+   uint8x16_t [__arm_]vqshrunbq_m[_n_s16](uint8x16_t a, int16x8_t b, const int imm, mve_pred16_t p)  */
+struct binary_rshift_narrow_unsigned_def : public overloaded_base<0>
+{
+  void
+  build (function_builder &b, const function_group_info &group,
+        bool preserve_user_namespace) const override
+  {
+    b.add_overloaded_functions (group, MODE_n, preserve_user_namespace);
+    build_all (b, "vhu0,vhu0,v0,ss32", group, MODE_n, preserve_user_namespace);
+  }
+
+  tree
+  resolve (function_resolver &r) const override
+  {
+    unsigned int i, nargs;
+    type_suffix_index type;
+    if (!r.check_gp_argument (3, i, nargs)
+       || (type = r.infer_vector_type (1)) == NUM_TYPE_SUFFIXES
+       || !r.require_integer_immediate (i))
+      return error_mark_node;
+
+    type_suffix_index narrow_suffix
+      = find_type_suffix (TYPE_unsigned,
+                         type_suffixes[type].element_bits / 2);
+
+    if (!r.require_matching_vector_type (0, narrow_suffix))
+      return error_mark_node;
+
+    return r.resolve_to (r.mode_suffix_id, type);
+  }
+
+  bool
+  check (function_checker &c) const override
+  {
+    unsigned int bits = c.type_suffix (0).element_bits;
+    return c.require_immediate_range (2, 1, bits / 2);
+  }
+
+};
+SHAPE (binary_rshift_narrow_unsigned)
+
 /* <T0>xN_t vfoo[_t0](uint64_t, uint64_t)
 
    where there are N arguments in total.
index d72686d187b8df9a609068b64281d4949dbbb02a..ca1c1017e8e6594d201bd2b175a013bed155473f 100644 (file)
@@ -41,6 +41,7 @@ namespace arm_mve
     extern const function_shape *const binary_orrq;
     extern const function_shape *const binary_round_lshift;
     extern const function_shape *const binary_rshift_narrow;
+    extern const function_shape *const binary_rshift_narrow_unsigned;
     extern const function_shape *const create;
     extern const function_shape *const inherent;
     extern const function_shape *const unary_convert;