From patchwork Wed Nov 23 02:38:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiaolin Tang X-Patchwork-Id: 61001 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 6D6983852220 for ; Wed, 23 Nov 2022 02:39:45 +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 4C9793857B98 for ; Wed, 23 Nov 2022 02:39:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4C9793857B98 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 _____8Axy+rDh31jWScAAA--.333S3; Wed, 23 Nov 2022 10:38:59 +0800 (CST) Received: from 5.5.5 (unknown [10.2.5.5]) by localhost.localdomain (Coremail) with SMTP id AQAAf8BxoOK9h31jy3kYAA--.63733S4; Wed, 23 Nov 2022 10:38:58 +0800 (CST) From: Xiaolin Tang To: adhemerval.zanella@linaro.org, libc-alpha@sourceware.org, caiyinyu@loongson.cn, xry111@xry111.site Cc: xuchenghua@loongson.cn, chenglulu@loongson.cn, Xiaolin Tang Subject: [PATCH 8/9] LoongArch: Add support for scalbn[f] Date: Wed, 23 Nov 2022 10:38:50 +0800 Message-Id: <20221123023851.751187-3-tangxiaolin@loongson.cn> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221123023851.751187-1-tangxiaolin@loongson.cn> References: <20221123023851.751187-1-tangxiaolin@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: AQAAf8BxoOK9h31jy3kYAA--.63733S4 X-CM-SenderInfo: pwd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_Jr 0_GrUvcSsGvfC2KfnxnUUI43ZEXa7IU8w0eJUUUUU== X-Spam-Status: No, score=-12.8 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" Add inline assembler for the scalbn functions. Passes GLIBC regression. GCC 13, LoongArch support ___builtin_scalbn{,f} with -fno-math-errno, but only "libm" can use -fno-math-errno in GLIBC, and scalbn is in libc instead of libm because __printf_fp calls it. --- sysdeps/loongarch/fpu/s_scalbn.c | 29 +++++++++++++++++++++++++++++ sysdeps/loongarch/fpu/s_scalbnf.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 sysdeps/loongarch/fpu/s_scalbn.c create mode 100644 sysdeps/loongarch/fpu/s_scalbnf.c diff --git a/sysdeps/loongarch/fpu/s_scalbn.c b/sysdeps/loongarch/fpu/s_scalbn.c new file mode 100644 index 0000000000..c03e81a31e --- /dev/null +++ b/sysdeps/loongarch/fpu/s_scalbn.c @@ -0,0 +1,29 @@ +/* scalbn(). 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 + +double +__scalbn (double x, int fn) +{ + double tmp; + asm volatile ("movgr2fr.d \t%0, %1" : "=f" (tmp) : "r" (fn)); + asm volatile ("fscaleb.d \t%0, %1, %2" : "=f" (x) : "f" (x), "f" (tmp)); + return x; +} diff --git a/sysdeps/loongarch/fpu/s_scalbnf.c b/sysdeps/loongarch/fpu/s_scalbnf.c new file mode 100644 index 0000000000..15e6428044 --- /dev/null +++ b/sysdeps/loongarch/fpu/s_scalbnf.c @@ -0,0 +1,29 @@ +/* scalbnf(). 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 + +float +__scalbnf (float x, int fn) +{ + float tmp; + asm volatile ("movgr2fr.w \t%0, %1" : "=f" (tmp) : "r" (fn)); + asm volatile ("fscaleb.s \t%0, %1, %2" : "=f" (x) : "f" (x), "f" (tmp)); + return x; +}