History

clean up softfloat code, leave the things of obvious need

Sigrid Solveig Haflínudóttir committed 2 years ago

Commit 8a8dbdd1 parent 26684155 files · +370 −2348Browse files

Unified · Split

5 files
  1. Makefile +1 −0
  2. dotadd.c +4 −10
  3. mkfile +8 −2
  4. softfloat.c +341 −271
  5. softfloat.h +16 −2065
Makefile+1−0
@@ -124,6 +124,7 @@ HDRS=\ · 123 unmodified lines
124 sbar.h\124 sbar.h\
125 screen.h\125 screen.h\
126 server.h\126 server.h\
127 softfloat.h\
127 spritegn.h\128 spritegn.h\
128 unix/libc.h\129 unix/libc.h\
129 unix/u.h\130 unix/u.h\
dotadd.c+4−10
@@ -5,21 +5,15 @@ float · 4 unmodified lines
5dotadd(float *a, float *b)5dotadd(float *a, float *b)
6{6{
7 extFloat80_t x, y, m, z;7 extFloat80_t x, y, m, z;
8 union {
9 float32_t v;
10 float f;
11 }f;
12 int i;8 int i;
13 9
14 f.f = b[3];10 f32_to_extF80M(b[3], &z);
15 f32_to_extF80M(f.v, &z);
16 for(i = 0; i < 3; i++){11 for(i = 0; i < 3; i++){
17 f.f = a[i]; f32_to_extF80M(f.v, &x);12 f32_to_extF80M(a[i], &x);
18 f.f = b[i]; f32_to_extF80M(f.v, &y);13 f32_to_extF80M(b[i], &y);
19 extF80M_mul(&x, &y, &m);14 extF80M_mul(&x, &y, &m);
20 extF80M_add(&z, &m, &z);15 extF80M_add(&z, &m, &z);
21 f.v = extF80M_to_f32(&z);
22 }16 }
23 17
24 return f.f;18 return extF80M_to_f32(&z);;
25}19}
mkfile+8−2
@@ -2,10 +2,9 @@ · 1 unmodified line
2 2
3BIN=/$objtype/bin/games3BIN=/$objtype/bin/games
4TARG=quake4TARG=quake
5CFLAGS=$CFLAGS -p -D__plan9__5CFLAGS=$CFLAGS -D__plan9__
6 6
7OFILES=\7OFILES=\
8 ${SOFTFLOAT}\
9 span`{test -f span_$objtype.s && echo -n _$objtype}.$O\8 span`{test -f span_$objtype.s && echo -n _$objtype}.$O\
10 span_alpha.$O\9 span_alpha.$O\
11 dotproduct`{test -f span_$objtype.s && echo -n _$objtype}.$O\10 dotproduct`{test -f span_$objtype.s && echo -n _$objtype}.$O\
@@ -118,6 +117,7 @@ HFILES=\ · 106 unmodified lines
118 sbar.h\117 sbar.h\
119 screen.h\118 screen.h\
120 server.h\119 server.h\
120 softfloat.h\
121 spritegn.h\121 spritegn.h\
122 vid.h\122 vid.h\
123 view.h\123 view.h\
@@ -126,3 +126,9 @@ HFILES=\ · 2 unmodified lines
126 zone.h\126 zone.h\
127 127
128</sys/src/cmd/mkone128</sys/src/cmd/mkone
129
130dotadd.$O: dotadd.c
131 $CC $CFLAGS -p dotadd.c
132
133softfloat.$O: softfloat.c
134 $CC $CFLAGS -p softfloat.c
softfloat.c+341−271
@@ -40,12 +40,151 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. · 39 unmodified lines
40#define UINT64_C(x) x##ULL40#define UINT64_C(x) x##ULL
41#endif41#endif
42 42
43#if BYTE_ORDER == LITTLE_ENDIAN
44struct uint128 { u64int v0, v64; };
45struct uint64_extra { u64int extra, v; };
46#define wordIncr 1
47#define indexWord( total, n ) (n)
48#define indexWordHi( total ) ((total) - 1)
49#define indexWordLo( total ) 0
50#define indexMultiword( total, m, n ) (n)
51#define indexMultiwordHi( total, n ) ((total) - (n))
52#define indexMultiwordLo( total, n ) 0
53#define indexMultiwordHiBut( total, n ) (n)
54#define indexMultiwordLoBut( total, n ) 0
55#else
56struct uint128 { u64int v64, v0; };
57struct uint64_extra { u64int v, extra; };
58#define wordIncr -1
59#define indexWord( total, n ) ((total) - 1 - (n))
60#define indexWordHi( total ) 0
61#define indexWordLo( total ) ((total) - 1)
62#define indexMultiword( total, m, n ) ((total) - 1 - (m))
63#define indexMultiwordHi( total, n ) 0
64#define indexMultiwordLo( total, n ) ((total) - (n))
65#define indexMultiwordHiBut( total, n ) 0
66#define indexMultiwordLoBut( total, n ) (n)
67#endif
68
69/*----------------------------------------------------------------------------
70| Default value for 'softfloat_detectTininess'.
71*----------------------------------------------------------------------------*/
72#define init_detectTininess softfloat_tininess_afterRounding
73
74/*----------------------------------------------------------------------------
75| "Common NaN" structure, used to transfer NaN representations from one format
76| to another.
77*----------------------------------------------------------------------------*/
78struct commonNaN {
79 bool sign;
80#if BYTE_ORDER == LITTLE_ENDIAN
81 u64int v0, v64;
82#else
83 u64int v64, v0;
84#endif
85};
86
87union ui32_f32 { u32int ui; float32_t f; };
88
89enum {
90 softfloat_mulAdd_subC = 1,
91 softfloat_mulAdd_subProd = 2
92};
93
94
95/*----------------------------------------------------------------------------
96| Software floating-point underflow tininess-detection mode.
97*----------------------------------------------------------------------------*/
98enum {
99 softfloat_tininess_beforeRounding = 0,
100 softfloat_tininess_afterRounding = 1
101};
102
103/*----------------------------------------------------------------------------
104| Software floating-point rounding mode. (Mode "odd" is supported only if
105| SoftFloat is compiled with macro 'SOFTFLOAT_ROUND_ODD' defined.)
106*----------------------------------------------------------------------------*/
107enum {
108 softfloat_round_near_even = 0,
109 softfloat_round_minMag = 1,
110 softfloat_round_min = 2,
111 softfloat_round_max = 3,
112 softfloat_round_near_maxMag = 4,
113 softfloat_round_odd = 6
114};
115
116/*----------------------------------------------------------------------------
117| Software floating-point exception flags.
118*----------------------------------------------------------------------------*/
119typedef enum {
120 softfloat_flag_inexact = 1,
121 softfloat_flag_underflow = 2,
122 softfloat_flag_overflow = 4,
123 softfloat_flag_infinite = 8,
124 softfloat_flag_invalid = 16
125} exceptionFlag_t;
126
127/*----------------------------------------------------------------------------
128| Returns true when 32-bit unsigned integer 'uiA' has the bit pattern of a
129| 32-bit floating-point signaling NaN.
130| Note: This macro evaluates its argument more than once.
131*----------------------------------------------------------------------------*/
132#define softfloat_isSigNaNF32UI( uiA ) ((((uiA) & 0x7FC00000) == 0x7F800000) && ((uiA) & 0x003FFFFF))
133
134/*----------------------------------------------------------------------------
135| The bit pattern for a default generated 80-bit extended floating-point NaN.
136*----------------------------------------------------------------------------*/
137#define defaultNaNExtF80UI64 0xFFFF
138#define defaultNaNExtF80UI0 UINT64_C( 0xC000000000000000 )
139
140/*----------------------------------------------------------------------------
141| Returns true when the 80-bit unsigned integer formed from concatenating
142| 16-bit 'uiA64' and 64-bit 'uiA0' has the bit pattern of an 80-bit extended
143| floating-point signaling NaN.
144| Note: This macro evaluates its arguments more than once.
145*----------------------------------------------------------------------------*/
146#define softfloat_isSigNaNExtF80UI( uiA64, uiA0 ) ((((uiA64) & 0x7FFF) == 0x7FFF) && ! ((uiA0) & UINT64_C( 0x4000000000000000 )) && ((uiA0) & UINT64_C( 0x3FFFFFFFFFFFFFFF )))
147
148#define signF32UI( a ) ((bool) ((u32int) (a)>>31))
149#define expF32UI( a ) ((s16int) ((a)>>23) & 0xFF)
150#define fracF32UI( a ) ((a) & 0x007FFFFF)
151#define packToF32UI( sign, exp, sig ) (((u32int) (sign)<<31) + ((u32int) (exp)<<23) + (sig))
152
153#define isNaNF32UI( a ) (((~(a) & 0x7F800000) == 0) && ((a) & 0x007FFFFF))
154
155struct exp16_sig32 { s16int exp; u32int sig; };
156
157static struct exp16_sig32 softfloat_normSubnormalF32Sig( u32int );
158static float32_t softfloat_roundPackToF32( bool, s16int, u32int );
159
160#define signExtF80UI64( a64 ) ((bool) ((u16int) (a64)>>15))
161#define expExtF80UI64( a64 ) ((a64) & 0x7FFF)
162#define packToExtF80UI64( sign, exp ) ((u16int) (sign)<<15 | (exp))
163
164#define isNaNExtF80UI( a64, a0 ) ((((a64) & 0x7FFF) == 0x7FFF) && ((a0) & UINT64_C( 0x7FFFFFFFFFFFFFFF )))
165
166struct exp32_sig64 { s32int exp; u64int sig; };
167
168#define signF128UI64( a64 ) ((bool) ((u64int) (a64)>>63))
169#define expF128UI64( a64 ) ((s32int) ((a64)>>48) & 0x7FFF)
170#define fracF128UI64( a64 ) ((a64) & UINT64_C( 0x0000FFFFFFFFFFFF ))
171#define packToF128UI64( sign, exp, sig64 ) (((u64int) (sign)<<63) + ((u64int) (exp)<<48) + (sig64))
172
173#define isNaNF128UI( a64, a0 ) (((~(a64) & UINT64_C( 0x7FFF000000000000 )) == 0) && (a0 || ((a64) & UINT64_C( 0x0000FFFFFFFFFFFF ))))
174
175struct exp32_sig128 { s32int exp; struct uint128 sig; };
176
177/*----------------------------------------------------------------------------
178| Routine to raise any or all of the software floating-point exception flags.
179*----------------------------------------------------------------------------*/
180static void softfloat_raiseFlags( u8int );
181
43u8int softfloat_roundingMode = softfloat_round_near_even;182u8int softfloat_roundingMode = softfloat_round_near_even;
44u8int softfloat_detectTininess = init_detectTininess;183u8int softfloat_detectTininess = init_detectTininess;
45u8int softfloat_exceptionFlags = 0;184u8int softfloat_exceptionFlags = 0;
46u8int extF80_roundingPrecision = 80;185u8int extF80_roundingPrecision = 80;
47 186
48bool187static bool
49extF80M_isSignalingNaN( const extFloat80_t *aPtr )188extF80M_isSignalingNaN( const extFloat80_t *aPtr )
50{189{
51 const struct extFloat80M *aSPtr;190 const struct extFloat80M *aSPtr;
@@ -65,7 +204,7 @@ extF80M_isSignalingNaN( const extFloat80_t *aPtr ) · 13 unmodified lines
65| floating-point NaN, and stores this NaN at the location pointed to by204| floating-point NaN, and stores this NaN at the location pointed to by
66| `zSPtr'.205| `zSPtr'.
67*----------------------------------------------------------------------------*/206*----------------------------------------------------------------------------*/
68void207static void
69softfloat_commonNaNToExtF80M(const struct commonNaN *aPtr, struct extFloat80M *zSPtr )208softfloat_commonNaNToExtF80M(const struct commonNaN *aPtr, struct extFloat80M *zSPtr )
70{209{
71 210
@@ -78,7 +217,7 @@ softfloat_commonNaNToExtF80M(const struct commonNaN *aPtr, struct extFloat80M *z · 6 unmodified lines
78| Converts the common NaN pointed to by `aPtr' into a 32-bit floating-point217| Converts the common NaN pointed to by `aPtr' into a 32-bit floating-point
79| NaN, and returns the bit pattern of this value as an unsigned integer.218| NaN, and returns the bit pattern of this value as an unsigned integer.
80*----------------------------------------------------------------------------*/219*----------------------------------------------------------------------------*/
81u32int220static u32int
82softfloat_commonNaNToF32UI( const struct commonNaN *aPtr )221softfloat_commonNaNToF32UI( const struct commonNaN *aPtr )
83{222{
84 223
@@ -92,7 +231,7 @@ softfloat_commonNaNToF32UI( const struct commonNaN *aPtr ) · 7 unmodified lines
92| common NaN at the location pointed to by `zPtr'. If the NaN is a signaling231| common NaN at the location pointed to by `zPtr'. If the NaN is a signaling
93| NaN, the invalid exception is raised.232| NaN, the invalid exception is raised.
94*----------------------------------------------------------------------------*/233*----------------------------------------------------------------------------*/
95void234static void
96softfloat_extF80MToCommonNaN(const struct extFloat80M *aSPtr, struct commonNaN *zPtr )235softfloat_extF80MToCommonNaN(const struct extFloat80M *aSPtr, struct commonNaN *zPtr )
97{236{
98 237
@@ -111,7 +250,7 @@ softfloat_extF80MToCommonNaN(const struct extFloat80M *aSPtr, struct commonNaN * · 12 unmodified lines
111| location pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid250| location pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid
112| exception is raised.251| exception is raised.
113*----------------------------------------------------------------------------*/252*----------------------------------------------------------------------------*/
114void253static void
115softfloat_f32UIToCommonNaN( u32int uiA, struct commonNaN *zPtr )254softfloat_f32UIToCommonNaN( u32int uiA, struct commonNaN *zPtr )
116{255{
117 256
@@ -130,7 +269,7 @@ softfloat_f32UIToCommonNaN( u32int uiA, struct commonNaN *zPtr ) · 12 unmodified lines
130| at the location pointed to by `zSPtr'. If either original floating-point269| at the location pointed to by `zSPtr'. If either original floating-point
131| value is a signaling NaN, the invalid exception is raised.270| value is a signaling NaN, the invalid exception is raised.
132*----------------------------------------------------------------------------*/271*----------------------------------------------------------------------------*/
133void272static void
134softfloat_propagateNaNExtF80M(273softfloat_propagateNaNExtF80M(
135 const struct extFloat80M *aSPtr,274 const struct extFloat80M *aSPtr,
136 const struct extFloat80M *bSPtr,275 const struct extFloat80M *bSPtr,
@@ -197,7 +336,7 @@ softfloat_propagateNaNExtF80M( · 60 unmodified lines
197| result. If either original floating-point value is a signaling NaN, the336| result. If either original floating-point value is a signaling NaN, the
198| invalid exception is raised.337| invalid exception is raised.
199*----------------------------------------------------------------------------*/338*----------------------------------------------------------------------------*/
200struct uint128339static struct uint128
201 softfloat_propagateNaNExtF80UI(340 softfloat_propagateNaNExtF80UI(
202 u16int uiA64,341 u16int uiA64,
203 u64int uiA0,342 u64int uiA0,
@@ -257,20 +396,16 @@ struct uint128 · 53 unmodified lines
257| to substitute a result value. If traps are not implemented, this routine396| to substitute a result value. If traps are not implemented, this routine
258| should be simply `softfloat_exceptionFlags |= flags;'.397| should be simply `softfloat_exceptionFlags |= flags;'.
259*----------------------------------------------------------------------------*/398*----------------------------------------------------------------------------*/
260void399static void
261softfloat_raiseFlags( u8int flags )400softfloat_raiseFlags( u8int flags )
262{401{
263
264 softfloat_exceptionFlags |= flags;402 softfloat_exceptionFlags |= flags;
265
266}403}
267 404
268u64int405static u64int
269softfloat_shortShiftRightJam64( u64int a, u8int dist )406softfloat_shortShiftRightJam64( u64int a, u8int dist )
270{407{
271
272 return a>>dist | ((a & (((u64int) 1<<dist) - 1)) != 0);408 return a>>dist | ((a & (((u64int) 1<<dist) - 1)) != 0);
273
274}409}
275 410
276/*----------------------------------------------------------------------------411/*----------------------------------------------------------------------------
@@ -297,7 +432,7 @@ static const u8int softfloat_countLeadingZeros8[256] = { · 20 unmodified lines
297 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0432 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
298};433};
299 434
300u8int435static u8int
301softfloat_countLeadingZeros64( u64int a )436softfloat_countLeadingZeros64( u64int a )
302{437{
303 u8int count;438 u8int count;
@@ -325,7 +460,7 @@ softfloat_countLeadingZeros64( u64int a ) · 21 unmodified lines
325 460
326}461}
327 462
328int463static int
329softfloat_normExtF80SigM( u64int *sigPtr )464softfloat_normExtF80SigM( u64int *sigPtr )
330{465{
331 u64int sig;466 u64int sig;
@@ -338,7 +473,7 @@ softfloat_normExtF80SigM( u64int *sigPtr ) · 6 unmodified lines
338 473
339}474}
340 475
341u8int476static u8int
342softfloat_countLeadingZeros32( u32int a )477softfloat_countLeadingZeros32( u32int a )
343{478{
344 u8int count;479 u8int count;
@@ -357,7 +492,7 @@ softfloat_countLeadingZeros32( u32int a ) · 12 unmodified lines
357 492
358}493}
359 494
360struct exp16_sig32495static struct exp16_sig32
361softfloat_normSubnormalF32Sig( u32int sig )496softfloat_normSubnormalF32Sig( u32int sig )
362{497{
363 s8int shiftDist;498 s8int shiftDist;
@@ -370,7 +505,7 @@ softfloat_normSubnormalF32Sig( u32int sig ) · 6 unmodified lines
370 505
371}506}
372 507
373u32int508static u32int
374softfloat_shiftRightJam32( u32int a, u16int dist )509softfloat_shiftRightJam32( u32int a, u16int dist )
375{510{
376 511
@@ -379,7 +514,7 @@ softfloat_shiftRightJam32( u32int a, u16int dist ) · 2 unmodified lines
379 514
380}515}
381 516
382float32_t517static float32_t
383 softfloat_roundPackToF32( bool sign, s16int exp, u32int sig )518 softfloat_roundPackToF32( bool sign, s16int exp, u32int sig )
384{519{
385 u8int roundingMode;520 u8int roundingMode;
@@ -431,18 +566,11 @@ float32_t · 45 unmodified lines
431 sig = (sig + roundIncrement)>>7;566 sig = (sig + roundIncrement)>>7;
432 if ( roundBits ) {567 if ( roundBits ) {
433 softfloat_exceptionFlags |= softfloat_flag_inexact;568 softfloat_exceptionFlags |= softfloat_flag_inexact;
434#ifdef SOFTFLOAT_ROUND_ODD
435 if ( roundingMode == softfloat_round_odd ) {
436 sig |= 1;
437 goto packReturn;
438 }
439#endif
440 }569 }
441 sig &= ~(u32int) (! (roundBits ^ 0x40) & roundNearEven);570 sig &= ~(u32int) (! (roundBits ^ 0x40) & roundNearEven);
442 if ( ! sig ) exp = 0;571 if ( ! sig ) exp = 0;
443 /*------------------------------------------------------------------------572 /*------------------------------------------------------------------------
444 *------------------------------------------------------------------------*/573 *------------------------------------------------------------------------*/
445 packReturn:
446 uiZ = packToF32UI( sign, exp, sig );574 uiZ = packToF32UI( sign, exp, sig );
447 uiZ:575 uiZ:
448 uZ.ui = uiZ;576 uZ.ui = uiZ;
@@ -450,120 +578,7 @@ float32_t · 1 unmodified line
450 578
451}579}
452 580
453void581static struct uint64_extra
454f32_to_extF80M( float32_t a, extFloat80_t *zPtr )
455{
456 struct extFloat80M *zSPtr;
457 union ui32_f32 uA;
458 u32int uiA;
459 bool sign;
460 s16int exp;
461 u32int frac;
462 struct commonNaN commonNaN;
463 u16int uiZ64;
464 u32int uiZ32;
465 struct exp16_sig32 normExpSig;
466
467 /*------------------------------------------------------------------------
468 *------------------------------------------------------------------------*/
469 zSPtr = (struct extFloat80M *) zPtr;
470 uA.f = a;
471 uiA = uA.ui;
472 sign = signF32UI( uiA );
473 exp = expF32UI( uiA );
474 frac = fracF32UI( uiA );
475 /*------------------------------------------------------------------------
476 *------------------------------------------------------------------------*/
477 if ( exp == 0xFF ) {
478 if ( frac ) {
479 softfloat_f32UIToCommonNaN( uiA, &commonNaN );
480 softfloat_commonNaNToExtF80M( &commonNaN, zSPtr );
481 return;
482 }
483 uiZ64 = packToExtF80UI64( sign, 0x7FFF );
484 uiZ32 = 0x80000000;
485 goto uiZ;
486 }
487 /*------------------------------------------------------------------------
488 *------------------------------------------------------------------------*/
489 if ( ! exp ) {
490 if ( ! frac ) {
491 uiZ64 = packToExtF80UI64( sign, 0 );
492 uiZ32 = 0;
493 goto uiZ;
494 }
495 normExpSig = softfloat_normSubnormalF32Sig( frac );
496 exp = normExpSig.exp;
497 frac = normExpSig.sig;
498 }
499 /*------------------------------------------------------------------------
500 *------------------------------------------------------------------------*/
501 uiZ64 = packToExtF80UI64( sign, exp + 0x3F80 );
502 uiZ32 = 0x80000000 | (u32int) frac<<8;
503 uiZ:
504 zSPtr->signExp = uiZ64;
505 zSPtr->signif = (u64int) uiZ32<<32;
506
507}
508
509float32_t
510extF80M_to_f32( const extFloat80_t *aPtr )
511{
512 const struct extFloat80M *aSPtr;
513 u16int uiA64;
514 bool sign;
515 s32int exp;
516 u64int sig;
517 struct commonNaN commonNaN;
518 u32int uiZ, sig32;
519 union ui32_f32 uZ;
520
521 /*------------------------------------------------------------------------
522 *------------------------------------------------------------------------*/
523 aSPtr = (const struct extFloat80M *) aPtr;
524 /*------------------------------------------------------------------------
525 *------------------------------------------------------------------------*/
526 uiA64 = aSPtr->signExp;
527 sign = signExtF80UI64( uiA64 );
528 exp = expExtF80UI64( uiA64 );
529 sig = aSPtr->signif;
530 /*------------------------------------------------------------------------
531 *------------------------------------------------------------------------*/
532 if ( exp == 0x7FFF ) {
533 if ( sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
534 softfloat_extF80MToCommonNaN( aSPtr, &commonNaN );
535 uiZ = softfloat_commonNaNToF32UI( &commonNaN );
536 } else {
537 uiZ = packToF32UI( sign, 0xFF, 0 );
538 }
539 goto uiZ;
540 }
541 /*------------------------------------------------------------------------
542 *------------------------------------------------------------------------*/
543 if ( ! (sig & UINT64_C( 0x8000000000000000 )) ) {
544 if ( ! sig ) {
545 uiZ = packToF32UI( sign, 0, 0 );
546 goto uiZ;
547 }
548 exp += softfloat_normExtF80SigM( &sig );
549 }
550 /*------------------------------------------------------------------------
551 *------------------------------------------------------------------------*/
552 sig32 = softfloat_shortShiftRightJam64( sig, 33 );
553 exp -= 0x3F81;
554 if ( sizeof (s16int) < sizeof (s32int) ) {
555 if ( exp < -0x1000 ) exp = -0x1000;
556 }
557 return softfloat_roundPackToF32( sign, exp, sig32 );
558 /*------------------------------------------------------------------------
559 *------------------------------------------------------------------------*/
560 uiZ:
561 uZ.ui = uiZ;
562 return uZ.f;
563
564}
565
566struct uint64_extra
567 softfloat_shiftRightJam64Extra(582 softfloat_shiftRightJam64Extra(
568 u64int a, u64int extra, u32int dist )583 u64int a, u64int extra, u32int dist )
569{584{
@@ -581,7 +596,7 @@ struct uint64_extra · 11 unmodified lines
581 596
582}597}
583 598
584struct uint128599static struct uint128
585 softfloat_shiftRightJam128( u64int a64, u64int a0, u32int dist )600 softfloat_shiftRightJam128( u64int a64, u64int a0, u32int dist )
586{601{
587 u8int u8NegDist;602 u8int u8NegDist;
@@ -606,7 +621,7 @@ struct uint128 · 18 unmodified lines
606 621
607}622}
608 623
609struct uint64_extra624static struct uint64_extra
610 softfloat_shortShiftRightJam64Extra(625 softfloat_shortShiftRightJam64Extra(
611 u64int a, u64int extra, u8int dist )626 u64int a, u64int extra, u8int dist )
612{627{
@@ -618,7 +633,7 @@ struct uint64_extra · 5 unmodified lines
618 633
619}634}
620 635
621struct exp32_sig64636static struct exp32_sig64
622softfloat_normSubnormalExtF80Sig( u64int sig )637softfloat_normSubnormalExtF80Sig( u64int sig )
623{638{
624 s8int shiftDist;639 s8int shiftDist;
@@ -631,7 +646,7 @@ softfloat_normSubnormalExtF80Sig( u64int sig ) · 6 unmodified lines
631 646
632}647}
633 648
634struct uint128649static struct uint128
635 softfloat_sub128( u64int a64, u64int a0, u64int b64, u64int b0 )650 softfloat_sub128( u64int a64, u64int a0, u64int b64, u64int b0 )
636{651{
637 struct uint128 z;652 struct uint128 z;
@@ -642,7 +657,7 @@ struct uint128 · 4 unmodified lines
642 657
643}658}
644 659
645u64int660static u64int
646softfloat_shiftRightJam64( u64int a, u32int dist )661softfloat_shiftRightJam64( u64int a, u32int dist )
647{662{
648 return663 return
@@ -650,7 +665,7 @@ softfloat_shiftRightJam64( u64int a, u32int dist ) · 1 unmodified line
650 665
651}666}
652 667
653struct uint128668static struct uint128
654 softfloat_shortShiftLeft128( u64int a64, u64int a0, u8int dist )669 softfloat_shortShiftLeft128( u64int a64, u64int a0, u8int dist )
655{670{
656 struct uint128 z;671 struct uint128 z;
@@ -661,37 +676,7 @@ struct uint128 · 4 unmodified lines
661 676
662}677}
663 678
664extFloat80_t679static extFloat80_t
665 softfloat_normRoundPackToExtF80(
666 bool sign,
667 s32int exp,
668 u64int sig,
669 u64int sigExtra,
670 u8int roundingPrecision
671 )
672{
673 s8int shiftDist;
674 struct uint128 sig128;
675
676 if ( ! sig ) {
677 exp -= 64;
678 sig = sigExtra;
679 sigExtra = 0;
680 }
681 shiftDist = softfloat_countLeadingZeros64( sig );
682 exp -= shiftDist;
683 if ( shiftDist ) {
684 sig128 = softfloat_shortShiftLeft128( sig, sigExtra, shiftDist );
685 sig = sig128.v64;
686 sigExtra = sig128.v0;
687 }
688 return
689 softfloat_roundPackToExtF80(
690 sign, exp, sig, sigExtra, roundingPrecision );
691
692}
693
694extFloat80_t
695 softfloat_roundPackToExtF80(680 softfloat_roundPackToExtF80(
696 bool sign,681 bool sign,
697 s32int exp,682 s32int exp,
@@ -746,11 +731,6 @@ extFloat80_t · 48 unmodified lines
746 if ( roundBits ) {731 if ( roundBits ) {
747 if ( isTiny ) softfloat_raiseFlags( softfloat_flag_underflow );732 if ( isTiny ) softfloat_raiseFlags( softfloat_flag_underflow );
748 softfloat_exceptionFlags |= softfloat_flag_inexact;733 softfloat_exceptionFlags |= softfloat_flag_inexact;
749#ifdef SOFTFLOAT_ROUND_ODD
750 if ( roundingMode == softfloat_round_odd ) {
751 sig |= roundMask + 1;
752 }
753#endif
754 }734 }
755 sig += roundIncrement;735 sig += roundIncrement;
756 exp = ((sig & UINT64_C( 0x8000000000000000 )) != 0);736 exp = ((sig & UINT64_C( 0x8000000000000000 )) != 0);
@@ -772,12 +752,6 @@ extFloat80_t · 15 unmodified lines
772 *------------------------------------------------------------------------*/752 *------------------------------------------------------------------------*/
773 if ( roundBits ) {753 if ( roundBits ) {
774 softfloat_exceptionFlags |= softfloat_flag_inexact;754 softfloat_exceptionFlags |= softfloat_flag_inexact;
775#ifdef SOFTFLOAT_ROUND_ODD
776 if ( roundingMode == softfloat_round_odd ) {
777 sig = (sig & ~roundMask) | (roundMask + 1);
778 goto packReturn;
779 }
780#endif
781 }755 }
782 sig = (u64int) (sig + roundIncrement);756 sig = (u64int) (sig + roundIncrement);
783 if ( sig < roundIncrement ) {757 if ( sig < roundIncrement ) {
@@ -820,12 +794,6 @@ extFloat80_t · 36 unmodified lines
820 if ( sigExtra ) {794 if ( sigExtra ) {
821 if ( isTiny ) softfloat_raiseFlags( softfloat_flag_underflow );795 if ( isTiny ) softfloat_raiseFlags( softfloat_flag_underflow );
822 softfloat_exceptionFlags |= softfloat_flag_inexact;796 softfloat_exceptionFlags |= softfloat_flag_inexact;
823#ifdef SOFTFLOAT_ROUND_ODD
824 if ( roundingMode == softfloat_round_odd ) {
825 sig |= 1;
826 goto packReturn;
827 }
828#endif
829 }797 }
830 doIncrement = (UINT64_C( 0x8000000000000000 ) <= sigExtra);798 doIncrement = (UINT64_C( 0x8000000000000000 ) <= sigExtra);
831 if (799 if (
@@ -877,12 +845,6 @@ extFloat80_t · 45 unmodified lines
877 *------------------------------------------------------------------------*/845 *------------------------------------------------------------------------*/
878 if ( sigExtra ) {846 if ( sigExtra ) {
879 softfloat_exceptionFlags |= softfloat_flag_inexact;847 softfloat_exceptionFlags |= softfloat_flag_inexact;
880#ifdef SOFTFLOAT_ROUND_ODD
881 if ( roundingMode == softfloat_round_odd ) {
882 sig |= 1;
883 goto packReturn;
884 }
885#endif
886 }848 }
887 if ( doIncrement ) {849 if ( doIncrement ) {
888 ++sig;850 ++sig;
@@ -905,7 +867,37 @@ extFloat80_t · 16 unmodified lines
905 867
906}868}
907 869
908extFloat80_t870static extFloat80_t
871 softfloat_normRoundPackToExtF80(
872 bool sign,
873 s32int exp,
874 u64int sig,
875 u64int sigExtra,
876 u8int roundingPrecision
877 )
878{
879 s8int shiftDist;
880 struct uint128 sig128;
881
882 if ( ! sig ) {
883 exp -= 64;
884 sig = sigExtra;
885 sigExtra = 0;
886 }
887 shiftDist = softfloat_countLeadingZeros64( sig );
888 exp -= shiftDist;
889 if ( shiftDist ) {
890 sig128 = softfloat_shortShiftLeft128( sig, sigExtra, shiftDist );
891 sig = sig128.v64;
892 sigExtra = sig128.v0;
893 }
894 return
895 softfloat_roundPackToExtF80(
896 sign, exp, sig, sigExtra, roundingPrecision );
897
898}
899
900static extFloat80_t
909 softfloat_subMagsExtF80(901 softfloat_subMagsExtF80(
910 u16int uiA64,902 u16int uiA64,
911 u64int uiA0,903 u64int uiA0,
@@ -1020,7 +1012,7 @@ extFloat80_t · 108 unmodified lines
1020 1012
1021}1013}
1022 1014
1023extFloat80_t1015static extFloat80_t
1024 softfloat_addMagsExtF80(1016 softfloat_addMagsExtF80(
1025 u16int uiA64,1017 u16int uiA64,
1026 u64int uiA0,1018 u64int uiA0,
@@ -1133,46 +1125,7 @@ extFloat80_t · 106 unmodified lines
1133 1125
1134}1126}
1135 1127
1136void1128static void
1137 extF80M_add(
1138 const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr )
1139{
1140 const struct extFloat80M *aSPtr, *bSPtr;
1141 u16int uiA64;
1142 u64int uiA0;
1143 bool signA;
1144 u16int uiB64;
1145 u64int uiB0;
1146 bool signB;
1147#if ! defined INLINE_LEVEL || (INLINE_LEVEL < 2)
1148 extFloat80_t
1149 (*magsFuncPtr)(
1150 u16int, u64int, u16int, u64int, bool );
1151#endif
1152
1153 aSPtr = (const struct extFloat80M *) aPtr;
1154 bSPtr = (const struct extFloat80M *) bPtr;
1155 uiA64 = aSPtr->signExp;
1156 uiA0 = aSPtr->signif;
1157 signA = signExtF80UI64( uiA64 );
1158 uiB64 = bSPtr->signExp;
1159 uiB0 = bSPtr->signif;
1160 signB = signExtF80UI64( uiB64 );
1161#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
1162 if ( signA == signB ) {
1163 *zPtr = softfloat_addMagsExtF80( uiA64, uiA0, uiB64, uiB0, signA );
1164 } else {
1165 *zPtr = softfloat_subMagsExtF80( uiA64, uiA0, uiB64, uiB0, signA );
1166 }
1167#else
1168 magsFuncPtr =
1169 (signA == signB) ? softfloat_addMagsExtF80 : softfloat_subMagsExtF80;
1170 *zPtr = (*magsFuncPtr)( uiA64, uiA0, uiB64, uiB0, signA );
1171#endif
1172
1173}
1174
1175void
1176 softfloat_addM(1129 softfloat_addM(
1177 u8int size_words,1130 u8int size_words,
1178 const u32int *aPtr,1131 const u32int *aPtr,
@@ -1204,7 +1157,7 @@ void · 25 unmodified lines
1204*----------------------------------------------------------------------------*/1157*----------------------------------------------------------------------------*/
1205#define softfloat_add96M( aPtr, bPtr, zPtr ) softfloat_addM( 3, aPtr, bPtr, zPtr )1158#define softfloat_add96M( aPtr, bPtr, zPtr ) softfloat_addM( 3, aPtr, bPtr, zPtr )
1206 1159
1207void1160static void
1208softfloat_mul64To128M( u64int a, u64int b, u32int *zPtr )1161softfloat_mul64To128M( u64int a, u64int b, u32int *zPtr )
1209{1162{
1210 u32int a32, a0, b32, b0;1163 u32int a32, a0, b32, b0;
@@ -1229,7 +1182,7 @@ softfloat_mul64To128M( u64int a, u64int b, u32int *zPtr ) · 18 unmodified lines
1229 1182
1230}1183}
1231 1184
1232void1185static void
1233softfloat_invalidExtF80M( struct extFloat80M *zSPtr )1186softfloat_invalidExtF80M( struct extFloat80M *zSPtr )
1234{1187{
1235 1188
@@ -1239,7 +1192,7 @@ softfloat_invalidExtF80M( struct extFloat80M *zSPtr ) · 3 unmodified lines
1239 1192
1240}1193}
1241 1194
1242bool1195static bool
1243 softfloat_tryPropagateNaNExtF80M(1196 softfloat_tryPropagateNaNExtF80M(
1244 const struct extFloat80M *aSPtr,1197 const struct extFloat80M *aSPtr,
1245 const struct extFloat80M *bSPtr,1198 const struct extFloat80M *bSPtr,
@@ -1262,7 +1215,7 @@ bool · 16 unmodified lines
1262 1215
1263}1216}
1264 1217
1265void1218static void
1266 softfloat_shortShiftRightJamM(1219 softfloat_shortShiftRightJamM(
1267 u8int size_words,1220 u8int size_words,
1268 const u32int *aPtr,1221 const u32int *aPtr,
@@ -1296,7 +1249,7 @@ void · 27 unmodified lines
1296*----------------------------------------------------------------------------*/1249*----------------------------------------------------------------------------*/
1297#define softfloat_shiftRightJam96M( aPtr, dist, zPtr ) softfloat_shiftRightJamM( 3, aPtr, dist, zPtr )1250#define softfloat_shiftRightJam96M( aPtr, dist, zPtr ) softfloat_shiftRightJamM( 3, aPtr, dist, zPtr )
1298 1251
1299void1252static void
1300 softfloat_shiftRightJamM(1253 softfloat_shiftRightJamM(
1301 u8int size_words,1254 u8int size_words,
1302 const u32int *aPtr,1255 const u32int *aPtr,
@@ -1352,7 +1305,7 @@ void · 49 unmodified lines
1352 1305
1353}1306}
1354 1307
1355void1308static void
1356 softfloat_roundPackMToExtF80M(1309 softfloat_roundPackMToExtF80M(
1357 bool sign,1310 bool sign,
1358 s32int exp,1311 s32int exp,
@@ -1412,11 +1365,6 @@ void · 53 unmodified lines
1412 if ( roundBits ) {1365 if ( roundBits ) {
1413 if ( isTiny ) softfloat_raiseFlags( softfloat_flag_underflow );1366 if ( isTiny ) softfloat_raiseFlags( softfloat_flag_underflow );
1414 softfloat_exceptionFlags |= softfloat_flag_inexact;1367 softfloat_exceptionFlags |= softfloat_flag_inexact;
1415#ifdef SOFTFLOAT_ROUND_ODD
1416 if ( roundingMode == softfloat_round_odd ) {
1417 sig |= roundMask + 1;
1418 }
1419#endif
1420 }1368 }
1421 sig += roundIncrement;1369 sig += roundIncrement;
1422 exp = ((sig & UINT64_C( 0x8000000000000000 )) != 0);1370 exp = ((sig & UINT64_C( 0x8000000000000000 )) != 0);
@@ -1438,12 +1386,6 @@ void · 15 unmodified lines
1438 *------------------------------------------------------------------------*/1386 *------------------------------------------------------------------------*/
1439 if ( roundBits ) {1387 if ( roundBits ) {
1440 softfloat_exceptionFlags |= softfloat_flag_inexact;1388 softfloat_exceptionFlags |= softfloat_flag_inexact;
1441#ifdef SOFTFLOAT_ROUND_ODD
1442 if ( roundingMode == softfloat_round_odd ) {
1443 sig = (sig & ~roundMask) | (roundMask + 1);
1444 goto packReturn;
1445 }
1446#endif
1447 }1389 }
1448 sig += roundIncrement;1390 sig += roundIncrement;
1449 if ( sig < roundIncrement ) {1391 if ( sig < roundIncrement ) {
@@ -1488,12 +1430,6 @@ void · 38 unmodified lines
1488 if ( sigExtra ) {1430 if ( sigExtra ) {
1489 if ( isTiny ) softfloat_raiseFlags( softfloat_flag_underflow );1431 if ( isTiny ) softfloat_raiseFlags( softfloat_flag_underflow );
1490 softfloat_exceptionFlags |= softfloat_flag_inexact;1432 softfloat_exceptionFlags |= softfloat_flag_inexact;
1491#ifdef SOFTFLOAT_ROUND_ODD
1492 if ( roundingMode == softfloat_round_odd ) {
1493 sig |= 1;
1494 goto packReturn;
1495 }
1496#endif
1497 }1433 }
1498 doIncrement = (0x80000000 <= sigExtra);1434 doIncrement = (0x80000000 <= sigExtra);
1499 if (1435 if (
@@ -1542,12 +1478,6 @@ void · 42 unmodified lines
1542 *------------------------------------------------------------------------*/1478 *------------------------------------------------------------------------*/
1543 if ( sigExtra ) {1479 if ( sigExtra ) {
1544 softfloat_exceptionFlags |= softfloat_flag_inexact;1480 softfloat_exceptionFlags |= softfloat_flag_inexact;
1545#ifdef SOFTFLOAT_ROUND_ODD
1546 if ( roundingMode == softfloat_round_odd ) {
1547 sig |= 1;
1548 goto packReturn;
1549 }
1550#endif
1551 }1481 }
1552 if ( doIncrement ) {1482 if ( doIncrement ) {
1553 ++sig;1483 ++sig;
@@ -1566,6 +1496,146 @@ void · 12 unmodified lines
1566 1496
1567}1497}
1568 1498
1499void
1500f32_to_extF80M( float32_t a, extFloat80_t *zPtr )
1501{
1502 struct extFloat80M *zSPtr;
1503 union ui32_f32 uA;
1504 u32int uiA;
1505 bool sign;
1506 s16int exp;
1507 u32int frac;
1508 struct commonNaN commonNaN;
1509 u16int uiZ64;
1510 u32int uiZ32;
1511 struct exp16_sig32 normExpSig;
1512
1513 /*------------------------------------------------------------------------
1514 *------------------------------------------------------------------------*/
1515 zSPtr = (struct extFloat80M *) zPtr;
1516 uA.f = a;
1517 uiA = uA.ui;
1518 sign = signF32UI( uiA );
1519 exp = expF32UI( uiA );
1520 frac = fracF32UI( uiA );
1521 /*------------------------------------------------------------------------
1522 *------------------------------------------------------------------------*/
1523 if ( exp == 0xFF ) {
1524 if ( frac ) {
1525 softfloat_f32UIToCommonNaN( uiA, &commonNaN );
1526 softfloat_commonNaNToExtF80M( &commonNaN, zSPtr );
1527 return;
1528 }
1529 uiZ64 = packToExtF80UI64( sign, 0x7FFF );
1530 uiZ32 = 0x80000000;
1531 goto uiZ;
1532 }
1533 /*------------------------------------------------------------------------
1534 *------------------------------------------------------------------------*/
1535 if ( ! exp ) {
1536 if ( ! frac ) {
1537 uiZ64 = packToExtF80UI64( sign, 0 );
1538 uiZ32 = 0;
1539 goto uiZ;
1540 }
1541 normExpSig = softfloat_normSubnormalF32Sig( frac );
1542 exp = normExpSig.exp;
1543 frac = normExpSig.sig;
1544 }
1545 /*------------------------------------------------------------------------
1546 *------------------------------------------------------------------------*/
1547 uiZ64 = packToExtF80UI64( sign, exp + 0x3F80 );
1548 uiZ32 = 0x80000000 | (u32int) frac<<8;
1549 uiZ:
1550 zSPtr->signExp = uiZ64;
1551 zSPtr->signif = (u64int) uiZ32<<32;
1552
1553}
1554
1555float32_t
1556extF80M_to_f32( const extFloat80_t *aPtr )
1557{
1558 const struct extFloat80M *aSPtr;
1559 u16int uiA64;
1560 bool sign;
1561 s32int exp;
1562 u64int sig;
1563 struct commonNaN commonNaN;
1564 u32int uiZ, sig32;
1565 union ui32_f32 uZ;
1566
1567 /*------------------------------------------------------------------------
1568 *------------------------------------------------------------------------*/
1569 aSPtr = (const struct extFloat80M *) aPtr;
1570 /*------------------------------------------------------------------------
1571 *------------------------------------------------------------------------*/
1572 uiA64 = aSPtr->signExp;
1573 sign = signExtF80UI64( uiA64 );
1574 exp = expExtF80UI64( uiA64 );
1575 sig = aSPtr->signif;
1576 /*------------------------------------------------------------------------
1577 *------------------------------------------------------------------------*/
1578 if ( exp == 0x7FFF ) {
1579 if ( sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
1580 softfloat_extF80MToCommonNaN( aSPtr, &commonNaN );
1581 uiZ = softfloat_commonNaNToF32UI( &commonNaN );
1582 } else {
1583 uiZ = packToF32UI( sign, 0xFF, 0 );
1584 }
1585 goto uiZ;
1586 }
1587 /*------------------------------------------------------------------------
1588 *------------------------------------------------------------------------*/
1589 if ( ! (sig & UINT64_C( 0x8000000000000000 )) ) {
1590 if ( ! sig ) {
1591 uiZ = packToF32UI( sign, 0, 0 );
1592 goto uiZ;
1593 }
1594 exp += softfloat_normExtF80SigM( &sig );
1595 }
1596 /*------------------------------------------------------------------------
1597 *------------------------------------------------------------------------*/
1598 sig32 = softfloat_shortShiftRightJam64( sig, 33 );
1599 exp -= 0x3F81;
1600 if ( sizeof (s16int) < sizeof (s32int) ) {
1601 if ( exp < -0x1000 ) exp = -0x1000;
1602 }
1603 return softfloat_roundPackToF32( sign, exp, sig32 );
1604 /*------------------------------------------------------------------------
1605 *------------------------------------------------------------------------*/
1606 uiZ:
1607 uZ.ui = uiZ;
1608 return uZ.f;
1609
1610}
1611
1612void
1613 extF80M_add(
1614 const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr )
1615{
1616 const struct extFloat80M *aSPtr, *bSPtr;
1617 u16int uiA64;
1618 u64int uiA0;
1619 bool signA;
1620 u16int uiB64;
1621 u64int uiB0;
1622 bool signB;
1623
1624 aSPtr = (const struct extFloat80M *) aPtr;
1625 bSPtr = (const struct extFloat80M *) bPtr;
1626 uiA64 = aSPtr->signExp;
1627 uiA0 = aSPtr->signif;
1628 signA = signExtF80UI64( uiA64 );
1629 uiB64 = bSPtr->signExp;
1630 uiB0 = bSPtr->signif;
1631 signB = signExtF80UI64( uiB64 );
1632 if ( signA == signB ) {
1633 *zPtr = softfloat_addMagsExtF80( uiA64, uiA0, uiB64, uiB0, signA );
1634 } else {
1635 *zPtr = softfloat_subMagsExtF80( uiA64, uiA0, uiB64, uiB0, signA );
1636 }
1637}
1638
1569void1639void
1570 extF80M_mul(1640 extF80M_mul(
1571 const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr )1641 const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr )
softfloat.h+16−2065
@@ -35,2084 +35,35 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. · 34 unmodified lines
35 35
36#pragma once36#pragma once
37 37
38#define SOFTFLOAT_FAST_INT6438typedef struct extFloat80M extFloat80_t;
39#define LITTLEENDIAN39typedef float float32_t;
40#define INLINE_LEVEL 0
41#define SOFTFLOAT_FAST_DIV64TO32
42#define SOFTFLOAT_FAST_DIV32TO16
43#define SOFTFLOAT_ROUND_ODD
44#define INLINE inline
45
46#ifdef SOFTFLOAT_FAST_INT64
47
48#ifdef LITTLEENDIAN
49struct uint128 { u64int v0, v64; };
50struct uint64_extra { u64int extra, v; };
51struct uint128_extra { u64int extra; struct uint128 v; };
52#else
53struct uint128 { u64int v64, v0; };
54struct uint64_extra { u64int v, extra; };
55struct uint128_extra { struct uint128 v; u64int extra; };
56#endif
57
58#endif
59
60/*----------------------------------------------------------------------------
61| These macros are used to isolate the differences in word order between big-
62| endian and little-endian platforms.
63*----------------------------------------------------------------------------*/
64#ifdef LITTLEENDIAN
65#define wordIncr 1
66#define indexWord( total, n ) (n)
67#define indexWordHi( total ) ((total) - 1)
68#define indexWordLo( total ) 0
69#define indexMultiword( total, m, n ) (n)
70#define indexMultiwordHi( total, n ) ((total) - (n))
71#define indexMultiwordLo( total, n ) 0
72#define indexMultiwordHiBut( total, n ) (n)
73#define indexMultiwordLoBut( total, n ) 0
74#define INIT_UINTM4( v3, v2, v1, v0 ) { v0, v1, v2, v3 }
75#else
76#define wordIncr -1
77#define indexWord( total, n ) ((total) - 1 - (n))
78#define indexWordHi( total ) 0
79#define indexWordLo( total ) ((total) - 1)
80#define indexMultiword( total, m, n ) ((total) - 1 - (m))
81#define indexMultiwordHi( total, n ) 0
82#define indexMultiwordLo( total, n ) ((total) - (n))
83#define indexMultiwordHiBut( total, n ) 0
84#define indexMultiwordLoBut( total, n ) (n)
85#define INIT_UINTM4( v3, v2, v1, v0 ) { v3, v2, v1, v0 }
86#endif
87
88#ifndef softfloat_shortShiftRightJam64
89/*----------------------------------------------------------------------------
90| Shifts 'a' right by the number of bits given in 'dist', which must be in
91| the range 1 to 63. If any nonzero bits are shifted off, they are "jammed"
92| into the least-significant bit of the shifted value by setting the least-
93| significant bit to 1. This shifted-and-jammed value is returned.
94*----------------------------------------------------------------------------*/
95#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
96INLINE
97u64int softfloat_shortShiftRightJam64( u64int a, u8int dist )
98 { return a>>dist | ((a & (((u64int) 1<<dist) - 1)) != 0); }
99#else
100u64int softfloat_shortShiftRightJam64( u64int a, u8int dist );
101#endif
102#endif
103
104#ifndef softfloat_shiftRightJam32
105/*----------------------------------------------------------------------------
106| Shifts 'a' right by the number of bits given in 'dist', which must not
107| be zero. If any nonzero bits are shifted off, they are "jammed" into the
108| least-significant bit of the shifted value by setting the least-significant
109| bit to 1. This shifted-and-jammed value is returned.
110| The value of 'dist' can be arbitrarily large. In particular, if 'dist' is
111| greater than 32, the result will be either 0 or 1, depending on whether 'a'
112| is zero or nonzero.
113*----------------------------------------------------------------------------*/
114#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
115INLINE u32int softfloat_shiftRightJam32( u32int a, u16int dist )
116{
117 return
118 (dist < 31) ? a>>dist | ((u32int) (a<<(-dist & 31)) != 0) : (a != 0);
119}
120#else
121u32int softfloat_shiftRightJam32( u32int a, u16int dist );
122#endif
123#endif
124
125#ifndef softfloat_shiftRightJam64
126/*----------------------------------------------------------------------------
127| Shifts 'a' right by the number of bits given in 'dist', which must not
128| be zero. If any nonzero bits are shifted off, they are "jammed" into the
129| least-significant bit of the shifted value by setting the least-significant
130| bit to 1. This shifted-and-jammed value is returned.
131| The value of 'dist' can be arbitrarily large. In particular, if 'dist' is
132| greater than 64, the result will be either 0 or 1, depending on whether 'a'
133| is zero or nonzero.
134*----------------------------------------------------------------------------*/
135#if defined INLINE_LEVEL && (3 <= INLINE_LEVEL)
136INLINE u64int softfloat_shiftRightJam64( u64int a, u32int dist )
137{
138 return
139 (dist < 63) ? a>>dist | ((u64int) (a<<(-dist & 63)) != 0) : (a != 0);
140}
141#else
142u64int softfloat_shiftRightJam64( u64int a, u32int dist );
143#endif
144#endif
145
146#ifndef softfloat_countLeadingZeros16
147/*----------------------------------------------------------------------------
148| Returns the number of leading 0 bits before the most-significant 1 bit of
149| 'a'. If 'a' is zero, 16 is returned.
150*----------------------------------------------------------------------------*/
151#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
152INLINE u8int softfloat_countLeadingZeros16( u16int a )
153{
154 u8int count = 8;
155 if ( 0x100 <= a ) {
156 count = 0;
157 a >>= 8;
158 }
159 count += softfloat_countLeadingZeros8[a];
160 return count;
161}
162#else
163u8int softfloat_countLeadingZeros16( u16int a );
164#endif
165#endif
166
167#ifndef softfloat_countLeadingZeros32
168/*----------------------------------------------------------------------------
169| Returns the number of leading 0 bits before the most-significant 1 bit of
170| 'a'. If 'a' is zero, 32 is returned.
171*----------------------------------------------------------------------------*/
172#if defined INLINE_LEVEL && (3 <= INLINE_LEVEL)
173INLINE u8int softfloat_countLeadingZeros32( u32int a )
174{
175 u8int count = 0;
176 if ( a < 0x10000 ) {
177 count = 16;
178 a <<= 16;
179 }
180 if ( a < 0x1000000 ) {
181 count += 8;
182 a <<= 8;
183 }
184 count += softfloat_countLeadingZeros8[a>>24];
185 return count;
186}
187#else
188u8int softfloat_countLeadingZeros32( u32int a );
189#endif
190#endif
191
192#ifndef softfloat_countLeadingZeros64
193/*----------------------------------------------------------------------------
194| Returns the number of leading 0 bits before the most-significant 1 bit of
195| 'a'. If 'a' is zero, 64 is returned.
196*----------------------------------------------------------------------------*/
197u8int softfloat_countLeadingZeros64( u64int a );
198#endif
199
200extern const u16int softfloat_approxRecip_1k0s[16];
201extern const u16int softfloat_approxRecip_1k1s[16];
202
203#ifndef softfloat_approxRecip32_1
204/*----------------------------------------------------------------------------
205| Returns an approximation to the reciprocal of the number represented by 'a',
206| where 'a' is interpreted as an unsigned fixed-point number with one integer
207| bit and 31 fraction bits. The 'a' input must be "normalized", meaning that
208| its most-significant bit (bit 31) must be 1. Thus, if A is the value of
209| the fixed-point interpretation of 'a', then 1 <= A < 2. The returned value
210| is interpreted as a pure unsigned fraction, having no integer bits and 32
211| fraction bits. The approximation returned is never greater than the true
212| reciprocal 1/A, and it differs from the true reciprocal by at most 2.006 ulp
213| (units in the last place).
214*----------------------------------------------------------------------------*/
215#ifdef SOFTFLOAT_FAST_DIV64TO32
216#define softfloat_approxRecip32_1( a ) ((u32int) (UINT64_C( 0x7FFFFFFFFFFFFFFF ) / (u32int) (a)))
217#else
218u32int softfloat_approxRecip32_1( u32int a );
219#endif
220#endif
221
222extern const u16int softfloat_approxRecipSqrt_1k0s[16];
223extern const u16int softfloat_approxRecipSqrt_1k1s[16];
224
225#ifndef softfloat_approxRecipSqrt32_1
226/*----------------------------------------------------------------------------
227| Returns an approximation to the reciprocal of the square root of the number
228| represented by 'a', where 'a' is interpreted as an unsigned fixed-point
229| number either with one integer bit and 31 fraction bits or with two integer
230| bits and 30 fraction bits. The format of 'a' is determined by 'oddExpA',
231| which must be either 0 or 1. If 'oddExpA' is 1, 'a' is interpreted as
232| having one integer bit, and if 'oddExpA' is 0, 'a' is interpreted as having
233| two integer bits. The 'a' input must be "normalized", meaning that its
234| most-significant bit (bit 31) must be 1. Thus, if A is the value of the
235| fixed-point interpretation of 'a', it follows that 1 <= A < 2 when 'oddExpA'
236| is 1, and 2 <= A < 4 when 'oddExpA' is 0.
237| The returned value is interpreted as a pure unsigned fraction, having
238| no integer bits and 32 fraction bits. The approximation returned is never
239| greater than the true reciprocal 1/sqrt(A), and it differs from the true
240| reciprocal by at most 2.06 ulp (units in the last place). The approximation
241| returned is also always within the range 0.5 to 1; thus, the most-
242| significant bit of the result is always set.
243*----------------------------------------------------------------------------*/
244u32int softfloat_approxRecipSqrt32_1( unsigned int oddExpA, u32int a );
245#endif
246
247#ifdef SOFTFLOAT_FAST_INT64
248
249/*----------------------------------------------------------------------------
250| The following functions are needed only when 'SOFTFLOAT_FAST_INT64' is
251| defined.
252*----------------------------------------------------------------------------*/
253
254#ifndef softfloat_eq128
255/*----------------------------------------------------------------------------
256| Returns true if the 128-bit unsigned integer formed by concatenating 'a64'
257| and 'a0' is equal to the 128-bit unsigned integer formed by concatenating
258| 'b64' and 'b0'.
259*----------------------------------------------------------------------------*/
260#if defined INLINE_LEVEL && (1 <= INLINE_LEVEL)
261INLINE
262bool softfloat_eq128( u64int a64, u64int a0, u64int b64, u64int b0 )
263 { return (a64 == b64) && (a0 == b0); }
264#else
265bool softfloat_eq128( u64int a64, u64int a0, u64int b64, u64int b0 );
266#endif
267#endif
268
269#ifndef softfloat_le128
270/*----------------------------------------------------------------------------
271| Returns true if the 128-bit unsigned integer formed by concatenating 'a64'
272| and 'a0' is less than or equal to the 128-bit unsigned integer formed by
273| concatenating 'b64' and 'b0'.
274*----------------------------------------------------------------------------*/
275#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
276INLINE
277bool softfloat_le128( u64int a64, u64int a0, u64int b64, u64int b0 )
278 { return (a64 < b64) || ((a64 == b64) && (a0 <= b0)); }
279#else
280bool softfloat_le128( u64int a64, u64int a0, u64int b64, u64int b0 );
281#endif
282#endif
283
284#ifndef softfloat_lt128
285/*----------------------------------------------------------------------------
286| Returns true if the 128-bit unsigned integer formed by concatenating 'a64'
287| and 'a0' is less than the 128-bit unsigned integer formed by concatenating
288| 'b64' and 'b0'.
289*----------------------------------------------------------------------------*/
290#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
291INLINE
292bool softfloat_lt128( u64int a64, u64int a0, u64int b64, u64int b0 )
293 { return (a64 < b64) || ((a64 == b64) && (a0 < b0)); }
294#else
295bool softfloat_lt128( u64int a64, u64int a0, u64int b64, u64int b0 );
296#endif
297#endif
298
299#ifndef softfloat_shortShiftLeft128
300/*----------------------------------------------------------------------------
301| Shifts the 128 bits formed by concatenating 'a64' and 'a0' left by the
302| number of bits given in 'dist', which must be in the range 1 to 63.
303*----------------------------------------------------------------------------*/
304#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
305INLINE
306struct uint128
307 softfloat_shortShiftLeft128( u64int a64, u64int a0, u8int dist )
308{
309 struct uint128 z;
310 z.v64 = a64<<dist | a0>>(-dist & 63);
311 z.v0 = a0<<dist;
312 return z;
313}
314#else
315struct uint128
316 softfloat_shortShiftLeft128( u64int a64, u64int a0, u8int dist );
317#endif
318#endif
319
320#ifndef softfloat_shortShiftRight128
321/*----------------------------------------------------------------------------
322| Shifts the 128 bits formed by concatenating 'a64' and 'a0' right by the
323| number of bits given in 'dist', which must be in the range 1 to 63.
324*----------------------------------------------------------------------------*/
325#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
326INLINE
327struct uint128
328 softfloat_shortShiftRight128( u64int a64, u64int a0, u8int dist )
329{
330 struct uint128 z;
331 z.v64 = a64>>dist;
332 z.v0 = a64<<(-dist & 63) | a0>>dist;
333 return z;
334}
335#else
336struct uint128
337 softfloat_shortShiftRight128( u64int a64, u64int a0, u8int dist );
338#endif
339#endif
340
341#ifndef softfloat_shortShiftRightJam64Extra
342/*----------------------------------------------------------------------------
343| This function is the same as 'softfloat_shiftRightJam64Extra' (below),
344| except that 'dist' must be in the range 1 to 63.
345*----------------------------------------------------------------------------*/
346#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
347INLINE
348struct uint64_extra
349 softfloat_shortShiftRightJam64Extra(
350 u64int a, u64int extra, u8int dist )
351{
352 struct uint64_extra z;
353 z.v = a>>dist;
354 z.extra = a<<(-dist & 63) | (extra != 0);
355 return z;
356}
357#else
358struct uint64_extra
359 softfloat_shortShiftRightJam64Extra(
360 u64int a, u64int extra, u8int dist );
361#endif
362#endif
363
364#ifndef softfloat_shortShiftRightJam128
365/*----------------------------------------------------------------------------
366| Shifts the 128 bits formed by concatenating 'a64' and 'a0' right by the
367| number of bits given in 'dist', which must be in the range 1 to 63. If any
368| nonzero bits are shifted off, they are "jammed" into the least-significant
369| bit of the shifted value by setting the least-significant bit to 1. This
370| shifted-and-jammed value is returned.
371*----------------------------------------------------------------------------*/
372#if defined INLINE_LEVEL && (3 <= INLINE_LEVEL)
373INLINE
374struct uint128
375 softfloat_shortShiftRightJam128(
376 u64int a64, u64int a0, u8int dist )
377{
378 u8int negDist = -dist;
379 struct uint128 z;
380 z.v64 = a64>>dist;
381 z.v0 =
382 a64<<(negDist & 63) | a0>>dist
383 | ((u64int) (a0<<(negDist & 63)) != 0);
384 return z;
385}
386#else
387struct uint128
388 softfloat_shortShiftRightJam128(
389 u64int a64, u64int a0, u8int dist );
390#endif
391#endif
392
393#ifndef softfloat_shortShiftRightJam128Extra
394/*----------------------------------------------------------------------------
395| This function is the same as 'softfloat_shiftRightJam128Extra' (below),
396| except that 'dist' must be in the range 1 to 63.
397*----------------------------------------------------------------------------*/
398#if defined INLINE_LEVEL && (3 <= INLINE_LEVEL)
399INLINE
400struct uint128_extra
401 softfloat_shortShiftRightJam128Extra(
402 u64int a64, u64int a0, u64int extra, u8int dist )
403{
404 u8int negDist = -dist;
405 struct uint128_extra z;
406 z.v.v64 = a64>>dist;
407 z.v.v0 = a64<<(negDist & 63) | a0>>dist;
408 z.extra = a0<<(negDist & 63) | (extra != 0);
409 return z;
410}
411#else
412struct uint128_extra
413 softfloat_shortShiftRightJam128Extra(
414 u64int a64, u64int a0, u64int extra, u8int dist );
415#endif
416#endif
417
418#ifndef softfloat_shiftRightJam64Extra
419/*----------------------------------------------------------------------------
420| Shifts the 128 bits formed by concatenating 'a' and 'extra' right by 64
421| _plus_ the number of bits given in 'dist', which must not be zero. This
422| shifted value is at most 64 nonzero bits and is returned in the 'v' field
423| of the 'struct uint64_extra' result. The 64-bit 'extra' field of the result
424| contains a value formed as follows from the bits that were shifted off: The
425| _last_ bit shifted off is the most-significant bit of the 'extra' field, and
426| the other 63 bits of the 'extra' field are all zero if and only if _all_but_
427| _the_last_ bits shifted off were all zero.
428| (This function makes more sense if 'a' and 'extra' are considered to form
429| an unsigned fixed-point number with binary point between 'a' and 'extra'.
430| This fixed-point value is shifted right by the number of bits given in
431| 'dist', and the integer part of this shifted value is returned in the 'v'
432| field of the result. The fractional part of the shifted value is modified
433| as described above and returned in the 'extra' field of the result.)
434*----------------------------------------------------------------------------*/
435#if defined INLINE_LEVEL && (4 <= INLINE_LEVEL)
436INLINE
437struct uint64_extra
438 softfloat_shiftRightJam64Extra(
439 u64int a, u64int extra, u32int dist )
440{
441 struct uint64_extra z;
442 if ( dist < 64 ) {
443 z.v = a>>dist;
444 z.extra = a<<(-dist & 63);
445 } else {
446 z.v = 0;
447 z.extra = (dist == 64) ? a : (a != 0);
448 }
449 z.extra |= (extra != 0);
450 return z;
451}
452#else
453struct uint64_extra
454 softfloat_shiftRightJam64Extra(
455 u64int a, u64int extra, u32int dist );
456#endif
457#endif
458
459#ifndef softfloat_shiftRightJam128
460/*----------------------------------------------------------------------------
461| Shifts the 128 bits formed by concatenating 'a64' and 'a0' right by the
462| number of bits given in 'dist', which must not be zero. If any nonzero bits
463| are shifted off, they are "jammed" into the least-significant bit of the
464| shifted value by setting the least-significant bit to 1. This shifted-and-
465| jammed value is returned.
466| The value of 'dist' can be arbitrarily large. In particular, if 'dist' is
467| greater than 128, the result will be either 0 or 1, depending on whether the
468| original 128 bits are all zeros.
469*----------------------------------------------------------------------------*/
470struct uint128
471 softfloat_shiftRightJam128( u64int a64, u64int a0, u32int dist );
472#endif
473
474#ifndef softfloat_shiftRightJam128Extra
475/*----------------------------------------------------------------------------
476| Shifts the 192 bits formed by concatenating 'a64', 'a0', and 'extra' right
477| by 64 _plus_ the number of bits given in 'dist', which must not be zero.
478| This shifted value is at most 128 nonzero bits and is returned in the 'v'
479| field of the 'struct uint128_extra' result. The 64-bit 'extra' field of the
480| result contains a value formed as follows from the bits that were shifted
481| off: The _last_ bit shifted off is the most-significant bit of the 'extra'
482| field, and the other 63 bits of the 'extra' field are all zero if and only
483| if _all_but_the_last_ bits shifted off were all zero.
484| (This function makes more sense if 'a64', 'a0', and 'extra' are considered
485| to form an unsigned fixed-point number with binary point between 'a0' and
486| 'extra'. This fixed-point value is shifted right by the number of bits
487| given in 'dist', and the integer part of this shifted value is returned
488| in the 'v' field of the result. The fractional part of the shifted value
489| is modified as described above and returned in the 'extra' field of the
490| result.)
491*----------------------------------------------------------------------------*/
492struct uint128_extra
493 softfloat_shiftRightJam128Extra(
494 u64int a64, u64int a0, u64int extra, u32int dist );
495#endif
496
497#ifndef softfloat_shiftRightJam256M
498/*----------------------------------------------------------------------------
499| Shifts the 256-bit unsigned integer pointed to by 'aPtr' right by the number
500| of bits given in 'dist', which must not be zero. If any nonzero bits are
501| shifted off, they are "jammed" into the least-significant bit of the shifted
502| value by setting the least-significant bit to 1. This shifted-and-jammed
503| value is stored at the location pointed to by 'zPtr'. Each of 'aPtr' and
504| 'zPtr' points to an array of four 64-bit elements that concatenate in the
505| platform's normal endian order to form a 256-bit integer.
506| The value of 'dist' can be arbitrarily large. In particular, if 'dist'
507| is greater than 256, the stored result will be either 0 or 1, depending on
508| whether the original 256 bits are all zeros.
509*----------------------------------------------------------------------------*/
510void
511 softfloat_shiftRightJam256M(
512 const u64int *aPtr, u32int dist, u64int *zPtr );
513#endif
514
515#ifndef softfloat_add128
516/*----------------------------------------------------------------------------
517| Returns the sum of the 128-bit integer formed by concatenating 'a64' and
518| 'a0' and the 128-bit integer formed by concatenating 'b64' and 'b0'. The
519| addition is modulo 2^128, so any carry out is lost.
520*----------------------------------------------------------------------------*/
521#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
522INLINE
523struct uint128
524 softfloat_add128( u64int a64, u64int a0, u64int b64, u64int b0 )
525{
526 struct uint128 z;
527 z.v0 = a0 + b0;
528 z.v64 = a64 + b64 + (z.v0 < a0);
529 return z;
530}
531#else
532struct uint128
533 softfloat_add128( u64int a64, u64int a0, u64int b64, u64int b0 );
534#endif
535#endif
536
537#ifndef softfloat_add256M
538/*----------------------------------------------------------------------------
539| Adds the two 256-bit integers pointed to by 'aPtr' and 'bPtr'. The addition
540| is modulo 2^256, so any carry out is lost. The sum is stored at the
541| location pointed to by 'zPtr'. Each of 'aPtr', 'bPtr', and 'zPtr' points to
542| an array of four 64-bit elements that concatenate in the platform's normal
543| endian order to form a 256-bit integer.
544*----------------------------------------------------------------------------*/
545void
546 softfloat_add256M(
547 const u64int *aPtr, const u64int *bPtr, u64int *zPtr );
548#endif
549
550#ifndef softfloat_sub128
551/*----------------------------------------------------------------------------
552| Returns the difference of the 128-bit integer formed by concatenating 'a64'
553| and 'a0' and the 128-bit integer formed by concatenating 'b64' and 'b0'.
554| The subtraction is modulo 2^128, so any borrow out (carry out) is lost.
555*----------------------------------------------------------------------------*/
556#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
557INLINE
558struct uint128
559 softfloat_sub128( u64int a64, u64int a0, u64int b64, u64int b0 )
560{
561 struct uint128 z;
562 z.v0 = a0 - b0;
563 z.v64 = a64 - b64;
564 z.v64 -= (a0 < b0);
565 return z;
566}
567#else
568struct uint128
569 softfloat_sub128( u64int a64, u64int a0, u64int b64, u64int b0 );
570#endif
571#endif
572
573#ifndef softfloat_sub256M
574/*----------------------------------------------------------------------------
575| Subtracts the 256-bit integer pointed to by 'bPtr' from the 256-bit integer
576| pointed to by 'aPtr'. The addition is modulo 2^256, so any borrow out
577| (carry out) is lost. The difference is stored at the location pointed to
578| by 'zPtr'. Each of 'aPtr', 'bPtr', and 'zPtr' points to an array of four
579| 64-bit elements that concatenate in the platform's normal endian order to
580| form a 256-bit integer.
581*----------------------------------------------------------------------------*/
582void
583 softfloat_sub256M(
584 const u64int *aPtr, const u64int *bPtr, u64int *zPtr );
585#endif
586
587#ifndef softfloat_mul64ByShifted32To128
588/*----------------------------------------------------------------------------
589| Returns the 128-bit product of 'a', 'b', and 2^32.
590*----------------------------------------------------------------------------*/
591#if defined INLINE_LEVEL && (3 <= INLINE_LEVEL)
592INLINE struct uint128 softfloat_mul64ByShifted32To128( u64int a, u32int b )
593{
594 u64int mid;
595 struct uint128 z;
596 mid = (u64int) (u32int) a * b;
597 z.v0 = mid<<32;
598 z.v64 = (u64int) (u32int) (a>>32) * b + (mid>>32);
599 return z;
600}
601#else
602struct uint128 softfloat_mul64ByShifted32To128( u64int a, u32int b );
603#endif
604#endif
605
606#ifndef softfloat_mul64To128
607/*----------------------------------------------------------------------------
608| Returns the 128-bit product of 'a' and 'b'.
609*----------------------------------------------------------------------------*/
610struct uint128 softfloat_mul64To128( u64int a, u64int b );
611#endif
612
613#ifndef softfloat_mul128By32
614/*----------------------------------------------------------------------------
615| Returns the product of the 128-bit integer formed by concatenating 'a64' and
616| 'a0', multiplied by 'b'. The multiplication is modulo 2^128; any overflow
617| bits are discarded.
618*----------------------------------------------------------------------------*/
619#if defined INLINE_LEVEL && (4 <= INLINE_LEVEL)
620INLINE
621struct uint128 softfloat_mul128By32( u64int a64, u64int a0, u32int b )
622{
623 struct uint128 z;
624 u64int mid;
625 u32int carry;
626 z.v0 = a0 * b;
627 mid = (u64int) (u32int) (a0>>32) * b;
628 carry = (u32int) ((u32int) (z.v0>>32) - (u32int) mid);
629 z.v64 = a64 * b + (u32int) ((mid + carry)>>32);
630 return z;
631}
632#else
633struct uint128 softfloat_mul128By32( u64int a64, u64int a0, u32int b );
634#endif
635#endif
636
637#ifndef softfloat_mul128To256M
638/*----------------------------------------------------------------------------
639| Multiplies the 128-bit unsigned integer formed by concatenating 'a64' and
640| 'a0' by the 128-bit unsigned integer formed by concatenating 'b64' and
641| 'b0'. The 256-bit product is stored at the location pointed to by 'zPtr'.
642| Argument 'zPtr' points to an array of four 64-bit elements that concatenate
643| in the platform's normal endian order to form a 256-bit integer.
644*----------------------------------------------------------------------------*/
645void
646 softfloat_mul128To256M(
647 u64int a64, u64int a0, u64int b64, u64int b0, u64int *zPtr );
648#endif
649 40
41#ifdef __plan9__
42#define LITTLE_ENDIAN 1234
43#define BIG_ENDIAN 4321
44#if defined(__mips__) || \
45 defined(__power__) || defined(__power64__) || \
46 defined(__sparc__) || defined(__sparc64__)
47#define BYTE_ORDER BIG_ENDIAN
650#else48#else
651 49#define BYTE_ORDER LITTLE_ENDIAN
652/*----------------------------------------------------------------------------
653| The following functions are needed only when 'SOFTFLOAT_FAST_INT64' is not
654| defined.
655*----------------------------------------------------------------------------*/
656
657#ifndef softfloat_compare96M
658/*----------------------------------------------------------------------------
659| Compares the two 96-bit unsigned integers pointed to by 'aPtr' and 'bPtr'.
660| Returns -1 if the first integer (A) is less than the second (B); returns 0
661| if the two integers are equal; and returns +1 if the first integer (A)
662| is greater than the second (B). (The result is thus the signum of A - B.)
663| Each of 'aPtr' and 'bPtr' points to an array of three 32-bit elements that
664| concatenate in the platform's normal endian order to form a 96-bit integer.
665*----------------------------------------------------------------------------*/
666s8int softfloat_compare96M( const u32int *aPtr, const u32int *bPtr );
667#endif50#endif
668
669#ifndef softfloat_compare128M
670/*----------------------------------------------------------------------------
671| Compares the two 128-bit unsigned integers pointed to by 'aPtr' and 'bPtr'.
672| Returns -1 if the first integer (A) is less than the second (B); returns 0
673| if the two integers are equal; and returns +1 if the first integer (A)
674| is greater than the second (B). (The result is thus the signum of A - B.)
675| Each of 'aPtr' and 'bPtr' points to an array of four 32-bit elements that
676| concatenate in the platform's normal endian order to form a 128-bit integer.
677*----------------------------------------------------------------------------*/
678s8int
679 softfloat_compare128M( const u32int *aPtr, const u32int *bPtr );
680#endif
681
682#ifndef softfloat_shortShiftLeft64To96M
683/*----------------------------------------------------------------------------
684| Extends 'a' to 96 bits and shifts the value left by the number of bits given
685| in 'dist', which must be in the range 1 to 31. The result is stored at the
686| location pointed to by 'zPtr'. Argument 'zPtr' points to an array of three
687| 32-bit elements that concatenate in the platform's normal endian order to
688| form a 96-bit integer.
689*----------------------------------------------------------------------------*/
690#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
691INLINE
692void
693 softfloat_shortShiftLeft64To96M(
694 u64int a, u8int dist, u32int *zPtr )
695{
696 zPtr[indexWord( 3, 0 )] = (u32int) a<<dist;
697 a >>= 32 - dist;
698 zPtr[indexWord( 3, 2 )] = a>>32;
699 zPtr[indexWord( 3, 1 )] = a;
700}
701#else51#else
702void52#include <endian.h>
703 softfloat_shortShiftLeft64To96M(53#ifndef BYTE_ORDER
704 u64int a, u8int dist, u32int *zPtr );54#define LITTLE_ENDIAN __LITTLE_ENDIAN
705#endif55#define BIG_ENDIAN __BIG_ENDIAN
706#endif56#define BYTE_ORDER __BYTE_ORDER
707
708#ifndef softfloat_shortShiftLeftM
709/*----------------------------------------------------------------------------
710| Shifts the N-bit unsigned integer pointed to by 'aPtr' left by the number
711| of bits given in 'dist', where N = 'size_words' * 32. The value of 'dist'
712| must be in the range 1 to 31. Any nonzero bits shifted off are lost. The
713| shifted N-bit result is stored at the location pointed to by 'zPtr'. Each
714| of 'aPtr' and 'zPtr' points to a 'size_words'-long array of 32-bit elements
715| that concatenate in the platform's normal endian order to form an N-bit
716| integer.
717*----------------------------------------------------------------------------*/
718void
719 softfloat_shortShiftLeftM(
720 u8int size_words,
721 const u32int *aPtr,
722 u8int dist,
723 u32int *zPtr
724 );
725#endif
726
727#ifndef softfloat_shortShiftLeft96M
728/*----------------------------------------------------------------------------
729| This function or macro is the same as 'softfloat_shortShiftLeftM' with
730| 'size_words' = 3 (N = 96).
731*----------------------------------------------------------------------------*/
732#define softfloat_shortShiftLeft96M( aPtr, dist, zPtr ) softfloat_shortShiftLeftM( 3, aPtr, dist, zPtr )
733#endif
734
735#ifndef softfloat_shortShiftLeft128M
736/*----------------------------------------------------------------------------
737| This function or macro is the same as 'softfloat_shortShiftLeftM' with
738| 'size_words' = 4 (N = 128).
739*----------------------------------------------------------------------------*/
740#define softfloat_shortShiftLeft128M( aPtr, dist, zPtr ) softfloat_shortShiftLeftM( 4, aPtr, dist, zPtr )
741#endif
742
743#ifndef softfloat_shortShiftLeft160M
744/*----------------------------------------------------------------------------
745| This function or macro is the same as 'softfloat_shortShiftLeftM' with
746| 'size_words' = 5 (N = 160).
747*----------------------------------------------------------------------------*/
748#define softfloat_shortShiftLeft160M( aPtr, dist, zPtr ) softfloat_shortShiftLeftM( 5, aPtr, dist, zPtr )
749#endif
750
751#ifndef softfloat_shiftLeftM
752/*----------------------------------------------------------------------------
753| Shifts the N-bit unsigned integer pointed to by 'aPtr' left by the number
754| of bits given in 'dist', where N = 'size_words' * 32. The value of 'dist'
755| must not be zero. Any nonzero bits shifted off are lost. The shifted
756| N-bit result is stored at the location pointed to by 'zPtr'. Each of 'aPtr'
757| and 'zPtr' points to a 'size_words'-long array of 32-bit elements that
758| concatenate in the platform's normal endian order to form an N-bit integer.
759| The value of 'dist' can be arbitrarily large. In particular, if 'dist' is
760| greater than N, the stored result will be 0.
761*----------------------------------------------------------------------------*/
762void
763 softfloat_shiftLeftM(
764 u8int size_words,
765 const u32int *aPtr,
766 u32int dist,
767 u32int *zPtr
768 );
769#endif
770
771#ifndef softfloat_shiftLeft96M
772/*----------------------------------------------------------------------------
773| This function or macro is the same as 'softfloat_shiftLeftM' with
774| 'size_words' = 3 (N = 96).
775*----------------------------------------------------------------------------*/
776#define softfloat_shiftLeft96M( aPtr, dist, zPtr ) softfloat_shiftLeftM( 3, aPtr, dist, zPtr )
777#endif
778
779#ifndef softfloat_shiftLeft128M
780/*----------------------------------------------------------------------------
781| This function or macro is the same as 'softfloat_shiftLeftM' with
782| 'size_words' = 4 (N = 128).
783*----------------------------------------------------------------------------*/
784#define softfloat_shiftLeft128M( aPtr, dist, zPtr ) softfloat_shiftLeftM( 4, aPtr, dist, zPtr )
785#endif
786
787#ifndef softfloat_shiftLeft160M
788/*----------------------------------------------------------------------------
789| This function or macro is the same as 'softfloat_shiftLeftM' with
790| 'size_words' = 5 (N = 160).
791*----------------------------------------------------------------------------*/
792#define softfloat_shiftLeft160M( aPtr, dist, zPtr ) softfloat_shiftLeftM( 5, aPtr, dist, zPtr )
793#endif
794
795#ifndef softfloat_shortShiftRightM
796/*----------------------------------------------------------------------------
797| Shifts the N-bit unsigned integer pointed to by 'aPtr' right by the number
798| of bits given in 'dist', where N = 'size_words' * 32. The value of 'dist'
799| must be in the range 1 to 31. Any nonzero bits shifted off are lost. The
800| shifted N-bit result is stored at the location pointed to by 'zPtr'. Each
801| of 'aPtr' and 'zPtr' points to a 'size_words'-long array of 32-bit elements
802| that concatenate in the platform's normal endian order to form an N-bit
803| integer.
804*----------------------------------------------------------------------------*/
805void
806 softfloat_shortShiftRightM(
807 u8int size_words,
808 const u32int *aPtr,
809 u8int dist,
810 u32int *zPtr
811 );
812#endif
813
814#ifndef softfloat_shortShiftRight128M
815/*----------------------------------------------------------------------------
816| This function or macro is the same as 'softfloat_shortShiftRightM' with
817| 'size_words' = 4 (N = 128).
818*----------------------------------------------------------------------------*/
819#define softfloat_shortShiftRight128M( aPtr, dist, zPtr ) softfloat_shortShiftRightM( 4, aPtr, dist, zPtr )
820#endif
821
822#ifndef softfloat_shortShiftRight160M
823/*----------------------------------------------------------------------------
824| This function or macro is the same as 'softfloat_shortShiftRightM' with
825| 'size_words' = 5 (N = 160).
826*----------------------------------------------------------------------------*/
827#define softfloat_shortShiftRight160M( aPtr, dist, zPtr ) softfloat_shortShiftRightM( 5, aPtr, dist, zPtr )
828#endif
829
830#ifndef softfloat_shortShiftRightJamM
831/*----------------------------------------------------------------------------
832| Shifts the N-bit unsigned integer pointed to by 'aPtr' right by the number
833| of bits given in 'dist', where N = 'size_words' * 32. The value of 'dist'
834| must be in the range 1 to 31. If any nonzero bits are shifted off, they are
835| "jammed" into the least-significant bit of the shifted value by setting the
836| least-significant bit to 1. This shifted-and-jammed N-bit result is stored
837| at the location pointed to by 'zPtr'. Each of 'aPtr' and 'zPtr' points
838| to a 'size_words'-long array of 32-bit elements that concatenate in the
839| platform's normal endian order to form an N-bit integer.
840*----------------------------------------------------------------------------*/
841void
842 softfloat_shortShiftRightJamM(
843 u8int, const u32int *, u8int, u32int * );
844#endif
845
846#ifndef softfloat_shortShiftRightJam160M
847/*----------------------------------------------------------------------------
848| This function or macro is the same as 'softfloat_shortShiftRightJamM' with
849| 'size_words' = 5 (N = 160).
850*----------------------------------------------------------------------------*/
851#define softfloat_shortShiftRightJam160M( aPtr, dist, zPtr ) softfloat_shortShiftRightJamM( 5, aPtr, dist, zPtr )
852#endif
853
854#ifndef softfloat_shiftRightM
855/*----------------------------------------------------------------------------
856| Shifts the N-bit unsigned integer pointed to by 'aPtr' right by the number
857| of bits given in 'dist', where N = 'size_words' * 32. The value of 'dist'
858| must not be zero. Any nonzero bits shifted off are lost. The shifted
859| N-bit result is stored at the location pointed to by 'zPtr'. Each of 'aPtr'
860| and 'zPtr' points to a 'size_words'-long array of 32-bit elements that
861| concatenate in the platform's normal endian order to form an N-bit integer.
862| The value of 'dist' can be arbitrarily large. In particular, if 'dist' is
863| greater than N, the stored result will be 0.
864*----------------------------------------------------------------------------*/
865void
866 softfloat_shiftRightM(
867 u8int size_words,
868 const u32int *aPtr,
869 u32int dist,
870 u32int *zPtr
871 );
872#endif
873
874#ifndef softfloat_shiftRight96M
875/*----------------------------------------------------------------------------
876| This function or macro is the same as 'softfloat_shiftRightM' with
877| 'size_words' = 3 (N = 96).
878*----------------------------------------------------------------------------*/
879#define softfloat_shiftRight96M( aPtr, dist, zPtr ) softfloat_shiftRightM( 3, aPtr, dist, zPtr )
880#endif
881
882#ifndef softfloat_shiftRightJamM
883/*----------------------------------------------------------------------------
884| Shifts the N-bit unsigned integer pointed to by 'aPtr' right by the number
885| of bits given in 'dist', where N = 'size_words' * 32. The value of 'dist'
886| must not be zero. If any nonzero bits are shifted off, they are "jammed"
887| into the least-significant bit of the shifted value by setting the least-
888| significant bit to 1. This shifted-and-jammed N-bit result is stored
889| at the location pointed to by 'zPtr'. Each of 'aPtr' and 'zPtr' points
890| to a 'size_words'-long array of 32-bit elements that concatenate in the
891| platform's normal endian order to form an N-bit integer.
892| The value of 'dist' can be arbitrarily large. In particular, if 'dist'
893| is greater than N, the stored result will be either 0 or 1, depending on
894| whether the original N bits are all zeros.
895*----------------------------------------------------------------------------*/
896void
897 softfloat_shiftRightJamM(
898 u8int size_words,
899 const u32int *aPtr,
900 u32int dist,
901 u32int *zPtr
902 );
903#endif
904
905#ifndef softfloat_shiftRightJam128M
906/*----------------------------------------------------------------------------
907| This function or macro is the same as 'softfloat_shiftRightJamM' with
908| 'size_words' = 4 (N = 128).
909*----------------------------------------------------------------------------*/
910#define softfloat_shiftRightJam128M( aPtr, dist, zPtr ) softfloat_shiftRightJamM( 4, aPtr, dist, zPtr )
911#endif
912
913#ifndef softfloat_shiftRightJam160M
914/*----------------------------------------------------------------------------
915| This function or macro is the same as 'softfloat_shiftRightJamM' with
916| 'size_words' = 5 (N = 160).
917*----------------------------------------------------------------------------*/
918#define softfloat_shiftRightJam160M( aPtr, dist, zPtr ) softfloat_shiftRightJamM( 5, aPtr, dist, zPtr )
919#endif
920
921#ifndef softfloat_addM
922/*----------------------------------------------------------------------------
923| Adds the two N-bit integers pointed to by 'aPtr' and 'bPtr', where N =
924| 'size_words' * 32. The addition is modulo 2^N, so any carry out is lost.
925| The N-bit sum is stored at the location pointed to by 'zPtr'. Each of
926| 'aPtr', 'bPtr', and 'zPtr' points to a 'size_words'-long array of 32-bit
927| elements that concatenate in the platform's normal endian order to form an
928| N-bit integer.
929*----------------------------------------------------------------------------*/
930void
931 softfloat_addM(
932 u8int size_words,
933 const u32int *aPtr,
934 const u32int *bPtr,
935 u32int *zPtr
936 );
937#endif
938
939#ifndef softfloat_add128M
940/*----------------------------------------------------------------------------
941| This function or macro is the same as 'softfloat_addM' with 'size_words'
942| = 4 (N = 128).
943*----------------------------------------------------------------------------*/
944#define softfloat_add128M( aPtr, bPtr, zPtr ) softfloat_addM( 4, aPtr, bPtr, zPtr )
945#endif
946
947#ifndef softfloat_add160M
948/*----------------------------------------------------------------------------
949| This function or macro is the same as 'softfloat_addM' with 'size_words'
950| = 5 (N = 160).
951*----------------------------------------------------------------------------*/
952#define softfloat_add160M( aPtr, bPtr, zPtr ) softfloat_addM( 5, aPtr, bPtr, zPtr )
953#endif
954
955#ifndef softfloat_addCarryM
956/*----------------------------------------------------------------------------
957| Adds the two N-bit unsigned integers pointed to by 'aPtr' and 'bPtr', where
958| N = 'size_words' * 32, plus 'carry', which must be either 0 or 1. The N-bit
959| sum (modulo 2^N) is stored at the location pointed to by 'zPtr', and any
960| carry out is returned as the result. Each of 'aPtr', 'bPtr', and 'zPtr'
961| points to a 'size_words'-long array of 32-bit elements that concatenate in
962| the platform's normal endian order to form an N-bit integer.
963*----------------------------------------------------------------------------*/
964u8int
965 softfloat_addCarryM(
966 u8int size_words,
967 const u32int *aPtr,
968 const u32int *bPtr,
969 u8int carry,
970 u32int *zPtr
971 );
972#endif
973
974#ifndef softfloat_addComplCarryM
975/*----------------------------------------------------------------------------
976| This function or macro is the same as 'softfloat_addCarryM', except that
977| the value of the unsigned integer pointed to by 'bPtr' is bit-wise completed
978| before the addition.
979*----------------------------------------------------------------------------*/
980u8int
981 softfloat_addComplCarryM(
982 u8int size_words,
983 const u32int *aPtr,
984 const u32int *bPtr,
985 u8int carry,
986 u32int *zPtr
987 );
988#endif
989
990#ifndef softfloat_addComplCarry96M
991/*----------------------------------------------------------------------------
992| This function or macro is the same as 'softfloat_addComplCarryM' with
993| 'size_words' = 3 (N = 96).
994*----------------------------------------------------------------------------*/
995#define softfloat_addComplCarry96M( aPtr, bPtr, carry, zPtr ) softfloat_addComplCarryM( 3, aPtr, bPtr, carry, zPtr )
996#endif
997
998#ifndef softfloat_negXM
999/*----------------------------------------------------------------------------
1000| Replaces the N-bit unsigned integer pointed to by 'zPtr' by the
1001| 2s-complement of itself, where N = 'size_words' * 32. Argument 'zPtr'
1002| points to a 'size_words'-long array of 32-bit elements that concatenate in
1003| the platform's normal endian order to form an N-bit integer.
1004*----------------------------------------------------------------------------*/
1005void softfloat_negXM( u8int size_words, u32int *zPtr );
1006#endif57#endif
1007
1008#ifndef softfloat_negX96M
1009/*----------------------------------------------------------------------------
1010| This function or macro is the same as 'softfloat_negXM' with 'size_words'
1011| = 3 (N = 96).
1012*----------------------------------------------------------------------------*/
1013#define softfloat_negX96M( zPtr ) softfloat_negXM( 3, zPtr )
1014#endif
1015
1016#ifndef softfloat_negX128M
1017/*----------------------------------------------------------------------------
1018| This function or macro is the same as 'softfloat_negXM' with 'size_words'
1019| = 4 (N = 128).
1020*----------------------------------------------------------------------------*/
1021#define softfloat_negX128M( zPtr ) softfloat_negXM( 4, zPtr )
1022#endif
1023
1024#ifndef softfloat_negX160M
1025/*----------------------------------------------------------------------------
1026| This function or macro is the same as 'softfloat_negXM' with 'size_words'
1027| = 5 (N = 160).
1028*----------------------------------------------------------------------------*/
1029#define softfloat_negX160M( zPtr ) softfloat_negXM( 5, zPtr )
1030#endif
1031
1032#ifndef softfloat_negX256M
1033/*----------------------------------------------------------------------------
1034| This function or macro is the same as 'softfloat_negXM' with 'size_words'
1035| = 8 (N = 256).
1036*----------------------------------------------------------------------------*/
1037#define softfloat_negX256M( zPtr ) softfloat_negXM( 8, zPtr )
1038#endif
1039
1040#ifndef softfloat_sub1XM
1041/*----------------------------------------------------------------------------
1042| Subtracts 1 from the N-bit integer pointed to by 'zPtr', where N =
1043| 'size_words' * 32. The subtraction is modulo 2^N, so any borrow out (carry
1044| out) is lost. Argument 'zPtr' points to a 'size_words'-long array of 32-bit
1045| elements that concatenate in the platform's normal endian order to form an
1046| N-bit integer.
1047*----------------------------------------------------------------------------*/
1048void softfloat_sub1XM( u8int size_words, u32int *zPtr );
1049#endif
1050
1051#ifndef softfloat_sub1X96M
1052/*----------------------------------------------------------------------------
1053| This function or macro is the same as 'softfloat_sub1XM' with 'size_words'
1054| = 3 (N = 96).
1055*----------------------------------------------------------------------------*/
1056#define softfloat_sub1X96M( zPtr ) softfloat_sub1XM( 3, zPtr )
1057#endif
1058
1059#ifndef softfloat_sub1X160M
1060/*----------------------------------------------------------------------------
1061| This function or macro is the same as 'softfloat_sub1XM' with 'size_words'
1062| = 5 (N = 160).
1063*----------------------------------------------------------------------------*/
1064#define softfloat_sub1X160M( zPtr ) softfloat_sub1XM( 5, zPtr )
1065#endif
1066
1067#ifndef softfloat_subM
1068/*----------------------------------------------------------------------------
1069| Subtracts the two N-bit integers pointed to by 'aPtr' and 'bPtr', where N =
1070| 'size_words' * 32. The subtraction is modulo 2^N, so any borrow out (carry
1071| out) is lost. The N-bit difference is stored at the location pointed to by
1072| 'zPtr'. Each of 'aPtr', 'bPtr', and 'zPtr' points to a 'size_words'-long
1073| array of 32-bit elements that concatenate in the platform's normal endian
1074| order to form an N-bit integer.
1075*----------------------------------------------------------------------------*/
1076void
1077 softfloat_subM(
1078 u8int size_words,
1079 const u32int *aPtr,
1080 const u32int *bPtr,
1081 u32int *zPtr
1082 );
1083#endif
1084
1085#ifndef softfloat_sub96M
1086/*----------------------------------------------------------------------------
1087| This function or macro is the same as 'softfloat_subM' with 'size_words'
1088| = 3 (N = 96).
1089*----------------------------------------------------------------------------*/
1090#define softfloat_sub96M( aPtr, bPtr, zPtr ) softfloat_subM( 3, aPtr, bPtr, zPtr )
1091#endif
1092
1093#ifndef softfloat_sub128M
1094/*----------------------------------------------------------------------------
1095| This function or macro is the same as 'softfloat_subM' with 'size_words'
1096| = 4 (N = 128).
1097*----------------------------------------------------------------------------*/
1098#define softfloat_sub128M( aPtr, bPtr, zPtr ) softfloat_subM( 4, aPtr, bPtr, zPtr )
1099#endif
1100
1101#ifndef softfloat_sub160M
1102/*----------------------------------------------------------------------------
1103| This function or macro is the same as 'softfloat_subM' with 'size_words'
1104| = 5 (N = 160).
1105*----------------------------------------------------------------------------*/
1106#define softfloat_sub160M( aPtr, bPtr, zPtr ) softfloat_subM( 5, aPtr, bPtr, zPtr )
1107#endif58#endif
1108 59
1109#ifndef softfloat_mul64To128M60#if BYTE_ORDER == LITTLE_ENDIAN
1110/*----------------------------------------------------------------------------
1111| Multiplies 'a' and 'b' and stores the 128-bit product at the location
1112| pointed to by 'zPtr'. Argument 'zPtr' points to an array of four 32-bit
1113| elements that concatenate in the platform's normal endian order to form a
1114| 128-bit integer.
1115*----------------------------------------------------------------------------*/
1116void softfloat_mul64To128M( u64int a, u64int b, u32int *zPtr );
1117#endif
1118
1119#ifndef softfloat_mul128MTo256M
1120/*----------------------------------------------------------------------------
1121| Multiplies the two 128-bit unsigned integers pointed to by 'aPtr' and
1122| 'bPtr', and stores the 256-bit product at the location pointed to by 'zPtr'.
1123| Each of 'aPtr' and 'bPtr' points to an array of four 32-bit elements that
1124| concatenate in the platform's normal endian order to form a 128-bit integer.
1125| Argument 'zPtr' points to an array of eight 32-bit elements that concatenate
1126| to form a 256-bit integer.
1127*----------------------------------------------------------------------------*/
1128void
1129 softfloat_mul128MTo256M(
1130 const u32int *aPtr, const u32int *bPtr, u32int *zPtr );
1131#endif
1132
1133#ifndef softfloat_remStepMBy32
1134/*----------------------------------------------------------------------------
1135| Performs a "remainder reduction step" as follows: Arguments 'remPtr' and
1136| 'bPtr' both point to N-bit unsigned integers, where N = 'size_words' * 32.
1137| Defining R and B as the values of those integers, the expression (R<<'dist')
1138| - B * q is computed modulo 2^N, and the N-bit result is stored at the
1139| location pointed to by 'zPtr'. Each of 'remPtr', 'bPtr', and 'zPtr' points
1140| to a 'size_words'-long array of 32-bit elements that concatenate in the
1141| platform's normal endian order to form an N-bit integer.
1142*----------------------------------------------------------------------------*/
1143void
1144 softfloat_remStepMBy32(
1145 u8int size_words,
1146 const u32int *remPtr,
1147 u8int dist,
1148 const u32int *bPtr,
1149 u32int q,
1150 u32int *zPtr
1151 );
1152#endif
1153
1154#ifndef softfloat_remStep96MBy32
1155/*----------------------------------------------------------------------------
1156| This function or macro is the same as 'softfloat_remStepMBy32' with
1157| 'size_words' = 3 (N = 96).
1158*----------------------------------------------------------------------------*/
1159#define softfloat_remStep96MBy32( remPtr, dist, bPtr, q, zPtr ) softfloat_remStepMBy32( 3, remPtr, dist, bPtr, q, zPtr )
1160#endif
1161
1162#ifndef softfloat_remStep128MBy32
1163/*----------------------------------------------------------------------------
1164| This function or macro is the same as 'softfloat_remStepMBy32' with
1165| 'size_words' = 4 (N = 128).
1166*----------------------------------------------------------------------------*/
1167#define softfloat_remStep128MBy32( remPtr, dist, bPtr, q, zPtr ) softfloat_remStepMBy32( 4, remPtr, dist, bPtr, q, zPtr )
1168#endif
1169
1170#ifndef softfloat_remStep160MBy32
1171/*----------------------------------------------------------------------------
1172| This function or macro is the same as 'softfloat_remStepMBy32' with
1173| 'size_words' = 5 (N = 160).
1174*----------------------------------------------------------------------------*/
1175#define softfloat_remStep160MBy32( remPtr, dist, bPtr, q, zPtr ) softfloat_remStepMBy32( 5, remPtr, dist, bPtr, q, zPtr )
1176#endif
1177
1178#endif
1179
1180/*----------------------------------------------------------------------------
1181| Types used to pass 16-bit, 32-bit, 64-bit, and 128-bit floating-point
1182| arguments and results to/from functions. These types must be exactly
1183| 16 bits, 32 bits, 64 bits, and 128 bits in size, respectively. Where a
1184| platform has "native" support for IEEE-Standard floating-point formats,
1185| the types below may, if desired, be defined as aliases for the native types
1186| (typically 'float' and 'double', and possibly 'long double').
1187*----------------------------------------------------------------------------*/
1188
1189typedef struct { u16int v; } float16_t;
1190typedef struct { u16int v; } bfloat16_t;
1191typedef struct { u32int v; } float32_t;
1192typedef struct { u64int v; } float64_t;
1193typedef struct { u64int v[2]; } float128_t;
1194
1195/*----------------------------------------------------------------------------
1196| The format of an 80-bit extended floating-point number in memory. This
1197| structure must contain a 16-bit field named 'signExp' and a 64-bit field
1198| named 'signif'.
1199*----------------------------------------------------------------------------*/
1200#ifdef LITTLEENDIAN
1201struct extFloat80M { u64int signif; u16int signExp; };61struct extFloat80M { u64int signif; u16int signExp; };
1202#else62#else
1203struct extFloat80M { u16int signExp; u64int signif; };63struct extFloat80M { u16int signExp; u64int signif; };
1204#endif64#endif
1205 65
1206/*----------------------------------------------------------------------------
1207| The type used to pass 80-bit extended floating-point arguments and
1208| results to/from functions. This type must have size identical to
1209| 'struct extFloat80M'. Type 'extFloat80_t' can be defined as an alias for
1210| 'struct extFloat80M'. Alternatively, if a platform has "native" support
1211| for IEEE-Standard 80-bit extended floating-point, it may be possible,
1212| if desired, to define 'extFloat80_t' as an alias for the native type
1213| (presumably either 'long double' or a nonstandard compiler-intrinsic type).
1214| In that case, the 'signif' and 'signExp' fields of 'struct extFloat80M'
1215| must align exactly with the locations in memory of the sign, exponent, and
1216| significand of the native type.
1217*----------------------------------------------------------------------------*/
1218typedef struct extFloat80M extFloat80_t;
1219
1220union ui16_f16 { u16int ui; float16_t f; };
1221union ui16_bf16 { u16int ui; bfloat16_t f; };
1222union ui32_f32 { u32int ui; float32_t f; };
1223union ui64_f64 { u64int ui; float64_t f; };
1224
1225#ifdef SOFTFLOAT_FAST_INT64
1226union extF80M_extF80 { struct extFloat80M fM; extFloat80_t f; };
1227union ui128_f128 { struct uint128 ui; float128_t f; };
1228#endif
1229
1230enum {
1231 softfloat_mulAdd_subC = 1,
1232 softfloat_mulAdd_subProd = 2
1233};
1234
1235/*----------------------------------------------------------------------------
1236*----------------------------------------------------------------------------*/
1237u32int softfloat_roundToUI32( bool, u64int, u8int, bool );
1238
1239#ifdef SOFTFLOAT_FAST_INT64
1240u64int
1241 softfloat_roundToUI64(
1242 bool, u64int, u64int, u8int, bool );
1243#else
1244u64int softfloat_roundMToUI64( bool, u32int *, u8int, bool );
1245#endif
1246
1247s32int softfloat_roundToI32( bool, u64int, u8int, bool );
1248
1249#ifdef SOFTFLOAT_FAST_INT64
1250s64int
1251 softfloat_roundToI64(
1252 bool, u64int, u64int, u8int, bool );
1253#else
1254s64int softfloat_roundMToI64( bool, u32int *, u8int, bool );
1255#endif
1256
1257/*----------------------------------------------------------------------------
1258*----------------------------------------------------------------------------*/
1259#define signF16UI( a ) ((bool) ((u16int) (a)>>15))
1260#define expF16UI( a ) ((s8int) ((a)>>10) & 0x1F)
1261#define fracF16UI( a ) ((a) & 0x03FF)
1262#define packToF16UI( sign, exp, sig ) (((u16int) (sign)<<15) + ((u16int) (exp)<<10) + (sig))
1263
1264#define isNaNF16UI( a ) (((~(a) & 0x7C00) == 0) && ((a) & 0x03FF))
1265
1266struct exp8_sig16 { s8int exp; u16int sig; };
1267struct exp8_sig16 softfloat_normSubnormalF16Sig( u16int );
1268
1269float16_t softfloat_roundPackToF16( bool, s16int, u16int );
1270float16_t softfloat_normRoundPackToF16( bool, s16int, u16int );
1271
1272float16_t softfloat_addMagsF16( u16int, u16int );
1273float16_t softfloat_subMagsF16( u16int, u16int );
1274float16_t
1275 softfloat_mulAddF16(
1276 u16int, u16int, u16int, u8int );
1277
1278/*----------------------------------------------------------------------------
1279*----------------------------------------------------------------------------*/
1280#define signBF16UI( a ) ((bool) ((u16int) (a)>>15))
1281#define expBF16UI( a ) ((s16int) ((a)>>7) & 0xFF)
1282#define fracBF16UI( a ) ((a) & 0x07F)
1283#define packToBF16UI( sign, exp, sig ) (((u16int) (sign)<<15) + ((u16int) (exp)<<7) + (sig))
1284
1285#define isNaNBF16UI( a ) (((~(a) & 0x7FC0) == 0) && ((a) & 0x07F))
1286
1287bfloat16_t softfloat_roundPackToBF16( bool, s16int, u16int );
1288struct exp8_sig16 softfloat_normSubnormalBF16Sig( u16int );
1289
1290/*----------------------------------------------------------------------------
1291*----------------------------------------------------------------------------*/
1292#define signF32UI( a ) ((bool) ((u32int) (a)>>31))
1293#define expF32UI( a ) ((s16int) ((a)>>23) & 0xFF)
1294#define fracF32UI( a ) ((a) & 0x007FFFFF)
1295#define packToF32UI( sign, exp, sig ) (((u32int) (sign)<<31) + ((u32int) (exp)<<23) + (sig))
1296
1297#define isNaNF32UI( a ) (((~(a) & 0x7F800000) == 0) && ((a) & 0x007FFFFF))
1298
1299struct exp16_sig32 { s16int exp; u32int sig; };
1300struct exp16_sig32 softfloat_normSubnormalF32Sig( u32int );
1301
1302float32_t softfloat_roundPackToF32( bool, s16int, u32int );
1303float32_t softfloat_normRoundPackToF32( bool, s16int, u32int );
1304
1305float32_t softfloat_addMagsF32( u32int, u32int );
1306float32_t softfloat_subMagsF32( u32int, u32int );
1307float32_t
1308 softfloat_mulAddF32(
1309 u32int, u32int, u32int, u8int );
1310
1311/*----------------------------------------------------------------------------
1312*----------------------------------------------------------------------------*/
1313#define signF64UI( a ) ((bool) ((u64int) (a)>>63))
1314#define expF64UI( a ) ((s16int) ((a)>>52) & 0x7FF)
1315#define fracF64UI( a ) ((a) & UINT64_C( 0x000FFFFFFFFFFFFF ))
1316#define packToF64UI( sign, exp, sig ) ((u64int) (((u64int) (sign)<<63) + ((u64int) (exp)<<52) + (sig)))
1317
1318#define isNaNF64UI( a ) (((~(a) & UINT64_C( 0x7FF0000000000000 )) == 0) && ((a) & UINT64_C( 0x000FFFFFFFFFFFFF )))
1319
1320struct exp16_sig64 { s16int exp; u64int sig; };
1321struct exp16_sig64 softfloat_normSubnormalF64Sig( u64int );
1322
1323float64_t softfloat_roundPackToF64( bool, s16int, u64int );
1324float64_t softfloat_normRoundPackToF64( bool, s16int, u64int );
1325
1326float64_t softfloat_addMagsF64( u64int, u64int, bool );
1327float64_t softfloat_subMagsF64( u64int, u64int, bool );
1328float64_t
1329 softfloat_mulAddF64(
1330 u64int, u64int, u64int, u8int );
1331
1332/*----------------------------------------------------------------------------
1333*----------------------------------------------------------------------------*/
1334#define signExtF80UI64( a64 ) ((bool) ((u16int) (a64)>>15))
1335#define expExtF80UI64( a64 ) ((a64) & 0x7FFF)
1336#define packToExtF80UI64( sign, exp ) ((u16int) (sign)<<15 | (exp))
1337
1338#define isNaNExtF80UI( a64, a0 ) ((((a64) & 0x7FFF) == 0x7FFF) && ((a0) & UINT64_C( 0x7FFFFFFFFFFFFFFF )))
1339
1340#ifdef SOFTFLOAT_FAST_INT64
1341
1342/*----------------------------------------------------------------------------
1343*----------------------------------------------------------------------------*/
1344
1345struct exp32_sig64 { s32int exp; u64int sig; };
1346struct exp32_sig64 softfloat_normSubnormalExtF80Sig( u64int );
1347
1348extFloat80_t
1349 softfloat_roundPackToExtF80(
1350 bool, s32int, u64int, u64int, u8int );
1351extFloat80_t
1352 softfloat_normRoundPackToExtF80(
1353 bool, s32int, u64int, u64int, u8int );
1354
1355extFloat80_t
1356 softfloat_addMagsExtF80(
1357 u16int, u64int, u16int, u64int, bool );
1358extFloat80_t
1359 softfloat_subMagsExtF80(
1360 u16int, u64int, u16int, u64int, bool );
1361
1362/*----------------------------------------------------------------------------
1363*----------------------------------------------------------------------------*/
1364#define signF128UI64( a64 ) ((bool) ((u64int) (a64)>>63))
1365#define expF128UI64( a64 ) ((s32int) ((a64)>>48) & 0x7FFF)
1366#define fracF128UI64( a64 ) ((a64) & UINT64_C( 0x0000FFFFFFFFFFFF ))
1367#define packToF128UI64( sign, exp, sig64 ) (((u64int) (sign)<<63) + ((u64int) (exp)<<48) + (sig64))
1368
1369#define isNaNF128UI( a64, a0 ) (((~(a64) & UINT64_C( 0x7FFF000000000000 )) == 0) && (a0 || ((a64) & UINT64_C( 0x0000FFFFFFFFFFFF ))))
1370
1371struct exp32_sig128 { s32int exp; struct uint128 sig; };
1372struct exp32_sig128
1373 softfloat_normSubnormalF128Sig( u64int, u64int );
1374
1375float128_t
1376 softfloat_roundPackToF128(
1377 bool, s32int, u64int, u64int, u64int );
1378float128_t
1379 softfloat_normRoundPackToF128(
1380 bool, s32int, u64int, u64int );
1381
1382float128_t
1383 softfloat_addMagsF128(
1384 u64int, u64int, u64int, u64int, bool );
1385float128_t
1386 softfloat_subMagsF128(
1387 u64int, u64int, u64int, u64int, bool );
1388float128_t
1389 softfloat_mulAddF128(
1390 u64int,
1391 u64int,
1392 u64int,
1393 u64int,
1394 u64int,
1395 u64int,
1396 u8int
1397 );
1398
1399#else
1400
1401/*----------------------------------------------------------------------------
1402*----------------------------------------------------------------------------*/
1403
1404bool
1405 softfloat_tryPropagateNaNExtF80M(
1406 const struct extFloat80M *,
1407 const struct extFloat80M *,
1408 struct extFloat80M *
1409 );
1410void softfloat_invalidExtF80M( struct extFloat80M * );
1411
1412int softfloat_normExtF80SigM( u64int * );
1413
1414void
1415 softfloat_roundPackMToExtF80M(
1416 bool, s32int, u32int *, u8int, struct extFloat80M * );
1417void
1418 softfloat_normRoundPackMToExtF80M(
1419 bool, s32int, u32int *, u8int, struct extFloat80M * );
1420
1421void
1422 softfloat_addExtF80M(
1423 const struct extFloat80M *,
1424 const struct extFloat80M *,
1425 struct extFloat80M *,
1426 bool
1427 );
1428
1429int
1430 softfloat_compareNonnormExtF80M(
1431 const struct extFloat80M *, const struct extFloat80M * );
1432
1433/*----------------------------------------------------------------------------
1434*----------------------------------------------------------------------------*/
1435#define signF128UI96( a96 ) ((bool) ((u32int) (a96)>>31))
1436#define expF128UI96( a96 ) ((s32int) ((a96)>>16) & 0x7FFF)
1437#define fracF128UI96( a96 ) ((a96) & 0x0000FFFF)
1438#define packToF128UI96( sign, exp, sig96 ) (((u32int) (sign)<<31) + ((u32int) (exp)<<16) + (sig96))
1439
1440bool softfloat_isNaNF128M( const u32int * );
1441
1442bool
1443 softfloat_tryPropagateNaNF128M(
1444 const u32int *, const u32int *, u32int * );
1445void softfloat_invalidF128M( u32int * );
1446
1447int softfloat_shiftNormSigF128M( const u32int *, u8int, u32int * );
1448
1449void softfloat_roundPackMToF128M( bool, s32int, u32int *, u32int * );
1450void softfloat_normRoundPackMToF128M( bool, s32int, u32int *, u32int * );
1451
1452void
1453 softfloat_addF128M( const u32int *, const u32int *, u32int *, bool );
1454void
1455 softfloat_mulAddF128M(
1456 const u32int *,
1457 const u32int *,
1458 const u32int *,
1459 u32int *,
1460 u8int
1461 );
1462
1463#endif
1464
1465#ifndef THREAD_LOCAL
1466#define THREAD_LOCAL
1467#endif
1468
1469/*----------------------------------------------------------------------------
1470| Software floating-point underflow tininess-detection mode.
1471*----------------------------------------------------------------------------*/
1472extern THREAD_LOCAL u8int softfloat_detectTininess;
1473enum {
1474 softfloat_tininess_beforeRounding = 0,
1475 softfloat_tininess_afterRounding = 1
1476};
1477
1478/*----------------------------------------------------------------------------
1479| Software floating-point rounding mode. (Mode "odd" is supported only if
1480| SoftFloat is compiled with macro 'SOFTFLOAT_ROUND_ODD' defined.)
1481*----------------------------------------------------------------------------*/
1482extern THREAD_LOCAL u8int softfloat_roundingMode;
1483enum {
1484 softfloat_round_near_even = 0,
1485 softfloat_round_minMag = 1,
1486 softfloat_round_min = 2,
1487 softfloat_round_max = 3,
1488 softfloat_round_near_maxMag = 4,
1489 softfloat_round_odd = 6
1490};
1491
1492/*----------------------------------------------------------------------------
1493| Software floating-point exception flags.
1494*----------------------------------------------------------------------------*/
1495extern THREAD_LOCAL u8int softfloat_exceptionFlags;
1496typedef enum {
1497 softfloat_flag_inexact = 1,
1498 softfloat_flag_underflow = 2,
1499 softfloat_flag_overflow = 4,
1500 softfloat_flag_infinite = 8,
1501 softfloat_flag_invalid = 16
1502} exceptionFlag_t;
1503
1504/*----------------------------------------------------------------------------
1505| Routine to raise any or all of the software floating-point exception flags.
1506*----------------------------------------------------------------------------*/
1507void softfloat_raiseFlags( u8int );
1508
1509/*----------------------------------------------------------------------------
1510| Integer-to-floating-point conversion routines.
1511*----------------------------------------------------------------------------*/
1512float16_t ui32_to_f16( u32int );
1513float32_t ui32_to_f32( u32int );
1514float64_t ui32_to_f64( u32int );
1515#ifdef SOFTFLOAT_FAST_INT64
1516extFloat80_t ui32_to_extF80( u32int );
1517float128_t ui32_to_f128( u32int );
1518#endif
1519void ui32_to_extF80M( u32int, extFloat80_t * );
1520void ui32_to_f128M( u32int, float128_t * );
1521float16_t ui64_to_f16( u64int );
1522float32_t ui64_to_f32( u64int );
1523float64_t ui64_to_f64( u64int );
1524#ifdef SOFTFLOAT_FAST_INT64
1525extFloat80_t ui64_to_extF80( u64int );
1526float128_t ui64_to_f128( u64int );
1527#endif
1528void ui64_to_extF80M( u64int, extFloat80_t * );
1529void ui64_to_f128M( u64int, float128_t * );
1530float16_t i32_to_f16( s32int );
1531float32_t i32_to_f32( s32int );
1532float64_t i32_to_f64( s32int );
1533#ifdef SOFTFLOAT_FAST_INT64
1534extFloat80_t i32_to_extF80( s32int );
1535float128_t i32_to_f128( s32int );
1536#endif
1537void i32_to_extF80M( s32int, extFloat80_t * );
1538void i32_to_f128M( s32int, float128_t * );
1539float16_t i64_to_f16( s64int );
1540float32_t i64_to_f32( s64int );
1541float64_t i64_to_f64( s64int );
1542#ifdef SOFTFLOAT_FAST_INT64
1543extFloat80_t i64_to_extF80( s64int );
1544float128_t i64_to_f128( s64int );
1545#endif
1546void i64_to_extF80M( s64int, extFloat80_t * );
1547void i64_to_f128M( s64int, float128_t * );
1548
1549/*----------------------------------------------------------------------------
1550| 16-bit (half-precision) floating-point operations.
1551*----------------------------------------------------------------------------*/
1552u32int f16_to_ui32( float16_t, u8int, bool );
1553u64int f16_to_ui64( float16_t, u8int, bool );
1554s32int f16_to_i32( float16_t, u8int, bool );
1555s64int f16_to_i64( float16_t, u8int, bool );
1556u32int f16_to_ui32_r_minMag( float16_t, bool );
1557u64int f16_to_ui64_r_minMag( float16_t, bool );
1558s32int f16_to_i32_r_minMag( float16_t, bool );
1559s64int f16_to_i64_r_minMag( float16_t, bool );
1560float32_t f16_to_f32( float16_t );
1561float64_t f16_to_f64( float16_t );
1562#ifdef SOFTFLOAT_FAST_INT64
1563extFloat80_t f16_to_extF80( float16_t );
1564float128_t f16_to_f128( float16_t );
1565#endif
1566void f16_to_extF80M( float16_t, extFloat80_t * );
1567void f16_to_f128M( float16_t, float128_t * );
1568float16_t f16_roundToInt( float16_t, u8int, bool );
1569float16_t f16_add( float16_t, float16_t );
1570float16_t f16_sub( float16_t, float16_t );
1571float16_t f16_mul( float16_t, float16_t );
1572float16_t f16_mulAdd( float16_t, float16_t, float16_t );
1573float16_t f16_div( float16_t, float16_t );
1574float16_t f16_rem( float16_t, float16_t );
1575float16_t f16_sqrt( float16_t );
1576bool f16_eq( float16_t, float16_t );
1577bool f16_le( float16_t, float16_t );
1578bool f16_lt( float16_t, float16_t );
1579bool f16_eq_signaling( float16_t, float16_t );
1580bool f16_le_quiet( float16_t, float16_t );
1581bool f16_lt_quiet( float16_t, float16_t );
1582bool f16_isSignalingNaN( float16_t );
1583
1584/*----------------------------------------------------------------------------
1585| 16-bit (brain float 16) floating-point operations.
1586*----------------------------------------------------------------------------*/
1587float32_t bf16_to_f32( bfloat16_t );
1588bfloat16_t f32_to_bf16( float32_t );
1589bool bf16_isSignalingNaN( bfloat16_t );
1590
1591/*----------------------------------------------------------------------------
1592| 32-bit (single-precision) floating-point operations.
1593*----------------------------------------------------------------------------*/
1594u32int f32_to_ui32( float32_t, u8int, bool );
1595u64int f32_to_ui64( float32_t, u8int, bool );
1596s32int f32_to_i32( float32_t, u8int, bool );
1597s64int f32_to_i64( float32_t, u8int, bool );
1598u32int f32_to_ui32_r_minMag( float32_t, bool );
1599u64int f32_to_ui64_r_minMag( float32_t, bool );
1600s32int f32_to_i32_r_minMag( float32_t, bool );
1601s64int f32_to_i64_r_minMag( float32_t, bool );
1602float16_t f32_to_f16( float32_t );
1603float64_t f32_to_f64( float32_t );
1604#ifdef SOFTFLOAT_FAST_INT64
1605extFloat80_t f32_to_extF80( float32_t );
1606float128_t f32_to_f128( float32_t );
1607#endif
1608void f32_to_extF80M( float32_t, extFloat80_t * );66void f32_to_extF80M( float32_t, extFloat80_t * );
1609void f32_to_f128M( float32_t, float128_t * );
1610float32_t f32_roundToInt( float32_t, u8int, bool );
1611float32_t f32_add( float32_t, float32_t );
1612float32_t f32_sub( float32_t, float32_t );
1613float32_t f32_mul( float32_t, float32_t );
1614float32_t f32_mulAdd( float32_t, float32_t, float32_t );
1615float32_t f32_div( float32_t, float32_t );
1616float32_t f32_rem( float32_t, float32_t );
1617float32_t f32_sqrt( float32_t );
1618bool f32_eq( float32_t, float32_t );
1619bool f32_le( float32_t, float32_t );
1620bool f32_lt( float32_t, float32_t );
1621bool f32_eq_signaling( float32_t, float32_t );
1622bool f32_le_quiet( float32_t, float32_t );
1623bool f32_lt_quiet( float32_t, float32_t );
1624bool f32_isSignalingNaN( float32_t );
1625
1626/*----------------------------------------------------------------------------
1627| 64-bit (double-precision) floating-point operations.
1628*----------------------------------------------------------------------------*/
1629u32int f64_to_ui32( float64_t, u8int, bool );
1630u64int f64_to_ui64( float64_t, u8int, bool );
1631s32int f64_to_i32( float64_t, u8int, bool );
1632s64int f64_to_i64( float64_t, u8int, bool );
1633u32int f64_to_ui32_r_minMag( float64_t, bool );
1634u64int f64_to_ui64_r_minMag( float64_t, bool );
1635s32int f64_to_i32_r_minMag( float64_t, bool );
1636s64int f64_to_i64_r_minMag( float64_t, bool );
1637float16_t f64_to_f16( float64_t );
1638float32_t f64_to_f32( float64_t );
1639#ifdef SOFTFLOAT_FAST_INT64
1640extFloat80_t f64_to_extF80( float64_t );
1641float128_t f64_to_f128( float64_t );
1642#endif
1643void f64_to_extF80M( float64_t, extFloat80_t * );
1644void f64_to_f128M( float64_t, float128_t * );
1645float64_t f64_roundToInt( float64_t, u8int, bool );
1646float64_t f64_add( float64_t, float64_t );
1647float64_t f64_sub( float64_t, float64_t );
1648float64_t f64_mul( float64_t, float64_t );
1649float64_t f64_mulAdd( float64_t, float64_t, float64_t );
1650float64_t f64_div( float64_t, float64_t );
1651float64_t f64_rem( float64_t, float64_t );
1652float64_t f64_sqrt( float64_t );
1653bool f64_eq( float64_t, float64_t );
1654bool f64_le( float64_t, float64_t );
1655bool f64_lt( float64_t, float64_t );
1656bool f64_eq_signaling( float64_t, float64_t );
1657bool f64_le_quiet( float64_t, float64_t );
1658bool f64_lt_quiet( float64_t, float64_t );
1659bool f64_isSignalingNaN( float64_t );
1660
1661/*----------------------------------------------------------------------------
1662| Rounding precision for 80-bit extended double-precision floating-point.
1663| Valid values are 32, 64, and 80.
1664*----------------------------------------------------------------------------*/
1665extern THREAD_LOCAL u8int extF80_roundingPrecision;
1666
1667/*----------------------------------------------------------------------------
1668| 80-bit extended double-precision floating-point operations.
1669*----------------------------------------------------------------------------*/
1670#ifdef SOFTFLOAT_FAST_INT64
1671u32int extF80_to_ui32( extFloat80_t, u8int, bool );
1672u64int extF80_to_ui64( extFloat80_t, u8int, bool );
1673s32int extF80_to_i32( extFloat80_t, u8int, bool );
1674s64int extF80_to_i64( extFloat80_t, u8int, bool );
1675u32int extF80_to_ui32_r_minMag( extFloat80_t, bool );
1676u64int extF80_to_ui64_r_minMag( extFloat80_t, bool );
1677s32int extF80_to_i32_r_minMag( extFloat80_t, bool );
1678s64int extF80_to_i64_r_minMag( extFloat80_t, bool );
1679float16_t extF80_to_f16( extFloat80_t );
1680float32_t extF80_to_f32( extFloat80_t );
1681float64_t extF80_to_f64( extFloat80_t );
1682float128_t extF80_to_f128( extFloat80_t );
1683extFloat80_t extF80_roundToInt( extFloat80_t, u8int, bool );
1684extFloat80_t extF80_add( extFloat80_t, extFloat80_t );
1685extFloat80_t extF80_sub( extFloat80_t, extFloat80_t );
1686extFloat80_t extF80_mul( extFloat80_t, extFloat80_t );
1687extFloat80_t extF80_div( extFloat80_t, extFloat80_t );
1688extFloat80_t extF80_rem( extFloat80_t, extFloat80_t );
1689extFloat80_t extF80_sqrt( extFloat80_t );
1690bool extF80_eq( extFloat80_t, extFloat80_t );
1691bool extF80_le( extFloat80_t, extFloat80_t );
1692bool extF80_lt( extFloat80_t, extFloat80_t );
1693bool extF80_eq_signaling( extFloat80_t, extFloat80_t );
1694bool extF80_le_quiet( extFloat80_t, extFloat80_t );
1695bool extF80_lt_quiet( extFloat80_t, extFloat80_t );
1696bool extF80_isSignalingNaN( extFloat80_t );
1697#endif
1698u32int extF80M_to_ui32( const extFloat80_t *, u8int, bool );
1699u64int extF80M_to_ui64( const extFloat80_t *, u8int, bool );
1700s32int extF80M_to_i32( const extFloat80_t *, u8int, bool );
1701s64int extF80M_to_i64( const extFloat80_t *, u8int, bool );
1702u32int extF80M_to_ui32_r_minMag( const extFloat80_t *, bool );
1703u64int extF80M_to_ui64_r_minMag( const extFloat80_t *, bool );
1704s32int extF80M_to_i32_r_minMag( const extFloat80_t *, bool );
1705s64int extF80M_to_i64_r_minMag( const extFloat80_t *, bool );
1706float16_t extF80M_to_f16( const extFloat80_t * );
1707float32_t extF80M_to_f32( const extFloat80_t * );67float32_t extF80M_to_f32( const extFloat80_t * );
1708float64_t extF80M_to_f64( const extFloat80_t * );
1709void extF80M_to_f128M( const extFloat80_t *, float128_t * );
1710void
1711 extF80M_roundToInt(
1712 const extFloat80_t *, u8int, bool, extFloat80_t * );
1713void extF80M_add( const extFloat80_t *, const extFloat80_t *, extFloat80_t * );68void extF80M_add( const extFloat80_t *, const extFloat80_t *, extFloat80_t * );
1714void extF80M_sub( const extFloat80_t *, const extFloat80_t *, extFloat80_t * );
1715void extF80M_mul( const extFloat80_t *, const extFloat80_t *, extFloat80_t * );69void extF80M_mul( const extFloat80_t *, const extFloat80_t *, extFloat80_t * );
1716void extF80M_div( const extFloat80_t *, const extFloat80_t *, extFloat80_t * );
1717void extF80M_rem( const extFloat80_t *, const extFloat80_t *, extFloat80_t * );
1718void extF80M_sqrt( const extFloat80_t *, extFloat80_t * );
1719bool extF80M_eq( const extFloat80_t *, const extFloat80_t * );
1720bool extF80M_le( const extFloat80_t *, const extFloat80_t * );
1721bool extF80M_lt( const extFloat80_t *, const extFloat80_t * );
1722bool extF80M_eq_signaling( const extFloat80_t *, const extFloat80_t * );
1723bool extF80M_le_quiet( const extFloat80_t *, const extFloat80_t * );
1724bool extF80M_lt_quiet( const extFloat80_t *, const extFloat80_t * );
1725bool extF80M_isSignalingNaN( const extFloat80_t * );
1726
1727/*----------------------------------------------------------------------------
1728| 128-bit (quadruple-precision) floating-point operations.
1729*----------------------------------------------------------------------------*/
1730#ifdef SOFTFLOAT_FAST_INT64
1731u32int f128_to_ui32( float128_t, u8int, bool );
1732u64int f128_to_ui64( float128_t, u8int, bool );
1733s32int f128_to_i32( float128_t, u8int, bool );
1734s64int f128_to_i64( float128_t, u8int, bool );
1735u32int f128_to_ui32_r_minMag( float128_t, bool );
1736u64int f128_to_ui64_r_minMag( float128_t, bool );
1737s32int f128_to_i32_r_minMag( float128_t, bool );
1738s64int f128_to_i64_r_minMag( float128_t, bool );
1739float16_t f128_to_f16( float128_t );
1740float32_t f128_to_f32( float128_t );
1741float64_t f128_to_f64( float128_t );
1742extFloat80_t f128_to_extF80( float128_t );
1743float128_t f128_roundToInt( float128_t, u8int, bool );
1744float128_t f128_add( float128_t, float128_t );
1745float128_t f128_sub( float128_t, float128_t );
1746float128_t f128_mul( float128_t, float128_t );
1747float128_t f128_mulAdd( float128_t, float128_t, float128_t );
1748float128_t f128_div( float128_t, float128_t );
1749float128_t f128_rem( float128_t, float128_t );
1750float128_t f128_sqrt( float128_t );
1751bool f128_eq( float128_t, float128_t );
1752bool f128_le( float128_t, float128_t );
1753bool f128_lt( float128_t, float128_t );
1754bool f128_eq_signaling( float128_t, float128_t );
1755bool f128_le_quiet( float128_t, float128_t );
1756bool f128_lt_quiet( float128_t, float128_t );
1757bool f128_isSignalingNaN( float128_t );
1758#endif
1759u32int f128M_to_ui32( const float128_t *, u8int, bool );
1760u64int f128M_to_ui64( const float128_t *, u8int, bool );
1761s32int f128M_to_i32( const float128_t *, u8int, bool );
1762s64int f128M_to_i64( const float128_t *, u8int, bool );
1763u32int f128M_to_ui32_r_minMag( const float128_t *, bool );
1764u64int f128M_to_ui64_r_minMag( const float128_t *, bool );
1765s32int f128M_to_i32_r_minMag( const float128_t *, bool );
1766s64int f128M_to_i64_r_minMag( const float128_t *, bool );
1767float16_t f128M_to_f16( const float128_t * );
1768float32_t f128M_to_f32( const float128_t * );
1769float64_t f128M_to_f64( const float128_t * );
1770void f128M_to_extF80M( const float128_t *, extFloat80_t * );
1771void f128M_roundToInt( const float128_t *, u8int, bool, float128_t * );
1772void f128M_add( const float128_t *, const float128_t *, float128_t * );
1773void f128M_sub( const float128_t *, const float128_t *, float128_t * );
1774void f128M_mul( const float128_t *, const float128_t *, float128_t * );
1775void
1776 f128M_mulAdd(
1777 const float128_t *, const float128_t *, const float128_t *, float128_t *
1778 );
1779void f128M_div( const float128_t *, const float128_t *, float128_t * );
1780void f128M_rem( const float128_t *, const float128_t *, float128_t * );
1781void f128M_sqrt( const float128_t *, float128_t * );
1782bool f128M_eq( const float128_t *, const float128_t * );
1783bool f128M_le( const float128_t *, const float128_t * );
1784bool f128M_lt( const float128_t *, const float128_t * );
1785bool f128M_eq_signaling( const float128_t *, const float128_t * );
1786bool f128M_le_quiet( const float128_t *, const float128_t * );
1787bool f128M_lt_quiet( const float128_t *, const float128_t * );
1788bool f128M_isSignalingNaN( const float128_t * );
1789
1790/*----------------------------------------------------------------------------
1791| Default value for 'softfloat_detectTininess'.
1792*----------------------------------------------------------------------------*/
1793#define init_detectTininess softfloat_tininess_afterRounding
1794
1795/*----------------------------------------------------------------------------
1796| The values to return on conversions to 32-bit integer formats that raise an
1797| invalid exception.
1798*----------------------------------------------------------------------------*/
1799#define ui32_fromPosOverflow 0xFFFFFFFF
1800#define ui32_fromNegOverflow 0xFFFFFFFF
1801#define ui32_fromNaN 0xFFFFFFFF
1802#define i32_fromPosOverflow (-0x7FFFFFFF - 1)
1803#define i32_fromNegOverflow (-0x7FFFFFFF - 1)
1804#define i32_fromNaN (-0x7FFFFFFF - 1)
1805
1806/*----------------------------------------------------------------------------
1807| The values to return on conversions to 64-bit integer formats that raise an
1808| invalid exception.
1809*----------------------------------------------------------------------------*/
1810#define ui64_fromPosOverflow UINT64_C( 0xFFFFFFFFFFFFFFFF )
1811#define ui64_fromNegOverflow UINT64_C( 0xFFFFFFFFFFFFFFFF )
1812#define ui64_fromNaN UINT64_C( 0xFFFFFFFFFFFFFFFF )
1813#define i64_fromPosOverflow (-INT64_C( 0x7FFFFFFFFFFFFFFF ) - 1)
1814#define i64_fromNegOverflow (-INT64_C( 0x7FFFFFFFFFFFFFFF ) - 1)
1815#define i64_fromNaN (-INT64_C( 0x7FFFFFFFFFFFFFFF ) - 1)
1816
1817/*----------------------------------------------------------------------------
1818| "Common NaN" structure, used to transfer NaN representations from one format
1819| to another.
1820*----------------------------------------------------------------------------*/
1821struct commonNaN {
1822 bool sign;
1823#ifdef LITTLEENDIAN
1824 u64int v0, v64;
1825#else
1826 u64int v64, v0;
1827#endif
1828};
1829
1830/*----------------------------------------------------------------------------
1831| The bit pattern for a default generated 16-bit floating-point NaN.
1832*----------------------------------------------------------------------------*/
1833#define defaultNaNF16UI 0xFE00
1834
1835/*----------------------------------------------------------------------------
1836| Returns true when 16-bit unsigned integer 'uiA' has the bit pattern of a
1837| 16-bit floating-point signaling NaN.
1838| Note: This macro evaluates its argument more than once.
1839*----------------------------------------------------------------------------*/
1840#define softfloat_isSigNaNF16UI( uiA ) ((((uiA) & 0x7E00) == 0x7C00) && ((uiA) & 0x01FF))
1841
1842/*----------------------------------------------------------------------------
1843| Assuming 'uiA' has the bit pattern of a 16-bit floating-point NaN, converts
1844| this NaN to the common NaN form, and stores the resulting common NaN at the
1845| location pointed to by 'zPtr'. If the NaN is a signaling NaN, the invalid
1846| exception is raised.
1847*----------------------------------------------------------------------------*/
1848void softfloat_f16UIToCommonNaN( u16int uiA, struct commonNaN *zPtr );
1849
1850/*----------------------------------------------------------------------------
1851| Converts the common NaN pointed to by 'aPtr' into a 16-bit floating-point
1852| NaN, and returns the bit pattern of this value as an unsigned integer.
1853*----------------------------------------------------------------------------*/
1854u16int softfloat_commonNaNToF16UI( const struct commonNaN *aPtr );
1855
1856/*----------------------------------------------------------------------------
1857| Interpreting 'uiA' and 'uiB' as the bit patterns of two 16-bit floating-
1858| point values, at least one of which is a NaN, returns the bit pattern of
1859| the combined NaN result. If either 'uiA' or 'uiB' has the pattern of a
1860| signaling NaN, the invalid exception is raised.
1861*----------------------------------------------------------------------------*/
1862u16int
1863 softfloat_propagateNaNF16UI( u16int uiA, u16int uiB );
1864
1865/*----------------------------------------------------------------------------
1866| The bit pattern for a default generated 32-bit floating-point NaN.
1867*----------------------------------------------------------------------------*/
1868#define defaultNaNF32UI 0xFFC00000
1869
1870/*----------------------------------------------------------------------------
1871| Returns true when 32-bit unsigned integer 'uiA' has the bit pattern of a
1872| 32-bit floating-point signaling NaN.
1873| Note: This macro evaluates its argument more than once.
1874*----------------------------------------------------------------------------*/
1875#define softfloat_isSigNaNF32UI( uiA ) ((((uiA) & 0x7FC00000) == 0x7F800000) && ((uiA) & 0x003FFFFF))
1876
1877/*----------------------------------------------------------------------------
1878| Assuming 'uiA' has the bit pattern of a 32-bit floating-point NaN, converts
1879| this NaN to the common NaN form, and stores the resulting common NaN at the
1880| location pointed to by 'zPtr'. If the NaN is a signaling NaN, the invalid
1881| exception is raised.
1882*----------------------------------------------------------------------------*/
1883void softfloat_f32UIToCommonNaN( u32int uiA, struct commonNaN *zPtr );
1884
1885/*----------------------------------------------------------------------------
1886| Converts the common NaN pointed to by 'aPtr' into a 32-bit floating-point
1887| NaN, and returns the bit pattern of this value as an unsigned integer.
1888*----------------------------------------------------------------------------*/
1889u32int softfloat_commonNaNToF32UI( const struct commonNaN *aPtr );
1890
1891/*----------------------------------------------------------------------------
1892| Interpreting 'uiA' and 'uiB' as the bit patterns of two 32-bit floating-
1893| point values, at least one of which is a NaN, returns the bit pattern of
1894| the combined NaN result. If either 'uiA' or 'uiB' has the pattern of a
1895| signaling NaN, the invalid exception is raised.
1896*----------------------------------------------------------------------------*/
1897u32int
1898 softfloat_propagateNaNF32UI( u32int uiA, u32int uiB );
1899
1900/*----------------------------------------------------------------------------
1901| The bit pattern for a default generated 64-bit floating-point NaN.
1902*----------------------------------------------------------------------------*/
1903#define defaultNaNF64UI UINT64_C( 0xFFF8000000000000 )
1904
1905/*----------------------------------------------------------------------------
1906| Returns true when 64-bit unsigned integer 'uiA' has the bit pattern of a
1907| 64-bit floating-point signaling NaN.
1908| Note: This macro evaluates its argument more than once.
1909*----------------------------------------------------------------------------*/
1910#define softfloat_isSigNaNF64UI( uiA ) ((((uiA) & UINT64_C( 0x7FF8000000000000 )) == UINT64_C( 0x7FF0000000000000 )) && ((uiA) & UINT64_C( 0x0007FFFFFFFFFFFF )))
1911
1912/*----------------------------------------------------------------------------
1913| Assuming 'uiA' has the bit pattern of a 64-bit floating-point NaN, converts
1914| this NaN to the common NaN form, and stores the resulting common NaN at the
1915| location pointed to by 'zPtr'. If the NaN is a signaling NaN, the invalid
1916| exception is raised.
1917*----------------------------------------------------------------------------*/
1918void softfloat_f64UIToCommonNaN( u64int uiA, struct commonNaN *zPtr );
1919
1920/*----------------------------------------------------------------------------
1921| Converts the common NaN pointed to by 'aPtr' into a 64-bit floating-point
1922| NaN, and returns the bit pattern of this value as an unsigned integer.
1923*----------------------------------------------------------------------------*/
1924u64int softfloat_commonNaNToF64UI( const struct commonNaN *aPtr );
1925
1926/*----------------------------------------------------------------------------
1927| Interpreting 'uiA' and 'uiB' as the bit patterns of two 64-bit floating-
1928| point values, at least one of which is a NaN, returns the bit pattern of
1929| the combined NaN result. If either 'uiA' or 'uiB' has the pattern of a
1930| signaling NaN, the invalid exception is raised.
1931*----------------------------------------------------------------------------*/
1932u64int
1933 softfloat_propagateNaNF64UI( u64int uiA, u64int uiB );
1934
1935/*----------------------------------------------------------------------------
1936| The bit pattern for a default generated 80-bit extended floating-point NaN.
1937*----------------------------------------------------------------------------*/
1938#define defaultNaNExtF80UI64 0xFFFF
1939#define defaultNaNExtF80UI0 UINT64_C( 0xC000000000000000 )
1940
1941/*----------------------------------------------------------------------------
1942| Returns true when the 80-bit unsigned integer formed from concatenating
1943| 16-bit 'uiA64' and 64-bit 'uiA0' has the bit pattern of an 80-bit extended
1944| floating-point signaling NaN.
1945| Note: This macro evaluates its arguments more than once.
1946*----------------------------------------------------------------------------*/
1947#define softfloat_isSigNaNExtF80UI( uiA64, uiA0 ) ((((uiA64) & 0x7FFF) == 0x7FFF) && ! ((uiA0) & UINT64_C( 0x4000000000000000 )) && ((uiA0) & UINT64_C( 0x3FFFFFFFFFFFFFFF )))
1948
1949#ifdef SOFTFLOAT_FAST_INT64
1950
1951/*----------------------------------------------------------------------------
1952| The following functions are needed only when 'SOFTFLOAT_FAST_INT64' is
1953| defined.
1954*----------------------------------------------------------------------------*/
1955
1956/*----------------------------------------------------------------------------
1957| Assuming the unsigned integer formed from concatenating 'uiA64' and 'uiA0'
1958| has the bit pattern of an 80-bit extended floating-point NaN, converts
1959| this NaN to the common NaN form, and stores the resulting common NaN at the
1960| location pointed to by 'zPtr'. If the NaN is a signaling NaN, the invalid
1961| exception is raised.
1962*----------------------------------------------------------------------------*/
1963void
1964 softfloat_extF80UIToCommonNaN(
1965 u16int uiA64, u64int uiA0, struct commonNaN *zPtr );
1966
1967/*----------------------------------------------------------------------------
1968| Converts the common NaN pointed to by 'aPtr' into an 80-bit extended
1969| floating-point NaN, and returns the bit pattern of this value as an unsigned
1970| integer.
1971*----------------------------------------------------------------------------*/
1972struct uint128 softfloat_commonNaNToExtF80UI( const struct commonNaN *aPtr );
1973
1974/*----------------------------------------------------------------------------
1975| Interpreting the unsigned integer formed from concatenating 'uiA64' and
1976| 'uiA0' as an 80-bit extended floating-point value, and likewise interpreting
1977| the unsigned integer formed from concatenating 'uiB64' and 'uiB0' as another
1978| 80-bit extended floating-point value, and assuming at least on of these
1979| floating-point values is a NaN, returns the bit pattern of the combined NaN
1980| result. If either original floating-point value is a signaling NaN, the
1981| invalid exception is raised.
1982*----------------------------------------------------------------------------*/
1983struct uint128
1984 softfloat_propagateNaNExtF80UI(
1985 u16int uiA64,
1986 u64int uiA0,
1987 u16int uiB64,
1988 u64int uiB0
1989 );
1990
1991/*----------------------------------------------------------------------------
1992| The bit pattern for a default generated 128-bit floating-point NaN.
1993*----------------------------------------------------------------------------*/
1994#define defaultNaNF128UI64 UINT64_C( 0xFFFF800000000000 )
1995#define defaultNaNF128UI0 UINT64_C( 0 )
1996
1997/*----------------------------------------------------------------------------
1998| Returns true when the 128-bit unsigned integer formed from concatenating
1999| 64-bit 'uiA64' and 64-bit 'uiA0' has the bit pattern of a 128-bit floating-
2000| point signaling NaN.
2001| Note: This macro evaluates its arguments more than once.
2002*----------------------------------------------------------------------------*/
2003#define softfloat_isSigNaNF128UI( uiA64, uiA0 ) ((((uiA64) & UINT64_C( 0x7FFF800000000000 )) == UINT64_C( 0x7FFF000000000000 )) && ((uiA0) || ((uiA64) & UINT64_C( 0x00007FFFFFFFFFFF ))))
2004
2005/*----------------------------------------------------------------------------
2006| Assuming the unsigned integer formed from concatenating 'uiA64' and 'uiA0'
2007| has the bit pattern of a 128-bit floating-point NaN, converts this NaN to
2008| the common NaN form, and stores the resulting common NaN at the location
2009| pointed to by 'zPtr'. If the NaN is a signaling NaN, the invalid exception
2010| is raised.
2011*----------------------------------------------------------------------------*/
2012void
2013 softfloat_f128UIToCommonNaN(
2014 u64int uiA64, u64int uiA0, struct commonNaN *zPtr );
2015
2016/*----------------------------------------------------------------------------
2017| Converts the common NaN pointed to by 'aPtr' into a 128-bit floating-point
2018| NaN, and returns the bit pattern of this value as an unsigned integer.
2019*----------------------------------------------------------------------------*/
2020struct uint128 softfloat_commonNaNToF128UI( const struct commonNaN * );
2021
2022/*----------------------------------------------------------------------------
2023| Interpreting the unsigned integer formed from concatenating 'uiA64' and
2024| 'uiA0' as a 128-bit floating-point value, and likewise interpreting the
2025| unsigned integer formed from concatenating 'uiB64' and 'uiB0' as another
2026| 128-bit floating-point value, and assuming at least on of these floating-
2027| point values is a NaN, returns the bit pattern of the combined NaN result.
2028| If either original floating-point value is a signaling NaN, the invalid
2029| exception is raised.
2030*----------------------------------------------------------------------------*/
2031struct uint128
2032 softfloat_propagateNaNF128UI(
2033 u64int uiA64,
2034 u64int uiA0,
2035 u64int uiB64,
2036 u64int uiB0
2037 );
2038
2039#else
2040
2041/*----------------------------------------------------------------------------
2042| The following functions are needed only when 'SOFTFLOAT_FAST_INT64' is not
2043| defined.
2044*----------------------------------------------------------------------------*/
2045
2046/*----------------------------------------------------------------------------
2047| Assuming the 80-bit extended floating-point value pointed to by 'aSPtr' is
2048| a NaN, converts this NaN to the common NaN form, and stores the resulting
2049| common NaN at the location pointed to by 'zPtr'. If the NaN is a signaling
2050| NaN, the invalid exception is raised.
2051*----------------------------------------------------------------------------*/
2052void
2053 softfloat_extF80MToCommonNaN(
2054 const struct extFloat80M *aSPtr, struct commonNaN *zPtr );
2055
2056/*----------------------------------------------------------------------------
2057| Converts the common NaN pointed to by 'aPtr' into an 80-bit extended
2058| floating-point NaN, and stores this NaN at the location pointed to by
2059| 'zSPtr'.
2060*----------------------------------------------------------------------------*/
2061void
2062 softfloat_commonNaNToExtF80M(
2063 const struct commonNaN *aPtr, struct extFloat80M *zSPtr );
2064
2065/*----------------------------------------------------------------------------
2066| Assuming at least one of the two 80-bit extended floating-point values
2067| pointed to by 'aSPtr' and 'bSPtr' is a NaN, stores the combined NaN result
2068| at the location pointed to by 'zSPtr'. If either original floating-point
2069| value is a signaling NaN, the invalid exception is raised.
2070*----------------------------------------------------------------------------*/
2071void
2072 softfloat_propagateNaNExtF80M(
2073 const struct extFloat80M *aSPtr,
2074 const struct extFloat80M *bSPtr,
2075 struct extFloat80M *zSPtr
2076 );
2077
2078/*----------------------------------------------------------------------------
2079| The bit pattern for a default generated 128-bit floating-point NaN.
2080*----------------------------------------------------------------------------*/
2081#define defaultNaNF128UI96 0xFFFF8000
2082#define defaultNaNF128UI64 0
2083#define defaultNaNF128UI32 0
2084#define defaultNaNF128UI0 0
2085
2086/*----------------------------------------------------------------------------
2087| Assuming the 128-bit floating-point value pointed to by 'aWPtr' is a NaN,
2088| converts this NaN to the common NaN form, and stores the resulting common
2089| NaN at the location pointed to by 'zPtr'. If the NaN is a signaling NaN,
2090| the invalid exception is raised. Argument 'aWPtr' points to an array of
2091| four 32-bit elements that concatenate in the platform's normal endian order
2092| to form a 128-bit floating-point value.
2093*----------------------------------------------------------------------------*/
2094void
2095 softfloat_f128MToCommonNaN( const u32int *aWPtr, struct commonNaN *zPtr );
2096
2097/*----------------------------------------------------------------------------
2098| Converts the common NaN pointed to by 'aPtr' into a 128-bit floating-point
2099| NaN, and stores this NaN at the location pointed to by 'zWPtr'. Argument
2100| 'zWPtr' points to an array of four 32-bit elements that concatenate in the
2101| platform's normal endian order to form a 128-bit floating-point value.
2102*----------------------------------------------------------------------------*/
2103void
2104 softfloat_commonNaNToF128M( const struct commonNaN *aPtr, u32int *zWPtr );
2105
2106/*----------------------------------------------------------------------------
2107| Assuming at least one of the two 128-bit floating-point values pointed to by
2108| 'aWPtr' and 'bWPtr' is a NaN, stores the combined NaN result at the location
2109| pointed to by 'zWPtr'. If either original floating-point value is a
2110| signaling NaN, the invalid exception is raised. Each of 'aWPtr', 'bWPtr',
2111| and 'zWPtr' points to an array of four 32-bit elements that concatenate in
2112| the platform's normal endian order to form a 128-bit floating-point value.
2113*----------------------------------------------------------------------------*/
2114void
2115 softfloat_propagateNaNF128M(
2116 const u32int *aWPtr, const u32int *bWPtr, u32int *zWPtr );
2117
2118#endif

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t