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