From patchwork Mon Nov 7 14:05:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiaolin Tang X-Patchwork-Id: 60097 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EC06E3857BA0 for ; Mon, 7 Nov 2022 14:06:01 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by sourceware.org (Postfix) with ESMTP id 453F83858C39 for ; Mon, 7 Nov 2022 14:05:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 453F83858C39 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=loongson.cn Received: from loongson.cn (unknown [10.2.5.5]) by gateway (Coremail) with SMTP id _____8DxTtutEGljrA0FAA--.16751S3; Mon, 07 Nov 2022 22:05:33 +0800 (CST) Received: from 5.5.5 (unknown [10.2.5.5]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Cxb+KkEGljEHoOAA--.40708S3; Mon, 07 Nov 2022 22:05:32 +0800 (CST) From: Xiaolin Tang To: adhemerval.zanella@linaro.org, libc-alpha@sourceware.org, i.swmail@xen0n.name Cc: caiyinyu@loongson.cn, xry111@xry111.site, xuchenghua@loongson.cn, chenglulu@loongson.cn, Xiaolin Tang Subject: [PATCH v2 01/10] LoongArch: Hard Float Support for functions {ll/l/ }rint{f/ }. Date: Mon, 7 Nov 2022 22:05:14 +0800 Message-Id: <20221107140523.896735-2-tangxiaolin@loongson.cn> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221107140523.896735-1-tangxiaolin@loongson.cn> References: <20221107140523.896735-1-tangxiaolin@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: AQAAf8Cxb+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IxAIcVC2z280aVCY1x0267AKxVWUJV W8JbIYCTnIWIevJa73UjIFyTuYvjxUwMKuUUUUU X-Spam-Status: No, score=-12.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_SHORT, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: , Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Use hardware Floating-point instruction frint.{s/d} to implement functions {ll/l/ }rint{f/ }. * sysdeps/loongarch/fpu/s_llrint.c: New file. * sysdeps/loongarch/fpu/s_llrintf.c: Likewise. * sysdeps/loongarch/fpu/s_lrint.c: Likewise. * sysdeps/loongarch/fpu/s_lrintf.c: Likewise. * sysdeps/loongarch/fpu/s_rint.c: Likewise. * sysdeps/loongarch/fpu/s_rintf.c: Likewise. --- sysdeps/loongarch/fpu/s_llrint.c | 29 +++++++++++++++++++++++++++++ sysdeps/loongarch/fpu/s_llrintf.c | 29 +++++++++++++++++++++++++++++ sysdeps/loongarch/fpu/s_lrint.c | 29 +++++++++++++++++++++++++++++ sysdeps/loongarch/fpu/s_lrintf.c | 29 +++++++++++++++++++++++++++++ sysdeps/loongarch/fpu/s_rint.c | 29 +++++++++++++++++++++++++++++ sysdeps/loongarch/fpu/s_rintf.c | 29 +++++++++++++++++++++++++++++ 6 files changed, 174 insertions(+) create mode 100644 sysdeps/loongarch/fpu/s_llrint.c create mode 100644 sysdeps/loongarch/fpu/s_llrintf.c create mode 100644 sysdeps/loongarch/fpu/s_lrint.c create mode 100644 sysdeps/loongarch/fpu/s_lrintf.c create mode 100644 sysdeps/loongarch/fpu/s_rint.c create mode 100644 sysdeps/loongarch/fpu/s_rintf.c diff --git a/sysdeps/loongarch/fpu/s_llrint.c b/sysdeps/loongarch/fpu/s_llrint.c new file mode 100644 index 0000000000..cf787f50ed --- /dev/null +++ b/sysdeps/loongarch/fpu/s_llrint.c @@ -0,0 +1,29 @@ +/* llrint(). LoongArch version. + Copyright (C) 2022 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 + . */ + +#define NO_MATH_REDIRECT +#include +#include + +long long int +__llrint (double x) +{ + asm volatile ("frint.d \t%0, %1" : "=f" (x) : "f" (x)); + return x; +} +libm_alias_double (__llrint, llrint) diff --git a/sysdeps/loongarch/fpu/s_llrintf.c b/sysdeps/loongarch/fpu/s_llrintf.c new file mode 100644 index 0000000000..a258e635ce --- /dev/null +++ b/sysdeps/loongarch/fpu/s_llrintf.c @@ -0,0 +1,29 @@ +/* llrintf(). LoongArch version. + Copyright (C) 2022 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 + . */ + +#define NO_MATH_REDIRECT +#include +#include + +long long int +__llrintf (float x) +{ + asm volatile ("frint.s \t%0, %1" : "=f" (x) : "f" (x)); + return x; +} +libm_alias_float (__llrint, llrint) diff --git a/sysdeps/loongarch/fpu/s_lrint.c b/sysdeps/loongarch/fpu/s_lrint.c new file mode 100644 index 0000000000..10d43218f8 --- /dev/null +++ b/sysdeps/loongarch/fpu/s_lrint.c @@ -0,0 +1,29 @@ +/* lrint(). LoongArch version. + Copyright (C) 2022 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 + . */ + +#define NO_MATH_REDIRECT +#include +#include + +long int +__lrint (double x) +{ + asm volatile ("frint.d \t%0, %1" : "=f" (x) : "f" (x)); + return x; +} +libm_alias_double (__lrint, lrint) diff --git a/sysdeps/loongarch/fpu/s_lrintf.c b/sysdeps/loongarch/fpu/s_lrintf.c new file mode 100644 index 0000000000..7168eda7cb --- /dev/null +++ b/sysdeps/loongarch/fpu/s_lrintf.c @@ -0,0 +1,29 @@ +/* lrintf(). LoongArch version. + Copyright (C) 2022 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 + . */ + +#define NO_MATH_REDIRECT +#include +#include + +long int +__lrintf (float x) +{ + asm volatile ("frint.s \t%0, %1" : "=f" (x) : "f" (x)); + return x; +} +libm_alias_float (__lrint, lrint) diff --git a/sysdeps/loongarch/fpu/s_rint.c b/sysdeps/loongarch/fpu/s_rint.c new file mode 100644 index 0000000000..429d5d1176 --- /dev/null +++ b/sysdeps/loongarch/fpu/s_rint.c @@ -0,0 +1,29 @@ +/* rint(). LoongArch version. + Copyright (C) 2022 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 + . */ + +#define NO_MATH_REDIRECT +#include +#include + +double +__rint (double x) +{ + asm volatile ("frint.d \t%0, %1" : "=f" (x) : "f" (x)); + return x; +} +libm_alias_double (__rint, rint) diff --git a/sysdeps/loongarch/fpu/s_rintf.c b/sysdeps/loongarch/fpu/s_rintf.c new file mode 100644 index 0000000000..b3faba2027 --- /dev/null +++ b/sysdeps/loongarch/fpu/s_rintf.c @@ -0,0 +1,29 @@ +/* rintf(). LoongArch version. + Copyright (C) 2022 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 + . */ + +#define NO_MATH_REDIRECT +#include +#include + +float +__rintf (float x) +{ + asm volatile ("frint.s \t%0, %1" : "=f" (x) : "f" (x)); + return x; +} +libm_alias_float (__rint, rint)