diff --git a/ChangeLog b/ChangeLog index c0607e4905..b016443d6f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,24 @@ 2005-12-04 Joseph S. Myers + * 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. + * soft-fp/op-common.h (__FP_CLZ): Define using __builtin_clz, __builtin_clzl and __builtin_clzll. diff --git a/soft-fp/Makefile b/soft-fp/Makefile index e0a3cfb0df..8eb89c5e51 100644 --- a/soft-fp/Makefile +++ b/soft-fp/Makefile @@ -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 --git a/soft-fp/double.h b/soft-fp/double.h index c659adec62..77d439b466 100644 --- a/soft-fp/double.h +++ b/soft-fp/double.h @@ -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 --git a/soft-fp/extended.h b/soft-fp/extended.h index 2edcbd05f0..a1f54ccceb 100644 --- a/soft-fp/extended.h +++ b/soft-fp/extended.h @@ -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 --git a/soft-fp/floatundidf.c b/soft-fp/floatundidf.c new file mode 100644 index 0000000000..03bda04e62 --- /dev/null +++ b/soft-fp/floatundidf.c @@ -0,0 +1,38 @@ +/* Software floating-point emulation. + Convert a 64bit unsigned integer to IEEE double + 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 "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 --git a/soft-fp/floatundisf.c b/soft-fp/floatundisf.c new file mode 100644 index 0000000000..68aa90fbf7 --- /dev/null +++ b/soft-fp/floatundisf.c @@ -0,0 +1,38 @@ +/* Software floating-point emulation. + Convert a 64bit unsigned integer to IEEE single + 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 "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 --git a/soft-fp/floatunditf.c b/soft-fp/floatunditf.c new file mode 100644 index 0000000000..2f53f7d6e4 --- /dev/null +++ b/soft-fp/floatunditf.c @@ -0,0 +1,38 @@ +/* Software floating-point emulation. + Convert a 64bit unsigned integer to IEEE quad + 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 "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 --git a/soft-fp/floatunsidf.c b/soft-fp/floatunsidf.c new file mode 100644 index 0000000000..2649adcb6d --- /dev/null +++ b/soft-fp/floatunsidf.c @@ -0,0 +1,38 @@ +/* Software floating-point emulation. + Convert a 32bit unsigned integer to IEEE double + 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 "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 --git a/soft-fp/floatunsisf.c b/soft-fp/floatunsisf.c new file mode 100644 index 0000000000..a7f21ca68b --- /dev/null +++ b/soft-fp/floatunsisf.c @@ -0,0 +1,38 @@ +/* Software floating-point emulation. + Convert a 32bit unsigned integer to IEEE single + 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 "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 --git a/soft-fp/floatunsitf.c b/soft-fp/floatunsitf.c new file mode 100644 index 0000000000..efb66e9f0a --- /dev/null +++ b/soft-fp/floatunsitf.c @@ -0,0 +1,38 @@ +/* Software floating-point emulation. + Convert a 32bit unsigned integer to IEEE quad + 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 "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 --git a/soft-fp/op-common.h b/soft-fp/op-common.h index 46162ed3f6..f30260ede4 100644 --- a/soft-fp/op-common.h +++ b/soft-fp/op-common.h @@ -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 --git a/soft-fp/quad.h b/soft-fp/quad.h index 33ee4d4b20..b03063bc05 100644 --- a/soft-fp/quad.h +++ b/soft-fp/quad.h @@ -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 --git a/soft-fp/single.h b/soft-fp/single.h index b571d5058a..094dc3c484 100644 --- a/soft-fp/single.h +++ b/soft-fp/single.h @@ -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 --git a/soft-fp/unorddf2.c b/soft-fp/unorddf2.c new file mode 100644 index 0000000000..35f3e673db --- /dev/null +++ b/soft-fp/unorddf2.c @@ -0,0 +1,36 @@ +/* Software floating-point emulation. + Return 1 iff a or b is a NaN, 0 otherwise. + Copyright (C) 2006 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 --git a/soft-fp/unordsf2.c b/soft-fp/unordsf2.c new file mode 100644 index 0000000000..e741b794c1 --- /dev/null +++ b/soft-fp/unordsf2.c @@ -0,0 +1,37 @@ +/* Software floating-point emulation. + Return 1 iff a or b is a NaN, 0 otherwise. + Copyright (C) 2006 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 --git a/soft-fp/unordtf2.c b/soft-fp/unordtf2.c new file mode 100644 index 0000000000..5e30ddb8d2 --- /dev/null +++ b/soft-fp/unordtf2.c @@ -0,0 +1,37 @@ +/* Software floating-point emulation. + Return 1 iff a or b is a NaN, 0 otherwise. + Copyright (C) 2006 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; +}