[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL v2 11/20] tcg: Add TCGContext.emit_before_op
From: |
Richard Henderson |
Subject: |
[PULL v2 11/20] tcg: Add TCGContext.emit_before_op |
Date: |
Tue, 9 Apr 2024 09:35:54 -1000 |
Allow operations to be emitted via normal expanders
into the middle of the opcode stream.
Tested-by: Jørgen Hansen <Jorgen.Hansen@wdc.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
include/tcg/tcg.h | 6 ++++++
tcg/tcg.c | 14 ++++++++++++--
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h
index 451f3fec41..05a1912f8a 100644
--- a/include/tcg/tcg.h
+++ b/include/tcg/tcg.h
@@ -553,6 +553,12 @@ struct TCGContext {
QTAILQ_HEAD(, TCGOp) ops, free_ops;
QSIMPLEQ_HEAD(, TCGLabel) labels;
+ /*
+ * When clear, new ops are added to the tail of @ops.
+ * When set, new ops are added in front of @emit_before_op.
+ */
+ TCGOp *emit_before_op;
+
/* Tells which temporary holds a given register.
It does not take into account fixed registers */
TCGTemp *reg_to_temp[TCG_TARGET_NB_REGS];
diff --git a/tcg/tcg.c b/tcg/tcg.c
index d6670237fb..0c0bb9d169 100644
--- a/tcg/tcg.c
+++ b/tcg/tcg.c
@@ -1521,6 +1521,7 @@ void tcg_func_start(TCGContext *s)
QTAILQ_INIT(&s->ops);
QTAILQ_INIT(&s->free_ops);
+ s->emit_before_op = NULL;
QSIMPLEQ_INIT(&s->labels);
tcg_debug_assert(s->addr_type == TCG_TYPE_I32 ||
@@ -2332,7 +2333,11 @@ static void tcg_gen_callN(TCGHelperInfo *info, TCGTemp
*ret, TCGTemp **args)
op->args[pi++] = (uintptr_t)info;
tcg_debug_assert(pi == total_args);
- QTAILQ_INSERT_TAIL(&tcg_ctx->ops, op, link);
+ if (tcg_ctx->emit_before_op) {
+ QTAILQ_INSERT_BEFORE(tcg_ctx->emit_before_op, op, link);
+ } else {
+ QTAILQ_INSERT_TAIL(&tcg_ctx->ops, op, link);
+ }
tcg_debug_assert(n_extend < ARRAY_SIZE(extend_free));
for (i = 0; i < n_extend; ++i) {
@@ -3215,7 +3220,12 @@ static TCGOp *tcg_op_alloc(TCGOpcode opc, unsigned nargs)
TCGOp *tcg_emit_op(TCGOpcode opc, unsigned nargs)
{
TCGOp *op = tcg_op_alloc(opc, nargs);
- QTAILQ_INSERT_TAIL(&tcg_ctx->ops, op, link);
+
+ if (tcg_ctx->emit_before_op) {
+ QTAILQ_INSERT_BEFORE(tcg_ctx->emit_before_op, op, link);
+ } else {
+ QTAILQ_INSERT_TAIL(&tcg_ctx->ops, op, link);
+ }
return op;
}
--
2.34.1
- [PULL v2 01/20] tcg/optimize: Do not attempt to constant fold neg_vec, (continued)
- [PULL v2 01/20] tcg/optimize: Do not attempt to constant fold neg_vec, Richard Henderson, 2024/04/09
- [PULL v2 02/20] linux-user: Fix waitid return of siginfo_t and rusage, Richard Henderson, 2024/04/09
- [PULL v2 03/20] linux-user: replace calloc() with g_new0(), Richard Henderson, 2024/04/09
- [PULL v2 04/20] target/hppa: Fix IIAOQ, IIASQ for pa2.0, Richard Henderson, 2024/04/09
- [PULL v2 05/20] target/sh4: mac.w: memory accesses are 16-bit words, Richard Henderson, 2024/04/09
- [PULL v2 06/20] target/sh4: Merge mach and macl into a union, Richard Henderson, 2024/04/09
- [PULL v2 07/20] target/sh4: Fix mac.l with saturation enabled, Richard Henderson, 2024/04/09
- [PULL v2 08/20] target/sh4: Fix mac.w with saturation enabled, Richard Henderson, 2024/04/09
- [PULL v2 09/20] target/sh4: add missing CHECK_NOT_DELAY_SLOT, Richard Henderson, 2024/04/09
- [PULL v2 10/20] target/m68k: Map FPU exceptions to FPSR register, Richard Henderson, 2024/04/09
- [PULL v2 11/20] tcg: Add TCGContext.emit_before_op,
Richard Henderson <=
- [PULL v2 12/20] accel/tcg: Add insn_start to DisasContextBase, Richard Henderson, 2024/04/09
- [PULL v2 14/20] target/hppa: Use insn_start from DisasContextBase, Richard Henderson, 2024/04/09
- [PULL v2 13/20] target/arm: Use insn_start from DisasContextBase, Richard Henderson, 2024/04/09
- [PULL v2 15/20] target/i386: Preserve DisasContextBase.insn_start across rewind, Richard Henderson, 2024/04/09
- [PULL v2 16/20] target/microblaze: Use insn_start from DisasContextBase, Richard Henderson, 2024/04/09
- [PULL v2 17/20] target/riscv: Use insn_start from DisasContextBase, Richard Henderson, 2024/04/09
- [PULL v2 18/20] target/s390x: Use insn_start from DisasContextBase, Richard Henderson, 2024/04/09
- [PULL v2 19/20] accel/tcg: Improve can_do_io management, Richard Henderson, 2024/04/09
- [PULL v2 20/20] linux-user: Preserve unswapped siginfo_t for strace, Richard Henderson, 2024/04/09
- Re: [PULL v2 00/20] misc patch queue, Peter Maydell, 2024/04/10