[PATCH 4/4] riscv: Addfpgetroundtoi and fpsetroundtoi stubs

Kito Cheng kito.cheng@gmail.com
Tue Jan 21 07:23:00 GMT 2020


Hi Keith:

Thanks for the patch, some inline comment :)

On Tue, Jan 21, 2020 at 2:47 PM Keith Packard <keithp@keithp.com> wrote:
>
> I've found no description of what these functions are supposed to do,
> so I'm not even going to try and implement them.
>
> Signed-off-by: Keith Packard <keithp@keithp.com>
> ---
>  newlib/libc/machine/riscv/ieeefp.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>
> diff --git a/newlib/libc/machine/riscv/ieeefp.c b/newlib/libc/machine/riscv/ieeefp.c
> index 60ecacfc2..46e4a4b15 100644
> --- a/newlib/libc/machine/riscv/ieeefp.c
> +++ b/newlib/libc/machine/riscv/ieeefp.c
> @@ -142,3 +142,13 @@ fpsetsticky(fp_except sticky)
>    return -1;
>  #endif /* __riscv_flen */
>  }
> +
> +fp_rdi fpgetroundtoi (void)
> +{
> +  return 0;

According RISC-V ISA spec, V20190608 11.7:
"All floating-point to integer and integer to floating-point
conversion instructions round according to the rm field."
So seem like FP_RDI_RD would be better value if hard float is available.

#if __riscv_flen
  return FP_RDI_RD;
#else
  /* libgcc always rounding toward zero.  */
  return FP_RDI_TOZ;
#endif

> +}
> +
> +fp_rdi fpsetroundtoi (fp_rdi rdi)
> +{
> +  return -1;

According the implementation in newlib/libc/sys/sysvi386/fpx.c, the
return value seems intend to return old rounding mode for fp to
integer.

But RISC-V don't provide any way to switch that, so return -1 OK to me.

> +}
> --
> 2.25.0.rc1
>



More information about the Newlib mailing list