1 .file "libm_frexp_4f.s"
3 // Copyright (C) 2000, 2001, Intel Corporation
4 // All rights reserved.
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.
9 // Redistribution and use in source and binary forms, with or without
10 // modification, are permitted provided that the following conditions are
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
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.
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://developer.intel.com/opensource.
41 //==============================================================
42 // 2/02/00: Initial version
43 // 3/20/00: Improved speed
44 // 6/01/00: Fixed bug when x a double-extended denormal
45 // 12/08/00 Corrected label on .endp
48 //==============================================================
49 // float frexp(float x, int* y)
50 // float __libm_frexp_4f(float x, int* y)
51 // where int* y is a 32-bit integer
53 // Overview of operation
54 //==============================================================
55 // break a floating point x number into fraction and an exponent
56 // The fraction is returned as a float
57 // The exponent is returned as an integer pointed to by y
58 // This is a true (not a biased exponent) but 0fffe is subtracted
59 // as a bias instead of 0xffff. This is because the fraction returned
60 // is between 0.5 and 1.0, not the expected IEEE range.
62 // The fraction is 0.5 <= fraction < 1.0
65 //==============================================================
68 // r14 exponent bias for x negative
69 // r15 exponent bias for x positive
73 // r19 exponent result
74 // r20 signexp of 2^64
75 // r32 on input contains the 32-bit IEEE float that is in f8
76 // r33 on input pointer to 32-bit integer for exponent
78 // predicate registers:
79 // p6 set if x is Nan, zero, or infinity
80 // p7 set if x negative
81 // p8 set if x positive
82 // p9 set if x double-extended denormal
84 // floating-point registers:
87 // f10 signexp for significand result for x positive
88 // f11 signexp for significand result for x negative
91 #include "libm_support.h"
94 .global __libm_frexp_4f#
97 .proc __libm_frexp_4f#
102 // Set signexp for significand result for x>0
103 // If x is a NaN, zero, or infinity, return it.
104 // Put 0 in the int pointer.
105 // x NAN, ZERO, INFINITY?
106 // Set signexp for significand result for x<0
108 (p0) mov r15 = 0x0fffe
109 (p0) fclass.m.unc p6,p0 = f8, 0xe7
110 (p0) mov r14 = 0x2fffe
112 // Form signexp of 2^64 in case x double-extended denormal
113 // Save the normalized value of input in f9
114 // The normalization also sets fault flags and takes faults if necessary
116 (p0) mov r20 = 0x1003f
121 // Move signexp for significand result for x>0 to FP reg
122 // Form 2^64 in case x double-extended denormal
124 (p0) setf.exp f10 = r15
125 (p0) setf.exp f12 = r20
129 // Move signexp for significand result for x<0 to FP reg
130 // If x NAN, ZERO, INFINITY, set *y=0 as a 32-bit integer, and exit
132 (p0) setf.exp f11 = r14
134 (p6) br.ret.spnt b0 ;;
137 // Form exponent mask
138 // p7 if x<0, else p8
140 (p0) mov r17 = 0x1ffff
141 (p0) fcmp.lt.unc p7,p8 = f8,f0
145 // Test for fnorm(x) denormal, means x double-extended denormal
148 (p0) fclass.m.unc p9,p0 = f9, 0x0b
152 // If x double-extended denormal add 64 to exponent bias for scaling
153 // If x double-extended denormal multiply x * 2^64 which is normal
155 (p9) add r15 = 64, r15
156 (p9) fmpy f9 = f9, f12
160 // true exponent stored to int pointer
161 // the bias is treated as 0xfffe instead of
162 // normal 0xffff because we want the significand
163 // to be in the range <=0.5 sig < 1.0
164 // Store the value of the exponent at the pointer in r33
166 // If x>0 form significand result
169 (p8) fmerge.se f8 = f10,f9
173 // Get signexp of normalized x
174 // If x<0 form significand result
176 (p0) getf.exp r16 = f9
177 (p7) fmerge.se f8 = f11,f9
181 // Get exp of normalized x
182 // Subtract off bias to get true exponent of x
184 (p0) and r18 = r17,r16 ;;
185 (p0) sub r19 = r18,r15
189 // Store int y as a 32-bit integer
190 // Make the value a float
194 (p0) br.ret.sptk b0 ;;
197 .endp __libm_frexp_4f
198 ASM_SIZE_DIRECTIVE(__libm_frexp_4f)
199 strong_alias(__libm_frexp_4f, _GI___libm_frexp_4f)