~ubuntu-branches/ubuntu/utopic/eglibc/utopic

« back to all changes in this revision

Viewing changes to ports/sysdeps/ia64/fpu/e_log2f.S

  • Committer: Package Import Robot
  • Author(s): Adam Conrad
  • Date: 2012-10-26 05:14:58 UTC
  • mfrom: (1.5.1) (4.4.22 experimental)
  • Revision ID: package-import@ubuntu.com-20121026051458-oryotr4i03ob5pab
Tags: 2.16-0ubuntu1
* Merge with unreleased 2.16 in Debian experimental, remaining changes:
  - Drop the Breaks line from libc6, which refers to a Debian transition
  - Remove the libc6 recommends on libc6-i686, which we don't build
  - Enable libc6{,-dev}-armel on armhf and libc6{-dev}-armhf on armel
  - Ship update-locale and validlocale in /usr/sbin in libc-bin
  - Don't build locales or locales-all in Ubuntu, we rely on langpacks
  - Heavily mangle the way we do service restarting on major upgrades
  - Use different MIN_KERNEL_SUPPORTED versions than Debian, due to
    buildd needs.  This should be universally bumped to 3.2.0 once all
    our buildds (including the PPA guests) are running precise kernels
  - Build i386 variants as -march=i686, build amd64 with -O3, and build
    ppc64 variants (both 64-bit and 32-bit) with -O3 -fno-tree-vectorize
  - Re-enable unsubmitted-ldconfig-cache-abi.diff and rebuild the cache
    on upgrades from previous versions that used a different constant
  - debian/patches/any/local-CVE-2012-3406.diff: switch to malloc when
    array grows too large to handle via alloca extension (CVE-2012-3406)
  - Build generic i386/i686 flavour with -mno-tls-direct-seg-refs
* Changes added/dropped with this merge while reducing our delta:
  - Stop building glibc docs from the eglibc source, and instead make
    the glibc-docs stub have a hard dependency on glibc-doc-reference
  - Remove outdated conflicts against ancient versions of ia32-libs
  - Drop the tzdata dependency from libc6, it's in required and minimal
  - Use gcc-4.7/g++-4.7 by default on all our supported architectures
  - Save our historical changelog as changelog.ubuntu in the source
  - Drop nscd's libaudit build-dep for now, as libaudit is in universe
  - Drop the unnecessary Breaks from libc6 to locales and locales-all
  - Ship xen's ld.so.conf.d snippet as /etc/ld.so.conf.d/libc6-xen.conf
* Disable hard failures on the test suite for the first upload to raring

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
.file "log2f.s"
 
2
 
 
3
 
 
4
// Copyright (c) 2000 - 2003, 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
// 09/11/00 Initial version
 
43
// 05/20/02 Cleaned up namespace and sf0 syntax
 
44
// 02/10/03 Reordered header: .section, .global, .proc, .align
 
45
//
 
46
// API
 
47
//==============================================================
 
48
// float log2f(float)
 
49
//
 
50
// Overview of operation
 
51
//==============================================================
 
52
// Background
 
53
//
 
54
// Implementation
 
55
//
 
56
// Let x = 2^l * m, where     m=1.b1 b2 ... b8 b9 ... b52
 
57
//     y=frcpa(m),   r=m*y-1, f=b1 b2 .. b8 (table index)
 
58
// j=0 if f<128; j=1 if f>=128
 
59
// T is a table that stores log2(1/y) (in entries 1..255) rounded to
 
60
//   double extended precision; f is used as an index; T[255]=0
 
61
//
 
62
// If f=0 and b9=0, r is set to 2^{-8}* 0.b9 b10 ... b52 = m-1 (fractional part of m),
 
63
//                  and 0 is used instead of T[0]
 
64
//                  (polynomial evaluation only, for m=1+r, 0<=r<2^{-9})
 
65
// If f=255, r is set to (m-2)/2  (T[255]=0, and only polynomial evaluation is used
 
66
//                                 for m=2(1-r'), 0<=r'<2^{-9})
 
67
//
 
68
// log2f(x) is approximated as
 
69
//     (l-j) + T[f] + (c1*r+c2*r^2+...+c6*r^6), if f>0
 
70
//
 
71
 
 
72
 
 
73
// Special values
 
74
//==============================================================
 
75
//  log2f(0)=-inf, raises Divide by Zero
 
76
//  log2f(+inf)=inf
 
77
//  log2f(x)=NaN,  raises Invalid if x<0
 
78
//
 
79
 
 
80
 
 
81
// Registers used
 
82
//==============================================================
 
83
//   f6-f14
 
84
//   r2-r3, r23-r30
 
85
//   p6,p7,p8,p12
 
86
//
 
87
 
 
88
 
 
89
GR_SAVE_B0                    = r33
 
90
GR_SAVE_PFS                   = r34
 
91
GR_SAVE_GP                    = r35 // This reg. can safely be used
 
92
GR_SAVE_SP                    = r36
 
93
 
 
94
GR_Parameter_X                = r37
 
95
GR_Parameter_Y                = r38
 
96
GR_Parameter_RESULT           = r39
 
97
GR_Parameter_TAG              = r40
 
98
 
 
99
FR_X             = f10
 
100
FR_Y             = f1
 
101
FR_RESULT        = f8
 
102
 
 
103
 
 
104
 
 
105
 
 
106
// Data tables
 
107
//==============================================================
 
108
 
 
109
RODATA
 
110
 
 
111
.align 16
 
112
 
 
113
LOCAL_OBJECT_START(poly_coeffs)
 
114
 
 
115
data8 0x3fdec709dc3a03fd, 0xbfd71547652b82fe //C_3 and C_4
 
116
data8 0xb8aa3b295c17f0bc, 0x00003fff  // C_1
 
117
data8 0xb8aa3b295c17f0bc, 0x0000bffe  // C_2
 
118
LOCAL_OBJECT_END(poly_coeffs)
 
119
 
 
120
 
 
121
LOCAL_OBJECT_START(T_table)
 
122
 
 
123
data8 0x3f671b0ea42e5fda, 0x3f815cfe8eaec830
 
124
data8 0x3f8cfee70c5ce5dc, 0x3f94564a62192834
 
125
data8 0x3f997723ace35766, 0x3f9f5923c69b54a1
 
126
data8 0x3fa2a094a085d693, 0x3fa538941776b01e
 
127
data8 0x3fa8324c9b914bc7, 0x3faacf54ce07d7e9
 
128
data8 0x3fadced958dadc12, 0x3fb0387efbca869e
 
129
data8 0x3fb18ac6067479c0, 0x3fb30edd3e13530d
 
130
data8 0x3fb463c15936464e, 0x3fb5b9e13c3fa21d
 
131
data8 0x3fb7113f3259e07a, 0x3fb869dd8d1b2035
 
132
data8 0x3fb9c3bea49d3214, 0x3fbb1ee4d7961701
 
133
data8 0x3fbc7b528b70f1c5, 0x3fbdd90a2c676ed4
 
134
data8 0x3fbf05d4976c2028, 0x3fc032fbbaee6d65
 
135
data8 0x3fc0e3b5a9f3284a, 0x3fc195195c7d125b
 
136
data8 0x3fc22dadc2ab3497, 0x3fc2e050231df57d
 
137
data8 0x3fc379f79c2b255b, 0x3fc42ddd2ba1b4a9
 
138
data8 0x3fc4c89b9e6807f5, 0x3fc563dc29ffacb2
 
139
data8 0x3fc619a25f5d798d, 0x3fc6b5ffbf367644
 
140
data8 0x3fc752e1f660f8d6, 0x3fc7f049e753e7cf
 
141
data8 0x3fc8a8980abfbd32, 0x3fc94724cca657be
 
142
data8 0x3fc9e63a24971f46, 0x3fca85d8feb202f7
 
143
data8 0x3fcb2602497d5346, 0x3fcbc6b6f5ee1c9b
 
144
data8 0x3fcc67f7f770a67e, 0x3fcceec4b2234fba
 
145
data8 0x3fcd91097ad13982, 0x3fce33dd57f3d335
 
146
data8 0x3fced74146bc7b10, 0x3fcf7b3646fef683
 
147
data8 0x3fd00223a943dc19, 0x3fd054a474bf0eb7
 
148
data8 0x3fd0999d9b9259a1, 0x3fd0eca66d3b2581
 
149
data8 0x3fd13ffa2e85b475, 0x3fd185a444fa0a7b
 
150
data8 0x3fd1cb8312f27eff, 0x3fd21fa1441ce5e8
 
151
data8 0x3fd265f526e603cb, 0x3fd2baa0c34be1ec
 
152
data8 0x3fd3016b45de21ce, 0x3fd3486c38aa29a8
 
153
data8 0x3fd38fa3efaa8262, 0x3fd3e562c0816a02
 
154
data8 0x3fd42d141f53b646, 0x3fd474fd543f222c
 
155
data8 0x3fd4bd1eb680e548, 0x3fd505789e234bd1
 
156
data8 0x3fd54e0b64003b70, 0x3fd596d761c3c1f0
 
157
data8 0x3fd5dfdcf1eeae0e, 0x3fd6291c6fd9329c
 
158
data8 0x3fd6729637b59418, 0x3fd6bc4aa692e0fd
 
159
data8 0x3fd7063a1a5fb4f2, 0x3fd75064f1ed0715
 
160
data8 0x3fd79acb8cf10390, 0x3fd7d67c1e43ae5c
 
161
data8 0x3fd8214f4068afa7, 0x3fd86c5f36dea3dc
 
162
data8 0x3fd8b7ac64dd7f9d, 0x3fd8f4167a0c6f92
 
163
data8 0x3fd93fd2d5e1bf1d, 0x3fd98bcd84296946
 
164
data8 0x3fd9c8c333e6e9a5, 0x3fda152f142981b4
 
165
data8 0x3fda527fd95fd8ff, 0x3fda9f5e3edeb9e6
 
166
data8 0x3fdadd0b2b5755a7, 0x3fdb2a5d6f51ff83
 
167
data8 0x3fdb686799b00be3, 0x3fdbb62f1b887cd8
 
168
data8 0x3fdbf4979f666668, 0x3fdc332a6e8399d4
 
169
data8 0x3fdc819dc2d45fe4, 0x3fdcc0908e19b7bd
 
170
data8 0x3fdcffae611ad12b, 0x3fdd3ef776d43ff4
 
171
data8 0x3fdd8e5002710128, 0x3fddcdfb486cb9a1
 
172
data8 0x3fde0dd294245fe4, 0x3fde4dd622a28840
 
173
data8 0x3fde8e06317114f0, 0x3fdece62fe9a9915
 
174
data8 0x3fdf1f164a15389a, 0x3fdf5fd8a9063e35
 
175
data8 0x3fdfa0c8937e7d5d, 0x3fdfe1e649bb6335
 
176
data8 0x3fe011990641535a, 0x3fe032560e91e59e
 
177
data8 0x3fe0532a5ebcd44a, 0x3fe0741617f5fc28
 
178
data8 0x3fe08cd653f38839, 0x3fe0adeb55c1103b
 
179
data8 0x3fe0cf181d5d1dd0, 0x3fe0f05ccd0aced7
 
180
data8 0x3fe111b9875788ab, 0x3fe1332e6f1bcf73
 
181
data8 0x3fe154bba77c2088, 0x3fe16df59bfa06c1
 
182
data8 0x3fe18fadb6e2d3c2, 0x3fe1b17e849adc26
 
183
data8 0x3fe1caeb6a0de814, 0x3fe1ece7c830eec9
 
184
data8 0x3fe20efd3dae01df, 0x3fe2289de375d901
 
185
data8 0x3fe24adf9b6a6fe0, 0x3fe26d3ad1aebcfc
 
186
data8 0x3fe287100c2771f4, 0x3fe2a9983b3c1b28
 
187
data8 0xbfda78e146f7bef4, 0xbfda33760a7f6051
 
188
data8 0xbfd9ff43476fb5f7, 0xbfd9b97c3c4eec8f
 
189
data8 0xbfd98504431717fc, 0xbfd93ee07535f967
 
190
data8 0xbfd90a228d5712b2, 0xbfd8c3a104cb24f5
 
191
data8 0xbfd88e9c72e0b226, 0xbfd847bc33d8618e
 
192
data8 0xbfd812703988bb69, 0xbfd7dd0569c04bff
 
193
data8 0xbfd7959c202292f1, 0xbfd75fe8d2c5d48f
 
194
data8 0xbfd72a1637cbc183, 0xbfd6e221cd9d0cde
 
195
data8 0xbfd6ac059985503b, 0xbfd675c99ce81f92
 
196
data8 0xbfd63f6db2590482, 0xbfd5f6c138136489
 
197
data8 0xbfd5c01a39fbd688, 0xbfd58952cf519193
 
198
data8 0xbfd5526ad18493ce, 0xbfd51b6219bfe6ea
 
199
data8 0xbfd4d1cdf8b4846f, 0xbfd49a784bcd1b8b
 
200
data8 0xbfd4630161832547, 0xbfd42b6911cf5465
 
201
data8 0xbfd3f3af3461e1c4, 0xbfd3bbd3a0a1dcfb
 
202
data8 0xbfd383d62dac7ae7, 0xbfd34bb6b2546218
 
203
data8 0xbfd313750520f520, 0xbfd2db10fc4d9aaf
 
204
data8 0xbfd2a28a6dc90387, 0xbfd269e12f346e2c
 
205
data8 0xbfd2311515e2e855, 0xbfd1f825f6d88e13
 
206
data8 0xbfd1bf13a6c9c69f, 0xbfd185ddfa1a7ed0
 
207
data8 0xbfd14c84c4dd6128, 0xbfd11307dad30b76
 
208
data8 0xbfd0d9670f6941fe, 0xbfd09fa235ba2020
 
209
data8 0xbfd0790adbb03009, 0xbfd03f09858c55fb
 
210
data8 0xbfd004e3a7c97cbd, 0xbfcf9532288fcf69
 
211
data8 0xbfcf205339208f27, 0xbfceab2a23a5b83e
 
212
data8 0xbfce5ce55fdd37a5, 0xbfcde73fe3b1480f
 
213
data8 0xbfcd714f44623927, 0xbfccfb1321b8c400
 
214
data8 0xbfccac163c770dc9, 0xbfcc355b67195dd0
 
215
data8 0xbfcbbe540a3f036f, 0xbfcb6ecf175f95e9
 
216
data8 0xbfcaf74751e1be33, 0xbfca7f71fb7bab9d
 
217
data8 0xbfca2f632320b86b, 0xbfc9b70ba539dfae
 
218
data8 0xbfc93e6587910444, 0xbfc8edcae8352b6c
 
219
data8 0xbfc874a0db01a719, 0xbfc7fb27199df16d
 
220
data8 0xbfc7a9fec7d05ddf, 0xbfc72fff456ac70d
 
221
data8 0xbfc6de7d66023dbc, 0xbfc663f6fac91316
 
222
data8 0xbfc6121ac74813cf, 0xbfc5970c478fff4a
 
223
data8 0xbfc51bab907a5c8a, 0xbfc4c93d33151b24
 
224
data8 0xbfc44d527fdadf55, 0xbfc3fa87be0f3a1b
 
225
data8 0xbfc3a797cd35d959, 0xbfc32ae9e278ae1a
 
226
data8 0xbfc2d79c6937efdd, 0xbfc25a619370d9dc
 
227
data8 0xbfc206b5bde2f8b8, 0xbfc188ecbd1d16be
 
228
data8 0xbfc134e1b489062e, 0xbfc0b6894488e95f
 
229
data8 0xbfc0621e2f556b5c, 0xbfc00d8c711a12cc
 
230
data8 0xbfbf1cd21257e18c, 0xbfbe72ec117fa5b2
 
231
data8 0xbfbdc8b7c49a1ddb, 0xbfbcc8d5e467b710
 
232
data8 0xbfbc1ddc9c39c7a1, 0xbfbb7294093cdd0f
 
233
data8 0xbfba7111df348494, 0xbfb9c501cdf75872
 
234
data8 0xbfb918a16e46335b, 0xbfb81579a73e83c6
 
235
data8 0xbfb7684f39f4ff2d, 0xbfb6bad3758efd87
 
236
data8 0xbfb60d060d7e41ac, 0xbfb507b836033bb7
 
237
data8 0xbfb4591d6310d85a, 0xbfb3aa2fdd27f1c3
 
238
data8 0xbfb2faef55ccb372, 0xbfb1f3723b4ae6db
 
239
data8 0xbfb14360d6136ffa, 0xbfb092fb594145c1
 
240
data8 0xbfafc482e8b48a7e, 0xbfae6265ace11ae4
 
241
data8 0xbfacff9e5c4341d0, 0xbfaaea3316095f72
 
242
data8 0xbfa985bfc3495194, 0xbfa820a01ac754cb
 
243
data8 0xbfa6bad3758efd87, 0xbfa554592bb8cd58
 
244
data8 0xbfa3ed3094685a26, 0xbfa2855905ca70f6
 
245
data8 0xbfa11cd1d5133413, 0xbf9dfd78881399f1
 
246
data8 0xbf9b28f618cc85df, 0xbf98530faa3c087b
 
247
data8 0xbf957bc3dddcd7fa, 0xbf92a3115322f9e6
 
248
data8 0xbf8f91ed4eef8370, 0xbf89dae4ec6b8b2e
 
249
data8 0xbf842106b1499209, 0xbf7cc89f97d67594
 
250
data8 0xbf71497accf7e11d, 0x0000000000000000
 
251
LOCAL_OBJECT_END(T_table)
 
252
 
 
253
 
 
254
.section .text
 
255
GLOBAL_LIBM_ENTRY(log2f)
 
256
 
 
257
{ .mfi
 
258
  alloc r32=ar.pfs,1,4,4,0
 
259
  // y=frcpa(x)
 
260
  frcpa.s1 f6,p0=f1,f8
 
261
  // will form significand of 1.5 (to test whether the index is 128 or above)
 
262
  mov r24=0xc
 
263
}
 
264
{.mfi
 
265
  nop.m 0
 
266
  // normalize x
 
267
  fma.s1 f7=f8,f1,f0
 
268
  // r2 = pointer to C_1...C_6 followed by T_table
 
269
  addl r2 = @ltoff(poly_coeffs), gp;;
 
270
}
 
271
{.mfi
 
272
  // get significand
 
273
  getf.sig r25=f8
 
274
  // f8 denormal ?
 
275
  fclass.m p8,p10=f8,0x9
 
276
  // will form significand of 1.5 (to test whether the index is 128 or above)
 
277
  shl r24=r24,60
 
278
}
 
279
{.mfi
 
280
  mov r26=0x804
 
281
  nop.f 0
 
282
  // r23=bias-1
 
283
  mov r23=0xfffe;;
 
284
}
 
285
 
 
286
{.mmf
 
287
  getf.exp r29=f8
 
288
  // load start address for C_1...C_6 followed by T_table
 
289
  ld8 r2=[r2]
 
290
  // will continue only for positive normal/denormal numbers
 
291
  fclass.nm.unc p12,p7 = f8, 0x19 ;;
 
292
}
 
293
 
 
294
.pred.rel "mutex",p8,p10
 
295
{.mfi
 
296
  // denormal input, repeat get significand (after normalization)
 
297
  (p8) getf.sig r25=f7
 
298
  // x=1 ?
 
299
  fcmp.eq.s0 p6,p0=f8,f1
 
300
  // get T_index
 
301
  (p10) shr.u r28=r25,63-8
 
302
}
 
303
{.mfi
 
304
  // f12=0.5
 
305
  setf.exp f12=r23
 
306
  nop.f 0
 
307
  // r27=bias
 
308
  mov r27=0xffff;;
 
309
}
 
310
 
 
311
{.mfb
 
312
  // denormal input, repeat get exponent (after normalization)
 
313
  (p8) getf.exp r29=f7
 
314
  nop.f 0
 
315
  (p12) br.cond.spnt SPECIAL_log2f
 
316
}
 
317
{.mfi
 
318
  cmp.geu p12,p0=r25,r24
 
319
  nop.f 0
 
320
  mov r23=0xff;;
 
321
}
 
322
 
 
323
{.mfi
 
324
  add r3=32,r2
 
325
  // r=1-x*y
 
326
  fms.s1 f6=f6,f8,f1
 
327
  // r26=0x80400...0 (threshold for using polynomial approximation)
 
328
  shl r26=r26,64-12
 
329
}
 
330
{.mfi
 
331
  // load C_3, C_4
 
332
  ldfpd f10,f11=[r2],16
 
333
  nop.f 0
 
334
  // r27=bias-1 (if index >=128, will add exponent+1)
 
335
  (p12) mov r27=0xfffe;;
 
336
}
 
337
 
 
338
{.mfi
 
339
  // load C_1
 
340
  ldfe f14=[r2],32
 
341
  // x=1, return 0
 
342
  (p6) fma.s.s0 f8=f0,f0,f0
 
343
  (p8) shr.u r28=r25,63-8
 
344
}
 
345
{.mib
 
346
  // load C_2
 
347
  ldfe f13=[r3]
 
348
  // r29=exponent-bias
 
349
  sub r29=r29,r27
 
350
  // x=1, return
 
351
  (p6) br.ret.spnt b0;;
 
352
}
 
353
 
 
354
 
 
355
{.mfi
 
356
  // get T_index
 
357
  and r28=r28,r23
 
358
  fmerge.se f7=f1,f7
 
359
  // if first 9 bits after leading 1 are all zero, then p8=1
 
360
  cmp.ltu p8,p12=r25,r26;;
 
361
}
 
362
{.mfi
 
363
  // f8=expon - bias
 
364
  setf.sig f8=r29
 
365
  nop.f 0
 
366
  // get T address
 
367
  shladd r2=r28,3,r2
 
368
}
 
369
{.mfi
 
370
  // first 8 bits after leading 1 are all ones ?
 
371
  cmp.eq p10,p0=r23,r28
 
372
  // if first 8 bits after leading bit are 0, use polynomial approx. only
 
373
  (p8) fms.s1 f6=f7,f1,f1
 
374
  nop.i 0;;
 
375
}
 
376
{.mfi
 
377
  //r26=1
 
378
  mov r26=1
 
379
  // if first 8 bits after leading 1 are all ones, use polynomial approx. only
 
380
  (p10) fms.s1 f6=f7,f12,f1
 
381
  nop.i 0;;
 
382
}
 
383
 
 
384
.pred.rel "mutex",p8,p12
 
385
{.mmf
 
386
  // load T (unless first 9 bits after leading 1 are 0)
 
387
  (p12) ldfd f12=[r2]
 
388
  nop.m 0
 
389
  // set T=0 (if first 9 bits after leading 1 are 0)
 
390
  (p8) fma.s1 f12=f0,f0,f0;;
 
391
}
 
392
 
 
393
{.mfi
 
394
  nop.m 0
 
395
  // P34=C_3+C_4*r
 
396
  fma.s1 f10=f11,f6,f10
 
397
  // r26=2^{63}
 
398
  shl r26=r26,63
 
399
}
 
400
{.mfi
 
401
  nop.m 0
 
402
  // r2=r*r
 
403
  fma.s1 f11=f6,f6,f0
 
404
  nop.i 0;;
 
405
}
 
406
{.mfi
 
407
  // significand of x is 1 ?
 
408
  cmp.eq p0,p6=r25,r26
 
409
  // P12=C_1+C_2*r
 
410
  fma.s1 f14=f13,f6,f14
 
411
  nop.i 0;;
 
412
}
 
413
{.mfi
 
414
  nop.m 0
 
415
  // normalize additive term (l=exponent of x)
 
416
  fcvt.xf f8=f8
 
417
  // if significand(x)=1, return exponent (l)
 
418
  nop.i 0;;
 
419
}
 
420
{.mfi
 
421
  nop.m 0
 
422
  // add T+l
 
423
  (p6) fma.s1 f8=f8,f1,f12
 
424
  nop.i 0
 
425
}
 
426
{.mfi
 
427
  nop.m 0
 
428
  // P14=P12+r2*P34
 
429
  (p6) fma.s1 f13=f10,f11,f14
 
430
  nop.i 0;;
 
431
}
 
432
 
 
433
{.mfb
 
434
  nop.m 0
 
435
  // result=T+l+r*P14
 
436
  (p6) fma.s.s0 f8=f13,f6,f8
 
437
  // return
 
438
  br.ret.sptk b0;;
 
439
}
 
440
 
 
441
 
 
442
SPECIAL_log2f:
 
443
{.mfi
 
444
  nop.m 0
 
445
  // x=+Infinity ?
 
446
  fclass.m p7,p0=f8,0x21
 
447
  nop.i 0;;
 
448
}
 
449
{.mfi
 
450
  nop.m 0
 
451
  // x=+/-Zero ?
 
452
  fclass.m p8,p0=f8,0x7
 
453
  nop.i 0;;
 
454
}
 
455
{.mfi
 
456
  nop.m 0
 
457
  // x=-Infinity, -normal, -denormal ?
 
458
  fclass.m p6,p0=f8,0x3a
 
459
  nop.i 0;;
 
460
}
 
461
{.mfb
 
462
  nop.m 0
 
463
  // log2f(+Infinity)=+Infinity
 
464
  nop.f 0
 
465
  (p7) br.ret.spnt b0;;
 
466
}
 
467
{.mfi
 
468
  (p8) mov GR_Parameter_TAG = 172
 
469
  // log2f(+/-0)=-infinity, raises Divide by Zero
 
470
  // set f8=-0
 
471
  (p8) fmerge.ns f8=f0,f8
 
472
  nop.i 0;;
 
473
}
 
474
{.mfb
 
475
  nop.m 0
 
476
  (p8) frcpa.s0 f8,p0=f1,f8
 
477
  (p8) br.cond.sptk __libm_error_region;;
 
478
}
 
479
{.mfb
 
480
  (p6) mov GR_Parameter_TAG = 173
 
481
  // x<0: return NaN, raise Invalid
 
482
  (p6) frcpa.s0 f8,p0=f0,f0
 
483
  (p6) br.cond.sptk __libm_error_region;;
 
484
}
 
485
 
 
486
 
 
487
{.mfb
 
488
  nop.m 0
 
489
  // Remaining cases: NaNs
 
490
  fma.s.s0 f8=f8,f1,f0
 
491
  br.ret.sptk b0;;
 
492
}
 
493
 
 
494
GLOBAL_LIBM_END(log2f)
 
495
 
 
496
 
 
497
LOCAL_LIBM_ENTRY(__libm_error_region)
 
498
.prologue
 
499
{ .mfi
 
500
        add   GR_Parameter_Y=-32,sp             // Parameter 2 value
 
501
        nop.f 0
 
502
.save   ar.pfs,GR_SAVE_PFS
 
503
        mov  GR_SAVE_PFS=ar.pfs                 // Save ar.pfs
 
504
}
 
505
{ .mfi
 
506
.fframe 64
 
507
        add sp=-64,sp                           // Create new stack
 
508
        nop.f 0
 
509
        mov GR_SAVE_GP=gp                       // Save gp
 
510
};;
 
511
{ .mmi
 
512
        stfs [GR_Parameter_Y] = FR_Y,16         // STORE Parameter 2 on stack
 
513
        add GR_Parameter_X = 16,sp              // Parameter 1 address
 
514
.save   b0, GR_SAVE_B0
 
515
        mov GR_SAVE_B0=b0                       // Save b0
 
516
};;
 
517
.body
 
518
{ .mib
 
519
        stfs [GR_Parameter_X] = FR_X                  // STORE Parameter 1 on stack
 
520
        add   GR_Parameter_RESULT = 0,GR_Parameter_Y  // Parameter 3 address
 
521
        nop.b 0
 
522
}
 
523
{ .mib
 
524
        stfs [GR_Parameter_Y] = FR_RESULT             // STORE Parameter 3 on stack
 
525
        add   GR_Parameter_Y = -16,GR_Parameter_Y
 
526
        br.call.sptk b0=__libm_error_support#         // Call error handling function
 
527
};;
 
528
{ .mmi
 
529
        nop.m 0
 
530
        nop.m 0
 
531
        add   GR_Parameter_RESULT = 48,sp
 
532
};;
 
533
{ .mmi
 
534
        ldfs  f8 = [GR_Parameter_RESULT]       // Get return result off stack
 
535
.restore sp
 
536
        add   sp = 64,sp                       // Restore stack pointer
 
537
        mov   b0 = GR_SAVE_B0                  // Restore return address
 
538
};;
 
539
{ .mib
 
540
        mov   gp = GR_SAVE_GP                  // Restore gp
 
541
        mov   ar.pfs = GR_SAVE_PFS             // Restore ar.pfs
 
542
        br.ret.sptk     b0                     // Return
 
543
};;
 
544
 
 
545
LOCAL_LIBM_END(__libm_error_region)
 
546
.type   __libm_error_support#,@function
 
547
.global __libm_error_support#
 
548
 
 
549
 
 
550
 
 
551