Message ID | 20250319134507.45045-4-philmd@linaro.org (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | tcg: Make tcg_gen_insn_start() target-agnostic | expand |
On 3/19/25 06:44, Philippe Mathieu-Daudé wrote: > Since restore_state_to_opc()'s rework in commits d29256896..04f105758 > and TCGContext::gen_insn_data[] widened in commit c9ad8d27caa ("tcg: > Widen gen_insn_data to uint64_t"), tcg_set_insn_start_param()'s 3rd > argument is uint64_t, not target_ulong. Use the same type signature > for tcg_gen_insn_start(). > > Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> > --- > include/tcg/tcg-op.h | 7 +++---- > accel/tcg/translate-all.c | 2 +- > 2 files changed, 4 insertions(+), 5 deletions(-) Your argument is flawed. It's not that the type when extracting is different, but that the type when inserting is intentionally truncated to the target address size. It's quite possible that there are no longer any odd uses, since I guess all uses of tcg_gen_insn_start are now in TranslatorOps.insn_start, reading from DisasContextBase.pc_next. If so, I would consider changing the type here to vaddr. r~
diff --git a/include/tcg/tcg-op.h b/include/tcg/tcg-op.h index 5dfddf995d6..8938f386599 100644 --- a/include/tcg/tcg-op.h +++ b/include/tcg/tcg-op.h @@ -23,21 +23,20 @@ #endif #if TARGET_INSN_START_EXTRA_WORDS == 0 -static inline void tcg_gen_insn_start(target_ulong pc) +static inline void tcg_gen_insn_start(uint64_t pc) { TCGOp *op = tcg_emit_op(INDEX_op_insn_start, 64 / TCG_TARGET_REG_BITS); tcg_set_insn_start_param(op, 0, pc); } #elif TARGET_INSN_START_EXTRA_WORDS == 1 -static inline void tcg_gen_insn_start(target_ulong pc, target_ulong a1) +static inline void tcg_gen_insn_start(uint64_t pc, uint64_t a1) { TCGOp *op = tcg_emit_op(INDEX_op_insn_start, 2 * 64 / TCG_TARGET_REG_BITS); tcg_set_insn_start_param(op, 0, pc); tcg_set_insn_start_param(op, 1, a1); } #elif TARGET_INSN_START_EXTRA_WORDS == 2 -static inline void tcg_gen_insn_start(target_ulong pc, target_ulong a1, - target_ulong a2) +static inline void tcg_gen_insn_start(uint64_t pc, uint64_t a1, uint64_t a2) { TCGOp *op = tcg_emit_op(INDEX_op_insn_start, 3 * 64 / TCG_TARGET_REG_BITS); tcg_set_insn_start_param(op, 0, pc); diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 82bc16bd535..a857aefd756 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -117,7 +117,7 @@ static int64_t decode_sleb128(const uint8_t **pp) /* Encode the data collected about the instructions while compiling TB. Place the data at BLOCK, and return the number of bytes consumed. - The logical table consists of TARGET_INSN_START_WORDS target_ulong's, + The logical table consists of TARGET_INSN_START_WORDS uint64_t's, which come from the target's insn_start data, followed by a uintptr_t which comes from the host pc of the end of the code implementing the insn.
Since restore_state_to_opc()'s rework in commits d29256896..04f105758 and TCGContext::gen_insn_data[] widened in commit c9ad8d27caa ("tcg: Widen gen_insn_data to uint64_t"), tcg_set_insn_start_param()'s 3rd argument is uint64_t, not target_ulong. Use the same type signature for tcg_gen_insn_start(). Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> --- include/tcg/tcg-op.h | 7 +++---- accel/tcg/translate-all.c | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-)