RISC-V: Simplify riscv_csr_address logic on state enable extensions
authorTsukasa OI <research_trasio@irq.a4lg.com>
Tue, 27 Dec 2022 03:31:19 +0000 (03:31 +0000)
committerTsukasa OI <research_trasio@irq.a4lg.com>
Thu, 29 Dec 2022 01:00:13 +0000 (01:00 +0000)
This commit makes CSR class handling for 'Smstateen' and 'Ssstateen'
extensions simpler using fall-throughs (as used in CSR_CLASS_I{,_32}).

gas/ChangeLog:

* config/tc-riscv.c (riscv_csr_address): Simplify the logic for
'Smstateen' and 'Ssstateen' extensions.

gas/config/tc-riscv.c

index 77c0d2e32abf9fa99588ce2bfffc064481c91dc1..cc0d74921027c660d98ed54ce4d2faea125f44c1 100644 (file)
@@ -1049,9 +1049,10 @@ riscv_csr_address (const char *csr_name,
     case CSR_CLASS_SMAIA:
       extension = "smaia";
       break;
-    case CSR_CLASS_SMSTATEEN:
     case CSR_CLASS_SMSTATEEN_32:
-      is_rv32_only = (csr_class == CSR_CLASS_SMSTATEEN_32);
+      is_rv32_only = true;
+      /* Fall through.  */
+    case CSR_CLASS_SMSTATEEN:
       extension = "smstateen";
       break;
     case CSR_CLASS_SSAIA:
@@ -1064,12 +1065,13 @@ riscv_csr_address (const char *csr_name,
                       || csr_class == CSR_CLASS_SSAIA_AND_H_32);
       extension = "ssaia";
       break;
-    case CSR_CLASS_SSSTATEEN:
-    case CSR_CLASS_SSSTATEEN_AND_H:
     case CSR_CLASS_SSSTATEEN_AND_H_32:
-      is_rv32_only = (csr_class == CSR_CLASS_SSSTATEEN_AND_H_32);
-      is_h_required = (csr_class == CSR_CLASS_SSSTATEEN_AND_H
-                     || csr_class == CSR_CLASS_SSSTATEEN_AND_H_32);
+      is_rv32_only = true;
+      /* Fall through.  */
+    case CSR_CLASS_SSSTATEEN_AND_H:
+      is_h_required = true;
+      /* Fall through.  */
+    case CSR_CLASS_SSSTATEEN:
       extension = "ssstateen";
       break;
     case CSR_CLASS_SSCOFPMF_32: