1*f14fb602SLionel Sambuc/* $NetBSD: softfloat-macros,v 1.3 2012/03/21 02:32:26 christos Exp $ */ 22fe8fb19SBen Gras 32fe8fb19SBen Gras/* 42fe8fb19SBen Gras=============================================================================== 52fe8fb19SBen Gras 62fe8fb19SBen GrasThis C source fragment is part of the SoftFloat IEC/IEEE Floating-point 72fe8fb19SBen GrasArithmetic Package, Release 2a. 82fe8fb19SBen Gras 92fe8fb19SBen GrasWritten by John R. Hauser. This work was made possible in part by the 102fe8fb19SBen GrasInternational Computer Science Institute, located at Suite 600, 1947 Center 112fe8fb19SBen GrasStreet, Berkeley, California 94704. Funding was partially provided by the 122fe8fb19SBen GrasNational Science Foundation under grant MIP-9311980. The original version 132fe8fb19SBen Grasof this code was written as part of a project to build a fixed-point vector 142fe8fb19SBen Grasprocessor in collaboration with the University of California at Berkeley, 152fe8fb19SBen Grasoverseen by Profs. Nelson Morgan and John Wawrzynek. More information 162fe8fb19SBen Grasis available through the Web page `http://HTTP.CS.Berkeley.EDU/~jhauser/ 172fe8fb19SBen Grasarithmetic/SoftFloat.html'. 182fe8fb19SBen Gras 192fe8fb19SBen GrasTHIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort 202fe8fb19SBen Grashas been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT 212fe8fb19SBen GrasTIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO 222fe8fb19SBen GrasPERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY 232fe8fb19SBen GrasAND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE. 242fe8fb19SBen Gras 252fe8fb19SBen GrasDerivative works are acceptable, even for commercial purposes, so long as 262fe8fb19SBen Gras(1) they include prominent notice that the work is derivative, and (2) they 272fe8fb19SBen Grasinclude prominent notice akin to these four paragraphs for those parts of 282fe8fb19SBen Grasthis code that are retained. 292fe8fb19SBen Gras 302fe8fb19SBen Gras=============================================================================== 312fe8fb19SBen Gras*/ 322fe8fb19SBen Gras 332fe8fb19SBen Gras/* 342fe8fb19SBen Gras------------------------------------------------------------------------------- 352fe8fb19SBen GrasShifts `a' right by the number of bits given in `count'. If any nonzero 362fe8fb19SBen Grasbits are shifted off, they are ``jammed'' into the least significant bit of 372fe8fb19SBen Grasthe result by setting the least significant bit to 1. The value of `count' 382fe8fb19SBen Grascan be arbitrarily large; in particular, if `count' is greater than 32, the 392fe8fb19SBen Grasresult will be either 0 or 1, depending on whether `a' is zero or nonzero. 402fe8fb19SBen GrasThe result is stored in the location pointed to by `zPtr'. 412fe8fb19SBen Gras------------------------------------------------------------------------------- 422fe8fb19SBen Gras*/ 432fe8fb19SBen GrasINLINE void shift32RightJamming( bits32 a, int16 count, bits32 *zPtr ) 442fe8fb19SBen Gras{ 452fe8fb19SBen Gras bits32 z; 462fe8fb19SBen Gras 472fe8fb19SBen Gras if ( count == 0 ) { 482fe8fb19SBen Gras z = a; 492fe8fb19SBen Gras } 502fe8fb19SBen Gras else if ( count < 32 ) { 512fe8fb19SBen Gras z = ( a>>count ) | ( ( a<<( ( - count ) & 31 ) ) != 0 ); 522fe8fb19SBen Gras } 532fe8fb19SBen Gras else { 542fe8fb19SBen Gras z = ( a != 0 ); 552fe8fb19SBen Gras } 562fe8fb19SBen Gras *zPtr = z; 572fe8fb19SBen Gras 582fe8fb19SBen Gras} 592fe8fb19SBen Gras 602fe8fb19SBen Gras/* 612fe8fb19SBen Gras------------------------------------------------------------------------------- 622fe8fb19SBen GrasShifts `a' right by the number of bits given in `count'. If any nonzero 632fe8fb19SBen Grasbits are shifted off, they are ``jammed'' into the least significant bit of 642fe8fb19SBen Grasthe result by setting the least significant bit to 1. The value of `count' 652fe8fb19SBen Grascan be arbitrarily large; in particular, if `count' is greater than 64, the 662fe8fb19SBen Grasresult will be either 0 or 1, depending on whether `a' is zero or nonzero. 672fe8fb19SBen GrasThe result is stored in the location pointed to by `zPtr'. 682fe8fb19SBen Gras------------------------------------------------------------------------------- 692fe8fb19SBen Gras*/ 702fe8fb19SBen GrasINLINE void shift64RightJamming( bits64 a, int16 count, bits64 *zPtr ) 712fe8fb19SBen Gras{ 722fe8fb19SBen Gras bits64 z; 732fe8fb19SBen Gras 742fe8fb19SBen Gras if ( count == 0 ) { 752fe8fb19SBen Gras z = a; 762fe8fb19SBen Gras } 772fe8fb19SBen Gras else if ( count < 64 ) { 782fe8fb19SBen Gras z = ( a>>count ) | ( ( a<<( ( - count ) & 63 ) ) != 0 ); 792fe8fb19SBen Gras } 802fe8fb19SBen Gras else { 812fe8fb19SBen Gras z = ( a != 0 ); 822fe8fb19SBen Gras } 832fe8fb19SBen Gras *zPtr = z; 842fe8fb19SBen Gras 852fe8fb19SBen Gras} 862fe8fb19SBen Gras 872fe8fb19SBen Gras/* 882fe8fb19SBen Gras------------------------------------------------------------------------------- 892fe8fb19SBen GrasShifts the 128-bit value formed by concatenating `a0' and `a1' right by 64 902fe8fb19SBen Gras_plus_ the number of bits given in `count'. The shifted result is at most 912fe8fb19SBen Gras64 nonzero bits; this is stored at the location pointed to by `z0Ptr'. The 922fe8fb19SBen Grasbits shifted off form a second 64-bit result as follows: The _last_ bit 932fe8fb19SBen Grasshifted off is the most-significant bit of the extra result, and the other 942fe8fb19SBen Gras63 bits of the extra result are all zero if and only if _all_but_the_last_ 952fe8fb19SBen Grasbits shifted off were all zero. This extra result is stored in the location 962fe8fb19SBen Graspointed to by `z1Ptr'. The value of `count' can be arbitrarily large. 972fe8fb19SBen Gras (This routine makes more sense if `a0' and `a1' are considered to form a 982fe8fb19SBen Grasfixed-point value with binary point between `a0' and `a1'. This fixed-point 992fe8fb19SBen Grasvalue is shifted right by the number of bits given in `count', and the 1002fe8fb19SBen Grasinteger part of the result is returned at the location pointed to by 1012fe8fb19SBen Gras`z0Ptr'. The fractional part of the result may be slightly corrupted as 1022fe8fb19SBen Grasdescribed above, and is returned at the location pointed to by `z1Ptr'.) 1032fe8fb19SBen Gras------------------------------------------------------------------------------- 1042fe8fb19SBen Gras*/ 1052fe8fb19SBen GrasINLINE void 1062fe8fb19SBen Gras shift64ExtraRightJamming( 1072fe8fb19SBen Gras bits64 a0, bits64 a1, int16 count, bits64 *z0Ptr, bits64 *z1Ptr ) 1082fe8fb19SBen Gras{ 1092fe8fb19SBen Gras bits64 z0, z1; 1102fe8fb19SBen Gras int8 negCount = ( - count ) & 63; 1112fe8fb19SBen Gras 1122fe8fb19SBen Gras if ( count == 0 ) { 1132fe8fb19SBen Gras z1 = a1; 1142fe8fb19SBen Gras z0 = a0; 1152fe8fb19SBen Gras } 1162fe8fb19SBen Gras else if ( count < 64 ) { 1172fe8fb19SBen Gras z1 = ( a0<<negCount ) | ( a1 != 0 ); 1182fe8fb19SBen Gras z0 = a0>>count; 1192fe8fb19SBen Gras } 1202fe8fb19SBen Gras else { 1212fe8fb19SBen Gras if ( count == 64 ) { 1222fe8fb19SBen Gras z1 = a0 | ( a1 != 0 ); 1232fe8fb19SBen Gras } 1242fe8fb19SBen Gras else { 1252fe8fb19SBen Gras z1 = ( ( a0 | a1 ) != 0 ); 1262fe8fb19SBen Gras } 1272fe8fb19SBen Gras z0 = 0; 1282fe8fb19SBen Gras } 1292fe8fb19SBen Gras *z1Ptr = z1; 1302fe8fb19SBen Gras *z0Ptr = z0; 1312fe8fb19SBen Gras 1322fe8fb19SBen Gras} 1332fe8fb19SBen Gras 1342fe8fb19SBen Gras/* 1352fe8fb19SBen Gras------------------------------------------------------------------------------- 1362fe8fb19SBen GrasShifts the 128-bit value formed by concatenating `a0' and `a1' right by the 1372fe8fb19SBen Grasnumber of bits given in `count'. Any bits shifted off are lost. The value 1382fe8fb19SBen Grasof `count' can be arbitrarily large; in particular, if `count' is greater 1392fe8fb19SBen Grasthan 128, the result will be 0. The result is broken into two 64-bit pieces 1402fe8fb19SBen Graswhich are stored at the locations pointed to by `z0Ptr' and `z1Ptr'. 1412fe8fb19SBen Gras------------------------------------------------------------------------------- 1422fe8fb19SBen Gras*/ 1432fe8fb19SBen GrasINLINE void 1442fe8fb19SBen Gras shift128Right( 1452fe8fb19SBen Gras bits64 a0, bits64 a1, int16 count, bits64 *z0Ptr, bits64 *z1Ptr ) 1462fe8fb19SBen Gras{ 1472fe8fb19SBen Gras bits64 z0, z1; 1482fe8fb19SBen Gras int8 negCount = ( - count ) & 63; 1492fe8fb19SBen Gras 1502fe8fb19SBen Gras if ( count == 0 ) { 1512fe8fb19SBen Gras z1 = a1; 1522fe8fb19SBen Gras z0 = a0; 1532fe8fb19SBen Gras } 1542fe8fb19SBen Gras else if ( count < 64 ) { 1552fe8fb19SBen Gras z1 = ( a0<<negCount ) | ( a1>>count ); 1562fe8fb19SBen Gras z0 = a0>>count; 1572fe8fb19SBen Gras } 1582fe8fb19SBen Gras else { 1592fe8fb19SBen Gras z1 = ( count < 64 ) ? ( a0>>( count & 63 ) ) : 0; 1602fe8fb19SBen Gras z0 = 0; 1612fe8fb19SBen Gras } 1622fe8fb19SBen Gras *z1Ptr = z1; 1632fe8fb19SBen Gras *z0Ptr = z0; 1642fe8fb19SBen Gras 1652fe8fb19SBen Gras} 1662fe8fb19SBen Gras 1672fe8fb19SBen Gras/* 1682fe8fb19SBen Gras------------------------------------------------------------------------------- 1692fe8fb19SBen GrasShifts the 128-bit value formed by concatenating `a0' and `a1' right by the 1702fe8fb19SBen Grasnumber of bits given in `count'. If any nonzero bits are shifted off, they 1712fe8fb19SBen Grasare ``jammed'' into the least significant bit of the result by setting the 1722fe8fb19SBen Grasleast significant bit to 1. The value of `count' can be arbitrarily large; 1732fe8fb19SBen Grasin particular, if `count' is greater than 128, the result will be either 1742fe8fb19SBen Gras0 or 1, depending on whether the concatenation of `a0' and `a1' is zero or 1752fe8fb19SBen Grasnonzero. The result is broken into two 64-bit pieces which are stored at 1762fe8fb19SBen Grasthe locations pointed to by `z0Ptr' and `z1Ptr'. 1772fe8fb19SBen Gras------------------------------------------------------------------------------- 1782fe8fb19SBen Gras*/ 1792fe8fb19SBen GrasINLINE void 1802fe8fb19SBen Gras shift128RightJamming( 1812fe8fb19SBen Gras bits64 a0, bits64 a1, int16 count, bits64 *z0Ptr, bits64 *z1Ptr ) 1822fe8fb19SBen Gras{ 1832fe8fb19SBen Gras bits64 z0, z1; 1842fe8fb19SBen Gras int8 negCount = ( - count ) & 63; 1852fe8fb19SBen Gras 1862fe8fb19SBen Gras if ( count == 0 ) { 1872fe8fb19SBen Gras z1 = a1; 1882fe8fb19SBen Gras z0 = a0; 1892fe8fb19SBen Gras } 1902fe8fb19SBen Gras else if ( count < 64 ) { 1912fe8fb19SBen Gras z1 = ( a0<<negCount ) | ( a1>>count ) | ( ( a1<<negCount ) != 0 ); 1922fe8fb19SBen Gras z0 = a0>>count; 1932fe8fb19SBen Gras } 1942fe8fb19SBen Gras else { 1952fe8fb19SBen Gras if ( count == 64 ) { 1962fe8fb19SBen Gras z1 = a0 | ( a1 != 0 ); 1972fe8fb19SBen Gras } 1982fe8fb19SBen Gras else if ( count < 128 ) { 1992fe8fb19SBen Gras z1 = ( a0>>( count & 63 ) ) | ( ( ( a0<<negCount ) | a1 ) != 0 ); 2002fe8fb19SBen Gras } 2012fe8fb19SBen Gras else { 2022fe8fb19SBen Gras z1 = ( ( a0 | a1 ) != 0 ); 2032fe8fb19SBen Gras } 2042fe8fb19SBen Gras z0 = 0; 2052fe8fb19SBen Gras } 2062fe8fb19SBen Gras *z1Ptr = z1; 2072fe8fb19SBen Gras *z0Ptr = z0; 2082fe8fb19SBen Gras 2092fe8fb19SBen Gras} 2102fe8fb19SBen Gras 2112fe8fb19SBen Gras/* 2122fe8fb19SBen Gras------------------------------------------------------------------------------- 2132fe8fb19SBen GrasShifts the 192-bit value formed by concatenating `a0', `a1', and `a2' right 2142fe8fb19SBen Grasby 64 _plus_ the number of bits given in `count'. The shifted result is 2152fe8fb19SBen Grasat most 128 nonzero bits; these are broken into two 64-bit pieces which are 2162fe8fb19SBen Grasstored at the locations pointed to by `z0Ptr' and `z1Ptr'. The bits shifted 2172fe8fb19SBen Grasoff form a third 64-bit result as follows: The _last_ bit shifted off is 2182fe8fb19SBen Grasthe most-significant bit of the extra result, and the other 63 bits of the 2192fe8fb19SBen Grasextra result are all zero if and only if _all_but_the_last_ bits shifted off 2202fe8fb19SBen Graswere all zero. This extra result is stored in the location pointed to by 2212fe8fb19SBen Gras`z2Ptr'. The value of `count' can be arbitrarily large. 2222fe8fb19SBen Gras (This routine makes more sense if `a0', `a1', and `a2' are considered 2232fe8fb19SBen Grasto form a fixed-point value with binary point between `a1' and `a2'. This 2242fe8fb19SBen Grasfixed-point value is shifted right by the number of bits given in `count', 2252fe8fb19SBen Grasand the integer part of the result is returned at the locations pointed to 2262fe8fb19SBen Grasby `z0Ptr' and `z1Ptr'. The fractional part of the result may be slightly 2272fe8fb19SBen Grascorrupted as described above, and is returned at the location pointed to by 2282fe8fb19SBen Gras`z2Ptr'.) 2292fe8fb19SBen Gras------------------------------------------------------------------------------- 2302fe8fb19SBen Gras*/ 2312fe8fb19SBen GrasINLINE void 2322fe8fb19SBen Gras shift128ExtraRightJamming( 2332fe8fb19SBen Gras bits64 a0, 2342fe8fb19SBen Gras bits64 a1, 2352fe8fb19SBen Gras bits64 a2, 2362fe8fb19SBen Gras int16 count, 2372fe8fb19SBen Gras bits64 *z0Ptr, 2382fe8fb19SBen Gras bits64 *z1Ptr, 2392fe8fb19SBen Gras bits64 *z2Ptr 2402fe8fb19SBen Gras ) 2412fe8fb19SBen Gras{ 2422fe8fb19SBen Gras bits64 z0, z1, z2; 2432fe8fb19SBen Gras int8 negCount = ( - count ) & 63; 2442fe8fb19SBen Gras 2452fe8fb19SBen Gras if ( count == 0 ) { 2462fe8fb19SBen Gras z2 = a2; 2472fe8fb19SBen Gras z1 = a1; 2482fe8fb19SBen Gras z0 = a0; 2492fe8fb19SBen Gras } 2502fe8fb19SBen Gras else { 2512fe8fb19SBen Gras if ( count < 64 ) { 2522fe8fb19SBen Gras z2 = a1<<negCount; 2532fe8fb19SBen Gras z1 = ( a0<<negCount ) | ( a1>>count ); 2542fe8fb19SBen Gras z0 = a0>>count; 2552fe8fb19SBen Gras } 2562fe8fb19SBen Gras else { 2572fe8fb19SBen Gras if ( count == 64 ) { 2582fe8fb19SBen Gras z2 = a1; 2592fe8fb19SBen Gras z1 = a0; 2602fe8fb19SBen Gras } 2612fe8fb19SBen Gras else { 2622fe8fb19SBen Gras a2 |= a1; 2632fe8fb19SBen Gras if ( count < 128 ) { 2642fe8fb19SBen Gras z2 = a0<<negCount; 2652fe8fb19SBen Gras z1 = a0>>( count & 63 ); 2662fe8fb19SBen Gras } 2672fe8fb19SBen Gras else { 2682fe8fb19SBen Gras z2 = ( count == 128 ) ? a0 : ( a0 != 0 ); 2692fe8fb19SBen Gras z1 = 0; 2702fe8fb19SBen Gras } 2712fe8fb19SBen Gras } 2722fe8fb19SBen Gras z0 = 0; 2732fe8fb19SBen Gras } 2742fe8fb19SBen Gras z2 |= ( a2 != 0 ); 2752fe8fb19SBen Gras } 2762fe8fb19SBen Gras *z2Ptr = z2; 2772fe8fb19SBen Gras *z1Ptr = z1; 2782fe8fb19SBen Gras *z0Ptr = z0; 2792fe8fb19SBen Gras 2802fe8fb19SBen Gras} 2812fe8fb19SBen Gras 2822fe8fb19SBen Gras/* 2832fe8fb19SBen Gras------------------------------------------------------------------------------- 2842fe8fb19SBen GrasShifts the 128-bit value formed by concatenating `a0' and `a1' left by the 2852fe8fb19SBen Grasnumber of bits given in `count'. Any bits shifted off are lost. The value 2862fe8fb19SBen Grasof `count' must be less than 64. The result is broken into two 64-bit 2872fe8fb19SBen Graspieces which are stored at the locations pointed to by `z0Ptr' and `z1Ptr'. 2882fe8fb19SBen Gras------------------------------------------------------------------------------- 2892fe8fb19SBen Gras*/ 2902fe8fb19SBen GrasINLINE void 2912fe8fb19SBen Gras shortShift128Left( 2922fe8fb19SBen Gras bits64 a0, bits64 a1, int16 count, bits64 *z0Ptr, bits64 *z1Ptr ) 2932fe8fb19SBen Gras{ 2942fe8fb19SBen Gras 2952fe8fb19SBen Gras *z1Ptr = a1<<count; 2962fe8fb19SBen Gras *z0Ptr = 2972fe8fb19SBen Gras ( count == 0 ) ? a0 : ( a0<<count ) | ( a1>>( ( - count ) & 63 ) ); 2982fe8fb19SBen Gras 2992fe8fb19SBen Gras} 3002fe8fb19SBen Gras 3012fe8fb19SBen Gras/* 3022fe8fb19SBen Gras------------------------------------------------------------------------------- 3032fe8fb19SBen GrasShifts the 192-bit value formed by concatenating `a0', `a1', and `a2' left 3042fe8fb19SBen Grasby the number of bits given in `count'. Any bits shifted off are lost. 3052fe8fb19SBen GrasThe value of `count' must be less than 64. The result is broken into three 3062fe8fb19SBen Gras64-bit pieces which are stored at the locations pointed to by `z0Ptr', 3072fe8fb19SBen Gras`z1Ptr', and `z2Ptr'. 3082fe8fb19SBen Gras------------------------------------------------------------------------------- 3092fe8fb19SBen Gras*/ 3102fe8fb19SBen GrasINLINE void 3112fe8fb19SBen Gras shortShift192Left( 3122fe8fb19SBen Gras bits64 a0, 3132fe8fb19SBen Gras bits64 a1, 3142fe8fb19SBen Gras bits64 a2, 3152fe8fb19SBen Gras int16 count, 3162fe8fb19SBen Gras bits64 *z0Ptr, 3172fe8fb19SBen Gras bits64 *z1Ptr, 3182fe8fb19SBen Gras bits64 *z2Ptr 3192fe8fb19SBen Gras ) 3202fe8fb19SBen Gras{ 3212fe8fb19SBen Gras bits64 z0, z1, z2; 3222fe8fb19SBen Gras int8 negCount; 3232fe8fb19SBen Gras 3242fe8fb19SBen Gras z2 = a2<<count; 3252fe8fb19SBen Gras z1 = a1<<count; 3262fe8fb19SBen Gras z0 = a0<<count; 3272fe8fb19SBen Gras if ( 0 < count ) { 3282fe8fb19SBen Gras negCount = ( ( - count ) & 63 ); 3292fe8fb19SBen Gras z1 |= a2>>negCount; 3302fe8fb19SBen Gras z0 |= a1>>negCount; 3312fe8fb19SBen Gras } 3322fe8fb19SBen Gras *z2Ptr = z2; 3332fe8fb19SBen Gras *z1Ptr = z1; 3342fe8fb19SBen Gras *z0Ptr = z0; 3352fe8fb19SBen Gras 3362fe8fb19SBen Gras} 3372fe8fb19SBen Gras 3382fe8fb19SBen Gras/* 3392fe8fb19SBen Gras------------------------------------------------------------------------------- 3402fe8fb19SBen GrasAdds the 128-bit value formed by concatenating `a0' and `a1' to the 128-bit 3412fe8fb19SBen Grasvalue formed by concatenating `b0' and `b1'. Addition is modulo 2^128, so 3422fe8fb19SBen Grasany carry out is lost. The result is broken into two 64-bit pieces which 3432fe8fb19SBen Grasare stored at the locations pointed to by `z0Ptr' and `z1Ptr'. 3442fe8fb19SBen Gras------------------------------------------------------------------------------- 3452fe8fb19SBen Gras*/ 3462fe8fb19SBen GrasINLINE void 3472fe8fb19SBen Gras add128( 3482fe8fb19SBen Gras bits64 a0, bits64 a1, bits64 b0, bits64 b1, bits64 *z0Ptr, bits64 *z1Ptr ) 3492fe8fb19SBen Gras{ 3502fe8fb19SBen Gras bits64 z1; 3512fe8fb19SBen Gras 3522fe8fb19SBen Gras z1 = a1 + b1; 3532fe8fb19SBen Gras *z1Ptr = z1; 3542fe8fb19SBen Gras *z0Ptr = a0 + b0 + ( z1 < a1 ); 3552fe8fb19SBen Gras 3562fe8fb19SBen Gras} 3572fe8fb19SBen Gras 3582fe8fb19SBen Gras/* 3592fe8fb19SBen Gras------------------------------------------------------------------------------- 3602fe8fb19SBen GrasAdds the 192-bit value formed by concatenating `a0', `a1', and `a2' to the 3612fe8fb19SBen Gras192-bit value formed by concatenating `b0', `b1', and `b2'. Addition is 3622fe8fb19SBen Grasmodulo 2^192, so any carry out is lost. The result is broken into three 3632fe8fb19SBen Gras64-bit pieces which are stored at the locations pointed to by `z0Ptr', 3642fe8fb19SBen Gras`z1Ptr', and `z2Ptr'. 3652fe8fb19SBen Gras------------------------------------------------------------------------------- 3662fe8fb19SBen Gras*/ 3672fe8fb19SBen GrasINLINE void 3682fe8fb19SBen Gras add192( 3692fe8fb19SBen Gras bits64 a0, 3702fe8fb19SBen Gras bits64 a1, 3712fe8fb19SBen Gras bits64 a2, 3722fe8fb19SBen Gras bits64 b0, 3732fe8fb19SBen Gras bits64 b1, 3742fe8fb19SBen Gras bits64 b2, 3752fe8fb19SBen Gras bits64 *z0Ptr, 3762fe8fb19SBen Gras bits64 *z1Ptr, 3772fe8fb19SBen Gras bits64 *z2Ptr 3782fe8fb19SBen Gras ) 3792fe8fb19SBen Gras{ 3802fe8fb19SBen Gras bits64 z0, z1, z2; 3812fe8fb19SBen Gras int8 carry0, carry1; 3822fe8fb19SBen Gras 3832fe8fb19SBen Gras z2 = a2 + b2; 3842fe8fb19SBen Gras carry1 = ( z2 < a2 ); 3852fe8fb19SBen Gras z1 = a1 + b1; 3862fe8fb19SBen Gras carry0 = ( z1 < a1 ); 3872fe8fb19SBen Gras z0 = a0 + b0; 3882fe8fb19SBen Gras z1 += carry1; 3892fe8fb19SBen Gras z0 += ( z1 < (bits64)carry1 ); 3902fe8fb19SBen Gras z0 += carry0; 3912fe8fb19SBen Gras *z2Ptr = z2; 3922fe8fb19SBen Gras *z1Ptr = z1; 3932fe8fb19SBen Gras *z0Ptr = z0; 3942fe8fb19SBen Gras 3952fe8fb19SBen Gras} 3962fe8fb19SBen Gras 3972fe8fb19SBen Gras/* 3982fe8fb19SBen Gras------------------------------------------------------------------------------- 3992fe8fb19SBen GrasSubtracts the 128-bit value formed by concatenating `b0' and `b1' from the 4002fe8fb19SBen Gras128-bit value formed by concatenating `a0' and `a1'. Subtraction is modulo 4012fe8fb19SBen Gras2^128, so any borrow out (carry out) is lost. The result is broken into two 4022fe8fb19SBen Gras64-bit pieces which are stored at the locations pointed to by `z0Ptr' and 4032fe8fb19SBen Gras`z1Ptr'. 4042fe8fb19SBen Gras------------------------------------------------------------------------------- 4052fe8fb19SBen Gras*/ 4062fe8fb19SBen GrasINLINE void 4072fe8fb19SBen Gras sub128( 4082fe8fb19SBen Gras bits64 a0, bits64 a1, bits64 b0, bits64 b1, bits64 *z0Ptr, bits64 *z1Ptr ) 4092fe8fb19SBen Gras{ 4102fe8fb19SBen Gras 4112fe8fb19SBen Gras *z1Ptr = a1 - b1; 4122fe8fb19SBen Gras *z0Ptr = a0 - b0 - ( a1 < b1 ); 4132fe8fb19SBen Gras 4142fe8fb19SBen Gras} 4152fe8fb19SBen Gras 4162fe8fb19SBen Gras/* 4172fe8fb19SBen Gras------------------------------------------------------------------------------- 4182fe8fb19SBen GrasSubtracts the 192-bit value formed by concatenating `b0', `b1', and `b2' 4192fe8fb19SBen Grasfrom the 192-bit value formed by concatenating `a0', `a1', and `a2'. 4202fe8fb19SBen GrasSubtraction is modulo 2^192, so any borrow out (carry out) is lost. The 4212fe8fb19SBen Grasresult is broken into three 64-bit pieces which are stored at the locations 4222fe8fb19SBen Graspointed to by `z0Ptr', `z1Ptr', and `z2Ptr'. 4232fe8fb19SBen Gras------------------------------------------------------------------------------- 4242fe8fb19SBen Gras*/ 4252fe8fb19SBen GrasINLINE void 4262fe8fb19SBen Gras sub192( 4272fe8fb19SBen Gras bits64 a0, 4282fe8fb19SBen Gras bits64 a1, 4292fe8fb19SBen Gras bits64 a2, 4302fe8fb19SBen Gras bits64 b0, 4312fe8fb19SBen Gras bits64 b1, 4322fe8fb19SBen Gras bits64 b2, 4332fe8fb19SBen Gras bits64 *z0Ptr, 4342fe8fb19SBen Gras bits64 *z1Ptr, 4352fe8fb19SBen Gras bits64 *z2Ptr 4362fe8fb19SBen Gras ) 4372fe8fb19SBen Gras{ 4382fe8fb19SBen Gras bits64 z0, z1, z2; 4392fe8fb19SBen Gras int8 borrow0, borrow1; 4402fe8fb19SBen Gras 4412fe8fb19SBen Gras z2 = a2 - b2; 4422fe8fb19SBen Gras borrow1 = ( a2 < b2 ); 4432fe8fb19SBen Gras z1 = a1 - b1; 4442fe8fb19SBen Gras borrow0 = ( a1 < b1 ); 4452fe8fb19SBen Gras z0 = a0 - b0; 4462fe8fb19SBen Gras z0 -= ( z1 < (bits64)borrow1 ); 4472fe8fb19SBen Gras z1 -= borrow1; 4482fe8fb19SBen Gras z0 -= borrow0; 4492fe8fb19SBen Gras *z2Ptr = z2; 4502fe8fb19SBen Gras *z1Ptr = z1; 4512fe8fb19SBen Gras *z0Ptr = z0; 4522fe8fb19SBen Gras 4532fe8fb19SBen Gras} 4542fe8fb19SBen Gras 4552fe8fb19SBen Gras/* 4562fe8fb19SBen Gras------------------------------------------------------------------------------- 4572fe8fb19SBen GrasMultiplies `a' by `b' to obtain a 128-bit product. The product is broken 4582fe8fb19SBen Grasinto two 64-bit pieces which are stored at the locations pointed to by 4592fe8fb19SBen Gras`z0Ptr' and `z1Ptr'. 4602fe8fb19SBen Gras------------------------------------------------------------------------------- 4612fe8fb19SBen Gras*/ 4622fe8fb19SBen GrasINLINE void mul64To128( bits64 a, bits64 b, bits64 *z0Ptr, bits64 *z1Ptr ) 4632fe8fb19SBen Gras{ 4642fe8fb19SBen Gras bits32 aHigh, aLow, bHigh, bLow; 4652fe8fb19SBen Gras bits64 z0, zMiddleA, zMiddleB, z1; 4662fe8fb19SBen Gras 467*f14fb602SLionel Sambuc aLow = (bits32)a; 468*f14fb602SLionel Sambuc aHigh = (bits32)(a>>32); 469*f14fb602SLionel Sambuc bLow = (bits32)b; 470*f14fb602SLionel Sambuc bHigh = (bits32)(b>>32); 4712fe8fb19SBen Gras z1 = ( (bits64) aLow ) * bLow; 4722fe8fb19SBen Gras zMiddleA = ( (bits64) aLow ) * bHigh; 4732fe8fb19SBen Gras zMiddleB = ( (bits64) aHigh ) * bLow; 4742fe8fb19SBen Gras z0 = ( (bits64) aHigh ) * bHigh; 4752fe8fb19SBen Gras zMiddleA += zMiddleB; 4762fe8fb19SBen Gras z0 += ( ( (bits64) ( zMiddleA < zMiddleB ) )<<32 ) + ( zMiddleA>>32 ); 4772fe8fb19SBen Gras zMiddleA <<= 32; 4782fe8fb19SBen Gras z1 += zMiddleA; 4792fe8fb19SBen Gras z0 += ( z1 < zMiddleA ); 4802fe8fb19SBen Gras *z1Ptr = z1; 4812fe8fb19SBen Gras *z0Ptr = z0; 4822fe8fb19SBen Gras 4832fe8fb19SBen Gras} 4842fe8fb19SBen Gras 4852fe8fb19SBen Gras/* 4862fe8fb19SBen Gras------------------------------------------------------------------------------- 4872fe8fb19SBen GrasMultiplies the 128-bit value formed by concatenating `a0' and `a1' by 4882fe8fb19SBen Gras`b' to obtain a 192-bit product. The product is broken into three 64-bit 4892fe8fb19SBen Graspieces which are stored at the locations pointed to by `z0Ptr', `z1Ptr', and 4902fe8fb19SBen Gras`z2Ptr'. 4912fe8fb19SBen Gras------------------------------------------------------------------------------- 4922fe8fb19SBen Gras*/ 4932fe8fb19SBen GrasINLINE void 4942fe8fb19SBen Gras mul128By64To192( 4952fe8fb19SBen Gras bits64 a0, 4962fe8fb19SBen Gras bits64 a1, 4972fe8fb19SBen Gras bits64 b, 4982fe8fb19SBen Gras bits64 *z0Ptr, 4992fe8fb19SBen Gras bits64 *z1Ptr, 5002fe8fb19SBen Gras bits64 *z2Ptr 5012fe8fb19SBen Gras ) 5022fe8fb19SBen Gras{ 5032fe8fb19SBen Gras bits64 z0, z1, z2, more1; 5042fe8fb19SBen Gras 5052fe8fb19SBen Gras mul64To128( a1, b, &z1, &z2 ); 5062fe8fb19SBen Gras mul64To128( a0, b, &z0, &more1 ); 5072fe8fb19SBen Gras add128( z0, more1, 0, z1, &z0, &z1 ); 5082fe8fb19SBen Gras *z2Ptr = z2; 5092fe8fb19SBen Gras *z1Ptr = z1; 5102fe8fb19SBen Gras *z0Ptr = z0; 5112fe8fb19SBen Gras 5122fe8fb19SBen Gras} 5132fe8fb19SBen Gras 5142fe8fb19SBen Gras/* 5152fe8fb19SBen Gras------------------------------------------------------------------------------- 5162fe8fb19SBen GrasMultiplies the 128-bit value formed by concatenating `a0' and `a1' to the 5172fe8fb19SBen Gras128-bit value formed by concatenating `b0' and `b1' to obtain a 256-bit 5182fe8fb19SBen Grasproduct. The product is broken into four 64-bit pieces which are stored at 5192fe8fb19SBen Grasthe locations pointed to by `z0Ptr', `z1Ptr', `z2Ptr', and `z3Ptr'. 5202fe8fb19SBen Gras------------------------------------------------------------------------------- 5212fe8fb19SBen Gras*/ 5222fe8fb19SBen GrasINLINE void 5232fe8fb19SBen Gras mul128To256( 5242fe8fb19SBen Gras bits64 a0, 5252fe8fb19SBen Gras bits64 a1, 5262fe8fb19SBen Gras bits64 b0, 5272fe8fb19SBen Gras bits64 b1, 5282fe8fb19SBen Gras bits64 *z0Ptr, 5292fe8fb19SBen Gras bits64 *z1Ptr, 5302fe8fb19SBen Gras bits64 *z2Ptr, 5312fe8fb19SBen Gras bits64 *z3Ptr 5322fe8fb19SBen Gras ) 5332fe8fb19SBen Gras{ 5342fe8fb19SBen Gras bits64 z0, z1, z2, z3; 5352fe8fb19SBen Gras bits64 more1, more2; 5362fe8fb19SBen Gras 5372fe8fb19SBen Gras mul64To128( a1, b1, &z2, &z3 ); 5382fe8fb19SBen Gras mul64To128( a1, b0, &z1, &more2 ); 5392fe8fb19SBen Gras add128( z1, more2, 0, z2, &z1, &z2 ); 5402fe8fb19SBen Gras mul64To128( a0, b0, &z0, &more1 ); 5412fe8fb19SBen Gras add128( z0, more1, 0, z1, &z0, &z1 ); 5422fe8fb19SBen Gras mul64To128( a0, b1, &more1, &more2 ); 5432fe8fb19SBen Gras add128( more1, more2, 0, z2, &more1, &z2 ); 5442fe8fb19SBen Gras add128( z0, z1, 0, more1, &z0, &z1 ); 5452fe8fb19SBen Gras *z3Ptr = z3; 5462fe8fb19SBen Gras *z2Ptr = z2; 5472fe8fb19SBen Gras *z1Ptr = z1; 5482fe8fb19SBen Gras *z0Ptr = z0; 5492fe8fb19SBen Gras 5502fe8fb19SBen Gras} 5512fe8fb19SBen Gras 5522fe8fb19SBen Gras/* 5532fe8fb19SBen Gras------------------------------------------------------------------------------- 5542fe8fb19SBen GrasReturns an approximation to the 64-bit integer quotient obtained by dividing 5552fe8fb19SBen Gras`b' into the 128-bit value formed by concatenating `a0' and `a1'. The 5562fe8fb19SBen Grasdivisor `b' must be at least 2^63. If q is the exact quotient truncated 5572fe8fb19SBen Grastoward zero, the approximation returned lies between q and q + 2 inclusive. 5582fe8fb19SBen GrasIf the exact quotient q is larger than 64 bits, the maximum positive 64-bit 5592fe8fb19SBen Grasunsigned integer is returned. 5602fe8fb19SBen Gras------------------------------------------------------------------------------- 5612fe8fb19SBen Gras*/ 5622fe8fb19SBen Grasstatic bits64 estimateDiv128To64( bits64 a0, bits64 a1, bits64 b ) 5632fe8fb19SBen Gras{ 5642fe8fb19SBen Gras bits64 b0, b1; 5652fe8fb19SBen Gras bits64 rem0, rem1, term0, term1; 5662fe8fb19SBen Gras bits64 z; 5672fe8fb19SBen Gras 5682fe8fb19SBen Gras if ( b <= a0 ) return LIT64( 0xFFFFFFFFFFFFFFFF ); 5692fe8fb19SBen Gras b0 = b>>32; 5702fe8fb19SBen Gras z = ( b0<<32 <= a0 ) ? LIT64( 0xFFFFFFFF00000000 ) : ( a0 / b0 )<<32; 5712fe8fb19SBen Gras mul64To128( b, z, &term0, &term1 ); 5722fe8fb19SBen Gras sub128( a0, a1, term0, term1, &rem0, &rem1 ); 5732fe8fb19SBen Gras while ( ( (sbits64) rem0 ) < 0 ) { 5742fe8fb19SBen Gras z -= LIT64( 0x100000000 ); 5752fe8fb19SBen Gras b1 = b<<32; 5762fe8fb19SBen Gras add128( rem0, rem1, b0, b1, &rem0, &rem1 ); 5772fe8fb19SBen Gras } 5782fe8fb19SBen Gras rem0 = ( rem0<<32 ) | ( rem1>>32 ); 5792fe8fb19SBen Gras z |= ( b0<<32 <= rem0 ) ? 0xFFFFFFFF : rem0 / b0; 5802fe8fb19SBen Gras return z; 5812fe8fb19SBen Gras 5822fe8fb19SBen Gras} 5832fe8fb19SBen Gras 5842fe8fb19SBen Gras#if !defined(SOFTFLOAT_FOR_GCC) || defined(FLOATX80) || defined(FLOAT128) 5852fe8fb19SBen Gras/* 5862fe8fb19SBen Gras------------------------------------------------------------------------------- 5872fe8fb19SBen GrasReturns an approximation to the square root of the 32-bit significand given 5882fe8fb19SBen Grasby `a'. Considered as an integer, `a' must be at least 2^31. If bit 0 of 5892fe8fb19SBen Gras`aExp' (the least significant bit) is 1, the integer returned approximates 5902fe8fb19SBen Gras2^31*sqrt(`a'/2^31), where `a' is considered an integer. If bit 0 of `aExp' 5912fe8fb19SBen Grasis 0, the integer returned approximates 2^31*sqrt(`a'/2^30). In either 5922fe8fb19SBen Grascase, the approximation returned lies strictly within +/-2 of the exact 5932fe8fb19SBen Grasvalue. 5942fe8fb19SBen Gras------------------------------------------------------------------------------- 5952fe8fb19SBen Gras*/ 5962fe8fb19SBen Grasstatic bits32 estimateSqrt32( int16 aExp, bits32 a ) 5972fe8fb19SBen Gras{ 5982fe8fb19SBen Gras static const bits16 sqrtOddAdjustments[] = { 5992fe8fb19SBen Gras 0x0004, 0x0022, 0x005D, 0x00B1, 0x011D, 0x019F, 0x0236, 0x02E0, 6002fe8fb19SBen Gras 0x039C, 0x0468, 0x0545, 0x0631, 0x072B, 0x0832, 0x0946, 0x0A67 6012fe8fb19SBen Gras }; 6022fe8fb19SBen Gras static const bits16 sqrtEvenAdjustments[] = { 6032fe8fb19SBen Gras 0x0A2D, 0x08AF, 0x075A, 0x0629, 0x051A, 0x0429, 0x0356, 0x029E, 6042fe8fb19SBen Gras 0x0200, 0x0179, 0x0109, 0x00AF, 0x0068, 0x0034, 0x0012, 0x0002 6052fe8fb19SBen Gras }; 6062fe8fb19SBen Gras int8 idx; 6072fe8fb19SBen Gras bits32 z; 6082fe8fb19SBen Gras 6092fe8fb19SBen Gras idx = ( a>>27 ) & 15; 6102fe8fb19SBen Gras if ( aExp & 1 ) { 6112fe8fb19SBen Gras z = 0x4000 + ( a>>17 ) - sqrtOddAdjustments[ idx ]; 6122fe8fb19SBen Gras z = ( ( a / z )<<14 ) + ( z<<15 ); 6132fe8fb19SBen Gras a >>= 1; 6142fe8fb19SBen Gras } 6152fe8fb19SBen Gras else { 6162fe8fb19SBen Gras z = 0x8000 + ( a>>17 ) - sqrtEvenAdjustments[ idx ]; 6172fe8fb19SBen Gras z = a / z + z; 6182fe8fb19SBen Gras z = ( 0x20000 <= z ) ? 0xFFFF8000 : ( z<<15 ); 619*f14fb602SLionel Sambuc if ( z <= a ) return (bits32) ( ( (bits32) a )>>1 ); 6202fe8fb19SBen Gras } 6212fe8fb19SBen Gras return ( (bits32) ( ( ( (bits64) a )<<31 ) / z ) ) + ( z>>1 ); 6222fe8fb19SBen Gras 6232fe8fb19SBen Gras} 6242fe8fb19SBen Gras#endif 6252fe8fb19SBen Gras 6262fe8fb19SBen Gras/* 6272fe8fb19SBen Gras------------------------------------------------------------------------------- 6282fe8fb19SBen GrasReturns the number of leading 0 bits before the most-significant 1 bit of 6292fe8fb19SBen Gras`a'. If `a' is zero, 32 is returned. 6302fe8fb19SBen Gras------------------------------------------------------------------------------- 6312fe8fb19SBen Gras*/ 6322fe8fb19SBen Grasstatic int8 countLeadingZeros32( bits32 a ) 6332fe8fb19SBen Gras{ 6342fe8fb19SBen Gras static const int8 countLeadingZerosHigh[] = { 6352fe8fb19SBen Gras 8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 6362fe8fb19SBen Gras 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 6372fe8fb19SBen Gras 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 6382fe8fb19SBen Gras 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 6392fe8fb19SBen Gras 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 6402fe8fb19SBen Gras 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 6412fe8fb19SBen Gras 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 6422fe8fb19SBen Gras 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 6432fe8fb19SBen Gras 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6442fe8fb19SBen Gras 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6452fe8fb19SBen Gras 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6462fe8fb19SBen Gras 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6472fe8fb19SBen Gras 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6482fe8fb19SBen Gras 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6492fe8fb19SBen Gras 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6502fe8fb19SBen Gras 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 6512fe8fb19SBen Gras }; 6522fe8fb19SBen Gras int8 shiftCount; 6532fe8fb19SBen Gras 6542fe8fb19SBen Gras shiftCount = 0; 6552fe8fb19SBen Gras if ( a < 0x10000 ) { 6562fe8fb19SBen Gras shiftCount += 16; 6572fe8fb19SBen Gras a <<= 16; 6582fe8fb19SBen Gras } 6592fe8fb19SBen Gras if ( a < 0x1000000 ) { 6602fe8fb19SBen Gras shiftCount += 8; 6612fe8fb19SBen Gras a <<= 8; 6622fe8fb19SBen Gras } 6632fe8fb19SBen Gras shiftCount += countLeadingZerosHigh[ a>>24 ]; 6642fe8fb19SBen Gras return shiftCount; 6652fe8fb19SBen Gras 6662fe8fb19SBen Gras} 6672fe8fb19SBen Gras 6682fe8fb19SBen Gras/* 6692fe8fb19SBen Gras------------------------------------------------------------------------------- 6702fe8fb19SBen GrasReturns the number of leading 0 bits before the most-significant 1 bit of 6712fe8fb19SBen Gras`a'. If `a' is zero, 64 is returned. 6722fe8fb19SBen Gras------------------------------------------------------------------------------- 6732fe8fb19SBen Gras*/ 6742fe8fb19SBen Grasstatic int8 countLeadingZeros64( bits64 a ) 6752fe8fb19SBen Gras{ 6762fe8fb19SBen Gras int8 shiftCount; 6772fe8fb19SBen Gras 6782fe8fb19SBen Gras shiftCount = 0; 6792fe8fb19SBen Gras if ( a < ( (bits64) 1 )<<32 ) { 6802fe8fb19SBen Gras shiftCount += 32; 6812fe8fb19SBen Gras } 6822fe8fb19SBen Gras else { 6832fe8fb19SBen Gras a >>= 32; 6842fe8fb19SBen Gras } 685*f14fb602SLionel Sambuc shiftCount += (int8)countLeadingZeros32( (bits32)a ); 6862fe8fb19SBen Gras return shiftCount; 6872fe8fb19SBen Gras 6882fe8fb19SBen Gras} 6892fe8fb19SBen Gras 6902fe8fb19SBen Gras/* 6912fe8fb19SBen Gras------------------------------------------------------------------------------- 6922fe8fb19SBen GrasReturns 1 if the 128-bit value formed by concatenating `a0' and `a1' 6932fe8fb19SBen Grasis equal to the 128-bit value formed by concatenating `b0' and `b1'. 6942fe8fb19SBen GrasOtherwise, returns 0. 6952fe8fb19SBen Gras------------------------------------------------------------------------------- 6962fe8fb19SBen Gras*/ 6972fe8fb19SBen GrasINLINE flag eq128( bits64 a0, bits64 a1, bits64 b0, bits64 b1 ) 6982fe8fb19SBen Gras{ 6992fe8fb19SBen Gras 7002fe8fb19SBen Gras return ( a0 == b0 ) && ( a1 == b1 ); 7012fe8fb19SBen Gras 7022fe8fb19SBen Gras} 7032fe8fb19SBen Gras 7042fe8fb19SBen Gras/* 7052fe8fb19SBen Gras------------------------------------------------------------------------------- 7062fe8fb19SBen GrasReturns 1 if the 128-bit value formed by concatenating `a0' and `a1' is less 7072fe8fb19SBen Grasthan or equal to the 128-bit value formed by concatenating `b0' and `b1'. 7082fe8fb19SBen GrasOtherwise, returns 0. 7092fe8fb19SBen Gras------------------------------------------------------------------------------- 7102fe8fb19SBen Gras*/ 7112fe8fb19SBen GrasINLINE flag le128( bits64 a0, bits64 a1, bits64 b0, bits64 b1 ) 7122fe8fb19SBen Gras{ 7132fe8fb19SBen Gras 7142fe8fb19SBen Gras return ( a0 < b0 ) || ( ( a0 == b0 ) && ( a1 <= b1 ) ); 7152fe8fb19SBen Gras 7162fe8fb19SBen Gras} 7172fe8fb19SBen Gras 7182fe8fb19SBen Gras/* 7192fe8fb19SBen Gras------------------------------------------------------------------------------- 7202fe8fb19SBen GrasReturns 1 if the 128-bit value formed by concatenating `a0' and `a1' is less 7212fe8fb19SBen Grasthan the 128-bit value formed by concatenating `b0' and `b1'. Otherwise, 7222fe8fb19SBen Grasreturns 0. 7232fe8fb19SBen Gras------------------------------------------------------------------------------- 7242fe8fb19SBen Gras*/ 7252fe8fb19SBen GrasINLINE flag lt128( bits64 a0, bits64 a1, bits64 b0, bits64 b1 ) 7262fe8fb19SBen Gras{ 7272fe8fb19SBen Gras 7282fe8fb19SBen Gras return ( a0 < b0 ) || ( ( a0 == b0 ) && ( a1 < b1 ) ); 7292fe8fb19SBen Gras 7302fe8fb19SBen Gras} 7312fe8fb19SBen Gras 7322fe8fb19SBen Gras/* 7332fe8fb19SBen Gras------------------------------------------------------------------------------- 7342fe8fb19SBen GrasReturns 1 if the 128-bit value formed by concatenating `a0' and `a1' is 7352fe8fb19SBen Grasnot equal to the 128-bit value formed by concatenating `b0' and `b1'. 7362fe8fb19SBen GrasOtherwise, returns 0. 7372fe8fb19SBen Gras------------------------------------------------------------------------------- 7382fe8fb19SBen Gras*/ 7392fe8fb19SBen GrasINLINE flag ne128( bits64 a0, bits64 a1, bits64 b0, bits64 b1 ) 7402fe8fb19SBen Gras{ 7412fe8fb19SBen Gras 7422fe8fb19SBen Gras return ( a0 != b0 ) || ( a1 != b1 ); 7432fe8fb19SBen Gras 7442fe8fb19SBen Gras} 7452fe8fb19SBen Gras 746