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.
r~
Richard Henderson (16):
tcg: Sort all_outop[] by INDEX name
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
include/tcg/tcg-op-common.h | 4 +
include/tcg/tcg-op.h | 2 +
include/tcg/tcg-opc.h | 1 +
tcg/aarch64/tcg-target-has.h | 4 +
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 +
target/alpha/translate.c | 20 ++---
target/i386/tcg/translate.c | 27 +++---
target/s390x/tcg/translate.c | 4 +-
tcg/optimize.c | 65 ++++++++++++++
tcg/tcg-op.c | 90 +++++++++++++++++++
tcg/tcg.c | 61 ++++++++-----
docs/devel/tcg-ops.rst | 4 +
.../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 +++++++++-------
31 files changed, 413 insertions(+), 88 deletions(-)
--
2.53.0