root / fpu / softfloat.h @ 7fee199c
History | View | Annotate | Download (24.8 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 | 158142c2 | bellard | #include "config.h" |
47 | 158142c2 | bellard | |
48 | 158142c2 | bellard | /*----------------------------------------------------------------------------
|
49 | 158142c2 | bellard | | Each of the following `typedef's defines the most convenient type that holds
|
50 | 158142c2 | bellard | | integers of at least as many bits as specified. For example, `uint8' should
|
51 | 158142c2 | bellard | | be the most convenient type that can hold unsigned integers of as many as
|
52 | 158142c2 | bellard | | 8 bits. The `flag' type must be able to hold either a 0 or 1. For most
|
53 | 158142c2 | bellard | | implementations of C, `flag', `uint8', and `int8' should all be `typedef'ed
|
54 | 158142c2 | bellard | | to the same as `int'.
|
55 | 158142c2 | bellard | *----------------------------------------------------------------------------*/
|
56 | 750afe93 | bellard | typedef uint8_t flag;
|
57 | 158142c2 | bellard | typedef uint8_t uint8;
|
58 | 158142c2 | bellard | typedef int8_t int8;
|
59 | b29fe3ed | malc | #ifndef _AIX
|
60 | 158142c2 | bellard | typedef int uint16; |
61 | 158142c2 | bellard | typedef int int16; |
62 | b29fe3ed | malc | #endif
|
63 | 158142c2 | bellard | typedef unsigned int uint32; |
64 | 158142c2 | bellard | typedef signed int int32; |
65 | 158142c2 | bellard | typedef uint64_t uint64;
|
66 | 158142c2 | bellard | typedef int64_t int64;
|
67 | 158142c2 | bellard | |
68 | 158142c2 | bellard | #define LIT64( a ) a##LL |
69 | 158142c2 | bellard | #define INLINE static inline |
70 | 158142c2 | bellard | |
71 | d2fbca94 | Guan Xuetao | #if defined(TARGET_MIPS) || defined(TARGET_SH4) || defined(TARGET_UNICORE32)
|
72 | 8559666d | Christophe Lyon | #define SNAN_BIT_IS_ONE 1 |
73 | 8559666d | Christophe Lyon | #else
|
74 | 8559666d | Christophe Lyon | #define SNAN_BIT_IS_ONE 0 |
75 | 8559666d | Christophe Lyon | #endif
|
76 | 8559666d | Christophe Lyon | |
77 | 158142c2 | bellard | #define STATUS_PARAM , float_status *status
|
78 | 158142c2 | bellard | #define STATUS(field) status->field
|
79 | 158142c2 | bellard | #define STATUS_VAR , status
|
80 | 158142c2 | bellard | |
81 | 1d6bda35 | bellard | /*----------------------------------------------------------------------------
|
82 | 1d6bda35 | bellard | | Software IEC/IEEE floating-point ordering relations
|
83 | 1d6bda35 | bellard | *----------------------------------------------------------------------------*/
|
84 | 1d6bda35 | bellard | enum {
|
85 | 1d6bda35 | bellard | float_relation_less = -1,
|
86 | 1d6bda35 | bellard | float_relation_equal = 0,
|
87 | 1d6bda35 | bellard | float_relation_greater = 1,
|
88 | 1d6bda35 | bellard | float_relation_unordered = 2
|
89 | 1d6bda35 | bellard | }; |
90 | 1d6bda35 | bellard | |
91 | 158142c2 | bellard | /*----------------------------------------------------------------------------
|
92 | 158142c2 | bellard | | Software IEC/IEEE floating-point types.
|
93 | 158142c2 | bellard | *----------------------------------------------------------------------------*/
|
94 | f090c9d4 | pbrook | /* Use structures for soft-float types. This prevents accidentally mixing
|
95 | f090c9d4 | pbrook | them with native int/float types. A sufficiently clever compiler and
|
96 | f090c9d4 | pbrook | sane ABI should be able to see though these structs. However
|
97 | f090c9d4 | pbrook | x86/gcc 3.x seems to struggle a bit, so leave them disabled by default. */
|
98 | f090c9d4 | pbrook | //#define USE_SOFTFLOAT_STRUCT_TYPES
|
99 | f090c9d4 | pbrook | #ifdef USE_SOFTFLOAT_STRUCT_TYPES
|
100 | f090c9d4 | pbrook | typedef struct { |
101 | bb4d4bb3 | Peter Maydell | uint16_t v; |
102 | bb4d4bb3 | Peter Maydell | } float16; |
103 | bb4d4bb3 | Peter Maydell | #define float16_val(x) (((float16)(x)).v)
|
104 | bb4d4bb3 | Peter Maydell | #define make_float16(x) __extension__ ({ float16 f16_val = {x}; f16_val; })
|
105 | d5138cf4 | Peter Maydell | #define const_float16(x) { x }
|
106 | bb4d4bb3 | Peter Maydell | typedef struct { |
107 | f090c9d4 | pbrook | uint32_t v; |
108 | f090c9d4 | pbrook | } float32; |
109 | f090c9d4 | pbrook | /* The cast ensures an error if the wrong type is passed. */
|
110 | f090c9d4 | pbrook | #define float32_val(x) (((float32)(x)).v)
|
111 | f090c9d4 | pbrook | #define make_float32(x) __extension__ ({ float32 f32_val = {x}; f32_val; })
|
112 | d5138cf4 | Peter Maydell | #define const_float32(x) { x }
|
113 | f090c9d4 | pbrook | typedef struct { |
114 | f090c9d4 | pbrook | uint64_t v; |
115 | f090c9d4 | pbrook | } float64; |
116 | f090c9d4 | pbrook | #define float64_val(x) (((float64)(x)).v)
|
117 | f090c9d4 | pbrook | #define make_float64(x) __extension__ ({ float64 f64_val = {x}; f64_val; })
|
118 | d5138cf4 | Peter Maydell | #define const_float64(x) { x }
|
119 | f090c9d4 | pbrook | #else
|
120 | bb4d4bb3 | Peter Maydell | typedef uint16_t float16;
|
121 | 158142c2 | bellard | typedef uint32_t float32;
|
122 | 158142c2 | bellard | typedef uint64_t float64;
|
123 | bb4d4bb3 | Peter Maydell | #define float16_val(x) (x)
|
124 | f090c9d4 | pbrook | #define float32_val(x) (x)
|
125 | f090c9d4 | pbrook | #define float64_val(x) (x)
|
126 | bb4d4bb3 | Peter Maydell | #define make_float16(x) (x)
|
127 | f090c9d4 | pbrook | #define make_float32(x) (x)
|
128 | f090c9d4 | pbrook | #define make_float64(x) (x)
|
129 | d5138cf4 | Peter Maydell | #define const_float16(x) (x)
|
130 | d5138cf4 | Peter Maydell | #define const_float32(x) (x)
|
131 | d5138cf4 | Peter Maydell | #define const_float64(x) (x)
|
132 | f090c9d4 | pbrook | #endif
|
133 | 158142c2 | bellard | typedef struct { |
134 | 158142c2 | bellard | uint64_t low; |
135 | 158142c2 | bellard | uint16_t high; |
136 | 158142c2 | bellard | } floatx80; |
137 | f3218a8d | Aurelien Jarno | #define make_floatx80(exp, mant) ((floatx80) { mant, exp })
|
138 | 158142c2 | bellard | typedef struct { |
139 | e2542fe2 | Juan Quintela | #ifdef HOST_WORDS_BIGENDIAN
|
140 | 158142c2 | bellard | uint64_t high, low; |
141 | 158142c2 | bellard | #else
|
142 | 158142c2 | bellard | uint64_t low, high; |
143 | 158142c2 | bellard | #endif
|
144 | 158142c2 | bellard | } float128; |
145 | 158142c2 | bellard | |
146 | 158142c2 | bellard | /*----------------------------------------------------------------------------
|
147 | 158142c2 | bellard | | Software IEC/IEEE floating-point underflow tininess-detection mode.
|
148 | 158142c2 | bellard | *----------------------------------------------------------------------------*/
|
149 | 158142c2 | bellard | enum {
|
150 | 158142c2 | bellard | float_tininess_after_rounding = 0,
|
151 | 158142c2 | bellard | float_tininess_before_rounding = 1
|
152 | 158142c2 | bellard | }; |
153 | 158142c2 | bellard | |
154 | 158142c2 | bellard | /*----------------------------------------------------------------------------
|
155 | 158142c2 | bellard | | Software IEC/IEEE floating-point rounding mode.
|
156 | 158142c2 | bellard | *----------------------------------------------------------------------------*/
|
157 | 158142c2 | bellard | enum {
|
158 | 158142c2 | bellard | float_round_nearest_even = 0,
|
159 | 158142c2 | bellard | float_round_down = 1,
|
160 | 158142c2 | bellard | float_round_up = 2,
|
161 | 158142c2 | bellard | float_round_to_zero = 3
|
162 | 158142c2 | bellard | }; |
163 | 158142c2 | bellard | |
164 | 158142c2 | bellard | /*----------------------------------------------------------------------------
|
165 | 158142c2 | bellard | | Software IEC/IEEE floating-point exception flags.
|
166 | 158142c2 | bellard | *----------------------------------------------------------------------------*/
|
167 | 158142c2 | bellard | enum {
|
168 | 158142c2 | bellard | float_flag_invalid = 1,
|
169 | 158142c2 | bellard | float_flag_divbyzero = 4,
|
170 | 158142c2 | bellard | float_flag_overflow = 8,
|
171 | 158142c2 | bellard | float_flag_underflow = 16,
|
172 | 37d18660 | Peter Maydell | float_flag_inexact = 32,
|
173 | e6afc87f | Peter Maydell | float_flag_input_denormal = 64,
|
174 | e6afc87f | Peter Maydell | float_flag_output_denormal = 128
|
175 | 158142c2 | bellard | }; |
176 | 158142c2 | bellard | |
177 | 158142c2 | bellard | typedef struct float_status { |
178 | 158142c2 | bellard | signed char float_detect_tininess; |
179 | 158142c2 | bellard | signed char float_rounding_mode; |
180 | 158142c2 | bellard | signed char float_exception_flags; |
181 | 158142c2 | bellard | signed char floatx80_rounding_precision; |
182 | 37d18660 | Peter Maydell | /* should denormalised results go to zero and set the inexact flag? */
|
183 | fe76d976 | pbrook | flag flush_to_zero; |
184 | 37d18660 | Peter Maydell | /* should denormalised inputs go to zero and set the input_denormal flag? */
|
185 | 37d18660 | Peter Maydell | flag flush_inputs_to_zero; |
186 | 5c7908ed | pbrook | flag default_nan_mode; |
187 | 158142c2 | bellard | } float_status; |
188 | 158142c2 | bellard | |
189 | 158142c2 | bellard | void set_float_rounding_mode(int val STATUS_PARAM); |
190 | 1d6bda35 | bellard | void set_float_exception_flags(int val STATUS_PARAM); |
191 | c29aca44 | Peter Maydell | INLINE void set_float_detect_tininess(int val STATUS_PARAM) |
192 | c29aca44 | Peter Maydell | { |
193 | c29aca44 | Peter Maydell | STATUS(float_detect_tininess) = val; |
194 | c29aca44 | Peter Maydell | } |
195 | fe76d976 | pbrook | INLINE void set_flush_to_zero(flag val STATUS_PARAM)
|
196 | fe76d976 | pbrook | { |
197 | fe76d976 | pbrook | STATUS(flush_to_zero) = val; |
198 | fe76d976 | pbrook | } |
199 | 37d18660 | Peter Maydell | INLINE void set_flush_inputs_to_zero(flag val STATUS_PARAM)
|
200 | 37d18660 | Peter Maydell | { |
201 | 37d18660 | Peter Maydell | STATUS(flush_inputs_to_zero) = val; |
202 | 37d18660 | Peter Maydell | } |
203 | 5c7908ed | pbrook | INLINE void set_default_nan_mode(flag val STATUS_PARAM)
|
204 | 5c7908ed | pbrook | { |
205 | 5c7908ed | pbrook | STATUS(default_nan_mode) = val; |
206 | 5c7908ed | pbrook | } |
207 | 1d6bda35 | bellard | INLINE int get_float_exception_flags(float_status *status)
|
208 | 1d6bda35 | bellard | { |
209 | 1d6bda35 | bellard | return STATUS(float_exception_flags);
|
210 | 1d6bda35 | bellard | } |
211 | 158142c2 | bellard | void set_floatx80_rounding_precision(int val STATUS_PARAM); |
212 | 158142c2 | bellard | |
213 | 158142c2 | bellard | /*----------------------------------------------------------------------------
|
214 | 158142c2 | bellard | | Routine to raise any or all of the software IEC/IEEE floating-point
|
215 | 158142c2 | bellard | | exception flags.
|
216 | 158142c2 | bellard | *----------------------------------------------------------------------------*/
|
217 | ec530c81 | bellard | void float_raise( int8 flags STATUS_PARAM);
|
218 | 158142c2 | bellard | |
219 | 158142c2 | bellard | /*----------------------------------------------------------------------------
|
220 | 158142c2 | bellard | | Software IEC/IEEE integer-to-floating-point conversion routines.
|
221 | 158142c2 | bellard | *----------------------------------------------------------------------------*/
|
222 | 87b8cc3c | Andreas Färber | float32 int32_to_float32( int32 STATUS_PARAM ); |
223 | 87b8cc3c | Andreas Färber | float64 int32_to_float64( int32 STATUS_PARAM ); |
224 | 1d6bda35 | bellard | float32 uint32_to_float32( unsigned int STATUS_PARAM ); |
225 | 1d6bda35 | bellard | float64 uint32_to_float64( unsigned int STATUS_PARAM ); |
226 | 87b8cc3c | Andreas Färber | floatx80 int32_to_floatx80( int32 STATUS_PARAM ); |
227 | 87b8cc3c | Andreas Färber | float128 int32_to_float128( int32 STATUS_PARAM ); |
228 | 87b8cc3c | Andreas Färber | float32 int64_to_float32( int64 STATUS_PARAM ); |
229 | 87b8cc3c | Andreas Färber | float32 uint64_to_float32( uint64 STATUS_PARAM ); |
230 | 87b8cc3c | Andreas Färber | float64 int64_to_float64( int64 STATUS_PARAM ); |
231 | 87b8cc3c | Andreas Färber | float64 uint64_to_float64( uint64 STATUS_PARAM ); |
232 | 87b8cc3c | Andreas Färber | floatx80 int64_to_floatx80( int64 STATUS_PARAM ); |
233 | 87b8cc3c | Andreas Färber | float128 int64_to_float128( int64 STATUS_PARAM ); |
234 | 158142c2 | bellard | |
235 | 158142c2 | bellard | /*----------------------------------------------------------------------------
|
236 | 60011498 | Paul Brook | | Software half-precision conversion routines.
|
237 | 60011498 | Paul Brook | *----------------------------------------------------------------------------*/
|
238 | bb4d4bb3 | Peter Maydell | float16 float32_to_float16( float32, flag STATUS_PARAM ); |
239 | bb4d4bb3 | Peter Maydell | float32 float16_to_float32( float16, flag STATUS_PARAM ); |
240 | bb4d4bb3 | Peter Maydell | |
241 | bb4d4bb3 | Peter Maydell | /*----------------------------------------------------------------------------
|
242 | bb4d4bb3 | Peter Maydell | | Software half-precision operations.
|
243 | bb4d4bb3 | Peter Maydell | *----------------------------------------------------------------------------*/
|
244 | bb4d4bb3 | Peter Maydell | int float16_is_quiet_nan( float16 );
|
245 | bb4d4bb3 | Peter Maydell | int float16_is_signaling_nan( float16 );
|
246 | bb4d4bb3 | Peter Maydell | float16 float16_maybe_silence_nan( float16 ); |
247 | 60011498 | Paul Brook | |
248 | 60011498 | Paul Brook | /*----------------------------------------------------------------------------
|
249 | 8559666d | Christophe Lyon | | The pattern for a default generated half-precision NaN.
|
250 | 8559666d | Christophe Lyon | *----------------------------------------------------------------------------*/
|
251 | 8559666d | Christophe Lyon | #if defined(TARGET_ARM)
|
252 | 8559666d | Christophe Lyon | #define float16_default_nan make_float16(0x7E00) |
253 | 8559666d | Christophe Lyon | #elif SNAN_BIT_IS_ONE
|
254 | 8559666d | Christophe Lyon | #define float16_default_nan make_float16(0x7DFF) |
255 | 8559666d | Christophe Lyon | #else
|
256 | 8559666d | Christophe Lyon | #define float16_default_nan make_float16(0xFE00) |
257 | 8559666d | Christophe Lyon | #endif
|
258 | 8559666d | Christophe Lyon | |
259 | 8559666d | Christophe Lyon | /*----------------------------------------------------------------------------
|
260 | 158142c2 | bellard | | Software IEC/IEEE single-precision conversion routines.
|
261 | 158142c2 | bellard | *----------------------------------------------------------------------------*/
|
262 | 87b8cc3c | Andreas Färber | int16 float32_to_int16_round_to_zero( float32 STATUS_PARAM ); |
263 | cbcef455 | Peter Maydell | unsigned int float32_to_uint16_round_to_zero( float32 STATUS_PARAM ); |
264 | 87b8cc3c | Andreas Färber | int32 float32_to_int32( float32 STATUS_PARAM ); |
265 | 87b8cc3c | Andreas Färber | int32 float32_to_int32_round_to_zero( float32 STATUS_PARAM ); |
266 | 87b8cc3c | Andreas Färber | uint32 float32_to_uint32( float32 STATUS_PARAM ); |
267 | 87b8cc3c | Andreas Färber | uint32 float32_to_uint32_round_to_zero( float32 STATUS_PARAM ); |
268 | 87b8cc3c | Andreas Färber | int64 float32_to_int64( float32 STATUS_PARAM ); |
269 | 87b8cc3c | Andreas Färber | int64 float32_to_int64_round_to_zero( float32 STATUS_PARAM ); |
270 | 158142c2 | bellard | float64 float32_to_float64( float32 STATUS_PARAM ); |
271 | 158142c2 | bellard | floatx80 float32_to_floatx80( float32 STATUS_PARAM ); |
272 | 158142c2 | bellard | float128 float32_to_float128( float32 STATUS_PARAM ); |
273 | 158142c2 | bellard | |
274 | 158142c2 | bellard | /*----------------------------------------------------------------------------
|
275 | 158142c2 | bellard | | Software IEC/IEEE single-precision operations.
|
276 | 158142c2 | bellard | *----------------------------------------------------------------------------*/
|
277 | 158142c2 | bellard | float32 float32_round_to_int( float32 STATUS_PARAM ); |
278 | 158142c2 | bellard | float32 float32_add( float32, float32 STATUS_PARAM ); |
279 | 158142c2 | bellard | float32 float32_sub( float32, float32 STATUS_PARAM ); |
280 | 158142c2 | bellard | float32 float32_mul( float32, float32 STATUS_PARAM ); |
281 | 158142c2 | bellard | float32 float32_div( float32, float32 STATUS_PARAM ); |
282 | 158142c2 | bellard | float32 float32_rem( float32, float32 STATUS_PARAM ); |
283 | 158142c2 | bellard | float32 float32_sqrt( float32 STATUS_PARAM ); |
284 | 8229c991 | Aurelien Jarno | float32 float32_exp2( float32 STATUS_PARAM ); |
285 | 374dfc33 | aurel32 | float32 float32_log2( float32 STATUS_PARAM ); |
286 | b689362d | Aurelien Jarno | int float32_eq( float32, float32 STATUS_PARAM );
|
287 | 750afe93 | bellard | int float32_le( float32, float32 STATUS_PARAM );
|
288 | 750afe93 | bellard | int float32_lt( float32, float32 STATUS_PARAM );
|
289 | 67b7861d | Aurelien Jarno | int float32_unordered( float32, float32 STATUS_PARAM );
|
290 | b689362d | Aurelien Jarno | int float32_eq_quiet( float32, float32 STATUS_PARAM );
|
291 | 750afe93 | bellard | int float32_le_quiet( float32, float32 STATUS_PARAM );
|
292 | 750afe93 | bellard | int float32_lt_quiet( float32, float32 STATUS_PARAM );
|
293 | 67b7861d | Aurelien Jarno | int float32_unordered_quiet( float32, float32 STATUS_PARAM );
|
294 | 750afe93 | bellard | int float32_compare( float32, float32 STATUS_PARAM );
|
295 | 750afe93 | bellard | int float32_compare_quiet( float32, float32 STATUS_PARAM );
|
296 | 274f1b04 | Peter Maydell | float32 float32_min(float32, float32 STATUS_PARAM); |
297 | 274f1b04 | Peter Maydell | float32 float32_max(float32, float32 STATUS_PARAM); |
298 | 18569871 | Peter Maydell | int float32_is_quiet_nan( float32 );
|
299 | 750afe93 | bellard | int float32_is_signaling_nan( float32 );
|
300 | b408dbde | Peter Maydell | float32 float32_maybe_silence_nan( float32 ); |
301 | 9ee6e8bb | pbrook | float32 float32_scalbn( float32, int STATUS_PARAM );
|
302 | 158142c2 | bellard | |
303 | 1d6bda35 | bellard | INLINE float32 float32_abs(float32 a) |
304 | 1d6bda35 | bellard | { |
305 | 37d18660 | Peter Maydell | /* Note that abs does *not* handle NaN specially, nor does
|
306 | 37d18660 | Peter Maydell | * it flush denormal inputs to zero.
|
307 | 37d18660 | Peter Maydell | */
|
308 | f090c9d4 | pbrook | return make_float32(float32_val(a) & 0x7fffffff); |
309 | 1d6bda35 | bellard | } |
310 | 1d6bda35 | bellard | |
311 | 1d6bda35 | bellard | INLINE float32 float32_chs(float32 a) |
312 | 1d6bda35 | bellard | { |
313 | 37d18660 | Peter Maydell | /* Note that chs does *not* handle NaN specially, nor does
|
314 | 37d18660 | Peter Maydell | * it flush denormal inputs to zero.
|
315 | 37d18660 | Peter Maydell | */
|
316 | f090c9d4 | pbrook | return make_float32(float32_val(a) ^ 0x80000000); |
317 | 1d6bda35 | bellard | } |
318 | 1d6bda35 | bellard | |
319 | c52ab6f5 | aurel32 | INLINE int float32_is_infinity(float32 a)
|
320 | c52ab6f5 | aurel32 | { |
321 | dadd71a7 | aurel32 | return (float32_val(a) & 0x7fffffff) == 0x7f800000; |
322 | c52ab6f5 | aurel32 | } |
323 | c52ab6f5 | aurel32 | |
324 | c52ab6f5 | aurel32 | INLINE int float32_is_neg(float32 a)
|
325 | c52ab6f5 | aurel32 | { |
326 | c52ab6f5 | aurel32 | return float32_val(a) >> 31; |
327 | c52ab6f5 | aurel32 | } |
328 | c52ab6f5 | aurel32 | |
329 | c52ab6f5 | aurel32 | INLINE int float32_is_zero(float32 a)
|
330 | c52ab6f5 | aurel32 | { |
331 | c52ab6f5 | aurel32 | return (float32_val(a) & 0x7fffffff) == 0; |
332 | c52ab6f5 | aurel32 | } |
333 | c52ab6f5 | aurel32 | |
334 | 21d6ebde | Peter Maydell | INLINE int float32_is_any_nan(float32 a)
|
335 | 21d6ebde | Peter Maydell | { |
336 | 21d6ebde | Peter Maydell | return ((float32_val(a) & ~(1 << 31)) > 0x7f800000UL); |
337 | 21d6ebde | Peter Maydell | } |
338 | 21d6ebde | Peter Maydell | |
339 | 6f3300ad | Peter Maydell | INLINE int float32_is_zero_or_denormal(float32 a)
|
340 | 6f3300ad | Peter Maydell | { |
341 | 6f3300ad | Peter Maydell | return (float32_val(a) & 0x7f800000) == 0; |
342 | 6f3300ad | Peter Maydell | } |
343 | 6f3300ad | Peter Maydell | |
344 | c30fe7df | Christophe Lyon | INLINE float32 float32_set_sign(float32 a, int sign)
|
345 | c30fe7df | Christophe Lyon | { |
346 | c30fe7df | Christophe Lyon | return make_float32((float32_val(a) & 0x7fffffff) | (sign << 31)); |
347 | c30fe7df | Christophe Lyon | } |
348 | c30fe7df | Christophe Lyon | |
349 | f090c9d4 | pbrook | #define float32_zero make_float32(0) |
350 | 196cfc89 | aurel32 | #define float32_one make_float32(0x3f800000) |
351 | 8229c991 | Aurelien Jarno | #define float32_ln2 make_float32(0x3f317218) |
352 | c4b4c77a | Aurelien Jarno | #define float32_pi make_float32(0x40490fdb) |
353 | c30fe7df | Christophe Lyon | #define float32_half make_float32(0x3f000000) |
354 | c30fe7df | Christophe Lyon | #define float32_infinity make_float32(0x7f800000) |
355 | f090c9d4 | pbrook | |
356 | 8559666d | Christophe Lyon | |
357 | 8559666d | Christophe Lyon | /*----------------------------------------------------------------------------
|
358 | 8559666d | Christophe Lyon | | The pattern for a default generated single-precision NaN.
|
359 | 8559666d | Christophe Lyon | *----------------------------------------------------------------------------*/
|
360 | 8559666d | Christophe Lyon | #if defined(TARGET_SPARC)
|
361 | 8559666d | Christophe Lyon | #define float32_default_nan make_float32(0x7FFFFFFF) |
362 | 8559666d | Christophe Lyon | #elif defined(TARGET_PPC) || defined(TARGET_ARM) || defined(TARGET_ALPHA)
|
363 | 8559666d | Christophe Lyon | #define float32_default_nan make_float32(0x7FC00000) |
364 | 8559666d | Christophe Lyon | #elif SNAN_BIT_IS_ONE
|
365 | 8559666d | Christophe Lyon | #define float32_default_nan make_float32(0x7FBFFFFF) |
366 | 8559666d | Christophe Lyon | #else
|
367 | 8559666d | Christophe Lyon | #define float32_default_nan make_float32(0xFFC00000) |
368 | 8559666d | Christophe Lyon | #endif
|
369 | 8559666d | Christophe Lyon | |
370 | 158142c2 | bellard | /*----------------------------------------------------------------------------
|
371 | 158142c2 | bellard | | Software IEC/IEEE double-precision conversion routines.
|
372 | 158142c2 | bellard | *----------------------------------------------------------------------------*/
|
373 | 87b8cc3c | Andreas Färber | int16 float64_to_int16_round_to_zero( float64 STATUS_PARAM ); |
374 | cbcef455 | Peter Maydell | unsigned int float64_to_uint16_round_to_zero( float64 STATUS_PARAM ); |
375 | 87b8cc3c | Andreas Färber | int32 float64_to_int32( float64 STATUS_PARAM ); |
376 | 87b8cc3c | Andreas Färber | int32 float64_to_int32_round_to_zero( float64 STATUS_PARAM ); |
377 | 87b8cc3c | Andreas Färber | uint32 float64_to_uint32( float64 STATUS_PARAM ); |
378 | 87b8cc3c | Andreas Färber | uint32 float64_to_uint32_round_to_zero( float64 STATUS_PARAM ); |
379 | 87b8cc3c | Andreas Färber | int64 float64_to_int64( float64 STATUS_PARAM ); |
380 | 87b8cc3c | Andreas Färber | int64 float64_to_int64_round_to_zero( float64 STATUS_PARAM ); |
381 | 87b8cc3c | Andreas Färber | uint64 float64_to_uint64 (float64 a STATUS_PARAM); |
382 | 87b8cc3c | Andreas Färber | uint64 float64_to_uint64_round_to_zero (float64 a STATUS_PARAM); |
383 | 158142c2 | bellard | float32 float64_to_float32( float64 STATUS_PARAM ); |
384 | 158142c2 | bellard | floatx80 float64_to_floatx80( float64 STATUS_PARAM ); |
385 | 158142c2 | bellard | float128 float64_to_float128( float64 STATUS_PARAM ); |
386 | 158142c2 | bellard | |
387 | 158142c2 | bellard | /*----------------------------------------------------------------------------
|
388 | 158142c2 | bellard | | Software IEC/IEEE double-precision operations.
|
389 | 158142c2 | bellard | *----------------------------------------------------------------------------*/
|
390 | 158142c2 | bellard | float64 float64_round_to_int( float64 STATUS_PARAM ); |
391 | e6e5906b | pbrook | float64 float64_trunc_to_int( float64 STATUS_PARAM ); |
392 | 158142c2 | bellard | float64 float64_add( float64, float64 STATUS_PARAM ); |
393 | 158142c2 | bellard | float64 float64_sub( float64, float64 STATUS_PARAM ); |
394 | 158142c2 | bellard | float64 float64_mul( float64, float64 STATUS_PARAM ); |
395 | 158142c2 | bellard | float64 float64_div( float64, float64 STATUS_PARAM ); |
396 | 158142c2 | bellard | float64 float64_rem( float64, float64 STATUS_PARAM ); |
397 | 158142c2 | bellard | float64 float64_sqrt( float64 STATUS_PARAM ); |
398 | 374dfc33 | aurel32 | float64 float64_log2( float64 STATUS_PARAM ); |
399 | b689362d | Aurelien Jarno | int float64_eq( float64, float64 STATUS_PARAM );
|
400 | 750afe93 | bellard | int float64_le( float64, float64 STATUS_PARAM );
|
401 | 750afe93 | bellard | int float64_lt( float64, float64 STATUS_PARAM );
|
402 | 67b7861d | Aurelien Jarno | int float64_unordered( float64, float64 STATUS_PARAM );
|
403 | b689362d | Aurelien Jarno | int float64_eq_quiet( float64, float64 STATUS_PARAM );
|
404 | 750afe93 | bellard | int float64_le_quiet( float64, float64 STATUS_PARAM );
|
405 | 750afe93 | bellard | int float64_lt_quiet( float64, float64 STATUS_PARAM );
|
406 | 67b7861d | Aurelien Jarno | int float64_unordered_quiet( float64, float64 STATUS_PARAM );
|
407 | 750afe93 | bellard | int float64_compare( float64, float64 STATUS_PARAM );
|
408 | 750afe93 | bellard | int float64_compare_quiet( float64, float64 STATUS_PARAM );
|
409 | 274f1b04 | Peter Maydell | float64 float64_min(float64, float64 STATUS_PARAM); |
410 | 274f1b04 | Peter Maydell | float64 float64_max(float64, float64 STATUS_PARAM); |
411 | 18569871 | Peter Maydell | int float64_is_quiet_nan( float64 a );
|
412 | 750afe93 | bellard | int float64_is_signaling_nan( float64 );
|
413 | b408dbde | Peter Maydell | float64 float64_maybe_silence_nan( float64 ); |
414 | 9ee6e8bb | pbrook | float64 float64_scalbn( float64, int STATUS_PARAM );
|
415 | 158142c2 | bellard | |
416 | 1d6bda35 | bellard | INLINE float64 float64_abs(float64 a) |
417 | 1d6bda35 | bellard | { |
418 | 37d18660 | Peter Maydell | /* Note that abs does *not* handle NaN specially, nor does
|
419 | 37d18660 | Peter Maydell | * it flush denormal inputs to zero.
|
420 | 37d18660 | Peter Maydell | */
|
421 | f090c9d4 | pbrook | return make_float64(float64_val(a) & 0x7fffffffffffffffLL); |
422 | 1d6bda35 | bellard | } |
423 | 1d6bda35 | bellard | |
424 | 1d6bda35 | bellard | INLINE float64 float64_chs(float64 a) |
425 | 1d6bda35 | bellard | { |
426 | 37d18660 | Peter Maydell | /* Note that chs does *not* handle NaN specially, nor does
|
427 | 37d18660 | Peter Maydell | * it flush denormal inputs to zero.
|
428 | 37d18660 | Peter Maydell | */
|
429 | f090c9d4 | pbrook | return make_float64(float64_val(a) ^ 0x8000000000000000LL); |
430 | 1d6bda35 | bellard | } |
431 | 1d6bda35 | bellard | |
432 | c52ab6f5 | aurel32 | INLINE int float64_is_infinity(float64 a)
|
433 | c52ab6f5 | aurel32 | { |
434 | c52ab6f5 | aurel32 | return (float64_val(a) & 0x7fffffffffffffffLL ) == 0x7ff0000000000000LL; |
435 | c52ab6f5 | aurel32 | } |
436 | c52ab6f5 | aurel32 | |
437 | c52ab6f5 | aurel32 | INLINE int float64_is_neg(float64 a)
|
438 | c52ab6f5 | aurel32 | { |
439 | c52ab6f5 | aurel32 | return float64_val(a) >> 63; |
440 | c52ab6f5 | aurel32 | } |
441 | c52ab6f5 | aurel32 | |
442 | c52ab6f5 | aurel32 | INLINE int float64_is_zero(float64 a)
|
443 | c52ab6f5 | aurel32 | { |
444 | c52ab6f5 | aurel32 | return (float64_val(a) & 0x7fffffffffffffffLL) == 0; |
445 | c52ab6f5 | aurel32 | } |
446 | c52ab6f5 | aurel32 | |
447 | 21d6ebde | Peter Maydell | INLINE int float64_is_any_nan(float64 a)
|
448 | 21d6ebde | Peter Maydell | { |
449 | 21d6ebde | Peter Maydell | return ((float64_val(a) & ~(1ULL << 63)) > 0x7ff0000000000000ULL); |
450 | 21d6ebde | Peter Maydell | } |
451 | 21d6ebde | Peter Maydell | |
452 | 587eabfa | Aurelien Jarno | INLINE int float64_is_zero_or_denormal(float64 a)
|
453 | 587eabfa | Aurelien Jarno | { |
454 | 587eabfa | Aurelien Jarno | return (float64_val(a) & 0x7ff0000000000000LL) == 0; |
455 | 587eabfa | Aurelien Jarno | } |
456 | 587eabfa | Aurelien Jarno | |
457 | c30fe7df | Christophe Lyon | INLINE float64 float64_set_sign(float64 a, int sign)
|
458 | c30fe7df | Christophe Lyon | { |
459 | c30fe7df | Christophe Lyon | return make_float64((float64_val(a) & 0x7fffffffffffffffULL) |
460 | c30fe7df | Christophe Lyon | | ((int64_t)sign << 63));
|
461 | c30fe7df | Christophe Lyon | } |
462 | c30fe7df | Christophe Lyon | |
463 | f090c9d4 | pbrook | #define float64_zero make_float64(0) |
464 | 196cfc89 | aurel32 | #define float64_one make_float64(0x3ff0000000000000LL) |
465 | 8229c991 | Aurelien Jarno | #define float64_ln2 make_float64(0x3fe62e42fefa39efLL) |
466 | c4b4c77a | Aurelien Jarno | #define float64_pi make_float64(0x400921fb54442d18LL) |
467 | c30fe7df | Christophe Lyon | #define float64_half make_float64(0x3fe0000000000000LL) |
468 | c30fe7df | Christophe Lyon | #define float64_infinity make_float64(0x7ff0000000000000LL) |
469 | f090c9d4 | pbrook | |
470 | 8559666d | Christophe Lyon | /*----------------------------------------------------------------------------
|
471 | 8559666d | Christophe Lyon | | The pattern for a default generated double-precision NaN.
|
472 | 8559666d | Christophe Lyon | *----------------------------------------------------------------------------*/
|
473 | 8559666d | Christophe Lyon | #if defined(TARGET_SPARC)
|
474 | 8559666d | Christophe Lyon | #define float64_default_nan make_float64(LIT64( 0x7FFFFFFFFFFFFFFF )) |
475 | 8559666d | Christophe Lyon | #elif defined(TARGET_PPC) || defined(TARGET_ARM) || defined(TARGET_ALPHA)
|
476 | 8559666d | Christophe Lyon | #define float64_default_nan make_float64(LIT64( 0x7FF8000000000000 )) |
477 | 8559666d | Christophe Lyon | #elif SNAN_BIT_IS_ONE
|
478 | 8559666d | Christophe Lyon | #define float64_default_nan make_float64(LIT64( 0x7FF7FFFFFFFFFFFF )) |
479 | 8559666d | Christophe Lyon | #else
|
480 | 8559666d | Christophe Lyon | #define float64_default_nan make_float64(LIT64( 0xFFF8000000000000 )) |
481 | 8559666d | Christophe Lyon | #endif
|
482 | 8559666d | Christophe Lyon | |
483 | 158142c2 | bellard | /*----------------------------------------------------------------------------
|
484 | 158142c2 | bellard | | Software IEC/IEEE extended double-precision conversion routines.
|
485 | 158142c2 | bellard | *----------------------------------------------------------------------------*/
|
486 | 87b8cc3c | Andreas Färber | int32 floatx80_to_int32( floatx80 STATUS_PARAM ); |
487 | 87b8cc3c | Andreas Färber | int32 floatx80_to_int32_round_to_zero( floatx80 STATUS_PARAM ); |
488 | 87b8cc3c | Andreas Färber | int64 floatx80_to_int64( floatx80 STATUS_PARAM ); |
489 | 87b8cc3c | Andreas Färber | int64 floatx80_to_int64_round_to_zero( floatx80 STATUS_PARAM ); |
490 | 158142c2 | bellard | float32 floatx80_to_float32( floatx80 STATUS_PARAM ); |
491 | 158142c2 | bellard | float64 floatx80_to_float64( floatx80 STATUS_PARAM ); |
492 | 158142c2 | bellard | float128 floatx80_to_float128( floatx80 STATUS_PARAM ); |
493 | 158142c2 | bellard | |
494 | 158142c2 | bellard | /*----------------------------------------------------------------------------
|
495 | 158142c2 | bellard | | Software IEC/IEEE extended double-precision operations.
|
496 | 158142c2 | bellard | *----------------------------------------------------------------------------*/
|
497 | 158142c2 | bellard | floatx80 floatx80_round_to_int( floatx80 STATUS_PARAM ); |
498 | 158142c2 | bellard | floatx80 floatx80_add( floatx80, floatx80 STATUS_PARAM ); |
499 | 158142c2 | bellard | floatx80 floatx80_sub( floatx80, floatx80 STATUS_PARAM ); |
500 | 158142c2 | bellard | floatx80 floatx80_mul( floatx80, floatx80 STATUS_PARAM ); |
501 | 158142c2 | bellard | floatx80 floatx80_div( floatx80, floatx80 STATUS_PARAM ); |
502 | 158142c2 | bellard | floatx80 floatx80_rem( floatx80, floatx80 STATUS_PARAM ); |
503 | 158142c2 | bellard | floatx80 floatx80_sqrt( floatx80 STATUS_PARAM ); |
504 | b689362d | Aurelien Jarno | int floatx80_eq( floatx80, floatx80 STATUS_PARAM );
|
505 | 750afe93 | bellard | int floatx80_le( floatx80, floatx80 STATUS_PARAM );
|
506 | 750afe93 | bellard | int floatx80_lt( floatx80, floatx80 STATUS_PARAM );
|
507 | 67b7861d | Aurelien Jarno | int floatx80_unordered( floatx80, floatx80 STATUS_PARAM );
|
508 | b689362d | Aurelien Jarno | int floatx80_eq_quiet( floatx80, floatx80 STATUS_PARAM );
|
509 | 750afe93 | bellard | int floatx80_le_quiet( floatx80, floatx80 STATUS_PARAM );
|
510 | 750afe93 | bellard | int floatx80_lt_quiet( floatx80, floatx80 STATUS_PARAM );
|
511 | 67b7861d | Aurelien Jarno | int floatx80_unordered_quiet( floatx80, floatx80 STATUS_PARAM );
|
512 | f6714d36 | Aurelien Jarno | int floatx80_compare( floatx80, floatx80 STATUS_PARAM );
|
513 | f6714d36 | Aurelien Jarno | int floatx80_compare_quiet( floatx80, floatx80 STATUS_PARAM );
|
514 | 18569871 | Peter Maydell | int floatx80_is_quiet_nan( floatx80 );
|
515 | 750afe93 | bellard | int floatx80_is_signaling_nan( floatx80 );
|
516 | f6a7d92a | Aurelien Jarno | floatx80 floatx80_maybe_silence_nan( floatx80 ); |
517 | 9ee6e8bb | pbrook | floatx80 floatx80_scalbn( floatx80, int STATUS_PARAM );
|
518 | 158142c2 | bellard | |
519 | 1d6bda35 | bellard | INLINE floatx80 floatx80_abs(floatx80 a) |
520 | 1d6bda35 | bellard | { |
521 | 1d6bda35 | bellard | a.high &= 0x7fff;
|
522 | 1d6bda35 | bellard | return a;
|
523 | 1d6bda35 | bellard | } |
524 | 1d6bda35 | bellard | |
525 | 1d6bda35 | bellard | INLINE floatx80 floatx80_chs(floatx80 a) |
526 | 1d6bda35 | bellard | { |
527 | 1d6bda35 | bellard | a.high ^= 0x8000;
|
528 | 1d6bda35 | bellard | return a;
|
529 | 1d6bda35 | bellard | } |
530 | 1d6bda35 | bellard | |
531 | c52ab6f5 | aurel32 | INLINE int floatx80_is_infinity(floatx80 a)
|
532 | c52ab6f5 | aurel32 | { |
533 | b76235e4 | Aurelien Jarno | return (a.high & 0x7fff) == 0x7fff && a.low == 0x8000000000000000LL; |
534 | c52ab6f5 | aurel32 | } |
535 | c52ab6f5 | aurel32 | |
536 | c52ab6f5 | aurel32 | INLINE int floatx80_is_neg(floatx80 a)
|
537 | c52ab6f5 | aurel32 | { |
538 | c52ab6f5 | aurel32 | return a.high >> 15; |
539 | c52ab6f5 | aurel32 | } |
540 | c52ab6f5 | aurel32 | |
541 | c52ab6f5 | aurel32 | INLINE int floatx80_is_zero(floatx80 a)
|
542 | c52ab6f5 | aurel32 | { |
543 | c52ab6f5 | aurel32 | return (a.high & 0x7fff) == 0 && a.low == 0; |
544 | c52ab6f5 | aurel32 | } |
545 | c52ab6f5 | aurel32 | |
546 | 587eabfa | Aurelien Jarno | INLINE int floatx80_is_zero_or_denormal(floatx80 a)
|
547 | 587eabfa | Aurelien Jarno | { |
548 | 587eabfa | Aurelien Jarno | return (a.high & 0x7fff) == 0; |
549 | 587eabfa | Aurelien Jarno | } |
550 | 587eabfa | Aurelien Jarno | |
551 | 2bed652f | Peter Maydell | INLINE int floatx80_is_any_nan(floatx80 a)
|
552 | 2bed652f | Peter Maydell | { |
553 | 2bed652f | Peter Maydell | return ((a.high & 0x7fff) == 0x7fff) && (a.low<<1); |
554 | 2bed652f | Peter Maydell | } |
555 | 2bed652f | Peter Maydell | |
556 | f3218a8d | Aurelien Jarno | #define floatx80_zero make_floatx80(0x0000, 0x0000000000000000LL) |
557 | f3218a8d | Aurelien Jarno | #define floatx80_one make_floatx80(0x3fff, 0x8000000000000000LL) |
558 | f3218a8d | Aurelien Jarno | #define floatx80_ln2 make_floatx80(0x3ffe, 0xb17217f7d1cf79acLL) |
559 | c4b4c77a | Aurelien Jarno | #define floatx80_pi make_floatx80(0x4000, 0xc90fdaa22168c235LL) |
560 | f3218a8d | Aurelien Jarno | #define floatx80_half make_floatx80(0x3ffe, 0x8000000000000000LL) |
561 | f3218a8d | Aurelien Jarno | #define floatx80_infinity make_floatx80(0x7fff, 0x8000000000000000LL) |
562 | f3218a8d | Aurelien Jarno | |
563 | 8559666d | Christophe Lyon | /*----------------------------------------------------------------------------
|
564 | 8559666d | Christophe Lyon | | The pattern for a default generated extended double-precision NaN. The
|
565 | 8559666d | Christophe Lyon | | `high' and `low' values hold the most- and least-significant bits,
|
566 | 8559666d | Christophe Lyon | | respectively.
|
567 | 8559666d | Christophe Lyon | *----------------------------------------------------------------------------*/
|
568 | 8559666d | Christophe Lyon | #if SNAN_BIT_IS_ONE
|
569 | 8559666d | Christophe Lyon | #define floatx80_default_nan_high 0x7FFF |
570 | 8559666d | Christophe Lyon | #define floatx80_default_nan_low LIT64( 0xBFFFFFFFFFFFFFFF ) |
571 | 8559666d | Christophe Lyon | #else
|
572 | 8559666d | Christophe Lyon | #define floatx80_default_nan_high 0xFFFF |
573 | 8559666d | Christophe Lyon | #define floatx80_default_nan_low LIT64( 0xC000000000000000 ) |
574 | 8559666d | Christophe Lyon | #endif
|
575 | 8559666d | Christophe Lyon | |
576 | 158142c2 | bellard | /*----------------------------------------------------------------------------
|
577 | 158142c2 | bellard | | Software IEC/IEEE quadruple-precision conversion routines.
|
578 | 158142c2 | bellard | *----------------------------------------------------------------------------*/
|
579 | 87b8cc3c | Andreas Färber | int32 float128_to_int32( float128 STATUS_PARAM ); |
580 | 87b8cc3c | Andreas Färber | int32 float128_to_int32_round_to_zero( float128 STATUS_PARAM ); |
581 | 87b8cc3c | Andreas Färber | int64 float128_to_int64( float128 STATUS_PARAM ); |
582 | 87b8cc3c | Andreas Färber | int64 float128_to_int64_round_to_zero( float128 STATUS_PARAM ); |
583 | 158142c2 | bellard | float32 float128_to_float32( float128 STATUS_PARAM ); |
584 | 158142c2 | bellard | float64 float128_to_float64( float128 STATUS_PARAM ); |
585 | 158142c2 | bellard | floatx80 float128_to_floatx80( float128 STATUS_PARAM ); |
586 | 158142c2 | bellard | |
587 | 158142c2 | bellard | /*----------------------------------------------------------------------------
|
588 | 158142c2 | bellard | | Software IEC/IEEE quadruple-precision operations.
|
589 | 158142c2 | bellard | *----------------------------------------------------------------------------*/
|
590 | 158142c2 | bellard | float128 float128_round_to_int( float128 STATUS_PARAM ); |
591 | 158142c2 | bellard | float128 float128_add( float128, float128 STATUS_PARAM ); |
592 | 158142c2 | bellard | float128 float128_sub( float128, float128 STATUS_PARAM ); |
593 | 158142c2 | bellard | float128 float128_mul( float128, float128 STATUS_PARAM ); |
594 | 158142c2 | bellard | float128 float128_div( float128, float128 STATUS_PARAM ); |
595 | 158142c2 | bellard | float128 float128_rem( float128, float128 STATUS_PARAM ); |
596 | 158142c2 | bellard | float128 float128_sqrt( float128 STATUS_PARAM ); |
597 | b689362d | Aurelien Jarno | int float128_eq( float128, float128 STATUS_PARAM );
|
598 | 750afe93 | bellard | int float128_le( float128, float128 STATUS_PARAM );
|
599 | 750afe93 | bellard | int float128_lt( float128, float128 STATUS_PARAM );
|
600 | 67b7861d | Aurelien Jarno | int float128_unordered( float128, float128 STATUS_PARAM );
|
601 | b689362d | Aurelien Jarno | int float128_eq_quiet( float128, float128 STATUS_PARAM );
|
602 | 750afe93 | bellard | int float128_le_quiet( float128, float128 STATUS_PARAM );
|
603 | 750afe93 | bellard | int float128_lt_quiet( float128, float128 STATUS_PARAM );
|
604 | 67b7861d | Aurelien Jarno | int float128_unordered_quiet( float128, float128 STATUS_PARAM );
|
605 | 1f587329 | blueswir1 | int float128_compare( float128, float128 STATUS_PARAM );
|
606 | 1f587329 | blueswir1 | int float128_compare_quiet( float128, float128 STATUS_PARAM );
|
607 | 18569871 | Peter Maydell | int float128_is_quiet_nan( float128 );
|
608 | 750afe93 | bellard | int float128_is_signaling_nan( float128 );
|
609 | f6a7d92a | Aurelien Jarno | float128 float128_maybe_silence_nan( float128 ); |
610 | 9ee6e8bb | pbrook | float128 float128_scalbn( float128, int STATUS_PARAM );
|
611 | 158142c2 | bellard | |
612 | 1d6bda35 | bellard | INLINE float128 float128_abs(float128 a) |
613 | 1d6bda35 | bellard | { |
614 | 1d6bda35 | bellard | a.high &= 0x7fffffffffffffffLL;
|
615 | 1d6bda35 | bellard | return a;
|
616 | 1d6bda35 | bellard | } |
617 | 1d6bda35 | bellard | |
618 | 1d6bda35 | bellard | INLINE float128 float128_chs(float128 a) |
619 | 1d6bda35 | bellard | { |
620 | 1d6bda35 | bellard | a.high ^= 0x8000000000000000LL;
|
621 | 1d6bda35 | bellard | return a;
|
622 | 1d6bda35 | bellard | } |
623 | 1d6bda35 | bellard | |
624 | c52ab6f5 | aurel32 | INLINE int float128_is_infinity(float128 a)
|
625 | c52ab6f5 | aurel32 | { |
626 | c52ab6f5 | aurel32 | return (a.high & 0x7fffffffffffffffLL) == 0x7fff000000000000LL && a.low == 0; |
627 | c52ab6f5 | aurel32 | } |
628 | c52ab6f5 | aurel32 | |
629 | c52ab6f5 | aurel32 | INLINE int float128_is_neg(float128 a)
|
630 | c52ab6f5 | aurel32 | { |
631 | c52ab6f5 | aurel32 | return a.high >> 63; |
632 | c52ab6f5 | aurel32 | } |
633 | c52ab6f5 | aurel32 | |
634 | c52ab6f5 | aurel32 | INLINE int float128_is_zero(float128 a)
|
635 | c52ab6f5 | aurel32 | { |
636 | c52ab6f5 | aurel32 | return (a.high & 0x7fffffffffffffffLL) == 0 && a.low == 0; |
637 | c52ab6f5 | aurel32 | } |
638 | c52ab6f5 | aurel32 | |
639 | 587eabfa | Aurelien Jarno | INLINE int float128_is_zero_or_denormal(float128 a)
|
640 | 587eabfa | Aurelien Jarno | { |
641 | 587eabfa | Aurelien Jarno | return (a.high & 0x7fff000000000000LL) == 0; |
642 | 587eabfa | Aurelien Jarno | } |
643 | 587eabfa | Aurelien Jarno | |
644 | 2bed652f | Peter Maydell | INLINE int float128_is_any_nan(float128 a)
|
645 | 2bed652f | Peter Maydell | { |
646 | 2bed652f | Peter Maydell | return ((a.high >> 48) & 0x7fff) == 0x7fff && |
647 | 2bed652f | Peter Maydell | ((a.low != 0) || ((a.high & 0xffffffffffffLL) != 0)); |
648 | 2bed652f | Peter Maydell | } |
649 | 2bed652f | Peter Maydell | |
650 | 8559666d | Christophe Lyon | /*----------------------------------------------------------------------------
|
651 | 8559666d | Christophe Lyon | | The pattern for a default generated quadruple-precision NaN. The `high' and
|
652 | 8559666d | Christophe Lyon | | `low' values hold the most- and least-significant bits, respectively.
|
653 | 8559666d | Christophe Lyon | *----------------------------------------------------------------------------*/
|
654 | 8559666d | Christophe Lyon | #if SNAN_BIT_IS_ONE
|
655 | 8559666d | Christophe Lyon | #define float128_default_nan_high LIT64( 0x7FFF7FFFFFFFFFFF ) |
656 | 8559666d | Christophe Lyon | #define float128_default_nan_low LIT64( 0xFFFFFFFFFFFFFFFF ) |
657 | 8559666d | Christophe Lyon | #else
|
658 | 8559666d | Christophe Lyon | #define float128_default_nan_high LIT64( 0xFFFF800000000000 ) |
659 | 8559666d | Christophe Lyon | #define float128_default_nan_low LIT64( 0x0000000000000000 ) |
660 | 8559666d | Christophe Lyon | #endif
|
661 | 8559666d | Christophe Lyon | |
662 | 158142c2 | bellard | #endif /* !SOFTFLOAT_H */ |