1 /* Definitions of target machine for GNU compiler, for IBM S/390
2 Copyright (C) 1999-2017 Free Software Foundation, Inc.
3 Contributed by Hartmut Penner (hpenner@de.ibm.com) and
4 Ulrich Weigand (uweigand@de.ibm.com).
5 Andreas Krebbel (Andreas.Krebbel@de.ibm.com)
7 This file is part of GCC.
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
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
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/>. */
26 /* Optional architectural facilities supported by the processor. */
32 PF_LONG_DISPLACEMENT
= 4,
45 /* This is necessary to avoid a warning about comparing different enum
47 #define s390_tune_attr ((enum attr_cpu)(s390_tune > PROCESSOR_2964_Z13 ? PROCESSOR_2964_Z13 : s390_tune ))
49 /* These flags indicate that the generated code should run on a cpu
50 providing the respective hardware facility regardless of the
51 current cpu mode (ESA or z/Architecture). */
53 #define TARGET_CPU_IEEE_FLOAT \
54 (s390_arch_flags & PF_IEEE_FLOAT)
55 #define TARGET_CPU_IEEE_FLOAT_P(opts) \
56 (opts->x_s390_arch_flags & PF_IEEE_FLOAT)
57 #define TARGET_CPU_ZARCH \
58 (s390_arch_flags & PF_ZARCH)
59 #define TARGET_CPU_ZARCH_P(opts) \
60 (opts->x_s390_arch_flags & PF_ZARCH)
61 #define TARGET_CPU_LONG_DISPLACEMENT \
62 (s390_arch_flags & PF_LONG_DISPLACEMENT)
63 #define TARGET_CPU_LONG_DISPLACEMENT_P(opts) \
64 (opts->x_s390_arch_flags & PF_LONG_DISPLACEMENT)
65 #define TARGET_CPU_EXTIMM \
66 (s390_arch_flags & PF_EXTIMM)
67 #define TARGET_CPU_EXTIMM_P(opts) \
68 (opts->x_s390_arch_flags & PF_EXTIMM)
69 #define TARGET_CPU_DFP \
70 (s390_arch_flags & PF_DFP)
71 #define TARGET_CPU_DFP_P(opts) \
72 (opts->x_s390_arch_flags & PF_DFP)
73 #define TARGET_CPU_Z10 \
74 (s390_arch_flags & PF_Z10)
75 #define TARGET_CPU_Z10_P(opts) \
76 (opts->x_s390_arch_flags & PF_Z10)
77 #define TARGET_CPU_Z196 \
78 (s390_arch_flags & PF_Z196)
79 #define TARGET_CPU_Z196_P(opts) \
80 (opts->x_s390_arch_flags & PF_Z196)
81 #define TARGET_CPU_ZEC12 \
82 (s390_arch_flags & PF_ZEC12)
83 #define TARGET_CPU_ZEC12_P(opts) \
84 (opts->x_s390_arch_flags & PF_ZEC12)
85 #define TARGET_CPU_HTM \
86 (s390_arch_flags & PF_TX)
87 #define TARGET_CPU_HTM_P(opts) \
88 (opts->x_s390_arch_flags & PF_TX)
89 #define TARGET_CPU_Z13 \
90 (s390_arch_flags & PF_Z13)
91 #define TARGET_CPU_Z13_P(opts) \
92 (opts->x_s390_arch_flags & PF_Z13)
93 #define TARGET_CPU_VX \
94 (s390_arch_flags & PF_VX)
95 #define TARGET_CPU_VX_P(opts) \
96 (opts->x_s390_arch_flags & PF_VX)
97 #define TARGET_CPU_ARCH12 \
98 (s390_arch_flags & PF_ARCH12)
99 #define TARGET_CPU_ARCH12_P(opts) \
100 (opts->x_s390_arch_flags & PF_ARCH12)
101 #define TARGET_CPU_VXE \
102 (s390_arch_flags & PF_VXE)
103 #define TARGET_CPU_VXE_P(opts) \
104 (opts->x_s390_arch_flags & PF_VXE)
106 #define TARGET_HARD_FLOAT_P(opts) (!TARGET_SOFT_FLOAT_P(opts))
108 /* These flags indicate that the generated code should run on a cpu
109 providing the respective hardware facility when run in
110 z/Architecture mode. */
112 #define TARGET_LONG_DISPLACEMENT \
113 (TARGET_ZARCH && TARGET_CPU_LONG_DISPLACEMENT)
114 #define TARGET_LONG_DISPLACEMENT_P(opts) \
115 (TARGET_ZARCH_P (opts->x_target_flags) \
116 && TARGET_CPU_LONG_DISPLACEMENT_P (opts))
117 #define TARGET_EXTIMM \
118 (TARGET_ZARCH && TARGET_CPU_EXTIMM)
119 #define TARGET_EXTIMM_P(opts) \
120 (TARGET_ZARCH_P (opts->x_target_flags) && TARGET_CPU_EXTIMM_P (opts))
122 (TARGET_ZARCH && TARGET_CPU_DFP && TARGET_HARD_FLOAT)
123 #define TARGET_DFP_P(opts) \
124 (TARGET_ZARCH_P (opts->x_target_flags) && TARGET_CPU_DFP_P (opts) \
125 && TARGET_HARD_FLOAT_P (opts->x_target_flags))
127 (TARGET_ZARCH && TARGET_CPU_Z10)
128 #define TARGET_Z10_P(opts) \
129 (TARGET_ZARCH_P (opts->x_target_flags) && TARGET_CPU_Z10_P (opts))
130 #define TARGET_Z196 \
131 (TARGET_ZARCH && TARGET_CPU_Z196)
132 #define TARGET_Z196_P(opts) \
133 (TARGET_ZARCH_P (opts->x_target_flags) && TARGET_CPU_Z196_P (opts))
134 #define TARGET_ZEC12 \
135 (TARGET_ZARCH && TARGET_CPU_ZEC12)
136 #define TARGET_ZEC12_P(opts) \
137 (TARGET_ZARCH_P (opts->x_target_flags) && TARGET_CPU_ZEC12_P (opts))
138 #define TARGET_HTM (TARGET_OPT_HTM)
139 #define TARGET_HTM_P(opts) (TARGET_OPT_HTM_P (opts->x_target_flags))
141 (TARGET_ZARCH && TARGET_CPU_Z13)
142 #define TARGET_Z13_P(opts) \
143 (TARGET_ZARCH_P (opts->x_target_flags) && TARGET_CPU_Z13_P (opts))
145 (TARGET_ZARCH && TARGET_CPU_VX && TARGET_OPT_VX && TARGET_HARD_FLOAT)
146 #define TARGET_VX_P(opts) \
147 (TARGET_ZARCH_P (opts->x_target_flags) && TARGET_CPU_VX_P (opts) \
148 && TARGET_OPT_VX_P (opts->x_target_flags) \
149 && TARGET_HARD_FLOAT_P (opts->x_target_flags))
150 #define TARGET_ARCH12 (TARGET_ZARCH && TARGET_CPU_ARCH12)
151 #define TARGET_ARCH12_P(opts) \
152 (TARGET_ZARCH_P (opts->x_target_flags) && TARGET_CPU_ARCH12_P (opts))
154 (TARGET_VX && TARGET_CPU_VXE)
155 #define TARGET_VXE_P(opts) \
156 (TARGET_VX_P (opts) && TARGET_CPU_VXE_P (opts))
158 #ifdef HAVE_AS_MACHINE_MACHINEMODE
159 #define S390_USE_TARGET_ATTRIBUTE 1
161 #define S390_USE_TARGET_ATTRIBUTE 0
164 #ifdef HAVE_AS_ARCHITECTURE_MODIFIERS
165 #define S390_USE_ARCHITECTURE_MODIFIERS 1
167 #define S390_USE_ARCHITECTURE_MODIFIERS 0
170 #if S390_USE_TARGET_ATTRIBUTE
171 /* For switching between functions with different target attributes. */
172 #define SWITCHABLE_TARGET 1
175 #define TARGET_SUPPORTS_WIDE_INT 1
177 /* Use the ABI introduced with IBM z13:
178 - pass vector arguments <= 16 bytes in VRs
179 - align *all* vector types to 8 bytes */
180 #define TARGET_VX_ABI TARGET_VX
182 #define TARGET_AVOID_CMP_AND_BRANCH (s390_tune == PROCESSOR_2817_Z196)
184 /* Run-time target specification. */
186 /* Defaults for option flags defined only on some subtargets. */
187 #ifndef TARGET_TPF_PROFILING
188 #define TARGET_TPF_PROFILING 0
191 /* This will be overridden by OS headers. */
194 /* Target CPU builtins. */
195 #define TARGET_CPU_CPP_BUILTINS() s390_cpu_cpp_builtins (pfile)
197 #ifdef DEFAULT_TARGET_64BIT
198 #define TARGET_DEFAULT (MASK_64BIT | MASK_ZARCH | MASK_HARD_DFP \
199 | MASK_OPT_HTM | MASK_OPT_VX)
201 #define TARGET_DEFAULT 0
204 /* Support for configure-time defaults. */
205 #define OPTION_DEFAULT_SPECS \
206 { "mode", "%{!mesa:%{!mzarch:-m%(VALUE)}}" }, \
207 { "arch", "%{!march=*:-march=%(VALUE)}" }, \
208 { "tune", "%{!mtune=*:-mtune=%(VALUE)}" }
211 extern const char *s390_host_detect_local_cpu (int argc
, const char **argv
);
212 # define EXTRA_SPEC_FUNCTIONS \
213 { "local_cpu_detect", s390_host_detect_local_cpu },
215 #define MARCH_MTUNE_NATIVE_SPECS \
216 "%{mtune=native:%<mtune=native %:local_cpu_detect(tune)} " \
217 "%{march=native:%<march=native" \
218 " %:local_cpu_detect(arch %{mesa|mzarch:mesa_mzarch})}"
220 # define MARCH_MTUNE_NATIVE_SPECS ""
223 #ifdef DEFAULT_TARGET_64BIT
224 #define S390_TARGET_BITS_STRING "64"
226 #define S390_TARGET_BITS_STRING "31"
229 /* Defaulting rules. */
230 #define DRIVER_SELF_SPECS \
231 MARCH_MTUNE_NATIVE_SPECS, \
232 "%{!m31:%{!m64:-m" S390_TARGET_BITS_STRING "}}", \
233 "%{!mesa:%{!mzarch:%{m31:-mesa}%{m64:-mzarch}}}", \
234 "%{!march=*:-march=z900}"
236 /* Constants needed to control the TEST DATA CLASS (TDC) instruction. */
237 #define S390_TDC_POSITIVE_ZERO (1 << 11)
238 #define S390_TDC_NEGATIVE_ZERO (1 << 10)
239 #define S390_TDC_POSITIVE_NORMALIZED_BFP_NUMBER (1 << 9)
240 #define S390_TDC_NEGATIVE_NORMALIZED_BFP_NUMBER (1 << 8)
241 #define S390_TDC_POSITIVE_DENORMALIZED_BFP_NUMBER (1 << 7)
242 #define S390_TDC_NEGATIVE_DENORMALIZED_BFP_NUMBER (1 << 6)
243 #define S390_TDC_POSITIVE_INFINITY (1 << 5)
244 #define S390_TDC_NEGATIVE_INFINITY (1 << 4)
245 #define S390_TDC_POSITIVE_QUIET_NAN (1 << 3)
246 #define S390_TDC_NEGATIVE_QUIET_NAN (1 << 2)
247 #define S390_TDC_POSITIVE_SIGNALING_NAN (1 << 1)
248 #define S390_TDC_NEGATIVE_SIGNALING_NAN (1 << 0)
250 /* The following values are different for DFP. */
251 #define S390_TDC_POSITIVE_DENORMALIZED_DFP_NUMBER (1 << 9)
252 #define S390_TDC_NEGATIVE_DENORMALIZED_DFP_NUMBER (1 << 8)
253 #define S390_TDC_POSITIVE_NORMALIZED_DFP_NUMBER (1 << 7)
254 #define S390_TDC_NEGATIVE_NORMALIZED_DFP_NUMBER (1 << 6)
256 /* For signbit, the BFP-DFP-difference makes no difference. */
257 #define S390_TDC_SIGNBIT_SET (S390_TDC_NEGATIVE_ZERO \
258 | S390_TDC_NEGATIVE_NORMALIZED_BFP_NUMBER \
259 | S390_TDC_NEGATIVE_DENORMALIZED_BFP_NUMBER\
260 | S390_TDC_NEGATIVE_INFINITY \
261 | S390_TDC_NEGATIVE_QUIET_NAN \
262 | S390_TDC_NEGATIVE_SIGNALING_NAN )
264 #define S390_TDC_INFINITY (S390_TDC_POSITIVE_INFINITY \
265 | S390_TDC_NEGATIVE_INFINITY )
267 /* Target machine storage layout. */
269 /* Everything is big-endian. */
270 #define BITS_BIG_ENDIAN 1
271 #define BYTES_BIG_ENDIAN 1
272 #define WORDS_BIG_ENDIAN 1
274 #define STACK_SIZE_MODE (Pmode)
278 /* Width of a word, in units (bytes). */
279 #define UNITS_PER_WORD (TARGET_ZARCH ? 8 : 4)
281 /* Width of a pointer. To be used instead of UNITS_PER_WORD in
282 ABI-relevant contexts. This always matches
283 GET_MODE_SIZE (Pmode). */
284 #define UNITS_PER_LONG (TARGET_64BIT ? 8 : 4)
285 #define MIN_UNITS_PER_WORD 4
286 #define MAX_BITS_PER_WORD 64
289 /* In libgcc, UNITS_PER_WORD has ABI-relevant effects, e.g. whether
290 the library should export TImode functions or not. Thus, we have
291 to redefine UNITS_PER_WORD depending on __s390x__ for libgcc. */
293 #define UNITS_PER_WORD 8
295 #define UNITS_PER_WORD 4
299 /* Width of a pointer, in bits. */
300 #define POINTER_SIZE (TARGET_64BIT ? 64 : 32)
302 /* Allocation boundary (in *bits*) for storing arguments in argument list. */
303 #define PARM_BOUNDARY (TARGET_64BIT ? 64 : 32)
305 /* Boundary (in *bits*) on which stack pointer should be aligned. */
306 #define STACK_BOUNDARY 64
308 /* Allocation boundary (in *bits*) for the code of a function. */
309 #define FUNCTION_BOUNDARY 64
311 /* There is no point aligning anything to a rounder boundary than this. */
312 #define BIGGEST_ALIGNMENT 64
314 /* Alignment of field after `int : 0' in a structure. */
315 #define EMPTY_FIELD_BOUNDARY 32
317 /* Alignment on even addresses for LARL instruction. */
318 #define CONSTANT_ALIGNMENT(EXP, ALIGN) (ALIGN) < 16 ? 16 : (ALIGN)
319 #define DATA_ABI_ALIGNMENT(TYPE, ALIGN) (ALIGN) < 16 ? 16 : (ALIGN)
321 /* Alignment is not required by the hardware. */
322 #define STRICT_ALIGNMENT 0
324 /* Mode of stack savearea.
325 FUNCTION is VOIDmode because calling convention maintains SP.
326 BLOCK needs Pmode for SP.
327 NONLOCAL needs twice Pmode to maintain both backchain and SP. */
328 #define STACK_SAVEAREA_MODE(LEVEL) \
329 ((LEVEL) == SAVE_FUNCTION ? VOIDmode \
330 : (LEVEL) == SAVE_NONLOCAL ? (TARGET_64BIT ? OImode : TImode) : Pmode)
335 /* Sizes in bits of the source language data types. */
336 #define SHORT_TYPE_SIZE 16
337 #define INT_TYPE_SIZE 32
338 #define LONG_TYPE_SIZE (TARGET_64BIT ? 64 : 32)
339 #define LONG_LONG_TYPE_SIZE 64
340 #define FLOAT_TYPE_SIZE 32
341 #define DOUBLE_TYPE_SIZE 64
342 #define LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64)
344 /* Work around target_flags dependency in ada/targtyps.c. */
345 #define WIDEST_HARDWARE_FP_SIZE 64
347 /* We use "unsigned char" as default. */
348 #define DEFAULT_SIGNED_CHAR 0
351 /* Register usage. */
353 /* We have 16 general purpose registers (registers 0-15),
354 and 16 floating point registers (registers 16-31).
355 (On non-IEEE machines, we have only 4 fp registers.)
357 Amongst the general purpose registers, some are used
358 for specific purposes:
359 GPR 11: Hard frame pointer (if needed)
360 GPR 12: Global offset table pointer (if needed)
361 GPR 13: Literal pool base register
362 GPR 14: Return address register
363 GPR 15: Stack pointer
365 Registers 32-35 are 'fake' hard registers that do not
366 correspond to actual hardware:
367 Reg 32: Argument pointer
368 Reg 33: Condition code
369 Reg 34: Frame pointer
370 Reg 35: Return address pointer
372 Registers 36 and 37 are mapped to access registers
373 0 and 1, used to implement thread-local storage.
375 Reg 38-53: Vector registers v16-v31 */
377 #define FIRST_PSEUDO_REGISTER 54
379 /* Standard register usage. */
380 #define GENERAL_REGNO_P(N) ((int)(N) >= 0 && (N) < 16)
381 #define ADDR_REGNO_P(N) ((N) >= 1 && (N) < 16)
382 #define FP_REGNO_P(N) ((N) >= 16 && (N) < 32)
383 #define CC_REGNO_P(N) ((N) == 33)
384 #define FRAME_REGNO_P(N) ((N) == 32 || (N) == 34 || (N) == 35)
385 #define ACCESS_REGNO_P(N) ((N) == 36 || (N) == 37)
386 #define VECTOR_NOFP_REGNO_P(N) ((N) >= 38 && (N) <= 53)
387 #define VECTOR_REGNO_P(N) (FP_REGNO_P (N) || VECTOR_NOFP_REGNO_P (N))
389 #define GENERAL_REG_P(X) (REG_P (X) && GENERAL_REGNO_P (REGNO (X)))
390 #define ADDR_REG_P(X) (REG_P (X) && ADDR_REGNO_P (REGNO (X)))
391 #define FP_REG_P(X) (REG_P (X) && FP_REGNO_P (REGNO (X)))
392 #define CC_REG_P(X) (REG_P (X) && CC_REGNO_P (REGNO (X)))
393 #define FRAME_REG_P(X) (REG_P (X) && FRAME_REGNO_P (REGNO (X)))
394 #define ACCESS_REG_P(X) (REG_P (X) && ACCESS_REGNO_P (REGNO (X)))
395 #define VECTOR_NOFP_REG_P(X) (REG_P (X) && VECTOR_NOFP_REGNO_P (REGNO (X)))
396 #define VECTOR_REG_P(X) (REG_P (X) && VECTOR_REGNO_P (REGNO (X)))
398 /* Set up fixed registers and calling convention:
400 GPRs 0-5 are always call-clobbered,
401 GPRs 6-15 are always call-saved.
402 GPR 12 is fixed if used as GOT pointer.
403 GPR 13 is always fixed (as literal pool pointer).
404 GPR 14 is always fixed on S/390 machines (as return address).
405 GPR 15 is always fixed (as stack pointer).
406 The 'fake' hard registers are call-clobbered and fixed.
407 The access registers are call-saved and fixed.
409 On 31-bit, FPRs 18-19 are call-clobbered;
410 on 64-bit, FPRs 24-31 are call-clobbered.
411 The remaining FPRs are call-saved.
413 All non-FP vector registers are call-clobbered v16-v31. */
415 #define FIXED_REGISTERS \
431 #define CALL_USED_REGISTERS \
447 #define CALL_REALLY_USED_REGISTERS \
448 { 1, 1, 1, 1, /* r0 - r15 */ \
452 1, 1, 1, 1, /* f0 (16) - f15 (31) */ \
456 1, 1, 1, 1, /* arg, cc, fp, ret addr */ \
457 0, 0, /* a0 (36), a1 (37) */ \
458 1, 1, 1, 1, /* v16 (38) - v23 (45) */ \
460 1, 1, 1, 1, /* v24 (46) - v31 (53) */ \
463 /* Preferred register allocation order. */
464 #define REG_ALLOC_ORDER \
465 { 1, 2, 3, 4, 5, 0, 12, 11, 10, 9, 8, 7, 6, 14, 13, \
466 16, 17, 18, 19, 20, 21, 22, 23, \
467 24, 25, 26, 27, 28, 29, 30, 31, \
468 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, \
469 15, 32, 33, 34, 35, 36, 37 }
472 #define HARD_REGNO_RENAME_OK(FROM, TO) \
473 s390_hard_regno_rename_ok ((FROM), (TO))
475 /* Maximum number of registers to represent a value of mode MODE
476 in a register of class CLASS. */
477 #define CLASS_MAX_NREGS(CLASS, MODE) \
478 s390_class_max_nregs ((CLASS), (MODE))
480 #define CANNOT_CHANGE_MODE_CLASS(FROM, TO, CLASS) \
481 s390_cannot_change_mode_class ((FROM), (TO), (CLASS))
483 /* We can reverse a CC mode safely if we know whether it comes from a
484 floating point compare or not. With the vector modes it is encoded
486 FIXME: It might make sense to do this for other cc modes as well. */
487 #define REVERSIBLE_CC_MODE(MODE) \
488 ((MODE) == CCVIALLmode || (MODE) == CCVIANYmode \
489 || (MODE) == CCVFALLmode || (MODE) == CCVFANYmode)
491 /* Given a condition code and a mode, return the inverse condition. */
492 #define REVERSE_CONDITION(CODE, MODE) s390_reverse_condition (MODE, CODE)
495 /* Register classes. */
497 /* We use the following register classes:
498 GENERAL_REGS All general purpose registers
499 ADDR_REGS All general purpose registers except %r0
500 (These registers can be used in address generation)
501 FP_REGS All floating point registers
502 CC_REGS The condition code register
503 ACCESS_REGS The access registers
505 GENERAL_FP_REGS Union of GENERAL_REGS and FP_REGS
506 ADDR_FP_REGS Union of ADDR_REGS and FP_REGS
507 GENERAL_CC_REGS Union of GENERAL_REGS and CC_REGS
508 ADDR_CC_REGS Union of ADDR_REGS and CC_REGS
511 ALL_REGS All registers
513 Note that the 'fake' frame pointer and argument pointer registers
514 are included amongst the address registers here. */
518 NO_REGS
, CC_REGS
, ADDR_REGS
, GENERAL_REGS
, ACCESS_REGS
,
519 ADDR_CC_REGS
, GENERAL_CC_REGS
,
520 FP_REGS
, ADDR_FP_REGS
, GENERAL_FP_REGS
,
521 VEC_REGS
, ADDR_VEC_REGS
, GENERAL_VEC_REGS
,
522 ALL_REGS
, LIM_REG_CLASSES
524 #define N_REG_CLASSES (int) LIM_REG_CLASSES
526 #define REG_CLASS_NAMES \
527 { "NO_REGS", "CC_REGS", "ADDR_REGS", "GENERAL_REGS", "ACCESS_REGS", \
528 "ADDR_CC_REGS", "GENERAL_CC_REGS", \
529 "FP_REGS", "ADDR_FP_REGS", "GENERAL_FP_REGS", \
530 "VEC_REGS", "ADDR_VEC_REGS", "GENERAL_VEC_REGS", \
533 /* Class -> register mapping. */
534 #define REG_CLASS_CONTENTS \
536 { 0x00000000, 0x00000000 }, /* NO_REGS */ \
537 { 0x00000000, 0x00000002 }, /* CC_REGS */ \
538 { 0x0000fffe, 0x0000000d }, /* ADDR_REGS */ \
539 { 0x0000ffff, 0x0000000d }, /* GENERAL_REGS */ \
540 { 0x00000000, 0x00000030 }, /* ACCESS_REGS */ \
541 { 0x0000fffe, 0x0000000f }, /* ADDR_CC_REGS */ \
542 { 0x0000ffff, 0x0000000f }, /* GENERAL_CC_REGS */ \
543 { 0xffff0000, 0x00000000 }, /* FP_REGS */ \
544 { 0xfffffffe, 0x0000000d }, /* ADDR_FP_REGS */ \
545 { 0xffffffff, 0x0000000d }, /* GENERAL_FP_REGS */ \
546 { 0xffff0000, 0x003fffc0 }, /* VEC_REGS */ \
547 { 0xfffffffe, 0x003fffcd }, /* ADDR_VEC_REGS */ \
548 { 0xffffffff, 0x003fffcd }, /* GENERAL_VEC_REGS */ \
549 { 0xffffffff, 0x003fffff }, /* ALL_REGS */ \
552 /* In some case register allocation order is not enough for IRA to
553 generate a good code. The following macro (if defined) increases
554 cost of REGNO for a pseudo approximately by pseudo usage frequency
555 multiplied by the macro value.
557 We avoid usage of BASE_REGNUM by nonzero macro value because the
558 reload can decide not to use the hard register because some
559 constant was forced to be in memory. */
560 #define IRA_HARD_REGNO_ADD_COST_MULTIPLIER(regno) \
561 ((regno) != BASE_REGNUM ? 0.0 : 0.5)
563 /* Register -> class mapping. */
564 extern const enum reg_class regclass_map
[FIRST_PSEUDO_REGISTER
];
565 #define REGNO_REG_CLASS(REGNO) (regclass_map[REGNO])
567 /* ADDR_REGS can be used as base or index register. */
568 #define INDEX_REG_CLASS ADDR_REGS
569 #define BASE_REG_CLASS ADDR_REGS
571 /* Check whether REGNO is a hard register of the suitable class
572 or a pseudo register currently allocated to one such. */
573 #define REGNO_OK_FOR_INDEX_P(REGNO) \
574 (((REGNO) < FIRST_PSEUDO_REGISTER \
575 && REGNO_REG_CLASS ((REGNO)) == ADDR_REGS) \
576 || ADDR_REGNO_P (reg_renumber[REGNO]))
577 #define REGNO_OK_FOR_BASE_P(REGNO) REGNO_OK_FOR_INDEX_P (REGNO)
580 /* Stack layout and calling conventions. */
582 /* Our stack grows from higher to lower addresses. However, local variables
583 are accessed by positive offsets, and function arguments are stored at
584 increasing addresses. */
585 #define STACK_GROWS_DOWNWARD 1
586 #define FRAME_GROWS_DOWNWARD 1
587 /* #undef ARGS_GROW_DOWNWARD */
589 /* The basic stack layout looks like this: the stack pointer points
590 to the register save area for called functions. Above that area
591 is the location to place outgoing arguments. Above those follow
592 dynamic allocations (alloca), and finally the local variables. */
594 /* Offset from stack-pointer to first location of outgoing args. */
595 #define STACK_POINTER_OFFSET (TARGET_64BIT ? 160 : 96)
597 /* Offset within stack frame to start allocating local variables at. */
598 #define STARTING_FRAME_OFFSET 0
600 /* Offset from the stack pointer register to an item dynamically
601 allocated on the stack, e.g., by `alloca'. */
602 #define STACK_DYNAMIC_OFFSET(FUNDECL) \
603 (STACK_POINTER_OFFSET + crtl->outgoing_args_size)
605 /* Offset of first parameter from the argument pointer register value.
606 We have a fake argument pointer register that points directly to
607 the argument area. */
608 #define FIRST_PARM_OFFSET(FNDECL) 0
610 /* Defining this macro makes __builtin_frame_address(0) and
611 __builtin_return_address(0) work with -fomit-frame-pointer. */
612 #define INITIAL_FRAME_ADDRESS_RTX \
613 (plus_constant (Pmode, arg_pointer_rtx, -STACK_POINTER_OFFSET))
615 /* The return address of the current frame is retrieved
616 from the initial value of register RETURN_REGNUM.
617 For frames farther back, we use the stack slot where
618 the corresponding RETURN_REGNUM register was saved. */
619 #define DYNAMIC_CHAIN_ADDRESS(FRAME) \
620 (TARGET_PACKED_STACK ? \
621 plus_constant (Pmode, (FRAME), \
622 STACK_POINTER_OFFSET - UNITS_PER_LONG) : (FRAME))
624 /* For -mpacked-stack this adds 160 - 8 (96 - 4) to the output of
625 builtin_frame_address. Otherwise arg pointer -
626 STACK_POINTER_OFFSET would be returned for
627 __builtin_frame_address(0) what might result in an address pointing
628 somewhere into the middle of the local variables since the packed
629 stack layout generally does not need all the bytes in the register
631 #define FRAME_ADDR_RTX(FRAME) \
632 DYNAMIC_CHAIN_ADDRESS ((FRAME))
634 #define RETURN_ADDR_RTX(COUNT, FRAME) \
635 s390_return_addr_rtx ((COUNT), DYNAMIC_CHAIN_ADDRESS ((FRAME)))
637 /* In 31-bit mode, we need to mask off the high bit of return addresses. */
638 #define MASK_RETURN_ADDR (TARGET_64BIT ? constm1_rtx : GEN_INT (0x7fffffff))
641 /* Exception handling. */
643 /* Describe calling conventions for DWARF-2 exception handling. */
644 #define INCOMING_RETURN_ADDR_RTX gen_rtx_REG (Pmode, RETURN_REGNUM)
645 #define INCOMING_FRAME_SP_OFFSET STACK_POINTER_OFFSET
646 #define DWARF_FRAME_RETURN_COLUMN 14
648 /* Describe how we implement __builtin_eh_return. */
649 #define EH_RETURN_DATA_REGNO(N) ((N) < 4 ? (N) + 6 : INVALID_REGNUM)
650 #define EH_RETURN_HANDLER_RTX gen_rtx_MEM (Pmode, return_address_pointer_rtx)
652 /* Select a format to encode pointers in exception handling data. */
653 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \
655 ? ((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel | DW_EH_PE_sdata4 \
658 /* Register save slot alignment. */
659 #define DWARF_CIE_DATA_ALIGNMENT (-UNITS_PER_LONG)
661 /* Let the assembler generate debug line info. */
662 #define DWARF2_ASM_LINE_DEBUG_INFO 1
664 /* Define the dwarf register mapping.
667 #define DBX_REGISTER_NUMBER(regno) \
668 (((regno) >= 38 && (regno) <= 53) ? (regno) + 30 : (regno))
670 /* Frame registers. */
672 #define STACK_POINTER_REGNUM 15
673 #define FRAME_POINTER_REGNUM 34
674 #define HARD_FRAME_POINTER_REGNUM 11
675 #define ARG_POINTER_REGNUM 32
676 #define RETURN_ADDRESS_POINTER_REGNUM 35
678 /* The static chain must be call-clobbered, but not used for
679 function argument passing. As register 1 is clobbered by
680 the trampoline code, we only have one option. */
681 #define STATIC_CHAIN_REGNUM 0
683 /* Number of hardware registers that go into the DWARF-2 unwind info.
684 To avoid ABI incompatibility, this number must not change even as
685 'fake' hard registers are added or removed. */
686 #define DWARF_FRAME_REGISTERS 34
689 /* Frame pointer and argument pointer elimination. */
691 #define ELIMINABLE_REGS \
692 {{ FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM }, \
693 { FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM }, \
694 { ARG_POINTER_REGNUM, STACK_POINTER_REGNUM }, \
695 { ARG_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM }, \
696 { RETURN_ADDRESS_POINTER_REGNUM, STACK_POINTER_REGNUM }, \
697 { RETURN_ADDRESS_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM }, \
698 { BASE_REGNUM, BASE_REGNUM }}
700 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
701 (OFFSET) = s390_initial_elimination_offset ((FROM), (TO))
704 /* Stack arguments. */
706 /* We need current_function_outgoing_args to be valid. */
707 #define ACCUMULATE_OUTGOING_ARGS 1
710 /* Register arguments. */
712 typedef struct s390_arg_structure
714 int gprs
; /* gpr so far */
715 int fprs
; /* fpr so far */
716 int vrs
; /* vr so far */
720 #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, NN, N_NAMED_ARGS) \
721 ((CUM).gprs=0, (CUM).fprs=0, (CUM).vrs=0)
723 #define FIRST_VEC_ARG_REGNO 46
724 #define LAST_VEC_ARG_REGNO 53
726 /* Arguments can be placed in general registers 2 to 6, or in floating
727 point registers 0 and 2 for 31 bit and fprs 0, 2, 4 and 6 for 64
729 #define FUNCTION_ARG_REGNO_P(N) \
730 (((N) >=2 && (N) < 7) || (N) == 16 || (N) == 17 \
731 || (TARGET_64BIT && ((N) == 18 || (N) == 19)) \
732 || (TARGET_VX && ((N) >= FIRST_VEC_ARG_REGNO && (N) <= LAST_VEC_ARG_REGNO)))
735 /* Only gpr 2, fpr 0, and v24 are ever used as return registers. */
736 #define FUNCTION_VALUE_REGNO_P(N) \
737 ((N) == 2 || (N) == 16 \
738 || (TARGET_VX && (N) == FIRST_VEC_ARG_REGNO))
741 /* Function entry and exit. */
743 /* When returning from a function, the stack pointer does not matter. */
744 #define EXIT_IGNORE_STACK 1
749 #define FUNCTION_PROFILER(FILE, LABELNO) \
750 s390_function_profiler ((FILE), ((LABELNO)))
752 #define PROFILE_BEFORE_PROLOGUE 1
755 /* Trampolines for nested functions. */
757 #define TRAMPOLINE_SIZE (TARGET_64BIT ? 32 : 16)
758 #define TRAMPOLINE_ALIGNMENT BITS_PER_WORD
760 /* Addressing modes, and classification of registers for them. */
762 /* Recognize any constant value that is a valid address. */
763 #define CONSTANT_ADDRESS_P(X) 0
765 /* Maximum number of registers that can appear in a valid memory address. */
766 #define MAX_REGS_PER_ADDRESS 2
768 /* This definition replaces the formerly used 'm' constraint with a
769 different constraint letter in order to avoid changing semantics of
770 the 'm' constraint when accepting new address formats in
771 TARGET_LEGITIMATE_ADDRESS_P. The constraint letter defined here
772 must not be used in insn definitions or inline assemblies. */
773 #define TARGET_MEM_CONSTRAINT 'e'
775 /* Try a machine-dependent way of reloading an illegitimate address
776 operand. If we find one, push the reload and jump to WIN. This
777 macro is used in only one place: `find_reloads_address' in reload.c. */
778 #define LEGITIMIZE_RELOAD_ADDRESS(AD, MODE, OPNUM, TYPE, IND, WIN) \
780 rtx new_rtx = legitimize_reload_address ((AD), (MODE), \
781 (OPNUM), (int)(TYPE)); \
789 /* Helper macro for s390.c and s390.md to check for symbolic constants. */
790 #define SYMBOLIC_CONST(X) \
791 (GET_CODE (X) == SYMBOL_REF \
792 || GET_CODE (X) == LABEL_REF \
793 || (GET_CODE (X) == CONST && symbolic_reference_mentioned_p (X)))
795 #define TLS_SYMBOLIC_CONST(X) \
796 ((GET_CODE (X) == SYMBOL_REF && tls_symbolic_operand (X)) \
797 || (GET_CODE (X) == CONST && tls_symbolic_reference_mentioned_p (X)))
800 /* Condition codes. */
802 /* Given a comparison code (EQ, NE, etc.) and the first operand of a COMPARE,
803 return the mode to be used for the comparison. */
804 #define SELECT_CC_MODE(OP, X, Y) s390_select_ccmode ((OP), (X), (Y))
806 /* Relative costs of operations. */
808 /* A C expression for the cost of a branch instruction. A value of 1
809 is the default; other values are interpreted relative to that. */
810 #define BRANCH_COST(speed_p, predictable_p) s390_branch_cost
812 /* Nonzero if access to memory by bytes is slow and undesirable. */
813 #define SLOW_BYTE_ACCESS 1
815 /* An integer expression for the size in bits of the largest integer machine
816 mode that should actually be used. We allow pairs of registers. */
817 #define MAX_FIXED_MODE_SIZE GET_MODE_BITSIZE (TARGET_64BIT ? TImode : DImode)
819 /* The maximum number of bytes that a single instruction can move quickly
820 between memory and registers or between two memory locations. */
821 #define MOVE_MAX (TARGET_ZARCH ? 16 : 8)
822 #define MOVE_MAX_PIECES (TARGET_ZARCH ? 8 : 4)
823 #define MAX_MOVE_MAX 16
825 /* Don't perform CSE on function addresses. */
826 #define NO_FUNCTION_CSE 1
828 /* This value is used in tree-sra to decide whether it might benefical
829 to split a struct move into several word-size moves. For S/390
830 only small values make sense here since struct moves are relatively
831 cheap thanks to mvc so the small default value chosen for archs
832 with memmove patterns should be ok. But this value is multiplied
833 in tree-sra with UNITS_PER_WORD to make a decision so we adjust it
834 here to compensate for that factor since mvc costs exactly the same
836 #define MOVE_RATIO(speed) (TARGET_64BIT? 2 : 4)
841 /* Output before read-only data. */
842 #define TEXT_SECTION_ASM_OP ".text"
844 /* Output before writable (initialized) data. */
845 #define DATA_SECTION_ASM_OP ".data"
847 /* Output before writable (uninitialized) data. */
848 #define BSS_SECTION_ASM_OP ".bss"
850 /* S/390 constant pool breaks the devices in crtstuff.c to control section
851 in where code resides. We have to write it as asm code. */
853 #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
856 0: .long\t" USER_LABEL_PREFIX #FUNC " - 0b\n\
858 bas\t%r14,0(%r3,%r2)\n\
863 /* Position independent code. */
865 #define PIC_OFFSET_TABLE_REGNUM (flag_pic ? 12 : INVALID_REGNUM)
867 #define LEGITIMATE_PIC_OPERAND_P(X) legitimate_pic_operand_p (X)
869 #ifndef TARGET_DEFAULT_PIC_DATA_IS_TEXT_RELATIVE
870 #define TARGET_DEFAULT_PIC_DATA_IS_TEXT_RELATIVE 1
874 /* Assembler file format. */
876 /* Character to start a comment. */
877 #define ASM_COMMENT_START "#"
879 /* Declare an uninitialized external linkage data object. */
880 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
881 asm_output_aligned_bss ((FILE), (DECL), (NAME), (SIZE), (ALIGN))
883 /* Globalizing directive for a label. */
884 #define GLOBAL_ASM_OP ".globl "
886 /* Advance the location counter to a multiple of 2**LOG bytes. */
887 #define ASM_OUTPUT_ALIGN(FILE, LOG) \
888 if ((LOG)) fprintf ((FILE), "\t.align\t%d\n", 1 << (LOG))
890 /* Advance the location counter by SIZE bytes. */
891 #define ASM_OUTPUT_SKIP(FILE, SIZE) \
892 fprintf ((FILE), "\t.set\t.,.+" HOST_WIDE_INT_PRINT_UNSIGNED"\n", (SIZE))
894 /* The LOCAL_LABEL_PREFIX variable is used by dbxelf.h. */
895 #define LOCAL_LABEL_PREFIX "."
897 #define LABEL_ALIGN(LABEL) \
898 s390_label_align ((LABEL))
900 /* How to refer to registers in assembler output. This sequence is
901 indexed by compiler's hard-register-number (see above). */
902 #define REGISTER_NAMES \
903 { "%r0", "%r1", "%r2", "%r3", "%r4", "%r5", "%r6", "%r7", \
904 "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15", \
905 "%f0", "%f2", "%f4", "%f6", "%f1", "%f3", "%f5", "%f7", \
906 "%f8", "%f10", "%f12", "%f14", "%f9", "%f11", "%f13", "%f15", \
907 "%ap", "%cc", "%fp", "%rp", "%a0", "%a1", \
908 "%v16", "%v18", "%v20", "%v22", "%v17", "%v19", "%v21", "%v23", \
909 "%v24", "%v26", "%v28", "%v30", "%v25", "%v27", "%v29", "%v31" \
912 #define ADDITIONAL_REGISTER_NAMES \
913 { { "v0", 16 }, { "v2", 17 }, { "v4", 18 }, { "v6", 19 }, \
914 { "v1", 20 }, { "v3", 21 }, { "v5", 22 }, { "v7", 23 }, \
915 { "v8", 24 }, { "v10", 25 }, { "v12", 26 }, { "v14", 27 }, \
916 { "v9", 28 }, { "v11", 29 }, { "v13", 30 }, { "v15", 31 } };
918 /* Print operand X (an rtx) in assembler syntax to file FILE. */
919 #define PRINT_OPERAND(FILE, X, CODE) print_operand ((FILE), (X), (CODE))
920 #define PRINT_OPERAND_ADDRESS(FILE, ADDR) print_operand_address ((FILE), (ADDR))
922 /* Output an element of a case-vector that is absolute. */
923 #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \
926 fputs (integer_asm_op (UNITS_PER_LONG, TRUE), (FILE)); \
927 ASM_GENERATE_INTERNAL_LABEL (buf, "L", (VALUE)); \
928 assemble_name ((FILE), buf); \
929 fputc ('\n', (FILE)); \
932 /* Output an element of a case-vector that is relative. */
933 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
936 fputs (integer_asm_op (UNITS_PER_LONG, TRUE), (FILE)); \
937 ASM_GENERATE_INTERNAL_LABEL (buf, "L", (VALUE)); \
938 assemble_name ((FILE), buf); \
939 fputc ('-', (FILE)); \
940 ASM_GENERATE_INTERNAL_LABEL (buf, "L", (REL)); \
941 assemble_name ((FILE), buf); \
942 fputc ('\n', (FILE)); \
945 /* Mark the return register as used by the epilogue so that we can
946 use it in unadorned (return) and (simple_return) instructions. */
947 #define EPILOGUE_USES(REGNO) ((REGNO) == RETURN_REGNUM)
949 #undef ASM_OUTPUT_FUNCTION_LABEL
950 #define ASM_OUTPUT_FUNCTION_LABEL(FILE, NAME, DECL) \
951 s390_asm_output_function_label ((FILE), (NAME), (DECL))
953 #if S390_USE_TARGET_ATTRIBUTE
954 /* Hook to output .machine and .machinemode at start of function. */
955 #undef ASM_OUTPUT_FUNCTION_PREFIX
956 #define ASM_OUTPUT_FUNCTION_PREFIX s390_asm_output_function_prefix
958 /* Hook to output .machine and .machinemode at end of function. */
959 #undef ASM_DECLARE_FUNCTION_SIZE
960 #define ASM_DECLARE_FUNCTION_SIZE s390_asm_declare_function_size
963 /* Miscellaneous parameters. */
965 /* Specify the machine mode that this machine uses for the index in the
966 tablejump instruction. */
967 #define CASE_VECTOR_MODE (TARGET_64BIT ? DImode : SImode)
969 /* Value is 1 if truncating an integer of INPREC bits to OUTPREC bits
970 is done just by pretending it is already truncated. */
971 #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
973 /* Specify the machine mode that pointers have.
974 After generation of rtl, the compiler makes no further distinction
975 between pointers and any other objects of this machine mode. */
976 #define Pmode (TARGET_64BIT ? DImode : SImode)
978 /* This is -1 for "pointer mode" extend. See ptr_extend in s390.md. */
979 #define POINTERS_EXTEND_UNSIGNED -1
981 /* A function address in a call instruction is a byte address (for
982 indexing purposes) so give the MEM rtx a byte's mode. */
983 #define FUNCTION_MODE QImode
985 /* Specify the value which is used when clz operand is zero. */
986 #define CLZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE) ((VALUE) = 64, 1)
988 /* Machine-specific symbol_ref flags. */
989 #define SYMBOL_FLAG_ALIGN_SHIFT SYMBOL_FLAG_MACH_DEP_SHIFT
990 #define SYMBOL_FLAG_ALIGN_MASK \
991 ((SYMBOL_FLAG_MACH_DEP << 0) | (SYMBOL_FLAG_MACH_DEP << 1))
993 #define SYMBOL_FLAG_SET_ALIGN(X, A) \
994 (SYMBOL_REF_FLAGS (X) = (SYMBOL_REF_FLAGS (X) & ~SYMBOL_FLAG_ALIGN_MASK) \
995 | (A << SYMBOL_FLAG_ALIGN_SHIFT))
997 #define SYMBOL_FLAG_GET_ALIGN(X) \
998 ((SYMBOL_REF_FLAGS (X) & SYMBOL_FLAG_ALIGN_MASK) >> SYMBOL_FLAG_ALIGN_SHIFT)
1000 /* Helpers to access symbol_ref flags. They are used in
1001 check_symref_alignment() and larl_operand to detect if the
1002 available alignment matches the required one. We do not use
1003 a positive check like _ALIGN2 because in that case we would have
1004 to annotate every symbol_ref. However, we only want to touch
1005 the symbol_refs that can be misaligned and assume that the others
1006 are correctly aligned. Hence, if a symbol_ref does not have
1007 a _NOTALIGN flag it is supposed to be correctly aligned. */
1008 #define SYMBOL_FLAG_SET_NOTALIGN2(X) SYMBOL_FLAG_SET_ALIGN((X), 1)
1009 #define SYMBOL_FLAG_SET_NOTALIGN4(X) SYMBOL_FLAG_SET_ALIGN((X), 2)
1010 #define SYMBOL_FLAG_SET_NOTALIGN8(X) SYMBOL_FLAG_SET_ALIGN((X), 3)
1012 #define SYMBOL_FLAG_NOTALIGN2_P(X) (SYMBOL_FLAG_GET_ALIGN(X) == 1)
1013 #define SYMBOL_FLAG_NOTALIGN4_P(X) (SYMBOL_FLAG_GET_ALIGN(X) == 2 \
1014 || SYMBOL_FLAG_GET_ALIGN(X) == 1)
1015 #define SYMBOL_FLAG_NOTALIGN8_P(X) (SYMBOL_FLAG_GET_ALIGN(X) == 3 \
1016 || SYMBOL_FLAG_GET_ALIGN(X) == 2 \
1017 || SYMBOL_FLAG_GET_ALIGN(X) == 1)
1019 /* Check whether integer displacement is in range for a short displacement. */
1020 #define SHORT_DISP_IN_RANGE(d) ((d) >= 0 && (d) <= 4095)
1022 /* Check whether integer displacement is in range. */
1023 #define DISP_IN_RANGE(d) \
1024 (TARGET_LONG_DISPLACEMENT \
1025 ? ((d) >= -524288 && (d) <= 524287) \
1026 : SHORT_DISP_IN_RANGE(d))
1028 /* Reads can reuse write prefetches, used by tree-ssa-prefetch-loops.c. */
1029 #define READ_CAN_USE_WRITE_PREFETCH 1
1031 extern const int processor_flags_table
[];
1033 /* The truth element value for vector comparisons. Our instructions
1034 always generate -1 in that case. */
1035 #define VECTOR_STORE_FLAG_VALUE(MODE) CONSTM1_RTX (GET_MODE_INNER (MODE))
1037 /* Target pragma. */
1039 /* resolve_overloaded_builtin can not be defined the normal way since
1040 it is defined in code which technically belongs to the
1042 #define REGISTER_TARGET_PRAGMAS() \
1044 s390_register_target_pragmas (); \