public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] aarch64, acle header: Cast uint64_t pointers to DIMode.
@ 2024-02-05 14:56 Iain Sandoe
  2024-02-05 21:04 ` Iain Sandoe
  0 siblings, 1 reply; 5+ messages in thread
From: Iain Sandoe @ 2024-02-05 14:56 UTC (permalink / raw)
  To: gcc-patches

Tested on aarch64-linux,darwin and a cross from aarch64-darwin to linux,
OK for trunk, or some alternative is needed?
thanks
Iain

--- 8< ---

Currently, most of the acle tests fail on the Darwin port because
DI mode is "long" and uint64 is "long long".  The fix for this used
in other headers is to cast the pointers using __builtin_aarch64_simd_di
and that is what this patch does.

gcc/ChangeLog:

	* config/aarch64/arm_acle.h (__rndr): Cast uint64 pointer to DI
	mode to avoid typedef mismatches.
	(__rndrrs): Likewise.
---
 gcc/config/aarch64/arm_acle.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/config/aarch64/arm_acle.h b/gcc/config/aarch64/arm_acle.h
index 2aa681090fa..823f87187b1 100644
--- a/gcc/config/aarch64/arm_acle.h
+++ b/gcc/config/aarch64/arm_acle.h
@@ -309,14 +309,14 @@ __extension__ extern __inline int
 __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
 __rndr (uint64_t *__res)
 {
-  return __builtin_aarch64_rndr (__res);
+  return __builtin_aarch64_rndr ((__builtin_aarch64_simd_di *) __res);
 }
 
 __extension__ extern __inline int
 __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
 __rndrrs (uint64_t *__res)
 {
-  return __builtin_aarch64_rndrrs (__res);
+  return __builtin_aarch64_rndrrs ((__builtin_aarch64_simd_di *) __res);
 }
 
 #pragma GCC pop_options
-- 
2.39.2 (Apple Git-143)


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] aarch64, acle header: Cast uint64_t pointers to DIMode.
  2024-02-05 14:56 [PATCH] aarch64, acle header: Cast uint64_t pointers to DIMode Iain Sandoe
@ 2024-02-05 21:04 ` Iain Sandoe
  2024-02-15 18:05   ` Richard Sandiford
  0 siblings, 1 reply; 5+ messages in thread
From: Iain Sandoe @ 2024-02-05 21:04 UTC (permalink / raw)
  To: GCC Patches



> On 5 Feb 2024, at 14:56, Iain Sandoe <iains.gcc@gmail.com> wrote:
> 
> Tested on aarch64-linux,darwin and a cross from aarch64-darwin to linux,
> OK for trunk, or some alternative is needed?

Hmm.. apparently, this fails the linaro pre-commit CI for g++ with:
error: invalid conversion from 'long int*' to 'long unsigned int*' [-fpermissive]

So, I guess some alternative is needed, advice welcome,
Iain

> thanks
> Iain
> 
> --- 8< ---
> 
> Currently, most of the acle tests fail on the Darwin port because
> DI mode is "long" and uint64 is "long long".  The fix for this used
> in other headers is to cast the pointers using __builtin_aarch64_simd_di
> and that is what this patch does.
> 
> gcc/ChangeLog:
> 
> 	* config/aarch64/arm_acle.h (__rndr): Cast uint64 pointer to DI
> 	mode to avoid typedef mismatches.
> 	(__rndrrs): Likewise.
> ---
> gcc/config/aarch64/arm_acle.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/gcc/config/aarch64/arm_acle.h b/gcc/config/aarch64/arm_acle.h
> index 2aa681090fa..823f87187b1 100644
> --- a/gcc/config/aarch64/arm_acle.h
> +++ b/gcc/config/aarch64/arm_acle.h
> @@ -309,14 +309,14 @@ __extension__ extern __inline int
> __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
> __rndr (uint64_t *__res)
> {
> -  return __builtin_aarch64_rndr (__res);
> +  return __builtin_aarch64_rndr ((__builtin_aarch64_simd_di *) __res);
> }
> 
> __extension__ extern __inline int
> __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
> __rndrrs (uint64_t *__res)
> {
> -  return __builtin_aarch64_rndrrs (__res);
> +  return __builtin_aarch64_rndrrs ((__builtin_aarch64_simd_di *) __res);
> }
> 
> #pragma GCC pop_options
> -- 
> 2.39.2 (Apple Git-143)
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] aarch64, acle header: Cast uint64_t pointers to DIMode.
  2024-02-05 21:04 ` Iain Sandoe
@ 2024-02-15 18:05   ` Richard Sandiford
  2024-02-16 13:40     ` Iain Sandoe
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Sandiford @ 2024-02-15 18:05 UTC (permalink / raw)
  To: Iain Sandoe; +Cc: GCC Patches

Iain Sandoe <iains.gcc@gmail.com> writes:
>> On 5 Feb 2024, at 14:56, Iain Sandoe <iains.gcc@gmail.com> wrote:
>> 
>> Tested on aarch64-linux,darwin and a cross from aarch64-darwin to linux,
>> OK for trunk, or some alternative is needed?
>
> Hmm.. apparently, this fails the linaro pre-commit CI for g++ with:
> error: invalid conversion from 'long int*' to 'long unsigned int*' [-fpermissive]
>
> So, I guess some alternative is needed, advice welcome,

The builtins are registered with:

static void
aarch64_init_rng_builtins (void)
{
  tree unsigned_ptr_type = build_pointer_type (unsigned_intDI_type_node);
  ...

Does it work if you change unsigned_intDI_type_node to
get_typenode_from_name (UINT64_TYPE)?

Thanks,
Richard

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] aarch64, acle header: Cast uint64_t pointers to DIMode.
  2024-02-15 18:05   ` Richard Sandiford
@ 2024-02-16 13:40     ` Iain Sandoe
  2024-02-19  9:48       ` Richard Sandiford
  0 siblings, 1 reply; 5+ messages in thread
From: Iain Sandoe @ 2024-02-16 13:40 UTC (permalink / raw)
  To: Richard Sandiford; +Cc: GCC Patches



> On 15 Feb 2024, at 18:05, Richard Sandiford <richard.sandiford@arm.com> wrote:
> 
> Iain Sandoe <iains.gcc@gmail.com> writes:
>>> On 5 Feb 2024, at 14:56, Iain Sandoe <iains.gcc@gmail.com> wrote:
>>> 
>>> Tested on aarch64-linux,darwin and a cross from aarch64-darwin to linux,
>>> OK for trunk, or some alternative is needed?
>> 
>> Hmm.. apparently, this fails the linaro pre-commit CI for g++ with:
>> error: invalid conversion from 'long int*' to 'long unsigned int*' [-fpermissive]
>> 
>> So, I guess some alternative is needed, advice welcome,
> 
> The builtins are registered with:
> 
> static void
> aarch64_init_rng_builtins (void)
> {
>  tree unsigned_ptr_type = build_pointer_type (unsigned_intDI_type_node);
>  ...
> 
> Does it work if you change unsigned_intDI_type_node to
> get_typenode_from_name (UINT64_TYPE)?

Yes, that works fine; tested on aarch64-linux and aarch64-darwin.

revised, as below,
OK for trunk?
Iain


Subject: [PATCH] aarch64: Register rng builtins with uint64_t pointers.

Currently, these are registered as unsigned_intDI_type_node which is not
necessarily the same type definition as uint64_t.  On platforms where these
differ that causes fails in consuming the arm_acle.h header.

gcc/ChangeLog:

	* config/aarch64/aarch64-builtins.cc (aarch64_init_rng_builtins):
	Register these builtins with a pointer to uint64_t rather than unsigned
	DI mode.
---
 gcc/config/aarch64/aarch64-builtins.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/config/aarch64/aarch64-builtins.cc b/gcc/config/aarch64/aarch64-builtins.cc
index e211a7271ba..1330558f109 100644
--- a/gcc/config/aarch64/aarch64-builtins.cc
+++ b/gcc/config/aarch64/aarch64-builtins.cc
@@ -1759,7 +1759,8 @@ aarch64_init_tme_builtins (void)
 static void
 aarch64_init_rng_builtins (void)
 {
-  tree unsigned_ptr_type = build_pointer_type (unsigned_intDI_type_node);
+  tree unsigned_ptr_type
+    = build_pointer_type (get_typenode_from_name (UINT64_TYPE));
   tree ftype
     = build_function_type_list (integer_type_node, unsigned_ptr_type, NULL);
   aarch64_builtin_decls[AARCH64_BUILTIN_RNG_RNDR]
-- 
2.39.2 (Apple Git-143)



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] aarch64, acle header: Cast uint64_t pointers to DIMode.
  2024-02-16 13:40     ` Iain Sandoe
@ 2024-02-19  9:48       ` Richard Sandiford
  0 siblings, 0 replies; 5+ messages in thread
From: Richard Sandiford @ 2024-02-19  9:48 UTC (permalink / raw)
  To: Iain Sandoe; +Cc: GCC Patches

Iain Sandoe <iain@sandoe.co.uk> writes:
>> On 15 Feb 2024, at 18:05, Richard Sandiford <richard.sandiford@arm.com> wrote:
>> 
>> Iain Sandoe <iains.gcc@gmail.com> writes:
>>>> On 5 Feb 2024, at 14:56, Iain Sandoe <iains.gcc@gmail.com> wrote:
>>>> 
>>>> Tested on aarch64-linux,darwin and a cross from aarch64-darwin to linux,
>>>> OK for trunk, or some alternative is needed?
>>> 
>>> Hmm.. apparently, this fails the linaro pre-commit CI for g++ with:
>>> error: invalid conversion from 'long int*' to 'long unsigned int*' [-fpermissive]
>>> 
>>> So, I guess some alternative is needed, advice welcome,
>> 
>> The builtins are registered with:
>> 
>> static void
>> aarch64_init_rng_builtins (void)
>> {
>>  tree unsigned_ptr_type = build_pointer_type (unsigned_intDI_type_node);
>>  ...
>> 
>> Does it work if you change unsigned_intDI_type_node to
>> get_typenode_from_name (UINT64_TYPE)?
>
> Yes, that works fine; tested on aarch64-linux and aarch64-darwin.
>
> revised, as below,
> OK for trunk?
> Iain
>
>
> Subject: [PATCH] aarch64: Register rng builtins with uint64_t pointers.
>
> Currently, these are registered as unsigned_intDI_type_node which is not
> necessarily the same type definition as uint64_t.  On platforms where these
> differ that causes fails in consuming the arm_acle.h header.
>
> gcc/ChangeLog:
>
> 	* config/aarch64/aarch64-builtins.cc (aarch64_init_rng_builtins):
> 	Register these builtins with a pointer to uint64_t rather than unsigned
> 	DI mode.

OK, thanks.

Richard

> ---
>  gcc/config/aarch64/aarch64-builtins.cc | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/gcc/config/aarch64/aarch64-builtins.cc b/gcc/config/aarch64/aarch64-builtins.cc
> index e211a7271ba..1330558f109 100644
> --- a/gcc/config/aarch64/aarch64-builtins.cc
> +++ b/gcc/config/aarch64/aarch64-builtins.cc
> @@ -1759,7 +1759,8 @@ aarch64_init_tme_builtins (void)
>  static void
>  aarch64_init_rng_builtins (void)
>  {
> -  tree unsigned_ptr_type = build_pointer_type (unsigned_intDI_type_node);
> +  tree unsigned_ptr_type
> +    = build_pointer_type (get_typenode_from_name (UINT64_TYPE));
>    tree ftype
>      = build_function_type_list (integer_type_node, unsigned_ptr_type, NULL);
>    aarch64_builtin_decls[AARCH64_BUILTIN_RNG_RNDR]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-02-19  9:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-05 14:56 [PATCH] aarch64, acle header: Cast uint64_t pointers to DIMode Iain Sandoe
2024-02-05 21:04 ` Iain Sandoe
2024-02-15 18:05   ` Richard Sandiford
2024-02-16 13:40     ` Iain Sandoe
2024-02-19  9:48       ` Richard Sandiford

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).