[gcc(refs/users/meissner/heads/work026)] PowerPC: Add float128/Decimal conversions.
Michael Meissner
meissner@gcc.gnu.org
Thu Nov 12 03:55:49 GMT 2020
https://gcc.gnu.org/g:14bc963a272610d9625a70869db8e5e87f949b70
commit 14bc963a272610d9625a70869db8e5e87f949b70
Author: Michael Meissner <meissner@linux.ibm.com>
Date: Wed Nov 11 22:54:58 2020 -0500
PowerPC: Add float128/Decimal 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 | 58 +++++++++++++++++++++++++++++++++++++++
libgcc/config/rs6000/_kf_to_dd.c | 57 ++++++++++++++++++++++++++++++++++++++
libgcc/config/rs6000/_kf_to_sd.c | 58 +++++++++++++++++++++++++++++++++++++++
libgcc/config/rs6000/_kf_to_td.c | 56 ++++++++++++++++++++++++++++++++++++++
libgcc/config/rs6000/_sd_to_kf.c | 59 ++++++++++++++++++++++++++++++++++++++++
libgcc/config/rs6000/_td_to_kf.c | 58 +++++++++++++++++++++++++++++++++++++++
libgcc/config/rs6000/t-float128 | 26 +++++++++++++++++-
7 files changed, 371 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..93601fa280e
--- /dev/null
+++ b/libgcc/config/rs6000/_dd_to_kf.c
@@ -0,0 +1,58 @@
+/* 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. */
+#include <features.h>
+
+#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..fa4cc7e1716
--- /dev/null
+++ b/libgcc/config/rs6000/_kf_to_dd.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/>. */
+
+/* _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_tf_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. */
+#include <features.h>
+
+#if ((__GLIBC__ * 1000) + __GLIBC_MINOR__) < 2032
+
+#include <stdlib.h>
+extern _Decimal64 __dpd_trunckfdd (long double);
+
+_Decimal64
+__dpd_trunckfdd (long double x __attribute__ ((unused)))
+{
+ abort ();
+}
+
+#else
+/* Map the external name to the float128 default. */
+#define __dpd_trunctfdd __dpd_trunckfdd
+
+/* 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..ec92d697f84
--- /dev/null
+++ b/libgcc/config/rs6000/_kf_to_sd.c
@@ -0,0 +1,58 @@
+/* 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. */
+#include <features.h>
+
+#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..9a8f65647ea
--- /dev/null
+++ b/libgcc/config/rs6000/_kf_to_td.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 -> 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. */
+#include <features.h>
+
+#if ((__GLIBC__ * 1000) + __GLIBC_MINOR__) < 2032
+
+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..3c2f04d3f78
--- /dev/null
+++ b/libgcc/config/rs6000/_sd_to_kf.c
@@ -0,0 +1,59 @@
+/* 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. */
+#include <features.h>
+
+#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..26eefabdabc
--- /dev/null
+++ b/libgcc/config/rs6000/_td_to_kf.c
@@ -0,0 +1,58 @@
+/* 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. */
+#include <features.h>
+
+#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 $@"; \
More information about the Gcc-cvs
mailing list