Skip to content

Commit

Permalink
Fix tracking of LC0
Browse files Browse the repository at this point in the history
  • Loading branch information
Rot127 committed Nov 28, 2023
1 parent 090825c commit ebff01c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 17 deletions.
20 changes: 4 additions & 16 deletions target/hexagon/genptr.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ void gen_log_reg_write(DisasContext *ctx, int rnum, TCGv val)
tcg_gen_movi_tl(hex_reg_written[rnum], 1);
}
if (rnum != HEX_REG_PC) {
if (ctx->need_commit) {
if (ctx->need_commit && rnum != HEX_REG_LC0) {
gen_helper_trace_store_reg_new(tcg_constant_i32(rnum), val);
} else {
gen_helper_trace_store_reg(tcg_constant_i32(rnum), val);
Expand Down Expand Up @@ -955,11 +955,7 @@ static void gen_endloop1(DisasContext *ctx)
TCGv lc1 = get_result_gpr(ctx, HEX_REG_LC1);
gen_jumpr(ctx, hex_gpr[HEX_REG_SA1]);
tcg_gen_subi_tl(lc1, hex_gpr[HEX_REG_LC1], 1);
if (ctx->need_commit) {
gen_helper_trace_store_reg_new(tcg_constant_i32(HEX_REG_LC1), lc1);
} else {
gen_helper_trace_store_reg(tcg_constant_i32(HEX_REG_LC1), lc1);
}
gen_helper_trace_store_reg(tcg_constant_i32(HEX_REG_LC1), lc1);
}
gen_set_label(label);
}
Expand Down Expand Up @@ -1011,11 +1007,7 @@ static void gen_endloop01(DisasContext *ctx)
TCGv lc0 = get_result_gpr(ctx, HEX_REG_LC0);
gen_jumpr(ctx, hex_gpr[HEX_REG_SA0]);
tcg_gen_subi_tl(lc0, hex_gpr[HEX_REG_LC0], 1);
if (ctx->need_commit) {
gen_helper_trace_store_reg_new(tcg_constant_i32(HEX_REG_LC0), lc0);
} else {
gen_helper_trace_store_reg(tcg_constant_i32(HEX_REG_LC0), lc0);
}
gen_helper_trace_store_reg(tcg_constant_i32(HEX_REG_LC0), lc0);
tcg_gen_br(done);
}
gen_set_label(label3);
Expand All @@ -1024,11 +1016,7 @@ static void gen_endloop01(DisasContext *ctx)
TCGv lc1 = get_result_gpr(ctx, HEX_REG_LC1);
gen_jumpr(ctx, hex_gpr[HEX_REG_SA1]);
tcg_gen_subi_tl(lc1, hex_gpr[HEX_REG_LC1], 1);
if (ctx->need_commit) {
gen_helper_trace_store_reg_new(tcg_constant_i32(HEX_REG_LC1), lc1);
} else {
gen_helper_trace_store_reg(tcg_constant_i32(HEX_REG_LC1), lc1);
}
gen_helper_trace_store_reg(tcg_constant_i32(HEX_REG_LC1), lc1);
}
gen_set_label(done);
}
Expand Down
5 changes: 4 additions & 1 deletion target/hexagon/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -687,8 +687,11 @@ static void gen_reg_writes(DisasContext *ctx)
int reg_num = ctx->reg_log[i];

tcg_gen_mov_tl(hex_gpr[reg_num], get_result_gpr(ctx, reg_num));
if (reg_num != HEX_REG_PC) {
if (reg_num != HEX_REG_PC && reg_num != HEX_REG_LC0) {
// PC writes are not tracked.
// LC0 is never tracked, because at this point it doesn't necessarily
// hold the correct value.
// Due to direct blocck chaining, it might hold the not decremented value.
gen_helper_trace_store_reg(tcg_constant_i32(reg_num), hex_gpr[reg_num]);
}

Expand Down

0 comments on commit ebff01c

Please sign in to comment.