1 /* Target-dependent code for s390.
3 Copyright (C) 2003-2024 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/>. */
23 #include "prologue-value.h"
33 enum s390_vector_abi_kind
39 /* The tdep structure. */
41 struct s390_gdbarch_tdep
: gdbarch_tdep_base
43 /* Target description. */
44 const struct target_desc
*tdesc
= nullptr;
47 enum s390_abi_kind abi
{};
50 enum s390_vector_abi_kind vector_abi
{};
52 /* Pseudo register numbers. */
53 int gpr_full_regnum
= 0;
56 int v0_full_regnum
= 0;
59 bool have_linux_v1
= 0;
60 bool have_linux_v2
= 0;
65 /* Hook to record OS specific systemcall. */
66 int (*s390_syscall_record
) (struct regcache
*regcache
, LONGEST svc_number
)
70 using s390_gdbarch_tdep_up
= std::unique_ptr
<s390_gdbarch_tdep
>;
72 /* Decoding S/390 instructions. */
74 /* Named opcode values for the S/390 instructions we recognize. Some
75 instructions have their opcode split across two fields; those are the
76 op1_* and op2_* enums. */
80 op1_lhi
= 0xa7, op2_lhi
= 0x08,
81 op1_lghi
= 0xa7, op2_lghi
= 0x09,
82 op1_lgfi
= 0xc0, op2_lgfi
= 0x01,
86 op1_ly
= 0xe3, op2_ly
= 0x58,
87 op1_lg
= 0xe3, op2_lg
= 0x04,
89 op1_lmy
= 0xeb, op2_lmy
= 0x98,
90 op1_lmg
= 0xeb, op2_lmg
= 0x04,
92 op1_sty
= 0xe3, op2_sty
= 0x50,
93 op1_stg
= 0xe3, op2_stg
= 0x24,
96 op1_stmy
= 0xeb, op2_stmy
= 0x90,
97 op1_stmg
= 0xeb, op2_stmg
= 0x24,
98 op1_aghi
= 0xa7, op2_aghi
= 0x0b,
99 op1_ahi
= 0xa7, op2_ahi
= 0x0a,
100 op1_agfi
= 0xc2, op2_agfi
= 0x08,
101 op1_afi
= 0xc2, op2_afi
= 0x09,
102 op1_algfi
= 0xc2, op2_algfi
= 0x0a,
103 op1_alfi
= 0xc2, op2_alfi
= 0x0b,
107 op1_ay
= 0xe3, op2_ay
= 0x5a,
108 op1_ag
= 0xe3, op2_ag
= 0x08,
109 op1_slgfi
= 0xc2, op2_slgfi
= 0x04,
110 op1_slfi
= 0xc2, op2_slfi
= 0x05,
114 op1_sy
= 0xe3, op2_sy
= 0x5b,
115 op1_sg
= 0xe3, op2_sg
= 0x09,
119 op1_lay
= 0xe3, op2_lay
= 0x71,
120 op1_larl
= 0xc0, op2_larl
= 0x00,
128 op1_bctg
= 0xe3, op2_bctg
= 0x46,
130 op1_bxhg
= 0xeb, op2_bxhg
= 0x44,
132 op1_bxleg
= 0xeb, op2_bxleg
= 0x45,
133 op1_bras
= 0xa7, op2_bras
= 0x05,
134 op1_brasl
= 0xc0, op2_brasl
= 0x05,
135 op1_brc
= 0xa7, op2_brc
= 0x04,
136 op1_brcl
= 0xc0, op2_brcl
= 0x04,
137 op1_brct
= 0xa7, op2_brct
= 0x06,
138 op1_brctg
= 0xa7, op2_brctg
= 0x07,
140 op1_brxhg
= 0xec, op2_brxhg
= 0x44,
142 op1_brxlg
= 0xec, op2_brxlg
= 0x45,
146 /* Hardware capabilities. */
148 #ifndef HWCAP_S390_HIGH_GPRS
149 #define HWCAP_S390_HIGH_GPRS 512
152 #ifndef HWCAP_S390_TE
153 #define HWCAP_S390_TE 1024
156 #ifndef HWCAP_S390_VX
157 #define HWCAP_S390_VX 2048
160 #ifndef HWCAP_S390_GS
161 #define HWCAP_S390_GS 16384
164 /* Register information. */
166 /* Program Status Word. */
167 #define S390_PSWM_REGNUM 0
168 #define S390_PSWA_REGNUM 1
169 /* General Purpose Registers. */
170 #define S390_R0_REGNUM 2
171 #define S390_R1_REGNUM 3
172 #define S390_R2_REGNUM 4
173 #define S390_R3_REGNUM 5
174 #define S390_R4_REGNUM 6
175 #define S390_R5_REGNUM 7
176 #define S390_R6_REGNUM 8
177 #define S390_R7_REGNUM 9
178 #define S390_R8_REGNUM 10
179 #define S390_R9_REGNUM 11
180 #define S390_R10_REGNUM 12
181 #define S390_R11_REGNUM 13
182 #define S390_R12_REGNUM 14
183 #define S390_R13_REGNUM 15
184 #define S390_R14_REGNUM 16
185 #define S390_R15_REGNUM 17
186 /* Access Registers. */
187 #define S390_A0_REGNUM 18
188 #define S390_A1_REGNUM 19
189 #define S390_A2_REGNUM 20
190 #define S390_A3_REGNUM 21
191 #define S390_A4_REGNUM 22
192 #define S390_A5_REGNUM 23
193 #define S390_A6_REGNUM 24
194 #define S390_A7_REGNUM 25
195 #define S390_A8_REGNUM 26
196 #define S390_A9_REGNUM 27
197 #define S390_A10_REGNUM 28
198 #define S390_A11_REGNUM 29
199 #define S390_A12_REGNUM 30
200 #define S390_A13_REGNUM 31
201 #define S390_A14_REGNUM 32
202 #define S390_A15_REGNUM 33
203 /* Floating Point Control Word. */
204 #define S390_FPC_REGNUM 34
205 /* Floating Point Registers. */
206 #define S390_F0_REGNUM 35
207 #define S390_F1_REGNUM 36
208 #define S390_F2_REGNUM 37
209 #define S390_F3_REGNUM 38
210 #define S390_F4_REGNUM 39
211 #define S390_F5_REGNUM 40
212 #define S390_F6_REGNUM 41
213 #define S390_F7_REGNUM 42
214 #define S390_F8_REGNUM 43
215 #define S390_F9_REGNUM 44
216 #define S390_F10_REGNUM 45
217 #define S390_F11_REGNUM 46
218 #define S390_F12_REGNUM 47
219 #define S390_F13_REGNUM 48
220 #define S390_F14_REGNUM 49
221 #define S390_F15_REGNUM 50
222 /* General Purpose Register Upper Halves. */
223 #define S390_R0_UPPER_REGNUM 51
224 #define S390_R1_UPPER_REGNUM 52
225 #define S390_R2_UPPER_REGNUM 53
226 #define S390_R3_UPPER_REGNUM 54
227 #define S390_R4_UPPER_REGNUM 55
228 #define S390_R5_UPPER_REGNUM 56
229 #define S390_R6_UPPER_REGNUM 57
230 #define S390_R7_UPPER_REGNUM 58
231 #define S390_R8_UPPER_REGNUM 59
232 #define S390_R9_UPPER_REGNUM 60
233 #define S390_R10_UPPER_REGNUM 61
234 #define S390_R11_UPPER_REGNUM 62
235 #define S390_R12_UPPER_REGNUM 63
236 #define S390_R13_UPPER_REGNUM 64
237 #define S390_R14_UPPER_REGNUM 65
238 #define S390_R15_UPPER_REGNUM 66
239 /* GNU/Linux-specific optional registers. */
240 #define S390_ORIG_R2_REGNUM 67
241 #define S390_LAST_BREAK_REGNUM 68
242 #define S390_SYSTEM_CALL_REGNUM 69
243 /* Transaction diagnostic block. */
244 #define S390_TDB_DWORD0_REGNUM 70
245 #define S390_TDB_ABORT_CODE_REGNUM 71
246 #define S390_TDB_CONFLICT_TOKEN_REGNUM 72
247 #define S390_TDB_ATIA_REGNUM 73
248 #define S390_TDB_R0_REGNUM 74
249 #define S390_TDB_R1_REGNUM 75
250 #define S390_TDB_R2_REGNUM 76
251 #define S390_TDB_R3_REGNUM 77
252 #define S390_TDB_R4_REGNUM 78
253 #define S390_TDB_R5_REGNUM 79
254 #define S390_TDB_R6_REGNUM 80
255 #define S390_TDB_R7_REGNUM 81
256 #define S390_TDB_R8_REGNUM 82
257 #define S390_TDB_R9_REGNUM 83
258 #define S390_TDB_R10_REGNUM 84
259 #define S390_TDB_R11_REGNUM 85
260 #define S390_TDB_R12_REGNUM 86
261 #define S390_TDB_R13_REGNUM 87
262 #define S390_TDB_R14_REGNUM 88
263 #define S390_TDB_R15_REGNUM 89
264 /* Vector registers. */
265 #define S390_V0_LOWER_REGNUM 90
266 #define S390_V1_LOWER_REGNUM 91
267 #define S390_V2_LOWER_REGNUM 92
268 #define S390_V3_LOWER_REGNUM 93
269 #define S390_V4_LOWER_REGNUM 94
270 #define S390_V5_LOWER_REGNUM 95
271 #define S390_V6_LOWER_REGNUM 96
272 #define S390_V7_LOWER_REGNUM 97
273 #define S390_V8_LOWER_REGNUM 98
274 #define S390_V9_LOWER_REGNUM 99
275 #define S390_V10_LOWER_REGNUM 100
276 #define S390_V11_LOWER_REGNUM 101
277 #define S390_V12_LOWER_REGNUM 102
278 #define S390_V13_LOWER_REGNUM 103
279 #define S390_V14_LOWER_REGNUM 104
280 #define S390_V15_LOWER_REGNUM 105
281 #define S390_V16_REGNUM 106
282 #define S390_V17_REGNUM 107
283 #define S390_V18_REGNUM 108
284 #define S390_V19_REGNUM 109
285 #define S390_V20_REGNUM 110
286 #define S390_V21_REGNUM 111
287 #define S390_V22_REGNUM 112
288 #define S390_V23_REGNUM 113
289 #define S390_V24_REGNUM 114
290 #define S390_V25_REGNUM 115
291 #define S390_V26_REGNUM 116
292 #define S390_V27_REGNUM 117
293 #define S390_V28_REGNUM 118
294 #define S390_V29_REGNUM 119
295 #define S390_V30_REGNUM 120
296 #define S390_V31_REGNUM 121
297 #define S390_GSD_REGNUM 122
298 #define S390_GSSM_REGNUM 123
299 #define S390_GSEPLA_REGNUM 124
300 #define S390_BC_GSD_REGNUM 125
301 #define S390_BC_GSSM_REGNUM 126
302 #define S390_BC_GSEPLA_REGNUM 127
304 #define S390_NUM_REGS 128
306 #define S390_NUM_GPRS 16
307 #define S390_NUM_FPRS 16
309 #define S390_MAX_INSTR_SIZE 6
311 /* Special register usage. */
312 #define S390_SP_REGNUM S390_R15_REGNUM
313 #define S390_RETADDR_REGNUM S390_R14_REGNUM
314 #define S390_FRAME_REGNUM S390_R11_REGNUM
316 /* Frame unwinding. */
318 extern struct value
*s390_trad_frame_prev_register
319 (const frame_info_ptr
&this_frame
, struct trad_frame_saved_reg saved_regs
[],
322 extern const struct target_desc
*tdesc_s390_linux32
;
323 extern const struct target_desc
*tdesc_s390x_linux64
;
325 #endif /* S390_TDEP_H */