summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Jaeger <aj@suse.de>2002-07-06 15:07:30 +0000
committerAndreas Jaeger <aj@suse.de>2002-07-06 15:07:30 +0000
commit9359218f0fa991ee10df00cfdc4fc1822c9d9597 (patch)
tree9850632a6d8c6587f9b2adc0288b4994ea87c2ea
parentaeb25823d8ef62566bef76351cc318673f3f36c7 (diff)
Update.
2002-07-06 Andreas Jaeger <aj@suse.de> * sysdeps/x86_64/fpu/bits/mathinline.h: New. * sysdeps/x86_64/fpu/s_copysign.S: New. * sysdeps/x86_64/fpu/s_copysignf.S: New. * sysdeps/x86_64/fpu/s_copysignl.S: New. * sysdeps/x86_64/fpu/s_finitel.S: New. * sysdeps/x86_64/fpu/s_fmax.S: New. * sysdeps/x86_64/fpu/s_fmaxf.S: New. * sysdeps/x86_64/fpu/s_fmaxl.S: New. * sysdeps/x86_64/fpu/s_fmin.S: New. * sysdeps/x86_64/fpu/s_fminf.S: New. * sysdeps/x86_64/fpu/s_fminl.S: New.
-rw-r--r--ChangeLog14
-rw-r--r--sysdeps/x86_64/fpu/bits/mathinline.h40
-rw-r--r--sysdeps/x86_64/fpu/s_copysign.S52
-rw-r--r--sysdeps/x86_64/fpu/s_copysignf.S37
-rw-r--r--sysdeps/x86_64/fpu/s_copysignl.S22
-rw-r--r--sysdeps/x86_64/fpu/s_fdiml.S42
-rw-r--r--sysdeps/x86_64/fpu/s_finitel.S16
-rw-r--r--sysdeps/x86_64/fpu/s_fmax.S36
-rw-r--r--sysdeps/x86_64/fpu/s_fmaxf.S36
-rw-r--r--sysdeps/x86_64/fpu/s_fmaxl.S40
-rw-r--r--sysdeps/x86_64/fpu/s_fmin.S36
-rw-r--r--sysdeps/x86_64/fpu/s_fminf.S36
-rw-r--r--sysdeps/x86_64/fpu/s_fminl.S38
13 files changed, 445 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 0a042b4c7b..f916d3f356 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2002-07-06 Andreas Jaeger <aj@suse.de>
+
+ * sysdeps/x86_64/fpu/bits/mathinline.h: New.
+ * sysdeps/x86_64/fpu/s_copysign.S: New.
+ * sysdeps/x86_64/fpu/s_copysignf.S: New.
+ * sysdeps/x86_64/fpu/s_copysignl.S: New.
+ * sysdeps/x86_64/fpu/s_finitel.S: New.
+ * sysdeps/x86_64/fpu/s_fmax.S: New.
+ * sysdeps/x86_64/fpu/s_fmaxf.S: New.
+ * sysdeps/x86_64/fpu/s_fmaxl.S: New.
+ * sysdeps/x86_64/fpu/s_fmin.S: New.
+ * sysdeps/x86_64/fpu/s_fminf.S: New.
+ * sysdeps/x86_64/fpu/s_fminl.S: New.
+
2002-06-05 Brian Youmans <3diff@gnu.org>
* sysdeps/ia64/fpu/e_acos.S: Added text of Intel license.
diff --git a/sysdeps/x86_64/fpu/bits/mathinline.h b/sysdeps/x86_64/fpu/bits/mathinline.h
new file mode 100644
index 0000000000..08e1c5b1da
--- /dev/null
+++ b/sysdeps/x86_64/fpu/bits/mathinline.h
@@ -0,0 +1,40 @@
+/* Inline math functions for x86-64.
+ Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Jaeger <aj@suse.de>, 2002.
+
+ 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. */
+
+#ifndef _MATH_H
+# error "Never use <bits/mathinline.h> directly; include <math.h> instead."
+#endif
+
+#ifdef __cplusplus
+# define __MATH_INLINE __inline
+#else
+# define __MATH_INLINE extern __inline
+#endif
+
+
+#if defined __USE_ISOC99 && defined __GNUC__ && __GNUC__ >= 2
+/* GCC has builtins that can be used. */
+# define isgreater(x, y) __builtin_isgreater (x, y)
+# define isgreaterequal(x, y) __builtin_isgreaterequal (x, y)
+# define isless(x, y) __builtin_isless (x, y)
+# define islessequal(x, y) __builtin_islessequal (x, y)
+# define islessgreater(x, y) __builtin_islessgreater (x, y)
+# define isunordered(x, y) __builtin_isunordered (x, y)
+#endif
diff --git a/sysdeps/x86_64/fpu/s_copysign.S b/sysdeps/x86_64/fpu/s_copysign.S
new file mode 100644
index 0000000000..f1ebcf8bf1
--- /dev/null
+++ b/sysdeps/x86_64/fpu/s_copysign.S
@@ -0,0 +1,52 @@
+/* copy sign, double version.
+ Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Jaeger <aj@suse.de>, 2002.
+
+ 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 <machine/asm.h>
+
+#ifdef __ELF__
+ .section .rodata
+#else
+ .text
+#endif
+
+ .align ALIGNARG(4)
+ ASM_TYPE_DIRECTIVE(signmask,@object)
+signmask:
+ .byte 0, 0, 0, 0, 0, 0, 0, 0x80
+ .byte 0, 0, 0, 0, 0, 0, 0, 0
+othermask:
+ .byte 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f
+ .byte 0, 0, 0, 0, 0, 0, 0, 0
+ ASM_SIZE_DIRECTIVE(othermask)
+
+#ifdef PIC
+#define MO(op) op##(%rip)
+#else
+#define MO(op) op
+#endif
+
+ENTRY(__copysign)
+ andpd MO(othermask),%xmm0
+ andpd MO(signmask),%xmm1
+ orpd %xmm1,%xmm0
+ ret
+END (__copysign)
+
+weak_alias (__copysign, copysign)
diff --git a/sysdeps/x86_64/fpu/s_copysignf.S b/sysdeps/x86_64/fpu/s_copysignf.S
new file mode 100644
index 0000000000..46919580d2
--- /dev/null
+++ b/sysdeps/x86_64/fpu/s_copysignf.S
@@ -0,0 +1,37 @@
+/* copy sign, double version.
+ Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Jaeger <aj@suse.de>, 2002.
+
+ 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 <machine/asm.h>
+
+ENTRY(__copysignf)
+ movss %xmm0,-4(%rsp)
+ mov -4(%rsp,1),%edx
+ movss %xmm1,-4(%rsp)
+ mov -4(%rsp),%eax
+ and $0x7fffffff,%edx
+ and $0x80000000,%eax
+ or %eax,%edx
+ mov %edx,-4(%rsp)
+ movss -4(%rsp),%xmm1
+ movaps %xmm1,%xmm0
+ retq
+END (__copysignf)
+
+weak_alias (__copysignf, copysignf)
diff --git a/sysdeps/x86_64/fpu/s_copysignl.S b/sysdeps/x86_64/fpu/s_copysignl.S
new file mode 100644
index 0000000000..2ffd612d65
--- /dev/null
+++ b/sysdeps/x86_64/fpu/s_copysignl.S
@@ -0,0 +1,22 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Changes for long double by Ulrich Drepper <drepper@cygnus.com>.
+ * Adopted for x86-64 by Andreas Jaeger <aj@suse.de>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: $")
+
+ENTRY(__copysignl)
+ movl 32(%rsp),%edx
+ movl 16(%rsp),%eax
+ andl $0x8000,%edx
+ andl $0x7fff,%eax
+ orl %edx,%eax
+ movl %eax,16(%rsp)
+ fldt 8(%rsp)
+ ret
+END (__copysignl)
+weak_alias (__copysignl, copysignl)
diff --git a/sysdeps/x86_64/fpu/s_fdiml.S b/sysdeps/x86_64/fpu/s_fdiml.S
new file mode 100644
index 0000000000..3789d14bb0
--- /dev/null
+++ b/sysdeps/x86_64/fpu/s_fdiml.S
@@ -0,0 +1,42 @@
+/* Compute positive difference.
+ Copyright (C) 1997, 1998, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
+
+ 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 <sysdep.h>
+
+ .text
+ENTRY(__fdiml)
+ fldt 8(%esp) // x
+ fldt 24(%esp) // x : y
+
+ fucomi %st(1), %st
+ jp 1f
+
+ fsubrp %st, %st(1)
+ fldz
+ fcomi %st(1), %st
+ fcmovb %st(1), %st
+ jmp 2f
+
+1: fucomi %st(0), %st
+ fcmovnu %st(1), %st
+2: fstp %st(1)
+ ret
+END(__fdiml)
+weak_alias (__fdiml, fdiml)
diff --git a/sysdeps/x86_64/fpu/s_finitel.S b/sysdeps/x86_64/fpu/s_finitel.S
new file mode 100644
index 0000000000..45b9886fb6
--- /dev/null
+++ b/sysdeps/x86_64/fpu/s_finitel.S
@@ -0,0 +1,16 @@
+/*
+ * Written by Joe Keane <jgk@jgk.org>.
+ * Adopted for x86-64 by Andreas Jaeger <aj@suse.de>.
+ */
+
+#include <machine/asm.h>
+
+ENTRY(__finitel)
+ movl 16(%rsp),%eax
+ orl $0xffff8000, %eax
+ incl %eax
+ shrl $31, %eax
+ ret
+END (__finitel)
+strong_alias(__finitel, __finitel_internal)
+weak_alias (__finitel, finitel)
diff --git a/sysdeps/x86_64/fpu/s_fmax.S b/sysdeps/x86_64/fpu/s_fmax.S
new file mode 100644
index 0000000000..b55d6f84ce
--- /dev/null
+++ b/sysdeps/x86_64/fpu/s_fmax.S
@@ -0,0 +1,36 @@
+/* Compute maximum of two numbers, regarding NaN as missing argument.
+ Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Jaeger <aj@suse.de>, 2002.
+
+ 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 <sysdep.h>
+
+ .text
+ENTRY(__fmax)
+ ucomisd %xmm0, %xmm1
+ jp 1f // jump if unordered
+ maxsd %xmm1, %xmm0
+ jmp 2f
+
+1: ucomisd %xmm1, %xmm1 // Is xmm1 a NaN?
+ jp 2f // then return xmm0
+ movsd %xmm1, %xmm0 // otherwise return xmm1
+
+2: ret
+END(__fmax)
+weak_alias (__fmax, fmax)
diff --git a/sysdeps/x86_64/fpu/s_fmaxf.S b/sysdeps/x86_64/fpu/s_fmaxf.S
new file mode 100644
index 0000000000..20d6fdd065
--- /dev/null
+++ b/sysdeps/x86_64/fpu/s_fmaxf.S
@@ -0,0 +1,36 @@
+/* Compute maximum of two numbers, regarding NaN as missing argument.
+ Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Jaeger <aj@suse.de>, 2002.
+
+ 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 <sysdep.h>
+
+ .text
+ENTRY(__fmaxf)
+ ucomiss %xmm0, %xmm1
+ jp 1f // jump if unordered
+ maxss %xmm1, %xmm0
+ jmp 2f
+
+1: ucomiss %xmm1, %xmm1 // Is xmm1 a NaN?
+ jp 2f // then return xmm0
+ movss %xmm1, %xmm0 // otherwise return xmm1
+
+2: ret
+END(__fmaxf)
+weak_alias (__fmaxf, fmaxf)
diff --git a/sysdeps/x86_64/fpu/s_fmaxl.S b/sysdeps/x86_64/fpu/s_fmaxl.S
new file mode 100644
index 0000000000..557ef3a17c
--- /dev/null
+++ b/sysdeps/x86_64/fpu/s_fmaxl.S
@@ -0,0 +1,40 @@
+/* Compute maximum of two numbers, regarding NaN as missing argument.
+ Copyright (C) 1997, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
+
+ 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 <sysdep.h>
+
+ .text
+ENTRY(__fmaxl)
+ fldt 8(%rsp) // x
+ fldt 24(%rsp) // x : y
+
+ fucomi %st(0), %st
+ fcmovu %st(1), %st // now %st contains y if not NaN, x otherwise
+
+ fxch
+
+ fucomi %st(1), %st
+ fcmovb %st(1), %st
+
+ fstp %st(1)
+
+ ret
+END(__fmaxl)
+weak_alias (__fmaxl, fmaxl)
diff --git a/sysdeps/x86_64/fpu/s_fmin.S b/sysdeps/x86_64/fpu/s_fmin.S
new file mode 100644
index 0000000000..37a3daaab2
--- /dev/null
+++ b/sysdeps/x86_64/fpu/s_fmin.S
@@ -0,0 +1,36 @@
+/* Compute minimum of two numbers, regarding NaN as missing argument.
+ Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Jaeger <aj@suse.de>, 2002.
+
+ 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 <sysdep.h>
+
+ .text
+ENTRY(__fmin)
+ ucomisd %xmm0, %xmm1
+ jp 1f // jump if unordered
+ minsd %xmm1, %xmm0
+ jmp 2f
+
+1: ucomisd %xmm1, %xmm1 // Is xmm1 a NaN?
+ jp 2f // then return xmm0
+ movsd %xmm1, %xmm0 // otherwise return xmm1
+
+2: ret
+END(__fmin)
+weak_alias (__fmin, fmin)
diff --git a/sysdeps/x86_64/fpu/s_fminf.S b/sysdeps/x86_64/fpu/s_fminf.S
new file mode 100644
index 0000000000..8e6f04bc08
--- /dev/null
+++ b/sysdeps/x86_64/fpu/s_fminf.S
@@ -0,0 +1,36 @@
+/* Compute minimum of two numbers, regarding NaN as missing argument.
+ Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Jaeger <aj@suse.de>, 2002.
+
+ 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 <sysdep.h>
+
+ .text
+ENTRY(__fminf)
+ ucomiss %xmm0, %xmm1
+ jp 1f // jump if unordered
+ minss %xmm1, %xmm0
+ jmp 2f
+
+1: ucomiss %xmm1, %xmm1 // Is xmm1 a NaN?
+ jp 2f // then return xmm0
+ movss %xmm1, %xmm0 // otherwise return xmm1
+
+2: ret
+END(__fminf)
+weak_alias (__fminf, fminf)
diff --git a/sysdeps/x86_64/fpu/s_fminl.S b/sysdeps/x86_64/fpu/s_fminl.S
new file mode 100644
index 0000000000..cbe58f1b25
--- /dev/null
+++ b/sysdeps/x86_64/fpu/s_fminl.S
@@ -0,0 +1,38 @@
+/* Compute minimum of two numbers, regarding NaN as missing argument.
+ Copyright (C) 1997, 1998, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
+
+ 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 <sysdep.h>
+
+ .text
+ENTRY(__fminl)
+ fldt 8(%rsp) // x
+ fldt 24(%rsp) // x : y
+
+ fucomi %st(0), %st
+ fcmovu %st(1), %st // now %st contains y if not NaN, x otherwise
+
+ fucomi %st(1), %st
+ fcmovnb %st(1), %st
+
+ fstp %st(1)
+
+ ret
+END(__fminl)
+weak_alias (__fminl, fminl)