Re: [PATCH] RISC-V: Support Zfinx/Zdinx extension.

Sebastian Huber <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <[email protected]>
On 26.07.23 12:03, Kito Cheng via Newlib wrote:
> Zfinx/Zdinx are new extensions ratified in 2022, it similar to F/D 
> extensions, support hard float operation for single/double precision, 
> but the difference between Zfinx/Zdinx and F/D is Zfinx/Zdinx is 
> operating under general purpose registers rather than dedicated 
> floating-point registers. This patch improve the hard float support 
> detection for RISC-V port, so that Zfinx/Zdinx can have better/right 
> performance. Co-authored-by: Jesse Huang <[email protected]>

This patch probably broke the RTEMS build of Newlib:

../../../../../gnu-mirror-gcc-d04fe55/newlib/libm/machine/riscv/fesetround.c: 
In function 'fesetround':
../../../../../gnu-mirror-gcc-d04fe55/newlib/libm/machine/riscv/fesetround.c:56:12: 
error: 'FE_RMODE_MASK' undeclared (first use in this function)
    56 |   round &= FE_RMODE_MASK;
       |            ^~~~~~~~~~~~~
../../../../../gnu-mirror-gcc-d04fe55/newlib/libm/machine/riscv/fesetround.c:56:12: 
note: each undeclared identifier is reported only once for each function 
it appears in
make[6]: *** [Makefile:48845: libm/machine/riscv/libm_a-fesetround.o] 
Error 1
make[6]: *** Waiting for unfinished jobs....
../../../../../gnu-mirror-gcc-d04fe55/newlib/libm/complex/cprojl.c: In 
function 'cprojl':
../../../../../gnu-mirror-gcc-d04fe55/newlib/libm/complex/cprojl.c:60:18: 
warning: implicit declaration of function 'copysignl'; did you mean 
'copysignf'? [-Wimplicit-function-declaration]
    60 |   IMAG_PART(w) = copysignl(0.0L, cimagl(z));
       |                  ^~~~~~~~~
       |                  copysignf
make[6]: Leaving directory 
'/tmp/sh/b-rsb/riscv-rtems6-gcc-d04fe55-newlib-fe5886a-x86_64-linux-gnu-1/build/riscv-rtems6/rv32imaf/ilp32f/newlib'

We have

#if defined(__riscv_f) || defined(__riscv_zfinx)

[...]

/* Per "The RISC-V Instruction Set Manual: Volume I: User-Level ISA:
  * Version 2.1", Section 8.2, "Floating-Point Control and Status
  * Register":
  *
  * Rounding Mode  Mnemonic Meaning  Meaning
  * -------------  ----------------  -------
  * 000            RNE               Round to Nearest, ties to Even
  * 001            RTZ               Round towards Zero
  * 010            RDN               Round Down (towards −∞)
  * 011            RUP               Round Up (towards +∞)
  * 100            RMM               Round to Nearest, ties to Max Magnitude
  * 101                              Invalid. Reserved for future use.
  * 110                              Invalid. Reserved for future use.
  * 111                              In instruction’s rm field, selects 
dynamic rounding mode;
  *                                  In Rounding Mode register, Invalid
  */

#define FE_TONEAREST_MM 0x00000004
#define FE_UPWARD     	0x00000003
#define FE_DOWNWARD   	0x00000002
#define FE_TOWARDZERO 	0x00000001
#define FE_TONEAREST  	0x00000000

#define FE_RMODE_MASK   0x7

vs.

int fesetround(int round)
{

#ifdef __RISCV_HARD_FLOAT

   /* Mask round to be sure only valid rounding bits are set */

   round &= FE_RMODE_MASK;

-- 
embedded brains GmbH
Herr Sebastian HUBER
Dornierstr. 4
82178 Puchheim
Germany
email: [email protected]
phone: +49-89-18 94 741 - 16
fax:   +49-89-18 94 741 - 08

Registergericht: Amtsgericht München
Registernummer: HRB 157899
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
Unsere Datenschutzerklärung finden Sie hier:
https://embedded-brains.de/datenschutzerklaerung/
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.