about summary refs log tree commit diff
path: root/sysdeps/x86_64/fpu/e_scalbl.S
blob: 1b1b5cca266b20bbfdb6a43c53d3f4ce416e8c71 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
 * Public domain.
 */

#include <machine/asm.h>
#include <libm-alias-finite.h>

	.section .rodata

	.align ALIGNARG(4)
	.type zero_nan,@object
zero_nan:
	.double 0.0
nan:	.byte 0, 0, 0, 0, 0, 0, 0xff, 0x7f
	.byte 0, 0, 0, 0, 0, 0, 0, 0x80
	.byte 0, 0, 0, 0, 0, 0, 0xff, 0x7f
	ASM_SIZE_DIRECTIVE(zero_nan)


#ifdef PIC
# define MO(op) op##(%rip)
#else
# define MO(op) op
#endif

	.text
ENTRY(__ieee754_scalbl)
	fldt	24(%rsp)
	fxam
	fnstsw
	fldt	8(%rsp)
	andl	$0x4700, %eax
	cmpl	$0x0700, %eax
	je	1f
	andl	$0x4500, %eax
	cmpl	$0x0100, %eax
	je	2f
	fxam
	fnstsw
	andl	$0x4500, %eax
	cmpl	$0x0100, %eax
	je	2f
	fld	%st(1)
	frndint
	fcomip	%st(2), %st
	jne	4f
	fscale
	fstp	%st(1)
	ret

	/* y is -inf */
1:	fxam
	fnstsw
	movl	16(%rsp), %edx
	shrl	$5, %eax
	fstp	%st
	fstp	%st
	andl	$0x8000, %edx
	andl	$0x0228, %eax
	cmpl	$0x0028, %eax
	je	4f
	andl	$8, %eax
	shrl	$11, %edx
	addl	%edx, %eax
#ifdef PIC
	lea	zero_nan(%rip),%rdx
	fldl	(%rdx,%rax,1)
#else
	fldl	zero_nan(%rax, 1)
#endif
	ret

	/* The result is NaN; raise an exception for sNaN arguments.  */
2:	faddp
	ret

	/* Return NaN and raise the invalid exception.  */
4:	fstp	%st
	fstp	%st
	fldz
	fdiv	%st
	ret
END(__ieee754_scalbl)
libm_alias_finite (__ieee754_scalbl, __scalbl)