1//===-- RegisterContextFreeBSD_mips64.cpp ---------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===---------------------------------------------------------------------===//
8
9#include "RegisterContextFreeBSD_mips64.h"
10#include "RegisterContextPOSIX_mips64.h"
11#include "lldb-mips-freebsd-register-enums.h"
12#include <vector>
13
14using namespace lldb_private;
15using namespace lldb;
16
17static const uint32_t g_gp_regnums_mips64[] = {
18 gpr_zero_mips64, gpr_r1_mips64, gpr_r2_mips64, gpr_r3_mips64,
19 gpr_r4_mips64, gpr_r5_mips64, gpr_r6_mips64, gpr_r7_mips64,
20 gpr_r8_mips64, gpr_r9_mips64, gpr_r10_mips64, gpr_r11_mips64,
21 gpr_r12_mips64, gpr_r13_mips64, gpr_r14_mips64, gpr_r15_mips64,
22 gpr_r16_mips64, gpr_r17_mips64, gpr_r18_mips64, gpr_r19_mips64,
23 gpr_r20_mips64, gpr_r21_mips64, gpr_r22_mips64, gpr_r23_mips64,
24 gpr_r24_mips64, gpr_r25_mips64, gpr_r26_mips64, gpr_r27_mips64,
25 gpr_gp_mips64, gpr_sp_mips64, gpr_r30_mips64, gpr_ra_mips64,
26 gpr_sr_mips64, gpr_mullo_mips64, gpr_mulhi_mips64, gpr_badvaddr_mips64,
27 gpr_cause_mips64, gpr_pc_mips64, gpr_ic_mips64, gpr_dummy_mips64,
28 LLDB_INVALID_REGNUM // register sets need to end with this flag
29};
30
31static_assert((sizeof(g_gp_regnums_mips64) / sizeof(g_gp_regnums_mips64[0])) -
32 1 ==
33 k_num_gpr_registers_mips64,
34 "g_gp_regnums_mips64 has wrong number of register infos");
35
36const uint32_t g_fp_regnums_mips64[] = {
37 fpr_f0_mips64, fpr_f1_mips64, fpr_f2_mips64, fpr_f3_mips64,
38 fpr_f4_mips64, fpr_f5_mips64, fpr_f6_mips64, fpr_f7_mips64,
39 fpr_f8_mips64, fpr_f9_mips64, fpr_f10_mips64, fpr_f11_mips64,
40 fpr_f12_mips64, fpr_f13_mips64, fpr_f14_mips64, fpr_f15_mips64,
41 fpr_f16_mips64, fpr_f17_mips64, fpr_f18_mips64, fpr_f19_mips64,
42 fpr_f20_mips64, fpr_f21_mips64, fpr_f22_mips64, fpr_f23_mips64,
43 fpr_f24_mips64, fpr_f25_mips64, fpr_f26_mips64, fpr_f27_mips64,
44 fpr_f28_mips64, fpr_f29_mips64, fpr_f30_mips64, fpr_f31_mips64,
45 fpr_fcsr_mips64, fpr_fir_mips64,
46 LLDB_INVALID_REGNUM // register sets need to end with this flag
47};
48
49static_assert((sizeof(g_fp_regnums_mips64) / sizeof(g_fp_regnums_mips64[0])) -
50 1 ==
51 k_num_fpr_registers_mips64,
52 "g_fp_regnums_mips64 has wrong number of register infos");
53
54// Number of register sets provided by this context.
55constexpr size_t k_num_register_sets = 2;
56
57static const RegisterSet g_reg_sets_mips64[k_num_register_sets] = {
58 {.name: "General Purpose Registers", .short_name: "gpr", .num_registers: k_num_gpr_registers_mips64,
59 .registers: g_gp_regnums_mips64},
60 {.name: "Floating Point Registers", .short_name: "fpu", .num_registers: k_num_fpr_registers_mips64,
61 .registers: g_fp_regnums_mips64},
62};
63
64// http://svnweb.freebsd.org/base/head/sys/mips/include/regnum.h
65typedef struct _GPR {
66 uint64_t zero;
67 uint64_t r1;
68 uint64_t r2;
69 uint64_t r3;
70 uint64_t r4;
71 uint64_t r5;
72 uint64_t r6;
73 uint64_t r7;
74 uint64_t r8;
75 uint64_t r9;
76 uint64_t r10;
77 uint64_t r11;
78 uint64_t r12;
79 uint64_t r13;
80 uint64_t r14;
81 uint64_t r15;
82 uint64_t r16;
83 uint64_t r17;
84 uint64_t r18;
85 uint64_t r19;
86 uint64_t r20;
87 uint64_t r21;
88 uint64_t r22;
89 uint64_t r23;
90 uint64_t r24;
91 uint64_t r25;
92 uint64_t r26;
93 uint64_t r27;
94 uint64_t gp;
95 uint64_t sp;
96 uint64_t r30;
97 uint64_t ra;
98 uint64_t sr;
99 uint64_t mullo;
100 uint64_t mulhi;
101 uint64_t badvaddr;
102 uint64_t cause;
103 uint64_t pc;
104 uint64_t ic;
105 uint64_t dummy;
106} GPR_freebsd_mips;
107
108typedef struct _FPR {
109 uint64_t f0;
110 uint64_t f1;
111 uint64_t f2;
112 uint64_t f3;
113 uint64_t f4;
114 uint64_t f5;
115 uint64_t f6;
116 uint64_t f7;
117 uint64_t f8;
118 uint64_t f9;
119 uint64_t f10;
120 uint64_t f11;
121 uint64_t f12;
122 uint64_t f13;
123 uint64_t f14;
124 uint64_t f15;
125 uint64_t f16;
126 uint64_t f17;
127 uint64_t f18;
128 uint64_t f19;
129 uint64_t f20;
130 uint64_t f21;
131 uint64_t f22;
132 uint64_t f23;
133 uint64_t f24;
134 uint64_t f25;
135 uint64_t f26;
136 uint64_t f27;
137 uint64_t f28;
138 uint64_t f29;
139 uint64_t f30;
140 uint64_t f31;
141 uint64_t fcsr;
142 uint64_t fir;
143} FPR_freebsd_mips;
144
145// Include RegisterInfos_mips64 to declare our g_register_infos_mips64
146// structure.
147#define DECLARE_REGISTER_INFOS_MIPS64_STRUCT
148#include "RegisterInfos_mips64.h"
149#undef DECLARE_REGISTER_INFOS_MIPS64_STRUCT
150
151RegisterContextFreeBSD_mips64::RegisterContextFreeBSD_mips64(
152 const ArchSpec &target_arch)
153 : RegisterInfoInterface(target_arch) {}
154
155size_t RegisterContextFreeBSD_mips64::GetGPRSize() const {
156 return sizeof(GPR_freebsd_mips);
157}
158
159const RegisterSet *
160RegisterContextFreeBSD_mips64::GetRegisterSet(size_t set) const {
161 // Check if RegisterSet is available
162 if (set < k_num_register_sets)
163 return &g_reg_sets_mips64[set];
164 return nullptr;
165}
166
167size_t RegisterContextFreeBSD_mips64::GetRegisterSetCount() const {
168 return k_num_register_sets;
169}
170
171const RegisterInfo *RegisterContextFreeBSD_mips64::GetRegisterInfo() const {
172 assert(GetTargetArchitecture().GetCore() == ArchSpec::eCore_mips64);
173 return g_register_infos_mips64;
174}
175
176uint32_t RegisterContextFreeBSD_mips64::GetRegisterCount() const {
177 return static_cast<uint32_t>(sizeof(g_register_infos_mips64) /
178 sizeof(g_register_infos_mips64[0]));
179}
180

source code of lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.cpp