[4/4] riscv: Addfpgetroundtoi and fpsetroundtoi stubs

Message ID 20200121064637.1355843-4-keithp@keithp.com
State New
Headers show
Series
  • [1/4] riscv: Use current pseudo-instructions to access the FCSR register
Related show

Commit Message

Keith Packard Jan. 21, 2020, 6:46 a.m.
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(+)

-- 
2.25.0.rc1

Comments

Jim Wilson Jan. 21, 2020, 10:43 p.m. | #1
I think fpgetroundtoi and fpsetroundtoi should always return error.

I found a reference in a NEC V810 manual that has separate bits for FP
rounding and FP->INT conversion rounding.  Hence it needs two separate
interfaces to be able to access the two sets of rounding bits.  For
bonus points, it mentions that tkcw means task control word.  tkcw is
used in the newlib sysvi386 port implementation of these functions.
So I think some very old (pre x87?) x86 ports also had two separate
sets of rounding bits, and this is why newlib has the second set of
functions.  I didn't find a reference to confirm this though.  But for
any modern machine, there is only one set of FP rounding flags, and
hence I think the fp{get,set}roundtoi functions are useless, and
should always return error.

Jim
Kito Cheng Jan. 22, 2020, 7:06 a.m. | #2
Hi Jim, Keith:

I agree both should return error (-1), the problem seems more
complicated if we consider long double.
But those functions are seems like useless now, so yeah, let's always
return error :P

Thanks :)

On Wed, Jan 22, 2020 at 6:43 AM Jim Wilson <jimw@sifive.com> wrote:
>

> I think fpgetroundtoi and fpsetroundtoi should always return error.

>

> I found a reference in a NEC V810 manual that has separate bits for FP

> rounding and FP->INT conversion rounding.  Hence it needs two separate

> interfaces to be able to access the two sets of rounding bits.  For

> bonus points, it mentions that tkcw means task control word.  tkcw is

> used in the newlib sysvi386 port implementation of these functions.

> So I think some very old (pre x87?) x86 ports also had two separate

> sets of rounding bits, and this is why newlib has the second set of

> functions.  I didn't find a reference to confirm this though.  But for

> any modern machine, there is only one set of FP rounding flags, and

> hence I think the fp{get,set}roundtoi functions are useless, and

> should always return error.

>

> Jim

Patch

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;
+}
+
+fp_rdi fpsetroundtoi (fp_rdi rdi)
+{
+  return -1;
+}