This patch includes: - VMSKLTZ.{B/H/W/D}; - VMSKGEZ.B; - VMSKNZ.B. Reviewed-by: Richard Henderson <richard.hender...@linaro.org> Signed-off-by: Song Gao <gaos...@loongson.cn> Message-Id: <20230504122810.4094787-21-gaos...@loongson.cn> --- target/loongarch/disas.c | 7 ++ target/loongarch/helper.h | 7 ++ target/loongarch/insn_trans/trans_lsx.c.inc | 7 ++ target/loongarch/insns.decode | 7 ++ target/loongarch/lsx_helper.c | 113 ++++++++++++++++++++ 5 files changed, 141 insertions(+)
diff --git a/target/loongarch/disas.c b/target/loongarch/disas.c index 46e808c321..2725b827ee 100644 --- a/target/loongarch/disas.c +++ b/target/loongarch/disas.c @@ -1084,3 +1084,10 @@ INSN_LSX(vsigncov_b, vvv) INSN_LSX(vsigncov_h, vvv) INSN_LSX(vsigncov_w, vvv) INSN_LSX(vsigncov_d, vvv) + +INSN_LSX(vmskltz_b, vv) +INSN_LSX(vmskltz_h, vv) +INSN_LSX(vmskltz_w, vv) +INSN_LSX(vmskltz_d, vv) +INSN_LSX(vmskgez_b, vv) +INSN_LSX(vmsknz_b, vv) diff --git a/target/loongarch/helper.h b/target/loongarch/helper.h index e1e5d58697..34b7b2f576 100644 --- a/target/loongarch/helper.h +++ b/target/loongarch/helper.h @@ -343,3 +343,10 @@ DEF_HELPER_FLAGS_4(vsigncov_b, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) DEF_HELPER_FLAGS_4(vsigncov_h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) DEF_HELPER_FLAGS_4(vsigncov_w, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) DEF_HELPER_FLAGS_4(vsigncov_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) + +DEF_HELPER_3(vmskltz_b, void, env, i32, i32) +DEF_HELPER_3(vmskltz_h, void, env, i32, i32) +DEF_HELPER_3(vmskltz_w, void, env, i32, i32) +DEF_HELPER_3(vmskltz_d, void, env, i32, i32) +DEF_HELPER_3(vmskgez_b, void, env, i32, i32) +DEF_HELPER_3(vmsknz_b, 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 644917a695..64387f2666 100644 --- a/target/loongarch/insn_trans/trans_lsx.c.inc +++ b/target/loongarch/insn_trans/trans_lsx.c.inc @@ -2867,3 +2867,10 @@ TRANS(vsigncov_b, gvec_vvv, MO_8, do_vsigncov) TRANS(vsigncov_h, gvec_vvv, MO_16, do_vsigncov) TRANS(vsigncov_w, gvec_vvv, MO_32, do_vsigncov) TRANS(vsigncov_d, gvec_vvv, MO_64, do_vsigncov) + +TRANS(vmskltz_b, gen_vv, gen_helper_vmskltz_b) +TRANS(vmskltz_h, gen_vv, gen_helper_vmskltz_h) +TRANS(vmskltz_w, gen_vv, gen_helper_vmskltz_w) +TRANS(vmskltz_d, gen_vv, gen_helper_vmskltz_d) +TRANS(vmskgez_b, gen_vv, gen_helper_vmskgez_b) +TRANS(vmsknz_b, gen_vv, gen_helper_vmsknz_b) diff --git a/target/loongarch/insns.decode b/target/loongarch/insns.decode index 4233dd7404..47c1ef78a7 100644 --- a/target/loongarch/insns.decode +++ b/target/loongarch/insns.decode @@ -783,3 +783,10 @@ vsigncov_b 0111 00010010 11100 ..... ..... ..... @vvv vsigncov_h 0111 00010010 11101 ..... ..... ..... @vvv vsigncov_w 0111 00010010 11110 ..... ..... ..... @vvv vsigncov_d 0111 00010010 11111 ..... ..... ..... @vvv + +vmskltz_b 0111 00101001 11000 10000 ..... ..... @vv +vmskltz_h 0111 00101001 11000 10001 ..... ..... @vv +vmskltz_w 0111 00101001 11000 10010 ..... ..... @vv +vmskltz_d 0111 00101001 11000 10011 ..... ..... @vv +vmskgez_b 0111 00101001 11000 10100 ..... ..... @vv +vmsknz_b 0111 00101001 11000 11000 ..... ..... @vv diff --git a/target/loongarch/lsx_helper.c b/target/loongarch/lsx_helper.c index 408815ea45..2359c63fdf 100644 --- a/target/loongarch/lsx_helper.c +++ b/target/loongarch/lsx_helper.c @@ -669,3 +669,116 @@ DO_3OP(vsigncov_b, 8, B, DO_SIGNCOV) DO_3OP(vsigncov_h, 16, H, DO_SIGNCOV) DO_3OP(vsigncov_w, 32, W, DO_SIGNCOV) DO_3OP(vsigncov_d, 64, D, DO_SIGNCOV) + +static uint64_t do_vmskltz_b(int64_t val) +{ + uint64_t m = 0x8080808080808080ULL; + uint64_t c = val & m; + c |= c << 7; + c |= c << 14; + c |= c << 28; + return c >> 56; +} + +void HELPER(vmskltz_b)(CPULoongArchState *env, uint32_t vd, uint32_t vj) +{ + uint16_t temp = 0; + VReg *Vd = &(env->fpr[vd].vreg); + VReg *Vj = &(env->fpr[vj].vreg); + + temp = do_vmskltz_b(Vj->D(0)); + temp |= (do_vmskltz_b(Vj->D(1)) << 8); + Vd->D(0) = temp; + Vd->D(1) = 0; +} + +static uint64_t do_vmskltz_h(int64_t val) +{ + uint64_t m = 0x8000800080008000ULL; + uint64_t c = val & m; + c |= c << 15; + c |= c << 30; + return c >> 60; +} + +void HELPER(vmskltz_h)(CPULoongArchState *env, uint32_t vd, uint32_t vj) +{ + uint16_t temp = 0; + VReg *Vd = &(env->fpr[vd].vreg); + VReg *Vj = &(env->fpr[vj].vreg); + + temp = do_vmskltz_h(Vj->D(0)); + temp |= (do_vmskltz_h(Vj->D(1)) << 4); + Vd->D(0) = temp; + Vd->D(1) = 0; +} + +static uint64_t do_vmskltz_w(int64_t val) +{ + uint64_t m = 0x8000000080000000ULL; + uint64_t c = val & m; + c |= c << 31; + return c >> 62; +} + +void HELPER(vmskltz_w)(CPULoongArchState *env, uint32_t vd, uint32_t vj) +{ + uint16_t temp = 0; + VReg *Vd = &(env->fpr[vd].vreg); + VReg *Vj = &(env->fpr[vj].vreg); + + temp = do_vmskltz_w(Vj->D(0)); + temp |= (do_vmskltz_w(Vj->D(1)) << 2); + Vd->D(0) = temp; + Vd->D(1) = 0; +} + +static uint64_t do_vmskltz_d(int64_t val) +{ + return (uint64_t)val >> 63; +} +void HELPER(vmskltz_d)(CPULoongArchState *env, uint32_t vd, uint32_t vj) +{ + uint16_t temp = 0; + VReg *Vd = &(env->fpr[vd].vreg); + VReg *Vj = &(env->fpr[vj].vreg); + + temp = do_vmskltz_d(Vj->D(0)); + temp |= (do_vmskltz_d(Vj->D(1)) << 1); + Vd->D(0) = temp; + Vd->D(1) = 0; +} + +void HELPER(vmskgez_b)(CPULoongArchState *env, uint32_t vd, uint32_t vj) +{ + uint16_t temp = 0; + VReg *Vd = &(env->fpr[vd].vreg); + VReg *Vj = &(env->fpr[vj].vreg); + + temp = do_vmskltz_b(Vj->D(0)); + temp |= (do_vmskltz_b(Vj->D(1)) << 8); + Vd->D(0) = (uint16_t)(~temp); + Vd->D(1) = 0; +} + +static uint64_t do_vmskez_b(uint64_t a) +{ + uint64_t m = 0x7f7f7f7f7f7f7f7fULL; + uint64_t c = ~(((a & m) + m) | a | m); + c |= c << 7; + c |= c << 14; + c |= c << 28; + return c >> 56; +} + +void HELPER(vmsknz_b)(CPULoongArchState *env, uint32_t vd, uint32_t vj) +{ + uint16_t temp = 0; + VReg *Vd = &(env->fpr[vd].vreg); + VReg *Vj = &(env->fpr[vj].vreg); + + temp = do_vmskez_b(Vj->D(0)); + temp |= (do_vmskez_b(Vj->D(1)) << 8); + Vd->D(0) = (uint16_t)(~temp); + Vd->D(1) = 0; +} -- 2.31.1