mbox series

[00/76] tcg: Drop tcg_temp_free from translators

Message ID 20230225091427.1817156-1-richard.henderson@linaro.org
Headers show
Series tcg: Drop tcg_temp_free from translators | expand

Message

Richard Henderson Feb. 25, 2023, 9:13 a.m. UTC
Based-on: 20230225085945.1798188-1-richard.henderson@linaro.org
("[PATCH v3 00/30] tcg: Simplify temporary usage")

In the above patch set, we changed the lifetime of the temps
allocated by the guest translators, and eliminated their reuse,
so that we have the best chance of reducing their strength.

That we don't reuse them means that we gain nothing by freeing them.
Therefore, drop all mention of tcg_temp_free from target/.

This may be the most negative diffstat I've ever produced.  :-)

r~

Richard Henderson (76):
  tcg: Remove tcg_check_temp_count, tcg_clear_temp_count
  accel/tcg: Remove translator_loop_temp_check
  target/alpha: Drop tcg_temp_free
  target/arm: Remove arm_free_cc, a64_free_cc
  target/arm: Remove value_global from DisasCompare
  target/arm: Drop tcg_temp_free from translator.c
  target/arm: Drop DisasContext.tmp_a64
  target/arm: Drop new_tmp_a64
  target/arm: Drop new_tmp_a64_zero
  target/arm: Drop tcg_temp_free from translator-a64.c
  target/arm: Drop tcg_temp_free from translator-m-nocp.c
  target/arm: Drop tcg_temp_free from translator-mve.c
  target/arm: Drop tcg_temp_free from translator-neon.c
  target/arm: Drop tcg_temp_free from translator-sme.c
  target/arm: Drop tcg_temp_free from translator-sve.c
  target/arm: Drop tcg_temp_free from translator-vfp.c
  target/arm: Drop tcg_temp_free from translator.h
  target/avr: Drop DisasContext.free_skip_var0
  target/avr: Drop R from trans_COM
  target/avr: Drop tcg_temp_free
  target/cris: Drop cris_alu_free_temps
  target/cris: Drop cris_alu_m_free_temps
  target/cris: Drop addr from dec10_ind_move_m_pr
  target/cris: Drop tcg_temp_free
  target/cris: Drop tcg_temp_free from C code
  target/cris: Drop tcg_temp_free from gen_tcg_funcs.py
  target/hexagon/idef-parser: Drop tcg_temp_free
  target/hexagon/idef-parser: Drop HexValue.is_manual
  target/hppa: Drop tcg_temp_free
  target/i386: Drop tcg_temp_free
  target/loongarch: Drop temp_new
  target/loongarch: Drop tcg_temp_free
  target/m68k: Drop mark_to_release
  target/m68k: Drop free_cond
  target/m68k: Drop tcg_temp_free
  target/microblaze: Drop tcg_temp_free
  target/mips: Drop tcg_temp_free from micromips_translate.c.inc
  target/mips: Drop tcg_temp_free from mips16e_translate.c.inc
  target/mips: Drop tcg_temp_free from msa_translate.c
  target/mips: Drop tcg_temp_free from mxu_translate.c
  target/mips: Drop tcg_temp_free from nanomips_translate.c.inc
  target/mips: Drop tcg_temp_free from octeon_translate.c
  target/mips: Drop tcg_temp_free from translate_addr_const.c
  target/mips: Drop tcg_temp_free from tx79_translate.c
  target/mips: Fix trans_mult_acc return
  target/mips: Drop tcg_temp_free from vr54xx_translate.c
  target/mips: Drop tcg_temp_free from translate.c
  target/nios2: Drop tcg_temp_free
  target/openrisc: Drop tcg_temp_free
  target/ppc: Drop tcg_temp_free
  target/riscv: Drop ftemp_new
  target/riscv: Drop temp_new
  target/riscv: Drop tcg_temp_free
  target/rx: Drop tcg_temp_free
  target/s390x: Use tcg_constant_* in local contexts
  target/s390x: Use tcg_constant_* for DisasCompare
  target/s390x: Use tcg_constant_i32 for fpinst_extract_m34
  target/s390x: Use tcg_constant_* in translate_vx.c.inc
  target/s390x: Drop free_compare
  target/s390x: Drop tcg_temp_free from translate_vx.c.inc
  target/s390x: Drop tcg_temp_free from translate.c
  target/s390x: Remove assert vs g_in2
  target/s390x: Remove g_out, g_out2, g_in1, g_in2 from DisasContext
  target/sh4: Drop tcg_temp_free
  target/sparc: Drop get_temp_tl
  target/sparc: Drop get_temp_i32
  target/sparc: Remove egress label in disas_sparc_context
  target/sparc: Drop free_compare
  target/sparc: Drop tcg_temp_free
  target/tricore: Drop tcg_temp_free
  target/sparc: Drop reset_sar_tracker
  target/xtensa: Drop tcg_temp_free
  include/exec/gen-icount: Drop tcg_temp_free in gen_tb_start
  tracing: remove transform.py
  tcg: Create tcg/tcg-temp-internal.h
  docs/devel/tcg-ops: Drop recommendation to free temps

 docs/devel/tcg-ops.rst                        |   4 -
 target/hexagon/idef-parser/README.rst         |   8 -
 meson.build                                   |   1 -
 include/exec/gen-icount.h                     |   2 -
 include/exec/translator.h                     |   2 -
 include/tcg/tcg-temp-internal.h               |  83 +++
 include/tcg/tcg.h                             |  68 --
 target/arm/translate-a64.h                    |   2 -
 target/arm/translate.h                        |   7 -
 target/hexagon/gen_tcg.h                      |  29 -
 target/hexagon/gen_tcg_hvx.h                  |  15 -
 target/hexagon/idef-parser/idef-parser.h      |   1 -
 target/hexagon/idef-parser/parser-helpers.h   |   4 -
 target/hexagon/macros.h                       |   7 -
 target/loongarch/translate.h                  |   3 -
 accel/tcg/plugin-gen.c                        |   1 +
 accel/tcg/translator.c                        |  16 -
 target/alpha/translate.c                      |  71 --
 target/arm/translate-a64.c                    | 594 ++--------------
 target/arm/translate-m-nocp.c                 |  20 -
 target/arm/translate-mve.c                    |  52 --
 target/arm/translate-neon.c                   | 131 +---
 target/arm/translate-sme.c                    |  28 -
 target/arm/translate-sve.c                    | 206 +-----
 target/arm/translate-vfp.c                    | 193 -----
 target/arm/translate.c                        | 281 +-------
 target/avr/translate.c                        | 251 -------
 target/cris/translate.c                       | 113 ---
 target/hexagon/genptr.c                       |  58 --
 target/hexagon/idef-parser/parser-helpers.c   | 158 -----
 target/hexagon/translate.c                    |   7 -
 target/hppa/translate.c                       |  93 +--
 target/i386/tcg/translate.c                   |  41 --
 target/loongarch/translate.c                  |  21 +-
 target/m68k/translate.c                       | 276 +-------
 target/microblaze/translate.c                 |  54 --
 target/mips/tcg/msa_translate.c               |   9 -
 target/mips/tcg/mxu_translate.c               |  51 --
 target/mips/tcg/octeon_translate.c            |  23 -
 target/mips/tcg/translate.c                   | 537 +-------------
 target/mips/tcg/translate_addr_const.c        |   7 -
 target/mips/tcg/tx79_translate.c              |  41 --
 target/mips/tcg/vr54xx_translate.c            |   6 +-
 target/nios2/translate.c                      |  15 -
 target/openrisc/translate.c                   |  39 -
 target/ppc/translate.c                        | 285 --------
 target/riscv/translate.c                      |  61 +-
 target/rx/translate.c                         |  84 ---
 target/s390x/tcg/translate.c                  | 668 +++++-------------
 target/sh4/translate.c                        | 110 ---
 target/sparc/translate.c                      | 259 +------
 target/tricore/translate.c                    | 540 +-------------
 target/xtensa/translate.c                     | 121 +---
 tcg/tcg-op-gvec.c                             |   1 +
 tcg/tcg-op-vec.c                              |   1 +
 tcg/tcg-op.c                                  |   1 +
 tcg/tcg.c                                     |  55 +-
 target/cris/translate_v10.c.inc               |  49 +-
 target/i386/tcg/decode-new.c.inc              |  15 -
 target/i386/tcg/emit.c.inc                    |   6 -
 target/loongarch/insn_trans/trans_arith.c.inc |  12 -
 .../loongarch/insn_trans/trans_atomic.c.inc   |   3 -
 target/loongarch/insn_trans/trans_bit.c.inc   |  12 -
 target/loongarch/insn_trans/trans_fcmp.c.inc  |   3 -
 .../loongarch/insn_trans/trans_fmemory.c.inc  |  20 +-
 target/loongarch/insn_trans/trans_fmov.c.inc  |   6 -
 .../loongarch/insn_trans/trans_memory.c.inc   |  34 +-
 .../insn_trans/trans_privileged.c.inc         |   6 +-
 target/loongarch/insn_trans/trans_shift.c.inc |  11 -
 target/mips/tcg/micromips_translate.c.inc     |   8 -
 target/mips/tcg/mips16e_translate.c.inc       |   6 -
 target/mips/tcg/nanomips_translate.c.inc      | 127 +---
 target/ppc/power8-pmu-regs.c.inc              |  16 -
 target/ppc/translate/dfp-impl.c.inc           |  20 -
 target/ppc/translate/fixedpoint-impl.c.inc    |  16 -
 target/ppc/translate/fp-impl.c.inc            | 122 +---
 target/ppc/translate/spe-impl.c.inc           |  59 --
 target/ppc/translate/storage-ctrl-impl.c.inc  |   2 -
 target/ppc/translate/vmx-impl.c.inc           | 296 +-------
 target/ppc/translate/vsx-impl.c.inc           | 287 +-------
 target/riscv/insn_trans/trans_rvb.c.inc       |  24 -
 target/riscv/insn_trans/trans_rvd.c.inc       |   2 -
 target/riscv/insn_trans/trans_rvf.c.inc       |   9 -
 target/riscv/insn_trans/trans_rvi.c.inc       |  37 -
 target/riscv/insn_trans/trans_rvk.c.inc       |  15 -
 target/riscv/insn_trans/trans_rvm.c.inc       |  33 -
 target/riscv/insn_trans/trans_rvv.c.inc       |  55 --
 target/riscv/insn_trans/trans_rvzfh.c.inc     |  12 +-
 target/riscv/insn_trans/trans_xthead.c.inc    |  24 +-
 target/s390x/tcg/translate_vx.c.inc           | 188 +----
 scripts/tracetool/transform.py                | 168 -----
 target/hexagon/README                         |   5 -
 target/hexagon/gen_tcg_funcs.py               |  79 +--
 target/hexagon/idef-parser/idef-parser.y      |  12 -
 94 files changed, 471 insertions(+), 7143 deletions(-)
 create mode 100644 include/tcg/tcg-temp-internal.h
 delete mode 100644 scripts/tracetool/transform.py

Comments

Philippe Mathieu-Daudé Feb. 25, 2023, 10:10 a.m. UTC | #1
On 25/2/23 10:13, Richard Henderson wrote:
> Based-on: 20230225085945.1798188-1-richard.henderson@linaro.org
> ("[PATCH v3 00/30] tcg: Simplify temporary usage")
> 
> In the above patch set, we changed the lifetime of the temps
> allocated by the guest translators, and eliminated their reuse,
> so that we have the best chance of reducing their strength.
> 
> That we don't reuse them means that we gain nothing by freeing them.
> Therefore, drop all mention of tcg_temp_free from target/.
> 
> This may be the most negative diffstat I've ever produced.  :-)

>   94 files changed, 471 insertions(+), 7143 deletions(-)

7143 + 2 = 7145 by removing tcg_const_ptr():

-- >8 --
diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h
index 43ce4bfa7d..64b88268cd 100644
--- a/include/tcg/tcg.h
+++ b/include/tcg/tcg.h
@@ -1020,6 +1020,4 @@ TCGv_vec tcg_constant_vec_matching(TCGv_vec match, 
unsigned vece, int64_t val);
  #if UINTPTR_MAX == UINT32_MAX
-# define tcg_const_ptr(x)        ((TCGv_ptr)tcg_const_i32((intptr_t)(x)))
  # define tcg_constant_ptr(x) 
((TCGv_ptr)tcg_constant_i32((intptr_t)(x)))
  #else
-# define tcg_const_ptr(x)        ((TCGv_ptr)tcg_const_i64((intptr_t)(x)))
  # define tcg_constant_ptr(x) 
((TCGv_ptr)tcg_constant_i64((intptr_t)(x)))
diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c
index 5bf80b22d7..ce40fac557 100644
--- a/target/arm/translate-sve.c
+++ b/target/arm/translate-sve.c
@@ -4210,3 +4210,3 @@ void gen_sve_ldr(DisasContext *s, TCGv_ptr base, 
int vofs,
          TCGLabel *loop = gen_new_label();
-        TCGv_ptr tp, i = tcg_const_ptr(0);
+        TCGv_ptr tp, i = tcg_constant_ptr(NULL);

@@ -4288,3 +4288,3 @@ void gen_sve_str(DisasContext *s, TCGv_ptr base, 
int vofs,
          TCGLabel *loop = gen_new_label();
-        TCGv_ptr tp, i = tcg_const_ptr(0);
+        TCGv_ptr tp, i = tcg_constant_ptr(NULL);
---
Philippe Mathieu-Daudé Feb. 25, 2023, 10:11 a.m. UTC | #2
On 25/2/23 11:10, Philippe Mathieu-Daudé wrote:
> On 25/2/23 10:13, Richard Henderson wrote:
>> Based-on: 20230225085945.1798188-1-richard.henderson@linaro.org
>> ("[PATCH v3 00/30] tcg: Simplify temporary usage")
>>
>> In the above patch set, we changed the lifetime of the temps
>> allocated by the guest translators, and eliminated their reuse,
>> so that we have the best chance of reducing their strength.
>>
>> That we don't reuse them means that we gain nothing by freeing them.
>> Therefore, drop all mention of tcg_temp_free from target/.
>>
>> This may be the most negative diffstat I've ever produced.  :-)
> 
>>   94 files changed, 471 insertions(+), 7143 deletions(-)
> 
> 7143 + 2 = 7145 by removing tcg_const_ptr():
> 
> -- >8 --
> diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h
> index 43ce4bfa7d..64b88268cd 100644
> --- a/include/tcg/tcg.h
> +++ b/include/tcg/tcg.h
> @@ -1020,6 +1020,4 @@ TCGv_vec tcg_constant_vec_matching(TCGv_vec match, 
> unsigned vece, int64_t val);
>   #if UINTPTR_MAX == UINT32_MAX
> -# define tcg_const_ptr(x)        ((TCGv_ptr)tcg_const_i32((intptr_t)(x)))
>   # define tcg_constant_ptr(x) ((TCGv_ptr)tcg_constant_i32((intptr_t)(x)))
>   #else
> -# define tcg_const_ptr(x)        ((TCGv_ptr)tcg_const_i64((intptr_t)(x)))
>   # define tcg_constant_ptr(x) ((TCGv_ptr)tcg_constant_i64((intptr_t)(x)))
> diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c
> index 5bf80b22d7..ce40fac557 100644
> --- a/target/arm/translate-sve.c
> +++ b/target/arm/translate-sve.c
> @@ -4210,3 +4210,3 @@ void gen_sve_ldr(DisasContext *s, TCGv_ptr base, 
> int vofs,
>           TCGLabel *loop = gen_new_label();
> -        TCGv_ptr tp, i = tcg_const_ptr(0);
> +        TCGv_ptr tp, i = tcg_constant_ptr(NULL);

Scratch that, I missed i is modified:

         tcg_gen_addi_ptr(i, i, 8);