From patchwork Thu Mar 4 21:01:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Meissner X-Patchwork-Id: 1447498 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=jcy2thn8; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Ds3Fq2HY1z9sPf for ; Fri, 5 Mar 2021 08:01:49 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 215963854829; Thu, 4 Mar 2021 21:01:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 215963854829 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1614891706; bh=UaNhXTdISR2YONWpPuL7cSIxqqNH1VKQMDKSHKdPWZo=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=jcy2thn8Ifu1VGxeNkjoIAYHuiaKvmI71cJOj7wm5t4RXzMf5lsVxW4fTzhKGTmhN HQmr4mv2RHPAb9k3RStVJrtAnol5RgqeTFcthy2swBb3gk33iBzt1iR9Br4M5FGv82 Zvps2faAhRBuJMCCRfiyxbeZjQfpBVuh6tlZUWws= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 76E973857C50 for ; Thu, 4 Mar 2021 21:01:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 76E973857C50 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 124KqkJQ056606; Thu, 4 Mar 2021 16:01:40 -0500 Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3736yq87cb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Mar 2021 16:01:40 -0500 Received: from m0098413.ppops.net (m0098413.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 124KtJk2068676; Thu, 4 Mar 2021 16:01:39 -0500 Received: from ppma04wdc.us.ibm.com (1a.90.2fa9.ip4.static.sl-reverse.com [169.47.144.26]) by mx0b-001b2d01.pphosted.com with ESMTP id 3736yq87c3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Mar 2021 16:01:39 -0500 Received: from pps.filterd (ppma04wdc.us.ibm.com [127.0.0.1]) by ppma04wdc.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 124KwIZ1032574; Thu, 4 Mar 2021 21:01:39 GMT Received: from b01cxnp22034.gho.pok.ibm.com (b01cxnp22034.gho.pok.ibm.com [9.57.198.24]) by ppma04wdc.us.ibm.com with ESMTP id 3712pj1yqf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Mar 2021 21:01:39 +0000 Received: from b01ledav001.gho.pok.ibm.com (b01ledav001.gho.pok.ibm.com [9.57.199.106]) by b01cxnp22034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 124L1cIj33554726 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 4 Mar 2021 21:01:38 GMT Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8F11128066; Thu, 4 Mar 2021 21:01:38 +0000 (GMT) Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1D5CC28059; Thu, 4 Mar 2021 21:01:36 +0000 (GMT) Received: from ibm-toto.the-meissners.org (unknown [9.65.200.124]) by b01ledav001.gho.pok.ibm.com (Postfix) with ESMTPS; Thu, 4 Mar 2021 21:01:36 +0000 (GMT) Date: Thu, 4 Mar 2021 16:01:35 -0500 To: gcc-patches@gcc.gnu.org, Michael Meissner , Segher Boessenkool , David Edelsohn , Bill Schmidt , Peter Bergner , Joseph Myers Subject: [PATCH, V3] Require GLIBC 2.32 for Decimal/_Float128 conversions. Message-ID: <20210304210135.GA32076@ibm-toto.the-meissners.org> Mail-Followup-To: Michael Meissner , gcc-patches@gcc.gnu.org, Segher Boessenkool , David Edelsohn , Bill Schmidt , Peter Bergner , Joseph Myers MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369, 18.0.761 definitions=2021-03-04_08:2021-03-03, 2021-03-04 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 mlxlogscore=999 spamscore=0 mlxscore=0 bulkscore=0 phishscore=0 clxscore=1015 priorityscore=1501 suspectscore=0 impostorscore=0 adultscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103040100 X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, KAM_MANYTO, KAM_SHORT, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Michael Meissner via Gcc-patches From: Michael Meissner Reply-To: Michael Meissner Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" [PATCH V3] Require GLIBC 2.32 for Decimal/_Float128 conversions. In the patch that I applied on March 2nd, I had code to provide support for Decimal/_Float128 conversions if the user did not use at least GLIBC 2.32. It did this by using __ibm128 as an intermediate type. The trouble is __ibm128 cannot represent all of the numbers that _Float128 can, and you lose if you do this conversion. This patch removes this support. The dfp-bit.c functions now call the the __sprintfieee128 and __strtoieee128 functions to do the conversion. If the user does not have GLIBC, they will get a linker error that these functions do not exist. The float128 support functions are only built into the static libgcc, so there isn't an issue with having references to __strtoieee128 and __sprintfieee128 with older GLIBC libraries. As an added bonus, this patch eliminates the __sprintfkf function which included stdio.h to get a definition for the sprintf library function. This allows for building cross compilers without having to have a target stdio.h available. I have built bootstrap compilers for power9 little endian systems with the three different long double formats (IBM 128-bit, IEEE 128-bit, and 64-bit) and there were no regressions from previous runs. I have also build bootstrap compilers on a big endian power8 and there was no regression there either. Can I check this patch into the master branch? libgcc/ 2021-03-04 Michael Meissner * config/rs6000/t-float128 (fp128_decstr_funcs): Delete. (fp128_ppc_funcs): Do not add $(fp128_decstr_funcs). (fp128_decstr_objs): Delete. * dfp-bit.h: Call __sprintfieee128 to do conversions from _Float128 to a Decimal type. Call __strtoieee128 to do conversions from a Decimal type to _Float128. * config/rs6000/_sprintfkf.c: Delete file. * config/rs6000/_sprintfkf.h: Delete file. * config/rs6000/_strtokf.c: Delete file. * config/rs6000/_strtokf.h: Delete file. --- libgcc/config/rs6000/_sprintfkf.c | 58 ------------------------------- libgcc/config/rs6000/_sprintfkf.h | 27 -------------- libgcc/config/rs6000/_strtokf.c | 53 ---------------------------- libgcc/config/rs6000/_strtokf.h | 27 -------------- libgcc/config/rs6000/t-float128 | 13 +------ libgcc/dfp-bit.h | 8 ++--- 6 files changed, 5 insertions(+), 181 deletions(-) delete mode 100644 libgcc/config/rs6000/_sprintfkf.c delete mode 100644 libgcc/config/rs6000/_sprintfkf.h delete mode 100644 libgcc/config/rs6000/_strtokf.c delete mode 100644 libgcc/config/rs6000/_strtokf.h diff --git a/libgcc/config/rs6000/_sprintfkf.c b/libgcc/config/rs6000/_sprintfkf.c deleted file mode 100644 index 2d624f14e25..00000000000 --- a/libgcc/config/rs6000/_sprintfkf.c +++ /dev/null @@ -1,58 +0,0 @@ -/* Copyright (C) 1989-2021 Free Software Foundation, Inc. - -This file is part of GCC. - -GCC is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free -Software Foundation; either version 3, or (at your option) any later -version. - -GCC is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -Under Section 7 of GPL version 3, you are granted additional -permissions described in the GCC Runtime Library Exception, version -3.1, as published by the Free Software Foundation. - -You should have received a copy of the GNU General Public License and -a copy of the GCC Runtime Library Exception along with this program; -see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -. */ - -/* Conversion to IEEE 128-bit floating point from string using snprintf. */ - -#include -#include -#include -#include -#include -#include <_sprintfkf.h> - -/* This function must be built with IBM 128-bit as long double, so that we can - access the strfroml function if do not have an IEEE 128-bit version, and if - that is not available, use sprintf. */ -#if !defined(__LONG_DOUBLE_128__) || !defined(__LONG_DOUBLE_IBM128__) -#error "Long double is not IBM 128-bit" -#endif - -/* If the user is using GLIBC 2.32, we can use the __snprintfieee128 function. - - If we are linked against an earlier library, we will have fake it by - converting the value to long double, and using sprintf to do the conversion. - This isn't ideal, as IEEE 128-bit has more exponent range than IBM - 128-bit. */ - -extern int __sprintfieee128 (char *restrict, const char *restrict, ...) - __attribute__ ((__weak__)); - -int __sprintfkf (char *restrict string, - const char *restrict format, - _Float128 number) -{ - if (__sprintfieee128) - return __sprintfieee128 (string, format, number); - - return sprintf (string, format, (long double) number); -} diff --git a/libgcc/config/rs6000/_sprintfkf.h b/libgcc/config/rs6000/_sprintfkf.h deleted file mode 100644 index de9d7137f69..00000000000 --- a/libgcc/config/rs6000/_sprintfkf.h +++ /dev/null @@ -1,27 +0,0 @@ -/* Copyright (C) 1989-2021 Free Software Foundation, Inc. - -This file is part of GCC. - -GCC is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free -Software Foundation; either version 3, or (at your option) any later -version. - -GCC is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -Under Section 7 of GPL version 3, you are granted additional -permissions described in the GCC Runtime Library Exception, version -3.1, as published by the Free Software Foundation. - -You should have received a copy of the GNU General Public License and -a copy of the GCC Runtime Library Exception along with this program; -see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -. */ - -/* Declaration of the conversion function to IEEE 128-bit floating point from - string using snprintf. */ - -extern int __sprintfkf (char *restrict, const char *restrict, _Float128); diff --git a/libgcc/config/rs6000/_strtokf.c b/libgcc/config/rs6000/_strtokf.c deleted file mode 100644 index dc13534cdc2..00000000000 --- a/libgcc/config/rs6000/_strtokf.c +++ /dev/null @@ -1,53 +0,0 @@ -/* Copyright (C) 1989-2021 Free Software Foundation, Inc. - -This file is part of GCC. - -GCC is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free -Software Foundation; either version 3, or (at your option) any later -version. - -GCC is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -Under Section 7 of GPL version 3, you are granted additional -permissions described in the GCC Runtime Library Exception, version -3.1, as published by the Free Software Foundation. - -You should have received a copy of the GNU General Public License and -a copy of the GCC Runtime Library Exception along with this program; -see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -. */ - -/* Conversion to IEEE 128-bit floating point from string. */ - -#include -#include -#include -#include - -/* This function must be built with IBM 128-bit as long double, so that we can - access the strtold function if do not have an IEEE 128-bit version. */ -#if !defined(__LONG_DOUBLE_128__) || !defined(__LONG_DOUBLE_IBM128__) -#error "Long double is not IBM 128-bit" -#endif - -/* If the user is using GLIBC 2.32, we can use the __strtoieee128 function. - - If we are linked against an earlier library, we will have fake it by - converting the string to IBM 128-bit long double, and then converting that to - __float128. This isn't ideal, as IEEE 128-bit has more exponent range than - IBM 128-bit. */ - -extern _Float128 __strtoieee128 (const char *, char **) __attribute__ ((__weak__)); - -_Float128 -__strtokf (const char *string, char **endptr) -{ - if (__strtoieee128) - return __strtoieee128 (string, endptr); - - return strtold (string, endptr); -} diff --git a/libgcc/config/rs6000/_strtokf.h b/libgcc/config/rs6000/_strtokf.h deleted file mode 100644 index a7ca8e09244..00000000000 --- a/libgcc/config/rs6000/_strtokf.h +++ /dev/null @@ -1,27 +0,0 @@ -/* Copyright (C) 1989-2021 Free Software Foundation, Inc. - -This file is part of GCC. - -GCC is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free -Software Foundation; either version 3, or (at your option) any later -version. - -GCC is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -Under Section 7 of GPL version 3, you are granted additional -permissions described in the GCC Runtime Library Exception, version -3.1, as published by the Free Software Foundation. - -You should have received a copy of the GNU General Public License and -a copy of the GCC Runtime Library Exception along with this program; -see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -. */ - -/* Declaration of the conversion function to IEEE 128-bit floating point from - string. */ - -extern _Float128 __strtokf (const char *, char **); diff --git a/libgcc/config/rs6000/t-float128 b/libgcc/config/rs6000/t-float128 index 6fb1a3d871b..8b089d4433c 100644 --- a/libgcc/config/rs6000/t-float128 +++ b/libgcc/config/rs6000/t-float128 @@ -26,10 +26,6 @@ fp128_softfp_obj = $(fp128_softfp_static_obj) $(fp128_softfp_shared_obj) fp128_dec_funcs = _kf_to_sd _kf_to_dd _kf_to_td \ _sd_to_kf _dd_to_kf _td_to_kf -# _Float128 to/from string conversions that must be compiled with IBM 128-bit -# long double. -fp128_decstr_funcs = _strtokf _sprintfkf - # Decimal <-> __ibm128 conversions ibm128_dec_funcs = _tf_to_sd _tf_to_dd _tf_to_td \ _sd_to_tf _dd_to_tf _td_to_tf @@ -38,7 +34,7 @@ ibm128_dec_funcs = _tf_to_sd _tf_to_dd _tf_to_td \ fp128_ppc_funcs = floattikf floatuntikf fixkfti fixunskfti \ extendkftf2-sw trunctfkf2-sw \ sfp-exceptions _mulkc3 _divkc3 _powikf2 \ - $(fp128_dec_funcs) $(fp128_decstr_funcs) + $(fp128_dec_funcs) fp128_ppc_src = $(addprefix $(srcdir)/config/rs6000/,$(addsuffix \ .c,$(fp128_ppc_funcs))) @@ -88,9 +84,6 @@ $(fp128_obj) : $(srcdir)/config/rs6000/quad-float128.h fp128_dec_objs = $(addsuffix $(objext),$(fp128_dec_funcs)) \ $(addsuffix _s$(objext),$(fp128_dec_funcs)) -fp128_decstr_objs = $(addsuffix $(objext),$(fp128_decstr_funcs)) \ - $(addsuffix _s$(objext),$(fp128_decstr_funcs)) - ibm128_dec_objs = $(addsuffix $(objext),$(ibm128_dec_funcs)) \ $(addsuffix _s$(objext),$(ibm128_dec_funcs)) @@ -98,12 +91,8 @@ FP128_CFLAGS_DECIMAL = -mno-gnu-attribute -Wno-psabi -mabi=ieeelongdouble IBM128_CFLAGS_DECIMAL = -mno-gnu-attribute -Wno-psabi -mabi=ibmlongdouble $(fp128_dec_objs) : INTERNAL_CFLAGS += $(FP128_CFLAGS_DECIMAL) -$(fp128_decstr_objs) : INTERNAL_CFLAGS += $(IBM128_CFLAGS_DECIMAL) $(ibm128_dec_objs) : INTERNAL_CFLAGS += $(IBM128_CFLAGS_DECIMAL) -$(fp128_decstr_objs) : $(srcdir)/config/rs6000/_strtokf.h \ - $(srcdir)/config/rs6000/_sprintfkf.h \ - $(fp128_softfp_src) : $(srcdir)/soft-fp/$(subst -sw,,$(subst kf,tf,$@)) $(fp128_dep) @src="$(srcdir)/soft-fp/$(subst -sw,,$(subst kf,tf,$@))"; \ echo "Create $@"; \ diff --git a/libgcc/dfp-bit.h b/libgcc/dfp-bit.h index 5e3bfa65ab8..e04cb831026 100644 --- a/libgcc/dfp-bit.h +++ b/libgcc/dfp-bit.h @@ -298,8 +298,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #define BFP_TYPE _Float128 #define BFP_FMT "%.36Le" #define BFP_VIA_TYPE _Float128 -#define STR_TO_BFP __strtokf -#include <_strtokf.h> +#define STR_TO_BFP __strtoieee128 +extern _Float128 __strtoieee128 (const char *, char **); #endif /* BFP_KIND */ @@ -647,8 +647,8 @@ extern DFP_C_TYPE BFP_TO_DFP (BFP_TYPE); #elif defined (L_kf_to_sd) || defined (L_kf_to_dd) || defined (L_kf_to_td) extern DFP_C_TYPE BFP_TO_DFP (BFP_TYPE); -#include <_sprintfkf.h> -#define BFP_SPRINTF __sprintfkf +extern int __sprintfieee128 (char *restrict, const char *restrict, ...); +#define BFP_SPRINTF __sprintfieee128 #endif #endif /* _DFPBIT_H */