On 10/9/23 22:13, Kito Cheng wrote:
riscv_subset_list only accept a full arch string before, but we need to
parse single extension when supporting target attribute, also we may set
a riscv_subset_list directly rather than re-parsing the ISA string
again.

gcc/ChangeLog:

        * config/riscv/riscv-subset.h (riscv_subset_list::parse_single_std_ext):
        New.
        (riscv_subset_list::parse_single_multiletter_ext): Ditto.
        (riscv_subset_list::clone): Ditto.
        (riscv_subset_list::parse_single_ext): Ditto.
        (riscv_subset_list::set_loc): Ditto.
        (riscv_set_arch_by_subset_list): Ditto.
        * common/config/riscv/riscv-common.cc
        (riscv_subset_list::parse_single_std_ext): New.
        (riscv_subset_list::parse_single_multiletter_ext): Ditto.
        (riscv_subset_list::clone): Ditto.
        (riscv_subset_list::parse_single_ext): Ditto.
        (riscv_subset_list::set_loc): Ditto.
        (riscv_set_arch_by_subset_list): Ditto.
---
  gcc/common/config/riscv/riscv-common.cc | 203 ++++++++++++++++++++++++
  gcc/config/riscv/riscv-subset.h         |  11 ++
  2 files changed, 214 insertions(+)

diff --git a/gcc/common/config/riscv/riscv-common.cc 
b/gcc/common/config/riscv/riscv-common.cc
index 9a0a68fe5db..25630d5923e 100644
--- a/gcc/common/config/riscv/riscv-common.cc
+++ b/gcc/common/config/riscv/riscv-common.cc
@@ -1138,6 +1173,102 @@ riscv_subset_list::handle_combine_ext ()
      }
  }
+/* Parsing function for multi-letter extensions.
+
+   Return Value:
+     Points to the end of extensions.
+
+   Arguments:
+     `p`: Current parsing position.
+     `ext_type`: What kind of extensions, 's', 'z' or 'x'.
+     `ext_type_str`: Full name for kind of extension.  */
+
+
+const char *
+riscv_subset_list::parse_single_multiletter_ext (const char *p,
+                                                const char *ext_type,
+                                                const char *ext_type_str)
[ ... ]




+
+  if (end_of_version == NULL)
+    return NULL;
I think when we hit this path we leak SUBSET.




std::string
@@ -1498,6 +1673,34 @@ static const riscv_ext_flag_table_t 
riscv_ext_flag_table[] =
    {NULL, NULL, 0}
  };
+void
+riscv_set_arch_by_subset_list (riscv_subset_list *subset_list,
+                              struct gcc_options *opts)
Needs a function comment.

OK with those two minor issues fixed.

jeff

Reply via email to