From: Taylor Simpson <[email protected]>

Signed-off-by: Taylor Simpson <[email protected]>
Reviewed-by: Marco Liebel <[email protected]>
Reviewed-by: Brian Cain <[email protected]>
Signed-off-by: Brian Cain <[email protected]>
---
 target/hexagon/translate.h | 11 +++++++++--
 target/hexagon/translate.c |  6 ++++++
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/target/hexagon/translate.h b/target/hexagon/translate.h
index eb0d10d686c..b90f7fff1c1 100644
--- a/target/hexagon/translate.h
+++ b/target/hexagon/translate.h
@@ -51,6 +51,8 @@ typedef struct DisasContext {
     DECLARE_BITMAP(gregs_multi_write, NUM_GREGS);
     int sreg_log[SREG_WRITES_MAX];
     int sreg_log_idx;
+    DECLARE_BITMAP(sregs_written, NUM_SREGS);
+    DECLARE_BITMAP(sregs_multi_write, NUM_SREGS);
     TCGv_i32 t_sreg_new_value[HEX_SREG_GLB_START];
     TCGv_i32 greg_new_value[NUM_GREGS];
 #endif
@@ -125,8 +127,13 @@ static inline void ctx_log_greg_write_pair(DisasContext 
*ctx, int rnum)
 
 static inline void ctx_log_sreg_write(DisasContext *ctx, int rnum)
 {
-    ctx->sreg_log[ctx->sreg_log_idx] = rnum;
-    ctx->sreg_log_idx++;
+    if (!test_bit(rnum, ctx->sregs_written)) {
+        set_bit(rnum, ctx->sregs_written);
+        ctx->sreg_log[ctx->sreg_log_idx] = rnum;
+        ctx->sreg_log_idx++;
+    } else {
+        set_bit(rnum, ctx->sregs_multi_write);
+    }
 }
 
 static inline void ctx_log_sreg_write_pair(DisasContext *ctx, int rnum)
diff --git a/target/hexagon/translate.c b/target/hexagon/translate.c
index bcc4a6e6eff..81f8895e47b 100644
--- a/target/hexagon/translate.c
+++ b/target/hexagon/translate.c
@@ -580,6 +580,8 @@ static void clear_pkt_ctx(DisasContext *ctx)
     bitmap_zero(ctx->gregs_written, NUM_GREGS);
     bitmap_zero(ctx->gregs_multi_write, NUM_GREGS);
     ctx->sreg_log_idx = 0;
+    bitmap_zero(ctx->sregs_written, NUM_SREGS);
+    bitmap_zero(ctx->sregs_multi_write, NUM_SREGS);
 #endif
     bitmap_zero(ctx->gpr_multi_write, TOTAL_PER_THREAD_REGS);
     bitmap_zero(ctx->gpr_uncond, TOTAL_PER_THREAD_REGS);
@@ -637,6 +639,10 @@ static bool pkt_has_write_conflict(DisasContext *ctx)
     if (!bitmap_empty(ctx->gregs_multi_write, NUM_GREGS)) {
         return true;
     }
+
+    if (!bitmap_empty(ctx->sregs_multi_write, NUM_SREGS)) {
+        return true;
+    }
 #endif
 
     return false;
-- 
2.34.1

Reply via email to