public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] LoongArch: Use "$fcsr0" instead of "$r0" in _FPU_{GET,SET}CW
@ 2024-04-29  7:31 Xi Ruoyao
  2024-05-23  3:20 ` Ping: " Xi Ruoyao
  2024-05-23 13:09 ` Adhemerval Zanella Netto
  0 siblings, 2 replies; 4+ messages in thread
From: Xi Ruoyao @ 2024-04-29  7:31 UTC (permalink / raw)
  To: libc-alpha
  Cc: caiyinyu, Adhemerval Zanella, WANG Xuerui, luweining, Xi Ruoyao

Clang inline-asm parser does not allow using "$r0" in
movfcsr2gr/movgr2fcsr, so everything using _FPU_{GET,SET}CW is now
failing to build with Clang on LoongArch.  As we now requires Binutils
>= 2.41 which supports using "$fcsr0" here, use it instead of "$r0" to
fix the issue.

Link: https://github.com/loongson-community/discussions/issues/53#issuecomment-2081507390
Link: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=4142b2368353
Signed-off-by: Xi Ruoyao <xry111@xry111.site>
---

People in the Cc list will receive this twice because I've mistyped the
address of libc-alpha first time.  Sorry.  Stupid I :(.

 sysdeps/loongarch/fpu_control.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sysdeps/loongarch/fpu_control.h b/sysdeps/loongarch/fpu_control.h
index 54add4e01c..3cdf2417d9 100644
--- a/sysdeps/loongarch/fpu_control.h
+++ b/sysdeps/loongarch/fpu_control.h
@@ -91,8 +91,8 @@ typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__SI__)));
 /* Macros for accessing the hardware control word.  */
 extern fpu_control_t __loongarch_fpu_getcw (void) __THROW;
 extern void __loongarch_fpu_setcw (fpu_control_t) __THROW;
-#define _FPU_GETCW(cw) __asm__ volatile ("movfcsr2gr %0,$r0" : "=r"(cw))
-#define _FPU_SETCW(cw) __asm__ volatile ("movgr2fcsr $r0,%0" : : "r"(cw))
+#define _FPU_GETCW(cw) __asm__ volatile ("movfcsr2gr %0,$fcsr0" : "=r"(cw))
+#define _FPU_SETCW(cw) __asm__ volatile ("movgr2fcsr $fcsr0,%0" : : "r"(cw))
 
 /* Default control word set at startup.  */
 extern fpu_control_t __fpu_control;
-- 
2.44.0


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

* Ping: [PATCH] LoongArch: Use "$fcsr0" instead of "$r0" in _FPU_{GET,SET}CW
  2024-04-29  7:31 [PATCH] LoongArch: Use "$fcsr0" instead of "$r0" in _FPU_{GET,SET}CW Xi Ruoyao
@ 2024-05-23  3:20 ` Xi Ruoyao
  2024-05-23 13:09 ` Adhemerval Zanella Netto
  1 sibling, 0 replies; 4+ messages in thread
From: Xi Ruoyao @ 2024-05-23  3:20 UTC (permalink / raw)
  To: libc-alpha; +Cc: caiyinyu, Adhemerval Zanella, WANG Xuerui, luweining

Ping.

On Mon, 2024-04-29 at 15:31 +0800, Xi Ruoyao wrote:
> Clang inline-asm parser does not allow using "$r0" in
> movfcsr2gr/movgr2fcsr, so everything using _FPU_{GET,SET}CW is now
> failing to build with Clang on LoongArch.  As we now requires Binutils
> > = 2.41 which supports using "$fcsr0" here, use it instead of "$r0" to
> fix the issue.
> 
> Link: https://github.com/loongson-community/discussions/issues/53#issuecomment-2081507390
> Link: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=4142b2368353
> Signed-off-by: Xi Ruoyao <xry111@xry111.site>
> ---
> 
> People in the Cc list will receive this twice because I've mistyped the
> address of libc-alpha first time.  Sorry.  Stupid I :(.
> 
>  sysdeps/loongarch/fpu_control.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/sysdeps/loongarch/fpu_control.h b/sysdeps/loongarch/fpu_control.h
> index 54add4e01c..3cdf2417d9 100644
> --- a/sysdeps/loongarch/fpu_control.h
> +++ b/sysdeps/loongarch/fpu_control.h
> @@ -91,8 +91,8 @@ typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__SI__)));
>  /* Macros for accessing the hardware control word.  */
>  extern fpu_control_t __loongarch_fpu_getcw (void) __THROW;
>  extern void __loongarch_fpu_setcw (fpu_control_t) __THROW;
> -#define _FPU_GETCW(cw) __asm__ volatile ("movfcsr2gr %0,$r0" : "=r"(cw))
> -#define _FPU_SETCW(cw) __asm__ volatile ("movgr2fcsr $r0,%0" : : "r"(cw))
> +#define _FPU_GETCW(cw) __asm__ volatile ("movfcsr2gr %0,$fcsr0" : "=r"(cw))
> +#define _FPU_SETCW(cw) __asm__ volatile ("movgr2fcsr $fcsr0,%0" : : "r"(cw))
>  
>  /* Default control word set at startup.  */
>  extern fpu_control_t __fpu_control;

-- 
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University

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

* Re: [PATCH] LoongArch: Use "$fcsr0" instead of "$r0" in _FPU_{GET,SET}CW
  2024-04-29  7:31 [PATCH] LoongArch: Use "$fcsr0" instead of "$r0" in _FPU_{GET,SET}CW Xi Ruoyao
  2024-05-23  3:20 ` Ping: " Xi Ruoyao
@ 2024-05-23 13:09 ` Adhemerval Zanella Netto
  2024-05-26  6:15   ` caiyinyu
  1 sibling, 1 reply; 4+ messages in thread
From: Adhemerval Zanella Netto @ 2024-05-23 13:09 UTC (permalink / raw)
  To: Xi Ruoyao, libc-alpha; +Cc: caiyinyu, WANG Xuerui, luweining



On 29/04/24 04:31, Xi Ruoyao wrote:
> Clang inline-asm parser does not allow using "$r0" in
> movfcsr2gr/movgr2fcsr, so everything using _FPU_{GET,SET}CW is now
> failing to build with Clang on LoongArch.  As we now requires Binutils
>> = 2.41 which supports using "$fcsr0" here, use it instead of "$r0" to
> fix the issue.
> 
> Link: https://github.com/loongson-community/discussions/issues/53#issuecomment-2081507390
> Link: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=4142b2368353
> Signed-off-by: Xi Ruoyao <xry111@xry111.site>

LGTM, thanks.  It is safe to use with old gcc and binutils or the new 
constraint required a specific gcc version?

> ---
> 
> People in the Cc list will receive this twice because I've mistyped the
> address of libc-alpha first time.  Sorry.  Stupid I :(.
> 
>  sysdeps/loongarch/fpu_control.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/sysdeps/loongarch/fpu_control.h b/sysdeps/loongarch/fpu_control.h
> index 54add4e01c..3cdf2417d9 100644
> --- a/sysdeps/loongarch/fpu_control.h
> +++ b/sysdeps/loongarch/fpu_control.h
> @@ -91,8 +91,8 @@ typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__SI__)));
>  /* Macros for accessing the hardware control word.  */
>  extern fpu_control_t __loongarch_fpu_getcw (void) __THROW;
>  extern void __loongarch_fpu_setcw (fpu_control_t) __THROW;
> -#define _FPU_GETCW(cw) __asm__ volatile ("movfcsr2gr %0,$r0" : "=r"(cw))
> -#define _FPU_SETCW(cw) __asm__ volatile ("movgr2fcsr $r0,%0" : : "r"(cw))
> +#define _FPU_GETCW(cw) __asm__ volatile ("movfcsr2gr %0,$fcsr0" : "=r"(cw))
> +#define _FPU_SETCW(cw) __asm__ volatile ("movgr2fcsr $fcsr0,%0" : : "r"(cw))
>  
>  /* Default control word set at startup.  */
>  extern fpu_control_t __fpu_control;

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

* Re: [PATCH] LoongArch: Use "$fcsr0" instead of "$r0" in _FPU_{GET,SET}CW
  2024-05-23 13:09 ` Adhemerval Zanella Netto
@ 2024-05-26  6:15   ` caiyinyu
  0 siblings, 0 replies; 4+ messages in thread
From: caiyinyu @ 2024-05-26  6:15 UTC (permalink / raw)
  To: Adhemerval Zanella Netto, Xi Ruoyao, libc-alpha; +Cc: WANG Xuerui, luweining


在 2024/5/23 下午9:09, Adhemerval Zanella Netto 写道:
>
> On 29/04/24 04:31, Xi Ruoyao wrote:
>> Clang inline-asm parser does not allow using "$r0" in
>> movfcsr2gr/movgr2fcsr, so everything using _FPU_{GET,SET}CW is now
>> failing to build with Clang on LoongArch.  As we now requires Binutils
>>> = 2.41 which supports using "$fcsr0" here, use it instead of "$r0" to
>> fix the issue.
>>
>> Link: https://github.com/loongson-community/discussions/issues/53#issuecomment-2081507390
>> Link: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=4142b2368353
>> Signed-off-by: Xi Ruoyao <xry111@xry111.site>
> LGTM, thanks.  It is safe to use with old gcc and binutils or the new
> constraint required a specific gcc version?
1.  Starting from LoongArch glibc-2.39, the minimum required version of 
binutils
is 2.41(because of the LASX/LSX vector instructions), and binutils 
support for
this modification also begins with version 2.41

2.  All LoongArch gcc support this change.

The header files modified this time are export header files, but I think 
this
change is ok.  In conclusion, I plan to merge this commit.
>> ---
>>
>> People in the Cc list will receive this twice because I've mistyped the
>> address of libc-alpha first time.  Sorry.  Stupid I :(.
>>
>>   sysdeps/loongarch/fpu_control.h | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/sysdeps/loongarch/fpu_control.h b/sysdeps/loongarch/fpu_control.h
>> index 54add4e01c..3cdf2417d9 100644
>> --- a/sysdeps/loongarch/fpu_control.h
>> +++ b/sysdeps/loongarch/fpu_control.h
>> @@ -91,8 +91,8 @@ typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__SI__)));
>>   /* Macros for accessing the hardware control word.  */
>>   extern fpu_control_t __loongarch_fpu_getcw (void) __THROW;
>>   extern void __loongarch_fpu_setcw (fpu_control_t) __THROW;
>> -#define _FPU_GETCW(cw) __asm__ volatile ("movfcsr2gr %0,$r0" : "=r"(cw))
>> -#define _FPU_SETCW(cw) __asm__ volatile ("movgr2fcsr $r0,%0" : : "r"(cw))
>> +#define _FPU_GETCW(cw) __asm__ volatile ("movfcsr2gr %0,$fcsr0" : "=r"(cw))
>> +#define _FPU_SETCW(cw) __asm__ volatile ("movgr2fcsr $fcsr0,%0" : : "r"(cw))
>>   
>>   /* Default control word set at startup.  */
>>   extern fpu_control_t __fpu_control;


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

end of thread, other threads:[~2024-05-26  6:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-29  7:31 [PATCH] LoongArch: Use "$fcsr0" instead of "$r0" in _FPU_{GET,SET}CW Xi Ruoyao
2024-05-23  3:20 ` Ping: " Xi Ruoyao
2024-05-23 13:09 ` Adhemerval Zanella Netto
2024-05-26  6:15   ` caiyinyu

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