riscv: No volatile needed on asm to _read_ rounding mode, exceptions.

These instructions can be omitted if the return values are unused.
In contrast, _writes_ to the rounding mode or exceptions must not be
omitted (even if we ignore the return value, which is the old value
of the field).

I think "memory" is the wrong clobber on these asm blocks too; they
can't be reordered around _floating-point_ instructions, while
reordering around loads and stores is fine.  But I don't know how to
spell the right thing in gcclish.
This commit is contained in:
riastradh 2024-05-14 15:17:57 +00:00
parent 5830d5d1cf
commit 3fd343c9a6
1 changed files with 4 additions and 4 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: sysreg.h,v 1.32 2024/05/14 15:16:51 riastradh Exp $ */
/* $NetBSD: sysreg.h,v 1.33 2024/05/14 15:17:57 riastradh Exp $ */
/*
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@ -57,7 +57,7 @@ static inline uint32_t
fcsr_read(void)
{
uint32_t __fcsr;
asm volatile("frcsr %0" : "=r"(__fcsr) :: "memory");
asm("frcsr %0" : "=r"(__fcsr) :: "memory");
return __fcsr;
}
@ -73,7 +73,7 @@ static inline uint32_t
fcsr_fflags_read(void)
{
uint32_t __old;
asm volatile("frflags %0" : "=r"(__old) :: "memory");
asm("frflags %0" : "=r"(__old) :: "memory");
return __old;
}
@ -89,7 +89,7 @@ static inline uint32_t
fcsr_frm_read(void)
{
uint32_t __old;
asm volatile("frrm\t%0" : "=r"(__old) :: "memory");
asm("frrm\t%0" : "=r"(__old) :: "memory");
return __old;
}