1 /* Definition of data structure of RISC-V subset for GNU compiler. 2 Copyright (C) 2011-2021 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 72 public: 73 ~riscv_subset_list (); 74 75 void add (const char *, int, int, bool, bool); 76 77 void add (const char *, bool); 78 79 riscv_subset_t *lookup (const char *, 80 int major_version = RISCV_DONT_CARE_VERSION, 81 int minor_version = RISCV_DONT_CARE_VERSION) const; 82 83 std::string to_string (bool) const; 84 xlen()85 unsigned xlen () const {return m_xlen;}; 86 87 static riscv_subset_list *parse (const char *, location_t); 88 begin()89 const riscv_subset_t *begin () const {return m_head;}; end()90 const riscv_subset_t *end () const {return NULL;}; 91 }; 92 93 extern const riscv_subset_list *riscv_current_subset_list (void); 94 95 #endif /* ! GCC_RISCV_SUBSET_H */ 96