]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/s390-tdep.c
Update copyright year range in all GDB files
[thirdparty/binutils-gdb.git] / gdb / s390-tdep.c
CommitLineData
d6e58945
PR
1/* Target-dependent code for s390.
2
3666a048 3 Copyright (C) 2001-2021 Free Software Foundation, Inc.
d6e58945
PR
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20#include "defs.h"
21
22#include "arch-utils.h"
23#include "ax-gdb.h"
82ca8957 24#include "dwarf2/frame.h"
d6e58945
PR
25#include "elf/s390.h"
26#include "elf-bfd.h"
27#include "frame-base.h"
28#include "frame-unwind.h"
29#include "gdbarch.h"
30#include "gdbcore.h"
31#include "infrun.h"
32#include "linux-tdep.h"
33#include "objfiles.h"
34#include "osabi.h"
35#include "record-full.h"
36#include "regcache.h"
37#include "reggroups.h"
38#include "s390-tdep.h"
39#include "target-descriptions.h"
40#include "trad-frame.h"
41#include "value.h"
42
c81e8879
PR
43#include "features/s390-linux32.c"
44#include "features/s390x-linux64.c"
45
d6e58945
PR
46/* Holds the current set of options to be passed to the disassembler. */
47static char *s390_disassembler_options;
48
49/* Breakpoints. */
50
51constexpr gdb_byte s390_break_insn[] = { 0x0, 0x1 };
52
53typedef BP_MANIPULATION (s390_break_insn) s390_breakpoint;
54
1022c627
AA
55/* Types. */
56
57/* Implement the gdbarch type alignment method. */
58
59static ULONGEST
60s390_type_align (gdbarch *gdbarch, struct type *t)
61{
62 t = check_typedef (t);
63
64 if (TYPE_LENGTH (t) > 8)
65 {
78134374 66 switch (t->code ())
1022c627
AA
67 {
68 case TYPE_CODE_INT:
69 case TYPE_CODE_RANGE:
70 case TYPE_CODE_FLT:
71 case TYPE_CODE_ENUM:
72 case TYPE_CODE_CHAR:
73 case TYPE_CODE_BOOL:
74 case TYPE_CODE_DECFLOAT:
75 return 8;
76
77 case TYPE_CODE_ARRAY:
bd63c870 78 if (t->is_vector ())
1022c627
AA
79 return 8;
80 break;
81 }
82 }
83 return 0;
84}
85
d6e58945
PR
86/* Decoding S/390 instructions. */
87
88/* Read a single instruction from address AT. */
89
90static int
91s390_readinstruction (bfd_byte instr[], CORE_ADDR at)
92{
93 static int s390_instrlen[] = { 2, 4, 4, 6 };
94 int instrlen;
95
96 if (target_read_memory (at, &instr[0], 2))
97 return -1;
98 instrlen = s390_instrlen[instr[0] >> 6];
99 if (instrlen > 2)
100 {
101 if (target_read_memory (at + 2, &instr[2], instrlen - 2))
102 return -1;
103 }
104 return instrlen;
105}
106
107/* The functions below are for recognizing and decoding S/390
108 instructions of various formats. Each of them checks whether INSN
109 is an instruction of the given format, with the specified opcodes.
110 If it is, it sets the remaining arguments to the values of the
111 instruction's fields, and returns a non-zero value; otherwise, it
112 returns zero.
113
114 These functions' arguments appear in the order they appear in the
115 instruction, not in the machine-language form. So, opcodes always
116 come first, even though they're sometimes scattered around the
117 instructions. And displacements appear before base and extension
118 registers, as they do in the assembly syntax, not at the end, as
119 they do in the machine language.
120
121 Test for RI instruction format. */
122
123static int
124is_ri (bfd_byte *insn, int op1, int op2, unsigned int *r1, int *i2)
125{
126 if (insn[0] == op1 && (insn[1] & 0xf) == op2)
127 {
128 *r1 = (insn[1] >> 4) & 0xf;
129 /* i2 is a 16-bit signed quantity. */
130 *i2 = (((insn[2] << 8) | insn[3]) ^ 0x8000) - 0x8000;
131 return 1;
132 }
133 else
134 return 0;
135}
136
137/* Test for RIL instruction format. See comment on is_ri for details. */
138
139static int
140is_ril (bfd_byte *insn, int op1, int op2,
141 unsigned int *r1, int *i2)
142{
143 if (insn[0] == op1 && (insn[1] & 0xf) == op2)
144 {
145 *r1 = (insn[1] >> 4) & 0xf;
146 /* i2 is a signed quantity. If the host 'int' is 32 bits long,
147 no sign extension is necessary, but we don't want to assume
148 that. */
149 *i2 = (((insn[2] << 24)
150 | (insn[3] << 16)
151 | (insn[4] << 8)
152 | (insn[5])) ^ 0x80000000) - 0x80000000;
153 return 1;
154 }
155 else
156 return 0;
157}
158
159/* Test for RR instruction format. See comment on is_ri for details. */
160
161static int
162is_rr (bfd_byte *insn, int op, unsigned int *r1, unsigned int *r2)
163{
164 if (insn[0] == op)
165 {
166 *r1 = (insn[1] >> 4) & 0xf;
167 *r2 = insn[1] & 0xf;
168 return 1;
169 }
170 else
171 return 0;
172}
173
174/* Test for RRE instruction format. See comment on is_ri for details. */
175
176static int
177is_rre (bfd_byte *insn, int op, unsigned int *r1, unsigned int *r2)
178{
179 if (((insn[0] << 8) | insn[1]) == op)
180 {
181 /* Yes, insn[3]. insn[2] is unused in RRE format. */
182 *r1 = (insn[3] >> 4) & 0xf;
183 *r2 = insn[3] & 0xf;
184 return 1;
185 }
186 else
187 return 0;
188}
189
190/* Test for RS instruction format. See comment on is_ri for details. */
191
192static int
193is_rs (bfd_byte *insn, int op,
194 unsigned int *r1, unsigned int *r3, int *d2, unsigned int *b2)
195{
196 if (insn[0] == op)
197 {
198 *r1 = (insn[1] >> 4) & 0xf;
199 *r3 = insn[1] & 0xf;
200 *b2 = (insn[2] >> 4) & 0xf;
201 *d2 = ((insn[2] & 0xf) << 8) | insn[3];
202 return 1;
203 }
204 else
205 return 0;
206}
207
208/* Test for RSY instruction format. See comment on is_ri for details. */
209
210static int
211is_rsy (bfd_byte *insn, int op1, int op2,
212 unsigned int *r1, unsigned int *r3, int *d2, unsigned int *b2)
213{
214 if (insn[0] == op1
215 && insn[5] == op2)
216 {
217 *r1 = (insn[1] >> 4) & 0xf;
218 *r3 = insn[1] & 0xf;
219 *b2 = (insn[2] >> 4) & 0xf;
220 /* The 'long displacement' is a 20-bit signed integer. */
221 *d2 = ((((insn[2] & 0xf) << 8) | insn[3] | (insn[4] << 12))
222 ^ 0x80000) - 0x80000;
223 return 1;
224 }
225 else
226 return 0;
227}
228
229/* Test for RX instruction format. See comment on is_ri for details. */
230
231static int
232is_rx (bfd_byte *insn, int op,
233 unsigned int *r1, int *d2, unsigned int *x2, unsigned int *b2)
234{
235 if (insn[0] == op)
236 {
237 *r1 = (insn[1] >> 4) & 0xf;
238 *x2 = insn[1] & 0xf;
239 *b2 = (insn[2] >> 4) & 0xf;
240 *d2 = ((insn[2] & 0xf) << 8) | insn[3];
241 return 1;
242 }
243 else
244 return 0;
245}
246
247/* Test for RXY instruction format. See comment on is_ri for details. */
248
249static int
250is_rxy (bfd_byte *insn, int op1, int op2,
251 unsigned int *r1, int *d2, unsigned int *x2, unsigned int *b2)
252{
253 if (insn[0] == op1
254 && insn[5] == op2)
255 {
256 *r1 = (insn[1] >> 4) & 0xf;
257 *x2 = insn[1] & 0xf;
258 *b2 = (insn[2] >> 4) & 0xf;
259 /* The 'long displacement' is a 20-bit signed integer. */
260 *d2 = ((((insn[2] & 0xf) << 8) | insn[3] | (insn[4] << 12))
261 ^ 0x80000) - 0x80000;
262 return 1;
263 }
264 else
265 return 0;
266}
267
268/* A helper for s390_software_single_step, decides if an instruction
269 is a partial-execution instruction that needs to be executed until
270 completion when in record mode. If it is, returns 1 and writes
271 instruction length to a pointer. */
272
273static int
274s390_is_partial_instruction (struct gdbarch *gdbarch, CORE_ADDR loc, int *len)
275{
276 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
277 uint16_t insn;
278
279 insn = read_memory_integer (loc, 2, byte_order);
280
281 switch (insn >> 8)
282 {
283 case 0xa8: /* MVCLE */
284 *len = 4;
285 return 1;
286
287 case 0xeb:
288 {
289 insn = read_memory_integer (loc + 4, 2, byte_order);
290 if ((insn & 0xff) == 0x8e)
291 {
292 /* MVCLU */
293 *len = 6;
294 return 1;
295 }
296 }
297 break;
298 }
299
300 switch (insn)
301 {
302 case 0xb255: /* MVST */
303 case 0xb263: /* CMPSC */
304 case 0xb2a5: /* TRE */
305 case 0xb2a6: /* CU21 */
306 case 0xb2a7: /* CU12 */
307 case 0xb9b0: /* CU14 */
308 case 0xb9b1: /* CU24 */
309 case 0xb9b2: /* CU41 */
310 case 0xb9b3: /* CU42 */
311 case 0xb92a: /* KMF */
312 case 0xb92b: /* KMO */
313 case 0xb92f: /* KMC */
314 case 0xb92d: /* KMCTR */
315 case 0xb92e: /* KM */
316 case 0xb93c: /* PPNO */
317 case 0xb990: /* TRTT */
318 case 0xb991: /* TRTO */
319 case 0xb992: /* TROT */
320 case 0xb993: /* TROO */
321 *len = 4;
322 return 1;
323 }
324
325 return 0;
326}
327
328/* Implement the "software_single_step" gdbarch method, needed to single step
329 through instructions like MVCLE in record mode, to make sure they are
330 executed to completion. Without that, record will save the full length
331 of destination buffer on every iteration, even though the CPU will only
332 process about 4kiB of it each time, leading to O(n**2) memory and time
333 complexity. */
334
335static std::vector<CORE_ADDR>
336s390_software_single_step (struct regcache *regcache)
337{
338 struct gdbarch *gdbarch = regcache->arch ();
339 CORE_ADDR loc = regcache_read_pc (regcache);
340 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
341 int len;
342 uint16_t insn;
343
344 /* Special handling only if recording. */
345 if (!record_full_is_used ())
346 return {};
347
348 /* First, match a partial instruction. */
349 if (!s390_is_partial_instruction (gdbarch, loc, &len))
350 return {};
351
352 loc += len;
353
354 /* Second, look for a branch back to it. */
355 insn = read_memory_integer (loc, 2, byte_order);
356 if (insn != 0xa714) /* BRC with mask 1 */
357 return {};
358
359 insn = read_memory_integer (loc + 2, 2, byte_order);
360 if (insn != (uint16_t) -(len / 2))
361 return {};
362
363 loc += 4;
364
365 /* Found it, step past the whole thing. */
366 return {loc};
367}
368
369/* Displaced stepping. */
370
371/* Return true if INSN is a non-branch RIL-b or RIL-c format
372 instruction. */
373
374static int
375is_non_branch_ril (gdb_byte *insn)
376{
377 gdb_byte op1 = insn[0];
378
379 if (op1 == 0xc4)
380 {
381 gdb_byte op2 = insn[1] & 0x0f;
382
383 switch (op2)
384 {
385 case 0x02: /* llhrl */
386 case 0x04: /* lghrl */
387 case 0x05: /* lhrl */
388 case 0x06: /* llghrl */
389 case 0x07: /* sthrl */
390 case 0x08: /* lgrl */
391 case 0x0b: /* stgrl */
392 case 0x0c: /* lgfrl */
393 case 0x0d: /* lrl */
394 case 0x0e: /* llgfrl */
395 case 0x0f: /* strl */
396 return 1;
397 }
398 }
399 else if (op1 == 0xc6)
400 {
401 gdb_byte op2 = insn[1] & 0x0f;
402
403 switch (op2)
404 {
405 case 0x00: /* exrl */
406 case 0x02: /* pfdrl */
407 case 0x04: /* cghrl */
408 case 0x05: /* chrl */
409 case 0x06: /* clghrl */
410 case 0x07: /* clhrl */
411 case 0x08: /* cgrl */
412 case 0x0a: /* clgrl */
413 case 0x0c: /* cgfrl */
414 case 0x0d: /* crl */
415 case 0x0e: /* clgfrl */
416 case 0x0f: /* clrl */
417 return 1;
418 }
419 }
420
421 return 0;
422}
423
1152d984
SM
424typedef buf_displaced_step_copy_insn_closure
425 s390_displaced_step_copy_insn_closure;
d6e58945
PR
426
427/* Implementation of gdbarch_displaced_step_copy_insn. */
428
1152d984 429static displaced_step_copy_insn_closure_up
d6e58945
PR
430s390_displaced_step_copy_insn (struct gdbarch *gdbarch,
431 CORE_ADDR from, CORE_ADDR to,
432 struct regcache *regs)
433{
434 size_t len = gdbarch_max_insn_length (gdbarch);
1152d984
SM
435 std::unique_ptr<s390_displaced_step_copy_insn_closure> closure
436 (new s390_displaced_step_copy_insn_closure (len));
d6e58945
PR
437 gdb_byte *buf = closure->buf.data ();
438
439 read_memory (from, buf, len);
440
441 /* Adjust the displacement field of PC-relative RIL instructions,
442 except branches. The latter are handled in the fixup hook. */
443 if (is_non_branch_ril (buf))
444 {
445 LONGEST offset;
446
447 offset = extract_signed_integer (buf + 2, 4, BFD_ENDIAN_BIG);
448 offset = (from - to + offset * 2) / 2;
449
450 /* If the instruction is too far from the jump pad, punt. This
451 will usually happen with instructions in shared libraries.
452 We could probably support these by rewriting them to be
453 absolute or fully emulating them. */
454 if (offset < INT32_MIN || offset > INT32_MAX)
455 {
456 /* Let the core fall back to stepping over the breakpoint
457 in-line. */
136821d9
SM
458 displaced_debug_printf ("can't displaced step RIL instruction: offset "
459 "%s out of range", plongest (offset));
d6e58945
PR
460
461 return NULL;
462 }
463
464 store_signed_integer (buf + 2, 4, BFD_ENDIAN_BIG, offset);
465 }
466
467 write_memory (to, buf, len);
468
136821d9
SM
469 displaced_debug_printf ("copy %s->%s: %s",
470 paddress (gdbarch, from), paddress (gdbarch, to),
471 displaced_step_dump_bytes (buf, len).c_str ());
d6e58945 472
6d0cf446 473 /* This is a work around for a problem with g++ 4.8. */
1152d984 474 return displaced_step_copy_insn_closure_up (closure.release ());
d6e58945
PR
475}
476
477/* Fix up the state of registers and memory after having single-stepped
478 a displaced instruction. */
479
480static void
481s390_displaced_step_fixup (struct gdbarch *gdbarch,
1152d984 482 displaced_step_copy_insn_closure *closure_,
d6e58945
PR
483 CORE_ADDR from, CORE_ADDR to,
484 struct regcache *regs)
485{
486 /* Our closure is a copy of the instruction. */
1152d984
SM
487 s390_displaced_step_copy_insn_closure *closure
488 = (s390_displaced_step_copy_insn_closure *) closure_;
d6e58945
PR
489 gdb_byte *insn = closure->buf.data ();
490 static int s390_instrlen[] = { 2, 4, 4, 6 };
491 int insnlen = s390_instrlen[insn[0] >> 6];
492
493 /* Fields for various kinds of instructions. */
494 unsigned int b2, r1, r2, x2, r3;
495 int i2, d2;
496
497 /* Get current PC and addressing mode bit. */
498 CORE_ADDR pc = regcache_read_pc (regs);
499 ULONGEST amode = 0;
500
501 if (register_size (gdbarch, S390_PSWA_REGNUM) == 4)
502 {
503 regcache_cooked_read_unsigned (regs, S390_PSWA_REGNUM, &amode);
504 amode &= 0x80000000;
505 }
506
136821d9
SM
507 displaced_debug_printf ("(s390) fixup (%s, %s) pc %s len %d amode 0x%x",
508 paddress (gdbarch, from), paddress (gdbarch, to),
509 paddress (gdbarch, pc), insnlen, (int) amode);
d6e58945
PR
510
511 /* Handle absolute branch and save instructions. */
8ba83e91
TV
512 int op_basr_p = is_rr (insn, op_basr, &r1, &r2);
513 if (op_basr_p
d6e58945
PR
514 || is_rx (insn, op_bas, &r1, &d2, &x2, &b2))
515 {
516 /* Recompute saved return address in R1. */
517 regcache_cooked_write_unsigned (regs, S390_R0_REGNUM + r1,
518 amode | (from + insnlen));
5c1eda30 519 /* Update PC iff the instruction doesn't actually branch. */
8ba83e91 520 if (op_basr_p && r2 == 0)
5c1eda30 521 regcache_write_pc (regs, from + insnlen);
d6e58945
PR
522 }
523
524 /* Handle absolute branch instructions. */
525 else if (is_rr (insn, op_bcr, &r1, &r2)
526 || is_rx (insn, op_bc, &r1, &d2, &x2, &b2)
527 || is_rr (insn, op_bctr, &r1, &r2)
528 || is_rre (insn, op_bctgr, &r1, &r2)
529 || is_rx (insn, op_bct, &r1, &d2, &x2, &b2)
530 || is_rxy (insn, op1_bctg, op2_brctg, &r1, &d2, &x2, &b2)
531 || is_rs (insn, op_bxh, &r1, &r3, &d2, &b2)
532 || is_rsy (insn, op1_bxhg, op2_bxhg, &r1, &r3, &d2, &b2)
533 || is_rs (insn, op_bxle, &r1, &r3, &d2, &b2)
534 || is_rsy (insn, op1_bxleg, op2_bxleg, &r1, &r3, &d2, &b2))
535 {
536 /* Update PC iff branch was *not* taken. */
537 if (pc == to + insnlen)
538 regcache_write_pc (regs, from + insnlen);
539 }
540
541 /* Handle PC-relative branch and save instructions. */
542 else if (is_ri (insn, op1_bras, op2_bras, &r1, &i2)
543 || is_ril (insn, op1_brasl, op2_brasl, &r1, &i2))
544 {
545 /* Update PC. */
546 regcache_write_pc (regs, pc - to + from);
547 /* Recompute saved return address in R1. */
548 regcache_cooked_write_unsigned (regs, S390_R0_REGNUM + r1,
549 amode | (from + insnlen));
550 }
551
552 /* Handle LOAD ADDRESS RELATIVE LONG. */
553 else if (is_ril (insn, op1_larl, op2_larl, &r1, &i2))
554 {
555 /* Update PC. */
556 regcache_write_pc (regs, from + insnlen);
557 /* Recompute output address in R1. */
558 regcache_cooked_write_unsigned (regs, S390_R0_REGNUM + r1,
559 amode | (from + i2 * 2));
560 }
561
562 /* If we executed a breakpoint instruction, point PC right back at it. */
563 else if (insn[0] == 0x0 && insn[1] == 0x1)
564 regcache_write_pc (regs, from);
565
566 /* For any other insn, adjust PC by negated displacement. PC then
567 points right after the original instruction, except for PC-relative
568 branches, where it points to the adjusted branch target. */
569 else
570 regcache_write_pc (regs, pc - to + from);
571
136821d9
SM
572 displaced_debug_printf ("(s390) pc is now %s",
573 paddress (gdbarch, regcache_read_pc (regs)));
d6e58945
PR
574}
575
576/* Implement displaced_step_hw_singlestep gdbarch method. */
577
07fbbd01 578static bool
40a53766 579s390_displaced_step_hw_singlestep (struct gdbarch *gdbarch)
d6e58945 580{
07fbbd01 581 return true;
d6e58945
PR
582}
583
584/* Prologue analysis. */
585
586struct s390_prologue_data {
587
588 /* The stack. */
589 struct pv_area *stack;
590
591 /* The size and byte-order of a GPR or FPR. */
592 int gpr_size;
593 int fpr_size;
594 enum bfd_endian byte_order;
595
596 /* The general-purpose registers. */
597 pv_t gpr[S390_NUM_GPRS];
598
599 /* The floating-point registers. */
600 pv_t fpr[S390_NUM_FPRS];
601
602 /* The offset relative to the CFA where the incoming GPR N was saved
603 by the function prologue. 0 if not saved or unknown. */
604 int gpr_slot[S390_NUM_GPRS];
605
606 /* Likewise for FPRs. */
607 int fpr_slot[S390_NUM_FPRS];
608
609 /* Nonzero if the backchain was saved. This is assumed to be the
610 case when the incoming SP is saved at the current SP location. */
611 int back_chain_saved_p;
612};
613
614/* Return the effective address for an X-style instruction, like:
615
616 L R1, D2(X2, B2)
617
618 Here, X2 and B2 are registers, and D2 is a signed 20-bit
619 constant; the effective address is the sum of all three. If either
620 X2 or B2 are zero, then it doesn't contribute to the sum --- this
621 means that r0 can't be used as either X2 or B2. */
622
623static pv_t
624s390_addr (struct s390_prologue_data *data,
625 int d2, unsigned int x2, unsigned int b2)
626{
627 pv_t result;
628
629 result = pv_constant (d2);
630 if (x2)
631 result = pv_add (result, data->gpr[x2]);
632 if (b2)
633 result = pv_add (result, data->gpr[b2]);
634
635 return result;
636}
637
638/* Do a SIZE-byte store of VALUE to D2(X2,B2). */
639
640static void
641s390_store (struct s390_prologue_data *data,
642 int d2, unsigned int x2, unsigned int b2, CORE_ADDR size,
643 pv_t value)
644{
645 pv_t addr = s390_addr (data, d2, x2, b2);
646 pv_t offset;
647
648 /* Check whether we are storing the backchain. */
649 offset = pv_subtract (data->gpr[S390_SP_REGNUM - S390_R0_REGNUM], addr);
650
651 if (pv_is_constant (offset) && offset.k == 0)
652 if (size == data->gpr_size
653 && pv_is_register_k (value, S390_SP_REGNUM, 0))
654 {
655 data->back_chain_saved_p = 1;
656 return;
657 }
658
659 /* Check whether we are storing a register into the stack. */
660 if (!data->stack->store_would_trash (addr))
661 data->stack->store (addr, size, value);
662
663 /* Note: If this is some store we cannot identify, you might think we
664 should forget our cached values, as any of those might have been hit.
665
666 However, we make the assumption that the register save areas are only
667 ever stored to once in any given function, and we do recognize these
668 stores. Thus every store we cannot recognize does not hit our data. */
669}
670
671/* Do a SIZE-byte load from D2(X2,B2). */
672
673static pv_t
674s390_load (struct s390_prologue_data *data,
675 int d2, unsigned int x2, unsigned int b2, CORE_ADDR size)
676
677{
678 pv_t addr = s390_addr (data, d2, x2, b2);
679
680 /* If it's a load from an in-line constant pool, then we can
681 simulate that, under the assumption that the code isn't
682 going to change between the time the processor actually
683 executed it creating the current frame, and the time when
684 we're analyzing the code to unwind past that frame. */
685 if (pv_is_constant (addr))
686 {
687 struct target_section *secp;
8b88a78e 688 secp = target_section_by_addr (current_top_target (), addr.k);
d6e58945 689 if (secp != NULL
fd361982 690 && (bfd_section_flags (secp->the_bfd_section) & SEC_READONLY))
d6e58945
PR
691 return pv_constant (read_memory_integer (addr.k, size,
692 data->byte_order));
693 }
694
695 /* Check whether we are accessing one of our save slots. */
696 return data->stack->fetch (addr, size);
697}
698
699/* Function for finding saved registers in a 'struct pv_area'; we pass
700 this to pv_area::scan.
701
702 If VALUE is a saved register, ADDR says it was saved at a constant
703 offset from the frame base, and SIZE indicates that the whole
704 register was saved, record its offset in the reg_offset table in
705 PROLOGUE_UNTYPED. */
706
707static void
708s390_check_for_saved (void *data_untyped, pv_t addr,
709 CORE_ADDR size, pv_t value)
710{
711 struct s390_prologue_data *data = (struct s390_prologue_data *) data_untyped;
712 int i, offset;
713
714 if (!pv_is_register (addr, S390_SP_REGNUM))
715 return;
716
717 offset = 16 * data->gpr_size + 32 - addr.k;
718
719 /* If we are storing the original value of a register, we want to
720 record the CFA offset. If the same register is stored multiple
721 times, the stack slot with the highest address counts. */
722
723 for (i = 0; i < S390_NUM_GPRS; i++)
724 if (size == data->gpr_size
725 && pv_is_register_k (value, S390_R0_REGNUM + i, 0))
726 if (data->gpr_slot[i] == 0
727 || data->gpr_slot[i] > offset)
728 {
729 data->gpr_slot[i] = offset;
730 return;
731 }
732
733 for (i = 0; i < S390_NUM_FPRS; i++)
734 if (size == data->fpr_size
735 && pv_is_register_k (value, S390_F0_REGNUM + i, 0))
736 if (data->fpr_slot[i] == 0
737 || data->fpr_slot[i] > offset)
738 {
739 data->fpr_slot[i] = offset;
740 return;
741 }
742}
743
744/* Analyze the prologue of the function starting at START_PC, continuing at
745 most until CURRENT_PC. Initialize DATA to hold all information we find
746 out about the state of the registers and stack slots. Return the address
747 of the instruction after the last one that changed the SP, FP, or back
748 chain; or zero on error. */
749
750static CORE_ADDR
751s390_analyze_prologue (struct gdbarch *gdbarch,
752 CORE_ADDR start_pc,
753 CORE_ADDR current_pc,
754 struct s390_prologue_data *data)
755{
756 int word_size = gdbarch_ptr_bit (gdbarch) / 8;
757
758 /* Our return value:
759 The address of the instruction after the last one that changed
760 the SP, FP, or back chain; zero if we got an error trying to
761 read memory. */
762 CORE_ADDR result = start_pc;
763
764 /* The current PC for our abstract interpretation. */
765 CORE_ADDR pc;
766
767 /* The address of the next instruction after that. */
768 CORE_ADDR next_pc;
769
770 pv_area stack (S390_SP_REGNUM, gdbarch_addr_bit (gdbarch));
771 scoped_restore restore_stack = make_scoped_restore (&data->stack, &stack);
772
773 /* Set up everything's initial value. */
774 {
775 int i;
776
777 /* For the purpose of prologue tracking, we consider the GPR size to
778 be equal to the ABI word size, even if it is actually larger
779 (i.e. when running a 32-bit binary under a 64-bit kernel). */
780 data->gpr_size = word_size;
781 data->fpr_size = 8;
782 data->byte_order = gdbarch_byte_order (gdbarch);
783
784 for (i = 0; i < S390_NUM_GPRS; i++)
785 data->gpr[i] = pv_register (S390_R0_REGNUM + i, 0);
786
787 for (i = 0; i < S390_NUM_FPRS; i++)
788 data->fpr[i] = pv_register (S390_F0_REGNUM + i, 0);
789
790 for (i = 0; i < S390_NUM_GPRS; i++)
791 data->gpr_slot[i] = 0;
792
793 for (i = 0; i < S390_NUM_FPRS; i++)
794 data->fpr_slot[i] = 0;
795
796 data->back_chain_saved_p = 0;
797 }
798
799 /* Start interpreting instructions, until we hit the frame's
800 current PC or the first branch instruction. */
801 for (pc = start_pc; pc > 0 && pc < current_pc; pc = next_pc)
802 {
803 bfd_byte insn[S390_MAX_INSTR_SIZE];
804 int insn_len = s390_readinstruction (insn, pc);
805
806 bfd_byte dummy[S390_MAX_INSTR_SIZE] = { 0 };
807 bfd_byte *insn32 = word_size == 4 ? insn : dummy;
808 bfd_byte *insn64 = word_size == 8 ? insn : dummy;
809
810 /* Fields for various kinds of instructions. */
811 unsigned int b2, r1, r2, x2, r3;
812 int i2, d2;
813
814 /* The values of SP and FP before this instruction,
815 for detecting instructions that change them. */
816 pv_t pre_insn_sp, pre_insn_fp;
817 /* Likewise for the flag whether the back chain was saved. */
818 int pre_insn_back_chain_saved_p;
819
820 /* If we got an error trying to read the instruction, report it. */
821 if (insn_len < 0)
822 {
823 result = 0;
824 break;
825 }
826
827 next_pc = pc + insn_len;
828
829 pre_insn_sp = data->gpr[S390_SP_REGNUM - S390_R0_REGNUM];
830 pre_insn_fp = data->gpr[S390_FRAME_REGNUM - S390_R0_REGNUM];
831 pre_insn_back_chain_saved_p = data->back_chain_saved_p;
832
833 /* LHI r1, i2 --- load halfword immediate. */
834 /* LGHI r1, i2 --- load halfword immediate (64-bit version). */
835 /* LGFI r1, i2 --- load fullword immediate. */
836 if (is_ri (insn32, op1_lhi, op2_lhi, &r1, &i2)
837 || is_ri (insn64, op1_lghi, op2_lghi, &r1, &i2)
838 || is_ril (insn, op1_lgfi, op2_lgfi, &r1, &i2))
839 data->gpr[r1] = pv_constant (i2);
840
841 /* LR r1, r2 --- load from register. */
842 /* LGR r1, r2 --- load from register (64-bit version). */
843 else if (is_rr (insn32, op_lr, &r1, &r2)
844 || is_rre (insn64, op_lgr, &r1, &r2))
845 data->gpr[r1] = data->gpr[r2];
846
847 /* L r1, d2(x2, b2) --- load. */
848 /* LY r1, d2(x2, b2) --- load (long-displacement version). */
849 /* LG r1, d2(x2, b2) --- load (64-bit version). */
850 else if (is_rx (insn32, op_l, &r1, &d2, &x2, &b2)
851 || is_rxy (insn32, op1_ly, op2_ly, &r1, &d2, &x2, &b2)
852 || is_rxy (insn64, op1_lg, op2_lg, &r1, &d2, &x2, &b2))
853 data->gpr[r1] = s390_load (data, d2, x2, b2, data->gpr_size);
854
855 /* ST r1, d2(x2, b2) --- store. */
856 /* STY r1, d2(x2, b2) --- store (long-displacement version). */
857 /* STG r1, d2(x2, b2) --- store (64-bit version). */
858 else if (is_rx (insn32, op_st, &r1, &d2, &x2, &b2)
859 || is_rxy (insn32, op1_sty, op2_sty, &r1, &d2, &x2, &b2)
860 || is_rxy (insn64, op1_stg, op2_stg, &r1, &d2, &x2, &b2))
861 s390_store (data, d2, x2, b2, data->gpr_size, data->gpr[r1]);
862
863 /* STD r1, d2(x2,b2) --- store floating-point register. */
864 else if (is_rx (insn, op_std, &r1, &d2, &x2, &b2))
865 s390_store (data, d2, x2, b2, data->fpr_size, data->fpr[r1]);
866
867 /* STM r1, r3, d2(b2) --- store multiple. */
868 /* STMY r1, r3, d2(b2) --- store multiple (long-displacement
869 version). */
870 /* STMG r1, r3, d2(b2) --- store multiple (64-bit version). */
871 else if (is_rs (insn32, op_stm, &r1, &r3, &d2, &b2)
872 || is_rsy (insn32, op1_stmy, op2_stmy, &r1, &r3, &d2, &b2)
873 || is_rsy (insn64, op1_stmg, op2_stmg, &r1, &r3, &d2, &b2))
874 {
875 for (; r1 <= r3; r1++, d2 += data->gpr_size)
876 s390_store (data, d2, 0, b2, data->gpr_size, data->gpr[r1]);
877 }
878
879 /* AHI r1, i2 --- add halfword immediate. */
880 /* AGHI r1, i2 --- add halfword immediate (64-bit version). */
881 /* AFI r1, i2 --- add fullword immediate. */
882 /* AGFI r1, i2 --- add fullword immediate (64-bit version). */
883 else if (is_ri (insn32, op1_ahi, op2_ahi, &r1, &i2)
884 || is_ri (insn64, op1_aghi, op2_aghi, &r1, &i2)
885 || is_ril (insn32, op1_afi, op2_afi, &r1, &i2)
886 || is_ril (insn64, op1_agfi, op2_agfi, &r1, &i2))
887 data->gpr[r1] = pv_add_constant (data->gpr[r1], i2);
888
889 /* ALFI r1, i2 --- add logical immediate. */
890 /* ALGFI r1, i2 --- add logical immediate (64-bit version). */
891 else if (is_ril (insn32, op1_alfi, op2_alfi, &r1, &i2)
892 || is_ril (insn64, op1_algfi, op2_algfi, &r1, &i2))
893 data->gpr[r1] = pv_add_constant (data->gpr[r1],
894 (CORE_ADDR)i2 & 0xffffffff);
895
896 /* AR r1, r2 -- add register. */
897 /* AGR r1, r2 -- add register (64-bit version). */
898 else if (is_rr (insn32, op_ar, &r1, &r2)
899 || is_rre (insn64, op_agr, &r1, &r2))
900 data->gpr[r1] = pv_add (data->gpr[r1], data->gpr[r2]);
901
902 /* A r1, d2(x2, b2) -- add. */
903 /* AY r1, d2(x2, b2) -- add (long-displacement version). */
904 /* AG r1, d2(x2, b2) -- add (64-bit version). */
905 else if (is_rx (insn32, op_a, &r1, &d2, &x2, &b2)
906 || is_rxy (insn32, op1_ay, op2_ay, &r1, &d2, &x2, &b2)
907 || is_rxy (insn64, op1_ag, op2_ag, &r1, &d2, &x2, &b2))
908 data->gpr[r1] = pv_add (data->gpr[r1],
909 s390_load (data, d2, x2, b2, data->gpr_size));
910
911 /* SLFI r1, i2 --- subtract logical immediate. */
912 /* SLGFI r1, i2 --- subtract logical immediate (64-bit version). */
913 else if (is_ril (insn32, op1_slfi, op2_slfi, &r1, &i2)
914 || is_ril (insn64, op1_slgfi, op2_slgfi, &r1, &i2))
915 data->gpr[r1] = pv_add_constant (data->gpr[r1],
916 -((CORE_ADDR)i2 & 0xffffffff));
917
918 /* SR r1, r2 -- subtract register. */
919 /* SGR r1, r2 -- subtract register (64-bit version). */
920 else if (is_rr (insn32, op_sr, &r1, &r2)
921 || is_rre (insn64, op_sgr, &r1, &r2))
922 data->gpr[r1] = pv_subtract (data->gpr[r1], data->gpr[r2]);
923
924 /* S r1, d2(x2, b2) -- subtract. */
925 /* SY r1, d2(x2, b2) -- subtract (long-displacement version). */
926 /* SG r1, d2(x2, b2) -- subtract (64-bit version). */
927 else if (is_rx (insn32, op_s, &r1, &d2, &x2, &b2)
928 || is_rxy (insn32, op1_sy, op2_sy, &r1, &d2, &x2, &b2)
929 || is_rxy (insn64, op1_sg, op2_sg, &r1, &d2, &x2, &b2))
930 data->gpr[r1] = pv_subtract (data->gpr[r1],
931 s390_load (data, d2, x2, b2, data->gpr_size));
932
933 /* LA r1, d2(x2, b2) --- load address. */
934 /* LAY r1, d2(x2, b2) --- load address (long-displacement version). */
935 else if (is_rx (insn, op_la, &r1, &d2, &x2, &b2)
936 || is_rxy (insn, op1_lay, op2_lay, &r1, &d2, &x2, &b2))
937 data->gpr[r1] = s390_addr (data, d2, x2, b2);
938
939 /* LARL r1, i2 --- load address relative long. */
940 else if (is_ril (insn, op1_larl, op2_larl, &r1, &i2))
941 data->gpr[r1] = pv_constant (pc + i2 * 2);
942
943 /* BASR r1, 0 --- branch and save.
944 Since r2 is zero, this saves the PC in r1, but doesn't branch. */
945 else if (is_rr (insn, op_basr, &r1, &r2)
946 && r2 == 0)
947 data->gpr[r1] = pv_constant (next_pc);
948
949 /* BRAS r1, i2 --- branch relative and save. */
950 else if (is_ri (insn, op1_bras, op2_bras, &r1, &i2))
951 {
952 data->gpr[r1] = pv_constant (next_pc);
953 next_pc = pc + i2 * 2;
954
955 /* We'd better not interpret any backward branches. We'll
956 never terminate. */
957 if (next_pc <= pc)
958 break;
959 }
960
961 /* BRC/BRCL -- branch relative on condition. Ignore "branch
962 never", branch to following instruction, and "conditional
963 trap" (BRC +2). Otherwise terminate search. */
964 else if (is_ri (insn, op1_brc, op2_brc, &r1, &i2))
965 {
966 if (r1 != 0 && i2 != 1 && i2 != 2)
967 break;
968 }
969 else if (is_ril (insn, op1_brcl, op2_brcl, &r1, &i2))
970 {
971 if (r1 != 0 && i2 != 3)
972 break;
973 }
974
975 /* Terminate search when hitting any other branch instruction. */
976 else if (is_rr (insn, op_basr, &r1, &r2)
977 || is_rx (insn, op_bas, &r1, &d2, &x2, &b2)
978 || is_rr (insn, op_bcr, &r1, &r2)
979 || is_rx (insn, op_bc, &r1, &d2, &x2, &b2)
980 || is_ril (insn, op1_brasl, op2_brasl, &r2, &i2))
981 break;
982
983 else
984 {
985 /* An instruction we don't know how to simulate. The only
986 safe thing to do would be to set every value we're tracking
987 to 'unknown'. Instead, we'll be optimistic: we assume that
988 we *can* interpret every instruction that the compiler uses
989 to manipulate any of the data we're interested in here --
990 then we can just ignore anything else. */
991 }
992
993 /* Record the address after the last instruction that changed
994 the FP, SP, or backlink. Ignore instructions that changed
995 them back to their original values --- those are probably
996 restore instructions. (The back chain is never restored,
997 just popped.) */
998 {
999 pv_t sp = data->gpr[S390_SP_REGNUM - S390_R0_REGNUM];
1000 pv_t fp = data->gpr[S390_FRAME_REGNUM - S390_R0_REGNUM];
1001
1002 if ((! pv_is_identical (pre_insn_sp, sp)
1003 && ! pv_is_register_k (sp, S390_SP_REGNUM, 0)
1004 && sp.kind != pvk_unknown)
1005 || (! pv_is_identical (pre_insn_fp, fp)
1006 && ! pv_is_register_k (fp, S390_FRAME_REGNUM, 0)
1007 && fp.kind != pvk_unknown)
1008 || pre_insn_back_chain_saved_p != data->back_chain_saved_p)
1009 result = next_pc;
1010 }
1011 }
1012
1013 /* Record where all the registers were saved. */
1014 data->stack->scan (s390_check_for_saved, data);
1015
1016 return result;
1017}
1018
1019/* Advance PC across any function entry prologue instructions to reach
1020 some "real" code. */
1021
1022static CORE_ADDR
1023s390_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
1024{
1025 struct s390_prologue_data data;
1026 CORE_ADDR skip_pc, func_addr;
1027
1028 if (find_pc_partial_function (pc, NULL, &func_addr, NULL))
1029 {
1030 CORE_ADDR post_prologue_pc
1031 = skip_prologue_using_sal (gdbarch, func_addr);
1032 if (post_prologue_pc != 0)
1033 return std::max (pc, post_prologue_pc);
1034 }
1035
1036 skip_pc = s390_analyze_prologue (gdbarch, pc, (CORE_ADDR)-1, &data);
1037 return skip_pc ? skip_pc : pc;
1038}
1039
1040/* Register handling. */
1041
1042/* ABI call-saved register information. */
1043
1044static int
1045s390_register_call_saved (struct gdbarch *gdbarch, int regnum)
1046{
1047 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
1048
1049 switch (tdep->abi)
1050 {
1051 case ABI_LINUX_S390:
1052 if ((regnum >= S390_R6_REGNUM && regnum <= S390_R15_REGNUM)
1053 || regnum == S390_F4_REGNUM || regnum == S390_F6_REGNUM
1054 || regnum == S390_A0_REGNUM)
1055 return 1;
1056
1057 break;
1058
1059 case ABI_LINUX_ZSERIES:
1060 if ((regnum >= S390_R6_REGNUM && regnum <= S390_R15_REGNUM)
1061 || (regnum >= S390_F8_REGNUM && regnum <= S390_F15_REGNUM)
1062 || (regnum >= S390_A0_REGNUM && regnum <= S390_A1_REGNUM))
1063 return 1;
1064
1065 break;
1066 }
1067
1068 return 0;
1069}
1070
1071/* The "guess_tracepoint_registers" gdbarch method. */
1072
1073static void
1074s390_guess_tracepoint_registers (struct gdbarch *gdbarch,
1075 struct regcache *regcache,
1076 CORE_ADDR addr)
1077{
1078 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
1079 int sz = register_size (gdbarch, S390_PSWA_REGNUM);
1080 gdb_byte *reg = (gdb_byte *) alloca (sz);
1081 ULONGEST pswm, pswa;
1082
1083 /* Set PSWA from the location and a default PSWM (the only part we're
1084 unlikely to get right is the CC). */
1085 if (tdep->abi == ABI_LINUX_S390)
1086 {
1087 /* 31-bit PSWA needs high bit set (it's very unlikely the target
1088 was in 24-bit mode). */
1089 pswa = addr | 0x80000000UL;
1090 pswm = 0x070d0000UL;
1091 }
1092 else
1093 {
1094 pswa = addr;
1095 pswm = 0x0705000180000000ULL;
1096 }
1097
1098 store_unsigned_integer (reg, sz, gdbarch_byte_order (gdbarch), pswa);
73e1c03f 1099 regcache->raw_supply (S390_PSWA_REGNUM, reg);
d6e58945
PR
1100
1101 store_unsigned_integer (reg, sz, gdbarch_byte_order (gdbarch), pswm);
73e1c03f 1102 regcache->raw_supply (S390_PSWM_REGNUM, reg);
d6e58945
PR
1103}
1104
1105/* Return the name of register REGNO. Return the empty string for
1106 registers that shouldn't be visible. */
1107
1108static const char *
1109s390_register_name (struct gdbarch *gdbarch, int regnum)
1110{
1111 if (regnum >= S390_V0_LOWER_REGNUM
1112 && regnum <= S390_V15_LOWER_REGNUM)
1113 return "";
1114 return tdesc_register_name (gdbarch, regnum);
1115}
1116
1117/* DWARF Register Mapping. */
1118
1119static const short s390_dwarf_regmap[] =
1120{
1121 /* 0-15: General Purpose Registers. */
1122 S390_R0_REGNUM, S390_R1_REGNUM, S390_R2_REGNUM, S390_R3_REGNUM,
1123 S390_R4_REGNUM, S390_R5_REGNUM, S390_R6_REGNUM, S390_R7_REGNUM,
1124 S390_R8_REGNUM, S390_R9_REGNUM, S390_R10_REGNUM, S390_R11_REGNUM,
1125 S390_R12_REGNUM, S390_R13_REGNUM, S390_R14_REGNUM, S390_R15_REGNUM,
1126
1127 /* 16-31: Floating Point Registers / Vector Registers 0-15. */
1128 S390_F0_REGNUM, S390_F2_REGNUM, S390_F4_REGNUM, S390_F6_REGNUM,
1129 S390_F1_REGNUM, S390_F3_REGNUM, S390_F5_REGNUM, S390_F7_REGNUM,
1130 S390_F8_REGNUM, S390_F10_REGNUM, S390_F12_REGNUM, S390_F14_REGNUM,
1131 S390_F9_REGNUM, S390_F11_REGNUM, S390_F13_REGNUM, S390_F15_REGNUM,
1132
1133 /* 32-47: Control Registers (not mapped). */
1134 -1, -1, -1, -1, -1, -1, -1, -1,
1135 -1, -1, -1, -1, -1, -1, -1, -1,
1136
1137 /* 48-63: Access Registers. */
1138 S390_A0_REGNUM, S390_A1_REGNUM, S390_A2_REGNUM, S390_A3_REGNUM,
1139 S390_A4_REGNUM, S390_A5_REGNUM, S390_A6_REGNUM, S390_A7_REGNUM,
1140 S390_A8_REGNUM, S390_A9_REGNUM, S390_A10_REGNUM, S390_A11_REGNUM,
1141 S390_A12_REGNUM, S390_A13_REGNUM, S390_A14_REGNUM, S390_A15_REGNUM,
1142
1143 /* 64-65: Program Status Word. */
1144 S390_PSWM_REGNUM,
1145 S390_PSWA_REGNUM,
1146
1147 /* 66-67: Reserved. */
1148 -1, -1,
1149
1150 /* 68-83: Vector Registers 16-31. */
1151 S390_V16_REGNUM, S390_V18_REGNUM, S390_V20_REGNUM, S390_V22_REGNUM,
1152 S390_V17_REGNUM, S390_V19_REGNUM, S390_V21_REGNUM, S390_V23_REGNUM,
1153 S390_V24_REGNUM, S390_V26_REGNUM, S390_V28_REGNUM, S390_V30_REGNUM,
1154 S390_V25_REGNUM, S390_V27_REGNUM, S390_V29_REGNUM, S390_V31_REGNUM,
1155
1156 /* End of "official" DWARF registers. The remainder of the map is
1157 for GDB internal use only. */
1158
1159 /* GPR Lower Half Access. */
1160 S390_R0_REGNUM, S390_R1_REGNUM, S390_R2_REGNUM, S390_R3_REGNUM,
1161 S390_R4_REGNUM, S390_R5_REGNUM, S390_R6_REGNUM, S390_R7_REGNUM,
1162 S390_R8_REGNUM, S390_R9_REGNUM, S390_R10_REGNUM, S390_R11_REGNUM,
1163 S390_R12_REGNUM, S390_R13_REGNUM, S390_R14_REGNUM, S390_R15_REGNUM,
1164};
1165
1166enum { s390_dwarf_reg_r0l = ARRAY_SIZE (s390_dwarf_regmap) - 16 };
1167
1168/* Convert DWARF register number REG to the appropriate register
1169 number used by GDB. */
1170
1171static int
1172s390_dwarf_reg_to_regnum (struct gdbarch *gdbarch, int reg)
1173{
1174 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
1175 int gdb_reg = -1;
1176
1177 /* In a 32-on-64 debug scenario, debug info refers to the full
1178 64-bit GPRs. Note that call frame information still refers to
1179 the 32-bit lower halves, because s390_adjust_frame_regnum uses
1180 special register numbers to access GPRs. */
1181 if (tdep->gpr_full_regnum != -1 && reg >= 0 && reg < 16)
1182 return tdep->gpr_full_regnum + reg;
1183
1184 if (reg >= 0 && reg < ARRAY_SIZE (s390_dwarf_regmap))
1185 gdb_reg = s390_dwarf_regmap[reg];
1186
1187 if (tdep->v0_full_regnum == -1)
1188 {
1189 if (gdb_reg >= S390_V16_REGNUM && gdb_reg <= S390_V31_REGNUM)
1190 gdb_reg = -1;
1191 }
1192 else
1193 {
1194 if (gdb_reg >= S390_F0_REGNUM && gdb_reg <= S390_F15_REGNUM)
1195 gdb_reg = gdb_reg - S390_F0_REGNUM + tdep->v0_full_regnum;
1196 }
1197
1198 return gdb_reg;
1199}
1200
1201/* Pseudo registers. */
1202
1203/* Check whether REGNUM indicates a coupled general purpose register.
1204 These pseudo-registers are composed of two adjacent gprs. */
1205
1206static int
1207regnum_is_gpr_full (struct gdbarch_tdep *tdep, int regnum)
1208{
1209 return (tdep->gpr_full_regnum != -1
1210 && regnum >= tdep->gpr_full_regnum
1211 && regnum <= tdep->gpr_full_regnum + 15);
1212}
1213
1214/* Check whether REGNUM indicates a full vector register (v0-v15).
1215 These pseudo-registers are composed of f0-f15 and v0l-v15l. */
1216
1217static int
1218regnum_is_vxr_full (struct gdbarch_tdep *tdep, int regnum)
1219{
1220 return (tdep->v0_full_regnum != -1
1221 && regnum >= tdep->v0_full_regnum
1222 && regnum <= tdep->v0_full_regnum + 15);
1223}
1224
1225/* 'float' values are stored in the upper half of floating-point
1226 registers, even though we are otherwise a big-endian platform. The
1227 same applies to a 'float' value within a vector. */
1228
1229static struct value *
1230s390_value_from_register (struct gdbarch *gdbarch, struct type *type,
1231 int regnum, struct frame_id frame_id)
1232{
1233 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
1234 struct value *value = default_value_from_register (gdbarch, type,
1235 regnum, frame_id);
1236 check_typedef (type);
1237
1238 if ((regnum >= S390_F0_REGNUM && regnum <= S390_F15_REGNUM
1239 && TYPE_LENGTH (type) < 8)
1240 || regnum_is_vxr_full (tdep, regnum)
1241 || (regnum >= S390_V16_REGNUM && regnum <= S390_V31_REGNUM))
1242 set_value_offset (value, 0);
1243
1244 return value;
1245}
1246
1247/* Implement pseudo_register_name tdesc method. */
1248
1249static const char *
1250s390_pseudo_register_name (struct gdbarch *gdbarch, int regnum)
1251{
1252 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
1253
1254 if (regnum == tdep->pc_regnum)
1255 return "pc";
1256
1257 if (regnum == tdep->cc_regnum)
1258 return "cc";
1259
1260 if (regnum_is_gpr_full (tdep, regnum))
1261 {
1262 static const char *full_name[] = {
1263 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
1264 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15"
1265 };
1266 return full_name[regnum - tdep->gpr_full_regnum];
1267 }
1268
1269 if (regnum_is_vxr_full (tdep, regnum))
1270 {
1271 static const char *full_name[] = {
1272 "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7",
1273 "v8", "v9", "v10", "v11", "v12", "v13", "v14", "v15"
1274 };
1275 return full_name[regnum - tdep->v0_full_regnum];
1276 }
1277
1278 internal_error (__FILE__, __LINE__, _("invalid regnum"));
1279}
1280
1281/* Implement pseudo_register_type tdesc method. */
1282
1283static struct type *
1284s390_pseudo_register_type (struct gdbarch *gdbarch, int regnum)
1285{
1286 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
1287
1288 if (regnum == tdep->pc_regnum)
1289 return builtin_type (gdbarch)->builtin_func_ptr;
1290
1291 if (regnum == tdep->cc_regnum)
1292 return builtin_type (gdbarch)->builtin_int;
1293
1294 if (regnum_is_gpr_full (tdep, regnum))
1295 return builtin_type (gdbarch)->builtin_uint64;
1296
0667c506 1297 /* For the "concatenated" vector registers use the same type as v16. */
d6e58945 1298 if (regnum_is_vxr_full (tdep, regnum))
0667c506 1299 return tdesc_register_type (gdbarch, S390_V16_REGNUM);
d6e58945
PR
1300
1301 internal_error (__FILE__, __LINE__, _("invalid regnum"));
1302}
1303
1304/* Implement pseudo_register_read gdbarch method. */
1305
1306static enum register_status
849d0ba8 1307s390_pseudo_register_read (struct gdbarch *gdbarch, readable_regcache *regcache,
d6e58945
PR
1308 int regnum, gdb_byte *buf)
1309{
1310 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
1311 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
1312 int regsize = register_size (gdbarch, regnum);
1313 ULONGEST val;
1314
1315 if (regnum == tdep->pc_regnum)
1316 {
1317 enum register_status status;
1318
1319 status = regcache->raw_read (S390_PSWA_REGNUM, &val);
1320 if (status == REG_VALID)
1321 {
1322 if (register_size (gdbarch, S390_PSWA_REGNUM) == 4)
1323 val &= 0x7fffffff;
1324 store_unsigned_integer (buf, regsize, byte_order, val);
1325 }
1326 return status;
1327 }
1328
1329 if (regnum == tdep->cc_regnum)
1330 {
1331 enum register_status status;
1332
1333 status = regcache->raw_read (S390_PSWM_REGNUM, &val);
1334 if (status == REG_VALID)
1335 {
1336 if (register_size (gdbarch, S390_PSWA_REGNUM) == 4)
1337 val = (val >> 12) & 3;
1338 else
1339 val = (val >> 44) & 3;
1340 store_unsigned_integer (buf, regsize, byte_order, val);
1341 }
1342 return status;
1343 }
1344
1345 if (regnum_is_gpr_full (tdep, regnum))
1346 {
1347 enum register_status status;
1348 ULONGEST val_upper;
1349
1350 regnum -= tdep->gpr_full_regnum;
1351
1352 status = regcache->raw_read (S390_R0_REGNUM + regnum, &val);
1353 if (status == REG_VALID)
1354 status = regcache->raw_read (S390_R0_UPPER_REGNUM + regnum,
1355 &val_upper);
1356 if (status == REG_VALID)
1357 {
1358 val |= val_upper << 32;
1359 store_unsigned_integer (buf, regsize, byte_order, val);
1360 }
1361 return status;
1362 }
1363
1364 if (regnum_is_vxr_full (tdep, regnum))
1365 {
1366 enum register_status status;
1367
1368 regnum -= tdep->v0_full_regnum;
1369
1370 status = regcache->raw_read (S390_F0_REGNUM + regnum, buf);
1371 if (status == REG_VALID)
1372 status = regcache->raw_read (S390_V0_LOWER_REGNUM + regnum, buf + 8);
1373 return status;
1374 }
1375
1376 internal_error (__FILE__, __LINE__, _("invalid regnum"));
1377}
1378
1379/* Implement pseudo_register_write gdbarch method. */
1380
1381static void
1382s390_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
1383 int regnum, const gdb_byte *buf)
1384{
1385 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
1386 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
1387 int regsize = register_size (gdbarch, regnum);
1388 ULONGEST val, psw;
1389
1390 if (regnum == tdep->pc_regnum)
1391 {
1392 val = extract_unsigned_integer (buf, regsize, byte_order);
1393 if (register_size (gdbarch, S390_PSWA_REGNUM) == 4)
1394 {
1395 regcache_raw_read_unsigned (regcache, S390_PSWA_REGNUM, &psw);
1396 val = (psw & 0x80000000) | (val & 0x7fffffff);
1397 }
1398 regcache_raw_write_unsigned (regcache, S390_PSWA_REGNUM, val);
1399 return;
1400 }
1401
1402 if (regnum == tdep->cc_regnum)
1403 {
1404 val = extract_unsigned_integer (buf, regsize, byte_order);
1405 regcache_raw_read_unsigned (regcache, S390_PSWM_REGNUM, &psw);
1406 if (register_size (gdbarch, S390_PSWA_REGNUM) == 4)
1407 val = (psw & ~((ULONGEST)3 << 12)) | ((val & 3) << 12);
1408 else
1409 val = (psw & ~((ULONGEST)3 << 44)) | ((val & 3) << 44);
1410 regcache_raw_write_unsigned (regcache, S390_PSWM_REGNUM, val);
1411 return;
1412 }
1413
1414 if (regnum_is_gpr_full (tdep, regnum))
1415 {
1416 regnum -= tdep->gpr_full_regnum;
1417 val = extract_unsigned_integer (buf, regsize, byte_order);
1418 regcache_raw_write_unsigned (regcache, S390_R0_REGNUM + regnum,
1419 val & 0xffffffff);
1420 regcache_raw_write_unsigned (regcache, S390_R0_UPPER_REGNUM + regnum,
1421 val >> 32);
1422 return;
1423 }
1424
1425 if (regnum_is_vxr_full (tdep, regnum))
1426 {
1427 regnum -= tdep->v0_full_regnum;
10eaee5f
SM
1428 regcache->raw_write (S390_F0_REGNUM + regnum, buf);
1429 regcache->raw_write (S390_V0_LOWER_REGNUM + regnum, buf + 8);
d6e58945
PR
1430 return;
1431 }
1432
1433 internal_error (__FILE__, __LINE__, _("invalid regnum"));
1434}
1435
1436/* Register groups. */
1437
1438/* Implement pseudo_register_reggroup_p tdesc method. */
1439
1440static int
1441s390_pseudo_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
1442 struct reggroup *group)
1443{
1444 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
1445
1446 /* We usually save/restore the whole PSW, which includes PC and CC.
1447 However, some older gdbservers may not support saving/restoring
1448 the whole PSW yet, and will return an XML register description
1449 excluding those from the save/restore register groups. In those
1450 cases, we still need to explicitly save/restore PC and CC in order
1451 to push or pop frames. Since this doesn't hurt anything if we
1452 already save/restore the whole PSW (it's just redundant), we add
1453 PC and CC at this point unconditionally. */
1454 if (group == save_reggroup || group == restore_reggroup)
1455 return regnum == tdep->pc_regnum || regnum == tdep->cc_regnum;
1456
1457 if (group == vector_reggroup)
1458 return regnum_is_vxr_full (tdep, regnum);
1459
1460 if (group == general_reggroup && regnum_is_vxr_full (tdep, regnum))
1461 return 0;
1462
1463 return default_register_reggroup_p (gdbarch, regnum, group);
1464}
1465
1466/* The "ax_pseudo_register_collect" gdbarch method. */
1467
1468static int
1469s390_ax_pseudo_register_collect (struct gdbarch *gdbarch,
1470 struct agent_expr *ax, int regnum)
1471{
1472 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
1473 if (regnum == tdep->pc_regnum)
1474 {
1475 ax_reg_mask (ax, S390_PSWA_REGNUM);
1476 }
1477 else if (regnum == tdep->cc_regnum)
1478 {
1479 ax_reg_mask (ax, S390_PSWM_REGNUM);
1480 }
1481 else if (regnum_is_gpr_full (tdep, regnum))
1482 {
1483 regnum -= tdep->gpr_full_regnum;
1484 ax_reg_mask (ax, S390_R0_REGNUM + regnum);
1485 ax_reg_mask (ax, S390_R0_UPPER_REGNUM + regnum);
1486 }
1487 else if (regnum_is_vxr_full (tdep, regnum))
1488 {
1489 regnum -= tdep->v0_full_regnum;
1490 ax_reg_mask (ax, S390_F0_REGNUM + regnum);
1491 ax_reg_mask (ax, S390_V0_LOWER_REGNUM + regnum);
1492 }
1493 else
1494 {
1495 internal_error (__FILE__, __LINE__, _("invalid regnum"));
1496 }
1497 return 0;
1498}
1499
1500/* The "ax_pseudo_register_push_stack" gdbarch method. */
1501
1502static int
1503s390_ax_pseudo_register_push_stack (struct gdbarch *gdbarch,
1504 struct agent_expr *ax, int regnum)
1505{
1506 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
1507 if (regnum == tdep->pc_regnum)
1508 {
1509 ax_reg (ax, S390_PSWA_REGNUM);
1510 if (register_size (gdbarch, S390_PSWA_REGNUM) == 4)
1511 {
1512 ax_zero_ext (ax, 31);
1513 }
1514 }
1515 else if (regnum == tdep->cc_regnum)
1516 {
1517 ax_reg (ax, S390_PSWM_REGNUM);
1518 if (register_size (gdbarch, S390_PSWA_REGNUM) == 4)
1519 ax_const_l (ax, 12);
1520 else
1521 ax_const_l (ax, 44);
1522 ax_simple (ax, aop_rsh_unsigned);
1523 ax_zero_ext (ax, 2);
1524 }
1525 else if (regnum_is_gpr_full (tdep, regnum))
1526 {
1527 regnum -= tdep->gpr_full_regnum;
1528 ax_reg (ax, S390_R0_REGNUM + regnum);
1529 ax_reg (ax, S390_R0_UPPER_REGNUM + regnum);
1530 ax_const_l (ax, 32);
1531 ax_simple (ax, aop_lsh);
1532 ax_simple (ax, aop_bit_or);
1533 }
1534 else if (regnum_is_vxr_full (tdep, regnum))
1535 {
1536 /* Too large to stuff on the stack. */
1537 return 1;
1538 }
1539 else
1540 {
1541 internal_error (__FILE__, __LINE__, _("invalid regnum"));
1542 }
1543 return 0;
1544}
1545
1546/* The "gen_return_address" gdbarch method. Since this is supposed to be
1547 just a best-effort method, and we don't really have the means to run
1548 the full unwinder here, just collect the link register. */
1549
1550static void
1551s390_gen_return_address (struct gdbarch *gdbarch,
1552 struct agent_expr *ax, struct axs_value *value,
1553 CORE_ADDR scope)
1554{
1555 value->type = register_type (gdbarch, S390_R14_REGNUM);
1556 value->kind = axs_lvalue_register;
1557 value->u.reg = S390_R14_REGNUM;
1558}
1559
1560/* Address handling. */
1561
1562/* Implement addr_bits_remove gdbarch method.
1563 Only used for ABI_LINUX_S390. */
1564
1565static CORE_ADDR
1566s390_addr_bits_remove (struct gdbarch *gdbarch, CORE_ADDR addr)
1567{
1568 return addr & 0x7fffffff;
1569}
1570
1571/* Implement addr_class_type_flags gdbarch method.
1572 Only used for ABI_LINUX_ZSERIES. */
1573
314ad88d 1574static type_instance_flags
d6e58945
PR
1575s390_address_class_type_flags (int byte_size, int dwarf2_addr_class)
1576{
1577 if (byte_size == 4)
1578 return TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1;
1579 else
1580 return 0;
1581}
1582
1583/* Implement addr_class_type_flags_to_name gdbarch method.
1584 Only used for ABI_LINUX_ZSERIES. */
1585
1586static const char *
314ad88d
PA
1587s390_address_class_type_flags_to_name (struct gdbarch *gdbarch,
1588 type_instance_flags type_flags)
d6e58945
PR
1589{
1590 if (type_flags & TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1)
1591 return "mode32";
1592 else
1593 return NULL;
1594}
1595
1596/* Implement addr_class_name_to_type_flags gdbarch method.
1597 Only used for ABI_LINUX_ZSERIES. */
1598
314ad88d 1599static bool
d6e58945
PR
1600s390_address_class_name_to_type_flags (struct gdbarch *gdbarch,
1601 const char *name,
314ad88d 1602 type_instance_flags *type_flags_ptr)
d6e58945
PR
1603{
1604 if (strcmp (name, "mode32") == 0)
1605 {
1606 *type_flags_ptr = TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1;
314ad88d 1607 return true;
d6e58945
PR
1608 }
1609 else
314ad88d 1610 return false;
d6e58945
PR
1611}
1612
1613/* Inferior function calls. */
1614
1615/* Dummy function calls. */
1616
1617/* Unwrap any single-field structs in TYPE and return the effective
1618 "inner" type. E.g., yield "float" for all these cases:
1619
1620 float x;
1621 struct { float x };
1622 struct { struct { float x; } x; };
1623 struct { struct { struct { float x; } x; } x; };
1624
1625 However, if an inner type is smaller than MIN_SIZE, abort the
1626 unwrapping. */
1627
1628static struct type *
1629s390_effective_inner_type (struct type *type, unsigned int min_size)
1630{
78134374 1631 while (type->code () == TYPE_CODE_STRUCT)
d6e58945 1632 {
ba18312d 1633 struct type *inner = NULL;
d6e58945 1634
ba18312d
AA
1635 /* Find a non-static field, if any. Unless there's exactly one,
1636 abort the unwrapping. */
1f704f76 1637 for (int i = 0; i < type->num_fields (); i++)
ba18312d 1638 {
ceacbf6e 1639 struct field f = type->field (i);
ba18312d
AA
1640
1641 if (field_is_static (&f))
1642 continue;
1643 if (inner != NULL)
1644 return type;
b6cdac4b 1645 inner = f.type ();
ba18312d
AA
1646 }
1647
1648 if (inner == NULL)
1649 break;
1650 inner = check_typedef (inner);
d6e58945
PR
1651 if (TYPE_LENGTH (inner) < min_size)
1652 break;
1653 type = inner;
1654 }
1655
1656 return type;
1657}
1658
1659/* Return non-zero if TYPE should be passed like "float" or
1660 "double". */
1661
1662static int
1663s390_function_arg_float (struct type *type)
1664{
1665 /* Note that long double as well as complex types are intentionally
1666 excluded. */
1667 if (TYPE_LENGTH (type) > 8)
1668 return 0;
1669
1670 /* A struct containing just a float or double is passed like a float
1671 or double. */
1672 type = s390_effective_inner_type (type, 0);
1673
78134374
SM
1674 return (type->code () == TYPE_CODE_FLT
1675 || type->code () == TYPE_CODE_DECFLOAT);
d6e58945
PR
1676}
1677
1678/* Return non-zero if TYPE should be passed like a vector. */
1679
1680static int
1681s390_function_arg_vector (struct type *type)
1682{
1683 if (TYPE_LENGTH (type) > 16)
1684 return 0;
1685
1686 /* Structs containing just a vector are passed like a vector. */
1687 type = s390_effective_inner_type (type, TYPE_LENGTH (type));
1688
bd63c870 1689 return type->code () == TYPE_CODE_ARRAY && type->is_vector ();
d6e58945
PR
1690}
1691
1692/* Determine whether N is a power of two. */
1693
1694static int
1695is_power_of_two (unsigned int n)
1696{
1697 return n && ((n & (n - 1)) == 0);
1698}
1699
1700/* For an argument whose type is TYPE and which is not passed like a
1701 float or vector, return non-zero if it should be passed like "int"
1702 or "long long". */
1703
1704static int
1705s390_function_arg_integer (struct type *type)
1706{
78134374 1707 enum type_code code = type->code ();
d6e58945
PR
1708
1709 if (TYPE_LENGTH (type) > 8)
1710 return 0;
1711
1712 if (code == TYPE_CODE_INT
1713 || code == TYPE_CODE_ENUM
1714 || code == TYPE_CODE_RANGE
1715 || code == TYPE_CODE_CHAR
1716 || code == TYPE_CODE_BOOL
1717 || code == TYPE_CODE_PTR
1718 || TYPE_IS_REFERENCE (type))
1719 return 1;
1720
1721 return ((code == TYPE_CODE_UNION || code == TYPE_CODE_STRUCT)
1722 && is_power_of_two (TYPE_LENGTH (type)));
1723}
1724
1725/* Argument passing state: Internal data structure passed to helper
1726 routines of s390_push_dummy_call. */
1727
1728struct s390_arg_state
1729 {
1730 /* Register cache, or NULL, if we are in "preparation mode". */
1731 struct regcache *regcache;
1732 /* Next available general/floating-point/vector register for
1733 argument passing. */
1734 int gr, fr, vr;
1735 /* Current pointer to copy area (grows downwards). */
1736 CORE_ADDR copy;
1737 /* Current pointer to parameter area (grows upwards). */
1738 CORE_ADDR argp;
1739 };
1740
1741/* Prepare one argument ARG for a dummy call and update the argument
1742 passing state AS accordingly. If the regcache field in AS is set,
1743 operate in "write mode" and write ARG into the inferior. Otherwise
1744 run "preparation mode" and skip all updates to the inferior. */
1745
1746static void
1747s390_handle_arg (struct s390_arg_state *as, struct value *arg,
1748 struct gdbarch_tdep *tdep, int word_size,
1749 enum bfd_endian byte_order, int is_unnamed)
1750{
1751 struct type *type = check_typedef (value_type (arg));
1752 unsigned int length = TYPE_LENGTH (type);
1753 int write_mode = as->regcache != NULL;
1754
1755 if (s390_function_arg_float (type))
1756 {
1757 /* The GNU/Linux for S/390 ABI uses FPRs 0 and 2 to pass
1758 arguments. The GNU/Linux for zSeries ABI uses 0, 2, 4, and
1759 6. */
1760 if (as->fr <= (tdep->abi == ABI_LINUX_S390 ? 2 : 6))
1761 {
1762 /* When we store a single-precision value in an FP register,
1763 it occupies the leftmost bits. */
1764 if (write_mode)
e4c4a59b
SM
1765 as->regcache->cooked_write_part (S390_F0_REGNUM + as->fr, 0, length,
1766 value_contents (arg));
d6e58945
PR
1767 as->fr += 2;
1768 }
1769 else
1770 {
1771 /* When we store a single-precision value in a stack slot,
1772 it occupies the rightmost bits. */
1773 as->argp = align_up (as->argp + length, word_size);
1774 if (write_mode)
1775 write_memory (as->argp - length, value_contents (arg),
1776 length);
1777 }
1778 }
1779 else if (tdep->vector_abi == S390_VECTOR_ABI_128
1780 && s390_function_arg_vector (type))
1781 {
1782 static const char use_vr[] = {24, 26, 28, 30, 25, 27, 29, 31};
1783
1784 if (!is_unnamed && as->vr < ARRAY_SIZE (use_vr))
1785 {
1786 int regnum = S390_V24_REGNUM + use_vr[as->vr] - 24;
1787
1788 if (write_mode)
e4c4a59b
SM
1789 as->regcache->cooked_write_part (regnum, 0, length,
1790 value_contents (arg));
d6e58945
PR
1791 as->vr++;
1792 }
1793 else
1794 {
1795 if (write_mode)
1796 write_memory (as->argp, value_contents (arg), length);
1797 as->argp = align_up (as->argp + length, word_size);
1798 }
1799 }
1800 else if (s390_function_arg_integer (type) && length <= word_size)
1801 {
1802 /* Initialize it just to avoid a GCC false warning. */
1803 ULONGEST val = 0;
1804
1805 if (write_mode)
1806 {
1807 /* Place value in least significant bits of the register or
1808 memory word and sign- or zero-extend to full word size.
1809 This also applies to a struct or union. */
c6d940a9 1810 val = type->is_unsigned ()
d6e58945
PR
1811 ? extract_unsigned_integer (value_contents (arg),
1812 length, byte_order)
1813 : extract_signed_integer (value_contents (arg),
1814 length, byte_order);
1815 }
1816
1817 if (as->gr <= 6)
1818 {
1819 if (write_mode)
1820 regcache_cooked_write_unsigned (as->regcache,
1821 S390_R0_REGNUM + as->gr,
1822 val);
1823 as->gr++;
1824 }
1825 else
1826 {
1827 if (write_mode)
1828 write_memory_unsigned_integer (as->argp, word_size,
1829 byte_order, val);
1830 as->argp += word_size;
1831 }
1832 }
1833 else if (s390_function_arg_integer (type) && length == 8)
1834 {
1835 if (as->gr <= 5)
1836 {
1837 if (write_mode)
1838 {
b66f5587
SM
1839 as->regcache->cooked_write (S390_R0_REGNUM + as->gr,
1840 value_contents (arg));
1841 as->regcache->cooked_write (S390_R0_REGNUM + as->gr + 1,
1842 value_contents (arg) + word_size);
d6e58945
PR
1843 }
1844 as->gr += 2;
1845 }
1846 else
1847 {
1848 /* If we skipped r6 because we couldn't fit a DOUBLE_ARG
1849 in it, then don't go back and use it again later. */
1850 as->gr = 7;
1851
1852 if (write_mode)
1853 write_memory (as->argp, value_contents (arg), length);
1854 as->argp += length;
1855 }
1856 }
1857 else
1858 {
1859 /* This argument type is never passed in registers. Place the
1860 value in the copy area and pass a pointer to it. Use 8-byte
1861 alignment as a conservative assumption. */
1862 as->copy = align_down (as->copy - length, 8);
1863 if (write_mode)
1864 write_memory (as->copy, value_contents (arg), length);
1865
1866 if (as->gr <= 6)
1867 {
1868 if (write_mode)
1869 regcache_cooked_write_unsigned (as->regcache,
1870 S390_R0_REGNUM + as->gr,
1871 as->copy);
1872 as->gr++;
1873 }
1874 else
1875 {
1876 if (write_mode)
1877 write_memory_unsigned_integer (as->argp, word_size,
1878 byte_order, as->copy);
1879 as->argp += word_size;
1880 }
1881 }
1882}
1883
1884/* Put the actual parameter values pointed to by ARGS[0..NARGS-1] in
1885 place to be passed to a function, as specified by the "GNU/Linux
1886 for S/390 ELF Application Binary Interface Supplement".
1887
1888 SP is the current stack pointer. We must put arguments, links,
1889 padding, etc. whereever they belong, and return the new stack
1890 pointer value.
1891
1892 If STRUCT_RETURN is non-zero, then the function we're calling is
1893 going to return a structure by value; STRUCT_ADDR is the address of
1894 a block we've allocated for it on the stack.
1895
1896 Our caller has taken care of any type promotions needed to satisfy
1897 prototypes or the old K&R argument-passing rules. */
1898
1899static CORE_ADDR
1900s390_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
1901 struct regcache *regcache, CORE_ADDR bp_addr,
1902 int nargs, struct value **args, CORE_ADDR sp,
cf84fa6b
AH
1903 function_call_return_method return_method,
1904 CORE_ADDR struct_addr)
d6e58945
PR
1905{
1906 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
1907 int word_size = gdbarch_ptr_bit (gdbarch) / 8;
1908 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
1909 int i;
1910 struct s390_arg_state arg_state, arg_prep;
1911 CORE_ADDR param_area_start, new_sp;
1912 struct type *ftype = check_typedef (value_type (function));
1913
78134374 1914 if (ftype->code () == TYPE_CODE_PTR)
d6e58945
PR
1915 ftype = check_typedef (TYPE_TARGET_TYPE (ftype));
1916
1917 arg_prep.copy = sp;
cf84fa6b 1918 arg_prep.gr = (return_method == return_method_struct) ? 3 : 2;
d6e58945
PR
1919 arg_prep.fr = 0;
1920 arg_prep.vr = 0;
1921 arg_prep.argp = 0;
1922 arg_prep.regcache = NULL;
1923
1924 /* Initialize arg_state for "preparation mode". */
1925 arg_state = arg_prep;
1926
1927 /* Update arg_state.copy with the start of the reference-to-copy area
1928 and arg_state.argp with the size of the parameter area. */
1929 for (i = 0; i < nargs; i++)
1930 s390_handle_arg (&arg_state, args[i], tdep, word_size, byte_order,
a409645d 1931 ftype->has_varargs () && i >= ftype->num_fields ());
d6e58945
PR
1932
1933 param_area_start = align_down (arg_state.copy - arg_state.argp, 8);
1934
1935 /* Allocate the standard frame areas: the register save area, the
1936 word reserved for the compiler, and the back chain pointer. */
1937 new_sp = param_area_start - (16 * word_size + 32);
1938
1939 /* Now we have the final stack pointer. Make sure we didn't
1940 underflow; on 31-bit, this would result in addresses with the
1941 high bit set, which causes confusion elsewhere. Note that if we
1942 error out here, stack and registers remain untouched. */
1943 if (gdbarch_addr_bits_remove (gdbarch, new_sp) != new_sp)
1944 error (_("Stack overflow"));
1945
1946 /* Pass the structure return address in general register 2. */
cf84fa6b 1947 if (return_method == return_method_struct)
d6e58945
PR
1948 regcache_cooked_write_unsigned (regcache, S390_R2_REGNUM, struct_addr);
1949
1950 /* Initialize arg_state for "write mode". */
1951 arg_state = arg_prep;
1952 arg_state.argp = param_area_start;
1953 arg_state.regcache = regcache;
1954
1955 /* Write all parameters. */
1956 for (i = 0; i < nargs; i++)
1957 s390_handle_arg (&arg_state, args[i], tdep, word_size, byte_order,
a409645d 1958 ftype->has_varargs () && i >= ftype->num_fields ());
d6e58945
PR
1959
1960 /* Store return PSWA. In 31-bit mode, keep addressing mode bit. */
1961 if (word_size == 4)
1962 {
1963 ULONGEST pswa;
1964 regcache_cooked_read_unsigned (regcache, S390_PSWA_REGNUM, &pswa);
1965 bp_addr = (bp_addr & 0x7fffffff) | (pswa & 0x80000000);
1966 }
1967 regcache_cooked_write_unsigned (regcache, S390_RETADDR_REGNUM, bp_addr);
1968
1969 /* Store updated stack pointer. */
1970 regcache_cooked_write_unsigned (regcache, S390_SP_REGNUM, new_sp);
1971
1972 /* We need to return the 'stack part' of the frame ID,
1973 which is actually the top of the register save area. */
1974 return param_area_start;
1975}
1976
1977/* Assuming THIS_FRAME is a dummy, return the frame ID of that
1978 dummy frame. The frame ID's base needs to match the TOS value
1979 returned by push_dummy_call, and the PC match the dummy frame's
1980 breakpoint. */
1981
1982static struct frame_id
1983s390_dummy_id (struct gdbarch *gdbarch, struct frame_info *this_frame)
1984{
1985 int word_size = gdbarch_ptr_bit (gdbarch) / 8;
1986 CORE_ADDR sp = get_frame_register_unsigned (this_frame, S390_SP_REGNUM);
1987 sp = gdbarch_addr_bits_remove (gdbarch, sp);
1988
1989 return frame_id_build (sp + 16*word_size + 32,
1990 get_frame_pc (this_frame));
1991}
1992
1993/* Implement frame_align gdbarch method. */
1994
1995static CORE_ADDR
1996s390_frame_align (struct gdbarch *gdbarch, CORE_ADDR addr)
1997{
1998 /* Both the 32- and 64-bit ABI's say that the stack pointer should
1999 always be aligned on an eight-byte boundary. */
2000 return (addr & -8);
2001}
2002
2003/* Helper for s390_return_value: Set or retrieve a function return
2004 value if it resides in a register. */
2005
2006static void
2007s390_register_return_value (struct gdbarch *gdbarch, struct type *type,
2008 struct regcache *regcache,
2009 gdb_byte *out, const gdb_byte *in)
2010{
2011 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
2012 int word_size = gdbarch_ptr_bit (gdbarch) / 8;
2013 int length = TYPE_LENGTH (type);
78134374 2014 int code = type->code ();
d6e58945
PR
2015
2016 if (code == TYPE_CODE_FLT || code == TYPE_CODE_DECFLOAT)
2017 {
2018 /* Float-like value: left-aligned in f0. */
2019 if (in != NULL)
e4c4a59b 2020 regcache->cooked_write_part (S390_F0_REGNUM, 0, length, in);
d6e58945 2021 else
73bb0000 2022 regcache->cooked_read_part (S390_F0_REGNUM, 0, length, out);
d6e58945
PR
2023 }
2024 else if (code == TYPE_CODE_ARRAY)
2025 {
2026 /* Vector: left-aligned in v24. */
2027 if (in != NULL)
e4c4a59b 2028 regcache->cooked_write_part (S390_V24_REGNUM, 0, length, in);
d6e58945 2029 else
73bb0000 2030 regcache->cooked_read_part (S390_V24_REGNUM, 0, length, out);
d6e58945
PR
2031 }
2032 else if (length <= word_size)
2033 {
2034 /* Integer: zero- or sign-extended in r2. */
2035 if (out != NULL)
73bb0000
SM
2036 regcache->cooked_read_part (S390_R2_REGNUM, word_size - length, length,
2037 out);
c6d940a9 2038 else if (type->is_unsigned ())
d6e58945
PR
2039 regcache_cooked_write_unsigned
2040 (regcache, S390_R2_REGNUM,
2041 extract_unsigned_integer (in, length, byte_order));
2042 else
2043 regcache_cooked_write_signed
2044 (regcache, S390_R2_REGNUM,
2045 extract_signed_integer (in, length, byte_order));
2046 }
2047 else if (length == 2 * word_size)
2048 {
2049 /* Double word: in r2 and r3. */
2050 if (in != NULL)
2051 {
b66f5587
SM
2052 regcache->cooked_write (S390_R2_REGNUM, in);
2053 regcache->cooked_write (S390_R3_REGNUM, in + word_size);
d6e58945
PR
2054 }
2055 else
2056 {
dca08e1f
SM
2057 regcache->cooked_read (S390_R2_REGNUM, out);
2058 regcache->cooked_read (S390_R3_REGNUM, out + word_size);
d6e58945
PR
2059 }
2060 }
2061 else
2062 internal_error (__FILE__, __LINE__, _("invalid return type"));
2063}
2064
2065/* Implement the 'return_value' gdbarch method. */
2066
2067static enum return_value_convention
2068s390_return_value (struct gdbarch *gdbarch, struct value *function,
2069 struct type *type, struct regcache *regcache,
2070 gdb_byte *out, const gdb_byte *in)
2071{
2072 enum return_value_convention rvc;
2073
2074 type = check_typedef (type);
2075
78134374 2076 switch (type->code ())
d6e58945
PR
2077 {
2078 case TYPE_CODE_STRUCT:
2079 case TYPE_CODE_UNION:
2080 case TYPE_CODE_COMPLEX:
2081 rvc = RETURN_VALUE_STRUCT_CONVENTION;
2082 break;
2083 case TYPE_CODE_ARRAY:
2084 rvc = (gdbarch_tdep (gdbarch)->vector_abi == S390_VECTOR_ABI_128
bd63c870 2085 && TYPE_LENGTH (type) <= 16 && type->is_vector ())
d6e58945
PR
2086 ? RETURN_VALUE_REGISTER_CONVENTION
2087 : RETURN_VALUE_STRUCT_CONVENTION;
2088 break;
2089 default:
2090 rvc = TYPE_LENGTH (type) <= 8
2091 ? RETURN_VALUE_REGISTER_CONVENTION
2092 : RETURN_VALUE_STRUCT_CONVENTION;
2093 }
2094
2095 if (in != NULL || out != NULL)
2096 {
2097 if (rvc == RETURN_VALUE_REGISTER_CONVENTION)
2098 s390_register_return_value (gdbarch, type, regcache, out, in);
2099 else if (in != NULL)
2100 error (_("Cannot set function return value."));
2101 else
2102 error (_("Function return value unknown."));
2103 }
2104
2105 return rvc;
2106}
2107
2108/* Frame unwinding. */
2109
405feb71 2110/* Implement the stack_frame_destroyed_p gdbarch method. */
d6e58945
PR
2111
2112static int
2113s390_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc)
2114{
2115 int word_size = gdbarch_ptr_bit (gdbarch) / 8;
2116
2117 /* In frameless functions, there's no frame to destroy and thus
2118 we don't care about the epilogue.
2119
2120 In functions with frame, the epilogue sequence is a pair of
2121 a LM-type instruction that restores (amongst others) the
2122 return register %r14 and the stack pointer %r15, followed
2123 by a branch 'br %r14' --or equivalent-- that effects the
2124 actual return.
2125
2126 In that situation, this function needs to return 'true' in
2127 exactly one case: when pc points to that branch instruction.
2128
2129 Thus we try to disassemble the one instructions immediately
2130 preceding pc and check whether it is an LM-type instruction
2131 modifying the stack pointer.
2132
2133 Note that disassembling backwards is not reliable, so there
2134 is a slight chance of false positives here ... */
2135
2136 bfd_byte insn[6];
2137 unsigned int r1, r3, b2;
2138 int d2;
2139
2140 if (word_size == 4
2141 && !target_read_memory (pc - 4, insn, 4)
2142 && is_rs (insn, op_lm, &r1, &r3, &d2, &b2)
2143 && r3 == S390_SP_REGNUM - S390_R0_REGNUM)
2144 return 1;
2145
2146 if (word_size == 4
2147 && !target_read_memory (pc - 6, insn, 6)
2148 && is_rsy (insn, op1_lmy, op2_lmy, &r1, &r3, &d2, &b2)
2149 && r3 == S390_SP_REGNUM - S390_R0_REGNUM)
2150 return 1;
2151
2152 if (word_size == 8
2153 && !target_read_memory (pc - 6, insn, 6)
2154 && is_rsy (insn, op1_lmg, op2_lmg, &r1, &r3, &d2, &b2)
2155 && r3 == S390_SP_REGNUM - S390_R0_REGNUM)
2156 return 1;
2157
2158 return 0;
2159}
2160
2161/* Implement unwind_pc gdbarch method. */
2162
2163static CORE_ADDR
2164s390_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
2165{
2166 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
2167 ULONGEST pc;
2168 pc = frame_unwind_register_unsigned (next_frame, tdep->pc_regnum);
2169 return gdbarch_addr_bits_remove (gdbarch, pc);
2170}
2171
2172/* Implement unwind_sp gdbarch method. */
2173
2174static CORE_ADDR
2175s390_unwind_sp (struct gdbarch *gdbarch, struct frame_info *next_frame)
2176{
2177 ULONGEST sp;
2178 sp = frame_unwind_register_unsigned (next_frame, S390_SP_REGNUM);
2179 return gdbarch_addr_bits_remove (gdbarch, sp);
2180}
2181
2182/* Helper routine to unwind pseudo registers. */
2183
2184static struct value *
2185s390_unwind_pseudo_register (struct frame_info *this_frame, int regnum)
2186{
2187 struct gdbarch *gdbarch = get_frame_arch (this_frame);
2188 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
2189 struct type *type = register_type (gdbarch, regnum);
2190
2191 /* Unwind PC via PSW address. */
2192 if (regnum == tdep->pc_regnum)
2193 {
2194 struct value *val;
2195
2196 val = frame_unwind_register_value (this_frame, S390_PSWA_REGNUM);
2197 if (!value_optimized_out (val))
2198 {
2199 LONGEST pswa = value_as_long (val);
2200
2201 if (TYPE_LENGTH (type) == 4)
2202 return value_from_pointer (type, pswa & 0x7fffffff);
2203 else
2204 return value_from_pointer (type, pswa);
2205 }
2206 }
2207
2208 /* Unwind CC via PSW mask. */
2209 if (regnum == tdep->cc_regnum)
2210 {
2211 struct value *val;
2212
2213 val = frame_unwind_register_value (this_frame, S390_PSWM_REGNUM);
2214 if (!value_optimized_out (val))
2215 {
2216 LONGEST pswm = value_as_long (val);
2217
2218 if (TYPE_LENGTH (type) == 4)
2219 return value_from_longest (type, (pswm >> 12) & 3);
2220 else
2221 return value_from_longest (type, (pswm >> 44) & 3);
2222 }
2223 }
2224
2225 /* Unwind full GPRs to show at least the lower halves (as the
2226 upper halves are undefined). */
2227 if (regnum_is_gpr_full (tdep, regnum))
2228 {
2229 int reg = regnum - tdep->gpr_full_regnum;
2230 struct value *val;
2231
2232 val = frame_unwind_register_value (this_frame, S390_R0_REGNUM + reg);
2233 if (!value_optimized_out (val))
2234 return value_cast (type, val);
2235 }
2236
2237 return allocate_optimized_out_value (type);
2238}
2239
2240/* Translate a .eh_frame register to DWARF register, or adjust a
2241 .debug_frame register. */
2242
2243static int
2244s390_adjust_frame_regnum (struct gdbarch *gdbarch, int num, int eh_frame_p)
2245{
2246 /* See s390_dwarf_reg_to_regnum for comments. */
2247 return (num >= 0 && num < 16) ? num + s390_dwarf_reg_r0l : num;
2248}
2249
2250/* DWARF-2 frame unwinding. */
2251
2252/* Function to unwind a pseudo-register in dwarf2_frame unwinder. Used by
2253 s390_dwarf2_frame_init_reg. */
2254
2255static struct value *
2256s390_dwarf2_prev_register (struct frame_info *this_frame, void **this_cache,
2257 int regnum)
2258{
2259 return s390_unwind_pseudo_register (this_frame, regnum);
2260}
2261
2262/* Implement init_reg dwarf2_frame method. */
2263
2264static void
2265s390_dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum,
2266 struct dwarf2_frame_state_reg *reg,
2267 struct frame_info *this_frame)
2268{
2269 /* The condition code (and thus PSW mask) is call-clobbered. */
2270 if (regnum == S390_PSWM_REGNUM)
2271 reg->how = DWARF2_FRAME_REG_UNDEFINED;
2272
2273 /* The PSW address unwinds to the return address. */
2274 else if (regnum == S390_PSWA_REGNUM)
2275 reg->how = DWARF2_FRAME_REG_RA;
2276
2277 /* Fixed registers are call-saved or call-clobbered
2278 depending on the ABI in use. */
2279 else if (regnum < S390_NUM_REGS)
2280 {
2281 if (s390_register_call_saved (gdbarch, regnum))
2282 reg->how = DWARF2_FRAME_REG_SAME_VALUE;
2283 else
2284 reg->how = DWARF2_FRAME_REG_UNDEFINED;
2285 }
2286
2287 /* We install a special function to unwind pseudos. */
2288 else
2289 {
2290 reg->how = DWARF2_FRAME_REG_FN;
2291 reg->loc.fn = s390_dwarf2_prev_register;
2292 }
2293}
2294
2295/* Frame unwinding. */
2296
2297/* Wrapper for trad_frame_get_prev_register to allow for s390 pseudo
2298 register translation. */
2299
2300struct value *
2301s390_trad_frame_prev_register (struct frame_info *this_frame,
2302 struct trad_frame_saved_reg saved_regs[],
2303 int regnum)
2304{
2305 if (regnum < S390_NUM_REGS)
2306 return trad_frame_get_prev_register (this_frame, saved_regs, regnum);
2307 else
2308 return s390_unwind_pseudo_register (this_frame, regnum);
2309}
2310
2311/* Normal stack frames. */
2312
2313struct s390_unwind_cache {
2314
2315 CORE_ADDR func;
2316 CORE_ADDR frame_base;
2317 CORE_ADDR local_base;
2318
2319 struct trad_frame_saved_reg *saved_regs;
2320};
2321
2322/* Unwind THIS_FRAME and write the information into unwind cache INFO using
2323 prologue analysis. Helper for s390_frame_unwind_cache. */
2324
2325static int
2326s390_prologue_frame_unwind_cache (struct frame_info *this_frame,
2327 struct s390_unwind_cache *info)
2328{
2329 struct gdbarch *gdbarch = get_frame_arch (this_frame);
2330 int word_size = gdbarch_ptr_bit (gdbarch) / 8;
2331 struct s390_prologue_data data;
2332 pv_t *fp = &data.gpr[S390_FRAME_REGNUM - S390_R0_REGNUM];
2333 pv_t *sp = &data.gpr[S390_SP_REGNUM - S390_R0_REGNUM];
2334 int i;
2335 CORE_ADDR cfa;
2336 CORE_ADDR func;
2337 CORE_ADDR result;
2338 ULONGEST reg;
2339 CORE_ADDR prev_sp;
2340 int frame_pointer;
2341 int size;
2342 struct frame_info *next_frame;
2343
2344 /* Try to find the function start address. If we can't find it, we don't
2345 bother searching for it -- with modern compilers this would be mostly
2346 pointless anyway. Trust that we'll either have valid DWARF-2 CFI data
2347 or else a valid backchain ... */
2348 if (!get_frame_func_if_available (this_frame, &info->func))
2349 {
2350 info->func = -1;
2351 return 0;
2352 }
2353 func = info->func;
2354
2355 /* Try to analyze the prologue. */
2356 result = s390_analyze_prologue (gdbarch, func,
2357 get_frame_pc (this_frame), &data);
2358 if (!result)
2359 return 0;
2360
2361 /* If this was successful, we should have found the instruction that
2362 sets the stack pointer register to the previous value of the stack
2363 pointer minus the frame size. */
2364 if (!pv_is_register (*sp, S390_SP_REGNUM))
2365 return 0;
2366
2367 /* A frame size of zero at this point can mean either a real
2368 frameless function, or else a failure to find the prologue.
2369 Perform some sanity checks to verify we really have a
2370 frameless function. */
2371 if (sp->k == 0)
2372 {
2373 /* If the next frame is a NORMAL_FRAME, this frame *cannot* have frame
2374 size zero. This is only possible if the next frame is a sentinel
2375 frame, a dummy frame, or a signal trampoline frame. */
2376 /* FIXME: cagney/2004-05-01: This sanity check shouldn't be
2377 needed, instead the code should simpliy rely on its
2378 analysis. */
2379 next_frame = get_next_frame (this_frame);
2380 while (next_frame && get_frame_type (next_frame) == INLINE_FRAME)
2381 next_frame = get_next_frame (next_frame);
2382 if (next_frame
2383 && get_frame_type (get_next_frame (this_frame)) == NORMAL_FRAME)
2384 return 0;
2385
2386 /* If we really have a frameless function, %r14 must be valid
2387 -- in particular, it must point to a different function. */
2388 reg = get_frame_register_unsigned (this_frame, S390_RETADDR_REGNUM);
2389 reg = gdbarch_addr_bits_remove (gdbarch, reg) - 1;
2390 if (get_pc_function_start (reg) == func)
2391 {
2392 /* However, there is one case where it *is* valid for %r14
2393 to point to the same function -- if this is a recursive
2394 call, and we have stopped in the prologue *before* the
2395 stack frame was allocated.
2396
2397 Recognize this case by looking ahead a bit ... */
2398
2399 struct s390_prologue_data data2;
b926417a 2400 pv_t *sp2 = &data2.gpr[S390_SP_REGNUM - S390_R0_REGNUM];
d6e58945
PR
2401
2402 if (!(s390_analyze_prologue (gdbarch, func, (CORE_ADDR)-1, &data2)
b926417a
TT
2403 && pv_is_register (*sp2, S390_SP_REGNUM)
2404 && sp2->k != 0))
d6e58945
PR
2405 return 0;
2406 }
2407 }
2408
2409 /* OK, we've found valid prologue data. */
2410 size = -sp->k;
2411
2412 /* If the frame pointer originally also holds the same value
2413 as the stack pointer, we're probably using it. If it holds
2414 some other value -- even a constant offset -- it is most
2415 likely used as temp register. */
2416 if (pv_is_identical (*sp, *fp))
2417 frame_pointer = S390_FRAME_REGNUM;
2418 else
2419 frame_pointer = S390_SP_REGNUM;
2420
2421 /* If we've detected a function with stack frame, we'll still have to
2422 treat it as frameless if we're currently within the function epilog
2423 code at a point where the frame pointer has already been restored.
2424 This can only happen in an innermost frame. */
2425 /* FIXME: cagney/2004-05-01: This sanity check shouldn't be needed,
2426 instead the code should simpliy rely on its analysis. */
2427 next_frame = get_next_frame (this_frame);
2428 while (next_frame && get_frame_type (next_frame) == INLINE_FRAME)
2429 next_frame = get_next_frame (next_frame);
2430 if (size > 0
2431 && (next_frame == NULL
2432 || get_frame_type (get_next_frame (this_frame)) != NORMAL_FRAME))
2433 {
2434 /* See the comment in s390_stack_frame_destroyed_p on why this is
2435 not completely reliable ... */
2436 if (s390_stack_frame_destroyed_p (gdbarch, get_frame_pc (this_frame)))
2437 {
2438 memset (&data, 0, sizeof (data));
2439 size = 0;
2440 frame_pointer = S390_SP_REGNUM;
2441 }
2442 }
2443
2444 /* Once we know the frame register and the frame size, we can unwind
2445 the current value of the frame register from the next frame, and
2446 add back the frame size to arrive that the previous frame's
2447 stack pointer value. */
2448 prev_sp = get_frame_register_unsigned (this_frame, frame_pointer) + size;
2449 cfa = prev_sp + 16*word_size + 32;
2450
2451 /* Set up ABI call-saved/call-clobbered registers. */
2452 for (i = 0; i < S390_NUM_REGS; i++)
2453 if (!s390_register_call_saved (gdbarch, i))
2454 trad_frame_set_unknown (info->saved_regs, i);
2455
2456 /* CC is always call-clobbered. */
2457 trad_frame_set_unknown (info->saved_regs, S390_PSWM_REGNUM);
2458
2459 /* Record the addresses of all register spill slots the prologue parser
2460 has recognized. Consider only registers defined as call-saved by the
2461 ABI; for call-clobbered registers the parser may have recognized
2462 spurious stores. */
2463
2464 for (i = 0; i < 16; i++)
2465 if (s390_register_call_saved (gdbarch, S390_R0_REGNUM + i)
2466 && data.gpr_slot[i] != 0)
2467 info->saved_regs[S390_R0_REGNUM + i].addr = cfa - data.gpr_slot[i];
2468
2469 for (i = 0; i < 16; i++)
2470 if (s390_register_call_saved (gdbarch, S390_F0_REGNUM + i)
2471 && data.fpr_slot[i] != 0)
2472 info->saved_regs[S390_F0_REGNUM + i].addr = cfa - data.fpr_slot[i];
2473
2474 /* Function return will set PC to %r14. */
2475 info->saved_regs[S390_PSWA_REGNUM] = info->saved_regs[S390_RETADDR_REGNUM];
2476
2477 /* In frameless functions, we unwind simply by moving the return
2478 address to the PC. However, if we actually stored to the
2479 save area, use that -- we might only think the function frameless
2480 because we're in the middle of the prologue ... */
2481 if (size == 0
2482 && !trad_frame_addr_p (info->saved_regs, S390_PSWA_REGNUM))
2483 {
2484 info->saved_regs[S390_PSWA_REGNUM].realreg = S390_RETADDR_REGNUM;
2485 }
2486
2487 /* Another sanity check: unless this is a frameless function,
2488 we should have found spill slots for SP and PC.
2489 If not, we cannot unwind further -- this happens e.g. in
2490 libc's thread_start routine. */
2491 if (size > 0)
2492 {
2493 if (!trad_frame_addr_p (info->saved_regs, S390_SP_REGNUM)
2494 || !trad_frame_addr_p (info->saved_regs, S390_PSWA_REGNUM))
2495 prev_sp = -1;
2496 }
2497
2498 /* We use the current value of the frame register as local_base,
2499 and the top of the register save area as frame_base. */
2500 if (prev_sp != -1)
2501 {
2502 info->frame_base = prev_sp + 16*word_size + 32;
2503 info->local_base = prev_sp - size;
2504 }
2505
2506 return 1;
2507}
2508
2509/* Unwind THIS_FRAME and write the information into unwind cache INFO using
2510 back chain unwinding. Helper for s390_frame_unwind_cache. */
2511
2512static void
2513s390_backchain_frame_unwind_cache (struct frame_info *this_frame,
2514 struct s390_unwind_cache *info)
2515{
2516 struct gdbarch *gdbarch = get_frame_arch (this_frame);
2517 int word_size = gdbarch_ptr_bit (gdbarch) / 8;
2518 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
2519 CORE_ADDR backchain;
2520 ULONGEST reg;
2521 LONGEST sp, tmp;
2522 int i;
2523
2524 /* Set up ABI call-saved/call-clobbered registers. */
2525 for (i = 0; i < S390_NUM_REGS; i++)
2526 if (!s390_register_call_saved (gdbarch, i))
2527 trad_frame_set_unknown (info->saved_regs, i);
2528
2529 /* CC is always call-clobbered. */
2530 trad_frame_set_unknown (info->saved_regs, S390_PSWM_REGNUM);
2531
2532 /* Get the backchain. */
2533 reg = get_frame_register_unsigned (this_frame, S390_SP_REGNUM);
2534 if (!safe_read_memory_integer (reg, word_size, byte_order, &tmp))
2535 tmp = 0;
2536 backchain = (CORE_ADDR) tmp;
2537
2538 /* A zero backchain terminates the frame chain. As additional
2539 sanity check, let's verify that the spill slot for SP in the
2540 save area pointed to by the backchain in fact links back to
2541 the save area. */
2542 if (backchain != 0
2543 && safe_read_memory_integer (backchain + 15*word_size,
2544 word_size, byte_order, &sp)
2545 && (CORE_ADDR)sp == backchain)
2546 {
2547 /* We don't know which registers were saved, but it will have
2548 to be at least %r14 and %r15. This will allow us to continue
2549 unwinding, but other prev-frame registers may be incorrect ... */
2550 info->saved_regs[S390_SP_REGNUM].addr = backchain + 15*word_size;
2551 info->saved_regs[S390_RETADDR_REGNUM].addr = backchain + 14*word_size;
2552
2553 /* Function return will set PC to %r14. */
2554 info->saved_regs[S390_PSWA_REGNUM]
2555 = info->saved_regs[S390_RETADDR_REGNUM];
2556
2557 /* We use the current value of the frame register as local_base,
2558 and the top of the register save area as frame_base. */
2559 info->frame_base = backchain + 16*word_size + 32;
2560 info->local_base = reg;
2561 }
2562
2563 info->func = get_frame_pc (this_frame);
2564}
2565
2566/* Unwind THIS_FRAME and return the corresponding unwind cache for
2567 s390_frame_unwind and s390_frame_base. */
2568
2569static struct s390_unwind_cache *
2570s390_frame_unwind_cache (struct frame_info *this_frame,
2571 void **this_prologue_cache)
2572{
2573 struct s390_unwind_cache *info;
2574
2575 if (*this_prologue_cache)
2576 return (struct s390_unwind_cache *) *this_prologue_cache;
2577
2578 info = FRAME_OBSTACK_ZALLOC (struct s390_unwind_cache);
2579 *this_prologue_cache = info;
2580 info->saved_regs = trad_frame_alloc_saved_regs (this_frame);
2581 info->func = -1;
2582 info->frame_base = -1;
2583 info->local_base = -1;
2584
a70b8144 2585 try
d6e58945
PR
2586 {
2587 /* Try to use prologue analysis to fill the unwind cache.
2588 If this fails, fall back to reading the stack backchain. */
2589 if (!s390_prologue_frame_unwind_cache (this_frame, info))
2590 s390_backchain_frame_unwind_cache (this_frame, info);
2591 }
230d2906 2592 catch (const gdb_exception_error &ex)
d6e58945
PR
2593 {
2594 if (ex.error != NOT_AVAILABLE_ERROR)
eedc3f4f 2595 throw;
d6e58945 2596 }
d6e58945
PR
2597
2598 return info;
2599}
2600
2601/* Implement this_id frame_unwind method for s390_frame_unwind. */
2602
2603static void
2604s390_frame_this_id (struct frame_info *this_frame,
2605 void **this_prologue_cache,
2606 struct frame_id *this_id)
2607{
2608 struct s390_unwind_cache *info
2609 = s390_frame_unwind_cache (this_frame, this_prologue_cache);
2610
2611 if (info->frame_base == -1)
2612 {
2613 if (info->func != -1)
2614 *this_id = frame_id_build_unavailable_stack (info->func);
2615 return;
2616 }
2617
2618 *this_id = frame_id_build (info->frame_base, info->func);
2619}
2620
2621/* Implement prev_register frame_unwind method for s390_frame_unwind. */
2622
2623static struct value *
2624s390_frame_prev_register (struct frame_info *this_frame,
2625 void **this_prologue_cache, int regnum)
2626{
2627 struct s390_unwind_cache *info
2628 = s390_frame_unwind_cache (this_frame, this_prologue_cache);
2629
2630 return s390_trad_frame_prev_register (this_frame, info->saved_regs, regnum);
2631}
2632
2633/* Default S390 frame unwinder. */
2634
2635static const struct frame_unwind s390_frame_unwind = {
2636 NORMAL_FRAME,
2637 default_frame_unwind_stop_reason,
2638 s390_frame_this_id,
2639 s390_frame_prev_register,
2640 NULL,
2641 default_frame_sniffer
2642};
2643
2644/* Code stubs and their stack frames. For things like PLTs and NULL
2645 function calls (where there is no true frame and the return address
2646 is in the RETADDR register). */
2647
2648struct s390_stub_unwind_cache
2649{
2650 CORE_ADDR frame_base;
2651 struct trad_frame_saved_reg *saved_regs;
2652};
2653
2654/* Unwind THIS_FRAME and return the corresponding unwind cache for
2655 s390_stub_frame_unwind. */
2656
2657static struct s390_stub_unwind_cache *
2658s390_stub_frame_unwind_cache (struct frame_info *this_frame,
2659 void **this_prologue_cache)
2660{
2661 struct gdbarch *gdbarch = get_frame_arch (this_frame);
2662 int word_size = gdbarch_ptr_bit (gdbarch) / 8;
2663 struct s390_stub_unwind_cache *info;
2664 ULONGEST reg;
2665
2666 if (*this_prologue_cache)
2667 return (struct s390_stub_unwind_cache *) *this_prologue_cache;
2668
2669 info = FRAME_OBSTACK_ZALLOC (struct s390_stub_unwind_cache);
2670 *this_prologue_cache = info;
2671 info->saved_regs = trad_frame_alloc_saved_regs (this_frame);
2672
2673 /* The return address is in register %r14. */
2674 info->saved_regs[S390_PSWA_REGNUM].realreg = S390_RETADDR_REGNUM;
2675
2676 /* Retrieve stack pointer and determine our frame base. */
2677 reg = get_frame_register_unsigned (this_frame, S390_SP_REGNUM);
2678 info->frame_base = reg + 16*word_size + 32;
2679
2680 return info;
2681}
2682
2683/* Implement this_id frame_unwind method for s390_stub_frame_unwind. */
2684
2685static void
2686s390_stub_frame_this_id (struct frame_info *this_frame,
2687 void **this_prologue_cache,
2688 struct frame_id *this_id)
2689{
2690 struct s390_stub_unwind_cache *info
2691 = s390_stub_frame_unwind_cache (this_frame, this_prologue_cache);
2692 *this_id = frame_id_build (info->frame_base, get_frame_pc (this_frame));
2693}
2694
2695/* Implement prev_register frame_unwind method for s390_stub_frame_unwind. */
2696
2697static struct value *
2698s390_stub_frame_prev_register (struct frame_info *this_frame,
2699 void **this_prologue_cache, int regnum)
2700{
2701 struct s390_stub_unwind_cache *info
2702 = s390_stub_frame_unwind_cache (this_frame, this_prologue_cache);
2703 return s390_trad_frame_prev_register (this_frame, info->saved_regs, regnum);
2704}
2705
2706/* Implement sniffer frame_unwind method for s390_stub_frame_unwind. */
2707
2708static int
2709s390_stub_frame_sniffer (const struct frame_unwind *self,
2710 struct frame_info *this_frame,
2711 void **this_prologue_cache)
2712{
2713 CORE_ADDR addr_in_block;
2714 bfd_byte insn[S390_MAX_INSTR_SIZE];
2715
2716 /* If the current PC points to non-readable memory, we assume we
2717 have trapped due to an invalid function pointer call. We handle
2718 the non-existing current function like a PLT stub. */
2719 addr_in_block = get_frame_address_in_block (this_frame);
2720 if (in_plt_section (addr_in_block)
2721 || s390_readinstruction (insn, get_frame_pc (this_frame)) < 0)
2722 return 1;
2723 return 0;
2724}
2725
2726/* S390 stub frame unwinder. */
2727
2728static const struct frame_unwind s390_stub_frame_unwind = {
2729 NORMAL_FRAME,
2730 default_frame_unwind_stop_reason,
2731 s390_stub_frame_this_id,
2732 s390_stub_frame_prev_register,
2733 NULL,
2734 s390_stub_frame_sniffer
2735};
2736
2737/* Frame base handling. */
2738
2739static CORE_ADDR
2740s390_frame_base_address (struct frame_info *this_frame, void **this_cache)
2741{
2742 struct s390_unwind_cache *info
2743 = s390_frame_unwind_cache (this_frame, this_cache);
2744 return info->frame_base;
2745}
2746
2747static CORE_ADDR
2748s390_local_base_address (struct frame_info *this_frame, void **this_cache)
2749{
2750 struct s390_unwind_cache *info
2751 = s390_frame_unwind_cache (this_frame, this_cache);
2752 return info->local_base;
2753}
2754
2755static const struct frame_base s390_frame_base = {
2756 &s390_frame_unwind,
2757 s390_frame_base_address,
2758 s390_local_base_address,
2759 s390_local_base_address
2760};
2761
ef8914a4
PR
2762/* Process record-replay */
2763
2764/* Takes the intermediate sum of address calculations and masks off upper
2765 bits according to current addressing mode. */
2766
2767static CORE_ADDR
2768s390_record_address_mask (struct gdbarch *gdbarch, struct regcache *regcache,
2769 CORE_ADDR val)
2770{
2771 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
2772 ULONGEST pswm, pswa;
2773 int am;
2774 if (tdep->abi == ABI_LINUX_S390)
2775 {
2776 regcache_raw_read_unsigned (regcache, S390_PSWA_REGNUM, &pswa);
2777 am = pswa >> 31 & 1;
2778 }
2779 else
2780 {
2781 regcache_raw_read_unsigned (regcache, S390_PSWM_REGNUM, &pswm);
2782 am = pswm >> 31 & 3;
2783 }
2784 switch (am)
2785 {
2786 case 0:
2787 return val & 0xffffff;
2788 case 1:
2789 return val & 0x7fffffff;
2790 case 3:
2791 return val;
2792 default:
2793 fprintf_unfiltered (gdb_stdlog, "Warning: Addressing mode %d used.", am);
2794 return 0;
2795 }
2796}
2797
2798/* Calculates memory address using pre-calculated index, raw instruction word
2799 with b and d/dl fields, and raw instruction byte with dh field. Index and
2800 dh should be set to 0 if unused. */
2801
2802static CORE_ADDR
2803s390_record_calc_disp_common (struct gdbarch *gdbarch, struct regcache *regcache,
2804 ULONGEST x, uint16_t bd, int8_t dh)
2805{
2806 uint8_t rb = bd >> 12 & 0xf;
2807 int32_t d = (bd & 0xfff) | ((int32_t)dh << 12);
2808 ULONGEST b;
2809 CORE_ADDR res = d + x;
2810 if (rb)
2811 {
2812 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + rb, &b);
2813 res += b;
2814 }
2815 return s390_record_address_mask (gdbarch, regcache, res);
2816}
2817
2818/* Calculates memory address using raw x, b + d/dl, dh fields from
2819 instruction. rx and dh should be set to 0 if unused. */
2820
2821static CORE_ADDR
2822s390_record_calc_disp (struct gdbarch *gdbarch, struct regcache *regcache,
2823 uint8_t rx, uint16_t bd, int8_t dh)
2824{
2825 ULONGEST x = 0;
2826 if (rx)
2827 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + rx, &x);
2828 return s390_record_calc_disp_common (gdbarch, regcache, x, bd, dh);
2829}
2830
2831/* Calculates memory address for VSCE[GF] instructions. */
2832
2833static int
2834s390_record_calc_disp_vsce (struct gdbarch *gdbarch, struct regcache *regcache,
2835 uint8_t vx, uint8_t el, uint8_t es, uint16_t bd,
2836 int8_t dh, CORE_ADDR *res)
2837{
2838 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
2839 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
2840 ULONGEST x;
2841 gdb_byte buf[16];
2842 if (tdep->v0_full_regnum == -1 || el * es >= 16)
2843 return -1;
2844 if (vx < 16)
dca08e1f 2845 regcache->cooked_read (tdep->v0_full_regnum + vx, buf);
ef8914a4 2846 else
0b883586 2847 regcache->raw_read (S390_V16_REGNUM + vx - 16, buf);
ef8914a4
PR
2848 x = extract_unsigned_integer (buf + el * es, es, byte_order);
2849 *res = s390_record_calc_disp_common (gdbarch, regcache, x, bd, dh);
2850 return 0;
2851}
2852
2853/* Calculates memory address for instructions with relative long addressing. */
2854
2855static CORE_ADDR
2856s390_record_calc_rl (struct gdbarch *gdbarch, struct regcache *regcache,
2857 CORE_ADDR addr, uint16_t i1, uint16_t i2)
2858{
2859 int32_t ri = i1 << 16 | i2;
2860 return s390_record_address_mask (gdbarch, regcache, addr + (LONGEST)ri * 2);
2861}
2862
2863/* Population count helper. */
2864
2865static int s390_popcnt (unsigned int x) {
2866 int res = 0;
2867 while (x)
2868 {
2869 if (x & 1)
2870 res++;
2871 x >>= 1;
2872 }
2873 return res;
2874}
2875
2876/* Record 64-bit register. */
2877
2878static int
2879s390_record_gpr_g (struct gdbarch *gdbarch, struct regcache *regcache, int i)
2880{
2881 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
2882 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + i))
2883 return -1;
2884 if (tdep->abi == ABI_LINUX_S390)
2885 if (record_full_arch_list_add_reg (regcache, S390_R0_UPPER_REGNUM + i))
2886 return -1;
2887 return 0;
2888}
2889
2890/* Record high 32 bits of a register. */
2891
2892static int
2893s390_record_gpr_h (struct gdbarch *gdbarch, struct regcache *regcache, int i)
2894{
2895 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
2896 if (tdep->abi == ABI_LINUX_S390)
2897 {
2898 if (record_full_arch_list_add_reg (regcache, S390_R0_UPPER_REGNUM + i))
2899 return -1;
2900 }
2901 else
2902 {
2903 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + i))
2904 return -1;
2905 }
2906 return 0;
2907}
2908
2909/* Record vector register. */
2910
2911static int
2912s390_record_vr (struct gdbarch *gdbarch, struct regcache *regcache, int i)
2913{
2914 if (i < 16)
2915 {
2916 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + i))
2917 return -1;
2918 if (record_full_arch_list_add_reg (regcache, S390_V0_LOWER_REGNUM + i))
2919 return -1;
2920 }
2921 else
2922 {
2923 if (record_full_arch_list_add_reg (regcache, S390_V16_REGNUM + i - 16))
2924 return -1;
2925 }
2926 return 0;
2927}
2928
2929/* Implement process_record gdbarch method. */
2930
2931static int
2932s390_process_record (struct gdbarch *gdbarch, struct regcache *regcache,
2933 CORE_ADDR addr)
2934{
2935 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
2936 uint16_t insn[3] = {0};
2937 /* Instruction as bytes. */
2938 uint8_t ibyte[6];
2939 /* Instruction as nibbles. */
2940 uint8_t inib[12];
2941 /* Instruction vector registers. */
2942 uint8_t ivec[4];
2943 CORE_ADDR oaddr, oaddr2, oaddr3;
2944 ULONGEST tmp;
2945 int i, n;
2946 /* if EX/EXRL instruction used, here's the reg parameter */
2947 int ex = -1;
2948 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
2949
2950 /* Attempting to use EX or EXRL jumps back here */
2951ex:
2952
2953 /* Read instruction. */
2954 insn[0] = read_memory_unsigned_integer (addr, 2, byte_order);
2955 /* If execute was involved, do the adjustment. */
2956 if (ex != -1)
2957 insn[0] |= ex & 0xff;
2958 /* Two highest bits determine instruction size. */
2959 if (insn[0] >= 0x4000)
2960 insn[1] = read_memory_unsigned_integer (addr+2, 2, byte_order);
2961 else
2962 /* Not necessary, but avoids uninitialized variable warnings. */
2963 insn[1] = 0;
2964 if (insn[0] >= 0xc000)
2965 insn[2] = read_memory_unsigned_integer (addr+4, 2, byte_order);
2966 else
2967 insn[2] = 0;
2968 /* Split instruction into bytes and nibbles. */
2969 for (i = 0; i < 3; i++)
2970 {
2971 ibyte[i*2] = insn[i] >> 8 & 0xff;
2972 ibyte[i*2+1] = insn[i] & 0xff;
2973 }
2974 for (i = 0; i < 6; i++)
2975 {
2976 inib[i*2] = ibyte[i] >> 4 & 0xf;
2977 inib[i*2+1] = ibyte[i] & 0xf;
2978 }
2979 /* Compute vector registers, if applicable. */
2980 ivec[0] = (inib[9] >> 3 & 1) << 4 | inib[2];
2981 ivec[1] = (inib[9] >> 2 & 1) << 4 | inib[3];
2982 ivec[2] = (inib[9] >> 1 & 1) << 4 | inib[4];
2983 ivec[3] = (inib[9] >> 0 & 1) << 4 | inib[8];
2984
2985 switch (ibyte[0])
2986 {
2987 /* 0x00 undefined */
2988
2989 case 0x01:
2990 /* E-format instruction */
2991 switch (ibyte[1])
2992 {
2993 /* 0x00 undefined */
2994 /* 0x01 unsupported: PR - program return */
2995 /* 0x02 unsupported: UPT */
2996 /* 0x03 undefined */
2997 /* 0x04 privileged: PTFF - perform timing facility function */
2998 /* 0x05-0x06 undefined */
2999 /* 0x07 privileged: SCKPF - set clock programmable field */
3000 /* 0x08-0x09 undefined */
3001
3002 case 0x0a: /* PFPO - perform floating point operation */
3003 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM, &tmp);
3004 if (!(tmp & 0x80000000u))
3005 {
3006 uint8_t ofc = tmp >> 16 & 0xff;
3007 switch (ofc)
3008 {
3009 case 0x00: /* HFP32 */
3010 case 0x01: /* HFP64 */
3011 case 0x05: /* BFP32 */
3012 case 0x06: /* BFP64 */
3013 case 0x08: /* DFP32 */
3014 case 0x09: /* DFP64 */
3015 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM))
3016 return -1;
3017 break;
3018 case 0x02: /* HFP128 */
3019 case 0x07: /* BFP128 */
3020 case 0x0a: /* DFP128 */
3021 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM))
3022 return -1;
3023 if (record_full_arch_list_add_reg (regcache, S390_F2_REGNUM))
3024 return -1;
3025 break;
3026 default:
3027 fprintf_unfiltered (gdb_stdlog, "Warning: Unknown PFPO OFC %02x at %s.\n",
3028 ofc, paddress (gdbarch, addr));
3029 return -1;
3030 }
3031
3032 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
3033 return -1;
3034 }
3035 if (record_full_arch_list_add_reg (regcache, S390_R1_REGNUM))
3036 return -1;
3037 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
3038 return -1;
3039 break;
3040
3041 case 0x0b: /* TAM - test address mode */
3042 case 0x0c: /* SAM24 - set address mode 24 */
3043 case 0x0d: /* SAM31 - set address mode 31 */
3044 case 0x0e: /* SAM64 - set address mode 64 */
3045 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
3046 return -1;
3047 break;
3048
3049 /* 0x0f-0xfe undefined */
3050
3051 /* 0xff unsupported: TRAP */
3052
3053 default:
3054 goto UNKNOWN_OP;
3055 }
3056 break;
3057
3058 /* 0x02 undefined */
3059 /* 0x03 undefined */
3060
3061 case 0x04: /* SPM - set program mask */
3062 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
3063 return -1;
3064 break;
3065
3066 case 0x05: /* BALR - branch and link */
3067 case 0x45: /* BAL - branch and link */
3068 case 0x06: /* BCTR - branch on count */
3069 case 0x46: /* BCT - branch on count */
3070 case 0x0d: /* BASR - branch and save */
3071 case 0x4d: /* BAS - branch and save */
3072 case 0x84: /* BRXH - branch relative on index high */
3073 case 0x85: /* BRXLE - branch relative on index low or equal */
3074 case 0x86: /* BXH - branch on index high */
3075 case 0x87: /* BXLE - branch on index low or equal */
3076 /* BA[SL]* use native-size destination for linkage info, BCT*, BRX*, BX*
3077 use 32-bit destination as counter. */
3078 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
3079 return -1;
3080 break;
3081
3082 case 0x07: /* BCR - branch on condition */
3083 case 0x47: /* BC - branch on condition */
3084 /* No effect other than PC transfer. */
3085 break;
3086
3087 /* 0x08 undefined */
3088 /* 0x09 undefined */
3089
3090 case 0x0a:
3091 /* SVC - supervisor call */
3092 if (tdep->s390_syscall_record != NULL)
3093 {
3094 if (tdep->s390_syscall_record (regcache, ibyte[1]))
3095 return -1;
3096 }
3097 else
3098 {
3099 printf_unfiltered (_("no syscall record support\n"));
3100 return -1;
3101 }
3102 break;
3103
3104 case 0x0b: /* BSM - branch and set mode */
3105 if (inib[2])
3106 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
3107 return -1;
3108 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
3109 return -1;
3110 break;
3111
3112 case 0x0c: /* BASSM - branch and save and set mode */
3113 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
3114 return -1;
3115 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
3116 return -1;
3117 break;
3118
3119 case 0x0e: /* MVCL - move long [interruptible] */
3120 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + inib[2], &tmp);
3121 oaddr = s390_record_address_mask (gdbarch, regcache, tmp);
3122 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + (inib[2] | 1), &tmp);
3123 tmp &= 0xffffff;
3124 if (record_full_arch_list_add_mem (oaddr, tmp))
3125 return -1;
3126 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
3127 return -1;
3128 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[2] | 1)))
3129 return -1;
3130 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[3]))
3131 return -1;
3132 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[3] | 1)))
3133 return -1;
3134 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
3135 return -1;
3136 break;
3137
3138 case 0x0f: /* CLCL - compare logical long [interruptible] */
3139 case 0xa9: /* CLCLE - compare logical long extended [partial] */
3140 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
3141 return -1;
3142 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[2] | 1)))
3143 return -1;
3144 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[3]))
3145 return -1;
3146 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[3] | 1)))
3147 return -1;
3148 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
3149 return -1;
3150 break;
3151
3152 case 0x10: /* LPR - load positive */
3153 case 0x11: /* LNR - load negative */
3154 case 0x12: /* LTR - load and test */
3155 case 0x13: /* LCR - load complement */
3156 case 0x14: /* NR - and */
3157 case 0x16: /* OR - or */
3158 case 0x17: /* XR - xor */
3159 case 0x1a: /* AR - add */
3160 case 0x1b: /* SR - subtract */
3161 case 0x1e: /* ALR - add logical */
3162 case 0x1f: /* SLR - subtract logical */
3163 case 0x54: /* N - and */
3164 case 0x56: /* O - or */
3165 case 0x57: /* X - xor */
3166 case 0x5a: /* A - add */
3167 case 0x5b: /* S - subtract */
3168 case 0x5e: /* AL - add logical */
3169 case 0x5f: /* SL - subtract logical */
3170 case 0x4a: /* AH - add halfword */
3171 case 0x4b: /* SH - subtract halfword */
3172 case 0x8a: /* SRA - shift right single */
3173 case 0x8b: /* SLA - shift left single */
3174 case 0xbf: /* ICM - insert characters under mask */
3175 /* 32-bit destination + flags */
3176 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
3177 return -1;
3178 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
3179 return -1;
3180 break;
3181
3182 case 0x15: /* CLR - compare logical */
3183 case 0x55: /* CL - compare logical */
3184 case 0x19: /* CR - compare */
3185 case 0x29: /* CDR - compare */
3186 case 0x39: /* CER - compare */
3187 case 0x49: /* CH - compare halfword */
3188 case 0x59: /* C - compare */
3189 case 0x69: /* CD - compare */
3190 case 0x79: /* CE - compare */
3191 case 0x91: /* TM - test under mask */
3192 case 0x95: /* CLI - compare logical */
3193 case 0xbd: /* CLM - compare logical under mask */
3194 case 0xd5: /* CLC - compare logical */
3195 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
3196 return -1;
3197 break;
3198
3199 case 0x18: /* LR - load */
3200 case 0x48: /* LH - load halfword */
3201 case 0x58: /* L - load */
3202 case 0x41: /* LA - load address */
3203 case 0x43: /* IC - insert character */
3204 case 0x4c: /* MH - multiply halfword */
3205 case 0x71: /* MS - multiply single */
3206 case 0x88: /* SRL - shift right single logical */
3207 case 0x89: /* SLL - shift left single logical */
3208 /* 32-bit, 8-bit (IC), or native width (LA) destination, no flags */
3209 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
3210 return -1;
3211 break;
3212
3213 case 0x1c: /* MR - multiply */
3214 case 0x5c: /* M - multiply */
3215 case 0x1d: /* DR - divide */
3216 case 0x5d: /* D - divide */
3217 case 0x8c: /* SRDL - shift right double logical */
3218 case 0x8d: /* SLDL - shift left double logical */
3219 /* 32-bit pair destination, no flags */
3220 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
3221 return -1;
3222 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[2] | 1)))
3223 return -1;
3224 break;
3225
3226 case 0x20: /* LPDR - load positive */
3227 case 0x30: /* LPER - load positive */
3228 case 0x21: /* LNDR - load negative */
3229 case 0x31: /* LNER - load negative */
3230 case 0x22: /* LTDR - load and test */
3231 case 0x32: /* LTER - load and test */
3232 case 0x23: /* LCDR - load complement */
3233 case 0x33: /* LCER - load complement */
3234 case 0x2a: /* ADR - add */
3235 case 0x3a: /* AER - add */
3236 case 0x6a: /* AD - add */
3237 case 0x7a: /* AE - add */
3238 case 0x2b: /* SDR - subtract */
3239 case 0x3b: /* SER - subtract */
3240 case 0x6b: /* SD - subtract */
3241 case 0x7b: /* SE - subtract */
3242 case 0x2e: /* AWR - add unnormalized */
3243 case 0x3e: /* AUR - add unnormalized */
3244 case 0x6e: /* AW - add unnormalized */
3245 case 0x7e: /* AU - add unnormalized */
3246 case 0x2f: /* SWR - subtract unnormalized */
3247 case 0x3f: /* SUR - subtract unnormalized */
3248 case 0x6f: /* SW - subtract unnormalized */
3249 case 0x7f: /* SU - subtract unnormalized */
3250 /* float destination + flags */
3251 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[2]))
3252 return -1;
3253 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
3254 return -1;
3255 break;
3256
3257 case 0x24: /* HDR - halve */
3258 case 0x34: /* HER - halve */
3259 case 0x25: /* LDXR - load rounded */
3260 case 0x35: /* LEDR - load rounded */
3261 case 0x28: /* LDR - load */
3262 case 0x38: /* LER - load */
3263 case 0x68: /* LD - load */
3264 case 0x78: /* LE - load */
3265 case 0x2c: /* MDR - multiply */
3266 case 0x3c: /* MDER - multiply */
3267 case 0x6c: /* MD - multiply */
3268 case 0x7c: /* MDE - multiply */
3269 case 0x2d: /* DDR - divide */
3270 case 0x3d: /* DER - divide */
3271 case 0x6d: /* DD - divide */
3272 case 0x7d: /* DE - divide */
3273 /* float destination, no flags */
3274 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[2]))
3275 return -1;
3276 break;
3277
3278 case 0x26: /* MXR - multiply */
3279 case 0x27: /* MXDR - multiply */
3280 case 0x67: /* MXD - multiply */
3281 /* float pair destination, no flags */
3282 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[2]))
3283 return -1;
3284 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + (inib[2] | 2)))
3285 return -1;
3286 break;
3287
3288 case 0x36: /* AXR - add */
3289 case 0x37: /* SXR - subtract */
3290 /* float pair destination + flags */
3291 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[2]))
3292 return -1;
3293 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + (inib[2] | 2)))
3294 return -1;
3295 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
3296 return -1;
3297 break;
3298
3299 case 0x40: /* STH - store halfword */
3300 oaddr = s390_record_calc_disp (gdbarch, regcache, inib[3], insn[1], 0);
3301 if (record_full_arch_list_add_mem (oaddr, 2))
3302 return -1;
3303 break;
3304
3305 case 0x42: /* STC - store character */
3306 oaddr = s390_record_calc_disp (gdbarch, regcache, inib[3], insn[1], 0);
3307 if (record_full_arch_list_add_mem (oaddr, 1))
3308 return -1;
3309 break;
3310
3311 case 0x44: /* EX - execute */
3312 if (ex != -1)
3313 {
3314 fprintf_unfiltered (gdb_stdlog, "Warning: Double execute at %s.\n",
3315 paddress (gdbarch, addr));
3316 return -1;
3317 }
3318 addr = s390_record_calc_disp (gdbarch, regcache, inib[3], insn[1], 0);
3319 if (inib[2])
3320 {
3321 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + inib[2], &tmp);
3322 ex = tmp & 0xff;
3323 }
3324 else
3325 {
3326 ex = 0;
3327 }
3328 goto ex;
3329
3330 case 0x4e: /* CVD - convert to decimal */
3331 case 0x60: /* STD - store */
3332 oaddr = s390_record_calc_disp (gdbarch, regcache, inib[3], insn[1], 0);
3333 if (record_full_arch_list_add_mem (oaddr, 8))
3334 return -1;
3335 break;
3336
3337 case 0x4f: /* CVB - convert to binary */
3338 /* 32-bit gpr destination + FPC (DXC write) */
3339 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
3340 return -1;
3341 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
3342 return -1;
3343 break;
3344
3345 case 0x50: /* ST - store */
3346 case 0x70: /* STE - store */
3347 oaddr = s390_record_calc_disp (gdbarch, regcache, inib[3], insn[1], 0);
3348 if (record_full_arch_list_add_mem (oaddr, 4))
3349 return -1;
3350 break;
3351
3352 case 0x51: /* LAE - load address extended */
3353 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
3354 return -1;
3355 if (record_full_arch_list_add_reg (regcache, S390_A0_REGNUM + inib[2]))
3356 return -1;
3357 break;
3358
3359 /* 0x52 undefined */
3360 /* 0x53 undefined */
3361
3362 /* 0x61-0x66 undefined */
3363
3364 /* 0x72-0x77 undefined */
3365
3366 /* 0x80 privileged: SSM - set system mask */
3367 /* 0x81 undefined */
3368 /* 0x82 privileged: LPSW - load PSW */
3369 /* 0x83 privileged: diagnose */
3370
3371 case 0x8e: /* SRDA - shift right double */
3372 case 0x8f: /* SLDA - shift left double */
3373 /* 32-bit pair destination + flags */
3374 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
3375 return -1;
3376 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[2] | 1)))
3377 return -1;
3378 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
3379 return -1;
3380 break;
3381
3382 case 0x90: /* STM - store multiple */
3383 case 0x9b: /* STAM - store access multiple */
3384 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
3385 if (inib[2] <= inib[3])
3386 n = inib[3] - inib[2] + 1;
3387 else
3388 n = inib[3] + 0x10 - inib[2] + 1;
3389 if (record_full_arch_list_add_mem (oaddr, n * 4))
3390 return -1;
3391 break;
3392
3393 case 0x92: /* MVI - move */
3394 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
3395 if (record_full_arch_list_add_mem (oaddr, 1))
3396 return -1;
3397 break;
3398
3399 case 0x93: /* TS - test and set */
3400 case 0x94: /* NI - and */
3401 case 0x96: /* OI - or */
3402 case 0x97: /* XI - xor */
3403 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
3404 if (record_full_arch_list_add_mem (oaddr, 1))
3405 return -1;
3406 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
3407 return -1;
3408 break;
3409
3410 case 0x98: /* LM - load multiple */
3411 for (i = inib[2]; i != inib[3]; i++, i &= 0xf)
3412 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + i))
3413 return -1;
3414 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[3]))
3415 return -1;
3416 break;
3417
3418 /* 0x99 privileged: TRACE */
3419
3420 case 0x9a: /* LAM - load access multiple */
3421 for (i = inib[2]; i != inib[3]; i++, i &= 0xf)
3422 if (record_full_arch_list_add_reg (regcache, S390_A0_REGNUM + i))
3423 return -1;
3424 if (record_full_arch_list_add_reg (regcache, S390_A0_REGNUM + inib[3]))
3425 return -1;
3426 break;
3427
3428 /* 0x9c-0x9f privileged and obsolete (old I/O) */
3429 /* 0xa0-0xa4 undefined */
3430
3431 case 0xa5:
3432 case 0xa7:
3433 /* RI-format instruction */
3434 switch (ibyte[0] << 4 | inib[3])
3435 {
3436 case 0xa50: /* IIHH - insert immediate */
3437 case 0xa51: /* IIHL - insert immediate */
3438 /* high 32-bit destination */
3439 if (s390_record_gpr_h (gdbarch, regcache, inib[2]))
3440 return -1;
3441 break;
3442
3443 case 0xa52: /* IILH - insert immediate */
3444 case 0xa53: /* IILL - insert immediate */
3445 case 0xa75: /* BRAS - branch relative and save */
3446 case 0xa76: /* BRCT - branch relative on count */
3447 case 0xa78: /* LHI - load halfword immediate */
3448 case 0xa7c: /* MHI - multiply halfword immediate */
3449 /* 32-bit or native destination */
3450 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
3451 return -1;
3452 break;
3453
3454 case 0xa54: /* NIHH - and immediate */
3455 case 0xa55: /* NIHL - and immediate */
3456 case 0xa58: /* OIHH - or immediate */
3457 case 0xa59: /* OIHL - or immediate */
3458 /* high 32-bit destination + flags */
3459 if (s390_record_gpr_h (gdbarch, regcache, inib[2]))
3460 return -1;
3461 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
3462 return -1;
3463 break;
3464
3465 case 0xa56: /* NILH - and immediate */
3466 case 0xa57: /* NILL - and immediate */
3467 case 0xa5a: /* OILH - or immediate */
3468 case 0xa5b: /* OILL - or immediate */
3469 case 0xa7a: /* AHI - add halfword immediate */
3470 /* 32-bit destination + flags */
3471 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
3472 return -1;
3473 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
3474 return -1;
3475 break;
3476
3477 case 0xa5c: /* LLIHH - load logical immediate */
3478 case 0xa5d: /* LLIHL - load logical immediate */
3479 case 0xa5e: /* LLILH - load logical immediate */
3480 case 0xa5f: /* LLILL - load logical immediate */
3481 case 0xa77: /* BRCTG - branch relative on count */
3482 case 0xa79: /* LGHI - load halfword immediate */
3483 case 0xa7d: /* MGHI - multiply halfword immediate */
3484 /* 64-bit destination */
3485 if (s390_record_gpr_g (gdbarch, regcache, inib[2]))
3486 return -1;
3487 break;
3488
3489 case 0xa70: /* TMLH - test under mask */
3490 case 0xa71: /* TMLL - test under mask */
3491 case 0xa72: /* TMHH - test under mask */
3492 case 0xa73: /* TMHL - test under mask */
3493 case 0xa7e: /* CHI - compare halfword immediate */
3494 case 0xa7f: /* CGHI - compare halfword immediate */
3495 /* flags only */
3496 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
3497 return -1;
3498 break;
3499
3500 case 0xa74: /* BRC - branch relative on condition */
3501 /* no register change */
3502 break;
3503
3504 case 0xa7b: /* AGHI - add halfword immediate */
3505 /* 64-bit destination + flags */
3506 if (s390_record_gpr_g (gdbarch, regcache, inib[2]))
3507 return -1;
3508 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
3509 return -1;
3510 break;
3511
3512 default:
3513 goto UNKNOWN_OP;
3514 }
3515 break;
3516
3517 /* 0xa6 undefined */
3518
3519 case 0xa8: /* MVCLE - move long extended [partial] */
3520 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + inib[2], &tmp);
3521 oaddr = s390_record_address_mask (gdbarch, regcache, tmp);
3522 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + (inib[2] | 1), &tmp);
3523 if (record_full_arch_list_add_mem (oaddr, tmp))
3524 return -1;
3525 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
3526 return -1;
3527 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[2] | 1)))
3528 return -1;
3529 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[3]))
3530 return -1;
3531 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[3] | 1)))
3532 return -1;
3533 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
3534 return -1;
3535 break;
3536
3537 /* 0xaa-0xab undefined */
3538 /* 0xac privileged: STNSM - store then and system mask */
3539 /* 0xad privileged: STOSM - store then or system mask */
3540 /* 0xae privileged: SIGP - signal processor */
3541 /* 0xaf unsupported: MC - monitor call */
3542 /* 0xb0 undefined */
3543 /* 0xb1 privileged: LRA - load real address */
3544
3545 case 0xb2:
3546 case 0xb3:
3547 case 0xb9:
3548 /* S/RRD/RRE/RRF/IE-format instruction */
3549 switch (insn[0])
3550 {
3551 /* 0xb200-0xb204 undefined or privileged */
3552
3553 case 0xb205: /* STCK - store clock */
3554 case 0xb27c: /* STCKF - store clock fast */
3555 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
3556 if (record_full_arch_list_add_mem (oaddr, 8))
3557 return -1;
3558 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
3559 return -1;
3560 break;
3561
3562 /* 0xb206-0xb219 undefined, privileged, or unsupported */
3563 /* 0xb21a unsupported: CFC */
3564 /* 0xb21b-0xb221 undefined or privileged */
3565
3566 case 0xb222: /* IPM - insert program mask */
3567 case 0xb24f: /* EAR - extract access */
3568 case 0xb252: /* MSR - multiply single */
3569 case 0xb2ec: /* ETND - extract transaction nesting depth */
3570 case 0xb38c: /* EFPC - extract fpc */
3571 case 0xb91f: /* LRVR - load reversed */
3572 case 0xb926: /* LBR - load byte */
3573 case 0xb927: /* LHR - load halfword */
3574 case 0xb994: /* LLCR - load logical character */
3575 case 0xb995: /* LLHR - load logical halfword */
3576 case 0xb9f2: /* LOCR - load on condition */
3577 /* 32-bit gpr destination */
3578 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[6]))
3579 return -1;
3580 break;
3581
3582 /* 0xb223-0xb22c privileged or unsupported */
3583
3584 case 0xb22d: /* DXR - divide */
3585 case 0xb325: /* LXDR - load lengthened */
3586 case 0xb326: /* LXER - load lengthened */
3587 case 0xb336: /* SQXR - square root */
3588 case 0xb365: /* LXR - load */
3589 case 0xb367: /* FIXR - load fp integer */
3590 case 0xb376: /* LZXR - load zero */
3591 case 0xb3b6: /* CXFR - convert from fixed */
3592 case 0xb3c6: /* CXGR - convert from fixed */
3593 case 0xb3fe: /* IEXTR - insert biased exponent */
3594 /* float pair destination */
3595 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[6]))
3596 return -1;
3597 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + (inib[6] | 2)))
3598 return -1;
3599 break;
3600
3601 /* 0xb22e-0xb240 undefined, privileged, or unsupported */
3602
3603 case 0xb241: /* CKSM - checksum [partial] */
3604 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[6]))
3605 return -1;
3606 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[7]))
3607 return -1;
3608 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[7] | 1)))
3609 return -1;
3610 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
3611 return -1;
3612 break;
3613
3614 /* 0xb242-0xb243 undefined */
3615
3616 case 0xb244: /* SQDR - square root */
3617 case 0xb245: /* SQER - square root */
3618 case 0xb324: /* LDER - load lengthened */
3619 case 0xb337: /* MEER - multiply */
3620 case 0xb366: /* LEXR - load rounded */
3621 case 0xb370: /* LPDFR - load positive */
3622 case 0xb371: /* LNDFR - load negative */
3623 case 0xb372: /* CSDFR - copy sign */
3624 case 0xb373: /* LCDFR - load complement */
3625 case 0xb374: /* LZER - load zero */
3626 case 0xb375: /* LZDR - load zero */
3627 case 0xb377: /* FIER - load fp integer */
3628 case 0xb37f: /* FIDR - load fp integer */
3629 case 0xb3b4: /* CEFR - convert from fixed */
3630 case 0xb3b5: /* CDFR - convert from fixed */
3631 case 0xb3c1: /* LDGR - load fpr from gr */
3632 case 0xb3c4: /* CEGR - convert from fixed */
3633 case 0xb3c5: /* CDGR - convert from fixed */
3634 case 0xb3f6: /* IEDTR - insert biased exponent */
3635 /* float destination */
3636 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[6]))
3637 return -1;
3638 break;
3639
3640 /* 0xb246-0xb24c: privileged or unsupported */
3641
3642 case 0xb24d: /* CPYA - copy access */
3643 case 0xb24e: /* SAR - set access */
3644 if (record_full_arch_list_add_reg (regcache, S390_A0_REGNUM + inib[6]))
3645 return -1;
3646 break;
3647
3648 /* 0xb250-0xb251 undefined or privileged */
3649 /* 0xb253-0xb254 undefined or privileged */
3650
3651 case 0xb255: /* MVST - move string [partial] */
3652 {
3653 uint8_t end;
3654 gdb_byte cur;
3655 ULONGEST num = 0;
3656 /* Read ending byte. */
3657 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM, &tmp);
3658 end = tmp & 0xff;
3659 /* Get address of second operand. */
3660 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + inib[7], &tmp);
3661 oaddr = s390_record_address_mask (gdbarch, regcache, tmp);
3662 /* Search for ending byte and compute length. */
3663 do {
3664 num++;
3665 if (target_read_memory (oaddr, &cur, 1))
3666 return -1;
3667 oaddr++;
3668 } while (cur != end);
3669 /* Get address of first operand and record it. */
3670 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + inib[6], &tmp);
3671 oaddr = s390_record_address_mask (gdbarch, regcache, tmp);
3672 if (record_full_arch_list_add_mem (oaddr, num))
3673 return -1;
3674 /* Record the registers. */
3675 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[6]))
3676 return -1;
3677 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[7]))
3678 return -1;
3679 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
3680 return -1;
3681 }
3682 break;
3683
3684 /* 0xb256 undefined */
3685
3686 case 0xb257: /* CUSE - compare until substring equal [interruptible] */
3687 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[6]))
3688 return -1;
3689 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[6] | 1)))
3690 return -1;
3691 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[7]))
3692 return -1;
3693 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[7] | 1)))
3694 return -1;
3695 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
3696 return -1;
3697 break;
3698
3699 /* 0xb258-0xb25c undefined, privileged, or unsupported */
3700
3701 case 0xb25d: /* CLST - compare logical string [partial] */
3702 case 0xb25e: /* SRST - search string [partial] */
3703 case 0xb9be: /* SRSTU - search string unicode [partial] */
3704 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[6]))
3705 return -1;
3706 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[7]))
3707 return -1;
3708 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
3709 return -1;
3710 break;
3711
3712 /* 0xb25f-0xb262 undefined */
3713
3714 case 0xb263: /* CMPSC - compression call [interruptible] */
3715 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + inib[6], &tmp);
3716 oaddr = s390_record_address_mask (gdbarch, regcache, tmp);
3717 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + (inib[6] | 1), &tmp);
3718 if (record_full_arch_list_add_mem (oaddr, tmp))
3719 return -1;
3720 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[6]))
3721 return -1;
3722 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[6] | 1)))
3723 return -1;
3724 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[7]))
3725 return -1;
3726 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[7] | 1)))
3727 return -1;
3728 if (record_full_arch_list_add_reg (regcache, S390_R1_REGNUM))
3729 return -1;
3730 /* DXC may be written */
3731 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
3732 return -1;
3733 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
3734 return -1;
3735 break;
3736
3737 /* 0xb264-0xb277 undefined, privileged, or unsupported */
3738
3739 case 0xb278: /* STCKE - store clock extended */
3740 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
3741 if (record_full_arch_list_add_mem (oaddr, 16))
3742 return -1;
3743 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
3744 return -1;
3745 break;
3746
3747 /* 0xb279-0xb27b undefined or unsupported */
3748 /* 0xb27d-0xb298 undefined or privileged */
3749
3750 case 0xb299: /* SRNM - set rounding mode */
3751 case 0xb2b8: /* SRNMB - set bfp rounding mode */
3752 case 0xb2b9: /* SRNMT - set dfp rounding mode */
3753 case 0xb29d: /* LFPC - load fpc */
3754 case 0xb2bd: /* LFAS - load fpc and signal */
3755 case 0xb384: /* SFPC - set fpc */
3756 case 0xb385: /* SFASR - set fpc and signal */
3757 case 0xb960: /* CGRT - compare and trap */
3758 case 0xb961: /* CLGRT - compare logical and trap */
3759 case 0xb972: /* CRT - compare and trap */
3760 case 0xb973: /* CLRT - compare logical and trap */
3761 /* fpc only - including possible DXC write for trapping insns */
3762 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
3763 return -1;
3764 break;
3765
3766 /* 0xb29a-0xb29b undefined */
3767
3768 case 0xb29c: /* STFPC - store fpc */
3769 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
3770 if (record_full_arch_list_add_mem (oaddr, 4))
3771 return -1;
3772 break;
3773
3774 /* 0xb29e-0xb2a4 undefined */
3775
3776 case 0xb2a5: /* TRE - translate extended [partial] */
3777 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + inib[6], &tmp);
3778 oaddr = s390_record_address_mask (gdbarch, regcache, tmp);
3779 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + (inib[6] | 1), &tmp);
3780 if (record_full_arch_list_add_mem (oaddr, tmp))
3781 return -1;
3782 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[6]))
3783 return -1;
3784 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[6] | 1)))
3785 return -1;
3786 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
3787 return -1;
3788 break;
3789
3790 case 0xb2a6: /* CU21 - convert UTF-16 to UTF-8 [partial] */
3791 case 0xb2a7: /* CU12 - convert UTF-8 to UTF-16 [partial] */
3792 case 0xb9b0: /* CU14 - convert UTF-8 to UTF-32 [partial] */
3793 case 0xb9b1: /* CU24 - convert UTF-16 to UTF-32 [partial] */
3794 case 0xb9b2: /* CU41 - convert UTF-32 to UTF-8 [partial] */
3795 case 0xb9b3: /* CU42 - convert UTF-32 to UTF-16 [partial] */
3796 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + inib[6], &tmp);
3797 oaddr = s390_record_address_mask (gdbarch, regcache, tmp);
3798 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + (inib[6] | 1), &tmp);
3799 if (record_full_arch_list_add_mem (oaddr, tmp))
3800 return -1;
3801 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[6]))
3802 return -1;
3803 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[6] | 1)))
3804 return -1;
3805 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[7]))
3806 return -1;
3807 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[7] | 1)))
3808 return -1;
3809 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
3810 return -1;
3811 break;
3812
3813 /* 0xb2a8-0xb2af undefined */
3814
3815 case 0xb2b0: /* STFLE - store facility list extended */
3816 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
3817 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM, &tmp);
3818 tmp &= 0xff;
3819 if (record_full_arch_list_add_mem (oaddr, 8 * (tmp + 1)))
3820 return -1;
3821 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM))
3822 return -1;
3823 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
3824 return -1;
3825 break;
3826
3827 /* 0xb2b1-0xb2b7 undefined or privileged */
3828 /* 0xb2ba-0xb2bc undefined */
3829 /* 0xb2be-0xb2e7 undefined */
3830 /* 0xb2e9-0xb2eb undefined */
3831 /* 0xb2ed-0xb2f7 undefined */
3832 /* 0xb2f8 unsupported: TEND */
3833 /* 0xb2f9 undefined */
3834
3835 case 0xb2e8: /* PPA - perform processor assist */
3836 case 0xb2fa: /* NIAI - next instruction access intent */
3837 /* no visible effects */
3838 break;
3839
3840 /* 0xb2fb undefined */
3841 /* 0xb2fc unsupported: TABORT */
3842 /* 0xb2fd-0xb2fe undefined */
3843 /* 0xb2ff unsupported: TRAP */
3844
3845 case 0xb300: /* LPEBR - load positive */
3846 case 0xb301: /* LNEBR - load negative */
3847 case 0xb303: /* LCEBR - load complement */
3848 case 0xb310: /* LPDBR - load positive */
3849 case 0xb311: /* LNDBR - load negative */
3850 case 0xb313: /* LCDBR - load complement */
3851 case 0xb350: /* TBEDR - convert hfp to bfp */
3852 case 0xb351: /* TBDR - convert hfp to bfp */
3853 case 0xb358: /* THDER - convert bfp to hfp */
3854 case 0xb359: /* THDR - convert bfp to hfp */
3855 /* float destination + flags */
3856 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[6]))
3857 return -1;
3858 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
3859 return -1;
3860 break;
3861
3862 case 0xb304: /* LDEBR - load lengthened */
3863 case 0xb30c: /* MDEBR - multiply */
3864 case 0xb30d: /* DEBR - divide */
3865 case 0xb314: /* SQEBR - square root */
3866 case 0xb315: /* SQDBR - square root */
3867 case 0xb317: /* MEEBR - multiply */
3868 case 0xb31c: /* MDBR - multiply */
3869 case 0xb31d: /* DDBR - divide */
3870 case 0xb344: /* LEDBRA - load rounded */
3871 case 0xb345: /* LDXBRA - load rounded */
3872 case 0xb346: /* LEXBRA - load rounded */
3873 case 0xb357: /* FIEBRA - load fp integer */
3874 case 0xb35f: /* FIDBRA - load fp integer */
3875 case 0xb390: /* CELFBR - convert from logical */
3876 case 0xb391: /* CDLFBR - convert from logical */
3877 case 0xb394: /* CEFBR - convert from fixed */
3878 case 0xb395: /* CDFBR - convert from fixed */
3879 case 0xb3a0: /* CELGBR - convert from logical */
3880 case 0xb3a1: /* CDLGBR - convert from logical */
3881 case 0xb3a4: /* CEGBR - convert from fixed */
3882 case 0xb3a5: /* CDGBR - convert from fixed */
3883 case 0xb3d0: /* MDTR - multiply */
3884 case 0xb3d1: /* DDTR - divide */
3885 case 0xb3d4: /* LDETR - load lengthened */
3886 case 0xb3d5: /* LEDTR - load lengthened */
3887 case 0xb3d7: /* FIDTR - load fp integer */
3888 case 0xb3dd: /* LDXTR - load lengthened */
3889 case 0xb3f1: /* CDGTR - convert from fixed */
3890 case 0xb3f2: /* CDUTR - convert from unsigned packed */
3891 case 0xb3f3: /* CDSTR - convert from signed packed */
3892 case 0xb3f5: /* QADTR - quantize */
3893 case 0xb3f7: /* RRDTR - reround */
3894 case 0xb951: /* CDFTR - convert from fixed */
3895 case 0xb952: /* CDLGTR - convert from logical */
3896 case 0xb953: /* CDLFTR - convert from logical */
3897 /* float destination + fpc */
3898 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[6]))
3899 return -1;
3900 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
3901 return -1;
3902 break;
3903
3904 case 0xb305: /* LXDBR - load lengthened */
3905 case 0xb306: /* LXEBR - load lengthened */
3906 case 0xb307: /* MXDBR - multiply */
3907 case 0xb316: /* SQXBR - square root */
3908 case 0xb34c: /* MXBR - multiply */
3909 case 0xb34d: /* DXBR - divide */
3910 case 0xb347: /* FIXBRA - load fp integer */
3911 case 0xb392: /* CXLFBR - convert from logical */
3912 case 0xb396: /* CXFBR - convert from fixed */
3913 case 0xb3a2: /* CXLGBR - convert from logical */
3914 case 0xb3a6: /* CXGBR - convert from fixed */
3915 case 0xb3d8: /* MXTR - multiply */
3916 case 0xb3d9: /* DXTR - divide */
3917 case 0xb3dc: /* LXDTR - load lengthened */
3918 case 0xb3df: /* FIXTR - load fp integer */
3919 case 0xb3f9: /* CXGTR - convert from fixed */
3920 case 0xb3fa: /* CXUTR - convert from unsigned packed */
3921 case 0xb3fb: /* CXSTR - convert from signed packed */
3922 case 0xb3fd: /* QAXTR - quantize */
3923 case 0xb3ff: /* RRXTR - reround */
3924 case 0xb959: /* CXFTR - convert from fixed */
3925 case 0xb95a: /* CXLGTR - convert from logical */
3926 case 0xb95b: /* CXLFTR - convert from logical */
3927 /* float pair destination + fpc */
3928 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[6]))
3929 return -1;
3930 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + (inib[6] | 2)))
3931 return -1;
3932 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
3933 return -1;
3934 break;
3935
3936 case 0xb308: /* KEBR - compare and signal */
3937 case 0xb309: /* CEBR - compare */
3938 case 0xb318: /* KDBR - compare and signal */
3939 case 0xb319: /* CDBR - compare */
3940 case 0xb348: /* KXBR - compare and signal */
3941 case 0xb349: /* CXBR - compare */
3942 case 0xb3e0: /* KDTR - compare and signal */
3943 case 0xb3e4: /* CDTR - compare */
3944 case 0xb3e8: /* KXTR - compare and signal */
3945 case 0xb3ec: /* CXTR - compare */
3946 /* flags + fpc only */
3947 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
3948 return -1;
3949 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
3950 return -1;
3951 break;
3952
3953 case 0xb302: /* LTEBR - load and test */
3954 case 0xb312: /* LTDBR - load and test */
3955 case 0xb30a: /* AEBR - add */
3956 case 0xb30b: /* SEBR - subtract */
3957 case 0xb31a: /* ADBR - add */
3958 case 0xb31b: /* SDBR - subtract */
3959 case 0xb3d2: /* ADTR - add */
3960 case 0xb3d3: /* SDTR - subtract */
3961 case 0xb3d6: /* LTDTR - load and test */
3962 /* float destination + flags + fpc */
3963 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[6]))
3964 return -1;
3965 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
3966 return -1;
3967 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
3968 return -1;
3969 break;
3970
3971 case 0xb30e: /* MAEBR - multiply and add */
3972 case 0xb30f: /* MSEBR - multiply and subtract */
3973 case 0xb31e: /* MADBR - multiply and add */
3974 case 0xb31f: /* MSDBR - multiply and subtract */
3975 /* float destination [RRD] + fpc */
3976 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[4]))
3977 return -1;
3978 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
3979 return -1;
3980 break;
3981
3982 /* 0xb320-0xb323 undefined */
3983 /* 0xb327-0xb32d undefined */
3984
3985 case 0xb32e: /* MAER - multiply and add */
3986 case 0xb32f: /* MSER - multiply and subtract */
3987 case 0xb338: /* MAYLR - multiply and add unnormalized */
3988 case 0xb339: /* MYLR - multiply unnormalized */
3989 case 0xb33c: /* MAYHR - multiply and add unnormalized */
3990 case 0xb33d: /* MYHR - multiply unnormalized */
3991 case 0xb33e: /* MADR - multiply and add */
3992 case 0xb33f: /* MSDR - multiply and subtract */
3993 /* float destination [RRD] */
3994 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[4]))
3995 return -1;
3996 break;
3997
3998 /* 0xb330-0xb335 undefined */
3999
4000 case 0xb33a: /* MAYR - multiply and add unnormalized */
4001 case 0xb33b: /* MYR - multiply unnormalized */
4002 /* float pair destination [RRD] */
4003 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[4]))
4004 return -1;
4005 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + (inib[4] | 2)))
4006 return -1;
4007 break;
4008
4009 case 0xb340: /* LPXBR - load positive */
4010 case 0xb341: /* LNXBR - load negative */
4011 case 0xb343: /* LCXBR - load complement */
4012 case 0xb360: /* LPXR - load positive */
4013 case 0xb361: /* LNXR - load negative */
4014 case 0xb362: /* LTXR - load and test */
4015 case 0xb363: /* LCXR - load complement */
4016 /* float pair destination + flags */
4017 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[6]))
4018 return -1;
4019 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + (inib[6] | 2)))
4020 return -1;
4021 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
4022 return -1;
4023 break;
4024
4025 case 0xb342: /* LTXBR - load and test */
4026 case 0xb34a: /* AXBR - add */
4027 case 0xb34b: /* SXBR - subtract */
4028 case 0xb3da: /* AXTR - add */
4029 case 0xb3db: /* SXTR - subtract */
4030 case 0xb3de: /* LTXTR - load and test */
4031 /* float pair destination + flags + fpc */
4032 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[6]))
4033 return -1;
4034 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + (inib[6] | 2)))
4035 return -1;
4036 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
4037 return -1;
4038 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
4039 return -1;
4040 break;
4041
4042 /* 0xb34e-0xb34f undefined */
4043 /* 0xb352 undefined */
4044
4045 case 0xb353: /* DIEBR - divide to integer */
4046 case 0xb35b: /* DIDBR - divide to integer */
4047 /* two float destinations + flags + fpc */
4048 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[4]))
4049 return -1;
4050 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[6]))
4051 return -1;
4052 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
4053 return -1;
4054 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
4055 return -1;
4056 break;
4057
4058 /* 0xb354-0xb356 undefined */
4059 /* 0xb35a undefined */
4060
4061 /* 0xb35c-0xb35e undefined */
4062 /* 0xb364 undefined */
4063 /* 0xb368 undefined */
4064
4065 case 0xb369: /* CXR - compare */
4066 case 0xb3f4: /* CEDTR - compare biased exponent */
4067 case 0xb3fc: /* CEXTR - compare biased exponent */
4068 case 0xb920: /* CGR - compare */
4069 case 0xb921: /* CLGR - compare logical */
4070 case 0xb930: /* CGFR - compare */
4071 case 0xb931: /* CLGFR - compare logical */
4072 case 0xb9cd: /* CHHR - compare high */
4073 case 0xb9cf: /* CLHHR - compare logical high */
4074 case 0xb9dd: /* CHLR - compare high */
4075 case 0xb9df: /* CLHLR - compare logical high */
4076 /* flags only */
4077 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
4078 return -1;
4079 break;
4080
4081 /* 0xb36a-0xb36f undefined */
4082 /* 0xb377-0xb37e undefined */
4083 /* 0xb380-0xb383 undefined */
4084 /* 0xb386-0xb38b undefined */
4085 /* 0xb38d-0xb38f undefined */
4086 /* 0xb393 undefined */
4087 /* 0xb397 undefined */
4088
4089 case 0xb398: /* CFEBR - convert to fixed */
4090 case 0xb399: /* CFDBR - convert to fixed */
4091 case 0xb39a: /* CFXBR - convert to fixed */
4092 case 0xb39c: /* CLFEBR - convert to logical */
4093 case 0xb39d: /* CLFDBR - convert to logical */
4094 case 0xb39e: /* CLFXBR - convert to logical */
4095 case 0xb941: /* CFDTR - convert to fixed */
4096 case 0xb949: /* CFXTR - convert to fixed */
4097 case 0xb943: /* CLFDTR - convert to logical */
4098 case 0xb94b: /* CLFXTR - convert to logical */
4099 /* 32-bit gpr destination + flags + fpc */
4100 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[6]))
4101 return -1;
4102 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
4103 return -1;
4104 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
4105 return -1;
4106 break;
4107
4108 /* 0xb39b undefined */
4109 /* 0xb39f undefined */
4110
4111 /* 0xb3a3 undefined */
4112 /* 0xb3a7 undefined */
4113
4114 case 0xb3a8: /* CGEBR - convert to fixed */
4115 case 0xb3a9: /* CGDBR - convert to fixed */
4116 case 0xb3aa: /* CGXBR - convert to fixed */
4117 case 0xb3ac: /* CLGEBR - convert to logical */
4118 case 0xb3ad: /* CLGDBR - convert to logical */
4119 case 0xb3ae: /* CLGXBR - convert to logical */
4120 case 0xb3e1: /* CGDTR - convert to fixed */
4121 case 0xb3e9: /* CGXTR - convert to fixed */
4122 case 0xb942: /* CLGDTR - convert to logical */
4123 case 0xb94a: /* CLGXTR - convert to logical */
4124 /* 64-bit gpr destination + flags + fpc */
4125 if (s390_record_gpr_g (gdbarch, regcache, inib[6]))
4126 return -1;
4127 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
4128 return -1;
4129 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
4130 return -1;
4131 break;
4132
4133 /* 0xb3ab undefined */
4134 /* 0xb3af-0xb3b3 undefined */
4135 /* 0xb3b7 undefined */
4136
4137 case 0xb3b8: /* CFER - convert to fixed */
4138 case 0xb3b9: /* CFDR - convert to fixed */
4139 case 0xb3ba: /* CFXR - convert to fixed */
4140 case 0xb998: /* ALCR - add logical with carry */
4141 case 0xb999: /* SLBR - subtract logical with borrow */
4142 case 0xb9f4: /* NRK - and */
6d9d6da4 4143 case 0xb9f5: /* NCRK - and with complement */
ef8914a4
PR
4144 case 0xb9f6: /* ORK - or */
4145 case 0xb9f7: /* XRK - xor */
4146 case 0xb9f8: /* ARK - add */
4147 case 0xb9f9: /* SRK - subtract */
4148 case 0xb9fa: /* ALRK - add logical */
4149 case 0xb9fb: /* SLRK - subtract logical */
4150 /* 32-bit gpr destination + flags */
4151 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[6]))
4152 return -1;
4153 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
4154 return -1;
4155 break;
4156
4157 case 0xb3c8: /* CGER - convert to fixed */
4158 case 0xb3c9: /* CGDR - convert to fixed */
4159 case 0xb3ca: /* CGXR - convert to fixed */
4160 case 0xb900: /* LPGR - load positive */
4161 case 0xb901: /* LNGR - load negative */
4162 case 0xb902: /* LTGR - load and test */
4163 case 0xb903: /* LCGR - load complement */
4164 case 0xb908: /* AGR - add */
4165 case 0xb909: /* SGR - subtract */
4166 case 0xb90a: /* ALGR - add logical */
4167 case 0xb90b: /* SLGR - subtract logical */
4168 case 0xb910: /* LPGFR - load positive */
4169 case 0xb911: /* LNGFR - load negative */
4170 case 0xb912: /* LTGFR - load and test */
4171 case 0xb913: /* LCGFR - load complement */
4172 case 0xb918: /* AGFR - add */
4173 case 0xb919: /* SGFR - subtract */
4174 case 0xb91a: /* ALGFR - add logical */
4175 case 0xb91b: /* SLGFR - subtract logical */
6d9d6da4
AA
4176 case 0xb964: /* NNGRK - and 64 bit */
4177 case 0xb965: /* OCGRK - or with complement 64 bit */
4178 case 0xb966: /* NOGRK - or 64 bit */
4179 case 0xb967: /* NXGRK - not exclusive or 64 bit */
4180 case 0xb974: /* NNRK - and 32 bit */
4181 case 0xb975: /* OCRK - or with complement 32 bit */
4182 case 0xb976: /* NORK - or 32 bit */
4183 case 0xb977: /* NXRK - not exclusive or 32 bit */
ef8914a4
PR
4184 case 0xb980: /* NGR - and */
4185 case 0xb981: /* OGR - or */
4186 case 0xb982: /* XGR - xor */
4187 case 0xb988: /* ALCGR - add logical with carry */
4188 case 0xb989: /* SLBGR - subtract logical with borrow */
6d9d6da4 4189 case 0xb9c0: /* SELFHR - select high */
ef8914a4
PR
4190 case 0xb9e1: /* POPCNT - population count */
4191 case 0xb9e4: /* NGRK - and */
6d9d6da4 4192 case 0xb9e5: /* NCGRK - and with complement */
ef8914a4
PR
4193 case 0xb9e6: /* OGRK - or */
4194 case 0xb9e7: /* XGRK - xor */
4195 case 0xb9e8: /* AGRK - add */
4196 case 0xb9e9: /* SGRK - subtract */
4197 case 0xb9ea: /* ALGRK - add logical */
6d9d6da4 4198 case 0xb9e3: /* SELGR - select 64 bit */
ef8914a4
PR
4199 case 0xb9eb: /* SLGRK - subtract logical */
4200 case 0xb9ed: /* MSGRKC - multiply single 64x64 -> 64 */
6d9d6da4 4201 case 0xb9f0: /* SELR - select 32 bit */
ef8914a4
PR
4202 case 0xb9fd: /* MSRKC - multiply single 32x32 -> 32 */
4203 /* 64-bit gpr destination + flags */
4204 if (s390_record_gpr_g (gdbarch, regcache, inib[6]))
4205 return -1;
4206 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
4207 return -1;
4208 break;
4209
4210 /* 0xb3bb-0xb3c0 undefined */
4211 /* 0xb3c2-0xb3c3 undefined */
4212 /* 0xb3c7 undefined */
4213 /* 0xb3cb-0xb3cc undefined */
4214
4215 case 0xb3cd: /* LGDR - load gr from fpr */
4216 case 0xb3e2: /* CUDTR - convert to unsigned packed */
4217 case 0xb3e3: /* CSDTR - convert to signed packed */
4218 case 0xb3e5: /* EEDTR - extract biased exponent */
4219 case 0xb3e7: /* ESDTR - extract significance */
4220 case 0xb3ed: /* EEXTR - extract biased exponent */
4221 case 0xb3ef: /* ESXTR - extract significance */
4222 case 0xb904: /* LGR - load */
4223 case 0xb906: /* LGBR - load byte */
4224 case 0xb907: /* LGHR - load halfword */
4225 case 0xb90c: /* MSGR - multiply single */
4226 case 0xb90f: /* LRVGR - load reversed */
4227 case 0xb914: /* LGFR - load */
4228 case 0xb916: /* LLGFR - load logical */
4229 case 0xb917: /* LLGTR - load logical thirty one bits */
4230 case 0xb91c: /* MSGFR - multiply single 64<32 */
4231 case 0xb946: /* BCTGR - branch on count */
4232 case 0xb984: /* LLGCR - load logical character */
4233 case 0xb985: /* LLGHR - load logical halfword */
4234 case 0xb9e2: /* LOCGR - load on condition */
4235 /* 64-bit gpr destination */
4236 if (s390_record_gpr_g (gdbarch, regcache, inib[6]))
4237 return -1;
4238 break;
4239
4240 /* 0xb3ce-0xb3cf undefined */
4241 /* 0xb3e6 undefined */
4242
4243 case 0xb3ea: /* CUXTR - convert to unsigned packed */
4244 case 0xb3eb: /* CSXTR - convert to signed packed */
4245 case 0xb90d: /* DSGR - divide single */
4246 case 0xb91d: /* DSGFR - divide single */
4247 case 0xb986: /* MLGR - multiply logical */
4248 case 0xb987: /* DLGR - divide logical */
4249 case 0xb9ec: /* MGRK - multiply 64x64 -> 128 */
4250 /* 64-bit gpr pair destination */
4251 if (s390_record_gpr_g (gdbarch, regcache, inib[6]))
4252 return -1;
4253 if (s390_record_gpr_g (gdbarch, regcache, inib[6] | 1))
4254 return -1;
4255 break;
4256
4257 /* 0xb3ee undefined */
4258 /* 0xb3f0 undefined */
4259 /* 0xb3f8 undefined */
4260
4261 /* 0xb905 privileged */
4262
4263 /* 0xb90e unsupported: EREGG */
4264
4265 /* 0xb915 undefined */
4266
4267 case 0xb91e: /* KMAC - compute message authentication code [partial] */
4268 regcache_raw_read_unsigned (regcache, S390_R1_REGNUM, &tmp);
4269 oaddr = s390_record_address_mask (gdbarch, regcache, tmp);
4270 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM, &tmp);
4271 tmp &= 0xff;
4272 switch (tmp)
4273 {
4274 case 0x00: /* KMAC-Query */
4275 if (record_full_arch_list_add_mem (oaddr, 16))
4276 return -1;
4277 break;
4278
4279 case 0x01: /* KMAC-DEA */
4280 case 0x02: /* KMAC-TDEA-128 */
4281 case 0x03: /* KMAC-TDEA-192 */
4282 case 0x09: /* KMAC-Encrypted-DEA */
4283 case 0x0a: /* KMAC-Encrypted-TDEA-128 */
4284 case 0x0b: /* KMAC-Encrypted-TDEA-192 */
4285 if (record_full_arch_list_add_mem (oaddr, 8))
4286 return -1;
4287 break;
4288
4289 case 0x12: /* KMAC-AES-128 */
4290 case 0x13: /* KMAC-AES-192 */
4291 case 0x14: /* KMAC-AES-256 */
4292 case 0x1a: /* KMAC-Encrypted-AES-128 */
4293 case 0x1b: /* KMAC-Encrypted-AES-192 */
4294 case 0x1c: /* KMAC-Encrypted-AES-256 */
4295 if (record_full_arch_list_add_mem (oaddr, 16))
4296 return -1;
4297 break;
4298
4299 default:
4300 fprintf_unfiltered (gdb_stdlog, "Warning: Unknown KMAC function %02x at %s.\n",
4301 (int)tmp, paddress (gdbarch, addr));
4302 return -1;
4303 }
4304 if (tmp != 0)
4305 {
4306 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[7]))
4307 return -1;
4308 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[7] | 1)))
4309 return -1;
4310 }
4311 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
4312 return -1;
4313 break;
4314
4315 /* 0xb922-0xb924 undefined */
4316 /* 0xb925 privileged */
4317 /* 0xb928 privileged */
4318
4319 case 0xb929: /* KMA - cipher message with authentication */
4320 case 0xb92a: /* KMF - cipher message with cipher feedback [partial] */
4321 case 0xb92b: /* KMO - cipher message with output feedback [partial] */
4322 case 0xb92f: /* KMC - cipher message with chaining [partial] */
4323 regcache_raw_read_unsigned (regcache, S390_R1_REGNUM, &tmp);
4324 oaddr = s390_record_address_mask (gdbarch, regcache, tmp);
4325 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM, &tmp);
4326 tmp &= 0x7f;
4327 switch (tmp)
4328 {
4329 case 0x00: /* KM*-Query */
4330 if (record_full_arch_list_add_mem (oaddr, 16))
4331 return -1;
4332 break;
4333
4334 case 0x01: /* KM*-DEA */
4335 case 0x02: /* KM*-TDEA-128 */
4336 case 0x03: /* KM*-TDEA-192 */
4337 case 0x09: /* KM*-Encrypted-DEA */
4338 case 0x0a: /* KM*-Encrypted-TDEA-128 */
4339 case 0x0b: /* KM*-Encrypted-TDEA-192 */
4340 if (record_full_arch_list_add_mem (oaddr, 8))
4341 return -1;
4342 break;
4343
4344 case 0x12: /* KM*-AES-128 */
4345 case 0x13: /* KM*-AES-192 */
4346 case 0x14: /* KM*-AES-256 */
4347 case 0x1a: /* KM*-Encrypted-AES-128 */
4348 case 0x1b: /* KM*-Encrypted-AES-192 */
4349 case 0x1c: /* KM*-Encrypted-AES-256 */
4350 if (record_full_arch_list_add_mem (oaddr, 16))
4351 return -1;
4352 break;
4353
4354 case 0x43: /* KMC-PRNG */
4355 /* Only valid for KMC. */
4356 if (insn[0] == 0xb92f)
4357 {
4358 if (record_full_arch_list_add_mem (oaddr, 8))
4359 return -1;
4360 break;
4361 }
86a73007
TT
4362 /* For other instructions... */
4363 /* Fall through. */
ef8914a4
PR
4364 default:
4365 fprintf_unfiltered (gdb_stdlog, "Warning: Unknown KM* function %02x at %s.\n",
4366 (int)tmp, paddress (gdbarch, addr));
4367 return -1;
4368 }
4369 if (tmp != 0)
4370 {
4371 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + inib[6], &tmp);
4372 oaddr2 = s390_record_address_mask (gdbarch, regcache, tmp);
4373 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + (inib[7] | 1), &tmp);
4374 if (record_full_arch_list_add_mem (oaddr2, tmp))
4375 return -1;
4376 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[6]))
4377 return -1;
4378 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[7]))
4379 return -1;
4380 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[7] | 1)))
4381 return -1;
4382 }
4383 if (tmp != 0 && insn[0] == 0xb929)
4384 {
4385 if (record_full_arch_list_add_reg (regcache,
4386 S390_R0_REGNUM + inib[4]))
4387 return -1;
4388 if (record_full_arch_list_add_reg (regcache,
4389 S390_R0_REGNUM + (inib[4] | 1)))
4390 return -1;
4391 }
4392 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
4393 return -1;
4394 break;
4395
4396 case 0xb92c: /* PCC - perform cryptographic computation [partial] */
4397 regcache_raw_read_unsigned (regcache, S390_R1_REGNUM, &tmp);
4398 oaddr = s390_record_address_mask (gdbarch, regcache, tmp);
4399 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM, &tmp);
4400 tmp &= 0x7f;
4401 switch (tmp)
4402 {
4403 case 0x00: /* PCC-Query */
4404 if (record_full_arch_list_add_mem (oaddr, 16))
4405 return -1;
4406 break;
4407
4408 case 0x01: /* PCC-Compute-Last-Block-CMAC-Using-DEA */
4409 case 0x02: /* PCC-Compute-Last-Block-CMAC-Using-TDEA-128 */
4410 case 0x03: /* PCC-Compute-Last-Block-CMAC-Using-TDEA-192 */
4411 case 0x09: /* PCC-Compute-Last-Block-CMAC-Using-Encrypted-DEA */
4412 case 0x0a: /* PCC-Compute-Last-Block-CMAC-Using-Encrypted-TDEA-128 */
4413 case 0x0b: /* PCC-Compute-Last-Block-CMAC-Using-Encrypted-TDEA-192 */
4414 if (record_full_arch_list_add_mem (oaddr + 0x10, 8))
4415 return -1;
4416 break;
4417
4418 case 0x12: /* PCC-Compute-Last-Block-CMAC-Using-AES-128 */
4419 case 0x13: /* PCC-Compute-Last-Block-CMAC-Using-AES-192 */
4420 case 0x14: /* PCC-Compute-Last-Block-CMAC-Using-AES-256 */
4421 case 0x1a: /* PCC-Compute-Last-Block-CMAC-Using-Encrypted-AES-128 */
4422 case 0x1b: /* PCC-Compute-Last-Block-CMAC-Using-Encrypted-AES-192 */
4423 case 0x1c: /* PCC-Compute-Last-Block-CMAC-Using-Encrypted-AES-256 */
4424 if (record_full_arch_list_add_mem (oaddr + 0x18, 16))
4425 return -1;
4426 break;
4427
4428 case 0x32: /* PCC-Compute-XTS-Parameter-Using-AES-128 */
4429 if (record_full_arch_list_add_mem (oaddr + 0x30, 32))
4430 return -1;
4431 break;
4432
4433 case 0x34: /* PCC-Compute-XTS-Parameter-Using-AES-256 */
4434 if (record_full_arch_list_add_mem (oaddr + 0x40, 32))
4435 return -1;
4436 break;
4437
4438 case 0x3a: /* PCC-Compute-XTS-Parameter-Using-Encrypted-AES-128 */
4439 if (record_full_arch_list_add_mem (oaddr + 0x50, 32))
4440 return -1;
4441 break;
4442
4443 case 0x3c: /* PCC-Compute-XTS-Parameter-Using-Encrypted-AES-256 */
4444 if (record_full_arch_list_add_mem (oaddr + 0x60, 32))
4445 return -1;
4446 break;
4447
4448 default:
4449 fprintf_unfiltered (gdb_stdlog, "Warning: Unknown PCC function %02x at %s.\n",
4450 (int)tmp, paddress (gdbarch, addr));
4451 return -1;
4452 }
4453 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
4454 return -1;
4455 break;
4456
4457 case 0xb92d: /* KMCTR - cipher message with counter [partial] */
4458 regcache_raw_read_unsigned (regcache, S390_R1_REGNUM, &tmp);
4459 oaddr = s390_record_address_mask (gdbarch, regcache, tmp);
4460 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM, &tmp);
4461 tmp &= 0x7f;
4462 switch (tmp)
4463 {
4464 case 0x00: /* KMCTR-Query */
4465 if (record_full_arch_list_add_mem (oaddr, 16))
4466 return -1;
4467 break;
4468
4469 case 0x01: /* KMCTR-DEA */
4470 case 0x02: /* KMCTR-TDEA-128 */
4471 case 0x03: /* KMCTR-TDEA-192 */
4472 case 0x09: /* KMCTR-Encrypted-DEA */
4473 case 0x0a: /* KMCTR-Encrypted-TDEA-128 */
4474 case 0x0b: /* KMCTR-Encrypted-TDEA-192 */
4475 case 0x12: /* KMCTR-AES-128 */
4476 case 0x13: /* KMCTR-AES-192 */
4477 case 0x14: /* KMCTR-AES-256 */
4478 case 0x1a: /* KMCTR-Encrypted-AES-128 */
4479 case 0x1b: /* KMCTR-Encrypted-AES-192 */
4480 case 0x1c: /* KMCTR-Encrypted-AES-256 */
4481 break;
4482
4483 default:
4484 fprintf_unfiltered (gdb_stdlog, "Warning: Unknown KMCTR function %02x at %s.\n",
4485 (int)tmp, paddress (gdbarch, addr));
4486 return -1;
4487 }
4488 if (tmp != 0)
4489 {
4490 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + inib[6], &tmp);
4491 oaddr2 = s390_record_address_mask (gdbarch, regcache, tmp);
4492 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + (inib[7] | 1), &tmp);
4493 if (record_full_arch_list_add_mem (oaddr2, tmp))
4494 return -1;
4495 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[6]))
4496 return -1;
4497 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[7]))
4498 return -1;
4499 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[7] | 1)))
4500 return -1;
4501 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[4]))
4502 return -1;
4503 }
4504 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
4505 return -1;
4506 break;
4507
4508 case 0xb92e: /* KM - cipher message [partial] */
4509 regcache_raw_read_unsigned (regcache, S390_R1_REGNUM, &tmp);
4510 oaddr = s390_record_address_mask (gdbarch, regcache, tmp);
4511 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM, &tmp);
4512 tmp &= 0x7f;
4513 switch (tmp)
4514 {
4515 case 0x00: /* KM-Query */
4516 if (record_full_arch_list_add_mem (oaddr, 16))
4517 return -1;
4518 break;
4519
4520 case 0x01: /* KM-DEA */
4521 case 0x02: /* KM-TDEA-128 */
4522 case 0x03: /* KM-TDEA-192 */
4523 case 0x09: /* KM-Encrypted-DEA */
4524 case 0x0a: /* KM-Encrypted-TDEA-128 */
4525 case 0x0b: /* KM-Encrypted-TDEA-192 */
4526 case 0x12: /* KM-AES-128 */
4527 case 0x13: /* KM-AES-192 */
4528 case 0x14: /* KM-AES-256 */
4529 case 0x1a: /* KM-Encrypted-AES-128 */
4530 case 0x1b: /* KM-Encrypted-AES-192 */
4531 case 0x1c: /* KM-Encrypted-AES-256 */
4532 break;
4533
4534 case 0x32: /* KM-XTS-AES-128 */
4535 if (record_full_arch_list_add_mem (oaddr + 0x10, 16))
4536 return -1;
4537 break;
4538
4539 case 0x34: /* KM-XTS-AES-256 */
4540 if (record_full_arch_list_add_mem (oaddr + 0x20, 16))
4541 return -1;
4542 break;
4543
4544 case 0x3a: /* KM-XTS-Encrypted-AES-128 */
4545 if (record_full_arch_list_add_mem (oaddr + 0x30, 16))
4546 return -1;
4547 break;
4548
4549 case 0x3c: /* KM-XTS-Encrypted-AES-256 */
4550 if (record_full_arch_list_add_mem (oaddr + 0x40, 16))
4551 return -1;
4552 break;
4553
4554 default:
4555 fprintf_unfiltered (gdb_stdlog, "Warning: Unknown KM function %02x at %s.\n",
4556 (int)tmp, paddress (gdbarch, addr));
4557 return -1;
4558 }
4559 if (tmp != 0)
4560 {
4561 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + inib[6], &tmp);
4562 oaddr2 = s390_record_address_mask (gdbarch, regcache, tmp);
4563 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + (inib[7] | 1), &tmp);
4564 if (record_full_arch_list_add_mem (oaddr2, tmp))
4565 return -1;
4566 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[6]))
4567 return -1;
4568 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[7]))
4569 return -1;
4570 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[7] | 1)))
4571 return -1;
4572 }
4573 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
4574 return -1;
4575 break;
4576
6d9d6da4
AA
4577 /* 0xb932-0xb937 undefined */
4578
4579 /* 0xb938 unsupported: SORTL - sort lists */
4580 /* 0xb939 unsupported: DFLTCC - deflate conversion call */
4581 /* 0xb93a unsupported: KDSA - compute dig. signature auth. */
4582
4583 /* 0xb93b undefined */
ef8914a4
PR
4584
4585 case 0xb93c: /* PPNO - perform pseudorandom number operation [partial] */
4586 regcache_raw_read_unsigned (regcache, S390_R1_REGNUM, &tmp);
4587 oaddr = s390_record_address_mask (gdbarch, regcache, tmp);
4588 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM, &tmp);
4589 tmp &= 0xff;
4590 switch (tmp)
4591 {
4592 case 0x00: /* PPNO-Query */
4593 case 0x80: /* PPNO-Query */
4594 if (record_full_arch_list_add_mem (oaddr, 16))
4595 return -1;
4596 break;
4597
4598 case 0x03: /* PPNO-SHA-512-DRNG - generate */
4599 if (record_full_arch_list_add_mem (oaddr, 240))
4600 return -1;
4601 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + inib[6], &tmp);
4602 oaddr2 = s390_record_address_mask (gdbarch, regcache, tmp);
4603 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + (inib[6] | 1), &tmp);
4604 if (record_full_arch_list_add_mem (oaddr2, tmp))
4605 return -1;
4606 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[6]))
4607 return -1;
4608 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[6] | 1)))
4609 return -1;
4610 break;
4611
4612 case 0x83: /* PPNO-SHA-512-DRNG - seed */
4613 if (record_full_arch_list_add_mem (oaddr, 240))
4614 return -1;
4615 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[7]))
4616 return -1;
4617 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[7] | 1)))
4618 return -1;
4619 break;
4620
4621 default:
4622 fprintf_unfiltered (gdb_stdlog, "Warning: Unknown PPNO function %02x at %s.\n",
4623 (int)tmp, paddress (gdbarch, addr));
4624 return -1;
4625 }
4626 /* DXC may be written */
4627 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
4628 return -1;
4629 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
4630 return -1;
4631 break;
4632
4633 /* 0xb93d undefined */
4634
4635 case 0xb93e: /* KIMD - compute intermediate message digest [partial] */
4636 case 0xb93f: /* KLMD - compute last message digest [partial] */
4637 regcache_raw_read_unsigned (regcache, S390_R1_REGNUM, &tmp);
4638 oaddr = s390_record_address_mask (gdbarch, regcache, tmp);
4639 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM, &tmp);
4640 tmp &= 0xff;
4641 switch (tmp)
4642 {
4643 case 0x00: /* K*MD-Query */
4644 if (record_full_arch_list_add_mem (oaddr, 16))
4645 return -1;
4646 break;
4647
4648 case 0x01: /* K*MD-SHA-1 */
4649 if (record_full_arch_list_add_mem (oaddr, 20))
4650 return -1;
4651 break;
4652
4653 case 0x02: /* K*MD-SHA-256 */
4654 if (record_full_arch_list_add_mem (oaddr, 32))
4655 return -1;
4656 break;
4657
4658 case 0x03: /* K*MD-SHA-512 */
4659 if (record_full_arch_list_add_mem (oaddr, 64))
4660 return -1;
4661 break;
4662
4663 case 0x41: /* KIMD-GHASH */
4664 /* Only valid for KIMD. */
4665 if (insn[0] == 0xb93e)
4666 {
4667 if (record_full_arch_list_add_mem (oaddr, 16))
4668 return -1;
4669 break;
4670 }
86a73007
TT
4671 /* For KLMD... */
4672 /* Fall through. */
ef8914a4
PR
4673 default:
4674 fprintf_unfiltered (gdb_stdlog, "Warning: Unknown KMAC function %02x at %s.\n",
4675 (int)tmp, paddress (gdbarch, addr));
4676 return -1;
4677 }
4678 if (tmp != 0)
4679 {
4680 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[7]))
4681 return -1;
4682 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[7] | 1)))
4683 return -1;
4684 }
4685 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
4686 return -1;
4687 break;
4688
4689 /* 0xb940 undefined */
4690 /* 0xb944-0xb945 undefined */
4691 /* 0xb947-0xb948 undefined */
4692 /* 0xb94c-0xb950 undefined */
4693 /* 0xb954-0xb958 undefined */
4694 /* 0xb95c-0xb95f undefined */
4695 /* 0xb962-0xb971 undefined */
4696 /* 0xb974-0xb97f undefined */
4697
4698 case 0xb983: /* FLOGR - find leftmost one */
4699 /* 64-bit gpr pair destination + flags */
4700 if (s390_record_gpr_g (gdbarch, regcache, inib[6]))
4701 return -1;
4702 if (s390_record_gpr_g (gdbarch, regcache, inib[6] | 1))
4703 return -1;
4704 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
4705 return -1;
4706 break;
4707
4708 /* 0xb98a privileged */
4709 /* 0xb98b-0xb98c undefined */
4710
4711 case 0xb98d: /* EPSW - extract psw */
4712 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[6]))
4713 return -1;
4714 if (inib[7])
4715 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[7]))
4716 return -1;
4717 break;
4718
4719 /* 0xb98e-0xb98f privileged */
4720
4721 case 0xb990: /* TRTT - translate two to two [partial] */
4722 case 0xb991: /* TRTO - translate two to one [partial] */
4723 case 0xb992: /* TROT - translate one to two [partial] */
4724 case 0xb993: /* TROO - translate one to one [partial] */
4725 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + inib[6], &tmp);
4726 oaddr = s390_record_address_mask (gdbarch, regcache, tmp);
4727 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + (inib[6] | 1), &tmp);
4728 /* tmp is source length, we want destination length. Adjust. */
4729 if (insn[0] == 0xb991)
4730 tmp >>= 1;
4731 if (insn[0] == 0xb992)
4732 tmp <<= 1;
4733 if (record_full_arch_list_add_mem (oaddr, tmp))
4734 return -1;
4735 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[6]))
4736 return -1;
4737 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[6] | 1)))
4738 return -1;
4739 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[7]))
4740 return -1;
4741 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
4742 return -1;
4743 break;
4744
4745 case 0xb996: /* MLR - multiply logical */
4746 case 0xb997: /* DLR - divide logical */
4747 /* 32-bit gpr pair destination */
4748 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[6]))
4749 return -1;
4750 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[6] | 1)))
4751 return -1;
4752 break;
4753
4754 /* 0xb99a-0xb9af unsupported, privileged, or undefined */
4755 /* 0xb9b4-0xb9bc undefined */
4756
4757 case 0xb9bd: /* TRTRE - translate and test reverse extended [partial] */
4758 case 0xb9bf: /* TRTE - translate and test extended [partial] */
4759 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[6]))
4760 return -1;
4761 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[6] | 1)))
4762 return -1;
4763 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[7]))
4764 return -1;
4765 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
4766 return -1;
4767 break;
4768
4769 /* 0xb9c0-0xb9c7 undefined */
4770
4771 case 0xb9c8: /* AHHHR - add high */
4772 case 0xb9c9: /* SHHHR - subtract high */
4773 case 0xb9ca: /* ALHHHR - add logical high */
4774 case 0xb9cb: /* SLHHHR - subtract logical high */
4775 case 0xb9d8: /* AHHLR - add high */
4776 case 0xb9d9: /* SHHLR - subtract high */
4777 case 0xb9da: /* ALHHLR - add logical high */
4778 case 0xb9db: /* SLHHLR - subtract logical high */
4779 /* 32-bit high gpr destination + flags */
4780 if (s390_record_gpr_h (gdbarch, regcache, inib[6]))
4781 return -1;
4782 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
4783 return -1;
4784 break;
4785
4786 /* 0xb9cc undefined */
4787 /* 0xb9ce undefined */
4788 /* 0xb9d0-0xb9d7 undefined */
4789 /* 0xb9dc undefined */
4790 /* 0xb9de undefined */
4791
4792 case 0xb9e0: /* LOCFHR - load high on condition */
4793 /* 32-bit high gpr destination */
4794 if (s390_record_gpr_h (gdbarch, regcache, inib[6]))
4795 return -1;
4796 break;
4797
4798 /* 0xb9e3 undefined */
4799 /* 0xb9e5 undefined */
4800 /* 0xb9ee-0xb9f1 undefined */
4801 /* 0xb9f3 undefined */
4802 /* 0xb9f5 undefined */
4803 /* 0xb9fc undefined */
4804 /* 0xb9fe -0xb9ff undefined */
4805
4806 default:
4807 goto UNKNOWN_OP;
4808 }
4809 break;
4810
4811 /* 0xb4-0xb5 undefined */
4812 /* 0xb6 privileged: STCTL - store control */
4813 /* 0xb7 privileged: LCTL - load control */
4814 /* 0xb8 undefined */
4815
4816 case 0xba: /* CS - compare and swap */
4817 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
4818 if (record_full_arch_list_add_mem (oaddr, 4))
4819 return -1;
4820 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
4821 return -1;
4822 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
4823 return -1;
4824 break;
4825
4826 case 0xbb: /* CDS - compare double and swap */
4827 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
4828 if (record_full_arch_list_add_mem (oaddr, 8))
4829 return -1;
4830 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
4831 return -1;
4832 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[2] | 1)))
4833 return -1;
4834 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
4835 return -1;
4836 break;
4837
4838 /* 0xbc undefined */
4839
4840 case 0xbe: /* STCM - store characters under mask */
4841 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
4842 if (record_full_arch_list_add_mem (oaddr, s390_popcnt (inib[3])))
4843 return -1;
4844 break;
4845
4846 case 0xc0:
4847 case 0xc2:
4848 case 0xc4:
4849 case 0xc6:
4850 case 0xcc:
4851 /* RIL-format instruction */
4852 switch (ibyte[0] << 4 | inib[3])
4853 {
4854 case 0xc00: /* LARL - load address relative long */
4855 case 0xc05: /* BRASL - branch relative and save long */
4856 case 0xc09: /* IILF - insert immediate */
4857 case 0xc21: /* MSFI - multiply single immediate */
4858 case 0xc42: /* LLHRL - load logical halfword relative long */
4859 case 0xc45: /* LHRL - load halfword relative long */
4860 case 0xc4d: /* LRL - load relative long */
4861 /* 32-bit or native gpr destination */
4862 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
4863 return -1;
4864 break;
4865
4866 case 0xc01: /* LGFI - load immediate */
4867 case 0xc0e: /* LLIHF - load logical immediate */
4868 case 0xc0f: /* LLILF - load logical immediate */
4869 case 0xc20: /* MSGFI - multiply single immediate */
4870 case 0xc44: /* LGHRL - load halfword relative long */
4871 case 0xc46: /* LLGHRL - load logical halfword relative long */
4872 case 0xc48: /* LGRL - load relative long */
4873 case 0xc4c: /* LGFRL - load relative long */
4874 case 0xc4e: /* LLGFRL - load logical relative long */
4875 /* 64-bit gpr destination */
4876 if (s390_record_gpr_g (gdbarch, regcache, inib[2]))
4877 return -1;
4878 break;
4879
4880 /* 0xc02-0xc03 undefined */
4881
4882 case 0xc04: /* BRCL - branch relative on condition long */
4883 case 0xc62: /* PFDRL - prefetch data relative long */
4884 break;
4885
4886 case 0xc06: /* XIHF - xor immediate */
4887 case 0xc0a: /* NIHF - and immediate */
4888 case 0xc0c: /* OIHF - or immediate */
4889 case 0xcc8: /* AIH - add immediate high */
4890 case 0xcca: /* ALSIH - add logical with signed immediate high */
4891 /* 32-bit high gpr destination + flags */
4892 if (s390_record_gpr_h (gdbarch, regcache, inib[2]))
4893 return -1;
4894 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
4895 return -1;
4896 break;
4897
4898 case 0xc07: /* XILF - xor immediate */
4899 case 0xc0b: /* NILF - and immediate */
4900 case 0xc0d: /* OILF - or immediate */
4901 case 0xc25: /* SLFI - subtract logical immediate */
4902 case 0xc29: /* AFI - add immediate */
4903 case 0xc2b: /* ALFI - add logical immediate */
4904 /* 32-bit gpr destination + flags */
4905 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
4906 return -1;
4907 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
4908 return -1;
4909 break;
4910
4911 case 0xc08: /* IIHF - insert immediate */
4912 case 0xcc6: /* BRCTH - branch relative on count high */
4913 case 0xccb: /* ALSIHN - add logical with signed immediate high */
4914 /* 32-bit high gpr destination */
4915 if (s390_record_gpr_h (gdbarch, regcache, inib[2]))
4916 return -1;
4917 break;
4918
4919 /* 0xc22-0xc23 undefined */
4920
4921 case 0xc24: /* SLGFI - subtract logical immediate */
4922 case 0xc28: /* AGFI - add immediate */
4923 case 0xc2a: /* ALGFI - add logical immediate */
4924 /* 64-bit gpr destination + flags */
4925 if (s390_record_gpr_g (gdbarch, regcache, inib[2]))
4926 return -1;
4927 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
4928 return -1;
4929 break;
4930
4931 /* 0xc26-0xc27 undefined */
4932
4933 case 0xc2c: /* CGFI - compare immediate */
4934 case 0xc2d: /* CFI - compare immediate */
4935 case 0xc2e: /* CLGFI - compare logical immediate */
4936 case 0xc2f: /* CLFI - compare logical immediate */
4937 case 0xc64: /* CGHRL - compare halfword relative long */
4938 case 0xc65: /* CHRL - compare halfword relative long */
4939 case 0xc66: /* CLGHRL - compare logical halfword relative long */
4940 case 0xc67: /* CLHRL - compare logical halfword relative long */
4941 case 0xc68: /* CGRL - compare relative long */
4942 case 0xc6a: /* CLGRL - compare logical relative long */
4943 case 0xc6c: /* CGFRL - compare relative long */
4944 case 0xc6d: /* CRL - compare relative long */
4945 case 0xc6e: /* CLGFRL - compare logical relative long */
4946 case 0xc6f: /* CLRL - compare logical relative long */
4947 case 0xccd: /* CIH - compare immediate high */
4948 case 0xccf: /* CLIH - compare logical immediate high */
4949 /* flags only */
4950 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
4951 return -1;
4952 break;
4953
4954 /* 0xc40-0xc41 undefined */
4955 /* 0xc43 undefined */
4956
4957 case 0xc47: /* STHRL - store halfword relative long */
4958 oaddr = s390_record_calc_rl (gdbarch, regcache, addr, insn[1], insn[2]);
4959 if (record_full_arch_list_add_mem (oaddr, 2))
4960 return -1;
4961 break;
4962
4963 /* 0xc49-0xc4a undefined */
4964
4965 case 0xc4b: /* STGRL - store relative long */
4966 oaddr = s390_record_calc_rl (gdbarch, regcache, addr, insn[1], insn[2]);
4967 if (record_full_arch_list_add_mem (oaddr, 8))
4968 return -1;
4969 break;
4970
4971 case 0xc4f: /* STRL - store relative long */
4972 oaddr = s390_record_calc_rl (gdbarch, regcache, addr, insn[1], insn[2]);
4973 if (record_full_arch_list_add_mem (oaddr, 4))
4974 return -1;
4975 break;
4976
4977 case 0xc60: /* EXRL - execute relative long */
4978 if (ex != -1)
4979 {
4980 fprintf_unfiltered (gdb_stdlog, "Warning: Double execute at %s.\n",
4981 paddress (gdbarch, addr));
4982 return -1;
4983 }
4984 addr = s390_record_calc_rl (gdbarch, regcache, addr, insn[1], insn[2]);
4985 if (inib[2])
4986 {
4987 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + inib[2], &tmp);
4988 ex = tmp & 0xff;
4989 }
4990 else
4991 {
4992 ex = 0;
4993 }
4994 goto ex;
4995
4996 /* 0xc61 undefined */
4997 /* 0xc63 undefined */
4998 /* 0xc69 undefined */
4999 /* 0xc6b undefined */
5000 /* 0xcc0-0xcc5 undefined */
5001 /* 0xcc7 undefined */
5002 /* 0xcc9 undefined */
5003 /* 0xccc undefined */
5004 /* 0xcce undefined */
5005
5006 default:
5007 goto UNKNOWN_OP;
5008 }
5009 break;
5010
5011 /* 0xc1 undefined */
5012 /* 0xc3 undefined */
5013
5014 case 0xc5: /* BPRP - branch prediction relative preload */
5015 case 0xc7: /* BPP - branch prediction preload */
5016 /* no visible effect */
5017 break;
5018
5019 case 0xc8:
5020 /* SSF-format instruction */
5021 switch (ibyte[0] << 4 | inib[3])
5022 {
5023 /* 0xc80 unsupported */
5024
5025 case 0xc81: /* ECTG - extract cpu time */
5026 if (s390_record_gpr_g (gdbarch, regcache, inib[2]))
5027 return -1;
5028 if (s390_record_gpr_g (gdbarch, regcache, 0))
5029 return -1;
5030 if (s390_record_gpr_g (gdbarch, regcache, 1))
5031 return -1;
5032 break;
5033
5034 case 0xc82: /* CSST - compare and swap and store */
5035 {
5036 uint8_t fc, sc;
5037 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM, &tmp);
5038 fc = tmp & 0xff;
5039 sc = tmp >> 8 & 0xff;
5040
5041 /* First and third operands. */
5042 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
5043 switch (fc)
5044 {
5045 case 0x00: /* 32-bit */
5046 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
5047 return -1;
5048 if (record_full_arch_list_add_mem (oaddr, 4))
5049 return -1;
5050 break;
5051
5052 case 0x01: /* 64-bit */
5053 if (s390_record_gpr_g (gdbarch, regcache, inib[2]))
5054 return -1;
5055 if (record_full_arch_list_add_mem (oaddr, 8))
5056 return -1;
5057 break;
5058
5059 case 0x02: /* 128-bit */
5060 if (s390_record_gpr_g (gdbarch, regcache, inib[2]))
5061 return -1;
5062 if (s390_record_gpr_g (gdbarch, regcache, inib[2] | 1))
5063 return -1;
5064 if (record_full_arch_list_add_mem (oaddr, 16))
5065 return -1;
5066 break;
5067
5068 default:
5069 fprintf_unfiltered (gdb_stdlog, "Warning: Unknown CSST FC %02x at %s.\n",
5070 fc, paddress (gdbarch, addr));
5071 return -1;
5072 }
5073
5074 /* Second operand. */
5075 oaddr2 = s390_record_calc_disp (gdbarch, regcache, 0, insn[2], 0);
5076 if (sc > 4)
5077 {
5078 fprintf_unfiltered (gdb_stdlog, "Warning: Unknown CSST FC %02x at %s.\n",
5079 sc, paddress (gdbarch, addr));
5080 return -1;
5081 }
5082
5083 if (record_full_arch_list_add_mem (oaddr2, 1 << sc))
5084 return -1;
5085
5086 /* Flags. */
5087 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
5088 return -1;
5089 }
5090 break;
5091
5092 /* 0xc83 undefined */
5093
5094 case 0xc84: /* LPD - load pair disjoint */
5095 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
5096 return -1;
5097 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[2] | 1)))
5098 return -1;
5099 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
5100 return -1;
5101 break;
5102
5103 case 0xc85: /* LPDG - load pair disjoint */
5104 if (s390_record_gpr_g (gdbarch, regcache, inib[2]))
5105 return -1;
5106 if (s390_record_gpr_g (gdbarch, regcache, inib[2] | 1))
5107 return -1;
5108 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
5109 return -1;
5110 break;
5111
5112 /* 0xc86-0xc8f undefined */
5113
5114 default:
5115 goto UNKNOWN_OP;
5116 }
5117 break;
5118
5119 /* 0xc9-0xcb undefined */
5120 /* 0xcd-0xcf undefined */
5121
5122 case 0xd0: /* TRTR - translate and test reversed */
5123 case 0xdd: /* TRT - translate and test */
5124 if (record_full_arch_list_add_reg (regcache, S390_R1_REGNUM))
5125 return -1;
5126 if (record_full_arch_list_add_reg (regcache, S390_R2_REGNUM))
5127 return -1;
5128 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
5129 return -1;
5130 break;
5131
5132 case 0xd1: /* MVN - move numbers */
5133 case 0xd2: /* MVC - move */
5134 case 0xd3: /* MVZ - move zones */
5135 case 0xdc: /* TR - translate */
5136 case 0xe8: /* MVCIN - move inverse */
5137 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
5138 if (record_full_arch_list_add_mem (oaddr, ibyte[1] + 1))
5139 return -1;
5140 break;
5141
5142 case 0xd4: /* NC - and */
5143 case 0xd6: /* OC - or*/
5144 case 0xd7: /* XC - xor */
5145 case 0xe2: /* UNPKU - unpack unicode */
5146 case 0xea: /* UNPKA - unpack ASCII */
5147 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
5148 if (record_full_arch_list_add_mem (oaddr, ibyte[1] + 1))
5149 return -1;
5150 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
5151 return -1;
5152 break;
5153
5154 case 0xde: /* ED - edit */
5155 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
5156 if (record_full_arch_list_add_mem (oaddr, ibyte[1] + 1))
5157 return -1;
5158 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
5159 return -1;
5160 /* DXC may be written */
5161 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
5162 return -1;
5163 break;
5164
5165 case 0xdf: /* EDMK - edit and mark */
5166 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
5167 if (record_full_arch_list_add_mem (oaddr, ibyte[1] + 1))
5168 return -1;
5169 if (record_full_arch_list_add_reg (regcache, S390_R1_REGNUM))
5170 return -1;
5171 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
5172 return -1;
5173 /* DXC may be written */
5174 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
5175 return -1;
5176 break;
5177
5178 /* 0xd8 undefined */
5179 /* 0xd9 unsupported: MVCK - move with key */
5180 /* 0xda unsupported: MVCP - move to primary */
5181 /* 0xdb unsupported: MVCS - move to secondary */
5182 /* 0xe0 undefined */
5183
5184 case 0xe1: /* PKU - pack unicode */
5185 case 0xe9: /* PKA - pack ASCII */
5186 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
5187 if (record_full_arch_list_add_mem (oaddr, 16))
5188 return -1;
5189 break;
5190
5191 case 0xe3:
5192 case 0xe6:
5193 case 0xe7:
5194 case 0xeb:
5195 case 0xed:
5196 /* RXY/RXE/RXF/RSL/RSY/SIY/V*-format instruction */
5197 switch (ibyte[0] << 8 | ibyte[5])
5198 {
5199 /* 0xe300-0xe301 undefined */
5200
5201 case 0xe302: /* LTG - load and test */
5202 case 0xe308: /* AG - add */
5203 case 0xe309: /* SG - subtract */
5204 case 0xe30a: /* ALG - add logical */
5205 case 0xe30b: /* SLG - subtract logical */
5206 case 0xe318: /* AGF - add */
5207 case 0xe319: /* SGF - subtract */
5208 case 0xe31a: /* ALGF - add logical */
5209 case 0xe31b: /* SLGF - subtract logical */
5210 case 0xe332: /* LTGF - load and test */
5211 case 0xe380: /* NG - and */
5212 case 0xe381: /* OG - or */
5213 case 0xe382: /* XG - xor */
5214 case 0xe388: /* ALCG - add logical with carry */
5215 case 0xe389: /* SLBG - subtract logical with borrow */
5216 case 0xeb0a: /* SRAG - shift right single */
5217 case 0xeb0b: /* SLAG - shift left single */
5218 /* 64-bit gpr destination + flags */
5219 if (s390_record_gpr_g (gdbarch, regcache, inib[2]))
5220 return -1;
5221 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
5222 return -1;
5223 break;
5224
5225 /* 0xe303 privileged */
5226
5227 case 0xe304: /* LG - load */
5228 case 0xe30c: /* MSG - multiply single */
5229 case 0xe30f: /* LRVG - load reversed */
5230 case 0xe314: /* LGF - load */
5231 case 0xe315: /* LGH - load halfword */
5232 case 0xe316: /* LLGF - load logical */
5233 case 0xe317: /* LLGT - load logical thirty one bits */
5234 case 0xe31c: /* MSGF - multiply single */
5235 case 0xe32a: /* LZRG - load and zero rightmost byte */
5236 case 0xe33a: /* LLZRGF - load logical and zero rightmost byte */
5237 case 0xe33c: /* MGH - multiply halfword 64x16mem -> 64 */
5238 case 0xe346: /* BCTG - branch on count */
5239 case 0xe377: /* LGB - load byte */
5240 case 0xe390: /* LLGC - load logical character */
5241 case 0xe391: /* LLGH - load logical halfword */
5242 case 0xeb0c: /* SRLG - shift right single logical */
5243 case 0xeb0d: /* SLLG - shift left single logical */
5244 case 0xeb1c: /* RLLG - rotate left single logical */
5245 case 0xeb44: /* BXHG - branch on index high */
5246 case 0xeb45: /* BXLEG - branch on index low or equal */
5247 case 0xeb4c: /* ECAG - extract cpu attribute */
5248 case 0xebe2: /* LOCG - load on condition */
5249 /* 64-bit gpr destination */
5250 if (s390_record_gpr_g (gdbarch, regcache, inib[2]))
5251 return -1;
5252 break;
5253
5254 /* 0xe305 undefined */
5255
5256 case 0xe306: /* CVBY - convert to binary */
5257 /* 32-bit or native gpr destination + FPC (DXC write) */
5258 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
5259 return -1;
5260 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
5261 return -1;
5262 break;
5263
5264 /* 0xe307 undefined */
5265
5266 case 0xe30d: /* DSG - divide single */
5267 case 0xe31d: /* DSGF - divide single */
5268 case 0xe384: /* MG - multiply 64x64mem -> 128 */
5269 case 0xe386: /* MLG - multiply logical */
5270 case 0xe387: /* DLG - divide logical */
5271 case 0xe38f: /* LPQ - load pair from quadword */
5272 /* 64-bit gpr pair destination */
5273 if (s390_record_gpr_g (gdbarch, regcache, inib[2]))
5274 return -1;
5275 if (s390_record_gpr_g (gdbarch, regcache, inib[2] | 1))
5276 return -1;
5277 break;
5278
5279 case 0xe30e: /* CVBG - convert to binary */
5280 /* 64-bit gpr destination + FPC (DXC write) */
5281 if (s390_record_gpr_g (gdbarch, regcache, inib[2]))
5282 return -1;
5283 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
5284 return -1;
5285 break;
5286
5287 /* 0xe310-0xe311 undefined */
5288
5289 case 0xe312: /* LT - load and test */
5290 case 0xe338: /* AGH - add halfword to 64 bit value */
5291 case 0xe339: /* SGH - subtract halfword from 64 bit value */
5292 case 0xe353: /* MSC - multiply single 32x32mem -> 32 */
5293 case 0xe354: /* NY - and */
5294 case 0xe356: /* OY - or */
5295 case 0xe357: /* XY - xor */
5296 case 0xe35a: /* AY - add */
5297 case 0xe35b: /* SY - subtract */
5298 case 0xe35e: /* ALY - add logical */
5299 case 0xe35f: /* SLY - subtract logical */
5300 case 0xe37a: /* AHY - add halfword */
5301 case 0xe37b: /* SHY - subtract halfword */
5302 case 0xe383: /* MSGC - multiply single 64x64mem -> 64 */
5303 case 0xe398: /* ALC - add logical with carry */
5304 case 0xe399: /* SLB - subtract logical with borrow */
405feb71 5305 case 0xe727: /* LCBB - load count to block boundary */
ef8914a4
PR
5306 case 0xeb81: /* ICMY - insert characters under mask */
5307 case 0xebdc: /* SRAK - shift left single */
5308 case 0xebdd: /* SLAK - shift left single */
5309 /* 32/64-bit gpr destination + flags */
5310 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
5311 return -1;
5312 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
5313 return -1;
5314 break;
5315
5316 /* 0xe313 privileged */
5317
5318 case 0xe31e: /* LRV - load reversed */
5319 case 0xe31f: /* LRVH - load reversed */
5320 case 0xe33b: /* LZRF - load and zero rightmost byte */
5321 case 0xe351: /* MSY - multiply single */
5322 case 0xe358: /* LY - load */
5323 case 0xe371: /* LAY - load address */
5324 case 0xe373: /* ICY - insert character */
5325 case 0xe376: /* LB - load byte */
5326 case 0xe378: /* LHY - load */
5327 case 0xe37c: /* MHY - multiply halfword */
5328 case 0xe394: /* LLC - load logical character */
5329 case 0xe395: /* LLH - load logical halfword */
5330 case 0xeb1d: /* RLL - rotate left single logical */
5331 case 0xebde: /* SRLK - shift left single logical */
5332 case 0xebdf: /* SLLK - shift left single logical */
5333 case 0xebf2: /* LOC - load on condition */
5334 /* 32-bit or native gpr destination */
5335 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
5336 return -1;
5337 break;
5338
5339 case 0xe320: /* CG - compare */
5340 case 0xe321: /* CLG - compare logical */
5341 case 0xe330: /* CGF - compare */
5342 case 0xe331: /* CLGF - compare logical */
5343 case 0xe334: /* CGH - compare halfword */
5344 case 0xe355: /* CLY - compare logical */
5345 case 0xe359: /* CY - compare */
5346 case 0xe379: /* CHY - compare halfword */
5347 case 0xe3cd: /* CHF - compare high */
5348 case 0xe3cf: /* CLHF - compare logical high */
5349 case 0xeb20: /* CLMH - compare logical under mask high */
5350 case 0xeb21: /* CLMY - compare logical under mask */
5351 case 0xeb51: /* TMY - test under mask */
5352 case 0xeb55: /* CLIY - compare logical */
5353 case 0xebc0: /* TP - test decimal */
5354 case 0xed10: /* TCEB - test data class */
5355 case 0xed11: /* TCDB - test data class */
5356 case 0xed12: /* TCXB - test data class */
5357 case 0xed50: /* TDCET - test data class */
5358 case 0xed51: /* TDGET - test data group */
5359 case 0xed54: /* TDCDT - test data class */
5360 case 0xed55: /* TDGDT - test data group */
5361 case 0xed58: /* TDCXT - test data class */
5362 case 0xed59: /* TDGXT - test data group */
5363 /* flags only */
5364 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
5365 return -1;
5366 break;
5367
5368 /* 0xe322-0xe323 undefined */
5369
5370 case 0xe324: /* STG - store */
5371 case 0xe325: /* NTSTG - nontransactional store */
5372 case 0xe326: /* CVDY - convert to decimal */
5373 case 0xe32f: /* STRVG - store reversed */
ef8914a4
PR
5374 case 0xed67: /* STDY - store */
5375 oaddr = s390_record_calc_disp (gdbarch, regcache, inib[3], insn[1], ibyte[4]);
5376 if (record_full_arch_list_add_mem (oaddr, 8))
5377 return -1;
5378 break;
5379
5380 /* 0xe327-0xe329 undefined */
5381 /* 0xe32b-0xe32d undefined */
5382
5383 case 0xe32e: /* CVDG - convert to decimal */
5384 case 0xe38e: /* STPQ - store pair to quadword */
5385 oaddr = s390_record_calc_disp (gdbarch, regcache, inib[3], insn[1], ibyte[4]);
5386 if (record_full_arch_list_add_mem (oaddr, 16))
5387 return -1;
5388 break;
5389
5390 /* 0xe333 undefined */
5391 /* 0xe335 undefined */
5392
5393 case 0xe336: /* PFD - prefetch data */
5394 break;
5395
5396 /* 0xe337 undefined */
5397 /* 0xe33c-0xe33d undefined */
5398
5399 case 0xe33e: /* STRV - store reversed */
5400 case 0xe350: /* STY - store */
5401 case 0xe3cb: /* STFH - store high */
ef8914a4
PR
5402 case 0xed66: /* STEY - store */
5403 oaddr = s390_record_calc_disp (gdbarch, regcache, inib[3], insn[1], ibyte[4]);
5404 if (record_full_arch_list_add_mem (oaddr, 4))
5405 return -1;
5406 break;
5407
5408 case 0xe33f: /* STRVH - store reversed */
5409 case 0xe370: /* STHY - store halfword */
5410 case 0xe3c7: /* STHH - store halfword high */
5411 oaddr = s390_record_calc_disp (gdbarch, regcache, inib[3], insn[1], ibyte[4]);
5412 if (record_full_arch_list_add_mem (oaddr, 2))
5413 return -1;
5414 break;
5415
5416 /* 0xe340-0xe345 undefined */
5417
5418 case 0xe347: /* BIC - branch indirect on condition */
5419 break;
5420
5421 /* 0xe348-0xe34f undefined */
5422 /* 0xe352 undefined */
5423
5424 case 0xe35c: /* MFY - multiply */
5425 case 0xe396: /* ML - multiply logical */
5426 case 0xe397: /* DL - divide logical */
5427 /* 32-bit gpr pair destination */
5428 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
5429 return -1;
5430 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[2] | 1)))
5431 return -1;
5432 break;
5433
5434 /* 0xe35d undefined */
5435 /* 0xe360-0xe36f undefined */
5436
5437 case 0xe372: /* STCY - store character */
5438 case 0xe3c3: /* STCH - store character high */
5439 oaddr = s390_record_calc_disp (gdbarch, regcache, inib[3], insn[1], ibyte[4]);
5440 if (record_full_arch_list_add_mem (oaddr, 1))
5441 return -1;
5442 break;
5443
5444 /* 0xe374 undefined */
5445
5446 case 0xe375: /* LAEY - load address extended */
5447 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
5448 return -1;
5449 if (record_full_arch_list_add_reg (regcache, S390_A0_REGNUM + inib[2]))
5450 return -1;
5451 break;
5452
5453 /* 0xe37d-0xe37f undefined */
5454
5455 case 0xe385: /* LGAT - load and trap */
5456 case 0xe39c: /* LLGTAT - load logical thirty one bits and trap */
5457 case 0xe39d: /* LLGFAT - load logical and trap */
5458 case 0xe650: /* VCVB - vector convert to binary 32 bit*/
5459 case 0xe652: /* VCVBG - vector convert to binary 64 bit*/
5460 case 0xe721: /* VLGV - vector load gr from vr element */
5461 /* 64-bit gpr destination + fpc for possible DXC write */
5462 if (s390_record_gpr_g (gdbarch, regcache, inib[2]))
5463 return -1;
5464 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
5465 return -1;
5466 break;
5467
5468 /* 0xe38a-0xe38d undefined */
5469 /* 0xe392-0xe393 undefined */
5470 /* 0xe39a-0xe39b undefined */
5471 /* 0xe39e undefined */
5472
5473 case 0xe39f: /* LAT - load and trap */
5474 /* 32-bit gpr destination + fpc for possible DXC write */
5475 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
5476 return -1;
5477 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
5478 return -1;
5479 break;
5480
5481 /* 0xe3a0-0xe3bf undefined */
5482
5483 case 0xe3c0: /* LBH - load byte high */
5484 case 0xe3c2: /* LLCH - load logical character high */
5485 case 0xe3c4: /* LHH - load halfword high */
5486 case 0xe3c6: /* LLHH - load logical halfword high */
5487 case 0xe3ca: /* LFH - load high */
5488 case 0xebe0: /* LOCFH - load high on condition */
5489 /* 32-bit high gpr destination */
5490 if (s390_record_gpr_h (gdbarch, regcache, inib[2]))
5491 return -1;
5492 break;
5493
5494 /* 0xe3c1 undefined */
5495 /* 0xe3c5 undefined */
5496
5497 case 0xe3c8: /* LFHAT - load high and trap */
5498 /* 32-bit high gpr destination + fpc for possible DXC write */
5499 if (s390_record_gpr_h (gdbarch, regcache, inib[2]))
5500 return -1;
5501 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
5502 return -1;
5503 break;
5504
5505 /* 0xe3c9 undefined */
5506 /* 0xe3cc undefined */
5507 /* 0xe3ce undefined */
5508 /* 0xe3d0-0xe3ff undefined */
5509
6d9d6da4
AA
5510 case 0xe601: /* VLEBRH - vector load byte reversed element */
5511 case 0xe602: /* VLEBRG - vector load byte reversed element */
5512 case 0xe603: /* VLEBRF - vector load byte reversed element */
5513 case 0xe604: /* VLLEBRZ - vector load byte rev. el. and zero */
5514 case 0xe605: /* VLBRREP - vector load byte rev. el. and replicate */
5515 case 0xe606: /* VLBR - vector load byte reversed elements */
5516 case 0xe607: /* VLER - vector load elements reversed */
ef8914a4
PR
5517 case 0xe634: /* VPKZ - vector pack zoned */
5518 case 0xe635: /* VLRL - vector load rightmost with immed. length */
5519 case 0xe637: /* VLRLR - vector load rightmost with length */
5520 case 0xe649: /* VLIP - vector load immediate decimal */
5521 case 0xe700: /* VLEB - vector load element */
5522 case 0xe701: /* VLEH - vector load element */
5523 case 0xe702: /* VLEG - vector load element */
5524 case 0xe703: /* VLEF - vector load element */
5525 case 0xe704: /* VLLEZ - vector load logical element and zero */
5526 case 0xe705: /* VLREP - vector load and replicate */
5527 case 0xe706: /* VL - vector load */
405feb71 5528 case 0xe707: /* VLBB - vector load to block boundary */
ef8914a4
PR
5529 case 0xe712: /* VGEG - vector gather element */
5530 case 0xe713: /* VGEF - vector gather element */
5531 case 0xe722: /* VLVG - vector load vr element from gr */
5532 case 0xe730: /* VESL - vector element shift left */
5533 case 0xe733: /* VERLL - vector element rotate left logical */
5534 case 0xe737: /* VLL - vector load with length */
5535 case 0xe738: /* VESRL - vector element shift right logical */
5536 case 0xe73a: /* VESRA - vector element shift right arithmetic */
5537 case 0xe740: /* VLEIB - vector load element immediate */
5538 case 0xe741: /* VLEIH - vector load element immediate */
5539 case 0xe742: /* VLEIG - vector load element immediate */
5540 case 0xe743: /* VLEIF - vector load element immediate */
5541 case 0xe744: /* VGBM - vector generate byte mask */
5542 case 0xe745: /* VREPI - vector replicate immediate */
5543 case 0xe746: /* VGM - vector generate mask */
5544 case 0xe74d: /* VREP - vector replicate */
5545 case 0xe750: /* VPOPCT - vector population count */
5546 case 0xe752: /* VCTZ - vector count trailing zeros */
5547 case 0xe753: /* VCLZ - vector count leading zeros */
5548 case 0xe756: /* VLR - vector load */
5549 case 0xe75f: /* VSEG -vector sign extend to doubleword */
5550 case 0xe760: /* VMRL - vector merge low */
5551 case 0xe761: /* VMRH - vector merge high */
5552 case 0xe762: /* VLVGP - vector load vr from grs disjoint */
5553 case 0xe764: /* VSUM - vector sum across word */
5554 case 0xe765: /* VSUMG - vector sum across doubleword */
5555 case 0xe766: /* VCKSM - vector checksum */
5556 case 0xe767: /* VSUMQ - vector sum across quadword */
5557 case 0xe768: /* VN - vector and */
5558 case 0xe769: /* VNC - vector and with complement */
5559 case 0xe76a: /* VO - vector or */
5560 case 0xe76b: /* VNO - vector nor */
5561 case 0xe76c: /* VNX - vector not exclusive or */
5562 case 0xe76d: /* VX - vector xor */
5563 case 0xe76e: /* VNN - vector nand */
5564 case 0xe76f: /* VOC - vector or with complement */
5565 case 0xe770: /* VESLV - vector element shift left */
5566 case 0xe772: /* VERIM - vector element rotate and insert under mask */
5567 case 0xe773: /* VERLLV - vector element rotate left logical */
5568 case 0xe774: /* VSL - vector shift left */
5569 case 0xe775: /* VSLB - vector shift left by byte */
5570 case 0xe777: /* VSLDB - vector shift left double by byte */
5571 case 0xe778: /* VESRLV - vector element shift right logical */
5572 case 0xe77a: /* VESRAV - vector element shift right arithmetic */
5573 case 0xe77c: /* VSRL - vector shift right logical */
5574 case 0xe77d: /* VSRLB - vector shift right logical by byte */
5575 case 0xe77e: /* VSRA - vector shift right arithmetic */
5576 case 0xe77f: /* VSRAB - vector shift right arithmetic by byte */
5577 case 0xe784: /* VPDI - vector permute doubleword immediate */
5578 case 0xe785: /* VBPERM - vector bit permute */
6d9d6da4
AA
5579 case 0xe786: /* VSLD - vector shift left double by bit */
5580 case 0xe787: /* VSRD - vector shift right double by bit */
5581 case 0xe78b: /* VSTRS - vector string search */
ef8914a4
PR
5582 case 0xe78c: /* VPERM - vector permute */
5583 case 0xe78d: /* VSEL - vector select */
5584 case 0xe78e: /* VFMS - vector fp multiply and subtract */
5585 case 0xe78f: /* VFMA - vector fp multiply and add */
5586 case 0xe794: /* VPK - vector pack */
5587 case 0xe79e: /* VFNMS - vector fp negative multiply and subtract */
5588 case 0xe79f: /* VFNMA - vector fp negative multiply and add */
5589 case 0xe7a1: /* VMLH - vector multiply logical high */
5590 case 0xe7a2: /* VML - vector multiply low */
5591 case 0xe7a3: /* VMH - vector multiply high */
5592 case 0xe7a4: /* VMLE - vector multiply logical even */
5593 case 0xe7a5: /* VMLO - vector multiply logical odd */
5594 case 0xe7a6: /* VME - vector multiply even */
5595 case 0xe7a7: /* VMO - vector multiply odd */
5596 case 0xe7a9: /* VMALH - vector multiply and add logical high */
5597 case 0xe7aa: /* VMAL - vector multiply and add low */
5598 case 0xe7ab: /* VMAH - vector multiply and add high */
5599 case 0xe7ac: /* VMALE - vector multiply and add logical even */
5600 case 0xe7ad: /* VMALO - vector multiply and add logical odd */
5601 case 0xe7ae: /* VMAE - vector multiply and add even */
5602 case 0xe7af: /* VMAO - vector multiply and add odd */
5603 case 0xe7b4: /* VGFM - vector Galois field multiply sum */
5604 case 0xe7b8: /* VMSL - vector multiply sum logical */
5605 case 0xe7b9: /* VACCC - vector add with carry compute carry */
5606 case 0xe7bb: /* VAC - vector add with carry */
5607 case 0xe7bc: /* VGFMA - vector Galois field multiply sum and accumulate */
5608 case 0xe7bd: /* VSBCBI - vector subtract with borrow compute borrow indication */
5609 case 0xe7bf: /* VSBI - vector subtract with borrow indication */
6d9d6da4
AA
5610 case 0xe7c0: /* VCLFP - vector fp convert to logical */
5611 case 0xe7c1: /* VCFPL - vector fp convert from logical */
5612 case 0xe7c2: /* VCSFP - vector fp convert to fixed */
5613 case 0xe7c3: /* VCFPS - vector fp convert from fixed */
ef8914a4
PR
5614 case 0xe7c4: /* VLDE/VFLL - vector fp load lengthened */
5615 case 0xe7c5: /* VLED/VFLR - vector fp load rounded */
5616 case 0xe7c7: /* VFI - vector load fp integer */
5617 case 0xe7cc: /* VFPSO - vector fp perform sign operation */
5618 case 0xe7ce: /* VFSQ - vector fp square root */
5619 case 0xe7d4: /* VUPLL - vector unpack logical low */
5620 case 0xe7d6: /* VUPL - vector unpack low */
5621 case 0xe7d5: /* VUPLH - vector unpack logical high */
5622 case 0xe7d7: /* VUPH - vector unpack high */
5623 case 0xe7de: /* VLC - vector load complement */
5624 case 0xe7df: /* VLP - vector load positive */
5625 case 0xe7e2: /* VFA - vector fp subtract */
5626 case 0xe7e3: /* VFA - vector fp add */
5627 case 0xe7e5: /* VFD - vector fp divide */
5628 case 0xe7e7: /* VFM - vector fp multiply */
5629 case 0xe7ee: /* VFMIN - vector fp minimum */
5630 case 0xe7ef: /* VFMAX - vector fp maximum */
5631 case 0xe7f0: /* VAVGL - vector average logical */
5632 case 0xe7f1: /* VACC - vector add and compute carry */
5633 case 0xe7f2: /* VAVG - vector average */
5634 case 0xe7f3: /* VA - vector add */
5635 case 0xe7f5: /* VSCBI - vector subtract compute borrow indication */
5636 case 0xe7f7: /* VS - vector subtract */
5637 case 0xe7fc: /* VMNL - vector minimum logical */
5638 case 0xe7fd: /* VMXL - vector maximum logical */
5639 case 0xe7fe: /* VMN - vector minimum */
5640 case 0xe7ff: /* VMX - vector maximum */
5641 /* vector destination + FPC */
5642 if (s390_record_vr (gdbarch, regcache, ivec[0]))
5643 return -1;
5644 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
5645 return -1;
5646 break;
5647
5648 case 0xe63d: /* VSTRL - vector store rightmost with immed. length */
5649 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
5650 if (record_full_arch_list_add_mem (oaddr, inib[3] + 1))
5651 return -1;
5652 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
5653 return -1;
5654 break;
5655
5656 case 0xe708: /* VSTEB - vector store element */
5657 oaddr = s390_record_calc_disp (gdbarch, regcache, inib[3], insn[1], 0);
5658 if (record_full_arch_list_add_mem (oaddr, 1))
5659 return -1;
5660 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
5661 return -1;
5662 break;
5663
6d9d6da4 5664 case 0xe609: /* VSTEBRH - vector store byte reversed element */
ef8914a4
PR
5665 case 0xe709: /* VSTEH - vector store element */
5666 oaddr = s390_record_calc_disp (gdbarch, regcache, inib[3], insn[1], 0);
5667 if (record_full_arch_list_add_mem (oaddr, 2))
5668 return -1;
5669 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
5670 return -1;
5671 break;
5672
6d9d6da4 5673 case 0xe60a: /* VSTEBRG - vector store byte reversed element */
ef8914a4
PR
5674 case 0xe70a: /* VSTEG - vector store element */
5675 oaddr = s390_record_calc_disp (gdbarch, regcache, inib[3], insn[1], 0);
5676 if (record_full_arch_list_add_mem (oaddr, 8))
5677 return -1;
5678 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
5679 return -1;
5680 break;
5681
6d9d6da4 5682 case 0xe60b: /* VSTEBRF - vector store byte reversed element */
ef8914a4
PR
5683 case 0xe70b: /* VSTEF - vector store element */
5684 oaddr = s390_record_calc_disp (gdbarch, regcache, inib[3], insn[1], 0);
5685 if (record_full_arch_list_add_mem (oaddr, 4))
5686 return -1;
5687 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
5688 return -1;
5689 break;
5690
5691 /* 0xe70c-0xe70d undefined */
5692
6d9d6da4
AA
5693 case 0xe60e: /* VSTBR - vector store byte reversed elements */
5694 case 0xe60f: /* VSTER - vector store elements reversed */
ef8914a4
PR
5695 case 0xe70e: /* VST - vector store */
5696 oaddr = s390_record_calc_disp (gdbarch, regcache, inib[3], insn[1], 0);
5697 if (record_full_arch_list_add_mem (oaddr, 16))
5698 return -1;
5699 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
5700 return -1;
5701 break;
5702
5703 /* 0xe70f-0xe711 undefined */
5704 /* 0xe714-0xe719 undefined */
5705
5706 case 0xe71a: /* VSCEG - vector scatter element */
5707 if (s390_record_calc_disp_vsce (gdbarch, regcache, ivec[1], inib[8], 8, insn[1], 0, &oaddr))
5708 return -1;
5709 if (record_full_arch_list_add_mem (oaddr, 8))
5710 return -1;
5711 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
5712 return -1;
5713 break;
5714
5715 case 0xe71b: /* VSCEF - vector scatter element */
5716 if (s390_record_calc_disp_vsce (gdbarch, regcache, ivec[1], inib[8], 4, insn[1], 0, &oaddr))
5717 return -1;
5718 if (record_full_arch_list_add_mem (oaddr, 4))
5719 return -1;
5720 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
5721 return -1;
5722 break;
5723
5724 /* 0xe71c-0xe720 undefined */
5725 /* 0xe723-0xe726 undefined */
5726 /* 0xe728-0xe72f undefined */
5727 /* 0xe731-0xe732 undefined */
5728 /* 0xe734-0xe735 undefined */
5729
5730 case 0xe736: /* VLM - vector load multiple */
5731 for (i = ivec[0]; i != ivec[1]; i++, i &= 0x1f)
5732 if (s390_record_vr (gdbarch, regcache, i))
5733 return -1;
5734 if (s390_record_vr (gdbarch, regcache, ivec[1]))
5735 return -1;
5736 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
5737 return -1;
5738 break;
5739
5740 /* 0xe739 undefined */
5741 /* 0xe73b-0xe73d undefined */
5742
5743 case 0xe73e: /* VSTM - vector store multiple */
5744 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
5745 if (ivec[0] <= ivec[1])
5746 n = ivec[1] - ivec[0] + 1;
5747 else
5748 n = ivec[1] + 0x20 - ivec[0] + 1;
5749 if (record_full_arch_list_add_mem (oaddr, n * 16))
5750 return -1;
5751 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
5752 return -1;
5753 break;
5754
5755 case 0xe63c: /* VUPKZ - vector unpack zoned */
5756 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
5757 if (record_full_arch_list_add_mem (oaddr, (ibyte[1] + 1) & 31))
5758 return -1;
5759 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
5760 return -1;
5761 break;
5762
5763 case 0xe63f: /* VSTRLR - vector store rightmost with length */
5764 case 0xe73f: /* VSTL - vector store with length */
5765 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
5766 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + inib[3], &tmp);
5767 tmp &= 0xffffffffu;
5768 if (tmp > 15)
5769 tmp = 15;
5770 if (record_full_arch_list_add_mem (oaddr, tmp + 1))
5771 return -1;
5772 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
5773 return -1;
5774 break;
5775
5776 /* 0xe747-0xe749 undefined */
5777
5778 case 0xe658: /* VCVD - vector convert to decimal 32 bit */
5779 case 0xe659: /* VSRP - vector shift and round decimal */
5780 case 0xe65a: /* VCVDG - vector convert to decimal 64 bit*/
5781 case 0xe65b: /* VPSOP - vector perform sign operation decimal */
5782 case 0xe671: /* VAP - vector add decimal */
5783 case 0xe673: /* VSP - vector subtract decimal */
5784 case 0xe678: /* VMP - vector multiply decimal */
5785 case 0xe679: /* VMSP - vector multiply decimal */
5786 case 0xe67a: /* VDP - vector divide decimal */
5787 case 0xe67b: /* VRP - vector remainder decimal */
5788 case 0xe67e: /* VSDP - vector shift and divide decimal */
5789 case 0xe74a: /* VFTCI - vector fp test data class immediate */
5790 case 0xe75c: /* VISTR - vector isolate string */
5791 case 0xe780: /* VFEE - vector find element equal */
5792 case 0xe781: /* VFENE - vector find element not equal */
5793 case 0xe782: /* VFA - vector find any element equal */
5794 case 0xe78a: /* VSTRC - vector string range compare */
5795 case 0xe795: /* VPKLS - vector pack logical saturate */
5796 case 0xe797: /* VPKS - vector pack saturate */
5797 case 0xe7e8: /* VFCE - vector fp compare equal */
5798 case 0xe7ea: /* VFCHE - vector fp compare high or equal */
5799 case 0xe7eb: /* VFCH - vector fp compare high */
5800 case 0xe7f8: /* VCEQ - vector compare equal */
5801 case 0xe7f9: /* VCHL - vector compare high logical */
5802 case 0xe7fb: /* VCH - vector compare high */
5803 /* vector destination + flags + FPC */
5804 if (s390_record_vr (gdbarch, regcache, ivec[0]))
5805 return -1;
5806 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
5807 return -1;
5808 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
5809 return -1;
5810 break;
5811
5812 case 0xe65f: /* VTP - vector test decimal */
5813 /* flags + FPC */
5814 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
5815 return -1;
5816 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
5817 return -1;
5818 break;
5819
5820 /* 0xe74b-0xe74c undefined */
5821 /* 0xe74e-0xe74f undefined */
5822 /* 0xe751 undefined */
5823 /* 0xe754-0xe755 undefined */
5824 /* 0xe757-0xe75b undefined */
5825 /* 0xe75d-0xe75e undefined */
5826 /* 0xe763 undefined */
5827 /* 0xe771 undefined */
5828 /* 0xe776 undefined */
5829 /* 0xe779 undefined */
5830 /* 0xe77b undefined */
5831 /* 0xe783 undefined */
5832 /* 0xe786-0xe789 undefined */
5833 /* 0xe78b undefined */
5834 /* 0xe790-0xe793 undefined */
5835 /* 0xe796 undefined */
5836 /* 0xe798-0xe79d undefined */
5837 /* 0xe7a0 undefined */
5838 /* 0xe7a8 undefined */
5839 /* 0xe7b0-0xe7b3 undefined */
5840 /* 0xe7b5-0xe7b7 undefined */
5841 /* 0xe7ba undefined */
5842 /* 0xe7be undefined */
5843 /* 0xe7c6 undefined */
5844 /* 0xe7c8-0xe7c9 undefined */
5845
5846 case 0xe677: /* VCP - vector compare decimal */
5847 case 0xe7ca: /* WFK - vector fp compare and signal scalar */
5848 case 0xe7cb: /* WFC - vector fp compare scalar */
5849 case 0xe7d8: /* VTM - vector test under mask */
5850 case 0xe7d9: /* VECL - vector element compare logical */
5851 case 0xe7db: /* VEC - vector element compare */
5852 case 0xed08: /* KEB - compare and signal */
5853 case 0xed09: /* CEB - compare */
5854 case 0xed18: /* KDB - compare and signal */
5855 case 0xed19: /* CDB - compare */
5856 /* flags + fpc only */
5857 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
5858 return -1;
5859 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
5860 return -1;
5861 break;
5862
5863 /* 0xe7cd undefined */
5864 /* 0xe7cf-0xe7d3 undefined */
5865 /* 0xe7da undefined */
5866 /* 0xe7dc-0xe7dd undefined */
5867 /* 0xe7e0-0xe7e1 undefined */
5868 /* 0xe7e4 undefined */
5869 /* 0xe7e6 undefined */
5870 /* 0xe7e9 undefined */
5871 /* 0xe7ec-0xe7ed undefined */
5872 /* 0xe7f4 undefined */
5873 /* 0xe7f6 undefined */
5874 /* 0xe7fa undefined */
5875
5876 /* 0xeb00-0xeb03 undefined */
5877
5878 case 0xeb04: /* LMG - load multiple */
5879 for (i = inib[2]; i != inib[3]; i++, i &= 0xf)
5880 if (s390_record_gpr_g (gdbarch, regcache, i))
5881 return -1;
5882 if (s390_record_gpr_g (gdbarch, regcache, inib[3]))
5883 return -1;
5884 break;
5885
5886 /* 0xeb05-0xeb09 undefined */
5887 /* 0xeb0e undefined */
5888 /* 0xeb0f privileged: TRACG */
5889 /* 0xeb10-0xeb13 undefined */
5890
5891 case 0xeb14: /* CSY - compare and swap */
5892 case 0xebf4: /* LAN - load and and */
5893 case 0xebf6: /* LAO - load and or */
5894 case 0xebf7: /* LAX - load and xor */
5895 case 0xebf8: /* LAA - load and add */
5896 case 0xebfa: /* LAAL - load and add logical */
5897 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], ibyte[4]);
5898 if (record_full_arch_list_add_mem (oaddr, 4))
5899 return -1;
5900 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
5901 return -1;
5902 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
5903 return -1;
5904 break;
5905
5906 /* 0xeb15-0xeb1b undefined */
5907 /* 0xeb1e-0xeb1f undefined */
5908 /* 0xeb22 undefined */
5909
5910 case 0xeb23: /* CLT - compare logical and trap */
5911 case 0xeb2b: /* CLGT - compare logical and trap */
5912 /* fpc only - including possible DXC write for trapping insns */
5913 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
5914 return -1;
5915 break;
5916
5917 case 0xeb24: /* STMG - store multiple */
5918 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], ibyte[4]);
5919 if (inib[2] <= inib[3])
5920 n = inib[3] - inib[2] + 1;
5921 else
5922 n = inib[3] + 0x10 - inib[2] + 1;
5923 if (record_full_arch_list_add_mem (oaddr, n * 8))
5924 return -1;
5925 break;
5926
5927 /* 0xeb25 privileged */
5928
5929 case 0xeb26: /* STMH - store multiple high */
5930 case 0xeb90: /* STMY - store multiple */
5931 case 0xeb9b: /* STAMY - store access multiple */
5932 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], ibyte[4]);
5933 if (inib[2] <= inib[3])
5934 n = inib[3] - inib[2] + 1;
5935 else
5936 n = inib[3] + 0x10 - inib[2] + 1;
5937 if (record_full_arch_list_add_mem (oaddr, n * 4))
5938 return -1;
5939 break;
5940
5941 /* 0xeb27-0xeb2a undefined */
5942
5943 case 0xeb2c: /* STCMH - store characters under mask */
5944 case 0xeb2d: /* STCMY - store characters under mask */
5945 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], ibyte[4]);
5946 if (record_full_arch_list_add_mem (oaddr, s390_popcnt (inib[3])))
5947 return -1;
5948 break;
5949
5950 /* 0xeb2e undefined */
5951 /* 0xeb2f privileged */
5952
5953 case 0xeb30: /* CSG - compare and swap */
5954 case 0xebe4: /* LANG - load and and */
5955 case 0xebe6: /* LAOG - load and or */
5956 case 0xebe7: /* LAXG - load and xor */
5957 case 0xebe8: /* LAAG - load and add */
5958 case 0xebea: /* LAALG - load and add logical */
5959 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], ibyte[4]);
5960 if (record_full_arch_list_add_mem (oaddr, 8))
5961 return -1;
5962 if (s390_record_gpr_g (gdbarch, regcache, inib[2]))
5963 return -1;
5964 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
5965 return -1;
5966 break;
5967
5968 case 0xeb31: /* CDSY - compare double and swap */
5969 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], ibyte[4]);
5970 if (record_full_arch_list_add_mem (oaddr, 8))
5971 return -1;
5972 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
5973 return -1;
5974 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[2] | 1)))
5975 return -1;
5976 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
5977 return -1;
5978 break;
5979
5980 /* 0xeb32-0xeb3d undefined */
5981
5982 case 0xeb3e: /* CDSG - compare double and swap */
5983 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], ibyte[4]);
5984 if (record_full_arch_list_add_mem (oaddr, 16))
5985 return -1;
5986 if (s390_record_gpr_g (gdbarch, regcache, inib[2]))
5987 return -1;
5988 if (s390_record_gpr_g (gdbarch, regcache, inib[2] | 1))
5989 return -1;
5990 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
5991 return -1;
5992 break;
5993
5994 /* 0xeb3f-0xeb43 undefined */
5995 /* 0xeb46-0xeb4b undefined */
5996 /* 0xeb4d-0xeb50 undefined */
5997
5998 case 0xeb52: /* MVIY - move */
5999 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], ibyte[4]);
6000 if (record_full_arch_list_add_mem (oaddr, 1))
6001 return -1;
6002 break;
6003
6004 case 0xeb54: /* NIY - and */
6005 case 0xeb56: /* OIY - or */
6006 case 0xeb57: /* XIY - xor */
6007 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], ibyte[4]);
6008 if (record_full_arch_list_add_mem (oaddr, 1))
6009 return -1;
6010 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
6011 return -1;
6012 break;
6013
6014 /* 0xeb53 undefined */
6015 /* 0xeb58-0xeb69 undefined */
6016
6017 case 0xeb6a: /* ASI - add immediate */
6018 case 0xeb6e: /* ALSI - add immediate */
6019 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], ibyte[4]);
6020 if (record_full_arch_list_add_mem (oaddr, 4))
6021 return -1;
6022 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
6023 return -1;
6024 break;
6025
6026 /* 0xeb6b-0xeb6d undefined */
6027 /* 0xeb6f-0xeb79 undefined */
6028
6029 case 0xeb7a: /* AGSI - add immediate */
6030 case 0xeb7e: /* ALGSI - add immediate */
6031 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], ibyte[4]);
6032 if (record_full_arch_list_add_mem (oaddr, 8))
6033 return -1;
6034 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
6035 return -1;
6036 break;
6037
6038 /* 0xeb7b-0xeb7d undefined */
6039 /* 0xeb7f undefined */
6040
6041 case 0xeb80: /* ICMH - insert characters under mask */
6042 /* 32-bit high gpr destination + flags */
6043 if (s390_record_gpr_h (gdbarch, regcache, inib[2]))
6044 return -1;
6045 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
6046 return -1;
6047 break;
6048
6049 /* 0xeb82-0xeb8d undefined */
6050
6051 case 0xeb8e: /* MVCLU - move long unicode [partial] */
6052 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + inib[2], &tmp);
6053 oaddr = s390_record_address_mask (gdbarch, regcache, tmp);
6054 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + (inib[2] | 1), &tmp);
6055 if (record_full_arch_list_add_mem (oaddr, tmp))
6056 return -1;
6057 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
6058 return -1;
6059 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[2] | 1)))
6060 return -1;
6061 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[3]))
6062 return -1;
6063 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[3] | 1)))
6064 return -1;
6065 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
6066 return -1;
6067 break;
6068
6069 case 0xeb8f: /* CLCLU - compare logical long unicode [partial] */
6070 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
6071 return -1;
6072 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[2] | 1)))
6073 return -1;
6074 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[3]))
6075 return -1;
6076 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[3] | 1)))
6077 return -1;
6078 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
6079 return -1;
6080 break;
6081
6082 /* 0xeb91-0xeb95 undefined */
6083
6084 case 0xeb96: /* LMH - load multiple high */
6085 for (i = inib[2]; i != inib[3]; i++, i &= 0xf)
6086 if (s390_record_gpr_h (gdbarch, regcache, i))
6087 return -1;
6088 if (s390_record_gpr_h (gdbarch, regcache, inib[3]))
6089 return -1;
6090 break;
6091
6092 /* 0xeb97 undefined */
6093
6094 case 0xeb98: /* LMY - load multiple */
6095 for (i = inib[2]; i != inib[3]; i++, i &= 0xf)
6096 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + i))
6097 return -1;
6098 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[3]))
6099 return -1;
6100 break;
6101
6102 /* 0xeb99 undefined */
6103
6104 case 0xeb9a: /* LAMY - load access multiple */
6105 for (i = inib[2]; i != inib[3]; i++, i &= 0xf)
6106 if (record_full_arch_list_add_reg (regcache, S390_A0_REGNUM + i))
6107 return -1;
6108 if (record_full_arch_list_add_reg (regcache, S390_A0_REGNUM + inib[3]))
6109 return -1;
6110 break;
6111
6112 /* 0xeb9c-0xebbf undefined */
6113 /* 0xebc1-0xebdb undefined */
d5ef21c3
AA
6114
6115 case 0xebe1: /* STOCFH - store high on condition */
6116 case 0xebf3: /* STOC - store on condition */
6117 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], ibyte[4]);
6118 if (record_full_arch_list_add_mem (oaddr, 4))
6119 return -1;
6120 break;
6121
6122 case 0xebe3: /* STOCG - store on condition */
6123 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], ibyte[4]);
6124 if (record_full_arch_list_add_mem (oaddr, 8))
6125 return -1;
6126 break;
6127
ef8914a4
PR
6128 /* 0xebe5 undefined */
6129 /* 0xebe9 undefined */
6130 /* 0xebeb-0xebf1 undefined */
6131 /* 0xebf5 undefined */
6132 /* 0xebf9 undefined */
6133 /* 0xebfb-0xebff undefined */
6134
6135 /* 0xed00-0xed03 undefined */
6136
6137 case 0xed04: /* LDEB - load lengthened */
6138 case 0xed0c: /* MDEB - multiply */
6139 case 0xed0d: /* DEB - divide */
6140 case 0xed14: /* SQEB - square root */
6141 case 0xed15: /* SQDB - square root */
6142 case 0xed17: /* MEEB - multiply */
6143 case 0xed1c: /* MDB - multiply */
6144 case 0xed1d: /* DDB - divide */
6145 /* float destination + fpc */
6146 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[2]))
6147 return -1;
6148 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
6149 return -1;
6150 break;
6151
6152 case 0xed05: /* LXDB - load lengthened */
6153 case 0xed06: /* LXEB - load lengthened */
6154 case 0xed07: /* MXDB - multiply */
6155 /* float pair destination + fpc */
6156 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[2]))
6157 return -1;
6158 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + (inib[2] | 2)))
6159 return -1;
6160 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
6161 return -1;
6162 break;
6163
6164 case 0xed0a: /* AEB - add */
6165 case 0xed0b: /* SEB - subtract */
6166 case 0xed1a: /* ADB - add */
6167 case 0xed1b: /* SDB - subtract */
6168 /* float destination + flags + fpc */
6169 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[2]))
6170 return -1;
6171 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
6172 return -1;
6173 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
6174 return -1;
6175 break;
6176
6177 case 0xed0e: /* MAEB - multiply and add */
6178 case 0xed0f: /* MSEB - multiply and subtract */
6179 case 0xed1e: /* MADB - multiply and add */
6180 case 0xed1f: /* MSDB - multiply and subtract */
6181 case 0xed40: /* SLDT - shift significand left */
6182 case 0xed41: /* SRDT - shift significand right */
6183 case 0xedaa: /* CDZT - convert from zoned */
6184 case 0xedae: /* CDPT - convert from packed */
6185 /* float destination [RXF] + fpc */
6186 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[8]))
6187 return -1;
6188 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
6189 return -1;
6190 break;
6191
6192 /* 0xed13 undefined */
6193 /* 0xed16 undefined */
6194 /* 0xed20-0xed23 undefined */
6195
6196 case 0xed24: /* LDE - load lengthened */
6197 case 0xed34: /* SQE - square root */
6198 case 0xed35: /* SQD - square root */
6199 case 0xed37: /* MEE - multiply */
6200 case 0xed64: /* LEY - load */
6201 case 0xed65: /* LDY - load */
6202 /* float destination */
6203 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[2]))
6204 return -1;
6205 break;
6206
6207 case 0xed25: /* LXD - load lengthened */
6208 case 0xed26: /* LXE - load lengthened */
6209 /* float pair destination */
6210 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[2]))
6211 return -1;
6212 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + (inib[2] | 2)))
6213 return -1;
6214 break;
6215
6216 /* 0xed27-0xed2d undefined */
6217
6218 case 0xed2e: /* MAE - multiply and add */
6219 case 0xed2f: /* MSE - multiply and subtract */
6220 case 0xed38: /* MAYL - multiply and add unnormalized */
6221 case 0xed39: /* MYL - multiply unnormalized */
6222 case 0xed3c: /* MAYH - multiply and add unnormalized */
6223 case 0xed3d: /* MYH - multiply unnormalized */
6224 case 0xed3e: /* MAD - multiply and add */
6225 case 0xed3f: /* MSD - multiply and subtract */
6226 /* float destination [RXF] */
6227 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[8]))
6228 return -1;
6229 break;
6230
6231 /* 0xed30-0xed33 undefined */
6232 /* 0xed36 undefined */
6233
6234 case 0xed3a: /* MAY - multiply and add unnormalized */
6235 case 0xed3b: /* MY - multiply unnormalized */
6236 /* float pair destination [RXF] */
6237 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[8]))
6238 return -1;
6239 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + (inib[8] | 2)))
6240 return -1;
6241 break;
6242
405feb71 6243 /* 0xed42-0xed47 undefined */
ef8914a4
PR
6244
6245 case 0xed48: /* SLXT - shift significand left */
6246 case 0xed49: /* SRXT - shift significand right */
6247 case 0xedab: /* CXZT - convert from zoned */
6248 case 0xedaf: /* CXPT - convert from packed */
6249 /* float pair destination [RXF] + fpc */
6250 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[8]))
6251 return -1;
6252 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + (inib[8] | 2)))
6253 return -1;
6254 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
6255 return -1;
6256 break;
6257
405feb71
TV
6258 /* 0xed4a-0xed4f undefined */
6259 /* 0xed52-0xed53 undefined */
6260 /* 0xed56-0xed57 undefined */
6261 /* 0xed5a-0xed63 undefined */
ef8914a4
PR
6262 /* 0xed68-0xeda7 undefined */
6263
6264 case 0xeda8: /* CZDT - convert to zoned */
6265 case 0xeda9: /* CZXT - convert to zoned */
6266 case 0xedac: /* CPDT - convert to packed */
6267 case 0xedad: /* CPXT - convert to packed */
6268 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
6269 if (record_full_arch_list_add_mem (oaddr, ibyte[1] + 1))
6270 return -1;
6271 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
6272 return -1;
6273 break;
6274
6275 /* 0xedb0-0xedff undefined */
6276
6277 default:
6278 goto UNKNOWN_OP;
6279 }
6280 break;
6281
6282 /* 0xe4 undefined */
6283
6284 case 0xe5:
6285 /* SSE/SIL-format instruction */
6286 switch (insn[0])
6287 {
6d9d6da4
AA
6288 /* 0xe500-0xe509 undefined, privileged, or unsupported */
6289
6290 case 0xe50a: /* MVCRL - move right to left */
6291 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM, &tmp);
6292 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
6293 if (record_full_arch_list_add_mem (oaddr, (tmp & 0xff) + 1))
6294 return -1;
6295 break;
6296
6297 /* 0xe50b-0xe543 undefined, privileged, or unsupported */
ef8914a4
PR
6298
6299 case 0xe544: /* MVHHI - move */
6300 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
6301 if (record_full_arch_list_add_mem (oaddr, 2))
6302 return -1;
6303 break;
6304
6305 /* 0xe545-0xe547 undefined */
6306
6307 case 0xe548: /* MVGHI - move */
6308 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
6309 if (record_full_arch_list_add_mem (oaddr, 8))
6310 return -1;
6311 break;
6312
6313 /* 0xe549-0xe54b undefined */
6314
6315 case 0xe54c: /* MVHI - move */
6316 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
6317 if (record_full_arch_list_add_mem (oaddr, 4))
6318 return -1;
6319 break;
6320
6321 /* 0xe54d-0xe553 undefined */
6322
6323 case 0xe554: /* CHHSI - compare halfword immediate */
6324 case 0xe555: /* CLHHSI - compare logical immediate */
6325 case 0xe558: /* CGHSI - compare halfword immediate */
6326 case 0xe559: /* CLGHSI - compare logical immediate */
6327 case 0xe55c: /* CHSI - compare halfword immediate */
6328 case 0xe55d: /* CLFHSI - compare logical immediate */
6329 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
6330 return -1;
6331 break;
6332
6333 /* 0xe556-0xe557 undefined */
6334 /* 0xe55a-0xe55b undefined */
6335 /* 0xe55e-0xe55f undefined */
6336
6337 case 0xe560: /* TBEGIN - transaction begin */
6338 /* The transaction will be immediately aborted after this
6339 instruction, due to single-stepping. This instruction is
6340 only supported so that the program can fail a few times
6341 and go to the non-transactional fallback. */
6342 if (inib[4])
6343 {
6344 /* Transaction diagnostic block - user. */
6345 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
6346 if (record_full_arch_list_add_mem (oaddr, 256))
6347 return -1;
6348 }
6349 /* Transaction diagnostic block - supervisor. */
6350 if (record_full_arch_list_add_reg (regcache, S390_TDB_DWORD0_REGNUM))
6351 return -1;
6352 if (record_full_arch_list_add_reg (regcache, S390_TDB_ABORT_CODE_REGNUM))
6353 return -1;
6354 if (record_full_arch_list_add_reg (regcache, S390_TDB_CONFLICT_TOKEN_REGNUM))
6355 return -1;
6356 if (record_full_arch_list_add_reg (regcache, S390_TDB_ATIA_REGNUM))
6357 return -1;
6358 for (i = 0; i < 16; i++)
6359 if (record_full_arch_list_add_reg (regcache, S390_TDB_R0_REGNUM + i))
6360 return -1;
6361 /* And flags. */
6362 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
6363 return -1;
6364 break;
6365
6366 /* 0xe561 unsupported: TBEGINC */
6367 /* 0xe562-0xe5ff undefined */
6368
6369 default:
6370 goto UNKNOWN_OP;
6371 }
6372 break;
6373
6374 case 0xec:
6375 /* RIE/RIS/RRS-format instruction */
6376 switch (ibyte[0] << 8 | ibyte[5])
6377 {
6378 /* 0xec00-0xec41 undefined */
6379
6380 case 0xec42: /* LOCHI - load halfword immediate on condition */
6381 case 0xec51: /* RISBLG - rotate then insert selected bits low */
6382 /* 32-bit or native gpr destination */
6383 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
6384 return -1;
6385 break;
6386
6387 /* 0xec43 undefined */
6388
6389 case 0xec44: /* BRXHG - branch relative on index high */
6390 case 0xec45: /* BRXLG - branch relative on index low or equal */
6391 case 0xec46: /* LOCGHI - load halfword immediate on condition */
6392 case 0xec59: /* RISBGN - rotate then insert selected bits */
6393 /* 64-bit gpr destination */
6394 if (s390_record_gpr_g (gdbarch, regcache, inib[2]))
6395 return -1;
6396 break;
6397
6398 /* 0xec47-0xec4d undefined */
6399
6400 case 0xec4e: /* LOCHHI - load halfword immediate on condition */
6401 case 0xec5d: /* RISBHG - rotate then insert selected bits high */
6402 /* 32-bit high gpr destination */
6403 if (s390_record_gpr_h (gdbarch, regcache, inib[2]))
6404 return -1;
6405 break;
6406
6407 /* 0xec4f-0xec50 undefined */
6408 /* 0xec52-0xec53 undefined */
6409
6410 case 0xec54: /* RNSBG - rotate then and selected bits */
6411 case 0xec55: /* RISBG - rotate then insert selected bits */
6412 case 0xec56: /* ROSBG - rotate then or selected bits */
6413 case 0xec57: /* RXSBG - rotate then xor selected bits */
6414 case 0xecd9: /* AGHIK - add immediate */
6415 case 0xecdb: /* ALGHSIK - add logical immediate */
6416 /* 64-bit gpr destination + flags */
6417 if (s390_record_gpr_g (gdbarch, regcache, inib[2]))
6418 return -1;
6419 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
6420 return -1;
6421 break;
6422
6423 /* 0xec58 undefined */
6424 /* 0xec5a-0xec5c undefined */
6425 /* 0xec5e-0xec63 undefined */
6426
6427 case 0xec64: /* CGRJ - compare and branch relative */
6428 case 0xec65: /* CLGRJ - compare logical and branch relative */
6429 case 0xec76: /* CRJ - compare and branch relative */
6430 case 0xec77: /* CLRJ - compare logical and branch relative */
6431 case 0xec7c: /* CGIJ - compare immediate and branch relative */
6432 case 0xec7d: /* CLGIJ - compare logical immediate and branch relative */
6433 case 0xec7e: /* CIJ - compare immediate and branch relative */
6434 case 0xec7f: /* CLIJ - compare logical immediate and branch relative */
6435 case 0xece4: /* CGRB - compare and branch */
6436 case 0xece5: /* CLGRB - compare logical and branch */
6437 case 0xecf6: /* CRB - compare and branch */
6438 case 0xecf7: /* CLRB - compare logical and branch */
6439 case 0xecfc: /* CGIB - compare immediate and branch */
6440 case 0xecfd: /* CLGIB - compare logical immediate and branch */
6441 case 0xecfe: /* CIB - compare immediate and branch */
6442 case 0xecff: /* CLIB - compare logical immediate and branch */
6443 break;
6444
6445 /* 0xec66-0xec6f undefined */
6446
6447 case 0xec70: /* CGIT - compare immediate and trap */
6448 case 0xec71: /* CLGIT - compare logical immediate and trap */
6449 case 0xec72: /* CIT - compare immediate and trap */
6450 case 0xec73: /* CLFIT - compare logical immediate and trap */
6451 /* fpc only - including possible DXC write for trapping insns */
6452 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
6453 return -1;
6454 break;
6455
6456 /* 0xec74-0xec75 undefined */
6457 /* 0xec78-0xec7b undefined */
6458
6459 /* 0xec80-0xecd7 undefined */
6460
6461 case 0xecd8: /* AHIK - add immediate */
6462 case 0xecda: /* ALHSIK - add logical immediate */
6463 /* 32-bit gpr destination + flags */
6464 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
6465 return -1;
6466 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
6467 return -1;
6468 break;
6469
6470 /* 0xecdc-0xece3 undefined */
6471 /* 0xece6-0xecf5 undefined */
6472 /* 0xecf8-0xecfb undefined */
6473
6474 default:
6475 goto UNKNOWN_OP;
6476 }
6477 break;
6478
6479 case 0xee: /* PLO - perform locked operation */
6480 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM, &tmp);
6481 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
6482 oaddr2 = s390_record_calc_disp (gdbarch, regcache, 0, insn[2], 0);
6483 if (!(tmp & 0x100))
6484 {
6485 uint8_t fc = tmp & 0xff;
6486 gdb_byte buf[8];
6487 switch (fc)
6488 {
6489 case 0x00: /* CL */
6490 /* op1c */
6491 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
6492 return -1;
6493 /* op3 */
6494 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[3]))
6495 return -1;
6496 break;
6497
6498 case 0x01: /* CLG */
6499 /* op1c */
6500 if (record_full_arch_list_add_mem (oaddr2 + 0x08, 8))
6501 return -1;
6502 /* op3 */
6503 if (record_full_arch_list_add_mem (oaddr2 + 0x28, 8))
6504 return -1;
6505 break;
6506
6507 case 0x02: /* CLGR */
6508 /* op1c */
6509 if (s390_record_gpr_g (gdbarch, regcache, inib[2]))
6510 return -1;
6511 /* op3 */
6512 if (s390_record_gpr_g (gdbarch, regcache, inib[3]))
6513 return -1;
6514 break;
6515
6516 case 0x03: /* CLX */
6517 /* op1c */
6518 if (record_full_arch_list_add_mem (oaddr2 + 0x00, 16))
6519 return -1;
6520 /* op3 */
6521 if (record_full_arch_list_add_mem (oaddr2 + 0x20, 16))
6522 return -1;
6523 break;
6524
6525 case 0x08: /* DCS */
6526 /* op3c */
6527 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[3]))
6528 return -1;
6529 /* fallthru */
6530 case 0x0c: /* CSST */
6531 /* op4 */
6532 if (record_full_arch_list_add_mem (oaddr2, 4))
6533 return -1;
6534 goto CS;
6535
6536 case 0x14: /* CSTST */
6537 /* op8 */
6538 if (target_read_memory (oaddr2 + 0x88, buf, 8))
6539 return -1;
6540 oaddr3 = extract_unsigned_integer (buf, 8, byte_order);
6541 oaddr3 = s390_record_address_mask (gdbarch, regcache, oaddr3);
6542 if (record_full_arch_list_add_mem (oaddr3, 4))
6543 return -1;
6544 /* fallthru */
6545 case 0x10: /* CSDST */
6546 /* op6 */
6547 if (target_read_memory (oaddr2 + 0x68, buf, 8))
6548 return -1;
6549 oaddr3 = extract_unsigned_integer (buf, 8, byte_order);
6550 oaddr3 = s390_record_address_mask (gdbarch, regcache, oaddr3);
6551 if (record_full_arch_list_add_mem (oaddr3, 4))
6552 return -1;
6553 /* op4 */
6554 if (target_read_memory (oaddr2 + 0x48, buf, 8))
6555 return -1;
6556 oaddr3 = extract_unsigned_integer (buf, 8, byte_order);
6557 oaddr3 = s390_record_address_mask (gdbarch, regcache, oaddr3);
6558 if (record_full_arch_list_add_mem (oaddr3, 4))
6559 return -1;
6560 /* fallthru */
6561 case 0x04: /* CS */
6562CS:
6563 /* op1c */
6564 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
6565 return -1;
6566 /* op2 */
6567 if (record_full_arch_list_add_mem (oaddr, 4))
6568 return -1;
6569 break;
6570
6571 case 0x09: /* DCSG */
6572 /* op3c */
6573 if (record_full_arch_list_add_mem (oaddr2 + 0x28, 8))
6574 return -1;
6575 goto CSSTG;
6576
6577 case 0x15: /* CSTSTG */
6578 /* op8 */
6579 if (target_read_memory (oaddr2 + 0x88, buf, 8))
6580 return -1;
6581 oaddr3 = extract_unsigned_integer (buf, 8, byte_order);
6582 oaddr3 = s390_record_address_mask (gdbarch, regcache, oaddr3);
6583 if (record_full_arch_list_add_mem (oaddr3, 8))
6584 return -1;
6585 /* fallthru */
6586 case 0x11: /* CSDSTG */
6587 /* op6 */
6588 if (target_read_memory (oaddr2 + 0x68, buf, 8))
6589 return -1;
6590 oaddr3 = extract_unsigned_integer (buf, 8, byte_order);
6591 oaddr3 = s390_record_address_mask (gdbarch, regcache, oaddr3);
6592 if (record_full_arch_list_add_mem (oaddr3, 8))
6593 return -1;
6594 /* fallthru */
6595 case 0x0d: /* CSSTG */
6596CSSTG:
6597 /* op4 */
6598 if (target_read_memory (oaddr2 + 0x48, buf, 8))
6599 return -1;
6600 oaddr3 = extract_unsigned_integer (buf, 8, byte_order);
6601 oaddr3 = s390_record_address_mask (gdbarch, regcache, oaddr3);
6602 if (record_full_arch_list_add_mem (oaddr3, 8))
6603 return -1;
6604 /* fallthru */
6605 case 0x05: /* CSG */
6606 /* op1c */
6607 if (record_full_arch_list_add_mem (oaddr2 + 0x08, 8))
6608 return -1;
6609 /* op2 */
6610 if (record_full_arch_list_add_mem (oaddr, 8))
6611 return -1;
6612 break;
6613
6614 case 0x0a: /* DCSGR */
6615 /* op3c */
6616 if (s390_record_gpr_g (gdbarch, regcache, inib[3]))
6617 return -1;
6618 /* fallthru */
6619 case 0x0e: /* CSSTGR */
6620 /* op4 */
6621 if (record_full_arch_list_add_mem (oaddr2, 8))
6622 return -1;
6623 goto CSGR;
6624
6625 case 0x16: /* CSTSTGR */
6626 /* op8 */
6627 if (target_read_memory (oaddr2 + 0x88, buf, 8))
6628 return -1;
6629 oaddr3 = extract_unsigned_integer (buf, 8, byte_order);
6630 oaddr3 = s390_record_address_mask (gdbarch, regcache, oaddr3);
6631 if (record_full_arch_list_add_mem (oaddr3, 8))
6632 return -1;
6633 /* fallthru */
6634 case 0x12: /* CSDSTGR */
6635 /* op6 */
6636 if (target_read_memory (oaddr2 + 0x68, buf, 8))
6637 return -1;
6638 oaddr3 = extract_unsigned_integer (buf, 8, byte_order);
6639 oaddr3 = s390_record_address_mask (gdbarch, regcache, oaddr3);
6640 if (record_full_arch_list_add_mem (oaddr3, 8))
6641 return -1;
6642 /* op4 */
6643 if (target_read_memory (oaddr2 + 0x48, buf, 8))
6644 return -1;
6645 oaddr3 = extract_unsigned_integer (buf, 8, byte_order);
6646 oaddr3 = s390_record_address_mask (gdbarch, regcache, oaddr3);
6647 if (record_full_arch_list_add_mem (oaddr3, 8))
6648 return -1;
6649 /* fallthru */
6650 case 0x06: /* CSGR */
6651CSGR:
6652 /* op1c */
6653 if (s390_record_gpr_g (gdbarch, regcache, inib[2]))
6654 return -1;
6655 /* op2 */
6656 if (record_full_arch_list_add_mem (oaddr, 8))
6657 return -1;
6658 break;
6659
6660 case 0x0b: /* DCSX */
6661 /* op3c */
6662 if (record_full_arch_list_add_mem (oaddr2 + 0x20, 16))
6663 return -1;
6664 goto CSSTX;
6665
6666 case 0x17: /* CSTSTX */
6667 /* op8 */
6668 if (target_read_memory (oaddr2 + 0x88, buf, 8))
6669 return -1;
6670 oaddr3 = extract_unsigned_integer (buf, 8, byte_order);
6671 oaddr3 = s390_record_address_mask (gdbarch, regcache, oaddr3);
6672 if (record_full_arch_list_add_mem (oaddr3, 16))
6673 return -1;
6674 /* fallthru */
6675 case 0x13: /* CSDSTX */
6676 /* op6 */
6677 if (target_read_memory (oaddr2 + 0x68, buf, 8))
6678 return -1;
6679 oaddr3 = extract_unsigned_integer (buf, 8, byte_order);
6680 oaddr3 = s390_record_address_mask (gdbarch, regcache, oaddr3);
6681 if (record_full_arch_list_add_mem (oaddr3, 16))
6682 return -1;
6683 /* fallthru */
6684 case 0x0f: /* CSSTX */
6685CSSTX:
6686 /* op4 */
6687 if (target_read_memory (oaddr2 + 0x48, buf, 8))
6688 return -1;
6689 oaddr3 = extract_unsigned_integer (buf, 8, byte_order);
6690 oaddr3 = s390_record_address_mask (gdbarch, regcache, oaddr3);
6691 if (record_full_arch_list_add_mem (oaddr3, 16))
6692 return -1;
6693 /* fallthru */
6694 case 0x07: /* CSX */
6695 /* op1c */
6696 if (record_full_arch_list_add_mem (oaddr2 + 0x00, 16))
6697 return -1;
6698 /* op2 */
6699 if (record_full_arch_list_add_mem (oaddr, 16))
6700 return -1;
6701 break;
6702
6703 default:
6704 fprintf_unfiltered (gdb_stdlog, "Warning: Unknown PLO FC %02x at %s.\n",
6705 fc, paddress (gdbarch, addr));
6706 return -1;
6707 }
6708 }
6709 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
6710 return -1;
6711 break;
6712
6713 case 0xef: /* LMD - load multiple disjoint */
6714 for (i = inib[2]; i != inib[3]; i++, i &= 0xf)
6715 if (s390_record_gpr_g (gdbarch, regcache, i))
6716 return -1;
6717 if (s390_record_gpr_g (gdbarch, regcache, inib[3]))
6718 return -1;
6719 break;
6720
6721 case 0xf0: /* SRP - shift and round decimal */
6722 case 0xf8: /* ZAP - zero and add */
6723 case 0xfa: /* AP - add decimal */
6724 case 0xfb: /* SP - subtract decimal */
6725 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
6726 if (record_full_arch_list_add_mem (oaddr, inib[2] + 1))
6727 return -1;
6728 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
6729 return -1;
6730 /* DXC may be written */
6731 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
6732 return -1;
6733 break;
6734
6735 case 0xf1: /* MVO - move with offset */
6736 case 0xf2: /* PACK - pack */
6737 case 0xf3: /* UNPK - unpack */
6738 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
6739 if (record_full_arch_list_add_mem (oaddr, inib[2] + 1))
6740 return -1;
6741 break;
6742
6743 /* 0xf4-0xf7 undefined */
6744
6745 case 0xf9: /* CP - compare decimal */
6746 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
6747 return -1;
6748 /* DXC may be written */
6749 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
6750 return -1;
6751 break;
6752
6753 case 0xfc: /* MP - multiply decimal */
6754 case 0xfd: /* DP - divide decimal */
6755 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
6756 if (record_full_arch_list_add_mem (oaddr, inib[2] + 1))
6757 return -1;
6758 /* DXC may be written */
6759 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
6760 return -1;
6761 break;
6762
6763 /* 0xfe-0xff undefined */
6764
6765 default:
6766UNKNOWN_OP:
6767 fprintf_unfiltered (gdb_stdlog, "Warning: Don't know how to record %04x "
6768 "at %s.\n", insn[0], paddress (gdbarch, addr));
6769 return -1;
6770 }
6771
6772 if (record_full_arch_list_add_reg (regcache, S390_PSWA_REGNUM))
6773 return -1;
6774 if (record_full_arch_list_add_end ())
6775 return -1;
6776 return 0;
6777}
6778
d6e58945
PR
6779/* Miscellaneous. */
6780
6781/* Implement gdbarch_gcc_target_options. GCC does not know "-m32" or
6782 "-mcmodel=large". */
6783
953cff56 6784static std::string
d6e58945
PR
6785s390_gcc_target_options (struct gdbarch *gdbarch)
6786{
953cff56 6787 return gdbarch_ptr_bit (gdbarch) == 64 ? "-m64" : "-m31";
d6e58945
PR
6788}
6789
6790/* Implement gdbarch_gnu_triplet_regexp. Target triplets are "s390-*"
6791 for 31-bit and "s390x-*" for 64-bit, while the BFD arch name is
6792 always "s390". Note that an s390x compiler supports "-m31" as
6793 well. */
6794
6795static const char *
6796s390_gnu_triplet_regexp (struct gdbarch *gdbarch)
6797{
6798 return "s390x?";
6799}
6800
6801/* Implementation of `gdbarch_stap_is_single_operand', as defined in
6802 gdbarch.h. */
6803
6804static int
6805s390_stap_is_single_operand (struct gdbarch *gdbarch, const char *s)
6806{
6807 return ((isdigit (*s) && s[1] == '(' && s[2] == '%') /* Displacement
6808 or indirection. */
6809 || *s == '%' /* Register access. */
6810 || isdigit (*s)); /* Literal number. */
6811}
6812
6813/* gdbarch init. */
6814
6815/* Validate the range of registers. NAMES must be known at compile time. */
6816
6817#define s390_validate_reg_range(feature, tdesc_data, start, names) \
6818do \
6819{ \
6820 for (int i = 0; i < ARRAY_SIZE (names); i++) \
6821 if (!tdesc_numbered_register (feature, tdesc_data, start + i, names[i])) \
6822 return false; \
6823} \
6824while (0)
6825
6826/* Validate the target description. Also numbers registers contained in
6827 tdesc. */
6828
6829static bool
6830s390_tdesc_valid (struct gdbarch_tdep *tdep,
6831 struct tdesc_arch_data *tdesc_data)
6832{
6833 static const char *const psw[] = {
6834 "pswm", "pswa"
6835 };
6836 static const char *const gprs[] = {
6837 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
6838 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15"
6839 };
6840 static const char *const fprs[] = {
6841 "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7",
6842 "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15"
6843 };
6844 static const char *const acrs[] = {
6845 "acr0", "acr1", "acr2", "acr3", "acr4", "acr5", "acr6", "acr7",
6846 "acr8", "acr9", "acr10", "acr11", "acr12", "acr13", "acr14", "acr15"
6847 };
6848 static const char *const gprs_lower[] = {
6849 "r0l", "r1l", "r2l", "r3l", "r4l", "r5l", "r6l", "r7l",
6850 "r8l", "r9l", "r10l", "r11l", "r12l", "r13l", "r14l", "r15l"
6851 };
6852 static const char *const gprs_upper[] = {
6853 "r0h", "r1h", "r2h", "r3h", "r4h", "r5h", "r6h", "r7h",
6854 "r8h", "r9h", "r10h", "r11h", "r12h", "r13h", "r14h", "r15h"
6855 };
6856 static const char *const tdb_regs[] = {
6857 "tdb0", "tac", "tct", "atia",
6858 "tr0", "tr1", "tr2", "tr3", "tr4", "tr5", "tr6", "tr7",
6859 "tr8", "tr9", "tr10", "tr11", "tr12", "tr13", "tr14", "tr15"
6860 };
6861 static const char *const vxrs_low[] = {
6862 "v0l", "v1l", "v2l", "v3l", "v4l", "v5l", "v6l", "v7l", "v8l",
6863 "v9l", "v10l", "v11l", "v12l", "v13l", "v14l", "v15l",
6864 };
6865 static const char *const vxrs_high[] = {
6866 "v16", "v17", "v18", "v19", "v20", "v21", "v22", "v23", "v24",
6867 "v25", "v26", "v27", "v28", "v29", "v30", "v31",
6868 };
6869 static const char *const gs_cb[] = {
6870 "gsd", "gssm", "gsepla",
6871 };
6872 static const char *const gs_bc[] = {
6873 "bc_gsd", "bc_gssm", "bc_gsepla",
6874 };
6875
6876 const struct target_desc *tdesc = tdep->tdesc;
6877 const struct tdesc_feature *feature;
6878
c81e8879
PR
6879 if (!tdesc_has_registers (tdesc))
6880 return false;
6881
d6e58945
PR
6882 /* Core registers, i.e. general purpose and PSW. */
6883 feature = tdesc_find_feature (tdesc, "org.gnu.gdb.s390.core");
6884 if (feature == NULL)
6885 return false;
6886
6887 s390_validate_reg_range (feature, tdesc_data, S390_PSWM_REGNUM, psw);
6888
6889 if (tdesc_unnumbered_register (feature, "r0"))
6890 {
6891 s390_validate_reg_range (feature, tdesc_data, S390_R0_REGNUM, gprs);
6892 }
6893 else
6894 {
6895 tdep->have_upper = true;
6896 s390_validate_reg_range (feature, tdesc_data, S390_R0_REGNUM,
6897 gprs_lower);
6898 s390_validate_reg_range (feature, tdesc_data, S390_R0_UPPER_REGNUM,
6899 gprs_upper);
6900 }
6901
6902 /* Floating point registers. */
6903 feature = tdesc_find_feature (tdesc, "org.gnu.gdb.s390.fpr");
6904 if (feature == NULL)
6905 return false;
6906
6907 if (!tdesc_numbered_register (feature, tdesc_data, S390_FPC_REGNUM, "fpc"))
6908 return false;
6909
6910 s390_validate_reg_range (feature, tdesc_data, S390_F0_REGNUM, fprs);
6911
6912 /* Access control registers. */
6913 feature = tdesc_find_feature (tdesc, "org.gnu.gdb.s390.acr");
6914 if (feature == NULL)
6915 return false;
6916
6917 s390_validate_reg_range (feature, tdesc_data, S390_A0_REGNUM, acrs);
6918
6919 /* Optional GNU/Linux-specific "registers". */
6920 feature = tdesc_find_feature (tdesc, "org.gnu.gdb.s390.linux");
6921 if (feature)
6922 {
6923 tdesc_numbered_register (feature, tdesc_data,
6924 S390_ORIG_R2_REGNUM, "orig_r2");
6925
6926 if (tdesc_numbered_register (feature, tdesc_data,
6927 S390_LAST_BREAK_REGNUM, "last_break"))
6928 tdep->have_linux_v1 = true;
6929
6930 if (tdesc_numbered_register (feature, tdesc_data,
6931 S390_SYSTEM_CALL_REGNUM, "system_call"))
6932 tdep->have_linux_v2 = true;
6933
6934 if (tdep->have_linux_v2 && !tdep->have_linux_v1)
6935 return false;
6936 }
6937
6938 /* Transaction diagnostic block. */
6939 feature = tdesc_find_feature (tdesc, "org.gnu.gdb.s390.tdb");
6940 if (feature)
6941 {
6942 s390_validate_reg_range (feature, tdesc_data, S390_TDB_DWORD0_REGNUM,
6943 tdb_regs);
6944 tdep->have_tdb = true;
6945 }
6946
6947 /* Vector registers. */
6948 feature = tdesc_find_feature (tdesc, "org.gnu.gdb.s390.vx");
6949 if (feature)
6950 {
6951 s390_validate_reg_range (feature, tdesc_data, S390_V0_LOWER_REGNUM,
6952 vxrs_low);
6953 s390_validate_reg_range (feature, tdesc_data, S390_V16_REGNUM,
6954 vxrs_high);
6955 tdep->have_vx = true;
6956 }
6957
6958 /* Guarded-storage registers. */
6959 feature = tdesc_find_feature (tdesc, "org.gnu.gdb.s390.gs");
6960 if (feature)
6961 {
6962 s390_validate_reg_range (feature, tdesc_data, S390_GSD_REGNUM, gs_cb);
6963 tdep->have_gs = true;
6964 }
6965
6966 /* Guarded-storage broadcast control. */
6967 feature = tdesc_find_feature (tdesc, "org.gnu.gdb.s390.gsbc");
6968 if (feature)
6969 {
6970 if (!tdep->have_gs)
6971 return false;
6972 s390_validate_reg_range (feature, tdesc_data, S390_BC_GSD_REGNUM,
6973 gs_bc);
6974 }
6975
6976 return true;
6977}
6978
6979/* Allocate and initialize new gdbarch_tdep. Caller is responsible to free
6980 memory after use. */
6981
6982static struct gdbarch_tdep *
6983s390_gdbarch_tdep_alloc ()
6984{
6985 struct gdbarch_tdep *tdep = XCNEW (struct gdbarch_tdep);
6986
6987 tdep->tdesc = NULL;
6988
6989 tdep->abi = ABI_NONE;
6990 tdep->vector_abi = S390_VECTOR_ABI_NONE;
6991
6992 tdep->gpr_full_regnum = -1;
6993 tdep->v0_full_regnum = -1;
6994 tdep->pc_regnum = -1;
6995 tdep->cc_regnum = -1;
6996
6997 tdep->have_upper = false;
6998 tdep->have_linux_v1 = false;
6999 tdep->have_linux_v2 = false;
7000 tdep->have_tdb = false;
7001 tdep->have_vx = false;
7002 tdep->have_gs = false;
7003
7004 tdep->s390_syscall_record = NULL;
7005
7006 return tdep;
7007}
7008
7009/* Set up gdbarch struct. */
7010
7011static struct gdbarch *
7012s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
7013{
7014 const struct target_desc *tdesc = info.target_desc;
7015 int first_pseudo_reg, last_pseudo_reg;
7016 static const char *const stap_register_prefixes[] = { "%", NULL };
7017 static const char *const stap_register_indirection_prefixes[] = { "(",
7018 NULL };
7019 static const char *const stap_register_indirection_suffixes[] = { ")",
7020 NULL };
7021
d6e58945
PR
7022 struct gdbarch_tdep *tdep = s390_gdbarch_tdep_alloc ();
7023 struct gdbarch *gdbarch = gdbarch_alloc (&info, tdep);
c1e1314d
TT
7024 tdesc_arch_data_up tdesc_data = tdesc_data_alloc ();
7025 info.tdesc_data = tdesc_data.get ();
d6e58945
PR
7026
7027 set_gdbarch_believe_pcc_promotion (gdbarch, 0);
7028 set_gdbarch_char_signed (gdbarch, 0);
7029
7030 /* S/390 GNU/Linux uses either 64-bit or 128-bit long doubles.
7031 We can safely let them default to 128-bit, since the debug info
7032 will give the size of type actually used in each case. */
7033 set_gdbarch_long_double_bit (gdbarch, 128);
7034 set_gdbarch_long_double_format (gdbarch, floatformats_ia64_quad);
7035
1022c627
AA
7036 set_gdbarch_type_align (gdbarch, s390_type_align);
7037
d6e58945
PR
7038 /* Breakpoints. */
7039 /* Amount PC must be decremented by after a breakpoint. This is
7040 often the number of bytes returned by gdbarch_breakpoint_from_pc but not
7041 always. */
7042 set_gdbarch_decr_pc_after_break (gdbarch, 2);
7043 set_gdbarch_breakpoint_kind_from_pc (gdbarch, s390_breakpoint::kind_from_pc);
7044 set_gdbarch_sw_breakpoint_from_kind (gdbarch, s390_breakpoint::bp_from_kind);
7045
7046 /* Displaced stepping. */
7047 set_gdbarch_displaced_step_copy_insn (gdbarch,
7048 s390_displaced_step_copy_insn);
7049 set_gdbarch_displaced_step_fixup (gdbarch, s390_displaced_step_fixup);
187b041e
SM
7050 set_gdbarch_displaced_step_prepare (gdbarch, linux_displaced_step_prepare);
7051 set_gdbarch_displaced_step_finish (gdbarch, linux_displaced_step_finish);
7052 set_gdbarch_displaced_step_restore_all_in_ptid
7053 (gdbarch, linux_displaced_step_restore_all_in_ptid);
d6e58945
PR
7054 set_gdbarch_displaced_step_hw_singlestep (gdbarch, s390_displaced_step_hw_singlestep);
7055 set_gdbarch_software_single_step (gdbarch, s390_software_single_step);
7056 set_gdbarch_max_insn_length (gdbarch, S390_MAX_INSTR_SIZE);
7057
7058 /* Prologue analysis. */
7059 set_gdbarch_skip_prologue (gdbarch, s390_skip_prologue);
7060
7061 /* Register handling. */
7062 set_gdbarch_num_regs (gdbarch, S390_NUM_REGS);
7063 set_gdbarch_sp_regnum (gdbarch, S390_SP_REGNUM);
7064 set_gdbarch_fp0_regnum (gdbarch, S390_F0_REGNUM);
7065 set_gdbarch_guess_tracepoint_registers (gdbarch,
7066 s390_guess_tracepoint_registers);
7067 set_gdbarch_stab_reg_to_regnum (gdbarch, s390_dwarf_reg_to_regnum);
7068 set_gdbarch_dwarf2_reg_to_regnum (gdbarch, s390_dwarf_reg_to_regnum);
7069 set_gdbarch_value_from_register (gdbarch, s390_value_from_register);
7070
7071 /* Pseudo registers. */
7072 set_gdbarch_pseudo_register_read (gdbarch, s390_pseudo_register_read);
7073 set_gdbarch_pseudo_register_write (gdbarch, s390_pseudo_register_write);
7074 set_tdesc_pseudo_register_name (gdbarch, s390_pseudo_register_name);
7075 set_tdesc_pseudo_register_type (gdbarch, s390_pseudo_register_type);
7076 set_tdesc_pseudo_register_reggroup_p (gdbarch,
7077 s390_pseudo_register_reggroup_p);
7078 set_gdbarch_ax_pseudo_register_collect (gdbarch,
7079 s390_ax_pseudo_register_collect);
7080 set_gdbarch_ax_pseudo_register_push_stack
7081 (gdbarch, s390_ax_pseudo_register_push_stack);
7082 set_gdbarch_gen_return_address (gdbarch, s390_gen_return_address);
7083
7084 /* Inferior function calls. */
7085 set_gdbarch_push_dummy_call (gdbarch, s390_push_dummy_call);
7086 set_gdbarch_dummy_id (gdbarch, s390_dummy_id);
7087 set_gdbarch_frame_align (gdbarch, s390_frame_align);
7088 set_gdbarch_return_value (gdbarch, s390_return_value);
7089
7090 /* Frame handling. */
7091 /* Stack grows downward. */
7092 set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
7093 set_gdbarch_stack_frame_destroyed_p (gdbarch, s390_stack_frame_destroyed_p);
7094 dwarf2_frame_set_init_reg (gdbarch, s390_dwarf2_frame_init_reg);
7095 dwarf2_frame_set_adjust_regnum (gdbarch, s390_adjust_frame_regnum);
7096 dwarf2_append_unwinders (gdbarch);
7097 set_gdbarch_unwind_pc (gdbarch, s390_unwind_pc);
7098 set_gdbarch_unwind_sp (gdbarch, s390_unwind_sp);
7099
7100 switch (info.bfd_arch_info->mach)
7101 {
7102 case bfd_mach_s390_31:
7103 set_gdbarch_addr_bits_remove (gdbarch, s390_addr_bits_remove);
7104 break;
7105
7106 case bfd_mach_s390_64:
7107 set_gdbarch_long_bit (gdbarch, 64);
7108 set_gdbarch_long_long_bit (gdbarch, 64);
7109 set_gdbarch_ptr_bit (gdbarch, 64);
7110 set_gdbarch_address_class_type_flags (gdbarch,
7111 s390_address_class_type_flags);
7112 set_gdbarch_address_class_type_flags_to_name (gdbarch,
7113 s390_address_class_type_flags_to_name);
7114 set_gdbarch_address_class_name_to_type_flags (gdbarch,
7115 s390_address_class_name_to_type_flags);
7116 break;
7117 }
7118
7119 /* SystemTap functions. */
7120 set_gdbarch_stap_register_prefixes (gdbarch, stap_register_prefixes);
7121 set_gdbarch_stap_register_indirection_prefixes (gdbarch,
7122 stap_register_indirection_prefixes);
7123 set_gdbarch_stap_register_indirection_suffixes (gdbarch,
7124 stap_register_indirection_suffixes);
7125
7126 set_gdbarch_disassembler_options (gdbarch, &s390_disassembler_options);
7127 set_gdbarch_valid_disassembler_options (gdbarch,
7128 disassembler_options_s390 ());
7129
ef8914a4
PR
7130 /* Process record-replay */
7131 set_gdbarch_process_record (gdbarch, s390_process_record);
7132
d6e58945
PR
7133 /* Miscellaneous. */
7134 set_gdbarch_stap_is_single_operand (gdbarch, s390_stap_is_single_operand);
7135 set_gdbarch_gcc_target_options (gdbarch, s390_gcc_target_options);
7136 set_gdbarch_gnu_triplet_regexp (gdbarch, s390_gnu_triplet_regexp);
7137
7138 /* Initialize the OSABI. */
7139 gdbarch_init_osabi (info, gdbarch);
7140
c81e8879
PR
7141 /* Always create a default tdesc. Otherwise commands like 'set osabi'
7142 cause GDB to crash with an internal error when the user tries to set
7143 an unsupported OSABI. */
7144 if (!tdesc_has_registers (tdesc))
7145 {
7146 if (info.bfd_arch_info->mach == bfd_mach_s390_31)
7147 tdesc = tdesc_s390_linux32;
7148 else
7149 tdesc = tdesc_s390x_linux64;
7150 }
7151 tdep->tdesc = tdesc;
7152
d6e58945 7153 /* Check any target description for validity. */
c1e1314d 7154 if (!s390_tdesc_valid (tdep, tdesc_data.get ()))
d6e58945 7155 {
d6e58945
PR
7156 xfree (tdep);
7157 gdbarch_free (gdbarch);
7158 return NULL;
7159 }
7160
7161 /* Determine vector ABI. */
7162#ifdef HAVE_ELF
7163 if (tdep->have_vx
7164 && info.abfd != NULL
7165 && info.abfd->format == bfd_object
7166 && bfd_get_flavour (info.abfd) == bfd_target_elf_flavour
7167 && bfd_elf_get_obj_attr_int (info.abfd, OBJ_ATTR_GNU,
7168 Tag_GNU_S390_ABI_Vector) == 2)
7169 tdep->vector_abi = S390_VECTOR_ABI_128;
7170#endif
7171
7172 /* Find a candidate among extant architectures. */
7173 for (arches = gdbarch_list_lookup_by_info (arches, &info);
7174 arches != NULL;
7175 arches = gdbarch_list_lookup_by_info (arches->next, &info))
7176 {
7177 struct gdbarch_tdep *tmp = gdbarch_tdep (arches->gdbarch);
7178 if (!tmp)
7179 continue;
7180 /* A program can 'choose' not to use the vector registers when they
7181 are present. Leading to the same tdesc but different tdep and
7182 thereby a different gdbarch. */
7183 if (tmp->vector_abi != tdep->vector_abi)
7184 continue;
7185
d6e58945
PR
7186 xfree (tdep);
7187 gdbarch_free (gdbarch);
7188 return arches->gdbarch;
7189 }
7190
c1e1314d 7191 tdesc_use_registers (gdbarch, tdep->tdesc, std::move (tdesc_data));
d6e58945
PR
7192 set_gdbarch_register_name (gdbarch, s390_register_name);
7193
7194 /* Assign pseudo register numbers. */
7195 first_pseudo_reg = gdbarch_num_regs (gdbarch);
7196 last_pseudo_reg = first_pseudo_reg;
7197 if (tdep->have_upper)
7198 {
7199 tdep->gpr_full_regnum = last_pseudo_reg;
7200 last_pseudo_reg += 16;
7201 }
7202 if (tdep->have_vx)
7203 {
7204 tdep->v0_full_regnum = last_pseudo_reg;
7205 last_pseudo_reg += 16;
7206 }
7207 tdep->pc_regnum = last_pseudo_reg++;
7208 tdep->cc_regnum = last_pseudo_reg++;
7209 set_gdbarch_pc_regnum (gdbarch, tdep->pc_regnum);
7210 set_gdbarch_num_pseudo_regs (gdbarch, last_pseudo_reg - first_pseudo_reg);
7211
7212 /* Frame handling. */
7213 frame_base_append_sniffer (gdbarch, dwarf2_frame_base_sniffer);
7214 frame_unwind_append_unwinder (gdbarch, &s390_stub_frame_unwind);
7215 frame_unwind_append_unwinder (gdbarch, &s390_frame_unwind);
7216 frame_base_set_default (gdbarch, &s390_frame_base);
7217
7218 return gdbarch;
7219}
7220
6c265988 7221void _initialize_s390_tdep ();
d6e58945 7222void
6c265988 7223_initialize_s390_tdep ()
d6e58945
PR
7224{
7225 /* Hook us into the gdbarch mechanism. */
7226 register_gdbarch_init (bfd_arch_s390, s390_gdbarch_init);
c81e8879
PR
7227
7228 initialize_tdesc_s390_linux32 ();
7229 initialize_tdesc_s390x_linux64 ();
d6e58945 7230}