/[qemu]/qemu/fpu/softfloat.c
ViewVC logotype

Diff of /qemu/fpu/softfloat.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by bellard, Sun Mar 13 16:54:06 2005 UTC revision 1.2 by bellard, Sun Mar 13 18:52:28 2005 UTC
# Line 54  void set_float_rounding_mode(int val STA Line 54  void set_float_rounding_mode(int val STA
54      STATUS(float_rounding_mode) = val;      STATUS(float_rounding_mode) = val;
55  }  }
56    
57    void set_float_exception_flags(int val STATUS_PARAM)
58    {
59        STATUS(float_exception_flags) = val;
60    }
61    
62  #ifdef FLOATX80  #ifdef FLOATX80
63  void set_floatx80_rounding_precision(int val STATUS_PARAM)  void set_floatx80_rounding_precision(int val STATUS_PARAM)
64  {  {
# Line 5183  flag float128_lt_quiet( float128 a, floa Line 5188  flag float128_lt_quiet( float128 a, floa
5188    
5189  #endif  #endif
5190    
5191    /* misc functions */
5192    float32 uint32_to_float32( unsigned int a STATUS_PARAM )
5193    {
5194        return int64_to_float32(a STATUS_VAR);
5195    }
5196    
5197    float64 uint32_to_float64( unsigned int a STATUS_PARAM )
5198    {
5199        return int64_to_float64(a STATUS_VAR);
5200    }
5201    
5202    unsigned int float32_to_uint32( float32 a STATUS_PARAM )
5203    {
5204        int64_t v;
5205        unsigned int res;
5206    
5207        v = float32_to_int64(a STATUS_VAR);
5208        if (v < 0) {
5209            res = 0;
5210            float_raise( float_flag_invalid STATUS_VAR);
5211        } else if (v > 0xffffffff) {
5212            res = 0xffffffff;
5213            float_raise( float_flag_invalid STATUS_VAR);
5214        } else {
5215            res = v;
5216        }
5217        return res;
5218    }
5219    
5220    unsigned int float32_to_uint32_round_to_zero( float32 a STATUS_PARAM )
5221    {
5222        int64_t v;
5223        unsigned int res;
5224    
5225        v = float32_to_int64_round_to_zero(a STATUS_VAR);
5226        if (v < 0) {
5227            res = 0;
5228            float_raise( float_flag_invalid STATUS_VAR);
5229        } else if (v > 0xffffffff) {
5230            res = 0xffffffff;
5231            float_raise( float_flag_invalid STATUS_VAR);
5232        } else {
5233            res = v;
5234        }
5235        return res;
5236    }
5237    
5238    unsigned int float64_to_uint32( float64 a STATUS_PARAM )
5239    {
5240        int64_t v;
5241        unsigned int res;
5242    
5243        v = float64_to_int64(a STATUS_VAR);
5244        if (v < 0) {
5245            res = 0;
5246            float_raise( float_flag_invalid STATUS_VAR);
5247        } else if (v > 0xffffffff) {
5248            res = 0xffffffff;
5249            float_raise( float_flag_invalid STATUS_VAR);
5250        } else {
5251            res = v;
5252        }
5253        return res;
5254    }
5255    
5256    unsigned int float64_to_uint32_round_to_zero( float64 a STATUS_PARAM )
5257    {
5258        int64_t v;
5259        unsigned int res;
5260    
5261        v = float64_to_int64_round_to_zero(a STATUS_VAR);
5262        if (v < 0) {
5263            res = 0;
5264            float_raise( float_flag_invalid STATUS_VAR);
5265        } else if (v > 0xffffffff) {
5266            res = 0xffffffff;
5267            float_raise( float_flag_invalid STATUS_VAR);
5268        } else {
5269            res = v;
5270        }
5271        return res;
5272    }
5273    
5274    #define COMPARE(s, nan_exp)                                                  \
5275    INLINE char float ## s ## _compare_internal( float ## s a, float ## s b,     \
5276                                          int is_quiet STATUS_PARAM )            \
5277    {                                                                            \
5278        flag aSign, bSign;                                                       \
5279                                                                                 \
5280        if (( ( extractFloat ## s ## Exp( a ) == nan_exp ) &&                    \
5281             extractFloat ## s ## Frac( a ) ) ||                                 \
5282            ( ( extractFloat ## s ## Exp( b ) == nan_exp ) &&                    \
5283              extractFloat ## s ## Frac( b ) )) {                                \
5284            if (!is_quiet ||                                                     \
5285                float ## s ## _is_signaling_nan( a ) ||                          \
5286                float ## s ## _is_signaling_nan( b ) ) {                         \
5287                float_raise( float_flag_invalid STATUS_VAR);                     \
5288            }                                                                    \
5289            return float_relation_unordered;                                     \
5290        }                                                                        \
5291        aSign = extractFloat ## s ## Sign( a );                                  \
5292        bSign = extractFloat ## s ## Sign( b );                                  \
5293        if ( aSign != bSign ) {                                                  \
5294            if ( (bits ## s) ( ( a | b )<<1 ) == 0 ) {                           \
5295                /* zero case */                                                  \
5296                return float_relation_equal;                                     \
5297            } else {                                                             \
5298                return 1 - (2 * aSign);                                          \
5299            }                                                                    \
5300        } else {                                                                 \
5301            if (a == b) {                                                        \
5302                return float_relation_equal;                                     \
5303            } else {                                                             \
5304                return 1 - 2 * (aSign ^ ( a < b ));                              \
5305            }                                                                    \
5306        }                                                                        \
5307    }                                                                            \
5308                                                                                 \
5309    char float ## s ## _compare( float ## s a, float ## s b STATUS_PARAM )       \
5310    {                                                                            \
5311        return float ## s ## _compare_internal(a, b, 0 STATUS_VAR);              \
5312    }                                                                            \
5313                                                                                 \
5314    char float ## s ## _compare_quiet( float ## s a, float ## s b STATUS_PARAM ) \
5315    {                                                                            \
5316        return float ## s ## _compare_internal(a, b, 1 STATUS_VAR);              \
5317    }
5318    
5319    COMPARE(32, 0xff)
5320    COMPARE(64, 0x7ff)

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26