From patchwork Fri Oct 25 14:12:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 838342 Delivered-To: patch@linaro.org Received: by 2002:adf:e287:0:b0:37d:45d0:187 with SMTP id v7csp305640wri; Fri, 25 Oct 2024 07:13:21 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUvBIQimAJTZe5L8EGxoWME/CxkNxcdtJaeLNM0rVV/hzLaZqtmtV/3pQYZFDxGP7UyHoM/zw==@linaro.org X-Google-Smtp-Source: AGHT+IGRC5RZqtFifRHmMdAhyDFd5b2B1Cbs6o1N0mSwj9Ysn2UjDzQt+K66JxXes4wvJjzy8nbI X-Received: by 2002:a05:620a:318b:b0:7a9:b424:ffec with SMTP id af79cd13be357-7b186bca4e8mr563918685a.30.1729865601194; Fri, 25 Oct 2024 07:13:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729865601; cv=none; d=google.com; s=arc-20240605; b=ElhbXFqt+2k7PsiQM0IWk35WMSsmS7iI++faFoTnDZTjS4HEZq1Clfnt0TYp7ljJ21 //TShfix+tjA9kt34+b99koMjIay1glDFdLYjuaKU4r6aG2Srv375YcnbtHkqSXSTZmy ybOgSDKuDoS9HGsxfGlQm1WtfUkWe5Twh7qoCa7pRmrV78FLKIytiPhPp4Lp4dNkRg59 Z+N33BDVd9k8eIMKUe17AGFXDbmKqwmrwIo7eQ6OMXnBiea7/R6vXPYeXDK/NK5UbM4a +9YuOJ3pmQlB8bu6s+VWM3b1u7iD5zDzBoXtebo0um5ffgw7lsK9OCAF0qlMH+X7KlVT dgLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=noOStqS92L5He4WhIYZl74MdTVJ5AKWtfARpcTTpidc=; fh=97rJglenom4eB5QyrU4eM2JaokIj77G8hvzsmX6UJVs=; b=lf323Kjb8+cuODctw1QPgVRBmKTxBE2rGzf45npgPG+4GzRxHYXAFBJYubwtNdhsRD KAw1Z3FH3oH3rREQ67lzHaKUnC1y29xzA6tlPqrQ2FBkb/9tCl7C6CuqQB2kmRouI2Ho GFdqrsegpx7GoenZOjhpZz3ngkqNzAWYnyiN2C7Gh+pPw/JYj7pa+CnkfChGMcUEZO4Y hMKwNT20QYgvjGYi5GSZQ+iX3kuzmqK464HbwqV8edEvWPZv0AIajwOuOIPddGn1Xl1V T4H6ZkRvBKz5pWYMMwGFZJUFlgiWPZkv3OQ//nA1wZa1exh64OCVA8i5dYkXJ3nwb3W9 Zuug==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jIhxsrh0; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7b18d26a029si154776685a.114.2024.10.25.07.13.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 25 Oct 2024 07:13:21 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jIhxsrh0; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t4L3n-0003y8-9M; Fri, 25 Oct 2024 10:13:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t4L3m-0003xX-Ik for qemu-devel@nongnu.org; Fri, 25 Oct 2024 10:13:02 -0400 Received: from mail-lf1-x129.google.com ([2a00:1450:4864:20::129]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t4L3j-0007la-78 for qemu-devel@nongnu.org; Fri, 25 Oct 2024 10:13:02 -0400 Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-539f84907caso2337218e87.3 for ; Fri, 25 Oct 2024 07:12:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729865577; x=1730470377; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=noOStqS92L5He4WhIYZl74MdTVJ5AKWtfARpcTTpidc=; b=jIhxsrh0Q9fiBWSZU64t9sphn+NM7dy+v/xo5GSp1NNHDnTMBF3106VMe9ZsHwYYKa M4dfbMjksRz8kLSaQsPxtJ1EV/wp64XX97FeMOFis7LrEj5ZADG38L1lc2r0D/gpNs+K cR7jlbEzPvHmsycHZ5NRqbxTku+79j3jYj5y2LheOJXX3aRh6HGNHcj+5XB4zvSaEGPY LyEvYltrUo6s7Y/DNXeXVDw1OqL2qJpZs7B3AL8LoZm+SeRyxPtOGs5yIWoTnQ02FJEI s7fChd4DGHMmYsZPWkZ0tJeO1uu7b+/qdRv40hyN5au2Ln/2EuqWq8CfPgmUddyHh5WD Inqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729865577; x=1730470377; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=noOStqS92L5He4WhIYZl74MdTVJ5AKWtfARpcTTpidc=; b=Q0K5OmIsM89efTeTqsACGa0agMZAGFaDinjY5Pb/P/FV3W/0oGq3Fx+wZPis1ply4k brA99RUQTICtcJHpHgE3e99HHxzxQ5rHTp6XqWeRvl+ItanVNAZegeqBG29KJpfi2SCG GhcEI4RrQcMARPNHIIaf7P1cu0xz3xrK4JECPqx5kljAFPbfZL66beovyzkLakaIpwtK maqersNFVubUE85r5d1qYKkUV91ve60NFpUrIgoHGL9ckVg1Ckh334or7uLX3mTM6Z9e dK6P1BORWLQpGE6/MVQWOD5Gu82o9yl6ymRdlf6rvWi+RNPQLCIc0yzejSx2esaqXqB+ BEZA== X-Forwarded-Encrypted: i=1; AJvYcCWyiUHWNTRPGJRpL9XhwV/Id5dLjOPibgmJbkpKfuqce2wwtAQbjfwGXwZiwBAz0lMOjxXS9cJnW3/a@nongnu.org X-Gm-Message-State: AOJu0Yw5UtFlCJarIuY09LD+1gzTAR2hu5uQm9XToCG3cjA8HCQ0cvLs /fGriq3K3Fp66ajHnNNfPDCXt8YZhsk99P1TrMz+qUFYH1czvOI+s0t82bi4ob8= X-Received: by 2002:a05:6512:1048:b0:53b:1f90:576f with SMTP id 2adb3069b0e04-53b23dfcfb6mr3139601e87.22.1729865577170; Fri, 25 Oct 2024 07:12:57 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4318b57b051sm50104535e9.42.2024.10.25.07.12.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 07:12:56 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Song Gao , Eduardo Habkost , "Edgar E. Iglesias" , Jiaxun Yang , Aleksandar Rikalo , Stafford Horne , Nicholas Piggin , Daniel Henrique Barboza , Yoshinori Sato , David Hildenbrand , Ilya Leoshkevich , Thomas Huth , Mark Cave-Ayland , Artyom Tarasenko , Max Filippov , qemu-ppc@nongnu.org, qemu-s390x@nongnu.org Subject: [PATCH 01/21] softfloat: Allow 2-operand NaN propagation rule to be set at runtime Date: Fri, 25 Oct 2024 15:12:34 +0100 Message-Id: <20241025141254.2141506-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241025141254.2141506-1-peter.maydell@linaro.org> References: <20241025141254.2141506-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::129; envelope-from=peter.maydell@linaro.org; helo=mail-lf1-x129.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org IEEE 758 does not define a fixed rule for which NaN to pick as the result if both operands of a 2-operand operation are NaNs. As a result different architectures have ended up with different rules for propagating NaNs. QEMU currently hardcodes the NaN propagation logic into the binary because pickNaN() has an ifdef ladder for different targets. We want to make the propagation rule instead be selectable at runtime, because: * this will let us have multiple targets in one QEMU binary * the Arm FEAT_AFP architectural feature includes letting the guest select a NaN propagation rule at runtime * x86 specifies different propagation rules for x87 FPU ops and for SSE ops, and specifying the rule in the float_status would let us emulate this, instead of wrongly using the x87 rules everywhere In this commit we add an enum for the propagation rule, the field in float_status, and the corresponding getters and setters. We change pickNaN to honour this, but because all targets still leave this field at its default 0 value, the fallback logic will pick the rule type with the old ifdef ladder. It's valid not to set a propagation rule if default_nan_mode is enabled, because in that case there's no need to pick a NaN; all the callers of pickNaN() catch this case and skip calling it. So we can already assert that we don't get into the "no rule defined" codepath for our four targets which always set default_nan_mode: Hexagon, RiscV, SH4 and Tricore, and for the one target which does not have FP at all: avr. These targets will not need to be updated to call set_float_2nan_prop_rule(). Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- Reindent means a couple of slightly long lines in comments, but those will move again in a later patch, so seemed clearer to not re-wrap the comment and then re-rewrap it later. --- include/fpu/softfloat-helpers.h | 11 ++ include/fpu/softfloat-types.h | 42 ++++++ fpu/softfloat-specialize.c.inc | 229 ++++++++++++++++++-------------- 3 files changed, 185 insertions(+), 97 deletions(-) diff --git a/include/fpu/softfloat-helpers.h b/include/fpu/softfloat-helpers.h index 94cbe073ec5..453188de70b 100644 --- a/include/fpu/softfloat-helpers.h +++ b/include/fpu/softfloat-helpers.h @@ -75,6 +75,12 @@ static inline void set_floatx80_rounding_precision(FloatX80RoundPrec val, status->floatx80_rounding_precision = val; } +static inline void set_float_2nan_prop_rule(Float2NaNPropRule rule, + float_status *status) +{ + status->float_2nan_prop_rule = rule; +} + static inline void set_flush_to_zero(bool val, float_status *status) { status->flush_to_zero = val; @@ -126,6 +132,11 @@ get_floatx80_rounding_precision(float_status *status) return status->floatx80_rounding_precision; } +static inline Float2NaNPropRule get_float_2nan_prop_rule(float_status *status) +{ + return status->float_2nan_prop_rule; +} + static inline bool get_flush_to_zero(float_status *status) { return status->flush_to_zero; diff --git a/include/fpu/softfloat-types.h b/include/fpu/softfloat-types.h index 0884ec4ef7a..5cd5a0d0ae1 100644 --- a/include/fpu/softfloat-types.h +++ b/include/fpu/softfloat-types.h @@ -170,6 +170,47 @@ typedef enum __attribute__((__packed__)) { floatx80_precision_s, } FloatX80RoundPrec; +/* + * 2-input NaN propagation rule. Individual architectures have + * different rules for which input NaN is propagated to the output + * when there is more than one NaN on the input. + * + * If default_nan_mode is enabled then it is valid not to set a + * NaN propagation rule, because the softfloat code guarantees + * not to try to pick a NaN to propagate in default NaN mode. + * + * For transition, currently the 'none' rule will cause us to + * fall back to picking the propagation rule based on the existing + * ifdef ladder. When all targets are converted it will be an error + * not to set the rule in float_status unless in default_nan_mode, + * and we will assert if we need to handle an input NaN and no + * rule was selected. + */ +typedef enum __attribute__((__packed__)) { + /* No propagation rule specified */ + float_2nan_prop_none = 0, + /* Prefer SNaN over QNaN, then operand A over B */ + float_2nan_prop_s_ab, + /* Prefer SNaN over QNaN, then operand B over A */ + float_2nan_prop_s_ba, + /* Prefer A over B regardless of SNaN vs QNaN */ + float_2nan_prop_ab, + /* Prefer B over A regardless of SNaN vs QNaN */ + float_2nan_prop_ba, + /* + * This implements x87 NaN propagation rules: + * SNaN + QNaN => return the QNaN + * two SNaNs => return the one with the larger significand, silenced + * two QNaNs => return the one with the larger significand + * SNaN and a non-NaN => return the SNaN, silenced + * QNaN and a non-NaN => return the QNaN + * + * If we get down to comparing significands and they are the same, + * return the NaN with the positive sign bit (if any). + */ + float_2nan_prop_x87, +} Float2NaNPropRule; + /* * Floating Point Status. Individual architectures may maintain * several versions of float_status for different functions. The @@ -181,6 +222,7 @@ typedef struct float_status { uint16_t float_exception_flags; FloatRoundMode float_rounding_mode; FloatX80RoundPrec floatx80_rounding_precision; + Float2NaNPropRule float_2nan_prop_rule; bool tininess_before_rounding; /* should denormalised results go to zero and set the inexact flag? */ bool flush_to_zero; diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc index 4e279b9bc40..fae6794a152 100644 --- a/fpu/softfloat-specialize.c.inc +++ b/fpu/softfloat-specialize.c.inc @@ -390,118 +390,153 @@ bool float32_is_signaling_nan(float32 a_, float_status *status) static int pickNaN(FloatClass a_cls, FloatClass b_cls, bool aIsLargerSignificand, float_status *status) { -#if defined(TARGET_ARM) || defined(TARGET_MIPS) || defined(TARGET_HPPA) || \ - defined(TARGET_LOONGARCH64) || defined(TARGET_S390X) - /* ARM mandated NaN propagation rules (see FPProcessNaNs()), take - * the first of: - * 1. A if it is signaling - * 2. B if it is signaling - * 3. A (quiet) - * 4. B (quiet) - * A signaling NaN is always quietened before returning it. - */ - /* According to MIPS specifications, if one of the two operands is - * a sNaN, a new qNaN has to be generated. This is done in - * floatXX_silence_nan(). For qNaN inputs the specifications - * says: "When possible, this QNaN result is one of the operand QNaN - * values." In practice it seems that most implementations choose - * the first operand if both operands are qNaN. In short this gives - * the following rules: - * 1. A if it is signaling - * 2. B if it is signaling - * 3. A (quiet) - * 4. B (quiet) - * A signaling NaN is always silenced before returning it. - */ - if (is_snan(a_cls)) { - return 0; - } else if (is_snan(b_cls)) { - return 1; - } else if (is_qnan(a_cls)) { - return 0; - } else { - return 1; - } -#elif defined(TARGET_PPC) || defined(TARGET_M68K) - /* PowerPC propagation rules: - * 1. A if it sNaN or qNaN - * 2. B if it sNaN or qNaN - * A signaling NaN is always silenced before returning it. - */ - /* M68000 FAMILY PROGRAMMER'S REFERENCE MANUAL - * 3.4 FLOATING-POINT INSTRUCTION DETAILS - * If either operand, but not both operands, of an operation is a - * nonsignaling NaN, then that NaN is returned as the result. If both - * operands are nonsignaling NaNs, then the destination operand - * nonsignaling NaN is returned as the result. - * If either operand to an operation is a signaling NaN (SNaN), then the - * SNaN bit is set in the FPSR EXC byte. If the SNaN exception enable bit - * is set in the FPCR ENABLE byte, then the exception is taken and the - * destination is not modified. If the SNaN exception enable bit is not - * set, setting the SNaN bit in the operand to a one converts the SNaN to - * a nonsignaling NaN. The operation then continues as described in the - * preceding paragraph for nonsignaling NaNs. - */ - if (is_nan(a_cls)) { - return 0; - } else { - return 1; - } -#elif defined(TARGET_SPARC) - /* Prefer SNaN over QNaN, order B then A. */ - if (is_snan(b_cls)) { - return 1; - } else if (is_snan(a_cls)) { - return 0; - } else if (is_qnan(b_cls)) { - return 1; - } else { - return 0; - } -#elif defined(TARGET_XTENSA) + Float2NaNPropRule rule = status->float_2nan_prop_rule; + /* - * Xtensa has two NaN propagation modes. - * Which one is active is controlled by float_status::use_first_nan. + * We guarantee not to require the target to tell us how to + * pick a NaN if we're always returning the default NaN. */ - if (status->use_first_nan) { + assert(!status->default_nan_mode); + + if (rule == float_2nan_prop_none) { + /* target didn't set the rule: fall back to old ifdef choices */ +#if defined(TARGET_AVR) || defined(TARGET_HEXAGON) \ + || defined(TARGET_RISCV) || defined(TARGET_SH4) \ + || defined(TARGET_TRICORE) + g_assert_not_reached(); +#elif defined(TARGET_ARM) || defined(TARGET_MIPS) || defined(TARGET_HPPA) || \ + defined(TARGET_LOONGARCH64) || defined(TARGET_S390X) + /* + * ARM mandated NaN propagation rules (see FPProcessNaNs()), take + * the first of: + * 1. A if it is signaling + * 2. B if it is signaling + * 3. A (quiet) + * 4. B (quiet) + * A signaling NaN is always quietened before returning it. + */ + /* + * According to MIPS specifications, if one of the two operands is + * a sNaN, a new qNaN has to be generated. This is done in + * floatXX_silence_nan(). For qNaN inputs the specifications + * says: "When possible, this QNaN result is one of the operand QNaN + * values." In practice it seems that most implementations choose + * the first operand if both operands are qNaN. In short this gives + * the following rules: + * 1. A if it is signaling + * 2. B if it is signaling + * 3. A (quiet) + * 4. B (quiet) + * A signaling NaN is always silenced before returning it. + */ + rule = float_2nan_prop_s_ab; +#elif defined(TARGET_PPC) || defined(TARGET_M68K) + /* + * PowerPC propagation rules: + * 1. A if it sNaN or qNaN + * 2. B if it sNaN or qNaN + * A signaling NaN is always silenced before returning it. + */ + /* + * M68000 FAMILY PROGRAMMER'S REFERENCE MANUAL + * 3.4 FLOATING-POINT INSTRUCTION DETAILS + * If either operand, but not both operands, of an operation is a + * nonsignaling NaN, then that NaN is returned as the result. If both + * operands are nonsignaling NaNs, then the destination operand + * nonsignaling NaN is returned as the result. + * If either operand to an operation is a signaling NaN (SNaN), then the + * SNaN bit is set in the FPSR EXC byte. If the SNaN exception enable bit + * is set in the FPCR ENABLE byte, then the exception is taken and the + * destination is not modified. If the SNaN exception enable bit is not + * set, setting the SNaN bit in the operand to a one converts the SNaN to + * a nonsignaling NaN. The operation then continues as described in the + * preceding paragraph for nonsignaling NaNs. + */ + rule = float_2nan_prop_ab; +#elif defined(TARGET_SPARC) + /* Prefer SNaN over QNaN, order B then A. */ + rule = float_2nan_prop_s_ba; +#elif defined(TARGET_XTENSA) + /* + * Xtensa has two NaN propagation modes. + * Which one is active is controlled by float_status::use_first_nan. + */ + if (status->use_first_nan) { + rule = float_2nan_prop_ab; + } else { + rule = float_2nan_prop_ba; + } +#else + rule = float_2nan_prop_x87; +#endif + } + + switch (rule) { + case float_2nan_prop_s_ab: + if (is_snan(a_cls)) { + return 0; + } else if (is_snan(b_cls)) { + return 1; + } else if (is_qnan(a_cls)) { + return 0; + } else { + return 1; + } + break; + case float_2nan_prop_s_ba: + if (is_snan(b_cls)) { + return 1; + } else if (is_snan(a_cls)) { + return 0; + } else if (is_qnan(b_cls)) { + return 1; + } else { + return 0; + } + break; + case float_2nan_prop_ab: if (is_nan(a_cls)) { return 0; } else { return 1; } - } else { + break; + case float_2nan_prop_ba: if (is_nan(b_cls)) { return 1; } else { return 0; } - } -#else - /* This implements x87 NaN propagation rules: - * SNaN + QNaN => return the QNaN - * two SNaNs => return the one with the larger significand, silenced - * two QNaNs => return the one with the larger significand - * SNaN and a non-NaN => return the SNaN, silenced - * QNaN and a non-NaN => return the QNaN - * - * If we get down to comparing significands and they are the same, - * return the NaN with the positive sign bit (if any). - */ - if (is_snan(a_cls)) { - if (is_snan(b_cls)) { - return aIsLargerSignificand ? 0 : 1; - } - return is_qnan(b_cls) ? 1 : 0; - } else if (is_qnan(a_cls)) { - if (is_snan(b_cls) || !is_qnan(b_cls)) { - return 0; + break; + case float_2nan_prop_x87: + /* + * This implements x87 NaN propagation rules: + * SNaN + QNaN => return the QNaN + * two SNaNs => return the one with the larger significand, silenced + * two QNaNs => return the one with the larger significand + * SNaN and a non-NaN => return the SNaN, silenced + * QNaN and a non-NaN => return the QNaN + * + * If we get down to comparing significands and they are the same, + * return the NaN with the positive sign bit (if any). + */ + if (is_snan(a_cls)) { + if (is_snan(b_cls)) { + return aIsLargerSignificand ? 0 : 1; + } + return is_qnan(b_cls) ? 1 : 0; + } else if (is_qnan(a_cls)) { + if (is_snan(b_cls) || !is_qnan(b_cls)) { + return 0; + } else { + return aIsLargerSignificand ? 0 : 1; + } } else { - return aIsLargerSignificand ? 0 : 1; + return 1; } - } else { - return 1; + default: + g_assert_not_reached(); } -#endif } /*---------------------------------------------------------------------------- From patchwork Fri Oct 25 14:12:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 838345 Delivered-To: patch@linaro.org Received: by 2002:adf:e287:0:b0:37d:45d0:187 with SMTP id v7csp306219wri; Fri, 25 Oct 2024 07:14:09 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUqff84RzLlSSohlsNvFgDUFzkow3hon7E2lEbK1YIiBBKz2UBu+coX77MFK/cKTtTJLVSgJg==@linaro.org X-Google-Smtp-Source: AGHT+IEa4vTvSzc8s//UK2mDdFpykq6PR0RAFzdf934VnIQbrbuEnUnyRhou0H1Oj9Zs8zh3XQ9a X-Received: by 2002:a05:620a:1726:b0:7a7:d37b:3ee3 with SMTP id af79cd13be357-7b186601543mr947613485a.26.1729865648673; Fri, 25 Oct 2024 07:14:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729865648; cv=none; d=google.com; s=arc-20240605; b=etun1XHL8gk5x2LpQ6UlBigl7jY/50d3p3mhnBcI4rwYnN52s2QCcRnoM1Vpi9yQhH 0phDKfDkCOSPjNCQHsyyre3GUIZkQqxxHpGJJlhBtnrP5DOy6+Te9OIjPHH/v/V1tym6 AZxiwz4A5b0e3nPJkZf2HKCYzbe8DAyxXqMXj8TybdD5pGWwSs+Yn9DMHaGauY6cfZLD dX1fj4RkLAC9E91mZXGCWA+QKEfZE0iCrDl3QXJ/bD9pW9y7RMKZHzRv9gJmRJ1p7uZd 4HOnsUDzfBu5o7UhGutJL9l0xvc3NJFY+Ycs9zlwCT1VmEvFxMhwt6sjWj0vq53Dg0++ CAvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ZnxIUdeIDPfopOqS6esccSkst6Aak8TUkDQf9Y6bLJw=; fh=V6EOYOsTxtiGhEmP1WPv5x8bhtzpDMhOg3bMQJxVdBw=; b=CbF5c5yP271C1vvlLypi9DfWN0YKTRQ1ScCOxBN9GAwgWif0vxtlMePTxrVJzEr86r hIShELk+elaUdFMsidwhIqRBY6tw8GwdMpmC9eRDPZJsw8gpPGT4wc1wsXrCq12yk2ek y//CDTLLWFEGBtptdBRvbS0Y0TAC4oPMcrK3FxmFRHg5usx7Z+u3ksTfPvJfWEh4nDM9 WPd4ZUxt+RjhGWt2uQ5eBEFaVYDlLJfj4eiuru08MUzo7/spPQrZxZujy6E5AMJ6jGUN DaURUT6csyoBxUamD2wa5IcqmpvhwGoUrBUQjACJcljX4tlBV//K3ppK3BrrQkL243vC KR8A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wFazQQ+Z; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7b18d32130dsi155450885a.332.2024.10.25.07.14.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 25 Oct 2024 07:14:08 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wFazQQ+Z; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t4L3o-0003zR-My; Fri, 25 Oct 2024 10:13:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t4L3n-0003xr-3x for qemu-devel@nongnu.org; Fri, 25 Oct 2024 10:13:03 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t4L3j-0007lj-Js for qemu-devel@nongnu.org; Fri, 25 Oct 2024 10:13:02 -0400 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-37d41894a32so1613275f8f.1 for ; Fri, 25 Oct 2024 07:12:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729865578; x=1730470378; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZnxIUdeIDPfopOqS6esccSkst6Aak8TUkDQf9Y6bLJw=; b=wFazQQ+Zttx2Q0IVTm/i/o55910/+kh86QQ2FD5IxroezhhQ78OgmGj6nZ2ISRd5n7 CgPlOYiplTK2RCFHyvXRIQc32n5vWv1WVjy26UVbXIdZsQG1VTt2+ilpOZir3uPx0xGM G0I3PF9BrzJCu8yfw1dyUIctk7Idzc8By6IUJVC8Rak5gBUzkFMIYtkr9WKLGaNZJXxq AaDHmZkPniFDFlDbC+Mqa/PWzLD+owCzWhrw1+AYasDj8GbwTs03mWY268bkCMf2cBIN XlkfQ666HG4VVwhU45kdwL3z842dpdfLzCpjJcBg07whhs/acODElyUhJQrRDUKye1UV TJ2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729865578; x=1730470378; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZnxIUdeIDPfopOqS6esccSkst6Aak8TUkDQf9Y6bLJw=; b=qhBkdt2yjECTNFHJfARDRHHc/HvRT2cYsBD6nJQtWn8132S5dpnwPsBHHtVFS7EGVf oejpywqqYpqoJQDzw67HoMsxukWUHoTi6ZO6n1lQR8F3kn2qrnd+1vMpvGcD6jyQYpUG fbVOGtyVPMvHmjtQmW64fFshDmLtvGCrysKuROvmDY2AKjtRtZ8T2kbspQTVj4+7EUZo Dpm6PMVp3oSYbEcJubPNAlfZCopbClj7CrdelLgGdNrhvB9u/yxs27G8YoyhTy5MObiy 1hgIZPo7Ifx/JNpL/A0skbWVVja3C7pjsgF26vJAui1h0KrRKa+vxtX+eL/8tR7aDYb5 gSfA== X-Forwarded-Encrypted: i=1; AJvYcCXoW4ECr55qZYyQ/Zo5NOzHaM3B1gZaU8WZB/hN8eLDJXSqvCY7ZudTqSDNADGaHYHTmtGI1/paAPzv@nongnu.org X-Gm-Message-State: AOJu0Yy7l1hKLzhEEf3bad6F/Z5Ci16JWivuvc92ZmSIMUMpV96n8RAl k1MtJ/wl+hX/yUUtFBlEIUpfAiNM63QT997zJydjzgj9QJa2aQtYsag+lVhdtZA= X-Received: by 2002:a5d:4fcb:0:b0:374:c33d:377d with SMTP id ffacd0b85a97d-380458812bbmr4321188f8f.28.1729865578101; Fri, 25 Oct 2024 07:12:58 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4318b57b051sm50104535e9.42.2024.10.25.07.12.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 07:12:57 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Song Gao , Eduardo Habkost , "Edgar E. Iglesias" , Jiaxun Yang , Aleksandar Rikalo , Stafford Horne , Nicholas Piggin , Daniel Henrique Barboza , Yoshinori Sato , David Hildenbrand , Ilya Leoshkevich , Thomas Huth , Mark Cave-Ayland , Artyom Tarasenko , Max Filippov , qemu-ppc@nongnu.org, qemu-s390x@nongnu.org Subject: [PATCH 02/21] tests/fp: Explicitly set 2-NaN propagation rule Date: Fri, 25 Oct 2024 15:12:35 +0100 Message-Id: <20241025141254.2141506-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241025141254.2141506-1-peter.maydell@linaro.org> References: <20241025141254.2141506-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Explicitly set a 2-NaN propagation rule in the softfloat tests. In meson.build we put -DTARGET_ARM in fpcflags, and so we should select here the Arm propagation rule of float_2nan_prop_s_ab. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- tests/fp/fp-bench.c | 2 ++ tests/fp/fp-test-log2.c | 1 + tests/fp/fp-test.c | 2 ++ 3 files changed, 5 insertions(+) diff --git a/tests/fp/fp-bench.c b/tests/fp/fp-bench.c index 8ce0ca1545d..75c07d5d1f1 100644 --- a/tests/fp/fp-bench.c +++ b/tests/fp/fp-bench.c @@ -488,6 +488,8 @@ static void run_bench(void) { bench_func_t f; + set_float_2nan_prop_rule(float_2nan_prop_s_ab, &soft_status); + f = bench_funcs[operation][precision]; g_assert(f); f(); diff --git a/tests/fp/fp-test-log2.c b/tests/fp/fp-test-log2.c index 4eae93eb7cc..de702c4c80d 100644 --- a/tests/fp/fp-test-log2.c +++ b/tests/fp/fp-test-log2.c @@ -70,6 +70,7 @@ int main(int ac, char **av) float_status qsf = {0}; int i; + set_float_2nan_prop_rule(float_2nan_prop_s_ab, &qsf); set_float_rounding_mode(float_round_nearest_even, &qsf); test.d = 0.0; diff --git a/tests/fp/fp-test.c b/tests/fp/fp-test.c index 36b5712cda0..5f6f25c8821 100644 --- a/tests/fp/fp-test.c +++ b/tests/fp/fp-test.c @@ -935,6 +935,8 @@ void run_test(void) { unsigned int i; + set_float_2nan_prop_rule(float_2nan_prop_s_ab, &qsf); + genCases_setLevel(test_level); verCases_maxErrorCount = n_max_errors; From patchwork Fri Oct 25 14:12:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 838349 Delivered-To: patch@linaro.org Received: by 2002:adf:e287:0:b0:37d:45d0:187 with SMTP id v7csp306703wri; Fri, 25 Oct 2024 07:14:56 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWCWrMMKQQDqAeX/EVA3nysq6Nl+axYF8YMENvXmXdjD5D1q9wtmbv2cggwIO6kgAeo/Gur3Q==@linaro.org X-Google-Smtp-Source: AGHT+IE83/qwfInHxvVI/p+MSD5TK+Q3CAAAXaq9FW45lIIbRoZTz2Et9ltfnstU1twfzFIp2Zuu X-Received: by 2002:ac8:7d44:0:b0:460:a82a:39a8 with SMTP id d75a77b69052e-461258b2169mr69441711cf.13.1729865696134; Fri, 25 Oct 2024 07:14:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729865696; cv=none; d=google.com; s=arc-20240605; b=CWsmvYud4SUFOLYMdI4aYJLdf5H5AmKVs85hbN0RGvMMpnDiMiTXLx8eV3VX88yLVD Tj7N2VATleVpxMcOI70hs6a2qhi7ePD1J0Go9CUQTzCjAVNfuA7PFefpOypaXZaQE0Tn J2PfvNGFZ0O4sbfSmczChb7bUR41WFwu2EdhZR+ViuL5cI87JNq1gciDN6AC7RLPFcdO a83RS+iOif5/kV87jZRfMS6HaBvD03VwGZqpqBs9TPrz1qSNnRDxZqHbwkIuRgB0JYv/ GMmB/RiMuLM0bFIyNx86K6F9YeBTPlWhWMTVyiD5i4d2Pe72pIuAX1KqiLURoJ1eYkkM 1Qhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=eGwvRk7TZZeC43moIVYb7p9RL4z/VBbvk9hnG7xUO3c=; fh=14BaeO+kSDJnPAZpAZuMaNf4CBTQP6Za/1cw7FcYlnc=; b=UGmeYU/N+SbxWN5uTFxtfqWOPX08jLhS9k+y4omhUg44hPJVLcXOyuOoLSuai/5JVC e5iLyNJsKWJH6+hGFPrNXJw2zMNt0PfqvfPokJvZp1y3r5fYx03o845PfPPeTuh+NHjA ySuBhXIZUlhRYwWa2JUmCrY2mzDWDwWSZJGlJ/IPp94uBx+s/sH4G5RGu/7B5nFAYSRx +AHrmuQBsUdIZu85seZGdlbxNw9+biyCXgz/VZ2wFBz+94STqFDVrX4IHpCaOMam7LRl vu3Shrf03Tq3ByzfYBH1Hnk0x/YLPmP0xR+Yje7yJX4dCrMUJE+S3onMDUPbvGniHeaO FiLQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=csU1314F; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-46132396a2bsi14670351cf.527.2024.10.25.07.14.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 25 Oct 2024 07:14:56 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=csU1314F; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t4L3t-00044u-Ii; Fri, 25 Oct 2024 10:13:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t4L3p-000406-FI for qemu-devel@nongnu.org; Fri, 25 Oct 2024 10:13:05 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t4L3k-0007mD-R8 for qemu-devel@nongnu.org; Fri, 25 Oct 2024 10:13:05 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-43162cf1eaaso27318895e9.0 for ; Fri, 25 Oct 2024 07:13:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729865579; x=1730470379; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eGwvRk7TZZeC43moIVYb7p9RL4z/VBbvk9hnG7xUO3c=; b=csU1314FYbm4YozNi99R86y+c/GF1E2b4jGCRATbeBgb8HKVNk/fBvz2dnq02NeeyJ x5lT6UADsEWBGk4QGftmz4W+JLAm+07Giahp1Uv2GkaBgIeMmTmBONPRZaL4kT3Gz1ft nMmDAx3DCRTyDVPRP4ehLMLzFrH9GIerqqM6QLoRRXLzRdPktSQvNQRglwt9pe89LEvV zVl6uHiGJeNtQZTI7yGfOqA5+X6IbNRpd5BnoGilMDl70XxgL1kz1IYt+YRFopy+zWH2 Sx84BiLdoVSbl2kDPKECJcxZmDG47bll/3iP3JR8g5j4WdzbrLmgyT9OMadz4woJCBhX 3Ixw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729865579; x=1730470379; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eGwvRk7TZZeC43moIVYb7p9RL4z/VBbvk9hnG7xUO3c=; b=OQBDU9SHA6jhwzBTBHQizxRVSy5hO+wMnzlqJ8iKBYl+JlGAJrdG9nOOi1CrkA8FbC DJ2951nee4JZrIwJPavuLWaH0qMgrYSQm2fiRIFuNSEJrDIZXwT074l/DgzCjw5NhgYV F9EURcGFVl7hePY/5Ujdgk59gghuCn7Um/0u7Pt52rLsVGPH7HIlkcACQ4ol6ofmid08 Vrl3oTRz4jx1z/scm5DQpupkBaREKWFpVDxGon7TwDYRHqugq4RfWM2LCDsGUb9/3kSb +LEdad67TvrvCC5029HdDHjKhlCpVxUNGISUl8d8V7PMnmNbAykUM7282/AILQIq3w3N QWbg== X-Forwarded-Encrypted: i=1; AJvYcCUcxax5989PYRc+b2CzWfIysqhLb0R2C7xR9kvg5bYzn7zNYlC+BPEm+leqOZP13NtNkmc6oFsNQxlg@nongnu.org X-Gm-Message-State: AOJu0YzalOeLZIsaaOAg6zJQESb8nTA4RaM/oJl5QYWmjGEHMdHrnps6 q/fi4Bt11CQ/0kZvYHJgA9BycBUgi69n5QYR7ouT73bD6nsUQWCbzynMifo9Gm8= X-Received: by 2002:a05:600c:1f09:b0:426:59fe:ac27 with SMTP id 5b1f17b1804b1-43184241cc5mr111818875e9.26.1729865579076; Fri, 25 Oct 2024 07:12:59 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4318b57b051sm50104535e9.42.2024.10.25.07.12.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 07:12:58 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Song Gao , Eduardo Habkost , "Edgar E. Iglesias" , Jiaxun Yang , Aleksandar Rikalo , Stafford Horne , Nicholas Piggin , Daniel Henrique Barboza , Yoshinori Sato , David Hildenbrand , Ilya Leoshkevich , Thomas Huth , Mark Cave-Ayland , Artyom Tarasenko , Max Filippov , qemu-ppc@nongnu.org, qemu-s390x@nongnu.org Subject: [PATCH 03/21] target/arm: Explicitly set 2-NaN propagation rule Date: Fri, 25 Oct 2024 15:12:36 +0100 Message-Id: <20241025141254.2141506-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241025141254.2141506-1-peter.maydell@linaro.org> References: <20241025141254.2141506-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x335.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Set the 2-NaN propagation rule explicitly in the float_status words we use. We wrap this plus the pre-existing setting of the tininess-before-rounding flag in a new function arm_set_default_fp_behaviours() to avoid repetition, since we have a lot of float_status words at this point. The situation with FPA11 emulation in linux-user is a little odd, and arguably "correct" behaviour there would be to exactly match a real Linux kernel's FPA11 emulation. However FPA11 emulation is essentially dead at this point and so it seems better to continue with QEMU's current behaviour and leave a comment describing the situation. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- linux-user/arm/nwfpe/fpa11.c | 18 ++++++++++++++++++ target/arm/cpu.c | 25 +++++++++++++++++-------- fpu/softfloat-specialize.c.inc | 13 ++----------- 3 files changed, 37 insertions(+), 19 deletions(-) diff --git a/linux-user/arm/nwfpe/fpa11.c b/linux-user/arm/nwfpe/fpa11.c index 9a93610d245..8356beb52c6 100644 --- a/linux-user/arm/nwfpe/fpa11.c +++ b/linux-user/arm/nwfpe/fpa11.c @@ -51,6 +51,24 @@ void resetFPA11(void) #ifdef MAINTAIN_FPCR fpa11->fpcr = MASK_RESET; #endif + + /* + * Real FPA11 hardware does not handle NaNs, but always takes an + * exception for them to be software-emulated (ARM7500FE datasheet + * section 10.4). There is no documented architectural requirement + * for NaN propagation rules and it will depend on how the OS + * level software emulation opted to do it. We here use prop_s_ab + * which matches the later VFP hardware choice and how QEMU's + * fpa11 emulation has worked in the past. The real Linux kernel + * does something slightly different: arch/arm/nwfpe/softfloat-specialize + * propagateFloat64NaN() has the curious behaviour that it prefers + * the QNaN over the SNaN, but if both are QNaN it picks A and + * if both are SNaN it picks B. In theory we could add this as + * a NaN propagation rule, but in practice FPA11 emulation is so + * close to totally dead that it's not worth trying to match it at + * this late date. + */ + set_float_2nan_prop_rule(float_2nan_prop_s_ab, &fpa11->fp_status); } void SetRoundingMode(const unsigned int opcode) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 1320fd8c8fe..2fd286972a9 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -168,6 +168,18 @@ void arm_register_el_change_hook(ARMCPU *cpu, ARMELChangeHookFn *hook, QLIST_INSERT_HEAD(&cpu->el_change_hooks, entry, node); } +/* + * Set the float_status behaviour to match the Arm defaults: + * * tininess-before-rounding + * * 2-input NaN propagation prefers SNaN over QNaN, and then + * operand A over operand B (see FPProcessNaNs() pseudocode) + */ +static void arm_set_default_fp_behaviours(float_status *s) +{ + set_float_detect_tininess(float_tininess_before_rounding, s); + set_float_2nan_prop_rule(float_2nan_prop_s_ab, s); +} + static void cp_reg_reset(gpointer key, gpointer value, gpointer opaque) { /* Reset a single ARMCPRegInfo register */ @@ -549,14 +561,11 @@ static void arm_cpu_reset_hold(Object *obj, ResetType type) set_flush_inputs_to_zero(1, &env->vfp.standard_fp_status); set_default_nan_mode(1, &env->vfp.standard_fp_status); set_default_nan_mode(1, &env->vfp.standard_fp_status_f16); - set_float_detect_tininess(float_tininess_before_rounding, - &env->vfp.fp_status); - set_float_detect_tininess(float_tininess_before_rounding, - &env->vfp.standard_fp_status); - set_float_detect_tininess(float_tininess_before_rounding, - &env->vfp.fp_status_f16); - set_float_detect_tininess(float_tininess_before_rounding, - &env->vfp.standard_fp_status_f16); + arm_set_default_fp_behaviours(&env->vfp.fp_status); + arm_set_default_fp_behaviours(&env->vfp.standard_fp_status); + arm_set_default_fp_behaviours(&env->vfp.fp_status_f16); + arm_set_default_fp_behaviours(&env->vfp.standard_fp_status_f16); + #ifndef CONFIG_USER_ONLY if (kvm_enabled()) { kvm_arm_reset_vcpu(cpu); diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc index fae6794a152..70cd3628b54 100644 --- a/fpu/softfloat-specialize.c.inc +++ b/fpu/softfloat-specialize.c.inc @@ -402,19 +402,10 @@ static int pickNaN(FloatClass a_cls, FloatClass b_cls, /* target didn't set the rule: fall back to old ifdef choices */ #if defined(TARGET_AVR) || defined(TARGET_HEXAGON) \ || defined(TARGET_RISCV) || defined(TARGET_SH4) \ - || defined(TARGET_TRICORE) + || defined(TARGET_TRICORE) || defined(TARGET_ARM) g_assert_not_reached(); -#elif defined(TARGET_ARM) || defined(TARGET_MIPS) || defined(TARGET_HPPA) || \ +#elif defined(TARGET_MIPS) || defined(TARGET_HPPA) || \ defined(TARGET_LOONGARCH64) || defined(TARGET_S390X) - /* - * ARM mandated NaN propagation rules (see FPProcessNaNs()), take - * the first of: - * 1. A if it is signaling - * 2. B if it is signaling - * 3. A (quiet) - * 4. B (quiet) - * A signaling NaN is always quietened before returning it. - */ /* * According to MIPS specifications, if one of the two operands is * a sNaN, a new qNaN has to be generated. This is done in From patchwork Fri Oct 25 14:12:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 838357 Delivered-To: patch@linaro.org Received: by 2002:adf:e287:0:b0:37d:45d0:187 with SMTP id v7csp307861wri; Fri, 25 Oct 2024 07:16:43 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVeDZ+ZgwmUKBXWE9NAj8Dpj0IZvF5MiO36dCJ1Qm4a0H9cEOwnBaBadWiaePAKx5tpJ4uMCQ==@linaro.org X-Google-Smtp-Source: AGHT+IE6SFunedQJm746gTNj1zBqUtdJMdrxJs8jU6eiY45cFM6IaYe1B69nJwG6DtrApICpcG/B X-Received: by 2002:a05:6214:5f0c:b0:6cb:f1cb:a16d with SMTP id 6a1803df08f44-6ce341cbe66mr99295726d6.9.1729865803619; Fri, 25 Oct 2024 07:16:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729865803; cv=none; d=google.com; s=arc-20240605; b=LFAZv4RwkQYO+Y1B37z6qSxND4J9k0wakPcuTr4xYWfPIAo8H7c0MXjCYTK0WYTzkS 6wsfmEtVUiGVp8+7lsruSQU1uaFqpzNJDgd6TMHUx1v/rgr5fAafcCY+4n7NlPZ0k0k8 kCIvFb2o7Dk4SU+ppLKjLZKoD9cIMKnbhEuGjn73YQv7ICPifjifFvptJHOkXvfvstd6 gn2v6XjgqR2UKRj3166/nI1PBBB6L8L7Q+eZeIO3hgTk5jpm6fj5xWHxkjc+RPtvyAaI iD9Fknjcg76HfHNh70QmCAmE4kLNDRhm44CtToVikkfFX0KmmPIG/9WLuJ99UIgZnOvX LHJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=oxpTyYZBHeinKYjs0KLdQZTFPyy0lkXjTFzf5hZbbFo=; fh=u4rpmMO8obPl4xFFQVmB6riPjTXWFThK+w5UhPBKw6M=; b=bNdWizefdxNMQVek2rlluJmWUt1rKB2W3My4lN7fzpuBhCRrz5QCG13sulY/m2C83L n7hn+Mq2N7L34LjtC782YVgSSmDfjoiosf4PN0GEW6bYzVc93S/mUM3Ixy/8V329lyuR lfJxwdCkjmrGLrV3EwT8s0R3xZvbdiuAuu5g0W6mO43AHOS01dzbQyTBoemOqjWEEw6q QFDJlMlDPz9usvdWZCRstny2agFXblGVr1TH6LHoFHXEplLnS+UUNy1ixlPzhBceQdqv O8YgDaaWyO3lZpFLyqv8PehEQt4yks/tKXQZ2ItB7JHpHoSB5RZ7Bf84VMXA2o2EwLM6 WRQQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CGBuWOgn; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6d179a44947si16395476d6.341.2024.10.25.07.16.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 25 Oct 2024 07:16:43 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CGBuWOgn; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t4L3u-00046D-RA; Fri, 25 Oct 2024 10:13:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t4L3s-00042v-4j for qemu-devel@nongnu.org; Fri, 25 Oct 2024 10:13:08 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t4L3l-0007mm-KH for qemu-devel@nongnu.org; Fri, 25 Oct 2024 10:13:07 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-431548bd1b4so20390635e9.3 for ; Fri, 25 Oct 2024 07:13:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729865580; x=1730470380; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=oxpTyYZBHeinKYjs0KLdQZTFPyy0lkXjTFzf5hZbbFo=; b=CGBuWOgnxSzMdPYu0Rqs/8R6Pw7jLtC2XSAHErJjZbnCk75QLKtNPWZlryveWc0Ile 8V0uW9QhvS1i9bzN67Xkl3k8KZAzaZVGiLeC9Uy+KEp1uJ+O88fJM9nmTi7rgAXLnYl1 TuSuikrcAK7V12/E9k6/cpFuxzbC4gHCCKr3tYZAhjvywF6djZoX+qQg7UcVzoSA0LIT DqYKreg8VrONjmnCnNcS2Prx9ZsCD6nVzgLLMxNP+S46puGCq1w4Rvmzg8648k9Ze1sR I94Z22WNprp5IfK2t0L4oZvUnmdGlM2Ok2c/JpRBN0GPWncUOSMY0zA+dCPvAiAvVkFP R7cQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729865580; x=1730470380; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oxpTyYZBHeinKYjs0KLdQZTFPyy0lkXjTFzf5hZbbFo=; b=G+B9gMOZs4tGVGMRPIb0rEzKxO0lvxZEGi4FnSyOzxDdcDDcVYkD6bAMqDp6J0aXqA 4DDb8uXwgHcey+AIL22r8rGHetFnmvNWkC+Px9AmhhNBTv9WVxu6cEx8VUYM2zOwgjJH e4NeGEBO7MraixUCuCHUIWCllPUlQjaZoCMLIox3K9JGR570uh82l31KiDyiGWNji4Bd apu37jyb0oSTNcxSTb5u3M7FpVdMs7EboSnsfAI+S7N0aKLGmXzvXaf/wqcpGnUntiU6 88S7H+x/mEDMNu20xjz5TrnGYhLG5fR6tvo56FXYvvPmpMSnlhfUjf66ib8CI+CdHGr4 F4oA== X-Forwarded-Encrypted: i=1; AJvYcCWXPWGFVi1/fCPJJs0bfVYrNA2bxGymiuoVLR3ujuTFSxM17Yf8NzDJJVt7GskVmGv0fjwCSLQWlncG@nongnu.org X-Gm-Message-State: AOJu0YyjQrWL02OHU7qXJZ6DkZYPh7IpRsJJV1D/utI4SmLWvh5MNUkR +S8GZEp3aHmLV80Vp8RcrlxMSiAY4nfvgbYBgbL3XYhLNhzc7DzK1/dDgGzGV/A= X-Received: by 2002:a05:600c:511c:b0:42f:823d:dddd with SMTP id 5b1f17b1804b1-4318423b856mr71363435e9.27.1729865580016; Fri, 25 Oct 2024 07:13:00 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4318b57b051sm50104535e9.42.2024.10.25.07.12.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 07:12:59 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Song Gao , Eduardo Habkost , "Edgar E. Iglesias" , Jiaxun Yang , Aleksandar Rikalo , Stafford Horne , Nicholas Piggin , Daniel Henrique Barboza , Yoshinori Sato , David Hildenbrand , Ilya Leoshkevich , Thomas Huth , Mark Cave-Ayland , Artyom Tarasenko , Max Filippov , qemu-ppc@nongnu.org, qemu-s390x@nongnu.org Subject: [PATCH 04/21] target/mips: Explicitly set 2-NaN propagation rule Date: Fri, 25 Oct 2024 15:12:37 +0100 Message-Id: <20241025141254.2141506-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241025141254.2141506-1-peter.maydell@linaro.org> References: <20241025141254.2141506-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x334.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Set the 2-NaN propagation rule explicitly in the float_status words we use. For active_fpu.fp_status, we do this in a new fp_reset() function which mirrors the existing msa_reset() function in doing "first call restore to set the fp status parts that depend on CPU state, then set the fp status parts that are constant". Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé --- target/mips/fpu_helper.h | 22 ++++++++++++++++++++++ target/mips/cpu.c | 2 +- target/mips/msa.c | 17 +++++++++++++++++ fpu/softfloat-specialize.c.inc | 18 ++---------------- 4 files changed, 42 insertions(+), 17 deletions(-) diff --git a/target/mips/fpu_helper.h b/target/mips/fpu_helper.h index ad1116e8c10..7c3c7897b45 100644 --- a/target/mips/fpu_helper.h +++ b/target/mips/fpu_helper.h @@ -44,6 +44,28 @@ static inline void restore_fp_status(CPUMIPSState *env) restore_snan_bit_mode(env); } +static inline void fp_reset(CPUMIPSState *env) +{ + restore_fp_status(env); + + /* + * According to MIPS specifications, if one of the two operands is + * a sNaN, a new qNaN has to be generated. This is done in + * floatXX_silence_nan(). For qNaN inputs the specifications + * says: "When possible, this QNaN result is one of the operand QNaN + * values." In practice it seems that most implementations choose + * the first operand if both operands are qNaN. In short this gives + * the following rules: + * 1. A if it is signaling + * 2. B if it is signaling + * 3. A (quiet) + * 4. B (quiet) + * A signaling NaN is always silenced before returning it. + */ + set_float_2nan_prop_rule(float_2nan_prop_s_ab, + &env->active_fpu.fp_status); +} + /* MSA */ enum CPUMIPSMSADataFormat { diff --git a/target/mips/cpu.c b/target/mips/cpu.c index 9724e71a5e0..d0a43b6d5c7 100644 --- a/target/mips/cpu.c +++ b/target/mips/cpu.c @@ -407,9 +407,9 @@ static void mips_cpu_reset_hold(Object *obj, ResetType type) } msa_reset(env); + fp_reset(env); compute_hflags(env); - restore_fp_status(env); restore_pamask(env); cs->exception_index = EXCP_NONE; diff --git a/target/mips/msa.c b/target/mips/msa.c index 61f1a9a5936..9dffc428f5c 100644 --- a/target/mips/msa.c +++ b/target/mips/msa.c @@ -49,6 +49,23 @@ void msa_reset(CPUMIPSState *env) set_float_detect_tininess(float_tininess_after_rounding, &env->active_tc.msa_fp_status); + /* + * According to MIPS specifications, if one of the two operands is + * a sNaN, a new qNaN has to be generated. This is done in + * floatXX_silence_nan(). For qNaN inputs the specifications + * says: "When possible, this QNaN result is one of the operand QNaN + * values." In practice it seems that most implementations choose + * the first operand if both operands are qNaN. In short this gives + * the following rules: + * 1. A if it is signaling + * 2. B if it is signaling + * 3. A (quiet) + * 4. B (quiet) + * A signaling NaN is always silenced before returning it. + */ + set_float_2nan_prop_rule(float_2nan_prop_s_ab, + &env->active_tc.msa_fp_status); + /* clear float_status exception flags */ set_float_exception_flags(0, &env->active_tc.msa_fp_status); diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc index 70cd3628b54..c60b999aa3d 100644 --- a/fpu/softfloat-specialize.c.inc +++ b/fpu/softfloat-specialize.c.inc @@ -402,24 +402,10 @@ static int pickNaN(FloatClass a_cls, FloatClass b_cls, /* target didn't set the rule: fall back to old ifdef choices */ #if defined(TARGET_AVR) || defined(TARGET_HEXAGON) \ || defined(TARGET_RISCV) || defined(TARGET_SH4) \ - || defined(TARGET_TRICORE) || defined(TARGET_ARM) + || defined(TARGET_TRICORE) || defined(TARGET_ARM) || defined(TARGET_MIPS) g_assert_not_reached(); -#elif defined(TARGET_MIPS) || defined(TARGET_HPPA) || \ +#elif defined(TARGET_HPPA) || \ defined(TARGET_LOONGARCH64) || defined(TARGET_S390X) - /* - * According to MIPS specifications, if one of the two operands is - * a sNaN, a new qNaN has to be generated. This is done in - * floatXX_silence_nan(). For qNaN inputs the specifications - * says: "When possible, this QNaN result is one of the operand QNaN - * values." In practice it seems that most implementations choose - * the first operand if both operands are qNaN. In short this gives - * the following rules: - * 1. A if it is signaling - * 2. B if it is signaling - * 3. A (quiet) - * 4. B (quiet) - * A signaling NaN is always silenced before returning it. - */ rule = float_2nan_prop_s_ab; #elif defined(TARGET_PPC) || defined(TARGET_M68K) /* From patchwork Fri Oct 25 14:12:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 838361 Delivered-To: patch@linaro.org Received: by 2002:adf:e287:0:b0:37d:45d0:187 with SMTP id v7csp308737wri; Fri, 25 Oct 2024 07:17:59 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWcY1QsJmcNEipi+5WuplNLuLBj7U+SyLzWtT8U4lH1VpTVKKd2EpP+x1XH5I6hAFHmtlUb1g==@linaro.org X-Google-Smtp-Source: AGHT+IGTWmNKVVv1v8XfxBEZoPi4nizf157UUb5BKzU3yBCaSU1CSocyEZgv3SvfW71qQYm8dLe7 X-Received: by 2002:a05:620a:394f:b0:7a9:c160:c80b with SMTP id af79cd13be357-7b186babf70mr856013085a.8.1729865879507; Fri, 25 Oct 2024 07:17:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729865879; cv=none; d=google.com; s=arc-20240605; b=O5TAtdSJNON7fpxJerB+N2Z9zX+Raee0AEEfXhv4C9K67fk0kReWmqv2EDhUamqeoY bXeVwEBqA2I+nmMguZnJlO9kQd3YP5ULhMyNVcj6/PXeQZIdDa89WqCSA5bbdMlaKSSi TBMcJoA7LAA3sGcwKbWYcA96TNcg+e+GGwsyHYkcJ9Bug9ptWJTnaSCG4jO1t+xRMhco RAP6VjIl8cqPuWrbgj2Bn7o7IgxxVLFVOldY9ciSoreYAQatryPrDTQYBgMAJEfWfhX8 xvRLCblwr/ku3OBVLFKrrzYgx+5HdagPH1cwhXMUjPyzeGLlzattNszUmHXezOMdBiwX +rrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=YDlbbvylJyMrU/YJShcxhMfUmai1iRbva+PhQ15qan4=; fh=mQ94+JDKCuTRZEBuBVFMAzSyfCAHcso4ihd8C6tGW+E=; b=HbiQ11QqJCU0llTOaCoes4AXhLYpmtkYfCfUO8gC0NveVelFQ5Hs1CJwm2mEdG5yAp NWXUQggLzFn2cCKB46JVCHFgOIroMCOqWOM0qGuqFlRIVDYgne2uW98zsa9/PtJcgHyL bTwyzFgBi/nBkldDFF79ilVmcQ9ry8jKR3epea+FWeEAP0xdscg53QXGU84avSJVfj5+ hLG7bflcFU+Pnst08jAzvPpom3x0erTFdvECSMN4OLyTmbWGRvM5Bm+KIAKNFEkOm4TB dA0R4Utgs2F5a4C1z9gAAdoa2U6L32+iazMcH+GwTD1o5zNqkAMuVkdUGEb7AivIBJXE MpFw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=O2s93LMA; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7b18d26b044si162153185a.52.2024.10.25.07.17.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 25 Oct 2024 07:17:59 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=O2s93LMA; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t4L3x-00048O-E9; Fri, 25 Oct 2024 10:13:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t4L3s-00042x-57 for qemu-devel@nongnu.org; Fri, 25 Oct 2024 10:13:08 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t4L3m-0007nI-CA for qemu-devel@nongnu.org; Fri, 25 Oct 2024 10:13:07 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-4315c1c7392so21121825e9.1 for ; Fri, 25 Oct 2024 07:13:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729865581; x=1730470381; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YDlbbvylJyMrU/YJShcxhMfUmai1iRbva+PhQ15qan4=; b=O2s93LMAgXPvuN0338XpNBLW0UNo2M5/Kgk+ROvEM52yyeaN5uzbmk2gYnF9lHu2Lc JDouInfGo/lSWGLNW0EqQiXo/1ZnwSUYL2+3D48lEkb0qKDNZytlqyByju9SP5TAXYWn wHsfh7G2sBpR7j6xBihiAFL13b4ug89XNOW5jTMBgVu2UovagfCoq+npfffyeEjcdGnW 1QKBwiCn0Dlctx6oLTOYZOxqZEttcN91LdKz+jblhqItmYpQzk0P47Hy6UdHx17qy4LZ N0y3MAI/1G+kHb069gIRHXrzJ1SB0rGR99wpG7SZdF4vGf8BNOHl5x+pZIloTamiL0WQ /VGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729865581; x=1730470381; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YDlbbvylJyMrU/YJShcxhMfUmai1iRbva+PhQ15qan4=; b=AFzUpNvbQjzVdq82GrTYvl1NBTvgYGr0cJtOmzuDJy2fe9yK05ZyhF/TZtTLA1WPmJ Qdqmpr5NEEz8kg9KXjswRUOGGijXA6yiClDCFXQLXOOOh1Pq/7px+5jc41YyEB42FhW/ FR441V7Tpc9oltjkefnKZY2VWtxojj+900AOQUN7B21pecwI4hqs1cxu2mlfGKYVE3RS ZPoRjuMq11LDK4kBOlotbNc4Re3HBlzOF1xXlYCK8fi9r1RvCcvMVtPcHZ3J2nDJu++P O+JtbEwpgAQrKs+NZm+YktiaQQjDOP8szqCnkhTz1JHsE4Zak/Q4IVh58VOB0UfOFzqN DiGA== X-Forwarded-Encrypted: i=1; AJvYcCUcNaRht+KrRATa1kshZL7CE3UIzImIPJCbMX9wXDii7DiICbKEB4jEMnWOqk9ipuFDUJH7SSDVmPP8@nongnu.org X-Gm-Message-State: AOJu0Yzzt223NZSYxzzJqVNlc6yYZj/ZTl5B0q6RujqB8nDYLLGqUcg5 uKmDLiDEXaJKRM2CNkxTkqEJU9y04lfB4RKovsvFOiKsVFD+POyVIRKwsSoqXbU= X-Received: by 2002:a05:600c:1c03:b0:42b:af5a:109 with SMTP id 5b1f17b1804b1-4318424eb98mr90790405e9.24.1729865580849; Fri, 25 Oct 2024 07:13:00 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4318b57b051sm50104535e9.42.2024.10.25.07.13.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 07:13:00 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Song Gao , Eduardo Habkost , "Edgar E. Iglesias" , Jiaxun Yang , Aleksandar Rikalo , Stafford Horne , Nicholas Piggin , Daniel Henrique Barboza , Yoshinori Sato , David Hildenbrand , Ilya Leoshkevich , Thomas Huth , Mark Cave-Ayland , Artyom Tarasenko , Max Filippov , qemu-ppc@nongnu.org, qemu-s390x@nongnu.org Subject: [PATCH 05/21] target/loongarch: Explicitly set 2-NaN propagation rule Date: Fri, 25 Oct 2024 15:12:38 +0100 Message-Id: <20241025141254.2141506-6-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241025141254.2141506-1-peter.maydell@linaro.org> References: <20241025141254.2141506-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x332.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Set the 2-NaN propagation rule explicitly in the float_status word we use. (There are a couple of places in fpu_helper.c where we create a dummy float_status word with "float_status *s = { };", but these are only used for calling float*_is_quiet_nan() so it doesn't matter that we don't set a 2-NaN propagation rule there.) Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/loongarch/tcg/fpu_helper.c | 1 + fpu/softfloat-specialize.c.inc | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/target/loongarch/tcg/fpu_helper.c b/target/loongarch/tcg/fpu_helper.c index f6753c5875b..21bc3b04a96 100644 --- a/target/loongarch/tcg/fpu_helper.c +++ b/target/loongarch/tcg/fpu_helper.c @@ -31,6 +31,7 @@ void restore_fp_status(CPULoongArchState *env) set_float_rounding_mode(ieee_rm[(env->fcsr0 >> FCSR0_RM) & 0x3], &env->fp_status); set_flush_to_zero(0, &env->fp_status); + set_float_2nan_prop_rule(float_2nan_prop_s_ab, &env->fp_status); } int ieee_ex_to_loongarch(int xcpt) diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc index c60b999aa3d..bbc3b70fa9d 100644 --- a/fpu/softfloat-specialize.c.inc +++ b/fpu/softfloat-specialize.c.inc @@ -402,10 +402,10 @@ static int pickNaN(FloatClass a_cls, FloatClass b_cls, /* target didn't set the rule: fall back to old ifdef choices */ #if defined(TARGET_AVR) || defined(TARGET_HEXAGON) \ || defined(TARGET_RISCV) || defined(TARGET_SH4) \ - || defined(TARGET_TRICORE) || defined(TARGET_ARM) || defined(TARGET_MIPS) + || defined(TARGET_TRICORE) || defined(TARGET_ARM) || defined(TARGET_MIPS) \ + || defined(TARGET_LOONGARCH64) g_assert_not_reached(); -#elif defined(TARGET_HPPA) || \ - defined(TARGET_LOONGARCH64) || defined(TARGET_S390X) +#elif defined(TARGET_HPPA) || defined(TARGET_S390X) rule = float_2nan_prop_s_ab; #elif defined(TARGET_PPC) || defined(TARGET_M68K) /* From patchwork Fri Oct 25 14:12:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 838354 Delivered-To: patch@linaro.org Received: by 2002:adf:e287:0:b0:37d:45d0:187 with SMTP id v7csp307197wri; Fri, 25 Oct 2024 07:15:42 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUQdJYeSI5azwPdIVYVdJDq9hJa/zPytMQ3awMnhVjXHN+GqmXXP5G5d72ONMrLqoFxp2Sa9A==@linaro.org X-Google-Smtp-Source: AGHT+IFSzG3lPb6dlqIa6+802ewSEi5H6m9omvVHNxtorOepY6wMKOdARsRx7HOm6OjYBeiFrXCN X-Received: by 2002:a05:620a:1710:b0:7a9:b021:ee6 with SMTP id af79cd13be357-7b186ba851amr663364285a.11.1729865741825; Fri, 25 Oct 2024 07:15:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729865741; cv=none; d=google.com; s=arc-20240605; b=VCY8QuVH6B2AT8UmGVL2sNA9cEVtavq6gtOKvmt95oTqjsA5B5OHyG25UfugpRLURh T0udn/+lNd1VM0kDzXwPMMgHfPEtzXoppCPlTYleGgMGKFdq2RFl8iWZCe40oRSCMann cA/BMWllOXpY2DK8QEYna40lv4He+5M6z3Uq6iNlo/j+teg25MX9uV6PGK/LfrDzjb7f nA4AG9bJuagIxFtTT9IehRkLpy9IKRQGl8e+VWUatb5HN9J6zPislKf+nCTIxQ/TVGGH /+4LJPE4xaJ37NAepTl+SQuclH6d6P4nltXBEVzYmF5L7ldlPlRIEALs8nq/mzB4By/d HUcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Zz8dlKtWuutyQ/7iCySTdzhMOZ3Vcdo7OJOwt3HomLY=; fh=Fe+YL7nD6kDYP7dFicdl7fgnCIm450CF5vkezKdttVY=; b=jhpEFxVCr1mmlXxTtzTStig9y7SelJXGDpdQtxJ5mBusDM4XGhdcLnNRde2PrNffcn 3YjbLn97YeKQv5UtDaaByFwM8GyCp/u6cdynWqARsRFw7nv1rTDfC5fd/H5DXLYPmHSU uZNGel2EujTVxRB3+bFSpUmxJRoNJPVSE5XZ2cHFx9mz3cW/yGJRQOk1TFTfMLa0kX/2 GfgS6pWYIy+z1kXsraavzsUJPLZqJlwa8wDHw9r1uIAqHzjLC/absHfX7Q24CKeEj6A+ LJW2Rzz6QIjiPLJbYTK1THiuMWPd/fVdSpRgzzT+XRONi0F3mN23mdP2+aDJ1Ht+JtRZ httg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LmZoURKW; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7b18d35a306si155793885a.584.2024.10.25.07.15.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 25 Oct 2024 07:15:41 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LmZoURKW; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t4L3x-00049J-Uq; Fri, 25 Oct 2024 10:13:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t4L3s-00044O-Uq for qemu-devel@nongnu.org; Fri, 25 Oct 2024 10:13:08 -0400 Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t4L3n-0007ns-GW for qemu-devel@nongnu.org; Fri, 25 Oct 2024 10:13:08 -0400 Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-539e63c8678so2266633e87.0 for ; Fri, 25 Oct 2024 07:13:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729865582; x=1730470382; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Zz8dlKtWuutyQ/7iCySTdzhMOZ3Vcdo7OJOwt3HomLY=; b=LmZoURKWsnnKWlhyHsn/ezI3dpOfdDbZFr1rMDgWbM8ukch1WWE6mcQ5SlQhGTOtkU smjeDVTHfMzLWv3qIR5XK+LcKCDuGZB0aucXO3qzNV/Z/AAaoiH/2uJTh1dpl6BBNn5n lKz3CL/dngeQMjRpuux5Sh8t0uems5lHeWxB0Mc1+W1ZKeYl+zAC7hLkPuwUNetZHlS7 oQUp9vscMh3AFAasKjisuPNmcX53CyoyZFoY4S+7QcpyWISP6InVhRtdFcbCJd0/SqvX eqpZc4O1PeSE26gy4ilwV9IgERpZYjnrxemtRyUP+1sjDLj4R1B5zj63Y51sRmo+MLMP SMmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729865582; x=1730470382; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Zz8dlKtWuutyQ/7iCySTdzhMOZ3Vcdo7OJOwt3HomLY=; b=GJ4sUNRKqEKc00KGO3vc8+GivWG3Cw/q0D7dfkCQ+RLKs24+5j1ANcISSMjhzASeLt 5vR4sZDq5iIGV18k1XMIMj0Z34FSVzoh7hggfzoDM1f1SpOSMR28J410c8vmYL4FUVjn Xn6wab3bw/b2yMcGdybQdD6lPzXeLDAAf4o7hLt9dFT94Hz2rcPd9VB3Rgxg0iiDKjUj kiMy+S1gG/W3pq5jLHF//no7+1ffE5heZNDaZKg3+8UNG6hkW9AyWLq3URi8sLeqxJ6z Bd5q7TVOj8r8mYWdmoF+20TyGSbx+XuiOQ0Hojchh66eLHLP6sXFs6EsEKXz+TCGDpbA MQkQ== X-Forwarded-Encrypted: i=1; AJvYcCVQc3lIPkfU4NYD77R1dzN3OSofX9z3LUIC/XBRxPrOlC6GFnB6q1YgFvVxNAk4IdMD2aFRy6NIQjPg@nongnu.org X-Gm-Message-State: AOJu0YwB0BndqXO3EZq83SRM2r74KO9Hm+ZeJZ1HYvh+ZgyRp87JGXBa kmcEuvycjMlXe/4Lg1veQx4MS2W4LUGzrReUxh66Zx8ApxM7S6C87RDYEFjPeMU= X-Received: by 2002:a05:6512:3f13:b0:52e:9cc7:4461 with SMTP id 2adb3069b0e04-53b1a2f5445mr5904378e87.5.1729865581703; Fri, 25 Oct 2024 07:13:01 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4318b57b051sm50104535e9.42.2024.10.25.07.13.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 07:13:01 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Song Gao , Eduardo Habkost , "Edgar E. Iglesias" , Jiaxun Yang , Aleksandar Rikalo , Stafford Horne , Nicholas Piggin , Daniel Henrique Barboza , Yoshinori Sato , David Hildenbrand , Ilya Leoshkevich , Thomas Huth , Mark Cave-Ayland , Artyom Tarasenko , Max Filippov , qemu-ppc@nongnu.org, qemu-s390x@nongnu.org Subject: [PATCH 06/21] target/hppa: Explicitly set 2-NaN propagation rule Date: Fri, 25 Oct 2024 15:12:39 +0100 Message-Id: <20241025141254.2141506-7-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241025141254.2141506-1-peter.maydell@linaro.org> References: <20241025141254.2141506-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::134; envelope-from=peter.maydell@linaro.org; helo=mail-lf1-x134.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Set the 2-NaN propagation rule explicitly in env->fp_status. Really we only need to do this at CPU reset (after reset has zeroed out most of the CPU state struct, which typically includes fp_status fields). However target/hppa does not currently implement CPU reset at all, so leave a TODO comment to note that this could be moved if we ever do implement reset. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/hppa/fpu_helper.c | 6 ++++++ fpu/softfloat-specialize.c.inc | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/target/hppa/fpu_helper.c b/target/hppa/fpu_helper.c index deaed2b65d1..0e44074ba82 100644 --- a/target/hppa/fpu_helper.c +++ b/target/hppa/fpu_helper.c @@ -49,6 +49,12 @@ void HELPER(loaded_fr0)(CPUHPPAState *env) d = FIELD_EX32(shadow, FPSR, D); set_flush_to_zero(d, &env->fp_status); set_flush_inputs_to_zero(d, &env->fp_status); + + /* + * TODO: we only need to do this at CPU reset, but currently + * HPPA does note implement a CPU reset method at all... + */ + set_float_2nan_prop_rule(float_2nan_prop_s_ab, &env->fp_status); } void cpu_hppa_loaded_fr0(CPUHPPAState *env) diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc index bbc3b70fa9d..4e51cf8d083 100644 --- a/fpu/softfloat-specialize.c.inc +++ b/fpu/softfloat-specialize.c.inc @@ -403,9 +403,9 @@ static int pickNaN(FloatClass a_cls, FloatClass b_cls, #if defined(TARGET_AVR) || defined(TARGET_HEXAGON) \ || defined(TARGET_RISCV) || defined(TARGET_SH4) \ || defined(TARGET_TRICORE) || defined(TARGET_ARM) || defined(TARGET_MIPS) \ - || defined(TARGET_LOONGARCH64) + || defined(TARGET_LOONGARCH64) || defined(TARGET_HPPA) g_assert_not_reached(); -#elif defined(TARGET_HPPA) || defined(TARGET_S390X) +#elif defined(TARGET_S390X) rule = float_2nan_prop_s_ab; #elif defined(TARGET_PPC) || defined(TARGET_M68K) /* From patchwork Fri Oct 25 14:12:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 838347 Delivered-To: patch@linaro.org Received: by 2002:adf:e287:0:b0:37d:45d0:187 with SMTP id v7csp306529wri; Fri, 25 Oct 2024 07:14:41 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWDBAXrusDnYYwQ0CiOGl1Lxc1QfJzLkV57Mtb27+U0hpWjflgI5o4A7KRUjjCZvlvKbY7V2g==@linaro.org X-Google-Smtp-Source: AGHT+IHcY/5+vqgnMSQIbaaLHljDdgkJlmzOnSjE2aDyCdw33UzMIVhUKJ2b4Fn3MSREqqJgZpZv X-Received: by 2002:ac8:59d3:0:b0:461:1212:c5c2 with SMTP id d75a77b69052e-461146d6743mr149593711cf.26.1729865680935; Fri, 25 Oct 2024 07:14:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729865680; cv=none; d=google.com; s=arc-20240605; b=k85JCI8R2GoIpEEkt83VSlpBczX6NlhuRmsx1gTsaZgN+Hg2Lr1ebJscxEIUItOjHD yn/7y0bwUwXlhye/N4OtrFgWmtIeRk0ciuqmfwbMX5yrYxV6FrCEuj1Xsp/393Wrtofg qixPMNV/NNsYiezsDtTJHCcystIHJnstPRAgCJmAkrUnadbbmD43NcSF5YiVU88S5YPW 54vuikxseDFW7sxxN6taMvuA1HvrC82ovh11TqgWnKWhW9XtdrWb2zihAArEtmnGwV9H +U6KNwUVcnfoOgVJuyuwouPITSEd2qc4rYubKcKwcaIVhT/sJWldPzWFNBeUjicZa+os HcMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ixfMug0zlUN7NkGJexyOs+kqoUuLgEjdmFA8bPjqRvc=; fh=C3XY52Z9mcVnQeyeWcjqrJn3izWJL/WCux1k8ARP3FU=; b=Mc2fcEgwlaJ8LYGOsZ+jMX/olyWfsHbgemCvV0CGLknQeMNA6bHWZpArGI5SGuc2ue yfvWY5ZBrXBYyFxvQT7RAZiikiqi1UlqF2MUdSh2QVBOlfrJ86nPOfd39awv2UQbds6b UpjWro+di3k3YUNnc1hbG+JSvVDVO4UN1xtN+FEBB3ppK/mnVtrxXlpOlvflQ04HlsiH uxjl7syZrXge+5wPAkXQwcLev7v2kJPA0WMbldoM+G5Ed960uaC1b8oYSx9E+rK5xppt T9HdRuc8NNIS9Dop8boFXYp/QLstdgAjJ29JOTnXg0IzKuA9v/POV44mbCpciI/FOeMz kb8w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JpVzLQtj; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-4613235db6csi16616661cf.302.2024.10.25.07.14.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 25 Oct 2024 07:14:40 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JpVzLQtj; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t4L41-0004D7-Lk; Fri, 25 Oct 2024 10:13:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t4L3u-00046L-Sz for qemu-devel@nongnu.org; Fri, 25 Oct 2024 10:13:10 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t4L3o-0007oF-4K for qemu-devel@nongnu.org; Fri, 25 Oct 2024 10:13:10 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-43163667f0eso20598895e9.0 for ; Fri, 25 Oct 2024 07:13:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729865582; x=1730470382; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ixfMug0zlUN7NkGJexyOs+kqoUuLgEjdmFA8bPjqRvc=; b=JpVzLQtjMem9QPEwwD3MqYVycr9HYRhFThvWx+Fuefmmu+UxPRnIq6zwTlOlu3H/Iv fBCDTcG81/1h6pDE/nDvb/09WFZZ2PSYXpnL4M7XwwLWbIcGqFv3mbLquuKNMhCRcs7/ 42yvrZDUe41Oj+GeGD9r1a0xSaEwCCmagyWe9Ehd6OBWVfLh/RVWKsYFwN+0/6Jaz+ui Kn2hwdJEDqwG/eBUOFeJjWKTdjbbYYsuOOGObRM/ra4NzwgTMDWKE5B2t9/G+Y2u5Vm7 qAgB9TJR6u3Rj5xi260sfhv3TegnrEDJWQgLN7gTyBvYN2gyX1TXZUNAUCx2n1x85zrF rwXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729865582; x=1730470382; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ixfMug0zlUN7NkGJexyOs+kqoUuLgEjdmFA8bPjqRvc=; b=Im2cc6sBuEq4lo+LahpVlvlA8wFP/OnWUT571MpJFGfhvAaRFhELdCv8l9z2fg2fzu t9sgWBHe0osflxmoPWPWBD0TKMQjuKUqavCk00tzkf8LohTac9z3/Cs4s03YYdhhW2Ec V/uogw1Vq1KhYbDyoDexZyHMQI+xZLdzngEjNSqng8VZAfKMF+mgyQ0w5TrQSc6oVSht HsQA9lWiXV7bCZMBVRF6fcE3nFy/JZbQnmMJgyJw/dt5pZL5DnBlCEvmaWIoQw4t7kSf lfE/uRHK9EOfThbesmipws3ek3Q9LOtdh+zquCpGcAGTo4GmYeNyq4jGlmJJlanBNbVk 9tZg== X-Forwarded-Encrypted: i=1; AJvYcCU9408XmkUjNQDR6O4Jdu6DCAVuivO5lk/F8oqJyKpnOQeNg/AGy3c03PcC6isiOq4MFmJO9ijPjiKs@nongnu.org X-Gm-Message-State: AOJu0YwtcC6qAxZOBCWdAJcsYyJ0hTcqsKAMDdbQNscx9bTLqb32jXhR P0yjJRORYu1jwyk9Aj24KjkyMBLbp66QKqsOX9NnKfsDd+ZU9DLUZEHzGmr46Kiy6dbMEcHLSlv g X-Received: by 2002:a05:600c:34d4:b0:431:5533:8f0b with SMTP id 5b1f17b1804b1-43184246647mr93646725e9.32.1729865582530; Fri, 25 Oct 2024 07:13:02 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4318b57b051sm50104535e9.42.2024.10.25.07.13.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 07:13:02 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Song Gao , Eduardo Habkost , "Edgar E. Iglesias" , Jiaxun Yang , Aleksandar Rikalo , Stafford Horne , Nicholas Piggin , Daniel Henrique Barboza , Yoshinori Sato , David Hildenbrand , Ilya Leoshkevich , Thomas Huth , Mark Cave-Ayland , Artyom Tarasenko , Max Filippov , qemu-ppc@nongnu.org, qemu-s390x@nongnu.org Subject: [PATCH 07/21] target/s390x: Explicitly set 2-NaN propagation rule Date: Fri, 25 Oct 2024 15:12:40 +0100 Message-Id: <20241025141254.2141506-8-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241025141254.2141506-1-peter.maydell@linaro.org> References: <20241025141254.2141506-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x336.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Set the 2-NaN propagation rule explicitly in env->fpu_status. Signed-off-by: Peter Maydell Reviewed-by: Ilya Leoshkevich Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- target/s390x/cpu.c | 1 + fpu/softfloat-specialize.c.inc | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index 4e41a3dff59..514c70f3010 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -205,6 +205,7 @@ static void s390_cpu_reset_hold(Object *obj, ResetType type) /* tininess for underflow is detected before rounding */ set_float_detect_tininess(float_tininess_before_rounding, &env->fpu_status); + set_float_2nan_prop_rule(float_2nan_prop_s_ab, &env->fpu_status); /* fall through */ case RESET_TYPE_S390_CPU_NORMAL: env->psw.mask &= ~PSW_MASK_RI; diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc index 4e51cf8d083..a0c740e544d 100644 --- a/fpu/softfloat-specialize.c.inc +++ b/fpu/softfloat-specialize.c.inc @@ -403,10 +403,9 @@ static int pickNaN(FloatClass a_cls, FloatClass b_cls, #if defined(TARGET_AVR) || defined(TARGET_HEXAGON) \ || defined(TARGET_RISCV) || defined(TARGET_SH4) \ || defined(TARGET_TRICORE) || defined(TARGET_ARM) || defined(TARGET_MIPS) \ - || defined(TARGET_LOONGARCH64) || defined(TARGET_HPPA) + || defined(TARGET_LOONGARCH64) || defined(TARGET_HPPA) \ + || defined(TARGET_S390X) g_assert_not_reached(); -#elif defined(TARGET_S390X) - rule = float_2nan_prop_s_ab; #elif defined(TARGET_PPC) || defined(TARGET_M68K) /* * PowerPC propagation rules: From patchwork Fri Oct 25 14:12:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 838351 Delivered-To: patch@linaro.org Received: by 2002:adf:e287:0:b0:37d:45d0:187 with SMTP id v7csp307042wri; Fri, 25 Oct 2024 07:15:29 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX1BLaft+BZs4EM30QpjSiNVCrZJy06vAQKGZthggLao9mWNIWj2jIVhFSTxQ0VdKPPM7ho+g==@linaro.org X-Google-Smtp-Source: AGHT+IH4H5gNlSZ3UcjfAmwMzY5vzbBoUrNt3e4uxVHBWle55BrhOCoP8BTe1SyZ6qWYAChwlC/H X-Received: by 2002:a05:690c:101:b0:6dd:cdb9:cf2a with SMTP id 00721157ae682-6e85814cd0bmr56050167b3.1.1729865728965; Fri, 25 Oct 2024 07:15:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729865728; cv=none; d=google.com; s=arc-20240605; b=jY1JXUkPY4K+JNlBxiZQf1TFBWv7SW7uOddVxKSbzeRn1rjN18oq+SMiIYXtj8NRUy h9OFV3crsDEmiE8rPryPKTo9ndFhbJgb2OPIJaI4BBjRNhwioiF3BRlLtdIr/kFCEJZa 4fdCH0vaeCTq9+7qBBm+78aF5/M7NcWGmjaVuuOgdYNDwtEf2RF8lCzXssViIR0j9wI0 QyvrMv7fXnwUvaXhhUqygp9KUK5rZblsDZrezHNZlpj9vMWdMzq84RmGK1qhnmkhuMov G0Way5b/K96xrdb8lOLQO+BAZnM9kci8h1rFmf6EcSbdLS1P60xbp9866x7KaAzZ1Av2 Wd9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=+dIJNAUGIBKPluHUtywmy4VA6hHxALG+WEgmCVMe7gU=; fh=xqRH/4y5qlh3n0hvmZIpqt2+MbnH5YnpHWXbjaysMcQ=; b=caE+nYHZzUiAhTzbhwAHMMeDJXCyn8K+9Ph5svo1fHGiEFyTjl5UZYjHXmzleE+Lxb 6/CLN/1ItePBLub27Yh8z+BRj8rraigXNSkqPWnuGd7a3lQ/tuKgNRhGk1yRbRWoCnGt FD6t78fxCBVPl95qQInHdeCDapUCB/qPGe99ZhgdaVn1LfAfWk95RiMH+GNighxMvMH1 i4YPa602GtfvLbSMcfmX0emMiQaRD8ECDnzA0KslKngKF1Zxd4sS+qyrc3g+BuSsL8Pl uge85rSjz+K2w+SSzmPumWfpCuBK6jdiJlXjJIy4DMLyvqnaUQugv33WHtWYQhWxgEEN YSkA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ac1bPSnc; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 00721157ae682-6e9c6968cedsi9054627b3.0.2024.10.25.07.15.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 25 Oct 2024 07:15:28 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ac1bPSnc; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t4L43-0004G8-Vk; Fri, 25 Oct 2024 10:13:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t4L3w-00047h-B5 for qemu-devel@nongnu.org; Fri, 25 Oct 2024 10:13:12 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t4L3o-0007p1-Vy for qemu-devel@nongnu.org; Fri, 25 Oct 2024 10:13:12 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-4315839a7c9so21284315e9.3 for ; Fri, 25 Oct 2024 07:13:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729865583; x=1730470383; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+dIJNAUGIBKPluHUtywmy4VA6hHxALG+WEgmCVMe7gU=; b=Ac1bPSncqcqgIIWgKjIeAPAATfd3+ryGVtkFPoIvtdFNAqeUlp8TmG0HEy1TXYHf3k jfBhHNU9PDyE4S+zqNi9cjA5FTXRve9uKqk1eB8uyQNtmWfH6KaCpWpX4ZKNVzBThRW3 R69Pye7YYIe1wHN4tZ08CqJJPoi1ubNdQ1z9klpx/JWmy5FUHiwOfIoC+EWic63bueQd tvnB4LnZDeOlW6yRSjAGXu/Mu/stZqLnvSxr1QXTCKkdM9OJJgrFv7l2/uJpCzKZbTBA gh56Ys9eMbBKcjnDEMT3N+yRej/sDSzBEGgDkQ9fJJR6yQNcgdpfiBZIBJA/ye+4QGin 9U8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729865583; x=1730470383; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+dIJNAUGIBKPluHUtywmy4VA6hHxALG+WEgmCVMe7gU=; b=lhHEsI/MXx0GpPW8Z4hRrwdLTVZWemEyFxXK/fWZ+CNdSWJnN6DqPEfmZhzhrS5qqU MLxgMJALRMoOGnhujtsjE5MOIsFndXa8bYZsm2ABPSyiFlaDdi8jtqR3zYRDylm9Iky5 jADf3R4I/enGe3NrrV+NUDrRjjmWQIIyvHQ3xTItOxTj8yn+kntxI6bR3+v0Kzq2MlTf NzCqq/kHR63uzTV7vF5slMemAeeDSyx+vJ2JR1vIq1RGzc2RKxctMi44PI2yks92FU2l pTHGpga8RYxAnT8gM8dAR2Th4l29Y0FRz2NwOXh4TlUBLNy7N8yvx869HwUkyXjcZLQ0 gxNg== X-Forwarded-Encrypted: i=1; AJvYcCW4r7SfarZE4nnZYvKSXEGAj/gsAXniy61sRwRDYc+psoAbiY+6qp3kUdhYqRnswvmVt4MDCyvfs9in@nongnu.org X-Gm-Message-State: AOJu0Yx9DPZ2YF5gYxmGAzYnqtpd2BWk3MtBmVw60iKXL/qa6eZZr8cd s7rURsAe9uY1SxpABiFzqX54z7mwcUdrO+gSAlanuzEIhJ8W3XeemqInmMpWcBA= X-Received: by 2002:a05:600c:4694:b0:431:5f55:28ad with SMTP id 5b1f17b1804b1-43191349709mr34138735e9.22.1729865583374; Fri, 25 Oct 2024 07:13:03 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4318b57b051sm50104535e9.42.2024.10.25.07.13.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 07:13:03 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Song Gao , Eduardo Habkost , "Edgar E. Iglesias" , Jiaxun Yang , Aleksandar Rikalo , Stafford Horne , Nicholas Piggin , Daniel Henrique Barboza , Yoshinori Sato , David Hildenbrand , Ilya Leoshkevich , Thomas Huth , Mark Cave-Ayland , Artyom Tarasenko , Max Filippov , qemu-ppc@nongnu.org, qemu-s390x@nongnu.org Subject: [PATCH 08/21] target/ppc: Explicitly set 2-NaN propagation rule Date: Fri, 25 Oct 2024 15:12:41 +0100 Message-Id: <20241025141254.2141506-9-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241025141254.2141506-1-peter.maydell@linaro.org> References: <20241025141254.2141506-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Set the 2-NaN propagation rule explicitly in env->fp_status and env->vec_status. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- As an aside, it looks a bit suspicious that we set tininess_before_rounding on fp_status but not vec_status... --- target/ppc/cpu_init.c | 8 ++++++++ fpu/softfloat-specialize.c.inc | 10 ++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c index 23881d09e9f..5c9dcd1f857 100644 --- a/target/ppc/cpu_init.c +++ b/target/ppc/cpu_init.c @@ -7326,6 +7326,14 @@ static void ppc_cpu_reset_hold(Object *obj, ResetType type) /* tininess for underflow is detected before rounding */ set_float_detect_tininess(float_tininess_before_rounding, &env->fp_status); + /* + * PowerPC propagation rules: + * 1. A if it sNaN or qNaN + * 2. B if it sNaN or qNaN + * A signaling NaN is always silenced before returning it. + */ + set_float_2nan_prop_rule(float_2nan_prop_ab, &env->fp_status); + set_float_2nan_prop_rule(float_2nan_prop_ab, &env->vec_status); for (i = 0; i < ARRAY_SIZE(env->spr_cb); i++) { ppc_spr_t *spr = &env->spr_cb[i]; diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc index a0c740e544d..8e3124c11a6 100644 --- a/fpu/softfloat-specialize.c.inc +++ b/fpu/softfloat-specialize.c.inc @@ -404,15 +404,9 @@ static int pickNaN(FloatClass a_cls, FloatClass b_cls, || defined(TARGET_RISCV) || defined(TARGET_SH4) \ || defined(TARGET_TRICORE) || defined(TARGET_ARM) || defined(TARGET_MIPS) \ || defined(TARGET_LOONGARCH64) || defined(TARGET_HPPA) \ - || defined(TARGET_S390X) + || defined(TARGET_S390X) || defined(TARGET_PPC) g_assert_not_reached(); -#elif defined(TARGET_PPC) || defined(TARGET_M68K) - /* - * PowerPC propagation rules: - * 1. A if it sNaN or qNaN - * 2. B if it sNaN or qNaN - * A signaling NaN is always silenced before returning it. - */ +#elif defined(TARGET_M68K) /* * M68000 FAMILY PROGRAMMER'S REFERENCE MANUAL * 3.4 FLOATING-POINT INSTRUCTION DETAILS From patchwork Fri Oct 25 14:12:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 838352 Delivered-To: patch@linaro.org Received: by 2002:adf:e287:0:b0:37d:45d0:187 with SMTP id v7csp307066wri; Fri, 25 Oct 2024 07:15:31 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXnrYgoswppR4wBVlb2vKHFZQKUnKGTSX7/xNKitsZ9jilvtqLsBIpxz+HrnejivwIErhlk+A==@linaro.org X-Google-Smtp-Source: AGHT+IERzB98pJMvMoEWGdko958jTOlcuHzk+pKjucpxIaLLV9JBEvp2e2JyVS+oJb1DY/iOJ0Um X-Received: by 2002:a05:6870:968b:b0:288:4580:e415 with SMTP id 586e51a60fabf-28ced293729mr5948224fac.15.1729865731276; Fri, 25 Oct 2024 07:15:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729865731; cv=none; d=google.com; s=arc-20240605; b=CMYJIZkJscas6PnfmC3l/1i+Ra1gdJW4ugcsf5F1L5Z3OXFs658n1q7cYdBv0fzN+C qIBkLj8FfnaqtViRBZUIOhRWIZbXwaGbMi2bDGgVIic4Ic3F34ukTRDh//wfB4SPvm5N X3hb7aA3zGV6/tZ0wWl7shz8KWNck7dB5hTeN83EC/N6mk+eR4kbZu7x5CIiIQEjOYNl isDFa0YFKydl7j42wQAgtgkfJ4K5X71Vs81I6yBP9oyPqRRZGVVNBRUBcmInkee1hR/7 zyvx91Dlub2FYDs+OzuFRXvg+TmbHJnPlah3oVY05qrAxMZJC0wC0m7OdXGp4brmwzsC CoZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=XlVlvBeEo5iy1psg/A6qK9cIHAMeC9pxkWdSURdFSQg=; fh=3ZNg44Eotz2wa2LcEexmV5yWfDiu5k/A1QNviFjjaFU=; b=Qu/f1Sj0APVe8GNWRCChmFvMvuGX4/aqUMpWhpYQpXBOYRsZd/Sy/HLgGWsujCKuin El4hofVpW3ARAss+f2QRvk6L0SjtfL//KLL4sS/BwWMT5rC/jFl+bz6XAzv6NAbb1qln vshxV5Frzej0Dwy8kkqcFJCYNkHTpOtjOfvWTb73jFAX53mXKQBbfJHqA9mbUxCD5g2E OMmzDc8dVx5KXBTBYiMsqKlf9DMNzRGWDckwsM9q19QdaK+Q0BdHu9qs+dUV4Cm6KhUc h211+iRxr/ghL3/r5NKeZ1NWkvNPjt26RD4y7wkvZP1qj9zu/cZkkB986lLhx5GMZKXM OcCw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Bj8wxhAm; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-46132113c71si15262531cf.145.2024.10.25.07.15.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 25 Oct 2024 07:15:31 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Bj8wxhAm; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t4L42-0004FG-Un; Fri, 25 Oct 2024 10:13:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t4L3x-00049G-Qn for qemu-devel@nongnu.org; Fri, 25 Oct 2024 10:13:13 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t4L3p-0007pT-Sz for qemu-devel@nongnu.org; Fri, 25 Oct 2024 10:13:13 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-431695fa98bso20341415e9.3 for ; Fri, 25 Oct 2024 07:13:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729865584; x=1730470384; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XlVlvBeEo5iy1psg/A6qK9cIHAMeC9pxkWdSURdFSQg=; b=Bj8wxhAm9lpUJ1fIxmemV7A4Fhlzh6VxATJrSopcjMESDHrrWek+eh+R60432Qui77 I7+BvAPgiD/BJqkOMReTZ77j1yhCCpcsSU0/iAzE3AI10kYAje5qerfdZh7WhIBC6CZD wX7S6y86FwJ4w6gq7pl6e4jfaWTAHuh831DhRn+GEun/mesvE74+F66eyvv37bcOnd6C qEtNxBk380xAreFiLfRkU/QwRZpTR7sJgsAjlRaF2GbTIm8PMZasS5+BzHgZVvuoqLl3 FLVIuNPmmzXERchBoxiJRJFsg477wo6s5LBuCcnfgT8USyaEj5sCrgELo9Cvl28sCTDU uOOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729865584; x=1730470384; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XlVlvBeEo5iy1psg/A6qK9cIHAMeC9pxkWdSURdFSQg=; b=ghywnIFnV2NnppBQWlNjt91EIqD/LrAe975h3FP3BqJKiJa5YX4yNuEs5Sb8e1cwio 1Nx0tUr4Plxn80MOvhrvX7p0ZvBUgVRuKoBOfoDbZbUIzSUnrwvix6NFIgfDKg6921kl ZDvYwDvQqaR1fq5PQ6nCjRR9ux4MAhBOiPzqvkE3zaFod8/8f1moE7+68zdkRpKDEagq Exdx8k1jkUfzgz8T9xhLwEi7zK5X5krYtCs4LNKoF01BtvT3aRRaldPisNfZ8W7Zpg95 RSrfZlaBcyGgQLFHdT/S5bJ0dOKVh5iYJh1Ii5nHzZ1p42FOofvdMu1OX6T8Sz8zoZ7j 14HQ== X-Forwarded-Encrypted: i=1; AJvYcCUyHgj+gulJuU60iHK1UK3hXsbD26mQta/t5PBwGpzrEM+VudOCwSF+mNc0M9mrLdmcvVGEOwaxozxC@nongnu.org X-Gm-Message-State: AOJu0YyWcpM4JDmdeUbf7V0nRizzzywqwagI506FCcXyOnzPEn+ZbtdZ WudpqSE3/WXSHf8cbu8mtiW9xcUMRDqhuC067ce9fUkIJZq/QyrNkuu10HXnFHM= X-Received: by 2002:a05:600c:34cb:b0:430:5760:2fe with SMTP id 5b1f17b1804b1-4318c73947emr54557345e9.22.1729865584260; Fri, 25 Oct 2024 07:13:04 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4318b57b051sm50104535e9.42.2024.10.25.07.13.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 07:13:03 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Song Gao , Eduardo Habkost , "Edgar E. Iglesias" , Jiaxun Yang , Aleksandar Rikalo , Stafford Horne , Nicholas Piggin , Daniel Henrique Barboza , Yoshinori Sato , David Hildenbrand , Ilya Leoshkevich , Thomas Huth , Mark Cave-Ayland , Artyom Tarasenko , Max Filippov , qemu-ppc@nongnu.org, qemu-s390x@nongnu.org Subject: [PATCH 09/21] target/m68k: Explicitly set 2-NaN propagation rule Date: Fri, 25 Oct 2024 15:12:42 +0100 Message-Id: <20241025141254.2141506-10-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241025141254.2141506-1-peter.maydell@linaro.org> References: <20241025141254.2141506-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x331.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Explicitly set the 2-NaN propagation rule on env->fp_status and on the temporary fp_status that we use in frem (since we pass that to a division operation function). Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Signed-off-by: Peter Maydell --- target/m68k/cpu.c | 16 ++++++++++++++++ target/m68k/fpu_helper.c | 1 + fpu/softfloat-specialize.c.inc | 19 +------------------ 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c index 1d49f4cb238..5fe335558aa 100644 --- a/target/m68k/cpu.c +++ b/target/m68k/cpu.c @@ -93,6 +93,22 @@ static void m68k_cpu_reset_hold(Object *obj, ResetType type) env->fregs[i].d = nan; } cpu_m68k_set_fpcr(env, 0); + /* + * M68000 FAMILY PROGRAMMER'S REFERENCE MANUAL + * 3.4 FLOATING-POINT INSTRUCTION DETAILS + * If either operand, but not both operands, of an operation is a + * nonsignaling NaN, then that NaN is returned as the result. If both + * operands are nonsignaling NaNs, then the destination operand + * nonsignaling NaN is returned as the result. + * If either operand to an operation is a signaling NaN (SNaN), then the + * SNaN bit is set in the FPSR EXC byte. If the SNaN exception enable bit + * is set in the FPCR ENABLE byte, then the exception is taken and the + * destination is not modified. If the SNaN exception enable bit is not + * set, setting the SNaN bit in the operand to a one converts the SNaN to + * a nonsignaling NaN. The operation then continues as described in the + * preceding paragraph for nonsignaling NaNs. + */ + set_float_2nan_prop_rule(float_2nan_prop_ab, &env->fp_status); env->fpsr = 0; /* TODO: We should set PC from the interrupt vector. */ diff --git a/target/m68k/fpu_helper.c b/target/m68k/fpu_helper.c index 8314791f504..a605162b71f 100644 --- a/target/m68k/fpu_helper.c +++ b/target/m68k/fpu_helper.c @@ -620,6 +620,7 @@ void HELPER(frem)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1) int sign; /* Calculate quotient directly using round to nearest mode */ + set_float_2nan_prop_rule(float_2nan_prop_ab, &fp_status); set_float_rounding_mode(float_round_nearest_even, &fp_status); set_floatx80_rounding_precision( get_floatx80_rounding_precision(&env->fp_status), &fp_status); diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc index 8e3124c11a6..226632a4d10 100644 --- a/fpu/softfloat-specialize.c.inc +++ b/fpu/softfloat-specialize.c.inc @@ -404,25 +404,8 @@ static int pickNaN(FloatClass a_cls, FloatClass b_cls, || defined(TARGET_RISCV) || defined(TARGET_SH4) \ || defined(TARGET_TRICORE) || defined(TARGET_ARM) || defined(TARGET_MIPS) \ || defined(TARGET_LOONGARCH64) || defined(TARGET_HPPA) \ - || defined(TARGET_S390X) || defined(TARGET_PPC) + || defined(TARGET_S390X) || defined(TARGET_PPC) || defined(TARGET_M68K) g_assert_not_reached(); -#elif defined(TARGET_M68K) - /* - * M68000 FAMILY PROGRAMMER'S REFERENCE MANUAL - * 3.4 FLOATING-POINT INSTRUCTION DETAILS - * If either operand, but not both operands, of an operation is a - * nonsignaling NaN, then that NaN is returned as the result. If both - * operands are nonsignaling NaNs, then the destination operand - * nonsignaling NaN is returned as the result. - * If either operand to an operation is a signaling NaN (SNaN), then the - * SNaN bit is set in the FPSR EXC byte. If the SNaN exception enable bit - * is set in the FPCR ENABLE byte, then the exception is taken and the - * destination is not modified. If the SNaN exception enable bit is not - * set, setting the SNaN bit in the operand to a one converts the SNaN to - * a nonsignaling NaN. The operation then continues as described in the - * preceding paragraph for nonsignaling NaNs. - */ - rule = float_2nan_prop_ab; #elif defined(TARGET_SPARC) /* Prefer SNaN over QNaN, order B then A. */ rule = float_2nan_prop_s_ba; From patchwork Fri Oct 25 14:12:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 838350 Delivered-To: patch@linaro.org Received: by 2002:adf:e287:0:b0:37d:45d0:187 with SMTP id v7csp306963wri; Fri, 25 Oct 2024 07:15:23 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVAP4imlbKy1MY29OtWoOEIpspGNhtr35i5AEfV7BIDbZRE8Ii73FKxLnwO1ZGqTeTaSC5+Cg==@linaro.org X-Google-Smtp-Source: AGHT+IH/+ZZG5k2C6wFPcw9qgcLlF0flEepFrB0Wln2ogXGoAO7KU220k9iIFDGzCHUnVwDLX4KT X-Received: by 2002:a05:6214:4699:b0:6cb:cc5e:1bcf with SMTP id 6a1803df08f44-6d08e4513d9mr67499846d6.21.1729865723348; Fri, 25 Oct 2024 07:15:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729865723; cv=none; d=google.com; s=arc-20240605; b=knkfVXo1EAR2I0whmJgzLYS0l9xiTVoULfvU7atpYPEwj8R3E5DB0/oSYrqvFZ13iX zV8U6eRUfElIMzMD/u4mnY4Gii6QAWEl8xlWxl+1wo1ZkCTk+LnHOjTwHJOc1ZURiipb Mv8GvUWttPJvLhkMlXjHRRKBCSv2o7+iunKoME521KjvgfMxZqCEK/rVmxsKh5nS2y4U 7dS2frfmg0wLeAcE+Pq06ZtFEQ/cYwDjiORfU546JuVPofCAnln/qAnG50LlOx7CDLkH noiv7gxROTWLTEnVNlgaZAJzrJLeA3ozJj4JgQs7p6B0Lof0N6VxSULGDwvR/NrztMEU H7WQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=LWQTkVIYoMx387TeXW3tDVaYyEBBg7QXyfQFYBePRB4=; fh=d9x+uGGdAftYVoq79a6m5bVRHokqdNEmsJOWNC+K978=; b=JYpFCGotVNz00bMwprfGH+MOmM+F3YmhPsnmsx1kwdoR2pCenJkfRuqlvND0JmyLAA XXkKsTLx5KgErBOW4vi+ngCW03b0P0fL+3TCh7C0biPjfXGEEMGA3CMInyQ3PA4gfo6Q RrmJ6t0fLigwaHiQT4+DSDpcY0679QxyRgOcSCbuFXXDWTsF3FEGn6w5cBA7JOZw5vCo CgoBVGXssq71h3eKcG3VR/jUeshqAQx9u8ZbFgQdKRez6iQY71777FTRbUVwlLuT00sF 0pm2LU9FGhF0F4DgP1L8MNS3fnf18QJWDEH9gAk1BTwdG7ywuLoNCnly4ZMiGwMrtriV Q9QA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lkAQl2ea; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6d179a7dab3si16534266d6.436.2024.10.25.07.15.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 25 Oct 2024 07:15:23 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lkAQl2ea; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t4L3z-0004C7-VB; Fri, 25 Oct 2024 10:13:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t4L3y-0004A7-DH for qemu-devel@nongnu.org; Fri, 25 Oct 2024 10:13:14 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t4L3q-0007pw-F8 for qemu-devel@nongnu.org; Fri, 25 Oct 2024 10:13:14 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-431695fa98bso20341545e9.3 for ; Fri, 25 Oct 2024 07:13:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729865585; x=1730470385; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LWQTkVIYoMx387TeXW3tDVaYyEBBg7QXyfQFYBePRB4=; b=lkAQl2earbkay8EYGVF02u13RWSiTiD0htE/yj8EOZ8ReUAM4/U91P8KDfFobko5la CPrcz2i3MdCG0iZCkI5mmv9xZZaeRB1FHD/Rsn72T4WFWyOwZkCkGVj/HNXYXEvC+RZd AtGE9Elskx0r4978Zhm2KD1y4NvCbuJ7sTd4hRgOsPH/OL++YSb8k2DlAfsu6TIlC+FT tURhSW9NsqeNVeu9JezMvxUCl5+iPTPUPdV25YCUBgqAQyWaZUr6FF9ZIZCOHwPv9rjd EJkMTY3EXCxgE6lV9x0oVPwSzFtBe2a9SbmrFhKpkN8zubZB+IbvU8uxzCcd3IxilvhE cLoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729865585; x=1730470385; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LWQTkVIYoMx387TeXW3tDVaYyEBBg7QXyfQFYBePRB4=; b=SBblkma8woPJpjgtVxCa3cWGQ9EJmQt//vjqgTAHIQerb35NuNlhNSd1IpnZJsV/SL rIG8Vm8IFlVavYPOVrAAZ60wU1jhNJEme8zlhsrGKJoZLyX9NBdZ73U4kReRe1E3Yjy2 eyLXrnBDEgwTQVWMae71mk6jme0RzTeLThIAvZIGHKudCdj/cqywmEVwOijqz8bGQ6JL B5Kfb3E5aob05qvgWDnENYW6HqD4gj7vvNLSH2vWKkY1Yrm8JVhfxWACZkF6qkyaK4rx N8/G4e2MuVUE0/8BpdfRyZsDJ4EdRbg+rlwFdEw/O1vYxS+qG6A138rk4uvD+hD6cVgk cuIw== X-Forwarded-Encrypted: i=1; AJvYcCWeplKb4XgcXcaaj5ZOTvdXBFBmJo0sUWeNO2H9Sas8RnrbucSbUKvO5ztY2ZX3T5D4FlT7/gUdfZjW@nongnu.org X-Gm-Message-State: AOJu0YzmlymYcBmwiN48qA+9evGUE0zGT75LmKgwKL9VHp4UWKU780Dk 0lvPmhAjj4Mxq1fFenzTd9N35p0MwPdLJcbCdV+CxmCV6bOayTrwG9NvzxEA4rg= X-Received: by 2002:a05:600c:6d19:b0:425:7bbf:fd07 with SMTP id 5b1f17b1804b1-4318c8cd0bamr52618515e9.5.1729865585055; Fri, 25 Oct 2024 07:13:05 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4318b57b051sm50104535e9.42.2024.10.25.07.13.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 07:13:04 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Song Gao , Eduardo Habkost , "Edgar E. Iglesias" , Jiaxun Yang , Aleksandar Rikalo , Stafford Horne , Nicholas Piggin , Daniel Henrique Barboza , Yoshinori Sato , David Hildenbrand , Ilya Leoshkevich , Thomas Huth , Mark Cave-Ayland , Artyom Tarasenko , Max Filippov , qemu-ppc@nongnu.org, qemu-s390x@nongnu.org Subject: [PATCH 10/21] target/m68k: Initialize float_status fields in gdb set/get functions Date: Fri, 25 Oct 2024 15:12:43 +0100 Message-Id: <20241025141254.2141506-11-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241025141254.2141506-1-peter.maydell@linaro.org> References: <20241025141254.2141506-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x333.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org In cf_fpu_gdb_get_reg() and cf_fpu_gdb_set_reg() we use a temporary float_status variable to pass to floatx80_to_float64() and float64_to_floatx80(), but we don't initialize it, meaning that those functions could access uninitialized data. Zero-init the structs. (We don't need to set a NaN-propagation rule here because we don't use these with a 2-argument fpu operation.) Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- Spotted by code-inspection while I was doing the 2-NaN propagation patches. --- target/m68k/helper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/m68k/helper.c b/target/m68k/helper.c index 9d3db8419de..9bfc6ae97c0 100644 --- a/target/m68k/helper.c +++ b/target/m68k/helper.c @@ -36,7 +36,7 @@ static int cf_fpu_gdb_get_reg(CPUState *cs, GByteArray *mem_buf, int n) CPUM68KState *env = &cpu->env; if (n < 8) { - float_status s; + float_status s = {}; return gdb_get_reg64(mem_buf, floatx80_to_float64(env->fregs[n].d, &s)); } switch (n) { @@ -56,7 +56,7 @@ static int cf_fpu_gdb_set_reg(CPUState *cs, uint8_t *mem_buf, int n) CPUM68KState *env = &cpu->env; if (n < 8) { - float_status s; + float_status s = {}; env->fregs[n].d = float64_to_floatx80(ldq_be_p(mem_buf), &s); return 8; } From patchwork Fri Oct 25 14:12:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 838353 Delivered-To: patch@linaro.org Received: by 2002:adf:e287:0:b0:37d:45d0:187 with SMTP id v7csp307127wri; Fri, 25 Oct 2024 07:15:36 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXpsCojlPImoLIQ+jWhV3b493OJQqzO8fe8GTm4o4Aqxv7j/5rlnyKLhgBlGaAEXJnRaQKD3Q==@linaro.org X-Google-Smtp-Source: AGHT+IG9Hjg9OY6AMr8P0OMDfAKmP+m/3SGnUSUl4pxqy4E7nF1T+4QTDF89kS2mZ/00qaWOj9uM X-Received: by 2002:a05:622a:11c8:b0:460:b18c:ace8 with SMTP id d75a77b69052e-4612527ec8dmr90695591cf.21.1729865736417; Fri, 25 Oct 2024 07:15:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729865736; cv=none; d=google.com; s=arc-20240605; b=TxCXm5JiLO8HTz1h+1MCAwmMVFnIhdNIAZgpSUz26NlbsjMIhwvm4bokd/J32hSzPC 5CHICFYloXSULzKiBahIxCuPmF5Afo2Bc5t4CeTf+WJlBqVDqmbMS0It9Uq7Fn4482i2 aAtdYJUuVUT5E8xM5xiUXgVPQaWxIJ7JY6hkzZATpTj2LJ6yIADtrfvs66NdAA7KoL3Q /q2VvF0x1OdPNRxvfbwy3Z2zt4IRo9z49l99r1f9lWefLf18HkiBCwm3AjyCQf4tHHiU Dz5o8i6u1vMgFWEgzmRbTNP1psRfxtJa8MGFP29POxHOKxdgIXFDyjV2EmxNHXnsQ2Ma NYQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=jjOM3QYK37qULOvoMpKikOAGRTQIulU/PhbW7+12E+A=; fh=64gpealoCRGuULYQvYhQXBcu541pJjD0mWCvOBWjdgY=; b=cFTVAGtEu74QSS9OtNYKqMfNu4bfzbv2vW1Dk0DlSRR30py+w2VZNeDWQwx8enguQw 4ouZuXY/6XF7cZob/62wV67vto/JeJuE2FaeNLTCwARLK1RV5JdQMw44y6stJvCx7rog rc5UHNaV88/omnAxLkjSVg9OSRf3OiixukINUEtqYx4oxFsPXfnaono62U3eFYRz1tQ4 NII9GPisduiNYaLyoiC+rzJHyO8tQGagLobbtMIg1ygH7OlYyyxtC8PPmXAebUK+hRYH vE01zP+xV79cUSpu+HJ69Sp1wdObOzheaWePVr+dYkaoRxc8BJYvWkI5fl39sqzXq2eX pizg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="CLdBiU/1"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-4613238e1a8si14616421cf.474.2024.10.25.07.15.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 25 Oct 2024 07:15:36 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="CLdBiU/1"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t4L43-0004Fb-2f; Fri, 25 Oct 2024 10:13:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t4L3z-0004C3-Np for qemu-devel@nongnu.org; Fri, 25 Oct 2024 10:13:15 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t4L3r-0007qa-TS for qemu-devel@nongnu.org; Fri, 25 Oct 2024 10:13:15 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-4315abed18aso20415545e9.2 for ; Fri, 25 Oct 2024 07:13:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729865586; x=1730470386; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jjOM3QYK37qULOvoMpKikOAGRTQIulU/PhbW7+12E+A=; b=CLdBiU/1Fe8HGeL5xo32mAHXZwY5KCAkRLjHEkm3BRA+m/gnZH6OHrvtNw7cziYpaV b0cp29vrbJL8opXePKe9Fsqy20IZpfaGVEh8Sosq/1fBUW+Mrrds6xLlARLRBlDFht8k LW/2kU35JWF4kHP6tpf4cFzCUlFuGZMCMJfINohy8W18Ry5NBbhJuzpipdgcQW3BPdoP uzFxmaPHwuiHNEQjVyUhdQ7OPjS14voWjtPZOMMkX6ZPM4Y/fYMw+2IyaRy2TCiVCUSb +EHo2chM0Paf9j1pJbx63PPimIkkwzi6l7Wu2mRGoIpvFonGSbSRnaKb5H2uU/BkXj4z fpDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729865586; x=1730470386; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jjOM3QYK37qULOvoMpKikOAGRTQIulU/PhbW7+12E+A=; b=OiDYAz7qfheGe/MialAtHQN5Z3oQIRM42B2Qd1zPYg9E85AhBASCEWccyXvchpVxFR EsqEYr6M9m+ZgGh2c8PdfrV/smAay8tJ5cSNn6j9L9O5MW4FTyz6GTEwSTFBLgKOq3Hp D+s934GE9pcJZ9nK98DyMKekQ/yhBYVTxs+4PKfP+tDYPjbcwv9i3ADqLpJyRyJjP+m8 G/jrN80OYphzA3daWc+nZUzYNtPC4foHK90J2gjlwoMizqUgkZrdOnaQScG4VL6bG3cY 2t5pFBg5YhAQwpstgpnCVAMQ2LQlionQO02eESHdISr/tqKMMdjsi8wjmBVH65SzXEwn NWdg== X-Forwarded-Encrypted: i=1; AJvYcCV+PCrGbRhb6/SU/oyXd3jdEgBCjOer0liX/AvZmr70u+kJtaDBf108U83I+XLu4JpU4p/ACpe1sHAQ@nongnu.org X-Gm-Message-State: AOJu0Yy3pifFiUffbmSPimsgarB/OV2JGhoFZKAoBvTfr8dmarvwxu7l c9xSu3hNdY9PkNlVHITmQxYrPFShSOIJ7u8jh3hKZm/VSIOXZWrNOQ92T7uB/zs= X-Received: by 2002:a05:600c:5118:b0:431:3a6d:b84a with SMTP id 5b1f17b1804b1-431841e12cdmr75651695e9.4.1729865585974; Fri, 25 Oct 2024 07:13:05 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4318b57b051sm50104535e9.42.2024.10.25.07.13.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 07:13:05 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Song Gao , Eduardo Habkost , "Edgar E. Iglesias" , Jiaxun Yang , Aleksandar Rikalo , Stafford Horne , Nicholas Piggin , Daniel Henrique Barboza , Yoshinori Sato , David Hildenbrand , Ilya Leoshkevich , Thomas Huth , Mark Cave-Ayland , Artyom Tarasenko , Max Filippov , qemu-ppc@nongnu.org, qemu-s390x@nongnu.org Subject: [PATCH 11/21] target/sparc: Move cpu_put_fsr(env, 0) call to reset Date: Fri, 25 Oct 2024 15:12:44 +0100 Message-Id: <20241025141254.2141506-12-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241025141254.2141506-1-peter.maydell@linaro.org> References: <20241025141254.2141506-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Currently we call cpu_put_fsr(0) in sparc_cpu_realizefn(), which initializes various fields in the CPU struct: * fsr_cexc_ftt * fcc[] * fsr_qne * fsr It also sets the rounding mode in env->fp_status. This is largely pointless, because when we later reset the CPU this will zero out all the fields up until the "end_reset_fields" label, which includes all of these (but not fp_status!) Move the cpu_put_fsr(env, 0) call to reset, because that expresses the logical requirement: we want to reset FSR to 0 on every reset. This isn't a behaviour change because the fields are all zero anyway. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Mark Cave-Ayland Reviewed-by: Richard Henderson --- target/sparc/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c index 54cb269e0af..e7f4068a162 100644 --- a/target/sparc/cpu.c +++ b/target/sparc/cpu.c @@ -76,6 +76,7 @@ static void sparc_cpu_reset_hold(Object *obj, ResetType type) env->npc = env->pc + 4; #endif env->cache_control = 0; + cpu_put_fsr(env, 0); } #ifndef CONFIG_USER_ONLY @@ -805,7 +806,6 @@ static void sparc_cpu_realizefn(DeviceState *dev, Error **errp) env->version |= env->def.maxtl << 8; env->version |= env->def.nwindows - 1; #endif - cpu_put_fsr(env, 0); cpu_exec_realizefn(cs, &local_err); if (local_err != NULL) { From patchwork Fri Oct 25 14:12:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 838356 Delivered-To: patch@linaro.org Received: by 2002:adf:e287:0:b0:37d:45d0:187 with SMTP id v7csp307311wri; Fri, 25 Oct 2024 07:15:49 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWceixB0pWVUAu6k/SYGpl1SJ6bKH+Qo1zJ6wPDIJUtb1Ja27rRbGnUO6zr9h6eOm6xjBhFmg==@linaro.org X-Google-Smtp-Source: AGHT+IFqjqXbLd5agTiUzO7XcQAUOGu5VVqo8RnqXEybvpPS+ym9c0T8rdutps3G0WtWyPtusc2z X-Received: by 2002:a05:622a:5e8d:b0:461:313e:8868 with SMTP id d75a77b69052e-461313e90acmr26307231cf.50.1729865749381; Fri, 25 Oct 2024 07:15:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729865749; cv=none; d=google.com; s=arc-20240605; b=Xwmh6XPbG6b5+wEfQ0uoCtkbCd+0AjNyrm4QkIPEB/yxc13c/QDTiEn4I9L4gD+yJR PlaD3bJ3zyBBKbyjMtNHdSm3kXNpDdeVHZUTFvabnx26WW0oy2QZFOtL8aovHGvDJIA9 vETrJ0yiZ1Tsj5+X9gdO4gKopzIjrqCbeFUUPL3cPw9V5JSeB3/kFubxQ0SlECcnkWfm UbeLANgx0tt8dtqQCLqPHvAVN2OrEv5BVCRdNeXB7SQxDCh8hRXkwnuEPguQBYk+/0eI gqB2aHhd0uSYLwpBgyke2WNYRPTRP//3p5AxjgqbLFGXCNPBmtoLxTN/6gl207Cup/nb Speg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=+3N7Gh5ykD6QxUXP4fouNsk3DmkKRJ2QzcoWCfXISHI=; fh=lE7h1vrW5a8oxdabg5SgU/Odeje4uRFv/TXwCnaDUiE=; b=RjKl2nFdbfcQXPTYieTt3qeNx5Vvb6xAfoelm1EgkdO1IeE0YFEsmp39/T9XdHf+S0 qrMTi7+nD+/Vsm53J/VUOZxBfNTYyxRSvhYW0yEJo5sgfC0ulEVvocGzVEWZT113ShKG JNE4JFdx/CNj2/ktrRHtNCUMs3wXPuR7ugy8H8fOjDPX568t98N0ui7oeVPfA+sK5iMm aMnOVuvVhJ5SkB3kZ3u+YWZuDdbjFL79VwNBOUjYEfUUgtESVrW8Jg5/mDvq/ovMH/Ig 5Me/dTq1knDcm0aJjYdVj+1qKBb1w8ildwEIwPZd51qNFN9dhAuq3VvXjgZKDsb9tbON TwRg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VkHiDTtk; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-4613211374esi14810171cf.112.2024.10.25.07.15.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 25 Oct 2024 07:15:49 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VkHiDTtk; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t4L47-0004Kn-Dd; Fri, 25 Oct 2024 10:13:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t4L40-0004Cj-GN for qemu-devel@nongnu.org; Fri, 25 Oct 2024 10:13:16 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t4L3s-0007qw-Iq for qemu-devel@nongnu.org; Fri, 25 Oct 2024 10:13:16 -0400 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-37d41894a32so1613395f8f.1 for ; Fri, 25 Oct 2024 07:13:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729865587; x=1730470387; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+3N7Gh5ykD6QxUXP4fouNsk3DmkKRJ2QzcoWCfXISHI=; b=VkHiDTtkl6/xjD7vf7wRv6vPMshw+ZerzlexMzsF9ivpAYZdnYNEmlD5fYaA1UivxW 2EppflRwN20n291OyRg4MJcQTdRfD47bHJECxXK4LRCht5gCnfrWXE+qEcp+qW6pyfd1 k+NJB5/hfscgXIxmGdRVVaYA/HDNHWWmwTztGUpC+5jgT9xPgv4B0hYPNCf1dC8pW4Pb xKpAKpzvanmJJ++seOIv2/o7VS3uirtsMw+yJWmV1VRD8GKYJO2PoTLvcDNiuMIL8wEo OosJYc0baW5VNq64Unsux3tE6P9ya706IOffWX23HlAcfpuz03NFFMBkNFPmPkN+s15k +5HQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729865587; x=1730470387; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+3N7Gh5ykD6QxUXP4fouNsk3DmkKRJ2QzcoWCfXISHI=; b=A0e4RCdeTvWclCIsL0nVOQq6r/4iyFCkgCSeU+5mbGd25MLJckMFw30V6sEaY5vk40 1QHAVO2NjB53pLu6v2e5Tm2IJ8h42iR3f6OhrGYHTu743D+fiq6a0oBVkfe7NGdp5xGJ LVXh6sQumMubWRb5qFon16whyHGuXZ7LYB+yHOCUBMDsGWy1APpAfroTHyzOxG6kX3n+ lzE2XWQVl+Cd+ENCTVtA/QD5ytUc+qW9fw299E7jzO0PppucvWU6Je78kmM/3sUvmy+/ r/Wi4iGnMtU4J6HyZohHV1WsqLRWie3O/3kOtLuKI4RTID0760aMVHCR+2rIezhmEgEC l5Zg== X-Forwarded-Encrypted: i=1; AJvYcCUWgz9ITntkNMX3jUDSb1ASV59LbrVvwqWSWFs+PmaRaJ7b93CZnUMSXa4x2keKUMS0ORl6jLt3SG0E@nongnu.org X-Gm-Message-State: AOJu0Yz7zhoMH9i0d/3DqoYwlRrvjpoJF6TVCKL2ZRQpemZJO98myL+7 V+EwNDWUFYLz14f26bI4WsPwLWOrfFH4qV4ftfFhtdSTPZdIVW5Ynv6ctN0NdZc= X-Received: by 2002:a05:6000:d0b:b0:374:bd00:d1e with SMTP id ffacd0b85a97d-3803abc2879mr4856955f8f.3.1729865586918; Fri, 25 Oct 2024 07:13:06 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4318b57b051sm50104535e9.42.2024.10.25.07.13.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 07:13:06 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Song Gao , Eduardo Habkost , "Edgar E. Iglesias" , Jiaxun Yang , Aleksandar Rikalo , Stafford Horne , Nicholas Piggin , Daniel Henrique Barboza , Yoshinori Sato , David Hildenbrand , Ilya Leoshkevich , Thomas Huth , Mark Cave-Ayland , Artyom Tarasenko , Max Filippov , qemu-ppc@nongnu.org, qemu-s390x@nongnu.org Subject: [PATCH 12/21] target/sparc: Explicitly set 2-NaN propagation rule Date: Fri, 25 Oct 2024 15:12:45 +0100 Message-Id: <20241025141254.2141506-13-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241025141254.2141506-1-peter.maydell@linaro.org> References: <20241025141254.2141506-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x434.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Set the NaN propagation rule explicitly in the float_status words we use. Signed-off-by: Peter Maydell Acked-by: Mark Cave-Ayland Reviewed-by: Richard Henderson --- target/sparc/cpu.c | 8 ++++++++ target/sparc/fop_helper.c | 10 ++++++++-- fpu/softfloat-specialize.c.inc | 6 ++---- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c index e7f4068a162..dd7af86de73 100644 --- a/target/sparc/cpu.c +++ b/target/sparc/cpu.c @@ -26,6 +26,7 @@ #include "hw/qdev-properties.h" #include "qapi/visitor.h" #include "tcg/tcg.h" +#include "fpu/softfloat.h" //#define DEBUG_FEATURES @@ -807,6 +808,13 @@ static void sparc_cpu_realizefn(DeviceState *dev, Error **errp) env->version |= env->def.nwindows - 1; #endif + /* + * Prefer SNaN over QNaN, order B then A. It's OK to do this in realize + * rather than reset, because fp_status is after 'end_reset_fields' in + * the CPU state struct so it won't get zeroed on reset. + */ + set_float_2nan_prop_rule(float_2nan_prop_s_ba, &env->fp_status); + cpu_exec_realizefn(cs, &local_err); if (local_err != NULL) { error_propagate(errp, local_err); diff --git a/target/sparc/fop_helper.c b/target/sparc/fop_helper.c index b6692382b3b..6f9ccc008a0 100644 --- a/target/sparc/fop_helper.c +++ b/target/sparc/fop_helper.c @@ -497,7 +497,10 @@ uint32_t helper_flcmps(float32 src1, float32 src2) * Perform the comparison with a dummy fp environment. */ float_status discard = { }; - FloatRelation r = float32_compare_quiet(src1, src2, &discard); + FloatRelation r; + + set_float_2nan_prop_rule(float_2nan_prop_s_ba, &discard); + r = float32_compare_quiet(src1, src2, &discard); switch (r) { case float_relation_equal: @@ -518,7 +521,10 @@ uint32_t helper_flcmps(float32 src1, float32 src2) uint32_t helper_flcmpd(float64 src1, float64 src2) { float_status discard = { }; - FloatRelation r = float64_compare_quiet(src1, src2, &discard); + FloatRelation r; + + set_float_2nan_prop_rule(float_2nan_prop_s_ba, &discard); + r = float64_compare_quiet(src1, src2, &discard); switch (r) { case float_relation_equal: diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc index 226632a4d10..8bc95187178 100644 --- a/fpu/softfloat-specialize.c.inc +++ b/fpu/softfloat-specialize.c.inc @@ -404,11 +404,9 @@ static int pickNaN(FloatClass a_cls, FloatClass b_cls, || defined(TARGET_RISCV) || defined(TARGET_SH4) \ || defined(TARGET_TRICORE) || defined(TARGET_ARM) || defined(TARGET_MIPS) \ || defined(TARGET_LOONGARCH64) || defined(TARGET_HPPA) \ - || defined(TARGET_S390X) || defined(TARGET_PPC) || defined(TARGET_M68K) + || defined(TARGET_S390X) || defined(TARGET_PPC) || defined(TARGET_M68K) \ + || defined(TARGET_SPARC) g_assert_not_reached(); -#elif defined(TARGET_SPARC) - /* Prefer SNaN over QNaN, order B then A. */ - rule = float_2nan_prop_s_ba; #elif defined(TARGET_XTENSA) /* * Xtensa has two NaN propagation modes. From patchwork Fri Oct 25 14:12:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 838355 Delivered-To: patch@linaro.org Received: by 2002:adf:e287:0:b0:37d:45d0:187 with SMTP id v7csp307299wri; Fri, 25 Oct 2024 07:15:48 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWceUAWKX/P/Twqlx0X2a55LTDp2h7tOEmQjg18zWjqxJ32nbfpU2/UToMztxNayW2M6SAjQA==@linaro.org X-Google-Smtp-Source: AGHT+IGfhYD8kkWmJ6r/6xaVqsiaai/a3bBmak1CZkMclbLOziF6X/qwY88UjireWlMVljrBxzPS X-Received: by 2002:a05:620a:2a0e:b0:7ac:b1b1:e730 with SMTP id af79cd13be357-7b186d0c3e2mr710088485a.61.1729865748427; Fri, 25 Oct 2024 07:15:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729865748; cv=none; d=google.com; s=arc-20240605; b=N6KF/xYQbUvCcaStlwy/oQ4Y/h2LLv+/6fLsDPURZJ9dqQYOvroyI26u5+fdbLiuAo aaajyqOO9VPJgasdNXmH4xdJcPIbfFWBNknewjztAmxXyS5xK489iIwgPu33y7oYfXQn Tq6DLF+bmSRcPp4qDVWKNXowrwZ1UkBGLBFz7g+vYkIFmSy6uKr0TfYsUEj0DIdYN8M7 WxnnMEBRw5pBXQwiZR2ytCBmKkjKSxxT8+Ysb18dSkjuN54ddvog4SLaqEv3p77nRlEh DYnmeo8+IeWDOCb+ss9WJcS2mjdN8H6MZ6dNh3ejmJLsHUiNe3wH4hrp06v3YXwJzg2a yv5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=BczarKbZJDxbjH7vD9cLXbmuaONY9kegQ+oAgDMMF9U=; fh=j2oODthK5arPNfjrsKzTxNjtPB30jlspKwiRCuqkKSc=; b=SoyYnt5XzL4VOvIxnaJwpQW7OA7exJEDB4en5rhA/j8w5DPtfnxvDFXCavWnfU9eNg zPmtubHdKQs6anQMSpIkdZKx02A55l4Ej/eXoef+Hin6k+ZcHc53bswEyuuI5wlSO1FU g7kSiOhZ+SDr/LwGQPI97phAZtSHv0eb3C84rr/5+/xeVbZN8qSIjFKAyCYdx1FOeBCw vIdHMTeu33HdXfyKTw0w7E+8CL+Af7tzHBjkbQMsevmCOz7eiSUZILofQIVbAfAyEUHu 3blMc4TuXIB35OoYHhXcn873vqzsxvTm1sGSvTUzhNO8u5I7AczgQGa0e0BAymWcdhQ8 PFOg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XKyCwuPg; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7b18d352deesi153097385a.528.2024.10.25.07.15.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 25 Oct 2024 07:15:48 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XKyCwuPg; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t4L48-0004LA-4X; Fri, 25 Oct 2024 10:13:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t4L41-0004D9-DL for qemu-devel@nongnu.org; Fri, 25 Oct 2024 10:13:17 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t4L3t-0007rO-78 for qemu-devel@nongnu.org; Fri, 25 Oct 2024 10:13:17 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-4316e9f4a40so21293275e9.2 for ; Fri, 25 Oct 2024 07:13:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729865588; x=1730470388; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BczarKbZJDxbjH7vD9cLXbmuaONY9kegQ+oAgDMMF9U=; b=XKyCwuPgMRD5EESVEuJwYn4wbvkUiQHedOWBLth6UVHgYaoGkpqIlrjZvthKRk8Pwi 27d9gA84vjU/1Th7GK+rMm+zx+F7sGP0BRkc7KQPczUWhHgwzRIqtBgRNMRciQhV8cIu WWwevhjPMGTTBO18ZRwdlrB7WqTUu7KEQjl3wg8eMaOJe7XxJ7eAGgRcGAFcPJX3Y7Zo H1kkG1iO+3xS5N83MyWM5JoVUROBc7AOxgwQNVk0Seuga4l0N7v0R9NZOc8+Ts1VNtpW WOfh8O5UuseMvNxxmkGdgcBlQi6vmETGjziQP1Hc3HQa4T7d9VcEtxJ2pZZMY5D8m2NF EfdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729865588; x=1730470388; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BczarKbZJDxbjH7vD9cLXbmuaONY9kegQ+oAgDMMF9U=; b=Llp4FSyR3HPPNRnFccGxw9+wdjFWw9g3BdUnDw/uEg8St+ug57GCLJUzp3WbEMLtTR L7kUATDo3sQE3vMOCr0Pelg6UyDnI68ZHcwCqCcKrF1IF+cDVhmG/WymavvWCyxu/nVS aj6eDl8uypUVqLf+kcXaYwf/DPpTnllrlR6Yp4TeAdhNupvG7ydqg08+1ObYyEU/2rHd XtE3Xu/+KnKEXRAofGzJqHafErbvrtv1CU/f5DiyNGTygqcyv7ETLGjFue2XQSC4jA78 4wpBR8wm5yNvdDVcEK1miNgg2PS2IcUBTnEY2B8onLVP9PEnT9VgjSKI+CT4vcVgAZ1x u4KA== X-Forwarded-Encrypted: i=1; AJvYcCUgacg4i3fOA6iqry6PS79ZJ/YUyyiAnnZppH3Z9s0BrNK8fK+fy9+2i+VLRVzSz2Ivol2MlsoUZN1K@nongnu.org X-Gm-Message-State: AOJu0Yxc4SVhbgIGcqppKGpP44BXWqT3+Xqis2nyBH9RXYHxdSn5JWtC 6+9/dIMjMEIQvDtuGRq0VmwkZx6MwqsgZ5XqqtpGBbRkrFYxk2lzwrENzzBX/Kk= X-Received: by 2002:a05:600c:1552:b0:42c:b750:1a1e with SMTP id 5b1f17b1804b1-4318beb62e6mr50079065e9.0.1729865587749; Fri, 25 Oct 2024 07:13:07 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4318b57b051sm50104535e9.42.2024.10.25.07.13.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 07:13:07 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Song Gao , Eduardo Habkost , "Edgar E. Iglesias" , Jiaxun Yang , Aleksandar Rikalo , Stafford Horne , Nicholas Piggin , Daniel Henrique Barboza , Yoshinori Sato , David Hildenbrand , Ilya Leoshkevich , Thomas Huth , Mark Cave-Ayland , Artyom Tarasenko , Max Filippov , qemu-ppc@nongnu.org, qemu-s390x@nongnu.org Subject: [PATCH 13/21] target/xtensa: Factor out calls to set_use_first_nan() Date: Fri, 25 Oct 2024 15:12:46 +0100 Message-Id: <20241025141254.2141506-14-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241025141254.2141506-1-peter.maydell@linaro.org> References: <20241025141254.2141506-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x334.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org In xtensa we currently call set_use_first_nan() in a lot of places where we want to switch the NaN-propagation handling. We're about to change the softfloat API we use to do that, so start by factoring all the calls out into a single xtensa_use_first_nan() function. The bulk of this change was done with sed -i -e 's/set_use_first_nan(\([^,]*\),[^)]*)/xtensa_use_first_nan(env, \1)/' target/xtensa/fpu_helper.c Signed-off-by: Peter Maydell Reviewed-by: Max Filippov Reviewed-by: Richard Henderson --- target/xtensa/cpu.h | 6 ++++++ target/xtensa/cpu.c | 2 +- target/xtensa/fpu_helper.c | 33 +++++++++++++++++++-------------- 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/target/xtensa/cpu.h b/target/xtensa/cpu.h index 9f2341d8563..77e48eef19c 100644 --- a/target/xtensa/cpu.h +++ b/target/xtensa/cpu.h @@ -802,4 +802,10 @@ static inline void cpu_get_tb_cpu_state(CPUXtensaState *env, vaddr *pc, XtensaCPU *xtensa_cpu_create_with_clock(const char *cpu_type, Clock *cpu_refclk); +/* + * Set the NaN propagation rule for future FPU operations: + * use_first is true to pick the first NaN as the result if both + * inputs are NaNs, false to pick the second. + */ +void xtensa_use_first_nan(CPUXtensaState *env, bool use_first); #endif diff --git a/target/xtensa/cpu.c b/target/xtensa/cpu.c index a08c7a0b1f2..6f9039abaee 100644 --- a/target/xtensa/cpu.c +++ b/target/xtensa/cpu.c @@ -134,7 +134,7 @@ static void xtensa_cpu_reset_hold(Object *obj, ResetType type) cs->halted = env->runstall; #endif set_no_signaling_nans(!dfpu, &env->fp_status); - set_use_first_nan(!dfpu, &env->fp_status); + xtensa_use_first_nan(env, !dfpu); } static ObjectClass *xtensa_cpu_class_by_name(const char *cpu_model) diff --git a/target/xtensa/fpu_helper.c b/target/xtensa/fpu_helper.c index 381e83ded83..50a5efa65e2 100644 --- a/target/xtensa/fpu_helper.c +++ b/target/xtensa/fpu_helper.c @@ -57,6 +57,11 @@ static const struct { { XTENSA_FP_V, float_flag_invalid, }, }; +void xtensa_use_first_nan(CPUXtensaState *env, bool use_first) +{ + set_use_first_nan(use_first, &env->fp_status); +} + void HELPER(wur_fpu2k_fcr)(CPUXtensaState *env, uint32_t v) { static const int rounding_mode[] = { @@ -171,87 +176,87 @@ float32 HELPER(fpu2k_msub_s)(CPUXtensaState *env, float64 HELPER(add_d)(CPUXtensaState *env, float64 a, float64 b) { - set_use_first_nan(true, &env->fp_status); + xtensa_use_first_nan(env, true); return float64_add(a, b, &env->fp_status); } float32 HELPER(add_s)(CPUXtensaState *env, float32 a, float32 b) { - set_use_first_nan(env->config->use_first_nan, &env->fp_status); + xtensa_use_first_nan(env, env->config->use_first_nan); return float32_add(a, b, &env->fp_status); } float64 HELPER(sub_d)(CPUXtensaState *env, float64 a, float64 b) { - set_use_first_nan(true, &env->fp_status); + xtensa_use_first_nan(env, true); return float64_sub(a, b, &env->fp_status); } float32 HELPER(sub_s)(CPUXtensaState *env, float32 a, float32 b) { - set_use_first_nan(env->config->use_first_nan, &env->fp_status); + xtensa_use_first_nan(env, env->config->use_first_nan); return float32_sub(a, b, &env->fp_status); } float64 HELPER(mul_d)(CPUXtensaState *env, float64 a, float64 b) { - set_use_first_nan(true, &env->fp_status); + xtensa_use_first_nan(env, true); return float64_mul(a, b, &env->fp_status); } float32 HELPER(mul_s)(CPUXtensaState *env, float32 a, float32 b) { - set_use_first_nan(env->config->use_first_nan, &env->fp_status); + xtensa_use_first_nan(env, env->config->use_first_nan); return float32_mul(a, b, &env->fp_status); } float64 HELPER(madd_d)(CPUXtensaState *env, float64 a, float64 b, float64 c) { - set_use_first_nan(env->config->use_first_nan, &env->fp_status); + xtensa_use_first_nan(env, env->config->use_first_nan); return float64_muladd(b, c, a, 0, &env->fp_status); } float32 HELPER(madd_s)(CPUXtensaState *env, float32 a, float32 b, float32 c) { - set_use_first_nan(env->config->use_first_nan, &env->fp_status); + xtensa_use_first_nan(env, env->config->use_first_nan); return float32_muladd(b, c, a, 0, &env->fp_status); } float64 HELPER(msub_d)(CPUXtensaState *env, float64 a, float64 b, float64 c) { - set_use_first_nan(env->config->use_first_nan, &env->fp_status); + xtensa_use_first_nan(env, env->config->use_first_nan); return float64_muladd(b, c, a, float_muladd_negate_product, &env->fp_status); } float32 HELPER(msub_s)(CPUXtensaState *env, float32 a, float32 b, float32 c) { - set_use_first_nan(env->config->use_first_nan, &env->fp_status); + xtensa_use_first_nan(env, env->config->use_first_nan); return float32_muladd(b, c, a, float_muladd_negate_product, &env->fp_status); } float64 HELPER(mkdadj_d)(CPUXtensaState *env, float64 a, float64 b) { - set_use_first_nan(true, &env->fp_status); + xtensa_use_first_nan(env, true); return float64_div(b, a, &env->fp_status); } float32 HELPER(mkdadj_s)(CPUXtensaState *env, float32 a, float32 b) { - set_use_first_nan(env->config->use_first_nan, &env->fp_status); + xtensa_use_first_nan(env, env->config->use_first_nan); return float32_div(b, a, &env->fp_status); } float64 HELPER(mksadj_d)(CPUXtensaState *env, float64 v) { - set_use_first_nan(true, &env->fp_status); + xtensa_use_first_nan(env, true); return float64_sqrt(v, &env->fp_status); } float32 HELPER(mksadj_s)(CPUXtensaState *env, float32 v) { - set_use_first_nan(env->config->use_first_nan, &env->fp_status); + xtensa_use_first_nan(env, env->config->use_first_nan); return float32_sqrt(v, &env->fp_status); } From patchwork Fri Oct 25 14:12:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 838348 Delivered-To: patch@linaro.org Received: by 2002:adf:e287:0:b0:37d:45d0:187 with SMTP id v7csp306694wri; Fri, 25 Oct 2024 07:14:55 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVeWSYio0BlGF1d5J9hRvISKczdjiSQeXvCJHFfViKF0TJNOE8y5GOqjby508iXdS7UMZFQrQ==@linaro.org X-Google-Smtp-Source: AGHT+IFoj2hJvqnkwfRJ8nB09ALqvzTdVKR05t2kgMpM5a3u+yxBMA8OILPO8Dqx4vviKvmQv8pf X-Received: by 2002:a05:622a:30b:b0:460:ac8f:3bcd with SMTP id d75a77b69052e-461147080ebmr129869231cf.45.1729865695623; Fri, 25 Oct 2024 07:14:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729865695; cv=none; d=google.com; s=arc-20240605; b=GR3+dVh6NxtP77Locy4NOc75UmpTYofJjLfBidZnNuzejGwCq/0UzkDd8Zk4JNP9D0 X8By4VcAlmYOxHLEnX3/7kuuAttW6JsSWVM4u8P2BdjGC6gbg/CjCRwgMtvuYj0XyDN3 wYi/FRQLNUQodkGUSQ0c57tJJFfFVTM8bSkQNBKlbDvnn3qkDsiIqrNKM4hQ8NfLsZ6g tLhMQmHSfiroSHeQ2KoY1VuxzRiqSMnUV+fc3lgUjLlvJu5SMUIu7KQv6VpTPSgma4E3 kAIzm3MJW07YVv4pQhSfmrIN9L8O9Wv0M7N+JRDViaK+rLcw29oe/FsbKlNVwr/BoFF5 g7jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=E/5hJDm1PODLj3BAsIJIpQ+juZ5PqFngoiMdJEv0hac=; fh=8QD0t+6YxdHR8Colna9Zcusz3i65VO80X03AGi1jP+w=; b=IDDm7gETUFWyi8xpaHgLY9XinxySOSIliYW68JnEH9WVcfk7ZzOYkn0dGz+OltjoQo 3fab1A+CyxkSahQ9oOlWG+mfB9JuVPJi+5OW/rOeOD52QyRQNIGZy0rT+yeNXEd85DZL 2VyqP31v8100EZnGGTTyOeEb7OQ5JyqFz/kT01kER+dC1UZhFmS/H1u/Z7yMAr7f/jUH UgV42qnIwXIlq8uojXRb4/Fkj/w9fLWpWBPorcaC+GE3R7V4GsQW4L7Ipnj1/af69jwr j5TydBYjAnZxN6yo0QTjR1eD74mb8/ALOGVTgoQed/oPB6i4jzgCq73GUhDWY7z4lbeU ipdw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iGqzg3SG; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-461323cce4esi16696741cf.597.2024.10.25.07.14.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 25 Oct 2024 07:14:55 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iGqzg3SG; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t4L4B-0004Pe-JD; Fri, 25 Oct 2024 10:13:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t4L43-0004Fw-AK for qemu-devel@nongnu.org; Fri, 25 Oct 2024 10:13:19 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t4L3u-0007s9-3t for qemu-devel@nongnu.org; Fri, 25 Oct 2024 10:13:19 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-4315f24a6bbso20447695e9.1 for ; Fri, 25 Oct 2024 07:13:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729865588; x=1730470388; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=E/5hJDm1PODLj3BAsIJIpQ+juZ5PqFngoiMdJEv0hac=; b=iGqzg3SGOcUBSb+jS5N/ka49+o0NzhSKJbFBct29sn1YiHgr9TSVZ2rZfMEHqLncIG OH1IKB/4rBMqTux9/E7xFfwBGDj6uVzN+nJ0hOl4tyObJAiFDl7/Y+rU4PTqYCbr5YQ6 veRiXQloO9kh2o4VI8511uRmDhWo0ha86aVn4t00FWCZ3/Nmiftumo8WrDwt9QFRCzOC 0yusKc4avkLprT4u+CrLubuOkzvK4wMPqIQL6RHt2vi0oj0sl4+8zyS5vpuI7IUXqGfO NhrpJ4qhUXLEKFwVp+zsa+D5zGEplIfhjOerWk3Om4Q6AtnWJdxShMrOjnpLKz3YMZKt G6cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729865588; x=1730470388; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=E/5hJDm1PODLj3BAsIJIpQ+juZ5PqFngoiMdJEv0hac=; b=iL9n/9c4K6T98TbEa1UIQnLiB9i97935ekBrUUNXo8PkvzDlRSv4OfB68KldyPLW+V K9E3NyWtrXv8zXnMjcqkXhfkzOuykBCFz30ui3sTkPuqrwlLvsNQl4pcIA8ckJwdS482 3eSAE6dWce/oaD+uKlplwW4I7TmAvEmLbWZnivtf1YDy0MnD2bENhyhzvWz/pOPMUllz kw0zgHIQzD2bQ4dPT5khXp11ORaa0lzp1s8dGzhM0rwtmkEFiGHur4s0zED3+JOkpZgw xMSj2L5iPQXYLVjCG7x1RmDaqpF8B0uLgDRC5+oHV3y6y4tj+Yd3TdwRF9UTht0n/s0j HAig== X-Forwarded-Encrypted: i=1; AJvYcCWIAj0+aoSxkWDLClvE8jx8PuUhb8M1Lff0Bet8koTc4dNfus2/6kQR2ZRKnn0QHnMFAiK8K/HeevtT@nongnu.org X-Gm-Message-State: AOJu0YzgertamRzUXR9+VGJSU2gK83IKqjgBNjFOu+WjTEkUERqPdMS0 4bwVZKb00RDwyx3TZtSCFzcRuhYt9Z19hugrow7HZ32PX9pZ4UMzN39iPKZ7fyA= X-Received: by 2002:a05:600c:5011:b0:430:54a4:5b03 with SMTP id 5b1f17b1804b1-4318c6e0175mr46337875e9.6.1729865588576; Fri, 25 Oct 2024 07:13:08 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4318b57b051sm50104535e9.42.2024.10.25.07.13.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 07:13:08 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Song Gao , Eduardo Habkost , "Edgar E. Iglesias" , Jiaxun Yang , Aleksandar Rikalo , Stafford Horne , Nicholas Piggin , Daniel Henrique Barboza , Yoshinori Sato , David Hildenbrand , Ilya Leoshkevich , Thomas Huth , Mark Cave-Ayland , Artyom Tarasenko , Max Filippov , qemu-ppc@nongnu.org, qemu-s390x@nongnu.org Subject: [PATCH 14/21] target/xtensa: Explicitly set 2-NaN propagation rule Date: Fri, 25 Oct 2024 15:12:47 +0100 Message-Id: <20241025141254.2141506-15-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241025141254.2141506-1-peter.maydell@linaro.org> References: <20241025141254.2141506-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Set the NaN propagation rule explicitly in xtensa_use_first_nan(). (When we convert the softfloat pickNaNMulAdd routine to also select a NaN propagation rule at runtime, we will be able to remove the use_first_nan flag because the propagation rules will handle everything.) Signed-off-by: Peter Maydell Reviewed-by: Max Filippov Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- target/xtensa/fpu_helper.c | 2 ++ fpu/softfloat-specialize.c.inc | 12 +----------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/target/xtensa/fpu_helper.c b/target/xtensa/fpu_helper.c index 50a5efa65e2..f2d212d05df 100644 --- a/target/xtensa/fpu_helper.c +++ b/target/xtensa/fpu_helper.c @@ -60,6 +60,8 @@ static const struct { void xtensa_use_first_nan(CPUXtensaState *env, bool use_first) { set_use_first_nan(use_first, &env->fp_status); + set_float_2nan_prop_rule(use_first ? float_2nan_prop_ab : float_2nan_prop_ba, + &env->fp_status); } void HELPER(wur_fpu2k_fcr)(CPUXtensaState *env, uint32_t v) diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc index 8bc95187178..b050c5eb04a 100644 --- a/fpu/softfloat-specialize.c.inc +++ b/fpu/softfloat-specialize.c.inc @@ -405,18 +405,8 @@ static int pickNaN(FloatClass a_cls, FloatClass b_cls, || defined(TARGET_TRICORE) || defined(TARGET_ARM) || defined(TARGET_MIPS) \ || defined(TARGET_LOONGARCH64) || defined(TARGET_HPPA) \ || defined(TARGET_S390X) || defined(TARGET_PPC) || defined(TARGET_M68K) \ - || defined(TARGET_SPARC) + || defined(TARGET_SPARC) || defined(TARGET_XTENSA) g_assert_not_reached(); -#elif defined(TARGET_XTENSA) - /* - * Xtensa has two NaN propagation modes. - * Which one is active is controlled by float_status::use_first_nan. - */ - if (status->use_first_nan) { - rule = float_2nan_prop_ab; - } else { - rule = float_2nan_prop_ba; - } #else rule = float_2nan_prop_x87; #endif From patchwork Fri Oct 25 14:12:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 838360 Delivered-To: patch@linaro.org Received: by 2002:adf:e287:0:b0:37d:45d0:187 with SMTP id v7csp308707wri; Fri, 25 Oct 2024 07:17:57 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUUPhttD9BCLrzJwxU3Rd1KjmRJM21LDqebEDo7uDmX4j+YyHh/eUEz/qTXCzdgEcQ9SG50zA==@linaro.org X-Google-Smtp-Source: AGHT+IGROfenIGUWdPBOWaeJyH7bLHSb4ZAt56nfgSqrxGx9d94HcNDAAQ08Tc2ljUPZK13Wr12V X-Received: by 2002:a05:622a:18a6:b0:461:13a6:7df with SMTP id d75a77b69052e-461146bb024mr134249811cf.24.1729865876791; Fri, 25 Oct 2024 07:17:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729865876; cv=none; d=google.com; s=arc-20240605; b=KuaO6nlAt5yd5GCEAUkpxx2JDh2EFFfEaMPWamdf8PTY9l6yAY2Czg9ov9Lm3E8oPy Q/W9yn4lDgwnPHKv0aSYwYNfMII8cRc97SORCRpyZMwaybtVrARlzgPMQLShtch3ei7Z y5F9hMghu3TFlH856SuByDy8jZ/QruUYemJqr30pcyoNS3rRLSDB3TDe5V1p6FbTcG+i EoFC6q1i6/HDOp3nq7wGIcI7qBdM3SorW9/sw7kwHbrGsPzUG9ZJ9jn7Z15RI9c2Q9fW HhBYJzDcVb/8MvnvzvNd620XM5Buvf6xywUkPYIUGkfHUNhegJLFmtX25VZUOLomiwUE 4yvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=1cCo50wdC0NIgQKfnDkwtGpzRTYsS1ol+AjTcdAhO0A=; fh=J5FKj9qhQ5PJ+iTDkZAkMV1SUonkYZ+/AKTh3iy8AnA=; b=QTkaqxvk/8eCqNxGn30AUkLt20Ot6RBgjp9bpn0ilaaq9xpHl6TYGcbqf96YO90FQ9 R1dnRcFTzGPC5ufegjjygusqaDaYPp4o3fHyRin5/fr6F2ZP10DSxFH1K53Z0/ypysDf yZAUI5sgDL3beLeNblOLKMAZWGcwfTwPjLIS6n8b0ejm7XaHNhapQCjYK/8yCSV7O+g7 Cq+2/IBbzAO+ey+Cud4GzROqZ/X8+fJvbjG804tOVUqsT0oKZ+1cWNNsBjFKcJ3g8VGd BEWu5CBkiDor2qzzZ1we0+kAUpxCxLnNbr2lrUKXu4/K8lGqyZMAg3l6EM1WGblW2z5H i8OA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="SS6Q9Fp/"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-461323c48c2si14548891cf.542.2024.10.25.07.17.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 25 Oct 2024 07:17:56 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="SS6Q9Fp/"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t4L4D-0004RX-LA; Fri, 25 Oct 2024 10:13:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t4L44-0004GI-6r for qemu-devel@nongnu.org; Fri, 25 Oct 2024 10:13:21 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t4L3u-0007sl-U0 for qemu-devel@nongnu.org; Fri, 25 Oct 2024 10:13:19 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-43169902057so20481835e9.0 for ; Fri, 25 Oct 2024 07:13:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729865589; x=1730470389; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1cCo50wdC0NIgQKfnDkwtGpzRTYsS1ol+AjTcdAhO0A=; b=SS6Q9Fp/HdnY+6ajn/QNUZwh7QwfvagZsrs28rDOk4zxQqLmZZXnEh8bQMw2OSKWZD wznleDwLjNuJKOghzwreMj9ZEW3IEWW3GLUrYu9hrKg5Ng1q8fy73G7WJhBXVfKIarjH GaYanxj2fvkCqJalQaskgtleKvRApWzsPKgr+/AATfIG/Axkt7QeFtGvAX1L2ZtFyspG 1DRYPy6mpTc29jwu+aRJSqIzKy1Zuv4Ks66lHPK7A9EPmSHluL3O7iDfMAGxetrwP8t/ oK3m83oRu5rwdo4Ex79/otPqyFnj4rJJY1NbToTzYl0nc9qZ1Kw9yaba2SYTv26AKxsE 63FQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729865589; x=1730470389; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1cCo50wdC0NIgQKfnDkwtGpzRTYsS1ol+AjTcdAhO0A=; b=O9y8JK/LpFkFKoXLGZfmDAblWe2eXXJfY2h7DQMzpgzk1AmrzUAuDg0sXOWQh7hQvo jYSaJ5s50KcCUkgCF+CAL1C+H+tXsyFUIQecql6lcHnquI0b6RM8txGl1dbArkjTYBNA nkkY2CBMRonX5i0IXJ6WjeF02ajvgPrw48nV0+McIav1L+hirspa4WPg4+FdJKQ4VXG2 EJu+c9Va8lndFsUnVpNznCcekIMA/0N8CQBd2rSTJdn2T4a4F/rC5pvBsQFhw01xQ3Di RsK29TftrMaupbIkdoUvBpTfYux3pHFmBZm8WpGwefMzYOB8xL/cY3iPPhgStWX3zGPa QaTQ== X-Forwarded-Encrypted: i=1; AJvYcCV7+ozOQDmODyr/8hPcMGpIoM7wNQeqB7Eao0kKtw4mAHdi2uMvfHz7SkBHmdK00H/9Rsm/JKwVam+/@nongnu.org X-Gm-Message-State: AOJu0YyeywU58tkBbWJeGI3gl/Iz+3XVWY2TiQYtJpzbPvmZoGpb4Tq6 BeSs5YWTGSLzRvZgpx+fKmG5RQiSo0LPsi34YNcTYZ5hy8BhsmD9b7/7CwPWAy0= X-Received: by 2002:a05:600c:1d27:b0:431:58cd:b260 with SMTP id 5b1f17b1804b1-4318418a568mr84761005e9.25.1729865589416; Fri, 25 Oct 2024 07:13:09 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4318b57b051sm50104535e9.42.2024.10.25.07.13.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 07:13:09 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Song Gao , Eduardo Habkost , "Edgar E. Iglesias" , Jiaxun Yang , Aleksandar Rikalo , Stafford Horne , Nicholas Piggin , Daniel Henrique Barboza , Yoshinori Sato , David Hildenbrand , Ilya Leoshkevich , Thomas Huth , Mark Cave-Ayland , Artyom Tarasenko , Max Filippov , qemu-ppc@nongnu.org, qemu-s390x@nongnu.org Subject: [PATCH 15/21] target/i386: Set 2-NaN propagation rule explicitly Date: Fri, 25 Oct 2024 15:12:48 +0100 Message-Id: <20241025141254.2141506-16-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241025141254.2141506-1-peter.maydell@linaro.org> References: <20241025141254.2141506-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x333.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Set the NaN propagation rule explicitly for the float_status words used in the x86 target. This is a no-behaviour-change commit, so we retain the existing behaviour of using the x87-style "prefer QNaN over SNaN, then prefer the NaN with the larger significand" for MMX and SSE. This is however not the documented hardware behaviour, so we leave a TODO note about what we should be doing instead. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/i386/cpu.h | 3 +++ target/i386/cpu.c | 4 ++++ target/i386/tcg/fpu_helper.c | 40 ++++++++++++++++++++++++++++++++++ fpu/softfloat-specialize.c.inc | 3 ++- 4 files changed, 49 insertions(+), 1 deletion(-) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 74886d1580f..43ba62e92d3 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -2562,6 +2562,9 @@ static inline bool cpu_vmx_maybe_enabled(CPUX86State *env) int get_pg_mode(CPUX86State *env); /* fpu_helper.c */ + +/* Set all non-runtime-variable float_status fields to x86 handling */ +void cpu_init_fp_statuses(CPUX86State *env); void update_fp_status(CPUX86State *env); void update_mxcsr_status(CPUX86State *env); void update_mxcsr_from_sse_status(CPUX86State *env); diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 1ff1af032ea..e9260fbc654 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -7083,6 +7083,10 @@ static void x86_cpu_reset_hold(Object *obj, ResetType type) memset(env, 0, offsetof(CPUX86State, end_reset_fields)); + if (tcg_enabled()) { + cpu_init_fp_statuses(env); + } + env->old_exception = -1; /* init to reset state */ diff --git a/target/i386/tcg/fpu_helper.c b/target/i386/tcg/fpu_helper.c index e1b850f3fc2..53b49bb2977 100644 --- a/target/i386/tcg/fpu_helper.c +++ b/target/i386/tcg/fpu_helper.c @@ -135,6 +135,46 @@ static void fpu_set_exception(CPUX86State *env, int mask) } } +void cpu_init_fp_statuses(CPUX86State *env) +{ + /* + * Initialise the non-runtime-varying fields of the various + * float_status words to x86 behaviour. This must be called at + * CPU reset because the float_status words are in the + * "zeroed on reset" portion of the CPU state struct. + * Fields in float_status that vary under guest control are set + * via the codepath for setting that register, eg cpu_set_fpuc(). + */ + /* + * Use x87 NaN propagation rules: + * SNaN + QNaN => return the QNaN + * two SNaNs => return the one with the larger significand, silenced + * two QNaNs => return the one with the larger significand + * SNaN and a non-NaN => return the SNaN, silenced + * QNaN and a non-NaN => return the QNaN + * + * If we get down to comparing significands and they are the same, + * return the NaN with the positive sign bit (if any). + */ + set_float_2nan_prop_rule(float_2nan_prop_x87, &env->fp_status); + /* + * TODO: These are incorrect: the x86 Software Developer's Manual vol 1 + * section 4.8.3.5 "Operating on SNaNs and QNaNs" says that the + * "larger significand" behaviour is only used for x87 FPU operations. + * For SSE the required behaviour is to always return the first NaN, + * which is float_2nan_prop_ab. + * + * mmx_status is used only for the AMD 3DNow! instructions, which + * are documented in the "3DNow! Technology Manual" as not supporting + * NaNs or infinities as inputs. The result of passing two NaNs is + * documented as "undefined", so we can do what we choose. + * (Strictly there is some behaviour we don't implement correctly + * for these "unsupported" NaN and Inf values, like "NaN * 0 == 0".) + */ + set_float_2nan_prop_rule(float_2nan_prop_x87, &env->mmx_status); + set_float_2nan_prop_rule(float_2nan_prop_x87, &env->sse_status); +} + static inline uint8_t save_exception_flags(CPUX86State *env) { uint8_t old_flags = get_float_exception_flags(&env->fp_status); diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc index b050c5eb04a..77ebc8216f6 100644 --- a/fpu/softfloat-specialize.c.inc +++ b/fpu/softfloat-specialize.c.inc @@ -405,7 +405,8 @@ static int pickNaN(FloatClass a_cls, FloatClass b_cls, || defined(TARGET_TRICORE) || defined(TARGET_ARM) || defined(TARGET_MIPS) \ || defined(TARGET_LOONGARCH64) || defined(TARGET_HPPA) \ || defined(TARGET_S390X) || defined(TARGET_PPC) || defined(TARGET_M68K) \ - || defined(TARGET_SPARC) || defined(TARGET_XTENSA) + || defined(TARGET_SPARC) || defined(TARGET_XTENSA) \ + || defined(TARGET_I386) g_assert_not_reached(); #else rule = float_2nan_prop_x87; From patchwork Fri Oct 25 14:12:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 838362 Delivered-To: patch@linaro.org Received: by 2002:adf:e287:0:b0:37d:45d0:187 with SMTP id v7csp309068wri; Fri, 25 Oct 2024 07:18:27 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU45p5hdZY5bPbcS5uXHNRuRH4UXdM2ToFHBEmyMVXJL93P40TZkkV/+hp0ZYHMUx2+9vcu8w==@linaro.org X-Google-Smtp-Source: AGHT+IEUN4afo5JJGxrnvHeJBVzQZ7P+ESVs4I9WL5zwZcj5dWXIeOcm5GaR6kuBX5MQUoFvb+DT X-Received: by 2002:a05:620a:4454:b0:7ac:e8bf:894a with SMTP id af79cd13be357-7b18664f24cmr879574485a.20.1729865907379; Fri, 25 Oct 2024 07:18:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729865907; cv=none; d=google.com; s=arc-20240605; b=aAThbrDZoAqGz++hAQroY6AUEsJkpAD1QrCd00S7FcCjTuBMMQY7ULqpPywRLVFgGq 4WyRmkc13sVKfUYVge2LZAwPoEwr9TJfPeMtsIYtUbxxukzkeIfny8oxcK1EvGPaFMOG i6VNXVCrwD39MdV8Fbo5r8GANcQ8A+gx37No90J6I6RDksR6aek27xiR9z2WhA2W/YNo y0qqfaJIcR0grKxpZlVdGLD9dvurSkX+Ztv+sOywSccIhWiWHtbXSTF33J/IoL/D8HX2 ylFTB+UtrJypU9zd+kZU3qd2hvJ9p+R/wCpoPdopHHjU0RhMR1n73F+NvDF1sk7dAee2 h8nw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=R0KwrJ+RLRqyfxTos/cR3Np44ABB8RBfSuYyJrILdGI=; fh=ncrExHxEWqh8+Fh9MozZAoCWlVvrxckp6NjNmlmosik=; b=LRajndlzGm+JUl6tCybVB50R5xcvCf/eYOsN2A3a1351jBFFgo3NlE89yels+1YX4w o0LSWesQaYNYl1sAPHWuLvScgGZh+ba2LVI1rfxcDvAsBS/fN++Ip88RqLdRJmXC15iF Epu0Q6ilJBfyT0YY36Yq5X1Wp9kAGJpA7xmJ+8nns+cUIg0LHe2jUpslxnHzmt4QjlEA OaclMixdo4+E/6VEXhvNM5J8Zzr4UaJ0tVK18imS540TUB8QerENZW4aVxrTqXjSjnaQ 9LrDg9GxBvyOXdDjD7P3vA6/6LFzSs6CacfxXB7NTgPmPQZcofPbjZM0lqGxmYo7u1hh 8jZA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=F7nS6GVr; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7b18d3216aasi132796585a.303.2024.10.25.07.18.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 25 Oct 2024 07:18:27 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=F7nS6GVr; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t4L4I-0004Vj-II; Fri, 25 Oct 2024 10:13:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t4L48-0004LR-3P for qemu-devel@nongnu.org; Fri, 25 Oct 2024 10:13:24 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t4L3v-0007tQ-Tu for qemu-devel@nongnu.org; Fri, 25 Oct 2024 10:13:23 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-43169902057so20482035e9.0 for ; Fri, 25 Oct 2024 07:13:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729865590; x=1730470390; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=R0KwrJ+RLRqyfxTos/cR3Np44ABB8RBfSuYyJrILdGI=; b=F7nS6GVrZ6Ud5EY3wzWxnRC3v0jBOi+8Gh0/KNexEOm8jNQ6jjTPC0oLlfO+QDfiUl Ayke1GDj7kHX9yRk7QdjRSocLxQDWolEDWQnWy3jvo2kvZ2jVwThVF1cyyvb9Z+aZ6VW cXpI3vbr84tnrbXSMKiXwlG90xUg/E0Kaoe7cQFlk6mwfAYzGywW71enQCT7Nc0naleU XfgyC5dHqI5k0JHMhNvobWEg1gW3NFx2/Ixh4ZJJKmkZS98zWCHq0tlx7vigM25tx2cK b4VzTR0LaG3AyTwOUBDarPxH/keGoVFYN0tmzK/GDHpAVBeRl4x/7Rf6ZDEK8Zk1Nsjz BeDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729865590; x=1730470390; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=R0KwrJ+RLRqyfxTos/cR3Np44ABB8RBfSuYyJrILdGI=; b=fSNnz1S3PqQ6e690FiVUs7ubYIxXBH/CkLUrW6zUoZPj7rZn+XZCXoZoygtGgrluBs Mhiq6m1pDd9122leBvYvIyt3lUE3UYJQembKWzc6l6H4GnIzjwRMOiAPDJjyzewoYIqN MgWEtvlPgFO7sQ7nqJQF/tv3zMkViBFIIzj2hF05JeVWMUImcUDJjEAb1cHa6ZhZRANp kq39a1Re5IsoqZEnggx85Fy6j+LrY/mCU+aidpzosjebgRp1/KK/4RYCU+RPyJSSFPyI JT40Dy/E5rOt2poo310EDGmeFZz8KeDAYom5Tm8bGNNahGW896X+19/1jkuxVBYcek8P rg6w== X-Forwarded-Encrypted: i=1; AJvYcCVbYoJjc3GIs1rIYicd/d56CGez4esSIHYLzxlSmMNNB4E3FUfT6V8Cl8h9lGAdoTFYjgsR91I0QGlb@nongnu.org X-Gm-Message-State: AOJu0YxKxZBkwVx5fWFiuCg8jRvvtwjgYKnf0OR8SWvKSshMgbKszBHZ FsAqhG5dq7xAPVeOFVlgloTuF/ThxyEV7JuDS6U5Mw1Y9sYiZoDXk6yF9u+YJr8= X-Received: by 2002:a05:600c:1e08:b0:431:2b66:44f7 with SMTP id 5b1f17b1804b1-431841a5fe1mr81921395e9.31.1729865590281; Fri, 25 Oct 2024 07:13:10 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4318b57b051sm50104535e9.42.2024.10.25.07.13.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 07:13:10 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Song Gao , Eduardo Habkost , "Edgar E. Iglesias" , Jiaxun Yang , Aleksandar Rikalo , Stafford Horne , Nicholas Piggin , Daniel Henrique Barboza , Yoshinori Sato , David Hildenbrand , Ilya Leoshkevich , Thomas Huth , Mark Cave-Ayland , Artyom Tarasenko , Max Filippov , qemu-ppc@nongnu.org, qemu-s390x@nongnu.org Subject: [PATCH 16/21] target/alpha: Explicitly set 2-NaN propagation rule Date: Fri, 25 Oct 2024 15:12:49 +0100 Message-Id: <20241025141254.2141506-17-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241025141254.2141506-1-peter.maydell@linaro.org> References: <20241025141254.2141506-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x336.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Set the NaN propagation rule explicitly for the float_status word used in this target. This is a no-behaviour-change commit, so we retain the existing behaviour of x87-style pick-largest-significand NaN propagation. This is however not the architecturally correct handling, so we leave a TODO note to that effect. We also leave a TODO note pointing out that all this code in the cpu initfn (including the existing setting up of env->flags and the FPCR) should be in a currently non-existent CPU reset function. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- target/alpha/cpu.c | 11 +++++++++++ fpu/softfloat-specialize.c.inc | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/target/alpha/cpu.c b/target/alpha/cpu.c index 9db1dffc03e..5d75c941f7a 100644 --- a/target/alpha/cpu.c +++ b/target/alpha/cpu.c @@ -24,6 +24,7 @@ #include "qemu/qemu-print.h" #include "cpu.h" #include "exec/exec-all.h" +#include "fpu/softfloat.h" static void alpha_cpu_set_pc(CPUState *cs, vaddr value) @@ -187,7 +188,17 @@ static void alpha_cpu_initfn(Object *obj) { CPUAlphaState *env = cpu_env(CPU(obj)); + /* TODO all this should be done in reset, not init */ + env->lock_addr = -1; + + /* + * TODO: this is incorrect. The Alpha Architecture Handbook version 4 + * describes NaN propagation in section 4.7.10.4. We should prefer + * the operand in Fb (whether it is a QNaN or an SNaN), then the + * operand in Fa. That is float_2nan_prop_ba. + */ + set_float_2nan_prop_rule(float_2nan_prop_x87, &env->fp_status); #if defined(CONFIG_USER_ONLY) env->flags = ENV_FLAG_PS_USER | ENV_FLAG_FEN; cpu_alpha_store_fpcr(env, (uint64_t)(FPCR_INVD | FPCR_DZED | FPCR_OVFD diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc index 77ebc8216f6..a5c3e2b8de5 100644 --- a/fpu/softfloat-specialize.c.inc +++ b/fpu/softfloat-specialize.c.inc @@ -406,7 +406,7 @@ static int pickNaN(FloatClass a_cls, FloatClass b_cls, || defined(TARGET_LOONGARCH64) || defined(TARGET_HPPA) \ || defined(TARGET_S390X) || defined(TARGET_PPC) || defined(TARGET_M68K) \ || defined(TARGET_SPARC) || defined(TARGET_XTENSA) \ - || defined(TARGET_I386) + || defined(TARGET_I386) || defined(TARGET_ALPHA) g_assert_not_reached(); #else rule = float_2nan_prop_x87; From patchwork Fri Oct 25 14:12:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 838343 Delivered-To: patch@linaro.org Received: by 2002:adf:e287:0:b0:37d:45d0:187 with SMTP id v7csp306031wri; Fri, 25 Oct 2024 07:13:52 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXICMske3kz41EWHoQcCC7essREYvrVqdJdJDyl0//aEqLR0HTpmMk2gr9rXo6LXqU72T/5Kw==@linaro.org X-Google-Smtp-Source: AGHT+IEeBYARNG/fWtzt+IOENpoV33SqrWuoZUXCsSmxQisSpsSSygPu7ojROPSvb+AoupJpJev7 X-Received: by 2002:a05:6358:9106:b0:1bc:7c08:81c6 with SMTP id e5c5f4694b2df-1c3e4de4c50mr378676955d.28.1729865631876; Fri, 25 Oct 2024 07:13:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729865631; cv=none; d=google.com; s=arc-20240605; b=beTaomytVDCJxNlUJ2u9CfCBW0FkGQ2U0/WvyMsSnvtgQx+pjDLONEQf8QhmsOcKK0 hDXrY07jlOdNdb3VTaeNPi90JdUjav4GRx5bVmgRKsjO/1WA/oCIk8Yf+Eys/SJ8yGQo aJ4QK18qoZpyTOaGSzUM7oZiqBfyqJLxWJfXH5AX/lJXJS9Ud1AMGVCtrotmpWY/Tkp7 qpK0CZsHGG3VPJg08ouK/EgP5jrpiddG4f3jz/a1AaHlyVf8RxELsuYEkKS5+RCvoQRh 9sW1dKXPJ1YZT2fkNOtxwCGAWIVWYY3ieBQo7io5UTYHNez9fKpq4xC1QcazaHWafTJr 1/lA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=mCkNXmPfCnwutAypvXIltADsiovUrFYgTsHQnSnupeI=; fh=uEm0laqCp7F0hzpu2pihqNpBVRWKY5qtwOvZMheZWSI=; b=cLy786ejgupPCo3zIOTraWhIacOOByn/ugVyeAoNSH5j2ksiJPqQUyvSVHBHMAzbgv CBdqoPbYA1wtw2nnjAZnmlYMOIou/Rbi2UF7xMDEB/dIvHEqe1k6l4eHuxFPZS/xc1hO mjXj5dXSzPL6Zvi47U6VNzXYPC8qYIPnnhxH4/Hxikr3BwDxBX2jeteVQb8hxPu5pAg2 iTgGTiXq2f8ROLaLWx2OXrdRDGGLfgmfLQ3I5m9xsKnUwuDIQ9M+lwCyrkRi6rdMEcuM ftGeD4SwH9wFFW/UXe5y3t46YKOU/UdmemXjAYbHZ48rW15fx+kUPyjSX1D8AW9dg/5u 5DBA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pca3dyA0; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6d179a11016si16533046d6.229.2024.10.25.07.13.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 25 Oct 2024 07:13:51 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pca3dyA0; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t4L4E-0004TC-Ow; Fri, 25 Oct 2024 10:13:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t4L47-0004Km-8m for qemu-devel@nongnu.org; Fri, 25 Oct 2024 10:13:23 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t4L3x-0007tl-3Q for qemu-devel@nongnu.org; Fri, 25 Oct 2024 10:13:23 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-43161e7bb25so20292815e9.2 for ; Fri, 25 Oct 2024 07:13:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729865591; x=1730470391; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mCkNXmPfCnwutAypvXIltADsiovUrFYgTsHQnSnupeI=; b=pca3dyA0DUBtE/UZ+t+nbehNTEGr0PcZJrjxxZux1SDTYiAoHoVAxirQb0lEFRSTff M+8TK5ftfu2AmIzHGAhANFHIrybvu/rbdrR9iOX0YWZlIF2AVN8q1LbpyF1ChOaqTmB9 +kqJZ+sv6Tkhb8s1q3WrbKB63JN2xYe5z05Lb1fRA5NHFRZhWw2b3UPwBcaYt7h8zmVg Bv1Ql4ZXRhiQg7QJfpU6WQNk2nfhw39o9Et1J2KKsSL0CCXnzb0G+A++hOshHsN9w/wI /ya39ESiS9Z6+iGx5iL55AYEG+E4NOlZAnMyy7pnDlNXSFGLHH7llbuXHi9V36j8GEYc 3IJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729865591; x=1730470391; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mCkNXmPfCnwutAypvXIltADsiovUrFYgTsHQnSnupeI=; b=sZt5VzfVXDKspvu++NhGK6GR3A4ylNyjJh5FyDkuGIjHofc9FHl1tt1wJS7m/aBP+U jL1mjJTx/zcDbG6xDzyZ68NZ5a1Tqf/YD4NZgY7gts5Vam/M4Gqo0MkV2u9A4jQYB0gf mutdQFR4Co76bE5nygNOevnRghSoudgKKGwk41Lw/sjncl3YWumhsb/OxNlyxkTpf1Sk lRji3Msenpx/r84Ma4KlkSqPMrGBC3g3mVNbxYx8wXTcNt1TE+Wdkf0EZKtzI8bOh5nk I1Cs/zeCRaitfvOI01FITlFssR5WDX2xhdjkWnP07OrnuMtN6PmIqeg2c9XNsRhyFUG7 8AeA== X-Forwarded-Encrypted: i=1; AJvYcCUEZdfuSd+H4Q1OmqiroKr7gBMSvPudllCJdPRi3doP0dHpZr93GR5FkLjAW+9bMkO9I/GSS+VFsAtJ@nongnu.org X-Gm-Message-State: AOJu0YxEgodaWx9mkvGS/tHne6hP1te8wfKS77/hOdGZ2AETr42fuHHx 5PqL+k784LAvVBMaTw+syCaoT4WWv37ex6fajndwj7Mdhpe6AD4pO2djxOJZ/+A= X-Received: by 2002:a05:600c:4687:b0:431:2460:5574 with SMTP id 5b1f17b1804b1-4318418ac7amr71250255e9.27.1729865591153; Fri, 25 Oct 2024 07:13:11 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4318b57b051sm50104535e9.42.2024.10.25.07.13.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 07:13:10 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Song Gao , Eduardo Habkost , "Edgar E. Iglesias" , Jiaxun Yang , Aleksandar Rikalo , Stafford Horne , Nicholas Piggin , Daniel Henrique Barboza , Yoshinori Sato , David Hildenbrand , Ilya Leoshkevich , Thomas Huth , Mark Cave-Ayland , Artyom Tarasenko , Max Filippov , qemu-ppc@nongnu.org, qemu-s390x@nongnu.org Subject: [PATCH 17/21] target/microblaze: Move setting of float rounding mode to reset Date: Fri, 25 Oct 2024 15:12:50 +0100 Message-Id: <20241025141254.2141506-18-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241025141254.2141506-1-peter.maydell@linaro.org> References: <20241025141254.2141506-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Although the floating point rounding mode for Microblaze is always nearest-even, we cannot set it just once in the CPU initfn. This is because env->fp_status is in the part of the CPU state struct that is zeroed on reset. Move the call to set_float_rounding_mode() into the reset fn. (This had no guest-visible effects because it happens that the float_round_nearest_even enum value is 0, so when the struct was zeroed it didn't corrupt the setting.) Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/microblaze/cpu.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c index 135947ee800..6329a774331 100644 --- a/target/microblaze/cpu.c +++ b/target/microblaze/cpu.c @@ -201,6 +201,8 @@ static void mb_cpu_reset_hold(Object *obj, ResetType type) env->pc = cpu->cfg.base_vectors; + set_float_rounding_mode(float_round_nearest_even, &env->fp_status); + #if defined(CONFIG_USER_ONLY) /* start in user mode with interrupts enabled. */ mb_cpu_write_msr(env, MSR_EE | MSR_IE | MSR_VM | MSR_UM); @@ -311,15 +313,12 @@ static void mb_cpu_realizefn(DeviceState *dev, Error **errp) static void mb_cpu_initfn(Object *obj) { MicroBlazeCPU *cpu = MICROBLAZE_CPU(obj); - CPUMBState *env = &cpu->env; gdb_register_coprocessor(CPU(cpu), mb_cpu_gdb_read_stack_protect, mb_cpu_gdb_write_stack_protect, gdb_find_static_feature("microblaze-stack-protect.xml"), 0); - set_float_rounding_mode(float_round_nearest_even, &env->fp_status); - #ifndef CONFIG_USER_ONLY /* Inbound IRQ and FIR lines */ qdev_init_gpio_in(DEVICE(cpu), microblaze_cpu_set_irq, 2); From patchwork Fri Oct 25 14:12:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 838344 Delivered-To: patch@linaro.org Received: by 2002:adf:e287:0:b0:37d:45d0:187 with SMTP id v7csp306132wri; Fri, 25 Oct 2024 07:14:02 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXeJmeEuyejGkn9Za6mL0UNonn3Yn9Q3eY3FoffKIwoja10S95lNjbHEIsmeiFRChfhJOYp/w==@linaro.org X-Google-Smtp-Source: AGHT+IHbwqG30pgZ/vAOGrCYLt2M2EH5l7WQoQ4U9SZXRW3xivGEzQg2VZrY5LWf3RS2S6yhpkEN X-Received: by 2002:a05:6214:4906:b0:6d1:8389:7f4a with SMTP id 6a1803df08f44-6d183898403mr6869456d6.17.1729865642392; Fri, 25 Oct 2024 07:14:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729865642; cv=none; d=google.com; s=arc-20240605; b=BWNPhixX2ablQeEra1GL7VDzSCUnpRLWZJhb81kSjnkjVUFwhiDobWqcguxPzRgnDN CFOXKkuGrWs5jq8g65gfnWwMvw1/HMHD84kSGiXQ/uaLNrqXEbE/jAgqYqXS1O8xBfLC qKemlzBgBoXLxplpBu+sAyjSphp1ZLtPSC8KmVs6Te8GPuQgu2yCiDDX89h3ORCoXx6w nsR4OntxT784OE0Q9kHUXpzRFRoHgWy492xASBcxRW+Zu2AftqC6kDB69klJLEvrQEOU H7FBbpqOJJU3HG2U12xrhERyooC1oJez1TnEPwV/emsRFbItqo8smIGtODVmlXAcGhBs M8cQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=tMvryF9qkcHmjr/I6qQdi1be4a3BwpUnonGBJuEa1aE=; fh=tZH5GccmXiaTls3YAk+ZLW3rOEDc9RT9a/9kmWJgcIM=; b=d1L3dH1s5aP3fgBn3GSxdJXyCeQh/3h7IHCBYaGokPUo3RH1750mjecdJODREgmpPH 08Ps/M0CX751Ydu1Ru81Ho2KLEky7bu97jxTob00seoJcdP2KnuGvdwheFf3EBP/bDt1 vs3MaKPJrK+aZE32/ku1WbB767qe1Zb8efVaYNhVKrJ84/FbiJswimzKZQ86DY8kEphx UAwT5nMkdAYRnXUeNalDhFM/xRuayAw0xKy09PNmO4L2lpA+EFcafzYbSZ+ed2Rvkhhs kmfcbIvh5BoN4fFN+R7H02Lu9bYATwO77c++vggUjpTH6BoPNnQyv8G/i1AW2oX5WYKl /mvw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ODYsXzs2; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6d179a108e5si16599056d6.250.2024.10.25.07.14.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 25 Oct 2024 07:14:02 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ODYsXzs2; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t4L4J-0004XO-O8; Fri, 25 Oct 2024 10:13:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t4L49-0004OH-24 for qemu-devel@nongnu.org; Fri, 25 Oct 2024 10:13:25 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t4L3x-0007uK-Gd for qemu-devel@nongnu.org; Fri, 25 Oct 2024 10:13:24 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-4315df7b43fso21476885e9.0 for ; Fri, 25 Oct 2024 07:13:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729865592; x=1730470392; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tMvryF9qkcHmjr/I6qQdi1be4a3BwpUnonGBJuEa1aE=; b=ODYsXzs2oGzg1KOhMmCailOU5vkt1bPS2TGEQXiA+TdVtyXlO5EegJGbAnpW+KMxuh Rili1Yv+mQm5aWsp72XSTnuAioIh3+zcqwP0aXwjDFRbtvOzOH0zjpvB9L7bvDs7WpXN AUfj8e7oM2JUZSA7vdrvmG5T9c0V8tPOVXv0Xey67A6eATfqM/tsw0Y3zxv7cTlFxalF mii0bzftcopxGirixt2HnIWYTTjFyCc11TtBi6m8p97oZvYgCjDPLGmXPswaoqHG5Ddj 91h2C9BsEhg7/x89ABiIfwUXd+V8I/nvpIGWeNYfFyVETbNRNcN45yCkfF3pmNAU08JH G53w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729865592; x=1730470392; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tMvryF9qkcHmjr/I6qQdi1be4a3BwpUnonGBJuEa1aE=; b=vKWL7CPJ4wL7exh5LfXNDlw8fGiPLCdzcem568EAsGAdN2IjBXlXoRxkUpoVoPLnMm NWHnKOfmeB6ZFzR3l6B+iuhk6yOAya7RabvdXd7DoTpwITQb0D6kiOwGfzRSq2hT/TgS mFG0nclpTyyJLXeAwYoARL/54pQe964NDjrFN0KxKMlYoGz0CFh2IOvJjJgctSStpAZn 7ZozidvmZsb/Mh8QmgdMVkzwANP8i/SO1pB2PGCzd1s7Mxqjg21y8CGu9X+CwcfWYvH7 bOwTgejWIflce0MeBcOgn4blSbpEgcMA2R/fhVuyL92qNIfWOsBEGyFLUgL8t0vWoKoP vFEA== X-Forwarded-Encrypted: i=1; AJvYcCXSpcpcq/E8ZQqTCiGvBkzref6jLugofI34lmZkUF/R7YivpRbHzqL6dw8qJNs/YHKEZGSbjUoAByf+@nongnu.org X-Gm-Message-State: AOJu0YyQxGNeQwS3zg9alFRrKLEa3iHqHwh4UDFMGmfjZtJZE5QA8Vmn pVJHRwj7PnEyCJBL6pd8/FqEBkRGRo1FnTLa86iIoev6pXAbn8gVLvGlC/GV37I= X-Received: by 2002:a05:600c:19c6:b0:431:4fa0:2e0b with SMTP id 5b1f17b1804b1-4318c754b24mr47132065e9.28.1729865591969; Fri, 25 Oct 2024 07:13:11 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4318b57b051sm50104535e9.42.2024.10.25.07.13.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 07:13:11 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Song Gao , Eduardo Habkost , "Edgar E. Iglesias" , Jiaxun Yang , Aleksandar Rikalo , Stafford Horne , Nicholas Piggin , Daniel Henrique Barboza , Yoshinori Sato , David Hildenbrand , Ilya Leoshkevich , Thomas Huth , Mark Cave-Ayland , Artyom Tarasenko , Max Filippov , qemu-ppc@nongnu.org, qemu-s390x@nongnu.org Subject: [PATCH 18/21] target/microblaze: Explicitly set 2-NaN propagation rule Date: Fri, 25 Oct 2024 15:12:51 +0100 Message-Id: <20241025141254.2141506-19-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241025141254.2141506-1-peter.maydell@linaro.org> References: <20241025141254.2141506-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Set the NaN propagation rule explicitly for the float_status word used in the microblaze target. This is probably not the architecturally correct behaviour, but since this is a no-behaviour-change patch, we leave a TODO note to that effect. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- target/microblaze/cpu.c | 5 +++++ fpu/softfloat-specialize.c.inc | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c index 6329a774331..14286deead9 100644 --- a/target/microblaze/cpu.c +++ b/target/microblaze/cpu.c @@ -202,6 +202,11 @@ static void mb_cpu_reset_hold(Object *obj, ResetType type) env->pc = cpu->cfg.base_vectors; set_float_rounding_mode(float_round_nearest_even, &env->fp_status); + /* + * TODO: this is probably not the correct NaN propagation rule for + * this architecture. + */ + set_float_2nan_prop_rule(float_2nan_prop_x87, &env->fp_status); #if defined(CONFIG_USER_ONLY) /* start in user mode with interrupts enabled. */ diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc index a5c3e2b8de5..40cbb1ab73b 100644 --- a/fpu/softfloat-specialize.c.inc +++ b/fpu/softfloat-specialize.c.inc @@ -406,7 +406,8 @@ static int pickNaN(FloatClass a_cls, FloatClass b_cls, || defined(TARGET_LOONGARCH64) || defined(TARGET_HPPA) \ || defined(TARGET_S390X) || defined(TARGET_PPC) || defined(TARGET_M68K) \ || defined(TARGET_SPARC) || defined(TARGET_XTENSA) \ - || defined(TARGET_I386) || defined(TARGET_ALPHA) + || defined(TARGET_I386) || defined(TARGET_ALPHA) \ + || defined(TARGET_MICROBLAZE) g_assert_not_reached(); #else rule = float_2nan_prop_x87; From patchwork Fri Oct 25 14:12:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 838363 Delivered-To: patch@linaro.org Received: by 2002:adf:e287:0:b0:37d:45d0:187 with SMTP id v7csp309258wri; Fri, 25 Oct 2024 07:18:46 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV2hkPL9Mg/TrFMgEMQ3QYM4mrlGS/I08YPqD4Pv0CQkO4URpCK0o94/aGTV5jyXlhdI75t7w==@linaro.org X-Google-Smtp-Source: AGHT+IGLkjVsRu+5876sUfluoiymoe6Ku37HSTpr+VyfgW+RwPyRlU6nev7fYraB09kGKRAC0V84 X-Received: by 2002:a05:620a:4413:b0:7b1:4940:e9f5 with SMTP id af79cd13be357-7b186bb2a9bmr741215585a.18.1729865926736; Fri, 25 Oct 2024 07:18:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729865926; cv=none; d=google.com; s=arc-20240605; b=Wu9BpZ5RFuHH8Y9/CFS/jRwP9Ln9KaupYJGXiuV/jloIBCimqlFXMM2QZj9WkKiaX1 tkqvCwQs+dtn7B6XLZFFhQFFPcGWyYyqQJeMv2OlgLJWGEfTNpIg+vqP+y4hpgvQh/Az afvm3B0EaeoLruC0Whso1NZOpQZFN7NM9ZjB5zKWo10V7MQpV/SevtnvwMViqBr868mn gu40oCAIM3CzZ5whR9NEvhByO4Cy09EJkL33bULvn0u4pJL35SxYmyt4kzUMmaFduG2D 2uMcSChB7P2sr0+u8mcGjj7XrEtDPlnTSSgPJUZtNGBl6xp7NY8rF42eeRDhkUD9nunr wnKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ID1X5YPOP+wvOiim/+MbdA0+ojv9rI9zYRkjUusf1JE=; fh=MdZyvABTR4Gr48YQg8oSoHG4tFa6/Z6x1llEAnNb0w8=; b=Gn/+hC7NSxieViYKwlK7TZPUTcHTPo2OvAjJkWjreHCpzKT4AY714aioFSjqG8IZDZ l56FGCOQBeTHeAe0W7WKvjUGl73Sx9vT3VmpyRIv7Lr06cdr70UkmbX9MaI0TMdcoPOw 1vQpF0CygE804Xbpv5kKatKhgomZDb9stjAE/LyKpD5CSfvZQeKcuPWicSwrnaAVfyEm AzpE6KXNNgslusjcL/EL6yABfo0D3SdQ9U6ZOScW2FWVXJZedn34KvIofVKI5yoHbDYU fp4NDc37v25325wL8B5PTyUFHJV7TXgSttfW9DBhVZK4tODxCZTS3wwmtlsm5+IRs8Zb Iotw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=frUVCa6z; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7b18d362384si156976785a.640.2024.10.25.07.18.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 25 Oct 2024 07:18:46 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=frUVCa6z; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t4L4I-0004VJ-9m; Fri, 25 Oct 2024 10:13:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t4L4A-0004PK-Kq for qemu-devel@nongnu.org; Fri, 25 Oct 2024 10:13:26 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t4L3y-0007uk-EN for qemu-devel@nongnu.org; Fri, 25 Oct 2024 10:13:26 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4314f38d274so27178475e9.1 for ; Fri, 25 Oct 2024 07:13:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729865593; x=1730470393; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ID1X5YPOP+wvOiim/+MbdA0+ojv9rI9zYRkjUusf1JE=; b=frUVCa6zjscDYAOYmoQ8cjuBVXi9RkfQzHEIXNN41ZZV86q2w5A/+NuWeG/1eSgVxq kjH0pmkygx55ygkHZoSbT4CSLBwcoKHx1ZlT8aP2tmon9HxCA4/BMUXlSlnlc7hIa+st v4M5JI+s/p3+C+6oVGnIB5yxH7F2blMWFXiALkAYNsTIY4IUZHVGv3+K1N6u9xeodi1x 6ofMEW5gthepKcGKjPP/nniHttGyqCvwWCc7fTHq2LAdwnp7KfKadl4LBF5jGaWfeqMm K8viK/smDnec+yXRuxV3NlZidwycqY47bZQe1N+gvO9/noWRYMRawwiaT6NQ/WlAB7BL 4Geg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729865593; x=1730470393; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ID1X5YPOP+wvOiim/+MbdA0+ojv9rI9zYRkjUusf1JE=; b=vqQU9EAb9R6LQx8k63hrVg4hzNP5aJUjsMvlA+mqe9WcT47fA5EODfTwcBPcCCTM72 dH8CfP0MeA5l6DTo3uNv5zP6qmyMyje2aXsTWUh9Axc6kYIJLQd84hnG0VlFY29S9E0g OX/mDyNaepuVQUFGmFNSkI+WZ8lKpAEUxfFDDwlPvIVCFMb+M7dy3KFe2jgGPo2tkiJf nGTAY/217PVu7kvGZGh1FoHYyqnHqOD5groDPxqiGC5hy46StEAOtXD/0CTPDRvNzLrX 2i8Q3oPwo5tJY7GxZqDmHrfUwgeToHcgCxcFB0+sM2sOiFfQfJNcn52UsY2aa1k3EEpy 9wkg== X-Forwarded-Encrypted: i=1; AJvYcCVn1jWLWtTyS0zKDzJyQ86UnVdHj77R3RgDGyvfOCNczTK2RQiN7DhJFAn0jQqf15+vPBEEJO8KT0hi@nongnu.org X-Gm-Message-State: AOJu0Yz+8RprHoMc9OHKYvGBeP1fXps4vuN0TLhSUlpEuhJV4LP9eH4B vexVAbozARx4pzjn3imPUdl9RisVdqNPMk2zitla6n1RnkWvGDwgkaeo5WcXCpM= X-Received: by 2002:a05:600c:4f04:b0:431:24c3:dbaa with SMTP id 5b1f17b1804b1-4318c8db165mr63501525e9.2.1729865592796; Fri, 25 Oct 2024 07:13:12 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4318b57b051sm50104535e9.42.2024.10.25.07.13.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 07:13:12 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Song Gao , Eduardo Habkost , "Edgar E. Iglesias" , Jiaxun Yang , Aleksandar Rikalo , Stafford Horne , Nicholas Piggin , Daniel Henrique Barboza , Yoshinori Sato , David Hildenbrand , Ilya Leoshkevich , Thomas Huth , Mark Cave-Ayland , Artyom Tarasenko , Max Filippov , qemu-ppc@nongnu.org, qemu-s390x@nongnu.org Subject: [PATCH 19/21] target/openrisc: Explicitly set 2-NaN propagation rule Date: Fri, 25 Oct 2024 15:12:52 +0100 Message-Id: <20241025141254.2141506-20-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241025141254.2141506-1-peter.maydell@linaro.org> References: <20241025141254.2141506-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x333.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Set the NaN propagation rule explicitly for the float_status word used in the openrisc target. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- target/openrisc/cpu.c | 6 ++++++ fpu/softfloat-specialize.c.inc | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/target/openrisc/cpu.c b/target/openrisc/cpu.c index 6ec54ad7a6c..b96561d1f26 100644 --- a/target/openrisc/cpu.c +++ b/target/openrisc/cpu.c @@ -105,6 +105,12 @@ static void openrisc_cpu_reset_hold(Object *obj, ResetType type) set_float_detect_tininess(float_tininess_before_rounding, &cpu->env.fp_status); + /* + * TODO: this is probably not the correct NaN propagation rule for + * this architecture. + */ + set_float_2nan_prop_rule(float_2nan_prop_x87, &cpu->env.fp_status); + #ifndef CONFIG_USER_ONLY cpu->env.picmr = 0x00000000; diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc index 40cbb1ab73b..ee5c73cad46 100644 --- a/fpu/softfloat-specialize.c.inc +++ b/fpu/softfloat-specialize.c.inc @@ -407,7 +407,7 @@ static int pickNaN(FloatClass a_cls, FloatClass b_cls, || defined(TARGET_S390X) || defined(TARGET_PPC) || defined(TARGET_M68K) \ || defined(TARGET_SPARC) || defined(TARGET_XTENSA) \ || defined(TARGET_I386) || defined(TARGET_ALPHA) \ - || defined(TARGET_MICROBLAZE) + || defined(TARGET_MICROBLAZE) || defined(TARGET_OPENRISC) g_assert_not_reached(); #else rule = float_2nan_prop_x87; From patchwork Fri Oct 25 14:12:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 838346 Delivered-To: patch@linaro.org Received: by 2002:adf:e287:0:b0:37d:45d0:187 with SMTP id v7csp306248wri; Fri, 25 Oct 2024 07:14:11 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXitBHZQpCr4nXY6cwwrHm+KbMilK7ND0Dil7/eU6vnEvrek0lFaibfhgT+IyaUGIyxzQovow==@linaro.org X-Google-Smtp-Source: AGHT+IGNO0OMYDPcuI0s83R75/tpB+BDsDaUoo4bUW9lWi4PpNg/631VtZj99y0QifmU/7f5yPq9 X-Received: by 2002:a05:6902:1b87:b0:e2b:d4ef:25e8 with SMTP id 3f1490d57ef6-e2f2fbc3550mr5578771276.46.1729865650895; Fri, 25 Oct 2024 07:14:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729865650; cv=none; d=google.com; s=arc-20240605; b=PTkfdQXEFTP7YGuAPgoSMnvsScrDJZxUOMFu6CL7xITA3XRJw96wIfdC3rRFRyy39Y yT+CFNHnz8k9co6hdoplS99zJSVam/0mHNwAJe2Hw/3lbVJmqfd0bcGEOnmoM6ydTjeL asvPZpnAANvjo8MVycdGDuTeSQaWNkEHVD3134JxFCHLEJmPCqR2GsZIFL5ZwvRvEvlu 2fglRuElmSGYTHkUvegdvAwN8XxF/cjtoF9Qxz1ed1r+/Tth0aOq7hroHAIpqt9FBWn0 a4YitiAL4itmrrVUoLoKeQ1hnAj9lHib1HFwEaVz+1Fcne/X8DNOFhOJELfni/me/T6o rMwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=D17Ee6pVmUO+XC5zV2qFLSsZ3L5n+f/7oR7L3Btz1qY=; fh=pPmVlts4ZUf1sVXFwaDLw+UdVSXh/fOnabnSaIOIurE=; b=JIaHBa3oOLngF9JaxKmxwVcrEmlGx9L20YsH4X5UD73Db0zLKamBLNbSWfulOxTBzk 5Knqb6djRpHEwsqn+JpQYgkhxK0I+AxYC/looqm+/oLAVjhnTPz+l9PNYxSn3s4gDG75 OTQgWpSaC3aMgnhLFk6qIoGDfJdtSyfSTerB5Pv2mmjL2mh4hPybIwlMxIho/rmpc3WM rTL5ySLYZiIEw32wAC9e8ovKUQm6JUwmLacSFLwKK0fsoD0KB2BUUdNcywixBR9hrWCR o5+F3VrnnV0Osb/cp/Lb+Ww2k99jQY1tm6MWCzzEmu4KxExgYAsEjW2R3IgQ7HXSLQzw gh4w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cAK75Km+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-4613235ddcfsi15012621cf.350.2024.10.25.07.14.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 25 Oct 2024 07:14:10 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cAK75Km+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t4L4R-0004nQ-BG; Fri, 25 Oct 2024 10:13:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t4L4A-0004PJ-KO for qemu-devel@nongnu.org; Fri, 25 Oct 2024 10:13:26 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t4L3z-0007vH-34 for qemu-devel@nongnu.org; Fri, 25 Oct 2024 10:13:26 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-4316e9f4a40so21294035e9.2 for ; Fri, 25 Oct 2024 07:13:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729865594; x=1730470394; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=D17Ee6pVmUO+XC5zV2qFLSsZ3L5n+f/7oR7L3Btz1qY=; b=cAK75Km+rTrSaHVpzm5LZt73g11cAWk0qPgRPeZN58LFEMdFV2iBKNVT5IwzgLWqD0 s67H6KcSyLqO6Gp445X+v4aRQY8NMlaeuF1yhkNqQJqtM01f06VkCbUuSQxxVHYYbVv0 pFFyAPGWwv3GtxgafnApGvaD9iGWNVz6jsb6c07Ry2RuO62bAAWU5cLbJ4xwdiLvIc6J lPm2nlbJflFosP7oUUZikzhy3Tu1r/R4JoTjyKzRkMrUhkSfbDFijR8JQ4QXzD28U+uZ axOZNiQkHyLEAB0sK5yyWX1I9H8B5ZZQtqiw00ReaBzrLcZ0gBdhFJprxauYAjrhVCXd 1O9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729865594; x=1730470394; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=D17Ee6pVmUO+XC5zV2qFLSsZ3L5n+f/7oR7L3Btz1qY=; b=E4RX1SJbpeKJke0HEjBntB7KTPGVLbbsELTnC+Hn/5K10N2Fvjb1Xluua8auLQR+b8 XdvUvzxokdNKtkqHPfbkvf9gWuBQGSPvrWmhNYKMya/BlyuNoEnGS2R2HiE5AU9hbiPh Lsa1h7I1+XsOY8xunAel44hqDJnzmDuwDuyUFGaIzcJ9R27E0cQ64AudpguvwY9jeGAU ONv4y2uAwcDU0Mb/CMsuKV8OxOVlM02CNqRVyJc0leJrCYifdolsQa0D6A6ypRCn4Bxw z5JBImFq7JrW6GuMweQrT+iq+EpApr7XLkLIfAw+6iskAsTtJ7/IC5ApiE0eb7dvA3S9 qY3A== X-Forwarded-Encrypted: i=1; AJvYcCW9vwAS7KymATEnbDbI5ih616xX1mrNkklBIBRlflJ6OzhwWmpvU+TKPdEtZ6vaCZwSbllcj3fGvg1l@nongnu.org X-Gm-Message-State: AOJu0Yzc2fQKohB3TFloZ94KF0PKtaaq+uqg0WxezByRDBsA9SaI1CYk QmWkKG6AssXdM82KXRSwG+BT3t+Uipz87ZhVCpd32KIMxR+sFQO0MHIKWK8sLjE= X-Received: by 2002:a05:600c:1d98:b0:430:5356:ac92 with SMTP id 5b1f17b1804b1-4318c6e8ad6mr49585085e9.7.1729865593604; Fri, 25 Oct 2024 07:13:13 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4318b57b051sm50104535e9.42.2024.10.25.07.13.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 07:13:13 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Song Gao , Eduardo Habkost , "Edgar E. Iglesias" , Jiaxun Yang , Aleksandar Rikalo , Stafford Horne , Nicholas Piggin , Daniel Henrique Barboza , Yoshinori Sato , David Hildenbrand , Ilya Leoshkevich , Thomas Huth , Mark Cave-Ayland , Artyom Tarasenko , Max Filippov , qemu-ppc@nongnu.org, qemu-s390x@nongnu.org Subject: [PATCH 20/21] target/rx: Explicitly set 2-NaN propagation rule Date: Fri, 25 Oct 2024 15:12:53 +0100 Message-Id: <20241025141254.2141506-21-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241025141254.2141506-1-peter.maydell@linaro.org> References: <20241025141254.2141506-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Set the NaN propagation rule explicitly for the float_status word used in the rx target. This not the architecturally correct behaviour, but since this is a no-behaviour-change patch, we leave a TODO note to that effect. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- target/rx/cpu.c | 7 +++++++ fpu/softfloat-specialize.c.inc | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/target/rx/cpu.c b/target/rx/cpu.c index 36d2a6f1890..65a74ce720f 100644 --- a/target/rx/cpu.c +++ b/target/rx/cpu.c @@ -93,6 +93,13 @@ static void rx_cpu_reset_hold(Object *obj, ResetType type) env->fpsw = 0; set_flush_to_zero(1, &env->fp_status); set_flush_inputs_to_zero(1, &env->fp_status); + /* + * TODO: this is not the correct NaN propagation rule for this + * architecture. The "RX Family User's Manual: Software" table 1.6 + * defines the propagation rules as "prefer SNaN over QNaN; + * then prefer dest over source", which is float_2nan_prop_s_ab. + */ + set_float_2nan_prop_rule(float_2nan_prop_x87, &env->fp_status); } static ObjectClass *rx_cpu_class_by_name(const char *cpu_model) diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc index ee5c73cad46..254bbd67168 100644 --- a/fpu/softfloat-specialize.c.inc +++ b/fpu/softfloat-specialize.c.inc @@ -407,7 +407,8 @@ static int pickNaN(FloatClass a_cls, FloatClass b_cls, || defined(TARGET_S390X) || defined(TARGET_PPC) || defined(TARGET_M68K) \ || defined(TARGET_SPARC) || defined(TARGET_XTENSA) \ || defined(TARGET_I386) || defined(TARGET_ALPHA) \ - || defined(TARGET_MICROBLAZE) || defined(TARGET_OPENRISC) + || defined(TARGET_MICROBLAZE) || defined(TARGET_OPENRISC) \ + || defined(TARGET_RX) g_assert_not_reached(); #else rule = float_2nan_prop_x87; From patchwork Fri Oct 25 14:12:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 838358 Delivered-To: patch@linaro.org Received: by 2002:adf:e287:0:b0:37d:45d0:187 with SMTP id v7csp307883wri; Fri, 25 Oct 2024 07:16:45 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUJ6uwSStGkJlDYtXobzUR16+oUTCPEN0kMvzzXmX5fD4RJJE4EZlCGdGr40gVVeiIH7xJ/pQ==@linaro.org X-Google-Smtp-Source: AGHT+IFthTYnclus0XSXNr6abqWRTVxl/ngIkccKz34MAyBuWeHShKyRGRI7+fBJ83AmavQ0Fv4e X-Received: by 2002:a05:6102:3a07:b0:4a4:911a:46a2 with SMTP id ada2fe7eead31-4a8711e1f44mr7693609137.27.1729865805354; Fri, 25 Oct 2024 07:16:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729865805; cv=none; d=google.com; s=arc-20240605; b=QtGyNKyb/1Bx7fsGLSUwvEnPTUyiYdF54yYs229MjgA4s3j5nuBq21uGrkE8xmIAPE nvJUiATILOds/fJX10aAldB2VSJ39wY9V8NEy4FTMHxDPzfU3eJAS9zXMdNynFKewjHP a8jYi17OZUwQ1CI7J33kDeCuAUGIzXkK3xSzSqZ/3hKoKipnKI5K9UKsrPbum6R7D8YR tlEJK2XOJnq3UUEevAmDlG9OemPSzDDI1Yb/McRM44hA6YR20qbBEonRZ3w0VZGAkVSp aTy8xUo6gPtyTpU1qvyhcmW62e1sHuUDKWJeV5BsVGmagzwZvn6+Gqx8Cpm8/Q4EyMEe UC/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=3a+J6mOz6+tgsx1AS0v8GOVI5VoZBPQJco52huASzlo=; fh=TBWRBX4umOyBPeEYoQZdZYiSFW59J6TaQAopXY7hC0M=; b=N3sEHrHoO6GVHy+EmKzSrOSgCkbJT6TS5JNh5+X4MBiHVRkeYUhgVvd0E6kk5QuHhI qKXi5BT1zqGQArURUyRDpEAjLkmwWF9RHf5wNV1ZvtBaEIWzRXCf9OvGBrkGqDkKghsi 5AM3YFqrFaXqkSRU0QddDnlSST3y6P3S5/9uFdxNoOLIcngh7r19SELpAEIiiVLkhX8E ue62/a1A21n1pW8rmPOfuOOVDsARtNZ/rWIIsvBwiV/sngqfVhK0ChOoG3fYCW4d1Svh N35Rgh59YKOXpRtfo7Y3iVlw8hAnJsJQ7I6UYXBaOeeo541o7bxjlZMSDGCnQi3ugHRY opyg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=swGkzWKB; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ada2fe7eead31-4a8c51d22e9si304820137.148.2024.10.25.07.16.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 25 Oct 2024 07:16:45 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=swGkzWKB; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t4L4Q-0004jS-De; Fri, 25 Oct 2024 10:13:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t4L4D-0004RY-3c for qemu-devel@nongnu.org; Fri, 25 Oct 2024 10:13:29 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t4L40-0007vx-25 for qemu-devel@nongnu.org; Fri, 25 Oct 2024 10:13:28 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-4315eeb2601so27049265e9.2 for ; Fri, 25 Oct 2024 07:13:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729865594; x=1730470394; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3a+J6mOz6+tgsx1AS0v8GOVI5VoZBPQJco52huASzlo=; b=swGkzWKB74q/r6UrCjCpsnhkDVw6Jws4JQpv2NNPOqK2jbJxltko7H1+s8u/qRECcz EFrs4zJ52KlVn4HQ7M8a5bAgpanB0ujovC6GcYbm0RG/PaxnV3d2eSc8QmTym7D/Bqgq MjyH2wAhQpFCQuKjtwXgv0Bz4ijnmxfYngxfItHVH5kQKIhRIbO2Wr63fThNWYnzrswq 9O9h4ba8jTOW/5EMdqZIFdnZgL12fjKgOZRzXfDz0ByziOT9Z38yMkm8wUdgUoGEjVQ1 aV5kjVtvnf5sApbcb8kgcSp4PiKiNtge8Ur6Yk66Grv2f8ZtceGDJp5uzY0QOYL1JYOl 7uEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729865594; x=1730470394; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3a+J6mOz6+tgsx1AS0v8GOVI5VoZBPQJco52huASzlo=; b=t83tJoNs38s7o6wBQ6WMzW79SFYB4DdyEP3s/W4ZcuvOEZem9ql8hjz48jMOTuVn3e a7CnzyqHcL7VuE9WJa98DSlpGMY2uAn1/gLaQlwSO1Qx6uFejvEixxiqLHOEOpOHqH7i y0sefcqDjOsebmc2IdDMKADhjOMMimDCMavV+6PZbSi+5fhXvepQDDYvN6direHDYL/i +IL6FOGaTHvuKQ1brB/C69XrRvEtKN0AoErXW3Q1kXEJybD3pbENk2zoUUXROOH+PwyM kb4UBmsFU+kXyShv3to2Og8tZ1Le006dqAb+tg3bqbJ/fQeMHZPgjHWF3jz+Q+zlFAzF oUGQ== X-Forwarded-Encrypted: i=1; AJvYcCXG3OTE2UuWYaa7HvRCDEekEU4TtZ1wX8wK7mJeO1VP8t0ea7JUuytTHdFXbxI2M/294CM8C8MobqaA@nongnu.org X-Gm-Message-State: AOJu0Yw043jVn3efLLYBe/6vnrtdCkffPwABDMfe9bSVbgsM7dJDdhoe 7dKiQOKoDit7OLLohtMzLjUB33uwiDMjWTNZ8UgZT1rXZf8thbP8bPMnCDez85w= X-Received: by 2002:a05:600c:1d82:b0:431:5ba1:a520 with SMTP id 5b1f17b1804b1-431841eb454mr112345445e9.3.1729865594517; Fri, 25 Oct 2024 07:13:14 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4318b57b051sm50104535e9.42.2024.10.25.07.13.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 07:13:14 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Song Gao , Eduardo Habkost , "Edgar E. Iglesias" , Jiaxun Yang , Aleksandar Rikalo , Stafford Horne , Nicholas Piggin , Daniel Henrique Barboza , Yoshinori Sato , David Hildenbrand , Ilya Leoshkevich , Thomas Huth , Mark Cave-Ayland , Artyom Tarasenko , Max Filippov , qemu-ppc@nongnu.org, qemu-s390x@nongnu.org Subject: [PATCH 21/21] softfloat: Remove fallback rule from pickNaN() Date: Fri, 25 Oct 2024 15:12:54 +0100 Message-Id: <20241025141254.2141506-22-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241025141254.2141506-1-peter.maydell@linaro.org> References: <20241025141254.2141506-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x329.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Now that all targets have been converted to explicitly set a NaN propagation rule, we can remove the set of target ifdefs (which now list every target) and clean up the references to fallback behaviour for float_2nan_prop_none. The "default" case in the switch will catch any remaining places where status->float_2nan_prop_rule was not set by the target. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- include/fpu/softfloat-types.h | 10 +++------- fpu/softfloat-specialize.c.inc | 23 +++-------------------- 2 files changed, 6 insertions(+), 27 deletions(-) diff --git a/include/fpu/softfloat-types.h b/include/fpu/softfloat-types.h index 5cd5a0d0ae1..8f39691dfd0 100644 --- a/include/fpu/softfloat-types.h +++ b/include/fpu/softfloat-types.h @@ -178,13 +178,9 @@ typedef enum __attribute__((__packed__)) { * If default_nan_mode is enabled then it is valid not to set a * NaN propagation rule, because the softfloat code guarantees * not to try to pick a NaN to propagate in default NaN mode. - * - * For transition, currently the 'none' rule will cause us to - * fall back to picking the propagation rule based on the existing - * ifdef ladder. When all targets are converted it will be an error - * not to set the rule in float_status unless in default_nan_mode, - * and we will assert if we need to handle an input NaN and no - * rule was selected. + * When not in default-NaN mode, it is an error for the target + * not to set the rule in float_status, and we will assert if + * we need to handle an input NaN and no rule was selected. */ typedef enum __attribute__((__packed__)) { /* No propagation rule specified */ diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc index 254bbd67168..b5a32080505 100644 --- a/fpu/softfloat-specialize.c.inc +++ b/fpu/softfloat-specialize.c.inc @@ -390,32 +390,15 @@ bool float32_is_signaling_nan(float32 a_, float_status *status) static int pickNaN(FloatClass a_cls, FloatClass b_cls, bool aIsLargerSignificand, float_status *status) { - Float2NaNPropRule rule = status->float_2nan_prop_rule; - /* * We guarantee not to require the target to tell us how to * pick a NaN if we're always returning the default NaN. + * But if we're not in default-NaN mode then the target must + * specify via set_float_2nan_prop_rule(). */ assert(!status->default_nan_mode); - if (rule == float_2nan_prop_none) { - /* target didn't set the rule: fall back to old ifdef choices */ -#if defined(TARGET_AVR) || defined(TARGET_HEXAGON) \ - || defined(TARGET_RISCV) || defined(TARGET_SH4) \ - || defined(TARGET_TRICORE) || defined(TARGET_ARM) || defined(TARGET_MIPS) \ - || defined(TARGET_LOONGARCH64) || defined(TARGET_HPPA) \ - || defined(TARGET_S390X) || defined(TARGET_PPC) || defined(TARGET_M68K) \ - || defined(TARGET_SPARC) || defined(TARGET_XTENSA) \ - || defined(TARGET_I386) || defined(TARGET_ALPHA) \ - || defined(TARGET_MICROBLAZE) || defined(TARGET_OPENRISC) \ - || defined(TARGET_RX) - g_assert_not_reached(); -#else - rule = float_2nan_prop_x87; -#endif - } - - switch (rule) { + switch (status->float_2nan_prop_rule) { case float_2nan_prop_s_ab: if (is_snan(a_cls)) { return 0;