Move clear_pkt_ctx and analyze_packet out of gen_start_packet
Precursor to adding packet validity checks to analyze_packet
Signed-off-by: Taylor Simpson <ltaylorsimpson@gmail.com>
---
target/hexagon/translate.c | 46 ++++++++++++++++++++++----------------
1 file changed, 27 insertions(+), 19 deletions(-)
diff --git a/target/hexagon/translate.c b/target/hexagon/translate.c
index 2fdc956bf9..6e32805202 100644
--- a/target/hexagon/translate.c
+++ b/target/hexagon/translate.c
@@ -407,29 +407,12 @@ static void mark_implicit_writes(DisasContext *ctx)
mark_implicit_pred_writes(ctx);
}
-static void analyze_packet(DisasContext *ctx)
-{
- Packet *pkt = ctx->pkt;
- ctx->read_after_write = false;
- ctx->has_hvx_overlap = false;
- for (int i = 0; i < pkt->num_insns; i++) {
- Insn *insn = &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)
+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);
@@ -458,8 +441,29 @@ 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)
+{
+ Packet *pkt = ctx->pkt;
+ ctx->read_after_write = false;
+ ctx->has_hvx_overlap = false;
+ for (int i = 0; i < pkt->num_insns; i++) {
+ Insn *insn = &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)
+{
+ Packet *pkt = ctx->pkt;
+ target_ulong next_PC = ctx->base.pc_next + pkt->encod_pkt_size_in_bytes;
+ int i;
/*
* pregs_written is used both in the analyze phase as well as the code
@@ -957,6 +961,10 @@ static void decode_and_translate_packet(CPUHexagonState *env, DisasContext *ctx)
words_read = decode_packet(ctx, nwords, words, &pkt, false);
if (words_read > 0) {
pkt.pc = ctx->base.pc_next;
+
+ clear_pkt_ctx(ctx);
+ analyze_packet(ctx);
+
if (pkt.pkt_has_write_conflict) {
gen_exception_decode_fail(ctx, words_read,
HEX_CAUSE_REG_WRITE_CONFLICT);
--
2.43.0