1 |
|
---|
2 | /*============================================================================
|
---|
3 |
|
---|
4 | This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
---|
5 | Package, Release 3e, by John R. Hauser.
|
---|
6 |
|
---|
7 | Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
|
---|
8 | University of California. All rights reserved.
|
---|
9 |
|
---|
10 | Redistribution and use in source and binary forms, with or without
|
---|
11 | modification, are permitted provided that the following conditions are met:
|
---|
12 |
|
---|
13 | 1. Redistributions of source code must retain the above copyright notice,
|
---|
14 | this list of conditions, and the following disclaimer.
|
---|
15 |
|
---|
16 | 2. Redistributions in binary form must reproduce the above copyright notice,
|
---|
17 | this list of conditions, and the following disclaimer in the documentation
|
---|
18 | and/or other materials provided with the distribution.
|
---|
19 |
|
---|
20 | 3. Neither the name of the University nor the names of its contributors may
|
---|
21 | be used to endorse or promote products derived from this software without
|
---|
22 | specific prior written permission.
|
---|
23 |
|
---|
24 | THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
---|
25 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
---|
26 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
---|
27 | DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
---|
28 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
---|
29 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
---|
30 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
---|
31 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
32 | (INCLUDING 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 | =============================================================================*/
|
---|
36 |
|
---|
37 | #ifndef primitives_h
|
---|
38 | #define primitives_h 1
|
---|
39 |
|
---|
40 | #include <stdbool.h>
|
---|
41 | #include <stdint.h>
|
---|
42 | #include "primitiveTypes.h"
|
---|
43 |
|
---|
44 | #ifndef softfloat_shortShiftRightJam64
|
---|
45 | /*----------------------------------------------------------------------------
|
---|
46 | | Shifts 'a' right by the number of bits given in 'dist', which must be in
|
---|
47 | | the range 1 to 63. If any nonzero bits are shifted off, they are "jammed"
|
---|
48 | | into the least-significant bit of the shifted value by setting the least-
|
---|
49 | | significant bit to 1. This shifted-and-jammed value is returned.
|
---|
50 | *----------------------------------------------------------------------------*/
|
---|
51 | #if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
|
---|
52 | INLINE
|
---|
53 | uint64_t softfloat_shortShiftRightJam64( uint64_t a, uint_fast8_t dist )
|
---|
54 | { return a>>dist | ((a & (((uint_fast64_t) 1<<dist) - 1)) != 0); }
|
---|
55 | #else
|
---|
56 | uint64_t softfloat_shortShiftRightJam64( uint64_t a, uint_fast8_t dist );
|
---|
57 | #endif
|
---|
58 | #endif
|
---|
59 |
|
---|
60 | #ifndef softfloat_shiftRightJam32
|
---|
61 | /*----------------------------------------------------------------------------
|
---|
62 | | Shifts 'a' right by the number of bits given in 'dist', which must not
|
---|
63 | | be zero. If any nonzero bits are shifted off, they are "jammed" into the
|
---|
64 | | least-significant bit of the shifted value by setting the least-significant
|
---|
65 | | bit to 1. This shifted-and-jammed value is returned.
|
---|
66 | | The value of 'dist' can be arbitrarily large. In particular, if 'dist' is
|
---|
67 | | greater than 32, the result will be either 0 or 1, depending on whether 'a'
|
---|
68 | | is zero or nonzero.
|
---|
69 | *----------------------------------------------------------------------------*/
|
---|
70 | #if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
|
---|
71 | INLINE uint32_t softfloat_shiftRightJam32( uint32_t a, uint_fast16_t dist )
|
---|
72 | {
|
---|
73 | return
|
---|
74 | (dist < 31) ? a>>dist | ((uint32_t) (a<<(-dist & 31)) != 0) : (a != 0);
|
---|
75 | }
|
---|
76 | #else
|
---|
77 | uint32_t softfloat_shiftRightJam32( uint32_t a, uint_fast16_t dist );
|
---|
78 | #endif
|
---|
79 | #endif
|
---|
80 |
|
---|
81 | #ifndef softfloat_shiftRightJam64
|
---|
82 | /*----------------------------------------------------------------------------
|
---|
83 | | Shifts 'a' right by the number of bits given in 'dist', which must not
|
---|
84 | | be zero. If any nonzero bits are shifted off, they are "jammed" into the
|
---|
85 | | least-significant bit of the shifted value by setting the least-significant
|
---|
86 | | bit to 1. This shifted-and-jammed value is returned.
|
---|
87 | | The value of 'dist' can be arbitrarily large. In particular, if 'dist' is
|
---|
88 | | greater than 64, the result will be either 0 or 1, depending on whether 'a'
|
---|
89 | | is zero or nonzero.
|
---|
90 | *----------------------------------------------------------------------------*/
|
---|
91 | #if defined INLINE_LEVEL && (3 <= INLINE_LEVEL)
|
---|
92 | INLINE uint64_t softfloat_shiftRightJam64( uint64_t a, uint_fast32_t dist )
|
---|
93 | {
|
---|
94 | return
|
---|
95 | (dist < 63) ? a>>dist | ((uint64_t) (a<<(-dist & 63)) != 0) : (a != 0);
|
---|
96 | }
|
---|
97 | #else
|
---|
98 | uint64_t softfloat_shiftRightJam64( uint64_t a, uint_fast32_t dist );
|
---|
99 | #endif
|
---|
100 | #endif
|
---|
101 |
|
---|
102 | /*----------------------------------------------------------------------------
|
---|
103 | | A constant table that translates an 8-bit unsigned integer (the array index)
|
---|
104 | | into the number of leading 0 bits before the most-significant 1 of that
|
---|
105 | | integer. For integer zero (index 0), the corresponding table element is 8.
|
---|
106 | *----------------------------------------------------------------------------*/
|
---|
107 | extern const uint_least8_t softfloat_countLeadingZeros8[256];
|
---|
108 |
|
---|
109 | #ifndef softfloat_countLeadingZeros16
|
---|
110 | /*----------------------------------------------------------------------------
|
---|
111 | | Returns the number of leading 0 bits before the most-significant 1 bit of
|
---|
112 | | 'a'. If 'a' is zero, 16 is returned.
|
---|
113 | *----------------------------------------------------------------------------*/
|
---|
114 | #if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
|
---|
115 | INLINE uint_fast8_t softfloat_countLeadingZeros16( uint16_t a )
|
---|
116 | {
|
---|
117 | uint_fast8_t count = 8;
|
---|
118 | if ( 0x100 <= a ) {
|
---|
119 | count = 0;
|
---|
120 | a >>= 8;
|
---|
121 | }
|
---|
122 | count += softfloat_countLeadingZeros8[a];
|
---|
123 | return count;
|
---|
124 | }
|
---|
125 | #else
|
---|
126 | uint_fast8_t softfloat_countLeadingZeros16( uint16_t a );
|
---|
127 | #endif
|
---|
128 | #endif
|
---|
129 |
|
---|
130 | #ifndef softfloat_countLeadingZeros32
|
---|
131 | /*----------------------------------------------------------------------------
|
---|
132 | | Returns the number of leading 0 bits before the most-significant 1 bit of
|
---|
133 | | 'a'. If 'a' is zero, 32 is returned.
|
---|
134 | *----------------------------------------------------------------------------*/
|
---|
135 | #if defined INLINE_LEVEL && (3 <= INLINE_LEVEL)
|
---|
136 | INLINE uint_fast8_t softfloat_countLeadingZeros32( uint32_t a )
|
---|
137 | {
|
---|
138 | uint_fast8_t count = 0;
|
---|
139 | if ( a < 0x10000 ) {
|
---|
140 | count = 16;
|
---|
141 | a <<= 16;
|
---|
142 | }
|
---|
143 | if ( a < 0x1000000 ) {
|
---|
144 | count += 8;
|
---|
145 | a <<= 8;
|
---|
146 | }
|
---|
147 | count += softfloat_countLeadingZeros8[a>>24];
|
---|
148 | return count;
|
---|
149 | }
|
---|
150 | #else
|
---|
151 | uint_fast8_t softfloat_countLeadingZeros32( uint32_t a );
|
---|
152 | #endif
|
---|
153 | #endif
|
---|
154 |
|
---|
155 | #ifndef softfloat_countLeadingZeros64
|
---|
156 | /*----------------------------------------------------------------------------
|
---|
157 | | Returns the number of leading 0 bits before the most-significant 1 bit of
|
---|
158 | | 'a'. If 'a' is zero, 64 is returned.
|
---|
159 | *----------------------------------------------------------------------------*/
|
---|
160 | uint_fast8_t softfloat_countLeadingZeros64( uint64_t a );
|
---|
161 | #endif
|
---|
162 |
|
---|
163 | extern const uint16_t softfloat_approxRecip_1k0s[16];
|
---|
164 | extern const uint16_t softfloat_approxRecip_1k1s[16];
|
---|
165 |
|
---|
166 | #ifndef softfloat_approxRecip32_1
|
---|
167 | /*----------------------------------------------------------------------------
|
---|
168 | | Returns an approximation to the reciprocal of the number represented by 'a',
|
---|
169 | | where 'a' is interpreted as an unsigned fixed-point number with one integer
|
---|
170 | | bit and 31 fraction bits. The 'a' input must be "normalized", meaning that
|
---|
171 | | its most-significant bit (bit 31) must be 1. Thus, if A is the value of
|
---|
172 | | the fixed-point interpretation of 'a', then 1 <= A < 2. The returned value
|
---|
173 | | is interpreted as a pure unsigned fraction, having no integer bits and 32
|
---|
174 | | fraction bits. The approximation returned is never greater than the true
|
---|
175 | | reciprocal 1/A, and it differs from the true reciprocal by at most 2.006 ulp
|
---|
176 | | (units in the last place).
|
---|
177 | *----------------------------------------------------------------------------*/
|
---|
178 | #ifdef SOFTFLOAT_FAST_DIV64TO32
|
---|
179 | #define softfloat_approxRecip32_1( a ) ((uint32_t) (UINT64_C( 0x7FFFFFFFFFFFFFFF ) / (uint32_t) (a)))
|
---|
180 | #else
|
---|
181 | uint32_t softfloat_approxRecip32_1( uint32_t a );
|
---|
182 | #endif
|
---|
183 | #endif
|
---|
184 |
|
---|
185 | extern const uint16_t softfloat_approxRecipSqrt_1k0s[16];
|
---|
186 | extern const uint16_t softfloat_approxRecipSqrt_1k1s[16];
|
---|
187 |
|
---|
188 | #ifndef softfloat_approxRecipSqrt32_1
|
---|
189 | /*----------------------------------------------------------------------------
|
---|
190 | | Returns an approximation to the reciprocal of the square root of the number
|
---|
191 | | represented by 'a', where 'a' is interpreted as an unsigned fixed-point
|
---|
192 | | number either with one integer bit and 31 fraction bits or with two integer
|
---|
193 | | bits and 30 fraction bits. The format of 'a' is determined by 'oddExpA',
|
---|
194 | | which must be either 0 or 1. If 'oddExpA' is 1, 'a' is interpreted as
|
---|
195 | | having one integer bit, and if 'oddExpA' is 0, 'a' is interpreted as having
|
---|
196 | | two integer bits. The 'a' input must be "normalized", meaning that its
|
---|
197 | | most-significant bit (bit 31) must be 1. Thus, if A is the value of the
|
---|
198 | | fixed-point interpretation of 'a', it follows that 1 <= A < 2 when 'oddExpA'
|
---|
199 | | is 1, and 2 <= A < 4 when 'oddExpA' is 0.
|
---|
200 | | The returned value is interpreted as a pure unsigned fraction, having
|
---|
201 | | no integer bits and 32 fraction bits. The approximation returned is never
|
---|
202 | | greater than the true reciprocal 1/sqrt(A), and it differs from the true
|
---|
203 | | reciprocal by at most 2.06 ulp (units in the last place). The approximation
|
---|
204 | | returned is also always within the range 0.5 to 1; thus, the most-
|
---|
205 | | significant bit of the result is always set.
|
---|
206 | *----------------------------------------------------------------------------*/
|
---|
207 | uint32_t softfloat_approxRecipSqrt32_1( unsigned int oddExpA, uint32_t a );
|
---|
208 | #endif
|
---|
209 |
|
---|
210 | #ifdef SOFTFLOAT_FAST_INT64
|
---|
211 |
|
---|
212 | /*----------------------------------------------------------------------------
|
---|
213 | | The following functions are needed only when 'SOFTFLOAT_FAST_INT64' is
|
---|
214 | | defined.
|
---|
215 | *----------------------------------------------------------------------------*/
|
---|
216 |
|
---|
217 | #ifndef softfloat_eq128
|
---|
218 | /*----------------------------------------------------------------------------
|
---|
219 | | Returns true if the 128-bit unsigned integer formed by concatenating 'a64'
|
---|
220 | | and 'a0' is equal to the 128-bit unsigned integer formed by concatenating
|
---|
221 | | 'b64' and 'b0'.
|
---|
222 | *----------------------------------------------------------------------------*/
|
---|
223 | #if defined INLINE_LEVEL && (1 <= INLINE_LEVEL)
|
---|
224 | INLINE
|
---|
225 | bool softfloat_eq128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
|
---|
226 | { return (a64 == b64) && (a0 == b0); }
|
---|
227 | #else
|
---|
228 | bool softfloat_eq128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 );
|
---|
229 | #endif
|
---|
230 | #endif
|
---|
231 |
|
---|
232 | #ifndef softfloat_le128
|
---|
233 | /*----------------------------------------------------------------------------
|
---|
234 | | Returns true if the 128-bit unsigned integer formed by concatenating 'a64'
|
---|
235 | | and 'a0' is less than or equal to the 128-bit unsigned integer formed by
|
---|
236 | | concatenating 'b64' and 'b0'.
|
---|
237 | *----------------------------------------------------------------------------*/
|
---|
238 | #if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
|
---|
239 | INLINE
|
---|
240 | bool softfloat_le128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
|
---|
241 | { return (a64 < b64) || ((a64 == b64) && (a0 <= b0)); }
|
---|
242 | #else
|
---|
243 | bool softfloat_le128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 );
|
---|
244 | #endif
|
---|
245 | #endif
|
---|
246 |
|
---|
247 | #ifndef softfloat_lt128
|
---|
248 | /*----------------------------------------------------------------------------
|
---|
249 | | Returns true if the 128-bit unsigned integer formed by concatenating 'a64'
|
---|
250 | | and 'a0' is less than the 128-bit unsigned integer formed by concatenating
|
---|
251 | | 'b64' and 'b0'.
|
---|
252 | *----------------------------------------------------------------------------*/
|
---|
253 | #if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
|
---|
254 | INLINE
|
---|
255 | bool softfloat_lt128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
|
---|
256 | { return (a64 < b64) || ((a64 == b64) && (a0 < b0)); }
|
---|
257 | #else
|
---|
258 | bool softfloat_lt128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 );
|
---|
259 | #endif
|
---|
260 | #endif
|
---|
261 |
|
---|
262 | #ifndef softfloat_shortShiftLeft128
|
---|
263 | /*----------------------------------------------------------------------------
|
---|
264 | | Shifts the 128 bits formed by concatenating 'a64' and 'a0' left by the
|
---|
265 | | number of bits given in 'dist', which must be in the range 1 to 63.
|
---|
266 | *----------------------------------------------------------------------------*/
|
---|
267 | #if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
|
---|
268 | INLINE
|
---|
269 | struct uint128
|
---|
270 | softfloat_shortShiftLeft128( uint64_t a64, uint64_t a0, uint_fast8_t dist )
|
---|
271 | {
|
---|
272 | struct uint128 z;
|
---|
273 | z.v64 = a64<<dist | a0>>(-dist & 63);
|
---|
274 | z.v0 = a0<<dist;
|
---|
275 | return z;
|
---|
276 | }
|
---|
277 | #else
|
---|
278 | struct uint128
|
---|
279 | softfloat_shortShiftLeft128( uint64_t a64, uint64_t a0, uint_fast8_t dist );
|
---|
280 | #endif
|
---|
281 | #endif
|
---|
282 |
|
---|
283 | #ifndef softfloat_shortShiftRight128
|
---|
284 | /*----------------------------------------------------------------------------
|
---|
285 | | Shifts the 128 bits formed by concatenating 'a64' and 'a0' right by the
|
---|
286 | | number of bits given in 'dist', which must be in the range 1 to 63.
|
---|
287 | *----------------------------------------------------------------------------*/
|
---|
288 | #if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
|
---|
289 | INLINE
|
---|
290 | struct uint128
|
---|
291 | softfloat_shortShiftRight128( uint64_t a64, uint64_t a0, uint_fast8_t dist )
|
---|
292 | {
|
---|
293 | struct uint128 z;
|
---|
294 | z.v64 = a64>>dist;
|
---|
295 | z.v0 = a64<<(-dist & 63) | a0>>dist;
|
---|
296 | return z;
|
---|
297 | }
|
---|
298 | #else
|
---|
299 | struct uint128
|
---|
300 | softfloat_shortShiftRight128( uint64_t a64, uint64_t a0, uint_fast8_t dist );
|
---|
301 | #endif
|
---|
302 | #endif
|
---|
303 |
|
---|
304 | #ifndef softfloat_shortShiftRightJam64Extra
|
---|
305 | /*----------------------------------------------------------------------------
|
---|
306 | | This function is the same as 'softfloat_shiftRightJam64Extra' (below),
|
---|
307 | | except that 'dist' must be in the range 1 to 63.
|
---|
308 | *----------------------------------------------------------------------------*/
|
---|
309 | #if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
|
---|
310 | INLINE
|
---|
311 | struct uint64_extra
|
---|
312 | softfloat_shortShiftRightJam64Extra(
|
---|
313 | uint64_t a, uint64_t extra, uint_fast8_t dist )
|
---|
314 | {
|
---|
315 | struct uint64_extra z;
|
---|
316 | z.v = a>>dist;
|
---|
317 | z.extra = a<<(-dist & 63) | (extra != 0);
|
---|
318 | return z;
|
---|
319 | }
|
---|
320 | #else
|
---|
321 | struct uint64_extra
|
---|
322 | softfloat_shortShiftRightJam64Extra(
|
---|
323 | uint64_t a, uint64_t extra, uint_fast8_t dist );
|
---|
324 | #endif
|
---|
325 | #endif
|
---|
326 |
|
---|
327 | #ifndef softfloat_shortShiftRightJam128
|
---|
328 | /*----------------------------------------------------------------------------
|
---|
329 | | Shifts the 128 bits formed by concatenating 'a64' and 'a0' right by the
|
---|
330 | | number of bits given in 'dist', which must be in the range 1 to 63. If any
|
---|
331 | | nonzero bits are shifted off, they are "jammed" into the least-significant
|
---|
332 | | bit of the shifted value by setting the least-significant bit to 1. This
|
---|
333 | | shifted-and-jammed value is returned.
|
---|
334 | *----------------------------------------------------------------------------*/
|
---|
335 | #if defined INLINE_LEVEL && (3 <= INLINE_LEVEL)
|
---|
336 | INLINE
|
---|
337 | struct uint128
|
---|
338 | softfloat_shortShiftRightJam128(
|
---|
339 | uint64_t a64, uint64_t a0, uint_fast8_t dist )
|
---|
340 | {
|
---|
341 | uint_fast8_t negDist = -dist;
|
---|
342 | struct uint128 z;
|
---|
343 | z.v64 = a64>>dist;
|
---|
344 | z.v0 =
|
---|
345 | a64<<(negDist & 63) | a0>>dist
|
---|
346 | | ((uint64_t) (a0<<(negDist & 63)) != 0);
|
---|
347 | return z;
|
---|
348 | }
|
---|
349 | #else
|
---|
350 | struct uint128
|
---|
351 | softfloat_shortShiftRightJam128(
|
---|
352 | uint64_t a64, uint64_t a0, uint_fast8_t dist );
|
---|
353 | #endif
|
---|
354 | #endif
|
---|
355 |
|
---|
356 | #ifndef softfloat_shortShiftRightJam128Extra
|
---|
357 | /*----------------------------------------------------------------------------
|
---|
358 | | This function is the same as 'softfloat_shiftRightJam128Extra' (below),
|
---|
359 | | except that 'dist' must be in the range 1 to 63.
|
---|
360 | *----------------------------------------------------------------------------*/
|
---|
361 | #if defined INLINE_LEVEL && (3 <= INLINE_LEVEL)
|
---|
362 | INLINE
|
---|
363 | struct uint128_extra
|
---|
364 | softfloat_shortShiftRightJam128Extra(
|
---|
365 | uint64_t a64, uint64_t a0, uint64_t extra, uint_fast8_t dist )
|
---|
366 | {
|
---|
367 | uint_fast8_t negDist = -dist;
|
---|
368 | struct uint128_extra z;
|
---|
369 | z.v.v64 = a64>>dist;
|
---|
370 | z.v.v0 = a64<<(negDist & 63) | a0>>dist;
|
---|
371 | z.extra = a0<<(negDist & 63) | (extra != 0);
|
---|
372 | return z;
|
---|
373 | }
|
---|
374 | #else
|
---|
375 | struct uint128_extra
|
---|
376 | softfloat_shortShiftRightJam128Extra(
|
---|
377 | uint64_t a64, uint64_t a0, uint64_t extra, uint_fast8_t dist );
|
---|
378 | #endif
|
---|
379 | #endif
|
---|
380 |
|
---|
381 | #ifndef softfloat_shiftRightJam64Extra
|
---|
382 | /*----------------------------------------------------------------------------
|
---|
383 | | Shifts the 128 bits formed by concatenating 'a' and 'extra' right by 64
|
---|
384 | | _plus_ the number of bits given in 'dist', which must not be zero. This
|
---|
385 | | shifted value is at most 64 nonzero bits and is returned in the 'v' field
|
---|
386 | | of the 'struct uint64_extra' result. The 64-bit 'extra' field of the result
|
---|
387 | | contains a value formed as follows from the bits that were shifted off: The
|
---|
388 | | _last_ bit shifted off is the most-significant bit of the 'extra' field, and
|
---|
389 | | the other 63 bits of the 'extra' field are all zero if and only if _all_but_
|
---|
390 | | _the_last_ bits shifted off were all zero.
|
---|
391 | | (This function makes more sense if 'a' and 'extra' are considered to form
|
---|
392 | | an unsigned fixed-point number with binary point between 'a' and 'extra'.
|
---|
393 | | This fixed-point value is shifted right by the number of bits given in
|
---|
394 | | 'dist', and the integer part of this shifted value is returned in the 'v'
|
---|
395 | | field of the result. The fractional part of the shifted value is modified
|
---|
396 | | as described above and returned in the 'extra' field of the result.)
|
---|
397 | *----------------------------------------------------------------------------*/
|
---|
398 | #if defined INLINE_LEVEL && (4 <= INLINE_LEVEL)
|
---|
399 | INLINE
|
---|
400 | struct uint64_extra
|
---|
401 | softfloat_shiftRightJam64Extra(
|
---|
402 | uint64_t a, uint64_t extra, uint_fast32_t dist )
|
---|
403 | {
|
---|
404 | struct uint64_extra z;
|
---|
405 | if ( dist < 64 ) {
|
---|
406 | z.v = a>>dist;
|
---|
407 | z.extra = a<<(-dist & 63);
|
---|
408 | } else {
|
---|
409 | z.v = 0;
|
---|
410 | z.extra = (dist == 64) ? a : (a != 0);
|
---|
411 | }
|
---|
412 | z.extra |= (extra != 0);
|
---|
413 | return z;
|
---|
414 | }
|
---|
415 | #else
|
---|
416 | struct uint64_extra
|
---|
417 | softfloat_shiftRightJam64Extra(
|
---|
418 | uint64_t a, uint64_t extra, uint_fast32_t dist );
|
---|
419 | #endif
|
---|
420 | #endif
|
---|
421 |
|
---|
422 | #ifndef softfloat_shiftRightJam128
|
---|
423 | /*----------------------------------------------------------------------------
|
---|
424 | | Shifts the 128 bits formed by concatenating 'a64' and 'a0' right by the
|
---|
425 | | number of bits given in 'dist', which must not be zero. If any nonzero bits
|
---|
426 | | are shifted off, they are "jammed" into the least-significant bit of the
|
---|
427 | | shifted value by setting the least-significant bit to 1. This shifted-and-
|
---|
428 | | jammed value is returned.
|
---|
429 | | The value of 'dist' can be arbitrarily large. In particular, if 'dist' is
|
---|
430 | | greater than 128, the result will be either 0 or 1, depending on whether the
|
---|
431 | | original 128 bits are all zeros.
|
---|
432 | *----------------------------------------------------------------------------*/
|
---|
433 | struct uint128
|
---|
434 | softfloat_shiftRightJam128( uint64_t a64, uint64_t a0, uint_fast32_t dist );
|
---|
435 | #endif
|
---|
436 |
|
---|
437 | #ifndef softfloat_shiftRightJam128Extra
|
---|
438 | /*----------------------------------------------------------------------------
|
---|
439 | | Shifts the 192 bits formed by concatenating 'a64', 'a0', and 'extra' right
|
---|
440 | | by 64 _plus_ the number of bits given in 'dist', which must not be zero.
|
---|
441 | | This shifted value is at most 128 nonzero bits and is returned in the 'v'
|
---|
442 | | field of the 'struct uint128_extra' result. The 64-bit 'extra' field of the
|
---|
443 | | result contains a value formed as follows from the bits that were shifted
|
---|
444 | | off: The _last_ bit shifted off is the most-significant bit of the 'extra'
|
---|
445 | | field, and the other 63 bits of the 'extra' field are all zero if and only
|
---|
446 | | if _all_but_the_last_ bits shifted off were all zero.
|
---|
447 | | (This function makes more sense if 'a64', 'a0', and 'extra' are considered
|
---|
448 | | to form an unsigned fixed-point number with binary point between 'a0' and
|
---|
449 | | 'extra'. This fixed-point value is shifted right by the number of bits
|
---|
450 | | given in 'dist', and the integer part of this shifted value is returned
|
---|
451 | | in the 'v' field of the result. The fractional part of the shifted value
|
---|
452 | | is modified as described above and returned in the 'extra' field of the
|
---|
453 | | result.)
|
---|
454 | *----------------------------------------------------------------------------*/
|
---|
455 | struct uint128_extra
|
---|
456 | softfloat_shiftRightJam128Extra(
|
---|
457 | uint64_t a64, uint64_t a0, uint64_t extra, uint_fast32_t dist );
|
---|
458 | #endif
|
---|
459 |
|
---|
460 | #ifndef softfloat_shiftRightJam256M
|
---|
461 | /*----------------------------------------------------------------------------
|
---|
462 | | Shifts the 256-bit unsigned integer pointed to by 'aPtr' right by the number
|
---|
463 | | of bits given in 'dist', which must not be zero. If any nonzero bits are
|
---|
464 | | shifted off, they are "jammed" into the least-significant bit of the shifted
|
---|
465 | | value by setting the least-significant bit to 1. This shifted-and-jammed
|
---|
466 | | value is stored at the location pointed to by 'zPtr'. Each of 'aPtr' and
|
---|
467 | | 'zPtr' points to an array of four 64-bit elements that concatenate in the
|
---|
468 | | platform's normal endian order to form a 256-bit integer.
|
---|
469 | | The value of 'dist' can be arbitrarily large. In particular, if 'dist'
|
---|
470 | | is greater than 256, the stored result will be either 0 or 1, depending on
|
---|
471 | | whether the original 256 bits are all zeros.
|
---|
472 | *----------------------------------------------------------------------------*/
|
---|
473 | void
|
---|
474 | softfloat_shiftRightJam256M(
|
---|
475 | const uint64_t *aPtr, uint_fast32_t dist, uint64_t *zPtr );
|
---|
476 | #endif
|
---|
477 |
|
---|
478 | #ifndef softfloat_add128
|
---|
479 | /*----------------------------------------------------------------------------
|
---|
480 | | Returns the sum of the 128-bit integer formed by concatenating 'a64' and
|
---|
481 | | 'a0' and the 128-bit integer formed by concatenating 'b64' and 'b0'. The
|
---|
482 | | addition is modulo 2^128, so any carry out is lost.
|
---|
483 | *----------------------------------------------------------------------------*/
|
---|
484 | #if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
|
---|
485 | INLINE
|
---|
486 | struct uint128
|
---|
487 | softfloat_add128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
|
---|
488 | {
|
---|
489 | struct uint128 z;
|
---|
490 | z.v0 = a0 + b0;
|
---|
491 | z.v64 = a64 + b64 + (z.v0 < a0);
|
---|
492 | return z;
|
---|
493 | }
|
---|
494 | #else
|
---|
495 | struct uint128
|
---|
496 | softfloat_add128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 );
|
---|
497 | #endif
|
---|
498 | #endif
|
---|
499 |
|
---|
500 | #ifndef softfloat_add256M
|
---|
501 | /*----------------------------------------------------------------------------
|
---|
502 | | Adds the two 256-bit integers pointed to by 'aPtr' and 'bPtr'. The addition
|
---|
503 | | is modulo 2^256, so any carry out is lost. The sum is stored at the
|
---|
504 | | location pointed to by 'zPtr'. Each of 'aPtr', 'bPtr', and 'zPtr' points to
|
---|
505 | | an array of four 64-bit elements that concatenate in the platform's normal
|
---|
506 | | endian order to form a 256-bit integer.
|
---|
507 | *----------------------------------------------------------------------------*/
|
---|
508 | void
|
---|
509 | softfloat_add256M(
|
---|
510 | const uint64_t *aPtr, const uint64_t *bPtr, uint64_t *zPtr );
|
---|
511 | #endif
|
---|
512 |
|
---|
513 | #ifndef softfloat_sub128
|
---|
514 | /*----------------------------------------------------------------------------
|
---|
515 | | Returns the difference of the 128-bit integer formed by concatenating 'a64'
|
---|
516 | | and 'a0' and the 128-bit integer formed by concatenating 'b64' and 'b0'.
|
---|
517 | | The subtraction is modulo 2^128, so any borrow out (carry out) is lost.
|
---|
518 | *----------------------------------------------------------------------------*/
|
---|
519 | #if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
|
---|
520 | INLINE
|
---|
521 | struct uint128
|
---|
522 | softfloat_sub128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
|
---|
523 | {
|
---|
524 | struct uint128 z;
|
---|
525 | z.v0 = a0 - b0;
|
---|
526 | z.v64 = a64 - b64;
|
---|
527 | z.v64 -= (a0 < b0);
|
---|
528 | return z;
|
---|
529 | }
|
---|
530 | #else
|
---|
531 | struct uint128
|
---|
532 | softfloat_sub128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 );
|
---|
533 | #endif
|
---|
534 | #endif
|
---|
535 |
|
---|
536 | #ifndef softfloat_sub256M
|
---|
537 | /*----------------------------------------------------------------------------
|
---|
538 | | Subtracts the 256-bit integer pointed to by 'bPtr' from the 256-bit integer
|
---|
539 | | pointed to by 'aPtr'. The addition is modulo 2^256, so any borrow out
|
---|
540 | | (carry out) is lost. The difference is stored at the location pointed to
|
---|
541 | | by 'zPtr'. Each of 'aPtr', 'bPtr', and 'zPtr' points to an array of four
|
---|
542 | | 64-bit elements that concatenate in the platform's normal endian order to
|
---|
543 | | form a 256-bit integer.
|
---|
544 | *----------------------------------------------------------------------------*/
|
---|
545 | void
|
---|
546 | softfloat_sub256M(
|
---|
547 | const uint64_t *aPtr, const uint64_t *bPtr, uint64_t *zPtr );
|
---|
548 | #endif
|
---|
549 |
|
---|
550 | #ifndef softfloat_mul64ByShifted32To128
|
---|
551 | /*----------------------------------------------------------------------------
|
---|
552 | | Returns the 128-bit product of 'a', 'b', and 2^32.
|
---|
553 | *----------------------------------------------------------------------------*/
|
---|
554 | #if defined INLINE_LEVEL && (3 <= INLINE_LEVEL)
|
---|
555 | INLINE struct uint128 softfloat_mul64ByShifted32To128( uint64_t a, uint32_t b )
|
---|
556 | {
|
---|
557 | uint_fast64_t mid;
|
---|
558 | struct uint128 z;
|
---|
559 | mid = (uint_fast64_t) (uint32_t) a * b;
|
---|
560 | z.v0 = mid<<32;
|
---|
561 | z.v64 = (uint_fast64_t) (uint32_t) (a>>32) * b + (mid>>32);
|
---|
562 | return z;
|
---|
563 | }
|
---|
564 | #else
|
---|
565 | struct uint128 softfloat_mul64ByShifted32To128( uint64_t a, uint32_t b );
|
---|
566 | #endif
|
---|
567 | #endif
|
---|
568 |
|
---|
569 | #ifndef softfloat_mul64To128
|
---|
570 | /*----------------------------------------------------------------------------
|
---|
571 | | Returns the 128-bit product of 'a' and 'b'.
|
---|
572 | *----------------------------------------------------------------------------*/
|
---|
573 | struct uint128 softfloat_mul64To128( uint64_t a, uint64_t b );
|
---|
574 | #endif
|
---|
575 |
|
---|
576 | #ifndef softfloat_mul128By32
|
---|
577 | /*----------------------------------------------------------------------------
|
---|
578 | | Returns the product of the 128-bit integer formed by concatenating 'a64' and
|
---|
579 | | 'a0', multiplied by 'b'. The multiplication is modulo 2^128; any overflow
|
---|
580 | | bits are discarded.
|
---|
581 | *----------------------------------------------------------------------------*/
|
---|
582 | #if defined INLINE_LEVEL && (4 <= INLINE_LEVEL)
|
---|
583 | INLINE
|
---|
584 | struct uint128 softfloat_mul128By32( uint64_t a64, uint64_t a0, uint32_t b )
|
---|
585 | {
|
---|
586 | struct uint128 z;
|
---|
587 | uint_fast64_t mid;
|
---|
588 | uint_fast32_t carry;
|
---|
589 | z.v0 = a0 * b;
|
---|
590 | mid = (uint_fast64_t) (uint32_t) (a0>>32) * b;
|
---|
591 | carry = (uint32_t) ((uint_fast32_t) (z.v0>>32) - (uint_fast32_t) mid);
|
---|
592 | z.v64 = a64 * b + (uint_fast32_t) ((mid + carry)>>32);
|
---|
593 | return z;
|
---|
594 | }
|
---|
595 | #else
|
---|
596 | struct uint128 softfloat_mul128By32( uint64_t a64, uint64_t a0, uint32_t b );
|
---|
597 | #endif
|
---|
598 | #endif
|
---|
599 |
|
---|
600 | #ifndef softfloat_mul128To256M
|
---|
601 | /*----------------------------------------------------------------------------
|
---|
602 | | Multiplies the 128-bit unsigned integer formed by concatenating 'a64' and
|
---|
603 | | 'a0' by the 128-bit unsigned integer formed by concatenating 'b64' and
|
---|
604 | | 'b0'. The 256-bit product is stored at the location pointed to by 'zPtr'.
|
---|
605 | | Argument 'zPtr' points to an array of four 64-bit elements that concatenate
|
---|
606 | | in the platform's normal endian order to form a 256-bit integer.
|
---|
607 | *----------------------------------------------------------------------------*/
|
---|
608 | void
|
---|
609 | softfloat_mul128To256M(
|
---|
610 | uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0, uint64_t *zPtr );
|
---|
611 | #endif
|
---|
612 |
|
---|
613 | #else
|
---|
614 |
|
---|
615 | /*----------------------------------------------------------------------------
|
---|
616 | | The following functions are needed only when 'SOFTFLOAT_FAST_INT64' is not
|
---|
617 | | defined.
|
---|
618 | *----------------------------------------------------------------------------*/
|
---|
619 |
|
---|
620 | #ifndef softfloat_compare96M
|
---|
621 | /*----------------------------------------------------------------------------
|
---|
622 | | Compares the two 96-bit unsigned integers pointed to by 'aPtr' and 'bPtr'.
|
---|
623 | | Returns -1 if the first integer (A) is less than the second (B); returns 0
|
---|
624 | | if the two integers are equal; and returns +1 if the first integer (A)
|
---|
625 | | is greater than the second (B). (The result is thus the signum of A - B.)
|
---|
626 | | Each of 'aPtr' and 'bPtr' points to an array of three 32-bit elements that
|
---|
627 | | concatenate in the platform's normal endian order to form a 96-bit integer.
|
---|
628 | *----------------------------------------------------------------------------*/
|
---|
629 | int_fast8_t softfloat_compare96M( const uint32_t *aPtr, const uint32_t *bPtr );
|
---|
630 | #endif
|
---|
631 |
|
---|
632 | #ifndef softfloat_compare128M
|
---|
633 | /*----------------------------------------------------------------------------
|
---|
634 | | Compares the two 128-bit unsigned integers pointed to by 'aPtr' and 'bPtr'.
|
---|
635 | | Returns -1 if the first integer (A) is less than the second (B); returns 0
|
---|
636 | | if the two integers are equal; and returns +1 if the first integer (A)
|
---|
637 | | is greater than the second (B). (The result is thus the signum of A - B.)
|
---|
638 | | Each of 'aPtr' and 'bPtr' points to an array of four 32-bit elements that
|
---|
639 | | concatenate in the platform's normal endian order to form a 128-bit integer.
|
---|
640 | *----------------------------------------------------------------------------*/
|
---|
641 | int_fast8_t
|
---|
642 | softfloat_compare128M( const uint32_t *aPtr, const uint32_t *bPtr );
|
---|
643 | #endif
|
---|
644 |
|
---|
645 | #ifndef softfloat_shortShiftLeft64To96M
|
---|
646 | /*----------------------------------------------------------------------------
|
---|
647 | | Extends 'a' to 96 bits and shifts the value left by the number of bits given
|
---|
648 | | in 'dist', which must be in the range 1 to 31. The result is stored at the
|
---|
649 | | location pointed to by 'zPtr'. Argument 'zPtr' points to an array of three
|
---|
650 | | 32-bit elements that concatenate in the platform's normal endian order to
|
---|
651 | | form a 96-bit integer.
|
---|
652 | *----------------------------------------------------------------------------*/
|
---|
653 | #if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
|
---|
654 | INLINE
|
---|
655 | void
|
---|
656 | softfloat_shortShiftLeft64To96M(
|
---|
657 | uint64_t a, uint_fast8_t dist, uint32_t *zPtr )
|
---|
658 | {
|
---|
659 | zPtr[indexWord( 3, 0 )] = (uint32_t) a<<dist;
|
---|
660 | a >>= 32 - dist;
|
---|
661 | zPtr[indexWord( 3, 2 )] = a>>32;
|
---|
662 | zPtr[indexWord( 3, 1 )] = a;
|
---|
663 | }
|
---|
664 | #else
|
---|
665 | void
|
---|
666 | softfloat_shortShiftLeft64To96M(
|
---|
667 | uint64_t a, uint_fast8_t dist, uint32_t *zPtr );
|
---|
668 | #endif
|
---|
669 | #endif
|
---|
670 |
|
---|
671 | #ifndef softfloat_shortShiftLeftM
|
---|
672 | /*----------------------------------------------------------------------------
|
---|
673 | | Shifts the N-bit unsigned integer pointed to by 'aPtr' left by the number
|
---|
674 | | of bits given in 'dist', where N = 'size_words' * 32. The value of 'dist'
|
---|
675 | | must be in the range 1 to 31. Any nonzero bits shifted off are lost. The
|
---|
676 | | shifted N-bit result is stored at the location pointed to by 'zPtr'. Each
|
---|
677 | | of 'aPtr' and 'zPtr' points to a 'size_words'-long array of 32-bit elements
|
---|
678 | | that concatenate in the platform's normal endian order to form an N-bit
|
---|
679 | | integer.
|
---|
680 | *----------------------------------------------------------------------------*/
|
---|
681 | void
|
---|
682 | softfloat_shortShiftLeftM(
|
---|
683 | uint_fast8_t size_words,
|
---|
684 | const uint32_t *aPtr,
|
---|
685 | uint_fast8_t dist,
|
---|
686 | uint32_t *zPtr
|
---|
687 | );
|
---|
688 | #endif
|
---|
689 |
|
---|
690 | #ifndef softfloat_shortShiftLeft96M
|
---|
691 | /*----------------------------------------------------------------------------
|
---|
692 | | This function or macro is the same as 'softfloat_shortShiftLeftM' with
|
---|
693 | | 'size_words' = 3 (N = 96).
|
---|
694 | *----------------------------------------------------------------------------*/
|
---|
695 | #define softfloat_shortShiftLeft96M( aPtr, dist, zPtr ) softfloat_shortShiftLeftM( 3, aPtr, dist, zPtr )
|
---|
696 | #endif
|
---|
697 |
|
---|
698 | #ifndef softfloat_shortShiftLeft128M
|
---|
699 | /*----------------------------------------------------------------------------
|
---|
700 | | This function or macro is the same as 'softfloat_shortShiftLeftM' with
|
---|
701 | | 'size_words' = 4 (N = 128).
|
---|
702 | *----------------------------------------------------------------------------*/
|
---|
703 | #define softfloat_shortShiftLeft128M( aPtr, dist, zPtr ) softfloat_shortShiftLeftM( 4, aPtr, dist, zPtr )
|
---|
704 | #endif
|
---|
705 |
|
---|
706 | #ifndef softfloat_shortShiftLeft160M
|
---|
707 | /*----------------------------------------------------------------------------
|
---|
708 | | This function or macro is the same as 'softfloat_shortShiftLeftM' with
|
---|
709 | | 'size_words' = 5 (N = 160).
|
---|
710 | *----------------------------------------------------------------------------*/
|
---|
711 | #define softfloat_shortShiftLeft160M( aPtr, dist, zPtr ) softfloat_shortShiftLeftM( 5, aPtr, dist, zPtr )
|
---|
712 | #endif
|
---|
713 |
|
---|
714 | #ifndef softfloat_shiftLeftM
|
---|
715 | /*----------------------------------------------------------------------------
|
---|
716 | | Shifts the N-bit unsigned integer pointed to by 'aPtr' left by the number
|
---|
717 | | of bits given in 'dist', where N = 'size_words' * 32. The value of 'dist'
|
---|
718 | | must not be zero. Any nonzero bits shifted off are lost. The shifted
|
---|
719 | | N-bit result is stored at the location pointed to by 'zPtr'. Each of 'aPtr'
|
---|
720 | | and 'zPtr' points to a 'size_words'-long array of 32-bit elements that
|
---|
721 | | concatenate in the platform's normal endian order to form an N-bit integer.
|
---|
722 | | The value of 'dist' can be arbitrarily large. In particular, if 'dist' is
|
---|
723 | | greater than N, the stored result will be 0.
|
---|
724 | *----------------------------------------------------------------------------*/
|
---|
725 | void
|
---|
726 | softfloat_shiftLeftM(
|
---|
727 | uint_fast8_t size_words,
|
---|
728 | const uint32_t *aPtr,
|
---|
729 | uint32_t dist,
|
---|
730 | uint32_t *zPtr
|
---|
731 | );
|
---|
732 | #endif
|
---|
733 |
|
---|
734 | #ifndef softfloat_shiftLeft96M
|
---|
735 | /*----------------------------------------------------------------------------
|
---|
736 | | This function or macro is the same as 'softfloat_shiftLeftM' with
|
---|
737 | | 'size_words' = 3 (N = 96).
|
---|
738 | *----------------------------------------------------------------------------*/
|
---|
739 | #define softfloat_shiftLeft96M( aPtr, dist, zPtr ) softfloat_shiftLeftM( 3, aPtr, dist, zPtr )
|
---|
740 | #endif
|
---|
741 |
|
---|
742 | #ifndef softfloat_shiftLeft128M
|
---|
743 | /*----------------------------------------------------------------------------
|
---|
744 | | This function or macro is the same as 'softfloat_shiftLeftM' with
|
---|
745 | | 'size_words' = 4 (N = 128).
|
---|
746 | *----------------------------------------------------------------------------*/
|
---|
747 | #define softfloat_shiftLeft128M( aPtr, dist, zPtr ) softfloat_shiftLeftM( 4, aPtr, dist, zPtr )
|
---|
748 | #endif
|
---|
749 |
|
---|
750 | #ifndef softfloat_shiftLeft160M
|
---|
751 | /*----------------------------------------------------------------------------
|
---|
752 | | This function or macro is the same as 'softfloat_shiftLeftM' with
|
---|
753 | | 'size_words' = 5 (N = 160).
|
---|
754 | *----------------------------------------------------------------------------*/
|
---|
755 | #define softfloat_shiftLeft160M( aPtr, dist, zPtr ) softfloat_shiftLeftM( 5, aPtr, dist, zPtr )
|
---|
756 | #endif
|
---|
757 |
|
---|
758 | #ifndef softfloat_shortShiftRightM
|
---|
759 | /*----------------------------------------------------------------------------
|
---|
760 | | Shifts the N-bit unsigned integer pointed to by 'aPtr' right by the number
|
---|
761 | | of bits given in 'dist', where N = 'size_words' * 32. The value of 'dist'
|
---|
762 | | must be in the range 1 to 31. Any nonzero bits shifted off are lost. The
|
---|
763 | | shifted N-bit result is stored at the location pointed to by 'zPtr'. Each
|
---|
764 | | of 'aPtr' and 'zPtr' points to a 'size_words'-long array of 32-bit elements
|
---|
765 | | that concatenate in the platform's normal endian order to form an N-bit
|
---|
766 | | integer.
|
---|
767 | *----------------------------------------------------------------------------*/
|
---|
768 | void
|
---|
769 | softfloat_shortShiftRightM(
|
---|
770 | uint_fast8_t size_words,
|
---|
771 | const uint32_t *aPtr,
|
---|
772 | uint_fast8_t dist,
|
---|
773 | uint32_t *zPtr
|
---|
774 | );
|
---|
775 | #endif
|
---|
776 |
|
---|
777 | #ifndef softfloat_shortShiftRight128M
|
---|
778 | /*----------------------------------------------------------------------------
|
---|
779 | | This function or macro is the same as 'softfloat_shortShiftRightM' with
|
---|
780 | | 'size_words' = 4 (N = 128).
|
---|
781 | *----------------------------------------------------------------------------*/
|
---|
782 | #define softfloat_shortShiftRight128M( aPtr, dist, zPtr ) softfloat_shortShiftRightM( 4, aPtr, dist, zPtr )
|
---|
783 | #endif
|
---|
784 |
|
---|
785 | #ifndef softfloat_shortShiftRight160M
|
---|
786 | /*----------------------------------------------------------------------------
|
---|
787 | | This function or macro is the same as 'softfloat_shortShiftRightM' with
|
---|
788 | | 'size_words' = 5 (N = 160).
|
---|
789 | *----------------------------------------------------------------------------*/
|
---|
790 | #define softfloat_shortShiftRight160M( aPtr, dist, zPtr ) softfloat_shortShiftRightM( 5, aPtr, dist, zPtr )
|
---|
791 | #endif
|
---|
792 |
|
---|
793 | #ifndef softfloat_shortShiftRightJamM
|
---|
794 | /*----------------------------------------------------------------------------
|
---|
795 | | Shifts the N-bit unsigned integer pointed to by 'aPtr' right by the number
|
---|
796 | | of bits given in 'dist', where N = 'size_words' * 32. The value of 'dist'
|
---|
797 | | must be in the range 1 to 31. If any nonzero bits are shifted off, they are
|
---|
798 | | "jammed" into the least-significant bit of the shifted value by setting the
|
---|
799 | | least-significant bit to 1. This shifted-and-jammed N-bit result is stored
|
---|
800 | | at the location pointed to by 'zPtr'. Each of 'aPtr' and 'zPtr' points
|
---|
801 | | to a 'size_words'-long array of 32-bit elements that concatenate in the
|
---|
802 | | platform's normal endian order to form an N-bit integer.
|
---|
803 | *----------------------------------------------------------------------------*/
|
---|
804 | void
|
---|
805 | softfloat_shortShiftRightJamM(
|
---|
806 | uint_fast8_t, const uint32_t *, uint_fast8_t, uint32_t * );
|
---|
807 | #endif
|
---|
808 |
|
---|
809 | #ifndef softfloat_shortShiftRightJam160M
|
---|
810 | /*----------------------------------------------------------------------------
|
---|
811 | | This function or macro is the same as 'softfloat_shortShiftRightJamM' with
|
---|
812 | | 'size_words' = 5 (N = 160).
|
---|
813 | *----------------------------------------------------------------------------*/
|
---|
814 | #define softfloat_shortShiftRightJam160M( aPtr, dist, zPtr ) softfloat_shortShiftRightJamM( 5, aPtr, dist, zPtr )
|
---|
815 | #endif
|
---|
816 |
|
---|
817 | #ifndef softfloat_shiftRightM
|
---|
818 | /*----------------------------------------------------------------------------
|
---|
819 | | Shifts the N-bit unsigned integer pointed to by 'aPtr' right by the number
|
---|
820 | | of bits given in 'dist', where N = 'size_words' * 32. The value of 'dist'
|
---|
821 | | must not be zero. Any nonzero bits shifted off are lost. The shifted
|
---|
822 | | N-bit result is stored at the location pointed to by 'zPtr'. Each of 'aPtr'
|
---|
823 | | and 'zPtr' points to a 'size_words'-long array of 32-bit elements that
|
---|
824 | | concatenate in the platform's normal endian order to form an N-bit integer.
|
---|
825 | | The value of 'dist' can be arbitrarily large. In particular, if 'dist' is
|
---|
826 | | greater than N, the stored result will be 0.
|
---|
827 | *----------------------------------------------------------------------------*/
|
---|
828 | void
|
---|
829 | softfloat_shiftRightM(
|
---|
830 | uint_fast8_t size_words,
|
---|
831 | const uint32_t *aPtr,
|
---|
832 | uint32_t dist,
|
---|
833 | uint32_t *zPtr
|
---|
834 | );
|
---|
835 | #endif
|
---|
836 |
|
---|
837 | #ifndef softfloat_shiftRight96M
|
---|
838 | /*----------------------------------------------------------------------------
|
---|
839 | | This function or macro is the same as 'softfloat_shiftRightM' with
|
---|
840 | | 'size_words' = 3 (N = 96).
|
---|
841 | *----------------------------------------------------------------------------*/
|
---|
842 | #define softfloat_shiftRight96M( aPtr, dist, zPtr ) softfloat_shiftRightM( 3, aPtr, dist, zPtr )
|
---|
843 | #endif
|
---|
844 |
|
---|
845 | #ifndef softfloat_shiftRightJamM
|
---|
846 | /*----------------------------------------------------------------------------
|
---|
847 | | Shifts the N-bit unsigned integer pointed to by 'aPtr' right by the number
|
---|
848 | | of bits given in 'dist', where N = 'size_words' * 32. The value of 'dist'
|
---|
849 | | must not be zero. If any nonzero bits are shifted off, they are "jammed"
|
---|
850 | | into the least-significant bit of the shifted value by setting the least-
|
---|
851 | | significant bit to 1. This shifted-and-jammed N-bit result is stored
|
---|
852 | | at the location pointed to by 'zPtr'. Each of 'aPtr' and 'zPtr' points
|
---|
853 | | to a 'size_words'-long array of 32-bit elements that concatenate in the
|
---|
854 | | platform's normal endian order to form an N-bit integer.
|
---|
855 | | The value of 'dist' can be arbitrarily large. In particular, if 'dist'
|
---|
856 | | is greater than N, the stored result will be either 0 or 1, depending on
|
---|
857 | | whether the original N bits are all zeros.
|
---|
858 | *----------------------------------------------------------------------------*/
|
---|
859 | void
|
---|
860 | softfloat_shiftRightJamM(
|
---|
861 | uint_fast8_t size_words,
|
---|
862 | const uint32_t *aPtr,
|
---|
863 | uint32_t dist,
|
---|
864 | uint32_t *zPtr
|
---|
865 | );
|
---|
866 | #endif
|
---|
867 |
|
---|
868 | #ifndef softfloat_shiftRightJam96M
|
---|
869 | /*----------------------------------------------------------------------------
|
---|
870 | | This function or macro is the same as 'softfloat_shiftRightJamM' with
|
---|
871 | | 'size_words' = 3 (N = 96).
|
---|
872 | *----------------------------------------------------------------------------*/
|
---|
873 | #define softfloat_shiftRightJam96M( aPtr, dist, zPtr ) softfloat_shiftRightJamM( 3, aPtr, dist, zPtr )
|
---|
874 | #endif
|
---|
875 |
|
---|
876 | #ifndef softfloat_shiftRightJam128M
|
---|
877 | /*----------------------------------------------------------------------------
|
---|
878 | | This function or macro is the same as 'softfloat_shiftRightJamM' with
|
---|
879 | | 'size_words' = 4 (N = 128).
|
---|
880 | *----------------------------------------------------------------------------*/
|
---|
881 | #define softfloat_shiftRightJam128M( aPtr, dist, zPtr ) softfloat_shiftRightJamM( 4, aPtr, dist, zPtr )
|
---|
882 | #endif
|
---|
883 |
|
---|
884 | #ifndef softfloat_shiftRightJam160M
|
---|
885 | /*----------------------------------------------------------------------------
|
---|
886 | | This function or macro is the same as 'softfloat_shiftRightJamM' with
|
---|
887 | | 'size_words' = 5 (N = 160).
|
---|
888 | *----------------------------------------------------------------------------*/
|
---|
889 | #define softfloat_shiftRightJam160M( aPtr, dist, zPtr ) softfloat_shiftRightJamM( 5, aPtr, dist, zPtr )
|
---|
890 | #endif
|
---|
891 |
|
---|
892 | #ifndef softfloat_addM
|
---|
893 | /*----------------------------------------------------------------------------
|
---|
894 | | Adds the two N-bit integers pointed to by 'aPtr' and 'bPtr', where N =
|
---|
895 | | 'size_words' * 32. The addition is modulo 2^N, so any carry out is lost.
|
---|
896 | | The N-bit sum is stored at the location pointed to by 'zPtr'. Each of
|
---|
897 | | 'aPtr', 'bPtr', and 'zPtr' points to a 'size_words'-long array of 32-bit
|
---|
898 | | elements that concatenate in the platform's normal endian order to form an
|
---|
899 | | N-bit integer.
|
---|
900 | *----------------------------------------------------------------------------*/
|
---|
901 | void
|
---|
902 | softfloat_addM(
|
---|
903 | uint_fast8_t size_words,
|
---|
904 | const uint32_t *aPtr,
|
---|
905 | const uint32_t *bPtr,
|
---|
906 | uint32_t *zPtr
|
---|
907 | );
|
---|
908 | #endif
|
---|
909 |
|
---|
910 | #ifndef softfloat_add96M
|
---|
911 | /*----------------------------------------------------------------------------
|
---|
912 | | This function or macro is the same as 'softfloat_addM' with 'size_words'
|
---|
913 | | = 3 (N = 96).
|
---|
914 | *----------------------------------------------------------------------------*/
|
---|
915 | #define softfloat_add96M( aPtr, bPtr, zPtr ) softfloat_addM( 3, aPtr, bPtr, zPtr )
|
---|
916 | #endif
|
---|
917 |
|
---|
918 | #ifndef softfloat_add128M
|
---|
919 | /*----------------------------------------------------------------------------
|
---|
920 | | This function or macro is the same as 'softfloat_addM' with 'size_words'
|
---|
921 | | = 4 (N = 128).
|
---|
922 | *----------------------------------------------------------------------------*/
|
---|
923 | #define softfloat_add128M( aPtr, bPtr, zPtr ) softfloat_addM( 4, aPtr, bPtr, zPtr )
|
---|
924 | #endif
|
---|
925 |
|
---|
926 | #ifndef softfloat_add160M
|
---|
927 | /*----------------------------------------------------------------------------
|
---|
928 | | This function or macro is the same as 'softfloat_addM' with 'size_words'
|
---|
929 | | = 5 (N = 160).
|
---|
930 | *----------------------------------------------------------------------------*/
|
---|
931 | #define softfloat_add160M( aPtr, bPtr, zPtr ) softfloat_addM( 5, aPtr, bPtr, zPtr )
|
---|
932 | #endif
|
---|
933 |
|
---|
934 | #ifndef softfloat_addCarryM
|
---|
935 | /*----------------------------------------------------------------------------
|
---|
936 | | Adds the two N-bit unsigned integers pointed to by 'aPtr' and 'bPtr', where
|
---|
937 | | N = 'size_words' * 32, plus 'carry', which must be either 0 or 1. The N-bit
|
---|
938 | | sum (modulo 2^N) is stored at the location pointed to by 'zPtr', and any
|
---|
939 | | carry out is returned as the result. Each of 'aPtr', 'bPtr', and 'zPtr'
|
---|
940 | | points to a 'size_words'-long array of 32-bit elements that concatenate in
|
---|
941 | | the platform's normal endian order to form an N-bit integer.
|
---|
942 | *----------------------------------------------------------------------------*/
|
---|
943 | uint_fast8_t
|
---|
944 | softfloat_addCarryM(
|
---|
945 | uint_fast8_t size_words,
|
---|
946 | const uint32_t *aPtr,
|
---|
947 | const uint32_t *bPtr,
|
---|
948 | uint_fast8_t carry,
|
---|
949 | uint32_t *zPtr
|
---|
950 | );
|
---|
951 | #endif
|
---|
952 |
|
---|
953 | #ifndef softfloat_addComplCarryM
|
---|
954 | /*----------------------------------------------------------------------------
|
---|
955 | | This function or macro is the same as 'softfloat_addCarryM', except that
|
---|
956 | | the value of the unsigned integer pointed to by 'bPtr' is bit-wise completed
|
---|
957 | | before the addition.
|
---|
958 | *----------------------------------------------------------------------------*/
|
---|
959 | uint_fast8_t
|
---|
960 | softfloat_addComplCarryM(
|
---|
961 | uint_fast8_t size_words,
|
---|
962 | const uint32_t *aPtr,
|
---|
963 | const uint32_t *bPtr,
|
---|
964 | uint_fast8_t carry,
|
---|
965 | uint32_t *zPtr
|
---|
966 | );
|
---|
967 | #endif
|
---|
968 |
|
---|
969 | #ifndef softfloat_addComplCarry96M
|
---|
970 | /*----------------------------------------------------------------------------
|
---|
971 | | This function or macro is the same as 'softfloat_addComplCarryM' with
|
---|
972 | | 'size_words' = 3 (N = 96).
|
---|
973 | *----------------------------------------------------------------------------*/
|
---|
974 | #define softfloat_addComplCarry96M( aPtr, bPtr, carry, zPtr ) softfloat_addComplCarryM( 3, aPtr, bPtr, carry, zPtr )
|
---|
975 | #endif
|
---|
976 |
|
---|
977 | #ifndef softfloat_negXM
|
---|
978 | /*----------------------------------------------------------------------------
|
---|
979 | | Replaces the N-bit unsigned integer pointed to by 'zPtr' by the
|
---|
980 | | 2s-complement of itself, where N = 'size_words' * 32. Argument 'zPtr'
|
---|
981 | | points to a 'size_words'-long array of 32-bit elements that concatenate in
|
---|
982 | | the platform's normal endian order to form an N-bit integer.
|
---|
983 | *----------------------------------------------------------------------------*/
|
---|
984 | void softfloat_negXM( uint_fast8_t size_words, uint32_t *zPtr );
|
---|
985 | #endif
|
---|
986 |
|
---|
987 | #ifndef softfloat_negX96M
|
---|
988 | /*----------------------------------------------------------------------------
|
---|
989 | | This function or macro is the same as 'softfloat_negXM' with 'size_words'
|
---|
990 | | = 3 (N = 96).
|
---|
991 | *----------------------------------------------------------------------------*/
|
---|
992 | #define softfloat_negX96M( zPtr ) softfloat_negXM( 3, zPtr )
|
---|
993 | #endif
|
---|
994 |
|
---|
995 | #ifndef softfloat_negX128M
|
---|
996 | /*----------------------------------------------------------------------------
|
---|
997 | | This function or macro is the same as 'softfloat_negXM' with 'size_words'
|
---|
998 | | = 4 (N = 128).
|
---|
999 | *----------------------------------------------------------------------------*/
|
---|
1000 | #define softfloat_negX128M( zPtr ) softfloat_negXM( 4, zPtr )
|
---|
1001 | #endif
|
---|
1002 |
|
---|
1003 | #ifndef softfloat_negX160M
|
---|
1004 | /*----------------------------------------------------------------------------
|
---|
1005 | | This function or macro is the same as 'softfloat_negXM' with 'size_words'
|
---|
1006 | | = 5 (N = 160).
|
---|
1007 | *----------------------------------------------------------------------------*/
|
---|
1008 | #define softfloat_negX160M( zPtr ) softfloat_negXM( 5, zPtr )
|
---|
1009 | #endif
|
---|
1010 |
|
---|
1011 | #ifndef softfloat_negX256M
|
---|
1012 | /*----------------------------------------------------------------------------
|
---|
1013 | | This function or macro is the same as 'softfloat_negXM' with 'size_words'
|
---|
1014 | | = 8 (N = 256).
|
---|
1015 | *----------------------------------------------------------------------------*/
|
---|
1016 | #define softfloat_negX256M( zPtr ) softfloat_negXM( 8, zPtr )
|
---|
1017 | #endif
|
---|
1018 |
|
---|
1019 | #ifndef softfloat_sub1XM
|
---|
1020 | /*----------------------------------------------------------------------------
|
---|
1021 | | Subtracts 1 from the N-bit integer pointed to by 'zPtr', where N =
|
---|
1022 | | 'size_words' * 32. The subtraction is modulo 2^N, so any borrow out (carry
|
---|
1023 | | out) is lost. Argument 'zPtr' points to a 'size_words'-long array of 32-bit
|
---|
1024 | | elements that concatenate in the platform's normal endian order to form an
|
---|
1025 | | N-bit integer.
|
---|
1026 | *----------------------------------------------------------------------------*/
|
---|
1027 | void softfloat_sub1XM( uint_fast8_t size_words, uint32_t *zPtr );
|
---|
1028 | #endif
|
---|
1029 |
|
---|
1030 | #ifndef softfloat_sub1X96M
|
---|
1031 | /*----------------------------------------------------------------------------
|
---|
1032 | | This function or macro is the same as 'softfloat_sub1XM' with 'size_words'
|
---|
1033 | | = 3 (N = 96).
|
---|
1034 | *----------------------------------------------------------------------------*/
|
---|
1035 | #define softfloat_sub1X96M( zPtr ) softfloat_sub1XM( 3, zPtr )
|
---|
1036 | #endif
|
---|
1037 |
|
---|
1038 | #ifndef softfloat_sub1X160M
|
---|
1039 | /*----------------------------------------------------------------------------
|
---|
1040 | | This function or macro is the same as 'softfloat_sub1XM' with 'size_words'
|
---|
1041 | | = 5 (N = 160).
|
---|
1042 | *----------------------------------------------------------------------------*/
|
---|
1043 | #define softfloat_sub1X160M( zPtr ) softfloat_sub1XM( 5, zPtr )
|
---|
1044 | #endif
|
---|
1045 |
|
---|
1046 | #ifndef softfloat_subM
|
---|
1047 | /*----------------------------------------------------------------------------
|
---|
1048 | | Subtracts the two N-bit integers pointed to by 'aPtr' and 'bPtr', where N =
|
---|
1049 | | 'size_words' * 32. The subtraction is modulo 2^N, so any borrow out (carry
|
---|
1050 | | out) is lost. The N-bit difference is stored at the location pointed to by
|
---|
1051 | | 'zPtr'. Each of 'aPtr', 'bPtr', and 'zPtr' points to a 'size_words'-long
|
---|
1052 | | array of 32-bit elements that concatenate in the platform's normal endian
|
---|
1053 | | order to form an N-bit integer.
|
---|
1054 | *----------------------------------------------------------------------------*/
|
---|
1055 | void
|
---|
1056 | softfloat_subM(
|
---|
1057 | uint_fast8_t size_words,
|
---|
1058 | const uint32_t *aPtr,
|
---|
1059 | const uint32_t *bPtr,
|
---|
1060 | uint32_t *zPtr
|
---|
1061 | );
|
---|
1062 | #endif
|
---|
1063 |
|
---|
1064 | #ifndef softfloat_sub96M
|
---|
1065 | /*----------------------------------------------------------------------------
|
---|
1066 | | This function or macro is the same as 'softfloat_subM' with 'size_words'
|
---|
1067 | | = 3 (N = 96).
|
---|
1068 | *----------------------------------------------------------------------------*/
|
---|
1069 | #define softfloat_sub96M( aPtr, bPtr, zPtr ) softfloat_subM( 3, aPtr, bPtr, zPtr )
|
---|
1070 | #endif
|
---|
1071 |
|
---|
1072 | #ifndef softfloat_sub128M
|
---|
1073 | /*----------------------------------------------------------------------------
|
---|
1074 | | This function or macro is the same as 'softfloat_subM' with 'size_words'
|
---|
1075 | | = 4 (N = 128).
|
---|
1076 | *----------------------------------------------------------------------------*/
|
---|
1077 | #define softfloat_sub128M( aPtr, bPtr, zPtr ) softfloat_subM( 4, aPtr, bPtr, zPtr )
|
---|
1078 | #endif
|
---|
1079 |
|
---|
1080 | #ifndef softfloat_sub160M
|
---|
1081 | /*----------------------------------------------------------------------------
|
---|
1082 | | This function or macro is the same as 'softfloat_subM' with 'size_words'
|
---|
1083 | | = 5 (N = 160).
|
---|
1084 | *----------------------------------------------------------------------------*/
|
---|
1085 | #define softfloat_sub160M( aPtr, bPtr, zPtr ) softfloat_subM( 5, aPtr, bPtr, zPtr )
|
---|
1086 | #endif
|
---|
1087 |
|
---|
1088 | #ifndef softfloat_mul64To128M
|
---|
1089 | /*----------------------------------------------------------------------------
|
---|
1090 | | Multiplies 'a' and 'b' and stores the 128-bit product at the location
|
---|
1091 | | pointed to by 'zPtr'. Argument 'zPtr' points to an array of four 32-bit
|
---|
1092 | | elements that concatenate in the platform's normal endian order to form a
|
---|
1093 | | 128-bit integer.
|
---|
1094 | *----------------------------------------------------------------------------*/
|
---|
1095 | void softfloat_mul64To128M( uint64_t a, uint64_t b, uint32_t *zPtr );
|
---|
1096 | #endif
|
---|
1097 |
|
---|
1098 | #ifndef softfloat_mul128MTo256M
|
---|
1099 | /*----------------------------------------------------------------------------
|
---|
1100 | | Multiplies the two 128-bit unsigned integers pointed to by 'aPtr' and
|
---|
1101 | | 'bPtr', and stores the 256-bit product at the location pointed to by 'zPtr'.
|
---|
1102 | | Each of 'aPtr' and 'bPtr' points to an array of four 32-bit elements that
|
---|
1103 | | concatenate in the platform's normal endian order to form a 128-bit integer.
|
---|
1104 | | Argument 'zPtr' points to an array of eight 32-bit elements that concatenate
|
---|
1105 | | to form a 256-bit integer.
|
---|
1106 | *----------------------------------------------------------------------------*/
|
---|
1107 | void
|
---|
1108 | softfloat_mul128MTo256M(
|
---|
1109 | const uint32_t *aPtr, const uint32_t *bPtr, uint32_t *zPtr );
|
---|
1110 | #endif
|
---|
1111 |
|
---|
1112 | #ifndef softfloat_remStepMBy32
|
---|
1113 | /*----------------------------------------------------------------------------
|
---|
1114 | | Performs a "remainder reduction step" as follows: Arguments 'remPtr' and
|
---|
1115 | | 'bPtr' both point to N-bit unsigned integers, where N = 'size_words' * 32.
|
---|
1116 | | Defining R and B as the values of those integers, the expression (R<<'dist')
|
---|
1117 | | - B * q is computed modulo 2^N, and the N-bit result is stored at the
|
---|
1118 | | location pointed to by 'zPtr'. Each of 'remPtr', 'bPtr', and 'zPtr' points
|
---|
1119 | | to a 'size_words'-long array of 32-bit elements that concatenate in the
|
---|
1120 | | platform's normal endian order to form an N-bit integer.
|
---|
1121 | *----------------------------------------------------------------------------*/
|
---|
1122 | void
|
---|
1123 | softfloat_remStepMBy32(
|
---|
1124 | uint_fast8_t size_words,
|
---|
1125 | const uint32_t *remPtr,
|
---|
1126 | uint_fast8_t dist,
|
---|
1127 | const uint32_t *bPtr,
|
---|
1128 | uint32_t q,
|
---|
1129 | uint32_t *zPtr
|
---|
1130 | );
|
---|
1131 | #endif
|
---|
1132 |
|
---|
1133 | #ifndef softfloat_remStep96MBy32
|
---|
1134 | /*----------------------------------------------------------------------------
|
---|
1135 | | This function or macro is the same as 'softfloat_remStepMBy32' with
|
---|
1136 | | 'size_words' = 3 (N = 96).
|
---|
1137 | *----------------------------------------------------------------------------*/
|
---|
1138 | #define softfloat_remStep96MBy32( remPtr, dist, bPtr, q, zPtr ) softfloat_remStepMBy32( 3, remPtr, dist, bPtr, q, zPtr )
|
---|
1139 | #endif
|
---|
1140 |
|
---|
1141 | #ifndef softfloat_remStep128MBy32
|
---|
1142 | /*----------------------------------------------------------------------------
|
---|
1143 | | This function or macro is the same as 'softfloat_remStepMBy32' with
|
---|
1144 | | 'size_words' = 4 (N = 128).
|
---|
1145 | *----------------------------------------------------------------------------*/
|
---|
1146 | #define softfloat_remStep128MBy32( remPtr, dist, bPtr, q, zPtr ) softfloat_remStepMBy32( 4, remPtr, dist, bPtr, q, zPtr )
|
---|
1147 | #endif
|
---|
1148 |
|
---|
1149 | #ifndef softfloat_remStep160MBy32
|
---|
1150 | /*----------------------------------------------------------------------------
|
---|
1151 | | This function or macro is the same as 'softfloat_remStepMBy32' with
|
---|
1152 | | 'size_words' = 5 (N = 160).
|
---|
1153 | *----------------------------------------------------------------------------*/
|
---|
1154 | #define softfloat_remStep160MBy32( remPtr, dist, bPtr, q, zPtr ) softfloat_remStepMBy32( 5, remPtr, dist, bPtr, q, zPtr )
|
---|
1155 | #endif
|
---|
1156 |
|
---|
1157 | #endif
|
---|
1158 |
|
---|
1159 | #endif
|
---|
1160 |
|
---|