]> git.ipfire.org Git - thirdparty/gcc.git/commit
RISC-V: Handle differences between XTheadvector and Vector
authorJun Sha (Joshua) <cooper.joshua@linux.alibaba.com>
Fri, 12 Jan 2024 03:22:10 +0000 (11:22 +0800)
committerChristoph Müllner <christoph.muellner@vrull.eu>
Thu, 18 Jan 2024 14:38:35 +0000 (15:38 +0100)
commit2d7205eb2c3b175a86aab92bb652314f308f9c05
tree5a01c87d4e6b9fb969fb79bc64af2417043a0690
parent9a55cc625c5f4b0318b16173b20dcab80cff03a1
RISC-V: Handle differences between XTheadvector and Vector

This patch is to handle the differences in instruction generation
between Vector and XTheadVector. In this version, we only support
partial xtheadvector instructions that leverage directly from current
RVV1.0 with simple adding "th." prefix. For different name xtheadvector
instructions but share same patterns as RVV1.0 instructions, we will
use ASM targethook to rewrite the whole string of the instructions in
the following patches.

For some vector patterns that cannot be avoided, we use
"!TARGET_XTHEADVECTOR" to disable them in vector.md in order
not to generate instructions that xtheadvector does not support,
like vmv1r.

gcc/ChangeLog:

* config.gcc:  Add files for XTheadVector intrinsics.
* config/riscv/autovec.md: Guard XTheadVector.
* config/riscv/predicates.md: Disable immediate vl
for XTheadVector.
* config/riscv/riscv-c.cc (riscv_pragma_intrinsic):
Add pragma for XTheadVector.
* config/riscv/riscv-string.cc (riscv_expand_block_move):
Guard XTheadVector.
* config/riscv/riscv-v.cc (vls_mode_valid_p):
Avoid autovec.
* config/riscv/riscv-vector-builtins-bases.cc:
Do not normalize vsetvl instructions for XTheadVector.
* config/riscv/riscv-vector-builtins-shapes.cc (check_type):
New check type function.
(build_one): Adjust for XTheadVector.
* config/riscv/riscv-vector-switch.def (ENTRY):
Disable fractional mode for the XTheadVector extension.
(TUPLE_ENTRY): Likewise.
* config/riscv/riscv.cc (riscv_v_adjust_bytesize):
Guard XTheadVector.
(riscv_preferred_simd_mode): Likewsie.
(riscv_autovectorize_vector_modes): Likewise.
(riscv_vector_mode_supported_any_target_p): Likewise.
(TARGET_VECTOR_MODE_SUPPORTED_ANY_TARGET_P): Likewise.
* config/riscv/thead.cc (th_asm_output_opcode):
Rewrite vsetvl instructions.
* config/riscv/vector.md:
Include thead-vector.md and change fractional LMUL
into 1 for vbool.
* config/riscv/riscv_th_vector.h: New file.
* config/riscv/thead-vector.md: New file.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/base/pragma-1.c: Add XTheadVector.
* gcc.target/riscv/rvv/base/abi-1.c: Exclude XTheadVector.
* lib/target-supports.exp: Add target for XTheadVector.

Co-authored-by: Jin Ma <jinma@linux.alibaba.com>
Co-authored-by: Xianmiao Qu <cooper.qu@linux.alibaba.com>
Co-authored-by: Christoph Müllner <christoph.muellner@vrull.eu>
17 files changed:
gcc/config.gcc
gcc/config/riscv/autovec.md
gcc/config/riscv/predicates.md
gcc/config/riscv/riscv-c.cc
gcc/config/riscv/riscv-string.cc
gcc/config/riscv/riscv-v.cc
gcc/config/riscv/riscv-vector-builtins-bases.cc
gcc/config/riscv/riscv-vector-builtins-shapes.cc
gcc/config/riscv/riscv-vector-switch.def
gcc/config/riscv/riscv.cc
gcc/config/riscv/riscv_th_vector.h [new file with mode: 0644]
gcc/config/riscv/thead-vector.md [new file with mode: 0644]
gcc/config/riscv/thead.cc
gcc/config/riscv/vector.md
gcc/testsuite/gcc.target/riscv/rvv/base/abi-1.c
gcc/testsuite/gcc.target/riscv/rvv/base/pragma-1.c
gcc/testsuite/lib/target-supports.exp