1.file "exp10l.s"
2
3
4// Copyright (c) 2000 - 2004, Intel Corporation
5// All rights reserved.
6//
7//
8// Redistribution and use in source and binary forms, with or without
9// modification, are permitted provided that the following conditions are
10// met:
11//
12// * Redistributions of source code must retain the above copyright
13// notice, this list of conditions and the following disclaimer.
14//
15// * Redistributions in binary form must reproduce the above copyright
16// notice, this list of conditions and the following disclaimer in the
17// documentation and/or other materials provided with the distribution.
18//
19// * The name of Intel Corporation may not be used to endorse or promote
20// products derived from this software without specific prior written
21// permission.
22
23// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR ITS
27// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
29// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
31// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR TORT (INCLUDING
32// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34//
35// Intel Corporation is the author of this code, and requests that all
36// problem reports or change requests be submitted to it directly at
37// http://www.intel.com/software/products/opensource/libraries/num.htm.
38//
39// History
40//==============================================================
41// 08/25/00 Initial version
42// 05/20/02 Cleaned up namespace and sf0 syntax
43// 02/06/03 Reordered header: .section, .global, .proc, .align
44// 05/08/03 Reformatted assembly source; corrected overflow result for round to
45//          -inf and round to zero; exact results now don't set inexact flag
46// 12/16/04 Call error handling on underflow.
47//
48// API
49//==============================================================
50// long double exp10l(long double)
51//
52// Overview of operation
53//==============================================================
54// Background
55//
56// Implementation
57//
58// Let x= (K + f + r)/log2(10), where
59// K is an integer, f= 0.b1 b2... b8 (f>= 0),
60// and |r|<2^{-9}
61// T is a table that stores 2^f (256 entries) rounded to
62// double extended precision (only mantissa is stored)
63// D stores (2^f/T [ f ] - 1), rounded to single precision
64//
65// 10^x is approximated as
66// 2^K * T [ f ] * ((1+c1*r+c2*r^2+...+c6*r^6)*(1+c1*e)+D [ f ] ),
67// where e= log2(10)_lo*x+(log2(10)_hi*x-RN(log2(10)_hi*x))
68//
69
70
71
72// Special values
73//==============================================================
74// exp10(0)= 1
75// exp10(+inf)= inf
76// exp10(-inf)= 0
77//
78
79
80// Registers used
81//==============================================================
82// f6-f15, f32-f63
83// r14-r30, r32-r40
84// p6-p8, p11-p14
85//
86
87#include <shlib-compat.h>
88
89
90       FR_X        = f10
91       FR_Y        = f1
92       FR_RESULT   = f8
93
94       FR_COEFF1   = f6
95       FR_COEFF2   = f7
96       FR_KF0      = f9
97       FR_LOG10    = f10
98       FR_CONST1   = f11
99       FR_XL10     = f12
100       FR_COEFF3   = f13
101       FR_COEFF4   = f14
102       FR_UF_TEST  = f15
103       FR_OF_TEST  = f32
104       FR_L10_LOW  = f33
105       FR_COEFF5   = f34
106       FR_COEFF6   = f35
107       FR_L10      = f36
108       FR_C_L10    = f37
109       FR_XL10_H   = f38
110       FR_XL10_L   = f39
111       FR_KF       = f40
112       FR_E        = f41
113       FR_T        = f42
114       FR_D        = f43
115       FR_EXP_M_63 = f44
116       FR_R        = f45
117       FR_E1       = f46
118       FR_COEFF2   = f47
119       FR_P34      = f48
120       FR_P56      = f49
121       FR_R2       = f50
122       FR_RE       = f51
123       FR_D1       = f52
124       FR_P36      = f53
125       FR_R3E      = f54
126       FR_P1       = f55
127       FR_P        = f56
128       FR_T1       = f57
129       FR_XINT     = f58
130       FR_XINTF    = f59
131       FR_4        = f60
132       FR_28       = f61
133       FR_32       = f62
134       FR_SNORM_LIMIT = f63
135
136
137       GR_ADDR0    = r14
138       GR_D_ADDR   = r15
139       GR_ADDR     = r16
140       GR_B63      = r17
141       GR_KBITS    = r18
142       GR_F        = r19
143       GR_K        = r20
144       GR_D        = r21
145       GR_BM63     = r22
146       GR_T        = r23
147       GR_CONST1   = r24
148       GR_EMIN     = r25
149       GR_CONST2   = r26
150       GR_BM8      = r27
151       GR_SREG     = r28
152       GR_4_BIAS   = r29
153       GR_32_BIAS  = r30
154
155       GR_SAVE_B0  = r33
156       GR_SAVE_PFS = r34
157       GR_SAVE_GP  = r35
158       GR_SAVE_SP  = r36
159
160       GR_Parameter_X     = r37
161       GR_Parameter_Y     = r38
162       GR_Parameter_RESULT= r39
163       GR_Parameter_TAG   = r40
164
165
166// Data tables
167//==============================================================
168
169RODATA
170
171.align 16
172
173LOCAL_OBJECT_START(poly_coeffs)
174
175       data8 0xd49a784bcd1b8afe, 0x00004008 // log2(10)*2^8
176       data8 0x9a209a84fbcff798, 0x0000400b // overflow threshold
177       data8 0xb17217f7d1cf79ab, 0x00003ffe // C_1
178       data8 0xf5fdeffc162c7541, 0x00003ffc // C_2
179       data8 0x3fac6b08d704a0c0 // C_3
180       data8 0x3f83b2ab6fba4e77 // C_4
181       data8 0x3f55d87fe78a6731 // C_5
182       data8 0x3f2430912f86c787 // C_6
183       data8 0x9257edfe9b5fb698, 0x00003fbf // log2(10)_low (bits 64...127)
184       data8 0x9a1bc98027a81918, 0x0000c00b // Smallest normal threshold
185LOCAL_OBJECT_END(poly_coeffs)
186
187
188LOCAL_OBJECT_START(T_table)
189
190       // 2^{0.b1 b2 b3 b4 b5 b6 b7 b8}
191       data8 0x8000000000000000, 0x8058d7d2d5e5f6b1
192       data8 0x80b1ed4fd999ab6c, 0x810b40a1d81406d4
193       data8 0x8164d1f3bc030773, 0x81bea1708dde6056
194       data8 0x8218af4373fc25ec, 0x8272fb97b2a5894c
195       data8 0x82cd8698ac2ba1d7, 0x83285071e0fc4547
196       data8 0x8383594eefb6ee37, 0x83dea15b9541b132
197       data8 0x843a28c3acde4046, 0x8495efb3303efd30
198       data8 0x84f1f656379c1a29, 0x854e3cd8f9c8c95d
199       data8 0x85aac367cc487b15, 0x86078a2f23642a9f
200       data8 0x8664915b923fba04, 0x86c1d919caef5c88
201       data8 0x871f61969e8d1010, 0x877d2afefd4e256c
202       data8 0x87db357ff698d792, 0x88398146b919f1d4
203       data8 0x88980e8092da8527, 0x88f6dd5af155ac6b
204       data8 0x8955ee03618e5fdd, 0x89b540a7902557a4
205       data8 0x8a14d575496efd9a, 0x8a74ac9a79896e47
206       data8 0x8ad4c6452c728924, 0x8b3522a38e1e1032
207       data8 0x8b95c1e3ea8bd6e7, 0x8bf6a434adde0085
208       data8 0x8c57c9c4646f4dde, 0x8cb932c1bae97a95
209       data8 0x8d1adf5b7e5ba9e6, 0x8d7ccfc09c50e2f8
210       data8 0x8ddf042022e69cd6, 0x8e417ca940e35a01
211       data8 0x8ea4398b45cd53c0, 0x8f073af5a2013520
212       data8 0x8f6a8117e6c8e5c4, 0x8fce0c21c6726481
213       data8 0x9031dc431466b1dc, 0x9095f1abc540ca6b
214       data8 0x90fa4c8beee4b12b, 0x915eed13c89689d3
215       data8 0x91c3d373ab11c336, 0x9228ffdc10a051ad
216       data8 0x928e727d9531f9ac, 0x92f42b88f673aa7c
217       data8 0x935a2b2f13e6e92c, 0x93c071a0eef94bc1
218       data8 0x9426ff0fab1c04b6, 0x948dd3ac8ddb7ed3
219       data8 0x94f4efa8fef70961, 0x955c5336887894d5
220       data8 0x95c3fe86d6cc7fef, 0x962bf1cbb8d97560
221       data8 0x96942d3720185a00, 0x96fcb0fb20ac4ba3
222       data8 0x97657d49f17ab08e, 0x97ce9255ec4357ab
223       data8 0x9837f0518db8a96f, 0x98a1976f7597e996
224       data8 0x990b87e266c189aa, 0x9975c1dd47518c77
225       data8 0x99e0459320b7fa65, 0x9a4b13371fd166ca
226       data8 0x9ab62afc94ff864a, 0x9b218d16f441d63d
227       data8 0x9b8d39b9d54e5539, 0x9bf93118f3aa4cc1
228       data8 0x9c6573682ec32c2d, 0x9cd200db8a0774cb
229       data8 0x9d3ed9a72cffb751, 0x9dabfdff6367a2aa
230       data8 0x9e196e189d472420, 0x9e872a276f0b98ff
231       data8 0x9ef5326091a111ae, 0x9f6386f8e28ba651
232       data8 0x9fd228256400dd06, 0xa041161b3d0121be
233       data8 0xa0b0510fb9714fc2, 0xa11fd9384a344cf7
234       data8 0xa18faeca8544b6e4, 0xa1ffd1fc25cea188
235       data8 0xa27043030c496819, 0xa2e102153e918f9e
236       data8 0xa3520f68e802bb93, 0xa3c36b345991b47c
237       data8 0xa43515ae09e6809e, 0xa4a70f0c95768ec5
238       data8 0xa5195786be9ef339, 0xa58bef536dbeb6ee
239       data8 0xa5fed6a9b15138ea, 0xa6720dc0be08a20c
240       data8 0xa6e594cfeee86b1e, 0xa7596c0ec55ff55b
241       data8 0xa7cd93b4e965356a, 0xa8420bfa298f70d1
242       data8 0xa8b6d5167b320e09, 0xa92bef41fa77771b
243       data8 0xa9a15ab4ea7c0ef8, 0xaa1717a7b5693979
244       data8 0xaa8d2652ec907629, 0xab0386ef48868de1
245       data8 0xab7a39b5a93ed337, 0xabf13edf162675e9
246       data8 0xac6896a4be3fe929, 0xace0413ff83e5d04
247       data8 0xad583eea42a14ac6, 0xadd08fdd43d01491
248       data8 0xae493452ca35b80e, 0xaec22c84cc5c9465
249       data8 0xaf3b78ad690a4375, 0xafb51906e75b8661
250       data8 0xb02f0dcbb6e04584, 0xb0a957366fb7a3c9
251       data8 0xb123f581d2ac2590, 0xb19ee8e8c94feb09
252       data8 0xb21a31a66618fe3b, 0xb295cff5e47db4a4
253       data8 0xb311c412a9112489, 0xb38e0e38419fae18
254       data8 0xb40aaea2654b9841, 0xb487a58cf4a9c180
255       data8 0xb504f333f9de6484, 0xb58297d3a8b9f0d2
256       data8 0xb60093a85ed5f76c, 0xb67ee6eea3b22b8f
257       data8 0xb6fd91e328d17791, 0xb77c94c2c9d725e9
258       data8 0xb7fbefca8ca41e7c, 0xb87ba337a1743834
259       data8 0xb8fbaf4762fb9ee9, 0xb97c143756844dbf
260       data8 0xb9fcd2452c0b9deb, 0xba7de9aebe5fea09
261       data8 0xbaff5ab2133e45fb, 0xbb81258d5b704b6f
262       data8 0xbc034a7ef2e9fb0d, 0xbc85c9c560e7b269
263       data8 0xbd08a39f580c36bf, 0xbd8bd84bb67ed483
264       data8 0xbe0f6809860993e2, 0xbe935317fc378238
265       data8 0xbf1799b67a731083, 0xbf9c3c248e2486f8
266       data8 0xc0213aa1f0d08db0, 0xc0a6956e8836ca8d
267       data8 0xc12c4cca66709456, 0xc1b260f5ca0fbb33
268       data8 0xc238d2311e3d6673, 0xc2bfa0bcfad907c9
269       data8 0xc346ccda24976407, 0xc3ce56c98d21b15d
270       data8 0xc4563ecc5334cb33, 0xc4de8523c2c07baa
271       data8 0xc5672a115506dadd, 0xc5f02dd6b0bbc3d9
272       data8 0xc67990b5aa245f79, 0xc70352f04336c51e
273       data8 0xc78d74c8abb9b15d, 0xc817f681416452b2
274       data8 0xc8a2d85c8ffe2c45, 0xc92e1a9d517f0ecc
275       data8 0xc9b9bd866e2f27a3, 0xca45c15afcc72624
276       data8 0xcad2265e4290774e, 0xcb5eecd3b38597c9
277       data8 0xcbec14fef2727c5d, 0xcc799f23d11510e5
278       data8 0xcd078b86503dcdd2, 0xcd95da6a9ff06445
279       data8 0xce248c151f8480e4, 0xceb3a0ca5dc6a55d
280       data8 0xcf4318cf191918c1, 0xcfd2f4683f94eeb5
281       data8 0xd06333daef2b2595, 0xd0f3d76c75c5db8d
282       data8 0xd184df6251699ac6, 0xd2164c023056bcab
283       data8 0xd2a81d91f12ae45a, 0xd33a5457a3029054
284       data8 0xd3ccf099859ac379, 0xd45ff29e0972c561
285       data8 0xd4f35aabcfedfa1f, 0xd5872909ab75d18a
286       data8 0xd61b5dfe9f9bce07, 0xd6aff9d1e13ba2fe
287       data8 0xd744fccad69d6af4, 0xd7da67311797f56a
288       data8 0xd870394c6db32c84, 0xd9067364d44a929c
289       data8 0xd99d15c278afd7b6, 0xda3420adba4d8704
290       data8 0xdacb946f2ac9cc72, 0xdb63714f8e295255
291       data8 0xdbfbb797daf23755, 0xdc9467913a4f1c92
292       data8 0xdd2d818508324c20, 0xddc705bcd378f7f0
293       data8 0xde60f4825e0e9124, 0xdefb4e1f9d1037f2
294       data8 0xdf9612deb8f04420, 0xe031430a0d99e627
295       data8 0xe0ccdeec2a94e111, 0xe168e6cfd3295d23
296       data8 0xe2055afffe83d369, 0xe2a23bc7d7d91226
297       data8 0xe33f8972be8a5a51, 0xe3dd444c46499619
298       data8 0xe47b6ca0373da88d, 0xe51a02ba8e26d681
299       data8 0xe5b906e77c8348a8, 0xe658797368b3a717
300       data8 0xe6f85aaaee1fce22, 0xe798aadadd5b9cbf
301       data8 0xe8396a503c4bdc68, 0xe8da9958464b42ab
302       data8 0xe97c38406c4f8c57, 0xea1e4756550eb27b
303       data8 0xeac0c6e7dd24392f, 0xeb63b74317369840
304       data8 0xec0718b64c1cbddc, 0xecaaeb8ffb03ab41
305       data8 0xed4f301ed9942b84, 0xedf3e6b1d418a491
306       data8 0xee990f980da3025b, 0xef3eab20e032bc6b
307       data8 0xefe4b99bdcdaf5cb, 0xf08b3b58cbe8b76a
308       data8 0xf13230a7ad094509, 0xf1d999d8b7708cc1
309       data8 0xf281773c59ffb13a, 0xf329c9233b6bae9c
310       data8 0xf3d28fde3a641a5b, 0xf47bcbbe6db9fddf
311       data8 0xf5257d152486cc2c, 0xf5cfa433e6537290
312       data8 0xf67a416c733f846e, 0xf7255510c4288239
313       data8 0xf7d0df730ad13bb9, 0xf87ce0e5b2094d9c
314       data8 0xf92959bb5dd4ba74, 0xf9d64a46eb939f35
315       data8 0xfa83b2db722a033a, 0xfb3193cc4227c3f4
316       data8 0xfbdfed6ce5f09c49, 0xfc8ec01121e447bb
317       data8 0xfd3e0c0cf486c175, 0xfdedd1b496a89f35
318       data8 0xfe9e115c7b8f884c, 0xff4ecb59511ec8a5
319LOCAL_OBJECT_END(T_table)
320
321
322LOCAL_OBJECT_START(D_table)
323       data4 0x00000000, 0x9f55c08f, 0x1e93ffa3, 0x1dcd43a8
324       data4 0x1f751f79, 0x9f3cdd88, 0x9f43d155, 0x1eda222c
325       data4 0x1ef35513, 0x9f597895, 0x9e698881, 0x1ec71073
326       data4 0x1e50e371, 0x9dc01e19, 0x1de74133, 0x1e2f028c
327       data4 0x9edefb47, 0x1ebbac48, 0x9e8b0330, 0x9e9e9314
328       data4 0x1edc1d11, 0x1f098529, 0x9f52827c, 0x1f50050d
329       data4 0x1f301e8e, 0x1f5b64d1, 0x9f45e3ee, 0x9ef64d6d
330       data4 0x1d6ec5e8, 0x9e61ad9a, 0x1d44ccbb, 0x9e4a8bbb
331       data4 0x9cf11576, 0x9dcce7e7, 0x9d02ac90, 0x1f26ccf0
332       data4 0x9f0877c6, 0x9ddd62ae, 0x9f4b7fc3, 0x1ea8ef6b
333       data4 0x1ea4378d, 0x1ef6fc38, 0x1db99fd9, 0x1f22bf6f
334       data4 0x1f53e172, 0x1e85504a, 0x9f37cc75, 0x1f0c5e17
335       data4 0x1dde8aac, 0x9cb42bb2, 0x1e153cd7, 0x1eb62bba
336       data4 0x9e9b941b, 0x9ea80e3c, 0x1f508823, 0x1ec3fd36
337       data4 0x1e9ffaa1, 0x1e21e2eb, 0x9d948b1d, 0x9e8ac93a
338       data4 0x1ef7ee6f, 0x9e80dda3, 0x1f0814be, 0x1dc5ddfe
339       data4 0x1eedb9d1, 0x9f2aaa26, 0x9ea5b0fc, 0x1edf702e
340       data4 0x9e391201, 0x1f1316bb, 0x1ea27fb7, 0x9e05ed18
341       data4 0x9f199ed2, 0x1ee7fd7c, 0x1f003db6, 0x9eac3793
342       data4 0x9e5b8c10, 0x9f3af17c, 0x1bc9a8be, 0x1ee3c004
343       data4 0x9f19b1b2, 0x9f242ce9, 0x9ce67dd1, 0x9e4f6275
344       data4 0x1e20742c, 0x1eb9328a, 0x9f477153, 0x1d969718
345       data4 0x9f1e6c43, 0x1f2f67f4, 0x9f39c7e4, 0x9e3c4feb
346       data4 0x1da3956b, 0x9e7c685d, 0x1f280911, 0x9f0d8afb
347       data4 0x1e314b40, 0x9eb4f250, 0x9f1a34ad, 0x1ef5d5e7
348       data4 0x9f145496, 0x1e604827, 0x9f1e5195, 0x1e9c1fc0
349       data4 0x1efde521, 0x1e69b385, 0x1f316830, 0x9f244eae
350       data4 0x1f1787ec, 0x9e939971, 0x1f0bb393, 0x9f0511d6
351       data4 0x1ed919de, 0x1d8b7b28, 0x1e5ca4a9, 0x1e7c357b
352       data4 0x9e3ff8e8, 0x1eef53b5, 0x9ed22ed7, 0x1f16659b
353       data4 0x9f2db102, 0x9e2c6a78, 0x1f328d7d, 0x9f2fec3c
354       data4 0x1eb395bd, 0x9f242b84, 0x9e2683e6, 0x1ed71e68
355       data4 0x1efd1df5, 0x9e9eeafd, 0x9ed2249c, 0x1eef129a
356       data4 0x1d1ea44c, 0x9e81f7ff, 0x1eaf77c9, 0x9ee7a285
357       data4 0x1e1864ed, 0x9ee7edbb, 0x9e15a27d, 0x9ae61655
358       data4 0x1f1ff1a2, 0x1da29755, 0x9e5f46fb, 0x1e901236
359       data4 0x9eecfb9b, 0x9f204d2f, 0x1ec64685, 0x9eb809bd
360       data4 0x9e0026c5, 0x1d9f1da1, 0x1f142b49, 0x9f20f22e
361       data4 0x1f24b067, 0x1f185a4c, 0x9f09765c, 0x9ece902f
362       data4 0x1e2ca5db, 0x1e6de464, 0x9f071f67, 0x1f1518c3
363       data4 0x1ea13ded, 0x1f0b8414, 0x1edb6ad4, 0x9e548740
364       data4 0x9ea10efb, 0x1ee48a60, 0x1e7954c5, 0x9edad013
365       data4 0x9f21517d, 0x9e9b6e0c, 0x9ee7f9a6, 0x9ebd4298
366       data4 0x9d65b24e, 0x1eed751f, 0x9f1573ea, 0x9d430377
367       data4 0x9e13fc0c, 0x1e47008a, 0x1e3d5c1d, 0x1ef41a91
368       data4 0x9e4a4ef7, 0x9e952f18, 0x1d620566, 0x1d9b8d33
369       data4 0x1db06247, 0x1e94b31e, 0x1f0730ad, 0x9d79ffb4
370       data4 0x1ed64d51, 0x9e91fd11, 0x9e28d35a, 0x9dea0ed9
371       data4 0x1e891def, 0x9ee28ac0, 0x1e1db99b, 0x9ee1ce38
372       data4 0x9bdd9bca, 0x1eb72cb9, 0x9e8c53c6, 0x1e0df6ca
373       data4 0x1e8f2ccd, 0x9e9b0886, 0x1eeb3bc7, 0x1ec7e772
374       data4 0x9e210776, 0x9daf246c, 0x1ea1f151, 0x1ece4dc6
375       data4 0x1ce741c8, 0x1ed3c88f, 0x9ec9a4fd, 0x9e0c8d30
376       data4 0x1d2fbb26, 0x9ef212a7, 0x1ee44f1c, 0x9e445550
377       data4 0x1e075f77, 0x9d9291a3, 0x1f09c2ee, 0x9e012c88
378       data4 0x1f057d62, 0x9e7bb0dc, 0x9d8758ee, 0x1ee8d6c1
379       data4 0x9e509a57, 0x9e4ca7b7, 0x1e2cb341, 0x9ec35106
380       data4 0x1ecf3baf, 0x1e11781c, 0x1ea0cc78, 0x1eb75ca6
381       data4 0x1e961e1a, 0x1eb88853, 0x1e7abf50, 0x1ee38704
382       data4 0x9dc5ab0f, 0x1afe197b, 0x9ec07523, 0x9d9b7f78
383       data4 0x1f011618, 0x1ed43b0b, 0x9f035945, 0x9e3fd014
384       data4 0x9bbda5cd, 0x9e83f8ab, 0x1e58a928, 0x1e392d61
385       data4 0x1efdbb52, 0x1ee310a8, 0x9ec7ecc1, 0x1e8c9ed6
386       data4 0x9ef82dee, 0x9e70545b, 0x9ea53fc4, 0x1e40f419
387LOCAL_OBJECT_END(D_table)
388
389
390
391.section .text
392GLOBAL_IEEE754_ENTRY(exp10l)
393
394{.mfi
395       alloc GR_SREG = ar.pfs, 1, 4, 4, 0
396       // will continue only for normal/denormal numbers
397       fclass.nm.unc p12, p7 = f8, 0x1b
398       // GR_ADDR0 = pointer to log2(10), C_1...C_6 followed by T_table
399       addl GR_ADDR0 = @ltoff(poly_coeffs), gp ;;
400}
401
402{.mfi
403       // load start address for C_1...C_6 followed by T_table
404       ld8 GR_ADDR0 = [ GR_ADDR0 ]
405       // X<0 ?
406       fcmp.lt.s1 p6, p8 = f8, f0
407       // GR_BM8 = bias-8
408       mov GR_BM8 = 0xffff-8
409}
410{.mlx
411       nop.m 0
412       // GR_EMIN = (-2^14-62)*2^{8}
413       movl GR_EMIN = 0xca807c00 ;;
414}
415
416{.mmb
417       // FR_CONST1 = 2^{-8}
418       setf.exp FR_CONST1 = GR_BM8
419       // load log2(10)*2^8
420       ldfe FR_LOG10 = [ GR_ADDR0 ], 16
421 (p12) br.cond.spnt SPECIAL_EXP10 ;;
422}
423
424{.mmf
425       setf.s FR_UF_TEST = GR_EMIN
426       // load overflow threshold
427       ldfe FR_OF_TEST = [ GR_ADDR0 ], 16
428       // normalize x
429       fma.s0 f8 = f8, f1, f0 ;;
430}
431
432{.mmi
433       // load C_1
434       ldfe FR_COEFF1 = [ GR_ADDR0 ], 16 ;;
435       // load C_2
436       ldfe FR_COEFF2 = [ GR_ADDR0 ], 16
437       nop.i 0 ;;
438}
439
440{.mmf
441       // GR_D_ADDR = pointer to D table
442       add GR_D_ADDR = 2048-64+96+32, GR_ADDR0
443       // load C_3, C_4
444       ldfpd FR_COEFF3, FR_COEFF4 = [ GR_ADDR0 ], 16
445       // y = x*log2(10)*2^8
446       fma.s1 FR_XL10 = f8, FR_LOG10, f0 ;;
447}
448
449{.mfi
450       // load C_5, C_6
451       ldfpd FR_COEFF5, FR_COEFF6 = [ GR_ADDR0 ], 16
452       // get int(x)
453       fcvt.fx.trunc.s1 FR_XINT = f8
454       nop.i 0
455}
456{.mfi
457       nop.m 0
458       // FR_LOG10 = log2(10)
459       fma.s1 FR_L10 = FR_LOG10, FR_CONST1, f0
460       nop.i 0 ;;
461}
462
463{.mfi
464       // load log2(10)_low
465       ldfe FR_L10_LOW = [ GR_ADDR0 ], 16
466       // y0 = x*log2(10) = x*log2(10)_hi
467       fma.s1 FR_LOG10 = f8, FR_L10, f0
468       mov GR_EMIN = 0xffff-63
469}
470{.mfi
471       mov GR_32_BIAS = 0xffff + 5
472       // (K+f)*2^8 = round_to_int(y)
473       fcvt.fx.s1 FR_KF0 = FR_XL10
474       mov GR_4_BIAS = 0xffff + 2;;
475}
476
477{.mfi
478       // load smallest normal limit
479       ldfe FR_SNORM_LIMIT = [ GR_ADDR0 ], 16
480       // x>overflow threshold ?
481       fcmp.gt.s1 p12, p7 = f8, FR_OF_TEST
482       nop.i 0 ;;
483}
484
485{.mfi
486       setf.exp FR_32 = GR_32_BIAS
487       // x<underflow threshold ?
488  (p7) fcmp.lt.s1 p12, p7 = FR_XL10, FR_UF_TEST
489       nop.i 0 ;;
490}
491
492{.mfi
493       setf.exp FR_4 = GR_4_BIAS
494       fcvt.xf FR_XINTF = FR_XINT
495       nop.i 0
496}
497{.mfi
498       nop.m 0
499       // FR_L10 = log2(10)_h*x-RN(log2(10)_h*x)
500       fms.s1 FR_L10 = f8, FR_L10, FR_LOG10
501       nop.i 0 ;;
502}
503
504{.mfi
505       getf.sig GR_BM8 = FR_KF0
506       fcvt.xf FR_KF0 = FR_KF0
507       mov GR_CONST2 = 255 ;;
508}
509
510{.mfi
511       // GR_CONST2 = f
512       and GR_CONST2 = GR_CONST2, GR_BM8
513       // FR_L10_LOW = e = log2(10)_l*x+(log2(10)_h*x-RN(log2(10)_h*x))
514       fma.s1 FR_L10_LOW = FR_L10_LOW, f8, FR_L10
515       // GR_BM8 = K
516       shr GR_BM8 = GR_BM8, 8 ;;
517}
518
519{.mmi
520       // address of D
521       shladd GR_D_ADDR = GR_CONST2, 2, GR_D_ADDR
522       // K+ = bias-63
523       add GR_BM8 = GR_BM8, GR_EMIN
524       // address of T
525       shladd GR_ADDR0 = GR_CONST2, 3, GR_ADDR0 ;;
526}
527
528{.mfb
529       // load D
530       ldfs FR_OF_TEST = [ GR_D_ADDR ]
531       // is input an integer ?
532       fcmp.eq.s1 p13, p14 = f8, FR_XINTF
533 (p12) br.cond.spnt OUT_RANGE_EXP10 ;;
534}
535
536{.mmf
537       // load T
538       ldf8 FR_UF_TEST = [ GR_ADDR0 ]
539       // FR_XL10 = 2^{K-63}
540       setf.exp FR_XL10 = GR_BM8
541       // r = x*log2(10)_hi-2^{-10}* [ (K+f)*2^{10} ]
542       fnma.s1 FR_KF0 = FR_KF0, FR_CONST1, FR_LOG10 ;;
543}
544
545{.mfi
546       nop.m 0
547       // get 28.0
548       fms.s1 FR_28 = FR_32, f1, FR_4
549       nop.i 0
550}
551{.mfi
552       nop.m 0
553       // E = 1+C_1*e
554       fma.s1 FR_L10 = FR_L10_LOW, FR_COEFF1, f1
555       nop.i 0 ;;
556}
557
558{.mfi
559       nop.m 0
560       // P12 = C_1+C_2*r
561       fma.s1 FR_COEFF2 = FR_COEFF2, FR_KF0, FR_COEFF1
562       nop.i 0
563}
564{.mfi
565       nop.m 0
566       // P34 = C_3+C_4*r
567       fma.s1 FR_COEFF4 = FR_COEFF4, FR_KF0, FR_COEFF3
568       nop.i 0 ;;
569}
570
571{.mfi
572       nop.m 0
573       // P56 = C_5+C_6*r
574       fma.s1 FR_COEFF5 = FR_COEFF6, FR_KF0, FR_COEFF5
575       nop.i 0
576}
577{.mfi
578       nop.m 0
579       // GR_ADDR0 = r*r
580       fma.s1 FR_COEFF3 = FR_KF0, FR_KF0, f0
581       nop.i 0 ;;
582}
583
584{.mfi
585       nop.m 0
586       // if input is integer, is it positive ?
587 (p13) fcmp.ge.s1 p13, p14 = f8, f0
588       nop.i 0
589}
590{.mfi
591       nop.m 0
592       // r' = r*E
593       fma.s1 FR_KF0 = FR_KF0, FR_L10, f0
594       nop.i 0 ;;
595}
596
597{.mfi
598       nop.m 0
599       // D' = D+C_1*e
600       fma.s1 FR_OF_TEST = FR_L10_LOW, FR_COEFF1, FR_OF_TEST
601       nop.i 0 ;;
602}
603
604{.mfi
605       nop.m 0
606       // test if x >= smallest normal limit
607       fcmp.ge.s1 p11, p0 = f8, FR_SNORM_LIMIT
608       nop.i 0 ;;
609}
610
611{.mfi
612       nop.m 0
613       // P36 = P34+r2*P56
614       fma.s1 FR_COEFF4 = FR_COEFF5, FR_COEFF3, FR_COEFF4
615       nop.i 0
616}
617{.mfi
618       nop.m 0
619       // GR_D_ADDR = r'*r2
620       fma.s1 FR_COEFF3 = FR_COEFF3, FR_KF0, f0
621       nop.i 0 ;;
622}
623
624{.mfi
625       nop.m 0
626       // is input below 28.0 ?
627 (p13) fcmp.lt.s1 p13, p14 = f8, FR_28
628       nop.i 0
629}
630{.mfi
631       nop.m 0
632       // P' = P12*r'+D'
633       fma.s1 FR_COEFF2 = FR_COEFF2, FR_KF0, FR_OF_TEST
634       nop.i 0 ;;
635}
636
637{.mfi
638       nop.m 0
639       // P = P'+r3*P36
640       fma.s1 FR_COEFF3 = FR_COEFF3, FR_COEFF4, FR_COEFF2
641       nop.i 0
642}
643{.mfi
644       nop.m 0
645       // T = 2^{K-63}*T
646       fma.s1 FR_UF_TEST = FR_UF_TEST, FR_XL10, f0
647       nop.i 0 ;;
648}
649
650.pred.rel "mutex",p13,p14
651{.mfi
652       nop.m 0
653 (p13) fma.s1 f8 = FR_COEFF3, FR_UF_TEST, FR_UF_TEST
654       nop.i 0
655}
656{.mfb
657       nop.m 0
658       // result = T+T*P
659 (p14) fma.s0 f8 = FR_COEFF3, FR_UF_TEST, FR_UF_TEST
660       // return
661 (p11) br.ret.sptk b0 ;;                  // return, if result normal
662}
663
664// Here if result in denormal range (and not zero)
665{.mib
666       nop.m 0
667       mov GR_Parameter_TAG= 264
668       br.cond.sptk __libm_error_region           // Branch to error handling
669}
670;;
671
672SPECIAL_EXP10:
673
674{.mfi
675       nop.m 0
676       // x = -Infinity ?
677       fclass.m p6, p0 = f8, 0x22
678       nop.i 0 ;;
679}
680
681{.mfi
682       nop.m 0
683       // x = +Infinity ?
684       fclass.m p7, p0 = f8, 0x21
685       nop.i 0 ;;
686}
687
688{.mfi
689       nop.m 0
690       // x = +/-Zero ?
691       fclass.m p8, p0 = f8, 0x7
692       nop.i 0
693}
694{.mfb
695       nop.m 0
696       // exp10(-Infinity) = 0
697  (p6) mov f8 = f0
698  (p6) br.ret.spnt b0 ;;
699}
700
701{.mfb
702       nop.m 0
703       // exp10(+Infinity) = +Infinity
704       nop.f 0
705  (p7) br.ret.spnt b0 ;;
706}
707
708{.mfb
709       nop.m 0
710       // exp10(+/-0) = 1
711  (p8) mov f8 = f1
712  (p8) br.ret.spnt b0 ;;
713}
714
715{.mfb
716       nop.m 0
717       // Remaining cases: NaNs
718       fma.s0 f8 = f8, f1, f0
719       br.ret.sptk b0 ;;
720}
721
722
723OUT_RANGE_EXP10:
724
725// underflow: p6 = 1
726// overflow: p8 = 1
727
728.pred.rel "mutex",p6,p8
729{.mmi
730  (p8) mov GR_CONST1 = 0x1fffe
731  (p6) mov GR_CONST1 = 1
732       nop.i 0
733}
734;;
735
736{.mii
737       setf.exp FR_KF0 = GR_CONST1
738  (p8) mov GR_Parameter_TAG = 165
739  (p6) mov GR_Parameter_TAG = 264
740}
741;;
742
743{.mfb
744       nop.m 999
745       fma.s0 f8 = FR_KF0, FR_KF0, f0             // Create overflow/underflow
746       br.cond.sptk __libm_error_region           // Branch to error handling
747}
748;;
749
750GLOBAL_IEEE754_END(exp10l)
751libm_alias_ldouble_other (__exp10, exp10)
752#if SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_27)
753compat_symbol (libm, exp10l, pow10l, GLIBC_2_2)
754#endif
755
756
757LOCAL_LIBM_ENTRY(__libm_error_region)
758.prologue
759{.mfi
760       add GR_Parameter_Y = -32, sp // Parameter 2 value
761       nop.f 0
762.save ar.pfs, GR_SAVE_PFS
763       mov GR_SAVE_PFS = ar.pfs // Save ar.pfs
764}
765
766{.mfi
767.fframe 64
768       add sp = -64, sp // Create new stack
769       nop.f 0
770       mov GR_SAVE_GP = gp ;; // Save gp
771}
772
773{.mmi
774       stfe [ GR_Parameter_Y ] = FR_Y, 16 // STORE Parameter 2 on stack
775       add GR_Parameter_X = 16, sp // Parameter 1 address
776.save b0, GR_SAVE_B0
777       mov GR_SAVE_B0 = b0 ;; // Save b0
778}
779
780.body
781{.mib
782       stfe [ GR_Parameter_X ] = FR_X // STORE Parameter 1 on stack
783       add GR_Parameter_RESULT = 0, GR_Parameter_Y // Parameter 3 address
784       nop.b 0
785}
786{.mib
787       stfe [ GR_Parameter_Y ] = FR_RESULT // STORE Parameter 3 on stack
788       add GR_Parameter_Y = -16, GR_Parameter_Y
789       br.call.sptk b0 = __libm_error_support# ;; // Call error handling function
790}
791
792{.mmi
793       add GR_Parameter_RESULT = 48, sp
794       nop.m 0
795       nop.i 0 ;;
796}
797
798{.mmi
799       ldfe f8 = [ GR_Parameter_RESULT ] // Get return result off stack
800.restore sp
801       add sp = 64, sp // Restore stack pointer
802       mov b0 = GR_SAVE_B0 ;; // Restore return address
803}
804
805{.mib
806       mov gp = GR_SAVE_GP // Restore gp
807       mov ar.pfs = GR_SAVE_PFS // Restore ar.pfs
808       br.ret.sptk b0 ;; // Return
809}
810
811
812LOCAL_LIBM_END(__libm_error_region)
813.type __libm_error_support#, @function
814.global __libm_error_support#
815