Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3347 lines
72 KiB

  1. .file "sincos.s"
  2. // Copyright (c) 2000, Intel Corporation
  3. // All rights reserved.
  4. //
  5. // Contributed 2/2/2000 by John Harrison, Ted Kubaska, Bob Norin, Shane Story,
  6. // and Ping Tak Peter Tang of the Computational Software Lab, Intel Corporation.
  7. //
  8. // WARRANTY DISCLAIMER
  9. //
  10. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  11. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  12. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  13. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR ITS
  14. // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  15. // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  16. // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  17. // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  18. // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR TORT (INCLUDING
  19. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  20. // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  21. //
  22. // Intel Corporation is the author of this code, and requests that all
  23. // problem reports or change requests be submitted to it directly at
  24. // http://developer.intel.com/opensource.
  25. //
  26. // History
  27. //==============================================================
  28. // 2/02/00 Initial revision
  29. // 4/02/00 Unwind support added.
  30. // 6/16/00 Updated tables to enforce symmetry
  31. // 8/31/00 Saved 2 cycles in main path, and 9 in other paths.
  32. // 9/20/00 The updated tables regressed to an old version, so reinstated them
  33. // API
  34. //==============================================================
  35. // double sin( double x);
  36. // double cos( double x);
  37. //
  38. // Overview of operation
  39. //==============================================================
  40. //
  41. // Step 1
  42. // ======
  43. // Reduce x to region -1/2*pi/2^k ===== 0 ===== +1/2*pi/2^k
  44. // divide x by pi/2^k.
  45. // Multiply by 2^k/pi.
  46. // nfloat = Round result to integer (round-to-nearest)
  47. //
  48. // r = x - nfloat * pi/2^k
  49. // Do this as (x - nfloat * HIGH(pi/2^k)) - nfloat * LOW(pi/2^k) for increased accuracy.
  50. // pi/2^k is stored as two numbers that when added make pi/2^k.
  51. // pi/2^k = HIGH(pi/2^k) + LOW(pi/2^k)
  52. //
  53. // x = (nfloat * pi/2^k) + r
  54. // r is small enough that we can use a polynomial approximation
  55. // and is referred to as the reduced argument.
  56. //
  57. // Step 3
  58. // ======
  59. // Take the unreduced part and remove the multiples of 2pi.
  60. // So nfloat = nfloat (with lower k+1 bits cleared) + lower k+1 bits
  61. //
  62. // nfloat (with lower k+1 bits cleared) is a multiple of 2^(k+1)
  63. // N * 2^(k+1)
  64. // nfloat * pi/2^k = N * 2^(k+1) * pi/2^k + (lower k+1 bits) * pi/2^k
  65. // nfloat * pi/2^k = N * 2 * pi + (lower k+1 bits) * pi/2^k
  66. // nfloat * pi/2^k = N2pi + M * pi/2^k
  67. //
  68. //
  69. // Sin(x) = Sin((nfloat * pi/2^k) + r)
  70. // = Sin(nfloat * pi/2^k) * Cos(r) + Cos(nfloat * pi/2^k) * Sin(r)
  71. //
  72. // Sin(nfloat * pi/2^k) = Sin(N2pi + Mpi/2^k)
  73. // = Sin(N2pi)Cos(Mpi/2^k) + Cos(N2pi)Sin(Mpi/2^k)
  74. // = Sin(Mpi/2^k)
  75. //
  76. // Cos(nfloat * pi/2^k) = Cos(N2pi + Mpi/2^k)
  77. // = Cos(N2pi)Cos(Mpi/2^k) + Sin(N2pi)Sin(Mpi/2^k)
  78. // = Cos(Mpi/2^k)
  79. //
  80. // Sin(x) = Sin(Mpi/2^k) Cos(r) + Cos(Mpi/2^k) Sin(r)
  81. //
  82. //
  83. // Step 4
  84. // ======
  85. // 0 <= M < 2^(k+1)
  86. // There are 2^(k+1) Sin entries in a table.
  87. // There are 2^(k+1) Cos entries in a table.
  88. //
  89. // Get Sin(Mpi/2^k) and Cos(Mpi/2^k) by table lookup.
  90. //
  91. //
  92. // Step 5
  93. // ======
  94. // Calculate Cos(r) and Sin(r) by polynomial approximation.
  95. //
  96. // Cos(r) = 1 + r^2 q1 + r^4 q2 + r^6 q3 + ... = Series for Cos
  97. // Sin(r) = r + r^3 p1 + r^5 p2 + r^7 p3 + ... = Series for Sin
  98. //
  99. // and the coefficients q1, q2, ... and p1, p2, ... are stored in a table
  100. //
  101. //
  102. // Calculate
  103. // Sin(x) = Sin(Mpi/2^k) Cos(r) + Cos(Mpi/2^k) Sin(r)
  104. //
  105. // as follows
  106. //
  107. // Sm = Sin(Mpi/2^k) and Cm = Cos(Mpi/2^k)
  108. // rsq = r*r
  109. //
  110. //
  111. // P = p1 + r^2p2 + r^4p3 + r^6p4
  112. // Q = q1 + r^2q2 + r^4q3 + r^6q4
  113. //
  114. // rcub = r * rsq
  115. // Sin(r) = r + rcub * P
  116. // = r + r^3p1 + r^5p2 + r^7p3 + r^9p4 + ... = Sin(r)
  117. //
  118. // The coefficients are not exactly these values, but almost.
  119. //
  120. // p1 = -1/6 = -1/3!
  121. // p2 = 1/120 = 1/5!
  122. // p3 = -1/5040 = -1/7!
  123. // p4 = 1/362889 = 1/9!
  124. //
  125. // P = r + rcub * P
  126. //
  127. // Answer = Sm Cos(r) + Cm P
  128. //
  129. // Cos(r) = 1 + rsq Q
  130. // Cos(r) = 1 + r^2 Q
  131. // Cos(r) = 1 + r^2 (q1 + r^2q2 + r^4q3 + r^6q4)
  132. // Cos(r) = 1 + r^2q1 + r^4q2 + r^6q3 + r^8q4 + ...
  133. //
  134. // Sm Cos(r) = Sm(1 + rsq Q)
  135. // Sm Cos(r) = Sm + Sm rsq Q
  136. // Sm Cos(r) = Sm + s_rsq Q
  137. // Q = Sm + s_rsq Q
  138. //
  139. // Then,
  140. //
  141. // Answer = Q + Cm P
  142. // Registers used
  143. //==============================================================
  144. // general input registers:
  145. // r32 -> r45
  146. // predicate registers used:
  147. // p6 -> p13
  148. // floating-point registers used: 31
  149. // f9 -> f15
  150. // f32 -> f54
  151. // Assembly macros
  152. //==============================================================
  153. sind_W = f10
  154. sind_int_Nfloat = f11
  155. sind_Nfloat = f12
  156. sind_r = f13
  157. sind_rsq = f14
  158. sind_rcub = f15
  159. sind_Inv_Pi_by_16 = f32
  160. sind_Pi_by_16_hi = f33
  161. sind_Pi_by_16_lo = f34
  162. sind_Inv_Pi_by_64 = f35
  163. sind_Pi_by_64_hi = f36
  164. sind_Pi_by_64_lo = f37
  165. sind_Sm = f38
  166. sind_Cm = f39
  167. sind_P1 = f40
  168. sind_Q1 = f41
  169. sind_P2 = f42
  170. sind_Q2 = f43
  171. sind_P3 = f44
  172. sind_Q3 = f45
  173. sind_P4 = f46
  174. sind_Q4 = f47
  175. sind_P_temp1 = f48
  176. sind_P_temp2 = f49
  177. sind_Q_temp1 = f50
  178. sind_Q_temp2 = f51
  179. sind_P = f52
  180. sind_Q = f53
  181. sind_srsq = f54
  182. /////////////////////////////////////////////////////////////
  183. sind_r_signexp = r36
  184. sind_AD_beta_table = r37
  185. sind_r_sincos = r38
  186. sind_r_exp = r39
  187. sind_r_17_ones = r40
  188. GR_SAVE_PFS = r41
  189. GR_SAVE_B0 = r42
  190. GR_SAVE_GP = r43
  191. .data
  192. .align 16
  193. double_sind_pi:
  194. data8 0xA2F9836E4E44152A, 0x00004001 // 16/pi
  195. // c90fdaa22168c234
  196. data8 0xC90FDAA22168C234, 0x00003FFC // pi/16 hi
  197. // c4c6628b80dc1cd1 29024e088a
  198. data8 0xC4C6628B80DC1CD1, 0x00003FBC
  199. double_sind_pq_k4:
  200. data8 0x3EC71C963717C63A // P4
  201. data8 0x3EF9FFBA8F191AE6 // Q4
  202. data8 0xBF2A01A00F4E11A8 // P3
  203. data8 0xBF56C16C05AC77BF // Q3
  204. data8 0x3F8111111110F167 // P2
  205. data8 0x3FA555555554DD45 // Q2
  206. data8 0xBFC5555555555555 // P1
  207. data8 0xBFDFFFFFFFFFFFFC // Q1
  208. double_sin_cos_beta_k4:
  209. data8 0x0000000000000000 , 0x00000000 // sin( 0 pi/16) S0
  210. data8 0x8000000000000000 , 0x00003fff // cos( 0 pi/16) C0
  211. data8 0xc7c5c1e34d3055b3 , 0x00003ffc // sin( 1 pi/16) S1
  212. data8 0xfb14be7fbae58157 , 0x00003ffe // cos( 1 pi/16) C1
  213. data8 0xc3ef1535754b168e , 0x00003ffd // sin( 2 pi/16) S2
  214. data8 0xec835e79946a3146 , 0x00003ffe // cos( 2 pi/16) C2
  215. data8 0x8e39d9cd73464364 , 0x00003ffe // sin( 3 pi/16) S3
  216. data8 0xd4db3148750d181a , 0x00003ffe // cos( 3 pi/16) C3
  217. data8 0xb504f333f9de6484 , 0x00003ffe // sin( 4 pi/16) S4
  218. data8 0xb504f333f9de6484 , 0x00003ffe // cos( 4 pi/16) C4
  219. data8 0xd4db3148750d181a , 0x00003ffe // sin( 5 pi/16) C3
  220. data8 0x8e39d9cd73464364 , 0x00003ffe // cos( 5 pi/16) S3
  221. data8 0xec835e79946a3146 , 0x00003ffe // sin( 6 pi/16) C2
  222. data8 0xc3ef1535754b168e , 0x00003ffd // cos( 6 pi/16) S2
  223. data8 0xfb14be7fbae58157 , 0x00003ffe // sin( 7 pi/16) C1
  224. data8 0xc7c5c1e34d3055b3 , 0x00003ffc // cos( 7 pi/16) S1
  225. data8 0x8000000000000000 , 0x00003fff // sin( 8 pi/16) C0
  226. data8 0x0000000000000000 , 0x00000000 // cos( 8 pi/16) S0
  227. data8 0xfb14be7fbae58157 , 0x00003ffe // sin( 9 pi/16) C1
  228. data8 0xc7c5c1e34d3055b3 , 0x0000bffc // cos( 9 pi/16) -S1
  229. data8 0xec835e79946a3146 , 0x00003ffe // sin(10 pi/16) C2
  230. data8 0xc3ef1535754b168c , 0x0000bffd // cos(10 pi/16) -S2
  231. data8 0xd4db3148750d181a , 0x00003ffe // sin(11 pi/16) C3
  232. data8 0x8e39d9cd73464364 , 0x0000bffe // cos(11 pi/16) -S3
  233. data8 0xb504f333f9de6484 , 0x00003ffe // sin(12 pi/16) S4
  234. data8 0xb504f333f9de6484 , 0x0000bffe // cos(12 pi/16) -S4
  235. data8 0x8e39d9cd73464364 , 0x00003ffe // sin(13 pi/16) S3
  236. data8 0xd4db3148750d181a , 0x0000bffe // cos(13 pi/16) -C3
  237. data8 0xc3ef1535754b168e , 0x00003ffd // sin(14 pi/16) S2
  238. data8 0xec835e79946a3146 , 0x0000bffe // cos(14 pi/16) -C2
  239. data8 0xc7c5c1e34d3055b3 , 0x00003ffc // sin(15 pi/16) S1
  240. data8 0xfb14be7fbae58157 , 0x0000bffe // cos(15 pi/16) -C1
  241. data8 0x0000000000000000 , 0x00000000 // sin(16 pi/16) S0
  242. data8 0x8000000000000000 , 0x0000bfff // cos(16 pi/16) -C0
  243. data8 0xc7c5c1e34d3055b3 , 0x0000bffc // sin(17 pi/16) -S1
  244. data8 0xfb14be7fbae58157 , 0x0000bffe // cos(17 pi/16) -C1
  245. data8 0xc3ef1535754b168e , 0x0000bffd // sin(18 pi/16) -S2
  246. data8 0xec835e79946a3146 , 0x0000bffe // cos(18 pi/16) -C2
  247. data8 0x8e39d9cd73464364 , 0x0000bffe // sin(19 pi/16) -S3
  248. data8 0xd4db3148750d181a , 0x0000bffe // cos(19 pi/16) -C3
  249. data8 0xb504f333f9de6484 , 0x0000bffe // sin(20 pi/16) -S4
  250. data8 0xb504f333f9de6484 , 0x0000bffe // cos(20 pi/16) -S4
  251. data8 0xd4db3148750d181a , 0x0000bffe // sin(21 pi/16) -C3
  252. data8 0x8e39d9cd73464364 , 0x0000bffe // cos(21 pi/16) -S3
  253. data8 0xec835e79946a3146 , 0x0000bffe // sin(22 pi/16) -C2
  254. data8 0xc3ef1535754b168e , 0x0000bffd // cos(22 pi/16) -S2
  255. data8 0xfb14be7fbae58157 , 0x0000bffe // sin(23 pi/16) -C1
  256. data8 0xc7c5c1e34d3055b3 , 0x0000bffc // cos(23 pi/16) -S1
  257. data8 0x8000000000000000 , 0x0000bfff // sin(24 pi/16) -C0
  258. data8 0x0000000000000000 , 0x00000000 // cos(24 pi/16) S0
  259. data8 0xfb14be7fbae58157 , 0x0000bffe // sin(25 pi/16) -C1
  260. data8 0xc7c5c1e34d3055b3 , 0x00003ffc // cos(25 pi/16) S1
  261. data8 0xec835e79946a3146 , 0x0000bffe // sin(26 pi/16) -C2
  262. data8 0xc3ef1535754b168e , 0x00003ffd // cos(26 pi/16) S2
  263. data8 0xd4db3148750d181a , 0x0000bffe // sin(27 pi/16) -C3
  264. data8 0x8e39d9cd73464364 , 0x00003ffe // cos(27 pi/16) S3
  265. data8 0xb504f333f9de6484 , 0x0000bffe // sin(28 pi/16) -S4
  266. data8 0xb504f333f9de6484 , 0x00003ffe // cos(28 pi/16) S4
  267. data8 0x8e39d9cd73464364 , 0x0000bffe // sin(29 pi/16) -S3
  268. data8 0xd4db3148750d181a , 0x00003ffe // cos(29 pi/16) C3
  269. data8 0xc3ef1535754b168e , 0x0000bffd // sin(30 pi/16) -S2
  270. data8 0xec835e79946a3146 , 0x00003ffe // cos(30 pi/16) C2
  271. data8 0xc7c5c1e34d3055b3 , 0x0000bffc // sin(31 pi/16) -S1
  272. data8 0xfb14be7fbae58157 , 0x00003ffe // cos(31 pi/16) C1
  273. data8 0x0000000000000000 , 0x00000000 // sin(32 pi/16) S0
  274. data8 0x8000000000000000 , 0x00003fff // cos(32 pi/16) C0
  275. .align 32
  276. .global sin#
  277. .global cos#
  278. ////////////////////////////////////////////////////////
  279. // There are two entry points: sin and cos
  280. // If from sin, p8 is true
  281. // If from cos, p9 is true
  282. .section .text
  283. .proc sin#
  284. .align 32
  285. sin:
  286. // The initial fnorm will take any unmasked faults and
  287. // normalize any single/double unorms
  288. { .mfi
  289. alloc r32=ar.pfs,1,13,0,0
  290. (p0) fnorm f8 = f8
  291. (p0) cmp.eq.unc p8,p9 = r0, r0
  292. }
  293. { .mib
  294. (p0) addl r33 = @ltoff(double_sind_pi), gp
  295. (p0) mov sind_r_sincos = 0x0
  296. (p0) br.sptk SIND_SINCOS ;;
  297. }
  298. .endp sin
  299. .section .text
  300. .proc cos#
  301. .align 32
  302. cos:
  303. // The initial fnorm will take any unmasked faults and
  304. // normalize any single/double unorms
  305. { .mfi
  306. alloc r32=ar.pfs,1,13,0,0
  307. (p0) fnorm f8 = f8
  308. (p0) cmp.eq.unc p9,p8 = r0, r0
  309. }
  310. { .mib
  311. (p0) addl r33 = @ltoff(double_sind_pi), gp
  312. (p0) mov sind_r_sincos = 0x8
  313. (p0) br.sptk SIND_SINCOS ;;
  314. }
  315. ////////////////////////////////////////////////////////
  316. // All entry points end up here.
  317. // If from sin, sind_r_sincos is 0 and p8 is true
  318. // If from cos, sind_r_sincos is 8 = 2^(k-1) and p9 is true
  319. // We add sind_r_sincos to N
  320. SIND_SINCOS:
  321. { .mmi
  322. ld8 r33 = [r33]
  323. (p0) addl r34 = @ltoff(double_sind_pq_k4), gp
  324. (p0) mov sind_r_17_ones = 0x1ffff
  325. }
  326. ;;
  327. { .mfi
  328. ld8 r34 = [r34]
  329. nop.f 999
  330. nop.i 999 ;;
  331. }
  332. // 0x10009 is register_bias + 10.
  333. // So if f8 > 2^10 = Gamma, go to DBX
  334. { .mii
  335. (p0) ldfe sind_Inv_Pi_by_16 = [r33],16
  336. (p0) mov r35 = 0x10009
  337. nop.i 999 ;;
  338. }
  339. // Start loading P, Q coefficients
  340. { .mmi
  341. (p0) ldfpd sind_P4,sind_Q4 = [r34],16
  342. (p0) addl sind_AD_beta_table = @ltoff(double_sin_cos_beta_k4), gp
  343. nop.i 999 ;;
  344. }
  345. // SIN(0)
  346. { .mfi
  347. ld8 sind_AD_beta_table = [sind_AD_beta_table]
  348. (p8) fclass.m.unc p6,p0 = f8, 0x07
  349. nop.i 999 ;;
  350. }
  351. // COS(0)
  352. { .mfi
  353. (p0) getf.exp sind_r_signexp = f8
  354. (p9) fclass.m.unc p7,p0 = f8, 0x07
  355. nop.i 999
  356. }
  357. { .mfi
  358. (p0) ldfe sind_Pi_by_16_hi = [r33],16
  359. nop.f 999
  360. nop.i 999 ;;
  361. }
  362. { .mfb
  363. (p0) ldfe sind_Pi_by_16_lo = [r33],16
  364. nop.f 999
  365. (p6) br.ret.spnt b0 ;;
  366. }
  367. { .mfb
  368. (p0) and sind_r_exp = sind_r_17_ones, sind_r_signexp
  369. (p7) fmerge.s f8 = f1,f1
  370. (p7) br.ret.spnt b0 ;;
  371. }
  372. // p10 is true if we must call DBX SIN
  373. // p10 is true if f8 exp is > 0x10009 (which includes all ones
  374. // NAN or inf)
  375. { .mib
  376. (p0) ldfpd sind_P3,sind_Q3 = [r34],16
  377. (p0) cmp.ge.unc p10,p0 = sind_r_exp,r35
  378. (p10) br.cond.spnt SIND_DBX ;;
  379. }
  380. { .mfi
  381. (p0) ldfpd sind_P2,sind_Q2 = [r34],16
  382. nop.f 999
  383. nop.i 999 ;;
  384. }
  385. // sind_W = x * sind_Inv_Pi_by_16
  386. { .mfi
  387. (p0) ldfpd sind_P1,sind_Q1 = [r34]
  388. (p0) fma.s1 sind_W = f8, sind_Inv_Pi_by_16, f0
  389. nop.i 999 ;;
  390. }
  391. // sind_int_Nfloat = Round_Int_Nearest(sind_W)
  392. // sind_r = -sind_Nfloat * sind_Pi_by_16_hi + x
  393. // sind_r = sind_r -sind_Nfloat * sind_Pi_by_16_lo
  394. { .mfi
  395. nop.m 999
  396. (p0) fcvt.fx.s1 sind_int_Nfloat = sind_W
  397. nop.i 999 ;;
  398. }
  399. { .mfi
  400. nop.m 999
  401. (p0) fcvt.xf sind_Nfloat = sind_int_Nfloat
  402. nop.i 999 ;;
  403. }
  404. // get N = (int)sind_int_Nfloat
  405. // Add 2^(k-1) (which is in sind_r_sincos) to N
  406. { .mfi
  407. (p0) getf.sig r43 = sind_int_Nfloat
  408. nop.f 999
  409. nop.i 999 ;;
  410. }
  411. { .mmi
  412. (p0) add r43 = r43, sind_r_sincos ;;
  413. (p0) and r44 = 0x1f,r43
  414. nop.i 999 ;;
  415. }
  416. // Get M (least k+1 bits of N)
  417. // Add 32*M to address of sin_cos_beta table
  418. { .mfi
  419. nop.m 999
  420. (p0) fnma.s1 sind_r = sind_Nfloat, sind_Pi_by_16_hi, f8
  421. (p0) shl r44 = r44,5 ;;
  422. }
  423. { .mmi
  424. (p0) add r45 = r44, sind_AD_beta_table
  425. nop.m 999
  426. nop.i 999 ;;
  427. }
  428. { .mmi
  429. (p0) ldfe sind_Sm = [r45],16 ;;
  430. (p0) ldfe sind_Cm = [r45]
  431. nop.i 999 ;;
  432. }
  433. { .mfi
  434. nop.m 999
  435. (p0) fnma.s1 sind_r = sind_Nfloat, sind_Pi_by_16_lo, sind_r
  436. nop.i 999 ;;
  437. }
  438. // get rsq
  439. { .mfi
  440. nop.m 999
  441. (p0) fma.s1 sind_rsq = sind_r, sind_r, f0
  442. nop.i 999 ;;
  443. }
  444. // form P and Q series
  445. { .mfi
  446. nop.m 999
  447. (p0) fma.s1 sind_P_temp1 = sind_rsq, sind_P4, sind_P3
  448. nop.i 999
  449. }
  450. { .mfi
  451. nop.m 999
  452. (p0) fma.s1 sind_Q_temp1 = sind_rsq, sind_Q4, sind_Q3
  453. nop.i 999 ;;
  454. }
  455. // get rcube and sm*rsq
  456. { .mfi
  457. nop.m 999
  458. (p0) fmpy.s1 sind_srsq = sind_Sm,sind_rsq
  459. nop.i 999
  460. }
  461. { .mfi
  462. nop.m 999
  463. (p0) fmpy.s1 sind_rcub = sind_r, sind_rsq
  464. nop.i 999 ;;
  465. }
  466. { .mfi
  467. nop.m 999
  468. (p0) fma.s1 sind_Q_temp2 = sind_rsq, sind_Q_temp1, sind_Q2
  469. nop.i 999
  470. }
  471. { .mfi
  472. nop.m 999
  473. (p0) fma.s1 sind_P_temp2 = sind_rsq, sind_P_temp1, sind_P2
  474. nop.i 999 ;;
  475. }
  476. { .mfi
  477. nop.m 999
  478. (p0) fma.s1 sind_Q = sind_rsq, sind_Q_temp2, sind_Q1
  479. nop.i 999
  480. }
  481. { .mfi
  482. nop.m 999
  483. (p0) fma.s1 sind_P = sind_rsq, sind_P_temp2, sind_P1
  484. nop.i 999 ;;
  485. }
  486. // Get final P and Q
  487. { .mfi
  488. nop.m 999
  489. (p0) fma.s1 sind_Q = sind_srsq,sind_Q, sind_Sm
  490. nop.i 999
  491. }
  492. { .mfi
  493. nop.m 999
  494. (p0) fma.s1 sind_P = sind_rcub,sind_P, sind_r
  495. nop.i 999 ;;
  496. }
  497. // Final calculation
  498. { .mfb
  499. nop.m 999
  500. (p0) fma.d f8 = sind_Cm, sind_P, sind_Q
  501. (p0) br.ret.sptk b0 ;;
  502. }
  503. .endp cos#
  504. .proc __libm_callout_1
  505. __libm_callout_1:
  506. SIND_DBX:
  507. .prologue
  508. { .mfi
  509. nop.m 0
  510. nop.f 0
  511. .save ar.pfs,GR_SAVE_PFS
  512. mov GR_SAVE_PFS=ar.pfs
  513. }
  514. ;;
  515. { .mfi
  516. mov GR_SAVE_GP=gp
  517. nop.f 0
  518. .save b0, GR_SAVE_B0
  519. mov GR_SAVE_B0=b0
  520. }
  521. .body
  522. { .mbb
  523. nop.m 999
  524. (p9) br.cond.spnt COSD_DBX
  525. (p8) br.call.spnt.many b0=__libm_sin_double_dbx# ;;
  526. }
  527. ;;
  528. // if we come out of __libm_sin_double_dbx#
  529. // we want to ensure that p9 is false.
  530. { .mii
  531. nop.m 999
  532. nop.i 999
  533. (p0) cmp.eq.unc p8,p9 = r0,r0
  534. ;;
  535. }
  536. COSD_DBX:
  537. { .mib
  538. nop.m 999
  539. nop.i 999
  540. (p9) br.call.spnt.many b0=__libm_cos_double_dbx# ;;
  541. }
  542. { .mfi
  543. (p0) mov gp = GR_SAVE_GP
  544. nop.f 999
  545. (p0) mov b0 = GR_SAVE_B0
  546. }
  547. ;;
  548. { .mib
  549. nop.m 999
  550. (p0) mov ar.pfs = GR_SAVE_PFS
  551. (p0) br.ret.sptk b0 ;;
  552. }
  553. .endp __libm_callout_1
  554. // ====================================================================
  555. // ====================================================================
  556. // These functions calculate the sin and cos for inputs
  557. // greater than 2^10
  558. // __libm_sin_double_dbx# and __libm_cos_double_dbx#
  559. //*********************************************************************
  560. //*********************************************************************
  561. //
  562. // Function: Combined sin(x) and cos(x), where
  563. //
  564. // sin(x) = sine(x), for double precision x values
  565. // cos(x) = cosine(x), for double precision x values
  566. //
  567. //*********************************************************************
  568. //
  569. // Accuracy: Within .7 ulps for 80-bit floating point values
  570. // Very accurate for double precision values
  571. //
  572. //*********************************************************************
  573. //
  574. // Resources Used:
  575. //
  576. // Floating-Point Registers: f8 (Input and Return Value)
  577. // f32-f99
  578. //
  579. // General Purpose Registers:
  580. // r32-r43
  581. // r44-r45 (Used to pass arguments to pi_by_2 reduce routine)
  582. //
  583. // Predicate Registers: p6-p13
  584. //
  585. //*********************************************************************
  586. //
  587. // IEEE Special Conditions:
  588. //
  589. // Denormal fault raised on denormal inputs
  590. // Overflow exceptions do not occur
  591. // Underflow exceptions raised when appropriate for sin
  592. // (No specialized error handling for this routine)
  593. // Inexact raised when appropriate by algorithm
  594. //
  595. // sin(SNaN) = QNaN
  596. // sin(QNaN) = QNaN
  597. // sin(inf) = QNaN
  598. // sin(+/-0) = +/-0
  599. // cos(inf) = QNaN
  600. // cos(SNaN) = QNaN
  601. // cos(QNaN) = QNaN
  602. // cos(0) = 1
  603. //
  604. //*********************************************************************
  605. //
  606. // Mathematical Description
  607. // ========================
  608. //
  609. // The computation of FSIN and FCOS is best handled in one piece of
  610. // code. The main reason is that given any argument Arg, computation
  611. // of trigonometric functions first calculate N and an approximation
  612. // to alpha where
  613. //
  614. // Arg = N pi/2 + alpha, |alpha| <= pi/4.
  615. //
  616. // Since
  617. //
  618. // cos( Arg ) = sin( (N+1) pi/2 + alpha ),
  619. //
  620. // therefore, the code for computing sine will produce cosine as long
  621. // as 1 is added to N immediately after the argument reduction
  622. // process.
  623. //
  624. // Let M = N if sine
  625. // N+1 if cosine.
  626. //
  627. // Now, given
  628. //
  629. // Arg = M pi/2 + alpha, |alpha| <= pi/4,
  630. //
  631. // let I = M mod 4, or I be the two lsb of M when M is represented
  632. // as 2's complement. I = [i_0 i_1]. Then
  633. //
  634. // sin( Arg ) = (-1)^i_0 sin( alpha ) if i_1 = 0,
  635. // = (-1)^i_0 cos( alpha ) if i_1 = 1.
  636. //
  637. // For example:
  638. // if M = -1, I = 11
  639. // sin ((-pi/2 + alpha) = (-1) cos (alpha)
  640. // if M = 0, I = 00
  641. // sin (alpha) = sin (alpha)
  642. // if M = 1, I = 01
  643. // sin (pi/2 + alpha) = cos (alpha)
  644. // if M = 2, I = 10
  645. // sin (pi + alpha) = (-1) sin (alpha)
  646. // if M = 3, I = 11
  647. // sin ((3/2)pi + alpha) = (-1) cos (alpha)
  648. //
  649. // The value of alpha is obtained by argument reduction and
  650. // represented by two working precision numbers r and c where
  651. //
  652. // alpha = r + c accurately.
  653. //
  654. // The reduction method is described in a previous write up.
  655. // The argument reduction scheme identifies 4 cases. For Cases 2
  656. // and 4, because |alpha| is small, sin(r+c) and cos(r+c) can be
  657. // computed very easily by 2 or 3 terms of the Taylor series
  658. // expansion as follows:
  659. //
  660. // Case 2:
  661. // -------
  662. //
  663. // sin(r + c) = r + c - r^3/6 accurately
  664. // cos(r + c) = 1 - 2^(-67) accurately
  665. //
  666. // Case 4:
  667. // -------
  668. //
  669. // sin(r + c) = r + c - r^3/6 + r^5/120 accurately
  670. // cos(r + c) = 1 - r^2/2 + r^4/24 accurately
  671. //
  672. // The only cases left are Cases 1 and 3 of the argument reduction
  673. // procedure. These two cases will be merged since after the
  674. // argument is reduced in either cases, we have the reduced argument
  675. // represented as r + c and that the magnitude |r + c| is not small
  676. // enough to allow the usage of a very short approximation.
  677. //
  678. // The required calculation is either
  679. //
  680. // sin(r + c) = sin(r) + correction, or
  681. // cos(r + c) = cos(r) + correction.
  682. //
  683. // Specifically,
  684. //
  685. // sin(r + c) = sin(r) + c sin'(r) + O(c^2)
  686. // = sin(r) + c cos (r) + O(c^2)
  687. // = sin(r) + c(1 - r^2/2) accurately.
  688. // Similarly,
  689. //
  690. // cos(r + c) = cos(r) - c sin(r) + O(c^2)
  691. // = cos(r) - c(r - r^3/6) accurately.
  692. //
  693. // We therefore concentrate on accurately calculating sin(r) and
  694. // cos(r) for a working-precision number r, |r| <= pi/4 to within
  695. // 0.1% or so.
  696. //
  697. // The greatest challenge of this task is that the second terms of
  698. // the Taylor series
  699. //
  700. // r - r^3/3! + r^r/5! - ...
  701. //
  702. // and
  703. //
  704. // 1 - r^2/2! + r^4/4! - ...
  705. //
  706. // are not very small when |r| is close to pi/4 and the rounding
  707. // errors will be a concern if simple polynomial accumulation is
  708. // used. When |r| < 2^-3, however, the second terms will be small
  709. // enough (6 bits or so of right shift) that a normal Horner
  710. // recurrence suffices. Hence there are two cases that we consider
  711. // in the accurate computation of sin(r) and cos(r), |r| <= pi/4.
  712. //
  713. // Case small_r: |r| < 2^(-3)
  714. // --------------------------
  715. //
  716. // Since Arg = M pi/4 + r + c accurately, and M mod 4 is [i_0 i_1],
  717. // we have
  718. //
  719. // sin(Arg) = (-1)^i_0 * sin(r + c) if i_1 = 0
  720. // = (-1)^i_0 * cos(r + c) if i_1 = 1
  721. //
  722. // can be accurately approximated by
  723. //
  724. // sin(Arg) = (-1)^i_0 * [sin(r) + c] if i_1 = 0
  725. // = (-1)^i_0 * [cos(r) - c*r] if i_1 = 1
  726. //
  727. // because |r| is small and thus the second terms in the correction
  728. // are unneccessary.
  729. //
  730. // Finally, sin(r) and cos(r) are approximated by polynomials of
  731. // moderate lengths.
  732. //
  733. // sin(r) = r + S_1 r^3 + S_2 r^5 + ... + S_5 r^11
  734. // cos(r) = 1 + C_1 r^2 + C_2 r^4 + ... + C_5 r^10
  735. //
  736. // We can make use of predicates to selectively calculate
  737. // sin(r) or cos(r) based on i_1.
  738. //
  739. // Case normal_r: 2^(-3) <= |r| <= pi/4
  740. // ------------------------------------
  741. //
  742. // This case is more likely than the previous one if one considers
  743. // r to be uniformly distributed in [-pi/4 pi/4]. Again,
  744. //
  745. // sin(Arg) = (-1)^i_0 * sin(r + c) if i_1 = 0
  746. // = (-1)^i_0 * cos(r + c) if i_1 = 1.
  747. //
  748. // Because |r| is now larger, we need one extra term in the
  749. // correction. sin(Arg) can be accurately approximated by
  750. //
  751. // sin(Arg) = (-1)^i_0 * [sin(r) + c(1-r^2/2)] if i_1 = 0
  752. // = (-1)^i_0 * [cos(r) - c*r*(1 - r^2/6)] i_1 = 1.
  753. //
  754. // Finally, sin(r) and cos(r) are approximated by polynomials of
  755. // moderate lengths.
  756. //
  757. // sin(r) = r + PP_1_hi r^3 + PP_1_lo r^3 +
  758. // PP_2 r^5 + ... + PP_8 r^17
  759. //
  760. // cos(r) = 1 + QQ_1 r^2 + QQ_2 r^4 + ... + QQ_8 r^16
  761. //
  762. // where PP_1_hi is only about 16 bits long and QQ_1 is -1/2.
  763. // The crux in accurate computation is to calculate
  764. //
  765. // r + PP_1_hi r^3 or 1 + QQ_1 r^2
  766. //
  767. // accurately as two pieces: U_hi and U_lo. The way to achieve this
  768. // is to obtain r_hi as a 10 sig. bit number that approximates r to
  769. // roughly 8 bits or so of accuracy. (One convenient way is
  770. //
  771. // r_hi := frcpa( frcpa( r ) ).)
  772. //
  773. // This way,
  774. //
  775. // r + PP_1_hi r^3 = r + PP_1_hi r_hi^3 +
  776. // PP_1_hi (r^3 - r_hi^3)
  777. // = [r + PP_1_hi r_hi^3] +
  778. // [PP_1_hi (r - r_hi)
  779. // (r^2 + r_hi r + r_hi^2) ]
  780. // = U_hi + U_lo
  781. //
  782. // Since r_hi is only 10 bit long and PP_1_hi is only 16 bit long,
  783. // PP_1_hi * r_hi^3 is only at most 46 bit long and thus computed
  784. // exactly. Furthermore, r and PP_1_hi r_hi^3 are of opposite sign
  785. // and that there is no more than 8 bit shift off between r and
  786. // PP_1_hi * r_hi^3. Hence the sum, U_hi, is representable and thus
  787. // calculated without any error. Finally, the fact that
  788. //
  789. // |U_lo| <= 2^(-8) |U_hi|
  790. //
  791. // says that U_hi + U_lo is approximating r + PP_1_hi r^3 to roughly
  792. // 8 extra bits of accuracy.
  793. //
  794. // Similarly,
  795. //
  796. // 1 + QQ_1 r^2 = [1 + QQ_1 r_hi^2] +
  797. // [QQ_1 (r - r_hi)(r + r_hi)]
  798. // = U_hi + U_lo.
  799. //
  800. // Summarizing, we calculate r_hi = frcpa( frcpa( r ) ).
  801. //
  802. // If i_1 = 0, then
  803. //
  804. // U_hi := r + PP_1_hi * r_hi^3
  805. // U_lo := PP_1_hi * (r - r_hi) * (r^2 + r*r_hi + r_hi^2)
  806. // poly := PP_1_lo r^3 + PP_2 r^5 + ... + PP_8 r^17
  807. // correction := c * ( 1 + C_1 r^2 )
  808. //
  809. // Else ...i_1 = 1
  810. //
  811. // U_hi := 1 + QQ_1 * r_hi * r_hi
  812. // U_lo := QQ_1 * (r - r_hi) * (r + r_hi)
  813. // poly := QQ_2 * r^4 + QQ_3 * r^6 + ... + QQ_8 r^16
  814. // correction := -c * r * (1 + S_1 * r^2)
  815. //
  816. // End
  817. //
  818. // Finally,
  819. //
  820. // V := poly + ( U_lo + correction )
  821. //
  822. // / U_hi + V if i_0 = 0
  823. // result := |
  824. // \ (-U_hi) - V if i_0 = 1
  825. //
  826. // It is important that in the last step, negation of U_hi is
  827. // performed prior to the subtraction which is to be performed in
  828. // the user-set rounding mode.
  829. //
  830. //
  831. // Algorithmic Description
  832. // =======================
  833. //
  834. // The argument reduction algorithm is tightly integrated into FSIN
  835. // and FCOS which share the same code. The following is complete and
  836. // self-contained. The argument reduction description given
  837. // previously is repeated below.
  838. //
  839. //
  840. // Step 0. Initialization.
  841. //
  842. // If FSIN is invoked, set N_inc := 0; else if FCOS is invoked,
  843. // set N_inc := 1.
  844. //
  845. // Step 1. Check for exceptional and special cases.
  846. //
  847. // * If Arg is +-0, +-inf, NaN, NaT, go to Step 10 for special
  848. // handling.
  849. // * If |Arg| < 2^24, go to Step 2 for reduction of moderate
  850. // arguments. This is the most likely case.
  851. // * If |Arg| < 2^63, go to Step 8 for pre-reduction of large
  852. // arguments.
  853. // * If |Arg| >= 2^63, go to Step 10 for special handling.
  854. //
  855. // Step 2. Reduction of moderate arguments.
  856. //
  857. // If |Arg| < pi/4 ...quick branch
  858. // N_fix := N_inc (integer)
  859. // r := Arg
  860. // c := 0.0
  861. // Branch to Step 4, Case_1_complete
  862. // Else ...cf. argument reduction
  863. // N := Arg * two_by_PI (fp)
  864. // N_fix := fcvt.fx( N ) (int)
  865. // N := fcvt.xf( N_fix )
  866. // N_fix := N_fix + N_inc
  867. // s := Arg - N * P_1 (first piece of pi/2)
  868. // w := -N * P_2 (second piece of pi/2)
  869. //
  870. // If |s| >= 2^(-33)
  871. // go to Step 3, Case_1_reduce
  872. // Else
  873. // go to Step 7, Case_2_reduce
  874. // Endif
  875. // Endif
  876. //
  877. // Step 3. Case_1_reduce.
  878. //
  879. // r := s + w
  880. // c := (s - r) + w ...observe order
  881. //
  882. // Step 4. Case_1_complete
  883. //
  884. // ...At this point, the reduced argument alpha is
  885. // ...accurately represented as r + c.
  886. // If |r| < 2^(-3), go to Step 6, small_r.
  887. //
  888. // Step 5. Normal_r.
  889. //
  890. // Let [i_0 i_1] by the 2 lsb of N_fix.
  891. // FR_rsq := r * r
  892. // r_hi := frcpa( frcpa( r ) )
  893. // r_lo := r - r_hi
  894. //
  895. // If i_1 = 0, then
  896. // poly := r*FR_rsq*(PP_1_lo + FR_rsq*(PP_2 + ... FR_rsq*PP_8))
  897. // U_hi := r + PP_1_hi*r_hi*r_hi*r_hi ...any order
  898. // U_lo := PP_1_hi*r_lo*(r*r + r*r_hi + r_hi*r_hi)
  899. // correction := c + c*C_1*FR_rsq ...any order
  900. // Else
  901. // poly := FR_rsq*FR_rsq*(QQ_2 + FR_rsq*(QQ_3 + ... + FR_rsq*QQ_8))
  902. // U_hi := 1 + QQ_1 * r_hi * r_hi ...any order
  903. // U_lo := QQ_1 * r_lo * (r + r_hi)
  904. // correction := -c*(r + S_1*FR_rsq*r) ...any order
  905. // Endif
  906. //
  907. // V := poly + (U_lo + correction) ...observe order
  908. //
  909. // result := (i_0 == 0? 1.0 : -1.0)
  910. //
  911. // Last instruction in user-set rounding mode
  912. //
  913. // result := (i_0 == 0? result*U_hi + V :
  914. // result*U_hi - V)
  915. //
  916. // Return
  917. //
  918. // Step 6. Small_r.
  919. //
  920. // ...Use flush to zero mode without causing exception
  921. // Let [i_0 i_1] be the two lsb of N_fix.
  922. //
  923. // FR_rsq := r * r
  924. //
  925. // If i_1 = 0 then
  926. // z := FR_rsq*FR_rsq; z := FR_rsq*z *r
  927. // poly_lo := S_3 + FR_rsq*(S_4 + FR_rsq*S_5)
  928. // poly_hi := r*FR_rsq*(S_1 + FR_rsq*S_2)
  929. // correction := c
  930. // result := r
  931. // Else
  932. // z := FR_rsq*FR_rsq; z := FR_rsq*z
  933. // poly_lo := C_3 + FR_rsq*(C_4 + FR_rsq*C_5)
  934. // poly_hi := FR_rsq*(C_1 + FR_rsq*C_2)
  935. // correction := -c*r
  936. // result := 1
  937. // Endif
  938. //
  939. // poly := poly_hi + (z * poly_lo + correction)
  940. //
  941. // If i_0 = 1, result := -result
  942. //
  943. // Last operation. Perform in user-set rounding mode
  944. //
  945. // result := (i_0 == 0? result + poly :
  946. // result - poly )
  947. // Return
  948. //
  949. // Step 7. Case_2_reduce.
  950. //
  951. // ...Refer to the write up for argument reduction for
  952. // ...rationale. The reduction algorithm below is taken from
  953. // ...argument reduction description and integrated this.
  954. //
  955. // w := N*P_3
  956. // U_1 := N*P_2 + w ...FMA
  957. // U_2 := (N*P_2 - U_1) + w ...2 FMA
  958. // ...U_1 + U_2 is N*(P_2+P_3) accurately
  959. //
  960. // r := s - U_1
  961. // c := ( (s - r) - U_1 ) - U_2
  962. //
  963. // ...The mathematical sum r + c approximates the reduced
  964. // ...argument accurately. Note that although compared to
  965. // ...Case 1, this case requires much more work to reduce
  966. // ...the argument, the subsequent calculation needed for
  967. // ...any of the trigonometric function is very little because
  968. // ...|alpha| < 1.01*2^(-33) and thus two terms of the
  969. // ...Taylor series expansion suffices.
  970. //
  971. // If i_1 = 0 then
  972. // poly := c + S_1 * r * r * r ...any order
  973. // result := r
  974. // Else
  975. // poly := -2^(-67)
  976. // result := 1.0
  977. // Endif
  978. //
  979. // If i_0 = 1, result := -result
  980. //
  981. // Last operation. Perform in user-set rounding mode
  982. //
  983. // result := (i_0 == 0? result + poly :
  984. // result - poly )
  985. //
  986. // Return
  987. //
  988. //
  989. // Step 8. Pre-reduction of large arguments.
  990. //
  991. // ...Again, the following reduction procedure was described
  992. // ...in the separate write up for argument reduction, which
  993. // ...is tightly integrated here.
  994. // N_0 := Arg * Inv_P_0
  995. // N_0_fix := fcvt.fx( N_0 )
  996. // N_0 := fcvt.xf( N_0_fix)
  997. // Arg' := Arg - N_0 * P_0
  998. // w := N_0 * d_1
  999. // N := Arg' * two_by_PI
  1000. // N_fix := fcvt.fx( N )
  1001. // N := fcvt.xf( N_fix )
  1002. // N_fix := N_fix + N_inc
  1003. //
  1004. // s := Arg' - N * P_1
  1005. // w := w - N * P_2
  1006. //
  1007. // If |s| >= 2^(-14)
  1008. // go to Step 3
  1009. // Else
  1010. // go to Step 9
  1011. // Endif
  1012. //
  1013. // Step 9. Case_4_reduce.
  1014. //
  1015. // ...first obtain N_0*d_1 and -N*P_2 accurately
  1016. // U_hi := N_0 * d_1 V_hi := -N*P_2
  1017. // U_lo := N_0 * d_1 - U_hi V_lo := -N*P_2 - U_hi ...FMAs
  1018. //
  1019. // ...compute the contribution from N_0*d_1 and -N*P_3
  1020. // w := -N*P_3
  1021. // w := w + N_0*d_2
  1022. // t := U_lo + V_lo + w ...any order
  1023. //
  1024. // ...at this point, the mathematical value
  1025. // ...s + U_hi + V_hi + t approximates the true reduced argument
  1026. // ...accurately. Just need to compute this accurately.
  1027. //
  1028. // ...Calculate U_hi + V_hi accurately:
  1029. // A := U_hi + V_hi
  1030. // if |U_hi| >= |V_hi| then
  1031. // a := (U_hi - A) + V_hi
  1032. // else
  1033. // a := (V_hi - A) + U_hi
  1034. // endif
  1035. // ...order in computing "a" must be observed. This branch is
  1036. // ...best implemented by predicates.
  1037. // ...A + a is U_hi + V_hi accurately. Moreover, "a" is
  1038. // ...much smaller than A: |a| <= (1/2)ulp(A).
  1039. //
  1040. // ...Just need to calculate s + A + a + t
  1041. // C_hi := s + A t := t + a
  1042. // C_lo := (s - C_hi) + A
  1043. // C_lo := C_lo + t
  1044. //
  1045. // ...Final steps for reduction
  1046. // r := C_hi + C_lo
  1047. // c := (C_hi - r) + C_lo
  1048. //
  1049. // ...At this point, we have r and c
  1050. // ...And all we need is a couple of terms of the corresponding
  1051. // ...Taylor series.
  1052. //
  1053. // If i_1 = 0
  1054. // poly := c + r*FR_rsq*(S_1 + FR_rsq*S_2)
  1055. // result := r
  1056. // Else
  1057. // poly := FR_rsq*(C_1 + FR_rsq*C_2)
  1058. // result := 1
  1059. // Endif
  1060. //
  1061. // If i_0 = 1, result := -result
  1062. //
  1063. // Last operation. Perform in user-set rounding mode
  1064. //
  1065. // result := (i_0 == 0? result + poly :
  1066. // result - poly )
  1067. // Return
  1068. //
  1069. // Large Arguments: For arguments above 2**63, a Payne-Hanek
  1070. // style argument reduction is used and pi_by_2 reduce is called.
  1071. //
  1072. .data
  1073. .align 64
  1074. FSINCOS_CONSTANTS:
  1075. data4 0x4B800000, 0xCB800000, 0x00000000,0x00000000 // two**24, -two**24
  1076. data4 0x4E44152A, 0xA2F9836E, 0x00003FFE,0x00000000 // Inv_pi_by_2
  1077. data4 0xCE81B9F1, 0xC84D32B0, 0x00004016,0x00000000 // P_0
  1078. data4 0x2168C235, 0xC90FDAA2, 0x00003FFF,0x00000000 // P_1
  1079. data4 0xFC8F8CBB, 0xECE675D1, 0x0000BFBD,0x00000000 // P_2
  1080. data4 0xACC19C60, 0xB7ED8FBB, 0x0000BF7C,0x00000000 // P_3
  1081. data4 0x5F000000, 0xDF000000, 0x00000000,0x00000000 // two_to_63, -two_to_63
  1082. data4 0x6EC6B45A, 0xA397E504, 0x00003FE7,0x00000000 // Inv_P_0
  1083. data4 0xDBD171A1, 0x8D848E89, 0x0000BFBF,0x00000000 // d_1
  1084. data4 0x18A66F8E, 0xD5394C36, 0x0000BF7C,0x00000000 // d_2
  1085. data4 0x2168C234, 0xC90FDAA2, 0x00003FFE,0x00000000 // pi_by_4
  1086. data4 0x2168C234, 0xC90FDAA2, 0x0000BFFE,0x00000000 // neg_pi_by_4
  1087. data4 0x3E000000, 0xBE000000, 0x00000000,0x00000000 // two**-3, -two**-3
  1088. data4 0x2F000000, 0xAF000000, 0x9E000000,0x00000000 // two**-33, -two**-33, -two**-67
  1089. data4 0xA21C0BC9, 0xCC8ABEBC, 0x00003FCE,0x00000000 // PP_8
  1090. data4 0x720221DA, 0xD7468A05, 0x0000BFD6,0x00000000 // PP_7
  1091. data4 0x640AD517, 0xB092382F, 0x00003FDE,0x00000000 // PP_6
  1092. data4 0xD1EB75A4, 0xD7322B47, 0x0000BFE5,0x00000000 // PP_5
  1093. data4 0xFFFFFFFE, 0xFFFFFFFF, 0x0000BFFD,0x00000000 // C_1
  1094. data4 0x00000000, 0xAAAA0000, 0x0000BFFC,0x00000000 // PP_1_hi
  1095. data4 0xBAF69EEA, 0xB8EF1D2A, 0x00003FEC,0x00000000 // PP_4
  1096. data4 0x0D03BB69, 0xD00D00D0, 0x0000BFF2,0x00000000 // PP_3
  1097. data4 0x88888962, 0x88888888, 0x00003FF8,0x00000000 // PP_2
  1098. data4 0xAAAB0000, 0xAAAAAAAA, 0x0000BFEC,0x00000000 // PP_1_lo
  1099. data4 0xC2B0FE52, 0xD56232EF, 0x00003FD2,0x00000000 // QQ_8
  1100. data4 0x2B48DCA6, 0xC9C99ABA, 0x0000BFDA,0x00000000 // QQ_7
  1101. data4 0x9C716658, 0x8F76C650, 0x00003FE2,0x00000000 // QQ_6
  1102. data4 0xFDA8D0FC, 0x93F27DBA, 0x0000BFE9,0x00000000 // QQ_5
  1103. data4 0xAAAAAAAA, 0xAAAAAAAA, 0x0000BFFC,0x00000000 // S_1
  1104. data4 0x00000000, 0x80000000, 0x0000BFFE,0x00000000 // QQ_1
  1105. data4 0x0C6E5041, 0xD00D00D0, 0x00003FEF,0x00000000 // QQ_4
  1106. data4 0x0B607F60, 0xB60B60B6, 0x0000BFF5,0x00000000 // QQ_3
  1107. data4 0xAAAAAA9B, 0xAAAAAAAA, 0x00003FFA,0x00000000 // QQ_2
  1108. data4 0xFFFFFFFE, 0xFFFFFFFF, 0x0000BFFD,0x00000000 // C_1
  1109. data4 0xAAAA719F, 0xAAAAAAAA, 0x00003FFA,0x00000000 // C_2
  1110. data4 0x0356F994, 0xB60B60B6, 0x0000BFF5,0x00000000 // C_3
  1111. data4 0xB2385EA9, 0xD00CFFD5, 0x00003FEF,0x00000000 // C_4
  1112. data4 0x292A14CD, 0x93E4BD18, 0x0000BFE9,0x00000000 // C_5
  1113. data4 0xAAAAAAAA, 0xAAAAAAAA, 0x0000BFFC,0x00000000 // S_1
  1114. data4 0x888868DB, 0x88888888, 0x00003FF8,0x00000000 // S_2
  1115. data4 0x055EFD4B, 0xD00D00D0, 0x0000BFF2,0x00000000 // S_3
  1116. data4 0x839730B9, 0xB8EF1C5D, 0x00003FEC,0x00000000 // S_4
  1117. data4 0xE5B3F492, 0xD71EA3A4, 0x0000BFE5,0x00000000 // S_5
  1118. data4 0x38800000, 0xB8800000, 0x00000000 // two**-14, -two**-14
  1119. FR_Input_X = f8
  1120. FR_Neg_Two_to_M3 = f32
  1121. FR_Two_to_63 = f32
  1122. FR_Two_to_24 = f33
  1123. FR_Pi_by_4 = f33
  1124. FR_Two_to_M14 = f34
  1125. FR_Two_to_M33 = f35
  1126. FR_Neg_Two_to_24 = f36
  1127. FR_Neg_Pi_by_4 = f36
  1128. FR_Neg_Two_to_M14 = f37
  1129. FR_Neg_Two_to_M33 = f38
  1130. FR_Neg_Two_to_M67 = f39
  1131. FR_Inv_pi_by_2 = f40
  1132. FR_N_float = f41
  1133. FR_N_fix = f42
  1134. FR_P_1 = f43
  1135. FR_P_2 = f44
  1136. FR_P_3 = f45
  1137. FR_s = f46
  1138. FR_w = f47
  1139. FR_c = f48
  1140. FR_r = f49
  1141. FR_Z = f50
  1142. FR_A = f51
  1143. FR_a = f52
  1144. FR_t = f53
  1145. FR_U_1 = f54
  1146. FR_U_2 = f55
  1147. FR_C_1 = f56
  1148. FR_C_2 = f57
  1149. FR_C_3 = f58
  1150. FR_C_4 = f59
  1151. FR_C_5 = f60
  1152. FR_S_1 = f61
  1153. FR_S_2 = f62
  1154. FR_S_3 = f63
  1155. FR_S_4 = f64
  1156. FR_S_5 = f65
  1157. FR_poly_hi = f66
  1158. FR_poly_lo = f67
  1159. FR_r_hi = f68
  1160. FR_r_lo = f69
  1161. FR_rsq = f70
  1162. FR_r_cubed = f71
  1163. FR_C_hi = f72
  1164. FR_N_0 = f73
  1165. FR_d_1 = f74
  1166. FR_V = f75
  1167. FR_V_hi = f75
  1168. FR_V_lo = f76
  1169. FR_U_hi = f77
  1170. FR_U_lo = f78
  1171. FR_U_hiabs = f79
  1172. FR_V_hiabs = f80
  1173. FR_PP_8 = f81
  1174. FR_QQ_8 = f81
  1175. FR_PP_7 = f82
  1176. FR_QQ_7 = f82
  1177. FR_PP_6 = f83
  1178. FR_QQ_6 = f83
  1179. FR_PP_5 = f84
  1180. FR_QQ_5 = f84
  1181. FR_PP_4 = f85
  1182. FR_QQ_4 = f85
  1183. FR_PP_3 = f86
  1184. FR_QQ_3 = f86
  1185. FR_PP_2 = f87
  1186. FR_QQ_2 = f87
  1187. FR_QQ_1 = f88
  1188. FR_N_0_fix = f89
  1189. FR_Inv_P_0 = f90
  1190. FR_corr = f91
  1191. FR_poly = f92
  1192. FR_d_2 = f93
  1193. FR_Two_to_M3 = f94
  1194. FR_Neg_Two_to_63 = f94
  1195. FR_P_0 = f95
  1196. FR_C_lo = f96
  1197. FR_PP_1 = f97
  1198. FR_PP_1_lo = f98
  1199. FR_ArgPrime = f99
  1200. GR_Table_Base = r32
  1201. GR_Table_Base1 = r33
  1202. GR_i_0 = r34
  1203. GR_i_1 = r35
  1204. GR_N_Inc = r36
  1205. GR_Sin_or_Cos = r37
  1206. GR_SAVE_B0 = r39
  1207. GR_SAVE_GP = r40
  1208. GR_SAVE_PFS = r41
  1209. .section .text
  1210. .proc __libm_sin_double_dbx#
  1211. .align 64
  1212. __libm_sin_double_dbx:
  1213. { .mlx
  1214. alloc GR_Table_Base = ar.pfs,0,12,2,0
  1215. (p0) movl GR_Sin_or_Cos = 0x0 ;;
  1216. }
  1217. { .mmi
  1218. nop.m 999
  1219. (p0) addl GR_Table_Base = @ltoff(FSINCOS_CONSTANTS#), gp
  1220. nop.i 999
  1221. }
  1222. ;;
  1223. { .mmi
  1224. ld8 GR_Table_Base = [GR_Table_Base]
  1225. nop.m 999
  1226. nop.i 999
  1227. }
  1228. ;;
  1229. { .mib
  1230. nop.m 999
  1231. nop.i 999
  1232. (p0) br.cond.sptk SINCOS_CONTINUE ;;
  1233. }
  1234. .endp __libm_sin_double_dbx#
  1235. .section .text
  1236. .proc __libm_cos_double_dbx#
  1237. __libm_cos_double_dbx:
  1238. { .mlx
  1239. alloc GR_Table_Base= ar.pfs,0,12,2,0
  1240. (p0) movl GR_Sin_or_Cos = 0x1 ;;
  1241. }
  1242. { .mmi
  1243. nop.m 999
  1244. (p0) addl GR_Table_Base = @ltoff(FSINCOS_CONSTANTS#), gp
  1245. nop.i 999
  1246. }
  1247. ;;
  1248. { .mmi
  1249. ld8 GR_Table_Base = [GR_Table_Base]
  1250. nop.m 999
  1251. nop.i 999
  1252. }
  1253. ;;
  1254. //
  1255. // Load Table Address
  1256. //
  1257. SINCOS_CONTINUE:
  1258. { .mmi
  1259. (p0) add GR_Table_Base1 = 96, GR_Table_Base
  1260. (p0) ldfs FR_Two_to_24 = [GR_Table_Base], 4
  1261. nop.i 999
  1262. }
  1263. ;;
  1264. { .mmi
  1265. nop.m 999
  1266. //
  1267. // Load 2**24, load 2**63.
  1268. //
  1269. (p0) ldfs FR_Neg_Two_to_24 = [GR_Table_Base], 12
  1270. (p0) mov r41 = ar.pfs ;;
  1271. }
  1272. { .mfi
  1273. (p0) ldfs FR_Two_to_63 = [GR_Table_Base1], 4
  1274. //
  1275. // Check for unnormals - unsupported operands. We do not want
  1276. // to generate denormal exception
  1277. // Check for NatVals, QNaNs, SNaNs, +/-Infs
  1278. // Check for EM unsupporteds
  1279. // Check for Zero
  1280. //
  1281. (p0) fclass.m.unc p6, p8 = FR_Input_X, 0x1E3
  1282. (p0) mov r40 = gp ;;
  1283. }
  1284. { .mfi
  1285. nop.m 999
  1286. (p0) fclass.nm.unc p8, p0 = FR_Input_X, 0x1FF
  1287. // GR_Sin_or_Cos denotes
  1288. (p0) mov r39 = b0
  1289. }
  1290. { .mfb
  1291. (p0) ldfs FR_Neg_Two_to_63 = [GR_Table_Base1], 12
  1292. (p0) fclass.m.unc p10, p0 = FR_Input_X, 0x007
  1293. (p6) br.cond.spnt SINCOS_SPECIAL ;;
  1294. }
  1295. { .mib
  1296. nop.m 999
  1297. nop.i 999
  1298. (p8) br.cond.spnt SINCOS_SPECIAL ;;
  1299. }
  1300. { .mib
  1301. nop.m 999
  1302. nop.i 999
  1303. //
  1304. // Branch if +/- NaN, Inf.
  1305. // Load -2**24, load -2**63.
  1306. //
  1307. (p10) br.cond.spnt SINCOS_ZERO ;;
  1308. }
  1309. { .mmb
  1310. (p0) ldfe FR_Inv_pi_by_2 = [GR_Table_Base], 16
  1311. (p0) ldfe FR_Inv_P_0 = [GR_Table_Base1], 16
  1312. nop.b 999 ;;
  1313. }
  1314. { .mmb
  1315. nop.m 999
  1316. (p0) ldfe FR_d_1 = [GR_Table_Base1], 16
  1317. nop.b 999 ;;
  1318. }
  1319. //
  1320. // Raise possible denormal operand flag with useful fcmp
  1321. // Is x <= -2**63
  1322. // Load Inv_P_0 for pre-reduction
  1323. // Load Inv_pi_by_2
  1324. //
  1325. { .mmb
  1326. (p0) ldfe FR_P_0 = [GR_Table_Base], 16
  1327. (p0) ldfe FR_d_2 = [GR_Table_Base1], 16
  1328. nop.b 999 ;;
  1329. }
  1330. //
  1331. // Load P_0
  1332. // Load d_1
  1333. // Is x >= 2**63
  1334. // Is x <= -2**24?
  1335. //
  1336. { .mmi
  1337. (p0) ldfe FR_P_1 = [GR_Table_Base], 16 ;;
  1338. //
  1339. // Load P_1
  1340. // Load d_2
  1341. // Is x >= 2**24?
  1342. //
  1343. (p0) ldfe FR_P_2 = [GR_Table_Base], 16
  1344. nop.i 999 ;;
  1345. }
  1346. { .mmf
  1347. nop.m 999
  1348. (p0) ldfe FR_P_3 = [GR_Table_Base], 16
  1349. (p0) fcmp.le.unc.s1 p7, p8 = FR_Input_X, FR_Neg_Two_to_24
  1350. }
  1351. { .mfi
  1352. nop.m 999
  1353. //
  1354. // Branch if +/- zero.
  1355. // Decide about the paths to take:
  1356. // If -2**24 < FR_Input_X < 2**24 - CASE 1 OR 2
  1357. // OTHERWISE - CASE 3 OR 4
  1358. //
  1359. (p0) fcmp.le.unc.s0 p10, p11 = FR_Input_X, FR_Neg_Two_to_63
  1360. nop.i 999 ;;
  1361. }
  1362. { .mfi
  1363. nop.m 999
  1364. (p8) fcmp.ge.s1 p7, p0 = FR_Input_X, FR_Two_to_24
  1365. nop.i 999
  1366. }
  1367. { .mfi
  1368. (p0) ldfe FR_Pi_by_4 = [GR_Table_Base1], 16
  1369. (p11) fcmp.ge.s1 p10, p0 = FR_Input_X, FR_Two_to_63
  1370. nop.i 999 ;;
  1371. }
  1372. { .mmi
  1373. (p0) ldfe FR_Neg_Pi_by_4 = [GR_Table_Base1], 16 ;;
  1374. (p0) ldfs FR_Two_to_M3 = [GR_Table_Base1], 4
  1375. nop.i 999 ;;
  1376. }
  1377. { .mib
  1378. (p0) ldfs FR_Neg_Two_to_M3 = [GR_Table_Base1], 12
  1379. nop.i 999
  1380. //
  1381. // Load P_2
  1382. // Load P_3
  1383. // Load pi_by_4
  1384. // Load neg_pi_by_4
  1385. // Load 2**(-3)
  1386. // Load -2**(-3).
  1387. //
  1388. (p10) br.cond.spnt SINCOS_ARG_TOO_LARGE ;;
  1389. }
  1390. { .mib
  1391. nop.m 999
  1392. nop.i 999
  1393. //
  1394. // Branch out if x >= 2**63. Use Payne-Hanek Reduction
  1395. //
  1396. (p7) br.cond.spnt SINCOS_LARGER_ARG ;;
  1397. }
  1398. { .mfi
  1399. nop.m 999
  1400. //
  1401. // Branch if Arg <= -2**24 or Arg >= 2**24 and use pre-reduction.
  1402. //
  1403. (p0) fma.s1 FR_N_float = FR_Input_X, FR_Inv_pi_by_2, f0
  1404. nop.i 999 ;;
  1405. }
  1406. { .mfi
  1407. nop.m 999
  1408. (p0) fcmp.lt.unc.s1 p6, p7 = FR_Input_X, FR_Pi_by_4
  1409. nop.i 999 ;;
  1410. }
  1411. { .mfi
  1412. nop.m 999
  1413. //
  1414. // Select the case when |Arg| < pi/4
  1415. // Else Select the case when |Arg| >= pi/4
  1416. //
  1417. (p0) fcvt.fx.s1 FR_N_fix = FR_N_float
  1418. nop.i 999 ;;
  1419. }
  1420. { .mfi
  1421. nop.m 999
  1422. //
  1423. // N = Arg * 2/pi
  1424. // Check if Arg < pi/4
  1425. //
  1426. (p6) fcmp.gt.s1 p6, p7 = FR_Input_X, FR_Neg_Pi_by_4
  1427. nop.i 999 ;;
  1428. }
  1429. //
  1430. // Case 2: Convert integer N_fix back to normalized floating-point value.
  1431. // Case 1: p8 is only affected when p6 is set
  1432. //
  1433. { .mfi
  1434. (p7) ldfs FR_Two_to_M33 = [GR_Table_Base1], 4
  1435. //
  1436. // Grab the integer part of N and call it N_fix
  1437. //
  1438. (p6) fmerge.se FR_r = FR_Input_X, FR_Input_X
  1439. // If |x| < pi/4, r = x and c = 0
  1440. // lf |x| < pi/4, is x < 2**(-3).
  1441. // r = Arg
  1442. // c = 0
  1443. (p6) mov GR_N_Inc = GR_Sin_or_Cos ;;
  1444. }
  1445. { .mmf
  1446. nop.m 999
  1447. (p7) ldfs FR_Neg_Two_to_M33 = [GR_Table_Base1], 4
  1448. (p6) fmerge.se FR_c = f0, f0
  1449. }
  1450. { .mfi
  1451. nop.m 999
  1452. (p6) fcmp.lt.unc.s1 p8, p9 = FR_Input_X, FR_Two_to_M3
  1453. nop.i 999 ;;
  1454. }
  1455. { .mfi
  1456. nop.m 999
  1457. //
  1458. // lf |x| < pi/4, is -2**(-3)< x < 2**(-3) - set p8.
  1459. // If |x| >= pi/4,
  1460. // Create the right N for |x| < pi/4 and otherwise
  1461. // Case 2: Place integer part of N in GP register
  1462. //
  1463. (p7) fcvt.xf FR_N_float = FR_N_fix
  1464. nop.i 999 ;;
  1465. }
  1466. { .mmf
  1467. nop.m 999
  1468. (p7) getf.sig GR_N_Inc = FR_N_fix
  1469. (p8) fcmp.gt.s1 p8, p0 = FR_Input_X, FR_Neg_Two_to_M3 ;;
  1470. }
  1471. { .mib
  1472. nop.m 999
  1473. nop.i 999
  1474. //
  1475. // Load 2**(-33), -2**(-33)
  1476. //
  1477. (p8) br.cond.spnt SINCOS_SMALL_R ;;
  1478. }
  1479. { .mib
  1480. nop.m 999
  1481. nop.i 999
  1482. (p6) br.cond.sptk SINCOS_NORMAL_R ;;
  1483. }
  1484. //
  1485. // if |x| < pi/4, branch based on |x| < 2**(-3) or otherwise.
  1486. //
  1487. //
  1488. // In this branch, |x| >= pi/4.
  1489. //
  1490. { .mfi
  1491. (p0) ldfs FR_Neg_Two_to_M67 = [GR_Table_Base1], 8
  1492. //
  1493. // Load -2**(-67)
  1494. //
  1495. (p0) fnma.s1 FR_s = FR_N_float, FR_P_1, FR_Input_X
  1496. //
  1497. // w = N * P_2
  1498. // s = -N * P_1 + Arg
  1499. //
  1500. (p0) add GR_N_Inc = GR_N_Inc, GR_Sin_or_Cos
  1501. }
  1502. { .mfi
  1503. nop.m 999
  1504. (p0) fma.s1 FR_w = FR_N_float, FR_P_2, f0
  1505. nop.i 999 ;;
  1506. }
  1507. { .mfi
  1508. nop.m 999
  1509. //
  1510. // Adjust N_fix by N_inc to determine whether sine or
  1511. // cosine is being calculated
  1512. //
  1513. (p0) fcmp.lt.unc.s1 p7, p6 = FR_s, FR_Two_to_M33
  1514. nop.i 999 ;;
  1515. }
  1516. { .mfi
  1517. nop.m 999
  1518. (p7) fcmp.gt.s1 p7, p6 = FR_s, FR_Neg_Two_to_M33
  1519. nop.i 999 ;;
  1520. }
  1521. { .mfi
  1522. nop.m 999
  1523. // Remember x >= pi/4.
  1524. // Is s <= -2**(-33) or s >= 2**(-33) (p6)
  1525. // or -2**(-33) < s < 2**(-33) (p7)
  1526. (p6) fms.s1 FR_r = FR_s, f1, FR_w
  1527. nop.i 999
  1528. }
  1529. { .mfi
  1530. nop.m 999
  1531. (p7) fma.s1 FR_w = FR_N_float, FR_P_3, f0
  1532. nop.i 999 ;;
  1533. }
  1534. { .mfi
  1535. nop.m 999
  1536. (p7) fma.s1 FR_U_1 = FR_N_float, FR_P_2, FR_w
  1537. nop.i 999
  1538. }
  1539. { .mfi
  1540. nop.m 999
  1541. (p6) fms.s1 FR_c = FR_s, f1, FR_r
  1542. nop.i 999 ;;
  1543. }
  1544. { .mfi
  1545. nop.m 999
  1546. //
  1547. // For big s: r = s - w: No futher reduction is necessary
  1548. // For small s: w = N * P_3 (change sign) More reduction
  1549. //
  1550. (p6) fcmp.lt.unc.s1 p8, p9 = FR_r, FR_Two_to_M3
  1551. nop.i 999 ;;
  1552. }
  1553. { .mfi
  1554. nop.m 999
  1555. (p8) fcmp.gt.s1 p8, p9 = FR_r, FR_Neg_Two_to_M3
  1556. nop.i 999 ;;
  1557. }
  1558. { .mfi
  1559. nop.m 999
  1560. (p7) fms.s1 FR_r = FR_s, f1, FR_U_1
  1561. nop.i 999
  1562. }
  1563. { .mfb
  1564. nop.m 999
  1565. //
  1566. // For big s: Is |r| < 2**(-3)?
  1567. // For big s: c = S - r
  1568. // For small s: U_1 = N * P_2 + w
  1569. //
  1570. // If p8 is set, prepare to branch to Small_R.
  1571. // If p9 is set, prepare to branch to Normal_R.
  1572. // For big s, r is complete here.
  1573. //
  1574. (p6) fms.s1 FR_c = FR_c, f1, FR_w
  1575. //
  1576. // For big s: c = c + w (w has not been negated.)
  1577. // For small s: r = S - U_1
  1578. //
  1579. (p8) br.cond.spnt SINCOS_SMALL_R ;;
  1580. }
  1581. { .mib
  1582. nop.m 999
  1583. nop.i 999
  1584. (p9) br.cond.sptk SINCOS_NORMAL_R ;;
  1585. }
  1586. { .mfi
  1587. (p7) add GR_Table_Base1 = 224, GR_Table_Base1
  1588. //
  1589. // Branch to SINCOS_SMALL_R or SINCOS_NORMAL_R
  1590. //
  1591. (p7) fms.s1 FR_U_2 = FR_N_float, FR_P_2, FR_U_1
  1592. //
  1593. // c = S - U_1
  1594. // r = S_1 * r
  1595. //
  1596. //
  1597. (p7) extr.u GR_i_1 = GR_N_Inc, 0, 1
  1598. }
  1599. { .mmi
  1600. nop.m 999 ;;
  1601. //
  1602. // Get [i_0,i_1] - two lsb of N_fix_gr.
  1603. // Do dummy fmpy so inexact is always set.
  1604. //
  1605. (p7) cmp.eq.unc p9, p10 = 0x0, GR_i_1
  1606. (p7) extr.u GR_i_0 = GR_N_Inc, 1, 1 ;;
  1607. }
  1608. //
  1609. // For small s: U_2 = N * P_2 - U_1
  1610. // S_1 stored constant - grab the one stored with the
  1611. // coefficients.
  1612. //
  1613. { .mfi
  1614. (p7) ldfe FR_S_1 = [GR_Table_Base1], 16
  1615. //
  1616. // Check if i_1 and i_0 != 0
  1617. //
  1618. (p10) fma.s1 FR_poly = f0, f1, FR_Neg_Two_to_M67
  1619. (p7) cmp.eq.unc p11, p12 = 0x0, GR_i_0 ;;
  1620. }
  1621. { .mfi
  1622. nop.m 999
  1623. (p7) fms.s1 FR_s = FR_s, f1, FR_r
  1624. nop.i 999
  1625. }
  1626. { .mfi
  1627. nop.m 999
  1628. //
  1629. // S = S - r
  1630. // U_2 = U_2 + w
  1631. // load S_1
  1632. //
  1633. (p7) fma.s1 FR_rsq = FR_r, FR_r, f0
  1634. nop.i 999 ;;
  1635. }
  1636. { .mfi
  1637. nop.m 999
  1638. (p7) fma.s1 FR_U_2 = FR_U_2, f1, FR_w
  1639. nop.i 999
  1640. }
  1641. { .mfi
  1642. nop.m 999
  1643. (p7) fmerge.se FR_Input_X = FR_r, FR_r
  1644. nop.i 999 ;;
  1645. }
  1646. { .mfi
  1647. nop.m 999
  1648. (p10) fma.s1 FR_Input_X = f0, f1, f1
  1649. nop.i 999 ;;
  1650. }
  1651. { .mfi
  1652. nop.m 999
  1653. //
  1654. // FR_rsq = r * r
  1655. // Save r as the result.
  1656. //
  1657. (p7) fms.s1 FR_c = FR_s, f1, FR_U_1
  1658. nop.i 999 ;;
  1659. }
  1660. { .mfi
  1661. nop.m 999
  1662. //
  1663. // if ( i_1 ==0) poly = c + S_1*r*r*r
  1664. // else Result = 1
  1665. //
  1666. (p12) fnma.s1 FR_Input_X = FR_Input_X, f1, f0
  1667. nop.i 999
  1668. }
  1669. { .mfi
  1670. nop.m 999
  1671. (p7) fma.s1 FR_r = FR_S_1, FR_r, f0
  1672. nop.i 999 ;;
  1673. }
  1674. { .mfi
  1675. nop.m 999
  1676. (p7) fma.d.s0 FR_S_1 = FR_S_1, FR_S_1, f0
  1677. nop.i 999 ;;
  1678. }
  1679. { .mfi
  1680. nop.m 999
  1681. //
  1682. // If i_1 != 0, poly = 2**(-67)
  1683. //
  1684. (p7) fms.s1 FR_c = FR_c, f1, FR_U_2
  1685. nop.i 999 ;;
  1686. }
  1687. { .mfi
  1688. nop.m 999
  1689. //
  1690. // c = c - U_2
  1691. //
  1692. (p9) fma.s1 FR_poly = FR_r, FR_rsq, FR_c
  1693. nop.i 999 ;;
  1694. }
  1695. { .mfi
  1696. nop.m 999
  1697. //
  1698. // i_0 != 0, so Result = -Result
  1699. //
  1700. (p11) fma.d.s0 FR_Input_X = FR_Input_X, f1, FR_poly
  1701. nop.i 999 ;;
  1702. }
  1703. { .mfb
  1704. nop.m 999
  1705. (p12) fms.d.s0 FR_Input_X = FR_Input_X, f1, FR_poly
  1706. //
  1707. // if (i_0 == 0), Result = Result + poly
  1708. // else Result = Result - poly
  1709. //
  1710. (p0) br.ret.sptk b0 ;;
  1711. }
  1712. SINCOS_LARGER_ARG:
  1713. { .mfi
  1714. nop.m 999
  1715. (p0) fma.s1 FR_N_0 = FR_Input_X, FR_Inv_P_0, f0
  1716. nop.i 999
  1717. }
  1718. ;;
  1719. // This path for argument > 2*24
  1720. // Adjust table_ptr1 to beginning of table.
  1721. //
  1722. { .mmi
  1723. nop.m 999
  1724. (p0) addl GR_Table_Base = @ltoff(FSINCOS_CONSTANTS#), gp
  1725. nop.i 999
  1726. }
  1727. ;;
  1728. { .mmi
  1729. ld8 GR_Table_Base = [GR_Table_Base]
  1730. nop.m 999
  1731. nop.i 999
  1732. }
  1733. ;;
  1734. //
  1735. // Point to 2*-14
  1736. // N_0 = Arg * Inv_P_0
  1737. //
  1738. { .mmi
  1739. (p0) add GR_Table_Base = 688, GR_Table_Base ;;
  1740. (p0) ldfs FR_Two_to_M14 = [GR_Table_Base], 4
  1741. nop.i 999 ;;
  1742. }
  1743. { .mfi
  1744. (p0) ldfs FR_Neg_Two_to_M14 = [GR_Table_Base], 0
  1745. nop.f 999
  1746. nop.i 999 ;;
  1747. }
  1748. { .mfi
  1749. nop.m 999
  1750. //
  1751. // Load values 2**(-14) and -2**(-14)
  1752. //
  1753. (p0) fcvt.fx.s1 FR_N_0_fix = FR_N_0
  1754. nop.i 999 ;;
  1755. }
  1756. { .mfi
  1757. nop.m 999
  1758. //
  1759. // N_0_fix = integer part of N_0
  1760. //
  1761. (p0) fcvt.xf FR_N_0 = FR_N_0_fix
  1762. nop.i 999 ;;
  1763. }
  1764. { .mfi
  1765. nop.m 999
  1766. //
  1767. // Make N_0 the integer part
  1768. //
  1769. (p0) fnma.s1 FR_ArgPrime = FR_N_0, FR_P_0, FR_Input_X
  1770. nop.i 999
  1771. }
  1772. { .mfi
  1773. nop.m 999
  1774. (p0) fma.s1 FR_w = FR_N_0, FR_d_1, f0
  1775. nop.i 999 ;;
  1776. }
  1777. { .mfi
  1778. nop.m 999
  1779. //
  1780. // Arg' = -N_0 * P_0 + Arg
  1781. // w = N_0 * d_1
  1782. //
  1783. (p0) fma.s1 FR_N_float = FR_ArgPrime, FR_Inv_pi_by_2, f0
  1784. nop.i 999 ;;
  1785. }
  1786. { .mfi
  1787. nop.m 999
  1788. //
  1789. // N = A' * 2/pi
  1790. //
  1791. (p0) fcvt.fx.s1 FR_N_fix = FR_N_float
  1792. nop.i 999 ;;
  1793. }
  1794. { .mfi
  1795. nop.m 999
  1796. //
  1797. // N_fix is the integer part
  1798. //
  1799. (p0) fcvt.xf FR_N_float = FR_N_fix
  1800. nop.i 999 ;;
  1801. }
  1802. { .mfi
  1803. (p0) getf.sig GR_N_Inc = FR_N_fix
  1804. nop.f 999
  1805. nop.i 999 ;;
  1806. }
  1807. { .mii
  1808. nop.m 999
  1809. nop.i 999 ;;
  1810. (p0) add GR_N_Inc = GR_N_Inc, GR_Sin_or_Cos ;;
  1811. }
  1812. { .mfi
  1813. nop.m 999
  1814. //
  1815. // N is the integer part of the reduced-reduced argument.
  1816. // Put the integer in a GP register
  1817. //
  1818. (p0) fnma.s1 FR_s = FR_N_float, FR_P_1, FR_ArgPrime
  1819. nop.i 999
  1820. }
  1821. { .mfi
  1822. nop.m 999
  1823. (p0) fnma.s1 FR_w = FR_N_float, FR_P_2, FR_w
  1824. nop.i 999 ;;
  1825. }
  1826. { .mfi
  1827. nop.m 999
  1828. //
  1829. // s = -N*P_1 + Arg'
  1830. // w = -N*P_2 + w
  1831. // N_fix_gr = N_fix_gr + N_inc
  1832. //
  1833. (p0) fcmp.lt.unc.s1 p9, p8 = FR_s, FR_Two_to_M14
  1834. nop.i 999 ;;
  1835. }
  1836. { .mfi
  1837. nop.m 999
  1838. (p9) fcmp.gt.s1 p9, p8 = FR_s, FR_Neg_Two_to_M14
  1839. nop.i 999 ;;
  1840. }
  1841. { .mfi
  1842. nop.m 999
  1843. //
  1844. // For |s| > 2**(-14) r = S + w (r complete)
  1845. // Else U_hi = N_0 * d_1
  1846. //
  1847. (p9) fma.s1 FR_V_hi = FR_N_float, FR_P_2, f0
  1848. nop.i 999
  1849. }
  1850. { .mfi
  1851. nop.m 999
  1852. (p9) fma.s1 FR_U_hi = FR_N_0, FR_d_1, f0
  1853. nop.i 999 ;;
  1854. }
  1855. { .mfi
  1856. nop.m 999
  1857. //
  1858. // Either S <= -2**(-14) or S >= 2**(-14)
  1859. // or -2**(-14) < s < 2**(-14)
  1860. //
  1861. (p8) fma.s1 FR_r = FR_s, f1, FR_w
  1862. nop.i 999
  1863. }
  1864. { .mfi
  1865. nop.m 999
  1866. (p9) fma.s1 FR_w = FR_N_float, FR_P_3, f0
  1867. nop.i 999 ;;
  1868. }
  1869. { .mfi
  1870. nop.m 999
  1871. //
  1872. // We need abs of both U_hi and V_hi - don't
  1873. // worry about switched sign of V_hi.
  1874. //
  1875. (p9) fms.s1 FR_A = FR_U_hi, f1, FR_V_hi
  1876. nop.i 999
  1877. }
  1878. { .mfi
  1879. nop.m 999
  1880. //
  1881. // Big s: finish up c = (S - r) + w (c complete)
  1882. // Case 4: A = U_hi + V_hi
  1883. // Note: Worry about switched sign of V_hi, so subtract instead of add.
  1884. //
  1885. (p9) fnma.s1 FR_V_lo = FR_N_float, FR_P_2, FR_V_hi
  1886. nop.i 999 ;;
  1887. }
  1888. { .mfi
  1889. nop.m 999
  1890. (p9) fms.s1 FR_U_lo = FR_N_0, FR_d_1, FR_U_hi
  1891. nop.i 999 ;;
  1892. }
  1893. { .mfi
  1894. nop.m 999
  1895. (p9) fmerge.s FR_V_hiabs = f0, FR_V_hi
  1896. nop.i 999
  1897. }
  1898. { .mfi
  1899. nop.m 999
  1900. // For big s: c = S - r
  1901. // For small s do more work: U_lo = N_0 * d_1 - U_hi
  1902. //
  1903. (p9) fmerge.s FR_U_hiabs = f0, FR_U_hi
  1904. nop.i 999 ;;
  1905. }
  1906. { .mfi
  1907. nop.m 999
  1908. //
  1909. // For big s: Is |r| < 2**(-3)
  1910. // For big s: if p12 set, prepare to branch to Small_R.
  1911. // For big s: If p13 set, prepare to branch to Normal_R.
  1912. //
  1913. (p8) fms.s1 FR_c = FR_s, f1, FR_r
  1914. nop.i 999
  1915. }
  1916. { .mfi
  1917. nop.m 999
  1918. //
  1919. // For small S: V_hi = N * P_2
  1920. // w = N * P_3
  1921. // Note the product does not include the (-) as in the writeup
  1922. // so (-) missing for V_hi and w.
  1923. //
  1924. (p8) fcmp.lt.unc.s1 p12, p13 = FR_r, FR_Two_to_M3
  1925. nop.i 999 ;;
  1926. }
  1927. { .mfi
  1928. nop.m 999
  1929. (p12) fcmp.gt.s1 p12, p13 = FR_r, FR_Neg_Two_to_M3
  1930. nop.i 999 ;;
  1931. }
  1932. { .mfi
  1933. nop.m 999
  1934. (p8) fma.s1 FR_c = FR_c, f1, FR_w
  1935. nop.i 999
  1936. }
  1937. { .mfb
  1938. nop.m 999
  1939. (p9) fms.s1 FR_w = FR_N_0, FR_d_2, FR_w
  1940. (p12) br.cond.spnt SINCOS_SMALL_R ;;
  1941. }
  1942. { .mib
  1943. nop.m 999
  1944. nop.i 999
  1945. (p13) br.cond.sptk SINCOS_NORMAL_R ;;
  1946. }
  1947. { .mfi
  1948. nop.m 999
  1949. //
  1950. // Big s: Vector off when |r| < 2**(-3). Recall that p8 will be true.
  1951. // The remaining stuff is for Case 4.
  1952. // Small s: V_lo = N * P_2 + U_hi (U_hi is in place of V_hi in writeup)
  1953. // Note: the (-) is still missing for V_lo.
  1954. // Small s: w = w + N_0 * d_2
  1955. // Note: the (-) is now incorporated in w.
  1956. //
  1957. (p9) fcmp.ge.unc.s1 p10, p11 = FR_U_hiabs, FR_V_hiabs
  1958. (p0) extr.u GR_i_1 = GR_N_Inc, 0, 1 ;;
  1959. }
  1960. { .mfi
  1961. nop.m 999
  1962. //
  1963. // C_hi = S + A
  1964. //
  1965. (p9) fma.s1 FR_t = FR_U_lo, f1, FR_V_lo
  1966. (p0) extr.u GR_i_0 = GR_N_Inc, 1, 1 ;;
  1967. }
  1968. { .mfi
  1969. nop.m 999
  1970. //
  1971. // t = U_lo + V_lo
  1972. //
  1973. //
  1974. (p10) fms.s1 FR_a = FR_U_hi, f1, FR_A
  1975. nop.i 999 ;;
  1976. }
  1977. { .mfi
  1978. nop.m 999
  1979. (p11) fma.s1 FR_a = FR_V_hi, f1, FR_A
  1980. nop.i 999
  1981. }
  1982. ;;
  1983. { .mmi
  1984. nop.m 999
  1985. (p0) addl GR_Table_Base = @ltoff(FSINCOS_CONSTANTS#), gp
  1986. nop.i 999
  1987. }
  1988. ;;
  1989. { .mmi
  1990. ld8 GR_Table_Base = [GR_Table_Base]
  1991. nop.m 999
  1992. nop.i 999
  1993. }
  1994. ;;
  1995. { .mfi
  1996. (p0) add GR_Table_Base = 528, GR_Table_Base
  1997. //
  1998. // Is U_hiabs >= V_hiabs?
  1999. //
  2000. (p9) fma.s1 FR_C_hi = FR_s, f1, FR_A
  2001. nop.i 999 ;;
  2002. }
  2003. { .mmi
  2004. (p0) ldfe FR_C_1 = [GR_Table_Base], 16 ;;
  2005. (p0) ldfe FR_C_2 = [GR_Table_Base], 64
  2006. nop.i 999 ;;
  2007. }
  2008. { .mmf
  2009. nop.m 999
  2010. //
  2011. // c = c + C_lo finished.
  2012. // Load C_2
  2013. //
  2014. (p0) ldfe FR_S_1 = [GR_Table_Base], 16
  2015. //
  2016. // C_lo = S - C_hi
  2017. //
  2018. (p0) fma.s1 FR_t = FR_t, f1, FR_w ;;
  2019. }
  2020. //
  2021. // r and c have been computed.
  2022. // Make sure ftz mode is set - should be automatic when using wre
  2023. // |r| < 2**(-3)
  2024. // Get [i_0,i_1] - two lsb of N_fix.
  2025. // Load S_1
  2026. //
  2027. { .mfi
  2028. (p0) ldfe FR_S_2 = [GR_Table_Base], 64
  2029. //
  2030. // t = t + w
  2031. //
  2032. (p10) fms.s1 FR_a = FR_a, f1, FR_V_hi
  2033. (p0) cmp.eq.unc p9, p10 = 0x0, GR_i_0
  2034. }
  2035. { .mfi
  2036. nop.m 999
  2037. //
  2038. // For larger u than v: a = U_hi - A
  2039. // Else a = V_hi - A (do an add to account for missing (-) on V_hi
  2040. //
  2041. (p0) fms.s1 FR_C_lo = FR_s, f1, FR_C_hi
  2042. nop.i 999 ;;
  2043. }
  2044. { .mfi
  2045. nop.m 999
  2046. (p11) fms.s1 FR_a = FR_U_hi, f1, FR_a
  2047. (p0) cmp.eq.unc p11, p12 = 0x0, GR_i_1
  2048. }
  2049. { .mfi
  2050. nop.m 999
  2051. //
  2052. // If u > v: a = (U_hi - A) + V_hi
  2053. // Else a = (V_hi - A) + U_hi
  2054. // In each case account for negative missing from V_hi.
  2055. //
  2056. (p0) fma.s1 FR_C_lo = FR_C_lo, f1, FR_A
  2057. nop.i 999 ;;
  2058. }
  2059. { .mfi
  2060. nop.m 999
  2061. //
  2062. // C_lo = (S - C_hi) + A
  2063. //
  2064. (p0) fma.s1 FR_t = FR_t, f1, FR_a
  2065. nop.i 999 ;;
  2066. }
  2067. { .mfi
  2068. nop.m 999
  2069. //
  2070. // t = t + a
  2071. //
  2072. (p0) fma.s1 FR_C_lo = FR_C_lo, f1, FR_t
  2073. nop.i 999 ;;
  2074. }
  2075. { .mfi
  2076. nop.m 999
  2077. //
  2078. // C_lo = C_lo + t
  2079. // Adjust Table_Base to beginning of table
  2080. //
  2081. (p0) fma.s1 FR_r = FR_C_hi, f1, FR_C_lo
  2082. nop.i 999 ;;
  2083. }
  2084. { .mfi
  2085. nop.m 999
  2086. //
  2087. // Load S_2
  2088. //
  2089. (p0) fma.s1 FR_rsq = FR_r, FR_r, f0
  2090. nop.i 999
  2091. }
  2092. { .mfi
  2093. nop.m 999
  2094. //
  2095. // Table_Base points to C_1
  2096. // r = C_hi + C_lo
  2097. //
  2098. (p0) fms.s1 FR_c = FR_C_hi, f1, FR_r
  2099. nop.i 999 ;;
  2100. }
  2101. { .mfi
  2102. nop.m 999
  2103. //
  2104. // if i_1 ==0: poly = S_2 * FR_rsq + S_1
  2105. // else poly = C_2 * FR_rsq + C_1
  2106. //
  2107. (p11) fma.s1 FR_Input_X = f0, f1, FR_r
  2108. nop.i 999 ;;
  2109. }
  2110. { .mfi
  2111. nop.m 999
  2112. (p12) fma.s1 FR_Input_X = f0, f1, f1
  2113. nop.i 999 ;;
  2114. }
  2115. { .mfi
  2116. nop.m 999
  2117. //
  2118. // Compute r_cube = FR_rsq * r
  2119. //
  2120. (p11) fma.s1 FR_poly = FR_rsq, FR_S_2, FR_S_1
  2121. nop.i 999 ;;
  2122. }
  2123. { .mfi
  2124. nop.m 999
  2125. (p12) fma.s1 FR_poly = FR_rsq, FR_C_2, FR_C_1
  2126. nop.i 999
  2127. }
  2128. { .mfi
  2129. nop.m 999
  2130. //
  2131. // Compute FR_rsq = r * r
  2132. // Is i_1 == 0 ?
  2133. //
  2134. (p0) fma.s1 FR_r_cubed = FR_rsq, FR_r, f0
  2135. nop.i 999 ;;
  2136. }
  2137. { .mfi
  2138. nop.m 999
  2139. //
  2140. // c = C_hi - r
  2141. // Load C_1
  2142. //
  2143. (p0) fma.s1 FR_c = FR_c, f1, FR_C_lo
  2144. nop.i 999
  2145. }
  2146. { .mfi
  2147. nop.m 999
  2148. //
  2149. // if i_1 ==0: poly = r_cube * poly + c
  2150. // else poly = FR_rsq * poly
  2151. //
  2152. (p10) fms.s1 FR_Input_X = f0, f1, FR_Input_X
  2153. nop.i 999 ;;
  2154. }
  2155. { .mfi
  2156. nop.m 999
  2157. //
  2158. // if i_1 ==0: Result = r
  2159. // else Result = 1.0
  2160. //
  2161. (p11) fma.s1 FR_poly = FR_r_cubed, FR_poly, FR_c
  2162. nop.i 999 ;;
  2163. }
  2164. { .mfi
  2165. nop.m 999
  2166. (p12) fma.s1 FR_poly = FR_rsq, FR_poly, f0
  2167. nop.i 999 ;;
  2168. }
  2169. { .mfi
  2170. nop.m 999
  2171. //
  2172. // if i_0 !=0: Result = -Result
  2173. //
  2174. (p9) fma.d.s0 FR_Input_X = FR_Input_X, f1, FR_poly
  2175. nop.i 999 ;;
  2176. }
  2177. { .mfb
  2178. nop.m 999
  2179. (p10) fms.d.s0 FR_Input_X = FR_Input_X, f1, FR_poly
  2180. //
  2181. // if i_0 == 0: Result = Result + poly
  2182. // else Result = Result - poly
  2183. //
  2184. (p0) br.ret.sptk b0 ;;
  2185. }
  2186. SINCOS_SMALL_R:
  2187. { .mii
  2188. nop.m 999
  2189. (p0) extr.u GR_i_1 = GR_N_Inc, 0, 1 ;;
  2190. //
  2191. //
  2192. // Compare both i_1 and i_0 with 0.
  2193. // if i_1 == 0, set p9.
  2194. // if i_0 == 0, set p11.
  2195. //
  2196. (p0) cmp.eq.unc p9, p10 = 0x0, GR_i_1 ;;
  2197. }
  2198. { .mfi
  2199. nop.m 999
  2200. (p0) fma.s1 FR_rsq = FR_r, FR_r, f0
  2201. (p0) extr.u GR_i_0 = GR_N_Inc, 1, 1 ;;
  2202. }
  2203. { .mfi
  2204. nop.m 999
  2205. //
  2206. // Z = Z * FR_rsq
  2207. //
  2208. (p10) fnma.s1 FR_c = FR_c, FR_r, f0
  2209. (p0) cmp.eq.unc p11, p12 = 0x0, GR_i_0
  2210. }
  2211. ;;
  2212. // ******************************************************************
  2213. // ******************************************************************
  2214. // ******************************************************************
  2215. // r and c have been computed.
  2216. // We know whether this is the sine or cosine routine.
  2217. // Make sure ftz mode is set - should be automatic when using wre
  2218. // |r| < 2**(-3)
  2219. //
  2220. // Set table_ptr1 to beginning of constant table.
  2221. // Get [i_0,i_1] - two lsb of N_fix_gr.
  2222. //
  2223. { .mmi
  2224. nop.m 999
  2225. (p0) addl GR_Table_Base = @ltoff(FSINCOS_CONSTANTS#), gp
  2226. nop.i 999
  2227. }
  2228. ;;
  2229. { .mmi
  2230. ld8 GR_Table_Base = [GR_Table_Base]
  2231. nop.m 999
  2232. nop.i 999
  2233. }
  2234. ;;
  2235. //
  2236. // Set table_ptr1 to point to S_5.
  2237. // Set table_ptr1 to point to C_5.
  2238. // Compute FR_rsq = r * r
  2239. //
  2240. { .mfi
  2241. (p9) add GR_Table_Base = 672, GR_Table_Base
  2242. (p10) fmerge.s FR_r = f1, f1
  2243. (p10) add GR_Table_Base = 592, GR_Table_Base ;;
  2244. }
  2245. //
  2246. // Set table_ptr1 to point to S_5.
  2247. // Set table_ptr1 to point to C_5.
  2248. //
  2249. { .mmi
  2250. (p9) ldfe FR_S_5 = [GR_Table_Base], -16 ;;
  2251. //
  2252. // if (i_1 == 0) load S_5
  2253. // if (i_1 != 0) load C_5
  2254. //
  2255. (p9) ldfe FR_S_4 = [GR_Table_Base], -16
  2256. nop.i 999 ;;
  2257. }
  2258. { .mmf
  2259. (p10) ldfe FR_C_5 = [GR_Table_Base], -16
  2260. //
  2261. // Z = FR_rsq * FR_rsq
  2262. //
  2263. (p9) ldfe FR_S_3 = [GR_Table_Base], -16
  2264. //
  2265. // Compute FR_rsq = r * r
  2266. // if (i_1 == 0) load S_4
  2267. // if (i_1 != 0) load C_4
  2268. //
  2269. (p0) fma.s1 FR_Z = FR_rsq, FR_rsq, f0 ;;
  2270. }
  2271. //
  2272. // if (i_1 == 0) load S_3
  2273. // if (i_1 != 0) load C_3
  2274. //
  2275. { .mmi
  2276. (p9) ldfe FR_S_2 = [GR_Table_Base], -16 ;;
  2277. //
  2278. // if (i_1 == 0) load S_2
  2279. // if (i_1 != 0) load C_2
  2280. //
  2281. (p9) ldfe FR_S_1 = [GR_Table_Base], -16
  2282. nop.i 999
  2283. }
  2284. { .mmi
  2285. (p10) ldfe FR_C_4 = [GR_Table_Base], -16 ;;
  2286. (p10) ldfe FR_C_3 = [GR_Table_Base], -16
  2287. nop.i 999 ;;
  2288. }
  2289. { .mmi
  2290. (p10) ldfe FR_C_2 = [GR_Table_Base], -16 ;;
  2291. (p10) ldfe FR_C_1 = [GR_Table_Base], -16
  2292. nop.i 999
  2293. }
  2294. { .mfi
  2295. nop.m 999
  2296. //
  2297. // if (i_1 != 0):
  2298. // poly_lo = FR_rsq * C_5 + C_4
  2299. // poly_hi = FR_rsq * C_2 + C_1
  2300. //
  2301. (p9) fma.s1 FR_Z = FR_Z, FR_r, f0
  2302. nop.i 999 ;;
  2303. }
  2304. { .mfi
  2305. nop.m 999
  2306. //
  2307. // if (i_1 == 0) load S_1
  2308. // if (i_1 != 0) load C_1
  2309. //
  2310. (p9) fma.s1 FR_poly_lo = FR_rsq, FR_S_5, FR_S_4
  2311. nop.i 999
  2312. }
  2313. { .mfi
  2314. nop.m 999
  2315. //
  2316. // c = -c * r
  2317. // dummy fmpy's to flag inexact.
  2318. //
  2319. (p9) fma.d.s0 FR_S_4 = FR_S_4, FR_S_4, f0
  2320. nop.i 999 ;;
  2321. }
  2322. { .mfi
  2323. nop.m 999
  2324. //
  2325. // poly_lo = FR_rsq * poly_lo + C_3
  2326. // poly_hi = FR_rsq * poly_hi
  2327. //
  2328. (p0) fma.s1 FR_Z = FR_Z, FR_rsq, f0
  2329. nop.i 999 ;;
  2330. }
  2331. { .mfi
  2332. nop.m 999
  2333. (p9) fma.s1 FR_poly_hi = FR_rsq, FR_S_2, FR_S_1
  2334. nop.i 999
  2335. }
  2336. { .mfi
  2337. nop.m 999
  2338. //
  2339. // if (i_1 == 0):
  2340. // poly_lo = FR_rsq * S_5 + S_4
  2341. // poly_hi = FR_rsq * S_2 + S_1
  2342. //
  2343. (p10) fma.s1 FR_poly_lo = FR_rsq, FR_C_5, FR_C_4
  2344. nop.i 999 ;;
  2345. }
  2346. { .mfi
  2347. nop.m 999
  2348. //
  2349. // if (i_1 == 0):
  2350. // Z = Z * r for only one of the small r cases - not there
  2351. // in original implementation notes.
  2352. //
  2353. (p9) fma.s1 FR_poly_lo = FR_rsq, FR_poly_lo, FR_S_3
  2354. nop.i 999 ;;
  2355. }
  2356. { .mfi
  2357. nop.m 999
  2358. (p10) fma.s1 FR_poly_hi = FR_rsq, FR_C_2, FR_C_1
  2359. nop.i 999
  2360. }
  2361. { .mfi
  2362. nop.m 999
  2363. (p10) fma.d.s0 FR_C_1 = FR_C_1, FR_C_1, f0
  2364. nop.i 999 ;;
  2365. }
  2366. { .mfi
  2367. nop.m 999
  2368. (p9) fma.s1 FR_poly_hi = FR_poly_hi, FR_rsq, f0
  2369. nop.i 999
  2370. }
  2371. { .mfi
  2372. nop.m 999
  2373. //
  2374. // poly_lo = FR_rsq * poly_lo + S_3
  2375. // poly_hi = FR_rsq * poly_hi
  2376. //
  2377. (p10) fma.s1 FR_poly_lo = FR_rsq, FR_poly_lo, FR_C_3
  2378. nop.i 999 ;;
  2379. }
  2380. { .mfi
  2381. nop.m 999
  2382. (p10) fma.s1 FR_poly_hi = FR_poly_hi, FR_rsq, f0
  2383. nop.i 999 ;;
  2384. }
  2385. { .mfi
  2386. nop.m 999
  2387. //
  2388. // if (i_1 == 0): dummy fmpy's to flag inexact
  2389. // r = 1
  2390. //
  2391. (p9) fma.s1 FR_poly_hi = FR_r, FR_poly_hi, f0
  2392. nop.i 999
  2393. }
  2394. { .mfi
  2395. nop.m 999
  2396. //
  2397. // poly_hi = r * poly_hi
  2398. //
  2399. (p0) fma.s1 FR_poly = FR_Z, FR_poly_lo, FR_c
  2400. nop.i 999 ;;
  2401. }
  2402. { .mfi
  2403. nop.m 999
  2404. (p12) fms.s1 FR_r = f0, f1, FR_r
  2405. nop.i 999 ;;
  2406. }
  2407. { .mfi
  2408. nop.m 999
  2409. //
  2410. // poly_hi = Z * poly_lo + c
  2411. // if i_0 == 1: r = -r
  2412. //
  2413. (p0) fma.s1 FR_poly = FR_poly, f1, FR_poly_hi
  2414. nop.i 999 ;;
  2415. }
  2416. { .mfi
  2417. nop.m 999
  2418. (p12) fms.d.s0 FR_Input_X = FR_r, f1, FR_poly
  2419. nop.i 999
  2420. }
  2421. { .mfb
  2422. nop.m 999
  2423. //
  2424. // poly = poly + poly_hi
  2425. //
  2426. (p11) fma.d.s0 FR_Input_X = FR_r, f1, FR_poly
  2427. //
  2428. // if (i_0 == 0) Result = r + poly
  2429. // if (i_0 != 0) Result = r - poly
  2430. //
  2431. (p0) br.ret.sptk b0 ;;
  2432. }
  2433. SINCOS_NORMAL_R:
  2434. { .mii
  2435. nop.m 999
  2436. (p0) extr.u GR_i_1 = GR_N_Inc, 0, 1 ;;
  2437. //
  2438. // Set table_ptr1 and table_ptr2 to base address of
  2439. // constant table.
  2440. (p0) cmp.eq.unc p9, p10 = 0x0, GR_i_1 ;;
  2441. }
  2442. { .mfi
  2443. nop.m 999
  2444. (p0) fma.s1 FR_rsq = FR_r, FR_r, f0
  2445. (p0) extr.u GR_i_0 = GR_N_Inc, 1, 1 ;;
  2446. }
  2447. { .mfi
  2448. nop.m 999
  2449. (p0) frcpa.s1 FR_r_hi, p6 = f1, FR_r
  2450. (p0) cmp.eq.unc p11, p12 = 0x0, GR_i_0
  2451. }
  2452. ;;
  2453. // ******************************************************************
  2454. // ******************************************************************
  2455. // ******************************************************************
  2456. //
  2457. // r and c have been computed.
  2458. // We known whether this is the sine or cosine routine.
  2459. // Make sure ftz mode is set - should be automatic when using wre
  2460. // Get [i_0,i_1] - two lsb of N_fix_gr alone.
  2461. //
  2462. { .mmi
  2463. nop.m 999
  2464. (p0) addl GR_Table_Base = @ltoff(FSINCOS_CONSTANTS#), gp
  2465. nop.i 999
  2466. }
  2467. ;;
  2468. { .mmi
  2469. ld8 GR_Table_Base = [GR_Table_Base]
  2470. nop.m 999
  2471. nop.i 999
  2472. }
  2473. ;;
  2474. { .mfi
  2475. (p10) add GR_Table_Base = 384, GR_Table_Base
  2476. (p12) fms.s1 FR_Input_X = f0, f1, f1
  2477. (p9) add GR_Table_Base = 224, GR_Table_Base ;;
  2478. }
  2479. { .mmf
  2480. nop.m 999
  2481. (p10) ldfe FR_QQ_8 = [GR_Table_Base], 16
  2482. //
  2483. // if (i_1==0) poly = poly * FR_rsq + PP_1_lo
  2484. // else poly = FR_rsq * poly
  2485. //
  2486. (p11) fma.s1 FR_Input_X = f0, f1, f1 ;;
  2487. }
  2488. { .mmf
  2489. (p10) ldfe FR_QQ_7 = [GR_Table_Base], 16
  2490. //
  2491. // Adjust table pointers based on i_0
  2492. // Compute rsq = r * r
  2493. //
  2494. (p9) ldfe FR_PP_8 = [GR_Table_Base], 16
  2495. (p0) fma.s1 FR_r_cubed = FR_r, FR_rsq, f0 ;;
  2496. }
  2497. { .mmf
  2498. (p9) ldfe FR_PP_7 = [GR_Table_Base], 16
  2499. (p10) ldfe FR_QQ_6 = [GR_Table_Base], 16
  2500. //
  2501. // Load PP_8 and QQ_8; PP_7 and QQ_7
  2502. //
  2503. (p0) frcpa.s1 FR_r_hi, p6 = f1, FR_r_hi ;;
  2504. }
  2505. //
  2506. // if (i_1==0) poly = PP_7 + FR_rsq * PP_8.
  2507. // else poly = QQ_7 + FR_rsq * QQ_8.
  2508. //
  2509. { .mmb
  2510. (p9) ldfe FR_PP_6 = [GR_Table_Base], 16
  2511. (p10) ldfe FR_QQ_5 = [GR_Table_Base], 16
  2512. nop.b 999 ;;
  2513. }
  2514. { .mmb
  2515. (p9) ldfe FR_PP_5 = [GR_Table_Base], 16
  2516. (p10) ldfe FR_S_1 = [GR_Table_Base], 16
  2517. nop.b 999 ;;
  2518. }
  2519. { .mmb
  2520. (p10) ldfe FR_QQ_1 = [GR_Table_Base], 16
  2521. (p9) ldfe FR_C_1 = [GR_Table_Base], 16
  2522. nop.b 999 ;;
  2523. }
  2524. { .mmi
  2525. (p10) ldfe FR_QQ_4 = [GR_Table_Base], 16 ;;
  2526. (p9) ldfe FR_PP_1 = [GR_Table_Base], 16
  2527. nop.i 999 ;;
  2528. }
  2529. { .mmf
  2530. (p10) ldfe FR_QQ_3 = [GR_Table_Base], 16
  2531. //
  2532. // if (i_1=0) corr = corr + c*c
  2533. // else corr = corr * c
  2534. //
  2535. (p9) ldfe FR_PP_4 = [GR_Table_Base], 16
  2536. (p10) fma.s1 FR_poly = FR_rsq, FR_QQ_8, FR_QQ_7 ;;
  2537. }
  2538. //
  2539. // if (i_1=0) poly = rsq * poly + PP_5
  2540. // else poly = rsq * poly + QQ_5
  2541. // Load PP_4 or QQ_4
  2542. //
  2543. { .mmf
  2544. (p9) ldfe FR_PP_3 = [GR_Table_Base], 16
  2545. (p10) ldfe FR_QQ_2 = [GR_Table_Base], 16
  2546. //
  2547. // r_hi = frcpa(frcpa(r)).
  2548. // r_cube = r * FR_rsq.
  2549. //
  2550. (p9) fma.s1 FR_poly = FR_rsq, FR_PP_8, FR_PP_7 ;;
  2551. }
  2552. //
  2553. // Do dummy multiplies so inexact is always set.
  2554. //
  2555. { .mfi
  2556. (p9) ldfe FR_PP_2 = [GR_Table_Base], 16
  2557. //
  2558. // r_lo = r - r_hi
  2559. //
  2560. (p9) fma.s1 FR_U_lo = FR_r_hi, FR_r_hi, f0
  2561. nop.i 999 ;;
  2562. }
  2563. { .mmf
  2564. nop.m 999
  2565. (p9) ldfe FR_PP_1_lo = [GR_Table_Base], 16
  2566. (p10) fma.s1 FR_corr = FR_S_1, FR_r_cubed, FR_r
  2567. }
  2568. { .mfi
  2569. nop.m 999
  2570. (p10) fma.s1 FR_poly = FR_rsq, FR_poly, FR_QQ_6
  2571. nop.i 999 ;;
  2572. }
  2573. { .mfi
  2574. nop.m 999
  2575. //
  2576. // if (i_1=0) U_lo = r_hi * r_hi
  2577. // else U_lo = r_hi + r
  2578. //
  2579. (p9) fma.s1 FR_corr = FR_C_1, FR_rsq, f0
  2580. nop.i 999 ;;
  2581. }
  2582. { .mfi
  2583. nop.m 999
  2584. //
  2585. // if (i_1=0) corr = C_1 * rsq
  2586. // else corr = S_1 * r_cubed + r
  2587. //
  2588. (p9) fma.s1 FR_poly = FR_rsq, FR_poly, FR_PP_6
  2589. nop.i 999
  2590. }
  2591. { .mfi
  2592. nop.m 999
  2593. (p10) fma.s1 FR_U_lo = FR_r_hi, f1, FR_r
  2594. nop.i 999 ;;
  2595. }
  2596. { .mfi
  2597. nop.m 999
  2598. //
  2599. // if (i_1=0) U_hi = r_hi + U_hi
  2600. // else U_hi = QQ_1 * U_hi + 1
  2601. //
  2602. (p9) fma.s1 FR_U_lo = FR_r, FR_r_hi, FR_U_lo
  2603. nop.i 999
  2604. }
  2605. { .mfi
  2606. nop.m 999
  2607. //
  2608. // U_hi = r_hi * r_hi
  2609. //
  2610. (p0) fms.s1 FR_r_lo = FR_r, f1, FR_r_hi
  2611. nop.i 999 ;;
  2612. }
  2613. { .mfi
  2614. nop.m 999
  2615. //
  2616. // Load PP_1, PP_6, PP_5, and C_1
  2617. // Load QQ_1, QQ_6, QQ_5, and S_1
  2618. //
  2619. (p0) fma.s1 FR_U_hi = FR_r_hi, FR_r_hi, f0
  2620. nop.i 999 ;;
  2621. }
  2622. { .mfi
  2623. nop.m 999
  2624. (p10) fma.s1 FR_poly = FR_rsq, FR_poly, FR_QQ_5
  2625. nop.i 999
  2626. }
  2627. { .mfi
  2628. nop.m 999
  2629. (p10) fnma.s1 FR_corr = FR_corr, FR_c, f0
  2630. nop.i 999 ;;
  2631. }
  2632. { .mfi
  2633. nop.m 999
  2634. //
  2635. // if (i_1=0) U_lo = r * r_hi + U_lo
  2636. // else U_lo = r_lo * U_lo
  2637. //
  2638. (p9) fma.s1 FR_corr = FR_corr, FR_c, FR_c
  2639. nop.i 999 ;;
  2640. }
  2641. { .mfi
  2642. nop.m 999
  2643. (p9) fma.s1 FR_poly = FR_rsq, FR_poly, FR_PP_5
  2644. nop.i 999
  2645. }
  2646. { .mfi
  2647. nop.m 999
  2648. //
  2649. // if (i_1 =0) U_hi = r + U_hi
  2650. // if (i_1 =0) U_lo = r_lo * U_lo
  2651. //
  2652. //
  2653. (p9) fma.d.s0 FR_PP_5 = FR_PP_5, FR_PP_4, f0
  2654. nop.i 999 ;;
  2655. }
  2656. { .mfi
  2657. nop.m 999
  2658. (p9) fma.s1 FR_U_lo = FR_r, FR_r, FR_U_lo
  2659. nop.i 999
  2660. }
  2661. { .mfi
  2662. nop.m 999
  2663. (p10) fma.s1 FR_U_lo = FR_r_lo, FR_U_lo, f0
  2664. nop.i 999 ;;
  2665. }
  2666. { .mfi
  2667. nop.m 999
  2668. //
  2669. // if (i_1=0) poly = poly * rsq + PP_6
  2670. // else poly = poly * rsq + QQ_6
  2671. //
  2672. (p9) fma.s1 FR_U_hi = FR_r_hi, FR_U_hi, f0
  2673. nop.i 999 ;;
  2674. }
  2675. { .mfi
  2676. nop.m 999
  2677. (p10) fma.s1 FR_poly = FR_rsq, FR_poly, FR_QQ_4
  2678. nop.i 999
  2679. }
  2680. { .mfi
  2681. nop.m 999
  2682. (p10) fma.s1 FR_U_hi = FR_QQ_1, FR_U_hi, f1
  2683. nop.i 999 ;;
  2684. }
  2685. { .mfi
  2686. nop.m 999
  2687. (p10) fma.d.s0 FR_QQ_5 = FR_QQ_5, FR_QQ_5, f0
  2688. nop.i 999 ;;
  2689. }
  2690. { .mfi
  2691. nop.m 999
  2692. //
  2693. // if (i_1!=0) U_hi = PP_1 * U_hi
  2694. // if (i_1!=0) U_lo = r * r + U_lo
  2695. // Load PP_3 or QQ_3
  2696. //
  2697. (p9) fma.s1 FR_poly = FR_rsq, FR_poly, FR_PP_4
  2698. nop.i 999 ;;
  2699. }
  2700. { .mfi
  2701. nop.m 999
  2702. (p9) fma.s1 FR_U_lo = FR_r_lo, FR_U_lo, f0
  2703. nop.i 999
  2704. }
  2705. { .mfi
  2706. nop.m 999
  2707. (p10) fma.s1 FR_U_lo = FR_QQ_1,FR_U_lo, f0
  2708. nop.i 999 ;;
  2709. }
  2710. { .mfi
  2711. nop.m 999
  2712. (p9) fma.s1 FR_U_hi = FR_PP_1, FR_U_hi, f0
  2713. nop.i 999 ;;
  2714. }
  2715. { .mfi
  2716. nop.m 999
  2717. (p10) fma.s1 FR_poly = FR_rsq, FR_poly, FR_QQ_3
  2718. nop.i 999 ;;
  2719. }
  2720. { .mfi
  2721. nop.m 999
  2722. //
  2723. // Load PP_2, QQ_2
  2724. //
  2725. (p9) fma.s1 FR_poly = FR_rsq, FR_poly, FR_PP_3
  2726. nop.i 999 ;;
  2727. }
  2728. { .mfi
  2729. nop.m 999
  2730. //
  2731. // if (i_1==0) poly = FR_rsq * poly + PP_3
  2732. // else poly = FR_rsq * poly + QQ_3
  2733. // Load PP_1_lo
  2734. //
  2735. (p9) fma.s1 FR_U_lo = FR_PP_1, FR_U_lo, f0
  2736. nop.i 999 ;;
  2737. }
  2738. { .mfi
  2739. nop.m 999
  2740. //
  2741. // if (i_1 =0) poly = poly * rsq + pp_r4
  2742. // else poly = poly * rsq + qq_r4
  2743. //
  2744. (p9) fma.s1 FR_U_hi = FR_r, f1, FR_U_hi
  2745. nop.i 999 ;;
  2746. }
  2747. { .mfi
  2748. nop.m 999
  2749. (p10) fma.s1 FR_poly = FR_rsq, FR_poly, FR_QQ_2
  2750. nop.i 999 ;;
  2751. }
  2752. { .mfi
  2753. nop.m 999
  2754. //
  2755. // if (i_1==0) U_lo = PP_1_hi * U_lo
  2756. // else U_lo = QQ_1 * U_lo
  2757. //
  2758. (p9) fma.s1 FR_poly = FR_rsq, FR_poly, FR_PP_2
  2759. nop.i 999 ;;
  2760. }
  2761. { .mfi
  2762. nop.m 999
  2763. //
  2764. // if (i_0==0) Result = 1
  2765. // else Result = -1
  2766. //
  2767. (p0) fma.s1 FR_V = FR_U_lo, f1, FR_corr
  2768. nop.i 999 ;;
  2769. }
  2770. { .mfi
  2771. nop.m 999
  2772. (p10) fma.s1 FR_poly = FR_rsq, FR_poly, f0
  2773. nop.i 999 ;;
  2774. }
  2775. { .mfi
  2776. nop.m 999
  2777. //
  2778. // if (i_1==0) poly = FR_rsq * poly + PP_2
  2779. // else poly = FR_rsq * poly + QQ_2
  2780. //
  2781. (p9) fma.s1 FR_poly = FR_rsq, FR_poly, FR_PP_1_lo
  2782. nop.i 999 ;;
  2783. }
  2784. { .mfi
  2785. nop.m 999
  2786. (p10) fma.s1 FR_poly = FR_rsq, FR_poly, f0
  2787. nop.i 999 ;;
  2788. }
  2789. { .mfi
  2790. nop.m 999
  2791. //
  2792. // V = U_lo + corr
  2793. //
  2794. (p9) fma.s1 FR_poly = FR_r_cubed, FR_poly, f0
  2795. nop.i 999 ;;
  2796. }
  2797. { .mfi
  2798. nop.m 999
  2799. //
  2800. // if (i_1==0) poly = r_cube * poly
  2801. // else poly = FR_rsq * poly
  2802. //
  2803. (p0) fma.s1 FR_V = FR_poly, f1, FR_V
  2804. nop.i 999 ;;
  2805. }
  2806. { .mfi
  2807. nop.m 999
  2808. (p12) fms.d.s0 FR_Input_X = FR_Input_X, FR_U_hi, FR_V
  2809. nop.i 999
  2810. }
  2811. { .mfb
  2812. nop.m 999
  2813. //
  2814. // V = V + poly
  2815. //
  2816. (p11) fma.d.s0 FR_Input_X = FR_Input_X, FR_U_hi, FR_V
  2817. //
  2818. // if (i_0==0) Result = Result * U_hi + V
  2819. // else Result = Result * U_hi - V
  2820. //
  2821. (p0) br.ret.sptk b0 ;;
  2822. }
  2823. //
  2824. // If cosine, FR_Input_X = 1
  2825. // If sine, FR_Input_X = +/-Zero (Input FR_Input_X)
  2826. // Results are exact, no exceptions
  2827. //
  2828. SINCOS_ZERO:
  2829. { .mmb
  2830. (p0) cmp.eq.unc p6, p7 = 0x1, GR_Sin_or_Cos
  2831. nop.m 999
  2832. nop.b 999 ;;
  2833. }
  2834. { .mfi
  2835. nop.m 999
  2836. (p7) fmerge.s FR_Input_X = FR_Input_X, FR_Input_X
  2837. nop.i 999
  2838. }
  2839. { .mfb
  2840. nop.m 999
  2841. (p6) fmerge.s FR_Input_X = f1, f1
  2842. (p0) br.ret.sptk b0 ;;
  2843. }
  2844. SINCOS_SPECIAL:
  2845. //
  2846. // Path for Arg = +/- QNaN, SNaN, Inf
  2847. // Invalid can be raised. SNaNs
  2848. // become QNaNs
  2849. //
  2850. { .mfb
  2851. nop.m 999
  2852. (p0) fmpy.d.s0 FR_Input_X = FR_Input_X, f0
  2853. (p0) br.ret.sptk b0 ;;
  2854. }
  2855. .endp __libm_cos_double_dbx#
  2856. //
  2857. // Call int pi_by_2_reduce(double* x, double *y)
  2858. // for |arguments| >= 2**63
  2859. // Address to save r and c as double
  2860. //
  2861. //
  2862. // psp sp+64
  2863. // sp+48 -> f0 c
  2864. // r45 sp+32 -> f0 r
  2865. // r44 -> sp+16 -> InputX
  2866. // sp sp -> scratch provided to callee
  2867. .proc __libm_callout_2
  2868. __libm_callout_2:
  2869. SINCOS_ARG_TOO_LARGE:
  2870. .prologue
  2871. { .mfi
  2872. add r45=-32,sp // Parameter: r address
  2873. nop.f 0
  2874. .save ar.pfs,GR_SAVE_PFS
  2875. mov GR_SAVE_PFS=ar.pfs // Save ar.pfs
  2876. }
  2877. { .mfi
  2878. .fframe 64
  2879. add sp=-64,sp // Create new stack
  2880. nop.f 0
  2881. mov GR_SAVE_GP=gp // Save gp
  2882. };;
  2883. { .mmi
  2884. stfe [r45] = f0,16 // Clear Parameter r on stack
  2885. add r44 = 16,sp // Parameter x address
  2886. .save b0, GR_SAVE_B0
  2887. mov GR_SAVE_B0=b0 // Save b0
  2888. };;
  2889. .body
  2890. { .mib
  2891. stfe [r45] = f0,-16 // Clear Parameter c on stack
  2892. nop.i 0
  2893. nop.b 0
  2894. }
  2895. { .mib
  2896. stfe [r44] = FR_Input_X // Store Parameter x on stack
  2897. nop.i 0
  2898. (p0) br.call.sptk b0=__libm_pi_by_2_reduce# ;;
  2899. };;
  2900. { .mii
  2901. (p0) ldfe FR_Input_X =[r44],16
  2902. //
  2903. // Get r and c off stack
  2904. //
  2905. (p0) adds GR_Table_Base1 = -16, GR_Table_Base1
  2906. //
  2907. // Get r and c off stack
  2908. //
  2909. (p0) add GR_N_Inc = GR_Sin_or_Cos,r8 ;;
  2910. }
  2911. { .mmb
  2912. (p0) ldfe FR_r =[r45],16
  2913. //
  2914. // Get X off the stack
  2915. // Readjust Table ptr
  2916. //
  2917. (p0) ldfs FR_Two_to_M3 = [GR_Table_Base1],4
  2918. nop.b 999 ;;
  2919. }
  2920. { .mmb
  2921. (p0) ldfs FR_Neg_Two_to_M3 = [GR_Table_Base1],0
  2922. (p0) ldfe FR_c =[r45]
  2923. nop.b 999 ;;
  2924. }
  2925. { .mfi
  2926. .restore
  2927. add sp = 64,sp // Restore stack pointer
  2928. (p0) fcmp.lt.unc.s1 p6, p0 = FR_r, FR_Two_to_M3
  2929. mov b0 = GR_SAVE_B0 // Restore return address
  2930. };;
  2931. { .mib
  2932. mov gp = GR_SAVE_GP // Restore gp
  2933. mov ar.pfs = GR_SAVE_PFS // Restore ar.pfs
  2934. nop.b 0
  2935. };;
  2936. { .mfi
  2937. nop.m 999
  2938. (p6) fcmp.gt.unc.s1 p6, p0 = FR_r, FR_Neg_Two_to_M3
  2939. nop.i 999 ;;
  2940. }
  2941. { .mib
  2942. nop.m 999
  2943. nop.i 999
  2944. (p6) br.cond.spnt SINCOS_SMALL_R ;;
  2945. }
  2946. { .mib
  2947. nop.m 999
  2948. nop.i 999
  2949. (p0) br.cond.sptk SINCOS_NORMAL_R ;;
  2950. }
  2951. .endp __libm_callout_2
  2952. .type __libm_pi_by_2_reduce#,@function
  2953. .global __libm_pi_by_2_reduce#
  2954. .type __libm_sin_double_dbx#,@function
  2955. .global __libm_sin_double_dbx#
  2956. .type __libm_cos_double_dbx#,@function
  2957. .global __libm_cos_double_dbx#