From patchwork Tue Jun 11 10:53:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 166419 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2242746ilk; Tue, 11 Jun 2019 04:39:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqxmRtIuUc66nDw8/62w7UDlrYIsgPJpG5Nc/8oaBveMtfeAzZl7niRikBrVhpl6qD190Zc0 X-Received: by 2002:a0c:e705:: with SMTP id d5mr28367579qvn.11.1560253189684; Tue, 11 Jun 2019 04:39:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560253189; cv=none; d=google.com; s=arc-20160816; b=0gN49LFEAQhPQayt4bt6mZ6tsWK1f/TroU5zvvaNqrKcpSOOR1ZrDWslIrU5wR1w/N PbRbru1j7m+ng0jeU49sm5RniakIBwWcbp+I0WndDkvZtAORevMVtnoqAH+vbkmhmxMP irMymQ7oQ6rwy/iBn8bZyj3UXm+4jg9hskKUwHlXEHn8xCQXq72in1fuak+ReuPe75yy EsNP7jcJutJuoS5zEIgwPMyKup5/EGbtgnoKleh6HTvGoN/yXGvtY4de/wDF3zS3u9m8 1SuRFg46ZhWtSh1/CM2LJZ3NClZ3oAhK4/VHinunI6jOyf7BvvPyQyS9tqHeHMkrdboV fN1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=WpNh2pEc72OT/45x1zdU6rlyslDELvp+z0QBZzz6/wU=; b=S/2woAW+nKUgFh5QPGs5JR1epAlHFVLkA61Beaus+R5AQv8qPT5KgYPmZapM98Rht3 zATyzWmZXjzKwXOLJlsAVd3RFP9fRWONUYVXqh0qAr8GvoJgSH5a5YZ4pkIe+rDmPono MF915j4Lis1K2+iXzqtzgaEGrXRXVDcsII8im0D6/eKXTzhK//j56zIswcAkr/vbsbCg UEeIsZKKunauATPhxvHnmcWJnfg0VfWK2evAtlI429Ki46XA3G6DD87jDDAiGNdUiJzS PuK7QWlbPOW3uOuYkmvX54WvaMfO2gExLa4OFj1f4+R5IkSqBMLPXnGQi6/+oMnUektm waUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=atvBA759; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id e63si3787855qkd.116.2019.06.11.04.39.49 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 11 Jun 2019 04:39: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=fail header.i=@linaro.org header.s=google header.b=atvBA759; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:56544 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1haf81-0005oI-AP for patch@linaro.org; Tue, 11 Jun 2019 07:39:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39683) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1haeQR-0007f3-E3 for qemu-devel@nongnu.org; Tue, 11 Jun 2019 06:54:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1haeQL-0007r8-2G for qemu-devel@nongnu.org; Tue, 11 Jun 2019 06:54:47 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:35563) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1haeQK-0007iW-JN for qemu-devel@nongnu.org; Tue, 11 Jun 2019 06:54:40 -0400 Received: by mail-wm1-x341.google.com with SMTP id c6so2405420wml.0 for ; Tue, 11 Jun 2019 03:54:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WpNh2pEc72OT/45x1zdU6rlyslDELvp+z0QBZzz6/wU=; b=atvBA759yPlBgHW7gFIQzJgj3UdW/wjknKgJgQ9vrlryn9glaKmYyKuHbUSBFlOsry XK+gGaEBSKcx6DArSaQxD5sUg8y2dKT/zGHHlHU5VAtSiB9NcNlVrSlkenGcxbDV6KR7 UsOWT43UBuh5ncPrYHMSZ4esaEKYuCzpt2VVxt17daVsJJG54z5FOZdk8UirGiBtAU2H EcxCG49l4zw099yqH6Do9Nb8BbHazMuUrUvOwaxDKD4mefdGVM3O8DmRrUCQxtKWPZNW j9J8xpvMNVP9VGxz/djoBcCWG6yckFb7LNG0/tdV2i6YwnimgbvqO4/ixKzsZ8HIy+Fe ktcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WpNh2pEc72OT/45x1zdU6rlyslDELvp+z0QBZzz6/wU=; b=fLc5T/AZJNxeQ+QIeAn63DgyzQgaXqCWkZayCToGPk9mwARCga2i5ZW7h/Qw/YnmTO Hl+Le2pv6UalQOXaAmH2esD/ftqk9DqT6nmQjnGZ4dMG4ccRCJOOEgYVk16+Za4HrDMG jLZi9xX9vWzFiJ8R1Q8DQOqUBV0bYzyZynEKwmxlNRpEeJwHtPvF2UyzbBu/NcrttDmK dgshL6CxlfvBOyzoZCwaZsrOOVnMDNtwiV73DbCgCFsiK+Gh8Ib//QMkbCJtn0irtMxD 25qZbEAIVcK2cFzm+ue+hNbooxjEyRYwA7fBzy2VGS/+FyN4RF7pknimWU+xOJWpQUPL FX1A== X-Gm-Message-State: APjAAAVEyIy+f7Cv5cLRJEueodYfcL2SFKTL3dF2ZtgqgGzkIKrHwiQC wGCYzq8X/XkE4R53deTBxYr5mbevAzZCfA== X-Received: by 2002:a1c:e009:: with SMTP id x9mr17209137wmg.5.1560250470197; Tue, 11 Jun 2019 03:54:30 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id e17sm10785945wrt.95.2019.06.11.03.54.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Jun 2019 03:54:29 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Date: Tue, 11 Jun 2019 11:53:43 +0100 Message-Id: <20190611105351.9871-35-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190611105351.9871-1-peter.maydell@linaro.org> References: <20190611105351.9871-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::341 Subject: [Qemu-devel] [PATCH v2 34/42] 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: , Cc: Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(-) -- 2.20.1 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" +/* + * 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 = vfp_reg_offset(false, reg); +#ifdef HOST_WORDS_BIGENDIAN + if (!top) { + offs += 2; + } +#else + if (top) { + offs += 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) 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 = get_fpstatus_ptr(false); + ahp_mode = get_ahp_flag(); + tmp = 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 = get_fpstatus_ptr(false); + ahp_mode = get_ahp_flag(); + tmp = 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 = 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 761e8347fa0..34a82cfa424 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -3066,7 +3066,7 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) 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 == 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 extension - * 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 = 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 = get_fpstatus_ptr(false); - TCGv_i32 ahp_mode = get_ahp_flag(); - tmp = 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 = get_fpstatus_ptr(false); - TCGv_i32 ahp = get_ahp_flag(); - tmp = 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 = 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=%vd_sp vm=%vm_sp VCMP_dp ---- 1110 1.11 010 z:1 .... 1011 e:1 1.0 .... \ vd=%vd_dp vm=%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=%vd_sp vm=%vm_sp +VCVT_f64_f16 ---- 1110 1.11 0010 .... 1011 t:1 1.0 .... \ + vd=%vd_dp vm=%vm_sp