1e34c47eaSAlex Bennée /* 2e34c47eaSAlex Bennée * QEMU float support - standalone helpers 3e34c47eaSAlex Bennée * 4e34c47eaSAlex Bennée * This is provided for files that don't need the access to the full 5e34c47eaSAlex Bennée * set of softfloat functions. Typically this is cpu initialisation 6e34c47eaSAlex Bennée * code which wants to set default rounding and exceptions modes. 7e34c47eaSAlex Bennée * 8e34c47eaSAlex Bennée * The code in this source file is derived from release 2a of the SoftFloat 9e34c47eaSAlex Bennée * IEC/IEEE Floating-point Arithmetic Package. Those parts of the code (and 10e34c47eaSAlex Bennée * some later contributions) are provided under that license, as detailed below. 11e34c47eaSAlex Bennée * It has subsequently been modified by contributors to the QEMU Project, 12e34c47eaSAlex Bennée * so some portions are provided under: 13e34c47eaSAlex Bennée * the SoftFloat-2a license 14e34c47eaSAlex Bennée * the BSD license 15e34c47eaSAlex Bennée * GPL-v2-or-later 16e34c47eaSAlex Bennée * 17e34c47eaSAlex Bennée * Any future contributions to this file after December 1st 2014 will be 18e34c47eaSAlex Bennée * taken to be licensed under the Softfloat-2a license unless specifically 19e34c47eaSAlex Bennée * indicated otherwise. 20e34c47eaSAlex Bennée */ 21e34c47eaSAlex Bennée 22e34c47eaSAlex Bennée /* 23e34c47eaSAlex Bennée =============================================================================== 24e34c47eaSAlex Bennée This C header file is part of the SoftFloat IEC/IEEE Floating-point 25e34c47eaSAlex Bennée Arithmetic Package, Release 2a. 26e34c47eaSAlex Bennée 27e34c47eaSAlex Bennée Written by John R. Hauser. This work was made possible in part by the 28e34c47eaSAlex Bennée International Computer Science Institute, located at Suite 600, 1947 Center 29e34c47eaSAlex Bennée Street, Berkeley, California 94704. Funding was partially provided by the 30e34c47eaSAlex Bennée National Science Foundation under grant MIP-9311980. The original version 31e34c47eaSAlex Bennée of this code was written as part of a project to build a fixed-point vector 32e34c47eaSAlex Bennée processor in collaboration with the University of California at Berkeley, 33e34c47eaSAlex Bennée overseen by Profs. Nelson Morgan and John Wawrzynek. More information 34e34c47eaSAlex Bennée is available through the Web page `http://HTTP.CS.Berkeley.EDU/~jhauser/ 35e34c47eaSAlex Bennée arithmetic/SoftFloat.html'. 36e34c47eaSAlex Bennée 37e34c47eaSAlex Bennée THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort 38e34c47eaSAlex Bennée has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT 39e34c47eaSAlex Bennée TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO 40e34c47eaSAlex Bennée PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY 41e34c47eaSAlex Bennée AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE. 42e34c47eaSAlex Bennée 43e34c47eaSAlex Bennée Derivative works are acceptable, even for commercial purposes, so long as 44e34c47eaSAlex Bennée (1) they include prominent notice that the work is derivative, and (2) they 45e34c47eaSAlex Bennée include prominent notice akin to these four paragraphs for those parts of 46e34c47eaSAlex Bennée this code that are retained. 47e34c47eaSAlex Bennée 48e34c47eaSAlex Bennée =============================================================================== 49e34c47eaSAlex Bennée */ 50e34c47eaSAlex Bennée 51e52ee00dSAhmed Abouzied #ifndef SOFTFLOAT_HELPERS_H 52e52ee00dSAhmed Abouzied #define SOFTFLOAT_HELPERS_H 53e34c47eaSAlex Bennée 54e34c47eaSAlex Bennée #include "fpu/softfloat-types.h" 55e34c47eaSAlex Bennée 56a828b373SRichard Henderson static inline void set_float_detect_tininess(bool val, float_status *status) 57e34c47eaSAlex Bennée { 58a828b373SRichard Henderson status->tininess_before_rounding = val; 59e34c47eaSAlex Bennée } 60e34c47eaSAlex Bennée 613dede407SRichard Henderson static inline void set_float_rounding_mode(FloatRoundMode val, 623dede407SRichard Henderson float_status *status) 63e34c47eaSAlex Bennée { 64e34c47eaSAlex Bennée status->float_rounding_mode = val; 65e34c47eaSAlex Bennée } 66e34c47eaSAlex Bennée 67e34c47eaSAlex Bennée static inline void set_float_exception_flags(int val, float_status *status) 68e34c47eaSAlex Bennée { 69e34c47eaSAlex Bennée status->float_exception_flags = val; 70e34c47eaSAlex Bennée } 71e34c47eaSAlex Bennée 728da5f1dbSRichard Henderson static inline void set_floatx80_rounding_precision(FloatX80RoundPrec val, 73e34c47eaSAlex Bennée float_status *status) 74e34c47eaSAlex Bennée { 75e34c47eaSAlex Bennée status->floatx80_rounding_precision = val; 76e34c47eaSAlex Bennée } 77e34c47eaSAlex Bennée 78c120391cSRichard Henderson static inline void set_flush_to_zero(bool val, float_status *status) 79e34c47eaSAlex Bennée { 80e34c47eaSAlex Bennée status->flush_to_zero = val; 81e34c47eaSAlex Bennée } 82e34c47eaSAlex Bennée 83c120391cSRichard Henderson static inline void set_flush_inputs_to_zero(bool val, float_status *status) 84e34c47eaSAlex Bennée { 85e34c47eaSAlex Bennée status->flush_inputs_to_zero = val; 86e34c47eaSAlex Bennée } 87e34c47eaSAlex Bennée 88c120391cSRichard Henderson static inline void set_default_nan_mode(bool val, float_status *status) 89e34c47eaSAlex Bennée { 90e34c47eaSAlex Bennée status->default_nan_mode = val; 91e34c47eaSAlex Bennée } 92e34c47eaSAlex Bennée 93c120391cSRichard Henderson static inline void set_snan_bit_is_one(bool val, float_status *status) 94e34c47eaSAlex Bennée { 95e34c47eaSAlex Bennée status->snan_bit_is_one = val; 96e34c47eaSAlex Bennée } 97e34c47eaSAlex Bennée 98913602e3SMax Filippov static inline void set_use_first_nan(bool val, float_status *status) 99913602e3SMax Filippov { 100913602e3SMax Filippov status->use_first_nan = val; 101913602e3SMax Filippov } 102913602e3SMax Filippov 103cc43c692SMax Filippov static inline void set_no_signaling_nans(bool val, float_status *status) 104cc43c692SMax Filippov { 105cc43c692SMax Filippov status->no_signaling_nans = val; 106cc43c692SMax Filippov } 107cc43c692SMax Filippov 108a828b373SRichard Henderson static inline bool get_float_detect_tininess(float_status *status) 109e34c47eaSAlex Bennée { 110a828b373SRichard Henderson return status->tininess_before_rounding; 111e34c47eaSAlex Bennée } 112e34c47eaSAlex Bennée 1133dede407SRichard Henderson static inline FloatRoundMode get_float_rounding_mode(float_status *status) 114e34c47eaSAlex Bennée { 115e34c47eaSAlex Bennée return status->float_rounding_mode; 116e34c47eaSAlex Bennée } 117e34c47eaSAlex Bennée 118e34c47eaSAlex Bennée static inline int get_float_exception_flags(float_status *status) 119e34c47eaSAlex Bennée { 120e34c47eaSAlex Bennée return status->float_exception_flags; 121e34c47eaSAlex Bennée } 122e34c47eaSAlex Bennée 1238da5f1dbSRichard Henderson static inline FloatX80RoundPrec 1248da5f1dbSRichard Henderson get_floatx80_rounding_precision(float_status *status) 125e34c47eaSAlex Bennée { 126e34c47eaSAlex Bennée return status->floatx80_rounding_precision; 127e34c47eaSAlex Bennée } 128e34c47eaSAlex Bennée 129c120391cSRichard Henderson static inline bool get_flush_to_zero(float_status *status) 130e34c47eaSAlex Bennée { 131e34c47eaSAlex Bennée return status->flush_to_zero; 132e34c47eaSAlex Bennée } 133e34c47eaSAlex Bennée 134c120391cSRichard Henderson static inline bool get_flush_inputs_to_zero(float_status *status) 135e34c47eaSAlex Bennée { 136e34c47eaSAlex Bennée return status->flush_inputs_to_zero; 137e34c47eaSAlex Bennée } 138e34c47eaSAlex Bennée 139c120391cSRichard Henderson static inline bool get_default_nan_mode(float_status *status) 140e34c47eaSAlex Bennée { 141e34c47eaSAlex Bennée return status->default_nan_mode; 142e34c47eaSAlex Bennée } 143e34c47eaSAlex Bennée 144*ea9cea93SMarkus Armbruster #endif /* SOFTFLOAT_HELPERS_H */ 145