Message ID | 20241226-la32-fixes1-v2-13-0414594f8cb5@flygoat.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | target/loongarch: LoongArch32 fixes 1 | expand |
On 12/26/24 13:19, Jiaxun Yang wrote: > Use TCGv_i64 for intermediate values and perform truncation as necessary. > > Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com> > --- > target/loongarch/tcg/insn_trans/trans_extra.c.inc | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/target/loongarch/tcg/insn_trans/trans_extra.c.inc b/target/loongarch/tcg/insn_trans/trans_extra.c.inc > index cfa361fecfa9ba569034b2c591b910ae7a3c6427..f9fb828ce51f2ee925edde7330d3054da534ecb3 100644 > --- a/target/loongarch/tcg/insn_trans/trans_extra.c.inc > +++ b/target/loongarch/tcg/insn_trans/trans_extra.c.inc > @@ -46,13 +46,15 @@ static bool gen_rdtime(DisasContext *ctx, arg_rr *a, > { > TCGv dst1 = gpr_dst(ctx, a->rd, EXT_NONE); > TCGv dst2 = gpr_dst(ctx, a->rj, EXT_NONE); > + TCGv_i64 val = tcg_temp_new_i64(); > > translator_io_start(&ctx->base); > - gen_helper_rdtime_d(dst1, tcg_env); > + gen_helper_rdtime_d(val, tcg_env); > if (word) { > - tcg_gen_sextract_tl(dst1, dst1, high ? 32 : 0, 32); > + tcg_gen_sextract_i64(val, val, high ? 32 : 0, 32); > + tcg_gen_trunc_i64_tl(dst1, val); > } If !word, you are no longer assigning to dst1. The trunc must be moved below if (word). r~
diff --git a/target/loongarch/tcg/insn_trans/trans_extra.c.inc b/target/loongarch/tcg/insn_trans/trans_extra.c.inc index cfa361fecfa9ba569034b2c591b910ae7a3c6427..f9fb828ce51f2ee925edde7330d3054da534ecb3 100644 --- a/target/loongarch/tcg/insn_trans/trans_extra.c.inc +++ b/target/loongarch/tcg/insn_trans/trans_extra.c.inc @@ -46,13 +46,15 @@ static bool gen_rdtime(DisasContext *ctx, arg_rr *a, { TCGv dst1 = gpr_dst(ctx, a->rd, EXT_NONE); TCGv dst2 = gpr_dst(ctx, a->rj, EXT_NONE); + TCGv_i64 val = tcg_temp_new_i64(); translator_io_start(&ctx->base); - gen_helper_rdtime_d(dst1, tcg_env); + gen_helper_rdtime_d(val, tcg_env); if (word) { - tcg_gen_sextract_tl(dst1, dst1, high ? 32 : 0, 32); + tcg_gen_sextract_i64(val, val, high ? 32 : 0, 32); + tcg_gen_trunc_i64_tl(dst1, val); } - tcg_gen_ld_i64(dst2, tcg_env, offsetof(CPULoongArchState, CSR_TID)); + tcg_gen_ld_tl(dst2, tcg_env, offsetof(CPULoongArchState, CSR_TID)); return true; }
Use TCGv_i64 for intermediate values and perform truncation as necessary. Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com> --- target/loongarch/tcg/insn_trans/trans_extra.c.inc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)