From patchwork Sun Jan 12 10:34:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 37323 Received: (qmail 13858 invoked by alias); 12 Jan 2020 10:40:42 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 13798 invoked by uid 89); 12 Jan 2020 10:40:41 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT autolearn=ham version=3.3.1 spammy= X-HELO: esa6.hgst.iphmx.com DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1578825639; x=1610361639; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=i8gGMH6GCipx5+Y7lz+67k5+CLEoAYyfuxV0U4mmuYw=; b=A65qfC6sLm8h7ac4GCir7bhZxygZTqCvZSxq4PIZD75bsAUrJkk4Bqpr BQvQ0tNbHAwG0qO5ygWl1iUr+X+PFmfgKAGS3QKTPTUVTDVLDve3xCLvh YLLN7YpgBfJg/YW1Gqou58526F0eHRfek+ZDcMjLYVO4xe0Jp2VQoUWqp BjBOlZE/8HNQpMAl+QLrJ037jAgz2bGclGXglark/J1bc3KoiBoheayxy XDwzHQuVRjg/gT/qfiMj7qzkIsyWSjWcqjbFEAi//mFIG6GYaBIWyBehZ pIXL5vGw8rSaOLHnYqm9xJFaRMcwkKCqft08GTbJZ/c9SmhsLSNW8nkhM A==; IronPort-SDR: NcvzyuXIcRX8AsQdrTTbqz4mVjzt13kqHpvXMstU8oeZK/H+e73JjmFhuTDbxHPc/r0KLf9Nmy pe8sVyFqy4sIWuC5J+3x7VHoUwpcsb+YLqkxFb4hULZQuekVcRv6QwvH2SzRJ+zrt0h9354Ixh HHoxALCFKWUqDrbIbi+5xTlLZKTwYO3uNYKhvLX1l6LqJnTtnUOTrrbNMiycRW8QP0xCCfSXT5 EuDhor4WFRW4hr0CYwBYjb14UzGJ43liErQRNAYTcsvrYF9pE4funAB3vAQCbft1/BmdKyDFe9 l5o= IronPort-SDR: wEBZesDu+FBoruLIg4dbbFwdkUpp20jcaYVphnIXqH3+mXu2tawWrXLTzeqz7T00lPAe13CNcG R6uk2135VjmV38zJmlZZgNwFzL/lVyYl2lqnvC9H8mnxZDxMiCOYzkPDK1FkpkURzTa9TJP8l3 eSEQqELV4rPtiraEqNWDeS4Xt3Zv9WXZD79hDT3jSrB+dKCFAwMqcUrimotmbxBgglJLPmRSrA r7sESMuUZQcTJ18gbzbIjBqTUtF8Mqy94rkb67Ps8wnvcnie5qPgdkcbhbEsPRj0/NPoyOsUia jqO9YoS4UMzdU9xjKhNlMq7A IronPort-SDR: a+VDXmYC7HSTUXuWvYWyVBd0e33XU5YrVRXzrPu/cdv/nVzWikXIVmNMWH0FVs7HQ2e6cumDQf PDZ+3TxtYvTQ4rTyMLSLT5kmM3oN938/lVTxM7DMIkm1HNpN1qMykJ+c5Ga8FIAiQtLPIBZRcd znTMp6LbeZLGj3c4yjyIKX3tNn9YXdvA0PTcBK2sfRWmC0rtJqLfmjjptNzPvyl1SWTJ2Wl1TN TZERvvlzvcVGCEfRVODYF3ky3vMze7cMH+s2ir76knKENkpZOz43YoIh2WnbarR1/Y4oWchOBO Q70= WDCIronportException: Internal From: Alistair Francis To: libc-alpha@sourceware.org Cc: arnd@arndb.de, adhemerval.zanella@linaro.org, fweimer@redhat.com, joseph@codesourcery.com, palmerdabbelt@google.com, macro@wdc.com, zongbox@gmail.com, alistair.francis@wdc.com, alistair23@gmail.com Subject: [RFC v6 15/23] RISC-V: Hard float support for 32-bit Date: Sun, 12 Jan 2020 02:34:11 -0800 Message-Id: <074a68c70633ba1488128f46d65c846424e0e50a.1578824547.git.alistair.francis@wdc.com> In-Reply-To: References: MIME-Version: 1.0 From: Zong Li This patch contains hardware floating-point support for the RV32IF and RV32IFD --- 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 ++++++++++++++++++++++++++++++ 4 files changed, 124 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/sysdeps/riscv/rv32/rvd/s_lrint.c b/sysdeps/riscv/rv32/rvd/s_lrint.c new file mode 100644 index 0000000000..df406aacb6 --- /dev/null +++ b/sysdeps/riscv/rv32/rvd/s_lrint.c @@ -0,0 +1,31 @@ +/* lrint(). RISC-V version. + Copyright (C) 2017-2020 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 + . */ + +#include +#include +#include + +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..72aa2b179d --- /dev/null +++ b/sysdeps/riscv/rv32/rvd/s_lround.c @@ -0,0 +1,31 @@ +/* lround(). RISC-V version. + Copyright (C) 2017-2020 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 + . */ + +#include +#include +#include + +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 + . */ + +#include +#include +#include + +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..9ff5d63d1c --- /dev/null +++ b/sysdeps/riscv/rv32/rvf/s_lroundf.c @@ -0,0 +1,31 @@ +/* lroundf(). RISC-V version. + Copyright (C) 2017-2020 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 + . */ + +#include +#include +#include + +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)