From patchwork Tue Jun 11 10:53:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 166415 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2239911ilk; Tue, 11 Jun 2019 04:36:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqwT3/ZCDIFOa6l4tqyvGvOanpt9RMichTfj9ZbShQNGns3RervMzROi9UVg2Q0fgRGPd1fT X-Received: by 2002:a37:aa4d:: with SMTP id t74mr61016516qke.144.1560253005715; Tue, 11 Jun 2019 04:36:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560253005; cv=none; d=google.com; s=arc-20160816; b=g6geW8CgAyCK+5ggYy8/m0BeXG0GOGPgFQmJzCSA6VKb5OAG6GdUb8TavCB0XloLKV UoxV2G5vGkrF5gkm3aN9p9TNHlPrV74Od8AxX7cMMVqbgSpgn8p5DbfvgxZvbou8e3uQ Q716hmoS1iZGOBFp5BCeii7qMafGK6OGCAwoQd9FRoEsRpIwvnJ7tfXEFSyNx7jhITb4 cRhMxpab3dGF09uAXJ7PGe/S6d6Vm9EZvzWG04T8mdVdXeoxRMsBBgYg3L3OKqCKrYGs s21aUgZgr+yezRDblISwXzTWMouUCHqH5TVxbMry7D93JM6o7uVIOo3D8MG77pKJO0Pq tL+A== 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=r4ng9HLYZ5DFgnMk3vtI7Z+VfumqzZw467SH0uR5eNg=; b=bUajWD8h4E0IIjJwrGflJJjb+0CTYyI+MpDqwPbc1bDI1HdZCeJ4mnUu4URokXuFG3 jY1yeEOp/UABLYsBunIO8qOi1FnMzO2NeTcl1+KBTHAYaEjZLOWM8FKZhoFtahRquhLY tdqF8clHt4nq5A7pO0brDaYJEDVcdcRAffD1Jfe/rdjCXcjBrFq2GrpzM6LIgFVhRH6O C4piYydVWhsHvsE3xy/TW/kUHHHFwC4dP1SceA2O5e4XoHmRYhQGm7RcPqIrYLQHjs1M Vz0bdlSislcClxrtSa/0AXtsgI/S2zJmWt+tMly/C18+um2svQDfpk+BxAWUCWo1yxpr TmQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=h6XYekbM; 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 s29si6524383qth.286.2019.06.11.04.36.45 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 11 Jun 2019 04:36: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=fail header.i=@linaro.org header.s=google header.b=h6XYekbM; 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]:56515 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1haf53-0002KX-AB for patch@linaro.org; Tue, 11 Jun 2019 07:36:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39590) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1haeQO-0007ZG-42 for qemu-devel@nongnu.org; Tue, 11 Jun 2019 06:54:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1haeQK-0007pw-97 for qemu-devel@nongnu.org; Tue, 11 Jun 2019 06:54:43 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:37458) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1haeQJ-0007jC-T3 for qemu-devel@nongnu.org; Tue, 11 Jun 2019 06:54:40 -0400 Received: by mail-wm1-x341.google.com with SMTP id 22so2395738wmg.2 for ; Tue, 11 Jun 2019 03:54:32 -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=r4ng9HLYZ5DFgnMk3vtI7Z+VfumqzZw467SH0uR5eNg=; b=h6XYekbM0bGXC/Dzl+dbx0U7JoYRQpiITF8Luh8oSFld6S/DRR7Me3t93zZOSECc4q vHrn5tCcPPLjX1W5+R8NZjZWoGzSEOlSB59704qs77K5fSlfdfAb6nEH9rzFRzNaLwh+ +mKl/ssVhhueYHV52j1WvBRveAolFcSsmO6pbOpFJbINSx9vHEoD5OfpDVEZoppmmHkL 216keWdYZrCPmRhxqh4OHU2AYPtqCjciZnUkjSWaqGXs7iVGioKnCDngzjPyQ8n4VQd5 bi2P9h7NJaK8VJRIrxbY9A6U9n21X1dFiwRE2GfcBCwAvR9lkwGiIaBuz6zSgchJVnDt /Pnw== 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=r4ng9HLYZ5DFgnMk3vtI7Z+VfumqzZw467SH0uR5eNg=; b=nxx6vKp02vbXpMZw+CtO6/NFf+zYQfjfkIGq+V1imzhPjQWWf+ylapCgQ9NsdOcLO3 ytC85OaQJSZvg6tth/kkI8gieiqLQLmUZtKxK6xs9+2+9JpmhHO53WoMxP0I4Zeoc9QA 4arOoTt8YWCe/NXZigBCXGaoxixVZmitT7wTbPbRjhre5Q/YJT5e2VKfO9PCwzon3LwV kdNYprW4UPSNqno1cGWbIn4iT4NDqtUo5B6A9km+i+EdIh17NUe4BZOl02spdDscYoAx TOdfmShlPk1dORX4iegYuaZUx/Vm9Hh0fLE3/BI0uKIaywlgbaaRcpu39hOIKpDfFHjP wYfA== X-Gm-Message-State: APjAAAWB1o1yDAddQyT3LtqmuZD3nv7P90CNeoL4P1VCZcIL+lpZdLMN NS4Imkzgxly5nsDGT+Rp49sPxA== X-Received: by 2002:a1c:238d:: with SMTP id j135mr17646467wmj.53.1560250471393; Tue, 11 Jun 2019 03:54:31 -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.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Jun 2019 03:54:30 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Date: Tue, 11 Jun 2019 11:53:44 +0100 Message-Id: <20190611105351.9871-36-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 35/42] target/arm: Convert the VCVT-to-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 and VCVTB instructions which convert from f32 and f64 to f16 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 store of the right half of the input single-precision register rather than doing a load/modify/store sequence on the full 32 bits. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/translate-vfp.inc.c | 62 ++++++++++++++++++++++++++ target/arm/translate.c | 79 +--------------------------------- target/arm/vfp.decode | 6 +++ 3 files changed, 69 insertions(+), 78 deletions(-) -- 2.20.1 diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c index 732bf6020a9..a19ede86719 100644 --- a/target/arm/translate-vfp.inc.c +++ b/target/arm/translate-vfp.inc.c @@ -2095,3 +2095,65 @@ static bool trans_VCVT_f64_f16(DisasContext *s, arg_VCVT_f64_f16 *a) tcg_temp_free_i64(vd); return true; } + +static bool trans_VCVT_f16_f32(DisasContext *s, arg_VCVT_f16_f32 *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(); + + neon_load_reg32(tmp, a->vm); + gen_helper_vfp_fcvt_f32_to_f16(tmp, tmp, fpst, ahp_mode); + tcg_gen_st16_i32(tmp, cpu_env, vfp_f16_offset(a->vd, a->t)); + tcg_temp_free_i32(ahp_mode); + tcg_temp_free_ptr(fpst); + tcg_temp_free_i32(tmp); + return true; +} + +static bool trans_VCVT_f16_f64(DisasContext *s, arg_VCVT_f16_f64 *a) +{ + TCGv_ptr fpst; + TCGv_i32 ahp_mode; + TCGv_i32 tmp; + TCGv_i64 vm; + + 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->vm & 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(); + vm = tcg_temp_new_i64(); + + neon_load_reg64(vm, a->vm); + gen_helper_vfp_fcvt_f64_to_f16(tmp, vm, fpst, ahp_mode); + tcg_temp_free_i64(vm); + tcg_gen_st16_i32(tmp, cpu_env, vfp_f16_offset(a->vd, a->t)); + tcg_temp_free_i32(ahp_mode); + tcg_temp_free_ptr(fpst); + tcg_temp_free_i32(tmp); + return true; +} diff --git a/target/arm/translate.c b/target/arm/translate.c index 34a82cfa424..143b250a996 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -2963,20 +2963,6 @@ static int disas_dsp_insn(DisasContext *s, uint32_t insn) #define VFP_SREG_M(insn) VFP_SREG(insn, 0, 5) #define VFP_DREG_M(reg, insn) VFP_DREG(reg, insn, 0, 5) -/* Move between integer and VFP cores. */ -static TCGv_i32 gen_vfp_mrs(void) -{ - TCGv_i32 tmp = tcg_temp_new_i32(); - tcg_gen_mov_i32(tmp, cpu_F0s); - return tmp; -} - -static void gen_vfp_msr(TCGv_i32 tmp) -{ - tcg_gen_mov_i32(cpu_F0s, tmp); - tcg_temp_free_i32(tmp); -} - static void gen_neon_dup_low16(TCGv_i32 var) { TCGv_i32 tmp = tcg_temp_new_i32(); @@ -3003,8 +2989,6 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) { uint32_t rd, rn, rm, op, delta_d, delta_m, bank_mask; int dp, veclen; - TCGv_i32 tmp; - TCGv_i32 tmp2; if (!arm_dc_feature(s, ARM_FEATURE_VFP)) { return 1; @@ -3066,8 +3050,7 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) return 1; case 15: switch (rn) { - case 0 ... 5: - case 8 ... 11: + case 0 ... 11: /* Already handled by decodetree */ return 1; default: @@ -3080,20 +3063,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 0x06: /* vcvtb.f16.f32, vcvtb.f16.f64 */ - case 0x07: /* vcvtt.f16.f32, vcvtt.f16.f64 */ - if (dp) { - if (!dc_isar_feature(aa32_fp16_dpconv, s)) { - return 1; - } - } else { - if (!dc_isar_feature(aa32_fp16_spconv, s)) { - return 1; - } - } - rd_is_dp = false; - break; - case 0x0c: /* vrintr */ case 0x0d: /* vrintz */ case 0x0e: /* vrintx */ @@ -3221,52 +3190,6 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) switch (op) { case 15: /* extension space */ switch (rn) { - case 6: /* vcvtb.f16.f32, vcvtb.f16.f64 */ - { - TCGv_ptr fpst = get_fpstatus_ptr(false); - TCGv_i32 ahp = get_ahp_flag(); - tmp = tcg_temp_new_i32(); - - if (dp) { - gen_helper_vfp_fcvt_f64_to_f16(tmp, cpu_F0d, - fpst, ahp); - } else { - gen_helper_vfp_fcvt_f32_to_f16(tmp, cpu_F0s, - fpst, ahp); - } - tcg_temp_free_i32(ahp); - tcg_temp_free_ptr(fpst); - gen_mov_F0_vreg(0, rd); - tmp2 = gen_vfp_mrs(); - tcg_gen_andi_i32(tmp2, tmp2, 0xffff0000); - tcg_gen_or_i32(tmp, tmp, tmp2); - tcg_temp_free_i32(tmp2); - gen_vfp_msr(tmp); - break; - } - case 7: /* vcvtt.f16.f32, vcvtt.f16.f64 */ - { - TCGv_ptr fpst = get_fpstatus_ptr(false); - TCGv_i32 ahp = get_ahp_flag(); - tmp = tcg_temp_new_i32(); - if (dp) { - gen_helper_vfp_fcvt_f64_to_f16(tmp, cpu_F0d, - fpst, ahp); - } else { - gen_helper_vfp_fcvt_f32_to_f16(tmp, cpu_F0s, - fpst, ahp); - } - tcg_temp_free_i32(ahp); - tcg_temp_free_ptr(fpst); - tcg_gen_shli_i32(tmp, tmp, 16); - gen_mov_F0_vreg(0, rd); - tmp2 = gen_vfp_mrs(); - tcg_gen_ext16u_i32(tmp2, tmp2); - tcg_gen_or_i32(tmp, tmp, tmp2); - tcg_temp_free_i32(tmp2); - gen_vfp_msr(tmp); - break; - } case 12: /* vrintr */ { TCGv_ptr fpst = get_fpstatus_ptr(0); diff --git a/target/arm/vfp.decode b/target/arm/vfp.decode index 53d9544f7cd..b88d1d06f02 100644 --- a/target/arm/vfp.decode +++ b/target/arm/vfp.decode @@ -187,3 +187,9 @@ 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 + +# VCVTB and VCVTT to f16: Vd format is always vd_sp; Vm format depends on size bit +VCVT_f16_f32 ---- 1110 1.11 0011 .... 1010 t:1 1.0 .... \ + vd=%vd_sp vm=%vm_sp +VCVT_f16_f64 ---- 1110 1.11 0011 .... 1011 t:1 1.0 .... \ + vd=%vd_sp vm=%vm_dp