Signed-off-by: Taylor Simpson <[email protected]>
---
target/hexagon/translate.h | 11 +++++++++--
target/hexagon/translate.c | 8 ++++++++
2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/target/hexagon/translate.h b/target/hexagon/translate.h
index b6cdf51c20..eb0d10d686 100644
--- a/target/hexagon/translate.h
+++ b/target/hexagon/translate.h
@@ -47,6 +47,8 @@ typedef struct DisasContext {
#ifndef CONFIG_USER_ONLY
int greg_log[GREG_WRITES_MAX];
int greg_log_idx;
+ DECLARE_BITMAP(gregs_written, NUM_GREGS);
+ DECLARE_BITMAP(gregs_multi_write, NUM_GREGS);
int sreg_log[SREG_WRITES_MAX];
int sreg_log_idx;
TCGv_i32 t_sreg_new_value[HEX_SREG_GLB_START];
@@ -105,8 +107,13 @@ static inline void ctx_log_greg_write(DisasContext *ctx,
int rnum)
if (rnum > HEX_GREG_G3) {
return;
}
- ctx->greg_log[ctx->greg_log_idx] = rnum;
- ctx->greg_log_idx++;
+ if (!test_bit(rnum, ctx->gregs_written)) {
+ set_bit(rnum, ctx->gregs_written);
+ ctx->greg_log[ctx->greg_log_idx] = rnum;
+ ctx->greg_log_idx++;
+ } else {
+ set_bit(rnum, ctx->gregs_multi_write);
+ }
}
static inline void ctx_log_greg_write_pair(DisasContext *ctx, int rnum)
diff --git a/target/hexagon/translate.c b/target/hexagon/translate.c
index 815eecb60a..f469452daa 100644
--- a/target/hexagon/translate.c
+++ b/target/hexagon/translate.c
@@ -575,6 +575,8 @@ static void clear_pkt_ctx(DisasContext *ctx)
bitmap_zero(ctx->predicated_regs, TOTAL_PER_THREAD_REGS);
#ifndef CONFIG_USER_ONLY
ctx->greg_log_idx = 0;
+ bitmap_zero(ctx->gregs_written, NUM_GREGS);
+ bitmap_zero(ctx->qregs_multi_write, NUM_GREGS);
ctx->sreg_log_idx = 0;
#endif
bitmap_zero(ctx->gpr_multi_write, TOTAL_PER_THREAD_REGS);
@@ -629,6 +631,12 @@ static bool pkt_has_write_conflict(DisasContext *ctx)
return true;
}
+#ifndef CONFIG_USER_ONLY
+ if (!bitmap_empty(ctx->gregs_multi_write, NUM_GREGS)) {
+ return true;
+ }
+#endif
+
return false;
}
--
2.43.0