]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/amdgpu-tdep.h
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / amdgpu-tdep.h
CommitLineData
18b4d073
SM
1/* Target-dependent code for the AMDGPU architectures.
2
1d506c26 3 Copyright (C) 2019-2024 Free Software Foundation, Inc.
18b4d073
SM
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20#ifndef AMDGPU_TDEP_H
21#define AMDGPU_TDEP_H
22
23#include "gdbarch.h"
24
25#include <amd-dbgapi/amd-dbgapi.h>
26#include <unordered_map>
27
28/* Provide std::unordered_map::Hash for amd_dbgapi_register_id_t. */
29struct register_id_hash
30{
31 size_t
32 operator() (const amd_dbgapi_register_id_t &register_id) const
33 {
34 return std::hash<decltype (register_id.handle)> () (register_id.handle);
35 }
36};
37
38/* Provide std::unordered_map::Equal for amd_dbgapi_register_id_t. */
39struct register_id_equal_to
40{
41 bool
42 operator() (const amd_dbgapi_register_id_t &lhs,
43 const amd_dbgapi_register_id_t &rhs) const
44 {
45 return std::equal_to<decltype (lhs.handle)> () (lhs.handle, rhs.handle);
46 }
47};
48
49/* AMDGPU architecture specific information. */
50struct amdgpu_gdbarch_tdep : gdbarch_tdep_base
51{
52 /* This architecture's breakpoint instruction. */
53 gdb::unique_xmalloc_ptr<gdb_byte> breakpoint_instruction_bytes;
54 size_t breakpoint_instruction_size;
55
56 /* A vector of register_ids indexed by their equivalent gdb regnum. */
57 std::vector<amd_dbgapi_register_id_t> register_ids;
58
59 /* A vector of register_properties indexed by their equivalent gdb regnum. */
60 std::vector<amd_dbgapi_register_properties_t> register_properties;
61
62 /* A vector of register names indexed by their equivalent gdb regnum. */
63 std::vector<std::string> register_names;
64
65 /* A vector of register types created from the amd-dbgapi type strings,
66 indexed by their equivalent gdb regnum. These are computed lazily by
67 amdgpu_register_type, entries that haven't been computed yet are
68 nullptr. */
69 std::vector<type *> register_types;
70
71 /* A vector of GDB register numbers indexed by DWARF register number.
72
73 Unused DWARF register numbers map to value -1. */
74 std::vector<int> dwarf_regnum_to_gdb_regnum;
75
76 /* A map of gdb regnums keyed by they equivalent register_id. */
77 std::unordered_map<amd_dbgapi_register_id_t, int, register_id_hash,
78 register_id_equal_to>
79 regnum_map;
80
81 /* A map of register_class_ids keyed by their name. */
82 std::unordered_map<std::string, amd_dbgapi_register_class_id_t>
83 register_class_map;
84};
85
86/* Return true if GDBARCH is of an AMDGPU architecture. */
87bool is_amdgpu_arch (struct gdbarch *gdbarch);
88
89/* Return the amdgpu-specific data associated to ARCH. */
90
91amdgpu_gdbarch_tdep *get_amdgpu_gdbarch_tdep (gdbarch *arch);
92
93#endif /* AMDGPU_TDEP_H */