]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
RISC-V: Refine riscv_subset_list::parse [NFC]
authorKito Cheng <kito.cheng@sifive.com>
Mon, 27 Nov 2023 07:28:30 +0000 (15:28 +0800)
committerKito Cheng <kito.cheng@sifive.com>
Mon, 4 Dec 2023 06:34:41 +0000 (14:34 +0800)
Extract the logic of checking conflict extensions to a standard alone
function, prepare to add more checking logic.

gcc/ChangeLog:

* common/config/riscv/riscv-common.cc
(riscv_subset_list::check_conflict_ext): New.
(riscv_subset_list::parse): Move checking conflict ext. to
check_conflict_ext.
* config/riscv/riscv-subset.h:
Add riscv_subset_list::check_conflict_ext.

gcc/common/config/riscv/riscv-common.cc
gcc/config/riscv/riscv-subset.h

index ded85b4c5783ec923472a6b4b9b31b29b48f897b..de793f96fa569f989f0c9ec4a46734ee00b289dd 100644 (file)
@@ -1185,6 +1185,24 @@ riscv_subset_list::handle_combine_ext ()
     }
 }
 
+void
+riscv_subset_list::check_conflict_ext ()
+{
+  if (lookup ("zcf") && m_xlen == 64)
+    error_at (m_loc, "%<-march=%s%>: zcf extension supports in rv32 only",
+             m_arch);
+
+  if (lookup ("zfinx") && lookup ("f"))
+    error_at (m_loc,
+             "%<-march=%s%>: z*inx conflicts with floating-point "
+             "extensions",
+             m_arch);
+
+  /* 'H' hypervisor extension requires base ISA with 32 registers.  */
+  if (lookup ("e") && lookup ("h"))
+    error_at (m_loc, "%<-march=%s%>: h extension requires i extension", m_arch);
+}
+
 /* Parsing function for multi-letter extensions.
 
    Return Value:
@@ -1495,18 +1513,7 @@ riscv_subset_list::parse (const char *arch, location_t loc)
   gcc_assert (subset_list->check_implied_ext ());
 
   subset_list->handle_combine_ext ();
-
-  if (subset_list->lookup ("zcf") && subset_list->m_xlen == 64)
-    error_at (loc, "%<-march=%s%>: zcf extension supports in rv32 only"
-                 , arch);
-
-  if (subset_list->lookup ("zfinx") && subset_list->lookup ("f"))
-    error_at (loc, "%<-march=%s%>: z*inx conflicts with floating-point "
-                  "extensions", arch);
-
-  /* 'H' hypervisor extension requires base ISA with 32 registers.  */
-  if (subset_list->lookup ("e") && subset_list->lookup ("h"))
-    error_at (loc, "%<-march=%s%>: h extension requires i extension", arch);
+  subset_list->check_conflict_ext ();
 
   return subset_list;
 
index d2a4bd20530783661603b253b6afe2877cbeba11..ad1cab2aa242f5f9627c9da13d226a8db7732a81 100644 (file)
@@ -79,6 +79,7 @@ private:
   void handle_implied_ext (const char *);
   bool check_implied_ext ();
   void handle_combine_ext ();
+  void check_conflict_ext ();
 
 public:
   ~riscv_subset_list ();