From patchwork Wed Aug 19 15:39:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1347906 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=sourceware.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=dcoGUlu6; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BWsfY3CP5z9sPB for ; Thu, 20 Aug 2020 01:49:41 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D7D33386F81C; Wed, 19 Aug 2020 15:49:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D7D33386F81C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1597852154; bh=sTOz6tgZgOTcneBEMwoQrLgAcfiKnokCho4adBD92sg=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=dcoGUlu60stPMM05se0MEMPeSmrMm8rwD7rlu9L3fNfH3TnuzvW5LbcqTOwWX2MzX 5OwUAxoYrJ3SET40ST8ej+FV+lCZp9M/BSmE64c4qD3qGjNo2nuHGKIwAfKi43nQNS yxJbcXlBLhMuJ4J+/1r3oRxjZv5CpwXAbUd/593k= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from esa1.hgst.iphmx.com (esa1.hgst.iphmx.com [68.232.141.245]) by sourceware.org (Postfix) with ESMTPS id 873743842437 for ; Wed, 19 Aug 2020 15:49:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 873743842437 IronPort-SDR: 3Mezfr6aPrEVljtn09eIQjteCNFCe8o5CE2+0b2eC2f3b2nX6lOVPu7+dXvn1Xa+ElAjfXeM7X N1Irm+PdhyW9BbRnFHl+Bx70ttoveWlmrQIpef7NimaLz3n0afORvUfhkjd2Q/nuYLD1OTtoBN Kh25SaXXRZGVLr6JfgPvWImgnJIJqr6SKeb0kd+H1Fhnaf4ycEqsLoUqeZobRaamUJktwv74jp 4ilzDnKiyL9OVWugqNDHnVaJ6Uz0tm30rmSlbyM+NBGTVlE4qjMFUa+sdsFtzhNAu0m8VRP0Q4 Vvg= X-IronPort-AV: E=Sophos;i="5.76,331,1592841600"; d="scan'208";a="254766961" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 19 Aug 2020 23:49:10 +0800 IronPort-SDR: 40tcswpTHZ9ssLUZAUNEetFjJpntSLnw8Xa8aGERhOPETPudxJdkRqZfswBu82iwASbuTyi5IU dzib/zwPXtgw== Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Aug 2020 08:36:08 -0700 IronPort-SDR: b5iFxTzOqFup1y2OgvD4/1ZJ8bkiR2FCG8JrqVniC9yKxYi1H4e7urSe98YmIe75IWAKJPOQqk P6B+CE+RB72g== WDCIronportException: Internal Received: from lpt-kalia-a.ad.shared (HELO risc6-mainframe.hgst.com) ([10.86.59.58]) by uls-op-cesaip02.wdc.com with ESMTP; 19 Aug 2020 08:49:11 -0700 To: libc-alpha@sourceware.org Subject: [PATCH v5 09/17] RISC-V: Add hard float support for 32-bit CPUs Date: Wed, 19 Aug 2020 08:39:02 -0700 Message-Id: X-Mailer: git-send-email 2.28.0 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-13.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Alistair Francis via Libc-alpha From: Alistair Francis Reply-To: Alistair Francis Cc: alistair.francis@wdc.com Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" From: Zong Li This patch adds support for hardware floating-point support for the RV32IF and RV32IFD platforms. Reviewed-by: Maciej W. Rozycki --- 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..bdec792f18 --- /dev/null +++ b/sysdeps/riscv/rv32/rvd/s_lrint.c @@ -0,0 +1,31 @@ +/* lrint(). The 32-bit RISC-V (RV32) version. + Copyright (C) 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..78bccd47ae --- /dev/null +++ b/sysdeps/riscv/rv32/rvd/s_lround.c @@ -0,0 +1,31 @@ +/* lround(). 32-bit RISC-V (RV32) version. + Copyright (C) 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..b8e1df439e --- /dev/null +++ b/sysdeps/riscv/rv32/rvf/s_lrintf.c @@ -0,0 +1,31 @@ +/* lrintf(). 32-bit RISC-V (RV32) version. + Copyright (C) 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 +__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..32f9925084 --- /dev/null +++ b/sysdeps/riscv/rv32/rvf/s_lroundf.c @@ -0,0 +1,31 @@ +/* lroundf(). 32-bit RISC-V (RV32) version. + Copyright (C) 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)