Debian Codegraph @

gcc/config/s390/s390.h

raw
1 /* Definitions of target machine for GNU compiler, for IBM S/390
2 Copyright (C) 1999-2025 Free Software Foundation, Inc.
3 Contributed by Hartmut Penner ([email protected]) and
4 Ulrich Weigand ([email protected]).
5 Andreas Krebbel ([email protected])
6
7 This file is part of GCC.
8
9 GCC is free software; you can redistribute it and/or modify it under
10 the terms of the GNU General Public License as published by the Free
11 Software Foundation; either version 3, or (at your option) any later
12 version.
13
14 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with GCC; see the file COPYING3. If not see
21 <http://www.gnu.org/licenses/>. */
22
23 #ifndef _S390_H
24 #define _S390_H
25
26 /* Optional architectural facilities supported by the processor. */
27
28 enum processor_flags
29 {
30 PF_IEEE_FLOAT = 1,
31 PF_ZARCH = 2,
32 PF_LONG_DISPLACEMENT = 4,
33 PF_EXTIMM = 8,
34 PF_DFP = 16,
35 PF_Z10 = 32,
36 PF_Z196 = 64,
37 PF_ZEC12 = 128,
38 PF_TX = 256,
39 PF_Z13 = 512,
40 PF_VX = 1024,
41 PF_Z14 = 2048,
42 PF_VXE = 4096,
43 PF_VXE2 = 8192,
44 PF_Z15 = 16384,
45 PF_NNPA = 32768,
46 PF_Z16 = 65536,
47 PF_VXE3 = 131072,
48 PF_Z17 = 262144
49 };
50
51 /* This is necessary to avoid a warning about comparing different enum
52 types. */
53 #define s390_tune_attr ((enum attr_cpu)(s390_tune > PROCESSOR_9175_Z17 ? PROCESSOR_9175_Z17 : s390_tune ))
54
55 /* These flags indicate that the generated code should run on a cpu
56 providing the respective hardware facility regardless of the
57 current cpu mode (ESA or z/Architecture). */
58
59 #define TARGET_CPU_IEEE_FLOAT \
60 (s390_arch_flags & PF_IEEE_FLOAT)
61 #define TARGET_CPU_IEEE_FLOAT_P(opts) \
62 (opts->x_s390_arch_flags & PF_IEEE_FLOAT)
63 #define TARGET_CPU_LONG_DISPLACEMENT \
64 (s390_arch_flags & PF_LONG_DISPLACEMENT)
65 #define TARGET_CPU_LONG_DISPLACEMENT_P(opts) \
66 (opts->x_s390_arch_flags & PF_LONG_DISPLACEMENT)
67 #define TARGET_CPU_EXTIMM \
68 (s390_arch_flags & PF_EXTIMM)
69 #define TARGET_CPU_EXTIMM_P(opts) \
70 (opts->x_s390_arch_flags & PF_EXTIMM)
71 #define TARGET_CPU_DFP \
72 (s390_arch_flags & PF_DFP)
73 #define TARGET_CPU_DFP_P(opts) \
74 (opts->x_s390_arch_flags & PF_DFP)
75 #define TARGET_CPU_Z10 \
76 (s390_arch_flags & PF_Z10)
77 #define TARGET_CPU_Z10_P(opts) \
78 (opts->x_s390_arch_flags & PF_Z10)
79 #define TARGET_CPU_Z196 \
80 (s390_arch_flags & PF_Z196)
81 #define TARGET_CPU_Z196_P(opts) \
82 (opts->x_s390_arch_flags & PF_Z196)
83 #define TARGET_CPU_ZEC12 \
84 (s390_arch_flags & PF_ZEC12)
85 #define TARGET_CPU_ZEC12_P(opts) \
86 (opts->x_s390_arch_flags & PF_ZEC12)
87 #define TARGET_CPU_HTM \
88 (s390_arch_flags & PF_TX)
89 #define TARGET_CPU_HTM_P(opts) \
90 (opts->x_s390_arch_flags & PF_TX)
91 #define TARGET_CPU_Z13 \
92 (s390_arch_flags & PF_Z13)
93 #define TARGET_CPU_Z13_P(opts) \
94 (opts->x_s390_arch_flags & PF_Z13)
95 #define TARGET_CPU_VX \
96 (s390_arch_flags & PF_VX)
97 #define TARGET_CPU_VX_P(opts) \
98 (opts->x_s390_arch_flags & PF_VX)
99 #define TARGET_CPU_Z14 \
100 (s390_arch_flags & PF_Z14)
101 #define TARGET_CPU_Z14_P(opts) \
102 (opts->x_s390_arch_flags & PF_Z14)
103 #define TARGET_CPU_VXE \
104 (s390_arch_flags & PF_VXE)
105 #define TARGET_CPU_VXE_P(opts) \
106 (opts->x_s390_arch_flags & PF_VXE)
107 #define TARGET_CPU_Z15 \
108 (s390_arch_flags & PF_Z15)
109 #define TARGET_CPU_Z15_P(opts) \
110 (opts->x_s390_arch_flags & PF_Z15)
111 #define TARGET_CPU_VXE2 \
112 (s390_arch_flags & PF_VXE2)
113 #define TARGET_CPU_VXE2_P(opts) \
114 (opts->x_s390_arch_flags & PF_VXE2)
115 #define TARGET_CPU_Z16 \
116 (s390_arch_flags & PF_Z16)
117 #define TARGET_CPU_Z16_P(opts) \
118 (opts->x_s390_arch_flags & PF_Z16)
119 #define TARGET_CPU_NNPA \
120 (s390_arch_flags & PF_NNPA)
121 #define TARGET_CPU_NNPA_P(opts) \
122 (opts->x_s390_arch_flags & PF_NNPA)
123 #define TARGET_CPU_VXE3 \
124 (s390_arch_flags & PF_VXE3)
125 #define TARGET_CPU_VXE3_P(opts) \
126 (opts->x_s390_arch_flags & PF_VXE3)
127 #define TARGET_CPU_Z17 \
128 (s390_arch_flags & PF_Z17)
129 #define TARGET_CPU_Z17_P(opts) \
130 (opts->x_s390_arch_flags & PF_Z17)
131
132 #define TARGET_HARD_FLOAT_P(opts) (!TARGET_SOFT_FLOAT_P(opts))
133
134 /* These flags indicate that the generated code should run on a cpu
135 providing the respective hardware facility when run in
136 z/Architecture mode. */
137
138 #define TARGET_LONG_DISPLACEMENT \
139 (TARGET_ZARCH && TARGET_CPU_LONG_DISPLACEMENT)
140 #define TARGET_LONG_DISPLACEMENT_P(opts) \
141 (TARGET_ZARCH_P (opts->x_target_flags) \
142 && TARGET_CPU_LONG_DISPLACEMENT_P (opts))
143 #define TARGET_EXTIMM \
144 (TARGET_ZARCH && TARGET_CPU_EXTIMM)
145 #define TARGET_EXTIMM_P(opts) \
146 (TARGET_ZARCH_P (opts->x_target_flags) && TARGET_CPU_EXTIMM_P (opts))
147 #define TARGET_DFP \
148 (TARGET_ZARCH && TARGET_CPU_DFP && TARGET_HARD_FLOAT)
149 #define TARGET_DFP_P(opts) \
150 (TARGET_ZARCH_P (opts->x_target_flags) && TARGET_CPU_DFP_P (opts) \
151 && TARGET_HARD_FLOAT_P (opts->x_target_flags))
152 #define TARGET_Z10 \
153 (TARGET_ZARCH && TARGET_CPU_Z10)
154 #define TARGET_Z10_P(opts) \
155 (TARGET_ZARCH_P (opts->x_target_flags) && TARGET_CPU_Z10_P (opts))
156 #define TARGET_Z196 \
157 (TARGET_ZARCH && TARGET_CPU_Z196)
158 #define TARGET_Z196_P(opts) \
159 (TARGET_ZARCH_P (opts->x_target_flags) && TARGET_CPU_Z196_P (opts))
160 #define TARGET_ZEC12 \
161 (TARGET_ZARCH && TARGET_CPU_ZEC12)
162 #define TARGET_ZEC12_P(opts) \
163 (TARGET_ZARCH_P (opts->x_target_flags) && TARGET_CPU_ZEC12_P (opts))
164 #define TARGET_HTM (TARGET_OPT_HTM)
165 #define TARGET_HTM_P(opts) (TARGET_OPT_HTM_P (opts->x_target_flags))
166 #define TARGET_Z13 \
167 (TARGET_ZARCH && TARGET_CPU_Z13)
168 #define TARGET_Z13_P(opts) \
169 (TARGET_ZARCH_P (opts->x_target_flags) && TARGET_CPU_Z13_P (opts))
170 #define TARGET_VX \
171 (TARGET_ZARCH && TARGET_CPU_VX && TARGET_OPT_VX && TARGET_HARD_FLOAT)
172 #define TARGET_VX_P(opts) \
173 (TARGET_ZARCH_P (opts->x_target_flags) && TARGET_CPU_VX_P (opts) \
174 && TARGET_OPT_VX_P (opts->x_target_flags) \
175 && TARGET_HARD_FLOAT_P (opts->x_target_flags))
176 #define TARGET_Z14 (TARGET_ZARCH && TARGET_CPU_Z14)
177 #define TARGET_Z14_P(opts) \
178 (TARGET_ZARCH_P (opts->x_target_flags) && TARGET_CPU_Z14_P (opts))
179 #define TARGET_VXE \
180 (TARGET_VX && TARGET_CPU_VXE)
181 #define TARGET_VXE_P(opts) \
182 (TARGET_VX_P (opts) && TARGET_CPU_VXE_P (opts))
183 #define TARGET_Z15 (TARGET_ZARCH && TARGET_CPU_Z15)
184 #define TARGET_Z15_P(opts) \
185 (TARGET_ZARCH_P (opts->x_target_flags) && TARGET_CPU_Z15_P (opts))
186 #define TARGET_VXE2 \
187 (TARGET_VX && TARGET_CPU_VXE2)
188 #define TARGET_VXE2_P(opts) \
189 (TARGET_VX_P (opts) && TARGET_CPU_VXE2_P (opts))
190 #define TARGET_Z16 (TARGET_ZARCH && TARGET_CPU_Z16)
191 #define TARGET_Z16_P(opts) \
192 (TARGET_ZARCH_P (opts->x_target_flags) && TARGET_CPU_Z16_P (opts))
193 #define TARGET_NNPA \
194 (TARGET_ZARCH && TARGET_CPU_NNPA)
195 #define TARGET_NNPA_P(opts) \
196 (TARGET_ZARCH_P (opts) && TARGET_CPU_NNPA_P (opts))
197 #define TARGET_VXE3 \
198 (TARGET_VX && TARGET_CPU_VXE3)
199 #define TARGET_VXE3_P(opts) \
200 (TARGET_VX_P (opts) && TARGET_CPU_VXE3_P (opts))
201 #define TARGET_Z17 (TARGET_ZARCH && TARGET_CPU_Z17)
202 #define TARGET_Z17_P(opts) \
203 (TARGET_ZARCH_P (opts->x_target_flags) && TARGET_CPU_Z17_P (opts))
204
205 #if defined(HAVE_AS_VECTOR_LOADSTORE_ALIGNMENT_HINTS_ON_Z13)
206 #define TARGET_VECTOR_LOADSTORE_ALIGNMENT_HINTS TARGET_Z13
207 #elif defined(HAVE_AS_VECTOR_LOADSTORE_ALIGNMENT_HINTS)
208 #define TARGET_VECTOR_LOADSTORE_ALIGNMENT_HINTS TARGET_Z14
209 #else
210 #define TARGET_VECTOR_LOADSTORE_ALIGNMENT_HINTS 0
211 #endif
212
213 /* Evaluate to true if it is ok to emit a non-signaling vector
214 comparison. */
215 #define TARGET_NONSIGNALING_VECTOR_COMPARE_OK \
216 (TARGET_VX && !TARGET_VXE && (flag_finite_math_only || !flag_trapping_math))
217
218 #ifdef HAVE_AS_MACHINE_MACHINEMODE
219 #define S390_USE_TARGET_ATTRIBUTE 1
220 #else
221 #define S390_USE_TARGET_ATTRIBUTE 0
222 #endif
223
224 #ifdef HAVE_AS_ARCHITECTURE_MODIFIERS
225 #define S390_USE_ARCHITECTURE_MODIFIERS 1
226 #else
227 #define S390_USE_ARCHITECTURE_MODIFIERS 0
228 #endif
229
230 #if S390_USE_TARGET_ATTRIBUTE
231 /* For switching between functions with different target attributes. */
232 #define SWITCHABLE_TARGET 1
233 #endif
234
235 #define TARGET_SUPPORTS_WIDE_INT 1
236
237 /* Use the ABI introduced with IBM z13:
238 - pass vector arguments <= 16 bytes in VRs
239 - align *all* vector types to 8 bytes */
240 #define TARGET_VX_ABI TARGET_VX
241
242 #define TARGET_AVOID_CMP_AND_BRANCH (s390_tune == PROCESSOR_2817_Z196)
243
244 /* Issue a write prefetch for the +4 cache line. */
245 #define TARGET_SETMEM_PREFETCH_DISTANCE 1024
246
247 /* Expand to a C expressions evaluating to true if a setmem to VAL of
248 length LEN should be emitted using prefetch instructions. */
249 #define TARGET_SETMEM_PFD(VAL,LEN) \
250 (TARGET_Z10 \
251 && (s390_tune < PROCESSOR_2964_Z13 || (VAL) != const0_rtx) \
252 && (!CONST_INT_P (LEN) || INTVAL ((LEN)) > TARGET_SETMEM_PREFETCH_DISTANCE))
253
254 /* Run-time target specification. */
255
256 /* Defaults for option flags defined only on some subtargets. */
257 #ifndef TARGET_TPF_PROFILING
258 #define TARGET_TPF_PROFILING 0
259 #endif
260
261 /* This will be overridden by OS headers. */
262 #define TARGET_TPF 0
263
264 /* Target CPU builtins. */
265 #define TARGET_CPU_CPP_BUILTINS() s390_cpu_cpp_builtins (pfile)
266
267 #ifdef DEFAULT_TARGET_64BIT
268 #define TARGET_DEFAULT (MASK_64BIT | MASK_ZARCH | MASK_HARD_DFP \
269 | MASK_OPT_HTM | MASK_OPT_VX)
270 #else
271 #define TARGET_DEFAULT 0
272 #endif
273
274 /* Support for configure-time defaults.
275 The order here is important so that -march doesn't squash the
276 tune values. */
277 #define OPTION_DEFAULT_SPECS \
278 { "mode", "%{!mesa:%{!mzarch:-m%(VALUE)}}" }, \
279 { "tune", "%{!mtune=*:%{!march=*:-mtune=%(VALUE)}}" }, \
280 { "arch", "%{!march=*:-march=%(VALUE)}" }
281
282 #ifdef __s390__
283 extern const char *s390_host_detect_local_cpu (int argc, const char **argv);
284 # define EXTRA_SPEC_FUNCTIONS \
285 { "local_cpu_detect", s390_host_detect_local_cpu },
286
287 #define MARCH_MTUNE_NATIVE_SPECS \
288 "%{mtune=native:%<mtune=native %:local_cpu_detect(tune)} " \
289 "%{march=native:%<march=native" \
290 " %:local_cpu_detect(arch %{mesa|mzarch:mesa_mzarch})}"
291 #else
292 # define MARCH_MTUNE_NATIVE_SPECS ""
293 #endif
294
295 #ifdef DEFAULT_TARGET_64BIT
296 #define S390_TARGET_BITS_STRING "64"
297 #else
298 #define S390_TARGET_BITS_STRING "31"
299 #endif
300
301 /* Defaulting rules. */
302 #define DRIVER_SELF_SPECS \
303 MARCH_MTUNE_NATIVE_SPECS, \
304 "%{!m31:%{!m64:-m" S390_TARGET_BITS_STRING "}}", \
305 "%{!mesa:%{!mzarch:%{m31:-mesa}%{m64:-mzarch}}}", \
306 "%{!march=*:-march=z900}"
307
308 /* Target machine storage layout. */
309
310 /* Everything is big-endian. */
311 #define BITS_BIG_ENDIAN 1
312 #define BYTES_BIG_ENDIAN 1
313 #define WORDS_BIG_ENDIAN 1
314
315 #define STACK_SIZE_MODE (Pmode)
316
317 /* Make the stack pointer to be moved downwards while issuing stack probes with
318 -fstack-check. We need this to prevent memory below the stack pointer from
319 being accessed. */
320 #define STACK_CHECK_MOVING_SP 1
321
322 #ifndef IN_LIBGCC2
323
324 /* Width of a word, in units (bytes). */
325 #define UNITS_PER_WORD (TARGET_ZARCH ? 8 : 4)
326
327 /* Width of a pointer. To be used instead of UNITS_PER_WORD in
328 ABI-relevant contexts. This always matches
329 GET_MODE_SIZE (Pmode). */
330 #define UNITS_PER_LONG (TARGET_64BIT ? 8 : 4)
331 #define MIN_UNITS_PER_WORD 4
332 #define MAX_BITS_PER_WORD 64
333 #else
334
335 /* In libgcc, UNITS_PER_WORD has ABI-relevant effects, e.g. whether
336 the library should export TImode functions or not. Thus, we have
337 to redefine UNITS_PER_WORD depending on __s390x__ for libgcc. */
338 #ifdef __s390x__
339 #define UNITS_PER_WORD 8
340 #else
341 #define UNITS_PER_WORD 4
342 #endif
343 #endif
344
345 /* Width of a pointer, in bits. */
346 #define POINTER_SIZE (TARGET_64BIT ? 64 : 32)
347
348 /* Allocation boundary (in *bits*) for storing arguments in argument list. */
349 #define PARM_BOUNDARY (TARGET_64BIT ? 64 : 32)
350
351 /* Boundary (in *bits*) on which stack pointer should be aligned. */
352 #define STACK_BOUNDARY 64
353
354 /* Allocation boundary (in *bits*) for the code of a function. */
355 #define FUNCTION_BOUNDARY 64
356
357 /* There is no point aligning anything to a rounder boundary than this. */
358 #define BIGGEST_ALIGNMENT 64
359
360 /* Alignment of field after `int : 0' in a structure. */
361 #define EMPTY_FIELD_BOUNDARY 32
362
363 /* Alignment on even addresses for LARL instruction. */
364 #define DATA_ABI_ALIGNMENT(TYPE, ALIGN) (ALIGN) < 16 ? 16 : (ALIGN)
365
366 /* Alignment is not required by the hardware. */
367 #define STRICT_ALIGNMENT 0
368
369 /* Mode of stack savearea.
370 FUNCTION is VOIDmode because calling convention maintains SP.
371 BLOCK needs Pmode for SP.
372 NONLOCAL needs twice Pmode to maintain both backchain and SP. */
373 #define STACK_SAVEAREA_MODE(LEVEL) \
374 ((LEVEL) == SAVE_FUNCTION ? VOIDmode \
375 : (LEVEL) == SAVE_NONLOCAL ? (TARGET_64BIT ? OImode : TImode) : Pmode)
376
377
378 /* Type layout. */
379
380 /* Sizes in bits of the source language data types. */
381 #define SHORT_TYPE_SIZE 16
382 #define INT_TYPE_SIZE 32
383 #define LONG_TYPE_SIZE (TARGET_64BIT ? 64 : 32)
384 #define LONG_LONG_TYPE_SIZE 64
385
386 /* Work around target_flags dependency in ada/targtyps.cc. */
387 #define WIDEST_HARDWARE_FP_SIZE 64
388
389 /* We use "unsigned char" as default. */
390 #define DEFAULT_SIGNED_CHAR 0
391
392
393 /* Register usage. */
394
395 /* We have 16 general purpose registers (registers 0-15),
396 and 16 floating point registers (registers 16-31).
397 (On non-IEEE machines, we have only 4 fp registers.)
398
399 Amongst the general purpose registers, some are used
400 for specific purposes:
401 GPR 11: Hard frame pointer (if needed)
402 GPR 12: Global offset table pointer (if needed)
403 GPR 13: Literal pool base register
404 GPR 14: Return address register
405 GPR 15: Stack pointer
406
407 Registers 32-35 are 'fake' hard registers that do not
408 correspond to actual hardware:
409 Reg 32: Argument pointer
410 Reg 33: Condition code
411 Reg 34: Frame pointer
412 Reg 35: Return address pointer
413
414 Registers 36 and 37 are mapped to access registers
415 0 and 1, used to implement thread-local storage.
416
417 Reg 38-53: Vector registers v16-v31 */
418
419 #define FIRST_PSEUDO_REGISTER 54
420
421 /* Standard register usage. */
422 #define GENERAL_REGNO_P(N) ((int)(N) >= 0 && (N) < 16)
423 #define ADDR_REGNO_P(N) ((N) >= 1 && (N) < 16)
424 #define FP_REGNO_P(N) ((N) >= 16 && (N) < 32)
425 #define CC_REGNO_P(N) ((N) == 33)
426 #define FRAME_REGNO_P(N) ((N) == 32 || (N) == 34 || (N) == 35)
427 #define ACCESS_REGNO_P(N) ((N) == 36 || (N) == 37)
428 #define VECTOR_NOFP_REGNO_P(N) ((N) >= 38 && (N) <= 53)
429 #define VECTOR_REGNO_P(N) (FP_REGNO_P (N) || VECTOR_NOFP_REGNO_P (N))
430
431 #define GENERAL_REG_P(X) (REG_P (X) && GENERAL_REGNO_P (REGNO (X)))
432 #define ADDR_REG_P(X) (REG_P (X) && ADDR_REGNO_P (REGNO (X)))
433 #define FP_REG_P(X) (REG_P (X) && FP_REGNO_P (REGNO (X)))
434 #define CC_REG_P(X) (REG_P (X) && CC_REGNO_P (REGNO (X)))
435 #define FRAME_REG_P(X) (REG_P (X) && FRAME_REGNO_P (REGNO (X)))
436 #define ACCESS_REG_P(X) (REG_P (X) && ACCESS_REGNO_P (REGNO (X)))
437 #define VECTOR_NOFP_REG_P(X) (REG_P (X) && VECTOR_NOFP_REGNO_P (REGNO (X)))
438 #define VECTOR_REG_P(X) (REG_P (X) && VECTOR_REGNO_P (REGNO (X)))
439
440 /* Set up fixed registers and calling convention:
441
442 GPRs 0-5 are always call-clobbered,
443 GPRs 6-15 are always call-saved.
444 GPR 12 is fixed if used as GOT pointer.
445 GPR 13 is always fixed (as literal pool pointer).
446 GPR 14 is always fixed on S/390 machines (as return address).
447 GPR 15 is always fixed (as stack pointer).
448 The 'fake' hard registers are call-clobbered and fixed.
449 The access registers are call-saved and fixed.
450
451 On 31-bit, FPRs 18-19 are call-clobbered;
452 on 64-bit, FPRs 24-31 are call-clobbered.
453 The remaining FPRs are call-saved.
454
455 All non-FP vector registers are call-clobbered v16-v31. */
456
457 #define FIXED_REGISTERS \
458 { 0, 0, 0, 0, \
459 0, 0, 0, 0, \
460 0, 0, 0, 0, \
461 0, 1, 1, 1, \
462 0, 0, 0, 0, \
463 0, 0, 0, 0, \
464 0, 0, 0, 0, \
465 0, 0, 0, 0, \
466 1, 1, 1, 1, \
467 1, 1, \
468 0, 0, 0, 0, \
469 0, 0, 0, 0, \
470 0, 0, 0, 0, \
471 0, 0, 0, 0 }
472
473 #define CALL_REALLY_USED_REGISTERS \
474 { 1, 1, 1, 1, /* r0 - r15 */ \
475 1, 1, 0, 0, \
476 0, 0, 0, 0, \
477 0, 0, 0, 0, \
478 1, 1, 1, 1, /* f0 (16) - f15 (31) */ \
479 1, 1, 1, 1, \
480 1, 1, 1, 1, \
481 1, 1, 1, 1, \
482 1, 1, 1, 1, /* arg, cc, fp, ret addr */ \
483 0, 0, /* a0 (36), a1 (37) */ \
484 1, 1, 1, 1, /* v16 (38) - v23 (45) */ \
485 1, 1, 1, 1, \
486 1, 1, 1, 1, /* v24 (46) - v31 (53) */ \
487 1, 1, 1, 1 }
488
489 /* Preferred register allocation order. */
490 #define REG_ALLOC_ORDER \
491 { 1, 2, 3, 4, 5, 0, 12, 11, 10, 9, 8, 7, 6, 14, 13, \
492 16, 17, 18, 19, 20, 21, 22, 23, \
493 24, 25, 26, 27, 28, 29, 30, 31, \
494 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, \
495 15, 32, 33, 34, 35, 36, 37 }
496
497
498 #define HARD_REGNO_RENAME_OK(FROM, TO) \
499 s390_hard_regno_rename_ok ((FROM), (TO))
500
501 /* Maximum number of registers to represent a value of mode MODE
502 in a register of class CLASS. */
503 #define CLASS_MAX_NREGS(CLASS, MODE) \
504 s390_class_max_nregs ((CLASS), (MODE))
505
506 /* We can reverse a CC mode safely if we know whether it comes from a
507 floating point compare or not. With the vector modes it is encoded
508 as part of the mode.
509 FIXME: It might make sense to do this for other cc modes as well. */
510 #define REVERSIBLE_CC_MODE(MODE) \
511 ((MODE) == CCVIALLmode || (MODE) == CCVIANYmode \
512 || (MODE) == CCVFALLmode || (MODE) == CCVFANYmode)
513
514 /* Given a condition code and a mode, return the inverse condition. */
515 #define REVERSE_CONDITION(CODE, MODE) s390_reverse_condition (MODE, CODE)
516
517
518 /* Register classes. */
519
520 /* We use the following register classes:
521 GENERAL_REGS All general purpose registers
522 ADDR_REGS All general purpose registers except %r0
523 (These registers can be used in address generation)
524 FP_REGS All floating point registers
525 CC_REGS The condition code register
526 ACCESS_REGS The access registers
527
528 GENERAL_FP_REGS Union of GENERAL_REGS and FP_REGS
529 ADDR_FP_REGS Union of ADDR_REGS and FP_REGS
530 GENERAL_CC_REGS Union of GENERAL_REGS and CC_REGS
531 ADDR_CC_REGS Union of ADDR_REGS and CC_REGS
532
533 NO_REGS No registers
534 ALL_REGS All registers
535
536 Note that the 'fake' frame pointer and argument pointer registers
537 are included amongst the address registers here. */
538
539 enum reg_class
540 {
541 NO_REGS, CC_REGS, ADDR_REGS, GENERAL_REGS, ACCESS_REGS,
542 ADDR_CC_REGS, GENERAL_CC_REGS,
543 FP_REGS, ADDR_FP_REGS, GENERAL_FP_REGS,
544 VEC_REGS, ADDR_VEC_REGS, GENERAL_VEC_REGS,
545 ALL_REGS, LIM_REG_CLASSES
546 };
547 #define N_REG_CLASSES (int) LIM_REG_CLASSES
548
549 #define REG_CLASS_NAMES \
550 { "NO_REGS", "CC_REGS", "ADDR_REGS", "GENERAL_REGS", "ACCESS_REGS", \
551 "ADDR_CC_REGS", "GENERAL_CC_REGS", \
552 "FP_REGS", "ADDR_FP_REGS", "GENERAL_FP_REGS", \
553 "VEC_REGS", "ADDR_VEC_REGS", "GENERAL_VEC_REGS", \
554 "ALL_REGS" }
555
556 /* Class -> register mapping. */
557 #define REG_CLASS_CONTENTS \
558 { \
559 { 0x00000000, 0x00000000 }, /* NO_REGS */ \
560 { 0x00000000, 0x00000002 }, /* CC_REGS */ \
561 { 0x0000fffe, 0x0000000d }, /* ADDR_REGS */ \
562 { 0x0000ffff, 0x0000000d }, /* GENERAL_REGS */ \
563 { 0x00000000, 0x00000030 }, /* ACCESS_REGS */ \
564 { 0x0000fffe, 0x0000000f }, /* ADDR_CC_REGS */ \
565 { 0x0000ffff, 0x0000000f }, /* GENERAL_CC_REGS */ \
566 { 0xffff0000, 0x00000000 }, /* FP_REGS */ \
567 { 0xfffffffe, 0x0000000d }, /* ADDR_FP_REGS */ \
568 { 0xffffffff, 0x0000000d }, /* GENERAL_FP_REGS */ \
569 { 0xffff0000, 0x003fffc0 }, /* VEC_REGS */ \
570 { 0xfffffffe, 0x003fffcd }, /* ADDR_VEC_REGS */ \
571 { 0xffffffff, 0x003fffcd }, /* GENERAL_VEC_REGS */ \
572 { 0xffffffff, 0x003fffff }, /* ALL_REGS */ \
573 }
574
575 /* In some case register allocation order is not enough for IRA to
576 generate a good code. The following macro (if defined) increases
577 cost of REGNO for a pseudo approximately by pseudo usage frequency
578 multiplied by the macro value.
579
580 We avoid usage of BASE_REGNUM by nonzero macro value because the
581 reload can decide not to use the hard register because some
582 constant was forced to be in memory. */
583 #define IRA_HARD_REGNO_ADD_COST_MULTIPLIER(regno) \
584 ((regno) != BASE_REGNUM ? 0.0 : 0.5)
585
586 /* Register -> class mapping. */
587 extern const enum reg_class regclass_map[FIRST_PSEUDO_REGISTER];
588 #define REGNO_REG_CLASS(REGNO) (regclass_map[REGNO])
589
590 /* ADDR_REGS can be used as base or index register. */
591 #define INDEX_REG_CLASS ADDR_REGS
592 #define BASE_REG_CLASS ADDR_REGS
593
594 /* Check whether REGNO is a hard register of the suitable class
595 or a pseudo register currently allocated to one such. */
596 #define REGNO_OK_FOR_INDEX_P(REGNO) \
597 (((REGNO) < FIRST_PSEUDO_REGISTER \
598 && REGNO_REG_CLASS ((REGNO)) == ADDR_REGS) \
599 || ADDR_REGNO_P (reg_renumber[REGNO]))
600 #define REGNO_OK_FOR_BASE_P(REGNO) REGNO_OK_FOR_INDEX_P (REGNO)
601
602
603 /* Stack layout and calling conventions. */
604
605 /* Our stack grows from higher to lower addresses. However, local variables
606 are accessed by positive offsets, and function arguments are stored at
607 increasing addresses. */
608 #define STACK_GROWS_DOWNWARD 1
609 #define FRAME_GROWS_DOWNWARD 1
610 /* #undef ARGS_GROW_DOWNWARD */
611
612 /* The basic stack layout looks like this: the stack pointer points
613 to the register save area for called functions. Above that area
614 is the location to place outgoing arguments. Above those follow
615 dynamic allocations (alloca), and finally the local variables. */
616
617 /* Offset from stack-pointer to first location of outgoing args. */
618 #define STACK_POINTER_OFFSET (TARGET_64BIT ? 160 : 96)
619
620 /* Offset from the stack pointer register to an item dynamically
621 allocated on the stack, e.g., by `alloca'. */
622 #define STACK_DYNAMIC_OFFSET(FUNDECL) \
623 (STACK_POINTER_OFFSET + crtl->outgoing_args_size)
624
625 /* Offset of first parameter from the argument pointer register value.
626 We have a fake argument pointer register that points directly to
627 the argument area. */
628 #define FIRST_PARM_OFFSET(FNDECL) 0
629
630 /* Defining this macro makes __builtin_frame_address(0) and
631 __builtin_return_address(0) work with -fomit-frame-pointer. */
632 #define INITIAL_FRAME_ADDRESS_RTX \
633 (plus_constant (Pmode, arg_pointer_rtx, -STACK_POINTER_OFFSET))
634
635 /* The return address of the current frame is retrieved
636 from the initial value of register RETURN_REGNUM.
637 For frames farther back, we use the stack slot where
638 the corresponding RETURN_REGNUM register was saved. */
639 #define DYNAMIC_CHAIN_ADDRESS(FRAME) \
640 (TARGET_PACKED_STACK ? \
641 plus_constant (Pmode, (FRAME), \
642 STACK_POINTER_OFFSET - UNITS_PER_LONG) : (FRAME))
643
644 /* For -mpacked-stack this adds 160 - 8 (96 - 4) to the output of
645 builtin_frame_address. Otherwise arg pointer -
646 STACK_POINTER_OFFSET would be returned for
647 __builtin_frame_address(0) what might result in an address pointing
648 somewhere into the middle of the local variables since the packed
649 stack layout generally does not need all the bytes in the register
650 save area. */
651 #define FRAME_ADDR_RTX(FRAME) \
652 DYNAMIC_CHAIN_ADDRESS ((FRAME))
653
654 #define RETURN_ADDR_RTX(COUNT, FRAME) \
655 s390_return_addr_rtx ((COUNT), DYNAMIC_CHAIN_ADDRESS ((FRAME)))
656
657 /* In 31-bit mode, we need to mask off the high bit of return addresses. */
658 #define MASK_RETURN_ADDR (TARGET_64BIT ? constm1_rtx : GEN_INT (0x7fffffff))
659
660
661 /* Exception handling. */
662
663 /* Describe calling conventions for DWARF-2 exception handling. */
664 #define INCOMING_RETURN_ADDR_RTX gen_rtx_REG (Pmode, RETURN_REGNUM)
665 #define INCOMING_FRAME_SP_OFFSET STACK_POINTER_OFFSET
666 #define DWARF_FRAME_RETURN_COLUMN 14
667
668 /* Describe how we implement __builtin_eh_return. */
669 #define EH_RETURN_DATA_REGNO(N) ((N) < 4 ? (N) + 6 : INVALID_REGNUM)
670 #define EH_RETURN_HANDLER_RTX gen_rtx_MEM (Pmode, return_address_pointer_rtx)
671
672 /* Select a format to encode pointers in exception handling data. */
673 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \
674 (flag_pic \
675 ? ((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel | DW_EH_PE_sdata4 \
676 : DW_EH_PE_absptr)
677
678 /* Register save slot alignment. */
679 #define DWARF_CIE_DATA_ALIGNMENT (-UNITS_PER_LONG)
680
681 /* Let the assembler generate debug line info. */
682 #define DWARF2_ASM_LINE_DEBUG_INFO 1
683
684 /* Define the dwarf register mapping.
685 v16-v31 -> 68-83
686 rX -> X otherwise */
687 #define DEBUGGER_REGNO(regno) \
688 (((regno) >= 38 && (regno) <= 53) ? (regno) + 30 : (regno))
689
690 /* Frame registers. */
691
692 #define STACK_POINTER_REGNUM 15
693 #define FRAME_POINTER_REGNUM 34
694 #define HARD_FRAME_POINTER_REGNUM 11
695 #define ARG_POINTER_REGNUM 32
696 #define RETURN_ADDRESS_POINTER_REGNUM 35
697
698 /* The static chain must be call-clobbered, but not used for
699 function argument passing. As register 1 is clobbered by
700 the trampoline code, we only have one option. */
701 #define STATIC_CHAIN_REGNUM 0
702
703 /* Number of hardware registers that go into the DWARF-2 unwind info.
704 To avoid ABI incompatibility, this number must not change even as
705 'fake' hard registers are added or removed. */
706 #define DWARF_FRAME_REGISTERS 34
707
708
709 /* Frame pointer and argument pointer elimination. */
710
711 #define ELIMINABLE_REGS \
712 {{ FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM }, \
713 { FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM }, \
714 { ARG_POINTER_REGNUM, STACK_POINTER_REGNUM }, \
715 { ARG_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM }, \
716 { RETURN_ADDRESS_POINTER_REGNUM, STACK_POINTER_REGNUM }, \
717 { RETURN_ADDRESS_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM }, \
718 { BASE_REGNUM, BASE_REGNUM }}
719
720 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
721 (OFFSET) = s390_initial_elimination_offset ((FROM), (TO))
722
723
724 /* Stack arguments. */
725
726 /* We need current_function_outgoing_args to be valid. */
727 #define ACCUMULATE_OUTGOING_ARGS 1
728
729
730 /* Register arguments. */
731
732 typedef struct s390_arg_structure
733 {
734 int gprs; /* gpr so far */
735 int fprs; /* fpr so far */
736 int vrs; /* vr so far */
737 }
738 CUMULATIVE_ARGS;
739
740 #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, NN, N_NAMED_ARGS) \
741 ((CUM).gprs=0, (CUM).fprs=0, (CUM).vrs=0)
742
743 #define FIRST_VEC_ARG_REGNO 46
744 #define LAST_VEC_ARG_REGNO 53
745
746 /* Arguments can be placed in general registers 2 to 6, or in floating
747 point registers 0 and 2 for 31 bit and fprs 0, 2, 4 and 6 for 64
748 bit. */
749 #define FUNCTION_ARG_REGNO_P(N) \
750 (((N) >=2 && (N) < 7) || (N) == 16 || (N) == 17 \
751 || (TARGET_64BIT && ((N) == 18 || (N) == 19)) \
752 || (TARGET_VX && ((N) >= FIRST_VEC_ARG_REGNO && (N) <= LAST_VEC_ARG_REGNO)))
753
754
755 /* Only gpr 2, fpr 0, and v24 are ever used as return registers. */
756 #define FUNCTION_VALUE_REGNO_P(N) \
757 ((N) == 2 || (N) == 16 \
758 || (TARGET_VX && (N) == FIRST_VEC_ARG_REGNO))
759
760
761 /* Function entry and exit. */
762
763 /* When returning from a function, the stack pointer does not matter. */
764 #define EXIT_IGNORE_STACK 1
765
766
767 /* Profiling. */
768
769 #define FUNCTION_PROFILER(FILE, LABELNO) \
770 s390_function_profiler ((FILE), ((LABELNO)))
771
772 #define PROFILE_BEFORE_PROLOGUE 1
773
774 #define NO_PROFILE_COUNTERS 1
775
776
777 /* Trampolines for nested functions. */
778
779 #define TRAMPOLINE_SIZE (TARGET_64BIT ? 32 : 16)
780 #define TRAMPOLINE_ALIGNMENT BITS_PER_WORD
781
782 /* Addressing modes, and classification of registers for them. */
783
784 /* Recognize any constant value that is a valid address. */
785 #define CONSTANT_ADDRESS_P(X) 0
786
787 /* Maximum number of registers that can appear in a valid memory address. */
788 #define MAX_REGS_PER_ADDRESS 2
789
790 /* This definition replaces the formerly used 'm' constraint with a
791 different constraint letter in order to avoid changing semantics of
792 the 'm' constraint when accepting new address formats in
793 TARGET_LEGITIMATE_ADDRESS_P. The constraint letter defined here
794 must not be used in insn definitions or inline assemblies. */
795 #define TARGET_MEM_CONSTRAINT 'e'
796
797 /* Try a machine-dependent way of reloading an illegitimate address
798 operand. If we find one, push the reload and jump to WIN. This
799 macro is used in only one place: `find_reloads_address' in reload.cc. */
800 #define LEGITIMIZE_RELOAD_ADDRESS(AD, MODE, OPNUM, TYPE, IND, WIN) \
801 do { \
802 rtx new_rtx = legitimize_reload_address ((AD), (MODE), \
803 (OPNUM), (int)(TYPE)); \
804 if (new_rtx) \
805 { \
806 (AD) = new_rtx; \
807 goto WIN; \
808 } \
809 } while (0)
810
811 /* Helper macro for s390.cc and s390.md to check for symbolic constants. */
812 #define SYMBOLIC_CONST(X) \
813 (GET_CODE (X) == SYMBOL_REF \
814 || GET_CODE (X) == LABEL_REF \
815 || (GET_CODE (X) == CONST && symbolic_reference_mentioned_p (X)))
816
817 #define TLS_SYMBOLIC_CONST(X) \
818 ((GET_CODE (X) == SYMBOL_REF && tls_symbolic_operand (X)) \
819 || (GET_CODE (X) == CONST && tls_symbolic_reference_mentioned_p (X)))
820
821
822 /* Condition codes. */
823
824 /* Given a comparison code (EQ, NE, etc.) and the first operand of a COMPARE,
825 return the mode to be used for the comparison. */
826 #define SELECT_CC_MODE(OP, X, Y) s390_select_ccmode ((OP), (X), (Y))
827
828 /* Relative costs of operations. */
829
830 /* A C expression for the cost of a branch instruction. A value of 1
831 is the default; other values are interpreted relative to that. */
832 #define BRANCH_COST(speed_p, predictable_p) s390_branch_cost
833
834 /* Nonzero if access to memory by bytes is slow and undesirable. */
835 #define SLOW_BYTE_ACCESS 1
836
837 /* An integer expression for the size in bits of the largest integer machine
838 mode that should actually be used. We allow pairs of registers. */
839 #define MAX_FIXED_MODE_SIZE GET_MODE_BITSIZE (TARGET_64BIT ? TImode : DImode)
840
841 /* The maximum number of bytes that a single instruction can move quickly
842 between memory and registers or between two memory locations. */
843 #define MOVE_MAX (TARGET_ZARCH ? 16 : 8)
844 #define MOVE_MAX_PIECES (TARGET_ZARCH ? 8 : 4)
845 #define MAX_MOVE_MAX 16
846
847 /* Don't perform CSE on function addresses. */
848 #define NO_FUNCTION_CSE 1
849
850 /* This value is used in tree-sra to decide whether it might benefical
851 to split a struct move into several word-size moves. For S/390
852 only small values make sense here since struct moves are relatively
853 cheap thanks to mvc so the small default value chosen for archs
854 with memmove patterns should be ok. But this value is multiplied
855 in tree-sra with UNITS_PER_WORD to make a decision so we adjust it
856 here to compensate for that factor since mvc costs exactly the same
857 on 31 and 64 bit. */
858 #define MOVE_RATIO(speed) (TARGET_64BIT? 2 : 4)
859
860
861 /* Sections. */
862
863 /* Output before read-only data. */
864 #define TEXT_SECTION_ASM_OP ".text"
865
866 /* Output before writable (initialized) data. */
867 #define DATA_SECTION_ASM_OP ".data"
868
869 /* Output before writable (uninitialized) data. */
870 #define BSS_SECTION_ASM_OP ".bss"
871
872 /* S/390 constant pool breaks the devices in crtstuff.c to control section
873 in where code resides. We have to write it as asm code. */
874 #ifndef __s390x__
875 #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
876 asm (SECTION_OP "\n\
877 bras\t%r2,1f\n\
878 0: .long\t" USER_LABEL_PREFIX #FUNC " - 0b\n\
879 1: l\t%r3,0(%r2)\n\
880 bas\t%r14,0(%r3,%r2)\n\
881 .previous");
882 #endif
883
884
885 /* Position independent code. */
886
887 #define PIC_OFFSET_TABLE_REGNUM (flag_pic ? 12 : INVALID_REGNUM)
888
889 #define LEGITIMATE_PIC_OPERAND_P(X) legitimate_pic_operand_p (X)
890
891 #ifndef TARGET_DEFAULT_PIC_DATA_IS_TEXT_RELATIVE
892 #define TARGET_DEFAULT_PIC_DATA_IS_TEXT_RELATIVE 1
893 #endif
894
895
896 /* Assembler file format. */
897
898 /* Character to start a comment. */
899 #define ASM_COMMENT_START "#"
900
901 /* Declare an uninitialized external linkage data object. */
902 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
903 asm_output_aligned_bss ((FILE), (DECL), (NAME), (SIZE), (ALIGN))
904
905 /* Globalizing directive for a label. */
906 #define GLOBAL_ASM_OP ".globl "
907
908 /* Advance the location counter to a multiple of 2**LOG bytes. */
909 #define ASM_OUTPUT_ALIGN(FILE, LOG) \
910 if ((LOG)) fprintf ((FILE), "\t.align\t%d\n", 1 << (LOG))
911
912 /* Advance the location counter by SIZE bytes. */
913 #define ASM_OUTPUT_SKIP(FILE, SIZE) \
914 fprintf ((FILE), "\t.set\t.,.+" HOST_WIDE_INT_PRINT_UNSIGNED"\n", (SIZE))
915
916 /* The LOCAL_LABEL_PREFIX variable is used by dbxelf.h. */
917 #define LOCAL_LABEL_PREFIX "."
918
919 #define LABEL_ALIGN(LABEL) \
920 s390_label_align ((LABEL))
921
922 /* How to refer to registers in assembler output. This sequence is
923 indexed by compiler's hard-register-number (see above). */
924 #define REGISTER_NAMES \
925 { "%r0", "%r1", "%r2", "%r3", "%r4", "%r5", "%r6", "%r7", \
926 "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15", \
927 "%f0", "%f2", "%f4", "%f6", "%f1", "%f3", "%f5", "%f7", \
928 "%f8", "%f10", "%f12", "%f14", "%f9", "%f11", "%f13", "%f15", \
929 "%ap", "%cc", "%fp", "%rp", "%a0", "%a1", \
930 "%v16", "%v18", "%v20", "%v22", "%v17", "%v19", "%v21", "%v23", \
931 "%v24", "%v26", "%v28", "%v30", "%v25", "%v27", "%v29", "%v31" \
932 }
933
934 #define ADDITIONAL_REGISTER_NAMES \
935 { { "v0", 16 }, { "v2", 17 }, { "v4", 18 }, { "v6", 19 }, \
936 { "v1", 20 }, { "v3", 21 }, { "v5", 22 }, { "v7", 23 }, \
937 { "v8", 24 }, { "v10", 25 }, { "v12", 26 }, { "v14", 27 }, \
938 { "v9", 28 }, { "v11", 29 }, { "v13", 30 }, { "v15", 31 } };
939
940 /* Print operand X (an rtx) in assembler syntax to file FILE. */
941 #define PRINT_OPERAND(FILE, X, CODE) print_operand ((FILE), (X), (CODE))
942 #define PRINT_OPERAND_ADDRESS(FILE, ADDR) print_operand_address ((FILE), (ADDR))
943
944 /* Output an element of a case-vector that is absolute. */
945 #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \
946 do { \
947 char buf[32]; \
948 fputs (integer_asm_op (UNITS_PER_LONG, TRUE), (FILE)); \
949 ASM_GENERATE_INTERNAL_LABEL (buf, "L", (VALUE)); \
950 assemble_name ((FILE), buf); \
951 fputc ('\n', (FILE)); \
952 } while (0)
953
954 /* Output an element of a case-vector that is relative. */
955 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
956 do { \
957 char buf[32]; \
958 fputs (integer_asm_op (UNITS_PER_LONG, TRUE), (FILE)); \
959 ASM_GENERATE_INTERNAL_LABEL (buf, "L", (VALUE)); \
960 assemble_name ((FILE), buf); \
961 fputc ('-', (FILE)); \
962 ASM_GENERATE_INTERNAL_LABEL (buf, "L", (REL)); \
963 assemble_name ((FILE), buf); \
964 fputc ('\n', (FILE)); \
965 } while (0)
966
967 /* Mark the return register as used by the epilogue so that we can
968 use it in unadorned (return) and (simple_return) instructions. */
969 #define EPILOGUE_USES(REGNO) ((REGNO) == RETURN_REGNUM)
970
971 #undef ASM_OUTPUT_FUNCTION_LABEL
972 #define ASM_OUTPUT_FUNCTION_LABEL(FILE, NAME, DECL) \
973 s390_asm_output_function_label ((FILE), (NAME), (DECL))
974
975 #if S390_USE_TARGET_ATTRIBUTE
976 /* Hook to output .machine and .machinemode at start of function. */
977 #undef ASM_OUTPUT_FUNCTION_PREFIX
978 #define ASM_OUTPUT_FUNCTION_PREFIX s390_asm_output_function_prefix
979
980 /* Hook to output .machine and .machinemode at end of function. */
981 #undef ASM_DECLARE_FUNCTION_SIZE
982 #define ASM_DECLARE_FUNCTION_SIZE s390_asm_declare_function_size
983 #endif
984
985 /* Miscellaneous parameters. */
986
987 /* Specify the machine mode that this machine uses for the index in the
988 tablejump instruction. */
989 #define CASE_VECTOR_MODE (TARGET_64BIT ? DImode : SImode)
990
991 /* Specify the machine mode that pointers have.
992 After generation of rtl, the compiler makes no further distinction
993 between pointers and any other objects of this machine mode. */
994 #define Pmode (TARGET_64BIT ? DImode : SImode)
995
996 /* This is -1 for "pointer mode" extend. See ptr_extend in s390.md. */
997 #define POINTERS_EXTEND_UNSIGNED -1
998
999 /* A function address in a call instruction is a byte address (for
1000 indexing purposes) so give the MEM rtx a byte's mode. */
1001 #define FUNCTION_MODE QImode
1002
1003 /* Specify the value which is used when clz operand is zero. */
1004 #define CLZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE) ((VALUE) = 64, 1)
1005
1006 /* Specify the value which is used when ctz operand is zero. */
1007 #define CTZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE) ((VALUE) = 64, 1)
1008
1009 /* Machine-specific symbol_ref flags. */
1010 #define SYMBOL_FLAG_ALIGN_SHIFT SYMBOL_FLAG_MACH_DEP_SHIFT
1011 #define SYMBOL_FLAG_ALIGN_MASK \
1012 ((SYMBOL_FLAG_MACH_DEP << 0) | (SYMBOL_FLAG_MACH_DEP << 1))
1013
1014 #define SYMBOL_FLAG_SET_ALIGN(X, A) \
1015 (SYMBOL_REF_FLAGS (X) = (SYMBOL_REF_FLAGS (X) & ~SYMBOL_FLAG_ALIGN_MASK) \
1016 | (A << SYMBOL_FLAG_ALIGN_SHIFT))
1017
1018 #define SYMBOL_FLAG_GET_ALIGN(X) \
1019 ((SYMBOL_REF_FLAGS (X) & SYMBOL_FLAG_ALIGN_MASK) >> SYMBOL_FLAG_ALIGN_SHIFT)
1020
1021 /* Helpers to access symbol_ref flags. They are used in
1022 check_symref_alignment() and larl_operand to detect if the
1023 available alignment matches the required one. We do not use
1024 a positive check like _ALIGN2 because in that case we would have
1025 to annotate every symbol_ref. However, we only want to touch
1026 the symbol_refs that can be misaligned and assume that the others
1027 are correctly aligned. Hence, if a symbol_ref does not have
1028 a _NOTALIGN flag it is supposed to be correctly aligned. */
1029 #define SYMBOL_FLAG_SET_NOTALIGN2(X) SYMBOL_FLAG_SET_ALIGN((X), 1)
1030 #define SYMBOL_FLAG_SET_NOTALIGN4(X) SYMBOL_FLAG_SET_ALIGN((X), 2)
1031 #define SYMBOL_FLAG_SET_NOTALIGN8(X) SYMBOL_FLAG_SET_ALIGN((X), 3)
1032
1033 #define SYMBOL_FLAG_NOTALIGN2_P(X) (SYMBOL_FLAG_GET_ALIGN(X) == 1)
1034 #define SYMBOL_FLAG_NOTALIGN4_P(X) (SYMBOL_FLAG_GET_ALIGN(X) == 2 \
1035 || SYMBOL_FLAG_GET_ALIGN(X) == 1)
1036 #define SYMBOL_FLAG_NOTALIGN8_P(X) (SYMBOL_FLAG_GET_ALIGN(X) == 3 \
1037 || SYMBOL_FLAG_GET_ALIGN(X) == 2 \
1038 || SYMBOL_FLAG_GET_ALIGN(X) == 1)
1039
1040 /* Check whether integer displacement is in range for a short displacement. */
1041 #define SHORT_DISP_IN_RANGE(d) ((d) >= 0 && (d) <= 4095)
1042
1043 /* Check whether integer displacement is in range. */
1044 #define DISP_IN_RANGE(d) \
1045 (TARGET_LONG_DISPLACEMENT \
1046 ? ((d) >= -524288 && (d) <= 524287) \
1047 : SHORT_DISP_IN_RANGE(d))
1048
1049 /* Reads can reuse write prefetches, used by tree-ssa-prefetch-loops.c. */
1050 #define READ_CAN_USE_WRITE_PREFETCH 1
1051
1052 extern const int processor_flags_table[];
1053
1054 struct s390_processor
1055 {
1056 /* The preferred name to be used in user visible output. */
1057 const char *const name;
1058 /* CPU name as it should be passed to Binutils via .machine */
1059 const char *const binutils_name;
1060 const enum processor_type processor;
1061 const struct processor_costs *cost;
1062 int arch_level;
1063 };
1064
1065 extern const struct s390_processor processor_table[];
1066
1067 /* The truth element value for vector comparisons. Our instructions
1068 always generate -1 in that case. */
1069 #define VECTOR_STORE_FLAG_VALUE(MODE) CONSTM1_RTX (GET_MODE_INNER (MODE))
1070
1071 /* Target pragma. */
1072
1073 /* resolve_overloaded_builtin cannot be defined the normal way since
1074 it is defined in code which technically belongs to the
1075 front-end. */
1076 #define REGISTER_TARGET_PRAGMAS() \
1077 do { \
1078 s390_register_target_pragmas (); \
1079 } while (0)
1080
1081 #ifndef USED_FOR_TARGET
1082 /* The following structure is embedded in the machine
1083 specific part of struct function. */
1084
1085 struct GTY (()) s390_frame_layout
1086 {
1087 /* Offset within stack frame. */
1088 HOST_WIDE_INT gprs_offset;
1089 HOST_WIDE_INT f0_offset;
1090 HOST_WIDE_INT f4_offset;
1091 HOST_WIDE_INT f8_offset;
1092 HOST_WIDE_INT backchain_offset;
1093
1094 /* Number of first and last gpr where slots in the register
1095 save area are reserved for. */
1096 int first_save_gpr_slot;
1097 int last_save_gpr_slot;
1098
1099 /* Location (FP register number) where GPRs (r0-r15) should
1100 be saved to.
1101 0 - does not need to be saved at all
1102 -1 - stack slot */
1103 #define SAVE_SLOT_NONE 0
1104 #define SAVE_SLOT_STACK -1
1105 signed char gpr_save_slots[16];
1106
1107 /* Number of first and last gpr to be saved, restored. */
1108 int first_save_gpr;
1109 int first_restore_gpr;
1110 int last_save_gpr;
1111 int last_restore_gpr;
1112
1113 /* Bits standing for floating point registers. Set, if the
1114 respective register has to be saved. Starting with reg 16 (f0)
1115 at the rightmost bit.
1116 Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
1117 fpr 15 13 11 9 14 12 10 8 7 5 3 1 6 4 2 0
1118 reg 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 */
1119 unsigned int fpr_bitmap;
1120
1121 /* Number of floating point registers f8-f15 which must be saved. */
1122 int high_fprs;
1123
1124 /* Set if return address needs to be saved.
1125 This flag is set by s390_return_addr_rtx if it could not use
1126 the initial value of r14 and therefore depends on r14 saved
1127 to the stack. */
1128 bool save_return_addr_p;
1129
1130 /* Size of stack frame. */
1131 HOST_WIDE_INT frame_size;
1132 };
1133
1134
1135 /* Define the structure for the machine field in struct function. */
1136
1137 struct GTY(()) machine_function
1138 {
1139 struct s390_frame_layout frame_layout;
1140
1141 /* Literal pool base register. */
1142 rtx base_reg;
1143
1144 bool has_landing_pad_p;
1145
1146 /* True if the current function may contain a tbegin clobbering
1147 FPRs. */
1148 bool tbegin_p;
1149
1150 /* For -fsplit-stack support: A stack local which holds a pointer to
1151 the stack arguments for a function with a variable number of
1152 arguments. This is set at the start of the function and is used
1153 to initialize the overflow_arg_area field of the va_list
1154 structure. */
1155 rtx split_stack_varargs_pointer;
1156
1157 enum indirect_branch indirect_branch_jump;
1158 enum indirect_branch indirect_branch_call;
1159
1160 enum indirect_branch function_return_mem;
1161 enum indirect_branch function_return_reg;
1162 };
1163 #endif
1164
1165 #define TARGET_INDIRECT_BRANCH_NOBP_RET_OPTION \
1166 (cfun->machine->function_return_reg != indirect_branch_keep \
1167 || cfun->machine->function_return_mem != indirect_branch_keep)
1168
1169 #define TARGET_INDIRECT_BRANCH_NOBP_RET \
1170 ((cfun->machine->function_return_reg != indirect_branch_keep \
1171 && !s390_return_addr_from_memory ()) \
1172 || (cfun->machine->function_return_mem != indirect_branch_keep \
1173 && s390_return_addr_from_memory ()))
1174
1175 #define TARGET_INDIRECT_BRANCH_NOBP_JUMP \
1176 (cfun->machine->indirect_branch_jump != indirect_branch_keep)
1177
1178 #define TARGET_INDIRECT_BRANCH_NOBP_JUMP_THUNK \
1179 (cfun->machine->indirect_branch_jump == indirect_branch_thunk \
1180 || cfun->machine->indirect_branch_jump == indirect_branch_thunk_extern)
1181
1182 #define TARGET_INDIRECT_BRANCH_NOBP_JUMP_INLINE_THUNK \
1183 (cfun->machine->indirect_branch_jump == indirect_branch_thunk_inline)
1184
1185 #define TARGET_INDIRECT_BRANCH_NOBP_CALL \
1186 (cfun->machine->indirect_branch_call != indirect_branch_keep)
1187
1188 #ifndef TARGET_DEFAULT_INDIRECT_BRANCH_TABLE
1189 #define TARGET_DEFAULT_INDIRECT_BRANCH_TABLE 0
1190 #endif
1191
1192 #define TARGET_INDIRECT_BRANCH_THUNK_NAME_EXRL "__s390_indirect_jump_r%d"
1193 #define TARGET_INDIRECT_BRANCH_THUNK_NAME_EX "__s390_indirect_jump_r%duse_r%d"
1194
1195 #define TARGET_INDIRECT_BRANCH_TABLE s390_indirect_branch_table
1196
1197 #ifdef GENERATOR_FILE
1198 /* gencondmd.cc is built before insn-flags.h. Use an arbitrary opaque value
1199 that cannot be optimized away by gen_insn. */
1200 #define HAVE_TF(icode) TARGET_HARD_FLOAT
1201 #else
1202 #define HAVE_TF(icode) (HAVE_##icode##_fpr || HAVE_##icode##_vr)
1203 #endif
1204
1205 /* Dispatcher for movtf. */
1206 #define EXPAND_MOVTF(icode) \
1207 do \
1208 { \
1209 if (TARGET_VXE) \
1210 emit_insn (gen_##icode##_vr (operands[0], operands[1])); \
1211 else \
1212 emit_insn (gen_##icode##_fpr (operands[0], operands[1])); \
1213 DONE; \
1214 } \
1215 while (false)
1216
1217 /* Like EXPAND_MOVTF, but also legitimizes operands. */
1218 #define EXPAND_TF(icode, nops) \
1219 do \
1220 { \
1221 const size_t __nops = (nops); \
1222 expand_operand ops[__nops]; \
1223 create_output_operand (&ops[0], operands[0], GET_MODE (operands[0])); \
1224 for (size_t i = 1; i < __nops; i++) \
1225 create_input_operand (&ops[i], operands[i], GET_MODE (operands[i])); \
1226 if (TARGET_VXE) \
1227 expand_insn (CODE_FOR_##icode##_vr, __nops, ops); \
1228 else \
1229 expand_insn (CODE_FOR_##icode##_fpr, __nops, ops); \
1230 DONE; \
1231 } \
1232 while (false)
1233
1234 #endif /* S390_H */