This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
soft-fp patch: New functions for newer GCC
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: libc-alpha at sourceware dot org
- Date: Sun, 4 Dec 2005 14:44:05 +0000 (UTC)
- Subject: soft-fp patch: New functions for newer GCC
The soft-fp code provides the functions to which GCC could generate calls
when it was contributed in 1999. Newer versions of GCC can generate calls
to more soft-float functions, __unord* and __floatun*. This patch adds
implementations of these functions (those for __floatun* almost identical
to those for __float*) to glibc.
2005-12-04 Joseph S. Myers <joseph@codesourcery.com>
* soft-fp/Makefile (gcc-single-routines): Add unordsf2,
floatunsisf, floatundisf.
(gcc-double-routines): Add unorddf2, floatunsidf, floatundidf.
(gcc-quad-routines): Add unordtf2, floatunsitf, floatunditf.
* soft-fp/op-common.h (_FP_CMP_UNORD): Define.
* soft-fp/single.h (FP_CMP_UNORD_S): Define.
* soft-fp/double.h (FP_CMP_UNORD_D): Define.
* soft-fp/quad.h (FP_CMP_UNORD_Q): Define.
* soft-fp/extended.h (FP_CMP_UNORD_E): Define.
* soft-fp/unordsf2.c: New file.
* soft-fp/unorddf2.c: New file.
* soft-fp/unordtf2.c: New file.
* soft-fp/floatunsisf.c: New file.
* soft-fp/floatundisf.c: New file.
* soft-fp/floatunsidf.c: New file.
* soft-fp/floatundidf.c: New file.
* soft-fp/floatunsitf.c: New file.
* soft-fp/floatunditf.c: New file.
diff -rupN libc.orig/soft-fp/Makefile libc.newfuncs/soft-fp/Makefile
--- libc.orig/soft-fp/Makefile 2001-07-06 10:53:02.000000000 +0000
+++ libc.newfuncs/soft-fp/Makefile 2005-12-04 14:29:33.000000000 +0000
@@ -23,17 +23,18 @@
subdir := soft-fp
gcc-single-routines := negsf2 addsf3 subsf3 mulsf3 divsf3 eqsf2 \
- lesf2 gesf2 fixsfsi fixunssfsi floatsisf fixsfdi \
- fixunssfdi floatdisf sqrtsf2
+ lesf2 gesf2 unordsf2 fixsfsi fixunssfsi floatsisf fixsfdi \
+ fixunssfdi floatdisf sqrtsf2 floatunsisf floatundisf
gcc-double-routines := negdf2 adddf3 subdf3 muldf3 divdf3 eqdf2 \
- ledf2 gedf2 fixdfsi fixunsdfsi floatsidf fixdfdi \
- fixunsdfdi floatdidf extendsfdf2 truncdfsf2 sqrtdf2
+ ledf2 gedf2 unorddf2 fixdfsi fixunsdfsi floatsidf fixdfdi \
+ fixunsdfdi floatdidf extendsfdf2 truncdfsf2 sqrtdf2 floatunsidf \
+ floatundidf
gcc-quad-routines := negtf2 addtf3 subtf3 multf3 divtf3 eqtf2 \
- letf2 getf2 fixtfsi fixunstfsi floatsitf fixtfdi \
+ letf2 getf2 unordtf2 fixtfsi fixunstfsi floatsitf fixtfdi \
fixunstfdi floatditf extendsftf2 trunctfsf2 extenddftf2 \
- trunctfdf2 sqrttf2
+ trunctfdf2 sqrttf2 floatunsitf floatunditf
distribute := double.h op-1.h op-2.h op-4.h op-common.h quad.h \
single.h soft-fp.h extended.h Banner op-8.h testit.c \
diff -rupN libc.orig/soft-fp/double.h libc.newfuncs/soft-fp/double.h
--- libc.orig/soft-fp/double.h 2001-07-06 10:53:02.000000000 +0000
+++ libc.newfuncs/soft-fp/double.h 2005-12-04 14:29:33.000000000 +0000
@@ -113,6 +113,7 @@ union _FP_UNION_D
#define FP_CMP_D(r,X,Y,un) _FP_CMP(D,2,r,X,Y,un)
#define FP_CMP_EQ_D(r,X,Y) _FP_CMP_EQ(D,2,r,X,Y)
+#define FP_CMP_UNORD_D(r,X,Y) _FP_CMP_UNORD(D,2,r,X,Y)
#define FP_TO_INT_D(r,X,rsz,rsg) _FP_TO_INT(D,2,r,X,rsz,rsg)
#define FP_FROM_INT_D(X,r,rs,rt) _FP_FROM_INT(D,2,X,r,rs,rt)
diff -rupN libc.orig/soft-fp/extended.h libc.newfuncs/soft-fp/extended.h
--- libc.orig/soft-fp/extended.h 2001-07-06 10:53:02.000000000 +0000
+++ libc.newfuncs/soft-fp/extended.h 2005-12-04 14:29:33.000000000 +0000
@@ -224,6 +224,7 @@ union _FP_UNION_E
#define FP_CMP_E(r,X,Y,un) _FP_CMP(E,4,r,X,Y,un)
#define FP_CMP_EQ_E(r,X,Y) _FP_CMP_EQ(E,4,r,X,Y)
+#define FP_CMP_UNORD_E(r,X,Y) _FP_CMP_UNORD(E,4,r,X,Y)
#define FP_TO_INT_E(r,X,rsz,rsg) _FP_TO_INT(E,4,r,X,rsz,rsg)
#define FP_FROM_INT_E(X,r,rs,rt) _FP_FROM_INT(E,4,X,r,rs,rt)
diff -rupN libc.orig/soft-fp/floatundidf.c libc.newfuncs/soft-fp/floatundidf.c
--- libc.orig/soft-fp/floatundidf.c 1970-01-01 00:00:00.000000000 +0000
+++ libc.newfuncs/soft-fp/floatundidf.c 2005-12-04 14:29:33.000000000 +0000
@@ -0,0 +1,37 @@
+/* Software floating-point emulation.
+ Convert a 64bit unsigned integer to IEEE double
+ Copyright (C) 1997,1999 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 "soft-fp.h"
+#include "double.h"
+
+double __floatundidf(UDItype i)
+{
+ FP_DECL_EX;
+ FP_DECL_D(A);
+ double a;
+
+ FP_FROM_INT_D(A, i, 64, long long);
+ FP_PACK_D(a, A);
+ FP_HANDLE_EXCEPTIONS;
+
+ return a;
+}
diff -rupN libc.orig/soft-fp/floatundisf.c libc.newfuncs/soft-fp/floatundisf.c
--- libc.orig/soft-fp/floatundisf.c 1970-01-01 00:00:00.000000000 +0000
+++ libc.newfuncs/soft-fp/floatundisf.c 2005-12-04 14:29:33.000000000 +0000
@@ -0,0 +1,37 @@
+/* Software floating-point emulation.
+ Convert a 64bit unsigned integer to IEEE single
+ Copyright (C) 1997,1999 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 "soft-fp.h"
+#include "single.h"
+
+float __floatundisf(UDItype i)
+{
+ FP_DECL_EX;
+ FP_DECL_S(A);
+ float a;
+
+ FP_FROM_INT_S(A, i, 64, long long);
+ FP_PACK_S(a, A);
+ FP_HANDLE_EXCEPTIONS;
+
+ return a;
+}
diff -rupN libc.orig/soft-fp/floatunditf.c libc.newfuncs/soft-fp/floatunditf.c
--- libc.orig/soft-fp/floatunditf.c 1970-01-01 00:00:00.000000000 +0000
+++ libc.newfuncs/soft-fp/floatunditf.c 2005-12-04 14:29:33.000000000 +0000
@@ -0,0 +1,37 @@
+/* Software floating-point emulation.
+ Convert a 64bit unsigned integer to IEEE quad
+ Copyright (C) 1997,1999 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 "soft-fp.h"
+#include "quad.h"
+
+long double __floatunditf(UDItype i)
+{
+ FP_DECL_EX;
+ FP_DECL_Q(A);
+ long double a;
+
+ FP_FROM_INT_Q(A, i, 64, long long);
+ FP_PACK_Q(a, A);
+ FP_HANDLE_EXCEPTIONS;
+
+ return a;
+}
diff -rupN libc.orig/soft-fp/floatunsidf.c libc.newfuncs/soft-fp/floatunsidf.c
--- libc.orig/soft-fp/floatunsidf.c 1970-01-01 00:00:00.000000000 +0000
+++ libc.newfuncs/soft-fp/floatunsidf.c 2005-12-04 14:29:33.000000000 +0000
@@ -0,0 +1,37 @@
+/* Software floating-point emulation.
+ Convert a 32bit unsigned integer to IEEE double
+ Copyright (C) 1997,1999 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 "soft-fp.h"
+#include "double.h"
+
+double __floatunsidf(USItype i)
+{
+ FP_DECL_EX;
+ FP_DECL_D(A);
+ double a;
+
+ FP_FROM_INT_D(A, i, 32, int);
+ FP_PACK_D(a, A);
+ FP_HANDLE_EXCEPTIONS;
+
+ return a;
+}
diff -rupN libc.orig/soft-fp/floatunsisf.c libc.newfuncs/soft-fp/floatunsisf.c
--- libc.orig/soft-fp/floatunsisf.c 1970-01-01 00:00:00.000000000 +0000
+++ libc.newfuncs/soft-fp/floatunsisf.c 2005-12-04 14:29:33.000000000 +0000
@@ -0,0 +1,37 @@
+/* Software floating-point emulation.
+ Convert a 32bit unsigned integer to IEEE single
+ Copyright (C) 1997,1999 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 "soft-fp.h"
+#include "single.h"
+
+float __floatunsisf(USItype i)
+{
+ FP_DECL_EX;
+ FP_DECL_S(A);
+ float a;
+
+ FP_FROM_INT_S(A, i, 32, int);
+ FP_PACK_S(a, A);
+ FP_HANDLE_EXCEPTIONS;
+
+ return a;
+}
diff -rupN libc.orig/soft-fp/floatunsitf.c libc.newfuncs/soft-fp/floatunsitf.c
--- libc.orig/soft-fp/floatunsitf.c 1970-01-01 00:00:00.000000000 +0000
+++ libc.newfuncs/soft-fp/floatunsitf.c 2005-12-04 14:29:33.000000000 +0000
@@ -0,0 +1,37 @@
+/* Software floating-point emulation.
+ Convert a 32bit unsigned integer to IEEE quad
+ Copyright (C) 1997,1999 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 "soft-fp.h"
+#include "quad.h"
+
+long double __floatunsitf(USItype i)
+{
+ FP_DECL_EX;
+ FP_DECL_Q(A);
+ long double a;
+
+ FP_FROM_INT_Q(A, i, 32, int);
+ FP_PACK_Q(a, A);
+ FP_HANDLE_EXCEPTIONS;
+
+ return a;
+}
diff -rupN libc.orig/soft-fp/op-common.h libc.newfuncs/soft-fp/op-common.h
--- libc.orig/soft-fp/op-common.h 2002-12-31 18:29:02.000000000 +0000
+++ libc.newfuncs/soft-fp/op-common.h 2005-12-04 14:29:33.000000000 +0000
@@ -553,6 +553,14 @@ do { \
} \
} while (0)
+/* Version to test unordered. */
+
+#define _FP_CMP_UNORD(fs, wc, ret, X, Y) \
+ do { \
+ ret = ((X##_e == _FP_EXPMAX_##fs && !_FP_FRAC_ZEROP_##wc(X)) \
+ || (Y##_e == _FP_EXPMAX_##fs && !_FP_FRAC_ZEROP_##wc(Y))); \
+ } while (0)
+
/*
* Main square root routine. The input value should be cooked.
*/
diff -rupN libc.orig/soft-fp/quad.h libc.newfuncs/soft-fp/quad.h
--- libc.orig/soft-fp/quad.h 2004-03-07 10:43:17.000000000 +0000
+++ libc.newfuncs/soft-fp/quad.h 2005-12-04 14:29:33.000000000 +0000
@@ -119,6 +119,7 @@ union _FP_UNION_Q
#define FP_CMP_Q(r,X,Y,un) _FP_CMP(Q,4,r,X,Y,un)
#define FP_CMP_EQ_Q(r,X,Y) _FP_CMP_EQ(Q,4,r,X,Y)
+#define FP_CMP_UNORD_Q(r,X,Y) _FP_CMP_UNORD(Q,4,r,X,Y)
#define FP_TO_INT_Q(r,X,rsz,rsg) _FP_TO_INT(Q,4,r,X,rsz,rsg)
#define FP_FROM_INT_Q(X,r,rs,rt) _FP_FROM_INT(Q,4,X,r,rs,rt)
diff -rupN libc.orig/soft-fp/single.h libc.newfuncs/soft-fp/single.h
--- libc.orig/soft-fp/single.h 2001-07-06 10:53:04.000000000 +0000
+++ libc.newfuncs/soft-fp/single.h 2005-12-04 14:29:33.000000000 +0000
@@ -102,6 +102,7 @@ union _FP_UNION_S
#define FP_CMP_S(r,X,Y,un) _FP_CMP(S,1,r,X,Y,un)
#define FP_CMP_EQ_S(r,X,Y) _FP_CMP_EQ(S,1,r,X,Y)
+#define FP_CMP_UNORD_S(r,X,Y) _FP_CMP_UNORD(S,1,r,X,Y)
#define FP_TO_INT_S(r,X,rsz,rsg) _FP_TO_INT(S,1,r,X,rsz,rsg)
#define FP_FROM_INT_S(X,r,rs,rt) _FP_FROM_INT(S,1,X,r,rs,rt)
diff -rupN libc.orig/soft-fp/unorddf2.c libc.newfuncs/soft-fp/unorddf2.c
--- libc.orig/soft-fp/unorddf2.c 1970-01-01 00:00:00.000000000 +0000
+++ libc.newfuncs/soft-fp/unorddf2.c 2005-12-04 14:29:33.000000000 +0000
@@ -0,0 +1,35 @@
+/* Software floating-point emulation.
+ Return 1 iff a or b is a NaN, 0 otherwise.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Joseph Myers (joseph@codesourcery.com).
+
+ 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 "soft-fp.h"
+#include "double.h"
+
+int __unorddf2(double a, double b)
+{
+ FP_DECL_D(A); FP_DECL_D(B);
+ int r;
+
+ FP_UNPACK_RAW_D(A, a);
+ FP_UNPACK_RAW_D(B, b);
+ FP_CMP_UNORD_D(r, A, B);
+
+ return r;
+}
diff -rupN libc.orig/soft-fp/unordsf2.c libc.newfuncs/soft-fp/unordsf2.c
--- libc.orig/soft-fp/unordsf2.c 1970-01-01 00:00:00.000000000 +0000
+++ libc.newfuncs/soft-fp/unordsf2.c 2005-12-04 14:29:33.000000000 +0000
@@ -0,0 +1,35 @@
+/* Software floating-point emulation.
+ Return 1 iff a or b is a NaN, 0 otherwise.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Joseph Myers (joseph@codesourcery.com).
+
+ 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 "soft-fp.h"
+#include "single.h"
+
+int __unordsf2(float a, float b)
+{
+ FP_DECL_S(A); FP_DECL_S(B);
+ int r;
+
+ FP_UNPACK_RAW_S(A, a);
+ FP_UNPACK_RAW_S(B, b);
+ FP_CMP_UNORD_S(r, A, B);
+
+ return r;
+}
diff -rupN libc.orig/soft-fp/unordtf2.c libc.newfuncs/soft-fp/unordtf2.c
--- libc.orig/soft-fp/unordtf2.c 1970-01-01 00:00:00.000000000 +0000
+++ libc.newfuncs/soft-fp/unordtf2.c 2005-12-04 14:29:33.000000000 +0000
@@ -0,0 +1,35 @@
+/* Software floating-point emulation.
+ Return 1 iff a or b is a NaN, 0 otherwise.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Joseph Myers (joseph@codesourcery.com).
+
+ 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 "soft-fp.h"
+#include "quad.h"
+
+int __unordtf2(long double a, long double b)
+{
+ FP_DECL_Q(A); FP_DECL_Q(B);
+ int r;
+
+ FP_UNPACK_RAW_Q(A, a);
+ FP_UNPACK_RAW_Q(B, b);
+ FP_CMP_UNORD_Q(r, A, B);
+
+ return r;
+}
--
Joseph S. Myers
joseph@codesourcery.com