Skip to content

tcg constant pools

Richard Henderson qemu-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest23 patches 3 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/23tcg: Move USE_DIRECT_JUMP discriminator to tcg/cpu/tcg-target.haccel/tcg/cpu-exec.c accel/tcg/translate-all.c include/exec/exec-all.h +14 more+107 -1130 replies
2/23tcg: Rearrange ldst label trackingtcg/aarch64/tcg-target.h tcg/aarch64/tcg-target.inc.c tcg/arm/tcg-target.h +17 more+61 -1061 reply
3/23tcg: Infrastructure for managing constant poolsaccel/tcg/translate-all.c tcg/tcg-pool.inc.c tcg/tcg.c +1 more+119 -10 replies
4/23tcg/i386: Store out-of-range call targets in constant pooltcg/i386/tcg-target.h tcg/i386/tcg-target.inc.c+16 -30 replies
5/23tcg/s390: Introduce TCG_REG_TBtcg/s390/tcg-target.h tcg/s390/tcg-target.inc.c+61 -120 replies
6/23tcg/s390: Fix sign of patch_reloc addendtcg/s390/tcg-target.inc.c+13 -120 replies
7/23tcg/s390: Use constant pool for moviinclude/elf.h tcg/s390/tcg-target.h tcg/s390/tcg-target.inc.c+80 -540 replies
8/23tcg/s390: Use constant pool for anditcg/s390/tcg-target.inc.c+14 -60 replies
9/23tcg/s390: Use constant pool for oritcg/s390/tcg-target.inc.c+34 -400 replies
10/23tcg/s390: Use constant pool for xoritcg/s390/tcg-target.inc.c+40 -370 replies
11/23tcg/s390: Use constant pool for cmpitcg/s390/tcg-target.inc.c+67 -690 replies
12/23tcg/aarch64: Use constant pool for movitcg/aarch64/tcg-target.h tcg/aarch64/tcg-target.inc.c+33 -300 replies
13/23tcg/sparc: Introduce TCG_REG_TBtcg/sparc/tcg-target.inc.c+140 -300 replies
14/23tcg/sparc: Use constant pool for movitcg/sparc/tcg-target.h tcg/sparc/tcg-target.inc.c+58 -210 replies
15/23tcg/arm: Improve tlb load for armv7tcg/arm/tcg-target.inc.c+52 -200 replies
16/23tcg/arm: Tighten tlb indexing offset testtcg/arm/tcg-target.inc.c+3 -10 replies
17/23tcg/arm: Code rearrangementtcg/arm/tcg-target.inc.c+299 -3000 replies
18/23tcg/arm: Extract INSN_NOPtcg/arm/tcg-target.inc.c+11 -100 replies
19/23tcg/arm: Use constant pool for movitcg/arm/tcg-target.h tcg/arm/tcg-target.inc.c+75 -180 replies
20/23tcg/arm: Use constant pool for calltcg/arm/tcg-target.inc.c+3 -60 replies
21/23tcg/ppc: Change TCG_REG_RA to TCG_REG_TBtcg/ppc/tcg-target.inc.c+122 -1510 replies
22/23tcg/ppc: Look for shifted constantstcg/ppc/tcg-target.inc.c+9 -02 replies
23/23tcg/ppc: Use constant pool for movitcg/ppc/tcg-target.h tcg/ppc/tcg-target.inc.c+31 -40 replies

Reviews trailers per patch

1 of 23 patches has a Reviewed-by or Acked-by.

PatchPaolo Bonzini
1/23
2/23R-b
3/23
4/23
5/23
6/23
7/23
8/23
9/23
10/23
11/23
12/23
13/23
14/23
15/23
16/23
17/23
18/23
19/23
20/23
21/23
22/23
23/23

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [Qemu-devel] [PATCH for-2.11 00/23] tcg constant pools

RISC machines often require many instructions in order to construct large constants from the immediate values available to individual instructions. Static compilers like GCC often place these large constants into read-only memory and use one load instruction to fetch the constant instead; a collection of these is known as a "constant pool".

TCG currently generates all constants from immediate values. This can require 4 insns for a full 64-bit value for AArch64, 4 insns for a full 32-bit value for AArch32 v6. s390x z9 needs 4, ppc64 and sparc64 need 5, mips64 needs 6.

Moreover, entries in the constant pool may be used more than once. For instance, if there are 3 consecutive guest stores, then we can enter the host address of helper_le_ldul_mmu into the constant pool once for the 3 call invocations. Depending on the host memory map, the result may be a savings of (4*3*4) - (1*3*4+1*8) = 28 bytes.

This last is even true for the x86_64 host, where

movq $helper_ld_ldul_mmu, %rax; call *%rax

costs 10+6 bytes, but

call *label(%rip); .quad helper_ld_ldul_mmu

costs 6+8 bytes, plus the ability to share the 8 bytes for the entry.

r~

Richard Henderson (23):
tcg: Move USE_DIRECT_JUMP discriminator to tcg/cpu/tcg-target.h
tcg: Rearrange ldst label tracking
tcg: Infrastructure for managing constant pools tcg/i386: Store out-of-range call targets in constant pool tcg/s390: Introduce TCG_REG_TB
tcg/s390: Fix sign of patch_reloc addend
tcg/s390: Use constant pool for movi
tcg/s390: Use constant pool for andi
tcg/s390: Use constant pool for ori
tcg/s390: Use constant pool for xori
tcg/s390: Use constant pool for cmpi
tcg/aarch64: Use constant pool for movi
tcg/sparc: Introduce TCG_REG_TB
tcg/sparc: Use constant pool for movi
tcg/arm: Improve tlb load for armv7
tcg/arm: Tighten tlb indexing offset test
tcg/arm: Code rearrangement
tcg/arm: Extract INSN_NOP
tcg/arm: Use constant pool for movi
tcg/arm: Use constant pool for call
tcg/ppc: Change TCG_REG_RA to TCG_REG_TB
tcg/ppc: Look for shifted constants
tcg/ppc: Use constant pool for movi

 include/elf.h                         |   3 +-
 include/exec/exec-all.h               |  95 +----
 tcg/aarch64/tcg-target.h              |   8 +
 tcg/arm/tcg-target.h                  |   9 +
 tcg/i386/tcg-target.h                 |  14 +
 tcg/ia64/tcg-target.h                 |   8 +
 tcg/mips/tcg-target.h                 |   7 +
 tcg/ppc/tcg-target.h                  |   7 +
 tcg/s390/tcg-target.h                 |  15 +
 tcg/sparc/tcg-target.h                |   5 +
 tcg/tcg-be-null.h                     |  44 --
 tcg/tcg.h                             |  14 +-
 tcg/tci/tcg-target.h                  |   9 +
 accel/tcg/cpu-exec.c                  |  35 ++
 accel/tcg/translate-all.c             |  36 +-
 tcg/aarch64/tcg-target.inc.c          |  78 ++--
 tcg/arm/tcg-target.inc.c              | 780 +++++++++++++++++++---------------
 tcg/i386/tcg-target.inc.c             |  20 +-
 tcg/ia64/tcg-target.inc.c             |  19 +-
 tcg/mips/tcg-target.inc.c             |   7 +-
 tcg/ppc/tcg-target.inc.c              | 320 +++++++-------
 tcg/s390/tcg-target.inc.c             | 527 +++++++++++++----------
 tcg/sparc/tcg-target.inc.c            | 240 ++++++++---
 tcg/{tcg-be-ldst.h => tcg-ldst.inc.c} |  27 +-
 tcg/tcg-pool.inc.c                    |  85 ++++
 tcg/tcg.c                             |  26 +-
 tcg/tci/tcg-target.inc.c              |   2 -
 27 files changed, 1422 insertions(+), 1018 deletions(-)
 delete mode 100644 tcg/tcg-be-null.h
 rename tcg/{tcg-be-ldst.h => tcg-ldst.inc.c} (85%)
 create mode 100644 tcg/tcg-pool.inc.c
Signature · 1 line
2.13.3