softfloat-macros.h revision 1.1.2.2 1 1.1.2.2 nathanw /* $NetBSD: softfloat-macros.h,v 1.1.2.2 2001/06/21 20:07:17 nathanw Exp $ */
2 1.1.2.2 nathanw
3 1.1.2.2 nathanw /*
4 1.1.2.2 nathanw ===============================================================================
5 1.1.2.2 nathanw
6 1.1.2.2 nathanw This C source fragment is part of the SoftFloat IEC/IEEE Floating-point
7 1.1.2.2 nathanw Arithmetic Package, Release 2a.
8 1.1.2.2 nathanw
9 1.1.2.2 nathanw Written by John R. Hauser. This work was made possible in part by the
10 1.1.2.2 nathanw International Computer Science Institute, located at Suite 600, 1947 Center
11 1.1.2.2 nathanw Street, Berkeley, California 94704. Funding was partially provided by the
12 1.1.2.2 nathanw National Science Foundation under grant MIP-9311980. The original version
13 1.1.2.2 nathanw of this code was written as part of a project to build a fixed-point vector
14 1.1.2.2 nathanw processor in collaboration with the University of California at Berkeley,
15 1.1.2.2 nathanw overseen by Profs. Nelson Morgan and John Wawrzynek. More information
16 1.1.2.2 nathanw is available through the Web page `http://HTTP.CS.Berkeley.EDU/~jhauser/
17 1.1.2.2 nathanw arithmetic/SoftFloat.html'.
18 1.1.2.2 nathanw
19 1.1.2.2 nathanw THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort
20 1.1.2.2 nathanw has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT
21 1.1.2.2 nathanw TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO
22 1.1.2.2 nathanw PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY
23 1.1.2.2 nathanw AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE.
24 1.1.2.2 nathanw
25 1.1.2.2 nathanw Derivative works are acceptable, even for commercial purposes, so long as
26 1.1.2.2 nathanw (1) they include prominent notice that the work is derivative, and (2) they
27 1.1.2.2 nathanw include prominent notice akin to these four paragraphs for those parts of
28 1.1.2.2 nathanw this code that are retained.
29 1.1.2.2 nathanw
30 1.1.2.2 nathanw ===============================================================================
31 1.1.2.2 nathanw */
32 1.1.2.2 nathanw
33 1.1.2.2 nathanw /*
34 1.1.2.2 nathanw -------------------------------------------------------------------------------
35 1.1.2.2 nathanw Shifts `a' right by the number of bits given in `count'. If any nonzero
36 1.1.2.2 nathanw bits are shifted off, they are ``jammed'' into the least significant bit of
37 1.1.2.2 nathanw the result by setting the least significant bit to 1. The value of `count'
38 1.1.2.2 nathanw can be arbitrarily large; in particular, if `count' is greater than 32, the
39 1.1.2.2 nathanw result will be either 0 or 1, depending on whether `a' is zero or nonzero.
40 1.1.2.2 nathanw The result is stored in the location pointed to by `zPtr'.
41 1.1.2.2 nathanw -------------------------------------------------------------------------------
42 1.1.2.2 nathanw */
43 1.1.2.2 nathanw INLINE void shift32RightJamming( bits32 a, int16 count, bits32 *zPtr )
44 1.1.2.2 nathanw {
45 1.1.2.2 nathanw bits32 z;
46 1.1.2.2 nathanw
47 1.1.2.2 nathanw if ( count == 0 ) {
48 1.1.2.2 nathanw z = a;
49 1.1.2.2 nathanw }
50 1.1.2.2 nathanw else if ( count < 32 ) {
51 1.1.2.2 nathanw z = ( a>>count ) | ( ( a<<( ( - count ) & 31 ) ) != 0 );
52 1.1.2.2 nathanw }
53 1.1.2.2 nathanw else {
54 1.1.2.2 nathanw z = ( a != 0 );
55 1.1.2.2 nathanw }
56 1.1.2.2 nathanw *zPtr = z;
57 1.1.2.2 nathanw
58 1.1.2.2 nathanw }
59 1.1.2.2 nathanw
60 1.1.2.2 nathanw /*
61 1.1.2.2 nathanw -------------------------------------------------------------------------------
62 1.1.2.2 nathanw Shifts `a' right by the number of bits given in `count'. If any nonzero
63 1.1.2.2 nathanw bits are shifted off, they are ``jammed'' into the least significant bit of
64 1.1.2.2 nathanw the result by setting the least significant bit to 1. The value of `count'
65 1.1.2.2 nathanw can be arbitrarily large; in particular, if `count' is greater than 64, the
66 1.1.2.2 nathanw result will be either 0 or 1, depending on whether `a' is zero or nonzero.
67 1.1.2.2 nathanw The result is stored in the location pointed to by `zPtr'.
68 1.1.2.2 nathanw -------------------------------------------------------------------------------
69 1.1.2.2 nathanw */
70 1.1.2.2 nathanw INLINE void shift64RightJamming( bits64 a, int16 count, bits64 *zPtr )
71 1.1.2.2 nathanw {
72 1.1.2.2 nathanw bits64 z;
73 1.1.2.2 nathanw
74 1.1.2.2 nathanw if ( count == 0 ) {
75 1.1.2.2 nathanw z = a;
76 1.1.2.2 nathanw }
77 1.1.2.2 nathanw else if ( count < 64 ) {
78 1.1.2.2 nathanw z = ( a>>count ) | ( ( a<<( ( - count ) & 63 ) ) != 0 );
79 1.1.2.2 nathanw }
80 1.1.2.2 nathanw else {
81 1.1.2.2 nathanw z = ( a != 0 );
82 1.1.2.2 nathanw }
83 1.1.2.2 nathanw *zPtr = z;
84 1.1.2.2 nathanw
85 1.1.2.2 nathanw }
86 1.1.2.2 nathanw
87 1.1.2.2 nathanw /*
88 1.1.2.2 nathanw -------------------------------------------------------------------------------
89 1.1.2.2 nathanw Shifts the 128-bit value formed by concatenating `a0' and `a1' right by 64
90 1.1.2.2 nathanw _plus_ the number of bits given in `count'. The shifted result is at most
91 1.1.2.2 nathanw 64 nonzero bits; this is stored at the location pointed to by `z0Ptr'. The
92 1.1.2.2 nathanw bits shifted off form a second 64-bit result as follows: The _last_ bit
93 1.1.2.2 nathanw shifted off is the most-significant bit of the extra result, and the other
94 1.1.2.2 nathanw 63 bits of the extra result are all zero if and only if _all_but_the_last_
95 1.1.2.2 nathanw bits shifted off were all zero. This extra result is stored in the location
96 1.1.2.2 nathanw pointed to by `z1Ptr'. The value of `count' can be arbitrarily large.
97 1.1.2.2 nathanw (This routine makes more sense if `a0' and `a1' are considered to form a
98 1.1.2.2 nathanw fixed-point value with binary point between `a0' and `a1'. This fixed-point
99 1.1.2.2 nathanw value is shifted right by the number of bits given in `count', and the
100 1.1.2.2 nathanw integer part of the result is returned at the location pointed to by
101 1.1.2.2 nathanw `z0Ptr'. The fractional part of the result may be slightly corrupted as
102 1.1.2.2 nathanw described above, and is returned at the location pointed to by `z1Ptr'.)
103 1.1.2.2 nathanw -------------------------------------------------------------------------------
104 1.1.2.2 nathanw */
105 1.1.2.2 nathanw INLINE void
106 1.1.2.2 nathanw shift64ExtraRightJamming(
107 1.1.2.2 nathanw bits64 a0, bits64 a1, int16 count, bits64 *z0Ptr, bits64 *z1Ptr )
108 1.1.2.2 nathanw {
109 1.1.2.2 nathanw bits64 z0, z1;
110 1.1.2.2 nathanw int8 negCount = ( - count ) & 63;
111 1.1.2.2 nathanw
112 1.1.2.2 nathanw if ( count == 0 ) {
113 1.1.2.2 nathanw z1 = a1;
114 1.1.2.2 nathanw z0 = a0;
115 1.1.2.2 nathanw }
116 1.1.2.2 nathanw else if ( count < 64 ) {
117 1.1.2.2 nathanw z1 = ( a0<<negCount ) | ( a1 != 0 );
118 1.1.2.2 nathanw z0 = a0>>count;
119 1.1.2.2 nathanw }
120 1.1.2.2 nathanw else {
121 1.1.2.2 nathanw if ( count == 64 ) {
122 1.1.2.2 nathanw z1 = a0 | ( a1 != 0 );
123 1.1.2.2 nathanw }
124 1.1.2.2 nathanw else {
125 1.1.2.2 nathanw z1 = ( ( a0 | a1 ) != 0 );
126 1.1.2.2 nathanw }
127 1.1.2.2 nathanw z0 = 0;
128 1.1.2.2 nathanw }
129 1.1.2.2 nathanw *z1Ptr = z1;
130 1.1.2.2 nathanw *z0Ptr = z0;
131 1.1.2.2 nathanw
132 1.1.2.2 nathanw }
133 1.1.2.2 nathanw
134 1.1.2.2 nathanw /*
135 1.1.2.2 nathanw -------------------------------------------------------------------------------
136 1.1.2.2 nathanw Shifts the 128-bit value formed by concatenating `a0' and `a1' right by the
137 1.1.2.2 nathanw number of bits given in `count'. Any bits shifted off are lost. The value
138 1.1.2.2 nathanw of `count' can be arbitrarily large; in particular, if `count' is greater
139 1.1.2.2 nathanw than 128, the result will be 0. The result is broken into two 64-bit pieces
140 1.1.2.2 nathanw which are stored at the locations pointed to by `z0Ptr' and `z1Ptr'.
141 1.1.2.2 nathanw -------------------------------------------------------------------------------
142 1.1.2.2 nathanw */
143 1.1.2.2 nathanw INLINE void
144 1.1.2.2 nathanw shift128Right(
145 1.1.2.2 nathanw bits64 a0, bits64 a1, int16 count, bits64 *z0Ptr, bits64 *z1Ptr )
146 1.1.2.2 nathanw {
147 1.1.2.2 nathanw bits64 z0, z1;
148 1.1.2.2 nathanw int8 negCount = ( - count ) & 63;
149 1.1.2.2 nathanw
150 1.1.2.2 nathanw if ( count == 0 ) {
151 1.1.2.2 nathanw z1 = a1;
152 1.1.2.2 nathanw z0 = a0;
153 1.1.2.2 nathanw }
154 1.1.2.2 nathanw else if ( count < 64 ) {
155 1.1.2.2 nathanw z1 = ( a0<<negCount ) | ( a1>>count );
156 1.1.2.2 nathanw z0 = a0>>count;
157 1.1.2.2 nathanw }
158 1.1.2.2 nathanw else {
159 1.1.2.2 nathanw z1 = ( count < 64 ) ? ( a0>>( count & 63 ) ) : 0;
160 1.1.2.2 nathanw z0 = 0;
161 1.1.2.2 nathanw }
162 1.1.2.2 nathanw *z1Ptr = z1;
163 1.1.2.2 nathanw *z0Ptr = z0;
164 1.1.2.2 nathanw
165 1.1.2.2 nathanw }
166 1.1.2.2 nathanw
167 1.1.2.2 nathanw /*
168 1.1.2.2 nathanw -------------------------------------------------------------------------------
169 1.1.2.2 nathanw Shifts the 128-bit value formed by concatenating `a0' and `a1' right by the
170 1.1.2.2 nathanw number of bits given in `count'. If any nonzero bits are shifted off, they
171 1.1.2.2 nathanw are ``jammed'' into the least significant bit of the result by setting the
172 1.1.2.2 nathanw least significant bit to 1. The value of `count' can be arbitrarily large;
173 1.1.2.2 nathanw in particular, if `count' is greater than 128, the result will be either
174 1.1.2.2 nathanw 0 or 1, depending on whether the concatenation of `a0' and `a1' is zero or
175 1.1.2.2 nathanw nonzero. The result is broken into two 64-bit pieces which are stored at
176 1.1.2.2 nathanw the locations pointed to by `z0Ptr' and `z1Ptr'.
177 1.1.2.2 nathanw -------------------------------------------------------------------------------
178 1.1.2.2 nathanw */
179 1.1.2.2 nathanw INLINE void
180 1.1.2.2 nathanw shift128RightJamming(
181 1.1.2.2 nathanw bits64 a0, bits64 a1, int16 count, bits64 *z0Ptr, bits64 *z1Ptr )
182 1.1.2.2 nathanw {
183 1.1.2.2 nathanw bits64 z0, z1;
184 1.1.2.2 nathanw int8 negCount = ( - count ) & 63;
185 1.1.2.2 nathanw
186 1.1.2.2 nathanw if ( count == 0 ) {
187 1.1.2.2 nathanw z1 = a1;
188 1.1.2.2 nathanw z0 = a0;
189 1.1.2.2 nathanw }
190 1.1.2.2 nathanw else if ( count < 64 ) {
191 1.1.2.2 nathanw z1 = ( a0<<negCount ) | ( a1>>count ) | ( ( a1<<negCount ) != 0 );
192 1.1.2.2 nathanw z0 = a0>>count;
193 1.1.2.2 nathanw }
194 1.1.2.2 nathanw else {
195 1.1.2.2 nathanw if ( count == 64 ) {
196 1.1.2.2 nathanw z1 = a0 | ( a1 != 0 );
197 1.1.2.2 nathanw }
198 1.1.2.2 nathanw else if ( count < 128 ) {
199 1.1.2.2 nathanw z1 = ( a0>>( count & 63 ) ) | ( ( ( a0<<negCount ) | a1 ) != 0 );
200 1.1.2.2 nathanw }
201 1.1.2.2 nathanw else {
202 1.1.2.2 nathanw z1 = ( ( a0 | a1 ) != 0 );
203 1.1.2.2 nathanw }
204 1.1.2.2 nathanw z0 = 0;
205 1.1.2.2 nathanw }
206 1.1.2.2 nathanw *z1Ptr = z1;
207 1.1.2.2 nathanw *z0Ptr = z0;
208 1.1.2.2 nathanw
209 1.1.2.2 nathanw }
210 1.1.2.2 nathanw
211 1.1.2.2 nathanw /*
212 1.1.2.2 nathanw -------------------------------------------------------------------------------
213 1.1.2.2 nathanw Shifts the 192-bit value formed by concatenating `a0', `a1', and `a2' right
214 1.1.2.2 nathanw by 64 _plus_ the number of bits given in `count'. The shifted result is
215 1.1.2.2 nathanw at most 128 nonzero bits; these are broken into two 64-bit pieces which are
216 1.1.2.2 nathanw stored at the locations pointed to by `z0Ptr' and `z1Ptr'. The bits shifted
217 1.1.2.2 nathanw off form a third 64-bit result as follows: The _last_ bit shifted off is
218 1.1.2.2 nathanw the most-significant bit of the extra result, and the other 63 bits of the
219 1.1.2.2 nathanw extra result are all zero if and only if _all_but_the_last_ bits shifted off
220 1.1.2.2 nathanw were all zero. This extra result is stored in the location pointed to by
221 1.1.2.2 nathanw `z2Ptr'. The value of `count' can be arbitrarily large.
222 1.1.2.2 nathanw (This routine makes more sense if `a0', `a1', and `a2' are considered
223 1.1.2.2 nathanw to form a fixed-point value with binary point between `a1' and `a2'. This
224 1.1.2.2 nathanw fixed-point value is shifted right by the number of bits given in `count',
225 1.1.2.2 nathanw and the integer part of the result is returned at the locations pointed to
226 1.1.2.2 nathanw by `z0Ptr' and `z1Ptr'. The fractional part of the result may be slightly
227 1.1.2.2 nathanw corrupted as described above, and is returned at the location pointed to by
228 1.1.2.2 nathanw `z2Ptr'.)
229 1.1.2.2 nathanw -------------------------------------------------------------------------------
230 1.1.2.2 nathanw */
231 1.1.2.2 nathanw INLINE void
232 1.1.2.2 nathanw shift128ExtraRightJamming(
233 1.1.2.2 nathanw bits64 a0,
234 1.1.2.2 nathanw bits64 a1,
235 1.1.2.2 nathanw bits64 a2,
236 1.1.2.2 nathanw int16 count,
237 1.1.2.2 nathanw bits64 *z0Ptr,
238 1.1.2.2 nathanw bits64 *z1Ptr,
239 1.1.2.2 nathanw bits64 *z2Ptr
240 1.1.2.2 nathanw )
241 1.1.2.2 nathanw {
242 1.1.2.2 nathanw bits64 z0, z1, z2;
243 1.1.2.2 nathanw int8 negCount = ( - count ) & 63;
244 1.1.2.2 nathanw
245 1.1.2.2 nathanw if ( count == 0 ) {
246 1.1.2.2 nathanw z2 = a2;
247 1.1.2.2 nathanw z1 = a1;
248 1.1.2.2 nathanw z0 = a0;
249 1.1.2.2 nathanw }
250 1.1.2.2 nathanw else {
251 1.1.2.2 nathanw if ( count < 64 ) {
252 1.1.2.2 nathanw z2 = a1<<negCount;
253 1.1.2.2 nathanw z1 = ( a0<<negCount ) | ( a1>>count );
254 1.1.2.2 nathanw z0 = a0>>count;
255 1.1.2.2 nathanw }
256 1.1.2.2 nathanw else {
257 1.1.2.2 nathanw if ( count == 64 ) {
258 1.1.2.2 nathanw z2 = a1;
259 1.1.2.2 nathanw z1 = a0;
260 1.1.2.2 nathanw }
261 1.1.2.2 nathanw else {
262 1.1.2.2 nathanw a2 |= a1;
263 1.1.2.2 nathanw if ( count < 128 ) {
264 1.1.2.2 nathanw z2 = a0<<negCount;
265 1.1.2.2 nathanw z1 = a0>>( count & 63 );
266 1.1.2.2 nathanw }
267 1.1.2.2 nathanw else {
268 1.1.2.2 nathanw z2 = ( count == 128 ) ? a0 : ( a0 != 0 );
269 1.1.2.2 nathanw z1 = 0;
270 1.1.2.2 nathanw }
271 1.1.2.2 nathanw }
272 1.1.2.2 nathanw z0 = 0;
273 1.1.2.2 nathanw }
274 1.1.2.2 nathanw z2 |= ( a2 != 0 );
275 1.1.2.2 nathanw }
276 1.1.2.2 nathanw *z2Ptr = z2;
277 1.1.2.2 nathanw *z1Ptr = z1;
278 1.1.2.2 nathanw *z0Ptr = z0;
279 1.1.2.2 nathanw
280 1.1.2.2 nathanw }
281 1.1.2.2 nathanw
282 1.1.2.2 nathanw /*
283 1.1.2.2 nathanw -------------------------------------------------------------------------------
284 1.1.2.2 nathanw Shifts the 128-bit value formed by concatenating `a0' and `a1' left by the
285 1.1.2.2 nathanw number of bits given in `count'. Any bits shifted off are lost. The value
286 1.1.2.2 nathanw of `count' must be less than 64. The result is broken into two 64-bit
287 1.1.2.2 nathanw pieces which are stored at the locations pointed to by `z0Ptr' and `z1Ptr'.
288 1.1.2.2 nathanw -------------------------------------------------------------------------------
289 1.1.2.2 nathanw */
290 1.1.2.2 nathanw INLINE void
291 1.1.2.2 nathanw shortShift128Left(
292 1.1.2.2 nathanw bits64 a0, bits64 a1, int16 count, bits64 *z0Ptr, bits64 *z1Ptr )
293 1.1.2.2 nathanw {
294 1.1.2.2 nathanw
295 1.1.2.2 nathanw *z1Ptr = a1<<count;
296 1.1.2.2 nathanw *z0Ptr =
297 1.1.2.2 nathanw ( count == 0 ) ? a0 : ( a0<<count ) | ( a1>>( ( - count ) & 63 ) );
298 1.1.2.2 nathanw
299 1.1.2.2 nathanw }
300 1.1.2.2 nathanw
301 1.1.2.2 nathanw /*
302 1.1.2.2 nathanw -------------------------------------------------------------------------------
303 1.1.2.2 nathanw Shifts the 192-bit value formed by concatenating `a0', `a1', and `a2' left
304 1.1.2.2 nathanw by the number of bits given in `count'. Any bits shifted off are lost.
305 1.1.2.2 nathanw The value of `count' must be less than 64. The result is broken into three
306 1.1.2.2 nathanw 64-bit pieces which are stored at the locations pointed to by `z0Ptr',
307 1.1.2.2 nathanw `z1Ptr', and `z2Ptr'.
308 1.1.2.2 nathanw -------------------------------------------------------------------------------
309 1.1.2.2 nathanw */
310 1.1.2.2 nathanw INLINE void
311 1.1.2.2 nathanw shortShift192Left(
312 1.1.2.2 nathanw bits64 a0,
313 1.1.2.2 nathanw bits64 a1,
314 1.1.2.2 nathanw bits64 a2,
315 1.1.2.2 nathanw int16 count,
316 1.1.2.2 nathanw bits64 *z0Ptr,
317 1.1.2.2 nathanw bits64 *z1Ptr,
318 1.1.2.2 nathanw bits64 *z2Ptr
319 1.1.2.2 nathanw )
320 1.1.2.2 nathanw {
321 1.1.2.2 nathanw bits64 z0, z1, z2;
322 1.1.2.2 nathanw int8 negCount;
323 1.1.2.2 nathanw
324 1.1.2.2 nathanw z2 = a2<<count;
325 1.1.2.2 nathanw z1 = a1<<count;
326 1.1.2.2 nathanw z0 = a0<<count;
327 1.1.2.2 nathanw if ( 0 < count ) {
328 1.1.2.2 nathanw negCount = ( ( - count ) & 63 );
329 1.1.2.2 nathanw z1 |= a2>>negCount;
330 1.1.2.2 nathanw z0 |= a1>>negCount;
331 1.1.2.2 nathanw }
332 1.1.2.2 nathanw *z2Ptr = z2;
333 1.1.2.2 nathanw *z1Ptr = z1;
334 1.1.2.2 nathanw *z0Ptr = z0;
335 1.1.2.2 nathanw
336 1.1.2.2 nathanw }
337 1.1.2.2 nathanw
338 1.1.2.2 nathanw /*
339 1.1.2.2 nathanw -------------------------------------------------------------------------------
340 1.1.2.2 nathanw Adds the 128-bit value formed by concatenating `a0' and `a1' to the 128-bit
341 1.1.2.2 nathanw value formed by concatenating `b0' and `b1'. Addition is modulo 2^128, so
342 1.1.2.2 nathanw any carry out is lost. The result is broken into two 64-bit pieces which
343 1.1.2.2 nathanw are stored at the locations pointed to by `z0Ptr' and `z1Ptr'.
344 1.1.2.2 nathanw -------------------------------------------------------------------------------
345 1.1.2.2 nathanw */
346 1.1.2.2 nathanw INLINE void
347 1.1.2.2 nathanw add128(
348 1.1.2.2 nathanw bits64 a0, bits64 a1, bits64 b0, bits64 b1, bits64 *z0Ptr, bits64 *z1Ptr )
349 1.1.2.2 nathanw {
350 1.1.2.2 nathanw bits64 z1;
351 1.1.2.2 nathanw
352 1.1.2.2 nathanw z1 = a1 + b1;
353 1.1.2.2 nathanw *z1Ptr = z1;
354 1.1.2.2 nathanw *z0Ptr = a0 + b0 + ( z1 < a1 );
355 1.1.2.2 nathanw
356 1.1.2.2 nathanw }
357 1.1.2.2 nathanw
358 1.1.2.2 nathanw /*
359 1.1.2.2 nathanw -------------------------------------------------------------------------------
360 1.1.2.2 nathanw Adds the 192-bit value formed by concatenating `a0', `a1', and `a2' to the
361 1.1.2.2 nathanw 192-bit value formed by concatenating `b0', `b1', and `b2'. Addition is
362 1.1.2.2 nathanw modulo 2^192, so any carry out is lost. The result is broken into three
363 1.1.2.2 nathanw 64-bit pieces which are stored at the locations pointed to by `z0Ptr',
364 1.1.2.2 nathanw `z1Ptr', and `z2Ptr'.
365 1.1.2.2 nathanw -------------------------------------------------------------------------------
366 1.1.2.2 nathanw */
367 1.1.2.2 nathanw INLINE void
368 1.1.2.2 nathanw add192(
369 1.1.2.2 nathanw bits64 a0,
370 1.1.2.2 nathanw bits64 a1,
371 1.1.2.2 nathanw bits64 a2,
372 1.1.2.2 nathanw bits64 b0,
373 1.1.2.2 nathanw bits64 b1,
374 1.1.2.2 nathanw bits64 b2,
375 1.1.2.2 nathanw bits64 *z0Ptr,
376 1.1.2.2 nathanw bits64 *z1Ptr,
377 1.1.2.2 nathanw bits64 *z2Ptr
378 1.1.2.2 nathanw )
379 1.1.2.2 nathanw {
380 1.1.2.2 nathanw bits64 z0, z1, z2;
381 1.1.2.2 nathanw int8 carry0, carry1;
382 1.1.2.2 nathanw
383 1.1.2.2 nathanw z2 = a2 + b2;
384 1.1.2.2 nathanw carry1 = ( z2 < a2 );
385 1.1.2.2 nathanw z1 = a1 + b1;
386 1.1.2.2 nathanw carry0 = ( z1 < a1 );
387 1.1.2.2 nathanw z0 = a0 + b0;
388 1.1.2.2 nathanw z1 += carry1;
389 1.1.2.2 nathanw z0 += ( z1 < carry1 );
390 1.1.2.2 nathanw z0 += carry0;
391 1.1.2.2 nathanw *z2Ptr = z2;
392 1.1.2.2 nathanw *z1Ptr = z1;
393 1.1.2.2 nathanw *z0Ptr = z0;
394 1.1.2.2 nathanw
395 1.1.2.2 nathanw }
396 1.1.2.2 nathanw
397 1.1.2.2 nathanw /*
398 1.1.2.2 nathanw -------------------------------------------------------------------------------
399 1.1.2.2 nathanw Subtracts the 128-bit value formed by concatenating `b0' and `b1' from the
400 1.1.2.2 nathanw 128-bit value formed by concatenating `a0' and `a1'. Subtraction is modulo
401 1.1.2.2 nathanw 2^128, so any borrow out (carry out) is lost. The result is broken into two
402 1.1.2.2 nathanw 64-bit pieces which are stored at the locations pointed to by `z0Ptr' and
403 1.1.2.2 nathanw `z1Ptr'.
404 1.1.2.2 nathanw -------------------------------------------------------------------------------
405 1.1.2.2 nathanw */
406 1.1.2.2 nathanw INLINE void
407 1.1.2.2 nathanw sub128(
408 1.1.2.2 nathanw bits64 a0, bits64 a1, bits64 b0, bits64 b1, bits64 *z0Ptr, bits64 *z1Ptr )
409 1.1.2.2 nathanw {
410 1.1.2.2 nathanw
411 1.1.2.2 nathanw *z1Ptr = a1 - b1;
412 1.1.2.2 nathanw *z0Ptr = a0 - b0 - ( a1 < b1 );
413 1.1.2.2 nathanw
414 1.1.2.2 nathanw }
415 1.1.2.2 nathanw
416 1.1.2.2 nathanw /*
417 1.1.2.2 nathanw -------------------------------------------------------------------------------
418 1.1.2.2 nathanw Subtracts the 192-bit value formed by concatenating `b0', `b1', and `b2'
419 1.1.2.2 nathanw from the 192-bit value formed by concatenating `a0', `a1', and `a2'.
420 1.1.2.2 nathanw Subtraction is modulo 2^192, so any borrow out (carry out) is lost. The
421 1.1.2.2 nathanw result is broken into three 64-bit pieces which are stored at the locations
422 1.1.2.2 nathanw pointed to by `z0Ptr', `z1Ptr', and `z2Ptr'.
423 1.1.2.2 nathanw -------------------------------------------------------------------------------
424 1.1.2.2 nathanw */
425 1.1.2.2 nathanw INLINE void
426 1.1.2.2 nathanw sub192(
427 1.1.2.2 nathanw bits64 a0,
428 1.1.2.2 nathanw bits64 a1,
429 1.1.2.2 nathanw bits64 a2,
430 1.1.2.2 nathanw bits64 b0,
431 1.1.2.2 nathanw bits64 b1,
432 1.1.2.2 nathanw bits64 b2,
433 1.1.2.2 nathanw bits64 *z0Ptr,
434 1.1.2.2 nathanw bits64 *z1Ptr,
435 1.1.2.2 nathanw bits64 *z2Ptr
436 1.1.2.2 nathanw )
437 1.1.2.2 nathanw {
438 1.1.2.2 nathanw bits64 z0, z1, z2;
439 1.1.2.2 nathanw int8 borrow0, borrow1;
440 1.1.2.2 nathanw
441 1.1.2.2 nathanw z2 = a2 - b2;
442 1.1.2.2 nathanw borrow1 = ( a2 < b2 );
443 1.1.2.2 nathanw z1 = a1 - b1;
444 1.1.2.2 nathanw borrow0 = ( a1 < b1 );
445 1.1.2.2 nathanw z0 = a0 - b0;
446 1.1.2.2 nathanw z0 -= ( z1 < borrow1 );
447 1.1.2.2 nathanw z1 -= borrow1;
448 1.1.2.2 nathanw z0 -= borrow0;
449 1.1.2.2 nathanw *z2Ptr = z2;
450 1.1.2.2 nathanw *z1Ptr = z1;
451 1.1.2.2 nathanw *z0Ptr = z0;
452 1.1.2.2 nathanw
453 1.1.2.2 nathanw }
454 1.1.2.2 nathanw
455 1.1.2.2 nathanw /*
456 1.1.2.2 nathanw -------------------------------------------------------------------------------
457 1.1.2.2 nathanw Multiplies `a' by `b' to obtain a 128-bit product. The product is broken
458 1.1.2.2 nathanw into two 64-bit pieces which are stored at the locations pointed to by
459 1.1.2.2 nathanw `z0Ptr' and `z1Ptr'.
460 1.1.2.2 nathanw -------------------------------------------------------------------------------
461 1.1.2.2 nathanw */
462 1.1.2.2 nathanw INLINE void mul64To128( bits64 a, bits64 b, bits64 *z0Ptr, bits64 *z1Ptr )
463 1.1.2.2 nathanw {
464 1.1.2.2 nathanw bits32 aHigh, aLow, bHigh, bLow;
465 1.1.2.2 nathanw bits64 z0, zMiddleA, zMiddleB, z1;
466 1.1.2.2 nathanw
467 1.1.2.2 nathanw aLow = a;
468 1.1.2.2 nathanw aHigh = a>>32;
469 1.1.2.2 nathanw bLow = b;
470 1.1.2.2 nathanw bHigh = b>>32;
471 1.1.2.2 nathanw z1 = ( (bits64) aLow ) * bLow;
472 1.1.2.2 nathanw zMiddleA = ( (bits64) aLow ) * bHigh;
473 1.1.2.2 nathanw zMiddleB = ( (bits64) aHigh ) * bLow;
474 1.1.2.2 nathanw z0 = ( (bits64) aHigh ) * bHigh;
475 1.1.2.2 nathanw zMiddleA += zMiddleB;
476 1.1.2.2 nathanw z0 += ( ( (bits64) ( zMiddleA < zMiddleB ) )<<32 ) + ( zMiddleA>>32 );
477 1.1.2.2 nathanw zMiddleA <<= 32;
478 1.1.2.2 nathanw z1 += zMiddleA;
479 1.1.2.2 nathanw z0 += ( z1 < zMiddleA );
480 1.1.2.2 nathanw *z1Ptr = z1;
481 1.1.2.2 nathanw *z0Ptr = z0;
482 1.1.2.2 nathanw
483 1.1.2.2 nathanw }
484 1.1.2.2 nathanw
485 1.1.2.2 nathanw /*
486 1.1.2.2 nathanw -------------------------------------------------------------------------------
487 1.1.2.2 nathanw Multiplies the 128-bit value formed by concatenating `a0' and `a1' by
488 1.1.2.2 nathanw `b' to obtain a 192-bit product. The product is broken into three 64-bit
489 1.1.2.2 nathanw pieces which are stored at the locations pointed to by `z0Ptr', `z1Ptr', and
490 1.1.2.2 nathanw `z2Ptr'.
491 1.1.2.2 nathanw -------------------------------------------------------------------------------
492 1.1.2.2 nathanw */
493 1.1.2.2 nathanw INLINE void
494 1.1.2.2 nathanw mul128By64To192(
495 1.1.2.2 nathanw bits64 a0,
496 1.1.2.2 nathanw bits64 a1,
497 1.1.2.2 nathanw bits64 b,
498 1.1.2.2 nathanw bits64 *z0Ptr,
499 1.1.2.2 nathanw bits64 *z1Ptr,
500 1.1.2.2 nathanw bits64 *z2Ptr
501 1.1.2.2 nathanw )
502 1.1.2.2 nathanw {
503 1.1.2.2 nathanw bits64 z0, z1, z2, more1;
504 1.1.2.2 nathanw
505 1.1.2.2 nathanw mul64To128( a1, b, &z1, &z2 );
506 1.1.2.2 nathanw mul64To128( a0, b, &z0, &more1 );
507 1.1.2.2 nathanw add128( z0, more1, 0, z1, &z0, &z1 );
508 1.1.2.2 nathanw *z2Ptr = z2;
509 1.1.2.2 nathanw *z1Ptr = z1;
510 1.1.2.2 nathanw *z0Ptr = z0;
511 1.1.2.2 nathanw
512 1.1.2.2 nathanw }
513 1.1.2.2 nathanw
514 1.1.2.2 nathanw /*
515 1.1.2.2 nathanw -------------------------------------------------------------------------------
516 1.1.2.2 nathanw Multiplies the 128-bit value formed by concatenating `a0' and `a1' to the
517 1.1.2.2 nathanw 128-bit value formed by concatenating `b0' and `b1' to obtain a 256-bit
518 1.1.2.2 nathanw product. The product is broken into four 64-bit pieces which are stored at
519 1.1.2.2 nathanw the locations pointed to by `z0Ptr', `z1Ptr', `z2Ptr', and `z3Ptr'.
520 1.1.2.2 nathanw -------------------------------------------------------------------------------
521 1.1.2.2 nathanw */
522 1.1.2.2 nathanw INLINE void
523 1.1.2.2 nathanw mul128To256(
524 1.1.2.2 nathanw bits64 a0,
525 1.1.2.2 nathanw bits64 a1,
526 1.1.2.2 nathanw bits64 b0,
527 1.1.2.2 nathanw bits64 b1,
528 1.1.2.2 nathanw bits64 *z0Ptr,
529 1.1.2.2 nathanw bits64 *z1Ptr,
530 1.1.2.2 nathanw bits64 *z2Ptr,
531 1.1.2.2 nathanw bits64 *z3Ptr
532 1.1.2.2 nathanw )
533 1.1.2.2 nathanw {
534 1.1.2.2 nathanw bits64 z0, z1, z2, z3;
535 1.1.2.2 nathanw bits64 more1, more2;
536 1.1.2.2 nathanw
537 1.1.2.2 nathanw mul64To128( a1, b1, &z2, &z3 );
538 1.1.2.2 nathanw mul64To128( a1, b0, &z1, &more2 );
539 1.1.2.2 nathanw add128( z1, more2, 0, z2, &z1, &z2 );
540 1.1.2.2 nathanw mul64To128( a0, b0, &z0, &more1 );
541 1.1.2.2 nathanw add128( z0, more1, 0, z1, &z0, &z1 );
542 1.1.2.2 nathanw mul64To128( a0, b1, &more1, &more2 );
543 1.1.2.2 nathanw add128( more1, more2, 0, z2, &more1, &z2 );
544 1.1.2.2 nathanw add128( z0, z1, 0, more1, &z0, &z1 );
545 1.1.2.2 nathanw *z3Ptr = z3;
546 1.1.2.2 nathanw *z2Ptr = z2;
547 1.1.2.2 nathanw *z1Ptr = z1;
548 1.1.2.2 nathanw *z0Ptr = z0;
549 1.1.2.2 nathanw
550 1.1.2.2 nathanw }
551 1.1.2.2 nathanw
552 1.1.2.2 nathanw /*
553 1.1.2.2 nathanw -------------------------------------------------------------------------------
554 1.1.2.2 nathanw Returns an approximation to the 64-bit integer quotient obtained by dividing
555 1.1.2.2 nathanw `b' into the 128-bit value formed by concatenating `a0' and `a1'. The
556 1.1.2.2 nathanw divisor `b' must be at least 2^63. If q is the exact quotient truncated
557 1.1.2.2 nathanw toward zero, the approximation returned lies between q and q + 2 inclusive.
558 1.1.2.2 nathanw If the exact quotient q is larger than 64 bits, the maximum positive 64-bit
559 1.1.2.2 nathanw unsigned integer is returned.
560 1.1.2.2 nathanw -------------------------------------------------------------------------------
561 1.1.2.2 nathanw */
562 1.1.2.2 nathanw static bits64 estimateDiv128To64( bits64 a0, bits64 a1, bits64 b )
563 1.1.2.2 nathanw {
564 1.1.2.2 nathanw bits64 b0, b1;
565 1.1.2.2 nathanw bits64 rem0, rem1, term0, term1;
566 1.1.2.2 nathanw bits64 z;
567 1.1.2.2 nathanw
568 1.1.2.2 nathanw if ( b <= a0 ) return LIT64( 0xFFFFFFFFFFFFFFFF );
569 1.1.2.2 nathanw b0 = b>>32;
570 1.1.2.2 nathanw z = ( b0<<32 <= a0 ) ? LIT64( 0xFFFFFFFF00000000 ) : ( a0 / b0 )<<32;
571 1.1.2.2 nathanw mul64To128( b, z, &term0, &term1 );
572 1.1.2.2 nathanw sub128( a0, a1, term0, term1, &rem0, &rem1 );
573 1.1.2.2 nathanw while ( ( (sbits64) rem0 ) < 0 ) {
574 1.1.2.2 nathanw z -= LIT64( 0x100000000 );
575 1.1.2.2 nathanw b1 = b<<32;
576 1.1.2.2 nathanw add128( rem0, rem1, b0, b1, &rem0, &rem1 );
577 1.1.2.2 nathanw }
578 1.1.2.2 nathanw rem0 = ( rem0<<32 ) | ( rem1>>32 );
579 1.1.2.2 nathanw z |= ( b0<<32 <= rem0 ) ? 0xFFFFFFFF : rem0 / b0;
580 1.1.2.2 nathanw return z;
581 1.1.2.2 nathanw
582 1.1.2.2 nathanw }
583 1.1.2.2 nathanw
584 1.1.2.2 nathanw #ifndef SOFTFLOAT_FOR_GCC /* Not used */
585 1.1.2.2 nathanw /*
586 1.1.2.2 nathanw -------------------------------------------------------------------------------
587 1.1.2.2 nathanw Returns an approximation to the square root of the 32-bit significand given
588 1.1.2.2 nathanw by `a'. Considered as an integer, `a' must be at least 2^31. If bit 0 of
589 1.1.2.2 nathanw `aExp' (the least significant bit) is 1, the integer returned approximates
590 1.1.2.2 nathanw 2^31*sqrt(`a'/2^31), where `a' is considered an integer. If bit 0 of `aExp'
591 1.1.2.2 nathanw is 0, the integer returned approximates 2^31*sqrt(`a'/2^30). In either
592 1.1.2.2 nathanw case, the approximation returned lies strictly within +/-2 of the exact
593 1.1.2.2 nathanw value.
594 1.1.2.2 nathanw -------------------------------------------------------------------------------
595 1.1.2.2 nathanw */
596 1.1.2.2 nathanw static bits32 estimateSqrt32( int16 aExp, bits32 a )
597 1.1.2.2 nathanw {
598 1.1.2.2 nathanw static const bits16 sqrtOddAdjustments[] = {
599 1.1.2.2 nathanw 0x0004, 0x0022, 0x005D, 0x00B1, 0x011D, 0x019F, 0x0236, 0x02E0,
600 1.1.2.2 nathanw 0x039C, 0x0468, 0x0545, 0x0631, 0x072B, 0x0832, 0x0946, 0x0A67
601 1.1.2.2 nathanw };
602 1.1.2.2 nathanw static const bits16 sqrtEvenAdjustments[] = {
603 1.1.2.2 nathanw 0x0A2D, 0x08AF, 0x075A, 0x0629, 0x051A, 0x0429, 0x0356, 0x029E,
604 1.1.2.2 nathanw 0x0200, 0x0179, 0x0109, 0x00AF, 0x0068, 0x0034, 0x0012, 0x0002
605 1.1.2.2 nathanw };
606 1.1.2.2 nathanw int8 index;
607 1.1.2.2 nathanw bits32 z;
608 1.1.2.2 nathanw
609 1.1.2.2 nathanw index = ( a>>27 ) & 15;
610 1.1.2.2 nathanw if ( aExp & 1 ) {
611 1.1.2.2 nathanw z = 0x4000 + ( a>>17 ) - sqrtOddAdjustments[ index ];
612 1.1.2.2 nathanw z = ( ( a / z )<<14 ) + ( z<<15 );
613 1.1.2.2 nathanw a >>= 1;
614 1.1.2.2 nathanw }
615 1.1.2.2 nathanw else {
616 1.1.2.2 nathanw z = 0x8000 + ( a>>17 ) - sqrtEvenAdjustments[ index ];
617 1.1.2.2 nathanw z = a / z + z;
618 1.1.2.2 nathanw z = ( 0x20000 <= z ) ? 0xFFFF8000 : ( z<<15 );
619 1.1.2.2 nathanw if ( z <= a ) return (bits32) ( ( (sbits32) a )>>1 );
620 1.1.2.2 nathanw }
621 1.1.2.2 nathanw return ( (bits32) ( ( ( (bits64) a )<<31 ) / z ) ) + ( z>>1 );
622 1.1.2.2 nathanw
623 1.1.2.2 nathanw }
624 1.1.2.2 nathanw #endif
625 1.1.2.2 nathanw
626 1.1.2.2 nathanw /*
627 1.1.2.2 nathanw -------------------------------------------------------------------------------
628 1.1.2.2 nathanw Returns the number of leading 0 bits before the most-significant 1 bit of
629 1.1.2.2 nathanw `a'. If `a' is zero, 32 is returned.
630 1.1.2.2 nathanw -------------------------------------------------------------------------------
631 1.1.2.2 nathanw */
632 1.1.2.2 nathanw static int8 countLeadingZeros32( bits32 a )
633 1.1.2.2 nathanw {
634 1.1.2.2 nathanw static const int8 countLeadingZerosHigh[] = {
635 1.1.2.2 nathanw 8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4,
636 1.1.2.2 nathanw 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
637 1.1.2.2 nathanw 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
638 1.1.2.2 nathanw 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
639 1.1.2.2 nathanw 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
640 1.1.2.2 nathanw 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
641 1.1.2.2 nathanw 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
642 1.1.2.2 nathanw 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
643 1.1.2.2 nathanw 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
644 1.1.2.2 nathanw 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
645 1.1.2.2 nathanw 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
646 1.1.2.2 nathanw 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
647 1.1.2.2 nathanw 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
648 1.1.2.2 nathanw 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
649 1.1.2.2 nathanw 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
650 1.1.2.2 nathanw 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
651 1.1.2.2 nathanw };
652 1.1.2.2 nathanw int8 shiftCount;
653 1.1.2.2 nathanw
654 1.1.2.2 nathanw shiftCount = 0;
655 1.1.2.2 nathanw if ( a < 0x10000 ) {
656 1.1.2.2 nathanw shiftCount += 16;
657 1.1.2.2 nathanw a <<= 16;
658 1.1.2.2 nathanw }
659 1.1.2.2 nathanw if ( a < 0x1000000 ) {
660 1.1.2.2 nathanw shiftCount += 8;
661 1.1.2.2 nathanw a <<= 8;
662 1.1.2.2 nathanw }
663 1.1.2.2 nathanw shiftCount += countLeadingZerosHigh[ a>>24 ];
664 1.1.2.2 nathanw return shiftCount;
665 1.1.2.2 nathanw
666 1.1.2.2 nathanw }
667 1.1.2.2 nathanw
668 1.1.2.2 nathanw /*
669 1.1.2.2 nathanw -------------------------------------------------------------------------------
670 1.1.2.2 nathanw Returns the number of leading 0 bits before the most-significant 1 bit of
671 1.1.2.2 nathanw `a'. If `a' is zero, 64 is returned.
672 1.1.2.2 nathanw -------------------------------------------------------------------------------
673 1.1.2.2 nathanw */
674 1.1.2.2 nathanw static int8 countLeadingZeros64( bits64 a )
675 1.1.2.2 nathanw {
676 1.1.2.2 nathanw int8 shiftCount;
677 1.1.2.2 nathanw
678 1.1.2.2 nathanw shiftCount = 0;
679 1.1.2.2 nathanw if ( a < ( (bits64) 1 )<<32 ) {
680 1.1.2.2 nathanw shiftCount += 32;
681 1.1.2.2 nathanw }
682 1.1.2.2 nathanw else {
683 1.1.2.2 nathanw a >>= 32;
684 1.1.2.2 nathanw }
685 1.1.2.2 nathanw shiftCount += countLeadingZeros32( a );
686 1.1.2.2 nathanw return shiftCount;
687 1.1.2.2 nathanw
688 1.1.2.2 nathanw }
689 1.1.2.2 nathanw
690 1.1.2.2 nathanw /*
691 1.1.2.2 nathanw -------------------------------------------------------------------------------
692 1.1.2.2 nathanw Returns 1 if the 128-bit value formed by concatenating `a0' and `a1'
693 1.1.2.2 nathanw is equal to the 128-bit value formed by concatenating `b0' and `b1'.
694 1.1.2.2 nathanw Otherwise, returns 0.
695 1.1.2.2 nathanw -------------------------------------------------------------------------------
696 1.1.2.2 nathanw */
697 1.1.2.2 nathanw INLINE flag eq128( bits64 a0, bits64 a1, bits64 b0, bits64 b1 )
698 1.1.2.2 nathanw {
699 1.1.2.2 nathanw
700 1.1.2.2 nathanw return ( a0 == b0 ) && ( a1 == b1 );
701 1.1.2.2 nathanw
702 1.1.2.2 nathanw }
703 1.1.2.2 nathanw
704 1.1.2.2 nathanw /*
705 1.1.2.2 nathanw -------------------------------------------------------------------------------
706 1.1.2.2 nathanw Returns 1 if the 128-bit value formed by concatenating `a0' and `a1' is less
707 1.1.2.2 nathanw than or equal to the 128-bit value formed by concatenating `b0' and `b1'.
708 1.1.2.2 nathanw Otherwise, returns 0.
709 1.1.2.2 nathanw -------------------------------------------------------------------------------
710 1.1.2.2 nathanw */
711 1.1.2.2 nathanw INLINE flag le128( bits64 a0, bits64 a1, bits64 b0, bits64 b1 )
712 1.1.2.2 nathanw {
713 1.1.2.2 nathanw
714 1.1.2.2 nathanw return ( a0 < b0 ) || ( ( a0 == b0 ) && ( a1 <= b1 ) );
715 1.1.2.2 nathanw
716 1.1.2.2 nathanw }
717 1.1.2.2 nathanw
718 1.1.2.2 nathanw /*
719 1.1.2.2 nathanw -------------------------------------------------------------------------------
720 1.1.2.2 nathanw Returns 1 if the 128-bit value formed by concatenating `a0' and `a1' is less
721 1.1.2.2 nathanw than the 128-bit value formed by concatenating `b0' and `b1'. Otherwise,
722 1.1.2.2 nathanw returns 0.
723 1.1.2.2 nathanw -------------------------------------------------------------------------------
724 1.1.2.2 nathanw */
725 1.1.2.2 nathanw INLINE flag lt128( bits64 a0, bits64 a1, bits64 b0, bits64 b1 )
726 1.1.2.2 nathanw {
727 1.1.2.2 nathanw
728 1.1.2.2 nathanw return ( a0 < b0 ) || ( ( a0 == b0 ) && ( a1 < b1 ) );
729 1.1.2.2 nathanw
730 1.1.2.2 nathanw }
731 1.1.2.2 nathanw
732 1.1.2.2 nathanw /*
733 1.1.2.2 nathanw -------------------------------------------------------------------------------
734 1.1.2.2 nathanw Returns 1 if the 128-bit value formed by concatenating `a0' and `a1' is
735 1.1.2.2 nathanw not equal to the 128-bit value formed by concatenating `b0' and `b1'.
736 1.1.2.2 nathanw Otherwise, returns 0.
737 1.1.2.2 nathanw -------------------------------------------------------------------------------
738 1.1.2.2 nathanw */
739 1.1.2.2 nathanw INLINE flag ne128( bits64 a0, bits64 a1, bits64 b0, bits64 b1 )
740 1.1.2.2 nathanw {
741 1.1.2.2 nathanw
742 1.1.2.2 nathanw return ( a0 != b0 ) || ( a1 != b1 );
743 1.1.2.2 nathanw
744 1.1.2.2 nathanw }
745 1.1.2.2 nathanw
746