]>
Commit | Line | Data |
---|---|---|
9db1d521 | 1 | /* Definitions of target machine for GNU compiler, for IBM S/390 |
2f83c7d6 NC |
2 | Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, |
3 | 2007 Free Software Foundation, Inc. | |
9db1d521 | 4 | Contributed by Hartmut Penner (hpenner@de.ibm.com) and |
f314b9b1 | 5 | Ulrich Weigand (uweigand@de.ibm.com). |
9db1d521 | 6 | |
58add37a | 7 | This file is part of GCC. |
9db1d521 | 8 | |
58add37a UW |
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 | |
2f83c7d6 | 11 | Software Foundation; either version 3, or (at your option) any later |
58add37a UW |
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. | |
9db1d521 HP |
18 | |
19 | You should have received a copy of the GNU General Public License | |
2f83c7d6 NC |
20 | along with GCC; see the file COPYING3. If not see |
21 | <http://www.gnu.org/licenses/>. */ | |
9db1d521 HP |
22 | |
23 | #ifndef _S390_H | |
24 | #define _S390_H | |
25 | ||
42c78618 UW |
26 | /* Override the __fixdfdi etc. routines when building libgcc2. |
27 | ??? This should be done in a cleaner way ... */ | |
fe86047c | 28 | #if defined (IN_LIBGCC2) && !defined (__s390x__) |
ca11c37c | 29 | #include <config/s390/fixdfdi.h> |
42c78618 UW |
30 | #endif |
31 | ||
c7453384 | 32 | /* Which processor to generate code or schedule for. The cpu attribute |
1fec52be HP |
33 | defines a list that mirrors this list, so changes to s390.md must be |
34 | made at the same time. */ | |
35 | ||
36 | enum processor_type | |
37 | { | |
c7453384 EC |
38 | PROCESSOR_9672_G5, |
39 | PROCESSOR_9672_G6, | |
40 | PROCESSOR_2064_Z900, | |
f13e0d4e | 41 | PROCESSOR_2084_Z990, |
ec24698e | 42 | PROCESSOR_2094_Z9_109, |
1fec52be HP |
43 | PROCESSOR_max |
44 | }; | |
45 | ||
f13e0d4e UW |
46 | /* Optional architectural facilities supported by the processor. */ |
47 | ||
48 | enum processor_flags | |
49 | { | |
50 | PF_IEEE_FLOAT = 1, | |
51 | PF_ZARCH = 2, | |
ec24698e | 52 | PF_LONG_DISPLACEMENT = 4, |
85dae55a AK |
53 | PF_EXTIMM = 8, |
54 | PF_DFP = 16 | |
f13e0d4e UW |
55 | }; |
56 | ||
57 | extern enum processor_type s390_tune; | |
58 | extern enum processor_flags s390_tune_flags; | |
1fec52be HP |
59 | |
60 | extern enum processor_type s390_arch; | |
f13e0d4e | 61 | extern enum processor_flags s390_arch_flags; |
d75f90f1 | 62 | |
f13e0d4e UW |
63 | #define TARGET_CPU_IEEE_FLOAT \ |
64 | (s390_arch_flags & PF_IEEE_FLOAT) | |
65 | #define TARGET_CPU_ZARCH \ | |
66 | (s390_arch_flags & PF_ZARCH) | |
67 | #define TARGET_CPU_LONG_DISPLACEMENT \ | |
68 | (s390_arch_flags & PF_LONG_DISPLACEMENT) | |
ec24698e UW |
69 | #define TARGET_CPU_EXTIMM \ |
70 | (s390_arch_flags & PF_EXTIMM) | |
85dae55a AK |
71 | #define TARGET_CPU_DFP \ |
72 | (s390_arch_flags & PF_DFP) | |
f13e0d4e UW |
73 | |
74 | #define TARGET_LONG_DISPLACEMENT \ | |
75 | (TARGET_ZARCH && TARGET_CPU_LONG_DISPLACEMENT) | |
ec24698e UW |
76 | #define TARGET_EXTIMM \ |
77 | (TARGET_ZARCH && TARGET_CPU_EXTIMM) | |
85dae55a AK |
78 | #define TARGET_DFP \ |
79 | (TARGET_ZARCH && TARGET_CPU_DFP) | |
42c78618 | 80 | |
862a2d83 | 81 | /* Run-time target specification. */ |
9db1d521 | 82 | |
a771c4b3 UW |
83 | /* Defaults for option flags defined only on some subtargets. */ |
84 | #ifndef TARGET_TPF_PROFILING | |
85 | #define TARGET_TPF_PROFILING 0 | |
86 | #endif | |
87 | ||
4798630c D |
88 | /* This will be overridden by OS headers. */ |
89 | #define TARGET_TPF 0 | |
90 | ||
862a2d83 UW |
91 | /* Target CPU builtins. */ |
92 | #define TARGET_CPU_CPP_BUILTINS() \ | |
93 | do \ | |
94 | { \ | |
95 | builtin_assert ("cpu=s390"); \ | |
96 | builtin_assert ("machine=s390"); \ | |
97 | builtin_define ("__s390__"); \ | |
98 | if (TARGET_64BIT) \ | |
99 | builtin_define ("__s390x__"); \ | |
f61a2c7d AK |
100 | if (TARGET_LONG_DOUBLE_128) \ |
101 | builtin_define ("__LONG_DOUBLE_128__"); \ | |
862a2d83 UW |
102 | } \ |
103 | while (0) | |
9db1d521 | 104 | |
58d10f89 | 105 | #ifdef DEFAULT_TARGET_64BIT |
47d94c1a | 106 | #define TARGET_DEFAULT (MASK_64BIT | MASK_ZARCH | MASK_HARD_DFP) |
58d10f89 | 107 | #else |
85dae55a | 108 | #define TARGET_DEFAULT 0 |
58d10f89 UW |
109 | #endif |
110 | ||
f13e0d4e UW |
111 | /* Support for configure-time defaults. */ |
112 | #define OPTION_DEFAULT_SPECS \ | |
113 | { "mode", "%{!mesa:%{!mzarch:-m%(VALUE)}}" }, \ | |
114 | { "arch", "%{!march=*:-march=%(VALUE)}" }, \ | |
115 | { "tune", "%{!mtune=*:-mtune=%(VALUE)}" } | |
116 | ||
117 | /* Defaulting rules. */ | |
118 | #ifdef DEFAULT_TARGET_64BIT | |
119 | #define DRIVER_SELF_SPECS \ | |
120 | "%{!m31:%{!m64:-m64}}", \ | |
121 | "%{!mesa:%{!mzarch:%{m31:-mesa}%{m64:-mzarch}}}", \ | |
122 | "%{!march=*:%{mesa:-march=g5}%{mzarch:-march=z900}}" | |
123 | #else | |
124 | #define DRIVER_SELF_SPECS \ | |
125 | "%{!m31:%{!m64:-m31}}", \ | |
126 | "%{!mesa:%{!mzarch:%{m31:-mesa}%{m64:-mzarch}}}", \ | |
127 | "%{!march=*:%{mesa:-march=g5}%{mzarch:-march=z900}}" | |
128 | #endif | |
129 | ||
862a2d83 UW |
130 | /* Target version string. Overridden by the OS header. */ |
131 | #ifdef DEFAULT_TARGET_64BIT | |
132 | #define TARGET_VERSION fprintf (stderr, " (zSeries)"); | |
133 | #else | |
134 | #define TARGET_VERSION fprintf (stderr, " (S/390)"); | |
135 | #endif | |
9db1d521 | 136 | |
862a2d83 UW |
137 | /* Hooks to override options. */ |
138 | #define OPTIMIZATION_OPTIONS(LEVEL, SIZE) optimization_options(LEVEL, SIZE) | |
4023fb28 UW |
139 | #define OVERRIDE_OPTIONS override_options () |
140 | ||
862a2d83 UW |
141 | /* Frame pointer is not used for debugging. */ |
142 | #define CAN_DEBUG_WITHOUT_FP | |
9db1d521 | 143 | |
638e37c2 | 144 | /* Constants needed to control the TEST DATA CLASS (TDC) instruction. */ |
0387c142 WG |
145 | #define S390_TDC_POSITIVE_ZERO (1 << 11) |
146 | #define S390_TDC_NEGATIVE_ZERO (1 << 10) | |
147 | #define S390_TDC_POSITIVE_NORMALIZED_BFP_NUMBER (1 << 9) | |
148 | #define S390_TDC_NEGATIVE_NORMALIZED_BFP_NUMBER (1 << 8) | |
149 | #define S390_TDC_POSITIVE_DENORMALIZED_BFP_NUMBER (1 << 7) | |
150 | #define S390_TDC_NEGATIVE_DENORMALIZED_BFP_NUMBER (1 << 6) | |
151 | #define S390_TDC_POSITIVE_INFINITY (1 << 5) | |
152 | #define S390_TDC_NEGATIVE_INFINITY (1 << 4) | |
153 | #define S390_TDC_POSITIVE_QUIET_NAN (1 << 3) | |
154 | #define S390_TDC_NEGATIVE_QUIET_NAN (1 << 2) | |
155 | #define S390_TDC_POSITIVE_SIGNALING_NAN (1 << 1) | |
156 | #define S390_TDC_NEGATIVE_SIGNALING_NAN (1 << 0) | |
157 | ||
158 | /* The following values are different for DFP. */ | |
159 | #define S390_TDC_POSITIVE_DENORMALIZED_DFP_NUMBER (1 << 9) | |
160 | #define S390_TDC_NEGATIVE_DENORMALIZED_DFP_NUMBER (1 << 8) | |
161 | #define S390_TDC_POSITIVE_NORMALIZED_DFP_NUMBER (1 << 7) | |
162 | #define S390_TDC_NEGATIVE_NORMALIZED_DFP_NUMBER (1 << 6) | |
163 | ||
164 | /* For signbit, the BFP-DFP-difference makes no difference. */ | |
0f67fa83 | 165 | #define S390_TDC_SIGNBIT_SET (S390_TDC_NEGATIVE_ZERO \ |
0387c142 WG |
166 | | S390_TDC_NEGATIVE_NORMALIZED_BFP_NUMBER \ |
167 | | S390_TDC_NEGATIVE_DENORMALIZED_BFP_NUMBER\ | |
0f67fa83 WG |
168 | | S390_TDC_NEGATIVE_INFINITY \ |
169 | | S390_TDC_NEGATIVE_QUIET_NAN \ | |
170 | | S390_TDC_NEGATIVE_SIGNALING_NAN ) | |
171 | ||
638e37c2 WG |
172 | #define S390_TDC_INFINITY (S390_TDC_POSITIVE_INFINITY \ |
173 | | S390_TDC_NEGATIVE_INFINITY ) | |
9db1d521 | 174 | |
fe86047c UW |
175 | /* In libgcc2, determine target settings as compile-time constants. */ |
176 | #ifdef IN_LIBGCC2 | |
177 | #undef TARGET_64BIT | |
178 | #ifdef __s390x__ | |
179 | #define TARGET_64BIT 1 | |
180 | #else | |
181 | #define TARGET_64BIT 0 | |
182 | #endif | |
183 | #endif | |
184 | ||
185 | ||
9db1d521 HP |
186 | /* Target machine storage layout. */ |
187 | ||
862a2d83 | 188 | /* Everything is big-endian. */ |
9db1d521 | 189 | #define BITS_BIG_ENDIAN 1 |
9db1d521 | 190 | #define BYTES_BIG_ENDIAN 1 |
9db1d521 HP |
191 | #define WORDS_BIG_ENDIAN 1 |
192 | ||
9db1d521 | 193 | /* Width of a word, in units (bytes). */ |
9db1d521 | 194 | #define UNITS_PER_WORD (TARGET_64BIT ? 8 : 4) |
fe86047c | 195 | #ifndef IN_LIBGCC2 |
9db1d521 | 196 | #define MIN_UNITS_PER_WORD 4 |
fe86047c | 197 | #endif |
862a2d83 | 198 | #define MAX_BITS_PER_WORD 64 |
9db1d521 | 199 | |
862a2d83 | 200 | /* Function arguments and return values are promoted to word size. */ |
d4453b7a | 201 | #define PROMOTE_FUNCTION_MODE(MODE, UNSIGNEDP, TYPE) \ |
9db1d521 HP |
202 | if (INTEGRAL_MODE_P (MODE) && \ |
203 | GET_MODE_SIZE (MODE) < UNITS_PER_WORD) { \ | |
204 | (MODE) = Pmode; \ | |
205 | } | |
206 | ||
9db1d521 | 207 | /* Allocation boundary (in *bits*) for storing arguments in argument list. */ |
9db1d521 HP |
208 | #define PARM_BOUNDARY (TARGET_64BIT ? 64 : 32) |
209 | ||
210 | /* Boundary (in *bits*) on which stack pointer should be aligned. */ | |
9db1d521 HP |
211 | #define STACK_BOUNDARY 64 |
212 | ||
213 | /* Allocation boundary (in *bits*) for the code of a function. */ | |
9db1d521 HP |
214 | #define FUNCTION_BOUNDARY 32 |
215 | ||
216 | /* There is no point aligning anything to a rounder boundary than this. */ | |
9db1d521 HP |
217 | #define BIGGEST_ALIGNMENT 64 |
218 | ||
219 | /* Alignment of field after `int : 0' in a structure. */ | |
9db1d521 HP |
220 | #define EMPTY_FIELD_BOUNDARY 32 |
221 | ||
f710504c | 222 | /* Alignment on even addresses for LARL instruction. */ |
9db1d521 | 223 | #define CONSTANT_ALIGNMENT(EXP, ALIGN) (ALIGN) < 16 ? 16 : (ALIGN) |
9db1d521 HP |
224 | #define DATA_ALIGNMENT(TYPE, ALIGN) (ALIGN) < 16 ? 16 : (ALIGN) |
225 | ||
862a2d83 | 226 | /* Alignment is not required by the hardware. */ |
9db1d521 HP |
227 | #define STRICT_ALIGNMENT 0 |
228 | ||
862a2d83 UW |
229 | /* Mode of stack savearea. |
230 | FUNCTION is VOIDmode because calling convention maintains SP. | |
231 | BLOCK needs Pmode for SP. | |
232 | NONLOCAL needs twice Pmode to maintain both backchain and SP. */ | |
233 | #define STACK_SAVEAREA_MODE(LEVEL) \ | |
234 | (LEVEL == SAVE_FUNCTION ? VOIDmode \ | |
43ab026f | 235 | : LEVEL == SAVE_NONLOCAL ? (TARGET_64BIT ? OImode : TImode) : Pmode) |
862a2d83 | 236 | |
9db1d521 | 237 | |
862a2d83 | 238 | /* Type layout. */ |
9db1d521 | 239 | |
862a2d83 UW |
240 | /* Sizes in bits of the source language data types. */ |
241 | #define SHORT_TYPE_SIZE 16 | |
242 | #define INT_TYPE_SIZE 32 | |
243 | #define LONG_TYPE_SIZE (TARGET_64BIT ? 64 : 32) | |
862a2d83 UW |
244 | #define LONG_LONG_TYPE_SIZE 64 |
245 | #define FLOAT_TYPE_SIZE 32 | |
246 | #define DOUBLE_TYPE_SIZE 64 | |
f61a2c7d AK |
247 | #define LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64) |
248 | ||
249 | /* Define this to set long double type size to use in libgcc2.c, which can | |
250 | not depend on target_flags. */ | |
251 | #ifdef __LONG_DOUBLE_128__ | |
252 | #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 128 | |
253 | #else | |
254 | #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64 | |
255 | #endif | |
256 | ||
257 | /* Work around target_flags dependency in ada/targtyps.c. */ | |
258 | #define WIDEST_HARDWARE_FP_SIZE 64 | |
862a2d83 UW |
259 | |
260 | /* We use "unsigned char" as default. */ | |
261 | #define DEFAULT_SIGNED_CHAR 0 | |
262 | ||
263 | ||
264 | /* Register usage. */ | |
265 | ||
266 | /* We have 16 general purpose registers (registers 0-15), | |
267 | and 16 floating point registers (registers 16-31). | |
268 | (On non-IEEE machines, we have only 4 fp registers.) | |
c7453384 | 269 | |
862a2d83 UW |
270 | Amongst the general purpose registers, some are used |
271 | for specific purposes: | |
272 | GPR 11: Hard frame pointer (if needed) | |
273 | GPR 12: Global offset table pointer (if needed) | |
274 | GPR 13: Literal pool base register | |
275 | GPR 14: Return address register | |
276 | GPR 15: Stack pointer | |
c7453384 | 277 | |
c5aa1d12 | 278 | Registers 32-35 are 'fake' hard registers that do not |
862a2d83 UW |
279 | correspond to actual hardware: |
280 | Reg 32: Argument pointer | |
281 | Reg 33: Condition code | |
c5aa1d12 UW |
282 | Reg 34: Frame pointer |
283 | Reg 35: Return address pointer | |
862a2d83 | 284 | |
c5aa1d12 UW |
285 | Registers 36 and 37 are mapped to access registers |
286 | 0 and 1, used to implement thread-local storage. */ | |
287 | ||
288 | #define FIRST_PSEUDO_REGISTER 38 | |
862a2d83 UW |
289 | |
290 | /* Standard register usage. */ | |
8e509cf9 UW |
291 | #define GENERAL_REGNO_P(N) ((int)(N) >= 0 && (N) < 16) |
292 | #define ADDR_REGNO_P(N) ((N) >= 1 && (N) < 16) | |
142cd70f | 293 | #define FP_REGNO_P(N) ((N) >= 16 && (N) < 32) |
8e509cf9 | 294 | #define CC_REGNO_P(N) ((N) == 33) |
a38e09bc | 295 | #define FRAME_REGNO_P(N) ((N) == 32 || (N) == 34 || (N) == 35) |
c5aa1d12 | 296 | #define ACCESS_REGNO_P(N) ((N) == 36 || (N) == 37) |
8e509cf9 UW |
297 | |
298 | #define GENERAL_REG_P(X) (REG_P (X) && GENERAL_REGNO_P (REGNO (X))) | |
299 | #define ADDR_REG_P(X) (REG_P (X) && ADDR_REGNO_P (REGNO (X))) | |
300 | #define FP_REG_P(X) (REG_P (X) && FP_REGNO_P (REGNO (X))) | |
301 | #define CC_REG_P(X) (REG_P (X) && CC_REGNO_P (REGNO (X))) | |
4888ec5d | 302 | #define FRAME_REG_P(X) (REG_P (X) && FRAME_REGNO_P (REGNO (X))) |
c5aa1d12 | 303 | #define ACCESS_REG_P(X) (REG_P (X) && ACCESS_REGNO_P (REGNO (X))) |
9db1d521 | 304 | |
862a2d83 | 305 | /* Set up fixed registers and calling convention: |
9db1d521 | 306 | |
862a2d83 UW |
307 | GPRs 0-5 are always call-clobbered, |
308 | GPRs 6-15 are always call-saved. | |
309 | GPR 12 is fixed if used as GOT pointer. | |
310 | GPR 13 is always fixed (as literal pool pointer). | |
545d16ff | 311 | GPR 14 is always fixed on S/390 machines (as return address). |
862a2d83 UW |
312 | GPR 15 is always fixed (as stack pointer). |
313 | The 'fake' hard registers are call-clobbered and fixed. | |
c5aa1d12 | 314 | The access registers are call-saved and fixed. |
9db1d521 | 315 | |
862a2d83 UW |
316 | On 31-bit, FPRs 18-19 are call-clobbered; |
317 | on 64-bit, FPRs 24-31 are call-clobbered. | |
318 | The remaining FPRs are call-saved. */ | |
9db1d521 HP |
319 | |
320 | #define FIXED_REGISTERS \ | |
321 | { 0, 0, 0, 0, \ | |
322 | 0, 0, 0, 0, \ | |
323 | 0, 0, 0, 0, \ | |
324 | 0, 1, 1, 1, \ | |
325 | 0, 0, 0, 0, \ | |
326 | 0, 0, 0, 0, \ | |
327 | 0, 0, 0, 0, \ | |
328 | 0, 0, 0, 0, \ | |
c5aa1d12 UW |
329 | 1, 1, 1, 1, \ |
330 | 1, 1 } | |
9db1d521 | 331 | |
9db1d521 HP |
332 | #define CALL_USED_REGISTERS \ |
333 | { 1, 1, 1, 1, \ | |
334 | 1, 1, 0, 0, \ | |
335 | 0, 0, 0, 0, \ | |
336 | 0, 1, 1, 1, \ | |
4023fb28 UW |
337 | 1, 1, 1, 1, \ |
338 | 1, 1, 1, 1, \ | |
339 | 1, 1, 1, 1, \ | |
340 | 1, 1, 1, 1, \ | |
c5aa1d12 UW |
341 | 1, 1, 1, 1, \ |
342 | 1, 1 } | |
4023fb28 | 343 | |
4023fb28 UW |
344 | #define CALL_REALLY_USED_REGISTERS \ |
345 | { 1, 1, 1, 1, \ | |
9db1d521 | 346 | 1, 1, 0, 0, \ |
4023fb28 UW |
347 | 0, 0, 0, 0, \ |
348 | 0, 0, 0, 0, \ | |
9db1d521 HP |
349 | 1, 1, 1, 1, \ |
350 | 1, 1, 1, 1, \ | |
351 | 1, 1, 1, 1, \ | |
4023fb28 | 352 | 1, 1, 1, 1, \ |
c5aa1d12 UW |
353 | 1, 1, 1, 1, \ |
354 | 0, 0 } | |
9db1d521 | 355 | |
38899e29 | 356 | #define CONDITIONAL_REGISTER_USAGE s390_conditional_register_usage () |
9db1d521 | 357 | |
862a2d83 UW |
358 | /* Preferred register allocation order. */ |
359 | #define REG_ALLOC_ORDER \ | |
7633f08e | 360 | { 1, 2, 3, 4, 5, 0, 12, 11, 10, 9, 8, 7, 6, 14, 13, \ |
862a2d83 UW |
361 | 16, 17, 18, 19, 20, 21, 22, 23, \ |
362 | 24, 25, 26, 27, 28, 29, 30, 31, \ | |
c5aa1d12 | 363 | 15, 32, 33, 34, 35, 36, 37 } |
9db1d521 | 364 | |
9db1d521 | 365 | |
862a2d83 | 366 | /* Fitting values into registers. */ |
c7453384 | 367 | |
862a2d83 UW |
368 | /* Integer modes <= word size fit into any GPR. |
369 | Integer modes > word size fit into successive GPRs, starting with | |
370 | an even-numbered register. | |
371 | SImode and DImode fit into FPRs as well. | |
c7453384 | 372 | |
862a2d83 UW |
373 | Floating point modes <= word size fit into any FPR or GPR. |
374 | Floating point modes > word size (i.e. DFmode on 32-bit) fit | |
375 | into any FPR, or an even-odd GPR pair. | |
f61a2c7d | 376 | TFmode fits only into an even-odd FPR pair. |
c7453384 | 377 | |
862a2d83 UW |
378 | Complex floating point modes fit either into two FPRs, or into |
379 | successive GPRs (again starting with an even number). | |
f61a2c7d | 380 | TCmode fits only into two successive even-odd FPR pairs. |
c7453384 | 381 | |
862a2d83 | 382 | Condition code modes fit only into the CC register. */ |
9db1d521 | 383 | |
74aa8b4b AK |
384 | /* Because all registers in a class have the same size HARD_REGNO_NREGS |
385 | is equivalent to CLASS_MAX_NREGS. */ | |
9db1d521 | 386 | #define HARD_REGNO_NREGS(REGNO, MODE) \ |
74aa8b4b AK |
387 | s390_class_max_nregs (REGNO_REG_CLASS (REGNO), (MODE)) |
388 | ||
389 | #define HARD_REGNO_MODE_OK(REGNO, MODE) \ | |
390 | s390_hard_regno_mode_ok ((REGNO), (MODE)) | |
391 | ||
392 | #define HARD_REGNO_RENAME_OK(FROM, TO) \ | |
7633f08e UW |
393 | s390_hard_regno_rename_ok (FROM, TO) |
394 | ||
9db1d521 HP |
395 | #define MODES_TIEABLE_P(MODE1, MODE2) \ |
396 | (((MODE1) == SFmode || (MODE1) == DFmode) \ | |
397 | == ((MODE2) == SFmode || (MODE2) == DFmode)) | |
398 | ||
862a2d83 UW |
399 | /* Maximum number of registers to represent a value of mode MODE |
400 | in a register of class CLASS. */ | |
401 | #define CLASS_MAX_NREGS(CLASS, MODE) \ | |
74aa8b4b | 402 | s390_class_max_nregs ((CLASS), (MODE)) |
4023fb28 | 403 | |
862a2d83 UW |
404 | /* If a 4-byte value is loaded into a FPR, it is placed into the |
405 | *upper* half of the register, not the lower. Therefore, we | |
c5aa1d12 UW |
406 | cannot use SUBREGs to switch between modes in FP registers. |
407 | Likewise for access registers, since they have only half the | |
408 | word size on 64-bit. */ | |
f61a2c7d AK |
409 | #define CANNOT_CHANGE_MODE_CLASS(FROM, TO, CLASS) \ |
410 | (GET_MODE_SIZE (FROM) != GET_MODE_SIZE (TO) \ | |
411 | ? ((reg_classes_intersect_p (FP_REGS, CLASS) \ | |
412 | && (GET_MODE_SIZE (FROM) < 8 || GET_MODE_SIZE (TO) < 8)) \ | |
413 | || reg_classes_intersect_p (ACCESS_REGS, CLASS)) : 0) | |
9db1d521 | 414 | |
862a2d83 | 415 | /* Register classes. */ |
c7453384 | 416 | |
862a2d83 UW |
417 | /* We use the following register classes: |
418 | GENERAL_REGS All general purpose registers | |
419 | ADDR_REGS All general purpose registers except %r0 | |
420 | (These registers can be used in address generation) | |
421 | FP_REGS All floating point registers | |
c5aa1d12 UW |
422 | CC_REGS The condition code register |
423 | ACCESS_REGS The access registers | |
c7453384 | 424 | |
862a2d83 UW |
425 | GENERAL_FP_REGS Union of GENERAL_REGS and FP_REGS |
426 | ADDR_FP_REGS Union of ADDR_REGS and FP_REGS | |
c5aa1d12 UW |
427 | GENERAL_CC_REGS Union of GENERAL_REGS and CC_REGS |
428 | ADDR_CC_REGS Union of ADDR_REGS and CC_REGS | |
c7453384 | 429 | |
862a2d83 UW |
430 | NO_REGS No registers |
431 | ALL_REGS All registers | |
c7453384 | 432 | |
862a2d83 | 433 | Note that the 'fake' frame pointer and argument pointer registers |
c5aa1d12 | 434 | are included amongst the address registers here. */ |
9db1d521 HP |
435 | |
436 | enum reg_class | |
437 | { | |
c5aa1d12 | 438 | NO_REGS, CC_REGS, ADDR_REGS, GENERAL_REGS, ACCESS_REGS, |
9dc62c00 | 439 | ADDR_CC_REGS, GENERAL_CC_REGS, |
4023fb28 UW |
440 | FP_REGS, ADDR_FP_REGS, GENERAL_FP_REGS, |
441 | ALL_REGS, LIM_REG_CLASSES | |
9db1d521 | 442 | }; |
9db1d521 HP |
443 | #define N_REG_CLASSES (int) LIM_REG_CLASSES |
444 | ||
c5aa1d12 UW |
445 | #define REG_CLASS_NAMES \ |
446 | { "NO_REGS", "CC_REGS", "ADDR_REGS", "GENERAL_REGS", "ACCESS_REGS", \ | |
447 | "ADDR_CC_REGS", "GENERAL_CC_REGS", \ | |
448 | "FP_REGS", "ADDR_FP_REGS", "GENERAL_FP_REGS", "ALL_REGS" } | |
9db1d521 | 449 | |
862a2d83 | 450 | /* Class -> register mapping. */ |
9db1d521 HP |
451 | #define REG_CLASS_CONTENTS \ |
452 | { \ | |
453 | { 0x00000000, 0x00000000 }, /* NO_REGS */ \ | |
9dc62c00 | 454 | { 0x00000000, 0x00000002 }, /* CC_REGS */ \ |
a38e09bc AK |
455 | { 0x0000fffe, 0x0000000d }, /* ADDR_REGS */ \ |
456 | { 0x0000ffff, 0x0000000d }, /* GENERAL_REGS */ \ | |
c5aa1d12 | 457 | { 0x00000000, 0x00000030 }, /* ACCESS_REGS */ \ |
9dc62c00 AK |
458 | { 0x0000fffe, 0x0000000f }, /* ADDR_CC_REGS */ \ |
459 | { 0x0000ffff, 0x0000000f }, /* GENERAL_CC_REGS */ \ | |
9db1d521 | 460 | { 0xffff0000, 0x00000000 }, /* FP_REGS */ \ |
a38e09bc AK |
461 | { 0xfffffffe, 0x0000000d }, /* ADDR_FP_REGS */ \ |
462 | { 0xffffffff, 0x0000000d }, /* GENERAL_FP_REGS */ \ | |
c5aa1d12 | 463 | { 0xffffffff, 0x0000003f }, /* ALL_REGS */ \ |
9db1d521 HP |
464 | } |
465 | ||
862a2d83 UW |
466 | /* Register -> class mapping. */ |
467 | extern const enum reg_class regclass_map[FIRST_PSEUDO_REGISTER]; | |
468 | #define REGNO_REG_CLASS(REGNO) (regclass_map[REGNO]) | |
9db1d521 | 469 | |
862a2d83 UW |
470 | /* ADDR_REGS can be used as base or index register. */ |
471 | #define INDEX_REG_CLASS ADDR_REGS | |
472 | #define BASE_REG_CLASS ADDR_REGS | |
9db1d521 | 473 | |
862a2d83 UW |
474 | /* Check whether REGNO is a hard register of the suitable class |
475 | or a pseudo register currently allocated to one such. */ | |
476 | #define REGNO_OK_FOR_INDEX_P(REGNO) \ | |
477 | (((REGNO) < FIRST_PSEUDO_REGISTER \ | |
93fa8428 AK |
478 | && REGNO_REG_CLASS ((REGNO)) == ADDR_REGS) \ |
479 | || ADDR_REGNO_P (reg_renumber[REGNO])) | |
862a2d83 | 480 | #define REGNO_OK_FOR_BASE_P(REGNO) REGNO_OK_FOR_INDEX_P (REGNO) |
9db1d521 | 481 | |
9db1d521 | 482 | |
862a2d83 UW |
483 | /* Given an rtx X being reloaded into a reg required to be in class CLASS, |
484 | return the class of reg to actually use. */ | |
485 | #define PREFERRED_RELOAD_CLASS(X, CLASS) \ | |
486 | s390_preferred_reload_class ((X), (CLASS)) | |
9db1d521 | 487 | |
862a2d83 UW |
488 | /* We need secondary memory to move data between GPRs and FPRs. */ |
489 | #define SECONDARY_MEMORY_NEEDED(CLASS1, CLASS2, MODE) \ | |
85dae55a AK |
490 | ((CLASS1) != (CLASS2) \ |
491 | && ((CLASS1) == FP_REGS || (CLASS2) == FP_REGS) \ | |
492 | && (!TARGET_DFP || GET_MODE_SIZE (MODE) != 8)) | |
862a2d83 UW |
493 | |
494 | /* Get_secondary_mem widens its argument to BITS_PER_WORD which loses on 64bit | |
495 | because the movsi and movsf patterns don't handle r/f moves. */ | |
496 | #define SECONDARY_MEMORY_NEEDED_MODE(MODE) \ | |
497 | (GET_MODE_BITSIZE (MODE) < 32 \ | |
498 | ? mode_for_size (32, GET_MODE_CLASS (MODE), 0) \ | |
499 | : MODE) | |
500 | ||
501 | ||
862a2d83 | 502 | /* Stack layout and calling conventions. */ |
c7453384 | 503 | |
862a2d83 UW |
504 | /* Our stack grows from higher to lower addresses. However, local variables |
505 | are accessed by positive offsets, and function arguments are stored at | |
506 | increasing addresses. */ | |
507 | #define STACK_GROWS_DOWNWARD | |
63296cb1 | 508 | #define FRAME_GROWS_DOWNWARD 1 |
862a2d83 | 509 | /* #undef ARGS_GROW_DOWNWARD */ |
9db1d521 | 510 | |
862a2d83 UW |
511 | /* The basic stack layout looks like this: the stack pointer points |
512 | to the register save area for called functions. Above that area | |
513 | is the location to place outgoing arguments. Above those follow | |
514 | dynamic allocations (alloca), and finally the local variables. */ | |
9db1d521 | 515 | |
862a2d83 UW |
516 | /* Offset from stack-pointer to first location of outgoing args. */ |
517 | #define STACK_POINTER_OFFSET (TARGET_64BIT ? 160 : 96) | |
9db1d521 | 518 | |
862a2d83 | 519 | /* Offset within stack frame to start allocating local variables at. */ |
63296cb1 | 520 | #define STARTING_FRAME_OFFSET 0 |
9db1d521 | 521 | |
862a2d83 UW |
522 | /* Offset from the stack pointer register to an item dynamically |
523 | allocated on the stack, e.g., by `alloca'. */ | |
63296cb1 AK |
524 | extern int current_function_outgoing_args_size; |
525 | #define STACK_DYNAMIC_OFFSET(FUNDECL) \ | |
526 | (STACK_POINTER_OFFSET + current_function_outgoing_args_size) | |
9db1d521 | 527 | |
862a2d83 UW |
528 | /* Offset of first parameter from the argument pointer register value. |
529 | We have a fake argument pointer register that points directly to | |
530 | the argument area. */ | |
531 | #define FIRST_PARM_OFFSET(FNDECL) 0 | |
9db1d521 | 532 | |
c6d01079 AK |
533 | /* Defining this macro makes __builtin_frame_address(0) and |
534 | __builtin_return_address(0) work with -fomit-frame-pointer. */ | |
535 | #define INITIAL_FRAME_ADDRESS_RTX \ | |
536 | (TARGET_PACKED_STACK ? \ | |
537 | plus_constant (arg_pointer_rtx, -UNITS_PER_WORD) : \ | |
538 | plus_constant (arg_pointer_rtx, -STACK_POINTER_OFFSET)) | |
539 | ||
c7453384 | 540 | /* The return address of the current frame is retrieved |
4023fb28 UW |
541 | from the initial value of register RETURN_REGNUM. |
542 | For frames farther back, we use the stack slot where | |
543 | the corresponding RETURN_REGNUM register was saved. */ | |
c6d01079 AK |
544 | #define DYNAMIC_CHAIN_ADDRESS(FRAME) \ |
545 | (TARGET_PACKED_STACK ? \ | |
546 | plus_constant ((FRAME), STACK_POINTER_OFFSET - UNITS_PER_WORD) : (FRAME)) | |
4023fb28 | 547 | |
c6d01079 | 548 | #define RETURN_ADDR_RTX(COUNT, FRAME) \ |
5d4d885c | 549 | s390_return_addr_rtx ((COUNT), DYNAMIC_CHAIN_ADDRESS ((FRAME))) |
9db1d521 | 550 | |
862a2d83 | 551 | /* In 31-bit mode, we need to mask off the high bit of return addresses. */ |
a556fd39 | 552 | #define MASK_RETURN_ADDR (TARGET_64BIT ? constm1_rtx : GEN_INT (0x7fffffff)) |
9db1d521 | 553 | |
4023fb28 | 554 | |
862a2d83 | 555 | /* Exception handling. */ |
c7453384 | 556 | |
862a2d83 UW |
557 | /* Describe calling conventions for DWARF-2 exception handling. */ |
558 | #define INCOMING_RETURN_ADDR_RTX gen_rtx_REG (Pmode, RETURN_REGNUM) | |
4023fb28 | 559 | #define INCOMING_FRAME_SP_OFFSET STACK_POINTER_OFFSET |
9db1d521 HP |
560 | #define DWARF_FRAME_RETURN_COLUMN 14 |
561 | ||
562 | /* Describe how we implement __builtin_eh_return. */ | |
563 | #define EH_RETURN_DATA_REGNO(N) ((N) < 4 ? (N) + 6 : INVALID_REGNUM) | |
a38e09bc AK |
564 | #define EH_RETURN_HANDLER_RTX gen_rtx_MEM (Pmode, return_address_pointer_rtx) |
565 | ||
18789f4e UW |
566 | /* Select a format to encode pointers in exception handling data. */ |
567 | #define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \ | |
568 | (flag_pic \ | |
569 | ? ((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel | DW_EH_PE_sdata4 \ | |
570 | : DW_EH_PE_absptr) | |
571 | ||
9db1d521 | 572 | |
862a2d83 | 573 | /* Frame registers. */ |
9db1d521 | 574 | |
862a2d83 UW |
575 | #define STACK_POINTER_REGNUM 15 |
576 | #define FRAME_POINTER_REGNUM 34 | |
577 | #define HARD_FRAME_POINTER_REGNUM 11 | |
578 | #define ARG_POINTER_REGNUM 32 | |
a38e09bc | 579 | #define RETURN_ADDRESS_POINTER_REGNUM 35 |
9db1d521 | 580 | |
c7453384 EC |
581 | /* The static chain must be call-clobbered, but not used for |
582 | function argument passing. As register 1 is clobbered by | |
862a2d83 UW |
583 | the trampoline code, we only have one option. */ |
584 | #define STATIC_CHAIN_REGNUM 0 | |
9db1d521 | 585 | |
862a2d83 UW |
586 | /* Number of hardware registers that go into the DWARF-2 unwind info. |
587 | To avoid ABI incompatibility, this number must not change even as | |
588 | 'fake' hard registers are added or removed. */ | |
589 | #define DWARF_FRAME_REGISTERS 34 | |
9db1d521 | 590 | |
9db1d521 | 591 | |
862a2d83 | 592 | /* Frame pointer and argument pointer elimination. */ |
9db1d521 | 593 | |
862a2d83 | 594 | #define FRAME_POINTER_REQUIRED 0 |
9db1d521 | 595 | |
7633f08e UW |
596 | #define ELIMINABLE_REGS \ |
597 | {{ FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM }, \ | |
598 | { FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM }, \ | |
599 | { ARG_POINTER_REGNUM, STACK_POINTER_REGNUM }, \ | |
600 | { ARG_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM }, \ | |
601 | { RETURN_ADDRESS_POINTER_REGNUM, STACK_POINTER_REGNUM }, \ | |
602 | { RETURN_ADDRESS_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM }, \ | |
603 | { BASE_REGNUM, BASE_REGNUM }} | |
9db1d521 | 604 | |
91086990 UW |
605 | #define CAN_ELIMINATE(FROM, TO) \ |
606 | s390_can_eliminate ((FROM), (TO)) | |
607 | ||
608 | #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \ | |
609 | (OFFSET) = s390_initial_elimination_offset ((FROM), (TO)) | |
9db1d521 | 610 | |
9db1d521 | 611 | |
862a2d83 | 612 | /* Stack arguments. */ |
c7453384 | 613 | |
862a2d83 UW |
614 | /* We need current_function_outgoing_args to be valid. */ |
615 | #define ACCUMULATE_OUTGOING_ARGS 1 | |
9db1d521 | 616 | |
862a2d83 UW |
617 | /* Return doesn't modify the stack. */ |
618 | #define RETURN_POPS_ARGS(FUNDECL, FUNTYPE, SIZE) 0 | |
9db1d521 | 619 | |
9db1d521 | 620 | |
862a2d83 | 621 | /* Register arguments. */ |
c7453384 | 622 | |
9db1d521 HP |
623 | typedef struct s390_arg_structure |
624 | { | |
625 | int gprs; /* gpr so far */ | |
626 | int fprs; /* fpr so far */ | |
627 | } | |
628 | CUMULATIVE_ARGS; | |
629 | ||
07711f53 | 630 | #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, NN, N_NAMED_ARGS) \ |
9db1d521 HP |
631 | ((CUM).gprs=0, (CUM).fprs=0) |
632 | ||
9db1d521 | 633 | #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \ |
994fe660 | 634 | s390_function_arg_advance (&CUM, MODE, TYPE, NAMED) |
9db1d521 | 635 | |
9db1d521 | 636 | #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \ |
994fe660 | 637 | s390_function_arg (&CUM, MODE, TYPE, NAMED) |
9db1d521 | 638 | |
862a2d83 UW |
639 | /* Arguments can be placed in general registers 2 to 6, |
640 | or in floating point registers 0 and 2. */ | |
641 | #define FUNCTION_ARG_REGNO_P(N) (((N) >=2 && (N) <7) || \ | |
642 | (N) == 16 || (N) == 17) | |
9db1d521 | 643 | |
9db1d521 | 644 | |
862a2d83 | 645 | /* Scalar return values. */ |
c7453384 | 646 | |
8c17530e UW |
647 | #define FUNCTION_VALUE(VALTYPE, FUNC) \ |
648 | s390_function_value ((VALTYPE), VOIDmode) | |
649 | ||
650 | #define LIBCALL_VALUE(MODE) \ | |
651 | s390_function_value (NULL, (MODE)) | |
9db1d521 | 652 | |
862a2d83 | 653 | /* Only gpr 2 and fpr 0 are ever used as return registers. */ |
9db1d521 HP |
654 | #define FUNCTION_VALUE_REGNO_P(N) ((N) == 2 || (N) == 16) |
655 | ||
9db1d521 | 656 | |
862a2d83 | 657 | /* Function entry and exit. */ |
c7453384 | 658 | |
862a2d83 UW |
659 | /* When returning from a function, the stack pointer does not matter. */ |
660 | #define EXIT_IGNORE_STACK 1 | |
9db1d521 | 661 | |
9db1d521 | 662 | |
862a2d83 | 663 | /* Profiling. */ |
9db1d521 HP |
664 | |
665 | #define FUNCTION_PROFILER(FILE, LABELNO) \ | |
862a2d83 | 666 | s390_function_profiler ((FILE), ((LABELNO))) |
9db1d521 | 667 | |
c52a375d | 668 | #define PROFILE_BEFORE_PROLOGUE 1 |
9db1d521 | 669 | |
9db1d521 | 670 | |
862a2d83 | 671 | /* Trampolines for nested functions. */ |
9db1d521 | 672 | |
cadc42db | 673 | #define TRAMPOLINE_SIZE (TARGET_64BIT ? 32 : 16) |
9db1d521 | 674 | |
862a2d83 UW |
675 | #define INITIALIZE_TRAMPOLINE(ADDR, FNADDR, CXT) \ |
676 | s390_initialize_trampoline ((ADDR), (FNADDR), (CXT)) | |
9db1d521 | 677 | |
862a2d83 UW |
678 | #define TRAMPOLINE_TEMPLATE(FILE) \ |
679 | s390_trampoline_template (FILE) | |
9db1d521 | 680 | |
9db1d521 | 681 | |
862a2d83 | 682 | /* Addressing modes, and classification of registers for them. */ |
9db1d521 | 683 | |
862a2d83 UW |
684 | /* Recognize any constant value that is a valid address. */ |
685 | #define CONSTANT_ADDRESS_P(X) 0 | |
9db1d521 | 686 | |
862a2d83 UW |
687 | /* Maximum number of registers that can appear in a valid memory address. */ |
688 | #define MAX_REGS_PER_ADDRESS 2 | |
9db1d521 | 689 | |
862a2d83 UW |
690 | /* S/390 has no mode dependent addresses. */ |
691 | #define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR, LABEL) | |
9db1d521 HP |
692 | |
693 | /* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression that is a | |
694 | valid memory address for an instruction. | |
695 | The MODE argument is the machine mode for the MEM expression | |
862a2d83 | 696 | that wants to use this address. */ |
9db1d521 HP |
697 | #ifdef REG_OK_STRICT |
698 | #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \ | |
699 | { \ | |
700 | if (legitimate_address_p (MODE, X, 1)) \ | |
701 | goto ADDR; \ | |
702 | } | |
703 | #else | |
704 | #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \ | |
705 | { \ | |
706 | if (legitimate_address_p (MODE, X, 0)) \ | |
707 | goto ADDR; \ | |
708 | } | |
709 | #endif | |
710 | ||
9db1d521 HP |
711 | /* Try machine-dependent ways of modifying an illegitimate address |
712 | to be legitimate. If we find one, return the new, valid address. | |
713 | This macro is used in only one place: `memory_address' in explow.c. */ | |
9db1d521 HP |
714 | #define LEGITIMIZE_ADDRESS(X, OLDX, MODE, WIN) \ |
715 | { \ | |
716 | (X) = legitimize_address (X, OLDX, MODE); \ | |
717 | if (memory_address_p (MODE, X)) \ | |
718 | goto WIN; \ | |
719 | } | |
720 | ||
0b540f12 UW |
721 | /* Try a machine-dependent way of reloading an illegitimate address |
722 | operand. If we find one, push the reload and jump to WIN. This | |
723 | macro is used in only one place: `find_reloads_address' in reload.c. */ | |
724 | #define LEGITIMIZE_RELOAD_ADDRESS(AD, MODE, OPNUM, TYPE, IND, WIN) \ | |
725 | do { \ | |
726 | rtx new = legitimize_reload_address (AD, MODE, OPNUM, (int)(TYPE)); \ | |
727 | if (new) \ | |
728 | { \ | |
729 | (AD) = new; \ | |
730 | goto WIN; \ | |
731 | } \ | |
732 | } while (0) | |
733 | ||
862a2d83 UW |
734 | /* Nonzero if the constant value X is a legitimate general operand. |
735 | It is given that X satisfies CONSTANT_P or is a CONST_DOUBLE. */ | |
736 | #define LEGITIMATE_CONSTANT_P(X) \ | |
737 | legitimate_constant_p (X) | |
9db1d521 | 738 | |
862a2d83 UW |
739 | /* Helper macro for s390.c and s390.md to check for symbolic constants. */ |
740 | #define SYMBOLIC_CONST(X) \ | |
741 | (GET_CODE (X) == SYMBOL_REF \ | |
742 | || GET_CODE (X) == LABEL_REF \ | |
743 | || (GET_CODE (X) == CONST && symbolic_reference_mentioned_p (X))) | |
9db1d521 | 744 | |
fd3cd001 UW |
745 | #define TLS_SYMBOLIC_CONST(X) \ |
746 | ((GET_CODE (X) == SYMBOL_REF && tls_symbolic_operand (X)) \ | |
747 | || (GET_CODE (X) == CONST && tls_symbolic_reference_mentioned_p (X))) | |
748 | ||
9db1d521 | 749 | |
862a2d83 | 750 | /* Condition codes. */ |
9db1d521 | 751 | |
862a2d83 UW |
752 | /* Given a comparison code (EQ, NE, etc.) and the first operand of a COMPARE, |
753 | return the mode to be used for the comparison. */ | |
754 | #define SELECT_CC_MODE(OP, X, Y) s390_select_ccmode ((OP), (X), (Y)) | |
c7453384 | 755 | |
68f9c5e2 UW |
756 | /* Canonicalize a comparison from one we don't have to one we do have. */ |
757 | #define CANONICALIZE_COMPARISON(CODE, OP0, OP1) \ | |
758 | s390_canonicalize_comparison (&(CODE), &(OP0), &(OP1)) | |
759 | ||
862a2d83 UW |
760 | /* Define the information needed to generate branch and scc insns. This is |
761 | stored from the compare operation. Note that we can't use "rtx" here | |
762 | since it hasn't been defined! */ | |
e0374221 | 763 | extern struct rtx_def *s390_compare_op0, *s390_compare_op1, *s390_compare_emitted; |
9db1d521 | 764 | |
9db1d521 | 765 | |
862a2d83 | 766 | /* Relative costs of operations. */ |
9db1d521 | 767 | |
9db1d521 | 768 | /* On s390, copy between fprs and gprs is expensive. */ |
9db1d521 | 769 | #define REGISTER_MOVE_COST(MODE, CLASS1, CLASS2) \ |
14b3e8ef UW |
770 | (( ( reg_classes_intersect_p ((CLASS1), GENERAL_REGS) \ |
771 | && reg_classes_intersect_p ((CLASS2), FP_REGS)) \ | |
772 | || ( reg_classes_intersect_p ((CLASS1), FP_REGS) \ | |
773 | && reg_classes_intersect_p ((CLASS2), GENERAL_REGS))) ? 10 : 1) | |
9db1d521 | 774 | |
9db1d521 HP |
775 | /* A C expression for the cost of moving data of mode M between a |
776 | register and memory. A value of 2 is the default; this cost is | |
862a2d83 | 777 | relative to those in `REGISTER_MOVE_COST'. */ |
9db1d521 HP |
778 | #define MEMORY_MOVE_COST(M, C, I) 1 |
779 | ||
780 | /* A C expression for the cost of a branch instruction. A value of 1 | |
781 | is the default; other values are interpreted relative to that. */ | |
9db1d521 HP |
782 | #define BRANCH_COST 1 |
783 | ||
862a2d83 UW |
784 | /* Nonzero if access to memory by bytes is slow and undesirable. */ |
785 | #define SLOW_BYTE_ACCESS 1 | |
786 | ||
c5443745 UW |
787 | /* An integer expression for the size in bits of the largest integer machine |
788 | mode that should actually be used. We allow pairs of registers. */ | |
789 | #define MAX_FIXED_MODE_SIZE GET_MODE_BITSIZE (TARGET_64BIT ? TImode : DImode) | |
790 | ||
862a2d83 | 791 | /* The maximum number of bytes that a single instruction can move quickly |
ff482c8d | 792 | between memory and registers or between two memory locations. */ |
862a2d83 | 793 | #define MOVE_MAX (TARGET_64BIT ? 16 : 8) |
c5443745 | 794 | #define MOVE_MAX_PIECES (TARGET_64BIT ? 8 : 4) |
862a2d83 | 795 | #define MAX_MOVE_MAX 16 |
9db1d521 | 796 | |
862a2d83 UW |
797 | /* Determine whether to use move_by_pieces or block move insn. */ |
798 | #define MOVE_BY_PIECES_P(SIZE, ALIGN) \ | |
799 | ( (SIZE) == 1 || (SIZE) == 2 || (SIZE) == 4 \ | |
800 | || (TARGET_64BIT && (SIZE) == 8) ) | |
801 | ||
802 | /* Determine whether to use clear_by_pieces or block clear insn. */ | |
803 | #define CLEAR_BY_PIECES_P(SIZE, ALIGN) \ | |
804 | ( (SIZE) == 1 || (SIZE) == 2 || (SIZE) == 4 \ | |
805 | || (TARGET_64BIT && (SIZE) == 8) ) | |
806 | ||
45d78e7f | 807 | /* This macro is used to determine whether store_by_pieces should be |
cfa31150 | 808 | called to "memcpy" storage when the source is a constant string. */ |
45d78e7f JJ |
809 | #define STORE_BY_PIECES_P(SIZE, ALIGN) MOVE_BY_PIECES_P (SIZE, ALIGN) |
810 | ||
cfa31150 SL |
811 | /* Likewise to decide whether to "memset" storage with byte values |
812 | other than zero. */ | |
813 | #define SET_BY_PIECES_P(SIZE, ALIGN) STORE_BY_PIECES_P (SIZE, ALIGN) | |
814 | ||
862a2d83 UW |
815 | /* Don't perform CSE on function addresses. */ |
816 | #define NO_FUNCTION_CSE | |
817 | ||
5f1b2ee6 AK |
818 | /* This value is used in tree-sra to decide whether it might benefical |
819 | to split a struct move into several word-size moves. For S/390 | |
820 | only small values make sense here since struct moves are relatively | |
821 | cheap thanks to mvc so the small default value choosen for archs | |
822 | with memmove patterns should be ok. But this value is multiplied | |
823 | in tree-sra with UNITS_PER_WORD to make a decision so we adjust it | |
824 | here to compensate for that factor since mvc costs exactly the same | |
825 | on 31 and 64 bit. */ | |
826 | #define MOVE_RATIO (TARGET_64BIT? 2 : 4) | |
827 | ||
862a2d83 UW |
828 | |
829 | /* Sections. */ | |
830 | ||
831 | /* Output before read-only data. */ | |
832 | #define TEXT_SECTION_ASM_OP ".text" | |
833 | ||
834 | /* Output before writable (initialized) data. */ | |
835 | #define DATA_SECTION_ASM_OP ".data" | |
836 | ||
837 | /* Output before writable (uninitialized) data. */ | |
838 | #define BSS_SECTION_ASM_OP ".bss" | |
839 | ||
840 | /* S/390 constant pool breaks the devices in crtstuff.c to control section | |
841 | in where code resides. We have to write it as asm code. */ | |
842 | #ifndef __s390x__ | |
843 | #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \ | |
844 | asm (SECTION_OP "\n\ | |
845 | bras\t%r2,1f\n\ | |
846 | 0: .long\t" USER_LABEL_PREFIX #FUNC " - 0b\n\ | |
847 | 1: l\t%r3,0(%r2)\n\ | |
848 | bas\t%r14,0(%r3,%r2)\n\ | |
849 | .previous"); | |
850 | #endif | |
63a1ff86 | 851 | |
862a2d83 UW |
852 | |
853 | /* Position independent code. */ | |
854 | ||
c7453384 | 855 | extern int flag_pic; |
862a2d83 UW |
856 | |
857 | #define PIC_OFFSET_TABLE_REGNUM (flag_pic ? 12 : INVALID_REGNUM) | |
858 | ||
859 | #define LEGITIMATE_PIC_OPERAND_P(X) legitimate_pic_operand_p (X) | |
63a1ff86 UW |
860 | |
861 | ||
862 | /* Assembler file format. */ | |
863 | ||
864 | /* Character to start a comment. */ | |
865 | #define ASM_COMMENT_START "#" | |
866 | ||
867 | /* Declare an uninitialized external linkage data object. */ | |
868 | #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \ | |
869 | asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN) | |
870 | ||
871 | /* Globalizing directive for a label. */ | |
872 | #define GLOBAL_ASM_OP ".globl " | |
873 | ||
874 | /* Advance the location counter to a multiple of 2**LOG bytes. */ | |
875 | #define ASM_OUTPUT_ALIGN(FILE, LOG) \ | |
876 | if ((LOG)) fprintf ((FILE), "\t.align\t%d\n", 1 << (LOG)) | |
877 | ||
878 | /* Advance the location counter by SIZE bytes. */ | |
879 | #define ASM_OUTPUT_SKIP(FILE, SIZE) \ | |
58e15542 | 880 | fprintf ((FILE), "\t.set\t.,.+"HOST_WIDE_INT_PRINT_UNSIGNED"\n", (SIZE)) |
63a1ff86 | 881 | |
63a1ff86 UW |
882 | /* The LOCAL_LABEL_PREFIX variable is used by dbxelf.h. */ |
883 | #define LOCAL_LABEL_PREFIX "." | |
9db1d521 HP |
884 | |
885 | /* How to refer to registers in assembler output. This sequence is | |
886 | indexed by compiler's hard-register-number (see above). */ | |
9db1d521 HP |
887 | #define REGISTER_NAMES \ |
888 | { "%r0", "%r1", "%r2", "%r3", "%r4", "%r5", "%r6", "%r7", \ | |
a38e09bc | 889 | "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15", \ |
9db1d521 | 890 | "%f0", "%f2", "%f4", "%f6", "%f1", "%f3", "%f5", "%f7", \ |
a38e09bc | 891 | "%f8", "%f10", "%f12", "%f14", "%f9", "%f11", "%f13", "%f15", \ |
c5aa1d12 | 892 | "%ap", "%cc", "%fp", "%rp", "%a0", "%a1" \ |
9db1d521 HP |
893 | } |
894 | ||
63a1ff86 | 895 | /* Print operand X (an rtx) in assembler syntax to file FILE. */ |
9db1d521 | 896 | #define PRINT_OPERAND(FILE, X, CODE) print_operand (FILE, X, CODE) |
9db1d521 HP |
897 | #define PRINT_OPERAND_ADDRESS(FILE, ADDR) print_operand_address (FILE, ADDR) |
898 | ||
faeb9bb6 UW |
899 | /* Output machine-dependent UNSPECs in address constants. */ |
900 | #define OUTPUT_ADDR_CONST_EXTRA(FILE, X, FAIL) \ | |
901 | do { \ | |
902 | if (!s390_output_addr_const_extra (FILE, (X))) \ | |
903 | goto FAIL; \ | |
904 | } while (0); | |
905 | ||
63a1ff86 UW |
906 | /* Output an element of a case-vector that is absolute. */ |
907 | #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \ | |
908 | do { \ | |
909 | char buf[32]; \ | |
910 | fputs (integer_asm_op (UNITS_PER_WORD, TRUE), (FILE)); \ | |
911 | ASM_GENERATE_INTERNAL_LABEL (buf, "L", (VALUE)); \ | |
912 | assemble_name ((FILE), buf); \ | |
913 | fputc ('\n', (FILE)); \ | |
914 | } while (0) | |
915 | ||
916 | /* Output an element of a case-vector that is relative. */ | |
917 | #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \ | |
918 | do { \ | |
919 | char buf[32]; \ | |
920 | fputs (integer_asm_op (UNITS_PER_WORD, TRUE), (FILE)); \ | |
921 | ASM_GENERATE_INTERNAL_LABEL (buf, "L", (VALUE)); \ | |
922 | assemble_name ((FILE), buf); \ | |
923 | fputc ('-', (FILE)); \ | |
924 | ASM_GENERATE_INTERNAL_LABEL (buf, "L", (REL)); \ | |
925 | assemble_name ((FILE), buf); \ | |
926 | fputc ('\n', (FILE)); \ | |
927 | } while (0) | |
928 | ||
9db1d521 | 929 | |
862a2d83 UW |
930 | /* Miscellaneous parameters. */ |
931 | ||
862a2d83 UW |
932 | /* Specify the machine mode that this machine uses for the index in the |
933 | tablejump instruction. */ | |
934 | #define CASE_VECTOR_MODE (TARGET_64BIT ? DImode : SImode) | |
935 | ||
862a2d83 UW |
936 | /* Value is 1 if truncating an integer of INPREC bits to OUTPREC bits |
937 | is done just by pretending it is already truncated. */ | |
938 | #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1 | |
939 | ||
940 | /* Specify the machine mode that pointers have. | |
941 | After generation of rtl, the compiler makes no further distinction | |
942 | between pointers and any other objects of this machine mode. */ | |
943 | #define Pmode ((enum machine_mode) (TARGET_64BIT ? DImode : SImode)) | |
944 | ||
c7453384 EC |
945 | /* This is -1 for "pointer mode" extend. See ptr_extend in s390.md. */ |
946 | #define POINTERS_EXTEND_UNSIGNED -1 | |
947 | ||
862a2d83 UW |
948 | /* A function address in a call instruction is a byte address (for |
949 | indexing purposes) so give the MEM rtx a byte's mode. */ | |
950 | #define FUNCTION_MODE QImode | |
951 | ||
ec24698e UW |
952 | /* Specify the value which is used when clz operand is zero. */ |
953 | #define CLZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE) ((VALUE) = 64, 1) | |
954 | ||
0bfc3f69 AS |
955 | /* Machine-specific symbol_ref flags. */ |
956 | #define SYMBOL_FLAG_ALIGN1 (SYMBOL_FLAG_MACH_DEP << 0) | |
957 | ||
958 | /* Check whether integer displacement is in range. */ | |
959 | #define DISP_IN_RANGE(d) \ | |
960 | (TARGET_LONG_DISPLACEMENT? ((d) >= -524288 && (d) <= 524287) \ | |
961 | : ((d) >= 0 && (d) <= 4095)) | |
962 | ||
c7453384 | 963 | #endif |