1 /* GNU/Linux S/390 specific low level interface, for the remote server
3 Copyright (C) 2001-2020 Free Software Foundation, Inc.
5 This file is part of GDB.
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.
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.
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/>. */
20 /* This file is used for both 31-bit and 64-bit S/390 systems. */
23 #include "linux-low.h"
24 #include "elf/common.h"
26 #include "tracepoint.h"
28 #include <asm/ptrace.h>
29 #include "nat/gdb_ptrace.h"
34 #include "linux-s390-tdesc.h"
36 #ifndef HWCAP_S390_HIGH_GPRS
37 #define HWCAP_S390_HIGH_GPRS 512
41 #define HWCAP_S390_TE 1024
45 #define HWCAP_S390_VX 2048
49 #define HWCAP_S390_GS 16384
52 #define s390_num_regs 52
54 /* Linux target op definitions for the S/390 architecture. */
56 class s390_target
: public linux_process_target
60 const regs_info
*get_regs_info () override
;
62 const gdb_byte
*sw_breakpoint_from_kind (int kind
, int *size
) override
;
64 bool supports_z_point_type (char z_type
) override
;
66 void low_collect_ptrace_register (regcache
*regcache
, int regno
,
69 void low_supply_ptrace_register (regcache
*regcache
, int regno
,
70 const char *buf
) override
;
74 void low_arch_setup () override
;
76 bool low_cannot_fetch_register (int regno
) override
;
78 bool low_cannot_store_register (int regno
) override
;
80 bool low_supports_breakpoints () override
;
82 CORE_ADDR
low_get_pc (regcache
*regcache
) override
;
84 void low_set_pc (regcache
*regcache
, CORE_ADDR newpc
) override
;
86 int low_decr_pc_after_break () override
;
88 bool low_breakpoint_at (CORE_ADDR pc
) override
;
91 /* The singleton target ops object. */
93 static s390_target the_s390_target
;
95 static int s390_regmap
[] = {
96 PT_PSWMASK
, PT_PSWADDR
,
98 PT_GPR0
, PT_GPR1
, PT_GPR2
, PT_GPR3
,
99 PT_GPR4
, PT_GPR5
, PT_GPR6
, PT_GPR7
,
100 PT_GPR8
, PT_GPR9
, PT_GPR10
, PT_GPR11
,
101 PT_GPR12
, PT_GPR13
, PT_GPR14
, PT_GPR15
,
103 PT_ACR0
, PT_ACR1
, PT_ACR2
, PT_ACR3
,
104 PT_ACR4
, PT_ACR5
, PT_ACR6
, PT_ACR7
,
105 PT_ACR8
, PT_ACR9
, PT_ACR10
, PT_ACR11
,
106 PT_ACR12
, PT_ACR13
, PT_ACR14
, PT_ACR15
,
111 PT_FPR0_HI
, PT_FPR1_HI
, PT_FPR2_HI
, PT_FPR3_HI
,
112 PT_FPR4_HI
, PT_FPR5_HI
, PT_FPR6_HI
, PT_FPR7_HI
,
113 PT_FPR8_HI
, PT_FPR9_HI
, PT_FPR10_HI
, PT_FPR11_HI
,
114 PT_FPR12_HI
, PT_FPR13_HI
, PT_FPR14_HI
, PT_FPR15_HI
,
116 PT_FPR0
, PT_FPR1
, PT_FPR2
, PT_FPR3
,
117 PT_FPR4
, PT_FPR5
, PT_FPR6
, PT_FPR7
,
118 PT_FPR8
, PT_FPR9
, PT_FPR10
, PT_FPR11
,
119 PT_FPR12
, PT_FPR13
, PT_FPR14
, PT_FPR15
,
125 #define s390_num_regs_3264 68
128 static int s390_regmap_3264
[] = {
129 PT_PSWMASK
, PT_PSWADDR
,
131 PT_GPR0
, PT_GPR0
, PT_GPR1
, PT_GPR1
,
132 PT_GPR2
, PT_GPR2
, PT_GPR3
, PT_GPR3
,
133 PT_GPR4
, PT_GPR4
, PT_GPR5
, PT_GPR5
,
134 PT_GPR6
, PT_GPR6
, PT_GPR7
, PT_GPR7
,
135 PT_GPR8
, PT_GPR8
, PT_GPR9
, PT_GPR9
,
136 PT_GPR10
, PT_GPR10
, PT_GPR11
, PT_GPR11
,
137 PT_GPR12
, PT_GPR12
, PT_GPR13
, PT_GPR13
,
138 PT_GPR14
, PT_GPR14
, PT_GPR15
, PT_GPR15
,
140 PT_ACR0
, PT_ACR1
, PT_ACR2
, PT_ACR3
,
141 PT_ACR4
, PT_ACR5
, PT_ACR6
, PT_ACR7
,
142 PT_ACR8
, PT_ACR9
, PT_ACR10
, PT_ACR11
,
143 PT_ACR12
, PT_ACR13
, PT_ACR14
, PT_ACR15
,
147 PT_FPR0
, PT_FPR1
, PT_FPR2
, PT_FPR3
,
148 PT_FPR4
, PT_FPR5
, PT_FPR6
, PT_FPR7
,
149 PT_FPR8
, PT_FPR9
, PT_FPR10
, PT_FPR11
,
150 PT_FPR12
, PT_FPR13
, PT_FPR14
, PT_FPR15
,
155 static int s390_regmap_3264
[] = {
156 PT_PSWMASK
, PT_PSWADDR
,
158 -1, PT_GPR0
, -1, PT_GPR1
,
159 -1, PT_GPR2
, -1, PT_GPR3
,
160 -1, PT_GPR4
, -1, PT_GPR5
,
161 -1, PT_GPR6
, -1, PT_GPR7
,
162 -1, PT_GPR8
, -1, PT_GPR9
,
163 -1, PT_GPR10
, -1, PT_GPR11
,
164 -1, PT_GPR12
, -1, PT_GPR13
,
165 -1, PT_GPR14
, -1, PT_GPR15
,
167 PT_ACR0
, PT_ACR1
, PT_ACR2
, PT_ACR3
,
168 PT_ACR4
, PT_ACR5
, PT_ACR6
, PT_ACR7
,
169 PT_ACR8
, PT_ACR9
, PT_ACR10
, PT_ACR11
,
170 PT_ACR12
, PT_ACR13
, PT_ACR14
, PT_ACR15
,
174 PT_FPR0_HI
, PT_FPR1_HI
, PT_FPR2_HI
, PT_FPR3_HI
,
175 PT_FPR4_HI
, PT_FPR5_HI
, PT_FPR6_HI
, PT_FPR7_HI
,
176 PT_FPR8_HI
, PT_FPR9_HI
, PT_FPR10_HI
, PT_FPR11_HI
,
177 PT_FPR12_HI
, PT_FPR13_HI
, PT_FPR14_HI
, PT_FPR15_HI
,
185 s390_target::low_cannot_fetch_register (int regno
)
191 s390_target::low_cannot_store_register (int regno
)
197 s390_target::low_collect_ptrace_register (regcache
*regcache
, int regno
,
200 int size
= register_size (regcache
->tdesc
, regno
);
201 const struct regs_info
*regs_info
= get_regs_info ();
202 struct usrregs_info
*usr
= regs_info
->usrregs
;
203 int regaddr
= usr
->regmap
[regno
];
205 if (size
< sizeof (long))
207 memset (buf
, 0, sizeof (long));
209 if ((regno
^ 1) < usr
->num_regs
210 && usr
->regmap
[regno
^ 1] == regaddr
)
212 collect_register (regcache
, regno
& ~1, buf
);
213 collect_register (regcache
, (regno
& ~1) + 1,
214 buf
+ sizeof (long) - size
);
216 else if (regaddr
== PT_PSWMASK
)
218 /* Convert 4-byte PSW mask to 8 bytes by clearing bit 12 and copying
219 the basic addressing mode bit from the PSW address. */
220 gdb_byte
*addr
= (gdb_byte
*) alloca (register_size (regcache
->tdesc
, regno
^ 1));
221 collect_register (regcache
, regno
, buf
);
222 collect_register (regcache
, regno
^ 1, addr
);
224 buf
[size
] |= (addr
[0] & 0x80);
226 else if (regaddr
== PT_PSWADDR
)
228 /* Convert 4-byte PSW address to 8 bytes by clearing the addressing
229 mode bit (which gets copied to the PSW mask instead). */
230 collect_register (regcache
, regno
, buf
+ sizeof (long) - size
);
231 buf
[sizeof (long) - size
] &= ~0x80;
233 else if ((regaddr
>= PT_GPR0
&& regaddr
<= PT_GPR15
)
234 || regaddr
== PT_ORIGGPR2
)
235 collect_register (regcache
, regno
, buf
+ sizeof (long) - size
);
237 collect_register (regcache
, regno
, buf
);
239 else if (regaddr
!= -1)
240 collect_register (regcache
, regno
, buf
);
244 s390_target::low_supply_ptrace_register (regcache
*regcache
, int regno
,
247 int size
= register_size (regcache
->tdesc
, regno
);
248 const struct regs_info
*regs_info
= get_regs_info ();
249 struct usrregs_info
*usr
= regs_info
->usrregs
;
250 int regaddr
= usr
->regmap
[regno
];
252 if (size
< sizeof (long))
254 if ((regno
^ 1) < usr
->num_regs
255 && usr
->regmap
[regno
^ 1] == regaddr
)
257 supply_register (regcache
, regno
& ~1, buf
);
258 supply_register (regcache
, (regno
& ~1) + 1,
259 buf
+ sizeof (long) - size
);
261 else if (regaddr
== PT_PSWMASK
)
263 /* Convert 8-byte PSW mask to 4 bytes by setting bit 12 and copying
264 the basic addressing mode into the PSW address. */
265 gdb_byte
*mask
= (gdb_byte
*) alloca (size
);
266 gdb_byte
*addr
= (gdb_byte
*) alloca (register_size (regcache
->tdesc
, regno
^ 1));
267 memcpy (mask
, buf
, size
);
269 supply_register (regcache
, regno
, mask
);
271 collect_register (regcache
, regno
^ 1, addr
);
273 addr
[0] |= (buf
[size
] & 0x80);
274 supply_register (regcache
, regno
^ 1, addr
);
276 else if (regaddr
== PT_PSWADDR
)
278 /* Convert 8-byte PSW address to 4 bytes by truncating, but
279 keeping the addressing mode bit (which was set from the mask). */
280 gdb_byte
*addr
= (gdb_byte
*) alloca (size
);
282 collect_register (regcache
, regno
, addr
);
283 amode
= addr
[0] & 0x80;
284 memcpy (addr
, buf
+ sizeof (long) - size
, size
);
287 supply_register (regcache
, regno
, addr
);
289 else if ((regaddr
>= PT_GPR0
&& regaddr
<= PT_GPR15
)
290 || regaddr
== PT_ORIGGPR2
)
291 supply_register (regcache
, regno
, buf
+ sizeof (long) - size
);
293 supply_register (regcache
, regno
, buf
);
295 else if (regaddr
!= -1)
296 supply_register (regcache
, regno
, buf
);
299 /* Provide only a fill function for the general register set. ps_lgetregs
300 will use this for NPTL support. */
303 s390_fill_gregset (struct regcache
*regcache
, void *buf
)
306 const struct regs_info
*regs_info
= the_linux_target
->get_regs_info ();
307 struct usrregs_info
*usr
= regs_info
->usrregs
;
309 for (i
= 0; i
< usr
->num_regs
; i
++)
311 if (usr
->regmap
[i
] < PT_PSWMASK
312 || usr
->regmap
[i
] > PT_ACR15
)
315 ((s390_target
*) the_linux_target
)->low_collect_ptrace_register
316 (regcache
, i
, (char *) buf
+ usr
->regmap
[i
]);
320 /* Fill and store functions for extended register sets. */
324 s390_fill_gprs_high (struct regcache
*regcache
, void *buf
)
326 int r0h
= find_regno (regcache
->tdesc
, "r0h");
329 for (i
= 0; i
< 16; i
++)
330 collect_register (regcache
, r0h
+ 2 * i
, (char *) buf
+ 4 * i
);
334 s390_store_gprs_high (struct regcache
*regcache
, const void *buf
)
336 int r0h
= find_regno (regcache
->tdesc
, "r0h");
339 for (i
= 0; i
< 16; i
++)
340 supply_register (regcache
, r0h
+ 2 * i
, (const char *) buf
+ 4 * i
);
345 s390_store_last_break (struct regcache
*regcache
, const void *buf
)
349 p
= (const char *) buf
+ 8 - register_size (regcache
->tdesc
, 0);
350 supply_register_by_name (regcache
, "last_break", p
);
354 s390_fill_system_call (struct regcache
*regcache
, void *buf
)
356 collect_register_by_name (regcache
, "system_call", buf
);
360 s390_store_system_call (struct regcache
*regcache
, const void *buf
)
362 supply_register_by_name (regcache
, "system_call", buf
);
366 s390_store_tdb (struct regcache
*regcache
, const void *buf
)
368 int tdb0
= find_regno (regcache
->tdesc
, "tdb0");
369 int tr0
= find_regno (regcache
->tdesc
, "tr0");
372 for (i
= 0; i
< 4; i
++)
373 supply_register (regcache
, tdb0
+ i
, (const char *) buf
+ 8 * i
);
375 for (i
= 0; i
< 16; i
++)
376 supply_register (regcache
, tr0
+ i
, (const char *) buf
+ 8 * (16 + i
));
380 s390_fill_vxrs_low (struct regcache
*regcache
, void *buf
)
382 int v0
= find_regno (regcache
->tdesc
, "v0l");
385 for (i
= 0; i
< 16; i
++)
386 collect_register (regcache
, v0
+ i
, (char *) buf
+ 8 * i
);
390 s390_store_vxrs_low (struct regcache
*regcache
, const void *buf
)
392 int v0
= find_regno (regcache
->tdesc
, "v0l");
395 for (i
= 0; i
< 16; i
++)
396 supply_register (regcache
, v0
+ i
, (const char *) buf
+ 8 * i
);
400 s390_fill_vxrs_high (struct regcache
*regcache
, void *buf
)
402 int v16
= find_regno (regcache
->tdesc
, "v16");
405 for (i
= 0; i
< 16; i
++)
406 collect_register (regcache
, v16
+ i
, (char *) buf
+ 16 * i
);
410 s390_store_vxrs_high (struct regcache
*regcache
, const void *buf
)
412 int v16
= find_regno (regcache
->tdesc
, "v16");
415 for (i
= 0; i
< 16; i
++)
416 supply_register (regcache
, v16
+ i
, (const char *) buf
+ 16 * i
);
420 s390_store_gs (struct regcache
*regcache
, const void *buf
)
422 int gsd
= find_regno (regcache
->tdesc
, "gsd");
425 for (i
= 0; i
< 3; i
++)
426 supply_register (regcache
, gsd
+ i
, (const char *) buf
+ 8 * (i
+ 1));
430 s390_store_gsbc (struct regcache
*regcache
, const void *buf
)
432 int bc_gsd
= find_regno (regcache
->tdesc
, "bc_gsd");
435 for (i
= 0; i
< 3; i
++)
436 supply_register (regcache
, bc_gsd
+ i
, (const char *) buf
+ 8 * (i
+ 1));
439 static struct regset_info s390_regsets
[] = {
440 { 0, 0, 0, 0, GENERAL_REGS
, s390_fill_gregset
, NULL
},
442 { PTRACE_GETREGSET
, PTRACE_SETREGSET
, NT_S390_HIGH_GPRS
, 0,
443 EXTENDED_REGS
, s390_fill_gprs_high
, s390_store_gprs_high
},
445 /* Last break address is read-only; no fill function. */
446 { PTRACE_GETREGSET
, -1, NT_S390_LAST_BREAK
, 0, EXTENDED_REGS
,
447 NULL
, s390_store_last_break
},
448 { PTRACE_GETREGSET
, PTRACE_SETREGSET
, NT_S390_SYSTEM_CALL
, 0,
449 EXTENDED_REGS
, s390_fill_system_call
, s390_store_system_call
},
450 /* TDB is read-only. */
451 { PTRACE_GETREGSET
, -1, NT_S390_TDB
, 0, EXTENDED_REGS
,
452 NULL
, s390_store_tdb
},
453 { PTRACE_GETREGSET
, PTRACE_SETREGSET
, NT_S390_VXRS_LOW
, 0,
454 EXTENDED_REGS
, s390_fill_vxrs_low
, s390_store_vxrs_low
},
455 { PTRACE_GETREGSET
, PTRACE_SETREGSET
, NT_S390_VXRS_HIGH
, 0,
456 EXTENDED_REGS
, s390_fill_vxrs_high
, s390_store_vxrs_high
},
457 /* Guarded storage registers are read-only. */
458 { PTRACE_GETREGSET
, -1, NT_S390_GS_CB
, 0, EXTENDED_REGS
,
459 NULL
, s390_store_gs
},
460 { PTRACE_GETREGSET
, -1, NT_S390_GS_BC
, 0, EXTENDED_REGS
,
461 NULL
, s390_store_gsbc
},
466 static const gdb_byte s390_breakpoint
[] = { 0, 1 };
467 #define s390_breakpoint_len 2
469 /* Implementation of target ops method "sw_breakpoint_from_kind". */
472 s390_target::sw_breakpoint_from_kind (int kind
, int *size
)
474 *size
= s390_breakpoint_len
;
475 return s390_breakpoint
;
479 s390_target::low_supports_breakpoints ()
485 s390_target::low_get_pc (regcache
*regcache
)
487 if (register_size (regcache
->tdesc
, 0) == 4)
490 collect_register_by_name (regcache
, "pswa", &pswa
);
491 return pswa
& 0x7fffffff;
496 collect_register_by_name (regcache
, "pswa", &pc
);
502 s390_target::low_set_pc (regcache
*regcache
, CORE_ADDR newpc
)
504 if (register_size (regcache
->tdesc
, 0) == 4)
507 collect_register_by_name (regcache
, "pswa", &pswa
);
508 pswa
= (pswa
& 0x80000000) | (newpc
& 0x7fffffff);
509 supply_register_by_name (regcache
, "pswa", &pswa
);
513 unsigned long pc
= newpc
;
514 supply_register_by_name (regcache
, "pswa", &pc
);
519 s390_target::low_decr_pc_after_break ()
521 return s390_breakpoint_len
;
524 /* Determine the word size for the given PID, in bytes. */
528 s390_get_wordsize (int pid
)
531 PTRACE_XFER_TYPE pswm
= ptrace (PTRACE_PEEKUSER
, pid
,
532 (PTRACE_TYPE_ARG3
) 0,
533 (PTRACE_TYPE_ARG4
) 0);
536 warning (_("Couldn't determine word size, assuming 64-bit."));
539 /* Derive word size from extended addressing mode (PSW bit 31). */
540 return pswm
& (1L << 32) ? 8 : 4;
543 #define s390_get_wordsize(pid) 4
547 s390_check_regset (int pid
, int regset
, int regsize
)
549 void *buf
= alloca (regsize
);
553 iov
.iov_len
= regsize
;
555 if (ptrace (PTRACE_GETREGSET
, pid
, (long) regset
, (long) &iov
) >= 0
561 /* For a 31-bit inferior, whether the kernel supports using the full
563 static int have_hwcap_s390_high_gprs
= 0;
564 static int have_hwcap_s390_vx
= 0;
567 s390_target::low_arch_setup ()
569 const struct target_desc
*tdesc
;
570 struct regset_info
*regset
;
572 /* Determine word size and HWCAP. */
573 int pid
= pid_of (current_thread
);
574 int wordsize
= s390_get_wordsize (pid
);
575 unsigned long hwcap
= linux_get_hwcap (wordsize
);
577 /* Check whether the kernel supports extra register sets. */
578 int have_regset_last_break
579 = s390_check_regset (pid
, NT_S390_LAST_BREAK
, 8);
580 int have_regset_system_call
581 = s390_check_regset (pid
, NT_S390_SYSTEM_CALL
, 4);
583 = (s390_check_regset (pid
, NT_S390_TDB
, 256)
584 && (hwcap
& HWCAP_S390_TE
) != 0);
586 = (s390_check_regset (pid
, NT_S390_VXRS_LOW
, 128)
587 && s390_check_regset (pid
, NT_S390_VXRS_HIGH
, 256)
588 && (hwcap
& HWCAP_S390_VX
) != 0);
590 = (s390_check_regset (pid
, NT_S390_GS_CB
, 32)
591 && s390_check_regset (pid
, NT_S390_GS_BC
, 32)
592 && (hwcap
& HWCAP_S390_GS
) != 0);
599 tdesc
= tdesc_s390x_gs_linux64
;
600 else if (have_regset_vxrs
)
601 tdesc
= (have_regset_tdb
? tdesc_s390x_tevx_linux64
:
602 tdesc_s390x_vx_linux64
);
603 else if (have_regset_tdb
)
604 tdesc
= tdesc_s390x_te_linux64
;
605 else if (have_regset_system_call
)
606 tdesc
= tdesc_s390x_linux64v2
;
607 else if (have_regset_last_break
)
608 tdesc
= tdesc_s390x_linux64v1
;
610 tdesc
= tdesc_s390x_linux64
;
613 /* For a 31-bit inferior, check whether the kernel supports
614 using the full 64-bit GPRs. */
617 if (hwcap
& HWCAP_S390_HIGH_GPRS
)
619 have_hwcap_s390_high_gprs
= 1;
621 tdesc
= tdesc_s390_gs_linux64
;
622 else if (have_regset_vxrs
)
623 tdesc
= (have_regset_tdb
? tdesc_s390_tevx_linux64
:
624 tdesc_s390_vx_linux64
);
625 else if (have_regset_tdb
)
626 tdesc
= tdesc_s390_te_linux64
;
627 else if (have_regset_system_call
)
628 tdesc
= tdesc_s390_linux64v2
;
629 else if (have_regset_last_break
)
630 tdesc
= tdesc_s390_linux64v1
;
632 tdesc
= tdesc_s390_linux64
;
636 /* Assume 31-bit inferior process. */
637 if (have_regset_system_call
)
638 tdesc
= tdesc_s390_linux32v2
;
639 else if (have_regset_last_break
)
640 tdesc
= tdesc_s390_linux32v1
;
642 tdesc
= tdesc_s390_linux32
;
645 have_hwcap_s390_vx
= have_regset_vxrs
;
648 /* Update target_regsets according to available register sets. */
649 for (regset
= s390_regsets
; regset
->size
>= 0; regset
++)
650 if (regset
->get_request
== PTRACE_GETREGSET
)
651 switch (regset
->nt_type
)
654 case NT_S390_HIGH_GPRS
:
655 regset
->size
= have_hwcap_s390_high_gprs
? 64 : 0;
658 case NT_S390_LAST_BREAK
:
659 regset
->size
= have_regset_last_break
? 8 : 0;
661 case NT_S390_SYSTEM_CALL
:
662 regset
->size
= have_regset_system_call
? 4 : 0;
665 regset
->size
= have_regset_tdb
? 256 : 0;
667 case NT_S390_VXRS_LOW
:
668 regset
->size
= have_regset_vxrs
? 128 : 0;
670 case NT_S390_VXRS_HIGH
:
671 regset
->size
= have_regset_vxrs
? 256 : 0;
675 regset
->size
= have_regset_gs
? 32 : 0;
680 current_process ()->tdesc
= tdesc
;
685 s390_target::low_breakpoint_at (CORE_ADDR pc
)
687 unsigned char c
[s390_breakpoint_len
];
688 read_inferior_memory (pc
, c
, s390_breakpoint_len
);
689 return memcmp (c
, s390_breakpoint
, s390_breakpoint_len
) == 0;
692 /* Breakpoint/Watchpoint support. */
694 /* The "supports_z_point_type" target ops method. */
697 s390_target::supports_z_point_type (char z_type
)
708 /* Support for hardware single step. */
711 s390_supports_hardware_single_step (void)
716 static struct usrregs_info s390_usrregs_info
=
722 static struct regsets_info s390_regsets_info
=
724 s390_regsets
, /* regsets */
726 NULL
, /* disabled_regsets */
729 static struct regs_info myregs_info
=
731 NULL
, /* regset_bitmap */
736 static struct usrregs_info s390_usrregs_info_3264
=
742 static struct regsets_info s390_regsets_info_3264
=
744 s390_regsets
, /* regsets */
746 NULL
, /* disabled_regsets */
749 static struct regs_info regs_info_3264
=
751 NULL
, /* regset_bitmap */
752 &s390_usrregs_info_3264
,
753 &s390_regsets_info_3264
757 s390_target::get_regs_info ()
759 if (have_hwcap_s390_high_gprs
)
762 const struct target_desc
*tdesc
= current_process ()->tdesc
;
764 if (register_size (tdesc
, 0) == 4)
765 return ®s_info_3264
;
767 return ®s_info_3264
;
773 /* The "supports_tracepoints" linux_target_ops method. */
776 s390_supports_tracepoints (void)
781 /* Implementation of linux_target_ops method "get_thread_area". */
784 s390_get_thread_area (int lwpid
, CORE_ADDR
*addrp
)
786 CORE_ADDR res
= ptrace (PTRACE_PEEKUSER
, lwpid
, (long) PT_ACR0
, (long) 0);
788 struct regcache
*regcache
= get_thread_regcache (current_thread
, 0);
790 if (register_size (regcache
->tdesc
, 0) == 4)
791 res
&= 0xffffffffull
;
798 /* Fast tracepoint support.
800 The register save area on stack is identical for all targets:
802 0x000+i*0x10: VR0-VR31
809 If we're on 31-bit linux, we just don't store the high parts of the GPRs.
810 Likewise, if there's no VX support, we just store the FRs into the slots
811 of low VR halves. The agent code is responsible for rearranging that
814 /* Code sequence saving GPRs for 31-bit target with no high GPRs. There's
815 one trick used at the very beginning: since there's no way to allocate
816 stack space without destroying CC (lay instruction can do it, but it's
817 only supported on later CPUs), we take 4 different execution paths for
818 every possible value of CC, allocate stack space, save %r0, stuff the
819 CC value in %r0 (shifted to match its position in PSWM high word),
820 then branch to common path. */
822 static const unsigned char s390_ft_entry_gpr_esa
[] = {
823 0xa7, 0x14, 0x00, 0x1e, /* jo .Lcc3 */
824 0xa7, 0x24, 0x00, 0x14, /* jh .Lcc2 */
825 0xa7, 0x44, 0x00, 0x0a, /* jl .Lcc1 */
827 0xa7, 0xfa, 0xfd, 0x00, /* ahi %r15, -0x300 */
828 0x50, 0x00, 0xf2, 0x04, /* st %r0, 0x204(%r15) */
829 0xa7, 0x08, 0x00, 0x00, /* lhi %r0, 0 */
830 0xa7, 0xf4, 0x00, 0x18, /* j .Lccdone */
832 0xa7, 0xfa, 0xfd, 0x00, /* ahi %r15, -0x300 */
833 0x50, 0x00, 0xf2, 0x04, /* st %r0, 0x204(%r15) */
834 0xa7, 0x08, 0x10, 0x00, /* lhi %r0, 0x1000 */
835 0xa7, 0xf4, 0x00, 0x10, /* j .Lccdone */
837 0xa7, 0xfa, 0xfd, 0x00, /* ahi %r15, -0x300 */
838 0x50, 0x00, 0xf2, 0x04, /* st %r0, 0x204(%r15) */
839 0xa7, 0x08, 0x20, 0x00, /* lhi %r0, 0x2000 */
840 0xa7, 0xf4, 0x00, 0x08, /* j .Lccdone */
842 0xa7, 0xfa, 0xfd, 0x00, /* ahi %r15, -0x300 */
843 0x50, 0x00, 0xf2, 0x04, /* st %r0, 0x204(%r15) */
844 0xa7, 0x08, 0x30, 0x00, /* lhi %r0, 0x3000 */
846 0x50, 0x10, 0xf2, 0x0c, /* st %r1, 0x20c(%r15) */
847 0x50, 0x20, 0xf2, 0x14, /* st %r2, 0x214(%r15) */
848 0x50, 0x30, 0xf2, 0x1c, /* st %r3, 0x21c(%r15) */
849 0x50, 0x40, 0xf2, 0x24, /* st %r4, 0x224(%r15) */
850 0x50, 0x50, 0xf2, 0x2c, /* st %r5, 0x22c(%r15) */
851 0x50, 0x60, 0xf2, 0x34, /* st %r6, 0x234(%r15) */
852 0x50, 0x70, 0xf2, 0x3c, /* st %r7, 0x23c(%r15) */
853 0x50, 0x80, 0xf2, 0x44, /* st %r8, 0x244(%r15) */
854 0x50, 0x90, 0xf2, 0x4c, /* st %r9, 0x24c(%r15) */
855 0x50, 0xa0, 0xf2, 0x54, /* st %r10, 0x254(%r15) */
856 0x50, 0xb0, 0xf2, 0x5c, /* st %r11, 0x25c(%r15) */
857 0x50, 0xc0, 0xf2, 0x64, /* st %r12, 0x264(%r15) */
858 0x50, 0xd0, 0xf2, 0x6c, /* st %r13, 0x26c(%r15) */
859 0x50, 0xe0, 0xf2, 0x74, /* st %r14, 0x274(%r15) */
860 /* Compute original value of %r15 and store it. We use ahi instead
861 of la to preserve the whole value, and not just the low 31 bits.
862 This is not particularly important here, but essential in the
863 zarch case where someone might be using the high word of %r15
864 as an extra register. */
865 0x18, 0x1f, /* lr %r1, %r15 */
866 0xa7, 0x1a, 0x03, 0x00, /* ahi %r1, 0x300 */
867 0x50, 0x10, 0xf2, 0x7c, /* st %r1, 0x27c(%r15) */
870 /* Code sequence saving GPRs for 31-bit target with high GPRs and for 64-bit
871 target. Same as above, except this time we can use load/store multiple,
872 since the 64-bit regs are tightly packed. */
874 static const unsigned char s390_ft_entry_gpr_zarch
[] = {
875 0xa7, 0x14, 0x00, 0x21, /* jo .Lcc3 */
876 0xa7, 0x24, 0x00, 0x16, /* jh .Lcc2 */
877 0xa7, 0x44, 0x00, 0x0b, /* jl .Lcc1 */
879 0xa7, 0xfb, 0xfd, 0x00, /* aghi %r15, -0x300 */
880 0xeb, 0x0e, 0xf2, 0x00, 0x00, 0x24, /* stmg %r0, %r14, 0x200(%r15) */
881 0xa7, 0x08, 0x00, 0x00, /* lhi %r0, 0 */
882 0xa7, 0xf4, 0x00, 0x1b, /* j .Lccdone */
884 0xa7, 0xfb, 0xfd, 0x00, /* aghi %r15, -0x300 */
885 0xeb, 0x0e, 0xf2, 0x00, 0x00, 0x24, /* stmg %r0, %r14, 0x200(%r15) */
886 0xa7, 0x08, 0x10, 0x00, /* lhi %r0, 0x1000 */
887 0xa7, 0xf4, 0x00, 0x12, /* j .Lccdone */
889 0xa7, 0xfb, 0xfd, 0x00, /* aghi %r15, -0x300 */
890 0xeb, 0x0e, 0xf2, 0x00, 0x00, 0x24, /* stmg %r0, %r14, 0x200(%r15) */
891 0xa7, 0x08, 0x20, 0x00, /* lhi %r0, 0x2000 */
892 0xa7, 0xf4, 0x00, 0x09, /* j .Lccdone */
894 0xa7, 0xfb, 0xfd, 0x00, /* aghi %r15, -0x300 */
895 0xeb, 0x0e, 0xf2, 0x00, 0x00, 0x24, /* stmg %r0, %r14, 0x200(%r15) */
896 0xa7, 0x08, 0x30, 0x00, /* lhi %r0, 0x3000 */
898 0xb9, 0x04, 0x00, 0x1f, /* lgr %r1, %r15 */
899 0xa7, 0x1b, 0x03, 0x00, /* aghi %r1, 0x300 */
900 0xe3, 0x10, 0xf2, 0x78, 0x00, 0x24, /* stg %r1, 0x278(%r15) */
903 /* Code sequence saving ARs, PSWM and FPC. PSWM has to be assembled from
904 current PSWM (read by epsw) and CC from entry (in %r0). */
906 static const unsigned char s390_ft_entry_misc
[] = {
907 0x9b, 0x0f, 0xf2, 0x80, /* stam %a0, %a15, 0x20(%%r15) */
908 0xb9, 0x8d, 0x00, 0x23, /* epsw %r2, %r3 */
909 0xa7, 0x18, 0xcf, 0xff, /* lhi %r1, ~0x3000 */
910 0x14, 0x21, /* nr %r2, %r1 */
911 0x16, 0x20, /* or %r2, %r0 */
912 0x50, 0x20, 0xf2, 0xc0, /* st %r2, 0x2c0(%r15) */
913 0x50, 0x30, 0xf2, 0xc4, /* st %r3, 0x2c4(%r15) */
914 0xb2, 0x9c, 0xf2, 0xd0, /* stfpc 0x2d0(%r15) */
917 /* Code sequence saving FRs, used if VX not supported. */
919 static const unsigned char s390_ft_entry_fr
[] = {
920 0x60, 0x00, 0xf0, 0x00, /* std %f0, 0x000(%r15) */
921 0x60, 0x10, 0xf0, 0x10, /* std %f1, 0x010(%r15) */
922 0x60, 0x20, 0xf0, 0x20, /* std %f2, 0x020(%r15) */
923 0x60, 0x30, 0xf0, 0x30, /* std %f3, 0x030(%r15) */
924 0x60, 0x40, 0xf0, 0x40, /* std %f4, 0x040(%r15) */
925 0x60, 0x50, 0xf0, 0x50, /* std %f5, 0x050(%r15) */
926 0x60, 0x60, 0xf0, 0x60, /* std %f6, 0x060(%r15) */
927 0x60, 0x70, 0xf0, 0x70, /* std %f7, 0x070(%r15) */
928 0x60, 0x80, 0xf0, 0x80, /* std %f8, 0x080(%r15) */
929 0x60, 0x90, 0xf0, 0x90, /* std %f9, 0x090(%r15) */
930 0x60, 0xa0, 0xf0, 0xa0, /* std %f10, 0x0a0(%r15) */
931 0x60, 0xb0, 0xf0, 0xb0, /* std %f11, 0x0b0(%r15) */
932 0x60, 0xc0, 0xf0, 0xc0, /* std %f12, 0x0c0(%r15) */
933 0x60, 0xd0, 0xf0, 0xd0, /* std %f13, 0x0d0(%r15) */
934 0x60, 0xe0, 0xf0, 0xe0, /* std %f14, 0x0e0(%r15) */
935 0x60, 0xf0, 0xf0, 0xf0, /* std %f15, 0x0f0(%r15) */
938 /* Code sequence saving VRs, used if VX not supported. */
940 static const unsigned char s390_ft_entry_vr
[] = {
941 0xe7, 0x0f, 0xf0, 0x00, 0x00, 0x3e, /* vstm %v0, %v15, 0x000(%r15) */
942 0xe7, 0x0f, 0xf1, 0x00, 0x0c, 0x3e, /* vstm %v16, %v31, 0x100(%r15) */
945 /* Code sequence doing the collection call for 31-bit target. %r1 contains
946 the address of the literal pool. */
948 static const unsigned char s390_ft_main_31
[] = {
949 /* Load the literals into registers. */
950 0x58, 0x50, 0x10, 0x00, /* l %r5, 0x0(%r1) */
951 0x58, 0x20, 0x10, 0x04, /* l %r2, 0x4(%r1) */
952 0x58, 0x40, 0x10, 0x08, /* l %r4, 0x8(%r1) */
953 0x58, 0x60, 0x10, 0x0c, /* l %r6, 0xc(%r1) */
954 /* Save original PSWA (tracepoint address | 0x80000000). */
955 0x50, 0x50, 0xf2, 0xcc, /* st %r5, 0x2cc(%r15) */
956 /* Construct a collecting_t object at %r15+0x2e0. */
957 0x50, 0x20, 0xf2, 0xe0, /* st %r2, 0x2e0(%r15) */
958 0x9b, 0x00, 0xf2, 0xe4, /* stam %a0, %a0, 0x2e4(%r15) */
959 /* Move its address to %r0. */
960 0x41, 0x00, 0xf2, 0xe0, /* la %r0, 0x2e0(%r15) */
963 0xa7, 0x18, 0x00, 0x00, /* lhi %r1, 0 */
964 0xba, 0x10, 0x60, 0x00, /* cs %r1, %r0, 0(%r6) */
965 0xa7, 0x74, 0xff, 0xfc, /* jne .Lloop */
966 /* Address of the register save block to %r3. */
967 0x18, 0x3f, /* lr %r3, %r15 */
968 /* Make a stack frame, so that we can call the collector. */
969 0xa7, 0xfa, 0xff, 0xa0, /* ahi %r15, -0x60 */
971 0x0d, 0xe4, /* basr %r14, %r4 */
972 /* And get rid of the stack frame again. */
973 0x41, 0xf0, 0xf0, 0x60, /* la %r15, 0x60(%r15) */
974 /* Leave the lock. */
975 0x07, 0xf0, /* br %r0 */
976 0xa7, 0x18, 0x00, 0x00, /* lhi %r1, 0 */
977 0x50, 0x10, 0x60, 0x00, /* st %t1, 0(%r6) */
980 /* Code sequence doing the collection call for 64-bit target. %r1 contains
981 the address of the literal pool. */
983 static const unsigned char s390_ft_main_64
[] = {
984 /* Load the literals into registers. */
985 0xe3, 0x50, 0x10, 0x00, 0x00, 0x04, /* lg %r5, 0x00(%r1) */
986 0xe3, 0x20, 0x10, 0x08, 0x00, 0x04, /* lg %r2, 0x08(%r1) */
987 0xe3, 0x40, 0x10, 0x10, 0x00, 0x04, /* lg %r4, 0x10(%r1) */
988 0xe3, 0x60, 0x10, 0x18, 0x00, 0x04, /* lg %r6, 0x18(%r1) */
989 /* Save original PSWA (tracepoint address). */
990 0xe3, 0x50, 0xf2, 0xc8, 0x00, 0x24, /* stg %r5, 0x2c8(%r15) */
991 /* Construct a collecting_t object at %r15+0x2e0. */
992 0xe3, 0x20, 0xf2, 0xe0, 0x00, 0x24, /* stg %r2, 0x2e0(%r15) */
993 0x9b, 0x01, 0xf2, 0xe8, /* stam %a0, %a1, 0x2e8(%r15) */
994 /* Move its address to %r0. */
995 0x41, 0x00, 0xf2, 0xe0, /* la %r0, 0x2e0(%r15) */
998 0xa7, 0x19, 0x00, 0x00, /* lghi %r1, 0 */
999 0xeb, 0x10, 0x60, 0x00, 0x00, 0x30, /* csg %r1, %r0, 0(%r6) */
1000 0xa7, 0x74, 0xff, 0xfb, /* jne .Lloop */
1001 /* Address of the register save block to %r3. */
1002 0xb9, 0x04, 0x00, 0x3f, /* lgr %r3, %r15 */
1003 /* Make a stack frame, so that we can call the collector. */
1004 0xa7, 0xfb, 0xff, 0x60, /* aghi %r15, -0xa0 */
1006 0x0d, 0xe4, /* basr %r14, %r4 */
1007 /* And get rid of the stack frame again. */
1008 0x41, 0xf0, 0xf0, 0xa0, /* la %r15, 0xa0(%r15) */
1009 /* Leave the lock. */
1010 0x07, 0xf0, /* br %r0 */
1011 0xa7, 0x19, 0x00, 0x00, /* lghi %r1, 0 */
1012 0xe3, 0x10, 0x60, 0x00, 0x00, 0x24, /* stg %t1, 0(%r6) */
1015 /* Code sequence restoring FRs, for targets with no VX support. */
1017 static const unsigned char s390_ft_exit_fr
[] = {
1018 0x68, 0x00, 0xf0, 0x00, /* ld %f0, 0x000(%r15) */
1019 0x68, 0x10, 0xf0, 0x10, /* ld %f1, 0x010(%r15) */
1020 0x68, 0x20, 0xf0, 0x20, /* ld %f2, 0x020(%r15) */
1021 0x68, 0x30, 0xf0, 0x30, /* ld %f3, 0x030(%r15) */
1022 0x68, 0x40, 0xf0, 0x40, /* ld %f4, 0x040(%r15) */
1023 0x68, 0x50, 0xf0, 0x50, /* ld %f5, 0x050(%r15) */
1024 0x68, 0x60, 0xf0, 0x60, /* ld %f6, 0x060(%r15) */
1025 0x68, 0x70, 0xf0, 0x70, /* ld %f7, 0x070(%r15) */
1026 0x68, 0x80, 0xf0, 0x80, /* ld %f8, 0x080(%r15) */
1027 0x68, 0x90, 0xf0, 0x90, /* ld %f9, 0x090(%r15) */
1028 0x68, 0xa0, 0xf0, 0xa0, /* ld %f10, 0x0a0(%r15) */
1029 0x68, 0xb0, 0xf0, 0xb0, /* ld %f11, 0x0b0(%r15) */
1030 0x68, 0xc0, 0xf0, 0xc0, /* ld %f12, 0x0c0(%r15) */
1031 0x68, 0xd0, 0xf0, 0xd0, /* ld %f13, 0x0d0(%r15) */
1032 0x68, 0xe0, 0xf0, 0xe0, /* ld %f14, 0x0e0(%r15) */
1033 0x68, 0xf0, 0xf0, 0xf0, /* ld %f15, 0x0f0(%r15) */
1036 /* Code sequence restoring VRs. */
1038 static const unsigned char s390_ft_exit_vr
[] = {
1039 0xe7, 0x0f, 0xf0, 0x00, 0x00, 0x36, /* vlm %v0, %v15, 0x000(%r15) */
1040 0xe7, 0x0f, 0xf1, 0x00, 0x0c, 0x36, /* vlm %v16, %v31, 0x100(%r15) */
1043 /* Code sequence restoring misc registers. As for PSWM, only CC should be
1044 modified by C code, so we use the alr instruction to restore it by
1045 manufacturing an operand that'll result in the original flags. */
1047 static const unsigned char s390_ft_exit_misc
[] = {
1048 0xb2, 0x9d, 0xf2, 0xd0, /* lfpc 0x2d0(%r15) */
1049 0x58, 0x00, 0xf2, 0xc0, /* l %r0, 0x2c0(%r15) */
1050 /* Extract CC to high 2 bits of %r0. */
1051 0x88, 0x00, 0x00, 0x0c, /* srl %r0, 12 */
1052 0x89, 0x00, 0x00, 0x1e, /* sll %r0, 30 */
1053 /* Add %r0 to itself. Result will be nonzero iff CC bit 0 is set, and
1054 will have carry iff CC bit 1 is set - resulting in the same flags
1056 0x1e, 0x00, /* alr %r0, %r0 */
1057 0x9a, 0x0f, 0xf2, 0x80, /* lam %a0, %a15, 0x280(%r15) */
1060 /* Code sequence restoring GPRs, for 31-bit targets with no high GPRs. */
1062 static const unsigned char s390_ft_exit_gpr_esa
[] = {
1063 0x58, 0x00, 0xf2, 0x04, /* l %r0, 0x204(%r15) */
1064 0x58, 0x10, 0xf2, 0x0c, /* l %r1, 0x20c(%r15) */
1065 0x58, 0x20, 0xf2, 0x14, /* l %r2, 0x214(%r15) */
1066 0x58, 0x30, 0xf2, 0x1c, /* l %r3, 0x21c(%r15) */
1067 0x58, 0x40, 0xf2, 0x24, /* l %r4, 0x224(%r15) */
1068 0x58, 0x50, 0xf2, 0x2c, /* l %r5, 0x22c(%r15) */
1069 0x58, 0x60, 0xf2, 0x34, /* l %r6, 0x234(%r15) */
1070 0x58, 0x70, 0xf2, 0x3c, /* l %r7, 0x23c(%r15) */
1071 0x58, 0x80, 0xf2, 0x44, /* l %r8, 0x244(%r15) */
1072 0x58, 0x90, 0xf2, 0x4c, /* l %r9, 0x24c(%r15) */
1073 0x58, 0xa0, 0xf2, 0x54, /* l %r10, 0x254(%r15) */
1074 0x58, 0xb0, 0xf2, 0x5c, /* l %r11, 0x25c(%r15) */
1075 0x58, 0xc0, 0xf2, 0x64, /* l %r12, 0x264(%r15) */
1076 0x58, 0xd0, 0xf2, 0x6c, /* l %r13, 0x26c(%r15) */
1077 0x58, 0xe0, 0xf2, 0x74, /* l %r14, 0x274(%r15) */
1078 0x58, 0xf0, 0xf2, 0x7c, /* l %r15, 0x27c(%r15) */
1081 /* Code sequence restoring GPRs, for 64-bit targets and 31-bit targets
1084 static const unsigned char s390_ft_exit_gpr_zarch
[] = {
1085 0xeb, 0x0f, 0xf2, 0x00, 0x00, 0x04, /* lmg %r0, %r15, 0x200(%r15) */
1088 /* Writes instructions to target, updating the to pointer. */
1091 append_insns (CORE_ADDR
*to
, size_t len
, const unsigned char *buf
)
1093 target_write_memory (*to
, buf
, len
);
1097 /* Relocates an instruction from oldloc to *to, updating to. */
1100 s390_relocate_instruction (CORE_ADDR
*to
, CORE_ADDR oldloc
, int is_64
)
1105 /* 0: no fixup, 1: PC16DBL fixup, 2: PC32DBL fixup. */
1108 read_inferior_memory (oldloc
, buf
, sizeof buf
);
1111 else if (buf
[0] < 0xc0)
1117 case 0x05: /* BALR */
1118 case 0x0c: /* BASSM */
1119 case 0x0d: /* BASR */
1120 case 0x45: /* BAL */
1121 case 0x4d: /* BAS */
1122 /* These save a return address and mess around with registers.
1123 We can't relocate them. */
1125 case 0x84: /* BRXH */
1126 case 0x85: /* BRXLE */
1131 /* BRC, BRAS, BRCT, BRCTG */
1132 if (op2
>= 4 && op2
<= 7)
1140 /* LARL, BRCL, BRASL */
1141 if (op2
== 0 || op2
== 4 || op2
== 5)
1149 /* PC-relative addressing instructions. */
1152 case 0xc5: /* BPRP */
1153 case 0xc7: /* BPP */
1154 /* Branch prediction - just skip it. */
1166 case 0x44: /* BRXHG */
1167 case 0x45: /* BRXLG */
1168 case 0x64: /* CGRJ */
1169 case 0x65: /* CLGRJ */
1170 case 0x76: /* CRJ */
1171 case 0x77: /* CLRJ */
1180 /* We'll have to relocate an instruction with a PC-relative field.
1181 First, compute the target. */
1182 int64_t loffset
= 0;
1186 int16_t soffset
= 0;
1187 memcpy (&soffset
, buf
+ 2, 2);
1192 int32_t soffset
= 0;
1193 memcpy (&soffset
, buf
+ 2, 4);
1196 target
= oldloc
+ loffset
* 2;
1198 target
&= 0x7fffffff;
1202 /* BRAS or BRASL was used. We cannot just relocate those, since
1203 they save the return address in a register. We can, however,
1204 replace them with a LARL+JG sequence. */
1206 /* Make the LARL. */
1210 loffset
= oldloc
+ ilen
- *to
;
1213 if (soffset
!= loffset
&& is_64
)
1215 memcpy (buf
+ 2, &soffset
, 4);
1216 append_insns (to
, 6, buf
);
1218 /* Note: this is not fully correct. In 31-bit mode, LARL will write
1219 an address with the top bit 0, while BRAS/BRASL will write it
1220 with top bit 1. It should not matter much, since linux compilers
1221 use BR and not BSM to return from functions, but it could confuse
1222 some poor stack unwinder. */
1224 /* We'll now be writing a JG. */
1231 /* Compute the new offset and write it to the buffer. */
1232 loffset
= target
- *to
;
1237 int16_t soffset
= loffset
;
1238 if (soffset
!= loffset
)
1240 memcpy (buf
+ 2, &soffset
, 2);
1244 int32_t soffset
= loffset
;
1245 if (soffset
!= loffset
&& is_64
)
1247 memcpy (buf
+ 2, &soffset
, 4);
1250 append_insns (to
, ilen
, buf
);
1254 /* Implementation of linux_target_ops method
1255 "install_fast_tracepoint_jump_pad". */
1258 s390_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint
,
1260 CORE_ADDR collector
,
1263 CORE_ADDR
*jump_entry
,
1264 CORE_ADDR
*trampoline
,
1265 ULONGEST
*trampoline_size
,
1266 unsigned char *jjump_pad_insn
,
1267 ULONGEST
*jjump_pad_insn_size
,
1268 CORE_ADDR
*adjusted_insn_addr
,
1269 CORE_ADDR
*adjusted_insn_addr_end
,
1275 unsigned char jbuf
[6] = { 0xc0, 0xf4, 0, 0, 0, 0 }; /* jg ... */
1276 CORE_ADDR buildaddr
= *jump_entry
;
1278 struct regcache
*regcache
= get_thread_regcache (current_thread
, 0);
1279 int is_64
= register_size (regcache
->tdesc
, 0) == 8;
1280 int is_zarch
= is_64
|| have_hwcap_s390_high_gprs
;
1281 int has_vx
= have_hwcap_s390_vx
;
1283 int is_64
= 0, is_zarch
= 0, has_vx
= 0;
1285 CORE_ADDR literals
[4] = {
1292 /* First, store the GPRs. */
1294 append_insns (&buildaddr
, sizeof s390_ft_entry_gpr_zarch
,
1295 s390_ft_entry_gpr_zarch
);
1297 append_insns (&buildaddr
, sizeof s390_ft_entry_gpr_esa
,
1298 s390_ft_entry_gpr_esa
);
1300 /* Second, misc registers (ARs, PSWM, FPC). PSWA will be stored below. */
1301 append_insns (&buildaddr
, sizeof s390_ft_entry_misc
, s390_ft_entry_misc
);
1303 /* Third, FRs or VRs. */
1305 append_insns (&buildaddr
, sizeof s390_ft_entry_vr
, s390_ft_entry_vr
);
1307 append_insns (&buildaddr
, sizeof s390_ft_entry_fr
, s390_ft_entry_fr
);
1309 /* Now, the main part of code - store PSWA, take lock, call collector,
1310 leave lock. First, we'll need to fetch 4 literals. */
1312 unsigned char buf
[] = {
1313 0x07, 0x07, /* nopr %r7 */
1314 0x07, 0x07, /* nopr %r7 */
1315 0x07, 0x07, /* nopr %r7 */
1316 0xa7, 0x15, 0x00, 0x12, /* bras %r1, .Lend */
1317 0, 0, 0, 0, 0, 0, 0, 0, /* tpaddr */
1318 0, 0, 0, 0, 0, 0, 0, 0, /* tpoint */
1319 0, 0, 0, 0, 0, 0, 0, 0, /* collector */
1320 0, 0, 0, 0, 0, 0, 0, 0, /* lockaddr */
1323 /* Find the proper start place in buf, so that literals will be
1325 int bufpos
= (buildaddr
+ 2) & 7;
1326 /* Stuff the literals into the buffer. */
1327 for (i
= 0; i
< 4; i
++) {
1328 uint64_t lit
= literals
[i
];
1329 memcpy (&buf
[sizeof buf
- 32 + i
* 8], &lit
, 8);
1331 append_insns (&buildaddr
, sizeof buf
- bufpos
, buf
+ bufpos
);
1332 append_insns (&buildaddr
, sizeof s390_ft_main_64
, s390_ft_main_64
);
1334 unsigned char buf
[] = {
1335 0x07, 0x07, /* nopr %r7 */
1336 0xa7, 0x15, 0x00, 0x0a, /* bras %r1, .Lend */
1337 0, 0, 0, 0, /* tpaddr */
1338 0, 0, 0, 0, /* tpoint */
1339 0, 0, 0, 0, /* collector */
1340 0, 0, 0, 0, /* lockaddr */
1343 /* Find the proper start place in buf, so that literals will be
1345 int bufpos
= (buildaddr
+ 2) & 3;
1346 /* First literal will be saved as the PSWA, make sure it has the high bit
1348 literals
[0] |= 0x80000000;
1349 /* Stuff the literals into the buffer. */
1350 for (i
= 0; i
< 4; i
++) {
1351 uint32_t lit
= literals
[i
];
1352 memcpy (&buf
[sizeof buf
- 16 + i
* 4], &lit
, 4);
1354 append_insns (&buildaddr
, sizeof buf
- bufpos
, buf
+ bufpos
);
1355 append_insns (&buildaddr
, sizeof s390_ft_main_31
, s390_ft_main_31
);
1358 /* Restore FRs or VRs. */
1360 append_insns (&buildaddr
, sizeof s390_ft_exit_vr
, s390_ft_exit_vr
);
1362 append_insns (&buildaddr
, sizeof s390_ft_exit_fr
, s390_ft_exit_fr
);
1364 /* Restore misc registers. */
1365 append_insns (&buildaddr
, sizeof s390_ft_exit_misc
, s390_ft_exit_misc
);
1367 /* Restore the GPRs. */
1369 append_insns (&buildaddr
, sizeof s390_ft_exit_gpr_zarch
,
1370 s390_ft_exit_gpr_zarch
);
1372 append_insns (&buildaddr
, sizeof s390_ft_exit_gpr_esa
,
1373 s390_ft_exit_gpr_esa
);
1375 /* Now, adjust the original instruction to execute in the jump
1377 *adjusted_insn_addr
= buildaddr
;
1378 if (s390_relocate_instruction (&buildaddr
, tpaddr
, is_64
))
1380 sprintf (err
, "E.Could not relocate instruction for tracepoint.");
1383 *adjusted_insn_addr_end
= buildaddr
;
1385 /* Finally, write a jump back to the program. */
1387 loffset
= (tpaddr
+ orig_size
) - buildaddr
;
1390 if (is_64
&& offset
!= loffset
)
1393 "E.Jump back from jump pad too far from tracepoint "
1394 "(offset 0x%" PRIx64
" > int33).", loffset
);
1397 memcpy (jbuf
+ 2, &offset
, 4);
1398 append_insns (&buildaddr
, sizeof jbuf
, jbuf
);
1400 /* The jump pad is now built. Wire in a jump to our jump pad. This
1401 is always done last (by our caller actually), so that we can
1402 install fast tracepoints with threads running. This relies on
1403 the agent's atomic write support. */
1404 loffset
= *jump_entry
- tpaddr
;
1407 if (is_64
&& offset
!= loffset
)
1410 "E.Jump back from jump pad too far from tracepoint "
1411 "(offset 0x%" PRIx64
" > int33).", loffset
);
1414 memcpy (jbuf
+ 2, &offset
, 4);
1415 memcpy (jjump_pad_insn
, jbuf
, sizeof jbuf
);
1416 *jjump_pad_insn_size
= sizeof jbuf
;
1418 /* Return the end address of our pad. */
1419 *jump_entry
= buildaddr
;
1424 /* Implementation of linux_target_ops method
1425 "get_min_fast_tracepoint_insn_len". */
1428 s390_get_min_fast_tracepoint_insn_len (void)
1430 /* We only support using 6-byte jumps to reach the tracepoint code.
1431 If the tracepoint buffer were allocated sufficiently close (64kiB)
1432 to the executable code, and the traced instruction itself was close
1433 enough to the beginning, we could use 4-byte jumps, but this doesn't
1434 seem to be worth the effort. */
1438 /* Implementation of linux_target_ops method "get_ipa_tdesc_idx". */
1441 s390_get_ipa_tdesc_idx (void)
1443 struct regcache
*regcache
= get_thread_regcache (current_thread
, 0);
1444 const struct target_desc
*tdesc
= regcache
->tdesc
;
1447 if (tdesc
== tdesc_s390x_linux64
)
1448 return S390_TDESC_64
;
1449 if (tdesc
== tdesc_s390x_linux64v1
)
1450 return S390_TDESC_64V1
;
1451 if (tdesc
== tdesc_s390x_linux64v2
)
1452 return S390_TDESC_64V2
;
1453 if (tdesc
== tdesc_s390x_te_linux64
)
1454 return S390_TDESC_TE
;
1455 if (tdesc
== tdesc_s390x_vx_linux64
)
1456 return S390_TDESC_VX
;
1457 if (tdesc
== tdesc_s390x_tevx_linux64
)
1458 return S390_TDESC_TEVX
;
1459 if (tdesc
== tdesc_s390x_gs_linux64
)
1460 return S390_TDESC_GS
;
1463 if (tdesc
== tdesc_s390_linux32
)
1464 return S390_TDESC_32
;
1465 if (tdesc
== tdesc_s390_linux32v1
)
1466 return S390_TDESC_32V1
;
1467 if (tdesc
== tdesc_s390_linux32v2
)
1468 return S390_TDESC_32V2
;
1469 if (tdesc
== tdesc_s390_linux64
)
1470 return S390_TDESC_64
;
1471 if (tdesc
== tdesc_s390_linux64v1
)
1472 return S390_TDESC_64V1
;
1473 if (tdesc
== tdesc_s390_linux64v2
)
1474 return S390_TDESC_64V2
;
1475 if (tdesc
== tdesc_s390_te_linux64
)
1476 return S390_TDESC_TE
;
1477 if (tdesc
== tdesc_s390_vx_linux64
)
1478 return S390_TDESC_VX
;
1479 if (tdesc
== tdesc_s390_tevx_linux64
)
1480 return S390_TDESC_TEVX
;
1481 if (tdesc
== tdesc_s390_gs_linux64
)
1482 return S390_TDESC_GS
;
1487 /* Appends given buffer to current_insn_ptr in the target. */
1490 add_insns (const unsigned char *start
, int len
)
1492 CORE_ADDR buildaddr
= current_insn_ptr
;
1495 debug_printf ("Adding %d bytes of insn at %s\n",
1496 len
, paddress (buildaddr
));
1498 append_insns (&buildaddr
, len
, start
);
1499 current_insn_ptr
= buildaddr
;
1502 /* Register usage in emit:
1505 - %r2: top of stack (high word for 31-bit)
1506 - %r3: low word of top of stack (for 31-bit)
1508 - %r6, %r7, %r8: don't use
1511 - %r11: frame pointer
1512 - %r12: saved top of stack for void_call_2 (high word for 31-bit)
1513 - %r13: low word of saved top of stack (for 31-bit)
1514 - %r14: return address for calls
1515 - %r15: stack pointer
1519 /* The "emit_prologue" emit_ops method for s390. */
1522 s390_emit_prologue (void)
1524 static const unsigned char buf
[] = {
1525 0x90, 0x9f, 0xf0, 0x24, /* stm %r9, %r15, 0x24(%r15) */
1526 0x18, 0x92, /* lr %r9, %r2 */
1527 0x18, 0xa3, /* lr %r10, %r3 */
1528 0x18, 0xbf, /* lr %r11, %r15 */
1530 add_insns (buf
, sizeof buf
);
1533 /* The "emit_epilogue" emit_ops method for s390. */
1536 s390_emit_epilogue (void)
1538 static const unsigned char buf
[] = {
1539 0x90, 0x23, 0xa0, 0x00, /* stm %r2, %r3, 0(%r10) */
1540 0xa7, 0x28, 0x00, 0x00, /* lhi %r2, 0 */
1541 0x98, 0x9f, 0xb0, 0x24, /* lm %r9, %r15, 0x24(%r11) */
1542 0x07, 0xfe, /* br %r14 */
1544 add_insns (buf
, sizeof buf
);
1547 /* The "emit_add" emit_ops method for s390. */
1550 s390_emit_add (void)
1552 static const unsigned char buf
[] = {
1553 0x5e, 0x30, 0xf0, 0x04, /* al %r3, 4(%r15) */
1554 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x98, /* al %r2, 0(%r15) */
1555 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
1557 add_insns (buf
, sizeof buf
);
1560 /* The "emit_sub" emit_ops method for s390. */
1563 s390_emit_sub (void)
1565 static const unsigned char buf
[] = {
1566 0x98, 0x45, 0xf0, 0x00, /* lm %r4, %r5, 0(%r15) */
1567 0x1f, 0x53, /* slr %r5, %r3 */
1568 0xb9, 0x99, 0x00, 0x42, /* slbr %r4, %r2 */
1569 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
1570 0x18, 0x35, /* lr %r3, %r5 */
1571 0x18, 0x24, /* lr %r2, %r4 */
1573 add_insns (buf
, sizeof buf
);
1576 /* The "emit_mul" emit_ops method for s390. */
1579 s390_emit_mul (void)
1584 /* The "emit_lsh" emit_ops method for s390. */
1587 s390_emit_lsh (void)
1589 static const unsigned char buf
[] = {
1590 0x18, 0x43, /* lr %r4, %r3 */
1591 0x98, 0x23, 0xf0, 0x00, /* lm %r2, %r3, 0(%r15) */
1592 0x8d, 0x20, 0x40, 0x00, /* sldl %r2, 0(%r4) */
1593 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
1595 add_insns (buf
, sizeof buf
);
1598 /* The "emit_rsh_signed" emit_ops method for s390. */
1601 s390_emit_rsh_signed (void)
1603 static const unsigned char buf
[] = {
1604 0x18, 0x43, /* lr %r4, %r3 */
1605 0x98, 0x23, 0xf0, 0x00, /* lm %r2, %r3, 0(%r15) */
1606 0x8e, 0x20, 0x40, 0x00, /* srda %r2, 0(%r4) */
1607 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
1609 add_insns (buf
, sizeof buf
);
1612 /* The "emit_rsh_unsigned" emit_ops method for s390. */
1615 s390_emit_rsh_unsigned (void)
1617 static const unsigned char buf
[] = {
1618 0x18, 0x43, /* lr %r4, %r3 */
1619 0x98, 0x23, 0xf0, 0x00, /* lm %r2, %r3, 0(%r15) */
1620 0x8c, 0x20, 0x40, 0x00, /* srdl %r2, 0(%r4) */
1621 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
1623 add_insns (buf
, sizeof buf
);
1626 /* The "emit_ext" emit_ops method for s390. */
1629 s390_emit_ext (int arg
)
1631 unsigned char buf
[] = {
1632 0x8d, 0x20, 0x00, (unsigned char) (64 - arg
), /* sldl %r2, <64-arg> */
1633 0x8e, 0x20, 0x00, (unsigned char) (64 - arg
), /* srda %r2, <64-arg> */
1635 add_insns (buf
, sizeof buf
);
1638 /* The "emit_log_not" emit_ops method for s390. */
1641 s390_emit_log_not (void)
1643 static const unsigned char buf
[] = {
1644 0x16, 0x23, /* or %r2, %r3 */
1645 0xa7, 0x28, 0x00, 0x00, /* lhi %r2, 0 */
1646 0xa7, 0x38, 0x00, 0x00, /* lhi %r3, 0 */
1647 0xa7, 0x74, 0x00, 0x04, /* jne .Lskip */
1648 0xa7, 0x38, 0x00, 0x01, /* lhi %r3, 1 */
1651 add_insns (buf
, sizeof buf
);
1654 /* The "emit_bit_and" emit_ops method for s390. */
1657 s390_emit_bit_and (void)
1659 static const unsigned char buf
[] = {
1660 0x54, 0x20, 0xf0, 0x00, /* n %r2, 0(%r15) */
1661 0x54, 0x30, 0xf0, 0x04, /* n %r3, 4(%r15) */
1662 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
1664 add_insns (buf
, sizeof buf
);
1667 /* The "emit_bit_or" emit_ops method for s390. */
1670 s390_emit_bit_or (void)
1672 static const unsigned char buf
[] = {
1673 0x56, 0x20, 0xf0, 0x00, /* o %r2, 0(%r15) */
1674 0x56, 0x30, 0xf0, 0x04, /* o %r3, 4(%r15) */
1675 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
1677 add_insns (buf
, sizeof buf
);
1680 /* The "emit_bit_xor" emit_ops method for s390. */
1683 s390_emit_bit_xor (void)
1685 static const unsigned char buf
[] = {
1686 0x57, 0x20, 0xf0, 0x00, /* x %r2, 0(%r15) */
1687 0x57, 0x30, 0xf0, 0x04, /* x %r3, 4(%r15) */
1688 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
1690 add_insns (buf
, sizeof buf
);
1693 /* The "emit_bit_not" emit_ops method for s390. */
1696 s390_emit_bit_not (void)
1698 static const unsigned char buf
[] = {
1699 0xa7, 0x48, 0xff, 0xff, /* lhi %r4, -1 */
1700 0x17, 0x24, /* xr %r2, %r4 */
1701 0x17, 0x34, /* xr %r3, %r4 */
1703 add_insns (buf
, sizeof buf
);
1706 /* The "emit_equal" emit_ops method for s390. */
1709 s390_emit_equal (void)
1711 s390_emit_bit_xor ();
1712 s390_emit_log_not ();
1715 /* The "emit_less_signed" emit_ops method for s390. */
1718 s390_emit_less_signed (void)
1720 static const unsigned char buf
[] = {
1721 0x59, 0x20, 0xf0, 0x00, /* c %r2, 0(%r15) */
1722 0xa7, 0x24, 0x00, 0x0c, /* jh .Lless */
1723 0xa7, 0x44, 0x00, 0x06, /* jl .Lhigh */
1724 0x55, 0x30, 0xf0, 0x04, /* cl %r3, 4(%r15) */
1725 0xa7, 0x24, 0x00, 0x06, /* jh .Lless */
1727 0xa7, 0x38, 0x00, 0x00, /* lhi %r3, 0 */
1728 0xa7, 0xf4, 0x00, 0x04, /* j .Lend */
1730 0xa7, 0x38, 0x00, 0x01, /* lhi %r3, 1 */
1732 0xa7, 0x28, 0x00, 0x00, /* lhi %r2, 0 */
1733 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
1735 add_insns (buf
, sizeof buf
);
1738 /* The "emit_less_unsigned" emit_ops method for s390. */
1741 s390_emit_less_unsigned (void)
1743 static const unsigned char buf
[] = {
1744 0x55, 0x20, 0xf0, 0x00, /* cl %r2, 0(%r15) */
1745 0xa7, 0x24, 0x00, 0x0c, /* jh .Lless */
1746 0xa7, 0x44, 0x00, 0x06, /* jl .Lhigh */
1747 0x55, 0x30, 0xf0, 0x04, /* cl %r3, 4(%r15) */
1748 0xa7, 0x24, 0x00, 0x06, /* jh .Lless */
1750 0xa7, 0x38, 0x00, 0x00, /* lhi %r3, 0 */
1751 0xa7, 0xf4, 0x00, 0x04, /* j .Lend */
1753 0xa7, 0x38, 0x00, 0x01, /* lhi %r3, 1 */
1755 0xa7, 0x28, 0x00, 0x00, /* lhi %r2, 0 */
1756 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
1758 add_insns (buf
, sizeof buf
);
1761 /* The "emit_ref" emit_ops method for s390. */
1764 s390_emit_ref (int size
)
1766 static const unsigned char buf1
[] = {
1767 0xa7, 0x28, 0x00, 0x00, /* lhi %r2, 0 */
1768 0x43, 0x30, 0x30, 0x00, /* ic %r3, 0(%r3) */
1770 static const unsigned char buf2
[] = {
1771 0xa7, 0x28, 0x00, 0x00, /* lhi %r2, 0 */
1772 0x48, 0x30, 0x30, 0x00, /* lh %r3, 0(%r3) */
1774 static const unsigned char buf4
[] = {
1775 0xa7, 0x28, 0x00, 0x00, /* lhi %r2, 0 */
1776 0x58, 0x30, 0x30, 0x00, /* l %r3, 0(%r3) */
1778 static const unsigned char buf8
[] = {
1779 0x98, 0x23, 0x30, 0x00, /* lm %r2, %r3, 0(%r3) */
1784 add_insns (buf1
, sizeof buf1
);
1787 add_insns (buf2
, sizeof buf2
);
1790 add_insns (buf4
, sizeof buf4
);
1793 add_insns (buf8
, sizeof buf8
);
1800 /* The "emit_if_goto" emit_ops method for s390. */
1803 s390_emit_if_goto (int *offset_p
, int *size_p
)
1805 static const unsigned char buf
[] = {
1806 0x16, 0x23, /* or %r2, %r3 */
1807 0x98, 0x23, 0xf0, 0x00, /* lm %r2, %r3, 0(%r15) */
1808 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
1809 0xc0, 0x74, 0x00, 0x00, 0x00, 0x00 /* jgne <fillme> */
1811 add_insns (buf
, sizeof buf
);
1818 /* The "emit_goto" emit_ops method for s390 and s390x. */
1821 s390_emit_goto (int *offset_p
, int *size_p
)
1823 static const unsigned char buf
[] = {
1824 0xc0, 0xf4, 0x00, 0x00, 0x00, 0x00, /* jg <fillme> */
1826 add_insns (buf
, sizeof buf
);
1833 /* The "write_goto_address" emit_ops method for s390 and s390x. */
1836 s390_write_goto_address (CORE_ADDR from
, CORE_ADDR to
, int size
)
1838 long diff
= ((long) (to
- (from
- 2))) / 2;
1840 unsigned char buf
[sizeof sdiff
];
1842 /* We're only doing 4-byte sizes at the moment. */
1843 if (size
!= sizeof sdiff
|| sdiff
!= diff
)
1849 memcpy (buf
, &sdiff
, sizeof sdiff
);
1850 target_write_memory (from
, buf
, sizeof sdiff
);
1853 /* Preparation for emitting a literal pool of given size. Loads the address
1854 of the pool into %r1, and jumps over it. Called should emit the pool data
1855 immediately afterwards. Used for both s390 and s390x. */
1858 s390_emit_litpool (int size
)
1860 static const unsigned char nop
[] = {
1863 unsigned char buf
[] = {
1865 (unsigned char) ((size
+ 4) / 2), /* bras %r1, .Lend+size */
1870 /* buf needs to start at even halfword for litpool to be aligned */
1871 if (current_insn_ptr
& 2)
1872 add_insns (nop
, sizeof nop
);
1876 while ((current_insn_ptr
& 6) != 4)
1877 add_insns (nop
, sizeof nop
);
1879 add_insns (buf
, sizeof buf
);
1882 /* The "emit_const" emit_ops method for s390. */
1885 s390_emit_const (LONGEST num
)
1887 unsigned long long n
= num
;
1888 unsigned char buf_s
[] = {
1889 /* lhi %r3, <num> */
1891 (unsigned char) (num
>> 8), (unsigned char) num
,
1895 static const unsigned char buf_l
[] = {
1896 0x98, 0x23, 0x10, 0x00, /* lm %r2, %r3, 0(%r1) */
1898 if (num
< 0x8000 && num
>= 0)
1900 add_insns (buf_s
, sizeof buf_s
);
1904 s390_emit_litpool (8);
1905 add_insns ((unsigned char *) &n
, sizeof n
);
1906 add_insns (buf_l
, sizeof buf_l
);
1910 /* The "emit_call" emit_ops method for s390. */
1913 s390_emit_call (CORE_ADDR fn
)
1915 unsigned int n
= fn
;
1916 static const unsigned char buf
[] = {
1917 0x58, 0x10, 0x10, 0x00, /* l %r1, 0(%r1) */
1918 0xa7, 0xfa, 0xff, 0xa0, /* ahi %r15, -0x60 */
1919 0x0d, 0xe1, /* basr %r14, %r1 */
1920 0xa7, 0xfa, 0x00, 0x60, /* ahi %r15, 0x60 */
1922 s390_emit_litpool (4);
1923 add_insns ((unsigned char *) &n
, sizeof n
);
1924 add_insns (buf
, sizeof buf
);
1927 /* The "emit_reg" emit_ops method for s390. */
1930 s390_emit_reg (int reg
)
1932 unsigned char bufpre
[] = {
1935 /* lhi %r3, <reg> */
1936 0xa7, 0x38, (unsigned char) (reg
>> 8), (unsigned char) reg
,
1938 add_insns (bufpre
, sizeof bufpre
);
1939 s390_emit_call (get_raw_reg_func_addr ());
1942 /* The "emit_pop" emit_ops method for s390. */
1945 s390_emit_pop (void)
1947 static const unsigned char buf
[] = {
1948 0x98, 0x23, 0xf0, 0x00, /* lm %r2, %r3, 0(%r15) */
1949 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
1951 add_insns (buf
, sizeof buf
);
1954 /* The "emit_stack_flush" emit_ops method for s390. */
1957 s390_emit_stack_flush (void)
1959 static const unsigned char buf
[] = {
1960 0xa7, 0xfa, 0xff, 0xf8, /* ahi %r15, -8 */
1961 0x90, 0x23, 0xf0, 0x00, /* stm %r2, %r3, 0(%r15) */
1963 add_insns (buf
, sizeof buf
);
1966 /* The "emit_zero_ext" emit_ops method for s390. */
1969 s390_emit_zero_ext (int arg
)
1971 unsigned char buf
[] = {
1972 0x8d, 0x20, 0x00, (unsigned char) (64 - arg
), /* sldl %r2, <64-arg> */
1973 0x8c, 0x20, 0x00, (unsigned char) (64 - arg
), /* srdl %r2, <64-arg> */
1975 add_insns (buf
, sizeof buf
);
1978 /* The "emit_swap" emit_ops method for s390. */
1981 s390_emit_swap (void)
1983 static const unsigned char buf
[] = {
1984 0x98, 0x45, 0xf0, 0x00, /* lm %r4, %r5, 0(%r15) */
1985 0x90, 0x23, 0xf0, 0x00, /* stm %r2, %r3, 0(%r15) */
1986 0x18, 0x24, /* lr %r2, %r4 */
1987 0x18, 0x35, /* lr %r3, %r5 */
1989 add_insns (buf
, sizeof buf
);
1992 /* The "emit_stack_adjust" emit_ops method for s390. */
1995 s390_emit_stack_adjust (int n
)
1997 unsigned char buf
[] = {
2000 (unsigned char ) (n
* 8 >> 8), (unsigned char) (n
* 8),
2002 add_insns (buf
, sizeof buf
);
2005 /* Sets %r2 to a 32-bit constant. */
2008 s390_emit_set_r2 (int arg1
)
2010 unsigned char buf_s
[] = {
2011 /* lhi %r2, <arg1> */
2012 0xa7, 0x28, (unsigned char) (arg1
>> 8), (unsigned char) arg1
,
2014 static const unsigned char buf_l
[] = {
2015 0x58, 0x20, 0x10, 0x00, /* l %r2, 0(%r1) */
2017 if (arg1
< 0x8000 && arg1
>= -0x8000)
2019 add_insns (buf_s
, sizeof buf_s
);
2023 s390_emit_litpool (4);
2024 add_insns ((unsigned char *) &arg1
, sizeof arg1
);
2025 add_insns (buf_l
, sizeof buf_l
);
2029 /* The "emit_int_call_1" emit_ops method for s390. */
2032 s390_emit_int_call_1 (CORE_ADDR fn
, int arg1
)
2034 /* FN's prototype is `LONGEST(*fn)(int)'. */
2035 s390_emit_set_r2 (arg1
);
2036 s390_emit_call (fn
);
2039 /* The "emit_void_call_2" emit_ops method for s390. */
2042 s390_emit_void_call_2 (CORE_ADDR fn
, int arg1
)
2044 /* FN's prototype is `void(*fn)(int,LONGEST)'. */
2045 static const unsigned char buf
[] = {
2046 0x18, 0xc2, /* lr %r12, %r2 */
2047 0x18, 0xd3, /* lr %r13, %r3 */
2048 0x18, 0x43, /* lr %r4, %r3 */
2049 0x18, 0x32, /* lr %r3, %r2 */
2051 static const unsigned char buf2
[] = {
2052 0x18, 0x2c, /* lr %r2, %r12 */
2053 0x18, 0x3d, /* lr %r3, %r13 */
2055 add_insns (buf
, sizeof buf
);
2056 s390_emit_set_r2 (arg1
);
2057 s390_emit_call (fn
);
2058 add_insns (buf2
, sizeof buf2
);
2061 /* The "emit_eq_goto" emit_ops method for s390. */
2064 s390_emit_eq_goto (int *offset_p
, int *size_p
)
2066 static const unsigned char buf
[] = {
2067 0x57, 0x20, 0xf0, 0x00, /* x %r2, 0(%r15) */
2068 0x57, 0x30, 0xf0, 0x04, /* x %r3, 4(%r15) */
2069 0x16, 0x23, /* or %r2, %r3 */
2070 0x98, 0x23, 0xf0, 0x08, /* lm %r2, %r3, 8(%r15) */
2071 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
2072 0xc0, 0x84, 0x00, 0x00, 0x00, 0x00, /* jge <fillme> */
2074 add_insns (buf
, sizeof buf
);
2081 /* The "emit_ne_goto" emit_ops method for s390. */
2084 s390_emit_ne_goto (int *offset_p
, int *size_p
)
2086 static const unsigned char buf
[] = {
2087 0x57, 0x20, 0xf0, 0x00, /* x %r2, 0(%r15) */
2088 0x57, 0x30, 0xf0, 0x04, /* x %r3, 4(%r15) */
2089 0x16, 0x23, /* or %r2, %r3 */
2090 0x98, 0x23, 0xf0, 0x08, /* lm %r2, %r3, 8(%r15) */
2091 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
2092 0xc0, 0x74, 0x00, 0x00, 0x00, 0x00, /* jgne <fillme> */
2094 add_insns (buf
, sizeof buf
);
2101 /* The "emit_lt_goto" emit_ops method for s390. */
2104 s390_emit_lt_goto (int *offset_p
, int *size_p
)
2106 static const unsigned char buf
[] = {
2107 0x59, 0x20, 0xf0, 0x00, /* c %r2, 0(%r15) */
2108 0xa7, 0x24, 0x00, 0x0e, /* jh .Ltrue */
2109 0xa7, 0x44, 0x00, 0x06, /* jl .Lfalse */
2110 0x55, 0x30, 0xf0, 0x04, /* cl %r3, 4(%r15) */
2111 0xa7, 0x24, 0x00, 0x08, /* jh .Ltrue */
2113 0x98, 0x23, 0xf0, 0x08, /* lm %r2, %r3, 8(%r15) */
2114 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
2115 0xa7, 0xf4, 0x00, 0x09, /* j .Lend */
2117 0x98, 0x23, 0xf0, 0x08, /* lm %r2, %r3, 8(%r15) */
2118 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
2119 0xc0, 0xf4, 0x00, 0x00, 0x00, 0x00, /* jg <fillme> */
2122 add_insns (buf
, sizeof buf
);
2129 /* The "emit_le_goto" emit_ops method for s390. */
2132 s390_emit_le_goto (int *offset_p
, int *size_p
)
2134 static const unsigned char buf
[] = {
2135 0x59, 0x20, 0xf0, 0x00, /* c %r2, 0(%r15) */
2136 0xa7, 0x24, 0x00, 0x0e, /* jh .Ltrue */
2137 0xa7, 0x44, 0x00, 0x06, /* jl .Lfalse */
2138 0x55, 0x30, 0xf0, 0x04, /* cl %r3, 4(%r15) */
2139 0xa7, 0xa4, 0x00, 0x08, /* jhe .Ltrue */
2141 0x98, 0x23, 0xf0, 0x08, /* lm %r2, %r3, 8(%r15) */
2142 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
2143 0xa7, 0xf4, 0x00, 0x09, /* j .Lend */
2145 0x98, 0x23, 0xf0, 0x08, /* lm %r2, %r3, 8(%r15) */
2146 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
2147 0xc0, 0xf4, 0x00, 0x00, 0x00, 0x00, /* jg <fillme> */
2150 add_insns (buf
, sizeof buf
);
2157 /* The "emit_gt_goto" emit_ops method for s390. */
2160 s390_emit_gt_goto (int *offset_p
, int *size_p
)
2162 static const unsigned char buf
[] = {
2163 0x59, 0x20, 0xf0, 0x00, /* c %r2, 0(%r15) */
2164 0xa7, 0x44, 0x00, 0x0e, /* jl .Ltrue */
2165 0xa7, 0x24, 0x00, 0x06, /* jh .Lfalse */
2166 0x55, 0x30, 0xf0, 0x04, /* cl %r3, 4(%r15) */
2167 0xa7, 0x44, 0x00, 0x08, /* jl .Ltrue */
2169 0x98, 0x23, 0xf0, 0x08, /* lm %r2, %r3, 8(%r15) */
2170 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
2171 0xa7, 0xf4, 0x00, 0x09, /* j .Lend */
2173 0x98, 0x23, 0xf0, 0x08, /* lm %r2, %r3, 8(%r15) */
2174 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
2175 0xc0, 0xf4, 0x00, 0x00, 0x00, 0x00, /* jg <fillme> */
2178 add_insns (buf
, sizeof buf
);
2185 /* The "emit_ge_goto" emit_ops method for s390. */
2188 s390_emit_ge_goto (int *offset_p
, int *size_p
)
2190 static const unsigned char buf
[] = {
2191 0x59, 0x20, 0xf0, 0x00, /* c %r2, 0(%r15) */
2192 0xa7, 0x44, 0x00, 0x0e, /* jl .Ltrue */
2193 0xa7, 0x24, 0x00, 0x06, /* jh .Lfalse */
2194 0x55, 0x30, 0xf0, 0x04, /* cl %r3, 4(%r15) */
2195 0xa7, 0xc4, 0x00, 0x08, /* jle .Ltrue */
2197 0x98, 0x23, 0xf0, 0x08, /* lm %r2, %r3, 8(%r15) */
2198 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
2199 0xa7, 0xf4, 0x00, 0x09, /* j .Lend */
2201 0x98, 0x23, 0xf0, 0x08, /* lm %r2, %r3, 8(%r15) */
2202 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
2203 0xc0, 0xf4, 0x00, 0x00, 0x00, 0x00, /* jg <fillme> */
2206 add_insns (buf
, sizeof buf
);
2213 /* The "emit_ops" structure for s390. Named _impl to avoid name
2214 collision with s390_emit_ops function. */
2216 static struct emit_ops s390_emit_ops_impl
=
2224 s390_emit_rsh_signed
,
2225 s390_emit_rsh_unsigned
,
2233 s390_emit_less_signed
,
2234 s390_emit_less_unsigned
,
2238 s390_write_goto_address
,
2243 s390_emit_stack_flush
,
2246 s390_emit_stack_adjust
,
2247 s390_emit_int_call_1
,
2248 s390_emit_void_call_2
,
2259 /* The "emit_prologue" emit_ops method for s390x. */
2262 s390x_emit_prologue (void)
2264 static const unsigned char buf
[] = {
2265 0xeb, 0x9f, 0xf0, 0x48, 0x00, 0x24, /* stmg %r9, %r15, 0x48(%r15) */
2266 0xb9, 0x04, 0x00, 0x92, /* lgr %r9, %r2 */
2267 0xb9, 0x04, 0x00, 0xa3, /* lgr %r10, %r3 */
2268 0xb9, 0x04, 0x00, 0xbf, /* lgr %r11, %r15 */
2270 add_insns (buf
, sizeof buf
);
2273 /* The "emit_epilogue" emit_ops method for s390x. */
2276 s390x_emit_epilogue (void)
2278 static const unsigned char buf
[] = {
2279 0xe3, 0x20, 0xa0, 0x00, 0x00, 0x24, /* stg %r2, 0(%r10) */
2280 0xa7, 0x29, 0x00, 0x00, /* lghi %r2, 0 */
2281 0xeb, 0x9f, 0xf0, 0x48, 0x00, 0x04, /* lmg %r9, %r15, 0x48(%r15) */
2282 0x07, 0xfe, /* br %r14 */
2284 add_insns (buf
, sizeof buf
);
2287 /* The "emit_add" emit_ops method for s390x. */
2290 s390x_emit_add (void)
2292 static const unsigned char buf
[] = {
2293 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x0a, /* alg %r2, 0(%r15) */
2294 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
2296 add_insns (buf
, sizeof buf
);
2299 /* The "emit_sub" emit_ops method for s390x. */
2302 s390x_emit_sub (void)
2304 static const unsigned char buf
[] = {
2305 0xe3, 0x30, 0xf0, 0x00, 0x00, 0x04, /* lg %r3, 0(%r15) */
2306 0xb9, 0x0b, 0x00, 0x32, /* slgr %r3, %r2 */
2307 0xb9, 0x04, 0x00, 0x23, /* lgr %r2, %r3 */
2308 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
2310 add_insns (buf
, sizeof buf
);
2313 /* The "emit_mul" emit_ops method for s390x. */
2316 s390x_emit_mul (void)
2321 /* The "emit_lsh" emit_ops method for s390x. */
2324 s390x_emit_lsh (void)
2326 static const unsigned char buf
[] = {
2327 0xe3, 0x30, 0xf0, 0x00, 0x00, 0x04, /* lg %r3, 0(%r15) */
2328 0xeb, 0x23, 0x20, 0x00, 0x00, 0x0d, /* sllg %r2, %r3, 0(%r2) */
2329 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
2331 add_insns (buf
, sizeof buf
);
2334 /* The "emit_rsh_signed" emit_ops method for s390x. */
2337 s390x_emit_rsh_signed (void)
2339 static const unsigned char buf
[] = {
2340 0xe3, 0x30, 0xf0, 0x00, 0x00, 0x04, /* lg %r3, 0(%r15) */
2341 0xeb, 0x23, 0x20, 0x00, 0x00, 0x0a, /* srag %r2, %r3, 0(%r2) */
2342 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
2344 add_insns (buf
, sizeof buf
);
2347 /* The "emit_rsh_unsigned" emit_ops method for s390x. */
2350 s390x_emit_rsh_unsigned (void)
2352 static const unsigned char buf
[] = {
2353 0xe3, 0x30, 0xf0, 0x00, 0x00, 0x04, /* lg %r3, 0(%r15) */
2354 0xeb, 0x23, 0x20, 0x00, 0x00, 0x0c, /* srlg %r2, %r3, 0(%r2) */
2355 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
2357 add_insns (buf
, sizeof buf
);
2360 /* The "emit_ext" emit_ops method for s390x. */
2363 s390x_emit_ext (int arg
)
2365 unsigned char buf
[] = {
2366 /* sllg %r2, %r2, <64-arg> */
2367 0xeb, 0x22, 0x00, (unsigned char) (64 - arg
), 0x00, 0x0d,
2368 /* srag %r2, %r2, <64-arg> */
2369 0xeb, 0x22, 0x00, (unsigned char) (64 - arg
), 0x00, 0x0a,
2371 add_insns (buf
, sizeof buf
);
2374 /* The "emit_log_not" emit_ops method for s390x. */
2377 s390x_emit_log_not (void)
2379 static const unsigned char buf
[] = {
2380 0xb9, 0x00, 0x00, 0x22, /* lpgr %r2, %r2 */
2381 0xa7, 0x2b, 0xff, 0xff, /* aghi %r2, -1 */
2382 0xeb, 0x22, 0x00, 0x3f, 0x00, 0x0c, /* srlg %r2, %r2, 63 */
2384 add_insns (buf
, sizeof buf
);
2387 /* The "emit_bit_and" emit_ops method for s390x. */
2390 s390x_emit_bit_and (void)
2392 static const unsigned char buf
[] = {
2393 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x80, /* ng %r2, 0(%r15) */
2394 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
2396 add_insns (buf
, sizeof buf
);
2399 /* The "emit_bit_or" emit_ops method for s390x. */
2402 s390x_emit_bit_or (void)
2404 static const unsigned char buf
[] = {
2405 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x81, /* og %r2, 0(%r15) */
2406 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
2408 add_insns (buf
, sizeof buf
);
2411 /* The "emit_bit_xor" emit_ops method for s390x. */
2414 s390x_emit_bit_xor (void)
2416 static const unsigned char buf
[] = {
2417 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x82, /* xg %r2, 0(%r15) */
2418 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
2420 add_insns (buf
, sizeof buf
);
2423 /* The "emit_bit_not" emit_ops method for s390x. */
2426 s390x_emit_bit_not (void)
2428 static const unsigned char buf
[] = {
2429 0xa7, 0x39, 0xff, 0xff, /* lghi %r3, -1 */
2430 0xb9, 0x82, 0x00, 0x23, /* xgr %r2, %r3 */
2432 add_insns (buf
, sizeof buf
);
2435 /* The "emit_equal" emit_ops method for s390x. */
2438 s390x_emit_equal (void)
2440 s390x_emit_bit_xor ();
2441 s390x_emit_log_not ();
2444 /* The "emit_less_signed" emit_ops method for s390x. */
2447 s390x_emit_less_signed (void)
2449 static const unsigned char buf
[] = {
2450 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x20, /* cg %r2, 0(%r15) */
2451 0xa7, 0x29, 0x00, 0x01, /* lghi %r2, 1 */
2452 0xa7, 0x24, 0x00, 0x04, /* jh .Lend */
2453 0xa7, 0x29, 0x00, 0x00, /* lghi %r2, 0 */
2455 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
2457 add_insns (buf
, sizeof buf
);
2460 /* The "emit_less_unsigned" emit_ops method for s390x. */
2463 s390x_emit_less_unsigned (void)
2465 static const unsigned char buf
[] = {
2466 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x21, /* clg %r2, 0(%r15) */
2467 0xa7, 0x29, 0x00, 0x01, /* lghi %r2, 1 */
2468 0xa7, 0x24, 0x00, 0x04, /* jh .Lend */
2469 0xa7, 0x29, 0x00, 0x00, /* lghi %r2, 0 */
2471 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
2473 add_insns (buf
, sizeof buf
);
2476 /* The "emit_ref" emit_ops method for s390x. */
2479 s390x_emit_ref (int size
)
2481 static const unsigned char buf1
[] = {
2482 0xe3, 0x20, 0x20, 0x00, 0x00, 0x90, /* llgc %r2, 0(%r2) */
2484 static const unsigned char buf2
[] = {
2485 0xe3, 0x20, 0x20, 0x00, 0x00, 0x91 /* llgh %r2, 0(%r2) */
2487 static const unsigned char buf4
[] = {
2488 0xe3, 0x20, 0x20, 0x00, 0x00, 0x16, /* llgf %r2, 0(%r2) */
2490 static const unsigned char buf8
[] = {
2491 0xe3, 0x20, 0x20, 0x00, 0x00, 0x04, /* lg %r2, 0(%r2) */
2496 add_insns (buf1
, sizeof buf1
);
2499 add_insns (buf2
, sizeof buf2
);
2502 add_insns (buf4
, sizeof buf4
);
2505 add_insns (buf8
, sizeof buf8
);
2512 /* The "emit_if_goto" emit_ops method for s390x. */
2515 s390x_emit_if_goto (int *offset_p
, int *size_p
)
2517 static const unsigned char buf
[] = {
2518 0xb9, 0x02, 0x00, 0x22, /* ltgr %r2, %r2 */
2519 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x04, /* lg %r2, 0(%r15) */
2520 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
2521 0xc0, 0x74, 0x00, 0x00, 0x00, 0x00, /* jgne <fillme> */
2523 add_insns (buf
, sizeof buf
);
2530 /* The "emit_const" emit_ops method for s390x. */
2533 s390x_emit_const (LONGEST num
)
2535 unsigned long long n
= num
;
2536 unsigned char buf_s
[] = {
2537 /* lghi %r2, <num> */
2538 0xa7, 0x29, (unsigned char) (num
>> 8), (unsigned char) num
,
2540 static const unsigned char buf_l
[] = {
2541 0xe3, 0x20, 0x10, 0x00, 0x00, 0x04, /* lg %r2, 0(%r1) */
2543 if (num
< 0x8000 && num
>= -0x8000)
2545 add_insns (buf_s
, sizeof buf_s
);
2549 s390_emit_litpool (8);
2550 add_insns ((unsigned char *) &n
, sizeof n
);
2551 add_insns (buf_l
, sizeof buf_l
);
2555 /* The "emit_call" emit_ops method for s390x. */
2558 s390x_emit_call (CORE_ADDR fn
)
2560 unsigned long n
= fn
;
2561 static const unsigned char buf
[] = {
2562 0xe3, 0x10, 0x10, 0x00, 0x00, 0x04, /* lg %r1, 0(%r1) */
2563 0xa7, 0xfb, 0xff, 0x60, /* aghi %r15, -0xa0 */
2564 0x0d, 0xe1, /* basr %r14, %r1 */
2565 0xa7, 0xfb, 0x00, 0xa0, /* aghi %r15, 0xa0 */
2567 s390_emit_litpool (8);
2568 add_insns ((unsigned char *) &n
, sizeof n
);
2569 add_insns (buf
, sizeof buf
);
2572 /* The "emit_reg" emit_ops method for s390x. */
2575 s390x_emit_reg (int reg
)
2577 unsigned char buf
[] = {
2579 0xb9, 0x04, 0x00, 0x29,
2580 /* lghi %r3, <reg> */
2581 0xa7, 0x39, (unsigned char) (reg
>> 8), (unsigned char) reg
,
2583 add_insns (buf
, sizeof buf
);
2584 s390x_emit_call (get_raw_reg_func_addr ());
2587 /* The "emit_pop" emit_ops method for s390x. */
2590 s390x_emit_pop (void)
2592 static const unsigned char buf
[] = {
2593 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x04, /* lg %r2, 0(%r15) */
2594 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
2596 add_insns (buf
, sizeof buf
);
2599 /* The "emit_stack_flush" emit_ops method for s390x. */
2602 s390x_emit_stack_flush (void)
2604 static const unsigned char buf
[] = {
2605 0xa7, 0xfb, 0xff, 0xf8, /* aghi %r15, -8 */
2606 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x24, /* stg %r2, 0(%r15) */
2608 add_insns (buf
, sizeof buf
);
2611 /* The "emit_zero_ext" emit_ops method for s390x. */
2614 s390x_emit_zero_ext (int arg
)
2616 unsigned char buf
[] = {
2617 /* sllg %r2, %r2, <64-arg> */
2618 0xeb, 0x22, 0x00, (unsigned char) (64 - arg
), 0x00, 0x0d,
2619 /* srlg %r2, %r2, <64-arg> */
2620 0xeb, 0x22, 0x00, (unsigned char) (64 - arg
), 0x00, 0x0c,
2622 add_insns (buf
, sizeof buf
);
2625 /* The "emit_swap" emit_ops method for s390x. */
2628 s390x_emit_swap (void)
2630 static const unsigned char buf
[] = {
2631 0xe3, 0x30, 0xf0, 0x00, 0x00, 0x04, /* lg %r3, 0(%r15) */
2632 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x24, /* stg %r2, 0(%r15) */
2633 0xb9, 0x04, 0x00, 0x23, /* lgr %r2, %r3 */
2635 add_insns (buf
, sizeof buf
);
2638 /* The "emit_stack_adjust" emit_ops method for s390x. */
2641 s390x_emit_stack_adjust (int n
)
2643 unsigned char buf
[] = {
2644 /* aghi %r15, 8*n */
2646 (unsigned char) (n
* 8 >> 8), (unsigned char) (n
* 8),
2648 add_insns (buf
, sizeof buf
);
2651 /* The "emit_int_call_1" emit_ops method for s390x. */
2654 s390x_emit_int_call_1 (CORE_ADDR fn
, int arg1
)
2656 /* FN's prototype is `LONGEST(*fn)(int)'. */
2657 s390x_emit_const (arg1
);
2658 s390x_emit_call (fn
);
2661 /* The "emit_void_call_2" emit_ops method for s390x. */
2664 s390x_emit_void_call_2 (CORE_ADDR fn
, int arg1
)
2666 /* FN's prototype is `void(*fn)(int,LONGEST)'. */
2667 static const unsigned char buf
[] = {
2668 0xb9, 0x04, 0x00, 0x32, /* lgr %r3, %r2 */
2669 0xb9, 0x04, 0x00, 0xc2, /* lgr %r12, %r2 */
2671 static const unsigned char buf2
[] = {
2672 0xb9, 0x04, 0x00, 0x2c, /* lgr %r2, %r12 */
2674 add_insns (buf
, sizeof buf
);
2675 s390x_emit_const (arg1
);
2676 s390x_emit_call (fn
);
2677 add_insns (buf2
, sizeof buf2
);
2680 /* The "emit_eq_goto" emit_ops method for s390x. */
2683 s390x_emit_eq_goto (int *offset_p
, int *size_p
)
2685 static const unsigned char buf
[] = {
2686 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x20, /* cg %r2, 0(%r15) */
2687 0xe3, 0x20, 0xf0, 0x08, 0x00, 0x04, /* lg %r2, 8(%r15) */
2688 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
2689 0xc0, 0x84, 0x00, 0x00, 0x00, 0x00, /* jge <fillme> */
2691 add_insns (buf
, sizeof buf
);
2698 /* The "emit_ne_goto" emit_ops method for s390x. */
2701 s390x_emit_ne_goto (int *offset_p
, int *size_p
)
2703 static const unsigned char buf
[] = {
2704 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x20, /* cg %r2, 0(%r15) */
2705 0xe3, 0x20, 0xf0, 0x08, 0x00, 0x04, /* lg %r2, 8(%r15) */
2706 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
2707 0xc0, 0x74, 0x00, 0x00, 0x00, 0x00, /* jgne <fillme> */
2709 add_insns (buf
, sizeof buf
);
2716 /* The "emit_lt_goto" emit_ops method for s390x. */
2719 s390x_emit_lt_goto (int *offset_p
, int *size_p
)
2721 static const unsigned char buf
[] = {
2722 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x20, /* cg %r2, 0(%r15) */
2723 0xe3, 0x20, 0xf0, 0x08, 0x00, 0x04, /* lg %r2, 8(%r15) */
2724 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
2725 0xc0, 0x24, 0x00, 0x00, 0x00, 0x00, /* jgh <fillme> */
2727 add_insns (buf
, sizeof buf
);
2734 /* The "emit_le_goto" emit_ops method for s390x. */
2737 s390x_emit_le_goto (int *offset_p
, int *size_p
)
2739 static const unsigned char buf
[] = {
2740 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x20, /* cg %r2, 0(%r15) */
2741 0xe3, 0x20, 0xf0, 0x08, 0x00, 0x04, /* lg %r2, 8(%r15) */
2742 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
2743 0xc0, 0xa4, 0x00, 0x00, 0x00, 0x00, /* jghe <fillme> */
2745 add_insns (buf
, sizeof buf
);
2752 /* The "emit_gt_goto" emit_ops method for s390x. */
2755 s390x_emit_gt_goto (int *offset_p
, int *size_p
)
2757 static const unsigned char buf
[] = {
2758 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x20, /* cg %r2, 0(%r15) */
2759 0xe3, 0x20, 0xf0, 0x08, 0x00, 0x04, /* lg %r2, 8(%r15) */
2760 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
2761 0xc0, 0x44, 0x00, 0x00, 0x00, 0x00, /* jgl <fillme> */
2763 add_insns (buf
, sizeof buf
);
2770 /* The "emit_ge_goto" emit_ops method for s390x. */
2773 s390x_emit_ge_goto (int *offset_p
, int *size_p
)
2775 static const unsigned char buf
[] = {
2776 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x20, /* cg %r2, 0(%r15) */
2777 0xe3, 0x20, 0xf0, 0x08, 0x00, 0x04, /* lg %r2, 8(%r15) */
2778 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
2779 0xc0, 0xc4, 0x00, 0x00, 0x00, 0x00, /* jgle <fillme> */
2781 add_insns (buf
, sizeof buf
);
2788 /* The "emit_ops" structure for s390x. */
2790 static struct emit_ops s390x_emit_ops
=
2792 s390x_emit_prologue
,
2793 s390x_emit_epilogue
,
2798 s390x_emit_rsh_signed
,
2799 s390x_emit_rsh_unsigned
,
2807 s390x_emit_less_signed
,
2808 s390x_emit_less_unsigned
,
2812 s390_write_goto_address
,
2817 s390x_emit_stack_flush
,
2818 s390x_emit_zero_ext
,
2820 s390x_emit_stack_adjust
,
2821 s390x_emit_int_call_1
,
2822 s390x_emit_void_call_2
,
2832 /* The "emit_ops" linux_target_ops method. */
2834 static struct emit_ops
*
2835 s390_emit_ops (void)
2838 struct regcache
*regcache
= get_thread_regcache (current_thread
, 0);
2840 if (register_size (regcache
->tdesc
, 0) == 8)
2841 return &s390x_emit_ops
;
2844 return &s390_emit_ops_impl
;
2847 struct linux_target_ops the_low_target
= {
2848 NULL
, /* process_qsupported */
2849 s390_supports_tracepoints
,
2850 s390_get_thread_area
,
2851 s390_install_fast_tracepoint_jump_pad
,
2853 s390_get_min_fast_tracepoint_insn_len
,
2854 NULL
, /* supports_range_stepping */
2855 s390_supports_hardware_single_step
,
2856 NULL
, /* get_syscall_trapinfo */
2857 s390_get_ipa_tdesc_idx
,
2860 /* The linux target ops object. */
2862 linux_process_target
*the_linux_target
= &the_s390_target
;
2865 initialize_low_arch (void)
2867 /* Initialize the Linux target descriptions. */
2869 init_registers_s390_linux32 ();
2870 init_registers_s390_linux32v1 ();
2871 init_registers_s390_linux32v2 ();
2872 init_registers_s390_linux64 ();
2873 init_registers_s390_linux64v1 ();
2874 init_registers_s390_linux64v2 ();
2875 init_registers_s390_te_linux64 ();
2876 init_registers_s390_vx_linux64 ();
2877 init_registers_s390_tevx_linux64 ();
2878 init_registers_s390_gs_linux64 ();
2880 init_registers_s390x_linux64 ();
2881 init_registers_s390x_linux64v1 ();
2882 init_registers_s390x_linux64v2 ();
2883 init_registers_s390x_te_linux64 ();
2884 init_registers_s390x_vx_linux64 ();
2885 init_registers_s390x_tevx_linux64 ();
2886 init_registers_s390x_gs_linux64 ();
2889 initialize_regsets_info (&s390_regsets_info
);
2890 initialize_regsets_info (&s390_regsets_info_3264
);