1//===-- RegisterContextFreeBSD_powerpc.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_powerpc.h"
10#include "RegisterContextPOSIX_powerpc.h"
11#include <vector>
12
13using namespace lldb_private;
14using namespace lldb;
15
16// http://svnweb.freebsd.org/base/head/sys/powerpc/include/reg.h
17typedef struct _GPR64 {
18 uint64_t r0;
19 uint64_t r1;
20 uint64_t r2;
21 uint64_t r3;
22 uint64_t r4;
23 uint64_t r5;
24 uint64_t r6;
25 uint64_t r7;
26 uint64_t r8;
27 uint64_t r9;
28 uint64_t r10;
29 uint64_t r11;
30 uint64_t r12;
31 uint64_t r13;
32 uint64_t r14;
33 uint64_t r15;
34 uint64_t r16;
35 uint64_t r17;
36 uint64_t r18;
37 uint64_t r19;
38 uint64_t r20;
39 uint64_t r21;
40 uint64_t r22;
41 uint64_t r23;
42 uint64_t r24;
43 uint64_t r25;
44 uint64_t r26;
45 uint64_t r27;
46 uint64_t r28;
47 uint64_t r29;
48 uint64_t r30;
49 uint64_t r31;
50 uint64_t lr;
51 uint64_t cr;
52 uint64_t xer;
53 uint64_t ctr;
54 uint64_t pc;
55} GPR64;
56
57typedef struct _GPR32 {
58 uint32_t r0;
59 uint32_t r1;
60 uint32_t r2;
61 uint32_t r3;
62 uint32_t r4;
63 uint32_t r5;
64 uint32_t r6;
65 uint32_t r7;
66 uint32_t r8;
67 uint32_t r9;
68 uint32_t r10;
69 uint32_t r11;
70 uint32_t r12;
71 uint32_t r13;
72 uint32_t r14;
73 uint32_t r15;
74 uint32_t r16;
75 uint32_t r17;
76 uint32_t r18;
77 uint32_t r19;
78 uint32_t r20;
79 uint32_t r21;
80 uint32_t r22;
81 uint32_t r23;
82 uint32_t r24;
83 uint32_t r25;
84 uint32_t r26;
85 uint32_t r27;
86 uint32_t r28;
87 uint32_t r29;
88 uint32_t r30;
89 uint32_t r31;
90 uint32_t lr;
91 uint32_t cr;
92 uint32_t xer;
93 uint32_t ctr;
94 uint32_t pc;
95} GPR32;
96
97typedef struct _FPR {
98 uint64_t f0;
99 uint64_t f1;
100 uint64_t f2;
101 uint64_t f3;
102 uint64_t f4;
103 uint64_t f5;
104 uint64_t f6;
105 uint64_t f7;
106 uint64_t f8;
107 uint64_t f9;
108 uint64_t f10;
109 uint64_t f11;
110 uint64_t f12;
111 uint64_t f13;
112 uint64_t f14;
113 uint64_t f15;
114 uint64_t f16;
115 uint64_t f17;
116 uint64_t f18;
117 uint64_t f19;
118 uint64_t f20;
119 uint64_t f21;
120 uint64_t f22;
121 uint64_t f23;
122 uint64_t f24;
123 uint64_t f25;
124 uint64_t f26;
125 uint64_t f27;
126 uint64_t f28;
127 uint64_t f29;
128 uint64_t f30;
129 uint64_t f31;
130 uint64_t fpscr;
131} FPR;
132
133typedef struct _VMX {
134 uint32_t v0[4];
135 uint32_t v1[4];
136 uint32_t v2[4];
137 uint32_t v3[4];
138 uint32_t v4[4];
139 uint32_t v5[4];
140 uint32_t v6[4];
141 uint32_t v7[4];
142 uint32_t v8[4];
143 uint32_t v9[4];
144 uint32_t v10[4];
145 uint32_t v11[4];
146 uint32_t v12[4];
147 uint32_t v13[4];
148 uint32_t v14[4];
149 uint32_t v15[4];
150 uint32_t v16[4];
151 uint32_t v17[4];
152 uint32_t v18[4];
153 uint32_t v19[4];
154 uint32_t v20[4];
155 uint32_t v21[4];
156 uint32_t v22[4];
157 uint32_t v23[4];
158 uint32_t v24[4];
159 uint32_t v25[4];
160 uint32_t v26[4];
161 uint32_t v27[4];
162 uint32_t v28[4];
163 uint32_t v29[4];
164 uint32_t v30[4];
165 uint32_t v31[4];
166 uint32_t pad[2];
167 uint32_t vrsave;
168 uint32_t vscr;
169} VMX;
170
171// Include RegisterInfos_powerpc to declare our g_register_infos_powerpc
172// structure.
173#define DECLARE_REGISTER_INFOS_POWERPC_STRUCT
174#include "RegisterInfos_powerpc.h"
175#undef DECLARE_REGISTER_INFOS_POWERPC_STRUCT
176
177RegisterContextFreeBSD_powerpc::RegisterContextFreeBSD_powerpc(
178 const ArchSpec &target_arch)
179 : RegisterInfoInterface(target_arch) {}
180
181RegisterContextFreeBSD_powerpc::~RegisterContextFreeBSD_powerpc() = default;
182
183size_t RegisterContextFreeBSD_powerpc::GetGPRSize() const {
184 // This is an 'abstract' base, so no GPR struct.
185 return 0;
186}
187
188const RegisterInfo *RegisterContextFreeBSD_powerpc::GetRegisterInfo() const {
189 llvm_unreachable("Abstract class!");
190 return nullptr;
191}
192
193uint32_t RegisterContextFreeBSD_powerpc::GetRegisterCount() const { return 0; }
194
195RegisterContextFreeBSD_powerpc32::RegisterContextFreeBSD_powerpc32(
196 const ArchSpec &target_arch)
197 : RegisterContextFreeBSD_powerpc(target_arch) {}
198
199RegisterContextFreeBSD_powerpc32::~RegisterContextFreeBSD_powerpc32() = default;
200
201size_t RegisterContextFreeBSD_powerpc32::GetGPRSize() const {
202 return sizeof(GPR32);
203}
204
205const RegisterInfo *RegisterContextFreeBSD_powerpc32::GetRegisterInfo() const {
206 return g_register_infos_powerpc32;
207}
208
209uint32_t RegisterContextFreeBSD_powerpc32::GetRegisterCount() const {
210 return static_cast<uint32_t>(sizeof(g_register_infos_powerpc32) /
211 sizeof(g_register_infos_powerpc32[0]));
212}
213
214RegisterContextFreeBSD_powerpc64::RegisterContextFreeBSD_powerpc64(
215 const ArchSpec &target_arch)
216 : RegisterContextFreeBSD_powerpc(target_arch) {}
217
218RegisterContextFreeBSD_powerpc64::~RegisterContextFreeBSD_powerpc64() = default;
219
220size_t RegisterContextFreeBSD_powerpc64::GetGPRSize() const {
221 return sizeof(GPR64);
222}
223
224const RegisterInfo *RegisterContextFreeBSD_powerpc64::GetRegisterInfo() const {
225 if (GetTargetArchitecture().GetMachine() == llvm::Triple::ppc)
226 return g_register_infos_powerpc64_32;
227 return g_register_infos_powerpc64;
228}
229
230uint32_t RegisterContextFreeBSD_powerpc64::GetRegisterCount() const {
231 return static_cast<uint32_t>(sizeof(g_register_infos_powerpc64) /
232 sizeof(g_register_infos_powerpc64[0]));
233}
234

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