qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org
Subject: [Qemu-devel] [PATCH v5 25/35] target/arm: Implement SVE floating-point round to integral value
Date: Wed, 20 Jun 2018 15:53:49 -1000	[thread overview]
Message-ID: <20180621015359.12018-26-richard.henderson@linaro.org> (raw)
In-Reply-To: <20180621015359.12018-1-richard.henderson@linaro.org>

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 target/arm/helper-sve.h    | 14 +++++++
 target/arm/sve_helper.c    |  8 ++++
 target/arm/translate-sve.c | 77 ++++++++++++++++++++++++++++++++++++++
 target/arm/sve.decode      |  9 +++++
 4 files changed, 108 insertions(+)

diff --git a/target/arm/helper-sve.h b/target/arm/helper-sve.h
index 37fa9eb9bb..36168c5bb2 100644
--- a/target/arm/helper-sve.h
+++ b/target/arm/helper-sve.h
@@ -985,6 +985,20 @@ DEF_HELPER_FLAGS_5(sve_fcvtzu_sd, TCG_CALL_NO_RWG,
 DEF_HELPER_FLAGS_5(sve_fcvtzu_dd, TCG_CALL_NO_RWG,
                    void, ptr, ptr, ptr, ptr, i32)
 
+DEF_HELPER_FLAGS_5(sve_frint_h, TCG_CALL_NO_RWG,
+                   void, ptr, ptr, ptr, ptr, i32)
+DEF_HELPER_FLAGS_5(sve_frint_s, TCG_CALL_NO_RWG,
+                   void, ptr, ptr, ptr, ptr, i32)
+DEF_HELPER_FLAGS_5(sve_frint_d, TCG_CALL_NO_RWG,
+                   void, ptr, ptr, ptr, ptr, i32)
+
+DEF_HELPER_FLAGS_5(sve_frintx_h, TCG_CALL_NO_RWG,
+                   void, ptr, ptr, ptr, ptr, i32)
+DEF_HELPER_FLAGS_5(sve_frintx_s, TCG_CALL_NO_RWG,
+                   void, ptr, ptr, ptr, ptr, i32)
+DEF_HELPER_FLAGS_5(sve_frintx_d, TCG_CALL_NO_RWG,
+                   void, ptr, ptr, ptr, ptr, i32)
+
 DEF_HELPER_FLAGS_5(sve_scvt_hh, TCG_CALL_NO_RWG,
                    void, ptr, ptr, ptr, ptr, i32)
 DEF_HELPER_FLAGS_5(sve_scvt_sh, TCG_CALL_NO_RWG,
diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c
index 497efbf3a8..3b7a2f58c1 100644
--- a/target/arm/sve_helper.c
+++ b/target/arm/sve_helper.c
@@ -3262,6 +3262,14 @@ DO_ZPZ_FP(sve_fcvtzu_sd, uint64_t,     , vfp_float32_to_uint64_rtz)
 DO_ZPZ_FP(sve_fcvtzu_ds, uint64_t,     , helper_vfp_touizd)
 DO_ZPZ_FP(sve_fcvtzu_dd, uint64_t,     , vfp_float64_to_uint64_rtz)
 
+DO_ZPZ_FP(sve_frint_h, uint16_t, H1_2, helper_advsimd_rinth)
+DO_ZPZ_FP(sve_frint_s, uint32_t, H1_4, helper_rints)
+DO_ZPZ_FP(sve_frint_d, uint64_t,     , helper_rintd)
+
+DO_ZPZ_FP(sve_frintx_h, uint16_t, H1_2, float16_round_to_int)
+DO_ZPZ_FP(sve_frintx_s, uint32_t, H1_4, float32_round_to_int)
+DO_ZPZ_FP(sve_frintx_d, uint64_t,     , float64_round_to_int)
+
 DO_ZPZ_FP(sve_scvt_hh, uint16_t, H1_2, int16_to_float16)
 DO_ZPZ_FP(sve_scvt_sh, uint32_t, H1_4, int32_to_float16)
 DO_ZPZ_FP(sve_scvt_ss, uint32_t, H1_4, int32_to_float32)
diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c
index fd94c5337e..15e4f2888b 100644
--- a/target/arm/translate-sve.c
+++ b/target/arm/translate-sve.c
@@ -4040,6 +4040,83 @@ static bool trans_FCVTZU_dd(DisasContext *s, arg_rpr_esz *a, uint32_t insn)
     return do_zpz_ptr(s, a->rd, a->rn, a->pg, false, gen_helper_sve_fcvtzu_dd);
 }
 
+static gen_helper_gvec_3_ptr * const frint_fns[3] = {
+    gen_helper_sve_frint_h,
+    gen_helper_sve_frint_s,
+    gen_helper_sve_frint_d
+};
+
+static bool trans_FRINTI(DisasContext *s, arg_rpr_esz *a, uint32_t insn)
+{
+    if (a->esz == 0) {
+        return false;
+    }
+    return do_zpz_ptr(s, a->rd, a->rn, a->pg, a->esz == MO_16,
+                      frint_fns[a->esz - 1]);
+}
+
+static bool trans_FRINTX(DisasContext *s, arg_rpr_esz *a, uint32_t insn)
+{
+    static gen_helper_gvec_3_ptr * const fns[3] = {
+        gen_helper_sve_frintx_h,
+        gen_helper_sve_frintx_s,
+        gen_helper_sve_frintx_d
+    };
+    if (a->esz == 0) {
+        return false;
+    }
+    return do_zpz_ptr(s, a->rd, a->rn, a->pg, a->esz == MO_16, fns[a->esz - 1]);
+}
+
+static bool do_frint_mode(DisasContext *s, arg_rpr_esz *a, int mode)
+{
+    if (a->esz == 0) {
+        return false;
+    }
+    if (sve_access_check(s)) {
+        unsigned vsz = vec_full_reg_size(s);
+        TCGv_i32 tmode = tcg_const_i32(mode);
+        TCGv_ptr status = get_fpstatus_ptr(a->esz == MO_16);
+
+        gen_helper_set_rmode(tmode, tmode, status);
+
+        tcg_gen_gvec_3_ptr(vec_full_reg_offset(s, a->rd),
+                           vec_full_reg_offset(s, a->rn),
+                           pred_full_reg_offset(s, a->pg),
+                           status, vsz, vsz, 0, frint_fns[a->esz - 1]);
+
+        gen_helper_set_rmode(tmode, tmode, status);
+        tcg_temp_free_i32(tmode);
+        tcg_temp_free_ptr(status);
+    }
+    return true;
+}
+
+static bool trans_FRINTN(DisasContext *s, arg_rpr_esz *a, uint32_t insn)
+{
+    return do_frint_mode(s, a, float_round_nearest_even);
+}
+
+static bool trans_FRINTP(DisasContext *s, arg_rpr_esz *a, uint32_t insn)
+{
+    return do_frint_mode(s, a, float_round_up);
+}
+
+static bool trans_FRINTM(DisasContext *s, arg_rpr_esz *a, uint32_t insn)
+{
+    return do_frint_mode(s, a, float_round_down);
+}
+
+static bool trans_FRINTZ(DisasContext *s, arg_rpr_esz *a, uint32_t insn)
+{
+    return do_frint_mode(s, a, float_round_to_zero);
+}
+
+static bool trans_FRINTA(DisasContext *s, arg_rpr_esz *a, uint32_t insn)
+{
+    return do_frint_mode(s, a, float_round_ties_away);
+}
+
 static bool trans_SCVTF_hh(DisasContext *s, arg_rpr_esz *a, uint32_t insn)
 {
     return do_zpz_ptr(s, a->rd, a->rn, a->pg, true, gen_helper_sve_scvt_hh);
diff --git a/target/arm/sve.decode b/target/arm/sve.decode
index c4597d4fbe..eeab3d485f 100644
--- a/target/arm/sve.decode
+++ b/target/arm/sve.decode
@@ -840,6 +840,15 @@ FCVTZU_sd       01100101 11 011 10 1 101 ... ..... .....        @rd_pg_rn_e0
 FCVTZS_dd       01100101 11 011 11 0 101 ... ..... .....        @rd_pg_rn_e0
 FCVTZU_dd       01100101 11 011 11 1 101 ... ..... .....        @rd_pg_rn_e0
 
+# SVE floating-point round to integral value
+FRINTN          01100101 .. 000 000 101 ... ..... .....         @rd_pg_rn
+FRINTP          01100101 .. 000 001 101 ... ..... .....         @rd_pg_rn
+FRINTM          01100101 .. 000 010 101 ... ..... .....         @rd_pg_rn
+FRINTZ          01100101 .. 000 011 101 ... ..... .....         @rd_pg_rn
+FRINTA          01100101 .. 000 100 101 ... ..... .....         @rd_pg_rn
+FRINTX          01100101 .. 000 110 101 ... ..... .....         @rd_pg_rn
+FRINTI          01100101 .. 000 111 101 ... ..... .....         @rd_pg_rn
+
 # SVE integer convert to floating-point
 SCVTF_hh        01100101 01 010 01 0 101 ... ..... .....        @rd_pg_rn_e0
 SCVTF_sh        01100101 01 010 10 0 101 ... ..... .....        @rd_pg_rn_e0
-- 
2.17.1

  parent reply	other threads:[~2018-06-21  1:55 UTC|newest]

Thread overview: 95+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-21  1:53 [Qemu-devel] [PATCH v5 00/35] target/arm SVE patches Richard Henderson
2018-06-21  1:53 ` [Qemu-devel] [PATCH v5 01/35] target/arm: Implement SVE Memory Contiguous Load Group Richard Henderson
2018-06-22 15:29   ` Peter Maydell
2018-06-26  9:55   ` Alex Bennée
2018-06-26 14:04     ` Richard Henderson
2018-06-21  1:53 ` [Qemu-devel] [PATCH v5 02/35] target/arm: Implement SVE Contiguous Load, first-fault and no-fault Richard Henderson
2018-06-22 16:04   ` Peter Maydell
2018-06-22 18:37     ` Richard Henderson
2018-06-26 12:52   ` Alex Bennée
2018-06-26 14:06     ` Richard Henderson
2018-06-27 11:37       ` Alex Bennée
2018-06-21  1:53 ` [Qemu-devel] [PATCH v5 03/35] target/arm: Implement SVE Memory Contiguous Store Group Richard Henderson
2018-06-25 15:03   ` Peter Maydell
2018-06-27 11:38   ` Alex Bennée
2018-06-21  1:53 ` [Qemu-devel] [PATCH v5 04/35] target/arm: Implement SVE load and broadcast quadword Richard Henderson
2018-06-25 15:08   ` Peter Maydell
2018-06-27 14:05   ` Alex Bennée
2018-06-21  1:53 ` [Qemu-devel] [PATCH v5 05/35] target/arm: Implement SVE integer convert to floating-point Richard Henderson
2018-06-25 15:21   ` Peter Maydell
2018-06-27 14:19   ` Alex Bennée
2018-06-21  1:53 ` [Qemu-devel] [PATCH v5 06/35] target/arm: Implement SVE floating-point arithmetic (predicated) Richard Henderson
2018-06-25 15:24   ` Peter Maydell
2018-06-21  1:53 ` [Qemu-devel] [PATCH v5 07/35] target/arm: Implement SVE FP Multiply-Add Group Richard Henderson
2018-06-25 15:32   ` Peter Maydell
2018-06-26 14:08     ` Richard Henderson
2018-06-26 14:11       ` Peter Maydell
2018-06-21  1:53 ` [Qemu-devel] [PATCH v5 08/35] target/arm: Implement SVE Floating Point Accumulating Reduction Group Richard Henderson
2018-06-25 15:35   ` Peter Maydell
2018-06-21  1:53 ` [Qemu-devel] [PATCH v5 09/35] target/arm: Implement SVE load and broadcast element Richard Henderson
2018-06-25 15:46   ` Peter Maydell
2018-06-26 14:10     ` Richard Henderson
2018-06-21  1:53 ` [Qemu-devel] [PATCH v5 10/35] target/arm: Implement SVE store vector/predicate register Richard Henderson
2018-06-25 15:51   ` Peter Maydell
2018-06-21  1:53 ` [Qemu-devel] [PATCH v5 11/35] target/arm: Implement SVE scatter stores Richard Henderson
2018-06-25 16:13   ` Peter Maydell
2018-06-26 14:21     ` Richard Henderson
2018-06-21  1:53 ` [Qemu-devel] [PATCH v5 12/35] target/arm: Implement SVE prefetches Richard Henderson
2018-06-25 16:18   ` Peter Maydell
2018-06-21  1:53 ` [Qemu-devel] [PATCH v5 13/35] target/arm: Implement SVE gather loads Richard Henderson
2018-06-25 16:55   ` Peter Maydell
2018-06-26 14:39     ` Richard Henderson
2018-06-21  1:53 ` [Qemu-devel] [PATCH v5 14/35] target/arm: Implement SVE first-fault " Richard Henderson
2018-06-25 16:57   ` Peter Maydell
2018-06-21  1:53 ` [Qemu-devel] [PATCH v5 15/35] target/arm: Implement SVE scatter store vector immediate Richard Henderson
2018-06-25 17:00   ` Peter Maydell
2018-06-21  1:53 ` [Qemu-devel] [PATCH v5 16/35] target/arm: Implement SVE floating-point compare vectors Richard Henderson
2018-06-25 17:20   ` Peter Maydell
2018-06-26 16:41     ` Richard Henderson
2018-06-21  1:53 ` [Qemu-devel] [PATCH v5 17/35] target/arm: Implement SVE floating-point arithmetic with immediate Richard Henderson
2018-06-25 17:27   ` Peter Maydell
2018-06-21  1:53 ` [Qemu-devel] [PATCH v5 18/35] target/arm: Implement SVE Floating Point Multiply Indexed Group Richard Henderson
2018-06-25 17:47   ` Peter Maydell
2018-06-26 14:50     ` Richard Henderson
2018-06-21  1:53 ` [Qemu-devel] [PATCH v5 19/35] target/arm: Implement SVE FP Fast Reduction Group Richard Henderson
2018-06-26 10:09   ` Peter Maydell
2018-06-21  1:53 ` [Qemu-devel] [PATCH v5 20/35] target/arm: Implement SVE Floating Point Unary Operations - Unpredicated Group Richard Henderson
2018-06-26 10:13   ` Peter Maydell
2018-06-21  1:53 ` [Qemu-devel] [PATCH v5 21/35] target/arm: Implement SVE FP Compare with Zero Group Richard Henderson
2018-06-26 10:18   ` Peter Maydell
2018-06-21  1:53 ` [Qemu-devel] [PATCH v5 22/35] target/arm: Implement SVE floating-point trig multiply-add coefficient Richard Henderson
2018-06-26 10:25   ` Peter Maydell
2018-06-21  1:53 ` [Qemu-devel] [PATCH v5 23/35] target/arm: Implement SVE floating-point convert precision Richard Henderson
2018-06-26 10:44   ` Peter Maydell
2018-06-27  4:02     ` Richard Henderson
2018-06-21  1:53 ` [Qemu-devel] [PATCH v5 24/35] target/arm: Implement SVE floating-point convert to integer Richard Henderson
2018-06-26 10:58   ` Peter Maydell
2018-06-26 18:24     ` Richard Henderson
2018-06-21  1:53 ` Richard Henderson [this message]
2018-06-26 12:09   ` [Qemu-devel] [PATCH v5 25/35] target/arm: Implement SVE floating-point round to integral value Peter Maydell
2018-06-21  1:53 ` [Qemu-devel] [PATCH v5 26/35] target/arm: Implement SVE floating-point unary operations Richard Henderson
2018-06-26 12:13   ` Peter Maydell
2018-06-21  1:53 ` [Qemu-devel] [PATCH v5 27/35] target/arm: Implement SVE MOVPRFX Richard Henderson
2018-06-26 12:24   ` Peter Maydell
2018-06-26 14:57     ` Richard Henderson
2018-06-21  1:53 ` [Qemu-devel] [PATCH v5 28/35] target/arm: Implement SVE floating-point complex add Richard Henderson
2018-06-26 13:17   ` Peter Maydell
2018-06-21  1:53 ` [Qemu-devel] [PATCH v5 29/35] target/arm: Implement SVE fp complex multiply add Richard Henderson
2018-06-26 13:29   ` Peter Maydell
2018-06-26 15:04     ` Richard Henderson
2018-06-26 15:17       ` Peter Maydell
2018-06-21  1:53 ` [Qemu-devel] [PATCH v5 30/35] target/arm: Pass index to AdvSIMD FCMLA (indexed) Richard Henderson
2018-06-26 13:38   ` Peter Maydell
2018-06-26 15:07     ` Richard Henderson
2018-06-21  1:53 ` [Qemu-devel] [PATCH v5 31/35] target/arm: Implement SVE fp complex multiply add (indexed) Richard Henderson
2018-06-21  1:53 ` [Qemu-devel] [PATCH v5 32/35] target/arm: Implement SVE dot product (vectors) Richard Henderson
2018-06-26 13:47   ` Peter Maydell
2018-06-21  1:53 ` [Qemu-devel] [PATCH v5 33/35] target/arm: Implement SVE dot product (indexed) Richard Henderson
2018-06-26 15:30   ` Peter Maydell
2018-06-26 16:17     ` Richard Henderson
2018-06-26 16:30       ` Peter Maydell
2018-06-21  1:53 ` [Qemu-devel] [PATCH v5 34/35] target/arm: Enable SVE for aarch64-linux-user Richard Henderson
2018-06-21  1:53 ` [Qemu-devel] [PATCH v5 35/35] target/arm: Implement ARMv8.2-DotProd Richard Henderson
2018-06-26 15:38   ` Peter Maydell
2018-06-21  5:18 ` [Qemu-devel] [PATCH v5 00/35] target/arm SVE patches no-reply
2018-06-26  9:41 ` Alex Bennée

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=20180621015359.12018-26-richard.henderson@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=peter.maydell@linaro.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).