Blame sysdeps/x86_64/fpu/e_log10l.S

Packit 6c4009
/*
Packit 6c4009
 * Written by J.T. Conklin <jtc@netbsd.org>.
Packit 6c4009
 * Public domain.
Packit 6c4009
 *
Packit 6c4009
 * Adapted for `long double' by Ulrich Drepper <drepper@cygnus.com>.
Packit 6c4009
 *
Packit 6c4009
 * Changed to use fyl2xp1 for values near 1, <drepper@cygnus.com>.
Packit 6c4009
 * Adapted for x86-64 by Andreas Jaeger <aj@suse.de>.
Packit 6c4009
 */
Packit 6c4009
Packit 6c4009
#include <machine/asm.h>
Packit 6c4009
Packit 6c4009
	.section .rodata.cst8,"aM",@progbits,8
Packit 6c4009
Packit 6c4009
	.p2align 3
Packit 6c4009
	.type one,@object
Packit 6c4009
one:	.double 1.0
Packit 6c4009
	ASM_SIZE_DIRECTIVE(one)
Packit 6c4009
	/* It is not important that this constant is precise.  It is only
Packit 6c4009
	   a value which is known to be on the safe side for using the
Packit 6c4009
	   fyl2xp1 instruction.  */
Packit 6c4009
	.type limit,@object
Packit 6c4009
limit:	.double 0.29
Packit 6c4009
	ASM_SIZE_DIRECTIVE(limit)
Packit 6c4009
Packit 6c4009
Packit 6c4009
#ifdef PIC
Packit 6c4009
# define MO(op) op##(%rip)
Packit 6c4009
#else
Packit 6c4009
# define MO(op) op
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
	.text
Packit 6c4009
ENTRY(__ieee754_log10l)
Packit 6c4009
	fldlg2			// log10(2)
Packit 6c4009
	fldt	8(%rsp)		// x : log10(2)
Packit 6c4009
	fxam
Packit 6c4009
	fnstsw
Packit 6c4009
	fld	%st		// x : x : log10(2)
Packit 6c4009
	testb	$1, %ah
Packit 6c4009
	jnz	3f		// in case x is NaN or ±Inf
Packit 6c4009
4:	fsubl	MO(one)		// x-1 : x : log10(2)
Packit 6c4009
	fld	%st		// x-1 : x-1 : x : log10(2)
Packit 6c4009
	fabs			// |x-1| : x-1 : x : log10(2)
Packit 6c4009
	fcompl	MO(limit)	// x-1 : x : log10(2)
Packit 6c4009
	fnstsw			// x-1 : x : log10(2)
Packit 6c4009
	andb	$0x45, %ah
Packit 6c4009
	jz	2f
Packit 6c4009
	fxam
Packit 6c4009
	fnstsw
Packit 6c4009
	andb	$0x45, %ah
Packit 6c4009
	cmpb	$0x40, %ah
Packit 6c4009
	jne	5f
Packit 6c4009
	fabs			// log10(1) is +0 in all rounding modes.
Packit 6c4009
5:	fstp	%st(1)		// x-1 : log10(2)
Packit 6c4009
	fyl2xp1			// log10(x)
Packit 6c4009
	ret
Packit 6c4009
Packit 6c4009
2:	fstp	%st(0)		// x : log10(2)
Packit 6c4009
	fyl2x			// log10(x)
Packit 6c4009
	ret
Packit 6c4009
Packit 6c4009
3:	testb	$4, %ah
Packit 6c4009
	jnz	4b		// in case x is ±Inf
Packit 6c4009
	fstp	%st(1)
Packit 6c4009
	fstp	%st(1)
Packit 6c4009
	fadd	%st(0)
Packit 6c4009
	ret
Packit 6c4009
END(__ieee754_log10l)
Packit 6c4009
Packit 6c4009
Packit 6c4009
ENTRY(__log10l_finite)
Packit 6c4009
	fldlg2			// log10(2)
Packit 6c4009
	fldt	8(%rsp)		// x : log10(2)
Packit 6c4009
	fld	%st		// x : x : log10(2)
Packit 6c4009
4:	fsubl	MO(one)		// x-1 : x : log10(2)
Packit 6c4009
	fld	%st		// x-1 : x-1 : x : log10(2)
Packit 6c4009
	fabs			// |x-1| : x-1 : x : log10(2)
Packit 6c4009
	fcompl	MO(limit)	// x-1 : x : log10(2)
Packit 6c4009
	fnstsw			// x-1 : x : log10(2)
Packit 6c4009
	andb	$0x45, %ah
Packit 6c4009
	jz	2b
Packit 6c4009
	fxam
Packit 6c4009
	fnstsw
Packit 6c4009
	andb	$0x45, %ah
Packit 6c4009
	cmpb	$0x40, %ah
Packit 6c4009
	jne	6f
Packit 6c4009
	fabs			// log10(1) is +0 in all rounding modes.
Packit 6c4009
6:	fstp	%st(1)		// x-1 : log10(2)
Packit 6c4009
	fyl2xp1			// log10(x)
Packit 6c4009
	ret
Packit 6c4009
END(__log10l_finite)