[PATCH v6 000/100] tcg: Generic expansion of most operations

Richard Henderson posted 100 patches 2 days, 6 hours ago
accel/tcg/tcg-runtime.h                    |   10 -
include/qemu/compiler.h                    |    8 +
include/tcg/tcg-op-common.h                |  556 ++--
include/tcg/tcg-op-mem.h                   |   36 +-
include/tcg/tcg-temp-internal.h            |    2 +
include/tcg/tcg.h                          |   61 +-
tcg/tcg-internal.h                         |  160 +-
include/tcg/tcg-op-def.h.inc               |  110 +
accel/tcg/tcg-runtime.c                    |   44 -
tcg/tcg-op-gvec.c                          |   41 -
tcg/tcg-op-ldst.c                          |  734 ++---
tcg/tcg-op.c                               | 3030 +++++++-------------
tcg/tcg.c                                  |    8 +
target/ppc/translate/fixedpoint-impl.c.inc |    4 +-
14 files changed, 1834 insertions(+), 2970 deletions(-)
create mode 100644 include/tcg/tcg-op-def.h.inc
[PATCH v6 000/100] tcg: Generic expansion of most operations
Posted by Richard Henderson 2 days, 6 hours ago
This eliminates the majority of the code duplication between
the _i32 and _i64 expanders.  What remains are those expanders
that truly differ between the two widths, or that are only
present for one width.

Changes for v6:
  - No __attribute__((alias)), since unsupported on MacOS.
  - Constants canonicalized in tcg_constant_internal, as pointed out in review.
  - Other flubs fixed, also per review.


r~


Richard Henderson (100):
  include/qemu/compiler: Add QEMU_*_NONNULL attributes
  tcg: Annontate functions in tcg.h with QEMU_*_NONNULL
  tcg: Annontate functions in tcg-op-mem.h with QEMU_*_NONNULL
  tcg: Annontate functions in tcg-internal.h with QEMU_*_NONNULL
  tcg: Prepare for easy temp lifetimes
  tcg: Enforce sign-extension for TCG_TYPE_I32 in tcg_constant_internal
  tcg: Generic expansion of tcg_gen_mov_*
  tcg: Generic expansion of tcg_gen_movi_*
  tcg: Generic expansion of tcg_gen_discard_*
  tcg: Generic expansion of tcg_gen_add_*
  tcg: Generic expansion of tcg_gen_addi_*
  tcg: Generic expansion of tcg_gen_sub_*
  tcg: Generic expansion of tcg_gen_subi_*
  tcg: Generic expansion of tcg_gen_neg_*
  tcg: Generic expansion of tcg_gen_subfi_*
  tcg: Generic expansion of tcg_gen_and_*
  tcg: Generic expansion of tcg_gen_or_*
  tcg: Generic expansion of tcg_gen_xor_*
  tcg: Generic expansion of tcg_gen_shl_*
  tcg: Generic expansion of tcg_gen_shr_*
  tcg: Generic expansion of tcg_gen_sar_*
  tcg: Generic expansion of tcg_gen_mul_*
  tcg: Generic expansion of tcg_gen_shli_*
  tcg: Generic expansion of tcg_gen_shri_*
  tcg: Generic expansion of tcg_gen_sari_*
  tcg: Generic expansion of tcg_gen_andi_*
  tcg: Generic expansion of tcg_gen_ori_*
  tcg: Generic expansion of tcg_gen_xori_*
  tcg: Generic expansion of tcg_gen_muli_*
  tcg: Generic expansion of tcg_gen_not_*
  tcg: Drop division helpers
  tcg: Generic expansion of tcg_gen_div_*
  tcg: Generic expansion of tcg_gen_rem_*
  tcg: Generic expansion of tcg_gen_divu_*
  tcg: Generic expansion of tcg_gen_remu_*
  tcg: Generic expansion of tcg_gen_andc_*
  tcg: Generic expansion of tcg_gen_eqv_*
  tcg: Generic expansion of tcg_gen_nand_*
  tcg: Generic expansion of tcg_gen_nor_*
  tcg: Generic expansion of tcg_gen_orc_*
  tcg: Generic expansion of tcg_gen_brcond_*
  tcg: Generic expansion of tcg_gen_brcondi_*
  tcg: Generic expansion of tcg_gen_setcond_*
  tcg: Generic expansion of tcg_gen_setcondi_*
  tcg: Generic expansion of tcg_gen_negsetcond_*
  tcg: Generic expansion of tcg_gen_negsetcondi_*
  tcg: Generic expansion of tcg_gen_movcond_*
  tcg: Split out tcg_gen_ext{rl,rh,s,u}
  tcg: Convert ext/trunc from TCGv_ptr to the new interfaces
  tcg: Generic expansion of tcg_gen_clz_*
  tcg: Use signed integer for tcg_gen_{clz,ctz}i_{i32,i64}
  tcg: Generic expansion of tcg_gen_clzi_*
  tcg: Generic expansion of tcg_gen_ctpop_*
  tcg: Generic expansion of tcg_gen_ctz_*
  tcg: Generic expansion of tcg_gen_ctzi_*
  tcg: Generic expansion of tcg_gen_clrsb_*
  tcg: Generic expansion of tcg_gen_rotl_*
  tcg: Generic expansion of tcg_gen_rotr_*
  tcg: Generic expansion of tcg_gen_rotri_*
  tcg: Generic expansion of tcg_gen_rotli_*
  tcg: Generic expansion of tcg_gen_deposit_*
  tcg: Generic expansion of tcg_gen_extract_*
  tcg: Generic expansion of tcg_gen_sextract_*
  tcg: Generic expansion of tcg_gen_deposit_z_*
  tcg: Generic expansion of tcg_gen_ext8s_*
  tcg: Generic expansion of tcg_gen_ext8u_*
  tcg: Generic expansion of tcg_gen_ext16s_*
  tcg: Generic expansion of tcg_gen_ext16u_*
  tcg: Generic expansion of tcg_gen_ext_*
  tcg: Generic expansion of tcg_gen_smin_*
  tcg: Generic expansion of tcg_gen_smax_*
  tcg: Generic expansion of tcg_gen_umin_*
  tcg: Generic expansion of tcg_gen_umax_*
  tcg: Generic expansion of tcg_gen_abs_*
  tcg: Generic expansion of tcg_gen_ussub_*
  tcg: Use umax in ussub if available
  tcg: Generic expansion of tcg_gen_extract2_*
  tcg: Generic expansion of tcg_gen_addcio_*
  tcg: Generic expansion of tcg_gen_add2_*
  tcg: Generic expansion of tcg_gen_sub2_*
  tcg: Generic expansion of tcg_gen_mulu2_*
  tcg: Generic expansion of tcg_gen_muls2_*
  tcg: Use unsigned for flags for bswap and revbit operations
  tcg: Generic expansion of tcg_gen_bswap16_*
  tcg: Split out gen_bitswap
  tcg: Generic expansion of tcg_gen_revbit8_*
  tcg: Generic expansion of tcg_gen_ld_*
  tcg: Generic expansion of tcg_gen_ld8s_*
  tcg: Generic expansion of tcg_gen_ld8u_*
  tcg: Generic expansion of tcg_gen_ld16s_*
  tcg: Generic expansion of tcg_gen_ld16u_*
  tcg: Generic expansion of tcg_gen_st_*
  tcg: Generic expansion of tcg_gen_st8_*
  tcg: Generic expansion of tcg_gen_st16_*
  tcg: Generic expansion of tcg_gen_dup_*
  tcg: Generic expansion of tcg_gen_qemu_ld_chk
  tcg: Generic expansion of tcg_gen_qemu_st_chk
  tcg: Generic expansion of tcg_gen_{non}atomic_qemu_cmpxchg_chk
  tcg: Generic expansion of remaining atomic operations
  tcg: Annontate functions in tcg-op-common.h with QEMU_*_NONNULL

 accel/tcg/tcg-runtime.h                    |   10 -
 include/qemu/compiler.h                    |    8 +
 include/tcg/tcg-op-common.h                |  556 ++--
 include/tcg/tcg-op-mem.h                   |   36 +-
 include/tcg/tcg-temp-internal.h            |    2 +
 include/tcg/tcg.h                          |   61 +-
 tcg/tcg-internal.h                         |  160 +-
 include/tcg/tcg-op-def.h.inc               |  110 +
 accel/tcg/tcg-runtime.c                    |   44 -
 tcg/tcg-op-gvec.c                          |   41 -
 tcg/tcg-op-ldst.c                          |  734 ++---
 tcg/tcg-op.c                               | 3030 +++++++-------------
 tcg/tcg.c                                  |    8 +
 target/ppc/translate/fixedpoint-impl.c.inc |    4 +-
 14 files changed, 1834 insertions(+), 2970 deletions(-)
 create mode 100644 include/tcg/tcg-op-def.h.inc

-- 
2.53.0
Re: [PATCH v6 000/100] tcg: Generic expansion of most operations
Posted by Matt Turner 1 day, 22 hours ago
On Wed, Oct 21, 2026 at 10:16 AM Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> This eliminates the majority of the code duplication between
> the _i32 and _i64 expanders.  What remains are those expanders
> that truly differ between the two widths, or that are only
> present for one width.
>
> Changes for v6:
>   - No __attribute__((alias)), since unsupported on MacOS.
>   - Constants canonicalized in tcg_constant_internal, as pointed out in review.
>   - Other flubs fixed, also per review.

I pointed out a bunch of trivial issues. checkpatch.pl also complains
about a things like

ERROR: storage class should be at the beginning of the declaration
#50: FILE: tcg/tcg-internal.h:63:
+QEMU_RET_ARG_NONNULL static inline TCGv_i64 TCGV128_LOW(TCGv_i128 t)

and

ERROR: space required after that ',' (ctx:VxV)
#123: FILE: tcg/tcg-op.c:322:
+    { tcg_gen_##NAME(TYPE, glue(C_,T1)(a), glue(C_,T2)(b), glue(C_,T3)(c)); }

Otherwise, this looks good to me. The whole series is.

Reviewed-by: Matt Turner <mattst88@gmail.com>