non-linux regtest: update cmdline expecteds
[valgrind.git] / VEX / pub / libvex_guest_ppc64.h
blobc7fe874a899fb182823b464b538bb30311bdf08d
2 /*---------------------------------------------------------------*/
3 /*--- begin libvex_guest_ppc64.h ---*/
4 /*---------------------------------------------------------------*/
6 /*
7 This file is part of Valgrind, a dynamic binary instrumentation
8 framework.
10 Copyright (C) 2004-2017 OpenWorks LLP
11 info@open-works.net
13 This program is free software; you can redistribute it and/or
14 modify it under the terms of the GNU General Public License as
15 published by the Free Software Foundation; either version 2 of the
16 License, or (at your option) any later version.
18 This program is distributed in the hope that it will be useful, but
19 WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, see <http://www.gnu.org/licenses/>.
26 The GNU General Public License is contained in the file COPYING.
28 Neither the names of the U.S. Department of Energy nor the
29 University of California nor the names of its contributors may be
30 used to endorse or promote products derived from this software
31 without prior written permission.
34 #ifndef __LIBVEX_PUB_GUEST_PPC64_H
35 #define __LIBVEX_PUB_GUEST_PPC64_H
37 #include "libvex_basictypes.h"
40 volatile == caller-saved (not preserved across function calls)
41 non-volatile == callee-saved (preserved across function calls)
43 r0 Volatile register used in function prologs
44 r1 Stack frame pointer
45 r2 TOC pointer
46 r3 Volatile parameter and return value register
47 r4-r10 Volatile registers used for function parameters
48 r11 Volatile register used in calls by pointer and as an
49 environment pointer for languages which require one
50 r12 Volatile register used for exception handling and glink code
51 r13 Reserved for use as system thread ID
52 r14-r31 Nonvolatile registers used for local variables
54 f0 Volatile scratch register
55 f1-f4 Volatile floating point parameter and return value registers
56 f5-f13 Volatile floating point parameter registers
57 f14-f31 Nonvolatile registers
59 LR Link register (volatile)
60 CTR Loop counter register (volatile)
61 XER Fixed point exception register (volatile)
62 FPSCR Floating point status and control register (volatile)
64 CR0-CR1 Volatile condition code register fields
65 CR2-CR4 Nonvolatile condition code register fields
66 CR5-CR7 Volatile condition code register fields
68 On processors with the VMX feature.
70 v0-v1 Volatile scratch registers
71 v2-v13 Volatile vector parameters registers
72 v14-v19 Volatile scratch registers
73 v20-v31 Non-volatile registers
74 vrsave Non-volatile 32-bit register
78 /*---------------------------------------------------------------*/
79 /*--- Vex's representation of the PPC64 CPU state ---*/
80 /*---------------------------------------------------------------*/
82 #define VEX_GUEST_PPC64_REDIR_STACK_SIZE (16/*entries*/ * 2/*words per entry*/)
84 typedef
85 struct {
86 /* Event check fail addr, counter, and padding to make GPR0 16
87 aligned. */
88 /* 0 */ ULong host_EvC_FAILADDR;
89 /* 8 */ UInt host_EvC_COUNTER;
90 /* 12 */ UInt pad0;
91 /* Add 16 to all of the offsets below .. */
92 /* General Purpose Registers */
93 /* 0 */ ULong guest_GPR0;
94 /* 8 */ ULong guest_GPR1;
95 /* 16 */ ULong guest_GPR2;
96 /* 24 */ ULong guest_GPR3;
97 /* 32 */ ULong guest_GPR4;
98 /* 40 */ ULong guest_GPR5;
99 /* 48 */ ULong guest_GPR6;
100 /* 56 */ ULong guest_GPR7;
101 /* 64 */ ULong guest_GPR8;
102 /* 72 */ ULong guest_GPR9;
103 /* 80 */ ULong guest_GPR10;
104 /* 88 */ ULong guest_GPR11;
105 /* 96 */ ULong guest_GPR12;
106 /* 104 */ ULong guest_GPR13;
107 /* 112 */ ULong guest_GPR14;
108 /* 120 */ ULong guest_GPR15;
109 /* 128 */ ULong guest_GPR16;
110 /* 136 */ ULong guest_GPR17;
111 /* 144 */ ULong guest_GPR18;
112 /* 152 */ ULong guest_GPR19;
113 /* 160 */ ULong guest_GPR20;
114 /* 168 */ ULong guest_GPR21;
115 /* 176 */ ULong guest_GPR22;
116 /* 184 */ ULong guest_GPR23;
117 /* 192 */ ULong guest_GPR24;
118 /* 200 */ ULong guest_GPR25;
119 /* 208 */ ULong guest_GPR26;
120 /* 216 */ ULong guest_GPR27;
121 /* 224 */ ULong guest_GPR28;
122 /* 232 */ ULong guest_GPR29;
123 /* 240 */ ULong guest_GPR30;
124 /* 248 */ ULong guest_GPR31;
126 // Vector Registers, Floating Point Registers, and VSX Registers
127 // With ISA 2.06, the "Vector-Scalar Floating-point" category
128 // provides facilities to support vector and scalar binary floating-
129 // point operations. A unified register file is an integral part
130 // of this new facility, combining floating point and vector registers
131 // using a 64x128-bit vector. These are referred to as VSR[0..63].
132 // The floating point registers are now mapped into double word element 0
133 // of VSR[0..31]. The 32x128-bit vector registers defined by the "Vector
134 // Facility [Category: Vector]" are now mapped to VSR[32..63].
136 // IMPORTANT: the user of libvex must place the guest state so as
137 // to ensure that guest_VSR{0..63}, and any shadows thereof, are
138 // 16-aligned.
140 /* 256 */ U128 guest_VSR0;
141 /* 272 */ U128 guest_VSR1;
142 /* 288 */ U128 guest_VSR2;
143 /* 304 */ U128 guest_VSR3;
144 /* 320 */ U128 guest_VSR4;
145 /* 336 */ U128 guest_VSR5;
146 /* 352 */ U128 guest_VSR6;
147 /* 368 */ U128 guest_VSR7;
148 /* 384 */ U128 guest_VSR8;
149 /* 400 */ U128 guest_VSR9;
150 /* 416 */ U128 guest_VSR10;
151 /* 432 */ U128 guest_VSR11;
152 /* 448 */ U128 guest_VSR12;
153 /* 464 */ U128 guest_VSR13;
154 /* 480 */ U128 guest_VSR14;
155 /* 496 */ U128 guest_VSR15;
156 /* 512 */ U128 guest_VSR16;
157 /* 528 */ U128 guest_VSR17;
158 /* 544 */ U128 guest_VSR18;
159 /* 560 */ U128 guest_VSR19;
160 /* 576 */ U128 guest_VSR20;
161 /* 592 */ U128 guest_VSR21;
162 /* 608 */ U128 guest_VSR22;
163 /* 624 */ U128 guest_VSR23;
164 /* 640 */ U128 guest_VSR24;
165 /* 656 */ U128 guest_VSR25;
166 /* 672 */ U128 guest_VSR26;
167 /* 688 */ U128 guest_VSR27;
168 /* 704 */ U128 guest_VSR28;
169 /* 720 */ U128 guest_VSR29;
170 /* 736 */ U128 guest_VSR30;
171 /* 752 */ U128 guest_VSR31;
172 /* 768 */ U128 guest_VSR32;
173 /* 784 */ U128 guest_VSR33;
174 /* 800 */ U128 guest_VSR34;
175 /* 816 */ U128 guest_VSR35;
176 /* 832 */ U128 guest_VSR36;
177 /* 848 */ U128 guest_VSR37;
178 /* 864 */ U128 guest_VSR38;
179 /* 880 */ U128 guest_VSR39;
180 /* 896 */ U128 guest_VSR40;
181 /* 912 */ U128 guest_VSR41;
182 /* 928 */ U128 guest_VSR42;
183 /* 944 */ U128 guest_VSR43;
184 /* 960 */ U128 guest_VSR44;
185 /* 976 */ U128 guest_VSR45;
186 /* 992 */ U128 guest_VSR46;
187 /* 1008 */ U128 guest_VSR47;
188 /* 1024 */ U128 guest_VSR48;
189 /* 1040 */ U128 guest_VSR49;
190 /* 1056 */ U128 guest_VSR50;
191 /* 1072 */ U128 guest_VSR51;
192 /* 1088 */ U128 guest_VSR52;
193 /* 1104 */ U128 guest_VSR53;
194 /* 1120 */ U128 guest_VSR54;
195 /* 1136 */ U128 guest_VSR55;
196 /* 1152 */ U128 guest_VSR56;
197 /* 1168 */ U128 guest_VSR57;
198 /* 1184 */ U128 guest_VSR58;
199 /* 1200 */ U128 guest_VSR59;
200 /* 1216 */ U128 guest_VSR60;
201 /* 1232 */ U128 guest_VSR61;
202 /* 1248 */ U128 guest_VSR62;
203 /* 1264 */ U128 guest_VSR63;
205 /* 1280 */ ULong guest_CIA; // IP (no arch visible register)
206 /* 1288 */ ULong guest_LR; // Link Register
207 /* 1296 */ ULong guest_CTR; // Count Register
209 /* XER pieces */
210 /* 1304 */ UChar guest_XER_SO; /* in lsb */
211 /* 1305 */ UChar guest_XER_OV; /* in lsb */
212 /* 1306 */ UChar guest_XER_OV32; /* in lsb */
213 /* 1307 */ UChar guest_XER_CA; /* in lsb */
214 /* 1308 */ UChar guest_XER_CA32; /* in lsb */
215 /* 1309 */ UChar guest_XER_BC; /* all bits */
217 /* CR pieces */
218 /* 1310 */ UChar guest_CR0_321; /* in [3:1] */
219 /* 1311 */ UChar guest_CR0_0; /* in lsb */
220 /* 1312 */ UChar guest_CR1_321; /* in [3:1] */
221 /* 1313 */ UChar guest_CR1_0; /* in lsb */
222 /* 1314 */ UChar guest_CR2_321; /* in [3:1] */
223 /* 1315 */ UChar guest_CR2_0; /* in lsb */
224 /* 1316 */ UChar guest_CR3_321; /* in [3:1] */
225 /* 1317 */ UChar guest_CR3_0; /* in lsb */
226 /* 1318 */ UChar guest_CR4_321; /* in [3:1] */
227 /* 1319 */ UChar guest_CR4_0; /* in lsb */
228 /* 1320 */ UChar guest_CR5_321; /* in [3:1] */
229 /* 1321 */ UChar guest_CR5_0; /* in lsb */
230 /* 1322 */ UChar guest_CR6_321; /* in [3:1] */
231 /* 1323 */ UChar guest_CR6_0; /* in lsb */
232 /* 1324 */ UChar guest_CR7_321; /* in [3:1] */
233 /* 1325 */ UChar guest_CR7_0; /* in lsb */
235 /* FP Status and Control Register fields. Only rounding mode fields
236 * and Floating-point Condition Code (FPCC) fields are supported.
238 /* 1326 */ UChar guest_FPROUND; // Binary Floating Point Rounding Mode
239 /* 1327 */ UChar guest_DFPROUND; // Decimal Floating Point Rounding Mode
240 /* 1328 */ UChar guest_C_FPCC; // Floating-point Condition Code
241 // and Floating-point Condition Code
243 /* 1329 */ UChar pad2;
244 /* 1330 */ UChar pad3;
245 /* 1331 */ UChar pad4;
247 /* Vector Save/Restore Register */
248 /* 1332 */ UInt guest_VRSAVE;
250 /* Vector Status and Control Register */
251 /* 1336 */ UInt guest_VSCR;
253 /* Emulation notes */
254 /* 1340 */ UInt guest_EMNOTE;
256 /* gcc adds 4 bytes padding here: pre-empt it. */
257 /* 1344 */ UInt padding;
259 /* For icbi: record start and length of area to invalidate */
260 /* 1348 */ ULong guest_CMSTART;
261 /* 1356 */ ULong guest_CMLEN;
263 /* Used to record the unredirected guest address at the start of
264 a translation whose start has been redirected. By reading
265 this pseudo-register shortly afterwards, the translation can
266 find out what the corresponding no-redirection address was.
267 Note, this is only set for wrap-style redirects, not for
268 replace-style ones. */
269 /* 1364 */ ULong guest_NRADDR;
270 /* 1372 */ ULong guest_NRADDR_GPR2;
272 /* A grows-upwards stack for hidden saves/restores of LR and R2
273 needed for function interception and wrapping on ppc64-linux.
274 A horrible hack. REDIR_SP points to the highest live entry,
275 and so starts at -1. */
276 /* 1380 */ ULong guest_REDIR_SP;
277 /* 1388 */ ULong guest_REDIR_STACK[VEX_GUEST_PPC64_REDIR_STACK_SIZE];
279 /* Needed for Darwin: CIA at the last SC insn. Used when backing up
280 to restart a syscall that has been interrupted by a signal. */
281 /* 1648 */ ULong guest_IP_AT_SYSCALL;
283 /* SPRG3, which AIUI is readonly in user space. Needed for
284 threading on AIX. */
285 /* 1656 */ ULong guest_SPRG3_RO;
287 /* 1664 */ ULong guest_TFHAR; // Transaction Failure Handler Address Register
288 /* 1672 */ ULong guest_TEXASR; // Transaction EXception And Summary Register
289 /* 1680 */ ULong guest_TFIAR; // Transaction Failure Instruction Address Register
290 /* 1688 */ ULong guest_PPR; // Program Priority register
291 /* 1696 */ UInt guest_TEXASRU; // Transaction EXception And Summary Register Upper
292 /* 1700 */ UInt guest_PSPB; // Problem State Priority Boost register
293 /* 1704 */ ULong guest_DSCR; // Data Stream Control register
295 /* Historical note, Initial ACC support was implemented to use a separate
296 register file, but in practice (ISA 3.1) the hardware implementation
297 logically overlays over the existing VSR registers. This may change
298 in future hardware, so the current implementation assumes ACC and VSRs
299 logically contain the same data, but code remains in place to support
300 future implementations that may require a separate register file.
301 02/08/2022. */
302 /* The guest_ACC_entries must be in order and sequential. The helper
303 routines get_ACC_entry(), write_ACC_entry() calculate the offset of
304 the ACC entry based on a address of guest_ACC_0_r0. */
305 /* 1712 */ U128 guest_ACC_0_r0;
306 /* 1728 */ U128 guest_ACC_0_r1;
307 /* 1744 */ U128 guest_ACC_0_r2;
308 /* 1760 */ U128 guest_ACC_0_r3;
309 /* 1776 */ U128 guest_ACC_1_r0;
310 /* 1792 */ U128 guest_ACC_1_r1;
311 /* 1808 */ U128 guest_ACC_1_r2;
312 /* 1824 */ U128 guest_ACC_1_r3;
313 /* 1840 */ U128 guest_ACC_2_r0;
314 /* 1856 */ U128 guest_ACC_2_r1;
315 /* 1872 */ U128 guest_ACC_2_r2;
316 /* 1888 */ U128 guest_ACC_2_r3;
317 /* 1904 */ U128 guest_ACC_3_r0;
318 /* 1920 */ U128 guest_ACC_3_r1;
319 /* 1936 */ U128 guest_ACC_3_r2;
320 /* 1952 */ U128 guest_ACC_3_r3;
321 /* 1968 */ U128 guest_ACC_4_r0;
322 /* 1984 */ U128 guest_ACC_4_r1;
323 /* 2000 */ U128 guest_ACC_4_r2;
324 /* 2016 */ U128 guest_ACC_4_r3;
325 /* 2032 */ U128 guest_ACC_5_r0;
326 /* 2048 */ U128 guest_ACC_5_r1;
327 /* 2064 */ U128 guest_ACC_5_r2;
328 /* 2080 */ U128 guest_ACC_5_r3;
329 /* 2096 */ U128 guest_ACC_6_r0;
330 /* 2112 */ U128 guest_ACC_6_r1;
331 /* 2128 */ U128 guest_ACC_6_r2;
332 /* 2144 */ U128 guest_ACC_6_r3;
333 /* 2160 */ U128 guest_ACC_7_r0;
334 /* 2176 */ U128 guest_ACC_7_r1;
335 /* 2192 */ U128 guest_ACC_7_r2;
336 /* 2208 */ U128 guest_ACC_7_r3;
338 /* 2224 */ UInt guest_syscall_flag;
339 /* 2228 */ UInt padding1;
340 /* 2232 */ UInt padding2;
341 /* 2236 */ UInt padding3;
342 /* Padding to make it have an 16-aligned size */
343 /* 2222 UInt padding0; */
345 VexGuestPPC64State;
348 /*---------------------------------------------------------------*/
349 /*--- Utility functions for PPC64 guest stuff. ---*/
350 /*---------------------------------------------------------------*/
352 /* ALL THE FOLLOWING ARE VISIBLE TO LIBRARY CLIENT */
354 /* Initialise all guest PPC64 state. */
355 extern
356 void LibVEX_GuestPPC64_initialise ( /*OUT*/VexGuestPPC64State* vex_state );
359 /* Write the given native %CR value to the supplied VexGuestPPC64State
360 structure. Note, %CR is 32-bits even for ppc64. */
361 extern
362 void LibVEX_GuestPPC64_put_CR ( UInt cr_native,
363 /*OUT*/VexGuestPPC64State* vex_state );
365 /* Extract from the supplied VexGuestPPC64State structure the
366 corresponding native %CR value. Note, %CR is 32-bits even for
367 ppc64. */
368 extern
369 UInt LibVEX_GuestPPC64_get_CR ( /*IN*/const VexGuestPPC64State* vex_state );
372 /* Write the given native %XER value to the supplied
373 VexGuestPPC64State structure. Note, %XER is 32-bits even for
374 ppc64. */
375 extern
376 void LibVEX_GuestPPC64_put_XER ( UInt xer_native,
377 /*OUT*/VexGuestPPC64State* vex_state );
379 /* Extract from the supplied VexGuestPPC64State structure the
380 corresponding native %XER value. Note, %CR is 32-bits even for
381 ppc64. */
382 extern
383 UInt LibVEX_GuestPPC64_get_XER ( /*IN*/const VexGuestPPC64State* vex_state );
385 #endif /* ndef __LIBVEX_PUB_GUEST_PPC64_H */
388 /*---------------------------------------------------------------*/
389 /*--- libvex_guest_ppc64.h ---*/
390 /*---------------------------------------------------------------*/