]>
Commit | Line | Data |
---|---|---|
f7eac6eb | 1 | /* |
f7eac6eb RM |
2 | * Public domain. |
3 | */ | |
4 | ||
5 | #include <machine/asm.h> | |
220622dd | 6 | #include <libm-alias-finite.h> |
f7eac6eb | 7 | |
0ac5ae23 | 8 | .section .rodata.cst8,"aM",@progbits,8 |
622c86f4 | 9 | |
0ac5ae23 | 10 | .p2align 3 |
b67e9372 | 11 | .type one,@object |
d38cd08c UD |
12 | one: .double 1.0 |
13 | ASM_SIZE_DIRECTIVE(one) | |
14 | /* It is not important that this constant is precise. It is only | |
15 | a value which is known to be on the safe side for using the | |
16 | fyl2xp1 instruction. */ | |
b67e9372 | 17 | .type limit,@object |
d38cd08c UD |
18 | limit: .double 0.29 |
19 | ASM_SIZE_DIRECTIVE(limit) | |
20 | ||
21 | ||
22 | #ifdef PIC | |
0ac5ae23 | 23 | # define MO(op) op##@GOTOFF(%edx) |
d38cd08c | 24 | #else |
0ac5ae23 | 25 | # define MO(op) op |
d38cd08c UD |
26 | #endif |
27 | ||
28 | .text | |
f7eac6eb | 29 | ENTRY(__ieee754_log) |
d38cd08c UD |
30 | fldln2 // log(2) |
31 | fldl 4(%esp) // x : log(2) | |
6b2665f5 UD |
32 | fxam |
33 | fnstsw | |
d38cd08c | 34 | #ifdef PIC |
fee732e5 | 35 | LOAD_PIC_REG (dx) |
d38cd08c UD |
36 | #endif |
37 | fld %st // x : x : log(2) | |
6b2665f5 UD |
38 | sahf |
39 | jc 3f // in case x is NaN or +-Inf | |
40 | 4: fsubl MO(one) // x-1 : x : log(2) | |
d38cd08c UD |
41 | fld %st // x-1 : x-1 : x : log(2) |
42 | fabs // |x-1| : x-1 : x : log(2) | |
43 | fcompl MO(limit) // x-1 : x : log(2) | |
44 | fnstsw // x-1 : x : log(2) | |
0d8733c4 UD |
45 | andb $0x45, %ah |
46 | jz 2f | |
f7be7376 JM |
47 | fxam |
48 | fnstsw | |
49 | andb $0x45, %ah | |
50 | cmpb $0x40, %ah | |
51 | jne 5f | |
52 | fabs // log(1) is +0 in all rounding modes. | |
53 | 5: fstp %st(1) // x-1 : log(2) | |
d38cd08c UD |
54 | fyl2xp1 // log(x) |
55 | ret | |
56 | ||
6bc31da0 | 57 | 2: fstp %st(0) // x : log(2) |
d38cd08c | 58 | fyl2x // log(x) |
f7eac6eb | 59 | ret |
6b2665f5 UD |
60 | |
61 | 3: jp 4b // in case x is +-Inf | |
62 | fstp %st(1) | |
63 | fstp %st(1) | |
64 | ret | |
d38cd08c | 65 | END (__ieee754_log) |
38ad40ce UD |
66 | |
67 | ENTRY(__log_finite) | |
68 | fldln2 // log(2) | |
69 | fldl 4(%esp) // x : log(2) | |
70 | #ifdef PIC | |
71 | LOAD_PIC_REG (dx) | |
72 | #endif | |
73 | fld %st // x : x : log(2) | |
74 | fsubl MO(one) // x-1 : x : log(2) | |
75 | fld %st // x-1 : x-1 : x : log(2) | |
76 | fabs // |x-1| : x-1 : x : log(2) | |
77 | fcompl MO(limit) // x-1 : x : log(2) | |
78 | fnstsw // x-1 : x : log(2) | |
79 | andb $0x45, %ah | |
80 | jz 2b | |
01189b08 JM |
81 | fxam |
82 | fnstsw | |
83 | andb $0x45, %ah | |
84 | cmpb $0x40, %ah | |
85 | jne 6f | |
86 | fabs // log(1) is +0 in all rounding modes. | |
87 | 6: fstp %st(1) // x-1 : log(2) | |
38ad40ce UD |
88 | fyl2xp1 // log(x) |
89 | ret | |
90 | END(__log_finite) | |
220622dd | 91 | libm_alias_finite (__log_finite, __log) |