This is the mail archive of the
libc-ports@sources.redhat.com
mailing list for the libc-ports project.
MIPS64 sqrtl implementation
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: libc-ports at sourceware dot org
- Date: Wed, 7 Jun 2006 21:58:23 +0000 (UTC)
- Subject: MIPS64 sqrtl implementation
This patch adds an implementation of sqrtl for MIPS64, using soft-fp in
the same way as the implementation for Alpha. It depends on the soft-fp
quad.h patch I just sent to libc-alpha.
2006-06-07 Joseph Myers <joseph@codesourcery.com>
* sysdeps/mips/mips64/n32/Implies: Add mips/mips64/soft-fp.
* sysdeps/mips/mips64/n64/Implies: Likewise.
* sysdeps/mips/mips64/soft-fp/Makefile: New.
* sysdeps/mips/mips64/soft-fp/e_sqrtl.c: New.
* sysdeps/mips/mips64/soft-fp/sfp-machine.h: Include <fenv.h> and
<fpu_control.h>. Use hardware exception and rounding mode
settings.
Index: sysdeps/mips/mips64/n32/Implies
===================================================================
RCS file: /cvs/glibc/ports/sysdeps/mips/mips64/n32/Implies,v
retrieving revision 1.2
diff -u -r1.2 Implies
--- sysdeps/mips/mips64/n32/Implies 9 Sep 2003 20:10:22 -0000 1.2
+++ sysdeps/mips/mips64/n32/Implies 7 Jun 2006 11:02:28 -0000
@@ -1,4 +1,5 @@
ieee754/ldbl-128
+mips/mips64/soft-fp
mips/mips64
mips
wordsize-32
Index: sysdeps/mips/mips64/n64/Implies
===================================================================
RCS file: /cvs/glibc/ports/sysdeps/mips/mips64/n64/Implies,v
retrieving revision 1.2
diff -u -r1.2 Implies
--- sysdeps/mips/mips64/n64/Implies 9 Sep 2003 20:10:22 -0000 1.2
+++ sysdeps/mips/mips64/n64/Implies 7 Jun 2006 11:02:28 -0000
@@ -1,4 +1,5 @@
ieee754/ldbl-128
+mips/mips64/soft-fp
mips/mips64
mips
wordsize-64
Index: sysdeps/mips/mips64/soft-fp/Makefile
===================================================================
RCS file: sysdeps/mips/mips64/soft-fp/Makefile
diff -N sysdeps/mips/mips64/soft-fp/Makefile
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ sysdeps/mips/mips64/soft-fp/Makefile 7 Jun 2006 11:02:28 -0000
@@ -0,0 +1,3 @@
+ifeq ($(subdir),math)
+CPPFLAGS += -I../soft-fp
+endif
Index: sysdeps/mips/mips64/soft-fp/e_sqrtl.c
===================================================================
RCS file: sysdeps/mips/mips64/soft-fp/e_sqrtl.c
diff -N sysdeps/mips/mips64/soft-fp/e_sqrtl.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ sysdeps/mips/mips64/soft-fp/e_sqrtl.c 7 Jun 2006 11:02:28 -0000
@@ -0,0 +1,39 @@
+/* long double square root in software floating-point emulation.
+ Copyright (C) 1997, 1999, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com) and
+ Jakub Jelinek (jj@ultra.linux.cz).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <stdlib.h>
+#include <soft-fp.h>
+#include <quad.h>
+
+long double
+__ieee754_sqrtl (const long double a)
+{
+ FP_DECL_EX;
+ FP_DECL_Q(A); FP_DECL_Q(C);
+ long double c;
+
+ FP_INIT_ROUNDMODE;
+ FP_UNPACK_Q(A, a);
+ FP_SQRT_Q(C, A);
+ FP_PACK_Q(c, C);
+ FP_HANDLE_EXCEPTIONS;
+ return c;
+}
Index: sysdeps/mips/mips64/soft-fp/sfp-machine.h
===================================================================
RCS file: /cvs/glibc/ports/sysdeps/mips/mips64/soft-fp/sfp-machine.h,v
retrieving revision 1.2
diff -u -r1.2 sfp-machine.h
--- sysdeps/mips/mips64/soft-fp/sfp-machine.h 17 Mar 2003 15:47:12 -0000 1.2
+++ sysdeps/mips/mips64/soft-fp/sfp-machine.h 7 Jun 2006 11:02:28 -0000
@@ -1,3 +1,6 @@
+#include <fenv.h>
+#include <fpu_control.h>
+
#define _FP_W_TYPE_SIZE 64
#define _FP_W_TYPE unsigned long long
#define _FP_WS_TYPE signed long long
@@ -40,8 +43,32 @@
R##_c = FP_CLS_NAN; \
} while (0)
-#define FP_EX_INVALID (1 << 4)
-#define FP_EX_DIVZERO (1 << 3)
-#define FP_EX_OVERFLOW (1 << 2)
-#define FP_EX_UNDERFLOW (1 << 1)
-#define FP_EX_INEXACT (1 << 0)
+#define _FP_DECL_EX fpu_control_t _fcw
+
+#define FP_ROUNDMODE (_fcw & 0x3)
+
+#define FP_RND_NEAREST FE_TONEAREST
+#define FP_RND_ZERO FE_TOWARDZERO
+#define FP_RND_PINF FE_UPWARD
+#define FP_RND_MINF FE_DOWNWARD
+
+#define FP_EX_INVALID FE_INVALID
+#define FP_EX_OVERFLOW FE_OVERFLOW
+#define FP_EX_UNDERFLOW FE_UNDERFLOW
+#define FP_EX_DIVZERO FE_DIVBYZERO
+#define FP_EX_INEXACT FE_INEXACT
+
+#ifdef __mips_hard_float
+#define FP_INIT_ROUNDMODE \
+do { \
+ _FPU_GETCW (_fcw); \
+} while (0)
+
+#define FP_HANDLE_EXCEPTIONS \
+do { \
+ if (__builtin_expect (_fex, 0)) \
+ _FPU_SETCW (_fcw | _fex | (_fex << 10)); \
+} while (0)
+#else
+#define FP_INIT_ROUNDMODE _fcw = FP_RND_NEAREST
+#endif
--
Joseph S. Myers
joseph@codesourcery.com