From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-il1-x133.google.com (mail-il1-x133.google.com [IPv6:2607:f8b0:4864:20::133]) by sourceware.org (Postfix) with ESMTPS id 834173858C20 for ; Mon, 25 Dec 2023 12:36:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 834173858C20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 834173858C20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::133 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703507820; cv=none; b=QUCkC6OTKqU4/nJ8l54kejNn6ha+P/Qt02M/9nHR7SQIsKu09KmeZNjXi+WI/HuARgcmV8RontLokGWfXeGux7oi6LLTNsfSlXjU0mBbmNBGGWrCsmr55gOOeopl4TsOU8/Yy3tPyM89zB+WFwSpE13UfoNC/tcFzUj9rv6Mdis= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703507820; c=relaxed/simple; bh=x1DFjHZAeY32Q6g5pptEf/M4APRNwUV3Z6FJVnMJBcA=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=ZO2L7LZdhUCNYHQceRBbVWFg1CDa5cp0xm0SBo6dJ8/n+t1n7p5wYzBn47hCG4/q+x72gBUm8yUL4VJGjctsegVdFgb7v+WPpK1k6Fu28ObHxwKy42A5yYlzXFIPDvHBf0uOZZ9D4jcqn8hVjQMJyZ9OdLJ6GU8KlsEMFD9F0nU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-il1-x133.google.com with SMTP id e9e14a558f8ab-35fd902c6b5so30436065ab.3 for ; Mon, 25 Dec 2023 04:36:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703507812; x=1704112612; darn=sourceware.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=adrJAh6Wa4B5HJJpwUhAf+iQyiGoxjr4KGI5Nn6p2SY=; b=dSWlmCxsITA0EW0xqElIyhiqYsa6wkRAyDF9Hylehkku2sNF/IdbZgt2iaQyUIchnT HXhxz5Ij6nbAhC2vluBCzbBoVCqEJR55wD+BYLtq5pbMr2GirAyDZR9PmONUWkE+G96M J0HU/6KRnvoUEODJQ+sIsP4NdqVon2O9HkAgnLwI7ptBGLdpr33Q0rfZXcw4CLDl9eP6 RwSMpSth5616YDpjjvZigIFlmJpyvjq6/HAm9Ljpn6koZ31KJPSUABgBkKwJeHzMGLAV 8mJk2lyjfdH7/fyz0yJ58B95DsLmxyAe9lKsLot1cZ4gPq/BwbqbR7/xMRXfLqa5EoSN 5QqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703507812; x=1704112612; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=adrJAh6Wa4B5HJJpwUhAf+iQyiGoxjr4KGI5Nn6p2SY=; b=VtfZQL5PfCQyr5m5Pjy2K2UD5dP7NYZJBDbPfFs781BEhfeD6azYUxzN18HmC6Y91F RDn28uPTqhCnPGIOZQQWZSZtyTMEp8SfFYIkusNcqoiq5iy+DIm2BIPA0Y2XD5Nb2UM5 2O+ENmRMDe+sfL7ho6cWxee9iEYCCNtuApvcXL+tVTAX+SxuTyhynvgowcAfNTi+utBl Xu/jQJvW7l54DMloDZjoTvVRfqiA5caKXKKB8tGR/fvbobs3QooFBRrekzFvP4Dbav+g EbYB2Eg9mmrA3gf1+rym0PRr2ltV48bh74yUrhLFSQ+NX5ODEBvsRNNzKDaNGnDMX83v wWaw== X-Gm-Message-State: AOJu0YzX00Xk0E/sTExBnc8YfaujvZQGtBYfNtHmZPynpwwlCxiSlxhk SGR4kuODg6j/TvTnt8vBk1QWdpjZyle2+p51u9zdmDr7w5Y= X-Google-Smtp-Source: AGHT+IG+iLpPlJ8g6bh+RBXWFwTYF4AgDIE4SBD9sMhb6ZrbXKsQJcYwGdXbw3QkWx1wQRABoxTF2Wt8XN4qHOTi5ek= X-Received: by 2002:a05:6e02:1aa8:b0:360:3f3:8651 with SMTP id l8-20020a056e021aa800b0036003f38651mr1199123ilv.108.1703507811394; Mon, 25 Dec 2023 04:36:51 -0800 (PST) MIME-Version: 1.0 References: <20231225103548.1615-2-zhujunxian@oss.cipunited.com> <20231225103548.1615-4-zhujunxian@oss.cipunited.com> In-Reply-To: <20231225103548.1615-4-zhujunxian@oss.cipunited.com> From: YunQiang Su Date: Mon, 25 Dec 2023 20:36:41 +0800 Message-ID: Subject: Re: [PATCH 2/2] MIPS: Hard-float rounding instructions support To: Junxian Zhu Cc: Libc-alpha , rongrong@oss.cipunited.com Content-Type: multipart/alternative; boundary="000000000000f8698d060d54d1f8" X-Spam-Status: No, score=-6.4 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,HTML_MESSAGE,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: --000000000000f8698d060d54d1f8 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Junxian Zhu =E4=BA=8E 2023=E5=B9=B412=E6=9C= =8825=E6=97=A5=E5=91=A8=E4=B8=80 18:38=E5=86=99=E9=81=93=EF=BC=9A > From: Junxian Zhu > > Use hardware floating-point rounding instructions to implement roundeven, > trunc, ceil and floor. > > * sysdeps/mips/mips32/Implies: Add source path. > * sysdeps/mips/mips64/Implies: Likewise. > * sysdeps/mips/fpu/Makefile: Newfile. > * sysdeps/mips/fpu/s_ceil.c: Likewise. > * sysdeps/mips/fpu/s_ceil_fpu.S: Likewise. > * sysdeps/mips/fpu/s_ceilf.c: Likewise. > * sysdeps/mips/fpu/s_ceilf_fpu.S: Likewise. > * sysdeps/mips/fpu/s_floor.c: Likewise. > * sysdeps/mips/fpu/s_floor_fpu.S: Likewise. > * sysdeps/mips/fpu/s_floorf.c: Likewise. > * sysdeps/mips/fpu/s_floorf_fpu.S: Likewise. > * sysdeps/mips/fpu/s_roundeven.c: Likewise. > * sysdeps/mips/fpu/s_roundeven_fpu.S: Likewise. > * sysdeps/mips/fpu/s_roundevenf.c: Likewise. > * sysdeps/mips/fpu/s_roundevenf_fpu.S: Likewise. > * sysdeps/mips/fpu/s_trunc.c: Likewise. > * sysdeps/mips/fpu/s_trunc_fpu.S: Likewise. > * sysdeps/mips/fpu/s_truncf.c: Likewise. > * sysdeps/mips/fpu/s_truncf_fpu.S: Likewise. > > Signed-off-by: Rong Zhang > Signed-off-by: Junxian Zhu > --- > sysdeps/mips/fpu/Makefile | 12 ++++ > sysdeps/mips/fpu/s_ceil.c | 30 ++++++++++ > sysdeps/mips/fpu/s_ceil_fpu.S | 90 +++++++++++++++++++++++++++++ > sysdeps/mips/fpu/s_ceilf.c | 30 ++++++++++ > sysdeps/mips/fpu/s_ceilf_fpu.S | 82 ++++++++++++++++++++++++++ > sysdeps/mips/fpu/s_floor.c | 24 ++++++++ > sysdeps/mips/fpu/s_floor_fpu.S | 88 ++++++++++++++++++++++++++++ > sysdeps/mips/fpu/s_floorf.c | 24 ++++++++ > sysdeps/mips/fpu/s_floorf_fpu.S | 80 +++++++++++++++++++++++++ > sysdeps/mips/fpu/s_roundeven.c | 24 ++++++++ > sysdeps/mips/fpu/s_roundeven_fpu.S | 87 ++++++++++++++++++++++++++++ > sysdeps/mips/fpu/s_roundevenf.c | 24 ++++++++ > sysdeps/mips/fpu/s_roundevenf_fpu.S | 79 +++++++++++++++++++++++++ > sysdeps/mips/fpu/s_trunc.c | 24 ++++++++ > sysdeps/mips/fpu/s_trunc_fpu.S | 84 +++++++++++++++++++++++++++ > sysdeps/mips/fpu/s_truncf.c | 24 ++++++++ > sysdeps/mips/fpu/s_truncf_fpu.S | 76 ++++++++++++++++++++++++ > sysdeps/mips/mips32/Implies | 1 + > sysdeps/mips/mips64/Implies | 1 + > 19 files changed, 884 insertions(+) > create mode 100644 sysdeps/mips/fpu/Makefile > create mode 100644 sysdeps/mips/fpu/s_ceil.c > create mode 100644 sysdeps/mips/fpu/s_ceil_fpu.S > create mode 100644 sysdeps/mips/fpu/s_ceilf.c > create mode 100644 sysdeps/mips/fpu/s_ceilf_fpu.S > create mode 100644 sysdeps/mips/fpu/s_floor.c > create mode 100644 sysdeps/mips/fpu/s_floor_fpu.S > create mode 100644 sysdeps/mips/fpu/s_floorf.c > create mode 100644 sysdeps/mips/fpu/s_floorf_fpu.S > create mode 100644 sysdeps/mips/fpu/s_roundeven.c > create mode 100644 sysdeps/mips/fpu/s_roundeven_fpu.S > create mode 100644 sysdeps/mips/fpu/s_roundevenf.c > create mode 100644 sysdeps/mips/fpu/s_roundevenf_fpu.S > create mode 100644 sysdeps/mips/fpu/s_trunc.c > create mode 100644 sysdeps/mips/fpu/s_trunc_fpu.S > create mode 100644 sysdeps/mips/fpu/s_truncf.c > create mode 100644 sysdeps/mips/fpu/s_truncf_fpu.S > > diff --git a/sysdeps/mips/fpu/Makefile b/sysdeps/mips/fpu/Makefile > new file mode 100644 > index 0000000000..ad537d6bf1 > --- /dev/null > +++ b/sysdeps/mips/fpu/Makefile > @@ -0,0 +1,12 @@ > +ifeq ($(subdir),math) > +sysdep_routines +=3D s_floor_fpu s_floorf_fpu \ > + s_ceil_fpu s_ceilf_fpu \ > + s_trunc_fpu s_truncf_fpu \ > + s_roundeven_fpu s_roundevenf_fpu > + > +libm-sysdep_routines +=3D s_floor_fpu s_floorf_fpu \ > + s_ceil_fpu s_ceilf_fpu \ > + s_trunc_fpu s_truncf_fpu \ > + s_roundeven_fpu s_roundevenf_fpu > + > +endif > diff --git a/sysdeps/mips/fpu/s_ceil.c b/sysdeps/mips/fpu/s_ceil.c > new file mode 100644 > index 0000000000..91a90a70c5 > --- /dev/null > +++ b/sysdeps/mips/fpu/s_ceil.c > @@ -0,0 +1,30 @@ > +/* Copyright (C) 2023 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 > + . */ > + > +/* > + * ceil(x) > + * Return x rounded toward -inf to integral value > + * Method: > + * Bit twiddling. > + */ > + > +#if !((__mips_fpr =3D=3D 64) && (__mips_hard_float =3D=3D 1) > \ > + && ((__mips =3D=3D 32 && __mips_isa_rev > 1) || __mips =3D=3D 64)) > + > __mips_fpr =3D=3D 64 this condition should not be here. it means fp64. In fact your code should also support fp32 and fpxx. +# include > + > +#endif > diff --git a/sysdeps/mips/fpu/s_ceil_fpu.S b/sysdeps/mips/fpu/s_ceil_fpu.S > new file mode 100644 > index 0000000000..13d4f85ad3 > --- /dev/null > +++ b/sysdeps/mips/fpu/s_ceil_fpu.S > @@ -0,0 +1,90 @@ > +/* Copyright (C) 2023 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 > + . */ > + > +/* > + * ceil(x) > + * Return x rounded toward -inf to integral value > + * Method: > + * Bit twiddling. > + */ > + > +#if ((__mips_fpr =3D=3D 64) && (__mips_hard_float =3D=3D 1) && ((__mips = =3D=3D 32 && > __mips_isa_rev > 1) || __mips =3D=3D 64)) > +#include > +#include > +#include > + > +ENTRY(__ceil) > + .set push > + .set noreorder > + .set noat > +# $f0=3Dret, $f12=3Ddouble, a0=3Dint64/int32_h, a1=3Dint32_l, a2=3Dsign,= a3=3Dexp > +#if __mips =3D=3D 64 > + dmfc1 a0, $f12 # assign int64 > +#else > + mfhc1 a0, $f12 # assign int64 > +#endif > + cfc1 t0, $f26 > + ceil.l.d $f0, $f12 > +#if __mips =3D=3D 64 > +#if __mips_isa_rev > 1 > + dext a3, a0, 52, 11 # assign exp > +#else > + dsrl a3, a0, 52 > + andi a3, a3, 0x7ff > +#endif > +#else > + ext a3, a0, 20, 11 # assign exp > +#endif > + sltiu AT, a3, 1023 > + bnez AT, SMALL # exp < 1023 > + ctc1 t0, $f26 > + sltiu AT, a3, 1023+54 > + beqz AT, BIG # exp >=3D 1023+54 > + li AT, 0x7ff > + > + jr ra > + cvt.d.l $f0, $f0 > +BIG: > + bne AT, a3, RETURN_AS_IS # exp !=3D 0x7ff, no frac > + nop > +NAN_INF: > + jr ra > + add.d $f0, $f12, $f12 # return double + double > +SMALL: > +#if __mips =3D=3D 64 > + dsrl a2, a0, 63 > +#else > + srl a2, a0, 31 > +#endif > + beqz a2, SMALL_POSITIVE # sign =3D=3D 0 > + nop > +SMALL_NEGATIVE: # return -0.0 > + jr ra > + neg.d $f0, $f0 > +SMALL_POSITIVE: > + jr ra > + cvt.d.l $f0, $f0 > +RETURN_AS_IS: > + jr ra > + mov.d $f0, $f12 > + .set pop > + > +END (__ceil) > +libm_alias_double (__ceil, ceil) > + > +#endif > + > diff --git a/sysdeps/mips/fpu/s_ceilf.c b/sysdeps/mips/fpu/s_ceilf.c > new file mode 100644 > index 0000000000..a7f81c7539 > --- /dev/null > +++ b/sysdeps/mips/fpu/s_ceilf.c > @@ -0,0 +1,30 @@ > +/* Copyright (C) 2023 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 > + . */ > + > +/* > + * ceil(x) > + * Return x rounded toward -inf to integral value > + * Method: > + * Bit twiddling. > + */ > + > +#if !((__mips_fpr =3D=3D 64) && (__mips_hard_float =3D=3D 1) > \ > + && ((__mips =3D=3D 32 && __mips_isa_rev > 1) || __mips =3D=3D 64)) > + > +# include > + > +#endif > diff --git a/sysdeps/mips/fpu/s_ceilf_fpu.S > b/sysdeps/mips/fpu/s_ceilf_fpu.S > new file mode 100644 > index 0000000000..7952894f73 > --- /dev/null > +++ b/sysdeps/mips/fpu/s_ceilf_fpu.S > @@ -0,0 +1,82 @@ > +/* Copyright (C) 2023 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 > + . */ > + > +/* > + * ceil(x) > + * Return x rounded toward -inf to integral value > + * Method: > + * Bit twiddling. > + */ > + > +#if ((__mips_fpr =3D=3D 64) && (__mips_hard_float =3D=3D 1) && ((__mips = =3D=3D 32 && > __mips_isa_rev > 1) || __mips =3D=3D 64)) > +#include > +#include > +#include > + > +ENTRY(__ceilf) > + .set push > + .set noreorder > + .set noat > +# f0=3Dret, f12=3Dfloat, a0=3Dint32, a2=3Dsign, a3=3Dexp > + mfc1 a0, $f12 # assign int32 > + cfc1 t0, $f26 > + ceil.l.s $f0, $f12 > +#if __mips =3D=3D 64 > +#if __mips_isa_rev > 1 > + dext a3, a0, 23, 8 # assign exp > +#else > + dsrl a3, a0, 23 > + andi a3, a3, 0x1ff > +#endif > +#else > + ext a3, a0, 23, 8 # assign exp > +#endif > + sltiu AT, a3, 127 > + bnez AT, SMALL # exp < 127 > + ctc1 t0, $f26 > + sltiu AT, a3, 127+25 > + beqz AT, BIG # exp >=3D 127+25 > + li AT, 0xff > + > + jr ra > + cvt.s.l $f0, $f0 > +BIG: > + bne AT, a3, RETURN_AS_IS # exp !=3D 0xff, no frac > + nop > +NAN_INF: > + jr ra > + add.s $f0, $f12, $f12 # return double + double > +SMALL: > + srl a2, a0, 31 > + beqz a2, SMALL_POSITIVE # sign =3D=3D 0 > + nop > +SMALL_NEGATIVE: # return -0.0 > + jr ra > + neg.s $f0, $f0 > +SMALL_POSITIVE: > + jr ra > + cvt.s.l $f0, $f0 > +RETURN_AS_IS: > + jr ra > + mov.s $f0, $f12 > + .set pop > + > +END (__ceilf) > +libm_alias_float (__ceil, ceil) > + > +#endif > + > diff --git a/sysdeps/mips/fpu/s_floor.c b/sysdeps/mips/fpu/s_floor.c > new file mode 100644 > index 0000000000..4b43dc9ad9 > --- /dev/null > +++ b/sysdeps/mips/fpu/s_floor.c > @@ -0,0 +1,24 @@ > +/* Round double to integer away from zero. > + Copyright (C) 2023 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 > + . */ > + > +#if !((__mips_fpr =3D=3D 64) && (__mips_hard_float =3D=3D 1) > \ > + && ((__mips =3D=3D 32 && __mips_isa_rev > 1) || __mips =3D=3D 64)) > + > +# include > + > +#endif > diff --git a/sysdeps/mips/fpu/s_floor_fpu.S > b/sysdeps/mips/fpu/s_floor_fpu.S > new file mode 100644 > index 0000000000..fda661fd3a > --- /dev/null > +++ b/sysdeps/mips/fpu/s_floor_fpu.S > @@ -0,0 +1,88 @@ > +/* Round double to integer away from zero. > + Copyright (C) 2023 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 > + . */ > + > +#if ((__mips_fpr =3D=3D 64) && (__mips_hard_float =3D=3D 1) && ((__mips = =3D=3D 32 && > __mips_isa_rev > 1) || __mips =3D=3D 64)) > +#include > +#include > +#include > + > +ENTRY(__floor) > + .set push > + .set noreorder > + .set noat > +# f0=3Dret, f12=3Ddouble, a0=3Dint64/int32_h, a1=3Dint32_l, a2=3Dsign, a= 3=3Dexp > +#if __mips =3D=3D 64 > + dmfc1 a0, $f12 # assign int64 > +#else > + mfhc1 a0, $f12 # assign int64 > +#endif > + cfc1 t0, $f26 > + floor.l.d $f0, $f12 > +#if __mips =3D=3D 64 > +#if __mips_isa_rev > 1 > + dext a3, a0, 52, 11 # assign exp > +#else > + dsrl a3, a0, 52 > + andi a3, a3, 0x7ff > +#endif > +#else > + ext a3, a0, 20, 11 # assign exp > +#endif > + sltiu AT, a3, 1023 > + bnez AT, SMALL # exp < 1023 > + ctc1 t0, $f26 > + sltiu AT, a3, 1023+54 > + beqz AT, BIG # exp >=3D 1023+54 > + li AT, 0x7ff > + > + jr ra > + cvt.d.l $f0, $f0 > +BIG: > + bne AT, a3, RETURN_AS_IS # exp !=3D 0x7ff, no frac > + nop > +NAN_INF: > + jr ra > + add.d $f0, $f12, $f12 # return double + double > +SMALL: > +#if __mips =3D=3D 64 > + dsrl a2, a0, 63 > +#else > + srl a2, a0, 31 > +#endif > + beqz a2, SMALL_POSITIVE # sign =3D=3D 0 > + li AT, 0xbff # used by SMALL_NEGATIVE > +SMALL_NEGATIVE: > + mfhc1 t1, $f0 > + bnez t1, SMALL_POSITIVE # sign =3D=3D 0 > + nop > + > + jr ra > + neg.d $f0, $f0 > +SMALL_POSITIVE: > + jr ra > + cvt.d.l $f0, $f0 > +RETURN_AS_IS: > + jr ra > + mov.d $f0, $f12 > + .set pop > + > +END (__floor) > +libm_alias_double (__floor, floor) > + > +#endif > + > diff --git a/sysdeps/mips/fpu/s_floorf.c b/sysdeps/mips/fpu/s_floorf.c > new file mode 100644 > index 0000000000..30cfda7820 > --- /dev/null > +++ b/sysdeps/mips/fpu/s_floorf.c > @@ -0,0 +1,24 @@ > +/* Round double to integer away from zero. > + Copyright (C) 2023 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 > + . */ > + > +#if !((__mips_fpr =3D=3D 64) && (__mips_hard_float =3D=3D 1) > \ > + && ((__mips =3D=3D 32 && __mips_isa_rev > 1) || __mips =3D=3D 64)) > + > +# include > + > +#endif > diff --git a/sysdeps/mips/fpu/s_floorf_fpu.S > b/sysdeps/mips/fpu/s_floorf_fpu.S > new file mode 100644 > index 0000000000..8edd234dbc > --- /dev/null > +++ b/sysdeps/mips/fpu/s_floorf_fpu.S > @@ -0,0 +1,80 @@ > +/* Round double to integer away from zero. > + Copyright (C) 2023 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 > + . */ > + > +#if ((__mips_fpr =3D=3D 64) && (__mips_hard_float =3D=3D 1) && ((__mips = =3D=3D 32 && > __mips_isa_rev > 1) || __mips =3D=3D 64)) > +#include > +#include > +#include > + > +ENTRY(__floorf) > + .set push > + .set noreorder > + .set noat > +# f0=3Dret, f12=3Dfloat, a0=3Dint32, a2=3Dsign, a3=3Dexp > + mfc1 a0, $f12 # assign int32 > + cfc1 t0, $f26 > + floor.l.s $f0, $f12 > +#if __mips =3D=3D 64 > +#if __mips_isa_rev > 1 > + dext a3, a0, 23, 8 # assign exp > +#else > + dsrl a3, a0, 23 > + andi a3, a3, 0x1ff > +#endif > +#else > + ext a3, a0, 23, 8 # assign exp > +#endif > + sltiu AT, a3, 127 > + bnez AT, SMALL # exp < 127 > + ctc1 t0, $f26 > + sltiu AT, a3, 127+25 > + beqz AT, BIG # exp >=3D 127+25 > + li AT, 0xff > + > + jr ra > + cvt.s.l $f0, $f0 > +BIG: > + bne AT, a3, RETURN_AS_IS # exp !=3D 0xff, no frac > + nop > +NAN_INF: > + jr ra > + add.s $f0, $f12, $f12 # return double + double > +SMALL: > + srl a2, a0, 31 > + beqz a2, SMALL_POSITIVE # sign =3D=3D 0 > + li AT, 0xbff # used by SMALL_NEGATIVE > +SMALL_NEGATIVE: > + mfhc1 t1, $f0 > + bnez t1, SMALL_POSITIVE # sign =3D=3D 0 > + nop > + > + jr ra > + neg.s $f0, $f0 > +SMALL_POSITIVE: > + jr ra > + cvt.s.l $f0, $f0 > +RETURN_AS_IS: > + jr ra > + mov.s $f0, $f12 > + .set pop > + > +END (__floorf) > +libm_alias_float (__floor, floor) > + > +#endif > + > diff --git a/sysdeps/mips/fpu/s_roundeven.c > b/sysdeps/mips/fpu/s_roundeven.c > new file mode 100644 > index 0000000000..dace85a70b > --- /dev/null > +++ b/sysdeps/mips/fpu/s_roundeven.c > @@ -0,0 +1,24 @@ > +/* Round to nearest integer value, rounding halfway cases to even. > + Copyright (C) 2023 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 > + . */ > + > +#if !((__mips_fpr =3D=3D 64) && (__mips_hard_float =3D=3D 1) > \ > + && ((__mips =3D=3D 32 && __mips_isa_rev > 1) || __mips =3D=3D 64)) > + > +# include > + > +#endif > diff --git a/sysdeps/mips/fpu/s_roundeven_fpu.S > b/sysdeps/mips/fpu/s_roundeven_fpu.S > new file mode 100644 > index 0000000000..aef6434886 > --- /dev/null > +++ b/sysdeps/mips/fpu/s_roundeven_fpu.S > @@ -0,0 +1,87 @@ > +/* Round to nearest integer value, rounding halfway cases to even. > + Copyright (C) 2023 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 > + . */ > + > +#if ((__mips_fpr =3D=3D 64) && (__mips_hard_float =3D=3D 1) && ((__mips = =3D=3D 32 && > __mips_isa_rev > 1) || __mips =3D=3D 64)) > +#include > +#include > +#include > + > +ENTRY(__roundeven) > + .set push > + .set noreorder > + .set noat > +# f0=3Dret, f12=3Ddouble, a0=3Dint64/int32_h, a1=3Dint32_l, a2=3Dsign, a= 3=3Dexp > +#if __mips =3D=3D 64 > + dmfc1 a0, $f12 # assign int64 > +#else > + mfhc1 a0, $f12 # assign int64 > +#endif > + cfc1 t0, $f26 > + round.l.d $f0, $f12 > +#if __mips =3D=3D 64 > +#if __mips_isa_rev > 1 > + dext a3, a0, 52, 11 # assign exp > +#else > + dsrl a3, a0, 52 > + andi a3, a3, 0x7ff > +#endif > +#else > + ext a3, a0, 20, 11 # assign exp > +#endif > + sltiu AT, a3, 1023 > + bnez AT, SMALL # exp < 1023 > + ctc1 t0, $f26 > + sltiu AT, a3, 1023+54 > + beqz AT, BIG # exp >=3D 1023+54 > + li AT, 0x7ff > + > + jr ra > + cvt.d.l $f0, $f0 > +BIG: > + bne AT, a3, RETURN_AS_IS # exp !=3D 0x7ff, no frac > + nop > +NAN_INF: > + jr ra > + add.d $f0, $f12, $f12 # return double + double > +SMALL: > +#if __mips =3D=3D 64 > + dsrl a2, a0, 63 > +#else > + srl a2, a0, 31 > +#endif > + beqz a2, SMALL_POSITIVE # sign =3D=3D 0 > + nop > +SMALL_NEGATIVE: > + mfhc1 t1, $f0 > + bnez t1, SMALL_POSITIVE # sign =3D=3D 0 > + nop > + > + jr ra > + neg.d $f0, $f0 > +SMALL_POSITIVE: > + jr ra > + cvt.d.l $f0, $f0 > +RETURN_AS_IS: > + jr ra > + mov.d $f0, $f12 > + .set pop > + > +END (__roundeven) > +libm_alias_double (__roundeven, roundeven) > + > +#endif > diff --git a/sysdeps/mips/fpu/s_roundevenf.c > b/sysdeps/mips/fpu/s_roundevenf.c > new file mode 100644 > index 0000000000..5bb35901db > --- /dev/null > +++ b/sysdeps/mips/fpu/s_roundevenf.c > @@ -0,0 +1,24 @@ > +/* Round to nearest integer value, rounding halfway cases to even. > + Copyright (C) 2023 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 > + . */ > + > +#if !((__mips_fpr =3D=3D 64) && (__mips_hard_float =3D=3D 1) > \ > + && ((__mips =3D=3D 32 && __mips_isa_rev > 1) || __mips =3D=3D 64)) > + > +# include > + > +#endif > diff --git a/sysdeps/mips/fpu/s_roundevenf_fpu.S > b/sysdeps/mips/fpu/s_roundevenf_fpu.S > new file mode 100644 > index 0000000000..e946e50d8f > --- /dev/null > +++ b/sysdeps/mips/fpu/s_roundevenf_fpu.S > @@ -0,0 +1,79 @@ > +/* Round to nearest integer value, rounding halfway cases to even. > + Copyright (C) 2023 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 > + . */ > + > +#if ((__mips_fpr =3D=3D 64) && (__mips_hard_float =3D=3D 1) && ((__mips = =3D=3D 32 && > __mips_isa_rev > 1) || __mips =3D=3D 64)) > +#include > +#include > +#include > + > +ENTRY(__roundevenf) > + .set push > + .set noreorder > + .set noat > +# f0=3Dret, f12=3Dfloat, a0=3Dint32, a2=3Dsign, a3=3Dexp > + mfc1 a0, $f12 # assign int32 > + cfc1 t0, $f26 > + round.l.s $f0, $f12 > +#if __mips =3D=3D 64 > +#if __mips_isa_rev > 1 > + dext a3, a0, 23, 8 # assign exp > +#else > + dsrl a3, a0, 23 > + andi a3, a3, 0x1ff > +#endif > +#else > + ext a3, a0, 23, 8 # assign exp > +#endif > + sltiu AT, a3, 127 > + bnez AT, SMALL # exp < 127 > + ctc1 t0, $f26 > + sltiu AT, a3, 127+25 > + beqz AT, BIG # exp >=3D 127+25 > + li AT, 0xff > + > + jr ra > + cvt.s.l $f0, $f0 > +BIG: > + bne AT, a3, RETURN_AS_IS # exp !=3D 0xff, no frac > + nop > +NAN_INF: > + jr ra > + add.s $f0, $f12, $f12 # return double + double > +SMALL: > + srl a2, a0, 31 > + beqz a2, SMALL_POSITIVE # sign =3D=3D 0 > + nop > +SMALL_NEGATIVE: > + mfhc1 t1, $f0 > + bnez t1, SMALL_POSITIVE # sign =3D=3D 0 > + nop > + > + jr ra > + neg.s $f0, $f0 > +SMALL_POSITIVE: > + jr ra > + cvt.s.l $f0, $f0 > +RETURN_AS_IS: > + jr ra > + mov.s $f0, $f12 > + .set pop > + > +END (__roundevenf) > +libm_alias_float (__roundeven, roundeven) > + > +#endif > diff --git a/sysdeps/mips/fpu/s_trunc.c b/sysdeps/mips/fpu/s_trunc.c > new file mode 100644 > index 0000000000..3865026c70 > --- /dev/null > +++ b/sysdeps/mips/fpu/s_trunc.c > @@ -0,0 +1,24 @@ > +/* Truncate argument to nearest integral value not larger than the > argument. > + Copyright (C) 2023 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 > + . */ > + > +#if !((__mips_fpr =3D=3D 64) && (__mips_hard_float =3D=3D 1) > \ > + && ((__mips =3D=3D 32 && __mips_isa_rev > 1) || __mips =3D=3D 64)) > + > +# include > + > +#endif > diff --git a/sysdeps/mips/fpu/s_trunc_fpu.S > b/sysdeps/mips/fpu/s_trunc_fpu.S > new file mode 100644 > index 0000000000..3a7947507f > --- /dev/null > +++ b/sysdeps/mips/fpu/s_trunc_fpu.S > @@ -0,0 +1,84 @@ > +/* Truncate argument to nearest integral value not larger than the > argument. > + Copyright (C) 2023 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 > + . */ > + > +#if ((__mips_fpr =3D=3D 64) && (__mips_hard_float =3D=3D 1) && ((__mips = =3D=3D 32 && > __mips_isa_rev > 1) || __mips =3D=3D 64)) > +#include > +#include > +#include > + > +ENTRY(__trunc) > + .set push > + .set noreorder > + .set noat > +# f0=3Dret, f12=3Ddouble, a0=3Dint64/int32_h, a1=3Dint32_l, a2=3Dsign, a= 3=3Dexp > +#if __mips =3D=3D 64 > + dmfc1 a0, $f12 # assign int64 > +#else > + mfhc1 a0, $f12 # assign int64 > +#endif > + cfc1 t0, $f26 > + trunc.l.d $f0, $f12 > +#if __mips =3D=3D 64 > +#if __mips_isa_rev > 1 > + dext a3, a0, 52, 11 # assign exp > +#else > + dsrl a3, a0, 52 > + andi a3, a3, 0x7ff > +#endif > +#else > + ext a3, a0, 20, 11 # assign exp > +#endif > + sltiu AT, a3, 1023 > + bnez AT, SMALL # exp < 1023 > + ctc1 t0, $f26 > + sltiu AT, a3, 1023+54 > + beqz AT, BIG # exp >=3D 1023+54 > + li AT, 0x7ff > + > + jr ra > + cvt.d.l $f0, $f0 > +BIG: > + bne AT, a3, RETURN_AS_IS # exp !=3D 0x7ff, no frac > + nop > +NAN_INF: > + jr ra > + add.d $f0, $f12, $f12 # return double + double > +SMALL: > +#if __mips =3D=3D 64 > + dsrl a2, a0, 63 > +#else > + srl a2, a0, 31 > +#endif > + beqz a2, SMALL_POSITIVE # sign =3D=3D 0 > + nop > +SMALL_NEGATIVE: # return -0.0 > + jr ra > + neg.d $f0, $f0 > +SMALL_POSITIVE: > + jr ra > + cvt.d.l $f0, $f0 > +RETURN_AS_IS: > + jr ra > + mov.d $f0, $f12 > + .set pop > + > +END (__trunc) > +libm_alias_double (__trunc, trunc) > + > +#endif > + > diff --git a/sysdeps/mips/fpu/s_truncf.c b/sysdeps/mips/fpu/s_truncf.c > new file mode 100644 > index 0000000000..59ef17bf74 > --- /dev/null > +++ b/sysdeps/mips/fpu/s_truncf.c > @@ -0,0 +1,24 @@ > +/* Truncate argument to nearest integral value not larger than the > argument. > + Copyright (C) 2023 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 > + . */ > + > +#if !((__mips_fpr =3D=3D 64) && (__mips_hard_float =3D=3D 1) > \ > + && ((__mips =3D=3D 32 && __mips_isa_rev > 1) || __mips =3D=3D 64)) > + > +# include > + > +#endif > diff --git a/sysdeps/mips/fpu/s_truncf_fpu.S > b/sysdeps/mips/fpu/s_truncf_fpu.S > new file mode 100644 > index 0000000000..1878d88e3c > --- /dev/null > +++ b/sysdeps/mips/fpu/s_truncf_fpu.S > @@ -0,0 +1,76 @@ > +/* Truncate argument to nearest integral value not larger than the > argument. > + Copyright (C) 2023 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 > + . */ > + > +#if ((__mips_fpr =3D=3D 64) && (__mips_hard_float =3D=3D 1) && ((__mips = =3D=3D 32 && > __mips_isa_rev > 1) || __mips =3D=3D 64)) > +#include > +#include > +#include > + > +ENTRY(__truncf) > + .set push > + .set noreorder > + .set noat > +# f0=3Dret, f12=3Dfloat, a0=3Dint32, a2=3Dsign, a3=3Dexp > + mfc1 a0, $f12 # assign int32 > + cfc1 t0, $f26 > + trunc.l.s $f0, $f12 > +#if __mips =3D=3D 64 > +#if __mips_isa_rev > 1 > + dext a3, a0, 23, 8 # assign exp > +#else > + dsrl a3, a0, 23 > + andi a3, a3, 0x1ff > +#endif > +#else > + ext a3, a0, 23, 8 # assign exp > +#endif > + sltiu AT, a3, 127 > + bnez AT, SMALL # exp < 127 > + ctc1 t0, $f26 > + sltiu AT, a3, 127+25 > + beqz AT, BIG # exp >=3D 127+25 > + li AT, 0xff > + > + jr ra > + cvt.s.l $f0, $f0 > +BIG: > + bne AT, a3, RETURN_AS_IS # exp !=3D 0xff, no frac > + nop > +NAN_INF: > + jr ra > + add.s $f0, $f12, $f12 # return double + double > +SMALL: > + srl a2, a0, 31 > + beqz a2, SMALL_POSITIVE # sign =3D=3D 0 > + nop > +SMALL_NEGATIVE: # return -0.0 > + jr ra > + neg.s $f0, $f0 > +SMALL_POSITIVE: > + jr ra > + cvt.s.l $f0, $f0 > +RETURN_AS_IS: > + jr ra > + mov.s $f0, $f12 > + .set pop > + > +END (__truncf) > +libm_alias_float (__trunc, trunc) > + > +#endif > + > diff --git a/sysdeps/mips/mips32/Implies b/sysdeps/mips/mips32/Implies > index 6473f2517c..71b3678c6c 100644 > --- a/sysdeps/mips/mips32/Implies > +++ b/sysdeps/mips/mips32/Implies > @@ -1,3 +1,4 @@ > +mips/fpu > mips/ieee754 > mips > wordsize-32 > diff --git a/sysdeps/mips/mips64/Implies b/sysdeps/mips/mips64/Implies > index 826ff1541f..8885ebd564 100644 > --- a/sysdeps/mips/mips64/Implies > +++ b/sysdeps/mips/mips64/Implies > @@ -1,4 +1,5 @@ > # MIPS uses IEEE 754 floating point. > +mips/fpu > mips/ieee754 > ieee754/flt-32 > ieee754/dbl-64 > -- > 2.43.0.windows.1 > --000000000000f8698d060d54d1f8--