softfloat: Define comparison operations for bfloat16
PATCH 1/1 softfloat: Define comparison operations for bfloat16
These operations were missed in Zhiwei's bfloat16 implementation.
--- include/fpu/softfloat.h | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+)
include/fpu/softfloat.h +41 -0
@@ -479,6 +479,47 @@ static inline bfloat16 bfloat16_set_sign(bfloat16 a, int sign)return (a &0x7fff ) | (sign <<15 ); } +static inline bool bfloat16_eq (bfloat16 a,bfloat16 b,float_status *s) +{ +return bfloat16_compare (a, b, s) == float_relation_equal; +} + +static inline bool bfloat16_le (bfloat16 a,bfloat16 b,float_status *s) +{ +return bfloat16_compare (a, b, s) <= float_relation_equal; +} + +static inline bool bfloat16_lt (bfloat16 a,bfloat16 b,float_status *s) +{ +return bfloat16_compare (a, b, s) < float_relation_equal; +} + +static inline bool bfloat16_unordered (bfloat16 a,bfloat16 b,float_status *s) +{ +return bfloat16_compare (a, b, s) == float_relation_unordered; +} + +static inline bool bfloat16_eq_quiet (bfloat16 a,bfloat16 b,float_status *s) +{ +return bfloat16_compare_quiet (a, b, s) == float_relation_equal; +} + +static inline bool bfloat16_le_quiet (bfloat16 a,bfloat16 b,float_status *s) +{ +return bfloat16_compare_quiet (a, b, s) <= float_relation_equal; +} + +static inline bool bfloat16_lt_quiet (bfloat16 a,bfloat16 b,float_status *s) +{ +return bfloat16_compare_quiet (a, b, s) < float_relation_equal; +} + +static inline bool bfloat16_unordered_quiet (bfloat16 a,bfloat16 b, +float_status *s) +{ +return bfloat16_compare_quiet (a, b, s) == float_relation_unordered; +} +#define bfloat16_zero 0#define bfloat16_half 0x3f00#define bfloat16_one 0x3f80
Signature · 1 line
2.25.1
Quoted 42 lines · Richard Henderson
These operations were missed in Zhiwei's bfloat16 implementation.
Signed-off-by Richard Henderson <[email protected]>--- include/fpu/softfloat.h | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+)include/fpu/softfloat.h +27
-0@@ -479,6 +479,47 @@ static inline bfloat16 bfloat16_set_sign(bfloat16 a, int sign)return (a &0x7fff ) | (sign <<15 ); } +static inline bool bfloat16_eq (bfloat16 a,bfloat16 b,float_status *s) +{ +return bfloat16_compare (a, b, s) == float_relation_equal; +} + +static inline bool bfloat16_le (bfloat16 a,bfloat16 b,float_status *s) +{ +return bfloat16_compare (a, b, s) <= float_relation_equal; +} + +static inline bool bfloat16_lt (bfloat16 a,bfloat16 b,float_status *s) +{ +return bfloat16_compare (a, b, s) < float_relation_equal; +} + +static inline bool bfloat16_unordered (bfloat16 a,bfloat16 b,float_status *s) +{ +return bfloat16_compare (a, b, s) == float_relation_unordered; +} + +static inline bool bfloat16_eq_quiet (bfloat16 a,bfloat16 b,float_status *s) +{ +return bfloat16_compare_quiet (a, b, s) == float_relation_equal; +} + +static inline bool bfloat16_le_quiet (bfloat16 a,bfloat16 b,float_status *s) +{
include/fpu/softfloat.h static inline bfloat16 bfloat16_set_sign(bfloat16 a, int sign) · line 518
Quoted 10 lines
include/fpu/softfloat.h +10
-0+return bfloat16_compare_quiet (a, b, s) <= float_relation_equal; +} + +static inline bool bfloat16_lt_quiet (bfloat16 a,bfloat16 b,float_status *s) +{ +return bfloat16_compare_quiet (a, b, s) < float_relation_equal; +} + +static inline bool bfloat16_unordered_quiet (bfloat16 a,bfloat16 b, +float_status *s)
Indentation.
include/fpu/softfloat.h static inline bfloat16 bfloat16_set_sign(bfloat16 a, int sign) · line 522
Quoted 4 lines
include/fpu/softfloat.h +4
-0+{ +return bfloat16_compare_quiet (a, b, s) == float_relation_unordered; +} +
Hi Richard,
If you have already applied the bfloat16 patch set, I am afraid you have to remove these lines.
-int bfloat16_unordered_quiet(bfloat16, bfloat16, float_status *status); -int bfloat16_le(bfloat16, bfloat16, float_status *status); -int bfloat16_lt(bfloat16, bfloat16, float_status *status); -int bfloat16_eq_quiet(bfloat16, bfloat16, float_status *status);
The corresponding float16 interfaces have been removed in the master branch when I sent the bfloat16 patch set. So I deleted the implementations. But I forgot to remove the declarations.
I see you have applied float16 comparison interfaces from Kito, and the corresponding bfloat16 interfaces have all been defined here. After remove the redundant declarations,
Quoted 3 lines
include/fpu/softfloat.h +0
-0#define bfloat16_zero 0#define bfloat16_half 0x3f00#define bfloat16_one 0x3f80