mbox series

[v2,00/29] tcg: bswap improvements

Message ID 20210621231849.1871164-1-richard.henderson@linaro.org
Headers show
Series tcg: bswap improvements | expand

Message

Richard Henderson June 21, 2021, 11:18 p.m. UTC
This has been on my to-do list for several years, and I've
finally spent a rainy weekend doing something about it.

The current tcg bswap opcode is fairly strict: for swaps smaller
than the TCGv size, it requires zero-extended input and provides
zero-extended output.

This has meant that various tcg/ backends have their own handling
of bswap when it comes to memory, to minimize overhead for stores
(which do not care about zero-extended output) or for signed loads
(which would rather not sign-extend after zero-extending).

Solve this by adding some operation flags to the tcg bswap opcode:

  TCG_BSWAP_IZ  -- Input is Zero extended
  TCG_BSWAP_OZ  -- Output is Zero extended
  TCG_BSWAP_OS  -- Output is Sign extended

For instance, bswap before store would not set any of these flags,
allowing unextended input and producing unextended output.

Changes for v2:
  * Merge tcg_out_rev{16,32,64}, which perhaps solves the issue of
    mnemonics vs actual opcodes, and also preps for Phil suggestion
    of adding additional tcg opcodes for hswap and wswap operations.
  * Improve comments for ppc bswap.
  * Improve README entries.

Patches lacking review/ack:

  03-tcg-aarch64-Merge-tcg_out_rev-16-32-64.patch
  11-tcg-ppc-Support-bswap-flags.patch
  12-tcg-ppc-Use-power10-byte-reverse-instructions.patch
  13-tcg-s390-Support-bswap-flags.patch
  14-tcg-mips-Support-bswap-flags-in-tcg_out_bswap16.patch


r~


Richard Henderson (29):
  tcg: Add flags argument to bswap opcodes
  tcg/i386: Support bswap flags
  tcg/aarch64: Merge tcg_out_rev{16,32,64}
  tcg/aarch64: Support bswap flags
  tcg/arm: Support bswap flags
  tcg/ppc: Split out tcg_out_ext{8,16,32}s
  tcg/ppc: Split out tcg_out_sari{32,64}
  tcg/ppc: Split out tcg_out_bswap16
  tcg/ppc: Split out tcg_out_bswap32
  tcg/ppc: Split out tcg_out_bswap64
  tcg/ppc: Support bswap flags
  tcg/ppc: Use power10 byte-reverse instructions
  tcg/s390: Support bswap flags
  tcg/mips: Support bswap flags in tcg_out_bswap16
  tcg/mips: Support bswap flags in tcg_out_bswap32
  tcg/tci: Support bswap flags
  tcg: Handle new bswap flags during optimize
  tcg: Add flags argument to tcg_gen_bswap16_*, tcg_gen_bswap32_i64
  tcg: Make use of bswap flags in tcg_gen_qemu_ld_*
  tcg: Make use of bswap flags in tcg_gen_qemu_st_*
  target/arm: Improve REV32
  target/arm: Improve vector REV
  target/arm: Improve REVSH
  target/i386: Improve bswap translation
  target/sh4: Improve swap.b translation
  target/mips: Fix gen_mxu_s32ldd_s32lddr
  tcg/arm: Unset TCG_TARGET_HAS_MEMORY_BSWAP
  tcg/aarch64: Unset TCG_TARGET_HAS_MEMORY_BSWAP
  tcg/riscv: Remove MO_BSWAP handling

 include/tcg/tcg-op.h            |   8 +-
 include/tcg/tcg-opc.h           |  10 +-
 include/tcg/tcg.h               |  12 ++
 tcg/aarch64/tcg-target.h        |   2 +-
 tcg/arm/tcg-target.h            |   2 +-
 target/arm/translate-a64.c      |  21 +--
 target/arm/translate.c          |   4 +-
 target/i386/tcg/translate.c     |  14 +-
 target/mips/tcg/mxu_translate.c |   6 +-
 target/s390x/translate.c        |   4 +-
 target/sh4/translate.c          |   3 +-
 tcg/optimize.c                  |  56 +++++-
 tcg/tcg-op.c                    | 143 ++++++++++------
 tcg/tcg.c                       |  28 +++
 tcg/tci.c                       |   3 +-
 tcg/aarch64/tcg-target.c.inc    | 125 ++++++--------
 tcg/arm/tcg-target.c.inc        | 295 ++++++++++++++------------------
 tcg/i386/tcg-target.c.inc       |  20 ++-
 tcg/mips/tcg-target.c.inc       |  99 +++++------
 tcg/ppc/tcg-target.c.inc        | 230 +++++++++++++++++--------
 tcg/riscv/tcg-target.c.inc      |  64 +++----
 tcg/s390/tcg-target.c.inc       |  34 +++-
 tcg/tci/tcg-target.c.inc        |  23 ++-
 tcg/README                      |  22 ++-
 24 files changed, 702 insertions(+), 526 deletions(-)

-- 
2.25.1

Comments

no-reply@patchew.org June 21, 2021, 11:45 p.m. UTC | #1
Patchew URL: https://patchew.org/QEMU/20210621231849.1871164-1-richard.henderson@linaro.org/



Hi,

This series seems to have some coding style problems. See output below for
more information:

Type: series
Message-id: 20210621231849.1871164-1-richard.henderson@linaro.org
Subject: [PATCH v2 00/29] tcg: bswap improvements

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
 * [new tag]         patchew/20210621231849.1871164-1-richard.henderson@linaro.org -> patchew/20210621231849.1871164-1-richard.henderson@linaro.org
Switched to a new branch 'test'
8a1ce95 tcg/riscv: Remove MO_BSWAP handling
042d928 tcg/aarch64: Unset TCG_TARGET_HAS_MEMORY_BSWAP
b12d261 tcg/arm: Unset TCG_TARGET_HAS_MEMORY_BSWAP
a72e94c target/mips: Fix gen_mxu_s32ldd_s32lddr
8c44e92 target/sh4: Improve swap.b translation
5def832 target/i386: Improve bswap translation
c558d58 target/arm: Improve REVSH
465157c target/arm: Improve vector REV
1fbd37e target/arm: Improve REV32
c0a1731 tcg: Make use of bswap flags in tcg_gen_qemu_st_*
446bceb tcg: Make use of bswap flags in tcg_gen_qemu_ld_*
6001384 tcg: Add flags argument to tcg_gen_bswap16_*, tcg_gen_bswap32_i64
a38add9 tcg: Handle new bswap flags during optimize
8152e2f tcg/tci: Support bswap flags
ed16867 tcg/mips: Support bswap flags in tcg_out_bswap32
1c402bf tcg/mips: Support bswap flags in tcg_out_bswap16
a21ddba tcg/s390: Support bswap flags
4c9ee2c tcg/ppc: Use power10 byte-reverse instructions
258cd29 tcg/ppc: Support bswap flags
dda8631 tcg/ppc: Split out tcg_out_bswap64
cced49b tcg/ppc: Split out tcg_out_bswap32
248ebec tcg/ppc: Split out tcg_out_bswap16
7d61b03 tcg/ppc: Split out tcg_out_sari{32,64}
69f510f tcg/ppc: Split out tcg_out_ext{8,16,32}s
fd998ad tcg/arm: Support bswap flags
2bf67ce tcg/aarch64: Support bswap flags
b14d4b1 tcg/aarch64: Merge tcg_out_rev{16,32,64}
47f04bc tcg/i386: Support bswap flags
a013bcf tcg: Add flags argument to bswap opcodes

=== OUTPUT BEGIN ===
1/29 Checking commit a013bcf9920f (tcg: Add flags argument to bswap opcodes)
2/29 Checking commit 47f04bcfbd3c (tcg/i386: Support bswap flags)
3/29 Checking commit b14d4b1a15d3 (tcg/aarch64: Merge tcg_out_rev{16,32,64})
4/29 Checking commit 2bf67ce46f28 (tcg/aarch64: Support bswap flags)
5/29 Checking commit fd998ad55098 (tcg/arm: Support bswap flags)
6/29 Checking commit 69f510fc9ccf (tcg/ppc: Split out tcg_out_ext{8,16,32}s)
7/29 Checking commit 7d61b03fe7f7 (tcg/ppc: Split out tcg_out_sari{32,64})
8/29 Checking commit 248ebecd716e (tcg/ppc: Split out tcg_out_bswap16)
9/29 Checking commit cced49b22079 (tcg/ppc: Split out tcg_out_bswap32)
10/29 Checking commit dda86314b2df (tcg/ppc: Split out tcg_out_bswap64)
11/29 Checking commit 258cd29045b2 (tcg/ppc: Support bswap flags)
12/29 Checking commit 4c9ee2ce7bfe (tcg/ppc: Use power10 byte-reverse instructions)
13/29 Checking commit a21ddba7adfd (tcg/s390: Support bswap flags)
14/29 Checking commit 1c402bf4ea32 (tcg/mips: Support bswap flags in tcg_out_bswap16)
15/29 Checking commit ed16867a8514 (tcg/mips: Support bswap flags in tcg_out_bswap32)
16/29 Checking commit 8152e2fbe20b (tcg/tci: Support bswap flags)
17/29 Checking commit a38add98a8cd (tcg: Handle new bswap flags during optimize)
ERROR: spaces required around that ':' (ctx:VxE)
#41: FILE: tcg/optimize.c:1033:
+        CASE_OP_32_64(bswap16):
                               ^

ERROR: spaces required around that ':' (ctx:VxE)
#94: FILE: tcg/optimize.c:1188:
+        CASE_OP_32_64(bswap16):
                               ^

ERROR: spaces required around that ':' (ctx:VxE)
#95: FILE: tcg/optimize.c:1189:
+        CASE_OP_32_64(bswap32):
                               ^

total: 3 errors, 0 warnings, 82 lines checked

Patch 17/29 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

18/29 Checking commit 6001384c5d55 (tcg: Add flags argument to tcg_gen_bswap16_*, tcg_gen_bswap32_i64)
ERROR: code indent should never use tabs
#165: FILE: target/sh4/translate.c:680:
+^I    tcg_gen_bswap16_i32(low, low, TCG_BSWAP_IZ | TCG_BSWAP_OZ);$

total: 1 errors, 0 warnings, 296 lines checked

Patch 18/29 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

19/29 Checking commit 446bcebe129b (tcg: Make use of bswap flags in tcg_gen_qemu_ld_*)
20/29 Checking commit c0a1731ecfa5 (tcg: Make use of bswap flags in tcg_gen_qemu_st_*)
21/29 Checking commit 1fbd37ebe67c (target/arm: Improve REV32)
22/29 Checking commit 465157cd1fae (target/arm: Improve vector REV)
23/29 Checking commit c558d5861f46 (target/arm: Improve REVSH)
24/29 Checking commit 5def83230457 (target/i386: Improve bswap translation)
25/29 Checking commit 8c44e9208531 (target/sh4: Improve swap.b translation)
ERROR: code indent should never use tabs
#26: FILE: target/sh4/translate.c:679:
+^I    tcg_gen_bswap16_i32(low, REG(B7_4), 0);$

total: 1 errors, 0 warnings, 9 lines checked

Patch 25/29 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

26/29 Checking commit a72e94c577a2 (target/mips: Fix gen_mxu_s32ldd_s32lddr)
27/29 Checking commit b12d261e534a (tcg/arm: Unset TCG_TARGET_HAS_MEMORY_BSWAP)
28/29 Checking commit 042d928a69ef (tcg/aarch64: Unset TCG_TARGET_HAS_MEMORY_BSWAP)
29/29 Checking commit 8a1ce95c40b9 (tcg/riscv: Remove MO_BSWAP handling)
=== OUTPUT END ===

Test command exited with code: 1


The full log is available at
http://patchew.org/logs/20210621231849.1871164-1-richard.henderson@linaro.org/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com