(CFLAGS-tst-align.c): Add -mpreferred-stack-boundary=4.
[glibc.git] / sysdeps / ia64 / fpu / e_expf.S
blob2aad021335fd112de82818023347686090afaa55
1 .file "expf.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.
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.
40 // History
41 //==============================================================
42 // 4/04/00  Unwind update
43 // 4/04/00  Unwind support added
44 // 8/15/00  Bundle added after call to __libm_error_support to properly
45 //          set [the previously overwritten] GR_Parameter_RESULT.
46 // 8/21/00  Improvements to save 2 cycles on main path, and shorten x=0 case
47 // 12/07/00 Widen main path, shorten x=inf, nan paths
50 #include "libm_support.h"
52 // Assembly macros
53 //==============================================================
54 // integer registers used
56  exp_GR_0x0f                = r33
57  exp_GR_0xf0                = r34
59  EXP_AD_P_1                 = r36
60  EXP_AD_P_2                 = r37
61  EXP_AD_T1                  = r38
62  EXP_AD_T2                  = r39
63  exp_GR_Mint                = r40
65  exp_GR_Mint_p_128          = r41
66  exp_GR_Ind1                = r42
67  EXP_AD_M1                  = r43
68  exp_GR_Ind2                = r44
69  EXP_AD_M2                  = r45
71  exp_GR_min_oflow           = r46
72  exp_GR_max_zero            = r47
73  exp_GR_max_norm            = r48
74  exp_GR_max_uflow           = r49
75  exp_GR_min_norm            = r50
77  exp_GR_17ones              = r51
78  exp_GR_gt_ln               = r52
79  exp_GR_T2_size             = r53
81  exp_GR_17ones_m1           = r56
82  exp_GR_one                 = r57
86 GR_SAVE_B0                    = r53
87 GR_SAVE_PFS                   = r55
88 GR_SAVE_GP                    = r54 
90 GR_Parameter_X                = r59
91 GR_Parameter_Y                = r60
92 GR_Parameter_RESULT           = r61
93 GR_Parameter_TAG              = r62
95 FR_X             = f10
96 FR_Y             = f1
97 FR_RESULT        = f8
100 // floating point registers used
102  EXP_MIN_SGL_OFLOW_ARG      = f11
103  EXP_MAX_SGL_ZERO_ARG       = f12
104  EXP_MAX_SGL_NORM_ARG       = f13
105  EXP_MAX_SGL_UFLOW_ARG      = f14
106  EXP_MIN_SGL_NORM_ARG       = f15
108  exp_coeff_P5               = f32
109  exp_coeff_P6               = f33
110  exp_coeff_P3               = f34
111  exp_coeff_P4               = f35
113  exp_coeff_P1               = f36
114  exp_coeff_P2               = f37
115  exp_Mx                     = f38
116  exp_Mfloat                 = f39
117  exp_R                      = f40
119  exp_P1                     = f41
120  exp_P2                     = f42
121  exp_P3                     = f43
122  exp_Rsq                    = f44
123  exp_R4                     = f45
125  exp_P4                     = f46
126  exp_P5                     = f47
127  exp_P6                     = f48
128  exp_P7                     = f49
129  exp_T1                     = f50
131  exp_T2                     = f51
132  exp_T                      = f52
133  exp_A                      = f53
134  exp_norm_f8                = f54
135  exp_wre_urm_f8             = f55
137  exp_ftz_urm_f8             = f56
138  exp_gt_pln                 = f57
141 #ifdef _LIBC
142 .rodata
143 #else
144 .data
145 #endif
147 .align 16
149 exp_coeff_1_table:
150 ASM_TYPE_DIRECTIVE(exp_coeff_1_table,@object)
151 data8 0x3F56F35FDE4F8563 // p5
152 data8 0x3F2A378BEFECCFDD // p6
153 data8 0x3FE00000258C581D // p1
154 data8 0x3FC555557AE7B3D4 // p2
155 ASM_SIZE_DIRECTIVE(exp_coeff_1_table)
158 exp_coeff_2_table:
159 ASM_TYPE_DIRECTIVE(exp_coeff_2_table,@object)
160 data8 0x3FA5551BB6592FAE // p3
161 data8 0x3F8110E8EBFFD485 // p4
162 ASM_SIZE_DIRECTIVE(exp_coeff_2_table)
165 exp_T2_table:
166 ASM_TYPE_DIRECTIVE(exp_T2_table,@object)
167 data8 0xa175cf9cd7d85844 , 0x00003f46 // exp(-128)
168 data8 0xdb7279415a1f9eed , 0x00003f47 // exp(-127)
169 data8 0x95213b242bd8ca5f , 0x00003f49 // exp(-126)
170 data8 0xcab03c968c989f83 , 0x00003f4a // exp(-125)
171 data8 0x89bdb674702961ad , 0x00003f4c // exp(-124)
172 data8 0xbb35a2eec278be35 , 0x00003f4d // exp(-123)
173 data8 0xfe71b17f373e7e7a , 0x00003f4e // exp(-122)
174 data8 0xace9a6ec52a39b63 , 0x00003f50 // exp(-121)
175 data8 0xeb03423fe393cf1c , 0x00003f51 // exp(-120)
176 data8 0x9fb52c5bcaef1693 , 0x00003f53 // exp(-119)
177 data8 0xd910b6377ed60bf1 , 0x00003f54 // exp(-118)
178 data8 0x9382dad8a9fdbfe4 , 0x00003f56 // exp(-117)
179 data8 0xc87d0a84dea869a3 , 0x00003f57 // exp(-116)
180 data8 0x883efb4c6d1087b0 , 0x00003f59 // exp(-115)
181 data8 0xb92d7373dce9a502 , 0x00003f5a // exp(-114)
182 data8 0xfbaeb020577fb0cb , 0x00003f5b // exp(-113)
183 ASM_SIZE_DIRECTIVE(exp_T2_table)
186 exp_T1_table:
187 ASM_TYPE_DIRECTIVE(exp_T1_table,@object)
188 data8 0x8000000000000000 , 0x00003fff // exp(16 * 0)
189 data8 0x87975e8540010249 , 0x00004016 // exp(16 * 1) 
190 data8 0x8fa1fe625b3163ec , 0x0000402d // exp(16 * 2) 
191 data8 0x9826b576512a59d7 , 0x00004044 // exp(16 * 3) 
192 data8 0xa12cc167acbe6902 , 0x0000405b // exp(16 * 4) 
193 data8 0xaabbcdcc279f59e4 , 0x00004072 // exp(16 * 5) 
194 data8 0xb4dbfaadc045d16f , 0x00004089 // exp(16 * 6) 
195 data8 0xbf95e372ccdbf146 , 0x000040a0 // exp(16 * 7) 
196 data8 0xcaf2a62eea10bbfb , 0x000040b7 // exp(16 * 8) 
197 data8 0xd6fbeb62fddbd340 , 0x000040ce // exp(16 * 9) 
198 data8 0xe3bbee32e4a440ea , 0x000040e5 // exp(16 * 10)
199 data8 0xf13d8517c34199a8 , 0x000040fc // exp(16 * 11)
200 data8 0xff8c2b166241eedd , 0x00004113 // exp(16 * 12)
201 data8 0x875a04c0b38d6129 , 0x0000412b // exp(16 * 13)
202 data8 0x8f610127db6774d7 , 0x00004142 // exp(16 * 14)
203 data8 0x97e1dd87e5c20bb6 , 0x00004159 // exp(16 * 15)
204 ASM_SIZE_DIRECTIVE(exp_T1_table)
206 // Argument Reduction
207 //  exp_Mx = (int)f8            ==> The value of f8 rounded to int is placed into the
208 //                                  significand of exp_Mx as a two's
209 //                                  complement number.
211 // Later we want to have exp_Mx in a general register. Do this with a getf.sig
212 // and call the general register exp_GR_Mint
214 //  exp_Mfloat = (float)(int)f8 ==> the two's complement number in
215 //                                  significand of exp_Mx is turned
216 //                                  into a floating point number.
217 //  R = 1 - exp_Mfloat          ==> reduced argument
219 // Core Approximation
220 // Calculate a series in R
221 //  R * p6 + p5
222 //  R * p4 + p3
223 //  R * p2 + p1
224 //  R^2
225 //  R^4
226 //  R^2(R * p6 + p5) + (R * p4 + p3)
227 //  R^2(R * p2 + p1)
228 //  R^4(R^2(R * p6 + p5) + (R * p4 + p3)) + (R^2(R * p2 + p1))
229 //  R + 1
230 //  exp(R) = (1 + R) + R^4(R^2(R * p6 + p5) + (R * p4 + p3)) + (R^2(R * p2 + p1))
231 //  exp(R) = 1 + R + R^2 * p1 + R^3 * p2 + R^4 * p3 + R^5 * p4 + R^6 * p5 + R^7 * p6
233 // Reconstruction
234 // signficand of exp_Mx is two's complement,
235 // -103 < x < 89
236 // The smallest single denormal is 2^-149 = ssdn
237 //    For e^x = ssdn
238 //        x   = log(ssdn) = -103.279
239 //    But with rounding result goes to ssdn until -103.972079
240 // The largest single normal is  1.<23 1's> 2^126 ~ 2^127 = lsn
241 //    For e^x = lsn
242 //        x   = log(lsn) = 88.7228
244 // expf overflows                       when x > 42b17218 = 88.7228
245 // expf returns largest single denormal when x = c2aeac50
246 // expf goes to zero when                    x < c2cff1b5 
248 // Consider range of 8-bit two's complement, -128 ---> 127
249 // Add 128; range becomes                       0 ---> 255
251 // The number (=i) in 0 ---> 255 is used as offset into two tables.
253 // i = abcd efgh = abcd * 16 + efgh = i1 * 16 + i2
255 // i1 = (exp_GR_Mint + 128)  & 0xf0 (show 0xf0 as -0x10 to avoid assembler error)
256 //                                  (The immediate in the AND is an 8-bit two's complement)
257 // i1 = i1 + start of T1 table (EXP_AD_T1)
258 //    Note that the entries in T1 are double-extended numbers on 16-byte boundaries
259 //    and that i1 is already shifted left by 16 after the AND.
261 // i2 must be shifted left by 4 before adding to the start of the table.
262 // i2 = ((exp_GR_Mint + 128)  & 0x0f) << 4
263 // i2 = i2 + start of T2 table (EXP_AD_T2)
265 // T      = T1 * T2
266 // A      = T * (1 + R)
267 // answer = T *  (R^2 * p1 + R^3 * p2 + R^4 * p3 + R^5 * p4 + R^6 * p5 + R^7 * p6) +
268 //          T *  (1 + R)
269 //        = T * exp(R)
272 .global expf#
274 .section .text
275 .proc  expf#
276 .align 32
277 expf:
278 #ifdef _LIBC
279 .global __ieee754_expf#
280 __ieee754_expf:
281 #endif
283 { .mfi
284      alloc      r32            = ar.pfs,1,26,4,0
285      fcvt.fx.s1   exp_Mx       =    f8
286      mov       exp_GR_17ones   =    0x1FFFF
288 { .mlx
289      addl      EXP_AD_P_1      =    @ltoff(exp_coeff_1_table),gp
290      movl      exp_GR_min_oflow = 0x42b17218    
294 // Fnorm done to take any enabled faults
295 { .mfi
296      ld8       EXP_AD_P_1      =  [EXP_AD_P_1]
297      fclass.m  p6,p0      = f8, 0x07    //@zero
298      nop.i 999
300 { .mfi
301      add       exp_GR_max_norm = -1, exp_GR_min_oflow  // 0x42b17217
302      fnorm     exp_norm_f8     =    f8
303      nop.i 999
307 { .mfi
308      setf.s    EXP_MIN_SGL_OFLOW_ARG = exp_GR_min_oflow  // 0x42b17218
309      fclass.m  p7,p0      = f8, 0x22    // Test for x=-inf
310      mov       exp_GR_0xf0 = 0x0f0
312 { .mlx
313      setf.s    EXP_MAX_SGL_NORM_ARG = exp_GR_max_norm
314      movl      exp_GR_max_zero = 0xc2cff1b5    
319 { .mlx
320      mov       exp_GR_0x0f = 0x00f
321      movl      exp_GR_max_uflow = 0xc2aeac50    
323 { .mfb
324      nop.m 999
325 (p6) fma.s     f8 = f1,f1,f0
326 (p6) br.ret.spnt   b0        // quick exit for x=0
330 { .mfi
331      setf.s    EXP_MAX_SGL_ZERO_ARG = exp_GR_max_zero
332      fclass.m  p8,p0      = f8, 0x21    // Test for x=+inf
333      adds      exp_GR_min_norm = 1, exp_GR_max_uflow  // 0xc2aeac51
335 { .mfb
336      ldfpd     exp_coeff_P5,exp_coeff_P6     =    [EXP_AD_P_1],16
337 (p7) fma.s     f8 = f0,f0,f0
338 (p7) br.ret.spnt   b0        // quick exit for x=-inf
342 { .mmf
343      ldfpd     exp_coeff_P1,exp_coeff_P2     =    [EXP_AD_P_1],16
344      setf.s    EXP_MAX_SGL_UFLOW_ARG = exp_GR_max_uflow
345      fclass.m  p9,p0      = f8, 0xc3    // Test for x=nan
349 { .mmb
350      ldfpd     exp_coeff_P3,exp_coeff_P4     =    [EXP_AD_P_1],16
351      setf.s    EXP_MIN_SGL_NORM_ARG = exp_GR_min_norm
352 (p8) br.ret.spnt   b0        // quick exit for x=+inf
356 // EXP_AD_P_1 now points to exp_T2_table
357 { .mfi
358      mov exp_GR_T2_size           = 0x100
359      fcvt.xf   exp_Mfloat     =    exp_Mx
360      nop.i 999
364 { .mfb
365      getf.sig  exp_GR_Mint    =    exp_Mx
366 (p9) fmerge.s     f8 = exp_norm_f8, exp_norm_f8
367 (p9) br.ret.spnt   b0        // quick exit for x=nan
371 { .mmi
372      nop.m 999
373      mov      EXP_AD_T2       =  EXP_AD_P_1
374      add      EXP_AD_T1       =  exp_GR_T2_size,EXP_AD_P_1 ;;
378 { .mmi
379      adds      exp_GR_Mint_p_128   =    0x80,exp_GR_Mint ;;
380      and       exp_GR_Ind1      =    exp_GR_Mint_p_128, exp_GR_0xf0
381      and       exp_GR_Ind2      =    exp_GR_Mint_p_128, exp_GR_0x0f ;;
384 // Divide arguments into the following categories:
385 //  Certain Underflow/zero  p11 - -inf < x <= MAX_SGL_ZERO_ARG 
386 //  Certain Underflow       p12 - MAX_SGL_ZERO_ARG < x <= MAX_SGL_UFLOW_ARG 
387 //  Possible Underflow      p13 - MAX_SGL_UFLOW_ARG < x < MIN_SGL_NORM_ARG
388 //  Certain Safe                - MIN_SGL_NORM_ARG <= x <= MAX_SGL_NORM_ARG
389 //  Possible Overflow       p14 - MAX_SGL_NORM_ARG < x < MIN_SGL_OFLOW_ARG
390 //  Certain Overflow        p15 - MIN_SGL_OFLOW_ARG <= x < +inf
392 // If the input is really a single arg, then there will never be "Possible
393 // Underflow" or "Possible Overflow" arguments.
396 { .mfi
397      add       EXP_AD_M1 =    exp_GR_Ind1,EXP_AD_T1
398      fcmp.ge.s1  p15,p14 = exp_norm_f8,EXP_MIN_SGL_OFLOW_ARG
399      nop.i 999
401 { .mfi
402      shladd       EXP_AD_M2                =    exp_GR_Ind2,4,EXP_AD_T2
403      fms.s1    exp_R                    =    f1,f8,exp_Mfloat
404      nop.i 999 ;;
407 { .mfi
408      ldfe           exp_T1    =    [EXP_AD_M1]
409      fcmp.le.s1  p11,p12 = exp_norm_f8,EXP_MAX_SGL_ZERO_ARG
410      nop.i 999 ;;
413 { .mfb
414       ldfe           exp_T2   =    [EXP_AD_M2]
415 (p14) fcmp.gt.s1  p14,p0 = exp_norm_f8,EXP_MAX_SGL_NORM_ARG
416 (p15) br.cond.spnt L(EXP_CERTAIN_OVERFLOW) ;;
419 { .mfb
420       nop.m 999
421 (p12) fcmp.le.s1  p12,p0 = exp_norm_f8,EXP_MAX_SGL_UFLOW_ARG
422 (p11) br.cond.spnt L(EXP_CERTAIN_UNDERFLOW_ZERO)
426 { .mfi
427       nop.m 999
428 (p13) fcmp.lt.s1  p13,p0 = exp_norm_f8,EXP_MIN_SGL_NORM_ARG
429       nop.i 999
434 { .mfi
435      nop.m                 999
436      fma.s1    exp_Rsq   =    exp_R,exp_R,f0
437      nop.i                 999
439 { .mfi
440      nop.m                 999
441      fma.s1    exp_P3    =    exp_R,exp_coeff_P2,exp_coeff_P1
442      nop.i                 999 
446 { .mfi
447      nop.m                 999
448      fma.s1    exp_P1    =    exp_R,exp_coeff_P6,exp_coeff_P5
449      nop.i                 999 
451 { .mfi
452      nop.m                 999
453      fma.s1    exp_P2    =    exp_R,exp_coeff_P4,exp_coeff_P3
454      nop.i                 999
459 { .mfi
460      nop.m                 999
461      fma.s1    exp_P7    =    f1,exp_R,f1
462      nop.i                 999
467 { .mfi
468      nop.m                 999
469      fma.s1    exp_P5    =    exp_Rsq,exp_P3,f0
470      nop.i                 999
472 { .mfi
473      nop.m                 999
474      fma.s1    exp_R4    =    exp_Rsq,exp_Rsq,f0
475      nop.i                 999 
479 { .mfi
480      nop.m                 999
481      fma.s1    exp_T     =    exp_T1,exp_T2,f0
482      nop.i                 999 
484 { .mfi
485      nop.m                 999
486      fma.s1    exp_P4    =    exp_Rsq,exp_P1,exp_P2
487      nop.i                 999 
491 { .mfi
492      nop.m                 999
493      fma.s1    exp_A     =    exp_T,exp_P7,f0
494      nop.i                 999
496 { .mfi
497      nop.m                 999
498      fma.s1    exp_P6    =    exp_R4,exp_P4,exp_P5
499      nop.i                 999
503 { .bbb
504 (p12) br.cond.spnt L(EXP_CERTAIN_UNDERFLOW)
505 (p13) br.cond.spnt L(EXP_POSSIBLE_UNDERFLOW)
506 (p14) br.cond.spnt L(EXP_POSSIBLE_OVERFLOW)
510 { .mfb
511      nop.m            999
512      fma.s     f8   =    exp_T,exp_P6,exp_A
513      br.ret.sptk     b0
517 L(EXP_POSSIBLE_OVERFLOW):
519 // We got an answer. EXP_MAX_SGL_NORM_ARG < x < EXP_MIN_SGL_OFLOW_ARG
520 // overflow is a possibility, not a certainty
521 // Set wre in s2 and perform the last operation with s2
523 // We define an overflow when the answer with
524 //    WRE set
525 //    user-defined rounding mode
526 // is lsn +1
528 // Is the exponent 1 more than the largest single?
529 // If so, go to ERROR RETURN, else (no overflow) get the answer and
530 // leave.
532 // Largest single is FE (biased single)
533 //                   FE - 7F + FFFF = 1007E
535 // Create + largest_single_plus_ulp
536 // Create - largest_single_plus_ulp
538 // Calculate answer with WRE set.
540 // Cases when answer is lsn+1  are as follows:
542 //           midpoint
543 //              |
544 //  lsn         |         lsn+1
545 // --+----------|----------+------------
546 //              |
547 //    +inf          +inf      -inf
548 //                  RN         RN
549 //                             RZ
550 // exp_gt_pln contains the floating point number lsn+1.
551 // The setf.exp puts 0x1007f in the exponent and 0x800... in the significand.
553 // If the answer is >= lsn+1, we have overflowed.
554 // Then p6 is TRUE. Set the overflow tag, save input in FR_X,
555 // do the final calculation for IEEE result, and branch to error return.
557 { .mfi
558        mov         exp_GR_gt_ln    = 0x1007F 
559        fsetc.s2    0x7F,0x42
560        nop.i 999
564 { .mfi
565        setf.exp      exp_gt_pln    = exp_GR_gt_ln
566        fma.s.s2    exp_wre_urm_f8  = exp_T,  exp_P6, exp_A
567        nop.i 999
571 { .mfi
572        nop.m 999
573        fsetc.s2 0x7F,0x40
574        nop.i 999
578 { .mfi
579        nop.m 999
580        fcmp.ge.unc.s1 p6, p0       =  exp_wre_urm_f8, exp_gt_pln
581        nop.i 999
585 { .mfb
586        nop.m 999
587        nop.f 999
588 (p6)   br.cond.spnt L(EXP_CERTAIN_OVERFLOW)  // Branch if really overflow
592 { .mfb
593        nop.m 999
594        fma.s        f8             = exp_T,  exp_P6, exp_A
595        br.ret.sptk     b0                 // Exit if really no overflow
599 L(EXP_CERTAIN_OVERFLOW):
600 { .mmi
601       sub   exp_GR_17ones_m1 = exp_GR_17ones, r0, 1 ;;
602       setf.exp     f9 = exp_GR_17ones_m1
603       nop.i 999 ;;
606 { .mfi
607       nop.m 999
608       fmerge.s FR_X = f8,f8
609       nop.i 999
611 { .mfb
612       mov        GR_Parameter_TAG = 16
613       fma.s       FR_RESULT = f9, f9, f0    // Set I,O and +INF result
614       br.cond.sptk  __libm_error_region ;;                             
617 L(EXP_POSSIBLE_UNDERFLOW): 
619 // We got an answer. EXP_MAX_SGL_UFLOW_ARG < x < EXP_MIN_SGL_NORM_ARG
620 // underflow is a possibility, not a certainty
622 // We define an underflow when the answer with
623 //    ftz set
624 // is zero (tiny numbers become zero)
626 // Notice (from below) that if we have an unlimited exponent range,
627 // then there is an extra machine number E between the largest denormal and
628 // the smallest normal.
630 // So if with unbounded exponent we round to E or below, then we are
631 // tiny and underflow has occurred.
633 // But notice that you can be in a situation where we are tiny, namely
634 // rounded to E, but when the exponent is bounded we round to smallest
635 // normal. So the answer can be the smallest normal with underflow.
637 //                           E
638 // -----+--------------------+--------------------+-----
639 //      |                    |                    |
640 //   1.1...10 2^-7f      1.1...11 2^-7f      1.0...00 2^-7e  
641 //   0.1...11 2^-7e                                     (biased, 1)
642 //    largest dn                               smallest normal
644 // If the answer is = 0, we have underflowed.
645 // Then p6 is TRUE. Set the underflow tag, save input in FR_X,
646 // do the final calculation for IEEE result, and branch to error return.
648 { .mfi
649        nop.m 999
650        fsetc.s2 0x7F,0x41
651        nop.i 999
655 { .mfi
656        nop.m 999
657        fma.s.s2     exp_ftz_urm_f8  = exp_T,  exp_P6, exp_A
658        nop.i 999
663 { .mfi
664        nop.m 999
665        fsetc.s2 0x7F,0x40
666        nop.i 999
670 { .mfi
671        nop.m 999
672        fcmp.eq.unc.s1 p6, p0     =  exp_ftz_urm_f8, f0
673        nop.i 999
677 { .mfb
678        nop.m 999
679        nop.f 999
680 (p6)   br.cond.spnt L(EXP_CERTAIN_UNDERFLOW)  // Branch if really underflow 
684 { .mfb
685        nop.m 999
686        fma.s        f8             = exp_T,  exp_P6, exp_A
687        br.ret.sptk     b0                  // Exit if really no underflow
691 L(EXP_CERTAIN_UNDERFLOW):
692 { .mfi
693       nop.m 999
694       fmerge.s FR_X = f8,f8
695       nop.i 999
697 { .mfb
698       mov        GR_Parameter_TAG = 17
699       fma.s       FR_RESULT  = exp_T, exp_P6, exp_A // Set I,U and tiny result
700       br.cond.sptk  __libm_error_region ;;                             
703 L(EXP_CERTAIN_UNDERFLOW_ZERO):
704 { .mmi
705       mov   exp_GR_one = 1 ;;
706       setf.exp     f9 = exp_GR_one
707       nop.i 999 ;;
710 { .mfi
711       nop.m 999
712       fmerge.s FR_X = f8,f8
713       nop.i 999
715 { .mfb
716       mov        GR_Parameter_TAG = 17
717       fma.s       FR_RESULT = f9, f9, f0    // Set I,U and tiny (+0.0) result
718       br.cond.sptk  __libm_error_region ;;                             
721 .endp expf
722 ASM_SIZE_DIRECTIVE(expf)
725 .proc __libm_error_region
726 __libm_error_region:
727 .prologue
728 { .mfi
729         add   GR_Parameter_Y=-32,sp             // Parameter 2 value
730         nop.f 999
731 .save   ar.pfs,GR_SAVE_PFS
732         mov  GR_SAVE_PFS=ar.pfs                 // Save ar.pfs
734 { .mfi
735 .fframe 64
736         add sp=-64,sp                           // Create new stack
737         nop.f 0
738         mov GR_SAVE_GP=gp                       // Save gp
740 { .mmi
741         stfs [GR_Parameter_Y] = FR_Y,16         // Store Parameter 2 on stack
742         add GR_Parameter_X = 16,sp              // Parameter 1 address
743 .save   b0, GR_SAVE_B0
744         mov GR_SAVE_B0=b0                       // Save b0
746 .body
747 { .mfi
748         stfs [GR_Parameter_X] = FR_X            // Store Parameter 1 on stack
749         nop.f 0
750         add   GR_Parameter_RESULT = 0,GR_Parameter_Y // Parameter 3 address
752 { .mib
753         stfs [GR_Parameter_Y] = FR_RESULT       // Store Parameter 3 on stack
754         add   GR_Parameter_Y = -16,GR_Parameter_Y
755         br.call.sptk b0=__libm_error_support#   // Call error handling function
758 { .mmi
759         nop.m 0
760         nop.m 0
761         add   GR_Parameter_RESULT = 48,sp
764 { .mmi
765         ldfs  f8 = [GR_Parameter_RESULT]       // Get return result off stack
766 .restore sp
767         add   sp = 64,sp                       // Restore stack pointer
768         mov   b0 = GR_SAVE_B0                  // Restore return address
770 { .mib
771         mov   gp = GR_SAVE_GP                  // Restore gp 
772         mov   ar.pfs = GR_SAVE_PFS             // Restore ar.pfs
773         br.ret.sptk     b0                     // Return
774 };; 
776 .endp __libm_error_region
777 ASM_SIZE_DIRECTIVE(__libm_error_region)
780 .type   __libm_error_support#,@function
781 .global __libm_error_support#