13 Star 16 Fork 152

src-openEuler/glibc

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0014-Sw64-float128-Implementation.patch 22.83 KB
一键复制 编辑 原始数据 按行查看 历史
swcompiler 提交于 2024-12-16 14:02 . Sw64: Add Sw64 ISA support
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725
From 08fc38c7c5d764a69899f2305a0b5211675de02c Mon Sep 17 00:00:00 2001
From: swcompiler <lc@wxiat.com>
Date: Fri, 29 Nov 2024 14:24:53 +0800
Subject: [PATCH 14/23] Sw64: float128 Implementation
---
sysdeps/sw_64/e_sqrtl.c | 48 +++++++++++++++++++++++
sysdeps/sw_64/ots_add.c | 40 +++++++++++++++++++
sysdeps/sw_64/ots_cmp.c | 63 ++++++++++++++++++++++++++++++
sysdeps/sw_64/ots_cmpe.c | 78 ++++++++++++++++++++++++++++++++++++++
sysdeps/sw_64/ots_cvtqux.c | 39 +++++++++++++++++++
sysdeps/sw_64/ots_cvtqx.c | 38 +++++++++++++++++++
sysdeps/sw_64/ots_cvttx.c | 47 +++++++++++++++++++++++
sysdeps/sw_64/ots_cvtxq.c | 41 ++++++++++++++++++++
sysdeps/sw_64/ots_cvtxt.c | 43 +++++++++++++++++++++
sysdeps/sw_64/ots_div.c | 40 +++++++++++++++++++
sysdeps/sw_64/ots_mul.c | 40 +++++++++++++++++++
sysdeps/sw_64/ots_nintxq.c | 53 ++++++++++++++++++++++++++
sysdeps/sw_64/ots_sub.c | 40 +++++++++++++++++++
13 files changed, 610 insertions(+)
create mode 100644 sysdeps/sw_64/e_sqrtl.c
create mode 100644 sysdeps/sw_64/ots_add.c
create mode 100644 sysdeps/sw_64/ots_cmp.c
create mode 100644 sysdeps/sw_64/ots_cmpe.c
create mode 100644 sysdeps/sw_64/ots_cvtqux.c
create mode 100644 sysdeps/sw_64/ots_cvtqx.c
create mode 100644 sysdeps/sw_64/ots_cvttx.c
create mode 100644 sysdeps/sw_64/ots_cvtxq.c
create mode 100644 sysdeps/sw_64/ots_cvtxt.c
create mode 100644 sysdeps/sw_64/ots_div.c
create mode 100644 sysdeps/sw_64/ots_mul.c
create mode 100644 sysdeps/sw_64/ots_nintxq.c
create mode 100644 sysdeps/sw_64/ots_sub.c
diff --git a/sysdeps/sw_64/e_sqrtl.c b/sysdeps/sw_64/e_sqrtl.c
new file mode 100644
index 00000000..13cc1f0e
--- /dev/null
+++ b/sysdeps/sw_64/e_sqrtl.c
@@ -0,0 +1,48 @@
+/* long double square root in software floating-point emulation.
+ Copyright (C) 1997-2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com) and
+ Jakub Jelinek (jj@ultra.linux.cz).
+
+ 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
+ <https://www.gnu.org/licenses/>. */
+
+#include <stdlib.h>
+#include <soft-fp.h>
+#include <quad.h>
+#include <shlib-compat.h>
+
+long double
+__ieee754_sqrtl (const long double a)
+{
+ FP_DECL_EX;
+ FP_DECL_Q (A);
+ FP_DECL_Q (C);
+ long double c;
+ long _round = 4; /* dynamic rounding */
+
+ FP_INIT_ROUNDMODE;
+ FP_UNPACK_Q (A, a);
+ FP_SQRT_Q (C, A);
+ FP_PACK_Q (c, C);
+ FP_HANDLE_EXCEPTIONS;
+ return c;
+}
+
+/* ??? We forgot to add this symbol in 2.15. Getting this into 2.18 isn't as
+ straight-forward as just adding the alias, since a generic Versions file
+ includes the 2.15 version and the linker uses the first one it sees. */
+#if SHLIB_COMPAT (libm, GLIBC_2_15, GLIBC_2_18)
+compat_symbol (libm, __ieee754_sqrtl, __sqrtl_finite, GLIBC_2_18);
+#endif
diff --git a/sysdeps/sw_64/ots_add.c b/sysdeps/sw_64/ots_add.c
new file mode 100644
index 00000000..4e3f160c
--- /dev/null
+++ b/sysdeps/sw_64/ots_add.c
@@ -0,0 +1,40 @@
+/* Software floating-point emulation: addition.
+ Copyright (C) 1997-2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com) and
+ Jakub Jelinek (jj@ultra.linux.cz).
+
+ 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
+ <http://www.gnu.org/licenses/>. */
+
+#include "local-soft-fp.h"
+
+void
+_OtsAddX (long al, long ah, long bl, long bh, long _round)
+{
+ FP_DECL_EX;
+ FP_DECL_Q (A);
+ FP_DECL_Q (B);
+ FP_DECL_Q (C);
+ AXP_DECL_RETURN_Q (c);
+
+ FP_INIT_ROUNDMODE;
+ AXP_UNPACK_SEMIRAW_Q (A, a);
+ AXP_UNPACK_SEMIRAW_Q (B, b);
+ FP_ADD_Q (C, A, B);
+ AXP_PACK_SEMIRAW_Q (c, C);
+ FP_HANDLE_EXCEPTIONS;
+
+ AXP_RETURN_Q (c);
+}
diff --git a/sysdeps/sw_64/ots_cmp.c b/sysdeps/sw_64/ots_cmp.c
new file mode 100644
index 00000000..42766f23
--- /dev/null
+++ b/sysdeps/sw_64/ots_cmp.c
@@ -0,0 +1,63 @@
+/* Software floating-point emulation: comparison.
+ Copyright (C) 1997-2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com) and
+ Jakub Jelinek (jj@ultra.linux.cz).
+
+ 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
+ <http://www.gnu.org/licenses/>. */
+
+#include "local-soft-fp.h"
+
+static long
+internal_equality (long al, long ah, long bl, long bh, long neq)
+{
+ FP_DECL_EX;
+ FP_DECL_Q (A);
+ FP_DECL_Q (B);
+ long r;
+
+ AXP_UNPACK_RAW_Q (A, a);
+ AXP_UNPACK_RAW_Q (B, b);
+
+ if ((A_e == _FP_EXPMAX_Q && !_FP_FRAC_ZEROP_2 (A))
+ || (B_e == _FP_EXPMAX_Q && !_FP_FRAC_ZEROP_2 (B)))
+ {
+ /* EQ and NE signal invalid operation only if either operand is SNaN. */
+ if (FP_ISSIGNAN_Q (A) || FP_ISSIGNAN_Q (B))
+ {
+ FP_SET_EXCEPTION (FP_EX_INVALID);
+ FP_HANDLE_EXCEPTIONS;
+ }
+ return -1;
+ }
+
+ r = (A_e == B_e && _FP_FRAC_EQ_2 (A, B)
+ && (A_s == B_s || (!A_e && _FP_FRAC_ZEROP_2 (A))));
+ r ^= neq;
+
+ return r;
+}
+
+long
+_OtsEqlX (long al, long ah, long bl, long bh)
+{
+ return internal_equality (al, ah, bl, bh, 0);
+}
+
+long
+_OtsNeqX (long al, long ah, long bl, long bh)
+{
+ return internal_equality (al, ah, bl, bh, 1);
+}
diff --git a/sysdeps/sw_64/ots_cmpe.c b/sysdeps/sw_64/ots_cmpe.c
new file mode 100644
index 00000000..7604e94e
--- /dev/null
+++ b/sysdeps/sw_64/ots_cmpe.c
@@ -0,0 +1,78 @@
+/* Software floating-point emulation: comparison.
+ Copyright (C) 1997-2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com) and
+ Jakub Jelinek (jj@ultra.linux.cz).
+
+ 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
+ <http://www.gnu.org/licenses/>. */
+
+#include "local-soft-fp.h"
+
+static long
+internal_compare (long al, long ah, long bl, long bh)
+{
+ FP_DECL_EX;
+ FP_DECL_Q (A);
+ FP_DECL_Q (B);
+ long r;
+
+ AXP_UNPACK_RAW_Q (A, a);
+ AXP_UNPACK_RAW_Q (B, b);
+ FP_CMP_Q (r, A, B, 2, 2);
+
+ FP_HANDLE_EXCEPTIONS;
+
+ return r;
+}
+
+long
+_OtsLssX (long al, long ah, long bl, long bh)
+{
+ long r = internal_compare (al, ah, bl, bh);
+ if (r == 2)
+ return -1;
+ else
+ return r < 0;
+}
+
+long
+_OtsLeqX (long al, long ah, long bl, long bh)
+{
+ long r = internal_compare (al, ah, bl, bh);
+ if (r == 2)
+ return -1;
+ else
+ return r <= 0;
+}
+
+long
+_OtsGtrX (long al, long ah, long bl, long bh)
+{
+ long r = internal_compare (al, ah, bl, bh);
+ if (r == 2)
+ return -1;
+ else
+ return r > 0;
+}
+
+long
+_OtsGeqX (long al, long ah, long bl, long bh)
+{
+ long r = internal_compare (al, ah, bl, bh);
+ if (r == 2)
+ return -1;
+ else
+ return r >= 0;
+}
diff --git a/sysdeps/sw_64/ots_cvtqux.c b/sysdeps/sw_64/ots_cvtqux.c
new file mode 100644
index 00000000..283bbe19
--- /dev/null
+++ b/sysdeps/sw_64/ots_cvtqux.c
@@ -0,0 +1,39 @@
+/* Software floating-point emulation: unsigned integer to float conversion.
+ Copyright (C) 1997-2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com) and
+ Jakub Jelinek (jj@ultra.linux.cz).
+
+ 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
+ <http://www.gnu.org/licenses/>. */
+
+#include "local-soft-fp.h"
+
+/* Should never actually be used, since we've more bits of precision
+ than the incomming long, but needed for linkage. */
+#undef FP_ROUNDMODE
+#define FP_ROUNDMODE FP_RND_ZERO
+
+void
+_OtsCvtQUX (unsigned long a)
+{
+ FP_DECL_EX;
+ FP_DECL_Q (C);
+ AXP_DECL_RETURN_Q (c);
+
+ FP_FROM_INT_Q (C, a, 64, unsigned long);
+ AXP_PACK_RAW_Q (c, C);
+
+ AXP_RETURN_Q (c);
+}
diff --git a/sysdeps/sw_64/ots_cvtqx.c b/sysdeps/sw_64/ots_cvtqx.c
new file mode 100644
index 00000000..dd51eb27
--- /dev/null
+++ b/sysdeps/sw_64/ots_cvtqx.c
@@ -0,0 +1,38 @@
+/* Software floating-point emulation: signed integer to float conversion.
+ Copyright (C) 1997-2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com) and
+ Jakub Jelinek (jj@ultra.linux.cz).
+
+ 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
+ <http://www.gnu.org/licenses/>. */
+
+#include "local-soft-fp.h"
+
+/* Should never actually be used, since we've more bits of precision
+ than the incomming long, but needed for linkage. */
+#undef FP_ROUNDMODE
+#define FP_ROUNDMODE FP_RND_ZERO
+
+void
+_OtsCvtQX (long a)
+{
+ FP_DECL_EX;
+ FP_DECL_Q (C);
+ AXP_DECL_RETURN_Q (c);
+
+ FP_FROM_INT_Q (C, a, 64, unsigned long);
+ AXP_PACK_RAW_Q (c, C);
+ AXP_RETURN_Q (c);
+}
diff --git a/sysdeps/sw_64/ots_cvttx.c b/sysdeps/sw_64/ots_cvttx.c
new file mode 100644
index 00000000..4defb56d
--- /dev/null
+++ b/sysdeps/sw_64/ots_cvttx.c
@@ -0,0 +1,47 @@
+/* Software floating-point emulation: floating point extension.
+ Copyright (C) 1997-2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com) and
+ Jakub Jelinek (jj@ultra.linux.cz).
+
+ 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
+ <https://www.gnu.org/licenses/>. */
+
+#include "local-soft-fp.h"
+#include "double.h"
+
+/* Should never actually be used, since we're extending, but needed
+ for linkage. */
+#undef FP_ROUNDMODE
+#define FP_ROUNDMODE FP_RND_ZERO
+
+void
+_OtsConvertFloatTX (double a)
+{
+ FP_DECL_EX;
+ FP_DECL_D (A);
+ FP_DECL_Q (C);
+ AXP_DECL_RETURN_Q (c);
+
+ FP_UNPACK_RAW_D (A, a);
+#if _FP_W_TYPE_SIZE < 64
+ FP_EXTEND (Q, D, 4, 2, C, A);
+#else
+ FP_EXTEND (Q, D, 2, 1, C, A);
+#endif
+ AXP_PACK_RAW_Q (c, C);
+ FP_HANDLE_EXCEPTIONS;
+
+ AXP_RETURN_Q (c);
+}
diff --git a/sysdeps/sw_64/ots_cvtxq.c b/sysdeps/sw_64/ots_cvtxq.c
new file mode 100644
index 00000000..e88adf14
--- /dev/null
+++ b/sysdeps/sw_64/ots_cvtxq.c
@@ -0,0 +1,41 @@
+/* Software floating-point emulation: float to integer conversion.
+ Copyright (C) 1997-2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com) and
+ Jakub Jelinek (jj@ultra.linux.cz).
+
+ 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
+ <http://www.gnu.org/licenses/>. */
+
+#include "local-soft-fp.h"
+
+long
+_OtsCvtXQ (long al, long ah, long _round)
+{
+ FP_DECL_EX;
+ FP_DECL_Q (A);
+ unsigned long r;
+ long s;
+
+ /* If bit 3 is set, then integer overflow detection is requested. */
+ s = _round & 8 ? 1 : -1;
+ _round = _round & 3;
+
+ FP_INIT_ROUNDMODE;
+ AXP_UNPACK_RAW_Q (A, a);
+ FP_TO_INT_Q (r, A, 64, s);
+ FP_HANDLE_EXCEPTIONS;
+
+ return r;
+}
diff --git a/sysdeps/sw_64/ots_cvtxt.c b/sysdeps/sw_64/ots_cvtxt.c
new file mode 100644
index 00000000..a20db3a7
--- /dev/null
+++ b/sysdeps/sw_64/ots_cvtxt.c
@@ -0,0 +1,43 @@
+/* Software floating-point emulation: floating point truncation.
+ Copyright (C) 1997-2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com) and
+ Jakub Jelinek (jj@ultra.linux.cz).
+
+ 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
+ <https://www.gnu.org/licenses/>. */
+
+#include "local-soft-fp.h"
+#include "double.h"
+
+double
+_OtsConvertFloatXT (long al, long ah, long _round)
+{
+ FP_DECL_EX;
+ FP_DECL_Q (A);
+ FP_DECL_D (R);
+ double r;
+
+ FP_INIT_ROUNDMODE;
+ AXP_UNPACK_SEMIRAW_Q (A, a);
+#if _FP_W_TYPE_SIZE < 64
+ FP_TRUNC (D, Q, 2, 4, R, A);
+#else
+ FP_TRUNC (D, Q, 1, 2, R, A);
+#endif
+ FP_PACK_SEMIRAW_D (r, R);
+ FP_HANDLE_EXCEPTIONS;
+
+ return r;
+}
diff --git a/sysdeps/sw_64/ots_div.c b/sysdeps/sw_64/ots_div.c
new file mode 100644
index 00000000..af0e7d60
--- /dev/null
+++ b/sysdeps/sw_64/ots_div.c
@@ -0,0 +1,40 @@
+/* Software floating-point emulation: division.
+ Copyright (C) 1997-2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com) and
+ Jakub Jelinek (jj@ultra.linux.cz).
+
+ 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
+ <http://www.gnu.org/licenses/>. */
+
+#include "local-soft-fp.h"
+
+void
+_OtsDivX (long al, long ah, long bl, long bh, long _round)
+{
+ FP_DECL_EX;
+ FP_DECL_Q (A);
+ FP_DECL_Q (B);
+ FP_DECL_Q (C);
+ AXP_DECL_RETURN_Q (c);
+
+ FP_INIT_ROUNDMODE;
+ AXP_UNPACK_Q (A, a);
+ AXP_UNPACK_Q (B, b);
+ FP_DIV_Q (C, A, B);
+ AXP_PACK_Q (c, C);
+ FP_HANDLE_EXCEPTIONS;
+
+ AXP_RETURN_Q (c);
+}
diff --git a/sysdeps/sw_64/ots_mul.c b/sysdeps/sw_64/ots_mul.c
new file mode 100644
index 00000000..41dba23d
--- /dev/null
+++ b/sysdeps/sw_64/ots_mul.c
@@ -0,0 +1,40 @@
+/* Software floating-point emulation: multiplication.
+ Copyright (C) 1997-2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com) and
+ Jakub Jelinek (jj@ultra.linux.cz).
+
+ 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
+ <http://www.gnu.org/licenses/>. */
+
+#include "local-soft-fp.h"
+
+void
+_OtsMulX (long al, long ah, long bl, long bh, long _round)
+{
+ FP_DECL_EX;
+ FP_DECL_Q (A);
+ FP_DECL_Q (B);
+ FP_DECL_Q (C);
+ AXP_DECL_RETURN_Q (c);
+
+ FP_INIT_ROUNDMODE;
+ AXP_UNPACK_Q (A, a);
+ AXP_UNPACK_Q (B, b);
+ FP_MUL_Q (C, A, B);
+ AXP_PACK_Q (c, C);
+ FP_HANDLE_EXCEPTIONS;
+
+ AXP_RETURN_Q (c);
+}
diff --git a/sysdeps/sw_64/ots_nintxq.c b/sysdeps/sw_64/ots_nintxq.c
new file mode 100644
index 00000000..ac4c610a
--- /dev/null
+++ b/sysdeps/sw_64/ots_nintxq.c
@@ -0,0 +1,53 @@
+/* Software floating-point emulation: convert to fortran nearest.
+ Copyright (C) 1997-2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com) and
+ Jakub Jelinek (jj@ultra.linux.cz).
+
+ 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
+ <http://www.gnu.org/licenses/>. */
+
+#include "local-soft-fp.h"
+
+long
+_OtsNintXQ (long al, long ah, long _round)
+{
+ FP_DECL_EX;
+ FP_DECL_Q (A);
+ FP_DECL_Q (B);
+ FP_DECL_Q (C);
+ unsigned long r;
+ long s;
+
+ /* If bit 3 is set, then integer overflow detection is requested. */
+ s = _round & 8 ? 1 : -1;
+ _round = _round & 3;
+
+ FP_INIT_ROUNDMODE;
+ AXP_UNPACK_SEMIRAW_Q (A, a);
+
+ /* Build 0.5 * sign(A) */
+ B_e = _FP_EXPBIAS_Q;
+ __FP_FRAC_SET_2 (B, 0, 0);
+ B_s = A_s;
+
+ FP_ADD_Q (C, A, B);
+ _FP_FRAC_SRL_2 (C, _FP_WORKBITS);
+ _FP_FRAC_HIGH_RAW_Q (C) &= ~(_FP_W_TYPE) _FP_IMPLBIT_Q;
+ FP_TO_INT_Q (r, C, 64, s);
+ if (s > 0 && (_fex &= FP_EX_INVALID))
+ FP_HANDLE_EXCEPTIONS;
+
+ return r;
+}
diff --git a/sysdeps/sw_64/ots_sub.c b/sysdeps/sw_64/ots_sub.c
new file mode 100644
index 00000000..c0bc573e
--- /dev/null
+++ b/sysdeps/sw_64/ots_sub.c
@@ -0,0 +1,40 @@
+/* Software floating-point emulation: subtraction.
+ Copyright (C) 1997-2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com) and
+ Jakub Jelinek (jj@ultra.linux.cz).
+
+ 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
+ <http://www.gnu.org/licenses/>. */
+
+#include "local-soft-fp.h"
+
+void
+_OtsSubX (long al, long ah, long bl, long bh, long _round)
+{
+ FP_DECL_EX;
+ FP_DECL_Q (A);
+ FP_DECL_Q (B);
+ FP_DECL_Q (C);
+ AXP_DECL_RETURN_Q (c);
+
+ FP_INIT_ROUNDMODE;
+ AXP_UNPACK_SEMIRAW_Q (A, a);
+ AXP_UNPACK_SEMIRAW_Q (B, b);
+ FP_SUB_Q (C, A, B);
+ AXP_PACK_SEMIRAW_Q (c, C);
+ FP_HANDLE_EXCEPTIONS;
+
+ AXP_RETURN_Q (c);
+}
--
2.25.1
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/glibc.git
git@gitee.com:src-openeuler/glibc.git
src-openeuler
glibc
glibc
master

搜索帮助