Re: [Ada,FYI] revamp ada.numerics.aux
On Jan 21, 2021, Sebastian Huber wrote: > Which target properties determine that a-nallfl__wraplf.ads should be > used? The question really is what makes the default a-nallfl.ads unusable for a target. It works when the Ada type Long_Long_Float and the C long double type are nop-convertible. When they aren't, the attempt to compile it will report mismatch between the functions declared with Long_Long_Float, and the C intrinsics they're mapped to. > Can it be used for all targets? It would compile, but it shouldn't be used that way. The wraplf implementation uses wrappers of the Long_Float/C double implementations of trigonometric and transcendental functions. When Long_Long_Float and Long_Float are different names for the same base FP types, that's ok, but when Long_Long_Float is wider, the results may be unacceptably imprecise. in general, you can use wraplf when long double and double use the same representation in C. When they don't, one needs to tell whether GNAT maps Long_Long_Float to long double or to double. GNAT wants Long_Long_Float to be as much of a hardware-supported type as Long_Float, and the heuristics to accomplish that, in gcc/ada/set_targ.adb:C_Type_For is to only use long double if it can represent no more than 18 digits. I believe this heuristics is to be revisited in a not-too-distant future, but it's what it is ATM. -- Alexandre Oliva, happy hacker https://FSFLA.org/blogs/lxo/ Free Software Activist GNU Toolchain Engineer Vim, Vi, Voltei pro Emacs -- GNUlius Caesar
Re: [Ada,FYI] revamp ada.numerics.aux
Hello Alexandre, On 13/01/2021 19:40, Alexandre Oliva wrote: Would you like to take a stab at it yourself, or should I? I can try to figure out a patch, but I have to guess how it works. What's needed is adding LIBGNAT_TARGET_PAIRS += \ a-nallfl.adsI have this issue also for AArch64. For Linux this is also used for MIPS, PowerPC, SPARC. I was able to build a PowerPC (32 and 64 bit) and SPARC compiler without the a-nallfl__wraplf.ads. Which target properties determine that a-nallfl__wraplf.ads should be used? Can it be used for all targets? -- embedded brains GmbH Herr Sebastian HUBER Dornierstr. 4 82178 Puchheim Germany email: sebastian.hu...@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/
Re: [Ada,FYI] revamp ada.numerics.aux
On Jan 13, 2021, Sebastian Huber wrote: > This is probably not RTEMS-specific. I guess it is a general riscv issue. You're right, but the riscv*-linux-gnu configuration already has the fix. >> Would you like to take a stab at it yourself, or should I? > I can try to figure out a patch, but I have to guess how it works. What's needed is adding LIBGNAT_TARGET_PAIRS += \ a-nallfl.adshttps://FSFLA.org/blogs/lxo/ Free Software Activist GNU Toolchain Engineer Vim, Vi, Voltei pro Emacs -- GNUlius Caesar
Re: [Ada,FYI] revamp ada.numerics.aux
On 13/01/2021 17:45, Alexandre Oliva wrote: Hello, Sebastian, On Jan 13, 2021, Sebastian Huber wrote: I have a similar issue on riscv-rtems*: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98595 Can this be fixed also with a patch to gcc/ada/Makefile.rtl? Yeah, that's definitely the way to go. I'm afraid the fix will be a little more involved than others because there doesn't seem to be any Makefile.rtl section specific for riscv-rtems, but that's just a matter of creating one. This is probably not RTEMS-specific. I guess it is a general riscv issue. Would you like to take a stab at it yourself, or should I? I can try to figure out a patch, but I have to guess how it works. -- embedded brains GmbH Herr Sebastian HUBER Dornierstr. 4 82178 Puchheim Germany email: sebastian.hu...@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/
Re: [Ada,FYI] revamp ada.numerics.aux
Hello, Sebastian, On Jan 13, 2021, Sebastian Huber wrote: > I have a similar issue on riscv-rtems*: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98595 > Can this be fixed also with a patch to gcc/ada/Makefile.rtl? Yeah, that's definitely the way to go. I'm afraid the fix will be a little more involved than others because there doesn't seem to be any Makefile.rtl section specific for riscv-rtems, but that's just a matter of creating one. Would you like to take a stab at it yourself, or should I? -- Alexandre Oliva, happy hacker https://FSFLA.org/blogs/lxo/ Free Software Activist GNU Toolchain Engineer Vim, Vi, Voltei pro Emacs -- GNUlius Caesar
Re: [Ada,FYI] revamp ada.numerics.aux
Hello Alexandre, On 19/10/2020 13:52, Alexandre Oliva wrote: On Oct 19, 2020, Andreas Schwab wrote: -nostdinc a-nallfl.ads -o a-nallfl.o a-nallfl.ads:48:13: warning: intrinsic binding type mismatch on return value a-nallfl.ads:48:13: warning: intrinsic binding type mismatch on argument 1 a-nallfl.ads:48:13: warning: profile of "Sin" doesn't match the builtin it binds Thanks for the report. Ada's Standard.Long_Long_Float is mapped to C double rather than long double on this target. Here's a workaround, for aarch64-* and ppc*-linux-gnu, where I've observed the mismatch so far. I'm not sure whether we're going to use something like this, or a fix for the mismatch; I'm yet to figure out how to implement the latter. aarch64-* and ppc*-linux-gnu long long float/long double mismatch I have a similar issue on riscv-rtems*: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98595 Can this be fixed also with a patch to gcc/ada/Makefile.rtl? -- embedded brains GmbH Herr Sebastian HUBER Dornierstr. 4 82178 Puchheim Germany email: sebastian.hu...@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/
Re: move sincos after pre (was: Re: [Ada, FYI] revamp ada.numerics.aux)
On October 23, 2020 4:23:35 PM GMT+02:00, Alexandre Oliva wrote: >On Oct 22, 2020, Alexandre Oliva wrote: > >> On Oct 18, 2020, Alexandre Oliva wrote: >>> The option is provided by default, but there is an alternate version >>> that doesn't, that is used for vxworks targets. > >> vxworks float EFs not precise enough -> use long float > >> From: Alexandre Oliva > >> Some acats-4 tests that check the precision of Float elementary >> functions fail with vxworks 7.2's implementations of single-precision >> math functions. > >> This patch arranges for us to bypass the single-precision functions, >> and use the Aux_Long_Float implementation, based on the double-typed >> calls from the C library, for Float and Short_Float. > > >On platforms in which Aux_[Real_Type] involves non-NOP conversions >(e.g., between single- and double-precision, or between short float >and float), the conversions before the calls are CSEd too late for >sincos to combine calls. > >This patch moves sincos after PRE, where the conversions are unified >at -O2. > >I'm regstrapping this on x86_64-linux-gnu and powerpc64-linux-gnu, and >also testing it on affected platforms. Another way to go, that would >take a little more effort, would be to extend sincos to take equivalent >conversions as the same operand, but I doubt I'll be able to undertake >that any time soon, so... Is this one ok to install? Can you move it one pass further after sink please? Also I don't remember exactly but does pass_sincos only handle sin/cos unifying? Thanks, Richard. > >for gcc/ChangeLog > > * passes.def: Move sincos after pre. > >for gcc/testsuite/ChangeLog > > * gnat.dg/sin_cos.ads: New. > * gnat.dg/sin_cos.adb: New. > * gcc.dg/sin_cos.c: New. >--- > gcc/passes.def|2 +- >gcc/testsuite/gcc.dg/sin_cos.c| 41 >+ > gcc/testsuite/gnat.dg/sin_cos.adb | 14 + > gcc/testsuite/gnat.dg/sin_cos.ads |4 > 4 files changed, 60 insertions(+), 1 deletion(-) > create mode 100644 gcc/testsuite/gcc.dg/sin_cos.c > create mode 100644 gcc/testsuite/gnat.dg/sin_cos.adb > create mode 100644 gcc/testsuite/gnat.dg/sin_cos.ads > >diff --git a/gcc/passes.def b/gcc/passes.def >index cf15d8e..2743506 100644 >--- a/gcc/passes.def >+++ b/gcc/passes.def >@@ -242,12 +242,12 @@ along with GCC; see the file COPYING3. If not >see > NEXT_PASS (pass_ccp, true /* nonzero_p */); > /* After CCP we rewrite no longer addressed locals into SSA >form if possible. */ >- NEXT_PASS (pass_cse_sincos); > NEXT_PASS (pass_optimize_bswap); > NEXT_PASS (pass_laddress); > NEXT_PASS (pass_lim); > NEXT_PASS (pass_walloca, false); > NEXT_PASS (pass_pre); >+ NEXT_PASS (pass_cse_sincos); > NEXT_PASS (pass_sink_code); > NEXT_PASS (pass_sancov); > NEXT_PASS (pass_asan); >diff --git a/gcc/testsuite/gcc.dg/sin_cos.c >b/gcc/testsuite/gcc.dg/sin_cos.c >new file mode 100644 >index ..a4a7727 >--- /dev/null >+++ b/gcc/testsuite/gcc.dg/sin_cos.c >@@ -0,0 +1,41 @@ >+/* { dg-do compile } */ >+/* { dg-options "-O2" } */ >+ >+/* This maps to essentially the same gimple that is generated for >+ gnat.dg/sin_cos.adb, on platforms that use the wraplf variant of >+ Ada.Numerics.Aux_Float. The value of EPSILON is not relevant to >+ the test, but the test must be there to keep the conversions in >+ different BBs long enough to trigger the problem that prevented the >+ sincos optimization, because the arguments passed to sin and cos >+ didn't get unified into a single SSA_NAME in time for sincos. */ >+ >+#include >+ >+#define EPSILON 3.4526697709225118160247802734375e-4 >+ >+static float my_sinf(float x) { >+ return (float) sin ((double) x); >+} >+ >+static float wrap_sinf(float x) { >+ if (fabs (x) < EPSILON) >+return 0; >+ return my_sinf (x); >+} >+ >+static float my_cosf(float x) { >+ return (float) cos ((double) x); >+} >+ >+static float wrap_cosf(float x) { >+ if (fabs (x) < EPSILON) >+return 1; >+ return my_cosf (x); >+} >+ >+float my_sin_cos(float x, float *s, float *c) { >+ *s = wrap_sinf (x); >+ *c = wrap_cosf (x); >+} >+ >+/* { dg-final { scan-assembler "sincos\|cexp" { target *-linux-gnu* >*-w64-mingw* powerpc*-*-* } } } */ >diff --git a/gcc/testsuite/gnat.dg/sin_cos.adb >b/gcc/testsuite/gnat.dg/sin_cos.adb >new file mode 100644 >index ..e72f521 >--- /dev/null >+++ b/gcc/testsuite/gnat.dg/sin_cos.adb >@@ -0,0 +1,14 @@ >+-- { dg-do compile } >+-- { dg-options "-O2 -gnatn" } >+ >+with Ada.Numerics.Elementary_Functions; >+use Ada.Numerics.Elementary_Functions; >+package body Sin_Cos is >+ procedure Sin_Cos (Angle : T; SinA, CosA : out T) is >+ begin >+ SinA := Sin (Angle); >+ CosA := Cos (Angle); >+ end; >+end Sin_Cos; >+ >+-- { dg-final { scan-assembler "sincos\|cexp" { target *-linux-gnu* >*-w64-mingw* powerpc*-*-* } } } >diff --git
move sincos after pre (was: Re: [Ada,FYI] revamp ada.numerics.aux)
On Oct 22, 2020, Alexandre Oliva wrote: > On Oct 18, 2020, Alexandre Oliva wrote: >> The option is provided by default, but there is an alternate version >> that doesn't, that is used for vxworks targets. > vxworks float EFs not precise enough -> use long float > From: Alexandre Oliva > Some acats-4 tests that check the precision of Float elementary > functions fail with vxworks 7.2's implementations of single-precision > math functions. > This patch arranges for us to bypass the single-precision functions, > and use the Aux_Long_Float implementation, based on the double-typed > calls from the C library, for Float and Short_Float. On platforms in which Aux_[Real_Type] involves non-NOP conversions (e.g., between single- and double-precision, or between short float and float), the conversions before the calls are CSEd too late for sincos to combine calls. This patch moves sincos after PRE, where the conversions are unified at -O2. I'm regstrapping this on x86_64-linux-gnu and powerpc64-linux-gnu, and also testing it on affected platforms. Another way to go, that would take a little more effort, would be to extend sincos to take equivalent conversions as the same operand, but I doubt I'll be able to undertake that any time soon, so... Is this one ok to install? for gcc/ChangeLog * passes.def: Move sincos after pre. for gcc/testsuite/ChangeLog * gnat.dg/sin_cos.ads: New. * gnat.dg/sin_cos.adb: New. * gcc.dg/sin_cos.c: New. --- gcc/passes.def|2 +- gcc/testsuite/gcc.dg/sin_cos.c| 41 + gcc/testsuite/gnat.dg/sin_cos.adb | 14 + gcc/testsuite/gnat.dg/sin_cos.ads |4 4 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/sin_cos.c create mode 100644 gcc/testsuite/gnat.dg/sin_cos.adb create mode 100644 gcc/testsuite/gnat.dg/sin_cos.ads diff --git a/gcc/passes.def b/gcc/passes.def index cf15d8e..2743506 100644 --- a/gcc/passes.def +++ b/gcc/passes.def @@ -242,12 +242,12 @@ along with GCC; see the file COPYING3. If not see NEXT_PASS (pass_ccp, true /* nonzero_p */); /* After CCP we rewrite no longer addressed locals into SSA form if possible. */ - NEXT_PASS (pass_cse_sincos); NEXT_PASS (pass_optimize_bswap); NEXT_PASS (pass_laddress); NEXT_PASS (pass_lim); NEXT_PASS (pass_walloca, false); NEXT_PASS (pass_pre); + NEXT_PASS (pass_cse_sincos); NEXT_PASS (pass_sink_code); NEXT_PASS (pass_sancov); NEXT_PASS (pass_asan); diff --git a/gcc/testsuite/gcc.dg/sin_cos.c b/gcc/testsuite/gcc.dg/sin_cos.c new file mode 100644 index ..a4a7727 --- /dev/null +++ b/gcc/testsuite/gcc.dg/sin_cos.c @@ -0,0 +1,41 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +/* This maps to essentially the same gimple that is generated for + gnat.dg/sin_cos.adb, on platforms that use the wraplf variant of + Ada.Numerics.Aux_Float. The value of EPSILON is not relevant to + the test, but the test must be there to keep the conversions in + different BBs long enough to trigger the problem that prevented the + sincos optimization, because the arguments passed to sin and cos + didn't get unified into a single SSA_NAME in time for sincos. */ + +#include + +#define EPSILON 3.4526697709225118160247802734375e-4 + +static float my_sinf(float x) { + return (float) sin ((double) x); +} + +static float wrap_sinf(float x) { + if (fabs (x) < EPSILON) +return 0; + return my_sinf (x); +} + +static float my_cosf(float x) { + return (float) cos ((double) x); +} + +static float wrap_cosf(float x) { + if (fabs (x) < EPSILON) +return 1; + return my_cosf (x); +} + +float my_sin_cos(float x, float *s, float *c) { + *s = wrap_sinf (x); + *c = wrap_cosf (x); +} + +/* { dg-final { scan-assembler "sincos\|cexp" { target *-linux-gnu* *-w64-mingw* powerpc*-*-* } } } */ diff --git a/gcc/testsuite/gnat.dg/sin_cos.adb b/gcc/testsuite/gnat.dg/sin_cos.adb new file mode 100644 index ..e72f521 --- /dev/null +++ b/gcc/testsuite/gnat.dg/sin_cos.adb @@ -0,0 +1,14 @@ +-- { dg-do compile } +-- { dg-options "-O2 -gnatn" } + +with Ada.Numerics.Elementary_Functions; +use Ada.Numerics.Elementary_Functions; +package body Sin_Cos is + procedure Sin_Cos (Angle : T; SinA, CosA : out T) is + begin + SinA := Sin (Angle); + CosA := Cos (Angle); + end; +end Sin_Cos; + +-- { dg-final { scan-assembler "sincos\|cexp" { target *-linux-gnu* *-w64-mingw* powerpc*-*-* } } } diff --git a/gcc/testsuite/gnat.dg/sin_cos.ads b/gcc/testsuite/gnat.dg/sin_cos.ads new file mode 100644 index ..a0eff3d --- /dev/null +++ b/gcc/testsuite/gnat.dg/sin_cos.ads @@ -0,0 +1,4 @@ +package Sin_Cos is + subtype T is Float; + procedure Sin_Cos (Angle : T; SinA, CosA : out T); +end Sin_Cos; -- Alexandre Oliva, happy hacker https://FSFLA.org/blogs/lxo/ Free Software Activist
Re: [Ada,FYI] revamp ada.numerics.aux
On Oct 22, 2020, Eric Botcazou wrote: >> So I'm going ahead and checking this in, approved by Eric Botcazou. >> (Rainer's followup patch is coming up separately but momentarily) >> >> >> aarch64-* and ppc*-linux-gnu long long float/long double mismatch > Does this fix https://gcc.gnu.org/PR97504 for PowerPC64? Yeah. > Note that S/390 is affected as well according to Stefan. Thanks for drawing my attention to it. I also noticed sparc*-linux-gnu and powerpc*-darwin had missed the earlier fixes for sparc and ppc. Here's the patch I'm checking in. more wraplf for aux long long float: s390, sparc and powerpc From: Alexandre Oliva The wraplf version of Ada.Numerics.Aux_Long_Long_Float is needed on s390* as well. Also add it to sparc*-linux-gnu and powerpc-darwin, that were missed when adding it for sparc and ppc targets. for gcc/ada/ChangeLog PR ada/97504 * Makefile.rtl (LIBGNAT_TARGET_PAIRS): Select wraplf version of Aux_Long_Long_Float for s390 and remaining sparc and powerpc targets. --- gcc/ada/Makefile.rtl |3 +++ 1 file changed, 3 insertions(+) diff --git a/gcc/ada/Makefile.rtl b/gcc/ada/Makefile.rtl index e2a4f4e..a1cf23a 100644 --- a/gcc/ada/Makefile.rtl +++ b/gcc/ada/Makefile.rtl @@ -1909,6 +1909,7 @@ endif ifeq ($(strip $(filter-out s390% linux%,$(target_cpu) $(target_os))),) LIBGNAT_TARGET_PAIRS = \ a-intnam.adshttps://FSFLA.org/blogs/lxo/ Free Software Activist GNU Toolchain Engineer
Re: [Ada,FYI] revamp ada.numerics.aux
Rainer Orth wrote: > Hi Alexandre, > >> On Oct 19, 2020, Andreas Schwab wrote: >> >>> -nostdinc a-nallfl.ads -o a-nallfl.o >>> a-nallfl.ads:48:13: warning: intrinsic binding type mismatch on return value >>> a-nallfl.ads:48:13: warning: intrinsic binding type mismatch on argument 1 >>> a-nallfl.ads:48:13: warning: profile of "Sin" doesn't match the builtin >>> it binds >> >> Thanks for the report. Ada's Standard.Long_Long_Float is mapped to C >> double rather than long double on this target. >> >> Here's a workaround, for aarch64-* and ppc*-linux-gnu, where I've >> observed the mismatch so far. > > your patch similarly broke sparc*-sun-solaris* bootstrap. The attached > snippet on top of this workaround fixes that. Also powerpc-darwin. FAOD - these functions only related to the C “double” [64bit] type, right? (i.e. this is not related to the use of of long double [on powerpc darwin, the default for that is the same as AIX - ibm128]). thanks Iain [PATCH] Darwin, Ada, PowerPC : Fix bootstrap after recent change. --- gcc/ada/Makefile.rtl | 1 + 1 file changed, 1 insertion(+) diff --git a/gcc/ada/Makefile.rtl b/gcc/ada/Makefile.rtl index 7a0c05b423d..9fd9f6af25f 100644 --- a/gcc/ada/Makefile.rtl +++ b/gcc/ada/Makefile.rtl @@ -2778,6 +2778,7 @@ ifeq ($(strip $(filter-out darwin%,$(target_os))),) ifeq ($(strip $(filter-out powerpc%,$(target_cpu))),) LIBGNAT_TARGET_PAIRS += \ + a-nallfl.ads
Re: [Ada,FYI] revamp ada.numerics.aux
> So I'm going ahead and checking this in, approved by Eric Botcazou. > (Rainer's followup patch is coming up separately but momentarily) > > > aarch64-* and ppc*-linux-gnu long long float/long double mismatch Does this fix https://gcc.gnu.org/PR97504 for PowerPC64? Note that S/390 is affected as well according to Stefan. -- Eric Botcazou
Re: [Ada,FYI] revamp ada.numerics.aux
On Oct 22, 2020, Alexandre Oliva wrote: > (some regressions remain on x86 and x86_64, > so further changes are expected Here's the fix I'm installing. I'd failed to add the __nolibm bit to x86*-vxworks in the Ada.Numerics.Aux revamp patch. Then, when I added __wraplf for low-precision real types, I added them next to __nolibm, since that was supposed to be present for all vxworks ports. Oops. I'm checking this in. Tested with the affected platforms. Approved by Eric Botcazou. use wraplf for low-precision elementary functions on x86*-vxworks too From: Alexandre Oliva The earlier patch that introduced the wraplf variants missed the x86*-vxworks* ports. This fixes them. for gcc/ada/ChangeLog * Makefile.rtl (LIBGNAT_TARGET_PAIRS) : Select nolibm and wraplf variants like other vxworks ports. --- gcc/ada/Makefile.rtl |3 +++ 1 file changed, 3 insertions(+) diff --git a/gcc/ada/Makefile.rtl b/gcc/ada/Makefile.rtl index efb73e5..e2a4f4e 100644 --- a/gcc/ada/Makefile.rtl +++ b/gcc/ada/Makefile.rtl @@ -1279,6 +1279,9 @@ ifeq ($(strip $(filter-out %86 x86_64 wrs vxworks vxworks7%,$(target_cpu) $(targ LIBGNAT_TARGET_PAIRS+= \ a-intnam.adshttps://FSFLA.org/blogs/lxo/ Free Software Activist GNU Toolchain Engineer
Re: [Ada,FYI] revamp ada.numerics.aux
On Oct 18, 2020, Alexandre Oliva wrote: > The Aux_Short_Float unit is implemented in terms of the Aux_Float one, > and the others rely on the elementary functions from the C Math > library for float, double and long double types, respectively. Use Aux_Long_Float for all real types on LynxOS From: Alexandre Oliva Its libc does not offer *f or *l elementary functions, so rely on the C double ones only. Tested with the target platform, also regstrapped on x86_64-linux-gnu along with other patches. Approved by Eric Botcazou. for gcc/ada/ChangeLog * Makefile.rtl (LIBGNAT_TARGET_PAIRS) : Rely on Aux_Long_Float for all real types. --- gcc/ada/Makefile.rtl |3 +++ 1 file changed, 3 insertions(+) diff --git a/gcc/ada/Makefile.rtl b/gcc/ada/Makefile.rtl index 04c7cc8..efb73e5 100644 --- a/gcc/ada/Makefile.rtl +++ b/gcc/ada/Makefile.rtl @@ -2015,6 +2015,9 @@ ifeq ($(strip $(filter-out lynxos178%,$(target_os))),) LIBGNAT_TARGET_PAIRS = \ a-intnam.adshttps://FSFLA.org/blogs/lxo/ Free Software Activist GNU Toolchain Engineer
Re: [Ada,FYI] revamp ada.numerics.aux
On Oct 18, 2020, Alexandre Oliva wrote: > The option is provided by default, but there is an alternate version > that doesn't, that is used for vxworks targets. vxworks float EFs not precise enough -> use long float From: Alexandre Oliva Some acats-4 tests that check the precision of Float elementary functions fail with vxworks 7.2's implementations of single-precision math functions. This patch arranges for us to bypass the single-precision functions, and use the Aux_Long_Float implementation, based on the double-typed calls from the C library, for Float and Short_Float. Tested on affected platforms (some regressions remain on x86 and x86_64, so further changes are expected, but this is incremental progress), also regstrapped on x86_64-linux-gnu along with other patches, approved by Eric Botcazou. for gcc/ada/ChangeLog * Makefile.rtl (LIBGNAT_TARGET_PAIRS): Use Long Float-based variant of Aux_Short_Float and Aux_Float on vxworks targets. * libgnat/a-nashfl__wraplf.ads: New. * libgnat/a-nuaufl__wraplf.ads: New. --- gcc/ada/Makefile.rtl |8 +++ gcc/ada/libgnat/a-nashfl__wraplf.ads | 87 ++ gcc/ada/libgnat/a-nuaufl__wraplf.ads | 87 ++ 3 files changed, 182 insertions(+) create mode 100644 gcc/ada/libgnat/a-nashfl__wraplf.ads create mode 100644 gcc/ada/libgnat/a-nuaufl__wraplf.ads diff --git a/gcc/ada/Makefile.rtl b/gcc/ada/Makefile.rtl index fb7ecb1..04c7cc8 100644 --- a/gcc/ada/Makefile.rtl +++ b/gcc/ada/Makefile.rtl @@ -1026,6 +1026,8 @@ ifeq ($(strip $(filter-out powerpc% wrs vxworks vxworksspe vxworks7% vxworks7spe LIBGNAT_TARGET_PAIRS = \ a-intnam.adshttp://www.gnu.org/licenses/>. -- +-- -- +-- GNAT was originally developed by the GNAT team at New York University. -- +-- Extensive contributions were provided by Ada Core Technologies Inc. -- +-- -- +-- + +-- This package provides the basic computational interface for the +-- generic elementary functions. The functions in this unit are +-- wrappers for those in the Long Float package. + +with Ada.Numerics.Aux_Long_Float; + +package Ada.Numerics.Aux_Short_Float is + pragma Pure; + + subtype T is Short_Float; + package Aux renames Ada.Numerics.Aux_Long_Float; + subtype W is Aux.T; + + -- Use the Aux implementation. + + function Sin (X : T) return T + is (T (Aux.Sin (W (X; + + function Cos (X : T) return T + is (T (Aux.Cos (W (X; + + function Tan (X : T) return T + is (T (Aux.Tan (W (X; + + function Exp (X : T) return T + is (T (Aux.Exp (W (X; + + function Sqrt (X : T) return T + is (T (Aux.Sqrt (W (X; + + function Log (X : T) return T + is (T (Aux.Log (W (X; + + function Acos (X : T) return T + is (T (Aux.Acos (W (X; + + function Asin (X : T) return T + is (T (Aux.Asin (W (X; + + function Atan (X : T) return T + is (T (Aux.Atan (W (X; + + function Sinh (X : T) return T + is (T (Aux.Sinh (W (X; + + function Cosh (X : T) return T + is (T (Aux.Cosh (W (X; + + function Tanh (X : T) return T + is (T (Aux.Tanh (W (X; + + function Pow (X, Y : T) return T + is (T (Aux.Pow (W (X), W (Y; + +end Ada.Numerics.Aux_Short_Float; diff --git a/gcc/ada/libgnat/a-nuaufl__wraplf.ads b/gcc/ada/libgnat/a-nuaufl__wraplf.ads new file mode 100644 index ..b6eb22c --- /dev/null +++ b/gcc/ada/libgnat/a-nuaufl__wraplf.ads @@ -0,0 +1,87 @@ +-- +-- -- +-- GNAT RUN-TIME COMPONENTS -- +-- -- +-- A D A . N U M E R I C S . A U X _ F L O A T-- +-- -- +-- S p e c -- +-- (Double-based Version, Float) -- +-- -- +-- Copyright (C) 1992-2020, Free Software Foundation, Inc. -- +-- -- +-- GNAT is free software; you can redistribute it and/or modify it under -- +-- terms of the GNU General Public License as published by the Free Soft- -- +-- ware Foundation; either version 3, or (at your option) any later ver- -- +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- +-- OUT ANY WARRANTY; without even the
Re: [Ada,FYI] revamp ada.numerics.aux
On Oct 20, 2020, Rainer Orth wrote: > your patch similarly broke sparc*-sun-solaris* bootstrap. The attached > snippet on top of this workaround fixes that. Thanks, here's what I'm installing, approved by me with my build machinery maintainer hat on ;-) Use Aux_Long_Long_Float wraplf for sparc*-sun-solaris too From: Rainer Orth Like aarch64-* and ppc*-linux-gnu, sparc*-sun-solaris has Long_Long_Float mapped to double rather than long double, so the intrinsics in the default version of a-nallfl.ads have mismatching types. Adopt the wraplf workaround for it as well. for gcc/ada/ChangeLog * Makefile.rtl (LIBGNAT_TARGET_PAIRS) : Use wraplf version of a-nallfl. --- gcc/ada/Makefile.rtl |1 + 1 file changed, 1 insertion(+) diff --git a/gcc/ada/Makefile.rtl b/gcc/ada/Makefile.rtl index 87ee3e9..fb7ecb1 100644 --- a/gcc/ada/Makefile.rtl +++ b/gcc/ada/Makefile.rtl @@ -1572,6 +1572,7 @@ endif ifeq ($(strip $(filter-out sparc% sun solaris%,$(target_cpu) $(target_vendor) $(target_os))),) LIBGNAT_TARGET_PAIRS = \ a-intnam.adshttps://FSFLA.org/blogs/lxo/ Free Software Activist GNU Toolchain Engineer
Re: [Ada,FYI] revamp ada.numerics.aux
On Oct 19, 2020, Alexandre Oliva wrote: > Hello, Andreas, > On Oct 19, 2020, Andreas Schwab wrote: >> -nostdinc a-nallfl.ads -o a-nallfl.o >> a-nallfl.ads:48:13: warning: intrinsic binding type mismatch on return value >> a-nallfl.ads:48:13: warning: intrinsic binding type mismatch on argument 1 >> a-nallfl.ads:48:13: warning: profile of "Sin" doesn't match the builtin it >> binds > Thanks for the report. Ada's Standard.Long_Long_Float is mapped to C > double rather than long double on this target. Long story short, we're keeping the mapping as is at least for now. For the curious, it's caused by the Max_HW_Digits cap in Set_Target.C_Type_For, in gcc/ada/set_targ.adb. So I'm going ahead and checking this in, approved by Eric Botcazou. (Rainer's followup patch is coming up separately but momentarily) aarch64-* and ppc*-linux-gnu long long float/long double mismatch From: Alexandre Oliva Some platforms have failed to build because long long float is mapped to double rather than long double, and then the attempts to import intrinsics for long double in Aux_Long_Long_Float raise warnings turned into errors. This patch is a work around for the mismatch, arranging for Aux_Long_Long_Float to map to Aux_Long_Float. for gcc/ada/ChangeLog * Makefile.rtl (LIBGNAT_TARGET_PAIRS): Use a-nallfl__wraplf.ads on aarch64-* and ppc*-linux-gnu targets. * libgnat/a-nallfl__wraplf.ads: New. --- gcc/ada/Makefile.rtl |6 ++ gcc/ada/libgnat/a-nallfl__wraplf.ads | 87 ++ 2 files changed, 93 insertions(+) create mode 100644 gcc/ada/libgnat/a-nallfl__wraplf.ads diff --git a/gcc/ada/Makefile.rtl b/gcc/ada/Makefile.rtl index 898eb5d..87ee3e9 100644 --- a/gcc/ada/Makefile.rtl +++ b/gcc/ada/Makefile.rtl @@ -1402,6 +1402,7 @@ ifeq ($(strip $(filter-out aarch64 arm% coff wrs vx%,$(target_cpu) $(target_vend VX=vxworks7 EH_MECHANISM=-gcc SIGTRAMP_OBJ=sigtramp-vxworks.o +LIBGNAT_TARGET_PAIRS += a-nallfl.adshttp://www.gnu.org/licenses/>. -- +-- -- +-- GNAT was originally developed by the GNAT team at New York University. -- +-- Extensive contributions were provided by Ada Core Technologies Inc. -- +-- -- +-- + +-- This package provides the basic computational interface for the +-- generic elementary functions. The functions in this unit are +-- wrappers for those in the Long Float package. + +with Ada.Numerics.Aux_Long_Float; + +package Ada.Numerics.Aux_Long_Long_Float is + pragma Pure; + + subtype T is Long_Long_Float; + package Aux renames Ada.Numerics.Aux_Long_Float; + subtype W is Aux.T; + + -- Use the Aux implementation. + + function Sin (X : T) return T + is (T (Aux.Sin (W (X; + + function Cos (X : T) return T + is (T (Aux.Cos (W (X; + + function Tan (X : T) return T + is (T (Aux.Tan (W (X; + + function Exp (X : T) return T + is (T (Aux.Exp (W (X; + + function Sqrt (X : T) return T + is (T (Aux.Sqrt (W (X; + + function Log (X : T) return T + is (T (Aux.Log (W (X; + + function Acos (X : T) return T + is (T (Aux.Acos (W (X; + + function Asin (X : T) return T + is (T (Aux.Asin (W (X; + + function Atan (X : T) return T + is (T (Aux.Atan (W (X; + + function Sinh (X : T) return T + is (T (Aux.Sinh (W (X; + + function Cosh (X : T) return T + is (T (Aux.Cosh (W (X; + + function Tanh (X : T) return T + is (T (Aux.Tanh (W (X; + + function Pow (X, Y : T) return T + is (T (Aux.Pow (W (X), W (Y; + +end Ada.Numerics.Aux_Long_Long_Float; -- Alexandre Oliva, happy hacker https://FSFLA.org/blogs/lxo/ Free Software Activist GNU Toolchain Engineer
Re: [Ada,FYI] revamp ada.numerics.aux
Hi Alexandre, > On Oct 19, 2020, Andreas Schwab wrote: > >> -nostdinc a-nallfl.ads -o a-nallfl.o >> a-nallfl.ads:48:13: warning: intrinsic binding type mismatch on return value >> a-nallfl.ads:48:13: warning: intrinsic binding type mismatch on argument 1 >> a-nallfl.ads:48:13: warning: profile of "Sin" doesn't match the builtin >> it binds > > Thanks for the report. Ada's Standard.Long_Long_Float is mapped to C > double rather than long double on this target. > > Here's a workaround, for aarch64-* and ppc*-linux-gnu, where I've > observed the mismatch so far. your patch similarly broke sparc*-sun-solaris* bootstrap. The attached snippet on top of this workaround fixes that. Rainer -- - Rainer Orth, Center for Biotechnology, Bielefeld University diff --git a/gcc/ada/Makefile.rtl b/gcc/ada/Makefile.rtl --- a/gcc/ada/Makefile.rtl +++ b/gcc/ada/Makefile.rtl @@ -1466,6 +1468,7 @@ endif ifeq ($(strip $(filter-out sparc% sun solaris%,$(target_cpu) $(target_vendor) $(target_os))),) LIBGNAT_TARGET_PAIRS = \ a-intnam.ads
Re: [Ada,FYI] revamp ada.numerics.aux
Hello, Andreas, On Oct 19, 2020, Andreas Schwab wrote: > -nostdinc a-nallfl.ads -o a-nallfl.o > a-nallfl.ads:48:13: warning: intrinsic binding type mismatch on return value > a-nallfl.ads:48:13: warning: intrinsic binding type mismatch on argument 1 > a-nallfl.ads:48:13: warning: profile of "Sin" doesn't match the builtin it > binds Thanks for the report. Ada's Standard.Long_Long_Float is mapped to C double rather than long double on this target. Here's a workaround, for aarch64-* and ppc*-linux-gnu, where I've observed the mismatch so far. I'm not sure whether we're going to use something like this, or a fix for the mismatch; I'm yet to figure out how to implement the latter. aarch64-* and ppc*-linux-gnu long long float/long double mismatch --- gcc/ada/Makefile.rtl |6 ++ gcc/ada/libgnat/a-nallfl__wraplf.ads | 87 ++ 2 files changed, 93 insertions(+) create mode 100644 gcc/ada/libgnat/a-nallfl__wraplf.ads diff --git a/gcc/ada/Makefile.rtl b/gcc/ada/Makefile.rtl index 2bc95db..6a83371e 100644 --- a/gcc/ada/Makefile.rtl +++ b/gcc/ada/Makefile.rtl @@ -1298,6 +1298,7 @@ ifeq ($(strip $(filter-out aarch64 arm% coff wrs vx%,$(target_cpu) $(target_vend VX=vxworks7 EH_MECHANISM=-gcc SIGTRAMP_OBJ=sigtramp-vxworks.o +LIBGNAT_TARGET_PAIRS += a-nallfl.adshttp://www.gnu.org/licenses/>. -- +-- -- +-- GNAT was originally developed by the GNAT team at New York University. -- +-- Extensive contributions were provided by Ada Core Technologies Inc. -- +-- -- +-- + +-- This package provides the basic computational interface for the +-- generic elementary functions. The functions in this unit are +-- wrappers for those in the Long Float package. + +with Ada.Numerics.Aux_Long_Float; + +package Ada.Numerics.Aux_Long_Long_Float is + pragma Pure; + + subtype T is Long_Long_Float; + package Aux renames Ada.Numerics.Aux_Long_Float; + subtype W is Aux.T; + + -- Use the Aux implementation. + + function Sin (X : T) return T + is (T (Aux.Sin (W (X; + + function Cos (X : T) return T + is (T (Aux.Cos (W (X; + + function Tan (X : T) return T + is (T (Aux.Tan (W (X; + + function Exp (X : T) return T + is (T (Aux.Exp (W (X; + + function Sqrt (X : T) return T + is (T (Aux.Sqrt (W (X; + + function Log (X : T) return T + is (T (Aux.Log (W (X; + + function Acos (X : T) return T + is (T (Aux.Acos (W (X; + + function Asin (X : T) return T + is (T (Aux.Asin (W (X; + + function Atan (X : T) return T + is (T (Aux.Atan (W (X; + + function Sinh (X : T) return T + is (T (Aux.Sinh (W (X; + + function Cosh (X : T) return T + is (T (Aux.Cosh (W (X; + + function Tanh (X : T) return T + is (T (Aux.Tanh (W (X; + + function Pow (X, Y : T) return T + is (T (Aux.Pow (W (X), W (Y; + +end Ada.Numerics.Aux_Long_Long_Float; -- Alexandre Oliva, happy hacker https://FSFLA.org/blogs/lxo/ Free Software Activist GNU Toolchain Engineer
Re: [Ada,FYI] revamp ada.numerics.aux
/opt/gcc/gcc-20201019/Build/./gcc/xgcc -B/opt/gcc/gcc-20201019/Build/./gcc/ -B/usr/aarch64-suse-linux/bin/ -B/usr/aarch64-suse-linux/lib/ -isystem /usr/aarch64-suse-linux/include -isystem /usr/aarch64-suse-linux/sys-include -c -g -O2 -fPIC -W -Wall -gnatpg -nostdinc a-nallfl.ads -o a-nallfl.o a-nallfl.ads:48:13: warning: intrinsic binding type mismatch on return value a-nallfl.ads:48:13: warning: intrinsic binding type mismatch on argument 1 a-nallfl.ads:48:13: warning: profile of "Sin" doesn't match the builtin it binds a-nallfl.ads:51:13: warning: intrinsic binding type mismatch on return value a-nallfl.ads:51:13: warning: intrinsic binding type mismatch on argument 1 a-nallfl.ads:51:13: warning: profile of "Cos" doesn't match the builtin it binds a-nallfl.ads:54:13: warning: intrinsic binding type mismatch on return value a-nallfl.ads:54:13: warning: intrinsic binding type mismatch on argument 1 a-nallfl.ads:54:13: warning: profile of "Tan" doesn't match the builtin it binds a-nallfl.ads:57:13: warning: intrinsic binding type mismatch on return value a-nallfl.ads:57:13: warning: intrinsic binding type mismatch on argument 1 a-nallfl.ads:57:13: warning: profile of "Exp" doesn't match the builtin it binds a-nallfl.ads:60:13: warning: intrinsic binding type mismatch on return value a-nallfl.ads:60:13: warning: intrinsic binding type mismatch on argument 1 a-nallfl.ads:60:13: warning: profile of "Sqrt" doesn't match the builtin it binds a-nallfl.ads:63:13: warning: intrinsic binding type mismatch on return value a-nallfl.ads:63:13: warning: intrinsic binding type mismatch on argument 1 a-nallfl.ads:63:13: warning: profile of "Log" doesn't match the builtin it binds a-nallfl.ads:66:13: warning: intrinsic binding type mismatch on return value a-nallfl.ads:66:13: warning: intrinsic binding type mismatch on argument 1 a-nallfl.ads:66:13: warning: profile of "Acos" doesn't match the builtin it binds a-nallfl.ads:69:13: warning: intrinsic binding type mismatch on return value a-nallfl.ads:69:13: warning: intrinsic binding type mismatch on argument 1 a-nallfl.ads:69:13: warning: profile of "Asin" doesn't match the builtin it binds a-nallfl.ads:72:13: warning: intrinsic binding type mismatch on return value a-nallfl.ads:72:13: warning: intrinsic binding type mismatch on argument 1 a-nallfl.ads:72:13: warning: profile of "Atan" doesn't match the builtin it binds a-nallfl.ads:75:13: warning: intrinsic binding type mismatch on return value a-nallfl.ads:75:13: warning: intrinsic binding type mismatch on argument 1 a-nallfl.ads:75:13: warning: profile of "Sinh" doesn't match the builtin it binds a-nallfl.ads:78:13: warning: intrinsic binding type mismatch on return value a-nallfl.ads:78:13: warning: intrinsic binding type mismatch on argument 1 a-nallfl.ads:78:13: warning: profile of "Cosh" doesn't match the builtin it binds a-nallfl.ads:81:13: warning: intrinsic binding type mismatch on return value a-nallfl.ads:81:13: warning: intrinsic binding type mismatch on argument 1 a-nallfl.ads:81:13: warning: profile of "Tanh" doesn't match the builtin it binds a-nallfl.ads:84:13: warning: intrinsic binding type mismatch on return value a-nallfl.ads:84:13: warning: intrinsic binding type mismatch on argument 1 a-nallfl.ads:84:13: warning: profile of "Pow" doesn't match the builtin it binds make[7]: *** [../gcc-interface/Makefile:302: a-nallfl.o] Error 1 Andreas. -- Andreas Schwab, sch...@linux-m68k.org GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different."
[Ada,FYI] revamp ada.numerics.aux
Instead of mapping elementary functions for all types to a single type, use the intrinsics available for the various base types. A new Ada.Numerics.Aux_Generic_Float is introduced to explicitly dispatch, based on the 'Digits attribute of the base type, to the various newly-added Aux_Short_Float, Aux_Float, Aux_Long_Float, or Aux_Long_Long_Float. The Aux_Short_Float unit is implemented in terms of the Aux_Float one, and the others rely on the elementary functions from the C Math library for float, double and long double types, respectively. An Aux_Linker_Options is added, and units that import intrinsics from libm/libc depend on it to provide the "-lm" linker option if needed. The option is provided by default, but there is an alternate version that doesn't, that is used for vxworks targets. The Aux variant that used to open-code Sin and Cos for the ancient ppc-darwin, because of insufficient precision in libc, is dropped, along with the alternate dummy body for Aux. Both are presumed no longer needed. The original Ada.Numerics.Aux is retained, for backward compatibility, as a wrapper for a newly-added Aux_Compat, that renames Aux_Long_Float, except on x86, in which an alternate version renames Aux_Long_Long_Float. Generic_Elementary_Functions and Generic_Complex_Types are adjusted to use Aux_Generic_Float, avoiding the type conversions and inefficiencies of computing results in higher precision than requested. Generic_Complex_Elementary_Functions is adjusted to enable an additional instance of the sincos optimization, even without -gnatn. Regstrapped on x86_64-linux-gnu, also tested wiht various other targets. Approved by Arno. Installing. for gcc/ada/ChangeLog * Makefile.rtl (GNATRTL_NONTASKING_OBJS): Compile Ada.Numerics child units Aux_Generic_Float, Aux_Long_Long_Float, Aux_Long_Float, Aux_Float, Aux_Short_Float, Aux_Compat, and Aux_Linker_Options. (X86_TARGET_PAIRS): Drop dummy body for Aux. Use x86 version of Aux_Compat. (X86_64_TARGET_PAIRS): Likewise. (LIBGNAT_TARGET_PAIRS): On VxWorks, select the nolibm variants. Drop the darwin version of Aux. Drop the redundant libc-x86 numaux variants on x86* kfreebsd variants. * libgnat/a-nagefl.ads: New Aux_Generic_Float. * libgnat/a-naliop.ads: New Aux_Linker_Options. * libgnat/a-naliop__nolibm.ads: New. * libgnat/a-nallfl.ads: New Aux_Long_Long_Float. * libgnat/a-nalofl.ads: New Aux_Long_Float. * libgnat/a-nuaufl.ads: New Aux_Float. * libgnat/a-nashfl.ads: New Aux_Short_Float. * libgnat/a-ngcefu.ads (Exp): Factor out the Im (X) passed to Sin and Cos in the Complex variant too. * libgnat/a-ngcoty.adb: Switch to Aux_Generic_Float. Drop redundant conversions. * libgnat/a-ngelfu.adb: Likewise. * libgnat/a-nuauco.ads: New Aux_Compat. * libgnat/a-nuauco__x86.ads: New. * libgnat/a-numaux.ads: Replace with Compat wrapper. * libgnat/a-numaux__darwin.adb: Remove. * libgnat/a-numaux__darwin.ads: Remove. * libgnat/a-numaux__dummy.adb: Remove. * libgnat/a-numaux__libc-x86.ads: Remove. * libgnat/a-numaux__vxworks.ads: Remove. --- gcc/ada/Makefile.rtl | 27 ++-- gcc/ada/libgnat/a-nagefl.ads | 171 ++ gcc/ada/libgnat/a-naliop.ads | 45 +++ gcc/ada/libgnat/a-naliop__nolibm.ads | 43 +++ gcc/ada/libgnat/a-nallfl.ads | 87 + gcc/ada/libgnat/a-nalofl.ads | 87 + gcc/ada/libgnat/a-nashfl.ads | 87 + gcc/ada/libgnat/a-ngcefu.adb |5 - gcc/ada/libgnat/a-ngcoty.adb | 34 +++-- gcc/ada/libgnat/a-ngelfu.adb | 39 +++--- gcc/ada/libgnat/a-nuauco.ads | 40 ++ gcc/ada/libgnat/a-nuauco__x86.ads | 39 ++ gcc/ada/libgnat/a-nuaufl.ads | 87 + gcc/ada/libgnat/a-numaux.ads | 94 +- gcc/ada/libgnat/a-numaux__darwin.adb | 211 gcc/ada/libgnat/a-numaux__darwin.ads | 103 gcc/ada/libgnat/a-numaux__dummy.adb| 32 - gcc/ada/libgnat/a-numaux__libc-x86.ads | 97 --- gcc/ada/libgnat/a-numaux__vxworks.ads | 97 --- 19 files changed, 773 insertions(+), 652 deletions(-) create mode 100644 gcc/ada/libgnat/a-nagefl.ads create mode 100644 gcc/ada/libgnat/a-naliop.ads create mode 100644 gcc/ada/libgnat/a-naliop__nolibm.ads create mode 100644 gcc/ada/libgnat/a-nallfl.ads create mode 100644 gcc/ada/libgnat/a-nalofl.ads create mode 100644 gcc/ada/libgnat/a-nashfl.ads create mode 100644 gcc/ada/libgnat/a-nuauco.ads create mode 100644 gcc/ada/libgnat/a-nuauco__x86.ads create mode 100644 gcc/ada/libgnat/a-nuaufl.ads delete mode 100644 gcc/ada/libgnat/a-numaux__darwin.adb delete mode 100644