mbox series

[00/22] plugins: Rewrite plugin code generation

Message ID 20240316015720.3661236-1-richard.henderson@linaro.org
Headers show
Series plugins: Rewrite plugin code generation | expand

Message

Richard Henderson March 16, 2024, 1:56 a.m. UTC
As I mooted with Pierrick earlier this week:

(1) Add a (trivial) mechanism for emitting code into
the middle of the opcode sequence: tcg_ctx->emit_before_op.

(2) Rip out all of the "empty" generation and "copy"
to modify those sequences.  Replace with regular code
generation once we know what values to place.

There's probably still more cleanup that could be done:

There seems to be a lot of artificial separation between
plugins and the rest of the code base, even between
plugins/api.c and plugins/core.c.

I suspect that all of plugins could be moved into the
build-once buckets.


r~


Richard Henderson (22):
  tcg: Add TCGContext.emit_before_op
  tcg: Make tcg/helper-info.h self-contained
  tcg: Pass function pointer to tcg_gen_call*
  plugins: Zero new qemu_plugin_dyn_cb entries
  plugins: Move function pointer in qemu_plugin_dyn_cb
  plugins: Create TCGHelperInfo for all out-of-line callbacks
  plugins: Use emit_before_op for PLUGIN_GEN_AFTER_INSN
  plugins: Use emit_before_op for PLUGIN_GEN_FROM_TB
  plugins: Add PLUGIN_GEN_AFTER_TB
  plugins: Use emit_before_op for PLUGIN_GEN_FROM_INSN
  plugins: Use emit_before_op for PLUGIN_GEN_FROM_MEM
  plugins: Remove plugin helpers
  tcg: Remove TCG_CALL_PLUGIN
  tcg: Remove INDEX_op_plugin_cb_{start,end}
  plugins: Simplify callback queues
  plugins: Introduce PLUGIN_CB_MEM_REGULAR
  plugins: Replace pr_ops with a proper debug dump flag
  plugins: Split out common cb expanders
  plugins: Merge qemu_plugin_tb_insn_get to plugin-gen.c
  plugins: Move qemu_plugin_insn_cleanup_fn to tcg.c
  plugins: Inline plugin_gen_empty_callback
  plugins: Update the documentation block for plugin-gen.c

 accel/tcg/plugin-helpers.h         |    5 -
 include/exec/helper-gen-common.h   |    4 -
 include/exec/helper-proto-common.h |    4 -
 include/exec/plugin-gen.h          |    4 -
 include/qemu/log.h                 |    1 +
 include/qemu/plugin.h              |   79 +--
 include/tcg/helper-info.h          |    3 +
 include/tcg/tcg-op-common.h        |    4 +-
 include/tcg/tcg-opc.h              |    4 +-
 include/tcg/tcg.h                  |   27 +-
 include/exec/helper-gen.h.inc      |   24 +-
 accel/tcg/plugin-gen.c             | 1008 +++++++---------------------
 plugins/api.c                      |   26 +-
 plugins/core.c                     |   61 +-
 tcg/tcg-op-ldst.c                  |    6 +-
 tcg/tcg-op.c                       |    8 +-
 tcg/tcg.c                          |  104 ++-
 util/log.c                         |    4 +
 18 files changed, 424 insertions(+), 952 deletions(-)
 delete mode 100644 accel/tcg/plugin-helpers.h

Comments

Pierrick Bouvier March 19, 2024, 1:38 p.m. UTC | #1
On 3/16/24 05:56, Richard Henderson wrote:
> As I mooted with Pierrick earlier this week:
> 
> (1) Add a (trivial) mechanism for emitting code into
> the middle of the opcode sequence: tcg_ctx->emit_before_op.
> 
> (2) Rip out all of the "empty" generation and "copy"
> to modify those sequences.  Replace with regular code
> generation once we know what values to place.
> 
> There's probably still more cleanup that could be done:
> 
> There seems to be a lot of artificial separation between
> plugins and the rest of the code base, even between
> plugins/api.c and plugins/core.c.
> 
> I suspect that all of plugins could be moved into the
> build-once buckets.
> 
> 
> r~
> 
> 
> Richard Henderson (22):
>    tcg: Add TCGContext.emit_before_op
>    tcg: Make tcg/helper-info.h self-contained
>    tcg: Pass function pointer to tcg_gen_call*
>    plugins: Zero new qemu_plugin_dyn_cb entries
>    plugins: Move function pointer in qemu_plugin_dyn_cb
>    plugins: Create TCGHelperInfo for all out-of-line callbacks
>    plugins: Use emit_before_op for PLUGIN_GEN_AFTER_INSN
>    plugins: Use emit_before_op for PLUGIN_GEN_FROM_TB
>    plugins: Add PLUGIN_GEN_AFTER_TB
>    plugins: Use emit_before_op for PLUGIN_GEN_FROM_INSN
>    plugins: Use emit_before_op for PLUGIN_GEN_FROM_MEM
>    plugins: Remove plugin helpers
>    tcg: Remove TCG_CALL_PLUGIN
>    tcg: Remove INDEX_op_plugin_cb_{start,end}
>    plugins: Simplify callback queues
>    plugins: Introduce PLUGIN_CB_MEM_REGULAR
>    plugins: Replace pr_ops with a proper debug dump flag
>    plugins: Split out common cb expanders
>    plugins: Merge qemu_plugin_tb_insn_get to plugin-gen.c
>    plugins: Move qemu_plugin_insn_cleanup_fn to tcg.c
>    plugins: Inline plugin_gen_empty_callback
>    plugins: Update the documentation block for plugin-gen.c
> 
>   accel/tcg/plugin-helpers.h         |    5 -
>   include/exec/helper-gen-common.h   |    4 -
>   include/exec/helper-proto-common.h |    4 -
>   include/exec/plugin-gen.h          |    4 -
>   include/qemu/log.h                 |    1 +
>   include/qemu/plugin.h              |   79 +--
>   include/tcg/helper-info.h          |    3 +
>   include/tcg/tcg-op-common.h        |    4 +-
>   include/tcg/tcg-opc.h              |    4 +-
>   include/tcg/tcg.h                  |   27 +-
>   include/exec/helper-gen.h.inc      |   24 +-
>   accel/tcg/plugin-gen.c             | 1008 +++++++---------------------
>   plugins/api.c                      |   26 +-
>   plugins/core.c                     |   61 +-
>   tcg/tcg-op-ldst.c                  |    6 +-
>   tcg/tcg-op.c                       |    8 +-
>   tcg/tcg.c                          |  104 ++-
>   util/log.c                         |    4 +
>   18 files changed, 424 insertions(+), 952 deletions(-)
>   delete mode 100644 accel/tcg/plugin-helpers.h
> 

Really great series. Not only the final code is much simpler, but it's 
faster as well (from the few tests I ran).