Support mcount/gprof test with GCC defaulting to PIE
[glibc.git] / sysdeps / i386 / fpu / e_scalbf.S
blob4f2dfa3acf7287dafcf8a1f7c41be6609c5e1754
1 /*
2  * Written by J.T. Conklin <jtc@netbsd.org>.
3  * Public domain.
4  * Adapted for float type by Ulrich Drepper <drepper@cygnus.com>.
5  *
6  * Correct handling of y==-inf <drepper@gnu>
7  */
9 #include <machine/asm.h>
10 #include <i386-math-asm.h>
12         .section .rodata
14         .align ALIGNARG(4)
15         .type zero_nan,@object
16 zero_nan:
17         .double 0.0
18 nan:    .byte 0, 0, 0, 0, 0, 0, 0xff, 0x7f
19         .byte 0, 0, 0, 0, 0, 0, 0, 0x80
20         .byte 0, 0, 0, 0, 0, 0, 0xff, 0x7f
21         ASM_SIZE_DIRECTIVE(zero_nan)
24 #ifdef PIC
25 # define MO(op) op##@GOTOFF(%ecx)
26 # define MOX(op,x,f) op##@GOTOFF(%ecx,x,f)
27 #else
28 # define MO(op) op
29 # define MOX(op,x,f) op(,x,f)
30 #endif
33         .text
34 ENTRY(__ieee754_scalbf)
35         flds    8(%esp)
36         fxam
37         fnstsw
38         flds    4(%esp)
39         andl    $0x4700, %eax
40         cmpl    $0x0700, %eax
41         je      1f
42         andl    $0x4500, %eax
43         cmpl    $0x0100, %eax
44         je      2f
45         fxam
46         fnstsw
47         andl    $0x4500, %eax
48         cmpl    $0x0100, %eax
49         je      3f
50         fld     %st(1)
51         frndint
52         fcomp   %st(2)
53         fnstsw
54         sahf
55         jne     4f
56         fscale
57         fstp    %st(1)
58         FLT_NARROW_EVAL
59         ret
61         /* y is -inf */
62 1:      fxam
63 #ifdef  PIC
64         LOAD_PIC_REG (cx)
65 #endif
66         fnstsw
67         movl    4(%esp), %edx
68         shrl    $5, %eax
69         fstp    %st
70         fstp    %st
71         andl    $0x80000000, %edx
72         andl    $0x0228, %eax
73         cmpl    $0x0028, %eax
74         je      4f
75         andl    $8, %eax
76         shrl    $27, %edx
77         addl    %edx, %eax
78         fldl    MOX(zero_nan, %eax, 1)
79         ret
81         /* The result is NaN, but we must not raise an exception.
82            So use a variable.  */
83 2:      fstp    %st
84         fstp    %st
85 #ifdef  PIC
86         LOAD_PIC_REG (cx)
87 #endif
88         fldl    MO(nan)
89         ret
91         /* The first parameter is a NaN.  Return it.  */
92 3:      fstp    %st(1)
93         ret
95         /* Return NaN and raise the invalid exception.  */
96 4:      fstp    %st
97         fstp    %st
98         fldz
99         fdiv    %st
100         ret
101 END(__ieee754_scalbf)
102 strong_alias (__ieee754_scalbf, __scalbf_finite)