[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL v2 30/45] target/loongarch: Implement vpcnt
From: |
Song Gao |
Subject: |
[PULL v2 30/45] target/loongarch: Implement vpcnt |
Date: |
Sat, 6 May 2023 14:35:25 +0800 |
This patch includes:
- VPCNT.{B/H/W/D}.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Song Gao <gaosong@loongson.cn>
Message-Id: <20230504122810.4094787-31-gaosong@loongson.cn>
---
target/loongarch/disas.c | 5 +++++
target/loongarch/helper.h | 5 +++++
target/loongarch/insn_trans/trans_lsx.c.inc | 5 +++++
target/loongarch/insns.decode | 5 +++++
target/loongarch/lsx_helper.c | 18 ++++++++++++++++++
5 files changed, 38 insertions(+)
diff --git a/target/loongarch/disas.c b/target/loongarch/disas.c
index 0c82a1d9d1..0ca51de9d8 100644
--- a/target/loongarch/disas.c
+++ b/target/loongarch/disas.c
@@ -1267,3 +1267,8 @@ INSN_LSX(vclz_b, vv)
INSN_LSX(vclz_h, vv)
INSN_LSX(vclz_w, vv)
INSN_LSX(vclz_d, vv)
+
+INSN_LSX(vpcnt_b, vv)
+INSN_LSX(vpcnt_h, vv)
+INSN_LSX(vpcnt_w, vv)
+INSN_LSX(vpcnt_d, vv)
diff --git a/target/loongarch/helper.h b/target/loongarch/helper.h
index e21e9b9704..96b9b16923 100644
--- a/target/loongarch/helper.h
+++ b/target/loongarch/helper.h
@@ -480,3 +480,8 @@ DEF_HELPER_3(vclz_b, void, env, i32, i32)
DEF_HELPER_3(vclz_h, void, env, i32, i32)
DEF_HELPER_3(vclz_w, void, env, i32, i32)
DEF_HELPER_3(vclz_d, void, env, i32, i32)
+
+DEF_HELPER_3(vpcnt_b, void, env, i32, i32)
+DEF_HELPER_3(vpcnt_h, void, env, i32, i32)
+DEF_HELPER_3(vpcnt_w, void, env, i32, i32)
+DEF_HELPER_3(vpcnt_d, void, env, i32, i32)
diff --git a/target/loongarch/insn_trans/trans_lsx.c.inc
b/target/loongarch/insn_trans/trans_lsx.c.inc
index c7649fb777..f4ebdca63c 100644
--- a/target/loongarch/insn_trans/trans_lsx.c.inc
+++ b/target/loongarch/insn_trans/trans_lsx.c.inc
@@ -3106,3 +3106,8 @@ TRANS(vclz_b, gen_vv, gen_helper_vclz_b)
TRANS(vclz_h, gen_vv, gen_helper_vclz_h)
TRANS(vclz_w, gen_vv, gen_helper_vclz_w)
TRANS(vclz_d, gen_vv, gen_helper_vclz_d)
+
+TRANS(vpcnt_b, gen_vv, gen_helper_vpcnt_b)
+TRANS(vpcnt_h, gen_vv, gen_helper_vpcnt_h)
+TRANS(vpcnt_w, gen_vv, gen_helper_vpcnt_w)
+TRANS(vpcnt_d, gen_vv, gen_helper_vpcnt_d)
diff --git a/target/loongarch/insns.decode b/target/loongarch/insns.decode
index 7591ec1bab..f865e83da5 100644
--- a/target/loongarch/insns.decode
+++ b/target/loongarch/insns.decode
@@ -968,3 +968,8 @@ vclz_b 0111 00101001 11000 00100 ..... .....
@vv
vclz_h 0111 00101001 11000 00101 ..... ..... @vv
vclz_w 0111 00101001 11000 00110 ..... ..... @vv
vclz_d 0111 00101001 11000 00111 ..... ..... @vv
+
+vpcnt_b 0111 00101001 11000 01000 ..... ..... @vv
+vpcnt_h 0111 00101001 11000 01001 ..... ..... @vv
+vpcnt_w 0111 00101001 11000 01010 ..... ..... @vv
+vpcnt_d 0111 00101001 11000 01011 ..... ..... @vv
diff --git a/target/loongarch/lsx_helper.c b/target/loongarch/lsx_helper.c
index e808e5fc83..9f91a47e66 100644
--- a/target/loongarch/lsx_helper.c
+++ b/target/loongarch/lsx_helper.c
@@ -1946,3 +1946,21 @@ DO_2OP(vclz_b, 8, UB, DO_CLZ_B)
DO_2OP(vclz_h, 16, UH, DO_CLZ_H)
DO_2OP(vclz_w, 32, UW, DO_CLZ_W)
DO_2OP(vclz_d, 64, UD, DO_CLZ_D)
+
+#define VPCNT(NAME, BIT, E, FN) \
+void HELPER(NAME)(CPULoongArchState *env, uint32_t vd, uint32_t vj) \
+{ \
+ int i; \
+ VReg *Vd = &(env->fpr[vd].vreg); \
+ VReg *Vj = &(env->fpr[vj].vreg); \
+ \
+ for (i = 0; i < LSX_LEN/BIT; i++) \
+ { \
+ Vd->E(i) = FN(Vj->E(i)); \
+ } \
+}
+
+VPCNT(vpcnt_b, 8, UB, ctpop8)
+VPCNT(vpcnt_h, 16, UH, ctpop16)
+VPCNT(vpcnt_w, 32, UW, ctpop32)
+VPCNT(vpcnt_d, 64, UD, ctpop64)
--
2.31.1
- [PULL v2 02/45] target/loongarch: meson.build support build LSX, (continued)
- [PULL v2 02/45] target/loongarch: meson.build support build LSX, Song Gao, 2023/05/06
- [PULL v2 04/45] target/loongarch: Implement vadd/vsub, Song Gao, 2023/05/06
- [PULL v2 23/45] target/loongarch: Implement vsllwil vextl, Song Gao, 2023/05/06
- [PULL v2 17/45] target/loongarch: Implement vsat, Song Gao, 2023/05/06
- [PULL v2 21/45] target/loongarch: Implement LSX logic instructions, Song Gao, 2023/05/06
- [PULL v2 25/45] target/loongarch: Implement vsrln vsran, Song Gao, 2023/05/06
- [PULL v2 22/45] target/loongarch: Implement vsll vsrl vsra vrotr, Song Gao, 2023/05/06
- [PULL v2 24/45] target/loongarch: Implement vsrlr vsrar, Song Gao, 2023/05/06
- [PULL v2 26/45] target/loongarch: Implement vsrlrn vsrarn, Song Gao, 2023/05/06
- [PULL v2 34/45] target/loongarch: Implement LSX fpu fcvt instructions, Song Gao, 2023/05/06
- [PULL v2 30/45] target/loongarch: Implement vpcnt,
Song Gao <=
- [PULL v2 29/45] target/loongarch: Implement vclo vclz, Song Gao, 2023/05/06
- [PULL v2 27/45] target/loongarch: Implement vssrln vssran, Song Gao, 2023/05/06
- [PULL v2 32/45] target/loongarch: Implement vfrstp, Song Gao, 2023/05/06
- [PULL v2 28/45] target/loongarch: Implement vssrlrn vssrarn, Song Gao, 2023/05/06
- [PULL v2 35/45] target/loongarch: Implement vseq vsle vslt, Song Gao, 2023/05/06
- [PULL v2 38/45] target/loongarch: Implement vinsgr2vr vpickve2gr vreplgr2vr, Song Gao, 2023/05/06
- [PULL v2 39/45] target/loongarch: Implement vreplve vpack vpick, Song Gao, 2023/05/06
- [PULL v2 37/45] target/loongarch: Implement vbitsel vset, Song Gao, 2023/05/06
- [PULL v2 42/45] target/loongarch: Implement vldi, Song Gao, 2023/05/06
- [PULL v2 45/45] hw/intc: don't use target_ulong for LoongArch ipi, Song Gao, 2023/05/06