public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Kito Cheng <kito.cheng@sifive.com>
To: gcc-patches@gcc.gnu.org, kito.cheng@gmail.com, jimw@sifive.com
Cc: Kito Cheng <kito.cheng@sifive.com>
Subject: [PATCH 1/2] RISC-V: Move class riscv_subset_list and riscv_subset_t to riscv-protos.h
Date: Mon,  4 Jan 2021 17:48:04 +0800	[thread overview]
Message-ID: <20210104094805.2160-2-kito.cheng@sifive.com> (raw)
In-Reply-To: <20210104094805.2160-1-kito.cheng@sifive.com>

Pre-work of new style of architecture extension test macros, we need the
list used in `config/riscv/riscv-c.c`, so those struct/class declaration
must move to header file rather than local C file.

gcc/ChangeLog

	* common/config/riscv/riscv-common.c (RISCV_DONT_CARE_VERSION):
	Move to riscv-protos.h.
	(struct riscv_subset_t): Ditto.
	(class riscv_subset_list): Ditto.
	* config/riscv/riscv-protos.h (RISCV_DONT_CARE_VERSION): Move
	from riscv-common.c.
	(struct riscv_subset_t): Ditto.
	(class riscv_subset_list): Ditto.
---
 gcc/common/config/riscv/riscv-common.c | 66 -------------------------
 gcc/config/riscv/riscv-protos.h        | 67 ++++++++++++++++++++++++++
 2 files changed, 67 insertions(+), 66 deletions(-)

diff --git a/gcc/common/config/riscv/riscv-common.c b/gcc/common/config/riscv/riscv-common.c
index 5e3ddcf3f81..3a8bcbef006 100644
--- a/gcc/common/config/riscv/riscv-common.c
+++ b/gcc/common/config/riscv/riscv-common.c
@@ -31,22 +31,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "diagnostic-core.h"
 #include "config/riscv/riscv-protos.h"
 
-#define RISCV_DONT_CARE_VERSION -1
-
-/* Subset info.  */
-struct riscv_subset_t
-{
-  riscv_subset_t ();
-
-  std::string name;
-  int major_version;
-  int minor_version;
-  struct riscv_subset_t *next;
-
-  bool explicit_version_p;
-  bool implied_p;
-};
-
 /* Type for implied ISA info.  */
 struct riscv_implied_info_t
 {
@@ -123,56 +107,6 @@ static const riscv_cpu_info riscv_cpu_tables[] =
     {NULL, NULL, NULL}
 };
 
-/* Subset list.  */
-class riscv_subset_list
-{
-private:
-  /* Original arch string.  */
-  const char *m_arch;
-
-  /* Location of arch string, used for report error.  */
-  location_t m_loc;
-
-  /* Head of subset info list.  */
-  riscv_subset_t *m_head;
-
-  /* Tail of subset info list.  */
-  riscv_subset_t *m_tail;
-
-  /* X-len of m_arch. */
-  unsigned m_xlen;
-
-  riscv_subset_list (const char *, location_t);
-
-  const char *parsing_subset_version (const char *, const char *, unsigned *,
-				      unsigned *, bool, bool *);
-
-  const char *parse_std_ext (const char *);
-
-  const char *parse_multiletter_ext (const char *, const char *,
-				     const char *);
-
-  void handle_implied_ext (riscv_subset_t *);
-
-public:
-  ~riscv_subset_list ();
-
-  void add (const char *, int, int, bool, bool);
-
-  void add (const char *, bool);
-
-  riscv_subset_t *lookup (const char *,
-			  int major_version = RISCV_DONT_CARE_VERSION,
-			  int minor_version = RISCV_DONT_CARE_VERSION) const;
-
-  std::string to_string (bool) const;
-
-  unsigned xlen() const {return m_xlen;};
-
-  static riscv_subset_list *parse (const char *, location_t);
-
-};
-
 static const char *riscv_supported_std_ext (void);
 
 static riscv_subset_list *current_subset_list = NULL;
diff --git a/gcc/config/riscv/riscv-protos.h b/gcc/config/riscv/riscv-protos.h
index 256dab1d0cf..1a258553d73 100644
--- a/gcc/config/riscv/riscv-protos.h
+++ b/gcc/config/riscv/riscv-protos.h
@@ -108,4 +108,71 @@ struct riscv_cpu_info {
 
 extern const riscv_cpu_info *riscv_find_cpu (const char *);
 
+#define RISCV_DONT_CARE_VERSION -1
+
+/* Subset info.  */
+struct riscv_subset_t
+{
+  riscv_subset_t ();
+
+  std::string name;
+  int major_version;
+  int minor_version;
+  struct riscv_subset_t *next;
+
+  bool explicit_version_p;
+  bool implied_p;
+};
+
+/* Subset list.  */
+class riscv_subset_list
+{
+private:
+  /* Original arch string.  */
+  const char *m_arch;
+
+  /* Location of arch string, used for report error.  */
+  location_t m_loc;
+
+  /* Head of subset info list.  */
+  riscv_subset_t *m_head;
+
+  /* Tail of subset info list.  */
+  riscv_subset_t *m_tail;
+
+  /* X-len of m_arch. */
+  unsigned m_xlen;
+
+  riscv_subset_list (const char *, location_t);
+
+  const char *parsing_subset_version (const char *, const char *, unsigned *,
+				      unsigned *, bool, bool *);
+
+  const char *parse_std_ext (const char *);
+
+  const char *parse_multiletter_ext (const char *, const char *,
+				     const char *);
+
+  void handle_implied_ext (riscv_subset_t *);
+
+public:
+  ~riscv_subset_list ();
+
+  void add (const char *, int, int, bool, bool);
+
+  void add (const char *, bool);
+
+  riscv_subset_t *lookup (const char *,
+			  int major_version = RISCV_DONT_CARE_VERSION,
+			  int minor_version = RISCV_DONT_CARE_VERSION) const;
+
+  std::string to_string (bool) const;
+
+  unsigned xlen () const {return m_xlen;};
+
+  static riscv_subset_list *parse (const char *, location_t);
+
+  int match_score (riscv_subset_list *) const;
+};
+
 #endif /* ! GCC_RISCV_PROTOS_H */
-- 
2.29.2


  reply	other threads:[~2021-01-04  9:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-04  9:48 [PATCH 0/2] RISC-V: Introduce new architecture extension test macros Kito Cheng
2021-01-04  9:48 ` Kito Cheng [this message]
2021-01-04  9:48 ` [PATCH 2/2] RISC-V: Implement new style of " Kito Cheng
2021-01-06 15:23 ` [PATCH 0/2] RISC-V: Introduce new " Kito Cheng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210104094805.2160-2-kito.cheng@sifive.com \
    --to=kito.cheng@sifive.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jimw@sifive.com \
    --cc=kito.cheng@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).