xref: /netbsd/external/gpl3/gdb/dist/gdb/arch/arc.h (revision 1424dfb3)
1*1424dfb3Schristos /* Copyright (C) 2017-2020 Free Software Foundation, Inc.
2*1424dfb3Schristos 
3*1424dfb3Schristos    This file is part of GDB.
4*1424dfb3Schristos 
5*1424dfb3Schristos    This program is free software; you can redistribute it and/or modify
6*1424dfb3Schristos    it under the terms of the GNU General Public License as published by
7*1424dfb3Schristos    the Free Software Foundation; either version 3 of the License, or
8*1424dfb3Schristos    (at your option) any later version.
9*1424dfb3Schristos 
10*1424dfb3Schristos    This program is distributed in the hope that it will be useful,
11*1424dfb3Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
12*1424dfb3Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13*1424dfb3Schristos    GNU General Public License for more details.
14*1424dfb3Schristos 
15*1424dfb3Schristos    You should have received a copy of the GNU General Public License
16*1424dfb3Schristos    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
17*1424dfb3Schristos 
18*1424dfb3Schristos #ifndef ARCH_ARC_H
19*1424dfb3Schristos #define ARCH_ARC_H
20*1424dfb3Schristos 
21*1424dfb3Schristos #include "gdbsupport/tdesc.h"
22*1424dfb3Schristos 
23*1424dfb3Schristos /* Supported ARC ISAs.  */
24*1424dfb3Schristos enum arc_isa
25*1424dfb3Schristos {
26*1424dfb3Schristos   ARC_ISA_ARCV1 = 1,  /* a.k.a. ARCompact (ARC600, ARC700)  */
27*1424dfb3Schristos   ARC_ISA_ARCV2	      /* such as ARC EM and ARC HS  */
28*1424dfb3Schristos };
29*1424dfb3Schristos 
30*1424dfb3Schristos struct arc_gdbarch_features
31*1424dfb3Schristos {
arc_gdbarch_featuresarc_gdbarch_features32*1424dfb3Schristos   arc_gdbarch_features (int reg_size, arc_isa isa)
33*1424dfb3Schristos     : reg_size (reg_size), isa (isa)
34*1424dfb3Schristos   {}
35*1424dfb3Schristos 
36*1424dfb3Schristos   /* Register size in bytes.  Possible values are 4, and 8.  A 0 indicates
37*1424dfb3Schristos      an uninitialised value.  */
38*1424dfb3Schristos   const int reg_size;
39*1424dfb3Schristos 
40*1424dfb3Schristos   /* See ARC_ISA enum.  */
41*1424dfb3Schristos   const arc_isa isa;
42*1424dfb3Schristos 
43*1424dfb3Schristos   /* Equality operator.  */
44*1424dfb3Schristos   bool operator== (const struct arc_gdbarch_features &rhs) const
45*1424dfb3Schristos   {
46*1424dfb3Schristos     return (reg_size == rhs.reg_size && isa == rhs.isa);
47*1424dfb3Schristos   }
48*1424dfb3Schristos 
49*1424dfb3Schristos   /* Inequality operator.  */
50*1424dfb3Schristos   bool operator!= (const struct arc_gdbarch_features &rhs) const
51*1424dfb3Schristos   {
52*1424dfb3Schristos     return !(*this == rhs);
53*1424dfb3Schristos   }
54*1424dfb3Schristos 
55*1424dfb3Schristos   /* Used by std::unordered_map to hash the feature sets.  The hash is
56*1424dfb3Schristos      calculated in the manner below:
57*1424dfb3Schristos      REG_SIZE |  ISA
58*1424dfb3Schristos       5-bits  | 4-bits  */
59*1424dfb3Schristos 
hasharc_gdbarch_features60*1424dfb3Schristos   std::size_t hash () const noexcept
61*1424dfb3Schristos   {
62*1424dfb3Schristos     std::size_t val = ((reg_size & 0x1f) << 8 | (isa & 0xf) << 0);
63*1424dfb3Schristos     return val;
64*1424dfb3Schristos   }
65*1424dfb3Schristos };
66*1424dfb3Schristos 
67*1424dfb3Schristos #ifdef GDBSERVER
68*1424dfb3Schristos 
69*1424dfb3Schristos /* Create and return a target description that is compatible with FEATURES.
70*1424dfb3Schristos    The only external client of this must be the gdbserver which manipulates
71*1424dfb3Schristos    the returned data.  */
72*1424dfb3Schristos 
73*1424dfb3Schristos target_desc *arc_create_target_description
74*1424dfb3Schristos 	(const struct arc_gdbarch_features &features);
75*1424dfb3Schristos 
76*1424dfb3Schristos #else
77*1424dfb3Schristos 
78*1424dfb3Schristos /* Lookup the cache for a target description matching the FEATURES.
79*1424dfb3Schristos    If nothing is found, then create one and return it.  */
80*1424dfb3Schristos 
81*1424dfb3Schristos const target_desc *arc_lookup_target_description
82*1424dfb3Schristos 	(const struct arc_gdbarch_features &features);
83*1424dfb3Schristos 
84*1424dfb3Schristos #endif /* GDBSERVER */
85*1424dfb3Schristos 
86*1424dfb3Schristos 
87*1424dfb3Schristos #endif /* ARCH_ARC_H */
88