From 00ef37e860d505f41a621708c62f3e9363868ee1 Mon Sep 17 00:00:00 2001 From: Jiawei Date: Tue, 29 Oct 2024 20:44:23 +0800 Subject: RISC-V: Add Zcmt instructions and csr. This patch supports Zcmt[1] instruction 'cm.jt' and 'cm.jalt'. Add new CSR jvt for tablejump using. Since 'cm.jt' and 'cm.jalt' have the same instructiong encoding, use 'match_cm_jt' and 'match_cm_jalt' check the 'zcmt_index' field to distinguish them. [1] https://github.com/riscvarchive/riscv-code-size-reduction/releases Co-Authored by: Charlie Keaney Co-Authored by: Mary Bennett Co-Authored by: Nandni Jamnadas Co-Authored by: Sinan Lin Co-Authored by: Simon Cook Co-Authored by: Shihua Liao Co-Authored by: Yulong Shi bfd/ChangeLog: * elfxx-riscv.c (riscv_multi_subset_supports): New extension. (riscv_multi_subset_supports_ext): Ditto. gas/ChangeLog: * config/tc-riscv.c (enum riscv_csr_class): New CSR. (riscv_csr_address): Ditto. (validate_riscv_insn): New operand. (riscv_ip): Ditto. * testsuite/gas/riscv/csr-version-1p10.d: New CSR. * testsuite/gas/riscv/csr-version-1p10.l: Ditto. * testsuite/gas/riscv/csr-version-1p11.d: Ditto. * testsuite/gas/riscv/csr-version-1p11.l: Ditto. * testsuite/gas/riscv/csr-version-1p12.d: Ditto. * testsuite/gas/riscv/csr-version-1p12.l: Ditto. * testsuite/gas/riscv/csr.s: Ditto. * testsuite/gas/riscv/march-help.l: New extension. * testsuite/gas/riscv/zcmt-fail.d: New test. * testsuite/gas/riscv/zcmt-fail.l: New test. * testsuite/gas/riscv/zcmt-fail.s: New test. * testsuite/gas/riscv/zcmt.d: New test. * testsuite/gas/riscv/zcmt.s: New test. include/ChangeLog: * opcode/riscv-opc.h (MATCH_CM_JT): New opcode. (MASK_CM_JT): New mask. (MATCH_CM_JALT): New opcode. (MASK_CM_JALT): New mask. (CSR_JVT): New CSR. (DECLARE_INSN): New declaration. (DECLARE_CSR): Ditto. * opcode/riscv.h (EXTRACT_ZCMT_INDEX): New marco. (ENCODE_ZCMT_INDEX): Ditto. (enum riscv_insn_class): New class. opcodes/ChangeLog: * riscv-dis.c (print_insn_args): New operand. * riscv-opc.c (match_cm_jt): New function. (match_cm_jalt): Ditto. --- bfd/elfxx-riscv.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'bfd/elfxx-riscv.c') diff --git a/bfd/elfxx-riscv.c b/bfd/elfxx-riscv.c index 4b48d8e..701c724 100644 --- a/bfd/elfxx-riscv.c +++ b/bfd/elfxx-riscv.c @@ -1214,6 +1214,7 @@ static struct riscv_implicit_subset riscv_implicit_subsets[] = {"zcf", "+f,+zca", check_implicit_always}, {"zcmp", "+zca", check_implicit_always}, {"zcmop", "+zca", check_implicit_always}, + {"zcmt", "+zca,+zicsr", check_implicit_always}, {"shcounterenw", "+h", check_implicit_always}, {"shgatpa", "+h", check_implicit_always}, @@ -1424,6 +1425,7 @@ static struct riscv_supported_ext riscv_supported_std_z_ext[] = {"zcd", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, {"zcmop", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, {"zcmp", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, + {"zcmt", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, {NULL, 0, 0, 0, 0} }; @@ -2720,6 +2722,8 @@ riscv_multi_subset_supports (riscv_parse_subset_t *rps, return riscv_subset_supports (rps, "zcmop"); case INSN_CLASS_ZCMP: return riscv_subset_supports (rps, "zcmp"); + case INSN_CLASS_ZCMT: + return riscv_subset_supports (rps, "zcmt"); case INSN_CLASS_SVINVAL: return riscv_subset_supports (rps, "svinval"); case INSN_CLASS_H: @@ -3002,6 +3006,8 @@ riscv_multi_subset_supports_ext (riscv_parse_subset_t *rps, return "zcmop"; case INSN_CLASS_ZCMP: return "zcmp"; + case INSN_CLASS_ZCMT: + return "zcmt"; case INSN_CLASS_SVINVAL: return "svinval"; case INSN_CLASS_H: -- cgit v1.1