[PATCH 00/26] multi-target: prefix helpers with target prefix

Pierrick Bouvier posted 26 patches 1 month ago
Failed in applying to current master (apply log)
There is a newer version of this series
include/exec/helper-gen-common.h        |   7 +
include/exec/helper-gen.h.inc           |  48 +-
include/exec/helper-head.h.inc          |   8 +-
include/exec/helper-info.c.inc          |  16 +-
include/exec/helper-proto-common.h      |   7 +
meson.build                             |   2 +
target/alpha/clk_helper.c               |   2 +-
target/alpha/fpu_helper.c               |  60 +--
target/alpha/helper.c                   |   6 +-
target/alpha/helper.h                   |   2 +-
target/alpha/int_helper.c               |  38 +-
target/alpha/sys_helper.c               |  12 +-
target/alpha/translate.c                |   4 +-
target/alpha/vax_helper.c               |  42 +-
target/arm/tcg/helper-a64.c             |   6 +-
target/arm/tcg/mve_helper.c             |  28 +-
target/arm/tcg/psci.c                   |   2 +-
target/arm/tcg/sme_helper.c             |   4 +-
target/arm/tcg/sve_helper.c             | 141 ++---
target/arm/tcg/tlb_helper.c             |   2 +-
target/arm/tcg/vec_helper.c             |  72 +--
target/arm/tcg/vec_helper64.c           |  64 +--
target/arm/tcg/vec_internal.h           |   5 +-
target/avr/helper.c                     |  12 +-
target/hexagon/gen_tcg.h                |   2 +-
target/hexagon/gen_tcg_sys.h            |   2 +-
target/hexagon/helper.h                 |   4 +-
target/hexagon/op_helper.c              |   4 +-
target/hexagon/translate.c              |   4 +-
target/hppa/fpu_helper.c                |   2 +-
target/hppa/helper.h                    |   6 +-
target/hppa/op_helper.c                 |   4 +-
target/hppa/sys_helper.c                |  10 +-
target/hppa/translate.c                 |   6 +-
target/i386/ops_sse.h                   | 401 +++++++-------
target/i386/tcg/bpt_helper.c            |   6 +-
target/i386/tcg/cc_helper.c             |  14 +-
target/i386/tcg/excp_helper.c           |   8 +-
target/i386/tcg/fpu_helper.c            | 182 +++----
target/i386/tcg/int_helper.c            |  34 +-
target/i386/tcg/mem_helper.c            |   4 +-
target/i386/tcg/misc_helper.c           |  16 +-
target/i386/tcg/mpx_helper.c            |  12 +-
target/i386/tcg/seg_helper.c            |  32 +-
target/i386/tcg/system/bpt_helper.c     |   6 +-
target/i386/tcg/system/misc_helper.c    |  32 +-
target/i386/tcg/system/seg_helper.c     |   4 +-
target/i386/tcg/system/smm_helper.c     |  12 +-
target/i386/tcg/system/svm_helper.c     |  16 +-
target/i386/tcg/user/seg_helper.c       |   4 +-
target/loongarch/tcg/csr_helper.c       |  22 +-
target/loongarch/tcg/fpu_helper.c       | 126 ++---
target/loongarch/tcg/iocsr_helper.c     |  16 +-
target/loongarch/tcg/op_helper.c        |  18 +-
target/loongarch/tcg/tlb_helper.c       |  26 +-
target/loongarch/tcg/vec_helper.c       |   4 +-
target/m68k/op_helper.c                 |   2 +-
target/microblaze/helper.h              |  10 +-
target/microblaze/op_helper.c           |  46 +-
target/microblaze/translate.c           |  10 +-
target/mips/tcg/dsp_helper.c            | 187 +++----
target/mips/tcg/exception.c             |   8 +-
target/mips/tcg/fpu_helper.c            | 291 +++++-----
target/mips/tcg/ldst_helper.c           |  18 +-
target/mips/tcg/lmmi_helper.c           |  98 ++--
target/mips/tcg/msa_helper.c            | 690 ++++++++++++------------
target/mips/tcg/octeon_crypto.c         | 100 ++--
target/mips/tcg/op_helper.c             |  34 +-
target/mips/tcg/system/cp0_helper.c     | 276 +++++-----
target/mips/tcg/system/lcsr_helper.c    |   8 +-
target/mips/tcg/system/special_helper.c |  12 +-
target/mips/tcg/system/tlb_helper.c     |  14 +-
target/mips/tcg/vr54xx_helper.c         |  30 +-
target/or1k/fpu_helper.c                |  16 +-
target/or1k/helper.h                    |   2 +-
target/or1k/interrupt_helper.c          |   2 +-
target/or1k/translate.c                 |   2 +-
target/ppc/dfp_helper.c                 |  52 +-
target/ppc/fpu_helper.c                 | 396 +++++++-------
target/ppc/int_helper.c                 | 292 +++++-----
target/ppc/internal.h                   |   7 +-
target/ppc/mem_helper.c                 |  28 +-
target/ppc/misc_helper.c                |  56 +-
target/ppc/mmu-hash64.c                 |  18 +-
target/ppc/mmu_helper.c                 |  70 +--
target/ppc/power8-pmu.c                 |  14 +-
target/ppc/tcg-excp_helper.c            |  56 +-
target/ppc/timebase_helper.c            |  54 +-
target/ppc/translate/vsx-impl.c.inc     |   2 +-
target/riscv/tcg/debug.c                |   2 +-
target/riscv/tcg/fpu_helper.c           | 196 +++----
target/riscv/tcg/op_helper.c            |  74 +--
target/rx/helper.h                      |  12 +-
target/rx/op_helper.c                   |  62 +--
target/rx/translate.c                   |  14 +-
target/s390x/tcg/mem_helper.c           |   2 +-
target/sh4/op_helper.c                  |  76 +--
target/sparc/fop_helper.c               | 106 ++--
target/sparc/helper.c                   |  22 +-
target/sparc/int64_helper.c             |   6 +-
target/sparc/ldst_helper.c              |  14 +-
target/sparc/vis_helper.c               |  94 ++--
target/sparc/win_helper.c               |  38 +-
target/tricore/fpu_helper.c             |  32 +-
target/tricore/helper.h                 |  14 +-
target/tricore/op_helper.c              | 220 ++++----
target/tricore/translate.c              |  14 +-
107 files changed, 2789 insertions(+), 2739 deletions(-)
[PATCH 00/26] multi-target: prefix helpers with target prefix
Posted by Pierrick Bouvier 1 month ago
When linking multiple targets together, we usually have conflicts with helper
names. So far, it was solved using ad-hoc renaming, but multiple people pointed it
would be better to have a general mechanism for it, so here it is.

A previous series attempted that:
https://lore.kernel.org/qemu-devel/20260930073935.712-1-luoyonggang@gmail.com/,
but it was relying on (binary) symbol renaming, which is not a portable solution.
Instead, this series approaches the problem from source code directly.
It requires more change, but it's cleaner IMHO.

Series follows these steps:

First, we make sure all helpers and definition are using HELPER() macro. A lot
of helpers were already defined this way, we just make sure it's exhaustive.
After that we don't have any 'helper_' left on any target code. This is a big
change touching the whole codebase, but it's a simple mechanical change. As long
as it compiles and links, we know it's correct.

Then, we introduce the prefix for target helpers. For this , we add a new define
(from meson) that applies to all target related code. It could later be used to
prefix other symbols also, that's why it's not named "TCG".

Finally, we cleanup the previous manual helpers prefix that were added in
codebase.

Pierrick Bouvier (26):
  target/alpha: define and call helpers using HELPER macro
  target/arm: define and call helpers using HELPER macro
  target/avr: define and call helpers using HELPER macro
  target/hppa: define and call helpers using HELPER macro
  target/i386: define and call helpers using HELPER macro
  target/loongarch: define and call helpers using HELPER macro
  target/m68k: define and call helpers using HELPER macro
  target/microblaze: define and call helpers using HELPER macro
  target/mips: define and call helpers using HELPER macro
  target/or1k: define and call helpers using HELPER macro
  target/ppc: define and call helpers using HELPER macro
  target/riscv: define and call helpers using HELPER macro
  target/rx: define and call helpers using HELPER macro
  target/s390x: define and call helpers using HELPER macro
  target/sh4: define and call helpers using HELPER macro
  target/sparc: define and call helpers using HELPER macro
  target/tricore: define and call helpers using HELPER macro
  tcg: introduce HELPER_INFO macro
  tcg: prefix helpers with target base architecture
  target/alpha: remove explicit target specific prefix
  target/hexagon: remove explicit target specific prefix
  target/hppa: remove explicit target specific prefix
  target/microblaze: remove explicit target specific prefix
  target/or1k: remove explicit target specific prefix
  target/rx: remove explicit target specific prefix
  target/tricore: remove explicit target specific prefix

 include/exec/helper-gen-common.h        |   7 +
 include/exec/helper-gen.h.inc           |  48 +-
 include/exec/helper-head.h.inc          |   8 +-
 include/exec/helper-info.c.inc          |  16 +-
 include/exec/helper-proto-common.h      |   7 +
 meson.build                             |   2 +
 target/alpha/clk_helper.c               |   2 +-
 target/alpha/fpu_helper.c               |  60 +--
 target/alpha/helper.c                   |   6 +-
 target/alpha/helper.h                   |   2 +-
 target/alpha/int_helper.c               |  38 +-
 target/alpha/sys_helper.c               |  12 +-
 target/alpha/translate.c                |   4 +-
 target/alpha/vax_helper.c               |  42 +-
 target/arm/tcg/helper-a64.c             |   6 +-
 target/arm/tcg/mve_helper.c             |  28 +-
 target/arm/tcg/psci.c                   |   2 +-
 target/arm/tcg/sme_helper.c             |   4 +-
 target/arm/tcg/sve_helper.c             | 141 ++---
 target/arm/tcg/tlb_helper.c             |   2 +-
 target/arm/tcg/vec_helper.c             |  72 +--
 target/arm/tcg/vec_helper64.c           |  64 +--
 target/arm/tcg/vec_internal.h           |   5 +-
 target/avr/helper.c                     |  12 +-
 target/hexagon/gen_tcg.h                |   2 +-
 target/hexagon/gen_tcg_sys.h            |   2 +-
 target/hexagon/helper.h                 |   4 +-
 target/hexagon/op_helper.c              |   4 +-
 target/hexagon/translate.c              |   4 +-
 target/hppa/fpu_helper.c                |   2 +-
 target/hppa/helper.h                    |   6 +-
 target/hppa/op_helper.c                 |   4 +-
 target/hppa/sys_helper.c                |  10 +-
 target/hppa/translate.c                 |   6 +-
 target/i386/ops_sse.h                   | 401 +++++++-------
 target/i386/tcg/bpt_helper.c            |   6 +-
 target/i386/tcg/cc_helper.c             |  14 +-
 target/i386/tcg/excp_helper.c           |   8 +-
 target/i386/tcg/fpu_helper.c            | 182 +++----
 target/i386/tcg/int_helper.c            |  34 +-
 target/i386/tcg/mem_helper.c            |   4 +-
 target/i386/tcg/misc_helper.c           |  16 +-
 target/i386/tcg/mpx_helper.c            |  12 +-
 target/i386/tcg/seg_helper.c            |  32 +-
 target/i386/tcg/system/bpt_helper.c     |   6 +-
 target/i386/tcg/system/misc_helper.c    |  32 +-
 target/i386/tcg/system/seg_helper.c     |   4 +-
 target/i386/tcg/system/smm_helper.c     |  12 +-
 target/i386/tcg/system/svm_helper.c     |  16 +-
 target/i386/tcg/user/seg_helper.c       |   4 +-
 target/loongarch/tcg/csr_helper.c       |  22 +-
 target/loongarch/tcg/fpu_helper.c       | 126 ++---
 target/loongarch/tcg/iocsr_helper.c     |  16 +-
 target/loongarch/tcg/op_helper.c        |  18 +-
 target/loongarch/tcg/tlb_helper.c       |  26 +-
 target/loongarch/tcg/vec_helper.c       |   4 +-
 target/m68k/op_helper.c                 |   2 +-
 target/microblaze/helper.h              |  10 +-
 target/microblaze/op_helper.c           |  46 +-
 target/microblaze/translate.c           |  10 +-
 target/mips/tcg/dsp_helper.c            | 187 +++----
 target/mips/tcg/exception.c             |   8 +-
 target/mips/tcg/fpu_helper.c            | 291 +++++-----
 target/mips/tcg/ldst_helper.c           |  18 +-
 target/mips/tcg/lmmi_helper.c           |  98 ++--
 target/mips/tcg/msa_helper.c            | 690 ++++++++++++------------
 target/mips/tcg/octeon_crypto.c         | 100 ++--
 target/mips/tcg/op_helper.c             |  34 +-
 target/mips/tcg/system/cp0_helper.c     | 276 +++++-----
 target/mips/tcg/system/lcsr_helper.c    |   8 +-
 target/mips/tcg/system/special_helper.c |  12 +-
 target/mips/tcg/system/tlb_helper.c     |  14 +-
 target/mips/tcg/vr54xx_helper.c         |  30 +-
 target/or1k/fpu_helper.c                |  16 +-
 target/or1k/helper.h                    |   2 +-
 target/or1k/interrupt_helper.c          |   2 +-
 target/or1k/translate.c                 |   2 +-
 target/ppc/dfp_helper.c                 |  52 +-
 target/ppc/fpu_helper.c                 | 396 +++++++-------
 target/ppc/int_helper.c                 | 292 +++++-----
 target/ppc/internal.h                   |   7 +-
 target/ppc/mem_helper.c                 |  28 +-
 target/ppc/misc_helper.c                |  56 +-
 target/ppc/mmu-hash64.c                 |  18 +-
 target/ppc/mmu_helper.c                 |  70 +--
 target/ppc/power8-pmu.c                 |  14 +-
 target/ppc/tcg-excp_helper.c            |  56 +-
 target/ppc/timebase_helper.c            |  54 +-
 target/ppc/translate/vsx-impl.c.inc     |   2 +-
 target/riscv/tcg/debug.c                |   2 +-
 target/riscv/tcg/fpu_helper.c           | 196 +++----
 target/riscv/tcg/op_helper.c            |  74 +--
 target/rx/helper.h                      |  12 +-
 target/rx/op_helper.c                   |  62 +--
 target/rx/translate.c                   |  14 +-
 target/s390x/tcg/mem_helper.c           |   2 +-
 target/sh4/op_helper.c                  |  76 +--
 target/sparc/fop_helper.c               | 106 ++--
 target/sparc/helper.c                   |  22 +-
 target/sparc/int64_helper.c             |   6 +-
 target/sparc/ldst_helper.c              |  14 +-
 target/sparc/vis_helper.c               |  94 ++--
 target/sparc/win_helper.c               |  38 +-
 target/tricore/fpu_helper.c             |  32 +-
 target/tricore/helper.h                 |  14 +-
 target/tricore/op_helper.c              | 220 ++++----
 target/tricore/translate.c              |  14 +-
 107 files changed, 2789 insertions(+), 2739 deletions(-)

-- 
2.43.0
Re: [PATCH 00/26] multi-target: prefix helpers with target prefix
Posted by Pierrick Bouvier 4 weeks, 1 day ago
On 10/19/26 2:20 PM, Pierrick Bouvier wrote:
> When linking multiple targets together, we usually have conflicts with helper
> names. So far, it was solved using ad-hoc renaming, but multiple people pointed it
> would be better to have a general mechanism for it, so here it is.
> 
> A previous series attempted that:
> https://lore.kernel.org/qemu-devel/20260930073935.712-1-luoyonggang@gmail.com/,
> but it was relying on (binary) symbol renaming, which is not a portable solution.
> Instead, this series approaches the problem from source code directly.
> It requires more change, but it's cleaner IMHO.
> 
> Series follows these steps:
> 
> First, we make sure all helpers and definition are using HELPER() macro. A lot
> of helpers were already defined this way, we just make sure it's exhaustive.
> After that we don't have any 'helper_' left on any target code. This is a big
> change touching the whole codebase, but it's a simple mechanical change. As long
> as it compiles and links, we know it's correct.
> 
> Then, we introduce the prefix for target helpers. For this , we add a new define
> (from meson) that applies to all target related code. It could later be used to
> prefix other symbols also, that's why it's not named "TCG".
> 
> Finally, we cleanup the previous manual helpers prefix that were added in
> codebase.
> 
> Pierrick Bouvier (26):
>    target/alpha: define and call helpers using HELPER macro
>    target/arm: define and call helpers using HELPER macro
>    target/avr: define and call helpers using HELPER macro
>    target/hppa: define and call helpers using HELPER macro
>    target/i386: define and call helpers using HELPER macro
>    target/loongarch: define and call helpers using HELPER macro
>    target/m68k: define and call helpers using HELPER macro
>    target/microblaze: define and call helpers using HELPER macro
>    target/mips: define and call helpers using HELPER macro
>    target/or1k: define and call helpers using HELPER macro
>    target/ppc: define and call helpers using HELPER macro
>    target/riscv: define and call helpers using HELPER macro
>    target/rx: define and call helpers using HELPER macro
>    target/s390x: define and call helpers using HELPER macro
>    target/sh4: define and call helpers using HELPER macro
>    target/sparc: define and call helpers using HELPER macro
>    target/tricore: define and call helpers using HELPER macro
>    tcg: introduce HELPER_INFO macro
>    tcg: prefix helpers with target base architecture
>    target/alpha: remove explicit target specific prefix
>    target/hexagon: remove explicit target specific prefix
>    target/hppa: remove explicit target specific prefix
>    target/microblaze: remove explicit target specific prefix
>    target/or1k: remove explicit target specific prefix
>    target/rx: remove explicit target specific prefix
>    target/tricore: remove explicit target specific prefix
> 
>   include/exec/helper-gen-common.h        |   7 +
>   include/exec/helper-gen.h.inc           |  48 +-
>   include/exec/helper-head.h.inc          |   8 +-
>   include/exec/helper-info.c.inc          |  16 +-
>   include/exec/helper-proto-common.h      |   7 +
>   meson.build                             |   2 +
>   target/alpha/clk_helper.c               |   2 +-
>   target/alpha/fpu_helper.c               |  60 +--
>   target/alpha/helper.c                   |   6 +-
>   target/alpha/helper.h                   |   2 +-
>   target/alpha/int_helper.c               |  38 +-
>   target/alpha/sys_helper.c               |  12 +-
>   target/alpha/translate.c                |   4 +-
>   target/alpha/vax_helper.c               |  42 +-
>   target/arm/tcg/helper-a64.c             |   6 +-
>   target/arm/tcg/mve_helper.c             |  28 +-
>   target/arm/tcg/psci.c                   |   2 +-
>   target/arm/tcg/sme_helper.c             |   4 +-
>   target/arm/tcg/sve_helper.c             | 141 ++---
>   target/arm/tcg/tlb_helper.c             |   2 +-
>   target/arm/tcg/vec_helper.c             |  72 +--
>   target/arm/tcg/vec_helper64.c           |  64 +--
>   target/arm/tcg/vec_internal.h           |   5 +-
>   target/avr/helper.c                     |  12 +-
>   target/hexagon/gen_tcg.h                |   2 +-
>   target/hexagon/gen_tcg_sys.h            |   2 +-
>   target/hexagon/helper.h                 |   4 +-
>   target/hexagon/op_helper.c              |   4 +-
>   target/hexagon/translate.c              |   4 +-
>   target/hppa/fpu_helper.c                |   2 +-
>   target/hppa/helper.h                    |   6 +-
>   target/hppa/op_helper.c                 |   4 +-
>   target/hppa/sys_helper.c                |  10 +-
>   target/hppa/translate.c                 |   6 +-
>   target/i386/ops_sse.h                   | 401 +++++++-------
>   target/i386/tcg/bpt_helper.c            |   6 +-
>   target/i386/tcg/cc_helper.c             |  14 +-
>   target/i386/tcg/excp_helper.c           |   8 +-
>   target/i386/tcg/fpu_helper.c            | 182 +++----
>   target/i386/tcg/int_helper.c            |  34 +-
>   target/i386/tcg/mem_helper.c            |   4 +-
>   target/i386/tcg/misc_helper.c           |  16 +-
>   target/i386/tcg/mpx_helper.c            |  12 +-
>   target/i386/tcg/seg_helper.c            |  32 +-
>   target/i386/tcg/system/bpt_helper.c     |   6 +-
>   target/i386/tcg/system/misc_helper.c    |  32 +-
>   target/i386/tcg/system/seg_helper.c     |   4 +-
>   target/i386/tcg/system/smm_helper.c     |  12 +-
>   target/i386/tcg/system/svm_helper.c     |  16 +-
>   target/i386/tcg/user/seg_helper.c       |   4 +-
>   target/loongarch/tcg/csr_helper.c       |  22 +-
>   target/loongarch/tcg/fpu_helper.c       | 126 ++---
>   target/loongarch/tcg/iocsr_helper.c     |  16 +-
>   target/loongarch/tcg/op_helper.c        |  18 +-
>   target/loongarch/tcg/tlb_helper.c       |  26 +-
>   target/loongarch/tcg/vec_helper.c       |   4 +-
>   target/m68k/op_helper.c                 |   2 +-
>   target/microblaze/helper.h              |  10 +-
>   target/microblaze/op_helper.c           |  46 +-
>   target/microblaze/translate.c           |  10 +-
>   target/mips/tcg/dsp_helper.c            | 187 +++----
>   target/mips/tcg/exception.c             |   8 +-
>   target/mips/tcg/fpu_helper.c            | 291 +++++-----
>   target/mips/tcg/ldst_helper.c           |  18 +-
>   target/mips/tcg/lmmi_helper.c           |  98 ++--
>   target/mips/tcg/msa_helper.c            | 690 ++++++++++++------------
>   target/mips/tcg/octeon_crypto.c         | 100 ++--
>   target/mips/tcg/op_helper.c             |  34 +-
>   target/mips/tcg/system/cp0_helper.c     | 276 +++++-----
>   target/mips/tcg/system/lcsr_helper.c    |   8 +-
>   target/mips/tcg/system/special_helper.c |  12 +-
>   target/mips/tcg/system/tlb_helper.c     |  14 +-
>   target/mips/tcg/vr54xx_helper.c         |  30 +-
>   target/or1k/fpu_helper.c                |  16 +-
>   target/or1k/helper.h                    |   2 +-
>   target/or1k/interrupt_helper.c          |   2 +-
>   target/or1k/translate.c                 |   2 +-
>   target/ppc/dfp_helper.c                 |  52 +-
>   target/ppc/fpu_helper.c                 | 396 +++++++-------
>   target/ppc/int_helper.c                 | 292 +++++-----
>   target/ppc/internal.h                   |   7 +-
>   target/ppc/mem_helper.c                 |  28 +-
>   target/ppc/misc_helper.c                |  56 +-
>   target/ppc/mmu-hash64.c                 |  18 +-
>   target/ppc/mmu_helper.c                 |  70 +--
>   target/ppc/power8-pmu.c                 |  14 +-
>   target/ppc/tcg-excp_helper.c            |  56 +-
>   target/ppc/timebase_helper.c            |  54 +-
>   target/ppc/translate/vsx-impl.c.inc     |   2 +-
>   target/riscv/tcg/debug.c                |   2 +-
>   target/riscv/tcg/fpu_helper.c           | 196 +++----
>   target/riscv/tcg/op_helper.c            |  74 +--
>   target/rx/helper.h                      |  12 +-
>   target/rx/op_helper.c                   |  62 +--
>   target/rx/translate.c                   |  14 +-
>   target/s390x/tcg/mem_helper.c           |   2 +-
>   target/sh4/op_helper.c                  |  76 +--
>   target/sparc/fop_helper.c               | 106 ++--
>   target/sparc/helper.c                   |  22 +-
>   target/sparc/int64_helper.c             |   6 +-
>   target/sparc/ldst_helper.c              |  14 +-
>   target/sparc/vis_helper.c               |  94 ++--
>   target/sparc/win_helper.c               |  38 +-
>   target/tricore/fpu_helper.c             |  32 +-
>   target/tricore/helper.h                 |  14 +-
>   target/tricore/op_helper.c              | 220 ++++----
>   target/tricore/translate.c              |  14 +-
>   107 files changed, 2789 insertions(+), 2739 deletions(-)
> 

Sent v2, after partial merge:
https://lore.kernel.org/qemu-devel/20261024163249.77855-1-pierrick.bouvier@oss.qualcomm.com/T/#t

Regards,
Pierrick
Re: [PATCH 00/26] multi-target: prefix helpers with target prefix
Posted by Pierrick Bouvier 1 month ago
On 10/19/2026 2:20 PM, Pierrick Bouvier wrote:
> When linking multiple targets together, we usually have conflicts with helper
> names. So far, it was solved using ad-hoc renaming, but multiple people pointed it
> would be better to have a general mechanism for it, so here it is.
> 
> A previous series attempted that:
> https://lore.kernel.org/qemu-devel/20260930073935.712-1-luoyonggang@gmail.com/,
> but it was relying on (binary) symbol renaming, which is not a portable solution.
> Instead, this series approaches the problem from source code directly.
> It requires more change, but it's cleaner IMHO.
> 
> Series follows these steps:
> 
> First, we make sure all helpers and definition are using HELPER() macro. A lot
> of helpers were already defined this way, we just make sure it's exhaustive.
> After that we don't have any 'helper_' left on any target code. This is a big
> change touching the whole codebase, but it's a simple mechanical change. As long
> as it compiles and links, we know it's correct.
> 
> Then, we introduce the prefix for target helpers. For this , we add a new define
> (from meson) that applies to all target related code. It could later be used to
> prefix other symbols also, that's why it's not named "TCG".
> 
> Finally, we cleanup the previous manual helpers prefix that were added in
> codebase.
>

@Richard: does that series works for you?

Since it's touching all targets, I would try to upstream this before the
freeze on November 2 (ideally end of this week or early next week), to
limit conflicts with all the people sending changes touching to any helper.

Regards,
Pierrick
Re: [PATCH 00/26] multi-target: prefix helpers with target prefix
Posted by Anton Johansson via qemu development 1 month ago
On 19/10/26, Pierrick Bouvier wrote:
> When linking multiple targets together, we usually have conflicts with helper
> names. So far, it was solved using ad-hoc renaming, but multiple people pointed it
> would be better to have a general mechanism for it, so here it is.
> 
> A previous series attempted that:
> https://lore.kernel.org/qemu-devel/20260930073935.712-1-luoyonggang@gmail.com/,
> but it was relying on (binary) symbol renaming, which is not a portable solution.
> Instead, this series approaches the problem from source code directly.
> It requires more change, but it's cleaner IMHO.
> 
> Series follows these steps:
> 
> First, we make sure all helpers and definition are using HELPER() macro. A lot
> of helpers were already defined this way, we just make sure it's exhaustive.
> After that we don't have any 'helper_' left on any target code. This is a big
> change touching the whole codebase, but it's a simple mechanical change. As long
> as it compiles and links, we know it's correct.
> 
> Then, we introduce the prefix for target helpers. For this , we add a new define
> (from meson) that applies to all target related code. It could later be used to
> prefix other symbols also, that's why it's not named "TCG".
> 
> Finally, we cleanup the previous manual helpers prefix that were added in
> codebase.
> 
> Pierrick Bouvier (26):
>   target/alpha: define and call helpers using HELPER macro
>   target/arm: define and call helpers using HELPER macro
>   target/avr: define and call helpers using HELPER macro
>   target/hppa: define and call helpers using HELPER macro
>   target/i386: define and call helpers using HELPER macro
>   target/loongarch: define and call helpers using HELPER macro
>   target/m68k: define and call helpers using HELPER macro
>   target/microblaze: define and call helpers using HELPER macro
>   target/mips: define and call helpers using HELPER macro
>   target/or1k: define and call helpers using HELPER macro
>   target/ppc: define and call helpers using HELPER macro
>   target/riscv: define and call helpers using HELPER macro
>   target/rx: define and call helpers using HELPER macro
>   target/s390x: define and call helpers using HELPER macro
>   target/sh4: define and call helpers using HELPER macro
>   target/sparc: define and call helpers using HELPER macro
>   target/tricore: define and call helpers using HELPER macro
>   tcg: introduce HELPER_INFO macro
>   tcg: prefix helpers with target base architecture
>   target/alpha: remove explicit target specific prefix
>   target/hexagon: remove explicit target specific prefix
>   target/hppa: remove explicit target specific prefix
>   target/microblaze: remove explicit target specific prefix
>   target/or1k: remove explicit target specific prefix
>   target/rx: remove explicit target specific prefix
>   target/tricore: remove explicit target specific prefix

Hi, since this allows us to link different targets together with clashing
helper names, what about going one step further to allow symbol
collisions between say riscv32/64 etc.? It would make converting targets
to heterogeoneous emulation much easier since you could just compile
op_helper.c and translate.c twice and select different function pointers
based on target_*().

When I played around with this I ended up splitting helper.h in to
helper-common.h and helper-target.h, where the latter would get an extra
helper_*_tl32_*() prefix and could be compiled twice. But I recall you
mentioning this might be too much helper magic.

Just throwing ideas out there, either way the current series is good.

Series:
Reviewed-by: Anton Johansson <anjo@rev.ng>
Re: [PATCH 00/26] multi-target: prefix helpers with target prefix
Posted by Pierrick Bouvier 1 month ago
On 10/22/2026 5:57 AM, Anton Johansson wrote:
> On 19/10/26, Pierrick Bouvier wrote:
>> When linking multiple targets together, we usually have conflicts with helper
>> names. So far, it was solved using ad-hoc renaming, but multiple people pointed it
>> would be better to have a general mechanism for it, so here it is.
>>
>> A previous series attempted that:
>> https://lore.kernel.org/qemu-devel/20260930073935.712-1-luoyonggang@gmail.com/,
>> but it was relying on (binary) symbol renaming, which is not a portable solution.
>> Instead, this series approaches the problem from source code directly.
>> It requires more change, but it's cleaner IMHO.
>>
>> Series follows these steps:
>>
>> First, we make sure all helpers and definition are using HELPER() macro. A lot
>> of helpers were already defined this way, we just make sure it's exhaustive.
>> After that we don't have any 'helper_' left on any target code. This is a big
>> change touching the whole codebase, but it's a simple mechanical change. As long
>> as it compiles and links, we know it's correct.
>>
>> Then, we introduce the prefix for target helpers. For this , we add a new define
>> (from meson) that applies to all target related code. It could later be used to
>> prefix other symbols also, that's why it's not named "TCG".
>>
>> Finally, we cleanup the previous manual helpers prefix that were added in
>> codebase.
>>
>> Pierrick Bouvier (26):
>>   target/alpha: define and call helpers using HELPER macro
>>   target/arm: define and call helpers using HELPER macro
>>   target/avr: define and call helpers using HELPER macro
>>   target/hppa: define and call helpers using HELPER macro
>>   target/i386: define and call helpers using HELPER macro
>>   target/loongarch: define and call helpers using HELPER macro
>>   target/m68k: define and call helpers using HELPER macro
>>   target/microblaze: define and call helpers using HELPER macro
>>   target/mips: define and call helpers using HELPER macro
>>   target/or1k: define and call helpers using HELPER macro
>>   target/ppc: define and call helpers using HELPER macro
>>   target/riscv: define and call helpers using HELPER macro
>>   target/rx: define and call helpers using HELPER macro
>>   target/s390x: define and call helpers using HELPER macro
>>   target/sh4: define and call helpers using HELPER macro
>>   target/sparc: define and call helpers using HELPER macro
>>   target/tricore: define and call helpers using HELPER macro
>>   tcg: introduce HELPER_INFO macro
>>   tcg: prefix helpers with target base architecture
>>   target/alpha: remove explicit target specific prefix
>>   target/hexagon: remove explicit target specific prefix
>>   target/hppa: remove explicit target specific prefix
>>   target/microblaze: remove explicit target specific prefix
>>   target/or1k: remove explicit target specific prefix
>>   target/rx: remove explicit target specific prefix
>>   target/tricore: remove explicit target specific prefix
> 
> Hi, since this allows us to link different targets together with clashing
> helper names, what about going one step further to allow symbol
> collisions between say riscv32/64 etc.? It would make converting targets
> to heterogeoneous emulation much easier since you could just compile
> op_helper.c and translate.c twice and select different function pointers
> based on target_*().
>

We had this idea also while working on arm/aarch64, and resisted the
temptation. That said, it was only because the code was correctly
splitted in different files between 32/64 variant.
For riscv32/64, I can understand it's a different challenge, and it
would be worth exploring the idea if it's not easy to split
implementation between 32 and 64 parts.
I remember that Richard was more inclined to do the proper refactoring
required for other targets though.

Regarding current series, when the time come, we can simply replace
TARGET_ARCH_PREFIX to use the full target_arch, instead of just
target_base_arch.

In all cases, if you want to demonstrate this (on one file only to save
your time and energy), feel free to send a series exploring this
approach so we can talk about it.

> When I played around with this I ended up splitting helper.h in to
> helper-common.h and helper-target.h, where the latter would get an extra
> helper_*_tl32_*() prefix and could be compiled twice. But I recall you
> mentioning this might be too much helper magic.
>

I'm not a big fan of preprocessor usage to create duplicated definition
of macros, but it's a personal preference, not a general truth.

In case it helps with duplicated compilation of files you mentioned
above, feel free to show an example using it. I suspect it won't be
needed with current series though.

> Just throwing ideas out there, either way the current series is good.
> 
> Series:
> Reviewed-by: Anton Johansson <anjo@rev.ng>
Re: [PATCH 00/26] multi-target: prefix helpers with target prefix
Posted by Yonggang Luo 1 month ago
On Thu, Oct 22, 2026 at 8:52 PM Anton Johansson via qemu development
<qemu-devel@nongnu.org> wrote:
>
> On 19/10/26, Pierrick Bouvier wrote:
> > When linking multiple targets together, we usually have conflicts with helper
> > names. So far, it was solved using ad-hoc renaming, but multiple people pointed it
> > would be better to have a general mechanism for it, so here it is.
> >
> > A previous series attempted that:
> > https://lore.kernel.org/qemu-devel/20260930073935.712-1-luoyonggang@gmail.com/,
> > but it was relying on (binary) symbol renaming, which is not a portable solution.
> > Instead, this series approaches the problem from source code directly.
> > It requires more change, but it's cleaner IMHO.
> >
> > Series follows these steps:
> >
> > First, we make sure all helpers and definition are using HELPER() macro. A lot
> > of helpers were already defined this way, we just make sure it's exhaustive.
> > After that we don't have any 'helper_' left on any target code. This is a big
> > change touching the whole codebase, but it's a simple mechanical change. As long
> > as it compiles and links, we know it's correct.
> >
> > Then, we introduce the prefix for target helpers. For this , we add a new define
> > (from meson) that applies to all target related code. It could later be used to
> > prefix other symbols also, that's why it's not named "TCG".
> >
> > Finally, we cleanup the previous manual helpers prefix that were added in
> > codebase.
> >
> > Pierrick Bouvier (26):
> >   target/alpha: define and call helpers using HELPER macro
> >   target/arm: define and call helpers using HELPER macro
> >   target/avr: define and call helpers using HELPER macro
> >   target/hppa: define and call helpers using HELPER macro
> >   target/i386: define and call helpers using HELPER macro
> >   target/loongarch: define and call helpers using HELPER macro
> >   target/m68k: define and call helpers using HELPER macro
> >   target/microblaze: define and call helpers using HELPER macro
> >   target/mips: define and call helpers using HELPER macro
> >   target/or1k: define and call helpers using HELPER macro
> >   target/ppc: define and call helpers using HELPER macro
> >   target/riscv: define and call helpers using HELPER macro
> >   target/rx: define and call helpers using HELPER macro
> >   target/s390x: define and call helpers using HELPER macro
> >   target/sh4: define and call helpers using HELPER macro
> >   target/sparc: define and call helpers using HELPER macro
> >   target/tricore: define and call helpers using HELPER macro
> >   tcg: introduce HELPER_INFO macro
> >   tcg: prefix helpers with target base architecture
> >   target/alpha: remove explicit target specific prefix
> >   target/hexagon: remove explicit target specific prefix
> >   target/hppa: remove explicit target specific prefix
> >   target/microblaze: remove explicit target specific prefix
> >   target/or1k: remove explicit target specific prefix
> >   target/rx: remove explicit target specific prefix
> >   target/tricore: remove explicit target specific prefix
>
> Hi, since this allows us to link different targets together with clashing
> helper names, what about going one step further to allow symbol
> collisions between say riscv32/64 etc.? It would make converting targets
> to heterogeoneous emulation much easier since you could just compile
> op_helper.c and translate.c twice and select different function pointers
> based on target_*().

Hi I've done that, do I need to post those patches? and indeed working!
Except, I need to define target_ulong to be always uint64_t. And I tried it for
both riscv/i386.

>
> When I played around with this I ended up splitting helper.h in to
> helper-common.h and helper-target.h, where the latter would get an extra
> helper_*_tl32_*() prefix and could be compiled twice. But I recall you
> mentioning this might be too much helper magic.
>
> Just throwing ideas out there, either way the current series is good.
>
> Series:
> Reviewed-by: Anton Johansson <anjo@rev.ng>
>


-- 
         此致
礼
罗勇刚
Yours
    sincerely,
Yonggang Luo
Re: [PATCH 00/26] multi-target: prefix helpers with target prefix
Posted by Philippe Mathieu-Daudé 1 month ago
On 19/10/26 23:20, Pierrick Bouvier wrote:
> When linking multiple targets together, we usually have conflicts with helper
> names. So far, it was solved using ad-hoc renaming, but multiple people pointed it
> would be better to have a general mechanism for it, so here it is.
> 
> A previous series attempted that:
> https://lore.kernel.org/qemu-devel/20260930073935.712-1-luoyonggang@gmail.com/,
> but it was relying on (binary) symbol renaming, which is not a portable solution.
> Instead, this series approaches the problem from source code directly.
> It requires more change, but it's cleaner IMHO.
> 
> Series follows these steps:
> 
> First, we make sure all helpers and definition are using HELPER() macro. A lot
> of helpers were already defined this way, we just make sure it's exhaustive.
> After that we don't have any 'helper_' left on any target code. This is a big
> change touching the whole codebase, but it's a simple mechanical change. As long
> as it compiles and links, we know it's correct.

I started to do the same manually 3 weeks ago and gave up after
converting the 3rd target, thanks for covering all of them.

> Pierrick Bouvier (26):
>    target/alpha: define and call helpers using HELPER macro
>    target/arm: define and call helpers using HELPER macro
>    target/avr: define and call helpers using HELPER macro
>    target/hppa: define and call helpers using HELPER macro
>    target/i386: define and call helpers using HELPER macro
>    target/loongarch: define and call helpers using HELPER macro
>    target/m68k: define and call helpers using HELPER macro
>    target/microblaze: define and call helpers using HELPER macro
>    target/mips: define and call helpers using HELPER macro
>    target/or1k: define and call helpers using HELPER macro
>    target/ppc: define and call helpers using HELPER macro
>    target/riscv: define and call helpers using HELPER macro
>    target/rx: define and call helpers using HELPER macro
>    target/s390x: define and call helpers using HELPER macro
>    target/sh4: define and call helpers using HELPER macro
>    target/sparc: define and call helpers using HELPER macro

patches 1 to 17:
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>


Re: [PATCH 00/26] multi-target: prefix helpers with target prefix
Posted by Yonggang Luo 1 month ago
On Tue, Oct 20, 2026 at 5:22 AM Pierrick Bouvier
<pierrick.bouvier@oss.qualcomm.com> wrote:
>
> When linking multiple targets together, we usually have conflicts with helper
> names. So far, it was solved using ad-hoc renaming, but multiple people pointed it
> would be better to have a general mechanism for it, so here it is.
>
> A previous series attempted that:
> https://lore.kernel.org/qemu-devel/20260930073935.712-1-luoyonggang@gmail.com/,
> but it was relying on (binary) symbol renaming, which is not a portable solution.
> Instead, this series approaches the problem from source code directly.
> It requires more change, but it's cleaner IMHO.


Hi Pierrick
thanks, this is what I want, I was thinking of this way, just changed
too much, so I am
worried about so many changes.

I have a bad feeling that my patch has so many magic macros, your way
is decent.

Series:
Acked-by: Yonggang Luo <luoyonggang@gmail.com>


>
> Series follows these steps:
>
> First, we make sure all helpers and definition are using HELPER() macro. A lot
> of helpers were already defined this way, we just make sure it's exhaustive.
> After that we don't have any 'helper_' left on any target code. This is a big
> change touching the whole codebase, but it's a simple mechanical change. As long
> as it compiles and links, we know it's correct.
>
> Then, we introduce the prefix for target helpers. For this , we add a new define
> (from meson) that applies to all target related code. It could later be used to
> prefix other symbols also, that's why it's not named "TCG".
>
> Finally, we cleanup the previous manual helpers prefix that were added in
> codebase.
>
> Pierrick Bouvier (26):
>   target/alpha: define and call helpers using HELPER macro
>   target/arm: define and call helpers using HELPER macro
>   target/avr: define and call helpers using HELPER macro
>   target/hppa: define and call helpers using HELPER macro
>   target/i386: define and call helpers using HELPER macro
>   target/loongarch: define and call helpers using HELPER macro
>   target/m68k: define and call helpers using HELPER macro
>   target/microblaze: define and call helpers using HELPER macro
>   target/mips: define and call helpers using HELPER macro
>   target/or1k: define and call helpers using HELPER macro
>   target/ppc: define and call helpers using HELPER macro
>   target/riscv: define and call helpers using HELPER macro
>   target/rx: define and call helpers using HELPER macro
>   target/s390x: define and call helpers using HELPER macro
>   target/sh4: define and call helpers using HELPER macro
>   target/sparc: define and call helpers using HELPER macro
>   target/tricore: define and call helpers using HELPER macro
>   tcg: introduce HELPER_INFO macro
>   tcg: prefix helpers with target base architecture
>   target/alpha: remove explicit target specific prefix
>   target/hexagon: remove explicit target specific prefix
>   target/hppa: remove explicit target specific prefix
>   target/microblaze: remove explicit target specific prefix
>   target/or1k: remove explicit target specific prefix
>   target/rx: remove explicit target specific prefix
>   target/tricore: remove explicit target specific prefix
>
>  include/exec/helper-gen-common.h        |   7 +
>  include/exec/helper-gen.h.inc           |  48 +-
>  include/exec/helper-head.h.inc          |   8 +-
>  include/exec/helper-info.c.inc          |  16 +-
>  include/exec/helper-proto-common.h      |   7 +
>  meson.build                             |   2 +
>  target/alpha/clk_helper.c               |   2 +-
>  target/alpha/fpu_helper.c               |  60 +--
>  target/alpha/helper.c                   |   6 +-
>  target/alpha/helper.h                   |   2 +-
>  target/alpha/int_helper.c               |  38 +-
>  target/alpha/sys_helper.c               |  12 +-
>  target/alpha/translate.c                |   4 +-
>  target/alpha/vax_helper.c               |  42 +-
>  target/arm/tcg/helper-a64.c             |   6 +-
>  target/arm/tcg/mve_helper.c             |  28 +-
>  target/arm/tcg/psci.c                   |   2 +-
>  target/arm/tcg/sme_helper.c             |   4 +-
>  target/arm/tcg/sve_helper.c             | 141 ++---
>  target/arm/tcg/tlb_helper.c             |   2 +-
>  target/arm/tcg/vec_helper.c             |  72 +--
>  target/arm/tcg/vec_helper64.c           |  64 +--
>  target/arm/tcg/vec_internal.h           |   5 +-
>  target/avr/helper.c                     |  12 +-
>  target/hexagon/gen_tcg.h                |   2 +-
>  target/hexagon/gen_tcg_sys.h            |   2 +-
>  target/hexagon/helper.h                 |   4 +-
>  target/hexagon/op_helper.c              |   4 +-
>  target/hexagon/translate.c              |   4 +-
>  target/hppa/fpu_helper.c                |   2 +-
>  target/hppa/helper.h                    |   6 +-
>  target/hppa/op_helper.c                 |   4 +-
>  target/hppa/sys_helper.c                |  10 +-
>  target/hppa/translate.c                 |   6 +-
>  target/i386/ops_sse.h                   | 401 +++++++-------
>  target/i386/tcg/bpt_helper.c            |   6 +-
>  target/i386/tcg/cc_helper.c             |  14 +-
>  target/i386/tcg/excp_helper.c           |   8 +-
>  target/i386/tcg/fpu_helper.c            | 182 +++----
>  target/i386/tcg/int_helper.c            |  34 +-
>  target/i386/tcg/mem_helper.c            |   4 +-
>  target/i386/tcg/misc_helper.c           |  16 +-
>  target/i386/tcg/mpx_helper.c            |  12 +-
>  target/i386/tcg/seg_helper.c            |  32 +-
>  target/i386/tcg/system/bpt_helper.c     |   6 +-
>  target/i386/tcg/system/misc_helper.c    |  32 +-
>  target/i386/tcg/system/seg_helper.c     |   4 +-
>  target/i386/tcg/system/smm_helper.c     |  12 +-
>  target/i386/tcg/system/svm_helper.c     |  16 +-
>  target/i386/tcg/user/seg_helper.c       |   4 +-
>  target/loongarch/tcg/csr_helper.c       |  22 +-
>  target/loongarch/tcg/fpu_helper.c       | 126 ++---
>  target/loongarch/tcg/iocsr_helper.c     |  16 +-
>  target/loongarch/tcg/op_helper.c        |  18 +-
>  target/loongarch/tcg/tlb_helper.c       |  26 +-
>  target/loongarch/tcg/vec_helper.c       |   4 +-
>  target/m68k/op_helper.c                 |   2 +-
>  target/microblaze/helper.h              |  10 +-
>  target/microblaze/op_helper.c           |  46 +-
>  target/microblaze/translate.c           |  10 +-
>  target/mips/tcg/dsp_helper.c            | 187 +++----
>  target/mips/tcg/exception.c             |   8 +-
>  target/mips/tcg/fpu_helper.c            | 291 +++++-----
>  target/mips/tcg/ldst_helper.c           |  18 +-
>  target/mips/tcg/lmmi_helper.c           |  98 ++--
>  target/mips/tcg/msa_helper.c            | 690 ++++++++++++------------
>  target/mips/tcg/octeon_crypto.c         | 100 ++--
>  target/mips/tcg/op_helper.c             |  34 +-
>  target/mips/tcg/system/cp0_helper.c     | 276 +++++-----
>  target/mips/tcg/system/lcsr_helper.c    |   8 +-
>  target/mips/tcg/system/special_helper.c |  12 +-
>  target/mips/tcg/system/tlb_helper.c     |  14 +-
>  target/mips/tcg/vr54xx_helper.c         |  30 +-
>  target/or1k/fpu_helper.c                |  16 +-
>  target/or1k/helper.h                    |   2 +-
>  target/or1k/interrupt_helper.c          |   2 +-
>  target/or1k/translate.c                 |   2 +-
>  target/ppc/dfp_helper.c                 |  52 +-
>  target/ppc/fpu_helper.c                 | 396 +++++++-------
>  target/ppc/int_helper.c                 | 292 +++++-----
>  target/ppc/internal.h                   |   7 +-
>  target/ppc/mem_helper.c                 |  28 +-
>  target/ppc/misc_helper.c                |  56 +-
>  target/ppc/mmu-hash64.c                 |  18 +-
>  target/ppc/mmu_helper.c                 |  70 +--
>  target/ppc/power8-pmu.c                 |  14 +-
>  target/ppc/tcg-excp_helper.c            |  56 +-
>  target/ppc/timebase_helper.c            |  54 +-
>  target/ppc/translate/vsx-impl.c.inc     |   2 +-
>  target/riscv/tcg/debug.c                |   2 +-
>  target/riscv/tcg/fpu_helper.c           | 196 +++----
>  target/riscv/tcg/op_helper.c            |  74 +--
>  target/rx/helper.h                      |  12 +-
>  target/rx/op_helper.c                   |  62 +--
>  target/rx/translate.c                   |  14 +-
>  target/s390x/tcg/mem_helper.c           |   2 +-
>  target/sh4/op_helper.c                  |  76 +--
>  target/sparc/fop_helper.c               | 106 ++--
>  target/sparc/helper.c                   |  22 +-
>  target/sparc/int64_helper.c             |   6 +-
>  target/sparc/ldst_helper.c              |  14 +-
>  target/sparc/vis_helper.c               |  94 ++--
>  target/sparc/win_helper.c               |  38 +-
>  target/tricore/fpu_helper.c             |  32 +-
>  target/tricore/helper.h                 |  14 +-
>  target/tricore/op_helper.c              | 220 ++++----
>  target/tricore/translate.c              |  14 +-
>  107 files changed, 2789 insertions(+), 2739 deletions(-)
>
> --
> 2.43.0
>
>


-- 
         此致
礼
罗勇刚
Yours
    sincerely,
Yonggang Luo