From nobody Fri Dec 19 04:30:05 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1598978624; cv=none; d=zohomail.com; s=zohoarc; b=Z9umi624STWE951jFHuscC/86fdJmDWjv+NJnDOqFq5LnOqV4QHvAzABXu+7UaPN2MG0yTe6yar9wR8GydLUxT79Ja+qZEAj12EKTMjqUaSbcHooIWwUBcmw6puJb+Vb63041Rww/p/X7USbKJXWnE9WQgAJ7PxrWScvqBTpUjo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598978624; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=vDUYcD7pvi3Ifu5u3OJmIJiYp59u5Ae51Z8NHkuIuqw=; b=MIYLb3hx3iT3UlHbiQn/2JZVi/MKn1G7ihPH0vpm1dgknwNWAfAxDoskNbyp/309LSKqGWk29C6M9VrMD7dnXBQPfKSYsYHsWfG0FJjz/qpp/sH6/me5JPkqkyMbzJRDnqAIOpnbT4cqVha/cS+C9APphCmQA+u0REz2busuvT4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1598978624518676.4670534504985; Tue, 1 Sep 2020 09:43:44 -0700 (PDT) Received: from localhost ([::1]:54560 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kD8HW-0002a8-Oz for importer@patchew.org; Tue, 01 Sep 2020 11:33:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47980) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kD83n-0008Pt-2e for qemu-devel@nongnu.org; Tue, 01 Sep 2020 11:18:59 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]:56295) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kD83k-0006EV-Oy for qemu-devel@nongnu.org; Tue, 01 Sep 2020 11:18:58 -0400 Received: by mail-wm1-x336.google.com with SMTP id a65so1537795wme.5 for ; Tue, 01 Sep 2020 08:18:56 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id z9sm2242317wma.4.2020.09.01.08.18.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2020 08:18:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=vDUYcD7pvi3Ifu5u3OJmIJiYp59u5Ae51Z8NHkuIuqw=; b=qiWHxe+MEVtc5Z39KDJHXfliCiA5vsdKzSxt8e/CNYtplS9atmU2eMXJmU4RSOfUHi hitxpj2mh1BwdjlS3gVWvnygFplGnsa12iujbUHuUhvQTxLyurJknUrsqjM3hyARtPiP N6RjUK3s0zCii6d/fFODvxNvqplwAcy9iIhVZEcS2wpjunpdsTBoqUSQirvCQ8Aw6eZb 3YNUveEvfPs+yhvm0w6Z4aJA8H+NHi/rZA2VnVaiSZBQzQz1s09j1ErB8SwxC8u7q+3D qbc6vPuaWDLeow4PptPn6v06zRzNwtIPc71ZbMEcrrsMusiBOzTl/jkrQ9AOiR4up2JM 9XmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vDUYcD7pvi3Ifu5u3OJmIJiYp59u5Ae51Z8NHkuIuqw=; b=EiGoDpKJeVyFgyfjzcwMZC0KJWEaTGzjuo8phDof4qO46j8MMqPcDvr903v/JOJMiH YWIKSJs4kK2VaZ6slbQvUxzjaORKp1GvqOLTW0Mn1dmlU+hzMxJuVK8MHCz57y5u4Hhq BQNzr77AyCHW4WKHwXtuuHJPkB+w+sxunoFW8MyUBzKSrfR+5Qpp8dPGMW6qwJG/VHbm jbyI9sBN//gbIxtCkmlbEJ1ucBZpP8ob+oKSTNZ+7RkbogSZXJ36HxPTlX4T1lu6rthh eaOmN6UV4iKIKqSMa8zgasayd7Nihk/sYGiOS5G1or5tn244FPiVSlN6r/N2BxFH/Cxe H0rg== X-Gm-Message-State: AOAM533O3i78BDC8yZE4d1EQhHOAkpsuz+Re6x2k/aKZPPoV2TuyDKSh bG1+UpXKAJw/SOGHFtgzOk6aV0AJafJIbUH3 X-Google-Smtp-Source: ABdhPJyligUbsEHZtDJ9ceYW+J24uJK3bwAsseGbUpldbaCW//bb2DL1VjjtgG6DVI72IVFf4CkOhA== X-Received: by 2002:a7b:c195:: with SMTP id y21mr2289138wmi.20.1598973529525; Tue, 01 Sep 2020 08:18:49 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 18/47] target/arm: Implement VFP fp16 VRINT* Date: Tue, 1 Sep 2020 16:17:54 +0100 Message-Id: <20200901151823.29785-19-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200901151823.29785-1-peter.maydell@linaro.org> References: <20200901151823.29785-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x336.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" Implement the fp16 version of the VFP VRINT* insns. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20200828183354.27913-19-peter.maydell@linaro.org --- target/arm/helper.h | 2 + target/arm/vfp-uncond.decode | 6 ++- target/arm/vfp.decode | 3 ++ target/arm/vfp_helper.c | 21 ++++++++ target/arm/translate-vfp.c.inc | 98 +++++++++++++++++++++++++++++++--- 5 files changed, 122 insertions(+), 8 deletions(-) diff --git a/target/arm/helper.h b/target/arm/helper.h index 03193728476..f5ad5088bf1 100644 --- a/target/arm/helper.h +++ b/target/arm/helper.h @@ -242,8 +242,10 @@ DEF_HELPER_3(shr_cc, i32, env, i32, i32) DEF_HELPER_3(sar_cc, i32, env, i32, i32) DEF_HELPER_3(ror_cc, i32, env, i32, i32) =20 +DEF_HELPER_FLAGS_2(rinth_exact, TCG_CALL_NO_RWG, f16, f16, ptr) DEF_HELPER_FLAGS_2(rints_exact, TCG_CALL_NO_RWG, f32, f32, ptr) DEF_HELPER_FLAGS_2(rintd_exact, TCG_CALL_NO_RWG, f64, f64, ptr) +DEF_HELPER_FLAGS_2(rinth, TCG_CALL_NO_RWG, f16, f16, ptr) DEF_HELPER_FLAGS_2(rints, TCG_CALL_NO_RWG, f32, f32, ptr) DEF_HELPER_FLAGS_2(rintd, TCG_CALL_NO_RWG, f64, f64, ptr) =20 diff --git a/target/arm/vfp-uncond.decode b/target/arm/vfp-uncond.decode index 8ba7b1703e0..9615544623a 100644 --- a/target/arm/vfp-uncond.decode +++ b/target/arm/vfp-uncond.decode @@ -60,10 +60,12 @@ VMINNM_sp 1111 1110 1.00 .... .... 1010 .1.0 .... = @vfp_dnm_s VMAXNM_dp 1111 1110 1.00 .... .... 1011 .0.0 .... @vfp_dnm_d VMINNM_dp 1111 1110 1.00 .... .... 1011 .1.0 .... @vfp_dnm_d =20 +VRINT 1111 1110 1.11 10 rm:2 .... 1001 01.0 .... \ + vm=3D%vm_sp vd=3D%vd_sp sz=3D1 VRINT 1111 1110 1.11 10 rm:2 .... 1010 01.0 .... \ - vm=3D%vm_sp vd=3D%vd_sp dp=3D0 + vm=3D%vm_sp vd=3D%vd_sp sz=3D2 VRINT 1111 1110 1.11 10 rm:2 .... 1011 01.0 .... \ - vm=3D%vm_dp vd=3D%vd_dp dp=3D1 + vm=3D%vm_dp vd=3D%vd_dp sz=3D3 =20 # VCVT float to int with specified rounding mode; Vd is always single-prec= ision VCVT 1111 1110 1.11 11 rm:2 .... 1001 op:1 1.0 .... \ diff --git a/target/arm/vfp.decode b/target/arm/vfp.decode index a8f1137be1e..9a79e99f1b0 100644 --- a/target/arm/vfp.decode +++ b/target/arm/vfp.decode @@ -195,12 +195,15 @@ VCVT_f16_f32 ---- 1110 1.11 0011 .... 1010 t:1 1.0 ..= .. \ VCVT_f16_f64 ---- 1110 1.11 0011 .... 1011 t:1 1.0 .... \ vd=3D%vd_sp vm=3D%vm_dp =20 +VRINTR_hp ---- 1110 1.11 0110 .... 1001 01.0 .... @vfp_dm_ss VRINTR_sp ---- 1110 1.11 0110 .... 1010 01.0 .... @vfp_dm_ss VRINTR_dp ---- 1110 1.11 0110 .... 1011 01.0 .... @vfp_dm_dd =20 +VRINTZ_hp ---- 1110 1.11 0110 .... 1001 11.0 .... @vfp_dm_ss VRINTZ_sp ---- 1110 1.11 0110 .... 1010 11.0 .... @vfp_dm_ss VRINTZ_dp ---- 1110 1.11 0110 .... 1011 11.0 .... @vfp_dm_dd =20 +VRINTX_hp ---- 1110 1.11 0111 .... 1001 01.0 .... @vfp_dm_ss VRINTX_sp ---- 1110 1.11 0111 .... 1010 01.0 .... @vfp_dm_ss VRINTX_dp ---- 1110 1.11 0111 .... 1011 01.0 .... @vfp_dm_dd =20 diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c index ab3f0b170a7..586dfd22e5e 100644 --- a/target/arm/vfp_helper.c +++ b/target/arm/vfp_helper.c @@ -1019,6 +1019,11 @@ float64 VFP_HELPER(muladd, d)(float64 a, float64 b, = float64 c, void *fpstp) } =20 /* ARMv8 round to integral */ +dh_ctype_f16 HELPER(rinth_exact)(dh_ctype_f16 x, void *fp_status) +{ + return float16_round_to_int(x, fp_status); +} + float32 HELPER(rints_exact)(float32 x, void *fp_status) { return float32_round_to_int(x, fp_status); @@ -1029,6 +1034,22 @@ float64 HELPER(rintd_exact)(float64 x, void *fp_stat= us) return float64_round_to_int(x, fp_status); } =20 +dh_ctype_f16 HELPER(rinth)(dh_ctype_f16 x, void *fp_status) +{ + int old_flags =3D get_float_exception_flags(fp_status), new_flags; + float16 ret; + + ret =3D float16_round_to_int(x, fp_status); + + /* Suppress any inexact exceptions the conversion produced */ + if (!(old_flags & float_flag_inexact)) { + new_flags =3D get_float_exception_flags(fp_status); + set_float_exception_flags(new_flags & ~float_flag_inexact, fp_stat= us); + } + + return ret; +} + float32 HELPER(rints)(float32 x, void *fp_status) { int old_flags =3D get_float_exception_flags(fp_status), new_flags; diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc index 869b67b2b93..7ce044fa896 100644 --- a/target/arm/translate-vfp.c.inc +++ b/target/arm/translate-vfp.c.inc @@ -341,7 +341,7 @@ static const uint8_t fp_decode_rm[] =3D { static bool trans_VRINT(DisasContext *s, arg_VRINT *a) { uint32_t rd, rm; - bool dp =3D a->dp; + int sz =3D a->sz; TCGv_ptr fpst; TCGv_i32 tcg_rmode; int rounding =3D fp_decode_rm[a->rm]; @@ -350,12 +350,16 @@ static bool trans_VRINT(DisasContext *s, arg_VRINT *a) return false; } =20 - if (dp && !dc_isar_feature(aa32_fpdp_v2, s)) { + if (sz =3D=3D 3 && !dc_isar_feature(aa32_fpdp_v2, s)) { + return false; + } + + if (sz =3D=3D 1 && !dc_isar_feature(aa32_fp16_arith, s)) { return false; } =20 /* UNDEF accesses to D16-D31 if they don't exist */ - if (dp && !dc_isar_feature(aa32_simd_r32, s) && + if (sz =3D=3D 3 && !dc_isar_feature(aa32_simd_r32, s) && ((a->vm | a->vd) & 0x10)) { return false; } @@ -367,12 +371,16 @@ static bool trans_VRINT(DisasContext *s, arg_VRINT *a) return true; } =20 - fpst =3D fpstatus_ptr(FPST_FPCR); + if (sz =3D=3D 1) { + fpst =3D fpstatus_ptr(FPST_FPCR_F16); + } else { + fpst =3D fpstatus_ptr(FPST_FPCR); + } =20 tcg_rmode =3D tcg_const_i32(arm_rmode_to_sf(rounding)); gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); =20 - if (dp) { + if (sz =3D=3D 3) { TCGv_i64 tcg_op; TCGv_i64 tcg_res; tcg_op =3D tcg_temp_new_i64(); @@ -388,7 +396,11 @@ static bool trans_VRINT(DisasContext *s, arg_VRINT *a) tcg_op =3D tcg_temp_new_i32(); tcg_res =3D tcg_temp_new_i32(); neon_load_reg32(tcg_op, rm); - gen_helper_rints(tcg_res, tcg_op, fpst); + if (sz =3D=3D 1) { + gen_helper_rinth(tcg_res, tcg_op, fpst); + } else { + gen_helper_rints(tcg_res, tcg_op, fpst); + } neon_store_reg32(tcg_res, rd); tcg_temp_free_i32(tcg_op); tcg_temp_free_i32(tcg_res); @@ -2638,6 +2650,29 @@ static bool trans_VCVT_f16_f64(DisasContext *s, arg_= VCVT_f16_f64 *a) return true; } =20 +static bool trans_VRINTR_hp(DisasContext *s, arg_VRINTR_sp *a) +{ + TCGv_ptr fpst; + TCGv_i32 tmp; + + if (!dc_isar_feature(aa32_fp16_arith, s)) { + return false; + } + + if (!vfp_access_check(s)) { + return true; + } + + tmp =3D tcg_temp_new_i32(); + neon_load_reg32(tmp, a->vm); + fpst =3D fpstatus_ptr(FPST_FPCR_F16); + gen_helper_rinth(tmp, tmp, fpst); + neon_store_reg32(tmp, a->vd); + tcg_temp_free_ptr(fpst); + tcg_temp_free_i32(tmp); + return true; +} + static bool trans_VRINTR_sp(DisasContext *s, arg_VRINTR_sp *a) { TCGv_ptr fpst; @@ -2693,6 +2728,34 @@ static bool trans_VRINTR_dp(DisasContext *s, arg_VRI= NTR_dp *a) return true; } =20 +static bool trans_VRINTZ_hp(DisasContext *s, arg_VRINTZ_sp *a) +{ + TCGv_ptr fpst; + TCGv_i32 tmp; + TCGv_i32 tcg_rmode; + + if (!dc_isar_feature(aa32_fp16_arith, s)) { + return false; + } + + if (!vfp_access_check(s)) { + return true; + } + + tmp =3D tcg_temp_new_i32(); + neon_load_reg32(tmp, a->vm); + fpst =3D fpstatus_ptr(FPST_FPCR_F16); + tcg_rmode =3D tcg_const_i32(float_round_to_zero); + gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); + gen_helper_rinth(tmp, tmp, fpst); + gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); + neon_store_reg32(tmp, a->vd); + tcg_temp_free_ptr(fpst); + tcg_temp_free_i32(tcg_rmode); + tcg_temp_free_i32(tmp); + return true; +} + static bool trans_VRINTZ_sp(DisasContext *s, arg_VRINTZ_sp *a) { TCGv_ptr fpst; @@ -2758,6 +2821,29 @@ static bool trans_VRINTZ_dp(DisasContext *s, arg_VRI= NTZ_dp *a) return true; } =20 +static bool trans_VRINTX_hp(DisasContext *s, arg_VRINTX_sp *a) +{ + TCGv_ptr fpst; + TCGv_i32 tmp; + + if (!dc_isar_feature(aa32_fp16_arith, s)) { + return false; + } + + if (!vfp_access_check(s)) { + return true; + } + + tmp =3D tcg_temp_new_i32(); + neon_load_reg32(tmp, a->vm); + fpst =3D fpstatus_ptr(FPST_FPCR_F16); + gen_helper_rinth_exact(tmp, tmp, fpst); + neon_store_reg32(tmp, a->vd); + tcg_temp_free_ptr(fpst); + tcg_temp_free_i32(tmp); + return true; +} + static bool trans_VRINTX_sp(DisasContext *s, arg_VRINTX_sp *a) { TCGv_ptr fpst; --=20 2.20.1