RISC-V: Move class riscv_subset_list and riscv_subset_t to riscv-protos.h
authorKito Cheng <kito.cheng@sifive.com>
Tue, 29 Dec 2020 08:15:19 +0000 (16:15 +0800)
committerKito Cheng <kito.cheng@sifive.com>
Fri, 8 Jan 2021 03:14:02 +0000 (11:14 +0800)
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-subset.h.
(struct riscv_subset_t): Ditto.
(class riscv_subset_list): Ditto.
* config/riscv/riscv-subset.h (RISCV_DONT_CARE_VERSION): Move
from riscv-common.c.
(struct riscv_subset_t): Ditto.
(class riscv_subset_list): Ditto.
* config/riscv/t-riscv ($(common_out_file)): Add file
dependency.

gcc/common/config/riscv/riscv-common.c
gcc/config/riscv/riscv-subset.h [new file with mode: 0644]
gcc/config/riscv/t-riscv

index 7b75114..934c716 100644 (file)
@@ -30,22 +30,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "flags.h"
 #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;
-};
+#include "config/riscv/riscv-subset.h"
 
 /* Type for implied ISA info.  */
 struct riscv_implied_info_t
@@ -123,56 +108,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-subset.h b/gcc/config/riscv/riscv-subset.h
new file mode 100644 (file)
index 0000000..ae7401a
--- /dev/null
@@ -0,0 +1,90 @@
+/* Definition of data structure of RISC-V subset for GNU compiler.
+   Copyright (C) 2011-2021 Free Software Foundation, Inc.
+   Contributed by Andrew Waterman (andrew@sifive.com).
+   Based on MIPS target for GNU compiler.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
+
+#ifndef GCC_RISCV_SUBSET_H
+#define GCC_RISCV_SUBSET_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;
+};
+
+/* 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);
+};
+
+#endif /* ! GCC_RISCV_SUBSET_H */
index 702767c..1215ea8 100644 (file)
@@ -25,4 +25,6 @@ riscv-shorten-memrefs.o: $(srcdir)/config/riscv/riscv-shorten-memrefs.c
 
 PASSES_EXTRA += $(srcdir)/config/riscv/riscv-passes.def
 
-$(common_out_file): $(srcdir)/config/riscv/riscv-cores.def
+$(common_out_file): $(srcdir)/config/riscv/riscv-cores.def \
+    $(srcdir)/config/riscv/riscv-protos.h \
+    $(srcdir)/config/riscv/riscv-subset.h