]>
Commit | Line | Data |
---|---|---|
d5efd131 MF |
1 | .file "logf.s" |
2 | ||
3 | ||
4 | // Copyright (c) 2000 - 2005, Intel Corporation | |
5 | // All rights reserved. | |
6 | // | |
7 | // Contributed 2000 by the Intel Numerics Group, Intel Corporation | |
8 | // | |
9 | // Redistribution and use in source and binary forms, with or without | |
10 | // modification, are permitted provided that the following conditions are | |
11 | // met: | |
12 | // | |
13 | // * Redistributions of source code must retain the above copyright | |
14 | // notice, this list of conditions and the following disclaimer. | |
15 | // | |
16 | // * Redistributions in binary form must reproduce the above copyright | |
17 | // notice, this list of conditions and the following disclaimer in the | |
18 | // documentation and/or other materials provided with the distribution. | |
19 | // | |
20 | // * The name of Intel Corporation may not be used to endorse or promote | |
21 | // products derived from this software without specific prior written | |
22 | // permission. | |
23 | ||
24 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
25 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
26 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
27 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR ITS | |
28 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
29 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
30 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
31 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | |
32 | // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR TORT (INCLUDING | |
33 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
34 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
35 | // | |
36 | // Intel Corporation is the author of this code, and requests that all | |
37 | // problem reports or change requests be submitted to it directly at | |
38 | // http://www.intel.com/software/products/opensource/libraries/num.htm. | |
39 | // | |
40 | // History | |
41 | //============================================================== | |
42 | // 03/01/00 Initial version | |
43 | // 08/15/00 Bundle added after call to __libm_error_support to properly | |
44 | // set [the previously overwritten] GR_Parameter_RESULT. | |
45 | // 01/10/01 Improved speed, fixed flags for neg denormals | |
46 | // 05/20/02 Cleaned up namespace and sf0 syntax | |
47 | // 05/23/02 Modified algorithm. Now only one polynomial is used | |
48 | // for |x-1| >= 1/256 and for |x-1| < 1/256 | |
49 | // 02/10/03 Reordered header: .section, .global, .proc, .align | |
50 | // 03/31/05 Reformatted delimiters between data tables | |
51 | // | |
52 | // API | |
53 | //============================================================== | |
54 | // float logf(float) | |
55 | // float log10f(float) | |
56 | // | |
57 | // | |
58 | // Overview of operation | |
59 | //============================================================== | |
60 | // Background | |
61 | // ---------- | |
62 | // | |
63 | // This algorithm is based on fact that | |
64 | // log(a b) = log(a) + log(b). | |
65 | // | |
66 | // In our case we have x = 2^N f, where 1 <= f < 2. | |
67 | // So | |
68 | // log(x) = log(2^N f) = log(2^N) + log(f) = n*log(2) + log(f) | |
69 | // | |
70 | // To calculate log(f) we do following | |
71 | // log(f) = log(f * frcpa(f) / frcpa(f)) = | |
72 | // = log(f * frcpa(f)) + log(1/frcpa(f)) | |
73 | // | |
74 | // According to definition of IA-64's frcpa instruction it's a | |
75 | // floating point that approximates 1/f using a lookup on the | |
76 | // top of 8 bits of the input number's significand with relative | |
77 | // error < 2^(-8.886). So we have following | |
78 | // | |
79 | // |(1/f - frcpa(f)) / (1/f))| = |1 - f*frcpa(f)| < 1/256 | |
80 | // | |
81 | // and | |
82 | // | |
83 | // log(f) = log(f * frcpa(f)) + log(1/frcpa(f)) = | |
84 | // = log(1 + r) + T | |
85 | // | |
86 | // The first value can be computed by polynomial P(r) approximating | |
87 | // log(1 + r) on |r| < 1/256 and the second is precomputed tabular | |
88 | // value defined by top 8 bit of f. | |
89 | // | |
90 | // Finally we have that log(x) ~ (N*log(2) + T) + P(r) | |
91 | // | |
92 | // Note that if input argument is close to 1.0 (in our case it means | |
93 | // that |1 - x| < 1/256) we can use just polynomial approximation | |
94 | // because x = 2^0 * f = f = 1 + r and | |
95 | // log(x) = log(1 + r) ~ P(r) | |
96 | // | |
97 | // | |
98 | // To compute log10(x) we just use identity: | |
99 | // | |
100 | // log10(x) = log(x)/log(10) | |
101 | // | |
102 | // so we have that | |
103 | // | |
104 | // log10(x) = (N*log(2) + T + log(1+r)) / log(10) = | |
105 | // = N*(log(2)/log(10)) + (T/log(10)) + log(1 + r)/log(10) | |
106 | // | |
107 | // | |
108 | // Implementation | |
109 | // -------------- | |
110 | // It can be seen that formulas for log and log10 differ from one another | |
111 | // only by coefficients and tabular values. Namely as log as log10 are | |
112 | // calculated as (N*L1 + T) + L2*Series(r) where in case of log | |
113 | // L1 = log(2) | |
114 | // T = log(1/frcpa(x)) | |
115 | // L2 = 1.0 | |
116 | // and in case of log10 | |
117 | // L1 = log(2)/log(10) | |
118 | // T = log(1/frcpa(x))/log(10) | |
119 | // L2 = 1.0/log(10) | |
120 | // | |
121 | // So common code with two different entry points those set pointers | |
122 | // to the base address of coresponding data sets containing values | |
123 | // of L2,T and prepare integer representation of L1 needed for following | |
124 | // setf instruction can be used. | |
125 | // | |
126 | // Note that both log and log10 use common approximation polynomial | |
127 | // it means we need only one set of coefficients of approximation. | |
128 | // | |
129 | // 1. Computation of log(x) for |x-1| >= 1/256 | |
130 | // InvX = frcpa(x) | |
131 | // r = InvX*x - 1 | |
132 | // P(r) = r*((1 - A2*r) + r^2*(A3 - A4*r)) = r*P2(r), | |
133 | // A4,A3,A2 are created with setf inctruction. | |
134 | // We use Taylor series and so A4 = 1/4, A3 = 1/3, | |
135 | // A2 = 1/2 rounded to double. | |
136 | // | |
137 | // N = float(n) where n is true unbiased exponent of x | |
138 | // | |
139 | // T is tabular value of log(1/frcpa(x)) calculated in quad precision | |
140 | // and rounded to double. To T we get bits from 55 to 62 of register | |
141 | // format significand of x and calculate address | |
142 | // ad_T = table_base_addr + 8 * index | |
143 | // | |
144 | // L2 (1.0 or 1.0/log(10) depending on function) is calculated in quad | |
145 | // precision and rounded to double; it's loaded from memory | |
146 | // | |
147 | // L1 (log(2) or log10(2) depending on function) is calculated in quad | |
148 | // precision and rounded to double; it's created with setf. | |
149 | // | |
150 | // And final result = P2(r)*(r*L2) + (T + N*L1) | |
151 | // | |
152 | // | |
153 | // 2. Computation of log(x) for |x-1| < 1/256 | |
154 | // r = x - 1 | |
155 | // P(r) = r*((1 - A2*r) + r^2*(A3 - A4*r)) = r*P2(r), | |
156 | // A4,A3,A2 are the same as in case |x-1| >= 1/256 | |
157 | // | |
158 | // And final result = P2(r)*(r*L2) | |
159 | // | |
160 | // 3. How we define is input argument such that |x-1| < 1/256 or not. | |
161 | // | |
6f65e668 | 162 | // To do it we analyze biased exponent and significand of input argument. |
d5efd131 MF |
163 | // |
164 | // a) First we test is biased exponent equal to 0xFFFE or 0xFFFF (i.e. | |
165 | // we test is 0.5 <= x < 2). This comparison can be performed using | |
166 | // unsigned version of cmp instruction in such a way | |
167 | // biased_exponent_of_x - 0xFFFE < 2 | |
168 | // | |
169 | // | |
170 | // b) Second (in case when result of a) is true) we need to compare x | |
171 | // with 1-1/256 and 1+1/256 or in register format representation with | |
172 | // 0xFFFEFF00000000000000 and 0xFFFF8080000000000000 correspondingly. | |
173 | // As far as biased exponent of x here can be equal only to 0xFFFE or | |
174 | // 0xFFFF we need to test only last bit of it. Also signifigand always | |
175 | // has implicit bit set to 1 that can be exluded from comparison. | |
176 | // Thus it's quite enough to generate 64-bit integer bits of that are | |
177 | // ix[63] = biased_exponent_of_x[0] and ix[62-0] = significand_of_x[62-0] | |
178 | // and compare it with 0x7F00000000000000 and 0x80800000000000000 (those | |
179 | // obtained like ix from register representatinos of 255/256 and | |
180 | // 257/256). This comparison can be made like in a), using unsigned | |
181 | // version of cmp i.e. ix - 0x7F00000000000000 < 0x0180000000000000. | |
182 | // 0x0180000000000000 is difference between 0x80800000000000000 and | |
183 | // 0x7F00000000000000. | |
184 | // | |
185 | // Note: NaT, any NaNs, +/-INF, +/-0, negatives and unnormalized numbers are | |
186 | // filtered and processed on special branches. | |
187 | // | |
188 | // | |
189 | // Special values | |
190 | //============================================================== | |
191 | // | |
192 | // logf(+0) = -inf | |
193 | // logf(-0) = -inf | |
194 | // | |
195 | // logf(+qnan) = +qnan | |
196 | // logf(-qnan) = -qnan | |
197 | // logf(+snan) = +qnan | |
198 | // logf(-snan) = -qnan | |
199 | // | |
200 | // logf(-n) = QNAN Indefinite | |
201 | // logf(-inf) = QNAN Indefinite | |
202 | // | |
203 | // logf(+inf) = +inf | |
204 | // | |
205 | // Registers used | |
206 | //============================================================== | |
207 | // Floating Point registers used: | |
208 | // f8, input | |
209 | // f12 -> f14, f33 -> f39 | |
210 | // | |
211 | // General registers used: | |
212 | // r8 -> r11 | |
213 | // r14 -> r19 | |
214 | // | |
215 | // Predicate registers used: | |
216 | // p6 -> p12 | |
217 | ||
218 | ||
219 | // Assembly macros | |
220 | //============================================================== | |
221 | ||
222 | GR_TAG = r8 | |
223 | GR_ad_T = r8 | |
224 | GR_N = r9 | |
225 | GR_Exp = r10 | |
226 | GR_Sig = r11 | |
227 | ||
228 | GR_025 = r14 | |
229 | GR_05 = r15 | |
230 | GR_A3 = r16 | |
231 | GR_Ind = r17 | |
232 | GR_dx = r15 | |
233 | GR_Ln2 = r19 | |
234 | GR_de = r20 | |
235 | GR_x = r21 | |
236 | GR_xorg = r22 | |
237 | ||
238 | GR_SAVE_B0 = r33 | |
239 | GR_SAVE_PFS = r34 | |
240 | GR_SAVE_GP = r35 | |
241 | GR_SAVE_SP = r36 | |
242 | ||
243 | GR_Parameter_X = r37 | |
244 | GR_Parameter_Y = r38 | |
245 | GR_Parameter_RESULT = r39 | |
246 | GR_Parameter_TAG = r40 | |
247 | ||
248 | ||
249 | FR_A2 = f12 | |
250 | FR_A3 = f13 | |
251 | FR_A4 = f14 | |
252 | ||
253 | FR_RcpX = f33 | |
254 | FR_r = f34 | |
255 | FR_r2 = f35 | |
256 | FR_tmp = f35 | |
257 | FR_Ln2 = f36 | |
258 | FR_T = f37 | |
259 | FR_N = f38 | |
260 | FR_NxLn2pT = f38 | |
261 | FR_NormX = f39 | |
262 | FR_InvLn10 = f40 | |
263 | ||
264 | ||
265 | FR_Y = f1 | |
266 | FR_X = f10 | |
267 | FR_RESULT = f8 | |
268 | ||
269 | ||
270 | // Data tables | |
271 | //============================================================== | |
272 | RODATA | |
273 | .align 16 | |
274 | LOCAL_OBJECT_START(logf_data) | |
275 | data8 0x3FF0000000000000 // 1.0 | |
276 | // | |
277 | // ln(1/frcpa(1+i/256)), i=0...255 | |
278 | data8 0x3F60040155D5889E // 0 | |
279 | data8 0x3F78121214586B54 // 1 | |
280 | data8 0x3F841929F96832F0 // 2 | |
281 | data8 0x3F8C317384C75F06 // 3 | |
282 | data8 0x3F91A6B91AC73386 // 4 | |
283 | data8 0x3F95BA9A5D9AC039 // 5 | |
284 | data8 0x3F99D2A8074325F4 // 6 | |
285 | data8 0x3F9D6B2725979802 // 7 | |
286 | data8 0x3FA0C58FA19DFAAA // 8 | |
287 | data8 0x3FA2954C78CBCE1B // 9 | |
288 | data8 0x3FA4A94D2DA96C56 // 10 | |
289 | data8 0x3FA67C94F2D4BB58 // 11 | |
290 | data8 0x3FA85188B630F068 // 12 | |
291 | data8 0x3FAA6B8ABE73AF4C // 13 | |
292 | data8 0x3FAC441E06F72A9E // 14 | |
293 | data8 0x3FAE1E6713606D07 // 15 | |
294 | data8 0x3FAFFA6911AB9301 // 16 | |
295 | data8 0x3FB0EC139C5DA601 // 17 | |
296 | data8 0x3FB1DBD2643D190B // 18 | |
297 | data8 0x3FB2CC7284FE5F1C // 19 | |
298 | data8 0x3FB3BDF5A7D1EE64 // 20 | |
299 | data8 0x3FB4B05D7AA012E0 // 21 | |
300 | data8 0x3FB580DB7CEB5702 // 22 | |
301 | data8 0x3FB674F089365A7A // 23 | |
302 | data8 0x3FB769EF2C6B568D // 24 | |
303 | data8 0x3FB85FD927506A48 // 25 | |
304 | data8 0x3FB9335E5D594989 // 26 | |
305 | data8 0x3FBA2B0220C8E5F5 // 27 | |
306 | data8 0x3FBB0004AC1A86AC // 28 | |
307 | data8 0x3FBBF968769FCA11 // 29 | |
308 | data8 0x3FBCCFEDBFEE13A8 // 30 | |
309 | data8 0x3FBDA727638446A2 // 31 | |
310 | data8 0x3FBEA3257FE10F7A // 32 | |
311 | data8 0x3FBF7BE9FEDBFDE6 // 33 | |
312 | data8 0x3FC02AB352FF25F4 // 34 | |
313 | data8 0x3FC097CE579D204D // 35 | |
314 | data8 0x3FC1178E8227E47C // 36 | |
315 | data8 0x3FC185747DBECF34 // 37 | |
316 | data8 0x3FC1F3B925F25D41 // 38 | |
317 | data8 0x3FC2625D1E6DDF57 // 39 | |
318 | data8 0x3FC2D1610C86813A // 40 | |
319 | data8 0x3FC340C59741142E // 41 | |
320 | data8 0x3FC3B08B6757F2A9 // 42 | |
321 | data8 0x3FC40DFB08378003 // 43 | |
322 | data8 0x3FC47E74E8CA5F7C // 44 | |
323 | data8 0x3FC4EF51F6466DE4 // 45 | |
324 | data8 0x3FC56092E02BA516 // 46 | |
325 | data8 0x3FC5D23857CD74D5 // 47 | |
326 | data8 0x3FC6313A37335D76 // 48 | |
327 | data8 0x3FC6A399DABBD383 // 49 | |
328 | data8 0x3FC70337DD3CE41B // 50 | |
329 | data8 0x3FC77654128F6127 // 51 | |
330 | data8 0x3FC7E9D82A0B022D // 52 | |
331 | data8 0x3FC84A6B759F512F // 53 | |
332 | data8 0x3FC8AB47D5F5A310 // 54 | |
333 | data8 0x3FC91FE49096581B // 55 | |
334 | data8 0x3FC981634011AA75 // 56 | |
335 | data8 0x3FC9F6C407089664 // 57 | |
336 | data8 0x3FCA58E729348F43 // 58 | |
337 | data8 0x3FCABB55C31693AD // 59 | |
338 | data8 0x3FCB1E104919EFD0 // 60 | |
339 | data8 0x3FCB94EE93E367CB // 61 | |
340 | data8 0x3FCBF851C067555F // 62 | |
341 | data8 0x3FCC5C0254BF23A6 // 63 | |
342 | data8 0x3FCCC000C9DB3C52 // 64 | |
343 | data8 0x3FCD244D99C85674 // 65 | |
344 | data8 0x3FCD88E93FB2F450 // 66 | |
345 | data8 0x3FCDEDD437EAEF01 // 67 | |
346 | data8 0x3FCE530EFFE71012 // 68 | |
347 | data8 0x3FCEB89A1648B971 // 69 | |
348 | data8 0x3FCF1E75FADF9BDE // 70 | |
349 | data8 0x3FCF84A32EAD7C35 // 71 | |
350 | data8 0x3FCFEB2233EA07CD // 72 | |
351 | data8 0x3FD028F9C7035C1C // 73 | |
352 | data8 0x3FD05C8BE0D9635A // 74 | |
353 | data8 0x3FD085EB8F8AE797 // 75 | |
354 | data8 0x3FD0B9C8E32D1911 // 76 | |
355 | data8 0x3FD0EDD060B78081 // 77 | |
356 | data8 0x3FD122024CF0063F // 78 | |
357 | data8 0x3FD14BE2927AECD4 // 79 | |
358 | data8 0x3FD180618EF18ADF // 80 | |
359 | data8 0x3FD1B50BBE2FC63B // 81 | |
360 | data8 0x3FD1DF4CC7CF242D // 82 | |
361 | data8 0x3FD214456D0EB8D4 // 83 | |
362 | data8 0x3FD23EC5991EBA49 // 84 | |
363 | data8 0x3FD2740D9F870AFB // 85 | |
364 | data8 0x3FD29ECDABCDFA04 // 86 | |
365 | data8 0x3FD2D46602ADCCEE // 87 | |
366 | data8 0x3FD2FF66B04EA9D4 // 88 | |
367 | data8 0x3FD335504B355A37 // 89 | |
368 | data8 0x3FD360925EC44F5D // 90 | |
369 | data8 0x3FD38BF1C3337E75 // 91 | |
370 | data8 0x3FD3C25277333184 // 92 | |
371 | data8 0x3FD3EDF463C1683E // 93 | |
372 | data8 0x3FD419B423D5E8C7 // 94 | |
373 | data8 0x3FD44591E0539F49 // 95 | |
374 | data8 0x3FD47C9175B6F0AD // 96 | |
375 | data8 0x3FD4A8B341552B09 // 97 | |
376 | data8 0x3FD4D4F3908901A0 // 98 | |
377 | data8 0x3FD501528DA1F968 // 99 | |
378 | data8 0x3FD52DD06347D4F6 // 100 | |
379 | data8 0x3FD55A6D3C7B8A8A // 101 | |
380 | data8 0x3FD5925D2B112A59 // 102 | |
381 | data8 0x3FD5BF406B543DB2 // 103 | |
382 | data8 0x3FD5EC433D5C35AE // 104 | |
383 | data8 0x3FD61965CDB02C1F // 105 | |
384 | data8 0x3FD646A84935B2A2 // 106 | |
385 | data8 0x3FD6740ADD31DE94 // 107 | |
386 | data8 0x3FD6A18DB74A58C5 // 108 | |
387 | data8 0x3FD6CF31058670EC // 109 | |
388 | data8 0x3FD6F180E852F0BA // 110 | |
389 | data8 0x3FD71F5D71B894F0 // 111 | |
390 | data8 0x3FD74D5AEFD66D5C // 112 | |
391 | data8 0x3FD77B79922BD37E // 113 | |
392 | data8 0x3FD7A9B9889F19E2 // 114 | |
393 | data8 0x3FD7D81B037EB6A6 // 115 | |
394 | data8 0x3FD8069E33827231 // 116 | |
395 | data8 0x3FD82996D3EF8BCB // 117 | |
396 | data8 0x3FD85855776DCBFB // 118 | |
397 | data8 0x3FD8873658327CCF // 119 | |
398 | data8 0x3FD8AA75973AB8CF // 120 | |
399 | data8 0x3FD8D992DC8824E5 // 121 | |
400 | data8 0x3FD908D2EA7D9512 // 122 | |
401 | data8 0x3FD92C59E79C0E56 // 123 | |
402 | data8 0x3FD95BD750EE3ED3 // 124 | |
403 | data8 0x3FD98B7811A3EE5B // 125 | |
404 | data8 0x3FD9AF47F33D406C // 126 | |
405 | data8 0x3FD9DF270C1914A8 // 127 | |
406 | data8 0x3FDA0325ED14FDA4 // 128 | |
407 | data8 0x3FDA33440224FA79 // 129 | |
408 | data8 0x3FDA57725E80C383 // 130 | |
409 | data8 0x3FDA87D0165DD199 // 131 | |
410 | data8 0x3FDAAC2E6C03F896 // 132 | |
411 | data8 0x3FDADCCC6FDF6A81 // 133 | |
412 | data8 0x3FDB015B3EB1E790 // 134 | |
413 | data8 0x3FDB323A3A635948 // 135 | |
414 | data8 0x3FDB56FA04462909 // 136 | |
415 | data8 0x3FDB881AA659BC93 // 137 | |
416 | data8 0x3FDBAD0BEF3DB165 // 138 | |
417 | data8 0x3FDBD21297781C2F // 139 | |
418 | data8 0x3FDC039236F08819 // 140 | |
419 | data8 0x3FDC28CB1E4D32FD // 141 | |
420 | data8 0x3FDC4E19B84723C2 // 142 | |
421 | data8 0x3FDC7FF9C74554C9 // 143 | |
422 | data8 0x3FDCA57B64E9DB05 // 144 | |
423 | data8 0x3FDCCB130A5CEBB0 // 145 | |
424 | data8 0x3FDCF0C0D18F326F // 146 | |
425 | data8 0x3FDD232075B5A201 // 147 | |
426 | data8 0x3FDD490246DEFA6B // 148 | |
427 | data8 0x3FDD6EFA918D25CD // 149 | |
428 | data8 0x3FDD9509707AE52F // 150 | |
429 | data8 0x3FDDBB2EFE92C554 // 151 | |
430 | data8 0x3FDDEE2F3445E4AF // 152 | |
431 | data8 0x3FDE148A1A2726CE // 153 | |
432 | data8 0x3FDE3AFC0A49FF40 // 154 | |
433 | data8 0x3FDE6185206D516E // 155 | |
434 | data8 0x3FDE882578823D52 // 156 | |
435 | data8 0x3FDEAEDD2EAC990C // 157 | |
436 | data8 0x3FDED5AC5F436BE3 // 158 | |
437 | data8 0x3FDEFC9326D16AB9 // 159 | |
438 | data8 0x3FDF2391A2157600 // 160 | |
439 | data8 0x3FDF4AA7EE03192D // 161 | |
440 | data8 0x3FDF71D627C30BB0 // 162 | |
441 | data8 0x3FDF991C6CB3B379 // 163 | |
442 | data8 0x3FDFC07ADA69A910 // 164 | |
443 | data8 0x3FDFE7F18EB03D3E // 165 | |
444 | data8 0x3FE007C053C5002E // 166 | |
445 | data8 0x3FE01B942198A5A1 // 167 | |
446 | data8 0x3FE02F74400C64EB // 168 | |
447 | data8 0x3FE04360BE7603AD // 169 | |
448 | data8 0x3FE05759AC47FE34 // 170 | |
449 | data8 0x3FE06B5F1911CF52 // 171 | |
450 | data8 0x3FE078BF0533C568 // 172 | |
451 | data8 0x3FE08CD9687E7B0E // 173 | |
452 | data8 0x3FE0A10074CF9019 // 174 | |
453 | data8 0x3FE0B5343A234477 // 175 | |
454 | data8 0x3FE0C974C89431CE // 176 | |
455 | data8 0x3FE0DDC2305B9886 // 177 | |
456 | data8 0x3FE0EB524BAFC918 // 178 | |
457 | data8 0x3FE0FFB54213A476 // 179 | |
458 | data8 0x3FE114253DA97D9F // 180 | |
459 | data8 0x3FE128A24F1D9AFF // 181 | |
460 | data8 0x3FE1365252BF0865 // 182 | |
461 | data8 0x3FE14AE558B4A92D // 183 | |
462 | data8 0x3FE15F85A19C765B // 184 | |
463 | data8 0x3FE16D4D38C119FA // 185 | |
464 | data8 0x3FE18203C20DD133 // 186 | |
465 | data8 0x3FE196C7BC4B1F3B // 187 | |
466 | data8 0x3FE1A4A738B7A33C // 188 | |
467 | data8 0x3FE1B981C0C9653D // 189 | |
468 | data8 0x3FE1CE69E8BB106B // 190 | |
469 | data8 0x3FE1DC619DE06944 // 191 | |
470 | data8 0x3FE1F160A2AD0DA4 // 192 | |
471 | data8 0x3FE2066D7740737E // 193 | |
472 | data8 0x3FE2147DBA47A394 // 194 | |
473 | data8 0x3FE229A1BC5EBAC3 // 195 | |
474 | data8 0x3FE237C1841A502E // 196 | |
475 | data8 0x3FE24CFCE6F80D9A // 197 | |
476 | data8 0x3FE25B2C55CD5762 // 198 | |
477 | data8 0x3FE2707F4D5F7C41 // 199 | |
478 | data8 0x3FE285E0842CA384 // 200 | |
479 | data8 0x3FE294294708B773 // 201 | |
480 | data8 0x3FE2A9A2670AFF0C // 202 | |
481 | data8 0x3FE2B7FB2C8D1CC1 // 203 | |
482 | data8 0x3FE2C65A6395F5F5 // 204 | |
483 | data8 0x3FE2DBF557B0DF43 // 205 | |
484 | data8 0x3FE2EA64C3F97655 // 206 | |
485 | data8 0x3FE3001823684D73 // 207 | |
486 | data8 0x3FE30E97E9A8B5CD // 208 | |
487 | data8 0x3FE32463EBDD34EA // 209 | |
488 | data8 0x3FE332F4314AD796 // 210 | |
489 | data8 0x3FE348D90E7464D0 // 211 | |
490 | data8 0x3FE35779F8C43D6E // 212 | |
491 | data8 0x3FE36621961A6A99 // 213 | |
492 | data8 0x3FE37C299F3C366A // 214 | |
493 | data8 0x3FE38AE2171976E7 // 215 | |
494 | data8 0x3FE399A157A603E7 // 216 | |
495 | data8 0x3FE3AFCCFE77B9D1 // 217 | |
496 | data8 0x3FE3BE9D503533B5 // 218 | |
497 | data8 0x3FE3CD7480B4A8A3 // 219 | |
498 | data8 0x3FE3E3C43918F76C // 220 | |
499 | data8 0x3FE3F2ACB27ED6C7 // 221 | |
500 | data8 0x3FE4019C2125CA93 // 222 | |
501 | data8 0x3FE4181061389722 // 223 | |
502 | data8 0x3FE42711518DF545 // 224 | |
503 | data8 0x3FE436194E12B6BF // 225 | |
504 | data8 0x3FE445285D68EA69 // 226 | |
505 | data8 0x3FE45BCC464C893A // 227 | |
506 | data8 0x3FE46AED21F117FC // 228 | |
507 | data8 0x3FE47A1527E8A2D3 // 229 | |
508 | data8 0x3FE489445EFFFCCC // 230 | |
509 | data8 0x3FE4A018BCB69835 // 231 | |
510 | data8 0x3FE4AF5A0C9D65D7 // 232 | |
511 | data8 0x3FE4BEA2A5BDBE87 // 233 | |
512 | data8 0x3FE4CDF28F10AC46 // 234 | |
513 | data8 0x3FE4DD49CF994058 // 235 | |
514 | data8 0x3FE4ECA86E64A684 // 236 | |
515 | data8 0x3FE503C43CD8EB68 // 237 | |
516 | data8 0x3FE513356667FC57 // 238 | |
517 | data8 0x3FE522AE0738A3D8 // 239 | |
518 | data8 0x3FE5322E26867857 // 240 | |
519 | data8 0x3FE541B5CB979809 // 241 | |
520 | data8 0x3FE55144FDBCBD62 // 242 | |
521 | data8 0x3FE560DBC45153C7 // 243 | |
522 | data8 0x3FE5707A26BB8C66 // 244 | |
523 | data8 0x3FE587F60ED5B900 // 245 | |
524 | data8 0x3FE597A7977C8F31 // 246 | |
525 | data8 0x3FE5A760D634BB8B // 247 | |
526 | data8 0x3FE5B721D295F10F // 248 | |
527 | data8 0x3FE5C6EA94431EF9 // 249 | |
528 | data8 0x3FE5D6BB22EA86F6 // 250 | |
529 | data8 0x3FE5E6938645D390 // 251 | |
530 | data8 0x3FE5F673C61A2ED2 // 252 | |
531 | data8 0x3FE6065BEA385926 // 253 | |
532 | data8 0x3FE6164BFA7CC06B // 254 | |
533 | data8 0x3FE62643FECF9743 // 255 | |
534 | LOCAL_OBJECT_END(logf_data) | |
535 | ||
536 | LOCAL_OBJECT_START(log10f_data) | |
537 | data8 0x3FDBCB7B1526E50E // 1/ln(10) | |
538 | // | |
539 | // ln(1/frcpa(1+i/256))/ln(10), i=0...255 | |
540 | data8 0x3F4BD27045BFD025 // 0 | |
541 | data8 0x3F64E84E793A474A // 1 | |
542 | data8 0x3F7175085AB85FF0 // 2 | |
543 | data8 0x3F787CFF9D9147A5 // 3 | |
544 | data8 0x3F7EA9D372B89FC8 // 4 | |
545 | data8 0x3F82DF9D95DA961C // 5 | |
546 | data8 0x3F866DF172D6372C // 6 | |
547 | data8 0x3F898D79EF5EEDF0 // 7 | |
548 | data8 0x3F8D22ADF3F9579D // 8 | |
549 | data8 0x3F9024231D30C398 // 9 | |
550 | data8 0x3F91F23A98897D4A // 10 | |
551 | data8 0x3F93881A7B818F9E // 11 | |
552 | data8 0x3F951F6E1E759E35 // 12 | |
553 | data8 0x3F96F2BCE7ADC5B4 // 13 | |
554 | data8 0x3F988D362CDF359E // 14 | |
555 | data8 0x3F9A292BAF010982 // 15 | |
556 | data8 0x3F9BC6A03117EB97 // 16 | |
557 | data8 0x3F9D65967DE3AB09 // 17 | |
558 | data8 0x3F9F061167FC31E8 // 18 | |
559 | data8 0x3FA05409E4F7819C // 19 | |
560 | data8 0x3FA125D0432EA20E // 20 | |
561 | data8 0x3FA1F85D440D299B // 21 | |
562 | data8 0x3FA2AD755749617D // 22 | |
563 | data8 0x3FA381772A00E604 // 23 | |
564 | data8 0x3FA45643E165A70B // 24 | |
565 | data8 0x3FA52BDD034475B8 // 25 | |
566 | data8 0x3FA5E3966B7E9295 // 26 | |
567 | data8 0x3FA6BAAF47C5B245 // 27 | |
568 | data8 0x3FA773B3E8C4F3C8 // 28 | |
569 | data8 0x3FA84C51EBEE8D15 // 29 | |
570 | data8 0x3FA906A6786FC1CB // 30 | |
571 | data8 0x3FA9C197ABF00DD7 // 31 | |
572 | data8 0x3FAA9C78712191F7 // 32 | |
573 | data8 0x3FAB58C09C8D637C // 33 | |
574 | data8 0x3FAC15A8BCDD7B7E // 34 | |
575 | data8 0x3FACD331E2C2967C // 35 | |
576 | data8 0x3FADB11ED766ABF4 // 36 | |
577 | data8 0x3FAE70089346A9E6 // 37 | |
578 | data8 0x3FAF2F96C6754AEE // 38 | |
579 | data8 0x3FAFEFCA8D451FD6 // 39 | |
580 | data8 0x3FB0585283764178 // 40 | |
581 | data8 0x3FB0B913AAC7D3A7 // 41 | |
582 | data8 0x3FB11A294F2569F6 // 42 | |
583 | data8 0x3FB16B51A2696891 // 43 | |
584 | data8 0x3FB1CD03ADACC8BE // 44 | |
585 | data8 0x3FB22F0BDD7745F5 // 45 | |
586 | data8 0x3FB2916ACA38D1E8 // 46 | |
587 | data8 0x3FB2F4210DF7663D // 47 | |
588 | data8 0x3FB346A6C3C49066 // 48 | |
589 | data8 0x3FB3A9FEBC60540A // 49 | |
590 | data8 0x3FB3FD0C10A3AA54 // 50 | |
591 | data8 0x3FB46107D3540A82 // 51 | |
592 | data8 0x3FB4C55DD16967FE // 52 | |
593 | data8 0x3FB51940330C000B // 53 | |
594 | data8 0x3FB56D620EE7115E // 54 | |
595 | data8 0x3FB5D2ABCF26178E // 55 | |
596 | data8 0x3FB6275AA5DEBF81 // 56 | |
597 | data8 0x3FB68D4EAF26D7EE // 57 | |
598 | data8 0x3FB6E28C5C54A28D // 58 | |
599 | data8 0x3FB7380B9665B7C8 // 59 | |
600 | data8 0x3FB78DCCC278E85B // 60 | |
601 | data8 0x3FB7F50C2CF2557A // 61 | |
602 | data8 0x3FB84B5FD5EAEFD8 // 62 | |
603 | data8 0x3FB8A1F6BAB2B226 // 63 | |
604 | data8 0x3FB8F8D144557BDF // 64 | |
605 | data8 0x3FB94FEFDCD61D92 // 65 | |
606 | data8 0x3FB9A752EF316149 // 66 | |
607 | data8 0x3FB9FEFAE7611EE0 // 67 | |
608 | data8 0x3FBA56E8325F5C87 // 68 | |
609 | data8 0x3FBAAF1B3E297BB4 // 69 | |
610 | data8 0x3FBB079479C372AD // 70 | |
611 | data8 0x3FBB6054553B12F7 // 71 | |
612 | data8 0x3FBBB95B41AB5CE6 // 72 | |
613 | data8 0x3FBC12A9B13FE079 // 73 | |
614 | data8 0x3FBC6C4017382BEA // 74 | |
615 | data8 0x3FBCB41FBA42686D // 75 | |
616 | data8 0x3FBD0E38CE73393F // 76 | |
617 | data8 0x3FBD689B2193F133 // 77 | |
618 | data8 0x3FBDC3472B1D2860 // 78 | |
619 | data8 0x3FBE0C06300D528B // 79 | |
620 | data8 0x3FBE6738190E394C // 80 | |
621 | data8 0x3FBEC2B50D208D9B // 81 | |
622 | data8 0x3FBF0C1C2B936828 // 82 | |
623 | data8 0x3FBF68216C9CC727 // 83 | |
624 | data8 0x3FBFB1F6381856F4 // 84 | |
625 | data8 0x3FC00742AF4CE5F8 // 85 | |
626 | data8 0x3FC02C64906512D2 // 86 | |
627 | data8 0x3FC05AF1E63E03B4 // 87 | |
628 | data8 0x3FC0804BEA723AA9 // 88 | |
629 | data8 0x3FC0AF1FD6711527 // 89 | |
630 | data8 0x3FC0D4B2A8805A00 // 90 | |
631 | data8 0x3FC0FA5EF136A06C // 91 | |
632 | data8 0x3FC1299A4FB3E306 // 92 | |
633 | data8 0x3FC14F806253C3ED // 93 | |
634 | data8 0x3FC175805D1587C1 // 94 | |
635 | data8 0x3FC19B9A637CA295 // 95 | |
636 | data8 0x3FC1CB5FC26EDE17 // 96 | |
637 | data8 0x3FC1F1B4E65F2590 // 97 | |
638 | data8 0x3FC218248B5DC3E5 // 98 | |
639 | data8 0x3FC23EAED62ADC76 // 99 | |
640 | data8 0x3FC26553EBD337BD // 100 | |
641 | data8 0x3FC28C13F1B11900 // 101 | |
642 | data8 0x3FC2BCAA14381386 // 102 | |
643 | data8 0x3FC2E3A740B7800F // 103 | |
644 | data8 0x3FC30ABFD8F333B6 // 104 | |
645 | data8 0x3FC331F403985097 // 105 | |
646 | data8 0x3FC35943E7A60690 // 106 | |
647 | data8 0x3FC380AFAC6E7C07 // 107 | |
648 | data8 0x3FC3A8377997B9E6 // 108 | |
649 | data8 0x3FC3CFDB771C9ADB // 109 | |
650 | data8 0x3FC3EDA90D39A5DF // 110 | |
651 | data8 0x3FC4157EC09505CD // 111 | |
652 | data8 0x3FC43D7113FB04C1 // 112 | |
653 | data8 0x3FC4658030AD1CCF // 113 | |
654 | data8 0x3FC48DAC404638F6 // 114 | |
655 | data8 0x3FC4B5F56CBBB869 // 115 | |
656 | data8 0x3FC4DE5BE05E7583 // 116 | |
657 | data8 0x3FC4FCBC0776FD85 // 117 | |
658 | data8 0x3FC525561E9256EE // 118 | |
659 | data8 0x3FC54E0DF3198865 // 119 | |
660 | data8 0x3FC56CAB7112BDE2 // 120 | |
661 | data8 0x3FC59597BA735B15 // 121 | |
662 | data8 0x3FC5BEA23A506FDA // 122 | |
663 | data8 0x3FC5DD7E08DE382F // 123 | |
664 | data8 0x3FC606BDD3F92355 // 124 | |
665 | data8 0x3FC6301C518A501F // 125 | |
666 | data8 0x3FC64F3770618916 // 126 | |
667 | data8 0x3FC678CC14C1E2D8 // 127 | |
668 | data8 0x3FC6981005ED2947 // 128 | |
669 | data8 0x3FC6C1DB5F9BB336 // 129 | |
670 | data8 0x3FC6E1488ECD2881 // 130 | |
671 | data8 0x3FC70B4B2E7E41B9 // 131 | |
672 | data8 0x3FC72AE209146BF9 // 132 | |
673 | data8 0x3FC7551C81BD8DCF // 133 | |
674 | data8 0x3FC774DD76CC43BE // 134 | |
675 | data8 0x3FC79F505DB00E88 // 135 | |
676 | data8 0x3FC7BF3BDE099F30 // 136 | |
677 | data8 0x3FC7E9E7CAC437F9 // 137 | |
678 | data8 0x3FC809FE4902D00D // 138 | |
679 | data8 0x3FC82A2757995CBE // 139 | |
680 | data8 0x3FC85525C625E098 // 140 | |
681 | data8 0x3FC8757A79831887 // 141 | |
682 | data8 0x3FC895E2058D8E03 // 142 | |
683 | data8 0x3FC8C13437695532 // 143 | |
684 | data8 0x3FC8E1C812EF32BE // 144 | |
685 | data8 0x3FC9026F112197E8 // 145 | |
686 | data8 0x3FC923294888880B // 146 | |
687 | data8 0x3FC94EEA4B8334F3 // 147 | |
688 | data8 0x3FC96FD1B639FC09 // 148 | |
689 | data8 0x3FC990CCA66229AC // 149 | |
690 | data8 0x3FC9B1DB33334843 // 150 | |
691 | data8 0x3FC9D2FD740E6607 // 151 | |
692 | data8 0x3FC9FF49EEDCB553 // 152 | |
693 | data8 0x3FCA209A84FBCFF8 // 153 | |
694 | data8 0x3FCA41FF1E43F02B // 154 | |
695 | data8 0x3FCA6377D2CE9378 // 155 | |
696 | data8 0x3FCA8504BAE0D9F6 // 156 | |
697 | data8 0x3FCAA6A5EEEBEFE3 // 157 | |
698 | data8 0x3FCAC85B878D7879 // 158 | |
699 | data8 0x3FCAEA259D8FFA0B // 159 | |
700 | data8 0x3FCB0C0449EB4B6B // 160 | |
701 | data8 0x3FCB2DF7A5C50299 // 161 | |
702 | data8 0x3FCB4FFFCA70E4D1 // 162 | |
703 | data8 0x3FCB721CD17157E3 // 163 | |
704 | data8 0x3FCB944ED477D4ED // 164 | |
705 | data8 0x3FCBB695ED655C7D // 165 | |
706 | data8 0x3FCBD8F2364AEC0F // 166 | |
707 | data8 0x3FCBFB63C969F4FF // 167 | |
708 | data8 0x3FCC1DEAC134D4E9 // 168 | |
709 | data8 0x3FCC4087384F4F80 // 169 | |
710 | data8 0x3FCC6339498F09E2 // 170 | |
711 | data8 0x3FCC86010FFC076C // 171 | |
712 | data8 0x3FCC9D3D065C5B42 // 172 | |
713 | data8 0x3FCCC029375BA07A // 173 | |
714 | data8 0x3FCCE32B66978BA4 // 174 | |
715 | data8 0x3FCD0643AFD51404 // 175 | |
716 | data8 0x3FCD29722F0DEA45 // 176 | |
717 | data8 0x3FCD4CB70070FE44 // 177 | |
718 | data8 0x3FCD6446AB3F8C96 // 178 | |
719 | data8 0x3FCD87B0EF71DB45 // 179 | |
720 | data8 0x3FCDAB31D1FE99A7 // 180 | |
721 | data8 0x3FCDCEC96FDC888F // 181 | |
722 | data8 0x3FCDE6908876357A // 182 | |
723 | data8 0x3FCE0A4E4A25C200 // 183 | |
724 | data8 0x3FCE2E2315755E33 // 184 | |
725 | data8 0x3FCE461322D1648A // 185 | |
726 | data8 0x3FCE6A0E95C7787B // 186 | |
727 | data8 0x3FCE8E216243DD60 // 187 | |
728 | data8 0x3FCEA63AF26E007C // 188 | |
729 | data8 0x3FCECA74ED15E0B7 // 189 | |
730 | data8 0x3FCEEEC692CCD25A // 190 | |
731 | data8 0x3FCF070A36B8D9C1 // 191 | |
732 | data8 0x3FCF2B8393E34A2D // 192 | |
733 | data8 0x3FCF5014EF538A5B // 193 | |
734 | data8 0x3FCF68833AF1B180 // 194 | |
735 | data8 0x3FCF8D3CD9F3F04F // 195 | |
736 | data8 0x3FCFA5C61ADD93E9 // 196 | |
737 | data8 0x3FCFCAA8567EBA7A // 197 | |
738 | data8 0x3FCFE34CC8743DD8 // 198 | |
739 | data8 0x3FD0042BFD74F519 // 199 | |
740 | data8 0x3FD016BDF6A18017 // 200 | |
741 | data8 0x3FD023262F907322 // 201 | |
742 | data8 0x3FD035CCED8D32A1 // 202 | |
743 | data8 0x3FD042430E869FFC // 203 | |
744 | data8 0x3FD04EBEC842B2E0 // 204 | |
745 | data8 0x3FD06182E84FD4AC // 205 | |
746 | data8 0x3FD06E0CB609D383 // 206 | |
747 | data8 0x3FD080E60BEC8F12 // 207 | |
748 | data8 0x3FD08D7E0D894735 // 208 | |
749 | data8 0x3FD0A06CC96A2056 // 209 | |
750 | data8 0x3FD0AD131F3B3C55 // 210 | |
751 | data8 0x3FD0C01771E775FB // 211 | |
752 | data8 0x3FD0CCCC3CAD6F4B // 212 | |
753 | data8 0x3FD0D986D91A34A9 // 213 | |
754 | data8 0x3FD0ECA9B8861A2D // 214 | |
755 | data8 0x3FD0F972F87FF3D6 // 215 | |
756 | data8 0x3FD106421CF0E5F7 // 216 | |
757 | data8 0x3FD11983EBE28A9D // 217 | |
758 | data8 0x3FD12661E35B785A // 218 | |
759 | data8 0x3FD13345D2779D3B // 219 | |
760 | data8 0x3FD146A6F597283A // 220 | |
761 | data8 0x3FD15399E81EA83D // 221 | |
762 | data8 0x3FD16092E5D3A9A6 // 222 | |
763 | data8 0x3FD17413C3B7AB5E // 223 | |
764 | data8 0x3FD1811BF629D6FB // 224 | |
765 | data8 0x3FD18E2A47B46686 // 225 | |
766 | data8 0x3FD19B3EBE1A4418 // 226 | |
767 | data8 0x3FD1AEE9017CB450 // 227 | |
768 | data8 0x3FD1BC0CED7134E2 // 228 | |
769 | data8 0x3FD1C93712ABC7FF // 229 | |
770 | data8 0x3FD1D66777147D3F // 230 | |
771 | data8 0x3FD1EA3BD1286E1C // 231 | |
772 | data8 0x3FD1F77BED932C4C // 232 | |
773 | data8 0x3FD204C25E1B031F // 233 | |
774 | data8 0x3FD2120F28CE69B1 // 234 | |
775 | data8 0x3FD21F6253C48D01 // 235 | |
776 | data8 0x3FD22CBBE51D60AA // 236 | |
777 | data8 0x3FD240CE4C975444 // 237 | |
778 | data8 0x3FD24E37F8ECDAE8 // 238 | |
779 | data8 0x3FD25BA8215AF7FC // 239 | |
780 | data8 0x3FD2691ECC29F042 // 240 | |
781 | data8 0x3FD2769BFFAB2E00 // 241 | |
782 | data8 0x3FD2841FC23952C9 // 242 | |
783 | data8 0x3FD291AA1A384978 // 243 | |
784 | data8 0x3FD29F3B0E15584B // 244 | |
785 | data8 0x3FD2B3A0EE479DF7 // 245 | |
786 | data8 0x3FD2C142842C09E6 // 246 | |
787 | data8 0x3FD2CEEACCB7BD6D // 247 | |
788 | data8 0x3FD2DC99CE82FF21 // 248 | |
789 | data8 0x3FD2EA4F902FD7DA // 249 | |
790 | data8 0x3FD2F80C186A25FD // 250 | |
791 | data8 0x3FD305CF6DE7B0F7 // 251 | |
792 | data8 0x3FD3139997683CE7 // 252 | |
793 | data8 0x3FD3216A9BB59E7C // 253 | |
794 | data8 0x3FD32F4281A3CEFF // 254 | |
795 | data8 0x3FD33D2150110092 // 255 | |
796 | LOCAL_OBJECT_END(log10f_data) | |
797 | ||
798 | ||
799 | // Code | |
800 | //============================================================== | |
801 | .section .text | |
802 | ||
803 | // logf has p13 true, p14 false | |
804 | // log10f has p14 true, p13 false | |
805 | ||
806 | GLOBAL_IEEE754_ENTRY(log10f) | |
807 | { .mfi | |
808 | getf.exp GR_Exp = f8 // if x is unorm then must recompute | |
809 | frcpa.s1 FR_RcpX,p0 = f1,f8 | |
810 | mov GR_05 = 0xFFFE // biased exponent of A2=0.5 | |
811 | } | |
812 | { .mlx | |
813 | addl GR_ad_T = @ltoff(log10f_data),gp | |
814 | movl GR_A3 = 0x3FD5555555555555 // double precision memory | |
815 | // representation of A3 | |
816 | };; | |
817 | { .mfi | |
818 | getf.sig GR_Sig = f8 // if x is unorm then must recompute | |
819 | fclass.m p8,p0 = f8,9 // is x positive unorm? | |
820 | sub GR_025 = GR_05,r0,1 // biased exponent of A4=0.25 | |
821 | } | |
822 | { .mlx | |
823 | ld8 GR_ad_T = [GR_ad_T] | |
824 | movl GR_Ln2 = 0x3FD34413509F79FF // double precision memory | |
825 | // representation of | |
826 | // log(2)/ln(10) | |
827 | };; | |
828 | { .mfi | |
829 | setf.d FR_A3 = GR_A3 // create A3 | |
830 | fcmp.eq.s1 p14,p13 = f0,f0 // set p14 to 1 for log10f | |
831 | dep.z GR_xorg = GR_05,55,8 // 0x7F00000000000000 integer number | |
832 | // bits of that are | |
833 | // GR_xorg[63] = last bit of biased | |
834 | // exponent of 255/256 | |
835 | // GR_xorg[62-0] = bits from 62 to 0 | |
836 | // of significand of 255/256 | |
837 | } | |
838 | { .mib | |
839 | setf.exp FR_A2 = GR_05 // create A2 | |
840 | sub GR_de = GR_Exp,GR_05 // biased_exponent_of_x - 0xFFFE | |
841 | // needed to comparion with 0.5 and 2.0 | |
842 | br.cond.sptk logf_log10f_common | |
843 | };; | |
844 | GLOBAL_IEEE754_END(log10f) | |
845 | ||
846 | GLOBAL_IEEE754_ENTRY(logf) | |
847 | { .mfi | |
848 | getf.exp GR_Exp = f8 // if x is unorm then must recompute | |
849 | frcpa.s1 FR_RcpX,p0 = f1,f8 | |
850 | mov GR_05 = 0xFFFE // biased exponent of A2=-0.5 | |
851 | } | |
852 | { .mlx | |
853 | addl GR_ad_T = @ltoff(logf_data),gp | |
854 | movl GR_A3 = 0x3FD5555555555555 // double precision memory | |
855 | // representation of A3 | |
856 | };; | |
857 | { .mfi | |
858 | getf.sig GR_Sig = f8 // if x is unorm then must recompute | |
859 | fclass.m p8,p0 = f8,9 // is x positive unorm? | |
860 | dep.z GR_xorg = GR_05,55,8 // 0x7F00000000000000 integer number | |
861 | // bits of that are | |
862 | // GR_xorg[63] = last bit of biased | |
863 | // exponent of 255/256 | |
864 | // GR_xorg[62-0] = bits from 62 to 0 | |
865 | // of significand of 255/256 | |
866 | } | |
867 | { .mfi | |
868 | ld8 GR_ad_T = [GR_ad_T] | |
869 | nop.f 0 | |
870 | sub GR_025 = GR_05,r0,1 // biased exponent of A4=0.25 | |
871 | };; | |
872 | { .mfi | |
873 | setf.d FR_A3 = GR_A3 // create A3 | |
874 | fcmp.eq.s1 p13,p14 = f0,f0 // p13 - true for logf | |
875 | sub GR_de = GR_Exp,GR_05 // biased_exponent_of_x - 0xFFFE | |
876 | // needed to comparion with 0.5 and 2.0 | |
877 | } | |
878 | { .mlx | |
879 | setf.exp FR_A2 = GR_05 // create A2 | |
880 | movl GR_Ln2 = 0x3FE62E42FEFA39EF // double precision memory | |
881 | // representation of log(2) | |
882 | };; | |
883 | logf_log10f_common: | |
884 | { .mfi | |
885 | setf.exp FR_A4 = GR_025 // create A4=0.25 | |
886 | fclass.m p9,p0 = f8,0x3A // is x < 0 (including negateve unnormals)? | |
887 | dep GR_x = GR_Exp,GR_Sig,63,1 // produce integer that bits are | |
888 | // GR_x[63] = GR_Exp[0] | |
889 | // GR_x[62-0] = GR_Sig[62-0] | |
890 | } | |
891 | { .mib | |
892 | sub GR_N = GR_Exp,GR_05,1 // unbiased exponent of x | |
893 | cmp.gtu p6,p7 = 2,GR_de // is 0.5 <= x < 2.0? | |
894 | (p8) br.cond.spnt logf_positive_unorm | |
895 | };; | |
896 | logf_core: | |
897 | { .mfi | |
898 | setf.sig FR_N = GR_N // copy unbiased exponent of x to the | |
899 | // significand field of FR_N | |
900 | fclass.m p10,p0 = f8,0x1E1 // is x NaN, NaT or +Inf? | |
901 | dep.z GR_dx = GR_05,54,3 // 0x0180000000000000 - difference | |
902 | // between our integer representations | |
903 | // of 257/256 and 255/256 | |
904 | } | |
905 | { .mfi | |
906 | nop.m 0 | |
907 | nop.f 0 | |
908 | sub GR_x = GR_x,GR_xorg // difference between representations | |
909 | // of x and 255/256 | |
910 | };; | |
911 | { .mfi | |
912 | ldfd FR_InvLn10 = [GR_ad_T],8 | |
913 | fcmp.eq.s1 p11,p0 = f8,f1 // is x equal to 1.0? | |
914 | extr.u GR_Ind = GR_Sig,55,8 // get bits from 55 to 62 as index | |
915 | } | |
916 | { .mib | |
917 | setf.d FR_Ln2 = GR_Ln2 // create log(2) or log10(2) | |
918 | (p6) cmp.gtu p6,p7 = GR_dx,GR_x // set p6 if 255/256 <= x < 257/256 | |
919 | (p9) br.cond.spnt logf_negatives // jump if input argument is negative number | |
920 | };; | |
921 | // p6 is true if |x-1| < 1/256 | |
922 | // p7 is true if |x-1| >= 1/256 | |
923 | .pred.rel "mutex",p6,p7 | |
924 | { .mfi | |
925 | shladd GR_ad_T = GR_Ind,3,GR_ad_T // calculate address of T | |
926 | (p7) fms.s1 FR_r = FR_RcpX,f8,f1 // range reduction for |x-1|>=1/256 | |
927 | extr.u GR_Exp = GR_Exp,0,17 // exponent without sign | |
928 | } | |
929 | { .mfb | |
930 | nop.m 0 | |
931 | (p6) fms.s1 FR_r = f8,f1,f1 // range reduction for |x-1|<1/256 | |
932 | (p10) br.cond.spnt logf_nan_nat_pinf // exit for NaN, NaT or +Inf | |
933 | };; | |
934 | { .mfb | |
935 | ldfd FR_T = [GR_ad_T] // load T | |
936 | (p11) fma.s.s0 f8 = f0,f0,f0 | |
937 | (p11) br.ret.spnt b0 // exit for x = 1.0 | |
938 | };; | |
939 | { .mib | |
940 | nop.m 0 | |
941 | cmp.eq p12,p0 = r0,GR_Exp // is x +/-0? (here it's quite enough | |
942 | // only to compare exponent with 0 | |
943 | // because all unnormals already | |
944 | // have been filtered) | |
945 | (p12) br.cond.spnt logf_zeroes // Branch if input argument is +/-0 | |
946 | };; | |
947 | { .mfi | |
948 | nop.m 0 | |
949 | fnma.s1 FR_A2 = FR_A2,FR_r,f1 // A2*r+1 | |
950 | nop.i 0 | |
951 | } | |
952 | { .mfi | |
953 | nop.m 0 | |
954 | fma.s1 FR_r2 = FR_r,FR_r,f0 // r^2 | |
955 | nop.i 0 | |
956 | };; | |
957 | { .mfi | |
958 | nop.m 0 | |
959 | fcvt.xf FR_N = FR_N // convert integer N in significand of FR_N | |
960 | // to floating-point representation | |
961 | nop.i 0 | |
962 | } | |
963 | { .mfi | |
964 | nop.m 0 | |
965 | fnma.s1 FR_A3 = FR_A4,FR_r,FR_A3 // A4*r+A3 | |
966 | nop.i 0 | |
967 | };; | |
968 | { .mfi | |
969 | nop.m 0 | |
970 | fma.s1 FR_r = FR_r,FR_InvLn10,f0 // For log10f we have r/log(10) | |
971 | nop.i 0 | |
972 | } | |
973 | { .mfi | |
974 | nop.m 0 | |
975 | nop.f 0 | |
976 | nop.i 0 | |
977 | };; | |
978 | { .mfi | |
979 | nop.m 0 | |
980 | fma.s1 FR_A2 = FR_A3,FR_r2,FR_A2 // (A4*r+A3)*r^2+(A2*r+1) | |
981 | nop.i 0 | |
982 | } | |
983 | { .mfi | |
984 | nop.m 0 | |
985 | fma.s1 FR_NxLn2pT = FR_N,FR_Ln2,FR_T // N*Ln2+T | |
986 | nop.i 0 | |
987 | };; | |
988 | .pred.rel "mutex",p6,p7 | |
989 | { .mfi | |
990 | nop.m 0 | |
991 | (p7) fma.s.s0 f8 = FR_A2,FR_r,FR_NxLn2pT // result for |x-1|>=1/256 | |
992 | nop.i 0 | |
993 | } | |
994 | { .mfb | |
995 | nop.m 0 | |
996 | (p6) fma.s.s0 f8 = FR_A2,FR_r,f0 // result for |x-1|<1/256 | |
997 | br.ret.sptk b0 | |
998 | };; | |
999 | ||
1000 | .align 32 | |
1001 | logf_positive_unorm: | |
1002 | { .mfi | |
1003 | nop.m 0 | |
1004 | (p8) fma.s0 f8 = f8,f1,f0 // Normalize & set D-flag | |
1005 | nop.i 0 | |
1006 | };; | |
1007 | { .mfi | |
1008 | getf.exp GR_Exp = f8 // recompute biased exponent | |
1009 | nop.f 0 | |
1010 | cmp.ne p6,p7 = r0,r0 // p6 <- 0, p7 <- 1 because | |
1011 | // in case of unorm we are out | |
1012 | // interval [255/256; 257/256] | |
1013 | };; | |
1014 | { .mfi | |
1015 | getf.sig GR_Sig = f8 // recompute significand | |
1016 | nop.f 0 | |
1017 | nop.i 0 | |
1018 | };; | |
1019 | { .mib | |
1020 | sub GR_N = GR_Exp,GR_05,1 // unbiased exponent N | |
1021 | nop.i 0 | |
1022 | br.cond.sptk logf_core // return into main path | |
1023 | };; | |
1024 | ||
1025 | .align 32 | |
1026 | logf_nan_nat_pinf: | |
1027 | { .mfi | |
1028 | nop.m 0 | |
1029 | fma.s.s0 f8 = f8,f1,f0 // set V-flag | |
1030 | nop.i 0 | |
1031 | } | |
1032 | { .mfb | |
1033 | nop.m 0 | |
1034 | nop.f 0 | |
1035 | br.ret.sptk b0 // exit for NaN, NaT or +Inf | |
1036 | };; | |
1037 | ||
1038 | .align 32 | |
1039 | logf_zeroes: | |
1040 | { .mfi | |
1041 | nop.m 0 | |
1042 | fmerge.s FR_X = f8,f8 // keep input argument for subsequent | |
1043 | // call of __libm_error_support# | |
1044 | nop.i 0 | |
1045 | } | |
1046 | { .mfi | |
1047 | (p13) mov GR_TAG = 4 // set libm error in case of logf | |
1048 | fms.s1 FR_tmp = f0,f0,f1 // -1.0 | |
1049 | nop.i 0 | |
1050 | };; | |
1051 | { .mfi | |
1052 | nop.m 0 | |
1053 | frcpa.s0 f8,p0 = FR_tmp,f0 // log(+/-0) should be equal to -INF. | |
1054 | // We can get it using frcpa because it | |
1055 | // sets result to the IEEE-754 mandated | |
1056 | // quotient of FR_tmp/f0. | |
1057 | // As far as FR_tmp is -1 it'll be -INF | |
1058 | nop.i 0 | |
1059 | } | |
1060 | { .mib | |
1061 | (p14) mov GR_TAG = 10 // set libm error in case of log10f | |
1062 | nop.i 0 | |
1063 | br.cond.sptk logf_libm_err | |
1064 | };; | |
1065 | ||
1066 | .align 32 | |
1067 | logf_negatives: | |
1068 | { .mfi | |
1069 | (p13) mov GR_TAG = 5 // set libm error in case of logf | |
1070 | fmerge.s FR_X = f8,f8 // keep input argument for subsequent | |
1071 | // call of __libm_error_support# | |
1072 | nop.i 0 | |
1073 | };; | |
1074 | { .mfi | |
1075 | (p14) mov GR_TAG = 11 // set libm error in case of log10f | |
1076 | frcpa.s0 f8,p0 = f0,f0 // log(negatives) should be equal to NaN. | |
1077 | // We can get it using frcpa because it | |
1078 | // sets result to the IEEE-754 mandated | |
1079 | // quotient of f0/f0 i.e. NaN. | |
1080 | nop.i 0 | |
1081 | };; | |
1082 | ||
1083 | .align 32 | |
1084 | logf_libm_err: | |
1085 | { .mmi | |
1086 | alloc r32 = ar.pfs,1,4,4,0 | |
1087 | mov GR_Parameter_TAG = GR_TAG | |
1088 | nop.i 0 | |
1089 | };; | |
1090 | GLOBAL_IEEE754_END(logf) | |
1091 | ||
1092 | ||
1093 | // Stack operations when calling error support. | |
1094 | // (1) (2) (3) (call) (4) | |
1095 | // sp -> + psp -> + psp -> + sp -> + | |
1096 | // | | | | | |
1097 | // | | <- GR_Y R3 ->| <- GR_RESULT | -> f8 | |
1098 | // | | | | | |
1099 | // | <-GR_Y Y2->| Y2 ->| <- GR_Y | | |
1100 | // | | | | | |
1101 | // | | <- GR_X X1 ->| | | |
1102 | // | | | | | |
1103 | // sp-64 -> + sp -> + sp -> + + | |
1104 | // save ar.pfs save b0 restore gp | |
1105 | // save gp restore ar.pfs | |
1106 | ||
1107 | LOCAL_LIBM_ENTRY(__libm_error_region) | |
1108 | .prologue | |
1109 | { .mfi | |
1110 | add GR_Parameter_Y=-32,sp // Parameter 2 value | |
1111 | nop.f 0 | |
1112 | .save ar.pfs,GR_SAVE_PFS | |
1113 | mov GR_SAVE_PFS=ar.pfs // Save ar.pfs | |
1114 | } | |
1115 | { .mfi | |
1116 | .fframe 64 | |
1117 | add sp=-64,sp // Create new stack | |
1118 | nop.f 0 | |
1119 | mov GR_SAVE_GP=gp // Save gp | |
1120 | };; | |
1121 | { .mmi | |
1122 | stfs [GR_Parameter_Y] = FR_Y,16 // STORE Parameter 2 on stack | |
1123 | add GR_Parameter_X = 16,sp // Parameter 1 address | |
1124 | .save b0, GR_SAVE_B0 | |
1125 | mov GR_SAVE_B0=b0 // Save b0 | |
1126 | };; | |
1127 | .body | |
1128 | { .mib | |
1129 | stfs [GR_Parameter_X] = FR_X // STORE Parameter 1 on stack | |
1130 | add GR_Parameter_RESULT = 0,GR_Parameter_Y // Parameter 3 address | |
1131 | nop.b 0 | |
1132 | } | |
1133 | { .mib | |
1134 | stfs [GR_Parameter_Y] = FR_RESULT // STORE Parameter 3 on stack | |
1135 | add GR_Parameter_Y = -16,GR_Parameter_Y | |
1136 | br.call.sptk b0=__libm_error_support# // Call error handling function | |
1137 | };; | |
1138 | { .mmi | |
1139 | nop.m 0 | |
1140 | nop.m 0 | |
1141 | add GR_Parameter_RESULT = 48,sp | |
1142 | };; | |
1143 | { .mmi | |
1144 | ldfs f8 = [GR_Parameter_RESULT] // Get return result off stack | |
1145 | .restore sp | |
1146 | add sp = 64,sp // Restore stack pointer | |
1147 | mov b0 = GR_SAVE_B0 // Restore return address | |
1148 | };; | |
1149 | { .mib | |
1150 | mov gp = GR_SAVE_GP // Restore gp | |
1151 | mov ar.pfs = GR_SAVE_PFS // Restore ar.pfs | |
1152 | br.ret.sptk b0 // Return | |
1153 | };; | |
1154 | ||
1155 | LOCAL_LIBM_END(__libm_error_region) | |
1156 | ||
1157 | .type __libm_error_support#,@function | |
1158 | .global __libm_error_support# | |
1159 |