This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[RFC v2 15/20] RISC-V: Hard float support for the 32 bit
- From: Alistair Francis <alistair dot francis at wdc dot com>
- To: libc-alpha at sourceware dot org
- Cc: arnd at arndb dot de, adhemerval dot zanella at linaro dot org, fweimer at redhat dot com, palmer at sifive dot com, macro at wdc dot com, zongbox at gmail dot com, zong at andestech dot com, alistair dot francis at wdc dot com, alistair23 at gmail dot com
- Date: Mon, 24 Jun 2019 17:09:29 -0700
- Subject: [RFC v2 15/20] RISC-V: Hard float support for the 32 bit
- Ironport-sdr: ah/AKdbXPgDYcuw+GwCyYrvPxpY2PZh5a8PJtC90+vnExtr8OcSGlfy246/MWTpbr9T3HDuluH P4B0Rv9H/wUiJkMeRfO5695rxDeDNEkAu6LmrvHFvj/jGRKG0iThnTALf5JJ6IYm2kpTMirbcE YNX1N4pucv1YUem+pV1Qfmek+kCY6jo4xQUgLoIZu1O+67jy79YtL4KpHQ2AFfy+LkWLPYUag9 12gkpqFtntTGBI2mTBD8H72chMXUxtK4pa8bwbB4T2EAKADNeAH9OY27dHzJOv9OUhUYriYWY1 6i2EpG7+GoUxHb/JdmozMtiC
- Ironport-sdr: 3KdNNj8lo7KlZWYz6qeuRjQDpXkOHv/tOsKM5/BeSLwPl87/iPqOM1tO6b/cRB32PGwYg1lfV8 ljuRquplXVSW5cRv0f8MQD+bJSIrgASYFKYZB+6EWHrx25/Mmpgwq91J00UI7H6sP1AECg3T0w 4jLn9J5HkhbwFjC4eTfYp+iirrEFPQMxj57v95oHwgQPKWkoPsQAgpVsbtJdAUOi8rC1mjs3bN jXSoG1/XHj27BhkhrSmyjAgWZBEmShn0AZT/1VLrosQyvSzGqmaHH5JpwkuVyQWZvaghtV2PVe MiY=
- References: <cover.1561421042.git.alistair.francis@wdc.com>
From: Zong Li <zongbox@gmail.com>
This patch contains hardware floating-point support for the RV32IF and
RV32IFD
2018-11-29 Zong Li <zong@andestech.com>
* sysdeps/riscv/rv32/rvd/s_lrint.c: New file.
* sysdeps/riscv/rv32/rvd/s_lround.c: Likewise.
* sysdeps/riscv/rv32/rvf/s_lrintf.c: Likewise.
* sysdeps/riscv/rv32/rvf/s_lroundf.c: Likewise.
---
ChangeLog | 4 ++++
sysdeps/riscv/rv32/rvd/s_lrint.c | 31 ++++++++++++++++++++++++++++++
sysdeps/riscv/rv32/rvd/s_lround.c | 31 ++++++++++++++++++++++++++++++
sysdeps/riscv/rv32/rvf/s_lrintf.c | 31 ++++++++++++++++++++++++++++++
sysdeps/riscv/rv32/rvf/s_lroundf.c | 31 ++++++++++++++++++++++++++++++
5 files changed, 128 insertions(+)
create mode 100644 sysdeps/riscv/rv32/rvd/s_lrint.c
create mode 100644 sysdeps/riscv/rv32/rvd/s_lround.c
create mode 100644 sysdeps/riscv/rv32/rvf/s_lrintf.c
create mode 100644 sysdeps/riscv/rv32/rvf/s_lroundf.c
diff --git a/ChangeLog b/ChangeLog
index 98bb7f600d..b25e734556 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -28,6 +28,10 @@
* sysdeps/riscv/sfp-machine.h: Likewise.
* sysdeps/riscv/sys/asm.h: Likewise.
* sysdeps/unix/sysv/linux/riscv/rv32/jmp_buf-macros.h: New file.
+ * sysdeps/riscv/rv32/rvd/s_lrint.c: New file.
+ * sysdeps/riscv/rv32/rvd/s_lround.c: Likewise.
+ * sysdeps/riscv/rv32/rvf/s_lrintf.c: Likewise.
+ * sysdeps/riscv/rv32/rvf/s_lroundf.c: Likewise.
2019-06-20 Dmitry V. Levin <ldv@altlinux.org>
Florian Weimer <fweimer@redhat.com>
diff --git a/sysdeps/riscv/rv32/rvd/s_lrint.c b/sysdeps/riscv/rv32/rvd/s_lrint.c
new file mode 100644
index 0000000000..4d5bdbc200
--- /dev/null
+++ b/sysdeps/riscv/rv32/rvd/s_lrint.c
@@ -0,0 +1,31 @@
+/* lrint(). RISC-V version.
+ Copyright (C) 2017-2018 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <math.h>
+#include <libm-alias-double.h>
+#include <stdint.h>
+
+long int
+__lrint (double x)
+{
+ int32_t res;
+ asm ("fcvt.w.d %0, %1" : "=r" (res) : "f" (x));
+ return res;
+}
+
+libm_alias_double (__lrint, lrint)
diff --git a/sysdeps/riscv/rv32/rvd/s_lround.c b/sysdeps/riscv/rv32/rvd/s_lround.c
new file mode 100644
index 0000000000..f5d9cf2e07
--- /dev/null
+++ b/sysdeps/riscv/rv32/rvd/s_lround.c
@@ -0,0 +1,31 @@
+/* lround(). RISC-V version.
+ Copyright (C) 2017-2018 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <math.h>
+#include <libm-alias-double.h>
+#include <stdint.h>
+
+long int
+__lround (double x)
+{
+ int32_t res;
+ asm ("fcvt.w.d %0, %1, rmm" : "=r" (res) : "f" (x));
+ return res;
+}
+
+libm_alias_double (__lround, lround)
diff --git a/sysdeps/riscv/rv32/rvf/s_lrintf.c b/sysdeps/riscv/rv32/rvf/s_lrintf.c
new file mode 100644
index 0000000000..08d44fa738
--- /dev/null
+++ b/sysdeps/riscv/rv32/rvf/s_lrintf.c
@@ -0,0 +1,31 @@
+/* lrintf(). RISC-V version.
+ Copyright (C) 2017-2018 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <math.h>
+#include <libm-alias-float.h>
+#include <stdint.h>
+
+long int
+__lrintf (float x)
+{
+ int32_t res;
+ asm ("fcvt.w.s %0, %1" : "=r" (res) : "f" (x));
+ return res;
+}
+
+libm_alias_float (__lrint, lrint)
diff --git a/sysdeps/riscv/rv32/rvf/s_lroundf.c b/sysdeps/riscv/rv32/rvf/s_lroundf.c
new file mode 100644
index 0000000000..f31b432936
--- /dev/null
+++ b/sysdeps/riscv/rv32/rvf/s_lroundf.c
@@ -0,0 +1,31 @@
+/* lroundf(). RISC-V version.
+ Copyright (C) 2017-2018 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <math.h>
+#include <libm-alias-float.h>
+#include <stdint.h>
+
+long int
+__lroundf (float x)
+{
+ int32_t res;
+ asm ("fcvt.w.s %0, %1, rmm" : "=r" (res) : "f" (x));
+ return res;
+}
+
+libm_alias_float (__lround, lround)
--
2.22.0