@@ -111,12 +111,12 @@ typedef int64_t int64;
111
111
/*----------------------------------------------------------------------------
112
112
| Software IEC/IEEE floating-point ordering relations
113
113
*----------------------------------------------------------------------------*/
114
- enum {
114
+ typedef enum {
115
115
float_relation_less = -1 ,
116
116
float_relation_equal = 0 ,
117
117
float_relation_greater = 1 ,
118
118
float_relation_unordered = 2
119
- };
119
+ } FloatRelation ;
120
120
121
121
/*----------------------------------------------------------------------------
122
122
| Software IEC/IEEE floating-point types.
@@ -187,13 +187,18 @@ enum {
187
187
/*----------------------------------------------------------------------------
188
188
| Software IEC/IEEE floating-point rounding mode.
189
189
*----------------------------------------------------------------------------*/
190
- enum {
190
+
191
+ typedef enum __attribute__ ((__packed__ )) {
191
192
float_round_nearest_even = 0 ,
192
193
float_round_down = 1 ,
193
194
float_round_up = 2 ,
194
195
float_round_to_zero = 3 ,
195
196
float_round_ties_away = 4 ,
196
- };
197
+ /* Not an IEEE rounding mode: round to closest odd, overflow to max */
198
+ float_round_to_odd = 5 ,
199
+ /* Not an IEEE rounding mode: round to closest odd, overflow to inf */
200
+ float_round_to_odd_inf = 6 ,
201
+ } FloatRoundMode ;
197
202
198
203
/*----------------------------------------------------------------------------
199
204
| Software IEC/IEEE floating-point exception flags.
@@ -208,6 +213,15 @@ enum {
208
213
float_flag_output_denormal = 128
209
214
};
210
215
216
+ /*
217
+ * Rounding precision for floatx80.
218
+ */
219
+ typedef enum __attribute__ ((__packed__ )) {
220
+ floatx80_precision_x ,
221
+ floatx80_precision_d ,
222
+ floatx80_precision_s ,
223
+ } FloatX80RoundPrec ;
224
+
211
225
typedef struct float_status {
212
226
signed char float_detect_tininess ;
213
227
signed char float_rounding_mode ;
@@ -628,6 +642,7 @@ int floatx80_is_quiet_nan( floatx80 );
628
642
int floatx80_is_signaling_nan ( floatx80 );
629
643
floatx80 floatx80_maybe_silence_nan ( floatx80 );
630
644
floatx80 floatx80_scalbn (floatx80 , int , float_status * status );
645
+ floatx80 floatx80_silence_nan ( floatx80 );
631
646
632
647
static inline floatx80 floatx80_abs (floatx80 a )
633
648
{
@@ -666,17 +681,116 @@ static inline int floatx80_is_any_nan(floatx80 a)
666
681
return ((a .high & 0x7fff ) == 0x7fff ) && (a .low <<1 );
667
682
}
668
683
684
+ /*----------------------------------------------------------------------------
685
+ | Return whether the given value is an invalid floatx80 encoding.
686
+ | Invalid floatx80 encodings arise when the integer bit is not set, but
687
+ | the exponent is not zero. The only times the integer bit is permitted to
688
+ | be zero is in subnormal numbers and the value zero.
689
+ | This includes what the Intel software developer's manual calls pseudo-NaNs,
690
+ | pseudo-infinities and un-normal numbers. It does not include
691
+ | pseudo-denormals, which must still be correctly handled as inputs even
692
+ | if they are never generated as outputs.
693
+ *----------------------------------------------------------------------------*/
694
+ static inline bool floatx80_invalid_encoding (floatx80 a )
695
+ {
696
+ #if defined(TARGET_M68K )
697
+ /*-------------------------------------------------------------------------
698
+ | With m68k, the explicit integer bit can be zero in the case of:
699
+ | - zeros (exp == 0, mantissa == 0)
700
+ | - denormalized numbers (exp == 0, mantissa != 0)
701
+ | - unnormalized numbers (exp != 0, exp < 0x7FFF)
702
+ | - infinities (exp == 0x7FFF, mantissa == 0)
703
+ | - not-a-numbers (exp == 0x7FFF, mantissa != 0)
704
+ |
705
+ | For infinities and NaNs, the explicit integer bit can be either one or
706
+ | zero.
707
+ |
708
+ | The IEEE 754 standard does not define a zero integer bit. Such a number
709
+ | is an unnormalized number. Hardware does not directly support
710
+ | denormalized and unnormalized numbers, but implicitly supports them by
711
+ | trapping them as unimplemented data types, allowing efficient conversion
712
+ | in software.
713
+ |
714
+ | See "M68000 FAMILY PROGRAMMER’S REFERENCE MANUAL",
715
+ | "1.6 FLOATING-POINT DATA TYPES"
716
+ *------------------------------------------------------------------------*/
717
+ return false;
718
+ #else
719
+ return (a .low & (1ULL << 63 )) == 0 && (a .high & 0x7FFF ) != 0 ;
720
+ #endif
721
+ }
722
+
669
723
#define floatx80_zero make_floatx80(0x0000, 0x0000000000000000LL)
670
724
#define floatx80_one make_floatx80(0x3fff, 0x8000000000000000LL)
671
725
#define floatx80_ln2 make_floatx80(0x3ffe, 0xb17217f7d1cf79acLL)
672
726
#define floatx80_pi make_floatx80(0x4000, 0xc90fdaa22168c235LL)
673
727
#define floatx80_half make_floatx80(0x3ffe, 0x8000000000000000LL)
674
728
#define floatx80_infinity make_floatx80(0x7fff, 0x8000000000000000LL)
675
729
730
+ /*----------------------------------------------------------------------------
731
+ | Returns the fraction bits of the extended double-precision floating-point
732
+ | value `a'.
733
+ *----------------------------------------------------------------------------*/
734
+
735
+ inline uint64_t extractFloatx80Frac ( floatx80 a )
736
+ {
737
+
738
+ return a .low ;
739
+
740
+ }
741
+
742
+ /*----------------------------------------------------------------------------
743
+ | Returns the exponent bits of the extended double-precision floating-point
744
+ | value `a'.
745
+ *----------------------------------------------------------------------------*/
746
+
747
+ inline int32 extractFloatx80Exp ( floatx80 a )
748
+ {
749
+
750
+ return a .high & 0x7FFF ;
751
+
752
+ }
753
+
754
+ /*----------------------------------------------------------------------------
755
+ | Returns the sign bit of the extended double-precision floating-point value
756
+ | `a'.
757
+ *----------------------------------------------------------------------------*/
758
+
759
+ inline flag extractFloatx80Sign ( floatx80 a )
760
+ {
761
+
762
+ return a .high >>15 ;
763
+
764
+ }
765
+
766
+ /*----------------------------------------------------------------------------
767
+ | Takes an abstract floating-point value having sign `zSign', exponent
768
+ | `zExp', and significand formed by the concatenation of `zSig0' and `zSig1',
769
+ | and returns the proper extended double-precision floating-point value
770
+ | corresponding to the abstract input. This routine is just like
771
+ | `roundAndPackFloatx80' except that the input significand does not have to be
772
+ | normalized.
773
+ *----------------------------------------------------------------------------*/
774
+
775
+ floatx80 normalizeRoundAndPackFloatx80 (int8 roundingPrecision ,
776
+ flag zSign , int32 zExp ,
777
+ uint64_t zSig0 , uint64_t zSig1 ,
778
+ float_status * status );
779
+
780
+ /*----------------------------------------------------------------------------
781
+ | Normalizes the subnormal extended double-precision floating-point value
782
+ | represented by the denormalized significand `aSig'. The normalized exponent
783
+ | and significand are stored at the locations pointed to by `zExpPtr' and
784
+ | `zSigPtr', respectively.
785
+ *----------------------------------------------------------------------------*/
786
+
787
+ void normalizeFloatx80Subnormal (uint64_t aSig , int32_t * zExpPtr ,
788
+ uint64_t * zSigPtr );
789
+
676
790
/*----------------------------------------------------------------------------
677
791
| The pattern for a default generated extended double-precision NaN.
678
792
*----------------------------------------------------------------------------*/
679
- extern const floatx80 floatx80_default_nan ;
793
+ floatx80 floatx80_default_nan ( float_status * status ) ;
680
794
681
795
/*----------------------------------------------------------------------------
682
796
| Software IEC/IEEE quadruple-precision conversion routines.
0 commit comments