From patchwork Thu Feb 6 19:56:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 862537 Delivered-To: patch@linaro.org Received: by 2002:a5d:51d2:0:b0:385:e875:8a9e with SMTP id n18csp284399wrv; Thu, 6 Feb 2025 11:58:43 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVW0XcSwfO75JmzjbiH9DgSWDjNfosp36+/K7+iqwug+uQVbKPp+Zzm5DcBc/fF+j3yaJxk4A==@linaro.org X-Google-Smtp-Source: AGHT+IHkkqNAAhgVy5G6yZfY0q7b81N3a/zzcLJGrOoWx6K11uhSxyDUmFV50HfKkunfVmkAtoeY X-Received: by 2002:a05:622a:1495:b0:467:561a:6ad1 with SMTP id d75a77b69052e-47167ad11aamr6510421cf.42.1738871923640; Thu, 06 Feb 2025 11:58:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1738871923; cv=none; d=google.com; s=arc-20240605; b=DO3UmLBb8gE7lf2of335CGlv9nCxi9H/0FRE+Aw8mRNs04q092RkRvQVGnqk9gravf aJCSxk9hT5pMBjOvaecSGPOiEiQ9yctNAPNkUpTDXb70C95l1/kjR9RIf/LfIEiOkjT7 7H1Etcyf6jbd4QQglPK/Dcd3TbCd1mOyOu6/OoEm4xw8g0l4f9QClOko5FhoZOebjjW9 ynX2IUu4b/xDE2w4kJ7FZgD3BR9gQrLZgbBPQHCU4EPNp2op5XRQS0M/OzjCngUbFbqh jjFmpNCkVjreTYvhcLfGwfnPJMCo6EP300VMSau7kE85xEq9dElrWIYISzf8bXpfLYdR w7Gg== 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=2gdYxBdEqJ0uWnKxFXykRwPyqfo99tq7h+X2aYPXavI=; fh=9Ev+QBUhk6P6vR3LT1wYeDLexozsz44nqjfoyPajZCc=; b=eQLgkuBQCGrQbJgbBbgQrCQAnCSURK2Rlsw4vXU/jvxZjIRwBBiXKOiboGifvkH+wJ TC4jxP59Apb3TVM3OkLeaMWhW4wg1s5n7G987mwG7qrY265ZyjnZfqKUvKksiVYM+t/x MQsKZqdS2kdE+8JnerHjBb5lE+0kgnsotzu6bHv1gsmYUYO1w0t1e0skPwCbqaR9Y742 SJPjoK0PGKfLfoG0wrbMKDHQGzgfERROUw+VJzvWfoMrmhY3HiwPUkwY3G00EC3YFt5M gU6KqTWF4atqfgVB/WFrE88A6bRfLYtvGIAgnm9IaOLZ3UPsUuR89xw1zwRoV7vIl9Np n/cA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RpqfLlq5; 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-47153bc27cbsi16644421cf.533.2025.02.06.11.58.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Feb 2025 11:58:43 -0800 (PST) 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=RpqfLlq5; 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 1tg80U-0007NT-L3; Thu, 06 Feb 2025 14:57:50 -0500 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 1tg807-0007A4-EV for qemu-devel@nongnu.org; Thu, 06 Feb 2025 14:57:27 -0500 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tg804-0000TM-Sn for qemu-devel@nongnu.org; Thu, 06 Feb 2025 14:57:27 -0500 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-21f49bd087cso9131315ad.0 for ; Thu, 06 Feb 2025 11:57:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1738871843; x=1739476643; 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=2gdYxBdEqJ0uWnKxFXykRwPyqfo99tq7h+X2aYPXavI=; b=RpqfLlq5Zgv0hEiGc1/z9nZazSJDw9X8wN515rlCDp+4UD1fXiZCZ5ZFks1+3Xhqqq AGfvW7zoJ59vKHoxflM5Jx9Plju7eKrkMyg5wMXMU3Y2L/zJfuIDrOanJpNhXFF7EeuB Re5l/B+XRZkWrvdo5z7QRHTNpjK8DA+X+OmoVcPNU9k96/gTCmJrUT7cUHUM46nvr4oT fBbRcWCShPCQmieMNvTyHjlM+tI5WocJoGaUR892izDqkm4meSbM0sGeqaZiD1KYtzJ/ cTYoFV0s4B8yOZ/XVBy7o0Yp0LGZi5O59P9ka5a55JgzP0flRjTZ/qnVR1UkNr+R8YBa VuLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738871843; x=1739476643; 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=2gdYxBdEqJ0uWnKxFXykRwPyqfo99tq7h+X2aYPXavI=; b=QRL7ROhVizQmHN8r2o1tODZ2iUVFXwOuuiWcG+hkgeMJ+Tc8DbhSiBS9KFNz7kx8IW qA5bn1N5HSN6ZgHE75jljXOxPMr2TtHIR+v4lNheOGROxtkQaeajFg3HkJGq3ttQTL4H rtKvJWqX9Sp5/CHEj+CMqByVSDZuApY+JQyXqz+qe39Pj7H+O609GUJwpv8LyPm/fWy6 wdcjNyZmFl4H3/OiPW5onRrnqwfjal7AuMG/U74am3k1EOpd25Ydc8Aq6PBZGGERBRtG DxquMw1dAgXNuFOOkrKUx9o1WOeD2BBRyEtv9MB8xBx1jou8ihJNTL12E8Z5QQUkbnVB F40g== X-Gm-Message-State: AOJu0Yz9et4kRe1FWFS1jj8lNmM4ocevcn2EjG4JvI4/bUIhFjksGzSu rCGdI2LmeNJTx4UWcDh8qCaqZex2hn2ghjScIogjOKfI0z7CB4ZrL1oCUUdbw1bAJdOsiCEx0Qx b X-Gm-Gg: ASbGncsqv5mDDR8u3laCyX9FqUGUuRmfaVB9AAVpGDidKWskQYYFpkqFd/6x68WOwFE CriAgNjMAXs5CiJNEeC+AdfHouw/dLCXnmGEqcNG4gSBUxb91UYegWnHSHgHi1+Tt/gjjdC7qEy ecsy04ROk8ffnA4XJM4Dqij8rWdJyOiuK6TGgNR3El1SrX9CoEHD0+SNhy75yYeCz4rvvxQaY8N G+B+uxzd7xXtsDn5VhVWe4g76Bo3CArja79jYP4KFBMxKxMolYUJtiiUcu1aVXmHg10y0RIVzYy JnI12g6DtQtYO4pnO/o/QARIA3of0OuTJi/0vkdtqx9pdzI= X-Received: by 2002:a05:6a00:420b:b0:71e:e4f:3e58 with SMTP id d2e1a72fcca58-7305d4e7461mr850654b3a.17.1738871843516; Thu, 06 Feb 2025 11:57:23 -0800 (PST) Received: from stoup.. (71-212-39-66.tukw.qwest.net. [71.212.39.66]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-73048c16370sm1666993b3a.152.2025.02.06.11.57.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Feb 2025 11:57:23 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 09/61] target/arm: Introduce FPST_ZA, FPST_ZA_F16 Date: Thu, 6 Feb 2025 11:56:23 -0800 Message-ID: <20250206195715.2150758-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250206195715.2150758-1-richard.henderson@linaro.org> References: <20250206195715.2150758-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::636; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x636.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 Rather than repeatedly copying FPST_FPCR to locals and setting default nan mode, create dedicated float_status. Signed-off-by: Richard Henderson --- target/arm/cpu.h | 12 +++++++++++- target/arm/cpu.c | 4 ++++ target/arm/vfp_helper.c | 10 ++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index e6513ef1e5..42c39ac6bd 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -219,6 +219,8 @@ typedef struct NVICState NVICState; * when FPCR.AH == 1 (bfloat16 conversions and multiplies, * and the reciprocal and square root estimate/step insns); * for half-precision + * ZA: the "streaming sve" fp status. + * ZA_F16: likewise for half-precision. * * Half-precision operations are governed by a separate * flush-to-zero control bit in FPSCR:FZ16. We pass a separate @@ -239,6 +241,12 @@ typedef struct NVICState NVICState; * they ignore FPCR.RMode. But they don't ignore FPCR.FZ16, * which means we need an FPST_AH_F16 as well. * + * The "ZA" float_status are for Streaming SVE operations which use + * default-NaN and do not generate fp exceptions, which means that they + * do not accumulate exception bits back into FPCR. + * See e.g. FPAdd vs FPAdd_ZA pseudocode functions, and the setting + * of fpcr.DN and fpexec parameters. + * * To avoid having to transfer exception bits around, we simply * say that the FPSCR cumulative exception flags are the logical * OR of the flags in the four fp statuses. This relies on the @@ -252,10 +260,12 @@ typedef enum ARMFPStatusFlavour { FPST_A64_F16, FPST_AH, FPST_AH_F16, + FPST_ZA, + FPST_ZA_F16, FPST_STD, FPST_STD_F16, } ARMFPStatusFlavour; -#define FPST_COUNT 8 +#define FPST_COUNT 10 typedef struct CPUArchState { /* Regs for current mode. */ diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 180e11c5d7..ba08c05ec6 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -550,11 +550,15 @@ static void arm_cpu_reset_hold(Object *obj, ResetType type) set_flush_inputs_to_zero(1, &env->vfp.fp_status[FPST_STD]); set_default_nan_mode(1, &env->vfp.fp_status[FPST_STD]); set_default_nan_mode(1, &env->vfp.fp_status[FPST_STD_F16]); + set_default_nan_mode(1, &env->vfp.fp_status[FPST_ZA]); + set_default_nan_mode(1, &env->vfp.fp_status[FPST_ZA_F16]); arm_set_default_fp_behaviours(&env->vfp.fp_status[FPST_A32]); arm_set_default_fp_behaviours(&env->vfp.fp_status[FPST_A64]); + arm_set_default_fp_behaviours(&env->vfp.fp_status[FPST_ZA]); arm_set_default_fp_behaviours(&env->vfp.fp_status[FPST_STD]); arm_set_default_fp_behaviours(&env->vfp.fp_status[FPST_A32_F16]); arm_set_default_fp_behaviours(&env->vfp.fp_status[FPST_A64_F16]); + arm_set_default_fp_behaviours(&env->vfp.fp_status[FPST_ZA_F16]); arm_set_default_fp_behaviours(&env->vfp.fp_status[FPST_STD_F16]); arm_set_ah_fp_behaviours(&env->vfp.fp_status[FPST_AH]); set_flush_to_zero(1, &env->vfp.fp_status[FPST_AH]); diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c index ff4b25bf28..f26c0d211e 100644 --- a/target/arm/vfp_helper.c +++ b/target/arm/vfp_helper.c @@ -202,6 +202,8 @@ static void vfp_set_fpcr_to_host(CPUARMState *env, uint32_t val, uint32_t mask) set_float_rounding_mode(i, &env->vfp.fp_status[FPST_A64]); set_float_rounding_mode(i, &env->vfp.fp_status[FPST_A32_F16]); set_float_rounding_mode(i, &env->vfp.fp_status[FPST_A64_F16]); + set_float_rounding_mode(i, &env->vfp.fp_status[FPST_ZA]); + set_float_rounding_mode(i, &env->vfp.fp_status[FPST_ZA_F16]); } if (changed & FPCR_FZ16) { bool ftz_enabled = val & FPCR_FZ16; @@ -209,15 +211,18 @@ static void vfp_set_fpcr_to_host(CPUARMState *env, uint32_t val, uint32_t mask) set_flush_to_zero(ftz_enabled, &env->vfp.fp_status[FPST_A64_F16]); set_flush_to_zero(ftz_enabled, &env->vfp.fp_status[FPST_STD_F16]); set_flush_to_zero(ftz_enabled, &env->vfp.fp_status[FPST_AH_F16]); + set_flush_to_zero(ftz_enabled, &env->vfp.fp_status[FPST_ZA_F16]); set_flush_inputs_to_zero(ftz_enabled, &env->vfp.fp_status[FPST_A32_F16]); set_flush_inputs_to_zero(ftz_enabled, &env->vfp.fp_status[FPST_A64_F16]); set_flush_inputs_to_zero(ftz_enabled, &env->vfp.fp_status[FPST_STD_F16]); set_flush_inputs_to_zero(ftz_enabled, &env->vfp.fp_status[FPST_AH_F16]); + set_flush_inputs_to_zero(ftz_enabled, &env->vfp.fp_status[FPST_ZA_F16]); } if (changed & FPCR_FZ) { bool ftz_enabled = val & FPCR_FZ; set_flush_to_zero(ftz_enabled, &env->vfp.fp_status[FPST_A32]); set_flush_to_zero(ftz_enabled, &env->vfp.fp_status[FPST_A64]); + set_flush_to_zero(ftz_enabled, &env->vfp.fp_status[FPST_ZA]); /* FIZ is A64 only so FZ always makes A32 code flush inputs to zero */ set_flush_inputs_to_zero(ftz_enabled, &env->vfp.fp_status[FPST_A32]); } @@ -229,6 +234,7 @@ static void vfp_set_fpcr_to_host(CPUARMState *env, uint32_t val, uint32_t mask) bool fitz_enabled = (val & FPCR_FIZ) || (val & (FPCR_FZ | FPCR_AH)) == FPCR_FZ; set_flush_inputs_to_zero(fitz_enabled, &env->vfp.fp_status[FPST_A64]); + set_flush_inputs_to_zero(fitz_enabled, &env->vfp.fp_status[FPST_ZA]); } if (changed & FPCR_DN) { bool dnan_enabled = val & FPCR_DN; @@ -246,9 +252,13 @@ static void vfp_set_fpcr_to_host(CPUARMState *env, uint32_t val, uint32_t mask) /* Change behaviours for A64 FP operations */ arm_set_ah_fp_behaviours(&env->vfp.fp_status[FPST_A64]); arm_set_ah_fp_behaviours(&env->vfp.fp_status[FPST_A64_F16]); + arm_set_ah_fp_behaviours(&env->vfp.fp_status[FPST_ZA]); + arm_set_ah_fp_behaviours(&env->vfp.fp_status[FPST_ZA_F16]); } else { arm_set_default_fp_behaviours(&env->vfp.fp_status[FPST_A64]); arm_set_default_fp_behaviours(&env->vfp.fp_status[FPST_A64_F16]); + arm_set_default_fp_behaviours(&env->vfp.fp_status[FPST_ZA]); + arm_set_default_fp_behaviours(&env->vfp.fp_status[FPST_ZA_F16]); } } /*