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

Kito Cheng <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <CA+yXCZBm__GiqSGm3WeE3jOoG=9KQjqYT-rC=+wEmm9rjnuerQ@mail.gmail.com>
Hi Keith:

Thanks for the patch, some inline comment :)

On Tue, Jan 21, 2020 at 2:47 PM Keith Packard <[email protected]> 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 <[email protected]>
> ---
>  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
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.