Add a complex addressing mode primitive, and some trivial use cases.

This came up in conversation with Matt Turner re his inline jump cache
expansion.  In particular,

-    tcg_gen_shli_i64(h, h, 4);
-    tcg_gen_add_i64(ent, jc, ent);
+    tcg_gen_lea_i64(ent, jc, h, 4, 0);

With the use case in target/i386/tcg, we get nearly full coverage of
all the possible use cases.  The only thing I didn't immediately see
is shifts > 3, which could be visible with loongarch64 guests.

There are plenty of other places in target/ that could use this, but
the shift/add/imm extraction/generation are inconveniently separated.
E.g. m68k address generation, arm add-shifted, etc.

It may not even be worth converting those, but instead adding some
trivial peepholing along the lines of Matt's user-only guest displacement.

Changes in v2:

Based-on: [email protected]
("[PATCH v4 000/101] tcg: Generic expansion of most operations")

Plus other transitive dependencies.  Full tree at

https://gitlab.com/rth7680/qemu/-/tree/tcg-lea


r~


Philippe Mathieu-Daudé (1):
  target/mips: Use tcg_gen_lea() for [D]LSA and MXU S32LD*V opcodes

Richard Henderson (15):
  tcg: Add INDEX_op_lea
  tcg: Add tcg_gen_lea_{i32,i64,tl}
  tcg/optimize: Handle INDEX_op_lea
  target/alpha: Use tcg_gen_lea_i64 for S{4,8}ADD{L,Q}
  target/loongarch: Use tcg_gen_lea_tl for ALSL
  target/riscv: Use tcg_gen_lea_tl for SH*ADD
  target/s390x: Use tcg_gen_lea_i64 in get_address
  target/i386: Use tcg_gen_lea_tl in gen_lea_modrm_1
  tcg/x86_64: Introduce TCG_REG_NONE
  tcg/x86_64: Implement INDEX_op_lea
  tcg/loongarch64: Import SLADD insns
  tcg/loongarch64: Implement INDEX_op_lea
  tcg/aarch64: Implement INDEX_op_lea
  tcg/riscv64: Implement INDEX_op_lea
  tcg/s390x: Implement INDEX_op_lea

 docs/devel/tcg-ops.rst                        |  4 +
 include/tcg/tcg-op.h                          |  2 +
 include/tcg/tcg-opc.h                         |  1 +
 tcg/aarch64/tcg-target-has.h                  |  3 +
 tcg/loongarch64/tcg-target-has.h              |  3 +
 tcg/ppc64/tcg-target-has.h                    |  3 +
 tcg/riscv64/tcg-target-has.h                  | 11 +++
 tcg/s390x/tcg-target-has.h                    |  4 +
 tcg/sparc64/tcg-target-has.h                  |  3 +
 tcg/tci/tcg-target-has.h                      |  3 +
 tcg/x86_64/tcg-target-con-set.h               |  1 +
 tcg/x86_64/tcg-target-has.h                   |  3 +
 tcg/x86_64/tcg-target.h                       |  3 +
 include/tcg/tcg-op-def.h.inc                  |  1 +
 target/alpha/translate.c                      | 20 ++---
 target/i386/tcg/translate.c                   | 27 ++++---
 target/mips/tcg/mxu_translate.c               |  3 +-
 target/mips/tcg/translate_addr_const.c        |  6 +-
 target/s390x/tcg/translate.c                  |  4 +-
 tcg/optimize.c                                | 66 +++++++++++++++-
 tcg/tcg-op.c                                  | 43 ++++++++++
 tcg/tcg.c                                     | 22 ++++++
 .../tcg/insn_trans/trans_arith.c.inc          |  4 +-
 target/riscv/tcg/insn_trans/trans_rvb.c.inc   |  5 +-
 tcg/aarch64/tcg-target.c.inc                  | 11 +++
 tcg/loongarch64/tcg-insn-defs.c.inc           | 30 ++++++-
 tcg/loongarch64/tcg-target.c.inc              | 15 ++++
 tcg/ppc64/tcg-target.c.inc                    |  3 +
 tcg/riscv64/tcg-target.c.inc                  | 17 ++++
 tcg/s390x/tcg-target.c.inc                    | 14 ++++
 tcg/sparc64/tcg-target.c.inc                  |  3 +
 tcg/tci/tcg-target.c.inc                      |  4 +
 tcg/x86_64/tcg-target.c.inc                   | 79 +++++++++++--------
 33 files changed, 346 insertions(+), 75 deletions(-)

-- 
2.53.0


Reply via email to