From patchwork Mon Jun 15 20:14:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vineet Gupta X-Patchwork-Id: 1309703 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=synopsys.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20170209 header.b=VyObDUmF; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=synopsys.com header.i=@synopsys.com header.a=rsa-sha256 header.s=mail header.b=MoaSMJQV; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49m2cb3hNfz9sSF for ; Tue, 16 Jun 2020 06:14:55 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=yiwR2BHCnUe8bdaeGnvksp/+IXRR3O+E1ZtFlvx+w6k=; b=VyObDUmFAFcGzu zqEsKRv5J6G1v5YebmTyn2C+OVFNnMAMcKVmmDNTpcGmPpe7c6srBw0rNhxbR/+I8Ac4H1vJaWrTd TqjZ1rhN/z+5LtzM2gONz2EJ7pMCfPOg6P3YPZrLc03wBL4naIcKGpg2BPqXtW9r2sTNeCjS8guHk 8u+XxtRU1Qhl7ypfkYvOSyTqtrkoVtWb5d6ON/TCMjLBqMZacycfJ/eCeZBd6d/Wy9tfViZN1xupx 9s5+SEd1hwaWpVoYekSY7OhXMwJo7n4J317tXivBSO5c+vGttRojcWoEhy2KLE/pSJkEOlgeZFtDM m75OMYQpFtny9ao5n28w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jkvVO-0003c4-1n; Mon, 15 Jun 2020 20:14:54 +0000 Received: from smtprelay-out1.synopsys.com ([149.117.87.133]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jkvVH-0003Wj-Ms for linux-snps-arc@lists.infradead.org; Mon, 15 Jun 2020 20:14:52 +0000 Received: from mailhost.synopsys.com (sv2-mailhost1.synopsys.com [10.205.2.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by smtprelay-out1.synopsys.com (Postfix) with ESMTPS id 5B1D5C0BB3; Mon, 15 Jun 2020 20:14:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1592252087; bh=nHtgyI5gXGD5NrXC2kKi63PeNzR7GBrTqrhHEgdGveY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MoaSMJQVlartzHTzeN8hR7wGZnksJdJ3Zf27XTZrNQf70Q1FQnXd7fiFKv8jAU9Vy aVsLwSLlvx7z17JYdTYUrqT23M/EMBOTuVHSMxnXKvbOOajQD3n5XTqgwdGQx1BdXi fI3u2gvjPEE8iMvErueQ4MjwZnXMOs2zMBHSQddCxdas3+PYwxCadV3EbKwtV8FrS2 U0bmWssE0Y/mqBVOSm2csJqq2Z1tfCLlfBwG6jX49+4XxqoS8asbJux04SBquvuQuQ czs9L9pnWdoSQB5xEzdUGQM6/VdzkW4yqVxYpfW58q5r/HU54PqnxSI1kmbdInvjmO 0Ad0tARQFGzXg== Received: from vineetg-Latitude-7400.internal.synopsys.com (unknown [10.13.183.89]) by mailhost.synopsys.com (Postfix) with ESMTP id C7836A00A1; Mon, 15 Jun 2020 20:14:46 +0000 (UTC) X-SNPS-Relay: synopsys.com From: Vineet Gupta To: libc-alpha@sourceware.org Subject: [PATCH v7 05/13] ARC: math soft float support Date: Mon, 15 Jun 2020 13:14:33 -0700 Message-Id: <20200615201441.31820-6-vgupta@synopsys.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200615201441.31820-1-vgupta@synopsys.com> References: <20200615201441.31820-1-vgupta@synopsys.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200615_131447_827621_6FF2B186 X-CRM114-Status: GOOD ( 15.95 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 RCVD_IN_MSPIKE_H4 RBL: Very Good reputation (+4) [149.117.87.133 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: linux-snps-arc@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on Synopsys ARC Processors List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vineet Gupta , linux-snps-arc@lists.infradead.org Sender: "linux-snps-arc" Errors-To: linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org --- sysdeps/arc/bits/fenv.h | 78 +++++++++++++++++++++++ sysdeps/arc/nofpu/Implies | 1 + sysdeps/arc/nofpu/math-tests-exceptions.h | 27 ++++++++ sysdeps/arc/nofpu/math-tests-rounding.h | 27 ++++++++ sysdeps/arc/sfp-machine.h | 70 ++++++++++++++++++++ 5 files changed, 203 insertions(+) create mode 100644 sysdeps/arc/bits/fenv.h create mode 100644 sysdeps/arc/nofpu/Implies create mode 100644 sysdeps/arc/nofpu/math-tests-exceptions.h create mode 100644 sysdeps/arc/nofpu/math-tests-rounding.h create mode 100644 sysdeps/arc/sfp-machine.h diff --git a/sysdeps/arc/bits/fenv.h b/sysdeps/arc/bits/fenv.h new file mode 100644 index 000000000000..b375641e6248 --- /dev/null +++ b/sysdeps/arc/bits/fenv.h @@ -0,0 +1,78 @@ +/* Floating point environment. ARC version. + Copyright (C) 2020 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 + . */ + +#ifndef _FENV_H +# error "Never use directly; include instead." +#endif + +enum + { + FE_INVALID = +# define FE_INVALID (0x01) + FE_INVALID, + FE_DIVBYZERO = +# define FE_DIVBYZERO (0x02) + FE_DIVBYZERO, + FE_OVERFLOW = +# define FE_OVERFLOW (0x04) + FE_OVERFLOW, + FE_UNDERFLOW = +# define FE_UNDERFLOW (0x08) + FE_UNDERFLOW, + FE_INEXACT = +# define FE_INEXACT (0x10) + FE_INEXACT + }; + +# define FE_ALL_EXCEPT \ + (FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW | FE_INEXACT) + +enum + { + FE_TOWARDZERO = +# define FE_TOWARDZERO (0x0) + FE_TOWARDZERO, + FE_TONEAREST = +# define FE_TONEAREST (0x1) /* default */ + FE_TONEAREST, + FE_UPWARD = +# define FE_UPWARD (0x2) + FE_UPWARD, + FE_DOWNWARD = +# define FE_DOWNWARD (0x3) + FE_DOWNWARD + }; + +typedef unsigned int fexcept_t; + +typedef struct +{ + unsigned int __fpcr; + unsigned int __fpsr; +} fenv_t; + +/* If the default argument is used we use this value. */ +#define FE_DFL_ENV ((const fenv_t *) -1) + +#if __GLIBC_USE (IEC_60559_BFP_EXT) +/* Type representing floating-point control modes. */ +typedef unsigned int femode_t; + +/* Default floating-point control modes. */ +# define FE_DFL_MODE ((const femode_t *) -1L) +#endif diff --git a/sysdeps/arc/nofpu/Implies b/sysdeps/arc/nofpu/Implies new file mode 100644 index 000000000000..abcbadb25f22 --- /dev/null +++ b/sysdeps/arc/nofpu/Implies @@ -0,0 +1 @@ +ieee754/soft-fp diff --git a/sysdeps/arc/nofpu/math-tests-exceptions.h b/sysdeps/arc/nofpu/math-tests-exceptions.h new file mode 100644 index 000000000000..b2a712c8c254 --- /dev/null +++ b/sysdeps/arc/nofpu/math-tests-exceptions.h @@ -0,0 +1,27 @@ +/* Configuration for math tests. Exceptions support ARC version. + Copyright (C) 2020 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 + . */ + +#ifndef ARC_NOFPU_MATH_TESTS_EXCEPTIONS_H +#define ARC_NOFPU_MATH_TESTS_EXCEPTIONS_H 1 + +/* Soft-float does not support exceptions. */ +#define EXCEPTION_TESTS_float 0 +#define EXCEPTION_TESTS_double 0 +#define EXCEPTION_TESTS_long_double 0 + +#endif diff --git a/sysdeps/arc/nofpu/math-tests-rounding.h b/sysdeps/arc/nofpu/math-tests-rounding.h new file mode 100644 index 000000000000..2f67483db20d --- /dev/null +++ b/sysdeps/arc/nofpu/math-tests-rounding.h @@ -0,0 +1,27 @@ +/* Configuration for math tests: rounding mode support. ARC version. + Copyright (C) 2020 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 + . */ + +#ifndef ARC_NOFPU_MATH_TESTS_ROUNDING_H +#define ARC_NOFPU_MATH_TESTS_ROUNDING_H 1 + +/* Soft-float only supports to-nearest rounding mode. */ +#define ROUNDING_TESTS_float(MODE) ((MODE) == FE_TONEAREST) +#define ROUNDING_TESTS_double(MODE) ((MODE) == FE_TONEAREST) +#define ROUNDING_TESTS_long_double(MODE) ((MODE) == FE_TONEAREST) + +#endif diff --git a/sysdeps/arc/sfp-machine.h b/sysdeps/arc/sfp-machine.h new file mode 100644 index 000000000000..f8c5b40d7ff8 --- /dev/null +++ b/sysdeps/arc/sfp-machine.h @@ -0,0 +1,70 @@ +/* Machine-dependent software floating-point definitions. ARC version. + Copyright (C) 2020 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 _FP_W_TYPE_SIZE 32 +#define _FP_W_TYPE unsigned long +#define _FP_WS_TYPE signed long +#define _FP_I_TYPE long + +#define _FP_MUL_MEAT_S(R,X,Y) \ + _FP_MUL_MEAT_1_wide(_FP_WFRACBITS_S,R,X,Y,umul_ppmm) +#define _FP_MUL_MEAT_D(R,X,Y) \ + _FP_MUL_MEAT_2_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm) +#define _FP_MUL_MEAT_Q(R,X,Y) \ + _FP_MUL_MEAT_4_wide(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm) + +#define _FP_MUL_MEAT_DW_S(R,X,Y) \ + _FP_MUL_MEAT_DW_1_wide(_FP_WFRACBITS_S,R,X,Y,umul_ppmm) +#define _FP_MUL_MEAT_DW_D(R,X,Y) \ + _FP_MUL_MEAT_DW_2_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm) +#define _FP_MUL_MEAT_DW_Q(R,X,Y) \ + _FP_MUL_MEAT_DW_4_wide(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm) + +#define _FP_DIV_MEAT_S(R,X,Y) _FP_DIV_MEAT_1_loop(S,R,X,Y) +#define _FP_DIV_MEAT_D(R,X,Y) _FP_DIV_MEAT_2_udiv(D,R,X,Y) +#define _FP_DIV_MEAT_Q(R,X,Y) _FP_DIV_MEAT_4_udiv(Q,R,X,Y) + +#define _FP_NANFRAC_S ((_FP_QNANBIT_S << 1) - 1) +#define _FP_NANFRAC_D ((_FP_QNANBIT_D << 1) - 1), -1 +#define _FP_NANFRAC_Q ((_FP_QNANBIT_Q << 1) - 1), -1, -1, -1 +#define _FP_NANSIGN_S 0 +#define _FP_NANSIGN_D 0 +#define _FP_NANSIGN_Q 0 + +#define _FP_KEEPNANFRACP 1 +#define _FP_QNANNEGATEDP 0 + +/* This is arbitrarily taken from the PowerPC version. */ +#define _FP_CHOOSENAN(fs, wc, R, X, Y, OP) \ + do { \ + if ((_FP_FRAC_HIGH_RAW_##fs(X) & _FP_QNANBIT_##fs) \ + && !(_FP_FRAC_HIGH_RAW_##fs(Y) & _FP_QNANBIT_##fs)) \ + { \ + R##_s = Y##_s; \ + _FP_FRAC_COPY_##wc(R,Y); \ + } \ + else \ + { \ + R##_s = X##_s; \ + _FP_FRAC_COPY_##wc(R,X); \ + } \ + R##_c = FP_CLS_NAN; \ + } while (0) + +#define _FP_TININESS_AFTER_ROUNDING 1