Andreas Färber | 8d725fa | 2011-03-07 01:34:04 +0100 | [diff] [blame] | 1 | /* |
| 2 | * QEMU float support |
| 3 | * |
Peter Maydell | 242695d | 2014-11-24 18:43:26 +0000 | [diff] [blame] | 4 | * The code in this source file is derived from release 2a of the SoftFloat |
| 5 | * IEC/IEEE Floating-point Arithmetic Package. Those parts of the code (and |
| 6 | * some later contributions) are provided under that license, as detailed below. |
| 7 | * It has subsequently been modified by contributors to the QEMU Project, |
| 8 | * so some portions are provided under: |
| 9 | * the SoftFloat-2a license |
| 10 | * the BSD license |
| 11 | * GPL-v2-or-later |
| 12 | * |
| 13 | * Any future contributions to this file after December 1st 2014 |
| 14 | * will be taken to be licensed under GPL-v2-or-later unless specifically |
| 15 | * indicated otherwise. See the COPYING file in the top-level directory. |
Andreas Färber | 8d725fa | 2011-03-07 01:34:04 +0100 | [diff] [blame] | 16 | */ |
| 17 | |
Peter Maydell | 2b6fee5 | 2014-11-21 22:41:09 +0000 | [diff] [blame] | 18 | /* |
| 19 | =============================================================================== |
| 20 | This C header file is part of the SoftFloat IEC/IEEE Floating-point |
| 21 | Arithmetic Package, Release 2a. |
bellard | 158142c | 2005-03-13 16:54:06 +0000 | [diff] [blame] | 22 | |
| 23 | Written by John R. Hauser. This work was made possible in part by the |
| 24 | International Computer Science Institute, located at Suite 600, 1947 Center |
| 25 | Street, Berkeley, California 94704. Funding was partially provided by the |
| 26 | National Science Foundation under grant MIP-9311980. The original version |
| 27 | of this code was written as part of a project to build a fixed-point vector |
| 28 | processor in collaboration with the University of California at Berkeley, |
| 29 | overseen by Profs. Nelson Morgan and John Wawrzynek. More information |
Peter Maydell | 2b6fee5 | 2014-11-21 22:41:09 +0000 | [diff] [blame] | 30 | is available through the Web page `http://HTTP.CS.Berkeley.EDU/~jhauser/ |
bellard | 158142c | 2005-03-13 16:54:06 +0000 | [diff] [blame] | 31 | arithmetic/SoftFloat.html'. |
| 32 | |
Peter Maydell | 2b6fee5 | 2014-11-21 22:41:09 +0000 | [diff] [blame] | 33 | THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort |
| 34 | has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT |
| 35 | TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO |
| 36 | PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY |
| 37 | AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE. |
bellard | 158142c | 2005-03-13 16:54:06 +0000 | [diff] [blame] | 38 | |
| 39 | Derivative works are acceptable, even for commercial purposes, so long as |
Peter Maydell | 2b6fee5 | 2014-11-21 22:41:09 +0000 | [diff] [blame] | 40 | (1) they include prominent notice that the work is derivative, and (2) they |
| 41 | include prominent notice akin to these four paragraphs for those parts of |
| 42 | this code that are retained. |
bellard | 158142c | 2005-03-13 16:54:06 +0000 | [diff] [blame] | 43 | |
Peter Maydell | 2b6fee5 | 2014-11-21 22:41:09 +0000 | [diff] [blame] | 44 | =============================================================================== |
| 45 | */ |
bellard | 158142c | 2005-03-13 16:54:06 +0000 | [diff] [blame] | 46 | |
Peter Maydell | 242695d | 2014-11-24 18:43:26 +0000 | [diff] [blame] | 47 | /* BSD licensing: |
| 48 | * Copyright (c) 2006, Fabrice Bellard |
| 49 | * All rights reserved. |
| 50 | * |
| 51 | * Redistribution and use in source and binary forms, with or without |
| 52 | * modification, are permitted provided that the following conditions are met: |
| 53 | * |
| 54 | * 1. Redistributions of source code must retain the above copyright notice, |
| 55 | * this list of conditions and the following disclaimer. |
| 56 | * |
| 57 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
| 58 | * this list of conditions and the following disclaimer in the documentation |
| 59 | * and/or other materials provided with the distribution. |
| 60 | * |
| 61 | * 3. Neither the name of the copyright holder nor the names of its contributors |
| 62 | * may be used to endorse or promote products derived from this software without |
| 63 | * specific prior written permission. |
| 64 | * |
| 65 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 66 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 67 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 68 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
| 69 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 70 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 71 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 72 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 73 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 74 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
| 75 | * THE POSSIBILITY OF SUCH DAMAGE. |
| 76 | */ |
| 77 | |
| 78 | /* Portions of this work are licensed under the terms of the GNU GPL, |
| 79 | * version 2 or later. See the COPYING file in the top-level directory. |
| 80 | */ |
| 81 | |
bellard | 158142c | 2005-03-13 16:54:06 +0000 | [diff] [blame] | 82 | #ifndef SOFTFLOAT_H |
| 83 | #define SOFTFLOAT_H |
| 84 | |
Juan Quintela | 75b5a69 | 2009-07-27 16:13:23 +0200 | [diff] [blame] | 85 | #if defined(CONFIG_SOLARIS) && defined(CONFIG_NEEDS_LIBSUNMATH) |
ths | 0475a5c | 2007-04-01 18:54:44 +0000 | [diff] [blame] | 86 | #include <sunmath.h> |
| 87 | #endif |
| 88 | |
bellard | 158142c | 2005-03-13 16:54:06 +0000 | [diff] [blame] | 89 | #include <inttypes.h> |
Paolo Bonzini | 789ec7c | 2011-07-28 12:10:29 +0200 | [diff] [blame] | 90 | #include "config-host.h" |
Paolo Bonzini | 1de7afc | 2012-12-17 18:20:00 +0100 | [diff] [blame] | 91 | #include "qemu/osdep.h" |
bellard | 158142c | 2005-03-13 16:54:06 +0000 | [diff] [blame] | 92 | |
| 93 | /*---------------------------------------------------------------------------- |
| 94 | | Each of the following `typedef's defines the most convenient type that holds |
| 95 | | integers of at least as many bits as specified. For example, `uint8' should |
| 96 | | be the most convenient type that can hold unsigned integers of as many as |
| 97 | | 8 bits. The `flag' type must be able to hold either a 0 or 1. For most |
| 98 | | implementations of C, `flag', `uint8', and `int8' should all be `typedef'ed |
| 99 | | to the same as `int'. |
| 100 | *----------------------------------------------------------------------------*/ |
bellard | 750afe9 | 2006-10-28 19:27:11 +0000 | [diff] [blame] | 101 | typedef uint8_t flag; |
bellard | 158142c | 2005-03-13 16:54:06 +0000 | [diff] [blame] | 102 | typedef uint8_t uint8; |
| 103 | typedef int8_t int8; |
bellard | 158142c | 2005-03-13 16:54:06 +0000 | [diff] [blame] | 104 | typedef unsigned int uint32; |
| 105 | typedef signed int int32; |
| 106 | typedef uint64_t uint64; |
| 107 | typedef int64_t int64; |
| 108 | |
bellard | 158142c | 2005-03-13 16:54:06 +0000 | [diff] [blame] | 109 | #define LIT64( a ) a##LL |
bellard | 158142c | 2005-03-13 16:54:06 +0000 | [diff] [blame] | 110 | |
bellard | 158142c | 2005-03-13 16:54:06 +0000 | [diff] [blame] | 111 | #define STATUS_PARAM , float_status *status |
| 112 | #define STATUS(field) status->field |
| 113 | #define STATUS_VAR , status |
| 114 | |
bellard | 1d6bda3 | 2005-03-13 18:52:29 +0000 | [diff] [blame] | 115 | /*---------------------------------------------------------------------------- |
| 116 | | Software IEC/IEEE floating-point ordering relations |
| 117 | *----------------------------------------------------------------------------*/ |
| 118 | enum { |
| 119 | float_relation_less = -1, |
| 120 | float_relation_equal = 0, |
| 121 | float_relation_greater = 1, |
| 122 | float_relation_unordered = 2 |
| 123 | }; |
| 124 | |
bellard | 158142c | 2005-03-13 16:54:06 +0000 | [diff] [blame] | 125 | /*---------------------------------------------------------------------------- |
| 126 | | Software IEC/IEEE floating-point types. |
| 127 | *----------------------------------------------------------------------------*/ |
pbrook | f090c9d | 2007-11-18 14:33:24 +0000 | [diff] [blame] | 128 | /* Use structures for soft-float types. This prevents accidentally mixing |
| 129 | them with native int/float types. A sufficiently clever compiler and |
| 130 | sane ABI should be able to see though these structs. However |
| 131 | x86/gcc 3.x seems to struggle a bit, so leave them disabled by default. */ |
| 132 | //#define USE_SOFTFLOAT_STRUCT_TYPES |
| 133 | #ifdef USE_SOFTFLOAT_STRUCT_TYPES |
| 134 | typedef struct { |
Peter Maydell | bb4d4bb | 2011-02-10 11:28:56 +0000 | [diff] [blame] | 135 | uint16_t v; |
| 136 | } float16; |
| 137 | #define float16_val(x) (((float16)(x)).v) |
| 138 | #define make_float16(x) __extension__ ({ float16 f16_val = {x}; f16_val; }) |
Peter Maydell | d5138cf | 2011-02-10 13:59:34 +0000 | [diff] [blame] | 139 | #define const_float16(x) { x } |
Peter Maydell | bb4d4bb | 2011-02-10 11:28:56 +0000 | [diff] [blame] | 140 | typedef struct { |
pbrook | f090c9d | 2007-11-18 14:33:24 +0000 | [diff] [blame] | 141 | uint32_t v; |
| 142 | } float32; |
| 143 | /* The cast ensures an error if the wrong type is passed. */ |
| 144 | #define float32_val(x) (((float32)(x)).v) |
| 145 | #define make_float32(x) __extension__ ({ float32 f32_val = {x}; f32_val; }) |
Peter Maydell | d5138cf | 2011-02-10 13:59:34 +0000 | [diff] [blame] | 146 | #define const_float32(x) { x } |
pbrook | f090c9d | 2007-11-18 14:33:24 +0000 | [diff] [blame] | 147 | typedef struct { |
| 148 | uint64_t v; |
| 149 | } float64; |
| 150 | #define float64_val(x) (((float64)(x)).v) |
| 151 | #define make_float64(x) __extension__ ({ float64 f64_val = {x}; f64_val; }) |
Peter Maydell | d5138cf | 2011-02-10 13:59:34 +0000 | [diff] [blame] | 152 | #define const_float64(x) { x } |
pbrook | f090c9d | 2007-11-18 14:33:24 +0000 | [diff] [blame] | 153 | #else |
Peter Maydell | bb4d4bb | 2011-02-10 11:28:56 +0000 | [diff] [blame] | 154 | typedef uint16_t float16; |
bellard | 158142c | 2005-03-13 16:54:06 +0000 | [diff] [blame] | 155 | typedef uint32_t float32; |
| 156 | typedef uint64_t float64; |
Peter Maydell | bb4d4bb | 2011-02-10 11:28:56 +0000 | [diff] [blame] | 157 | #define float16_val(x) (x) |
pbrook | f090c9d | 2007-11-18 14:33:24 +0000 | [diff] [blame] | 158 | #define float32_val(x) (x) |
| 159 | #define float64_val(x) (x) |
Peter Maydell | bb4d4bb | 2011-02-10 11:28:56 +0000 | [diff] [blame] | 160 | #define make_float16(x) (x) |
pbrook | f090c9d | 2007-11-18 14:33:24 +0000 | [diff] [blame] | 161 | #define make_float32(x) (x) |
| 162 | #define make_float64(x) (x) |
Peter Maydell | d5138cf | 2011-02-10 13:59:34 +0000 | [diff] [blame] | 163 | #define const_float16(x) (x) |
| 164 | #define const_float32(x) (x) |
| 165 | #define const_float64(x) (x) |
pbrook | f090c9d | 2007-11-18 14:33:24 +0000 | [diff] [blame] | 166 | #endif |
bellard | 158142c | 2005-03-13 16:54:06 +0000 | [diff] [blame] | 167 | typedef struct { |
| 168 | uint64_t low; |
| 169 | uint16_t high; |
| 170 | } floatx80; |
Aurelien Jarno | f3218a8 | 2011-04-20 13:04:22 +0200 | [diff] [blame] | 171 | #define make_floatx80(exp, mant) ((floatx80) { mant, exp }) |
Avi Kivity | 3bf7e40 | 2011-12-27 17:11:20 +0200 | [diff] [blame] | 172 | #define make_floatx80_init(exp, mant) { .low = mant, .high = exp } |
bellard | 158142c | 2005-03-13 16:54:06 +0000 | [diff] [blame] | 173 | typedef struct { |
Juan Quintela | e2542fe | 2009-07-27 16:13:06 +0200 | [diff] [blame] | 174 | #ifdef HOST_WORDS_BIGENDIAN |
bellard | 158142c | 2005-03-13 16:54:06 +0000 | [diff] [blame] | 175 | uint64_t high, low; |
| 176 | #else |
| 177 | uint64_t low, high; |
| 178 | #endif |
| 179 | } float128; |
Paolo Bonzini | 789ec7c | 2011-07-28 12:10:29 +0200 | [diff] [blame] | 180 | #define make_float128(high_, low_) ((float128) { .high = high_, .low = low_ }) |
Avi Kivity | 3bf7e40 | 2011-12-27 17:11:20 +0200 | [diff] [blame] | 181 | #define make_float128_init(high_, low_) { .high = high_, .low = low_ } |
bellard | 158142c | 2005-03-13 16:54:06 +0000 | [diff] [blame] | 182 | |
| 183 | /*---------------------------------------------------------------------------- |
| 184 | | Software IEC/IEEE floating-point underflow tininess-detection mode. |
| 185 | *----------------------------------------------------------------------------*/ |
| 186 | enum { |
| 187 | float_tininess_after_rounding = 0, |
| 188 | float_tininess_before_rounding = 1 |
| 189 | }; |
| 190 | |
| 191 | /*---------------------------------------------------------------------------- |
| 192 | | Software IEC/IEEE floating-point rounding mode. |
| 193 | *----------------------------------------------------------------------------*/ |
| 194 | enum { |
| 195 | float_round_nearest_even = 0, |
| 196 | float_round_down = 1, |
| 197 | float_round_up = 2, |
Peter Maydell | f9288a7 | 2014-01-07 17:19:12 +0000 | [diff] [blame] | 198 | float_round_to_zero = 3, |
| 199 | float_round_ties_away = 4, |
bellard | 158142c | 2005-03-13 16:54:06 +0000 | [diff] [blame] | 200 | }; |
| 201 | |
| 202 | /*---------------------------------------------------------------------------- |
| 203 | | Software IEC/IEEE floating-point exception flags. |
| 204 | *----------------------------------------------------------------------------*/ |
| 205 | enum { |
| 206 | float_flag_invalid = 1, |
| 207 | float_flag_divbyzero = 4, |
| 208 | float_flag_overflow = 8, |
| 209 | float_flag_underflow = 16, |
Peter Maydell | 37d1866 | 2011-01-06 19:37:53 +0000 | [diff] [blame] | 210 | float_flag_inexact = 32, |
Peter Maydell | e6afc87 | 2011-05-19 14:46:17 +0100 | [diff] [blame] | 211 | float_flag_input_denormal = 64, |
| 212 | float_flag_output_denormal = 128 |
bellard | 158142c | 2005-03-13 16:54:06 +0000 | [diff] [blame] | 213 | }; |
| 214 | |
| 215 | typedef struct float_status { |
| 216 | signed char float_detect_tininess; |
| 217 | signed char float_rounding_mode; |
| 218 | signed char float_exception_flags; |
bellard | 158142c | 2005-03-13 16:54:06 +0000 | [diff] [blame] | 219 | signed char floatx80_rounding_precision; |
Peter Maydell | 37d1866 | 2011-01-06 19:37:53 +0000 | [diff] [blame] | 220 | /* should denormalised results go to zero and set the inexact flag? */ |
pbrook | fe76d97 | 2008-12-19 14:33:59 +0000 | [diff] [blame] | 221 | flag flush_to_zero; |
Peter Maydell | 37d1866 | 2011-01-06 19:37:53 +0000 | [diff] [blame] | 222 | /* should denormalised inputs go to zero and set the input_denormal flag? */ |
| 223 | flag flush_inputs_to_zero; |
pbrook | 5c7908e | 2008-12-19 13:53:37 +0000 | [diff] [blame] | 224 | flag default_nan_mode; |
bellard | 158142c | 2005-03-13 16:54:06 +0000 | [diff] [blame] | 225 | } float_status; |
| 226 | |
Luiz Capitulino | a49db98 | 2014-06-19 10:13:43 -0400 | [diff] [blame] | 227 | static inline void set_float_detect_tininess(int val STATUS_PARAM) |
Peter Maydell | c29aca4 | 2011-04-12 13:56:40 +0100 | [diff] [blame] | 228 | { |
| 229 | STATUS(float_detect_tininess) = val; |
| 230 | } |
Luiz Capitulino | a49db98 | 2014-06-19 10:13:43 -0400 | [diff] [blame] | 231 | static inline void set_float_rounding_mode(int val STATUS_PARAM) |
Peter Maydell | 879d096 | 2014-01-07 17:19:11 +0000 | [diff] [blame] | 232 | { |
| 233 | STATUS(float_rounding_mode) = val; |
| 234 | } |
Luiz Capitulino | a49db98 | 2014-06-19 10:13:43 -0400 | [diff] [blame] | 235 | static inline void set_float_exception_flags(int val STATUS_PARAM) |
Peter Maydell | 879d096 | 2014-01-07 17:19:11 +0000 | [diff] [blame] | 236 | { |
| 237 | STATUS(float_exception_flags) = val; |
| 238 | } |
Luiz Capitulino | a49db98 | 2014-06-19 10:13:43 -0400 | [diff] [blame] | 239 | static inline void set_floatx80_rounding_precision(int val STATUS_PARAM) |
Peter Maydell | 879d096 | 2014-01-07 17:19:11 +0000 | [diff] [blame] | 240 | { |
| 241 | STATUS(floatx80_rounding_precision) = val; |
| 242 | } |
Luiz Capitulino | a49db98 | 2014-06-19 10:13:43 -0400 | [diff] [blame] | 243 | static inline void set_flush_to_zero(flag val STATUS_PARAM) |
pbrook | fe76d97 | 2008-12-19 14:33:59 +0000 | [diff] [blame] | 244 | { |
| 245 | STATUS(flush_to_zero) = val; |
| 246 | } |
Luiz Capitulino | a49db98 | 2014-06-19 10:13:43 -0400 | [diff] [blame] | 247 | static inline void set_flush_inputs_to_zero(flag val STATUS_PARAM) |
Peter Maydell | 37d1866 | 2011-01-06 19:37:53 +0000 | [diff] [blame] | 248 | { |
| 249 | STATUS(flush_inputs_to_zero) = val; |
| 250 | } |
Luiz Capitulino | a49db98 | 2014-06-19 10:13:43 -0400 | [diff] [blame] | 251 | static inline void set_default_nan_mode(flag val STATUS_PARAM) |
pbrook | 5c7908e | 2008-12-19 13:53:37 +0000 | [diff] [blame] | 252 | { |
| 253 | STATUS(default_nan_mode) = val; |
| 254 | } |
Luiz Capitulino | a49db98 | 2014-06-19 10:13:43 -0400 | [diff] [blame] | 255 | static inline int get_float_detect_tininess(float_status *status) |
Peter Maydell | 879d096 | 2014-01-07 17:19:11 +0000 | [diff] [blame] | 256 | { |
| 257 | return STATUS(float_detect_tininess); |
| 258 | } |
Luiz Capitulino | a49db98 | 2014-06-19 10:13:43 -0400 | [diff] [blame] | 259 | static inline int get_float_rounding_mode(float_status *status) |
Peter Maydell | 879d096 | 2014-01-07 17:19:11 +0000 | [diff] [blame] | 260 | { |
| 261 | return STATUS(float_rounding_mode); |
| 262 | } |
Luiz Capitulino | a49db98 | 2014-06-19 10:13:43 -0400 | [diff] [blame] | 263 | static inline int get_float_exception_flags(float_status *status) |
bellard | 1d6bda3 | 2005-03-13 18:52:29 +0000 | [diff] [blame] | 264 | { |
| 265 | return STATUS(float_exception_flags); |
| 266 | } |
Luiz Capitulino | a49db98 | 2014-06-19 10:13:43 -0400 | [diff] [blame] | 267 | static inline int get_floatx80_rounding_precision(float_status *status) |
Peter Maydell | 879d096 | 2014-01-07 17:19:11 +0000 | [diff] [blame] | 268 | { |
| 269 | return STATUS(floatx80_rounding_precision); |
| 270 | } |
Luiz Capitulino | a49db98 | 2014-06-19 10:13:43 -0400 | [diff] [blame] | 271 | static inline flag get_flush_to_zero(float_status *status) |
Peter Maydell | 879d096 | 2014-01-07 17:19:11 +0000 | [diff] [blame] | 272 | { |
| 273 | return STATUS(flush_to_zero); |
| 274 | } |
Luiz Capitulino | a49db98 | 2014-06-19 10:13:43 -0400 | [diff] [blame] | 275 | static inline flag get_flush_inputs_to_zero(float_status *status) |
Peter Maydell | 879d096 | 2014-01-07 17:19:11 +0000 | [diff] [blame] | 276 | { |
| 277 | return STATUS(flush_inputs_to_zero); |
| 278 | } |
Luiz Capitulino | a49db98 | 2014-06-19 10:13:43 -0400 | [diff] [blame] | 279 | static inline flag get_default_nan_mode(float_status *status) |
Peter Maydell | 879d096 | 2014-01-07 17:19:11 +0000 | [diff] [blame] | 280 | { |
| 281 | return STATUS(default_nan_mode); |
| 282 | } |
bellard | 158142c | 2005-03-13 16:54:06 +0000 | [diff] [blame] | 283 | |
| 284 | /*---------------------------------------------------------------------------- |
| 285 | | Routine to raise any or all of the software IEC/IEEE floating-point |
| 286 | | exception flags. |
| 287 | *----------------------------------------------------------------------------*/ |
bellard | ec530c8 | 2006-04-25 22:36:06 +0000 | [diff] [blame] | 288 | void float_raise( int8 flags STATUS_PARAM); |
bellard | 158142c | 2005-03-13 16:54:06 +0000 | [diff] [blame] | 289 | |
| 290 | /*---------------------------------------------------------------------------- |
Alex Bennée | 7baeabc | 2014-03-17 16:31:51 +0000 | [diff] [blame] | 291 | | If `a' is denormal and we are in flush-to-zero mode then set the |
| 292 | | input-denormal exception and return zero. Otherwise just return the value. |
| 293 | *----------------------------------------------------------------------------*/ |
| 294 | float32 float32_squash_input_denormal(float32 a STATUS_PARAM); |
| 295 | float64 float64_squash_input_denormal(float64 a STATUS_PARAM); |
| 296 | |
| 297 | /*---------------------------------------------------------------------------- |
Peter Maydell | 369be8f | 2011-10-19 16:14:06 +0000 | [diff] [blame] | 298 | | Options to indicate which negations to perform in float*_muladd() |
| 299 | | Using these differs from negating an input or output before calling |
| 300 | | the muladd function in that this means that a NaN doesn't have its |
| 301 | | sign bit inverted before it is propagated. |
Peter Maydell | 67d4353 | 2014-02-20 10:35:50 +0000 | [diff] [blame] | 302 | | We also support halving the result before rounding, as a special |
| 303 | | case to support the ARM fused-sqrt-step instruction FRSQRTS. |
Peter Maydell | 369be8f | 2011-10-19 16:14:06 +0000 | [diff] [blame] | 304 | *----------------------------------------------------------------------------*/ |
| 305 | enum { |
| 306 | float_muladd_negate_c = 1, |
| 307 | float_muladd_negate_product = 2, |
Max Filippov | 6617680 | 2012-09-19 04:23:50 +0400 | [diff] [blame] | 308 | float_muladd_negate_result = 4, |
Peter Maydell | 67d4353 | 2014-02-20 10:35:50 +0000 | [diff] [blame] | 309 | float_muladd_halve_result = 8, |
Peter Maydell | 369be8f | 2011-10-19 16:14:06 +0000 | [diff] [blame] | 310 | }; |
| 311 | |
| 312 | /*---------------------------------------------------------------------------- |
bellard | 158142c | 2005-03-13 16:54:06 +0000 | [diff] [blame] | 313 | | Software IEC/IEEE integer-to-floating-point conversion routines. |
| 314 | *----------------------------------------------------------------------------*/ |
Peter Maydell | c4850f9 | 2014-01-07 17:17:49 +0000 | [diff] [blame] | 315 | float32 int32_to_float32(int32_t STATUS_PARAM); |
| 316 | float64 int32_to_float64(int32_t STATUS_PARAM); |
| 317 | float32 uint32_to_float32(uint32_t STATUS_PARAM); |
| 318 | float64 uint32_to_float64(uint32_t STATUS_PARAM); |
| 319 | floatx80 int32_to_floatx80(int32_t STATUS_PARAM); |
| 320 | float128 int32_to_float128(int32_t STATUS_PARAM); |
| 321 | float32 int64_to_float32(int64_t STATUS_PARAM); |
Peter Maydell | c4850f9 | 2014-01-07 17:17:49 +0000 | [diff] [blame] | 322 | float64 int64_to_float64(int64_t STATUS_PARAM); |
Peter Maydell | 25cbb61 | 2014-11-24 15:47:12 +0000 | [diff] [blame] | 323 | float32 uint64_to_float32(uint64_t STATUS_PARAM); |
| 324 | float64 uint64_to_float64(uint64_t STATUS_PARAM); |
Peter Maydell | c4850f9 | 2014-01-07 17:17:49 +0000 | [diff] [blame] | 325 | floatx80 int64_to_floatx80(int64_t STATUS_PARAM); |
| 326 | float128 int64_to_float128(int64_t STATUS_PARAM); |
| 327 | float128 uint64_to_float128(uint64_t STATUS_PARAM); |
bellard | 158142c | 2005-03-13 16:54:06 +0000 | [diff] [blame] | 328 | |
Peter Maydell | 8afbdab | 2014-01-07 17:17:49 +0000 | [diff] [blame] | 329 | /* We provide the int16 versions for symmetry of API with float-to-int */ |
Luiz Capitulino | a49db98 | 2014-06-19 10:13:43 -0400 | [diff] [blame] | 330 | static inline float32 int16_to_float32(int16_t v STATUS_PARAM) |
Peter Maydell | 8afbdab | 2014-01-07 17:17:49 +0000 | [diff] [blame] | 331 | { |
| 332 | return int32_to_float32(v STATUS_VAR); |
| 333 | } |
| 334 | |
Luiz Capitulino | a49db98 | 2014-06-19 10:13:43 -0400 | [diff] [blame] | 335 | static inline float32 uint16_to_float32(uint16_t v STATUS_PARAM) |
Peter Maydell | 8afbdab | 2014-01-07 17:17:49 +0000 | [diff] [blame] | 336 | { |
| 337 | return uint32_to_float32(v STATUS_VAR); |
| 338 | } |
| 339 | |
Luiz Capitulino | a49db98 | 2014-06-19 10:13:43 -0400 | [diff] [blame] | 340 | static inline float64 int16_to_float64(int16_t v STATUS_PARAM) |
Peter Maydell | 8afbdab | 2014-01-07 17:17:49 +0000 | [diff] [blame] | 341 | { |
| 342 | return int32_to_float64(v STATUS_VAR); |
| 343 | } |
| 344 | |
Luiz Capitulino | a49db98 | 2014-06-19 10:13:43 -0400 | [diff] [blame] | 345 | static inline float64 uint16_to_float64(uint16_t v STATUS_PARAM) |
Peter Maydell | 8afbdab | 2014-01-07 17:17:49 +0000 | [diff] [blame] | 346 | { |
| 347 | return uint32_to_float64(v STATUS_VAR); |
| 348 | } |
| 349 | |
bellard | 158142c | 2005-03-13 16:54:06 +0000 | [diff] [blame] | 350 | /*---------------------------------------------------------------------------- |
Paul Brook | 6001149 | 2009-11-19 16:45:20 +0000 | [diff] [blame] | 351 | | Software half-precision conversion routines. |
| 352 | *----------------------------------------------------------------------------*/ |
Peter Maydell | bb4d4bb | 2011-02-10 11:28:56 +0000 | [diff] [blame] | 353 | float16 float32_to_float16( float32, flag STATUS_PARAM ); |
| 354 | float32 float16_to_float32( float16, flag STATUS_PARAM ); |
Peter Maydell | 14c9a07 | 2014-01-07 17:19:12 +0000 | [diff] [blame] | 355 | float16 float64_to_float16(float64 a, flag ieee STATUS_PARAM); |
| 356 | float64 float16_to_float64(float16 a, flag ieee STATUS_PARAM); |
Peter Maydell | bb4d4bb | 2011-02-10 11:28:56 +0000 | [diff] [blame] | 357 | |
| 358 | /*---------------------------------------------------------------------------- |
| 359 | | Software half-precision operations. |
| 360 | *----------------------------------------------------------------------------*/ |
| 361 | int float16_is_quiet_nan( float16 ); |
| 362 | int float16_is_signaling_nan( float16 ); |
| 363 | float16 float16_maybe_silence_nan( float16 ); |
Paul Brook | 6001149 | 2009-11-19 16:45:20 +0000 | [diff] [blame] | 364 | |
Luiz Capitulino | a49db98 | 2014-06-19 10:13:43 -0400 | [diff] [blame] | 365 | static inline int float16_is_any_nan(float16 a) |
Max Filippov | 213ff4e | 2012-09-19 04:23:51 +0400 | [diff] [blame] | 366 | { |
| 367 | return ((float16_val(a) & ~0x8000) > 0x7c00); |
| 368 | } |
| 369 | |
Paul Brook | 6001149 | 2009-11-19 16:45:20 +0000 | [diff] [blame] | 370 | /*---------------------------------------------------------------------------- |
Christophe Lyon | 8559666 | 2011-02-21 17:38:44 +0100 | [diff] [blame] | 371 | | The pattern for a default generated half-precision NaN. |
| 372 | *----------------------------------------------------------------------------*/ |
Paolo Bonzini | 789ec7c | 2011-07-28 12:10:29 +0200 | [diff] [blame] | 373 | extern const float16 float16_default_nan; |
Christophe Lyon | 8559666 | 2011-02-21 17:38:44 +0100 | [diff] [blame] | 374 | |
| 375 | /*---------------------------------------------------------------------------- |
bellard | 158142c | 2005-03-13 16:54:06 +0000 | [diff] [blame] | 376 | | Software IEC/IEEE single-precision conversion routines. |
| 377 | *----------------------------------------------------------------------------*/ |
Will Newton | f581bf5 | 2014-01-07 17:17:48 +0000 | [diff] [blame] | 378 | int_fast16_t float32_to_int16(float32 STATUS_PARAM); |
| 379 | uint_fast16_t float32_to_uint16(float32 STATUS_PARAM); |
Andreas Färber | 94a49d8 | 2012-04-26 00:15:56 +0200 | [diff] [blame] | 380 | int_fast16_t float32_to_int16_round_to_zero(float32 STATUS_PARAM); |
Andreas Färber | 5aea4c5 | 2012-04-26 00:15:55 +0200 | [diff] [blame] | 381 | uint_fast16_t float32_to_uint16_round_to_zero(float32 STATUS_PARAM); |
Andreas Färber | 87b8cc3 | 2011-03-07 01:34:05 +0100 | [diff] [blame] | 382 | int32 float32_to_int32( float32 STATUS_PARAM ); |
| 383 | int32 float32_to_int32_round_to_zero( float32 STATUS_PARAM ); |
| 384 | uint32 float32_to_uint32( float32 STATUS_PARAM ); |
| 385 | uint32 float32_to_uint32_round_to_zero( float32 STATUS_PARAM ); |
| 386 | int64 float32_to_int64( float32 STATUS_PARAM ); |
Tom Musta | 2f18bbf | 2014-01-07 17:17:50 +0000 | [diff] [blame] | 387 | uint64 float32_to_uint64(float32 STATUS_PARAM); |
Tom Musta | a13d448 | 2014-03-31 16:03:55 -0500 | [diff] [blame] | 388 | uint64 float32_to_uint64_round_to_zero(float32 STATUS_PARAM); |
Andreas Färber | 87b8cc3 | 2011-03-07 01:34:05 +0100 | [diff] [blame] | 389 | int64 float32_to_int64_round_to_zero( float32 STATUS_PARAM ); |
bellard | 158142c | 2005-03-13 16:54:06 +0000 | [diff] [blame] | 390 | float64 float32_to_float64( float32 STATUS_PARAM ); |
bellard | 158142c | 2005-03-13 16:54:06 +0000 | [diff] [blame] | 391 | floatx80 float32_to_floatx80( float32 STATUS_PARAM ); |
bellard | 158142c | 2005-03-13 16:54:06 +0000 | [diff] [blame] | 392 | float128 float32_to_float128( float32 STATUS_PARAM ); |
bellard | 158142c | 2005-03-13 16:54:06 +0000 | [diff] [blame] | 393 | |
| 394 | /*---------------------------------------------------------------------------- |
| 395 | | Software IEC/IEEE single-precision operations. |
| 396 | *----------------------------------------------------------------------------*/ |
| 397 | float32 float32_round_to_int( float32 STATUS_PARAM ); |
| 398 | float32 float32_add( float32, float32 STATUS_PARAM ); |
| 399 | float32 float32_sub( float32, float32 STATUS_PARAM ); |
| 400 | float32 float32_mul( float32, float32 STATUS_PARAM ); |
| 401 | float32 float32_div( float32, float32 STATUS_PARAM ); |
| 402 | float32 float32_rem( float32, float32 STATUS_PARAM ); |
Peter Maydell | 369be8f | 2011-10-19 16:14:06 +0000 | [diff] [blame] | 403 | float32 float32_muladd(float32, float32, float32, int STATUS_PARAM); |
bellard | 158142c | 2005-03-13 16:54:06 +0000 | [diff] [blame] | 404 | float32 float32_sqrt( float32 STATUS_PARAM ); |
Aurelien Jarno | 8229c99 | 2009-02-05 12:04:05 +0100 | [diff] [blame] | 405 | float32 float32_exp2( float32 STATUS_PARAM ); |
aurel32 | 374dfc3 | 2009-02-05 13:42:47 +0000 | [diff] [blame] | 406 | float32 float32_log2( float32 STATUS_PARAM ); |
Aurelien Jarno | b689362 | 2011-04-14 00:49:29 +0200 | [diff] [blame] | 407 | int float32_eq( float32, float32 STATUS_PARAM ); |
bellard | 750afe9 | 2006-10-28 19:27:11 +0000 | [diff] [blame] | 408 | int float32_le( float32, float32 STATUS_PARAM ); |
| 409 | int float32_lt( float32, float32 STATUS_PARAM ); |
Aurelien Jarno | 67b7861 | 2011-04-14 00:49:29 +0200 | [diff] [blame] | 410 | int float32_unordered( float32, float32 STATUS_PARAM ); |
Aurelien Jarno | b689362 | 2011-04-14 00:49:29 +0200 | [diff] [blame] | 411 | int float32_eq_quiet( float32, float32 STATUS_PARAM ); |
bellard | 750afe9 | 2006-10-28 19:27:11 +0000 | [diff] [blame] | 412 | int float32_le_quiet( float32, float32 STATUS_PARAM ); |
| 413 | int float32_lt_quiet( float32, float32 STATUS_PARAM ); |
Aurelien Jarno | 67b7861 | 2011-04-14 00:49:29 +0200 | [diff] [blame] | 414 | int float32_unordered_quiet( float32, float32 STATUS_PARAM ); |
bellard | 750afe9 | 2006-10-28 19:27:11 +0000 | [diff] [blame] | 415 | int float32_compare( float32, float32 STATUS_PARAM ); |
| 416 | int float32_compare_quiet( float32, float32 STATUS_PARAM ); |
Peter Maydell | 274f1b0 | 2011-03-11 08:12:25 +0000 | [diff] [blame] | 417 | float32 float32_min(float32, float32 STATUS_PARAM); |
| 418 | float32 float32_max(float32, float32 STATUS_PARAM); |
Will Newton | e17ab31 | 2013-12-06 17:01:41 +0000 | [diff] [blame] | 419 | float32 float32_minnum(float32, float32 STATUS_PARAM); |
| 420 | float32 float32_maxnum(float32, float32 STATUS_PARAM); |
Leon Alrae | 2d31e06 | 2014-06-27 08:49:06 +0100 | [diff] [blame] | 421 | float32 float32_minnummag(float32, float32 STATUS_PARAM); |
| 422 | float32 float32_maxnummag(float32, float32 STATUS_PARAM); |
Peter Maydell | 1856987 | 2010-12-17 15:56:06 +0000 | [diff] [blame] | 423 | int float32_is_quiet_nan( float32 ); |
bellard | 750afe9 | 2006-10-28 19:27:11 +0000 | [diff] [blame] | 424 | int float32_is_signaling_nan( float32 ); |
Peter Maydell | b408dbd | 2010-12-07 15:37:34 +0000 | [diff] [blame] | 425 | float32 float32_maybe_silence_nan( float32 ); |
pbrook | 9ee6e8b | 2007-11-11 00:04:49 +0000 | [diff] [blame] | 426 | float32 float32_scalbn( float32, int STATUS_PARAM ); |
bellard | 158142c | 2005-03-13 16:54:06 +0000 | [diff] [blame] | 427 | |
Luiz Capitulino | a49db98 | 2014-06-19 10:13:43 -0400 | [diff] [blame] | 428 | static inline float32 float32_abs(float32 a) |
bellard | 1d6bda3 | 2005-03-13 18:52:29 +0000 | [diff] [blame] | 429 | { |
Peter Maydell | 37d1866 | 2011-01-06 19:37:53 +0000 | [diff] [blame] | 430 | /* Note that abs does *not* handle NaN specially, nor does |
| 431 | * it flush denormal inputs to zero. |
| 432 | */ |
pbrook | f090c9d | 2007-11-18 14:33:24 +0000 | [diff] [blame] | 433 | return make_float32(float32_val(a) & 0x7fffffff); |
bellard | 1d6bda3 | 2005-03-13 18:52:29 +0000 | [diff] [blame] | 434 | } |
| 435 | |
Luiz Capitulino | a49db98 | 2014-06-19 10:13:43 -0400 | [diff] [blame] | 436 | static inline float32 float32_chs(float32 a) |
bellard | 1d6bda3 | 2005-03-13 18:52:29 +0000 | [diff] [blame] | 437 | { |
Peter Maydell | 37d1866 | 2011-01-06 19:37:53 +0000 | [diff] [blame] | 438 | /* Note that chs does *not* handle NaN specially, nor does |
| 439 | * it flush denormal inputs to zero. |
| 440 | */ |
pbrook | f090c9d | 2007-11-18 14:33:24 +0000 | [diff] [blame] | 441 | return make_float32(float32_val(a) ^ 0x80000000); |
bellard | 1d6bda3 | 2005-03-13 18:52:29 +0000 | [diff] [blame] | 442 | } |
| 443 | |
Luiz Capitulino | a49db98 | 2014-06-19 10:13:43 -0400 | [diff] [blame] | 444 | static inline int float32_is_infinity(float32 a) |
aurel32 | c52ab6f | 2008-12-15 17:14:20 +0000 | [diff] [blame] | 445 | { |
aurel32 | dadd71a | 2008-12-18 22:43:16 +0000 | [diff] [blame] | 446 | return (float32_val(a) & 0x7fffffff) == 0x7f800000; |
aurel32 | c52ab6f | 2008-12-15 17:14:20 +0000 | [diff] [blame] | 447 | } |
| 448 | |
Luiz Capitulino | a49db98 | 2014-06-19 10:13:43 -0400 | [diff] [blame] | 449 | static inline int float32_is_neg(float32 a) |
aurel32 | c52ab6f | 2008-12-15 17:14:20 +0000 | [diff] [blame] | 450 | { |
| 451 | return float32_val(a) >> 31; |
| 452 | } |
| 453 | |
Luiz Capitulino | a49db98 | 2014-06-19 10:13:43 -0400 | [diff] [blame] | 454 | static inline int float32_is_zero(float32 a) |
aurel32 | c52ab6f | 2008-12-15 17:14:20 +0000 | [diff] [blame] | 455 | { |
| 456 | return (float32_val(a) & 0x7fffffff) == 0; |
| 457 | } |
| 458 | |
Luiz Capitulino | a49db98 | 2014-06-19 10:13:43 -0400 | [diff] [blame] | 459 | static inline int float32_is_any_nan(float32 a) |
Peter Maydell | 21d6ebd | 2010-12-07 15:37:34 +0000 | [diff] [blame] | 460 | { |
| 461 | return ((float32_val(a) & ~(1 << 31)) > 0x7f800000UL); |
| 462 | } |
| 463 | |
Luiz Capitulino | a49db98 | 2014-06-19 10:13:43 -0400 | [diff] [blame] | 464 | static inline int float32_is_zero_or_denormal(float32 a) |
Peter Maydell | 6f3300a | 2011-01-14 20:39:18 +0100 | [diff] [blame] | 465 | { |
| 466 | return (float32_val(a) & 0x7f800000) == 0; |
| 467 | } |
| 468 | |
Luiz Capitulino | a49db98 | 2014-06-19 10:13:43 -0400 | [diff] [blame] | 469 | static inline float32 float32_set_sign(float32 a, int sign) |
Christophe Lyon | c30fe7d | 2011-02-21 17:38:45 +0100 | [diff] [blame] | 470 | { |
| 471 | return make_float32((float32_val(a) & 0x7fffffff) | (sign << 31)); |
| 472 | } |
| 473 | |
pbrook | f090c9d | 2007-11-18 14:33:24 +0000 | [diff] [blame] | 474 | #define float32_zero make_float32(0) |
aurel32 | 196cfc8 | 2009-02-04 13:52:27 +0000 | [diff] [blame] | 475 | #define float32_one make_float32(0x3f800000) |
Aurelien Jarno | 8229c99 | 2009-02-05 12:04:05 +0100 | [diff] [blame] | 476 | #define float32_ln2 make_float32(0x3f317218) |
Aurelien Jarno | c4b4c77 | 2011-04-20 13:04:22 +0200 | [diff] [blame] | 477 | #define float32_pi make_float32(0x40490fdb) |
Christophe Lyon | c30fe7d | 2011-02-21 17:38:45 +0100 | [diff] [blame] | 478 | #define float32_half make_float32(0x3f000000) |
| 479 | #define float32_infinity make_float32(0x7f800000) |
pbrook | f090c9d | 2007-11-18 14:33:24 +0000 | [diff] [blame] | 480 | |
Christophe Lyon | 8559666 | 2011-02-21 17:38:44 +0100 | [diff] [blame] | 481 | |
| 482 | /*---------------------------------------------------------------------------- |
| 483 | | The pattern for a default generated single-precision NaN. |
| 484 | *----------------------------------------------------------------------------*/ |
Paolo Bonzini | 789ec7c | 2011-07-28 12:10:29 +0200 | [diff] [blame] | 485 | extern const float32 float32_default_nan; |
Christophe Lyon | 8559666 | 2011-02-21 17:38:44 +0100 | [diff] [blame] | 486 | |
bellard | 158142c | 2005-03-13 16:54:06 +0000 | [diff] [blame] | 487 | /*---------------------------------------------------------------------------- |
| 488 | | Software IEC/IEEE double-precision conversion routines. |
| 489 | *----------------------------------------------------------------------------*/ |
Will Newton | f581bf5 | 2014-01-07 17:17:48 +0000 | [diff] [blame] | 490 | int_fast16_t float64_to_int16(float64 STATUS_PARAM); |
| 491 | uint_fast16_t float64_to_uint16(float64 STATUS_PARAM); |
Andreas Färber | 94a49d8 | 2012-04-26 00:15:56 +0200 | [diff] [blame] | 492 | int_fast16_t float64_to_int16_round_to_zero(float64 STATUS_PARAM); |
Andreas Färber | 5aea4c5 | 2012-04-26 00:15:55 +0200 | [diff] [blame] | 493 | uint_fast16_t float64_to_uint16_round_to_zero(float64 STATUS_PARAM); |
Andreas Färber | 87b8cc3 | 2011-03-07 01:34:05 +0100 | [diff] [blame] | 494 | int32 float64_to_int32( float64 STATUS_PARAM ); |
| 495 | int32 float64_to_int32_round_to_zero( float64 STATUS_PARAM ); |
| 496 | uint32 float64_to_uint32( float64 STATUS_PARAM ); |
| 497 | uint32 float64_to_uint32_round_to_zero( float64 STATUS_PARAM ); |
| 498 | int64 float64_to_int64( float64 STATUS_PARAM ); |
| 499 | int64 float64_to_int64_round_to_zero( float64 STATUS_PARAM ); |
| 500 | uint64 float64_to_uint64 (float64 a STATUS_PARAM); |
| 501 | uint64 float64_to_uint64_round_to_zero (float64 a STATUS_PARAM); |
bellard | 158142c | 2005-03-13 16:54:06 +0000 | [diff] [blame] | 502 | float32 float64_to_float32( float64 STATUS_PARAM ); |
bellard | 158142c | 2005-03-13 16:54:06 +0000 | [diff] [blame] | 503 | floatx80 float64_to_floatx80( float64 STATUS_PARAM ); |
bellard | 158142c | 2005-03-13 16:54:06 +0000 | [diff] [blame] | 504 | float128 float64_to_float128( float64 STATUS_PARAM ); |
bellard | 158142c | 2005-03-13 16:54:06 +0000 | [diff] [blame] | 505 | |
| 506 | /*---------------------------------------------------------------------------- |
| 507 | | Software IEC/IEEE double-precision operations. |
| 508 | *----------------------------------------------------------------------------*/ |
| 509 | float64 float64_round_to_int( float64 STATUS_PARAM ); |
pbrook | e6e5906 | 2006-10-22 00:18:54 +0000 | [diff] [blame] | 510 | float64 float64_trunc_to_int( float64 STATUS_PARAM ); |
bellard | 158142c | 2005-03-13 16:54:06 +0000 | [diff] [blame] | 511 | float64 float64_add( float64, float64 STATUS_PARAM ); |
| 512 | float64 float64_sub( float64, float64 STATUS_PARAM ); |
| 513 | float64 float64_mul( float64, float64 STATUS_PARAM ); |
| 514 | float64 float64_div( float64, float64 STATUS_PARAM ); |
| 515 | float64 float64_rem( float64, float64 STATUS_PARAM ); |
Peter Maydell | 369be8f | 2011-10-19 16:14:06 +0000 | [diff] [blame] | 516 | float64 float64_muladd(float64, float64, float64, int STATUS_PARAM); |
bellard | 158142c | 2005-03-13 16:54:06 +0000 | [diff] [blame] | 517 | float64 float64_sqrt( float64 STATUS_PARAM ); |
aurel32 | 374dfc3 | 2009-02-05 13:42:47 +0000 | [diff] [blame] | 518 | float64 float64_log2( float64 STATUS_PARAM ); |
Aurelien Jarno | b689362 | 2011-04-14 00:49:29 +0200 | [diff] [blame] | 519 | int float64_eq( float64, float64 STATUS_PARAM ); |
bellard | 750afe9 | 2006-10-28 19:27:11 +0000 | [diff] [blame] | 520 | int float64_le( float64, float64 STATUS_PARAM ); |
| 521 | int float64_lt( float64, float64 STATUS_PARAM ); |
Aurelien Jarno | 67b7861 | 2011-04-14 00:49:29 +0200 | [diff] [blame] | 522 | int float64_unordered( float64, float64 STATUS_PARAM ); |
Aurelien Jarno | b689362 | 2011-04-14 00:49:29 +0200 | [diff] [blame] | 523 | int float64_eq_quiet( float64, float64 STATUS_PARAM ); |
bellard | 750afe9 | 2006-10-28 19:27:11 +0000 | [diff] [blame] | 524 | int float64_le_quiet( float64, float64 STATUS_PARAM ); |
| 525 | int float64_lt_quiet( float64, float64 STATUS_PARAM ); |
Aurelien Jarno | 67b7861 | 2011-04-14 00:49:29 +0200 | [diff] [blame] | 526 | int float64_unordered_quiet( float64, float64 STATUS_PARAM ); |
bellard | 750afe9 | 2006-10-28 19:27:11 +0000 | [diff] [blame] | 527 | int float64_compare( float64, float64 STATUS_PARAM ); |
| 528 | int float64_compare_quiet( float64, float64 STATUS_PARAM ); |
Peter Maydell | 274f1b0 | 2011-03-11 08:12:25 +0000 | [diff] [blame] | 529 | float64 float64_min(float64, float64 STATUS_PARAM); |
| 530 | float64 float64_max(float64, float64 STATUS_PARAM); |
Will Newton | e17ab31 | 2013-12-06 17:01:41 +0000 | [diff] [blame] | 531 | float64 float64_minnum(float64, float64 STATUS_PARAM); |
| 532 | float64 float64_maxnum(float64, float64 STATUS_PARAM); |
Leon Alrae | 2d31e06 | 2014-06-27 08:49:06 +0100 | [diff] [blame] | 533 | float64 float64_minnummag(float64, float64 STATUS_PARAM); |
| 534 | float64 float64_maxnummag(float64, float64 STATUS_PARAM); |
Peter Maydell | 1856987 | 2010-12-17 15:56:06 +0000 | [diff] [blame] | 535 | int float64_is_quiet_nan( float64 a ); |
bellard | 750afe9 | 2006-10-28 19:27:11 +0000 | [diff] [blame] | 536 | int float64_is_signaling_nan( float64 ); |
Peter Maydell | b408dbd | 2010-12-07 15:37:34 +0000 | [diff] [blame] | 537 | float64 float64_maybe_silence_nan( float64 ); |
pbrook | 9ee6e8b | 2007-11-11 00:04:49 +0000 | [diff] [blame] | 538 | float64 float64_scalbn( float64, int STATUS_PARAM ); |
bellard | 158142c | 2005-03-13 16:54:06 +0000 | [diff] [blame] | 539 | |
Luiz Capitulino | a49db98 | 2014-06-19 10:13:43 -0400 | [diff] [blame] | 540 | static inline float64 float64_abs(float64 a) |
bellard | 1d6bda3 | 2005-03-13 18:52:29 +0000 | [diff] [blame] | 541 | { |
Peter Maydell | 37d1866 | 2011-01-06 19:37:53 +0000 | [diff] [blame] | 542 | /* Note that abs does *not* handle NaN specially, nor does |
| 543 | * it flush denormal inputs to zero. |
| 544 | */ |
pbrook | f090c9d | 2007-11-18 14:33:24 +0000 | [diff] [blame] | 545 | return make_float64(float64_val(a) & 0x7fffffffffffffffLL); |
bellard | 1d6bda3 | 2005-03-13 18:52:29 +0000 | [diff] [blame] | 546 | } |
| 547 | |
Luiz Capitulino | a49db98 | 2014-06-19 10:13:43 -0400 | [diff] [blame] | 548 | static inline float64 float64_chs(float64 a) |
bellard | 1d6bda3 | 2005-03-13 18:52:29 +0000 | [diff] [blame] | 549 | { |
Peter Maydell | 37d1866 | 2011-01-06 19:37:53 +0000 | [diff] [blame] | 550 | /* Note that chs does *not* handle NaN specially, nor does |
| 551 | * it flush denormal inputs to zero. |
| 552 | */ |
pbrook | f090c9d | 2007-11-18 14:33:24 +0000 | [diff] [blame] | 553 | return make_float64(float64_val(a) ^ 0x8000000000000000LL); |
bellard | 1d6bda3 | 2005-03-13 18:52:29 +0000 | [diff] [blame] | 554 | } |
| 555 | |
Luiz Capitulino | a49db98 | 2014-06-19 10:13:43 -0400 | [diff] [blame] | 556 | static inline int float64_is_infinity(float64 a) |
aurel32 | c52ab6f | 2008-12-15 17:14:20 +0000 | [diff] [blame] | 557 | { |
| 558 | return (float64_val(a) & 0x7fffffffffffffffLL ) == 0x7ff0000000000000LL; |
| 559 | } |
| 560 | |
Luiz Capitulino | a49db98 | 2014-06-19 10:13:43 -0400 | [diff] [blame] | 561 | static inline int float64_is_neg(float64 a) |
aurel32 | c52ab6f | 2008-12-15 17:14:20 +0000 | [diff] [blame] | 562 | { |
| 563 | return float64_val(a) >> 63; |
| 564 | } |
| 565 | |
Luiz Capitulino | a49db98 | 2014-06-19 10:13:43 -0400 | [diff] [blame] | 566 | static inline int float64_is_zero(float64 a) |
aurel32 | c52ab6f | 2008-12-15 17:14:20 +0000 | [diff] [blame] | 567 | { |
| 568 | return (float64_val(a) & 0x7fffffffffffffffLL) == 0; |
| 569 | } |
| 570 | |
Luiz Capitulino | a49db98 | 2014-06-19 10:13:43 -0400 | [diff] [blame] | 571 | static inline int float64_is_any_nan(float64 a) |
Peter Maydell | 21d6ebd | 2010-12-07 15:37:34 +0000 | [diff] [blame] | 572 | { |
| 573 | return ((float64_val(a) & ~(1ULL << 63)) > 0x7ff0000000000000ULL); |
| 574 | } |
| 575 | |
Luiz Capitulino | a49db98 | 2014-06-19 10:13:43 -0400 | [diff] [blame] | 576 | static inline int float64_is_zero_or_denormal(float64 a) |
Aurelien Jarno | 587eabf | 2011-05-15 14:09:18 +0200 | [diff] [blame] | 577 | { |
| 578 | return (float64_val(a) & 0x7ff0000000000000LL) == 0; |
| 579 | } |
| 580 | |
Luiz Capitulino | a49db98 | 2014-06-19 10:13:43 -0400 | [diff] [blame] | 581 | static inline float64 float64_set_sign(float64 a, int sign) |
Christophe Lyon | c30fe7d | 2011-02-21 17:38:45 +0100 | [diff] [blame] | 582 | { |
| 583 | return make_float64((float64_val(a) & 0x7fffffffffffffffULL) |
| 584 | | ((int64_t)sign << 63)); |
| 585 | } |
| 586 | |
pbrook | f090c9d | 2007-11-18 14:33:24 +0000 | [diff] [blame] | 587 | #define float64_zero make_float64(0) |
aurel32 | 196cfc8 | 2009-02-04 13:52:27 +0000 | [diff] [blame] | 588 | #define float64_one make_float64(0x3ff0000000000000LL) |
Aurelien Jarno | 8229c99 | 2009-02-05 12:04:05 +0100 | [diff] [blame] | 589 | #define float64_ln2 make_float64(0x3fe62e42fefa39efLL) |
Aurelien Jarno | c4b4c77 | 2011-04-20 13:04:22 +0200 | [diff] [blame] | 590 | #define float64_pi make_float64(0x400921fb54442d18LL) |
Christophe Lyon | c30fe7d | 2011-02-21 17:38:45 +0100 | [diff] [blame] | 591 | #define float64_half make_float64(0x3fe0000000000000LL) |
| 592 | #define float64_infinity make_float64(0x7ff0000000000000LL) |
pbrook | f090c9d | 2007-11-18 14:33:24 +0000 | [diff] [blame] | 593 | |
Christophe Lyon | 8559666 | 2011-02-21 17:38:44 +0100 | [diff] [blame] | 594 | /*---------------------------------------------------------------------------- |
| 595 | | The pattern for a default generated double-precision NaN. |
| 596 | *----------------------------------------------------------------------------*/ |
Paolo Bonzini | 789ec7c | 2011-07-28 12:10:29 +0200 | [diff] [blame] | 597 | extern const float64 float64_default_nan; |
Christophe Lyon | 8559666 | 2011-02-21 17:38:44 +0100 | [diff] [blame] | 598 | |
bellard | 158142c | 2005-03-13 16:54:06 +0000 | [diff] [blame] | 599 | /*---------------------------------------------------------------------------- |
| 600 | | Software IEC/IEEE extended double-precision conversion routines. |
| 601 | *----------------------------------------------------------------------------*/ |
Andreas Färber | 87b8cc3 | 2011-03-07 01:34:05 +0100 | [diff] [blame] | 602 | int32 floatx80_to_int32( floatx80 STATUS_PARAM ); |
| 603 | int32 floatx80_to_int32_round_to_zero( floatx80 STATUS_PARAM ); |
| 604 | int64 floatx80_to_int64( floatx80 STATUS_PARAM ); |
| 605 | int64 floatx80_to_int64_round_to_zero( floatx80 STATUS_PARAM ); |
bellard | 158142c | 2005-03-13 16:54:06 +0000 | [diff] [blame] | 606 | float32 floatx80_to_float32( floatx80 STATUS_PARAM ); |
| 607 | float64 floatx80_to_float64( floatx80 STATUS_PARAM ); |
bellard | 158142c | 2005-03-13 16:54:06 +0000 | [diff] [blame] | 608 | float128 floatx80_to_float128( floatx80 STATUS_PARAM ); |
bellard | 158142c | 2005-03-13 16:54:06 +0000 | [diff] [blame] | 609 | |
| 610 | /*---------------------------------------------------------------------------- |
| 611 | | Software IEC/IEEE extended double-precision operations. |
| 612 | *----------------------------------------------------------------------------*/ |
| 613 | floatx80 floatx80_round_to_int( floatx80 STATUS_PARAM ); |
| 614 | floatx80 floatx80_add( floatx80, floatx80 STATUS_PARAM ); |
| 615 | floatx80 floatx80_sub( floatx80, floatx80 STATUS_PARAM ); |
| 616 | floatx80 floatx80_mul( floatx80, floatx80 STATUS_PARAM ); |
| 617 | floatx80 floatx80_div( floatx80, floatx80 STATUS_PARAM ); |
| 618 | floatx80 floatx80_rem( floatx80, floatx80 STATUS_PARAM ); |
| 619 | floatx80 floatx80_sqrt( floatx80 STATUS_PARAM ); |
Aurelien Jarno | b689362 | 2011-04-14 00:49:29 +0200 | [diff] [blame] | 620 | int floatx80_eq( floatx80, floatx80 STATUS_PARAM ); |
bellard | 750afe9 | 2006-10-28 19:27:11 +0000 | [diff] [blame] | 621 | int floatx80_le( floatx80, floatx80 STATUS_PARAM ); |
| 622 | int floatx80_lt( floatx80, floatx80 STATUS_PARAM ); |
Aurelien Jarno | 67b7861 | 2011-04-14 00:49:29 +0200 | [diff] [blame] | 623 | int floatx80_unordered( floatx80, floatx80 STATUS_PARAM ); |
Aurelien Jarno | b689362 | 2011-04-14 00:49:29 +0200 | [diff] [blame] | 624 | int floatx80_eq_quiet( floatx80, floatx80 STATUS_PARAM ); |
bellard | 750afe9 | 2006-10-28 19:27:11 +0000 | [diff] [blame] | 625 | int floatx80_le_quiet( floatx80, floatx80 STATUS_PARAM ); |
| 626 | int floatx80_lt_quiet( floatx80, floatx80 STATUS_PARAM ); |
Aurelien Jarno | 67b7861 | 2011-04-14 00:49:29 +0200 | [diff] [blame] | 627 | int floatx80_unordered_quiet( floatx80, floatx80 STATUS_PARAM ); |
Aurelien Jarno | f6714d3 | 2011-04-20 13:04:22 +0200 | [diff] [blame] | 628 | int floatx80_compare( floatx80, floatx80 STATUS_PARAM ); |
| 629 | int floatx80_compare_quiet( floatx80, floatx80 STATUS_PARAM ); |
Peter Maydell | 1856987 | 2010-12-17 15:56:06 +0000 | [diff] [blame] | 630 | int floatx80_is_quiet_nan( floatx80 ); |
bellard | 750afe9 | 2006-10-28 19:27:11 +0000 | [diff] [blame] | 631 | int floatx80_is_signaling_nan( floatx80 ); |
Aurelien Jarno | f6a7d92 | 2011-01-06 15:38:19 +0100 | [diff] [blame] | 632 | floatx80 floatx80_maybe_silence_nan( floatx80 ); |
pbrook | 9ee6e8b | 2007-11-11 00:04:49 +0000 | [diff] [blame] | 633 | floatx80 floatx80_scalbn( floatx80, int STATUS_PARAM ); |
bellard | 158142c | 2005-03-13 16:54:06 +0000 | [diff] [blame] | 634 | |
Luiz Capitulino | a49db98 | 2014-06-19 10:13:43 -0400 | [diff] [blame] | 635 | static inline floatx80 floatx80_abs(floatx80 a) |
bellard | 1d6bda3 | 2005-03-13 18:52:29 +0000 | [diff] [blame] | 636 | { |
| 637 | a.high &= 0x7fff; |
| 638 | return a; |
| 639 | } |
| 640 | |
Luiz Capitulino | a49db98 | 2014-06-19 10:13:43 -0400 | [diff] [blame] | 641 | static inline floatx80 floatx80_chs(floatx80 a) |
bellard | 1d6bda3 | 2005-03-13 18:52:29 +0000 | [diff] [blame] | 642 | { |
| 643 | a.high ^= 0x8000; |
| 644 | return a; |
| 645 | } |
| 646 | |
Luiz Capitulino | a49db98 | 2014-06-19 10:13:43 -0400 | [diff] [blame] | 647 | static inline int floatx80_is_infinity(floatx80 a) |
aurel32 | c52ab6f | 2008-12-15 17:14:20 +0000 | [diff] [blame] | 648 | { |
Aurelien Jarno | b76235e | 2011-04-20 13:04:22 +0200 | [diff] [blame] | 649 | return (a.high & 0x7fff) == 0x7fff && a.low == 0x8000000000000000LL; |
aurel32 | c52ab6f | 2008-12-15 17:14:20 +0000 | [diff] [blame] | 650 | } |
| 651 | |
Luiz Capitulino | a49db98 | 2014-06-19 10:13:43 -0400 | [diff] [blame] | 652 | static inline int floatx80_is_neg(floatx80 a) |
aurel32 | c52ab6f | 2008-12-15 17:14:20 +0000 | [diff] [blame] | 653 | { |
| 654 | return a.high >> 15; |
| 655 | } |
| 656 | |
Luiz Capitulino | a49db98 | 2014-06-19 10:13:43 -0400 | [diff] [blame] | 657 | static inline int floatx80_is_zero(floatx80 a) |
aurel32 | c52ab6f | 2008-12-15 17:14:20 +0000 | [diff] [blame] | 658 | { |
| 659 | return (a.high & 0x7fff) == 0 && a.low == 0; |
| 660 | } |
| 661 | |
Luiz Capitulino | a49db98 | 2014-06-19 10:13:43 -0400 | [diff] [blame] | 662 | static inline int floatx80_is_zero_or_denormal(floatx80 a) |
Aurelien Jarno | 587eabf | 2011-05-15 14:09:18 +0200 | [diff] [blame] | 663 | { |
| 664 | return (a.high & 0x7fff) == 0; |
| 665 | } |
| 666 | |
Luiz Capitulino | a49db98 | 2014-06-19 10:13:43 -0400 | [diff] [blame] | 667 | static inline int floatx80_is_any_nan(floatx80 a) |
Peter Maydell | 2bed652 | 2011-01-06 18:34:43 +0000 | [diff] [blame] | 668 | { |
| 669 | return ((a.high & 0x7fff) == 0x7fff) && (a.low<<1); |
| 670 | } |
| 671 | |
Aurelien Jarno | f3218a8 | 2011-04-20 13:04:22 +0200 | [diff] [blame] | 672 | #define floatx80_zero make_floatx80(0x0000, 0x0000000000000000LL) |
| 673 | #define floatx80_one make_floatx80(0x3fff, 0x8000000000000000LL) |
| 674 | #define floatx80_ln2 make_floatx80(0x3ffe, 0xb17217f7d1cf79acLL) |
Aurelien Jarno | c4b4c77 | 2011-04-20 13:04:22 +0200 | [diff] [blame] | 675 | #define floatx80_pi make_floatx80(0x4000, 0xc90fdaa22168c235LL) |
Aurelien Jarno | f3218a8 | 2011-04-20 13:04:22 +0200 | [diff] [blame] | 676 | #define floatx80_half make_floatx80(0x3ffe, 0x8000000000000000LL) |
| 677 | #define floatx80_infinity make_floatx80(0x7fff, 0x8000000000000000LL) |
| 678 | |
Christophe Lyon | 8559666 | 2011-02-21 17:38:44 +0100 | [diff] [blame] | 679 | /*---------------------------------------------------------------------------- |
Paolo Bonzini | 789ec7c | 2011-07-28 12:10:29 +0200 | [diff] [blame] | 680 | | The pattern for a default generated extended double-precision NaN. |
Christophe Lyon | 8559666 | 2011-02-21 17:38:44 +0100 | [diff] [blame] | 681 | *----------------------------------------------------------------------------*/ |
Paolo Bonzini | 789ec7c | 2011-07-28 12:10:29 +0200 | [diff] [blame] | 682 | extern const floatx80 floatx80_default_nan; |
Christophe Lyon | 8559666 | 2011-02-21 17:38:44 +0100 | [diff] [blame] | 683 | |
bellard | 158142c | 2005-03-13 16:54:06 +0000 | [diff] [blame] | 684 | /*---------------------------------------------------------------------------- |
| 685 | | Software IEC/IEEE quadruple-precision conversion routines. |
| 686 | *----------------------------------------------------------------------------*/ |
Andreas Färber | 87b8cc3 | 2011-03-07 01:34:05 +0100 | [diff] [blame] | 687 | int32 float128_to_int32( float128 STATUS_PARAM ); |
| 688 | int32 float128_to_int32_round_to_zero( float128 STATUS_PARAM ); |
| 689 | int64 float128_to_int64( float128 STATUS_PARAM ); |
| 690 | int64 float128_to_int64_round_to_zero( float128 STATUS_PARAM ); |
bellard | 158142c | 2005-03-13 16:54:06 +0000 | [diff] [blame] | 691 | float32 float128_to_float32( float128 STATUS_PARAM ); |
| 692 | float64 float128_to_float64( float128 STATUS_PARAM ); |
bellard | 158142c | 2005-03-13 16:54:06 +0000 | [diff] [blame] | 693 | floatx80 float128_to_floatx80( float128 STATUS_PARAM ); |
bellard | 158142c | 2005-03-13 16:54:06 +0000 | [diff] [blame] | 694 | |
| 695 | /*---------------------------------------------------------------------------- |
| 696 | | Software IEC/IEEE quadruple-precision operations. |
| 697 | *----------------------------------------------------------------------------*/ |
| 698 | float128 float128_round_to_int( float128 STATUS_PARAM ); |
| 699 | float128 float128_add( float128, float128 STATUS_PARAM ); |
| 700 | float128 float128_sub( float128, float128 STATUS_PARAM ); |
| 701 | float128 float128_mul( float128, float128 STATUS_PARAM ); |
| 702 | float128 float128_div( float128, float128 STATUS_PARAM ); |
| 703 | float128 float128_rem( float128, float128 STATUS_PARAM ); |
| 704 | float128 float128_sqrt( float128 STATUS_PARAM ); |
Aurelien Jarno | b689362 | 2011-04-14 00:49:29 +0200 | [diff] [blame] | 705 | int float128_eq( float128, float128 STATUS_PARAM ); |
bellard | 750afe9 | 2006-10-28 19:27:11 +0000 | [diff] [blame] | 706 | int float128_le( float128, float128 STATUS_PARAM ); |
| 707 | int float128_lt( float128, float128 STATUS_PARAM ); |
Aurelien Jarno | 67b7861 | 2011-04-14 00:49:29 +0200 | [diff] [blame] | 708 | int float128_unordered( float128, float128 STATUS_PARAM ); |
Aurelien Jarno | b689362 | 2011-04-14 00:49:29 +0200 | [diff] [blame] | 709 | int float128_eq_quiet( float128, float128 STATUS_PARAM ); |
bellard | 750afe9 | 2006-10-28 19:27:11 +0000 | [diff] [blame] | 710 | int float128_le_quiet( float128, float128 STATUS_PARAM ); |
| 711 | int float128_lt_quiet( float128, float128 STATUS_PARAM ); |
Aurelien Jarno | 67b7861 | 2011-04-14 00:49:29 +0200 | [diff] [blame] | 712 | int float128_unordered_quiet( float128, float128 STATUS_PARAM ); |
blueswir1 | 1f58732 | 2007-11-25 18:40:20 +0000 | [diff] [blame] | 713 | int float128_compare( float128, float128 STATUS_PARAM ); |
| 714 | int float128_compare_quiet( float128, float128 STATUS_PARAM ); |
Peter Maydell | 1856987 | 2010-12-17 15:56:06 +0000 | [diff] [blame] | 715 | int float128_is_quiet_nan( float128 ); |
bellard | 750afe9 | 2006-10-28 19:27:11 +0000 | [diff] [blame] | 716 | int float128_is_signaling_nan( float128 ); |
Aurelien Jarno | f6a7d92 | 2011-01-06 15:38:19 +0100 | [diff] [blame] | 717 | float128 float128_maybe_silence_nan( float128 ); |
pbrook | 9ee6e8b | 2007-11-11 00:04:49 +0000 | [diff] [blame] | 718 | float128 float128_scalbn( float128, int STATUS_PARAM ); |
bellard | 158142c | 2005-03-13 16:54:06 +0000 | [diff] [blame] | 719 | |
Luiz Capitulino | a49db98 | 2014-06-19 10:13:43 -0400 | [diff] [blame] | 720 | static inline float128 float128_abs(float128 a) |
bellard | 1d6bda3 | 2005-03-13 18:52:29 +0000 | [diff] [blame] | 721 | { |
| 722 | a.high &= 0x7fffffffffffffffLL; |
| 723 | return a; |
| 724 | } |
| 725 | |
Luiz Capitulino | a49db98 | 2014-06-19 10:13:43 -0400 | [diff] [blame] | 726 | static inline float128 float128_chs(float128 a) |
bellard | 1d6bda3 | 2005-03-13 18:52:29 +0000 | [diff] [blame] | 727 | { |
| 728 | a.high ^= 0x8000000000000000LL; |
| 729 | return a; |
| 730 | } |
| 731 | |
Luiz Capitulino | a49db98 | 2014-06-19 10:13:43 -0400 | [diff] [blame] | 732 | static inline int float128_is_infinity(float128 a) |
aurel32 | c52ab6f | 2008-12-15 17:14:20 +0000 | [diff] [blame] | 733 | { |
| 734 | return (a.high & 0x7fffffffffffffffLL) == 0x7fff000000000000LL && a.low == 0; |
| 735 | } |
| 736 | |
Luiz Capitulino | a49db98 | 2014-06-19 10:13:43 -0400 | [diff] [blame] | 737 | static inline int float128_is_neg(float128 a) |
aurel32 | c52ab6f | 2008-12-15 17:14:20 +0000 | [diff] [blame] | 738 | { |
| 739 | return a.high >> 63; |
| 740 | } |
| 741 | |
Luiz Capitulino | a49db98 | 2014-06-19 10:13:43 -0400 | [diff] [blame] | 742 | static inline int float128_is_zero(float128 a) |
aurel32 | c52ab6f | 2008-12-15 17:14:20 +0000 | [diff] [blame] | 743 | { |
| 744 | return (a.high & 0x7fffffffffffffffLL) == 0 && a.low == 0; |
| 745 | } |
| 746 | |
Luiz Capitulino | a49db98 | 2014-06-19 10:13:43 -0400 | [diff] [blame] | 747 | static inline int float128_is_zero_or_denormal(float128 a) |
Aurelien Jarno | 587eabf | 2011-05-15 14:09:18 +0200 | [diff] [blame] | 748 | { |
| 749 | return (a.high & 0x7fff000000000000LL) == 0; |
| 750 | } |
| 751 | |
Luiz Capitulino | a49db98 | 2014-06-19 10:13:43 -0400 | [diff] [blame] | 752 | static inline int float128_is_any_nan(float128 a) |
Peter Maydell | 2bed652 | 2011-01-06 18:34:43 +0000 | [diff] [blame] | 753 | { |
| 754 | return ((a.high >> 48) & 0x7fff) == 0x7fff && |
| 755 | ((a.low != 0) || ((a.high & 0xffffffffffffLL) != 0)); |
| 756 | } |
| 757 | |
Richard Henderson | 1e397ea | 2012-12-31 10:09:04 -0800 | [diff] [blame] | 758 | #define float128_zero make_float128(0, 0) |
| 759 | |
Christophe Lyon | 8559666 | 2011-02-21 17:38:44 +0100 | [diff] [blame] | 760 | /*---------------------------------------------------------------------------- |
Paolo Bonzini | 789ec7c | 2011-07-28 12:10:29 +0200 | [diff] [blame] | 761 | | The pattern for a default generated quadruple-precision NaN. |
Christophe Lyon | 8559666 | 2011-02-21 17:38:44 +0100 | [diff] [blame] | 762 | *----------------------------------------------------------------------------*/ |
Paolo Bonzini | 789ec7c | 2011-07-28 12:10:29 +0200 | [diff] [blame] | 763 | extern const float128 float128_default_nan; |
Christophe Lyon | 8559666 | 2011-02-21 17:38:44 +0100 | [diff] [blame] | 764 | |
bellard | 158142c | 2005-03-13 16:54:06 +0000 | [diff] [blame] | 765 | #endif /* !SOFTFLOAT_H */ |