The instructions have the same function as RVV1.0. Overall there are only general differences between XTheadVector and RVV1.0.
Signed-off-by: Huang Tao <eric.hu...@linux.alibaba.com> --- target/riscv/helper.h | 33 +++++++++ .../riscv/insn_trans/trans_xtheadvector.c.inc | 18 ++--- target/riscv/xtheadvector_helper.c | 67 +++++++++++++++++++ 3 files changed, 110 insertions(+), 8 deletions(-) diff --git a/target/riscv/helper.h b/target/riscv/helper.h index 8f2dec158b..f3e4ab0f1f 100644 --- a/target/riscv/helper.h +++ b/target/riscv/helper.h @@ -1695,3 +1695,36 @@ DEF_HELPER_6(th_vmsgt_vx_b, void, ptr, ptr, tl, ptr, env, i32) DEF_HELPER_6(th_vmsgt_vx_h, void, ptr, ptr, tl, ptr, env, i32) DEF_HELPER_6(th_vmsgt_vx_w, void, ptr, ptr, tl, ptr, env, i32) DEF_HELPER_6(th_vmsgt_vx_d, void, ptr, ptr, tl, ptr, env, i32) + +DEF_HELPER_6(th_vminu_vv_b, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(th_vminu_vv_h, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(th_vminu_vv_w, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(th_vminu_vv_d, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(th_vmin_vv_b, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(th_vmin_vv_h, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(th_vmin_vv_w, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(th_vmin_vv_d, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(th_vmaxu_vv_b, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(th_vmaxu_vv_h, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(th_vmaxu_vv_w, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(th_vmaxu_vv_d, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(th_vmax_vv_b, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(th_vmax_vv_h, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(th_vmax_vv_w, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(th_vmax_vv_d, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(th_vminu_vx_b, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(th_vminu_vx_h, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(th_vminu_vx_w, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(th_vminu_vx_d, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(th_vmin_vx_b, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(th_vmin_vx_h, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(th_vmin_vx_w, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(th_vmin_vx_d, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(th_vmaxu_vx_b, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(th_vmaxu_vx_h, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(th_vmaxu_vx_w, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(th_vmaxu_vx_d, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(th_vmax_vx_b, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(th_vmax_vx_h, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(th_vmax_vx_w, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(th_vmax_vx_d, void, ptr, ptr, tl, ptr, env, i32) diff --git a/target/riscv/insn_trans/trans_xtheadvector.c.inc b/target/riscv/insn_trans/trans_xtheadvector.c.inc index 049d9da0a5..f19a771b61 100644 --- a/target/riscv/insn_trans/trans_xtheadvector.c.inc +++ b/target/riscv/insn_trans/trans_xtheadvector.c.inc @@ -1519,20 +1519,22 @@ GEN_OPIVI_TRANS_TH(th_vmsle_vi, IMM_SX, th_vmsle_vx, opivx_cmp_check_th) GEN_OPIVI_TRANS_TH(th_vmsgtu_vi, IMM_ZX, th_vmsgtu_vx, opivx_cmp_check_th) GEN_OPIVI_TRANS_TH(th_vmsgt_vi, IMM_SX, th_vmsgt_vx, opivx_cmp_check_th) +/* Vector Integer Min/Max Instructions */ +GEN_OPIVV_GVEC_TRANS_TH(th_vminu_vv, umin) +GEN_OPIVV_GVEC_TRANS_TH(th_vmin_vv, smin) +GEN_OPIVV_GVEC_TRANS_TH(th_vmaxu_vv, umax) +GEN_OPIVV_GVEC_TRANS_TH(th_vmax_vv, smax) +GEN_OPIVX_TRANS_TH(th_vminu_vx, opivx_check_th) +GEN_OPIVX_TRANS_TH(th_vmin_vx, opivx_check_th) +GEN_OPIVX_TRANS_TH(th_vmaxu_vx, opivx_check_th) +GEN_OPIVX_TRANS_TH(th_vmax_vx, opivx_check_th) + #define TH_TRANS_STUB(NAME) \ static bool trans_##NAME(DisasContext *s, arg_##NAME *a) \ { \ return require_xtheadvector(s); \ } -TH_TRANS_STUB(th_vminu_vv) -TH_TRANS_STUB(th_vminu_vx) -TH_TRANS_STUB(th_vmin_vv) -TH_TRANS_STUB(th_vmin_vx) -TH_TRANS_STUB(th_vmaxu_vv) -TH_TRANS_STUB(th_vmaxu_vx) -TH_TRANS_STUB(th_vmax_vv) -TH_TRANS_STUB(th_vmax_vx) TH_TRANS_STUB(th_vmul_vv) TH_TRANS_STUB(th_vmul_vx) TH_TRANS_STUB(th_vmulh_vv) diff --git a/target/riscv/xtheadvector_helper.c b/target/riscv/xtheadvector_helper.c index 827650b325..da869e1069 100644 --- a/target/riscv/xtheadvector_helper.c +++ b/target/riscv/xtheadvector_helper.c @@ -1542,3 +1542,70 @@ GEN_TH_CMP_VX(th_vmsgt_vx_b, int8_t, H1, TH_MSGT) GEN_TH_CMP_VX(th_vmsgt_vx_h, int16_t, H2, TH_MSGT) GEN_TH_CMP_VX(th_vmsgt_vx_w, int32_t, H4, TH_MSGT) GEN_TH_CMP_VX(th_vmsgt_vx_d, int64_t, H8, TH_MSGT) + +/* Vector Integer Min/Max Instructions */ +THCALL(TH_OPIVV2, th_vminu_vv_b, OP_UUU_B, H1, H1, H1, TH_MIN) +THCALL(TH_OPIVV2, th_vminu_vv_h, OP_UUU_H, H2, H2, H2, TH_MIN) +THCALL(TH_OPIVV2, th_vminu_vv_w, OP_UUU_W, H4, H4, H4, TH_MIN) +THCALL(TH_OPIVV2, th_vminu_vv_d, OP_UUU_D, H8, H8, H8, TH_MIN) +THCALL(TH_OPIVV2, th_vmin_vv_b, OP_SSS_B, H1, H1, H1, TH_MIN) +THCALL(TH_OPIVV2, th_vmin_vv_h, OP_SSS_H, H2, H2, H2, TH_MIN) +THCALL(TH_OPIVV2, th_vmin_vv_w, OP_SSS_W, H4, H4, H4, TH_MIN) +THCALL(TH_OPIVV2, th_vmin_vv_d, OP_SSS_D, H8, H8, H8, TH_MIN) +THCALL(TH_OPIVV2, th_vmaxu_vv_b, OP_UUU_B, H1, H1, H1, TH_MAX) +THCALL(TH_OPIVV2, th_vmaxu_vv_h, OP_UUU_H, H2, H2, H2, TH_MAX) +THCALL(TH_OPIVV2, th_vmaxu_vv_w, OP_UUU_W, H4, H4, H4, TH_MAX) +THCALL(TH_OPIVV2, th_vmaxu_vv_d, OP_UUU_D, H8, H8, H8, TH_MAX) +THCALL(TH_OPIVV2, th_vmax_vv_b, OP_SSS_B, H1, H1, H1, TH_MAX) +THCALL(TH_OPIVV2, th_vmax_vv_h, OP_SSS_H, H2, H2, H2, TH_MAX) +THCALL(TH_OPIVV2, th_vmax_vv_w, OP_SSS_W, H4, H4, H4, TH_MAX) +THCALL(TH_OPIVV2, th_vmax_vv_d, OP_SSS_D, H8, H8, H8, TH_MAX) +GEN_TH_VV(th_vminu_vv_b, 1, 1, clearb_th) +GEN_TH_VV(th_vminu_vv_h, 2, 2, clearh_th) +GEN_TH_VV(th_vminu_vv_w, 4, 4, clearl_th) +GEN_TH_VV(th_vminu_vv_d, 8, 8, clearq_th) +GEN_TH_VV(th_vmin_vv_b, 1, 1, clearb_th) +GEN_TH_VV(th_vmin_vv_h, 2, 2, clearh_th) +GEN_TH_VV(th_vmin_vv_w, 4, 4, clearl_th) +GEN_TH_VV(th_vmin_vv_d, 8, 8, clearq_th) +GEN_TH_VV(th_vmaxu_vv_b, 1, 1, clearb_th) +GEN_TH_VV(th_vmaxu_vv_h, 2, 2, clearh_th) +GEN_TH_VV(th_vmaxu_vv_w, 4, 4, clearl_th) +GEN_TH_VV(th_vmaxu_vv_d, 8, 8, clearq_th) +GEN_TH_VV(th_vmax_vv_b, 1, 1, clearb_th) +GEN_TH_VV(th_vmax_vv_h, 2, 2, clearh_th) +GEN_TH_VV(th_vmax_vv_w, 4, 4, clearl_th) +GEN_TH_VV(th_vmax_vv_d, 8, 8, clearq_th) + +THCALL(TH_OPIVX2, th_vminu_vx_b, OP_UUU_B, H1, H1, TH_MIN) +THCALL(TH_OPIVX2, th_vminu_vx_h, OP_UUU_H, H2, H2, TH_MIN) +THCALL(TH_OPIVX2, th_vminu_vx_w, OP_UUU_W, H4, H4, TH_MIN) +THCALL(TH_OPIVX2, th_vminu_vx_d, OP_UUU_D, H8, H8, TH_MIN) +THCALL(TH_OPIVX2, th_vmin_vx_b, OP_SSS_B, H1, H1, TH_MIN) +THCALL(TH_OPIVX2, th_vmin_vx_h, OP_SSS_H, H2, H2, TH_MIN) +THCALL(TH_OPIVX2, th_vmin_vx_w, OP_SSS_W, H4, H4, TH_MIN) +THCALL(TH_OPIVX2, th_vmin_vx_d, OP_SSS_D, H8, H8, TH_MIN) +THCALL(TH_OPIVX2, th_vmaxu_vx_b, OP_UUU_B, H1, H1, TH_MAX) +THCALL(TH_OPIVX2, th_vmaxu_vx_h, OP_UUU_H, H2, H2, TH_MAX) +THCALL(TH_OPIVX2, th_vmaxu_vx_w, OP_UUU_W, H4, H4, TH_MAX) +THCALL(TH_OPIVX2, th_vmaxu_vx_d, OP_UUU_D, H8, H8, TH_MAX) +THCALL(TH_OPIVX2, th_vmax_vx_b, OP_SSS_B, H1, H1, TH_MAX) +THCALL(TH_OPIVX2, th_vmax_vx_h, OP_SSS_H, H2, H2, TH_MAX) +THCALL(TH_OPIVX2, th_vmax_vx_w, OP_SSS_W, H4, H4, TH_MAX) +THCALL(TH_OPIVX2, th_vmax_vx_d, OP_SSS_D, H8, H8, TH_MAX) +GEN_TH_VX(th_vminu_vx_b, 1, 1, clearb_th) +GEN_TH_VX(th_vminu_vx_h, 2, 2, clearh_th) +GEN_TH_VX(th_vminu_vx_w, 4, 4, clearl_th) +GEN_TH_VX(th_vminu_vx_d, 8, 8, clearq_th) +GEN_TH_VX(th_vmin_vx_b, 1, 1, clearb_th) +GEN_TH_VX(th_vmin_vx_h, 2, 2, clearh_th) +GEN_TH_VX(th_vmin_vx_w, 4, 4, clearl_th) +GEN_TH_VX(th_vmin_vx_d, 8, 8, clearq_th) +GEN_TH_VX(th_vmaxu_vx_b, 1, 1, clearb_th) +GEN_TH_VX(th_vmaxu_vx_h, 2, 2, clearh_th) +GEN_TH_VX(th_vmaxu_vx_w, 4, 4, clearl_th) +GEN_TH_VX(th_vmaxu_vx_d, 8, 8, clearq_th) +GEN_TH_VX(th_vmax_vx_b, 1, 1, clearb_th) +GEN_TH_VX(th_vmax_vx_h, 2, 2, clearh_th) +GEN_TH_VX(th_vmax_vx_w, 4, 4, clearl_th) +GEN_TH_VX(th_vmax_vx_d, 8, 8, clearq_th) -- 2.44.0