public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/meissner/heads/work025)] PowerPC: Add Decimal <-> float128 conversions.
@ 2020-11-11 18:01 Michael Meissner
  0 siblings, 0 replies; only message in thread
From: Michael Meissner @ 2020-11-11 18:01 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:adbdb13386bb14c522c8c25b74f31c66478a417d

commit adbdb13386bb14c522c8c25b74f31c66478a417d
Author: Michael Meissner <meissner@linux.ibm.com>
Date:   Wed Nov 11 13:00:50 2020 -0500

    PowerPC: Add Decimal <-> float128 conversions.
    
    libgcc/
    2020-11-11  Michael Meissner  <meissner@linux.ibm.com>
    
            * config/rs6000/t-float128 (fp128_dec_funcs): New macro.
            (ibm128_dec_funcs): New macro.
            (fp128_ppc_funcs): Add the Decimal <-> __float128 conversions.
            (fp128_dec_objs): Force Decimal <-> __float128 conversions to be
            compiled with -mabi=ieeelongdouble.
            (ibm128_dec_objs): Force Decimal <-> __float128 conversions to be
            compiled with -mabi=ieeelongdouble.
            (FP128_CFLAGS_DECIMAL): New macro.
            (IBM128_CFLAGS_DECIMAL): New macro.
            * 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/_td_to_kf.c: New file.

Diff:
---
 libgcc/config/rs6000/_dd_to_kf.c | 56 +++++++++++++++++++++++++++++++++++++++
 libgcc/config/rs6000/_kf_to_dd.c | 55 ++++++++++++++++++++++++++++++++++++++
 libgcc/config/rs6000/_kf_to_sd.c | 56 +++++++++++++++++++++++++++++++++++++++
 libgcc/config/rs6000/_kf_to_td.c | 55 ++++++++++++++++++++++++++++++++++++++
 libgcc/config/rs6000/_sd_to_kf.c | 57 ++++++++++++++++++++++++++++++++++++++++
 libgcc/config/rs6000/_td_to_kf.c | 56 +++++++++++++++++++++++++++++++++++++++
 libgcc/config/rs6000/t-float128  | 26 +++++++++++++++++-
 7 files changed, 360 insertions(+), 1 deletion(-)

diff --git a/libgcc/config/rs6000/_dd_to_kf.c b/libgcc/config/rs6000/_dd_to_kf.c
new file mode 100644
index 00000000000..df688a63758
--- /dev/null
+++ b/libgcc/config/rs6000/_dd_to_kf.c
@@ -0,0 +1,56 @@
+/* Copyright (C) 1989-2020 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
+<http://www.gnu.org/licenses/>.  */
+
+/* Decimal64 -> _Float128 conversion.  */
+
+/* FINE_GRAINED_LIBRARIES is used so we can isolate just to dd_to_tf conversion
+   function from dp-bits.c.  */
+#define FINE_GRAINED_LIBRARIES	1
+#define L_dd_to_tf		1
+#define WIDTH			64
+
+#if !defined(__LONG_DOUBLE_128__) || !defined(__LONG_DOUBLE_IEEE128__)
+#error "Long double is not IEEE 128-bit"
+#endif
+
+/* If we don't have at least GLIBC 2.32, the strtold used by dfp-bit.c does not
+   have support for float128.  Add an abort in case this is called.  */
+#if ((__GLIBC__ * 1000) + __GLIBC_MINOR__) < 2032
+
+#include <stdlib.h>
+extern long double __dpd_extendddkf (_Decimal64);
+
+long double
+__dpd_extendddkf (_Decimal64 x __attribute__ ((unused)))
+{
+  abort ();
+}
+
+#else
+
+/* Map the external name to the float128 default.  */
+#define __dpd_extendddtf	__dpd_extendddkf
+
+/* Use dfp-bit.c to do the real work.  */
+#include "dfp-bit.c"
+#endif
diff --git a/libgcc/config/rs6000/_kf_to_dd.c b/libgcc/config/rs6000/_kf_to_dd.c
new file mode 100644
index 00000000000..e497044ab4f
--- /dev/null
+++ b/libgcc/config/rs6000/_kf_to_dd.c
@@ -0,0 +1,55 @@
+/* Copyright (C) 1989-2020 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
+<http://www.gnu.org/licenses/>.  */
+
+/* _Float128 -> Decimal64 conversion.  */
+
+/* FINE_GRAINED_LIBRARIES is used so we can isolate just to tf_to_dd conversion
+   function from dp-bits.c.  */
+#define FINE_GRAINED_LIBRARIES	1
+#define L_df_to_dd		1
+#define WIDTH			64
+
+#if !defined(__LONG_DOUBLE_128__) || !defined(__LONG_DOUBLE_IEEE128__)
+#error "Long double is not IEEE 128-bit"
+#endif
+
+/* If we don't have at least GLIBC 2.32, the strtold used by dfp-bit.c does not
+   have support for float128.  Add an abort in case this is called.  */
+#if ((__GLIBC__ * 1000) + __GLIBC_MINOR__) < 2032
+
+#include <stdlib.h>
+extern _Decimal64 __dpd_extendkfdd (long double);
+
+_Decimal64
+__dpd_extendkfdd (long double x __attribute__ ((unused)))
+{
+  abort ();
+}
+
+#else
+/* Map the external name to the float128 default.  */
+#define __dpd_trunctdtf		__dpd_trunctdkf
+
+/* Use dfp-bit.c to do the real work.  */
+#include "dfp-bit.c"
+#endif
diff --git a/libgcc/config/rs6000/_kf_to_sd.c b/libgcc/config/rs6000/_kf_to_sd.c
new file mode 100644
index 00000000000..dc691092eab
--- /dev/null
+++ b/libgcc/config/rs6000/_kf_to_sd.c
@@ -0,0 +1,56 @@
+/* Copyright (C) 1989-2020 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
+<http://www.gnu.org/licenses/>.  */
+
+/* _Float128 -> Decimal32 conversion.  */
+
+/* FINE_GRAINED_LIBRARIES is used so we can isolate just to tf_to_sd conversion
+   function from dp-bits.c.  */
+#define FINE_GRAINED_LIBRARIES	1
+#define L_tf_to_sd		1
+#define WIDTH			32
+
+#if !defined(__LONG_DOUBLE_128__) || !defined(__LONG_DOUBLE_IEEE128__)
+#error "Long double is not IEEE 128-bit"
+#endif
+
+/* If we don't have at least GLIBC 2.32, the strtold used by dfp-bit.c does not
+   have support for float128.  Add an abort in case this is called.  */
+#if ((__GLIBC__ * 1000) + __GLIBC_MINOR__) < 2032
+
+#include <stdlib.h>
+extern _Decimal32 __dpd_extendkfsd (long double);
+
+_Decimal32
+__dpd_extendkfsd (long double x __attribute__ ((unused)))
+{
+  abort ();
+}
+
+#else
+
+/* Map the external name to the float128 default.  */
+#define __dpd_trunctfsd	__dpd_trunckfsd
+
+/* Use dfp-bit.c to do the real work.  */
+#include "dfp-bit.c"
+#endif
diff --git a/libgcc/config/rs6000/_kf_to_td.c b/libgcc/config/rs6000/_kf_to_td.c
new file mode 100644
index 00000000000..f3f47599051
--- /dev/null
+++ b/libgcc/config/rs6000/_kf_to_td.c
@@ -0,0 +1,55 @@
+/* Copyright (C) 1989-2020 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
+<http://www.gnu.org/licenses/>.  */
+
+/* _Float128 -> Decimal128 conversion.  */
+
+/* FINE_GRAINED_LIBRARIES is used so we can isolate just to tf_to_td conversion
+   function from dp-bits.c.  */
+#define FINE_GRAINED_LIBRARIES	1
+#define L_tf_to_td		1
+#define WIDTH			128
+
+#if !defined(__LONG_DOUBLE_128__) || !defined(__LONG_DOUBLE_IEEE128__)
+#error "Long double is not IEEE 128-bit"
+#endif
+
+/* If we don't have at least GLIBC 2.32, the strtold used by dfp-bit.c does not
+   have support for float128.  Add an abort in case this is called.  */
+#if ((__GLIBC__ * 1000) + __GLIBC_MINOR__) < 2032
+
+#include <stdlib.h>
+extern _Decimal128 __dpd_extendkftd (long double);
+
+_Decimal128
+__dpd_extendkftd (long double x __attribute__ ((unused)))
+{
+  abort ();
+}
+
+#else
+/* Map the external name to the float128 default.  */
+#define __dpd_extendtftd	__dpd_extendkftd
+
+/* Use dfp-bit.c to do the real work.  */
+#include "dfp-bit.c"
+#endif
diff --git a/libgcc/config/rs6000/_sd_to_kf.c b/libgcc/config/rs6000/_sd_to_kf.c
new file mode 100644
index 00000000000..44bba0a1466
--- /dev/null
+++ b/libgcc/config/rs6000/_sd_to_kf.c
@@ -0,0 +1,57 @@
+/* Copyright (C) 1989-2020 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
+<http://www.gnu.org/licenses/>.  */
+
+/* Decimal32 -> _Float128 conversion.  */
+
+/* FINE_GRAINED_LIBRARIES is used so we can isolate just to sd_to_tf conversion
+   function from dp-bits.c.  */
+#define FINE_GRAINED_LIBRARIES	1
+#define L_sd_to_tf		1
+#define WIDTH			32
+
+#if !defined(__LONG_DOUBLE_128__) || !defined(__LONG_DOUBLE_IEEE128__)
+#error "Long double is not IEEE 128-bit"
+#endif
+
+/* If we don't have at least GLIBC 2.32, the strtold used by dfp-bit.c does not
+   have support for float128.  Add an abort in case this is called.  */
+#if ((__GLIBC__ * 1000) + __GLIBC_MINOR__) < 2032
+
+#include <stdlib.h>
+extern long double __dpd_extendsdkf (_Decimal32);
+
+long double
+__dpd_extendsdkf (_Decimal32 x __attribute__ ((unused)))
+{
+  abort ();
+}
+
+#else
+
+
+/* Map the external name to the float128 default.  */
+#define __dpd_extendsdtf	__dpd_extendsdkf
+
+/* Use dfp-bit.c to do the real work.  */
+#include "dfp-bit.c"
+#endif
diff --git a/libgcc/config/rs6000/_td_to_kf.c b/libgcc/config/rs6000/_td_to_kf.c
new file mode 100644
index 00000000000..947e2e335b0
--- /dev/null
+++ b/libgcc/config/rs6000/_td_to_kf.c
@@ -0,0 +1,56 @@
+/* Copyright (C) 1989-2020 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
+<http://www.gnu.org/licenses/>.  */
+
+/* Decimal128 -> _Float128 conversion.  */
+
+/* FINE_GRAINED_LIBRARIES is used so we can isolate just to td_to_tf conversion
+   function from dp-bits.c.  */
+#define FINE_GRAINED_LIBRARIES	1
+#define L_td_to_tf		1
+#define WIDTH			128
+
+#if !defined(__LONG_DOUBLE_128__) || !defined(__LONG_DOUBLE_IEEE128__)
+#error "Long double is not IEEE 128-bit"
+#endif
+
+/* If we don't have at least GLIBC 2.32, the strtold used by dfp-bit.c does not
+   have support for float128.  Add an abort in case this is called.  */
+#if ((__GLIBC__ * 1000) + __GLIBC_MINOR__) < 2032
+
+#include <stdlib.h>
+extern long double __dpd_trunctdkf (_Decimal128);
+
+long double
+__dpd_trunctdkf (_Decimal128 x __attribute__ ((unused)))
+{
+  abort ();
+}
+
+#else
+
+/* Map the external name to the float128 default.  */
+#define __dpd_trunctdtf	__dpd_trunctdkf
+
+/* Use dfp-bit.c to do the real work.  */
+#include "dfp-bit.c"
+#endif
diff --git a/libgcc/config/rs6000/t-float128 b/libgcc/config/rs6000/t-float128
index d5413445189..8b089d4433c 100644
--- a/libgcc/config/rs6000/t-float128
+++ b/libgcc/config/rs6000/t-float128
@@ -22,10 +22,19 @@ fp128_softfp_static_obj	= $(addsuffix -sw$(objext),$(fp128_softfp_funcs))
 fp128_softfp_shared_obj	= $(addsuffix -sw_s$(objext),$(fp128_softfp_funcs))
 fp128_softfp_obj	= $(fp128_softfp_static_obj) $(fp128_softfp_shared_obj)
 
+# Decimal <-> _Float128 conversions
+fp128_dec_funcs		= _kf_to_sd _kf_to_dd _kf_to_td \
+			  _sd_to_kf _dd_to_kf _td_to_kf
+
+# Decimal <-> __ibm128 conversions
+ibm128_dec_funcs	= _tf_to_sd _tf_to_dd _tf_to_td \
+			  _sd_to_tf _dd_to_tf _td_to_tf
+
 # New functions for software emulation
 fp128_ppc_funcs		= floattikf floatuntikf fixkfti fixunskfti \
 			  extendkftf2-sw trunctfkf2-sw \
-			  sfp-exceptions _mulkc3 _divkc3 _powikf2
+			  sfp-exceptions _mulkc3 _divkc3 _powikf2 \
+			  $(fp128_dec_funcs)
 
 fp128_ppc_src		= $(addprefix $(srcdir)/config/rs6000/,$(addsuffix \
 				.c,$(fp128_ppc_funcs)))
@@ -69,6 +78,21 @@ $(fp128_ppc_obj)	 : INTERNAL_CFLAGS += $(FP128_CFLAGS_SW)
 $(fp128_obj)		 : $(fp128_includes)
 $(fp128_obj)		 : $(srcdir)/config/rs6000/quad-float128.h
 
+# Force the TF mode to/from decimal functions to be compiled with IBM long
+# double.  Add building the KF mode to/from decimal conversions with explict
+# IEEE long double.
+fp128_dec_objs		= $(addsuffix $(objext),$(fp128_dec_funcs)) \
+			  $(addsuffix _s$(objext),$(fp128_dec_funcs))
+
+ibm128_dec_objs		= $(addsuffix $(objext),$(ibm128_dec_funcs)) \
+			  $(addsuffix _s$(objext),$(ibm128_dec_funcs))
+
+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)
+$(ibm128_dec_objs)	: INTERNAL_CFLAGS += $(IBM128_CFLAGS_DECIMAL)
+
 $(fp128_softfp_src) : $(srcdir)/soft-fp/$(subst -sw,,$(subst kf,tf,$@)) $(fp128_dep)
 	@src="$(srcdir)/soft-fp/$(subst -sw,,$(subst kf,tf,$@))"; \
 	echo "Create $@"; \


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-11-11 18:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-11 18:01 [gcc(refs/users/meissner/heads/work025)] PowerPC: Add Decimal <-> float128 conversions Michael Meissner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).