• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revisiónb7b1ac684fea49c6bfe1ad8b706aed7b09116d15 (tree)
Tiempo2020-05-20 00:42:49
AutorRichard Henderson <richard.henderson@lina...>
CommiterRichard Henderson

Log Message

softfloat: Inline float128 compare specializations

Replace the float128 compare specializations with inline functions
that call the standard float128_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>

Cambiar Resumen

Diferencia incremental

--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -7218,244 +7218,6 @@ float128 float128_sqrt(float128 a, float_status *status)
72187218
72197219 }
72207220
7221-/*----------------------------------------------------------------------------
7222-| Returns 1 if the quadruple-precision floating-point value `a' is equal to
7223-| the corresponding value `b', and 0 otherwise. The invalid exception is
7224-| raised if either operand is a NaN. Otherwise, the comparison is performed
7225-| according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
7226-*----------------------------------------------------------------------------*/
7227-
7228-int float128_eq(float128 a, float128 b, float_status *status)
7229-{
7230-
7231- if ( ( ( extractFloat128Exp( a ) == 0x7FFF )
7232- && ( extractFloat128Frac0( a ) | extractFloat128Frac1( a ) ) )
7233- || ( ( extractFloat128Exp( b ) == 0x7FFF )
7234- && ( extractFloat128Frac0( b ) | extractFloat128Frac1( b ) ) )
7235- ) {
7236- float_raise(float_flag_invalid, status);
7237- return 0;
7238- }
7239- return
7240- ( a.low == b.low )
7241- && ( ( a.high == b.high )
7242- || ( ( a.low == 0 )
7243- && ( (uint64_t) ( ( a.high | b.high )<<1 ) == 0 ) )
7244- );
7245-
7246-}
7247-
7248-/*----------------------------------------------------------------------------
7249-| Returns 1 if the quadruple-precision floating-point value `a' is less than
7250-| or equal to the corresponding value `b', and 0 otherwise. The invalid
7251-| exception is raised if either operand is a NaN. The comparison is performed
7252-| according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
7253-*----------------------------------------------------------------------------*/
7254-
7255-int float128_le(float128 a, float128 b, float_status *status)
7256-{
7257- bool aSign, bSign;
7258-
7259- if ( ( ( extractFloat128Exp( a ) == 0x7FFF )
7260- && ( extractFloat128Frac0( a ) | extractFloat128Frac1( a ) ) )
7261- || ( ( extractFloat128Exp( b ) == 0x7FFF )
7262- && ( extractFloat128Frac0( b ) | extractFloat128Frac1( b ) ) )
7263- ) {
7264- float_raise(float_flag_invalid, status);
7265- return 0;
7266- }
7267- aSign = extractFloat128Sign( a );
7268- bSign = extractFloat128Sign( b );
7269- if ( aSign != bSign ) {
7270- return
7271- aSign
7272- || ( ( ( (uint64_t) ( ( a.high | b.high )<<1 ) ) | a.low | b.low )
7273- == 0 );
7274- }
7275- return
7276- aSign ? le128( b.high, b.low, a.high, a.low )
7277- : le128( a.high, a.low, b.high, b.low );
7278-
7279-}
7280-
7281-/*----------------------------------------------------------------------------
7282-| Returns 1 if the quadruple-precision floating-point value `a' is less than
7283-| the corresponding value `b', and 0 otherwise. The invalid exception is
7284-| raised if either operand is a NaN. The comparison is performed according
7285-| to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
7286-*----------------------------------------------------------------------------*/
7287-
7288-int float128_lt(float128 a, float128 b, float_status *status)
7289-{
7290- bool aSign, bSign;
7291-
7292- if ( ( ( extractFloat128Exp( a ) == 0x7FFF )
7293- && ( extractFloat128Frac0( a ) | extractFloat128Frac1( a ) ) )
7294- || ( ( extractFloat128Exp( b ) == 0x7FFF )
7295- && ( extractFloat128Frac0( b ) | extractFloat128Frac1( b ) ) )
7296- ) {
7297- float_raise(float_flag_invalid, status);
7298- return 0;
7299- }
7300- aSign = extractFloat128Sign( a );
7301- bSign = extractFloat128Sign( b );
7302- if ( aSign != bSign ) {
7303- return
7304- aSign
7305- && ( ( ( (uint64_t) ( ( a.high | b.high )<<1 ) ) | a.low | b.low )
7306- != 0 );
7307- }
7308- return
7309- aSign ? lt128( b.high, b.low, a.high, a.low )
7310- : lt128( a.high, a.low, b.high, b.low );
7311-
7312-}
7313-
7314-/*----------------------------------------------------------------------------
7315-| Returns 1 if the quadruple-precision floating-point values `a' and `b' cannot
7316-| be compared, and 0 otherwise. The invalid exception is raised if either
7317-| operand is a NaN. The comparison is performed according to the IEC/IEEE
7318-| Standard for Binary Floating-Point Arithmetic.
7319-*----------------------------------------------------------------------------*/
7320-
7321-int float128_unordered(float128 a, float128 b, float_status *status)
7322-{
7323- if ( ( ( extractFloat128Exp( a ) == 0x7FFF )
7324- && ( extractFloat128Frac0( a ) | extractFloat128Frac1( a ) ) )
7325- || ( ( extractFloat128Exp( b ) == 0x7FFF )
7326- && ( extractFloat128Frac0( b ) | extractFloat128Frac1( b ) ) )
7327- ) {
7328- float_raise(float_flag_invalid, status);
7329- return 1;
7330- }
7331- return 0;
7332-}
7333-
7334-/*----------------------------------------------------------------------------
7335-| Returns 1 if the quadruple-precision floating-point value `a' is equal to
7336-| the corresponding value `b', and 0 otherwise. Quiet NaNs do not cause an
7337-| exception. The comparison is performed according to the IEC/IEEE Standard
7338-| for Binary Floating-Point Arithmetic.
7339-*----------------------------------------------------------------------------*/
7340-
7341-int float128_eq_quiet(float128 a, float128 b, float_status *status)
7342-{
7343-
7344- if ( ( ( extractFloat128Exp( a ) == 0x7FFF )
7345- && ( extractFloat128Frac0( a ) | extractFloat128Frac1( a ) ) )
7346- || ( ( extractFloat128Exp( b ) == 0x7FFF )
7347- && ( extractFloat128Frac0( b ) | extractFloat128Frac1( b ) ) )
7348- ) {
7349- if (float128_is_signaling_nan(a, status)
7350- || float128_is_signaling_nan(b, status)) {
7351- float_raise(float_flag_invalid, status);
7352- }
7353- return 0;
7354- }
7355- return
7356- ( a.low == b.low )
7357- && ( ( a.high == b.high )
7358- || ( ( a.low == 0 )
7359- && ( (uint64_t) ( ( a.high | b.high )<<1 ) == 0 ) )
7360- );
7361-
7362-}
7363-
7364-/*----------------------------------------------------------------------------
7365-| Returns 1 if the quadruple-precision floating-point value `a' is less than
7366-| or equal to the corresponding value `b', and 0 otherwise. Quiet NaNs do not
7367-| cause an exception. Otherwise, the comparison is performed according to the
7368-| IEC/IEEE Standard for Binary Floating-Point Arithmetic.
7369-*----------------------------------------------------------------------------*/
7370-
7371-int float128_le_quiet(float128 a, float128 b, float_status *status)
7372-{
7373- bool aSign, bSign;
7374-
7375- if ( ( ( extractFloat128Exp( a ) == 0x7FFF )
7376- && ( extractFloat128Frac0( a ) | extractFloat128Frac1( a ) ) )
7377- || ( ( extractFloat128Exp( b ) == 0x7FFF )
7378- && ( extractFloat128Frac0( b ) | extractFloat128Frac1( b ) ) )
7379- ) {
7380- if (float128_is_signaling_nan(a, status)
7381- || float128_is_signaling_nan(b, status)) {
7382- float_raise(float_flag_invalid, status);
7383- }
7384- return 0;
7385- }
7386- aSign = extractFloat128Sign( a );
7387- bSign = extractFloat128Sign( b );
7388- if ( aSign != bSign ) {
7389- return
7390- aSign
7391- || ( ( ( (uint64_t) ( ( a.high | b.high )<<1 ) ) | a.low | b.low )
7392- == 0 );
7393- }
7394- return
7395- aSign ? le128( b.high, b.low, a.high, a.low )
7396- : le128( a.high, a.low, b.high, b.low );
7397-
7398-}
7399-
7400-/*----------------------------------------------------------------------------
7401-| Returns 1 if the quadruple-precision floating-point value `a' is less than
7402-| the corresponding value `b', and 0 otherwise. Quiet NaNs do not cause an
7403-| exception. Otherwise, the comparison is performed according to the IEC/IEEE
7404-| Standard for Binary Floating-Point Arithmetic.
7405-*----------------------------------------------------------------------------*/
7406-
7407-int float128_lt_quiet(float128 a, float128 b, float_status *status)
7408-{
7409- bool aSign, bSign;
7410-
7411- if ( ( ( extractFloat128Exp( a ) == 0x7FFF )
7412- && ( extractFloat128Frac0( a ) | extractFloat128Frac1( a ) ) )
7413- || ( ( extractFloat128Exp( b ) == 0x7FFF )
7414- && ( extractFloat128Frac0( b ) | extractFloat128Frac1( b ) ) )
7415- ) {
7416- if (float128_is_signaling_nan(a, status)
7417- || float128_is_signaling_nan(b, status)) {
7418- float_raise(float_flag_invalid, status);
7419- }
7420- return 0;
7421- }
7422- aSign = extractFloat128Sign( a );
7423- bSign = extractFloat128Sign( b );
7424- if ( aSign != bSign ) {
7425- return
7426- aSign
7427- && ( ( ( (uint64_t) ( ( a.high | b.high )<<1 ) ) | a.low | b.low )
7428- != 0 );
7429- }
7430- return
7431- aSign ? lt128( b.high, b.low, a.high, a.low )
7432- : lt128( a.high, a.low, b.high, b.low );
7433-
7434-}
7435-
7436-/*----------------------------------------------------------------------------
7437-| Returns 1 if the quadruple-precision floating-point values `a' and `b' cannot
7438-| be compared, and 0 otherwise. Quiet NaNs do not cause an exception. The
7439-| comparison is performed according to the IEC/IEEE Standard for Binary
7440-| Floating-Point Arithmetic.
7441-*----------------------------------------------------------------------------*/
7442-
7443-int float128_unordered_quiet(float128 a, float128 b, float_status *status)
7444-{
7445- if ( ( ( extractFloat128Exp( a ) == 0x7FFF )
7446- && ( extractFloat128Frac0( a ) | extractFloat128Frac1( a ) ) )
7447- || ( ( extractFloat128Exp( b ) == 0x7FFF )
7448- && ( extractFloat128Frac0( b ) | extractFloat128Frac1( b ) ) )
7449- ) {
7450- if (float128_is_signaling_nan(a, status)
7451- || float128_is_signaling_nan(b, status)) {
7452- float_raise(float_flag_invalid, status);
7453- }
7454- return 1;
7455- }
7456- return 0;
7457-}
7458-
74597221 static inline FloatRelation
74607222 floatx80_compare_internal(floatx80 a, floatx80 b, bool is_quiet,
74617223 float_status *status)
--- a/include/fpu/softfloat.h
+++ b/include/fpu/softfloat.h
@@ -901,14 +901,6 @@ float128 float128_mul(float128, float128, float_status *status);
901901 float128 float128_div(float128, float128, float_status *status);
902902 float128 float128_rem(float128, float128, float_status *status);
903903 float128 float128_sqrt(float128, float_status *status);
904-int float128_eq(float128, float128, float_status *status);
905-int float128_le(float128, float128, float_status *status);
906-int float128_lt(float128, float128, float_status *status);
907-int float128_unordered(float128, float128, float_status *status);
908-int float128_eq_quiet(float128, float128, float_status *status);
909-int float128_le_quiet(float128, float128, float_status *status);
910-int float128_lt_quiet(float128, float128, float_status *status);
911-int float128_unordered_quiet(float128, float128, float_status *status);
912904 FloatRelation float128_compare(float128, float128, float_status *status);
913905 FloatRelation float128_compare_quiet(float128, float128, float_status *status);
914906 int float128_is_quiet_nan(float128, float_status *status);
@@ -964,6 +956,47 @@ static inline int float128_is_any_nan(float128 a)
964956 ((a.low != 0) || ((a.high & 0xffffffffffffLL) != 0));
965957 }
966958
959+static inline bool float128_eq(float128 a, float128 b, float_status *s)
960+{
961+ return float128_compare(a, b, s) == float_relation_equal;
962+}
963+
964+static inline bool float128_le(float128 a, float128 b, float_status *s)
965+{
966+ return float128_compare(a, b, s) <= float_relation_equal;
967+}
968+
969+static inline bool float128_lt(float128 a, float128 b, float_status *s)
970+{
971+ return float128_compare(a, b, s) < float_relation_equal;
972+}
973+
974+static inline bool float128_unordered(float128 a, float128 b, float_status *s)
975+{
976+ return float128_compare(a, b, s) == float_relation_unordered;
977+}
978+
979+static inline bool float128_eq_quiet(float128 a, float128 b, float_status *s)
980+{
981+ return float128_compare_quiet(a, b, s) == float_relation_equal;
982+}
983+
984+static inline bool float128_le_quiet(float128 a, float128 b, float_status *s)
985+{
986+ return float128_compare_quiet(a, b, s) <= float_relation_equal;
987+}
988+
989+static inline bool float128_lt_quiet(float128 a, float128 b, float_status *s)
990+{
991+ return float128_compare_quiet(a, b, s) < float_relation_equal;
992+}
993+
994+static inline bool float128_unordered_quiet(float128 a, float128 b,
995+ float_status *s)
996+{
997+ return float128_compare_quiet(a, b, s) == float_relation_unordered;
998+}
999+
9671000 #define float128_zero make_float128(0, 0)
9681001
9691002 /*----------------------------------------------------------------------------