1 | /* |
2 | * Written by J.T. Conklin <jtc@netbsd.org>. |
3 | * Public domain. |
4 | * |
5 | * Adapted for `long double' by Ulrich Drepper <drepper@cygnus.com>. |
6 | * Adapted for x86-64 by Andreas Jaeger <aj@suse.de> |
7 | * |
8 | * Correct handling of y==-inf <drepper@gnu> |
9 | */ |
10 | |
11 | #include <machine/asm.h> |
12 | #include <libm-alias-finite.h> |
13 | |
14 | .section .rodata |
15 | |
16 | .align ALIGNARG(4) |
17 | .type zero_nan,@object |
18 | zero_nan: |
19 | .double 0.0 |
20 | nan: .byte 0, 0, 0, 0, 0, 0, 0xff, 0x7f |
21 | .byte 0, 0, 0, 0, 0, 0, 0, 0x80 |
22 | .byte 0, 0, 0, 0, 0, 0, 0xff, 0x7f |
23 | ASM_SIZE_DIRECTIVE(zero_nan) |
24 | |
25 | |
26 | #ifdef PIC |
27 | # define MO(op) op##(%rip) |
28 | #else |
29 | # define MO(op) op |
30 | #endif |
31 | |
32 | .text |
33 | ENTRY(__ieee754_scalbl) |
34 | fldt 24(%rsp) |
35 | fxam |
36 | fnstsw |
37 | fldt 8(%rsp) |
38 | andl $0x4700, %eax |
39 | cmpl $0x0700, %eax |
40 | je 1f |
41 | andl $0x4500, %eax |
42 | cmpl $0x0100, %eax |
43 | je 2f |
44 | fxam |
45 | fnstsw |
46 | andl $0x4500, %eax |
47 | cmpl $0x0100, %eax |
48 | je 2f |
49 | fld %st(1) |
50 | frndint |
51 | fcomip %st(2), %st |
52 | jne 4f |
53 | fscale |
54 | fstp %st(1) |
55 | ret |
56 | |
57 | /* y is -inf */ |
58 | 1: fxam |
59 | fnstsw |
60 | movl 16(%rsp), %edx |
61 | shrl $5, %eax |
62 | fstp %st |
63 | fstp %st |
64 | andl $0x8000, %edx |
65 | andl $0x0228, %eax |
66 | cmpl $0x0028, %eax |
67 | je 4f |
68 | andl $8, %eax |
69 | shrl $11, %edx |
70 | addl %edx, %eax |
71 | #ifdef PIC |
72 | lea zero_nan(%rip),%rdx |
73 | fldl (%rdx,%rax,1) |
74 | #else |
75 | fldl zero_nan(%rax, 1) |
76 | #endif |
77 | ret |
78 | |
79 | /* The result is NaN; raise an exception for sNaN arguments. */ |
80 | 2: faddp |
81 | ret |
82 | |
83 | /* Return NaN and raise the invalid exception. */ |
84 | 4: fstp %st |
85 | fstp %st |
86 | fldz |
87 | fdiv %st |
88 | ret |
89 | END(__ieee754_scalbl) |
90 | libm_alias_finite (__ieee754_scalbl, __scalbl) |
91 | |