diff mbox series

[2/6] arm: [MVE intrinsics] Add support for void and load/store pointers as argument types.

Message ID 20231116152617.2193377-2-christophe.lyon@linaro.org
State New
Headers show
Series [1/6] arm: Fix arm_simd_types and MVE scalar_types | expand

Commit Message

Christophe Lyon Nov. 16, 2023, 3:26 p.m. UTC
This patch adds support for '_', 'al' and 'as' for void, load pointer
and store pointer argument/return value types in intrinsic signatures.

It also adds a mew memory_scalar_type() helper to function_instance,
which is used by 'al' and 'as'.

2023-11-16  Christophe Lyon  <christophe.lyon@linaro.org>

	gcc/
	* config/arm/arm-mve-builtins-shapes.cc (build_const_pointer):
	New.
	(parse_type): Add support for '_', 'al' and 'as'.
	* config/arm/arm-mve-builtins.h (function_instance): Add
	memory_scalar_type.
	(function_base): Likewise.
---
 gcc/config/arm/arm-mve-builtins-shapes.cc | 25 +++++++++++++++++++++++
 gcc/config/arm/arm-mve-builtins.h         | 17 +++++++++++++++
 2 files changed, 42 insertions(+)

Comments

Kyrylo Tkachov Nov. 16, 2023, 4:47 p.m. UTC | #1
> -----Original Message-----
> From: Christophe Lyon <christophe.lyon@linaro.org>
> Sent: Thursday, November 16, 2023 3:26 PM
> To: gcc-patches@gcc.gnu.org; Richard Sandiford
> <Richard.Sandiford@arm.com>; Richard Earnshaw
> <Richard.Earnshaw@arm.com>; Kyrylo Tkachov <Kyrylo.Tkachov@arm.com>
> Cc: Christophe Lyon <christophe.lyon@linaro.org>
> Subject: [PATCH 2/6] arm: [MVE intrinsics] Add support for void and
> load/store pointers as argument types.
> 
> This patch adds support for '_', 'al' and 'as' for void, load pointer
> and store pointer argument/return value types in intrinsic signatures.
> 
> It also adds a mew memory_scalar_type() helper to function_instance,
> which is used by 'al' and 'as'.

Ok.
Thanks,
Kyrill

> 
> 2023-11-16  Christophe Lyon  <christophe.lyon@linaro.org>
> 
> 	gcc/
> 	* config/arm/arm-mve-builtins-shapes.cc (build_const_pointer):
> 	New.
> 	(parse_type): Add support for '_', 'al' and 'as'.
> 	* config/arm/arm-mve-builtins.h (function_instance): Add
> 	memory_scalar_type.
> 	(function_base): Likewise.
> ---
>  gcc/config/arm/arm-mve-builtins-shapes.cc | 25 +++++++++++++++++++++++
>  gcc/config/arm/arm-mve-builtins.h         | 17 +++++++++++++++
>  2 files changed, 42 insertions(+)
> 
> diff --git a/gcc/config/arm/arm-mve-builtins-shapes.cc b/gcc/config/arm/arm-
> mve-builtins-shapes.cc
> index 23eb9d0e69b..ce87ebcef30 100644
> --- a/gcc/config/arm/arm-mve-builtins-shapes.cc
> +++ b/gcc/config/arm/arm-mve-builtins-shapes.cc
> @@ -39,6 +39,13 @@
> 
>  namespace arm_mve {
> 
> +/* Return a representation of "const T *".  */
> +static tree
> +build_const_pointer (tree t)
> +{
> +  return build_pointer_type (build_qualified_type (t, TYPE_QUAL_CONST));
> +}
> +
>  /* If INSTANCE has a predicate, add it to the list of argument types
>     in ARGUMENT_TYPES.  RETURN_TYPE is the type returned by the
>     function.  */
> @@ -140,6 +147,9 @@ parse_element_type (const function_instance
> &instance, const char *&format)
>  /* Read and return a type from FORMAT for function INSTANCE.  Advance
>     FORMAT beyond the type string.  The format is:
> 
> +   _       - void
> +   al      - array pointer for loads
> +   as      - array pointer for stores
>     p       - predicates with type mve_pred16_t
>     s<elt>  - a scalar type with the given element suffix
>     t<elt>  - a vector or tuple type with given element suffix [*1]
> @@ -156,6 +166,21 @@ parse_type (const function_instance &instance,
> const char *&format)
>  {
>    int ch = *format++;
> 
> +
> +  if (ch == '_')
> +    return void_type_node;
> +
> +  if (ch == 'a')
> +    {
> +      ch = *format++;
> +      if (ch == 'l')
> +	return build_const_pointer (instance.memory_scalar_type ());
> +      if (ch == 's') {
> +	return build_pointer_type (instance.memory_scalar_type ());
> +      }
> +      gcc_unreachable ();
> +    }
> +
>    if (ch == 'p')
>      return get_mve_pred16_t ();
> 
> diff --git a/gcc/config/arm/arm-mve-builtins.h b/gcc/config/arm/arm-mve-
> builtins.h
> index 37b8223dfb2..4fd230fe4c7 100644
> --- a/gcc/config/arm/arm-mve-builtins.h
> +++ b/gcc/config/arm/arm-mve-builtins.h
> @@ -277,6 +277,7 @@ public:
>    bool could_trap_p () const;
> 
>    unsigned int vectors_per_tuple () const;
> +  tree memory_scalar_type () const;
> 
>    const mode_suffix_info &mode_suffix () const;
> 
> @@ -519,6 +520,14 @@ public:
>       of vectors in the tuples, otherwise return 1.  */
>    virtual unsigned int vectors_per_tuple () const { return 1; }
> 
> +  /* If the function addresses memory, return the type of a single
> +     scalar memory element.  */
> +  virtual tree
> +  memory_scalar_type (const function_instance &) const
> +  {
> +    gcc_unreachable ();
> +  }
> +
>    /* Try to fold the given gimple call.  Return the new gimple statement
>       on success, otherwise return null.  */
>    virtual gimple *fold (gimple_folder &) const { return NULL; }
> @@ -644,6 +653,14 @@ function_instance::vectors_per_tuple () const
>    return base->vectors_per_tuple ();
>  }
> 
> +/* If the function addresses memory, return the type of a single
> +   scalar memory element.  */
> +inline tree
> +function_instance::memory_scalar_type () const
> +{
> +  return base->memory_scalar_type (*this);
> +}
> +
>  /* Return information about the function's mode suffix.  */
>  inline const mode_suffix_info &
>  function_instance::mode_suffix () const
> --
> 2.34.1
diff mbox series

Patch

diff --git a/gcc/config/arm/arm-mve-builtins-shapes.cc b/gcc/config/arm/arm-mve-builtins-shapes.cc
index 23eb9d0e69b..ce87ebcef30 100644
--- a/gcc/config/arm/arm-mve-builtins-shapes.cc
+++ b/gcc/config/arm/arm-mve-builtins-shapes.cc
@@ -39,6 +39,13 @@ 
 
 namespace arm_mve {
 
+/* Return a representation of "const T *".  */
+static tree
+build_const_pointer (tree t)
+{
+  return build_pointer_type (build_qualified_type (t, TYPE_QUAL_CONST));
+}
+
 /* If INSTANCE has a predicate, add it to the list of argument types
    in ARGUMENT_TYPES.  RETURN_TYPE is the type returned by the
    function.  */
@@ -140,6 +147,9 @@  parse_element_type (const function_instance &instance, const char *&format)
 /* Read and return a type from FORMAT for function INSTANCE.  Advance
    FORMAT beyond the type string.  The format is:
 
+   _       - void
+   al      - array pointer for loads
+   as      - array pointer for stores
    p       - predicates with type mve_pred16_t
    s<elt>  - a scalar type with the given element suffix
    t<elt>  - a vector or tuple type with given element suffix [*1]
@@ -156,6 +166,21 @@  parse_type (const function_instance &instance, const char *&format)
 {
   int ch = *format++;
 
+
+  if (ch == '_')
+    return void_type_node;
+
+  if (ch == 'a')
+    {
+      ch = *format++;
+      if (ch == 'l')
+	return build_const_pointer (instance.memory_scalar_type ());
+      if (ch == 's') {
+	return build_pointer_type (instance.memory_scalar_type ());
+      }
+      gcc_unreachable ();
+    }
+
   if (ch == 'p')
     return get_mve_pred16_t ();
 
diff --git a/gcc/config/arm/arm-mve-builtins.h b/gcc/config/arm/arm-mve-builtins.h
index 37b8223dfb2..4fd230fe4c7 100644
--- a/gcc/config/arm/arm-mve-builtins.h
+++ b/gcc/config/arm/arm-mve-builtins.h
@@ -277,6 +277,7 @@  public:
   bool could_trap_p () const;
 
   unsigned int vectors_per_tuple () const;
+  tree memory_scalar_type () const;
 
   const mode_suffix_info &mode_suffix () const;
 
@@ -519,6 +520,14 @@  public:
      of vectors in the tuples, otherwise return 1.  */
   virtual unsigned int vectors_per_tuple () const { return 1; }
 
+  /* If the function addresses memory, return the type of a single
+     scalar memory element.  */
+  virtual tree
+  memory_scalar_type (const function_instance &) const
+  {
+    gcc_unreachable ();
+  }
+
   /* Try to fold the given gimple call.  Return the new gimple statement
      on success, otherwise return null.  */
   virtual gimple *fold (gimple_folder &) const { return NULL; }
@@ -644,6 +653,14 @@  function_instance::vectors_per_tuple () const
   return base->vectors_per_tuple ();
 }
 
+/* If the function addresses memory, return the type of a single
+   scalar memory element.  */
+inline tree
+function_instance::memory_scalar_type () const
+{
+  return base->memory_scalar_type (*this);
+}
+
 /* Return information about the function's mode suffix.  */
 inline const mode_suffix_info &
 function_instance::mode_suffix () const