Revisión | c6baf65000f826a713e8d9b5b35e617b0ca9ab5d (tree) |
---|---|
Tiempo | 2020-05-20 00:42:57 |
Autor | Richard Henderson <richard.henderson@lina...> |
Commiter | Richard Henderson |
softfloat: Inline floatx80 compare specializations
Replace the floatx80 compare specializations with inline functions
that call the standard floatx80_compare{,_quiet} functions.
Use bool as the return type.
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
@@ -5850,263 +5850,6 @@ floatx80 floatx80_sqrt(floatx80 a, float_status *status) | ||
5850 | 5850 | } |
5851 | 5851 | |
5852 | 5852 | /*---------------------------------------------------------------------------- |
5853 | -| Returns 1 if the extended double-precision floating-point value `a' is equal | |
5854 | -| to the corresponding value `b', and 0 otherwise. The invalid exception is | |
5855 | -| raised if either operand is a NaN. Otherwise, the comparison is performed | |
5856 | -| according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic. | |
5857 | -*----------------------------------------------------------------------------*/ | |
5858 | - | |
5859 | -int floatx80_eq(floatx80 a, floatx80 b, float_status *status) | |
5860 | -{ | |
5861 | - | |
5862 | - if (floatx80_invalid_encoding(a) || floatx80_invalid_encoding(b) | |
5863 | - || (extractFloatx80Exp(a) == 0x7FFF | |
5864 | - && (uint64_t) (extractFloatx80Frac(a) << 1)) | |
5865 | - || (extractFloatx80Exp(b) == 0x7FFF | |
5866 | - && (uint64_t) (extractFloatx80Frac(b) << 1)) | |
5867 | - ) { | |
5868 | - float_raise(float_flag_invalid, status); | |
5869 | - return 0; | |
5870 | - } | |
5871 | - return | |
5872 | - ( a.low == b.low ) | |
5873 | - && ( ( a.high == b.high ) | |
5874 | - || ( ( a.low == 0 ) | |
5875 | - && ( (uint16_t) ( ( a.high | b.high )<<1 ) == 0 ) ) | |
5876 | - ); | |
5877 | - | |
5878 | -} | |
5879 | - | |
5880 | -/*---------------------------------------------------------------------------- | |
5881 | -| Returns 1 if the extended double-precision floating-point value `a' is | |
5882 | -| less than or equal to the corresponding value `b', and 0 otherwise. The | |
5883 | -| invalid exception is raised if either operand is a NaN. The comparison is | |
5884 | -| performed according to the IEC/IEEE Standard for Binary Floating-Point | |
5885 | -| Arithmetic. | |
5886 | -*----------------------------------------------------------------------------*/ | |
5887 | - | |
5888 | -int floatx80_le(floatx80 a, floatx80 b, float_status *status) | |
5889 | -{ | |
5890 | - bool aSign, bSign; | |
5891 | - | |
5892 | - if (floatx80_invalid_encoding(a) || floatx80_invalid_encoding(b) | |
5893 | - || (extractFloatx80Exp(a) == 0x7FFF | |
5894 | - && (uint64_t) (extractFloatx80Frac(a) << 1)) | |
5895 | - || (extractFloatx80Exp(b) == 0x7FFF | |
5896 | - && (uint64_t) (extractFloatx80Frac(b) << 1)) | |
5897 | - ) { | |
5898 | - float_raise(float_flag_invalid, status); | |
5899 | - return 0; | |
5900 | - } | |
5901 | - aSign = extractFloatx80Sign( a ); | |
5902 | - bSign = extractFloatx80Sign( b ); | |
5903 | - if ( aSign != bSign ) { | |
5904 | - return | |
5905 | - aSign | |
5906 | - || ( ( ( (uint16_t) ( ( a.high | b.high )<<1 ) ) | a.low | b.low ) | |
5907 | - == 0 ); | |
5908 | - } | |
5909 | - return | |
5910 | - aSign ? le128( b.high, b.low, a.high, a.low ) | |
5911 | - : le128( a.high, a.low, b.high, b.low ); | |
5912 | - | |
5913 | -} | |
5914 | - | |
5915 | -/*---------------------------------------------------------------------------- | |
5916 | -| Returns 1 if the extended double-precision floating-point value `a' is | |
5917 | -| less than the corresponding value `b', and 0 otherwise. The invalid | |
5918 | -| exception is raised if either operand is a NaN. The comparison is performed | |
5919 | -| according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic. | |
5920 | -*----------------------------------------------------------------------------*/ | |
5921 | - | |
5922 | -int floatx80_lt(floatx80 a, floatx80 b, float_status *status) | |
5923 | -{ | |
5924 | - bool aSign, bSign; | |
5925 | - | |
5926 | - if (floatx80_invalid_encoding(a) || floatx80_invalid_encoding(b) | |
5927 | - || (extractFloatx80Exp(a) == 0x7FFF | |
5928 | - && (uint64_t) (extractFloatx80Frac(a) << 1)) | |
5929 | - || (extractFloatx80Exp(b) == 0x7FFF | |
5930 | - && (uint64_t) (extractFloatx80Frac(b) << 1)) | |
5931 | - ) { | |
5932 | - float_raise(float_flag_invalid, status); | |
5933 | - return 0; | |
5934 | - } | |
5935 | - aSign = extractFloatx80Sign( a ); | |
5936 | - bSign = extractFloatx80Sign( b ); | |
5937 | - if ( aSign != bSign ) { | |
5938 | - return | |
5939 | - aSign | |
5940 | - && ( ( ( (uint16_t) ( ( a.high | b.high )<<1 ) ) | a.low | b.low ) | |
5941 | - != 0 ); | |
5942 | - } | |
5943 | - return | |
5944 | - aSign ? lt128( b.high, b.low, a.high, a.low ) | |
5945 | - : lt128( a.high, a.low, b.high, b.low ); | |
5946 | - | |
5947 | -} | |
5948 | - | |
5949 | -/*---------------------------------------------------------------------------- | |
5950 | -| Returns 1 if the extended double-precision floating-point values `a' and `b' | |
5951 | -| cannot be compared, and 0 otherwise. The invalid exception is raised if | |
5952 | -| either operand is a NaN. The comparison is performed according to the | |
5953 | -| IEC/IEEE Standard for Binary Floating-Point Arithmetic. | |
5954 | -*----------------------------------------------------------------------------*/ | |
5955 | -int floatx80_unordered(floatx80 a, floatx80 b, float_status *status) | |
5956 | -{ | |
5957 | - if (floatx80_invalid_encoding(a) || floatx80_invalid_encoding(b) | |
5958 | - || (extractFloatx80Exp(a) == 0x7FFF | |
5959 | - && (uint64_t) (extractFloatx80Frac(a) << 1)) | |
5960 | - || (extractFloatx80Exp(b) == 0x7FFF | |
5961 | - && (uint64_t) (extractFloatx80Frac(b) << 1)) | |
5962 | - ) { | |
5963 | - float_raise(float_flag_invalid, status); | |
5964 | - return 1; | |
5965 | - } | |
5966 | - return 0; | |
5967 | -} | |
5968 | - | |
5969 | -/*---------------------------------------------------------------------------- | |
5970 | -| Returns 1 if the extended double-precision floating-point value `a' is | |
5971 | -| equal to the corresponding value `b', and 0 otherwise. Quiet NaNs do not | |
5972 | -| cause an exception. The comparison is performed according to the IEC/IEEE | |
5973 | -| Standard for Binary Floating-Point Arithmetic. | |
5974 | -*----------------------------------------------------------------------------*/ | |
5975 | - | |
5976 | -int floatx80_eq_quiet(floatx80 a, floatx80 b, float_status *status) | |
5977 | -{ | |
5978 | - | |
5979 | - if (floatx80_invalid_encoding(a) || floatx80_invalid_encoding(b)) { | |
5980 | - float_raise(float_flag_invalid, status); | |
5981 | - return 0; | |
5982 | - } | |
5983 | - if ( ( ( extractFloatx80Exp( a ) == 0x7FFF ) | |
5984 | - && (uint64_t) ( extractFloatx80Frac( a )<<1 ) ) | |
5985 | - || ( ( extractFloatx80Exp( b ) == 0x7FFF ) | |
5986 | - && (uint64_t) ( extractFloatx80Frac( b )<<1 ) ) | |
5987 | - ) { | |
5988 | - if (floatx80_is_signaling_nan(a, status) | |
5989 | - || floatx80_is_signaling_nan(b, status)) { | |
5990 | - float_raise(float_flag_invalid, status); | |
5991 | - } | |
5992 | - return 0; | |
5993 | - } | |
5994 | - return | |
5995 | - ( a.low == b.low ) | |
5996 | - && ( ( a.high == b.high ) | |
5997 | - || ( ( a.low == 0 ) | |
5998 | - && ( (uint16_t) ( ( a.high | b.high )<<1 ) == 0 ) ) | |
5999 | - ); | |
6000 | - | |
6001 | -} | |
6002 | - | |
6003 | -/*---------------------------------------------------------------------------- | |
6004 | -| Returns 1 if the extended double-precision floating-point value `a' is less | |
6005 | -| than or equal to the corresponding value `b', and 0 otherwise. Quiet NaNs | |
6006 | -| do not cause an exception. Otherwise, the comparison is performed according | |
6007 | -| to the IEC/IEEE Standard for Binary Floating-Point Arithmetic. | |
6008 | -*----------------------------------------------------------------------------*/ | |
6009 | - | |
6010 | -int floatx80_le_quiet(floatx80 a, floatx80 b, float_status *status) | |
6011 | -{ | |
6012 | - bool aSign, bSign; | |
6013 | - | |
6014 | - if (floatx80_invalid_encoding(a) || floatx80_invalid_encoding(b)) { | |
6015 | - float_raise(float_flag_invalid, status); | |
6016 | - return 0; | |
6017 | - } | |
6018 | - if ( ( ( extractFloatx80Exp( a ) == 0x7FFF ) | |
6019 | - && (uint64_t) ( extractFloatx80Frac( a )<<1 ) ) | |
6020 | - || ( ( extractFloatx80Exp( b ) == 0x7FFF ) | |
6021 | - && (uint64_t) ( extractFloatx80Frac( b )<<1 ) ) | |
6022 | - ) { | |
6023 | - if (floatx80_is_signaling_nan(a, status) | |
6024 | - || floatx80_is_signaling_nan(b, status)) { | |
6025 | - float_raise(float_flag_invalid, status); | |
6026 | - } | |
6027 | - return 0; | |
6028 | - } | |
6029 | - aSign = extractFloatx80Sign( a ); | |
6030 | - bSign = extractFloatx80Sign( b ); | |
6031 | - if ( aSign != bSign ) { | |
6032 | - return | |
6033 | - aSign | |
6034 | - || ( ( ( (uint16_t) ( ( a.high | b.high )<<1 ) ) | a.low | b.low ) | |
6035 | - == 0 ); | |
6036 | - } | |
6037 | - return | |
6038 | - aSign ? le128( b.high, b.low, a.high, a.low ) | |
6039 | - : le128( a.high, a.low, b.high, b.low ); | |
6040 | - | |
6041 | -} | |
6042 | - | |
6043 | -/*---------------------------------------------------------------------------- | |
6044 | -| Returns 1 if the extended double-precision floating-point value `a' is less | |
6045 | -| than the corresponding value `b', and 0 otherwise. Quiet NaNs do not cause | |
6046 | -| an exception. Otherwise, the comparison is performed according to the | |
6047 | -| IEC/IEEE Standard for Binary Floating-Point Arithmetic. | |
6048 | -*----------------------------------------------------------------------------*/ | |
6049 | - | |
6050 | -int floatx80_lt_quiet(floatx80 a, floatx80 b, float_status *status) | |
6051 | -{ | |
6052 | - bool aSign, bSign; | |
6053 | - | |
6054 | - if (floatx80_invalid_encoding(a) || floatx80_invalid_encoding(b)) { | |
6055 | - float_raise(float_flag_invalid, status); | |
6056 | - return 0; | |
6057 | - } | |
6058 | - if ( ( ( extractFloatx80Exp( a ) == 0x7FFF ) | |
6059 | - && (uint64_t) ( extractFloatx80Frac( a )<<1 ) ) | |
6060 | - || ( ( extractFloatx80Exp( b ) == 0x7FFF ) | |
6061 | - && (uint64_t) ( extractFloatx80Frac( b )<<1 ) ) | |
6062 | - ) { | |
6063 | - if (floatx80_is_signaling_nan(a, status) | |
6064 | - || floatx80_is_signaling_nan(b, status)) { | |
6065 | - float_raise(float_flag_invalid, status); | |
6066 | - } | |
6067 | - return 0; | |
6068 | - } | |
6069 | - aSign = extractFloatx80Sign( a ); | |
6070 | - bSign = extractFloatx80Sign( b ); | |
6071 | - if ( aSign != bSign ) { | |
6072 | - return | |
6073 | - aSign | |
6074 | - && ( ( ( (uint16_t) ( ( a.high | b.high )<<1 ) ) | a.low | b.low ) | |
6075 | - != 0 ); | |
6076 | - } | |
6077 | - return | |
6078 | - aSign ? lt128( b.high, b.low, a.high, a.low ) | |
6079 | - : lt128( a.high, a.low, b.high, b.low ); | |
6080 | - | |
6081 | -} | |
6082 | - | |
6083 | -/*---------------------------------------------------------------------------- | |
6084 | -| Returns 1 if the extended double-precision floating-point values `a' and `b' | |
6085 | -| cannot be compared, and 0 otherwise. Quiet NaNs do not cause an exception. | |
6086 | -| The comparison is performed according to the IEC/IEEE Standard for Binary | |
6087 | -| Floating-Point Arithmetic. | |
6088 | -*----------------------------------------------------------------------------*/ | |
6089 | -int floatx80_unordered_quiet(floatx80 a, floatx80 b, float_status *status) | |
6090 | -{ | |
6091 | - if (floatx80_invalid_encoding(a) || floatx80_invalid_encoding(b)) { | |
6092 | - float_raise(float_flag_invalid, status); | |
6093 | - return 1; | |
6094 | - } | |
6095 | - if ( ( ( extractFloatx80Exp( a ) == 0x7FFF ) | |
6096 | - && (uint64_t) ( extractFloatx80Frac( a )<<1 ) ) | |
6097 | - || ( ( extractFloatx80Exp( b ) == 0x7FFF ) | |
6098 | - && (uint64_t) ( extractFloatx80Frac( b )<<1 ) ) | |
6099 | - ) { | |
6100 | - if (floatx80_is_signaling_nan(a, status) | |
6101 | - || floatx80_is_signaling_nan(b, status)) { | |
6102 | - float_raise(float_flag_invalid, status); | |
6103 | - } | |
6104 | - return 1; | |
6105 | - } | |
6106 | - return 0; | |
6107 | -} | |
6108 | - | |
6109 | -/*---------------------------------------------------------------------------- | |
6110 | 5853 | | Returns the result of converting the quadruple-precision floating-point |
6111 | 5854 | | value `a' to the 32-bit two's complement integer format. The conversion |
6112 | 5855 | | is performed according to the IEC/IEEE Standard for Binary Floating-Point |
@@ -689,14 +689,6 @@ floatx80 floatx80_mul(floatx80, floatx80, float_status *status); | ||
689 | 689 | floatx80 floatx80_div(floatx80, floatx80, float_status *status); |
690 | 690 | floatx80 floatx80_rem(floatx80, floatx80, float_status *status); |
691 | 691 | floatx80 floatx80_sqrt(floatx80, float_status *status); |
692 | -int floatx80_eq(floatx80, floatx80, float_status *status); | |
693 | -int floatx80_le(floatx80, floatx80, float_status *status); | |
694 | -int floatx80_lt(floatx80, floatx80, float_status *status); | |
695 | -int floatx80_unordered(floatx80, floatx80, float_status *status); | |
696 | -int floatx80_eq_quiet(floatx80, floatx80, float_status *status); | |
697 | -int floatx80_le_quiet(floatx80, floatx80, float_status *status); | |
698 | -int floatx80_lt_quiet(floatx80, floatx80, float_status *status); | |
699 | -int floatx80_unordered_quiet(floatx80, floatx80, float_status *status); | |
700 | 692 | FloatRelation floatx80_compare(floatx80, floatx80, float_status *status); |
701 | 693 | FloatRelation floatx80_compare_quiet(floatx80, floatx80, float_status *status); |
702 | 694 | int floatx80_is_quiet_nan(floatx80, float_status *status); |
@@ -746,6 +738,47 @@ static inline int floatx80_is_any_nan(floatx80 a) | ||
746 | 738 | return ((a.high & 0x7fff) == 0x7fff) && (a.low<<1); |
747 | 739 | } |
748 | 740 | |
741 | +static inline bool floatx80_eq(floatx80 a, floatx80 b, float_status *s) | |
742 | +{ | |
743 | + return floatx80_compare(a, b, s) == float_relation_equal; | |
744 | +} | |
745 | + | |
746 | +static inline bool floatx80_le(floatx80 a, floatx80 b, float_status *s) | |
747 | +{ | |
748 | + return floatx80_compare(a, b, s) <= float_relation_equal; | |
749 | +} | |
750 | + | |
751 | +static inline bool floatx80_lt(floatx80 a, floatx80 b, float_status *s) | |
752 | +{ | |
753 | + return floatx80_compare(a, b, s) < float_relation_equal; | |
754 | +} | |
755 | + | |
756 | +static inline bool floatx80_unordered(floatx80 a, floatx80 b, float_status *s) | |
757 | +{ | |
758 | + return floatx80_compare(a, b, s) == float_relation_unordered; | |
759 | +} | |
760 | + | |
761 | +static inline bool floatx80_eq_quiet(floatx80 a, floatx80 b, float_status *s) | |
762 | +{ | |
763 | + return floatx80_compare_quiet(a, b, s) == float_relation_equal; | |
764 | +} | |
765 | + | |
766 | +static inline bool floatx80_le_quiet(floatx80 a, floatx80 b, float_status *s) | |
767 | +{ | |
768 | + return floatx80_compare_quiet(a, b, s) <= float_relation_equal; | |
769 | +} | |
770 | + | |
771 | +static inline bool floatx80_lt_quiet(floatx80 a, floatx80 b, float_status *s) | |
772 | +{ | |
773 | + return floatx80_compare_quiet(a, b, s) < float_relation_equal; | |
774 | +} | |
775 | + | |
776 | +static inline bool floatx80_unordered_quiet(floatx80 a, floatx80 b, | |
777 | + float_status *s) | |
778 | +{ | |
779 | + return floatx80_compare_quiet(a, b, s) == float_relation_unordered; | |
780 | +} | |
781 | + | |
749 | 782 | /*---------------------------------------------------------------------------- |
750 | 783 | | Return whether the given value is an invalid floatx80 encoding. |
751 | 784 | | Invalid floatx80 encodings arise when the integer bit is not set, but |