public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/azanella/clang] i386: sfp-machine.h: Do no use asm input cast for clang
@ 2023-09-28 17:52 Adhemerval Zanella
  0 siblings, 0 replies; 7+ messages in thread
From: Adhemerval Zanella @ 2023-09-28 17:52 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=77ec140129554dc3335c763413d4870dcf2d6f65

commit 77ec140129554dc3335c763413d4870dcf2d6f65
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Tue Jul 26 08:45:41 2022 -0300

    i386: sfp-machine.h: Do no use asm input cast for clang
    
    clang by default rejects the input casts with:
    
      error: invalid use of a cast in a inline asm context requiring an
      lvalue: remove the cast or build with -fheinous-gnu-extensions
    
    And even with -fheinous-gnu-extensions clang still throws an warning
    and also states that this option might be removed in the future.
    For gcc the cast are still useful [1] as type-checking.
    
    [1] https://gcc.gnu.org/pipermail/gcc-patches/2021-October/581722.html

Diff:
---
 sysdeps/x86/fpu/sfp-machine.h | 44 +++++++++++++++++++++++++------------------
 1 file changed, 26 insertions(+), 18 deletions(-)

diff --git a/sysdeps/x86/fpu/sfp-machine.h b/sysdeps/x86/fpu/sfp-machine.h
index 89a73642b1..dd23c797bd 100644
--- a/sysdeps/x86/fpu/sfp-machine.h
+++ b/sysdeps/x86/fpu/sfp-machine.h
@@ -64,15 +64,23 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
 # define _FP_WS_TYPE		signed int
 # define _FP_I_TYPE		int
 
+/* clang does not support output constraint as lvalue, while gcc uses it as a
+   simple type check.  */
+# ifdef __clang__
+#  define __asm_output_check_type(__type, __arg) (__arg)
+# else
+#  define __asm_output_check_type(__type, __arg) ((__type)(__arg))
+# endif
+
 # define __FP_FRAC_ADD_4(r3,r2,r1,r0,x3,x2,x1,x0,y3,y2,y1,y0)	\
   __asm__ ("add{l} {%11,%3|%3,%11}\n\t"				\
 	   "adc{l} {%9,%2|%2,%9}\n\t"				\
 	   "adc{l} {%7,%1|%1,%7}\n\t"				\
 	   "adc{l} {%5,%0|%0,%5}"				\
-	   : "=r" ((USItype) (r3)),				\
-	     "=&r" ((USItype) (r2)),				\
-	     "=&r" ((USItype) (r1)),				\
-	     "=&r" ((USItype) (r0))				\
+	   : "=r" __asm_output_check_type (USItype, r3),	\
+	     "=&r" __asm_output_check_type (USItype, r2),	\
+	     "=&r" __asm_output_check_type (USItype, r1),	\
+	     "=&r" __asm_output_check_type (USItype, r0)	\
 	   : "%0" ((USItype) (x3)),				\
 	     "g" ((USItype) (y3)),				\
 	     "%1" ((USItype) (x2)),				\
@@ -85,9 +93,9 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
   __asm__ ("add{l} {%8,%2|%2,%8}\n\t"				\
 	   "adc{l} {%6,%1|%1,%6}\n\t"				\
 	   "adc{l} {%4,%0|%0,%4}"				\
-	   : "=r" ((USItype) (r2)),				\
-	     "=&r" ((USItype) (r1)),				\
-	     "=&r" ((USItype) (r0))				\
+	   : "=r" __asm_output_check_type (USItype, r2),	\
+	     "=&r" __asm_output_check_type (USItype, r1),	\
+	     "=&r" __asm_output_check_type (USItype, r0)	\
 	   : "%0" ((USItype) (x2)),				\
 	     "g" ((USItype) (y2)),				\
 	     "%1" ((USItype) (x1)),				\
@@ -99,10 +107,10 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
 	   "sbb{l} {%9,%2|%2,%9}\n\t"				\
 	   "sbb{l} {%7,%1|%1,%7}\n\t"				\
 	   "sbb{l} {%5,%0|%0,%5}"				\
-	   : "=r" ((USItype) (r3)),				\
-	     "=&r" ((USItype) (r2)),				\
-	     "=&r" ((USItype) (r1)),				\
-	     "=&r" ((USItype) (r0))				\
+	   : "=r" __asm_output_check_type (USItype, r3),	\
+	     "=&r" __asm_output_check_type (USItype, r2),	\
+	     "=&r" __asm_output_check_type (USItype, r1),	\
+	     "=&r" __asm_output_check_type (USItype, r0)	\
 	   : "0" ((USItype) (x3)),				\
 	     "g" ((USItype) (y3)),				\
 	     "1" ((USItype) (x2)),				\
@@ -115,9 +123,9 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
   __asm__ ("sub{l} {%8,%2|%2,%8}\n\t"				\
 	   "sbb{l} {%6,%1|%1,%6}\n\t"				\
 	   "sbb{l} {%4,%0|%0,%4}"				\
-	   : "=r" ((USItype) (r2)),				\
-	     "=&r" ((USItype) (r1)),				\
-	     "=&r" ((USItype) (r0))				\
+	   : "=r" __asm_output_check_type (USItype, r2),	\
+	     "=&r" __asm_output_check_type (USItype, r1),	\
+	     "=&r" __asm_output_check_type (USItype, r0)	\
 	   : "0" ((USItype) (x2)),				\
 	     "g" ((USItype) (y2)),				\
 	     "1" ((USItype) (x1)),				\
@@ -129,10 +137,10 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
 	   "adc{l} {$0,%2|%2,0}\n\t"				\
 	   "adc{l} {$0,%1|%1,0}\n\t"				\
 	   "adc{l} {$0,%0|%0,0}"				\
-	   : "+r" ((USItype) (x3)),				\
-	     "+&r" ((USItype) (x2)),				\
-	     "+&r" ((USItype) (x1)),				\
-	     "+&r" ((USItype) (x0))				\
+	   : "+r" __asm_output_check_type (USItype, x3),	\
+	     "+&r" __asm_output_check_type (USItype, x2),	\
+	     "+&r" __asm_output_check_type (USItype, x1),	\
+	     "+&r" __asm_output_check_type (USItype, x0)	\
 	   : "g" ((USItype) (i)))

^ permalink raw reply	[flat|nested] 7+ messages in thread
* [glibc/azanella/clang] i386: sfp-machine.h: Do no use asm input cast for clang
@ 2023-12-21 18:54 Adhemerval Zanella
  0 siblings, 0 replies; 7+ messages in thread
From: Adhemerval Zanella @ 2023-12-21 18:54 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=f2d30112b1fbbec1bc3743aace27c27e530ee3e7

commit f2d30112b1fbbec1bc3743aace27c27e530ee3e7
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Tue Jul 26 08:45:41 2022 -0300

    i386: sfp-machine.h: Do no use asm input cast for clang
    
    clang by default rejects the input casts with:
    
      error: invalid use of a cast in a inline asm context requiring an
      lvalue: remove the cast or build with -fheinous-gnu-extensions
    
    And even with -fheinous-gnu-extensions clang still throws an warning
    and also states that this option might be removed in the future.
    For gcc the cast are still useful [1] as type-checking.
    
    [1] https://gcc.gnu.org/pipermail/gcc-patches/2021-October/581722.html

Diff:
---
 sysdeps/x86/fpu/sfp-machine.h | 44 +++++++++++++++++++++++++------------------
 1 file changed, 26 insertions(+), 18 deletions(-)

diff --git a/sysdeps/x86/fpu/sfp-machine.h b/sysdeps/x86/fpu/sfp-machine.h
index 89a73642b1..dd23c797bd 100644
--- a/sysdeps/x86/fpu/sfp-machine.h
+++ b/sysdeps/x86/fpu/sfp-machine.h
@@ -64,15 +64,23 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
 # define _FP_WS_TYPE		signed int
 # define _FP_I_TYPE		int
 
+/* clang does not support output constraint as lvalue, while gcc uses it as a
+   simple type check.  */
+# ifdef __clang__
+#  define __asm_output_check_type(__type, __arg) (__arg)
+# else
+#  define __asm_output_check_type(__type, __arg) ((__type)(__arg))
+# endif
+
 # define __FP_FRAC_ADD_4(r3,r2,r1,r0,x3,x2,x1,x0,y3,y2,y1,y0)	\
   __asm__ ("add{l} {%11,%3|%3,%11}\n\t"				\
 	   "adc{l} {%9,%2|%2,%9}\n\t"				\
 	   "adc{l} {%7,%1|%1,%7}\n\t"				\
 	   "adc{l} {%5,%0|%0,%5}"				\
-	   : "=r" ((USItype) (r3)),				\
-	     "=&r" ((USItype) (r2)),				\
-	     "=&r" ((USItype) (r1)),				\
-	     "=&r" ((USItype) (r0))				\
+	   : "=r" __asm_output_check_type (USItype, r3),	\
+	     "=&r" __asm_output_check_type (USItype, r2),	\
+	     "=&r" __asm_output_check_type (USItype, r1),	\
+	     "=&r" __asm_output_check_type (USItype, r0)	\
 	   : "%0" ((USItype) (x3)),				\
 	     "g" ((USItype) (y3)),				\
 	     "%1" ((USItype) (x2)),				\
@@ -85,9 +93,9 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
   __asm__ ("add{l} {%8,%2|%2,%8}\n\t"				\
 	   "adc{l} {%6,%1|%1,%6}\n\t"				\
 	   "adc{l} {%4,%0|%0,%4}"				\
-	   : "=r" ((USItype) (r2)),				\
-	     "=&r" ((USItype) (r1)),				\
-	     "=&r" ((USItype) (r0))				\
+	   : "=r" __asm_output_check_type (USItype, r2),	\
+	     "=&r" __asm_output_check_type (USItype, r1),	\
+	     "=&r" __asm_output_check_type (USItype, r0)	\
 	   : "%0" ((USItype) (x2)),				\
 	     "g" ((USItype) (y2)),				\
 	     "%1" ((USItype) (x1)),				\
@@ -99,10 +107,10 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
 	   "sbb{l} {%9,%2|%2,%9}\n\t"				\
 	   "sbb{l} {%7,%1|%1,%7}\n\t"				\
 	   "sbb{l} {%5,%0|%0,%5}"				\
-	   : "=r" ((USItype) (r3)),				\
-	     "=&r" ((USItype) (r2)),				\
-	     "=&r" ((USItype) (r1)),				\
-	     "=&r" ((USItype) (r0))				\
+	   : "=r" __asm_output_check_type (USItype, r3),	\
+	     "=&r" __asm_output_check_type (USItype, r2),	\
+	     "=&r" __asm_output_check_type (USItype, r1),	\
+	     "=&r" __asm_output_check_type (USItype, r0)	\
 	   : "0" ((USItype) (x3)),				\
 	     "g" ((USItype) (y3)),				\
 	     "1" ((USItype) (x2)),				\
@@ -115,9 +123,9 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
   __asm__ ("sub{l} {%8,%2|%2,%8}\n\t"				\
 	   "sbb{l} {%6,%1|%1,%6}\n\t"				\
 	   "sbb{l} {%4,%0|%0,%4}"				\
-	   : "=r" ((USItype) (r2)),				\
-	     "=&r" ((USItype) (r1)),				\
-	     "=&r" ((USItype) (r0))				\
+	   : "=r" __asm_output_check_type (USItype, r2),	\
+	     "=&r" __asm_output_check_type (USItype, r1),	\
+	     "=&r" __asm_output_check_type (USItype, r0)	\
 	   : "0" ((USItype) (x2)),				\
 	     "g" ((USItype) (y2)),				\
 	     "1" ((USItype) (x1)),				\
@@ -129,10 +137,10 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
 	   "adc{l} {$0,%2|%2,0}\n\t"				\
 	   "adc{l} {$0,%1|%1,0}\n\t"				\
 	   "adc{l} {$0,%0|%0,0}"				\
-	   : "+r" ((USItype) (x3)),				\
-	     "+&r" ((USItype) (x2)),				\
-	     "+&r" ((USItype) (x1)),				\
-	     "+&r" ((USItype) (x0))				\
+	   : "+r" __asm_output_check_type (USItype, x3),	\
+	     "+&r" __asm_output_check_type (USItype, x2),	\
+	     "+&r" __asm_output_check_type (USItype, x1),	\
+	     "+&r" __asm_output_check_type (USItype, x0)	\
 	   : "g" ((USItype) (i)))

^ permalink raw reply	[flat|nested] 7+ messages in thread
* [glibc/azanella/clang] i386: sfp-machine.h: Do no use asm input cast for clang
@ 2024-01-29 17:57 Adhemerval Zanella
  0 siblings, 0 replies; 7+ messages in thread
From: Adhemerval Zanella @ 2024-01-29 17:57 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=843debe08c70602454cc589e52fea70cc5873a7d

commit 843debe08c70602454cc589e52fea70cc5873a7d
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Tue Jul 26 08:45:41 2022 -0300

    i386: sfp-machine.h: Do no use asm input cast for clang
    
    clang by default rejects the input casts with:
    
      error: invalid use of a cast in a inline asm context requiring an
      lvalue: remove the cast or build with -fheinous-gnu-extensions
    
    And even with -fheinous-gnu-extensions clang still throws an warning
    and also states that this option might be removed in the future.
    For gcc the cast are still useful [1] as type-checking.
    
    [1] https://gcc.gnu.org/pipermail/gcc-patches/2021-October/581722.html

Diff:
---
 sysdeps/x86/fpu/sfp-machine.h | 44 +++++++++++++++++++++++++------------------
 1 file changed, 26 insertions(+), 18 deletions(-)

diff --git a/sysdeps/x86/fpu/sfp-machine.h b/sysdeps/x86/fpu/sfp-machine.h
index 89a73642b1..dd23c797bd 100644
--- a/sysdeps/x86/fpu/sfp-machine.h
+++ b/sysdeps/x86/fpu/sfp-machine.h
@@ -64,15 +64,23 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
 # define _FP_WS_TYPE		signed int
 # define _FP_I_TYPE		int
 
+/* clang does not support output constraint as lvalue, while gcc uses it as a
+   simple type check.  */
+# ifdef __clang__
+#  define __asm_output_check_type(__type, __arg) (__arg)
+# else
+#  define __asm_output_check_type(__type, __arg) ((__type)(__arg))
+# endif
+
 # define __FP_FRAC_ADD_4(r3,r2,r1,r0,x3,x2,x1,x0,y3,y2,y1,y0)	\
   __asm__ ("add{l} {%11,%3|%3,%11}\n\t"				\
 	   "adc{l} {%9,%2|%2,%9}\n\t"				\
 	   "adc{l} {%7,%1|%1,%7}\n\t"				\
 	   "adc{l} {%5,%0|%0,%5}"				\
-	   : "=r" ((USItype) (r3)),				\
-	     "=&r" ((USItype) (r2)),				\
-	     "=&r" ((USItype) (r1)),				\
-	     "=&r" ((USItype) (r0))				\
+	   : "=r" __asm_output_check_type (USItype, r3),	\
+	     "=&r" __asm_output_check_type (USItype, r2),	\
+	     "=&r" __asm_output_check_type (USItype, r1),	\
+	     "=&r" __asm_output_check_type (USItype, r0)	\
 	   : "%0" ((USItype) (x3)),				\
 	     "g" ((USItype) (y3)),				\
 	     "%1" ((USItype) (x2)),				\
@@ -85,9 +93,9 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
   __asm__ ("add{l} {%8,%2|%2,%8}\n\t"				\
 	   "adc{l} {%6,%1|%1,%6}\n\t"				\
 	   "adc{l} {%4,%0|%0,%4}"				\
-	   : "=r" ((USItype) (r2)),				\
-	     "=&r" ((USItype) (r1)),				\
-	     "=&r" ((USItype) (r0))				\
+	   : "=r" __asm_output_check_type (USItype, r2),	\
+	     "=&r" __asm_output_check_type (USItype, r1),	\
+	     "=&r" __asm_output_check_type (USItype, r0)	\
 	   : "%0" ((USItype) (x2)),				\
 	     "g" ((USItype) (y2)),				\
 	     "%1" ((USItype) (x1)),				\
@@ -99,10 +107,10 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
 	   "sbb{l} {%9,%2|%2,%9}\n\t"				\
 	   "sbb{l} {%7,%1|%1,%7}\n\t"				\
 	   "sbb{l} {%5,%0|%0,%5}"				\
-	   : "=r" ((USItype) (r3)),				\
-	     "=&r" ((USItype) (r2)),				\
-	     "=&r" ((USItype) (r1)),				\
-	     "=&r" ((USItype) (r0))				\
+	   : "=r" __asm_output_check_type (USItype, r3),	\
+	     "=&r" __asm_output_check_type (USItype, r2),	\
+	     "=&r" __asm_output_check_type (USItype, r1),	\
+	     "=&r" __asm_output_check_type (USItype, r0)	\
 	   : "0" ((USItype) (x3)),				\
 	     "g" ((USItype) (y3)),				\
 	     "1" ((USItype) (x2)),				\
@@ -115,9 +123,9 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
   __asm__ ("sub{l} {%8,%2|%2,%8}\n\t"				\
 	   "sbb{l} {%6,%1|%1,%6}\n\t"				\
 	   "sbb{l} {%4,%0|%0,%4}"				\
-	   : "=r" ((USItype) (r2)),				\
-	     "=&r" ((USItype) (r1)),				\
-	     "=&r" ((USItype) (r0))				\
+	   : "=r" __asm_output_check_type (USItype, r2),	\
+	     "=&r" __asm_output_check_type (USItype, r1),	\
+	     "=&r" __asm_output_check_type (USItype, r0)	\
 	   : "0" ((USItype) (x2)),				\
 	     "g" ((USItype) (y2)),				\
 	     "1" ((USItype) (x1)),				\
@@ -129,10 +137,10 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
 	   "adc{l} {$0,%2|%2,0}\n\t"				\
 	   "adc{l} {$0,%1|%1,0}\n\t"				\
 	   "adc{l} {$0,%0|%0,0}"				\
-	   : "+r" ((USItype) (x3)),				\
-	     "+&r" ((USItype) (x2)),				\
-	     "+&r" ((USItype) (x1)),				\
-	     "+&r" ((USItype) (x0))				\
+	   : "+r" __asm_output_check_type (USItype, x3),	\
+	     "+&r" __asm_output_check_type (USItype, x2),	\
+	     "+&r" __asm_output_check_type (USItype, x1),	\
+	     "+&r" __asm_output_check_type (USItype, x0)	\
 	   : "g" ((USItype) (i)))

^ permalink raw reply	[flat|nested] 7+ messages in thread
* [glibc/azanella/clang] i386: sfp-machine.h: Do no use asm input cast for clang
@ 2024-02-07 14:07 Adhemerval Zanella
  0 siblings, 0 replies; 7+ messages in thread
From: Adhemerval Zanella @ 2024-02-07 14:07 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=4b26cd2ef61f90ed0ee1b73a2614e7a7d5bda04c

commit 4b26cd2ef61f90ed0ee1b73a2614e7a7d5bda04c
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Tue Jul 26 08:45:41 2022 -0300

    i386: sfp-machine.h: Do no use asm input cast for clang
    
    clang by default rejects the input casts with:
    
      error: invalid use of a cast in a inline asm context requiring an
      lvalue: remove the cast or build with -fheinous-gnu-extensions
    
    And even with -fheinous-gnu-extensions clang still throws an warning
    and also states that this option might be removed in the future.
    For gcc the cast are still useful [1] as type-checking.
    
    [1] https://gcc.gnu.org/pipermail/gcc-patches/2021-October/581722.html

Diff:
---
 sysdeps/x86/fpu/sfp-machine.h | 44 +++++++++++++++++++++++++------------------
 1 file changed, 26 insertions(+), 18 deletions(-)

diff --git a/sysdeps/x86/fpu/sfp-machine.h b/sysdeps/x86/fpu/sfp-machine.h
index 89a73642b1..dd23c797bd 100644
--- a/sysdeps/x86/fpu/sfp-machine.h
+++ b/sysdeps/x86/fpu/sfp-machine.h
@@ -64,15 +64,23 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
 # define _FP_WS_TYPE		signed int
 # define _FP_I_TYPE		int
 
+/* clang does not support output constraint as lvalue, while gcc uses it as a
+   simple type check.  */
+# ifdef __clang__
+#  define __asm_output_check_type(__type, __arg) (__arg)
+# else
+#  define __asm_output_check_type(__type, __arg) ((__type)(__arg))
+# endif
+
 # define __FP_FRAC_ADD_4(r3,r2,r1,r0,x3,x2,x1,x0,y3,y2,y1,y0)	\
   __asm__ ("add{l} {%11,%3|%3,%11}\n\t"				\
 	   "adc{l} {%9,%2|%2,%9}\n\t"				\
 	   "adc{l} {%7,%1|%1,%7}\n\t"				\
 	   "adc{l} {%5,%0|%0,%5}"				\
-	   : "=r" ((USItype) (r3)),				\
-	     "=&r" ((USItype) (r2)),				\
-	     "=&r" ((USItype) (r1)),				\
-	     "=&r" ((USItype) (r0))				\
+	   : "=r" __asm_output_check_type (USItype, r3),	\
+	     "=&r" __asm_output_check_type (USItype, r2),	\
+	     "=&r" __asm_output_check_type (USItype, r1),	\
+	     "=&r" __asm_output_check_type (USItype, r0)	\
 	   : "%0" ((USItype) (x3)),				\
 	     "g" ((USItype) (y3)),				\
 	     "%1" ((USItype) (x2)),				\
@@ -85,9 +93,9 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
   __asm__ ("add{l} {%8,%2|%2,%8}\n\t"				\
 	   "adc{l} {%6,%1|%1,%6}\n\t"				\
 	   "adc{l} {%4,%0|%0,%4}"				\
-	   : "=r" ((USItype) (r2)),				\
-	     "=&r" ((USItype) (r1)),				\
-	     "=&r" ((USItype) (r0))				\
+	   : "=r" __asm_output_check_type (USItype, r2),	\
+	     "=&r" __asm_output_check_type (USItype, r1),	\
+	     "=&r" __asm_output_check_type (USItype, r0)	\
 	   : "%0" ((USItype) (x2)),				\
 	     "g" ((USItype) (y2)),				\
 	     "%1" ((USItype) (x1)),				\
@@ -99,10 +107,10 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
 	   "sbb{l} {%9,%2|%2,%9}\n\t"				\
 	   "sbb{l} {%7,%1|%1,%7}\n\t"				\
 	   "sbb{l} {%5,%0|%0,%5}"				\
-	   : "=r" ((USItype) (r3)),				\
-	     "=&r" ((USItype) (r2)),				\
-	     "=&r" ((USItype) (r1)),				\
-	     "=&r" ((USItype) (r0))				\
+	   : "=r" __asm_output_check_type (USItype, r3),	\
+	     "=&r" __asm_output_check_type (USItype, r2),	\
+	     "=&r" __asm_output_check_type (USItype, r1),	\
+	     "=&r" __asm_output_check_type (USItype, r0)	\
 	   : "0" ((USItype) (x3)),				\
 	     "g" ((USItype) (y3)),				\
 	     "1" ((USItype) (x2)),				\
@@ -115,9 +123,9 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
   __asm__ ("sub{l} {%8,%2|%2,%8}\n\t"				\
 	   "sbb{l} {%6,%1|%1,%6}\n\t"				\
 	   "sbb{l} {%4,%0|%0,%4}"				\
-	   : "=r" ((USItype) (r2)),				\
-	     "=&r" ((USItype) (r1)),				\
-	     "=&r" ((USItype) (r0))				\
+	   : "=r" __asm_output_check_type (USItype, r2),	\
+	     "=&r" __asm_output_check_type (USItype, r1),	\
+	     "=&r" __asm_output_check_type (USItype, r0)	\
 	   : "0" ((USItype) (x2)),				\
 	     "g" ((USItype) (y2)),				\
 	     "1" ((USItype) (x1)),				\
@@ -129,10 +137,10 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
 	   "adc{l} {$0,%2|%2,0}\n\t"				\
 	   "adc{l} {$0,%1|%1,0}\n\t"				\
 	   "adc{l} {$0,%0|%0,0}"				\
-	   : "+r" ((USItype) (x3)),				\
-	     "+&r" ((USItype) (x2)),				\
-	     "+&r" ((USItype) (x1)),				\
-	     "+&r" ((USItype) (x0))				\
+	   : "+r" __asm_output_check_type (USItype, x3),	\
+	     "+&r" __asm_output_check_type (USItype, x2),	\
+	     "+&r" __asm_output_check_type (USItype, x1),	\
+	     "+&r" __asm_output_check_type (USItype, x0)	\
 	   : "g" ((USItype) (i)))

^ permalink raw reply	[flat|nested] 7+ messages in thread
* [glibc/azanella/clang] i386: sfp-machine.h: Do no use asm input cast for clang
@ 2024-02-09 17:32 Adhemerval Zanella
  0 siblings, 0 replies; 7+ messages in thread
From: Adhemerval Zanella @ 2024-02-09 17:32 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=3859a340f89e6373859251b48e3ca4e81510a922

commit 3859a340f89e6373859251b48e3ca4e81510a922
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Tue Jul 26 08:45:41 2022 -0300

    i386: sfp-machine.h: Do no use asm input cast for clang
    
    clang by default rejects the input casts with:
    
      error: invalid use of a cast in a inline asm context requiring an
      lvalue: remove the cast or build with -fheinous-gnu-extensions
    
    And even with -fheinous-gnu-extensions clang still throws an warning
    and also states that this option might be removed in the future.
    For gcc the cast are still useful [1] as type-checking.
    
    [1] https://gcc.gnu.org/pipermail/gcc-patches/2021-October/581722.html

Diff:
---
 sysdeps/x86/fpu/sfp-machine.h | 44 +++++++++++++++++++++++++------------------
 1 file changed, 26 insertions(+), 18 deletions(-)

diff --git a/sysdeps/x86/fpu/sfp-machine.h b/sysdeps/x86/fpu/sfp-machine.h
index 89a73642b1..dd23c797bd 100644
--- a/sysdeps/x86/fpu/sfp-machine.h
+++ b/sysdeps/x86/fpu/sfp-machine.h
@@ -64,15 +64,23 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
 # define _FP_WS_TYPE		signed int
 # define _FP_I_TYPE		int
 
+/* clang does not support output constraint as lvalue, while gcc uses it as a
+   simple type check.  */
+# ifdef __clang__
+#  define __asm_output_check_type(__type, __arg) (__arg)
+# else
+#  define __asm_output_check_type(__type, __arg) ((__type)(__arg))
+# endif
+
 # define __FP_FRAC_ADD_4(r3,r2,r1,r0,x3,x2,x1,x0,y3,y2,y1,y0)	\
   __asm__ ("add{l} {%11,%3|%3,%11}\n\t"				\
 	   "adc{l} {%9,%2|%2,%9}\n\t"				\
 	   "adc{l} {%7,%1|%1,%7}\n\t"				\
 	   "adc{l} {%5,%0|%0,%5}"				\
-	   : "=r" ((USItype) (r3)),				\
-	     "=&r" ((USItype) (r2)),				\
-	     "=&r" ((USItype) (r1)),				\
-	     "=&r" ((USItype) (r0))				\
+	   : "=r" __asm_output_check_type (USItype, r3),	\
+	     "=&r" __asm_output_check_type (USItype, r2),	\
+	     "=&r" __asm_output_check_type (USItype, r1),	\
+	     "=&r" __asm_output_check_type (USItype, r0)	\
 	   : "%0" ((USItype) (x3)),				\
 	     "g" ((USItype) (y3)),				\
 	     "%1" ((USItype) (x2)),				\
@@ -85,9 +93,9 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
   __asm__ ("add{l} {%8,%2|%2,%8}\n\t"				\
 	   "adc{l} {%6,%1|%1,%6}\n\t"				\
 	   "adc{l} {%4,%0|%0,%4}"				\
-	   : "=r" ((USItype) (r2)),				\
-	     "=&r" ((USItype) (r1)),				\
-	     "=&r" ((USItype) (r0))				\
+	   : "=r" __asm_output_check_type (USItype, r2),	\
+	     "=&r" __asm_output_check_type (USItype, r1),	\
+	     "=&r" __asm_output_check_type (USItype, r0)	\
 	   : "%0" ((USItype) (x2)),				\
 	     "g" ((USItype) (y2)),				\
 	     "%1" ((USItype) (x1)),				\
@@ -99,10 +107,10 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
 	   "sbb{l} {%9,%2|%2,%9}\n\t"				\
 	   "sbb{l} {%7,%1|%1,%7}\n\t"				\
 	   "sbb{l} {%5,%0|%0,%5}"				\
-	   : "=r" ((USItype) (r3)),				\
-	     "=&r" ((USItype) (r2)),				\
-	     "=&r" ((USItype) (r1)),				\
-	     "=&r" ((USItype) (r0))				\
+	   : "=r" __asm_output_check_type (USItype, r3),	\
+	     "=&r" __asm_output_check_type (USItype, r2),	\
+	     "=&r" __asm_output_check_type (USItype, r1),	\
+	     "=&r" __asm_output_check_type (USItype, r0)	\
 	   : "0" ((USItype) (x3)),				\
 	     "g" ((USItype) (y3)),				\
 	     "1" ((USItype) (x2)),				\
@@ -115,9 +123,9 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
   __asm__ ("sub{l} {%8,%2|%2,%8}\n\t"				\
 	   "sbb{l} {%6,%1|%1,%6}\n\t"				\
 	   "sbb{l} {%4,%0|%0,%4}"				\
-	   : "=r" ((USItype) (r2)),				\
-	     "=&r" ((USItype) (r1)),				\
-	     "=&r" ((USItype) (r0))				\
+	   : "=r" __asm_output_check_type (USItype, r2),	\
+	     "=&r" __asm_output_check_type (USItype, r1),	\
+	     "=&r" __asm_output_check_type (USItype, r0)	\
 	   : "0" ((USItype) (x2)),				\
 	     "g" ((USItype) (y2)),				\
 	     "1" ((USItype) (x1)),				\
@@ -129,10 +137,10 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
 	   "adc{l} {$0,%2|%2,0}\n\t"				\
 	   "adc{l} {$0,%1|%1,0}\n\t"				\
 	   "adc{l} {$0,%0|%0,0}"				\
-	   : "+r" ((USItype) (x3)),				\
-	     "+&r" ((USItype) (x2)),				\
-	     "+&r" ((USItype) (x1)),				\
-	     "+&r" ((USItype) (x0))				\
+	   : "+r" __asm_output_check_type (USItype, x3),	\
+	     "+&r" __asm_output_check_type (USItype, x2),	\
+	     "+&r" __asm_output_check_type (USItype, x1),	\
+	     "+&r" __asm_output_check_type (USItype, x0)	\
 	   : "g" ((USItype) (i)))

^ permalink raw reply	[flat|nested] 7+ messages in thread
* [glibc/azanella/clang] i386: sfp-machine.h: Do no use asm input cast for clang
@ 2024-04-02 15:54 Adhemerval Zanella
  0 siblings, 0 replies; 7+ messages in thread
From: Adhemerval Zanella @ 2024-04-02 15:54 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=df8bd79253a2014d8083ce18a64fd8d6f7fc827e

commit df8bd79253a2014d8083ce18a64fd8d6f7fc827e
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Tue Jul 26 08:45:41 2022 -0300

    i386: sfp-machine.h: Do no use asm input cast for clang
    
    clang by default rejects the input casts with:
    
      error: invalid use of a cast in a inline asm context requiring an
      lvalue: remove the cast or build with -fheinous-gnu-extensions
    
    And even with -fheinous-gnu-extensions clang still throws an warning
    and also states that this option might be removed in the future.
    For gcc the cast are still useful [1] as type-checking.
    
    [1] https://gcc.gnu.org/pipermail/gcc-patches/2021-October/581722.html

Diff:
---
 sysdeps/x86/fpu/sfp-machine.h | 44 +++++++++++++++++++++++++------------------
 1 file changed, 26 insertions(+), 18 deletions(-)

diff --git a/sysdeps/x86/fpu/sfp-machine.h b/sysdeps/x86/fpu/sfp-machine.h
index 89a73642b1..dd23c797bd 100644
--- a/sysdeps/x86/fpu/sfp-machine.h
+++ b/sysdeps/x86/fpu/sfp-machine.h
@@ -64,15 +64,23 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
 # define _FP_WS_TYPE		signed int
 # define _FP_I_TYPE		int
 
+/* clang does not support output constraint as lvalue, while gcc uses it as a
+   simple type check.  */
+# ifdef __clang__
+#  define __asm_output_check_type(__type, __arg) (__arg)
+# else
+#  define __asm_output_check_type(__type, __arg) ((__type)(__arg))
+# endif
+
 # define __FP_FRAC_ADD_4(r3,r2,r1,r0,x3,x2,x1,x0,y3,y2,y1,y0)	\
   __asm__ ("add{l} {%11,%3|%3,%11}\n\t"				\
 	   "adc{l} {%9,%2|%2,%9}\n\t"				\
 	   "adc{l} {%7,%1|%1,%7}\n\t"				\
 	   "adc{l} {%5,%0|%0,%5}"				\
-	   : "=r" ((USItype) (r3)),				\
-	     "=&r" ((USItype) (r2)),				\
-	     "=&r" ((USItype) (r1)),				\
-	     "=&r" ((USItype) (r0))				\
+	   : "=r" __asm_output_check_type (USItype, r3),	\
+	     "=&r" __asm_output_check_type (USItype, r2),	\
+	     "=&r" __asm_output_check_type (USItype, r1),	\
+	     "=&r" __asm_output_check_type (USItype, r0)	\
 	   : "%0" ((USItype) (x3)),				\
 	     "g" ((USItype) (y3)),				\
 	     "%1" ((USItype) (x2)),				\
@@ -85,9 +93,9 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
   __asm__ ("add{l} {%8,%2|%2,%8}\n\t"				\
 	   "adc{l} {%6,%1|%1,%6}\n\t"				\
 	   "adc{l} {%4,%0|%0,%4}"				\
-	   : "=r" ((USItype) (r2)),				\
-	     "=&r" ((USItype) (r1)),				\
-	     "=&r" ((USItype) (r0))				\
+	   : "=r" __asm_output_check_type (USItype, r2),	\
+	     "=&r" __asm_output_check_type (USItype, r1),	\
+	     "=&r" __asm_output_check_type (USItype, r0)	\
 	   : "%0" ((USItype) (x2)),				\
 	     "g" ((USItype) (y2)),				\
 	     "%1" ((USItype) (x1)),				\
@@ -99,10 +107,10 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
 	   "sbb{l} {%9,%2|%2,%9}\n\t"				\
 	   "sbb{l} {%7,%1|%1,%7}\n\t"				\
 	   "sbb{l} {%5,%0|%0,%5}"				\
-	   : "=r" ((USItype) (r3)),				\
-	     "=&r" ((USItype) (r2)),				\
-	     "=&r" ((USItype) (r1)),				\
-	     "=&r" ((USItype) (r0))				\
+	   : "=r" __asm_output_check_type (USItype, r3),	\
+	     "=&r" __asm_output_check_type (USItype, r2),	\
+	     "=&r" __asm_output_check_type (USItype, r1),	\
+	     "=&r" __asm_output_check_type (USItype, r0)	\
 	   : "0" ((USItype) (x3)),				\
 	     "g" ((USItype) (y3)),				\
 	     "1" ((USItype) (x2)),				\
@@ -115,9 +123,9 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
   __asm__ ("sub{l} {%8,%2|%2,%8}\n\t"				\
 	   "sbb{l} {%6,%1|%1,%6}\n\t"				\
 	   "sbb{l} {%4,%0|%0,%4}"				\
-	   : "=r" ((USItype) (r2)),				\
-	     "=&r" ((USItype) (r1)),				\
-	     "=&r" ((USItype) (r0))				\
+	   : "=r" __asm_output_check_type (USItype, r2),	\
+	     "=&r" __asm_output_check_type (USItype, r1),	\
+	     "=&r" __asm_output_check_type (USItype, r0)	\
 	   : "0" ((USItype) (x2)),				\
 	     "g" ((USItype) (y2)),				\
 	     "1" ((USItype) (x1)),				\
@@ -129,10 +137,10 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
 	   "adc{l} {$0,%2|%2,0}\n\t"				\
 	   "adc{l} {$0,%1|%1,0}\n\t"				\
 	   "adc{l} {$0,%0|%0,0}"				\
-	   : "+r" ((USItype) (x3)),				\
-	     "+&r" ((USItype) (x2)),				\
-	     "+&r" ((USItype) (x1)),				\
-	     "+&r" ((USItype) (x0))				\
+	   : "+r" __asm_output_check_type (USItype, x3),	\
+	     "+&r" __asm_output_check_type (USItype, x2),	\
+	     "+&r" __asm_output_check_type (USItype, x1),	\
+	     "+&r" __asm_output_check_type (USItype, x0)	\
 	   : "g" ((USItype) (i)))

^ permalink raw reply	[flat|nested] 7+ messages in thread
* [glibc/azanella/clang] i386: sfp-machine.h: Do no use asm input cast for clang
@ 2024-04-17 20:07 Adhemerval Zanella
  0 siblings, 0 replies; 7+ messages in thread
From: Adhemerval Zanella @ 2024-04-17 20:07 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=140d0a73995ddde307034e20fbd1a8808a5d4636

commit 140d0a73995ddde307034e20fbd1a8808a5d4636
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Tue Jul 26 08:45:41 2022 -0300

    i386: sfp-machine.h: Do no use asm input cast for clang
    
    clang by default rejects the input casts with:
    
      error: invalid use of a cast in a inline asm context requiring an
      lvalue: remove the cast or build with -fheinous-gnu-extensions
    
    And even with -fheinous-gnu-extensions clang still throws an warning
    and also states that this option might be removed in the future.
    For gcc the cast are still useful [1] as type-checking.
    
    [1] https://gcc.gnu.org/pipermail/gcc-patches/2021-October/581722.html

Diff:
---
 sysdeps/x86/fpu/sfp-machine.h | 44 +++++++++++++++++++++++++------------------
 1 file changed, 26 insertions(+), 18 deletions(-)

diff --git a/sysdeps/x86/fpu/sfp-machine.h b/sysdeps/x86/fpu/sfp-machine.h
index 89a73642b1..dd23c797bd 100644
--- a/sysdeps/x86/fpu/sfp-machine.h
+++ b/sysdeps/x86/fpu/sfp-machine.h
@@ -64,15 +64,23 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
 # define _FP_WS_TYPE		signed int
 # define _FP_I_TYPE		int
 
+/* clang does not support output constraint as lvalue, while gcc uses it as a
+   simple type check.  */
+# ifdef __clang__
+#  define __asm_output_check_type(__type, __arg) (__arg)
+# else
+#  define __asm_output_check_type(__type, __arg) ((__type)(__arg))
+# endif
+
 # define __FP_FRAC_ADD_4(r3,r2,r1,r0,x3,x2,x1,x0,y3,y2,y1,y0)	\
   __asm__ ("add{l} {%11,%3|%3,%11}\n\t"				\
 	   "adc{l} {%9,%2|%2,%9}\n\t"				\
 	   "adc{l} {%7,%1|%1,%7}\n\t"				\
 	   "adc{l} {%5,%0|%0,%5}"				\
-	   : "=r" ((USItype) (r3)),				\
-	     "=&r" ((USItype) (r2)),				\
-	     "=&r" ((USItype) (r1)),				\
-	     "=&r" ((USItype) (r0))				\
+	   : "=r" __asm_output_check_type (USItype, r3),	\
+	     "=&r" __asm_output_check_type (USItype, r2),	\
+	     "=&r" __asm_output_check_type (USItype, r1),	\
+	     "=&r" __asm_output_check_type (USItype, r0)	\
 	   : "%0" ((USItype) (x3)),				\
 	     "g" ((USItype) (y3)),				\
 	     "%1" ((USItype) (x2)),				\
@@ -85,9 +93,9 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
   __asm__ ("add{l} {%8,%2|%2,%8}\n\t"				\
 	   "adc{l} {%6,%1|%1,%6}\n\t"				\
 	   "adc{l} {%4,%0|%0,%4}"				\
-	   : "=r" ((USItype) (r2)),				\
-	     "=&r" ((USItype) (r1)),				\
-	     "=&r" ((USItype) (r0))				\
+	   : "=r" __asm_output_check_type (USItype, r2),	\
+	     "=&r" __asm_output_check_type (USItype, r1),	\
+	     "=&r" __asm_output_check_type (USItype, r0)	\
 	   : "%0" ((USItype) (x2)),				\
 	     "g" ((USItype) (y2)),				\
 	     "%1" ((USItype) (x1)),				\
@@ -99,10 +107,10 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
 	   "sbb{l} {%9,%2|%2,%9}\n\t"				\
 	   "sbb{l} {%7,%1|%1,%7}\n\t"				\
 	   "sbb{l} {%5,%0|%0,%5}"				\
-	   : "=r" ((USItype) (r3)),				\
-	     "=&r" ((USItype) (r2)),				\
-	     "=&r" ((USItype) (r1)),				\
-	     "=&r" ((USItype) (r0))				\
+	   : "=r" __asm_output_check_type (USItype, r3),	\
+	     "=&r" __asm_output_check_type (USItype, r2),	\
+	     "=&r" __asm_output_check_type (USItype, r1),	\
+	     "=&r" __asm_output_check_type (USItype, r0)	\
 	   : "0" ((USItype) (x3)),				\
 	     "g" ((USItype) (y3)),				\
 	     "1" ((USItype) (x2)),				\
@@ -115,9 +123,9 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
   __asm__ ("sub{l} {%8,%2|%2,%8}\n\t"				\
 	   "sbb{l} {%6,%1|%1,%6}\n\t"				\
 	   "sbb{l} {%4,%0|%0,%4}"				\
-	   : "=r" ((USItype) (r2)),				\
-	     "=&r" ((USItype) (r1)),				\
-	     "=&r" ((USItype) (r0))				\
+	   : "=r" __asm_output_check_type (USItype, r2),	\
+	     "=&r" __asm_output_check_type (USItype, r1),	\
+	     "=&r" __asm_output_check_type (USItype, r0)	\
 	   : "0" ((USItype) (x2)),				\
 	     "g" ((USItype) (y2)),				\
 	     "1" ((USItype) (x1)),				\
@@ -129,10 +137,10 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
 	   "adc{l} {$0,%2|%2,0}\n\t"				\
 	   "adc{l} {$0,%1|%1,0}\n\t"				\
 	   "adc{l} {$0,%0|%0,0}"				\
-	   : "+r" ((USItype) (x3)),				\
-	     "+&r" ((USItype) (x2)),				\
-	     "+&r" ((USItype) (x1)),				\
-	     "+&r" ((USItype) (x0))				\
+	   : "+r" __asm_output_check_type (USItype, x3),	\
+	     "+&r" __asm_output_check_type (USItype, x2),	\
+	     "+&r" __asm_output_check_type (USItype, x1),	\
+	     "+&r" __asm_output_check_type (USItype, x0)	\
 	   : "g" ((USItype) (i)))

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

end of thread, other threads:[~2024-04-17 20:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-28 17:52 [glibc/azanella/clang] i386: sfp-machine.h: Do no use asm input cast for clang Adhemerval Zanella
2023-12-21 18:54 Adhemerval Zanella
2024-01-29 17:57 Adhemerval Zanella
2024-02-07 14:07 Adhemerval Zanella
2024-02-09 17:32 Adhemerval Zanella
2024-04-02 15:54 Adhemerval Zanella
2024-04-17 20:07 Adhemerval Zanella

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