Leaked source code of windows server 2003
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.

1057 lines
31 KiB

  1. .file "sinh.s"
  2. // Copyright (c) 2000, 2001, 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 version
  29. // 4/04/00 Unwind support added
  30. // 8/15/00 Bundle added after call to __libm_error_support to properly
  31. // set [the previously overwritten] GR_Parameter_RESULT.
  32. // 10/12/00 Update to set denormal operand and underflow flags
  33. // 1/22/01 Fixed to set inexact flag for small args.
  34. // 5/02/01 Reworked to improve speed of all paths
  35. //
  36. // API
  37. //==============================================================
  38. // double = sinh(double)
  39. // input floating point f8
  40. // output floating point f8
  41. //
  42. // Registers used
  43. //==============================================================
  44. // general registers:
  45. // r32 -> r47
  46. // predicate registers used:
  47. // p6 -> p11
  48. // floating-point registers used:
  49. // f9 -> f15; f32 -> f90;
  50. // f8 has input, then output
  51. //
  52. // Overview of operation
  53. //==============================================================
  54. // There are seven paths
  55. // 1. 0 < |x| < 0.25 SINH_BY_POLY
  56. // 2. 0.25 <=|x| < 32 SINH_BY_TBL
  57. // 3. 32 <= |x| < 710.47586 SINH_BY_EXP (merged path with SINH_BY_TBL)
  58. // 4. |x| >= 710.47586 SINH_HUGE
  59. // 5. x=0 Done with early exit
  60. // 6. x=inf,nan Done with early exit
  61. // 7. x=denormal SINH_DENORM
  62. //
  63. // For double we get overflow for x >= 4008 b19e 747d cfc3 ed8b
  64. // >= 710.475860073
  65. //
  66. //
  67. // 1. SINH_BY_POLY 0 < |x| < 0.25
  68. // ===============
  69. // Evaluate sinh(x) by a 13th order polynomial
  70. // Care is take for the order of multiplication; and P_1 is not exactly 1/3!,
  71. // P_2 is not exactly 1/5!, etc.
  72. // sinh(x) = sign * (series(e^x) - series(e^-x))/2
  73. // = sign * (ax + ax^3/3! + ax^5/5! + ax^7/7! + ax^9/9! + ax^11/11!
  74. // + ax^13/13!)
  75. // = sign * (ax + ax * ( ax^2 * (1/3! + ax^4 * (1/7! + ax^4*1/11!)) )
  76. // + ax * ( ax^4 * (1/5! + ax^4 * (1/9! + ax^4*1/13!)) ))
  77. // = sign * (ax + ax*p_odd + (ax*p_even))
  78. // = sign * (ax + Y_lo)
  79. // sinh(x) = sign * (Y_hi + Y_lo)
  80. // Note that ax = |x|
  81. //
  82. // 2. SINH_BY_TBL 0.25 <= |x| < 32.0
  83. // =============
  84. // sinh(x) = sinh(B+R)
  85. // = sinh(B)cosh(R) + cosh(B)sinh(R)
  86. //
  87. // ax = |x| = M*log2/64 + R
  88. // B = M*log2/64
  89. // M = 64*N + j
  90. // We will calculate M and get N as (M-j)/64
  91. // The division is a shift.
  92. // exp(B) = exp(N*log2 + j*log2/64)
  93. // = 2^N * 2^(j*log2/64)
  94. // sinh(B) = 1/2(e^B -e^-B)
  95. // = 1/2(2^N * 2^(j*log2/64) - 2^-N * 2^(-j*log2/64))
  96. // sinh(B) = (2^(N-1) * 2^(j*log2/64) - 2^(-N-1) * 2^(-j*log2/64))
  97. // cosh(B) = (2^(N-1) * 2^(j*log2/64) + 2^(-N-1) * 2^(-j*log2/64))
  98. // 2^(j*log2/64) is stored as Tjhi + Tjlo , j= -32,....,32
  99. // Tjhi is double-extended (80-bit) and Tjlo is single(32-bit)
  100. //
  101. // R = ax - M*log2/64
  102. // R = ax - M*log2_by_64_hi - M*log2_by_64_lo
  103. // exp(R) = 1 + R +R^2(1/2! + R(1/3! + R(1/4! + ... + R(1/n!)...)
  104. // = 1 + p_odd + p_even
  105. // where the p_even uses the A coefficients and the p_even uses
  106. // the B coefficients
  107. //
  108. // So sinh(R) = 1 + p_odd + p_even -(1 -p_odd -p_even)/2 = p_odd
  109. // cosh(R) = 1 + p_even
  110. // sinh(B) = S_hi + S_lo
  111. // cosh(B) = C_hi
  112. // sinh(x) = sinh(B)cosh(R) + cosh(B)sinh(R)
  113. //
  114. // 3. SINH_BY_EXP 32.0 <= |x| < 710.47586 ( 4008 b19e 747d cfc3 ed8b )
  115. // ==============
  116. // Can approximate result by exp(x)/2 in this region.
  117. // Y_hi = Tjhi
  118. // Y_lo = Tjhi * (p_odd + p_even) + Tjlo
  119. // sinh(x) = Y_hi + Y_lo
  120. //
  121. // 4. SINH_HUGE |x| >= 710.47586 ( 4008 b19e 747d cfc3 ed8b )
  122. // ============
  123. // Set error tag and call error support
  124. //
  125. //
  126. // Assembly macros
  127. //==============================================================
  128. sinh_GR_ad1 = r34
  129. sinh_GR_Mmj = r34
  130. sinh_GR_jshf = r36
  131. sinh_GR_M = r35
  132. sinh_GR_N = r35
  133. sinh_GR_exp_2tom57 = r36
  134. sinh_GR_j = r36
  135. sinh_GR_joff = r36
  136. sinh_GR_exp_mask = r37
  137. sinh_GR_mJ = r38
  138. sinh_AD_mJ = r38
  139. sinh_GR_signexp_x = r38
  140. sinh_GR_signexp_sgnx_0_5 = r38
  141. sinh_GR_exp_0_25 = r39
  142. sinh_GR_J = r39
  143. sinh_AD_J = r39
  144. sinh_GR_sig_inv_ln2 = r40
  145. sinh_GR_exp_32 = r40
  146. sinh_GR_exp_huge = r40
  147. sinh_GR_all_ones = r40
  148. sinh_GR_ad2e = r41
  149. sinh_GR_ad3 = r42
  150. sinh_GR_ad4 = r43
  151. sinh_GR_rshf = r44
  152. sinh_GR_ad2o = r45
  153. sinh_GR_rshf_2to57 = r46
  154. sinh_GR_exp_denorm = r46
  155. sinh_GR_exp_x = r47
  156. GR_SAVE_PFS = r41
  157. GR_SAVE_B0 = r42
  158. GR_SAVE_GP = r43
  159. GR_Parameter_X = r44
  160. GR_Parameter_Y = r45
  161. GR_Parameter_RESULT = r46
  162. GR_Parameter_TAG = r47
  163. sinh_FR_ABS_X = f9
  164. sinh_FR_X2 = f10
  165. sinh_FR_X4 = f11
  166. sinh_FR_all_ones = f13
  167. sinh_FR_tmp = f14
  168. sinh_FR_RSHF = f15
  169. sinh_FR_Inv_log2by64 = f32
  170. sinh_FR_log2by64_lo = f33
  171. sinh_FR_log2by64_hi = f34
  172. sinh_FR_A1 = f35
  173. sinh_FR_A2 = f36
  174. sinh_FR_A3 = f37
  175. sinh_FR_Rcub = f38
  176. sinh_FR_M_temp = f39
  177. sinh_FR_R_temp = f40
  178. sinh_FR_Rsq = f41
  179. sinh_FR_R = f42
  180. sinh_FR_M = f43
  181. sinh_FR_B1 = f44
  182. sinh_FR_B2 = f45
  183. sinh_FR_B3 = f46
  184. sinh_FR_peven_temp1 = f47
  185. sinh_FR_peven_temp2 = f48
  186. sinh_FR_peven = f49
  187. sinh_FR_podd_temp1 = f50
  188. sinh_FR_podd_temp2 = f51
  189. sinh_FR_podd = f52
  190. sinh_FR_poly65 = f53
  191. sinh_FR_poly6543 = f53
  192. sinh_FR_poly6to1 = f53
  193. sinh_FR_poly43 = f54
  194. sinh_FR_poly21 = f55
  195. sinh_FR_X3 = f56
  196. sinh_FR_INV_LN2_2TO63= f57
  197. sinh_FR_RSHF_2TO57 = f58
  198. sinh_FR_2TOM57 = f59
  199. sinh_FR_smlst_oflow_input = f60
  200. sinh_FR_pre_result = f61
  201. sinh_FR_huge = f62
  202. sinh_FR_spos = f63
  203. sinh_FR_sneg = f64
  204. sinh_FR_Tjhi = f65
  205. sinh_FR_Tjlo = f66
  206. sinh_FR_Tmjhi = f67
  207. sinh_FR_Tmjlo = f68
  208. sinh_FR_S_hi = f69
  209. sinh_FR_SC_hi_temp = f70
  210. sinh_FR_S_lo_temp1 = f71
  211. sinh_FR_S_lo_temp2 = f72
  212. sinh_FR_S_lo_temp3 = f73
  213. sinh_FR_S_lo_temp4 = f73
  214. sinh_FR_S_lo = f74
  215. sinh_FR_C_hi = f75
  216. sinh_FR_C_hi_temp1 = f76
  217. sinh_FR_Y_hi = f77
  218. sinh_FR_Y_lo_temp = f78
  219. sinh_FR_Y_lo = f79
  220. sinh_FR_NORM_X = f80
  221. sinh_FR_P1 = f81
  222. sinh_FR_P2 = f82
  223. sinh_FR_P3 = f83
  224. sinh_FR_P4 = f84
  225. sinh_FR_P5 = f85
  226. sinh_FR_P6 = f86
  227. sinh_FR_Tjhi_spos = f87
  228. sinh_FR_Tjlo_spos = f88
  229. sinh_FR_huge = f89
  230. sinh_FR_signed_hi_lo = f90
  231. // Data tables
  232. //==============================================================
  233. // DO NOT CHANGE ORDER OF THESE TABLES
  234. .data
  235. .align 16
  236. double_sinh_arg_reduction:
  237. // data8 0xB8AA3B295C17F0BC, 0x00004005 // 64/log2 -- signif loaded with setf
  238. data8 0xB17217F7D1000000, 0x00003FF8 // log2/64 high part
  239. data8 0xCF79ABC9E3B39804, 0x00003FD0 // log2/64 low part
  240. double_sinh_p_table:
  241. data8 0xb19e747dcfc3ed8b, 0x00004008 // Smallest x to overflow (710.47586)
  242. data8 0xB08AF9AE78C1239F, 0x00003FDE // P6
  243. data8 0xB8EF1D28926D8891, 0x00003FEC // P4
  244. data8 0x8888888888888412, 0x00003FF8 // P2
  245. data8 0xD732377688025BE9, 0x00003FE5 // P5
  246. data8 0xD00D00D00D4D39F2, 0x00003FF2 // P3
  247. data8 0xAAAAAAAAAAAAAAAB, 0x00003FFC // P1
  248. double_sinh_ab_table:
  249. data8 0xAAAAAAAAAAAAAAAC, 0x00003FFC // A1
  250. data8 0x88888888884ECDD5, 0x00003FF8 // A2
  251. data8 0xD00D0C6DCC26A86B, 0x00003FF2 // A3
  252. data8 0x8000000000000002, 0x00003FFE // B1
  253. data8 0xAAAAAAAAAA402C77, 0x00003FFA // B2
  254. data8 0xB60B6CC96BDB144D, 0x00003FF5 // B3
  255. double_sinh_j_table:
  256. data8 0xB504F333F9DE6484, 0x00003FFE, 0x1EB2FB13, 0x00000000
  257. data8 0xB6FD91E328D17791, 0x00003FFE, 0x1CE2CBE2, 0x00000000
  258. data8 0xB8FBAF4762FB9EE9, 0x00003FFE, 0x1DDC3CBC, 0x00000000
  259. data8 0xBAFF5AB2133E45FB, 0x00003FFE, 0x1EE9AA34, 0x00000000
  260. data8 0xBD08A39F580C36BF, 0x00003FFE, 0x9EAEFDC1, 0x00000000
  261. data8 0xBF1799B67A731083, 0x00003FFE, 0x9DBF517B, 0x00000000
  262. data8 0xC12C4CCA66709456, 0x00003FFE, 0x1EF88AFB, 0x00000000
  263. data8 0xC346CCDA24976407, 0x00003FFE, 0x1E03B216, 0x00000000
  264. data8 0xC5672A115506DADD, 0x00003FFE, 0x1E78AB43, 0x00000000
  265. data8 0xC78D74C8ABB9B15D, 0x00003FFE, 0x9E7B1747, 0x00000000
  266. data8 0xC9B9BD866E2F27A3, 0x00003FFE, 0x9EFE3C0E, 0x00000000
  267. data8 0xCBEC14FEF2727C5D, 0x00003FFE, 0x9D36F837, 0x00000000
  268. data8 0xCE248C151F8480E4, 0x00003FFE, 0x9DEE53E4, 0x00000000
  269. data8 0xD06333DAEF2B2595, 0x00003FFE, 0x9E24AE8E, 0x00000000
  270. data8 0xD2A81D91F12AE45A, 0x00003FFE, 0x1D912473, 0x00000000
  271. data8 0xD4F35AABCFEDFA1F, 0x00003FFE, 0x1EB243BE, 0x00000000
  272. data8 0xD744FCCAD69D6AF4, 0x00003FFE, 0x1E669A2F, 0x00000000
  273. data8 0xD99D15C278AFD7B6, 0x00003FFE, 0x9BBC610A, 0x00000000
  274. data8 0xDBFBB797DAF23755, 0x00003FFE, 0x1E761035, 0x00000000
  275. data8 0xDE60F4825E0E9124, 0x00003FFE, 0x9E0BE175, 0x00000000
  276. data8 0xE0CCDEEC2A94E111, 0x00003FFE, 0x1CCB12A1, 0x00000000
  277. data8 0xE33F8972BE8A5A51, 0x00003FFE, 0x1D1BFE90, 0x00000000
  278. data8 0xE5B906E77C8348A8, 0x00003FFE, 0x1DF2F47A, 0x00000000
  279. data8 0xE8396A503C4BDC68, 0x00003FFE, 0x1EF22F22, 0x00000000
  280. data8 0xEAC0C6E7DD24392F, 0x00003FFE, 0x9E3F4A29, 0x00000000
  281. data8 0xED4F301ED9942B84, 0x00003FFE, 0x1EC01A5B, 0x00000000
  282. data8 0xEFE4B99BDCDAF5CB, 0x00003FFE, 0x1E8CAC3A, 0x00000000
  283. data8 0xF281773C59FFB13A, 0x00003FFE, 0x9DBB3FAB, 0x00000000
  284. data8 0xF5257D152486CC2C, 0x00003FFE, 0x1EF73A19, 0x00000000
  285. data8 0xF7D0DF730AD13BB9, 0x00003FFE, 0x9BB795B5, 0x00000000
  286. data8 0xFA83B2DB722A033A, 0x00003FFE, 0x1EF84B76, 0x00000000
  287. data8 0xFD3E0C0CF486C175, 0x00003FFE, 0x9EF5818B, 0x00000000
  288. data8 0x8000000000000000, 0x00003FFF, 0x00000000, 0x00000000
  289. data8 0x8164D1F3BC030773, 0x00003FFF, 0x1F77CACA, 0x00000000
  290. data8 0x82CD8698AC2BA1D7, 0x00003FFF, 0x1EF8A91D, 0x00000000
  291. data8 0x843A28C3ACDE4046, 0x00003FFF, 0x1E57C976, 0x00000000
  292. data8 0x85AAC367CC487B15, 0x00003FFF, 0x9EE8DA92, 0x00000000
  293. data8 0x871F61969E8D1010, 0x00003FFF, 0x1EE85C9F, 0x00000000
  294. data8 0x88980E8092DA8527, 0x00003FFF, 0x1F3BF1AF, 0x00000000
  295. data8 0x8A14D575496EFD9A, 0x00003FFF, 0x1D80CA1E, 0x00000000
  296. data8 0x8B95C1E3EA8BD6E7, 0x00003FFF, 0x9D0373AF, 0x00000000
  297. data8 0x8D1ADF5B7E5BA9E6, 0x00003FFF, 0x9F167097, 0x00000000
  298. data8 0x8EA4398B45CD53C0, 0x00003FFF, 0x1EB70051, 0x00000000
  299. data8 0x9031DC431466B1DC, 0x00003FFF, 0x1F6EB029, 0x00000000
  300. data8 0x91C3D373AB11C336, 0x00003FFF, 0x1DFD6D8E, 0x00000000
  301. data8 0x935A2B2F13E6E92C, 0x00003FFF, 0x9EB319B0, 0x00000000
  302. data8 0x94F4EFA8FEF70961, 0x00003FFF, 0x1EBA2BEB, 0x00000000
  303. data8 0x96942D3720185A00, 0x00003FFF, 0x1F11D537, 0x00000000
  304. data8 0x9837F0518DB8A96F, 0x00003FFF, 0x1F0D5A46, 0x00000000
  305. data8 0x99E0459320B7FA65, 0x00003FFF, 0x9E5E7BCA, 0x00000000
  306. data8 0x9B8D39B9D54E5539, 0x00003FFF, 0x9F3AAFD1, 0x00000000
  307. data8 0x9D3ED9A72CFFB751, 0x00003FFF, 0x9E86DACC, 0x00000000
  308. data8 0x9EF5326091A111AE, 0x00003FFF, 0x9F3EDDC2, 0x00000000
  309. data8 0xA0B0510FB9714FC2, 0x00003FFF, 0x1E496E3D, 0x00000000
  310. data8 0xA27043030C496819, 0x00003FFF, 0x9F490BF6, 0x00000000
  311. data8 0xA43515AE09E6809E, 0x00003FFF, 0x1DD1DB48, 0x00000000
  312. data8 0xA5FED6A9B15138EA, 0x00003FFF, 0x1E65EBFB, 0x00000000
  313. data8 0xA7CD93B4E965356A, 0x00003FFF, 0x9F427496, 0x00000000
  314. data8 0xA9A15AB4EA7C0EF8, 0x00003FFF, 0x1F283C4A, 0x00000000
  315. data8 0xAB7A39B5A93ED337, 0x00003FFF, 0x1F4B0047, 0x00000000
  316. data8 0xAD583EEA42A14AC6, 0x00003FFF, 0x1F130152, 0x00000000
  317. data8 0xAF3B78AD690A4375, 0x00003FFF, 0x9E8367C0, 0x00000000
  318. data8 0xB123F581D2AC2590, 0x00003FFF, 0x9F705F90, 0x00000000
  319. data8 0xB311C412A9112489, 0x00003FFF, 0x1EFB3C53, 0x00000000
  320. data8 0xB504F333F9DE6484, 0x00003FFF, 0x1F32FB13, 0x00000000
  321. .align 32
  322. .global sinh#
  323. .section .text
  324. .proc sinh#
  325. .align 32
  326. sinh:
  327. { .mlx
  328. alloc r32 = ar.pfs,0,12,4,0
  329. movl sinh_GR_sig_inv_ln2 = 0xb8aa3b295c17f0bc // significand of 1/ln2
  330. }
  331. { .mlx
  332. addl sinh_GR_ad1 = @ltoff(double_sinh_arg_reduction), gp
  333. movl sinh_GR_rshf_2to57 = 0x4778000000000000 // 1.10000 2^(63+57)
  334. }
  335. ;;
  336. { .mfi
  337. ld8 sinh_GR_ad1 = [sinh_GR_ad1]
  338. fmerge.s sinh_FR_ABS_X = f0,f8
  339. mov sinh_GR_exp_0_25 = 0x0fffd // Form exponent for 0.25
  340. }
  341. { .mfi
  342. nop.m 999
  343. fnorm.s1 sinh_FR_NORM_X = f8
  344. mov sinh_GR_exp_2tom57 = 0xffff-57
  345. }
  346. ;;
  347. { .mfi
  348. setf.d sinh_FR_RSHF_2TO57 = sinh_GR_rshf_2to57 // Form const 1.100 * 2^120
  349. fclass.m p10,p0 = f8, 0x0b // Test for denorm
  350. mov sinh_GR_exp_mask = 0x1ffff
  351. }
  352. { .mlx
  353. setf.sig sinh_FR_INV_LN2_2TO63 = sinh_GR_sig_inv_ln2 // Form 1/ln2 * 2^63
  354. movl sinh_GR_rshf = 0x43e8000000000000 // 1.10000 2^63 for right shift
  355. }
  356. ;;
  357. { .mfi
  358. getf.exp sinh_GR_signexp_x = f8 // Extract signexp of x
  359. fclass.m p7,p0 = f8, 0x07 // Test if x=0
  360. nop.i 999
  361. }
  362. { .mfi
  363. setf.exp sinh_FR_2TOM57 = sinh_GR_exp_2tom57 // Form 2^-57 for scaling
  364. nop.f 999
  365. add sinh_GR_ad3 = 0x90, sinh_GR_ad1 // Point to ab_table
  366. }
  367. ;;
  368. { .mfi
  369. setf.d sinh_FR_RSHF = sinh_GR_rshf // Form right shift const 1.100 * 2^63
  370. fclass.m p6,p0 = f8, 0xe3 // Test if x nan, inf
  371. add sinh_GR_ad4 = 0x4f0, sinh_GR_ad1 // Point to j_table midpoint
  372. }
  373. { .mib
  374. add sinh_GR_ad2e = 0x20, sinh_GR_ad1 // Point to p_table
  375. mov sinh_GR_all_ones = -1
  376. (p10) br.cond.spnt SINH_DENORM // Branch if x denorm
  377. }
  378. ;;
  379. // Common path -- return here from SINH_DENORM if x is unnorm
  380. SINH_COMMON:
  381. { .mfi
  382. ldfe sinh_FR_smlst_oflow_input = [sinh_GR_ad2e],16
  383. nop.f 999
  384. nop.i 999
  385. }
  386. { .mib
  387. ldfe sinh_FR_log2by64_hi = [sinh_GR_ad1],16
  388. and sinh_GR_exp_x = sinh_GR_exp_mask, sinh_GR_signexp_x
  389. (p7) br.ret.spnt b0 // Exit if x=0
  390. }
  391. ;;
  392. { .mfi
  393. // Make constant that will generate inexact when squared
  394. setf.sig sinh_FR_all_ones = sinh_GR_all_ones
  395. fcmp.lt.s1 p8,p9 = f8,f0 // Test for x<0
  396. cmp.ge p7,p0 = sinh_GR_exp_x, sinh_GR_exp_0_25 // Test x < 0.25
  397. }
  398. { .mfb
  399. add sinh_GR_ad2o = 0x30, sinh_GR_ad2e // Point to p_table odd coeffs
  400. (p6) fma.d.s0 f8 = f8,f1,f8
  401. (p6) br.ret.spnt b0 // Exit for x nan, inf
  402. }
  403. ;;
  404. // Get the A coefficients for SINH_BY_TBL
  405. // Calculate X2 = ax*ax for SINH_BY_POLY
  406. { .mfi
  407. ldfe sinh_FR_log2by64_lo = [sinh_GR_ad1],16
  408. nop.f 999
  409. nop.i 999
  410. }
  411. { .mfb
  412. ldfe sinh_FR_A1 = [sinh_GR_ad3],16
  413. fma.s1 sinh_FR_X2 = sinh_FR_ABS_X, sinh_FR_ABS_X, f0
  414. (p7) br.cond.sptk SINH_BY_TBL
  415. }
  416. ;;
  417. // Here if 0 < |x| < 0.25
  418. SINH_BY_POLY:
  419. { .mmf
  420. ldfe sinh_FR_P6 = [sinh_GR_ad2e],16
  421. ldfe sinh_FR_P5 = [sinh_GR_ad2o],16
  422. nop.f 999
  423. }
  424. ;;
  425. { .mmi
  426. ldfe sinh_FR_P4 = [sinh_GR_ad2e],16
  427. ldfe sinh_FR_P3 = [sinh_GR_ad2o],16
  428. nop.i 999
  429. }
  430. ;;
  431. { .mmi
  432. ldfe sinh_FR_P2 = [sinh_GR_ad2e],16
  433. ldfe sinh_FR_P1 = [sinh_GR_ad2o],16
  434. nop.i 999
  435. }
  436. ;;
  437. { .mfi
  438. nop.m 999
  439. fma.s1 sinh_FR_X3 = sinh_FR_NORM_X, sinh_FR_X2, f0
  440. nop.i 999
  441. }
  442. { .mfi
  443. nop.m 999
  444. fma.s1 sinh_FR_X4 = sinh_FR_X2, sinh_FR_X2, f0
  445. nop.i 999
  446. }
  447. ;;
  448. { .mfi
  449. nop.m 999
  450. fma.s1 sinh_FR_poly65 = sinh_FR_X2, sinh_FR_P6, sinh_FR_P5
  451. nop.i 999
  452. }
  453. { .mfi
  454. nop.m 999
  455. fma.s1 sinh_FR_poly43 = sinh_FR_X2, sinh_FR_P4, sinh_FR_P3
  456. nop.i 999
  457. }
  458. ;;
  459. { .mfi
  460. nop.m 999
  461. fma.s1 sinh_FR_poly21 = sinh_FR_X2, sinh_FR_P2, sinh_FR_P1
  462. nop.i 999
  463. }
  464. ;;
  465. { .mfi
  466. nop.m 999
  467. fma.s1 sinh_FR_poly6543 = sinh_FR_X4, sinh_FR_poly65, sinh_FR_poly43
  468. nop.i 999
  469. }
  470. ;;
  471. { .mfi
  472. nop.m 999
  473. fma.s1 sinh_FR_poly6to1 = sinh_FR_X4, sinh_FR_poly6543, sinh_FR_poly21
  474. nop.i 999
  475. }
  476. ;;
  477. // Dummy multiply to generate inexact
  478. { .mfi
  479. nop.m 999
  480. fmpy.s0 sinh_FR_tmp = sinh_FR_all_ones, sinh_FR_all_ones
  481. nop.i 999
  482. }
  483. { .mfb
  484. nop.m 999
  485. fma.d.s0 f8 = sinh_FR_poly6to1, sinh_FR_X3, sinh_FR_NORM_X
  486. br.ret.sptk b0 // Exit SINH_BY_POLY
  487. }
  488. ;;
  489. // Here if |x| >= 0.25
  490. SINH_BY_TBL:
  491. // ******************************************************
  492. // STEP 1 (TBL and EXP) - Argument reduction
  493. // ******************************************************
  494. // Get the following constants.
  495. // Inv_log2by64
  496. // log2by64_hi
  497. // log2by64_lo
  498. // We want 2^(N-1) and 2^(-N-1). So bias N-1 and -N-1 and
  499. // put them in an exponent.
  500. // sinh_FR_spos = 2^(N-1) and sinh_FR_sneg = 2^(-N-1)
  501. // 0xffff + (N-1) = 0xffff +N -1
  502. // 0xffff - (N +1) = 0xffff -N -1
  503. // Calculate M and keep it as integer and floating point.
  504. // M = round-to-integer(x*Inv_log2by64)
  505. // sinh_FR_M = M = truncate(ax/(log2/64))
  506. // Put the integer representation of M in sinh_GR_M
  507. // and the floating point representation of M in sinh_FR_M
  508. // Get the remaining A,B coefficients
  509. { .mfi
  510. ldfe sinh_FR_A2 = [sinh_GR_ad3],16
  511. nop.f 999
  512. nop.i 999
  513. }
  514. ;;
  515. { .mmi
  516. ldfe sinh_FR_A3 = [sinh_GR_ad3],16 ;;
  517. ldfe sinh_FR_B1 = [sinh_GR_ad3],16
  518. nop.i 999
  519. }
  520. ;;
  521. .pred.rel "mutex",p8,p9
  522. // Use constant (1.100*2^(63-6)) to get rounded M into rightmost significand
  523. // |x| * 64 * 1/ln2 * 2^(63-6) + 1.1000 * 2^(63+(63-6))
  524. { .mfi
  525. (p8) mov sinh_GR_signexp_sgnx_0_5 = 0x2fffe // signexp of -0.5
  526. fma.s1 sinh_FR_M_temp = sinh_FR_ABS_X, sinh_FR_INV_LN2_2TO63, sinh_FR_RSHF_2TO57
  527. (p9) mov sinh_GR_signexp_sgnx_0_5 = 0x0fffe // signexp of +0.5
  528. }
  529. ;;
  530. // Test for |x| >= overflow limit
  531. { .mfi
  532. nop.m 999
  533. fcmp.ge.s1 p6,p0 = sinh_FR_ABS_X, sinh_FR_smlst_oflow_input
  534. nop.i 999
  535. }
  536. ;;
  537. { .mfi
  538. ldfe sinh_FR_B2 = [sinh_GR_ad3],16
  539. nop.f 999
  540. nop.i 999
  541. }
  542. ;;
  543. // Subtract RSHF constant to get rounded M as a floating point value
  544. // M_temp * 2^(63-6) - 2^63
  545. { .mfb
  546. ldfe sinh_FR_B3 = [sinh_GR_ad3],16
  547. fms.s1 sinh_FR_M = sinh_FR_M_temp, sinh_FR_2TOM57, sinh_FR_RSHF
  548. (p6) br.cond.spnt SINH_HUGE // Branch if result will overflow
  549. }
  550. ;;
  551. { .mfi
  552. getf.sig sinh_GR_M = sinh_FR_M_temp
  553. nop.f 999
  554. nop.i 999
  555. }
  556. ;;
  557. // Calculate j. j is the signed extension of the six lsb of M. It
  558. // has a range of -32 thru 31.
  559. // Calculate R
  560. // ax - M*log2by64_hi
  561. // R = (ax - M*log2by64_hi) - M*log2by64_lo
  562. { .mfi
  563. nop.m 999
  564. fnma.s1 sinh_FR_R_temp = sinh_FR_M, sinh_FR_log2by64_hi, sinh_FR_ABS_X
  565. and sinh_GR_j = 0x3f, sinh_GR_M
  566. }
  567. ;;
  568. { .mii
  569. nop.m 999
  570. shl sinh_GR_jshf = sinh_GR_j, 0x2 ;; // Shift j so can sign extend it
  571. sxt1 sinh_GR_jshf = sinh_GR_jshf
  572. }
  573. ;;
  574. // N = (M-j)/64
  575. { .mii
  576. mov sinh_GR_exp_32 = 0x10004
  577. shr sinh_GR_j = sinh_GR_jshf, 0x2 ;; // Now j has range -32 to 31
  578. sub sinh_GR_Mmj = sinh_GR_M, sinh_GR_j ;; // M-j
  579. }
  580. ;;
  581. // The TBL and EXP branches are merged and predicated
  582. // If TBL, p6 true, 0.25 <= |x| < 32
  583. // If EXP, p7 true, 32 <= |x| < overflow_limit
  584. //
  585. { .mfi
  586. cmp.ge p7,p6 = sinh_GR_exp_x, sinh_GR_exp_32 // Test if x >= 32
  587. fnma.s1 sinh_FR_R = sinh_FR_M, sinh_FR_log2by64_lo, sinh_FR_R_temp
  588. shr sinh_GR_N = sinh_GR_Mmj, 0x6 // N = (M-j)/64
  589. }
  590. ;;
  591. { .mmi
  592. sub r40 = sinh_GR_signexp_sgnx_0_5, sinh_GR_N // signexp of sgnx*2^(-N-1)
  593. add r39 = sinh_GR_signexp_sgnx_0_5, sinh_GR_N // signexp of sgnx*2^(N-1)
  594. shl sinh_GR_joff = sinh_GR_j,5 // Make j offset to j_table
  595. }
  596. ;;
  597. { .mfi
  598. setf.exp sinh_FR_spos = r39 // Form sgnx * 2^(N-1)
  599. nop.f 999
  600. sub sinh_GR_mJ = r0, sinh_GR_joff // Table offset for -j
  601. }
  602. { .mfi
  603. setf.exp sinh_FR_sneg = r40 // Form sgnx * 2^(-N-1)
  604. nop.f 999
  605. add sinh_GR_J = r0, sinh_GR_joff // Table offset for +j
  606. }
  607. ;;
  608. // Get the address of the J table midpoint, add the offset
  609. { .mmf
  610. add sinh_AD_mJ = sinh_GR_ad4, sinh_GR_mJ
  611. add sinh_AD_J = sinh_GR_ad4, sinh_GR_J
  612. nop.f 999
  613. }
  614. ;;
  615. { .mmf
  616. ldfe sinh_FR_Tmjhi = [sinh_AD_mJ],16
  617. ldfe sinh_FR_Tjhi = [sinh_AD_J],16
  618. nop.f 999
  619. }
  620. ;;
  621. // ******************************************************
  622. // STEP 2 (TBL and EXP)
  623. // ******************************************************
  624. // Calculate Rsquared and Rcubed in preparation for p_even and p_odd
  625. { .mmf
  626. ldfs sinh_FR_Tmjlo = [sinh_AD_mJ],16
  627. ldfs sinh_FR_Tjlo = [sinh_AD_J],16
  628. fma.s1 sinh_FR_Rsq = sinh_FR_R, sinh_FR_R, f0
  629. }
  630. ;;
  631. // Calculate p_even
  632. // B_2 + Rsq *B_3
  633. // B_1 + Rsq * (B_2 + Rsq *B_3)
  634. // p_even = Rsq * (B_1 + Rsq * (B_2 + Rsq *B_3))
  635. { .mfi
  636. nop.m 999
  637. fma.s1 sinh_FR_peven_temp1 = sinh_FR_Rsq, sinh_FR_B3, sinh_FR_B2
  638. nop.i 999
  639. }
  640. // Calculate p_odd
  641. // A_2 + Rsq *A_3
  642. // A_1 + Rsq * (A_2 + Rsq *A_3)
  643. // podd = R + Rcub * (A_1 + Rsq * (A_2 + Rsq *A_3))
  644. { .mfi
  645. nop.m 999
  646. fma.s1 sinh_FR_podd_temp1 = sinh_FR_Rsq, sinh_FR_A3, sinh_FR_A2
  647. nop.i 999
  648. }
  649. ;;
  650. { .mfi
  651. nop.m 999
  652. fma.s1 sinh_FR_Rcub = sinh_FR_Rsq, sinh_FR_R, f0
  653. nop.i 999
  654. }
  655. ;;
  656. //
  657. // If TBL,
  658. // Calculate S_hi and S_lo, and C_hi
  659. // SC_hi_temp = sneg * Tmjhi
  660. // S_hi = spos * Tjhi - SC_hi_temp
  661. // S_hi = spos * Tjhi - (sneg * Tmjhi)
  662. // C_hi = spos * Tjhi + SC_hi_temp
  663. // C_hi = spos * Tjhi + (sneg * Tmjhi)
  664. { .mfi
  665. nop.m 999
  666. (p6) fma.s1 sinh_FR_SC_hi_temp = sinh_FR_sneg, sinh_FR_Tmjhi, f0
  667. nop.i 999
  668. }
  669. ;;
  670. // If TBL,
  671. // S_lo_temp3 = sneg * Tmjlo
  672. // S_lo_temp4 = spos * Tjlo - S_lo_temp3
  673. // S_lo_temp4 = spos * Tjlo -(sneg * Tmjlo)
  674. { .mfi
  675. nop.m 999
  676. (p6) fma.s1 sinh_FR_S_lo_temp3 = sinh_FR_sneg, sinh_FR_Tmjlo, f0
  677. nop.i 999
  678. }
  679. ;;
  680. { .mfi
  681. nop.m 999
  682. fma.s1 sinh_FR_peven_temp2 = sinh_FR_Rsq, sinh_FR_peven_temp1, sinh_FR_B1
  683. nop.i 999
  684. }
  685. { .mfi
  686. nop.m 999
  687. fma.s1 sinh_FR_podd_temp2 = sinh_FR_Rsq, sinh_FR_podd_temp1, sinh_FR_A1
  688. nop.i 999
  689. }
  690. ;;
  691. // If EXP,
  692. // Compute sgnx * 2^(N-1) * Tjhi and sgnx * 2^(N-1) * Tjlo
  693. { .mfi
  694. nop.m 999
  695. (p7) fma.s1 sinh_FR_Tjhi_spos = sinh_FR_Tjhi, sinh_FR_spos, f0
  696. nop.i 999
  697. }
  698. { .mfi
  699. nop.m 999
  700. (p7) fma.s1 sinh_FR_Tjlo_spos = sinh_FR_Tjlo, sinh_FR_spos, f0
  701. nop.i 999
  702. }
  703. ;;
  704. { .mfi
  705. nop.m 999
  706. (p6) fms.s1 sinh_FR_S_hi = sinh_FR_spos, sinh_FR_Tjhi, sinh_FR_SC_hi_temp
  707. nop.i 999
  708. }
  709. ;;
  710. { .mfi
  711. nop.m 999
  712. (p6) fma.s1 sinh_FR_C_hi = sinh_FR_spos, sinh_FR_Tjhi, sinh_FR_SC_hi_temp
  713. nop.i 999
  714. }
  715. { .mfi
  716. nop.m 999
  717. (p6) fms.s1 sinh_FR_S_lo_temp4 = sinh_FR_spos, sinh_FR_Tjlo, sinh_FR_S_lo_temp3
  718. nop.i 999
  719. }
  720. ;;
  721. { .mfi
  722. nop.m 999
  723. fma.s1 sinh_FR_peven = sinh_FR_Rsq, sinh_FR_peven_temp2, f0
  724. nop.i 999
  725. }
  726. { .mfi
  727. nop.m 999
  728. fma.s1 sinh_FR_podd = sinh_FR_podd_temp2, sinh_FR_Rcub, sinh_FR_R
  729. nop.i 999
  730. }
  731. ;;
  732. // If TBL,
  733. // S_lo_temp1 = spos * Tjhi - S_hi
  734. // S_lo_temp2 = -sneg * Tmjlo + S_lo_temp1
  735. // S_lo_temp2 = -sneg * Tmjlo + (spos * Tjhi - S_hi)
  736. { .mfi
  737. nop.m 999
  738. (p6) fms.s1 sinh_FR_S_lo_temp1 = sinh_FR_spos, sinh_FR_Tjhi, sinh_FR_S_hi
  739. nop.i 999
  740. }
  741. ;;
  742. { .mfi
  743. nop.m 999
  744. (p6) fnma.s1 sinh_FR_S_lo_temp2 = sinh_FR_sneg, sinh_FR_Tmjhi, sinh_FR_S_lo_temp1
  745. nop.i 999
  746. }
  747. ;;
  748. // If EXP,
  749. // Y_hi = sgnx * 2^(N-1) * Tjhi
  750. // Y_lo = sgnx * 2^(N-1) * Tjhi * (p_odd + p_even) + sgnx * 2^(N-1) * Tjlo
  751. { .mfi
  752. nop.m 999
  753. (p7) fma.s1 sinh_FR_Y_lo_temp = sinh_FR_peven, f1, sinh_FR_podd
  754. nop.i 999
  755. }
  756. ;;
  757. // If TBL,
  758. // S_lo = S_lo_temp4 + S_lo_temp2
  759. { .mfi
  760. nop.m 999
  761. (p6) fma.s1 sinh_FR_S_lo = sinh_FR_S_lo_temp4, f1, sinh_FR_S_lo_temp2
  762. nop.i 999
  763. }
  764. ;;
  765. // If TBL,
  766. // Y_hi = S_hi
  767. // Y_lo = C_hi*p_odd + (S_hi*p_even + S_lo)
  768. { .mfi
  769. nop.m 999
  770. (p6) fma.s1 sinh_FR_Y_lo_temp = sinh_FR_S_hi, sinh_FR_peven, sinh_FR_S_lo
  771. nop.i 999
  772. }
  773. ;;
  774. { .mfi
  775. nop.m 999
  776. (p7) fma.s1 sinh_FR_Y_lo = sinh_FR_Tjhi_spos, sinh_FR_Y_lo_temp, sinh_FR_Tjlo_spos
  777. nop.i 999
  778. }
  779. ;;
  780. // Dummy multiply to generate inexact
  781. { .mfi
  782. nop.m 999
  783. fmpy.s0 sinh_FR_tmp = sinh_FR_all_ones, sinh_FR_all_ones
  784. nop.i 999
  785. }
  786. { .mfi
  787. nop.m 999
  788. (p6) fma.s1 sinh_FR_Y_lo = sinh_FR_C_hi, sinh_FR_podd, sinh_FR_Y_lo_temp
  789. nop.i 999
  790. }
  791. ;;
  792. // f8 = answer = Y_hi + Y_lo
  793. { .mfi
  794. nop.m 999
  795. (p7) fma.d.s0 f8 = sinh_FR_Y_lo, f1, sinh_FR_Tjhi_spos
  796. nop.i 999
  797. }
  798. ;;
  799. // f8 = answer = Y_hi + Y_lo
  800. { .mfb
  801. nop.m 999
  802. (p6) fma.d.s0 f8 = sinh_FR_Y_lo, f1, sinh_FR_S_hi
  803. br.ret.sptk b0 // Exit for SINH_BY_TBL and SINH_BY_EXP
  804. }
  805. ;;
  806. // Here if x denorm or unorm
  807. SINH_DENORM:
  808. // Determine if x really a denorm and not a unorm
  809. { .mmf
  810. getf.exp sinh_GR_signexp_x = sinh_FR_NORM_X
  811. mov sinh_GR_exp_denorm = 0x0fc01 // Real denorms will have exp < this
  812. fmerge.s sinh_FR_ABS_X = f0, sinh_FR_NORM_X
  813. }
  814. ;;
  815. { .mfi
  816. nop.m 999
  817. fcmp.eq.s0 p10,p0 = f8, f0 // Set denorm flag
  818. nop.i 999
  819. }
  820. ;;
  821. // Set p8 if really a denorm
  822. { .mmi
  823. and sinh_GR_exp_x = sinh_GR_exp_mask, sinh_GR_signexp_x ;;
  824. cmp.lt p8,p9 = sinh_GR_exp_x, sinh_GR_exp_denorm
  825. nop.i 999
  826. }
  827. ;;
  828. // Identify denormal operands.
  829. { .mfb
  830. nop.m 999
  831. (p8) fcmp.ge.unc.s1 p6,p7 = f8, f0 // Test sign of denorm
  832. (p9) br.cond.sptk SINH_COMMON // Return to main path if x unorm
  833. }
  834. ;;
  835. { .mfi
  836. nop.m 999
  837. (p6) fma.d.s0 f8 = f8,f8,f8 // If x +denorm, result=x+x^2
  838. nop.i 999
  839. }
  840. { .mfb
  841. nop.m 999
  842. (p7) fnma.d.s0 f8 = f8,f8,f8 // If x -denorm, result=x-x^2
  843. br.ret.sptk b0 // Exit if x denorm
  844. }
  845. ;;
  846. // Here if |x| >= overflow limit
  847. SINH_HUGE:
  848. // for SINH_HUGE, put 24000 in exponent; take sign from input
  849. { .mmi
  850. mov sinh_GR_exp_huge = 0x15dbf ;;
  851. setf.exp sinh_FR_huge = sinh_GR_exp_huge
  852. nop.i 999
  853. }
  854. ;;
  855. .pred.rel "mutex",p8,p9
  856. { .mfi
  857. nop.m 999
  858. (p8) fnma.s1 sinh_FR_signed_hi_lo = sinh_FR_huge, f1, f1
  859. nop.i 999
  860. }
  861. { .mfi
  862. nop.m 999
  863. (p9) fma.s1 sinh_FR_signed_hi_lo = sinh_FR_huge, f1, f1
  864. nop.i 999
  865. }
  866. ;;
  867. { .mfi
  868. nop.m 999
  869. fma.d.s0 sinh_FR_pre_result = sinh_FR_signed_hi_lo, sinh_FR_huge, f0
  870. mov GR_Parameter_TAG = 127
  871. }
  872. ;;
  873. .endp sinh
  874. // Stack operations when calling error support.
  875. // (1) (2) (3) (call) (4)
  876. // sp -> + psp -> + psp -> + sp -> +
  877. // | | | |
  878. // | | <- GR_Y R3 ->| <- GR_RESULT | -> f8
  879. // | | | |
  880. // | <-GR_Y Y2->| Y2 ->| <- GR_Y |
  881. // | | | |
  882. // | | <- GR_X X1 ->| |
  883. // | | | |
  884. // sp-64 -> + sp -> + sp -> + +
  885. // save ar.pfs save b0 restore gp
  886. // save gp restore ar.pfs
  887. .proc __libm_error_region
  888. __libm_error_region:
  889. SINH_ERROR_SUPPORT:
  890. .prologue
  891. // (1)
  892. { .mfi
  893. add GR_Parameter_Y=-32,sp // Parameter 2 value
  894. nop.f 0
  895. .save ar.pfs,GR_SAVE_PFS
  896. mov GR_SAVE_PFS=ar.pfs // Save ar.pfs
  897. }
  898. { .mfi
  899. .fframe 64
  900. add sp=-64,sp // Create new stack
  901. nop.f 0
  902. mov GR_SAVE_GP=gp // Save gp
  903. };;
  904. // (2)
  905. { .mmi
  906. stfd [GR_Parameter_Y] = f0,16 // STORE Parameter 2 on stack
  907. add GR_Parameter_X = 16,sp // Parameter 1 address
  908. .save b0, GR_SAVE_B0
  909. mov GR_SAVE_B0=b0 // Save b0
  910. };;
  911. .body
  912. // (3)
  913. { .mib
  914. stfd [GR_Parameter_X] = f8 // STORE Parameter 1 on stack
  915. add GR_Parameter_RESULT = 0,GR_Parameter_Y // Parameter 3 address
  916. nop.b 0
  917. }
  918. { .mib
  919. stfd [GR_Parameter_Y] = sinh_FR_pre_result // STORE Parameter 3 on stack
  920. add GR_Parameter_Y = -16,GR_Parameter_Y
  921. br.call.sptk b0=__libm_error_support# // Call error handling function
  922. };;
  923. { .mmi
  924. nop.m 0
  925. nop.m 0
  926. add GR_Parameter_RESULT = 48,sp
  927. };;
  928. // (4)
  929. { .mmi
  930. ldfd f8 = [GR_Parameter_RESULT] // Get return result off stack
  931. .restore
  932. add sp = 64,sp // Restore stack pointer
  933. mov b0 = GR_SAVE_B0 // Restore return address
  934. };;
  935. { .mib
  936. mov gp = GR_SAVE_GP // Restore gp
  937. mov ar.pfs = GR_SAVE_PFS // Restore ar.pfs
  938. br.ret.sptk b0 // Return
  939. };;
  940. .endp __libm_error_region
  941. .type __libm_error_support#,@function
  942. .global __libm_error_support#