From patchwork Sat Feb 3 15:53:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John David Anglin X-Patchwork-Id: 1894912 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TRxyd6B98z23gM for ; Sun, 4 Feb 2024 02:54:01 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A338E3857B88 for ; Sat, 3 Feb 2024 15:53:59 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from dellerweb.de (unknown [IPv6:2a02:c207:3003:236::1]) by sourceware.org (Postfix) with ESMTPS id 129A3385840E for ; Sat, 3 Feb 2024 15:53:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 129A3385840E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=parisc-linux.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=parisc-linux.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 129A3385840E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a02:c207:3003:236::1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706975621; cv=none; b=M5GDoypl0oCFl+iDLfRrIGLFpDBNKchm5k/S5jVzk+nzuV8vV8j7sSYje4NXAviaI3B065jUaTdMP89VVlv9mg8saOMSxfgXRSs8SFOfwiHW788a4z6sCnSMVKILcOsXFbv7pJPrt/mgQt9SVKMWKCwtD3PAb7NC3gl3OZVEzm0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706975621; c=relaxed/simple; bh=LLbVmSc6J/zj1fyirBt4lOJpOz9ErwYPSjQEgn/exM8=; h=Date:From:To:Subject:Message-ID:MIME-Version; b=G8YSbLeVgHZ/7KKK9VO84qH6krzkUQdzlWVhulG45YaKvyfKGTtYf6i3bnEbWN0ZA1IIGIV8UGbIlcNlxGRIPuOR+QIpWoBsWEcUb/S2CbOJfPE0GXo/9RCbS6Fhtg5shPAZsdvesNWMZb7q9Joe/EuXE+DJVuQc18qMg4aai18= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from mx3210.localdomain (unknown [142.126.114.79]) by dellerweb.de (Postfix) with ESMTPSA id 3302116000F8; Sat, 3 Feb 2024 16:53:37 +0100 (CET) Received: by mx3210.localdomain (Postfix, from userid 1000) id 36E6D22012D; Sat, 3 Feb 2024 15:53:34 +0000 (UTC) Date: Sat, 3 Feb 2024 15:53:33 +0000 From: John David Anglin To: GCC Patches Subject: [committed] libatomic: Provide FPU exception defines for hppa Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_SHORT, SPF_HELO_PASS, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Tested on hppa64-hp-hpux11.11. Committed to trunk. Dave --- libatomic: Provide FPU exception defines for hppa The exception defines in do not match the exception bits in the FPU status register on hppa-linux and hppa64-hpux11.11. On linux, they match the trap enable bits. On 64-bit hpux, they match the exception bits for IA64. The IA64 bits are in a different order and location than HPPA. HP uses table look ups to reorder the bits in code to test and raise exceptions. All the architectures that I looked at just pass the FPU status register to __atomic_feraiseexcept(). The simplest approach for hppa is to define FE_INEXACT, etc, to match the status register and not include . 2024-02-03 John David Anglin libatomic/ChangeLog: PR target/59778 * configure.tgt (hppa*): Set ARCH. * config/pa/fenv.c: New file. diff --git a/libatomic/config/pa/fenv.c b/libatomic/config/pa/fenv.c new file mode 100644 index 00000000000..232e8416ffd --- /dev/null +++ b/libatomic/config/pa/fenv.c @@ -0,0 +1,74 @@ +/* Copyright (C) 2012-2024 Free Software Foundation, Inc. + + This file is part of the GNU Atomic Library (libatomic). + + Libatomic is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + Libatomic 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 General Public License for + more details. + + Under Section 7 of GPL version 3, you are granted additional + permissions described in the GCC Runtime Library Exception, version + 3.1, as published by the Free Software Foundation. + + You should have received a copy of the GNU General Public License and + a copy of the GCC Runtime Library Exception along with this program; + see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + . */ + +#include "libatomic_i.h" + +#define FE_INEXACT (1<<27) +#define FE_UNDERFLOW (1<<28) +#define FE_OVERFLOW (1<<29) +#define FE_DIVBYZERO (1<<30) +#define FE_INVALID (1<<31) + +/* Raise the supported floating-point exceptions from EXCEPTS. Other + bits in EXCEPTS are ignored. */ + +void +__atomic_feraiseexcept (int excepts __attribute__ ((unused))) +{ + volatile float r __attribute__ ((unused)); +#ifdef FE_INVALID + if (excepts & FE_INVALID) + { + volatile float zero = 0.0f; + r = zero / zero; + } +#endif +#ifdef FE_DIVBYZERO + if (excepts & FE_DIVBYZERO) + { + volatile float zero = 0.0f; + r = 1.0f / zero; + } +#endif +#ifdef FE_OVERFLOW + if (excepts & FE_OVERFLOW) + { + volatile float max = __FLT_MAX__; + r = max * max; + } +#endif +#ifdef FE_UNDERFLOW + if (excepts & FE_UNDERFLOW) + { + volatile float min = __FLT_MIN__; + r = min * min; + } +#endif +#ifdef FE_INEXACT + if (excepts & FE_INEXACT) + { + volatile float three = 3.0f; + r = 1.0f / three; + } +#endif +} diff --git a/libatomic/configure.tgt b/libatomic/configure.tgt index 67a5f2dff80..4237f283fe4 100644 --- a/libatomic/configure.tgt +++ b/libatomic/configure.tgt @@ -36,6 +36,7 @@ case "${target_cpu}" in XCFLAGS="${XCFLAGS} -mfp-trap-mode=sui" ARCH=alpha ;; + hppa*) ARCH=pa ;; rs6000 | powerpc*) ARCH=powerpc ;; riscv*) ARCH=riscv ;; sh*) ARCH=sh ;;