[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 37/85] target/arm: Introduce gen_gvec_cls, gen_gvec_clz
From: |
Peter Maydell |
Subject: |
[PULL 37/85] target/arm: Introduce gen_gvec_cls, gen_gvec_clz |
Date: |
Fri, 13 Dec 2024 17:31:41 +0000 |
From: Richard Henderson <richard.henderson@linaro.org>
Add gvec interfaces for CLS and CLZ operations.
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20241211163036.2297116-38-richard.henderson@linaro.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
target/arm/tcg/translate.h | 5 +++++
target/arm/tcg/gengvec.c | 35 +++++++++++++++++++++++++++++++++
target/arm/tcg/translate-a64.c | 29 +++++++--------------------
target/arm/tcg/translate-neon.c | 29 ++-------------------------
4 files changed, 49 insertions(+), 49 deletions(-)
diff --git a/target/arm/tcg/translate.h b/target/arm/tcg/translate.h
index 20cd0e851c4..5c6c24f0575 100644
--- a/target/arm/tcg/translate.h
+++ b/target/arm/tcg/translate.h
@@ -578,6 +578,11 @@ void gen_gvec_umaxp(unsigned vece, uint32_t rd_ofs,
uint32_t rn_ofs,
void gen_gvec_uminp(unsigned vece, uint32_t rd_ofs, uint32_t rn_ofs,
uint32_t rm_ofs, uint32_t opr_sz, uint32_t max_sz);
+void gen_gvec_cls(unsigned vece, uint32_t rd_ofs, uint32_t rn_ofs,
+ uint32_t opr_sz, uint32_t max_sz);
+void gen_gvec_clz(unsigned vece, uint32_t rd_ofs, uint32_t rn_ofs,
+ uint32_t opr_sz, uint32_t max_sz);
+
/*
* Forward to the isar_feature_* tests given a DisasContext pointer.
*/
diff --git a/target/arm/tcg/gengvec.c b/target/arm/tcg/gengvec.c
index f652520b652..834b2961c06 100644
--- a/target/arm/tcg/gengvec.c
+++ b/target/arm/tcg/gengvec.c
@@ -2358,3 +2358,38 @@ void gen_gvec_urhadd(unsigned vece, uint32_t rd_ofs,
uint32_t rn_ofs,
assert(vece <= MO_32);
tcg_gen_gvec_3(rd_ofs, rn_ofs, rm_ofs, opr_sz, max_sz, &g[vece]);
}
+
+void gen_gvec_cls(unsigned vece, uint32_t rd_ofs, uint32_t rn_ofs,
+ uint32_t opr_sz, uint32_t max_sz)
+{
+ static const GVecGen2 g[] = {
+ { .fni4 = gen_helper_neon_cls_s8,
+ .vece = MO_8 },
+ { .fni4 = gen_helper_neon_cls_s16,
+ .vece = MO_16 },
+ { .fni4 = tcg_gen_clrsb_i32,
+ .vece = MO_32 },
+ };
+ assert(vece <= MO_32);
+ tcg_gen_gvec_2(rd_ofs, rn_ofs, opr_sz, max_sz, &g[vece]);
+}
+
+static void gen_clz32_i32(TCGv_i32 d, TCGv_i32 n)
+{
+ tcg_gen_clzi_i32(d, n, 32);
+}
+
+void gen_gvec_clz(unsigned vece, uint32_t rd_ofs, uint32_t rn_ofs,
+ uint32_t opr_sz, uint32_t max_sz)
+{
+ static const GVecGen2 g[] = {
+ { .fni4 = gen_helper_neon_clz_u8,
+ .vece = MO_8 },
+ { .fni4 = gen_helper_neon_clz_u16,
+ .vece = MO_16 },
+ { .fni4 = gen_clz32_i32,
+ .vece = MO_32 },
+ };
+ assert(vece <= MO_32);
+ tcg_gen_gvec_2(rd_ofs, rn_ofs, opr_sz, max_sz, &g[vece]);
+}
diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c
index c697f0e9441..387bbbf906b 100644
--- a/target/arm/tcg/translate-a64.c
+++ b/target/arm/tcg/translate-a64.c
@@ -10321,6 +10321,13 @@ static void disas_simd_two_reg_misc(DisasContext *s,
uint32_t insn)
}
switch (opcode) {
+ case 0x4: /* CLZ, CLS */
+ if (u) {
+ gen_gvec_fn2(s, is_q, rd, rn, gen_gvec_clz, size);
+ } else {
+ gen_gvec_fn2(s, is_q, rd, rn, gen_gvec_cls, size);
+ }
+ return;
case 0x5:
if (u && size == 0) { /* NOT */
gen_gvec_fn2(s, is_q, rd, rn, tcg_gen_gvec_not, 0);
@@ -10379,13 +10386,6 @@ static void disas_simd_two_reg_misc(DisasContext *s,
uint32_t insn)
if (size == 2) {
/* Special cases for 32 bit elements */
switch (opcode) {
- case 0x4: /* CLS */
- if (u) {
- tcg_gen_clzi_i32(tcg_res, tcg_op, 32);
- } else {
- tcg_gen_clrsb_i32(tcg_res, tcg_op);
- }
- break;
case 0x2f: /* FABS */
gen_vfp_abss(tcg_res, tcg_op);
break;
@@ -10450,21 +10450,6 @@ static void disas_simd_two_reg_misc(DisasContext *s,
uint32_t insn)
gen_helper_neon_cnt_u8(tcg_res, tcg_op);
}
break;
- case 0x4: /* CLS, CLZ */
- if (u) {
- if (size == 0) {
- gen_helper_neon_clz_u8(tcg_res, tcg_op);
- } else {
- gen_helper_neon_clz_u16(tcg_res, tcg_op);
- }
- } else {
- if (size == 0) {
- gen_helper_neon_cls_s8(tcg_res, tcg_op);
- } else {
- gen_helper_neon_cls_s16(tcg_res, tcg_op);
- }
- }
- break;
default:
case 0x7: /* SQABS, SQNEG */
g_assert_not_reached();
diff --git a/target/arm/tcg/translate-neon.c b/target/arm/tcg/translate-neon.c
index 9c8829ad7d2..1c89a532722 100644
--- a/target/arm/tcg/translate-neon.c
+++ b/target/arm/tcg/translate-neon.c
@@ -3120,6 +3120,8 @@ DO_2MISC_VEC(VCGT0, gen_gvec_cgt0)
DO_2MISC_VEC(VCLE0, gen_gvec_cle0)
DO_2MISC_VEC(VCGE0, gen_gvec_cge0)
DO_2MISC_VEC(VCLT0, gen_gvec_clt0)
+DO_2MISC_VEC(VCLS, gen_gvec_cls)
+DO_2MISC_VEC(VCLZ, gen_gvec_clz)
static bool trans_VMVN(DisasContext *s, arg_2misc *a)
{
@@ -3227,33 +3229,6 @@ static bool trans_VREV16(DisasContext *s, arg_2misc *a)
return do_2misc(s, a, gen_rev16);
}
-static bool trans_VCLS(DisasContext *s, arg_2misc *a)
-{
- static NeonGenOneOpFn * const fn[] = {
- gen_helper_neon_cls_s8,
- gen_helper_neon_cls_s16,
- gen_helper_neon_cls_s32,
- NULL,
- };
- return do_2misc(s, a, fn[a->size]);
-}
-
-static void do_VCLZ_32(TCGv_i32 rd, TCGv_i32 rm)
-{
- tcg_gen_clzi_i32(rd, rm, 32);
-}
-
-static bool trans_VCLZ(DisasContext *s, arg_2misc *a)
-{
- static NeonGenOneOpFn * const fn[] = {
- gen_helper_neon_clz_u8,
- gen_helper_neon_clz_u16,
- do_VCLZ_32,
- NULL,
- };
- return do_2misc(s, a, fn[a->size]);
-}
-
static bool trans_VCNT(DisasContext *s, arg_2misc *a)
{
if (a->size != 0) {
--
2.34.1
- [PULL 18/85] target/arm: Convert CCMP, CCMN to decodetree, (continued)
- [PULL 18/85] target/arm: Convert CCMP, CCMN to decodetree, Peter Maydell, 2024/12/13
- [PULL 16/85] target/arm: Convert RMIF to decodetree, Peter Maydell, 2024/12/13
- [PULL 19/85] target/arm: Convert disas_cond_select to decodetree, Peter Maydell, 2024/12/13
- [PULL 23/85] target/arm: Fix decode of fp16 vector fabs, fneg, fsqrt, Peter Maydell, 2024/12/13
- [PULL 26/85] target/arm: Remove helper_sqrt_f16, Peter Maydell, 2024/12/13
- [PULL 27/85] target/arm: Convert FSQRT (scalar) to decodetree, Peter Maydell, 2024/12/13
- [PULL 28/85] target/arm: Convert FRINT[NPMSAXI] (scalar) to decodetree, Peter Maydell, 2024/12/13
- [PULL 30/85] target/arm: Convert FRINT{32, 64}[ZX] (scalar) to decodetree, Peter Maydell, 2024/12/13
- [PULL 31/85] target/arm: Convert FCVT (scalar) to decodetree, Peter Maydell, 2024/12/13
- [PULL 35/85] target/arm: Convert SQABS, SQNEG to decodetree, Peter Maydell, 2024/12/13
- [PULL 37/85] target/arm: Introduce gen_gvec_cls, gen_gvec_clz,
Peter Maydell <=
- [PULL 41/85] target/arm: Convert CMGT, CMGE, GMLT, GMLE, CMEQ (zero) to decodetree, Peter Maydell, 2024/12/13
- [PULL 40/85] target/arm: Convert CNT, NOT, RBIT (vector) to decodetree, Peter Maydell, 2024/12/13
- [PULL 42/85] target/arm: Introduce gen_gvec_rev{16,32,64}, Peter Maydell, 2024/12/13
- [PULL 43/85] target/arm: Convert handle_rev to decodetree, Peter Maydell, 2024/12/13
- [PULL 47/85] target/arm: Remove helper_neon_{add,sub}l_u{16,32}, Peter Maydell, 2024/12/13
- [PULL 46/85] target/arm: Convert handle_2misc_pairwise to decodetree, Peter Maydell, 2024/12/13
- [PULL 52/85] target/arm: Convert SHLL to decodetree, Peter Maydell, 2024/12/13
- [PULL 50/85] target/arm: Convert FCVTN, BFCVTN to decodetree, Peter Maydell, 2024/12/13
- [PULL 54/85] target/arm: Convert FABS, FNEG (vector) to decodetree, Peter Maydell, 2024/12/13
- [PULL 53/85] target/arm: Implement gen_gvec_fabs, gen_gvec_fneg, Peter Maydell, 2024/12/13
- Prev by Date:
[PULL 35/85] target/arm: Convert SQABS, SQNEG to decodetree
- Next by Date:
[PULL 41/85] target/arm: Convert CMGT, CMGE, GMLT, GMLE, CMEQ (zero) to decodetree
- Previous by thread:
[PULL 35/85] target/arm: Convert SQABS, SQNEG to decodetree
- Next by thread:
[PULL 41/85] target/arm: Convert CMGT, CMGE, GMLT, GMLE, CMEQ (zero) to decodetree
- Index(es):