]>
Commit | Line | Data |
---|---|---|
f7eac6eb RM |
1 | /* |
2 | * Written by J.T. Conklin <jtc@netbsd.org>. | |
3 | * Public domain. | |
d38cd08c UD |
4 | * |
5 | * Changed to use fyl2xp1 for values near 1, <drepper@cygnus.com>. | |
f7eac6eb RM |
6 | */ |
7 | ||
8 | #include <machine/asm.h> | |
9 | ||
d38cd08c | 10 | #ifdef __ELF__ |
0ac5ae23 | 11 | .section .rodata.cst8,"aM",@progbits,8 |
d38cd08c UD |
12 | #else |
13 | .text | |
14 | #endif | |
0ac5ae23 | 15 | .p2align 3 |
d38cd08c UD |
16 | ASM_TYPE_DIRECTIVE(one,@object) |
17 | one: .double 1.0 | |
18 | ASM_SIZE_DIRECTIVE(one) | |
19 | /* It is not important that this constant is precise. It is only | |
20 | a value which is known to be on the safe side for using the | |
21 | fyl2xp1 instruction. */ | |
22 | ASM_TYPE_DIRECTIVE(limit,@object) | |
23 | limit: .double 0.29 | |
24 | ASM_SIZE_DIRECTIVE(limit) | |
25 | ||
26 | ||
27 | #ifdef PIC | |
0ac5ae23 | 28 | # define MO(op) op##@GOTOFF(%edx) |
d38cd08c | 29 | #else |
0ac5ae23 | 30 | # define MO(op) op |
d38cd08c UD |
31 | #endif |
32 | ||
33 | .text | |
f7eac6eb | 34 | ENTRY(__ieee754_log) |
d38cd08c UD |
35 | fldln2 // log(2) |
36 | fldl 4(%esp) // x : log(2) | |
6b2665f5 UD |
37 | fxam |
38 | fnstsw | |
d38cd08c | 39 | #ifdef PIC |
fee732e5 | 40 | LOAD_PIC_REG (dx) |
d38cd08c UD |
41 | #endif |
42 | fld %st // x : x : log(2) | |
6b2665f5 UD |
43 | sahf |
44 | jc 3f // in case x is NaN or +-Inf | |
45 | 4: fsubl MO(one) // x-1 : x : log(2) | |
d38cd08c UD |
46 | fld %st // x-1 : x-1 : x : log(2) |
47 | fabs // |x-1| : x-1 : x : log(2) | |
48 | fcompl MO(limit) // x-1 : x : log(2) | |
49 | fnstsw // x-1 : x : log(2) | |
0d8733c4 UD |
50 | andb $0x45, %ah |
51 | jz 2f | |
d38cd08c UD |
52 | fstp %st(1) // x-1 : log(2) |
53 | fyl2xp1 // log(x) | |
54 | ret | |
55 | ||
6bc31da0 | 56 | 2: fstp %st(0) // x : log(2) |
d38cd08c | 57 | fyl2x // log(x) |
f7eac6eb | 58 | ret |
6b2665f5 UD |
59 | |
60 | 3: jp 4b // in case x is +-Inf | |
61 | fstp %st(1) | |
62 | fstp %st(1) | |
63 | ret | |
d38cd08c | 64 | END (__ieee754_log) |
0ac5ae23 | 65 | strong_alias (__ieee754_log, __log_finite) |