Re: [PATCH 1/3] PowerPC: Add long double target-supports.

2021-02-23 Thread Michael Meissner via Gcc-patches
On Fri, Jan 15, 2021 at 06:16:43PM +, Joseph Myers wrote:
> On Thu, 14 Jan 2021, Michael Meissner via Gcc-patches wrote:
> 
> > +return [check_runtime_nocache ppc_long_double_ovveride_ibm128 {
> 
> > +return [check_runtime_nocache ppc_long_double_ovveride_ieee128 {
> 
> > +return [check_runtime_nocache ppc_long_double_ovveride_64bit {
> 
> All these places have the typo "ovveride".

Thanks.  I have fixed these in the next version of the patch.

-- 
Michael Meissner, IBM
IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA
email: meiss...@linux.ibm.com, phone: +1 (978) 899-4797


Re: [PATCH 1/3] PowerPC: Add long double target-supports.

2021-01-15 Thread Joseph Myers
On Thu, 14 Jan 2021, Michael Meissner via Gcc-patches wrote:

> +return [check_runtime_nocache ppc_long_double_ovveride_ibm128 {

> +return [check_runtime_nocache ppc_long_double_ovveride_ieee128 {

> +return [check_runtime_nocache ppc_long_double_ovveride_64bit {

All these places have the typo "ovveride".

-- 
Joseph S. Myers
jos...@codesourcery.com


Re: [PATCH 1/3] PowerPC: Add long double target-supports.

2020-12-14 Thread Segher Boessenkool
On Thu, Dec 03, 2020 at 11:06:12PM -0500, Michael Meissner wrote:
> +proc check_effective_target_ppc_long_double_ibm { } {
> +return [check_cached_effective_target ppc_long_double_ibm {
> + int main()
> + {
> +   #if !defined(_ARCH_PPC) || !defined(__LONG_DOUBLE_IBM128__)
> + return 1;
> +   #else
> + return 0;
> +   #endif
> + }
> +}]
> +}

OK.

> +proc check_effective_target_ppc_long_double_ieee { } {
> +return [check_cached_effective_target ppc_long_double_ieee {
> + int main()
> + {
> +   #if !defined(_ARCH_PPC) || !defined(__LONG_DOUBLE_IEEE128__)
> + return 1;
> +   #else
> + return 0;
> +   #endif
> + }
> +}]
> +}

OK.

These names could be without "_ppc", if the functions were defined more
generically.  It's not clear that will be useful right now though.

> +# Like check_effective_target_ppc_long_double_ibm, but check if we can
> +# explicitly override the long double format to use the IBM 128-bit extended
> +# double format, and GLIBC supports doing this override by switching the
> +# sprintf to handle long double.

This comment needs work.

> +proc check_effective_target_ppc_long_double_override_ibm { } {
> +set options "-mlong-double-128 -mabi=ibmlongdouble -Wno-psabi"
> +check_runtime_nocache ppc_long_double_ovveride_ibm {

It is spelled "override".

> + #include 
> + #include 
> + volatile __ibm128 a = (__ibm128) 3.0;
> + volatile long double one = 1.0L;
> + volatile long double two = 2.0L;
> + volatile long double b;
> + char buffer[20];
> + int main()
> + {
> +   #if !defined(_ARCH_PPC) || !defined(__LONG_DOUBLE_IBM128__)
> + return 1;
> +   #else
> + b = one + two;
> + if (memcmp ((void *)&a, (void *)&b, sizeof (long double)) != 0)

The pointer casts are unnecessary, and can be harmful.

You should use  sizeof(b)  , and check that  sizeof(a) == sizeof(b)  .

> +   return 1;
> + sprintf (buffer, "%lg", b);
> + return strcmp (buffer, "3") != 0;
> +   #endif
> + }
> +} $options
> +}

The name of this should say it is something to do with libc, or even
glibc in fact ("lg" is not portable), and with text output.

> +# Like check_effective_target_ppc_long_double_ieee, but check if we can
> +# explicitly override the long double format to use the IEEE 128-bit format,
> +# and GLIBC supports doing this override by switching the sprintf to handle
> +# long double.
> +
> +proc check_effective_target_ppc_long_double_override_ieee { } {
> +set options "-mlong-double-128 -mabi=ieeelongdouble -Wno-psabi"
> +check_runtime_nocache ppc_long_double_ovveride_ieee {
> + #include 
> + #include 
> + volatile _Float128 a = 3.0f128;
> + volatile long double one = 1.0L;
> + volatile long double two = 2.0L;
> + volatile long double b;
> + char buffer[20];
> + int main()
> + {
> +   #if !defined(_ARCH_PPC) || !defined(__LONG_DOUBLE_IEEE128__)
> + return 1;
> +   #else
> + b = one + two;
> + if (memcmp ((void *)&a, (void *)&b, sizeof (long double)) != 0)
> +   return 1;
> + sprintf (buffer, "%lg", b);
> + return strcmp (buffer, "3") != 0;
> +   #endif
> + }
> +} $options
> +}

Ditto.

> +# See if the target is a powerpc with the long double format that is 
> 128-bits.
> +
> +proc check_effective_target_ppc_long_double_128bit { } {
> +return [check_cached_effective_target ppc_long_double_128bit {
> + int main()
> + {
> +   #ifndef _ARCH_PPC
> + return 1;
> +   #else
> + return sizeof (long double) != 16;
> + #endif
> + }
> +}]
> +}

In this case checking for PowerPC seems a really bad design: this is
obviously exactly the same on any architecture.

> +proc check_effective_target_ppc_long_double_64bit { } {
> +return [check_cached_effective_target ppc_long_double_64bit {
> + int main()
> + {
> +   #ifndef _ARCH_PPC
> + return 1;
> +   #else
> + return sizeof (long double) != 8;
> +   #endif
> + }
> +}]
> +}

Ditto.


Segher


Re: [PATCH 1/3] PowerPC: Add long double target-supports.

2020-11-24 Thread Segher Boessenkool
On Tue, Nov 24, 2020 at 04:44:19PM -0500, Michael Meissner wrote:
> On Mon, Nov 23, 2020 at 02:28:57PM -0600, Segher Boessenkool wrote:
> > On Sat, Nov 21, 2020 at 12:33:52AM -0500, Michael Meissner wrote:
> > > +# See if the target is a powerpc with the long double format that uses 
> > > the IBM
> > > +# extended double format.
> > 
> > "Return 1 if the target is PowerPC, and long double is IBM extended double."
> > 
> > > @@ -7939,6 +7992,9 @@ proc is-effective-target { arg } {
> > > "power10_hw" { set selected [check_power10_hw_available] }
> > > "ppc_float128_sw" { set selected [check_ppc_float128_sw_available] }
> > > "ppc_float128_hw" { set selected [check_ppc_float128_hw_available] }
> > > +   "ppc_long_double_ibm" { set selected [check_ppc_long_double_ibm] }
> > > +   "ppc_long_double_ieee" { set selected [check_ppc_long_double_ieee] }
> > > +   "ppc_long_double_64bit" { set selected [check_ppc_long_double_64bit] }
> > > "ppc_recip_hw"   { set selected [check_ppc_recip_hw_available] }
> > > "ppc_cpu_supports_hw" { set selected 
> > > [check_ppc_cpu_supports_hw_available] }
> > > "ppc_mma_hw" { set selected [check_ppc_mma_hw_available] }
> > 
> > Why this?  It just defines aliases to the exact same name?
> 
> If you remove those lines you get the failure from the default case:
> 
> default  { error "unknown effective target keyword `$arg'" }

So name the functions check_effective_target_ppc_long_double_ibm etc.?
Then it is all handled by the generic code, and yes you can use these
same names in the testcases.


Segher


Re: [PATCH 1/3] PowerPC: Add long double target-supports.

2020-11-24 Thread Michael Meissner via Gcc-patches
On Mon, Nov 23, 2020 at 02:28:57PM -0600, Segher Boessenkool wrote:
> Hi!
> 
> On Sat, Nov 21, 2020 at 12:33:52AM -0500, Michael Meissner wrote:
> > +# See if the target is a powerpc with the long double format that uses the 
> > IBM
> > +# extended double format.
> 
> "Return 1 if the target is PowerPC, and long double is IBM extended double."
> 
> > @@ -7939,6 +7992,9 @@ proc is-effective-target { arg } {
> >   "power10_hw" { set selected [check_power10_hw_available] }
> >   "ppc_float128_sw" { set selected [check_ppc_float128_sw_available] }
> >   "ppc_float128_hw" { set selected [check_ppc_float128_hw_available] }
> > + "ppc_long_double_ibm" { set selected [check_ppc_long_double_ibm] }
> > + "ppc_long_double_ieee" { set selected [check_ppc_long_double_ieee] }
> > + "ppc_long_double_64bit" { set selected [check_ppc_long_double_64bit] }
> >   "ppc_recip_hw"   { set selected [check_ppc_recip_hw_available] }
> >   "ppc_cpu_supports_hw" { set selected 
> > [check_ppc_cpu_supports_hw_available] }
> >   "ppc_mma_hw" { set selected [check_ppc_mma_hw_available] }
> 
> Why this?  It just defines aliases to the exact same name?

If you remove those lines you get the failure from the default case:

  default  { error "unknown effective target keyword `$arg'" }

-- 
Michael Meissner, IBM
IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA
email: meiss...@linux.ibm.com, phone: +1 (978) 899-4797


Re: [PATCH 1/3] PowerPC: Add long double target-supports.

2020-11-23 Thread Segher Boessenkool
Hi!

On Sat, Nov 21, 2020 at 12:33:52AM -0500, Michael Meissner wrote:
> +# See if the target is a powerpc with the long double format that uses the 
> IBM
> +# extended double format.

"Return 1 if the target is PowerPC, and long double is IBM extended double."

> @@ -7939,6 +7992,9 @@ proc is-effective-target { arg } {
> "power10_hw" { set selected [check_power10_hw_available] }
> "ppc_float128_sw" { set selected [check_ppc_float128_sw_available] }
> "ppc_float128_hw" { set selected [check_ppc_float128_hw_available] }
> +   "ppc_long_double_ibm" { set selected [check_ppc_long_double_ibm] }
> +   "ppc_long_double_ieee" { set selected [check_ppc_long_double_ieee] }
> +   "ppc_long_double_64bit" { set selected [check_ppc_long_double_64bit] }
> "ppc_recip_hw"   { set selected [check_ppc_recip_hw_available] }
> "ppc_cpu_supports_hw" { set selected 
> [check_ppc_cpu_supports_hw_available] }
> "ppc_mma_hw" { set selected [check_ppc_mma_hw_available] }

Why this?  It just defines aliases to the exact same name?


Segher