mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2024-12-22 14:15:32 +00:00
softfloat: Define misc operations for bfloat16
Backports 5ebf5f4be66c378fd5f3dee85f54dd4942171d57
This commit is contained in:
parent
d8168a8142
commit
d26cd63ad6
|
@ -213,6 +213,8 @@
|
|||
#define bfloat16_sqrt bfloat16_sqrt_aarch64
|
||||
#define bfloat16_compare bfloat16_compare_aarch64
|
||||
#define bfloat16_compare_quiet bfloat16_compare_quiet_aarch64
|
||||
#define bfloat16_is_quiet_nan bfloat16_is_quiet_nan_aarch64
|
||||
#define bfloat16_is_signaling_nan bfloat16_is_signaling_nan_aarch64
|
||||
#define bfloat16_silence_nan bfloat16_silence_nan_aarch64
|
||||
#define bfloat16_default_nan bfloat16_default_nan_aarch64
|
||||
#define bfloat16_to_float32 bfloat16_to_float32_aarch64
|
||||
|
|
|
@ -213,6 +213,8 @@
|
|||
#define bfloat16_sqrt bfloat16_sqrt_aarch64eb
|
||||
#define bfloat16_compare bfloat16_compare_aarch64eb
|
||||
#define bfloat16_compare_quiet bfloat16_compare_quiet_aarch64eb
|
||||
#define bfloat16_is_quiet_nan bfloat16_is_quiet_nan_aarch64eb
|
||||
#define bfloat16_is_signaling_nan bfloat16_is_signaling_nan_aarch64eb
|
||||
#define bfloat16_silence_nan bfloat16_silence_nan_aarch64eb
|
||||
#define bfloat16_default_nan bfloat16_default_nan_aarch64eb
|
||||
#define bfloat16_to_float32 bfloat16_to_float32_aarch64eb
|
||||
|
|
|
@ -213,6 +213,8 @@
|
|||
#define bfloat16_sqrt bfloat16_sqrt_arm
|
||||
#define bfloat16_compare bfloat16_compare_arm
|
||||
#define bfloat16_compare_quiet bfloat16_compare_quiet_arm
|
||||
#define bfloat16_is_quiet_nan bfloat16_is_quiet_nan_arm
|
||||
#define bfloat16_is_signaling_nan bfloat16_is_signaling_nan_arm
|
||||
#define bfloat16_silence_nan bfloat16_silence_nan_arm
|
||||
#define bfloat16_default_nan bfloat16_default_nan_arm
|
||||
#define bfloat16_to_float32 bfloat16_to_float32_arm
|
||||
|
|
|
@ -213,6 +213,8 @@
|
|||
#define bfloat16_sqrt bfloat16_sqrt_armeb
|
||||
#define bfloat16_compare bfloat16_compare_armeb
|
||||
#define bfloat16_compare_quiet bfloat16_compare_quiet_armeb
|
||||
#define bfloat16_is_quiet_nan bfloat16_is_quiet_nan_armeb
|
||||
#define bfloat16_is_signaling_nan bfloat16_is_signaling_nan_armeb
|
||||
#define bfloat16_silence_nan bfloat16_silence_nan_armeb
|
||||
#define bfloat16_default_nan bfloat16_default_nan_armeb
|
||||
#define bfloat16_to_float32 bfloat16_to_float32_armeb
|
||||
|
|
|
@ -265,6 +265,25 @@ bool float16_is_quiet_nan(float16 a_, float_status *status)
|
|||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Returns 1 if the bfloat16 value `a' is a quiet
|
||||
| NaN; otherwise returns 0.
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
bool bfloat16_is_quiet_nan(bfloat16 a_, float_status *status)
|
||||
{
|
||||
if (no_signaling_nans(status)) {
|
||||
return bfloat16_is_any_nan(a_);
|
||||
} else {
|
||||
uint16_t a = a_;
|
||||
if (snan_bit_is_one(status)) {
|
||||
return (((a >> 6) & 0x1FF) == 0x1FE) && (a & 0x3F);
|
||||
} else {
|
||||
return ((a >> 6) & 0x1FF) == 0x1FF;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Returns 1 if the half-precision floating-point value `a' is a signaling
|
||||
| NaN; otherwise returns 0.
|
||||
|
@ -284,6 +303,25 @@ bool float16_is_signaling_nan(float16 a_, float_status *status)
|
|||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Returns 1 if the bfloat16 value `a' is a signaling
|
||||
| NaN; otherwise returns 0.
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
bool bfloat16_is_signaling_nan(bfloat16 a_, float_status *status)
|
||||
{
|
||||
if (no_signaling_nans(status)) {
|
||||
return 0;
|
||||
} else {
|
||||
uint16_t a = a_;
|
||||
if (snan_bit_is_one(status)) {
|
||||
return ((a >> 6) & 0x1FF) == 0x1FF;
|
||||
} else {
|
||||
return (((a >> 6) & 0x1FF) == 0x1FE) && (a & 0x3F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Returns 1 if the single-precision floating-point value `a' is a quiet
|
||||
| NaN; otherwise returns 0.
|
||||
|
|
|
@ -219,6 +219,8 @@ symbols = (
|
|||
'bfloat16_sqrt',
|
||||
'bfloat16_compare',
|
||||
'bfloat16_compare_quiet',
|
||||
'bfloat16_is_quiet_nan',
|
||||
'bfloat16_is_signaling_nan',
|
||||
'bfloat16_silence_nan',
|
||||
'bfloat16_default_nan',
|
||||
'bfloat16_to_float32',
|
||||
|
|
|
@ -426,9 +426,57 @@ bfloat16 bfloat16_sqrt(bfloat16, float_status *status);
|
|||
FloatRelation bfloat16_compare(bfloat16, bfloat16, float_status *status);
|
||||
FloatRelation bfloat16_compare_quiet(bfloat16, bfloat16, float_status *status);
|
||||
|
||||
bool bfloat16_is_quiet_nan(bfloat16, float_status *status);
|
||||
bool bfloat16_is_signaling_nan(bfloat16, float_status *status);
|
||||
bfloat16 bfloat16_silence_nan(bfloat16, float_status *status);
|
||||
bfloat16 bfloat16_default_nan(float_status *status);
|
||||
|
||||
static inline bool bfloat16_is_any_nan(bfloat16 a)
|
||||
{
|
||||
return ((a & ~0x8000) > 0x7F80);
|
||||
}
|
||||
|
||||
static inline bool bfloat16_is_neg(bfloat16 a)
|
||||
{
|
||||
return a >> 15;
|
||||
}
|
||||
|
||||
static inline bool bfloat16_is_infinity(bfloat16 a)
|
||||
{
|
||||
return (a & 0x7fff) == 0x7F80;
|
||||
}
|
||||
|
||||
static inline bool bfloat16_is_zero(bfloat16 a)
|
||||
{
|
||||
return (a & 0x7fff) == 0;
|
||||
}
|
||||
|
||||
static inline bool bfloat16_is_zero_or_denormal(bfloat16 a)
|
||||
{
|
||||
return (a & 0x7F80) == 0;
|
||||
}
|
||||
|
||||
static inline bool bfloat16_is_normal(bfloat16 a)
|
||||
{
|
||||
return (((a >> 7) + 1) & 0xff) >= 2;
|
||||
}
|
||||
|
||||
static inline bfloat16 bfloat16_abs(bfloat16 a)
|
||||
{
|
||||
/* Note that abs does *not* handle NaN specially, nor does
|
||||
* it flush denormal inputs to zero.
|
||||
*/
|
||||
return a & 0x7fff;
|
||||
}
|
||||
|
||||
static inline bfloat16 bfloat16_chs(bfloat16 a)
|
||||
{
|
||||
/* Note that chs does *not* handle NaN specially, nor does
|
||||
* it flush denormal inputs to zero.
|
||||
*/
|
||||
return a ^ 0x8000;
|
||||
}
|
||||
|
||||
static inline bfloat16 bfloat16_set_sign(bfloat16 a, int sign)
|
||||
{
|
||||
return (a & 0x7fff) | (sign << 15);
|
||||
|
|
|
@ -213,6 +213,8 @@
|
|||
#define bfloat16_sqrt bfloat16_sqrt_m68k
|
||||
#define bfloat16_compare bfloat16_compare_m68k
|
||||
#define bfloat16_compare_quiet bfloat16_compare_quiet_m68k
|
||||
#define bfloat16_is_quiet_nan bfloat16_is_quiet_nan_m68k
|
||||
#define bfloat16_is_signaling_nan bfloat16_is_signaling_nan_m68k
|
||||
#define bfloat16_silence_nan bfloat16_silence_nan_m68k
|
||||
#define bfloat16_default_nan bfloat16_default_nan_m68k
|
||||
#define bfloat16_to_float32 bfloat16_to_float32_m68k
|
||||
|
|
|
@ -213,6 +213,8 @@
|
|||
#define bfloat16_sqrt bfloat16_sqrt_mips
|
||||
#define bfloat16_compare bfloat16_compare_mips
|
||||
#define bfloat16_compare_quiet bfloat16_compare_quiet_mips
|
||||
#define bfloat16_is_quiet_nan bfloat16_is_quiet_nan_mips
|
||||
#define bfloat16_is_signaling_nan bfloat16_is_signaling_nan_mips
|
||||
#define bfloat16_silence_nan bfloat16_silence_nan_mips
|
||||
#define bfloat16_default_nan bfloat16_default_nan_mips
|
||||
#define bfloat16_to_float32 bfloat16_to_float32_mips
|
||||
|
|
|
@ -213,6 +213,8 @@
|
|||
#define bfloat16_sqrt bfloat16_sqrt_mips64
|
||||
#define bfloat16_compare bfloat16_compare_mips64
|
||||
#define bfloat16_compare_quiet bfloat16_compare_quiet_mips64
|
||||
#define bfloat16_is_quiet_nan bfloat16_is_quiet_nan_mips64
|
||||
#define bfloat16_is_signaling_nan bfloat16_is_signaling_nan_mips64
|
||||
#define bfloat16_silence_nan bfloat16_silence_nan_mips64
|
||||
#define bfloat16_default_nan bfloat16_default_nan_mips64
|
||||
#define bfloat16_to_float32 bfloat16_to_float32_mips64
|
||||
|
|
|
@ -213,6 +213,8 @@
|
|||
#define bfloat16_sqrt bfloat16_sqrt_mips64el
|
||||
#define bfloat16_compare bfloat16_compare_mips64el
|
||||
#define bfloat16_compare_quiet bfloat16_compare_quiet_mips64el
|
||||
#define bfloat16_is_quiet_nan bfloat16_is_quiet_nan_mips64el
|
||||
#define bfloat16_is_signaling_nan bfloat16_is_signaling_nan_mips64el
|
||||
#define bfloat16_silence_nan bfloat16_silence_nan_mips64el
|
||||
#define bfloat16_default_nan bfloat16_default_nan_mips64el
|
||||
#define bfloat16_to_float32 bfloat16_to_float32_mips64el
|
||||
|
|
|
@ -213,6 +213,8 @@
|
|||
#define bfloat16_sqrt bfloat16_sqrt_mipsel
|
||||
#define bfloat16_compare bfloat16_compare_mipsel
|
||||
#define bfloat16_compare_quiet bfloat16_compare_quiet_mipsel
|
||||
#define bfloat16_is_quiet_nan bfloat16_is_quiet_nan_mipsel
|
||||
#define bfloat16_is_signaling_nan bfloat16_is_signaling_nan_mipsel
|
||||
#define bfloat16_silence_nan bfloat16_silence_nan_mipsel
|
||||
#define bfloat16_default_nan bfloat16_default_nan_mipsel
|
||||
#define bfloat16_to_float32 bfloat16_to_float32_mipsel
|
||||
|
|
|
@ -213,6 +213,8 @@
|
|||
#define bfloat16_sqrt bfloat16_sqrt_powerpc
|
||||
#define bfloat16_compare bfloat16_compare_powerpc
|
||||
#define bfloat16_compare_quiet bfloat16_compare_quiet_powerpc
|
||||
#define bfloat16_is_quiet_nan bfloat16_is_quiet_nan_powerpc
|
||||
#define bfloat16_is_signaling_nan bfloat16_is_signaling_nan_powerpc
|
||||
#define bfloat16_silence_nan bfloat16_silence_nan_powerpc
|
||||
#define bfloat16_default_nan bfloat16_default_nan_powerpc
|
||||
#define bfloat16_to_float32 bfloat16_to_float32_powerpc
|
||||
|
|
|
@ -213,6 +213,8 @@
|
|||
#define bfloat16_sqrt bfloat16_sqrt_riscv32
|
||||
#define bfloat16_compare bfloat16_compare_riscv32
|
||||
#define bfloat16_compare_quiet bfloat16_compare_quiet_riscv32
|
||||
#define bfloat16_is_quiet_nan bfloat16_is_quiet_nan_riscv32
|
||||
#define bfloat16_is_signaling_nan bfloat16_is_signaling_nan_riscv32
|
||||
#define bfloat16_silence_nan bfloat16_silence_nan_riscv32
|
||||
#define bfloat16_default_nan bfloat16_default_nan_riscv32
|
||||
#define bfloat16_to_float32 bfloat16_to_float32_riscv32
|
||||
|
|
|
@ -213,6 +213,8 @@
|
|||
#define bfloat16_sqrt bfloat16_sqrt_riscv64
|
||||
#define bfloat16_compare bfloat16_compare_riscv64
|
||||
#define bfloat16_compare_quiet bfloat16_compare_quiet_riscv64
|
||||
#define bfloat16_is_quiet_nan bfloat16_is_quiet_nan_riscv64
|
||||
#define bfloat16_is_signaling_nan bfloat16_is_signaling_nan_riscv64
|
||||
#define bfloat16_silence_nan bfloat16_silence_nan_riscv64
|
||||
#define bfloat16_default_nan bfloat16_default_nan_riscv64
|
||||
#define bfloat16_to_float32 bfloat16_to_float32_riscv64
|
||||
|
|
|
@ -213,6 +213,8 @@
|
|||
#define bfloat16_sqrt bfloat16_sqrt_sparc
|
||||
#define bfloat16_compare bfloat16_compare_sparc
|
||||
#define bfloat16_compare_quiet bfloat16_compare_quiet_sparc
|
||||
#define bfloat16_is_quiet_nan bfloat16_is_quiet_nan_sparc
|
||||
#define bfloat16_is_signaling_nan bfloat16_is_signaling_nan_sparc
|
||||
#define bfloat16_silence_nan bfloat16_silence_nan_sparc
|
||||
#define bfloat16_default_nan bfloat16_default_nan_sparc
|
||||
#define bfloat16_to_float32 bfloat16_to_float32_sparc
|
||||
|
|
|
@ -213,6 +213,8 @@
|
|||
#define bfloat16_sqrt bfloat16_sqrt_sparc64
|
||||
#define bfloat16_compare bfloat16_compare_sparc64
|
||||
#define bfloat16_compare_quiet bfloat16_compare_quiet_sparc64
|
||||
#define bfloat16_is_quiet_nan bfloat16_is_quiet_nan_sparc64
|
||||
#define bfloat16_is_signaling_nan bfloat16_is_signaling_nan_sparc64
|
||||
#define bfloat16_silence_nan bfloat16_silence_nan_sparc64
|
||||
#define bfloat16_default_nan bfloat16_default_nan_sparc64
|
||||
#define bfloat16_to_float32 bfloat16_to_float32_sparc64
|
||||
|
|
|
@ -213,6 +213,8 @@
|
|||
#define bfloat16_sqrt bfloat16_sqrt_x86_64
|
||||
#define bfloat16_compare bfloat16_compare_x86_64
|
||||
#define bfloat16_compare_quiet bfloat16_compare_quiet_x86_64
|
||||
#define bfloat16_is_quiet_nan bfloat16_is_quiet_nan_x86_64
|
||||
#define bfloat16_is_signaling_nan bfloat16_is_signaling_nan_x86_64
|
||||
#define bfloat16_silence_nan bfloat16_silence_nan_x86_64
|
||||
#define bfloat16_default_nan bfloat16_default_nan_x86_64
|
||||
#define bfloat16_to_float32 bfloat16_to_float32_x86_64
|
||||
|
|
Loading…
Reference in a new issue