Remove support in configure for unsupported architectures
[glibc.git] / sysdeps / ia64 / fpu / libm_frexpf.S
blobdde2d09b4b97c292e8cfc06d5158f54562f3b276
1 .file "libm_frexpf.s"
4 // Copyright (c) 2000 - 2003, Intel Corporation
5 // All rights reserved.
6 //
7 // Contributed 2000 by the Intel Numerics Group, Intel Corporation
8 //
9 // Redistribution and use in source and binary forms, with or without
10 // modification, are permitted provided that the following conditions are
11 // met:
13 // * Redistributions of source code must retain the above copyright
14 // notice, this list of conditions and the following disclaimer.
16 // * Redistributions in binary form must reproduce the above copyright
17 // notice, this list of conditions and the following disclaimer in the
18 // documentation and/or other materials provided with the distribution.
20 // * The name of Intel Corporation may not be used to endorse or promote
21 // products derived from this software without specific prior written
22 // permission.
24 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
25 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
26 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR ITS 
28 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
29 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
30 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
31 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 
32 // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR TORT (INCLUDING
33 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
34 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
35 // 
36 // Intel Corporation is the author of this code, and requests that all
37 // problem reports or change requests be submitted to it directly at 
38 // http://www.intel.com/software/products/opensource/libraries/num.htm.
40 // History
41 //==============================================================
42 // 02/02/00 Initial version
43 // 03/20/00 Improved speed
44 // 06/01/00 Fixed bug when x a double-extended denormal
45 // 12/08/00 Corrected label on .endp
46 // 01/23/02 Added handling for int 32 or 64 bits
47 // 05/20/02 Cleaned up namespace and sf0 syntax
48 // 02/10/03 Reordered header: .section, .global, .proc, .align
50 // API
51 //==============================================================
52 // float __libm_frexpf(float x, int* y, int int_type)
53 // input  floating point f8, pointer to y (r33), int int_type (r34)
54 // output floating point f8, returns the fraction of x, 0.5 <= fraction < 1.0
55 // output int* y, returns the true exponent of x
57 // int_type = 0 if int is 32 bits
58 // int_type = 1 if int is 64 bits
60 // int* y is returned as a 32 bit integer if int_type = 0
61 // int* y is returned as a 64 bit integer if int_type = 1
63 // Overview of operation
64 //==============================================================
65 // break a floating point x number into fraction and an exponent
66 // The fraction is returned as a float
67 // The exponent is returned as an integer pointed to by y
68 //    This is a true (not a biased exponent) but 0fffe is subtracted
69 //    as a bias instead of 0xffff. This is because the fraction returned
70 //    is between 0.5 and 1.0, not the expected IEEE range.
72 // The fraction is 0.5 <= fraction < 1.0
74 // Registers used
75 //==============================================================
77 // general registers: 
78 // r14  exponent bias for x negative
79 // r15  exponent bias for x positive
80 // r16  signexp of x
81 // r17  exponent mask
82 // r18  exponent of x
83 // r19  exponent result
84 // r20  signexp of 2^64
85 // r32  on input contains the 32-bit IEEE float that is in f8
86 // r33  on input pointer to 32-bit or 64-bit integer for exponent
87 // r34  on input contains 0 if output int is 32 bits, else output int is 64 bits
89 // predicate registers:
90 // p6   set if x is Nan, zero, or infinity
91 // p7   set if x negative
92 // p8   set if x positive
93 // p9   set if x double-extended denormal
94 // p10  set if int_type = 0, 32-bit integer
95 // p11  set if int_type = 1, 64-bit integer
97 // floating-point registers:
98 // f8  input, output
99 // f9  normalized x
100 // f10 signexp for significand result for x positive
101 // f11 signexp for significand result for x negative
102 // f12 2^64
104 .section .text
105 GLOBAL_LIBM_ENTRY(__libm_frexpf)
107 // Set signexp for significand result for x>0
108 // If x is a NaN, zero, or infinity, return it.
109 // Put 0 in the int pointer.
110 // x NAN, ZERO, INFINITY?
111 // Set signexp for significand result for x<0
112 { .mfi
113         mov         r15 = 0x0fffe
114         fclass.m    p6,p7 = f8, 0xe7
115         mov         r14 = 0x2fffe
117 // Form signexp of 2^64 in case x double-extended denormal
118 // Save the normalized value of input in f9
119 // The normalization also sets fault flags and takes faults if necessary
120 { .mfi
121         mov         r20 = 0x1003f
122         fnorm.s0    f9 = f8 
123         nop.i 999 ;;
126 // Move signexp for significand result for x>0 to FP reg
127 // Form 2^64 in case x double-extended denormal
128 { .mmi
129         setf.exp    f10 = r15
130         setf.exp    f12 = r20
131         nop.i 999 ;;
134 // Move signexp for significand result for x<0 to FP reg
135 // p7 if x<0, else p8
136 // If x=0,nan,inf, set p10 if output int to be 32 bits, or set p11 if 64 bits
137 { .mfi
138         setf.exp    f11 = r14
139 (p7)    fcmp.lt.s0  p7,p8 = f8,f0
140 (p6)    cmp.eq.unc  p10,p11 = r34, r0 ;; 
143 // If x NAN, ZERO, INFINITY, set *y=0 and exit
144 { .mmb
145 (p10)   st4         [r33] = r0      // Store *y=0 as 32-bit integer
146 (p11)   st8         [r33] = r0      // Store *y=0 as 64-bit integer
147 (p6)    br.ret.spnt b0 ;;
150 // Form exponent mask
151 // Test for fnorm(x) denormal, means x double-extended denormal
152 { .mfi
153         mov         r17 = 0x1ffff
154         fclass.m    p9,p0 = f9, 0x0b
155         nop.i 999 ;;
158 // If x double-extended denormal add 64 to exponent bias for scaling
159 // If x double-extended denormal multiply x * 2^64 which is normal
160 // Set p10 if output int to be 32 bits, or set p11 if 64 bits
161 { .mfi
162 (p9)    add         r15 = 64, r15
163 (p9)    fmpy.s0     f9 = f9, f12
164         cmp.eq      p10,p11 = r34, r0 ;; 
167 // true exponent stored to int pointer
168 // the bias is treated as 0xfffe instead of 
169 // normal 0xffff because we want the significand
170 // to be in the range <=0.5 sig < 1.0
171 // Store the value of the exponent at the pointer in r33
173 // If x>0 form significand result 
174 { .mfi
175         nop.m 999
176 (p8)    fmerge.se   f8 = f10,f9
177         nop.i 999  ;;
180 // Get signexp of normalized x
181 // If x<0 form significand result 
182 { .mfi
183         getf.exp    r16 = f9
184 (p7)    fmerge.se   f8 = f11,f9
185         nop.i 999  ;;
188 // Get exp of normalized x
189 // Subtract off bias to get true exponent of x
190 { .mmi
191         and         r18 = r17,r16 ;;
192         sub         r19 = r18,r15
193         nop.i 999  ;;
196 // Store int *y as a 32-bit integer
197 // Make the value a float
198 { .mfi
199 (p10)   st4         [r33] = r19        // Store *y as 32-bit integer
200         fnorm.s.s0  f8 = f8
201         nop.i 999
203 { .mfb
204 (p11)   st8         [r33] = r19        // Store *y as 64-bit integer
205         nop.f 999
206         br.ret.sptk b0 ;;
209 GLOBAL_LIBM_END(__libm_frexpf)