From patchwork Tue Feb 14 08:57:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xi Ruoyao X-Patchwork-Id: 64947 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6D7573858409 for ; Tue, 14 Feb 2023 08:57:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6D7573858409 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676365077; bh=Qjd9ciVEyOp7QWXzwXKF2MlOa6F2vJruiZ/H9VNmClE=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=fpBjcnrP0vUqzYO+p8GJ8q+/BC/Dk7ym8V+F5XSPTOYu18KL20KHMdEYnrFipgztS 3Fb9MSQRggdmX4gqLtMLBWjtGryeTO5+16VqQYhpNFsxKZJuViRX27ohPnFqggbwyB rSQzt7IszEYF54WEO5hIvum+XVdnUeJx3/aiV8P8= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from xry111.site (xry111.site [89.208.246.23]) by sourceware.org (Postfix) with ESMTPS id 292543858409 for ; Tue, 14 Feb 2023 08:57:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 292543858409 Received: from stargazer.. (unknown [IPv6:240e:456:1030:5cf6:bedf:6bc:7e29:f3e5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) (Authenticated sender: xry111@xry111.site) by xry111.site (Postfix) with ESMTPSA id 0C2856612C; Tue, 14 Feb 2023 03:57:29 -0500 (EST) To: libc-alpha@sourceware.org Cc: caiyinyu , Wang Xuerui , Xi Ruoyao Subject: [PATCH] LoongArch: Add math-barriers.h Date: Tue, 14 Feb 2023 16:57:13 +0800 Message-Id: <20230214085713.44338-1-xry111@xry111.site> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 X-Spam-Status: No, score=-8.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, LIKELY_SPAM_FROM, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Xi Ruoyao via Libc-alpha From: Xi Ruoyao Reply-To: Xi Ruoyao Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" This patch implements the LoongArch specific math barriers in order to omit the store and load from stack if possible. Signed-off-by: Xi Ruoyao Reviewed-by: Adhemerval Zanella --- sysdeps/loongarch/fpu/math-barriers.h | 28 +++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 sysdeps/loongarch/fpu/math-barriers.h diff --git a/sysdeps/loongarch/fpu/math-barriers.h b/sysdeps/loongarch/fpu/math-barriers.h new file mode 100644 index 0000000000..3e977e43a6 --- /dev/null +++ b/sysdeps/loongarch/fpu/math-barriers.h @@ -0,0 +1,28 @@ +/* Control when floating-point expressions are evaluated. LoongArch version. + 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 + . */ + +#ifndef _LOONGARCH_MATH_BARRIERS_H +#define _LOONGARCH_MATH_BARRIERS_H 1 + +/* Generic code forces values to memory; we don't need to do that. */ +#define math_opt_barrier(x) \ + ({ __typeof (x) __x = (x); __asm ("" : "+frm" (__x)); __x; }) +#define math_force_eval(x) \ + ({ __typeof (x) __x = (x); __asm __volatile__ ("" : : "frm" (__x)); }) + +#endif /* math-barriers.h */