From 384fa30dddabbf1629841fb853fed218a9849380 Mon Sep 17 00:00:00 2001 From: Daniel Jacobowitz Date: Wed, 23 May 2007 17:13:59 +0000 Subject: [PATCH] * 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 and . Use hardware exception and rounding mode settings. --- ChangeLog.mips | 10 ++++++++ sysdeps/mips/mips64/n32/Implies | 1 + sysdeps/mips/mips64/n64/Implies | 1 + sysdeps/mips/mips64/soft-fp/Makefile | 3 +++ sysdeps/mips/mips64/soft-fp/e_sqrtl.c | 39 +++++++++++++++++++++++++++++++ sysdeps/mips/mips64/soft-fp/sfp-machine.h | 37 +++++++++++++++++++++++++---- 6 files changed, 86 insertions(+), 5 deletions(-) create mode 100644 sysdeps/mips/mips64/soft-fp/Makefile create mode 100644 sysdeps/mips/mips64/soft-fp/e_sqrtl.c diff --git a/ChangeLog.mips b/ChangeLog.mips index 097f7e2..2b5754f 100644 --- a/ChangeLog.mips +++ b/ChangeLog.mips @@ -1,3 +1,13 @@ +2007-05-23 Joseph Myers + + * 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 and + . Use hardware exception and rounding mode + settings. + 2007-05-23 Richard Sandiford * sysdeps/mips/dl-machine.h (elf_machine_reloc): Change type of diff --git a/sysdeps/mips/mips64/n32/Implies b/sysdeps/mips/mips64/n32/Implies index a7cb280..bed8f14 100644 --- a/sysdeps/mips/mips64/n32/Implies +++ b/sysdeps/mips/mips64/n32/Implies @@ -1,4 +1,5 @@ ieee754/ldbl-128 +mips/mips64/soft-fp mips/mips64 mips wordsize-32 diff --git a/sysdeps/mips/mips64/n64/Implies b/sysdeps/mips/mips64/n64/Implies index e507786..214b85c 100644 --- a/sysdeps/mips/mips64/n64/Implies +++ b/sysdeps/mips/mips64/n64/Implies @@ -1,4 +1,5 @@ ieee754/ldbl-128 +mips/mips64/soft-fp mips/mips64 mips wordsize-64 diff --git a/sysdeps/mips/mips64/soft-fp/Makefile b/sysdeps/mips/mips64/soft-fp/Makefile new file mode 100644 index 0000000..ada13e8 --- /dev/null +++ b/sysdeps/mips/mips64/soft-fp/Makefile @@ -0,0 +1,3 @@ +ifeq ($(subdir),math) +CPPFLAGS += -I../soft-fp +endif diff --git a/sysdeps/mips/mips64/soft-fp/e_sqrtl.c b/sysdeps/mips/mips64/soft-fp/e_sqrtl.c new file mode 100644 index 0000000..81fd58a --- /dev/null +++ b/sysdeps/mips/mips64/soft-fp/e_sqrtl.c @@ -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 +#include +#include + +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; +} diff --git a/sysdeps/mips/mips64/soft-fp/sfp-machine.h b/sysdeps/mips/mips64/soft-fp/sfp-machine.h index 309a14a..9c1ee3b 100644 --- a/sysdeps/mips/mips64/soft-fp/sfp-machine.h +++ b/sysdeps/mips/mips64/soft-fp/sfp-machine.h @@ -1,3 +1,6 @@ +#include +#include + #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 -- 2.7.4