Get rid of ASM_TYPE_DIRECTIVE{,_PREFIX}.
[platform/upstream/glibc.git] / sysdeps / i386 / fpu / s_expm1f.S
1 /* ix87 specific implementation of exp(x)-1.
2    Copyright (C) 1996-1997, 2005, 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    Based on code by John C. Bowman <bowman@ipp-garching.mpg.de>.
6    Corrections by H.J. Lu (hjl@gnu.ai.mit.edu), 1997.
7
8    The GNU C Library is free software; you can redistribute it and/or
9    modify it under the terms of the GNU Lesser General Public
10    License as published by the Free Software Foundation; either
11    version 2.1 of the License, or (at your option) any later version.
12
13    The GNU C Library is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16    Lesser General Public License for more details.
17
18    You should have received a copy of the GNU Lesser General Public
19    License along with the GNU C Library; if not, see
20    <http://www.gnu.org/licenses/>.  */
21
22         /* Using: e^x - 1 = 2^(x * log2(e)) - 1 */
23
24 #include <sysdep.h>
25 #include <machine/asm.h>
26
27         .section .rodata
28
29         .align ALIGNARG(4)
30         .type minus1,@object
31 minus1: .double -1.0
32         ASM_SIZE_DIRECTIVE(minus1)
33         .type one,@object
34 one:    .double 1.0
35         ASM_SIZE_DIRECTIVE(one)
36         .type l2e,@object
37 l2e:    .tfloat 1.442695040888963407359924681002
38         ASM_SIZE_DIRECTIVE(l2e)
39
40 #ifdef PIC
41 #define MO(op) op##@GOTOFF(%edx)
42 #else
43 #define MO(op) op
44 #endif
45
46         .text
47 ENTRY(__expm1f)
48         movzwl  4+2(%esp), %eax
49         xorb    $0x80, %ah      // invert sign bit (now 1 is "positive")
50         cmpl    $0xc2b1, %eax   // is num >= 88.5?
51         jae     HIDDEN_JUMPTARGET (__expf)
52
53         flds    4(%esp)         // x
54         fxam                    // Is NaN, +-Inf or +-0?
55         xorb    $0x80, %ah
56         cmpl    $0xc190, %eax   // is num <= -18.0?
57         fstsw   %ax
58         movb    $0x45, %ch
59         jb      4f
60
61         // Below -18.0 (may be -NaN or -Inf).
62         andb    %ah, %ch
63 #ifdef  PIC
64         LOAD_PIC_REG (dx)
65 #endif
66         cmpb    $0x01, %ch
67         je      5f              // If -NaN, jump.
68         jmp     2f              // -large, possibly -Inf.
69
70 4:      // In range -18.0 to 88.5 (may be +-0 but not NaN or +-Inf).
71         andb    %ah, %ch
72         cmpb    $0x40, %ch
73         je      3f              // If +-0, jump.
74 #ifdef  PIC
75         LOAD_PIC_REG (dx)
76 #endif
77
78 5:      fldt    MO(l2e)         // log2(e) : x
79         fmulp                   // log2(e)*x
80         fld     %st             // log2(e)*x : log2(e)*x
81         frndint                 // int(log2(e)*x) : log2(e)*x
82         fsubr   %st, %st(1)     // int(log2(e)*x) : fract(log2(e)*x)
83         fxch                    // fract(log2(e)*x) : int(log2(e)*x)
84         f2xm1                   // 2^fract(log2(e)*x)-1 : int(log2(e)*x)
85         fscale                  // 2^(log2(e)*x)-2^int(log2(e)*x) : int(log2(e)*x)
86         fxch                    // int(log2(e)*x) : 2^(log2(e)*x)-2^int(log2(e)*x)
87         fldl    MO(one)         // 1 : int(log2(e)*x) : 2^(log2(e)*x)-2^int(log2(e)*x)
88         fscale                  // 2^int(log2(e)*x) : int(log2(e)*x) : 2^(log2(e)*x)-2^int(log2(e)*x)
89         fsubrl  MO(one)         // 1-2^int(log2(e)*x) : int(log2(e)*x) : 2^(log2(e)*x)-2^int(log2(e)*x)
90         fstp    %st(1)          // 1-2^int(log2(e)*x) : 2^(log2(e)*x)-2^int(log2(e)*x)
91         fsubrp  %st, %st(1)     // 2^(log2(e)*x)
92         ret
93
94 2:      fstp    %st
95         fldl    MO(minus1)      // Set result to -1.0.
96 3:      ret
97 END(__expm1f)
98 weak_alias (__expm1f, expm1f)