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