public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed] RISC-V: Refine riscv_subset_list::parse [NFC]
@ 2023-12-04  6:40 Kito Cheng
  0 siblings, 0 replies; only message in thread
From: Kito Cheng @ 2023-12-04  6:40 UTC (permalink / raw)
  To: gcc-patches, kito.cheng; +Cc: Kito Cheng

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 | 31 +++++++++++++++----------
 gcc/config/riscv/riscv-subset.h         |  1 +
 2 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/gcc/common/config/riscv/riscv-common.cc b/gcc/common/config/riscv/riscv-common.cc
index ded85b4c578..de793f96fa5 100644
--- a/gcc/common/config/riscv/riscv-common.cc
+++ b/gcc/common/config/riscv/riscv-common.cc
@@ -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;
 
diff --git a/gcc/config/riscv/riscv-subset.h b/gcc/config/riscv/riscv-subset.h
index d2a4bd20530..ad1cab2aa24 100644
--- a/gcc/config/riscv/riscv-subset.h
+++ b/gcc/config/riscv/riscv-subset.h
@@ -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 ();
-- 
2.40.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-12-04  6:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-04  6:40 [committed] RISC-V: Refine riscv_subset_list::parse [NFC] Kito Cheng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).