localedata: dz_BT, bo_CN: convert to UTF-8
[glibc.git] / sysdeps / ia64 / fpu / libm_sincos.S
blobbef2fee6fd99e5b0b63dbca66958bf8f9a7769ad
1 .file "libm_sincos.s"
4 // Copyright (c) 2002 - 2005, Intel Corporation
5 // All rights reserved.
6 //
7 //
8 // Redistribution and use in source and binary forms, with or without
9 // modification, are permitted provided that the following conditions are
10 // met:
12 // * Redistributions of source code must retain the above copyright
13 // notice, this list of conditions and the following disclaimer.
15 // * Redistributions in binary form must reproduce the above copyright
16 // notice, this list of conditions and the following disclaimer in the
17 // documentation and/or other materials provided with the distribution.
19 // * The name of Intel Corporation may not be used to endorse or promote
20 // products derived from this software without specific prior written
21 // permission.
23 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR ITS
27 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
29 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
31 // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR TORT (INCLUDING
32 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 // Intel Corporation is the author of this code, and requests that all
36 // problem reports or change requests be submitted to it directly at
37 // http://www.intel.com/software/products/opensource/libraries/num.htm.
39 // History
40 //==============================================================
41 // 02/01/02 Initial version
42 // 02/18/02 Large arguments processing routine is excluded.
43 //          External interface entry points are added
44 // 03/13/02 Corrected restore of predicate registers
45 // 03/19/02 Added stack unwind around call to __libm_cis_large
46 // 09/05/02 Work range is widened by reduction strengthen (3 parts of Pi/16)
47 // 02/10/03 Reordered header: .section, .global, .proc, .align
48 // 08/08/03 Improved performance
49 // 02/11/04 cis is moved to the separate file.
50 // 03/31/05 Reformatted delimiters between data tables
52 // API
53 //==============================================================
54 // 1) void sincos(double, double*s, double*c)
55 // 2) __libm_sincos - internal LIBM function, that accepts
56 //    argument in f8 and returns cosine through f8, sine through f9
58 // Overview of operation
59 //==============================================================
61 // Step 1
62 // ======
63 // Reduce x to region -1/2*pi/2^k ===== 0 ===== +1/2*pi/2^k  where k=4
64 //    divide x by pi/2^k.
65 //    Multiply by 2^k/pi.
66 //    nfloat = Round result to integer (round-to-nearest)
68 // r = x -  nfloat * pi/2^k
69 //    Do this as ((((x -  nfloat * HIGH(pi/2^k))) -
70 //                        nfloat * LOW(pi/2^k)) -
71 //                        nfloat * LOWEST(pi/2^k) for increased accuracy.
72 //    pi/2^k is stored as two numbers that when added make pi/2^k.
73 //       pi/2^k = HIGH(pi/2^k) + LOW(pi/2^k)
74 //    HIGH and LOW parts are rounded to zero values,
75 //    and LOWEST is rounded to nearest one.
77 // x = (nfloat * pi/2^k) + r
78 //    r is small enough that we can use a polynomial approximation
79 //    and is referred to as the reduced argument.
81 // Step 3
82 // ======
83 // Take the unreduced part and remove the multiples of 2pi.
84 // So nfloat = nfloat (with lower k+1 bits cleared) + lower k+1 bits
86 //    nfloat (with lower k+1 bits cleared) is a multiple of 2^(k+1)
87 //    N * 2^(k+1)
88 //    nfloat * pi/2^k = N * 2^(k+1) * pi/2^k + (lower k+1 bits) * pi/2^k
89 //    nfloat * pi/2^k = N * 2 * pi + (lower k+1 bits) * pi/2^k
90 //    nfloat * pi/2^k = N2pi + M * pi/2^k
93 // Sin(x) = Sin((nfloat * pi/2^k) + r)
94 //        = Sin(nfloat * pi/2^k) * Cos(r) + Cos(nfloat * pi/2^k) * Sin(r)
96 //          Sin(nfloat * pi/2^k) = Sin(N2pi + Mpi/2^k)
97 //                               = Sin(N2pi)Cos(Mpi/2^k) + Cos(N2pi)Sin(Mpi/2^k)
98 //                               = Sin(Mpi/2^k)
100 //          Cos(nfloat * pi/2^k) = Cos(N2pi + Mpi/2^k)
101 //                               = Cos(N2pi)Cos(Mpi/2^k) + Sin(N2pi)Sin(Mpi/2^k)
102 //                               = Cos(Mpi/2^k)
104 // Sin(x) = Sin(Mpi/2^k) Cos(r) + Cos(Mpi/2^k) Sin(r)
107 // Step 4
108 // ======
109 // 0 <= M < 2^(k+1)
110 // There are 2^(k+1) Sin entries in a table.
111 // There are 2^(k+1) Cos entries in a table.
113 // Get Sin(Mpi/2^k) and Cos(Mpi/2^k) by table lookup.
116 // Step 5
117 // ======
118 // Calculate Cos(r) and Sin(r) by polynomial approximation.
120 // Cos(r) = 1 + r^2 q1  + r^4 q2 + r^6 q3 + ... = Series for Cos
121 // Sin(r) = r + r^3 p1  + r^5 p2 + r^7 p3 + ... = Series for Sin
123 // and the coefficients q1, q2, ... and p1, p2, ... are stored in a table
126 // Calculate
127 // Sin(x) = Sin(Mpi/2^k) Cos(r) + Cos(Mpi/2^k) Sin(r)
129 // as follows
131 //    S[m] = Sin(Mpi/2^k) and C[m] = Cos(Mpi/2^k)
132 //    rsq = r*r
135 //    P = p1 + r^2p2 + r^4p3 + r^6p4
136 //    Q = q1 + r^2q2 + r^4q3 + r^6q4
138 //       rcub = r * rsq
139 //       Sin(r) = r + rcub * P
140 //              = r + r^3p1  + r^5p2 + r^7p3 + r^9p4 + ... = Sin(r)
142 //            The coefficients are not exactly these values, but almost.
144 //            p1 = -1/6  = -1/3!
145 //            p2 = 1/120 =  1/5!
146 //            p3 = -1/5040 = -1/7!
147 //            p4 = 1/362889 = 1/9!
149 //       P =  r + rcub * P
151 //    Answer = S[m] Cos(r) + C[m] P
153 //       Cos(r) = 1 + rsq Q
154 //       Cos(r) = 1 + r^2 Q
155 //       Cos(r) = 1 + r^2 (q1 + r^2q2 + r^4q3 + r^6q4)
156 //       Cos(r) = 1 + r^2q1 + r^4q2 + r^6q3 + r^8q4 + ...
158 //       S[m] Cos(r) = S[m](1 + rsq Q)
159 //       S[m] Cos(r) = S[m] + S[m] rsq Q
160 //       S[m] Cos(r) = S[m] + s_rsq Q
161 //       Q           = S[m] + s_rsq Q
163 // Then,
165 //    Answer = Q + C[m] P
167 // Registers used
168 //==============================================================
169 // general input registers:
170 // r14 -> r39
172 // predicate registers used:
173 // p6 -> p14
175 // floating-point registers used
176 // f9 -> f15
177 // f32 -> f67
179 // Assembly macros
180 //==============================================================
182 cis_Arg                     = f8
184 cis_Sin_res                 = f9
185 cis_Cos_res                 = f8
187 cis_NORM_f8                 = f10
188 cis_W                       = f11
189 cis_int_Nfloat              = f12
190 cis_Nfloat                  = f13
192 cis_r                       = f14
193 cis_rsq                     = f15
194 cis_rcub                    = f32
196 cis_Inv_Pi_by_16            = f33
197 cis_Pi_by_16_hi             = f34
198 cis_Pi_by_16_lo             = f35
200 cis_Inv_Pi_by_64            = f36
201 cis_Pi_by_16_lowest         = f37
202 cis_r_exact                 = f38
205 cis_P1                      = f39
206 cis_Q1                      = f40
207 cis_P2                      = f41
208 cis_Q2                      = f42
209 cis_P3                      = f43
210 cis_Q3                      = f44
211 cis_P4                      = f45
212 cis_Q4                      = f46
214 cis_P_temp1                 = f47
215 cis_P_temp2                 = f48
217 cis_Q_temp1                 = f49
218 cis_Q_temp2                 = f50
220 cis_P                       = f51
222 cis_SIG_INV_PI_BY_16_2TO61  = f52
223 cis_RSHF_2TO61              = f53
224 cis_RSHF                    = f54
225 cis_2TOM61                  = f55
226 cis_NFLOAT                  = f56
227 cis_W_2TO61_RSH             = f57
229 cis_tmp                     = f58
231 cis_Sm_sin                  = f59
232 cis_Cm_sin                  = f60
234 cis_Sm_cos                  = f61
235 cis_Cm_cos                  = f62
237 cis_srsq_sin                = f63
238 cis_srsq_cos                = f64
240 cis_Q_sin                   = f65
241 cis_Q_cos                   = f66
242 cis_Q                       = f67
244 /////////////////////////////////////////////////////////////
246 cis_pResSin                 = r33
247 cis_pResCos                 = r34
249 cis_GR_sig_inv_pi_by_16     = r14
250 cis_GR_rshf_2to61           = r15
251 cis_GR_rshf                 = r16
252 cis_GR_exp_2tom61           = r17
253 cis_GR_n                    = r18
254 cis_GR_n_sin                = r19
255 cis_exp_limit               = r20
256 cis_r_signexp               = r21
257 cis_AD_1                    = r22
258 cis_r_sincos                = r23
259 cis_r_exp                   = r24
260 cis_r_17_ones               = r25
261 cis_GR_m_sin                = r26
262 cis_GR_32m_sin              = r26
263 cis_GR_n_cos                = r27
264 cis_GR_m_cos                = r28
265 cis_GR_32m_cos              = r28
266 cis_AD_2_sin                = r29
267 cis_AD_2_cos                = r30
268 cis_gr_tmp                  = r31
270 GR_SAVE_B0                  = r35
271 GR_SAVE_GP                  = r36
272 rB0_SAVED                   = r37
273 GR_SAVE_PFS                 = r38
274 GR_SAVE_PR                  = r39
276 RODATA
278 .align 16
279 // Pi/16 parts
280 LOCAL_OBJECT_START(double_cis_pi)
281    data8 0xC90FDAA22168C234, 0x00003FFC // pi/16 1st part
282    data8 0xC4C6628B80DC1CD1, 0x00003FBC // pi/16 2nd part
283    data8 0xA4093822299F31D0, 0x00003F7A // pi/16 3rd part
284 LOCAL_OBJECT_END(double_cis_pi)
286 // Coefficients for polynomials
287 LOCAL_OBJECT_START(double_cis_pq_k4)
288    data8 0x3EC71C963717C63A // P4
289    data8 0x3EF9FFBA8F191AE6 // Q4
290    data8 0xBF2A01A00F4E11A8 // P3
291    data8 0xBF56C16C05AC77BF // Q3
292    data8 0x3F8111111110F167 // P2
293    data8 0x3FA555555554DD45 // Q2
294    data8 0xBFC5555555555555 // P1
295    data8 0xBFDFFFFFFFFFFFFC // Q1
296 LOCAL_OBJECT_END(double_cis_pq_k4)
298 // Sincos table (S[m], C[m])
299 LOCAL_OBJECT_START(double_sin_cos_beta_k4)
300 data8 0x0000000000000000 , 0x00000000 // sin( 0 pi/16)  S0
301 data8 0x8000000000000000 , 0x00003fff // cos( 0 pi/16)  C0
303 data8 0xc7c5c1e34d3055b3 , 0x00003ffc // sin( 1 pi/16)  S1
304 data8 0xfb14be7fbae58157 , 0x00003ffe // cos( 1 pi/16)  C1
306 data8 0xc3ef1535754b168e , 0x00003ffd // sin( 2 pi/16)  S2
307 data8 0xec835e79946a3146 , 0x00003ffe // cos( 2 pi/16)  C2
309 data8 0x8e39d9cd73464364 , 0x00003ffe // sin( 3 pi/16)  S3
310 data8 0xd4db3148750d181a , 0x00003ffe // cos( 3 pi/16)  C3
312 data8 0xb504f333f9de6484 , 0x00003ffe // sin( 4 pi/16)  S4
313 data8 0xb504f333f9de6484 , 0x00003ffe // cos( 4 pi/16)  C4
315 data8 0xd4db3148750d181a , 0x00003ffe // sin( 5 pi/16)  C3
316 data8 0x8e39d9cd73464364 , 0x00003ffe // cos( 5 pi/16)  S3
318 data8 0xec835e79946a3146 , 0x00003ffe // sin( 6 pi/16)  C2
319 data8 0xc3ef1535754b168e , 0x00003ffd // cos( 6 pi/16)  S2
321 data8 0xfb14be7fbae58157 , 0x00003ffe // sin( 7 pi/16)  C1
322 data8 0xc7c5c1e34d3055b3 , 0x00003ffc // cos( 7 pi/16)  S1
324 data8 0x8000000000000000 , 0x00003fff // sin( 8 pi/16)  C0
325 data8 0x0000000000000000 , 0x00000000 // cos( 8 pi/16)  S0
327 data8 0xfb14be7fbae58157 , 0x00003ffe // sin( 9 pi/16)  C1
328 data8 0xc7c5c1e34d3055b3 , 0x0000bffc // cos( 9 pi/16)  -S1
330 data8 0xec835e79946a3146 , 0x00003ffe // sin(10 pi/16)  C2
331 data8 0xc3ef1535754b168e , 0x0000bffd // cos(10 pi/16)  -S2
333 data8 0xd4db3148750d181a , 0x00003ffe // sin(11 pi/16)  C3
334 data8 0x8e39d9cd73464364 , 0x0000bffe // cos(11 pi/16)  -S3
336 data8 0xb504f333f9de6484 , 0x00003ffe // sin(12 pi/16)  S4
337 data8 0xb504f333f9de6484 , 0x0000bffe // cos(12 pi/16)  -S4
339 data8 0x8e39d9cd73464364 , 0x00003ffe // sin(13 pi/16) S3
340 data8 0xd4db3148750d181a , 0x0000bffe // cos(13 pi/16) -C3
342 data8 0xc3ef1535754b168e , 0x00003ffd // sin(14 pi/16) S2
343 data8 0xec835e79946a3146 , 0x0000bffe // cos(14 pi/16) -C2
345 data8 0xc7c5c1e34d3055b3 , 0x00003ffc // sin(15 pi/16) S1
346 data8 0xfb14be7fbae58157 , 0x0000bffe // cos(15 pi/16) -C1
348 data8 0x0000000000000000 , 0x00000000 // sin(16 pi/16) S0
349 data8 0x8000000000000000 , 0x0000bfff // cos(16 pi/16) -C0
351 data8 0xc7c5c1e34d3055b3 , 0x0000bffc // sin(17 pi/16) -S1
352 data8 0xfb14be7fbae58157 , 0x0000bffe // cos(17 pi/16) -C1
354 data8 0xc3ef1535754b168e , 0x0000bffd // sin(18 pi/16) -S2
355 data8 0xec835e79946a3146 , 0x0000bffe // cos(18 pi/16) -C2
357 data8 0x8e39d9cd73464364 , 0x0000bffe // sin(19 pi/16) -S3
358 data8 0xd4db3148750d181a , 0x0000bffe // cos(19 pi/16) -C3
360 data8 0xb504f333f9de6484 , 0x0000bffe // sin(20 pi/16) -S4
361 data8 0xb504f333f9de6484 , 0x0000bffe // cos(20 pi/16) -S4
363 data8 0xd4db3148750d181a , 0x0000bffe // sin(21 pi/16) -C3
364 data8 0x8e39d9cd73464364 , 0x0000bffe // cos(21 pi/16) -S3
366 data8 0xec835e79946a3146 , 0x0000bffe // sin(22 pi/16) -C2
367 data8 0xc3ef1535754b168e , 0x0000bffd // cos(22 pi/16) -S2
369 data8 0xfb14be7fbae58157 , 0x0000bffe // sin(23 pi/16) -C1
370 data8 0xc7c5c1e34d3055b3 , 0x0000bffc // cos(23 pi/16) -S1
372 data8 0x8000000000000000 , 0x0000bfff // sin(24 pi/16) -C0
373 data8 0x0000000000000000 , 0x00000000 // cos(24 pi/16) S0
375 data8 0xfb14be7fbae58157 , 0x0000bffe // sin(25 pi/16) -C1
376 data8 0xc7c5c1e34d3055b3 , 0x00003ffc // cos(25 pi/16) S1
378 data8 0xec835e79946a3146 , 0x0000bffe // sin(26 pi/16) -C2
379 data8 0xc3ef1535754b168e , 0x00003ffd // cos(26 pi/16) S2
381 data8 0xd4db3148750d181a , 0x0000bffe // sin(27 pi/16) -C3
382 data8 0x8e39d9cd73464364 , 0x00003ffe // cos(27 pi/16) S3
384 data8 0xb504f333f9de6484 , 0x0000bffe // sin(28 pi/16) -S4
385 data8 0xb504f333f9de6484 , 0x00003ffe // cos(28 pi/16) S4
387 data8 0x8e39d9cd73464364 , 0x0000bffe // sin(29 pi/16) -S3
388 data8 0xd4db3148750d181a , 0x00003ffe // cos(29 pi/16) C3
390 data8 0xc3ef1535754b168e , 0x0000bffd // sin(30 pi/16) -S2
391 data8 0xec835e79946a3146 , 0x00003ffe // cos(30 pi/16) C2
393 data8 0xc7c5c1e34d3055b3 , 0x0000bffc // sin(31 pi/16) -S1
394 data8 0xfb14be7fbae58157 , 0x00003ffe // cos(31 pi/16) C1
396 data8 0x0000000000000000 , 0x00000000 // sin(32 pi/16) S0
397 data8 0x8000000000000000 , 0x00003fff // cos(32 pi/16) C0
398 LOCAL_OBJECT_END(double_sin_cos_beta_k4)
400 .section .text
402 GLOBAL_IEEE754_ENTRY(sincos)
403 // cis_GR_sig_inv_pi_by_16 = significand of 16/pi
404 { .mlx
405       getf.exp      cis_r_signexp       = cis_Arg
406       movl          cis_GR_sig_inv_pi_by_16 = 0xA2F9836E4E44152A
409 // cis_GR_rshf_2to61 = 1.1000 2^(63+63-2)
410 { .mlx
411       addl          cis_AD_1                = @ltoff(double_cis_pi), gp
412       movl          cis_GR_rshf_2to61       = 0x47b8000000000000
415 { .mfi
416       ld8           cis_AD_1            = [cis_AD_1]
417       fnorm.s1      cis_NORM_f8         = cis_Arg
418       cmp.eq        p13, p14            = r0, r0 // p13 set for sincos
420 // cis_GR_exp_2tom61 = exponent of scaling factor 2^-61
421 { .mib
422       mov           cis_GR_exp_2tom61   = 0xffff-61
423       nop.i         0
424       br.cond.sptk  _CIS_COMMON
426 GLOBAL_IEEE754_END(sincos)
427 libm_alias_double_other (__sincos, sincos)
429 GLOBAL_LIBM_ENTRY(__libm_sincos)
430 // cis_GR_sig_inv_pi_by_16 = significand of 16/pi
431 { .mlx
432       getf.exp      cis_r_signexp       = cis_Arg
433       movl          cis_GR_sig_inv_pi_by_16 = 0xA2F9836E4E44152A
435 // cis_GR_rshf_2to61 = 1.1000 2^(63+63-2)
436 { .mlx
437       addl          cis_AD_1            = @ltoff(double_cis_pi), gp
438       movl          cis_GR_rshf_2to61   = 0x47b8000000000000
441 // p14 set for __libm_sincos and cis
442 { .mfi
443       ld8           cis_AD_1            = [cis_AD_1]
444       fnorm.s1      cis_NORM_f8         = cis_Arg
445       cmp.eq        p14, p13            = r0, r0
447 // cis_GR_exp_2tom61 = exponent of scaling factor 2^-61
448 { .mib
449       mov           cis_GR_exp_2tom61   = 0xffff-61
450       nop.i         0
451       nop.b         0
454 _CIS_COMMON:
455 //  Form two constants we need
456 //  16/pi * 2^-2 * 2^63, scaled by 2^61 since we just loaded the significand
457 //  1.1000...000 * 2^(63+63-2) to right shift int(W) into the low significand
458 //  fcmp used to set denormal, and invalid on snans
459 { .mfi
460       setf.sig      cis_SIG_INV_PI_BY_16_2TO61 = cis_GR_sig_inv_pi_by_16
461       fclass.m      p6,p0                      = cis_Arg, 0xe7 // if x=0,inf,nan
462       addl          cis_gr_tmp                 = -1, r0
464 // 1.1000 2^63 for right shift
465 { .mlx
466       setf.d        cis_RSHF_2TO61             = cis_GR_rshf_2to61
467       movl          cis_GR_rshf                = 0x43e8000000000000
470 //  Form another constant
471 //  2^-61 for scaling Nfloat
472 //  0x1001a is register_bias + 27.
473 //  So if f8 >= 2^27, go to large arguments routine
474 { .mfi
475       alloc         GR_SAVE_PFS         = ar.pfs, 3, 5, 0, 0
476       fclass.m      p11,p0              = cis_Arg, 0x0b // Test for x=unorm
477       mov           cis_exp_limit       = 0x1001a
479 { .mib
480       setf.exp      cis_2TOM61          = cis_GR_exp_2tom61
481       nop.i         0
482 (p6)  br.cond.spnt  _CIS_SPECIAL_ARGS
485 //  Load the two pieces of pi/16
486 //  Form another constant
487 //  1.1000...000 * 2^63, the right shift constant
488 { .mmb
489       ldfe          cis_Pi_by_16_hi     = [cis_AD_1],16
490       setf.d        cis_RSHF            = cis_GR_rshf
491 (p11) br.cond.spnt  _CIS_UNORM          // Branch if x=unorm
494 _CIS_COMMON2:
495 // Return here if x=unorm
496 // Create constant inexact set
497 { .mmi
498       ldfe          cis_Pi_by_16_lo     = [cis_AD_1],16
499       setf.sig      cis_tmp             = cis_gr_tmp
500       nop.i         0
503 // Select exponent (17 lsb)
504 { .mfi
505       ldfe          cis_Pi_by_16_lowest = [cis_AD_1],16
506       nop.f         0
507       dep.z         cis_r_exp           = cis_r_signexp, 0, 17
510 // Start loading P, Q coefficients
511 // p10 is true if we must call routines to handle larger arguments
512 // p10 is true if f8 exp is > 0x1001a
513 { .mmb
514       ldfpd         cis_P4,cis_Q4       = [cis_AD_1],16
515       cmp.ge        p10, p0             = cis_r_exp, cis_exp_limit
516 (p10) br.cond.spnt  _CIS_LARGE_ARGS // go to |x| >= 2^27 path
519 // cis_W = x * cis_Inv_Pi_by_16
520 // Multiply x by scaled 16/pi and add large const to shift integer part of W to
521 // rightmost bits of significand
522 { .mfi
523       ldfpd         cis_P3,cis_Q3       = [cis_AD_1],16
524       fma.s1 cis_W_2TO61_RSH = cis_NORM_f8,cis_SIG_INV_PI_BY_16_2TO61,cis_RSHF_2TO61
525       nop.i  0
528 // get N = (int)cis_int_Nfloat
529 // cis_NFLOAT = Round_Int_Nearest(cis_W)
530 { .mmf
531       getf.sig      cis_GR_n            = cis_W_2TO61_RSH
532       ldfpd  cis_P2,cis_Q2   = [cis_AD_1],16
533       fms.s1        cis_NFLOAT          = cis_W_2TO61_RSH,cis_2TOM61,cis_RSHF
536 // cis_r = -cis_Nfloat * cis_Pi_by_16_hi + x
537 { .mfi
538       ldfpd         cis_P1,cis_Q1       = [cis_AD_1], 16
539       fnma.s1       cis_r               = cis_NFLOAT,cis_Pi_by_16_hi,cis_NORM_f8
540       nop.i         0
543 // Add 2^(k-1) (which is in cis_r_sincos) to N
544 { .mmi
545       add           cis_GR_n_cos        = 0x8, cis_GR_n
547 //Get M (least k+1 bits of N)
548       and           cis_GR_m_sin        = 0x1f,cis_GR_n
549       and           cis_GR_m_cos        = 0x1f,cis_GR_n_cos
552 { .mmi
553       nop.m         0
554       nop.m         0
555       shl           cis_GR_32m_sin      = cis_GR_m_sin,5
558 // Add 32*M to address of sin_cos_beta table
559 // cis_r =  cis_r -cis_Nfloat * cis_Pi_by_16_lo
560 { .mfi
561       add           cis_AD_2_sin        = cis_GR_32m_sin, cis_AD_1
562       fnma.s1       cis_r               = cis_NFLOAT, cis_Pi_by_16_lo,  cis_r
563       shl           cis_GR_32m_cos      = cis_GR_m_cos,5
566 // Add 32*M to address of sin_cos_beta table
567 { .mmf
568       ldfe          cis_Sm_sin          = [cis_AD_2_sin],16
569       add           cis_AD_2_cos        = cis_GR_32m_cos, cis_AD_1
570       fclass.m.unc  p10,p0              = cis_Arg,0x0b  // den. input - uflow
573 { .mfi
574       ldfe          cis_Sm_cos          = [cis_AD_2_cos], 16
575       nop.i         0
578 { .mfi
579       ldfe          cis_Cm_sin          = [cis_AD_2_sin]
580       fma.s1        cis_rsq             = cis_r, cis_r,   f0  // get r^2
581       nop.i         0
583 // fmpy forces inexact flag
584 { .mfi
585       nop.m         0
586       fmpy.s0       cis_tmp             = cis_tmp,cis_tmp
587       nop.i         0
590 { .mfi
591       nop.m         0
592       fnma.s1       cis_r_exact         = cis_NFLOAT, cis_Pi_by_16_lowest, cis_r
593       nop.i         0
596 { .mfi
597       ldfe          cis_Cm_cos          = [cis_AD_2_cos]
598       fma.s1        cis_P_temp1         = cis_rsq, cis_P4, cis_P3
599       nop.i         0
602 { .mfi
603       nop.m         0
604       fma.s1        cis_Q_temp1         = cis_rsq, cis_Q4, cis_Q3
605       nop.i         0
608 { .mfi
609       nop.m         0
610       fmpy.s1       cis_srsq_sin        = cis_Sm_sin, cis_rsq
611       nop.i         0
613 { .mfi
614       nop.m         0
615       fmpy.s1       cis_srsq_cos        = cis_Sm_cos,cis_rsq
616       nop.i         0
619 { .mfi
620       nop.m         0
621       fma.s1        cis_Q_temp2         = cis_rsq, cis_Q_temp1, cis_Q2
622       nop.i         0
624 { .mfi
625       nop.m         0
626       fma.s1        cis_P_temp2         = cis_rsq, cis_P_temp1, cis_P2
627       nop.i         0
630 { .mfi
631       nop.m         0
632       fmpy.s1       cis_rcub            = cis_r_exact, cis_rsq // get r^3
633       nop.i         0
636 { .mfi
637       nop.m         0
638       fma.s1        cis_Q               = cis_rsq, cis_Q_temp2, cis_Q1
639       nop.i         0
641 { .mfi
642       nop.m         0
643       fma.s1        cis_P               = cis_rsq, cis_P_temp2, cis_P1
644       nop.i         0
647 { .mfi
648       nop.m         0
649       fma.s1        cis_Q_sin           = cis_srsq_sin,cis_Q, cis_Sm_sin
650       nop.i         0
652 { .mfi
653       nop.m         0
654       fma.s1        cis_Q_cos           = cis_srsq_cos,cis_Q, cis_Sm_cos
655       nop.i         0
658 { .mfi
659       nop.m         0
660       fma.s1        cis_P               = cis_rcub,cis_P, cis_r_exact // final P
661       nop.i         0
664 // If den. arg, force underflow to be set
665 { .mfi
666       nop.m         0
667 (p10) fmpy.d.s0     cis_tmp             = cis_Arg,cis_Arg
668       nop.i         0
671 { .mfi
672       nop.m         0
673       fma.d.s0      cis_Sin_res         = cis_Cm_sin,cis_P,cis_Q_sin//Final sin
674       nop.i         0
676 { .mfb
677       nop.m         0
678       fma.d.s0      cis_Cos_res         = cis_Cm_cos,cis_P,cis_Q_cos//Final cos
679 (p14) br.ret.sptk   b0  // common exit for __libm_sincos and cis main path
682 { .mmb
683       stfd          [cis_pResSin]       = cis_Sin_res
684       stfd          [cis_pResCos]       = cis_Cos_res
685       br.ret.sptk   b0 // common exit for sincos main path
688 _CIS_SPECIAL_ARGS:
689 // sin(+/-0) = +/-0
690 // sin(Inf)  = NaN
691 // sin(NaN)  = NaN
692 { .mfi
693       nop.m         999
694       fma.d.s0      cis_Sin_res          = cis_Arg, f0, f0 // sinf(+/-0,NaN,Inf)
695       nop.i         999
697 // cos(+/-0) = 1.0
698 // cos(Inf)  = NaN
699 // cos(NaN)  = NaN
700 { .mfb
701       nop.m         999
702       fma.d.s0      cis_Cos_res          = cis_Arg, f0, f1 // cosf(+/-0,NaN,Inf)
703 (p14) br.ret.sptk   b0 //spec exit for __libm_sincos and cis main path
706 { .mmb
707       stfd          [cis_pResSin]       = cis_Sin_res
708       stfd          [cis_pResCos]       = cis_Cos_res
709       br.ret.sptk   b0 // common exit for sincos main path
712 _CIS_UNORM:
713 // Here if x=unorm
714 { .mfb
715       getf.exp      cis_r_signexp       = cis_NORM_f8 // Get signexp of x
716       fcmp.eq.s0    p11,p0              = cis_Arg, f0 // Dummy op to set denorm
717       br.cond.sptk  _CIS_COMMON2        // Return to main path
720 GLOBAL_LIBM_END(__libm_sincos)
722 ////  |x| > 2^27 path  ///////
723 .proc _CIS_LARGE_ARGS
724 _CIS_LARGE_ARGS:
725 .prologue
726 { .mfi
727       nop.m         0
728       nop.f         0
729 .save ar.pfs, GR_SAVE_PFS
730       mov           GR_SAVE_PFS         = ar.pfs
734 { .mfi
735       mov           GR_SAVE_GP          = gp
736       nop.f         0
737 .save b0, GR_SAVE_B0
738       mov           GR_SAVE_B0          = b0
741 .body
742 // Call of huge arguments sincos
743 { .mib
744       nop.m         0
745       mov           GR_SAVE_PR          = pr
746       br.call.sptk  b0                  = __libm_sincos_large
749 { .mfi
750       mov           gp                  = GR_SAVE_GP
751       nop.f         0
752       mov           pr                  = GR_SAVE_PR, 0x1fffe
756 { .mfi
757       nop.m         0
758       nop.f         0
759       mov           b0                  = GR_SAVE_B0
763 { .mfi
764       nop.m         0
765       fma.d.s0      cis_Cos_res         = cis_Cos_res, f1, f0
766       mov           ar.pfs              = GR_SAVE_PFS
768 { .mfb
769       nop.m         0
770       fma.d.s0      cis_Sin_res         = cis_Sin_res, f1, f0
771 (p14) br.ret.sptk   b0  // exit for |x| > 2^27 path (__libm_sincos and cis)
774 { .mmb
775       stfd          [cis_pResSin]       = cis_Sin_res
776       stfd          [cis_pResCos]       = cis_Cos_res
777       br.ret.sptk   b0 // exit for sincos |x| > 2^27 path
779 .endp _CIS_LARGE_ARGS
781 .type __libm_sincos_large#,@function
782 .global __libm_sincos_large#