public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] powerpc/setjmp: Fix 64-bit buffer alignment
@ 2022-11-07 15:48 Sebastian Huber
  2022-11-07 16:33 ` Corinna Vinschen
  0 siblings, 1 reply; 3+ messages in thread
From: Sebastian Huber @ 2022-11-07 15:48 UTC (permalink / raw)
  To: newlib

The rlwinm is a word-size instruction which clears the remaining 32 bits of a
64-bit register.  Use clrrdi in 64-bit configurations.
---
 newlib/libc/machine/powerpc/setjmp.S | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/newlib/libc/machine/powerpc/setjmp.S b/newlib/libc/machine/powerpc/setjmp.S
index 3a6fa4a58..c7af5b105 100644
--- a/newlib/libc/machine/powerpc/setjmp.S
+++ b/newlib/libc/machine/powerpc/setjmp.S
@@ -8,11 +8,19 @@
 FUNC_START(setjmp)
 #ifdef __ALTIVEC__
 	addi	3,3,15		# align Altivec to 16 byte boundary
+#if __powerpc64__
+	clrrdi	3,3,4
+#else
 	rlwinm	3,3,0,0,27
+#endif
 #else
 	addi	3,3,7		# align to 8 byte boundary
+#if __powerpc64__
+	clrrdi	3,3,3
+#else
 	rlwinm	3,3,0,0,28
 #endif
+#endif
 #if __SPE__
 	/* If we are E500, then save 64-bit registers.  */
 	evstdd	1,0(3)		# offset 0
@@ -193,11 +201,19 @@ FUNC_END(setjmp)
 FUNC_START(longjmp)
 #ifdef __ALTIVEC__
 	addi	3,3,15		# align Altivec to 16 byte boundary
+#if __powerpc64__
+	clrrdi	3,3,4
+#else
 	rlwinm	3,3,0,0,27
+#endif
 #else
 	addi	3,3,7		# align to 8 byte boundary
+#if __powerpc64__
+	clrrdi	3,3,3
+#else
 	rlwinm	3,3,0,0,28
 #endif
+#endif
 #if __SPE__
 	/* If we are E500, then restore 64-bit registers.  */
 	evldd	1,0(3)		# offset 0
-- 
2.35.3


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

* Re: [PATCH] powerpc/setjmp: Fix 64-bit buffer alignment
  2022-11-07 15:48 [PATCH] powerpc/setjmp: Fix 64-bit buffer alignment Sebastian Huber
@ 2022-11-07 16:33 ` Corinna Vinschen
  2022-11-10 15:19   ` Sebastian Huber
  0 siblings, 1 reply; 3+ messages in thread
From: Corinna Vinschen @ 2022-11-07 16:33 UTC (permalink / raw)
  To: newlib

On Nov  7 16:48, Sebastian Huber wrote:
> The rlwinm is a word-size instruction which clears the remaining 32 bits of a
> 64-bit register.  Use clrrdi in 64-bit configurations.

I'm getting a bit cross-eyed when looling at PowerPC assembler.
I'm sure you tested it, so feel free to push.


Thanks,
Corinna


> ---
>  newlib/libc/machine/powerpc/setjmp.S | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/newlib/libc/machine/powerpc/setjmp.S b/newlib/libc/machine/powerpc/setjmp.S
> index 3a6fa4a58..c7af5b105 100644
> --- a/newlib/libc/machine/powerpc/setjmp.S
> +++ b/newlib/libc/machine/powerpc/setjmp.S
> @@ -8,11 +8,19 @@
>  FUNC_START(setjmp)
>  #ifdef __ALTIVEC__
>  	addi	3,3,15		# align Altivec to 16 byte boundary
> +#if __powerpc64__
> +	clrrdi	3,3,4
> +#else
>  	rlwinm	3,3,0,0,27
> +#endif
>  #else
>  	addi	3,3,7		# align to 8 byte boundary
> +#if __powerpc64__
> +	clrrdi	3,3,3
> +#else
>  	rlwinm	3,3,0,0,28
>  #endif
> +#endif
>  #if __SPE__
>  	/* If we are E500, then save 64-bit registers.  */
>  	evstdd	1,0(3)		# offset 0
> @@ -193,11 +201,19 @@ FUNC_END(setjmp)
>  FUNC_START(longjmp)
>  #ifdef __ALTIVEC__
>  	addi	3,3,15		# align Altivec to 16 byte boundary
> +#if __powerpc64__
> +	clrrdi	3,3,4
> +#else
>  	rlwinm	3,3,0,0,27
> +#endif
>  #else
>  	addi	3,3,7		# align to 8 byte boundary
> +#if __powerpc64__
> +	clrrdi	3,3,3
> +#else
>  	rlwinm	3,3,0,0,28
>  #endif
> +#endif
>  #if __SPE__
>  	/* If we are E500, then restore 64-bit registers.  */
>  	evldd	1,0(3)		# offset 0
> -- 
> 2.35.3


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

* Re: [PATCH] powerpc/setjmp: Fix 64-bit buffer alignment
  2022-11-07 16:33 ` Corinna Vinschen
@ 2022-11-10 15:19   ` Sebastian Huber
  0 siblings, 0 replies; 3+ messages in thread
From: Sebastian Huber @ 2022-11-10 15:19 UTC (permalink / raw)
  To: newlib

On 07/11/2022 17:33, Corinna Vinschen wrote:
> On Nov  7 16:48, Sebastian Huber wrote:
>> The rlwinm is a word-size instruction which clears the remaining 32 bits of a
>> 64-bit register.  Use clrrdi in 64-bit configurations.
> I'm getting a bit cross-eyed when looling at PowerPC assembler.
> I'm sure you tested it, so feel free to push.

Yes, I did test the individual patches, however, I should have tested 
the overall function better. I hope that the 64-bit support is now complete.

-- 
embedded brains GmbH
Herr Sebastian HUBER
Dornierstr. 4
82178 Puchheim
Germany
email: sebastian.huber@embedded-brains.de
phone: +49-89-18 94 741 - 16
fax:   +49-89-18 94 741 - 08

Registergericht: Amtsgericht München
Registernummer: HRB 157899
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
Unsere Datenschutzerklärung finden Sie hier:
https://embedded-brains.de/datenschutzerklaerung/

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

end of thread, other threads:[~2022-11-10 15:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-07 15:48 [PATCH] powerpc/setjmp: Fix 64-bit buffer alignment Sebastian Huber
2022-11-07 16:33 ` Corinna Vinschen
2022-11-10 15:19   ` Sebastian Huber

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).