{"id":2175555,"url":"http://patchwork.ozlabs.org/api/1.0/patches/2175555/?format=json","project":{"id":41,"url":"http://patchwork.ozlabs.org/api/1.0/projects/41/?format=json","name":"GNU C Library","link_name":"glibc","list_id":"libc-alpha.sourceware.org","list_email":"libc-alpha@sourceware.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20251218123011.2577148-3-mengqinggang@loongson.cn>","date":"2025-12-18T12:30:08","name":"[v2,2/5] LoongArch: Add support for LA32 in sysdeps/loongarch/fpu","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"9e3ae0d6d6f4cd1e4b70a019ae0c4a75cacb5bbd","submitter":{"id":87178,"url":"http://patchwork.ozlabs.org/api/1.0/people/87178/?format=json","name":"mengqinggang","email":"mengqinggang@loongson.cn"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/glibc/patch/20251218123011.2577148-3-mengqinggang@loongson.cn/mbox/","series":[{"id":485843,"url":"http://patchwork.ozlabs.org/api/1.0/series/485843/?format=json","date":"2025-12-18T12:30:06","name":"Add support for LoongArch32","version":2,"mbox":"http://patchwork.ozlabs.org/series/485843/mbox/"}],"check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2175555/checks/","tags":{},"headers":{"Return-Path":"<libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org>","X-Original-To":["incoming@patchwork.ozlabs.org","libc-alpha@sourceware.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","libc-alpha@sourceware.org"],"Authentication-Results":["legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org\n (client-ip=38.145.34.32; helo=vm01.sourceware.org;\n envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org;\n receiver=patchwork.ozlabs.org)","sourceware.org;\n dmarc=none (p=none dis=none) header.from=loongson.cn","sourceware.org; spf=pass smtp.mailfrom=loongson.cn","server2.sourceware.org;\n arc=none smtp.remote-ip=114.242.206.163"],"Received":["from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4dX9683wVJz1y3k\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 18 Dec 2025 23:32:16 +1100 (AEDT)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id E4EC14BA2E27\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 18 Dec 2025 12:32:13 +0000 (GMT)","from mail.loongson.cn (mail.loongson.cn [114.242.206.163])\n by sourceware.org (Postfix) with ESMTP id 112D44BA2E06\n for <libc-alpha@sourceware.org>; Thu, 18 Dec 2025 12:31:50 +0000 (GMT)","from loongson.cn (unknown [10.2.6.7])\n by gateway (Coremail) with SMTP id _____8AxScIw9ENpt3YAAA--.1447S3;\n Thu, 18 Dec 2025 20:31:44 +0800 (CST)","from amd9754.. (unknown [10.2.6.7])\n by front1 (Coremail) with SMTP id qMiowJDxC8Iu9ENpM1QBAA--.2619S2;\n Thu, 18 Dec 2025 20:31:42 +0800 (CST)"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org E4EC14BA2E27","OpenDKIM Filter v2.11.0 sourceware.org 112D44BA2E06"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org 112D44BA2E06","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org 112D44BA2E06","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1766061111; cv=none;\n b=x8ZQzF5tPosjjZ1X6APAou5lF8UCDhoDJw3lzaUP47BXzCRyWFZ7+PfqN51XDmhUqsn6lv6mo3FaVXA8PTYQeliwbAfPDJJm2o8sNAFtFpvv49YZmVoNCS5abwp0wb9E4u2dfLigOA/w+cJj57WH9DqZ8ddbEffvZqV3VUTQ/h8=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1766061111; c=relaxed/simple;\n bh=HuiqLssYQz6WbDMuvqbBG34S8wbBjGcf9gQXcLj5E90=;\n h=From:To:Subject:Date:Message-Id:MIME-Version;\n b=pML7XlTlvrITD4njsmYUCUD7jov1qJOkVKphqC2tg0ahJ8ck7dB9bVKocESzFbs9vR7abcybsO4FuJv7fWFAkUPRrw+Jp505ODU+vxmOrsZqbuTwcMIi9yhC7a0jsdsVD5+z5+0xn/O8qgoS33Gc+uAR5LQmf7vb1z8NofUCCfg=","ARC-Authentication-Results":"i=1; server2.sourceware.org","From":"mengqinggang <mengqinggang@loongson.cn>","To":"libc-alpha@sourceware.org","Cc":"adhemerval.zanella@linaro.org, xuchenghua@loongson.cn,\n caiyinyu@loongson.cn, chenglulu@loongson.cn, cailulu@loongson.cn,\n xry111@xry111.site, i.swmail@xen0n.name, maskray@google.com,\n luweining@loongson.cn, hejinyang@loongson.cn, mengqinggang@loongson.cn","Subject":"[PATCH v2 2/5] LoongArch: Add support for LA32 in\n sysdeps/loongarch/fpu","Date":"Thu, 18 Dec 2025 20:30:08 +0800","Message-Id":"<20251218123011.2577148-3-mengqinggang@loongson.cn>","X-Mailer":"git-send-email 2.34.1","In-Reply-To":"<20251218123011.2577148-1-mengqinggang@loongson.cn>","References":"<20251218123011.2577148-1-mengqinggang@loongson.cn>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-CM-TRANSID":"qMiowJDxC8Iu9ENpM1QBAA--.2619S2","X-CM-SenderInfo":"5phqw15lqjwttqj6z05rqj20fqof0/","X-Coremail-Antispam":"1Uk129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7\n ZEXasCq-sGcSsGvfJ3UbIjqfuFe4nvWSU5nxnvy29KBjDU0xBIdaVrnUUvcSsGvfC2Kfnx\n nUUI43ZEXa7xR_UUUUUUUUU==","X-BeenThere":"libc-alpha@sourceware.org","X-Mailman-Version":"2.1.30","Precedence":"list","List-Id":"Libc-alpha mailing list <libc-alpha.sourceware.org>","List-Unsubscribe":"<https://sourceware.org/mailman/options/libc-alpha>,\n <mailto:libc-alpha-request@sourceware.org?subject=unsubscribe>","List-Archive":"<https://sourceware.org/pipermail/libc-alpha/>","List-Post":"<mailto:libc-alpha@sourceware.org>","List-Help":"<mailto:libc-alpha-request@sourceware.org?subject=help>","List-Subscribe":"<https://sourceware.org/mailman/listinfo/libc-alpha>,\n <mailto:libc-alpha-request@sourceware.org?subject=subscribe>","Errors-To":"libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org"},"content":"---\n sysdeps/loongarch/fpu/e_scalb.c                  | 10 ++++++++++\n sysdeps/loongarch/fpu/e_scalbf.c                 | 10 ++++++++++\n sysdeps/loongarch/fpu/math-use-builtins-llrint.h |  2 +-\n sysdeps/loongarch/fpu/math-use-builtins-logb.h   |  2 +-\n sysdeps/loongarch/fpu/math-use-builtins-lrint.h  |  2 +-\n sysdeps/loongarch/fpu/math-use-builtins-rint.h   |  2 +-\n sysdeps/loongarch/fpu/math-use-builtins-sqrt.h   | 10 ++++++++--\n sysdeps/loongarch/fpu/s_scalbn.c                 | 10 ++++++++++\n sysdeps/loongarch/fpu/s_scalbnf.c                |  8 ++++++++\n sysdeps/loongarch/fpu/w_ilogb-impl.h             |  8 ++++++++\n sysdeps/loongarch/fpu/w_ilogbf-impl.h            |  8 ++++++++\n 11 files changed, 66 insertions(+), 6 deletions(-)","diff":"diff --git a/sysdeps/loongarch/fpu/e_scalb.c b/sysdeps/loongarch/fpu/e_scalb.c\nindex 039cbd6ac8..439e38c6a7 100644\n--- a/sysdeps/loongarch/fpu/e_scalb.c\n+++ b/sysdeps/loongarch/fpu/e_scalb.c\n@@ -16,6 +16,8 @@\n    License along with the GNU C Library; if not, see\n    <https://www.gnu.org/licenses/>.  */\n \n+#ifdef __loongarch64\n+\n #define NO_MATH_REDIRECT\n #include <math.h>\n #include <libm-alias-finite.h>\n@@ -57,4 +59,12 @@ __ieee754_scalb (double x, double fn)\n \n   return x;\n }\n+\n libm_alias_finite (__ieee754_scalb, __scalb)\n+\n+#else /* #ifdef __loongarch64 */\n+\n+#include <sysdeps/generic/math-type-macros-double.h>\n+#include <math/e_scalb_template.c>\n+\n+#endif /* #ifdef __loongarch64 */\ndiff --git a/sysdeps/loongarch/fpu/e_scalbf.c b/sysdeps/loongarch/fpu/e_scalbf.c\nindex 4a4092cf40..c8196f7d6e 100644\n--- a/sysdeps/loongarch/fpu/e_scalbf.c\n+++ b/sysdeps/loongarch/fpu/e_scalbf.c\n@@ -16,6 +16,8 @@\n    License along with the GNU C Library; if not, see\n    <https://www.gnu.org/licenses/>.  */\n \n+#ifdef __loongarch64\n+\n #define NO_MATH_REDIRECT\n #include <math.h>\n #include <libm-alias-finite.h>\n@@ -57,4 +59,12 @@ __ieee754_scalbf (float x, float fn)\n \n   return x;\n }\n+\n libm_alias_finite (__ieee754_scalbf, __scalbf)\n+\n+#else /* #ifdef __loongarch64 */\n+\n+#include <sysdeps/generic/math-type-macros-float.h>\n+#include <math/e_scalb_template.c>\n+\n+#endif /* #ifdef __loongarch64 */\ndiff --git a/sysdeps/loongarch/fpu/math-use-builtins-llrint.h b/sysdeps/loongarch/fpu/math-use-builtins-llrint.h\nindex bee5910b09..82f89d41f9 100644\n--- a/sysdeps/loongarch/fpu/math-use-builtins-llrint.h\n+++ b/sysdeps/loongarch/fpu/math-use-builtins-llrint.h\n@@ -1,4 +1,4 @@\n-#if __GNUC_PREREQ (13, 0)\n+#if __GNUC_PREREQ (13, 0) && __loongarch_grlen == 64\n # define USE_LLRINT_BUILTIN 1\n # define USE_LLRINTF_BUILTIN 1\n #else\ndiff --git a/sysdeps/loongarch/fpu/math-use-builtins-logb.h b/sysdeps/loongarch/fpu/math-use-builtins-logb.h\nindex b1c3f30dc4..d8ca3d1aa2 100644\n--- a/sysdeps/loongarch/fpu/math-use-builtins-logb.h\n+++ b/sysdeps/loongarch/fpu/math-use-builtins-logb.h\n@@ -1,4 +1,4 @@\n-#if __GNUC_PREREQ (13, 0)\n+#if __GNUC_PREREQ (13, 0) && __loongarch_grlen == 64\n # define USE_LOGB_BUILTIN 1\n # define USE_LOGBF_BUILTIN 1\n #else\ndiff --git a/sysdeps/loongarch/fpu/math-use-builtins-lrint.h b/sysdeps/loongarch/fpu/math-use-builtins-lrint.h\nindex 7df8aac81f..80345fdf3f 100644\n--- a/sysdeps/loongarch/fpu/math-use-builtins-lrint.h\n+++ b/sysdeps/loongarch/fpu/math-use-builtins-lrint.h\n@@ -1,4 +1,4 @@\n-#if __GNUC_PREREQ (13, 0)\n+#if __GNUC_PREREQ (13, 0) && __loongarch_grlen == 64\n # define USE_LRINT_BUILTIN 1\n # define USE_LRINTF_BUILTIN 1\n #else\ndiff --git a/sysdeps/loongarch/fpu/math-use-builtins-rint.h b/sysdeps/loongarch/fpu/math-use-builtins-rint.h\nindex cd91482f5f..73ce3e45bc 100644\n--- a/sysdeps/loongarch/fpu/math-use-builtins-rint.h\n+++ b/sysdeps/loongarch/fpu/math-use-builtins-rint.h\n@@ -1,4 +1,4 @@\n-#if __GNUC_PREREQ (13, 0)\n+#if __GNUC_PREREQ (13, 0) && __loongarch_grlen == 64\n #  define USE_RINT_BUILTIN 1\n #  define USE_RINTF_BUILTIN 1\n #else\ndiff --git a/sysdeps/loongarch/fpu/math-use-builtins-sqrt.h b/sysdeps/loongarch/fpu/math-use-builtins-sqrt.h\nindex e94c915ba6..f031bd7536 100644\n--- a/sysdeps/loongarch/fpu/math-use-builtins-sqrt.h\n+++ b/sysdeps/loongarch/fpu/math-use-builtins-sqrt.h\n@@ -1,4 +1,10 @@\n-#define USE_SQRT_BUILTIN 1\n-#define USE_SQRTF_BUILTIN 1\n+#if __loongarch_grlen == 64\n+  #define USE_SQRT_BUILTIN 1\n+  #define USE_SQRTF_BUILTIN 1\n+#else\n+  #define USE_SQRT_BUILTIN 0\n+  #define USE_SQRTF_BUILTIN 0\n+#endif\n+\n #define USE_SQRTL_BUILTIN 0\n #define USE_SQRTF128_BUILTIN 0\ndiff --git a/sysdeps/loongarch/fpu/s_scalbn.c b/sysdeps/loongarch/fpu/s_scalbn.c\nindex 34d4cd40a0..cff78c7965 100644\n--- a/sysdeps/loongarch/fpu/s_scalbn.c\n+++ b/sysdeps/loongarch/fpu/s_scalbn.c\n@@ -16,14 +16,24 @@\n    License along with the GNU C Library; if not, see\n    <https://www.gnu.org/licenses/>.  */\n \n+#ifdef __loongarch64\n+\n #define NO_MATH_REDIRECT\n #include <math.h>\n \n+/* Return x * 2^fn.  */\n double\n __scalbn (double x, int fn)\n {\n   double tmp;\n+  /* Move fn to exp.  */\n   asm volatile (\"movgr2fr.d \\t%0, %1\" : \"=f\" (tmp) : \"r\" (fn));\n   asm volatile (\"fscaleb.d \\t%0, %1, %2\" : \"=f\" (x) : \"f\" (x), \"f\" (tmp));\n   return x;\n }\n+\n+#else /* #ifdef __loongarch64 */\n+\n+#include <sysdeps/ieee754/dbl-64/s_scalbn.c>\n+\n+#endif /* #ifdef __loongarch64 */\ndiff --git a/sysdeps/loongarch/fpu/s_scalbnf.c b/sysdeps/loongarch/fpu/s_scalbnf.c\nindex fde18cf9c1..933fae8e3d 100644\n--- a/sysdeps/loongarch/fpu/s_scalbnf.c\n+++ b/sysdeps/loongarch/fpu/s_scalbnf.c\n@@ -16,6 +16,8 @@\n    License along with the GNU C Library; if not, see\n    <https://www.gnu.org/licenses/>.  */\n \n+#ifdef __loongarch64\n+\n #define NO_MATH_REDIRECT\n #include <math.h>\n \n@@ -27,3 +29,9 @@ __scalbnf (float x, int fn)\n   asm volatile (\"fscaleb.s \\t%0, %1, %2\" : \"=f\" (x) : \"f\" (x), \"f\" (tmp));\n   return x;\n }\n+\n+#else /* #ifdef __loongarch64 */\n+\n+#include <sysdeps/ieee754/flt-32/s_scalbnf.c>\n+\n+#endif /* #ifdef __loongarch64 */\ndiff --git a/sysdeps/loongarch/fpu/w_ilogb-impl.h b/sysdeps/loongarch/fpu/w_ilogb-impl.h\nindex 1905373189..dd14ea791d 100644\n--- a/sysdeps/loongarch/fpu/w_ilogb-impl.h\n+++ b/sysdeps/loongarch/fpu/w_ilogb-impl.h\n@@ -16,6 +16,8 @@\n    License along with the GNU C Library; if not, see\n    <https://www.gnu.org/licenses/>.  */\n \n+#ifdef __loongarch64\n+\n #include <fpu_control.h>\n \n static inline RET_TYPE\n@@ -35,3 +37,9 @@ IMPL_NAME (double x)\n       return x;\n     }\n }\n+\n+#else /* #ifdef __loongarch64 */\n+\n+#include <sysdeps/ieee754/dbl-64/w_ilogb-impl.h>\n+\n+#endif /* #ifdef __loongarch64 */\ndiff --git a/sysdeps/loongarch/fpu/w_ilogbf-impl.h b/sysdeps/loongarch/fpu/w_ilogbf-impl.h\nindex 9cb4172c26..4527dbcd39 100644\n--- a/sysdeps/loongarch/fpu/w_ilogbf-impl.h\n+++ b/sysdeps/loongarch/fpu/w_ilogbf-impl.h\n@@ -16,6 +16,8 @@\n    License along with the GNU C Library; if not, see\n    <https://www.gnu.org/licenses/>.  */\n \n+#ifdef __loongarch64\n+\n #include <fpu_control.h>\n \n static inline RET_TYPE\n@@ -35,3 +37,9 @@ IMPL_NAME (float x)\n       return x;\n     }\n }\n+\n+#else /* #ifdef __loongarch64 */\n+\n+#include <sysdeps/ieee754/flt-32/w_ilogbf-impl.h>\n+\n+#endif /* #ifdef __loongarch64 */\n","prefixes":["v2","2/5"]}