From patchwork Sat Aug 10 01:00:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 34044 Received: (qmail 77292 invoked by alias); 10 Aug 2019 01:03:56 -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 77238 invoked by uid 89); 10 Aug 2019 01:03:55 -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: esa1.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=1565399033; x=1596935033; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NndjqXRKCypdh7O4sAFzzlwE1pEdr9l71POnZce5hnk=; b=Q1vYxLhuc5iQ3sOc3GGjhXkuslGjuP1DSEqj9vv+6fq/8Dsu4F14rPTM FHfMCS/3xgyv7OHB+pUujXPGLu+y0xOcWhaO40uaKqWrK65cPCQjNlDsf ELtohqI750h++So/qlzQFazsa3Kk2OaiLBuYTcUNPZH3fkosTwVjqmqBy lOpm4G8Id3MImOVOUiYrFqgIB4AwH6jLNic0+MCAGuu/rwIPHFLxLqB+a 5A5+KwVDhTKZRFURPkWjNpHrSkRHGRJFyXDBTF1z/yzdqIoAYgKowpZqG jI/2+P3hAWJRVvqNQtRfLMifyQQQ5nJliiYgYGelP65qF57iG5SV654P2 w==; IronPort-SDR: QkmeBGc31KqXK1grDL/A+OOi6GTB7izgCCCVGvrl1LmW2TvYCLfaWe8ynaZZ340ZlLFNuRyb7l nzzSl1ZEHevG53z1tgcE6K7VBS4Z85cx+EUkTVd+cxv6XlTBXxKWdW4DUIduL9+3+lurnvhyHL yxHeq2l2yQ3sINDp46FixLULGQIbTITOi57PUFXJoT8voditn1aCZhOSSW7aG2NbvqbQGHc5nr PkbH/HIlHTbifTK+vTDVPZ+5QXUG6K0SO8pE5keHCAxSlunYU95TEdg2C1LiiE8Evkq7jCbzxp /X4= IronPort-SDR: g7mhRfeY1LZ4xckLPd+DCMsnB0RfvNGdEAFpx8iddbymqAY/8Vu7CO+MXx115o4Iu01SuSIhiK 7EHwlhhMt3qE2ZIWUJ3qz5czH+kBuxPnoZEW9f3CDp8gS78X+474e8oJ2gyzPjJBTh9TuZhEC+ AxTtUvooqHEGiWt3ecH+aSkdAXFie/wlPwI/pOHxva5mlUU9VnS1QYEakYHWqcKGykD0pCa0Ks u2hMqGB0sJwgk7Y7uPXogeU8B9NkrtDNpYTjTPA3y7LOcehspAIqZMLFuOE2ha+BjrM9OXYiXi OokAduReg+EJlwa5SedDFk5d IronPort-SDR: bbGSwf4evwMakxyFqNsz7YXBHZ44qJ4UR7n1FU/pbzu2hmIJZr/mT17geA8lv+Hhj8nYiRV7l+ aGP+h3Hu6Ms7IyFhl5940BsRzJo0YUbqB+bWN3GjIwzLA9ErQuVXhfi6zVYqm8XvQVzhOVswIQ RQHc/rWZ6oqgs2UXVBuo/d6C/e+Yh5aMfhljidNWvJNNOVZLn/1UHuEuo+7f2GE2LQk2JHfo0h PGyjI9DYeSxpG9cg8P8JO2Z1wbrefB60K2VaHXaPCusiYjQhaGkf7QabmOlQVzLhbmpHk3Ojt0 LI0= From: Alistair Francis To: libc-alpha@sourceware.org Cc: arnd@arndb.de, adhemerval.zanella@linaro.org, fweimer@redhat.com, palmer@sifive.com, macro@wdc.com, zongbox@gmail.com, alistair.francis@wdc.com, alistair23@gmail.com Subject: [RFC v4 17/24] RISC-V: Hard float support for the 32 bit Date: Fri, 9 Aug 2019 18:00:32 -0700 Message-Id: In-Reply-To: References: MIME-Version: 1.0 From: Zong Li This patch contains hardware floating-point support for the RV32IF and RV32IFD 2018-11-29 Zong Li * 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 4faa11ab454..4c926088ba3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1446,6 +1446,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 Florian Weimer diff --git a/sysdeps/riscv/rv32/rvd/s_lrint.c b/sysdeps/riscv/rv32/rvd/s_lrint.c new file mode 100644 index 00000000000..4d5bdbc200e --- /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 + . */ + +#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 00000000000..f5d9cf2e070 --- /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 + . */ + +#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 00000000000..08d44fa7385 --- /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 00000000000..f31b4329362 --- /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 + . */ + +#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)