• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

sst/elements/genericProc/FE/ppcFrontEnd/softfloat/softfloat.h

00001 #ifndef __SOFTFLOAT_H__
00002 #define __SOFTFLOAT_H__
00003 /*============================================================================
00004 
00005 This C header file is part of the SoftFloat IEC/IEEE Floating-point Arithmetic
00006 Package, Release 2b.
00007 
00008 Written by John R. Hauser.  This work was made possible in part by the
00009 International Computer Science Institute, located at Suite 600, 1947 Center
00010 Street, Berkeley, California 94704.  Funding was partially provided by the
00011 National Science Foundation under grant MIP-9311980.  The original version
00012 of this code was written as part of a project to build a fixed-point vector
00013 processor in collaboration with the University of California at Berkeley,
00014 overseen by Profs. Nelson Morgan and John Wawrzynek.  More information
00015 is available through the Web page `http://www.cs.berkeley.edu/~jhauser/
00016 arithmetic/SoftFloat.html'.
00017 
00018 THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE.  Although reasonable effort has
00019 been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT TIMES
00020 RESULT IN INCORRECT BEHAVIOR.  USE OF THIS SOFTWARE IS RESTRICTED TO PERSONS
00021 AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ALL LOSSES,
00022 COSTS, OR OTHER PROBLEMS THEY INCUR DUE TO THE SOFTWARE, AND WHO FURTHERMORE
00023 EFFECTIVELY INDEMNIFY JOHN HAUSER AND THE INTERNATIONAL COMPUTER SCIENCE
00024 INSTITUTE (possibly via similar legal warning) AGAINST ALL LOSSES, COSTS, OR
00025 OTHER PROBLEMS INCURRED BY THEIR CUSTOMERS AND CLIENTS DUE TO THE SOFTWARE.
00026 
00027 Derivative works are acceptable, even for commercial purposes, so long as
00028 (1) the source code for the derivative work includes prominent notice that
00029 the work is derivative, and (2) the source code includes prominent notice with
00030 these four paragraphs for those parts of this code that are retained.
00031 
00032 =============================================================================*/
00033 
00034 #ifdef __cplusplus
00035 extern "C" {
00036 #endif
00037 
00038 /*----------------------------------------------------------------------------
00039 | The macro `FLOATX80' must be defined to enable the extended double-precision
00040 | floating-point format `floatx80'.  If this macro is not defined, the
00041 | `floatx80' type will not be defined, and none of the functions that either
00042 | input or output the `floatx80' type will be defined.  The same applies to
00043 | the `FLOAT128' macro and the quadruple-precision format `float128'.
00044 *----------------------------------------------------------------------------*/
00045 #define FLOATX80
00046 #define FLOAT128
00047 
00048 /*----------------------------------------------------------------------------
00049 | Software IEC/IEEE floating-point types.
00050 *----------------------------------------------------------------------------*/
00051 typedef unsigned int float32;
00052 typedef unsigned long long float64;
00053 #ifdef FLOATX80
00054 typedef struct {
00055     unsigned short high;
00056     unsigned long long low;
00057 } floatx80;
00058 #endif
00059 #ifdef FLOAT128
00060 typedef struct {
00061     unsigned long long high, low;
00062 } float128;
00063 #endif
00064 
00065 /*----------------------------------------------------------------------------
00066 | Software IEC/IEEE floating-point underflow tininess-detection mode.
00067 *----------------------------------------------------------------------------*/
00068 extern int float_detect_tininess;
00069 enum {
00070     float_tininess_after_rounding  = 0,
00071     float_tininess_before_rounding = 1
00072 };
00073 
00074 /*----------------------------------------------------------------------------
00075 | Software IEC/IEEE floating-point rounding mode.
00076 *----------------------------------------------------------------------------*/
00077 extern int8 float_rounding_mode;
00078 enum {
00079     float_round_nearest_even = 0,
00080     float_round_to_zero      = 1,
00081     float_round_up           = 2,
00082     float_round_down         = 3
00083 };
00084 
00085 /*----------------------------------------------------------------------------
00086 | Software IEC/IEEE floating-point exception flags.
00087 *----------------------------------------------------------------------------*/
00088 extern int float_exception_flags;
00089 enum {
00090     float_flag_inexact   =  1,
00091     float_flag_divbyzero =  2,
00092     float_flag_underflow =  4,
00093     float_flag_overflow  =  8,
00094     float_flag_invalid   = 16
00095 };
00096 
00097 /*----------------------------------------------------------------------------
00098  * wcmclen: rounding-detection for ppc FPSCR FR register 
00099  *----------------------------------------------------------------------------*/
00100 extern int float_rounding_flags;
00101 enum {
00102     float_rounding_no  = 0,
00103     float_rounding_yes = 1
00104 };
00105 
00106 /*----------------------------------------------------------------------------
00107 | Routine to raise any or all of the software IEC/IEEE floating-point
00108 | exception flags.
00109 *----------------------------------------------------------------------------*/
00110 void float_raise( int );
00111 
00112 /*----------------------------------------------------------------------------
00113 | Software IEC/IEEE integer-to-floating-point conversion routines.
00114 *----------------------------------------------------------------------------*/
00115 float32 int32_to_float32( int );
00116 float64 int32_to_float64( int );
00117 #ifdef FLOATX80
00118 floatx80 int32_to_floatx80( int );
00119 #endif
00120 #ifdef FLOAT128
00121 float128 int32_to_float128( int );
00122 #endif
00123 float32 int64_to_float32( long long );
00124 float64 int64_to_float64( long long );
00125 #ifdef FLOATX80
00126 floatx80 int64_to_floatx80( long long );
00127 #endif
00128 #ifdef FLOAT128
00129 float128 int64_to_float128( long long );
00130 #endif
00131 
00132 /*----------------------------------------------------------------------------
00133 | Software IEC/IEEE single-precision conversion routines.
00134 *----------------------------------------------------------------------------*/
00135 int float32_to_int32( float32 );
00136 int float32_to_int32_round_to_zero( float32 );
00137 long long float32_to_int64( float32 );
00138 long long float32_to_int64_round_to_zero( float32 );
00139 float64 float32_to_float64( float32 );
00140 #ifdef FLOATX80
00141 floatx80 float32_to_floatx80( float32 );
00142 #endif
00143 #ifdef FLOAT128
00144 float128 float32_to_float128( float32 );
00145 #endif
00146 
00147 /*----------------------------------------------------------------------------
00148 | Software IEC/IEEE single-precision operations.
00149 *----------------------------------------------------------------------------*/
00150 float32 float32_round_to_int( float32 );
00151 float32 float32_add( float32, float32 );
00152 float32 float32_sub( float32, float32 );
00153 float32 float32_mul( float32, float32 );
00154 float32 float32_div( float32, float32 );
00155 float32 float32_rem( float32, float32 );
00156 float32 float32_sqrt( float32 );
00157 int float32_eq( float32, float32 );
00158 int float32_le( float32, float32 );
00159 int float32_lt( float32, float32 );
00160 int float32_eq_signaling( float32, float32 );
00161 int float32_le_quiet( float32, float32 );
00162 int float32_lt_quiet( float32, float32 );
00163 int float32_is_signaling_nan( float32 );
00164 
00165 /*----------------------------------------------------------------------------
00166 | Software IEC/IEEE double-precision conversion routines.
00167 *----------------------------------------------------------------------------*/
00168 int float64_to_int32( float64 );
00169 int float64_to_int32_round_to_zero( float64 );
00170 long long float64_to_int64( float64 );
00171 long long float64_to_int64_round_to_zero( float64 );
00172 float32 float64_to_float32( float64 );
00173 #ifdef FLOATX80
00174 floatx80 float64_to_floatx80( float64 );
00175 #endif
00176 #ifdef FLOAT128
00177 float128 float64_to_float128( float64 );
00178 #endif
00179 
00180 /*----------------------------------------------------------------------------
00181 | Software IEC/IEEE double-precision operations.
00182 *----------------------------------------------------------------------------*/
00183 float64 float64_round_to_int( float64 );
00184 float64 float64_add( float64, float64 );
00185 float64 float64_sub( float64, float64 );
00186 float64 float64_mul( float64, float64 );
00187 float64 float64_div( float64, float64 );
00188 float64 float64_rem( float64, float64 );
00189 float64 float64_sqrt( float64 );
00190 int float64_eq( float64, float64 );
00191 int float64_le( float64, float64 );
00192 int float64_lt( float64, float64 );
00193 int float64_eq_signaling( float64, float64 );
00194 int float64_le_quiet( float64, float64 );
00195 int float64_lt_quiet( float64, float64 );
00196 int float64_is_signaling_nan( float64 );
00197 
00198 #ifdef FLOATX80
00199 
00200 /*----------------------------------------------------------------------------
00201 | Software IEC/IEEE extended double-precision conversion routines.
00202 *----------------------------------------------------------------------------*/
00203 int floatx80_to_int32( floatx80 );
00204 int floatx80_to_int32_round_to_zero( floatx80 );
00205 long long floatx80_to_int64( floatx80 );
00206 long long floatx80_to_int64_round_to_zero( floatx80 );
00207 float32 floatx80_to_float32( floatx80 );
00208 float64 floatx80_to_float64( floatx80 );
00209 #ifdef FLOAT128
00210 float128 floatx80_to_float128( floatx80 );
00211 #endif
00212 
00213 /*----------------------------------------------------------------------------
00214 | Software IEC/IEEE extended double-precision rounding precision.  Valid
00215 | values are 32, 64, and 80.
00216 *----------------------------------------------------------------------------*/
00217 extern int floatx80_rounding_precision;
00218 
00219 /*----------------------------------------------------------------------------
00220 | Software IEC/IEEE extended double-precision operations.
00221 *----------------------------------------------------------------------------*/
00222 floatx80 floatx80_round_to_int( floatx80 );
00223 floatx80 floatx80_add( floatx80, floatx80 );
00224 floatx80 floatx80_sub( floatx80, floatx80 );
00225 floatx80 floatx80_mul( floatx80, floatx80 );
00226 floatx80 floatx80_div( floatx80, floatx80 );
00227 floatx80 floatx80_rem( floatx80, floatx80 );
00228 floatx80 floatx80_sqrt( floatx80 );
00229 int floatx80_eq( floatx80, floatx80 );
00230 int floatx80_le( floatx80, floatx80 );
00231 int floatx80_lt( floatx80, floatx80 );
00232 int floatx80_eq_signaling( floatx80, floatx80 );
00233 int floatx80_le_quiet( floatx80, floatx80 );
00234 int floatx80_lt_quiet( floatx80, floatx80 );
00235 int floatx80_is_signaling_nan( floatx80 );
00236 
00237 #endif
00238 
00239 #ifdef FLOAT128
00240 
00241 /*----------------------------------------------------------------------------
00242 | Software IEC/IEEE quadruple-precision conversion routines.
00243 *----------------------------------------------------------------------------*/
00244 int float128_to_int32( float128 );
00245 int float128_to_int32_round_to_zero( float128 );
00246 long long float128_to_int64( float128 );
00247 long long float128_to_int64_round_to_zero( float128 );
00248 float32 float128_to_float32( float128 );
00249 float64 float128_to_float64( float128 );
00250 #ifdef FLOATX80
00251 floatx80 float128_to_floatx80( float128 );
00252 #endif
00253 
00254 /*----------------------------------------------------------------------------
00255 | Software IEC/IEEE quadruple-precision operations.
00256 *----------------------------------------------------------------------------*/
00257 float128 float128_round_to_int( float128 );
00258 float128 float128_add( float128, float128 );
00259 float128 float128_sub( float128, float128 );
00260 float128 float128_mul( float128, float128 );
00261 float128 float128_div( float128, float128 );
00262 float128 float128_rem( float128, float128 );
00263 float128 float128_sqrt( float128 );
00264 int float128_eq( float128, float128 );
00265 int float128_le( float128, float128 );
00266 int float128_lt( float128, float128 );
00267 int float128_eq_signaling( float128, float128 );
00268 int float128_le_quiet( float128, float128 );
00269 int float128_lt_quiet( float128, float128 );
00270 int float128_is_signaling_nan( float128 );
00271 
00272 #endif
00273 
00274 #ifdef __cplusplus
00275 };
00276 #endif
00277 
00278 
00279 #endif

Generated on Fri Oct 22 2010 11:02:22 for SST by  doxygen 1.7.1