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