Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Make the MIPS N32/N64 ABIs properly support 128-bit long dou...
details: https://anonhg.NetBSD.org/src/rev/35e35744f7e3
branches: trunk
changeset: 760967:35e35744f7e3
user: matt <matt%NetBSD.org@localhost>
date: Mon Jan 17 23:53:03 2011 +0000
description:
Make the MIPS N32/N64 ABIs properly support 128-bit long doubles. With this
change, we should be fully conformant with the N32 and N64 ABIs.
Add {fpclassify,infinity,isnan,ininf,signbit}l_ieee754.c back to lib/libc/gen.
Note that infinityl_ieee754.c will work with either 64-bit, 80-bit, or
128-bit long doubles.
diffstat:
gnu/dist/gcc4/gcc/config/mips/netbsd64.h | 6 -
lib/libc/arch/mips/gdtoa/Makefile.inc | 9 +-
lib/libc/arch/mips/gdtoa/gd_qnan.h | 10 ++-
lib/libc/arch/mips/gen/Makefile.inc | 14 +-
lib/libc/arch/mips/softfloat/softfloat.h | 9 +-
lib/libc/gen/fpclassifyl_ieee754.c | 68 ++++++++++++++++
lib/libc/gen/infinityl_ieee754.c | 39 +++++++++
lib/libc/gen/isfinitel_ieee754.c | 57 +++++++++++++
lib/libc/gen/isinfl_ieee754.c | 66 +++++++++++++++
lib/libc/gen/isnanl_ieee754.c | 66 +++++++++++++++
lib/libc/gen/signbitl_ieee754.c | 56 +++++++++++++
sys/arch/mips/include/float.h | 34 +++++++-
sys/arch/mips/include/ieee.h | 129 ++++++++++++++++++++++++++++++-
sys/arch/mips/include/math.h | 5 +-
14 files changed, 545 insertions(+), 23 deletions(-)
diffs (truncated from 691 to 300 lines):
diff -r d3182d861989 -r 35e35744f7e3 gnu/dist/gcc4/gcc/config/mips/netbsd64.h
--- a/gnu/dist/gcc4/gcc/config/mips/netbsd64.h Mon Jan 17 23:34:44 2011 +0000
+++ b/gnu/dist/gcc4/gcc/config/mips/netbsd64.h Mon Jan 17 23:53:03 2011 +0000
@@ -50,9 +50,3 @@
%{mips32} %{mips32r2} %{mips64} %{mips64r2} \
%{bestGnum} %{call_shared} %{no_archive} %{exact_version} \
%(netbsd_link_spec)"
-
-#undef LONG_DOUBLE_TYPE_SIZE
-#define LONG_DOUBLE_TYPE_SIZE 64
-
-#undef LIBGCC2_LONG_DOUBLE_TYPE_SIZE
-#define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64
diff -r d3182d861989 -r 35e35744f7e3 lib/libc/arch/mips/gdtoa/Makefile.inc
--- a/lib/libc/arch/mips/gdtoa/Makefile.inc Mon Jan 17 23:34:44 2011 +0000
+++ b/lib/libc/arch/mips/gdtoa/Makefile.inc Mon Jan 17 23:53:03 2011 +0000
@@ -1,3 +1,10 @@
-# $NetBSD: Makefile.inc,v 1.1 2006/03/15 17:35:18 kleink Exp $
+# $NetBSD: Makefile.inc,v 1.2 2011/01/17 23:53:03 matt Exp $
+CPUFLAGS?=
SRCS+= strtof.c
+.if (${MACHINE_ARCH} == "mips64eb" || ${MACHINE_ARCH} == "mips64el")
+.if ${CPUFLAGS:M-mabi=32} == ""
+SRCS+= strtold_pQ.c
+SRCS+= strtopQ.c
+.endif
+.endif
diff -r d3182d861989 -r 35e35744f7e3 lib/libc/arch/mips/gdtoa/gd_qnan.h
--- a/lib/libc/arch/mips/gdtoa/gd_qnan.h Mon Jan 17 23:34:44 2011 +0000
+++ b/lib/libc/arch/mips/gdtoa/gd_qnan.h Mon Jan 17 23:53:03 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: gd_qnan.h,v 1.1 2006/01/25 15:33:28 kleink Exp $ */
+/* $NetBSD: gd_qnan.h,v 1.2 2011/01/17 23:53:03 matt Exp $ */
#include <machine/endian.h>
@@ -6,7 +6,15 @@
#if BYTE_ORDER == BIG_ENDIAN
#define d_QNAN0 0x7ff40000
#define d_QNAN1 0x0
+#define ld_QNAN0 0x7fff8000
+#define ld_QNAN1 0x0
+#define ld_QNAN2 0x0
+#define ld_QNAN3 0x0
#else
#define d_QNAN0 0x0
#define d_QNAN1 0x7ff40000
+#define ld_QNAN0 0x0
+#define ld_QNAN1 0x0
+#define ld_QNAN2 0x0
+#define ld_QNAN3 0x7fff8000
#endif
diff -r d3182d861989 -r 35e35744f7e3 lib/libc/arch/mips/gen/Makefile.inc
--- a/lib/libc/arch/mips/gen/Makefile.inc Mon Jan 17 23:34:44 2011 +0000
+++ b/lib/libc/arch/mips/gen/Makefile.inc Mon Jan 17 23:53:03 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.inc,v 1.31 2010/09/03 17:22:51 matt Exp $
+# $NetBSD: Makefile.inc,v 1.32 2011/01/17 23:53:03 matt Exp $
.if ${MKSOFTFLOAT} == "no"
SRCS+= fabs.S ldexp.S modf.S
@@ -7,12 +7,12 @@
.endif
# Common ieee754 constants and functions
-SRCS+= infinityf_ieee754.c infinity_ieee754.c infinityl_dbl_ieee754.c
-SRCS+= fpclassifyf_ieee754.c fpclassifyd_ieee754.c
-SRCS+= isinff_ieee754.c isinfd_ieee754.c
-SRCS+= isnanf_ieee754.c isnand_ieee754.c
-SRCS+= isfinitef_ieee754.c isfinited_ieee754.c
-SRCS+= signbitf_ieee754.c signbitd_ieee754.c
+SRCS+= infinityf_ieee754.c infinity_ieee754.c infinityl_ieee754.c
+SRCS+= fpclassifyf_ieee754.c fpclassifyd_ieee754.c fpclassifyl_ieee754.c
+SRCS+= isinff_ieee754.c isinfd_ieee754.c isinfl_ieee754.c
+SRCS+= isnanf_ieee754.c isnand_ieee754.c isnanl_ieee754.c
+SRCS+= isfinitef_ieee754.c isfinited_ieee754.c isfinitel_ieee754.c
+SRCS+= signbitf_ieee754.c signbitd_ieee754.c signbitl_ieee754.c
SRCS+= nanf.c
SRCS+= flt_rounds.c
diff -r d3182d861989 -r 35e35744f7e3 lib/libc/arch/mips/softfloat/softfloat.h
--- a/lib/libc/arch/mips/softfloat/softfloat.h Mon Jan 17 23:34:44 2011 +0000
+++ b/lib/libc/arch/mips/softfloat/softfloat.h Mon Jan 17 23:53:03 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: softfloat.h,v 1.2 2009/12/14 01:07:42 matt Exp $ */
+/* $NetBSD: softfloat.h,v 1.3 2011/01/17 23:53:04 matt Exp $ */
/* This is a derivative work. */
@@ -42,7 +42,9 @@
-------------------------------------------------------------------------------
*/
/* #define FLOATX80 */
-/* #define FLOAT128 */
+#if defined(__mips_n32) || defined(__mips_n64)
+#define FLOAT128
+#endif
#include <machine/ieeefp.h>
@@ -133,10 +135,10 @@
#ifdef FLOATX80
floatx80 int64_to_floatx80( long long );
#endif
+#endif
#ifdef FLOAT128
float128 int64_to_float128( long long );
#endif
-#endif
/*
-------------------------------------------------------------------------------
@@ -315,6 +317,7 @@
int float128_le_quiet( float128, float128 );
int float128_lt_quiet( float128, float128 );
int float128_is_signaling_nan( float128 );
+flag float128_is_nan( float128 );
#endif
diff -r d3182d861989 -r 35e35744f7e3 lib/libc/gen/fpclassifyl_ieee754.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libc/gen/fpclassifyl_ieee754.c Mon Jan 17 23:53:03 2011 +0000
@@ -0,0 +1,68 @@
+/* $NetBSD: fpclassifyl_ieee754.c,v 1.1 2011/01/17 23:53:03 matt Exp $ */
+
+/*-
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Matt Thomas.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: fpclassifyl_ieee754.c,v 1.1 2011/01/17 23:53:03 matt Exp $");
+#endif
+
+#include <machine/ieee.h>
+#include <math.h>
+
+#ifdef __HAVE_LONG_DOUBLE
+/*
+ * 7.12.3.1 fpclassify - classify real floating type
+ * IEEE 754 compatible 128-bit extended-precision version
+ */
+int
+__fpclassifyl(long double x)
+{
+ union ieee_ext_u u;
+
+ u.extu_ld = x;
+
+ if (u.extu_ext.ext_exp == 0) {
+ if (u.extu_ext.ext_frach == 0 && u.extu_ext.ext_frachm == 0
+ && u.extu_ext.ext_fraclm == 0 && u.extu_ext.ext_fracl == 0)
+ return FP_ZERO;
+ else
+ return FP_SUBNORMAL;
+ } else if (u.extu_ext.ext_exp == EXT_EXP_INFNAN) {
+ if (u.extu_ext.ext_frach == 0 && u.extu_ext.ext_frachm == 0
+ && u.extu_ext.ext_fraclm == 0 && u.extu_ext.ext_fracl == 0)
+ return FP_INFINITE;
+ else
+ return FP_NAN;
+ }
+
+ return FP_NORMAL;
+}
+#endif /* __HAVE_LONG_DOUBLE */
diff -r d3182d861989 -r 35e35744f7e3 lib/libc/gen/infinityl_ieee754.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libc/gen/infinityl_ieee754.c Mon Jan 17 23:53:03 2011 +0000
@@ -0,0 +1,39 @@
+/* $NetBSD: infinityl_ieee754.c,v 1.1 2011/01/17 23:53:03 matt Exp $ */
+
+/*
+ * IEEE-compatible infinityl.c for 64-bit or 128-bit long double format.
+ * This is public domain.
+ */
+
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: infinityl_ieee754.c,v 1.1 2011/01/17 23:53:03 matt Exp $");
+#endif /* LIBC_SCCS and not lint */
+
+#include <math.h>
+#include <machine/endian.h>
+#include <machine/ieee.h>
+
+#ifdef __HAVE_LONG_DOUBLE
+#define LDBL_EXPBITS EXT_EXPBITS
+#define LDBL_EXP_INFNAN EXT_EXP_INFNAN
+#else
+#define LDBL_EXPBITS DBL_EXPBITS
+#define LDBL_EXP_INFNAN DBL_EXP_INFNAN
+#endif
+
+#define EXP_INFNAN (LDBL_EXP_INFNAN << (31 - LDBL_EXPBITS))
+
+const union __long_double_u __infinityl = { {
+#if BYTE_ORDER == BIG_ENDIAN
+ [0] = (EXP_INFNAN >> 24) & 0x7f,
+ [1] = (EXP_INFNAN >> 16) & 0xff,
+ [2] = (EXP_INFNAN >> 8) & 0xff,
+ [3] = (EXP_INFNAN >> 0) & 0xff,
+#else
+ [sizeof(long double)-4] = (EXP_INFNAN >> 0) & 0xff,
+ [sizeof(long double)-3] = (EXP_INFNAN >> 8) & 0xff,
+ [sizeof(long double)-2] = (EXP_INFNAN >> 16) & 0xff,
+ [sizeof(long double)-1] = (EXP_INFNAN >> 24) & 0x7f,
+#endif
+} };
diff -r d3182d861989 -r 35e35744f7e3 lib/libc/gen/isfinitel_ieee754.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libc/gen/isfinitel_ieee754.c Mon Jan 17 23:53:03 2011 +0000
@@ -0,0 +1,57 @@
+/* $NetBSD: isfinitel_ieee754.c,v 1.1 2011/01/17 23:53:03 matt Exp $ */
+
+/*-
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Matt Thomas.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: isfinitel_ieee754.c,v 1.1 2011/01/17 23:53:03 matt Exp $");
+#endif
+
+#include <machine/ieee.h>
+#include <math.h>
+
+#ifdef __HAVE_LONG_DOUBLE
+/*
+ * 7.12.3.2 isfinite - determine whether an argument has finite value
+ * IEEE 754 compatible 128-bit extended-precision version
+ */
+int
+__isfinitel(long double x)
+{
+ union ieee_ext_u u;
+
+ u.extu_ld = x;
+
+ if (u.extu_ext.ext_exp == EXT_EXP_INFNAN)
+ return 0;
+
+ return 1;
+}
+#endif /* __HAVE_LONG_DOUBLE */
diff -r d3182d861989 -r 35e35744f7e3 lib/libc/gen/isinfl_ieee754.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libc/gen/isinfl_ieee754.c Mon Jan 17 23:53:03 2011 +0000
Home |
Main Index |
Thread Index |
Old Index