Skip to contentSkip to conversation

Hexagon (target/hexagon) Check for multiwrites in analyze_packet

PATCH In review Taylor Simpson 3 participants 21 messages Sep 14 – Sep 15 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

v3 cover Hexagon (target/hexagon) Check for multiwrites in analyze_packet

Currently, we check for register multiwrites during packet decode. The downside of this approach is that it only checks a single destination register for each instruction. During analyze_packet, we can check for more than one write per instruction. Further, we can check for different types of registers. This series adds checks for HVX v-registers and q-registers.

Note that multiple writes to a predicate register are allowed on Hexagon.

Changes in v2
- Rebase against latest sources, including Hexagon system mode
- Add checks for multiple writes to system registers

Changes in v3
- Address feedback from Brian Cain <[email protected]> Fix check-functional failures
Typo in commit comment
- Address feedback from Marco Liebel <[email protected]> Add test for mixed predicated/unconditional writes to vreg

Taylor Simpson (10):
Hexagon (target/hexagon) Move code out of gen_start_packet Hexagon (target/hexagon) Check for GPR multiwrite in analyze_packet Hexagon (tests/tcg/hexagon) Add tests for multi-destination
instructions
Hexagon (target/hexagon) Check for vreg multiwrite in analyze_packet Hexagon (tests/tcg/hexagon) Add tests for vreg multiple writes Hexagon (target/hexagon) Check for qreg multiwrite in analyze_packet Hexagon (tests/tcg/hexagon) Add tests for qreg multiple writes Hexagon (target/hexagon) Check for greg multiwrite in analyze_packet Hexagon (target/hexagon) Check for sreg multiwrite in analyze_packet Hexagon (target/hexagon) Remove old way of detecting register
multiwrites

 target/hexagon/insn.h               |   4 -
 target/hexagon/translate.h          |  47 +++++++--
 target/hexagon/decode.c             |  54 ----------
 target/hexagon/translate.c          |  90 +++++++++++++----
 tests/tcg/hexagon/multiple-writes.c | 149 ++++++++++++++++++++++++++++
 target/hexagon/gen_trans_funcs.py   |  10 --
 tests/tcg/hexagon/meson.build       |   2 +-
 7 files changed, 261 insertions(+), 95 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH v3 1/10 Hexagon (target/hexagon) Move code out of gen_start_packet

Move clear_pkt_ctx and analyze_packet out of gen_start_packet Precursor to adding packet validity checks to analyze_packet

---
 target/hexagon/translate.c | 45 ++++++++++++++++++++++----------------
 1 file changed, 26 insertions(+), 19 deletions(-)
target/hexagon/translate.c +26 -19
index 5d3d67e5d3..52dd1f0266 100644
@@ -562,28 +562,13 @@ static void mark_implicit_writes(DisasContext *ctx)
     mark_implicit_pred_writes(ctx);
 }
 
-static void analyze_packet(DisasContext *ctx)
-{
-    ctx->read_after_write = false;
-    ctx->has_hvx_overlap = false;
-    for (int i = 0; i < ctx->pkt.num_insns; i++) {
-        Insn *insn = &ctx->pkt.insn[i];
-        ctx->insn = insn;
-        if (opcode_analyze[insn->opcode]) {
-            opcode_analyze[insn->opcode](ctx);
-        }
-    }
-
-    ctx->need_commit = need_commit(ctx);
-}
-
-static void gen_start_packet(DisasContext *ctx)
+/* Clear out the disassembly context */
+static void clear_pkt_ctx(DisasContext *ctx)
 {
     Packet *pkt = &ctx->pkt;
     target_ulong next_PC = ctx->base.pc_next + pkt->encod_pkt_size_in_bytes;
     int i;
 
-    /* Clear out the disassembly context */
     ctx->next_PC = next_PC;
     ctx->reg_log_idx = 0;
     bitmap_zero(ctx->regs_written, TOTAL_PER_THREAD_REGS);
@@ -616,8 +601,26 @@ static void gen_start_packet(DisasContext *ctx)
     for (i = 0; i < NUM_PREGS; i++) {
         ctx->new_pred_value[i] = NULL;
     }
+}
 
-    analyze_packet(ctx);
+static void analyze_packet(DisasContext *ctx)
+{
+    ctx->read_after_write = false;
+    ctx->has_hvx_overlap = false;
+    for (int i = 0; i < ctx->pkt.num_insns; i++) {
+        Insn *insn = &ctx->pkt.insn[i];
+        ctx->insn = insn;
+        if (opcode_analyze[insn->opcode]) {
+            opcode_analyze[insn->opcode](ctx);
+        }
+    }
+
+    ctx->need_commit = need_commit(ctx);
+}
+
+static void gen_start_packet(DisasContext *ctx)
+{
+    int i;
 
     /*
      * pregs_written is used both in the analyze phase as well as the code
@@ -659,7 +662,7 @@ static void gen_start_packet(DisasContext *ctx)
     ctx->pkt_ends_tb = pkt_ends_tb(&ctx->pkt);
     ctx->need_next_pc = need_next_PC(ctx);
     if (ctx->need_next_pc) {
-        tcg_gen_movi_tl(hex_next_PC, next_PC);
+        tcg_gen_movi_tl(hex_next_PC, ctx->next_PC);
     }
 
     /* Preload the predicated registers into get_result_gpr(ctx, i) */
@@ -1199,6 +1202,10 @@ static void decode_and_translate_packet(CPUHexagonState *env, DisasContext *ctx)
     words_read = decode_packet(ctx, nwords, words, &ctx->pkt, false);
     if (words_read > 0) {
         ctx->pkt.pc = ctx->base.pc_next;
+
+        clear_pkt_ctx(ctx);
+        analyze_packet(ctx);
+
         if (ctx->pkt.pkt_has_write_conflict) {
             gen_exception_decode_fail(ctx, words_read,
                                       HEX_CAUSE_REG_WRITE_CONFLICT);
Signature · 1 line
2.43.0
#2 lore raw

PATCH v3 2/10 Hexagon (target/hexagon) Check for GPR multiwrite in analyze_packet

In reply to Taylor Simpson

For now, assert the new method is a superset of the old method We'll remove the old method in a subsequent patch

---
 target/hexagon/translate.h |  6 ++++++
 target/hexagon/translate.c | 23 ++++++++++++++++++++++-
 2 files changed, 28 insertions(+), 1 deletion(-)
target/hexagon/translate.h +6 -0
index d8628383f1..964e6ce0b7 100644
@@ -41,6 +41,8 @@ typedef struct DisasContext {
     DECLARE_BITMAP(regs_written, TOTAL_PER_THREAD_REGS);
     DECLARE_BITMAP(predicated_regs, TOTAL_PER_THREAD_REGS);
     bool pkt_ends_tb;
+    DECLARE_BITMAP(gpr_multi_write, TOTAL_PER_THREAD_REGS);
+    DECLARE_BITMAP(gpr_uncond, TOTAL_PER_THREAD_REGS);
     bool implicit_usr_write;
 #ifndef CONFIG_USER_ONLY
     int greg_log[GREG_WRITES_MAX];
@@ -157,9 +159,13 @@ static inline void ctx_log_reg_write(DisasContext *ctx, int rnum,
             ctx->reg_log[ctx->reg_log_idx] = rnum;
             ctx->reg_log_idx++;
             set_bit(rnum, ctx->regs_written);
+        } else {
+            set_bit(rnum, ctx->gpr_multi_write);
         }
         if (is_predicated) {
             set_bit(rnum, ctx->predicated_regs);
+        } else {
+            set_bit(rnum, ctx->gpr_uncond);
         }
     }
 }
target/hexagon/translate.c +22 -1
index 52dd1f0266..60441dc309 100644
@@ -577,6 +577,8 @@ static void clear_pkt_ctx(DisasContext *ctx)
     ctx->greg_log_idx = 0;
     ctx->sreg_log_idx = 0;
 #endif
+    bitmap_zero(ctx->gpr_multi_write, TOTAL_PER_THREAD_REGS);
+    bitmap_zero(ctx->gpr_uncond, TOTAL_PER_THREAD_REGS);
     ctx->preg_log_idx = 0;
     bitmap_zero(ctx->pregs_written, NUM_PREGS);
     ctx->future_vregs_idx = 0;
@@ -603,6 +605,19 @@ static void clear_pkt_ctx(DisasContext *ctx)
     }
 }
 
+static bool pkt_has_write_conflict(DisasContext *ctx)
+{
+    DECLARE_BITMAP(gpr_conflict, TOTAL_PER_THREAD_REGS);
+
+    bitmap_and(gpr_conflict, ctx->gpr_multi_write, ctx->gpr_uncond,
+               TOTAL_PER_THREAD_REGS);
+    if (!bitmap_empty(gpr_conflict, TOTAL_PER_THREAD_REGS)) {
+        return true;
+    }
+
+    return false;
+}
+
 static void analyze_packet(DisasContext *ctx)
 {
     ctx->read_after_write = false;
@@ -1206,7 +1221,13 @@ static void decode_and_translate_packet(CPUHexagonState *env, DisasContext *ctx)
         clear_pkt_ctx(ctx);
         analyze_packet(ctx);
 
-        if (ctx->pkt.pkt_has_write_conflict) {
+        /*
+         * Check that the new method is a superset of the old methond
+         * Remove in a later patch
+         */
+        g_assert(!ctx->pkt.pkt_has_write_conflict ||
+                 pkt_has_write_conflict(ctx));
+        if (pkt_has_write_conflict(ctx)) {
             gen_exception_decode_fail(ctx, words_read,
                                       HEX_CAUSE_REG_WRITE_CONFLICT);
             return;
Signature · 1 line
2.43.0
Reviewed-by on v3 2/10
#3 lore raw

Re: [PATCH v3 02/10] Hexagon (target/hexagon) Check for GPR multiwrite in analyze_packet

Quoted 6 lines · Taylor Simpson

For now, assert the new method is a superset of the old method We'll remove the old method in a subsequent patch

---

Quoted 79 lines
  target/hexagon/translate.h |  6 ++++++
  target/hexagon/translate.c | 23 ++++++++++++++++++++++-
  2 files changed, 28 insertions(+), 1 deletion(-)
target/hexagon/translate.h +6 -0
index d8628383f1..964e6ce0b7 100644
@@ -41,6 +41,8 @@ typedef struct DisasContext {
      DECLARE_BITMAP(regs_written, TOTAL_PER_THREAD_REGS);
      DECLARE_BITMAP(predicated_regs, TOTAL_PER_THREAD_REGS);
      bool pkt_ends_tb;
+    DECLARE_BITMAP(gpr_multi_write, TOTAL_PER_THREAD_REGS);
+    DECLARE_BITMAP(gpr_uncond, TOTAL_PER_THREAD_REGS);
      bool implicit_usr_write;
  #ifndef CONFIG_USER_ONLY
      int greg_log[GREG_WRITES_MAX];
@@ -157,9 +159,13 @@ static inline void ctx_log_reg_write(DisasContext *ctx, int rnum,
              ctx->reg_log[ctx->reg_log_idx] = rnum;
              ctx->reg_log_idx++;
              set_bit(rnum, ctx->regs_written);
+        } else {
+            set_bit(rnum, ctx->gpr_multi_write);
          }
          if (is_predicated) {
              set_bit(rnum, ctx->predicated_regs);
+        } else {
+            set_bit(rnum, ctx->gpr_uncond);
          }
      }
  }
target/hexagon/translate.c +22 -1
index 52dd1f0266..60441dc309 100644
@@ -577,6 +577,8 @@ static void clear_pkt_ctx(DisasContext *ctx)
      ctx->greg_log_idx = 0;
      ctx->sreg_log_idx = 0;
  #endif
+    bitmap_zero(ctx->gpr_multi_write, TOTAL_PER_THREAD_REGS);
+    bitmap_zero(ctx->gpr_uncond, TOTAL_PER_THREAD_REGS);
      ctx->preg_log_idx = 0;
      bitmap_zero(ctx->pregs_written, NUM_PREGS);
      ctx->future_vregs_idx = 0;
@@ -603,6 +605,19 @@ static void clear_pkt_ctx(DisasContext *ctx)
      }
  }
 
+static bool pkt_has_write_conflict(DisasContext *ctx)
+{
+    DECLARE_BITMAP(gpr_conflict, TOTAL_PER_THREAD_REGS);
+
+    bitmap_and(gpr_conflict, ctx->gpr_multi_write, ctx->gpr_uncond,
+               TOTAL_PER_THREAD_REGS);
+    if (!bitmap_empty(gpr_conflict, TOTAL_PER_THREAD_REGS)) {
+        return true;
+    }
+
+    return false;
+}
+
  static void analyze_packet(DisasContext *ctx)
  {
      ctx->read_after_write = false;
@@ -1206,7 +1221,13 @@ static void decode_and_translate_packet(CPUHexagonState *env, DisasContext *ctx)
          clear_pkt_ctx(ctx);
          analyze_packet(ctx);
 
-        if (ctx->pkt.pkt_has_write_conflict) {
+        /*
+         * Check that the new method is a superset of the old methond
+         * Remove in a later patch
+         */
+        g_assert(!ctx->pkt.pkt_has_write_conflict ||
+                 pkt_has_write_conflict(ctx));
+        if (pkt_has_write_conflict(ctx)) {
              gen_exception_decode_fail(ctx, words_read,
                                        HEX_CAUSE_REG_WRITE_CONFLICT);
              return;
#4 lore raw

PATCH v3 3/10 Hexagon (tests/tcg/hexagon) Add tests for multi-destination instructions

In reply to Taylor Simpson

Instructions such as post-increment loads define multiple destinations These make it harder to detect multi-write conflicts

---
 tests/tcg/hexagon/multiple-writes.c | 60 +++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)
tests/tcg/hexagon/multiple-writes.c +60 -0
index 8686317fdc..4305903547 100644
@@ -143,6 +143,62 @@ static int test_zero(void)
     return sig;
 }
 
+/* Test multiple post-increment writes to the same GPR */
+static int test_post_increment1(void)
+{
+    int sig;
+
+    asm volatile(
+        "r0 = #0\n"
+        "r1 = ##1f\n"
+        "memw(%1) = r1\n"
+        ".word 0x9b004021    /* {    r1 = memb(r0++#1)      */\n"
+        ".word 0x9b00c022    /*      r2 = memb(r0++#1) }    */\n"
+        "1:\n"
+        "%0 = r0\n"
+        : "=r"(sig)
+        : "r"(&resume_pc)
+        : "r0", "r1", "memory");
+
+    return sig;
+}
+
+static int test_post_increment2(void)
+{
+    int sig;
+
+    asm volatile(
+        "r0 = #0\n"
+        "r1 = ##1f\n"
+        "memw(%1) = r1\n"
+        ".word 0x9b00c020    /* r0 = memb(r0++#1) */\n"
+        "1:\n"
+        "%0 = r0\n"
+        : "=r"(sig)
+        : "r"(&resume_pc)
+        : "r0", "r1", "memory");
+
+    return sig;
+}
+
+static int test_post_increment3(void)
+{
+    int sig;
+
+    asm volatile(
+        "r0 = #0\n"
+        "r1 = ##1f\n"
+        "memw(%1) = r1\n"
+        ".word 0x9bc1c020    /* r1:0 = memd(r1++#8) */\n"
+        "1:\n"
+        "%0 = r0\n"
+        : "=r"(sig)
+        : "r"(&resume_pc)
+        : "r0", "r1", "memory");
+
+    return sig;
+}
+
 int main()
 {
     struct sigaction act;
@@ -164,6 +220,10 @@ int main()
     /* Illegal: zero encoding = duplex with duplicate dest R0 */
     assert(test_zero() == SIGILL);
 
+    assert(test_post_increment1() == SIGILL);
+    assert(test_post_increment2() == SIGILL);
+    assert(test_post_increment3() == SIGILL);
+
     puts("PASS");
     return EXIT_SUCCESS;
 }
Signature · 1 line
2.43.0
#5 lore raw

PATCH v3 4/10 Hexagon (target/hexagon) Check for vreg multiwrite in analyze_packet

In reply to Taylor Simpson
---
 target/hexagon/translate.h | 12 +++++++++++-
 target/hexagon/translate.c |  9 +++++++++
 2 files changed, 20 insertions(+), 1 deletion(-)
target/hexagon/translate.h +11 -1
index 964e6ce0b7..9ee5f25365 100644
@@ -70,6 +70,8 @@ typedef struct DisasContext {
     DECLARE_BITMAP(vregs_select, NUM_VREGS);
     DECLARE_BITMAP(predicated_future_vregs, NUM_VREGS);
     DECLARE_BITMAP(predicated_tmp_vregs, NUM_VREGS);
+    DECLARE_BITMAP(vregs_multi_write, NUM_VREGS);
+    DECLARE_BITMAP(vregs_uncond, NUM_VREGS);
     DECLARE_BITMAP(insn_vregs_read, NUM_VREGS);
     int qreg_log[NUM_QREGS];
     int qreg_log_idx;
@@ -218,7 +220,11 @@ static inline void ctx_log_vreg_write(DisasContext *ctx,
             ctx->has_hvx_overlap = true;
         }
     }
-    set_bit(rnum, ctx->vregs_written);
+    if (!test_bit(rnum, ctx->vregs_written)) {
+        set_bit(rnum, ctx->vregs_written);
+    } else {
+        set_bit(rnum, ctx->vregs_multi_write);
+    }
     if (type != EXT_TMP) {
         if (!test_bit(rnum, ctx->vregs_updated)) {
             ctx->vreg_log[ctx->vreg_log_idx] = rnum;
@@ -229,6 +235,8 @@ static inline void ctx_log_vreg_write(DisasContext *ctx,
         set_bit(rnum, ctx->vregs_updated);
         if (is_predicated) {
             set_bit(rnum, ctx->predicated_future_vregs);
+        } else {
+            set_bit(rnum, ctx->vregs_uncond);
         }
     }
     if (type == EXT_NEW) {
@@ -238,6 +246,8 @@ static inline void ctx_log_vreg_write(DisasContext *ctx,
         set_bit(rnum, ctx->vregs_updated_tmp);
         if (is_predicated) {
             set_bit(rnum, ctx->predicated_tmp_vregs);
+        } else {
+            set_bit(rnum, ctx->vregs_uncond);
         }
     }
 }
target/hexagon/translate.c +9 -0
index 60441dc309..ca22bae28f 100644
@@ -589,6 +589,8 @@ static void clear_pkt_ctx(DisasContext *ctx)
     bitmap_zero(ctx->vregs_updated, NUM_VREGS);
     bitmap_zero(ctx->vregs_select, NUM_VREGS);
     bitmap_zero(ctx->predicated_future_vregs, NUM_VREGS);
+    bitmap_zero(ctx->vregs_multi_write, NUM_VREGS);
+    bitmap_zero(ctx->vregs_uncond, NUM_VREGS);
     bitmap_zero(ctx->predicated_tmp_vregs, NUM_VREGS);
     bitmap_zero(ctx->qregs_written, NUM_QREGS);
     ctx->qreg_log_idx = 0;
@@ -608,6 +610,7 @@ static void clear_pkt_ctx(DisasContext *ctx)
 static bool pkt_has_write_conflict(DisasContext *ctx)
 {
     DECLARE_BITMAP(gpr_conflict, TOTAL_PER_THREAD_REGS);
+    DECLARE_BITMAP(vregs_conflict, NUM_VREGS);
 
     bitmap_and(gpr_conflict, ctx->gpr_multi_write, ctx->gpr_uncond,
                TOTAL_PER_THREAD_REGS);
@@ -615,6 +618,12 @@ static bool pkt_has_write_conflict(DisasContext *ctx)
         return true;
     }
 
+    bitmap_and(vregs_conflict, ctx->vregs_multi_write, ctx->vregs_uncond,
+               NUM_VREGS);
+    if (!bitmap_empty(vregs_conflict, NUM_VREGS)) {
+        return true;
+    }
+
     return false;
 }
 
Signature · 1 line
2.43.0
#6 lore raw

PATCH v3 5/10 Hexagon (tests/tcg/hexagon) Add tests for vreg multiple writes

In reply to Taylor Simpson
---
 tests/tcg/hexagon/multiple-writes.c | 66 +++++++++++++++++++++++++++++
 tests/tcg/hexagon/meson.build       |  2 +-
 2 files changed, 67 insertions(+), 1 deletion(-)
tests/tcg/hexagon/multiple-writes.c +66 -0
index 4305903547..62e5828a0a 100644
@@ -199,6 +199,68 @@ static int test_post_increment3(void)
     return sig;
 }
 
+static int test_vreg_legal_predicated(void)
+{
+    int sig;
+
+    asm volatile(
+        "r0 = #0\n"
+        "r1 = ##1f\n"
+        "memw(%1) = r1\n"
+        "r2 = #7\n"
+        "r3 = #13\n"
+        "p0 = cmp.eq(r2, r3)\n"
+        "{\n"
+        "    if (p0) v0 = v1\n"
+        "    if (!p0) v0 = v2\n"
+        "}\n"
+        "1:\n"
+        "%0 = #23\n"
+        : "=r"(sig)
+        : "r"(&resume_pc)
+        : "r0", "r1", "r2", "r3", "p0", "v0", "v1", "memory");
+
+    return sig;
+}
+
+static int test_vreg_illegal_mixed(void)
+{
+    int sig;
+
+    asm volatile(
+        "r0 = #0\n"
+        "r1 = ##1f\n"
+        "memw(%1) = r1\n"
+        ".word 0x1a004100    /* { if (p0) v0 = v1 */\n"
+        ".word 0x1e03e2e0    /*   v0 = v2  } */\n"
+        "1:\n"
+        "%0 = r0\n"
+        : "=r"(sig)
+        : "r"(&resume_pc)
+        : "r0", "r1", "memory");
+
+    return sig;
+}
+
+static int test_vreg_illegal_uncond(void)
+{
+    int sig;
+
+    asm volatile(
+        "r0 = #0\n"
+        "r1 = ##1f\n"
+        "memw(%1) = r1\n"
+        ".word 0x1e0361e0    /* { v0 = v1 */\n"
+        ".word 0x1e03e2e0    /*   v0 = v2  } */\n"
+        "1:\n"
+        "%0 = r0\n"
+        : "=r"(sig)
+        : "r"(&resume_pc)
+        : "r0", "r1", "memory");
+
+    return sig;
+}
+
 int main()
 {
     struct sigaction act;
@@ -224,6 +286,10 @@ int main()
     assert(test_post_increment2() == SIGILL);
     assert(test_post_increment3() == SIGILL);
 
+    assert(test_vreg_legal_predicated() == 23);
+    assert(test_vreg_illegal_mixed() == SIGILL);
+    assert(test_vreg_illegal_uncond() == SIGILL);
+
     puts("PASS");
     return EXIT_SUCCESS;
 }
tests/tcg/hexagon/meson.build +1 -1
index 4a2826c427..08c6e34c20 100644
@@ -54,7 +54,7 @@ tests += {
   'load_unpack.c': {'cflags': cflags},
   # Build this test with -mv71 to exercise the CABAC instruction
   'misc.c': {'cflags': [cflags, '-mv71', '-O2']},
-  'multiple-writes.c': {'cflags': cflags},
+  'multiple-writes.c': {'cflags': [cflags, '-mhvx']},
   'overflow.c': {'cflags': cflags, 'exe_name': 'hex-overflow'},
   'preg_alias.c': {'cflags': cflags},
   'dual_stores.c': {'cflags': cflags},
Signature · 1 line
2.43.0
Reviewed-by on v3 5/10
#7 lore raw

Re: [PATCH v3 05/10] Hexagon (tests/tcg/hexagon) Add tests for vreg multiple writes

Quoted 2 lines · Taylor Simpson

---

Quoted 101 lines
  tests/tcg/hexagon/multiple-writes.c | 66 +++++++++++++++++++++++++++++
  tests/tcg/hexagon/meson.build       |  2 +-
  2 files changed, 67 insertions(+), 1 deletion(-)
tests/tcg/hexagon/multiple-writes.c +66 -0
index 4305903547..62e5828a0a 100644
@@ -199,6 +199,68 @@ static int test_post_increment3(void)
      return sig;
  }
 
+static int test_vreg_legal_predicated(void)
+{
+    int sig;
+
+    asm volatile(
+        "r0 = #0\n"
+        "r1 = ##1f\n"
+        "memw(%1) = r1\n"
+        "r2 = #7\n"
+        "r3 = #13\n"
+        "p0 = cmp.eq(r2, r3)\n"
+        "{\n"
+        "    if (p0) v0 = v1\n"
+        "    if (!p0) v0 = v2\n"
+        "}\n"
+        "1:\n"
+        "%0 = #23\n"
+        : "=r"(sig)
+        : "r"(&resume_pc)
+        : "r0", "r1", "r2", "r3", "p0", "v0", "v1", "memory");
+
+    return sig;
+}
+
+static int test_vreg_illegal_mixed(void)
+{
+    int sig;
+
+    asm volatile(
+        "r0 = #0\n"
+        "r1 = ##1f\n"
+        "memw(%1) = r1\n"
+        ".word 0x1a004100    /* { if (p0) v0 = v1 */\n"
+        ".word 0x1e03e2e0    /*   v0 = v2  } */\n"
+        "1:\n"
+        "%0 = r0\n"
+        : "=r"(sig)
+        : "r"(&resume_pc)
+        : "r0", "r1", "memory");
+
+    return sig;
+}
+
+static int test_vreg_illegal_uncond(void)
+{
+    int sig;
+
+    asm volatile(
+        "r0 = #0\n"
+        "r1 = ##1f\n"
+        "memw(%1) = r1\n"
+        ".word 0x1e0361e0    /* { v0 = v1 */\n"
+        ".word 0x1e03e2e0    /*   v0 = v2  } */\n"
+        "1:\n"
+        "%0 = r0\n"
+        : "=r"(sig)
+        : "r"(&resume_pc)
+        : "r0", "r1", "memory");
+
+    return sig;
+}
+
  int main()
  {
      struct sigaction act;
@@ -224,6 +286,10 @@ int main()
      assert(test_post_increment2() == SIGILL);
      assert(test_post_increment3() == SIGILL);
 
+    assert(test_vreg_legal_predicated() == 23);
+    assert(test_vreg_illegal_mixed() == SIGILL);
+    assert(test_vreg_illegal_uncond() == SIGILL);
+
      puts("PASS");
      return EXIT_SUCCESS;
  }
tests/tcg/hexagon/meson.build +1 -1
index 4a2826c427..08c6e34c20 100644
@@ -54,7 +54,7 @@ tests += {
    'load_unpack.c': {'cflags': cflags},
    # Build this test with -mv71 to exercise the CABAC instruction
    'misc.c': {'cflags': [cflags, '-mv71', '-O2']},
-  'multiple-writes.c': {'cflags': cflags},
+  'multiple-writes.c': {'cflags': [cflags, '-mhvx']},
    'overflow.c': {'cflags': cflags, 'exe_name': 'hex-overflow'},
    'preg_alias.c': {'cflags': cflags},
    'dual_stores.c': {'cflags': cflags},
#9 lore raw

PATCH v3 6/10 Hexagon (target/hexagon) Check for qreg multiwrite in analyze_packet

In reply to Taylor Simpson
---
 target/hexagon/translate.h | 7 ++++++-
 target/hexagon/translate.c | 5 +++++
 2 files changed, 11 insertions(+), 1 deletion(-)
target/hexagon/translate.h +6 -1
index 9ee5f25365..b6cdf51c20 100644
@@ -76,6 +76,7 @@ typedef struct DisasContext {
     int qreg_log[NUM_QREGS];
     int qreg_log_idx;
     DECLARE_BITMAP(qregs_written, NUM_QREGS);
+    DECLARE_BITMAP(qregs_multi_write, NUM_QREGS);
     DECLARE_BITMAP(insn_qregs_written, NUM_QREGS);
     DECLARE_BITMAP(insn_qregs_read, NUM_QREGS);
     bool pre_commit;
@@ -308,7 +309,11 @@ static inline void ctx_log_qreg_write(DisasContext *ctx,
             ctx->has_hvx_overlap = true;
         }
     }
-    set_bit(rnum, ctx->qregs_written);
+    if (!test_bit(rnum, ctx->qregs_written)) {
+        set_bit(rnum, ctx->qregs_written);
+    } else {
+        set_bit(rnum, ctx->qregs_multi_write);
+    }
     ctx->qreg_log[ctx->qreg_log_idx] = rnum;
     ctx->qreg_log_idx++;
 }
target/hexagon/translate.c +5 -0
index ca22bae28f..815eecb60a 100644
@@ -593,6 +593,7 @@ static void clear_pkt_ctx(DisasContext *ctx)
     bitmap_zero(ctx->vregs_uncond, NUM_VREGS);
     bitmap_zero(ctx->predicated_tmp_vregs, NUM_VREGS);
     bitmap_zero(ctx->qregs_written, NUM_QREGS);
+    bitmap_zero(ctx->qregs_multi_write, NUM_QREGS);
     ctx->qreg_log_idx = 0;
     for (i = 0; i < STORES_MAX; i++) {
         ctx->store_width[i] = 0;
@@ -624,6 +625,10 @@ static bool pkt_has_write_conflict(DisasContext *ctx)
         return true;
     }
 
+    if (!bitmap_empty(ctx->qregs_multi_write, NUM_QREGS)) {
+        return true;
+    }
+
     return false;
 }
 
Signature · 1 line
2.43.0
Reviewed-by on v3 6/10
#10 lore raw

Re: [PATCH v3 06/10] Hexagon (target/hexagon) Check for qreg multiwrite in analyze_packet

Quoted 3 lines · Taylor Simpson

---

Quoted 52 lines
  target/hexagon/translate.h | 7 ++++++-
  target/hexagon/translate.c | 5 +++++
  2 files changed, 11 insertions(+), 1 deletion(-)
target/hexagon/translate.h +6 -1
index 9ee5f25365..b6cdf51c20 100644
@@ -76,6 +76,7 @@ typedef struct DisasContext {
      int qreg_log[NUM_QREGS];
      int qreg_log_idx;
      DECLARE_BITMAP(qregs_written, NUM_QREGS);
+    DECLARE_BITMAP(qregs_multi_write, NUM_QREGS);
      DECLARE_BITMAP(insn_qregs_written, NUM_QREGS);
      DECLARE_BITMAP(insn_qregs_read, NUM_QREGS);
      bool pre_commit;
@@ -308,7 +309,11 @@ static inline void ctx_log_qreg_write(DisasContext *ctx,
              ctx->has_hvx_overlap = true;
          }
      }
-    set_bit(rnum, ctx->qregs_written);
+    if (!test_bit(rnum, ctx->qregs_written)) {
+        set_bit(rnum, ctx->qregs_written);
+    } else {
+        set_bit(rnum, ctx->qregs_multi_write);
+    }
      ctx->qreg_log[ctx->qreg_log_idx] = rnum;
      ctx->qreg_log_idx++;
  }
target/hexagon/translate.c +5 -0
index ca22bae28f..815eecb60a 100644
@@ -593,6 +593,7 @@ static void clear_pkt_ctx(DisasContext *ctx)
      bitmap_zero(ctx->vregs_uncond, NUM_VREGS);
      bitmap_zero(ctx->predicated_tmp_vregs, NUM_VREGS);
      bitmap_zero(ctx->qregs_written, NUM_QREGS);
+    bitmap_zero(ctx->qregs_multi_write, NUM_QREGS);
      ctx->qreg_log_idx = 0;
      for (i = 0; i < STORES_MAX; i++) {
          ctx->store_width[i] = 0;
@@ -624,6 +625,10 @@ static bool pkt_has_write_conflict(DisasContext *ctx)
          return true;
      }
 
+    if (!bitmap_empty(ctx->qregs_multi_write, NUM_QREGS)) {
+        return true;
+    }
+
      return false;
  }
 
#11 lore raw

PATCH v3 7/10 Hexagon (tests/tcg/hexagon) Add tests for qreg multiple writes

In reply to Taylor Simpson
---
 tests/tcg/hexagon/multiple-writes.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
tests/tcg/hexagon/multiple-writes.c +23 -0
index 62e5828a0a..bd2b1384dd 100644
@@ -261,6 +261,27 @@ static int test_vreg_illegal_uncond(void)
     return sig;
 }
 
+static int test_qreg_illegal(void)
+{
+    int sig;
+
+    asm volatile(
+        "r0 = #0\n"
+        "r1 = ##1f\n"
+        "memw(%1) = r1\n"
+        "{\n"
+        ".word 0x19a14048    /* { q0 = vand(v0, r1) */\n"
+        ".word 0x19a0c044    /*   q0 = vsetq(r0) } */\n"
+        "}\n"
+        "1:\n"
+        "%0 = r0\n"
+        : "=r"(sig)
+        : "r"(&resume_pc)
+        : "r0", "r1", "memory");
+
+    return sig;
+}
+
 int main()
 {
     struct sigaction act;
@@ -290,6 +311,8 @@ int main()
     assert(test_vreg_illegal_mixed() == SIGILL);
     assert(test_vreg_illegal_uncond() == SIGILL);
 
+    assert(test_qreg_illegal() == SIGILL);
+
     puts("PASS");
     return EXIT_SUCCESS;
 }
Signature · 1 line
2.43.0
Reviewed-by on v3 7/10
#12 lore raw

Re: [PATCH v3 07/10] Hexagon (tests/tcg/hexagon) Add tests for qreg multiple writes

Quoted 3 lines · Taylor Simpson

---

Quoted 44 lines
  tests/tcg/hexagon/multiple-writes.c | 23 +++++++++++++++++++++++
  1 file changed, 23 insertions(+)
tests/tcg/hexagon/multiple-writes.c +23 -0
index 62e5828a0a..bd2b1384dd 100644
@@ -261,6 +261,27 @@ static int test_vreg_illegal_uncond(void)
      return sig;
  }
 
+static int test_qreg_illegal(void)
+{
+    int sig;
+
+    asm volatile(
+        "r0 = #0\n"
+        "r1 = ##1f\n"
+        "memw(%1) = r1\n"
+        "{\n"
+        ".word 0x19a14048    /* { q0 = vand(v0, r1) */\n"
+        ".word 0x19a0c044    /*   q0 = vsetq(r0) } */\n"
+        "}\n"
+        "1:\n"
+        "%0 = r0\n"
+        : "=r"(sig)
+        : "r"(&resume_pc)
+        : "r0", "r1", "memory");
+
+    return sig;
+}
+
  int main()
  {
      struct sigaction act;
@@ -290,6 +311,8 @@ int main()
      assert(test_vreg_illegal_mixed() == SIGILL);
      assert(test_vreg_illegal_uncond() == SIGILL);
 
+    assert(test_qreg_illegal() == SIGILL);
+
      puts("PASS");
      return EXIT_SUCCESS;
  }
#13 lore raw

PATCH v3 8/10 Hexagon (target/hexagon) Check for greg multiwrite in analyze_packet

In reply to Taylor Simpson
---
 target/hexagon/translate.h | 11 +++++++++--
 target/hexagon/translate.c |  8 ++++++++
 2 files changed, 17 insertions(+), 2 deletions(-)
target/hexagon/translate.h +9 -2
index b6cdf51c20..eb0d10d686 100644
@@ -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)
target/hexagon/translate.c +8 -0
index 815eecb60a..19585a108c 100644
@@ -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->gregs_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;
 }
 
Signature · 1 line
2.43.0
Reviewed-by on v3 8/10
#14 lore raw

Re: [PATCH v3 08/10] Hexagon (target/hexagon) Check for greg multiwrite in analyze_packet

Quoted 2 lines · Taylor Simpson

---

Quoted 59 lines
  target/hexagon/translate.h | 11 +++++++++--
  target/hexagon/translate.c |  8 ++++++++
  2 files changed, 17 insertions(+), 2 deletions(-)
target/hexagon/translate.h +9 -2
index b6cdf51c20..eb0d10d686 100644
@@ -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)
target/hexagon/translate.c +8 -0
index 815eecb60a..19585a108c 100644
@@ -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->gregs_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;
  }
 
#16 lore raw

PATCH v3 9/10 Hexagon (target/hexagon) Check for sreg multiwrite in analyze_packet

In reply to Taylor Simpson
---
 target/hexagon/translate.h | 11 +++++++++--
 target/hexagon/translate.c |  6 ++++++
 2 files changed, 15 insertions(+), 2 deletions(-)
target/hexagon/translate.h +9 -2
index eb0d10d686..b90f7fff1c 100644
@@ -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)
target/hexagon/translate.c +6 -0
index 19585a108c..a35c6c6835 100644
@@ -578,6 +578,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);
@@ -635,6 +637,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;
Signature · 1 line
2.43.0
Reviewed-by on v3 9/10
#17 lore raw

Re: [PATCH v3 09/10] Hexagon (target/hexagon) Check for sreg multiwrite in analyze_packet

Quoted 2 lines · Taylor Simpson

---

Quoted 57 lines
  target/hexagon/translate.h | 11 +++++++++--
  target/hexagon/translate.c |  6 ++++++
  2 files changed, 15 insertions(+), 2 deletions(-)
target/hexagon/translate.h +9 -2
index eb0d10d686..b90f7fff1c 100644
@@ -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)
target/hexagon/translate.c +6 -0
index 19585a108c..a35c6c6835 100644
@@ -578,6 +578,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);
@@ -635,6 +637,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;
#19 lore raw

PATCH v3 10/10 Hexagon (target/hexagon) Remove old way of detecting register multiwrites

In reply to Taylor Simpson

We now detect register multiwrites in packet analysis instead of packet decoding

---
 target/hexagon/insn.h             |  4 ---
 target/hexagon/decode.c           | 54 -------------------------------
 target/hexagon/translate.c        |  6 ----
 target/hexagon/gen_trans_funcs.py | 10 ------
 4 files changed, 74 deletions(-)
target/hexagon/insn.h +0 -4
index 835b1c954e..5d59430da9 100644
@@ -41,8 +41,6 @@ struct Instruction {
     uint32_t new_value_producer_slot:4;
     int32_t new_read_idx;
     int32_t dest_idx;
-    bool dest_is_pair;
-    bool dest_is_gpr;
     bool has_pred_dest;
 
     bool part1;              /*
@@ -74,8 +72,6 @@ struct Packet {
     bool pkt_has_hvx;
     Insn *vhist_insn;
 
-    bool pkt_has_write_conflict;
-
     Insn insn[INSTRUCTIONS_MAX];
 };
 
target/hexagon/decode.c +0 -54

72 lines not on this page · raw message

target/hexagon/translate.c +0 -6
index a35c6c6835..acf9407481 100644
@@ -1249,12 +1249,6 @@ static void decode_and_translate_packet(CPUHexagonState *env, DisasContext *ctx)
         clear_pkt_ctx(ctx);
         analyze_packet(ctx);
 
-        /*
-         * Check that the new method is a superset of the old methond
-         * Remove in a later patch
-         */
-        g_assert(!ctx->pkt.pkt_has_write_conflict ||
-                 pkt_has_write_conflict(ctx));
         if (pkt_has_write_conflict(ctx)) {
             gen_exception_decode_fail(ctx, words_read,
                                       HEX_CAUSE_REG_WRITE_CONFLICT);
target/hexagon/gen_trans_funcs.py +0 -10
index 19c1f9fdea..45da1b7b5d 100755
@@ -91,8 +91,6 @@ def gen_trans_funcs(f):
         new_read_idx = -1
         dest_idx = -1
         dest_idx_reg_id = None
-        dest_is_pair = "false"
-        dest_is_gpr = "false"
         has_pred_dest = "false"
         for regno, (reg_type, reg_id, *_) in enumerate(regs):
             reg = hex_common.get_register(tag, reg_type, reg_id)
@@ -106,12 +104,6 @@ def gen_trans_funcs(f):
                 if dest_idx_reg_id is None or reg_id < dest_idx_reg_id:
                     dest_idx = regno
                     dest_idx_reg_id = reg_id
-                    dest_is_pair = ("true"
-                                    if isinstance(reg, hex_common.Pair)
-                                    else "false")
-                    dest_is_gpr = ("true"
-                                   if reg_type == "R"
-                                   else "false")
             if reg_type == "P" and reg.is_written() and not reg.is_read():
                 has_pred_dest = "true"
 
@@ -137,8 +129,6 @@ def gen_trans_funcs(f):
         f.write(code_fmt(f"""\
             insn->new_read_idx = {new_read_idx};
             insn->dest_idx = {dest_idx};
-            insn->dest_is_pair = {dest_is_pair};
-            insn->dest_is_gpr = {dest_is_gpr};
             insn->has_pred_dest = {has_pred_dest};
         """))
         f.write(textwrap.dedent(f"""\
Signature · 1 line
2.43.0
#20 lore raw
In reply to Taylor Simpson
Quoted 8 lines · Taylor Simpson

Currently, we check for register multiwrites during packet decode. The downside of this approach is that it only checks a single destination register for each instruction. During analyze_packet, we can check for more than one write per instruction. Further, we can check for different types of registers. This series adds checks for HVX v-registers and q-registers.

Note that multiple writes to a predicate register are allowed on Hexagon.

This series is now queued for inclusion in an upcoming pull req - thanks, Taylor!

Quoted 35 lines

Changes in v2
- Rebase against latest sources, including Hexagon system mode
- Add checks for multiple writes to system registers

Changes in v3
- Address feedback from Brian Cain <[email protected]> Fix check-functional failures
Typo in commit comment
- Address feedback from Marco Liebel <[email protected]> Add test for mixed predicated/unconditional writes to vreg

Taylor Simpson (10):
Hexagon (target/hexagon) Move code out of gen_start_packet Hexagon (target/hexagon) Check for GPR multiwrite in analyze_packet Hexagon (tests/tcg/hexagon) Add tests for multi-destination
instructions
Hexagon (target/hexagon) Check for vreg multiwrite in analyze_packet Hexagon (tests/tcg/hexagon) Add tests for vreg multiple writes Hexagon (target/hexagon) Check for qreg multiwrite in analyze_packet Hexagon (tests/tcg/hexagon) Add tests for qreg multiple writes Hexagon (target/hexagon) Check for greg multiwrite in analyze_packet Hexagon (target/hexagon) Check for sreg multiwrite in analyze_packet Hexagon (target/hexagon) Remove old way of detecting register
multiwrites

  target/hexagon/insn.h               |   4 -
  target/hexagon/translate.h          |  47 +++++++--
  target/hexagon/decode.c             |  54 ----------
  target/hexagon/translate.c          |  90 +++++++++++++----
  tests/tcg/hexagon/multiple-writes.c | 149 ++++++++++++++++++++++++++++
  target/hexagon/gen_trans_funcs.py   |  10 --
  tests/tcg/hexagon/meson.build       |   2 +-
  7 files changed, 261 insertions(+), 95 deletions(-)