(CFLAGS-tst-align.c): Add -mpreferred-stack-boundary=4.
[glibc.git] / sysdeps / ia64 / fpu / s_ceilf.S
blobd1011052e8449e60bf135d5e5061c3aa73f31519
1 .file "ceilf.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 // 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://developer.intel.com/opensource.
41 #include "libm_support.h"
43 .align 32
44 .global ceilf#
46 .section .text
47 .proc  ceilf#
48 .align 32
50 // History
51 //==============================================================
52 // 2/02/00: Initial version
53 // 6/13/00: Improved speed
54 // 6/27/00: Eliminated incorrect invalid flag setting
56 // API
57 //==============================================================
58 // float ceilf(float x)
60 // general input registers:  
62 ceil_GR_FFFF      = r14
63 ceil_GR_signexp   = r15
64 ceil_GR_exponent  = r16
65 ceil_GR_expmask   = r17
66 ceil_GR_bigexp    = r18
69 // predicate registers used: 
71 // p6  ==> Input is NaN, infinity, zero
72 // p7  ==> Input is denormal
73 // p8  ==> Input is <0
74 // p9  ==> Input is >=0
75 // p10 ==> Input is already an integer (bigger than largest integer)
76 // p11 ==> Input is not a large integer
77 // p12 ==> Input is a smaller integer
78 // p13 ==> Input is not an even integer, so inexact must be set
79 // p14 ==> Input is between -1 and 0, so result will be -0 and inexact
82 // floating-point registers used: 
84 CEIL_SIGNED_ZERO  = f7
85 CEIL_NORM_f8      = f9                        
86 CEIL_FFFF         = f10 
87 CEIL_INEXACT      = f11 
88 CEIL_FLOAT_INT_f8 = f12
89 CEIL_INT_f8       = f13
90 CEIL_adj          = f14
91 CEIL_MINUS_ONE    = f15
93 // Overview of operation
94 //==============================================================
96 // float ceilf(float x)
97 // Return an integer value (represented as a float) that is the smallest 
98 // value not less than x
99 // This is x rounded toward +infinity to an integral value.
100 // Inexact is set if x != ceilf(x)
101 // **************************************************************************
103 // Set denormal flag for denormal input and
104 // and take denormal fault if necessary.
106 // Is the input an integer value already?
108 // double_extended
109 // if the exponent is > 1003e => 3F(true) = 63(decimal)
110 // we have a significand of 64 bits 1.63-bits.
111 // If we multiply by 2^63, we no longer have a fractional part
112 // So input is an integer value already.
114 // double
115 // if the exponent is >= 10033 => 34(true) = 52(decimal)
116 // 34 + 3ff = 433
117 // we have a significand of 53 bits 1.52-bits. (implicit 1)
118 // If we multiply by 2^52, we no longer have a fractional part
119 // So input is an integer value already.
121 // single
122 // if the exponent is > 10016 => 17(true) = 23(decimal)
123 // we have a significand of 24 bits 1.23-bits. (implicit 1)
124 // If we multiply by 2^23, we no longer have a fractional part
125 // So input is an integer value already.
127 // If x is NAN, ZERO, or INFINITY, then  return
129 // qnan snan inf norm     unorm 0 -+
130 // 1    1    1   0        0     1 11     0xe7
133 ceilf:
135 { .mfi
136       getf.exp ceil_GR_signexp  = f8
137       fcvt.fx.trunc.s1     CEIL_INT_f8  = f8
138       addl        ceil_GR_bigexp = 0x10016, r0
140 { .mfi
141       addl        ceil_GR_FFFF      = -1,r0
142       fcmp.lt.s1  p8,p9 = f8,f0
143       mov         ceil_GR_expmask    = 0x1FFFF ;;
146 // p7 ==> denorm
147 { .mfi
148       setf.sig    CEIL_FFFF  = ceil_GR_FFFF
149       fclass.m    p7,p0 = f8, 0x0b
150       nop.i 999
152 { .mfi
153       nop.m 999
154       fnorm           CEIL_NORM_f8  = f8
155       nop.i 999 ;;
158 // Form 0 with sign of input in case negative zero is needed
159 { .mfi
160       nop.m 999
161       fmerge.s           CEIL_SIGNED_ZERO = f8, f0
162       nop.i 999
164 { .mfi
165       nop.m 999
166       fsub.s1           CEIL_MINUS_ONE = f0, f1
167       nop.i 999 ;;
170 // p6 ==> NAN, INF, ZERO
171 { .mfb
172       nop.m 999
173       fclass.m      p6,p10 = f8, 0xe7
174 (p7)  br.cond.spnt  L(CEIL_DENORM) ;;
177 L(CEIL_COMMON):
178 .pred.rel "mutex",p8,p9
179 // Set adjustment to add to trunc(x) for result
180 //   If x>0,  adjustment is 1.0
181 //   If x<=0, adjustment is 0.0
182 { .mfi
183       and      ceil_GR_exponent = ceil_GR_signexp, ceil_GR_expmask
184 (p9)  fadd.s1  CEIL_adj = f1,f0
185       nop.i 999
187 { .mfi
188       nop.m 999
189 (p8)  fadd.s1  CEIL_adj = f0,f0
190       nop.i 999 ;;
193 { .mfi
194 (p10) cmp.ge.unc    p10,p11 = ceil_GR_exponent, ceil_GR_bigexp
195 (p6)  fnorm.s f8 = f8
196       nop.i 999 ;;
199 { .mfi
200       nop.m 999
201 (p11) fcvt.xf         CEIL_FLOAT_INT_f8   = CEIL_INT_f8
202       nop.i 999 ;;
205 { .mfi
206       nop.m 999
207 (p10) fnorm.s f8 = CEIL_NORM_f8
208       nop.i 999 ;;
211 // Is -1 < x < 0?  If so, result will be -0.  Special case it with p14 set.
212 { .mfi
213       nop.m 999
214 (p8)  fcmp.gt.unc.s1 p14,p0 = CEIL_NORM_f8, CEIL_MINUS_ONE
215       nop.i 999 ;;
218 { .mfi
219 (p14) cmp.ne  p11,p0 = r0,r0
220 (p14) fnorm.s f8 = CEIL_SIGNED_ZERO
221       nop.i 999
223 { .mfi
224       nop.m 999
225 (p14) fmpy.s0     CEIL_INEXACT = CEIL_FFFF,CEIL_FFFF
226       nop.i 999 ;;
229 { .mfi
230       nop.m 999
231 (p11) fadd.s   f8 = CEIL_FLOAT_INT_f8,CEIL_adj
232       nop.i 999 ;;
234 { .mfi
235       nop.m 999
236 (p11) fcmp.eq.unc.s1  p12,p13  = CEIL_FLOAT_INT_f8, CEIL_NORM_f8
237       nop.i 999 ;;
240 // Set inexact if result not equal to input
241 { .mfi
242       nop.m 999
243 (p13) fmpy.s0     CEIL_INEXACT = CEIL_FFFF,CEIL_FFFF
244       nop.i 999
246 // Set result to input if integer
247 { .mfb
248       nop.m 999
249 (p12) fnorm.s f8 = CEIL_NORM_f8
250       br.ret.sptk    b0 ;;
253 // Here if input denorm
254 L(CEIL_DENORM):
255 { .mfb
256       getf.exp ceil_GR_signexp  = CEIL_NORM_f8
257       fcvt.fx.trunc.s1     CEIL_INT_f8  = CEIL_NORM_f8
258       br.cond.sptk  L(CEIL_COMMON) ;;
261 .endp ceilf
262 ASM_SIZE_DIRECTIVE(ceilf)