softfloat.h

Go to the documentation of this file.
00001 #ifndef __SOFTFLOAT_H__
00002 #define __SOFTFLOAT_H__
00003 /*
00004 ===============================================================================
00005 
00006 This C header file is part of the SoftFloat IEC/IEEE Floating-point
00007 Arithmetic Package, Release 2.
00008 
00009 Written by John R. Hauser.  This work was made possible in part by the
00010 International Computer Science Institute, located at Suite 600, 1947 Center
00011 Street, Berkeley, California 94704.  Funding was partially provided by the
00012 National Science Foundation under grant MIP-9311980.  The original version
00013 of this code was written as part of a project to build a fixed-point vector
00014 processor in collaboration with the University of California at Berkeley,
00015 overseen by Profs. Nelson Morgan and John Wawrzynek.  More information
00016 is available through the Web page `http://http.cs.berkeley.edu/~jhauser/
00017 arithmetic/softfloat.html'.
00018 
00019 THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE.  Although reasonable effort
00020 has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT
00021 TIMES RESULT IN INCORRECT BEHAVIOR.  USE OF THIS SOFTWARE IS RESTRICTED TO
00022 PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY
00023 AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE.
00024 
00025 Derivative works are acceptable, even for commercial purposes, so long as
00026 (1) they include prominent notice that the work is derivative, and (2) they
00027 include prominent notice akin to these three paragraphs for those parts of
00028 this code that are retained.
00029 
00030 ===============================================================================
00031 */
00032 /*
00033  Modifications to the structure of the file and the passing
00034  of status variables by Thomas Fletcher QNX Software Systems
00035  November 19, 1998.
00036 
00037  Contributions by Gregory Rogers <grogers@cray.com> for the
00038  int64 conversion routines. See softfloat.c
00039 */
00040 
00041 //All of our configuration lies here ...
00042 #include "fp-config.h"
00043 
00044 /*
00045 -------------------------------------------------------------------------------
00046 Brought in from softfloat-specialize (why is it there?)
00047 -------------------------------------------------------------------------------
00048 */
00049 typedef struct {
00050     flag sign;
00051     bits64 high, low;
00052 } commonNaNT;
00053 
00054 /*
00055 -------------------------------------------------------------------------------
00056 Routine to initialize the run time options
00057 -------------------------------------------------------------------------------
00058 */
00059 void softfloat_env_init(run_options *op);
00060 
00061 /*
00062 -------------------------------------------------------------------------------
00063 Routine to raise any or all of the software IEC/IEEE floating-point
00064 exception flags.
00065 -------------------------------------------------------------------------------
00066 */
00067 void float_raise( int8, run_options *ro );
00068 
00069 /*
00070 -------------------------------------------------------------------------------
00071 Software IEC/IEEE integer-to-floating-point conversion routines.
00072 -------------------------------------------------------------------------------
00073 */
00074 float32 int32_to_float32( int, run_options *ro );
00075 float64 int32_to_float64( int, run_options *ro );
00076 float32 int64_to_float32( int64, run_options *ro );
00077 float64 int64_to_float64( int64, run_options *ro );
00078 #ifdef FLOATX80
00079 floatx80 int32_to_floatx80( int, run_options *ro );
00080 #endif
00081 #ifdef FLOAT128
00082 float128 int32_to_float128( int, run_options *ro );
00083 #endif
00084 
00085 /*
00086 -------------------------------------------------------------------------------
00087 Software IEC/IEEE single-precision conversion routines.
00088 -------------------------------------------------------------------------------
00089 */
00090 int32 float32_to_int32( float32, run_options *ro );
00091 int64 float32_to_int64( float32, run_options *ro );
00092 int32 float32_to_int32_round_to_zero( float32, run_options *ro );
00093 float64 float32_to_float64( float32, run_options *ro );
00094 #ifdef FLOATX80
00095 floatx80 float32_to_floatx80( float32, run_options *ro );
00096 #endif
00097 #ifdef FLOAT128
00098 float128 float32_to_float128( float32, run_options *ro );
00099 #endif
00100 
00101 /*
00102 -------------------------------------------------------------------------------
00103 Software IEC/IEEE single-precision operations.
00104 -------------------------------------------------------------------------------
00105 */
00106 float32 float32_round_to_int( float32, run_options *ro );
00107 float32 float32_add( float32, float32, run_options *ro );
00108 float32 float32_sub( float32, float32, run_options *ro );
00109 float32 float32_mul( float32, float32, run_options *ro );
00110 float32 float32_div( float32, float32, run_options *ro );
00111 float32 float32_rem( float32, float32, run_options *ro );
00112 float32 float32_sqrt( float32, run_options *ro );
00113 flag float32_eq( float32, float32, run_options *ro );
00114 flag float32_le( float32, float32, run_options *ro );
00115 flag float32_lt( float32, float32, run_options *ro );
00116 flag float32_eq_signaling( float32, float32, run_options *ro );
00117 flag float32_le_quiet( float32, float32, run_options *ro );
00118 flag float32_lt_quiet( float32, float32, run_options *ro );
00119 flag float32_is_signaling_nan( float32 );
00120 
00121 /*
00122 -------------------------------------------------------------------------------
00123 Software IEC/IEEE double-precision conversion routines.
00124 -------------------------------------------------------------------------------
00125 */
00126 int32 float64_to_int32( float64, run_options *ro );
00127 int64 float64_to_int64( float64, run_options *ro );
00128 int32 float64_to_int32_round_to_zero( float64, run_options *ro );
00129 float32 float64_to_float32( float64, run_options *ro );
00130 #ifdef FLOATX80
00131 floatx80 float64_to_floatx80( float64, run_options *ro );
00132 #endif
00133 #ifdef FLOAT128
00134 float128 float64_to_float128( float64, run_options *ro );
00135 #endif
00136 
00137 //Additional functions made available (TF)
00138 int float64ZeroType(float64 a) __attribute__((const));
00139 int float64InfType(float64 a) __attribute__((const));
00140 int float64SubnormType(float64 a) __attribute__((const));
00141 flag float64_is_nan(float64 a) __attribute__((const));
00142 flag float32_is_nan(float32 a) __attribute__((const));
00143 
00144 /*
00145 -------------------------------------------------------------------------------
00146 Software IEC/IEEE double-precision operations.
00147 -------------------------------------------------------------------------------
00148 */
00149 float64 float64_round_to_int( float64, run_options *ro );
00150 float64 float64_add( float64, float64, run_options *ro );
00151 float64 float64_sub( float64, float64, run_options *ro );
00152 float64 float64_mul( float64, float64, run_options *ro );
00153 float64 float64_div( float64, float64, run_options *ro );
00154 float64 float64_rem( float64, float64, run_options *ro );
00155 float64 float64_sqrt( float64, run_options *ro );
00156 flag float64_eq( float64, float64, run_options *ro );
00157 flag float64_le( float64, float64, run_options *ro );
00158 flag float64_lt( float64, float64, run_options *ro );
00159 flag float64_eq_signaling( float64, float64, run_options *ro );
00160 flag float64_le_quiet( float64, float64, run_options *ro );
00161 flag float64_lt_quiet( float64, float64, run_options *ro );
00162 flag float64_is_signaling_nan( float64 );
00163 
00164 #ifdef FLOATX80
00165 
00166 /*
00167 -------------------------------------------------------------------------------
00168 Software IEC/IEEE extended double-precision conversion routines.
00169 -------------------------------------------------------------------------------
00170 */
00171 int32 floatx80_to_int32( floatx80, run_options *ro );
00172 int32 floatx80_to_int32_round_to_zero( floatx80, run_options *ro );
00173 float32 floatx80_to_float32( floatx80, run_options *ro );
00174 float64 floatx80_to_float64( floatx80, run_options *ro );
00175 #ifdef FLOAT128
00176 float128 floatx80_to_float128( floatx80, run_options *ro );
00177 #endif
00178 
00179 /*
00180 -------------------------------------------------------------------------------
00181 Software IEC/IEEE extended double-precision rounding precision.  Valid
00182 values are 32, 64, and 80.
00183 -------------------------------------------------------------------------------
00184 extern signed char floatx80_rounding_precision;
00185 */
00186 
00187 /*
00188 -------------------------------------------------------------------------------
00189 Software IEC/IEEE extended double-precision operations.
00190 -------------------------------------------------------------------------------
00191 */
00192 floatx80 floatx80_round_to_int( floatx80, run_options *ro );
00193 floatx80 floatx80_add( floatx80, floatx80, run_options *ro );
00194 floatx80 floatx80_sub( floatx80, floatx80, run_options *ro );
00195 floatx80 floatx80_mul( floatx80, floatx80, run_options *ro );
00196 floatx80 floatx80_div( floatx80, floatx80, run_options *ro );
00197 floatx80 floatx80_rem( floatx80, floatx80, run_options *ro );
00198 floatx80 floatx80_sqrt( floatx80, run_options *ro );
00199 flag floatx80_eq( floatx80, floatx80, run_options *ro );
00200 flag floatx80_le( floatx80, floatx80, run_options *ro );
00201 flag floatx80_lt( floatx80, floatx80, run_options *ro );
00202 flag floatx80_eq_signaling( floatx80, floatx80, run_options *ro );
00203 flag floatx80_le_quiet( floatx80, floatx80, run_options *ro );
00204 flag floatx80_lt_quiet( floatx80, floatx80, run_options *ro );
00205 flag floatx80_is_signaling_nan( floatx80 );
00206 
00207 #endif
00208 
00209 #ifdef FLOAT128
00210 
00211 /*
00212 -------------------------------------------------------------------------------
00213 Software IEC/IEEE quadruple-precision conversion routines.
00214 -------------------------------------------------------------------------------
00215 */
00216 int32 float128_to_int32( float128, run_options *ro );
00217 int32 float128_to_int32_round_to_zero( float128, run_options *ro );
00218 float32 float128_to_float32( float128, run_options *ro );
00219 float64 float128_to_float64( float128, run_options *ro );
00220 #ifdef FLOATX80
00221 floatx80 float128_to_floatx80( float128, run_options *ro );
00222 #endif
00223 
00224 /*
00225 -------------------------------------------------------------------------------
00226 Software IEC/IEEE quadruple-precision operations.
00227 -------------------------------------------------------------------------------
00228 */
00229 float128 float128_round_to_int( float128, run_options *ro );
00230 float128 float128_add( float128, float128, run_options *ro );
00231 float128 float128_sub( float128, float128, run_options *ro );
00232 float128 float128_mul( float128, float128, run_options *ro );
00233 float128 float128_div( float128, float128, run_options *ro );
00234 float128 float128_rem( float128, float128, run_options *ro );
00235 float128 float128_sqrt( float128, run_options *ro );
00236 flag float128_eq( float128, float128, run_options *ro );
00237 flag float128_le( float128, float128, run_options *ro );
00238 flag float128_lt( float128, float128, run_options *ro );
00239 flag float128_eq_signaling( float128, float128, run_options *ro );
00240 flag float128_le_quiet( float128, float128, run_options *ro );
00241 flag float128_lt_quiet( float128, float128, run_options *ro );
00242 flag float128_is_signaling_nan( float128 );
00243 
00244 #endif
00245 #endif
00246 
00247 __SRCVERSION( "$URL: http://svn.ott.qnx.com/product/trunk/lib/ieee754/softfloat/softfloat.h $ $Rev: 224061 $" )

Generated on Fri Nov 13 15:38:37 2009 for fpassist for PPC SPE by  doxygen 1.5.9