]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/i386/fpu/e_atanh.S
* intl/Makefile (tst-gettext[45].out): Pass also $(run-program-prefix)
[thirdparty/glibc.git] / sysdeps / i386 / fpu / e_atanh.S
1 /* ix87 specific implementation of arctanh function.
2 Copyright (C) 1996, 1999, 2005 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, write to the Free
18 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 USA. */
20
21 #include <machine/asm.h>
22
23 #ifdef __ELF__
24 .section .rodata
25 #else
26 .text
27 #endif
28
29 .align ALIGNARG(4)
30 ASM_TYPE_DIRECTIVE(half,@object)
31 half: .double 0.5
32 ASM_SIZE_DIRECTIVE(half)
33 ASM_TYPE_DIRECTIVE(one,@object)
34 one: .double 1.0
35 ASM_SIZE_DIRECTIVE(one)
36 ASM_TYPE_DIRECTIVE(limit,@object)
37 limit: .double 0.29
38 ASM_SIZE_DIRECTIVE(limit)
39 ASM_TYPE_DIRECTIVE(ln2_2,@object)
40 ln2_2: .tfloat 0.3465735902799726547086160
41 ASM_SIZE_DIRECTIVE(ln2_2)
42
43 #ifdef PIC
44 #define MO(op) op##@GOTOFF(%edx)
45 #else
46 #define MO(op) op
47 #endif
48
49 .text
50 ENTRY(__ieee754_atanh)
51 movl 8(%esp), %ecx
52
53 movl %ecx, %eax
54 andl $0x7fffffff, %eax
55 cmpl $0x7ff00000, %eax
56 jae 5f
57 7:
58
59 #ifdef PIC
60 call 1f
61 cfi_adjust_cfa_offset (4)
62 1: popl %edx
63 cfi_adjust_cfa_offset (-4)
64 addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %edx
65 #endif
66
67 andl $0x80000000, %ecx // ECX == 0 iff X >= 0
68
69 fldt MO(ln2_2) // 0.5*ln2
70 xorl %ecx, 8(%esp)
71 fldl 4(%esp) // |x| : 0.5*ln2
72 fcoml MO(half) // |x| : 0.5*ln2
73 fld %st // |x| : |x| : 0.5*ln2
74 fnstsw // |x| : |x| : 0.5*ln2
75 sahf
76 jae 2f
77 fadd %st, %st(1) // |x| : 2*|x| : 0.5*ln2
78 fld %st // |x| : |x| : 2*|x| : 0.5*ln2
79 fsubrl MO(one) // 1-|x| : |x| : 2*|x| : 0.5*ln2
80 fxch // |x| : 1-|x| : 2*|x| : 0.5*ln2
81 fmul %st(2) // 2*|x|^2 : 1-|x| : 2*|x| : 0.5*ln2
82 fdivp // (2*|x|^2)/(1-|x|) : 2*|x| : 0.5*ln2
83 faddp // 2*|x|+(2*|x|^2)/(1-|x|) : 0.5*ln2
84 fcoml MO(limit) // 2*|x|+(2*|x|^2)/(1-|x|) : 0.5*ln2
85 fnstsw // 2*|x|+(2*|x|^2)/(1-|x|) : 0.5*ln2
86 sahf
87 jae 4f
88 fyl2xp1 // 0.5*ln2*ld(1+2*|x|+(2*|x|^2)/(1-|x|))
89 jecxz 3f
90 fchs // 0.5*ln2*ld(1+2*x+(2*x^2)/(1-x))
91 3: ret
92
93 .align ALIGNARG(4)
94 4: faddl MO(one) // 1+2*|x|+(2*|x|^2)/(1-|x|) : 0.5*ln2
95 fyl2x // 0.5*ln2*ld(1+2*|x|+(2*|x|^2)/(1-|x|))
96 jecxz 3f
97 fchs // 0.5*ln2*ld(1+2*x+(2*x^2)/(1-x))
98 3: ret
99
100 .align ALIGNARG(4)
101 2: faddl MO(one) // 1+|x| : |x| : 0.5*ln2
102 fxch // |x| : 1+|x| : 0.5*ln2
103 fsubrl MO(one) // 1-|x| : 1+|x| : 0.5*ln2
104 fdivrp // (1+|x|)/(1-|x|) : 0.5*ln2
105 fyl2x // 0.5*ln2*ld((1+|x|)/(1-|x|))
106 jecxz 3f
107 fchs // 0.5*ln2*ld((1+x)/(1-x))
108 3: ret
109
110 // x == NaN or ±Inf
111 5: ja 6f
112 cmpl $0, 4(%esp)
113 je 7b
114 6: fldl 4(%esp)
115 ret
116 END(__ieee754_atanh)