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