Update copyright notices with scripts/update-copyrights
[glibc.git] / sysdeps / i386 / fpu / e_atanhf.S
blob5a4208cec3cf1e6237407e495bd99a8cdc129c42
1 /* ix87 specific implementation of arctanh function.
2    Copyright (C) 1996-2014 Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
4    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
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.
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.
16    You should have received a copy of the GNU Lesser General Public
17    License along with the GNU C Library; if not, see
18    <http://www.gnu.org/licenses/>.  */
20 #include <machine/asm.h>
22         .section .rodata
24         .align ALIGNARG(4)
25         .type half,@object
26 half:   .double 0.5
27         ASM_SIZE_DIRECTIVE(half)
28         .type one,@object
29 one:    .double 1.0
30         ASM_SIZE_DIRECTIVE(one)
31         .type limit,@object
32 limit:  .double 0.29
33         ASM_SIZE_DIRECTIVE(limit)
34         .align ALIGNARG(4)
35         .type ln2_2,@object
36 ln2_2:  .tfloat 0.3465735902799726547086160
37         ASM_SIZE_DIRECTIVE(ln2_2)
39 #ifdef PIC
40 #define MO(op) op##@GOTOFF(%edx)
41 #else
42 #define MO(op) op
43 #endif
45         .text
46 ENTRY(__ieee754_atanhf)
47         movl    4(%esp), %ecx
49         movl    %ecx, %eax
50         andl    $0x7fffffff, %eax
51         cmpl    $0x7f800000, %eax
52         ja      5f
54 #ifdef PIC
55         LOAD_PIC_REG (dx)
56 #endif
58         andl    $0x80000000, %ecx // ECX == 0 iff X >= 0
60         fldt    MO(ln2_2)       // 0.5*ln2
61         xorl    %ecx, 4(%esp)
62         flds    4(%esp)         // |x| : 0.5*ln2
63         fcoml   MO(half)        // |x| : 0.5*ln2
64         fld     %st(0)          // |x| : |x| : 0.5*ln2
65         fnstsw                  // |x| : |x| : 0.5*ln2
66         sahf
67         jae     2f
68         fadd    %st, %st(1)     // |x| : 2*|x| : 0.5*ln2
69         fld     %st             // |x| : |x| : 2*|x| : 0.5*ln2
70         fsubrl  MO(one)         // 1-|x| : |x| : 2*|x| : 0.5*ln2
71         fxch                    // |x| : 1-|x| : 2*|x| : 0.5*ln2
72         fmul    %st(2)          // 2*|x|^2 : 1-|x| : 2*|x| : 0.5*ln2
73         fdivp                   // (2*|x|^2)/(1-|x|) : 2*|x| : 0.5*ln2
74         faddp                   // 2*|x|+(2*|x|^2)/(1-|x|) : 0.5*ln2
75         fcoml   MO(limit)       // 2*|x|+(2*|x|^2)/(1-|x|) : 0.5*ln2
76         fnstsw                  // 2*|x|+(2*|x|^2)/(1-|x|) : 0.5*ln2
77         sahf
78         jae     4f
79         fyl2xp1                 // 0.5*ln2*ld(1+2*|x|+(2*|x|^2)/(1-|x|))
80         jecxz   3f
81         fchs                    // 0.5*ln2*ld(1+2*x+(2*x^2)/(1-x))
82 3:      ret
84         .align ALIGNARG(4)
85 4:      faddl   MO(one)         // 1+2*|x|+(2*|x|^2)/(1-|x|) : 0.5*ln2
86         fyl2x                   // 0.5*ln2*ld(1+2*|x|+(2*|x|^2)/(1-|x|))
87         jecxz   3f
88         fchs                    // 0.5*ln2*ld(1+2*x+(2*x^2)/(1-x))
89 3:      ret
91         .align ALIGNARG(4)
92 2:      faddl   MO(one)         // 1+|x| : |x| : 0.5*ln2
93         fxch                    // |x| : 1+|x| : 0.5*ln2
94         fsubrl  MO(one)         // 1-|x| : 1+|x| : 0.5*ln2
95         fdivrp                  // (1+|x|)/(1-|x|) : 0.5*ln2
96         fyl2x                   // 0.5*ln2*ld((1+|x|)/(1-|x|))
97         jecxz   3f
98         fchs                    // 0.5*ln2*ld((1+x)/(1-x))
99 3:      ret
101         // x == NaN
102 5:      flds    4(%esp)
103         ret
104 END(__ieee754_atanhf)
105 strong_alias (__ieee754_atanhf, __atanhf_finite)