this repo has no description
1/*
2 * floorl.s
3 *
4 * by Ian Ollmann
5 *
6 * Copyright (c) Apple Inc. 2007. All Rights Reserved.
7 *
8 * C99 implementation of floorl for __i386__ and __x86_64__.
9 */
10
11
12#include <machine/asm.h>
13#include "abi.h"
14
15
16ENTRY( floorl )
17 movswl 8+FRAME_SIZE( STACKP ), %eax // load signed exponent
18 movl %eax, %edx // sign + exponent
19 andl $0x7fff, %eax // exponent
20 subl $0x3fff, %eax // remove bias
21 cmpl $63, %eax // if( |x| >= 0x1.0p63 || |x| < 1.0 || isnan(x) )
22 jae 2f // goto 2
23
24 movl $63, %ecx
25 movq FRAME_SIZE( STACKP ), %xmm0 // significand
26 subl %eax, %ecx // 63 - exponent
27 pcmpeqb %xmm1, %xmm1 // -1LL
28 movd %ecx, %xmm7 // 63-exponent
29 pxor %xmm2, %xmm2 // 0
30 psubq %xmm1, %xmm2 // 1
31 movdqa %xmm2, %xmm1 // 1
32 psllq %xmm7, %xmm2 // one's bit
33 psubq %xmm1, %xmm2 // fract mask
34 pandn %xmm0, %xmm2
35 movq %xmm2, FRAME_SIZE( STACKP )
36 pcmpeqd %xmm2, %xmm0
37 pmovmskb %xmm0, %eax
38 cmp $0xffff, %eax
39 fldt FRAME_SIZE( STACKP ) // result
40 je 1f
41
42 //need to set the inexact flag and correct rounding
43 sarl $31, %edx
44 andl $0xbf800000, %edx
45 movl %edx, FRAME_SIZE(STACKP)
46 fadds FRAME_SIZE( STACKP ) // correct rounding
47
48 // set inexact
49 fldpi
50 fmul %st(0), %st(0)
51 fstp %st(0)
52
531: ret
54
55// |x| >= 0x1.0p63 || |x| < 1.0 || isnan(x)
562: jge 3f
57
58// |x| < 1.0
59 fldt FRAME_SIZE( STACKP ) // { x }
60 fldz // { 0, x }
61 fucomip %st(1), %st(0) // { x }
62 je 1b
63
64 fistpl FRAME_SIZE( STACKP )
65 fldz // { 0 }
66 fld1 // { 1, 0 }
67 fchs // { -1, 0 }
68 fcmovb %st(1), %st(0)
69 fstp %st(1)
70 ret
71
72// |x| >= 0x1.0p63 || isnan(x)
733: fldt FRAME_SIZE(STACKP)
74 fldz
75 faddp
76 ret