Add config file so b4 uses inbox.sourceware.org automatically
[official-gcc.git] / gcc / config / riscv / riscv-subset.h
blobdace4de657538f7d72d955a26ac47dac8fd646cf
1 /* Definition of data structure of RISC-V subset for GNU compiler.
2 Copyright (C) 2011-2024 Free Software Foundation, Inc.
3 Contributed by Andrew Waterman (andrew@sifive.com).
4 Based on MIPS target for GNU compiler.
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
11 any later version.
13 GCC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
22 #ifndef GCC_RISCV_SUBSET_H
23 #define GCC_RISCV_SUBSET_H
25 #define RISCV_DONT_CARE_VERSION -1
27 /* Subset info. */
28 struct riscv_subset_t
30 riscv_subset_t ();
32 std::string name;
33 int major_version;
34 int minor_version;
35 struct riscv_subset_t *next;
37 bool explicit_version_p;
38 bool implied_p;
41 /* Subset list. */
42 class riscv_subset_list
44 public:
45 /* Because the parse method is called in several places, to prevent repeated
46 errors, use this flag to prevent it from repeating parse. */
47 static bool parse_failed;
49 private:
50 /* Original arch string. */
51 const char *m_arch;
53 /* Location of arch string, used for report error. */
54 location_t m_loc;
56 /* Head of subset info list. */
57 riscv_subset_t *m_head;
59 /* Tail of subset info list. */
60 riscv_subset_t *m_tail;
62 /* X-len of m_arch. */
63 unsigned m_xlen;
65 /* Number of subsets. */
66 unsigned m_subset_num;
68 /* Allow adding the same extension more than once. */
69 bool m_allow_adding_dup;
71 riscv_subset_list (const char *, location_t);
73 const char *parsing_subset_version (const char *, const char *, unsigned *,
74 unsigned *, bool, bool *);
76 const char *parse_base_ext (const char *);
78 const char *parse_single_std_ext (const char *, bool);
80 const char *parse_single_multiletter_ext (const char *, const char *,
81 const char *, bool);
83 void handle_implied_ext (const char *);
84 bool check_implied_ext ();
85 void handle_combine_ext ();
86 void check_conflict_ext ();
88 public:
89 ~riscv_subset_list ();
91 void add (const char *, int, int, bool, bool);
93 void add (const char *, bool);
95 riscv_subset_t *lookup (const char *,
96 int major_version = RISCV_DONT_CARE_VERSION,
97 int minor_version = RISCV_DONT_CARE_VERSION) const;
99 std::string to_string (bool) const;
101 unsigned xlen () const {return m_xlen;};
103 riscv_subset_list *clone () const;
105 static riscv_subset_list *parse (const char *, location_t);
106 const char *parse_single_ext (const char *, bool exact_single_p = true);
108 const riscv_subset_t *begin () const {return m_head;};
109 const riscv_subset_t *end () const {return NULL;};
111 int match_score (riscv_subset_list *) const;
113 void set_loc (location_t);
115 void set_allow_adding_dup (bool v) { m_allow_adding_dup = v; }
117 void finalize ();
120 extern const riscv_subset_list *riscv_cmdline_subset_list (void);
121 extern void
122 riscv_set_arch_by_subset_list (riscv_subset_list *, struct gcc_options *);
124 #endif /* ! GCC_RISCV_SUBSET_H */