All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-arm@nongnu.org, qemu-devel@nongnu.org
Subject: [PATCH v2 12/45] target/arm: Implement VFP fp16 VCVT between float and integer
Date: Fri, 28 Aug 2020 19:33:21 +0100	[thread overview]
Message-ID: <20200828183354.27913-13-peter.maydell@linaro.org> (raw)
In-Reply-To: <20200828183354.27913-1-peter.maydell@linaro.org>

Implement the fp16 versions of the VFP VCVT instruction forms which
convert between floating point and integer.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
 target/arm/vfp.decode          |  4 +++
 target/arm/translate-vfp.c.inc | 65 ++++++++++++++++++++++++++++++++++
 2 files changed, 69 insertions(+)

diff --git a/target/arm/vfp.decode b/target/arm/vfp.decode
index 37f96e2d261..642ec039e3c 100644
--- a/target/arm/vfp.decode
+++ b/target/arm/vfp.decode
@@ -210,6 +210,8 @@ VCVT_sp      ---- 1110 1.11 0111 .... 1010 11.0 ....        @vfp_dm_ds
 VCVT_dp      ---- 1110 1.11 0111 .... 1011 11.0 ....        @vfp_dm_sd
 
 # VCVT from integer to floating point: Vm always single; Vd depends on size
+VCVT_int_hp  ---- 1110 1.11 1000 .... 1001 s:1 1.0 .... \
+             vd=%vd_sp vm=%vm_sp
 VCVT_int_sp  ---- 1110 1.11 1000 .... 1010 s:1 1.0 .... \
              vd=%vd_sp vm=%vm_sp
 VCVT_int_dp  ---- 1110 1.11 1000 .... 1011 s:1 1.0 .... \
@@ -229,6 +231,8 @@ VCVT_fix_dp  ---- 1110 1.11 1.1. .... 1011 .1.0 .... \
              vd=%vd_dp imm=%vm_sp opc=%vcvt_fix_op
 
 # VCVT float to integer (VCVT and VCVTR): Vd always single; Vd depends on size
+VCVT_hp_int  ---- 1110 1.11 110 s:1 .... 1001 rz:1 1.0 .... \
+             vd=%vd_sp vm=%vm_sp
 VCVT_sp_int  ---- 1110 1.11 110 s:1 .... 1010 rz:1 1.0 .... \
              vd=%vd_sp vm=%vm_sp
 VCVT_dp_int  ---- 1110 1.11 110 s:1 .... 1011 rz:1 1.0 .... \
diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc
index 59ef4d4fbc3..0140822d183 100644
--- a/target/arm/translate-vfp.c.inc
+++ b/target/arm/translate-vfp.c.inc
@@ -2845,6 +2845,35 @@ static bool trans_VCVT_dp(DisasContext *s, arg_VCVT_dp *a)
     return true;
 }
 
+static bool trans_VCVT_int_hp(DisasContext *s, arg_VCVT_int_sp *a)
+{
+    TCGv_i32 vm;
+    TCGv_ptr fpst;
+
+    if (!dc_isar_feature(aa32_fp16_arith, s)) {
+        return false;
+    }
+
+    if (!vfp_access_check(s)) {
+        return true;
+    }
+
+    vm = tcg_temp_new_i32();
+    neon_load_reg32(vm, a->vm);
+    fpst = fpstatus_ptr(FPST_FPCR_F16);
+    if (a->s) {
+        /* i32 -> f16 */
+        gen_helper_vfp_sitoh(vm, vm, fpst);
+    } else {
+        /* u32 -> f16 */
+        gen_helper_vfp_uitoh(vm, vm, fpst);
+    }
+    neon_store_reg32(vm, a->vd);
+    tcg_temp_free_i32(vm);
+    tcg_temp_free_ptr(fpst);
+    return true;
+}
+
 static bool trans_VCVT_int_sp(DisasContext *s, arg_VCVT_int_sp *a)
 {
     TCGv_i32 vm;
@@ -3067,6 +3096,42 @@ static bool trans_VCVT_fix_dp(DisasContext *s, arg_VCVT_fix_dp *a)
     return true;
 }
 
+static bool trans_VCVT_hp_int(DisasContext *s, arg_VCVT_sp_int *a)
+{
+    TCGv_i32 vm;
+    TCGv_ptr fpst;
+
+    if (!dc_isar_feature(aa32_fp16_arith, s)) {
+        return false;
+    }
+
+    if (!vfp_access_check(s)) {
+        return true;
+    }
+
+    fpst = fpstatus_ptr(FPST_FPCR_F16);
+    vm = tcg_temp_new_i32();
+    neon_load_reg32(vm, a->vm);
+
+    if (a->s) {
+        if (a->rz) {
+            gen_helper_vfp_tosizh(vm, vm, fpst);
+        } else {
+            gen_helper_vfp_tosih(vm, vm, fpst);
+        }
+    } else {
+        if (a->rz) {
+            gen_helper_vfp_touizh(vm, vm, fpst);
+        } else {
+            gen_helper_vfp_touih(vm, vm, fpst);
+        }
+    }
+    neon_store_reg32(vm, a->vd);
+    tcg_temp_free_i32(vm);
+    tcg_temp_free_ptr(fpst);
+    return true;
+}
+
 static bool trans_VCVT_sp_int(DisasContext *s, arg_VCVT_sp_int *a)
 {
     TCGv_i32 vm;
-- 
2.20.1



  parent reply	other threads:[~2020-08-28 18:41 UTC|newest]

Thread overview: 75+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-28 18:33 [PATCH v2 00/45] target/arm: Implement fp16 for AArch32 VFP and Neon Peter Maydell
2020-08-28 18:33 ` [PATCH v2 01/45] target/arm: Remove local definitions of float constants Peter Maydell
2020-08-28 18:33 ` [PATCH v2 02/45] target/arm: Use correct ID register check for aa32_fp16_arith Peter Maydell
2020-08-28 18:33 ` [PATCH v2 03/45] target/arm: Implement VFP fp16 for VFP_BINOP operations Peter Maydell
2020-08-28 18:33 ` [PATCH v2 04/45] target/arm: Implement VFP fp16 VMLA, VMLS, VNMLS, VNMLA, VNMUL Peter Maydell
2020-08-28 18:33 ` [PATCH v2 05/45] target/arm: Macroify trans functions for VFMA, VFMS, VFNMA, VFNMS Peter Maydell
2020-08-28 18:33 ` [PATCH v2 06/45] target/arm: Implement VFP fp16 for fused-multiply-add Peter Maydell
2020-08-28 18:33 ` [PATCH v2 07/45] target/arm: Macroify uses of do_vfp_2op_sp() and do_vfp_2op_dp() Peter Maydell
2020-08-28 18:33 ` [PATCH v2 08/45] target/arm: Implement VFP fp16 for VABS, VNEG, VSQRT Peter Maydell
2020-08-28 18:33 ` [PATCH v2 09/45] target/arm: Implement VFP fp16 for VMOV immediate Peter Maydell
2020-08-28 18:33 ` [PATCH v2 10/45] target/arm: Implement VFP fp16 VCMP Peter Maydell
2020-08-28 18:33 ` [PATCH v2 11/45] target/arm: Implement VFP fp16 VLDR and VSTR Peter Maydell
2020-08-28 18:33 ` Peter Maydell [this message]
2020-08-28 18:33 ` [PATCH v2 13/45] target/arm: Make VFP_CONV_FIX macros take separate float type and float size Peter Maydell
2020-08-28 18:33 ` [PATCH v2 14/45] target/arm: Use macros instead of open-coding fp16 conversion helpers Peter Maydell
2020-08-28 18:33 ` [PATCH v2 15/45] target/arm: Implement VFP fp16 VCVT between float and fixed-point Peter Maydell
2020-08-28 18:33 ` [PATCH v2 16/45] target/arm: Implement VFP vp16 VCVT-with-specified-rounding-mode Peter Maydell
2020-08-28 18:33 ` [PATCH v2 17/45] target/arm: Implement VFP fp16 VSEL Peter Maydell
2020-08-28 18:33 ` [PATCH v2 18/45] target/arm: Implement VFP fp16 VRINT* Peter Maydell
2020-08-28 18:33 ` [PATCH v2 19/45] target/arm: Implement new VFP fp16 insn VINS Peter Maydell
2020-08-28 18:33 ` [PATCH v2 20/45] target/arm: Implement new VFP fp16 insn VMOVX Peter Maydell
2020-08-28 18:33 ` [PATCH v2 21/45] target/arm: Implement VFP fp16 VMOV between gp and halfprec registers Peter Maydell
2020-08-28 18:33 ` [PATCH v2 22/45] fpu: Add float16 comparison functions Peter Maydell
2020-08-28 20:02   ` Richard Henderson
2020-08-28 18:33 ` [PATCH v2 23/45] target/arm: Implement FP16 for Neon VADD, VSUB, VABD, VMUL Peter Maydell
2020-08-28 20:06   ` Richard Henderson
2020-08-28 18:33 ` [PATCH v2 24/45] target/arm: Implement fp16 for Neon VRECPE, VRSQRTE using gvec Peter Maydell
2020-08-28 20:10   ` Richard Henderson
2020-08-28 21:40     ` Peter Maydell
2020-08-28 22:53       ` Richard Henderson
2020-08-29 13:53         ` Peter Maydell
2020-08-29 15:30           ` Richard Henderson
2020-08-28 18:33 ` [PATCH v2 25/45] target/arm: Implement fp16 for Neon VABS, VNEG of floats Peter Maydell
2020-08-28 20:33   ` Richard Henderson
2020-08-28 18:33 ` [PATCH v2 26/45] target/arm: Implement fp16 for VCEQ, VCGE, VCGT comparisons Peter Maydell
2020-08-28 20:45   ` Richard Henderson
2020-08-28 18:33 ` [PATCH v2 27/45] target/arm: Implement fp16 for VACGE, VACGT Peter Maydell
2020-08-28 20:46   ` Richard Henderson
2020-08-28 18:33 ` [PATCH v2 28/45] target/arm: Implement fp16 for Neon VMAX, VMIN Peter Maydell
2020-08-28 20:46   ` Richard Henderson
2020-08-28 18:33 ` [PATCH v2 29/45] target/arm: Implement fp16 for Neon VMAXNM, VMINNM Peter Maydell
2020-08-28 20:52   ` Richard Henderson
2020-08-28 18:33 ` [PATCH v2 30/45] target/arm: Implement fp16 for Neon VMLA, VMLS operations Peter Maydell
2020-08-28 20:54   ` Richard Henderson
2020-08-28 18:33 ` [PATCH v2 31/45] target/arm: Implement fp16 for Neon VFMA, VMFS Peter Maydell
2020-08-28 22:55   ` Richard Henderson
2020-08-28 18:33 ` [PATCH v2 32/45] target/arm: Implement fp16 for Neon fp compare-vs-0 Peter Maydell
2020-08-28 22:57   ` Richard Henderson
2020-08-28 18:33 ` [PATCH v2 33/45] target/arm: Implement fp16 for Neon VRECPS Peter Maydell
2020-08-28 23:02   ` Richard Henderson
2020-08-28 18:33 ` [PATCH v2 34/45] target/arm: Implement fp16 for Neon VRSQRTS Peter Maydell
2020-08-28 23:03   ` Richard Henderson
2020-08-28 18:33 ` [PATCH v2 35/45] target/arm: Implement fp16 for Neon pairwise fp ops Peter Maydell
2020-08-28 23:05   ` Richard Henderson
2020-08-28 18:33 ` [PATCH v2 36/45] target/arm: Implement fp16 for Neon float-integer VCVT Peter Maydell
2020-08-28 23:07   ` Richard Henderson
2020-08-28 18:33 ` [PATCH v2 37/45] target/arm: Convert Neon VCVT fixed-point to gvec Peter Maydell
2020-08-28 23:08   ` Richard Henderson
2020-08-28 18:33 ` [PATCH v2 38/45] target/arm: Implement fp16 for Neon VCVT fixed-point Peter Maydell
2020-08-28 23:10   ` Richard Henderson
2020-08-28 18:33 ` [PATCH v2 39/45] target/arm: Implement fp16 for Neon VCVT with rounding modes Peter Maydell
2020-08-28 23:13   ` Richard Henderson
2020-08-28 18:33 ` [PATCH v2 40/45] target/arm: Implement fp16 for Neon VRINT-with-specified-rounding-mode Peter Maydell
2020-08-28 23:15   ` Richard Henderson
2020-08-28 18:33 ` [PATCH v2 41/45] target/arm: Implement fp16 for Neon VRINTX Peter Maydell
2020-08-28 23:16   ` Richard Henderson
2020-08-28 18:33 ` [PATCH v2 42/45] target/arm/vec_helper: Handle oprsz less than 16 bytes in indexed operations Peter Maydell
2020-08-28 23:17   ` Richard Henderson
2020-08-28 18:33 ` [PATCH v2 43/45] target/arm/vec_helper: Add gvec fp indexed multiply-and-add operations Peter Maydell
2020-08-28 23:24   ` Richard Henderson
2020-08-29 13:51     ` Peter Maydell
2020-08-28 18:33 ` [PATCH v2 44/45] target/arm: Implement fp16 for Neon VMUL, VMLA, VMLS Peter Maydell
2020-08-28 23:38   ` Richard Henderson
2020-08-29 13:52     ` Peter Maydell
2020-08-28 18:33 ` [PATCH v2 45/45] target/arm: Enable FP16 in '-cpu max' Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200828183354.27913-13-peter.maydell@linaro.org \
    --to=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.