[15/23] arm: [MVE intrinsics] add binary_rshift_narrow shape

Message ID 20230505083930.101210-15-christophe.lyon@arm.com
State Accepted
Headers
Series [01/23] arm: [MVE intrinsics] add binary_round_lshift shape |

Checks

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

Commit Message

Christophe Lyon May 5, 2023, 8:39 a.m. UTC
  This patch adds the binary_rshift_narrow shape description.

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

	gcc/
	* config/arm/arm-mve-builtins-shapes.cc (binary_rshift_narrow):
	New.
	* config/arm/arm-mve-builtins-shapes.h (binary_rshift_narrow): New.
---
 gcc/config/arm/arm-mve-builtins-shapes.cc | 47 +++++++++++++++++++++++
 gcc/config/arm/arm-mve-builtins-shapes.h  |  1 +
 2 files changed, 48 insertions(+)
  

Comments

Kyrylo Tkachov May 5, 2023, 11 a.m. UTC | #1
> -----Original Message-----
> From: Christophe Lyon <christophe.lyon@arm.com>
> Sent: Friday, May 5, 2023 9:39 AM
> 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 15/23] arm: [MVE intrinsics] add binary_rshift_narrow shape
> 
> This patch adds the binary_rshift_narrow shape description.

Ok.
Thanks,
Kyrill

> 
> 2022-09-08  Christophe Lyon  <christophe.lyon@arm.com>
> 
> 	gcc/
> 	* config/arm/arm-mve-builtins-shapes.cc (binary_rshift_narrow):
> 	New.
> 	* config/arm/arm-mve-builtins-shapes.h (binary_rshift_narrow):
> New.
> ---
>  gcc/config/arm/arm-mve-builtins-shapes.cc | 47 +++++++++++++++++++++++
>  gcc/config/arm/arm-mve-builtins-shapes.h  |  1 +
>  2 files changed, 48 insertions(+)
> 
> diff --git a/gcc/config/arm/arm-mve-builtins-shapes.cc b/gcc/config/arm/arm-
> mve-builtins-shapes.cc
> index 4ecb612ece5..88934e1ca15 100644
> --- a/gcc/config/arm/arm-mve-builtins-shapes.cc
> +++ b/gcc/config/arm/arm-mve-builtins-shapes.cc
> @@ -617,6 +617,53 @@ struct binary_lshift_r_def : public
> overloaded_base<0>
>  };
>  SHAPE (binary_lshift_r)
> 
> +/* <T0:half>_t vfoo[_n_t0](<T0:half>_t, <T0>_t, const int)
> +
> +   Narrowing right shifts.
> +   Check that 'imm' is in the [1..#bits/2] range.
> +
> +   Example: vqrshrnbq.
> +   int8x16_t [__arm_]vqrshrnbq[_n_s16](int8x16_t a, int16x8_t b, const int
> imm)
> +   int8x16_t [__arm_]vqrshrnbq_m[_n_s16](int8x16_t a, int16x8_t b, const int
> imm, mve_pred16_t p)  */
> +struct binary_rshift_narrow_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, "vh0,vh0,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_suffixes[type].tclass,
> +			  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)
> +
>  /* <T0>xN_t vfoo[_t0](uint64_t, uint64_t)
> 
>     where there are N arguments in total.
> diff --git a/gcc/config/arm/arm-mve-builtins-shapes.h b/gcc/config/arm/arm-
> mve-builtins-shapes.h
> index 25d9b60a670..d72686d187b 100644
> --- a/gcc/config/arm/arm-mve-builtins-shapes.h
> +++ b/gcc/config/arm/arm-mve-builtins-shapes.h
> @@ -40,6 +40,7 @@ namespace arm_mve
>      extern const function_shape *const binary_opt_n;
>      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 create;
>      extern const function_shape *const inherent;
>      extern const function_shape *const unary_convert;
> --
> 2.34.1
  

Patch

diff --git a/gcc/config/arm/arm-mve-builtins-shapes.cc b/gcc/config/arm/arm-mve-builtins-shapes.cc
index 4ecb612ece5..88934e1ca15 100644
--- a/gcc/config/arm/arm-mve-builtins-shapes.cc
+++ b/gcc/config/arm/arm-mve-builtins-shapes.cc
@@ -617,6 +617,53 @@  struct binary_lshift_r_def : public overloaded_base<0>
 };
 SHAPE (binary_lshift_r)
 
+/* <T0:half>_t vfoo[_n_t0](<T0:half>_t, <T0>_t, const int)
+
+   Narrowing right shifts.
+   Check that 'imm' is in the [1..#bits/2] range.
+
+   Example: vqrshrnbq.
+   int8x16_t [__arm_]vqrshrnbq[_n_s16](int8x16_t a, int16x8_t b, const int imm)
+   int8x16_t [__arm_]vqrshrnbq_m[_n_s16](int8x16_t a, int16x8_t b, const int imm, mve_pred16_t p)  */
+struct binary_rshift_narrow_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, "vh0,vh0,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_suffixes[type].tclass,
+			  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)
+
 /* <T0>xN_t vfoo[_t0](uint64_t, uint64_t)
 
    where there are N arguments in total.
diff --git a/gcc/config/arm/arm-mve-builtins-shapes.h b/gcc/config/arm/arm-mve-builtins-shapes.h
index 25d9b60a670..d72686d187b 100644
--- a/gcc/config/arm/arm-mve-builtins-shapes.h
+++ b/gcc/config/arm/arm-mve-builtins-shapes.h
@@ -40,6 +40,7 @@  namespace arm_mve
     extern const function_shape *const binary_opt_n;
     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 create;
     extern const function_shape *const inherent;
     extern const function_shape *const unary_convert;