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
;
64 void low_arch_setup () override
;
66 bool low_cannot_fetch_register (int regno
) override
;
68 bool low_cannot_store_register (int regno
) override
;
70 bool low_supports_breakpoints () override
;
72 CORE_ADDR
low_get_pc (regcache
*regcache
) override
;
74 void low_set_pc (regcache
*regcache
, CORE_ADDR newpc
) override
;
77 /* The singleton target ops object. */
79 static s390_target the_s390_target
;
81 static int s390_regmap
[] = {
82 PT_PSWMASK
, PT_PSWADDR
,
84 PT_GPR0
, PT_GPR1
, PT_GPR2
, PT_GPR3
,
85 PT_GPR4
, PT_GPR5
, PT_GPR6
, PT_GPR7
,
86 PT_GPR8
, PT_GPR9
, PT_GPR10
, PT_GPR11
,
87 PT_GPR12
, PT_GPR13
, PT_GPR14
, PT_GPR15
,
89 PT_ACR0
, PT_ACR1
, PT_ACR2
, PT_ACR3
,
90 PT_ACR4
, PT_ACR5
, PT_ACR6
, PT_ACR7
,
91 PT_ACR8
, PT_ACR9
, PT_ACR10
, PT_ACR11
,
92 PT_ACR12
, PT_ACR13
, PT_ACR14
, PT_ACR15
,
97 PT_FPR0_HI
, PT_FPR1_HI
, PT_FPR2_HI
, PT_FPR3_HI
,
98 PT_FPR4_HI
, PT_FPR5_HI
, PT_FPR6_HI
, PT_FPR7_HI
,
99 PT_FPR8_HI
, PT_FPR9_HI
, PT_FPR10_HI
, PT_FPR11_HI
,
100 PT_FPR12_HI
, PT_FPR13_HI
, PT_FPR14_HI
, PT_FPR15_HI
,
102 PT_FPR0
, PT_FPR1
, PT_FPR2
, PT_FPR3
,
103 PT_FPR4
, PT_FPR5
, PT_FPR6
, PT_FPR7
,
104 PT_FPR8
, PT_FPR9
, PT_FPR10
, PT_FPR11
,
105 PT_FPR12
, PT_FPR13
, PT_FPR14
, PT_FPR15
,
111 #define s390_num_regs_3264 68
114 static int s390_regmap_3264
[] = {
115 PT_PSWMASK
, PT_PSWADDR
,
117 PT_GPR0
, PT_GPR0
, PT_GPR1
, PT_GPR1
,
118 PT_GPR2
, PT_GPR2
, PT_GPR3
, PT_GPR3
,
119 PT_GPR4
, PT_GPR4
, PT_GPR5
, PT_GPR5
,
120 PT_GPR6
, PT_GPR6
, PT_GPR7
, PT_GPR7
,
121 PT_GPR8
, PT_GPR8
, PT_GPR9
, PT_GPR9
,
122 PT_GPR10
, PT_GPR10
, PT_GPR11
, PT_GPR11
,
123 PT_GPR12
, PT_GPR12
, PT_GPR13
, PT_GPR13
,
124 PT_GPR14
, PT_GPR14
, PT_GPR15
, PT_GPR15
,
126 PT_ACR0
, PT_ACR1
, PT_ACR2
, PT_ACR3
,
127 PT_ACR4
, PT_ACR5
, PT_ACR6
, PT_ACR7
,
128 PT_ACR8
, PT_ACR9
, PT_ACR10
, PT_ACR11
,
129 PT_ACR12
, PT_ACR13
, PT_ACR14
, PT_ACR15
,
133 PT_FPR0
, PT_FPR1
, PT_FPR2
, PT_FPR3
,
134 PT_FPR4
, PT_FPR5
, PT_FPR6
, PT_FPR7
,
135 PT_FPR8
, PT_FPR9
, PT_FPR10
, PT_FPR11
,
136 PT_FPR12
, PT_FPR13
, PT_FPR14
, PT_FPR15
,
141 static int s390_regmap_3264
[] = {
142 PT_PSWMASK
, PT_PSWADDR
,
144 -1, PT_GPR0
, -1, PT_GPR1
,
145 -1, PT_GPR2
, -1, PT_GPR3
,
146 -1, PT_GPR4
, -1, PT_GPR5
,
147 -1, PT_GPR6
, -1, PT_GPR7
,
148 -1, PT_GPR8
, -1, PT_GPR9
,
149 -1, PT_GPR10
, -1, PT_GPR11
,
150 -1, PT_GPR12
, -1, PT_GPR13
,
151 -1, PT_GPR14
, -1, PT_GPR15
,
153 PT_ACR0
, PT_ACR1
, PT_ACR2
, PT_ACR3
,
154 PT_ACR4
, PT_ACR5
, PT_ACR6
, PT_ACR7
,
155 PT_ACR8
, PT_ACR9
, PT_ACR10
, PT_ACR11
,
156 PT_ACR12
, PT_ACR13
, PT_ACR14
, PT_ACR15
,
160 PT_FPR0_HI
, PT_FPR1_HI
, PT_FPR2_HI
, PT_FPR3_HI
,
161 PT_FPR4_HI
, PT_FPR5_HI
, PT_FPR6_HI
, PT_FPR7_HI
,
162 PT_FPR8_HI
, PT_FPR9_HI
, PT_FPR10_HI
, PT_FPR11_HI
,
163 PT_FPR12_HI
, PT_FPR13_HI
, PT_FPR14_HI
, PT_FPR15_HI
,
171 s390_target::low_cannot_fetch_register (int regno
)
177 s390_target::low_cannot_store_register (int regno
)
183 s390_collect_ptrace_register (struct regcache
*regcache
, int regno
, char *buf
)
185 int size
= register_size (regcache
->tdesc
, regno
);
186 const struct regs_info
*regs_info
= the_linux_target
->get_regs_info ();
187 struct usrregs_info
*usr
= regs_info
->usrregs
;
188 int regaddr
= usr
->regmap
[regno
];
190 if (size
< sizeof (long))
192 memset (buf
, 0, sizeof (long));
194 if ((regno
^ 1) < usr
->num_regs
195 && usr
->regmap
[regno
^ 1] == regaddr
)
197 collect_register (regcache
, regno
& ~1, buf
);
198 collect_register (regcache
, (regno
& ~1) + 1,
199 buf
+ sizeof (long) - size
);
201 else if (regaddr
== PT_PSWMASK
)
203 /* Convert 4-byte PSW mask to 8 bytes by clearing bit 12 and copying
204 the basic addressing mode bit from the PSW address. */
205 gdb_byte
*addr
= (gdb_byte
*) alloca (register_size (regcache
->tdesc
, regno
^ 1));
206 collect_register (regcache
, regno
, buf
);
207 collect_register (regcache
, regno
^ 1, addr
);
209 buf
[size
] |= (addr
[0] & 0x80);
211 else if (regaddr
== PT_PSWADDR
)
213 /* Convert 4-byte PSW address to 8 bytes by clearing the addressing
214 mode bit (which gets copied to the PSW mask instead). */
215 collect_register (regcache
, regno
, buf
+ sizeof (long) - size
);
216 buf
[sizeof (long) - size
] &= ~0x80;
218 else if ((regaddr
>= PT_GPR0
&& regaddr
<= PT_GPR15
)
219 || regaddr
== PT_ORIGGPR2
)
220 collect_register (regcache
, regno
, buf
+ sizeof (long) - size
);
222 collect_register (regcache
, regno
, buf
);
224 else if (regaddr
!= -1)
225 collect_register (regcache
, regno
, buf
);
229 s390_supply_ptrace_register (struct regcache
*regcache
,
230 int regno
, const char *buf
)
232 int size
= register_size (regcache
->tdesc
, regno
);
233 const struct regs_info
*regs_info
= the_linux_target
->get_regs_info ();
234 struct usrregs_info
*usr
= regs_info
->usrregs
;
235 int regaddr
= usr
->regmap
[regno
];
237 if (size
< sizeof (long))
239 if ((regno
^ 1) < usr
->num_regs
240 && usr
->regmap
[regno
^ 1] == regaddr
)
242 supply_register (regcache
, regno
& ~1, buf
);
243 supply_register (regcache
, (regno
& ~1) + 1,
244 buf
+ sizeof (long) - size
);
246 else if (regaddr
== PT_PSWMASK
)
248 /* Convert 8-byte PSW mask to 4 bytes by setting bit 12 and copying
249 the basic addressing mode into the PSW address. */
250 gdb_byte
*mask
= (gdb_byte
*) alloca (size
);
251 gdb_byte
*addr
= (gdb_byte
*) alloca (register_size (regcache
->tdesc
, regno
^ 1));
252 memcpy (mask
, buf
, size
);
254 supply_register (regcache
, regno
, mask
);
256 collect_register (regcache
, regno
^ 1, addr
);
258 addr
[0] |= (buf
[size
] & 0x80);
259 supply_register (regcache
, regno
^ 1, addr
);
261 else if (regaddr
== PT_PSWADDR
)
263 /* Convert 8-byte PSW address to 4 bytes by truncating, but
264 keeping the addressing mode bit (which was set from the mask). */
265 gdb_byte
*addr
= (gdb_byte
*) alloca (size
);
267 collect_register (regcache
, regno
, addr
);
268 amode
= addr
[0] & 0x80;
269 memcpy (addr
, buf
+ sizeof (long) - size
, size
);
272 supply_register (regcache
, regno
, addr
);
274 else if ((regaddr
>= PT_GPR0
&& regaddr
<= PT_GPR15
)
275 || regaddr
== PT_ORIGGPR2
)
276 supply_register (regcache
, regno
, buf
+ sizeof (long) - size
);
278 supply_register (regcache
, regno
, buf
);
280 else if (regaddr
!= -1)
281 supply_register (regcache
, regno
, buf
);
284 /* Provide only a fill function for the general register set. ps_lgetregs
285 will use this for NPTL support. */
288 s390_fill_gregset (struct regcache
*regcache
, void *buf
)
291 const struct regs_info
*regs_info
= the_linux_target
->get_regs_info ();
292 struct usrregs_info
*usr
= regs_info
->usrregs
;
294 for (i
= 0; i
< usr
->num_regs
; i
++)
296 if (usr
->regmap
[i
] < PT_PSWMASK
297 || usr
->regmap
[i
] > PT_ACR15
)
300 s390_collect_ptrace_register (regcache
, i
,
301 (char *) buf
+ usr
->regmap
[i
]);
305 /* Fill and store functions for extended register sets. */
309 s390_fill_gprs_high (struct regcache
*regcache
, void *buf
)
311 int r0h
= find_regno (regcache
->tdesc
, "r0h");
314 for (i
= 0; i
< 16; i
++)
315 collect_register (regcache
, r0h
+ 2 * i
, (char *) buf
+ 4 * i
);
319 s390_store_gprs_high (struct regcache
*regcache
, const void *buf
)
321 int r0h
= find_regno (regcache
->tdesc
, "r0h");
324 for (i
= 0; i
< 16; i
++)
325 supply_register (regcache
, r0h
+ 2 * i
, (const char *) buf
+ 4 * i
);
330 s390_store_last_break (struct regcache
*regcache
, const void *buf
)
334 p
= (const char *) buf
+ 8 - register_size (regcache
->tdesc
, 0);
335 supply_register_by_name (regcache
, "last_break", p
);
339 s390_fill_system_call (struct regcache
*regcache
, void *buf
)
341 collect_register_by_name (regcache
, "system_call", buf
);
345 s390_store_system_call (struct regcache
*regcache
, const void *buf
)
347 supply_register_by_name (regcache
, "system_call", buf
);
351 s390_store_tdb (struct regcache
*regcache
, const void *buf
)
353 int tdb0
= find_regno (regcache
->tdesc
, "tdb0");
354 int tr0
= find_regno (regcache
->tdesc
, "tr0");
357 for (i
= 0; i
< 4; i
++)
358 supply_register (regcache
, tdb0
+ i
, (const char *) buf
+ 8 * i
);
360 for (i
= 0; i
< 16; i
++)
361 supply_register (regcache
, tr0
+ i
, (const char *) buf
+ 8 * (16 + i
));
365 s390_fill_vxrs_low (struct regcache
*regcache
, void *buf
)
367 int v0
= find_regno (regcache
->tdesc
, "v0l");
370 for (i
= 0; i
< 16; i
++)
371 collect_register (regcache
, v0
+ i
, (char *) buf
+ 8 * i
);
375 s390_store_vxrs_low (struct regcache
*regcache
, const void *buf
)
377 int v0
= find_regno (regcache
->tdesc
, "v0l");
380 for (i
= 0; i
< 16; i
++)
381 supply_register (regcache
, v0
+ i
, (const char *) buf
+ 8 * i
);
385 s390_fill_vxrs_high (struct regcache
*regcache
, void *buf
)
387 int v16
= find_regno (regcache
->tdesc
, "v16");
390 for (i
= 0; i
< 16; i
++)
391 collect_register (regcache
, v16
+ i
, (char *) buf
+ 16 * i
);
395 s390_store_vxrs_high (struct regcache
*regcache
, const void *buf
)
397 int v16
= find_regno (regcache
->tdesc
, "v16");
400 for (i
= 0; i
< 16; i
++)
401 supply_register (regcache
, v16
+ i
, (const char *) buf
+ 16 * i
);
405 s390_store_gs (struct regcache
*regcache
, const void *buf
)
407 int gsd
= find_regno (regcache
->tdesc
, "gsd");
410 for (i
= 0; i
< 3; i
++)
411 supply_register (regcache
, gsd
+ i
, (const char *) buf
+ 8 * (i
+ 1));
415 s390_store_gsbc (struct regcache
*regcache
, const void *buf
)
417 int bc_gsd
= find_regno (regcache
->tdesc
, "bc_gsd");
420 for (i
= 0; i
< 3; i
++)
421 supply_register (regcache
, bc_gsd
+ i
, (const char *) buf
+ 8 * (i
+ 1));
424 static struct regset_info s390_regsets
[] = {
425 { 0, 0, 0, 0, GENERAL_REGS
, s390_fill_gregset
, NULL
},
427 { PTRACE_GETREGSET
, PTRACE_SETREGSET
, NT_S390_HIGH_GPRS
, 0,
428 EXTENDED_REGS
, s390_fill_gprs_high
, s390_store_gprs_high
},
430 /* Last break address is read-only; no fill function. */
431 { PTRACE_GETREGSET
, -1, NT_S390_LAST_BREAK
, 0, EXTENDED_REGS
,
432 NULL
, s390_store_last_break
},
433 { PTRACE_GETREGSET
, PTRACE_SETREGSET
, NT_S390_SYSTEM_CALL
, 0,
434 EXTENDED_REGS
, s390_fill_system_call
, s390_store_system_call
},
435 /* TDB is read-only. */
436 { PTRACE_GETREGSET
, -1, NT_S390_TDB
, 0, EXTENDED_REGS
,
437 NULL
, s390_store_tdb
},
438 { PTRACE_GETREGSET
, PTRACE_SETREGSET
, NT_S390_VXRS_LOW
, 0,
439 EXTENDED_REGS
, s390_fill_vxrs_low
, s390_store_vxrs_low
},
440 { PTRACE_GETREGSET
, PTRACE_SETREGSET
, NT_S390_VXRS_HIGH
, 0,
441 EXTENDED_REGS
, s390_fill_vxrs_high
, s390_store_vxrs_high
},
442 /* Guarded storage registers are read-only. */
443 { PTRACE_GETREGSET
, -1, NT_S390_GS_CB
, 0, EXTENDED_REGS
,
444 NULL
, s390_store_gs
},
445 { PTRACE_GETREGSET
, -1, NT_S390_GS_BC
, 0, EXTENDED_REGS
,
446 NULL
, s390_store_gsbc
},
451 static const gdb_byte s390_breakpoint
[] = { 0, 1 };
452 #define s390_breakpoint_len 2
454 /* Implementation of linux_target_ops method "sw_breakpoint_from_kind". */
456 static const gdb_byte
*
457 s390_sw_breakpoint_from_kind (int kind
, int *size
)
459 *size
= s390_breakpoint_len
;
460 return s390_breakpoint
;
464 s390_target::low_supports_breakpoints ()
470 s390_target::low_get_pc (regcache
*regcache
)
472 if (register_size (regcache
->tdesc
, 0) == 4)
475 collect_register_by_name (regcache
, "pswa", &pswa
);
476 return pswa
& 0x7fffffff;
481 collect_register_by_name (regcache
, "pswa", &pc
);
487 s390_target::low_set_pc (regcache
*regcache
, CORE_ADDR newpc
)
489 if (register_size (regcache
->tdesc
, 0) == 4)
492 collect_register_by_name (regcache
, "pswa", &pswa
);
493 pswa
= (pswa
& 0x80000000) | (newpc
& 0x7fffffff);
494 supply_register_by_name (regcache
, "pswa", &pswa
);
498 unsigned long pc
= newpc
;
499 supply_register_by_name (regcache
, "pswa", &pc
);
503 /* Determine the word size for the given PID, in bytes. */
507 s390_get_wordsize (int pid
)
510 PTRACE_XFER_TYPE pswm
= ptrace (PTRACE_PEEKUSER
, pid
,
511 (PTRACE_TYPE_ARG3
) 0,
512 (PTRACE_TYPE_ARG4
) 0);
515 warning (_("Couldn't determine word size, assuming 64-bit."));
518 /* Derive word size from extended addressing mode (PSW bit 31). */
519 return pswm
& (1L << 32) ? 8 : 4;
522 #define s390_get_wordsize(pid) 4
526 s390_check_regset (int pid
, int regset
, int regsize
)
528 void *buf
= alloca (regsize
);
532 iov
.iov_len
= regsize
;
534 if (ptrace (PTRACE_GETREGSET
, pid
, (long) regset
, (long) &iov
) >= 0
540 /* For a 31-bit inferior, whether the kernel supports using the full
542 static int have_hwcap_s390_high_gprs
= 0;
543 static int have_hwcap_s390_vx
= 0;
546 s390_target::low_arch_setup ()
548 const struct target_desc
*tdesc
;
549 struct regset_info
*regset
;
551 /* Determine word size and HWCAP. */
552 int pid
= pid_of (current_thread
);
553 int wordsize
= s390_get_wordsize (pid
);
554 unsigned long hwcap
= linux_get_hwcap (wordsize
);
556 /* Check whether the kernel supports extra register sets. */
557 int have_regset_last_break
558 = s390_check_regset (pid
, NT_S390_LAST_BREAK
, 8);
559 int have_regset_system_call
560 = s390_check_regset (pid
, NT_S390_SYSTEM_CALL
, 4);
562 = (s390_check_regset (pid
, NT_S390_TDB
, 256)
563 && (hwcap
& HWCAP_S390_TE
) != 0);
565 = (s390_check_regset (pid
, NT_S390_VXRS_LOW
, 128)
566 && s390_check_regset (pid
, NT_S390_VXRS_HIGH
, 256)
567 && (hwcap
& HWCAP_S390_VX
) != 0);
569 = (s390_check_regset (pid
, NT_S390_GS_CB
, 32)
570 && s390_check_regset (pid
, NT_S390_GS_BC
, 32)
571 && (hwcap
& HWCAP_S390_GS
) != 0);
578 tdesc
= tdesc_s390x_gs_linux64
;
579 else if (have_regset_vxrs
)
580 tdesc
= (have_regset_tdb
? tdesc_s390x_tevx_linux64
:
581 tdesc_s390x_vx_linux64
);
582 else if (have_regset_tdb
)
583 tdesc
= tdesc_s390x_te_linux64
;
584 else if (have_regset_system_call
)
585 tdesc
= tdesc_s390x_linux64v2
;
586 else if (have_regset_last_break
)
587 tdesc
= tdesc_s390x_linux64v1
;
589 tdesc
= tdesc_s390x_linux64
;
592 /* For a 31-bit inferior, check whether the kernel supports
593 using the full 64-bit GPRs. */
596 if (hwcap
& HWCAP_S390_HIGH_GPRS
)
598 have_hwcap_s390_high_gprs
= 1;
600 tdesc
= tdesc_s390_gs_linux64
;
601 else if (have_regset_vxrs
)
602 tdesc
= (have_regset_tdb
? tdesc_s390_tevx_linux64
:
603 tdesc_s390_vx_linux64
);
604 else if (have_regset_tdb
)
605 tdesc
= tdesc_s390_te_linux64
;
606 else if (have_regset_system_call
)
607 tdesc
= tdesc_s390_linux64v2
;
608 else if (have_regset_last_break
)
609 tdesc
= tdesc_s390_linux64v1
;
611 tdesc
= tdesc_s390_linux64
;
615 /* Assume 31-bit inferior process. */
616 if (have_regset_system_call
)
617 tdesc
= tdesc_s390_linux32v2
;
618 else if (have_regset_last_break
)
619 tdesc
= tdesc_s390_linux32v1
;
621 tdesc
= tdesc_s390_linux32
;
624 have_hwcap_s390_vx
= have_regset_vxrs
;
627 /* Update target_regsets according to available register sets. */
628 for (regset
= s390_regsets
; regset
->size
>= 0; regset
++)
629 if (regset
->get_request
== PTRACE_GETREGSET
)
630 switch (regset
->nt_type
)
633 case NT_S390_HIGH_GPRS
:
634 regset
->size
= have_hwcap_s390_high_gprs
? 64 : 0;
637 case NT_S390_LAST_BREAK
:
638 regset
->size
= have_regset_last_break
? 8 : 0;
640 case NT_S390_SYSTEM_CALL
:
641 regset
->size
= have_regset_system_call
? 4 : 0;
644 regset
->size
= have_regset_tdb
? 256 : 0;
646 case NT_S390_VXRS_LOW
:
647 regset
->size
= have_regset_vxrs
? 128 : 0;
649 case NT_S390_VXRS_HIGH
:
650 regset
->size
= have_regset_vxrs
? 256 : 0;
654 regset
->size
= have_regset_gs
? 32 : 0;
659 current_process ()->tdesc
= tdesc
;
664 s390_breakpoint_at (CORE_ADDR pc
)
666 unsigned char c
[s390_breakpoint_len
];
667 read_inferior_memory (pc
, c
, s390_breakpoint_len
);
668 return memcmp (c
, s390_breakpoint
, s390_breakpoint_len
) == 0;
671 /* Breakpoint/Watchpoint support. */
673 /* The "supports_z_point_type" linux_target_ops method. */
676 s390_supports_z_point_type (char z_type
)
687 /* Support for hardware single step. */
690 s390_supports_hardware_single_step (void)
695 static struct usrregs_info s390_usrregs_info
=
701 static struct regsets_info s390_regsets_info
=
703 s390_regsets
, /* regsets */
705 NULL
, /* disabled_regsets */
708 static struct regs_info myregs_info
=
710 NULL
, /* regset_bitmap */
715 static struct usrregs_info s390_usrregs_info_3264
=
721 static struct regsets_info s390_regsets_info_3264
=
723 s390_regsets
, /* regsets */
725 NULL
, /* disabled_regsets */
728 static struct regs_info regs_info_3264
=
730 NULL
, /* regset_bitmap */
731 &s390_usrregs_info_3264
,
732 &s390_regsets_info_3264
736 s390_target::get_regs_info ()
738 if (have_hwcap_s390_high_gprs
)
741 const struct target_desc
*tdesc
= current_process ()->tdesc
;
743 if (register_size (tdesc
, 0) == 4)
744 return ®s_info_3264
;
746 return ®s_info_3264
;
752 /* The "supports_tracepoints" linux_target_ops method. */
755 s390_supports_tracepoints (void)
760 /* Implementation of linux_target_ops method "get_thread_area". */
763 s390_get_thread_area (int lwpid
, CORE_ADDR
*addrp
)
765 CORE_ADDR res
= ptrace (PTRACE_PEEKUSER
, lwpid
, (long) PT_ACR0
, (long) 0);
767 struct regcache
*regcache
= get_thread_regcache (current_thread
, 0);
769 if (register_size (regcache
->tdesc
, 0) == 4)
770 res
&= 0xffffffffull
;
777 /* Fast tracepoint support.
779 The register save area on stack is identical for all targets:
781 0x000+i*0x10: VR0-VR31
788 If we're on 31-bit linux, we just don't store the high parts of the GPRs.
789 Likewise, if there's no VX support, we just store the FRs into the slots
790 of low VR halves. The agent code is responsible for rearranging that
793 /* Code sequence saving GPRs for 31-bit target with no high GPRs. There's
794 one trick used at the very beginning: since there's no way to allocate
795 stack space without destroying CC (lay instruction can do it, but it's
796 only supported on later CPUs), we take 4 different execution paths for
797 every possible value of CC, allocate stack space, save %r0, stuff the
798 CC value in %r0 (shifted to match its position in PSWM high word),
799 then branch to common path. */
801 static const unsigned char s390_ft_entry_gpr_esa
[] = {
802 0xa7, 0x14, 0x00, 0x1e, /* jo .Lcc3 */
803 0xa7, 0x24, 0x00, 0x14, /* jh .Lcc2 */
804 0xa7, 0x44, 0x00, 0x0a, /* jl .Lcc1 */
806 0xa7, 0xfa, 0xfd, 0x00, /* ahi %r15, -0x300 */
807 0x50, 0x00, 0xf2, 0x04, /* st %r0, 0x204(%r15) */
808 0xa7, 0x08, 0x00, 0x00, /* lhi %r0, 0 */
809 0xa7, 0xf4, 0x00, 0x18, /* j .Lccdone */
811 0xa7, 0xfa, 0xfd, 0x00, /* ahi %r15, -0x300 */
812 0x50, 0x00, 0xf2, 0x04, /* st %r0, 0x204(%r15) */
813 0xa7, 0x08, 0x10, 0x00, /* lhi %r0, 0x1000 */
814 0xa7, 0xf4, 0x00, 0x10, /* j .Lccdone */
816 0xa7, 0xfa, 0xfd, 0x00, /* ahi %r15, -0x300 */
817 0x50, 0x00, 0xf2, 0x04, /* st %r0, 0x204(%r15) */
818 0xa7, 0x08, 0x20, 0x00, /* lhi %r0, 0x2000 */
819 0xa7, 0xf4, 0x00, 0x08, /* j .Lccdone */
821 0xa7, 0xfa, 0xfd, 0x00, /* ahi %r15, -0x300 */
822 0x50, 0x00, 0xf2, 0x04, /* st %r0, 0x204(%r15) */
823 0xa7, 0x08, 0x30, 0x00, /* lhi %r0, 0x3000 */
825 0x50, 0x10, 0xf2, 0x0c, /* st %r1, 0x20c(%r15) */
826 0x50, 0x20, 0xf2, 0x14, /* st %r2, 0x214(%r15) */
827 0x50, 0x30, 0xf2, 0x1c, /* st %r3, 0x21c(%r15) */
828 0x50, 0x40, 0xf2, 0x24, /* st %r4, 0x224(%r15) */
829 0x50, 0x50, 0xf2, 0x2c, /* st %r5, 0x22c(%r15) */
830 0x50, 0x60, 0xf2, 0x34, /* st %r6, 0x234(%r15) */
831 0x50, 0x70, 0xf2, 0x3c, /* st %r7, 0x23c(%r15) */
832 0x50, 0x80, 0xf2, 0x44, /* st %r8, 0x244(%r15) */
833 0x50, 0x90, 0xf2, 0x4c, /* st %r9, 0x24c(%r15) */
834 0x50, 0xa0, 0xf2, 0x54, /* st %r10, 0x254(%r15) */
835 0x50, 0xb0, 0xf2, 0x5c, /* st %r11, 0x25c(%r15) */
836 0x50, 0xc0, 0xf2, 0x64, /* st %r12, 0x264(%r15) */
837 0x50, 0xd0, 0xf2, 0x6c, /* st %r13, 0x26c(%r15) */
838 0x50, 0xe0, 0xf2, 0x74, /* st %r14, 0x274(%r15) */
839 /* Compute original value of %r15 and store it. We use ahi instead
840 of la to preserve the whole value, and not just the low 31 bits.
841 This is not particularly important here, but essential in the
842 zarch case where someone might be using the high word of %r15
843 as an extra register. */
844 0x18, 0x1f, /* lr %r1, %r15 */
845 0xa7, 0x1a, 0x03, 0x00, /* ahi %r1, 0x300 */
846 0x50, 0x10, 0xf2, 0x7c, /* st %r1, 0x27c(%r15) */
849 /* Code sequence saving GPRs for 31-bit target with high GPRs and for 64-bit
850 target. Same as above, except this time we can use load/store multiple,
851 since the 64-bit regs are tightly packed. */
853 static const unsigned char s390_ft_entry_gpr_zarch
[] = {
854 0xa7, 0x14, 0x00, 0x21, /* jo .Lcc3 */
855 0xa7, 0x24, 0x00, 0x16, /* jh .Lcc2 */
856 0xa7, 0x44, 0x00, 0x0b, /* jl .Lcc1 */
858 0xa7, 0xfb, 0xfd, 0x00, /* aghi %r15, -0x300 */
859 0xeb, 0x0e, 0xf2, 0x00, 0x00, 0x24, /* stmg %r0, %r14, 0x200(%r15) */
860 0xa7, 0x08, 0x00, 0x00, /* lhi %r0, 0 */
861 0xa7, 0xf4, 0x00, 0x1b, /* j .Lccdone */
863 0xa7, 0xfb, 0xfd, 0x00, /* aghi %r15, -0x300 */
864 0xeb, 0x0e, 0xf2, 0x00, 0x00, 0x24, /* stmg %r0, %r14, 0x200(%r15) */
865 0xa7, 0x08, 0x10, 0x00, /* lhi %r0, 0x1000 */
866 0xa7, 0xf4, 0x00, 0x12, /* j .Lccdone */
868 0xa7, 0xfb, 0xfd, 0x00, /* aghi %r15, -0x300 */
869 0xeb, 0x0e, 0xf2, 0x00, 0x00, 0x24, /* stmg %r0, %r14, 0x200(%r15) */
870 0xa7, 0x08, 0x20, 0x00, /* lhi %r0, 0x2000 */
871 0xa7, 0xf4, 0x00, 0x09, /* j .Lccdone */
873 0xa7, 0xfb, 0xfd, 0x00, /* aghi %r15, -0x300 */
874 0xeb, 0x0e, 0xf2, 0x00, 0x00, 0x24, /* stmg %r0, %r14, 0x200(%r15) */
875 0xa7, 0x08, 0x30, 0x00, /* lhi %r0, 0x3000 */
877 0xb9, 0x04, 0x00, 0x1f, /* lgr %r1, %r15 */
878 0xa7, 0x1b, 0x03, 0x00, /* aghi %r1, 0x300 */
879 0xe3, 0x10, 0xf2, 0x78, 0x00, 0x24, /* stg %r1, 0x278(%r15) */
882 /* Code sequence saving ARs, PSWM and FPC. PSWM has to be assembled from
883 current PSWM (read by epsw) and CC from entry (in %r0). */
885 static const unsigned char s390_ft_entry_misc
[] = {
886 0x9b, 0x0f, 0xf2, 0x80, /* stam %a0, %a15, 0x20(%%r15) */
887 0xb9, 0x8d, 0x00, 0x23, /* epsw %r2, %r3 */
888 0xa7, 0x18, 0xcf, 0xff, /* lhi %r1, ~0x3000 */
889 0x14, 0x21, /* nr %r2, %r1 */
890 0x16, 0x20, /* or %r2, %r0 */
891 0x50, 0x20, 0xf2, 0xc0, /* st %r2, 0x2c0(%r15) */
892 0x50, 0x30, 0xf2, 0xc4, /* st %r3, 0x2c4(%r15) */
893 0xb2, 0x9c, 0xf2, 0xd0, /* stfpc 0x2d0(%r15) */
896 /* Code sequence saving FRs, used if VX not supported. */
898 static const unsigned char s390_ft_entry_fr
[] = {
899 0x60, 0x00, 0xf0, 0x00, /* std %f0, 0x000(%r15) */
900 0x60, 0x10, 0xf0, 0x10, /* std %f1, 0x010(%r15) */
901 0x60, 0x20, 0xf0, 0x20, /* std %f2, 0x020(%r15) */
902 0x60, 0x30, 0xf0, 0x30, /* std %f3, 0x030(%r15) */
903 0x60, 0x40, 0xf0, 0x40, /* std %f4, 0x040(%r15) */
904 0x60, 0x50, 0xf0, 0x50, /* std %f5, 0x050(%r15) */
905 0x60, 0x60, 0xf0, 0x60, /* std %f6, 0x060(%r15) */
906 0x60, 0x70, 0xf0, 0x70, /* std %f7, 0x070(%r15) */
907 0x60, 0x80, 0xf0, 0x80, /* std %f8, 0x080(%r15) */
908 0x60, 0x90, 0xf0, 0x90, /* std %f9, 0x090(%r15) */
909 0x60, 0xa0, 0xf0, 0xa0, /* std %f10, 0x0a0(%r15) */
910 0x60, 0xb0, 0xf0, 0xb0, /* std %f11, 0x0b0(%r15) */
911 0x60, 0xc0, 0xf0, 0xc0, /* std %f12, 0x0c0(%r15) */
912 0x60, 0xd0, 0xf0, 0xd0, /* std %f13, 0x0d0(%r15) */
913 0x60, 0xe0, 0xf0, 0xe0, /* std %f14, 0x0e0(%r15) */
914 0x60, 0xf0, 0xf0, 0xf0, /* std %f15, 0x0f0(%r15) */
917 /* Code sequence saving VRs, used if VX not supported. */
919 static const unsigned char s390_ft_entry_vr
[] = {
920 0xe7, 0x0f, 0xf0, 0x00, 0x00, 0x3e, /* vstm %v0, %v15, 0x000(%r15) */
921 0xe7, 0x0f, 0xf1, 0x00, 0x0c, 0x3e, /* vstm %v16, %v31, 0x100(%r15) */
924 /* Code sequence doing the collection call for 31-bit target. %r1 contains
925 the address of the literal pool. */
927 static const unsigned char s390_ft_main_31
[] = {
928 /* Load the literals into registers. */
929 0x58, 0x50, 0x10, 0x00, /* l %r5, 0x0(%r1) */
930 0x58, 0x20, 0x10, 0x04, /* l %r2, 0x4(%r1) */
931 0x58, 0x40, 0x10, 0x08, /* l %r4, 0x8(%r1) */
932 0x58, 0x60, 0x10, 0x0c, /* l %r6, 0xc(%r1) */
933 /* Save original PSWA (tracepoint address | 0x80000000). */
934 0x50, 0x50, 0xf2, 0xcc, /* st %r5, 0x2cc(%r15) */
935 /* Construct a collecting_t object at %r15+0x2e0. */
936 0x50, 0x20, 0xf2, 0xe0, /* st %r2, 0x2e0(%r15) */
937 0x9b, 0x00, 0xf2, 0xe4, /* stam %a0, %a0, 0x2e4(%r15) */
938 /* Move its address to %r0. */
939 0x41, 0x00, 0xf2, 0xe0, /* la %r0, 0x2e0(%r15) */
942 0xa7, 0x18, 0x00, 0x00, /* lhi %r1, 0 */
943 0xba, 0x10, 0x60, 0x00, /* cs %r1, %r0, 0(%r6) */
944 0xa7, 0x74, 0xff, 0xfc, /* jne .Lloop */
945 /* Address of the register save block to %r3. */
946 0x18, 0x3f, /* lr %r3, %r15 */
947 /* Make a stack frame, so that we can call the collector. */
948 0xa7, 0xfa, 0xff, 0xa0, /* ahi %r15, -0x60 */
950 0x0d, 0xe4, /* basr %r14, %r4 */
951 /* And get rid of the stack frame again. */
952 0x41, 0xf0, 0xf0, 0x60, /* la %r15, 0x60(%r15) */
953 /* Leave the lock. */
954 0x07, 0xf0, /* br %r0 */
955 0xa7, 0x18, 0x00, 0x00, /* lhi %r1, 0 */
956 0x50, 0x10, 0x60, 0x00, /* st %t1, 0(%r6) */
959 /* Code sequence doing the collection call for 64-bit target. %r1 contains
960 the address of the literal pool. */
962 static const unsigned char s390_ft_main_64
[] = {
963 /* Load the literals into registers. */
964 0xe3, 0x50, 0x10, 0x00, 0x00, 0x04, /* lg %r5, 0x00(%r1) */
965 0xe3, 0x20, 0x10, 0x08, 0x00, 0x04, /* lg %r2, 0x08(%r1) */
966 0xe3, 0x40, 0x10, 0x10, 0x00, 0x04, /* lg %r4, 0x10(%r1) */
967 0xe3, 0x60, 0x10, 0x18, 0x00, 0x04, /* lg %r6, 0x18(%r1) */
968 /* Save original PSWA (tracepoint address). */
969 0xe3, 0x50, 0xf2, 0xc8, 0x00, 0x24, /* stg %r5, 0x2c8(%r15) */
970 /* Construct a collecting_t object at %r15+0x2e0. */
971 0xe3, 0x20, 0xf2, 0xe0, 0x00, 0x24, /* stg %r2, 0x2e0(%r15) */
972 0x9b, 0x01, 0xf2, 0xe8, /* stam %a0, %a1, 0x2e8(%r15) */
973 /* Move its address to %r0. */
974 0x41, 0x00, 0xf2, 0xe0, /* la %r0, 0x2e0(%r15) */
977 0xa7, 0x19, 0x00, 0x00, /* lghi %r1, 0 */
978 0xeb, 0x10, 0x60, 0x00, 0x00, 0x30, /* csg %r1, %r0, 0(%r6) */
979 0xa7, 0x74, 0xff, 0xfb, /* jne .Lloop */
980 /* Address of the register save block to %r3. */
981 0xb9, 0x04, 0x00, 0x3f, /* lgr %r3, %r15 */
982 /* Make a stack frame, so that we can call the collector. */
983 0xa7, 0xfb, 0xff, 0x60, /* aghi %r15, -0xa0 */
985 0x0d, 0xe4, /* basr %r14, %r4 */
986 /* And get rid of the stack frame again. */
987 0x41, 0xf0, 0xf0, 0xa0, /* la %r15, 0xa0(%r15) */
988 /* Leave the lock. */
989 0x07, 0xf0, /* br %r0 */
990 0xa7, 0x19, 0x00, 0x00, /* lghi %r1, 0 */
991 0xe3, 0x10, 0x60, 0x00, 0x00, 0x24, /* stg %t1, 0(%r6) */
994 /* Code sequence restoring FRs, for targets with no VX support. */
996 static const unsigned char s390_ft_exit_fr
[] = {
997 0x68, 0x00, 0xf0, 0x00, /* ld %f0, 0x000(%r15) */
998 0x68, 0x10, 0xf0, 0x10, /* ld %f1, 0x010(%r15) */
999 0x68, 0x20, 0xf0, 0x20, /* ld %f2, 0x020(%r15) */
1000 0x68, 0x30, 0xf0, 0x30, /* ld %f3, 0x030(%r15) */
1001 0x68, 0x40, 0xf0, 0x40, /* ld %f4, 0x040(%r15) */
1002 0x68, 0x50, 0xf0, 0x50, /* ld %f5, 0x050(%r15) */
1003 0x68, 0x60, 0xf0, 0x60, /* ld %f6, 0x060(%r15) */
1004 0x68, 0x70, 0xf0, 0x70, /* ld %f7, 0x070(%r15) */
1005 0x68, 0x80, 0xf0, 0x80, /* ld %f8, 0x080(%r15) */
1006 0x68, 0x90, 0xf0, 0x90, /* ld %f9, 0x090(%r15) */
1007 0x68, 0xa0, 0xf0, 0xa0, /* ld %f10, 0x0a0(%r15) */
1008 0x68, 0xb0, 0xf0, 0xb0, /* ld %f11, 0x0b0(%r15) */
1009 0x68, 0xc0, 0xf0, 0xc0, /* ld %f12, 0x0c0(%r15) */
1010 0x68, 0xd0, 0xf0, 0xd0, /* ld %f13, 0x0d0(%r15) */
1011 0x68, 0xe0, 0xf0, 0xe0, /* ld %f14, 0x0e0(%r15) */
1012 0x68, 0xf0, 0xf0, 0xf0, /* ld %f15, 0x0f0(%r15) */
1015 /* Code sequence restoring VRs. */
1017 static const unsigned char s390_ft_exit_vr
[] = {
1018 0xe7, 0x0f, 0xf0, 0x00, 0x00, 0x36, /* vlm %v0, %v15, 0x000(%r15) */
1019 0xe7, 0x0f, 0xf1, 0x00, 0x0c, 0x36, /* vlm %v16, %v31, 0x100(%r15) */
1022 /* Code sequence restoring misc registers. As for PSWM, only CC should be
1023 modified by C code, so we use the alr instruction to restore it by
1024 manufacturing an operand that'll result in the original flags. */
1026 static const unsigned char s390_ft_exit_misc
[] = {
1027 0xb2, 0x9d, 0xf2, 0xd0, /* lfpc 0x2d0(%r15) */
1028 0x58, 0x00, 0xf2, 0xc0, /* l %r0, 0x2c0(%r15) */
1029 /* Extract CC to high 2 bits of %r0. */
1030 0x88, 0x00, 0x00, 0x0c, /* srl %r0, 12 */
1031 0x89, 0x00, 0x00, 0x1e, /* sll %r0, 30 */
1032 /* Add %r0 to itself. Result will be nonzero iff CC bit 0 is set, and
1033 will have carry iff CC bit 1 is set - resulting in the same flags
1035 0x1e, 0x00, /* alr %r0, %r0 */
1036 0x9a, 0x0f, 0xf2, 0x80, /* lam %a0, %a15, 0x280(%r15) */
1039 /* Code sequence restoring GPRs, for 31-bit targets with no high GPRs. */
1041 static const unsigned char s390_ft_exit_gpr_esa
[] = {
1042 0x58, 0x00, 0xf2, 0x04, /* l %r0, 0x204(%r15) */
1043 0x58, 0x10, 0xf2, 0x0c, /* l %r1, 0x20c(%r15) */
1044 0x58, 0x20, 0xf2, 0x14, /* l %r2, 0x214(%r15) */
1045 0x58, 0x30, 0xf2, 0x1c, /* l %r3, 0x21c(%r15) */
1046 0x58, 0x40, 0xf2, 0x24, /* l %r4, 0x224(%r15) */
1047 0x58, 0x50, 0xf2, 0x2c, /* l %r5, 0x22c(%r15) */
1048 0x58, 0x60, 0xf2, 0x34, /* l %r6, 0x234(%r15) */
1049 0x58, 0x70, 0xf2, 0x3c, /* l %r7, 0x23c(%r15) */
1050 0x58, 0x80, 0xf2, 0x44, /* l %r8, 0x244(%r15) */
1051 0x58, 0x90, 0xf2, 0x4c, /* l %r9, 0x24c(%r15) */
1052 0x58, 0xa0, 0xf2, 0x54, /* l %r10, 0x254(%r15) */
1053 0x58, 0xb0, 0xf2, 0x5c, /* l %r11, 0x25c(%r15) */
1054 0x58, 0xc0, 0xf2, 0x64, /* l %r12, 0x264(%r15) */
1055 0x58, 0xd0, 0xf2, 0x6c, /* l %r13, 0x26c(%r15) */
1056 0x58, 0xe0, 0xf2, 0x74, /* l %r14, 0x274(%r15) */
1057 0x58, 0xf0, 0xf2, 0x7c, /* l %r15, 0x27c(%r15) */
1060 /* Code sequence restoring GPRs, for 64-bit targets and 31-bit targets
1063 static const unsigned char s390_ft_exit_gpr_zarch
[] = {
1064 0xeb, 0x0f, 0xf2, 0x00, 0x00, 0x04, /* lmg %r0, %r15, 0x200(%r15) */
1067 /* Writes instructions to target, updating the to pointer. */
1070 append_insns (CORE_ADDR
*to
, size_t len
, const unsigned char *buf
)
1072 target_write_memory (*to
, buf
, len
);
1076 /* Relocates an instruction from oldloc to *to, updating to. */
1079 s390_relocate_instruction (CORE_ADDR
*to
, CORE_ADDR oldloc
, int is_64
)
1084 /* 0: no fixup, 1: PC16DBL fixup, 2: PC32DBL fixup. */
1087 read_inferior_memory (oldloc
, buf
, sizeof buf
);
1090 else if (buf
[0] < 0xc0)
1096 case 0x05: /* BALR */
1097 case 0x0c: /* BASSM */
1098 case 0x0d: /* BASR */
1099 case 0x45: /* BAL */
1100 case 0x4d: /* BAS */
1101 /* These save a return address and mess around with registers.
1102 We can't relocate them. */
1104 case 0x84: /* BRXH */
1105 case 0x85: /* BRXLE */
1110 /* BRC, BRAS, BRCT, BRCTG */
1111 if (op2
>= 4 && op2
<= 7)
1119 /* LARL, BRCL, BRASL */
1120 if (op2
== 0 || op2
== 4 || op2
== 5)
1128 /* PC-relative addressing instructions. */
1131 case 0xc5: /* BPRP */
1132 case 0xc7: /* BPP */
1133 /* Branch prediction - just skip it. */
1145 case 0x44: /* BRXHG */
1146 case 0x45: /* BRXLG */
1147 case 0x64: /* CGRJ */
1148 case 0x65: /* CLGRJ */
1149 case 0x76: /* CRJ */
1150 case 0x77: /* CLRJ */
1159 /* We'll have to relocate an instruction with a PC-relative field.
1160 First, compute the target. */
1161 int64_t loffset
= 0;
1165 int16_t soffset
= 0;
1166 memcpy (&soffset
, buf
+ 2, 2);
1171 int32_t soffset
= 0;
1172 memcpy (&soffset
, buf
+ 2, 4);
1175 target
= oldloc
+ loffset
* 2;
1177 target
&= 0x7fffffff;
1181 /* BRAS or BRASL was used. We cannot just relocate those, since
1182 they save the return address in a register. We can, however,
1183 replace them with a LARL+JG sequence. */
1185 /* Make the LARL. */
1189 loffset
= oldloc
+ ilen
- *to
;
1192 if (soffset
!= loffset
&& is_64
)
1194 memcpy (buf
+ 2, &soffset
, 4);
1195 append_insns (to
, 6, buf
);
1197 /* Note: this is not fully correct. In 31-bit mode, LARL will write
1198 an address with the top bit 0, while BRAS/BRASL will write it
1199 with top bit 1. It should not matter much, since linux compilers
1200 use BR and not BSM to return from functions, but it could confuse
1201 some poor stack unwinder. */
1203 /* We'll now be writing a JG. */
1210 /* Compute the new offset and write it to the buffer. */
1211 loffset
= target
- *to
;
1216 int16_t soffset
= loffset
;
1217 if (soffset
!= loffset
)
1219 memcpy (buf
+ 2, &soffset
, 2);
1223 int32_t soffset
= loffset
;
1224 if (soffset
!= loffset
&& is_64
)
1226 memcpy (buf
+ 2, &soffset
, 4);
1229 append_insns (to
, ilen
, buf
);
1233 /* Implementation of linux_target_ops method
1234 "install_fast_tracepoint_jump_pad". */
1237 s390_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint
,
1239 CORE_ADDR collector
,
1242 CORE_ADDR
*jump_entry
,
1243 CORE_ADDR
*trampoline
,
1244 ULONGEST
*trampoline_size
,
1245 unsigned char *jjump_pad_insn
,
1246 ULONGEST
*jjump_pad_insn_size
,
1247 CORE_ADDR
*adjusted_insn_addr
,
1248 CORE_ADDR
*adjusted_insn_addr_end
,
1254 unsigned char jbuf
[6] = { 0xc0, 0xf4, 0, 0, 0, 0 }; /* jg ... */
1255 CORE_ADDR buildaddr
= *jump_entry
;
1257 struct regcache
*regcache
= get_thread_regcache (current_thread
, 0);
1258 int is_64
= register_size (regcache
->tdesc
, 0) == 8;
1259 int is_zarch
= is_64
|| have_hwcap_s390_high_gprs
;
1260 int has_vx
= have_hwcap_s390_vx
;
1262 int is_64
= 0, is_zarch
= 0, has_vx
= 0;
1264 CORE_ADDR literals
[4] = {
1271 /* First, store the GPRs. */
1273 append_insns (&buildaddr
, sizeof s390_ft_entry_gpr_zarch
,
1274 s390_ft_entry_gpr_zarch
);
1276 append_insns (&buildaddr
, sizeof s390_ft_entry_gpr_esa
,
1277 s390_ft_entry_gpr_esa
);
1279 /* Second, misc registers (ARs, PSWM, FPC). PSWA will be stored below. */
1280 append_insns (&buildaddr
, sizeof s390_ft_entry_misc
, s390_ft_entry_misc
);
1282 /* Third, FRs or VRs. */
1284 append_insns (&buildaddr
, sizeof s390_ft_entry_vr
, s390_ft_entry_vr
);
1286 append_insns (&buildaddr
, sizeof s390_ft_entry_fr
, s390_ft_entry_fr
);
1288 /* Now, the main part of code - store PSWA, take lock, call collector,
1289 leave lock. First, we'll need to fetch 4 literals. */
1291 unsigned char buf
[] = {
1292 0x07, 0x07, /* nopr %r7 */
1293 0x07, 0x07, /* nopr %r7 */
1294 0x07, 0x07, /* nopr %r7 */
1295 0xa7, 0x15, 0x00, 0x12, /* bras %r1, .Lend */
1296 0, 0, 0, 0, 0, 0, 0, 0, /* tpaddr */
1297 0, 0, 0, 0, 0, 0, 0, 0, /* tpoint */
1298 0, 0, 0, 0, 0, 0, 0, 0, /* collector */
1299 0, 0, 0, 0, 0, 0, 0, 0, /* lockaddr */
1302 /* Find the proper start place in buf, so that literals will be
1304 int bufpos
= (buildaddr
+ 2) & 7;
1305 /* Stuff the literals into the buffer. */
1306 for (i
= 0; i
< 4; i
++) {
1307 uint64_t lit
= literals
[i
];
1308 memcpy (&buf
[sizeof buf
- 32 + i
* 8], &lit
, 8);
1310 append_insns (&buildaddr
, sizeof buf
- bufpos
, buf
+ bufpos
);
1311 append_insns (&buildaddr
, sizeof s390_ft_main_64
, s390_ft_main_64
);
1313 unsigned char buf
[] = {
1314 0x07, 0x07, /* nopr %r7 */
1315 0xa7, 0x15, 0x00, 0x0a, /* bras %r1, .Lend */
1316 0, 0, 0, 0, /* tpaddr */
1317 0, 0, 0, 0, /* tpoint */
1318 0, 0, 0, 0, /* collector */
1319 0, 0, 0, 0, /* lockaddr */
1322 /* Find the proper start place in buf, so that literals will be
1324 int bufpos
= (buildaddr
+ 2) & 3;
1325 /* First literal will be saved as the PSWA, make sure it has the high bit
1327 literals
[0] |= 0x80000000;
1328 /* Stuff the literals into the buffer. */
1329 for (i
= 0; i
< 4; i
++) {
1330 uint32_t lit
= literals
[i
];
1331 memcpy (&buf
[sizeof buf
- 16 + i
* 4], &lit
, 4);
1333 append_insns (&buildaddr
, sizeof buf
- bufpos
, buf
+ bufpos
);
1334 append_insns (&buildaddr
, sizeof s390_ft_main_31
, s390_ft_main_31
);
1337 /* Restore FRs or VRs. */
1339 append_insns (&buildaddr
, sizeof s390_ft_exit_vr
, s390_ft_exit_vr
);
1341 append_insns (&buildaddr
, sizeof s390_ft_exit_fr
, s390_ft_exit_fr
);
1343 /* Restore misc registers. */
1344 append_insns (&buildaddr
, sizeof s390_ft_exit_misc
, s390_ft_exit_misc
);
1346 /* Restore the GPRs. */
1348 append_insns (&buildaddr
, sizeof s390_ft_exit_gpr_zarch
,
1349 s390_ft_exit_gpr_zarch
);
1351 append_insns (&buildaddr
, sizeof s390_ft_exit_gpr_esa
,
1352 s390_ft_exit_gpr_esa
);
1354 /* Now, adjust the original instruction to execute in the jump
1356 *adjusted_insn_addr
= buildaddr
;
1357 if (s390_relocate_instruction (&buildaddr
, tpaddr
, is_64
))
1359 sprintf (err
, "E.Could not relocate instruction for tracepoint.");
1362 *adjusted_insn_addr_end
= buildaddr
;
1364 /* Finally, write a jump back to the program. */
1366 loffset
= (tpaddr
+ orig_size
) - buildaddr
;
1369 if (is_64
&& offset
!= loffset
)
1372 "E.Jump back from jump pad too far from tracepoint "
1373 "(offset 0x%" PRIx64
" > int33).", loffset
);
1376 memcpy (jbuf
+ 2, &offset
, 4);
1377 append_insns (&buildaddr
, sizeof jbuf
, jbuf
);
1379 /* The jump pad is now built. Wire in a jump to our jump pad. This
1380 is always done last (by our caller actually), so that we can
1381 install fast tracepoints with threads running. This relies on
1382 the agent's atomic write support. */
1383 loffset
= *jump_entry
- tpaddr
;
1386 if (is_64
&& offset
!= loffset
)
1389 "E.Jump back from jump pad too far from tracepoint "
1390 "(offset 0x%" PRIx64
" > int33).", loffset
);
1393 memcpy (jbuf
+ 2, &offset
, 4);
1394 memcpy (jjump_pad_insn
, jbuf
, sizeof jbuf
);
1395 *jjump_pad_insn_size
= sizeof jbuf
;
1397 /* Return the end address of our pad. */
1398 *jump_entry
= buildaddr
;
1403 /* Implementation of linux_target_ops method
1404 "get_min_fast_tracepoint_insn_len". */
1407 s390_get_min_fast_tracepoint_insn_len (void)
1409 /* We only support using 6-byte jumps to reach the tracepoint code.
1410 If the tracepoint buffer were allocated sufficiently close (64kiB)
1411 to the executable code, and the traced instruction itself was close
1412 enough to the beginning, we could use 4-byte jumps, but this doesn't
1413 seem to be worth the effort. */
1417 /* Implementation of linux_target_ops method "get_ipa_tdesc_idx". */
1420 s390_get_ipa_tdesc_idx (void)
1422 struct regcache
*regcache
= get_thread_regcache (current_thread
, 0);
1423 const struct target_desc
*tdesc
= regcache
->tdesc
;
1426 if (tdesc
== tdesc_s390x_linux64
)
1427 return S390_TDESC_64
;
1428 if (tdesc
== tdesc_s390x_linux64v1
)
1429 return S390_TDESC_64V1
;
1430 if (tdesc
== tdesc_s390x_linux64v2
)
1431 return S390_TDESC_64V2
;
1432 if (tdesc
== tdesc_s390x_te_linux64
)
1433 return S390_TDESC_TE
;
1434 if (tdesc
== tdesc_s390x_vx_linux64
)
1435 return S390_TDESC_VX
;
1436 if (tdesc
== tdesc_s390x_tevx_linux64
)
1437 return S390_TDESC_TEVX
;
1438 if (tdesc
== tdesc_s390x_gs_linux64
)
1439 return S390_TDESC_GS
;
1442 if (tdesc
== tdesc_s390_linux32
)
1443 return S390_TDESC_32
;
1444 if (tdesc
== tdesc_s390_linux32v1
)
1445 return S390_TDESC_32V1
;
1446 if (tdesc
== tdesc_s390_linux32v2
)
1447 return S390_TDESC_32V2
;
1448 if (tdesc
== tdesc_s390_linux64
)
1449 return S390_TDESC_64
;
1450 if (tdesc
== tdesc_s390_linux64v1
)
1451 return S390_TDESC_64V1
;
1452 if (tdesc
== tdesc_s390_linux64v2
)
1453 return S390_TDESC_64V2
;
1454 if (tdesc
== tdesc_s390_te_linux64
)
1455 return S390_TDESC_TE
;
1456 if (tdesc
== tdesc_s390_vx_linux64
)
1457 return S390_TDESC_VX
;
1458 if (tdesc
== tdesc_s390_tevx_linux64
)
1459 return S390_TDESC_TEVX
;
1460 if (tdesc
== tdesc_s390_gs_linux64
)
1461 return S390_TDESC_GS
;
1466 /* Appends given buffer to current_insn_ptr in the target. */
1469 add_insns (const unsigned char *start
, int len
)
1471 CORE_ADDR buildaddr
= current_insn_ptr
;
1474 debug_printf ("Adding %d bytes of insn at %s\n",
1475 len
, paddress (buildaddr
));
1477 append_insns (&buildaddr
, len
, start
);
1478 current_insn_ptr
= buildaddr
;
1481 /* Register usage in emit:
1484 - %r2: top of stack (high word for 31-bit)
1485 - %r3: low word of top of stack (for 31-bit)
1487 - %r6, %r7, %r8: don't use
1490 - %r11: frame pointer
1491 - %r12: saved top of stack for void_call_2 (high word for 31-bit)
1492 - %r13: low word of saved top of stack (for 31-bit)
1493 - %r14: return address for calls
1494 - %r15: stack pointer
1498 /* The "emit_prologue" emit_ops method for s390. */
1501 s390_emit_prologue (void)
1503 static const unsigned char buf
[] = {
1504 0x90, 0x9f, 0xf0, 0x24, /* stm %r9, %r15, 0x24(%r15) */
1505 0x18, 0x92, /* lr %r9, %r2 */
1506 0x18, 0xa3, /* lr %r10, %r3 */
1507 0x18, 0xbf, /* lr %r11, %r15 */
1509 add_insns (buf
, sizeof buf
);
1512 /* The "emit_epilogue" emit_ops method for s390. */
1515 s390_emit_epilogue (void)
1517 static const unsigned char buf
[] = {
1518 0x90, 0x23, 0xa0, 0x00, /* stm %r2, %r3, 0(%r10) */
1519 0xa7, 0x28, 0x00, 0x00, /* lhi %r2, 0 */
1520 0x98, 0x9f, 0xb0, 0x24, /* lm %r9, %r15, 0x24(%r11) */
1521 0x07, 0xfe, /* br %r14 */
1523 add_insns (buf
, sizeof buf
);
1526 /* The "emit_add" emit_ops method for s390. */
1529 s390_emit_add (void)
1531 static const unsigned char buf
[] = {
1532 0x5e, 0x30, 0xf0, 0x04, /* al %r3, 4(%r15) */
1533 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x98, /* al %r2, 0(%r15) */
1534 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
1536 add_insns (buf
, sizeof buf
);
1539 /* The "emit_sub" emit_ops method for s390. */
1542 s390_emit_sub (void)
1544 static const unsigned char buf
[] = {
1545 0x98, 0x45, 0xf0, 0x00, /* lm %r4, %r5, 0(%r15) */
1546 0x1f, 0x53, /* slr %r5, %r3 */
1547 0xb9, 0x99, 0x00, 0x42, /* slbr %r4, %r2 */
1548 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
1549 0x18, 0x35, /* lr %r3, %r5 */
1550 0x18, 0x24, /* lr %r2, %r4 */
1552 add_insns (buf
, sizeof buf
);
1555 /* The "emit_mul" emit_ops method for s390. */
1558 s390_emit_mul (void)
1563 /* The "emit_lsh" emit_ops method for s390. */
1566 s390_emit_lsh (void)
1568 static const unsigned char buf
[] = {
1569 0x18, 0x43, /* lr %r4, %r3 */
1570 0x98, 0x23, 0xf0, 0x00, /* lm %r2, %r3, 0(%r15) */
1571 0x8d, 0x20, 0x40, 0x00, /* sldl %r2, 0(%r4) */
1572 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
1574 add_insns (buf
, sizeof buf
);
1577 /* The "emit_rsh_signed" emit_ops method for s390. */
1580 s390_emit_rsh_signed (void)
1582 static const unsigned char buf
[] = {
1583 0x18, 0x43, /* lr %r4, %r3 */
1584 0x98, 0x23, 0xf0, 0x00, /* lm %r2, %r3, 0(%r15) */
1585 0x8e, 0x20, 0x40, 0x00, /* srda %r2, 0(%r4) */
1586 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
1588 add_insns (buf
, sizeof buf
);
1591 /* The "emit_rsh_unsigned" emit_ops method for s390. */
1594 s390_emit_rsh_unsigned (void)
1596 static const unsigned char buf
[] = {
1597 0x18, 0x43, /* lr %r4, %r3 */
1598 0x98, 0x23, 0xf0, 0x00, /* lm %r2, %r3, 0(%r15) */
1599 0x8c, 0x20, 0x40, 0x00, /* srdl %r2, 0(%r4) */
1600 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
1602 add_insns (buf
, sizeof buf
);
1605 /* The "emit_ext" emit_ops method for s390. */
1608 s390_emit_ext (int arg
)
1610 unsigned char buf
[] = {
1611 0x8d, 0x20, 0x00, (unsigned char) (64 - arg
), /* sldl %r2, <64-arg> */
1612 0x8e, 0x20, 0x00, (unsigned char) (64 - arg
), /* srda %r2, <64-arg> */
1614 add_insns (buf
, sizeof buf
);
1617 /* The "emit_log_not" emit_ops method for s390. */
1620 s390_emit_log_not (void)
1622 static const unsigned char buf
[] = {
1623 0x16, 0x23, /* or %r2, %r3 */
1624 0xa7, 0x28, 0x00, 0x00, /* lhi %r2, 0 */
1625 0xa7, 0x38, 0x00, 0x00, /* lhi %r3, 0 */
1626 0xa7, 0x74, 0x00, 0x04, /* jne .Lskip */
1627 0xa7, 0x38, 0x00, 0x01, /* lhi %r3, 1 */
1630 add_insns (buf
, sizeof buf
);
1633 /* The "emit_bit_and" emit_ops method for s390. */
1636 s390_emit_bit_and (void)
1638 static const unsigned char buf
[] = {
1639 0x54, 0x20, 0xf0, 0x00, /* n %r2, 0(%r15) */
1640 0x54, 0x30, 0xf0, 0x04, /* n %r3, 4(%r15) */
1641 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
1643 add_insns (buf
, sizeof buf
);
1646 /* The "emit_bit_or" emit_ops method for s390. */
1649 s390_emit_bit_or (void)
1651 static const unsigned char buf
[] = {
1652 0x56, 0x20, 0xf0, 0x00, /* o %r2, 0(%r15) */
1653 0x56, 0x30, 0xf0, 0x04, /* o %r3, 4(%r15) */
1654 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
1656 add_insns (buf
, sizeof buf
);
1659 /* The "emit_bit_xor" emit_ops method for s390. */
1662 s390_emit_bit_xor (void)
1664 static const unsigned char buf
[] = {
1665 0x57, 0x20, 0xf0, 0x00, /* x %r2, 0(%r15) */
1666 0x57, 0x30, 0xf0, 0x04, /* x %r3, 4(%r15) */
1667 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
1669 add_insns (buf
, sizeof buf
);
1672 /* The "emit_bit_not" emit_ops method for s390. */
1675 s390_emit_bit_not (void)
1677 static const unsigned char buf
[] = {
1678 0xa7, 0x48, 0xff, 0xff, /* lhi %r4, -1 */
1679 0x17, 0x24, /* xr %r2, %r4 */
1680 0x17, 0x34, /* xr %r3, %r4 */
1682 add_insns (buf
, sizeof buf
);
1685 /* The "emit_equal" emit_ops method for s390. */
1688 s390_emit_equal (void)
1690 s390_emit_bit_xor ();
1691 s390_emit_log_not ();
1694 /* The "emit_less_signed" emit_ops method for s390. */
1697 s390_emit_less_signed (void)
1699 static const unsigned char buf
[] = {
1700 0x59, 0x20, 0xf0, 0x00, /* c %r2, 0(%r15) */
1701 0xa7, 0x24, 0x00, 0x0c, /* jh .Lless */
1702 0xa7, 0x44, 0x00, 0x06, /* jl .Lhigh */
1703 0x55, 0x30, 0xf0, 0x04, /* cl %r3, 4(%r15) */
1704 0xa7, 0x24, 0x00, 0x06, /* jh .Lless */
1706 0xa7, 0x38, 0x00, 0x00, /* lhi %r3, 0 */
1707 0xa7, 0xf4, 0x00, 0x04, /* j .Lend */
1709 0xa7, 0x38, 0x00, 0x01, /* lhi %r3, 1 */
1711 0xa7, 0x28, 0x00, 0x00, /* lhi %r2, 0 */
1712 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
1714 add_insns (buf
, sizeof buf
);
1717 /* The "emit_less_unsigned" emit_ops method for s390. */
1720 s390_emit_less_unsigned (void)
1722 static const unsigned char buf
[] = {
1723 0x55, 0x20, 0xf0, 0x00, /* cl %r2, 0(%r15) */
1724 0xa7, 0x24, 0x00, 0x0c, /* jh .Lless */
1725 0xa7, 0x44, 0x00, 0x06, /* jl .Lhigh */
1726 0x55, 0x30, 0xf0, 0x04, /* cl %r3, 4(%r15) */
1727 0xa7, 0x24, 0x00, 0x06, /* jh .Lless */
1729 0xa7, 0x38, 0x00, 0x00, /* lhi %r3, 0 */
1730 0xa7, 0xf4, 0x00, 0x04, /* j .Lend */
1732 0xa7, 0x38, 0x00, 0x01, /* lhi %r3, 1 */
1734 0xa7, 0x28, 0x00, 0x00, /* lhi %r2, 0 */
1735 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
1737 add_insns (buf
, sizeof buf
);
1740 /* The "emit_ref" emit_ops method for s390. */
1743 s390_emit_ref (int size
)
1745 static const unsigned char buf1
[] = {
1746 0xa7, 0x28, 0x00, 0x00, /* lhi %r2, 0 */
1747 0x43, 0x30, 0x30, 0x00, /* ic %r3, 0(%r3) */
1749 static const unsigned char buf2
[] = {
1750 0xa7, 0x28, 0x00, 0x00, /* lhi %r2, 0 */
1751 0x48, 0x30, 0x30, 0x00, /* lh %r3, 0(%r3) */
1753 static const unsigned char buf4
[] = {
1754 0xa7, 0x28, 0x00, 0x00, /* lhi %r2, 0 */
1755 0x58, 0x30, 0x30, 0x00, /* l %r3, 0(%r3) */
1757 static const unsigned char buf8
[] = {
1758 0x98, 0x23, 0x30, 0x00, /* lm %r2, %r3, 0(%r3) */
1763 add_insns (buf1
, sizeof buf1
);
1766 add_insns (buf2
, sizeof buf2
);
1769 add_insns (buf4
, sizeof buf4
);
1772 add_insns (buf8
, sizeof buf8
);
1779 /* The "emit_if_goto" emit_ops method for s390. */
1782 s390_emit_if_goto (int *offset_p
, int *size_p
)
1784 static const unsigned char buf
[] = {
1785 0x16, 0x23, /* or %r2, %r3 */
1786 0x98, 0x23, 0xf0, 0x00, /* lm %r2, %r3, 0(%r15) */
1787 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
1788 0xc0, 0x74, 0x00, 0x00, 0x00, 0x00 /* jgne <fillme> */
1790 add_insns (buf
, sizeof buf
);
1797 /* The "emit_goto" emit_ops method for s390 and s390x. */
1800 s390_emit_goto (int *offset_p
, int *size_p
)
1802 static const unsigned char buf
[] = {
1803 0xc0, 0xf4, 0x00, 0x00, 0x00, 0x00, /* jg <fillme> */
1805 add_insns (buf
, sizeof buf
);
1812 /* The "write_goto_address" emit_ops method for s390 and s390x. */
1815 s390_write_goto_address (CORE_ADDR from
, CORE_ADDR to
, int size
)
1817 long diff
= ((long) (to
- (from
- 2))) / 2;
1819 unsigned char buf
[sizeof sdiff
];
1821 /* We're only doing 4-byte sizes at the moment. */
1822 if (size
!= sizeof sdiff
|| sdiff
!= diff
)
1828 memcpy (buf
, &sdiff
, sizeof sdiff
);
1829 target_write_memory (from
, buf
, sizeof sdiff
);
1832 /* Preparation for emitting a literal pool of given size. Loads the address
1833 of the pool into %r1, and jumps over it. Called should emit the pool data
1834 immediately afterwards. Used for both s390 and s390x. */
1837 s390_emit_litpool (int size
)
1839 static const unsigned char nop
[] = {
1842 unsigned char buf
[] = {
1844 (unsigned char) ((size
+ 4) / 2), /* bras %r1, .Lend+size */
1849 /* buf needs to start at even halfword for litpool to be aligned */
1850 if (current_insn_ptr
& 2)
1851 add_insns (nop
, sizeof nop
);
1855 while ((current_insn_ptr
& 6) != 4)
1856 add_insns (nop
, sizeof nop
);
1858 add_insns (buf
, sizeof buf
);
1861 /* The "emit_const" emit_ops method for s390. */
1864 s390_emit_const (LONGEST num
)
1866 unsigned long long n
= num
;
1867 unsigned char buf_s
[] = {
1868 /* lhi %r3, <num> */
1870 (unsigned char) (num
>> 8), (unsigned char) num
,
1874 static const unsigned char buf_l
[] = {
1875 0x98, 0x23, 0x10, 0x00, /* lm %r2, %r3, 0(%r1) */
1877 if (num
< 0x8000 && num
>= 0)
1879 add_insns (buf_s
, sizeof buf_s
);
1883 s390_emit_litpool (8);
1884 add_insns ((unsigned char *) &n
, sizeof n
);
1885 add_insns (buf_l
, sizeof buf_l
);
1889 /* The "emit_call" emit_ops method for s390. */
1892 s390_emit_call (CORE_ADDR fn
)
1894 unsigned int n
= fn
;
1895 static const unsigned char buf
[] = {
1896 0x58, 0x10, 0x10, 0x00, /* l %r1, 0(%r1) */
1897 0xa7, 0xfa, 0xff, 0xa0, /* ahi %r15, -0x60 */
1898 0x0d, 0xe1, /* basr %r14, %r1 */
1899 0xa7, 0xfa, 0x00, 0x60, /* ahi %r15, 0x60 */
1901 s390_emit_litpool (4);
1902 add_insns ((unsigned char *) &n
, sizeof n
);
1903 add_insns (buf
, sizeof buf
);
1906 /* The "emit_reg" emit_ops method for s390. */
1909 s390_emit_reg (int reg
)
1911 unsigned char bufpre
[] = {
1914 /* lhi %r3, <reg> */
1915 0xa7, 0x38, (unsigned char) (reg
>> 8), (unsigned char) reg
,
1917 add_insns (bufpre
, sizeof bufpre
);
1918 s390_emit_call (get_raw_reg_func_addr ());
1921 /* The "emit_pop" emit_ops method for s390. */
1924 s390_emit_pop (void)
1926 static const unsigned char buf
[] = {
1927 0x98, 0x23, 0xf0, 0x00, /* lm %r2, %r3, 0(%r15) */
1928 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
1930 add_insns (buf
, sizeof buf
);
1933 /* The "emit_stack_flush" emit_ops method for s390. */
1936 s390_emit_stack_flush (void)
1938 static const unsigned char buf
[] = {
1939 0xa7, 0xfa, 0xff, 0xf8, /* ahi %r15, -8 */
1940 0x90, 0x23, 0xf0, 0x00, /* stm %r2, %r3, 0(%r15) */
1942 add_insns (buf
, sizeof buf
);
1945 /* The "emit_zero_ext" emit_ops method for s390. */
1948 s390_emit_zero_ext (int arg
)
1950 unsigned char buf
[] = {
1951 0x8d, 0x20, 0x00, (unsigned char) (64 - arg
), /* sldl %r2, <64-arg> */
1952 0x8c, 0x20, 0x00, (unsigned char) (64 - arg
), /* srdl %r2, <64-arg> */
1954 add_insns (buf
, sizeof buf
);
1957 /* The "emit_swap" emit_ops method for s390. */
1960 s390_emit_swap (void)
1962 static const unsigned char buf
[] = {
1963 0x98, 0x45, 0xf0, 0x00, /* lm %r4, %r5, 0(%r15) */
1964 0x90, 0x23, 0xf0, 0x00, /* stm %r2, %r3, 0(%r15) */
1965 0x18, 0x24, /* lr %r2, %r4 */
1966 0x18, 0x35, /* lr %r3, %r5 */
1968 add_insns (buf
, sizeof buf
);
1971 /* The "emit_stack_adjust" emit_ops method for s390. */
1974 s390_emit_stack_adjust (int n
)
1976 unsigned char buf
[] = {
1979 (unsigned char ) (n
* 8 >> 8), (unsigned char) (n
* 8),
1981 add_insns (buf
, sizeof buf
);
1984 /* Sets %r2 to a 32-bit constant. */
1987 s390_emit_set_r2 (int arg1
)
1989 unsigned char buf_s
[] = {
1990 /* lhi %r2, <arg1> */
1991 0xa7, 0x28, (unsigned char) (arg1
>> 8), (unsigned char) arg1
,
1993 static const unsigned char buf_l
[] = {
1994 0x58, 0x20, 0x10, 0x00, /* l %r2, 0(%r1) */
1996 if (arg1
< 0x8000 && arg1
>= -0x8000)
1998 add_insns (buf_s
, sizeof buf_s
);
2002 s390_emit_litpool (4);
2003 add_insns ((unsigned char *) &arg1
, sizeof arg1
);
2004 add_insns (buf_l
, sizeof buf_l
);
2008 /* The "emit_int_call_1" emit_ops method for s390. */
2011 s390_emit_int_call_1 (CORE_ADDR fn
, int arg1
)
2013 /* FN's prototype is `LONGEST(*fn)(int)'. */
2014 s390_emit_set_r2 (arg1
);
2015 s390_emit_call (fn
);
2018 /* The "emit_void_call_2" emit_ops method for s390. */
2021 s390_emit_void_call_2 (CORE_ADDR fn
, int arg1
)
2023 /* FN's prototype is `void(*fn)(int,LONGEST)'. */
2024 static const unsigned char buf
[] = {
2025 0x18, 0xc2, /* lr %r12, %r2 */
2026 0x18, 0xd3, /* lr %r13, %r3 */
2027 0x18, 0x43, /* lr %r4, %r3 */
2028 0x18, 0x32, /* lr %r3, %r2 */
2030 static const unsigned char buf2
[] = {
2031 0x18, 0x2c, /* lr %r2, %r12 */
2032 0x18, 0x3d, /* lr %r3, %r13 */
2034 add_insns (buf
, sizeof buf
);
2035 s390_emit_set_r2 (arg1
);
2036 s390_emit_call (fn
);
2037 add_insns (buf2
, sizeof buf2
);
2040 /* The "emit_eq_goto" emit_ops method for s390. */
2043 s390_emit_eq_goto (int *offset_p
, int *size_p
)
2045 static const unsigned char buf
[] = {
2046 0x57, 0x20, 0xf0, 0x00, /* x %r2, 0(%r15) */
2047 0x57, 0x30, 0xf0, 0x04, /* x %r3, 4(%r15) */
2048 0x16, 0x23, /* or %r2, %r3 */
2049 0x98, 0x23, 0xf0, 0x08, /* lm %r2, %r3, 8(%r15) */
2050 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
2051 0xc0, 0x84, 0x00, 0x00, 0x00, 0x00, /* jge <fillme> */
2053 add_insns (buf
, sizeof buf
);
2060 /* The "emit_ne_goto" emit_ops method for s390. */
2063 s390_emit_ne_goto (int *offset_p
, int *size_p
)
2065 static const unsigned char buf
[] = {
2066 0x57, 0x20, 0xf0, 0x00, /* x %r2, 0(%r15) */
2067 0x57, 0x30, 0xf0, 0x04, /* x %r3, 4(%r15) */
2068 0x16, 0x23, /* or %r2, %r3 */
2069 0x98, 0x23, 0xf0, 0x08, /* lm %r2, %r3, 8(%r15) */
2070 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
2071 0xc0, 0x74, 0x00, 0x00, 0x00, 0x00, /* jgne <fillme> */
2073 add_insns (buf
, sizeof buf
);
2080 /* The "emit_lt_goto" emit_ops method for s390. */
2083 s390_emit_lt_goto (int *offset_p
, int *size_p
)
2085 static const unsigned char buf
[] = {
2086 0x59, 0x20, 0xf0, 0x00, /* c %r2, 0(%r15) */
2087 0xa7, 0x24, 0x00, 0x0e, /* jh .Ltrue */
2088 0xa7, 0x44, 0x00, 0x06, /* jl .Lfalse */
2089 0x55, 0x30, 0xf0, 0x04, /* cl %r3, 4(%r15) */
2090 0xa7, 0x24, 0x00, 0x08, /* jh .Ltrue */
2092 0x98, 0x23, 0xf0, 0x08, /* lm %r2, %r3, 8(%r15) */
2093 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
2094 0xa7, 0xf4, 0x00, 0x09, /* j .Lend */
2096 0x98, 0x23, 0xf0, 0x08, /* lm %r2, %r3, 8(%r15) */
2097 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
2098 0xc0, 0xf4, 0x00, 0x00, 0x00, 0x00, /* jg <fillme> */
2101 add_insns (buf
, sizeof buf
);
2108 /* The "emit_le_goto" emit_ops method for s390. */
2111 s390_emit_le_goto (int *offset_p
, int *size_p
)
2113 static const unsigned char buf
[] = {
2114 0x59, 0x20, 0xf0, 0x00, /* c %r2, 0(%r15) */
2115 0xa7, 0x24, 0x00, 0x0e, /* jh .Ltrue */
2116 0xa7, 0x44, 0x00, 0x06, /* jl .Lfalse */
2117 0x55, 0x30, 0xf0, 0x04, /* cl %r3, 4(%r15) */
2118 0xa7, 0xa4, 0x00, 0x08, /* jhe .Ltrue */
2120 0x98, 0x23, 0xf0, 0x08, /* lm %r2, %r3, 8(%r15) */
2121 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
2122 0xa7, 0xf4, 0x00, 0x09, /* j .Lend */
2124 0x98, 0x23, 0xf0, 0x08, /* lm %r2, %r3, 8(%r15) */
2125 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
2126 0xc0, 0xf4, 0x00, 0x00, 0x00, 0x00, /* jg <fillme> */
2129 add_insns (buf
, sizeof buf
);
2136 /* The "emit_gt_goto" emit_ops method for s390. */
2139 s390_emit_gt_goto (int *offset_p
, int *size_p
)
2141 static const unsigned char buf
[] = {
2142 0x59, 0x20, 0xf0, 0x00, /* c %r2, 0(%r15) */
2143 0xa7, 0x44, 0x00, 0x0e, /* jl .Ltrue */
2144 0xa7, 0x24, 0x00, 0x06, /* jh .Lfalse */
2145 0x55, 0x30, 0xf0, 0x04, /* cl %r3, 4(%r15) */
2146 0xa7, 0x44, 0x00, 0x08, /* jl .Ltrue */
2148 0x98, 0x23, 0xf0, 0x08, /* lm %r2, %r3, 8(%r15) */
2149 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
2150 0xa7, 0xf4, 0x00, 0x09, /* j .Lend */
2152 0x98, 0x23, 0xf0, 0x08, /* lm %r2, %r3, 8(%r15) */
2153 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
2154 0xc0, 0xf4, 0x00, 0x00, 0x00, 0x00, /* jg <fillme> */
2157 add_insns (buf
, sizeof buf
);
2164 /* The "emit_ge_goto" emit_ops method for s390. */
2167 s390_emit_ge_goto (int *offset_p
, int *size_p
)
2169 static const unsigned char buf
[] = {
2170 0x59, 0x20, 0xf0, 0x00, /* c %r2, 0(%r15) */
2171 0xa7, 0x44, 0x00, 0x0e, /* jl .Ltrue */
2172 0xa7, 0x24, 0x00, 0x06, /* jh .Lfalse */
2173 0x55, 0x30, 0xf0, 0x04, /* cl %r3, 4(%r15) */
2174 0xa7, 0xc4, 0x00, 0x08, /* jle .Ltrue */
2176 0x98, 0x23, 0xf0, 0x08, /* lm %r2, %r3, 8(%r15) */
2177 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
2178 0xa7, 0xf4, 0x00, 0x09, /* j .Lend */
2180 0x98, 0x23, 0xf0, 0x08, /* lm %r2, %r3, 8(%r15) */
2181 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
2182 0xc0, 0xf4, 0x00, 0x00, 0x00, 0x00, /* jg <fillme> */
2185 add_insns (buf
, sizeof buf
);
2192 /* The "emit_ops" structure for s390. Named _impl to avoid name
2193 collision with s390_emit_ops function. */
2195 static struct emit_ops s390_emit_ops_impl
=
2203 s390_emit_rsh_signed
,
2204 s390_emit_rsh_unsigned
,
2212 s390_emit_less_signed
,
2213 s390_emit_less_unsigned
,
2217 s390_write_goto_address
,
2222 s390_emit_stack_flush
,
2225 s390_emit_stack_adjust
,
2226 s390_emit_int_call_1
,
2227 s390_emit_void_call_2
,
2238 /* The "emit_prologue" emit_ops method for s390x. */
2241 s390x_emit_prologue (void)
2243 static const unsigned char buf
[] = {
2244 0xeb, 0x9f, 0xf0, 0x48, 0x00, 0x24, /* stmg %r9, %r15, 0x48(%r15) */
2245 0xb9, 0x04, 0x00, 0x92, /* lgr %r9, %r2 */
2246 0xb9, 0x04, 0x00, 0xa3, /* lgr %r10, %r3 */
2247 0xb9, 0x04, 0x00, 0xbf, /* lgr %r11, %r15 */
2249 add_insns (buf
, sizeof buf
);
2252 /* The "emit_epilogue" emit_ops method for s390x. */
2255 s390x_emit_epilogue (void)
2257 static const unsigned char buf
[] = {
2258 0xe3, 0x20, 0xa0, 0x00, 0x00, 0x24, /* stg %r2, 0(%r10) */
2259 0xa7, 0x29, 0x00, 0x00, /* lghi %r2, 0 */
2260 0xeb, 0x9f, 0xf0, 0x48, 0x00, 0x04, /* lmg %r9, %r15, 0x48(%r15) */
2261 0x07, 0xfe, /* br %r14 */
2263 add_insns (buf
, sizeof buf
);
2266 /* The "emit_add" emit_ops method for s390x. */
2269 s390x_emit_add (void)
2271 static const unsigned char buf
[] = {
2272 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x0a, /* alg %r2, 0(%r15) */
2273 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
2275 add_insns (buf
, sizeof buf
);
2278 /* The "emit_sub" emit_ops method for s390x. */
2281 s390x_emit_sub (void)
2283 static const unsigned char buf
[] = {
2284 0xe3, 0x30, 0xf0, 0x00, 0x00, 0x04, /* lg %r3, 0(%r15) */
2285 0xb9, 0x0b, 0x00, 0x32, /* slgr %r3, %r2 */
2286 0xb9, 0x04, 0x00, 0x23, /* lgr %r2, %r3 */
2287 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
2289 add_insns (buf
, sizeof buf
);
2292 /* The "emit_mul" emit_ops method for s390x. */
2295 s390x_emit_mul (void)
2300 /* The "emit_lsh" emit_ops method for s390x. */
2303 s390x_emit_lsh (void)
2305 static const unsigned char buf
[] = {
2306 0xe3, 0x30, 0xf0, 0x00, 0x00, 0x04, /* lg %r3, 0(%r15) */
2307 0xeb, 0x23, 0x20, 0x00, 0x00, 0x0d, /* sllg %r2, %r3, 0(%r2) */
2308 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
2310 add_insns (buf
, sizeof buf
);
2313 /* The "emit_rsh_signed" emit_ops method for s390x. */
2316 s390x_emit_rsh_signed (void)
2318 static const unsigned char buf
[] = {
2319 0xe3, 0x30, 0xf0, 0x00, 0x00, 0x04, /* lg %r3, 0(%r15) */
2320 0xeb, 0x23, 0x20, 0x00, 0x00, 0x0a, /* srag %r2, %r3, 0(%r2) */
2321 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
2323 add_insns (buf
, sizeof buf
);
2326 /* The "emit_rsh_unsigned" emit_ops method for s390x. */
2329 s390x_emit_rsh_unsigned (void)
2331 static const unsigned char buf
[] = {
2332 0xe3, 0x30, 0xf0, 0x00, 0x00, 0x04, /* lg %r3, 0(%r15) */
2333 0xeb, 0x23, 0x20, 0x00, 0x00, 0x0c, /* srlg %r2, %r3, 0(%r2) */
2334 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
2336 add_insns (buf
, sizeof buf
);
2339 /* The "emit_ext" emit_ops method for s390x. */
2342 s390x_emit_ext (int arg
)
2344 unsigned char buf
[] = {
2345 /* sllg %r2, %r2, <64-arg> */
2346 0xeb, 0x22, 0x00, (unsigned char) (64 - arg
), 0x00, 0x0d,
2347 /* srag %r2, %r2, <64-arg> */
2348 0xeb, 0x22, 0x00, (unsigned char) (64 - arg
), 0x00, 0x0a,
2350 add_insns (buf
, sizeof buf
);
2353 /* The "emit_log_not" emit_ops method for s390x. */
2356 s390x_emit_log_not (void)
2358 static const unsigned char buf
[] = {
2359 0xb9, 0x00, 0x00, 0x22, /* lpgr %r2, %r2 */
2360 0xa7, 0x2b, 0xff, 0xff, /* aghi %r2, -1 */
2361 0xeb, 0x22, 0x00, 0x3f, 0x00, 0x0c, /* srlg %r2, %r2, 63 */
2363 add_insns (buf
, sizeof buf
);
2366 /* The "emit_bit_and" emit_ops method for s390x. */
2369 s390x_emit_bit_and (void)
2371 static const unsigned char buf
[] = {
2372 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x80, /* ng %r2, 0(%r15) */
2373 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
2375 add_insns (buf
, sizeof buf
);
2378 /* The "emit_bit_or" emit_ops method for s390x. */
2381 s390x_emit_bit_or (void)
2383 static const unsigned char buf
[] = {
2384 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x81, /* og %r2, 0(%r15) */
2385 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
2387 add_insns (buf
, sizeof buf
);
2390 /* The "emit_bit_xor" emit_ops method for s390x. */
2393 s390x_emit_bit_xor (void)
2395 static const unsigned char buf
[] = {
2396 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x82, /* xg %r2, 0(%r15) */
2397 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
2399 add_insns (buf
, sizeof buf
);
2402 /* The "emit_bit_not" emit_ops method for s390x. */
2405 s390x_emit_bit_not (void)
2407 static const unsigned char buf
[] = {
2408 0xa7, 0x39, 0xff, 0xff, /* lghi %r3, -1 */
2409 0xb9, 0x82, 0x00, 0x23, /* xgr %r2, %r3 */
2411 add_insns (buf
, sizeof buf
);
2414 /* The "emit_equal" emit_ops method for s390x. */
2417 s390x_emit_equal (void)
2419 s390x_emit_bit_xor ();
2420 s390x_emit_log_not ();
2423 /* The "emit_less_signed" emit_ops method for s390x. */
2426 s390x_emit_less_signed (void)
2428 static const unsigned char buf
[] = {
2429 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x20, /* cg %r2, 0(%r15) */
2430 0xa7, 0x29, 0x00, 0x01, /* lghi %r2, 1 */
2431 0xa7, 0x24, 0x00, 0x04, /* jh .Lend */
2432 0xa7, 0x29, 0x00, 0x00, /* lghi %r2, 0 */
2434 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
2436 add_insns (buf
, sizeof buf
);
2439 /* The "emit_less_unsigned" emit_ops method for s390x. */
2442 s390x_emit_less_unsigned (void)
2444 static const unsigned char buf
[] = {
2445 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x21, /* clg %r2, 0(%r15) */
2446 0xa7, 0x29, 0x00, 0x01, /* lghi %r2, 1 */
2447 0xa7, 0x24, 0x00, 0x04, /* jh .Lend */
2448 0xa7, 0x29, 0x00, 0x00, /* lghi %r2, 0 */
2450 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
2452 add_insns (buf
, sizeof buf
);
2455 /* The "emit_ref" emit_ops method for s390x. */
2458 s390x_emit_ref (int size
)
2460 static const unsigned char buf1
[] = {
2461 0xe3, 0x20, 0x20, 0x00, 0x00, 0x90, /* llgc %r2, 0(%r2) */
2463 static const unsigned char buf2
[] = {
2464 0xe3, 0x20, 0x20, 0x00, 0x00, 0x91 /* llgh %r2, 0(%r2) */
2466 static const unsigned char buf4
[] = {
2467 0xe3, 0x20, 0x20, 0x00, 0x00, 0x16, /* llgf %r2, 0(%r2) */
2469 static const unsigned char buf8
[] = {
2470 0xe3, 0x20, 0x20, 0x00, 0x00, 0x04, /* lg %r2, 0(%r2) */
2475 add_insns (buf1
, sizeof buf1
);
2478 add_insns (buf2
, sizeof buf2
);
2481 add_insns (buf4
, sizeof buf4
);
2484 add_insns (buf8
, sizeof buf8
);
2491 /* The "emit_if_goto" emit_ops method for s390x. */
2494 s390x_emit_if_goto (int *offset_p
, int *size_p
)
2496 static const unsigned char buf
[] = {
2497 0xb9, 0x02, 0x00, 0x22, /* ltgr %r2, %r2 */
2498 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x04, /* lg %r2, 0(%r15) */
2499 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
2500 0xc0, 0x74, 0x00, 0x00, 0x00, 0x00, /* jgne <fillme> */
2502 add_insns (buf
, sizeof buf
);
2509 /* The "emit_const" emit_ops method for s390x. */
2512 s390x_emit_const (LONGEST num
)
2514 unsigned long long n
= num
;
2515 unsigned char buf_s
[] = {
2516 /* lghi %r2, <num> */
2517 0xa7, 0x29, (unsigned char) (num
>> 8), (unsigned char) num
,
2519 static const unsigned char buf_l
[] = {
2520 0xe3, 0x20, 0x10, 0x00, 0x00, 0x04, /* lg %r2, 0(%r1) */
2522 if (num
< 0x8000 && num
>= -0x8000)
2524 add_insns (buf_s
, sizeof buf_s
);
2528 s390_emit_litpool (8);
2529 add_insns ((unsigned char *) &n
, sizeof n
);
2530 add_insns (buf_l
, sizeof buf_l
);
2534 /* The "emit_call" emit_ops method for s390x. */
2537 s390x_emit_call (CORE_ADDR fn
)
2539 unsigned long n
= fn
;
2540 static const unsigned char buf
[] = {
2541 0xe3, 0x10, 0x10, 0x00, 0x00, 0x04, /* lg %r1, 0(%r1) */
2542 0xa7, 0xfb, 0xff, 0x60, /* aghi %r15, -0xa0 */
2543 0x0d, 0xe1, /* basr %r14, %r1 */
2544 0xa7, 0xfb, 0x00, 0xa0, /* aghi %r15, 0xa0 */
2546 s390_emit_litpool (8);
2547 add_insns ((unsigned char *) &n
, sizeof n
);
2548 add_insns (buf
, sizeof buf
);
2551 /* The "emit_reg" emit_ops method for s390x. */
2554 s390x_emit_reg (int reg
)
2556 unsigned char buf
[] = {
2558 0xb9, 0x04, 0x00, 0x29,
2559 /* lghi %r3, <reg> */
2560 0xa7, 0x39, (unsigned char) (reg
>> 8), (unsigned char) reg
,
2562 add_insns (buf
, sizeof buf
);
2563 s390x_emit_call (get_raw_reg_func_addr ());
2566 /* The "emit_pop" emit_ops method for s390x. */
2569 s390x_emit_pop (void)
2571 static const unsigned char buf
[] = {
2572 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x04, /* lg %r2, 0(%r15) */
2573 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
2575 add_insns (buf
, sizeof buf
);
2578 /* The "emit_stack_flush" emit_ops method for s390x. */
2581 s390x_emit_stack_flush (void)
2583 static const unsigned char buf
[] = {
2584 0xa7, 0xfb, 0xff, 0xf8, /* aghi %r15, -8 */
2585 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x24, /* stg %r2, 0(%r15) */
2587 add_insns (buf
, sizeof buf
);
2590 /* The "emit_zero_ext" emit_ops method for s390x. */
2593 s390x_emit_zero_ext (int arg
)
2595 unsigned char buf
[] = {
2596 /* sllg %r2, %r2, <64-arg> */
2597 0xeb, 0x22, 0x00, (unsigned char) (64 - arg
), 0x00, 0x0d,
2598 /* srlg %r2, %r2, <64-arg> */
2599 0xeb, 0x22, 0x00, (unsigned char) (64 - arg
), 0x00, 0x0c,
2601 add_insns (buf
, sizeof buf
);
2604 /* The "emit_swap" emit_ops method for s390x. */
2607 s390x_emit_swap (void)
2609 static const unsigned char buf
[] = {
2610 0xe3, 0x30, 0xf0, 0x00, 0x00, 0x04, /* lg %r3, 0(%r15) */
2611 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x24, /* stg %r2, 0(%r15) */
2612 0xb9, 0x04, 0x00, 0x23, /* lgr %r2, %r3 */
2614 add_insns (buf
, sizeof buf
);
2617 /* The "emit_stack_adjust" emit_ops method for s390x. */
2620 s390x_emit_stack_adjust (int n
)
2622 unsigned char buf
[] = {
2623 /* aghi %r15, 8*n */
2625 (unsigned char) (n
* 8 >> 8), (unsigned char) (n
* 8),
2627 add_insns (buf
, sizeof buf
);
2630 /* The "emit_int_call_1" emit_ops method for s390x. */
2633 s390x_emit_int_call_1 (CORE_ADDR fn
, int arg1
)
2635 /* FN's prototype is `LONGEST(*fn)(int)'. */
2636 s390x_emit_const (arg1
);
2637 s390x_emit_call (fn
);
2640 /* The "emit_void_call_2" emit_ops method for s390x. */
2643 s390x_emit_void_call_2 (CORE_ADDR fn
, int arg1
)
2645 /* FN's prototype is `void(*fn)(int,LONGEST)'. */
2646 static const unsigned char buf
[] = {
2647 0xb9, 0x04, 0x00, 0x32, /* lgr %r3, %r2 */
2648 0xb9, 0x04, 0x00, 0xc2, /* lgr %r12, %r2 */
2650 static const unsigned char buf2
[] = {
2651 0xb9, 0x04, 0x00, 0x2c, /* lgr %r2, %r12 */
2653 add_insns (buf
, sizeof buf
);
2654 s390x_emit_const (arg1
);
2655 s390x_emit_call (fn
);
2656 add_insns (buf2
, sizeof buf2
);
2659 /* The "emit_eq_goto" emit_ops method for s390x. */
2662 s390x_emit_eq_goto (int *offset_p
, int *size_p
)
2664 static const unsigned char buf
[] = {
2665 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x20, /* cg %r2, 0(%r15) */
2666 0xe3, 0x20, 0xf0, 0x08, 0x00, 0x04, /* lg %r2, 8(%r15) */
2667 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
2668 0xc0, 0x84, 0x00, 0x00, 0x00, 0x00, /* jge <fillme> */
2670 add_insns (buf
, sizeof buf
);
2677 /* The "emit_ne_goto" emit_ops method for s390x. */
2680 s390x_emit_ne_goto (int *offset_p
, int *size_p
)
2682 static const unsigned char buf
[] = {
2683 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x20, /* cg %r2, 0(%r15) */
2684 0xe3, 0x20, 0xf0, 0x08, 0x00, 0x04, /* lg %r2, 8(%r15) */
2685 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
2686 0xc0, 0x74, 0x00, 0x00, 0x00, 0x00, /* jgne <fillme> */
2688 add_insns (buf
, sizeof buf
);
2695 /* The "emit_lt_goto" emit_ops method for s390x. */
2698 s390x_emit_lt_goto (int *offset_p
, int *size_p
)
2700 static const unsigned char buf
[] = {
2701 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x20, /* cg %r2, 0(%r15) */
2702 0xe3, 0x20, 0xf0, 0x08, 0x00, 0x04, /* lg %r2, 8(%r15) */
2703 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
2704 0xc0, 0x24, 0x00, 0x00, 0x00, 0x00, /* jgh <fillme> */
2706 add_insns (buf
, sizeof buf
);
2713 /* The "emit_le_goto" emit_ops method for s390x. */
2716 s390x_emit_le_goto (int *offset_p
, int *size_p
)
2718 static const unsigned char buf
[] = {
2719 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x20, /* cg %r2, 0(%r15) */
2720 0xe3, 0x20, 0xf0, 0x08, 0x00, 0x04, /* lg %r2, 8(%r15) */
2721 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
2722 0xc0, 0xa4, 0x00, 0x00, 0x00, 0x00, /* jghe <fillme> */
2724 add_insns (buf
, sizeof buf
);
2731 /* The "emit_gt_goto" emit_ops method for s390x. */
2734 s390x_emit_gt_goto (int *offset_p
, int *size_p
)
2736 static const unsigned char buf
[] = {
2737 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x20, /* cg %r2, 0(%r15) */
2738 0xe3, 0x20, 0xf0, 0x08, 0x00, 0x04, /* lg %r2, 8(%r15) */
2739 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
2740 0xc0, 0x44, 0x00, 0x00, 0x00, 0x00, /* jgl <fillme> */
2742 add_insns (buf
, sizeof buf
);
2749 /* The "emit_ge_goto" emit_ops method for s390x. */
2752 s390x_emit_ge_goto (int *offset_p
, int *size_p
)
2754 static const unsigned char buf
[] = {
2755 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x20, /* cg %r2, 0(%r15) */
2756 0xe3, 0x20, 0xf0, 0x08, 0x00, 0x04, /* lg %r2, 8(%r15) */
2757 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
2758 0xc0, 0xc4, 0x00, 0x00, 0x00, 0x00, /* jgle <fillme> */
2760 add_insns (buf
, sizeof buf
);
2767 /* The "emit_ops" structure for s390x. */
2769 static struct emit_ops s390x_emit_ops
=
2771 s390x_emit_prologue
,
2772 s390x_emit_epilogue
,
2777 s390x_emit_rsh_signed
,
2778 s390x_emit_rsh_unsigned
,
2786 s390x_emit_less_signed
,
2787 s390x_emit_less_unsigned
,
2791 s390_write_goto_address
,
2796 s390x_emit_stack_flush
,
2797 s390x_emit_zero_ext
,
2799 s390x_emit_stack_adjust
,
2800 s390x_emit_int_call_1
,
2801 s390x_emit_void_call_2
,
2811 /* The "emit_ops" linux_target_ops method. */
2813 static struct emit_ops
*
2814 s390_emit_ops (void)
2817 struct regcache
*regcache
= get_thread_regcache (current_thread
, 0);
2819 if (register_size (regcache
->tdesc
, 0) == 8)
2820 return &s390x_emit_ops
;
2823 return &s390_emit_ops_impl
;
2826 struct linux_target_ops the_low_target
= {
2827 NULL
, /* breakpoint_kind_from_pc */
2828 s390_sw_breakpoint_from_kind
,
2830 s390_breakpoint_len
,
2832 s390_supports_z_point_type
,
2837 s390_collect_ptrace_register
,
2838 s390_supply_ptrace_register
,
2839 NULL
, /* siginfo_fixup */
2840 NULL
, /* new_process */
2841 NULL
, /* delete_process */
2842 NULL
, /* new_thread */
2843 NULL
, /* delete_thread */
2844 NULL
, /* new_fork */
2845 NULL
, /* prepare_to_resume */
2846 NULL
, /* process_qsupported */
2847 s390_supports_tracepoints
,
2848 s390_get_thread_area
,
2849 s390_install_fast_tracepoint_jump_pad
,
2851 s390_get_min_fast_tracepoint_insn_len
,
2852 NULL
, /* supports_range_stepping */
2853 NULL
, /* breakpoint_kind_from_current_state */
2854 s390_supports_hardware_single_step
,
2855 NULL
, /* get_syscall_trapinfo */
2856 s390_get_ipa_tdesc_idx
,
2859 /* The linux target ops object. */
2861 linux_process_target
*the_linux_target
= &the_s390_target
;
2864 initialize_low_arch (void)
2866 /* Initialize the Linux target descriptions. */
2868 init_registers_s390_linux32 ();
2869 init_registers_s390_linux32v1 ();
2870 init_registers_s390_linux32v2 ();
2871 init_registers_s390_linux64 ();
2872 init_registers_s390_linux64v1 ();
2873 init_registers_s390_linux64v2 ();
2874 init_registers_s390_te_linux64 ();
2875 init_registers_s390_vx_linux64 ();
2876 init_registers_s390_tevx_linux64 ();
2877 init_registers_s390_gs_linux64 ();
2879 init_registers_s390x_linux64 ();
2880 init_registers_s390x_linux64v1 ();
2881 init_registers_s390x_linux64v2 ();
2882 init_registers_s390x_te_linux64 ();
2883 init_registers_s390x_vx_linux64 ();
2884 init_registers_s390x_tevx_linux64 ();
2885 init_registers_s390x_gs_linux64 ();
2888 initialize_regsets_info (&s390_regsets_info
);
2889 initialize_regsets_info (&s390_regsets_info_3264
);