[1/2] RISC-V: Add complex CSR error handling

Message ID 4e00819a3822f4f793c79663deff121e7e60ea8b.1692602822.git.research_trasio@irq.a4lg.com
State New
Headers
Series RISC-V: Add support for indirect CSR access extensions |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_check--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_binutils_check--master-arm success Testing passed
linaro-tcwg-bot/tcwg_binutils_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 success Testing passed

Commit Message

Tsukasa OI Aug. 21, 2023, 7:27 a.m. UTC
  From: Tsukasa OI <research_trasio@irq.a4lg.com>

This commit adds template for complex CSR error handling (such like
multiple extensions involved).

gas/ChangeLog:

	* config/tc-riscv.c (riscv_csr_address): Add complex CSR error
	handling.
---
 gas/config/tc-riscv.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
  

Patch

diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c
index 959cbbc32a5e..f587ea416f59 100644
--- a/gas/config/tc-riscv.c
+++ b/gas/config/tc-riscv.c
@@ -1020,6 +1020,8 @@  riscv_csr_address (const char *csr_name,
   bool need_check_version = false;
   bool is_rv32_only = false;
   bool is_h_required = false;
+  bool is_csr_req_complex = false;
+  bool csr_ok = false;
   const char* extension = NULL;
 
   switch (csr_class)
@@ -1106,8 +1108,10 @@  riscv_csr_address (const char *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))
+      if (is_csr_req_complex
+	      ? !csr_ok
+	      : (extension != NULL
+		 && !riscv_subset_supports (&riscv_rps_as, extension)))
 	as_warn (_("invalid CSR `%s', needs `%s' extension"),
 		 csr_name, extension);
     }