* sysdeps/unix/sysv/linux/m68k/sysdep.h (INLINE_SYSCALL): Don't
[glibc.git] / sysdeps / ia64 / fpu / libm_frexp4l.S
blob4dfd22370479bbc30d4c8295570a2f16e4eef234
1 .file "libm_frexp_4l.s"
3 // Copyright (c) 2000, 2001, Intel Corporation
4 // All rights reserved.
5 // 
6 // Contributed 2/2/2000 by John Harrison, Ted Kubaska, Bob Norin, Shane Story,
7 // and Ping Tak Peter Tang of the Computational Software Lab, Intel Corporation.
8 // 
9 // WARRANTY DISCLAIMER
10 // 
11 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
12 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
13 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
14 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR ITS 
15 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
16 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
17 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
18 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 
19 // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR TORT (INCLUDING
20 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
21 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
22 // 
23 // Intel Corporation is the author of this code, and requests that all
24 // problem reports or change requests be submitted to it directly at 
25 // http://developer.intel.com/opensource.
27 // History
28 //==============================================================
29 // 3/20/00: Initial version
30 // 6/01/00: Fixed bug when x a double-extended denormal
31 // 12/08/00 Corrected label on .endp
33 // API
34 //==============================================================
35 // long double frexpl(long double x, int* y)
36 // long double __libm_frexp_4l(long double x, int* y)
37 //   where int* y is a 32-bit integer
39 // Overview of operation
40 //==============================================================
41 // break a floating point x number into fraction and an exponent
42 // The fraction is returned as a long double
43 // The exponent is returned as an integer pointed to by y
44 //    This is a true (not a biased exponent) but 0fffe is subtracted
45 //    as a bias instead of 0xffff. This is because the fraction returned
46 //    is between 0.5 and 1.0, not the expected IEEE range.
48 // The fraction is 0.5 <= fraction < 1.0
50 // Registers used
51 //==============================================================
53 // general registers: 
54 // r14  exponent bias for x negative
55 // r15  exponent bias for x positive
56 // r16  signexp of x
57 // r17  exponent mask
58 // r18  exponent of x
59 // r19  exponent result
60 // r20  signexp of 2^64
61 // r32-33  on input contains the 80-bit IEEE long double that is in f8
62 // r34  on input pointer to 32-bit integer for exponent
64 // predicate registers:
65 // p6   set if x is Nan, zero, or infinity
66 // p7   set if x negative
67 // p8   set if x positive
68 // p9   set if x double-extended denormal
70 // floating-point registers:
71 // f8  input, output
72 // f9  normalized x
73 // f10 signexp for significand result for x positive
74 // f11 signexp for significand result for x negative
75 // f12 2^64
77 #include "libm_support.h"
79 .align 32
80 .global __libm_frexp_4l#
82 .section .text
83 .proc  __libm_frexp_4l#
84 .align 32
86 __libm_frexp_4l: 
88 // Set signexp for significand result for x>0
89 // If x is a NaN, zero, or infinity, return it.
90 // Put 0 in the int pointer.
91 // x NAN, ZERO, INFINITY?
92 // Set signexp for significand result for x<0
93 { .mfi
94 (p0)    mov         r15 = 0x0fffe
95 (p0)    fclass.m.unc p6,p0 = f8, 0xe7
96 (p0)    mov         r14 = 0x2fffe
98 // Form signexp of 2^64 in case x double-extended denormal
99 // Save the normalized value of input in f9
100 // The normalization also sets fault flags and takes faults if necessary
101 { .mfi
102 (p0)    mov         r20 = 0x1003f
103 (p0)    fnorm       f9 = f8 
104         nop.i 999 ;;
107 // Move signexp for significand result for x>0 to FP reg
108 // Form 2^64 in case x double-extended denormal
109 { .mmi
110 (p0)    setf.exp    f10 = r15
111 (p0)    setf.exp    f12 = r20
112         nop.i 999 ;;
115 // Move signexp for significand result for x<0 to FP reg
116 // If x NAN, ZERO, INFINITY, set *y=0 as a 32-bit integer, and exit
117 { .mmb
118 (p0)    setf.exp    f11 = r14
119 (p6)    st4         [r34] = r0
120 (p6)    br.ret.spnt b0 ;;
123 // Form exponent mask
124 // p7 if x<0, else p8
125 { .mfi
126 (p0)    mov         r17 = 0x1ffff
127 (p0)    fcmp.lt.unc p7,p8 = f8,f0
128         nop.i 999 ;;
131 // Test for fnorm(x) denormal, means x double-extended denormal
132 { .mfi
133         nop.m 999
134 (p0)    fclass.m.unc p9,p0 = f9, 0x0b
135         nop.i 999 ;;
138 // If x double-extended denormal add 64 to exponent bias for scaling
139 // If x double-extended denormal multiply x * 2^64 which is normal
140 { .mfi
141 (p9)    add         r15 = 64, r15
142 (p9)    fmpy        f9 = f9, f12
143         nop.i 999 ;;
146 // true exponent stored to int pointer
147 // the bias is treated as 0xfffe instead of 
148 // normal 0xffff because we want the significand
149 // to be in the range <=0.5 sig < 1.0
150 // Store the value of the exponent at the pointer in r34
152 // If x>0 form significand result 
153 { .mfi
154         nop.m 999
155 (p8)    fmerge.se   f8 = f10,f9
156         nop.i 999  ;;
159 // Get signexp of normalized x
160 // If x<0 form significand result 
161 { .mfi
162 (p0)    getf.exp    r16 = f9
163 (p7)    fmerge.se   f8 = f11,f9
164         nop.i 999  ;;
167 // Get exp of normalized x
168 // Subtract off bias to get true exponent of x
169 { .mmi
170 (p0)    and         r18 = r17,r16 ;;
171 (p0)    sub         r19 = r18,r15
172         nop.i 999  ;;
175 // Store int y as a 32-bit integer
176 // Make the value a long double
177 { .mfb
178 (p0)    st4         [r34] = r19
179 (p0)    fnorm       f8 = f8
180 (p0)    br.ret.sptk b0 ;;
183 .endp __libm_frexp_4l
184 ASM_SIZE_DIRECTIVE(__libm_frexp_4l)