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