1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
|
//===----------------------------- Registers.hpp --------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//
// Models register sets for supported processors.
//
//===----------------------------------------------------------------------===//
#ifndef __REGISTERS_HPP__
#define __REGISTERS_HPP__
#include <cassert>
#include <cstdint>
namespace _Unwind {
enum {
REGNO_X86_EAX = 0,
REGNO_X86_ECX = 1,
REGNO_X86_EDX = 2,
REGNO_X86_EBX = 3,
REGNO_X86_ESP = 4,
REGNO_X86_EBP = 5,
REGNO_X86_ESI = 6,
REGNO_X86_EDI = 7,
REGNO_X86_EIP = 8,
};
class Registers_x86 {
public:
enum {
LAST_RESTORE_REG = REGNO_X86_EIP,
IP_PSEUDO_REG = REGNO_X86_EIP,
LAST_REGISTER = REGNO_X86_EIP,
};
__dso_hidden Registers_x86();
static int dwarf2regno(int num) { return num; }
bool validRegister(int num) const {
return num >= REGNO_X86_EAX && num <= REGNO_X86_EDI;
}
uint32_t getRegister(int num) const {
assert(validRegister(num));
return reg[num];
}
void setRegister(int num, uint32_t value) {
assert(validRegister(num));
reg[num] = value;
}
uint32_t getIP() const { return reg[REGNO_X86_EIP]; }
void setIP(uint32_t value) { reg[REGNO_X86_EIP] = value; }
uint32_t getSP() const { return reg[REGNO_X86_ESP]; }
void setSP(uint32_t value) { reg[REGNO_X86_ESP] = value; }
bool validFloatVectorRegister(int num) const { return false; }
void copyFloatVectorRegister(int num, uint32_t addr) {
}
__dso_hidden void jumpto() const __dead;
private:
uint32_t reg[REGNO_X86_EIP + 1];
};
enum {
REGNO_X86_64_RAX = 0,
REGNO_X86_64_RDX = 1,
REGNO_X86_64_RCX = 2,
REGNO_X86_64_RBX = 3,
REGNO_X86_64_RSI = 4,
REGNO_X86_64_RDI = 5,
REGNO_X86_64_RBP = 6,
REGNO_X86_64_RSP = 7,
REGNO_X86_64_R8 = 8,
REGNO_X86_64_R9 = 9,
REGNO_X86_64_R10 = 10,
REGNO_X86_64_R11 = 11,
REGNO_X86_64_R12 = 12,
REGNO_X86_64_R13 = 13,
REGNO_X86_64_R14 = 14,
REGNO_X86_64_R15 = 15,
REGNO_X86_64_RIP = 16,
};
class Registers_x86_64 {
public:
enum {
LAST_RESTORE_REG = REGNO_X86_64_RIP,
IP_PSEUDO_REG = REGNO_X86_64_RIP,
LAST_REGISTER = REGNO_X86_64_RIP,
};
__dso_hidden Registers_x86_64();
static int dwarf2regno(int num) { return num; }
bool validRegister(int num) const {
return num >= REGNO_X86_64_RAX && num <= REGNO_X86_64_R15;
}
uint64_t getRegister(int num) const {
assert(validRegister(num));
return reg[num];
}
void setRegister(int num, uint64_t value) {
assert(validRegister(num));
reg[num] = value;
}
uint64_t getIP() const { return reg[REGNO_X86_64_RIP]; }
void setIP(uint64_t value) { reg[REGNO_X86_64_RIP] = value; }
uint64_t getSP() const { return reg[REGNO_X86_64_RSP]; }
void setSP(uint64_t value) { reg[REGNO_X86_64_RSP] = value; }
bool validFloatVectorRegister(int num) const { return false; }
void copyFloatVectorRegister(int num, uint64_t addr) {
}
__dso_hidden void jumpto() const __dead;
private:
uint64_t reg[REGNO_X86_64_RIP + 1];
};
enum {
DWARF_PPC32_R0 = 0,
DWARF_PPC32_R31 = 31,
DWARF_PPC32_F0 = 32,
DWARF_PPC32_F31 = 63,
DWARF_PPC32_V0 = 1124,
DWARF_PPC32_V31 = 1155,
DWARF_PPC32_LR = 65,
DWARF_PPC32_CTR = 66,
DWARF_PPC32_XER = 76,
REGNO_PPC32_R0 = 0,
REGNO_PPC32_R1 = 0,
REGNO_PPC32_R31 = 31,
REGNO_PPC32_CR = 32,
REGNO_PPC32_LR = 33,
REGNO_PPC32_CTR = 34,
REGNO_PPC32_XER = 35,
REGNO_PPC32_SRR0 = 36,
REGNO_PPC32_F0 = REGNO_PPC32_SRR0 + 1,
REGNO_PPC32_F31 = REGNO_PPC32_F0 + 31,
REGNO_PPC32_V0 = REGNO_PPC32_F31 + 1,
REGNO_PPC32_V31 = REGNO_PPC32_V0 + 31,
};
class Registers_ppc32 {
public:
enum {
LAST_RESTORE_REG = REGNO_PPC32_V31,
IP_PSEUDO_REG = REGNO_PPC32_SRR0,
LAST_REGISTER = REGNO_PPC32_V31,
};
__dso_hidden Registers_ppc32();
static int dwarf2regno(int num) {
if (num >= DWARF_PPC32_R0 && num <= DWARF_PPC32_R31)
return REGNO_PPC32_R0 + (num - DWARF_PPC32_R0);
if (num >= DWARF_PPC32_F0 && num <= DWARF_PPC32_F31)
return REGNO_PPC32_F0 + (num - DWARF_PPC32_F0);
if (num >= DWARF_PPC32_V0 && num <= DWARF_PPC32_V31)
return REGNO_PPC32_V0 + (num - DWARF_PPC32_V0);
return LAST_REGISTER + 1;
}
bool validRegister(int num) const {
return num >= 0 && num <= LAST_RESTORE_REG;
}
uint64_t getRegister(int num) const {
assert(validRegister(num));
return reg[num];
}
void setRegister(int num, uint64_t value) {
assert(validRegister(num));
reg[num] = value;
}
uint64_t getIP() const { return reg[REGNO_PPC32_SRR0]; }
void setIP(uint64_t value) { reg[REGNO_PPC32_SRR0] = value; }
uint64_t getSP() const { return reg[REGNO_PPC32_R1]; }
void setSP(uint64_t value) { reg[REGNO_PPC32_R1] = value; }
bool validFloatVectorRegister(int num) const {
return (num >= REGNO_PPC32_F0 && num <= REGNO_PPC32_F31) ||
(num >= REGNO_PPC32_V0 && num <= REGNO_PPC32_V31);
}
void copyFloatVectorRegister(int num, uint64_t addr_) {
const void *addr = reinterpret_cast<const void *>(addr_);
if (num >= REGNO_PPC32_F0 && num <= REGNO_PPC32_F31)
memcpy(fpreg + (num - REGNO_PPC32_F0), addr, sizeof(fpreg[0]));
else
memcpy(vecreg + (num - REGNO_PPC32_V0), addr, sizeof(vecreg[0]));
}
__dso_hidden void jumpto() const __dead;
private:
struct vecreg_t {
uint64_t low, high;
};
uint32_t reg[REGNO_PPC32_SRR0 + 1];
uint64_t fpreg[32];
vecreg_t vecreg[64];
};
enum {
DWARF_ARM32_R0 = 0,
DWARF_ARM32_R15 = 15,
DWARF_ARM32_SPSR = 128,
DWARF_ARM32_D0 = 256, // VFP-v3/Neon
DWARF_ARM32_D31 = 287,
REGNO_ARM32_R0 = 0,
REGNO_ARM32_SP = 13,
REGNO_ARM32_R15 = 15,
REGNO_ARM32_SPSR = 16,
REGNO_ARM32_D0 = 0,
REGNO_ARM32_D31 = 31,
};
class Registers_arm32 {
public:
enum {
LAST_RESTORE_REG = REGNO_ARM32_SPSR,
IP_PSEUDO_REG = REGNO_ARM32_SPSR,
LAST_REGISTER = REGNO_ARM32_D31,
};
__dso_hidden Registers_arm32();
static int dwarf2regno(int num) {
if (num >= DWARF_ARM32_R0 && num <= DWARF_ARM32_R15)
return REGNO_ARM32_R0 + (num - DWARF_ARM32_R0);
if (num >= DWARF_ARM32_D0 && num <= DWARF_ARM32_D31)
return REGNO_ARM32_D0 + (num - DWARF_ARM32_D0);
if (num == DWARF_ARM32_SPSR)
return REGNO_ARM32_SPSR;
return LAST_REGISTER + 1;
}
bool validRegister(int num) const {
return num >= 0 && num <= LAST_RESTORE_REG;
}
uint64_t getRegister(int num) const {
assert(validRegister(num));
return reg[num];
}
void setRegister(int num, uint64_t value) {
assert(validRegister(num));
reg[num] = value;
}
uint64_t getIP() const { return reg[REGNO_ARM32_R15]; }
void setIP(uint64_t value) { reg[REGNO_ARM32_R15] = value; }
uint64_t getSP() const { return reg[REGNO_ARM32_SP]; }
void setSP(uint64_t value) { reg[REGNO_ARM32_SP] = value; }
bool validFloatVectorRegister(int num) const {
return (num >= REGNO_ARM32_D0 && num <= REGNO_ARM32_D31);
}
void copyFloatVectorRegister(int num, uint64_t addr_) {
const void *addr = reinterpret_cast<const void *>(addr_);
memcpy(fpreg + (num - REGNO_ARM32_D0), addr, sizeof(fpreg[0]));
}
__dso_hidden void jumpto() const __dead;
private:
uint32_t reg[REGNO_ARM32_SPSR + 1];
uint64_t fpreg[32];
};
} // namespace _Unwind
#endif // __REGISTERS_HPP__
|