diff mbox series

[RFC,60/65] softfloat: add fp16 and uint8/int8 interconvert functions

Message ID 20200710104920.13550-61-frank.chang@sifive.com
State New
Headers show
Series target/riscv: support vector extension v0.9 | expand

Commit Message

Frank Chang July 10, 2020, 10:49 a.m. UTC
From: Frank Chang <frank.chang@sifive.com>

Signed-off-by: Frank Chang <frank.chang@sifive.com>
---
 fpu/softfloat.c         | 34 ++++++++++++++++++++++++++++++++++
 include/fpu/softfloat.h |  8 ++++++++
 2 files changed, 42 insertions(+)

Comments

Frank Chang July 10, 2020, 12:15 p.m. UTC | #1
On Fri, Jul 10, 2020 at 8:07 PM Alex Bennée <alex.bennee@linaro.org> wrote:

>
> frank.chang@sifive.com writes:
>
> > From: Frank Chang <frank.chang@sifive.com>
> >
> > Signed-off-by: Frank Chang <frank.chang@sifive.com>
>
> Did I miss the rest of the series somewhere?
>
> Otherwise this looks fine to me:
>
> Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
>
> If you mean float16 to uint8 and int8 conversion functions, this commit is
everything.
I think I just cc the mail based on *scripts/get_maintainer.pl
<http://get_maintainer.pl>*, so probably didn't send the whole series to
everyone.
--
Frank Chang

> --
> Alex Bennée
>
Frank Chang July 10, 2020, 1:13 p.m. UTC | #2
On Fri, Jul 10, 2020 at 8:46 PM Alex Bennée <alex.bennee@linaro.org> wrote:

>
> Frank Chang <frank.chang@sifive.com> writes:
>
> > On Fri, Jul 10, 2020 at 8:07 PM Alex Bennée <alex.bennee@linaro.org>
> wrote:
> >
> >>
> >> frank.chang@sifive.com writes:
> >>
> >> > From: Frank Chang <frank.chang@sifive.com>
> >> >
> >> > Signed-off-by: Frank Chang <frank.chang@sifive.com>
> >>
> >> Did I miss the rest of the series somewhere?
> >>
> >> Otherwise this looks fine to me:
> >>
> >> Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
> >>
> >> If you mean float16 to uint8 and int8 conversion functions, this commit
> is
> > everything.
> > I think I just cc the mail based on *scripts/get_maintainer.pl
> > <http://get_maintainer.pl>*, so probably didn't send the whole series to
> > everyone.
>
> Usually I see the rest of the thread from the mailing list. I can't see:
>
>   In-Reply-To: <20200710104920.13550-1-frank.chang@sifive.com>
>   References: <20200710104920.13550-1-frank.chang@sifive.com>
>
> on any of the qemu mailing lists.
>
> --
> Alex Bennée
>

The rest of the patches are coming out:
https://patchew.org/QEMU/20200710104920.13550-1-frank.chang@sifive.com/
Not sure what caused the delay...
--
Frank Chang
Alex Bennée July 10, 2020, 2:59 p.m. UTC | #3
Frank Chang <frank.chang@sifive.com> writes:

> On Fri, Jul 10, 2020 at 8:46 PM Alex Bennée <alex.bennee@linaro.org> wrote:
>
>>
>> Frank Chang <frank.chang@sifive.com> writes:
>>
>> > On Fri, Jul 10, 2020 at 8:07 PM Alex Bennée <alex.bennee@linaro.org>
>> wrote:
>> >
>> >>
>> >> frank.chang@sifive.com writes:
>> >>
>> >> > From: Frank Chang <frank.chang@sifive.com>
>> >> >
>> >> > Signed-off-by: Frank Chang <frank.chang@sifive.com>
>> >>
>> >> Did I miss the rest of the series somewhere?
>> >>
>> >> Otherwise this looks fine to me:
>> >>
>> >> Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
>> >>
>> >> If you mean float16 to uint8 and int8 conversion functions, this commit
>> is
>> > everything.
>> > I think I just cc the mail based on *scripts/get_maintainer.pl
>> > <http://get_maintainer.pl>*, so probably didn't send the whole series to
>> > everyone.
>>
>> Usually I see the rest of the thread from the mailing list. I can't see:
>>
>>   In-Reply-To: <20200710104920.13550-1-frank.chang@sifive.com>
>>   References: <20200710104920.13550-1-frank.chang@sifive.com>
>>
>> on any of the qemu mailing lists.
>>
>> --
>> Alex Bennée
>>
>
> The rest of the patches are coming out:
> https://patchew.org/QEMU/20200710104920.13550-1-frank.chang@sifive.com/
> Not sure what caused the delay...

Ahh the mailing list is still chugging a bit it seems.
diff mbox series

Patch

diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index 79be4f5840..fa1c99c03e 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -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);
diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h
index ff4e2605b1..b0ae8f6295 100644
--- a/include/fpu/softfloat.h
+++ b/include/fpu/softfloat.h
@@ -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);