From 1f2ab5b3900f1d6ff357352a211c8f1fecc03cf8 Mon Sep 17 00:00:00 2001
From: Christophe Lyon <christophe.lyon@linaro.org>
Date: Sun, 13 Oct 2024 21:03:12 +0000
Subject: [PATCH] arm: [MVE intrinsics] Add store_scatter_base shape

This patch adds the store_scatter_base shape description.

gcc/ChangeLog:

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

diff --git a/gcc/config/arm/arm-mve-builtins-shapes.cc b/gcc/config/arm/arm-mve-builtins-shapes.cc
index 9350805c2a24..64d4ba5d74e1 100644
--- a/gcc/config/arm/arm-mve-builtins-shapes.cc
+++ b/gcc/config/arm/arm-mve-builtins-shapes.cc
@@ -1677,6 +1677,55 @@ struct store_scatter_offset_def : public store_scatter
 };
 SHAPE (store_scatter_offset)
 
+/* void vfoo[_t0](<Y>_t, const int, <T0>_t)
+
+   where <X> is tied to <t0>.
+   <Y> has the same width as <T0> but is of unsigned type.
+
+   Example: vstrbq_scatter_base
+   void [__arm_]vstrwq_scatter_base[_s32](uint32x4_t addr, const int offset, int32x4_t value)
+   void [__arm_]vstrwq_scatter_base_p[_s32](uint32x4_t addr, const int offset, int32x4_t value, mve_pred16_t p)  */
+struct store_scatter_base_def : public store_scatter
+{
+  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);
+    build_all (b, "_,vu0,ss64,v0", group, MODE_none, 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)
+	|| !r.require_integer_immediate (1)
+	|| (type = r.infer_vector_type (2)) == NUM_TYPE_SUFFIXES)
+      return error_mark_node;
+
+    type_suffix_index base_type
+      = find_type_suffix (TYPE_unsigned, type_suffixes[type].element_bits);
+
+    /* Base (arg 0) should be a vector of unsigned with same width as value
+       (arg 2).  */
+    if (!r.require_matching_vector_type (0, base_type))
+      return error_mark_node;
+
+    return r.resolve_to (r.mode_suffix_id, type);
+  }
+
+  bool
+  check (function_checker &c) const override
+  {
+    int multiple = c.type_suffix (0).element_bits / 8;
+    int bound = 127 * multiple;
+    return c.require_immediate_range_multiple (1, -bound, bound, multiple);
+  }
+};
+SHAPE (store_scatter_base)
+
 /* <T0>_t vfoo[_t0](<T0>_t, <T0>_t, <T0>_t)
 
    i.e. the standard shape for ternary operations that operate on
diff --git a/gcc/config/arm/arm-mve-builtins-shapes.h b/gcc/config/arm/arm-mve-builtins-shapes.h
index be0e09755cc4..1d361addd762 100644
--- a/gcc/config/arm/arm-mve-builtins-shapes.h
+++ b/gcc/config/arm/arm-mve-builtins-shapes.h
@@ -65,6 +65,7 @@ namespace arm_mve
     extern const function_shape *const load_ext;
     extern const function_shape *const mvn;
     extern const function_shape *const store;
+    extern const function_shape *const store_scatter_base;
     extern const function_shape *const store_scatter_offset;
     extern const function_shape *const ternary;
     extern const function_shape *const ternary_lshift;
-- 
GitLab