qemu/tcg
Huang Shiyuan f63e7089b4 tcg/riscv: Add basic support for vector
The RISC-V vector instruction set utilizes the LMUL field to group
multiple registers, enabling variable-length vector registers. This
implementation uses only the first register number of each group while
reserving the other register numbers within the group.

In TCG, each VEC_IR can have 3 types (TCG_TYPE_V64/128/256), and the
host runtime needs to adjust LMUL based on the type to use different
register groups.

This presents challenges for TCG's register allocation. Currently, we
avoid modifying the register allocation part of TCG and only expose the
minimum number of vector registers.

For example, when the host vlen is 64 bits and type is TCG_TYPE_V256, with
LMUL equal to 4, we use 4 vector registers as one register group. We can
use a maximum of 8 register groups, but the V0 register number is reserved
as a mask register, so we can effectively use at most 7 register groups.
Moreover, when type is smaller than TCG_TYPE_V256, only 7 registers are
forced to be used. This is because TCG cannot yet dynamically constrain
registers with type; likewise, when the host vlen is 128 bits and
TCG_TYPE_V256, we can use at most 15 registers.

There is not much pressure on vector register allocation in TCG now, so
using 7 registers is feasible and will not have a major impact on code
generation.

This patch:
1. Reserves vector register 0 for use as a mask register.
2. When using register groups, reserves the additional registers within
   each group.

Signed-off-by: Huang Shiyuan <swung0x48@outlook.com>
Co-authored-by: TANG Tiancheng <tangtiancheng.ttc@alibaba-inc.com>
Signed-off-by: TANG Tiancheng <tangtiancheng.ttc@alibaba-inc.com>
Reviewed-by: Liu Zhiwei <zhiwei_liu@linux.alibaba.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20241007025700.47259-3-zhiwei_liu@linux.alibaba.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2024-10-22 11:57:25 -07:00
..
aarch64 tcg/aarch64: Support TCG_TARGET_HAS_tst_vec 2024-05-22 19:05:25 -07:00
arm include/exec/memop: Rename get_alignment_bits 2024-10-13 11:27:03 -07:00
i386 tcg/i386: Implement vector TST{EQ,NE} for avx512 2024-09-22 06:54:50 +02:00
loongarch64 tcg/loongarch64: remove break after g_assert_not_reached() 2024-09-24 13:53:35 +02:00
mips tcg: Add TCGConst argument to tcg_target_const_match 2024-02-03 23:53:48 +00:00
ppc tcg/ppc: Use TCG_REG_TMP2 for scratch index in prepare_host_addr 2024-10-08 06:40:31 -07:00
riscv tcg/riscv: Add basic support for vector 2024-10-22 11:57:25 -07:00
s390x tcg/s390x: fix constraint for 32-bit TSTEQ/TSTNE 2024-10-17 19:41:22 +02:00
sparc64 include/exec/memop: Rename get_alignment_bits 2024-10-13 11:27:03 -07:00
tci tcg/tci: Support TCG_COND_TST{EQ,NE} 2024-02-05 22:45:41 +00:00
debuginfo.c accel/tcg: Move perf and debuginfo support to tcg/ 2024-01-29 21:04:10 +10:00
meson.build meson: Drop the .fa library suffix 2024-07-03 18:41:26 +02:00
optimize.c tcg/optimize: Optimize bitsel_vec 2024-09-22 06:54:49 +02:00
perf.c accel/tcg: Move perf and debuginfo support to tcg/ 2024-01-29 21:04:10 +10:00
region.c tcg: Make the cleanup-on-error path unique 2024-01-23 13:22:46 +10:00
tcg-common.c tcg: Silent -Wmissing-field-initializers warning 2023-02-27 22:29:01 +01:00
tcg-internal.h tcg: Export vec_gen_6 2024-09-22 06:54:49 +02:00
tcg-ldst.c.inc tcg: Move TCGLabelQemuLdst to tcg.c 2023-05-05 17:21:03 +01:00
tcg-op-gvec.c tcg: Fix iteration step in 32-bit gvec operation 2024-09-22 06:54:49 +02:00
tcg-op-ldst.c include/exec/memop: Rename get_alignment_bits 2024-10-13 11:27:03 -07:00
tcg-op-vec.c tcg: Export vec_gen_6 2024-09-22 06:54:49 +02:00
tcg-op.c tcg: Propagate new TCGOp to add_as_label_use 2024-09-22 06:54:49 +02:00
tcg-pool.c.inc tcg: Introduce tcg_splitwx_to_{rx,rw} 2021-01-07 05:09:41 -10:00
tcg.c tcg: Reset data_gen_ptr correctly 2024-10-22 11:57:25 -07:00
tci.c tcg: Make tcg/helper-info.h self-contained 2024-04-30 16:12:05 -07:00