]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/config/s390/s390.h
Update copyright years.
[thirdparty/gcc.git] / gcc / config / s390 / s390.h
CommitLineData
4673c1a0 1/* Definitions of target machine for GNU compiler, for IBM S/390
aad93da1 2 Copyright (C) 1999-2017 Free Software Foundation, Inc.
4673c1a0 3 Contributed by Hartmut Penner (hpenner@de.ibm.com) and
0c0a8ea5 4 Ulrich Weigand (uweigand@de.ibm.com).
e68d6a13 5 Andreas Krebbel (Andreas.Krebbel@de.ibm.com)
4673c1a0 6
1e98c8f3 7This file is part of GCC.
4673c1a0 8
1e98c8f3 9GCC is free software; you can redistribute it and/or modify it under
10the terms of the GNU General Public License as published by the Free
038d1e19 11Software Foundation; either version 3, or (at your option) any later
1e98c8f3 12version.
13
14GCC is distributed in the hope that it will be useful, but WITHOUT ANY
15WARRANTY; without even the implied warranty of MERCHANTABILITY or
16FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17for more details.
4673c1a0 18
19You should have received a copy of the GNU General Public License
038d1e19 20along with GCC; see the file COPYING3. If not see
21<http://www.gnu.org/licenses/>. */
4673c1a0 22
23#ifndef _S390_H
24#define _S390_H
25
b8c0043c 26/* Optional architectural facilities supported by the processor. */
27
28enum processor_flags
29{
30 PF_IEEE_FLOAT = 1,
31 PF_ZARCH = 2,
163277cf 32 PF_LONG_DISPLACEMENT = 4,
0c2edaa7 33 PF_EXTIMM = 8,
a850370e 34 PF_DFP = 16,
33d033da 35 PF_Z10 = 32,
81769881 36 PF_Z196 = 64,
5ada7a14 37 PF_ZEC12 = 128,
cc79fcc9 38 PF_TX = 256,
39 PF_Z13 = 512,
40 PF_VX = 1024
b8c0043c 41};
42
23911610 43/* This is necessary to avoid a warning about comparing different enum
44 types. */
45#define s390_tune_attr ((enum attr_cpu)s390_tune)
46
e68d6a13 47/* These flags indicate that the generated code should run on a cpu
48 providing the respective hardware facility regardless of the
49 current cpu mode (ESA or z/Architecture). */
50
b8c0043c 51#define TARGET_CPU_IEEE_FLOAT \
52 (s390_arch_flags & PF_IEEE_FLOAT)
7a0cee35 53#define TARGET_CPU_IEEE_FLOAT_P(opts) \
54 (opts->x_s390_arch_flags & PF_IEEE_FLOAT)
b8c0043c 55#define TARGET_CPU_ZARCH \
56 (s390_arch_flags & PF_ZARCH)
7a0cee35 57#define TARGET_CPU_ZARCH_P(opts) \
58 (opts->x_s390_arch_flags & PF_ZARCH)
b8c0043c 59#define TARGET_CPU_LONG_DISPLACEMENT \
60 (s390_arch_flags & PF_LONG_DISPLACEMENT)
7a0cee35 61#define TARGET_CPU_LONG_DISPLACEMENT_P(opts) \
62 (opts->x_s390_arch_flags & PF_LONG_DISPLACEMENT)
163277cf 63#define TARGET_CPU_EXTIMM \
7a0cee35 64 (s390_arch_flags & PF_EXTIMM)
65#define TARGET_CPU_EXTIMM_P(opts) \
66 (opts->x_s390_arch_flags & PF_EXTIMM)
0c2edaa7 67#define TARGET_CPU_DFP \
7a0cee35 68 (s390_arch_flags & PF_DFP)
69#define TARGET_CPU_DFP_P(opts) \
70 (opts->x_s390_arch_flags & PF_DFP)
a850370e 71#define TARGET_CPU_Z10 \
7a0cee35 72 (s390_arch_flags & PF_Z10)
73#define TARGET_CPU_Z10_P(opts) \
74 (opts->x_s390_arch_flags & PF_Z10)
33d033da 75#define TARGET_CPU_Z196 \
7a0cee35 76 (s390_arch_flags & PF_Z196)
77#define TARGET_CPU_Z196_P(opts) \
78 (opts->x_s390_arch_flags & PF_Z196)
81769881 79#define TARGET_CPU_ZEC12 \
7a0cee35 80 (s390_arch_flags & PF_ZEC12)
81#define TARGET_CPU_ZEC12_P(opts) \
82 (opts->x_s390_arch_flags & PF_ZEC12)
5ada7a14 83#define TARGET_CPU_HTM \
7a0cee35 84 (s390_arch_flags & PF_TX)
85#define TARGET_CPU_HTM_P(opts) \
86 (opts->x_s390_arch_flags & PF_TX)
cc79fcc9 87#define TARGET_CPU_Z13 \
7a0cee35 88 (s390_arch_flags & PF_Z13)
89#define TARGET_CPU_Z13_P(opts) \
90 (opts->x_s390_arch_flags & PF_Z13)
cc79fcc9 91#define TARGET_CPU_VX \
92 (s390_arch_flags & PF_VX)
7a0cee35 93#define TARGET_CPU_VX_P(opts) \
94 (opts->x_s390_arch_flags & PF_VX)
95
96#define TARGET_HARD_FLOAT_P(opts) (!TARGET_SOFT_FLOAT_P(opts))
b8c0043c 97
e68d6a13 98/* These flags indicate that the generated code should run on a cpu
99 providing the respective hardware facility when run in
100 z/Architecture mode. */
101
b8c0043c 102#define TARGET_LONG_DISPLACEMENT \
7a0cee35 103 (TARGET_ZARCH && TARGET_CPU_LONG_DISPLACEMENT)
104#define TARGET_LONG_DISPLACEMENT_P(opts) \
105 (TARGET_ZARCH_P (opts->x_target_flags) \
106 && TARGET_CPU_LONG_DISPLACEMENT_P (opts))
163277cf 107#define TARGET_EXTIMM \
7a0cee35 108 (TARGET_ZARCH && TARGET_CPU_EXTIMM)
109#define TARGET_EXTIMM_P(opts) \
110 (TARGET_ZARCH_P (opts->x_target_flags) && TARGET_CPU_EXTIMM_P (opts))
0c2edaa7 111#define TARGET_DFP \
7a0cee35 112 (TARGET_ZARCH && TARGET_CPU_DFP && TARGET_HARD_FLOAT)
113#define TARGET_DFP_P(opts) \
114 (TARGET_ZARCH_P (opts->x_target_flags) && TARGET_CPU_DFP_P (opts) \
115 && TARGET_HARD_FLOAT_P (opts->x_target_flags))
a850370e 116#define TARGET_Z10 \
7a0cee35 117 (TARGET_ZARCH && TARGET_CPU_Z10)
118#define TARGET_Z10_P(opts) \
119 (TARGET_ZARCH_P (opts->x_target_flags) && TARGET_CPU_Z10_P (opts))
33d033da 120#define TARGET_Z196 \
7a0cee35 121 (TARGET_ZARCH && TARGET_CPU_Z196)
122#define TARGET_Z196_P(opts) \
123 (TARGET_ZARCH_P (opts->x_target_flags) && TARGET_CPU_Z196_P (opts))
81769881 124#define TARGET_ZEC12 \
7a0cee35 125 (TARGET_ZARCH && TARGET_CPU_ZEC12)
126#define TARGET_ZEC12_P(opts) \
127 (TARGET_ZARCH_P (opts->x_target_flags) && TARGET_CPU_ZEC12_P (opts))
ee2dbc39 128#define TARGET_HTM (TARGET_OPT_HTM)
7a0cee35 129#define TARGET_HTM_P(opts) (TARGET_OPT_HTM_P (opts->x_target_flags))
cc79fcc9 130#define TARGET_Z13 \
7a0cee35 131 (TARGET_ZARCH && TARGET_CPU_Z13)
132#define TARGET_Z13_P(opts) \
133 (TARGET_ZARCH_P (opts->x_target_flags) && TARGET_CPU_Z13_P (opts))
cc79fcc9 134#define TARGET_VX \
7a0cee35 135 (TARGET_ZARCH && TARGET_CPU_VX && TARGET_OPT_VX && TARGET_HARD_FLOAT)
136#define TARGET_VX_P(opts) \
137 (TARGET_ZARCH_P (opts->x_target_flags) && TARGET_CPU_VX_P (opts) \
138 && TARGET_OPT_VX_P (opts->x_target_flags) \
139 && TARGET_HARD_FLOAT_P (opts->x_target_flags))
140
141#ifdef HAVE_AS_MACHINE_MACHINEMODE
142#define S390_USE_TARGET_ATTRIBUTE 1
143#else
144#define S390_USE_TARGET_ATTRIBUTE 0
145#endif
146
147#ifdef HAVE_AS_ARCHITECTURE_MODIFIERS
148#define S390_USE_ARCHITECTURE_MODIFIERS 1
149#else
150#define S390_USE_ARCHITECTURE_MODIFIERS 0
151#endif
152
153#if S390_USE_TARGET_ATTRIBUTE
154/* For switching between functions with different target attributes. */
155#define SWITCHABLE_TARGET 1
156#endif
33d033da 157
ba0e61d6 158#define TARGET_SUPPORTS_WIDE_INT 1
159
cc79fcc9 160/* Use the ABI introduced with IBM z13:
161 - pass vector arguments <= 16 bytes in VRs
162 - align *all* vector types to 8 bytes */
163#define TARGET_VX_ABI TARGET_VX
33d033da 164
165#define TARGET_AVOID_CMP_AND_BRANCH (s390_tune == PROCESSOR_2817_Z196)
6c3a2301 166
7718b866 167/* Run-time target specification. */
4673c1a0 168
d2351d8b 169/* Defaults for option flags defined only on some subtargets. */
170#ifndef TARGET_TPF_PROFILING
171#define TARGET_TPF_PROFILING 0
172#endif
173
b33c41a1 174/* This will be overridden by OS headers. */
175#define TARGET_TPF 0
176
7718b866 177/* Target CPU builtins. */
07f32359 178#define TARGET_CPU_CPP_BUILTINS() s390_cpu_cpp_builtins (pfile)
4673c1a0 179
d50213e6 180#ifdef DEFAULT_TARGET_64BIT
cc79fcc9 181#define TARGET_DEFAULT (MASK_64BIT | MASK_ZARCH | MASK_HARD_DFP \
182 | MASK_OPT_HTM | MASK_OPT_VX)
d50213e6 183#else
0c2edaa7 184#define TARGET_DEFAULT 0
d50213e6 185#endif
186
b8c0043c 187/* Support for configure-time defaults. */
188#define OPTION_DEFAULT_SPECS \
189 { "mode", "%{!mesa:%{!mzarch:-m%(VALUE)}}" }, \
190 { "arch", "%{!march=*:-march=%(VALUE)}" }, \
191 { "tune", "%{!mtune=*:-mtune=%(VALUE)}" }
192
058194ac 193#ifdef __s390__
db249f37 194extern const char *s390_host_detect_local_cpu (int argc, const char **argv);
195# define EXTRA_SPEC_FUNCTIONS \
196 { "local_cpu_detect", s390_host_detect_local_cpu },
197
f369dcc9 198#define MARCH_MTUNE_NATIVE_SPECS \
199 "%{mtune=native:%<mtune=native %:local_cpu_detect(tune)} " \
200 "%{march=native:%<march=native" \
201 " %:local_cpu_detect(arch %{mesa|mzarch:mesa_mzarch})}"
058194ac 202#else
203# define MARCH_MTUNE_NATIVE_SPECS ""
204#endif
db249f37 205
b8c0043c 206#ifdef DEFAULT_TARGET_64BIT
f369dcc9 207#define S390_TARGET_BITS_STRING "64"
b8c0043c 208#else
f369dcc9 209#define S390_TARGET_BITS_STRING "31"
210#endif
211
212/* Defaulting rules. */
b8c0043c 213#define DRIVER_SELF_SPECS \
f369dcc9 214 MARCH_MTUNE_NATIVE_SPECS, \
215 "%{!m31:%{!m64:-m" S390_TARGET_BITS_STRING "}}", \
b8c0043c 216 "%{!mesa:%{!mzarch:%{m31:-mesa}%{m64:-mzarch}}}", \
3bd8520f 217 "%{!march=*:-march=z900}"
b8c0043c 218
27784c70 219/* Constants needed to control the TEST DATA CLASS (TDC) instruction. */
d1191819 220#define S390_TDC_POSITIVE_ZERO (1 << 11)
221#define S390_TDC_NEGATIVE_ZERO (1 << 10)
222#define S390_TDC_POSITIVE_NORMALIZED_BFP_NUMBER (1 << 9)
223#define S390_TDC_NEGATIVE_NORMALIZED_BFP_NUMBER (1 << 8)
224#define S390_TDC_POSITIVE_DENORMALIZED_BFP_NUMBER (1 << 7)
225#define S390_TDC_NEGATIVE_DENORMALIZED_BFP_NUMBER (1 << 6)
226#define S390_TDC_POSITIVE_INFINITY (1 << 5)
227#define S390_TDC_NEGATIVE_INFINITY (1 << 4)
228#define S390_TDC_POSITIVE_QUIET_NAN (1 << 3)
229#define S390_TDC_NEGATIVE_QUIET_NAN (1 << 2)
230#define S390_TDC_POSITIVE_SIGNALING_NAN (1 << 1)
231#define S390_TDC_NEGATIVE_SIGNALING_NAN (1 << 0)
232
233/* The following values are different for DFP. */
234#define S390_TDC_POSITIVE_DENORMALIZED_DFP_NUMBER (1 << 9)
235#define S390_TDC_NEGATIVE_DENORMALIZED_DFP_NUMBER (1 << 8)
236#define S390_TDC_POSITIVE_NORMALIZED_DFP_NUMBER (1 << 7)
237#define S390_TDC_NEGATIVE_NORMALIZED_DFP_NUMBER (1 << 6)
238
ffead1ca 239/* For signbit, the BFP-DFP-difference makes no difference. */
93f564d6 240#define S390_TDC_SIGNBIT_SET (S390_TDC_NEGATIVE_ZERO \
d1191819 241 | S390_TDC_NEGATIVE_NORMALIZED_BFP_NUMBER \
242 | S390_TDC_NEGATIVE_DENORMALIZED_BFP_NUMBER\
93f564d6 243 | S390_TDC_NEGATIVE_INFINITY \
244 | S390_TDC_NEGATIVE_QUIET_NAN \
245 | S390_TDC_NEGATIVE_SIGNALING_NAN )
246
27784c70 247#define S390_TDC_INFINITY (S390_TDC_POSITIVE_INFINITY \
248 | S390_TDC_NEGATIVE_INFINITY )
4673c1a0 249
250/* Target machine storage layout. */
251
7718b866 252/* Everything is big-endian. */
4673c1a0 253#define BITS_BIG_ENDIAN 1
4673c1a0 254#define BYTES_BIG_ENDIAN 1
4673c1a0 255#define WORDS_BIG_ENDIAN 1
256
b5fdc416 257#define STACK_SIZE_MODE (Pmode)
258
76a4c804 259/* Vector arguments are left-justified when placed on the stack during
260 parameter passing. */
261#define FUNCTION_ARG_PADDING(MODE, TYPE) \
262 (s390_function_arg_vector ((MODE), (TYPE)) \
263 ? upward \
264 : DEFAULT_FUNCTION_ARG_PADDING ((MODE), (TYPE)))
265
f553e2d1 266#ifndef IN_LIBGCC2
b5fdc416 267
268/* Width of a word, in units (bytes). */
269 #define UNITS_PER_WORD (TARGET_ZARCH ? 8 : 4)
270
271/* Width of a pointer. To be used instead of UNITS_PER_WORD in
272 ABI-relevant contexts. This always matches
273 GET_MODE_SIZE (Pmode). */
274 #define UNITS_PER_LONG (TARGET_64BIT ? 8 : 4)
275 #define MIN_UNITS_PER_WORD 4
276 #define MAX_BITS_PER_WORD 64
277#else
278
279 /* In libgcc, UNITS_PER_WORD has ABI-relevant effects, e.g. whether
280 the library should export TImode functions or not. Thus, we have
281 to redefine UNITS_PER_WORD depending on __s390x__ for libgcc. */
282 #ifdef __s390x__
283 #define UNITS_PER_WORD 8
284 #else
285 #define UNITS_PER_WORD 4
286 #endif
f553e2d1 287#endif
b5fdc416 288
289/* Width of a pointer, in bits. */
290#define POINTER_SIZE (TARGET_64BIT ? 64 : 32)
4673c1a0 291
4673c1a0 292/* Allocation boundary (in *bits*) for storing arguments in argument list. */
4673c1a0 293#define PARM_BOUNDARY (TARGET_64BIT ? 64 : 32)
294
295/* Boundary (in *bits*) on which stack pointer should be aligned. */
4673c1a0 296#define STACK_BOUNDARY 64
297
298/* Allocation boundary (in *bits*) for the code of a function. */
77bc9912 299#define FUNCTION_BOUNDARY 64
4673c1a0 300
301/* There is no point aligning anything to a rounder boundary than this. */
4673c1a0 302#define BIGGEST_ALIGNMENT 64
303
304/* Alignment of field after `int : 0' in a structure. */
4673c1a0 305#define EMPTY_FIELD_BOUNDARY 32
306
8ef587dc 307/* Alignment on even addresses for LARL instruction. */
4673c1a0 308#define CONSTANT_ALIGNMENT(EXP, ALIGN) (ALIGN) < 16 ? 16 : (ALIGN)
a16734cd 309#define DATA_ABI_ALIGNMENT(TYPE, ALIGN) (ALIGN) < 16 ? 16 : (ALIGN)
4673c1a0 310
7718b866 311/* Alignment is not required by the hardware. */
4673c1a0 312#define STRICT_ALIGNMENT 0
313
7718b866 314/* Mode of stack savearea.
315 FUNCTION is VOIDmode because calling convention maintains SP.
316 BLOCK needs Pmode for SP.
317 NONLOCAL needs twice Pmode to maintain both backchain and SP. */
55673549 318#define STACK_SAVEAREA_MODE(LEVEL) \
319 ((LEVEL) == SAVE_FUNCTION ? VOIDmode \
320 : (LEVEL) == SAVE_NONLOCAL ? (TARGET_64BIT ? OImode : TImode) : Pmode)
7718b866 321
4673c1a0 322
7718b866 323/* Type layout. */
4673c1a0 324
7718b866 325/* Sizes in bits of the source language data types. */
326#define SHORT_TYPE_SIZE 16
327#define INT_TYPE_SIZE 32
328#define LONG_TYPE_SIZE (TARGET_64BIT ? 64 : 32)
7718b866 329#define LONG_LONG_TYPE_SIZE 64
330#define FLOAT_TYPE_SIZE 32
331#define DOUBLE_TYPE_SIZE 64
429f9fdb 332#define LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64)
333
429f9fdb 334/* Work around target_flags dependency in ada/targtyps.c. */
335#define WIDEST_HARDWARE_FP_SIZE 64
7718b866 336
337/* We use "unsigned char" as default. */
338#define DEFAULT_SIGNED_CHAR 0
339
340
341/* Register usage. */
342
343/* We have 16 general purpose registers (registers 0-15),
344 and 16 floating point registers (registers 16-31).
345 (On non-IEEE machines, we have only 4 fp registers.)
f81e845f 346
7718b866 347 Amongst the general purpose registers, some are used
348 for specific purposes:
349 GPR 11: Hard frame pointer (if needed)
350 GPR 12: Global offset table pointer (if needed)
351 GPR 13: Literal pool base register
352 GPR 14: Return address register
353 GPR 15: Stack pointer
f81e845f 354
923cf36d 355 Registers 32-35 are 'fake' hard registers that do not
7718b866 356 correspond to actual hardware:
357 Reg 32: Argument pointer
358 Reg 33: Condition code
ffead1ca 359 Reg 34: Frame pointer
923cf36d 360 Reg 35: Return address pointer
7718b866 361
ffead1ca 362 Registers 36 and 37 are mapped to access registers
76a4c804 363 0 and 1, used to implement thread-local storage.
364
365 Reg 38-53: Vector registers v16-v31 */
923cf36d 366
76a4c804 367#define FIRST_PSEUDO_REGISTER 54
7718b866 368
369/* Standard register usage. */
25da9e9f 370#define GENERAL_REGNO_P(N) ((int)(N) >= 0 && (N) < 16)
371#define ADDR_REGNO_P(N) ((N) >= 1 && (N) < 16)
095798e3 372#define FP_REGNO_P(N) ((N) >= 16 && (N) < 32)
25da9e9f 373#define CC_REGNO_P(N) ((N) == 33)
7cbfc974 374#define FRAME_REGNO_P(N) ((N) == 32 || (N) == 34 || (N) == 35)
923cf36d 375#define ACCESS_REGNO_P(N) ((N) == 36 || (N) == 37)
76a4c804 376#define VECTOR_NOFP_REGNO_P(N) ((N) >= 38 && (N) <= 53)
377#define VECTOR_REGNO_P(N) (FP_REGNO_P (N) || VECTOR_NOFP_REGNO_P (N))
25da9e9f 378
379#define GENERAL_REG_P(X) (REG_P (X) && GENERAL_REGNO_P (REGNO (X)))
380#define ADDR_REG_P(X) (REG_P (X) && ADDR_REGNO_P (REGNO (X)))
381#define FP_REG_P(X) (REG_P (X) && FP_REGNO_P (REGNO (X)))
382#define CC_REG_P(X) (REG_P (X) && CC_REGNO_P (REGNO (X)))
ec3b9583 383#define FRAME_REG_P(X) (REG_P (X) && FRAME_REGNO_P (REGNO (X)))
923cf36d 384#define ACCESS_REG_P(X) (REG_P (X) && ACCESS_REGNO_P (REGNO (X)))
76a4c804 385#define VECTOR_NOFP_REG_P(X) (REG_P (X) && VECTOR_NOFP_REGNO_P (REGNO (X)))
386#define VECTOR_REG_P(X) (REG_P (X) && VECTOR_REGNO_P (REGNO (X)))
4673c1a0 387
7718b866 388/* Set up fixed registers and calling convention:
4673c1a0 389
7718b866 390 GPRs 0-5 are always call-clobbered,
391 GPRs 6-15 are always call-saved.
392 GPR 12 is fixed if used as GOT pointer.
393 GPR 13 is always fixed (as literal pool pointer).
5fe74ca1 394 GPR 14 is always fixed on S/390 machines (as return address).
7718b866 395 GPR 15 is always fixed (as stack pointer).
396 The 'fake' hard registers are call-clobbered and fixed.
923cf36d 397 The access registers are call-saved and fixed.
4673c1a0 398
7718b866 399 On 31-bit, FPRs 18-19 are call-clobbered;
400 on 64-bit, FPRs 24-31 are call-clobbered.
76a4c804 401 The remaining FPRs are call-saved.
402
403 All non-FP vector registers are call-clobbered v16-v31. */
4673c1a0 404
405#define FIXED_REGISTERS \
406{ 0, 0, 0, 0, \
407 0, 0, 0, 0, \
408 0, 0, 0, 0, \
409 0, 1, 1, 1, \
410 0, 0, 0, 0, \
411 0, 0, 0, 0, \
412 0, 0, 0, 0, \
413 0, 0, 0, 0, \
923cf36d 414 1, 1, 1, 1, \
76a4c804 415 1, 1, \
416 0, 0, 0, 0, \
417 0, 0, 0, 0, \
418 0, 0, 0, 0, \
419 0, 0, 0, 0 }
4673c1a0 420
4673c1a0 421#define CALL_USED_REGISTERS \
422{ 1, 1, 1, 1, \
423 1, 1, 0, 0, \
424 0, 0, 0, 0, \
425 0, 1, 1, 1, \
8b4a4127 426 1, 1, 1, 1, \
427 1, 1, 1, 1, \
428 1, 1, 1, 1, \
429 1, 1, 1, 1, \
923cf36d 430 1, 1, 1, 1, \
76a4c804 431 1, 1, \
432 1, 1, 1, 1, \
433 1, 1, 1, 1, \
434 1, 1, 1, 1, \
435 1, 1, 1, 1 }
8b4a4127 436
8b4a4127 437#define CALL_REALLY_USED_REGISTERS \
76a4c804 438{ 1, 1, 1, 1, /* r0 - r15 */ \
4673c1a0 439 1, 1, 0, 0, \
8b4a4127 440 0, 0, 0, 0, \
441 0, 0, 0, 0, \
76a4c804 442 1, 1, 1, 1, /* f0 (16) - f15 (31) */ \
4673c1a0 443 1, 1, 1, 1, \
444 1, 1, 1, 1, \
445 1, 1, 1, 1, \
76a4c804 446 1, 1, 1, 1, /* arg, cc, fp, ret addr */ \
447 0, 0, /* a0 (36), a1 (37) */ \
448 1, 1, 1, 1, /* v16 (38) - v23 (45) */ \
923cf36d 449 1, 1, 1, 1, \
76a4c804 450 1, 1, 1, 1, /* v24 (46) - v31 (53) */ \
451 1, 1, 1, 1 }
4673c1a0 452
7718b866 453/* Preferred register allocation order. */
76a4c804 454#define REG_ALLOC_ORDER \
455 { 1, 2, 3, 4, 5, 0, 12, 11, 10, 9, 8, 7, 6, 14, 13, \
456 16, 17, 18, 19, 20, 21, 22, 23, \
457 24, 25, 26, 27, 28, 29, 30, 31, \
458 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, \
459 15, 32, 33, 34, 35, 36, 37 }
4673c1a0 460
4673c1a0 461
7718b866 462/* Fitting values into registers. */
f81e845f 463
7718b866 464/* Integer modes <= word size fit into any GPR.
465 Integer modes > word size fit into successive GPRs, starting with
466 an even-numbered register.
467 SImode and DImode fit into FPRs as well.
f81e845f 468
7718b866 469 Floating point modes <= word size fit into any FPR or GPR.
470 Floating point modes > word size (i.e. DFmode on 32-bit) fit
471 into any FPR, or an even-odd GPR pair.
429f9fdb 472 TFmode fits only into an even-odd FPR pair.
f81e845f 473
7718b866 474 Complex floating point modes fit either into two FPRs, or into
475 successive GPRs (again starting with an even number).
429f9fdb 476 TCmode fits only into two successive even-odd FPR pairs.
f81e845f 477
7718b866 478 Condition code modes fit only into the CC register. */
4673c1a0 479
8f1128bb 480/* Because all registers in a class have the same size HARD_REGNO_NREGS
481 is equivalent to CLASS_MAX_NREGS. */
4673c1a0 482#define HARD_REGNO_NREGS(REGNO, MODE) \
8f1128bb 483 s390_class_max_nregs (REGNO_REG_CLASS (REGNO), (MODE))
484
485#define HARD_REGNO_MODE_OK(REGNO, MODE) \
486 s390_hard_regno_mode_ok ((REGNO), (MODE))
487
488#define HARD_REGNO_RENAME_OK(FROM, TO) \
55673549 489 s390_hard_regno_rename_ok ((FROM), (TO))
d1a5573e 490
4673c1a0 491#define MODES_TIEABLE_P(MODE1, MODE2) \
492 (((MODE1) == SFmode || (MODE1) == DFmode) \
493 == ((MODE2) == SFmode || (MODE2) == DFmode))
494
b5fdc416 495/* When generating code that runs in z/Architecture mode,
496 but conforms to the 31-bit ABI, GPRs can hold 8 bytes;
497 the ABI guarantees only that the lower 4 bytes are
498 saved across calls, however. */
76a4c804 499#define HARD_REGNO_CALL_PART_CLOBBERED(REGNO, MODE) \
500 ((!TARGET_64BIT && TARGET_ZARCH \
501 && GET_MODE_SIZE (MODE) > 4 \
502 && (((REGNO) >= 6 && (REGNO) <= 15) || (REGNO) == 32)) \
503 || (TARGET_VX \
504 && GET_MODE_SIZE (MODE) > 8 \
505 && (((TARGET_64BIT && (REGNO) >= 24 && (REGNO) <= 31)) \
506 || (!TARGET_64BIT && ((REGNO) == 18 || (REGNO) == 19)))))
b5fdc416 507
7718b866 508/* Maximum number of registers to represent a value of mode MODE
509 in a register of class CLASS. */
510#define CLASS_MAX_NREGS(CLASS, MODE) \
8f1128bb 511 s390_class_max_nregs ((CLASS), (MODE))
8b4a4127 512
429f9fdb 513#define CANNOT_CHANGE_MODE_CLASS(FROM, TO, CLASS) \
76a4c804 514 s390_cannot_change_mode_class ((FROM), (TO), (CLASS))
4673c1a0 515
e17ed6ec 516/* We can reverse a CC mode safely if we know whether it comes from a
517 floating point compare or not. With the vector modes it is encoded
518 as part of the mode.
519 FIXME: It might make sense to do this for other cc modes as well. */
520#define REVERSIBLE_CC_MODE(MODE) \
521 ((MODE) == CCVIALLmode || (MODE) == CCVIANYmode \
522 || (MODE) == CCVFALLmode || (MODE) == CCVFANYmode)
523
524/* Given a condition code and a mode, return the inverse condition. */
525#define REVERSE_CONDITION(CODE, MODE) s390_reverse_condition (MODE, CODE)
526
527
7718b866 528/* Register classes. */
f81e845f 529
7718b866 530/* We use the following register classes:
531 GENERAL_REGS All general purpose registers
532 ADDR_REGS All general purpose registers except %r0
533 (These registers can be used in address generation)
534 FP_REGS All floating point registers
923cf36d 535 CC_REGS The condition code register
536 ACCESS_REGS The access registers
f81e845f 537
7718b866 538 GENERAL_FP_REGS Union of GENERAL_REGS and FP_REGS
539 ADDR_FP_REGS Union of ADDR_REGS and FP_REGS
923cf36d 540 GENERAL_CC_REGS Union of GENERAL_REGS and CC_REGS
541 ADDR_CC_REGS Union of ADDR_REGS and CC_REGS
f81e845f 542
7718b866 543 NO_REGS No registers
544 ALL_REGS All registers
f81e845f 545
7718b866 546 Note that the 'fake' frame pointer and argument pointer registers
923cf36d 547 are included amongst the address registers here. */
4673c1a0 548
549enum reg_class
550{
923cf36d 551 NO_REGS, CC_REGS, ADDR_REGS, GENERAL_REGS, ACCESS_REGS,
ffead1ca 552 ADDR_CC_REGS, GENERAL_CC_REGS,
8b4a4127 553 FP_REGS, ADDR_FP_REGS, GENERAL_FP_REGS,
76a4c804 554 VEC_REGS, ADDR_VEC_REGS, GENERAL_VEC_REGS,
8b4a4127 555 ALL_REGS, LIM_REG_CLASSES
4673c1a0 556};
4673c1a0 557#define N_REG_CLASSES (int) LIM_REG_CLASSES
558
923cf36d 559#define REG_CLASS_NAMES \
560{ "NO_REGS", "CC_REGS", "ADDR_REGS", "GENERAL_REGS", "ACCESS_REGS", \
561 "ADDR_CC_REGS", "GENERAL_CC_REGS", \
76a4c804 562 "FP_REGS", "ADDR_FP_REGS", "GENERAL_FP_REGS", \
563 "VEC_REGS", "ADDR_VEC_REGS", "GENERAL_VEC_REGS", \
564 "ALL_REGS" }
4673c1a0 565
7718b866 566/* Class -> register mapping. */
76a4c804 567#define REG_CLASS_CONTENTS \
568{ \
4673c1a0 569 { 0x00000000, 0x00000000 }, /* NO_REGS */ \
bcbf02a5 570 { 0x00000000, 0x00000002 }, /* CC_REGS */ \
7cbfc974 571 { 0x0000fffe, 0x0000000d }, /* ADDR_REGS */ \
572 { 0x0000ffff, 0x0000000d }, /* GENERAL_REGS */ \
923cf36d 573 { 0x00000000, 0x00000030 }, /* ACCESS_REGS */ \
bcbf02a5 574 { 0x0000fffe, 0x0000000f }, /* ADDR_CC_REGS */ \
575 { 0x0000ffff, 0x0000000f }, /* GENERAL_CC_REGS */ \
4673c1a0 576 { 0xffff0000, 0x00000000 }, /* FP_REGS */ \
7cbfc974 577 { 0xfffffffe, 0x0000000d }, /* ADDR_FP_REGS */ \
578 { 0xffffffff, 0x0000000d }, /* GENERAL_FP_REGS */ \
76a4c804 579 { 0xffff0000, 0x003fffc0 }, /* VEC_REGS */ \
580 { 0xfffffffe, 0x003fffcd }, /* ADDR_VEC_REGS */ \
581 { 0xffffffff, 0x003fffcd }, /* GENERAL_VEC_REGS */ \
582 { 0xffffffff, 0x003fffff }, /* ALL_REGS */ \
4673c1a0 583}
584
47dd2e78 585/* In some case register allocation order is not enough for IRA to
586 generate a good code. The following macro (if defined) increases
587 cost of REGNO for a pseudo approximately by pseudo usage frequency
588 multiplied by the macro value.
589
590 We avoid usage of BASE_REGNUM by nonzero macro value because the
591 reload can decide not to use the hard register because some
592 constant was forced to be in memory. */
593#define IRA_HARD_REGNO_ADD_COST_MULTIPLIER(regno) \
55673549 594 ((regno) != BASE_REGNUM ? 0.0 : 0.5)
47dd2e78 595
7718b866 596/* Register -> class mapping. */
597extern const enum reg_class regclass_map[FIRST_PSEUDO_REGISTER];
598#define REGNO_REG_CLASS(REGNO) (regclass_map[REGNO])
4673c1a0 599
7718b866 600/* ADDR_REGS can be used as base or index register. */
601#define INDEX_REG_CLASS ADDR_REGS
602#define BASE_REG_CLASS ADDR_REGS
4673c1a0 603
7718b866 604/* Check whether REGNO is a hard register of the suitable class
605 or a pseudo register currently allocated to one such. */
606#define REGNO_OK_FOR_INDEX_P(REGNO) \
607 (((REGNO) < FIRST_PSEUDO_REGISTER \
1e280623 608 && REGNO_REG_CLASS ((REGNO)) == ADDR_REGS) \
609 || ADDR_REGNO_P (reg_renumber[REGNO]))
7718b866 610#define REGNO_OK_FOR_BASE_P(REGNO) REGNO_OK_FOR_INDEX_P (REGNO)
4673c1a0 611
4673c1a0 612
76a4c804 613/* We need secondary memory to move data between GPRs and FPRs.
614
615 - With DFP the ldgr lgdr instructions are available. Due to the
616 different alignment we cannot use them for SFmode. For 31 bit a
617 64 bit value in GPR would be a register pair so here we still
618 need to go via memory.
619
620 - With z13 we can do the SF/SImode moves with vlgvf. Due to the
621 overlapping of FPRs and VRs we still disallow TF/TD modes to be
622 in full VRs so as before also on z13 we do these moves via
623 memory.
624
625 FIXME: Should we try splitting it into two vlgvg's/vlvg's instead? */
626#define SECONDARY_MEMORY_NEEDED(CLASS1, CLASS2, MODE) \
55673549 627 (((reg_classes_intersect_p ((CLASS1), VEC_REGS) \
628 && reg_classes_intersect_p ((CLASS2), GENERAL_REGS)) \
629 || (reg_classes_intersect_p ((CLASS1), GENERAL_REGS) \
630 && reg_classes_intersect_p ((CLASS2), VEC_REGS))) \
76a4c804 631 && (!TARGET_DFP || !TARGET_64BIT || GET_MODE_SIZE (MODE) != 8) \
632 && (!TARGET_VX || (SCALAR_FLOAT_MODE_P (MODE) \
633 && GET_MODE_SIZE (MODE) > 8)))
7718b866 634
635/* Get_secondary_mem widens its argument to BITS_PER_WORD which loses on 64bit
636 because the movsi and movsf patterns don't handle r/f moves. */
637#define SECONDARY_MEMORY_NEEDED_MODE(MODE) \
638 (GET_MODE_BITSIZE (MODE) < 32 \
639 ? mode_for_size (32, GET_MODE_CLASS (MODE), 0) \
55673549 640 : (MODE))
7718b866 641
642
7718b866 643/* Stack layout and calling conventions. */
f81e845f 644
7718b866 645/* Our stack grows from higher to lower addresses. However, local variables
646 are accessed by positive offsets, and function arguments are stored at
647 increasing addresses. */
2b785411 648#define STACK_GROWS_DOWNWARD 1
119114cb 649#define FRAME_GROWS_DOWNWARD 1
7718b866 650/* #undef ARGS_GROW_DOWNWARD */
4673c1a0 651
7718b866 652/* The basic stack layout looks like this: the stack pointer points
653 to the register save area for called functions. Above that area
654 is the location to place outgoing arguments. Above those follow
655 dynamic allocations (alloca), and finally the local variables. */
4673c1a0 656
7718b866 657/* Offset from stack-pointer to first location of outgoing args. */
658#define STACK_POINTER_OFFSET (TARGET_64BIT ? 160 : 96)
4673c1a0 659
7718b866 660/* Offset within stack frame to start allocating local variables at. */
119114cb 661#define STARTING_FRAME_OFFSET 0
4673c1a0 662
7718b866 663/* Offset from the stack pointer register to an item dynamically
664 allocated on the stack, e.g., by `alloca'. */
119114cb 665#define STACK_DYNAMIC_OFFSET(FUNDECL) \
abe32cce 666 (STACK_POINTER_OFFSET + crtl->outgoing_args_size)
4673c1a0 667
7718b866 668/* Offset of first parameter from the argument pointer register value.
669 We have a fake argument pointer register that points directly to
670 the argument area. */
671#define FIRST_PARM_OFFSET(FNDECL) 0
4673c1a0 672
ffead1ca 673/* Defining this macro makes __builtin_frame_address(0) and
869d0ef0 674 __builtin_return_address(0) work with -fomit-frame-pointer. */
675#define INITIAL_FRAME_ADDRESS_RTX \
29c05e22 676 (plus_constant (Pmode, arg_pointer_rtx, -STACK_POINTER_OFFSET))
869d0ef0 677
f81e845f 678/* The return address of the current frame is retrieved
8b4a4127 679 from the initial value of register RETURN_REGNUM.
680 For frames farther back, we use the stack slot where
681 the corresponding RETURN_REGNUM register was saved. */
869d0ef0 682#define DYNAMIC_CHAIN_ADDRESS(FRAME) \
683 (TARGET_PACKED_STACK ? \
29c05e22 684 plus_constant (Pmode, (FRAME), \
685 STACK_POINTER_OFFSET - UNITS_PER_LONG) : (FRAME))
8b4a4127 686
4f091f59 687/* For -mpacked-stack this adds 160 - 8 (96 - 4) to the output of
688 builtin_frame_address. Otherwise arg pointer -
689 STACK_POINTER_OFFSET would be returned for
690 __builtin_frame_address(0) what might result in an address pointing
691 somewhere into the middle of the local variables since the packed
692 stack layout generally does not need all the bytes in the register
693 save area. */
694#define FRAME_ADDR_RTX(FRAME) \
695 DYNAMIC_CHAIN_ADDRESS ((FRAME))
696
869d0ef0 697#define RETURN_ADDR_RTX(COUNT, FRAME) \
abd8f04d 698 s390_return_addr_rtx ((COUNT), DYNAMIC_CHAIN_ADDRESS ((FRAME)))
4673c1a0 699
7718b866 700/* In 31-bit mode, we need to mask off the high bit of return addresses. */
bcd9bd66 701#define MASK_RETURN_ADDR (TARGET_64BIT ? constm1_rtx : GEN_INT (0x7fffffff))
4673c1a0 702
8b4a4127 703
7718b866 704/* Exception handling. */
f81e845f 705
7718b866 706/* Describe calling conventions for DWARF-2 exception handling. */
707#define INCOMING_RETURN_ADDR_RTX gen_rtx_REG (Pmode, RETURN_REGNUM)
8b4a4127 708#define INCOMING_FRAME_SP_OFFSET STACK_POINTER_OFFSET
4673c1a0 709#define DWARF_FRAME_RETURN_COLUMN 14
710
711/* Describe how we implement __builtin_eh_return. */
712#define EH_RETURN_DATA_REGNO(N) ((N) < 4 ? (N) + 6 : INVALID_REGNUM)
7cbfc974 713#define EH_RETURN_HANDLER_RTX gen_rtx_MEM (Pmode, return_address_pointer_rtx)
ffead1ca 714
e3a04290 715/* Select a format to encode pointers in exception handling data. */
716#define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \
717 (flag_pic \
718 ? ((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel | DW_EH_PE_sdata4 \
719 : DW_EH_PE_absptr)
720
b5fdc416 721/* Register save slot alignment. */
722#define DWARF_CIE_DATA_ALIGNMENT (-UNITS_PER_LONG)
723
a22cd2a7 724/* Let the assembler generate debug line info. */
725#define DWARF2_ASM_LINE_DEBUG_INFO 1
726
76a4c804 727/* Define the dwarf register mapping.
728 v16-v31 -> 68-83
729 rX -> X otherwise */
55673549 730#define DBX_REGISTER_NUMBER(regno) \
731 (((regno) >= 38 && (regno) <= 53) ? (regno) + 30 : (regno))
4673c1a0 732
7718b866 733/* Frame registers. */
4673c1a0 734
7718b866 735#define STACK_POINTER_REGNUM 15
736#define FRAME_POINTER_REGNUM 34
737#define HARD_FRAME_POINTER_REGNUM 11
738#define ARG_POINTER_REGNUM 32
7cbfc974 739#define RETURN_ADDRESS_POINTER_REGNUM 35
4673c1a0 740
f81e845f 741/* The static chain must be call-clobbered, but not used for
742 function argument passing. As register 1 is clobbered by
7718b866 743 the trampoline code, we only have one option. */
744#define STATIC_CHAIN_REGNUM 0
4673c1a0 745
7718b866 746/* Number of hardware registers that go into the DWARF-2 unwind info.
747 To avoid ABI incompatibility, this number must not change even as
748 'fake' hard registers are added or removed. */
749#define DWARF_FRAME_REGISTERS 34
4673c1a0 750
4673c1a0 751
7718b866 752/* Frame pointer and argument pointer elimination. */
4673c1a0 753
d1a5573e 754#define ELIMINABLE_REGS \
755{{ FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM }, \
756 { FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM }, \
757 { ARG_POINTER_REGNUM, STACK_POINTER_REGNUM }, \
758 { ARG_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM }, \
759 { RETURN_ADDRESS_POINTER_REGNUM, STACK_POINTER_REGNUM }, \
760 { RETURN_ADDRESS_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM }, \
761 { BASE_REGNUM, BASE_REGNUM }}
4673c1a0 762
4fed3f99 763#define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
764 (OFFSET) = s390_initial_elimination_offset ((FROM), (TO))
4673c1a0 765
4673c1a0 766
7718b866 767/* Stack arguments. */
f81e845f 768
7718b866 769/* We need current_function_outgoing_args to be valid. */
770#define ACCUMULATE_OUTGOING_ARGS 1
4673c1a0 771
4673c1a0 772
7718b866 773/* Register arguments. */
f81e845f 774
4673c1a0 775typedef struct s390_arg_structure
776{
777 int gprs; /* gpr so far */
778 int fprs; /* fpr so far */
76a4c804 779 int vrs; /* vr so far */
4673c1a0 780}
781CUMULATIVE_ARGS;
782
34f27375 783#define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, NN, N_NAMED_ARGS) \
76a4c804 784 ((CUM).gprs=0, (CUM).fprs=0, (CUM).vrs=0)
785
786#define FIRST_VEC_ARG_REGNO 46
787#define LAST_VEC_ARG_REGNO 53
4673c1a0 788
8364148d 789/* Arguments can be placed in general registers 2 to 6, or in floating
790 point registers 0 and 2 for 31 bit and fprs 0, 2, 4 and 6 for 64
791 bit. */
76a4c804 792#define FUNCTION_ARG_REGNO_P(N) \
793 (((N) >=2 && (N) < 7) || (N) == 16 || (N) == 17 \
794 || (TARGET_64BIT && ((N) == 18 || (N) == 19)) \
795 || (TARGET_VX && ((N) >= FIRST_VEC_ARG_REGNO && (N) <= LAST_VEC_ARG_REGNO)))
4673c1a0 796
4673c1a0 797
76a4c804 798/* Only gpr 2, fpr 0, and v24 are ever used as return registers. */
799#define FUNCTION_VALUE_REGNO_P(N) \
800 ((N) == 2 || (N) == 16 \
801 || (TARGET_VX && (N) == FIRST_VEC_ARG_REGNO))
4673c1a0 802
4673c1a0 803
7718b866 804/* Function entry and exit. */
f81e845f 805
7718b866 806/* When returning from a function, the stack pointer does not matter. */
807#define EXIT_IGNORE_STACK 1
4673c1a0 808
4673c1a0 809
7718b866 810/* Profiling. */
4673c1a0 811
812#define FUNCTION_PROFILER(FILE, LABELNO) \
7718b866 813 s390_function_profiler ((FILE), ((LABELNO)))
4673c1a0 814
ecfe03ce 815#define PROFILE_BEFORE_PROLOGUE 1
4673c1a0 816
4673c1a0 817
7718b866 818/* Trampolines for nested functions. */
4673c1a0 819
4d946732 820#define TRAMPOLINE_SIZE (TARGET_64BIT ? 32 : 16)
821#define TRAMPOLINE_ALIGNMENT BITS_PER_WORD
4673c1a0 822
7718b866 823/* Addressing modes, and classification of registers for them. */
4673c1a0 824
7718b866 825/* Recognize any constant value that is a valid address. */
826#define CONSTANT_ADDRESS_P(X) 0
4673c1a0 827
7718b866 828/* Maximum number of registers that can appear in a valid memory address. */
829#define MAX_REGS_PER_ADDRESS 2
4673c1a0 830
e68d6a13 831/* This definition replaces the formerly used 'm' constraint with a
fd50b071 832 different constraint letter in order to avoid changing semantics of
833 the 'm' constraint when accepting new address formats in
834 TARGET_LEGITIMATE_ADDRESS_P. The constraint letter defined here
835 must not be used in insn definitions or inline assemblies. */
e68d6a13 836#define TARGET_MEM_CONSTRAINT 'e'
837
e4542435 838/* Try a machine-dependent way of reloading an illegitimate address
839 operand. If we find one, push the reload and jump to WIN. This
840 macro is used in only one place: `find_reloads_address' in reload.c. */
841#define LEGITIMIZE_RELOAD_ADDRESS(AD, MODE, OPNUM, TYPE, IND, WIN) \
55673549 842 do { \
843 rtx new_rtx = legitimize_reload_address ((AD), (MODE), \
844 (OPNUM), (int)(TYPE)); \
845 if (new_rtx) \
846 { \
847 (AD) = new_rtx; \
848 goto WIN; \
849 } \
850 } while (0)
e4542435 851
7718b866 852/* Helper macro for s390.c and s390.md to check for symbolic constants. */
55673549 853#define SYMBOLIC_CONST(X) \
854 (GET_CODE (X) == SYMBOL_REF \
855 || GET_CODE (X) == LABEL_REF \
856 || (GET_CODE (X) == CONST && symbolic_reference_mentioned_p (X)))
4673c1a0 857
55673549 858#define TLS_SYMBOLIC_CONST(X) \
859 ((GET_CODE (X) == SYMBOL_REF && tls_symbolic_operand (X)) \
860 || (GET_CODE (X) == CONST && tls_symbolic_reference_mentioned_p (X)))
be00aaa8 861
4673c1a0 862
7718b866 863/* Condition codes. */
4673c1a0 864
7718b866 865/* Given a comparison code (EQ, NE, etc.) and the first operand of a COMPARE,
866 return the mode to be used for the comparison. */
867#define SELECT_CC_MODE(OP, X, Y) s390_select_ccmode ((OP), (X), (Y))
f81e845f 868
7718b866 869/* Relative costs of operations. */
4673c1a0 870
4673c1a0 871/* A C expression for the cost of a branch instruction. A value of 1
872 is the default; other values are interpreted relative to that. */
abb9bd4b 873#define BRANCH_COST(speed_p, predictable_p) s390_branch_cost
4673c1a0 874
7718b866 875/* Nonzero if access to memory by bytes is slow and undesirable. */
876#define SLOW_BYTE_ACCESS 1
877
363f612f 878/* An integer expression for the size in bits of the largest integer machine
ffead1ca 879 mode that should actually be used. We allow pairs of registers. */
363f612f 880#define MAX_FIXED_MODE_SIZE GET_MODE_BITSIZE (TARGET_64BIT ? TImode : DImode)
881
7718b866 882/* The maximum number of bytes that a single instruction can move quickly
1d60d981 883 between memory and registers or between two memory locations. */
b5fdc416 884#define MOVE_MAX (TARGET_ZARCH ? 16 : 8)
885#define MOVE_MAX_PIECES (TARGET_ZARCH ? 8 : 4)
7718b866 886#define MAX_MOVE_MAX 16
4673c1a0 887
7718b866 888/* Don't perform CSE on function addresses. */
93516111 889#define NO_FUNCTION_CSE 1
7718b866 890
6cb659b1 891/* This value is used in tree-sra to decide whether it might benefical
892 to split a struct move into several word-size moves. For S/390
893 only small values make sense here since struct moves are relatively
9d75589a 894 cheap thanks to mvc so the small default value chosen for archs
6cb659b1 895 with memmove patterns should be ok. But this value is multiplied
896 in tree-sra with UNITS_PER_WORD to make a decision so we adjust it
897 here to compensate for that factor since mvc costs exactly the same
898 on 31 and 64 bit. */
f5733e7c 899#define MOVE_RATIO(speed) (TARGET_64BIT? 2 : 4)
6cb659b1 900
7718b866 901
902/* Sections. */
903
904/* Output before read-only data. */
905#define TEXT_SECTION_ASM_OP ".text"
906
907/* Output before writable (initialized) data. */
908#define DATA_SECTION_ASM_OP ".data"
909
910/* Output before writable (uninitialized) data. */
911#define BSS_SECTION_ASM_OP ".bss"
912
913/* S/390 constant pool breaks the devices in crtstuff.c to control section
914 in where code resides. We have to write it as asm code. */
915#ifndef __s390x__
916#define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
917 asm (SECTION_OP "\n\
918 bras\t%r2,1f\n\
9190: .long\t" USER_LABEL_PREFIX #FUNC " - 0b\n\
9201: l\t%r3,0(%r2)\n\
921 bas\t%r14,0(%r3,%r2)\n\
922 .previous");
923#endif
a983c6d2 924
7718b866 925
926/* Position independent code. */
927
7718b866 928#define PIC_OFFSET_TABLE_REGNUM (flag_pic ? 12 : INVALID_REGNUM)
929
930#define LEGITIMATE_PIC_OPERAND_P(X) legitimate_pic_operand_p (X)
a983c6d2 931
932
933/* Assembler file format. */
934
935/* Character to start a comment. */
936#define ASM_COMMENT_START "#"
937
938/* Declare an uninitialized external linkage data object. */
55673549 939#define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
940 asm_output_aligned_bss ((FILE), (DECL), (NAME), (SIZE), (ALIGN))
a983c6d2 941
942/* Globalizing directive for a label. */
943#define GLOBAL_ASM_OP ".globl "
944
945/* Advance the location counter to a multiple of 2**LOG bytes. */
946#define ASM_OUTPUT_ALIGN(FILE, LOG) \
947 if ((LOG)) fprintf ((FILE), "\t.align\t%d\n", 1 << (LOG))
948
949/* Advance the location counter by SIZE bytes. */
950#define ASM_OUTPUT_SKIP(FILE, SIZE) \
f03df321 951 fprintf ((FILE), "\t.set\t.,.+" HOST_WIDE_INT_PRINT_UNSIGNED"\n", (SIZE))
a983c6d2 952
a983c6d2 953/* The LOCAL_LABEL_PREFIX variable is used by dbxelf.h. */
954#define LOCAL_LABEL_PREFIX "."
4673c1a0 955
6d0afa28 956#define LABEL_ALIGN(LABEL) \
55673549 957 s390_label_align ((LABEL))
6d0afa28 958
4673c1a0 959/* How to refer to registers in assembler output. This sequence is
960 indexed by compiler's hard-register-number (see above). */
4673c1a0 961#define REGISTER_NAMES \
76a4c804 962 { "%r0", "%r1", "%r2", "%r3", "%r4", "%r5", "%r6", "%r7", \
963 "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15", \
964 "%f0", "%f2", "%f4", "%f6", "%f1", "%f3", "%f5", "%f7", \
965 "%f8", "%f10", "%f12", "%f14", "%f9", "%f11", "%f13", "%f15", \
966 "%ap", "%cc", "%fp", "%rp", "%a0", "%a1", \
967 "%v16", "%v18", "%v20", "%v22", "%v17", "%v19", "%v21", "%v23", \
968 "%v24", "%v26", "%v28", "%v30", "%v25", "%v27", "%v29", "%v31" \
969 }
970
971#define ADDITIONAL_REGISTER_NAMES \
972 { { "v0", 16 }, { "v2", 17 }, { "v4", 18 }, { "v6", 19 }, \
973 { "v1", 20 }, { "v3", 21 }, { "v5", 22 }, { "v7", 23 }, \
974 { "v8", 24 }, { "v10", 25 }, { "v12", 26 }, { "v14", 27 }, \
975 { "v9", 28 }, { "v11", 29 }, { "v13", 30 }, { "v15", 31 } };
4673c1a0 976
a983c6d2 977/* Print operand X (an rtx) in assembler syntax to file FILE. */
55673549 978#define PRINT_OPERAND(FILE, X, CODE) print_operand ((FILE), (X), (CODE))
979#define PRINT_OPERAND_ADDRESS(FILE, ADDR) print_operand_address ((FILE), (ADDR))
4673c1a0 980
a983c6d2 981/* Output an element of a case-vector that is absolute. */
982#define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \
983do { \
984 char buf[32]; \
b5fdc416 985 fputs (integer_asm_op (UNITS_PER_LONG, TRUE), (FILE)); \
a983c6d2 986 ASM_GENERATE_INTERNAL_LABEL (buf, "L", (VALUE)); \
987 assemble_name ((FILE), buf); \
988 fputc ('\n', (FILE)); \
989} while (0)
990
991/* Output an element of a case-vector that is relative. */
992#define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
993do { \
994 char buf[32]; \
b5fdc416 995 fputs (integer_asm_op (UNITS_PER_LONG, TRUE), (FILE)); \
a983c6d2 996 ASM_GENERATE_INTERNAL_LABEL (buf, "L", (VALUE)); \
997 assemble_name ((FILE), buf); \
998 fputc ('-', (FILE)); \
999 ASM_GENERATE_INTERNAL_LABEL (buf, "L", (REL)); \
1000 assemble_name ((FILE), buf); \
1001 fputc ('\n', (FILE)); \
1002} while (0)
1003
7a64c761 1004/* Mark the return register as used by the epilogue so that we can
1005 use it in unadorned (return) and (simple_return) instructions. */
1006#define EPILOGUE_USES(REGNO) ((REGNO) == RETURN_REGNUM)
1007
77bc9912 1008#undef ASM_OUTPUT_FUNCTION_LABEL
55673549 1009#define ASM_OUTPUT_FUNCTION_LABEL(FILE, NAME, DECL) \
1010 s390_asm_output_function_label ((FILE), (NAME), (DECL))
4673c1a0 1011
7a0cee35 1012#if S390_USE_TARGET_ATTRIBUTE
1013/* Hook to output .machine and .machinemode at start of function. */
1014#undef ASM_OUTPUT_FUNCTION_PREFIX
1015#define ASM_OUTPUT_FUNCTION_PREFIX s390_asm_output_function_prefix
1016
1017/* Hook to output .machine and .machinemode at end of function. */
1018#undef ASM_DECLARE_FUNCTION_SIZE
1019#define ASM_DECLARE_FUNCTION_SIZE s390_asm_declare_function_size
1020#endif
1021
7718b866 1022/* Miscellaneous parameters. */
1023
7718b866 1024/* Specify the machine mode that this machine uses for the index in the
1025 tablejump instruction. */
1026#define CASE_VECTOR_MODE (TARGET_64BIT ? DImode : SImode)
1027
7718b866 1028/* Value is 1 if truncating an integer of INPREC bits to OUTPREC bits
1029 is done just by pretending it is already truncated. */
1030#define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
1031
1032/* Specify the machine mode that pointers have.
1033 After generation of rtl, the compiler makes no further distinction
1034 between pointers and any other objects of this machine mode. */
3754d046 1035#define Pmode ((machine_mode) (TARGET_64BIT ? DImode : SImode))
7718b866 1036
f81e845f 1037/* This is -1 for "pointer mode" extend. See ptr_extend in s390.md. */
1038#define POINTERS_EXTEND_UNSIGNED -1
1039
7718b866 1040/* A function address in a call instruction is a byte address (for
1041 indexing purposes) so give the MEM rtx a byte's mode. */
1042#define FUNCTION_MODE QImode
1043
163277cf 1044/* Specify the value which is used when clz operand is zero. */
1045#define CLZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE) ((VALUE) = 64, 1)
1046
8cc5de33 1047/* Machine-specific symbol_ref flags. */
78affa36 1048#define SYMBOL_FLAG_ALIGN_SHIFT SYMBOL_FLAG_MACH_DEP_SHIFT
1049#define SYMBOL_FLAG_ALIGN_MASK \
1050 ((SYMBOL_FLAG_MACH_DEP << 0) | (SYMBOL_FLAG_MACH_DEP << 1))
1051
1052#define SYMBOL_FLAG_SET_ALIGN(X, A) \
1053 (SYMBOL_REF_FLAGS (X) = (SYMBOL_REF_FLAGS (X) & ~SYMBOL_FLAG_ALIGN_MASK) \
1054 | (A << SYMBOL_FLAG_ALIGN_SHIFT))
1055
1056#define SYMBOL_FLAG_GET_ALIGN(X) \
1057 ((SYMBOL_REF_FLAGS (X) & SYMBOL_FLAG_ALIGN_MASK) >> SYMBOL_FLAG_ALIGN_SHIFT)
1058
1059/* Helpers to access symbol_ref flags. They are used in
1060 check_symref_alignment() and larl_operand to detect if the
1061 available alignment matches the required one. We do not use
1062 a positive check like _ALIGN2 because in that case we would have
1063 to annotate every symbol_ref. However, we only want to touch
1064 the symbol_refs that can be misaligned and assume that the others
1065 are correctly aligned. Hence, if a symbol_ref does not have
1066 a _NOTALIGN flag it is supposed to be correctly aligned. */
55673549 1067#define SYMBOL_FLAG_SET_NOTALIGN2(X) SYMBOL_FLAG_SET_ALIGN((X), 1)
1068#define SYMBOL_FLAG_SET_NOTALIGN4(X) SYMBOL_FLAG_SET_ALIGN((X), 2)
1069#define SYMBOL_FLAG_SET_NOTALIGN8(X) SYMBOL_FLAG_SET_ALIGN((X), 3)
78affa36 1070
1071#define SYMBOL_FLAG_NOTALIGN2_P(X) (SYMBOL_FLAG_GET_ALIGN(X) == 1)
55673549 1072#define SYMBOL_FLAG_NOTALIGN4_P(X) (SYMBOL_FLAG_GET_ALIGN(X) == 2 \
78affa36 1073 || SYMBOL_FLAG_GET_ALIGN(X) == 1)
55673549 1074#define SYMBOL_FLAG_NOTALIGN8_P(X) (SYMBOL_FLAG_GET_ALIGN(X) == 3 \
1075 || SYMBOL_FLAG_GET_ALIGN(X) == 2 \
78affa36 1076 || SYMBOL_FLAG_GET_ALIGN(X) == 1)
8cc5de33 1077
76a4c804 1078/* Check whether integer displacement is in range for a short displacement. */
1079#define SHORT_DISP_IN_RANGE(d) ((d) >= 0 && (d) <= 4095)
1080
8cc5de33 1081/* Check whether integer displacement is in range. */
55673549 1082#define DISP_IN_RANGE(d) \
1083 (TARGET_LONG_DISPLACEMENT \
1084 ? ((d) >= -524288 && (d) <= 524287) \
1085 : SHORT_DISP_IN_RANGE(d))
8cc5de33 1086
d80deb0a 1087/* Reads can reuse write prefetches, used by tree-ssa-prefetch-loops.c. */
1088#define READ_CAN_USE_WRITE_PREFETCH 1
218e3e4e 1089
1090extern const int processor_flags_table[];
76a4c804 1091
1092/* The truth element value for vector comparisons. Our instructions
1093 always generate -1 in that case. */
1094#define VECTOR_STORE_FLAG_VALUE(MODE) CONSTM1_RTX (GET_MODE_INNER (MODE))
1095
07f32359 1096/* Target pragma. */
1097
1098/* resolve_overloaded_builtin can not be defined the normal way since
1099 it is defined in code which technically belongs to the
1100 front-end. */
1101#define REGISTER_TARGET_PRAGMAS() \
1102 do { \
1103 s390_register_target_pragmas (); \
1104 } while (0)
1105
76a4c804 1106#endif /* S390_H */