Re: [PATCH] Add conversions between _Float128 and Decimal.
On Fri, Jan 29, 2021 at 03:45:49PM -0600, will schmidt wrote: > On Thu, 2021-01-28 at 21:42 -0500, Michael Meissner via Gcc-patches wrote: > > [PATCH] Add conversions between _Float128 and Decimal. > > > > Hi, > Just a couple cosmetic nits in the description. The changelog seems to > match that patch contents OK. > > > > This patch implements conversions between _Float128 and the 3 Decimal > > floating types. It does by extendending the dfp-bit conversions to add a > > nit: 'does so' or 'does this' > > > new binary floating point type (KF), and doing the conversions in the same > > mannor as the other binary/decimal conversions. > > manner. > > > > > In particular for conversions from _Float128 to Decimal, it uses a sprintf > > variant to convert _Float128 to strings, and a type specific function that > > converts the string output to the appropriate Decimal type > > > > For conversions from one of the Decimal types to _Float128, it uses a > > decimal > > function to convert to string (i.e. __decimalToString), and then uses a > > variant of strtold to convert to _Float128. > > > Are the sprintf and strtold functions called actually variants? Normally sprintf and strtold are used for converting between binary and decimal floating point types. With these patches, when you are converting _Float128 to Decimal, __sprintfkf is used instead of sprintf. When you are converting Decimal to _Float128, __strtokf is used instead of strtold. These two functions handle checking whether GLIBC 2.32 or newer was used and if so, it calls __sprintfieee128 or __strtoieee128 respectively. If GLIBC 2.31 or earlier was used, then it does the conversion between __ibm128 and _Float128 to do the conversion. > Other source files in libgcc/config appear to have the copyright range > starting at a later date, presumably when the file was created. > So.. I think this should be Copyright (C) 2021 FSF Well they were initially cloned from other files, so I kept the long copyright date. But I could use just 2021. -- 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] Add conversions between _Float128 and Decimal.
On Thu, 2021-01-28 at 21:42 -0500, Michael Meissner via Gcc-patches wrote: > [PATCH] Add conversions between _Float128 and Decimal. > Hi, Just a couple cosmetic nits in the description. The changelog seems to match that patch contents OK. > This patch implements conversions between _Float128 and the 3 Decimal > floating types. It does by extendending the dfp-bit conversions to add a nit: 'does so' or 'does this' > new binary floating point type (KF), and doing the conversions in the same > mannor as the other binary/decimal conversions. manner. > > In particular for conversions from _Float128 to Decimal, it uses a sprintf > variant to convert _Float128 to strings, and a type specific function that > converts the string output to the appropriate Decimal type > > For conversions from one of the Decimal types to _Float128, it uses a decimal > function to convert to string (i.e. __decimalToString), and then uses a > variant of strtold to convert to _Float128. Are the sprintf and strtold functions called actually variants? > > If the user is linked against GLIBC 2.32 or newer, then the sprintf and > strtold > variant functions can use the features directly in GLIBC 2.32 to do this > conversion. > > If you have an older GLIBC and want to convert _Float128 to one of the Decimal > types, it will convert the _Float128 to __ibm128 and then convert that to > Decimal. > > Similarly if you have one of the Decimal types, and want to convert to > _Float128, it will first convert the Decimal type to __ibm128, and then > convert > __ibm128 to _Float128. > > These functions will primarily be used if/when the default PowerPC long double > type is changed to IEEE 128-bit, but they could also be used if the user > explicitly converts _Float128 to/from a Decimal type. > > One test case relating to Decimal fails if I build a compiler where the > default > is IEEE 128-bit: > > * c-c++-common/dfp/convert-bfp-11.c > > I have patches for this test, and they have been submitted separately. ok > > I have tested this patch by doing builds, bootstraps, and make check with 3 > builds on a power9 little endian server: > > * Build one used the default long double being IBM 128-bit; > * Build two set the long double default to IEEE 128-bit; (and) > * Build three set the long double default to 64-bit. > > The compilers built fine providing I recompiled gmp, mpc, and mpfr with the > appropriate long double options. There were a few differences in the test > suite runs that will be addressed in later patches, but over all it works > well. This patch is required to be able to build a toolchain where the > default > long double is IEEE 128-bit. > Can I check this patch into the master branch > for > GCC 11? Separate the check-in question from the description paragraph. > > I have also built compilers with this patch on a big endian power8 system that > has both 32-bit and 64-bit support. There were no regressions in running > these > tests on the system. > > Can I check this patch into the master branch? > > libgcc/ > 2021-01-28 Michael Meissner > > * config/rs6000/_dd_to_kf.c: New file. > * config/rs6000/_kf_to_dd.c: New file. > * config/rs6000/_kf_to_sd.c: New file. > * config/rs6000/_kf_to_td.c: New file. > * config/rs6000/_sd_to_kf.c: New file. > * config/rs6000/_sprintfkf.c: New file. > * config/rs6000/_sprintfkf.h: New file. > * config/rs6000/_strtokf.h: New file. > * config/rs6000/_strtokf.c: New file. > * config/rs6000/_td_to_kf.c: New file. > * config/rs6000/quad-float128.h: Add new declarations. > * config/rs6000/t-float128 (fp128_dec_funcs): New macro. > (fp128_decstr_funcs): New macro. > (ibm128_dec_funcs): New macro. > (fp128_ppc_funcs): Add the new conversions. > (fp128_dec_objs): Force Decimal <-> __float128 conversions to be > compiled with -mabi=ieeelongdouble. > (fp128_decstr_objs): Force __float128 <-> string conversions to be > compiled with -mabi=ibmlongdouble. > (ibm128_dec_objs): Force Decimal <-> __float128 conversions to be > compiled with -mabi=ieeelongdouble. > (FP128_CFLAGS_DECIMAL): New macro. > (IBM128_CFLAGS_DECIMAL): New macro. > * dfp-bit.c (DFP_TO_BFP): Add PowerPC _Float128 support. > (BFP_TO_DFP): Add PowerPC _Float128 support. > * dfp-bit.h (BFP_KIND): Add new binary floating point kind for > IEEE 128-bit floating point. > (DFP_TO_BFP): Add PowerPC _Float128 support. > (BFP_TO_DFP): Add PowerPC _Float128
[PATCH] Add conversions between _Float128 and Decimal.
[PATCH] Add conversions between _Float128 and Decimal. This patch implements conversions between _Float128 and the 3 Decimal floating types. It does by extendending the dfp-bit conversions to add a new binary floating point type (KF), and doing the conversions in the same mannor as the other binary/decimal conversions. In particular for conversions from _Float128 to Decimal, it uses a sprintf variant to convert _Float128 to strings, and a type specific function that converts the string output to the appropriate Decimal type For conversions from one of the Decimal types to _Float128, it uses a decimal function to convert to string (i.e. __decimalToString), and then uses a variant of strtold to convert to _Float128. If the user is linked against GLIBC 2.32 or newer, then the sprintf and strtold variant functions can use the features directly in GLIBC 2.32 to do this conversion. If you have an older GLIBC and want to convert _Float128 to one of the Decimal types, it will convert the _Float128 to __ibm128 and then convert that to Decimal. Similarly if you have one of the Decimal types, and want to convert to _Float128, it will first convert the Decimal type to __ibm128, and then convert __ibm128 to _Float128. These functions will primarily be used if/when the default PowerPC long double type is changed to IEEE 128-bit, but they could also be used if the user explicitly converts _Float128 to/from a Decimal type. One test case relating to Decimal fails if I build a compiler where the default is IEEE 128-bit: * c-c++-common/dfp/convert-bfp-11.c I have patches for this test, and they have been submitted separately. I have tested this patch by doing builds, bootstraps, and make check with 3 builds on a power9 little endian server: * Build one used the default long double being IBM 128-bit; * Build two set the long double default to IEEE 128-bit; (and) * Build three set the long double default to 64-bit. The compilers built fine providing I recompiled gmp, mpc, and mpfr with the appropriate long double options. There were a few differences in the test suite runs that will be addressed in later patches, but over all it works well. This patch is required to be able to build a toolchain where the default long double is IEEE 128-bit. Can I check this patch into the master branch for GCC 11? I have also built compilers with this patch on a big endian power8 system that has both 32-bit and 64-bit support. There were no regressions in running these tests on the system. Can I check this patch into the master branch? libgcc/ 2021-01-28 Michael Meissner * config/rs6000/_dd_to_kf.c: New file. * config/rs6000/_kf_to_dd.c: New file. * config/rs6000/_kf_to_sd.c: New file. * config/rs6000/_kf_to_td.c: New file. * config/rs6000/_sd_to_kf.c: New file. * config/rs6000/_sprintfkf.c: New file. * config/rs6000/_sprintfkf.h: New file. * config/rs6000/_strtokf.h: New file. * config/rs6000/_strtokf.c: New file. * config/rs6000/_td_to_kf.c: New file. * config/rs6000/quad-float128.h: Add new declarations. * config/rs6000/t-float128 (fp128_dec_funcs): New macro. (fp128_decstr_funcs): New macro. (ibm128_dec_funcs): New macro. (fp128_ppc_funcs): Add the new conversions. (fp128_dec_objs): Force Decimal <-> __float128 conversions to be compiled with -mabi=ieeelongdouble. (fp128_decstr_objs): Force __float128 <-> string conversions to be compiled with -mabi=ibmlongdouble. (ibm128_dec_objs): Force Decimal <-> __float128 conversions to be compiled with -mabi=ieeelongdouble. (FP128_CFLAGS_DECIMAL): New macro. (IBM128_CFLAGS_DECIMAL): New macro. * dfp-bit.c (DFP_TO_BFP): Add PowerPC _Float128 support. (BFP_TO_DFP): Add PowerPC _Float128 support. * dfp-bit.h (BFP_KIND): Add new binary floating point kind for IEEE 128-bit floating point. (DFP_TO_BFP): Add PowerPC _Float128 support. (BFP_TO_DFP): Add PowerPC _Float128 support. (BFP_SPRINTF): New macro. --- libgcc/config/rs6000/_dd_to_kf.c | 37 ++ libgcc/config/rs6000/_kf_to_dd.c | 37 ++ libgcc/config/rs6000/_kf_to_sd.c | 37 ++ libgcc/config/rs6000/_kf_to_td.c | 37 ++ libgcc/config/rs6000/_sd_to_kf.c | 37 ++ libgcc/config/rs6000/_sprintfkf.c| 57 libgcc/config/rs6000/_sprintfkf.h| 28 ++ libgcc/config/rs6000/_strtokf.c | 56 +++ libgcc/config/rs6000/_strtokf.h | 27 + libgcc/config/rs6000/_td_to_kf.c | 37 ++ libgcc/config/rs6000/quad-float128.h | 8 libgcc/config/rs6000/t-float128 | 37 +- libgcc/dfp-bit.c | 12 +-