Re: [PATCH][GCC] arm: fix __arm_vld1q_z* and __arm_vst1q_p* intrinsics.

2021-12-22 Thread Murray Steele via Gcc-patches
Hi,

On 22/12/2021 16:04, Richard Earnshaw wrote:

> 
> Is there a PR in bugzilla for this?
> 
> R.
> 


No, not at this time. It's something I came across whilst
making changes of my own.

For completeness, the ACLE specification I am referencing
has been added below [1].

[1]: https://github.com/ARM-software/acle/releases/tag/r2021Q3

Thanks,
Murray


[PATCH][GCC] arm: fix __arm_vld1q_z* and __arm_vst1q_p* intrinsics.

2021-12-22 Thread Murray Steele via Gcc-patches
Hi All,

This patch fixes the implementation of the existing __arm_vld1q_z* and
__arm_vst1q_p* MVE intrinsic functions.

The MVE ACLE allows for __ARM_MVE_PRESERVE_USER_NAMESPACE to be defined,
which removes definitions for intrinsic functions without the __arm_
prefix. __arm_vld1q_z* and __arm_vst1q_p* are currently implemented via
calls to vldr* and vstr*, which results in several compile-time errors when
__ARM_MVE_PRESERVE_USER_NAMESPACE is defined. This patch replaces these
with calls to their prefixed counterparts, __arm_vldr* and __arm_str*,
and adds a test covering the definition of __ARM_MVE_PRESERVE_USER_NAMESPACE.

Regression tested on arm-eabi -- no issues.

Thanks,
Murray

gcc/ChangeLog:

* config/arm/arm_mve.h (__arm_vst1q_p_u8): Use prefixed intrinsic
function.
(__arm_vst1q_p_s8): Likewise.
(__arm_vld1q_z_u8): Likewise.
(__arm_vld1q_z_s8): Likewise.
(__arm_vst1q_p_u16): Likewise.
(__arm_vst1q_p_s16): Likewise.
(__arm_vld1q_z_u16): Likewise.
(__arm_vld1q_z_s16): Likewise.
(__arm_vst1q_p_u32): Likewise.
(__arm_vst1q_p_s32): Likewise.
(__arm_vld1q_z_u32): Likewise.
(__arm_vld1q_z_s32): Likewise.
(__arm_vld1q_z_f16): Likewise.
(__arm_vst1q_p_f16): Likewise.
(__arm_vld1q_z_f32): Likewise.
(__arm_vst1q_p_f32): Likewise.

gcc/testsuite/ChangeLog:

* gcc.target/arm/mve/general/preserve_user_namespace_1.c: New test.diff --git a/gcc/config/arm/arm_mve.h b/gcc/config/arm/arm_mve.h
index 
e04d46218d03effdf0cb79471108cd2f24e92dec..708f5c71fddfc2cab0b0456e0b8724c803544ddc
 100644
--- a/gcc/config/arm/arm_mve.h
+++ b/gcc/config/arm/arm_mve.h
@@ -16171,14 +16171,14 @@ __extension__ extern __inline void
 __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
 __arm_vst1q_p_u8 (uint8_t * __addr, uint8x16_t __value, mve_pred16_t __p)
 {
-  return vstrbq_p_u8 (__addr, __value, __p);
+  return __arm_vstrbq_p_u8 (__addr, __value, __p);
 }
 
 __extension__ extern __inline void
 __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
 __arm_vst1q_p_s8 (int8_t * __addr, int8x16_t __value, mve_pred16_t __p)
 {
-  return vstrbq_p_s8 (__addr, __value, __p);
+  return __arm_vstrbq_p_s8 (__addr, __value, __p);
 }
 
 __extension__ extern __inline void
@@ -16203,14 +16203,14 @@ __extension__ extern __inline uint8x16_t
 __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
 __arm_vld1q_z_u8 (uint8_t const *__base, mve_pred16_t __p)
 {
-  return vldrbq_z_u8 ( __base, __p);
+  return __arm_vldrbq_z_u8 ( __base, __p);
 }
 
 __extension__ extern __inline int8x16_t
 __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
 __arm_vld1q_z_s8 (int8_t const *__base, mve_pred16_t __p)
 {
-  return vldrbq_z_s8 ( __base, __p);
+  return __arm_vldrbq_z_s8 ( __base, __p);
 }
 
 __extension__ extern __inline int8x16x2_t
@@ -16253,14 +16253,14 @@ __extension__ extern __inline void
 __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
 __arm_vst1q_p_u16 (uint16_t * __addr, uint16x8_t __value, mve_pred16_t __p)
 {
-  return vstrhq_p_u16 (__addr, __value, __p);
+  return __arm_vstrhq_p_u16 (__addr, __value, __p);
 }
 
 __extension__ extern __inline void
 __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
 __arm_vst1q_p_s16 (int16_t * __addr, int16x8_t __value, mve_pred16_t __p)
 {
-  return vstrhq_p_s16 (__addr, __value, __p);
+  return __arm_vstrhq_p_s16 (__addr, __value, __p);
 }
 
 __extension__ extern __inline void
@@ -16285,14 +16285,14 @@ __extension__ extern __inline uint16x8_t
 __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
 __arm_vld1q_z_u16 (uint16_t const *__base, mve_pred16_t __p)
 {
-  return vldrhq_z_u16 ( __base, __p);
+  return __arm_vldrhq_z_u16 ( __base, __p);
 }
 
 __extension__ extern __inline int16x8_t
 __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
 __arm_vld1q_z_s16 (int16_t const *__base, mve_pred16_t __p)
 {
-  return vldrhq_z_s16 ( __base, __p);
+  return __arm_vldrhq_z_s16 ( __base, __p);
 }
 
 __extension__ extern __inline int16x8x2_t
@@ -16335,14 +16335,14 @@ __extension__ extern __inline void
 __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
 __arm_vst1q_p_u32 (uint32_t * __addr, uint32x4_t __value, mve_pred16_t __p)
 {
-  return vstrwq_p_u32 (__addr, __value, __p);
+  return __arm_vstrwq_p_u32 (__addr, __value, __p);
 }
 
 __extension__ extern __inline void
 __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
 __arm_vst1q_p_s32 (int32_t * __addr, int32x4_t __value, mve_pred16_t __p)
 {
-  return vstrwq_p_s32 (__addr, __value, __p);
+  return __arm_vstrwq_p_s32 (__addr, __value, __p);
 }
 
 __extension__ extern __inline void
@@ -16367,14 +16367,14 @@ __extension__ extern __inline uint32x4_t
 __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
 __arm_vld1q_z_u32 (uint32_t const *__base, mve_pred16_t __

Re: [PATCH v3 2/2][GCC] arm: Declare MVE types internally via pragma

2021-12-21 Thread Murray Steele via Gcc-patches
Hi,


I'd like to ping this patch revision [1]. 

Thanks,
Murray

[1]: https://gcc.gnu.org/pipermail/gcc-patches/2021-December/586476.html

---

On 09/12/2021 15:24, Murray Steele via Gcc-patches wrote:
> Changes from original patch:
> 
> 1. Make mentioned changes to changelog.
> 2. Add namespace-end comments.
> 3. Add #error for when arm-mve-builtins.def is included without
>defining DEF_MVE_TYPE.
> 4. Make placement of '#undef DEF_MVE_TYPE' consistent.
> 
> ---
> 
> This patch moves the implementation of MVE ACLE types from
> arm_mve_types.h to inside GCC via a new pragma, which replaces the prior
> type definitions. This allows for the types to be used internally for
> intrinsic function definitions.
> 
> Bootstrapped and regression tested on arm-none-linux-gnuabihf, and
> regression tested on arm-eabi -- no issues.
> 
> Thanks,
> Murray
> 
> gcc/ChangeLog:
> 
> * config.gcc: Add arm-mve-builtins.o to extra_objs.
> * config/arm/arm-c.c (arm_pragma_arm): Handle "#pragma GCC arm".
> (arm_register_target_pragmas): Register it.
> * config/arm/arm-protos.h: (arm_mve::arm_handle_mve_types_h): New
> prototype.
> * config/arm/arm_mve_types.h: Replace MVE type definitions with
> new pragma.
> * config/arm/t-arm: (arm-mve-builtins.o): New target rule.
> * config/arm/arm-mve-builtins.cc: New file.
> * config/arm/arm-mve-builtins.def: New file.
> * config/arm/arm-mve-builtins.h: New file.
> 
> gcc/testsuite/ChangeLog:
> 
> * gcc.target/arm/mve/mve.exp: Add new subdirectories.
> * gcc.target/arm/mve/general-c/type_redef_1.c: New test.
> * gcc.target/arm/mve/general/double_pragmas_1.c: New test.
> * gcc.target/arm/mve/general/nomve_1.c: New test.


[PATCH v3 2/2][GCC] arm: Declare MVE types internally via pragma

2021-12-09 Thread Murray Steele via Gcc-patches
Changes from original patch:

1. Make mentioned changes to changelog.
2. Add namespace-end comments.
3. Add #error for when arm-mve-builtins.def is included without
   defining DEF_MVE_TYPE.
4. Make placement of '#undef DEF_MVE_TYPE' consistent.

---

This patch moves the implementation of MVE ACLE types from
arm_mve_types.h to inside GCC via a new pragma, which replaces the prior
type definitions. This allows for the types to be used internally for
intrinsic function definitions.

Bootstrapped and regression tested on arm-none-linux-gnuabihf, and
regression tested on arm-eabi -- no issues.

Thanks,
Murray

gcc/ChangeLog:

* config.gcc: Add arm-mve-builtins.o to extra_objs.
* config/arm/arm-c.c (arm_pragma_arm): Handle "#pragma GCC arm".
(arm_register_target_pragmas): Register it.
* config/arm/arm-protos.h: (arm_mve::arm_handle_mve_types_h): New
prototype.
* config/arm/arm_mve_types.h: Replace MVE type definitions with
new pragma.
* config/arm/t-arm: (arm-mve-builtins.o): New target rule.
* config/arm/arm-mve-builtins.cc: New file.
* config/arm/arm-mve-builtins.def: New file.
* config/arm/arm-mve-builtins.h: New file.

gcc/testsuite/ChangeLog:

* gcc.target/arm/mve/mve.exp: Add new subdirectories.
* gcc.target/arm/mve/general-c/type_redef_1.c: New test.
* gcc.target/arm/mve/general/double_pragmas_1.c: New test.
* gcc.target/arm/mve/general/nomve_1.c: New test.diff --git a/gcc/config.gcc b/gcc/config.gcc
index 
edd12655c4a1e6feb09aabbee77eacd9f66b4171..0aa386403112eff80cb5071fa6ff2fdbe610c9fc
 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -352,14 +352,14 @@ arc*-*-*)
;;
 arm*-*-*)
cpu_type=arm
-   extra_objs="arm-builtins.o aarch-common.o"
+   extra_objs="arm-builtins.o arm-mve-builtins.o aarch-common.o"
extra_headers="mmintrin.h arm_neon.h arm_acle.h arm_fp16.h arm_cmse.h 
arm_bf16.h arm_mve_types.h arm_mve.h arm_cde.h"
target_type_format_char='%'
c_target_objs="arm-c.o"
cxx_target_objs="arm-c.o"
d_target_objs="arm-d.o"
extra_options="${extra_options} arm/arm-tables.opt"
-   target_gtfiles="\$(srcdir)/config/arm/arm-builtins.c"
+   target_gtfiles="\$(srcdir)/config/arm/arm-builtins.c 
\$(srcdir)/config/arm/arm-mve-builtins.h 
\$(srcdir)/config/arm/arm-mve-builtins.cc"
;;
 avr-*-*)
cpu_type=avr
diff --git a/gcc/config/arm/arm-c.c b/gcc/config/arm/arm-c.c
index 
cc7901bca8dc9c5c27ed6afc5bc26afd42689e6d..d1414f6e0e1c2bd0a7364b837c16adf493221376
 100644
--- a/gcc/config/arm/arm-c.c
+++ b/gcc/config/arm/arm-c.c
@@ -28,6 +28,7 @@
 #include "c-family/c-pragma.h"
 #include "stringpool.h"
 #include "arm-builtins.h"
+#include "arm-protos.h"
 
 tree
 arm_resolve_cde_builtin (location_t loc, tree fndecl, void *arglist)
@@ -129,6 +130,24 @@ arm_resolve_cde_builtin (location_t loc, tree fndecl, void 
*arglist)
   return call_expr;
 }
 
+/* Implement "#pragma GCC arm".  */
+static void
+arm_pragma_arm (cpp_reader *)
+{
+  tree x;
+  if (pragma_lex (&x) != CPP_STRING)
+{
+  error ("%<#pragma GCC arm%> requires a string parameter");
+  return;
+}
+
+  const char *name = TREE_STRING_POINTER (x);
+  if (strcmp (name, "arm_mve_types.h") == 0)
+arm_mve::handle_arm_mve_types_h ();
+  else
+error ("unknown %<#pragma GCC arm%> option %qs", name);
+}
+
 /* Implement TARGET_RESOLVE_OVERLOADED_BUILTIN.  This is currently only
used for the MVE related builtins for the CDE extension.
Here we ensure the type of arguments is such that the size is correct, and
@@ -476,6 +495,8 @@ arm_register_target_pragmas (void)
   targetm.target_option.pragma_parse = arm_pragma_target_parse;
   targetm.resolve_overloaded_builtin = arm_resolve_overloaded_builtin;
 
+  c_register_pragma ("GCC", "arm", arm_pragma_arm);
+
 #ifdef REGISTER_SUBTARGET_PRAGMAS
   REGISTER_SUBTARGET_PRAGMAS ();
 #endif
diff --git a/gcc/config/arm/arm-mve-builtins.cc 
b/gcc/config/arm/arm-mve-builtins.cc
new file mode 100644
index 
..71838a83caa417195971114239accc1633c238fb
--- /dev/null
+++ b/gcc/config/arm/arm-mve-builtins.cc
@@ -0,0 +1,196 @@
+/* ACLE support for Arm MVE
+   Copyright (C) 2021 Free Software Foundation, Inc.
+
+   This file is part of GCC.
+
+   GCC is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3, or (at your option)
+   any later version.
+
+   GCC is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with GCC; see the file COPYING3.  If not see
+   .  */

Re: [PATCH 2/2][GCC] arm: Declare MVE types internally via pragma

2021-12-08 Thread Murray Steele via Gcc-patches
Hi,

Thank you for the feedback, I'll make the noted changes to the changelog and
add the missing end-of-namespace comments.

On 08/12/2021 15:23, Richard Earnshaw wrote:

> diff --git a/gcc/config/arm/arm-mve-builtins.def 
> b/gcc/config/arm/arm-mve-builtins.def
> new file mode 100644
> index 
> ..02a46bec3e4cba6add9bce4021c732e15aa8b012
> --- /dev/null
> +++ b/gcc/config/arm/arm-mve-builtins.def
> @@ -0,0 +1,41 @@
> 
> +#ifndef DEF_MVE_TYPE
> +#define DEF_MVE_TYPE(A, B)
> +#endif
> 
> When would this file ever be included when this macro wasn't defined? Better 
> to require the caller to define this by using #error if it's missing.
> 
> then...
> 
> +
> +#undef DEF_MVE_TYPE
> 
> This isn't needed anymore, because caller should undef it after use.


I'd added this because later patches that build from this series will most
likely need to define further DEF_MVE_* macros, in the style of the current
SVE implementation. You are right that it is unnecessary for right now though,
and I'll remove it too.

Thanks again,

Murray


[PING][PATCH 2/2][GCC] arm: Declare MVE types internally via pragma

2021-12-08 Thread Murray Steele via Gcc-patches
Hi,


I'd like to ping this patch revision [1]. 

Thanks,
Murray

[1]: https://gcc.gnu.org/pipermail/gcc-patches/2021-November/585400.html

---

On 25/11/2021 09:42, Murray Steele wrote:
> Changes from original patch:
> 
> 1. Merged test_redef_* test files into one
> 2. Encapsulated contents of arm-mve-builtins.h in namespace arm_mve (missed
>in initial patch).
> 3. Added extern declarations for scalar_types and acle_vector types to
>arm-mve-builtins.h (missed in initial patch).
> 4. Added arm-mve-builtins.(cc|h) to gt_targets for arm-*-*-* (missed in
>initial patch).
> 5. Added include for gt-arm-mve-builtins.h to arm-mve-builtins.cc (missed in
>initial patch).
> 6. Removed explicit initialisation of handle_arm_mve_types_p as it is 
> unneeded.
> 
> ---
> 
> This patch moves the implementation of MVE ACLE types from
> arm_mve_types.h to inside GCC via a new pragma, which replaces the prior
> type definitions. This allows for the types to be used internally for
> intrinsic function definitions.
> 
> Bootstrapped and regression tested on arm-none-linux-gnuabihf, and
> regression tested on arm-eabi -- no issues.
> 
> Thanks,
> Murray
> 
> gcc/ChangeLog:
> 
> * config.gcc: Add arm-mve-builtins.o to extra_objs for arm-*-*-*
> targets.
> * config/arm/arm-c.c (arm_pragma_arm): Handle new pragma.
> (arm_register_target_pragmas): Register new pragma.
> * config/arm/arm-protos.h: Add arm_mve namespace and declare
> arm_handle_mve_types_h.
> * config/arm/arm_mve_types.h: Replace MVE type definitions with
> new pragma.
> * config/arm/t-arm: Add arm-mve-builtins.o target.
> * config/arm/arm-mve-builtins.cc: New file.
> * config/arm/arm-mve-builtins.def: New file.
> * config/arm/arm-mve-builtins.h: New file.
> 
> gcc/testsuite/ChangeLog:
> 
> * gcc.target/arm/mve/mve.exp: Add new subdirectories.
> * gcc.target/arm/mve/general-c/type_redef_1.c: New test.
> * gcc.target/arm/mve/general/double_pragmas_1.c: New test.
> * gcc.target/arm/mve/general/nomve_1.c: New test.
> 



Re: [PATCH 2/2][GCC] arm: Declare MVE types internally via pragma

2021-11-25 Thread Murray Steele via Gcc-patches
Changes from original patch:

1. Merged test_redef_* test files into one
2. Encapsulated contents of arm-mve-builtins.h in namespace arm_mve (missed
   in initial patch).
3. Added extern declarations for scalar_types and acle_vector types to
   arm-mve-builtins.h (missed in initial patch).
4. Added arm-mve-builtins.(cc|h) to gt_targets for arm-*-*-* (missed in
   initial patch).
5. Added include for gt-arm-mve-builtins.h to arm-mve-builtins.cc (missed in
   initial patch).
6. Removed explicit initialisation of handle_arm_mve_types_p as it is unneeded.

---

This patch moves the implementation of MVE ACLE types from
arm_mve_types.h to inside GCC via a new pragma, which replaces the prior
type definitions. This allows for the types to be used internally for
intrinsic function definitions.

Bootstrapped and regression tested on arm-none-linux-gnuabihf, and
regression tested on arm-eabi -- no issues.

Thanks,
Murray

gcc/ChangeLog:

* config.gcc: Add arm-mve-builtins.o to extra_objs for arm-*-*-*
targets.
* config/arm/arm-c.c (arm_pragma_arm): Handle new pragma.
(arm_register_target_pragmas): Register new pragma.
* config/arm/arm-protos.h: Add arm_mve namespace and declare
arm_handle_mve_types_h.
* config/arm/arm_mve_types.h: Replace MVE type definitions with
new pragma.
* config/arm/t-arm: Add arm-mve-builtins.o target.
* config/arm/arm-mve-builtins.cc: New file.
* config/arm/arm-mve-builtins.def: New file.
* config/arm/arm-mve-builtins.h: New file.

gcc/testsuite/ChangeLog:

* gcc.target/arm/mve/mve.exp: Add new subdirectories.
* gcc.target/arm/mve/general-c/type_redef_1.c: New test.
* gcc.target/arm/mve/general/double_pragmas_1.c: New test.
* gcc.target/arm/mve/general/nomve_1.c: New test.
diff --git a/gcc/config.gcc b/gcc/config.gcc
index 
edd12655c4a1e6feb09aabbee77eacd9f66b4171..0aa386403112eff80cb5071fa6ff2fdbe610c9fc
 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -352,14 +352,14 @@ arc*-*-*)
;;
 arm*-*-*)
cpu_type=arm
-   extra_objs="arm-builtins.o aarch-common.o"
+   extra_objs="arm-builtins.o arm-mve-builtins.o aarch-common.o"
extra_headers="mmintrin.h arm_neon.h arm_acle.h arm_fp16.h arm_cmse.h 
arm_bf16.h arm_mve_types.h arm_mve.h arm_cde.h"
target_type_format_char='%'
c_target_objs="arm-c.o"
cxx_target_objs="arm-c.o"
d_target_objs="arm-d.o"
extra_options="${extra_options} arm/arm-tables.opt"
-   target_gtfiles="\$(srcdir)/config/arm/arm-builtins.c"
+   target_gtfiles="\$(srcdir)/config/arm/arm-builtins.c 
\$(srcdir)/config/arm/arm-mve-builtins.h 
\$(srcdir)/config/arm/arm-mve-builtins.cc"
;;
 avr-*-*)
cpu_type=avr
diff --git a/gcc/config/arm/arm-c.c b/gcc/config/arm/arm-c.c
index 
cc7901bca8dc9c5c27ed6afc5bc26afd42689e6d..d1414f6e0e1c2bd0a7364b837c16adf493221376
 100644
--- a/gcc/config/arm/arm-c.c
+++ b/gcc/config/arm/arm-c.c
@@ -28,6 +28,7 @@
 #include "c-family/c-pragma.h"
 #include "stringpool.h"
 #include "arm-builtins.h"
+#include "arm-protos.h"
 
 tree
 arm_resolve_cde_builtin (location_t loc, tree fndecl, void *arglist)
@@ -129,6 +130,24 @@ arm_resolve_cde_builtin (location_t loc, tree fndecl, void 
*arglist)
   return call_expr;
 }
 
+/* Implement "#pragma GCC arm".  */
+static void
+arm_pragma_arm (cpp_reader *)
+{
+  tree x;
+  if (pragma_lex (&x) != CPP_STRING)
+{
+  error ("%<#pragma GCC arm%> requires a string parameter");
+  return;
+}
+
+  const char *name = TREE_STRING_POINTER (x);
+  if (strcmp (name, "arm_mve_types.h") == 0)
+arm_mve::handle_arm_mve_types_h ();
+  else
+error ("unknown %<#pragma GCC arm%> option %qs", name);
+}
+
 /* Implement TARGET_RESOLVE_OVERLOADED_BUILTIN.  This is currently only
used for the MVE related builtins for the CDE extension.
Here we ensure the type of arguments is such that the size is correct, and
@@ -476,6 +495,8 @@ arm_register_target_pragmas (void)
   targetm.target_option.pragma_parse = arm_pragma_target_parse;
   targetm.resolve_overloaded_builtin = arm_resolve_overloaded_builtin;
 
+  c_register_pragma ("GCC", "arm", arm_pragma_arm);
+
 #ifdef REGISTER_SUBTARGET_PRAGMAS
   REGISTER_SUBTARGET_PRAGMAS ();
 #endif
diff --git a/gcc/config/arm/arm-mve-builtins.cc 
b/gcc/config/arm/arm-mve-builtins.cc
new file mode 100644
index 
..99ddc8d49aad39e057c1c0d349c6c02c278553d6
--- /dev/null
+++ b/gcc/config/arm/arm-mve-builtins.cc
@@ -0,0 +1,196 @@
+/* ACLE support for Arm MVE
+   Copyright (C) 2021 Free Software Foundation, Inc.
+
+   This file is part of GCC.
+
+   GCC is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3, or (at your option)
+   any later version.
+
+   GCC is distributed in the hope that it will be useful, but

Re: [PATCH 1/2][GCC] arm: Move arm_simd_info array declaration into header

2021-11-24 Thread Murray Steele via Gcc-patches
On 18/11/2021 15:40, Richard Earnshaw wrote:
> 
> 
> On 16/11/2021 10:14, Murray Steele via Gcc-patches wrote:
>> Hi all,
>>
>> This patch moves the arm_simd_type and arm_type_qualifiers enums, and
>> arm_simd_info struct from arm-builtins.c into arm-builtins.h header.
>>
>> This is a first step towards internalising the type definitions for MVE
>> predicate, vector, and tuple types.  By moving arm_simd_types into a
>> header, we allow future patches to use these type trees externally to
>> arm-builtins.c, which is a crucial step towards developing an MVE
>> intrinsics framework similar to the current SVE implementation.
>>
>> Thanks,
>> Murray
>>
>> gcc/ChangeLog:
>>
>> * config/arm/arm-builtins.c (enum arm_type_qualifiers): Move to
>> arm_builtins.h
>> (enum arm_simd_type): Move to arm-builtins.h
>> (struct arm_simd_type_info): Move to arm-builtins.h
>> * config/arm/arm-builtins.h (enum arm_simd_type): Move from
>> arm-builtins.c
>> (enum arm_type_qualifiers): Move from arm-builtins.c
>> (struct arm_simd_type_info): Move from arm-builtins.c
>>
>>
>>
> 
> OK.
> 
> R.

Hi Richard,

I don't currently have write access, so I will need this patch committed on my 
behalf.

Thanks again,
Murray


Re: [PATCH 2/2][GCC] arm: Declare MVE types internally via pragma

2021-11-23 Thread Murray Steele via Gcc-patches
On 23/11/2021 14:16, Richard Earnshaw wrote:
> 
> 
> On 23/11/2021 09:37, Murray Steele wrote:
>> On 18/11/2021 15:45, Richard Earnshaw wrote:
>>
>>>
>>> This is mostly OK, but can't we reduce the number of tests somewhat? For 
>>> example, I think you can merge type_redef_13.c and type_redef_14.c by 
>>> writing
>>>
>>> /* { dg-do compile } */
>>> /* { dg-require-effective-target arm_v8_1m_mve_ok } */
>>> /* { dg-add-options arm_v8_1m_mve } */
>>>
>>> int uint8x16x4_t; /* { dg-message "note: previous declaration of 
>>> 'uint8x16x4_t'" } */
>>> int uint16x8x2_t; /* { dg-message "note: previous declaration of 
>>> 'uint16x8x2_t'" } */
>>>
>>> #pragma GCC arm "arm_mve_types.h"  /* { dg-error {'uint8x16x4_t' 
>>> redeclared} } */
>>>    /* { dg-error {'uint16x8x2_t' redeclared} {target *-*-*} .-1 } */
>>>
>>> etc.  Note the second dg-error is anchored to the line above it (.-1).
>>>
>>> R.
>>
>> Thanks. I think if we'd like to reduce the number of tests, it would make 
>> the most
>> sense to merge the test cases in the way you've described based on their 
>> implementation
>> and target features. i.e.
>>
>> - type_redef_1.c : covers mve_pred16_t.
>> - type_redef_2.c : covers single-integer-vector types.
>> - type_redef_3.c : covers single-float-vector types.
>> - type_redef_4.c : covers integer-vector-tuple types.
>> - type_redef_5.c : covers float-vector-tuple types.
>>
>> The idea being that the test results for these tests should allow someone to 
>> triangulate
>> the cause of the failure. For example, if tests 4 and 5 fail, it is likely 
>> due to a
>> deficiency in the MVE tuple type implementation, rather than the handling of 
>> target-specific
>> features. More specific tests failures can be determined by looking through 
>> log files.
>>
>> Thanks,
>> Murray
>>
> 
> Merged files will still have the same number of tests, and the same possible 
> test names, just from fewer source files.  So I don't think triangulation 
> will be an issue.

Ok. In that case we could merge all source files into one which covers all 
types.

Thanks,
Murray


Re: [PATCH 2/2][GCC] arm: Declare MVE types internally via pragma

2021-11-23 Thread Murray Steele via Gcc-patches
On 18/11/2021 15:45, Richard Earnshaw wrote:

> 
> This is mostly OK, but can't we reduce the number of tests somewhat? For 
> example, I think you can merge type_redef_13.c and type_redef_14.c by writing
> 
> /* { dg-do compile } */
> /* { dg-require-effective-target arm_v8_1m_mve_ok } */
> /* { dg-add-options arm_v8_1m_mve } */
> 
> int uint8x16x4_t; /* { dg-message "note: previous declaration of 
> 'uint8x16x4_t'" } */
> int uint16x8x2_t; /* { dg-message "note: previous declaration of 
> 'uint16x8x2_t'" } */
> 
> #pragma GCC arm "arm_mve_types.h"  /* { dg-error {'uint8x16x4_t' redeclared} 
> } */
>   /* { dg-error {'uint16x8x2_t' redeclared} {target *-*-*} .-1 } */
> 
> etc.  Note the second dg-error is anchored to the line above it (.-1).
> 
> R.

Thanks. I think if we'd like to reduce the number of tests, it would make the 
most
sense to merge the test cases in the way you've described based on their 
implementation
and target features. i.e.

- type_redef_1.c : covers mve_pred16_t.
- type_redef_2.c : covers single-integer-vector types.
- type_redef_3.c : covers single-float-vector types.
- type_redef_4.c : covers integer-vector-tuple types.
- type_redef_5.c : covers float-vector-tuple types.

The idea being that the test results for these tests should allow someone to 
triangulate
the cause of the failure. For example, if tests 4 and 5 fail, it is likely due 
to a
deficiency in the MVE tuple type implementation, rather than the handling of 
target-specific
features. More specific tests failures can be determined by looking through log 
files.

Thanks,
Murray


[PATCH 2/2][GCC] arm: Declare MVE types internally via pragma

2021-11-16 Thread Murray Steele via Gcc-patches
Hi all,

This patch moves the implementation of MVE ACLE types from
arm_mve_types.h to inside GCC via a new pragma, which replaces the prior
type definitions. This allows for the types to be used internally for
intrinsic function definitions.

Bootstrapped and regression tested on arm-none-linux-gnuabihf, and
regression tested on arm-eabi -- no issues.

Thanks,
Murray

gcc/ChangeLog:

* config.gcc: Add arm-mve-builtins.o to extra_objs for arm-*-*-*
targets.
* config/arm/arm-c.c (arm_pragma_arm): Handle new pragma.
(arm_register_target_pragmas): Register new pragma.
* config/arm/arm-protos.h: Add arm_mve namespace and declare
arm_handle_mve_types_h.
* config/arm/arm_mve_types.h: Replace MVE type definitions with
new pragma.
* config/arm/t-arm: Add arm-mve-builtins.o target.
* config/arm/arm-mve-builtins.cc: New file.
* config/arm/arm-mve-builtins.def: New file.
* config/arm/arm-mve-builtins.h: New file.

gcc/testsuite/ChangeLog:

* gcc.target/arm/mve/mve.exp: Add new subdirectories.
* gcc.target/arm/mve/general-c/type_redef_1.c: New test.
* gcc.target/arm/mve/general-c/type_redef_10.c: New test.
* gcc.target/arm/mve/general-c/type_redef_11.c: New test.
* gcc.target/arm/mve/general-c/type_redef_12.c: New test.
* gcc.target/arm/mve/general-c/type_redef_13.c: New test.
* gcc.target/arm/mve/general-c/type_redef_14.c: New test.
* gcc.target/arm/mve/general-c/type_redef_15.c: New test.
* gcc.target/arm/mve/general-c/type_redef_16.c: New test.
* gcc.target/arm/mve/general-c/type_redef_17.c: New test.
* gcc.target/arm/mve/general-c/type_redef_18.c: New test.
* gcc.target/arm/mve/general-c/type_redef_19.c: New test.
* gcc.target/arm/mve/general-c/type_redef_2.c: New test.
* gcc.target/arm/mve/general-c/type_redef_20.c: New test.
* gcc.target/arm/mve/general-c/type_redef_21.c: New test.
* gcc.target/arm/mve/general-c/type_redef_22.c: New test.
* gcc.target/arm/mve/general-c/type_redef_23.c: New test.
* gcc.target/arm/mve/general-c/type_redef_24.c: New test.
* gcc.target/arm/mve/general-c/type_redef_25.c: New test.
* gcc.target/arm/mve/general-c/type_redef_26.c: New test.
* gcc.target/arm/mve/general-c/type_redef_27.c: New test.
* gcc.target/arm/mve/general-c/type_redef_28.c: New test.
* gcc.target/arm/mve/general-c/type_redef_29.c: New test.
* gcc.target/arm/mve/general-c/type_redef_3.c: New test.
* gcc.target/arm/mve/general-c/type_redef_30.c: New test.
* gcc.target/arm/mve/general-c/type_redef_31.c: New test.
* gcc.target/arm/mve/general-c/type_redef_4.c: New test.
* gcc.target/arm/mve/general-c/type_redef_5.c: New test.
* gcc.target/arm/mve/general-c/type_redef_6.c: New test.
* gcc.target/arm/mve/general-c/type_redef_7.c: New test.
* gcc.target/arm/mve/general-c/type_redef_8.c: New test.
* gcc.target/arm/mve/general-c/type_redef_9.c: New test.
* gcc.target/arm/mve/general/double_pragmas_1.c: New test.
* gcc.target/arm/mve/general/nomve_1.c: New test.



diff --git a/gcc/config.gcc b/gcc/config.gcc
index 
3675e063a5365ff84854eb5c2c27921216494c69..50d3401e3aa94f077d7e0675ee443a94431dba1e
 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -352,7 +352,7 @@ arc*-*-*)
;;
 arm*-*-*)
cpu_type=arm
-   extra_objs="arm-builtins.o aarch-common.o"
+   extra_objs="arm-builtins.o arm-mve-builtins.o aarch-common.o"
extra_headers="mmintrin.h arm_neon.h arm_acle.h arm_fp16.h arm_cmse.h 
arm_bf16.h arm_mve_types.h arm_mve.h arm_cde.h"
target_type_format_char='%'
c_target_objs="arm-c.o"
diff --git a/gcc/config/arm/arm-c.c b/gcc/config/arm/arm-c.c
index 
cc7901bca8dc9c5c27ed6afc5bc26afd42689e6d..d1414f6e0e1c2bd0a7364b837c16adf493221376
 100644
--- a/gcc/config/arm/arm-c.c
+++ b/gcc/config/arm/arm-c.c
@@ -28,6 +28,7 @@
 #include "c-family/c-pragma.h"
 #include "stringpool.h"
 #include "arm-builtins.h"
+#include "arm-protos.h"
 
 tree
 arm_resolve_cde_builtin (location_t loc, tree fndecl, void *arglist)
@@ -129,6 +130,24 @@ arm_resolve_cde_builtin (location_t loc, tree fndecl, void 
*arglist)
   return call_expr;
 }
 
+/* Implement "#pragma GCC arm".  */
+static void
+arm_pragma_arm (cpp_reader *)
+{
+  tree x;
+  if (pragma_lex (&x) != CPP_STRING)
+{
+  error ("%<#pragma GCC arm%> requires a string parameter");
+  return;
+}
+
+  const char *name = TREE_STRING_POINTER (x);
+  if (strcmp (name, "arm_mve_types.h") == 0)
+arm_mve::handle_arm_mve_types_h ();
+  else
+error ("unknown %<#pragma GCC arm%> option %qs", name);
+}
+
 /* Implement TARGET_RESOLVE_OVERLOADED_BUILTIN.  This is currently only
used for the MVE related builtins for the CDE extension.
Here we ensure the type of arguments is such

[PATCH 1/2][GCC] arm: Move arm_simd_info array declaration into header

2021-11-16 Thread Murray Steele via Gcc-patches
Hi all,

This patch moves the arm_simd_type and arm_type_qualifiers enums, and
arm_simd_info struct from arm-builtins.c into arm-builtins.h header.

This is a first step towards internalising the type definitions for MVE
predicate, vector, and tuple types.  By moving arm_simd_types into a
header, we allow future patches to use these type trees externally to
arm-builtins.c, which is a crucial step towards developing an MVE
intrinsics framework similar to the current SVE implementation.

Thanks,
Murray

gcc/ChangeLog:

* config/arm/arm-builtins.c (enum arm_type_qualifiers): Move to
arm_builtins.h
(enum arm_simd_type): Move to arm-builtins.h
(struct arm_simd_type_info): Move to arm-builtins.h
* config/arm/arm-builtins.h (enum arm_simd_type): Move from
arm-builtins.c
(enum arm_type_qualifiers): Move from arm-builtins.c
(struct arm_simd_type_info): Move from arm-builtins.c



diff --git a/gcc/config/arm/arm-builtins.h b/gcc/config/arm/arm-builtins.h
index 
bee9f9bb83758820ca7faedf80b7e138026c1ca0..a40fa8950707314d3cc1372fb5c47a8891a18516
 100644
--- a/gcc/config/arm/arm-builtins.h
+++ b/gcc/config/arm/arm-builtins.h
@@ -32,4 +32,91 @@ enum resolver_ident {
 enum resolver_ident arm_describe_resolver (tree);
 unsigned arm_cde_end_args (tree);
 
+#define ENTRY(E, M, Q, S, T, G) E,
+enum arm_simd_type
+{
+#include "arm-simd-builtin-types.def"
+  __TYPE_FINAL
+};
+#undef ENTRY
+
+enum arm_type_qualifiers
+{
+  /* T foo.  */
+  qualifier_none = 0x0,
+  /* unsigned T foo.  */
+  qualifier_unsigned = 0x1, /* 1 << 0  */
+  /* const T foo.  */
+  qualifier_const = 0x2, /* 1 << 1  */
+  /* T *foo.  */
+  qualifier_pointer = 0x4, /* 1 << 2  */
+  /* const T * foo.  */
+  qualifier_const_pointer = 0x6,
+  /* Used when expanding arguments if an operand could
+ be an immediate.  */
+  qualifier_immediate = 0x8, /* 1 << 3  */
+  qualifier_unsigned_immediate = 0x9,
+  qualifier_maybe_immediate = 0x10, /* 1 << 4  */
+  /* void foo (...).  */
+  qualifier_void = 0x20, /* 1 << 5  */
+  /* Some patterns may have internal operands, this qualifier is an
+ instruction to the initialisation code to skip this operand.  */
+  qualifier_internal = 0x40, /* 1 << 6  */
+  /* Some builtins should use the T_*mode* encoded in a simd_builtin_datum
+ rather than using the type of the operand.  */
+  qualifier_map_mode = 0x80, /* 1 << 7  */
+  /* qualifier_pointer | qualifier_map_mode  */
+  qualifier_pointer_map_mode = 0x84,
+  /* qualifier_const_pointer | qualifier_map_mode  */
+  qualifier_const_pointer_map_mode = 0x86,
+  /* Polynomial types.  */
+  qualifier_poly = 0x100,
+  /* Lane indices - must be within range of previous argument = a vector.  */
+  qualifier_lane_index = 0x200,
+  /* Lane indices for single lane structure loads and stores.  */
+  qualifier_struct_load_store_lane_index = 0x400,
+  /* A void pointer.  */
+  qualifier_void_pointer = 0x800,
+  /* A const void pointer.  */
+  qualifier_const_void_pointer = 0x802,
+  /* Lane indices selected in pairs - must be within range of previous
+ argument = a vector.  */
+  qualifier_lane_pair_index = 0x1000,
+  /* Lane indices selected in quadtuplets - must be within range of previous
+ argument = a vector.  */
+  qualifier_lane_quadtup_index = 0x2000
+};
+
+struct arm_simd_type_info
+{
+  enum arm_simd_type type;
+
+  /* Internal type name.  */
+  const char *name;
+
+  /* Internal type name(mangled).  The mangled names conform to the
+ AAPCS (see "Procedure Call Standard for the ARM Architecture",
+ Appendix A).  To qualify for emission with the mangled names defined in
+ that document, a vector type must not only be of the correct mode but also
+ be of the correct internal Neon vector type (e.g. __simd64_int8_t);
+ these types are registered by arm_init_simd_builtin_types ().  In other
+ words, vector types defined in other ways e.g. via vector_size attribute
+ will get default mangled names.  */
+  const char *mangle;
+
+  /* Internal type.  */
+  tree itype;
+
+  /* Element type.  */
+  tree eltype;
+
+  /* Machine mode the internal type maps to.  */
+  machine_mode mode;
+
+  /* Qualifiers.  */
+  enum arm_type_qualifiers q;
+};
+
+extern struct arm_simd_type_info arm_simd_types[];
+
 #endif /* GCC_ARM_BUILTINS_H */
diff --git a/gcc/config/arm/arm-builtins.c b/gcc/config/arm/arm-builtins.c
index 
3a9ff8f26b8e222c52cb70f7509b714c3e475758..b6bf31349d8f0e996a6c169b061ebe05a2cf9acb
 100644
--- a/gcc/config/arm/arm-builtins.c
+++ b/gcc/config/arm/arm-builtins.c
@@ -48,53 +48,6 @@
 
 #define SIMD_MAX_BUILTIN_ARGS 7
 
-enum arm_type_qualifiers
-{
-  /* T foo.  */
-  qualifier_none = 0x0,
-  /* unsigned T foo.  */
-  qualifier_unsigned = 0x1, /* 1 << 0  */
-  /* const T foo.  */
-  qualifier_const = 0x2, /* 1 << 1  */
-  /* T *foo.  */
-  qualifier_pointer = 0x4, /* 1 << 2  */
-  /* const T * foo.  */
-  qualifier_const_pointer = 0x6,
-  /* Used when expanding arguments if an o

[PATCH 0/2][GCC] arm: Define MVE types internally

2021-11-16 Thread Murray Steele via Gcc-patches
Hi all,

This patch series implements the arm MVE ACLE types currently found
under config/arm/arm_mve_types.h internally via a new pragma. Exposing
the MVE ACLE types internally allows for an MVE intrinsics
implementation similar to the current SVE implementation.

Any prefix of the patch series should build and pass regression tests.

Thanks,
Murray

---

Murray Steele (2):
  arm: Move arm_simd_info array declaration into header
  arm: Define MVE types internally via pragma

 gcc/config.gcc|   2 +-
 gcc/config/arm/arm-builtins.c |  87 +---
 gcc/config/arm/arm-builtins.h |  87 
 gcc/config/arm/arm-c.c|  21 ++
 gcc/config/arm/arm-mve-builtins.cc| 192 ++
 gcc/config/arm/arm-mve-builtins.def   |  41 
 gcc/config/arm/arm-mve-builtins.h |  34 
 gcc/config/arm/arm-protos.h   |   5 +
 gcc/config/arm/arm_mve_types.h|  30 +--
 gcc/config/arm/t-arm  |  10 +
 .../arm/mve/general-c/type_redef_1.c  |   7 +
 .../arm/mve/general-c/type_redef_10.c |   7 +
 .../arm/mve/general-c/type_redef_11.c |   7 +
 .../arm/mve/general-c/type_redef_12.c |   7 +
 .../arm/mve/general-c/type_redef_13.c |   7 +
 .../arm/mve/general-c/type_redef_14.c |   7 +
 .../arm/mve/general-c/type_redef_15.c |   7 +
 .../arm/mve/general-c/type_redef_16.c |   7 +
 .../arm/mve/general-c/type_redef_17.c |   7 +
 .../arm/mve/general-c/type_redef_18.c |   7 +
 .../arm/mve/general-c/type_redef_19.c |   7 +
 .../arm/mve/general-c/type_redef_2.c  |   7 +
 .../arm/mve/general-c/type_redef_20.c |   7 +
 .../arm/mve/general-c/type_redef_21.c |   7 +
 .../arm/mve/general-c/type_redef_22.c |   7 +
 .../arm/mve/general-c/type_redef_23.c |   7 +
 .../arm/mve/general-c/type_redef_24.c |   7 +
 .../arm/mve/general-c/type_redef_25.c |   7 +
 .../arm/mve/general-c/type_redef_26.c |   7 +
 .../arm/mve/general-c/type_redef_27.c |   7 +
 .../arm/mve/general-c/type_redef_28.c |   7 +
 .../arm/mve/general-c/type_redef_29.c |   7 +
 .../arm/mve/general-c/type_redef_3.c  |   7 +
 .../arm/mve/general-c/type_redef_30.c |   7 +
 .../arm/mve/general-c/type_redef_31.c |   7 +
 .../arm/mve/general-c/type_redef_4.c  |   7 +
 .../arm/mve/general-c/type_redef_5.c  |   7 +
 .../arm/mve/general-c/type_redef_6.c  |   7 +
 .../arm/mve/general-c/type_redef_7.c  |   7 +
 .../arm/mve/general-c/type_redef_8.c  |   7 +
 .../arm/mve/general-c/type_redef_9.c  |   7 +
 .../arm/mve/general/double_pragmas_1.c|   8 +
 .../gcc.target/arm/mve/general/nomve_1.c  |   3 +
 gcc/testsuite/gcc.target/arm/mve/mve.exp  |   6 +
 44 files changed, 627 insertions(+), 116 deletions(-)
 create mode 100644 gcc/config/arm/arm-mve-builtins.cc
 create mode 100644 gcc/config/arm/arm-mve-builtins.def
 create mode 100644 gcc/config/arm/arm-mve-builtins.h
 create mode 100644 gcc/testsuite/gcc.target/arm/mve/general-c/type_redef_1.c
 create mode 100644 gcc/testsuite/gcc.target/arm/mve/general-c/type_redef_10.c
 create mode 100644 gcc/testsuite/gcc.target/arm/mve/general-c/type_redef_11.c
 create mode 100644 gcc/testsuite/gcc.target/arm/mve/general-c/type_redef_12.c
 create mode 100644 gcc/testsuite/gcc.target/arm/mve/general-c/type_redef_13.c
 create mode 100644 gcc/testsuite/gcc.target/arm/mve/general-c/type_redef_14.c
 create mode 100644 gcc/testsuite/gcc.target/arm/mve/general-c/type_redef_15.c
 create mode 100644 gcc/testsuite/gcc.target/arm/mve/general-c/type_redef_16.c
 create mode 100644 gcc/testsuite/gcc.target/arm/mve/general-c/type_redef_17.c
 create mode 100644 gcc/testsuite/gcc.target/arm/mve/general-c/type_redef_18.c
 create mode 100644 gcc/testsuite/gcc.target/arm/mve/general-c/type_redef_19.c
 create mode 100644 gcc/testsuite/gcc.target/arm/mve/general-c/type_redef_2.c
 create mode 100644 gcc/testsuite/gcc.target/arm/mve/general-c/type_redef_20.c
 create mode 100644 gcc/testsuite/gcc.target/arm/mve/general-c/type_redef_21.c
 create mode 100644 gcc/testsuite/gcc.target/arm/mve/general-c/type_redef_22.c
 create mode 100644 gcc/testsuite/gcc.target/arm/mve/general-c/type_redef_23.c
 create mode 100644 gcc/testsuite/gcc.target/arm/mve/general-c/type_redef_24.c
 create mode 100644 gcc/testsuite/gcc.target/arm/mve/general-c/type_redef_25.c
 create mode 100644 gcc/testsuite/gcc.target/arm/mve/general-c/type_redef_26.c
 create mode 100644 gcc/testsuite/gcc.target/arm/mve/general-c/type_redef_27.c
 create mode 100644 gcc/testsuite/gcc.target/arm/mve/general-c/type_redef_28.c
 create mode 100644 gcc/testsuite/gcc.target/arm/mve/general-c/type_redef_29.c
 create mode 100644 gcc/testsuite/gcc.target/arm/mve/general-c/type_redef_3.c
 create mode 100644 gcc