[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 01/21] tcg: Add TCGContext.emit_before_op
From: |
Richard Henderson |
Subject: |
[PATCH v2 01/21] tcg: Add TCGContext.emit_before_op |
Date: |
Thu, 4 Apr 2024 13:05:51 -1000 |
Allow operations to be emitted via normal expanders
into the middle of the opcode stream.
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
- [PATCH v2 00/21] Rewrite plugin code generation, Richard Henderson, 2024/04/04
- [PATCH v2 02/21] tcg: Make tcg/helper-info.h self-contained, Richard Henderson, 2024/04/04
- [PATCH v2 04/21] plugins: Zero new qemu_plugin_dyn_cb entries, Richard Henderson, 2024/04/04
- [PATCH v2 03/21] tcg: Pass function pointer to tcg_gen_call*, Richard Henderson, 2024/04/04
- [PATCH v2 05/21] plugins: Move function pointer in qemu_plugin_dyn_cb, Richard Henderson, 2024/04/04
- [PATCH v2 01/21] tcg: Add TCGContext.emit_before_op,
Richard Henderson <=
- [PATCH v2 07/21] plugins: Use emit_before_op for PLUGIN_GEN_AFTER_INSN, Richard Henderson, 2024/04/04
- [PATCH v2 08/21] plugins: Use emit_before_op for PLUGIN_GEN_FROM_TB, Richard Henderson, 2024/04/04
- [PATCH v2 09/21] plugins: Add PLUGIN_GEN_AFTER_TB, Richard Henderson, 2024/04/04
- [PATCH v2 06/21] plugins: Create TCGHelperInfo for all out-of-line callbacks, Richard Henderson, 2024/04/04
- [PATCH v2 19/21] plugins: Merge qemu_plugin_tb_insn_get to plugin-gen.c, Richard Henderson, 2024/04/04
- [PATCH v2 18/21] plugins: Split out common cb expanders, Richard Henderson, 2024/04/04
- [PATCH v2 16/21] plugins: Introduce PLUGIN_CB_MEM_REGULAR, Richard Henderson, 2024/04/04
- [PATCH v2 10/21] plugins: Use emit_before_op for PLUGIN_GEN_FROM_INSN, Richard Henderson, 2024/04/04
- [PATCH v2 11/21] plugins: Use emit_before_op for PLUGIN_GEN_FROM_MEM, Richard Henderson, 2024/04/04
- [PATCH v2 12/21] plugins: Remove plugin helpers, Richard Henderson, 2024/04/04