2 /*--------------------------------------------------------------------*/
3 /*--- Contains machine-specific (guest-state-layout-specific) ---*/
4 /*--- support for origin tracking. ---*/
5 /*--- mc_machine.c ---*/
6 /*--------------------------------------------------------------------*/
9 This file is part of MemCheck, a heavyweight Valgrind tool for
10 detecting memory errors.
12 Copyright (C) 2008-2017 OpenWorks Ltd
15 This program is free software; you can redistribute it and/or
16 modify it under the terms of the GNU General Public License as
17 published by the Free Software Foundation; either version 2 of the
18 License, or (at your option) any later version.
20 This program is distributed in the hope that it will be useful, but
21 WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 General Public License for more details.
25 You should have received a copy of the GNU General Public License
26 along with this program; if not, see <http://www.gnu.org/licenses/>.
28 The GNU General Public License is contained in the file COPYING.
30 Neither the names of the U.S. Department of Energy nor the
31 University of California nor the names of its contributors may be
32 used to endorse or promote products derived from this software
33 without prior written permission.
36 #include "pub_tool_basics.h"
37 #include "pub_tool_poolalloc.h" // For mc_include.h
38 #include "pub_tool_hashtable.h" // For mc_include.h
39 #include "pub_tool_libcassert.h"
40 #include "pub_tool_libcprint.h"
41 #include "pub_tool_tooliface.h"
42 #include "pub_tool_guest.h" // VexGuestArchState
44 #include "mc_include.h"
46 #define MC_SIZEOF_GUEST_STATE sizeof(VexGuestArchState)
48 __attribute__((unused
))
49 static inline Bool
host_is_big_endian ( void ) {
51 return 0x1122 == *(UShort
*)(&x
);
54 __attribute__((unused
))
55 static inline Bool
host_is_little_endian ( void ) {
57 return 0x3344 == *(UShort
*)(&x
);
61 /* Let (offset,szB) describe a reference to the guest state section
64 This function returns the corresponding guest state reference to be
65 used for the origin tag (which of course will be in the second
66 shadow area), or -1 if this piece of guest state is not to be
69 Since origin tags are 32-bits long, we expect any returned value
70 (except -1) to be a multiple of 4, between 0 and
71 sizeof(guest-state)-4 inclusive.
73 This is inherently (guest-)architecture specific. For x86 and
74 amd64 we do some somewhat tricky things to give %AH .. %DH their
75 own tags. On ppc32/64 we do some marginally tricky things to give
76 all 16 %CR components their own tags.
78 This function only deals with references to the guest state whose
79 offsets are known at translation time (that is, references arising
80 from Put and Get). References whose offset is not known until run
81 time (that is, arise from PutI and GetI) are handled by
82 MC_(get_otrack_reg_array_equiv_int_type) below.
84 Note that since some guest state arrays (eg, the x86 FP reg stack)
85 are accessed both as arrays (eg, x87 insns) and directly (eg, MMX
86 insns), the two functions must be consistent for those sections of
87 guest state -- that is, they must both say the area is shadowed, or
90 This function is dependent on the host's endianness, hence we
91 assert that the use case is supported.
93 static Int
get_otrack_shadow_offset_wrk ( Int offset
, Int szB
); /*fwds*/
95 Int
MC_(get_otrack_shadow_offset
) ( Int offset
, Int szB
)
97 Int cand
= get_otrack_shadow_offset_wrk( offset
, szB
);
100 tl_assert(0 == (cand
& 3));
101 tl_assert(cand
<= MC_SIZEOF_GUEST_STATE
-4);
106 static Int
get_otrack_shadow_offset_wrk ( Int offset
, Int szB
)
108 /* -------------------- ppc64 -------------------- */
110 # if defined(VGA_ppc64be) || defined(VGA_ppc64le)
112 # define GOF(_fieldname) \
113 (offsetof(VexGuestPPC64State,guest_##_fieldname))
114 # define SZB(_fieldname) \
115 (sizeof(((VexGuestPPC64State*)0)->guest_##_fieldname))
121 # if defined(VGA_ppc64be)
122 tl_assert(host_is_big_endian());
123 # elif defined(VGA_ppc64le)
124 tl_assert(host_is_little_endian());
127 if (sz
== 8 || sz
== 4) {
128 /* The point of this is to achieve
129 if ((o == GOF(GPRn) && sz == 8) || (o == 4+GOF(GPRn) && sz == 4))
131 by testing ox instead of o, and setting ox back 4 bytes when sz == 4.
133 # if defined(VGA_ppc64le)
136 Int ox
= sz
== 8 ? o
: (o
- 4);
138 if (ox
== GOF(GPR0
)) return ox
;
139 if (ox
== GOF(GPR1
)) return ox
;
140 if (ox
== GOF(GPR2
)) return ox
;
141 if (ox
== GOF(GPR3
)) return ox
;
142 if (ox
== GOF(GPR4
)) return ox
;
143 if (ox
== GOF(GPR5
)) return ox
;
144 if (ox
== GOF(GPR6
)) return ox
;
145 if (ox
== GOF(GPR7
)) return ox
;
146 if (ox
== GOF(GPR8
)) return ox
;
147 if (ox
== GOF(GPR9
)) return ox
;
148 if (ox
== GOF(GPR10
)) return ox
;
149 if (ox
== GOF(GPR11
)) return ox
;
150 if (ox
== GOF(GPR12
)) return ox
;
151 if (ox
== GOF(GPR13
)) return ox
;
152 if (ox
== GOF(GPR14
)) return ox
;
153 if (ox
== GOF(GPR15
)) return ox
;
154 if (ox
== GOF(GPR16
)) return ox
;
155 if (ox
== GOF(GPR17
)) return ox
;
156 if (ox
== GOF(GPR18
)) return ox
;
157 if (ox
== GOF(GPR19
)) return ox
;
158 if (ox
== GOF(GPR20
)) return ox
;
159 if (ox
== GOF(GPR21
)) return ox
;
160 if (ox
== GOF(GPR22
)) return ox
;
161 if (ox
== GOF(GPR23
)) return ox
;
162 if (ox
== GOF(GPR24
)) return ox
;
163 if (ox
== GOF(GPR25
)) return ox
;
164 if (ox
== GOF(GPR26
)) return ox
;
165 if (ox
== GOF(GPR27
)) return ox
;
166 if (ox
== GOF(GPR28
)) return ox
;
167 if (ox
== GOF(GPR29
)) return ox
;
168 if (ox
== GOF(GPR30
)) return ox
;
169 if (ox
== GOF(GPR31
)) return ox
;
172 if (o
== GOF(LR
) && sz
== 8) return o
;
173 if (o
== GOF(CTR
) && sz
== 8) return o
;
175 if (o
== GOF(CIA
) && sz
== 8) return -1;
176 if (o
== GOF(IP_AT_SYSCALL
) && sz
== 8) return -1; /* slot unused */
177 if (o
== GOF(FPROUND
) && sz
== 1) return -1;
178 if (o
== GOF(DFPROUND
) && sz
== 1) return -1;
179 if (o
== GOF(C_FPCC
) && sz
== 1) return -1;
180 if (o
== GOF(EMNOTE
) && sz
== 4) return -1;
181 if (o
== GOF(CMSTART
) && sz
== 8) return -1;
182 if (o
== GOF(CMLEN
) && sz
== 8) return -1;
183 if (o
== GOF(VSCR
) && sz
== 4) return -1;
184 if (o
== GOF(VRSAVE
) && sz
== 4) return -1;
185 if (o
== GOF(REDIR_SP
) && sz
== 8) return -1;
186 if (o
== GOF(NRADDR
) && sz
== 8) return -1;
187 if (o
== GOF(NRADDR_GPR2
) && sz
== 8) return -1;
188 if (o
== GOF(REDIR_STACK
) && sz
== 8) return -1;
189 if (o
== GOF(TFHAR
) && sz
== 8) return -1;
190 if (o
== GOF(TEXASR
) && sz
== 8) return -1;
191 if (o
== GOF(TEXASRU
) && sz
== 8) return -1;
192 if (o
== GOF(TFIAR
) && sz
== 8) return -1;
193 if (o
== GOF(PPR
) && sz
== 8) return -1;
194 if (o
== GOF(PSPB
) && sz
== 8) return -1;
195 if (o
== GOF(DSCR
) && sz
== 8) return -1;
197 // With ISA 2.06, the "Vector-Scalar Floating-point" category
198 // provides facilities to support vector and scalar binary floating-
199 // point operations. A unified register file is an integral part
200 // of this new facility, combining floating point and vector registers
201 // using a 64x128-bit vector. These are referred to as VSR[0..63].
202 // The floating point registers are now mapped into double word element 0
203 // of VSR[0..31]. The 32x128-bit vector registers defined by the "Vector
204 // Facility [Category: Vector]" are now mapped to VSR[32..63].
206 // Floating point registers . . .
207 if (o
== GOF(VSR0
) && sz
== 8) return o
;
208 if (o
== GOF(VSR1
) && sz
== 8) return o
;
209 if (o
== GOF(VSR2
) && sz
== 8) return o
;
210 if (o
== GOF(VSR3
) && sz
== 8) return o
;
211 if (o
== GOF(VSR4
) && sz
== 8) return o
;
212 if (o
== GOF(VSR5
) && sz
== 8) return o
;
213 if (o
== GOF(VSR6
) && sz
== 8) return o
;
214 if (o
== GOF(VSR7
) && sz
== 8) return o
;
215 if (o
== GOF(VSR8
) && sz
== 8) return o
;
216 if (o
== GOF(VSR9
) && sz
== 8) return o
;
217 if (o
== GOF(VSR10
) && sz
== 8) return o
;
218 if (o
== GOF(VSR11
) && sz
== 8) return o
;
219 if (o
== GOF(VSR12
) && sz
== 8) return o
;
220 if (o
== GOF(VSR13
) && sz
== 8) return o
;
221 if (o
== GOF(VSR14
) && sz
== 8) return o
;
222 if (o
== GOF(VSR15
) && sz
== 8) return o
;
223 if (o
== GOF(VSR16
) && sz
== 8) return o
;
224 if (o
== GOF(VSR17
) && sz
== 8) return o
;
225 if (o
== GOF(VSR18
) && sz
== 8) return o
;
226 if (o
== GOF(VSR19
) && sz
== 8) return o
;
227 if (o
== GOF(VSR20
) && sz
== 8) return o
;
228 if (o
== GOF(VSR21
) && sz
== 8) return o
;
229 if (o
== GOF(VSR22
) && sz
== 8) return o
;
230 if (o
== GOF(VSR23
) && sz
== 8) return o
;
231 if (o
== GOF(VSR24
) && sz
== 8) return o
;
232 if (o
== GOF(VSR25
) && sz
== 8) return o
;
233 if (o
== GOF(VSR26
) && sz
== 8) return o
;
234 if (o
== GOF(VSR27
) && sz
== 8) return o
;
235 if (o
== GOF(VSR28
) && sz
== 8) return o
;
236 if (o
== GOF(VSR29
) && sz
== 8) return o
;
237 if (o
== GOF(VSR30
) && sz
== 8) return o
;
238 if (o
== GOF(VSR31
) && sz
== 8) return o
;
240 /* For the various byte sized XER/CR pieces, use offset 8
242 tl_assert(SZB(VSR0
) == 16);
243 if (o
== GOF(XER_SO
) && sz
== 1) return 8 +GOF(VSR0
);
244 if (o
== GOF(XER_OV
) && sz
== 1) return 8 +GOF(VSR1
);
245 if (o
== GOF(XER_OV32
) && sz
== 1) return 8 +GOF(VSR20
);
246 if (o
== GOF(XER_CA
) && sz
== 1) return 8 +GOF(VSR2
);
247 if (o
== GOF(XER_CA32
) && sz
== 1) return 8 +GOF(VSR21
);
248 if (o
== GOF(XER_BC
) && sz
== 1) return 8 +GOF(VSR3
);
250 if (o
== GOF(CR0_321
) && sz
== 1) return 8 +GOF(VSR4
);
251 if (o
== GOF(CR0_0
) && sz
== 1) return 8 +GOF(VSR5
);
252 if (o
== GOF(CR1_321
) && sz
== 1) return 8 +GOF(VSR6
);
253 if (o
== GOF(CR1_0
) && sz
== 1) return 8 +GOF(VSR7
);
254 if (o
== GOF(CR2_321
) && sz
== 1) return 8 +GOF(VSR8
);
255 if (o
== GOF(CR2_0
) && sz
== 1) return 8 +GOF(VSR9
);
256 if (o
== GOF(CR3_321
) && sz
== 1) return 8 +GOF(VSR10
);
257 if (o
== GOF(CR3_0
) && sz
== 1) return 8 +GOF(VSR11
);
258 if (o
== GOF(CR4_321
) && sz
== 1) return 8 +GOF(VSR12
);
259 if (o
== GOF(CR4_0
) && sz
== 1) return 8 +GOF(VSR13
);
260 if (o
== GOF(CR5_321
) && sz
== 1) return 8 +GOF(VSR14
);
261 if (o
== GOF(CR5_0
) && sz
== 1) return 8 +GOF(VSR15
);
262 if (o
== GOF(CR6_321
) && sz
== 1) return 8 +GOF(VSR16
);
263 if (o
== GOF(CR6_0
) && sz
== 1) return 8 +GOF(VSR17
);
264 if (o
== GOF(CR7_321
) && sz
== 1) return 8 +GOF(VSR18
);
265 if (o
== GOF(CR7_0
) && sz
== 1) return 8 +GOF(VSR19
);
267 /* Vector registers .. use offset 0 in VSR0 .. VSR63. */
268 if (o
>= GOF(VSR0
) && o
+sz
<= GOF(VSR0
) +SZB(VSR0
)) return 0+ GOF(VSR0
);
269 if (o
>= GOF(VSR1
) && o
+sz
<= GOF(VSR1
) +SZB(VSR1
)) return 0+ GOF(VSR1
);
270 if (o
>= GOF(VSR2
) && o
+sz
<= GOF(VSR2
) +SZB(VSR2
)) return 0+ GOF(VSR2
);
271 if (o
>= GOF(VSR3
) && o
+sz
<= GOF(VSR3
) +SZB(VSR3
)) return 0+ GOF(VSR3
);
272 if (o
>= GOF(VSR4
) && o
+sz
<= GOF(VSR4
) +SZB(VSR4
)) return 0+ GOF(VSR4
);
273 if (o
>= GOF(VSR5
) && o
+sz
<= GOF(VSR5
) +SZB(VSR5
)) return 0+ GOF(VSR5
);
274 if (o
>= GOF(VSR6
) && o
+sz
<= GOF(VSR6
) +SZB(VSR6
)) return 0+ GOF(VSR6
);
275 if (o
>= GOF(VSR7
) && o
+sz
<= GOF(VSR7
) +SZB(VSR7
)) return 0+ GOF(VSR7
);
276 if (o
>= GOF(VSR8
) && o
+sz
<= GOF(VSR8
) +SZB(VSR8
)) return 0+ GOF(VSR8
);
277 if (o
>= GOF(VSR9
) && o
+sz
<= GOF(VSR9
) +SZB(VSR9
)) return 0+ GOF(VSR9
);
278 if (o
>= GOF(VSR10
) && o
+sz
<= GOF(VSR10
)+SZB(VSR10
)) return 0+ GOF(VSR10
);
279 if (o
>= GOF(VSR11
) && o
+sz
<= GOF(VSR11
)+SZB(VSR11
)) return 0+ GOF(VSR11
);
280 if (o
>= GOF(VSR12
) && o
+sz
<= GOF(VSR12
)+SZB(VSR12
)) return 0+ GOF(VSR12
);
281 if (o
>= GOF(VSR13
) && o
+sz
<= GOF(VSR13
)+SZB(VSR13
)) return 0+ GOF(VSR13
);
282 if (o
>= GOF(VSR14
) && o
+sz
<= GOF(VSR14
)+SZB(VSR14
)) return 0+ GOF(VSR14
);
283 if (o
>= GOF(VSR15
) && o
+sz
<= GOF(VSR15
)+SZB(VSR15
)) return 0+ GOF(VSR15
);
284 if (o
>= GOF(VSR16
) && o
+sz
<= GOF(VSR16
)+SZB(VSR16
)) return 0+ GOF(VSR16
);
285 if (o
>= GOF(VSR17
) && o
+sz
<= GOF(VSR17
)+SZB(VSR17
)) return 0+ GOF(VSR17
);
286 if (o
>= GOF(VSR18
) && o
+sz
<= GOF(VSR18
)+SZB(VSR18
)) return 0+ GOF(VSR18
);
287 if (o
>= GOF(VSR19
) && o
+sz
<= GOF(VSR19
)+SZB(VSR19
)) return 0+ GOF(VSR19
);
288 if (o
>= GOF(VSR20
) && o
+sz
<= GOF(VSR20
)+SZB(VSR20
)) return 0+ GOF(VSR20
);
289 if (o
>= GOF(VSR21
) && o
+sz
<= GOF(VSR21
)+SZB(VSR21
)) return 0+ GOF(VSR21
);
290 if (o
>= GOF(VSR22
) && o
+sz
<= GOF(VSR22
)+SZB(VSR22
)) return 0+ GOF(VSR22
);
291 if (o
>= GOF(VSR23
) && o
+sz
<= GOF(VSR23
)+SZB(VSR23
)) return 0+ GOF(VSR23
);
292 if (o
>= GOF(VSR24
) && o
+sz
<= GOF(VSR24
)+SZB(VSR24
)) return 0+ GOF(VSR24
);
293 if (o
>= GOF(VSR25
) && o
+sz
<= GOF(VSR25
)+SZB(VSR25
)) return 0+ GOF(VSR25
);
294 if (o
>= GOF(VSR26
) && o
+sz
<= GOF(VSR26
)+SZB(VSR26
)) return 0+ GOF(VSR26
);
295 if (o
>= GOF(VSR27
) && o
+sz
<= GOF(VSR27
)+SZB(VSR27
)) return 0+ GOF(VSR27
);
296 if (o
>= GOF(VSR28
) && o
+sz
<= GOF(VSR28
)+SZB(VSR28
)) return 0+ GOF(VSR28
);
297 if (o
>= GOF(VSR29
) && o
+sz
<= GOF(VSR29
)+SZB(VSR29
)) return 0+ GOF(VSR29
);
298 if (o
>= GOF(VSR30
) && o
+sz
<= GOF(VSR30
)+SZB(VSR30
)) return 0+ GOF(VSR30
);
299 if (o
>= GOF(VSR31
) && o
+sz
<= GOF(VSR31
)+SZB(VSR31
)) return 0+ GOF(VSR31
);
300 if (o
>= GOF(VSR32
) && o
+sz
<= GOF(VSR32
)+SZB(VSR32
)) return 0+ GOF(VSR32
);
301 if (o
>= GOF(VSR33
) && o
+sz
<= GOF(VSR33
)+SZB(VSR33
)) return 0+ GOF(VSR33
);
302 if (o
>= GOF(VSR34
) && o
+sz
<= GOF(VSR34
)+SZB(VSR34
)) return 0+ GOF(VSR34
);
303 if (o
>= GOF(VSR35
) && o
+sz
<= GOF(VSR35
)+SZB(VSR35
)) return 0+ GOF(VSR35
);
304 if (o
>= GOF(VSR36
) && o
+sz
<= GOF(VSR36
)+SZB(VSR36
)) return 0+ GOF(VSR36
);
305 if (o
>= GOF(VSR37
) && o
+sz
<= GOF(VSR37
)+SZB(VSR37
)) return 0+ GOF(VSR37
);
306 if (o
>= GOF(VSR38
) && o
+sz
<= GOF(VSR38
)+SZB(VSR38
)) return 0+ GOF(VSR38
);
307 if (o
>= GOF(VSR39
) && o
+sz
<= GOF(VSR39
)+SZB(VSR39
)) return 0+ GOF(VSR39
);
308 if (o
>= GOF(VSR40
) && o
+sz
<= GOF(VSR40
)+SZB(VSR40
)) return 0+ GOF(VSR40
);
309 if (o
>= GOF(VSR41
) && o
+sz
<= GOF(VSR41
)+SZB(VSR41
)) return 0+ GOF(VSR41
);
310 if (o
>= GOF(VSR42
) && o
+sz
<= GOF(VSR42
)+SZB(VSR42
)) return 0+ GOF(VSR42
);
311 if (o
>= GOF(VSR43
) && o
+sz
<= GOF(VSR43
)+SZB(VSR43
)) return 0+ GOF(VSR43
);
312 if (o
>= GOF(VSR44
) && o
+sz
<= GOF(VSR44
)+SZB(VSR44
)) return 0+ GOF(VSR44
);
313 if (o
>= GOF(VSR45
) && o
+sz
<= GOF(VSR45
)+SZB(VSR45
)) return 0+ GOF(VSR45
);
314 if (o
>= GOF(VSR46
) && o
+sz
<= GOF(VSR46
)+SZB(VSR46
)) return 0+ GOF(VSR46
);
315 if (o
>= GOF(VSR47
) && o
+sz
<= GOF(VSR47
)+SZB(VSR47
)) return 0+ GOF(VSR47
);
316 if (o
>= GOF(VSR48
) && o
+sz
<= GOF(VSR48
)+SZB(VSR48
)) return 0+ GOF(VSR48
);
317 if (o
>= GOF(VSR49
) && o
+sz
<= GOF(VSR49
)+SZB(VSR49
)) return 0+ GOF(VSR49
);
318 if (o
>= GOF(VSR50
) && o
+sz
<= GOF(VSR50
)+SZB(VSR50
)) return 0+ GOF(VSR50
);
319 if (o
>= GOF(VSR51
) && o
+sz
<= GOF(VSR51
)+SZB(VSR51
)) return 0+ GOF(VSR51
);
320 if (o
>= GOF(VSR52
) && o
+sz
<= GOF(VSR52
)+SZB(VSR52
)) return 0+ GOF(VSR52
);
321 if (o
>= GOF(VSR53
) && o
+sz
<= GOF(VSR53
)+SZB(VSR53
)) return 0+ GOF(VSR53
);
322 if (o
>= GOF(VSR54
) && o
+sz
<= GOF(VSR54
)+SZB(VSR54
)) return 0+ GOF(VSR54
);
323 if (o
>= GOF(VSR55
) && o
+sz
<= GOF(VSR55
)+SZB(VSR55
)) return 0+ GOF(VSR55
);
324 if (o
>= GOF(VSR56
) && o
+sz
<= GOF(VSR56
)+SZB(VSR56
)) return 0+ GOF(VSR56
);
325 if (o
>= GOF(VSR57
) && o
+sz
<= GOF(VSR57
)+SZB(VSR57
)) return 0+ GOF(VSR57
);
326 if (o
>= GOF(VSR58
) && o
+sz
<= GOF(VSR58
)+SZB(VSR58
)) return 0+ GOF(VSR58
);
327 if (o
>= GOF(VSR59
) && o
+sz
<= GOF(VSR59
)+SZB(VSR59
)) return 0+ GOF(VSR59
);
328 if (o
>= GOF(VSR60
) && o
+sz
<= GOF(VSR60
)+SZB(VSR60
)) return 0+ GOF(VSR60
);
329 if (o
>= GOF(VSR61
) && o
+sz
<= GOF(VSR61
)+SZB(VSR61
)) return 0+ GOF(VSR61
);
330 if (o
>= GOF(VSR62
) && o
+sz
<= GOF(VSR62
)+SZB(VSR62
)) return 0+ GOF(VSR62
);
331 if (o
>= GOF(VSR63
) && o
+sz
<= GOF(VSR63
)+SZB(VSR63
)) return 0+ GOF(VSR63
);
333 /* ACC register file. Each register is 128 bits. */
334 if (o
>= GOF(ACC_0_r0
) && o
+sz
<= GOF(ACC_0_r0
)+SZB(ACC_0_r0
))
335 return 0+ GOF(ACC_0_r0
);
336 if (o
>= GOF(ACC_0_r1
) && o
+sz
<= GOF(ACC_0_r1
)+SZB(ACC_0_r1
))
337 return 0+ GOF(ACC_0_r1
);
338 if (o
>= GOF(ACC_0_r2
) && o
+sz
<= GOF(ACC_0_r2
)+SZB(ACC_0_r2
))
339 return 0+ GOF(ACC_0_r2
);
340 if (o
>= GOF(ACC_0_r3
) && o
+sz
<= GOF(ACC_0_r3
)+SZB(ACC_0_r3
))
341 return 0+ GOF(ACC_0_r3
);
342 if (o
>= GOF(ACC_1_r0
) && o
+sz
<= GOF(ACC_1_r0
)+SZB(ACC_1_r0
))
343 return 0+ GOF(ACC_1_r0
);
344 if (o
>= GOF(ACC_1_r1
) && o
+sz
<= GOF(ACC_1_r1
)+SZB(ACC_1_r1
))
345 return 0+ GOF(ACC_1_r1
);
346 if (o
>= GOF(ACC_1_r2
) && o
+sz
<= GOF(ACC_1_r2
)+SZB(ACC_1_r2
))
347 return 0+ GOF(ACC_1_r2
);
348 if (o
>= GOF(ACC_1_r3
) && o
+sz
<= GOF(ACC_1_r3
)+SZB(ACC_1_r3
))
349 return 0+ GOF(ACC_1_r3
);
350 if (o
>= GOF(ACC_2_r0
) && o
+sz
<= GOF(ACC_2_r0
)+SZB(ACC_2_r0
))
351 return 0+ GOF(ACC_2_r0
);
352 if (o
>= GOF(ACC_2_r1
) && o
+sz
<= GOF(ACC_2_r1
)+SZB(ACC_2_r1
))
353 return 0+ GOF(ACC_2_r1
);
354 if (o
>= GOF(ACC_2_r2
) && o
+sz
<= GOF(ACC_2_r2
)+SZB(ACC_2_r2
))
355 return 0+ GOF(ACC_2_r2
);
356 if (o
>= GOF(ACC_2_r3
) && o
+sz
<= GOF(ACC_2_r3
)+SZB(ACC_2_r3
))
357 return 0+ GOF(ACC_2_r3
);
358 if (o
>= GOF(ACC_3_r0
) && o
+sz
<= GOF(ACC_3_r0
)+SZB(ACC_3_r0
))
359 return 0+ GOF(ACC_3_r0
);
360 if (o
>= GOF(ACC_3_r1
) && o
+sz
<= GOF(ACC_3_r1
)+SZB(ACC_3_r1
))
361 return 0+ GOF(ACC_3_r1
);
362 if (o
>= GOF(ACC_3_r2
) && o
+sz
<= GOF(ACC_3_r2
)+SZB(ACC_3_r2
))
363 return 0+ GOF(ACC_3_r2
);
364 if (o
>= GOF(ACC_3_r3
) && o
+sz
<= GOF(ACC_3_r3
)+SZB(ACC_3_r3
))
365 return 0+ GOF(ACC_3_r3
);
366 if (o
>= GOF(ACC_4_r0
) && o
+sz
<= GOF(ACC_4_r0
)+SZB(ACC_4_r0
))
367 return 0+ GOF(ACC_4_r0
);
368 if (o
>= GOF(ACC_4_r1
) && o
+sz
<= GOF(ACC_4_r1
)+SZB(ACC_4_r1
))
369 return 0+ GOF(ACC_4_r1
);
370 if (o
>= GOF(ACC_4_r2
) && o
+sz
<= GOF(ACC_4_r2
)+SZB(ACC_4_r2
))
371 return 0+ GOF(ACC_4_r2
);
372 if (o
>= GOF(ACC_4_r3
) && o
+sz
<= GOF(ACC_4_r3
)+SZB(ACC_4_r3
))
373 return 0+ GOF(ACC_4_r3
);
374 if (o
>= GOF(ACC_5_r0
) && o
+sz
<= GOF(ACC_5_r0
)+SZB(ACC_5_r0
))
375 return 0+ GOF(ACC_5_r0
);
376 if (o
>= GOF(ACC_5_r1
) && o
+sz
<= GOF(ACC_5_r1
)+SZB(ACC_5_r1
))
377 return 0+ GOF(ACC_5_r1
);
378 if (o
>= GOF(ACC_5_r2
) && o
+sz
<= GOF(ACC_5_r2
)+SZB(ACC_5_r2
))
379 return 0+ GOF(ACC_5_r2
);
380 if (o
>= GOF(ACC_5_r3
) && o
+sz
<= GOF(ACC_5_r3
)+SZB(ACC_5_r3
))
381 return 0+ GOF(ACC_5_r3
);
382 if (o
>= GOF(ACC_6_r0
) && o
+sz
<= GOF(ACC_6_r0
)+SZB(ACC_6_r0
))
383 return 0+ GOF(ACC_6_r0
);
384 if (o
>= GOF(ACC_6_r1
) && o
+sz
<= GOF(ACC_6_r1
)+SZB(ACC_6_r1
))
385 return 0+ GOF(ACC_6_r1
);
386 if (o
>= GOF(ACC_6_r2
) && o
+sz
<= GOF(ACC_6_r2
)+SZB(ACC_6_r2
))
387 return 0+ GOF(ACC_6_r2
);
388 if (o
>= GOF(ACC_6_r3
) && o
+sz
<= GOF(ACC_6_r3
)+SZB(ACC_6_r3
))
389 return 0+ GOF(ACC_6_r3
);
390 if (o
>= GOF(ACC_7_r0
) && o
+sz
<= GOF(ACC_7_r0
)+SZB(ACC_7_r0
))
391 return 0+ GOF(ACC_7_r0
);
392 if (o
>= GOF(ACC_7_r1
) && o
+sz
<= GOF(ACC_7_r1
)+SZB(ACC_7_r1
))
393 return 0+ GOF(ACC_7_r1
);
394 if (o
>= GOF(ACC_7_r2
) && o
+sz
<= GOF(ACC_7_r2
)+SZB(ACC_7_r2
))
395 return 0+ GOF(ACC_7_r2
);
396 if (o
>= GOF(ACC_7_r3
) && o
+sz
<= GOF(ACC_7_r3
)+SZB(ACC_7_r3
))
397 return 0+ GOF(ACC_7_r3
);
398 if (o
== GOF(syscall_flag
) && sz
== 4) return -1;
400 VG_(printf
)("MC_(get_otrack_shadow_offset)(ppc64)(off=%d,sz=%d)\n",
406 /* -------------------- ppc32 -------------------- */
408 # elif defined(VGA_ppc32)
410 # define GOF(_fieldname) \
411 (offsetof(VexGuestPPC32State,guest_##_fieldname))
412 # define SZB(_fieldname) \
413 (sizeof(((VexGuestPPC32State*)0)->guest_##_fieldname))
418 if (o
== GOF(GPR0
) && sz
== 4) return o
;
419 if (o
== GOF(GPR1
) && sz
== 4) return o
;
420 if (o
== GOF(GPR2
) && sz
== 4) return o
;
421 if (o
== GOF(GPR3
) && sz
== 4) return o
;
422 if (o
== GOF(GPR4
) && sz
== 4) return o
;
423 if (o
== GOF(GPR5
) && sz
== 4) return o
;
424 if (o
== GOF(GPR6
) && sz
== 4) return o
;
425 if (o
== GOF(GPR7
) && sz
== 4) return o
;
426 if (o
== GOF(GPR8
) && sz
== 4) return o
;
427 if (o
== GOF(GPR9
) && sz
== 4) return o
;
428 if (o
== GOF(GPR10
) && sz
== 4) return o
;
429 if (o
== GOF(GPR11
) && sz
== 4) return o
;
430 if (o
== GOF(GPR12
) && sz
== 4) return o
;
431 if (o
== GOF(GPR13
) && sz
== 4) return o
;
432 if (o
== GOF(GPR14
) && sz
== 4) return o
;
433 if (o
== GOF(GPR15
) && sz
== 4) return o
;
434 if (o
== GOF(GPR16
) && sz
== 4) return o
;
435 if (o
== GOF(GPR17
) && sz
== 4) return o
;
436 if (o
== GOF(GPR18
) && sz
== 4) return o
;
437 if (o
== GOF(GPR19
) && sz
== 4) return o
;
438 if (o
== GOF(GPR20
) && sz
== 4) return o
;
439 if (o
== GOF(GPR21
) && sz
== 4) return o
;
440 if (o
== GOF(GPR22
) && sz
== 4) return o
;
441 if (o
== GOF(GPR23
) && sz
== 4) return o
;
442 if (o
== GOF(GPR24
) && sz
== 4) return o
;
443 if (o
== GOF(GPR25
) && sz
== 4) return o
;
444 if (o
== GOF(GPR26
) && sz
== 4) return o
;
445 if (o
== GOF(GPR27
) && sz
== 4) return o
;
446 if (o
== GOF(GPR28
) && sz
== 4) return o
;
447 if (o
== GOF(GPR29
) && sz
== 4) return o
;
448 if (o
== GOF(GPR30
) && sz
== 4) return o
;
449 if (o
== GOF(GPR31
) && sz
== 4) return o
;
451 if (o
== GOF(LR
) && sz
== 4) return o
;
452 if (o
== GOF(CTR
) && sz
== 4) return o
;
454 if (o
== GOF(CIA
) && sz
== 4) return -1;
455 if (o
== GOF(IP_AT_SYSCALL
) && sz
== 4) return -1; /* slot unused */
456 if (o
== GOF(FPROUND
) && sz
== 1) return -1;
457 if (o
== GOF(DFPROUND
) && sz
== 1) return -1;
458 if (o
== GOF(C_FPCC
) && sz
== 1) return -1;
459 if (o
== GOF(VRSAVE
) && sz
== 4) return -1;
460 if (o
== GOF(EMNOTE
) && sz
== 4) return -1;
461 if (o
== GOF(CMSTART
) && sz
== 4) return -1;
462 if (o
== GOF(CMLEN
) && sz
== 4) return -1;
463 if (o
== GOF(VSCR
) && sz
== 4) return -1;
464 if (o
== GOF(REDIR_SP
) && sz
== 4) return -1;
465 if (o
== GOF(SPRG3_RO
) && sz
== 4) return -1;
467 // With ISA 2.06, the "Vector-Scalar Floating-point" category
468 // provides facilities to support vector and scalar binary floating-
469 // point operations. A unified register file is an integral part
470 // of this new facility, combining floating point and vector registers
471 // using a 64x128-bit vector. These are referred to as VSR[0..63].
472 // The floating point registers are now mapped into double word element 0
473 // of VSR[0..31]. The 32x128-bit vector registers defined by the "Vector
474 // Facility [Category: Vector]" are now mapped to VSR[32..63].
476 // Floating point registers . . .
477 if (o
== GOF(VSR0
) && sz
== 8) return o
;
478 if (o
== GOF(VSR1
) && sz
== 8) return o
;
479 if (o
== GOF(VSR2
) && sz
== 8) return o
;
480 if (o
== GOF(VSR3
) && sz
== 8) return o
;
481 if (o
== GOF(VSR4
) && sz
== 8) return o
;
482 if (o
== GOF(VSR5
) && sz
== 8) return o
;
483 if (o
== GOF(VSR6
) && sz
== 8) return o
;
484 if (o
== GOF(VSR7
) && sz
== 8) return o
;
485 if (o
== GOF(VSR8
) && sz
== 8) return o
;
486 if (o
== GOF(VSR9
) && sz
== 8) return o
;
487 if (o
== GOF(VSR10
) && sz
== 8) return o
;
488 if (o
== GOF(VSR11
) && sz
== 8) return o
;
489 if (o
== GOF(VSR12
) && sz
== 8) return o
;
490 if (o
== GOF(VSR13
) && sz
== 8) return o
;
491 if (o
== GOF(VSR14
) && sz
== 8) return o
;
492 if (o
== GOF(VSR15
) && sz
== 8) return o
;
493 if (o
== GOF(VSR16
) && sz
== 8) return o
;
494 if (o
== GOF(VSR17
) && sz
== 8) return o
;
495 if (o
== GOF(VSR18
) && sz
== 8) return o
;
496 if (o
== GOF(VSR19
) && sz
== 8) return o
;
497 if (o
== GOF(VSR20
) && sz
== 8) return o
;
498 if (o
== GOF(VSR21
) && sz
== 8) return o
;
499 if (o
== GOF(VSR22
) && sz
== 8) return o
;
500 if (o
== GOF(VSR23
) && sz
== 8) return o
;
501 if (o
== GOF(VSR24
) && sz
== 8) return o
;
502 if (o
== GOF(VSR25
) && sz
== 8) return o
;
503 if (o
== GOF(VSR26
) && sz
== 8) return o
;
504 if (o
== GOF(VSR27
) && sz
== 8) return o
;
505 if (o
== GOF(VSR28
) && sz
== 8) return o
;
506 if (o
== GOF(VSR29
) && sz
== 8) return o
;
507 if (o
== GOF(VSR30
) && sz
== 8) return o
;
508 if (o
== GOF(VSR31
) && sz
== 8) return o
;
510 /* For the various byte sized XER/CR pieces, use offset 8
512 tl_assert(SZB(VSR0
) == 16);
513 if (o
== GOF(XER_SO
) && sz
== 1) return 8 +GOF(VSR0
);
514 if (o
== GOF(XER_OV
) && sz
== 1) return 8 +GOF(VSR1
);
515 if (o
== GOF(XER_OV32
) && sz
== 1) return 8 +GOF(VSR20
);
516 if (o
== GOF(XER_CA
) && sz
== 1) return 8 +GOF(VSR2
);
517 if (o
== GOF(XER_CA32
) && sz
== 1) return 8 +GOF(VSR21
);
518 if (o
== GOF(XER_BC
) && sz
== 1) return 8 +GOF(VSR3
);
520 if (o
== GOF(CR0_321
) && sz
== 1) return 8 +GOF(VSR4
);
521 if (o
== GOF(CR0_0
) && sz
== 1) return 8 +GOF(VSR5
);
522 if (o
== GOF(CR1_321
) && sz
== 1) return 8 +GOF(VSR6
);
523 if (o
== GOF(CR1_0
) && sz
== 1) return 8 +GOF(VSR7
);
524 if (o
== GOF(CR2_321
) && sz
== 1) return 8 +GOF(VSR8
);
525 if (o
== GOF(CR2_0
) && sz
== 1) return 8 +GOF(VSR9
);
526 if (o
== GOF(CR3_321
) && sz
== 1) return 8 +GOF(VSR10
);
527 if (o
== GOF(CR3_0
) && sz
== 1) return 8 +GOF(VSR11
);
528 if (o
== GOF(CR4_321
) && sz
== 1) return 8 +GOF(VSR12
);
529 if (o
== GOF(CR4_0
) && sz
== 1) return 8 +GOF(VSR13
);
530 if (o
== GOF(CR5_321
) && sz
== 1) return 8 +GOF(VSR14
);
531 if (o
== GOF(CR5_0
) && sz
== 1) return 8 +GOF(VSR15
);
532 if (o
== GOF(CR6_321
) && sz
== 1) return 8 +GOF(VSR16
);
533 if (o
== GOF(CR6_0
) && sz
== 1) return 8 +GOF(VSR17
);
534 if (o
== GOF(CR7_321
) && sz
== 1) return 8 +GOF(VSR18
);
535 if (o
== GOF(CR7_0
) && sz
== 1) return 8 +GOF(VSR19
);
537 /* Vector registers .. use offset 0 in VSR0 .. VSR63. */
538 if (o
>= GOF(VSR0
) && o
+sz
<= GOF(VSR0
) +SZB(VSR0
)) return 0+ GOF(VSR0
);
539 if (o
>= GOF(VSR1
) && o
+sz
<= GOF(VSR1
) +SZB(VSR1
)) return 0+ GOF(VSR1
);
540 if (o
>= GOF(VSR2
) && o
+sz
<= GOF(VSR2
) +SZB(VSR2
)) return 0+ GOF(VSR2
);
541 if (o
>= GOF(VSR3
) && o
+sz
<= GOF(VSR3
) +SZB(VSR3
)) return 0+ GOF(VSR3
);
542 if (o
>= GOF(VSR4
) && o
+sz
<= GOF(VSR4
) +SZB(VSR4
)) return 0+ GOF(VSR4
);
543 if (o
>= GOF(VSR5
) && o
+sz
<= GOF(VSR5
) +SZB(VSR5
)) return 0+ GOF(VSR5
);
544 if (o
>= GOF(VSR6
) && o
+sz
<= GOF(VSR6
) +SZB(VSR6
)) return 0+ GOF(VSR6
);
545 if (o
>= GOF(VSR7
) && o
+sz
<= GOF(VSR7
) +SZB(VSR7
)) return 0+ GOF(VSR7
);
546 if (o
>= GOF(VSR8
) && o
+sz
<= GOF(VSR8
) +SZB(VSR8
)) return 0+ GOF(VSR8
);
547 if (o
>= GOF(VSR9
) && o
+sz
<= GOF(VSR9
) +SZB(VSR9
)) return 0+ GOF(VSR9
);
548 if (o
>= GOF(VSR10
) && o
+sz
<= GOF(VSR10
)+SZB(VSR10
)) return 0+ GOF(VSR10
);
549 if (o
>= GOF(VSR11
) && o
+sz
<= GOF(VSR11
)+SZB(VSR11
)) return 0+ GOF(VSR11
);
550 if (o
>= GOF(VSR12
) && o
+sz
<= GOF(VSR12
)+SZB(VSR12
)) return 0+ GOF(VSR12
);
551 if (o
>= GOF(VSR13
) && o
+sz
<= GOF(VSR13
)+SZB(VSR13
)) return 0+ GOF(VSR13
);
552 if (o
>= GOF(VSR14
) && o
+sz
<= GOF(VSR14
)+SZB(VSR14
)) return 0+ GOF(VSR14
);
553 if (o
>= GOF(VSR15
) && o
+sz
<= GOF(VSR15
)+SZB(VSR15
)) return 0+ GOF(VSR15
);
554 if (o
>= GOF(VSR16
) && o
+sz
<= GOF(VSR16
)+SZB(VSR16
)) return 0+ GOF(VSR16
);
555 if (o
>= GOF(VSR17
) && o
+sz
<= GOF(VSR17
)+SZB(VSR17
)) return 0+ GOF(VSR17
);
556 if (o
>= GOF(VSR18
) && o
+sz
<= GOF(VSR18
)+SZB(VSR18
)) return 0+ GOF(VSR18
);
557 if (o
>= GOF(VSR19
) && o
+sz
<= GOF(VSR19
)+SZB(VSR19
)) return 0+ GOF(VSR19
);
558 if (o
>= GOF(VSR20
) && o
+sz
<= GOF(VSR20
)+SZB(VSR20
)) return 0+ GOF(VSR20
);
559 if (o
>= GOF(VSR21
) && o
+sz
<= GOF(VSR21
)+SZB(VSR21
)) return 0+ GOF(VSR21
);
560 if (o
>= GOF(VSR22
) && o
+sz
<= GOF(VSR22
)+SZB(VSR22
)) return 0+ GOF(VSR22
);
561 if (o
>= GOF(VSR23
) && o
+sz
<= GOF(VSR23
)+SZB(VSR23
)) return 0+ GOF(VSR23
);
562 if (o
>= GOF(VSR24
) && o
+sz
<= GOF(VSR24
)+SZB(VSR24
)) return 0+ GOF(VSR24
);
563 if (o
>= GOF(VSR25
) && o
+sz
<= GOF(VSR25
)+SZB(VSR25
)) return 0+ GOF(VSR25
);
564 if (o
>= GOF(VSR26
) && o
+sz
<= GOF(VSR26
)+SZB(VSR26
)) return 0+ GOF(VSR26
);
565 if (o
>= GOF(VSR27
) && o
+sz
<= GOF(VSR27
)+SZB(VSR27
)) return 0+ GOF(VSR27
);
566 if (o
>= GOF(VSR28
) && o
+sz
<= GOF(VSR28
)+SZB(VSR28
)) return 0+ GOF(VSR28
);
567 if (o
>= GOF(VSR29
) && o
+sz
<= GOF(VSR29
)+SZB(VSR29
)) return 0+ GOF(VSR29
);
568 if (o
>= GOF(VSR30
) && o
+sz
<= GOF(VSR30
)+SZB(VSR30
)) return 0+ GOF(VSR30
);
569 if (o
>= GOF(VSR31
) && o
+sz
<= GOF(VSR31
)+SZB(VSR31
)) return 0+ GOF(VSR31
);
570 if (o
>= GOF(VSR32
) && o
+sz
<= GOF(VSR32
)+SZB(VSR32
)) return 0+ GOF(VSR32
);
571 if (o
>= GOF(VSR33
) && o
+sz
<= GOF(VSR33
)+SZB(VSR33
)) return 0+ GOF(VSR33
);
572 if (o
>= GOF(VSR34
) && o
+sz
<= GOF(VSR34
)+SZB(VSR34
)) return 0+ GOF(VSR34
);
573 if (o
>= GOF(VSR35
) && o
+sz
<= GOF(VSR35
)+SZB(VSR35
)) return 0+ GOF(VSR35
);
574 if (o
>= GOF(VSR36
) && o
+sz
<= GOF(VSR36
)+SZB(VSR36
)) return 0+ GOF(VSR36
);
575 if (o
>= GOF(VSR37
) && o
+sz
<= GOF(VSR37
)+SZB(VSR37
)) return 0+ GOF(VSR37
);
576 if (o
>= GOF(VSR38
) && o
+sz
<= GOF(VSR38
)+SZB(VSR38
)) return 0+ GOF(VSR38
);
577 if (o
>= GOF(VSR39
) && o
+sz
<= GOF(VSR39
)+SZB(VSR39
)) return 0+ GOF(VSR39
);
578 if (o
>= GOF(VSR40
) && o
+sz
<= GOF(VSR40
)+SZB(VSR40
)) return 0+ GOF(VSR40
);
579 if (o
>= GOF(VSR41
) && o
+sz
<= GOF(VSR41
)+SZB(VSR41
)) return 0+ GOF(VSR41
);
580 if (o
>= GOF(VSR42
) && o
+sz
<= GOF(VSR42
)+SZB(VSR42
)) return 0+ GOF(VSR42
);
581 if (o
>= GOF(VSR43
) && o
+sz
<= GOF(VSR43
)+SZB(VSR43
)) return 0+ GOF(VSR43
);
582 if (o
>= GOF(VSR44
) && o
+sz
<= GOF(VSR44
)+SZB(VSR44
)) return 0+ GOF(VSR44
);
583 if (o
>= GOF(VSR45
) && o
+sz
<= GOF(VSR45
)+SZB(VSR45
)) return 0+ GOF(VSR45
);
584 if (o
>= GOF(VSR46
) && o
+sz
<= GOF(VSR46
)+SZB(VSR46
)) return 0+ GOF(VSR46
);
585 if (o
>= GOF(VSR47
) && o
+sz
<= GOF(VSR47
)+SZB(VSR47
)) return 0+ GOF(VSR47
);
586 if (o
>= GOF(VSR48
) && o
+sz
<= GOF(VSR48
)+SZB(VSR48
)) return 0+ GOF(VSR48
);
587 if (o
>= GOF(VSR49
) && o
+sz
<= GOF(VSR49
)+SZB(VSR49
)) return 0+ GOF(VSR49
);
588 if (o
>= GOF(VSR50
) && o
+sz
<= GOF(VSR50
)+SZB(VSR50
)) return 0+ GOF(VSR50
);
589 if (o
>= GOF(VSR51
) && o
+sz
<= GOF(VSR51
)+SZB(VSR51
)) return 0+ GOF(VSR51
);
590 if (o
>= GOF(VSR52
) && o
+sz
<= GOF(VSR52
)+SZB(VSR52
)) return 0+ GOF(VSR52
);
591 if (o
>= GOF(VSR53
) && o
+sz
<= GOF(VSR53
)+SZB(VSR53
)) return 0+ GOF(VSR53
);
592 if (o
>= GOF(VSR54
) && o
+sz
<= GOF(VSR54
)+SZB(VSR54
)) return 0+ GOF(VSR54
);
593 if (o
>= GOF(VSR55
) && o
+sz
<= GOF(VSR55
)+SZB(VSR55
)) return 0+ GOF(VSR55
);
594 if (o
>= GOF(VSR56
) && o
+sz
<= GOF(VSR56
)+SZB(VSR56
)) return 0+ GOF(VSR56
);
595 if (o
>= GOF(VSR57
) && o
+sz
<= GOF(VSR57
)+SZB(VSR57
)) return 0+ GOF(VSR57
);
596 if (o
>= GOF(VSR58
) && o
+sz
<= GOF(VSR58
)+SZB(VSR58
)) return 0+ GOF(VSR58
);
597 if (o
>= GOF(VSR59
) && o
+sz
<= GOF(VSR59
)+SZB(VSR59
)) return 0+ GOF(VSR59
);
598 if (o
>= GOF(VSR60
) && o
+sz
<= GOF(VSR60
)+SZB(VSR60
)) return 0+ GOF(VSR60
);
599 if (o
>= GOF(VSR61
) && o
+sz
<= GOF(VSR61
)+SZB(VSR61
)) return 0+ GOF(VSR61
);
600 if (o
>= GOF(VSR62
) && o
+sz
<= GOF(VSR62
)+SZB(VSR62
)) return 0+ GOF(VSR62
);
601 if (o
>= GOF(VSR63
) && o
+sz
<= GOF(VSR63
)+SZB(VSR63
)) return 0+ GOF(VSR63
);
603 /* ACC registers are not supported on ppc32. */
605 VG_(printf
)("MC_(get_otrack_shadow_offset)(ppc32)(off=%d,sz=%d)\n",
611 /* -------------------- amd64 -------------------- */
613 # elif defined(VGA_amd64)
615 # define GOF(_fieldname) \
616 (offsetof(VexGuestAMD64State,guest_##_fieldname))
617 # define SZB(_fieldname) \
618 (sizeof(((VexGuestAMD64State*)0)->guest_##_fieldname))
621 Bool is1248
= sz
== 8 || sz
== 4 || sz
== 2 || sz
== 1;
623 tl_assert(host_is_little_endian());
625 if (o
== GOF(RAX
) && is1248
) return o
;
626 if (o
== GOF(RCX
) && is1248
) return o
;
627 if (o
== GOF(RDX
) && is1248
) return o
;
628 if (o
== GOF(RBX
) && is1248
) return o
;
629 if (o
== GOF(RSP
) && is1248
) return o
;
630 if (o
== GOF(RBP
) && is1248
) return o
;
631 if (o
== GOF(RSI
) && is1248
) return o
;
632 if (o
== GOF(RDI
) && is1248
) return o
;
633 if (o
== GOF(R8
) && is1248
) return o
;
634 if (o
== GOF(R9
) && is1248
) return o
;
635 if (o
== GOF(R10
) && is1248
) return o
;
636 if (o
== GOF(R11
) && is1248
) return o
;
637 if (o
== GOF(R12
) && is1248
) return o
;
638 if (o
== GOF(R13
) && is1248
) return o
;
639 if (o
== GOF(R14
) && is1248
) return o
;
640 if (o
== GOF(R15
) && is1248
) return o
;
642 if (o
== GOF(CC_DEP1
) && sz
== 8) return o
;
643 if (o
== GOF(CC_DEP2
) && sz
== 8) return o
;
645 if (o
== GOF(CC_OP
) && sz
== 8) return -1; /* slot used for %AH */
646 if (o
== GOF(CC_NDEP
) && sz
== 8) return -1; /* slot used for %BH */
647 if (o
== GOF(DFLAG
) && sz
== 8) return -1; /* slot used for %CH */
648 if (o
== GOF(RIP
) && sz
== 8) return -1; /* slot unused */
649 if (o
== GOF(IP_AT_SYSCALL
) && sz
== 8) return -1; /* slot unused */
650 if (o
== GOF(IDFLAG
) && sz
== 8) return -1; /* slot used for %DH */
651 if (o
== GOF(ACFLAG
) && sz
== 8) return -1; /* slot unused */
652 if (o
== GOF(FS_CONST
) && sz
== 8) return -1; /* slot unused */
653 if (o
== GOF(GS_CONST
) && sz
== 8) return -1; /* slot unused */
654 if (o
== GOF(CMSTART
) && sz
== 8) return -1; /* slot unused */
655 if (o
== GOF(CMLEN
) && sz
== 8) return -1; /* slot unused */
656 if (o
== GOF(NRADDR
) && sz
== 8) return -1; /* slot unused */
658 /* Treat %AH, %BH, %CH, %DH as independent registers. To do this
659 requires finding 4 unused 32-bit slots in the second-shadow
660 guest state, respectively: CC_OP CC_NDEP DFLAG IDFLAG, since
661 none of those are tracked. */
662 tl_assert(SZB(CC_OP
) == 8);
663 tl_assert(SZB(CC_NDEP
) == 8);
664 tl_assert(SZB(IDFLAG
) == 8);
665 tl_assert(SZB(DFLAG
) == 8);
667 if (o
== 1+ GOF(RAX
) && szB
== 1) return GOF(CC_OP
);
668 if (o
== 1+ GOF(RBX
) && szB
== 1) return GOF(CC_NDEP
);
669 if (o
== 1+ GOF(RCX
) && szB
== 1) return GOF(DFLAG
);
670 if (o
== 1+ GOF(RDX
) && szB
== 1) return GOF(IDFLAG
);
672 /* skip XMM and FP admin stuff */
673 if (o
== GOF(SSEROUND
) && szB
== 8) return -1;
674 if (o
== GOF(FTOP
) && szB
== 4) return -1;
675 if (o
== GOF(FPROUND
) && szB
== 8) return -1;
676 if (o
== GOF(EMNOTE
) && szB
== 4) return -1;
677 if (o
== GOF(FC3210
) && szB
== 8) return -1;
680 if (o
>= GOF(YMM0
) && o
+sz
<= GOF(YMM0
) +SZB(YMM0
)) return GOF(YMM0
);
681 if (o
>= GOF(YMM1
) && o
+sz
<= GOF(YMM1
) +SZB(YMM1
)) return GOF(YMM1
);
682 if (o
>= GOF(YMM2
) && o
+sz
<= GOF(YMM2
) +SZB(YMM2
)) return GOF(YMM2
);
683 if (o
>= GOF(YMM3
) && o
+sz
<= GOF(YMM3
) +SZB(YMM3
)) return GOF(YMM3
);
684 if (o
>= GOF(YMM4
) && o
+sz
<= GOF(YMM4
) +SZB(YMM4
)) return GOF(YMM4
);
685 if (o
>= GOF(YMM5
) && o
+sz
<= GOF(YMM5
) +SZB(YMM5
)) return GOF(YMM5
);
686 if (o
>= GOF(YMM6
) && o
+sz
<= GOF(YMM6
) +SZB(YMM6
)) return GOF(YMM6
);
687 if (o
>= GOF(YMM7
) && o
+sz
<= GOF(YMM7
) +SZB(YMM7
)) return GOF(YMM7
);
688 if (o
>= GOF(YMM8
) && o
+sz
<= GOF(YMM8
) +SZB(YMM8
)) return GOF(YMM8
);
689 if (o
>= GOF(YMM9
) && o
+sz
<= GOF(YMM9
) +SZB(YMM9
)) return GOF(YMM9
);
690 if (o
>= GOF(YMM10
) && o
+sz
<= GOF(YMM10
)+SZB(YMM10
)) return GOF(YMM10
);
691 if (o
>= GOF(YMM11
) && o
+sz
<= GOF(YMM11
)+SZB(YMM11
)) return GOF(YMM11
);
692 if (o
>= GOF(YMM12
) && o
+sz
<= GOF(YMM12
)+SZB(YMM12
)) return GOF(YMM12
);
693 if (o
>= GOF(YMM13
) && o
+sz
<= GOF(YMM13
)+SZB(YMM13
)) return GOF(YMM13
);
694 if (o
>= GOF(YMM14
) && o
+sz
<= GOF(YMM14
)+SZB(YMM14
)) return GOF(YMM14
);
695 if (o
>= GOF(YMM15
) && o
+sz
<= GOF(YMM15
)+SZB(YMM15
)) return GOF(YMM15
);
696 if (o
>= GOF(YMM16
) && o
+sz
<= GOF(YMM16
)+SZB(YMM16
)) return GOF(YMM16
);
698 /* MMX accesses to FP regs. Need to allow for 32-bit references
699 due to dirty helpers for frstor etc, which reference the entire
700 64-byte block in one go. */
701 if (o
>= GOF(FPREG
[0])
702 && o
+sz
<= GOF(FPREG
[0])+SZB(FPREG
[0])) return GOF(FPREG
[0]);
703 if (o
>= GOF(FPREG
[1])
704 && o
+sz
<= GOF(FPREG
[1])+SZB(FPREG
[1])) return GOF(FPREG
[1]);
705 if (o
>= GOF(FPREG
[2])
706 && o
+sz
<= GOF(FPREG
[2])+SZB(FPREG
[2])) return GOF(FPREG
[2]);
707 if (o
>= GOF(FPREG
[3])
708 && o
+sz
<= GOF(FPREG
[3])+SZB(FPREG
[3])) return GOF(FPREG
[3]);
709 if (o
>= GOF(FPREG
[4])
710 && o
+sz
<= GOF(FPREG
[4])+SZB(FPREG
[4])) return GOF(FPREG
[4]);
711 if (o
>= GOF(FPREG
[5])
712 && o
+sz
<= GOF(FPREG
[5])+SZB(FPREG
[5])) return GOF(FPREG
[5]);
713 if (o
>= GOF(FPREG
[6])
714 && o
+sz
<= GOF(FPREG
[6])+SZB(FPREG
[6])) return GOF(FPREG
[6]);
715 if (o
>= GOF(FPREG
[7])
716 && o
+sz
<= GOF(FPREG
[7])+SZB(FPREG
[7])) return GOF(FPREG
[7]);
718 /* Map high halves of %RAX,%RCX,%RDX,%RBX to the whole register.
719 This is needed because the general handling of dirty helper
720 calls is done in 4 byte chunks. Hence we will see these.
721 Currently we only expect to see artefacts from CPUID. */
722 if (o
== 4+ GOF(RAX
) && sz
== 4) return GOF(RAX
);
723 if (o
== 4+ GOF(RCX
) && sz
== 4) return GOF(RCX
);
724 if (o
== 4+ GOF(RDX
) && sz
== 4) return GOF(RDX
);
725 if (o
== 4+ GOF(RBX
) && sz
== 4) return GOF(RBX
);
727 VG_(printf
)("MC_(get_otrack_shadow_offset)(amd64)(off=%d,sz=%d)\n",
733 /* --------------------- x86 --------------------- */
735 # elif defined(VGA_x86)
737 # define GOF(_fieldname) \
738 (offsetof(VexGuestX86State,guest_##_fieldname))
739 # define SZB(_fieldname) \
740 (sizeof(((VexGuestX86State*)0)->guest_##_fieldname))
744 Bool is124
= sz
== 4 || sz
== 2 || sz
== 1;
746 tl_assert(host_is_little_endian());
748 if (o
== GOF(EAX
) && is124
) return o
;
749 if (o
== GOF(ECX
) && is124
) return o
;
750 if (o
== GOF(EDX
) && is124
) return o
;
751 if (o
== GOF(EBX
) && is124
) return o
;
752 if (o
== GOF(ESP
) && is124
) return o
;
753 if (o
== GOF(EBP
) && is124
) return o
;
754 if (o
== GOF(ESI
) && is124
) return o
;
755 if (o
== GOF(EDI
) && is124
) return o
;
757 if (o
== GOF(CC_DEP1
) && sz
== 4) return o
;
758 if (o
== GOF(CC_DEP2
) && sz
== 4) return o
;
760 if (o
== GOF(CC_OP
) && sz
== 4) return -1; /* slot used for %AH */
761 if (o
== GOF(CC_NDEP
) && sz
== 4) return -1; /* slot used for %BH */
762 if (o
== GOF(DFLAG
) && sz
== 4) return -1; /* slot used for %CH */
763 if (o
== GOF(EIP
) && sz
== 4) return -1; /* slot unused */
764 if (o
== GOF(IP_AT_SYSCALL
) && sz
== 4) return -1; /* slot unused */
765 if (o
== GOF(IDFLAG
) && sz
== 4) return -1; /* slot used for %DH */
766 if (o
== GOF(ACFLAG
) && sz
== 4) return -1; /* slot unused */
767 if (o
== GOF(CMSTART
) && sz
== 4) return -1; /* slot unused */
768 if (o
== GOF(CMLEN
) && sz
== 4) return -1; /* slot unused */
769 if (o
== GOF(NRADDR
) && sz
== 4) return -1; /* slot unused */
771 /* Treat %AH, %BH, %CH, %DH as independent registers. To do this
772 requires finding 4 unused 32-bit slots in the second-shadow
773 guest state, respectively: CC_OP CC_NDEP DFLAG IDFLAG since none
774 of those are tracked. */
775 tl_assert(SZB(CC_OP
) == 4);
776 tl_assert(SZB(CC_NDEP
) == 4);
777 tl_assert(SZB(DFLAG
) == 4);
778 tl_assert(SZB(IDFLAG
) == 4);
779 if (o
== 1+ GOF(EAX
) && szB
== 1) return GOF(CC_OP
);
780 if (o
== 1+ GOF(EBX
) && szB
== 1) return GOF(CC_NDEP
);
781 if (o
== 1+ GOF(ECX
) && szB
== 1) return GOF(DFLAG
);
782 if (o
== 1+ GOF(EDX
) && szB
== 1) return GOF(IDFLAG
);
784 /* skip XMM and FP admin stuff */
785 if (o
== GOF(SSEROUND
) && szB
== 4) return -1;
786 if (o
== GOF(FTOP
) && szB
== 4) return -1;
787 if (o
== GOF(FPROUND
) && szB
== 4) return -1;
788 if (o
== GOF(EMNOTE
) && szB
== 4) return -1;
789 if (o
== GOF(FC3210
) && szB
== 4) return -1;
792 if (o
>= GOF(XMM0
) && o
+sz
<= GOF(XMM0
)+SZB(XMM0
)) return GOF(XMM0
);
793 if (o
>= GOF(XMM1
) && o
+sz
<= GOF(XMM1
)+SZB(XMM1
)) return GOF(XMM1
);
794 if (o
>= GOF(XMM2
) && o
+sz
<= GOF(XMM2
)+SZB(XMM2
)) return GOF(XMM2
);
795 if (o
>= GOF(XMM3
) && o
+sz
<= GOF(XMM3
)+SZB(XMM3
)) return GOF(XMM3
);
796 if (o
>= GOF(XMM4
) && o
+sz
<= GOF(XMM4
)+SZB(XMM4
)) return GOF(XMM4
);
797 if (o
>= GOF(XMM5
) && o
+sz
<= GOF(XMM5
)+SZB(XMM5
)) return GOF(XMM5
);
798 if (o
>= GOF(XMM6
) && o
+sz
<= GOF(XMM6
)+SZB(XMM6
)) return GOF(XMM6
);
799 if (o
>= GOF(XMM7
) && o
+sz
<= GOF(XMM7
)+SZB(XMM7
)) return GOF(XMM7
);
801 /* MMX accesses to FP regs. Need to allow for 32-bit references
802 due to dirty helpers for frstor etc, which reference the entire
803 64-byte block in one go. */
804 if (o
>= GOF(FPREG
[0])
805 && o
+sz
<= GOF(FPREG
[0])+SZB(FPREG
[0])) return GOF(FPREG
[0]);
806 if (o
>= GOF(FPREG
[1])
807 && o
+sz
<= GOF(FPREG
[1])+SZB(FPREG
[1])) return GOF(FPREG
[1]);
808 if (o
>= GOF(FPREG
[2])
809 && o
+sz
<= GOF(FPREG
[2])+SZB(FPREG
[2])) return GOF(FPREG
[2]);
810 if (o
>= GOF(FPREG
[3])
811 && o
+sz
<= GOF(FPREG
[3])+SZB(FPREG
[3])) return GOF(FPREG
[3]);
812 if (o
>= GOF(FPREG
[4])
813 && o
+sz
<= GOF(FPREG
[4])+SZB(FPREG
[4])) return GOF(FPREG
[4]);
814 if (o
>= GOF(FPREG
[5])
815 && o
+sz
<= GOF(FPREG
[5])+SZB(FPREG
[5])) return GOF(FPREG
[5]);
816 if (o
>= GOF(FPREG
[6])
817 && o
+sz
<= GOF(FPREG
[6])+SZB(FPREG
[6])) return GOF(FPREG
[6]);
818 if (o
>= GOF(FPREG
[7])
819 && o
+sz
<= GOF(FPREG
[7])+SZB(FPREG
[7])) return GOF(FPREG
[7]);
821 /* skip %GS and other segment related stuff. We could shadow
822 guest_LDT and guest_GDT, although it seems pointless.
823 guest_CS .. guest_SS are too small to shadow directly and it
824 also seems pointless to shadow them indirectly (that is, in
825 the style of %AH .. %DH). */
826 if (o
== GOF(CS
) && sz
== 2) return -1;
827 if (o
== GOF(DS
) && sz
== 2) return -1;
828 if (o
== GOF(ES
) && sz
== 2) return -1;
829 if (o
== GOF(FS
) && sz
== 2) return -1;
830 if (o
== GOF(GS
) && sz
== 2) return -1;
831 if (o
== GOF(SS
) && sz
== 2) return -1;
832 if (o
== GOF(LDT
) && sz
== 4) return -1;
833 if (o
== GOF(GDT
) && sz
== 4) return -1;
835 VG_(printf
)("MC_(get_otrack_shadow_offset)(x86)(off=%d,sz=%d)\n",
841 /* -------------------- s390x -------------------- */
843 # elif defined(VGA_s390x)
844 # define GOF(_fieldname) \
845 (offsetof(VexGuestS390XState,guest_##_fieldname))
849 tl_assert(host_is_big_endian());
851 /* no matter what byte(s) we change, we have changed the full 8 byte value
852 and need to track this change for the whole register */
853 if (o
>= GOF(r0
) && sz
<= 8 && o
<= (GOF(r15
) + 8 - sz
))
854 return GOF(r0
) + ((o
-GOF(r0
)) & -8) ;
857 /* fprs are accessed 4 or 8 byte at once. Again, we track that change for
859 NOTE: FPRs are mapped to first double word of VRs[0-15] */
860 if ((sz
== 8 || sz
== 4) && o
>= GOF(v0
) && o
<= GOF(v15
)+8-sz
)
861 return GOF(v0
) + ((o
-GOF(v0
)) & -8) ;
863 /* access registers are accessed 4 bytes at once */
864 if (sz
== 4 && o
>= GOF(a0
) && o
<= GOF(a15
))
867 /* no matter what byte(s) we change, we have changed the full 16 byte value
868 and need to track this change for the whole register */
869 if (o
>= GOF(v0
) && sz
<= 16 && o
<= (GOF(v31
) + 16 - sz
))
870 return GOF(v0
) + ((o
-GOF(v0
)) & -16) ;
872 /* we access the guest counter either fully or one of the 4byte words */
873 if (o
== GOF(counter
) && (sz
== 8 || sz
==4))
875 if (o
== GOF(counter
) + 4 && sz
== 4)
878 if (o
== GOF(EMNOTE
) && sz
== 4) return -1;
880 if (o
== GOF(CC_OP
) && sz
== 8) return -1;
881 /* We access CC_DEP1 either fully or bits [0:31] */
882 if (o
== GOF(CC_DEP1
) && (sz
== 8 || sz
==4))
884 if (o
== GOF(CC_DEP2
) && sz
== 8) return o
;
885 if (o
== GOF(CC_NDEP
) && sz
== 8) return -1;
886 if (o
== GOF(CMSTART
) && sz
== 8) return -1;
887 if (o
== GOF(CMLEN
) && sz
== 8) return -1;
888 if (o
== GOF(NRADDR
) && sz
== 8) return -1;
889 if (o
== GOF(IP_AT_SYSCALL
) && sz
== 8) return -1;
890 if (o
== GOF(fpc
) && sz
== 4) return -1;
891 if (o
== GOF(IA
) && sz
== 8) return -1;
892 if (o
== (GOF(IA
) + 4) && sz
== 4) return -1;
893 if (o
== GOF(SYSNO
) && sz
== 8) return -1;
894 VG_(printf
)("MC_(get_otrack_shadow_offset)(s390x)(off=%d,sz=%d)\n",
900 /* --------------------- arm --------------------- */
902 # elif defined(VGA_arm)
904 # define GOF(_fieldname) \
905 (offsetof(VexGuestARMState,guest_##_fieldname))
906 # define SZB(_fieldname) \
907 (sizeof(((VexGuestARMState*)0)->guest_##_fieldname))
912 tl_assert(host_is_little_endian());
914 if (o
== GOF(R0
) && sz
== 4) return o
;
915 if (o
== GOF(R1
) && sz
== 4) return o
;
916 if (o
== GOF(R2
) && sz
== 4) return o
;
917 if (o
== GOF(R3
) && sz
== 4) return o
;
918 if (o
== GOF(R4
) && sz
== 4) return o
;
919 if (o
== GOF(R5
) && sz
== 4) return o
;
920 if (o
== GOF(R6
) && sz
== 4) return o
;
921 if (o
== GOF(R7
) && sz
== 4) return o
;
922 if (o
== GOF(R8
) && sz
== 4) return o
;
923 if (o
== GOF(R9
) && sz
== 4) return o
;
924 if (o
== GOF(R10
) && sz
== 4) return o
;
925 if (o
== GOF(R11
) && sz
== 4) return o
;
926 if (o
== GOF(R12
) && sz
== 4) return o
;
927 if (o
== GOF(R13
) && sz
== 4) return o
;
928 if (o
== GOF(R14
) && sz
== 4) return o
;
930 /* EAZG: These may be completely wrong. */
931 if (o
== GOF(R15T
) && sz
== 4) return -1; /* slot unused */
932 if (o
== GOF(CC_OP
) && sz
== 4) return -1; /* slot unused */
934 if (o
== GOF(CC_DEP1
) && sz
== 4) return o
;
935 if (o
== GOF(CC_DEP2
) && sz
== 4) return o
;
937 if (o
== GOF(CC_NDEP
) && sz
== 4) return -1; /* slot unused */
939 if (o
== GOF(QFLAG32
) && sz
== 4) return o
;
941 if (o
== GOF(GEFLAG0
) && sz
== 4) return o
;
942 if (o
== GOF(GEFLAG1
) && sz
== 4) return o
;
943 if (o
== GOF(GEFLAG2
) && sz
== 4) return o
;
944 if (o
== GOF(GEFLAG3
) && sz
== 4) return o
;
946 //if (o == GOF(SYSCALLNO) && sz == 4) return -1; /* slot unused */
947 //if (o == GOF(CC) && sz == 4) return -1; /* slot unused */
948 //if (o == GOF(EMNOTE) && sz == 4) return -1; /* slot unused */
949 //if (o == GOF(CMSTART) && sz == 4) return -1; /* slot unused */
950 //if (o == GOF(NRADDR) && sz == 4) return -1; /* slot unused */
952 if (o
== GOF(FPSCR
) && sz
== 4) return -1;
953 if (o
== GOF(TPIDRURO
) && sz
== 4) return -1;
954 if (o
== GOF(TPIDRURW
) && sz
== 4) return -1;
955 if (o
== GOF(ITSTATE
) && sz
== 4) return -1;
957 /* Accesses to F or D registers */
958 if (sz
== 4 || sz
== 8) {
959 if (o
>= GOF(D0
) && o
+sz
<= GOF(D0
) +SZB(D0
)) return GOF(D0
);
960 if (o
>= GOF(D1
) && o
+sz
<= GOF(D1
) +SZB(D1
)) return GOF(D1
);
961 if (o
>= GOF(D2
) && o
+sz
<= GOF(D2
) +SZB(D2
)) return GOF(D2
);
962 if (o
>= GOF(D3
) && o
+sz
<= GOF(D3
) +SZB(D3
)) return GOF(D3
);
963 if (o
>= GOF(D4
) && o
+sz
<= GOF(D4
) +SZB(D4
)) return GOF(D4
);
964 if (o
>= GOF(D5
) && o
+sz
<= GOF(D5
) +SZB(D5
)) return GOF(D5
);
965 if (o
>= GOF(D6
) && o
+sz
<= GOF(D6
) +SZB(D6
)) return GOF(D6
);
966 if (o
>= GOF(D7
) && o
+sz
<= GOF(D7
) +SZB(D7
)) return GOF(D7
);
967 if (o
>= GOF(D8
) && o
+sz
<= GOF(D8
) +SZB(D8
)) return GOF(D8
);
968 if (o
>= GOF(D9
) && o
+sz
<= GOF(D9
) +SZB(D9
)) return GOF(D9
);
969 if (o
>= GOF(D10
) && o
+sz
<= GOF(D10
)+SZB(D10
)) return GOF(D10
);
970 if (o
>= GOF(D11
) && o
+sz
<= GOF(D11
)+SZB(D11
)) return GOF(D11
);
971 if (o
>= GOF(D12
) && o
+sz
<= GOF(D12
)+SZB(D12
)) return GOF(D12
);
972 if (o
>= GOF(D13
) && o
+sz
<= GOF(D13
)+SZB(D13
)) return GOF(D13
);
973 if (o
>= GOF(D14
) && o
+sz
<= GOF(D14
)+SZB(D14
)) return GOF(D14
);
974 if (o
>= GOF(D15
) && o
+sz
<= GOF(D15
)+SZB(D15
)) return GOF(D15
);
975 if (o
>= GOF(D16
) && o
+sz
<= GOF(D16
)+SZB(D16
)) return GOF(D16
);
976 if (o
>= GOF(D17
) && o
+sz
<= GOF(D17
)+SZB(D17
)) return GOF(D17
);
977 if (o
>= GOF(D18
) && o
+sz
<= GOF(D18
)+SZB(D18
)) return GOF(D18
);
978 if (o
>= GOF(D19
) && o
+sz
<= GOF(D19
)+SZB(D19
)) return GOF(D19
);
979 if (o
>= GOF(D20
) && o
+sz
<= GOF(D20
)+SZB(D20
)) return GOF(D20
);
980 if (o
>= GOF(D21
) && o
+sz
<= GOF(D21
)+SZB(D21
)) return GOF(D21
);
981 if (o
>= GOF(D22
) && o
+sz
<= GOF(D22
)+SZB(D22
)) return GOF(D22
);
982 if (o
>= GOF(D23
) && o
+sz
<= GOF(D23
)+SZB(D23
)) return GOF(D23
);
983 if (o
>= GOF(D24
) && o
+sz
<= GOF(D24
)+SZB(D24
)) return GOF(D24
);
984 if (o
>= GOF(D25
) && o
+sz
<= GOF(D25
)+SZB(D25
)) return GOF(D25
);
985 if (o
>= GOF(D26
) && o
+sz
<= GOF(D26
)+SZB(D26
)) return GOF(D26
);
986 if (o
>= GOF(D27
) && o
+sz
<= GOF(D27
)+SZB(D27
)) return GOF(D27
);
987 if (o
>= GOF(D28
) && o
+sz
<= GOF(D28
)+SZB(D28
)) return GOF(D28
);
988 if (o
>= GOF(D29
) && o
+sz
<= GOF(D29
)+SZB(D29
)) return GOF(D29
);
989 if (o
>= GOF(D30
) && o
+sz
<= GOF(D30
)+SZB(D30
)) return GOF(D30
);
990 if (o
>= GOF(D31
) && o
+sz
<= GOF(D31
)+SZB(D31
)) return GOF(D31
);
993 /* Accesses to Q registers */
995 if (o
>= GOF(D0
) && o
+sz
<= GOF(D0
) +2*SZB(D0
)) return GOF(D0
); // Q0
996 if (o
>= GOF(D2
) && o
+sz
<= GOF(D2
) +2*SZB(D2
)) return GOF(D2
); // Q1
997 if (o
>= GOF(D4
) && o
+sz
<= GOF(D4
) +2*SZB(D4
)) return GOF(D4
); // Q2
998 if (o
>= GOF(D6
) && o
+sz
<= GOF(D6
) +2*SZB(D6
)) return GOF(D6
); // Q3
999 if (o
>= GOF(D8
) && o
+sz
<= GOF(D8
) +2*SZB(D8
)) return GOF(D8
); // Q4
1000 if (o
>= GOF(D10
) && o
+sz
<= GOF(D10
)+2*SZB(D10
)) return GOF(D10
); // Q5
1001 if (o
>= GOF(D12
) && o
+sz
<= GOF(D12
)+2*SZB(D12
)) return GOF(D12
); // Q6
1002 if (o
>= GOF(D14
) && o
+sz
<= GOF(D14
)+2*SZB(D14
)) return GOF(D14
); // Q7
1003 if (o
>= GOF(D16
) && o
+sz
<= GOF(D16
)+2*SZB(D16
)) return GOF(D16
); // Q8
1004 if (o
>= GOF(D18
) && o
+sz
<= GOF(D18
)+2*SZB(D18
)) return GOF(D18
); // Q9
1005 if (o
>= GOF(D20
) && o
+sz
<= GOF(D20
)+2*SZB(D20
)) return GOF(D20
); // Q10
1006 if (o
>= GOF(D22
) && o
+sz
<= GOF(D22
)+2*SZB(D22
)) return GOF(D22
); // Q11
1007 if (o
>= GOF(D24
) && o
+sz
<= GOF(D24
)+2*SZB(D24
)) return GOF(D24
); // Q12
1008 if (o
>= GOF(D26
) && o
+sz
<= GOF(D26
)+2*SZB(D26
)) return GOF(D26
); // Q13
1009 if (o
>= GOF(D28
) && o
+sz
<= GOF(D28
)+2*SZB(D28
)) return GOF(D28
); // Q14
1010 if (o
>= GOF(D30
) && o
+sz
<= GOF(D30
)+2*SZB(D30
)) return GOF(D30
); // Q15
1013 if (o
== GOF(CMSTART
) && sz
== 4) return -1;
1014 if (o
== GOF(CMLEN
) && sz
== 4) return -1;
1016 VG_(printf
)("MC_(get_otrack_shadow_offset)(arm)(off=%d,sz=%d)\n",
1022 /* --------------------- arm64 --------------------- */
1024 # elif defined(VGA_arm64)
1026 # define GOF(_fieldname) \
1027 (offsetof(VexGuestARM64State,guest_##_fieldname))
1028 # define SZB(_fieldname) \
1029 (sizeof(((VexGuestARM64State*)0)->guest_##_fieldname))
1033 Bool is48
= sz
== 8 || sz
== 4;
1036 tl_assert(host_is_little_endian());
1038 if (o
== GOF(X0
) && is48
) return o
;
1039 if (o
== GOF(X1
) && is48
) return o
;
1040 if (o
== GOF(X2
) && is48
) return o
;
1041 if (o
== GOF(X3
) && is48
) return o
;
1042 if (o
== GOF(X4
) && is48
) return o
;
1043 if (o
== GOF(X5
) && is48
) return o
;
1044 if (o
== GOF(X6
) && is48
) return o
;
1045 if (o
== GOF(X7
) && is48
) return o
;
1046 if (o
== GOF(X8
) && is48
) return o
;
1047 if (o
== GOF(X9
) && is48
) return o
;
1048 if (o
== GOF(X10
) && is48
) return o
;
1049 if (o
== GOF(X11
) && is48
) return o
;
1050 if (o
== GOF(X12
) && is48
) return o
;
1051 if (o
== GOF(X13
) && is48
) return o
;
1052 if (o
== GOF(X14
) && is48
) return o
;
1053 if (o
== GOF(X15
) && is48
) return o
;
1054 if (o
== GOF(X16
) && is48
) return o
;
1055 if (o
== GOF(X17
) && is48
) return o
;
1056 if (o
== GOF(X18
) && is48
) return o
;
1057 if (o
== GOF(X19
) && is48
) return o
;
1058 if (o
== GOF(X20
) && is48
) return o
;
1059 if (o
== GOF(X21
) && is48
) return o
;
1060 if (o
== GOF(X22
) && is48
) return o
;
1061 if (o
== GOF(X23
) && is48
) return o
;
1062 if (o
== GOF(X24
) && is48
) return o
;
1063 if (o
== GOF(X25
) && is48
) return o
;
1064 if (o
== GOF(X26
) && is48
) return o
;
1065 if (o
== GOF(X27
) && is48
) return o
;
1066 if (o
== GOF(X28
) && is48
) return o
;
1067 if (o
== GOF(X29
) && is48
) return o
;
1068 if (o
== GOF(X30
) && is48
) return o
;
1069 if (o
== GOF(XSP
) && is48
) return o
;
1071 if (o
== GOF(PC
) && is48
) return -1; // untracked
1072 if (o
== GOF(CC_DEP1
) && sz
== 8) return o
;
1073 if (o
== GOF(CC_DEP2
) && sz
== 8) return o
;
1075 if (o
== GOF(CC_OP
) && sz
== 8) return -1; // untracked
1076 if (o
== GOF(CC_NDEP
) && sz
== 8) return -1; // untracked
1077 if (o
== GOF(TPIDR_EL0
) && sz
== 8) return -1; // untracked
1079 if (o
>= GOF(Q0
) && o
+sz
<= GOF(Q0
) +SZB(Q0
)) return GOF(Q0
);
1080 if (o
>= GOF(Q1
) && o
+sz
<= GOF(Q1
) +SZB(Q1
)) return GOF(Q1
);
1081 if (o
>= GOF(Q2
) && o
+sz
<= GOF(Q2
) +SZB(Q2
)) return GOF(Q2
);
1082 if (o
>= GOF(Q3
) && o
+sz
<= GOF(Q3
) +SZB(Q3
)) return GOF(Q3
);
1083 if (o
>= GOF(Q4
) && o
+sz
<= GOF(Q4
) +SZB(Q4
)) return GOF(Q4
);
1084 if (o
>= GOF(Q5
) && o
+sz
<= GOF(Q5
) +SZB(Q5
)) return GOF(Q5
);
1085 if (o
>= GOF(Q6
) && o
+sz
<= GOF(Q6
) +SZB(Q6
)) return GOF(Q6
);
1086 if (o
>= GOF(Q7
) && o
+sz
<= GOF(Q7
) +SZB(Q7
)) return GOF(Q7
);
1087 if (o
>= GOF(Q8
) && o
+sz
<= GOF(Q8
) +SZB(Q8
)) return GOF(Q8
);
1088 if (o
>= GOF(Q9
) && o
+sz
<= GOF(Q9
) +SZB(Q9
)) return GOF(Q9
);
1089 if (o
>= GOF(Q10
) && o
+sz
<= GOF(Q10
)+SZB(Q10
)) return GOF(Q10
);
1090 if (o
>= GOF(Q11
) && o
+sz
<= GOF(Q11
)+SZB(Q11
)) return GOF(Q11
);
1091 if (o
>= GOF(Q12
) && o
+sz
<= GOF(Q12
)+SZB(Q12
)) return GOF(Q12
);
1092 if (o
>= GOF(Q13
) && o
+sz
<= GOF(Q13
)+SZB(Q13
)) return GOF(Q13
);
1093 if (o
>= GOF(Q14
) && o
+sz
<= GOF(Q14
)+SZB(Q14
)) return GOF(Q14
);
1094 if (o
>= GOF(Q15
) && o
+sz
<= GOF(Q15
)+SZB(Q15
)) return GOF(Q15
);
1095 if (o
>= GOF(Q16
) && o
+sz
<= GOF(Q16
)+SZB(Q16
)) return GOF(Q16
);
1096 if (o
>= GOF(Q17
) && o
+sz
<= GOF(Q17
)+SZB(Q17
)) return GOF(Q17
);
1097 if (o
>= GOF(Q18
) && o
+sz
<= GOF(Q18
)+SZB(Q18
)) return GOF(Q18
);
1098 if (o
>= GOF(Q19
) && o
+sz
<= GOF(Q19
)+SZB(Q19
)) return GOF(Q19
);
1099 if (o
>= GOF(Q20
) && o
+sz
<= GOF(Q20
)+SZB(Q20
)) return GOF(Q20
);
1100 if (o
>= GOF(Q21
) && o
+sz
<= GOF(Q21
)+SZB(Q21
)) return GOF(Q21
);
1101 if (o
>= GOF(Q22
) && o
+sz
<= GOF(Q22
)+SZB(Q22
)) return GOF(Q22
);
1102 if (o
>= GOF(Q23
) && o
+sz
<= GOF(Q23
)+SZB(Q23
)) return GOF(Q23
);
1103 if (o
>= GOF(Q24
) && o
+sz
<= GOF(Q24
)+SZB(Q24
)) return GOF(Q24
);
1104 if (o
>= GOF(Q25
) && o
+sz
<= GOF(Q25
)+SZB(Q25
)) return GOF(Q25
);
1105 if (o
>= GOF(Q26
) && o
+sz
<= GOF(Q26
)+SZB(Q26
)) return GOF(Q26
);
1106 if (o
>= GOF(Q27
) && o
+sz
<= GOF(Q27
)+SZB(Q27
)) return GOF(Q27
);
1107 if (o
>= GOF(Q28
) && o
+sz
<= GOF(Q28
)+SZB(Q28
)) return GOF(Q28
);
1108 if (o
>= GOF(Q29
) && o
+sz
<= GOF(Q29
)+SZB(Q29
)) return GOF(Q29
);
1109 if (o
>= GOF(Q30
) && o
+sz
<= GOF(Q30
)+SZB(Q30
)) return GOF(Q30
);
1110 if (o
>= GOF(Q31
) && o
+sz
<= GOF(Q31
)+SZB(Q31
)) return GOF(Q31
);
1112 if (o
== GOF(FPCR
) && sz
== 4) return -1; // untracked
1113 if (o
== GOF(QCFLAG
) && sz
== 16) return o
;
1115 if (o
== GOF(CMSTART
) && sz
== 8) return -1; // untracked
1116 if (o
== GOF(CMLEN
) && sz
== 8) return -1; // untracked
1118 if (o
== GOF(LLSC_SIZE
) && sz
== 8) return -1; // untracked
1119 if (o
== GOF(LLSC_ADDR
) && sz
== 8) return o
;
1120 if (o
== GOF(LLSC_DATA_LO64
) && sz
== 8) return o
;
1121 if (o
== GOF(LLSC_DATA_HI64
) && sz
== 8) return o
;
1123 VG_(printf
)("MC_(get_otrack_shadow_offset)(arm64)(off=%d,sz=%d)\n",
1129 /* --------------------- mips32 --------------------- */
1131 # elif defined(VGA_mips32) || defined(VGA_nanomips)
1133 # define GOF(_fieldname) \
1134 (offsetof(VexGuestMIPS32State,guest_##_fieldname))
1135 # define SZB(_fieldname) \
1136 (sizeof(((VexGuestMIPS32State*)0)->guest_##_fieldname))
1141 # if defined (VG_LITTLEENDIAN)
1142 tl_assert(host_is_little_endian());
1143 # elif defined (VG_BIGENDIAN)
1144 tl_assert(host_is_big_endian());
1146 # error "Unknown endianness"
1149 if (o
== GOF(r0
) && sz
== 4) return o
;
1150 if (o
== GOF(r1
) && sz
== 4) return o
;
1151 if (o
== GOF(r2
) && sz
== 4) return o
;
1152 if (o
== GOF(r3
) && sz
== 4) return o
;
1153 if (o
== GOF(r4
) && sz
== 4) return o
;
1154 if (o
== GOF(r5
) && sz
== 4) return o
;
1155 if (o
== GOF(r6
) && sz
== 4) return o
;
1156 if (o
== GOF(r7
) && sz
== 4) return o
;
1157 if (o
== GOF(r8
) && sz
== 4) return o
;
1158 if (o
== GOF(r9
) && sz
== 4) return o
;
1159 if (o
== GOF(r10
) && sz
== 4) return o
;
1160 if (o
== GOF(r11
) && sz
== 4) return o
;
1161 if (o
== GOF(r12
) && sz
== 4) return o
;
1162 if (o
== GOF(r13
) && sz
== 4) return o
;
1163 if (o
== GOF(r14
) && sz
== 4) return o
;
1164 if (o
== GOF(r15
) && sz
== 4) return o
;
1165 if (o
== GOF(r16
) && sz
== 4) return o
;
1166 if (o
== GOF(r17
) && sz
== 4) return o
;
1167 if (o
== GOF(r18
) && sz
== 4) return o
;
1168 if (o
== GOF(r19
) && sz
== 4) return o
;
1169 if (o
== GOF(r20
) && sz
== 4) return o
;
1170 if (o
== GOF(r21
) && sz
== 4) return o
;
1171 if (o
== GOF(r22
) && sz
== 4) return o
;
1172 if (o
== GOF(r23
) && sz
== 4) return o
;
1173 if (o
== GOF(r24
) && sz
== 4) return o
;
1174 if (o
== GOF(r25
) && sz
== 4) return o
;
1175 if (o
== GOF(r26
) && sz
== 4) return o
;
1176 if (o
== GOF(r27
) && sz
== 4) return o
;
1177 if (o
== GOF(r28
) && sz
== 4) return o
;
1178 if (o
== GOF(r29
) && sz
== 4) return o
;
1179 if (o
== GOF(r30
) && sz
== 4) return o
;
1180 if (o
== GOF(r31
) && sz
== 4) return o
;
1181 if (o
== GOF(PC
) && sz
== 4) return -1; /* slot unused */
1183 if (o
== GOF(HI
) && sz
== 4) return o
;
1184 if (o
== GOF(LO
) && sz
== 4) return o
;
1186 if (o
== GOF(FIR
) && sz
== 4) return -1; /* slot unused */
1187 if (o
== GOF(FCCR
) && sz
== 4) return -1; /* slot unused */
1188 if (o
== GOF(FEXR
) && sz
== 4) return -1; /* slot unused */
1189 if (o
== GOF(FENR
) && sz
== 4) return -1; /* slot unused */
1190 if (o
== GOF(FCSR
) && sz
== 4) return -1; /* slot unused */
1191 if (o
== GOF(ULR
) && sz
== 4) return -1;
1193 if (o
== GOF(EMNOTE
) && sz
== 4) return -1; /* slot unused */
1194 if (o
== GOF(CMSTART
) && sz
== 4) return -1; /* slot unused */
1195 if (o
== GOF(CMLEN
) && sz
== 4) return -1; /* slot unused */
1196 if (o
== GOF(NRADDR
) && sz
== 4) return -1; /* slot unused */
1198 if (o
>= GOF(f0
) && o
+sz
<= GOF(f0
) +SZB(f0
)) return GOF(f0
);
1199 if (o
>= GOF(f1
) && o
+sz
<= GOF(f1
) +SZB(f1
)) return GOF(f1
);
1200 if (o
>= GOF(f2
) && o
+sz
<= GOF(f2
) +SZB(f2
)) return GOF(f2
);
1201 if (o
>= GOF(f3
) && o
+sz
<= GOF(f3
) +SZB(f3
)) return GOF(f3
);
1202 if (o
>= GOF(f4
) && o
+sz
<= GOF(f4
) +SZB(f4
)) return GOF(f4
);
1203 if (o
>= GOF(f5
) && o
+sz
<= GOF(f5
) +SZB(f5
)) return GOF(f5
);
1204 if (o
>= GOF(f6
) && o
+sz
<= GOF(f6
) +SZB(f6
)) return GOF(f6
);
1205 if (o
>= GOF(f7
) && o
+sz
<= GOF(f7
) +SZB(f7
)) return GOF(f7
);
1206 if (o
>= GOF(f8
) && o
+sz
<= GOF(f8
) +SZB(f8
)) return GOF(f8
);
1207 if (o
>= GOF(f9
) && o
+sz
<= GOF(f9
) +SZB(f9
)) return GOF(f9
);
1208 if (o
>= GOF(f10
) && o
+sz
<= GOF(f10
)+SZB(f10
)) return GOF(f10
);
1209 if (o
>= GOF(f11
) && o
+sz
<= GOF(f11
)+SZB(f11
)) return GOF(f11
);
1210 if (o
>= GOF(f12
) && o
+sz
<= GOF(f12
)+SZB(f12
)) return GOF(f12
);
1211 if (o
>= GOF(f13
) && o
+sz
<= GOF(f13
)+SZB(f13
)) return GOF(f13
);
1212 if (o
>= GOF(f14
) && o
+sz
<= GOF(f14
)+SZB(f14
)) return GOF(f14
);
1213 if (o
>= GOF(f15
) && o
+sz
<= GOF(f15
)+SZB(f15
)) return GOF(f15
);
1215 if (o
>= GOF(f16
) && o
+sz
<= GOF(f16
)+SZB(f16
)) return GOF(f16
);
1216 if (o
>= GOF(f17
) && o
+sz
<= GOF(f17
) +SZB(f17
)) return GOF(f17
);
1217 if (o
>= GOF(f18
) && o
+sz
<= GOF(f18
) +SZB(f18
)) return GOF(f18
);
1218 if (o
>= GOF(f19
) && o
+sz
<= GOF(f19
) +SZB(f19
)) return GOF(f19
);
1219 if (o
>= GOF(f20
) && o
+sz
<= GOF(f20
) +SZB(f20
)) return GOF(f20
);
1220 if (o
>= GOF(f21
) && o
+sz
<= GOF(f21
) +SZB(f21
)) return GOF(f21
);
1221 if (o
>= GOF(f22
) && o
+sz
<= GOF(f22
) +SZB(f22
)) return GOF(f22
);
1222 if (o
>= GOF(f23
) && o
+sz
<= GOF(f23
) +SZB(f23
)) return GOF(f23
);
1223 if (o
>= GOF(f24
) && o
+sz
<= GOF(f24
) +SZB(f24
)) return GOF(f24
);
1224 if (o
>= GOF(f25
) && o
+sz
<= GOF(f25
) +SZB(f25
)) return GOF(f25
);
1225 if (o
>= GOF(f26
) && o
+sz
<= GOF(f26
)+SZB(f26
)) return GOF(f26
);
1226 if (o
>= GOF(f27
) && o
+sz
<= GOF(f27
)+SZB(f27
)) return GOF(f27
);
1227 if (o
>= GOF(f28
) && o
+sz
<= GOF(f28
)+SZB(f28
)) return GOF(f28
);
1228 if (o
>= GOF(f29
) && o
+sz
<= GOF(f29
)+SZB(f29
)) return GOF(f29
);
1229 if (o
>= GOF(f30
) && o
+sz
<= GOF(f30
)+SZB(f30
)) return GOF(f30
);
1230 if (o
>= GOF(f31
) && o
+sz
<= GOF(f31
)+SZB(f31
)) return GOF(f31
);
1233 if ((o
> GOF(NRADDR
)) && (o
<= GOF(NRADDR
) +12 )) return -1;
1235 /* MIPS32 DSP ASE(r2) specific registers. */
1236 if (o
== GOF(DSPControl
) && sz
== 4) return o
;
1237 if (o
== GOF(ac0
) && sz
== 8) return o
;
1238 if (o
== GOF(ac1
) && sz
== 8) return o
;
1239 if (o
== GOF(ac2
) && sz
== 8) return o
;
1240 if (o
== GOF(ac3
) && sz
== 8) return o
;
1242 if (o
== GOF(LLaddr
) && sz
== 4) return -1; /* slot unused */
1243 if (o
== GOF(LLdata
) && sz
== 4) return -1; /* slot unused */
1245 if (o
>= GOF(w0
) && o
+sz
<= GOF(w0
) + SZB(w0
)) return GOF(w0
);
1246 if (o
>= GOF(w1
) && o
+sz
<= GOF(w1
) + SZB(w1
)) return GOF(w1
);
1247 if (o
>= GOF(w2
) && o
+sz
<= GOF(w2
) + SZB(w2
)) return GOF(w2
);
1248 if (o
>= GOF(w3
) && o
+sz
<= GOF(w3
) + SZB(w3
)) return GOF(w3
);
1249 if (o
>= GOF(w4
) && o
+sz
<= GOF(w4
) + SZB(w4
)) return GOF(w4
);
1250 if (o
>= GOF(w5
) && o
+sz
<= GOF(w5
) + SZB(w5
)) return GOF(w5
);
1251 if (o
>= GOF(w6
) && o
+sz
<= GOF(w6
) + SZB(w6
)) return GOF(w6
);
1252 if (o
>= GOF(w7
) && o
+sz
<= GOF(w7
) + SZB(w7
)) return GOF(w7
);
1253 if (o
>= GOF(w8
) && o
+sz
<= GOF(w8
) + SZB(w8
)) return GOF(w8
);
1254 if (o
>= GOF(w9
) && o
+sz
<= GOF(w9
) + SZB(w9
)) return GOF(w9
);
1255 if (o
>= GOF(w10
) && o
+sz
<= GOF(w10
) + SZB(w10
)) return GOF(w10
);
1256 if (o
>= GOF(w11
) && o
+sz
<= GOF(w11
) + SZB(w11
)) return GOF(w11
);
1257 if (o
>= GOF(w12
) && o
+sz
<= GOF(w12
) + SZB(w12
)) return GOF(w12
);
1258 if (o
>= GOF(w13
) && o
+sz
<= GOF(w13
) + SZB(w13
)) return GOF(w13
);
1259 if (o
>= GOF(w14
) && o
+sz
<= GOF(w14
) + SZB(w14
)) return GOF(w14
);
1260 if (o
>= GOF(w15
) && o
+sz
<= GOF(w15
) + SZB(w15
)) return GOF(w15
);
1261 if (o
>= GOF(w16
) && o
+sz
<= GOF(w16
) + SZB(w16
)) return GOF(w16
);
1262 if (o
>= GOF(w17
) && o
+sz
<= GOF(w17
) + SZB(w17
)) return GOF(w17
);
1263 if (o
>= GOF(w18
) && o
+sz
<= GOF(w18
) + SZB(w18
)) return GOF(w18
);
1264 if (o
>= GOF(w19
) && o
+sz
<= GOF(w19
) + SZB(w19
)) return GOF(w19
);
1265 if (o
>= GOF(w20
) && o
+sz
<= GOF(w20
) + SZB(w20
)) return GOF(w20
);
1266 if (o
>= GOF(w21
) && o
+sz
<= GOF(w21
) + SZB(w21
)) return GOF(w21
);
1267 if (o
>= GOF(w22
) && o
+sz
<= GOF(w22
) + SZB(w22
)) return GOF(w22
);
1268 if (o
>= GOF(w23
) && o
+sz
<= GOF(w23
) + SZB(w23
)) return GOF(w23
);
1269 if (o
>= GOF(w24
) && o
+sz
<= GOF(w24
) + SZB(w24
)) return GOF(w24
);
1270 if (o
>= GOF(w25
) && o
+sz
<= GOF(w25
) + SZB(w25
)) return GOF(w25
);
1271 if (o
>= GOF(w26
) && o
+sz
<= GOF(w26
) + SZB(w26
)) return GOF(w26
);
1272 if (o
>= GOF(w27
) && o
+sz
<= GOF(w27
) + SZB(w27
)) return GOF(w27
);
1273 if (o
>= GOF(w28
) && o
+sz
<= GOF(w28
) + SZB(w28
)) return GOF(w28
);
1274 if (o
>= GOF(w29
) && o
+sz
<= GOF(w29
) + SZB(w29
)) return GOF(w29
);
1275 if (o
>= GOF(w30
) && o
+sz
<= GOF(w30
) + SZB(w30
)) return GOF(w30
);
1276 if (o
>= GOF(w31
) && o
+sz
<= GOF(w31
) + SZB(w31
)) return GOF(w31
);
1278 VG_(printf
)("MC_(get_otrack_shadow_offset)(mips)(off=%d,sz=%d)\n",
1284 /* --------------------- mips64 --------------------- */
1286 # elif defined(VGA_mips64)
1288 # define GOF(_fieldname) \
1289 (offsetof(VexGuestMIPS64State,guest_##_fieldname))
1290 # define SZB(_fieldname) \
1291 (sizeof(((VexGuestMIPS64State*)0)->guest_##_fieldname))
1296 #if defined (VG_LITTLEENDIAN)
1297 tl_assert(host_is_little_endian());
1298 #elif defined (VG_BIGENDIAN)
1299 tl_assert(host_is_big_endian());
1302 if (o
>= GOF(r0
) && sz
<= 8 && o
<= (GOF(r31
) + 8 - sz
))
1303 return GOF(r0
) + ((o
-GOF(r0
)) & -8) ;
1305 if (o
== GOF(PC
) && sz
== 8) return -1; /* slot unused */
1307 if (o
== GOF(HI
) && sz
== 8) return o
;
1308 if (o
== GOF(LO
) && sz
== 8) return o
;
1310 if (o
== GOF(FIR
) && sz
== 4) return -1; /* slot unused */
1311 if (o
== GOF(FCCR
) && sz
== 4) return -1; /* slot unused */
1312 if (o
== GOF(FEXR
) && sz
== 4) return -1; /* slot unused */
1313 if (o
== GOF(FENR
) && sz
== 4) return -1; /* slot unused */
1314 if (o
== GOF(FCSR
) && sz
== 4) return -1; /* slot unused */
1315 if (o
== GOF(ULR
) && sz
== 8) return o
;
1317 if (o
== GOF(EMNOTE
) && sz
== 4) return -1; /* slot unused */
1318 if (o
== GOF(CMSTART
) && sz
== 4) return -1; /* slot unused */
1319 if (o
== GOF(CMLEN
) && sz
== 4) return -1; /* slot unused */
1320 if (o
== GOF(NRADDR
) && sz
== 4) return -1; /* slot unused */
1322 if (o
>= GOF(f0
) && o
+sz
<= GOF(f0
) +SZB(f0
)) return GOF(f0
);
1323 if (o
>= GOF(f1
) && o
+sz
<= GOF(f1
) +SZB(f1
)) return GOF(f1
);
1324 if (o
>= GOF(f2
) && o
+sz
<= GOF(f2
) +SZB(f2
)) return GOF(f2
);
1325 if (o
>= GOF(f3
) && o
+sz
<= GOF(f3
) +SZB(f3
)) return GOF(f3
);
1326 if (o
>= GOF(f4
) && o
+sz
<= GOF(f4
) +SZB(f4
)) return GOF(f4
);
1327 if (o
>= GOF(f5
) && o
+sz
<= GOF(f5
) +SZB(f5
)) return GOF(f5
);
1328 if (o
>= GOF(f6
) && o
+sz
<= GOF(f6
) +SZB(f6
)) return GOF(f6
);
1329 if (o
>= GOF(f7
) && o
+sz
<= GOF(f7
) +SZB(f7
)) return GOF(f7
);
1330 if (o
>= GOF(f8
) && o
+sz
<= GOF(f8
) +SZB(f8
)) return GOF(f8
);
1331 if (o
>= GOF(f9
) && o
+sz
<= GOF(f9
) +SZB(f9
)) return GOF(f9
);
1332 if (o
>= GOF(f10
) && o
+sz
<= GOF(f10
)+SZB(f10
)) return GOF(f10
);
1333 if (o
>= GOF(f11
) && o
+sz
<= GOF(f11
)+SZB(f11
)) return GOF(f11
);
1334 if (o
>= GOF(f12
) && o
+sz
<= GOF(f12
)+SZB(f12
)) return GOF(f12
);
1335 if (o
>= GOF(f13
) && o
+sz
<= GOF(f13
)+SZB(f13
)) return GOF(f13
);
1336 if (o
>= GOF(f14
) && o
+sz
<= GOF(f14
)+SZB(f14
)) return GOF(f14
);
1337 if (o
>= GOF(f15
) && o
+sz
<= GOF(f15
)+SZB(f15
)) return GOF(f15
);
1338 if (o
>= GOF(f16
) && o
+sz
<= GOF(f16
)+SZB(f16
)) return GOF(f16
);
1339 if (o
>= GOF(f17
) && o
+sz
<= GOF(f17
)+SZB(f17
)) return GOF(f17
);
1340 if (o
>= GOF(f18
) && o
+sz
<= GOF(f18
)+SZB(f18
)) return GOF(f18
);
1341 if (o
>= GOF(f19
) && o
+sz
<= GOF(f19
)+SZB(f19
)) return GOF(f19
);
1342 if (o
>= GOF(f20
) && o
+sz
<= GOF(f20
)+SZB(f20
)) return GOF(f20
);
1343 if (o
>= GOF(f21
) && o
+sz
<= GOF(f21
)+SZB(f21
)) return GOF(f21
);
1344 if (o
>= GOF(f22
) && o
+sz
<= GOF(f22
)+SZB(f22
)) return GOF(f22
);
1345 if (o
>= GOF(f23
) && o
+sz
<= GOF(f23
)+SZB(f23
)) return GOF(f23
);
1346 if (o
>= GOF(f24
) && o
+sz
<= GOF(f24
)+SZB(f24
)) return GOF(f24
);
1347 if (o
>= GOF(f25
) && o
+sz
<= GOF(f25
)+SZB(f25
)) return GOF(f25
);
1348 if (o
>= GOF(f26
) && o
+sz
<= GOF(f26
)+SZB(f26
)) return GOF(f26
);
1349 if (o
>= GOF(f27
) && o
+sz
<= GOF(f27
)+SZB(f27
)) return GOF(f27
);
1350 if (o
>= GOF(f28
) && o
+sz
<= GOF(f28
)+SZB(f28
)) return GOF(f28
);
1351 if (o
>= GOF(f29
) && o
+sz
<= GOF(f29
)+SZB(f29
)) return GOF(f29
);
1352 if (o
>= GOF(f30
) && o
+sz
<= GOF(f30
)+SZB(f30
)) return GOF(f30
);
1353 if (o
>= GOF(f31
) && o
+sz
<= GOF(f31
)+SZB(f31
)) return GOF(f31
);
1355 if ((o
> GOF(NRADDR
)) && (o
<= GOF(NRADDR
) +12 )) return -1;
1357 if (o
== GOF(LLaddr
) && sz
== 8) return -1; /* slot unused */
1358 if (o
== GOF(LLdata
) && sz
== 8) return -1; /* slot unused */
1360 if (o
>= GOF(w0
) && o
+sz
<= GOF(w0
) + SZB(w0
)) return GOF(w0
);
1361 if (o
>= GOF(w1
) && o
+sz
<= GOF(w1
) + SZB(w1
)) return GOF(w1
);
1362 if (o
>= GOF(w2
) && o
+sz
<= GOF(w2
) + SZB(w2
)) return GOF(w2
);
1363 if (o
>= GOF(w3
) && o
+sz
<= GOF(w3
) + SZB(w3
)) return GOF(w3
);
1364 if (o
>= GOF(w4
) && o
+sz
<= GOF(w4
) + SZB(w4
)) return GOF(w4
);
1365 if (o
>= GOF(w5
) && o
+sz
<= GOF(w5
) + SZB(w5
)) return GOF(w5
);
1366 if (o
>= GOF(w6
) && o
+sz
<= GOF(w6
) + SZB(w6
)) return GOF(w6
);
1367 if (o
>= GOF(w7
) && o
+sz
<= GOF(w7
) + SZB(w7
)) return GOF(w7
);
1368 if (o
>= GOF(w8
) && o
+sz
<= GOF(w8
) + SZB(w8
)) return GOF(w8
);
1369 if (o
>= GOF(w9
) && o
+sz
<= GOF(w9
) + SZB(w9
)) return GOF(w9
);
1370 if (o
>= GOF(w10
) && o
+sz
<= GOF(w10
) + SZB(w10
)) return GOF(w10
);
1371 if (o
>= GOF(w11
) && o
+sz
<= GOF(w11
) + SZB(w11
)) return GOF(w11
);
1372 if (o
>= GOF(w12
) && o
+sz
<= GOF(w12
) + SZB(w12
)) return GOF(w12
);
1373 if (o
>= GOF(w13
) && o
+sz
<= GOF(w13
) + SZB(w13
)) return GOF(w13
);
1374 if (o
>= GOF(w14
) && o
+sz
<= GOF(w14
) + SZB(w14
)) return GOF(w14
);
1375 if (o
>= GOF(w15
) && o
+sz
<= GOF(w15
) + SZB(w15
)) return GOF(w15
);
1376 if (o
>= GOF(w16
) && o
+sz
<= GOF(w16
) + SZB(w16
)) return GOF(w16
);
1377 if (o
>= GOF(w17
) && o
+sz
<= GOF(w17
) + SZB(w17
)) return GOF(w17
);
1378 if (o
>= GOF(w18
) && o
+sz
<= GOF(w18
) + SZB(w18
)) return GOF(w18
);
1379 if (o
>= GOF(w19
) && o
+sz
<= GOF(w19
) + SZB(w19
)) return GOF(w19
);
1380 if (o
>= GOF(w20
) && o
+sz
<= GOF(w20
) + SZB(w20
)) return GOF(w20
);
1381 if (o
>= GOF(w21
) && o
+sz
<= GOF(w21
) + SZB(w21
)) return GOF(w21
);
1382 if (o
>= GOF(w22
) && o
+sz
<= GOF(w22
) + SZB(w22
)) return GOF(w22
);
1383 if (o
>= GOF(w23
) && o
+sz
<= GOF(w23
) + SZB(w23
)) return GOF(w23
);
1384 if (o
>= GOF(w24
) && o
+sz
<= GOF(w24
) + SZB(w24
)) return GOF(w24
);
1385 if (o
>= GOF(w25
) && o
+sz
<= GOF(w25
) + SZB(w25
)) return GOF(w25
);
1386 if (o
>= GOF(w26
) && o
+sz
<= GOF(w26
) + SZB(w26
)) return GOF(w26
);
1387 if (o
>= GOF(w27
) && o
+sz
<= GOF(w27
) + SZB(w27
)) return GOF(w27
);
1388 if (o
>= GOF(w28
) && o
+sz
<= GOF(w28
) + SZB(w28
)) return GOF(w28
);
1389 if (o
>= GOF(w29
) && o
+sz
<= GOF(w29
) + SZB(w29
)) return GOF(w29
);
1390 if (o
>= GOF(w30
) && o
+sz
<= GOF(w30
) + SZB(w30
)) return GOF(w30
);
1391 if (o
>= GOF(w31
) && o
+sz
<= GOF(w31
) + SZB(w31
)) return GOF(w31
);
1393 VG_(printf
)("MC_(get_otrack_shadow_offset)(mips)(off=%d,sz=%d)\n",
1400 # error "FIXME: not implemented for this architecture"
1405 /* Let 'arr' describe an indexed reference to a guest state section
1406 (guest state array).
1408 This function returns the corresponding guest state type to be used
1409 when indexing the corresponding array in the second shadow (origin
1410 tracking) area. If the array is not to be origin-tracked, return
1413 This function must agree with MC_(get_otrack_shadow_offset) above.
1414 See comments at the start of MC_(get_otrack_shadow_offset).
1416 IRType
MC_(get_otrack_reg_array_equiv_int_type
) ( IRRegArray
* arr
)
1418 /* -------------------- ppc64 -------------------- */
1419 # if defined(VGA_ppc64be) || defined(VGA_ppc64le)
1420 /* The redir stack. */
1421 if (arr
->base
== offsetof(VexGuestPPC64State
,guest_REDIR_STACK
[0])
1422 && arr
->elemTy
== Ity_I64
1423 && arr
->nElems
== VEX_GUEST_PPC64_REDIR_STACK_SIZE
)
1426 VG_(printf
)("get_reg_array_equiv_int_type(ppc64): unhandled: ");
1431 /* -------------------- ppc32 -------------------- */
1432 # elif defined(VGA_ppc32)
1433 /* The redir stack. */
1434 if (arr
->base
== offsetof(VexGuestPPC32State
,guest_REDIR_STACK
[0])
1435 && arr
->elemTy
== Ity_I32
1436 && arr
->nElems
== VEX_GUEST_PPC32_REDIR_STACK_SIZE
)
1439 VG_(printf
)("get_reg_array_equiv_int_type(ppc32): unhandled: ");
1444 /* -------------------- amd64 -------------------- */
1445 # elif defined(VGA_amd64)
1446 /* Ignore the FP tag array - pointless to shadow, and in any case
1447 the elements are too small */
1448 if (arr
->base
== offsetof(VexGuestAMD64State
,guest_FPTAG
)
1449 && arr
->elemTy
== Ity_I8
&& arr
->nElems
== 8)
1452 /* The FP register array */
1453 if (arr
->base
== offsetof(VexGuestAMD64State
,guest_FPREG
[0])
1454 && arr
->elemTy
== Ity_F64
&& arr
->nElems
== 8)
1457 VG_(printf
)("get_reg_array_equiv_int_type(amd64): unhandled: ");
1462 /* --------------------- x86 --------------------- */
1463 # elif defined(VGA_x86)
1464 /* Ignore the FP tag array - pointless to shadow, and in any case
1465 the elements are too small */
1466 if (arr
->base
== offsetof(VexGuestX86State
,guest_FPTAG
)
1467 && arr
->elemTy
== Ity_I8
&& arr
->nElems
== 8)
1470 /* The FP register array */
1471 if (arr
->base
== offsetof(VexGuestX86State
,guest_FPREG
[0])
1472 && arr
->elemTy
== Ity_F64
&& arr
->nElems
== 8)
1475 VG_(printf
)("get_reg_array_equiv_int_type(x86): unhandled: ");
1480 /* --------------------- arm --------------------- */
1481 # elif defined(VGA_arm)
1482 VG_(printf
)("get_reg_array_equiv_int_type(arm): unhandled: ");
1487 /* --------------------- arm64 --------------------- */
1488 # elif defined(VGA_arm64)
1489 VG_(printf
)("get_reg_array_equiv_int_type(arm64): unhandled: ");
1494 /* --------------------- s390x --------------------- */
1495 # elif defined(VGA_s390x)
1496 /* Should never het here because s390x does not use Ist_PutI
1500 /* --------------------- mips32 --------------------- */
1501 # elif defined(VGA_mips32)
1502 VG_(printf
)("get_reg_array_equiv_int_type(mips32): unhandled: ");
1506 /* --------------------- nanomips ------------------- */
1507 # elif defined(VGA_nanomips)
1508 VG_(printf
)("get_reg_array_equiv_int_type(nanomips): unhandled: ");
1513 /* --------------------- mips64 --------------------- */
1514 # elif defined(VGA_mips64)
1515 VG_(printf
)("get_reg_array_equiv_int_type(mips64): unhandled: ");
1521 # error "FIXME: not implemented for this architecture"
1526 /*--------------------------------------------------------------------*/
1527 /*--- end mc_machine.c ---*/
1528 /*--------------------------------------------------------------------*/