Remove support in configure for unsupported architectures
[glibc.git] / sysdeps / ia64 / fpu / s_cosf.S
blobbcdf1b0c0207b0604ebf92bb1b8ea8af3a0ac983
1 .file "sincosf.s"
4 // Copyright (c) 2000 - 2005, 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.
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 // 04/02/00 Unwind support added.
44 // 06/16/00 Updated tables to enforce symmetry
45 // 08/31/00 Saved 2 cycles in main path, and 9 in other paths.
46 // 09/20/00 The updated tables regressed to an old version, so reinstated them
47 // 10/18/00 Changed one table entry to ensure symmetry
48 // 01/03/01 Improved speed, fixed flag settings for small arguments.
49 // 02/18/02 Large arguments processing routine excluded
50 // 05/20/02 Cleaned up namespace and sf0 syntax
51 // 06/03/02 Insure inexact flag set for large arg result
52 // 09/05/02 Single precision version is made using double precision one as base
53 // 02/10/03 Reordered header: .section, .global, .proc, .align
54 // 03/31/05 Reformatted delimiters between data tables
56 // API
57 //==============================================================
58 // float sinf( float x);
59 // float cosf( float x);
61 // Overview of operation
62 //==============================================================
64 // Step 1
65 // ======
66 // Reduce x to region -1/2*pi/2^k ===== 0 ===== +1/2*pi/2^k  where k=4
67 //    divide x by pi/2^k.
68 //    Multiply by 2^k/pi.
69 //    nfloat = Round result to integer (round-to-nearest)
71 // r = x -  nfloat * pi/2^k
72 //    Do this as (x -  nfloat * HIGH(pi/2^k)) - nfloat * LOW(pi/2^k) 
74 //    for increased accuracy.
75 //    pi/2^k is stored as two numbers that when added make pi/2^k.
76 //       pi/2^k = HIGH(pi/2^k) + LOW(pi/2^k)
77 //    HIGH part is rounded to zero, LOW - to nearest
79 // x = (nfloat * pi/2^k) + r
80 //    r is small enough that we can use a polynomial approximation
81 //    and is referred to as the reduced argument.
83 // Step 3
84 // ======
85 // Take the unreduced part and remove the multiples of 2pi.
86 // So nfloat = nfloat (with lower k+1 bits cleared) + lower k+1 bits
88 //    nfloat (with lower k+1 bits cleared) is a multiple of 2^(k+1)
89 //    N * 2^(k+1)
90 //    nfloat * pi/2^k = N * 2^(k+1) * pi/2^k + (lower k+1 bits) * pi/2^k
91 //    nfloat * pi/2^k = N * 2 * pi + (lower k+1 bits) * pi/2^k
92 //    nfloat * pi/2^k = N2pi + M * pi/2^k
95 // Sin(x) = Sin((nfloat * pi/2^k) + r)
96 //        = Sin(nfloat * pi/2^k) * Cos(r) + Cos(nfloat * pi/2^k) * Sin(r)
98 //          Sin(nfloat * pi/2^k) = Sin(N2pi + Mpi/2^k)
99 //                               = Sin(N2pi)Cos(Mpi/2^k) + Cos(N2pi)Sin(Mpi/2^k)
100 //                               = Sin(Mpi/2^k)
102 //          Cos(nfloat * pi/2^k) = Cos(N2pi + Mpi/2^k)
103 //                               = Cos(N2pi)Cos(Mpi/2^k) + Sin(N2pi)Sin(Mpi/2^k)
104 //                               = Cos(Mpi/2^k)
106 // Sin(x) = Sin(Mpi/2^k) Cos(r) + Cos(Mpi/2^k) Sin(r)
109 // Step 4
110 // ======
111 // 0 <= M < 2^(k+1)
112 // There are 2^(k+1) Sin entries in a table.
113 // There are 2^(k+1) Cos entries in a table.
115 // Get Sin(Mpi/2^k) and Cos(Mpi/2^k) by table lookup.
118 // Step 5
119 // ======
120 // Calculate Cos(r) and Sin(r) by polynomial approximation.
122 // Cos(r) = 1 + r^2 q1  + r^4 q2  = Series for Cos
123 // Sin(r) = r + r^3 p1  + r^5 p2  = Series for Sin
125 // and the coefficients q1, q2 and p1, p2 are stored in a table
128 // Calculate
129 // Sin(x) = Sin(Mpi/2^k) Cos(r) + Cos(Mpi/2^k) Sin(r)
131 // as follows
133 //    S[m] = Sin(Mpi/2^k) and C[m] = Cos(Mpi/2^k)
134 //    rsq = r*r
137 //    P = P1 + r^2*P2
138 //    Q = Q1 + r^2*Q2
140 //       rcub = r * rsq
141 //       Sin(r) = r + rcub * P
142 //              = r + r^3p1  + r^5p2 = Sin(r)
144 //            The coefficients are not exactly these values, but almost.
146 //            p1 = -1/6  = -1/3!
147 //            p2 = 1/120 =  1/5!
148 //            p3 = -1/5040 = -1/7!
149 //            p4 = 1/362889 = 1/9!
151 //       P =  r + r^3 * P
153 //    Answer = S[m] Cos(r) + C[m] P
155 //       Cos(r) = 1 + rsq Q
156 //       Cos(r) = 1 + r^2 Q
157 //       Cos(r) = 1 + r^2 (q1 + r^2q2)
158 //       Cos(r) = 1 + r^2q1 + r^4q2
160 //       S[m] Cos(r) = S[m](1 + rsq Q)
161 //       S[m] Cos(r) = S[m] + S[m] rsq Q
162 //       S[m] Cos(r) = S[m] + s_rsq Q
163 //       Q         = S[m] + s_rsq Q
165 // Then,
167 //    Answer = Q + C[m] P
170 // Registers used
171 //==============================================================
172 // general input registers:
173 // r14 -> r19
174 // r32 -> r45
176 // predicate registers used:
177 // p6 -> p14
179 // floating-point registers used
180 // f9 -> f15
181 // f32 -> f61
183 // Assembly macros
184 //==============================================================
185 sincosf_NORM_f8                 = f9
186 sincosf_W                       = f10
187 sincosf_int_Nfloat              = f11
188 sincosf_Nfloat                  = f12
190 sincosf_r                       = f13
191 sincosf_rsq                     = f14
192 sincosf_rcub                    = f15
193 sincosf_save_tmp                = f15
195 sincosf_Inv_Pi_by_16            = f32
196 sincosf_Pi_by_16_1              = f33
197 sincosf_Pi_by_16_2              = f34
199 sincosf_Inv_Pi_by_64            = f35
201 sincosf_Pi_by_16_3              = f36
203 sincosf_r_exact                 = f37
205 sincosf_Sm                      = f38
206 sincosf_Cm                      = f39
208 sincosf_P1                      = f40
209 sincosf_Q1                      = f41
210 sincosf_P2                      = f42
211 sincosf_Q2                      = f43
212 sincosf_P3                      = f44
213 sincosf_Q3                      = f45
214 sincosf_P4                      = f46
215 sincosf_Q4                      = f47
217 sincosf_P_temp1                 = f48
218 sincosf_P_temp2                 = f49
220 sincosf_Q_temp1                 = f50
221 sincosf_Q_temp2                 = f51
223 sincosf_P                       = f52
224 sincosf_Q                       = f53
226 sincosf_srsq                    = f54
228 sincosf_SIG_INV_PI_BY_16_2TO61  = f55
229 sincosf_RSHF_2TO61              = f56
230 sincosf_RSHF                    = f57
231 sincosf_2TOM61                  = f58
232 sincosf_NFLOAT                  = f59
233 sincosf_W_2TO61_RSH             = f60
235 fp_tmp                          = f61
237 /////////////////////////////////////////////////////////////
239 sincosf_AD_1                    = r33
240 sincosf_AD_2                    = r34
241 sincosf_exp_limit               = r35
242 sincosf_r_signexp               = r36
243 sincosf_AD_beta_table           = r37
244 sincosf_r_sincos                = r38
246 sincosf_r_exp                   = r39
247 sincosf_r_17_ones               = r40
249 sincosf_GR_sig_inv_pi_by_16     = r14
250 sincosf_GR_rshf_2to61           = r15
251 sincosf_GR_rshf                 = r16
252 sincosf_GR_exp_2tom61           = r17
253 sincosf_GR_n                    = r18
254 sincosf_GR_m                    = r19
255 sincosf_GR_32m                  = r19
256 sincosf_GR_all_ones             = r19
258 gr_tmp                          = r41
259 GR_SAVE_PFS                     = r41
260 GR_SAVE_B0                      = r42
261 GR_SAVE_GP                      = r43
263 RODATA
264 .align 16
266 // Pi/16 parts
267 LOCAL_OBJECT_START(double_sincosf_pi)
268    data8 0xC90FDAA22168C234, 0x00003FFC // pi/16 1st part
269    data8 0xC4C6628B80DC1CD1, 0x00003FBC // pi/16 2nd part
270 LOCAL_OBJECT_END(double_sincosf_pi)
272 // Coefficients for polynomials
273 LOCAL_OBJECT_START(double_sincosf_pq_k4)
274    data8 0x3F810FABB668E9A2 // P2
275    data8 0x3FA552E3D6DE75C9 // Q2
276    data8 0xBFC555554447BC7F // P1
277    data8 0xBFDFFFFFC447610A // Q1
278 LOCAL_OBJECT_END(double_sincosf_pq_k4)
280 // Sincos table (S[m], C[m])
281 LOCAL_OBJECT_START(double_sin_cos_beta_k4)
282     data8 0x0000000000000000 // sin ( 0 Pi / 16 )
283     data8 0x3FF0000000000000 // cos ( 0 Pi / 16 )
285     data8 0x3FC8F8B83C69A60B // sin ( 1 Pi / 16 )
286     data8 0x3FEF6297CFF75CB0 // cos ( 1 Pi / 16 )
288     data8 0x3FD87DE2A6AEA963 // sin ( 2 Pi / 16 )
289     data8 0x3FED906BCF328D46 // cos ( 2 Pi / 16 )
291     data8 0x3FE1C73B39AE68C8 // sin ( 3 Pi / 16 )
292     data8 0x3FEA9B66290EA1A3 // cos ( 3 Pi / 16 )
294     data8 0x3FE6A09E667F3BCD // sin ( 4 Pi / 16 )
295     data8 0x3FE6A09E667F3BCD // cos ( 4 Pi / 16 )
297     data8 0x3FEA9B66290EA1A3 // sin ( 5 Pi / 16 )
298     data8 0x3FE1C73B39AE68C8 // cos ( 5 Pi / 16 )
300     data8 0x3FED906BCF328D46 // sin ( 6 Pi / 16 )
301     data8 0x3FD87DE2A6AEA963 // cos ( 6 Pi / 16 )
303     data8 0x3FEF6297CFF75CB0 // sin ( 7 Pi / 16 )
304     data8 0x3FC8F8B83C69A60B // cos ( 7 Pi / 16 )
306     data8 0x3FF0000000000000 // sin ( 8 Pi / 16 )
307     data8 0x0000000000000000 // cos ( 8 Pi / 16 )
309     data8 0x3FEF6297CFF75CB0 // sin ( 9 Pi / 16 )
310     data8 0xBFC8F8B83C69A60B // cos ( 9 Pi / 16 )
312     data8 0x3FED906BCF328D46 // sin ( 10 Pi / 16 )
313     data8 0xBFD87DE2A6AEA963 // cos ( 10 Pi / 16 )
315     data8 0x3FEA9B66290EA1A3 // sin ( 11 Pi / 16 )
316     data8 0xBFE1C73B39AE68C8 // cos ( 11 Pi / 16 )
318     data8 0x3FE6A09E667F3BCD // sin ( 12 Pi / 16 )
319     data8 0xBFE6A09E667F3BCD // cos ( 12 Pi / 16 )
321     data8 0x3FE1C73B39AE68C8 // sin ( 13 Pi / 16 )
322     data8 0xBFEA9B66290EA1A3 // cos ( 13 Pi / 16 )
324     data8 0x3FD87DE2A6AEA963 // sin ( 14 Pi / 16 )
325     data8 0xBFED906BCF328D46 // cos ( 14 Pi / 16 )
327     data8 0x3FC8F8B83C69A60B // sin ( 15 Pi / 16 )
328     data8 0xBFEF6297CFF75CB0 // cos ( 15 Pi / 16 )
330     data8 0x0000000000000000 // sin ( 16 Pi / 16 )
331     data8 0xBFF0000000000000 // cos ( 16 Pi / 16 )
333     data8 0xBFC8F8B83C69A60B // sin ( 17 Pi / 16 )
334     data8 0xBFEF6297CFF75CB0 // cos ( 17 Pi / 16 )
336     data8 0xBFD87DE2A6AEA963 // sin ( 18 Pi / 16 )
337     data8 0xBFED906BCF328D46 // cos ( 18 Pi / 16 )
339     data8 0xBFE1C73B39AE68C8 // sin ( 19 Pi / 16 )
340     data8 0xBFEA9B66290EA1A3 // cos ( 19 Pi / 16 )
342     data8 0xBFE6A09E667F3BCD // sin ( 20 Pi / 16 )
343     data8 0xBFE6A09E667F3BCD // cos ( 20 Pi / 16 )
345     data8 0xBFEA9B66290EA1A3 // sin ( 21 Pi / 16 )
346     data8 0xBFE1C73B39AE68C8 // cos ( 21 Pi / 16 )
348     data8 0xBFED906BCF328D46 // sin ( 22 Pi / 16 )
349     data8 0xBFD87DE2A6AEA963 // cos ( 22 Pi / 16 )
351     data8 0xBFEF6297CFF75CB0 // sin ( 23 Pi / 16 )
352     data8 0xBFC8F8B83C69A60B // cos ( 23 Pi / 16 )
354     data8 0xBFF0000000000000 // sin ( 24 Pi / 16 )
355     data8 0x0000000000000000 // cos ( 24 Pi / 16 )
357     data8 0xBFEF6297CFF75CB0 // sin ( 25 Pi / 16 )
358     data8 0x3FC8F8B83C69A60B // cos ( 25 Pi / 16 )
360     data8 0xBFED906BCF328D46 // sin ( 26 Pi / 16 )
361     data8 0x3FD87DE2A6AEA963 // cos ( 26 Pi / 16 )
363     data8 0xBFEA9B66290EA1A3 // sin ( 27 Pi / 16 )
364     data8 0x3FE1C73B39AE68C8 // cos ( 27 Pi / 16 )
366     data8 0xBFE6A09E667F3BCD // sin ( 28 Pi / 16 )
367     data8 0x3FE6A09E667F3BCD // cos ( 28 Pi / 16 )
369     data8 0xBFE1C73B39AE68C8 // sin ( 29 Pi / 16 )
370     data8 0x3FEA9B66290EA1A3 // cos ( 29 Pi / 16 )
372     data8 0xBFD87DE2A6AEA963 // sin ( 30 Pi / 16 )
373     data8 0x3FED906BCF328D46 // cos ( 30 Pi / 16 )
375     data8 0xBFC8F8B83C69A60B // sin ( 31 Pi / 16 )
376     data8 0x3FEF6297CFF75CB0 // cos ( 31 Pi / 16 )
378     data8 0x0000000000000000 // sin ( 32 Pi / 16 )
379     data8 0x3FF0000000000000 // cos ( 32 Pi / 16 )
380 LOCAL_OBJECT_END(double_sin_cos_beta_k4)
382 .section .text
384 ////////////////////////////////////////////////////////
385 // There are two entry points: sin and cos
386 // If from sin, p8 is true
387 // If from cos, p9 is true
389 GLOBAL_IEEE754_ENTRY(sinf)
391 { .mlx
392       alloc         r32                 = ar.pfs,1,13,0,0
393       movl  sincosf_GR_sig_inv_pi_by_16 = 0xA2F9836E4E44152A //signd of 16/pi
395 { .mlx
396       addl         sincosf_AD_1         = @ltoff(double_sincosf_pi), gp
397       movl  sincosf_GR_rshf_2to61       = 0x47b8000000000000 // 1.1 2^(63+63-2)
400 { .mfi
401       ld8           sincosf_AD_1        = [sincosf_AD_1]
402       fnorm.s1      sincosf_NORM_f8     = f8     // Normalize argument
403       cmp.eq        p8,p9               = r0, r0 // set p8 (clear p9) for sin
405 { .mib
406       mov           sincosf_GR_exp_2tom61 = 0xffff-61 // exponent of scale 2^-61
407       mov           sincosf_r_sincos      = 0x0       // 0 for sin
408       br.cond.sptk  _SINCOSF_COMMON                 // go to common part
411 GLOBAL_IEEE754_END(sinf)
413 GLOBAL_IEEE754_ENTRY(cosf)
415 { .mlx
416       alloc         r32                 = ar.pfs,1,13,0,0
417       movl  sincosf_GR_sig_inv_pi_by_16 = 0xA2F9836E4E44152A //signd of 16/pi
419 { .mlx
420       addl          sincosf_AD_1        = @ltoff(double_sincosf_pi), gp
421       movl  sincosf_GR_rshf_2to61       = 0x47b8000000000000 // 1.1 2^(63+63-2)
424 { .mfi
425       ld8           sincosf_AD_1        = [sincosf_AD_1]
426       fnorm.s1      sincosf_NORM_f8     = f8        // Normalize argument
427       cmp.eq        p9,p8               = r0, r0    // set p9 (clear p8) for cos
429 { .mib
430       mov           sincosf_GR_exp_2tom61 = 0xffff-61 // exponent of scale 2^-61
431       mov           sincosf_r_sincos      = 0x8       // 8 for cos
432       nop.b         999
435 ////////////////////////////////////////////////////////
436 // All entry points end up here.
437 // If from sin, sincosf_r_sincos is 0 and p8 is true
438 // If from cos, sincosf_r_sincos is 8 = 2^(k-1) and p9 is true
439 // We add sincosf_r_sincos to N
441 ///////////// Common sin and cos part //////////////////
442 _SINCOSF_COMMON:
444 //  Form two constants we need
445 //  16/pi * 2^-2 * 2^63, scaled by 2^61 since we just loaded the significand
446 //  1.1000...000 * 2^(63+63-2) to right shift int(W) into the low significand
447 //  fcmp used to set denormal, and invalid on snans
448 { .mfi
449       setf.sig      sincosf_SIG_INV_PI_BY_16_2TO61 = sincosf_GR_sig_inv_pi_by_16
450       fclass.m      p6,p0                          = f8, 0xe7 // if x=0,inf,nan
451       mov           sincosf_exp_limit              = 0x10017
453 { .mlx
454       setf.d        sincosf_RSHF_2TO61  = sincosf_GR_rshf_2to61
455       movl          sincosf_GR_rshf     = 0x43e8000000000000 // 1.1000 2^63
456 };;                                                          // Right shift
458 //  Form another constant
459 //  2^-61 for scaling Nfloat
460 //  0x10017 is register_bias + 24.
461 //  So if f8 >= 2^24, go to large argument routines
462 { .mmi
463       getf.exp      sincosf_r_signexp   = f8
464       setf.exp      sincosf_2TOM61      = sincosf_GR_exp_2tom61
465       addl          gr_tmp              = -1,r0 // For "inexect" constant create
468 // Load the two pieces of pi/16
469 // Form another constant
470 //  1.1000...000 * 2^63, the right shift constant
471 { .mmb
472       ldfe          sincosf_Pi_by_16_1  = [sincosf_AD_1],16
473       setf.d        sincosf_RSHF        = sincosf_GR_rshf
474 (p6)  br.cond.spnt  _SINCOSF_SPECIAL_ARGS
477 // Getting argument's exp for "large arguments" filtering
478 { .mmi
479       ldfe          sincosf_Pi_by_16_2  = [sincosf_AD_1],16
480       setf.sig      fp_tmp              = gr_tmp // constant for inexact set
481       nop.i         999
484 // Polynomial coefficients (Q2, Q1, P2, P1) loading
485 { .mmi
486       ldfpd         sincosf_P2,sincosf_Q2 = [sincosf_AD_1],16
487       nop.m         999 
488       nop.i         999 
491 // Select exponent (17 lsb)
492 { .mmi
493       ldfpd         sincosf_P1,sincosf_Q1 = [sincosf_AD_1],16
494       nop.m         999 
495       dep.z         sincosf_r_exp         = sincosf_r_signexp, 0, 17
498 // p10 is true if we must call routines to handle larger arguments
499 // p10 is true if f8 exp is >= 0x10017 (2^24)
500 { .mfb
501       cmp.ge        p10,p0              = sincosf_r_exp,sincosf_exp_limit
502       nop.f         999
503 (p10) br.cond.spnt  _SINCOSF_LARGE_ARGS // Go to "large args" routine
506 // sincosf_W          = x * sincosf_Inv_Pi_by_16
507 // Multiply x by scaled 16/pi and add large const to shift integer part of W to
508 //   rightmost bits of significand
509 { .mfi
510       nop.m         999 
511       fma.s1 sincosf_W_2TO61_RSH = sincosf_NORM_f8, sincosf_SIG_INV_PI_BY_16_2TO61, sincosf_RSHF_2TO61
512       nop.i         999 
515 // sincosf_NFLOAT = Round_Int_Nearest(sincosf_W)
516 // This is done by scaling back by 2^-61 and subtracting the shift constant
517 { .mfi
518       nop.m         999
519       fms.s1 sincosf_NFLOAT = sincosf_W_2TO61_RSH,sincosf_2TOM61,sincosf_RSHF
520       nop.i         999 
523 // get N = (int)sincosf_int_Nfloat
524 { .mfi
525       getf.sig      sincosf_GR_n        = sincosf_W_2TO61_RSH // integer N value
526       nop.f         999
527       nop.i         999 
530 // Add 2^(k-1) (which is in sincosf_r_sincos=8) to N
531 // sincosf_r          = -sincosf_Nfloat * sincosf_Pi_by_16_1 + x
532 { .mfi
533       add           sincosf_GR_n        = sincosf_GR_n, sincosf_r_sincos
534       fnma.s1 sincosf_r = sincosf_NFLOAT, sincosf_Pi_by_16_1, sincosf_NORM_f8
535       nop.i         999 
538 // Get M (least k+1 bits of N)
539 { .mmi
540       and           sincosf_GR_m        = 0x1f,sincosf_GR_n // Put mask 0x1F  - 
541       nop.m         999                                     // - select k+1 bits
542       nop.i         999
545 // Add 16*M to address of sin_cos_beta table
546 { .mfi
547       shladd        sincosf_AD_2        = sincosf_GR_32m, 4, sincosf_AD_1
548 (p8)  fclass.m.unc  p10,p0              = f8,0x0b  // If sin denormal input -
549       nop.i         999 
552 // Load Sin and Cos table value using obtained index m  (sincosf_AD_2)
553 { .mfi
554       ldfd          sincosf_Sm          = [sincosf_AD_2],8 // Sin value S[m]
555 (p9)  fclass.m.unc  p11,p0              = f8,0x0b  // If cos denormal input -
556       nop.i         999                            // - set denormal
559 // sincosf_r          = sincosf_r -sincosf_Nfloat * sincosf_Pi_by_16_2
560 { .mfi
561       ldfd          sincosf_Cm          = [sincosf_AD_2] // Cos table value C[m]
562       fnma.s1  sincosf_r_exact = sincosf_NFLOAT, sincosf_Pi_by_16_2, sincosf_r
563       nop.i         999
565 // get rsq = r*r
566 { .mfi
567       nop.m         999
568       fma.s1        sincosf_rsq         = sincosf_r, sincosf_r,  f0 // r^2 = r*r
569       nop.i         999
572 { .mfi
573       nop.m         999
574       fmpy.s0       fp_tmp              = fp_tmp, fp_tmp // forces inexact flag
575       nop.i         999                                
578 // Polynomials calculation 
579 // Q = Q2*r^2 + Q1
580 // P = P2*r^2 + P1
581 { .mfi
582       nop.m         999
583       fma.s1        sincosf_Q           = sincosf_rsq, sincosf_Q2, sincosf_Q1
584       nop.i         999
586 { .mfi
587       nop.m         999
588       fma.s1        sincosf_P           = sincosf_rsq, sincosf_P2, sincosf_P1
589       nop.i         999 
592 // get rcube and S[m]*r^2
593 { .mfi
594       nop.m         999
595       fmpy.s1       sincosf_srsq        = sincosf_Sm,sincosf_rsq // r^2*S[m]
596       nop.i         999
598 { .mfi
599       nop.m         999
600       fmpy.s1       sincosf_rcub        = sincosf_r_exact, sincosf_rsq
601       nop.i         999 
604 // Get final P and Q
605 // Q = Q*S[m]*r^2 + S[m]
606 // P = P*r^3 + r
607 { .mfi
608       nop.m         999
609       fma.s1        sincosf_Q           = sincosf_srsq,sincosf_Q, sincosf_Sm
610       nop.i         999
612 { .mfi
613       nop.m         999
614       fma.s1        sincosf_P           = sincosf_rcub,sincosf_P,sincosf_r_exact
615       nop.i         999 
618 // If sinf(denormal) - force underflow to be set
619 .pred.rel "mutex",p10,p11
620 { .mfi
621       nop.m         999
622 (p10) fmpy.s.s0     fp_tmp              = f8,f8 // forces underflow flag
623       nop.i         999                         // for denormal sine args
625 // If cosf(denormal) - force denormal to be set
626 { .mfi
627       nop.m         999
628 (p11) fma.s.s0     fp_tmp              = f8, f1, f8 // forces denormal flag
629       nop.i         999                              // for denormal cosine args
633 // Final calculation
634 // result = C[m]*P + Q
635 { .mfb
636       nop.m         999
637       fma.s.s0      f8                  = sincosf_Cm, sincosf_P, sincosf_Q
638       br.ret.sptk   b0 // Exit for common path
641 ////////// x = 0/Inf/NaN path //////////////////
642 _SINCOSF_SPECIAL_ARGS:
643 .pred.rel "mutex",p8,p9
644 // sinf(+/-0) = +/-0
645 // sinf(Inf)  = NaN
646 // sinf(NaN)  = NaN
647 { .mfi
648       nop.m         999
649 (p8)  fma.s.s0      f8                  = f8, f0, f0 // sinf(+/-0,NaN,Inf)
650       nop.i         999
652 // cosf(+/-0) = 1.0
653 // cosf(Inf)  = NaN
654 // cosf(NaN)  = NaN
655 { .mfb
656       nop.m         999
657 (p9)  fma.s.s0      f8                  = f8, f0, f1 // cosf(+/-0,NaN,Inf)
658       br.ret.sptk   b0 // Exit for x = 0/Inf/NaN path
661 GLOBAL_IEEE754_END(cosf)
663 //////////// x >= 2^24 - large arguments routine call ////////////
664 LOCAL_LIBM_ENTRY(__libm_callout_sincosf)
665 _SINCOSF_LARGE_ARGS:
666 .prologue
667 { .mfi
668       mov           sincosf_GR_all_ones = -1 // 0xffffffff
669       nop.f         999
670 .save ar.pfs,GR_SAVE_PFS
671       mov           GR_SAVE_PFS         = ar.pfs
675 { .mfi
676       mov           GR_SAVE_GP          = gp
677       nop.f         999
678 .save b0, GR_SAVE_B0
679       mov           GR_SAVE_B0          = b0
681 .body
683 { .mbb
684       setf.sig      sincosf_save_tmp    = sincosf_GR_all_ones  // inexact set
685       nop.b         999
686 (p8)  br.call.sptk.many b0              = __libm_sin_large# // sinf(large_X)
689 { .mbb
690       cmp.ne        p9,p0               = sincosf_r_sincos, r0 // set p9 if cos
691       nop.b         999
692 (p9)  br.call.sptk.many b0              = __libm_cos_large# // cosf(large_X)
695 { .mfi
696       mov           gp                  = GR_SAVE_GP
697       fma.s.s0      f8                  = f8, f1, f0 // Round result to single
698       mov           b0                  = GR_SAVE_B0
700 { .mfi // force inexact set
701       nop.m         999
702       fmpy.s0       sincosf_save_tmp    = sincosf_save_tmp, sincosf_save_tmp 
703       nop.i         999                                               
706 { .mib
707       nop.m         999
708       mov           ar.pfs              = GR_SAVE_PFS
709       br.ret.sptk   b0 // Exit for large arguments routine call
711 LOCAL_LIBM_END(__libm_callout_sincosf)
713 .type    __libm_sin_large#, @function
714 .global  __libm_sin_large#
715 .type    __libm_cos_large#, @function
716 .global  __libm_cos_large#