Message ID | 20240316015720.3661236-2-richard.henderson@linaro.org |
---|---|
State | Superseded |
Headers | show |
Series | plugins: Rewrite plugin code generation | expand |
On 3/16/24 05:56, Richard Henderson wrote: > Allow operations to be emitted via normal expanders > into the middle of the opcode stream. > > Signed-off-by: Richard Henderson <richard.henderson@linaro.org> > --- > include/tcg/tcg.h | 1 + > tcg/tcg.c | 14 ++++++++++++-- > 2 files changed, 13 insertions(+), 2 deletions(-) > > diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h > index 451f3fec41..e9d05f40b0 100644 > --- a/include/tcg/tcg.h > +++ b/include/tcg/tcg.h > @@ -552,6 +552,7 @@ struct TCGContext { > > QTAILQ_HEAD(, TCGOp) ops, free_ops; > QSIMPLEQ_HEAD(, TCGLabel) labels; > + TCGOp *emit_before_op; > > /* Tells which temporary holds a given register. > It does not take into account fixed registers */ > 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; > } > Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Richard Henderson <richard.henderson@linaro.org> writes: > Allow operations to be emitted via normal expanders > into the middle of the opcode stream. > > Signed-off-by: Richard Henderson <richard.henderson@linaro.org> > --- > include/tcg/tcg.h | 1 + > tcg/tcg.c | 14 ++++++++++++-- > 2 files changed, 13 insertions(+), 2 deletions(-) > > diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h > index 451f3fec41..e9d05f40b0 100644 > --- a/include/tcg/tcg.h > +++ b/include/tcg/tcg.h > @@ -552,6 +552,7 @@ struct TCGContext { > > QTAILQ_HEAD(, TCGOp) ops, free_ops; > QSIMPLEQ_HEAD(, TCGLabel) labels; > + TCGOp *emit_before_op; Could we add some kdoc comments to the TCGContext describing what each variables is for. Is this just a list of ops to emit before the current instruction emulation? Is it cleared between instruction boundaries?
On 3/19/24 04:04, Alex Bennée wrote: > Richard Henderson <richard.henderson@linaro.org> writes: > >> Allow operations to be emitted via normal expanders >> into the middle of the opcode stream. >> >> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> >> --- >> include/tcg/tcg.h | 1 + >> tcg/tcg.c | 14 ++++++++++++-- >> 2 files changed, 13 insertions(+), 2 deletions(-) >> >> diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h >> index 451f3fec41..e9d05f40b0 100644 >> --- a/include/tcg/tcg.h >> +++ b/include/tcg/tcg.h >> @@ -552,6 +552,7 @@ struct TCGContext { >> >> QTAILQ_HEAD(, TCGOp) ops, free_ops; >> QSIMPLEQ_HEAD(, TCGLabel) labels; >> + TCGOp *emit_before_op; > > Could we add some kdoc comments to the TCGContext describing what each > variables is for. Is this just a list of ops to emit before the current > instruction emulation? Is it cleared between instruction boundaries? It's not a list, it's an insertion point. Nothing automatic about it; manually controlled by plugin-gen.c. (I believe it will be useful for cleanup in tcg/optimize.c as well.) r~
diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index 451f3fec41..e9d05f40b0 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -552,6 +552,7 @@ struct TCGContext { QTAILQ_HEAD(, TCGOp) ops, free_ops; QSIMPLEQ_HEAD(, TCGLabel) labels; + TCGOp *emit_before_op; /* Tells which temporary holds a given register. It does not take into account fixed registers */ 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; }
Allow operations to be emitted via normal expanders into the middle of the opcode stream. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> --- include/tcg/tcg.h | 1 + tcg/tcg.c | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-)