Remove __ELF__ conditionals
[platform/upstream/glibc.git] / sysdeps / i386 / fpu / e_atanhl.S
1 /* ix87 specific implementation of arctanh function.
2    Copyright (C) 1996, 1999, 2011-2012 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         .section .rodata
24
25         .align ALIGNARG(4)
26         /* Please note that we use double values for 0.5 and 1.0.  These
27            numbers have exact representations and so we don't get accuracy
28            problems.  The advantage is that the code is simpler.  */
29         ASM_TYPE_DIRECTIVE(half,@object)
30 half:   .double 0.5
31         ASM_SIZE_DIRECTIVE(half)
32         ASM_TYPE_DIRECTIVE(one,@object)
33 one:    .double 1.0
34         ASM_SIZE_DIRECTIVE(one)
35         /* It is not important that this constant is precise.  It is only
36            a value which is known to be on the safe side for using the
37            fyl2xp1 instruction.  */
38         ASM_TYPE_DIRECTIVE(limit,@object)
39 limit:  .double 0.29
40         ASM_SIZE_DIRECTIVE(limit)
41         .align ALIGNARG(4)
42         ASM_TYPE_DIRECTIVE(ln2_2,@object)
43 ln2_2:  .tfloat 0.3465735902799726547086160
44         ASM_SIZE_DIRECTIVE(ln2_2)
45
46 #ifdef PIC
47 #define MO(op) op##@GOTOFF(%edx)
48 #else
49 #define MO(op) op
50 #endif
51
52         .text
53 ENTRY(__ieee754_atanhl)
54         movl    12(%esp), %ecx
55
56         movl    %ecx, %eax
57         andl    $0x7fff, %eax
58         cmpl    $0x7fff, %eax
59         je      5f
60 7:
61
62 #ifdef PIC
63         LOAD_PIC_REG (dx)
64 #endif
65
66         andl    $0x8000, %ecx   // ECX == 0 iff X >= 0
67
68         fldt    MO(ln2_2)       // 0.5*ln2
69         xorl    %ecx, 12(%esp)
70         fldt    4(%esp)         // |x| : 0.5*ln2
71         fcoml   MO(half)        // |x| : 0.5*ln2
72         fld     %st(0)          // |x| : |x| : 0.5*ln2
73         fnstsw                  // |x| : |x| : 0.5*ln2
74         sahf
75         jae     2f
76         fadd    %st, %st(1)     // |x| : 2*|x| : 0.5*ln2
77         fld     %st             // |x| : |x| : 2*|x| : 0.5*ln2
78         fsubrl  MO(one)         // 1-|x| : |x| : 2*|x| : 0.5*ln2
79         fxch                    // |x| : 1-|x| : 2*|x| : 0.5*ln2
80         fmul    %st(2)          // 2*|x|^2 : 1-|x| : 2*|x| : 0.5*ln2
81         fdivp                   // (2*|x|^2)/(1-|x|) : 2*|x| : 0.5*ln2
82         faddp                   // 2*|x|+(2*|x|^2)/(1-|x|) : 0.5*ln2
83         fcoml   MO(limit)       // 2*|x|+(2*|x|^2)/(1-|x|) : 0.5*ln2
84         fnstsw                  // 2*|x|+(2*|x|^2)/(1-|x|) : 0.5*ln2
85         sahf
86         jae     4f
87         fyl2xp1                 // 0.5*ln2*ld(1+2*|x|+(2*|x|^2)/(1-|x|))
88         jecxz   3f
89         fchs                    // 0.5*ln2*ld(1+2*x+(2*x^2)/(1-x))
90 3:      ret
91
92         .align ALIGNARG(4)
93 4:      faddl   MO(one)         // 1+2*|x|+(2*|x|^2)/(1-|x|) : 0.5*ln2
94         fyl2x                   // 0.5*ln2*ld(1+2*|x|+(2*|x|^2)/(1-|x|))
95         jecxz   3f
96         fchs                    // 0.5*ln2*ld(1+2*x+(2*x^2)/(1-x))
97 3:      ret
98
99         .align ALIGNARG(4)
100 2:      faddl   MO(one)         // 1+|x| : |x| : 0.5*ln2
101         fxch                    // |x| : 1+|x| : 0.5*ln2
102         fsubrl  MO(one)         // 1-|x| : 1+|x| : 0.5*ln2
103         fdivrp                  // (1+|x|)/(1-|x|) : 0.5*ln2
104         fyl2x                   // 0.5*ln2*ld((1+|x|)/(1-|x|))
105         jecxz   3f
106         fchs                    // 0.5*ln2*ld((1+x)/(1-x))
107 3:      ret
108
109         // x == NaN or ±Inf
110 5:      cmpl    $0x80000000, 8(%esp)
111         ja      6f
112         cmpl    $0, 4(%esp)
113         je      7b
114 6:      fldt    4(%esp)
115         ret
116 END(__ieee754_atanhl)
117 strong_alias (__ieee754_atanhl, __atanhl_finite)