On Thu, Aug 05, 2021 at 12:19:37PM -0600, Sandra Loosemore wrote: > On 8/5/21 11:33 AM, Michael Meissner wrote: > >At the moment, we only fully support C and C++ when changing the long double > >format (between IEEE 128-bit, IBM 128-bit, and 64-bit) when the compiler is > >invoked (and assuming you are using GLIBC 2.32 or newer). > > > >For Fortran and the other languages, the only way to change the floating > >point > >format is to configure the compiler with the '--with-long-double-format=ieee' > >configuration option. This makes TFmode use IEEE 128-bit floating point > >instead of IBM 128-bit floating point. > > My understanding from reading the code is is that for GNU/Linux > targets, PowerPC already defaults to the IEEE format for TFmode? > I'm not sure what targets the IBM format might be the default on.
All PowerPC systems that I'm aware of that use 128-bit floating point use the IBM format. It is anticipated that one or more Linux distributions in the future may move to IEEE 128-bit format, but right now, I'm not aware that any have moved. > >It would take somebody familar with the Fortran front end and libraries to > >make > >the same sort of modifications that were made for the C and C++ languages. > >Basically you need build libgfortran so that it has support for both floating > >point formats, using different names. You would need to modify the fortran > >front end to call the alternate functions when the switch is used to change > >the > >floating point format. It might be nice to have a Fortran specific way to > >specify which of the two floating point formats are used for REAL*16 (similar > >to the use of __float128 and __ibm128 in C/C++, and also _Float128 in just > >C). > > > >If you are going to do it, good luck. > > Well, I am actually not at all interested in doing that. My > questions for the PowerPC experts are: > > (1) When is the __float128 type defined, and which format does it > specify? Is it always the IEEE format, or does it specify the same > format as TFmode/long double? __float128 (and _Float128 in C) is always IEEE 128-bit, if IEEE 128-bit is supported. By default, IEEE 128-bit is only supported on little endian PowerPC 64-bit systems. For C (but not C++), you can declare constants with the f128 suffix so that they would be compatible with the _Float128 type. > > (2) If __float128 is not always the same 128-bit format as > TFmode/long double, how can I detect that in the Fortran front end > in a target-independent way? Is it possible without adding a new > target hook? You can look at the constants in float.h: For a system with IBM long double: FLT_RADIX = 2 LDBL_MANT_DIG = 106 LDBL_DIG = 31 LDBL_MIN_EXP = -968 LDBL_MIN_10_EXP = -291 LDBL_MAX_EXP = 1024 LDBL_MAX_10_EXP = 308 For a system with IEEE long double: FLT_RADIX = 2 LDBL_MANT_DIG = 113 LDBL_DIG = 33 LDBL_MIN_EXP = -16381 LDBL_MIN_10_EXP = -4931 LDBL_MAX_EXP = 16384 LDBL_MAX_10_EXP = 4932 For a system that uses 64-bit numbers for long double: FLT_RADIX = 2 LDBL_MANT_DIG = 53 LDBL_DIG = 15 LDBL_MIN_EXP = -1021 LDBL_MIN_10_EXP = -307 LDBL_MAX_EXP = 1024 LDBL_MAX_10_EXP = 308 In addition, the PowerPC GCC defines __LONG_DOUBLE_IEEE128__ if long double is IEEE 128-bit, and __LONG_DOUBLE_IBM128__ if long double IBM 128-bit. If long double is 64-bit, the macro __LONG_DOUBLE_128__ is not defined. > (3) Can we do anything about the "Additional Floating Types" section > in extend.texi? It's not clear on the answer to (1), and I think > the stuff about "future versions of GCC" is bit-rotten as it goes > back to at least GCC 6. (Either it's been implemented by now, or > the idea was discarded.) > > Basically, I want the Fortran front end to define c_float128 to 16 > if C supports __float128 and it corresponds to TFmode, otherwise it > ought to continue to define c_float128 to -4. I do not want to make > the Fortran front end support multiple 128-bit encodings at the same > time, just accurately define c_float128. -- 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