1 | /* |
2 | * Public domain. |
3 | * |
4 | * Adapted for i686 instructions. |
5 | */ |
6 | |
7 | #include <machine/asm.h> |
8 | #include <libm-alias-finite.h> |
9 | |
10 | .section .rodata.cst8,"aM" ,@progbits,8 |
11 | |
12 | .p2align 3 |
13 | .type one,@object |
14 | one: .double 1.0 |
15 | ASM_SIZE_DIRECTIVE(one) |
16 | /* It is not important that this constant is precise. It is only |
17 | a value which is known to be on the safe side for using the |
18 | fyl2xp1 instruction. */ |
19 | .type limit,@object |
20 | limit: .double 0.29 |
21 | ASM_SIZE_DIRECTIVE(limit) |
22 | |
23 | |
24 | #ifdef PIC |
25 | # define MO(op) op##@GOTOFF(%edx) |
26 | #else |
27 | # define MO(op) op |
28 | #endif |
29 | |
30 | .text |
31 | ENTRY(__ieee754_logl) |
32 | fldln2 // log(2) |
33 | fldt 4(%esp) // x : log(2) |
34 | fucomi %st |
35 | jp 3f |
36 | #ifdef PIC |
37 | LOAD_PIC_REG (dx) |
38 | #endif |
39 | fld %st // x : x : log(2) |
40 | movzwl 4+8(%esp), %eax |
41 | cmpl $0xc000, %eax |
42 | jae 5f // x <= -2, avoid overflow from -LDBL_MAX - 1. |
43 | fsubl MO(one) // x-1 : x : log(2) |
44 | 5: fld %st // x-1 : x-1 : x : log(2) |
45 | fabs // |x-1| : x-1 : x : log(2) |
46 | fldl MO(limit) // 0.29 : |x-1| : x-1 : x : log(2) |
47 | fcomip %st(1) // |x-1| : x-1 : x : log(2) |
48 | fstp %st(0) // x-1 : x : log(2) |
49 | jc 2f |
50 | fxam |
51 | fnstsw |
52 | andb $0x45, %ah |
53 | cmpb $0x40, %ah |
54 | jne 4f |
55 | fabs // log(1) is +0 in all rounding modes. |
56 | 4: fstp %st(1) // x-1 : log(2) |
57 | fyl2xp1 // log(x) |
58 | ret |
59 | |
60 | 2: fstp %st(0) // x : log(2) |
61 | fyl2x // log(x) |
62 | ret |
63 | |
64 | 3: fstp %st(1) |
65 | fadd %st(0) |
66 | ret |
67 | END (__ieee754_logl) |
68 | |
69 | ENTRY(__logl_finite) |
70 | fldln2 // log(2) |
71 | fldt 4(%esp) // x : log(2) |
72 | #ifdef PIC |
73 | LOAD_PIC_REG (dx) |
74 | #endif |
75 | fld %st // x : x : log(2) |
76 | fsubl MO(one) // x-1 : x : log(2) |
77 | fld %st // x-1 : x-1 : x : log(2) |
78 | fabs // |x-1| : x-1 : x : log(2) |
79 | fldl MO(limit) // 0.29 : |x-1| : x-1 : x : log(2) |
80 | fcomip %st(1) // |x-1| : x-1 : x : log(2) |
81 | fstp %st(0) // x-1 : x : log(2) |
82 | jc 2b |
83 | fxam |
84 | fnstsw |
85 | andb $0x45, %ah |
86 | cmpb $0x40, %ah |
87 | jne 6f |
88 | fabs // log(1) is +0 in all rounding modes. |
89 | 6: fstp %st(1) // x-1 : log(2) |
90 | fyl2xp1 // log(x) |
91 | ret |
92 | END(__logl_finite) |
93 | libm_alias_finite (__logl_finite, __logl) |
94 | |