Remove support in configure for unsupported architectures
[glibc.git] / sysdeps / ia64 / fpu / libm_sincos.S
blob7fda2afac4926c3de49fe5675f1c8cb8c0bc265b
1 .file "libm_sincos.s"
4 // Copyright (c) 2002 - 2005, Intel Corporation
5 // All rights reserved.
6 //
7 // Contributed 2002 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/01/02 Initial version
43 // 02/18/02 Large arguments processing routine is excluded.
44 //          External interface entry points are added
45 // 03/13/02 Corrected restore of predicate registers
46 // 03/19/02 Added stack unwind around call to __libm_cis_large
47 // 09/05/02 Work range is widened by reduction strengthen (3 parts of Pi/16)
48 // 02/10/03 Reordered header: .section, .global, .proc, .align
49 // 08/08/03 Improved performance
50 // 02/11/04 cis is moved to the separate file.
51 // 03/31/05 Reformatted delimiters between data tables
53 // API
54 //==============================================================
55 // 1) void sincos(double, double*s, double*c)
56 // 2) __libm_sincos - internal LIBM function, that accepts
57 //    argument in f8 and returns cosine through f8, sine through f9
59 // Overview of operation
60 //==============================================================
62 // Step 1
63 // ======
64 // Reduce x to region -1/2*pi/2^k ===== 0 ===== +1/2*pi/2^k  where k=4
65 //    divide x by pi/2^k.
66 //    Multiply by 2^k/pi.
67 //    nfloat = Round result to integer (round-to-nearest)
69 // r = x -  nfloat * pi/2^k
70 //    Do this as ((((x -  nfloat * HIGH(pi/2^k))) -
71 //                        nfloat * LOW(pi/2^k)) -
72 //                        nfloat * LOWEST(pi/2^k) for increased accuracy.
73 //    pi/2^k is stored as two numbers that when added make pi/2^k.
74 //       pi/2^k = HIGH(pi/2^k) + LOW(pi/2^k)
75 //    HIGH and LOW parts are rounded to zero values,
76 //    and LOWEST is rounded to nearest one.
78 // x = (nfloat * pi/2^k) + r
79 //    r is small enough that we can use a polynomial approximation
80 //    and is referred to as the reduced argument.
82 // Step 3
83 // ======
84 // Take the unreduced part and remove the multiples of 2pi.
85 // So nfloat = nfloat (with lower k+1 bits cleared) + lower k+1 bits
87 //    nfloat (with lower k+1 bits cleared) is a multiple of 2^(k+1)
88 //    N * 2^(k+1)
89 //    nfloat * pi/2^k = N * 2^(k+1) * pi/2^k + (lower k+1 bits) * pi/2^k
90 //    nfloat * pi/2^k = N * 2 * pi + (lower k+1 bits) * pi/2^k
91 //    nfloat * pi/2^k = N2pi + M * pi/2^k
94 // Sin(x) = Sin((nfloat * pi/2^k) + r)
95 //        = Sin(nfloat * pi/2^k) * Cos(r) + Cos(nfloat * pi/2^k) * Sin(r)
97 //          Sin(nfloat * pi/2^k) = Sin(N2pi + Mpi/2^k)
98 //                               = Sin(N2pi)Cos(Mpi/2^k) + Cos(N2pi)Sin(Mpi/2^k)
99 //                               = Sin(Mpi/2^k)
101 //          Cos(nfloat * pi/2^k) = Cos(N2pi + Mpi/2^k)
102 //                               = Cos(N2pi)Cos(Mpi/2^k) + Sin(N2pi)Sin(Mpi/2^k)
103 //                               = Cos(Mpi/2^k)
105 // Sin(x) = Sin(Mpi/2^k) Cos(r) + Cos(Mpi/2^k) Sin(r)
108 // Step 4
109 // ======
110 // 0 <= M < 2^(k+1)
111 // There are 2^(k+1) Sin entries in a table.
112 // There are 2^(k+1) Cos entries in a table.
114 // Get Sin(Mpi/2^k) and Cos(Mpi/2^k) by table lookup.
117 // Step 5
118 // ======
119 // Calculate Cos(r) and Sin(r) by polynomial approximation.
121 // Cos(r) = 1 + r^2 q1  + r^4 q2 + r^6 q3 + ... = Series for Cos
122 // Sin(r) = r + r^3 p1  + r^5 p2 + r^7 p3 + ... = Series for Sin
124 // and the coefficients q1, q2, ... and p1, p2, ... are stored in a table
127 // Calculate
128 // Sin(x) = Sin(Mpi/2^k) Cos(r) + Cos(Mpi/2^k) Sin(r)
130 // as follows
132 //    S[m] = Sin(Mpi/2^k) and C[m] = Cos(Mpi/2^k)
133 //    rsq = r*r
136 //    P = p1 + r^2p2 + r^4p3 + r^6p4
137 //    Q = q1 + r^2q2 + r^4q3 + r^6q4
139 //       rcub = r * rsq
140 //       Sin(r) = r + rcub * P
141 //              = r + r^3p1  + r^5p2 + r^7p3 + r^9p4 + ... = Sin(r)
143 //            The coefficients are not exactly these values, but almost.
145 //            p1 = -1/6  = -1/3!
146 //            p2 = 1/120 =  1/5!
147 //            p3 = -1/5040 = -1/7!
148 //            p4 = 1/362889 = 1/9!
150 //       P =  r + rcub * P
152 //    Answer = S[m] Cos(r) + C[m] P
154 //       Cos(r) = 1 + rsq Q
155 //       Cos(r) = 1 + r^2 Q
156 //       Cos(r) = 1 + r^2 (q1 + r^2q2 + r^4q3 + r^6q4)
157 //       Cos(r) = 1 + r^2q1 + r^4q2 + r^6q3 + r^8q4 + ...
159 //       S[m] Cos(r) = S[m](1 + rsq Q)
160 //       S[m] Cos(r) = S[m] + S[m] rsq Q
161 //       S[m] Cos(r) = S[m] + s_rsq Q
162 //       Q           = S[m] + s_rsq Q
164 // Then,
166 //    Answer = Q + C[m] P
168 // Registers used
169 //==============================================================
170 // general input registers:
171 // r14 -> r39
173 // predicate registers used:
174 // p6 -> p14
176 // floating-point registers used
177 // f9 -> f15
178 // f32 -> f67
180 // Assembly macros
181 //==============================================================
183 cis_Arg                     = f8
185 cis_Sin_res                 = f9
186 cis_Cos_res                 = f8
188 cis_NORM_f8                 = f10
189 cis_W                       = f11
190 cis_int_Nfloat              = f12
191 cis_Nfloat                  = f13
193 cis_r                       = f14
194 cis_rsq                     = f15
195 cis_rcub                    = f32
197 cis_Inv_Pi_by_16            = f33
198 cis_Pi_by_16_hi             = f34
199 cis_Pi_by_16_lo             = f35
201 cis_Inv_Pi_by_64            = f36
202 cis_Pi_by_16_lowest         = f37
203 cis_r_exact                 = f38
206 cis_P1                      = f39
207 cis_Q1                      = f40
208 cis_P2                      = f41
209 cis_Q2                      = f42
210 cis_P3                      = f43
211 cis_Q3                      = f44
212 cis_P4                      = f45
213 cis_Q4                      = f46
215 cis_P_temp1                 = f47
216 cis_P_temp2                 = f48
218 cis_Q_temp1                 = f49
219 cis_Q_temp2                 = f50
221 cis_P                       = f51
223 cis_SIG_INV_PI_BY_16_2TO61  = f52
224 cis_RSHF_2TO61              = f53
225 cis_RSHF                    = f54
226 cis_2TOM61                  = f55
227 cis_NFLOAT                  = f56
228 cis_W_2TO61_RSH             = f57
230 cis_tmp                     = f58
232 cis_Sm_sin                  = f59
233 cis_Cm_sin                  = f60
235 cis_Sm_cos                  = f61
236 cis_Cm_cos                  = f62
238 cis_srsq_sin                = f63
239 cis_srsq_cos                = f64
241 cis_Q_sin                   = f65
242 cis_Q_cos                   = f66
243 cis_Q                       = f67
245 /////////////////////////////////////////////////////////////
247 cis_pResSin                 = r33
248 cis_pResCos                 = r34
250 cis_GR_sig_inv_pi_by_16     = r14
251 cis_GR_rshf_2to61           = r15
252 cis_GR_rshf                 = r16
253 cis_GR_exp_2tom61           = r17
254 cis_GR_n                    = r18
255 cis_GR_n_sin                = r19
256 cis_exp_limit               = r20
257 cis_r_signexp               = r21
258 cis_AD_1                    = r22
259 cis_r_sincos                = r23
260 cis_r_exp                   = r24
261 cis_r_17_ones               = r25
262 cis_GR_m_sin                = r26
263 cis_GR_32m_sin              = r26
264 cis_GR_n_cos                = r27
265 cis_GR_m_cos                = r28
266 cis_GR_32m_cos              = r28
267 cis_AD_2_sin                = r29
268 cis_AD_2_cos                = r30
269 cis_gr_tmp                  = r31
271 GR_SAVE_B0                  = r35
272 GR_SAVE_GP                  = r36
273 rB0_SAVED                   = r37
274 GR_SAVE_PFS                 = r38
275 GR_SAVE_PR                  = r39
277 RODATA
279 .align 16
280 // Pi/16 parts
281 LOCAL_OBJECT_START(double_cis_pi)
282    data8 0xC90FDAA22168C234, 0x00003FFC // pi/16 1st part
283    data8 0xC4C6628B80DC1CD1, 0x00003FBC // pi/16 2nd part
284    data8 0xA4093822299F31D0, 0x00003F7A // pi/16 3rd part
285 LOCAL_OBJECT_END(double_cis_pi)
287 // Coefficients for polynomials
288 LOCAL_OBJECT_START(double_cis_pq_k4)
289    data8 0x3EC71C963717C63A // P4
290    data8 0x3EF9FFBA8F191AE6 // Q4
291    data8 0xBF2A01A00F4E11A8 // P3
292    data8 0xBF56C16C05AC77BF // Q3
293    data8 0x3F8111111110F167 // P2
294    data8 0x3FA555555554DD45 // Q2
295    data8 0xBFC5555555555555 // P1
296    data8 0xBFDFFFFFFFFFFFFC // Q1
297 LOCAL_OBJECT_END(double_cis_pq_k4)
299 // Sincos table (S[m], C[m])
300 LOCAL_OBJECT_START(double_sin_cos_beta_k4)
301 data8 0x0000000000000000 , 0x00000000 // sin( 0 pi/16)  S0
302 data8 0x8000000000000000 , 0x00003fff // cos( 0 pi/16)  C0
304 data8 0xc7c5c1e34d3055b3 , 0x00003ffc // sin( 1 pi/16)  S1
305 data8 0xfb14be7fbae58157 , 0x00003ffe // cos( 1 pi/16)  C1
307 data8 0xc3ef1535754b168e , 0x00003ffd // sin( 2 pi/16)  S2
308 data8 0xec835e79946a3146 , 0x00003ffe // cos( 2 pi/16)  C2
310 data8 0x8e39d9cd73464364 , 0x00003ffe // sin( 3 pi/16)  S3
311 data8 0xd4db3148750d181a , 0x00003ffe // cos( 3 pi/16)  C3
313 data8 0xb504f333f9de6484 , 0x00003ffe // sin( 4 pi/16)  S4
314 data8 0xb504f333f9de6484 , 0x00003ffe // cos( 4 pi/16)  C4
316 data8 0xd4db3148750d181a , 0x00003ffe // sin( 5 pi/16)  C3
317 data8 0x8e39d9cd73464364 , 0x00003ffe // cos( 5 pi/16)  S3
319 data8 0xec835e79946a3146 , 0x00003ffe // sin( 6 pi/16)  C2
320 data8 0xc3ef1535754b168e , 0x00003ffd // cos( 6 pi/16)  S2
322 data8 0xfb14be7fbae58157 , 0x00003ffe // sin( 7 pi/16)  C1
323 data8 0xc7c5c1e34d3055b3 , 0x00003ffc // cos( 7 pi/16)  S1
325 data8 0x8000000000000000 , 0x00003fff // sin( 8 pi/16)  C0
326 data8 0x0000000000000000 , 0x00000000 // cos( 8 pi/16)  S0
328 data8 0xfb14be7fbae58157 , 0x00003ffe // sin( 9 pi/16)  C1
329 data8 0xc7c5c1e34d3055b3 , 0x0000bffc // cos( 9 pi/16)  -S1
331 data8 0xec835e79946a3146 , 0x00003ffe // sin(10 pi/16)  C2
332 data8 0xc3ef1535754b168e , 0x0000bffd // cos(10 pi/16)  -S2
334 data8 0xd4db3148750d181a , 0x00003ffe // sin(11 pi/16)  C3
335 data8 0x8e39d9cd73464364 , 0x0000bffe // cos(11 pi/16)  -S3
337 data8 0xb504f333f9de6484 , 0x00003ffe // sin(12 pi/16)  S4
338 data8 0xb504f333f9de6484 , 0x0000bffe // cos(12 pi/16)  -S4
340 data8 0x8e39d9cd73464364 , 0x00003ffe // sin(13 pi/16) S3
341 data8 0xd4db3148750d181a , 0x0000bffe // cos(13 pi/16) -C3
343 data8 0xc3ef1535754b168e , 0x00003ffd // sin(14 pi/16) S2
344 data8 0xec835e79946a3146 , 0x0000bffe // cos(14 pi/16) -C2
346 data8 0xc7c5c1e34d3055b3 , 0x00003ffc // sin(15 pi/16) S1
347 data8 0xfb14be7fbae58157 , 0x0000bffe // cos(15 pi/16) -C1
349 data8 0x0000000000000000 , 0x00000000 // sin(16 pi/16) S0
350 data8 0x8000000000000000 , 0x0000bfff // cos(16 pi/16) -C0
352 data8 0xc7c5c1e34d3055b3 , 0x0000bffc // sin(17 pi/16) -S1
353 data8 0xfb14be7fbae58157 , 0x0000bffe // cos(17 pi/16) -C1
355 data8 0xc3ef1535754b168e , 0x0000bffd // sin(18 pi/16) -S2
356 data8 0xec835e79946a3146 , 0x0000bffe // cos(18 pi/16) -C2
358 data8 0x8e39d9cd73464364 , 0x0000bffe // sin(19 pi/16) -S3
359 data8 0xd4db3148750d181a , 0x0000bffe // cos(19 pi/16) -C3
361 data8 0xb504f333f9de6484 , 0x0000bffe // sin(20 pi/16) -S4
362 data8 0xb504f333f9de6484 , 0x0000bffe // cos(20 pi/16) -S4
364 data8 0xd4db3148750d181a , 0x0000bffe // sin(21 pi/16) -C3
365 data8 0x8e39d9cd73464364 , 0x0000bffe // cos(21 pi/16) -S3
367 data8 0xec835e79946a3146 , 0x0000bffe // sin(22 pi/16) -C2
368 data8 0xc3ef1535754b168e , 0x0000bffd // cos(22 pi/16) -S2
370 data8 0xfb14be7fbae58157 , 0x0000bffe // sin(23 pi/16) -C1
371 data8 0xc7c5c1e34d3055b3 , 0x0000bffc // cos(23 pi/16) -S1
373 data8 0x8000000000000000 , 0x0000bfff // sin(24 pi/16) -C0
374 data8 0x0000000000000000 , 0x00000000 // cos(24 pi/16) S0
376 data8 0xfb14be7fbae58157 , 0x0000bffe // sin(25 pi/16) -C1
377 data8 0xc7c5c1e34d3055b3 , 0x00003ffc // cos(25 pi/16) S1
379 data8 0xec835e79946a3146 , 0x0000bffe // sin(26 pi/16) -C2
380 data8 0xc3ef1535754b168e , 0x00003ffd // cos(26 pi/16) S2
382 data8 0xd4db3148750d181a , 0x0000bffe // sin(27 pi/16) -C3
383 data8 0x8e39d9cd73464364 , 0x00003ffe // cos(27 pi/16) S3
385 data8 0xb504f333f9de6484 , 0x0000bffe // sin(28 pi/16) -S4
386 data8 0xb504f333f9de6484 , 0x00003ffe // cos(28 pi/16) S4
388 data8 0x8e39d9cd73464364 , 0x0000bffe // sin(29 pi/16) -S3
389 data8 0xd4db3148750d181a , 0x00003ffe // cos(29 pi/16) C3
391 data8 0xc3ef1535754b168e , 0x0000bffd // sin(30 pi/16) -S2
392 data8 0xec835e79946a3146 , 0x00003ffe // cos(30 pi/16) C2
394 data8 0xc7c5c1e34d3055b3 , 0x0000bffc // sin(31 pi/16) -S1
395 data8 0xfb14be7fbae58157 , 0x00003ffe // cos(31 pi/16) C1
397 data8 0x0000000000000000 , 0x00000000 // sin(32 pi/16) S0
398 data8 0x8000000000000000 , 0x00003fff // cos(32 pi/16) C0
399 LOCAL_OBJECT_END(double_sin_cos_beta_k4)
401 .section .text
403 GLOBAL_IEEE754_ENTRY(sincos)
404 // cis_GR_sig_inv_pi_by_16 = significand of 16/pi
405 { .mlx
406       getf.exp      cis_r_signexp       = cis_Arg
407       movl          cis_GR_sig_inv_pi_by_16 = 0xA2F9836E4E44152A
410 // cis_GR_rshf_2to61 = 1.1000 2^(63+63-2)
411 { .mlx
412       addl          cis_AD_1                = @ltoff(double_cis_pi), gp
413       movl          cis_GR_rshf_2to61       = 0x47b8000000000000
416 { .mfi
417       ld8           cis_AD_1            = [cis_AD_1]
418       fnorm.s1      cis_NORM_f8         = cis_Arg
419       cmp.eq        p13, p14            = r0, r0 // p13 set for sincos
421 // cis_GR_exp_2tom61 = exponent of scaling factor 2^-61
422 { .mib
423       mov           cis_GR_exp_2tom61   = 0xffff-61
424       nop.i         0
425       br.cond.sptk  _CIS_COMMON
427 GLOBAL_IEEE754_END(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#