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