[PATCH v3 1/4] RISC-V: Add new CSR feature gate handling (RV32,H)
Tsukasa OI
research_trasio@irq.a4lg.com
Fri Jun 24 02:51:53 GMT 2022
To support feature gate like Smstateen && H, this commit adds certain
CSR feature gate handling. It also changes how RV32-only CSRs are
handled for cleanliness.
gas/ChangeLog:
* config/tc-riscv.c (riscv_csr_address): Add CSR feature gate
handling for H. Change handling on RV32.
---
gas/config/tc-riscv.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c
index 6b04dc98b76..6c5938b5596 100644
--- a/gas/config/tc-riscv.c
+++ b/gas/config/tc-riscv.c
@@ -899,20 +899,21 @@ riscv_csr_address (const char *csr_name,
struct riscv_csr_extra *saved_entry = entry;
enum riscv_csr_class csr_class = entry->csr_class;
bool need_check_version = false;
- bool rv32_only = true;
+ bool is_rv32_only = false;
+ bool is_h_required = false;
const char* extension = NULL;
switch (csr_class)
{
case CSR_CLASS_I_32:
- rv32_only = (xlen == 32);
+ is_rv32_only = true;
/* Fall through. */
case CSR_CLASS_I:
need_check_version = true;
extension = "i";
break;
case CSR_CLASS_H_32:
- rv32_only = (xlen == 32);
+ is_rv32_only = true;
/* Fall through. */
case CSR_CLASS_H:
extension = "h";
@@ -934,8 +935,10 @@ riscv_csr_address (const char *csr_name,
if (riscv_opts.csr_check)
{
- if (!rv32_only)
+ if (is_rv32_only && xlen != 32)
as_warn (_("invalid CSR `%s', needs rv32i extension"), csr_name);
+ if (is_h_required && !riscv_subset_supports (&riscv_rps_as, "h"))
+ as_warn (_("invalid CSR `%s', needs `h' extension"), csr_name);
if (extension != NULL
&& !riscv_subset_supports (&riscv_rps_as, extension))
--
2.34.1
More information about the Binutils
mailing list