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)
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
35 struct riscv_subset_t
*next
;
37 bool explicit_version_p
;
42 class riscv_subset_list
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
;
50 /* Original arch string. */
53 /* Location of arch string, used for report error. */
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. */
65 riscv_subset_list (const char *, location_t
);
67 const char *parsing_subset_version (const char *, const char *, unsigned *,
68 unsigned *, bool, bool *);
70 const char *parse_std_ext (const char *);
72 const char *parse_single_std_ext (const char *);
74 const char *parse_multiletter_ext (const char *, const char *,
76 const char *parse_single_multiletter_ext (const char *, const char *,
79 void handle_implied_ext (const char *);
80 bool check_implied_ext ();
81 void handle_combine_ext ();
82 void check_conflict_ext ();
85 ~riscv_subset_list ();
87 void add (const char *, int, int, bool, bool);
89 void add (const char *, bool);
91 riscv_subset_t
*lookup (const char *,
92 int major_version
= RISCV_DONT_CARE_VERSION
,
93 int minor_version
= RISCV_DONT_CARE_VERSION
) const;
95 std::string
to_string (bool) const;
97 unsigned xlen () const {return m_xlen
;};
99 riscv_subset_list
*clone () const;
101 static riscv_subset_list
*parse (const char *, location_t
);
102 const char *parse_single_ext (const char *);
104 const riscv_subset_t
*begin () const {return m_head
;};
105 const riscv_subset_t
*end () const {return NULL
;};
107 int match_score (riscv_subset_list
*) const;
109 void set_loc (location_t
);
112 extern const riscv_subset_list
*riscv_current_subset_list (void);
114 riscv_set_arch_by_subset_list (riscv_subset_list
*, struct gcc_options
*);
116 #endif /* ! GCC_RISCV_SUBSET_H */