diff mbox series

[1/2,RISC-V] add implied extension repeatly until stable

Message ID 20240705095631.949-2-gaofei@eswincomputing.com
State New
Headers show
Series c implies zca, and conditionally zcf & zcd | expand

Commit Message

Fei Gao July 5, 2024, 9:56 a.m. UTC
Call handle_implied_ext repeatly until there's no
new subset added into the subset list.

gcc/ChangeLog:

        * common/config/riscv/riscv-common.cc (riscv_subset_list::riscv_subset_list):
        init m_subset_num to 0.
        (riscv_subset_list::add): increase m_subset_num once a subset added.
        (riscv_subset_list::finalize): call handle_implied_ext repeatly
        until no change in m_subset_num.
        * config/riscv/riscv-subset.h: add m_subset_num member.

Signed-off-by: Fei Gao <gaofei@eswincomputing.com>
---
 gcc/common/config/riscv/riscv-common.cc | 14 +++++++++++---
 gcc/config/riscv/riscv-subset.h         |  3 +++
 2 files changed, 14 insertions(+), 3 deletions(-)

Comments

Jeff Law July 6, 2024, 2:13 p.m. UTC | #1
On 7/5/24 3:56 AM, Fei Gao wrote:
> Call handle_implied_ext repeatly until there's no
> new subset added into the subset list.
> 
> gcc/ChangeLog:
> 
>          * common/config/riscv/riscv-common.cc (riscv_subset_list::riscv_subset_list):
>          init m_subset_num to 0.
>          (riscv_subset_list::add): increase m_subset_num once a subset added.
>          (riscv_subset_list::finalize): call handle_implied_ext repeatly
>          until no change in m_subset_num.
>          * config/riscv/riscv-subset.h: add m_subset_num member.
OK.   It's unclear why the patch failed to apply in the linaro tester. 
But it ran through our RISC-V tester OK.

jeff
diff mbox series

Patch

diff --git a/gcc/common/config/riscv/riscv-common.cc b/gcc/common/config/riscv/riscv-common.cc
index 410e673f5e0..cad3551feb6 100644
--- a/gcc/common/config/riscv/riscv-common.cc
+++ b/gcc/common/config/riscv/riscv-common.cc
@@ -566,7 +566,8 @@  riscv_subset_t::riscv_subset_t ()
 }
 
 riscv_subset_list::riscv_subset_list (const char *arch, location_t loc)
-  : m_arch (arch), m_loc (loc), m_head (NULL), m_tail (NULL), m_xlen (0)
+  : m_arch (arch), m_loc (loc), m_head (NULL), m_tail (NULL), m_xlen (0),
+    m_subset_num (0)
 {
 }
 
@@ -812,6 +813,7 @@  riscv_subset_list::add (const char *subset, int major_version,
       return;
     }
 
+  m_subset_num++;
   riscv_subset_t *s = new riscv_subset_t ();
   riscv_subset_t *itr;
 
@@ -1586,9 +1588,15 @@  void
 riscv_subset_list::finalize ()
 {
   riscv_subset_t *subset;
+  unsigned pre_subset_num;
 
-  for (subset = m_head; subset != NULL; subset = subset->next)
-    handle_implied_ext (subset->name.c_str ());
+  do
+    {
+      pre_subset_num = m_subset_num;
+      for (subset = m_head; subset != NULL; subset = subset->next)
+	handle_implied_ext (subset->name.c_str ());
+    }
+  while (pre_subset_num != m_subset_num);
 
   gcc_assert (check_implied_ext ());
 
diff --git a/gcc/config/riscv/riscv-subset.h b/gcc/config/riscv/riscv-subset.h
index fe7f54d8bc5..7dc196a2007 100644
--- a/gcc/config/riscv/riscv-subset.h
+++ b/gcc/config/riscv/riscv-subset.h
@@ -62,6 +62,9 @@  private:
   /* X-len of m_arch. */
   unsigned m_xlen;
 
+  /* Number of subsets. */
+  unsigned m_subset_num;
+
   riscv_subset_list (const char *, location_t);
 
   const char *parsing_subset_version (const char *, const char *, unsigned *,