xref: /netbsd-src/external/gpl3/gcc/dist/gcc/config/riscv/riscv-subset.h (revision b1e838363e3c6fc78a55519254d99869742dd33c)
1 /* Definition of data structure of RISC-V subset for GNU compiler.
2    Copyright (C) 2011-2022 Free Software Foundation, Inc.
3    Contributed by Andrew Waterman (andrew@sifive.com).
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 #define RISCV_DONT_CARE_VERSION -1
26 
27 /* Subset info.  */
28 struct riscv_subset_t
29 {
30   riscv_subset_t ();
31 
32   std::string name;
33   int major_version;
34   int minor_version;
35   struct riscv_subset_t *next;
36 
37   bool explicit_version_p;
38   bool implied_p;
39 };
40 
41 /* Subset list.  */
42 class riscv_subset_list
43 {
44 private:
45   /* Original arch string.  */
46   const char *m_arch;
47 
48   /* Location of arch string, used for report error.  */
49   location_t m_loc;
50 
51   /* Head of subset info list.  */
52   riscv_subset_t *m_head;
53 
54   /* Tail of subset info list.  */
55   riscv_subset_t *m_tail;
56 
57   /* X-len of m_arch. */
58   unsigned m_xlen;
59 
60   riscv_subset_list (const char *, location_t);
61 
62   const char *parsing_subset_version (const char *, const char *, unsigned *,
63 				      unsigned *, bool, bool *);
64 
65   const char *parse_std_ext (const char *);
66 
67   const char *parse_multiletter_ext (const char *, const char *,
68 				     const char *);
69 
70   void handle_implied_ext (riscv_subset_t *);
71   void handle_combine_ext ();
72 
73 public:
74   ~riscv_subset_list ();
75 
76   void add (const char *, int, int, bool, bool);
77 
78   void add (const char *, bool);
79 
80   riscv_subset_t *lookup (const char *,
81 			  int major_version = RISCV_DONT_CARE_VERSION,
82 			  int minor_version = RISCV_DONT_CARE_VERSION) const;
83 
84   std::string to_string (bool) const;
85 
xlen()86   unsigned xlen () const {return m_xlen;};
87 
88   static riscv_subset_list *parse (const char *, location_t);
89 
begin()90   const riscv_subset_t *begin () const {return m_head;};
end()91   const riscv_subset_t *end () const {return NULL;};
92 };
93 
94 extern const riscv_subset_list *riscv_current_subset_list (void);
95 
96 #endif /* ! GCC_RISCV_SUBSET_H */
97