From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7891) id 097323854566; Tue, 29 Nov 2022 08:01:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 097323854566 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1669708884; bh=8VCUk/WjxaMFuTTOHxn+rBbF1Y5dJUtOYu6SvezrjxI=; h=From:To:Subject:Date:From; b=k/e6If5Njmg+S9JgXph5o+r8iNzKdHZd6faRteGNpuuT3zGwlbHDcKXbk366+hpl2 mHFVv0M1kXqBz6vqEJnOtLUnDwtgcBXfxuCLhFu4zWnmpK/umJ4/OuB9X4vmbW0O/T Tx6vwOiHwlivmSq5Pt+J15wG/UODAP4xpFh16Z3g= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Yinyu Cai To: glibc-cvs@sourceware.org Subject: [glibc] LoongArch: Add support for scalbn[f] X-Act-Checkin: glibc X-Git-Author: Xiaolin Tang X-Git-Refname: refs/heads/master X-Git-Oldrev: 13c549f49705d10105b16706124077e07068a936 X-Git-Newrev: e3d9ca4e9474ed4f9b6a9879867f14fea6e2bee9 Message-Id: <20221129080124.097323854566@sourceware.org> Date: Tue, 29 Nov 2022 08:01:24 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=e3d9ca4e9474ed4f9b6a9879867f14fea6e2bee9 commit e3d9ca4e9474ed4f9b6a9879867f14fea6e2bee9 Author: Xiaolin Tang Date: Wed Nov 23 11:49:24 2022 +0800 LoongArch: Add support for scalbn[f] 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. Diff: --- sysdeps/loongarch/fpu/s_scalbn.c | 29 +++++++++++++++++++++++++++++ sysdeps/loongarch/fpu/s_scalbnf.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) 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; +}