softfloat: Add fp16 and uint8/int8 conversion functions
Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Frank Chang <frank.chang@sifive.com> Message-Id: <1596102747-20226-4-git-send-email-chihmin.chao@sifive.com> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
parent
dd205025a0
commit
0d93d8ec63
@ -2109,6 +2109,13 @@ static int64_t round_to_int_and_pack(FloatParts in, FloatRoundMode rmode,
|
||||
}
|
||||
}
|
||||
|
||||
int8_t float16_to_int8_scalbn(float16 a, FloatRoundMode rmode, int scale,
|
||||
float_status *s)
|
||||
{
|
||||
return round_to_int_and_pack(float16_unpack_canonical(a, s),
|
||||
rmode, scale, INT8_MIN, INT8_MAX, s);
|
||||
}
|
||||
|
||||
int16_t float16_to_int16_scalbn(float16 a, FloatRoundMode rmode, int scale,
|
||||
float_status *s)
|
||||
{
|
||||
@ -2172,6 +2179,11 @@ int64_t float64_to_int64_scalbn(float64 a, FloatRoundMode rmode, int scale,
|
||||
rmode, scale, INT64_MIN, INT64_MAX, s);
|
||||
}
|
||||
|
||||
int8_t float16_to_int8(float16 a, float_status *s)
|
||||
{
|
||||
return float16_to_int8_scalbn(a, s->float_rounding_mode, 0, s);
|
||||
}
|
||||
|
||||
int16_t float16_to_int16(float16 a, float_status *s)
|
||||
{
|
||||
return float16_to_int16_scalbn(a, s->float_rounding_mode, 0, s);
|
||||
@ -2322,6 +2334,13 @@ static uint64_t round_to_uint_and_pack(FloatParts in, FloatRoundMode rmode,
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t float16_to_uint8_scalbn(float16 a, FloatRoundMode rmode, int scale,
|
||||
float_status *s)
|
||||
{
|
||||
return round_to_uint_and_pack(float16_unpack_canonical(a, s),
|
||||
rmode, scale, UINT8_MAX, s);
|
||||
}
|
||||
|
||||
uint16_t float16_to_uint16_scalbn(float16 a, FloatRoundMode rmode, int scale,
|
||||
float_status *s)
|
||||
{
|
||||
@ -2385,6 +2404,11 @@ uint64_t float64_to_uint64_scalbn(float64 a, FloatRoundMode rmode, int scale,
|
||||
rmode, scale, UINT64_MAX, s);
|
||||
}
|
||||
|
||||
uint8_t float16_to_uint8(float16 a, float_status *s)
|
||||
{
|
||||
return float16_to_uint8_scalbn(a, s->float_rounding_mode, 0, s);
|
||||
}
|
||||
|
||||
uint16_t float16_to_uint16(float16 a, float_status *s)
|
||||
{
|
||||
return float16_to_uint16_scalbn(a, s->float_rounding_mode, 0, s);
|
||||
@ -2539,6 +2563,11 @@ float16 int16_to_float16(int16_t a, float_status *status)
|
||||
return int64_to_float16_scalbn(a, 0, status);
|
||||
}
|
||||
|
||||
float16 int8_to_float16(int8_t a, float_status *status)
|
||||
{
|
||||
return int64_to_float16_scalbn(a, 0, status);
|
||||
}
|
||||
|
||||
float32 int64_to_float32_scalbn(int64_t a, int scale, float_status *status)
|
||||
{
|
||||
FloatParts pa = int_to_float(a, scale, status);
|
||||
@ -2664,6 +2693,11 @@ float16 uint16_to_float16(uint16_t a, float_status *status)
|
||||
return uint64_to_float16_scalbn(a, 0, status);
|
||||
}
|
||||
|
||||
float16 uint8_to_float16(uint8_t a, float_status *status)
|
||||
{
|
||||
return uint64_to_float16_scalbn(a, 0, status);
|
||||
}
|
||||
|
||||
float32 uint64_to_float32_scalbn(uint64_t a, int scale, float_status *status)
|
||||
{
|
||||
FloatParts pa = uint_to_float(a, scale, status);
|
||||
|
@ -136,9 +136,11 @@ float16 uint16_to_float16_scalbn(uint16_t a, int, float_status *status);
|
||||
float16 uint32_to_float16_scalbn(uint32_t a, int, float_status *status);
|
||||
float16 uint64_to_float16_scalbn(uint64_t a, int, float_status *status);
|
||||
|
||||
float16 int8_to_float16(int8_t a, float_status *status);
|
||||
float16 int16_to_float16(int16_t a, float_status *status);
|
||||
float16 int32_to_float16(int32_t a, float_status *status);
|
||||
float16 int64_to_float16(int64_t a, float_status *status);
|
||||
float16 uint8_to_float16(uint8_t a, float_status *status);
|
||||
float16 uint16_to_float16(uint16_t a, float_status *status);
|
||||
float16 uint32_to_float16(uint32_t a, float_status *status);
|
||||
float16 uint64_to_float16(uint64_t a, float_status *status);
|
||||
@ -187,10 +189,13 @@ float32 float16_to_float32(float16, bool ieee, float_status *status);
|
||||
float16 float64_to_float16(float64 a, bool ieee, float_status *status);
|
||||
float64 float16_to_float64(float16 a, bool ieee, float_status *status);
|
||||
|
||||
int8_t float16_to_int8_scalbn(float16, FloatRoundMode, int,
|
||||
float_status *status);
|
||||
int16_t float16_to_int16_scalbn(float16, FloatRoundMode, int, float_status *);
|
||||
int32_t float16_to_int32_scalbn(float16, FloatRoundMode, int, float_status *);
|
||||
int64_t float16_to_int64_scalbn(float16, FloatRoundMode, int, float_status *);
|
||||
|
||||
int8_t float16_to_int8(float16, float_status *status);
|
||||
int16_t float16_to_int16(float16, float_status *status);
|
||||
int32_t float16_to_int32(float16, float_status *status);
|
||||
int64_t float16_to_int64(float16, float_status *status);
|
||||
@ -199,6 +204,8 @@ int16_t float16_to_int16_round_to_zero(float16, float_status *status);
|
||||
int32_t float16_to_int32_round_to_zero(float16, float_status *status);
|
||||
int64_t float16_to_int64_round_to_zero(float16, float_status *status);
|
||||
|
||||
uint8_t float16_to_uint8_scalbn(float16 a, FloatRoundMode,
|
||||
int, float_status *status);
|
||||
uint16_t float16_to_uint16_scalbn(float16 a, FloatRoundMode,
|
||||
int, float_status *status);
|
||||
uint32_t float16_to_uint32_scalbn(float16 a, FloatRoundMode,
|
||||
@ -206,6 +213,7 @@ uint32_t float16_to_uint32_scalbn(float16 a, FloatRoundMode,
|
||||
uint64_t float16_to_uint64_scalbn(float16 a, FloatRoundMode,
|
||||
int, float_status *status);
|
||||
|
||||
uint8_t float16_to_uint8(float16 a, float_status *status);
|
||||
uint16_t float16_to_uint16(float16 a, float_status *status);
|
||||
uint32_t float16_to_uint32(float16 a, float_status *status);
|
||||
uint64_t float16_to_uint64(float16 a, float_status *status);
|
||||
|
Loading…
Reference in New Issue
Block a user