Debian Codegraph @

gcc/config/riscv/riscv-subset.h

raw
1 /* Definition of data structure of RISC-V subset for GNU compiler.
2 Copyright (C) 2011-2025 Free Software Foundation, Inc.
3 Contributed by Andrew Waterman ([email protected]).
4 Based on MIPS target for GNU compiler.
5
6 This file is part of GCC.
7
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.
12
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.
17
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/>. */
21
22 #ifndef GCC_RISCV_SUBSET_H
23 #define GCC_RISCV_SUBSET_H
24
25 #include "riscv-feature-bits.h"
26
27 #define RISCV_DONT_CARE_VERSION -1
28
29 /* Subset info. */
30 struct riscv_subset_t
31 {
32 riscv_subset_t ();
33
34 std::string name;
35 int major_version;
36 int minor_version;
37 struct riscv_subset_t *next;
38
39 bool explicit_version_p;
40 bool implied_p;
41 };
42
43 /* Subset list. */
44 class riscv_subset_list
45 {
46 public:
47 /* Because the parse method is called in several places, to prevent repeated
48 errors, use this flag to prevent it from repeating parse. */
49 static bool parse_failed;
50
51 private:
52 /* Original arch string. */
53 const char *m_arch;
54
55 /* Location of arch string, used for report error. */
56 location_t m_loc;
57
58 /* Head of subset info list. */
59 riscv_subset_t *m_head;
60
61 /* Tail of subset info list. */
62 riscv_subset_t *m_tail;
63
64 /* X-len of m_arch. */
65 unsigned m_xlen;
66
67 /* Number of subsets. */
68 unsigned m_subset_num;
69
70 /* Allow adding the same extension more than once. */
71 bool m_allow_adding_dup;
72
73 riscv_subset_list (const char *, location_t);
74
75 const char *parsing_subset_version (const char *, const char *, unsigned *,
76 unsigned *, bool, bool *);
77
78 const char *parse_base_ext (const char *);
79
80 const char *parse_single_std_ext (const char *, bool);
81
82 const char *parse_single_multiletter_ext (const char *, const char *,
83 const char *, bool);
84
85 void handle_implied_ext (const char *);
86 bool check_implied_ext ();
87 void handle_combine_ext ();
88 void check_conflict_ext ();
89
90 public:
91 ~riscv_subset_list ();
92
93 void add (const char *, int, int, bool, bool);
94
95 void add (const char *, bool);
96
97 riscv_subset_t *lookup (const char *,
98 int major_version = RISCV_DONT_CARE_VERSION,
99 int minor_version = RISCV_DONT_CARE_VERSION) const;
100
101 std::string to_string (bool) const;
102
103 unsigned xlen () const {return m_xlen;};
104
105 riscv_subset_list *clone () const;
106
107 static riscv_subset_list *parse (const char *, location_t);
108 const char *parse_single_ext (const char *, bool exact_single_p = true);
109
110 const riscv_subset_t *begin () const {return m_head;};
111 const riscv_subset_t *end () const {return NULL;};
112
113 int match_score (riscv_subset_list *) const;
114
115 void set_loc (location_t);
116
117 void set_allow_adding_dup (bool v) { m_allow_adding_dup = v; }
118
119 void finalize ();
120 };
121
122 extern const riscv_subset_list *riscv_cmdline_subset_list (void);
123 extern void
124 riscv_set_arch_by_subset_list (riscv_subset_list *, struct gcc_options *);
125 extern bool riscv_minimal_hwprobe_feature_bits (const char *,
126 struct riscv_feature_bits *,
127 location_t);
128 extern bool
129 riscv_ext_is_subset (struct cl_target_option *, struct cl_target_option *);
130 extern int riscv_x_target_flags_isa_mask (void);
131
132 #endif /* ! GCC_RISCV_SUBSET_H */