Skip to contentSkip to conversation

Remove 32-bit host support

PATCH In review Richard Henderson 7 participants 73 messages Jan 16 – Jan 19

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v2 cover Remove 32-bit host support

32-bit host support was deprecated with the 10.0 release, and so with the 11.0 release we may remove it. Phil already did some cleanup in 10.2, removing support for mips32 and ppc32 within tcg.

Changes for v2:
- Include wasm64 support, so that removing wasm32 does not lose the emstripten feature.
- Review feedback incorporated.

Patches requiring review:
05-gitlab-ci-Drop-build-wasm32-32bit.patch 06-tests-docker-dockerfiles-Drop-wasm32-from-emsdk-w.patch 07-gitlab-Remove-32-bit-host-testing.patch 09-meson-Drop-cpu-wasm32-tests.patch 17-tcg-i386-Remove-TCG_TARGET_REG_BITS-tests.patch 52-target-s390x-Simplify-atomicity-check-in-do_csst.patch

r~

Kohei Tokunaga (4):
meson: Add wasm64 support to the --cpu flag
configure: Enable to propagate -sMEMORY64 flag to Emscripten
dockerfiles: Add support for wasm64 to the wasm Dockerfile
gitlab-ci: Add build tests for wasm64

Richard Henderson (54):
gitlab-ci: Drop build-wasm32-32bit tests/docker/dockerfiles: Drop wasm32 from emsdk-wasm-cross.docker
gitlab: Remove 32-bit host testing
meson: Reject 32-bit hosts
meson: Drop cpu == wasm32 tests
*: Remove arm host support
bsd-user: Fix __i386__ test for TARGET_HAS_STAT_TIME_T_EXT *: Remove __i386__ tests
*: Remove i386 host support host/include/x86_64/bufferiszero: Remove no SSE2 fallback
meson: Remove cpu == x86 tests
*: Remove ppc host support
tcg/i386: Remove TCG_TARGET_REG_BITS tests
tcg/x86_64: Rename from i386
tcg/ppc64: Rename from ppc
meson: Drop host_arch rename for mips64
meson: Drop host_arch rename for riscv64
meson: Remove cpu == riscv32 tests
tcg: Make TCG_TARGET_REG_BITS common
tcg: Replace TCG_TARGET_REG_BITS / 8
*: Drop TCG_TARGET_REG_BITS test for prefer_i64
tcg: Remove INDEX_op_brcond2_i32
tcg: Remove INDEX_op_setcond2_i32
tcg: Remove INDEX_op_dup2_vec
tcg/tci: Drop TCG_TARGET_REG_BITS tests
tcg/tci: Remove glue TCG_TARGET_REG_BITS renames
tcg: Drop TCG_TARGET_REG_BITS test in region.c
tcg: Drop TCG_TARGET_REG_BITS tests in tcg-op.c
tcg: Drop TCG_TARGET_REG_BITS tests in tcg-op-gvec.c
tcg: Drop TCG_TARGET_REG_BITS tests in tcg-op-ldst.c
tcg: Drop TCG_TARGET_REG_BITS tests in tcg.c
tcg: Drop TCG_TARGET_REG_BITS tests in tcg-internal.h
tcg: Drop TCG_TARGET_REG_BITS test in tcg-has.h include/tcg: Drop TCG_TARGET_REG_BITS tests target/i386/tcg: Drop TCG_TARGET_REG_BITS test target/riscv: Drop TCG_TARGET_REG_BITS test accel/tcg/runtime: Remove 64-bit shift helpers accel/tcg/runtime: Remove helper_nonatomic_cmpxchgo
tcg: Unconditionally define atomic64 helpers
accel/tcg: Drop CONFIG_ATOMIC64 checks from ldst_atomicicy.c.inc accel/tcg: Drop CONFIG_ATOMIC64 test from translator.c linux-user/arm: Drop CONFIG_ATOMIC64 test linux-user/hppa: Drop CONFIG_ATOMIC64 test
target/arm: Drop CONFIG_ATOMIC64 tests
target/hppa: Drop CONFIG_ATOMIC64 test
target/m68k: Drop CONFIG_ATOMIC64 tests
target/s390x: Drop CONFIG_ATOMIC64 tests
target/s390x: Simplify atomicity check in do_csst
migration: Drop use of Stat64
block: Drop use of Stat64
util: Remove stats64
include/qemu/atomic: Drop qatomic_{read,set}_[iu]64
meson: Remove CONFIG_ATOMIC64
include/qemu/atomic: Drop aligned_{u}int64_t

 accel/tcg/atomic_template.h                   |    4 +-
 accel/tcg/tcg-runtime.h                       |   23 -
 bsd-user/syscall_defs.h                       |    2 +-
 host/include/i386/host/cpuinfo.h              |   41 -
 host/include/i386/host/crypto/aes-round.h     |  152 -
 host/include/i386/host/crypto/clmul.h         |   29 -
 host/include/ppc/host/cpuinfo.h               |   30 -
 host/include/ppc/host/crypto/aes-round.h      |  182 -
 host/include/ppc64/host/cpuinfo.h             |   31 +-
 host/include/ppc64/host/crypto/aes-round.h    |  183 +-
 .../include/{riscv => riscv64}/host/cpuinfo.h |    0
 host/include/x86_64/host/cpuinfo.h            |   42 +-
 host/include/x86_64/host/crypto/aes-round.h   |  153 +-
 host/include/x86_64/host/crypto/clmul.h       |   30 +-
 include/accel/tcg/cpu-ldst-common.h           |    9 -
 include/block/block_int-common.h              |    3 +-
 include/qemu/atomic.h                         |   39 +-
 include/qemu/cacheflush.h                     |    2 +-
 include/qemu/osdep.h                          |    6 +-
 include/qemu/processor.h                      |    2 +-
 include/qemu/stats64.h                        |  199 -
 include/qemu/timer.h                          |    9 -
 include/system/cpu-timers-internal.h          |    2 +-
 include/tcg/helper-info.h                     |    2 +-
 .../tcg/target-reg-bits.h                     |    8 +-
 include/tcg/tcg-op.h                          |    9 +-
 include/tcg/tcg-opc.h                         |    9 +-
 include/tcg/tcg.h                             |   29 +-
 linux-user/include/host/arm/host-signal.h     |   43 -
 linux-user/include/host/i386/host-signal.h    |   38 -
 .../host/{mips => mips64}/host-signal.h       |    0
 linux-user/include/host/ppc/host-signal.h     |   39 -
 .../host/{riscv => riscv64}/host-signal.h     |    0
 migration/migration-stats.h                   |   36 +-
 tcg/aarch64/tcg-target-reg-bits.h             |   12 -
 tcg/arm/tcg-target-con-set.h                  |   47 -
 tcg/arm/tcg-target-con-str.h                  |   26 -
 tcg/arm/tcg-target-has.h                      |   73 -
 tcg/arm/tcg-target-mo.h                       |   13 -
 tcg/arm/tcg-target-reg-bits.h                 |   12 -
 tcg/arm/tcg-target.h                          |   73 -
 tcg/i386/tcg-target-reg-bits.h                |   16 -
 tcg/loongarch64/tcg-target-reg-bits.h         |   21 -
 tcg/mips/tcg-target-reg-bits.h                |   16 -
 tcg/{mips => mips64}/tcg-target-con-set.h     |    0
 tcg/{mips => mips64}/tcg-target-con-str.h     |    0
 tcg/{mips => mips64}/tcg-target-has.h         |    0
 tcg/{mips => mips64}/tcg-target-mo.h          |    0
 tcg/{mips => mips64}/tcg-target.h             |    0
 tcg/{ppc => ppc64}/tcg-target-con-set.h       |    0
 tcg/{ppc => ppc64}/tcg-target-con-str.h       |    0
 tcg/{ppc => ppc64}/tcg-target-has.h           |    0
 tcg/{ppc => ppc64}/tcg-target-mo.h            |    0
 tcg/{ppc => ppc64}/tcg-target.h               |    0
 tcg/riscv/tcg-target-reg-bits.h               |   19 -
 tcg/{riscv => riscv64}/tcg-target-con-set.h   |    0
 tcg/{riscv => riscv64}/tcg-target-con-str.h   |    0
 tcg/{riscv => riscv64}/tcg-target-has.h       |    0
 tcg/{riscv => riscv64}/tcg-target-mo.h        |    0
 tcg/{riscv => riscv64}/tcg-target.h           |    0
 tcg/s390x/tcg-target-reg-bits.h               |   17 -
 tcg/sparc64/tcg-target-reg-bits.h             |   12 -
 tcg/tcg-has.h                                 |    5 -
 tcg/tcg-internal.h                            |   21 +-
 tcg/tci/tcg-target-has.h                      |    2 -
 tcg/tci/tcg-target-mo.h                       |    2 +-
 tcg/tci/tcg-target-reg-bits.h                 |   18 -
 tcg/{i386 => x86_64}/tcg-target-con-set.h     |    0
 tcg/{i386 => x86_64}/tcg-target-con-str.h     |    0
 tcg/{i386 => x86_64}/tcg-target-has.h         |    8 +-
 tcg/{i386 => x86_64}/tcg-target-mo.h          |    0
 tcg/{i386 => x86_64}/tcg-target.h             |   13 +-
 accel/kvm/kvm-all.c                           |    2 +-
 accel/qtest/qtest.c                           |    4 +-
 accel/tcg/cputlb.c                            |   37 +-
 accel/tcg/icount-common.c                     |   25 +-
 accel/tcg/tcg-runtime.c                       |   15 -
 accel/tcg/translator.c                        |    4 +-
 accel/tcg/user-exec.c                         |    2 -
 block/io.c                                    |   10 +-
 block/qapi.c                                  |    2 +-
 disas/disas-host.c                            |    9 -
 hw/display/xenfb.c                            |   10 +-
 hw/virtio/virtio-mem.c                        |    2 +-
 linux-user/arm/cpu_loop.c                     |   19 +-
 linux-user/hppa/cpu_loop.c                    |   14 +-
 linux-user/mmap.c                             |    2 +-
 linux-user/syscall.c                          |    9 -
 migration/cpu-throttle.c                      |    4 +-
 migration/migration-stats.c                   |   16 +-
 migration/migration.c                         |   24 +-
 migration/multifd-nocomp.c                    |    2 +-
 migration/multifd-zero-page.c                 |    4 +-
 migration/multifd.c                           |   12 +-
 migration/qemu-file.c                         |    6 +-
 migration/ram.c                               |   30 +-
 migration/rdma.c                              |    8 +-
 system/dirtylimit.c                           |    2 +-
 target/arm/ptw.c                              |   18 +-
 target/arm/tcg/gengvec.c                      |   32 +-
 target/arm/tcg/gengvec64.c                    |    4 +-
 target/arm/tcg/translate-sve.c                |   26 +-
 target/hppa/op_helper.c                       |    6 +-
 target/i386/cpu.c                             |   10 -
 target/m68k/op_helper.c                       |    7 +-
 target/s390x/tcg/mem_helper.c                 |   18 +-
 tcg/optimize.c                                |  322 --
 tcg/region.c                                  |   12 -
 tcg/tcg-op-gvec.c                             |  113 +-
 tcg/tcg-op-ldst.c                             |  130 +-
 tcg/tcg-op-vec.c                              |   14 +-
 tcg/tcg-op.c                                  |  765 +---
 tcg/tcg.c                                     |  376 +-
 tcg/tci.c                                     |   73 +-
 tests/unit/test-rcu-list.c                    |   17 +-
 util/atomic64.c                               |   85 -
 util/cacheflush.c                             |    4 +-
 util/qsp.c                                    |   12 +-
 util/stats64.c                                |  148 -
 .gitlab-ci.d/buildtest.yml                    |   17 +-
 .gitlab-ci.d/container-cross.yml              |   17 +-
 .gitlab-ci.d/container-template.yml           |    4 +-
 .gitlab-ci.d/containers.yml                   |    4 +-
 .gitlab-ci.d/crossbuilds.yml                  |   45 -
 MAINTAINERS                                   |   18 +-
 accel/tcg/atomic_common.c.inc                 |   32 -
 accel/tcg/ldst_atomicity.c.inc                |  149 +-
 common-user/host/arm/safe-syscall.inc.S       |  108 -
 common-user/host/i386/safe-syscall.inc.S      |  127 -
 .../host/{mips => mips64}/safe-syscall.inc.S  |    0
 common-user/host/ppc/safe-syscall.inc.S       |  107 -
 .../{riscv => riscv64}/safe-syscall.inc.S     |    0
 configure                                     |   64 +-
 docs/about/deprecated.rst                     |   29 -
 docs/about/removed-features.rst               |    6 +
 docs/devel/tcg-ops.rst                        |   32 +-
 host/include/i386/host/bufferiszero.c.inc     |  125 -
 host/include/x86_64/host/bufferiszero.c.inc   |  121 +-
 meson.build                                   |  105 +-
 target/i386/tcg/emit.c.inc                    |   39 +-
 target/riscv/insn_trans/trans_rvv.c.inc       |   56 +-
 tcg/arm/tcg-target-opc.h.inc                  |   16 -
 tcg/arm/tcg-target.c.inc                      | 3489 -----------------
 tcg/loongarch64/tcg-target.c.inc              |    4 +-
 tcg/{mips => mips64}/tcg-target-opc.h.inc     |    0
 tcg/{mips => mips64}/tcg-target.c.inc         |    0
 tcg/{ppc => ppc64}/tcg-target-opc.h.inc       |    0
 tcg/{ppc => ppc64}/tcg-target.c.inc           |    2 +-
 tcg/{riscv => riscv64}/tcg-target-opc.h.inc   |    0
 tcg/{riscv => riscv64}/tcg-target.c.inc       |    4 +-
 tcg/tci/tcg-target.c.inc                      |   84 +-
 tcg/{i386 => x86_64}/tcg-target-opc.h.inc     |    0
 tcg/{i386 => x86_64}/tcg-target.c.inc         |  552 +--
 ...2-cross.docker => emsdk-wasm-cross.docker} |   19 +-
 util/meson.build                              |    4 -
 155 files changed, 1211 insertions(+), 8446 deletions(-)
 delete mode 100644 host/include/i386/host/cpuinfo.h
 delete mode 100644 host/include/i386/host/crypto/aes-round.h
 delete mode 100644 host/include/i386/host/crypto/clmul.h
 delete mode 100644 host/include/ppc/host/cpuinfo.h
 delete mode 100644 host/include/ppc/host/crypto/aes-round.h
 rename host/include/{riscv => riscv64}/host/cpuinfo.h (100%)
 delete mode 100644 include/qemu/stats64.h
 rename tcg/ppc/tcg-target-reg-bits.h => include/tcg/target-reg-bits.h (71%)
 delete mode 100644 linux-user/include/host/arm/host-signal.h
 delete mode 100644 linux-user/include/host/i386/host-signal.h
 rename linux-user/include/host/{mips => mips64}/host-signal.h (100%)
 delete mode 100644 linux-user/include/host/ppc/host-signal.h
 rename linux-user/include/host/{riscv => riscv64}/host-signal.h (100%)
 delete mode 100644 tcg/aarch64/tcg-target-reg-bits.h
 delete mode 100644 tcg/arm/tcg-target-con-set.h
 delete mode 100644 tcg/arm/tcg-target-con-str.h
 delete mode 100644 tcg/arm/tcg-target-has.h
 delete mode 100644 tcg/arm/tcg-target-mo.h
 delete mode 100644 tcg/arm/tcg-target-reg-bits.h
 delete mode 100644 tcg/arm/tcg-target.h
 delete mode 100644 tcg/i386/tcg-target-reg-bits.h
 delete mode 100644 tcg/loongarch64/tcg-target-reg-bits.h
 delete mode 100644 tcg/mips/tcg-target-reg-bits.h
 rename tcg/{mips => mips64}/tcg-target-con-set.h (100%)
 rename tcg/{mips => mips64}/tcg-target-con-str.h (100%)
 rename tcg/{mips => mips64}/tcg-target-has.h (100%)
 rename tcg/{mips => mips64}/tcg-target-mo.h (100%)
 rename tcg/{mips => mips64}/tcg-target.h (100%)
 rename tcg/{ppc => ppc64}/tcg-target-con-set.h (100%)
 rename tcg/{ppc => ppc64}/tcg-target-con-str.h (100%)
 rename tcg/{ppc => ppc64}/tcg-target-has.h (100%)
 rename tcg/{ppc => ppc64}/tcg-target-mo.h (100%)
 rename tcg/{ppc => ppc64}/tcg-target.h (100%)
 delete mode 100644 tcg/riscv/tcg-target-reg-bits.h
 rename tcg/{riscv => riscv64}/tcg-target-con-set.h (100%)
 rename tcg/{riscv => riscv64}/tcg-target-con-str.h (100%)
 rename tcg/{riscv => riscv64}/tcg-target-has.h (100%)
 rename tcg/{riscv => riscv64}/tcg-target-mo.h (100%)
 rename tcg/{riscv => riscv64}/tcg-target.h (100%)
 delete mode 100644 tcg/s390x/tcg-target-reg-bits.h
 delete mode 100644 tcg/sparc64/tcg-target-reg-bits.h
 delete mode 100644 tcg/tci/tcg-target-reg-bits.h
 rename tcg/{i386 => x86_64}/tcg-target-con-set.h (100%)
 rename tcg/{i386 => x86_64}/tcg-target-con-str.h (100%)
 rename tcg/{i386 => x86_64}/tcg-target-has.h (92%)
 rename tcg/{i386 => x86_64}/tcg-target-mo.h (100%)
 rename tcg/{i386 => x86_64}/tcg-target.h (86%)
 delete mode 100644 util/atomic64.c
 delete mode 100644 util/stats64.c
 delete mode 100644 common-user/host/arm/safe-syscall.inc.S
 delete mode 100644 common-user/host/i386/safe-syscall.inc.S
 rename common-user/host/{mips => mips64}/safe-syscall.inc.S (100%)
 delete mode 100644 common-user/host/ppc/safe-syscall.inc.S
 rename common-user/host/{riscv => riscv64}/safe-syscall.inc.S (100%)
 delete mode 100644 host/include/i386/host/bufferiszero.c.inc
 delete mode 100644 tcg/arm/tcg-target-opc.h.inc
 delete mode 100644 tcg/arm/tcg-target.c.inc
 rename tcg/{mips => mips64}/tcg-target-opc.h.inc (100%)
 rename tcg/{mips => mips64}/tcg-target.c.inc (100%)
 rename tcg/{ppc => ppc64}/tcg-target-opc.h.inc (100%)
 rename tcg/{ppc => ppc64}/tcg-target.c.inc (99%)
 rename tcg/{riscv => riscv64}/tcg-target-opc.h.inc (100%)
 rename tcg/{riscv => riscv64}/tcg-target.c.inc (99%)
 rename tcg/{i386 => x86_64}/tcg-target-opc.h.inc (100%)
 rename tcg/{i386 => x86_64}/tcg-target.c.inc (89%)
 rename tests/docker/dockerfiles/{emsdk-wasm32-cross.docker => emsdk-wasm-cross.docker} (92%)
Signature · 1 line
2.43.0
#1 lore raw

PATCH v2 1/58 meson: Add wasm64 support to the --cpu flag

From: Kohei Tokunaga <[email protected]>

wasm64 target enables 64bit pointers using Emscripten's -sMEMORY64=1 flag[1]. This enables QEMU to run 64bit guests.

Although the configure script uses "uname -m" as the fallback value when "cpu" is empty, this can't be used for Emscripten which targets to Wasm. So, in wasm build, this commit fixes configure to require --cpu flag to be explicitly specified by the user.

[1] https://emscripten.org/docs/tools_reference/settings_reference.html#memory64

Message-ID: <91f16f0e9ae6b36fbf0c2caac510dcf855120400.1768308374.git.ktokunaga.mail@gmail.com>

---
 configure   | 6 +++++-
 meson.build | 4 ++--
 2 files changed, 7 insertions(+), 3 deletions(-)
configure +5 -1
index 55e0bd3425..92bfc5f976 100755
@@ -365,7 +365,6 @@ elif check_define __APPLE__; then
   host_os=darwin
 elif check_define EMSCRIPTEN ; then
   host_os=emscripten
-  cpu=wasm32
   cross_compile="yes"
 else
   # This is a fatal error, but don't report it yet, because we
@@ -419,6 +418,8 @@ elif check_define __aarch64__ ; then
   cpu="aarch64"
 elif check_define __loongarch64 ; then
   cpu="loongarch64"
+elif check_define EMSCRIPTEN ; then
+  error_exit "wasm32 or wasm64 must be specified to the cpu flag"
 else
   # Using uname is really broken, but it is just a fallback for architectures
   # that are going to use TCI anyway
@@ -519,6 +520,9 @@ case "$cpu" in
   wasm32)
     CPU_CFLAGS="-m32"
     ;;
+  wasm64)
+    CPU_CFLAGS="-m64 -sMEMORY64=1"
+    ;;
 esac
 
 if test -n "$host_arch" && {
meson.build +2 -2
index c58007291a..600c50007d 100644
@@ -51,7 +51,7 @@ qapi_trace_events = []
 bsd_oses = ['gnu/kfreebsd', 'freebsd', 'netbsd', 'openbsd', 'dragonfly', 'darwin']
 supported_oses = ['windows', 'freebsd', 'netbsd', 'openbsd', 'darwin', 'sunos', 'linux', 'emscripten']
 supported_cpus = ['ppc', 'ppc64', 's390x', 'riscv32', 'riscv64', 'x86', 'x86_64',
-  'arm', 'aarch64', 'loongarch64', 'mips64', 'sparc64', 'wasm32']
+  'arm', 'aarch64', 'loongarch64', 'mips64', 'sparc64', 'wasm32', 'wasm64']
 
 cpu = host_machine.cpu_family()
 
@@ -923,7 +923,7 @@ if have_tcg
     if not get_option('tcg_interpreter')
       error('Unsupported CPU @0@, try --enable-tcg-interpreter'.format(cpu))
     endif
-  elif host_arch == 'wasm32'
+  elif host_arch == 'wasm32' or host_arch == 'wasm64'
     if not get_option('tcg_interpreter')
       error('WebAssembly host requires --enable-tcg-interpreter')
     endif
Signature · 1 line
2.43.0
#2 lore raw

PATCH v2 2/58 configure: Enable to propagate -sMEMORY64 flag to Emscripten

In reply to Richard Henderson

From: Kohei Tokunaga <[email protected]>

Currently there are some engines that don't support wasm64 (e.g. unsupported on Safari[1]). To mitigate this issue, the configure script allows the user to use Emscripten's compatibility feature, "-sMEMORY64=2" flag[2].

Emscripten's "-sMEMORY64=2" flag still enables 64bit pointers in C code. But this flag lowers the output binary into wasm32, with limiting the maximum memory size to 4GB. So QEMU can run on wasm32 engines.

[1] https://webassembly.org/features/
[2] https://emscripten.org/docs/tools_reference/settings_reference.html#memory64

Message-ID: <a2f068c7884a629fe3e4b297368d70b0956ab048.1768308374.git.ktokunaga.mail@gmail.com>

---
 configure | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
configure +11 -1
index 92bfc5f976..326d27dab1 100755
@@ -182,6 +182,10 @@ EXTRA_CXXFLAGS=""
 EXTRA_OBJCFLAGS=""
 EXTRA_LDFLAGS=""
 
+# The value is propagated to Emscripten's "-sMEMORY64" flag.
+# https://emscripten.org/docs/tools_reference/settings_reference.html#memory64
+wasm64_memory64=1
+
 # Default value for a variable defining feature "foo".
 #  * foo="no"  feature will only be used if --enable-foo arg is given
 #  * foo=""    feature will be searched for, and if found, will be used
@@ -239,6 +243,8 @@ for opt do
   ;;
   --without-default-features) default_feature="no"
   ;;
+  --wasm64-32bit-address-limit) wasm64_memory64="2"
+  ;;
   esac
 done
 
@@ -521,7 +527,7 @@ case "$cpu" in
     CPU_CFLAGS="-m32"
     ;;
   wasm64)
-    CPU_CFLAGS="-m64 -sMEMORY64=1"
+    CPU_CFLAGS="-m64 -sMEMORY64=$wasm64_memory64"
     ;;
 esac
 
@@ -779,6 +785,8 @@ for opt do
   ;;
   --disable-rust) rust=disabled
   ;;
+  --wasm64-32bit-address-limit)
+  ;;
   # everything else has the same name in configure and meson
   --*) meson_option_parse "$opt" "$optarg"
   ;;
@@ -904,6 +912,8 @@ Advanced options (experts only):
   --disable-containers     don't use containers for cross-building
   --container-engine=TYPE  which container engine to use [$container_engine]
   --gdb=GDB-path           gdb to use for gdbstub tests [$gdb_bin]
+  --wasm64-32bit-address-limit Restrict wasm64 address space to 32-bit (default
+                               is to use the whole 64-bit range).
 EOF
   meson_options_help
 cat << EOF
Signature · 1 line
2.43.0
#3 lore raw

PATCH v2 3/58 dockerfiles: Add support for wasm64 to the wasm Dockerfile

In reply to Richard Henderson

From: Kohei Tokunaga <[email protected]>

This commit fixes Dockerfile of the wasm build to support both of wasm32 and wasm64 build. Dockerfile takes the following build argument and use it for building dependencies.

- TARGET_CPU: target wasm arch (wasm32 or wasm64)

Message-ID: <3f21342f50e0412a32143fe21ecc0d8db95b3f37.1768308374.git.ktokunaga.mail@gmail.com>

---
 MAINTAINERS                                   |  2 +-
 ...2-cross.docker => emsdk-wasm-cross.docker} | 26 ++++++++++++++-----
 2 files changed, 20 insertions(+), 8 deletions(-)
 rename tests/docker/dockerfiles/{emsdk-wasm32-cross.docker => emsdk-wasm-cross.docker} (89%)
MAINTAINERS +1 -1
index 4ddbfba9f0..de8246c3ff 100644
@@ -683,7 +683,7 @@ F: include/system/os-wasm.h
 F: os-wasm.c
 F: util/coroutine-wasm.c
 F: configs/meson/emscripten.txt
-F: tests/docker/dockerfiles/emsdk-wasm32-cross.docker
+F: tests/docker/dockerfiles/emsdk-wasm-cross.docker
 
 Alpha Machines
 --------------
tests/docker/dockerfiles/emsdk-wasm-cross.docker renamed from tests/docker/dockerfiles/emsdk-wasm32-cross.docker +19 -7
similarity index 89%
rename from tests/docker/dockerfiles/emsdk-wasm32-cross.docker
rename to tests/docker/dockerfiles/emsdk-wasm-cross.docker
index 1f08eb0b85..ecd5a02903 100644
@@ -1,14 +1,15 @@
 # syntax = docker/dockerfile:1.5
 
-ARG EMSDK_VERSION_QEMU=3.1.50
+ARG EMSDK_VERSION_QEMU=4.0.10
 ARG ZLIB_VERSION=1.3.1
 ARG GLIB_MINOR_VERSION=2.84
 ARG GLIB_VERSION=${GLIB_MINOR_VERSION}.0
 ARG PIXMAN_VERSION=0.44.2
-ARG FFI_VERSION=v3.4.7
+ARG FFI_VERSION=v3.5.2
 ARG MESON_VERSION=1.5.0
+ARG TARGET_CPU=wasm32
 
-FROM docker.io/emscripten/emsdk:$EMSDK_VERSION_QEMU AS build-base
+FROM docker.io/emscripten/emsdk:$EMSDK_VERSION_QEMU AS build-base-common
 ARG MESON_VERSION
 ENV TARGET=/builddeps/target
 ENV CPATH="$TARGET/include"
@@ -29,12 +30,22 @@ RUN pip3 install meson==${MESON_VERSION} tomli
 RUN mkdir /build
 WORKDIR /build
 RUN mkdir -p $TARGET
+
+FROM build-base-common AS build-base-wasm32
+
+FROM build-base-common AS build-base-wasm64
+ENV CFLAGS="$CFLAGS -sMEMORY64=1"
+ENV CXXFLAGS="$CXXFLAGS -sMEMORY64=1"
+ENV LDFLAGS="$LDFLAGS -sMEMORY64=1"
+
+FROM build-base-${TARGET_CPU} AS build-base
+ARG TARGET_CPU
 RUN <<EOF
 cat <<EOT > /cross.meson
 [host_machine]
 system = 'emscripten'
-cpu_family = 'wasm32'
-cpu = 'wasm32'
+cpu_family = '${TARGET_CPU}'
+cpu = '${TARGET_CPU}'
 endian = 'little'
 
 [binaries]
@@ -56,13 +67,14 @@ RUN emconfigure ./configure --prefix=$TARGET --static
 RUN emmake make install -j$(nproc)
 
 FROM build-base AS libffi-dev
+ARG TARGET_CPU
 ARG FFI_VERSION
 RUN mkdir -p /libffi
 RUN git clone https://github.com/libffi/libffi /libffi
 WORKDIR /libffi
 RUN git checkout $FFI_VERSION
 RUN autoreconf -fiv
-RUN emconfigure ./configure --host=wasm32-unknown-linux \
+RUN emconfigure ./configure --host=${TARGET_CPU}-unknown-linux \
     --prefix=$TARGET --enable-static \
     --disable-shared --disable-dependency-tracking \
     --disable-builddir --disable-multi-os-directory \
@@ -140,6 +152,6 @@ RUN sed -i -E "/#define HAVE_POSIX_SPAWN 1/d" ./_build/config.h
 RUN sed -i -E "/#define HAVE_PTHREAD_GETNAME_NP 1/d" ./_build/config.h
 RUN meson install -C _build
 
-FROM build-base
+FROM build-base-common
 COPY --from=glib-dev /builddeps/ /builddeps/
 COPY --from=pixman-dev /builddeps/ /builddeps/
Signature · 1 line
2.43.0
#4 lore raw

PATCH v2 4/58 gitlab-ci: Add build tests for wasm64

In reply to Richard Henderson

From: Kohei Tokunaga <[email protected]>

The wasm builds are tested for 3 targets: wasm32, wasm64(-sMEMORY64=1) and wasm64(-sMEMORY64=2). The CI builds the containers using the same Dockerfile (emsdk-wasm-cross.docker) with different build args.

Message-ID: <ee30d4956a485fd46b4735028486d3fb7b22fe60.1768308374.git.ktokunaga.mail@gmail.com>

---
 .gitlab-ci.d/buildtest.yml          | 24 +++++++++++++++++++++---
 .gitlab-ci.d/container-cross.yml    | 11 ++++++++++-
 .gitlab-ci.d/container-template.yml |  4 +++-
 .gitlab-ci.d/containers.yml         |  3 ++-
 4 files changed, 36 insertions(+), 6 deletions(-)
.gitlab-ci.d/buildtest.yml +21 -3
index dfe954fe3c..ea0f5bb057 100644
@@ -785,11 +785,29 @@ coverity:
     # Always manual on forks even if $QEMU_CI == "2"
     - when: manual
 
-build-wasm:
+build-wasm32-32bit:
   extends: .wasm_build_job_template
   timeout: 2h
   needs:
-    - job: wasm-emsdk-cross-container
+    - job: wasm32-emsdk-cross-container
   variables:
     IMAGE: emsdk-wasm32-cross
-    CONFIGURE_ARGS: --static --disable-tools --enable-debug --enable-tcg-interpreter
+    CONFIGURE_ARGS: --static --cpu=wasm32 --disable-tools --enable-debug --enable-tcg-interpreter
+
+build-wasm64-64bit:
+  extends: .wasm_build_job_template
+  timeout: 2h
+  needs:
+    - job: wasm64-emsdk-cross-container
+  variables:
+    IMAGE: emsdk-wasm64-cross
+    CONFIGURE_ARGS: --static --cpu=wasm64 --disable-tools --enable-debug --enable-tcg-interpreter
+
+build-wasm64-32bit:
+  extends: .wasm_build_job_template
+  timeout: 2h
+  needs:
+    - job: wasm64-emsdk-cross-container
+  variables:
+    IMAGE: emsdk-wasm64-cross
+    CONFIGURE_ARGS: --static --cpu=wasm64 --wasm64-32bit-address-limit --disable-tools --enable-debug --enable-tcg-interpreter
.gitlab-ci.d/container-cross.yml +10 -1
index 0fd7341afa..7022015e95 100644
@@ -86,7 +86,16 @@ win64-fedora-cross-container:
   variables:
     NAME: fedora-win64-cross
 
-wasm-emsdk-cross-container:
+wasm32-emsdk-cross-container:
   extends: .container_job_template
   variables:
     NAME: emsdk-wasm32-cross
+    BUILD_ARGS: --build-arg TARGET_CPU=wasm32
+    DOCKERFILE: emsdk-wasm-cross
+
+wasm64-emsdk-cross-container:
+  extends: .container_job_template
+  variables:
+    NAME: emsdk-wasm64-cross
+    BUILD_ARGS: --build-arg TARGET_CPU=wasm64
+    DOCKERFILE: emsdk-wasm-cross
.gitlab-ci.d/container-template.yml +3 -1
index 82c1b69e8d..b92e96b0fc 100644
@@ -10,12 +10,14 @@
     - export COMMON_TAG="$CI_REGISTRY/qemu-project/qemu/qemu/$NAME:latest"
     - docker login $CI_REGISTRY -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD"
     - until docker info; do sleep 1; done
+    - export DOCKERFILE_NAME=${DOCKERFILE:-$NAME}
   script:
     - echo "TAG:$TAG"
     - echo "COMMON_TAG:$COMMON_TAG"
     - docker build --tag "$TAG" --cache-from "$TAG" --cache-from "$COMMON_TAG"
       --build-arg BUILDKIT_INLINE_CACHE=1
-      -f "tests/docker/dockerfiles/$NAME.docker" "."
+      $BUILD_ARGS
+      -f "tests/docker/dockerfiles/$DOCKERFILE_NAME.docker" "."
     - docker push "$TAG"
   after_script:
     - docker logout
.gitlab-ci.d/containers.yml +2 -1
index f7d3e7205d..dde9a3f840 100644
@@ -58,7 +58,8 @@ weekly-container-builds:
     - tricore-debian-cross-container
     - xtensa-debian-cross-container
     - win64-fedora-cross-container
-    - wasm-emsdk-cross-container
+    - wasm32-emsdk-cross-container
+    - wasm64-emsdk-cross-container
     # containers
     - amd64-alpine-container
     - amd64-debian-container
Signature · 1 line
2.43.0
#5 lore raw

PATCH v2 5/58 gitlab-ci: Drop build-wasm32-32bit

In reply to Richard Henderson

Drop the wasm32 build and container jobs.

---
 .gitlab-ci.d/buildtest.yml       | 9 ---------
 .gitlab-ci.d/container-cross.yml | 7 -------
 .gitlab-ci.d/containers.yml      | 1 -
 3 files changed, 17 deletions(-)
.gitlab-ci.d/buildtest.yml +0 -9
index ea0f5bb057..e9b5b05e6e 100644
@@ -785,15 +785,6 @@ coverity:
     # Always manual on forks even if $QEMU_CI == "2"
     - when: manual
 
-build-wasm32-32bit:
-  extends: .wasm_build_job_template
-  timeout: 2h
-  needs:
-    - job: wasm32-emsdk-cross-container
-  variables:
-    IMAGE: emsdk-wasm32-cross
-    CONFIGURE_ARGS: --static --cpu=wasm32 --disable-tools --enable-debug --enable-tcg-interpreter
-
 build-wasm64-64bit:
   extends: .wasm_build_job_template
   timeout: 2h
.gitlab-ci.d/container-cross.yml +0 -7
index 7022015e95..6bdd482b80 100644
@@ -86,13 +86,6 @@ win64-fedora-cross-container:
   variables:
     NAME: fedora-win64-cross
 
-wasm32-emsdk-cross-container:
-  extends: .container_job_template
-  variables:
-    NAME: emsdk-wasm32-cross
-    BUILD_ARGS: --build-arg TARGET_CPU=wasm32
-    DOCKERFILE: emsdk-wasm-cross
-
 wasm64-emsdk-cross-container:
   extends: .container_job_template
   variables:
.gitlab-ci.d/containers.yml +0 -1
index dde9a3f840..9b6d33ac13 100644
@@ -58,7 +58,6 @@ weekly-container-builds:
     - tricore-debian-cross-container
     - xtensa-debian-cross-container
     - win64-fedora-cross-container
-    - wasm32-emsdk-cross-container
     - wasm64-emsdk-cross-container
     # containers
     - amd64-alpine-container
Signature · 1 line
2.43.0
Reviewed-by on v2 5/58
#6 lore raw

Re: [PATCH v2 05/58] gitlab-ci: Drop build-wasm32-32bit

Quoted 15 lines

Drop the wasm32 build and container jobs.

---
 .gitlab-ci.d/buildtest.yml       | 9 ---------
 .gitlab-ci.d/container-cross.yml | 7 -------
 .gitlab-ci.d/containers.yml      | 1 -
 3 files changed, 17 deletions(-)
.gitlab-ci.d/buildtest.yml +0 -0
index ea0f5bb057..e9b5b05e6e 100644
@@ -785,15 +785,6 @@ coverity:
     # Always manual on forks even if $QEMU_CI == "2"

.gitlab-ci.d/buildtest.yml coverity: · line 795

Quoted 10 lines
.gitlab-ci.d/buildtest.yml +0 -8
     - when: manual
 
-build-wasm32-32bit:
-  extends: .wasm_build_job_template
-  timeout: 2h
-  needs:
-    - job: wasm32-emsdk-cross-container
-  variables:
-    IMAGE: emsdk-wasm32-cross
-    CONFIGURE_ARGS: --static --cpu=wasm32 --disable-tools --enable-debug

--enable-tcg-interpreter

Review

Quoted 5 lines
.gitlab-ci.d/buildtest.yml +0 -1
-
 build-wasm64-64bit:
   extends: .wasm_build_job_template
   timeout: 2h
(quoted diff) +0 -0

b/.gitlab-ci.d/container-cross.yml

Quoted 22 lines

index 7022015e95..6bdd482b80 100644

.gitlab-ci.d/container-cross.yml +0 -7
@@ -86,13 +86,6 @@ win64-fedora-cross-container:
   variables:
     NAME: fedora-win64-cross
 
-wasm32-emsdk-cross-container:
-  extends: .container_job_template
-  variables:
-    NAME: emsdk-wasm32-cross
-    BUILD_ARGS: --build-arg TARGET_CPU=wasm32
-    DOCKERFILE: emsdk-wasm-cross
-
 wasm64-emsdk-cross-container:
   extends: .container_job_template
   variables:
.gitlab-ci.d/containers.yml +0 -0
index dde9a3f840..9b6d33ac13 100644

.gitlab-ci.d/containers.yml weekly-container-builds: · line 63

Quoted 7 lines
.gitlab-ci.d/containers.yml +0 -1
@@ -58,7 +58,6 @@ weekly-container-builds:
     - tricore-debian-cross-container
     - xtensa-debian-cross-container
     - win64-fedora-cross-container
-    - wasm32-emsdk-cross-container
     - wasm64-emsdk-cross-container
     # containers
     - amd64-alpine-container
Reviewed-by on v2 5/58
#7 lore raw

Re: [PATCH v2 05/58] gitlab-ci: Drop build-wasm32-32bit

In reply to Richard Henderson
Quoted 8 lines · Richard Henderson

Drop the wasm32 build and container jobs.

---
  .gitlab-ci.d/buildtest.yml       | 9 ---------
  .gitlab-ci.d/container-cross.yml | 7 -------
  .gitlab-ci.d/containers.yml      | 1 -
  3 files changed, 17 deletions(-)
#8 lore raw

PATCH v2 6/58 tests/docker/dockerfiles: Drop wasm32 from emsdk-wasm-cross.docker

In reply to Richard Henderson

We will no longer build wasm32, so drop the docker config. Streamline the dockerfile to hardcode TARGET_CPU as wasm64.

---
 .gitlab-ci.d/container-cross.yml                 |  1 -
 tests/docker/dockerfiles/emsdk-wasm-cross.docker | 15 ++++-----------
 2 files changed, 4 insertions(+), 12 deletions(-)
.gitlab-ci.d/container-cross.yml +0 -1
index 6bdd482b80..b376c837dc 100644
@@ -90,5 +90,4 @@ wasm64-emsdk-cross-container:
   extends: .container_job_template
   variables:
     NAME: emsdk-wasm64-cross
-    BUILD_ARGS: --build-arg TARGET_CPU=wasm64
     DOCKERFILE: emsdk-wasm-cross
tests/docker/dockerfiles/emsdk-wasm-cross.docker +4 -11
index ecd5a02903..8a924816f9 100644
@@ -7,7 +7,6 @@ ARG GLIB_VERSION=${GLIB_MINOR_VERSION}.0
 ARG PIXMAN_VERSION=0.44.2
 ARG FFI_VERSION=v3.5.2
 ARG MESON_VERSION=1.5.0
-ARG TARGET_CPU=wasm32
 
 FROM docker.io/emscripten/emsdk:$EMSDK_VERSION_QEMU AS build-base-common
 ARG MESON_VERSION
@@ -31,21 +30,16 @@ RUN mkdir /build
 WORKDIR /build
 RUN mkdir -p $TARGET
 
-FROM build-base-common AS build-base-wasm32
-
-FROM build-base-common AS build-base-wasm64
+FROM build-base-common AS build-base
 ENV CFLAGS="$CFLAGS -sMEMORY64=1"
 ENV CXXFLAGS="$CXXFLAGS -sMEMORY64=1"
 ENV LDFLAGS="$LDFLAGS -sMEMORY64=1"
-
-FROM build-base-${TARGET_CPU} AS build-base
-ARG TARGET_CPU
 RUN <<EOF
 cat <<EOT > /cross.meson
 [host_machine]
 system = 'emscripten'
-cpu_family = '${TARGET_CPU}'
-cpu = '${TARGET_CPU}'
+cpu_family = 'wasm64'
+cpu = 'wasm64'
 endian = 'little'
 
 [binaries]
@@ -67,14 +61,13 @@ RUN emconfigure ./configure --prefix=$TARGET --static
 RUN emmake make install -j$(nproc)
 
 FROM build-base AS libffi-dev
-ARG TARGET_CPU
 ARG FFI_VERSION
 RUN mkdir -p /libffi
 RUN git clone https://github.com/libffi/libffi /libffi
 WORKDIR /libffi
 RUN git checkout $FFI_VERSION
 RUN autoreconf -fiv
-RUN emconfigure ./configure --host=${TARGET_CPU}-unknown-linux \
+RUN emconfigure ./configure --host=wasm64-unknown-linux \
     --prefix=$TARGET --enable-static \
     --disable-shared --disable-dependency-tracking \
     --disable-builddir --disable-multi-os-directory \
Signature · 1 line
2.43.0
Reviewed-by on v2 6/58
#9 lore raw

Re: [PATCH v2 06/58] tests/docker/dockerfiles: Drop wasm32 from emsdk-wasm-cross.docker

Review

Quoted 10 lines

We will no longer build wasm32, so drop the docker config. Streamline the dockerfile to hardcode TARGET_CPU as wasm64.

---
 .gitlab-ci.d/container-cross.yml                 |  1 -
 tests/docker/dockerfiles/emsdk-wasm-cross.docker | 15 ++++-----------
 2 files changed, 4 insertions(+), 12 deletions(-)
(quoted diff) +0 -0

b/.gitlab-ci.d/container-cross.yml

Review

Quoted 10 lines

index 6bdd482b80..b376c837dc 100644

.gitlab-ci.d/container-cross.yml +0 -1
@@ -90,5 +90,4 @@ wasm64-emsdk-cross-container:
   extends: .container_job_template
   variables:
     NAME: emsdk-wasm64-cross
-    BUILD_ARGS: --build-arg TARGET_CPU=wasm64
     DOCKERFILE: emsdk-wasm-cross
(quoted diff) +0 -0

b/tests/docker/dockerfiles/emsdk-wasm-cross.docker

Quoted 42 lines

index ecd5a02903..8a924816f9 100644

tests/docker/dockerfiles/emsdk-wasm-cross.docker +3 -10
@@ -7,7 +7,6 @@ ARG GLIB_VERSION=${GLIB_MINOR_VERSION}.0
 ARG PIXMAN_VERSION=0.44.2
 ARG FFI_VERSION=v3.5.2
 ARG MESON_VERSION=1.5.0
-ARG TARGET_CPU=wasm32
 
 FROM docker.io/emscripten/emsdk:$EMSDK_VERSION_QEMU AS build-base-common
 ARG MESON_VERSION
@@ -31,21 +30,16 @@ RUN mkdir /build
 WORKDIR /build
 RUN mkdir -p $TARGET
 
-FROM build-base-common AS build-base-wasm32
-
-FROM build-base-common AS build-base-wasm64
+FROM build-base-common AS build-base
 ENV CFLAGS="$CFLAGS -sMEMORY64=1"
 ENV CXXFLAGS="$CXXFLAGS -sMEMORY64=1"
 ENV LDFLAGS="$LDFLAGS -sMEMORY64=1"
-
-FROM build-base-${TARGET_CPU} AS build-base
-ARG TARGET_CPU
 RUN <<EOF
 cat <<EOT > /cross.meson
 [host_machine]
 system = 'emscripten'
-cpu_family = '${TARGET_CPU}'
-cpu = '${TARGET_CPU}'
+cpu_family = 'wasm64'
+cpu = 'wasm64'
 endian = 'little'
 
 [binaries]
@@ -67,14 +61,13 @@ RUN emconfigure ./configure --prefix=$TARGET --static
 RUN emmake make install -j$(nproc)
 
 FROM build-base AS libffi-dev
-ARG TARGET_CPU
 ARG FFI_VERSION

tests/docker/dockerfiles/emsdk-wasm-cross.docker RUN emconfigure ./configure --prefix=$TARGET --static · line 73

Quoted 10 lines
tests/docker/dockerfiles/emsdk-wasm-cross.docker +1 -1
 RUN mkdir -p /libffi
 RUN git clone https://github.com/libffi/libffi /libffi
 WORKDIR /libffi
 RUN git checkout $FFI_VERSION
 RUN autoreconf -fiv
-RUN emconfigure ./configure --host=${TARGET_CPU}-unknown-linux \
+RUN emconfigure ./configure --host=wasm64-unknown-linux \
     --prefix=$TARGET --enable-static \
     --disable-shared --disable-dependency-tracking \
     --disable-builddir --disable-multi-os-directory \
#10 lore raw

PATCH v2 7/58 gitlab: Remove 32-bit host testing

In reply to Richard Henderson

These deprecated builds will be disabled.
Remove testing of armhf and i686.

---
 .gitlab-ci.d/container-cross.yml | 12 ---------
 .gitlab-ci.d/containers.yml      |  2 --
 .gitlab-ci.d/crossbuilds.yml     | 45 --------------------------------
 3 files changed, 59 deletions(-)
.gitlab-ci.d/container-cross.yml +0 -12
index b376c837dc..d7ae57fb1f 100644
@@ -22,12 +22,6 @@ arm64-debian-cross-container:
   variables:
     NAME: debian-arm64-cross
 
-armhf-debian-cross-container:
-  extends: .container_job_template
-  stage: containers
-  variables:
-    NAME: debian-armhf-cross
-
 hexagon-cross-container:
   extends: .container_job_template
   stage: containers
@@ -40,12 +34,6 @@ loongarch-debian-cross-container:
   variables:
     NAME: debian-loongarch-cross
 
-i686-debian-cross-container:
-  extends: .container_job_template
-  stage: containers
-  variables:
-    NAME: debian-i686-cross
-
 mips64el-debian-cross-container:
   extends: .container_job_template
   stage: containers
.gitlab-ci.d/containers.yml +0 -2
index 9b6d33ac13..6aeccf8be0 100644
@@ -47,10 +47,8 @@ weekly-container-builds:
     - amd64-debian-user-cross-container
     - amd64-debian-legacy-cross-container
     - arm64-debian-cross-container
-    - armhf-debian-cross-container
     - hexagon-cross-container
     - loongarch-debian-cross-container
-    - i686-debian-cross-container
     - mips64el-debian-cross-container
     - ppc64el-debian-cross-container
     - riscv64-debian-cross-container
.gitlab-ci.d/crossbuilds.yml +0 -45

57 lines not on this page · raw message

Signature · 1 line
2.43.0
Reviewed-by on v2 7/58
#11 lore raw

Re: [PATCH v2 07/58] gitlab: Remove 32-bit host testing

Quoted 9 lines · Richard Henderson

These deprecated builds will be disabled.
Remove testing of armhf and i686.

---
  .gitlab-ci.d/container-cross.yml | 12 ---------
  .gitlab-ci.d/containers.yml      |  2 --
  .gitlab-ci.d/crossbuilds.yml     | 45 --------------------------------
  3 files changed, 59 deletions(-)
#12 lore raw

PATCH v2 8/58 meson: Reject 32-bit hosts

In reply to Richard Henderson

32-bit hosts have been deprecated since 10.0.
As the first step, disable any such at configuration time. Further patches will remove the dead code.

---
 docs/about/deprecated.rst       | 29 -----------------------------
 docs/about/removed-features.rst |  6 ++++++
 meson.build                     | 17 ++++-------------
 3 files changed, 10 insertions(+), 42 deletions(-)
docs/about/deprecated.rst +0 -29
index 7abb3dab59..88efa3aa80 100644
@@ -186,28 +186,6 @@ maintain our cross-compilation CI tests of the architecture. As we no longer
 have CI coverage support may bitrot away before the deprecation process
 completes.
 
-System emulation on 32-bit x86 hosts (since 8.0)
-''''''''''''''''''''''''''''''''''''''''''''''''
-
-Support for 32-bit x86 host deployments is increasingly uncommon in mainstream
-OS distributions given the widespread availability of 64-bit x86 hardware.
-The QEMU project no longer considers 32-bit x86 support for system emulation to
-be an effective use of its limited resources, and thus intends to discontinue
-it. Since all recent x86 hardware from the past >10 years is capable of the
-64-bit x86 extensions, a corresponding 64-bit OS should be used instead.
-
-TCG Plugin support not enabled by default on 32-bit hosts (since 9.2)
-'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
-
-While it is still possible to enable TCG plugin support for 32-bit
-hosts there are a number of potential pitfalls when instrumenting
-64-bit guests. The plugin APIs typically pass most addresses as
-uint64_t but practices like encoding that address in a host pointer
-for passing as user-data will lose data. As most software analysis
-benefits from having plenty of host memory it seems reasonable to
-encourage users to use 64 bit builds of QEMU for analysis work
-whatever targets they are instrumenting.
-
 TCG Plugin support not enabled by default with TCI (since 9.2)
 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
 
@@ -216,13 +194,6 @@ is going to be so much slower it wouldn't make sense for any serious
 instrumentation. Due to implementation differences there will also be
 anomalies in things like memory instrumentation.
 
-32-bit host operating systems (since 10.0)
-''''''''''''''''''''''''''''''''''''''''''
-
-Keeping 32-bit host support alive is a substantial burden for the
-QEMU project.  Thus QEMU will in future drop the support for all
-32-bit host systems.
-
 System emulator CPUs
 --------------------
 
docs/about/removed-features.rst +6 -0
index e81d79da47..b0d7fa8813 100644
@@ -572,6 +572,12 @@ like the ``akita`` or ``terrier``; it has been deprecated in the
 kernel since 2001. None of the board types QEMU supports need
 ``param_struct`` support, so this option has been removed.
 
+32-bit host operating systems (removed in 11.0)
+'''''''''''''''''''''''''''''''''''''''''''''''
+
+Keeping 32-bit host support alive was a substantial burden for the
+QEMU project.  Thus QEMU dropped all support for all 32-bit host systems.
+
 
 User-mode emulator command line arguments
 -----------------------------------------
meson.build +4 -13
index 600c50007d..28f61be675 100644
@@ -332,6 +332,10 @@ endif
 # Compiler flags #
 ##################
 
+if cc.sizeof('void *') < 8
+  error('QEMU requires a 64-bit CPU host architecture')
+endif
+
 foreach lang : all_languages
   compiler = meson.get_compiler(lang)
   if compiler.get_id() == 'gcc' and compiler.version().version_compare('>=7.4')
@@ -3247,9 +3251,6 @@ if host_os == 'windows'
   endif
 endif
 
-# Detect host pointer size for the target configuration loop.
-host_long_bits = cc.sizeof('void *') * 8
-
 # Detect if ConvertStringToBSTR has been defined in _com_util namespace
 if host_os == 'windows'
   has_convert_string_to_bstr = cxx.links('''
@@ -3360,10 +3361,6 @@ foreach target : target_dirs
 
   target_kconfig = []
   foreach sym: accelerators
-    # Disallow 64-bit on 32-bit emulation and virtualization
-    if host_long_bits < config_target['TARGET_LONG_BITS'].to_int()
-      continue
-    endif
     if sym == 'CONFIG_TCG' or target in accelerator_targets.get(sym, [])
       config_target += { sym: 'y' }
       config_all_accel += { sym: 'y' }
@@ -5036,12 +5033,6 @@ if host_arch == 'unknown'
     message('configure has succeeded and you can continue to build, but')
     message('QEMU will use a slow interpreter to emulate the target CPU.')
   endif
-elif host_long_bits < 64
-  message()
-  warning('DEPRECATED HOST CPU')
-  message()
-  message('Support for 32-bit CPU host architecture ' + cpu + ' is going')
-  message('to be dropped in a future QEMU release.')
 elif host_arch == 'mips'
   message()
   warning('DEPRECATED HOST CPU')
Signature · 1 line
2.43.0
Reviewed-by on v2 8/58
#13 lore raw

Re: [PATCH v2 08/58] meson: Reject 32-bit hosts

Quoted 4 lines · Richard Henderson

32-bit hosts have been deprecated since 10.0.
As the first step, disable any such at configuration time. Further patches will remove the dead code.

Quoted 8 lines
---
  docs/about/deprecated.rst       | 29 -----------------------------
  docs/about/removed-features.rst |  6 ++++++
  meson.build                     | 17 ++++-------------
  3 files changed, 10 insertions(+), 42 deletions(-)
#14 lore raw

PATCH v2 9/58 meson: Drop cpu == wasm32 tests

In reply to Richard Henderson

The 32-bit wasm32 host is no longer supported.

---
 configure   | 5 +----
 meson.build | 6 +++---
 2 files changed, 4 insertions(+), 7 deletions(-)
configure +1 -4
index 326d27dab1..ba1b207b56 100755
@@ -425,7 +425,7 @@ elif check_define __aarch64__ ; then
 elif check_define __loongarch64 ; then
   cpu="loongarch64"
 elif check_define EMSCRIPTEN ; then
-  error_exit "wasm32 or wasm64 must be specified to the cpu flag"
+  error_exit "wasm64 must be specified to the cpu flag"
 else
   # Using uname is really broken, but it is just a fallback for architectures
   # that are going to use TCI anyway
@@ -523,9 +523,6 @@ case "$cpu" in
     linux_arch=x86
     CPU_CFLAGS="-m64"
     ;;
-  wasm32)
-    CPU_CFLAGS="-m32"
-    ;;
   wasm64)
     CPU_CFLAGS="-m64 -sMEMORY64=$wasm64_memory64"
     ;;
meson.build +3 -3
index 28f61be675..082c7a86ca 100644
@@ -51,7 +51,7 @@ qapi_trace_events = []
 bsd_oses = ['gnu/kfreebsd', 'freebsd', 'netbsd', 'openbsd', 'dragonfly', 'darwin']
 supported_oses = ['windows', 'freebsd', 'netbsd', 'openbsd', 'darwin', 'sunos', 'linux', 'emscripten']
 supported_cpus = ['ppc', 'ppc64', 's390x', 'riscv32', 'riscv64', 'x86', 'x86_64',
-  'arm', 'aarch64', 'loongarch64', 'mips64', 'sparc64', 'wasm32', 'wasm64']
+  'arm', 'aarch64', 'loongarch64', 'mips64', 'sparc64', 'wasm64']
 
 cpu = host_machine.cpu_family()
 
@@ -927,7 +927,7 @@ if have_tcg
     if not get_option('tcg_interpreter')
       error('Unsupported CPU @0@, try --enable-tcg-interpreter'.format(cpu))
     endif
-  elif host_arch == 'wasm32' or host_arch == 'wasm64'
+  elif host_arch == 'wasm64'
     if not get_option('tcg_interpreter')
       error('WebAssembly host requires --enable-tcg-interpreter')
     endif
@@ -4248,7 +4248,7 @@ if have_rust
     bindgen_args_common += ['--merge-extern-blocks']
   endif
   bindgen_c_args = []
-  if host_arch == 'wasm32'
+  if host_arch == 'wasm64'
     bindgen_c_args += ['-fvisibility=default']
   endif
   subdir('rust')
Signature · 1 line
2.43.0
Reviewed-by on v2 9/58
#15 lore raw

Re: [PATCH v2 09/58] meson: Drop cpu == wasm32 tests

Quoted 13 lines

The 32-bit wasm32 host is no longer supported.

---
 configure   | 5 +----
 meson.build | 6 +++---
 2 files changed, 4 insertions(+), 7 deletions(-)
configure +0 -0
index 326d27dab1..ba1b207b56 100755

configure elif check_define __aarch64__ ; then · line 430

Quoted 7 lines
configure +1 -1
@@ -425,7 +425,7 @@ elif check_define __aarch64__ ; then
 elif check_define __loongarch64 ; then
   cpu="loongarch64"
 elif check_define EMSCRIPTEN ; then
-  error_exit "wasm32 or wasm64 must be specified to the cpu flag"
+  error_exit "wasm64 must be specified to the cpu flag"
 else
   # Using uname is really broken, but it is just a fallback for

architectures

Quoted 16 lines
configure +0 -3
   # that are going to use TCI anyway
@@ -523,9 +523,6 @@ case "$cpu" in
     linux_arch=x86
     CPU_CFLAGS="-m64"
     ;;
-  wasm32)
-    CPU_CFLAGS="-m32"
-    ;;
   wasm64)
     CPU_CFLAGS="-m64 -sMEMORY64=$wasm64_memory64"
     ;;
meson.build +0 -0
index 28f61be675..082c7a86ca 100644

meson.build qapi_trace_events = [] · line 51

Quoted 1 line
meson.build +0 -0
@@ -51,7 +51,7 @@ qapi_trace_events = []
 bsd_oses = ['gnu/kfreebsd', 'freebsd', 'netbsd', 'openbsd', 'dragonfly',

'darwin']

meson.build qapi_trace_events = [] · line 52

Quoted 1 line
meson.build +0 -0
 supported_oses = ['windows', 'freebsd', 'netbsd', 'openbsd', 'darwin',

'sunos', 'linux', 'emscripten']

meson.build qapi_trace_events = [] · line 53

Quoted 1 line
meson.build +0 -0
 supported_cpus = ['ppc', 'ppc64', 's390x', 'riscv32', 'riscv64', 'x86',

'x86_64',

meson.build qapi_trace_events = [] · line 54

Quoted 1 line
meson.build +0 -1
-  'arm', 'aarch64', 'loongarch64', 'mips64', 'sparc64', 'wasm32',

'wasm64']

meson.build if have_tcg · line 928

Quoted 7 lines
meson.build +1 -0
+  'arm', 'aarch64', 'loongarch64', 'mips64', 'sparc64', 'wasm64']
 
 cpu = host_machine.cpu_family()
 
@@ -927,7 +927,7 @@ if have_tcg
     if not get_option('tcg_interpreter')
       error('Unsupported CPU @0@, try

--enable-tcg-interpreter'.format(cpu))

Quoted 7 lines
meson.build +1 -1
     endif
-  elif host_arch == 'wasm32' or host_arch == 'wasm64'
+  elif host_arch == 'wasm64'
     if not get_option('tcg_interpreter')
       error('WebAssembly host requires --enable-tcg-interpreter')
     endif

meson.build if have_rust · line 4254

Quoted 8 lines
meson.build +1 -1
@@ -4248,7 +4248,7 @@ if have_rust
     bindgen_args_common += ['--merge-extern-blocks']
   endif
   bindgen_c_args = []
-  if host_arch == 'wasm32'
+  if host_arch == 'wasm64'
     bindgen_c_args += ['-fvisibility=default']
   endif
   subdir('rust')
#16 lore raw

PATCH v2 10/58 *: Remove arm host support

In reply to Richard Henderson

Remove tcg/arm.
Remove instances of __arm__, except from tests and imported headers. Remove arm from supported_cpus.
Remove linux-user/include/host/arm.
Remove common-user/host/arm.

---
 include/qemu/osdep.h                      |    2 +-
 linux-user/include/host/arm/host-signal.h |   43 -
 tcg/arm/tcg-target-con-set.h              |   47 -
 tcg/arm/tcg-target-con-str.h              |   26 -
 tcg/arm/tcg-target-has.h                  |   73 -
 tcg/arm/tcg-target-mo.h                   |   13 -
 tcg/arm/tcg-target-reg-bits.h             |   12 -
 tcg/arm/tcg-target.h                      |   73 -
 disas/disas-host.c                        |    3 -
 hw/virtio/virtio-mem.c                    |    2 +-
 linux-user/mmap.c                         |    2 +-
 MAINTAINERS                               |    6 -
 common-user/host/arm/safe-syscall.inc.S   |  108 -
 configure                                 |    7 -
 meson.build                               |    7 +-
 tcg/arm/tcg-target-opc.h.inc              |   16 -
 tcg/arm/tcg-target.c.inc                  | 3489 ---------------------
 17 files changed, 5 insertions(+), 3924 deletions(-)
 delete mode 100644 linux-user/include/host/arm/host-signal.h
 delete mode 100644 tcg/arm/tcg-target-con-set.h
 delete mode 100644 tcg/arm/tcg-target-con-str.h
 delete mode 100644 tcg/arm/tcg-target-has.h
 delete mode 100644 tcg/arm/tcg-target-mo.h
 delete mode 100644 tcg/arm/tcg-target-reg-bits.h
 delete mode 100644 tcg/arm/tcg-target.h
 delete mode 100644 common-user/host/arm/safe-syscall.inc.S
 delete mode 100644 tcg/arm/tcg-target-opc.h.inc
 delete mode 100644 tcg/arm/tcg-target.c.inc
include/qemu/osdep.h +1 -1
index 3cb45a1467..4cdeda0b9c 100644
@@ -566,7 +566,7 @@ int madvise(char *, size_t, int);
 #endif
 
 #if defined(__linux__) && \
-    (defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) \
+    (defined(__x86_64__) || defined(__aarch64__) \
      || defined(__powerpc64__) || defined(__riscv))
    /* Use 2 MiB alignment so transparent hugepages can be used by KVM.
       Valgrind does not support alignments larger than 1 MiB,
linux-user/include/host/arm/host-signal.h deleted +0 -43

43 lines not on this page · raw message

tcg/arm/tcg-target-con-set.h deleted +0 -47

47 lines not on this page · raw message

tcg/arm/tcg-target-con-str.h deleted +0 -26
deleted file mode 100644
index f83f1d3919..0000000000
@@ -1,26 +0,0 @@
-/* SPDX-License-Identifier: MIT */
-/*
- * Define Arm target-specific operand constraints.
- * Copyright (c) 2021 Linaro
- */
-
-/*
- * Define constraint letters for register sets:
- * REGS(letter, register_mask)
- */
-REGS('e', ALL_GENERAL_REGS & 0x5555) /* even regs */
-REGS('r', ALL_GENERAL_REGS)
-REGS('q', ALL_QLDST_REGS)
-REGS('Q', ALL_QLDST_REGS & 0x5555)   /* even qldst */
-REGS('w', ALL_VECTOR_REGS)
-
-/*
- * Define constraint letters for constants:
- * CONST(letter, TCG_CT_CONST_* bit set)
- */
-CONST('I', TCG_CT_CONST_ARM)
-CONST('K', TCG_CT_CONST_INV)
-CONST('N', TCG_CT_CONST_NEG)
-CONST('O', TCG_CT_CONST_ORRI)
-CONST('V', TCG_CT_CONST_ANDI)
-CONST('Z', TCG_CT_CONST_ZERO)
tcg/arm/tcg-target-has.h deleted +0 -73

73 lines not on this page · raw message

tcg/arm/tcg-target-mo.h deleted +0 -13
deleted file mode 100644
index 12542dfd1c..0000000000
@@ -1,13 +0,0 @@
-/* SPDX-License-Identifier: MIT */
-/*
- * Define target-specific memory model
- * Copyright (c) 2008 Fabrice Bellard
- * Copyright (c) 2008 Andrzej Zaborowski
- */
-
-#ifndef TCG_TARGET_MO_H
-#define TCG_TARGET_MO_H
-
-#define TCG_TARGET_DEFAULT_MO  0
-
-#endif
tcg/arm/tcg-target-reg-bits.h deleted +0 -12
deleted file mode 100644
index 23b7730a8d..0000000000
@@ -1,12 +0,0 @@
-/* SPDX-License-Identifier: MIT */
-/*
- * Define target-specific register size
- * Copyright (c) 2023 Linaro
- */
-
-#ifndef TCG_TARGET_REG_BITS_H
-#define TCG_TARGET_REG_BITS_H
-
-#define TCG_TARGET_REG_BITS  32
-
-#endif
tcg/arm/tcg-target.h deleted +0 -73

73 lines not on this page · raw message

disas/disas-host.c +0 -3
index 4b06f41fa6..88e7d8800c 100644
@@ -74,9 +74,6 @@ static void initialize_debug_host(CPUDebug *s)
 #elif defined(__sparc__)
     s->info.print_insn = print_insn_sparc;
     s->info.mach = bfd_mach_sparc_v9b;
-#elif defined(__arm__)
-    /* TCG only generates code for arm mode.  */
-    s->info.cap_arch = CS_ARCH_ARM;
 #elif defined(__MIPSEB__)
     s->info.print_insn = print_insn_big_mips;
 #elif defined(__MIPSEL__)
hw/virtio/virtio-mem.c +1 -1
index 41de2ef5a0..c1e2defb68 100644
@@ -60,7 +60,7 @@ static uint32_t virtio_mem_default_thp_size(void)
 {
     uint32_t default_thp_size = VIRTIO_MEM_MIN_BLOCK_SIZE;
 
-#if defined(__x86_64__) || defined(__arm__) || defined(__powerpc64__)
+#if defined(__x86_64__) || defined(__powerpc64__)
     default_thp_size = 2 * MiB;
 #elif defined(__aarch64__)
     if (qemu_real_host_page_size() == 4 * KiB) {
linux-user/mmap.c +1 -1
index 4bcfaf7894..07175e11d5 100644
@@ -1296,7 +1296,7 @@ static inline abi_ulong target_shmlba(CPUArchState *cpu_env)
 }
 #endif
 
-#if defined(__arm__) || defined(__mips__) || defined(__sparc__)
+#if defined(__mips__) || defined(__sparc__)
 #define HOST_FORCE_SHMLBA 1
 #else
 #define HOST_FORCE_SHMLBA 0
MAINTAINERS +0 -6
index de8246c3ff..1a6e5bbafe 100644
@@ -4057,12 +4057,6 @@ S: Maintained
 L: [email protected]
 F: tcg/aarch64/
 
-ARM TCG target
-M: Richard Henderson <[email protected]>
-S: Maintained
-L: [email protected]
-F: tcg/arm/
-
 i386 TCG target
 M: Richard Henderson <[email protected]>
 S: Maintained
common-user/host/arm/safe-syscall.inc.S deleted +0 -108

108 lines not on this page · raw message

configure +0 -7
index ba1b207b56..0742f1212d 100755
@@ -418,8 +418,6 @@ elif check_define __riscv ; then
   else
     cpu="riscv32"
   fi
-elif check_define __arm__ ; then
-  cpu="arm"
 elif check_define __aarch64__ ; then
   cpu="aarch64"
 elif check_define __loongarch64 ; then
@@ -451,11 +449,6 @@ case "$cpu" in
     linux_arch=arm64
     ;;
 
-  armv*b|armv*l|arm)
-    cpu=arm
-    host_arch=arm
-    ;;
-
   i386|i486|i586|i686)
     cpu="i386"
     host_arch=i386
meson.build +2 -5
index 082c7a86ca..137b2dcdc7 100644
@@ -51,7 +51,7 @@ qapi_trace_events = []
 bsd_oses = ['gnu/kfreebsd', 'freebsd', 'netbsd', 'openbsd', 'dragonfly', 'darwin']
 supported_oses = ['windows', 'freebsd', 'netbsd', 'openbsd', 'darwin', 'sunos', 'linux', 'emscripten']
 supported_cpus = ['ppc', 'ppc64', 's390x', 'riscv32', 'riscv64', 'x86', 'x86_64',
-  'arm', 'aarch64', 'loongarch64', 'mips64', 'sparc64', 'wasm64']
+  'aarch64', 'loongarch64', 'mips64', 'sparc64', 'wasm64']
 
 cpu = host_machine.cpu_family()
 
@@ -304,9 +304,6 @@ if cpu == 'x86'
   xen_targets = ['i386-softmmu']
 elif cpu == 'x86_64'
   xen_targets = ['i386-softmmu', 'x86_64-softmmu']
-elif cpu == 'arm'
-  # i386 emulator provides xenpv machine type for multiple architectures
-  xen_targets = ['i386-softmmu']
 elif cpu == 'aarch64'
   # i386 emulator provides xenpv machine type for multiple architectures
   xen_targets = ['i386-softmmu', 'x86_64-softmmu', 'aarch64-softmmu']
@@ -3156,7 +3153,7 @@ endif
 config_host_data.set('CONFIG_AVX2_OPT', have_avx2)
 config_host_data.set('CONFIG_AVX512BW_OPT', have_avx512bw)
 
-# For both AArch64 and AArch32, detect if builtins are available.
+# For AArch64, detect if builtins are available.
 config_host_data.set('CONFIG_ARM_AES_BUILTIN', cc.compiles('''
     #include <arm_neon.h>
     #ifndef __ARM_FEATURE_AES
tcg/arm/tcg-target-opc.h.inc deleted +0 -16
deleted file mode 100644
index 70394e0282..0000000000
@@ -1,16 +0,0 @@
-/*
- * Copyright (c) 2019 Linaro
- *
- * This work is licensed under the terms of the GNU GPL, version 2 or
- * (at your option) any later version.
- *
- * See the COPYING file in the top-level directory for details.
- *
- * Target-specific opcodes for host vector expansion.  These will be
- * emitted by tcg_expand_vec_op.  For those familiar with GCC internals,
- * consider these to be UNSPEC with names.
- */
-
-DEF(arm_sli_vec, 1, 2, 1, TCG_OPF_VECTOR)
-DEF(arm_sshl_vec, 1, 2, 0, TCG_OPF_VECTOR)
-DEF(arm_ushl_vec, 1, 2, 0, TCG_OPF_VECTOR)
tcg/arm/tcg-target.c.inc deleted +0 -3489

2,500 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.43.0

Part of the diff is not shown here. View the raw message.

#17 lore raw

PATCH v2 11/58 bsd-user: Fix __i386__ test for TARGET_HAS_STAT_TIME_T_EXT

In reply to Richard Henderson

The target test is TARGET_I386, not __i386__.

---
 bsd-user/syscall_defs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
bsd-user/syscall_defs.h +1 -1
index 52f84d5dd1..c49be32bdc 100644
@@ -247,7 +247,7 @@ struct target_freebsd11_stat {
     unsigned int:(8 / 2) * (16 - (int)sizeof(struct target_freebsd_timespec));
 } __packed;
 
-#if defined(__i386__)
+#if defined(TARGET_I386)
 #define TARGET_HAS_STAT_TIME_T_EXT       1
 #endif
 
Signature · 1 line
2.43.0
Reviewed-by on v2 11/58
#18 lore raw

Re: [PATCH v2 11/58] bsd-user: Fix __i386__ test for TARGET_HAS_STAT_TIME_T_EXT

Quoted 11 lines · Richard Henderson

The target test is TARGET_I386, not __i386__.

---
 bsd-user/syscall_defs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
bsd-user/syscall_defs.h +0 -0
Quoted 17 lines

index 52f84d5dd1..c49be32bdc 100644

bsd-user/syscall_defs.h +1 -2
@@ -247,7 +247,7 @@ struct target_freebsd11_stat {
     unsigned int:(8 / 2) * (16 - (int)sizeof(struct
 target_freebsd_timespec));
 } __packed;
 
-#if defined(__i386__)
+#if defined(TARGET_I386)
 #define TARGET_HAS_STAT_TIME_T_EXT       1
 #endif
 
--

2.43.0

#19 lore raw

Re: [PATCH v2 11/58] bsd-user: Fix __i386__ test for TARGET_HAS_STAT_TIME_T_EXT

In reply to Richard Henderson
Quoted 7 lines · Richard Henderson

The target test is TARGET_I386, not __i386__.

This looks like a qemu-stable material (but probably of very low priority). Please let me know if it is not.

Thanks,

/mjt

Quoted 17 lines
---
  bsd-user/syscall_defs.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
bsd-user/syscall_defs.h +1 -1
index 52f84d5dd1..c49be32bdc 100644
@@ -247,7 +247,7 @@ struct target_freebsd11_stat {
      unsigned int:(8 / 2) * (16 - (int)sizeof(struct target_freebsd_timespec));
  } __packed;
 
-#if defined(__i386__)
+#if defined(TARGET_I386)
  #define TARGET_HAS_STAT_TIME_T_EXT       1
  #endif
 
#20 lore raw

Re: [PATCH v2 11/58] bsd-user: Fix __i386__ test for TARGET_HAS_STAT_TIME_T_EXT

Quoted 9 lines · Michael Tokarev
Quoted 7 lines · Richard Henderson

The target test is TARGET_I386, not __i386__.

Quoted 6 lines

This looks like a qemu-stable material (but probably of very low priority). Please let me know if it is not.

Thanks,

/mjt

It needs to come with this fix, or it will introduce a regression on x86_64 hosts:
https://lore.kernel.org/qemu-devel/[email protected]/T/#u

Regards,
Pierrick

#21 lore raw

PATCH v2 12/58 *: Remove __i386__ tests

In reply to Richard Henderson

Remove instances of __i386__, except from tests and imported headers.

Drop a block containing sanity check and fprintf error message for i386-on-i386 or x86_64-on-x86_64 emulation. If we really want something like this, we would do it via some form of compile-time check.

---
 include/qemu/atomic.h     |  4 ++--
 include/qemu/cacheflush.h |  2 +-
 include/qemu/osdep.h      |  4 +---
 include/qemu/processor.h  |  2 +-
 include/qemu/timer.h      |  9 ---------
 tcg/tci/tcg-target-mo.h   |  2 +-
 accel/kvm/kvm-all.c       |  2 +-
 disas/disas-host.c        |  6 ------
 hw/display/xenfb.c        | 10 +---------
 linux-user/syscall.c      |  9 ---------
 target/i386/cpu.c         | 10 ----------
 util/cacheflush.c         |  2 +-
 configure                 |  2 --
 13 files changed, 9 insertions(+), 55 deletions(-)
include/qemu/atomic.h +2 -2
index f80cba24cf..c39dc99f2f 100644
@@ -204,7 +204,7 @@
  * the same semantics.
  */
 #if !defined(QEMU_SANITIZE_THREAD) && \
-    (defined(__i386__) || defined(__x86_64__) || defined(__s390x__))
+    (defined(__x86_64__) || defined(__s390x__))
 # define smp_mb__before_rmw() signal_barrier()
 # define smp_mb__after_rmw() signal_barrier()
 #else
@@ -218,7 +218,7 @@
  */
 
 #if !defined(QEMU_SANITIZE_THREAD) && \
-    (defined(__i386__) || defined(__x86_64__) || defined(__s390x__))
+    (defined(__x86_64__) || defined(__s390x__))
 # define qatomic_set_mb(ptr, i) \
     ({ (void)qatomic_xchg(ptr, i); smp_mb__after_rmw(); })
 #else
include/qemu/cacheflush.h +1 -1
index 76eb55d818..8c64b87814 100644
@@ -19,7 +19,7 @@
  * mappings of the same physical page(s).
  */
 
-#if defined(__i386__) || defined(__x86_64__) || defined(__s390__)
+#if defined(__x86_64__) || defined(__s390__)
 
 static inline void flush_idcache_range(uintptr_t rx, uintptr_t rw, size_t len)
 {
include/qemu/osdep.h +1 -3
index 4cdeda0b9c..b384b5b506 100644
@@ -637,9 +637,7 @@ bool qemu_has_ofd_lock(void);
 
 bool qemu_has_direct_io(void);
 
-#if defined(__HAIKU__) && defined(__i386__)
-#define FMT_pid "%ld"
-#elif defined(WIN64)
+#ifdef WIN64
 #define FMT_pid "%" PRId64
 #else
 #define FMT_pid "%d"
include/qemu/processor.h +1 -1
index 9f0dcdf28f..95b3262f8b 100644
@@ -7,7 +7,7 @@
 #ifndef QEMU_PROCESSOR_H
 #define QEMU_PROCESSOR_H
 
-#if defined(__i386__) || defined(__x86_64__)
+#if defined(__x86_64__)
 # define cpu_relax() asm volatile("rep; nop" ::: "memory")
 
 #elif defined(__aarch64__)
include/qemu/timer.h +0 -9
index 8b561cd696..7c18da1652 100644
@@ -866,15 +866,6 @@ static inline int64_t cpu_get_host_ticks(void)
     return retval;
 }
 
-#elif defined(__i386__)
-
-static inline int64_t cpu_get_host_ticks(void)
-{
-    int64_t val;
-    asm volatile ("rdtsc" : "=A" (val));
-    return val;
-}
-
 #elif defined(__x86_64__)
 
 static inline int64_t cpu_get_host_ticks(void)
tcg/tci/tcg-target-mo.h +1 -1
index 779872e39a..b5b389dafc 100644
@@ -8,7 +8,7 @@
 #define TCG_TARGET_MO_H
 
 /*
- * We could notice __i386__ or __s390x__ and reduce the barriers depending
+ * We could notice __x86_64__ or __s390x__ and reduce the barriers depending
  * on the host.  But if you want performance, you use the normal backend.
  * We prefer consistency across hosts on this.
  */
accel/kvm/kvm-all.c +1 -1
index f85eb42d78..8301a512e7 100644
@@ -61,7 +61,7 @@
 #include <sys/eventfd.h>
 #endif
 
-#if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__)
+#if defined(__x86_64__) || defined(__aarch64__)
 # define KVM_HAVE_MCE_INJECTION 1
 #endif
 
disas/disas-host.c +0 -6
index 88e7d8800c..7cf432938e 100644
@@ -44,12 +44,6 @@ static void initialize_debug_host(CPUDebug *s)
 #endif
 #if defined(CONFIG_TCG_INTERPRETER)
     s->info.print_insn = print_insn_tci;
-#elif defined(__i386__)
-    s->info.mach = bfd_mach_i386_i386;
-    s->info.cap_arch = CS_ARCH_X86;
-    s->info.cap_mode = CS_MODE_32;
-    s->info.cap_insn_unit = 1;
-    s->info.cap_insn_split = 8;
 #elif defined(__x86_64__)
     s->info.mach = bfd_mach_x86_64;
     s->info.cap_arch = CS_ARCH_X86;
hw/display/xenfb.c +1 -9
index 164fd0b248..ba886a940e 100644
@@ -459,10 +459,7 @@ static int xenfb_map_fb(struct XenFB *xenfb)
          */
         uint32_t *ptr32 = NULL;
         uint32_t *ptr64 = NULL;
-#if defined(__i386__)
-        ptr32 = (void*)page->pd;
-        ptr64 = ((void*)page->pd) + 4;
-#elif defined(__x86_64__)
+#if defined(__x86_64__)
         ptr32 = ((void*)page->pd) - 4;
         ptr64 = (void*)page->pd;
 #endif
@@ -480,11 +477,6 @@ static int xenfb_map_fb(struct XenFB *xenfb)
         /* 64bit dom0, 32bit domU */
         mode = 32;
         pd   = ((void*)page->pd) - 4;
-#elif defined(__i386__)
-    } else if (strcmp(protocol, XEN_IO_PROTO_ABI_X86_64) == 0) {
-        /* 32bit dom0, 64bit domU */
-        mode = 64;
-        pd   = ((void*)page->pd) + 4;
 #endif
     }
 
linux-user/syscall.c +0 -9
index 67ad681098..3601715769 100644
@@ -7452,15 +7452,6 @@ void syscall_init(void)
                               ~(TARGET_IOC_SIZEMASK << TARGET_IOC_SIZESHIFT)) |
                 (size << TARGET_IOC_SIZESHIFT);
         }
-
-        /* automatic consistency check if same arch */
-#if (defined(__i386__) && defined(TARGET_I386) && defined(TARGET_ABI32)) || \
-    (defined(__x86_64__) && defined(TARGET_X86_64))
-        if (unlikely(ie->target_cmd != ie->host_cmd)) {
-            fprintf(stderr, "ERROR: ioctl(%s): target=0x%x host=0x%x\n",
-                    ie->name, ie->target_cmd, ie->host_cmd);
-        }
-#endif
         ie++;
     }
 }
target/i386/cpu.c +0 -10
index 37803cd724..0b8cca7cec 100644
@@ -2251,16 +2251,6 @@ void host_cpuid(uint32_t function, uint32_t count,
                  : "=a"(vec[0]), "=b"(vec[1]),
                    "=c"(vec[2]), "=d"(vec[3])
                  : "0"(function), "c"(count) : "cc");
-#elif defined(__i386__)
-    asm volatile("pusha \n\t"
-                 "cpuid \n\t"
-                 "mov %%eax, 0(%2) \n\t"
-                 "mov %%ebx, 4(%2) \n\t"
-                 "mov %%ecx, 8(%2) \n\t"
-                 "mov %%edx, 12(%2) \n\t"
-                 "popa"
-                 : : "a"(function), "c"(count), "S"(vec)
-                 : "memory", "cc");
 #else
     abort();
 #endif
util/cacheflush.c +1 -1
index 69c9614e2c..99221a409f 100644
@@ -225,7 +225,7 @@ static void __attribute__((constructor)) init_cache_info(void)
  * Architecture (+ OS) specific cache flushing mechanisms.
  */
 
-#if defined(__i386__) || defined(__x86_64__) || defined(__s390__)
+#if defined(__x86_64__) || defined(__s390__)
 
 /* Caches are coherent and do not require flushing; symbol inline. */
 
configure +0 -2
index 0742f1212d..de0f3a8ebe 100755
@@ -382,8 +382,6 @@ fi
 if test ! -z "$cpu" ; then
   # command line argument
   :
-elif check_define __i386__ ; then
-  cpu="i386"
 elif check_define __x86_64__ ; then
   if check_define __ILP32__ ; then
     cpu="x32"
Signature · 1 line
2.43.0
#22 lore raw

PATCH v2 13/58 *: Remove i386 host support

In reply to Richard Henderson

Move the files from host/include/i386 to host/include/x86_64, replacing the stub headers that redirected to i386.

Remove linux-user/include/host/i386.
Remove common-user/host/i386.

---
 host/include/i386/host/cpuinfo.h            |  41 ------
 host/include/i386/host/crypto/aes-round.h   | 152 -------------------
 host/include/i386/host/crypto/clmul.h       |  29 ----
 host/include/x86_64/host/cpuinfo.h          |  42 +++++-
 host/include/x86_64/host/crypto/aes-round.h | 153 +++++++++++++++++++-
 host/include/x86_64/host/crypto/clmul.h     |  30 +++-
 linux-user/include/host/i386/host-signal.h  |  38 -----
 common-user/host/i386/safe-syscall.inc.S    | 127 ----------------
 host/include/i386/host/bufferiszero.c.inc   | 125 ----------------
 host/include/x86_64/host/bufferiszero.c.inc | 126 +++++++++++++++-
 10 files changed, 347 insertions(+), 516 deletions(-)
 delete mode 100644 host/include/i386/host/cpuinfo.h
 delete mode 100644 host/include/i386/host/crypto/aes-round.h
 delete mode 100644 host/include/i386/host/crypto/clmul.h
 delete mode 100644 linux-user/include/host/i386/host-signal.h
 delete mode 100644 common-user/host/i386/safe-syscall.inc.S
 delete mode 100644 host/include/i386/host/bufferiszero.c.inc
host/include/i386/host/cpuinfo.h deleted +0 -41
deleted file mode 100644
index 93d029d499..0000000000
@@ -1,41 +0,0 @@
-/*
- * SPDX-License-Identifier: GPL-2.0-or-later
- * Host specific cpu identification for x86.
- */
-
-#ifndef HOST_CPUINFO_H
-#define HOST_CPUINFO_H
-
-/* Digested version of <cpuid.h> */
-
-#define CPUINFO_ALWAYS          (1u << 0)  /* so cpuinfo is nonzero */
-#define CPUINFO_OSXSAVE         (1u << 1)
-#define CPUINFO_MOVBE           (1u << 2)
-#define CPUINFO_LZCNT           (1u << 3)
-#define CPUINFO_POPCNT          (1u << 4)
-#define CPUINFO_BMI1            (1u << 5)
-#define CPUINFO_BMI2            (1u << 6)
-#define CPUINFO_SSE2            (1u << 7)
-#define CPUINFO_AVX1            (1u << 9)
-#define CPUINFO_AVX2            (1u << 10)
-#define CPUINFO_AVX512F         (1u << 11)
-#define CPUINFO_AVX512VL        (1u << 12)
-#define CPUINFO_AVX512BW        (1u << 13)
-#define CPUINFO_AVX512DQ        (1u << 14)
-#define CPUINFO_AVX512VBMI2     (1u << 15)
-#define CPUINFO_ATOMIC_VMOVDQA  (1u << 16)
-#define CPUINFO_ATOMIC_VMOVDQU  (1u << 17)
-#define CPUINFO_AES             (1u << 18)
-#define CPUINFO_PCLMUL          (1u << 19)
-#define CPUINFO_GFNI            (1u << 20)
-
-/* Initialized with a constructor. */
-extern unsigned cpuinfo;
-
-/*
- * We cannot rely on constructor ordering, so other constructors must
- * use the function interface rather than the variable above.
- */
-unsigned cpuinfo_init(void);
-
-#endif /* HOST_CPUINFO_H */
host/include/i386/host/crypto/aes-round.h deleted +0 -152

152 lines not on this page · raw message

host/include/i386/host/crypto/clmul.h deleted +0 -29
deleted file mode 100644
index dc3c814797..0000000000
@@ -1,29 +0,0 @@
-/*
- * x86 specific clmul acceleration.
- * SPDX-License-Identifier: GPL-2.0-or-later
- */
-
-#ifndef X86_HOST_CRYPTO_CLMUL_H
-#define X86_HOST_CRYPTO_CLMUL_H
-
-#include "host/cpuinfo.h"
-#include <immintrin.h>
-
-#if defined(__PCLMUL__)
-# define HAVE_CLMUL_ACCEL  true
-# define ATTR_CLMUL_ACCEL
-#else
-# define HAVE_CLMUL_ACCEL  likely(cpuinfo & CPUINFO_PCLMUL)
-# define ATTR_CLMUL_ACCEL  __attribute__((target("pclmul")))
-#endif
-
-static inline Int128 ATTR_CLMUL_ACCEL
-clmul_64_accel(uint64_t n, uint64_t m)
-{
-    union { __m128i v; Int128 s; } u;
-
-    u.v = _mm_clmulepi64_si128(_mm_set_epi64x(0, n), _mm_set_epi64x(0, m), 0);
-    return u.s;
-}
-
-#endif /* X86_HOST_CRYPTO_CLMUL_H */
host/include/x86_64/host/cpuinfo.h +41 -1

42 lines not on this page · raw message

host/include/x86_64/host/crypto/aes-round.h +152 -1

153 lines not on this page · raw message

host/include/x86_64/host/crypto/clmul.h +29 -1
index f25eced416..dc3c814797 100644
@@ -1 +1,29 @@
-#include "host/include/i386/host/crypto/clmul.h"
+/*
+ * x86 specific clmul acceleration.
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef X86_HOST_CRYPTO_CLMUL_H
+#define X86_HOST_CRYPTO_CLMUL_H
+
+#include "host/cpuinfo.h"
+#include <immintrin.h>
+
+#if defined(__PCLMUL__)
+# define HAVE_CLMUL_ACCEL  true
+# define ATTR_CLMUL_ACCEL
+#else
+# define HAVE_CLMUL_ACCEL  likely(cpuinfo & CPUINFO_PCLMUL)
+# define ATTR_CLMUL_ACCEL  __attribute__((target("pclmul")))
+#endif
+
+static inline Int128 ATTR_CLMUL_ACCEL
+clmul_64_accel(uint64_t n, uint64_t m)
+{
+    union { __m128i v; Int128 s; } u;
+
+    u.v = _mm_clmulepi64_si128(_mm_set_epi64x(0, n), _mm_set_epi64x(0, m), 0);
+    return u.s;
+}
+
+#endif /* X86_HOST_CRYPTO_CLMUL_H */
linux-user/include/host/i386/host-signal.h deleted +0 -38
deleted file mode 100644
index e2b64f077f..0000000000
@@ -1,38 +0,0 @@
-/*
- * host-signal.h: signal info dependent on the host architecture
- *
- * Copyright (c) 2003-2005 Fabrice Bellard
- * Copyright (c) 2021 Linaro Limited
- *
- * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
- * See the COPYING file in the top-level directory.
- */
-
-#ifndef I386_HOST_SIGNAL_H
-#define I386_HOST_SIGNAL_H
-
-/* The third argument to a SA_SIGINFO handler is ucontext_t. */
-typedef ucontext_t host_sigcontext;
-
-static inline uintptr_t host_signal_pc(host_sigcontext *uc)
-{
-    return uc->uc_mcontext.gregs[REG_EIP];
-}
-
-static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc)
-{
-    uc->uc_mcontext.gregs[REG_EIP] = pc;
-}
-
-static inline void *host_signal_mask(host_sigcontext *uc)
-{
-    return &uc->uc_sigmask;
-}
-
-static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc)
-{
-    return uc->uc_mcontext.gregs[REG_TRAPNO] == 0xe
-        && (uc->uc_mcontext.gregs[REG_ERR] & 0x2);
-}
-
-#endif
common-user/host/i386/safe-syscall.inc.S deleted +0 -127

127 lines not on this page · raw message

host/include/i386/host/bufferiszero.c.inc deleted +0 -125

125 lines not on this page · raw message

host/include/x86_64/host/bufferiszero.c.inc +125 -1

126 lines not on this page · raw message

Signature · 1 line
2.43.0
#23 lore raw

PATCH v2 14/58 host/include/x86_64/bufferiszero: Remove no SSE2 fallback

In reply to Richard Henderson

Since x86_64 always has SSE2, we can remove the fallback that was present for i686.

---
 host/include/x86_64/host/bufferiszero.c.inc | 5 -----
 1 file changed, 5 deletions(-)
host/include/x86_64/host/bufferiszero.c.inc +0 -5
index 74ae98580f..7e9d896a8d 100644
@@ -3,7 +3,6 @@
  * buffer_is_zero acceleration, x86 version.
  */
 
-#if defined(CONFIG_AVX2_OPT) || defined(__SSE2__)
 #include <immintrin.h>
 
 /* Helper for preventing the compiler from reassociating
@@ -119,7 +118,3 @@ static unsigned best_accel(void)
 #endif
     return info & CPUINFO_SSE2 ? 1 : 0;
 }
-
-#else
-# include "host/include/generic/host/bufferiszero.c.inc"
-#endif
Signature · 1 line
2.43.0
#24 lore raw

PATCH v2 15/58 meson: Remove cpu == x86 tests

In reply to Richard Henderson

The 32-bit x86 host is no longer supported.

---
 configure   | 16 +---------------
 meson.build | 49 ++++++++++---------------------------------------
 2 files changed, 11 insertions(+), 54 deletions(-)
configure +1 -15
index de0f3a8ebe..e9d0b9e2c0 100755
@@ -447,13 +447,6 @@ case "$cpu" in
     linux_arch=arm64
     ;;
 
-  i386|i486|i586|i686)
-    cpu="i386"
-    host_arch=i386
-    linux_arch=x86
-    CPU_CFLAGS="-m32"
-    ;;
-
   loongarch*)
     cpu=loongarch64
     host_arch=loongarch64
@@ -1944,14 +1937,7 @@ if test "$skip_meson" = no; then
   if test "$cross_compile" = "yes"; then
     echo "[host_machine]" >> $cross
     echo "system = '$host_os'" >> $cross
-    case "$cpu" in
-        i386)
-            echo "cpu_family = 'x86'" >> $cross
-            ;;
-        *)
-            echo "cpu_family = '$cpu'" >> $cross
-            ;;
-    esac
+    echo "cpu_family = '$cpu'" >> $cross
     echo "cpu = '$cpu'" >> $cross
     if test "$bigendian" = "yes" ; then
         echo "endian = 'big'" >> $cross
meson.build +10 -39

97 lines not on this page · raw message

Signature · 1 line
2.43.0
#25 lore raw

PATCH v2 16/58 *: Remove ppc host support

In reply to Richard Henderson

Move the files from host/include/ppc to host/include/ppc64, replacing the stub headers that redirected to ppc.

Remove linux-user/include/host/ppc.
Remove common-user/host/ppc.
Remove cpu == ppc tests from meson.

---
 host/include/ppc/host/cpuinfo.h            |  30 ----
 host/include/ppc/host/crypto/aes-round.h   | 182 --------------------
 host/include/ppc64/host/cpuinfo.h          |  31 +++-
 host/include/ppc64/host/crypto/aes-round.h | 183 ++++++++++++++++++++-
 linux-user/include/host/ppc/host-signal.h  |  39 -----
 common-user/host/ppc/safe-syscall.inc.S    | 107 ------------
 meson.build                                |   4 +-
 7 files changed, 213 insertions(+), 363 deletions(-)
 delete mode 100644 host/include/ppc/host/cpuinfo.h
 delete mode 100644 host/include/ppc/host/crypto/aes-round.h
 delete mode 100644 linux-user/include/host/ppc/host-signal.h
 delete mode 100644 common-user/host/ppc/safe-syscall.inc.S
host/include/ppc/host/cpuinfo.h deleted +0 -30
deleted file mode 100644
index 38b8eabe2a..0000000000
@@ -1,30 +0,0 @@
-/*
- * SPDX-License-Identifier: GPL-2.0-or-later
- * Host specific cpu identification for ppc.
- */
-
-#ifndef HOST_CPUINFO_H
-#define HOST_CPUINFO_H
-
-/* Digested version of <cpuid.h> */
-
-#define CPUINFO_ALWAYS          (1u << 0)  /* so cpuinfo is nonzero */
-#define CPUINFO_V2_06           (1u << 1)
-#define CPUINFO_V2_07           (1u << 2)
-#define CPUINFO_V3_0            (1u << 3)
-#define CPUINFO_V3_1            (1u << 4)
-#define CPUINFO_ISEL            (1u << 5)
-#define CPUINFO_ALTIVEC         (1u << 6)
-#define CPUINFO_VSX             (1u << 7)
-#define CPUINFO_CRYPTO          (1u << 8)
-
-/* Initialized with a constructor. */
-extern unsigned cpuinfo;
-
-/*
- * We cannot rely on constructor ordering, so other constructors must
- * use the function interface rather than the variable above.
- */
-unsigned cpuinfo_init(void);
-
-#endif /* HOST_CPUINFO_H */
host/include/ppc/host/crypto/aes-round.h deleted +0 -182

182 lines not on this page · raw message

host/include/ppc64/host/cpuinfo.h +30 -1
index 2f036a0627..38b8eabe2a 100644
@@ -1 +1,30 @@
-#include "host/include/ppc/host/cpuinfo.h"
+/*
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ * Host specific cpu identification for ppc.
+ */
+
+#ifndef HOST_CPUINFO_H
+#define HOST_CPUINFO_H
+
+/* Digested version of <cpuid.h> */
+
+#define CPUINFO_ALWAYS          (1u << 0)  /* so cpuinfo is nonzero */
+#define CPUINFO_V2_06           (1u << 1)
+#define CPUINFO_V2_07           (1u << 2)
+#define CPUINFO_V3_0            (1u << 3)
+#define CPUINFO_V3_1            (1u << 4)
+#define CPUINFO_ISEL            (1u << 5)
+#define CPUINFO_ALTIVEC         (1u << 6)
+#define CPUINFO_VSX             (1u << 7)
+#define CPUINFO_CRYPTO          (1u << 8)
+
+/* Initialized with a constructor. */
+extern unsigned cpuinfo;
+
+/*
+ * We cannot rely on constructor ordering, so other constructors must
+ * use the function interface rather than the variable above.
+ */
+unsigned cpuinfo_init(void);
+
+#endif /* HOST_CPUINFO_H */
host/include/ppc64/host/crypto/aes-round.h +182 -1

183 lines not on this page · raw message

linux-user/include/host/ppc/host-signal.h deleted +0 -39
deleted file mode 100644
index de25c803f5..0000000000
@@ -1,39 +0,0 @@
-/*
- * host-signal.h: signal info dependent on the host architecture
- *
- * Copyright (c) 2022 Linaro Ltd.
- *
- * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
- * See the COPYING file in the top-level directory.
- */
-
-#ifndef PPC_HOST_SIGNAL_H
-#define PPC_HOST_SIGNAL_H
-
-#include <asm/ptrace.h>
-
-/* The third argument to a SA_SIGINFO handler is ucontext_t. */
-typedef ucontext_t host_sigcontext;
-
-static inline uintptr_t host_signal_pc(host_sigcontext *uc)
-{
-    return uc->uc_mcontext.regs->nip;
-}
-
-static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc)
-{
-    uc->uc_mcontext.regs->nip = pc;
-}
-
-static inline void *host_signal_mask(host_sigcontext *uc)
-{
-    return &uc->uc_sigmask;
-}
-
-static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc)
-{
-    return uc->uc_mcontext.regs->trap != 0x400
-        && (uc->uc_mcontext.regs->dsisr & 0x02000000);
-}
-
-#endif
common-user/host/ppc/safe-syscall.inc.S deleted +0 -107

107 lines not on this page · raw message

meson.build +1 -3
index 506904c7d7..7993e4cfb9 100644
@@ -50,7 +50,7 @@ qapi_trace_events = []
 
 bsd_oses = ['gnu/kfreebsd', 'freebsd', 'netbsd', 'openbsd', 'dragonfly', 'darwin']
 supported_oses = ['windows', 'freebsd', 'netbsd', 'openbsd', 'darwin', 'sunos', 'linux', 'emscripten']
-supported_cpus = ['ppc', 'ppc64', 's390x', 'riscv32', 'riscv64', 'x86_64',
+supported_cpus = ['ppc64', 's390x', 'riscv32', 'riscv64', 'x86_64',
   'aarch64', 'loongarch64', 'mips64', 'sparc64', 'wasm64']
 
 cpu = host_machine.cpu_family()
@@ -279,8 +279,6 @@ elif cpu == 'aarch64'
   kvm_targets = ['aarch64-softmmu']
 elif cpu == 's390x'
   kvm_targets = ['s390x-softmmu']
-elif cpu == 'ppc'
-  kvm_targets = ['ppc-softmmu']
 elif cpu == 'ppc64'
   kvm_targets = ['ppc-softmmu', 'ppc64-softmmu']
 elif cpu == 'mips64'
Signature · 1 line
2.43.0
#26 lore raw

PATCH v2 17/58 tcg/i386: Remove TCG_TARGET_REG_BITS tests

In reply to Richard Henderson

We now only support 64-bit code generation.

---
 tcg/i386/tcg-target-has.h      |   8 +-
 tcg/i386/tcg-target-reg-bits.h |   2 +-
 tcg/i386/tcg-target.h          |  13 +-
 tcg/i386/tcg-target.c.inc      | 552 ++++++---------------------------
 4 files changed, 97 insertions(+), 478 deletions(-)
tcg/i386/tcg-target-has.h +2 -6
index 42647fabbd..d249c1b3e7 100644
@@ -26,13 +26,10 @@
 #define have_avx512vbmi2  ((cpuinfo & CPUINFO_AVX512VBMI2) && have_avx512vl)
 
 /* optional instructions */
-#if TCG_TARGET_REG_BITS == 64
 /* Keep 32-bit values zero-extended in a register.  */
 #define TCG_TARGET_HAS_extr_i64_i32     1
-#endif
 
-#define TCG_TARGET_HAS_qemu_ldst_i128 \
-    (TCG_TARGET_REG_BITS == 64 && (cpuinfo & CPUINFO_ATOMIC_VMOVDQA))
+#define TCG_TARGET_HAS_qemu_ldst_i128   (cpuinfo & CPUINFO_ATOMIC_VMOVDQA)
 
 #define TCG_TARGET_HAS_tst              1
 
@@ -63,8 +60,7 @@
 #define TCG_TARGET_HAS_tst_vec          have_avx512bw
 
 #define TCG_TARGET_deposit_valid(type, ofs, len) \
-    (((ofs) == 0 && ((len) == 8 || (len) == 16)) || \
-     (TCG_TARGET_REG_BITS == 32 && (ofs) == 8 && (len) == 8))
+    ((ofs) == 0 && ((len) == 8 || (len) == 16))
 
 /*
  * Check for the possibility of low byte/word extraction, high-byte extraction
tcg/i386/tcg-target-reg-bits.h +1 -1
index aa386050eb..fc3377e829 100644
@@ -10,7 +10,7 @@
 #ifdef __x86_64__
 # define TCG_TARGET_REG_BITS  64
 #else
-# define TCG_TARGET_REG_BITS  32
+# error
 #endif
 
 #endif
tcg/i386/tcg-target.h +2 -11
index 3cbdfbca52..7ebae56a7d 100644
@@ -27,13 +27,8 @@
 
 #define TCG_TARGET_INSN_UNIT_SIZE  1
 
-#ifdef __x86_64__
-# define TCG_TARGET_NB_REGS   32
-# define MAX_CODE_GEN_BUFFER_SIZE  (2 * GiB)
-#else
-# define TCG_TARGET_NB_REGS   24
-# define MAX_CODE_GEN_BUFFER_SIZE  UINT32_MAX
-#endif
+#define TCG_TARGET_NB_REGS   32
+#define MAX_CODE_GEN_BUFFER_SIZE  (2 * GiB)
 
 typedef enum {
     TCG_REG_EAX = 0,
@@ -45,8 +40,6 @@ typedef enum {
     TCG_REG_ESI,
     TCG_REG_EDI,
 
-    /* 64-bit registers; always define the symbols to avoid
-       too much if-deffing.  */
     TCG_REG_R8,
     TCG_REG_R9,
     TCG_REG_R10,
@@ -64,8 +57,6 @@ typedef enum {
     TCG_REG_XMM5,
     TCG_REG_XMM6,
     TCG_REG_XMM7,
-
-    /* 64-bit registers; likewise always define.  */
     TCG_REG_XMM8,
     TCG_REG_XMM9,
     TCG_REG_XMM10,
tcg/i386/tcg-target.c.inc +92 -460

949 lines not on this page · raw message

Signature · 1 line
2.43.0
Reviewed-by on v2 17/58
#27 lore raw

Re: [PATCH v2 17/58] tcg/i386: Remove TCG_TARGET_REG_BITS tests

Quoted 9 lines · Richard Henderson

We now only support 64-bit code generation.

---
  tcg/i386/tcg-target-has.h      |   8 +-
  tcg/i386/tcg-target-reg-bits.h |   2 +-
  tcg/i386/tcg-target.h          |  13 +-
  tcg/i386/tcg-target.c.inc      | 552 ++++++---------------------------
  4 files changed, 97 insertions(+), 478 deletions(-)

v2 now looks fine, thanks!

#28 lore raw

PATCH v2 18/58 tcg/x86_64: Rename from i386

In reply to Richard Henderson

Emphasize that we're generating 64-bit code.
Drop the explicit rename from meson's cpu.

---
 tcg/{i386 => x86_64}/tcg-target-con-set.h  | 0
 tcg/{i386 => x86_64}/tcg-target-con-str.h  | 0
 tcg/{i386 => x86_64}/tcg-target-has.h      | 0
 tcg/{i386 => x86_64}/tcg-target-mo.h       | 0
 tcg/{i386 => x86_64}/tcg-target-reg-bits.h | 0
 tcg/{i386 => x86_64}/tcg-target.h          | 0
 MAINTAINERS                                | 4 ++--
 meson.build                                | 2 --
 tcg/{i386 => x86_64}/tcg-target-opc.h.inc  | 0
 tcg/{i386 => x86_64}/tcg-target.c.inc      | 0
 10 files changed, 2 insertions(+), 4 deletions(-)
 rename tcg/{i386 => x86_64}/tcg-target-con-set.h (100%)
 rename tcg/{i386 => x86_64}/tcg-target-con-str.h (100%)
 rename tcg/{i386 => x86_64}/tcg-target-has.h (100%)
 rename tcg/{i386 => x86_64}/tcg-target-mo.h (100%)
 rename tcg/{i386 => x86_64}/tcg-target-reg-bits.h (100%)
 rename tcg/{i386 => x86_64}/tcg-target.h (100%)
 rename tcg/{i386 => x86_64}/tcg-target-opc.h.inc (100%)
 rename tcg/{i386 => x86_64}/tcg-target.c.inc (100%)
tcg/x86_64/tcg-target-con-set.h renamed from tcg/i386/tcg-target-con-set.h +0 -0
similarity index 100%
rename from tcg/i386/tcg-target-con-set.h
rename to tcg/x86_64/tcg-target-con-set.h
tcg/x86_64/tcg-target-con-str.h renamed from tcg/i386/tcg-target-con-str.h +0 -0
similarity index 100%
rename from tcg/i386/tcg-target-con-str.h
rename to tcg/x86_64/tcg-target-con-str.h
tcg/x86_64/tcg-target-has.h renamed from tcg/i386/tcg-target-has.h +0 -0
similarity index 100%
rename from tcg/i386/tcg-target-has.h
rename to tcg/x86_64/tcg-target-has.h
tcg/x86_64/tcg-target-mo.h renamed from tcg/i386/tcg-target-mo.h +0 -0
similarity index 100%
rename from tcg/i386/tcg-target-mo.h
rename to tcg/x86_64/tcg-target-mo.h
tcg/x86_64/tcg-target-reg-bits.h renamed from tcg/i386/tcg-target-reg-bits.h +0 -0
similarity index 100%
rename from tcg/i386/tcg-target-reg-bits.h
rename to tcg/x86_64/tcg-target-reg-bits.h
tcg/x86_64/tcg-target.h renamed from tcg/i386/tcg-target.h +0 -0
similarity index 100%
rename from tcg/i386/tcg-target.h
rename to tcg/x86_64/tcg-target.h
MAINTAINERS +2 -2
index 1a6e5bbafe..c39a8f54e8 100644
@@ -4057,10 +4057,10 @@ S: Maintained
 L: [email protected]
 F: tcg/aarch64/
 
-i386 TCG target
+X86 TCG target
 M: Richard Henderson <[email protected]>
 S: Maintained
-F: tcg/i386/
+F: tcg/x86_64/
 
 LoongArch64 TCG target
 M: WANG Xuerui <[email protected]>
meson.build +0 -2
index 7993e4cfb9..594e7d42c0 100644
@@ -907,8 +907,6 @@ if have_tcg
   endif
   if get_option('tcg_interpreter')
     tcg_arch = 'tci'
-  elif host_arch == 'x86_64'
-    tcg_arch = 'i386'
   elif host_arch == 'ppc64'
     tcg_arch = 'ppc'
   endif
tcg/x86_64/tcg-target-opc.h.inc renamed from tcg/i386/tcg-target-opc.h.inc +0 -0
similarity index 100%
rename from tcg/i386/tcg-target-opc.h.inc
rename to tcg/x86_64/tcg-target-opc.h.inc
tcg/x86_64/tcg-target.c.inc renamed from tcg/i386/tcg-target.c.inc +0 -0
similarity index 100%
rename from tcg/i386/tcg-target.c.inc
rename to tcg/x86_64/tcg-target.c.inc
Signature · 1 line
2.43.0
#29 lore raw

PATCH v2 19/58 tcg/ppc64: Rename from ppc

In reply to Richard Henderson

Emphasize that we're generating 64-bit code.
Drop the explicit rename from meson's cpu.

---
 tcg/{ppc => ppc64}/tcg-target-con-set.h  | 0
 tcg/{ppc => ppc64}/tcg-target-con-str.h  | 0
 tcg/{ppc => ppc64}/tcg-target-has.h      | 0
 tcg/{ppc => ppc64}/tcg-target-mo.h       | 0
 tcg/{ppc => ppc64}/tcg-target-reg-bits.h | 0
 tcg/{ppc => ppc64}/tcg-target.h          | 0
 MAINTAINERS                              | 2 +-
 meson.build                              | 2 --
 tcg/{ppc => ppc64}/tcg-target-opc.h.inc  | 0
 tcg/{ppc => ppc64}/tcg-target.c.inc      | 0
 10 files changed, 1 insertion(+), 3 deletions(-)
 rename tcg/{ppc => ppc64}/tcg-target-con-set.h (100%)
 rename tcg/{ppc => ppc64}/tcg-target-con-str.h (100%)
 rename tcg/{ppc => ppc64}/tcg-target-has.h (100%)
 rename tcg/{ppc => ppc64}/tcg-target-mo.h (100%)
 rename tcg/{ppc => ppc64}/tcg-target-reg-bits.h (100%)
 rename tcg/{ppc => ppc64}/tcg-target.h (100%)
 rename tcg/{ppc => ppc64}/tcg-target-opc.h.inc (100%)
 rename tcg/{ppc => ppc64}/tcg-target.c.inc (100%)
tcg/ppc64/tcg-target-con-set.h renamed from tcg/ppc/tcg-target-con-set.h +0 -0
similarity index 100%
rename from tcg/ppc/tcg-target-con-set.h
rename to tcg/ppc64/tcg-target-con-set.h
tcg/ppc64/tcg-target-con-str.h renamed from tcg/ppc/tcg-target-con-str.h +0 -0
similarity index 100%
rename from tcg/ppc/tcg-target-con-str.h
rename to tcg/ppc64/tcg-target-con-str.h
tcg/ppc64/tcg-target-has.h renamed from tcg/ppc/tcg-target-has.h +0 -0
similarity index 100%
rename from tcg/ppc/tcg-target-has.h
rename to tcg/ppc64/tcg-target-has.h
tcg/ppc64/tcg-target-mo.h renamed from tcg/ppc/tcg-target-mo.h +0 -0
similarity index 100%
rename from tcg/ppc/tcg-target-mo.h
rename to tcg/ppc64/tcg-target-mo.h
tcg/ppc64/tcg-target-reg-bits.h renamed from tcg/ppc/tcg-target-reg-bits.h +0 -0
similarity index 100%
rename from tcg/ppc/tcg-target-reg-bits.h
rename to tcg/ppc64/tcg-target-reg-bits.h
tcg/ppc64/tcg-target.h renamed from tcg/ppc/tcg-target.h +0 -0
similarity index 100%
rename from tcg/ppc/tcg-target.h
rename to tcg/ppc64/tcg-target.h
MAINTAINERS +1 -1
index c39a8f54e8..c58fa93fd5 100644
@@ -4079,7 +4079,7 @@ F: tcg/mips/
 PPC TCG target
 M: Richard Henderson <[email protected]>
 S: Odd Fixes
-F: tcg/ppc/
+F: tcg/ppc64/
 
 RISC-V TCG target
 M: Palmer Dabbelt <[email protected]>
meson.build +0 -2
index 594e7d42c0..0647ca0c89 100644
@@ -907,8 +907,6 @@ if have_tcg
   endif
   if get_option('tcg_interpreter')
     tcg_arch = 'tci'
-  elif host_arch == 'ppc64'
-    tcg_arch = 'ppc'
   endif
   add_project_arguments('-iquote', meson.current_source_dir() / 'tcg' / tcg_arch,
                         language: all_languages)
tcg/ppc64/tcg-target-opc.h.inc renamed from tcg/ppc/tcg-target-opc.h.inc +0 -0
similarity index 100%
rename from tcg/ppc/tcg-target-opc.h.inc
rename to tcg/ppc64/tcg-target-opc.h.inc
tcg/ppc64/tcg-target.c.inc renamed from tcg/ppc/tcg-target.c.inc +0 -0
similarity index 100%
rename from tcg/ppc/tcg-target.c.inc
rename to tcg/ppc64/tcg-target.c.inc
Signature · 1 line
2.43.0
#30 lore raw

PATCH v2 20/58 meson: Drop host_arch rename for mips64

In reply to Richard Henderson

This requires renaming several directories:
tcg/mips, linux-user/include/host/mips, and
common-user/host/mips.

---
 linux-user/include/host/{mips => mips64}/host-signal.h | 0
 tcg/{mips => mips64}/tcg-target-con-set.h              | 0
 tcg/{mips => mips64}/tcg-target-con-str.h              | 0
 tcg/{mips => mips64}/tcg-target-has.h                  | 0
 tcg/{mips => mips64}/tcg-target-mo.h                   | 0
 tcg/{mips => mips64}/tcg-target-reg-bits.h             | 0
 tcg/{mips => mips64}/tcg-target.h                      | 0
 MAINTAINERS                                            | 2 +-
 common-user/host/{mips => mips64}/safe-syscall.inc.S   | 0
 configure                                              | 8 +++-----
 meson.build                                            | 2 --
 tcg/{mips => mips64}/tcg-target-opc.h.inc              | 0
 tcg/{mips => mips64}/tcg-target.c.inc                  | 0
 13 files changed, 4 insertions(+), 8 deletions(-)
 rename linux-user/include/host/{mips => mips64}/host-signal.h (100%)
 rename tcg/{mips => mips64}/tcg-target-con-set.h (100%)
 rename tcg/{mips => mips64}/tcg-target-con-str.h (100%)
 rename tcg/{mips => mips64}/tcg-target-has.h (100%)
 rename tcg/{mips => mips64}/tcg-target-mo.h (100%)
 rename tcg/{mips => mips64}/tcg-target-reg-bits.h (100%)
 rename tcg/{mips => mips64}/tcg-target.h (100%)
 rename common-user/host/{mips => mips64}/safe-syscall.inc.S (100%)
 rename tcg/{mips => mips64}/tcg-target-opc.h.inc (100%)
 rename tcg/{mips => mips64}/tcg-target.c.inc (100%)
linux-user/include/host/mips64/host-signal.h renamed from linux-user/include/host/mips/host-signal.h +0 -0
similarity index 100%
rename from linux-user/include/host/mips/host-signal.h
rename to linux-user/include/host/mips64/host-signal.h
tcg/mips64/tcg-target-con-set.h renamed from tcg/mips/tcg-target-con-set.h +0 -0
similarity index 100%
rename from tcg/mips/tcg-target-con-set.h
rename to tcg/mips64/tcg-target-con-set.h
tcg/mips64/tcg-target-con-str.h renamed from tcg/mips/tcg-target-con-str.h +0 -0
similarity index 100%
rename from tcg/mips/tcg-target-con-str.h
rename to tcg/mips64/tcg-target-con-str.h
tcg/mips64/tcg-target-has.h renamed from tcg/mips/tcg-target-has.h +0 -0
similarity index 100%
rename from tcg/mips/tcg-target-has.h
rename to tcg/mips64/tcg-target-has.h
tcg/mips64/tcg-target-mo.h renamed from tcg/mips/tcg-target-mo.h +0 -0
similarity index 100%
rename from tcg/mips/tcg-target-mo.h
rename to tcg/mips64/tcg-target-mo.h
tcg/mips64/tcg-target-reg-bits.h renamed from tcg/mips/tcg-target-reg-bits.h +0 -0
similarity index 100%
rename from tcg/mips/tcg-target-reg-bits.h
rename to tcg/mips64/tcg-target-reg-bits.h
tcg/mips64/tcg-target.h renamed from tcg/mips/tcg-target.h +0 -0
similarity index 100%
rename from tcg/mips/tcg-target.h
rename to tcg/mips64/tcg-target.h
MAINTAINERS +1 -1
index c58fa93fd5..d3e6041186 100644
@@ -4074,7 +4074,7 @@ R: Huacai Chen <[email protected]>
 R: Jiaxun Yang <[email protected]>
 R: Aleksandar Rikalo <[email protected]>
 S: Odd Fixes
-F: tcg/mips/
+F: tcg/mips64/
 
 PPC TCG target
 M: Richard Henderson <[email protected]>
common-user/host/mips64/safe-syscall.inc.S renamed from common-user/host/mips/safe-syscall.inc.S +0 -0
similarity index 100%
rename from common-user/host/mips/safe-syscall.inc.S
rename to common-user/host/mips64/safe-syscall.inc.S
configure +3 -5
index e9d0b9e2c0..04d0b214b6 100755
@@ -400,10 +400,8 @@ elif check_define _ARCH_PPC64 ; then
   else
     cpu="ppc64"
   fi
-elif check_define __mips__ ; then
-  if check_define __mips64 ; then
-    cpu="mips64"
-  fi
+elif check_define __mips64 ; then
+  cpu="mips64"
 elif check_define __s390__ ; then
   if check_define __s390x__ ; then
     cpu="s390x"
@@ -455,7 +453,7 @@ case "$cpu" in
 
   mips64*|mipsisa64*)
     cpu=mips64
-    host_arch=mips
+    host_arch=mips64
     linux_arch=mips
     ;;
 
meson.build +0 -2
index 0647ca0c89..c36f2f6962 100644
@@ -265,8 +265,6 @@ enable_modules = get_option('modules') \
 
 if cpu not in supported_cpus
   host_arch = 'unknown'
-elif cpu == 'mips64'
-  host_arch = 'mips'
 elif cpu in ['riscv32', 'riscv64']
   host_arch = 'riscv'
 else
tcg/mips64/tcg-target-opc.h.inc renamed from tcg/mips/tcg-target-opc.h.inc +0 -0
similarity index 100%
rename from tcg/mips/tcg-target-opc.h.inc
rename to tcg/mips64/tcg-target-opc.h.inc
tcg/mips64/tcg-target.c.inc renamed from tcg/mips/tcg-target.c.inc +0 -0
similarity index 100%
rename from tcg/mips/tcg-target.c.inc
rename to tcg/mips64/tcg-target.c.inc
Signature · 1 line
2.43.0
#31 lore raw

PATCH v2 21/58 meson: Drop host_arch rename for riscv64

In reply to Richard Henderson

This requires renaming several directories:
tcg/riscv, linux-user/include/host/riscv, and
common-user/host/riscv.

---
 host/include/{riscv => riscv64}/host/cpuinfo.h           | 0
 linux-user/include/host/{riscv => riscv64}/host-signal.h | 0
 tcg/{riscv => riscv64}/tcg-target-con-set.h              | 0
 tcg/{riscv => riscv64}/tcg-target-con-str.h              | 0
 tcg/{riscv => riscv64}/tcg-target-has.h                  | 0
 tcg/{riscv => riscv64}/tcg-target-mo.h                   | 0
 tcg/{riscv => riscv64}/tcg-target-reg-bits.h             | 0
 tcg/{riscv => riscv64}/tcg-target.h                      | 0
 MAINTAINERS                                              | 2 +-
 common-user/host/{riscv => riscv64}/safe-syscall.inc.S   | 0
 configure                                                | 4 ++--
 meson.build                                              | 2 --
 tcg/{riscv => riscv64}/tcg-target-opc.h.inc              | 0
 tcg/{riscv => riscv64}/tcg-target.c.inc                  | 0
 14 files changed, 3 insertions(+), 5 deletions(-)
 rename host/include/{riscv => riscv64}/host/cpuinfo.h (100%)
 rename linux-user/include/host/{riscv => riscv64}/host-signal.h (100%)
 rename tcg/{riscv => riscv64}/tcg-target-con-set.h (100%)
 rename tcg/{riscv => riscv64}/tcg-target-con-str.h (100%)
 rename tcg/{riscv => riscv64}/tcg-target-has.h (100%)
 rename tcg/{riscv => riscv64}/tcg-target-mo.h (100%)
 rename tcg/{riscv => riscv64}/tcg-target-reg-bits.h (100%)
 rename tcg/{riscv => riscv64}/tcg-target.h (100%)
 rename common-user/host/{riscv => riscv64}/safe-syscall.inc.S (100%)
 rename tcg/{riscv => riscv64}/tcg-target-opc.h.inc (100%)
 rename tcg/{riscv => riscv64}/tcg-target.c.inc (100%)
host/include/riscv64/host/cpuinfo.h renamed from host/include/riscv/host/cpuinfo.h +0 -0
similarity index 100%
rename from host/include/riscv/host/cpuinfo.h
rename to host/include/riscv64/host/cpuinfo.h
linux-user/include/host/riscv64/host-signal.h renamed from linux-user/include/host/riscv/host-signal.h +0 -0
similarity index 100%
rename from linux-user/include/host/riscv/host-signal.h
rename to linux-user/include/host/riscv64/host-signal.h
tcg/riscv64/tcg-target-con-set.h renamed from tcg/riscv/tcg-target-con-set.h +0 -0
similarity index 100%
rename from tcg/riscv/tcg-target-con-set.h
rename to tcg/riscv64/tcg-target-con-set.h
tcg/riscv64/tcg-target-con-str.h renamed from tcg/riscv/tcg-target-con-str.h +0 -0
similarity index 100%
rename from tcg/riscv/tcg-target-con-str.h
rename to tcg/riscv64/tcg-target-con-str.h
tcg/riscv64/tcg-target-has.h renamed from tcg/riscv/tcg-target-has.h +0 -0
similarity index 100%
rename from tcg/riscv/tcg-target-has.h
rename to tcg/riscv64/tcg-target-has.h
tcg/riscv64/tcg-target-mo.h renamed from tcg/riscv/tcg-target-mo.h +0 -0
similarity index 100%
rename from tcg/riscv/tcg-target-mo.h
rename to tcg/riscv64/tcg-target-mo.h
tcg/riscv64/tcg-target-reg-bits.h renamed from tcg/riscv/tcg-target-reg-bits.h +0 -0
similarity index 100%
rename from tcg/riscv/tcg-target-reg-bits.h
rename to tcg/riscv64/tcg-target-reg-bits.h
tcg/riscv64/tcg-target.h renamed from tcg/riscv/tcg-target.h +0 -0
similarity index 100%
rename from tcg/riscv/tcg-target.h
rename to tcg/riscv64/tcg-target.h
MAINTAINERS +1 -1
index d3e6041186..c1e586c58f 100644
@@ -4086,7 +4086,7 @@ M: Palmer Dabbelt <[email protected]>
 M: Alistair Francis <[email protected]>
 L: [email protected]
 S: Maintained
-F: tcg/riscv/
+F: tcg/riscv64/
 F: disas/riscv.[ch]
 
 S390 TCG target
common-user/host/riscv64/safe-syscall.inc.S renamed from common-user/host/riscv/safe-syscall.inc.S +0 -0
similarity index 100%
rename from common-user/host/riscv/safe-syscall.inc.S
rename to common-user/host/riscv64/safe-syscall.inc.S
configure +2 -2
index 04d0b214b6..ee09f90125 100755
@@ -469,8 +469,8 @@ case "$cpu" in
     CPU_CFLAGS="-m64 -mlittle-endian"
     ;;
 
-  riscv32 | riscv64)
-    host_arch=riscv
+  riscv64)
+    host_arch=riscv64
     linux_arch=riscv
     ;;
 
meson.build +0 -2
index c36f2f6962..e1ac764793 100644
@@ -265,8 +265,6 @@ enable_modules = get_option('modules') \
 
 if cpu not in supported_cpus
   host_arch = 'unknown'
-elif cpu in ['riscv32', 'riscv64']
-  host_arch = 'riscv'
 else
   host_arch = cpu
 endif
tcg/riscv64/tcg-target-opc.h.inc renamed from tcg/riscv/tcg-target-opc.h.inc +0 -0
similarity index 100%
rename from tcg/riscv/tcg-target-opc.h.inc
rename to tcg/riscv64/tcg-target-opc.h.inc
tcg/riscv64/tcg-target.c.inc renamed from tcg/riscv/tcg-target.c.inc +0 -0
similarity index 100%
rename from tcg/riscv/tcg-target.c.inc
rename to tcg/riscv64/tcg-target.c.inc
Signature · 1 line
2.43.0
#32 lore raw

PATCH v2 22/58 meson: Remove cpu == riscv32 tests

In reply to Richard Henderson

The 32-bit riscv host is no longer supported.

---
 configure   | 10 +++-------
 meson.build |  4 +---
 2 files changed, 4 insertions(+), 10 deletions(-)
configure +3 -7
index ee09f90125..e69b3e474e 100755
@@ -408,12 +408,8 @@ elif check_define __s390__ ; then
   else
     cpu="s390"
   fi
-elif check_define __riscv ; then
-  if check_define _LP64 ; then
-    cpu="riscv64"
-  else
-    cpu="riscv32"
-  fi
+elif check_define __riscv && check_define _LP64 ; then
+  cpu="riscv64"
 elif check_define __aarch64__ ; then
   cpu="aarch64"
 elif check_define __loongarch64 ; then
@@ -1280,7 +1276,7 @@ EOF
     test "$bigendian" = no && rust_arch=${rust_arch}el
     ;;
 
-  riscv32|riscv64)
+  riscv64)
     # e.g. riscv64gc-unknown-linux-gnu, but riscv64-linux-android
     test "$android" = no && rust_arch=${rust_arch}gc
     ;;
meson.build +1 -3
index e1ac764793..0189d8fd44 100644
@@ -50,7 +50,7 @@ qapi_trace_events = []
 
 bsd_oses = ['gnu/kfreebsd', 'freebsd', 'netbsd', 'openbsd', 'dragonfly', 'darwin']
 supported_oses = ['windows', 'freebsd', 'netbsd', 'openbsd', 'darwin', 'sunos', 'linux', 'emscripten']
-supported_cpus = ['ppc64', 's390x', 'riscv32', 'riscv64', 'x86_64',
+supported_cpus = ['ppc64', 's390x', 'riscv64', 'x86_64',
   'aarch64', 'loongarch64', 'mips64', 'sparc64', 'wasm64']
 
 cpu = host_machine.cpu_family()
@@ -279,8 +279,6 @@ elif cpu == 'ppc64'
   kvm_targets = ['ppc-softmmu', 'ppc64-softmmu']
 elif cpu == 'mips64'
   kvm_targets = ['mips-softmmu', 'mipsel-softmmu', 'mips64-softmmu', 'mips64el-softmmu']
-elif cpu == 'riscv32'
-  kvm_targets = ['riscv32-softmmu']
 elif cpu == 'riscv64'
   kvm_targets = ['riscv64-softmmu']
 elif cpu == 'loongarch64'
Signature · 1 line
2.43.0
Reviewed-by on v2 22/58
#33 lore raw

Re: [PATCH v2 22/58] meson: Remove cpu == riscv32 tests

Quoted 9 lines · Richard Henderson

The 32-bit riscv host is no longer supported.

---
  configure   | 10 +++-------
  meson.build |  4 +---
  2 files changed, 4 insertions(+), 10 deletions(-)
#34 lore raw

PATCH v2 23/58 tcg: Make TCG_TARGET_REG_BITS common

In reply to Richard Henderson

Since we only support 64-bit hosts, there's no real need to parameterize TCG_TARGET_REG_BITS. It seems worth holding on to the identifier though, for documentation purposes.

Move one tcg/*/tcg-target-reg-bits.h to tcg/target-reg-bits.h and remove the others.

---
 include/tcg/helper-info.h                     |  2 +-
 .../tcg/target-reg-bits.h                     |  8 +++----
 include/tcg/tcg.h                             |  2 +-
 tcg/aarch64/tcg-target-reg-bits.h             | 12 -----------
 tcg/loongarch64/tcg-target-reg-bits.h         | 21 -------------------
 tcg/mips64/tcg-target-reg-bits.h              | 16 --------------
 tcg/riscv64/tcg-target-reg-bits.h             | 19 -----------------
 tcg/s390x/tcg-target-reg-bits.h               | 17 ---------------
 tcg/sparc64/tcg-target-reg-bits.h             | 12 -----------
 tcg/tci/tcg-target-reg-bits.h                 | 18 ----------------
 tcg/x86_64/tcg-target-reg-bits.h              | 16 --------------
 11 files changed, 6 insertions(+), 137 deletions(-)
 rename tcg/ppc64/tcg-target-reg-bits.h => include/tcg/target-reg-bits.h (71%)
 delete mode 100644 tcg/aarch64/tcg-target-reg-bits.h
 delete mode 100644 tcg/loongarch64/tcg-target-reg-bits.h
 delete mode 100644 tcg/mips64/tcg-target-reg-bits.h
 delete mode 100644 tcg/riscv64/tcg-target-reg-bits.h
 delete mode 100644 tcg/s390x/tcg-target-reg-bits.h
 delete mode 100644 tcg/sparc64/tcg-target-reg-bits.h
 delete mode 100644 tcg/tci/tcg-target-reg-bits.h
 delete mode 100644 tcg/x86_64/tcg-target-reg-bits.h
include/tcg/helper-info.h +1 -1
index 49a27e4eae..d5bda83a2e 100644
@@ -24,7 +24,7 @@
 #include <ffi.h>
 #pragma GCC diagnostic pop
 #endif
-#include "tcg-target-reg-bits.h"
+#include "tcg/target-reg-bits.h"
 
 #define MAX_CALL_IARGS  7
 
include/tcg/target-reg-bits.h renamed from tcg/ppc64/tcg-target-reg-bits.h +4 -4
similarity index 71%
rename from tcg/ppc64/tcg-target-reg-bits.h
rename to include/tcg/target-reg-bits.h
index 3a15d7bee4..8f4ad3ed99 100644
@@ -7,10 +7,10 @@
 #ifndef TCG_TARGET_REG_BITS_H
 #define TCG_TARGET_REG_BITS_H
 
-#ifndef _ARCH_PPC64
-# error Expecting 64-bit host architecture
-#endif
-
+/*
+ * We only support 64-bit hosts now.
+ * Retain the identifier for documentation.
+ */
 #define TCG_TARGET_REG_BITS  64
 
 #endif
include/tcg/tcg.h +1 -1
index a6d9aa50d4..067150c542 100644
@@ -31,7 +31,7 @@
 #include "qemu/plugin.h"
 #include "qemu/queue.h"
 #include "tcg/tcg-mo.h"
-#include "tcg-target-reg-bits.h"
+#include "tcg/target-reg-bits.h"
 #include "tcg-target.h"
 #include "tcg/tcg-cond.h"
 #include "tcg/insn-start-words.h"
tcg/aarch64/tcg-target-reg-bits.h deleted +0 -12
deleted file mode 100644
index 3b57a1aafb..0000000000
@@ -1,12 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/*
- * Define target-specific register size
- * Copyright (c) 2023 Linaro
- */
-
-#ifndef TCG_TARGET_REG_BITS_H
-#define TCG_TARGET_REG_BITS_H
-
-#define TCG_TARGET_REG_BITS  64
-
-#endif
tcg/loongarch64/tcg-target-reg-bits.h deleted +0 -21
deleted file mode 100644
index 51373ad70a..0000000000
@@ -1,21 +0,0 @@
-/* SPDX-License-Identifier: MIT */
-/*
- * Define target-specific register size
- * Copyright (c) 2021 WANG Xuerui <[email protected]>
- */
-
-#ifndef TCG_TARGET_REG_BITS_H
-#define TCG_TARGET_REG_BITS_H
-
-/*
- * Loongson removed the (incomplete) 32-bit support from kernel and toolchain
- * for the initial upstreaming of this architecture, so don't bother and just
- * support the LP64* ABI for now.
- */
-#if defined(__loongarch64)
-# define TCG_TARGET_REG_BITS 64
-#else
-# error unsupported LoongArch register size
-#endif
-
-#endif
tcg/mips64/tcg-target-reg-bits.h deleted +0 -16
deleted file mode 100644
index ee346a3f25..0000000000
@@ -1,16 +0,0 @@
-/* SPDX-License-Identifier: MIT */
-/*
- * Define target-specific register size
- * Copyright (c) 2008-2009 Arnaud Patard <[email protected]>
- */
-
-#ifndef TCG_TARGET_REG_BITS_H
-#define TCG_TARGET_REG_BITS_H
-
-#if !defined(_MIPS_SIM) || _MIPS_SIM != _ABI64
-# error "Unknown ABI"
-#endif
-
-#define TCG_TARGET_REG_BITS 64
-
-#endif
tcg/riscv64/tcg-target-reg-bits.h deleted +0 -19
deleted file mode 100644
index 761ca0d774..0000000000
@@ -1,19 +0,0 @@
-/* SPDX-License-Identifier: MIT */
-/*
- * Define target-specific register size
- * Copyright (c) 2018 SiFive, Inc
- */
-
-#ifndef TCG_TARGET_REG_BITS_H
-#define TCG_TARGET_REG_BITS_H
-
-/*
- * We don't support oversize guests.
- * Since we will only build tcg once, this in turn requires a 64-bit host.
- */
-#if __riscv_xlen != 64
-#error "unsupported code generation mode"
-#endif
-#define TCG_TARGET_REG_BITS 64
-
-#endif
tcg/s390x/tcg-target-reg-bits.h deleted +0 -17
deleted file mode 100644
index b01414e09d..0000000000
@@ -1,17 +0,0 @@
-/* SPDX-License-Identifier: MIT */
-/*
- * Define target-specific register size
- * Copyright (c) 2009 Ulrich Hecht <[email protected]>
- */
-
-#ifndef TCG_TARGET_REG_BITS_H
-#define TCG_TARGET_REG_BITS_H
-
-/* We only support generating code for 64-bit mode.  */
-#if UINTPTR_MAX == UINT64_MAX
-# define TCG_TARGET_REG_BITS 64
-#else
-# error "unsupported code generation mode"
-#endif
-
-#endif
tcg/sparc64/tcg-target-reg-bits.h deleted +0 -12
deleted file mode 100644
index 34a6711013..0000000000
@@ -1,12 +0,0 @@
-/* SPDX-License-Identifier: MIT */
-/*
- * Define target-specific register size
- * Copyright (c) 2023 Linaro
- */
-
-#ifndef TCG_TARGET_REG_BITS_H
-#define TCG_TARGET_REG_BITS_H
-
-#define TCG_TARGET_REG_BITS  64
-
-#endif
tcg/tci/tcg-target-reg-bits.h deleted +0 -18
deleted file mode 100644
index dcb1a203f8..0000000000
@@ -1,18 +0,0 @@
-/* SPDX-License-Identifier: MIT */
-/*
- * Define target-specific register size
- * Copyright (c) 2009, 2011 Stefan Weil
- */
-
-#ifndef TCG_TARGET_REG_BITS_H
-#define TCG_TARGET_REG_BITS_H
-
-#if UINTPTR_MAX == UINT32_MAX
-# define TCG_TARGET_REG_BITS 32
-#elif UINTPTR_MAX == UINT64_MAX
-# define TCG_TARGET_REG_BITS 64
-#else
-# error Unknown pointer size for tci target
-#endif
-
-#endif
tcg/x86_64/tcg-target-reg-bits.h deleted +0 -16
deleted file mode 100644
index fc3377e829..0000000000
@@ -1,16 +0,0 @@
-/* SPDX-License-Identifier: MIT */
-/*
- * Define target-specific register size
- * Copyright (c) 2008 Fabrice Bellard
- */
-
-#ifndef TCG_TARGET_REG_BITS_H
-#define TCG_TARGET_REG_BITS_H
-
-#ifdef __x86_64__
-# define TCG_TARGET_REG_BITS  64
-#else
-# error
-#endif
-
-#endif
Signature · 1 line
2.43.0
#35 lore raw

PATCH v2 24/58 tcg: Replace TCG_TARGET_REG_BITS / 8

In reply to Richard Henderson

Use sizeof(tcg_target_long) instead of division.

---
 tcg/tcg-op-gvec.c                | 2 +-
 tcg/loongarch64/tcg-target.c.inc | 4 ++--
 tcg/ppc64/tcg-target.c.inc       | 2 +-
 tcg/riscv64/tcg-target.c.inc     | 4 ++--
 4 files changed, 6 insertions(+), 6 deletions(-)
tcg/tcg-op-gvec.c +1 -1
index 2d184547ba..9c33430638 100644
@@ -607,7 +607,7 @@ static void do_dup(unsigned vece, TCGv_ptr dbase, uint32_t dofs,
     }
 
     /* Otherwise, inline with an integer type, unless "large".  */
-    if (check_size_impl(oprsz, TCG_TARGET_REG_BITS / 8)) {
+    if (check_size_impl(oprsz, sizeof(tcg_target_long))) {
         t_64 = NULL;
         t_32 = NULL;
 
tcg/loongarch64/tcg-target.c.inc +2 -2
index 10c69211ac..c3350c90fc 100644
@@ -2604,7 +2604,7 @@ static const int tcg_target_callee_save_regs[] = {
 };
 
 /* Stack frame parameters.  */
-#define REG_SIZE   (TCG_TARGET_REG_BITS / 8)
+#define REG_SIZE   ((int)sizeof(tcg_target_long))
 #define SAVE_SIZE  ((int)ARRAY_SIZE(tcg_target_callee_save_regs) * REG_SIZE)
 #define TEMP_SIZE  (CPU_TEMP_BUF_NLONGS * (int)sizeof(long))
 #define FRAME_SIZE ((TCG_STATIC_CALL_ARGS_SIZE + TEMP_SIZE + SAVE_SIZE \
@@ -2731,7 +2731,7 @@ static const DebugFrame debug_frame = {
     .h.cie.id = -1,
     .h.cie.version = 1,
     .h.cie.code_align = 1,
-    .h.cie.data_align = -(TCG_TARGET_REG_BITS / 8) & 0x7f, /* sleb128 */
+    .h.cie.data_align = -sizeof(tcg_target_long) & 0x7f, /* sleb128 */
     .h.cie.return_column = TCG_REG_RA,
 
     /* Total FDE size does not include the "len" member.  */
tcg/ppc64/tcg-target.c.inc +1 -1
index 3c36b26f25..b54afa0b6d 100644
@@ -70,7 +70,7 @@
 #define SZP  ((int)sizeof(void *))
 
 /* Shorthand for size of a register.  */
-#define SZR  (TCG_TARGET_REG_BITS / 8)
+#define SZR  ((int)sizeof(tcg_target_long))
 
 #define TCG_CT_CONST_S16     0x00100
 #define TCG_CT_CONST_U16     0x00200
tcg/riscv64/tcg-target.c.inc +2 -2
index 0967a445a3..76dd4fca97 100644
@@ -2934,7 +2934,7 @@ static const int tcg_target_callee_save_regs[] = {
 };
 
 /* Stack frame parameters.  */
-#define REG_SIZE   (TCG_TARGET_REG_BITS / 8)
+#define REG_SIZE   ((int)sizeof(tcg_target_long))
 #define SAVE_SIZE  ((int)ARRAY_SIZE(tcg_target_callee_save_regs) * REG_SIZE)
 #define TEMP_SIZE  (CPU_TEMP_BUF_NLONGS * (int)sizeof(long))
 #define FRAME_SIZE ((TCG_STATIC_CALL_ARGS_SIZE + TEMP_SIZE + SAVE_SIZE \
@@ -3114,7 +3114,7 @@ static const DebugFrame debug_frame = {
     .h.cie.id = -1,
     .h.cie.version = 1,
     .h.cie.code_align = 1,
-    .h.cie.data_align = -(TCG_TARGET_REG_BITS / 8) & 0x7f, /* sleb128 */
+    .h.cie.data_align = -sizeof(tcg_target_long) & 0x7f, /* sleb128 */
     .h.cie.return_column = TCG_REG_RA,
 
     /* Total FDE size does not include the "len" member.  */
Signature · 1 line
2.43.0
#36 lore raw

PATCH v2 25/58 *: Drop TCG_TARGET_REG_BITS test for prefer_i64

In reply to Richard Henderson

Mechanically via sed -i.

---
 target/arm/tcg/gengvec.c                | 32 ++++++-------
 target/arm/tcg/gengvec64.c              |  4 +-
 target/arm/tcg/translate-sve.c          | 26 +++++------
 tcg/tcg-op-gvec.c                       | 62 ++++++++++++-------------
 target/i386/tcg/emit.c.inc              |  2 +-
 target/riscv/insn_trans/trans_rvv.c.inc |  2 +-
 6 files changed, 64 insertions(+), 64 deletions(-)
target/arm/tcg/gengvec.c +16 -16
index 01867f8ace..f97d63549c 100644
@@ -165,7 +165,7 @@ void gen_gvec_ssra(unsigned vece, uint32_t rd_ofs, uint32_t rm_ofs,
         { .fni8 = gen_ssra64_i64,
           .fniv = gen_ssra_vec,
           .fno = gen_helper_gvec_ssra_d,
-          .prefer_i64 = TCG_TARGET_REG_BITS == 64,
+          .prefer_i64 = true,
           .opt_opc = vecop_list,
           .load_dest = true,
           .vece = MO_64 },
@@ -241,7 +241,7 @@ void gen_gvec_usra(unsigned vece, uint32_t rd_ofs, uint32_t rm_ofs,
         { .fni8 = gen_usra64_i64,
           .fniv = gen_usra_vec,
           .fno = gen_helper_gvec_usra_d,
-          .prefer_i64 = TCG_TARGET_REG_BITS == 64,
+          .prefer_i64 = true,
           .load_dest = true,
           .opt_opc = vecop_list,
           .vece = MO_64, },
@@ -349,7 +349,7 @@ void gen_gvec_srshr(unsigned vece, uint32_t rd_ofs, uint32_t rm_ofs,
         { .fni8 = gen_srshr64_i64,
           .fniv = gen_srshr_vec,
           .fno = gen_helper_gvec_srshr_d,
-          .prefer_i64 = TCG_TARGET_REG_BITS == 64,
+          .prefer_i64 = true,
           .opt_opc = vecop_list,
           .vece = MO_64 },
     };
@@ -439,7 +439,7 @@ void gen_gvec_srsra(unsigned vece, uint32_t rd_ofs, uint32_t rm_ofs,
         { .fni8 = gen_srsra64_i64,
           .fniv = gen_srsra_vec,
           .fno = gen_helper_gvec_srsra_d,
-          .prefer_i64 = TCG_TARGET_REG_BITS == 64,
+          .prefer_i64 = true,
           .opt_opc = vecop_list,
           .load_dest = true,
           .vece = MO_64 },
@@ -543,7 +543,7 @@ void gen_gvec_urshr(unsigned vece, uint32_t rd_ofs, uint32_t rm_ofs,
         { .fni8 = gen_urshr64_i64,
           .fniv = gen_urshr_vec,
           .fno = gen_helper_gvec_urshr_d,
-          .prefer_i64 = TCG_TARGET_REG_BITS == 64,
+          .prefer_i64 = true,
           .opt_opc = vecop_list,
           .vece = MO_64 },
     };
@@ -652,7 +652,7 @@ void gen_gvec_ursra(unsigned vece, uint32_t rd_ofs, uint32_t rm_ofs,
         { .fni8 = gen_ursra64_i64,
           .fniv = gen_ursra_vec,
           .fno = gen_helper_gvec_ursra_d,
-          .prefer_i64 = TCG_TARGET_REG_BITS == 64,
+          .prefer_i64 = true,
           .opt_opc = vecop_list,
           .load_dest = true,
           .vece = MO_64 },
@@ -736,7 +736,7 @@ void gen_gvec_sri(unsigned vece, uint32_t rd_ofs, uint32_t rm_ofs,
         { .fni8 = gen_shr64_ins_i64,
           .fniv = gen_shr_ins_vec,
           .fno = gen_helper_gvec_sri_d,
-          .prefer_i64 = TCG_TARGET_REG_BITS == 64,
+          .prefer_i64 = true,
           .load_dest = true,
           .opt_opc = vecop_list,
           .vece = MO_64 },
@@ -823,7 +823,7 @@ void gen_gvec_sli(unsigned vece, uint32_t rd_ofs, uint32_t rm_ofs,
         { .fni8 = gen_shl64_ins_i64,
           .fniv = gen_shl_ins_vec,
           .fno = gen_helper_gvec_sli_d,
-          .prefer_i64 = TCG_TARGET_REG_BITS == 64,
+          .prefer_i64 = true,
           .load_dest = true,
           .opt_opc = vecop_list,
           .vece = MO_64 },
@@ -927,7 +927,7 @@ void gen_gvec_mla(unsigned vece, uint32_t rd_ofs, uint32_t rn_ofs,
           .vece = MO_32 },
         { .fni8 = gen_mla64_i64,
           .fniv = gen_mla_vec,
-          .prefer_i64 = TCG_TARGET_REG_BITS == 64,
+          .prefer_i64 = true,
           .load_dest = true,
           .opt_opc = vecop_list,
           .vece = MO_64 },
@@ -959,7 +959,7 @@ void gen_gvec_mls(unsigned vece, uint32_t rd_ofs, uint32_t rn_ofs,
           .vece = MO_32 },
         { .fni8 = gen_mls64_i64,
           .fniv = gen_mls_vec,
-          .prefer_i64 = TCG_TARGET_REG_BITS == 64,
+          .prefer_i64 = true,
           .load_dest = true,
           .opt_opc = vecop_list,
           .vece = MO_64 },
@@ -1002,7 +1002,7 @@ void gen_gvec_cmtst(unsigned vece, uint32_t rd_ofs, uint32_t rn_ofs,
           .vece = MO_32 },
         { .fni8 = gen_cmtst_i64,
           .fniv = gen_cmtst_vec,
-          .prefer_i64 = TCG_TARGET_REG_BITS == 64,
+          .prefer_i64 = true,
           .opt_opc = vecop_list,
           .vece = MO_64 },
     };
@@ -1691,7 +1691,7 @@ void gen_gvec_sabd(unsigned vece, uint32_t rd_ofs, uint32_t rn_ofs,
         { .fni8 = gen_sabd_i64,
           .fniv = gen_sabd_vec,
           .fno = gen_helper_gvec_sabd_d,
-          .prefer_i64 = TCG_TARGET_REG_BITS == 64,
+          .prefer_i64 = true,
           .opt_opc = vecop_list,
           .vece = MO_64 },
     };
@@ -1748,7 +1748,7 @@ void gen_gvec_uabd(unsigned vece, uint32_t rd_ofs, uint32_t rn_ofs,
         { .fni8 = gen_uabd_i64,
           .fniv = gen_uabd_vec,
           .fno = gen_helper_gvec_uabd_d,
-          .prefer_i64 = TCG_TARGET_REG_BITS == 64,
+          .prefer_i64 = true,
           .opt_opc = vecop_list,
           .vece = MO_64 },
     };
@@ -1803,7 +1803,7 @@ void gen_gvec_saba(unsigned vece, uint32_t rd_ofs, uint32_t rn_ofs,
         { .fni8 = gen_saba_i64,
           .fniv = gen_saba_vec,
           .fno = gen_helper_gvec_saba_d,
-          .prefer_i64 = TCG_TARGET_REG_BITS == 64,
+          .prefer_i64 = true,
           .opt_opc = vecop_list,
           .load_dest = true,
           .vece = MO_64 },
@@ -1859,7 +1859,7 @@ void gen_gvec_uaba(unsigned vece, uint32_t rd_ofs, uint32_t rn_ofs,
         { .fni8 = gen_uaba_i64,
           .fniv = gen_uaba_vec,
           .fno = gen_helper_gvec_uaba_d,
-          .prefer_i64 = TCG_TARGET_REG_BITS == 64,
+          .prefer_i64 = true,
           .opt_opc = vecop_list,
           .load_dest = true,
           .vece = MO_64 },
@@ -2429,7 +2429,7 @@ void gen_gvec_rev32(unsigned vece, uint32_t rd_ofs, uint32_t rn_ofs,
     static const GVecGen2 g = {
         .fni8 = gen_bswap32_i64,
         .fni4 = tcg_gen_bswap32_i32,
-        .prefer_i64 = TCG_TARGET_REG_BITS == 64,
+        .prefer_i64 = true,
         .vece = MO_32
     };
 
target/arm/tcg/gengvec64.c +2 -2
index 2429cab1b8..c425d2b149 100644
@@ -157,7 +157,7 @@ void gen_gvec_eor3(unsigned vece, uint32_t d, uint32_t n, uint32_t m,
         .fniv = gen_eor3_vec,
         .fno = gen_helper_sve2_eor3,
         .vece = MO_64,
-        .prefer_i64 = TCG_TARGET_REG_BITS == 64,
+        .prefer_i64 = true,
     };
     tcg_gen_gvec_4(d, n, m, a, oprsz, maxsz, &op);
 }
@@ -183,7 +183,7 @@ void gen_gvec_bcax(unsigned vece, uint32_t d, uint32_t n, uint32_t m,
         .fniv = gen_bcax_vec,
         .fno = gen_helper_sve2_bcax,
         .vece = MO_64,
-        .prefer_i64 = TCG_TARGET_REG_BITS == 64,
+        .prefer_i64 = true,
     };
     tcg_gen_gvec_4(d, n, m, a, oprsz, maxsz, &op);
 }
target/arm/tcg/translate-sve.c +13 -13
index 07b827fa8e..64adb5c1ce 100644
@@ -623,7 +623,7 @@ static void gen_bsl1n(unsigned vece, uint32_t d, uint32_t n, uint32_t m,
         .fniv = gen_bsl1n_vec,
         .fno = gen_helper_sve2_bsl1n,
         .vece = MO_64,
-        .prefer_i64 = TCG_TARGET_REG_BITS == 64,
+        .prefer_i64 = true,
     };
     tcg_gen_gvec_4(d, n, m, a, oprsz, maxsz, &op);
 }
@@ -661,7 +661,7 @@ static void gen_bsl2n(unsigned vece, uint32_t d, uint32_t n, uint32_t m,
         .fniv = gen_bsl2n_vec,
         .fno = gen_helper_sve2_bsl2n,
         .vece = MO_64,
-        .prefer_i64 = TCG_TARGET_REG_BITS == 64,
+        .prefer_i64 = true,
     };
     tcg_gen_gvec_4(d, n, m, a, oprsz, maxsz, &op);
 }
@@ -690,7 +690,7 @@ static void gen_nbsl(unsigned vece, uint32_t d, uint32_t n, uint32_t m,
         .fniv = gen_nbsl_vec,
         .fno = gen_helper_sve2_nbsl,
         .vece = MO_64,
-        .prefer_i64 = TCG_TARGET_REG_BITS == 64,
+        .prefer_i64 = true,
     };
     tcg_gen_gvec_4(d, n, m, a, oprsz, maxsz, &op);
 }
@@ -1367,7 +1367,7 @@ static bool trans_AND_pppp(DisasContext *s, arg_rprr_s *a)
         .fni8 = gen_and_pg_i64,
         .fniv = gen_and_pg_vec,
         .fno = gen_helper_sve_and_pppp,
-        .prefer_i64 = TCG_TARGET_REG_BITS == 64,
+        .prefer_i64 = true,
     };
 
     if (!dc_isar_feature(aa64_sve, s)) {
@@ -1405,7 +1405,7 @@ static bool trans_BIC_pppp(DisasContext *s, arg_rprr_s *a)
         .fni8 = gen_bic_pg_i64,
         .fniv = gen_bic_pg_vec,
         .fno = gen_helper_sve_bic_pppp,
-        .prefer_i64 = TCG_TARGET_REG_BITS == 64,
+        .prefer_i64 = true,
     };
 
     if (!dc_isar_feature(aa64_sve, s)) {
@@ -1436,7 +1436,7 @@ static bool trans_EOR_pppp(DisasContext *s, arg_rprr_s *a)
         .fni8 = gen_eor_pg_i64,
         .fniv = gen_eor_pg_vec,
         .fno = gen_helper_sve_eor_pppp,
-        .prefer_i64 = TCG_TARGET_REG_BITS == 64,
+        .prefer_i64 = true,
     };
 
     if (!dc_isar_feature(aa64_sve, s)) {
@@ -1483,7 +1483,7 @@ static bool trans_ORR_pppp(DisasContext *s, arg_rprr_s *a)
         .fni8 = gen_orr_pg_i64,
         .fniv = gen_orr_pg_vec,
         .fno = gen_helper_sve_orr_pppp,
-        .prefer_i64 = TCG_TARGET_REG_BITS == 64,
+        .prefer_i64 = true,
     };
 
     if (!dc_isar_feature(aa64_sve, s)) {
@@ -1514,7 +1514,7 @@ static bool trans_ORN_pppp(DisasContext *s, arg_rprr_s *a)
         .fni8 = gen_orn_pg_i64,
         .fniv = gen_orn_pg_vec,
         .fno = gen_helper_sve_orn_pppp,
-        .prefer_i64 = TCG_TARGET_REG_BITS == 64,
+        .prefer_i64 = true,
     };
 
     if (!dc_isar_feature(aa64_sve, s)) {
@@ -1542,7 +1542,7 @@ static bool trans_NOR_pppp(DisasContext *s, arg_rprr_s *a)
         .fni8 = gen_nor_pg_i64,
         .fniv = gen_nor_pg_vec,
         .fno = gen_helper_sve_nor_pppp,
-        .prefer_i64 = TCG_TARGET_REG_BITS == 64,
+        .prefer_i64 = true,
     };
 
     if (!dc_isar_feature(aa64_sve, s)) {
@@ -1570,7 +1570,7 @@ static bool trans_NAND_pppp(DisasContext *s, arg_rprr_s *a)
         .fni8 = gen_nand_pg_i64,
         .fniv = gen_nand_pg_vec,
         .fno = gen_helper_sve_nand_pppp,
-        .prefer_i64 = TCG_TARGET_REG_BITS == 64,
+        .prefer_i64 = true,
     };
 
     if (!dc_isar_feature(aa64_sve, s)) {
@@ -3680,7 +3680,7 @@ static bool trans_SUBR_zzi(DisasContext *s, arg_rri_esz *a)
           .fniv = tcg_gen_sub_vec,
           .fno = gen_helper_sve_subri_d,
           .opt_opc = vecop_list,
-          .prefer_i64 = TCG_TARGET_REG_BITS == 64,
+          .prefer_i64 = true,
           .vece = MO_64,
           .scalar_first = true }
     };
@@ -8024,7 +8024,7 @@ static void gen_sclamp(unsigned vece, uint32_t d, uint32_t n, uint32_t m,
           .fno  = gen_helper_gvec_sclamp_d,
           .opt_opc = vecop,
           .vece = MO_64,
-          .prefer_i64 = TCG_TARGET_REG_BITS == 64 }
+          .prefer_i64 = true }
     };
     tcg_gen_gvec_4(d, n, m, a, oprsz, maxsz, &ops[vece]);
 }
@@ -8075,7 +8075,7 @@ static void gen_uclamp(unsigned vece, uint32_t d, uint32_t n, uint32_t m,
           .fno  = gen_helper_gvec_uclamp_d,
           .opt_opc = vecop,
           .vece = MO_64,
-          .prefer_i64 = TCG_TARGET_REG_BITS == 64 }
+          .prefer_i64 = true }
     };
     tcg_gen_gvec_4(d, n, m, a, oprsz, maxsz, &ops[vece]);
 }
tcg/tcg-op-gvec.c +31 -31

248 lines not on this page · raw message

target/i386/tcg/emit.c.inc +1 -1
index bc3a07f972..41bf047b8d 100644
@@ -3006,7 +3006,7 @@ static void gen_PMOVMSKB(DisasContext *s, X86DecodedInsn *decode)
         .fniv = gen_pmovmskb_vec,
         .opt_opc = vecop_list,
         .vece = MO_64,
-        .prefer_i64 = TCG_TARGET_REG_BITS == 64
+        .prefer_i64 = true
     };
     MemOp ot = decode->op[2].ot;
     int vec_len = vector_len(s, decode);
target/riscv/insn_trans/trans_rvv.c.inc +1 -1
index 2a487179f6..caefd38216 100644
@@ -1489,7 +1489,7 @@ static void tcg_gen_gvec_rsubs(unsigned vece, uint32_t dofs, uint32_t aofs,
           .fniv = gen_rsub_vec,
           .fno = gen_helper_vec_rsubs64,
           .opt_opc = vecop_list,
-          .prefer_i64 = TCG_TARGET_REG_BITS == 64,
+          .prefer_i64 = true,
           .vece = MO_64 },
     };
 
Signature · 1 line
2.43.0
#37 lore raw

PATCH v2 26/58 tcg: Remove INDEX_op_brcond2_i32

In reply to Richard Henderson

This opcode was exclusively for 32-bit hosts.

---
 include/tcg/tcg-opc.h    |  1 -
 tcg/optimize.c           | 99 ----------------------------------------
 tcg/tcg-op.c             | 32 ++-----------
 tcg/tcg.c                | 34 --------------
 docs/devel/tcg-ops.rst   |  7 +--
 tcg/tci/tcg-target.c.inc | 17 -------
 6 files changed, 4 insertions(+), 186 deletions(-)
include/tcg/tcg-opc.h +0 -1
index e988edd93a..55283af326 100644
@@ -103,7 +103,6 @@ DEF(subb1o, 1, 2, 0, TCG_OPF_INT | TCG_OPF_CARRY_OUT)
 DEF(subbi, 1, 2, 0, TCG_OPF_INT | TCG_OPF_CARRY_IN)
 DEF(subbio, 1, 2, 0, TCG_OPF_INT | TCG_OPF_CARRY_IN | TCG_OPF_CARRY_OUT)
 
-DEF(brcond2_i32, 0, 4, 2, TCG_OPF_BB_END | TCG_OPF_COND_BRANCH)
 DEF(setcond2_i32, 1, 4, 1, 0)
 
 /* size changing ops */
tcg/optimize.c +0 -99

111 lines not on this page · raw message

tcg/tcg-op.c +3 -29
index ab7b409be6..61f6fd9095 100644
@@ -265,14 +265,6 @@ static void DNI tcg_gen_op6i_i64(TCGOpcode opc, TCGv_i64 a1, TCGv_i64 a2,
                 tcgv_i64_arg(a3), tcgv_i64_arg(a4), tcgv_i64_arg(a5), a6);
 }
 
-static TCGOp * DNI tcg_gen_op6ii_i32(TCGOpcode opc, TCGv_i32 a1, TCGv_i32 a2,
-                                     TCGv_i32 a3, TCGv_i32 a4,
-                                     TCGArg a5, TCGArg a6)
-{
-    return tcg_gen_op6(opc, TCG_TYPE_I32, tcgv_i32_arg(a1), tcgv_i32_arg(a2),
-                       tcgv_i32_arg(a3), tcgv_i32_arg(a4), a5, a6);
-}
-
 /* Generic ops.  */
 
 void gen_set_label(TCGLabel *l)
@@ -1873,33 +1865,15 @@ void tcg_gen_brcond_i64(TCGCond cond, TCGv_i64 arg1, TCGv_i64 arg2, TCGLabel *l)
     if (cond == TCG_COND_ALWAYS) {
         tcg_gen_br(l);
     } else if (cond != TCG_COND_NEVER) {
-        TCGOp *op;
-        if (TCG_TARGET_REG_BITS == 32) {
-            op = tcg_gen_op6ii_i32(INDEX_op_brcond2_i32, TCGV_LOW(arg1),
-                                   TCGV_HIGH(arg1), TCGV_LOW(arg2),
-                                   TCGV_HIGH(arg2), cond, label_arg(l));
-        } else {
-            op = tcg_gen_op4ii_i64(INDEX_op_brcond, arg1, arg2, cond,
-                                   label_arg(l));
-        }
+        TCGOp *op = tcg_gen_op4ii_i64(INDEX_op_brcond, arg1, arg2, cond,
+                                      label_arg(l));
         add_as_label_use(l, op);
     }
 }
 
 void tcg_gen_brcondi_i64(TCGCond cond, TCGv_i64 arg1, int64_t arg2, TCGLabel *l)
 {
-    if (TCG_TARGET_REG_BITS == 64) {
-        tcg_gen_brcond_i64(cond, arg1, tcg_constant_i64(arg2), l);
-    } else if (cond == TCG_COND_ALWAYS) {
-        tcg_gen_br(l);
-    } else if (cond != TCG_COND_NEVER) {
-        TCGOp *op = tcg_gen_op6ii_i32(INDEX_op_brcond2_i32,
-                                      TCGV_LOW(arg1), TCGV_HIGH(arg1),
-                                      tcg_constant_i32(arg2),
-                                      tcg_constant_i32(arg2 >> 32),
-                                      cond, label_arg(l));
-        add_as_label_use(l, op);
-    }
+    tcg_gen_brcond_i64(cond, arg1, tcg_constant_i64(arg2), l);
 }
 
 void tcg_gen_setcond_i64(TCGCond cond, TCGv_i64 ret,
tcg/tcg.c +0 -34
index fbf09f5c82..0521767c46 100644
@@ -1010,13 +1010,6 @@ typedef struct TCGOutOpBrcond {
                    TCGReg a1, tcg_target_long a2, TCGLabel *label);
 } TCGOutOpBrcond;
 
-typedef struct TCGOutOpBrcond2 {
-    TCGOutOp base;
-    void (*out)(TCGContext *s, TCGCond cond, TCGReg al, TCGReg ah,
-                TCGArg bl, bool const_bl,
-                TCGArg bh, bool const_bh, TCGLabel *l);
-} TCGOutOpBrcond2;
-
 typedef struct TCGOutOpBswap {
     TCGOutOp base;
     void (*out_rr)(TCGContext *s, TCGType type,
@@ -1248,7 +1241,6 @@ static const TCGOutOp * const all_outop[NB_OPS] = {
     [INDEX_op_goto_ptr] = &outop_goto_ptr,
 
 #if TCG_TARGET_REG_BITS == 32
-    OUTOP(INDEX_op_brcond2_i32, TCGOutOpBrcond2, outop_brcond2),
     OUTOP(INDEX_op_setcond2_i32, TCGOutOpSetcond2, outop_setcond2),
 #else
     OUTOP(INDEX_op_bswap64, TCGOutOpUnary, outop_bswap64),
@@ -2490,7 +2482,6 @@ bool tcg_op_supported(TCGOpcode op, TCGType type, unsigned flags)
     case INDEX_op_xor:
         return has_type;
 
-    case INDEX_op_brcond2_i32:
     case INDEX_op_setcond2_i32:
         return TCG_TARGET_REG_BITS == 32;
 
@@ -3022,7 +3013,6 @@ void tcg_dump_ops(TCGContext *s, FILE *f, bool have_prefs)
             case INDEX_op_setcond:
             case INDEX_op_negsetcond:
             case INDEX_op_movcond:
-            case INDEX_op_brcond2_i32:
             case INDEX_op_setcond2_i32:
             case INDEX_op_cmp_vec:
             case INDEX_op_cmpsel_vec:
@@ -3106,7 +3096,6 @@ void tcg_dump_ops(TCGContext *s, FILE *f, bool have_prefs)
             case INDEX_op_set_label:
             case INDEX_op_br:
             case INDEX_op_brcond:
-            case INDEX_op_brcond2_i32:
                 col += ne_fprintf(f, "%s$L%d", k ? "," : "",
                                   arg_label(op->args[k])->id);
                 i++, k++;
@@ -3563,9 +3552,6 @@ void tcg_op_remove(TCGContext *s, TCGOp *op)
     case INDEX_op_brcond:
         remove_label_use(op, 3);
         break;
-    case INDEX_op_brcond2_i32:
-        remove_label_use(op, 5);
-        break;
     default:
         break;
     }
@@ -3664,9 +3650,6 @@ static void move_label_uses(TCGLabel *to, TCGLabel *from)
         case INDEX_op_brcond:
             op->args[3] = label_arg(to);
             break;
-        case INDEX_op_brcond2_i32:
-            op->args[5] = label_arg(to);
-            break;
         default:
             g_assert_not_reached();
         }
@@ -5285,9 +5268,6 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op)
     case INDEX_op_cmp_vec:
         op_cond = op->args[3];
         break;
-    case INDEX_op_brcond2_i32:
-        op_cond = op->args[4];
-        break;
     case INDEX_op_movcond:
     case INDEX_op_setcond2_i32:
     case INDEX_op_cmpsel_vec:
@@ -5890,19 +5870,6 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op)
         break;
 
 #if TCG_TARGET_REG_BITS == 32
-    case INDEX_op_brcond2_i32:
-        {
-            const TCGOutOpBrcond2 *out = &outop_brcond2;
-            TCGCond cond = new_args[4];
-            TCGLabel *label = arg_label(new_args[5]);
-
-            tcg_debug_assert(!const_args[0]);
-            tcg_debug_assert(!const_args[1]);
-            out->out(s, cond, new_args[0], new_args[1],
-                     new_args[2], const_args[2],
-                     new_args[3], const_args[3], label);
-        }
-        break;
     case INDEX_op_setcond2_i32:
         {
             const TCGOutOpSetcond2 *out = &outop_setcond2;
@@ -5915,7 +5882,6 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op)
         }
         break;
 #else
-    case INDEX_op_brcond2_i32:
     case INDEX_op_setcond2_i32:
         g_assert_not_reached();
 #endif
docs/devel/tcg-ops.rst +1 -6
index f26b837a30..10d5edb4ca 100644
@@ -705,11 +705,6 @@ They are emitted as needed by inline functions within ``tcg-op.h``.
 
 .. list-table::
 
-   * - brcond2_i32 *t0_low*, *t0_high*, *t1_low*, *t1_high*, *cond*, *label*
-
-     - | Similar to brcond, except that the 64-bit values *t0* and *t1*
-         are formed from two 32-bit arguments.
-
    * - setcond2_i32 *dest*, *t1_low*, *t1_high*, *t2_low*, *t2_high*, *cond*
 
      - | Similar to setcond, except that the 64-bit values *t1* and *t2* are
@@ -940,7 +935,7 @@ The target word size (``TCG_TARGET_REG_BITS``) is expected to be 32 bit or
 
 On a 32 bit target, all 64 bit operations are converted to 32 bits.
 A few specific operations must be implemented to allow it
-(see brcond2_i32, setcond2_i32).
+(see setcond2_i32).
 
 On a 64 bit target, the values are transferred between 32 and 64-bit
 registers using the following ops:
tcg/tci/tcg-target.c.inc +0 -17
index 532f87262c..1756ffc59c 100644
@@ -1047,23 +1047,6 @@ static const TCGOutOpMovcond outop_movcond = {
     .out = tgen_movcond,
 };
 
-static void tgen_brcond2(TCGContext *s, TCGCond cond, TCGReg al, TCGReg ah,
-                         TCGArg bl, bool const_bl,
-                         TCGArg bh, bool const_bh, TCGLabel *l)
-{
-    tcg_out_op_rrrrrc(s, INDEX_op_setcond2_i32, TCG_REG_TMP,
-                      al, ah, bl, bh, cond);
-    tcg_out_op_rl(s, INDEX_op_brcond, TCG_REG_TMP, l);
-}
-
-#if TCG_TARGET_REG_BITS != 32
-__attribute__((unused))
-#endif
-static const TCGOutOpBrcond2 outop_brcond2 = {
-    .base.static_constraint = C_O0_I4(r, r, r, r),
-    .out = tgen_brcond2,
-};
-
 static void tgen_setcond2(TCGContext *s, TCGCond cond, TCGReg ret,
                           TCGReg al, TCGReg ah,
                           TCGArg bl, bool const_bl,
Signature · 1 line
2.43.0
#38 lore raw

PATCH v2 27/58 tcg: Remove INDEX_op_setcond2_i32

In reply to Richard Henderson

This opcode was exclusively for 32-bit hosts.

---
 include/tcg/tcg-opc.h    |   2 -
 tcg/optimize.c           | 205 ---------------------------------------
 tcg/tcg-op.c             |  47 +--------
 tcg/tcg.c                |  32 ------
 tcg/tci.c                |  10 --
 docs/devel/tcg-ops.rst   |  27 +-----
 tcg/tci/tcg-target.c.inc |  16 ---
 7 files changed, 8 insertions(+), 331 deletions(-)
include/tcg/tcg-opc.h +0 -2
index 55283af326..fc1270f01e 100644
@@ -103,8 +103,6 @@ DEF(subb1o, 1, 2, 0, TCG_OPF_INT | TCG_OPF_CARRY_OUT)
 DEF(subbi, 1, 2, 0, TCG_OPF_INT | TCG_OPF_CARRY_IN)
 DEF(subbio, 1, 2, 0, TCG_OPF_INT | TCG_OPF_CARRY_IN | TCG_OPF_CARRY_OUT)
 
-DEF(setcond2_i32, 1, 4, 1, 0)
-
 /* size changing ops */
 DEF(ext_i32_i64, 1, 1, 0, 0)
 DEF(extu_i32_i64, 1, 1, 0, 0)
tcg/optimize.c +0 -205

229 lines not on this page · raw message

tcg/tcg-op.c +4 -43

73 lines not on this page · raw message

tcg/tcg.c +0 -32
index 0521767c46..b6a65fe224 100644
@@ -1088,12 +1088,6 @@ typedef struct TCGOutOpSetcond {
                     TCGReg ret, TCGReg a1, tcg_target_long a2);
 } TCGOutOpSetcond;
 
-typedef struct TCGOutOpSetcond2 {
-    TCGOutOp base;
-    void (*out)(TCGContext *s, TCGCond cond, TCGReg ret, TCGReg al, TCGReg ah,
-                TCGArg bl, bool const_bl, TCGArg bh, bool const_bh);
-} TCGOutOpSetcond2;
-
 typedef struct TCGOutOpStore {
     TCGOutOp base;
     void (*out_r)(TCGContext *s, TCGType type, TCGReg data,
@@ -1240,9 +1234,6 @@ static const TCGOutOp * const all_outop[NB_OPS] = {
 
     [INDEX_op_goto_ptr] = &outop_goto_ptr,
 
-#if TCG_TARGET_REG_BITS == 32
-    OUTOP(INDEX_op_setcond2_i32, TCGOutOpSetcond2, outop_setcond2),
-#else
     OUTOP(INDEX_op_bswap64, TCGOutOpUnary, outop_bswap64),
     OUTOP(INDEX_op_ext_i32_i64, TCGOutOpUnary, outop_exts_i32_i64),
     OUTOP(INDEX_op_extu_i32_i64, TCGOutOpUnary, outop_extu_i32_i64),
@@ -1251,7 +1242,6 @@ static const TCGOutOp * const all_outop[NB_OPS] = {
     OUTOP(INDEX_op_ld32u, TCGOutOpLoad, outop_ld32u),
     OUTOP(INDEX_op_ld32s, TCGOutOpLoad, outop_ld32s),
     OUTOP(INDEX_op_st32, TCGOutOpStore, outop_st),
-#endif
 };
 
 #undef OUTOP
@@ -2482,9 +2472,6 @@ bool tcg_op_supported(TCGOpcode op, TCGType type, unsigned flags)
     case INDEX_op_xor:
         return has_type;
 
-    case INDEX_op_setcond2_i32:
-        return TCG_TARGET_REG_BITS == 32;
-
     case INDEX_op_ld32u:
     case INDEX_op_ld32s:
     case INDEX_op_st32:
@@ -3013,7 +3000,6 @@ void tcg_dump_ops(TCGContext *s, FILE *f, bool have_prefs)
             case INDEX_op_setcond:
             case INDEX_op_negsetcond:
             case INDEX_op_movcond:
-            case INDEX_op_setcond2_i32:
             case INDEX_op_cmp_vec:
             case INDEX_op_cmpsel_vec:
                 if (op->args[k] < ARRAY_SIZE(cond_name)
@@ -5269,7 +5255,6 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op)
         op_cond = op->args[3];
         break;
     case INDEX_op_movcond:
-    case INDEX_op_setcond2_i32:
     case INDEX_op_cmpsel_vec:
         op_cond = op->args[5];
         break;
@@ -5869,23 +5854,6 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op)
         }
         break;
 
-#if TCG_TARGET_REG_BITS == 32
-    case INDEX_op_setcond2_i32:
-        {
-            const TCGOutOpSetcond2 *out = &outop_setcond2;
-            TCGCond cond = new_args[5];
-
-            tcg_debug_assert(!const_args[1]);
-            tcg_debug_assert(!const_args[2]);
-            out->out(s, cond, new_args[0], new_args[1], new_args[2],
-                     new_args[3], const_args[3], new_args[4], const_args[4]);
-        }
-        break;
-#else
-    case INDEX_op_setcond2_i32:
-        g_assert_not_reached();
-#endif
-
     case INDEX_op_goto_ptr:
         tcg_debug_assert(!const_args[0]);
         tcg_out_goto_ptr(s, new_args[0]);
tcg/tci.c +0 -10
index e15d4e8e08..7f3ba9b5da 100644
@@ -418,14 +418,6 @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env,
             tci_args_l(insn, tb_ptr, &ptr);
             tb_ptr = ptr;
             continue;
-#if TCG_TARGET_REG_BITS == 32
-        case INDEX_op_setcond2_i32:
-            tci_args_rrrrrc(insn, &r0, &r1, &r2, &r3, &r4, &condition);
-            regs[r0] = tci_compare64(tci_uint64(regs[r2], regs[r1]),
-                                     tci_uint64(regs[r4], regs[r3]),
-                                     condition);
-            break;
-#elif TCG_TARGET_REG_BITS == 64
         case INDEX_op_setcond:
             tci_args_rrrc(insn, &r0, &r1, &r2, &condition);
             regs[r0] = tci_compare64(regs[r1], regs[r2], condition);
@@ -435,7 +427,6 @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env,
             tmp32 = tci_compare64(regs[r1], regs[r2], condition);
             regs[r0] = regs[tmp32 ? r3 : r4];
             break;
-#endif
         case INDEX_op_mov:
             tci_args_rr(insn, &r0, &r1);
             regs[r0] = regs[r1];
@@ -1040,7 +1031,6 @@ int print_insn_tci(bfd_vma addr, disassemble_info *info)
 
     case INDEX_op_tci_movcond32:
     case INDEX_op_movcond:
-    case INDEX_op_setcond2_i32:
         tci_args_rrrrrc(insn, &r0, &r1, &r2, &r3, &r4, &c);
         info->fprintf_func(info->stream, "%-12s  %s, %s, %s, %s, %s, %s",
                            op_name, str_r(r0), str_r(r1), str_r(r2),
docs/devel/tcg-ops.rst +4 -23
index 10d5edb4ca..fd3a50bf4c 100644
@@ -696,21 +696,6 @@ Memory Barrier support
        | Please see :ref:`atomics-ref` for more information on memory barriers.
 
 
-64-bit guest on 32-bit host support
------------------------------------
-
-The following opcodes are internal to TCG.  Thus they are to be implemented by
-32-bit host code generators, but are not to be emitted by guest translators.
-They are emitted as needed by inline functions within ``tcg-op.h``.
-
-.. list-table::
-
-   * - setcond2_i32 *dest*, *t1_low*, *t1_high*, *t2_low*, *t2_high*, *cond*
-
-     - | Similar to setcond, except that the 64-bit values *t1* and *t2* are
-         formed from two 32-bit arguments. The result is a 32-bit value.
-
-
 QEMU specific operations
 ------------------------
 
@@ -930,15 +915,11 @@ than being a standalone C file.
 Assumptions
 -----------
 
-The target word size (``TCG_TARGET_REG_BITS``) is expected to be 32 bit or
-64 bit. It is expected that the pointer has the same size as the word.
+The target word size (``TCG_TARGET_REG_BITS``) is expected to be 64 bit.
+It is expected that the pointer has the same size as the word.
 
-On a 32 bit target, all 64 bit operations are converted to 32 bits.
-A few specific operations must be implemented to allow it
-(see setcond2_i32).
-
-On a 64 bit target, the values are transferred between 32 and 64-bit
-registers using the following ops:
+Values are transferred between 32 and 64-bit registers using the
+following ops:
 
 - extrl_i64_i32
 - extrh_i64_i32
tcg/tci/tcg-target.c.inc +0 -16
index 1756ffc59c..8bd8db4401 100644
@@ -1047,22 +1047,6 @@ static const TCGOutOpMovcond outop_movcond = {
     .out = tgen_movcond,
 };
 
-static void tgen_setcond2(TCGContext *s, TCGCond cond, TCGReg ret,
-                          TCGReg al, TCGReg ah,
-                          TCGArg bl, bool const_bl,
-                          TCGArg bh, bool const_bh)
-{
-    tcg_out_op_rrrrrc(s, INDEX_op_setcond2_i32, ret, al, ah, bl, bh, cond);
-}
-
-#if TCG_TARGET_REG_BITS != 32
-__attribute__((unused))
-#endif
-static const TCGOutOpSetcond2 outop_setcond2 = {
-    .base.static_constraint = C_O1_I4(r, r, r, r, r),
-    .out = tgen_setcond2,
-};
-
 static void tcg_out_mb(TCGContext *s, unsigned a0)
 {
     tcg_out_op_v(s, INDEX_op_mb);
Signature · 1 line
2.43.0
#39 lore raw

PATCH v2 28/58 tcg: Remove INDEX_op_dup2_vec

In reply to Richard Henderson

This opcode was exclusively for 32-bit hosts.

---
 include/tcg/tcg-opc.h |  1 -
 tcg/optimize.c        | 18 ---------
 tcg/tcg-op-vec.c      | 14 +------
 tcg/tcg.c             | 94 -------------------------------------------
 4 files changed, 2 insertions(+), 125 deletions(-)
include/tcg/tcg-opc.h +0 -1
index fc1270f01e..28806057c5 100644
@@ -130,7 +130,6 @@ DEF(qemu_st2, 0, 3, 1, TCG_OPF_CALL_CLOBBER | TCG_OPF_SIDE_EFFECTS | TCG_OPF_INT
 DEF(mov_vec, 1, 1, 0, TCG_OPF_VECTOR | TCG_OPF_NOT_PRESENT)
 
 DEF(dup_vec, 1, 1, 0, TCG_OPF_VECTOR)
-DEF(dup2_vec, 1, 2, 0, TCG_OPF_VECTOR)
 
 DEF(ld_vec, 1, 1, 1, TCG_OPF_VECTOR)
 DEF(st_vec, 0, 2, 1, TCG_OPF_VECTOR)
tcg/optimize.c +0 -18
index d845c7eef2..801a0a2c68 100644
@@ -1716,21 +1716,6 @@ static bool fold_dup(OptContext *ctx, TCGOp *op)
     return finish_folding(ctx, op);
 }
 
-static bool fold_dup2(OptContext *ctx, TCGOp *op)
-{
-    if (arg_is_const(op->args[1]) && arg_is_const(op->args[2])) {
-        uint64_t t = deposit64(arg_const_val(op->args[1]), 32, 32,
-                               arg_const_val(op->args[2]));
-        return tcg_opt_gen_movi(ctx, op, op->args[0], t);
-    }
-
-    if (args_are_copies(op->args[1], op->args[2])) {
-        op->opc = INDEX_op_dup_vec;
-        TCGOP_VECE(op) = MO_32;
-    }
-    return finish_folding(ctx, op);
-}
-
 static bool fold_eqv(OptContext *ctx, TCGOp *op)
 {
     uint64_t z_mask, o_mask, s_mask;
@@ -2887,9 +2872,6 @@ void tcg_optimize(TCGContext *s)
         case INDEX_op_dup_vec:
             done = fold_dup(&ctx, op);
             break;
-        case INDEX_op_dup2_vec:
-            done = fold_dup2(&ctx, op);
-            break;
         case INDEX_op_eqv:
         case INDEX_op_eqv_vec:
             done = fold_eqv(&ctx, op);
tcg/tcg-op-vec.c +2 -12
index 893d68e7d8..67e837174b 100644
@@ -75,7 +75,6 @@ bool tcg_can_emit_vecop_list(const TCGOpcode *list,
         case INDEX_op_xor_vec:
         case INDEX_op_mov_vec:
         case INDEX_op_dup_vec:
-        case INDEX_op_dup2_vec:
         case INDEX_op_ld_vec:
         case INDEX_op_st_vec:
         case INDEX_op_bitsel_vec:
@@ -228,20 +227,11 @@ void tcg_gen_dupi_vec(unsigned vece, TCGv_vec r, uint64_t a)
 void tcg_gen_dup_i64_vec(unsigned vece, TCGv_vec r, TCGv_i64 a)
 {
     TCGArg ri = tcgv_vec_arg(r);
+    TCGArg ai = tcgv_i64_arg(a);
     TCGTemp *rt = arg_temp(ri);
     TCGType type = rt->base_type;
 
-    if (TCG_TARGET_REG_BITS == 64) {
-        TCGArg ai = tcgv_i64_arg(a);
-        vec_gen_2(INDEX_op_dup_vec, type, vece, ri, ai);
-    } else if (vece == MO_64) {
-        TCGArg al = tcgv_i32_arg(TCGV_LOW(a));
-        TCGArg ah = tcgv_i32_arg(TCGV_HIGH(a));
-        vec_gen_3(INDEX_op_dup2_vec, type, MO_64, ri, al, ah);
-    } else {
-        TCGArg ai = tcgv_i32_arg(TCGV_LOW(a));
-        vec_gen_2(INDEX_op_dup_vec, type, vece, ri, ai);
-    }
+    vec_gen_2(INDEX_op_dup_vec, type, vece, ri, ai);
 }
 
 void tcg_gen_dup_i32_vec(unsigned vece, TCGv_vec r, TCGv_i32 a)
tcg/tcg.c +0 -94

112 lines not on this page · raw message

Signature · 1 line
2.43.0
#40 lore raw

PATCH v2 29/58 tcg/tci: Drop TCG_TARGET_REG_BITS tests

In reply to Richard Henderson
---
 tcg/tci/tcg-target-has.h |  2 --
 tcg/tci.c                | 50 ++-------------------------------------
 tcg/tci/tcg-target.c.inc | 51 ++++++----------------------------------
 3 files changed, 9 insertions(+), 94 deletions(-)
tcg/tci/tcg-target-has.h +0 -2
index ab07ce1fcb..64742cf0b7 100644
@@ -7,9 +7,7 @@
 #ifndef TCG_TARGET_HAS_H
 #define TCG_TARGET_HAS_H
 
-#if TCG_TARGET_REG_BITS == 64
 #define TCG_TARGET_HAS_extr_i64_i32     0
-#endif /* TCG_TARGET_REG_BITS == 64 */
 
 #define TCG_TARGET_HAS_qemu_ldst_i128   0
 
tcg/tci.c +2 -48

97 lines not on this page · raw message

tcg/tci/tcg-target.c.inc +7 -44

145 lines not on this page · raw message

Signature · 1 line
2.43.0
#41 lore raw

PATCH v2 30/58 tcg/tci: Remove glue TCG_TARGET_REG_BITS renames

In reply to Richard Henderson
---
 tcg/tci.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)
tcg/tci.c +4 -9
index f71993c287..29ecb39929 100644
@@ -26,11 +26,6 @@
 #include <ffi.h>
 
 
-#define ctpop_tr    glue(ctpop, TCG_TARGET_REG_BITS)
-#define deposit_tr  glue(deposit, TCG_TARGET_REG_BITS)
-#define extract_tr  glue(extract, TCG_TARGET_REG_BITS)
-#define sextract_tr glue(sextract, TCG_TARGET_REG_BITS)
-
 /*
  * Enable TCI assertions only when debugging TCG (and without NDEBUG defined).
  * Without assertions, the interpreter runs much faster.
@@ -525,7 +520,7 @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env,
             break;
         case INDEX_op_ctpop:
             tci_args_rr(insn, &r0, &r1);
-            regs[r0] = ctpop_tr(regs[r1]);
+            regs[r0] = ctpop64(regs[r1]);
             break;
         case INDEX_op_addco:
             tci_args_rrr(insn, &r0, &r1, &r2);
@@ -639,15 +634,15 @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env,
             break;
         case INDEX_op_deposit:
             tci_args_rrrbb(insn, &r0, &r1, &r2, &pos, &len);
-            regs[r0] = deposit_tr(regs[r1], pos, len, regs[r2]);
+            regs[r0] = deposit64(regs[r1], pos, len, regs[r2]);
             break;
         case INDEX_op_extract:
             tci_args_rrbb(insn, &r0, &r1, &pos, &len);
-            regs[r0] = extract_tr(regs[r1], pos, len);
+            regs[r0] = extract64(regs[r1], pos, len);
             break;
         case INDEX_op_sextract:
             tci_args_rrbb(insn, &r0, &r1, &pos, &len);
-            regs[r0] = sextract_tr(regs[r1], pos, len);
+            regs[r0] = sextract64(regs[r1], pos, len);
             break;
         case INDEX_op_brcond:
             tci_args_rl(insn, tb_ptr, &r0, &ptr);
Signature · 1 line
2.43.0
#42 lore raw

PATCH v2 31/58 tcg: Drop TCG_TARGET_REG_BITS test in region.c

In reply to Richard Henderson
---
 tcg/region.c | 12 ------------
 1 file changed, 12 deletions(-)
tcg/region.c +0 -12
index 2181267e48..5d4be1453b 100644
@@ -464,17 +464,6 @@ static size_t tcg_n_regions(size_t tb_size, unsigned max_threads)
  */
 #define MIN_CODE_GEN_BUFFER_SIZE     (1 * MiB)
 
-#if TCG_TARGET_REG_BITS == 32
-#define DEFAULT_CODE_GEN_BUFFER_SIZE_1 (32 * MiB)
-#ifdef CONFIG_USER_ONLY
-/*
- * For user mode on smaller 32 bit systems we may run into trouble
- * allocating big chunks of data in the right place. On these systems
- * we utilise a static code generation buffer directly in the binary.
- */
-#define USE_STATIC_CODE_GEN_BUFFER
-#endif
-#else /* TCG_TARGET_REG_BITS == 64 */
 #ifdef CONFIG_USER_ONLY
 /*
  * As user-mode emulation typically means running multiple instances
@@ -490,7 +479,6 @@ static size_t tcg_n_regions(size_t tb_size, unsigned max_threads)
  */
 #define DEFAULT_CODE_GEN_BUFFER_SIZE_1 (1 * GiB)
 #endif
-#endif
 
 #define DEFAULT_CODE_GEN_BUFFER_SIZE \
   (DEFAULT_CODE_GEN_BUFFER_SIZE_1 < MAX_CODE_GEN_BUFFER_SIZE \
Signature · 1 line
2.43.0
#43 lore raw

PATCH v2 32/58 tcg: Drop TCG_TARGET_REG_BITS tests in tcg-op.c

In reply to Richard Henderson
---
 tcg/tcg-op.c | 686 +++++++--------------------------------------------
 1 file changed, 90 insertions(+), 596 deletions(-)
tcg/tcg-op.c +90 -596
index d20888dd8f..8d67acc4fc 100644
@@ -1154,7 +1154,7 @@ void tcg_gen_mulu2_i32(TCGv_i32 rl, TCGv_i32 rh, TCGv_i32 arg1, TCGv_i32 arg2)
         tcg_gen_op3_i32(INDEX_op_muluh, rh, arg1, arg2);
         tcg_gen_mov_i32(rl, t);
         tcg_temp_free_i32(t);
-    } else if (TCG_TARGET_REG_BITS == 64) {
+    } else {
         TCGv_i64 t0 = tcg_temp_ebb_new_i64();
         TCGv_i64 t1 = tcg_temp_ebb_new_i64();
         tcg_gen_extu_i32_i64(t0, arg1);
@@ -1163,8 +1163,6 @@ void tcg_gen_mulu2_i32(TCGv_i32 rl, TCGv_i32 rh, TCGv_i32 arg1, TCGv_i32 arg2)
         tcg_gen_extr_i64_i32(rl, rh, t0);
         tcg_temp_free_i64(t0);
         tcg_temp_free_i64(t1);
-    } else {
-        g_assert_not_reached();
     }
 }
 
@@ -1178,24 +1176,6 @@ void tcg_gen_muls2_i32(TCGv_i32 rl, TCGv_i32 rh, TCGv_i32 arg1, TCGv_i32 arg2)
         tcg_gen_op3_i32(INDEX_op_mulsh, rh, arg1, arg2);
         tcg_gen_mov_i32(rl, t);
         tcg_temp_free_i32(t);
-    } else if (TCG_TARGET_REG_BITS == 32) {
-        TCGv_i32 t0 = tcg_temp_ebb_new_i32();
-        TCGv_i32 t1 = tcg_temp_ebb_new_i32();
-        TCGv_i32 t2 = tcg_temp_ebb_new_i32();
-        TCGv_i32 t3 = tcg_temp_ebb_new_i32();
-        tcg_gen_mulu2_i32(t0, t1, arg1, arg2);
-        /* Adjust for negative inputs.  */
-        tcg_gen_sari_i32(t2, arg1, 31);
-        tcg_gen_sari_i32(t3, arg2, 31);
-        tcg_gen_and_i32(t2, t2, arg2);
-        tcg_gen_and_i32(t3, t3, arg1);
-        tcg_gen_sub_i32(rh, t1, t2);
-        tcg_gen_sub_i32(rh, rh, t3);
-        tcg_gen_mov_i32(rl, t0);
-        tcg_temp_free_i32(t0);
-        tcg_temp_free_i32(t1);
-        tcg_temp_free_i32(t2);
-        tcg_temp_free_i32(t3);
     } else {
         TCGv_i64 t0 = tcg_temp_ebb_new_i64();
         TCGv_i64 t1 = tcg_temp_ebb_new_i64();
@@ -1210,29 +1190,14 @@ void tcg_gen_muls2_i32(TCGv_i32 rl, TCGv_i32 rh, TCGv_i32 arg1, TCGv_i32 arg2)
 
 void tcg_gen_mulsu2_i32(TCGv_i32 rl, TCGv_i32 rh, TCGv_i32 arg1, TCGv_i32 arg2)
 {
-    if (TCG_TARGET_REG_BITS == 32) {
-        TCGv_i32 t0 = tcg_temp_ebb_new_i32();
-        TCGv_i32 t1 = tcg_temp_ebb_new_i32();
-        TCGv_i32 t2 = tcg_temp_ebb_new_i32();
-        tcg_gen_mulu2_i32(t0, t1, arg1, arg2);
-        /* Adjust for negative input for the signed arg1.  */
-        tcg_gen_sari_i32(t2, arg1, 31);
-        tcg_gen_and_i32(t2, t2, arg2);
-        tcg_gen_sub_i32(rh, t1, t2);
-        tcg_gen_mov_i32(rl, t0);
-        tcg_temp_free_i32(t0);
-        tcg_temp_free_i32(t1);
-        tcg_temp_free_i32(t2);
-    } else {
-        TCGv_i64 t0 = tcg_temp_ebb_new_i64();
-        TCGv_i64 t1 = tcg_temp_ebb_new_i64();
-        tcg_gen_ext_i32_i64(t0, arg1);
-        tcg_gen_extu_i32_i64(t1, arg2);
-        tcg_gen_mul_i64(t0, t0, t1);
-        tcg_gen_extr_i64_i32(rl, rh, t0);
-        tcg_temp_free_i64(t0);
-        tcg_temp_free_i64(t1);
-    }
+    TCGv_i64 t0 = tcg_temp_ebb_new_i64();
+    TCGv_i64 t1 = tcg_temp_ebb_new_i64();
+    tcg_gen_ext_i32_i64(t0, arg1);
+    tcg_gen_extu_i32_i64(t1, arg2);
+    tcg_gen_mul_i64(t0, t0, t1);
+    tcg_gen_extr_i64_i32(rl, rh, t0);
+    tcg_temp_free_i64(t0);
+    tcg_temp_free_i64(t1);
 }
 
 void tcg_gen_ext8s_i32(TCGv_i32 ret, TCGv_i32 arg)
@@ -1414,263 +1379,119 @@ void tcg_gen_st_i32(TCGv_i32 arg1, TCGv_ptr arg2, tcg_target_long offset)
 
 void tcg_gen_discard_i64(TCGv_i64 arg)
 {
-    if (TCG_TARGET_REG_BITS == 64) {
-        tcg_gen_op1_i64(INDEX_op_discard, TCG_TYPE_I64, arg);
-    } else {
-        tcg_gen_discard_i32(TCGV_LOW(arg));
-        tcg_gen_discard_i32(TCGV_HIGH(arg));
-    }
+    tcg_gen_op1_i64(INDEX_op_discard, TCG_TYPE_I64, arg);
 }
 
 void tcg_gen_mov_i64(TCGv_i64 ret, TCGv_i64 arg)
 {
-    if (ret == arg) {
-        return;
-    }
-    if (TCG_TARGET_REG_BITS == 64) {
+    if (ret != arg) {
         tcg_gen_op2_i64(INDEX_op_mov, ret, arg);
-    } else {
-        TCGTemp *ts = tcgv_i64_temp(arg);
-
-        /* Canonicalize TCGv_i64 TEMP_CONST into TCGv_i32 TEMP_CONST. */
-        if (ts->kind == TEMP_CONST) {
-            tcg_gen_movi_i64(ret, ts->val);
-        } else {
-            tcg_gen_mov_i32(TCGV_LOW(ret), TCGV_LOW(arg));
-            tcg_gen_mov_i32(TCGV_HIGH(ret), TCGV_HIGH(arg));
-        }
     }
 }
 
 void tcg_gen_movi_i64(TCGv_i64 ret, int64_t arg)
 {
-    if (TCG_TARGET_REG_BITS == 64) {
-        tcg_gen_mov_i64(ret, tcg_constant_i64(arg));
-    } else {
-        tcg_gen_movi_i32(TCGV_LOW(ret), arg);
-        tcg_gen_movi_i32(TCGV_HIGH(ret), arg >> 32);
-    }
+    tcg_gen_mov_i64(ret, tcg_constant_i64(arg));
 }
 
 void tcg_gen_ld8u_i64(TCGv_i64 ret, TCGv_ptr arg2, tcg_target_long offset)
 {
-    if (TCG_TARGET_REG_BITS == 64) {
-        tcg_gen_ldst_op_i64(INDEX_op_ld8u, ret, arg2, offset);
-    } else {
-        tcg_gen_ld8u_i32(TCGV_LOW(ret), arg2, offset);
-        tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
-    }
+    tcg_gen_ldst_op_i64(INDEX_op_ld8u, ret, arg2, offset);
 }
 
 void tcg_gen_ld8s_i64(TCGv_i64 ret, TCGv_ptr arg2, tcg_target_long offset)
 {
-    if (TCG_TARGET_REG_BITS == 64) {
-        tcg_gen_ldst_op_i64(INDEX_op_ld8s, ret, arg2, offset);
-    } else {
-        tcg_gen_ld8s_i32(TCGV_LOW(ret), arg2, offset);
-        tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31);
-    }
+    tcg_gen_ldst_op_i64(INDEX_op_ld8s, ret, arg2, offset);
 }
 
 void tcg_gen_ld16u_i64(TCGv_i64 ret, TCGv_ptr arg2, tcg_target_long offset)
 {
-    if (TCG_TARGET_REG_BITS == 64) {
-        tcg_gen_ldst_op_i64(INDEX_op_ld16u, ret, arg2, offset);
-    } else {
-        tcg_gen_ld16u_i32(TCGV_LOW(ret), arg2, offset);
-        tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
-    }
+    tcg_gen_ldst_op_i64(INDEX_op_ld16u, ret, arg2, offset);
 }
 
 void tcg_gen_ld16s_i64(TCGv_i64 ret, TCGv_ptr arg2, tcg_target_long offset)
 {
-    if (TCG_TARGET_REG_BITS == 64) {
-        tcg_gen_ldst_op_i64(INDEX_op_ld16s, ret, arg2, offset);
-    } else {
-        tcg_gen_ld16s_i32(TCGV_LOW(ret), arg2, offset);
-        tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31);
-    }
+    tcg_gen_ldst_op_i64(INDEX_op_ld16s, ret, arg2, offset);
 }
 
 void tcg_gen_ld32u_i64(TCGv_i64 ret, TCGv_ptr arg2, tcg_target_long offset)
 {
-    if (TCG_TARGET_REG_BITS == 64) {
-        tcg_gen_ldst_op_i64(INDEX_op_ld32u, ret, arg2, offset);
-    } else {
-        tcg_gen_ld_i32(TCGV_LOW(ret), arg2, offset);
-        tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
-    }
+    tcg_gen_ldst_op_i64(INDEX_op_ld32u, ret, arg2, offset);
 }
 
 void tcg_gen_ld32s_i64(TCGv_i64 ret, TCGv_ptr arg2, tcg_target_long offset)
 {
-    if (TCG_TARGET_REG_BITS == 64) {
-        tcg_gen_ldst_op_i64(INDEX_op_ld32s, ret, arg2, offset);
-    } else {
-        tcg_gen_ld_i32(TCGV_LOW(ret), arg2, offset);
-        tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31);
-    }
+    tcg_gen_ldst_op_i64(INDEX_op_ld32s, ret, arg2, offset);
 }
 
 void tcg_gen_ld_i64(TCGv_i64 ret, TCGv_ptr arg2, tcg_target_long offset)
 {
-    /*
-     * For 32-bit host, since arg2 and ret have different types,
-     * they cannot be the same temporary -- no chance of overlap.
-     */
-    if (TCG_TARGET_REG_BITS == 64) {
-        tcg_gen_ldst_op_i64(INDEX_op_ld, ret, arg2, offset);
-    } else if (HOST_BIG_ENDIAN) {
-        tcg_gen_ld_i32(TCGV_HIGH(ret), arg2, offset);
-        tcg_gen_ld_i32(TCGV_LOW(ret), arg2, offset + 4);
-    } else {
-        tcg_gen_ld_i32(TCGV_LOW(ret), arg2, offset);
-        tcg_gen_ld_i32(TCGV_HIGH(ret), arg2, offset + 4);
-    }
+    tcg_gen_ldst_op_i64(INDEX_op_ld, ret, arg2, offset);
 }
 
 void tcg_gen_st8_i64(TCGv_i64 arg1, TCGv_ptr arg2, tcg_target_long offset)
 {
-    if (TCG_TARGET_REG_BITS == 64) {
-        tcg_gen_ldst_op_i64(INDEX_op_st8, arg1, arg2, offset);
-    } else {
-        tcg_gen_st8_i32(TCGV_LOW(arg1), arg2, offset);
-    }
+    tcg_gen_ldst_op_i64(INDEX_op_st8, arg1, arg2, offset);
 }
 
 void tcg_gen_st16_i64(TCGv_i64 arg1, TCGv_ptr arg2, tcg_target_long offset)
 {
-    if (TCG_TARGET_REG_BITS == 64) {
-        tcg_gen_ldst_op_i64(INDEX_op_st16, arg1, arg2, offset);
-    } else {
-        tcg_gen_st16_i32(TCGV_LOW(arg1), arg2, offset);
-    }
+    tcg_gen_ldst_op_i64(INDEX_op_st16, arg1, arg2, offset);
 }
 
 void tcg_gen_st32_i64(TCGv_i64 arg1, TCGv_ptr arg2, tcg_target_long offset)
 {
-    if (TCG_TARGET_REG_BITS == 64) {
-        tcg_gen_ldst_op_i64(INDEX_op_st32, arg1, arg2, offset);
-    } else {
-        tcg_gen_st_i32(TCGV_LOW(arg1), arg2, offset);
-    }
+    tcg_gen_ldst_op_i64(INDEX_op_st32, arg1, arg2, offset);
 }
 
 void tcg_gen_st_i64(TCGv_i64 arg1, TCGv_ptr arg2, tcg_target_long offset)
 {
-    if (TCG_TARGET_REG_BITS == 64) {
-        tcg_gen_ldst_op_i64(INDEX_op_st, arg1, arg2, offset);
-    } else if (HOST_BIG_ENDIAN) {
-        tcg_gen_st_i32(TCGV_HIGH(arg1), arg2, offset);
-        tcg_gen_st_i32(TCGV_LOW(arg1), arg2, offset + 4);
-    } else {
-        tcg_gen_st_i32(TCGV_LOW(arg1), arg2, offset);
-        tcg_gen_st_i32(TCGV_HIGH(arg1), arg2, offset + 4);
-    }
+    tcg_gen_ldst_op_i64(INDEX_op_st, arg1, arg2, offset);
 }
 
 void tcg_gen_add_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
 {
-    if (TCG_TARGET_REG_BITS == 64) {
-        tcg_gen_op3_i64(INDEX_op_add, ret, arg1, arg2);
-    } else {
-        tcg_gen_add2_i32(TCGV_LOW(ret), TCGV_HIGH(ret), TCGV_LOW(arg1),
-                         TCGV_HIGH(arg1), TCGV_LOW(arg2), TCGV_HIGH(arg2));
-    }
+    tcg_gen_op3_i64(INDEX_op_add, ret, arg1, arg2);
 }
 
 void tcg_gen_sub_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
 {
-    if (TCG_TARGET_REG_BITS == 64) {
-        tcg_gen_op3_i64(INDEX_op_sub, ret, arg1, arg2);
-    } else {
-        tcg_gen_sub2_i32(TCGV_LOW(ret), TCGV_HIGH(ret), TCGV_LOW(arg1),
-                         TCGV_HIGH(arg1), TCGV_LOW(arg2), TCGV_HIGH(arg2));
-    }
+    tcg_gen_op3_i64(INDEX_op_sub, ret, arg1, arg2);
 }
 
 void tcg_gen_and_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
 {
-    if (TCG_TARGET_REG_BITS == 64) {
-        tcg_gen_op3_i64(INDEX_op_and, ret, arg1, arg2);
-    } else {
-        tcg_gen_and_i32(TCGV_LOW(ret), TCGV_LOW(arg1), TCGV_LOW(arg2));
-        tcg_gen_and_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
-    }
+    tcg_gen_op3_i64(INDEX_op_and, ret, arg1, arg2);
 }
 
 void tcg_gen_or_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
 {
-    if (TCG_TARGET_REG_BITS == 64) {
-        tcg_gen_op3_i64(INDEX_op_or, ret, arg1, arg2);
-    } else {
-        tcg_gen_or_i32(TCGV_LOW(ret), TCGV_LOW(arg1), TCGV_LOW(arg2));
-        tcg_gen_or_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
-    }
+    tcg_gen_op3_i64(INDEX_op_or, ret, arg1, arg2);
 }
 
 void tcg_gen_xor_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
 {
-    if (TCG_TARGET_REG_BITS == 64) {
-        tcg_gen_op3_i64(INDEX_op_xor, ret, arg1, arg2);
-    } else {
-        tcg_gen_xor_i32(TCGV_LOW(ret), TCGV_LOW(arg1), TCGV_LOW(arg2));
-        tcg_gen_xor_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
-    }
+    tcg_gen_op3_i64(INDEX_op_xor, ret, arg1, arg2);
 }
 
 void tcg_gen_shl_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
 {
-    if (TCG_TARGET_REG_BITS == 64) {
-        tcg_gen_op3_i64(INDEX_op_shl, ret, arg1, arg2);
-    } else {
-        gen_helper_shl_i64(ret, arg1, arg2);
-    }
+    tcg_gen_op3_i64(INDEX_op_shl, ret, arg1, arg2);
 }
 
 void tcg_gen_shr_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
 {
-    if (TCG_TARGET_REG_BITS == 64) {
-        tcg_gen_op3_i64(INDEX_op_shr, ret, arg1, arg2);
-    } else {
-        gen_helper_shr_i64(ret, arg1, arg2);
-    }
+    tcg_gen_op3_i64(INDEX_op_shr, ret, arg1, arg2);
 }
 
 void tcg_gen_sar_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
 {
-    if (TCG_TARGET_REG_BITS == 64) {
-        tcg_gen_op3_i64(INDEX_op_sar, ret, arg1, arg2);
-    } else {
-        gen_helper_sar_i64(ret, arg1, arg2);
-    }
+    tcg_gen_op3_i64(INDEX_op_sar, ret, arg1, arg2);
 }
 
 void tcg_gen_mul_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
 {
-    TCGv_i64 t0;
-    TCGv_i32 t1;
-
-    if (TCG_TARGET_REG_BITS == 64) {
-        tcg_gen_op3_i64(INDEX_op_mul, ret, arg1, arg2);
-        return;
-    }
-
-
-    t0 = tcg_temp_ebb_new_i64();
-    t1 = tcg_temp_ebb_new_i32();
-
-    tcg_gen_mulu2_i32(TCGV_LOW(t0), TCGV_HIGH(t0),
-                      TCGV_LOW(arg1), TCGV_LOW(arg2));
-
-    tcg_gen_mul_i32(t1, TCGV_LOW(arg1), TCGV_HIGH(arg2));
-    tcg_gen_add_i32(TCGV_HIGH(t0), TCGV_HIGH(t0), t1);
-    tcg_gen_mul_i32(t1, TCGV_HIGH(arg1), TCGV_LOW(arg2));
-    tcg_gen_add_i32(TCGV_HIGH(t0), TCGV_HIGH(t0), t1);
-
-    tcg_gen_mov_i64(ret, t0);
-    tcg_temp_free_i64(t0);
-    tcg_temp_free_i32(t1);
+    tcg_gen_op3_i64(INDEX_op_mul, ret, arg1, arg2);
 }
 
 void tcg_gen_addi_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
@@ -1678,12 +1499,8 @@ void tcg_gen_addi_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
     /* some cases can be optimized here */
     if (arg2 == 0) {
         tcg_gen_mov_i64(ret, arg1);
-    } else if (TCG_TARGET_REG_BITS == 64) {
-        tcg_gen_add_i64(ret, arg1, tcg_constant_i64(arg2));
     } else {
-        tcg_gen_add2_i32(TCGV_LOW(ret), TCGV_HIGH(ret),
-                         TCGV_LOW(arg1), TCGV_HIGH(arg1),
-                         tcg_constant_i32(arg2), tcg_constant_i32(arg2 >> 32));
+        tcg_gen_add_i64(ret, arg1, tcg_constant_i64(arg2));
     }
 }
 
@@ -1691,12 +1508,8 @@ void tcg_gen_subfi_i64(TCGv_i64 ret, int64_t arg1, TCGv_i64 arg2)
 {
     if (arg1 == 0) {
         tcg_gen_neg_i64(ret, arg2);
-    } else if (TCG_TARGET_REG_BITS == 64) {
-        tcg_gen_sub_i64(ret, tcg_constant_i64(arg1), arg2);
     } else {
-        tcg_gen_sub2_i32(TCGV_LOW(ret), TCGV_HIGH(ret),
-                         tcg_constant_i32(arg1), tcg_constant_i32(arg1 >> 32),
-                         TCGV_LOW(arg2), TCGV_HIGH(arg2));
+        tcg_gen_sub_i64(ret, tcg_constant_i64(arg1), arg2);
     }
 }
 
@@ -1707,23 +1520,11 @@ void tcg_gen_subi_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
 
 void tcg_gen_neg_i64(TCGv_i64 ret, TCGv_i64 arg)
 {
-    if (TCG_TARGET_REG_BITS == 64) {
-        tcg_gen_op2_i64(INDEX_op_neg, ret, arg);
-    } else {
-        TCGv_i32 zero = tcg_constant_i32(0);
-        tcg_gen_sub2_i32(TCGV_LOW(ret), TCGV_HIGH(ret),
-                         zero, zero, TCGV_LOW(arg), TCGV_HIGH(arg));
-    }
+    tcg_gen_op2_i64(INDEX_op_neg, ret, arg);
 }
 
 void tcg_gen_andi_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
 {
-    if (TCG_TARGET_REG_BITS == 32) {
-        tcg_gen_andi_i32(TCGV_LOW(ret), TCGV_LOW(arg1), arg2);
-        tcg_gen_andi_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), arg2 >> 32);
-        return;
-    }
-
     /* Some cases can be optimized here.  */
     switch (arg2) {
     case 0:
@@ -1754,11 +1555,6 @@ void tcg_gen_andi_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
 
 void tcg_gen_ori_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
 {
-    if (TCG_TARGET_REG_BITS == 32) {
-        tcg_gen_ori_i32(TCGV_LOW(ret), TCGV_LOW(arg1), arg2);
-        tcg_gen_ori_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), arg2 >> 32);
-        return;
-    }
     /* Some cases can be optimized here.  */
     if (arg2 == -1) {
         tcg_gen_movi_i64(ret, -1);
@@ -1771,11 +1567,6 @@ void tcg_gen_ori_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
 
 void tcg_gen_xori_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
 {
-    if (TCG_TARGET_REG_BITS == 32) {
-        tcg_gen_xori_i32(TCGV_LOW(ret), TCGV_LOW(arg1), arg2);
-        tcg_gen_xori_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), arg2 >> 32);
-        return;
-    }
     /* Some cases can be optimized here.  */
     if (arg2 == 0) {
         tcg_gen_mov_i64(ret, arg1);
@@ -1788,48 +1579,10 @@ void tcg_gen_xori_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
     }
 }
 
-static inline void tcg_gen_shifti_i64(TCGv_i64 ret, TCGv_i64 arg1,
-                                      unsigned c, bool right, bool arith)
-{
-    tcg_debug_assert(c < 64);
-    if (c == 0) {
-        tcg_gen_mov_i32(TCGV_LOW(ret), TCGV_LOW(arg1));
-        tcg_gen_mov_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1));
-    } else if (c >= 32) {
-        c -= 32;
-        if (right) {
-            if (arith) {
-                tcg_gen_sari_i32(TCGV_LOW(ret), TCGV_HIGH(arg1), c);
-                tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), 31);
-            } else {
-                tcg_gen_shri_i32(TCGV_LOW(ret), TCGV_HIGH(arg1), c);
-                tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
-            }
-        } else {
-            tcg_gen_shli_i32(TCGV_HIGH(ret), TCGV_LOW(arg1), c);
-            tcg_gen_movi_i32(TCGV_LOW(ret), 0);
-        }
-    } else if (right) {
-        tcg_gen_extract2_i32(TCGV_LOW(ret), TCGV_LOW(arg1),
-                             TCGV_HIGH(arg1), c);
-        if (arith) {
-            tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), c);
-        } else {
-            tcg_gen_shri_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), c);
-        }
-    } else {
-        tcg_gen_extract2_i32(TCGV_HIGH(ret), TCGV_LOW(arg1),
-                             TCGV_HIGH(arg1), 32 - c);
-        tcg_gen_shli_i32(TCGV_LOW(ret), TCGV_LOW(arg1), c);
-    }
-}
-
 void tcg_gen_shli_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
 {
     tcg_debug_assert(arg2 >= 0 && arg2 < 64);
-    if (TCG_TARGET_REG_BITS == 32) {
-        tcg_gen_shifti_i64(ret, arg1, arg2, 0, 0);
-    } else if (arg2 == 0) {
+    if (arg2 == 0) {
         tcg_gen_mov_i64(ret, arg1);
     } else {
         tcg_gen_shl_i64(ret, arg1, tcg_constant_i64(arg2));
@@ -1839,9 +1592,7 @@ void tcg_gen_shli_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
 void tcg_gen_shri_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
 {
     tcg_debug_assert(arg2 >= 0 && arg2 < 64);
-    if (TCG_TARGET_REG_BITS == 32) {
-        tcg_gen_shifti_i64(ret, arg1, arg2, 1, 0);
-    } else if (arg2 == 0) {
+    if (arg2 == 0) {
         tcg_gen_mov_i64(ret, arg1);
     } else {
         tcg_gen_shr_i64(ret, arg1, tcg_constant_i64(arg2));
@@ -1851,9 +1602,7 @@ void tcg_gen_shri_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
 void tcg_gen_sari_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
 {
     tcg_debug_assert(arg2 >= 0 && arg2 < 64);
-    if (TCG_TARGET_REG_BITS == 32) {
-        tcg_gen_shifti_i64(ret, arg1, arg2, 1, 1);
-    } else if (arg2 == 0) {
+    if (arg2 == 0) {
         tcg_gen_mov_i64(ret, arg1);
     } else {
         tcg_gen_sar_i64(ret, arg1, tcg_constant_i64(arg2));
@@ -2034,14 +1783,7 @@ void tcg_gen_bswap16_i64(TCGv_i64 ret, TCGv_i64 arg, int flags)
     /* Only one extension flag may be present. */
     tcg_debug_assert(!(flags & TCG_BSWAP_OS) || !(flags & TCG_BSWAP_OZ));
 
-    if (TCG_TARGET_REG_BITS == 32) {
-        tcg_gen_bswap16_i32(TCGV_LOW(ret), TCGV_LOW(arg), flags);
-        if (flags & TCG_BSWAP_OS) {
-            tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31);
-        } else {
-            tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
-        }
-    } else if (tcg_op_supported(INDEX_op_bswap16, TCG_TYPE_I64, 0)) {
+    if (tcg_op_supported(INDEX_op_bswap16, TCG_TYPE_I64, 0)) {
         tcg_gen_op3i_i64(INDEX_op_bswap16, ret, arg, flags);
     } else {
         TCGv_i64 t0 = tcg_temp_ebb_new_i64();
@@ -2084,14 +1826,7 @@ void tcg_gen_bswap32_i64(TCGv_i64 ret, TCGv_i64 arg, int flags)
     /* Only one extension flag may be present. */
     tcg_debug_assert(!(flags & TCG_BSWAP_OS) || !(flags & TCG_BSWAP_OZ));
 
-    if (TCG_TARGET_REG_BITS == 32) {
-        tcg_gen_bswap32_i32(TCGV_LOW(ret), TCGV_LOW(arg));
-        if (flags & TCG_BSWAP_OS) {
-            tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31);
-        } else {
-            tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
-        }
-    } else if (tcg_op_supported(INDEX_op_bswap32, TCG_TYPE_I64, 0)) {
+    if (tcg_op_supported(INDEX_op_bswap32, TCG_TYPE_I64, 0)) {
         tcg_gen_op3i_i64(INDEX_op_bswap32, ret, arg, flags);
     } else {
         TCGv_i64 t0 = tcg_temp_ebb_new_i64();
@@ -2127,18 +1862,7 @@ void tcg_gen_bswap32_i64(TCGv_i64 ret, TCGv_i64 arg, int flags)
  */
 void tcg_gen_bswap64_i64(TCGv_i64 ret, TCGv_i64 arg)
 {
-    if (TCG_TARGET_REG_BITS == 32) {
-        TCGv_i32 t0, t1;
-        t0 = tcg_temp_ebb_new_i32();
-        t1 = tcg_temp_ebb_new_i32();
-
-        tcg_gen_bswap32_i32(t0, TCGV_LOW(arg));
-        tcg_gen_bswap32_i32(t1, TCGV_HIGH(arg));
-        tcg_gen_mov_i32(TCGV_LOW(ret), t1);
-        tcg_gen_mov_i32(TCGV_HIGH(ret), t0);
-        tcg_temp_free_i32(t0);
-        tcg_temp_free_i32(t1);
-    } else if (tcg_op_supported(INDEX_op_bswap64, TCG_TYPE_I64, 0)) {
+    if (tcg_op_supported(INDEX_op_bswap64, TCG_TYPE_I64, 0)) {
         tcg_gen_op3i_i64(INDEX_op_bswap64, ret, arg, 0);
     } else {
         TCGv_i64 t0 = tcg_temp_ebb_new_i64();
@@ -2207,10 +1931,7 @@ void tcg_gen_wswap_i64(TCGv_i64 ret, TCGv_i64 arg)
 
 void tcg_gen_not_i64(TCGv_i64 ret, TCGv_i64 arg)
 {
-    if (TCG_TARGET_REG_BITS == 32) {
-        tcg_gen_not_i32(TCGV_LOW(ret), TCGV_LOW(arg));
-        tcg_gen_not_i32(TCGV_HIGH(ret), TCGV_HIGH(arg));
-    } else if (tcg_op_supported(INDEX_op_not, TCG_TYPE_I64, 0)) {
+    if (tcg_op_supported(INDEX_op_not, TCG_TYPE_I64, 0)) {
         tcg_gen_op2_i64(INDEX_op_not, ret, arg);
     } else {
         tcg_gen_xori_i64(ret, arg, -1);
@@ -2219,10 +1940,7 @@ void tcg_gen_not_i64(TCGv_i64 ret, TCGv_i64 arg)
 
 void tcg_gen_andc_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
 {
-    if (TCG_TARGET_REG_BITS == 32) {
-        tcg_gen_andc_i32(TCGV_LOW(ret), TCGV_LOW(arg1), TCGV_LOW(arg2));
-        tcg_gen_andc_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
-    } else if (tcg_op_supported(INDEX_op_andc, TCG_TYPE_I64, 0)) {
+    if (tcg_op_supported(INDEX_op_andc, TCG_TYPE_I64, 0)) {
         tcg_gen_op3_i64(INDEX_op_andc, ret, arg1, arg2);
     } else {
         TCGv_i64 t0 = tcg_temp_ebb_new_i64();
@@ -2234,10 +1952,7 @@ void tcg_gen_andc_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
 
 void tcg_gen_eqv_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
 {
-    if (TCG_TARGET_REG_BITS == 32) {
-        tcg_gen_eqv_i32(TCGV_LOW(ret), TCGV_LOW(arg1), TCGV_LOW(arg2));
-        tcg_gen_eqv_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
-    } else if (tcg_op_supported(INDEX_op_eqv, TCG_TYPE_I64, 0)) {
+    if (tcg_op_supported(INDEX_op_eqv, TCG_TYPE_I64, 0)) {
         tcg_gen_op3_i64(INDEX_op_eqv, ret, arg1, arg2);
     } else {
         tcg_gen_xor_i64(ret, arg1, arg2);
@@ -2247,10 +1962,7 @@ void tcg_gen_eqv_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
 
 void tcg_gen_nand_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
 {
-    if (TCG_TARGET_REG_BITS == 32) {
-        tcg_gen_nand_i32(TCGV_LOW(ret), TCGV_LOW(arg1), TCGV_LOW(arg2));
-        tcg_gen_nand_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
-    } else if (tcg_op_supported(INDEX_op_nand, TCG_TYPE_I64, 0)) {
+    if (tcg_op_supported(INDEX_op_nand, TCG_TYPE_I64, 0)) {
         tcg_gen_op3_i64(INDEX_op_nand, ret, arg1, arg2);
     } else {
         tcg_gen_and_i64(ret, arg1, arg2);
@@ -2260,10 +1972,7 @@ void tcg_gen_nand_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
 
 void tcg_gen_nor_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
 {
-    if (TCG_TARGET_REG_BITS == 32) {
-        tcg_gen_nor_i32(TCGV_LOW(ret), TCGV_LOW(arg1), TCGV_LOW(arg2));
-        tcg_gen_nor_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
-    } else if (tcg_op_supported(INDEX_op_nor, TCG_TYPE_I64, 0)) {
+    if (tcg_op_supported(INDEX_op_nor, TCG_TYPE_I64, 0)) {
         tcg_gen_op3_i64(INDEX_op_nor, ret, arg1, arg2);
     } else {
         tcg_gen_or_i64(ret, arg1, arg2);
@@ -2273,10 +1982,7 @@ void tcg_gen_nor_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
 
 void tcg_gen_orc_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
 {
-    if (TCG_TARGET_REG_BITS == 32) {
-        tcg_gen_orc_i32(TCGV_LOW(ret), TCGV_LOW(arg1), TCGV_LOW(arg2));
-        tcg_gen_orc_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
-    } else if (tcg_op_supported(INDEX_op_orc, TCG_TYPE_I64, 0)) {
+    if (tcg_op_supported(INDEX_op_orc, TCG_TYPE_I64, 0)) {
         tcg_gen_op3_i64(INDEX_op_orc, ret, arg1, arg2);
     } else {
         TCGv_i64 t0 = tcg_temp_ebb_new_i64();
@@ -2297,18 +2003,7 @@ void tcg_gen_clz_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
 
 void tcg_gen_clzi_i64(TCGv_i64 ret, TCGv_i64 arg1, uint64_t arg2)
 {
-    if (TCG_TARGET_REG_BITS == 32
-        && arg2 <= 0xffffffffu
-        && tcg_op_supported(INDEX_op_clz, TCG_TYPE_I32, 0)) {
-        TCGv_i32 t = tcg_temp_ebb_new_i32();
-        tcg_gen_clzi_i32(t, TCGV_LOW(arg1), arg2 - 32);
-        tcg_gen_addi_i32(t, t, 32);
-        tcg_gen_clz_i32(TCGV_LOW(ret), TCGV_HIGH(arg1), t);
-        tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
-        tcg_temp_free_i32(t);
-    } else {
-        tcg_gen_clz_i64(ret, arg1, tcg_constant_i64(arg2));
-    }
+    tcg_gen_clz_i64(ret, arg1, tcg_constant_i64(arg2));
 }
 
 void tcg_gen_ctz_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
@@ -2342,18 +2037,9 @@ void tcg_gen_ctz_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
 
 void tcg_gen_ctzi_i64(TCGv_i64 ret, TCGv_i64 arg1, uint64_t arg2)
 {
-    if (TCG_TARGET_REG_BITS == 32
-        && arg2 <= 0xffffffffu
-        && tcg_op_supported(INDEX_op_ctz, TCG_TYPE_I32, 0)) {
-        TCGv_i32 t32 = tcg_temp_ebb_new_i32();
-        tcg_gen_ctzi_i32(t32, TCGV_HIGH(arg1), arg2 - 32);
-        tcg_gen_addi_i32(t32, t32, 32);
-        tcg_gen_ctz_i32(TCGV_LOW(ret), TCGV_LOW(arg1), t32);
-        tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
-        tcg_temp_free_i32(t32);
-    } else if (arg2 == 64
-               && !tcg_op_supported(INDEX_op_ctz, TCG_TYPE_I64, 0)
-               && tcg_op_supported(INDEX_op_ctpop, TCG_TYPE_I64, 0)) {
+    if (arg2 == 64
+        && !tcg_op_supported(INDEX_op_ctz, TCG_TYPE_I64, 0)
+        && tcg_op_supported(INDEX_op_ctpop, TCG_TYPE_I64, 0)) {
         /* This equivalence has the advantage of not requiring a fixup.  */
         TCGv_i64 t = tcg_temp_ebb_new_i64();
         tcg_gen_subi_i64(t, arg1, 1);
@@ -2381,21 +2067,11 @@ void tcg_gen_clrsb_i64(TCGv_i64 ret, TCGv_i64 arg)
 
 void tcg_gen_ctpop_i64(TCGv_i64 ret, TCGv_i64 arg1)
 {
-    if (TCG_TARGET_REG_BITS == 64) {
-        if (tcg_op_supported(INDEX_op_ctpop, TCG_TYPE_I64, 0)) {
-            tcg_gen_op2_i64(INDEX_op_ctpop, ret, arg1);
-            return;
-        }
+    if (tcg_op_supported(INDEX_op_ctpop, TCG_TYPE_I64, 0)) {
+        tcg_gen_op2_i64(INDEX_op_ctpop, ret, arg1);
     } else {
-        if (tcg_op_supported(INDEX_op_ctpop, TCG_TYPE_I32, 0)) {
-            tcg_gen_ctpop_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1));
-            tcg_gen_ctpop_i32(TCGV_LOW(ret), TCGV_LOW(arg1));
-            tcg_gen_add_i32(TCGV_LOW(ret), TCGV_LOW(ret), TCGV_HIGH(ret));
-            tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
-            return;
-        }
+        gen_helper_ctpop_i64(ret, arg1);
     }
-    gen_helper_ctpop_i64(ret, arg1);
 }
 
 void tcg_gen_rotl_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
@@ -2485,24 +2161,9 @@ void tcg_gen_deposit_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2,
         return;
     }
 
-    if (TCG_TARGET_REG_BITS == 64) {
-        if (TCG_TARGET_deposit_valid(TCG_TYPE_I64, ofs, len)) {
-            tcg_gen_op5ii_i64(INDEX_op_deposit, ret, arg1, arg2, ofs, len);
-            return;
-        }
-    } else {
-        if (ofs >= 32) {
-            tcg_gen_deposit_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1),
-                                TCGV_LOW(arg2), ofs - 32, len);
-            tcg_gen_mov_i32(TCGV_LOW(ret), TCGV_LOW(arg1));
-            return;
-        }
-        if (ofs + len <= 32) {
-            tcg_gen_deposit_i32(TCGV_LOW(ret), TCGV_LOW(arg1),
-                                TCGV_LOW(arg2), ofs, len);
-            tcg_gen_mov_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1));
-            return;
-        }
+    if (TCG_TARGET_deposit_valid(TCG_TYPE_I64, ofs, len)) {
+        tcg_gen_op5ii_i64(INDEX_op_deposit, ret, arg1, arg2, ofs, len);
+        return;
     }
 
     t1 = tcg_temp_ebb_new_i64();
@@ -2545,24 +2206,10 @@ void tcg_gen_deposit_z_i64(TCGv_i64 ret, TCGv_i64 arg,
         tcg_gen_shli_i64(ret, arg, ofs);
     } else if (ofs == 0) {
         tcg_gen_andi_i64(ret, arg, (1ull << len) - 1);
-    } else if (TCG_TARGET_REG_BITS == 64 &&
-               TCG_TARGET_deposit_valid(TCG_TYPE_I64, ofs, len)) {
+    } else if (TCG_TARGET_deposit_valid(TCG_TYPE_I64, ofs, len)) {
         TCGv_i64 zero = tcg_constant_i64(0);
         tcg_gen_op5ii_i64(INDEX_op_deposit, ret, zero, arg, ofs, len);
     } else {
-        if (TCG_TARGET_REG_BITS == 32) {
-            if (ofs >= 32) {
-                tcg_gen_deposit_z_i32(TCGV_HIGH(ret), TCGV_LOW(arg),
-                                      ofs - 32, len);
-                tcg_gen_movi_i32(TCGV_LOW(ret), 0);
-                return;
-            }
-            if (ofs + len <= 32) {
-                tcg_gen_deposit_z_i32(TCGV_LOW(ret), TCGV_LOW(arg), ofs, len);
-                tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
-                return;
-            }
-        }
         /*
          * To help two-operand hosts we prefer to zero-extend first,
          * which allows ARG to stay live.
@@ -2597,32 +2244,6 @@ void tcg_gen_extract_i64(TCGv_i64 ret, TCGv_i64 arg,
         return;
     }
 
-    if (TCG_TARGET_REG_BITS == 32) {
-        /* Look for a 32-bit extract within one of the two words.  */
-        if (ofs >= 32) {
-            tcg_gen_extract_i32(TCGV_LOW(ret), TCGV_HIGH(arg), ofs - 32, len);
-            tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
-            return;
-        }
-        if (ofs + len <= 32) {
-            tcg_gen_extract_i32(TCGV_LOW(ret), TCGV_LOW(arg), ofs, len);
-            tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
-            return;
-        }
-
-        /* The field is split across two words. */
-        tcg_gen_extract2_i32(TCGV_LOW(ret), TCGV_LOW(arg),
-                             TCGV_HIGH(arg), ofs);
-        if (len <= 32) {
-            tcg_gen_extract_i32(TCGV_LOW(ret), TCGV_LOW(ret), 0, len);
-            tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
-        } else {
-            tcg_gen_extract_i32(TCGV_HIGH(ret), TCGV_HIGH(arg),
-                                ofs, len - 32);
-        }
-        return;
-    }
-
     if (TCG_TARGET_extract_valid(TCG_TYPE_I64, ofs, len)) {
         tcg_gen_op4ii_i64(INDEX_op_extract, ret, arg, ofs, len);
         return;
@@ -2668,38 +2289,6 @@ void tcg_gen_sextract_i64(TCGv_i64 ret, TCGv_i64 arg,
         return;
     }
 
-    if (TCG_TARGET_REG_BITS == 32) {
-        /* Look for a 32-bit extract within one of the two words.  */
-        if (ofs >= 32) {
-            tcg_gen_sextract_i32(TCGV_LOW(ret), TCGV_HIGH(arg), ofs - 32, len);
-        } else if (ofs + len <= 32) {
-            tcg_gen_sextract_i32(TCGV_LOW(ret), TCGV_LOW(arg), ofs, len);
-        } else if (ofs == 0) {
-            tcg_gen_mov_i32(TCGV_LOW(ret), TCGV_LOW(arg));
-            tcg_gen_sextract_i32(TCGV_HIGH(ret), TCGV_HIGH(arg), 0, len - 32);
-            return;
-        } else if (len > 32) {
-            TCGv_i32 t = tcg_temp_ebb_new_i32();
-            /* Extract the bits for the high word normally.  */
-            tcg_gen_sextract_i32(t, TCGV_HIGH(arg), ofs + 32, len - 32);
-            /* Shift the field down for the low part.  */
-            tcg_gen_shri_i64(ret, arg, ofs);
-            /* Overwrite the shift into the high part.  */
-            tcg_gen_mov_i32(TCGV_HIGH(ret), t);
-            tcg_temp_free_i32(t);
-            return;
-        } else {
-            /* Shift the field down for the low part, such that the
-               field sits at the MSB.  */
-            tcg_gen_shri_i64(ret, arg, ofs + len - 32);
-            /* Shift the field down from the MSB, sign extending.  */
-            tcg_gen_sari_i32(TCGV_LOW(ret), TCGV_LOW(ret), 32 - len);
-        }
-        /* Sign-extend the field from 32 bits.  */
-        tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31);
-        return;
-    }
-
     if (TCG_TARGET_sextract_valid(TCG_TYPE_I64, ofs, len)) {
         tcg_gen_op4ii_i64(INDEX_op_sextract, ret, arg, ofs, len);
         return;
@@ -2763,20 +2352,8 @@ void tcg_gen_add2_i64(TCGv_i64 rl, TCGv_i64 rh, TCGv_i64 al,
     if (tcg_op_supported(INDEX_op_addci, TCG_TYPE_REG, 0)) {
         TCGv_i64 t0 = tcg_temp_ebb_new_i64();
 
-        if (TCG_TARGET_REG_BITS == 32) {
-            tcg_gen_op3_i32(INDEX_op_addco, TCGV_LOW(t0),
-                            TCGV_LOW(al), TCGV_LOW(bl));
-            tcg_gen_op3_i32(INDEX_op_addcio, TCGV_HIGH(t0),
-                            TCGV_HIGH(al), TCGV_HIGH(bl));
-            tcg_gen_op3_i32(INDEX_op_addcio, TCGV_LOW(rh),
-                            TCGV_LOW(ah), TCGV_LOW(bh));
-            tcg_gen_op3_i32(INDEX_op_addci, TCGV_HIGH(rh),
-                            TCGV_HIGH(ah), TCGV_HIGH(bh));
-        } else {
-            tcg_gen_op3_i64(INDEX_op_addco, t0, al, bl);
-            tcg_gen_op3_i64(INDEX_op_addci, rh, ah, bh);
-        }
-
+        tcg_gen_op3_i64(INDEX_op_addco, t0, al, bl);
+        tcg_gen_op3_i64(INDEX_op_addci, rh, ah, bh);
         tcg_gen_mov_i64(rl, t0);
         tcg_temp_free_i64(t0);
     } else {
@@ -2795,68 +2372,27 @@ void tcg_gen_add2_i64(TCGv_i64 rl, TCGv_i64 rh, TCGv_i64 al,
 void tcg_gen_addcio_i64(TCGv_i64 r, TCGv_i64 co,
                         TCGv_i64 a, TCGv_i64 b, TCGv_i64 ci)
 {
-    if (TCG_TARGET_REG_BITS == 64) {
-        if (tcg_op_supported(INDEX_op_addci, TCG_TYPE_I64, 0)) {
-            TCGv_i64 discard = tcg_temp_ebb_new_i64();
-            TCGv_i64 zero = tcg_constant_i64(0);
-            TCGv_i64 mone = tcg_constant_i64(-1);
+    if (tcg_op_supported(INDEX_op_addci, TCG_TYPE_I64, 0)) {
+        TCGv_i64 discard = tcg_temp_ebb_new_i64();
+        TCGv_i64 zero = tcg_constant_i64(0);
+        TCGv_i64 mone = tcg_constant_i64(-1);
 
-            tcg_gen_op3_i64(INDEX_op_addco, discard, ci, mone);
-            tcg_gen_op3_i64(INDEX_op_addcio, r, a, b);
-            tcg_gen_op3_i64(INDEX_op_addci, co, zero, zero);
-            tcg_temp_free_i64(discard);
-        } else {
-            TCGv_i64 t0 = tcg_temp_ebb_new_i64();
-            TCGv_i64 t1 = tcg_temp_ebb_new_i64();
-
-            tcg_gen_add_i64(t0, a, b);
-            tcg_gen_setcond_i64(TCG_COND_LTU, t1, t0, a);
-            tcg_gen_add_i64(r, t0, ci);
-            tcg_gen_setcond_i64(TCG_COND_LTU, t0, r, t0);
-            tcg_gen_or_i64(co, t0, t1);
-
-            tcg_temp_free_i64(t0);
-            tcg_temp_free_i64(t1);
-        }
+        tcg_gen_op3_i64(INDEX_op_addco, discard, ci, mone);
+        tcg_gen_op3_i64(INDEX_op_addcio, r, a, b);
+        tcg_gen_op3_i64(INDEX_op_addci, co, zero, zero);
+        tcg_temp_free_i64(discard);
     } else {
-        if (tcg_op_supported(INDEX_op_addci, TCG_TYPE_I32, 0)) {
-            TCGv_i32 discard = tcg_temp_ebb_new_i32();
-            TCGv_i32 zero = tcg_constant_i32(0);
-            TCGv_i32 mone = tcg_constant_i32(-1);
+        TCGv_i64 t0 = tcg_temp_ebb_new_i64();
+        TCGv_i64 t1 = tcg_temp_ebb_new_i64();
 
-            tcg_gen_op3_i32(INDEX_op_addco, discard, TCGV_LOW(ci), mone);
-            tcg_gen_op3_i32(INDEX_op_addcio, discard, TCGV_HIGH(ci), mone);
-            tcg_gen_op3_i32(INDEX_op_addcio, TCGV_LOW(r),
-                            TCGV_LOW(a), TCGV_LOW(b));
-            tcg_gen_op3_i32(INDEX_op_addcio, TCGV_HIGH(r),
-                            TCGV_HIGH(a), TCGV_HIGH(b));
-            tcg_gen_op3_i32(INDEX_op_addci, TCGV_LOW(co), zero, zero);
-            tcg_temp_free_i32(discard);
-        } else {
-            TCGv_i32 t0 = tcg_temp_ebb_new_i32();
-            TCGv_i32 c0 = tcg_temp_ebb_new_i32();
-            TCGv_i32 c1 = tcg_temp_ebb_new_i32();
+        tcg_gen_add_i64(t0, a, b);
+        tcg_gen_setcond_i64(TCG_COND_LTU, t1, t0, a);
+        tcg_gen_add_i64(r, t0, ci);
+        tcg_gen_setcond_i64(TCG_COND_LTU, t0, r, t0);
+        tcg_gen_or_i64(co, t0, t1);
 
-            tcg_gen_or_i32(c1, TCGV_LOW(ci), TCGV_HIGH(ci));
-            tcg_gen_setcondi_i32(TCG_COND_NE, c1, c1, 0);
-
-            tcg_gen_add_i32(t0, TCGV_LOW(a), TCGV_LOW(b));
-            tcg_gen_setcond_i32(TCG_COND_LTU, c0, t0, TCGV_LOW(a));
-            tcg_gen_add_i32(TCGV_LOW(r), t0, c1);
-            tcg_gen_setcond_i32(TCG_COND_LTU, c1, TCGV_LOW(r), c1);
-            tcg_gen_or_i32(c1, c1, c0);
-
-            tcg_gen_add_i32(t0, TCGV_HIGH(a), TCGV_HIGH(b));
-            tcg_gen_setcond_i32(TCG_COND_LTU, c0, t0, TCGV_HIGH(a));
-            tcg_gen_add_i32(TCGV_HIGH(r), t0, c1);
-            tcg_gen_setcond_i32(TCG_COND_LTU, c1, TCGV_HIGH(r), c1);
-            tcg_gen_or_i32(TCGV_LOW(co), c0, c1);
-
-            tcg_temp_free_i32(t0);
-            tcg_temp_free_i32(c0);
-            tcg_temp_free_i32(c1);
-        }
-        tcg_gen_movi_i32(TCGV_HIGH(co), 0);
+        tcg_temp_free_i64(t0);
+        tcg_temp_free_i64(t1);
     }
 }
 
@@ -2866,20 +2402,8 @@ void tcg_gen_sub2_i64(TCGv_i64 rl, TCGv_i64 rh, TCGv_i64 al,
     if (tcg_op_supported(INDEX_op_subbi, TCG_TYPE_REG, 0)) {
         TCGv_i64 t0 = tcg_temp_ebb_new_i64();
 
-        if (TCG_TARGET_REG_BITS == 32) {
-            tcg_gen_op3_i32(INDEX_op_subbo, TCGV_LOW(t0),
-                            TCGV_LOW(al), TCGV_LOW(bl));
-            tcg_gen_op3_i32(INDEX_op_subbio, TCGV_HIGH(t0),
-                            TCGV_HIGH(al), TCGV_HIGH(bl));
-            tcg_gen_op3_i32(INDEX_op_subbio, TCGV_LOW(rh),
-                            TCGV_LOW(ah), TCGV_LOW(bh));
-            tcg_gen_op3_i32(INDEX_op_subbi, TCGV_HIGH(rh),
-                            TCGV_HIGH(ah), TCGV_HIGH(bh));
-        } else {
-            tcg_gen_op3_i64(INDEX_op_subbo, t0, al, bl);
-            tcg_gen_op3_i64(INDEX_op_subbi, rh, ah, bh);
-        }
-
+        tcg_gen_op3_i64(INDEX_op_subbo, t0, al, bl);
+        tcg_gen_op3_i64(INDEX_op_subbi, rh, ah, bh);
         tcg_gen_mov_i64(rl, t0);
         tcg_temp_free_i64(t0);
     } else {
@@ -3002,57 +2526,32 @@ void tcg_gen_abs_i64(TCGv_i64 ret, TCGv_i64 a)
 
 void tcg_gen_extrl_i64_i32(TCGv_i32 ret, TCGv_i64 arg)
 {
-    if (TCG_TARGET_REG_BITS == 32) {
-        tcg_gen_mov_i32(ret, TCGV_LOW(arg));
-    } else {
-        tcg_gen_op2(INDEX_op_extrl_i64_i32, TCG_TYPE_I32,
-                    tcgv_i32_arg(ret), tcgv_i64_arg(arg));
-    }
+    tcg_gen_op2(INDEX_op_extrl_i64_i32, TCG_TYPE_I32,
+                tcgv_i32_arg(ret), tcgv_i64_arg(arg));
 }
 
 void tcg_gen_extrh_i64_i32(TCGv_i32 ret, TCGv_i64 arg)
 {
-    if (TCG_TARGET_REG_BITS == 32) {
-        tcg_gen_mov_i32(ret, TCGV_HIGH(arg));
-    } else {
-        tcg_gen_op2(INDEX_op_extrh_i64_i32, TCG_TYPE_I32,
-                    tcgv_i32_arg(ret), tcgv_i64_arg(arg));
-    }
+    tcg_gen_op2(INDEX_op_extrh_i64_i32, TCG_TYPE_I32,
+                tcgv_i32_arg(ret), tcgv_i64_arg(arg));
 }
 
 void tcg_gen_extu_i32_i64(TCGv_i64 ret, TCGv_i32 arg)
 {
-    if (TCG_TARGET_REG_BITS == 32) {
-        tcg_gen_mov_i32(TCGV_LOW(ret), arg);
-        tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
-    } else {
-        tcg_gen_op2(INDEX_op_extu_i32_i64, TCG_TYPE_I64,
-                    tcgv_i64_arg(ret), tcgv_i32_arg(arg));
-    }
+    tcg_gen_op2(INDEX_op_extu_i32_i64, TCG_TYPE_I64,
+                tcgv_i64_arg(ret), tcgv_i32_arg(arg));
 }
 
 void tcg_gen_ext_i32_i64(TCGv_i64 ret, TCGv_i32 arg)
 {
-    if (TCG_TARGET_REG_BITS == 32) {
-        tcg_gen_mov_i32(TCGV_LOW(ret), arg);
-        tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31);
-    } else {
-        tcg_gen_op2(INDEX_op_ext_i32_i64, TCG_TYPE_I64,
-                    tcgv_i64_arg(ret), tcgv_i32_arg(arg));
-    }
+    tcg_gen_op2(INDEX_op_ext_i32_i64, TCG_TYPE_I64,
+                tcgv_i64_arg(ret), tcgv_i32_arg(arg));
 }
 
 void tcg_gen_concat_i32_i64(TCGv_i64 dest, TCGv_i32 low, TCGv_i32 high)
 {
-    TCGv_i64 tmp;
+    TCGv_i64 tmp = tcg_temp_ebb_new_i64();
 
-    if (TCG_TARGET_REG_BITS == 32) {
-        tcg_gen_mov_i32(TCGV_LOW(dest), low);
-        tcg_gen_mov_i32(TCGV_HIGH(dest), high);
-        return;
-    }
-
-    tmp = tcg_temp_ebb_new_i64();
     /* These extensions are only needed for type correctness.
        We may be able to do better given target specific information.  */
     tcg_gen_extu_i32_i64(tmp, high);
@@ -3070,13 +2569,8 @@ void tcg_gen_concat_i32_i64(TCGv_i64 dest, TCGv_i32 low, TCGv_i32 high)
 
 void tcg_gen_extr_i64_i32(TCGv_i32 lo, TCGv_i32 hi, TCGv_i64 arg)
 {
-    if (TCG_TARGET_REG_BITS == 32) {
-        tcg_gen_mov_i32(lo, TCGV_LOW(arg));
-        tcg_gen_mov_i32(hi, TCGV_HIGH(arg));
-    } else {
-        tcg_gen_extrl_i64_i32(lo, arg);
-        tcg_gen_extrh_i64_i32(hi, arg);
-    }
+    tcg_gen_extrl_i64_i32(lo, arg);
+    tcg_gen_extrh_i64_i32(hi, arg);
 }
 
 void tcg_gen_extr32_i64(TCGv_i64 lo, TCGv_i64 hi, TCGv_i64 arg)
Signature · 1 line
2.43.0
#44 lore raw

PATCH v2 33/58 tcg: Drop TCG_TARGET_REG_BITS tests in tcg-op-gvec.c

In reply to Richard Henderson
---
 tcg/tcg-op-gvec.c | 49 +++++++++++++++++++++++------------------------
 1 file changed, 24 insertions(+), 25 deletions(-)
tcg/tcg-op-gvec.c +24 -25
index 2cfc7e9409..bc323e2500 100644
@@ -586,12 +586,11 @@ static void do_dup(unsigned vece, TCGv_ptr dbase, uint32_t dofs,
         }
     }
 
-    /* Implement inline with a vector type, if possible.
-     * Prefer integer when 64-bit host and no variable dup.
+    /*
+     * Implement inline with a vector type, if possible;
+     * prefer_i64 with 64-bit variable dup.
      */
-    type = choose_vector_type(NULL, vece, oprsz,
-                              (TCG_TARGET_REG_BITS == 64 && in_32 == NULL
-                               && (in_64 == NULL || vece == MO_64)));
+    type = choose_vector_type(NULL, vece, oprsz, vece == MO_64 && in_64);
     if (type != 0) {
         TCGv_vec t_vec = tcg_temp_new_vec(type);
 
@@ -612,11 +611,11 @@ static void do_dup(unsigned vece, TCGv_ptr dbase, uint32_t dofs,
         t_32 = NULL;
 
         if (in_32) {
-            /* We are given a 32-bit variable input.  For a 64-bit host,
-               use a 64-bit operation unless the 32-bit operation would
-               be simple enough.  */
-            if (TCG_TARGET_REG_BITS == 64
-                && (vece != MO_32 || !check_size_impl(oprsz, 4))) {
+            /*
+             * We are given a 32-bit variable input.  Use a 64-bit operation
+             * unless the 32-bit operation would be simple enough.
+             */
+            if (vece != MO_32 || !check_size_impl(oprsz, 4)) {
                 t_64 = tcg_temp_ebb_new_i64();
                 tcg_gen_extu_i32_i64(t_64, in_32);
                 tcg_gen_dup_i64(vece, t_64, t_64);
@@ -629,14 +628,16 @@ static void do_dup(unsigned vece, TCGv_ptr dbase, uint32_t dofs,
             t_64 = tcg_temp_ebb_new_i64();
             tcg_gen_dup_i64(vece, t_64, in_64);
         } else {
-            /* We are given a constant input.  */
-            /* For 64-bit hosts, use 64-bit constants for "simple" constants
-               or when we'd need too many 32-bit stores, or when a 64-bit
-               constant is really required.  */
+            /*
+             * We are given a constant input.
+             * Use 64-bit constants for "simple" constants or when we'd
+             * need too many 32-bit stores, or when a 64-bit constant
+             * is really required.
+             */
             if (vece == MO_64
-                || (TCG_TARGET_REG_BITS == 64
-                    && (in_c == 0 || in_c == -1
-                        || !check_size_impl(oprsz, 4)))) {
+                || in_c == 0
+                || in_c == -1
+                || !check_size_impl(oprsz, 4)) {
                 t_64 = tcg_constant_i64(in_c);
             } else {
                 t_32 = tcg_constant_i32(in_c);
@@ -3872,12 +3873,11 @@ void tcg_gen_gvec_cmp(TCGCond cond, unsigned vece, uint32_t dofs,
     }
 
     /*
-     * Implement inline with a vector type, if possible.
-     * Prefer integer when 64-bit host and 64-bit comparison.
+     * Implement inline with a vector type, if possible;
+     * prefer_i64 for a 64-bit comparison.
      */
     hold_list = tcg_swap_vecop_list(cmp_list);
-    type = choose_vector_type(cmp_list, vece, oprsz,
-                              TCG_TARGET_REG_BITS == 64 && vece == MO_64);
+    type = choose_vector_type(cmp_list, vece, oprsz, vece == MO_64);
     switch (type) {
     case TCG_TYPE_V256:
         /* Recall that ARM SVE allows vector sizes that are not a
@@ -3992,11 +3992,10 @@ void tcg_gen_gvec_cmps(TCGCond cond, unsigned vece, uint32_t dofs,
     }
 
     /*
-     * Implement inline with a vector type, if possible.
-     * Prefer integer when 64-bit host and 64-bit comparison.
+     * Implement inline with a vector type, if possible;
+     * prefer_i64 for a 64-bit comparison.
      */
-    type = choose_vector_type(cmp_list, vece, oprsz,
-                              TCG_TARGET_REG_BITS == 64 && vece == MO_64);
+    type = choose_vector_type(cmp_list, vece, oprsz, vece == MO_64);
     if (type != 0) {
         const TCGOpcode *hold_list = tcg_swap_vecop_list(cmp_list);
         TCGv_vec t_vec = tcg_temp_new_vec(type);
Signature · 1 line
2.43.0
#45 lore raw

PATCH v2 34/58 tcg: Drop TCG_TARGET_REG_BITS tests in tcg-op-ldst.c

In reply to Richard Henderson
---
 tcg/tcg-op-ldst.c | 113 +++++++++++-----------------------------------
 1 file changed, 27 insertions(+), 86 deletions(-)
tcg/tcg-op-ldst.c +27 -86
index 7716c3ad7c..55bfbf3a20 100644
@@ -106,24 +106,12 @@ static void gen_ldst2(TCGOpcode opc, TCGType type, TCGTemp *vl, TCGTemp *vh,
 
 static void gen_ld_i64(TCGv_i64 v, TCGTemp *addr, MemOpIdx oi)
 {
-    if (TCG_TARGET_REG_BITS == 32) {
-        gen_ldst2(INDEX_op_qemu_ld2, TCG_TYPE_I64,
-                  tcgv_i32_temp(TCGV_LOW(v)), tcgv_i32_temp(TCGV_HIGH(v)),
-                  addr, oi);
-    } else {
-        gen_ldst1(INDEX_op_qemu_ld, TCG_TYPE_I64, tcgv_i64_temp(v), addr, oi);
-    }
+    gen_ldst1(INDEX_op_qemu_ld, TCG_TYPE_I64, tcgv_i64_temp(v), addr, oi);
 }
 
 static void gen_st_i64(TCGv_i64 v, TCGTemp *addr, MemOpIdx oi)
 {
-    if (TCG_TARGET_REG_BITS == 32) {
-        gen_ldst2(INDEX_op_qemu_st2, TCG_TYPE_I64,
-                  tcgv_i32_temp(TCGV_LOW(v)), tcgv_i32_temp(TCGV_HIGH(v)),
-                  addr, oi);
-    } else {
-        gen_ldst1(INDEX_op_qemu_st, TCG_TYPE_I64, tcgv_i64_temp(v), addr, oi);
-    }
+    gen_ldst1(INDEX_op_qemu_st, TCG_TYPE_I64, tcgv_i64_temp(v), addr, oi);
 }
 
 static void tcg_gen_req_mo(TCGBar type)
@@ -143,7 +131,7 @@ static TCGTemp *tci_extend_addr(TCGTemp *addr)
      * Compare to the extension performed by tcg_out_{ld,st}_helper_args
      * for native code generation.
      */
-    if (TCG_TARGET_REG_BITS == 64 && tcg_ctx->addr_type == TCG_TYPE_I32) {
+    if (tcg_ctx->addr_type == TCG_TYPE_I32) {
         TCGv_i64 temp = tcg_temp_ebb_new_i64();
         tcg_gen_extu_i32_i64(temp, temp_tcgv_i32(addr));
         return tcgv_i64_temp(temp);
@@ -356,16 +344,6 @@ static void tcg_gen_qemu_ld_i64_int(TCGv_i64 val, TCGTemp *addr,
     TCGv_i64 copy_addr;
     TCGTemp *addr_new;
 
-    if (TCG_TARGET_REG_BITS == 32 && (memop & MO_SIZE) < MO_64) {
-        tcg_gen_qemu_ld_i32_int(TCGV_LOW(val), addr, idx, memop);
-        if (memop & MO_SIGN) {
-            tcg_gen_sari_i32(TCGV_HIGH(val), TCGV_LOW(val), 31);
-        } else {
-            tcg_gen_movi_i32(TCGV_HIGH(val), 0);
-        }
-        return;
-    }
-
     tcg_gen_req_mo(TCG_MO_LD_LD | TCG_MO_ST_LD);
     orig_memop = memop = tcg_canonicalize_memop(memop, 1, 0);
     orig_oi = oi = make_memop_idx(memop, idx);
@@ -421,11 +399,6 @@ static void tcg_gen_qemu_st_i64_int(TCGv_i64 val, TCGTemp *addr,
     MemOpIdx orig_oi, oi;
     TCGTemp *addr_new;
 
-    if (TCG_TARGET_REG_BITS == 32 && (memop & MO_SIZE) < MO_64) {
-        tcg_gen_qemu_st_i32_int(TCGV_LOW(val), addr, idx, memop);
-        return;
-    }
-
     tcg_gen_req_mo(TCG_MO_LD_ST | TCG_MO_ST_ST);
     memop = tcg_canonicalize_memop(memop, 1, 1);
     orig_oi = oi = make_memop_idx(memop, idx);
@@ -577,7 +550,7 @@ static void tcg_gen_qemu_ld_i128_int(TCGv_i128 val, TCGTemp *addr,
     orig_oi = make_memop_idx(memop, idx);
 
     /* TODO: For now, force 32-bit hosts to use the helper. */
-    if (TCG_TARGET_HAS_qemu_ldst_i128 && TCG_TARGET_REG_BITS == 64) {
+    if (TCG_TARGET_HAS_qemu_ldst_i128) {
         TCGv_i64 lo, hi;
         bool need_bswap = false;
         MemOpIdx oi = orig_oi;
@@ -691,7 +664,7 @@ static void tcg_gen_qemu_st_i128_int(TCGv_i128 val, TCGTemp *addr,
 
     /* TODO: For now, force 32-bit hosts to use the helper. */
 
-    if (TCG_TARGET_HAS_qemu_ldst_i128 && TCG_TARGET_REG_BITS == 64) {
+    if (TCG_TARGET_HAS_qemu_ldst_i128) {
         TCGv_i64 lo, hi;
         MemOpIdx oi = orig_oi;
         bool need_bswap = false;
@@ -950,17 +923,6 @@ static void tcg_gen_nonatomic_cmpxchg_i64_int(TCGv_i64 retv, TCGTemp *addr,
 {
     TCGv_i64 t1, t2;
 
-    if (TCG_TARGET_REG_BITS == 32 && (memop & MO_SIZE) < MO_64) {
-        tcg_gen_nonatomic_cmpxchg_i32_int(TCGV_LOW(retv), addr, TCGV_LOW(cmpv),
-                                          TCGV_LOW(newv), idx, memop);
-        if (memop & MO_SIGN) {
-            tcg_gen_sari_i32(TCGV_HIGH(retv), TCGV_LOW(retv), 31);
-        } else {
-            tcg_gen_movi_i32(TCGV_HIGH(retv), 0);
-        }
-        return;
-    }
-
     t1 = tcg_temp_ebb_new_i64();
     t2 = tcg_temp_ebb_new_i64();
 
@@ -1019,17 +981,6 @@ static void tcg_gen_atomic_cmpxchg_i64_int(TCGv_i64 retv, TCGTemp *addr,
          * is removed.
          */
         tcg_gen_movi_i64(retv, 0);
-        return;
-    }
-
-    if (TCG_TARGET_REG_BITS == 32) {
-        tcg_gen_atomic_cmpxchg_i32_int(TCGV_LOW(retv), addr, TCGV_LOW(cmpv),
-                                       TCGV_LOW(newv), idx, memop);
-        if (memop & MO_SIGN) {
-            tcg_gen_sari_i32(TCGV_HIGH(retv), TCGV_LOW(retv), 31);
-        } else {
-            tcg_gen_movi_i32(TCGV_HIGH(retv), 0);
-        }
     } else {
         TCGv_i32 c32 = tcg_temp_ebb_new_i32();
         TCGv_i32 n32 = tcg_temp_ebb_new_i32();
@@ -1064,43 +1015,33 @@ static void tcg_gen_nonatomic_cmpxchg_i128_int(TCGv_i128 retv, TCGTemp *addr,
                                                TCGv_i128 cmpv, TCGv_i128 newv,
                                                TCGArg idx, MemOp memop)
 {
-    if (TCG_TARGET_REG_BITS == 32) {
-        /* Inline expansion below is simply too large for 32-bit hosts. */
-        MemOpIdx oi = make_memop_idx(memop, idx);
-        TCGv_i64 a64 = maybe_extend_addr64(addr);
+    TCGv_i128 oldv = tcg_temp_ebb_new_i128();
+    TCGv_i128 tmpv = tcg_temp_ebb_new_i128();
+    TCGv_i64 t0 = tcg_temp_ebb_new_i64();
+    TCGv_i64 t1 = tcg_temp_ebb_new_i64();
+    TCGv_i64 z = tcg_constant_i64(0);
 
-        gen_helper_nonatomic_cmpxchgo(retv, tcg_env, a64, cmpv, newv,
-                                      tcg_constant_i32(oi));
-        maybe_free_addr64(a64);
-    } else {
-        TCGv_i128 oldv = tcg_temp_ebb_new_i128();
-        TCGv_i128 tmpv = tcg_temp_ebb_new_i128();
-        TCGv_i64 t0 = tcg_temp_ebb_new_i64();
-        TCGv_i64 t1 = tcg_temp_ebb_new_i64();
-        TCGv_i64 z = tcg_constant_i64(0);
+    tcg_gen_qemu_ld_i128_int(oldv, addr, idx, memop);
 
-        tcg_gen_qemu_ld_i128_int(oldv, addr, idx, memop);
+    /* Compare i128 */
+    tcg_gen_xor_i64(t0, TCGV128_LOW(oldv), TCGV128_LOW(cmpv));
+    tcg_gen_xor_i64(t1, TCGV128_HIGH(oldv), TCGV128_HIGH(cmpv));
+    tcg_gen_or_i64(t0, t0, t1);
 
-        /* Compare i128 */
-        tcg_gen_xor_i64(t0, TCGV128_LOW(oldv), TCGV128_LOW(cmpv));
-        tcg_gen_xor_i64(t1, TCGV128_HIGH(oldv), TCGV128_HIGH(cmpv));
-        tcg_gen_or_i64(t0, t0, t1);
+    /* tmpv = equal ? newv : oldv */
+    tcg_gen_movcond_i64(TCG_COND_EQ, TCGV128_LOW(tmpv), t0, z,
+                        TCGV128_LOW(newv), TCGV128_LOW(oldv));
+    tcg_gen_movcond_i64(TCG_COND_EQ, TCGV128_HIGH(tmpv), t0, z,
+                        TCGV128_HIGH(newv), TCGV128_HIGH(oldv));
 
-        /* tmpv = equal ? newv : oldv */
-        tcg_gen_movcond_i64(TCG_COND_EQ, TCGV128_LOW(tmpv), t0, z,
-                            TCGV128_LOW(newv), TCGV128_LOW(oldv));
-        tcg_gen_movcond_i64(TCG_COND_EQ, TCGV128_HIGH(tmpv), t0, z,
-                            TCGV128_HIGH(newv), TCGV128_HIGH(oldv));
+    /* Unconditional writeback. */
+    tcg_gen_qemu_st_i128_int(tmpv, addr, idx, memop);
+    tcg_gen_mov_i128(retv, oldv);
 
-        /* Unconditional writeback. */
-        tcg_gen_qemu_st_i128_int(tmpv, addr, idx, memop);
-        tcg_gen_mov_i128(retv, oldv);
-
-        tcg_temp_free_i64(t0);
-        tcg_temp_free_i64(t1);
-        tcg_temp_free_i128(tmpv);
-        tcg_temp_free_i128(oldv);
-    }
+    tcg_temp_free_i64(t0);
+    tcg_temp_free_i64(t1);
+    tcg_temp_free_i128(tmpv);
+    tcg_temp_free_i128(oldv);
 }
 
 void tcg_gen_nonatomic_cmpxchg_i128_chk(TCGv_i128 retv, TCGTemp *addr,
Signature · 1 line
2.43.0
#46 lore raw

PATCH v2 35/58 tcg: Drop TCG_TARGET_REG_BITS tests in tcg.c

In reply to Richard Henderson
---
 tcg/tcg.c | 216 +++++++++---------------------------------------------
 1 file changed, 36 insertions(+), 180 deletions(-)
tcg/tcg.c +36 -180
index 2b3bcbe750..e7bf4dad4e 100644
@@ -215,10 +215,8 @@ static void * const qemu_ld_helpers[MO_SSIZE + 1] __attribute__((unused)) = {
     [MO_SW] = helper_ldsw_mmu,
     [MO_UL] = helper_ldul_mmu,
     [MO_UQ] = helper_ldq_mmu,
-#if TCG_TARGET_REG_BITS == 64
     [MO_SL] = helper_ldsl_mmu,
     [MO_128] = helper_ld16_mmu,
-#endif
 };
 
 static void * const qemu_st_helpers[MO_SIZE + 1] __attribute__((unused)) = {
@@ -226,9 +224,7 @@ static void * const qemu_st_helpers[MO_SIZE + 1] __attribute__((unused)) = {
     [MO_16] = helper_stw_mmu,
     [MO_32] = helper_stl_mmu,
     [MO_64] = helper_stq_mmu,
-#if TCG_TARGET_REG_BITS == 64
     [MO_128] = helper_st16_mmu,
-#endif
 };
 
 typedef struct {
@@ -504,7 +500,6 @@ static void tcg_out_movext(TCGContext *s, TCGType dst_type, TCGReg dst,
         }
         break;
     case MO_UQ:
-        tcg_debug_assert(TCG_TARGET_REG_BITS == 64);
         if (dst_type == TCG_TYPE_I32) {
             tcg_out_extrl_i64_i32(s, dst, src);
         } else {
@@ -1113,7 +1108,6 @@ QEMU_BUILD_BUG_ON((int)(offsetof(CPUNegativeOffsetState, tlb.f[0]) -
                   < MIN_TLB_MASK_TABLE_OFS);
 #endif
 
-#if TCG_TARGET_REG_BITS == 64
 /*
  * We require these functions for slow-path function calls.
  * Adapt them generically for opcode output.
@@ -1148,7 +1142,6 @@ static const TCGOutOpUnary outop_extrl_i64_i32 = {
     .base.static_constraint = C_O1_I1(r, r),
     .out_rr = TCG_TARGET_HAS_extr_i64_i32 ? tgen_extrl_i64_i32 : NULL,
 };
-#endif
 
 static const TCGOutOp outop_goto_ptr = {
     .static_constraint = C_O0_I1(r),
@@ -1360,11 +1353,7 @@ void tcg_pool_reset(TCGContext *s)
  * the helpers, with the end result that it's easier to build manually.
  */
 
-#if TCG_TARGET_REG_BITS == 32
-# define dh_typecode_ttl  dh_typecode_i32
-#else
-# define dh_typecode_ttl  dh_typecode_i64
-#endif
+#define dh_typecode_ttl  dh_typecode_i64
 
 static TCGHelperInfo info_helper_ld32_mmu = {
     .flags = TCG_CALL_NO_WG,
@@ -1615,17 +1604,12 @@ static void init_call_layout(TCGHelperInfo *info)
         break;
     case dh_typecode_i32:
     case dh_typecode_s32:
+    case dh_typecode_i64:
+    case dh_typecode_s64:
     case dh_typecode_ptr:
         info->nr_out = 1;
         info->out_kind = TCG_CALL_RET_NORMAL;
         break;
-    case dh_typecode_i64:
-    case dh_typecode_s64:
-        info->nr_out = 64 / TCG_TARGET_REG_BITS;
-        info->out_kind = TCG_CALL_RET_NORMAL;
-        /* Query the last register now to trigger any assert early. */
-        tcg_target_call_oarg_reg(info->out_kind, info->nr_out - 1);
-        break;
     case dh_typecode_i128:
         info->nr_out = 128 / TCG_TARGET_REG_BITS;
         info->out_kind = TCG_TARGET_CALL_RET_I128;
@@ -1705,11 +1689,7 @@ static void init_call_layout(TCGHelperInfo *info)
                 layout_arg_even(&cum);
                 /* fall through */
             case TCG_CALL_ARG_NORMAL:
-                if (TCG_TARGET_REG_BITS == 32) {
-                    layout_arg_normal_n(&cum, info, 2);
-                } else {
-                    layout_arg_1(&cum, info, TCG_CALL_ARG_NORMAL);
-                }
+                layout_arg_1(&cum, info, TCG_CALL_ARG_NORMAL);
                 break;
             default:
                 qemu_build_not_reached();
@@ -2002,11 +1982,8 @@ static TCGTemp *tcg_global_alloc(TCGContext *s)
 static TCGTemp *tcg_global_reg_new_internal(TCGContext *s, TCGType type,
                                             TCGReg reg, const char *name)
 {
-    TCGTemp *ts;
+    TCGTemp *ts = tcg_global_alloc(s);
 
-    tcg_debug_assert(TCG_TARGET_REG_BITS == 64 || type == TCG_TYPE_I32);
-
-    ts = tcg_global_alloc(s);
     ts->base_type = type;
     ts->type = type;
     ts->kind = TEMP_FIXED;
@@ -2040,48 +2017,20 @@ static TCGTemp *tcg_global_mem_new_internal(TCGv_ptr base, intptr_t offset,
         /* We do not support double-indirect registers.  */
         tcg_debug_assert(!base_ts->indirect_reg);
         base_ts->indirect_base = 1;
-        s->nb_indirects += (TCG_TARGET_REG_BITS == 32 && type == TCG_TYPE_I64
-                            ? 2 : 1);
+        s->nb_indirects += 1;
         indirect_reg = 1;
         break;
     default:
         g_assert_not_reached();
     }
 
-    if (TCG_TARGET_REG_BITS == 32 && type == TCG_TYPE_I64) {
-        TCGTemp *ts2 = tcg_global_alloc(s);
-        char buf[64];
-
-        ts->base_type = TCG_TYPE_I64;
-        ts->type = TCG_TYPE_I32;
-        ts->indirect_reg = indirect_reg;
-        ts->mem_allocated = 1;
-        ts->mem_base = base_ts;
-        ts->mem_offset = offset;
-        pstrcpy(buf, sizeof(buf), name);
-        pstrcat(buf, sizeof(buf), "_0");
-        ts->name = strdup(buf);
-
-        tcg_debug_assert(ts2 == ts + 1);
-        ts2->base_type = TCG_TYPE_I64;
-        ts2->type = TCG_TYPE_I32;
-        ts2->indirect_reg = indirect_reg;
-        ts2->mem_allocated = 1;
-        ts2->mem_base = base_ts;
-        ts2->mem_offset = offset + 4;
-        ts2->temp_subindex = 1;
-        pstrcpy(buf, sizeof(buf), name);
-        pstrcat(buf, sizeof(buf), "_1");
-        ts2->name = strdup(buf);
-    } else {
-        ts->base_type = type;
-        ts->type = type;
-        ts->indirect_reg = indirect_reg;
-        ts->mem_allocated = 1;
-        ts->mem_base = base_ts;
-        ts->mem_offset = offset;
-        ts->name = name;
-    }
+    ts->base_type = type;
+    ts->type = type;
+    ts->indirect_reg = indirect_reg;
+    ts->mem_allocated = 1;
+    ts->mem_base = base_ts;
+    ts->mem_offset = offset;
+    ts->name = name;
     return ts;
 }
 
@@ -2128,14 +2077,12 @@ TCGTemp *tcg_temp_new_internal(TCGType type, TCGTempKind kind)
 
     switch (type) {
     case TCG_TYPE_I32:
+    case TCG_TYPE_I64:
     case TCG_TYPE_V64:
     case TCG_TYPE_V128:
     case TCG_TYPE_V256:
         n = 1;
         break;
-    case TCG_TYPE_I64:
-        n = 64 / TCG_TARGET_REG_BITS;
-        break;
     case TCG_TYPE_I128:
         n = 128 / TCG_TARGET_REG_BITS;
         break;
@@ -2300,43 +2247,13 @@ TCGTemp *tcg_constant_internal(TCGType type, int64_t val)
 
     ts = g_hash_table_lookup(h, &val);
     if (ts == NULL) {
-        int64_t *val_ptr;
-
         ts = tcg_temp_alloc(s);
-
-        if (TCG_TARGET_REG_BITS == 32 && type == TCG_TYPE_I64) {
-            TCGTemp *ts2 = tcg_temp_alloc(s);
-
-            tcg_debug_assert(ts2 == ts + 1);
-
-            ts->base_type = TCG_TYPE_I64;
-            ts->type = TCG_TYPE_I32;
-            ts->kind = TEMP_CONST;
-            ts->temp_allocated = 1;
-
-            ts2->base_type = TCG_TYPE_I64;
-            ts2->type = TCG_TYPE_I32;
-            ts2->kind = TEMP_CONST;
-            ts2->temp_allocated = 1;
-            ts2->temp_subindex = 1;
-
-            /*
-             * Retain the full value of the 64-bit constant in the low
-             * part, so that the hash table works.  Actual uses will
-             * truncate the value to the low part.
-             */
-            ts[HOST_BIG_ENDIAN].val = val;
-            ts[!HOST_BIG_ENDIAN].val = val >> 32;
-            val_ptr = &ts[HOST_BIG_ENDIAN].val;
-        } else {
-            ts->base_type = type;
-            ts->type = type;
-            ts->kind = TEMP_CONST;
-            ts->temp_allocated = 1;
-            ts->val = val;
-            val_ptr = &ts->val;
-        }
-        g_hash_table_insert(h, val_ptr, ts);
+        ts->base_type = type;
+        ts->type = type;
+        ts->kind = TEMP_CONST;
+        ts->temp_allocated = 1;
+        ts->val = val;
+        g_hash_table_insert(h, &ts->val, ts);
     }
 
     return ts;
@@ -2405,10 +2322,8 @@ bool tcg_op_supported(TCGOpcode op, TCGType type, unsigned flags)
 
     switch (type) {
     case TCG_TYPE_I32:
-        has_type = true;
-        break;
     case TCG_TYPE_I64:
-        has_type = TCG_TARGET_REG_BITS == 64;
+        has_type = true;
         break;
     case TCG_TYPE_V64:
         has_type = TCG_TARGET_HAS_v64;
@@ -2443,10 +2358,6 @@ bool tcg_op_supported(TCGOpcode op, TCGType type, unsigned flags)
 
     case INDEX_op_qemu_ld2:
     case INDEX_op_qemu_st2:
-        if (TCG_TARGET_REG_BITS == 32) {
-            tcg_debug_assert(type == TCG_TYPE_I64);
-            return true;
-        }
         tcg_debug_assert(type == TCG_TYPE_I128);
         goto do_lookup;
 
@@ -2479,7 +2390,7 @@ bool tcg_op_supported(TCGOpcode op, TCGType type, unsigned flags)
     case INDEX_op_extu_i32_i64:
     case INDEX_op_extrl_i64_i32:
     case INDEX_op_extrh_i64_i32:
-        return TCG_TARGET_REG_BITS == 64;
+        return true;
 
     case INDEX_op_mov_vec:
     case INDEX_op_dup_vec:
@@ -2792,11 +2703,9 @@ static char *tcg_get_arg_str_ptr(TCGContext *s, char *buf, int buf_size,
         case TCG_TYPE_I32:
             snprintf(buf, buf_size, "$0x%x", (int32_t)ts->val);
             break;
-#if TCG_TARGET_REG_BITS > 32
         case TCG_TYPE_I64:
             snprintf(buf, buf_size, "$0x%" PRIx64, ts->val);
             break;
-#endif
         case TCG_TYPE_V64:
         case TCG_TYPE_V128:
         case TCG_TYPE_V256:
@@ -5654,8 +5563,6 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op)
     case INDEX_op_extu_i32_i64:
     case INDEX_op_extrl_i64_i32:
     case INDEX_op_extrh_i64_i32:
-        assert(TCG_TARGET_REG_BITS == 64);
-        /* fall through */
     case INDEX_op_ctpop:
     case INDEX_op_neg:
     case INDEX_op_not:
@@ -6179,9 +6086,7 @@ static int tcg_out_helper_stk_ofs(TCGType type, unsigned slot)
      * Each stack slot is TCG_TARGET_LONG_BITS.  If the host does not
      * require extension to uint64_t, adjust the address for uint32_t.
      */
-    if (HOST_BIG_ENDIAN &&
-        TCG_TARGET_REG_BITS == 64 &&
-        type == TCG_TYPE_I32) {
+    if (HOST_BIG_ENDIAN && type == TCG_TYPE_I32) {
         ofs += 4;
     }
     return ofs;
@@ -6390,13 +6295,8 @@ static unsigned tcg_out_helper_add_mov(TCGMovExtend *mov,
         return 1;
     }
 
-    if (TCG_TARGET_REG_BITS == 32) {
-        assert(dst_type == TCG_TYPE_I64);
-        reg_mo = MO_32;
-    } else {
-        assert(dst_type == TCG_TYPE_I128);
-        reg_mo = MO_64;
-    }
+    assert(dst_type == TCG_TYPE_I128);
+    reg_mo = MO_64;
 
     mov[0].dst = loc[HOST_BIG_ENDIAN].arg_slot;
     mov[0].src = lo;
@@ -6442,26 +6342,10 @@ static void tcg_out_ld_helper_args(TCGContext *s, const TCGLabelQemuLdst *ldst,
     next_arg = 1;
 
     loc = &info->in[next_arg];
-    if (TCG_TARGET_REG_BITS == 32 && s->addr_type == TCG_TYPE_I32) {
-        /*
-         * 32-bit host with 32-bit guest: zero-extend the guest address
-         * to 64-bits for the helper by storing the low part, then
-         * load a zero for the high part.
-         */
-        tcg_out_helper_add_mov(mov, loc + HOST_BIG_ENDIAN,
-                               TCG_TYPE_I32, TCG_TYPE_I32,
-                               ldst->addr_reg, -1);
-        tcg_out_helper_load_slots(s, 1, mov, parm);
-
-        tcg_out_helper_load_imm(s, loc[!HOST_BIG_ENDIAN].arg_slot,
-                                TCG_TYPE_I32, 0, parm);
-        next_arg += 2;
-    } else {
-        nmov = tcg_out_helper_add_mov(mov, loc, TCG_TYPE_I64, s->addr_type,
-                                      ldst->addr_reg, -1);
-        tcg_out_helper_load_slots(s, nmov, mov, parm);
-        next_arg += nmov;
-    }
+    nmov = tcg_out_helper_add_mov(mov, loc, TCG_TYPE_I64, s->addr_type,
+                                  ldst->addr_reg, -1);
+    tcg_out_helper_load_slots(s, nmov, mov, parm);
+    next_arg += nmov;
 
     switch (info->out_kind) {
     case TCG_CALL_RET_NORMAL:
@@ -6503,13 +6387,8 @@ static void tcg_out_ld_helper_ret(TCGContext *s, const TCGLabelQemuLdst *ldst,
     int ofs_slot0;
 
     switch (ldst->type) {
-    case TCG_TYPE_I64:
-        if (TCG_TARGET_REG_BITS == 32) {
-            break;
-        }
-        /* fall through */
-
     case TCG_TYPE_I32:
+    case TCG_TYPE_I64:
         mov[0].dst = ldst->datalo_reg;
         mov[0].src = tcg_target_call_oarg_reg(TCG_CALL_RET_NORMAL, 0);
         mov[0].dst_type = ldst->type;
@@ -6526,7 +6405,7 @@ static void tcg_out_ld_helper_ret(TCGContext *s, const TCGLabelQemuLdst *ldst,
          * helper functions.
          */
         if (load_sign || !(mop & MO_SIGN)) {
-            if (TCG_TARGET_REG_BITS == 32 || ldst->type == TCG_TYPE_I32) {
+            if (ldst->type == TCG_TYPE_I32) {
                 mov[0].src_ext = MO_32;
             } else {
                 mov[0].src_ext = MO_64;
@@ -6538,7 +6417,6 @@ static void tcg_out_ld_helper_ret(TCGContext *s, const TCGLabelQemuLdst *ldst,
         return;
 
     case TCG_TYPE_I128:
-        tcg_debug_assert(TCG_TARGET_REG_BITS == 64);
         ofs_slot0 = TCG_TARGET_CALL_STACK_OFFSET;
         switch (TCG_TARGET_CALL_RET_I128) {
         case TCG_CALL_RET_NORMAL:
@@ -6568,14 +6446,14 @@ static void tcg_out_ld_helper_ret(TCGContext *s, const TCGLabelQemuLdst *ldst,
         tcg_target_call_oarg_reg(TCG_CALL_RET_NORMAL, HOST_BIG_ENDIAN);
     mov[0].dst_type = TCG_TYPE_REG;
     mov[0].src_type = TCG_TYPE_REG;
-    mov[0].src_ext = TCG_TARGET_REG_BITS == 32 ? MO_32 : MO_64;
+    mov[0].src_ext = MO_64;
 
     mov[1].dst = ldst->datahi_reg;
     mov[1].src =
         tcg_target_call_oarg_reg(TCG_CALL_RET_NORMAL, !HOST_BIG_ENDIAN);
     mov[1].dst_type = TCG_TYPE_REG;
     mov[1].src_type = TCG_TYPE_REG;
-    mov[1].src_ext = TCG_TARGET_REG_BITS == 32 ? MO_32 : MO_64;
+    mov[1].src_ext = MO_64;
 
     tcg_out_movext2(s, mov, mov + 1, parm->ntmp ? parm->tmp[0] : -1);
 }
@@ -6616,24 +6494,10 @@ static void tcg_out_st_helper_args(TCGContext *s, const TCGLabelQemuLdst *ldst,
     /* Handle addr argument. */
     loc = &info->in[next_arg];
     tcg_debug_assert(s->addr_type <= TCG_TYPE_REG);
-    if (TCG_TARGET_REG_BITS == 32) {
-        /*
-         * 32-bit host (and thus 32-bit guest): zero-extend the guest address
-         * to 64-bits for the helper by storing the low part.  Later,
-         * after we have processed the register inputs, we will load a
-         * zero for the high part.
-         */
-        tcg_out_helper_add_mov(mov, loc + HOST_BIG_ENDIAN,
-                               TCG_TYPE_I32, TCG_TYPE_I32,
+    n = tcg_out_helper_add_mov(mov, loc, TCG_TYPE_I64, s->addr_type,
                                ldst->addr_reg, -1);
-        next_arg += 2;
-        nmov += 1;
-    } else {
-        n = tcg_out_helper_add_mov(mov, loc, TCG_TYPE_I64, s->addr_type,
-                                   ldst->addr_reg, -1);
-        next_arg += n;
-        nmov += n;
-    }
+    next_arg += n;
+    nmov += n;
 
     /* Handle data argument. */
     loc = &info->in[next_arg];
@@ -6649,7 +6513,6 @@ static void tcg_out_st_helper_args(TCGContext *s, const TCGLabelQemuLdst *ldst,
         break;
 
     case TCG_CALL_ARG_BY_REF:
-        tcg_debug_assert(TCG_TARGET_REG_BITS == 64);
         tcg_debug_assert(data_type == TCG_TYPE_I128);
         tcg_out_st(s, TCG_TYPE_I64,
                    HOST_BIG_ENDIAN ? ldst->datahi_reg : ldst->datalo_reg,
@@ -6678,12 +6541,6 @@ static void tcg_out_st_helper_args(TCGContext *s, const TCGLabelQemuLdst *ldst,
         g_assert_not_reached();
     }
 
-    if (TCG_TARGET_REG_BITS == 32) {
-        /* Zero extend the address by loading a zero for the high part. */
-        loc = &info->in[1 + !HOST_BIG_ENDIAN];
-        tcg_out_helper_load_imm(s, loc->arg_slot, TCG_TYPE_I32, 0, parm);
-    }
-
     tcg_out_helper_load_common_args(s, ldst, parm, info, next_arg);
 }
 
@@ -6791,7 +6648,6 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb, uint64_t pc_start)
 
         switch (opc) {
         case INDEX_op_extrl_i64_i32:
-            assert(TCG_TARGET_REG_BITS == 64);
             /*
              * If TCG_TYPE_I32 is represented in some canonical form,
              * e.g. zero or sign-extended, then emit as a unary op.
Signature · 1 line
2.43.0
#47 lore raw

PATCH v2 36/58 tcg: Drop TCG_TARGET_REG_BITS tests in tcg-internal.h

In reply to Richard Henderson
---
 tcg/tcg-internal.h | 21 ++-------------------
 1 file changed, 2 insertions(+), 19 deletions(-)
tcg/tcg-internal.h +2 -19
index d6a12afe06..2cbfb5d5ca 100644
@@ -54,31 +54,14 @@ static inline unsigned tcg_call_flags(TCGOp *op)
     return tcg_call_info(op)->flags;
 }
 
-#if TCG_TARGET_REG_BITS == 32
-static inline TCGv_i32 TCGV_LOW(TCGv_i64 t)
-{
-    return temp_tcgv_i32(tcgv_i64_temp(t) + HOST_BIG_ENDIAN);
-}
-static inline TCGv_i32 TCGV_HIGH(TCGv_i64 t)
-{
-    return temp_tcgv_i32(tcgv_i64_temp(t) + !HOST_BIG_ENDIAN);
-}
-#else
-TCGv_i32 TCGV_LOW(TCGv_i64) QEMU_ERROR("32-bit code path is reachable");
-TCGv_i32 TCGV_HIGH(TCGv_i64) QEMU_ERROR("32-bit code path is reachable");
-#endif
-
 static inline TCGv_i64 TCGV128_LOW(TCGv_i128 t)
 {
-    /* For 32-bit, offset by 2, which may then have TCGV_{LOW,HIGH} applied. */
-    int o = HOST_BIG_ENDIAN ? 64 / TCG_TARGET_REG_BITS : 0;
-    return temp_tcgv_i64(tcgv_i128_temp(t) + o);
+    return temp_tcgv_i64(tcgv_i128_temp(t) + HOST_BIG_ENDIAN);
 }
 
 static inline TCGv_i64 TCGV128_HIGH(TCGv_i128 t)
 {
-    int o = HOST_BIG_ENDIAN ? 0 : 64 / TCG_TARGET_REG_BITS;
-    return temp_tcgv_i64(tcgv_i128_temp(t) + o);
+    return temp_tcgv_i64(tcgv_i128_temp(t) + !HOST_BIG_ENDIAN);
 }
 
 bool tcg_target_has_memory_bswap(MemOp memop);
Signature · 1 line
2.43.0
#48 lore raw

PATCH v2 37/58 tcg: Drop TCG_TARGET_REG_BITS test in tcg-has.h

In reply to Richard Henderson
---
 tcg/tcg-has.h | 5 -----
 1 file changed, 5 deletions(-)
tcg/tcg-has.h +0 -5
index 2fc0e50d20..27771dc7f0 100644
@@ -9,11 +9,6 @@
 
 #include "tcg-target-has.h"
 
-#if TCG_TARGET_REG_BITS == 32
-/* Turn some undef macros into false macros.  */
-#define TCG_TARGET_HAS_extr_i64_i32     0
-#endif
-
 #if !defined(TCG_TARGET_HAS_v64) \
     && !defined(TCG_TARGET_HAS_v128) \
     && !defined(TCG_TARGET_HAS_v256)
Signature · 1 line
2.43.0
#49 lore raw

PATCH v2 38/58 include/tcg: Drop TCG_TARGET_REG_BITS tests

In reply to Richard Henderson
---
 include/tcg/tcg-op.h  |  9 +++------
 include/tcg/tcg-opc.h |  5 +----
 include/tcg/tcg.h     | 27 ++-------------------------
 3 files changed, 6 insertions(+), 35 deletions(-)
include/tcg/tcg-op.h +3 -6
index 232733cb71..ee379994e7 100644
@@ -31,8 +31,7 @@
 #if TARGET_INSN_START_EXTRA_WORDS == 0
 static inline void tcg_gen_insn_start(target_ulong pc)
 {
-    TCGOp *op = tcg_emit_op(INDEX_op_insn_start,
-                            INSN_START_WORDS * 64 / TCG_TARGET_REG_BITS);
+    TCGOp *op = tcg_emit_op(INDEX_op_insn_start, INSN_START_WORDS);
     tcg_set_insn_start_param(op, 0, pc);
     tcg_set_insn_start_param(op, 1, 0);
     tcg_set_insn_start_param(op, 2, 0);
@@ -40,8 +39,7 @@ static inline void tcg_gen_insn_start(target_ulong pc)
 #elif TARGET_INSN_START_EXTRA_WORDS == 1
 static inline void tcg_gen_insn_start(target_ulong pc, target_ulong a1)
 {
-    TCGOp *op = tcg_emit_op(INDEX_op_insn_start,
-                            INSN_START_WORDS * 64 / TCG_TARGET_REG_BITS);
+    TCGOp *op = tcg_emit_op(INDEX_op_insn_start, INSN_START_WORDS);
     tcg_set_insn_start_param(op, 0, pc);
     tcg_set_insn_start_param(op, 1, a1);
     tcg_set_insn_start_param(op, 2, 0);
@@ -50,8 +48,7 @@ static inline void tcg_gen_insn_start(target_ulong pc, target_ulong a1)
 static inline void tcg_gen_insn_start(target_ulong pc, target_ulong a1,
                                       target_ulong a2)
 {
-    TCGOp *op = tcg_emit_op(INDEX_op_insn_start,
-                            INSN_START_WORDS * 64 / TCG_TARGET_REG_BITS);
+    TCGOp *op = tcg_emit_op(INDEX_op_insn_start, INSN_START_WORDS);
     tcg_set_insn_start_param(op, 0, pc);
     tcg_set_insn_start_param(op, 1, a1);
     tcg_set_insn_start_param(op, 2, a2);
include/tcg/tcg-opc.h +1 -4
index 28806057c5..61f1c28858 100644
@@ -109,9 +109,7 @@ DEF(extu_i32_i64, 1, 1, 0, 0)
 DEF(extrl_i64_i32, 1, 1, 0, 0)
 DEF(extrh_i64_i32, 1, 1, 0, 0)
 
-#define DATA64_ARGS  (TCG_TARGET_REG_BITS == 64 ? 1 : 2)
-
-DEF(insn_start, 0, 0, DATA64_ARGS * INSN_START_WORDS, TCG_OPF_NOT_PRESENT)
+DEF(insn_start, 0, 0, INSN_START_WORDS, TCG_OPF_NOT_PRESENT)
 
 DEF(exit_tb, 0, 0, 1, TCG_OPF_BB_EXIT | TCG_OPF_BB_END | TCG_OPF_NOT_PRESENT)
 DEF(goto_tb, 0, 0, 1, TCG_OPF_BB_EXIT | TCG_OPF_BB_END | TCG_OPF_NOT_PRESENT)
@@ -184,5 +182,4 @@ DEF(last_generic, 0, 0, 0, TCG_OPF_NOT_PRESENT)
 
 #include "tcg-target-opc.h.inc"
 
-#undef DATA64_ARGS
 #undef DEF
include/tcg/tcg.h +2 -25
index 067150c542..60942ce05c 100644
@@ -43,19 +43,10 @@
 #define CPU_TEMP_BUF_NLONGS 128
 #define TCG_STATIC_FRAME_SIZE  (CPU_TEMP_BUF_NLONGS * sizeof(long))
 
-#if TCG_TARGET_REG_BITS == 32
-typedef int32_t tcg_target_long;
-typedef uint32_t tcg_target_ulong;
-#define TCG_PRIlx PRIx32
-#define TCG_PRIld PRId32
-#elif TCG_TARGET_REG_BITS == 64
 typedef int64_t tcg_target_long;
 typedef uint64_t tcg_target_ulong;
 #define TCG_PRIlx PRIx64
 #define TCG_PRIld PRId64
-#else
-#error unsupported
-#endif
 
 #if TCG_TARGET_NB_REGS <= 32
 typedef uint32_t TCGRegSet;
@@ -147,11 +138,7 @@ typedef enum TCGType {
 #define TCG_TYPE_COUNT  (TCG_TYPE_V256 + 1)
 
     /* An alias for the size of the host register.  */
-#if TCG_TARGET_REG_BITS == 32
-    TCG_TYPE_REG = TCG_TYPE_I32,
-#else
     TCG_TYPE_REG = TCG_TYPE_I64,
-#endif
 
     /* An alias for the size of the native pointer.  */
 #if UINTPTR_MAX == UINT32_MAX
@@ -605,23 +592,13 @@ static inline void tcg_set_insn_param(TCGOp *op, unsigned arg, TCGArg v)
 static inline uint64_t tcg_get_insn_start_param(TCGOp *op, unsigned arg)
 {
     tcg_debug_assert(arg < INSN_START_WORDS);
-    if (TCG_TARGET_REG_BITS == 64) {
-        return tcg_get_insn_param(op, arg);
-    } else {
-        return deposit64(tcg_get_insn_param(op, arg * 2), 32, 32,
-                         tcg_get_insn_param(op, arg * 2 + 1));
-    }
+    return tcg_get_insn_param(op, arg);
 }
 
 static inline void tcg_set_insn_start_param(TCGOp *op, unsigned arg, uint64_t v)
 {
     tcg_debug_assert(arg < INSN_START_WORDS);
-    if (TCG_TARGET_REG_BITS == 64) {
-        tcg_set_insn_param(op, arg, v);
-    } else {
-        tcg_set_insn_param(op, arg * 2, v);
-        tcg_set_insn_param(op, arg * 2 + 1, v >> 32);
-    }
+    tcg_set_insn_param(op, arg, v);
 }
 
 /* The last op that was emitted.  */
Signature · 1 line
2.43.0
#50 lore raw

PATCH v2 39/58 target/i386/tcg: Drop TCG_TARGET_REG_BITS test

In reply to Richard Henderson
---
 target/i386/tcg/emit.c.inc | 37 +++++++++----------------------------
 1 file changed, 9 insertions(+), 28 deletions(-)
target/i386/tcg/emit.c.inc +9 -28
index 41bf047b8d..639a1eb638 100644
@@ -2094,34 +2094,15 @@ static void gen_IMUL3(DisasContext *s, X86DecodedInsn *decode)
 
     case MO_32:
 #ifdef TARGET_X86_64
-        if (TCG_TARGET_REG_BITS == 64) {
-            /*
-             * This produces fewer TCG ops, and better code if flags are needed,
-             * but it requires a 64-bit multiply even if they are not.  Use it
-             * only if the target has 64-bits registers.
-             *
-             * s->T0 is already sign-extended.
-             */
-            tcg_gen_ext32s_tl(s->T1, s->T1);
-            tcg_gen_mul_tl(s->T0, s->T0, s->T1);
-            /* Compare the full result to the extension of the truncated result.  */
-            tcg_gen_ext32s_tl(s->T1, s->T0);
-            cc_src_rhs = s->T0;
-        } else {
-            /* Variant that only needs a 32-bit widening multiply.  */
-            TCGv_i32 hi = tcg_temp_new_i32();
-            TCGv_i32 lo = tcg_temp_new_i32();
-            tcg_gen_trunc_tl_i32(lo, s->T0);
-            tcg_gen_trunc_tl_i32(hi, s->T1);
-            tcg_gen_muls2_i32(lo, hi, lo, hi);
-            tcg_gen_extu_i32_tl(s->T0, lo);
-
-            cc_src_rhs = tcg_temp_new();
-            tcg_gen_extu_i32_tl(cc_src_rhs, hi);
-            /* Compare the high part to the sign bit of the truncated result */
-            tcg_gen_sari_i32(lo, lo, 31);
-            tcg_gen_extu_i32_tl(s->T1, lo);
-        }
+        /*
+         * This produces fewer TCG ops, and better code if flags are needed.
+         * s->T0 is already sign-extended.
+         */
+        tcg_gen_ext32s_tl(s->T1, s->T1);
+        tcg_gen_mul_tl(s->T0, s->T0, s->T1);
+        /* Compare the full result to the extension of the truncated result.  */
+        tcg_gen_ext32s_tl(s->T1, s->T0);
+        cc_src_rhs = s->T0;
         break;
 
     case MO_64:
Signature · 1 line
2.43.0
#51 lore raw

PATCH v2 40/58 target/riscv: Drop TCG_TARGET_REG_BITS test

In reply to Richard Henderson
---
 target/riscv/insn_trans/trans_rvv.c.inc | 54 ++++++-------------------
 1 file changed, 13 insertions(+), 41 deletions(-)
target/riscv/insn_trans/trans_rvv.c.inc +13 -41
index caefd38216..4df9a40b44 100644
@@ -1181,60 +1181,32 @@ static bool ldst_whole_trans(uint32_t vd, uint32_t rs1, uint32_t nf,
      * Update vstart with the number of processed elements.
      * Use the helper function if either:
      * - vstart is not 0.
-     * - the target has 32 bit registers and we are loading/storing 64 bit long
-     *   elements. This is to ensure that we process every element with a single
-     *   memory instruction.
      */
 
-    bool use_helper_fn = !(s->vstart_eq_zero) ||
-                          (TCG_TARGET_REG_BITS == 32 && log2_esz == 3);
+    bool use_helper_fn = !s->vstart_eq_zero;
 
     if (!use_helper_fn) {
-        TCGv addr = tcg_temp_new();
         uint32_t size = s->cfg_ptr->vlenb * nf;
         TCGv_i64 t8 = tcg_temp_new_i64();
-        TCGv_i32 t4 = tcg_temp_new_i32();
         MemOp atomicity = MO_ATOM_NONE;
         if (log2_esz == 0) {
             atomicity = MO_ATOM_NONE;
         } else {
             atomicity = MO_ATOM_IFALIGN_PAIR;
         }
-        if (TCG_TARGET_REG_BITS == 64) {
-            for (int i = 0; i < size; i += 8) {
-                addr = get_address(s, rs1, i);
-                if (is_load) {
-                    tcg_gen_qemu_ld_i64(t8, addr, s->mem_idx,
-                            MO_LE | MO_64 | atomicity);
-                    tcg_gen_st_i64(t8, tcg_env, vreg_ofs(s, vd) + i);
-                } else {
-                    tcg_gen_ld_i64(t8, tcg_env, vreg_ofs(s, vd) + i);
-                    tcg_gen_qemu_st_i64(t8, addr, s->mem_idx,
-                            MO_LE | MO_64 | atomicity);
-                }
-                if (i == size - 8) {
-                    tcg_gen_movi_tl(cpu_vstart, 0);
-                } else {
-                    tcg_gen_addi_tl(cpu_vstart, cpu_vstart, 8 >> log2_esz);
-                }
+        for (int i = 0; i < size; i += 8) {
+            TCGv addr = get_address(s, rs1, i);
+            if (is_load) {
+                tcg_gen_qemu_ld_i64(t8, addr, s->mem_idx, MO_LEUQ | atomicity);
+                tcg_gen_st_i64(t8, tcg_env, vreg_ofs(s, vd) + i);
+            } else {
+                tcg_gen_ld_i64(t8, tcg_env, vreg_ofs(s, vd) + i);
+                tcg_gen_qemu_st_i64(t8, addr, s->mem_idx, MO_LEUQ | atomicity);
             }
-        } else {
-            for (int i = 0; i < size; i += 4) {
-                addr = get_address(s, rs1, i);
-                if (is_load) {
-                    tcg_gen_qemu_ld_i32(t4, addr, s->mem_idx,
-                            MO_LE | MO_32 | atomicity);
-                    tcg_gen_st_i32(t4, tcg_env, vreg_ofs(s, vd) + i);
-                } else {
-                    tcg_gen_ld_i32(t4, tcg_env, vreg_ofs(s, vd) + i);
-                    tcg_gen_qemu_st_i32(t4, addr, s->mem_idx,
-                            MO_LE | MO_32 | atomicity);
-                }
-                if (i == size - 4) {
-                    tcg_gen_movi_tl(cpu_vstart, 0);
-                } else {
-                    tcg_gen_addi_tl(cpu_vstart, cpu_vstart, 4 >> log2_esz);
-                }
+            if (i == size - 8) {
+                tcg_gen_movi_tl(cpu_vstart, 0);
+            } else {
+                tcg_gen_addi_tl(cpu_vstart, cpu_vstart, 8 >> log2_esz);
             }
         }
     } else {
Signature · 1 line
2.43.0
#52 lore raw

PATCH v2 41/58 accel/tcg/runtime: Remove 64-bit shift helpers

In reply to Richard Henderson

These were only required for some 32-bit hosts.

---
 accel/tcg/tcg-runtime.h |  4 ----
 accel/tcg/tcg-runtime.c | 15 ---------------
 2 files changed, 19 deletions(-)
accel/tcg/tcg-runtime.h +0 -4
index 8436599b9f..698e9baa29 100644
@@ -8,10 +8,6 @@ DEF_HELPER_FLAGS_2(rem_i64, TCG_CALL_NO_RWG_SE, s64, s64, s64)
 DEF_HELPER_FLAGS_2(divu_i64, TCG_CALL_NO_RWG_SE, i64, i64, i64)
 DEF_HELPER_FLAGS_2(remu_i64, TCG_CALL_NO_RWG_SE, i64, i64, i64)
 
-DEF_HELPER_FLAGS_2(shl_i64, TCG_CALL_NO_RWG_SE, i64, i64, i64)
-DEF_HELPER_FLAGS_2(shr_i64, TCG_CALL_NO_RWG_SE, i64, i64, i64)
-DEF_HELPER_FLAGS_2(sar_i64, TCG_CALL_NO_RWG_SE, s64, s64, s64)
-
 DEF_HELPER_FLAGS_2(mulsh_i64, TCG_CALL_NO_RWG_SE, s64, s64, s64)
 DEF_HELPER_FLAGS_2(muluh_i64, TCG_CALL_NO_RWG_SE, i64, i64, i64)
 
accel/tcg/tcg-runtime.c +0 -15
index fa7ed9739c..f483c9c2ba 100644
@@ -55,21 +55,6 @@ uint32_t HELPER(remu_i32)(uint32_t arg1, uint32_t arg2)
 
 /* 64-bit helpers */
 
-uint64_t HELPER(shl_i64)(uint64_t arg1, uint64_t arg2)
-{
-    return arg1 << arg2;
-}
-
-uint64_t HELPER(shr_i64)(uint64_t arg1, uint64_t arg2)
-{
-    return arg1 >> arg2;
-}
-
-int64_t HELPER(sar_i64)(int64_t arg1, int64_t arg2)
-{
-    return arg1 >> arg2;
-}
-
 int64_t HELPER(div_i64)(int64_t arg1, int64_t arg2)
 {
     return arg1 / arg2;
Signature · 1 line
2.43.0
#53 lore raw

PATCH v2 42/58 accel/tcg/runtime: Remove helper_nonatomic_cmpxchgo

In reply to Richard Henderson

This were only required for some 32-bit hosts.

---
 accel/tcg/tcg-runtime.h       |  3 ---
 accel/tcg/atomic_common.c.inc | 20 --------------------
 2 files changed, 23 deletions(-)
accel/tcg/tcg-runtime.h +0 -3
index 698e9baa29..dc89155c0f 100644
@@ -73,9 +73,6 @@ DEF_HELPER_FLAGS_4(atomic_fetch_oro_le, TCG_CALL_NO_WG,
                    i128, env, i64, i128, i32)
 #endif
 
-DEF_HELPER_FLAGS_5(nonatomic_cmpxchgo, TCG_CALL_NO_WG,
-                   i128, env, i64, i128, i128, i32)
-
 #ifdef CONFIG_ATOMIC64
 #define GEN_ATOMIC_HELPERS(NAME)                                  \
     DEF_HELPER_FLAGS_4(glue(glue(atomic_, NAME), b),              \
accel/tcg/atomic_common.c.inc +0 -20
index bca93a0ac4..1ff80d19fe 100644
@@ -59,26 +59,6 @@ CMPXCHG_HELPER(cmpxchgo_le, Int128)
 
 #undef CMPXCHG_HELPER
 
-Int128 HELPER(nonatomic_cmpxchgo)(CPUArchState *env, uint64_t addr,
-                                  Int128 cmpv, Int128 newv, uint32_t oi)
-{
-#if TCG_TARGET_REG_BITS == 32
-    uintptr_t ra = GETPC();
-    Int128 oldv;
-
-    oldv = cpu_ld16_mmu(env, addr, oi, ra);
-    if (int128_eq(oldv, cmpv)) {
-        cpu_st16_mmu(env, addr, newv, oi, ra);
-    } else {
-        /* Even with comparison failure, still need a write cycle. */
-        probe_write(env, addr, 16, get_mmuidx(oi), ra);
-    }
-    return oldv;
-#else
-    g_assert_not_reached();
-#endif
-}
-
 #define ATOMIC_HELPER(OP, TYPE) \
     TYPE HELPER(glue(atomic_,OP))(CPUArchState *env, uint64_t addr,  \
                                   TYPE val, uint32_t oi)                 \
Signature · 1 line
2.43.0
#54 lore raw

PATCH v2 43/58 tcg: Unconditionally define atomic64 helpers

In reply to Richard Henderson

CONFIG_ATOMIC64 is a configuration knob for 32-bit hosts.

---
 accel/tcg/tcg-runtime.h             | 16 ----------------
 include/accel/tcg/cpu-ldst-common.h |  9 ---------
 accel/tcg/cputlb.c                  |  2 --
 accel/tcg/user-exec.c               |  2 --
 tcg/tcg-op-ldst.c                   | 17 ++++++-----------
 accel/tcg/atomic_common.c.inc       | 12 ------------
 6 files changed, 6 insertions(+), 52 deletions(-)
accel/tcg/tcg-runtime.h +0 -16
index dc89155c0f..0b832176b3 100644
@@ -48,12 +48,10 @@ DEF_HELPER_FLAGS_5(atomic_cmpxchgl_be, TCG_CALL_NO_WG,
                    i32, env, i64, i32, i32, i32)
 DEF_HELPER_FLAGS_5(atomic_cmpxchgl_le, TCG_CALL_NO_WG,
                    i32, env, i64, i32, i32, i32)
-#ifdef CONFIG_ATOMIC64
 DEF_HELPER_FLAGS_5(atomic_cmpxchgq_be, TCG_CALL_NO_WG,
                    i64, env, i64, i64, i64, i32)
 DEF_HELPER_FLAGS_5(atomic_cmpxchgq_le, TCG_CALL_NO_WG,
                    i64, env, i64, i64, i64, i32)
-#endif
 #if HAVE_CMPXCHG128
 DEF_HELPER_FLAGS_5(atomic_cmpxchgo_be, TCG_CALL_NO_WG,
                    i128, env, i64, i128, i128, i32)
@@ -73,7 +71,6 @@ DEF_HELPER_FLAGS_4(atomic_fetch_oro_le, TCG_CALL_NO_WG,
                    i128, env, i64, i128, i32)
 #endif
 
-#ifdef CONFIG_ATOMIC64
 #define GEN_ATOMIC_HELPERS(NAME)                                  \
     DEF_HELPER_FLAGS_4(glue(glue(atomic_, NAME), b),              \
                        TCG_CALL_NO_WG, i32, env, i64, i32, i32)   \
@@ -89,19 +86,6 @@ DEF_HELPER_FLAGS_4(atomic_fetch_oro_le, TCG_CALL_NO_WG,
                        TCG_CALL_NO_WG, i64, env, i64, i64, i32)   \
     DEF_HELPER_FLAGS_4(glue(glue(atomic_, NAME), q_be),           \
                        TCG_CALL_NO_WG, i64, env, i64, i64, i32)
-#else
-#define GEN_ATOMIC_HELPERS(NAME)                                  \
-    DEF_HELPER_FLAGS_4(glue(glue(atomic_, NAME), b),              \
-                       TCG_CALL_NO_WG, i32, env, i64, i32, i32)   \
-    DEF_HELPER_FLAGS_4(glue(glue(atomic_, NAME), w_le),           \
-                       TCG_CALL_NO_WG, i32, env, i64, i32, i32)   \
-    DEF_HELPER_FLAGS_4(glue(glue(atomic_, NAME), w_be),           \
-                       TCG_CALL_NO_WG, i32, env, i64, i32, i32)   \
-    DEF_HELPER_FLAGS_4(glue(glue(atomic_, NAME), l_le),           \
-                       TCG_CALL_NO_WG, i32, env, i64, i32, i32)   \
-    DEF_HELPER_FLAGS_4(glue(glue(atomic_, NAME), l_be),           \
-                       TCG_CALL_NO_WG, i32, env, i64, i32, i32)
-#endif /* CONFIG_ATOMIC64 */
 
 GEN_ATOMIC_HELPERS(fetch_add)
 GEN_ATOMIC_HELPERS(fetch_and)
include/accel/tcg/cpu-ldst-common.h +0 -9
index 17a3250ded..f12be8cfb7 100644
@@ -60,7 +60,6 @@ TYPE cpu_atomic_ ## NAME ## SUFFIX ## _mmu      \
     (CPUArchState *env, vaddr addr, TYPE val,   \
      MemOpIdx oi, uintptr_t retaddr);
 
-#ifdef CONFIG_ATOMIC64
 #define GEN_ATOMIC_HELPER_ALL(NAME)          \
     GEN_ATOMIC_HELPER(NAME, uint32_t, b)     \
     GEN_ATOMIC_HELPER(NAME, uint32_t, w_le)  \
@@ -69,14 +68,6 @@ TYPE cpu_atomic_ ## NAME ## SUFFIX ## _mmu      \
     GEN_ATOMIC_HELPER(NAME, uint32_t, l_be)  \
     GEN_ATOMIC_HELPER(NAME, uint64_t, q_le)  \
     GEN_ATOMIC_HELPER(NAME, uint64_t, q_be)
-#else
-#define GEN_ATOMIC_HELPER_ALL(NAME)          \
-    GEN_ATOMIC_HELPER(NAME, uint32_t, b)     \
-    GEN_ATOMIC_HELPER(NAME, uint32_t, w_le)  \
-    GEN_ATOMIC_HELPER(NAME, uint32_t, w_be)  \
-    GEN_ATOMIC_HELPER(NAME, uint32_t, l_le)  \
-    GEN_ATOMIC_HELPER(NAME, uint32_t, l_be)
-#endif
 
 GEN_ATOMIC_HELPER_ALL(fetch_add)
 GEN_ATOMIC_HELPER_ALL(fetch_sub)
accel/tcg/cputlb.c +0 -2
index c30073326a..a6774083b0 100644
@@ -2886,10 +2886,8 @@ static void do_st16_mmu(CPUState *cpu, vaddr addr, Int128 val,
 #define DATA_SIZE 4
 #include "atomic_template.h"
 
-#ifdef CONFIG_ATOMIC64
 #define DATA_SIZE 8
 #include "atomic_template.h"
-#endif
 
 #if defined(CONFIG_ATOMIC128) || HAVE_CMPXCHG128
 #define DATA_SIZE 16
accel/tcg/user-exec.c +0 -2
index 1800dffa63..ddbdc0432d 100644
@@ -1258,10 +1258,8 @@ static void *atomic_mmu_lookup(CPUState *cpu, vaddr addr, MemOpIdx oi,
 #define DATA_SIZE 4
 #include "atomic_template.h"
 
-#ifdef CONFIG_ATOMIC64
 #define DATA_SIZE 8
 #include "atomic_template.h"
-#endif
 
 #if defined(CONFIG_ATOMIC128) || HAVE_CMPXCHG128
 #define DATA_SIZE 16
tcg/tcg-op-ldst.c +6 -11
index 55bfbf3a20..354d9968f9 100644
@@ -825,11 +825,6 @@ typedef void (*gen_atomic_op_i64)(TCGv_i64, TCGv_env, TCGv_i64,
 typedef void (*gen_atomic_op_i128)(TCGv_i128, TCGv_env, TCGv_i64,
                                    TCGv_i128, TCGv_i32);
 
-#ifdef CONFIG_ATOMIC64
-# define WITH_ATOMIC64(X) X,
-#else
-# define WITH_ATOMIC64(X)
-#endif
 #if HAVE_CMPXCHG128
 # define WITH_ATOMIC128(X) X,
 #else
@@ -842,8 +837,8 @@ static void * const table_cmpxchg[(MO_SIZE | MO_BSWAP) + 1] = {
     [MO_16 | MO_BE] = gen_helper_atomic_cmpxchgw_be,
     [MO_32 | MO_LE] = gen_helper_atomic_cmpxchgl_le,
     [MO_32 | MO_BE] = gen_helper_atomic_cmpxchgl_be,
-    WITH_ATOMIC64([MO_64 | MO_LE] = gen_helper_atomic_cmpxchgq_le)
-    WITH_ATOMIC64([MO_64 | MO_BE] = gen_helper_atomic_cmpxchgq_be)
+    [MO_64 | MO_LE] = gen_helper_atomic_cmpxchgq_le,
+    [MO_64 | MO_BE] = gen_helper_atomic_cmpxchgq_be,
     WITH_ATOMIC128([MO_128 | MO_LE] = gen_helper_atomic_cmpxchgo_le)
     WITH_ATOMIC128([MO_128 | MO_BE] = gen_helper_atomic_cmpxchgo_be)
 };
@@ -1235,8 +1230,8 @@ static void * const table_##NAME[(MO_SIZE | MO_BSWAP) + 1] = {          \
     [MO_16 | MO_BE] = gen_helper_atomic_##NAME##w_be,                   \
     [MO_32 | MO_LE] = gen_helper_atomic_##NAME##l_le,                   \
     [MO_32 | MO_BE] = gen_helper_atomic_##NAME##l_be,                   \
-    WITH_ATOMIC64([MO_64 | MO_LE] = gen_helper_atomic_##NAME##q_le)     \
-    WITH_ATOMIC64([MO_64 | MO_BE] = gen_helper_atomic_##NAME##q_be)     \
+    [MO_64 | MO_LE] = gen_helper_atomic_##NAME##q_le,                   \
+    [MO_64 | MO_BE] = gen_helper_atomic_##NAME##q_be,                   \
     WITH_ATOMIC128([MO_128 | MO_LE] = gen_helper_atomic_##NAME##o_le)   \
     WITH_ATOMIC128([MO_128 | MO_BE] = gen_helper_atomic_##NAME##o_be)   \
 };                                                                      \
@@ -1287,8 +1282,8 @@ static void * const table_##NAME[(MO_SIZE | MO_BSWAP) + 1] = {          \
     [MO_16 | MO_BE] = gen_helper_atomic_##NAME##w_be,                   \
     [MO_32 | MO_LE] = gen_helper_atomic_##NAME##l_le,                   \
     [MO_32 | MO_BE] = gen_helper_atomic_##NAME##l_be,                   \
-    WITH_ATOMIC64([MO_64 | MO_LE] = gen_helper_atomic_##NAME##q_le)     \
-    WITH_ATOMIC64([MO_64 | MO_BE] = gen_helper_atomic_##NAME##q_be)     \
+    [MO_64 | MO_LE] = gen_helper_atomic_##NAME##q_le,                   \
+    [MO_64 | MO_BE] = gen_helper_atomic_##NAME##q_be,                   \
 };                                                                      \
 void tcg_gen_atomic_##NAME##_i32_chk(TCGv_i32 ret, TCGTemp *addr,       \
                                      TCGv_i32 val, TCGArg idx,          \
accel/tcg/atomic_common.c.inc +0 -12
index 1ff80d19fe..7d779dd51d 100644
@@ -46,11 +46,8 @@ CMPXCHG_HELPER(cmpxchgw_be, uint32_t)
 CMPXCHG_HELPER(cmpxchgw_le, uint32_t)
 CMPXCHG_HELPER(cmpxchgl_be, uint32_t)
 CMPXCHG_HELPER(cmpxchgl_le, uint32_t)
-
-#ifdef CONFIG_ATOMIC64
 CMPXCHG_HELPER(cmpxchgq_be, uint64_t)
 CMPXCHG_HELPER(cmpxchgq_le, uint64_t)
-#endif
 
 #if HAVE_CMPXCHG128
 CMPXCHG_HELPER(cmpxchgo_be, Int128)
@@ -64,7 +61,6 @@ CMPXCHG_HELPER(cmpxchgo_le, Int128)
                                   TYPE val, uint32_t oi)                 \
     { return glue(glue(cpu_atomic_,OP),_mmu)(env, addr, val, oi, GETPC()); }
 
-#ifdef CONFIG_ATOMIC64
 #define GEN_ATOMIC_HELPERS(OP)              \
     ATOMIC_HELPER(glue(OP,b), uint32_t)     \
     ATOMIC_HELPER(glue(OP,w_be), uint32_t)  \
@@ -73,14 +69,6 @@ CMPXCHG_HELPER(cmpxchgo_le, Int128)
     ATOMIC_HELPER(glue(OP,l_le), uint32_t)  \
     ATOMIC_HELPER(glue(OP,q_be), uint64_t)  \
     ATOMIC_HELPER(glue(OP,q_le), uint64_t)
-#else
-#define GEN_ATOMIC_HELPERS(OP)              \
-    ATOMIC_HELPER(glue(OP,b), uint32_t)     \
-    ATOMIC_HELPER(glue(OP,w_be), uint32_t)  \
-    ATOMIC_HELPER(glue(OP,w_le), uint32_t)  \
-    ATOMIC_HELPER(glue(OP,l_be), uint32_t)  \
-    ATOMIC_HELPER(glue(OP,l_le), uint32_t)
-#endif
 
 GEN_ATOMIC_HELPERS(fetch_add)
 GEN_ATOMIC_HELPERS(fetch_and)
Signature · 1 line
2.43.0
#55 lore raw

PATCH v2 44/58 accel/tcg: Drop CONFIG_ATOMIC64 checks from ldst_atomicicy.c.inc

In reply to Richard Henderson

CONFIG_ATOMIC64 is a configuration knob for 32-bit hosts.

This allows removal of functions like load_atomic8_or_exit and simplification of load_atom_extract_al8_or_exit to load_atom_extract_al8.

---
 accel/tcg/cputlb.c             |  35 +-------
 accel/tcg/ldst_atomicity.c.inc | 149 +++++----------------------------
 2 files changed, 24 insertions(+), 160 deletions(-)
accel/tcg/cputlb.c +3 -32
index a6774083b0..6900a12682 100644
@@ -2080,25 +2080,6 @@ static uint64_t do_ld_parts_beN(MMULookupPageData *p, uint64_t ret_be)
     return ret_be;
 }
 
-/**
- * do_ld_parts_be4
- * @p: translation parameters
- * @ret_be: accumulated data
- *
- * As do_ld_bytes_beN, but with one atomic load.
- * Four aligned bytes are guaranteed to cover the load.
- */
-static uint64_t do_ld_whole_be4(MMULookupPageData *p, uint64_t ret_be)
-{
-    int o = p->addr & 3;
-    uint32_t x = load_atomic4(p->haddr - o);
-
-    x = cpu_to_be32(x);
-    x <<= o * 8;
-    x >>= (4 - p->size) * 8;
-    return (ret_be << (p->size * 8)) | x;
-}
-
 /**
  * do_ld_parts_be8
  * @p: translation parameters
@@ -2111,7 +2092,7 @@ static uint64_t do_ld_whole_be8(CPUState *cpu, uintptr_t ra,
                                 MMULookupPageData *p, uint64_t ret_be)
 {
     int o = p->addr & 7;
-    uint64_t x = load_atomic8_or_exit(cpu, ra, p->haddr - o);
+    uint64_t x = load_atomic8(p->haddr - o);
 
     x = cpu_to_be64(x);
     x <<= o * 8;
@@ -2176,11 +2157,7 @@ static uint64_t do_ld_beN(CPUState *cpu, MMULookupPageData *p,
         if (atom == MO_ATOM_IFALIGN_PAIR
             ? p->size == half_size
             : p->size >= half_size) {
-            if (!HAVE_al8_fast && p->size < 4) {
-                return do_ld_whole_be4(p, ret_be);
-            } else {
-                return do_ld_whole_be8(cpu, ra, p, ret_be);
-            }
+            return do_ld_whole_be8(cpu, ra, p, ret_be);
         }
         /* fall through */
 
@@ -2586,13 +2563,7 @@ static uint64_t do_st_leN(CPUState *cpu, MMULookupPageData *p,
         if (atom == MO_ATOM_IFALIGN_PAIR
             ? p->size == half_size
             : p->size >= half_size) {
-            if (!HAVE_al8_fast && p->size <= 4) {
-                return store_whole_le4(p->haddr, p->size, val_le);
-            } else if (HAVE_al8) {
-                return store_whole_le8(p->haddr, p->size, val_le);
-            } else {
-                cpu_loop_exit_atomic(cpu, ra);
-            }
+            return store_whole_le8(p->haddr, p->size, val_le);
         }
         /* fall through */
 
accel/tcg/ldst_atomicity.c.inc +21 -128

284 lines not on this page · raw message

Signature · 1 line
2.43.0
#56 lore raw

PATCH v2 45/58 accel/tcg: Drop CONFIG_ATOMIC64 test from translator.c

In reply to Richard Henderson
---
 accel/tcg/translator.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
accel/tcg/translator.c +1 -3
index 034f2f359e..f3eddcbb2e 100644
@@ -352,15 +352,13 @@ static bool translator_ld(CPUArchState *env, DisasContextBase *db,
             return true;
         }
         break;
-#ifdef CONFIG_ATOMIC64
     case 8:
         if (QEMU_IS_ALIGNED(pc, 8)) {
-            uint64_t t = qatomic_read__nocheck((uint64_t *)host);
+            uint64_t t = qatomic_read((uint64_t *)host);
             stq_he_p(dest, t);
             return true;
         }
         break;
-#endif
     }
     /* Unaligned or partial read from the second page is not atomic. */
     memcpy(dest, host, len);
Signature · 1 line
2.43.0
#57 lore raw

PATCH v2 46/58 linux-user/arm: Drop CONFIG_ATOMIC64 test

In reply to Richard Henderson
---
 linux-user/arm/cpu_loop.c | 19 +------------------
 1 file changed, 1 insertion(+), 18 deletions(-)
linux-user/arm/cpu_loop.c +1 -18
index cd89b7d6f5..40aefc4c1d 100644
@@ -146,25 +146,8 @@ static void arm_kernel_cmpxchg64_helper(CPUARMState *env)
     /* Swap if host != guest endianness, for the host cmpxchg below */
     oldval = tswap64(oldval);
     newval = tswap64(newval);
-
-#ifdef CONFIG_ATOMIC64
-    val = qatomic_cmpxchg__nocheck(host_addr, oldval, newval);
+    val = qatomic_cmpxchg(host_addr, oldval, newval);
     cpsr = (val == oldval) * CPSR_C;
-#else
-    /*
-     * This only works between threads, not between processes, but since
-     * the host has no 64-bit cmpxchg, it is the best that we can do.
-     */
-    start_exclusive();
-    val = *host_addr;
-    if (val == oldval) {
-        *host_addr = newval;
-        cpsr = CPSR_C;
-    } else {
-        cpsr = 0;
-    }
-    end_exclusive();
-#endif
     mmap_unlock();
 
     cpsr_write(env, cpsr, CPSR_C, CPSRWriteByInstr);
Signature · 1 line
2.43.0
#58 lore raw

PATCH v2 47/58 linux-user/hppa: Drop CONFIG_ATOMIC64 test

In reply to Richard Henderson
---
 linux-user/hppa/cpu_loop.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)
linux-user/hppa/cpu_loop.c +1 -13
index 356cb48acc..e5c0f52d94 100644
@@ -83,20 +83,8 @@ static abi_ulong hppa_lws(CPUHPPAState *env)
                 uint64_t o64, n64, r64;
                 o64 = *(uint64_t *)g2h(cs, old);
                 n64 = *(uint64_t *)g2h(cs, new);
-#ifdef CONFIG_ATOMIC64
-                r64 = qatomic_cmpxchg__nocheck((aligned_uint64_t *)g2h(cs, addr),
-                                               o64, n64);
+                r64 = qatomic_cmpxchg((aligned_uint64_t *)g2h(cs, addr), o64, n64);
                 ret = r64 != o64;
-#else
-                start_exclusive();
-                r64 = *(uint64_t *)g2h(cs, addr);
-                ret = 1;
-                if (r64 == o64) {
-                    *(uint64_t *)g2h(cs, addr) = n64;
-                    ret = 0;
-                }
-                end_exclusive();
-#endif
             }
             break;
         default:
Signature · 1 line
2.43.0
#59 lore raw

PATCH v2 48/58 target/arm: Drop CONFIG_ATOMIC64 tests

In reply to Richard Henderson
---
 target/arm/ptw.c | 18 +++++-------------
 1 file changed, 5 insertions(+), 13 deletions(-)
target/arm/ptw.c +5 -13
index a986dc66f6..8b8dc09e72 100644
@@ -757,20 +757,12 @@ static uint64_t arm_ldq_ptw(CPUARMState *env, S1Translate *ptw,
 
     if (likely(host)) {
         /* Page tables are in RAM, and we have the host address. */
-#ifdef CONFIG_ATOMIC64
-        data = qatomic_read__nocheck((uint64_t *)host);
+        data = qatomic_read((uint64_t *)host);
         if (ptw->out_be) {
             data = be64_to_cpu(data);
         } else {
             data = le64_to_cpu(data);
         }
-#else
-        if (ptw->out_be) {
-            data = ldq_be_p(host);
-        } else {
-            data = ldq_le_p(host);
-        }
-#endif
     } else {
         /* Page tables are in MMIO. */
         MemTxAttrs attrs = {
@@ -798,7 +790,7 @@ static uint64_t arm_casq_ptw(CPUARMState *env, uint64_t old_val,
                              uint64_t new_val, S1Translate *ptw,
                              ARMMMUFaultInfo *fi)
 {
-#if defined(CONFIG_ATOMIC64) && defined(CONFIG_TCG)
+#ifdef CONFIG_TCG
     uint64_t cur_val;
     void *host = ptw->out_host;
 
@@ -903,17 +895,17 @@ static uint64_t arm_casq_ptw(CPUARMState *env, uint64_t old_val,
     if (ptw->out_be) {
         old_val = cpu_to_be64(old_val);
         new_val = cpu_to_be64(new_val);
-        cur_val = qatomic_cmpxchg__nocheck((uint64_t *)host, old_val, new_val);
+        cur_val = qatomic_cmpxchg((uint64_t *)host, old_val, new_val);
         cur_val = be64_to_cpu(cur_val);
     } else {
         old_val = cpu_to_le64(old_val);
         new_val = cpu_to_le64(new_val);
-        cur_val = qatomic_cmpxchg__nocheck((uint64_t *)host, old_val, new_val);
+        cur_val = qatomic_cmpxchg((uint64_t *)host, old_val, new_val);
         cur_val = le64_to_cpu(cur_val);
     }
     return cur_val;
 #else
-    /* AArch32 does not have FEAT_HADFS; non-TCG guests only use debug-mode. */
+    /* Non-TCG guests only use debug-mode. */
     g_assert_not_reached();
 #endif
 }
Signature · 1 line
2.43.0
#60 lore raw

PATCH v2 49/58 target/hppa: Drop CONFIG_ATOMIC64 test

In reply to Richard Henderson
---
 target/hppa/op_helper.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
target/hppa/op_helper.c +1 -5
index 65faf03cd0..f961046e4c 100644
@@ -74,7 +74,6 @@ static void atomic_store_mask64(CPUHPPAState *env, target_ulong addr,
                                 uint64_t val, uint64_t mask,
                                 int size, uintptr_t ra)
 {
-#ifdef CONFIG_ATOMIC64
     int mmu_idx = cpu_mmu_index(env_cpu(env), 0);
     uint64_t old, new, cmp, *haddr;
     void *vaddr;
@@ -88,15 +87,12 @@ static void atomic_store_mask64(CPUHPPAState *env, target_ulong addr,
     old = *haddr;
     while (1) {
         new = be32_to_cpu((cpu_to_be32(old) & ~mask) | (val & mask));
-        cmp = qatomic_cmpxchg__nocheck(haddr, old, new);
+        cmp = qatomic_cmpxchg(haddr, old, new);
         if (cmp == old) {
             return;
         }
         old = cmp;
     }
-#else
-    cpu_loop_exit_atomic(env_cpu(env), ra);
-#endif
 }
 
 static void do_stby_b(CPUHPPAState *env, target_ulong addr, target_ulong val,
Signature · 1 line
2.43.0
#61 lore raw

PATCH v2 50/58 target/m68k: Drop CONFIG_ATOMIC64 tests

In reply to Richard Henderson
---
 target/m68k/op_helper.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
target/m68k/op_helper.c +1 -6
index a27e2bcfbc..f7df83c850 100644
@@ -816,14 +816,11 @@ static void do_cas2l(CPUM68KState *env, uint32_t regs, uint32_t a1, uint32_t a2,
     uint32_t u2 = env->dregs[Du2];
     uint32_t l1, l2;
     uintptr_t ra = GETPC();
-#if defined(CONFIG_ATOMIC64)
     int mmu_idx = cpu_mmu_index(env_cpu(env), 0);
     MemOpIdx oi = make_memop_idx(MO_BEUQ, mmu_idx);
-#endif
 
     if (parallel) {
         /* We're executing in a parallel context -- must be atomic.  */
-#ifdef CONFIG_ATOMIC64
         uint64_t c, u, l;
         if ((a1 & 7) == 0 && a2 == a1 + 4) {
             c = deposit64(c2, 32, 32, c1);
@@ -837,9 +834,7 @@ static void do_cas2l(CPUM68KState *env, uint32_t regs, uint32_t a1, uint32_t a2,
             l = cpu_atomic_cmpxchgq_be_mmu(env, a2, c, u, oi, ra);
             l2 = l >> 32;
             l1 = l;
-        } else
-#endif
-        {
+        } else {
             /* Tell the main loop we need to serialize this insn.  */
             cpu_loop_exit_atomic(env_cpu(env), ra);
         }
Signature · 1 line
2.43.0
#62 lore raw

PATCH v2 51/58 target/s390x: Drop CONFIG_ATOMIC64 tests

In reply to Richard Henderson
---
 target/s390x/tcg/mem_helper.c | 7 -------
 1 file changed, 7 deletions(-)
target/s390x/tcg/mem_helper.c +0 -7
index 2972b7ddb9..0b8b6d3bbb 100644
@@ -1815,9 +1815,7 @@ static uint32_t do_csst(CPUS390XState *env, uint32_t r3, uint64_t a1,
      */
     if (parallel) {
         uint32_t max = 2;
-#ifdef CONFIG_ATOMIC64
         max = 3;
-#endif
         if ((HAVE_CMPXCHG128 ? 0 : fc + 2 > max) ||
             (HAVE_ATOMIC128_RW ? 0 : sc > max)) {
             cpu_loop_exit_atomic(env_cpu(env), ra);
@@ -1856,12 +1854,7 @@ static uint32_t do_csst(CPUS390XState *env, uint32_t r3, uint64_t a1,
             uint64_t ov;
 
             if (parallel) {
-#ifdef CONFIG_ATOMIC64
                 ov = cpu_atomic_cmpxchgq_be_mmu(env, a1, cv, nv, oi8, ra);
-#else
-                /* Note that we asserted !parallel above.  */
-                g_assert_not_reached();
-#endif
             } else {
                 ov = cpu_ldq_mmu(env, a1, oi8, ra);
                 cpu_stq_mmu(env, a1, (ov == cv ? nv : ov), oi8, ra);
Signature · 1 line
2.43.0
#63 lore raw

PATCH v2 52/58 target/s390x: Simplify atomicity check in do_csst

In reply to Richard Henderson

We should have used MO_{32,64} from the start, rather than raw integer constants. However, now that the CONFIG_ATOMIC64 test has been removed, we can remove the 'max' variable and simplify the two blocks.

---
 target/s390x/tcg/mem_helper.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)
target/s390x/tcg/mem_helper.c +4 -7
index 0b8b6d3bbb..2a79a789f6 100644
@@ -1813,13 +1813,10 @@ static uint32_t do_csst(CPUS390XState *env, uint32_t r3, uint64_t a1,
      * restart early if we can't support either operation that is supposed
      * to be atomic.
      */
-    if (parallel) {
-        uint32_t max = 2;
-        max = 3;
-        if ((HAVE_CMPXCHG128 ? 0 : fc + 2 > max) ||
-            (HAVE_ATOMIC128_RW ? 0 : sc > max)) {
-            cpu_loop_exit_atomic(env_cpu(env), ra);
-        }
+    if (parallel &&
+        ((!HAVE_CMPXCHG128 && fc + 2 > MO_64) ||
+         (!HAVE_ATOMIC128_RW && sc > MO_64))) {
+        cpu_loop_exit_atomic(env_cpu(env), ra);
     }
 
     /*
Signature · 1 line
2.43.0
Reviewed-by on v2 52/58
#64 lore raw

Re: [PATCH v2 52/58] target/s390x: Simplify atomicity check in do_csst

Quoted 10 lines · Richard Henderson

We should have used MO_{32,64} from the start, rather than raw integer constants. However, now that the CONFIG_ATOMIC64 test has been removed, we can remove the 'max' variable and simplify the two blocks.

---
  target/s390x/tcg/mem_helper.c | 11 ++++-------
  1 file changed, 4 insertions(+), 7 deletions(-)
#65 lore raw

PATCH v2 53/58 migration: Drop use of Stat64

In reply to Richard Henderson

The Stat64 structure is an aid for 32-bit hosts, and is no longer required. Use plain 64-bit types.

---
 migration/migration-stats.h   | 36 ++++++++++++++++-------------------
 migration/cpu-throttle.c      |  4 ++--
 migration/migration-stats.c   | 16 ++++++++--------
 migration/migration.c         | 24 +++++++++++------------
 migration/multifd-nocomp.c    |  2 +-
 migration/multifd-zero-page.c |  4 ++--
 migration/multifd.c           | 12 ++++--------
 migration/qemu-file.c         |  6 +++---
 migration/ram.c               | 30 ++++++++++++++---------------
 migration/rdma.c              |  8 ++++----
 10 files changed, 67 insertions(+), 75 deletions(-)
migration/migration-stats.h +16 -20
index 05290ade76..c0f50144c9 100644
@@ -13,8 +13,6 @@
 #ifndef QEMU_MIGRATION_STATS_H
 #define QEMU_MIGRATION_STATS_H
 
-#include "qemu/stats64.h"
-
 /*
  * Amount of time to allocate to each "chunk" of bandwidth-throttled
  * data.
@@ -29,9 +27,7 @@
 
 /*
  * These are the ram migration statistic counters.  It is loosely
- * based on MigrationStats.  We change to Stat64 any counter that
- * needs to be updated using atomic ops (can be accessed by more than
- * one thread).
+ * based on MigrationStats.
  */
 typedef struct {
     /*
@@ -41,66 +37,66 @@ typedef struct {
      * since last iteration, not counting what the guest has dirtied
      * since we synchronized bitmaps.
      */
-    Stat64 dirty_bytes_last_sync;
+    uint64_t dirty_bytes_last_sync;
     /*
      * Number of pages dirtied per second.
      */
-    Stat64 dirty_pages_rate;
+    uint64_t dirty_pages_rate;
     /*
      * Number of times we have synchronized guest bitmaps.
      */
-    Stat64 dirty_sync_count;
+    uint64_t dirty_sync_count;
     /*
      * Number of times zero copy failed to send any page using zero
      * copy.
      */
-    Stat64 dirty_sync_missed_zero_copy;
+    uint64_t dirty_sync_missed_zero_copy;
     /*
      * Number of bytes sent at migration completion stage while the
      * guest is stopped.
      */
-    Stat64 downtime_bytes;
+    uint64_t downtime_bytes;
     /*
      * Number of bytes sent through multifd channels.
      */
-    Stat64 multifd_bytes;
+    uint64_t multifd_bytes;
     /*
      * Number of pages transferred that were not full of zeros.
      */
-    Stat64 normal_pages;
+    uint64_t normal_pages;
     /*
      * Number of bytes sent during postcopy.
      */
-    Stat64 postcopy_bytes;
+    uint64_t postcopy_bytes;
     /*
      * Number of postcopy page faults that we have handled during
      * postcopy stage.
      */
-    Stat64 postcopy_requests;
+    uint64_t postcopy_requests;
     /*
      * Number of bytes sent during precopy stage.
      */
-    Stat64 precopy_bytes;
+    uint64_t precopy_bytes;
     /*
      * Number of bytes transferred with QEMUFile.
      */
-    Stat64 qemu_file_transferred;
+    uint64_t qemu_file_transferred;
     /*
      * Amount of transferred data at the start of current cycle.
      */
-    Stat64 rate_limit_start;
+    uint64_t rate_limit_start;
     /*
      * Maximum amount of data we can send in a cycle.
      */
-    Stat64 rate_limit_max;
+    uint64_t rate_limit_max;
     /*
      * Number of bytes sent through RDMA.
      */
-    Stat64 rdma_bytes;
+    uint64_t rdma_bytes;
     /*
      * Number of pages transferred that were full of zeros.
      */
-    Stat64 zero_pages;
+    uint64_t zero_pages;
 } MigrationAtomicStats;
 
 extern MigrationAtomicStats mig_stats;
migration/cpu-throttle.c +2 -2
index 0642e6bdea..3b4d4aea52 100644
@@ -134,7 +134,7 @@ int cpu_throttle_get_percentage(void)
 
 void cpu_throttle_dirty_sync_timer_tick(void *opaque)
 {
-    uint64_t sync_cnt = stat64_get(&mig_stats.dirty_sync_count);
+    uint64_t sync_cnt = qatomic_read(&mig_stats.dirty_sync_count);
 
     /*
      * The first iteration copies all memory anyhow and has no
@@ -153,7 +153,7 @@ void cpu_throttle_dirty_sync_timer_tick(void *opaque)
     }
 
 end:
-    throttle_dirty_sync_count_prev = stat64_get(&mig_stats.dirty_sync_count);
+    throttle_dirty_sync_count_prev = qatomic_read(&mig_stats.dirty_sync_count);
 
     timer_mod(throttle_dirty_sync_timer,
         qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL_RT) +
migration/migration-stats.c +8 -8
index f690b98a03..3f17b6ac5c 100644
@@ -11,7 +11,7 @@
  */
 
 #include "qemu/osdep.h"
-#include "qemu/stats64.h"
+#include "qemu/atomic.h"
 #include "qemu-file.h"
 #include "trace.h"
 #include "migration-stats.h"
@@ -29,7 +29,7 @@ bool migration_rate_exceeded(QEMUFile *f)
         return false;
     }
 
-    uint64_t rate_limit_start = stat64_get(&mig_stats.rate_limit_start);
+    uint64_t rate_limit_start = qatomic_read(&mig_stats.rate_limit_start);
     uint64_t rate_limit_current = migration_transferred_bytes();
     uint64_t rate_limit_used = rate_limit_current - rate_limit_start;
 
@@ -41,7 +41,7 @@ bool migration_rate_exceeded(QEMUFile *f)
 
 uint64_t migration_rate_get(void)
 {
-    return stat64_get(&mig_stats.rate_limit_max);
+    return qatomic_read(&mig_stats.rate_limit_max);
 }
 
 #define XFER_LIMIT_RATIO (1000 / BUFFER_DELAY)
@@ -51,19 +51,19 @@ void migration_rate_set(uint64_t limit)
     /*
      * 'limit' is per second.  But we check it each BUFFER_DELAY milliseconds.
      */
-    stat64_set(&mig_stats.rate_limit_max, limit / XFER_LIMIT_RATIO);
+    qatomic_set(&mig_stats.rate_limit_max, limit / XFER_LIMIT_RATIO);
 }
 
 void migration_rate_reset(void)
 {
-    stat64_set(&mig_stats.rate_limit_start, migration_transferred_bytes());
+    qatomic_set(&mig_stats.rate_limit_start, migration_transferred_bytes());
 }
 
 uint64_t migration_transferred_bytes(void)
 {
-    uint64_t multifd = stat64_get(&mig_stats.multifd_bytes);
-    uint64_t rdma = stat64_get(&mig_stats.rdma_bytes);
-    uint64_t qemu_file = stat64_get(&mig_stats.qemu_file_transferred);
+    uint64_t multifd = qatomic_read(&mig_stats.multifd_bytes);
+    uint64_t rdma = qatomic_read(&mig_stats.rdma_bytes);
+    uint64_t qemu_file = qatomic_read(&mig_stats.qemu_file_transferred);
 
     trace_migration_transferred_bytes(qemu_file, multifd, rdma);
     return qemu_file + multifd + rdma;
migration/migration.c +12 -12
index 1c34d8d432..1bcde301f7 100644
@@ -1266,22 +1266,22 @@ static void populate_ram_info(MigrationInfo *info, MigrationState *s)
     info->ram = g_malloc0(sizeof(*info->ram));
     info->ram->transferred = migration_transferred_bytes();
     info->ram->total = ram_bytes_total();
-    info->ram->duplicate = stat64_get(&mig_stats.zero_pages);
-    info->ram->normal = stat64_get(&mig_stats.normal_pages);
+    info->ram->duplicate = qatomic_read(&mig_stats.zero_pages);
+    info->ram->normal = qatomic_read(&mig_stats.normal_pages);
     info->ram->normal_bytes = info->ram->normal * page_size;
     info->ram->mbps = s->mbps;
     info->ram->dirty_sync_count =
-        stat64_get(&mig_stats.dirty_sync_count);
+        qatomic_read(&mig_stats.dirty_sync_count);
     info->ram->dirty_sync_missed_zero_copy =
-        stat64_get(&mig_stats.dirty_sync_missed_zero_copy);
+        qatomic_read(&mig_stats.dirty_sync_missed_zero_copy);
     info->ram->postcopy_requests =
-        stat64_get(&mig_stats.postcopy_requests);
+        qatomic_read(&mig_stats.postcopy_requests);
     info->ram->page_size = page_size;
-    info->ram->multifd_bytes = stat64_get(&mig_stats.multifd_bytes);
+    info->ram->multifd_bytes = qatomic_read(&mig_stats.multifd_bytes);
     info->ram->pages_per_second = s->pages_per_second;
-    info->ram->precopy_bytes = stat64_get(&mig_stats.precopy_bytes);
-    info->ram->downtime_bytes = stat64_get(&mig_stats.downtime_bytes);
-    info->ram->postcopy_bytes = stat64_get(&mig_stats.postcopy_bytes);
+    info->ram->precopy_bytes = qatomic_read(&mig_stats.precopy_bytes);
+    info->ram->downtime_bytes = qatomic_read(&mig_stats.downtime_bytes);
+    info->ram->postcopy_bytes = qatomic_read(&mig_stats.postcopy_bytes);
 
     if (migrate_xbzrle()) {
         info->xbzrle_cache = g_malloc0(sizeof(*info->xbzrle_cache));
@@ -1302,7 +1302,7 @@ static void populate_ram_info(MigrationInfo *info, MigrationState *s)
     if (s->state != MIGRATION_STATUS_COMPLETED) {
         info->ram->remaining = ram_bytes_remaining();
         info->ram->dirty_pages_rate =
-           stat64_get(&mig_stats.dirty_pages_rate);
+           qatomic_read(&mig_stats.dirty_pages_rate);
     }
 
     if (migrate_dirty_limit() && dirtylimit_in_service()) {
@@ -3420,10 +3420,10 @@ static void migration_update_counters(MigrationState *s,
      * if we haven't sent anything, we don't want to
      * recalculate. 10000 is a small enough number for our purposes
      */
-    if (stat64_get(&mig_stats.dirty_pages_rate) &&
+    if (qatomic_read(&mig_stats.dirty_pages_rate) &&
         transferred > 10000) {
         s->expected_downtime =
-            stat64_get(&mig_stats.dirty_bytes_last_sync) / expected_bw_per_ms;
+            qatomic_read(&mig_stats.dirty_bytes_last_sync) / expected_bw_per_ms;
     }
 
     migration_rate_reset();
migration/multifd-nocomp.c +1 -1
index b48eae3d86..9be79b3b8e 100644
@@ -141,7 +141,7 @@ static int multifd_nocomp_send_prepare(MultiFDSendParams *p, Error **errp)
             return -1;
         }
 
-        stat64_add(&mig_stats.multifd_bytes, p->packet_len);
+        qatomic_add(&mig_stats.multifd_bytes, p->packet_len);
     }
 
     return 0;
migration/multifd-zero-page.c +2 -2
index 4cde868159..00c330416a 100644
@@ -77,8 +77,8 @@ void multifd_send_zero_page_detect(MultiFDSendParams *p)
     pages->normal_num = i;
 
 out:
-    stat64_add(&mig_stats.normal_pages, pages->normal_num);
-    stat64_add(&mig_stats.zero_pages, pages->num - pages->normal_num);
+    qatomic_add(&mig_stats.normal_pages, pages->normal_num);
+    qatomic_add(&mig_stats.zero_pages, pages->num - pages->normal_num);
 }
 
 void multifd_recv_zero_page_process(MultiFDRecvParams *p)
migration/multifd.c +4 -8
index bf6da85af8..c9d4a67a46 100644
@@ -58,10 +58,6 @@ struct {
      * operations on both 32bit / 64 bits hosts.  It means on 32bit systems
      * multifd will overflow the packet_num easier, but that should be
      * fine.
-     *
-     * Another option is to use QEMU's Stat64 then it'll be 64 bits on all
-     * hosts, however so far it does not support atomic fetch_add() yet.
-     * Make it easy for now.
      */
     uintptr_t packet_num;
     /*
@@ -174,7 +170,7 @@ static int multifd_send_initial_packet(MultiFDSendParams *p, Error **errp)
     if (ret != 0) {
         return -1;
     }
-    stat64_add(&mig_stats.multifd_bytes, size);
+    qatomic_add(&mig_stats.multifd_bytes, size);
     return 0;
 }
 
@@ -607,7 +603,7 @@ static int multifd_zero_copy_flush(QIOChannel *c)
         return -1;
     }
     if (ret == 1) {
-        stat64_add(&mig_stats.dirty_sync_missed_zero_copy, 1);
+        qatomic_add(&mig_stats.dirty_sync_missed_zero_copy, 1);
     }
 
     return ret;
@@ -735,7 +731,7 @@ static void *multifd_send_thread(void *opaque)
                 break;
             }
 
-            stat64_add(&mig_stats.multifd_bytes, total_size);
+            qatomic_add(&mig_stats.multifd_bytes, total_size);
 
             p->next_packet_size = 0;
             multifd_send_data_clear(p->data);
@@ -766,7 +762,7 @@ static void *multifd_send_thread(void *opaque)
                     break;
                 }
                 /* p->next_packet_size will always be zero for a SYNC packet */
-                stat64_add(&mig_stats.multifd_bytes, p->packet_len);
+                qatomic_add(&mig_stats.multifd_bytes, p->packet_len);
             }
 
             qatomic_set(&p->pending_sync, MULTIFD_SYNC_NONE);
migration/qemu-file.c +3 -3
index 4b5a409a80..8d82d94416 100644
@@ -295,7 +295,7 @@ int qemu_fflush(QEMUFile *f)
             qemu_file_set_error_obj(f, -EIO, local_error);
         } else {
             uint64_t size = iov_size(f->iov, f->iovcnt);
-            stat64_add(&mig_stats.qemu_file_transferred, size);
+            qatomic_add(&mig_stats.qemu_file_transferred, size);
         }
 
         qemu_iovec_release_ram(f);
@@ -552,7 +552,7 @@ void qemu_put_buffer_at(QEMUFile *f, const uint8_t *buf, size_t buflen,
         return;
     }
 
-    stat64_add(&mig_stats.qemu_file_transferred, buflen);
+    qatomic_add(&mig_stats.qemu_file_transferred, buflen);
 }
 
 
@@ -785,7 +785,7 @@ int coroutine_mixed_fn qemu_get_byte(QEMUFile *f)
 
 uint64_t qemu_file_transferred(QEMUFile *f)
 {
-    uint64_t ret = stat64_get(&mig_stats.qemu_file_transferred);
+    uint64_t ret = qatomic_read(&mig_stats.qemu_file_transferred);
     int i;
 
     g_assert(qemu_file_is_writable(f));
migration/ram.c +15 -15
index 04958c5603..fc7ece2c1a 100644
@@ -479,11 +479,11 @@ uint64_t ram_bytes_remaining(void)
 void ram_transferred_add(uint64_t bytes)
 {
     if (runstate_is_running()) {
-        stat64_add(&mig_stats.precopy_bytes, bytes);
+        qatomic_add(&mig_stats.precopy_bytes, bytes);
     } else if (migration_in_postcopy()) {
-        stat64_add(&mig_stats.postcopy_bytes, bytes);
+        qatomic_add(&mig_stats.postcopy_bytes, bytes);
     } else {
-        stat64_add(&mig_stats.downtime_bytes, bytes);
+        qatomic_add(&mig_stats.downtime_bytes, bytes);
     }
 }
 
@@ -605,7 +605,7 @@ static void xbzrle_cache_zero_page(ram_addr_t current_addr)
     /* We don't care if this fails to allocate a new cache page
      * as long as it updated an old one */
     cache_insert(XBZRLE.cache, current_addr, XBZRLE.zero_target_page,
-                 stat64_get(&mig_stats.dirty_sync_count));
+                 qatomic_read(&mig_stats.dirty_sync_count));
 }
 
 #define ENCODING_FLAG_XBZRLE 0x1
@@ -631,7 +631,7 @@ static int save_xbzrle_page(RAMState *rs, PageSearchStatus *pss,
     int encoded_len = 0, bytes_xbzrle;
     uint8_t *prev_cached_page;
     QEMUFile *file = pss->pss_channel;
-    uint64_t generation = stat64_get(&mig_stats.dirty_sync_count);
+    uint64_t generation = qatomic_read(&mig_stats.dirty_sync_count);
 
     if (!cache_is_cached(XBZRLE.cache, current_addr, generation)) {
         xbzrle_counters.cache_miss++;
@@ -1035,9 +1035,9 @@ uint64_t ram_pagesize_summary(void)
 
 uint64_t ram_get_total_transferred_pages(void)
 {
-    return stat64_get(&mig_stats.normal_pages) +
-        stat64_get(&mig_stats.zero_pages) +
-        xbzrle_counters.pages;
+    return (qatomic_read(&mig_stats.normal_pages) +
+            qatomic_read(&mig_stats.zero_pages) +
+            xbzrle_counters.pages);
 }
 
 static void migration_update_rates(RAMState *rs, int64_t end_time)
@@ -1045,7 +1045,7 @@ static void migration_update_rates(RAMState *rs, int64_t end_time)
     uint64_t page_count = rs->target_page_count - rs->target_page_count_prev;
 
     /* calculate period counters */
-    stat64_set(&mig_stats.dirty_pages_rate,
+    qatomic_set(&mig_stats.dirty_pages_rate,
                rs->num_dirty_pages_period * 1000 /
                (end_time - rs->time_last_bitmap_sync));
 
@@ -1136,7 +1136,7 @@ static void migration_bitmap_sync(RAMState *rs, bool last_stage)
     RAMBlock *block;
     int64_t end_time;
 
-    stat64_add(&mig_stats.dirty_sync_count, 1);
+    qatomic_add(&mig_stats.dirty_sync_count, 1);
 
     if (!rs->time_last_bitmap_sync) {
         rs->time_last_bitmap_sync = qemu_clock_get_ms(QEMU_CLOCK_REALTIME);
@@ -1150,7 +1150,7 @@ static void migration_bitmap_sync(RAMState *rs, bool last_stage)
             RAMBLOCK_FOREACH_NOT_IGNORED(block) {
                 ramblock_sync_dirty_bitmap(rs, block);
             }
-            stat64_set(&mig_stats.dirty_bytes_last_sync, ram_bytes_remaining());
+            qatomic_set(&mig_stats.dirty_bytes_last_sync, ram_bytes_remaining());
         }
     }
 
@@ -1173,7 +1173,7 @@ static void migration_bitmap_sync(RAMState *rs, bool last_stage)
         rs->bytes_xfer_prev = migration_transferred_bytes();
     }
     if (migrate_events()) {
-        uint64_t generation = stat64_get(&mig_stats.dirty_sync_count);
+        uint64_t generation = qatomic_read(&mig_stats.dirty_sync_count);
         qapi_event_send_migration_pass(generation);
     }
 }
@@ -1232,7 +1232,7 @@ static int save_zero_page(RAMState *rs, PageSearchStatus *pss,
         return 0;
     }
 
-    stat64_add(&mig_stats.zero_pages, 1);
+    qatomic_add(&mig_stats.zero_pages, 1);
 
     if (migrate_mapped_ram()) {
         /* zero pages are not transferred with mapped-ram */
@@ -1291,7 +1291,7 @@ static int save_normal_page(PageSearchStatus *pss, RAMBlock *block,
         }
     }
     ram_transferred_add(TARGET_PAGE_SIZE);
-    stat64_add(&mig_stats.normal_pages, 1);
+    qatomic_add(&mig_stats.normal_pages, 1);
     return 1;
 }
 
@@ -1943,7 +1943,7 @@ int ram_save_queue_pages(const char *rbname, ram_addr_t start, ram_addr_t len,
     RAMBlock *ramblock;
     RAMState *rs = ram_state;
 
-    stat64_add(&mig_stats.postcopy_requests, 1);
+    qatomic_add(&mig_stats.postcopy_requests, 1);
     RCU_READ_LOCK_GUARD();
 
     if (!rbname) {
migration/rdma.c +4 -4
index 9e301cf917..cced173379 100644
@@ -1936,8 +1936,8 @@ retry:
                  * would think that head.len would be the more similar
                  * thing to a correct value.
                  */
-                stat64_add(&mig_stats.zero_pages,
-                           sge.length / qemu_target_page_size());
+                qatomic_add(&mig_stats.zero_pages,
+                            sge.length / qemu_target_page_size());
                 return 1;
             }
 
@@ -2045,7 +2045,7 @@ retry:
     }
 
     set_bit(chunk, block->transit_bitmap);
-    stat64_add(&mig_stats.normal_pages, sge.length / qemu_target_page_size());
+    qatomic_add(&mig_stats.normal_pages, sge.length / qemu_target_page_size());
     /*
      * We are adding to transferred the amount of data written, but no
      * overhead at all.  I will assume that RDMA is magicaly and don't
@@ -2055,7 +2055,7 @@ retry:
      *     sizeof(send_wr) + sge.length
      * but this being RDMA, who knows.
      */
-    stat64_add(&mig_stats.rdma_bytes, sge.length);
+    qatomic_add(&mig_stats.rdma_bytes, sge.length);
     ram_transferred_add(sge.length);
     rdma->total_writes++;
 
Signature · 1 line
2.43.0
Reviewed-by on v2 53/58
#66 lore raw

Re: [PATCH v2 53/58] migration: Drop use of Stat64

Quoted 5 lines · Richard Henderson

The Stat64 structure is an aid for 32-bit hosts, and is no longer required. Use plain 64-bit types.

Quoted 12 lines
---
  migration/migration-stats.h   | 36 ++++++++++++++++-------------------
  migration/cpu-throttle.c      |  4 ++--
  migration/migration-stats.c   | 16 ++++++++--------
  migration/migration.c         | 24 +++++++++++------------
  migration/multifd-nocomp.c    |  2 +-
  migration/multifd-zero-page.c |  4 ++--
  migration/multifd.c           | 12 ++++--------
  migration/qemu-file.c         |  6 +++---
  migration/ram.c               | 30 ++++++++++++++---------------
  migration/rdma.c              |  8 ++++----
  10 files changed, 67 insertions(+), 75 deletions(-)
#67 lore raw

PATCH v2 54/58 block: Drop use of Stat64

In reply to Richard Henderson

The Stat64 structure is an aid for 32-bit hosts, and is no longer required. Use plain 64-bit types.

---
 include/block/block_int-common.h |  3 +--
 block/io.c                       | 10 +++++++++-
 block/qapi.c                     |  2 +-
 3 files changed, 11 insertions(+), 4 deletions(-)
include/block/block_int-common.h +1 -2
index 6d0898e53d..9324af903d 100644
@@ -30,7 +30,6 @@
 #include "qemu/aiocb.h"
 #include "qemu/iov.h"
 #include "qemu/rcu.h"
-#include "qemu/stats64.h"
 
 #define BLOCK_FLAG_LAZY_REFCOUNTS   8
 
@@ -1246,7 +1245,7 @@ struct BlockDriverState {
     QLIST_HEAD(, BdrvDirtyBitmap) dirty_bitmaps;
 
     /* Offset after the highest byte written to */
-    Stat64 wr_highest_offset;
+    uint64_t wr_highest_offset;
 
     /*
      * If true, copy read backing sectors into image.  Can be >1 if more
block/io.c +9 -1
index cace297f22..e8fb4ede4d 100644
@@ -39,6 +39,7 @@
 #include "qemu/main-loop.h"
 #include "system/replay.h"
 #include "qemu/units.h"
+#include "qemu/atomic.h"
 
 /* Maximum bounce buffer for copy-on-read and write zeroes, in bytes */
 #define MAX_BOUNCE_BUFFER (32768 << BDRV_SECTOR_BITS)
@@ -2044,7 +2045,14 @@ bdrv_co_write_req_finish(BdrvChild *child, int64_t offset, int64_t bytes,
     if (req->bytes) {
         switch (req->type) {
         case BDRV_TRACKED_WRITE:
-            stat64_max(&bs->wr_highest_offset, offset + bytes);
+            {
+                uint64_t new = offset + bytes;
+                uint64_t old = qatomic_read(&bs->wr_highest_offset);
+
+                while (old < new) {
+                    old = qatomic_cmpxchg(&bs->wr_highest_offset, old, new);
+                }
+            }
             /* fall through, to set dirty bits */
         case BDRV_TRACKED_DISCARD:
             bdrv_set_dirty(bs, offset, bytes);
block/qapi.c +1 -1
index 9f5771e019..27e0ac6a32 100644
@@ -651,7 +651,7 @@ bdrv_query_bds_stats(BlockDriverState *bs, bool blk_level)
         s->node_name = g_strdup(bdrv_get_node_name(bs));
     }
 
-    s->stats->wr_highest_offset = stat64_get(&bs->wr_highest_offset);
+    s->stats->wr_highest_offset = qatomic_read(&bs->wr_highest_offset);
 
     s->driver_specific = bdrv_get_specific_stats(bs);
 
Signature · 1 line
2.43.0
#68 lore raw

PATCH v2 55/58 util: Remove stats64

In reply to Richard Henderson

This API is no longer used.

---
 include/qemu/stats64.h | 199 -----------------------------------------
 util/stats64.c         | 148 ------------------------------
 util/meson.build       |   1 -
 3 files changed, 348 deletions(-)
 delete mode 100644 include/qemu/stats64.h
 delete mode 100644 util/stats64.c
include/qemu/stats64.h deleted +0 -199
deleted file mode 100644
index 99b5cb724a..0000000000
@@ -1,199 +0,0 @@
-/*
- * Atomic operations on 64-bit quantities.
- *
- * Copyright (C) 2017 Red Hat, Inc.
- *
- * Author: Paolo Bonzini <[email protected]>
- *
- * This work is licensed under the terms of the GNU GPL, version 2 or later.
- * See the COPYING file in the top-level directory.
- */
-
-#ifndef QEMU_STATS64_H
-#define QEMU_STATS64_H
-
-#include "qemu/atomic.h"
-
-/* This provides atomic operations on 64-bit type, using a reader-writer
- * spinlock on architectures that do not have 64-bit accesses.  Even on
- * those architectures, it tries hard not to take the lock.
- */
-
-typedef struct Stat64 {
-#ifdef CONFIG_ATOMIC64
-    aligned_uint64_t value;
-#else
-    uint32_t low, high;
-    uint32_t lock;
-#endif
-} Stat64;
-
-#ifdef CONFIG_ATOMIC64
-static inline void stat64_init(Stat64 *s, uint64_t value)
-{
-    /* This is not guaranteed to be atomic! */
-    *s = (Stat64) { value };
-}
-
-static inline uint64_t stat64_get(const Stat64 *s)
-{
-    return qatomic_read__nocheck(&s->value);
-}
-
-static inline void stat64_set(Stat64 *s, uint64_t value)
-{
-    qatomic_set__nocheck(&s->value, value);
-}
-
-static inline void stat64_add(Stat64 *s, uint64_t value)
-{
-    qatomic_add(&s->value, value);
-}
-
-static inline void stat64_min(Stat64 *s, uint64_t value)
-{
-    uint64_t orig = qatomic_read__nocheck(&s->value);
-    while (orig > value) {
-        orig = qatomic_cmpxchg__nocheck(&s->value, orig, value);
-    }
-}
-
-static inline void stat64_max(Stat64 *s, uint64_t value)
-{
-    uint64_t orig = qatomic_read__nocheck(&s->value);
-    while (orig < value) {
-        orig = qatomic_cmpxchg__nocheck(&s->value, orig, value);
-    }
-}
-#else
-uint64_t stat64_get(const Stat64 *s);
-void stat64_set(Stat64 *s, uint64_t value);
-bool stat64_min_slow(Stat64 *s, uint64_t value);
-bool stat64_max_slow(Stat64 *s, uint64_t value);
-bool stat64_add32_carry(Stat64 *s, uint32_t low, uint32_t high);
-
-static inline void stat64_init(Stat64 *s, uint64_t value)
-{
-    /* This is not guaranteed to be atomic! */
-    *s = (Stat64) { .low = value, .high = value >> 32, .lock = 0 };
-}
-
-static inline void stat64_add(Stat64 *s, uint64_t value)
-{
-    uint32_t low, high;
-    high = value >> 32;
-    low = (uint32_t) value;
-    if (!low) {
-        if (high) {
-            qatomic_add(&s->high, high);
-        }
-        return;
-    }
-
-    for (;;) {
-        uint32_t orig = s->low;
-        uint32_t result = orig + low;
-        uint32_t old;
-
-        if (result < low || high) {
-            /* If the high part is affected, take the lock.  */
-            if (stat64_add32_carry(s, low, high)) {
-                return;
-            }
-            continue;
-        }
-
-        /* No carry, try with a 32-bit cmpxchg.  The result is independent of
-         * the high 32 bits, so it can race just fine with stat64_add32_carry
-         * and even stat64_get!
-         */
-        old = qatomic_cmpxchg(&s->low, orig, result);
-        if (orig == old) {
-            return;
-        }
-    }
-}
-
-static inline void stat64_min(Stat64 *s, uint64_t value)
-{
-    uint32_t low, high;
-    uint32_t orig_low, orig_high;
-
-    high = value >> 32;
-    low = (uint32_t) value;
-    do {
-        orig_high = qatomic_read(&s->high);
-        if (orig_high < high) {
-            return;
-        }
-
-        if (orig_high == high) {
-            /* High 32 bits are equal.  Read low after high, otherwise we
-             * can get a false positive (e.g. 0x1235,0x0000 changes to
-             * 0x1234,0x8000 and we read it as 0x1234,0x0000). Pairs with
-             * the write barrier in stat64_min_slow.
-             */
-            smp_rmb();
-            orig_low = qatomic_read(&s->low);
-            if (orig_low <= low) {
-                return;
-            }
-
-            /* See if we were lucky and a writer raced against us.  The
-             * barrier is theoretically unnecessary, but if we remove it
-             * we may miss being lucky.
-             */
-            smp_rmb();
-            orig_high = qatomic_read(&s->high);
-            if (orig_high < high) {
-                return;
-            }
-        }
-
-        /* If the value changes in any way, we have to take the lock.  */
-    } while (!stat64_min_slow(s, value));
-}
-
-static inline void stat64_max(Stat64 *s, uint64_t value)
-{
-    uint32_t low, high;
-    uint32_t orig_low, orig_high;
-
-    high = value >> 32;
-    low = (uint32_t) value;
-    do {
-        orig_high = qatomic_read(&s->high);
-        if (orig_high > high) {
-            return;
-        }
-
-        if (orig_high == high) {
-            /* High 32 bits are equal.  Read low after high, otherwise we
-             * can get a false positive (e.g. 0x1234,0x8000 changes to
-             * 0x1235,0x0000 and we read it as 0x1235,0x8000). Pairs with
-             * the write barrier in stat64_max_slow.
-             */
-            smp_rmb();
-            orig_low = qatomic_read(&s->low);
-            if (orig_low >= low) {
-                return;
-            }
-
-            /* See if we were lucky and a writer raced against us.  The
-             * barrier is theoretically unnecessary, but if we remove it
-             * we may miss being lucky.
-             */
-            smp_rmb();
-            orig_high = qatomic_read(&s->high);
-            if (orig_high > high) {
-                return;
-            }
-        }
-
-        /* If the value changes in any way, we have to take the lock.  */
-    } while (!stat64_max_slow(s, value));
-}
-
-#endif
-
-#endif
util/stats64.c deleted +0 -148

148 lines not on this page · raw message

util/meson.build +0 -1
index 35029380a3..d7d6b213f6 100644
@@ -59,7 +59,6 @@ util_ss.add(files('qht.c'))
 util_ss.add(files('qsp.c'))
 util_ss.add(files('range.c'))
 util_ss.add(files('reserved-region.c'))
-util_ss.add(files('stats64.c'))
 util_ss.add(files('systemd.c'))
 util_ss.add(files('transactions.c'))
 util_ss.add(files('guest-random.c'))
Signature · 1 line
2.43.0
Reviewed-by on v2 55/58
#69 lore raw

Re: [PATCH v2 55/58] util: Remove stats64

Quoted 11 lines · Richard Henderson

This API is no longer used.

---
  include/qemu/stats64.h | 199 -----------------------------------------
  util/stats64.c         | 148 ------------------------------
  util/meson.build       |   1 -
  3 files changed, 348 deletions(-)

delete mode 100644 include/qemu/stats64.h
delete mode 100644 util/stats64.c

#70 lore raw

PATCH v2 56/58 include/qemu/atomic: Drop qatomic_{read,set}_[iu]64

In reply to Richard Henderson

Replace all uses with the normal qatomic_{read,set}.

---
 include/qemu/atomic.h      | 22 ----------
 accel/qtest/qtest.c        |  4 +-
 accel/tcg/icount-common.c  | 25 ++++++-----
 system/dirtylimit.c        |  2 +-
 tests/unit/test-rcu-list.c | 17 ++++----
 util/atomic64.c            | 85 --------------------------------------
 util/cacheflush.c          |  2 -
 util/qsp.c                 |  8 ++--
 util/meson.build           |  3 --
 9 files changed, 27 insertions(+), 141 deletions(-)
 delete mode 100644 util/atomic64.c
include/qemu/atomic.h +0 -22
index c39dc99f2f..27d98014d4 100644
@@ -247,26 +247,4 @@
 typedef int64_t aligned_int64_t __attribute__((aligned(8)));
 typedef uint64_t aligned_uint64_t __attribute__((aligned(8)));
 
-#ifdef CONFIG_ATOMIC64
-/* Use __nocheck because sizeof(void *) might be < sizeof(u64) */
-#define qatomic_read_i64(P) \
-    _Generic(*(P), int64_t: qatomic_read__nocheck(P))
-#define qatomic_read_u64(P) \
-    _Generic(*(P), uint64_t: qatomic_read__nocheck(P))
-#define qatomic_set_i64(P, V) \
-    _Generic(*(P), int64_t: qatomic_set__nocheck(P, V))
-#define qatomic_set_u64(P, V) \
-    _Generic(*(P), uint64_t: qatomic_set__nocheck(P, V))
-
-static inline void qatomic64_init(void)
-{
-}
-#else /* !CONFIG_ATOMIC64 */
-int64_t  qatomic_read_i64(const int64_t *ptr);
-uint64_t qatomic_read_u64(const uint64_t *ptr);
-void qatomic_set_i64(int64_t *ptr, int64_t val);
-void qatomic_set_u64(uint64_t *ptr, uint64_t val);
-void qatomic64_init(void);
-#endif /* !CONFIG_ATOMIC64 */
-
 #endif /* QEMU_ATOMIC_H */
accel/qtest/qtest.c +2 -2
index 1d4337d698..bb1491d93b 100644
@@ -31,12 +31,12 @@ static int64_t qtest_clock_counter;
 
 static int64_t qtest_get_virtual_clock(void)
 {
-    return qatomic_read_i64(&qtest_clock_counter);
+    return qatomic_read(&qtest_clock_counter);
 }
 
 static void qtest_set_virtual_clock(int64_t count)
 {
-    qatomic_set_i64(&qtest_clock_counter, count);
+    qatomic_set(&qtest_clock_counter, count);
 }
 
 static int qtest_init_accel(AccelState *as, MachineState *ms)
accel/tcg/icount-common.c +12 -13
index d6471174a3..b1b6c005fe 100644
@@ -86,8 +86,8 @@ static void icount_update_locked(CPUState *cpu)
     int64_t executed = icount_get_executed(cpu);
     cpu->icount_budget -= executed;
 
-    qatomic_set_i64(&timers_state.qemu_icount,
-                    timers_state.qemu_icount + executed);
+    qatomic_set(&timers_state.qemu_icount,
+                timers_state.qemu_icount + executed);
 }
 
 /*
@@ -116,15 +116,14 @@ static int64_t icount_get_raw_locked(void)
         /* Take into account what has run */
         icount_update_locked(cpu);
     }
-    /* The read is protected by the seqlock, but needs atomic64 to avoid UB */
-    return qatomic_read_i64(&timers_state.qemu_icount);
+    /* The read is protected by the seqlock, but needs atomic to avoid UB */
+    return qatomic_read(&timers_state.qemu_icount);
 }
 
 static int64_t icount_get_locked(void)
 {
     int64_t icount = icount_get_raw_locked();
-    return qatomic_read_i64(&timers_state.qemu_icount_bias) +
-        icount_to_ns(icount);
+    return qatomic_read(&timers_state.qemu_icount_bias) + icount_to_ns(icount);
 }
 
 int64_t icount_get_raw(void)
@@ -201,9 +200,9 @@ static void icount_adjust(void)
                     timers_state.icount_time_shift + 1);
     }
     timers_state.last_delta = delta;
-    qatomic_set_i64(&timers_state.qemu_icount_bias,
-                    cur_icount - (timers_state.qemu_icount
-                                  << timers_state.icount_time_shift));
+    qatomic_set(&timers_state.qemu_icount_bias,
+                cur_icount - (timers_state.qemu_icount
+                              << timers_state.icount_time_shift));
     seqlock_write_unlock(&timers_state.vm_clock_seqlock,
                          &timers_state.vm_clock_lock);
 }
@@ -269,8 +268,8 @@ static void icount_warp_rt(void)
             }
             warp_delta = MIN(warp_delta, delta);
         }
-        qatomic_set_i64(&timers_state.qemu_icount_bias,
-                        timers_state.qemu_icount_bias + warp_delta);
+        qatomic_set(&timers_state.qemu_icount_bias,
+                    timers_state.qemu_icount_bias + warp_delta);
     }
     timers_state.vm_clock_warp_start = -1;
     seqlock_write_unlock(&timers_state.vm_clock_seqlock,
@@ -361,8 +360,8 @@ void icount_start_warp_timer(void)
              */
             seqlock_write_lock(&timers_state.vm_clock_seqlock,
                                &timers_state.vm_clock_lock);
-            qatomic_set_i64(&timers_state.qemu_icount_bias,
-                            timers_state.qemu_icount_bias + deadline);
+            qatomic_set(&timers_state.qemu_icount_bias,
+                        timers_state.qemu_icount_bias + deadline);
             seqlock_write_unlock(&timers_state.vm_clock_seqlock,
                                  &timers_state.vm_clock_lock);
             qemu_clock_notify(QEMU_CLOCK_VIRTUAL);
system/dirtylimit.c +1 -1
index a0c327533c..50fa67f3d6 100644
@@ -123,7 +123,7 @@ static void *vcpu_dirty_rate_stat_thread(void *opaque)
 int64_t vcpu_dirty_rate_get(int cpu_index)
 {
     DirtyRateVcpu *rates = vcpu_dirty_rate_stat->stat.rates;
-    return qatomic_read_i64(&rates[cpu_index].dirty_rate);
+    return qatomic_read(&rates[cpu_index].dirty_rate);
 }
 
 void vcpu_dirty_rate_stat_start(void)
tests/unit/test-rcu-list.c +8 -9
index 8f0adb8b00..8dde3e61a8 100644
@@ -105,7 +105,7 @@ static void reclaim_list_el(struct rcu_head *prcu)
     struct list_element *el = container_of(prcu, struct list_element, rcu);
     g_free(el);
     /* Accessed only from call_rcu thread.  */
-    qatomic_set_i64(&n_reclaims, n_reclaims + 1);
+    qatomic_set(&n_reclaims, n_reclaims + 1);
 }
 
 #if TEST_LIST_TYPE == 1
@@ -247,7 +247,7 @@ static void *rcu_q_updater(void *arg)
     qemu_mutex_lock(&counts_mutex);
     n_nodes += n_nodes_local;
     n_updates += n_updates_local;
-    qatomic_set_i64(&n_nodes_removed, n_nodes_removed + n_removed_local);
+    qatomic_set(&n_nodes_removed, n_nodes_removed + n_removed_local);
     qemu_mutex_unlock(&counts_mutex);
     return NULL;
 }
@@ -301,23 +301,22 @@ static void rcu_qtest(const char *test, int duration, int nreaders)
         n_removed_local++;
     }
     qemu_mutex_lock(&counts_mutex);
-    qatomic_set_i64(&n_nodes_removed, n_nodes_removed + n_removed_local);
+    qatomic_set(&n_nodes_removed, n_nodes_removed + n_removed_local);
     qemu_mutex_unlock(&counts_mutex);
     synchronize_rcu();
-    while (qatomic_read_i64(&n_nodes_removed) >
-           qatomic_read_i64(&n_reclaims)) {
+    while (qatomic_read(&n_nodes_removed) > qatomic_read(&n_reclaims)) {
         g_usleep(100);
         synchronize_rcu();
     }
     if (g_test_in_charge) {
-        g_assert_cmpint(qatomic_read_i64(&n_nodes_removed), ==,
-                        qatomic_read_i64(&n_reclaims));
+        g_assert_cmpint(qatomic_read(&n_nodes_removed), ==,
+                        qatomic_read(&n_reclaims));
     } else {
         printf("%s: %d readers; 1 updater; nodes read: "  \
                "%lld, nodes removed: %"PRIi64"; nodes reclaimed: %"PRIi64"\n",
                test, nthreadsrunning - 1, n_reads,
-               qatomic_read_i64(&n_nodes_removed),
-               qatomic_read_i64(&n_reclaims));
+               qatomic_read(&n_nodes_removed),
+               qatomic_read(&n_reclaims));
         exit(0);
     }
 }
util/atomic64.c deleted +0 -85

85 lines not on this page · raw message

util/cacheflush.c +0 -2
index 99221a409f..c043c5f881 100644
@@ -216,8 +216,6 @@ static void __attribute__((constructor)) init_cache_info(void)
     qemu_icache_linesize_log = ctz32(isize);
     qemu_dcache_linesize = dsize;
     qemu_dcache_linesize_log = ctz32(dsize);
-
-    qatomic64_init();
 }
 
 
util/qsp.c +4 -4
index 6b783e2e7f..382e4397e2 100644
@@ -346,9 +346,9 @@ static QSPEntry *qsp_entry_get(const void *obj, const char *file, int line,
  */
 static inline void do_qsp_entry_record(QSPEntry *e, int64_t delta, bool acq)
 {
-    qatomic_set_u64(&e->ns, e->ns + delta);
+    qatomic_set(&e->ns, e->ns + delta);
     if (acq) {
-        qatomic_set_u64(&e->n_acqs, e->n_acqs + 1);
+        qatomic_set(&e->n_acqs, e->n_acqs + 1);
     }
 }
 
@@ -538,8 +538,8 @@ static void qsp_aggregate(void *p, uint32_t h, void *up)
      * The entry is in the global hash table; read from it atomically (as in
      * "read once").
      */
-    agg->ns += qatomic_read_u64(&e->ns);
-    agg->n_acqs += qatomic_read_u64(&e->n_acqs);
+    agg->ns += qatomic_read(&e->ns);
+    agg->n_acqs += qatomic_read(&e->n_acqs);
 }
 
 static void qsp_iter_diff(void *p, uint32_t hash, void *htp)
util/meson.build +0 -3
index d7d6b213f6..59e835a8d3 100644
@@ -1,8 +1,5 @@
 util_ss.add(files('osdep.c', 'cutils.c', 'unicode.c', 'qemu-timer-common.c'))
 util_ss.add(files('thread-context.c'), numa)
-if not config_host_data.get('CONFIG_ATOMIC64')
-  util_ss.add(files('atomic64.c'))
-endif
 if host_os != 'windows'
   util_ss.add(files('aio-posix.c'))
   util_ss.add(files('fdmon-poll.c'))
Signature · 1 line
2.43.0
#71 lore raw

PATCH v2 57/58 meson: Remove CONFIG_ATOMIC64

In reply to Richard Henderson

This config is no longer used.

---
 meson.build | 16 ----------------
 1 file changed, 16 deletions(-)
meson.build +0 -16
index 0189d8fd44..3108f01e88 100644
@@ -2939,22 +2939,6 @@ config_host_data.set('HAVE_BROKEN_SIZE_MAX', not cc.compiles('''
         return printf("%zu", SIZE_MAX);
     }''', args: ['-Werror']))
 
-# See if 64-bit atomic operations are supported.
-# Note that without __atomic builtins, we can only
-# assume atomic loads/stores max at pointer size.
-config_host_data.set('CONFIG_ATOMIC64', cc.links('''
-  #include <stdint.h>
-  int main(void)
-  {
-    uint64_t x = 0, y = 0;
-    y = __atomic_load_n(&x, __ATOMIC_RELAXED);
-    __atomic_store_n(&x, y, __ATOMIC_RELAXED);
-    __atomic_compare_exchange_n(&x, &y, x, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED);
-    __atomic_exchange_n(&x, y, __ATOMIC_RELAXED);
-    __atomic_fetch_add(&x, y, __ATOMIC_RELAXED);
-    return 0;
-  }''', args: qemu_isa_flags))
-
 # has_int128_type is set to false on Emscripten to avoid errors by libffi
 # during runtime.
 has_int128_type = host_os != 'emscripten' and cc.compiles('''
Signature · 1 line
2.43.0
#72 lore raw

PATCH v2 58/58 include/qemu/atomic: Drop aligned_{u}int64_t

In reply to Richard Henderson

As we no longer support i386 as a host architecture, this abstraction is no longer required.

---
 accel/tcg/atomic_template.h          |  4 ++--
 include/qemu/atomic.h                | 13 -------------
 include/system/cpu-timers-internal.h |  2 +-
 linux-user/hppa/cpu_loop.c           |  2 +-
 util/qsp.c                           |  4 ++--
 5 files changed, 6 insertions(+), 19 deletions(-)
accel/tcg/atomic_template.h +2 -2
index ae5203b439..f7924078f7 100644
@@ -27,8 +27,8 @@
 # define SHIFT      4
 #elif DATA_SIZE == 8
 # define SUFFIX     q
-# define DATA_TYPE  aligned_uint64_t
-# define SDATA_TYPE aligned_int64_t
+# define DATA_TYPE  uint64_t
+# define SDATA_TYPE int64_t
 # define BSWAP      bswap64
 # define SHIFT      3
 #elif DATA_SIZE == 4
include/qemu/atomic.h +0 -13
index 27d98014d4..dc9290084b 100644
@@ -234,17 +234,4 @@
     _oldn;                                                              \
 })
 
-/*
- * Abstractions to access atomically (i.e. "once") i64/u64 variables.
- *
- * The i386 abi is odd in that by default members are only aligned to
- * 4 bytes, which means that 8-byte types can wind up mis-aligned.
- * Clang will then warn about this, and emit a call into libatomic.
- *
- * Use of these types in structures when they will be used with atomic
- * operations can avoid this.
- */
-typedef int64_t aligned_int64_t __attribute__((aligned(8)));
-typedef uint64_t aligned_uint64_t __attribute__((aligned(8)));
-
 #endif /* QEMU_ATOMIC_H */
include/system/cpu-timers-internal.h +1 -1
index 94bb7394c5..8c262ce139 100644
@@ -47,7 +47,7 @@ typedef struct TimersState {
     int64_t last_delta;
 
     /* Compensate for varying guest execution speed.  */
-    aligned_int64_t qemu_icount_bias;
+    int64_t qemu_icount_bias;
 
     int64_t vm_clock_warp_start;
     int64_t cpu_clock_offset;
linux-user/hppa/cpu_loop.c +1 -1
index e5c0f52d94..972e85c487 100644
@@ -83,7 +83,7 @@ static abi_ulong hppa_lws(CPUHPPAState *env)
                 uint64_t o64, n64, r64;
                 o64 = *(uint64_t *)g2h(cs, old);
                 n64 = *(uint64_t *)g2h(cs, new);
-                r64 = qatomic_cmpxchg((aligned_uint64_t *)g2h(cs, addr), o64, n64);
+                r64 = qatomic_cmpxchg((uint64_t *)g2h(cs, addr), o64, n64);
                 ret = r64 != o64;
             }
             break;
util/qsp.c +2 -2
index 382e4397e2..55477ae025 100644
@@ -83,8 +83,8 @@ typedef struct QSPCallSite QSPCallSite;
 struct QSPEntry {
     void *thread_ptr;
     const QSPCallSite *callsite;
-    aligned_uint64_t n_acqs;
-    aligned_uint64_t ns;
+    uint64_t n_acqs;
+    uint64_t ns;
     unsigned int n_objs; /* count of coalesced objs; only used for reporting */
 };
 typedef struct QSPEntry QSPEntry;
Signature · 1 line
2.43.0