From 68e35a2b75eaf1a55a83bb0b102aeb017ab44e06 Mon Sep 17 00:00:00 2001 From: Song Gao Date: Fri, 30 Sep 2022 10:45:08 +0800 Subject: [PATCH] target/loongarch: bstrins.w src register need EXT_NONE use gen_bstrins/gen_bstrpic to replace gen_rr_ms_ls. Suggested-by: Richard Henderson Signed-off-by: Song Gao Reviewed-by: Richard Henderson Message-Id: <20220930024510.800005-2-gaosong@loongson.cn> --- target/loongarch/insn_trans/trans_bit.c.inc | 40 ++++++++++++--------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/target/loongarch/insn_trans/trans_bit.c.inc b/target/loongarch/insn_trans/trans_bit.c.inc index 9337714ec4..b01e4aeb23 100644 --- a/target/loongarch/insn_trans/trans_bit.c.inc +++ b/target/loongarch/insn_trans/trans_bit.c.inc @@ -27,26 +27,34 @@ static void gen_bytepick_d(TCGv dest, TCGv src1, TCGv src2, target_long sa) tcg_gen_extract2_i64(dest, src1, src2, (64 - sa * 8)); } -static void gen_bstrins(TCGv dest, TCGv src1, - unsigned int ls, unsigned int len) +static bool gen_bstrins(DisasContext *ctx, arg_rr_ms_ls *a, + DisasExtend dst_ext) { - tcg_gen_deposit_tl(dest, dest, src1, ls, len); -} - -static bool gen_rr_ms_ls(DisasContext *ctx, arg_rr_ms_ls *a, - DisasExtend src_ext, DisasExtend dst_ext, - void (*func)(TCGv, TCGv, unsigned int, unsigned int)) -{ - TCGv dest = gpr_dst(ctx, a->rd, dst_ext); - TCGv src1 = gpr_src(ctx, a->rj, src_ext); + TCGv src1 = gpr_src(ctx, a->rd, EXT_NONE); + TCGv src2 = gpr_src(ctx, a->rj, EXT_NONE); + TCGv dest = gpr_dst(ctx, a->rd, EXT_NONE); if (a->ls > a->ms) { return false; } - func(dest, src1, a->ls, a->ms - a->ls + 1); + tcg_gen_deposit_tl(dest, src1, src2, a->ls, a->ms - a->ls + 1); gen_set_gpr(a->rd, dest, dst_ext); + return true; +} +static bool gen_bstrpick(DisasContext *ctx, arg_rr_ms_ls *a, + DisasExtend dst_ext) +{ + TCGv dest = gpr_dst(ctx, a->rd, EXT_NONE); + TCGv src1 = gpr_src(ctx, a->rj, EXT_NONE); + + if (a->ls > a->ms) { + return false; + } + + tcg_gen_extract_tl(dest, src1, a->ls, a->ms - a->ls + 1); + gen_set_gpr(a->rd, dest, dst_ext); return true; } @@ -206,7 +214,7 @@ TRANS(maskeqz, gen_rrr, EXT_NONE, EXT_NONE, EXT_NONE, gen_maskeqz) TRANS(masknez, gen_rrr, EXT_NONE, EXT_NONE, EXT_NONE, gen_masknez) TRANS(bytepick_w, gen_rrr_sa, EXT_NONE, EXT_NONE, gen_bytepick_w) TRANS(bytepick_d, gen_rrr_sa, EXT_NONE, EXT_NONE, gen_bytepick_d) -TRANS(bstrins_w, gen_rr_ms_ls, EXT_NONE, EXT_NONE, gen_bstrins) -TRANS(bstrins_d, gen_rr_ms_ls, EXT_NONE, EXT_NONE, gen_bstrins) -TRANS(bstrpick_w, gen_rr_ms_ls, EXT_NONE, EXT_SIGN, tcg_gen_extract_tl) -TRANS(bstrpick_d, gen_rr_ms_ls, EXT_NONE, EXT_NONE, tcg_gen_extract_tl) +TRANS(bstrins_w, gen_bstrins, EXT_SIGN) +TRANS(bstrins_d, gen_bstrins, EXT_NONE) +TRANS(bstrpick_w, gen_bstrpick, EXT_SIGN) +TRANS(bstrpick_d, gen_bstrpick, EXT_NONE)