RE: [PATCH 1/6] arm: Fix arm_simd_types and MVE scalar_types

2023-11-16 Thread Kyrylo Tkachov



> -Original Message-
> From: Christophe Lyon 
> Sent: Thursday, November 16, 2023 3:26 PM
> To: gcc-patches@gcc.gnu.org; Richard Sandiford
> ; Richard Earnshaw
> ; Kyrylo Tkachov 
> Cc: Christophe Lyon 
> Subject: [PATCH 1/6] arm: Fix arm_simd_types and MVE scalar_types
> 
> So far we define arm_simd_types and scalar_types using type
> definitions like intSI_type_node, etc...
> 
> This is causing problems with later patches which re-implement
> load/store MVE intrinsics, leading to error messages such as:
>   error: passing argument 1 of 'vst1q_s32' from incompatible pointer type
>   note: expected 'int *' but argument is of type 'int32_t *' {aka 'long int 
> *'}
> 
> This patch uses get_typenode_from_name (INT32_TYPE) instead, which
> defines the types as appropriate for the target/C library.

Ok.
Thanks,
Kyrill

> 
> 2023-11-16  Christophe Lyon  
> 
>   gcc/
>   * config/arm/arm-builtins.cc (arm_init_simd_builtin_types): Fix
>   initialization of arm_simd_types[].eltype.
>   * config/arm/arm-mve-builtins.def (DEF_MVE_TYPE): Fix scalar
>   types.
> ---
>  gcc/config/arm/arm-builtins.cc  | 28 ++--
>  gcc/config/arm/arm-mve-builtins.def | 16 
>  2 files changed, 22 insertions(+), 22 deletions(-)
> 
> diff --git a/gcc/config/arm/arm-builtins.cc b/gcc/config/arm/arm-builtins.cc
> index fca7dcaf565..dd9c5815c45 100644
> --- a/gcc/config/arm/arm-builtins.cc
> +++ b/gcc/config/arm/arm-builtins.cc
> @@ -1580,20 +1580,20 @@ arm_init_simd_builtin_types (void)
>TYPE_STRING_FLAG (arm_simd_polyHI_type_node) = false;
>  }
>/* Init all the element types built by the front-end.  */
> -  arm_simd_types[Int8x8_t].eltype = intQI_type_node;
> -  arm_simd_types[Int8x16_t].eltype = intQI_type_node;
> -  arm_simd_types[Int16x4_t].eltype = intHI_type_node;
> -  arm_simd_types[Int16x8_t].eltype = intHI_type_node;
> -  arm_simd_types[Int32x2_t].eltype = intSI_type_node;
> -  arm_simd_types[Int32x4_t].eltype = intSI_type_node;
> -  arm_simd_types[Int64x2_t].eltype = intDI_type_node;
> -  arm_simd_types[Uint8x8_t].eltype = unsigned_intQI_type_node;
> -  arm_simd_types[Uint8x16_t].eltype = unsigned_intQI_type_node;
> -  arm_simd_types[Uint16x4_t].eltype = unsigned_intHI_type_node;
> -  arm_simd_types[Uint16x8_t].eltype = unsigned_intHI_type_node;
> -  arm_simd_types[Uint32x2_t].eltype = unsigned_intSI_type_node;
> -  arm_simd_types[Uint32x4_t].eltype = unsigned_intSI_type_node;
> -  arm_simd_types[Uint64x2_t].eltype = unsigned_intDI_type_node;
> +  arm_simd_types[Int8x8_t].eltype = get_typenode_from_name
> (INT8_TYPE);
> +  arm_simd_types[Int8x16_t].eltype = get_typenode_from_name
> (INT8_TYPE);
> +  arm_simd_types[Int16x4_t].eltype = get_typenode_from_name
> (INT16_TYPE);
> +  arm_simd_types[Int16x8_t].eltype = get_typenode_from_name
> (INT16_TYPE);
> +  arm_simd_types[Int32x2_t].eltype = get_typenode_from_name
> (INT32_TYPE);
> +  arm_simd_types[Int32x4_t].eltype = get_typenode_from_name
> (INT32_TYPE);
> +  arm_simd_types[Int64x2_t].eltype = get_typenode_from_name
> (INT64_TYPE);
> +  arm_simd_types[Uint8x8_t].eltype = get_typenode_from_name
> (UINT8_TYPE);
> +  arm_simd_types[Uint8x16_t].eltype = get_typenode_from_name
> (UINT8_TYPE);
> +  arm_simd_types[Uint16x4_t].eltype = get_typenode_from_name
> (UINT16_TYPE);
> +  arm_simd_types[Uint16x8_t].eltype = get_typenode_from_name
> (UINT16_TYPE);
> +  arm_simd_types[Uint32x2_t].eltype = get_typenode_from_name
> (UINT32_TYPE);
> +  arm_simd_types[Uint32x4_t].eltype = get_typenode_from_name
> (UINT32_TYPE);
> +  arm_simd_types[Uint64x2_t].eltype = get_typenode_from_name
> (UINT64_TYPE);
> 
>/* Note: poly64x2_t is defined in arm_neon.h, to ensure it gets default
>   mangling.  */
> diff --git a/gcc/config/arm/arm-mve-builtins.def b/gcc/config/arm/arm-mve-
> builtins.def
> index e2cf1baf370..a901d8231e9 100644
> --- a/gcc/config/arm/arm-mve-builtins.def
> +++ b/gcc/config/arm/arm-mve-builtins.def
> @@ -39,14 +39,14 @@ DEF_MVE_MODE (r, none, none, none)
> 
>  #define REQUIRES_FLOAT false
>  DEF_MVE_TYPE (mve_pred16_t, boolean_type_node)
> -DEF_MVE_TYPE (uint8x16_t, unsigned_intQI_type_node)
> -DEF_MVE_TYPE (uint16x8_t, unsigned_intHI_type_node)
> -DEF_MVE_TYPE (uint32x4_t, unsigned_intSI_type_node)
> -DEF_MVE_TYPE (uint64x2_t, unsigned_intDI_type_node)
> -DEF_MVE_TYPE (int8x16_t, intQI_type_node)
> -DEF_MVE_TYPE (int16x8_t, intHI_type_node)
> -DEF_MVE_TYPE (int32x4_t, intSI_type_node)
> -DEF_MVE_TYPE (int64x2_t, intDI_type_node)
> +DEF_MVE_TYPE (uint8x16_t, get_typenode_from_name (UINT8_TYPE))
> +DEF_MVE_TYPE (uint16x8_t, get_typenode_from_name (UINT16_TYPE))
> +DEF_

[PATCH 1/6] arm: Fix arm_simd_types and MVE scalar_types

2023-11-16 Thread Christophe Lyon
So far we define arm_simd_types and scalar_types using type
definitions like intSI_type_node, etc...

This is causing problems with later patches which re-implement
load/store MVE intrinsics, leading to error messages such as:
  error: passing argument 1 of 'vst1q_s32' from incompatible pointer type
  note: expected 'int *' but argument is of type 'int32_t *' {aka 'long int *'}

This patch uses get_typenode_from_name (INT32_TYPE) instead, which
defines the types as appropriate for the target/C library.

2023-11-16  Christophe Lyon  

gcc/
* config/arm/arm-builtins.cc (arm_init_simd_builtin_types): Fix
initialization of arm_simd_types[].eltype.
* config/arm/arm-mve-builtins.def (DEF_MVE_TYPE): Fix scalar
types.
---
 gcc/config/arm/arm-builtins.cc  | 28 ++--
 gcc/config/arm/arm-mve-builtins.def | 16 
 2 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/gcc/config/arm/arm-builtins.cc b/gcc/config/arm/arm-builtins.cc
index fca7dcaf565..dd9c5815c45 100644
--- a/gcc/config/arm/arm-builtins.cc
+++ b/gcc/config/arm/arm-builtins.cc
@@ -1580,20 +1580,20 @@ arm_init_simd_builtin_types (void)
   TYPE_STRING_FLAG (arm_simd_polyHI_type_node) = false;
 }
   /* Init all the element types built by the front-end.  */
-  arm_simd_types[Int8x8_t].eltype = intQI_type_node;
-  arm_simd_types[Int8x16_t].eltype = intQI_type_node;
-  arm_simd_types[Int16x4_t].eltype = intHI_type_node;
-  arm_simd_types[Int16x8_t].eltype = intHI_type_node;
-  arm_simd_types[Int32x2_t].eltype = intSI_type_node;
-  arm_simd_types[Int32x4_t].eltype = intSI_type_node;
-  arm_simd_types[Int64x2_t].eltype = intDI_type_node;
-  arm_simd_types[Uint8x8_t].eltype = unsigned_intQI_type_node;
-  arm_simd_types[Uint8x16_t].eltype = unsigned_intQI_type_node;
-  arm_simd_types[Uint16x4_t].eltype = unsigned_intHI_type_node;
-  arm_simd_types[Uint16x8_t].eltype = unsigned_intHI_type_node;
-  arm_simd_types[Uint32x2_t].eltype = unsigned_intSI_type_node;
-  arm_simd_types[Uint32x4_t].eltype = unsigned_intSI_type_node;
-  arm_simd_types[Uint64x2_t].eltype = unsigned_intDI_type_node;
+  arm_simd_types[Int8x8_t].eltype = get_typenode_from_name (INT8_TYPE);
+  arm_simd_types[Int8x16_t].eltype = get_typenode_from_name (INT8_TYPE);
+  arm_simd_types[Int16x4_t].eltype = get_typenode_from_name (INT16_TYPE);
+  arm_simd_types[Int16x8_t].eltype = get_typenode_from_name (INT16_TYPE);
+  arm_simd_types[Int32x2_t].eltype = get_typenode_from_name (INT32_TYPE);
+  arm_simd_types[Int32x4_t].eltype = get_typenode_from_name (INT32_TYPE);
+  arm_simd_types[Int64x2_t].eltype = get_typenode_from_name (INT64_TYPE);
+  arm_simd_types[Uint8x8_t].eltype = get_typenode_from_name (UINT8_TYPE);
+  arm_simd_types[Uint8x16_t].eltype = get_typenode_from_name (UINT8_TYPE);
+  arm_simd_types[Uint16x4_t].eltype = get_typenode_from_name (UINT16_TYPE);
+  arm_simd_types[Uint16x8_t].eltype = get_typenode_from_name (UINT16_TYPE);
+  arm_simd_types[Uint32x2_t].eltype = get_typenode_from_name (UINT32_TYPE);
+  arm_simd_types[Uint32x4_t].eltype = get_typenode_from_name (UINT32_TYPE);
+  arm_simd_types[Uint64x2_t].eltype = get_typenode_from_name (UINT64_TYPE);
 
   /* Note: poly64x2_t is defined in arm_neon.h, to ensure it gets default
  mangling.  */
diff --git a/gcc/config/arm/arm-mve-builtins.def 
b/gcc/config/arm/arm-mve-builtins.def
index e2cf1baf370..a901d8231e9 100644
--- a/gcc/config/arm/arm-mve-builtins.def
+++ b/gcc/config/arm/arm-mve-builtins.def
@@ -39,14 +39,14 @@ DEF_MVE_MODE (r, none, none, none)
 
 #define REQUIRES_FLOAT false
 DEF_MVE_TYPE (mve_pred16_t, boolean_type_node)
-DEF_MVE_TYPE (uint8x16_t, unsigned_intQI_type_node)
-DEF_MVE_TYPE (uint16x8_t, unsigned_intHI_type_node)
-DEF_MVE_TYPE (uint32x4_t, unsigned_intSI_type_node)
-DEF_MVE_TYPE (uint64x2_t, unsigned_intDI_type_node)
-DEF_MVE_TYPE (int8x16_t, intQI_type_node)
-DEF_MVE_TYPE (int16x8_t, intHI_type_node)
-DEF_MVE_TYPE (int32x4_t, intSI_type_node)
-DEF_MVE_TYPE (int64x2_t, intDI_type_node)
+DEF_MVE_TYPE (uint8x16_t, get_typenode_from_name (UINT8_TYPE))
+DEF_MVE_TYPE (uint16x8_t, get_typenode_from_name (UINT16_TYPE))
+DEF_MVE_TYPE (uint32x4_t, get_typenode_from_name (UINT32_TYPE))
+DEF_MVE_TYPE (uint64x2_t, get_typenode_from_name (UINT64_TYPE))
+DEF_MVE_TYPE (int8x16_t, get_typenode_from_name (INT8_TYPE))
+DEF_MVE_TYPE (int16x8_t, get_typenode_from_name (INT16_TYPE))
+DEF_MVE_TYPE (int32x4_t, get_typenode_from_name (INT32_TYPE))
+DEF_MVE_TYPE (int64x2_t, get_typenode_from_name (INT64_TYPE))
 #undef REQUIRES_FLOAT
 
 #define REQUIRES_FLOAT true
-- 
2.34.1