]> git.ipfire.org Git - thirdparty/qemu.git/log
thirdparty/qemu.git
5 weeks agoaccel/tcg: Use vaddr in cpu_loop.h
Richard Henderson [Wed, 30 Apr 2025 22:33:05 +0000 (15:33 -0700)] 
accel/tcg: Use vaddr in cpu_loop.h

Use vaddr instead of abi_ptr or target_ulong for a guest address.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agoaccel/tcg: Build tcg-all.c twice
Richard Henderson [Wed, 30 Apr 2025 22:25:29 +0000 (15:25 -0700)] 
accel/tcg: Build tcg-all.c twice

Remove some unused headers.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agoaccel/tcg: Build translate-all.c twice
Richard Henderson [Wed, 30 Apr 2025 22:10:46 +0000 (15:10 -0700)] 
accel/tcg: Build translate-all.c twice

Remove lots and lots of unused headers.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agoaccel/tcg: Use target_long_bits() in translate-all.c
Richard Henderson [Wed, 30 Apr 2025 21:40:30 +0000 (14:40 -0700)] 
accel/tcg: Use target_long_bits() in translate-all.c

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agoaccel/tcg: Don't use TARGET_LONG_BITS in decode_sleb128
Richard Henderson [Wed, 30 Apr 2025 21:35:47 +0000 (14:35 -0700)] 
accel/tcg: Don't use TARGET_LONG_BITS in decode_sleb128

When we changed decode_sleb128 from target_long to
int64_t, we failed to adjust the shift limit.

Cc: qemu-stable@nongnu.org
Fixes: c9ad8d27caa ("tcg: Widen gen_insn_data to uint64_t")
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agotcg: Define INSN_START_WORDS as constant 3
Richard Henderson [Wed, 30 Apr 2025 20:57:30 +0000 (13:57 -0700)] 
tcg: Define INSN_START_WORDS as constant 3

Use the same value for all targets.

Rename TARGET_INSN_START_WORDS and do not depend on
TARGET_INSN_START_EXTRA_WORDS.
Remove TCGContext.insn_start_words.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agoqemu: Introduce target_long_bits()
Philippe Mathieu-Daudé [Sun, 23 Mar 2025 12:20:24 +0000 (13:20 +0100)] 
qemu: Introduce target_long_bits()

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
6 weeks agoqemu/target_info: Add %target_cpu_type field to TargetInfo
Philippe Mathieu-Daudé [Tue, 29 Apr 2025 18:18:03 +0000 (20:18 +0200)] 
qemu/target_info: Add %target_cpu_type field to TargetInfo

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
6 weeks agosystem/vl: Filter machine list available for a particular target binary
Philippe Mathieu-Daudé [Sun, 23 Mar 2025 21:46:34 +0000 (22:46 +0100)] 
system/vl: Filter machine list available for a particular target binary

Binaries can register a QOM type to filter their machines
by filling their TargetInfo::machine_typename field.

This can be used by example by main() -> machine_help_func()
to filter the machines list.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agoaccel/tcg: Compile cpu-exec.c twice
Richard Henderson [Mon, 28 Apr 2025 17:20:41 +0000 (10:20 -0700)] 
accel/tcg: Compile cpu-exec.c twice

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agoaccel/tcg: Split out accel/tcg/helper-retaddr.h
Richard Henderson [Mon, 28 Apr 2025 17:16:52 +0000 (10:16 -0700)] 
accel/tcg: Split out accel/tcg/helper-retaddr.h

Move set_helper_retaddr and clear_helper_retaddr
to a new header file.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agoaccel/tcg: Pass TCGTBCPUState to tb_gen_code
Richard Henderson [Wed, 30 Apr 2025 01:59:26 +0000 (18:59 -0700)] 
accel/tcg: Pass TCGTBCPUState to tb_gen_code

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agoaccel/tcg: Use TCGTBCPUState in struct tb_desc
Richard Henderson [Wed, 30 Apr 2025 01:39:08 +0000 (18:39 -0700)] 
accel/tcg: Use TCGTBCPUState in struct tb_desc

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agoaccel/tcg: Pass TCGTBCPUState to tb_htable_lookup
Richard Henderson [Tue, 29 Apr 2025 20:02:32 +0000 (13:02 -0700)] 
accel/tcg: Pass TCGTBCPUState to tb_htable_lookup

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agoaccel/tcg: Pass TCGTBCPUState to tb_lookup
Richard Henderson [Tue, 29 Apr 2025 19:13:18 +0000 (12:13 -0700)] 
accel/tcg: Pass TCGTBCPUState to tb_lookup

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agoaccel/tcg: Move cpu_get_tb_cpu_state to TCGCPUOps
Richard Henderson [Mon, 28 Apr 2025 00:22:04 +0000 (17:22 -0700)] 
accel/tcg: Move cpu_get_tb_cpu_state to TCGCPUOps

Move the global function name to a hook on TCGCPUOps.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agoaccel/tcg: Return TCGTBCPUState from cpu_get_tb_cpu_state
Richard Henderson [Sun, 27 Apr 2025 22:32:11 +0000 (15:32 -0700)] 
accel/tcg: Return TCGTBCPUState from cpu_get_tb_cpu_state

Combine 3 different pointer returns into one structure return.

Include a cflags field in TCGTBCPUState, not filled in by
cpu_get_tb_cpu_state, but used by all callers.  This fills
a hole in the structure and is useful in some subroutines.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agotarget/riscv: Move cpu_get_tb_cpu_state to tcg-cpu.c
Richard Henderson [Sun, 27 Apr 2025 21:15:45 +0000 (14:15 -0700)] 
target/riscv: Move cpu_get_tb_cpu_state to tcg-cpu.c

This function is only relevant to tcg.
Move it to a tcg-specific file.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agotarget/arm: Unexport assert_hflags_rebuild_correctly
Richard Henderson [Tue, 29 Apr 2025 18:37:24 +0000 (11:37 -0700)] 
target/arm: Unexport assert_hflags_rebuild_correctly

This function is no longer used outside of hflags.c.
We can remove the stub as well.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agotarget/arm: Move cpu_get_tb_cpu_state to hflags.c
Richard Henderson [Tue, 29 Apr 2025 18:35:26 +0000 (11:35 -0700)] 
target/arm: Move cpu_get_tb_cpu_state to hflags.c

This is a tcg-specific function, so move it to a tcg file.
Also move mve_no_pred, a static function only used within
cpu_get_tb_cpu_state.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agoaccel/tcg: Hoist cpu_get_tb_cpu_state decl to accl/tcg/cpu-ops.h
Richard Henderson [Sun, 27 Apr 2025 22:15:14 +0000 (15:15 -0700)] 
accel/tcg: Hoist cpu_get_tb_cpu_state decl to accl/tcg/cpu-ops.h

For some targets, simply remove the local definition.
For other targets, move the inline definition out of line.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agotarget/i386: Split out x86_cpu_exec_reset
Richard Henderson [Sun, 27 Apr 2025 18:44:23 +0000 (11:44 -0700)] 
target/i386: Split out x86_cpu_exec_reset

Note that target/i386/cpu.h defines CPU_INTERRUPT_INIT
as CPU_INTERRUPT_RESET.  Therefore we can handle the
new TCGCPUOps.cpu_exec_reset hook.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agoaccel/tcg: Introduce TCGCPUOps.cpu_exec_reset
Richard Henderson [Sun, 27 Apr 2025 18:31:30 +0000 (11:31 -0700)] 
accel/tcg: Introduce TCGCPUOps.cpu_exec_reset

Initialize all instances with cpu_reset(), so that there
is no functional change.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agoaccel/tcg: Unconditionally use CPU_DUMP_CCOP in log_cpu_exec
Richard Henderson [Sun, 27 Apr 2025 18:02:25 +0000 (11:02 -0700)] 
accel/tcg: Unconditionally use CPU_DUMP_CCOP in log_cpu_exec

This flag is only tested by target/i386, so including this
makes no functional change.  This is similar to other places
like cpu-target.c which use CPU_DUMP_CCOP unconditionally.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agoaccel/tcg: Generalize fake_user_interrupt test
Richard Henderson [Sat, 26 Apr 2025 20:20:24 +0000 (20:20 +0000)] 
accel/tcg: Generalize fake_user_interrupt test

Test for the hook being present instead of ifdef TARGET_I386.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agoinclude: Remove 'exec/exec-all.h'
Philippe Mathieu-Daudé [Thu, 24 Apr 2025 20:24:12 +0000 (22:24 +0200)] 
include: Remove 'exec/exec-all.h'

"exec/exec-all.h" is now fully empty, let's remove it.

Mechanical change running:

  $ sed -i '/exec\/exec-all.h/d' $(git grep -wl exec/exec-all.h)

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20250424202412.91612-14-philmd@linaro.org>

6 weeks agoaccel/tcg: Extract probe API out of 'exec/exec-all.h'
Philippe Mathieu-Daudé [Thu, 24 Apr 2025 20:24:11 +0000 (22:24 +0200)] 
accel/tcg: Extract probe API out of 'exec/exec-all.h'

Declare probe methods in "accel/tcg/probe.h" to emphasize
they are specific to TCG accelerator.

Suggested-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20250424202412.91612-13-philmd@linaro.org>

6 weeks agophysmem: Restrict TCG IOTLB code to TCG accel
Philippe Mathieu-Daudé [Thu, 24 Apr 2025 20:24:10 +0000 (22:24 +0200)] 
physmem: Restrict TCG IOTLB code to TCG accel

Restrict iotlb_to_section(), address_space_translate_for_iotlb()
and memory_region_section_get_iotlb() to TCG. Declare them in
the new "accel/tcg/iommu.h" header. Declare iotlb_to_section()
using the MemoryRegionSection typedef.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20250424202412.91612-12-philmd@linaro.org>

6 weeks agophysmem: Move TCG IOTLB methods around
Philippe Mathieu-Daudé [Thu, 24 Apr 2025 20:24:09 +0000 (22:24 +0200)] 
physmem: Move TCG IOTLB methods around

The next commit will restrict TCG specific code in physmem.c
using some #ifdef'ry. In order to keep it simple, move
iotlb_to_section() and memory_region_section_get_iotlb()
around close together.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20250424202412.91612-11-philmd@linaro.org>

6 weeks agoaccel/tcg: Include 'accel/tcg/getpc.h' in 'exec/helper-proto'
Philippe Mathieu-Daudé [Thu, 24 Apr 2025 20:24:08 +0000 (22:24 +0200)] 
accel/tcg: Include 'accel/tcg/getpc.h' in 'exec/helper-proto'

Most files including "exec/helper-proto.h" call GETPC().
Include it there (in the common part) instead of the
unspecific "exec/exec-all.h" header.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20250424202412.91612-10-philmd@linaro.org>

6 weeks agotarget/riscv: Include missing 'accel/tcg/getpc.h' in csr.c
Philippe Mathieu-Daudé [Thu, 24 Apr 2025 20:24:06 +0000 (22:24 +0200)] 
target/riscv: Include missing 'accel/tcg/getpc.h' in csr.c

"accel/tcg/getpc.h" is pulled in indirectly. Include it
explicitly to avoid when refactoring unrelated headers:

  target/riscv/csr.c:2117:25: error: call to undeclared function 'GETPC' [-Wimplicit-function-declaration]
   2117 |     if ((val & RVC) && (GETPC() & ~3) != 0) {
        |                         ^

Note the TODO comment around GETPC() added upon introduction in
commit f18637cd611 ("RISC-V: Add misa runtime write support"):

 2099 static RISCVException write_misa(CPURISCVState *env, int csrno,
 2100                                  target_ulong val)
 2101 {
  ...
 2113     /*
 2114      * Suppress 'C' if next instruction is not aligned
 2115      * TODO: this should check next_pc
 2116      */
 2117     if ((val & RVC) && (GETPC() & ~3) != 0) {
 2118         val &= ~RVC;
 2119     }

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
Acked-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20250424202412.91612-8-philmd@linaro.org>

6 weeks agoaccel/tcg: Remove #error for non-tcg in getpc.h
Richard Henderson [Sat, 26 Apr 2025 19:35:00 +0000 (19:35 +0000)] 
accel/tcg: Remove #error for non-tcg in getpc.h

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agoaccel/tcg: Compile tb-maint.c twice
Richard Henderson [Thu, 24 Apr 2025 20:24:05 +0000 (22:24 +0200)] 
accel/tcg: Compile tb-maint.c twice

Reviewed-by: Anton Johansson <anjo@rev.ng>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agoinclude/exec: Move tb_invalidate_phys_range to translation-block.h
Richard Henderson [Thu, 24 Apr 2025 20:24:04 +0000 (22:24 +0200)] 
include/exec: Move tb_invalidate_phys_range to translation-block.h

Reviewed-by: Anton Johansson <anjo@rev.ng>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agoinclude/exec: Include missing headers in exec-all.h
Philippe Mathieu-Daudé [Thu, 24 Apr 2025 20:24:03 +0000 (22:24 +0200)] 
include/exec: Include missing headers in exec-all.h

"exec/exec-all.h" declares prototypes such:

  void *probe_access(CPUArchState *env, vaddr addr, int size,
                                        ^^^^^
                     MMUAccessType access_type, int mmu_idx,
                     uintptr_t retaddr);
  MemoryRegionSection *iotlb_to_section(CPUState *cpu,
                                        hwaddr index,
                                        ^^^^^^
                                        MemTxAttrs attrs);
                                        ^^^^^^^^^^

vaddr is defined in "exec/vaddr.h", hwaddr in "exec/hwaddr.h"
and MemTxAttrs in "exec/memattrs.h". All these headers are
indirectly pulled in via "exec/translation-block.h". Since
we will remove "exec/translation-block.h" in the next commit,
include the missing ones, otherwise we'd get errors such:

  include/exec/exec-all.h:51:1: error: unknown type name 'hwaddr'
     51 | hwaddr memory_region_section_get_iotlb(CPUState *cpu,
        | ^

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20250424202412.91612-5-philmd@linaro.org>

6 weeks agoaccel/tcg: Use vaddr in user/page-protection.h
Richard Henderson [Thu, 24 Apr 2025 20:24:01 +0000 (22:24 +0200)] 
accel/tcg: Use vaddr in user/page-protection.h

Reviewed-by: Anton Johansson <anjo@rev.ng>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agoaccel/tcg: Use vaddr for walk_memory_regions callback
Richard Henderson [Thu, 24 Apr 2025 20:24:00 +0000 (22:24 +0200)] 
accel/tcg: Use vaddr for walk_memory_regions callback

Use vaddr instead of target_ulong.  At the same time,
use int instead of unsigned long for flags, to match
page_set_flags().

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agoaccel/tcg: Reduce scope of tb_phys_invalidate, tb_set_jmp_target
Richard Henderson [Sat, 5 Apr 2025 16:45:48 +0000 (09:45 -0700)] 
accel/tcg: Reduce scope of tb_phys_invalidate, tb_set_jmp_target

Move the declarations of these functions out of exec/exec-all.h
to accel/tcg/internal-common.h.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agoaccel/tcg: Merge internal-target.h into internal-common.h
Richard Henderson [Sat, 5 Apr 2025 16:36:27 +0000 (09:36 -0700)] 
accel/tcg: Merge internal-target.h into internal-common.h

There's nothing left in internal-target.h that is
target specific.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agoaccel/tcg: Simplify L1_MAP_ADDR_SPACE_BITS
Richard Henderson [Wed, 2 Apr 2025 19:30:39 +0000 (12:30 -0700)] 
accel/tcg: Simplify L1_MAP_ADDR_SPACE_BITS

Stop taking TARGET_PHYS_ADDR_SPACE_BITS into account.
Simply allow the entire ram_addr_t space.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agoaccel/tcg: Simplify CPU_TLB_DYN_MAX_BITS
Richard Henderson [Wed, 2 Apr 2025 15:40:31 +0000 (08:40 -0700)] 
accel/tcg: Simplify CPU_TLB_DYN_MAX_BITS

Stop taking TARGET_VIRT_ADDR_SPACE_BITS into account.

Since we currently bound CPU_TLB_DYN_MAX_BITS to 22,
the new bound with a 4k page size is 20, which isn't
so different.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agoaccel/tcg: Convert TARGET_HAS_PRECISE_SMC to TCGCPUOps.precise_smc
Richard Henderson [Sat, 5 Apr 2025 15:43:44 +0000 (08:43 -0700)] 
accel/tcg: Convert TARGET_HAS_PRECISE_SMC to TCGCPUOps.precise_smc

Instead of having a compile-time TARGET_HAS_PRECISE_SMC definition,
have each target set the 'precise_smc' field in the TCGCPUOps
structure.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agoaccel/tcg: Add CPUState arg to tb_invalidate_phys_range_fast
Richard Henderson [Wed, 23 Apr 2025 20:10:45 +0000 (13:10 -0700)] 
accel/tcg: Add CPUState arg to tb_invalidate_phys_range_fast

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agoaccel/tcg: Add CPUState arg to tb_invalidate_phys_range
Richard Henderson [Wed, 23 Apr 2025 20:06:12 +0000 (13:06 -0700)] 
accel/tcg: Add CPUState arg to tb_invalidate_phys_range

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agoaccel/tcg: Merge tb_invalidate_phys_range{__locked}
Richard Henderson [Wed, 23 Apr 2025 19:37:28 +0000 (12:37 -0700)] 
accel/tcg: Merge tb_invalidate_phys_range{__locked}

Merge tb_invalidate_phys_page_fast__locked into its
only caller, tb_invalidate_phys_range_fast.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agoaccel/tcg: Add CPUState arg to tb_invalidate_phys_page_range__locked
Richard Henderson [Wed, 23 Apr 2025 19:23:30 +0000 (12:23 -0700)] 
accel/tcg: Add CPUState arg to tb_invalidate_phys_page_range__locked

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agoaccel/tcg: Add CPUState argument to tb_invalidate_phys_page_unwind
Richard Henderson [Fri, 4 Apr 2025 01:06:21 +0000 (18:06 -0700)] 
accel/tcg: Add CPUState argument to tb_invalidate_phys_page_unwind

Replace existing usage of current_cpu.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agoaccel/tcg: Add CPUState argument to page_unprotect
Richard Henderson [Thu, 3 Apr 2025 23:59:29 +0000 (16:59 -0700)] 
accel/tcg: Add CPUState argument to page_unprotect

In the next patch, page_unprotect will need to pass
the CPUState to tb_invalidate_phys_page_unwind.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agoMerge tag 'block-pull-request' of https://gitlab.com/stefanha/qemu into staging
Stefan Hajnoczi [Wed, 30 Apr 2025 17:34:43 +0000 (13:34 -0400)] 
Merge tag 'block-pull-request' of https://gitlab.com/stefanha/qemu into staging

Pull request

Kevin's fix for the divide-by-zero in my recent discard commit, triggered when
a host block device does not support discard.

# -----BEGIN PGP SIGNATURE-----
#
# iQEzBAABCgAdFiEEhpWov9P5fNqsNXdanKSrs4Grc8gFAmgSRfsACgkQnKSrs4Gr
# c8hGBwf8CBoDZzCJAE1sw2GSKnnd3J2qGf4Kg6CcMYOSZ8TLssDKQj6HG2gfWaJZ
# it9g9zq7TsodWCyV/qXrzOy5aa7WX8Tsf10O/87baFqGOp82KMPX8jQK1csRnTTF
# QyDocZhIvO+QJXnmnFjtvY7qfaxkzaT/8U+mWgaQM2zG83BNGg3uNyRPyz+RAfYl
# tVM3xNf2ETbN3D8SIOcpr80/tiWP8dZ8xTLyTfBYPbIP59QX2+Iu8BtLFt9npwT6
# kABnFkqnE/pA6FJz0ZIVenduOBs7IUSQFNvmxAjYIwxowQKsk4WFfjJEKHIHzwwO
# a64i43DcH8XgjCcueJ11DnmoB5RfAg==
# =yODA
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed 30 Apr 2025 11:47:07 EDT
# gpg:                using RSA key 8695A8BFD3F97CDAAC35775A9CA4ABB381AB73C8
# gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>" [ultimate]
# gpg:                 aka "Stefan Hajnoczi <stefanha@gmail.com>" [ultimate]
# Primary key fingerprint: 8695 A8BF D3F9 7CDA AC35  775A 9CA4 ABB3 81AB 73C8

* tag 'block-pull-request' of https://gitlab.com/stefanha/qemu:
  file-posix: Fix crash on discard_granularity == 0

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
6 weeks agoMerge tag 'pull-tcg-20250429' of https://gitlab.com/rth7680/qemu into staging
Stefan Hajnoczi [Wed, 30 Apr 2025 17:34:35 +0000 (13:34 -0400)] 
Merge tag 'pull-tcg-20250429' of https://gitlab.com/rth7680/qemu into staging

Convert TCG backend code generators to TCGOutOp structures,
decomposing the monolithic tcg_out_op functions.

# -----BEGIN PGP SIGNATURE-----
#
# iQFRBAABCgA7FiEEekgeeIaLTbaoWgXAZN846K9+IV8FAmgRDgcdHHJpY2hhcmQu
# aGVuZGVyc29uQGxpbmFyby5vcmcACgkQZN846K9+IV+0SQf9Ef8IE5QWjXEws706
# q+1deeDV2xa1sKAHG5fnskk1bXM31Cy4koNdDQbHTtDWedNEzWKyR7FxjlRm+zSW
# 6CposaEEsCGxdKUbvraflGbWuf2NUZpJoreNGo9BYZkfNWE9yJ0HlypjpxclziRA
# G0Ro4XMevi+yVA3cd8lEmft9cW+woFrVWu5I4tucMwY/8gzWRiHV4Z5YCeCEjD3C
# 3YYukhRTaA+7Lyd1G3rcqh8uSsAGGv2NLO26upK1mnVtZOoS/CgKWfBq5enVEuDd
# X6T544ipz8Z3eXFgzTzK4nl7TpmO+XEUbja3op7psrLHU84puX1/47HLk4TkHlE+
# 6/95eA==
# =vzOx
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue 29 Apr 2025 13:36:07 EDT
# gpg:                using RSA key 7A481E78868B4DB6A85A05C064DF38E8AF7E215F
# gpg:                issuer "richard.henderson@linaro.org"
# gpg: Good signature from "Richard Henderson <richard.henderson@linaro.org>" [full]
# Primary key fingerprint: 7A48 1E78 868B 4DB6 A85A  05C0 64DF 38E8 AF7E 215F

* tag 'pull-tcg-20250429' of https://gitlab.com/rth7680/qemu: (161 commits)
  tcg/sparc64: Implement CTPOP
  tcg/sparc64: Unexport use_vis3_instructions
  tcg: Remove tcg_out_op
  tcg: Convert qemu_st{2} to TCGOutOpLdSt{2}
  tcg: Convert qemu_ld{2} to TCGOutOpLoad{2}
  tcg: Merge INDEX_op_{ld,st}_{i32,i64,i128}
  tcg: Remove INDEX_op_qemu_st8_*
  tcg: Stash MemOp size in TCGOP_FLAGS
  tcg: Merge INDEX_op_st*_{i32,i64}
  tcg: Convert st to TCGOutOpStore
  tcg: Merge INDEX_op_ld*_{i32,i64}
  tcg: Convert ld to TCGOutOpLoad
  tcg: Formalize tcg_out_goto_ptr
  tcg: Formalize tcg_out_br
  tcg: Formalize tcg_out_mb
  tcg: Remove add2/sub2 opcodes
  tcg/tci: Implement add/sub carry opcodes
  tcg/sparc64: Implement add/sub carry opcodes
  tcg/sparc64: Hoist tcg_cond_to_bcond lookup out of tcg_out_movcc
  tcg/s390x: Use ADD LOGICAL WITH SIGNED IMMEDIATE
  ...

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
6 weeks agofile-posix: Fix crash on discard_granularity == 0
Kevin Wolf [Tue, 29 Apr 2025 15:56:54 +0000 (17:56 +0200)] 
file-posix: Fix crash on discard_granularity == 0

Block devices that don't support discard have a discard_granularity of
0. Currently, this results in a division by zero when we try to make
sure that it's a multiple of request_alignment. Only try to update
bs->bl.pdiscard_alignment when we got a non-zero discard_granularity
from sysfs.

Fixes: f605796aae4 ('file-posix: probe discard alignment on Linux block devices')
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-ID: <20250429155654.102735-1-kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
6 weeks agotcg/sparc64: Implement CTPOP
Richard Henderson [Fri, 25 Apr 2025 19:57:11 +0000 (12:57 -0700)] 
tcg/sparc64: Implement CTPOP

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agotcg/sparc64: Unexport use_vis3_instructions
Richard Henderson [Fri, 25 Apr 2025 18:59:58 +0000 (11:59 -0700)] 
tcg/sparc64: Unexport use_vis3_instructions

This variable is no longer used outside tcg-target.c.inc.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agotcg: Remove tcg_out_op
Richard Henderson [Sun, 16 Feb 2025 22:22:48 +0000 (14:22 -0800)] 
tcg: Remove tcg_out_op

All integer opcodes are now converted to TCGOutOp.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agotcg: Convert qemu_st{2} to TCGOutOpLdSt{2}
Richard Henderson [Sun, 16 Feb 2025 22:02:00 +0000 (14:02 -0800)] 
tcg: Convert qemu_st{2} to TCGOutOpLdSt{2}

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agotcg: Convert qemu_ld{2} to TCGOutOpLoad{2}
Richard Henderson [Tue, 11 Feb 2025 21:41:42 +0000 (13:41 -0800)] 
tcg: Convert qemu_ld{2} to TCGOutOpLoad{2}

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agotcg: Merge INDEX_op_{ld,st}_{i32,i64,i128}
Richard Henderson [Sun, 9 Feb 2025 20:55:15 +0000 (12:55 -0800)] 
tcg: Merge INDEX_op_{ld,st}_{i32,i64,i128}

Merge into INDEX_op_{ld,st,ld2,st2}, where "2" indicates that two
inputs or outputs are required. This simplifies the processing of
i64/i128 depending on host word size.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agotcg: Remove INDEX_op_qemu_st8_*
Richard Henderson [Mon, 27 Jan 2025 01:34:19 +0000 (17:34 -0800)] 
tcg: Remove INDEX_op_qemu_st8_*

The i386 backend can now check TCGOP_FLAGS to select
the correct set of constraints.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agotcg: Stash MemOp size in TCGOP_FLAGS
Richard Henderson [Thu, 23 Jan 2025 17:46:57 +0000 (09:46 -0800)] 
tcg: Stash MemOp size in TCGOP_FLAGS

This will enable removing INDEX_op_qemu_st8_*_i32,
by exposing the operand size to constraint selection.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agotcg: Merge INDEX_op_st*_{i32,i64}
Richard Henderson [Wed, 22 Jan 2025 21:28:55 +0000 (13:28 -0800)] 
tcg: Merge INDEX_op_st*_{i32,i64}

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agotcg: Convert st to TCGOutOpStore
Richard Henderson [Wed, 22 Jan 2025 20:49:41 +0000 (12:49 -0800)] 
tcg: Convert st to TCGOutOpStore

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agotcg: Merge INDEX_op_ld*_{i32,i64}
Richard Henderson [Wed, 22 Jan 2025 05:47:16 +0000 (21:47 -0800)] 
tcg: Merge INDEX_op_ld*_{i32,i64}

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agotcg: Convert ld to TCGOutOpLoad
Richard Henderson [Wed, 22 Jan 2025 04:44:42 +0000 (20:44 -0800)] 
tcg: Convert ld to TCGOutOpLoad

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agotcg: Formalize tcg_out_goto_ptr
Richard Henderson [Tue, 21 Jan 2025 05:57:32 +0000 (21:57 -0800)] 
tcg: Formalize tcg_out_goto_ptr

Split these functions out from tcg_out_op.
Define outop_goto_ptr generically.
Call tcg_out_goto_ptr from tcg_reg_alloc_op.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agotcg: Formalize tcg_out_br
Richard Henderson [Tue, 21 Jan 2025 05:17:07 +0000 (21:17 -0800)] 
tcg: Formalize tcg_out_br

Split these functions out from tcg_out_op.
Call it directly from tcg_gen_code.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agotcg: Formalize tcg_out_mb
Richard Henderson [Tue, 21 Jan 2025 04:47:42 +0000 (20:47 -0800)] 
tcg: Formalize tcg_out_mb

Most tcg backends already have a function for this;
the rest can split one out from tcg_out_op.
Call it directly from tcg_gen_code.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agotcg: Remove add2/sub2 opcodes
Richard Henderson [Tue, 21 Jan 2025 04:15:31 +0000 (20:15 -0800)] 
tcg: Remove add2/sub2 opcodes

All uses have been replaced by add/sub carry opcodes.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agotcg/tci: Implement add/sub carry opcodes
Richard Henderson [Tue, 21 Jan 2025 03:46:04 +0000 (19:46 -0800)] 
tcg/tci: Implement add/sub carry opcodes

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agotcg/sparc64: Implement add/sub carry opcodes
Richard Henderson [Tue, 21 Jan 2025 02:48:06 +0000 (18:48 -0800)] 
tcg/sparc64: Implement add/sub carry opcodes

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agotcg/sparc64: Hoist tcg_cond_to_bcond lookup out of tcg_out_movcc
Richard Henderson [Tue, 21 Jan 2025 00:34:47 +0000 (16:34 -0800)] 
tcg/sparc64: Hoist tcg_cond_to_bcond lookup out of tcg_out_movcc

Pass the sparc COND_* value not the tcg TCG_COND_* value.
This makes the usage within add2/sub2 clearer.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agotcg/s390x: Use ADD LOGICAL WITH SIGNED IMMEDIATE
Richard Henderson [Sun, 19 Jan 2025 18:01:18 +0000 (10:01 -0800)] 
tcg/s390x: Use ADD LOGICAL WITH SIGNED IMMEDIATE

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agotcg/s390x: Implement add/sub carry opcodes
Richard Henderson [Sun, 19 Jan 2025 17:31:26 +0000 (09:31 -0800)] 
tcg/s390x: Implement add/sub carry opcodes

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agotcg/s390x: Add TCG_CT_CONST_N32
Richard Henderson [Sat, 18 Jan 2025 22:01:12 +0000 (14:01 -0800)] 
tcg/s390x: Add TCG_CT_CONST_N32

We were using S32 | U32 for add2/sub2.  But the ALGFI and SLGFI
insns that implement this both have uint32_t immediates.
This makes the composite range balanced and
enables use of -0xffffffff ... -0x80000001.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agotcg/s390x: Honor carry_live in tcg_out_movi
Richard Henderson [Sat, 18 Jan 2025 21:26:43 +0000 (13:26 -0800)] 
tcg/s390x: Honor carry_live in tcg_out_movi

Do not clobber flags if they're live.  Required in order
to perform register allocation on add/sub carry opcodes.
LA and AGHI are the same size, so use LA unconditionally.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agotcg/ppc: Implement add/sub carry opcodes
Richard Henderson [Sat, 18 Jan 2025 00:38:13 +0000 (00:38 +0000)] 
tcg/ppc: Implement add/sub carry opcodes

Tested-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agotcg/arm: Implement add/sub carry opcodes
Richard Henderson [Wed, 15 Jan 2025 23:35:53 +0000 (23:35 +0000)] 
tcg/arm: Implement add/sub carry opcodes

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agotcg/aarch64: Implement add/sub carry opcodes
Richard Henderson [Wed, 15 Jan 2025 10:41:58 +0000 (02:41 -0800)] 
tcg/aarch64: Implement add/sub carry opcodes

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agotarget/tricore: Use tcg_gen_addcio_i32 for gen_addc_CC
Richard Henderson [Sat, 18 Jan 2025 10:08:55 +0000 (02:08 -0800)] 
target/tricore: Use tcg_gen_addcio_i32 for gen_addc_CC

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agotarget/sparc: Use tcg_gen_addcio_tl for gen_op_addcc_int
Richard Henderson [Sat, 18 Jan 2025 10:05:19 +0000 (02:05 -0800)] 
target/sparc: Use tcg_gen_addcio_tl for gen_op_addcc_int

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agotarget/sh4: Use tcg_gen_addcio_i32 for addc
Richard Henderson [Sat, 18 Jan 2025 10:03:03 +0000 (02:03 -0800)] 
target/sh4: Use tcg_gen_addcio_i32 for addc

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agotarget/s390x: Use tcg_gen_addcio_i64 for op_addc64
Richard Henderson [Sat, 18 Jan 2025 09:59:12 +0000 (01:59 -0800)] 
target/s390x: Use tcg_gen_addcio_i64 for op_addc64

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agotarget/ppc: Use tcg_gen_addcio_tl for ADD and SUBF
Richard Henderson [Sat, 18 Jan 2025 09:55:11 +0000 (01:55 -0800)] 
target/ppc: Use tcg_gen_addcio_tl for ADD and SUBF

Tested-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agotarget/openrisc: Use tcg_gen_addcio_* for ADDC
Richard Henderson [Sat, 18 Jan 2025 09:50:50 +0000 (01:50 -0800)] 
target/openrisc: Use tcg_gen_addcio_* for ADDC

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agotarget/microblaze: Use tcg_gen_addcio_i32
Richard Henderson [Sat, 18 Jan 2025 09:47:53 +0000 (01:47 -0800)] 
target/microblaze: Use tcg_gen_addcio_i32

Use this in gen_addc and gen_rsubc, both of which need
add with carry-in and carry-out.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agotarget/hppa: Use tcg_gen_addcio_i64
Richard Henderson [Sat, 18 Jan 2025 09:35:49 +0000 (01:35 -0800)] 
target/hppa: Use tcg_gen_addcio_i64

Use this in do_add, do_sub, and do_ds, all of which need
add with carry-in and carry-out.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agotarget/arm: Use tcg_gen_addcio_* for ADCS
Richard Henderson [Sat, 18 Jan 2025 09:27:41 +0000 (01:27 -0800)] 
target/arm: Use tcg_gen_addcio_* for ADCS

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agotcg: Add tcg_gen_addcio_{i32,i64,tl}
Richard Henderson [Sat, 18 Jan 2025 09:19:51 +0000 (01:19 -0800)] 
tcg: Add tcg_gen_addcio_{i32,i64,tl}

Create a function for performing an add with carry-in
and producing carry out.  The carry-out result is boolean.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agotcg/i386: Special case addci r, 0, 0
Richard Henderson [Sat, 18 Jan 2025 06:39:14 +0000 (22:39 -0800)] 
tcg/i386: Special case addci r, 0, 0

Using addci with two zeros as input in order to capture the value
of the carry-in bit is common.  Special case this with sbb+neg so
that we do not have to load 0 into a register first.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agotcg/i386: Implement add/sub carry opcodes
Richard Henderson [Sat, 18 Jan 2025 06:24:56 +0000 (22:24 -0800)] 
tcg/i386: Implement add/sub carry opcodes

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agotcg/i386: Honor carry_live in tcg_out_movi
Richard Henderson [Sat, 18 Jan 2025 06:05:48 +0000 (22:05 -0800)] 
tcg/i386: Honor carry_live in tcg_out_movi

Do not clobber flags if they're live.  Required in order
to perform register allocation on add/sub carry opcodes.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agotcg: Use sub carry opcodes to expand sub2
Richard Henderson [Wed, 15 Jan 2025 02:58:05 +0000 (18:58 -0800)] 
tcg: Use sub carry opcodes to expand sub2

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agotcg: Use add carry opcodes to expand add2
Richard Henderson [Tue, 14 Jan 2025 07:29:42 +0000 (23:29 -0800)] 
tcg: Use add carry opcodes to expand add2

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agotcg/optimize: With two const operands, prefer 0 in arg1
Richard Henderson [Wed, 15 Jan 2025 07:08:24 +0000 (23:08 -0800)] 
tcg/optimize: With two const operands, prefer 0 in arg1

For most binary operands, two const operands fold.
However, the add/sub carry opcodes have a third input.
Prefer "reg, zero, const" since many risc hosts have a
zero register that can fit a "reg, reg, const" insn format.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agotcg/optimize: Handle add/sub with carry opcodes
Richard Henderson [Wed, 15 Jan 2025 02:28:15 +0000 (18:28 -0800)] 
tcg/optimize: Handle add/sub with carry opcodes

Propagate known carry when possible, and simplify the opcodes
to not require carry-in when known.  The result will be cleaned
up further by the subsequent liveness analysis pass.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agotcg: Add TCGOutOp structures for add/sub carry opcodes
Richard Henderson [Wed, 15 Jan 2025 07:27:53 +0000 (23:27 -0800)] 
tcg: Add TCGOutOp structures for add/sub carry opcodes

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agotcg: Add add/sub with carry opcodes and infrastructure
Richard Henderson [Tue, 14 Jan 2025 21:58:39 +0000 (13:58 -0800)] 
tcg: Add add/sub with carry opcodes and infrastructure

Liveness needs to track carry-live state in order to
determine if the (hidden) output of the opcode is used.
Code generation needs to track carry-live state in order
to avoid clobbering cpu flags when loading constants.

So far, output routines and backends are unchanged.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agotcg: Sink def, nb_iargs, nb_oargs loads in liveness_pass_1
Richard Henderson [Tue, 14 Jan 2025 21:12:35 +0000 (13:12 -0800)] 
tcg: Sink def, nb_iargs, nb_oargs loads in liveness_pass_1

Sink the sets of the def, nb_iargs, nb_oargs variables to
the default and do_not_remove labels.  They're not really
needed beforehand, and it avoids preceding code from having
to keep them up-to-date.  Note that def had *not* been kept
up-to-date; thankfully only def->flags had been used and
those bits were constant between opcode changes.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agotcg: Move i into each for loop in liveness_pass_1
Richard Henderson [Tue, 14 Jan 2025 21:04:15 +0000 (13:04 -0800)] 
tcg: Move i into each for loop in liveness_pass_1

Use per-loop variables instead of one 'i' for the function.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agotcg/riscv: Drop support for add2/sub2
Richard Henderson [Tue, 14 Jan 2025 05:24:25 +0000 (21:24 -0800)] 
tcg/riscv: Drop support for add2/sub2

We now produce exactly the same code via generic expansion.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 weeks agotcg/mips: Drop support for add2/sub2
Richard Henderson [Tue, 14 Jan 2025 05:16:40 +0000 (21:16 -0800)] 
tcg/mips: Drop support for add2/sub2

We now produce exactly the same code via generic expansion.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>