root / fpu / softfloat.h @ b93af93d
History | View | Annotate | Download (24.9 kB)
1 | 158142c2 | bellard | /*============================================================================
|
---|---|---|---|
2 | 158142c2 | bellard | |
3 | 158142c2 | bellard | This C header file is part of the SoftFloat IEC/IEEE Floating-point Arithmetic
|
4 | 158142c2 | bellard | Package, Release 2b.
|
5 | 158142c2 | bellard | |
6 | 158142c2 | bellard | Written by John R. Hauser. This work was made possible in part by the
|
7 | 158142c2 | bellard | International Computer Science Institute, located at Suite 600, 1947 Center
|
8 | 158142c2 | bellard | Street, Berkeley, California 94704. Funding was partially provided by the
|
9 | 158142c2 | bellard | National Science Foundation under grant MIP-9311980. The original version
|
10 | 158142c2 | bellard | of this code was written as part of a project to build a fixed-point vector
|
11 | 158142c2 | bellard | processor in collaboration with the University of California at Berkeley,
|
12 | 158142c2 | bellard | overseen by Profs. Nelson Morgan and John Wawrzynek. More information
|
13 | 158142c2 | bellard | is available through the Web page `http://www.cs.berkeley.edu/~jhauser/
|
14 | 158142c2 | bellard | arithmetic/SoftFloat.html'.
|
15 | 158142c2 | bellard | |
16 | 158142c2 | bellard | THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort has
|
17 | 158142c2 | bellard | been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT TIMES
|
18 | 158142c2 | bellard | RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO PERSONS
|
19 | 158142c2 | bellard | AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ALL LOSSES,
|
20 | 158142c2 | bellard | COSTS, OR OTHER PROBLEMS THEY INCUR DUE TO THE SOFTWARE, AND WHO FURTHERMORE
|
21 | 158142c2 | bellard | EFFECTIVELY INDEMNIFY JOHN HAUSER AND THE INTERNATIONAL COMPUTER SCIENCE
|
22 | 158142c2 | bellard | INSTITUTE (possibly via similar legal warning) AGAINST ALL LOSSES, COSTS, OR
|
23 | 158142c2 | bellard | OTHER PROBLEMS INCURRED BY THEIR CUSTOMERS AND CLIENTS DUE TO THE SOFTWARE.
|
24 | 158142c2 | bellard | |
25 | 158142c2 | bellard | Derivative works are acceptable, even for commercial purposes, so long as
|
26 | 158142c2 | bellard | (1) the source code for the derivative work includes prominent notice that
|
27 | 158142c2 | bellard | the work is derivative, and (2) the source code includes prominent notice with
|
28 | 158142c2 | bellard | these four paragraphs for those parts of this code that are retained.
|
29 | 158142c2 | bellard | |
30 | 158142c2 | bellard | =============================================================================*/
|
31 | 158142c2 | bellard | |
32 | 158142c2 | bellard | #ifndef SOFTFLOAT_H
|
33 | 158142c2 | bellard | #define SOFTFLOAT_H
|
34 | 158142c2 | bellard | |
35 | 75b5a697 | Juan Quintela | #if defined(CONFIG_SOLARIS) && defined(CONFIG_NEEDS_LIBSUNMATH)
|
36 | 0475a5ca | ths | #include <sunmath.h> |
37 | 0475a5ca | ths | #endif
|
38 | 0475a5ca | ths | |
39 | 158142c2 | bellard | #include <inttypes.h> |
40 | 158142c2 | bellard | #include "config.h" |
41 | 158142c2 | bellard | |
42 | 158142c2 | bellard | /*----------------------------------------------------------------------------
|
43 | 158142c2 | bellard | | Each of the following `typedef's defines the most convenient type that holds
|
44 | 158142c2 | bellard | | integers of at least as many bits as specified. For example, `uint8' should
|
45 | 158142c2 | bellard | | be the most convenient type that can hold unsigned integers of as many as
|
46 | 158142c2 | bellard | | 8 bits. The `flag' type must be able to hold either a 0 or 1. For most
|
47 | 158142c2 | bellard | | implementations of C, `flag', `uint8', and `int8' should all be `typedef'ed
|
48 | 158142c2 | bellard | | to the same as `int'.
|
49 | 158142c2 | bellard | *----------------------------------------------------------------------------*/
|
50 | 750afe93 | bellard | typedef uint8_t flag;
|
51 | 158142c2 | bellard | typedef uint8_t uint8;
|
52 | 158142c2 | bellard | typedef int8_t int8;
|
53 | b29fe3ed | malc | #ifndef _AIX
|
54 | 158142c2 | bellard | typedef int uint16; |
55 | 158142c2 | bellard | typedef int int16; |
56 | b29fe3ed | malc | #endif
|
57 | 158142c2 | bellard | typedef unsigned int uint32; |
58 | 158142c2 | bellard | typedef signed int int32; |
59 | 158142c2 | bellard | typedef uint64_t uint64;
|
60 | 158142c2 | bellard | typedef int64_t int64;
|
61 | 158142c2 | bellard | |
62 | 158142c2 | bellard | /*----------------------------------------------------------------------------
|
63 | 158142c2 | bellard | | Each of the following `typedef's defines a type that holds integers
|
64 | 158142c2 | bellard | | of _exactly_ the number of bits specified. For instance, for most
|
65 | 158142c2 | bellard | | implementation of C, `bits16' and `sbits16' should be `typedef'ed to
|
66 | 158142c2 | bellard | | `unsigned short int' and `signed short int' (or `short int'), respectively.
|
67 | 158142c2 | bellard | *----------------------------------------------------------------------------*/
|
68 | 158142c2 | bellard | typedef uint8_t bits8;
|
69 | 158142c2 | bellard | typedef int8_t sbits8;
|
70 | 158142c2 | bellard | typedef uint16_t bits16;
|
71 | 158142c2 | bellard | typedef int16_t sbits16;
|
72 | 158142c2 | bellard | typedef uint32_t bits32;
|
73 | 158142c2 | bellard | typedef int32_t sbits32;
|
74 | 158142c2 | bellard | typedef uint64_t bits64;
|
75 | 158142c2 | bellard | typedef int64_t sbits64;
|
76 | 158142c2 | bellard | |
77 | 158142c2 | bellard | #define LIT64( a ) a##LL |
78 | 158142c2 | bellard | #define INLINE static inline |
79 | 158142c2 | bellard | |
80 | 8559666d | Christophe Lyon | #if defined(TARGET_MIPS) || defined(TARGET_SH4)
|
81 | 8559666d | Christophe Lyon | #define SNAN_BIT_IS_ONE 1 |
82 | 8559666d | Christophe Lyon | #else
|
83 | 8559666d | Christophe Lyon | #define SNAN_BIT_IS_ONE 0 |
84 | 8559666d | Christophe Lyon | #endif
|
85 | 8559666d | Christophe Lyon | |
86 | 158142c2 | bellard | /*----------------------------------------------------------------------------
|
87 | 158142c2 | bellard | | The macro `FLOATX80' must be defined to enable the extended double-precision
|
88 | 158142c2 | bellard | | floating-point format `floatx80'. If this macro is not defined, the
|
89 | 158142c2 | bellard | | `floatx80' type will not be defined, and none of the functions that either
|
90 | 158142c2 | bellard | | input or output the `floatx80' type will be defined. The same applies to
|
91 | 158142c2 | bellard | | the `FLOAT128' macro and the quadruple-precision format `float128'.
|
92 | 158142c2 | bellard | *----------------------------------------------------------------------------*/
|
93 | 158142c2 | bellard | #ifdef CONFIG_SOFTFLOAT
|
94 | 158142c2 | bellard | /* bit exact soft float support */
|
95 | 158142c2 | bellard | #define FLOATX80
|
96 | 158142c2 | bellard | #define FLOAT128
|
97 | 158142c2 | bellard | #else
|
98 | 158142c2 | bellard | /* native float support */
|
99 | 71e72a19 | Juan Quintela | #if (defined(__i386__) || defined(__x86_64__)) && !defined(CONFIG_BSD)
|
100 | 158142c2 | bellard | #define FLOATX80
|
101 | 158142c2 | bellard | #endif
|
102 | 158142c2 | bellard | #endif /* !CONFIG_SOFTFLOAT */ |
103 | 158142c2 | bellard | |
104 | 158142c2 | bellard | #define STATUS_PARAM , float_status *status
|
105 | 158142c2 | bellard | #define STATUS(field) status->field
|
106 | 158142c2 | bellard | #define STATUS_VAR , status
|
107 | 158142c2 | bellard | |
108 | 1d6bda35 | bellard | /*----------------------------------------------------------------------------
|
109 | 1d6bda35 | bellard | | Software IEC/IEEE floating-point ordering relations
|
110 | 1d6bda35 | bellard | *----------------------------------------------------------------------------*/
|
111 | 1d6bda35 | bellard | enum {
|
112 | 1d6bda35 | bellard | float_relation_less = -1,
|
113 | 1d6bda35 | bellard | float_relation_equal = 0,
|
114 | 1d6bda35 | bellard | float_relation_greater = 1,
|
115 | 1d6bda35 | bellard | float_relation_unordered = 2
|
116 | 1d6bda35 | bellard | }; |
117 | 1d6bda35 | bellard | |
118 | 158142c2 | bellard | #ifdef CONFIG_SOFTFLOAT
|
119 | 158142c2 | bellard | /*----------------------------------------------------------------------------
|
120 | 158142c2 | bellard | | Software IEC/IEEE floating-point types.
|
121 | 158142c2 | bellard | *----------------------------------------------------------------------------*/
|
122 | f090c9d4 | pbrook | /* Use structures for soft-float types. This prevents accidentally mixing
|
123 | f090c9d4 | pbrook | them with native int/float types. A sufficiently clever compiler and
|
124 | f090c9d4 | pbrook | sane ABI should be able to see though these structs. However
|
125 | f090c9d4 | pbrook | x86/gcc 3.x seems to struggle a bit, so leave them disabled by default. */
|
126 | f090c9d4 | pbrook | //#define USE_SOFTFLOAT_STRUCT_TYPES
|
127 | f090c9d4 | pbrook | #ifdef USE_SOFTFLOAT_STRUCT_TYPES
|
128 | f090c9d4 | pbrook | typedef struct { |
129 | bb4d4bb3 | Peter Maydell | uint16_t v; |
130 | bb4d4bb3 | Peter Maydell | } float16; |
131 | bb4d4bb3 | Peter Maydell | #define float16_val(x) (((float16)(x)).v)
|
132 | bb4d4bb3 | Peter Maydell | #define make_float16(x) __extension__ ({ float16 f16_val = {x}; f16_val; })
|
133 | d5138cf4 | Peter Maydell | #define const_float16(x) { x }
|
134 | bb4d4bb3 | Peter Maydell | typedef struct { |
135 | f090c9d4 | pbrook | uint32_t v; |
136 | f090c9d4 | pbrook | } float32; |
137 | f090c9d4 | pbrook | /* The cast ensures an error if the wrong type is passed. */
|
138 | f090c9d4 | pbrook | #define float32_val(x) (((float32)(x)).v)
|
139 | f090c9d4 | pbrook | #define make_float32(x) __extension__ ({ float32 f32_val = {x}; f32_val; })
|
140 | d5138cf4 | Peter Maydell | #define const_float32(x) { x }
|
141 | f090c9d4 | pbrook | typedef struct { |
142 | f090c9d4 | pbrook | uint64_t v; |
143 | f090c9d4 | pbrook | } float64; |
144 | f090c9d4 | pbrook | #define float64_val(x) (((float64)(x)).v)
|
145 | f090c9d4 | pbrook | #define make_float64(x) __extension__ ({ float64 f64_val = {x}; f64_val; })
|
146 | d5138cf4 | Peter Maydell | #define const_float64(x) { x }
|
147 | f090c9d4 | pbrook | #else
|
148 | bb4d4bb3 | Peter Maydell | typedef uint16_t float16;
|
149 | 158142c2 | bellard | typedef uint32_t float32;
|
150 | 158142c2 | bellard | typedef uint64_t float64;
|
151 | bb4d4bb3 | Peter Maydell | #define float16_val(x) (x)
|
152 | f090c9d4 | pbrook | #define float32_val(x) (x)
|
153 | f090c9d4 | pbrook | #define float64_val(x) (x)
|
154 | bb4d4bb3 | Peter Maydell | #define make_float16(x) (x)
|
155 | f090c9d4 | pbrook | #define make_float32(x) (x)
|
156 | f090c9d4 | pbrook | #define make_float64(x) (x)
|
157 | d5138cf4 | Peter Maydell | #define const_float16(x) (x)
|
158 | d5138cf4 | Peter Maydell | #define const_float32(x) (x)
|
159 | d5138cf4 | Peter Maydell | #define const_float64(x) (x)
|
160 | f090c9d4 | pbrook | #endif
|
161 | 158142c2 | bellard | #ifdef FLOATX80
|
162 | 158142c2 | bellard | typedef struct { |
163 | 158142c2 | bellard | uint64_t low; |
164 | 158142c2 | bellard | uint16_t high; |
165 | 158142c2 | bellard | } floatx80; |
166 | 158142c2 | bellard | #endif
|
167 | 158142c2 | bellard | #ifdef FLOAT128
|
168 | 158142c2 | bellard | typedef struct { |
169 | e2542fe2 | Juan Quintela | #ifdef HOST_WORDS_BIGENDIAN
|
170 | 158142c2 | bellard | uint64_t high, low; |
171 | 158142c2 | bellard | #else
|
172 | 158142c2 | bellard | uint64_t low, high; |
173 | 158142c2 | bellard | #endif
|
174 | 158142c2 | bellard | } float128; |
175 | 158142c2 | bellard | #endif
|
176 | 158142c2 | bellard | |
177 | 158142c2 | bellard | /*----------------------------------------------------------------------------
|
178 | 158142c2 | bellard | | Software IEC/IEEE floating-point underflow tininess-detection mode.
|
179 | 158142c2 | bellard | *----------------------------------------------------------------------------*/
|
180 | 158142c2 | bellard | enum {
|
181 | 158142c2 | bellard | float_tininess_after_rounding = 0,
|
182 | 158142c2 | bellard | float_tininess_before_rounding = 1
|
183 | 158142c2 | bellard | }; |
184 | 158142c2 | bellard | |
185 | 158142c2 | bellard | /*----------------------------------------------------------------------------
|
186 | 158142c2 | bellard | | Software IEC/IEEE floating-point rounding mode.
|
187 | 158142c2 | bellard | *----------------------------------------------------------------------------*/
|
188 | 158142c2 | bellard | enum {
|
189 | 158142c2 | bellard | float_round_nearest_even = 0,
|
190 | 158142c2 | bellard | float_round_down = 1,
|
191 | 158142c2 | bellard | float_round_up = 2,
|
192 | 158142c2 | bellard | float_round_to_zero = 3
|
193 | 158142c2 | bellard | }; |
194 | 158142c2 | bellard | |
195 | 158142c2 | bellard | /*----------------------------------------------------------------------------
|
196 | 158142c2 | bellard | | Software IEC/IEEE floating-point exception flags.
|
197 | 158142c2 | bellard | *----------------------------------------------------------------------------*/
|
198 | 158142c2 | bellard | enum {
|
199 | 158142c2 | bellard | float_flag_invalid = 1,
|
200 | 158142c2 | bellard | float_flag_divbyzero = 4,
|
201 | 158142c2 | bellard | float_flag_overflow = 8,
|
202 | 158142c2 | bellard | float_flag_underflow = 16,
|
203 | 37d18660 | Peter Maydell | float_flag_inexact = 32,
|
204 | 37d18660 | Peter Maydell | float_flag_input_denormal = 64
|
205 | 158142c2 | bellard | }; |
206 | 158142c2 | bellard | |
207 | 158142c2 | bellard | typedef struct float_status { |
208 | 158142c2 | bellard | signed char float_detect_tininess; |
209 | 158142c2 | bellard | signed char float_rounding_mode; |
210 | 158142c2 | bellard | signed char float_exception_flags; |
211 | 158142c2 | bellard | #ifdef FLOATX80
|
212 | 158142c2 | bellard | signed char floatx80_rounding_precision; |
213 | 158142c2 | bellard | #endif
|
214 | 37d18660 | Peter Maydell | /* should denormalised results go to zero and set the inexact flag? */
|
215 | fe76d976 | pbrook | flag flush_to_zero; |
216 | 37d18660 | Peter Maydell | /* should denormalised inputs go to zero and set the input_denormal flag? */
|
217 | 37d18660 | Peter Maydell | flag flush_inputs_to_zero; |
218 | 5c7908ed | pbrook | flag default_nan_mode; |
219 | 158142c2 | bellard | } float_status; |
220 | 158142c2 | bellard | |
221 | 158142c2 | bellard | void set_float_rounding_mode(int val STATUS_PARAM); |
222 | 1d6bda35 | bellard | void set_float_exception_flags(int val STATUS_PARAM); |
223 | fe76d976 | pbrook | INLINE void set_flush_to_zero(flag val STATUS_PARAM)
|
224 | fe76d976 | pbrook | { |
225 | fe76d976 | pbrook | STATUS(flush_to_zero) = val; |
226 | fe76d976 | pbrook | } |
227 | 37d18660 | Peter Maydell | INLINE void set_flush_inputs_to_zero(flag val STATUS_PARAM)
|
228 | 37d18660 | Peter Maydell | { |
229 | 37d18660 | Peter Maydell | STATUS(flush_inputs_to_zero) = val; |
230 | 37d18660 | Peter Maydell | } |
231 | 5c7908ed | pbrook | INLINE void set_default_nan_mode(flag val STATUS_PARAM)
|
232 | 5c7908ed | pbrook | { |
233 | 5c7908ed | pbrook | STATUS(default_nan_mode) = val; |
234 | 5c7908ed | pbrook | } |
235 | 1d6bda35 | bellard | INLINE int get_float_exception_flags(float_status *status)
|
236 | 1d6bda35 | bellard | { |
237 | 1d6bda35 | bellard | return STATUS(float_exception_flags);
|
238 | 1d6bda35 | bellard | } |
239 | 158142c2 | bellard | #ifdef FLOATX80
|
240 | 158142c2 | bellard | void set_floatx80_rounding_precision(int val STATUS_PARAM); |
241 | 158142c2 | bellard | #endif
|
242 | 158142c2 | bellard | |
243 | 158142c2 | bellard | /*----------------------------------------------------------------------------
|
244 | 158142c2 | bellard | | Routine to raise any or all of the software IEC/IEEE floating-point
|
245 | 158142c2 | bellard | | exception flags.
|
246 | 158142c2 | bellard | *----------------------------------------------------------------------------*/
|
247 | ec530c81 | bellard | void float_raise( int8 flags STATUS_PARAM);
|
248 | 158142c2 | bellard | |
249 | 158142c2 | bellard | /*----------------------------------------------------------------------------
|
250 | 158142c2 | bellard | | Software IEC/IEEE integer-to-floating-point conversion routines.
|
251 | 158142c2 | bellard | *----------------------------------------------------------------------------*/
|
252 | 158142c2 | bellard | float32 int32_to_float32( int STATUS_PARAM );
|
253 | 158142c2 | bellard | float64 int32_to_float64( int STATUS_PARAM );
|
254 | 1d6bda35 | bellard | float32 uint32_to_float32( unsigned int STATUS_PARAM ); |
255 | 1d6bda35 | bellard | float64 uint32_to_float64( unsigned int STATUS_PARAM ); |
256 | 158142c2 | bellard | #ifdef FLOATX80
|
257 | 158142c2 | bellard | floatx80 int32_to_floatx80( int STATUS_PARAM );
|
258 | 158142c2 | bellard | #endif
|
259 | 158142c2 | bellard | #ifdef FLOAT128
|
260 | 158142c2 | bellard | float128 int32_to_float128( int STATUS_PARAM );
|
261 | 158142c2 | bellard | #endif
|
262 | 158142c2 | bellard | float32 int64_to_float32( int64_t STATUS_PARAM ); |
263 | 75d62a58 | j_mayer | float32 uint64_to_float32( uint64_t STATUS_PARAM ); |
264 | 158142c2 | bellard | float64 int64_to_float64( int64_t STATUS_PARAM ); |
265 | 75d62a58 | j_mayer | float64 uint64_to_float64( uint64_t STATUS_PARAM ); |
266 | 158142c2 | bellard | #ifdef FLOATX80
|
267 | 158142c2 | bellard | floatx80 int64_to_floatx80( int64_t STATUS_PARAM ); |
268 | 158142c2 | bellard | #endif
|
269 | 158142c2 | bellard | #ifdef FLOAT128
|
270 | 158142c2 | bellard | float128 int64_to_float128( int64_t STATUS_PARAM ); |
271 | 158142c2 | bellard | #endif
|
272 | 158142c2 | bellard | |
273 | 158142c2 | bellard | /*----------------------------------------------------------------------------
|
274 | 60011498 | Paul Brook | | Software half-precision conversion routines.
|
275 | 60011498 | Paul Brook | *----------------------------------------------------------------------------*/
|
276 | bb4d4bb3 | Peter Maydell | float16 float32_to_float16( float32, flag STATUS_PARAM ); |
277 | bb4d4bb3 | Peter Maydell | float32 float16_to_float32( float16, flag STATUS_PARAM ); |
278 | bb4d4bb3 | Peter Maydell | |
279 | bb4d4bb3 | Peter Maydell | /*----------------------------------------------------------------------------
|
280 | bb4d4bb3 | Peter Maydell | | Software half-precision operations.
|
281 | bb4d4bb3 | Peter Maydell | *----------------------------------------------------------------------------*/
|
282 | bb4d4bb3 | Peter Maydell | int float16_is_quiet_nan( float16 );
|
283 | bb4d4bb3 | Peter Maydell | int float16_is_signaling_nan( float16 );
|
284 | bb4d4bb3 | Peter Maydell | float16 float16_maybe_silence_nan( float16 ); |
285 | 60011498 | Paul Brook | |
286 | 60011498 | Paul Brook | /*----------------------------------------------------------------------------
|
287 | 8559666d | Christophe Lyon | | The pattern for a default generated half-precision NaN.
|
288 | 8559666d | Christophe Lyon | *----------------------------------------------------------------------------*/
|
289 | 8559666d | Christophe Lyon | #if defined(TARGET_ARM)
|
290 | 8559666d | Christophe Lyon | #define float16_default_nan make_float16(0x7E00) |
291 | 8559666d | Christophe Lyon | #elif SNAN_BIT_IS_ONE
|
292 | 8559666d | Christophe Lyon | #define float16_default_nan make_float16(0x7DFF) |
293 | 8559666d | Christophe Lyon | #else
|
294 | 8559666d | Christophe Lyon | #define float16_default_nan make_float16(0xFE00) |
295 | 8559666d | Christophe Lyon | #endif
|
296 | 8559666d | Christophe Lyon | |
297 | 8559666d | Christophe Lyon | /*----------------------------------------------------------------------------
|
298 | 158142c2 | bellard | | Software IEC/IEEE single-precision conversion routines.
|
299 | 158142c2 | bellard | *----------------------------------------------------------------------------*/
|
300 | cbcef455 | Peter Maydell | int float32_to_int16_round_to_zero( float32 STATUS_PARAM );
|
301 | cbcef455 | Peter Maydell | unsigned int float32_to_uint16_round_to_zero( float32 STATUS_PARAM ); |
302 | 158142c2 | bellard | int float32_to_int32( float32 STATUS_PARAM );
|
303 | 158142c2 | bellard | int float32_to_int32_round_to_zero( float32 STATUS_PARAM );
|
304 | 1d6bda35 | bellard | unsigned int float32_to_uint32( float32 STATUS_PARAM ); |
305 | 1d6bda35 | bellard | unsigned int float32_to_uint32_round_to_zero( float32 STATUS_PARAM ); |
306 | 158142c2 | bellard | int64_t float32_to_int64( float32 STATUS_PARAM ); |
307 | 158142c2 | bellard | int64_t float32_to_int64_round_to_zero( float32 STATUS_PARAM ); |
308 | 158142c2 | bellard | float64 float32_to_float64( float32 STATUS_PARAM ); |
309 | 158142c2 | bellard | #ifdef FLOATX80
|
310 | 158142c2 | bellard | floatx80 float32_to_floatx80( float32 STATUS_PARAM ); |
311 | 158142c2 | bellard | #endif
|
312 | 158142c2 | bellard | #ifdef FLOAT128
|
313 | 158142c2 | bellard | float128 float32_to_float128( float32 STATUS_PARAM ); |
314 | 158142c2 | bellard | #endif
|
315 | 158142c2 | bellard | |
316 | 158142c2 | bellard | /*----------------------------------------------------------------------------
|
317 | 158142c2 | bellard | | Software IEC/IEEE single-precision operations.
|
318 | 158142c2 | bellard | *----------------------------------------------------------------------------*/
|
319 | 158142c2 | bellard | float32 float32_round_to_int( float32 STATUS_PARAM ); |
320 | 158142c2 | bellard | float32 float32_add( float32, float32 STATUS_PARAM ); |
321 | 158142c2 | bellard | float32 float32_sub( float32, float32 STATUS_PARAM ); |
322 | 158142c2 | bellard | float32 float32_mul( float32, float32 STATUS_PARAM ); |
323 | 158142c2 | bellard | float32 float32_div( float32, float32 STATUS_PARAM ); |
324 | 158142c2 | bellard | float32 float32_rem( float32, float32 STATUS_PARAM ); |
325 | 158142c2 | bellard | float32 float32_sqrt( float32 STATUS_PARAM ); |
326 | 8229c991 | Aurelien Jarno | float32 float32_exp2( float32 STATUS_PARAM ); |
327 | 374dfc33 | aurel32 | float32 float32_log2( float32 STATUS_PARAM ); |
328 | 750afe93 | bellard | int float32_eq( float32, float32 STATUS_PARAM );
|
329 | 750afe93 | bellard | int float32_le( float32, float32 STATUS_PARAM );
|
330 | 750afe93 | bellard | int float32_lt( float32, float32 STATUS_PARAM );
|
331 | 750afe93 | bellard | int float32_eq_signaling( float32, float32 STATUS_PARAM );
|
332 | 750afe93 | bellard | int float32_le_quiet( float32, float32 STATUS_PARAM );
|
333 | 750afe93 | bellard | int float32_lt_quiet( float32, float32 STATUS_PARAM );
|
334 | 750afe93 | bellard | int float32_compare( float32, float32 STATUS_PARAM );
|
335 | 750afe93 | bellard | int float32_compare_quiet( float32, float32 STATUS_PARAM );
|
336 | 18569871 | Peter Maydell | int float32_is_quiet_nan( float32 );
|
337 | 750afe93 | bellard | int float32_is_signaling_nan( float32 );
|
338 | b408dbde | Peter Maydell | float32 float32_maybe_silence_nan( float32 ); |
339 | 9ee6e8bb | pbrook | float32 float32_scalbn( float32, int STATUS_PARAM );
|
340 | 158142c2 | bellard | |
341 | 1d6bda35 | bellard | INLINE float32 float32_abs(float32 a) |
342 | 1d6bda35 | bellard | { |
343 | 37d18660 | Peter Maydell | /* Note that abs does *not* handle NaN specially, nor does
|
344 | 37d18660 | Peter Maydell | * it flush denormal inputs to zero.
|
345 | 37d18660 | Peter Maydell | */
|
346 | f090c9d4 | pbrook | return make_float32(float32_val(a) & 0x7fffffff); |
347 | 1d6bda35 | bellard | } |
348 | 1d6bda35 | bellard | |
349 | 1d6bda35 | bellard | INLINE float32 float32_chs(float32 a) |
350 | 1d6bda35 | bellard | { |
351 | 37d18660 | Peter Maydell | /* Note that chs does *not* handle NaN specially, nor does
|
352 | 37d18660 | Peter Maydell | * it flush denormal inputs to zero.
|
353 | 37d18660 | Peter Maydell | */
|
354 | f090c9d4 | pbrook | return make_float32(float32_val(a) ^ 0x80000000); |
355 | 1d6bda35 | bellard | } |
356 | 1d6bda35 | bellard | |
357 | c52ab6f5 | aurel32 | INLINE int float32_is_infinity(float32 a)
|
358 | c52ab6f5 | aurel32 | { |
359 | dadd71a7 | aurel32 | return (float32_val(a) & 0x7fffffff) == 0x7f800000; |
360 | c52ab6f5 | aurel32 | } |
361 | c52ab6f5 | aurel32 | |
362 | c52ab6f5 | aurel32 | INLINE int float32_is_neg(float32 a)
|
363 | c52ab6f5 | aurel32 | { |
364 | c52ab6f5 | aurel32 | return float32_val(a) >> 31; |
365 | c52ab6f5 | aurel32 | } |
366 | c52ab6f5 | aurel32 | |
367 | c52ab6f5 | aurel32 | INLINE int float32_is_zero(float32 a)
|
368 | c52ab6f5 | aurel32 | { |
369 | c52ab6f5 | aurel32 | return (float32_val(a) & 0x7fffffff) == 0; |
370 | c52ab6f5 | aurel32 | } |
371 | c52ab6f5 | aurel32 | |
372 | 21d6ebde | Peter Maydell | INLINE int float32_is_any_nan(float32 a)
|
373 | 21d6ebde | Peter Maydell | { |
374 | 21d6ebde | Peter Maydell | return ((float32_val(a) & ~(1 << 31)) > 0x7f800000UL); |
375 | 21d6ebde | Peter Maydell | } |
376 | 21d6ebde | Peter Maydell | |
377 | 6f3300ad | Peter Maydell | INLINE int float32_is_zero_or_denormal(float32 a)
|
378 | 6f3300ad | Peter Maydell | { |
379 | 6f3300ad | Peter Maydell | return (float32_val(a) & 0x7f800000) == 0; |
380 | 6f3300ad | Peter Maydell | } |
381 | 6f3300ad | Peter Maydell | |
382 | c30fe7df | Christophe Lyon | INLINE float32 float32_set_sign(float32 a, int sign)
|
383 | c30fe7df | Christophe Lyon | { |
384 | c30fe7df | Christophe Lyon | return make_float32((float32_val(a) & 0x7fffffff) | (sign << 31)); |
385 | c30fe7df | Christophe Lyon | } |
386 | c30fe7df | Christophe Lyon | |
387 | f090c9d4 | pbrook | #define float32_zero make_float32(0) |
388 | 196cfc89 | aurel32 | #define float32_one make_float32(0x3f800000) |
389 | 8229c991 | Aurelien Jarno | #define float32_ln2 make_float32(0x3f317218) |
390 | c30fe7df | Christophe Lyon | #define float32_half make_float32(0x3f000000) |
391 | c30fe7df | Christophe Lyon | #define float32_infinity make_float32(0x7f800000) |
392 | f090c9d4 | pbrook | |
393 | 8559666d | Christophe Lyon | |
394 | 8559666d | Christophe Lyon | /*----------------------------------------------------------------------------
|
395 | 8559666d | Christophe Lyon | | The pattern for a default generated single-precision NaN.
|
396 | 8559666d | Christophe Lyon | *----------------------------------------------------------------------------*/
|
397 | 8559666d | Christophe Lyon | #if defined(TARGET_SPARC)
|
398 | 8559666d | Christophe Lyon | #define float32_default_nan make_float32(0x7FFFFFFF) |
399 | 8559666d | Christophe Lyon | #elif defined(TARGET_PPC) || defined(TARGET_ARM) || defined(TARGET_ALPHA)
|
400 | 8559666d | Christophe Lyon | #define float32_default_nan make_float32(0x7FC00000) |
401 | 8559666d | Christophe Lyon | #elif SNAN_BIT_IS_ONE
|
402 | 8559666d | Christophe Lyon | #define float32_default_nan make_float32(0x7FBFFFFF) |
403 | 8559666d | Christophe Lyon | #else
|
404 | 8559666d | Christophe Lyon | #define float32_default_nan make_float32(0xFFC00000) |
405 | 8559666d | Christophe Lyon | #endif
|
406 | 8559666d | Christophe Lyon | |
407 | 158142c2 | bellard | /*----------------------------------------------------------------------------
|
408 | 158142c2 | bellard | | Software IEC/IEEE double-precision conversion routines.
|
409 | 158142c2 | bellard | *----------------------------------------------------------------------------*/
|
410 | cbcef455 | Peter Maydell | int float64_to_int16_round_to_zero( float64 STATUS_PARAM );
|
411 | cbcef455 | Peter Maydell | unsigned int float64_to_uint16_round_to_zero( float64 STATUS_PARAM ); |
412 | 158142c2 | bellard | int float64_to_int32( float64 STATUS_PARAM );
|
413 | 158142c2 | bellard | int float64_to_int32_round_to_zero( float64 STATUS_PARAM );
|
414 | 1d6bda35 | bellard | unsigned int float64_to_uint32( float64 STATUS_PARAM ); |
415 | 1d6bda35 | bellard | unsigned int float64_to_uint32_round_to_zero( float64 STATUS_PARAM ); |
416 | 158142c2 | bellard | int64_t float64_to_int64( float64 STATUS_PARAM ); |
417 | 158142c2 | bellard | int64_t float64_to_int64_round_to_zero( float64 STATUS_PARAM ); |
418 | 75d62a58 | j_mayer | uint64_t float64_to_uint64 (float64 a STATUS_PARAM); |
419 | 75d62a58 | j_mayer | uint64_t float64_to_uint64_round_to_zero (float64 a STATUS_PARAM); |
420 | 158142c2 | bellard | float32 float64_to_float32( float64 STATUS_PARAM ); |
421 | 158142c2 | bellard | #ifdef FLOATX80
|
422 | 158142c2 | bellard | floatx80 float64_to_floatx80( float64 STATUS_PARAM ); |
423 | 158142c2 | bellard | #endif
|
424 | 158142c2 | bellard | #ifdef FLOAT128
|
425 | 158142c2 | bellard | float128 float64_to_float128( float64 STATUS_PARAM ); |
426 | 158142c2 | bellard | #endif
|
427 | 158142c2 | bellard | |
428 | 158142c2 | bellard | /*----------------------------------------------------------------------------
|
429 | 158142c2 | bellard | | Software IEC/IEEE double-precision operations.
|
430 | 158142c2 | bellard | *----------------------------------------------------------------------------*/
|
431 | 158142c2 | bellard | float64 float64_round_to_int( float64 STATUS_PARAM ); |
432 | e6e5906b | pbrook | float64 float64_trunc_to_int( float64 STATUS_PARAM ); |
433 | 158142c2 | bellard | float64 float64_add( float64, float64 STATUS_PARAM ); |
434 | 158142c2 | bellard | float64 float64_sub( float64, float64 STATUS_PARAM ); |
435 | 158142c2 | bellard | float64 float64_mul( float64, float64 STATUS_PARAM ); |
436 | 158142c2 | bellard | float64 float64_div( float64, float64 STATUS_PARAM ); |
437 | 158142c2 | bellard | float64 float64_rem( float64, float64 STATUS_PARAM ); |
438 | 158142c2 | bellard | float64 float64_sqrt( float64 STATUS_PARAM ); |
439 | 374dfc33 | aurel32 | float64 float64_log2( float64 STATUS_PARAM ); |
440 | 750afe93 | bellard | int float64_eq( float64, float64 STATUS_PARAM );
|
441 | 750afe93 | bellard | int float64_le( float64, float64 STATUS_PARAM );
|
442 | 750afe93 | bellard | int float64_lt( float64, float64 STATUS_PARAM );
|
443 | 750afe93 | bellard | int float64_eq_signaling( float64, float64 STATUS_PARAM );
|
444 | 750afe93 | bellard | int float64_le_quiet( float64, float64 STATUS_PARAM );
|
445 | 750afe93 | bellard | int float64_lt_quiet( float64, float64 STATUS_PARAM );
|
446 | 750afe93 | bellard | int float64_compare( float64, float64 STATUS_PARAM );
|
447 | 750afe93 | bellard | int float64_compare_quiet( float64, float64 STATUS_PARAM );
|
448 | 18569871 | Peter Maydell | int float64_is_quiet_nan( float64 a );
|
449 | 750afe93 | bellard | int float64_is_signaling_nan( float64 );
|
450 | b408dbde | Peter Maydell | float64 float64_maybe_silence_nan( float64 ); |
451 | 9ee6e8bb | pbrook | float64 float64_scalbn( float64, int STATUS_PARAM );
|
452 | 158142c2 | bellard | |
453 | 1d6bda35 | bellard | INLINE float64 float64_abs(float64 a) |
454 | 1d6bda35 | bellard | { |
455 | 37d18660 | Peter Maydell | /* Note that abs does *not* handle NaN specially, nor does
|
456 | 37d18660 | Peter Maydell | * it flush denormal inputs to zero.
|
457 | 37d18660 | Peter Maydell | */
|
458 | f090c9d4 | pbrook | return make_float64(float64_val(a) & 0x7fffffffffffffffLL); |
459 | 1d6bda35 | bellard | } |
460 | 1d6bda35 | bellard | |
461 | 1d6bda35 | bellard | INLINE float64 float64_chs(float64 a) |
462 | 1d6bda35 | bellard | { |
463 | 37d18660 | Peter Maydell | /* Note that chs does *not* handle NaN specially, nor does
|
464 | 37d18660 | Peter Maydell | * it flush denormal inputs to zero.
|
465 | 37d18660 | Peter Maydell | */
|
466 | f090c9d4 | pbrook | return make_float64(float64_val(a) ^ 0x8000000000000000LL); |
467 | 1d6bda35 | bellard | } |
468 | 1d6bda35 | bellard | |
469 | c52ab6f5 | aurel32 | INLINE int float64_is_infinity(float64 a)
|
470 | c52ab6f5 | aurel32 | { |
471 | c52ab6f5 | aurel32 | return (float64_val(a) & 0x7fffffffffffffffLL ) == 0x7ff0000000000000LL; |
472 | c52ab6f5 | aurel32 | } |
473 | c52ab6f5 | aurel32 | |
474 | c52ab6f5 | aurel32 | INLINE int float64_is_neg(float64 a)
|
475 | c52ab6f5 | aurel32 | { |
476 | c52ab6f5 | aurel32 | return float64_val(a) >> 63; |
477 | c52ab6f5 | aurel32 | } |
478 | c52ab6f5 | aurel32 | |
479 | c52ab6f5 | aurel32 | INLINE int float64_is_zero(float64 a)
|
480 | c52ab6f5 | aurel32 | { |
481 | c52ab6f5 | aurel32 | return (float64_val(a) & 0x7fffffffffffffffLL) == 0; |
482 | c52ab6f5 | aurel32 | } |
483 | c52ab6f5 | aurel32 | |
484 | 21d6ebde | Peter Maydell | INLINE int float64_is_any_nan(float64 a)
|
485 | 21d6ebde | Peter Maydell | { |
486 | 21d6ebde | Peter Maydell | return ((float64_val(a) & ~(1ULL << 63)) > 0x7ff0000000000000ULL); |
487 | 21d6ebde | Peter Maydell | } |
488 | 21d6ebde | Peter Maydell | |
489 | c30fe7df | Christophe Lyon | INLINE float64 float64_set_sign(float64 a, int sign)
|
490 | c30fe7df | Christophe Lyon | { |
491 | c30fe7df | Christophe Lyon | return make_float64((float64_val(a) & 0x7fffffffffffffffULL) |
492 | c30fe7df | Christophe Lyon | | ((int64_t)sign << 63));
|
493 | c30fe7df | Christophe Lyon | } |
494 | c30fe7df | Christophe Lyon | |
495 | f090c9d4 | pbrook | #define float64_zero make_float64(0) |
496 | 196cfc89 | aurel32 | #define float64_one make_float64(0x3ff0000000000000LL) |
497 | 8229c991 | Aurelien Jarno | #define float64_ln2 make_float64(0x3fe62e42fefa39efLL) |
498 | c30fe7df | Christophe Lyon | #define float64_half make_float64(0x3fe0000000000000LL) |
499 | c30fe7df | Christophe Lyon | #define float64_infinity make_float64(0x7ff0000000000000LL) |
500 | f090c9d4 | pbrook | |
501 | 8559666d | Christophe Lyon | /*----------------------------------------------------------------------------
|
502 | 8559666d | Christophe Lyon | | The pattern for a default generated double-precision NaN.
|
503 | 8559666d | Christophe Lyon | *----------------------------------------------------------------------------*/
|
504 | 8559666d | Christophe Lyon | #if defined(TARGET_SPARC)
|
505 | 8559666d | Christophe Lyon | #define float64_default_nan make_float64(LIT64( 0x7FFFFFFFFFFFFFFF )) |
506 | 8559666d | Christophe Lyon | #elif defined(TARGET_PPC) || defined(TARGET_ARM) || defined(TARGET_ALPHA)
|
507 | 8559666d | Christophe Lyon | #define float64_default_nan make_float64(LIT64( 0x7FF8000000000000 )) |
508 | 8559666d | Christophe Lyon | #elif SNAN_BIT_IS_ONE
|
509 | 8559666d | Christophe Lyon | #define float64_default_nan make_float64(LIT64( 0x7FF7FFFFFFFFFFFF )) |
510 | 8559666d | Christophe Lyon | #else
|
511 | 8559666d | Christophe Lyon | #define float64_default_nan make_float64(LIT64( 0xFFF8000000000000 )) |
512 | 8559666d | Christophe Lyon | #endif
|
513 | 8559666d | Christophe Lyon | |
514 | 158142c2 | bellard | #ifdef FLOATX80
|
515 | 158142c2 | bellard | |
516 | 158142c2 | bellard | /*----------------------------------------------------------------------------
|
517 | 158142c2 | bellard | | Software IEC/IEEE extended double-precision conversion routines.
|
518 | 158142c2 | bellard | *----------------------------------------------------------------------------*/
|
519 | 158142c2 | bellard | int floatx80_to_int32( floatx80 STATUS_PARAM );
|
520 | 158142c2 | bellard | int floatx80_to_int32_round_to_zero( floatx80 STATUS_PARAM );
|
521 | 158142c2 | bellard | int64_t floatx80_to_int64( floatx80 STATUS_PARAM ); |
522 | 158142c2 | bellard | int64_t floatx80_to_int64_round_to_zero( floatx80 STATUS_PARAM ); |
523 | 158142c2 | bellard | float32 floatx80_to_float32( floatx80 STATUS_PARAM ); |
524 | 158142c2 | bellard | float64 floatx80_to_float64( floatx80 STATUS_PARAM ); |
525 | 158142c2 | bellard | #ifdef FLOAT128
|
526 | 158142c2 | bellard | float128 floatx80_to_float128( floatx80 STATUS_PARAM ); |
527 | 158142c2 | bellard | #endif
|
528 | 158142c2 | bellard | |
529 | 158142c2 | bellard | /*----------------------------------------------------------------------------
|
530 | 158142c2 | bellard | | Software IEC/IEEE extended double-precision operations.
|
531 | 158142c2 | bellard | *----------------------------------------------------------------------------*/
|
532 | 158142c2 | bellard | floatx80 floatx80_round_to_int( floatx80 STATUS_PARAM ); |
533 | 158142c2 | bellard | floatx80 floatx80_add( floatx80, floatx80 STATUS_PARAM ); |
534 | 158142c2 | bellard | floatx80 floatx80_sub( floatx80, floatx80 STATUS_PARAM ); |
535 | 158142c2 | bellard | floatx80 floatx80_mul( floatx80, floatx80 STATUS_PARAM ); |
536 | 158142c2 | bellard | floatx80 floatx80_div( floatx80, floatx80 STATUS_PARAM ); |
537 | 158142c2 | bellard | floatx80 floatx80_rem( floatx80, floatx80 STATUS_PARAM ); |
538 | 158142c2 | bellard | floatx80 floatx80_sqrt( floatx80 STATUS_PARAM ); |
539 | 750afe93 | bellard | int floatx80_eq( floatx80, floatx80 STATUS_PARAM );
|
540 | 750afe93 | bellard | int floatx80_le( floatx80, floatx80 STATUS_PARAM );
|
541 | 750afe93 | bellard | int floatx80_lt( floatx80, floatx80 STATUS_PARAM );
|
542 | 750afe93 | bellard | int floatx80_eq_signaling( floatx80, floatx80 STATUS_PARAM );
|
543 | 750afe93 | bellard | int floatx80_le_quiet( floatx80, floatx80 STATUS_PARAM );
|
544 | 750afe93 | bellard | int floatx80_lt_quiet( floatx80, floatx80 STATUS_PARAM );
|
545 | 18569871 | Peter Maydell | int floatx80_is_quiet_nan( floatx80 );
|
546 | 750afe93 | bellard | int floatx80_is_signaling_nan( floatx80 );
|
547 | f6a7d92a | Aurelien Jarno | floatx80 floatx80_maybe_silence_nan( floatx80 ); |
548 | 9ee6e8bb | pbrook | floatx80 floatx80_scalbn( floatx80, int STATUS_PARAM );
|
549 | 158142c2 | bellard | |
550 | 1d6bda35 | bellard | INLINE floatx80 floatx80_abs(floatx80 a) |
551 | 1d6bda35 | bellard | { |
552 | 1d6bda35 | bellard | a.high &= 0x7fff;
|
553 | 1d6bda35 | bellard | return a;
|
554 | 1d6bda35 | bellard | } |
555 | 1d6bda35 | bellard | |
556 | 1d6bda35 | bellard | INLINE floatx80 floatx80_chs(floatx80 a) |
557 | 1d6bda35 | bellard | { |
558 | 1d6bda35 | bellard | a.high ^= 0x8000;
|
559 | 1d6bda35 | bellard | return a;
|
560 | 1d6bda35 | bellard | } |
561 | 1d6bda35 | bellard | |
562 | c52ab6f5 | aurel32 | INLINE int floatx80_is_infinity(floatx80 a)
|
563 | c52ab6f5 | aurel32 | { |
564 | c52ab6f5 | aurel32 | return (a.high & 0x7fff) == 0x7fff && a.low == 0; |
565 | c52ab6f5 | aurel32 | } |
566 | c52ab6f5 | aurel32 | |
567 | c52ab6f5 | aurel32 | INLINE int floatx80_is_neg(floatx80 a)
|
568 | c52ab6f5 | aurel32 | { |
569 | c52ab6f5 | aurel32 | return a.high >> 15; |
570 | c52ab6f5 | aurel32 | } |
571 | c52ab6f5 | aurel32 | |
572 | c52ab6f5 | aurel32 | INLINE int floatx80_is_zero(floatx80 a)
|
573 | c52ab6f5 | aurel32 | { |
574 | c52ab6f5 | aurel32 | return (a.high & 0x7fff) == 0 && a.low == 0; |
575 | c52ab6f5 | aurel32 | } |
576 | c52ab6f5 | aurel32 | |
577 | 2bed652f | Peter Maydell | INLINE int floatx80_is_any_nan(floatx80 a)
|
578 | 2bed652f | Peter Maydell | { |
579 | 2bed652f | Peter Maydell | return ((a.high & 0x7fff) == 0x7fff) && (a.low<<1); |
580 | 2bed652f | Peter Maydell | } |
581 | 2bed652f | Peter Maydell | |
582 | 8559666d | Christophe Lyon | /*----------------------------------------------------------------------------
|
583 | 8559666d | Christophe Lyon | | The pattern for a default generated extended double-precision NaN. The
|
584 | 8559666d | Christophe Lyon | | `high' and `low' values hold the most- and least-significant bits,
|
585 | 8559666d | Christophe Lyon | | respectively.
|
586 | 8559666d | Christophe Lyon | *----------------------------------------------------------------------------*/
|
587 | 8559666d | Christophe Lyon | #if SNAN_BIT_IS_ONE
|
588 | 8559666d | Christophe Lyon | #define floatx80_default_nan_high 0x7FFF |
589 | 8559666d | Christophe Lyon | #define floatx80_default_nan_low LIT64( 0xBFFFFFFFFFFFFFFF ) |
590 | 8559666d | Christophe Lyon | #else
|
591 | 8559666d | Christophe Lyon | #define floatx80_default_nan_high 0xFFFF |
592 | 8559666d | Christophe Lyon | #define floatx80_default_nan_low LIT64( 0xC000000000000000 ) |
593 | 8559666d | Christophe Lyon | #endif
|
594 | 8559666d | Christophe Lyon | |
595 | 158142c2 | bellard | #endif
|
596 | 158142c2 | bellard | |
597 | 158142c2 | bellard | #ifdef FLOAT128
|
598 | 158142c2 | bellard | |
599 | 158142c2 | bellard | /*----------------------------------------------------------------------------
|
600 | 158142c2 | bellard | | Software IEC/IEEE quadruple-precision conversion routines.
|
601 | 158142c2 | bellard | *----------------------------------------------------------------------------*/
|
602 | 158142c2 | bellard | int float128_to_int32( float128 STATUS_PARAM );
|
603 | 158142c2 | bellard | int float128_to_int32_round_to_zero( float128 STATUS_PARAM );
|
604 | 158142c2 | bellard | int64_t float128_to_int64( float128 STATUS_PARAM ); |
605 | 158142c2 | bellard | int64_t float128_to_int64_round_to_zero( float128 STATUS_PARAM ); |
606 | 158142c2 | bellard | float32 float128_to_float32( float128 STATUS_PARAM ); |
607 | 158142c2 | bellard | float64 float128_to_float64( float128 STATUS_PARAM ); |
608 | 158142c2 | bellard | #ifdef FLOATX80
|
609 | 158142c2 | bellard | floatx80 float128_to_floatx80( float128 STATUS_PARAM ); |
610 | 158142c2 | bellard | #endif
|
611 | 158142c2 | bellard | |
612 | 158142c2 | bellard | /*----------------------------------------------------------------------------
|
613 | 158142c2 | bellard | | Software IEC/IEEE quadruple-precision operations.
|
614 | 158142c2 | bellard | *----------------------------------------------------------------------------*/
|
615 | 158142c2 | bellard | float128 float128_round_to_int( float128 STATUS_PARAM ); |
616 | 158142c2 | bellard | float128 float128_add( float128, float128 STATUS_PARAM ); |
617 | 158142c2 | bellard | float128 float128_sub( float128, float128 STATUS_PARAM ); |
618 | 158142c2 | bellard | float128 float128_mul( float128, float128 STATUS_PARAM ); |
619 | 158142c2 | bellard | float128 float128_div( float128, float128 STATUS_PARAM ); |
620 | 158142c2 | bellard | float128 float128_rem( float128, float128 STATUS_PARAM ); |
621 | 158142c2 | bellard | float128 float128_sqrt( float128 STATUS_PARAM ); |
622 | 750afe93 | bellard | int float128_eq( float128, float128 STATUS_PARAM );
|
623 | 750afe93 | bellard | int float128_le( float128, float128 STATUS_PARAM );
|
624 | 750afe93 | bellard | int float128_lt( float128, float128 STATUS_PARAM );
|
625 | 750afe93 | bellard | int float128_eq_signaling( float128, float128 STATUS_PARAM );
|
626 | 750afe93 | bellard | int float128_le_quiet( float128, float128 STATUS_PARAM );
|
627 | 750afe93 | bellard | int float128_lt_quiet( float128, float128 STATUS_PARAM );
|
628 | 1f587329 | blueswir1 | int float128_compare( float128, float128 STATUS_PARAM );
|
629 | 1f587329 | blueswir1 | int float128_compare_quiet( float128, float128 STATUS_PARAM );
|
630 | 18569871 | Peter Maydell | int float128_is_quiet_nan( float128 );
|
631 | 750afe93 | bellard | int float128_is_signaling_nan( float128 );
|
632 | f6a7d92a | Aurelien Jarno | float128 float128_maybe_silence_nan( float128 ); |
633 | 9ee6e8bb | pbrook | float128 float128_scalbn( float128, int STATUS_PARAM );
|
634 | 158142c2 | bellard | |
635 | 1d6bda35 | bellard | INLINE float128 float128_abs(float128 a) |
636 | 1d6bda35 | bellard | { |
637 | 1d6bda35 | bellard | a.high &= 0x7fffffffffffffffLL;
|
638 | 1d6bda35 | bellard | return a;
|
639 | 1d6bda35 | bellard | } |
640 | 1d6bda35 | bellard | |
641 | 1d6bda35 | bellard | INLINE float128 float128_chs(float128 a) |
642 | 1d6bda35 | bellard | { |
643 | 1d6bda35 | bellard | a.high ^= 0x8000000000000000LL;
|
644 | 1d6bda35 | bellard | return a;
|
645 | 1d6bda35 | bellard | } |
646 | 1d6bda35 | bellard | |
647 | c52ab6f5 | aurel32 | INLINE int float128_is_infinity(float128 a)
|
648 | c52ab6f5 | aurel32 | { |
649 | c52ab6f5 | aurel32 | return (a.high & 0x7fffffffffffffffLL) == 0x7fff000000000000LL && a.low == 0; |
650 | c52ab6f5 | aurel32 | } |
651 | c52ab6f5 | aurel32 | |
652 | c52ab6f5 | aurel32 | INLINE int float128_is_neg(float128 a)
|
653 | c52ab6f5 | aurel32 | { |
654 | c52ab6f5 | aurel32 | return a.high >> 63; |
655 | c52ab6f5 | aurel32 | } |
656 | c52ab6f5 | aurel32 | |
657 | c52ab6f5 | aurel32 | INLINE int float128_is_zero(float128 a)
|
658 | c52ab6f5 | aurel32 | { |
659 | c52ab6f5 | aurel32 | return (a.high & 0x7fffffffffffffffLL) == 0 && a.low == 0; |
660 | c52ab6f5 | aurel32 | } |
661 | c52ab6f5 | aurel32 | |
662 | 2bed652f | Peter Maydell | INLINE int float128_is_any_nan(float128 a)
|
663 | 2bed652f | Peter Maydell | { |
664 | 2bed652f | Peter Maydell | return ((a.high >> 48) & 0x7fff) == 0x7fff && |
665 | 2bed652f | Peter Maydell | ((a.low != 0) || ((a.high & 0xffffffffffffLL) != 0)); |
666 | 2bed652f | Peter Maydell | } |
667 | 2bed652f | Peter Maydell | |
668 | 8559666d | Christophe Lyon | /*----------------------------------------------------------------------------
|
669 | 8559666d | Christophe Lyon | | The pattern for a default generated quadruple-precision NaN. The `high' and
|
670 | 8559666d | Christophe Lyon | | `low' values hold the most- and least-significant bits, respectively.
|
671 | 8559666d | Christophe Lyon | *----------------------------------------------------------------------------*/
|
672 | 8559666d | Christophe Lyon | #if SNAN_BIT_IS_ONE
|
673 | 8559666d | Christophe Lyon | #define float128_default_nan_high LIT64( 0x7FFF7FFFFFFFFFFF ) |
674 | 8559666d | Christophe Lyon | #define float128_default_nan_low LIT64( 0xFFFFFFFFFFFFFFFF ) |
675 | 8559666d | Christophe Lyon | #else
|
676 | 8559666d | Christophe Lyon | #define float128_default_nan_high LIT64( 0xFFFF800000000000 ) |
677 | 8559666d | Christophe Lyon | #define float128_default_nan_low LIT64( 0x0000000000000000 ) |
678 | 8559666d | Christophe Lyon | #endif
|
679 | 8559666d | Christophe Lyon | |
680 | 158142c2 | bellard | #endif
|
681 | 158142c2 | bellard | |
682 | 158142c2 | bellard | #else /* CONFIG_SOFTFLOAT */ |
683 | 158142c2 | bellard | |
684 | 158142c2 | bellard | #include "softfloat-native.h" |
685 | 158142c2 | bellard | |
686 | 158142c2 | bellard | #endif /* !CONFIG_SOFTFLOAT */ |
687 | 158142c2 | bellard | |
688 | 158142c2 | bellard | #endif /* !SOFTFLOAT_H */ |