1 #ifndef TESTFLOAT_SPARC64_SOFTFLOAT_H 2 #define TESTFLOAT_SPARC64_SOFTFLOAT_H 3 4 /*============================================================================ 5 6 This C header file is part of the SoftFloat IEC/IEEE Floating-point Arithmetic 7 Package, Release 2b. 8 9 Written by John R. Hauser. This work was made possible in part by the 10 International Computer Science Institute, located at Suite 600, 1947 Center 11 Street, Berkeley, California 94704. Funding was partially provided by the 12 National Science Foundation under grant MIP-9311980. The original version 13 of this code was written as part of a project to build a fixed-point vector 14 processor in collaboration with the University of California at Berkeley, 15 overseen by Profs. Nelson Morgan and John Wawrzynek. More information 16 is available through the Web page `http://www.cs.berkeley.edu/~jhauser/ 17 arithmetic/SoftFloat.html'. 18 19 THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort has 20 been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT TIMES 21 RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO PERSONS 22 AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ALL LOSSES, 23 COSTS, OR OTHER PROBLEMS THEY INCUR DUE TO THE SOFTWARE, AND WHO FURTHERMORE 24 EFFECTIVELY INDEMNIFY JOHN HAUSER AND THE INTERNATIONAL COMPUTER SCIENCE 25 INSTITUTE (possibly via similar legal warning) AGAINST ALL LOSSES, COSTS, OR 26 OTHER PROBLEMS INCURRED BY THEIR CUSTOMERS AND CLIENTS DUE TO THE SOFTWARE. 27 28 Derivative works are acceptable, even for commercial purposes, so long as 29 (1) the source code for the derivative work includes prominent notice that 30 the work is derivative, and (2) the source code includes prominent notice with 31 these four paragraphs for those parts of this code that are retained. 32 33 =============================================================================*/ 34 35 /* $FreeBSD$ */ 36 37 #include <machine/ieeefp.h> 38 39 /*---------------------------------------------------------------------------- 40 | The macro `FLOATX80' must be defined to enable the extended double-precision 41 | floating-point format `floatx80'. If this macro is not defined, the 42 | `floatx80' type will not be defined, and none of the functions that either 43 | input or output the `floatx80' type will be defined. The same applies to 44 | the `FLOAT128' macro and the quadruple-precision format `float128'. 45 *----------------------------------------------------------------------------*/ 46 #define FLOATX80 47 #define FLOAT128 48 49 /*---------------------------------------------------------------------------- 50 | Software IEC/IEEE floating-point types. 51 *----------------------------------------------------------------------------*/ 52 typedef unsigned int float32; 53 typedef unsigned long float64; 54 #ifdef FLOATX80 55 typedef struct { 56 unsigned short high; 57 unsigned long low; 58 } floatx80; 59 #endif 60 #ifdef FLOAT128 61 typedef struct { 62 unsigned long high, low; 63 } float128; 64 #endif 65 66 /*---------------------------------------------------------------------------- 67 | Software IEC/IEEE floating-point underflow tininess-detection mode. 68 *----------------------------------------------------------------------------*/ 69 extern int float_detect_tininess; 70 enum { 71 float_tininess_after_rounding = 0, 72 float_tininess_before_rounding = 1 73 }; 74 75 /*---------------------------------------------------------------------------- 76 | Software IEC/IEEE floating-point rounding mode. 77 *----------------------------------------------------------------------------*/ 78 extern fp_rnd_t float_rounding_mode; 79 enum { 80 float_round_nearest_even = 0, 81 float_round_to_zero = 1, 82 float_round_up = 2, 83 float_round_down = 3 84 }; 85 86 /*---------------------------------------------------------------------------- 87 | Software IEC/IEEE floating-point exception flags. 88 *----------------------------------------------------------------------------*/ 89 typedef int fp_except; 90 extern fp_except float_exception_flags; 91 enum { 92 float_flag_inexact = 1, 93 float_flag_divbyzero = 2, 94 float_flag_underflow = 4, 95 float_flag_overflow = 8, 96 float_flag_invalid = 16 97 }; 98 99 /*---------------------------------------------------------------------------- 100 | Routine to raise any or all of the software IEC/IEEE floating-point 101 | exception flags. 102 *----------------------------------------------------------------------------*/ 103 void float_raise( int ); 104 105 /*---------------------------------------------------------------------------- 106 | Software IEC/IEEE integer-to-floating-point conversion routines. 107 *----------------------------------------------------------------------------*/ 108 float32 int32_to_float32( int ); 109 float64 int32_to_float64( int ); 110 #ifdef FLOATX80 111 floatx80 int32_to_floatx80( int ); 112 #endif 113 #ifdef FLOAT128 114 float128 int32_to_float128( int ); 115 #endif 116 float32 int64_to_float32( long ); 117 float64 int64_to_float64( long ); 118 #ifdef FLOATX80 119 floatx80 int64_to_floatx80( long ); 120 #endif 121 #ifdef FLOAT128 122 float128 int64_to_float128( long ); 123 #endif 124 125 /*---------------------------------------------------------------------------- 126 | Software IEC/IEEE single-precision conversion routines. 127 *----------------------------------------------------------------------------*/ 128 int float32_to_int32( float32 ); 129 int float32_to_int32_round_to_zero( float32 ); 130 long float32_to_int64( float32 ); 131 long float32_to_int64_round_to_zero( float32 ); 132 float64 float32_to_float64( float32 ); 133 #ifdef FLOATX80 134 floatx80 float32_to_floatx80( float32 ); 135 #endif 136 #ifdef FLOAT128 137 float128 float32_to_float128( float32 ); 138 #endif 139 140 /*---------------------------------------------------------------------------- 141 | Software IEC/IEEE single-precision operations. 142 *----------------------------------------------------------------------------*/ 143 float32 float32_round_to_int( float32 ); 144 float32 float32_add( float32, float32 ); 145 float32 float32_sub( float32, float32 ); 146 float32 float32_mul( float32, float32 ); 147 float32 float32_div( float32, float32 ); 148 float32 float32_rem( float32, float32 ); 149 float32 float32_sqrt( float32 ); 150 int float32_eq( float32, float32 ); 151 int float32_le( float32, float32 ); 152 int float32_lt( float32, float32 ); 153 int float32_eq_signaling( float32, float32 ); 154 int float32_le_quiet( float32, float32 ); 155 int float32_lt_quiet( float32, float32 ); 156 int float32_is_signaling_nan( float32 ); 157 158 /*---------------------------------------------------------------------------- 159 | Software IEC/IEEE double-precision conversion routines. 160 *----------------------------------------------------------------------------*/ 161 int float64_to_int32( float64 ); 162 int float64_to_int32_round_to_zero( float64 ); 163 long float64_to_int64( float64 ); 164 long float64_to_int64_round_to_zero( float64 ); 165 float32 float64_to_float32( float64 ); 166 #ifdef FLOATX80 167 floatx80 float64_to_floatx80( float64 ); 168 #endif 169 #ifdef FLOAT128 170 float128 float64_to_float128( float64 ); 171 #endif 172 173 /*---------------------------------------------------------------------------- 174 | Software IEC/IEEE double-precision operations. 175 *----------------------------------------------------------------------------*/ 176 float64 float64_round_to_int( float64 ); 177 float64 float64_add( float64, float64 ); 178 float64 float64_sub( float64, float64 ); 179 float64 float64_mul( float64, float64 ); 180 float64 float64_div( float64, float64 ); 181 float64 float64_rem( float64, float64 ); 182 float64 float64_sqrt( float64 ); 183 int float64_eq( float64, float64 ); 184 int float64_le( float64, float64 ); 185 int float64_lt( float64, float64 ); 186 int float64_eq_signaling( float64, float64 ); 187 int float64_le_quiet( float64, float64 ); 188 int float64_lt_quiet( float64, float64 ); 189 int float64_is_signaling_nan( float64 ); 190 191 #ifdef FLOATX80 192 193 /*---------------------------------------------------------------------------- 194 | Software IEC/IEEE extended double-precision conversion routines. 195 *----------------------------------------------------------------------------*/ 196 int floatx80_to_int32( floatx80 ); 197 int floatx80_to_int32_round_to_zero( floatx80 ); 198 long floatx80_to_int64( floatx80 ); 199 long floatx80_to_int64_round_to_zero( floatx80 ); 200 float32 floatx80_to_float32( floatx80 ); 201 float64 floatx80_to_float64( floatx80 ); 202 #ifdef FLOAT128 203 float128 floatx80_to_float128( floatx80 ); 204 #endif 205 206 /*---------------------------------------------------------------------------- 207 | Software IEC/IEEE extended double-precision rounding precision. Valid 208 | values are 32, 64, and 80. 209 *----------------------------------------------------------------------------*/ 210 extern int floatx80_rounding_precision; 211 212 /*---------------------------------------------------------------------------- 213 | Software IEC/IEEE extended double-precision operations. 214 *----------------------------------------------------------------------------*/ 215 floatx80 floatx80_round_to_int( floatx80 ); 216 floatx80 floatx80_add( floatx80, floatx80 ); 217 floatx80 floatx80_sub( floatx80, floatx80 ); 218 floatx80 floatx80_mul( floatx80, floatx80 ); 219 floatx80 floatx80_div( floatx80, floatx80 ); 220 floatx80 floatx80_rem( floatx80, floatx80 ); 221 floatx80 floatx80_sqrt( floatx80 ); 222 int floatx80_eq( floatx80, floatx80 ); 223 int floatx80_le( floatx80, floatx80 ); 224 int floatx80_lt( floatx80, floatx80 ); 225 int floatx80_eq_signaling( floatx80, floatx80 ); 226 int floatx80_le_quiet( floatx80, floatx80 ); 227 int floatx80_lt_quiet( floatx80, floatx80 ); 228 int floatx80_is_signaling_nan( floatx80 ); 229 230 #endif 231 232 #ifdef FLOAT128 233 234 /*---------------------------------------------------------------------------- 235 | Software IEC/IEEE quadruple-precision conversion routines. 236 *----------------------------------------------------------------------------*/ 237 int float128_to_int32( float128 ); 238 int float128_to_int32_round_to_zero( float128 ); 239 long float128_to_int64( float128 ); 240 long float128_to_int64_round_to_zero( float128 ); 241 float32 float128_to_float32( float128 ); 242 float64 float128_to_float64( float128 ); 243 #ifdef FLOATX80 244 floatx80 float128_to_floatx80( float128 ); 245 #endif 246 247 /*---------------------------------------------------------------------------- 248 | Software IEC/IEEE quadruple-precision operations. 249 *----------------------------------------------------------------------------*/ 250 float128 float128_round_to_int( float128 ); 251 float128 float128_add( float128, float128 ); 252 float128 float128_sub( float128, float128 ); 253 float128 float128_mul( float128, float128 ); 254 float128 float128_div( float128, float128 ); 255 float128 float128_rem( float128, float128 ); 256 float128 float128_sqrt( float128 ); 257 int float128_eq( float128, float128 ); 258 int float128_le( float128, float128 ); 259 int float128_lt( float128, float128 ); 260 int float128_eq_signaling( float128, float128 ); 261 int float128_le_quiet( float128, float128 ); 262 int float128_lt_quiet( float128, float128 ); 263 int float128_is_signaling_nan( float128 ); 264 265 #endif 266 267 #endif 268