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.

921 lines
30 KiB

  1. .file "logf.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. // 3/01/00 Initial version
  29. // 8/15/00 Bundle added after call to __libm_error_support to properly
  30. // set [the previously overwritten] GR_Parameter_RESULT.
  31. // 1/10/01 Improved speed, fixed flags for neg denormals
  32. //
  33. //
  34. // API
  35. //==============================================================
  36. // float logf(float)
  37. // float log10f(float)
  38. //
  39. // Overview of operation
  40. //==============================================================
  41. // Background
  42. //
  43. // Consider x = 2^N 1.f1 f2 f3 f4...f63
  44. // Log(x) = log(frcpa(x) x/frcpa(x))
  45. // = log(1/frcpa(x)) + log(frcpa(x) x)
  46. // = -log(frcpa(x)) + log(frcpa(x) x)
  47. //
  48. // frcpa(x) = 2^-N frcpa((1.f1 f2 ... f63)
  49. //
  50. // -log(frcpa(x)) = -log(C)
  51. // = -log(2^-N) - log(frcpa(1.f1 f2 ... f63))
  52. //
  53. // -log(frcpa(x)) = -log(C)
  54. // = +Nlog2 - log(frcpa(1.f1 f2 ... f63))
  55. //
  56. // -log(frcpa(x)) = -log(C)
  57. // = +Nlog2 + log(frcpa(1.f1 f2 ... f63))
  58. //
  59. // Log(x) = log(1/frcpa(x)) + log(frcpa(x) x)
  60. // Log(x) = +Nlog2 + log(1./frcpa(1.f1 f2 ... f63)) + log(frcpa(x) x)
  61. // Log(x) = +Nlog2 - log(/frcpa(1.f1 f2 ... f63)) + log(frcpa(x) x)
  62. // Log(x) = +Nlog2 + T + log(frcpa(x) x)
  63. //
  64. // Log(x) = +Nlog2 + T + log(C x)
  65. //
  66. // Cx = 1 + r
  67. //
  68. // Log(x) = +Nlog2 + T + log(1+r)
  69. // Log(x) = +Nlog2 + T + Series( r - r^2/2 + r^3/3 - r^4/4 ....)
  70. //
  71. // 1.f1 f2 ... f8 has 256 entries.
  72. // They are 1 + k/2^8, k = 0 ... 255
  73. // These 256 values are the table entries.
  74. //
  75. // Implementation
  76. //===============
  77. // CASE 1: |x-1| >= 2^-8
  78. // C = frcpa(x)
  79. // r = C * x - 1
  80. //
  81. // Form rseries = r + P1*r^2 + P2*r^3 + P3*r^4
  82. //
  83. // x = f * 2*n where f is 1.f_1f_2f_3....f_63
  84. // Nfloat = float(n) where n is the true unbiased exponent
  85. // pre-index = f_1f_2....f_8
  86. // index = pre_index * 16
  87. // get the dxt table entry at index + offset = T
  88. //
  89. // result = (T + Nfloat * log(2)) + rseries
  90. //
  91. // The T table is calculated as follows
  92. // Form x_k = 1 + k/2^8 where k goes from 0... 255
  93. // y_k = frcpa(x_k)
  94. // log(1/y_k) in quad and round to double
  95. // CASE 2: |x-1| < 2^-6
  96. // w = x - 1
  97. //
  98. // Form wseries = w + Q1*w^2 + Q2*w^3 + Q3*w^4
  99. //
  100. // result = wseries
  101. // Special values
  102. //==============================================================
  103. // log(+0) = -inf
  104. // log(-0) = -inf
  105. // log(+qnan) = +qnan
  106. // log(-qnan) = -qnan
  107. // log(+snan) = +qnan
  108. // log(-snan) = -qnan
  109. // log(-n) = QNAN Indefinite
  110. // log(-inf) = QNAN Indefinite
  111. // log(+inf) = +inf
  112. // Registers used
  113. //==============================================================
  114. // Floating Point registers used:
  115. // f8, input
  116. // f9 -> f15, f32 -> f47
  117. // General registers used:
  118. // r32 -> r51
  119. // Predicate registers used:
  120. // p6 -> p15
  121. // p8 log base e
  122. // p6 log base e special
  123. // p9 used in the frcpa
  124. // p13 log base e large W
  125. // p14 log base e small w
  126. // p7 log base 10
  127. // p10 log base 10 large W
  128. // p11 log base 10 small w
  129. // p12 log base 10 special
  130. // Assembly macros
  131. //==============================================================
  132. log_int_Nfloat = f9
  133. log_Nfloat = f10
  134. log_P3 = f11
  135. log_P2 = f12
  136. log_P1 = f13
  137. log_inv_ln10 = f14
  138. log_log2 = f15
  139. log_w = f32
  140. log_T = f33
  141. log_rp_p32 = f34
  142. log_rp_p2 = f35
  143. log_rp_p10 = f36
  144. log_rsq = f37
  145. log_T_plus_Nlog2 = f38
  146. log_r = f39
  147. log_C = f40
  148. log_rp_q32 = f41
  149. log_rp_q2 = f42
  150. log_rp_q10 = f43
  151. log_wsq = f44
  152. log_Q = f45
  153. log_inv_ln10 = f46
  154. log_NORM_f8 = f47
  155. // ===================================
  156. log_GR_exp_17_ones = r33
  157. log_GR_exp_16_ones = r34
  158. log_GR_exp_f8 = r35
  159. log_GR_signexp_f8 = r36
  160. log_GR_true_exp_f8 = r37
  161. log_GR_significand_f8 = r38
  162. log_GR_index = r39
  163. log_AD_1 = r40
  164. log_GR_signexp_w = r41
  165. log_GR_fff7 = r42
  166. log_AD_2 = r43
  167. log_GR_exp_w = r44
  168. GR_SAVE_B0 = r45
  169. GR_SAVE_GP = r46
  170. GR_SAVE_PFS = r47
  171. GR_Parameter_X = r48
  172. GR_Parameter_Y = r49
  173. GR_Parameter_RESULT = r50
  174. log_GR_tag = r51
  175. // Data tables
  176. //==============================================================
  177. .data
  178. .align 16
  179. log_table_1:
  180. data8 0xbfd0001008f39d59 // p3
  181. data8 0x3fd5556073e0c45a // p2
  182. log_table_2:
  183. data8 0xbfdffffffffaea15 // p1
  184. data8 0x3fdbcb7b1526e50e // 1/ln10
  185. data8 0x3fe62e42fefa39ef // Log(2)
  186. data8 0x0 // pad
  187. data8 0x3F60040155D5889E //log(1/frcpa(1+ 0/256)
  188. data8 0x3F78121214586B54 //log(1/frcpa(1+ 1/256)
  189. data8 0x3F841929F96832F0 //log(1/frcpa(1+ 2/256)
  190. data8 0x3F8C317384C75F06 //log(1/frcpa(1+ 3/256)
  191. data8 0x3F91A6B91AC73386 //log(1/frcpa(1+ 4/256)
  192. data8 0x3F95BA9A5D9AC039 //log(1/frcpa(1+ 5/256)
  193. data8 0x3F99D2A8074325F4 //log(1/frcpa(1+ 6/256)
  194. data8 0x3F9D6B2725979802 //log(1/frcpa(1+ 7/256)
  195. data8 0x3FA0C58FA19DFAAA //log(1/frcpa(1+ 8/256)
  196. data8 0x3FA2954C78CBCE1B //log(1/frcpa(1+ 9/256)
  197. data8 0x3FA4A94D2DA96C56 //log(1/frcpa(1+ 10/256)
  198. data8 0x3FA67C94F2D4BB58 //log(1/frcpa(1+ 11/256)
  199. data8 0x3FA85188B630F068 //log(1/frcpa(1+ 12/256)
  200. data8 0x3FAA6B8ABE73AF4C //log(1/frcpa(1+ 13/256)
  201. data8 0x3FAC441E06F72A9E //log(1/frcpa(1+ 14/256)
  202. data8 0x3FAE1E6713606D07 //log(1/frcpa(1+ 15/256)
  203. data8 0x3FAFFA6911AB9301 //log(1/frcpa(1+ 16/256)
  204. data8 0x3FB0EC139C5DA601 //log(1/frcpa(1+ 17/256)
  205. data8 0x3FB1DBD2643D190B //log(1/frcpa(1+ 18/256)
  206. data8 0x3FB2CC7284FE5F1C //log(1/frcpa(1+ 19/256)
  207. data8 0x3FB3BDF5A7D1EE64 //log(1/frcpa(1+ 20/256)
  208. data8 0x3FB4B05D7AA012E0 //log(1/frcpa(1+ 21/256)
  209. data8 0x3FB580DB7CEB5702 //log(1/frcpa(1+ 22/256)
  210. data8 0x3FB674F089365A7A //log(1/frcpa(1+ 23/256)
  211. data8 0x3FB769EF2C6B568D //log(1/frcpa(1+ 24/256)
  212. data8 0x3FB85FD927506A48 //log(1/frcpa(1+ 25/256)
  213. data8 0x3FB9335E5D594989 //log(1/frcpa(1+ 26/256)
  214. data8 0x3FBA2B0220C8E5F5 //log(1/frcpa(1+ 27/256)
  215. data8 0x3FBB0004AC1A86AC //log(1/frcpa(1+ 28/256)
  216. data8 0x3FBBF968769FCA11 //log(1/frcpa(1+ 29/256)
  217. data8 0x3FBCCFEDBFEE13A8 //log(1/frcpa(1+ 30/256)
  218. data8 0x3FBDA727638446A2 //log(1/frcpa(1+ 31/256)
  219. data8 0x3FBEA3257FE10F7A //log(1/frcpa(1+ 32/256)
  220. data8 0x3FBF7BE9FEDBFDE6 //log(1/frcpa(1+ 33/256)
  221. data8 0x3FC02AB352FF25F4 //log(1/frcpa(1+ 34/256)
  222. data8 0x3FC097CE579D204D //log(1/frcpa(1+ 35/256)
  223. data8 0x3FC1178E8227E47C //log(1/frcpa(1+ 36/256)
  224. data8 0x3FC185747DBECF34 //log(1/frcpa(1+ 37/256)
  225. data8 0x3FC1F3B925F25D41 //log(1/frcpa(1+ 38/256)
  226. data8 0x3FC2625D1E6DDF57 //log(1/frcpa(1+ 39/256)
  227. data8 0x3FC2D1610C86813A //log(1/frcpa(1+ 40/256)
  228. data8 0x3FC340C59741142E //log(1/frcpa(1+ 41/256)
  229. data8 0x3FC3B08B6757F2A9 //log(1/frcpa(1+ 42/256)
  230. data8 0x3FC40DFB08378003 //log(1/frcpa(1+ 43/256)
  231. data8 0x3FC47E74E8CA5F7C //log(1/frcpa(1+ 44/256)
  232. data8 0x3FC4EF51F6466DE4 //log(1/frcpa(1+ 45/256)
  233. data8 0x3FC56092E02BA516 //log(1/frcpa(1+ 46/256)
  234. data8 0x3FC5D23857CD74D5 //log(1/frcpa(1+ 47/256)
  235. data8 0x3FC6313A37335D76 //log(1/frcpa(1+ 48/256)
  236. data8 0x3FC6A399DABBD383 //log(1/frcpa(1+ 49/256)
  237. data8 0x3FC70337DD3CE41B //log(1/frcpa(1+ 50/256)
  238. data8 0x3FC77654128F6127 //log(1/frcpa(1+ 51/256)
  239. data8 0x3FC7E9D82A0B022D //log(1/frcpa(1+ 52/256)
  240. data8 0x3FC84A6B759F512F //log(1/frcpa(1+ 53/256)
  241. data8 0x3FC8AB47D5F5A310 //log(1/frcpa(1+ 54/256)
  242. data8 0x3FC91FE49096581B //log(1/frcpa(1+ 55/256)
  243. data8 0x3FC981634011AA75 //log(1/frcpa(1+ 56/256)
  244. data8 0x3FC9F6C407089664 //log(1/frcpa(1+ 57/256)
  245. data8 0x3FCA58E729348F43 //log(1/frcpa(1+ 58/256)
  246. data8 0x3FCABB55C31693AD //log(1/frcpa(1+ 59/256)
  247. data8 0x3FCB1E104919EFD0 //log(1/frcpa(1+ 60/256)
  248. data8 0x3FCB94EE93E367CB //log(1/frcpa(1+ 61/256)
  249. data8 0x3FCBF851C067555F //log(1/frcpa(1+ 62/256)
  250. data8 0x3FCC5C0254BF23A6 //log(1/frcpa(1+ 63/256)
  251. data8 0x3FCCC000C9DB3C52 //log(1/frcpa(1+ 64/256)
  252. data8 0x3FCD244D99C85674 //log(1/frcpa(1+ 65/256)
  253. data8 0x3FCD88E93FB2F450 //log(1/frcpa(1+ 66/256)
  254. data8 0x3FCDEDD437EAEF01 //log(1/frcpa(1+ 67/256)
  255. data8 0x3FCE530EFFE71012 //log(1/frcpa(1+ 68/256)
  256. data8 0x3FCEB89A1648B971 //log(1/frcpa(1+ 69/256)
  257. data8 0x3FCF1E75FADF9BDE //log(1/frcpa(1+ 70/256)
  258. data8 0x3FCF84A32EAD7C35 //log(1/frcpa(1+ 71/256)
  259. data8 0x3FCFEB2233EA07CD //log(1/frcpa(1+ 72/256)
  260. data8 0x3FD028F9C7035C1C //log(1/frcpa(1+ 73/256)
  261. data8 0x3FD05C8BE0D9635A //log(1/frcpa(1+ 74/256)
  262. data8 0x3FD085EB8F8AE797 //log(1/frcpa(1+ 75/256)
  263. data8 0x3FD0B9C8E32D1911 //log(1/frcpa(1+ 76/256)
  264. data8 0x3FD0EDD060B78081 //log(1/frcpa(1+ 77/256)
  265. data8 0x3FD122024CF0063F //log(1/frcpa(1+ 78/256)
  266. data8 0x3FD14BE2927AECD4 //log(1/frcpa(1+ 79/256)
  267. data8 0x3FD180618EF18ADF //log(1/frcpa(1+ 80/256)
  268. data8 0x3FD1B50BBE2FC63B //log(1/frcpa(1+ 81/256)
  269. data8 0x3FD1DF4CC7CF242D //log(1/frcpa(1+ 82/256)
  270. data8 0x3FD214456D0EB8D4 //log(1/frcpa(1+ 83/256)
  271. data8 0x3FD23EC5991EBA49 //log(1/frcpa(1+ 84/256)
  272. data8 0x3FD2740D9F870AFB //log(1/frcpa(1+ 85/256)
  273. data8 0x3FD29ECDABCDFA04 //log(1/frcpa(1+ 86/256)
  274. data8 0x3FD2D46602ADCCEE //log(1/frcpa(1+ 87/256)
  275. data8 0x3FD2FF66B04EA9D4 //log(1/frcpa(1+ 88/256)
  276. data8 0x3FD335504B355A37 //log(1/frcpa(1+ 89/256)
  277. data8 0x3FD360925EC44F5D //log(1/frcpa(1+ 90/256)
  278. data8 0x3FD38BF1C3337E75 //log(1/frcpa(1+ 91/256)
  279. data8 0x3FD3C25277333184 //log(1/frcpa(1+ 92/256)
  280. data8 0x3FD3EDF463C1683E //log(1/frcpa(1+ 93/256)
  281. data8 0x3FD419B423D5E8C7 //log(1/frcpa(1+ 94/256)
  282. data8 0x3FD44591E0539F49 //log(1/frcpa(1+ 95/256)
  283. data8 0x3FD47C9175B6F0AD //log(1/frcpa(1+ 96/256)
  284. data8 0x3FD4A8B341552B09 //log(1/frcpa(1+ 97/256)
  285. data8 0x3FD4D4F3908901A0 //log(1/frcpa(1+ 98/256)
  286. data8 0x3FD501528DA1F968 //log(1/frcpa(1+ 99/256)
  287. data8 0x3FD52DD06347D4F6 //log(1/frcpa(1+ 100/256)
  288. data8 0x3FD55A6D3C7B8A8A //log(1/frcpa(1+ 101/256)
  289. data8 0x3FD5925D2B112A59 //log(1/frcpa(1+ 102/256)
  290. data8 0x3FD5BF406B543DB2 //log(1/frcpa(1+ 103/256)
  291. data8 0x3FD5EC433D5C35AE //log(1/frcpa(1+ 104/256)
  292. data8 0x3FD61965CDB02C1F //log(1/frcpa(1+ 105/256)
  293. data8 0x3FD646A84935B2A2 //log(1/frcpa(1+ 106/256)
  294. data8 0x3FD6740ADD31DE94 //log(1/frcpa(1+ 107/256)
  295. data8 0x3FD6A18DB74A58C5 //log(1/frcpa(1+ 108/256)
  296. data8 0x3FD6CF31058670EC //log(1/frcpa(1+ 109/256)
  297. data8 0x3FD6F180E852F0BA //log(1/frcpa(1+ 110/256)
  298. data8 0x3FD71F5D71B894F0 //log(1/frcpa(1+ 111/256)
  299. data8 0x3FD74D5AEFD66D5C //log(1/frcpa(1+ 112/256)
  300. data8 0x3FD77B79922BD37E //log(1/frcpa(1+ 113/256)
  301. data8 0x3FD7A9B9889F19E2 //log(1/frcpa(1+ 114/256)
  302. data8 0x3FD7D81B037EB6A6 //log(1/frcpa(1+ 115/256)
  303. data8 0x3FD8069E33827231 //log(1/frcpa(1+ 116/256)
  304. data8 0x3FD82996D3EF8BCB //log(1/frcpa(1+ 117/256)
  305. data8 0x3FD85855776DCBFB //log(1/frcpa(1+ 118/256)
  306. data8 0x3FD8873658327CCF //log(1/frcpa(1+ 119/256)
  307. data8 0x3FD8AA75973AB8CF //log(1/frcpa(1+ 120/256)
  308. data8 0x3FD8D992DC8824E5 //log(1/frcpa(1+ 121/256)
  309. data8 0x3FD908D2EA7D9512 //log(1/frcpa(1+ 122/256)
  310. data8 0x3FD92C59E79C0E56 //log(1/frcpa(1+ 123/256)
  311. data8 0x3FD95BD750EE3ED3 //log(1/frcpa(1+ 124/256)
  312. data8 0x3FD98B7811A3EE5B //log(1/frcpa(1+ 125/256)
  313. data8 0x3FD9AF47F33D406C //log(1/frcpa(1+ 126/256)
  314. data8 0x3FD9DF270C1914A8 //log(1/frcpa(1+ 127/256)
  315. data8 0x3FDA0325ED14FDA4 //log(1/frcpa(1+ 128/256)
  316. data8 0x3FDA33440224FA79 //log(1/frcpa(1+ 129/256)
  317. data8 0x3FDA57725E80C383 //log(1/frcpa(1+ 130/256)
  318. data8 0x3FDA87D0165DD199 //log(1/frcpa(1+ 131/256)
  319. data8 0x3FDAAC2E6C03F896 //log(1/frcpa(1+ 132/256)
  320. data8 0x3FDADCCC6FDF6A81 //log(1/frcpa(1+ 133/256)
  321. data8 0x3FDB015B3EB1E790 //log(1/frcpa(1+ 134/256)
  322. data8 0x3FDB323A3A635948 //log(1/frcpa(1+ 135/256)
  323. data8 0x3FDB56FA04462909 //log(1/frcpa(1+ 136/256)
  324. data8 0x3FDB881AA659BC93 //log(1/frcpa(1+ 137/256)
  325. data8 0x3FDBAD0BEF3DB165 //log(1/frcpa(1+ 138/256)
  326. data8 0x3FDBD21297781C2F //log(1/frcpa(1+ 139/256)
  327. data8 0x3FDC039236F08819 //log(1/frcpa(1+ 140/256)
  328. data8 0x3FDC28CB1E4D32FD //log(1/frcpa(1+ 141/256)
  329. data8 0x3FDC4E19B84723C2 //log(1/frcpa(1+ 142/256)
  330. data8 0x3FDC7FF9C74554C9 //log(1/frcpa(1+ 143/256)
  331. data8 0x3FDCA57B64E9DB05 //log(1/frcpa(1+ 144/256)
  332. data8 0x3FDCCB130A5CEBB0 //log(1/frcpa(1+ 145/256)
  333. data8 0x3FDCF0C0D18F326F //log(1/frcpa(1+ 146/256)
  334. data8 0x3FDD232075B5A201 //log(1/frcpa(1+ 147/256)
  335. data8 0x3FDD490246DEFA6B //log(1/frcpa(1+ 148/256)
  336. data8 0x3FDD6EFA918D25CD //log(1/frcpa(1+ 149/256)
  337. data8 0x3FDD9509707AE52F //log(1/frcpa(1+ 150/256)
  338. data8 0x3FDDBB2EFE92C554 //log(1/frcpa(1+ 151/256)
  339. data8 0x3FDDEE2F3445E4AF //log(1/frcpa(1+ 152/256)
  340. data8 0x3FDE148A1A2726CE //log(1/frcpa(1+ 153/256)
  341. data8 0x3FDE3AFC0A49FF40 //log(1/frcpa(1+ 154/256)
  342. data8 0x3FDE6185206D516E //log(1/frcpa(1+ 155/256)
  343. data8 0x3FDE882578823D52 //log(1/frcpa(1+ 156/256)
  344. data8 0x3FDEAEDD2EAC990C //log(1/frcpa(1+ 157/256)
  345. data8 0x3FDED5AC5F436BE3 //log(1/frcpa(1+ 158/256)
  346. data8 0x3FDEFC9326D16AB9 //log(1/frcpa(1+ 159/256)
  347. data8 0x3FDF2391A2157600 //log(1/frcpa(1+ 160/256)
  348. data8 0x3FDF4AA7EE03192D //log(1/frcpa(1+ 161/256)
  349. data8 0x3FDF71D627C30BB0 //log(1/frcpa(1+ 162/256)
  350. data8 0x3FDF991C6CB3B379 //log(1/frcpa(1+ 163/256)
  351. data8 0x3FDFC07ADA69A910 //log(1/frcpa(1+ 164/256)
  352. data8 0x3FDFE7F18EB03D3E //log(1/frcpa(1+ 165/256)
  353. data8 0x3FE007C053C5002E //log(1/frcpa(1+ 166/256)
  354. data8 0x3FE01B942198A5A1 //log(1/frcpa(1+ 167/256)
  355. data8 0x3FE02F74400C64EB //log(1/frcpa(1+ 168/256)
  356. data8 0x3FE04360BE7603AD //log(1/frcpa(1+ 169/256)
  357. data8 0x3FE05759AC47FE34 //log(1/frcpa(1+ 170/256)
  358. data8 0x3FE06B5F1911CF52 //log(1/frcpa(1+ 171/256)
  359. data8 0x3FE078BF0533C568 //log(1/frcpa(1+ 172/256)
  360. data8 0x3FE08CD9687E7B0E //log(1/frcpa(1+ 173/256)
  361. data8 0x3FE0A10074CF9019 //log(1/frcpa(1+ 174/256)
  362. data8 0x3FE0B5343A234477 //log(1/frcpa(1+ 175/256)
  363. data8 0x3FE0C974C89431CE //log(1/frcpa(1+ 176/256)
  364. data8 0x3FE0DDC2305B9886 //log(1/frcpa(1+ 177/256)
  365. data8 0x3FE0EB524BAFC918 //log(1/frcpa(1+ 178/256)
  366. data8 0x3FE0FFB54213A476 //log(1/frcpa(1+ 179/256)
  367. data8 0x3FE114253DA97D9F //log(1/frcpa(1+ 180/256)
  368. data8 0x3FE128A24F1D9AFF //log(1/frcpa(1+ 181/256)
  369. data8 0x3FE1365252BF0865 //log(1/frcpa(1+ 182/256)
  370. data8 0x3FE14AE558B4A92D //log(1/frcpa(1+ 183/256)
  371. data8 0x3FE15F85A19C765B //log(1/frcpa(1+ 184/256)
  372. data8 0x3FE16D4D38C119FA //log(1/frcpa(1+ 185/256)
  373. data8 0x3FE18203C20DD133 //log(1/frcpa(1+ 186/256)
  374. data8 0x3FE196C7BC4B1F3B //log(1/frcpa(1+ 187/256)
  375. data8 0x3FE1A4A738B7A33C //log(1/frcpa(1+ 188/256)
  376. data8 0x3FE1B981C0C9653D //log(1/frcpa(1+ 189/256)
  377. data8 0x3FE1CE69E8BB106B //log(1/frcpa(1+ 190/256)
  378. data8 0x3FE1DC619DE06944 //log(1/frcpa(1+ 191/256)
  379. data8 0x3FE1F160A2AD0DA4 //log(1/frcpa(1+ 192/256)
  380. data8 0x3FE2066D7740737E //log(1/frcpa(1+ 193/256)
  381. data8 0x3FE2147DBA47A394 //log(1/frcpa(1+ 194/256)
  382. data8 0x3FE229A1BC5EBAC3 //log(1/frcpa(1+ 195/256)
  383. data8 0x3FE237C1841A502E //log(1/frcpa(1+ 196/256)
  384. data8 0x3FE24CFCE6F80D9A //log(1/frcpa(1+ 197/256)
  385. data8 0x3FE25B2C55CD5762 //log(1/frcpa(1+ 198/256)
  386. data8 0x3FE2707F4D5F7C41 //log(1/frcpa(1+ 199/256)
  387. data8 0x3FE285E0842CA384 //log(1/frcpa(1+ 200/256)
  388. data8 0x3FE294294708B773 //log(1/frcpa(1+ 201/256)
  389. data8 0x3FE2A9A2670AFF0C //log(1/frcpa(1+ 202/256)
  390. data8 0x3FE2B7FB2C8D1CC1 //log(1/frcpa(1+ 203/256)
  391. data8 0x3FE2C65A6395F5F5 //log(1/frcpa(1+ 204/256)
  392. data8 0x3FE2DBF557B0DF43 //log(1/frcpa(1+ 205/256)
  393. data8 0x3FE2EA64C3F97655 //log(1/frcpa(1+ 206/256)
  394. data8 0x3FE3001823684D73 //log(1/frcpa(1+ 207/256)
  395. data8 0x3FE30E97E9A8B5CD //log(1/frcpa(1+ 208/256)
  396. data8 0x3FE32463EBDD34EA //log(1/frcpa(1+ 209/256)
  397. data8 0x3FE332F4314AD796 //log(1/frcpa(1+ 210/256)
  398. data8 0x3FE348D90E7464D0 //log(1/frcpa(1+ 211/256)
  399. data8 0x3FE35779F8C43D6E //log(1/frcpa(1+ 212/256)
  400. data8 0x3FE36621961A6A99 //log(1/frcpa(1+ 213/256)
  401. data8 0x3FE37C299F3C366A //log(1/frcpa(1+ 214/256)
  402. data8 0x3FE38AE2171976E7 //log(1/frcpa(1+ 215/256)
  403. data8 0x3FE399A157A603E7 //log(1/frcpa(1+ 216/256)
  404. data8 0x3FE3AFCCFE77B9D1 //log(1/frcpa(1+ 217/256)
  405. data8 0x3FE3BE9D503533B5 //log(1/frcpa(1+ 218/256)
  406. data8 0x3FE3CD7480B4A8A3 //log(1/frcpa(1+ 219/256)
  407. data8 0x3FE3E3C43918F76C //log(1/frcpa(1+ 220/256)
  408. data8 0x3FE3F2ACB27ED6C7 //log(1/frcpa(1+ 221/256)
  409. data8 0x3FE4019C2125CA93 //log(1/frcpa(1+ 222/256)
  410. data8 0x3FE4181061389722 //log(1/frcpa(1+ 223/256)
  411. data8 0x3FE42711518DF545 //log(1/frcpa(1+ 224/256)
  412. data8 0x3FE436194E12B6BF //log(1/frcpa(1+ 225/256)
  413. data8 0x3FE445285D68EA69 //log(1/frcpa(1+ 226/256)
  414. data8 0x3FE45BCC464C893A //log(1/frcpa(1+ 227/256)
  415. data8 0x3FE46AED21F117FC //log(1/frcpa(1+ 228/256)
  416. data8 0x3FE47A1527E8A2D3 //log(1/frcpa(1+ 229/256)
  417. data8 0x3FE489445EFFFCCC //log(1/frcpa(1+ 230/256)
  418. data8 0x3FE4A018BCB69835 //log(1/frcpa(1+ 231/256)
  419. data8 0x3FE4AF5A0C9D65D7 //log(1/frcpa(1+ 232/256)
  420. data8 0x3FE4BEA2A5BDBE87 //log(1/frcpa(1+ 233/256)
  421. data8 0x3FE4CDF28F10AC46 //log(1/frcpa(1+ 234/256)
  422. data8 0x3FE4DD49CF994058 //log(1/frcpa(1+ 235/256)
  423. data8 0x3FE4ECA86E64A684 //log(1/frcpa(1+ 236/256)
  424. data8 0x3FE503C43CD8EB68 //log(1/frcpa(1+ 237/256)
  425. data8 0x3FE513356667FC57 //log(1/frcpa(1+ 238/256)
  426. data8 0x3FE522AE0738A3D8 //log(1/frcpa(1+ 239/256)
  427. data8 0x3FE5322E26867857 //log(1/frcpa(1+ 240/256)
  428. data8 0x3FE541B5CB979809 //log(1/frcpa(1+ 241/256)
  429. data8 0x3FE55144FDBCBD62 //log(1/frcpa(1+ 242/256)
  430. data8 0x3FE560DBC45153C7 //log(1/frcpa(1+ 243/256)
  431. data8 0x3FE5707A26BB8C66 //log(1/frcpa(1+ 244/256)
  432. data8 0x3FE587F60ED5B900 //log(1/frcpa(1+ 245/256)
  433. data8 0x3FE597A7977C8F31 //log(1/frcpa(1+ 246/256)
  434. data8 0x3FE5A760D634BB8B //log(1/frcpa(1+ 247/256)
  435. data8 0x3FE5B721D295F10F //log(1/frcpa(1+ 248/256)
  436. data8 0x3FE5C6EA94431EF9 //log(1/frcpa(1+ 249/256)
  437. data8 0x3FE5D6BB22EA86F6 //log(1/frcpa(1+ 250/256)
  438. data8 0x3FE5E6938645D390 //log(1/frcpa(1+ 251/256)
  439. data8 0x3FE5F673C61A2ED2 //log(1/frcpa(1+ 252/256)
  440. data8 0x3FE6065BEA385926 //log(1/frcpa(1+ 253/256)
  441. data8 0x3FE6164BFA7CC06B //log(1/frcpa(1+ 254/256)
  442. data8 0x3FE62643FECF9743 //log(1/frcpa(1+ 255/256)
  443. .align 32
  444. .global logf#
  445. .global log10f#
  446. // log10 has p7 true, p8 false
  447. // log has p8 true, p7 false
  448. .section .text
  449. .proc log10f#
  450. .align 32
  451. log10f:
  452. { .mfi
  453. alloc r32=ar.pfs,1,15,4,0
  454. frcpa.s1 log_C,p9 = f1,f8
  455. cmp.eq.unc p7,p8 = r0, r0
  456. }
  457. { .mfb
  458. addl log_AD_1 = @ltoff(log_table_1), gp
  459. fnorm.s1 log_NORM_f8 = f8
  460. br.sptk LOG_LOG10_X
  461. }
  462. ;;
  463. .endp log10f
  464. .section .text
  465. .proc logf#
  466. .align 32
  467. logf:
  468. { .mfi
  469. alloc r32=ar.pfs,1,15,4,0
  470. frcpa.s1 log_C,p9 = f1,f8
  471. cmp.eq.unc p8,p7 = r0, r0
  472. }
  473. { .mfi
  474. addl log_AD_1 = @ltoff(log_table_1), gp
  475. fnorm.s1 log_NORM_f8 = f8
  476. nop.i 999
  477. }
  478. ;;
  479. LOG_LOG10_X:
  480. { .mfi
  481. getf.exp log_GR_signexp_f8 = f8 // If x unorm then must recompute
  482. fclass.m.unc p15,p0 = f8, 0x0b // Test for x=unorm
  483. mov log_GR_fff7 = 0xfff7
  484. }
  485. { .mfi
  486. ld8 log_AD_1 = [log_AD_1]
  487. fms.s1 log_w = f8,f1,f1
  488. mov log_GR_exp_17_ones = 0x1ffff
  489. }
  490. ;;
  491. { .mmi
  492. getf.sig log_GR_significand_f8 = f8 // If x unorm then must recompute
  493. mov log_GR_exp_16_ones = 0xffff
  494. nop.i 999
  495. }
  496. ;;
  497. { .mmb
  498. adds log_AD_2 = 0x10, log_AD_1
  499. and log_GR_exp_f8 = log_GR_signexp_f8, log_GR_exp_17_ones
  500. (p15) br.cond.spnt LOG_DENORM
  501. }
  502. ;;
  503. LOG_COMMON:
  504. {.mfi
  505. ldfpd log_P3,log_P2 = [log_AD_1],16
  506. fclass.m.unc p6,p0 = f8, 0xc3 // Test for x=nan
  507. shl log_GR_index = log_GR_significand_f8,1
  508. }
  509. {.mfi
  510. sub log_GR_true_exp_f8 = log_GR_exp_f8, log_GR_exp_16_ones
  511. nop.f 999
  512. nop.i 999
  513. }
  514. ;;
  515. { .mfi
  516. ldfpd log_P1,log_inv_ln10 = [log_AD_2],16
  517. fclass.m.unc p11,p0 = f8, 0x21 // Test for x=+inf
  518. shr.u log_GR_index = log_GR_index,56
  519. }
  520. { .mfi
  521. setf.sig log_int_Nfloat = log_GR_true_exp_f8
  522. nop.f 999
  523. nop.i 999
  524. }
  525. ;;
  526. { .mfi
  527. ldfd log_log2 = [log_AD_2],16
  528. fma.s1 log_wsq = log_w, log_w, f0
  529. nop.i 999
  530. }
  531. { .mfb
  532. nop.m 999
  533. (p6) fma.s.s0 f8 = f8,f1,f0 // quietize nan result if x=nan
  534. (p6) br.ret.spnt b0 // Exit for x=nan
  535. }
  536. ;;
  537. { .mfi
  538. shladd log_AD_2 = log_GR_index,3,log_AD_2
  539. fcmp.eq.s1 p10,p0 = log_NORM_f8, f1 // Test for x=+1.0
  540. nop.i 999
  541. }
  542. { .mfb
  543. nop.m 999
  544. fms.s1 log_r = log_C,f8,f1
  545. (p11) br.ret.spnt b0 // Exit for x=+inf
  546. }
  547. ;;
  548. { .mmf
  549. nop.m 999
  550. nop.m 999
  551. fclass.m.unc p6,p0 = f8, 0x07 // Test for x=0
  552. }
  553. ;;
  554. { .mfb
  555. ldfd log_T = [log_AD_2]
  556. (p10) fmerge.s f8 = f0, f0
  557. (p10) br.ret.spnt b0 // Exit for x=1.0
  558. ;;
  559. }
  560. { .mfi
  561. getf.exp log_GR_signexp_w = log_w
  562. fclass.m.unc p12,p0 = f8, 0x3a // Test for x neg norm, unorm, inf
  563. nop.i 999
  564. }
  565. ;;
  566. { .mmb
  567. nop.m 999
  568. nop.m 999
  569. (p6) br.cond.spnt LOG_ZERO_NEG // Branch if x=0
  570. ;;
  571. }
  572. { .mfi
  573. and log_GR_exp_w = log_GR_exp_17_ones, log_GR_signexp_w
  574. nop.f 999
  575. nop.i 999
  576. }
  577. { .mfb
  578. nop.m 999
  579. fma.s1 log_rsq = log_r, log_r, f0
  580. (p12) br.cond.spnt LOG_ZERO_NEG // Branch if x<0
  581. ;;
  582. }
  583. { .mfi
  584. nop.m 999
  585. fma.s1 log_rp_p32 = log_P3, log_r, log_P2
  586. nop.i 999
  587. }
  588. { .mfi
  589. nop.m 999
  590. fma.s1 log_rp_q32 = log_P3, log_w, log_P2
  591. nop.i 999
  592. ;;
  593. }
  594. { .mfi
  595. nop.m 999
  596. fcvt.xf log_Nfloat = log_int_Nfloat
  597. nop.i 999 ;;
  598. }
  599. { .mfi
  600. nop.m 999
  601. fma.s1 log_rp_p10 = log_P1, log_r, f1
  602. nop.i 999
  603. }
  604. { .mfi
  605. nop.m 999
  606. fma.s1 log_rp_q10 = log_P1, log_w, f1
  607. nop.i 999
  608. ;;
  609. }
  610. // p13 <== large w log
  611. // p14 <== small w log
  612. { .mfi
  613. (p8) cmp.ge.unc p13,p14 = log_GR_exp_w, log_GR_fff7
  614. fcmp.eq.s0 p6,p0 = f8,f0 // Sets flag on +denormal input
  615. nop.i 999
  616. ;;
  617. }
  618. // p10 <== large w log10
  619. // p11 <== small w log10
  620. { .mfi
  621. (p7) cmp.ge.unc p10,p11 = log_GR_exp_w, log_GR_fff7
  622. nop.f 999
  623. nop.i 999 ;;
  624. }
  625. { .mfi
  626. nop.m 999
  627. fma.s1 log_T_plus_Nlog2 = log_Nfloat,log_log2, log_T
  628. nop.i 999 ;;
  629. }
  630. { .mfi
  631. nop.m 999
  632. fma.s1 log_rp_p2 = log_rp_p32, log_rsq, log_rp_p10
  633. nop.i 999
  634. }
  635. { .mfi
  636. nop.m 999
  637. fma.s1 log_rp_q2 = log_rp_q32, log_wsq, log_rp_q10
  638. nop.i 999
  639. ;;
  640. }
  641. // small w, log <== p14
  642. { .mfi
  643. nop.m 999
  644. (p14) fma.s f8 = log_rp_q2, log_w, f0
  645. nop.i 999
  646. }
  647. { .mfi
  648. nop.m 999
  649. (p11) fma.s1 log_Q = log_rp_q2, log_w, f0
  650. nop.i 999 ;;
  651. }
  652. // large w, log <== p13
  653. .pred.rel "mutex",p13,p10
  654. { .mfi
  655. nop.m 999
  656. (p13) fma.s f8 = log_rp_p2, log_r, log_T_plus_Nlog2
  657. nop.i 999
  658. }
  659. { .mfi
  660. nop.m 999
  661. (p10) fma.s1 log_Q = log_rp_p2, log_r, log_T_plus_Nlog2
  662. nop.i 999 ;;
  663. }
  664. // log10
  665. { .mfb
  666. nop.m 999
  667. (p7) fma.s f8 = log_inv_ln10,log_Q,f0
  668. br.ret.sptk b0
  669. ;;
  670. }
  671. LOG_DENORM:
  672. { .mmi
  673. getf.exp log_GR_signexp_f8 = log_NORM_f8
  674. nop.m 999
  675. nop.i 999
  676. }
  677. ;;
  678. { .mmb
  679. getf.sig log_GR_significand_f8 = log_NORM_f8
  680. and log_GR_exp_f8 = log_GR_signexp_f8, log_GR_exp_17_ones
  681. br.cond.sptk LOG_COMMON
  682. }
  683. ;;
  684. LOG_ZERO_NEG:
  685. // qnan snan inf norm unorm 0 -+
  686. // 0 0 0 0 0 1 11 0x7
  687. // 0 0 1 1 1 0 10 0x3a
  688. // Save x (f8) in f10
  689. { .mfi
  690. nop.m 999
  691. fmerge.s f10 = f8,f8
  692. nop.i 999 ;;
  693. }
  694. // p8 p9 means ln(+-0) = -inf
  695. // p7 p10 means log(+-0) = -inf
  696. // p13 means ln(-)
  697. // p14 means log(-)
  698. { .mfi
  699. nop.m 999
  700. fmerge.ns f6 = f1,f1 // Form -1.0
  701. nop.i 999 ;;
  702. }
  703. // p9 means ln(+-0) = -inf
  704. // p10 means log(+-0) = -inf
  705. // Log(+-0) = -inf
  706. { .mfi
  707. nop.m 999
  708. (p8) fclass.m.unc p9,p0 = f10, 0x07
  709. nop.i 999
  710. }
  711. { .mfi
  712. nop.m 999
  713. (p7) fclass.m.unc p10,p0 = f10, 0x07
  714. nop.i 999 ;;
  715. }
  716. // p13 ln(-)
  717. // p14 log(-)
  718. // Log(-inf, -normal, -unnormal) = QNAN indefinite
  719. { .mfi
  720. nop.m 999
  721. (p8) fclass.m.unc p13,p0 = f10, 0x3a
  722. nop.i 999
  723. }
  724. { .mfi
  725. nop.m 999
  726. (p7) fclass.m.unc p14,p0 = f10, 0x3a
  727. nop.i 999 ;;
  728. }
  729. .pred.rel "mutex",p9,p10
  730. { .mfi
  731. (p9) mov log_GR_tag = 4
  732. (p9) frcpa f8,p11 = f6,f0
  733. nop.i 999
  734. }
  735. { .mfi
  736. (p10) mov log_GR_tag = 10
  737. (p10) frcpa f8,p12 = f6,f0
  738. nop.i 999 ;;
  739. }
  740. .pred.rel "mutex",p13,p14
  741. { .mfi
  742. (p13) mov log_GR_tag = 5
  743. (p13) frcpa f8,p11 = f0,f0
  744. nop.i 999
  745. }
  746. { .mfb
  747. (p14) mov log_GR_tag = 11
  748. (p14) frcpa f8,p12 = f0,f0
  749. br.cond.sptk __libm_error_region ;;
  750. }
  751. .endp log
  752. // Stack operations when calling error support.
  753. // (1) (2) (3) (call) (4)
  754. // sp -> + psp -> + psp -> + sp -> +
  755. // | | | |
  756. // | | <- GR_Y R3 ->| <- GR_RESULT | -> f8
  757. // | | | |
  758. // | <-GR_Y Y2->| Y2 ->| <- GR_Y |
  759. // | | | |
  760. // | | <- GR_X X1 ->| |
  761. // | | | |
  762. // sp-64 -> + sp -> + sp -> + +
  763. // save ar.pfs save b0 restore gp
  764. // save gp restore ar.pfs
  765. .proc __libm_error_region
  766. __libm_error_region:
  767. .prologue
  768. // (1)
  769. { .mfi
  770. add GR_Parameter_Y=-32,sp // Parameter 2 value
  771. nop.f 0
  772. .save ar.pfs,GR_SAVE_PFS
  773. mov GR_SAVE_PFS=ar.pfs // Save ar.pfs
  774. }
  775. { .mfi
  776. .fframe 64
  777. add sp=-64,sp // Create new stack
  778. nop.f 0
  779. mov GR_SAVE_GP=gp // Save gp
  780. };;
  781. // (2)
  782. { .mmi
  783. stfs [GR_Parameter_Y] = f1,16 // STORE Parameter 2 on stack
  784. add GR_Parameter_X = 16,sp // Parameter 1 address
  785. .save b0, GR_SAVE_B0
  786. mov GR_SAVE_B0=b0 // Save b0
  787. };;
  788. .body
  789. // (3)
  790. { .mib
  791. stfs [GR_Parameter_X] = f10 // STORE Parameter 1 on stack
  792. add GR_Parameter_RESULT = 0,GR_Parameter_Y // Parameter 3 address
  793. nop.b 0
  794. }
  795. { .mib
  796. stfs [GR_Parameter_Y] = f8 // STORE Parameter 3 on stack
  797. add GR_Parameter_Y = -16,GR_Parameter_Y
  798. br.call.sptk b0=__libm_error_support# // Call error handling function
  799. };;
  800. { .mmi
  801. nop.m 0
  802. nop.m 0
  803. add GR_Parameter_RESULT = 48,sp
  804. };;
  805. // (4)
  806. { .mmi
  807. ldfs f8 = [GR_Parameter_RESULT] // Get return result off stack
  808. .restore
  809. add sp = 64,sp // Restore stack pointer
  810. mov b0 = GR_SAVE_B0 // Restore return address
  811. };;
  812. { .mib
  813. mov gp = GR_SAVE_GP // Restore gp
  814. mov ar.pfs = GR_SAVE_PFS // Restore ar.pfs
  815. br.ret.sptk b0 // Return
  816. };;
  817. .endp __libm_error_region
  818. .type __libm_error_support#,@function
  819. .global __libm_error_support#