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