From nobody Wed Apr 16 05:28:14 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1560432316; cv=none; d=zoho.com; s=zohoarc; b=MK09SmUmc76CnjWmBsmkjx9fhOLwwMb2MEotpkEbo04GCkHjV+ynRyvv/+LqsQSFfZ4SicpkdCFE/bTWqDcvb9eG6c0ew1U4Kqe4L/ugiv6BfSi6T9WTfF2o0hbZTKjGu1ifTwLjeEve2JIKjH2bF9WEz/dnEgxQfQkp9msZet8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560432316; 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:ARC-Authentication-Results; bh=ntm/Cb4AncOPeCVYJ1Vrv7fiT2IGGzLZpdC//b8Kuds=; b=R3udVGo5Vz4ZkPwOJDlUDQiHQmRucXnfXaj+7eVY/FRtaTcdRSU4eYa1yGQ7WsHFPP4uyg6/6Ptwwmg9Q5kDIEV7g2ViURLvvVUqK/cSEsUlhOrTUlwAEvmTmeBoR4qw9EunmfphH5GRMD6rSDqfZ4juZy8yKcMmeGoadJOACkQ= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail 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 1560432316372605.2653112548221; Thu, 13 Jun 2019 06:25:16 -0700 (PDT) Received: from localhost ([::1]:39676 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbPj9-0008CZ-9d for importer@patchew.org; Thu, 13 Jun 2019 09:25:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59439) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOdd-0008PO-7U for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbOdV-0004do-MI for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:29 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]:52171) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbOdV-0004Vg-5W for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:21 -0400 Received: by mail-wm1-x330.google.com with SMTP id 207so2082552wma.1 for ; Thu, 13 Jun 2019 05:15:19 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id y6sm2010576wrp.12.2019.06.13.05.15.17 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 05:15:17 -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=ntm/Cb4AncOPeCVYJ1Vrv7fiT2IGGzLZpdC//b8Kuds=; b=Ks1KLPCXk7vsjkTIQMuWoqHydm9jSDKxd1t3W3GQi1D2sHuGpgNnbjYv1dbJPMn0kc TanY1+2sDQVNOpE340765asdmZ4wi7d1PkqsYumShgbHAJOaWBzbiKFBtmnjAzobjN0c VyXPSo8dsFr8W6pL7qrsRD0SqZII5/EyGyzVA8XjCI1/nU8se1nG167eFDEemJvMR/ES BezGL+gj0jhOmMCIn8Lx6GUWyCJW6XuqT/Kc6nB+PGEPzEOrfD9m8K7SI4SUceRtDqo8 9Il1Ui0YNcpZoV+nvpl0QwzirOxz/SumKNeR0h0gNK8y/e4PfdETQIywWKqsv96A7W+4 Dl8A== 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=ntm/Cb4AncOPeCVYJ1Vrv7fiT2IGGzLZpdC//b8Kuds=; b=bKzpQQCcYZOyNukkWlnBV1QPTUDEuAYGgq5rLOoO8Eogx87bM1byFZ6RhCs3pi895n yMp9l31vKUk9sNOAou5weEFMT0iWBPzLvv6etJzZmO2LhLfXaqKwtkuXnWXHtt1Kkutl YEiNhZnO5Mi2S/7lSb/ENzbl5Vv4UYwy9afBppl69oa41ef5J3ZvyeAPQ9zvc/F7xffl cD58K5+PLaSOjFFIXVTGTtNBoGo7WsCi3rExZoLwi68WcXsfIsa3ks7YRAnJGFosML0B SI0rzg0z8MglYyaBif7OPmOP0gMOYkR9W8V57IeyAyJCUniMo/Pr4z8lhc4yxI4dkfQu T/Yg== X-Gm-Message-State: APjAAAWn27fWeWpFLmpgcuD/wUaD6DuX4hS4VAEybVuhOUveEm7zQVs8 fopW7RTyrsqNHtnN2ZO0shyYKGVCTyuOqg== X-Google-Smtp-Source: APXvYqxa0i5e5cK5zLRioP3BVJe8TJWxcoRr4ABhgcZLtUQMu+WHyXMxamuF+RFbgExRk3IzKW2VBg== X-Received: by 2002:a1c:b707:: with SMTP id h7mr3520312wmf.45.1560428118311; Thu, 13 Jun 2019 05:15:18 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 13 Jun 2019 13:14:25 +0100 Message-Id: <20190613121433.5246-41-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613121433.5246-1-peter.maydell@linaro.org> References: <20190613121433.5246-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::330 Subject: [Qemu-devel] [PULL 40/48] target/arm: Convert the VCVT-from-f16 insns to decodetree 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: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Convert the VCVTT, VCVTB instructions that deal with conversion from half-precision floats to f32 or 64 to decodetree. Since we're no longer constrained to the old decoder's style using cpu_F0s and cpu_F0d we can perform a direct 16 bit load of the right half of the input single-precision register rather than loading the full 32 bits and then doing a separate shift or sign-extension. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/translate-vfp.inc.c | 82 ++++++++++++++++++++++++++++++++++ target/arm/translate.c | 56 +---------------------- target/arm/vfp.decode | 6 +++ 3 files changed, 89 insertions(+), 55 deletions(-) diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c index ebde86210a6..732bf6020a9 100644 --- a/target/arm/translate-vfp.inc.c +++ b/target/arm/translate-vfp.inc.c @@ -30,6 +30,26 @@ #include "decode-vfp.inc.c" #include "decode-vfp-uncond.inc.c" =20 +/* + * Return the offset of a 16-bit half of the specified VFP single-precision + * register. If top is true, returns the top 16 bits; otherwise the bottom + * 16 bits. + */ +static inline long vfp_f16_offset(unsigned reg, bool top) +{ + long offs =3D vfp_reg_offset(false, reg); +#ifdef HOST_WORDS_BIGENDIAN + if (!top) { + offs +=3D 2; + } +#else + if (top) { + offs +=3D 2; + } +#endif + return offs; +} + /* * Check that VFP access is enabled. If it is, do the necessary * M-profile lazy-FP handling and then return true. @@ -2013,3 +2033,65 @@ static bool trans_VCMP_dp(DisasContext *s, arg_VCMP_= dp *a) =20 return true; } + +static bool trans_VCVT_f32_f16(DisasContext *s, arg_VCVT_f32_f16 *a) +{ + TCGv_ptr fpst; + TCGv_i32 ahp_mode; + TCGv_i32 tmp; + + if (!dc_isar_feature(aa32_fp16_spconv, s)) { + return false; + } + + if (!vfp_access_check(s)) { + return true; + } + + fpst =3D get_fpstatus_ptr(false); + ahp_mode =3D get_ahp_flag(); + tmp =3D tcg_temp_new_i32(); + /* The T bit tells us if we want the low or high 16 bits of Vm */ + tcg_gen_ld16u_i32(tmp, cpu_env, vfp_f16_offset(a->vm, a->t)); + gen_helper_vfp_fcvt_f16_to_f32(tmp, tmp, fpst, ahp_mode); + neon_store_reg32(tmp, a->vd); + tcg_temp_free_i32(ahp_mode); + tcg_temp_free_ptr(fpst); + tcg_temp_free_i32(tmp); + return true; +} + +static bool trans_VCVT_f64_f16(DisasContext *s, arg_VCVT_f64_f16 *a) +{ + TCGv_ptr fpst; + TCGv_i32 ahp_mode; + TCGv_i32 tmp; + TCGv_i64 vd; + + if (!dc_isar_feature(aa32_fp16_dpconv, s)) { + return false; + } + + /* UNDEF accesses to D16-D31 if they don't exist. */ + if (!dc_isar_feature(aa32_fp_d32, s) && (a->vd & 0x10)) { + return false; + } + + if (!vfp_access_check(s)) { + return true; + } + + fpst =3D get_fpstatus_ptr(false); + ahp_mode =3D get_ahp_flag(); + tmp =3D tcg_temp_new_i32(); + /* The T bit tells us if we want the low or high 16 bits of Vm */ + tcg_gen_ld16u_i32(tmp, cpu_env, vfp_f16_offset(a->vm, a->t)); + vd =3D tcg_temp_new_i64(); + gen_helper_vfp_fcvt_f16_to_f64(vd, tmp, fpst, ahp_mode); + neon_store_reg64(vd, a->vd); + tcg_temp_free_i32(ahp_mode); + tcg_temp_free_ptr(fpst); + tcg_temp_free_i32(tmp); + tcg_temp_free_i64(vd); + return true; +} diff --git a/target/arm/translate.c b/target/arm/translate.c index af1d01c49b7..a2cb2cdba58 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -3066,7 +3066,7 @@ static int disas_vfp_insn(DisasContext *s, uint32_t i= nsn) return 1; case 15: switch (rn) { - case 0 ... 3: + case 0 ... 5: case 8 ... 11: /* Already handled by decodetree */ return 1; @@ -3080,24 +3080,6 @@ static int disas_vfp_insn(DisasContext *s, uint32_t = insn) if (op =3D=3D 15) { /* rn is opcode, encoded as per VFP_SREG_N. */ switch (rn) { - case 0x04: /* vcvtb.f64.f16, vcvtb.f32.f16 */ - case 0x05: /* vcvtt.f64.f16, vcvtt.f32.f16 */ - /* - * VCVTB, VCVTT: only present with the halfprec extens= ion - * UNPREDICTABLE if bit 8 is set prior to ARMv8 - * (we choose to UNDEF) - */ - if (dp) { - if (!dc_isar_feature(aa32_fp16_dpconv, s)) { - return 1; - } - } else { - if (!dc_isar_feature(aa32_fp16_spconv, s)) { - return 1; - } - } - rm_is_dp =3D false; - break; case 0x06: /* vcvtb.f16.f32, vcvtb.f16.f64 */ case 0x07: /* vcvtt.f16.f32, vcvtt.f16.f64 */ if (dp) { @@ -3239,42 +3221,6 @@ static int disas_vfp_insn(DisasContext *s, uint32_t = insn) switch (op) { case 15: /* extension space */ switch (rn) { - case 4: /* vcvtb.f32.f16, vcvtb.f64.f16 */ - { - TCGv_ptr fpst =3D get_fpstatus_ptr(false); - TCGv_i32 ahp_mode =3D get_ahp_flag(); - tmp =3D gen_vfp_mrs(); - tcg_gen_ext16u_i32(tmp, tmp); - if (dp) { - gen_helper_vfp_fcvt_f16_to_f64(cpu_F0d, tmp, - fpst, ahp_mode); - } else { - gen_helper_vfp_fcvt_f16_to_f32(cpu_F0s, tmp, - fpst, ahp_mode); - } - tcg_temp_free_i32(ahp_mode); - tcg_temp_free_ptr(fpst); - tcg_temp_free_i32(tmp); - break; - } - case 5: /* vcvtt.f32.f16, vcvtt.f64.f16 */ - { - TCGv_ptr fpst =3D get_fpstatus_ptr(false); - TCGv_i32 ahp =3D get_ahp_flag(); - tmp =3D gen_vfp_mrs(); - tcg_gen_shri_i32(tmp, tmp, 16); - if (dp) { - gen_helper_vfp_fcvt_f16_to_f64(cpu_F0d, tmp, - fpst, ahp); - } else { - gen_helper_vfp_fcvt_f16_to_f32(cpu_F0s, tmp, - fpst, ahp); - } - tcg_temp_free_i32(tmp); - tcg_temp_free_i32(ahp); - tcg_temp_free_ptr(fpst); - break; - } case 6: /* vcvtb.f16.f32, vcvtb.f16.f64 */ { TCGv_ptr fpst =3D get_fpstatus_ptr(false); diff --git a/target/arm/vfp.decode b/target/arm/vfp.decode index 9db7aa7021a..53d9544f7cd 100644 --- a/target/arm/vfp.decode +++ b/target/arm/vfp.decode @@ -181,3 +181,9 @@ VCMP_sp ---- 1110 1.11 010 z:1 .... 1010 e:1 1.0 .= ... \ vd=3D%vd_sp vm=3D%vm_sp VCMP_dp ---- 1110 1.11 010 z:1 .... 1011 e:1 1.0 .... \ vd=3D%vd_dp vm=3D%vm_dp + +# VCVTT and VCVTB from f16: Vd format depends on size bit; Vm is always vm= _sp +VCVT_f32_f16 ---- 1110 1.11 0010 .... 1010 t:1 1.0 .... \ + vd=3D%vd_sp vm=3D%vm_sp +VCVT_f64_f16 ---- 1110 1.11 0010 .... 1011 t:1 1.0 .... \ + vd=3D%vd_dp vm=3D%vm_sp --=20 2.20.1