From c625f4ed05eb234d6a182201d14b3b1c64232afd Mon Sep 17 00:00:00 2001 From: Nelson Chu Date: Wed, 22 Jun 2022 17:03:16 +0800 Subject: RISC-V: Use single h extension to control hypervisor CSRs and instructions. According to the picture 28.1 in the current ISA spec, h is no larger the multi-letter extension, it is a single extension after v. Therefore, this patch fix the implementation, and use the single h to control hypervisor CSRs and instructions, which we promised to do before. bfd/ * elfxx-riscv.c (riscv_supported_std_ext): Added h with version 1.0 after v. (riscv_supported_std_h_ext): Removed. (riscv_all_supported_ext): Updated since riscv_supported_std_h_ext is removed. (riscv_prefix_ext_class): Removed RV_ISA_CLASS_H. (parse_config): Updated since riscv_prefix_ext_class is removed. (riscv_recognized_prefixed_ext): Likewise. (riscv_get_default_ext_version): Likewise. (riscv_multi_subset_supports): Handle INSN_CLASS_H for hypervisor instructions. (riscv_multi_subset_supports_ext): Likewise. gas/ * config/tc-riscv.c (riscv_csr_class): Added CSR_CLASS_H and CSR_CLASS_H_32 for hypervisor CSRs. (riscv_csr_address): Likewise. * testsuite/gas/riscv/csr-version-1p10.d: Updated since hypervisor CSRs are controlled by single h extension for now. * testsuite/gas/riscv/csr-version-1p10.l: Likewise. * testsuite/gas/riscv/csr-version-1p11.d: Likewise. * testsuite/gas/riscv/csr-version-1p11.l: Likewise. * testsuite/gas/riscv/csr-version-1p12.d: Likewise. * testsuite/gas/riscv/csr-version-1p12.l: Likewise. * testsuite/gas/riscv/csr-version-1p9p1.d: Likewise. * testsuite/gas/riscv/csr-version-1p9p1.l: Likewise. * testsuite/gas/riscv/h-ext-32.d: Added h to architecture string. * testsuite/gas/riscv/h-ext-64.d: Likewise. * testsuite/gas/riscv/march-fail-single-prefix-h: Removed since h is no longer multi-letter extension. * testsuite/gas/riscv/march-fail-unknown-h.d: Likewise. include/ * opcode/riscv-opc.h: Control hypervisor CSRs by h extension, rather than the privileged spec verisons. * opcode/riscv.h (riscv_insn_class): Added INSN_CLASS_H. opcodes/ * riscv-opc.c (riscv_opcodes): Control hypervisor instructions by h extension. --- gas/config/tc-riscv.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'gas/config') diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c index a10ae8e..6b04dc9 100644 --- a/gas/config/tc-riscv.c +++ b/gas/config/tc-riscv.c @@ -65,7 +65,9 @@ enum riscv_csr_class CSR_CLASS_F, /* f-ext only */ CSR_CLASS_ZKR, /* zkr only */ CSR_CLASS_V, /* rvv only */ - CSR_CLASS_DEBUG /* debug CSR */ + CSR_CLASS_DEBUG, /* debug CSR */ + CSR_CLASS_H, /* hypervisor */ + CSR_CLASS_H_32, /* hypervisor, rv32 only */ }; /* This structure holds all restricted conditions for a CSR. */ @@ -909,6 +911,12 @@ riscv_csr_address (const char *csr_name, need_check_version = true; extension = "i"; break; + case CSR_CLASS_H_32: + rv32_only = (xlen == 32); + /* Fall through. */ + case CSR_CLASS_H: + extension = "h"; + break; case CSR_CLASS_F: extension = "f"; break; -- cgit v1.1