]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
RISC-V: Support Zcmp push/pop instructions.
authorJiawei <jiawei@iscas.ac.cn>
Tue, 27 Feb 2024 03:48:11 +0000 (11:48 +0800)
committerNelson Chu <nelson@rivosinc.com>
Tue, 9 Apr 2024 07:56:12 +0000 (15:56 +0800)
commit9132c8152b899a1683bc886f8ba76bedadb48aa1
treeaa2ea7d660f18ce24eddcc70b8da58bf0508fabf
parent2bf280a827577eaf26d657af9f5e29dbf77e6ee2
RISC-V: Support Zcmp push/pop instructions.

Support zcmp extension push/pop/popret and popret zero instructions.
The `reg_list' is a list containing 1 to 13 registers, we can use:
"{ra}, {ra, s0}, {ra, s0-s1}, {ra, s0-s2} ... {ra, s0-sN}"
to present this feature.

Passed gcc/binutils regressions of riscv-gnu-toolchain.

Most of work was finished by Sinan Lin.
Co-Authored by: Charlie Keaney <charlie.keaney@embecosm.com>
Co-Authored by: Mary Bennett <mary.bennett@embecosm.com>
Co-Authored by: Nandni Jamnadas <nandni.jamnadas@embecosm.com>
Co-Authored by: Sinan Lin <sinan.lin@linux.alibaba.com>
Co-Authored by: Simon Cook <simon.cook@embecosm.com>
Co-Authored by: Shihua Liao <shihua@iscas.ac.cn>
Co-Authored by: Yulong Shi <yulong@iscas.ac.cn>

bfd/ChangeLog:

        * elfxx-riscv.c (riscv_implicit_subset): Imply zca for zcmp.
(riscv_supported_std_z_ext): Added zcmp with version 1.0.
(riscv_parse_check_conflicts): Zcmp conflicts with d/zcd.
        (riscv_multi_subset_supports): Handle zcmp.
        (riscv_multi_subset_supports_ext): Ditto.

gas/ChangeLog:

* NEWS: Updated.
        * config/tc-riscv.c (regno_to_reg_list): New function, used to map
register to reg_list number.
        (reglist_lookup): Called reglist_lookup_internal.  Return false if
reg_list number is zero, which is an invalid value.
(reglist_lookup_internal): Parse register list, and return the last
register by regno_to_reg_list.
        (validate_riscv_insn):  New operators.
        (riscv_ip): Ditto.
* testsuite/gas/riscv/march-help.l: Updated.
        * testsuite/gas/riscv/zcmp-push-pop-fail.d: New test.
        * testsuite/gas/riscv/zcmp-push-pop-fail.l: New test.
        * testsuite/gas/riscv/zcmp-push-pop-fail.s: New test.
        * testsuite/gas/riscv/zcmp-push-pop.d: New test.
        * testsuite/gas/riscv/zcmp-push-pop.s: New test.

include/ChangeLog:

        * opcode/riscv-opc.h (MATCH/MASK_CM_PUSH): New macros for zcmp.
        (MATCH/MASK_CM_POP): Ditto.
        (MATCH/MASK_CM_POPRET): Ditto.
        (MATCH/MASK_CM_POPRETZ): Ditto.
        (DECLARE_INSN): New declarations for zcmp.
        * opcode/riscv.h (EXTRACT/ENCODE/VALID_ZCMP_SPIMM): Handle spimm
operand for zcmp.
        (OP_MASK_REG_LIST): Handle operand for zcmp register list.
        (OP_SH_REG_LIST): Ditto.
        (ZCMP_SP_ALIGNMENT): New argument, used in riscv_get_sp_base.
        (X_S0, X_S1, X_S2, X_S10, X_S11): New register numbers.
        (enum riscv_insn_class): Added INSN_CLASS_ZCMP.
        (extern riscv_get_sp_base): Added.

opcodes/ChangeLog:

        * riscv-dis.c (print_reg_list): New function, used to get zcmp
reg_list field.
        (riscv_get_spimm): New function, used to get zcmp sp adjustment
immediate.
        (print_insn_args): Handle new operands for zcmp.
        * riscv-opc.c (riscv_get_sp_base): New function, used by gas and
objdump.  Get sp base adjustment.
(riscv_opcodes): Added zcmp instructions.
13 files changed:
bfd/elfxx-riscv.c
gas/NEWS
gas/config/tc-riscv.c
gas/testsuite/gas/riscv/march-help.l
gas/testsuite/gas/riscv/zcmp-push-pop-fail.d [new file with mode: 0644]
gas/testsuite/gas/riscv/zcmp-push-pop-fail.l [new file with mode: 0644]
gas/testsuite/gas/riscv/zcmp-push-pop-fail.s [new file with mode: 0644]
gas/testsuite/gas/riscv/zcmp-push-pop.d [new file with mode: 0644]
gas/testsuite/gas/riscv/zcmp-push-pop.s [new file with mode: 0644]
include/opcode/riscv-opc.h
include/opcode/riscv.h
opcodes/riscv-dis.c
opcodes/riscv-opc.c