]> git.ipfire.org Git - thirdparty/gcc.git/commit
riscv: thead: Add support for the XTheadMemPair ISA extension
authorChristoph Müllner <christoph.muellner@vrull.eu>
Fri, 24 Feb 2023 05:18:04 +0000 (06:18 +0100)
committerPhilipp Tomsich <philipp.tomsich@vrull.eu>
Wed, 15 Mar 2023 09:01:17 +0000 (10:01 +0100)
commit02fcaf412ae9508b75efa9602cd4ac58bc63d6a4
tree7fd244141f5999622af0c620f01ba59d0d549924
parent75047aeb7e6af248dee47ee29bdcd57f93e7352e
riscv: thead: Add support for the XTheadMemPair ISA extension

The XTheadMemPair ISA extension allows to pair two loads or stores:
* th.ldd (2x LD)
* th.lwd (2x LW)
* th.lwud (2x LWU)
* th.sdd (2x SD)
* th.swd (2x SW)

The displacement of these instructions is quite limited:
* Displacement := imm2 << shamt
* imm2 is a 2-bit unsigned value {0..3}
* shamt is 4 for th.ldd/th.sdd and 3 otherwise
But even with this small displacement we can identify many candidates.

The merge of the two loads/stores is realized in form of peephole2
passes that support instruction reordering.
The CFA expansion (save/restore registers on/from stack) is not
processed by the peephole2 pass and, therefore, needs special-treatment.
Many ideas of this patch are inspired by similar/equal approaches
in other backends.

gcc/ChangeLog:

* config.gcc: Add thead.o to RISC-V extra_objs.
* config/riscv/peephole.md: Add mempair peephole passes.
* config/riscv/riscv-protos.h (riscv_split_64bit_move_p): New
prototype.
(th_mempair_operands_p): Likewise.
(th_mempair_order_operands): Likewise.
(th_mempair_prepare_save_restore_operands): Likewise.
(th_mempair_save_restore_regs): Likewise.
(th_mempair_output_move): Likewise.
* config/riscv/riscv.cc (riscv_save_reg): Move code.
(riscv_restore_reg): Move code.
(riscv_for_each_saved_reg): Add code to emit mempair insns.
* config/riscv/t-riscv: Add thead.cc.
* config/riscv/thead.md (*th_mempair_load_<GPR:mode>2):
New insn.
(*th_mempair_store_<GPR:mode>2): Likewise.
(*th_mempair_load_extendsidi2): Likewise.
(*th_mempair_load_zero_extendsidi2): Likewise.
* config/riscv/thead.cc: New file.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/xtheadmempair-1.c: New test.
* gcc.target/riscv/xtheadmempair-2.c: New test.
* gcc.target/riscv/xtheadmempair-3.c: New test.

Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
gcc/config.gcc
gcc/config/riscv/peephole.md
gcc/config/riscv/riscv-protos.h
gcc/config/riscv/riscv.cc
gcc/config/riscv/t-riscv
gcc/config/riscv/thead.cc [new file with mode: 0644]
gcc/config/riscv/thead.md
gcc/testsuite/gcc.target/riscv/xtheadmempair-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/xtheadmempair-2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/xtheadmempair-3.c [new file with mode: 0644]