2004-05-03 Eric Christopher <echristo@redhat.com>
[official-gcc.git] / gcc / config / s390 / s390.h
blob9c35632d8a53e5ee055573ec3160cddcc6cfdbf9
1 /* Definitions of target machine for GNU compiler, for IBM S/390
2 Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004
3 Free Software Foundation, Inc.
4 Contributed by Hartmut Penner (hpenner@de.ibm.com) and
5 Ulrich Weigand (uweigand@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 2, or (at your option) any later
12 version.
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.
19 You should have received a copy of the GNU General Public License
20 along with GCC; see the file COPYING. If not, write to the Free
21 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 02111-1307, USA. */
24 #ifndef _S390_H
25 #define _S390_H
27 /* Override the __fixdfdi etc. routines when building libgcc2.
28 ??? This should be done in a cleaner way ... */
29 #if defined (IN_LIBGCC2) && !defined (__s390x__)
30 #include <config/s390/fixdfdi.h>
31 #endif
33 /* Which processor to generate code or schedule for. The cpu attribute
34 defines a list that mirrors this list, so changes to s390.md must be
35 made at the same time. */
37 enum processor_type
39 PROCESSOR_9672_G5,
40 PROCESSOR_9672_G6,
41 PROCESSOR_2064_Z900,
42 PROCESSOR_2084_Z990,
43 PROCESSOR_max
46 /* Optional architectural facilities supported by the processor. */
48 enum processor_flags
50 PF_IEEE_FLOAT = 1,
51 PF_ZARCH = 2,
52 PF_LONG_DISPLACEMENT = 4
55 extern enum processor_type s390_tune;
56 extern enum processor_flags s390_tune_flags;
57 extern const char *s390_tune_string;
59 extern enum processor_type s390_arch;
60 extern enum processor_flags s390_arch_flags;
61 extern const char *s390_arch_string;
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)
70 #define TARGET_LONG_DISPLACEMENT \
71 (TARGET_ZARCH && TARGET_CPU_LONG_DISPLACEMENT)
74 /* Run-time target specification. */
76 /* Target CPU builtins. */
77 #define TARGET_CPU_CPP_BUILTINS() \
78 do \
79 { \
80 builtin_assert ("cpu=s390"); \
81 builtin_assert ("machine=s390"); \
82 builtin_define ("__s390__"); \
83 if (TARGET_64BIT) \
84 builtin_define ("__s390x__"); \
85 } \
86 while (0)
88 /* Optional target features. */
89 extern int target_flags;
91 #define MASK_HARD_FLOAT 0x01
92 #define MASK_BACKCHAIN 0x02
93 #define MASK_SMALL_EXEC 0x04
94 #define MASK_DEBUG_ARG 0x08
95 #define MASK_64BIT 0x10
96 #define MASK_ZARCH 0x20
97 #define MASK_MVCLE 0x40
98 #define MASK_TPF 0x80
99 #define MASK_NO_FUSED_MADD 0x100
101 #define TARGET_HARD_FLOAT (target_flags & MASK_HARD_FLOAT)
102 #define TARGET_SOFT_FLOAT (!(target_flags & MASK_HARD_FLOAT))
103 #define TARGET_BACKCHAIN (target_flags & MASK_BACKCHAIN)
104 #define TARGET_SMALL_EXEC (target_flags & MASK_SMALL_EXEC)
105 #define TARGET_DEBUG_ARG (target_flags & MASK_DEBUG_ARG)
106 #define TARGET_64BIT (target_flags & MASK_64BIT)
107 #define TARGET_ZARCH (target_flags & MASK_ZARCH)
108 #define TARGET_MVCLE (target_flags & MASK_MVCLE)
109 #define TARGET_TPF (target_flags & MASK_TPF)
110 #define TARGET_NO_FUSED_MADD (target_flags & MASK_NO_FUSED_MADD)
111 #define TARGET_FUSED_MADD (! TARGET_NO_FUSED_MADD)
113 /* ??? Once this actually works, it could be made a runtime option. */
114 #define TARGET_IBM_FLOAT 0
115 #define TARGET_IEEE_FLOAT 1
117 #ifdef DEFAULT_TARGET_64BIT
118 #define TARGET_DEFAULT 0x31
119 #else
120 #define TARGET_DEFAULT 0x1
121 #endif
123 #define TARGET_SWITCHES \
124 { { "hard-float", 1, N_("Use hardware fp")}, \
125 { "soft-float", -1, N_("Don't use hardware fp")}, \
126 { "backchain", 2, N_("Set backchain")}, \
127 { "no-backchain", -2, N_("Don't set backchain (faster, but debug harder")},\
128 { "small-exec", 4, N_("Use bras for executable < 64k")}, \
129 { "no-small-exec", -4, N_("Don't use bras")}, \
130 { "debug", 8, N_("Additional debug prints")}, \
131 { "no-debug", -8, N_("Don't print additional debug prints")}, \
132 { "64", 16, N_("64 bit ABI")}, \
133 { "31", -16, N_("31 bit ABI")}, \
134 { "zarch", 32, N_("z/Architecture")}, \
135 { "esa", -32, N_("ESA/390 architecture")}, \
136 { "mvcle", 64, N_("mvcle use")}, \
137 { "no-mvcle", -64, N_("mvc&ex")}, \
138 { "tpf", 128, N_("enable tpf OS code")}, \
139 { "no-tpf", -128, N_("disable tpf OS code")}, \
140 { "no-fused-madd", 256, N_("disable fused multiply/add instructions")},\
141 { "fused-madd", -256, N_("enable fused multiply/add instructions")}, \
142 { "", TARGET_DEFAULT, 0 } }
144 #define TARGET_OPTIONS \
145 { { "tune=", &s390_tune_string, \
146 N_("Schedule code for given CPU"), 0}, \
147 { "arch=", &s390_arch_string, \
148 N_("Generate code for given CPU"), 0}, \
151 /* Support for configure-time defaults. */
152 #define OPTION_DEFAULT_SPECS \
153 { "mode", "%{!mesa:%{!mzarch:-m%(VALUE)}}" }, \
154 { "arch", "%{!march=*:-march=%(VALUE)}" }, \
155 { "tune", "%{!mtune=*:-mtune=%(VALUE)}" }
157 /* Defaulting rules. */
158 #ifdef DEFAULT_TARGET_64BIT
159 #define DRIVER_SELF_SPECS \
160 "%{!m31:%{!m64:-m64}}", \
161 "%{!mesa:%{!mzarch:%{m31:-mesa}%{m64:-mzarch}}}", \
162 "%{!march=*:%{mesa:-march=g5}%{mzarch:-march=z900}}"
163 #else
164 #define DRIVER_SELF_SPECS \
165 "%{!m31:%{!m64:-m31}}", \
166 "%{!mesa:%{!mzarch:%{m31:-mesa}%{m64:-mzarch}}}", \
167 "%{!march=*:%{mesa:-march=g5}%{mzarch:-march=z900}}"
168 #endif
170 /* Target version string. Overridden by the OS header. */
171 #ifdef DEFAULT_TARGET_64BIT
172 #define TARGET_VERSION fprintf (stderr, " (zSeries)");
173 #else
174 #define TARGET_VERSION fprintf (stderr, " (S/390)");
175 #endif
177 /* Hooks to override options. */
178 #define OPTIMIZATION_OPTIONS(LEVEL, SIZE) optimization_options(LEVEL, SIZE)
179 #define OVERRIDE_OPTIONS override_options ()
181 /* Frame pointer is not used for debugging. */
182 #define CAN_DEBUG_WITHOUT_FP
185 /* In libgcc2, determine target settings as compile-time constants. */
186 #ifdef IN_LIBGCC2
187 #undef TARGET_64BIT
188 #ifdef __s390x__
189 #define TARGET_64BIT 1
190 #else
191 #define TARGET_64BIT 0
192 #endif
193 #endif
196 /* Target machine storage layout. */
198 /* Everything is big-endian. */
199 #define BITS_BIG_ENDIAN 1
200 #define BYTES_BIG_ENDIAN 1
201 #define WORDS_BIG_ENDIAN 1
203 /* Width of a word, in units (bytes). */
204 #define UNITS_PER_WORD (TARGET_64BIT ? 8 : 4)
205 #ifndef IN_LIBGCC2
206 #define MIN_UNITS_PER_WORD 4
207 #endif
208 #define MAX_BITS_PER_WORD 64
210 /* Function arguments and return values are promoted to word size. */
211 #define PROMOTE_FUNCTION_MODE(MODE, UNSIGNEDP, TYPE) \
212 if (INTEGRAL_MODE_P (MODE) && \
213 GET_MODE_SIZE (MODE) < UNITS_PER_WORD) { \
214 (MODE) = Pmode; \
217 /* Allocation boundary (in *bits*) for storing arguments in argument list. */
218 #define PARM_BOUNDARY (TARGET_64BIT ? 64 : 32)
220 /* Boundary (in *bits*) on which stack pointer should be aligned. */
221 #define STACK_BOUNDARY 64
223 /* Allocation boundary (in *bits*) for the code of a function. */
224 #define FUNCTION_BOUNDARY 32
226 /* There is no point aligning anything to a rounder boundary than this. */
227 #define BIGGEST_ALIGNMENT 64
229 /* Alignment of field after `int : 0' in a structure. */
230 #define EMPTY_FIELD_BOUNDARY 32
232 /* Alignment on even addresses for LARL instruction. */
233 #define CONSTANT_ALIGNMENT(EXP, ALIGN) (ALIGN) < 16 ? 16 : (ALIGN)
234 #define DATA_ALIGNMENT(TYPE, ALIGN) (ALIGN) < 16 ? 16 : (ALIGN)
236 /* Alignment is not required by the hardware. */
237 #define STRICT_ALIGNMENT 0
239 /* Mode of stack savearea.
240 FUNCTION is VOIDmode because calling convention maintains SP.
241 BLOCK needs Pmode for SP.
242 NONLOCAL needs twice Pmode to maintain both backchain and SP. */
243 #define STACK_SAVEAREA_MODE(LEVEL) \
244 (LEVEL == SAVE_FUNCTION ? VOIDmode \
245 : LEVEL == SAVE_NONLOCAL ? (TARGET_64BIT ? OImode : TImode) : Pmode)
247 /* Define target floating point format. */
248 #define TARGET_FLOAT_FORMAT \
249 (TARGET_IEEE_FLOAT? IEEE_FLOAT_FORMAT : IBM_FLOAT_FORMAT)
252 /* Type layout. */
254 /* Sizes in bits of the source language data types. */
255 #define SHORT_TYPE_SIZE 16
256 #define INT_TYPE_SIZE 32
257 #define LONG_TYPE_SIZE (TARGET_64BIT ? 64 : 32)
258 #define LONG_LONG_TYPE_SIZE 64
259 #define FLOAT_TYPE_SIZE 32
260 #define DOUBLE_TYPE_SIZE 64
261 #define LONG_DOUBLE_TYPE_SIZE 64 /* ??? Should support extended format. */
263 /* We use "unsigned char" as default. */
264 #define DEFAULT_SIGNED_CHAR 0
267 /* Register usage. */
269 /* We have 16 general purpose registers (registers 0-15),
270 and 16 floating point registers (registers 16-31).
271 (On non-IEEE machines, we have only 4 fp registers.)
273 Amongst the general purpose registers, some are used
274 for specific purposes:
275 GPR 11: Hard frame pointer (if needed)
276 GPR 12: Global offset table pointer (if needed)
277 GPR 13: Literal pool base register
278 GPR 14: Return address register
279 GPR 15: Stack pointer
281 Registers 32-34 are 'fake' hard registers that do not
282 correspond to actual hardware:
283 Reg 32: Argument pointer
284 Reg 33: Condition code
285 Reg 34: Frame pointer */
287 #define FIRST_PSEUDO_REGISTER 35
289 /* Standard register usage. */
290 #define GENERAL_REGNO_P(N) ((int)(N) >= 0 && (N) < 16)
291 #define ADDR_REGNO_P(N) ((N) >= 1 && (N) < 16)
292 #define FP_REGNO_P(N) ((N) >= 16 && (N) < (TARGET_IEEE_FLOAT? 32 : 20))
293 #define CC_REGNO_P(N) ((N) == 33)
294 #define FRAME_REGNO_P(N) ((N) == 32 || (N) == 34)
296 #define GENERAL_REG_P(X) (REG_P (X) && GENERAL_REGNO_P (REGNO (X)))
297 #define ADDR_REG_P(X) (REG_P (X) && ADDR_REGNO_P (REGNO (X)))
298 #define FP_REG_P(X) (REG_P (X) && FP_REGNO_P (REGNO (X)))
299 #define CC_REG_P(X) (REG_P (X) && CC_REGNO_P (REGNO (X)))
300 #define FRAME_REG_P(X) (REG_P (X) && FRAME_REGNO_P (REGNO (X)))
302 #define SIBCALL_REGNUM 1
303 #define BASE_REGISTER 13
304 #define RETURN_REGNUM 14
305 #define CC_REGNUM 33
307 /* Set up fixed registers and calling convention:
309 GPRs 0-5 are always call-clobbered,
310 GPRs 6-15 are always call-saved.
311 GPR 12 is fixed if used as GOT pointer.
312 GPR 13 is always fixed (as literal pool pointer).
313 GPR 14 is always fixed on S/390 machines (as return address).
314 GPR 15 is always fixed (as stack pointer).
315 The 'fake' hard registers are call-clobbered and fixed.
317 On 31-bit, FPRs 18-19 are call-clobbered;
318 on 64-bit, FPRs 24-31 are call-clobbered.
319 The remaining FPRs are call-saved. */
321 #define FIXED_REGISTERS \
322 { 0, 0, 0, 0, \
323 0, 0, 0, 0, \
324 0, 0, 0, 0, \
325 0, 1, 1, 1, \
326 0, 0, 0, 0, \
327 0, 0, 0, 0, \
328 0, 0, 0, 0, \
329 0, 0, 0, 0, \
330 1, 1, 1 }
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, \
337 1, 1, 1, 1, \
338 1, 1, 1, 1, \
339 1, 1, 1, 1, \
340 1, 1, 1, 1, \
341 1, 1, 1 }
343 #define CALL_REALLY_USED_REGISTERS \
344 { 1, 1, 1, 1, \
345 1, 1, 0, 0, \
346 0, 0, 0, 0, \
347 0, 0, 0, 0, \
348 1, 1, 1, 1, \
349 1, 1, 1, 1, \
350 1, 1, 1, 1, \
351 1, 1, 1, 1, \
352 1, 1, 1 }
354 #define CONDITIONAL_REGISTER_USAGE s390_conditional_register_usage ()
356 /* Preferred register allocation order. */
357 #define REG_ALLOC_ORDER \
358 { 1, 2, 3, 4, 5, 0, 13, 12, 11, 10, 9, 8, 7, 6, 14, \
359 16, 17, 18, 19, 20, 21, 22, 23, \
360 24, 25, 26, 27, 28, 29, 30, 31, \
361 15, 32, 33, 34 }
364 /* Fitting values into registers. */
366 /* Integer modes <= word size fit into any GPR.
367 Integer modes > word size fit into successive GPRs, starting with
368 an even-numbered register.
369 SImode and DImode fit into FPRs as well.
371 Floating point modes <= word size fit into any FPR or GPR.
372 Floating point modes > word size (i.e. DFmode on 32-bit) fit
373 into any FPR, or an even-odd GPR pair.
375 Complex floating point modes fit either into two FPRs, or into
376 successive GPRs (again starting with an even number).
378 Condition code modes fit only into the CC register. */
380 #define HARD_REGNO_NREGS(REGNO, MODE) \
381 (FP_REGNO_P(REGNO)? \
382 (GET_MODE_CLASS(MODE) == MODE_COMPLEX_FLOAT ? 2 : 1) : \
383 GENERAL_REGNO_P(REGNO)? \
384 ((GET_MODE_SIZE(MODE)+UNITS_PER_WORD-1) / UNITS_PER_WORD) : \
387 #define HARD_REGNO_MODE_OK(REGNO, MODE) \
388 (FP_REGNO_P(REGNO)? \
389 ((MODE) == SImode || (MODE) == DImode || \
390 GET_MODE_CLASS(MODE) == MODE_FLOAT || \
391 GET_MODE_CLASS(MODE) == MODE_COMPLEX_FLOAT) : \
392 GENERAL_REGNO_P(REGNO)? \
393 (HARD_REGNO_NREGS(REGNO, MODE) == 1 || !((REGNO) & 1)) : \
394 CC_REGNO_P(REGNO)? \
395 GET_MODE_CLASS (MODE) == MODE_CC : \
396 FRAME_REGNO_P(REGNO)? \
397 (enum machine_mode) (MODE) == Pmode : \
400 #define MODES_TIEABLE_P(MODE1, MODE2) \
401 (((MODE1) == SFmode || (MODE1) == DFmode) \
402 == ((MODE2) == SFmode || (MODE2) == DFmode))
404 /* Maximum number of registers to represent a value of mode MODE
405 in a register of class CLASS. */
406 #define CLASS_MAX_NREGS(CLASS, MODE) \
407 ((CLASS) == FP_REGS ? \
408 (GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT ? 2 : 1) : \
409 (GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
411 /* If a 4-byte value is loaded into a FPR, it is placed into the
412 *upper* half of the register, not the lower. Therefore, we
413 cannot use SUBREGs to switch between modes in FP registers. */
414 #define CANNOT_CHANGE_MODE_CLASS(FROM, TO, CLASS) \
415 (GET_MODE_SIZE (FROM) != GET_MODE_SIZE (TO) \
416 ? reg_classes_intersect_p (FP_REGS, CLASS) : 0)
418 /* Register classes. */
420 /* We use the following register classes:
421 GENERAL_REGS All general purpose registers
422 ADDR_REGS All general purpose registers except %r0
423 (These registers can be used in address generation)
424 FP_REGS All floating point registers
426 GENERAL_FP_REGS Union of GENERAL_REGS and FP_REGS
427 ADDR_FP_REGS Union of ADDR_REGS and FP_REGS
429 NO_REGS No registers
430 ALL_REGS All registers
432 Note that the 'fake' frame pointer and argument pointer registers
433 are included amongst the address registers here. The condition
434 code register is only included in ALL_REGS. */
436 enum reg_class
438 NO_REGS, ADDR_REGS, GENERAL_REGS,
439 FP_REGS, ADDR_FP_REGS, GENERAL_FP_REGS,
440 ALL_REGS, LIM_REG_CLASSES
442 #define N_REG_CLASSES (int) LIM_REG_CLASSES
444 #define REG_CLASS_NAMES \
445 { "NO_REGS", "ADDR_REGS", "GENERAL_REGS", \
446 "FP_REGS", "ADDR_FP_REGS", "GENERAL_FP_REGS", "ALL_REGS" }
448 /* Class -> register mapping. */
449 #define REG_CLASS_CONTENTS \
451 { 0x00000000, 0x00000000 }, /* NO_REGS */ \
452 { 0x0000fffe, 0x00000005 }, /* ADDR_REGS */ \
453 { 0x0000ffff, 0x00000005 }, /* GENERAL_REGS */ \
454 { 0xffff0000, 0x00000000 }, /* FP_REGS */ \
455 { 0xfffffffe, 0x00000005 }, /* ADDR_FP_REGS */ \
456 { 0xffffffff, 0x00000005 }, /* GENERAL_FP_REGS */ \
457 { 0xffffffff, 0x00000007 }, /* ALL_REGS */ \
460 /* Register -> class mapping. */
461 extern const enum reg_class regclass_map[FIRST_PSEUDO_REGISTER];
462 #define REGNO_REG_CLASS(REGNO) (regclass_map[REGNO])
464 /* ADDR_REGS can be used as base or index register. */
465 #define INDEX_REG_CLASS ADDR_REGS
466 #define BASE_REG_CLASS ADDR_REGS
468 /* Check whether REGNO is a hard register of the suitable class
469 or a pseudo register currently allocated to one such. */
470 #define REGNO_OK_FOR_INDEX_P(REGNO) \
471 (((REGNO) < FIRST_PSEUDO_REGISTER \
472 && REGNO_REG_CLASS ((REGNO)) == ADDR_REGS) \
473 || (reg_renumber[REGNO] > 0 && reg_renumber[REGNO] < 16))
474 #define REGNO_OK_FOR_BASE_P(REGNO) REGNO_OK_FOR_INDEX_P (REGNO)
477 /* Given an rtx X being reloaded into a reg required to be in class CLASS,
478 return the class of reg to actually use. */
479 #define PREFERRED_RELOAD_CLASS(X, CLASS) \
480 s390_preferred_reload_class ((X), (CLASS))
482 /* We need a secondary reload when loading a PLUS which is
483 not a valid operand for LOAD ADDRESS. */
484 #define SECONDARY_INPUT_RELOAD_CLASS(CLASS, MODE, IN) \
485 s390_secondary_input_reload_class ((CLASS), (MODE), (IN))
487 /* We need a secondary reload when storing a double-word
488 to a non-offsettable memory address. */
489 #define SECONDARY_OUTPUT_RELOAD_CLASS(CLASS, MODE, OUT) \
490 s390_secondary_output_reload_class ((CLASS), (MODE), (OUT))
492 /* We need secondary memory to move data between GPRs and FPRs. */
493 #define SECONDARY_MEMORY_NEEDED(CLASS1, CLASS2, MODE) \
494 ((CLASS1) != (CLASS2) && ((CLASS1) == FP_REGS || (CLASS2) == FP_REGS))
496 /* Get_secondary_mem widens its argument to BITS_PER_WORD which loses on 64bit
497 because the movsi and movsf patterns don't handle r/f moves. */
498 #define SECONDARY_MEMORY_NEEDED_MODE(MODE) \
499 (GET_MODE_BITSIZE (MODE) < 32 \
500 ? mode_for_size (32, GET_MODE_CLASS (MODE), 0) \
501 : MODE)
504 /* Define various machine-dependent constraint letters. */
506 #define REG_CLASS_FROM_LETTER(C) \
507 ((C) == 'a' ? ADDR_REGS : \
508 (C) == 'd' ? GENERAL_REGS : \
509 (C) == 'f' ? FP_REGS : NO_REGS)
511 #define CONST_OK_FOR_CONSTRAINT_P(VALUE, C, STR) \
512 s390_const_ok_for_constraint_p ((VALUE), (C), (STR))
514 #define CONST_DOUBLE_OK_FOR_CONSTRAINT_P(VALUE, C, STR) 1
516 #define EXTRA_CONSTRAINT_STR(OP, C, STR) \
517 s390_extra_constraint_str ((OP), (C), (STR))
518 #define EXTRA_MEMORY_CONSTRAINT(C, STR) \
519 ((C) == 'Q' || (C) == 'R' || (C) == 'S' || (C) == 'T')
520 #define EXTRA_ADDRESS_CONSTRAINT(C, STR) \
521 ((C) == 'U' || (C) == 'W' || (C) == 'Y')
523 #define CONSTRAINT_LEN(C, STR) \
524 ((C) == 'N' ? 5 : DEFAULT_CONSTRAINT_LEN ((C), (STR)))
526 /* Stack layout and calling conventions. */
528 /* Our stack grows from higher to lower addresses. However, local variables
529 are accessed by positive offsets, and function arguments are stored at
530 increasing addresses. */
531 #define STACK_GROWS_DOWNWARD
532 /* #undef FRAME_GROWS_DOWNWARD */
533 /* #undef ARGS_GROW_DOWNWARD */
535 /* The basic stack layout looks like this: the stack pointer points
536 to the register save area for called functions. Above that area
537 is the location to place outgoing arguments. Above those follow
538 dynamic allocations (alloca), and finally the local variables. */
540 /* Offset from stack-pointer to first location of outgoing args. */
541 #define STACK_POINTER_OFFSET (TARGET_64BIT ? 160 : 96)
543 /* Offset within stack frame to start allocating local variables at. */
544 extern int current_function_outgoing_args_size;
545 #define STARTING_FRAME_OFFSET \
546 (STACK_POINTER_OFFSET + current_function_outgoing_args_size)
548 /* Offset from the stack pointer register to an item dynamically
549 allocated on the stack, e.g., by `alloca'. */
550 #define STACK_DYNAMIC_OFFSET(FUNDECL) (STARTING_FRAME_OFFSET)
552 /* Offset of first parameter from the argument pointer register value.
553 We have a fake argument pointer register that points directly to
554 the argument area. */
555 #define FIRST_PARM_OFFSET(FNDECL) 0
557 /* The return address of the current frame is retrieved
558 from the initial value of register RETURN_REGNUM.
559 For frames farther back, we use the stack slot where
560 the corresponding RETURN_REGNUM register was saved. */
562 #define DYNAMIC_CHAIN_ADDRESS(FRAME) \
563 ((FRAME) != hard_frame_pointer_rtx ? (FRAME) : \
564 plus_constant (arg_pointer_rtx, -STACK_POINTER_OFFSET))
566 #define RETURN_ADDR_RTX(COUNT, FRAME) \
567 s390_return_addr_rtx ((COUNT), DYNAMIC_CHAIN_ADDRESS ((FRAME)))
569 /* In 31-bit mode, we need to mask off the high bit of return addresses. */
570 #define MASK_RETURN_ADDR (TARGET_64BIT ? constm1_rtx : GEN_INT (0x7fffffff))
573 /* Exception handling. */
575 /* Describe calling conventions for DWARF-2 exception handling. */
576 #define INCOMING_RETURN_ADDR_RTX gen_rtx_REG (Pmode, RETURN_REGNUM)
577 #define INCOMING_FRAME_SP_OFFSET STACK_POINTER_OFFSET
578 #define DWARF_FRAME_RETURN_COLUMN 14
580 /* Describe how we implement __builtin_eh_return. */
581 #define EH_RETURN_DATA_REGNO(N) ((N) < 4 ? (N) + 6 : INVALID_REGNUM)
582 #define EH_RETURN_HANDLER_RTX \
583 gen_rtx_MEM (Pmode, plus_constant (arg_pointer_rtx, \
584 -STACK_POINTER_OFFSET + UNITS_PER_WORD*RETURN_REGNUM))
586 /* Select a format to encode pointers in exception handling data. */
587 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \
588 (flag_pic \
589 ? ((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel | DW_EH_PE_sdata4 \
590 : DW_EH_PE_absptr)
593 /* Frame registers. */
595 #define STACK_POINTER_REGNUM 15
596 #define FRAME_POINTER_REGNUM 34
597 #define HARD_FRAME_POINTER_REGNUM 11
598 #define ARG_POINTER_REGNUM 32
600 /* The static chain must be call-clobbered, but not used for
601 function argument passing. As register 1 is clobbered by
602 the trampoline code, we only have one option. */
603 #define STATIC_CHAIN_REGNUM 0
605 /* Number of hardware registers that go into the DWARF-2 unwind info.
606 To avoid ABI incompatibility, this number must not change even as
607 'fake' hard registers are added or removed. */
608 #define DWARF_FRAME_REGISTERS 34
611 /* Frame pointer and argument pointer elimination. */
613 #define FRAME_POINTER_REQUIRED 0
615 #define INITIAL_FRAME_POINTER_OFFSET(DEPTH) (DEPTH) = 0
617 #define ELIMINABLE_REGS \
618 {{ FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
619 { FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}, \
620 { ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
621 { ARG_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}}
623 #define CAN_ELIMINATE(FROM, TO) (1)
625 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
626 { if ((FROM) == FRAME_POINTER_REGNUM && (TO) == STACK_POINTER_REGNUM) \
627 { (OFFSET) = 0; } \
628 else if ((FROM) == FRAME_POINTER_REGNUM \
629 && (TO) == HARD_FRAME_POINTER_REGNUM) \
630 { (OFFSET) = 0; } \
631 else if ((FROM) == ARG_POINTER_REGNUM \
632 && (TO) == HARD_FRAME_POINTER_REGNUM) \
633 { (OFFSET) = s390_arg_frame_offset (); } \
634 else if ((FROM) == ARG_POINTER_REGNUM && (TO) == STACK_POINTER_REGNUM) \
635 { (OFFSET) = s390_arg_frame_offset (); } \
636 else \
637 abort(); \
641 /* Stack arguments. */
643 /* We need current_function_outgoing_args to be valid. */
644 #define ACCUMULATE_OUTGOING_ARGS 1
646 /* Return doesn't modify the stack. */
647 #define RETURN_POPS_ARGS(FUNDECL, FUNTYPE, SIZE) 0
650 /* Register arguments. */
652 typedef struct s390_arg_structure
654 int gprs; /* gpr so far */
655 int fprs; /* fpr so far */
657 CUMULATIVE_ARGS;
659 #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, NN, N_NAMED_ARGS) \
660 ((CUM).gprs=0, (CUM).fprs=0)
662 #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \
663 s390_function_arg_advance (&CUM, MODE, TYPE, NAMED)
665 #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
666 s390_function_arg (&CUM, MODE, TYPE, NAMED)
668 #define FUNCTION_ARG_PASS_BY_REFERENCE(CUM, MODE, TYPE, NAMED) \
669 s390_function_arg_pass_by_reference (MODE, TYPE)
671 #define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) 0
673 /* Arguments can be placed in general registers 2 to 6,
674 or in floating point registers 0 and 2. */
675 #define FUNCTION_ARG_REGNO_P(N) (((N) >=2 && (N) <7) || \
676 (N) == 16 || (N) == 17)
679 /* Scalar return values. */
681 #define FUNCTION_VALUE(VALTYPE, FUNC) \
682 s390_function_value ((VALTYPE), VOIDmode)
684 #define LIBCALL_VALUE(MODE) \
685 s390_function_value (NULL, (MODE))
687 /* Only gpr 2 and fpr 0 are ever used as return registers. */
688 #define FUNCTION_VALUE_REGNO_P(N) ((N) == 2 || (N) == 16)
691 /* Function entry and exit. */
693 /* When returning from a function, the stack pointer does not matter. */
694 #define EXIT_IGNORE_STACK 1
697 /* Profiling. */
699 #define FUNCTION_PROFILER(FILE, LABELNO) \
700 s390_function_profiler ((FILE), ((LABELNO)))
702 #define PROFILE_BEFORE_PROLOGUE 1
705 /* Implementing the varargs macros. */
707 #define EXPAND_BUILTIN_VA_START(valist, nextarg) \
708 s390_va_start (valist, nextarg)
710 #define EXPAND_BUILTIN_VA_ARG(valist, type) \
711 s390_va_arg (valist, type)
714 /* Trampolines for nested functions. */
716 #define TRAMPOLINE_SIZE (TARGET_64BIT ? 36 : 20)
718 #define INITIALIZE_TRAMPOLINE(ADDR, FNADDR, CXT) \
719 s390_initialize_trampoline ((ADDR), (FNADDR), (CXT))
721 #define TRAMPOLINE_TEMPLATE(FILE) \
722 s390_trampoline_template (FILE)
725 /* Library calls. */
727 /* We should use memcpy, not bcopy. */
728 #define TARGET_MEM_FUNCTIONS
731 /* Addressing modes, and classification of registers for them. */
733 /* Recognize any constant value that is a valid address. */
734 #define CONSTANT_ADDRESS_P(X) 0
736 /* Maximum number of registers that can appear in a valid memory address. */
737 #define MAX_REGS_PER_ADDRESS 2
739 /* The macros REG_OK_FOR..._P assume that the arg is a REG rtx and check
740 its validity for a certain class. We have two alternate definitions
741 for each of them. The usual definition accepts all pseudo regs; the
742 other rejects them all. The symbol REG_OK_STRICT causes the latter
743 definition to be used.
745 Most source files want to accept pseudo regs in the hope that they will
746 get allocated to the class that the insn wants them to be in.
747 Some source files that are used after register allocation
748 need to be strict. */
750 #define REG_OK_FOR_INDEX_NONSTRICT_P(X) \
751 ((GET_MODE (X) == Pmode) && \
752 ((REGNO (X) >= FIRST_PSEUDO_REGISTER) \
753 || REGNO_REG_CLASS (REGNO (X)) == ADDR_REGS))
755 #define REG_OK_FOR_BASE_NONSTRICT_P(X) REG_OK_FOR_INDEX_NONSTRICT_P (X)
757 #define REG_OK_FOR_INDEX_STRICT_P(X) \
758 ((GET_MODE (X) == Pmode) && (REGNO_OK_FOR_INDEX_P (REGNO (X))))
760 #define REG_OK_FOR_BASE_STRICT_P(X) \
761 ((GET_MODE (X) == Pmode) && (REGNO_OK_FOR_BASE_P (REGNO (X))))
763 #ifndef REG_OK_STRICT
764 #define REG_OK_FOR_INDEX_P(X) REG_OK_FOR_INDEX_NONSTRICT_P(X)
765 #define REG_OK_FOR_BASE_P(X) REG_OK_FOR_BASE_NONSTRICT_P(X)
766 #else
767 #define REG_OK_FOR_INDEX_P(X) REG_OK_FOR_INDEX_STRICT_P(X)
768 #define REG_OK_FOR_BASE_P(X) REG_OK_FOR_BASE_STRICT_P(X)
769 #endif
771 /* S/390 has no mode dependent addresses. */
772 #define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR, LABEL)
774 /* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression that is a
775 valid memory address for an instruction.
776 The MODE argument is the machine mode for the MEM expression
777 that wants to use this address. */
778 #ifdef REG_OK_STRICT
779 #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \
781 if (legitimate_address_p (MODE, X, 1)) \
782 goto ADDR; \
784 #else
785 #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \
787 if (legitimate_address_p (MODE, X, 0)) \
788 goto ADDR; \
790 #endif
792 /* Try machine-dependent ways of modifying an illegitimate address
793 to be legitimate. If we find one, return the new, valid address.
794 This macro is used in only one place: `memory_address' in explow.c. */
795 #define LEGITIMIZE_ADDRESS(X, OLDX, MODE, WIN) \
797 (X) = legitimize_address (X, OLDX, MODE); \
798 if (memory_address_p (MODE, X)) \
799 goto WIN; \
802 /* Nonzero if the constant value X is a legitimate general operand.
803 It is given that X satisfies CONSTANT_P or is a CONST_DOUBLE. */
804 #define LEGITIMATE_CONSTANT_P(X) \
805 legitimate_constant_p (X)
807 /* Helper macro for s390.c and s390.md to check for symbolic constants. */
808 #define SYMBOLIC_CONST(X) \
809 (GET_CODE (X) == SYMBOL_REF \
810 || GET_CODE (X) == LABEL_REF \
811 || (GET_CODE (X) == CONST && symbolic_reference_mentioned_p (X)))
813 #define TLS_SYMBOLIC_CONST(X) \
814 ((GET_CODE (X) == SYMBOL_REF && tls_symbolic_operand (X)) \
815 || (GET_CODE (X) == CONST && tls_symbolic_reference_mentioned_p (X)))
818 /* Condition codes. */
820 /* Given a comparison code (EQ, NE, etc.) and the first operand of a COMPARE,
821 return the mode to be used for the comparison. */
822 #define SELECT_CC_MODE(OP, X, Y) s390_select_ccmode ((OP), (X), (Y))
824 /* Define the information needed to generate branch and scc insns. This is
825 stored from the compare operation. Note that we can't use "rtx" here
826 since it hasn't been defined! */
827 extern struct rtx_def *s390_compare_op0, *s390_compare_op1;
830 /* Relative costs of operations. */
832 /* On s390, copy between fprs and gprs is expensive. */
833 #define REGISTER_MOVE_COST(MODE, CLASS1, CLASS2) \
834 (( ( reg_classes_intersect_p ((CLASS1), GENERAL_REGS) \
835 && reg_classes_intersect_p ((CLASS2), FP_REGS)) \
836 || ( reg_classes_intersect_p ((CLASS1), FP_REGS) \
837 && reg_classes_intersect_p ((CLASS2), GENERAL_REGS))) ? 10 : 1)
839 /* A C expression for the cost of moving data of mode M between a
840 register and memory. A value of 2 is the default; this cost is
841 relative to those in `REGISTER_MOVE_COST'. */
842 #define MEMORY_MOVE_COST(M, C, I) 1
844 /* A C expression for the cost of a branch instruction. A value of 1
845 is the default; other values are interpreted relative to that. */
846 #define BRANCH_COST 1
848 /* Nonzero if access to memory by bytes is slow and undesirable. */
849 #define SLOW_BYTE_ACCESS 1
851 /* The maximum number of bytes that a single instruction can move quickly
852 between memory and registers or between two memory locations. */
853 #define MOVE_MAX (TARGET_64BIT ? 16 : 8)
854 #define MAX_MOVE_MAX 16
856 /* Determine whether to use move_by_pieces or block move insn. */
857 #define MOVE_BY_PIECES_P(SIZE, ALIGN) \
858 ( (SIZE) == 1 || (SIZE) == 2 || (SIZE) == 4 \
859 || (TARGET_64BIT && (SIZE) == 8) )
861 /* Determine whether to use clear_by_pieces or block clear insn. */
862 #define CLEAR_BY_PIECES_P(SIZE, ALIGN) \
863 ( (SIZE) == 1 || (SIZE) == 2 || (SIZE) == 4 \
864 || (TARGET_64BIT && (SIZE) == 8) )
866 /* Don't perform CSE on function addresses. */
867 #define NO_FUNCTION_CSE
870 /* Sections. */
872 /* Output before read-only data. */
873 #define TEXT_SECTION_ASM_OP ".text"
875 /* Output before writable (initialized) data. */
876 #define DATA_SECTION_ASM_OP ".data"
878 /* Output before writable (uninitialized) data. */
879 #define BSS_SECTION_ASM_OP ".bss"
881 /* S/390 constant pool breaks the devices in crtstuff.c to control section
882 in where code resides. We have to write it as asm code. */
883 #ifndef __s390x__
884 #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
885 asm (SECTION_OP "\n\
886 bras\t%r2,1f\n\
887 0: .long\t" USER_LABEL_PREFIX #FUNC " - 0b\n\
888 1: l\t%r3,0(%r2)\n\
889 bas\t%r14,0(%r3,%r2)\n\
890 .previous");
891 #endif
894 /* Position independent code. */
896 extern int flag_pic;
898 #define PIC_OFFSET_TABLE_REGNUM (flag_pic ? 12 : INVALID_REGNUM)
900 #define LEGITIMATE_PIC_OPERAND_P(X) legitimate_pic_operand_p (X)
903 /* Assembler file format. */
905 /* Character to start a comment. */
906 #define ASM_COMMENT_START "#"
908 /* Declare an uninitialized external linkage data object. */
909 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
910 asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
912 /* Globalizing directive for a label. */
913 #define GLOBAL_ASM_OP ".globl "
915 /* Advance the location counter to a multiple of 2**LOG bytes. */
916 #define ASM_OUTPUT_ALIGN(FILE, LOG) \
917 if ((LOG)) fprintf ((FILE), "\t.align\t%d\n", 1 << (LOG))
919 /* Advance the location counter by SIZE bytes. */
920 #define ASM_OUTPUT_SKIP(FILE, SIZE) \
921 fprintf ((FILE), "\t.set\t.,.+"HOST_WIDE_INT_PRINT_UNSIGNED"\n", (SIZE))
923 /* The LOCAL_LABEL_PREFIX variable is used by dbxelf.h. */
924 #define LOCAL_LABEL_PREFIX "."
926 /* How to refer to registers in assembler output. This sequence is
927 indexed by compiler's hard-register-number (see above). */
928 #define REGISTER_NAMES \
929 { "%r0", "%r1", "%r2", "%r3", "%r4", "%r5", "%r6", "%r7", \
930 "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15", \
931 "%f0", "%f2", "%f4", "%f6", "%f1", "%f3", "%f5", "%f7", \
932 "%f8", "%f10", "%f12", "%f14", "%f9", "%f11", "%f13", "%f15", \
933 "%ap", "%cc", "%fp" \
936 /* Emit a dtp-relative reference to a TLS variable. */
938 #ifdef HAVE_AS_TLS
939 #define ASM_OUTPUT_DWARF_DTPREL(FILE, SIZE, X) \
940 s390_output_dwarf_dtprel (FILE, SIZE, X)
941 #endif
943 /* Print operand X (an rtx) in assembler syntax to file FILE. */
944 #define PRINT_OPERAND(FILE, X, CODE) print_operand (FILE, X, CODE)
945 #define PRINT_OPERAND_ADDRESS(FILE, ADDR) print_operand_address (FILE, ADDR)
947 /* Output machine-dependent UNSPECs in address constants. */
948 #define OUTPUT_ADDR_CONST_EXTRA(FILE, X, FAIL) \
949 do { \
950 if (!s390_output_addr_const_extra (FILE, (X))) \
951 goto FAIL; \
952 } while (0);
954 /* Output an element of a case-vector that is absolute. */
955 #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \
956 do { \
957 char buf[32]; \
958 fputs (integer_asm_op (UNITS_PER_WORD, TRUE), (FILE)); \
959 ASM_GENERATE_INTERNAL_LABEL (buf, "L", (VALUE)); \
960 assemble_name ((FILE), buf); \
961 fputc ('\n', (FILE)); \
962 } while (0)
964 /* Output an element of a case-vector that is relative. */
965 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
966 do { \
967 char buf[32]; \
968 fputs (integer_asm_op (UNITS_PER_WORD, TRUE), (FILE)); \
969 ASM_GENERATE_INTERNAL_LABEL (buf, "L", (VALUE)); \
970 assemble_name ((FILE), buf); \
971 fputc ('-', (FILE)); \
972 ASM_GENERATE_INTERNAL_LABEL (buf, "L", (REL)); \
973 assemble_name ((FILE), buf); \
974 fputc ('\n', (FILE)); \
975 } while (0)
978 /* Miscellaneous parameters. */
980 /* Define the codes that are matched by predicates in aux-output.c. */
981 #define PREDICATE_CODES \
982 {"s_operand", { SUBREG, MEM }}, \
983 {"s_imm_operand", { CONST_INT, CONST_DOUBLE, SUBREG, MEM }}, \
984 {"shift_count_operand", { REG, SUBREG, PLUS, CONST_INT }}, \
985 {"bras_sym_operand",{ SYMBOL_REF, CONST }}, \
986 {"larl_operand", { SYMBOL_REF, CONST, CONST_INT, CONST_DOUBLE }}, \
987 {"load_multiple_operation", {PARALLEL}}, \
988 {"store_multiple_operation", {PARALLEL}}, \
989 {"const0_operand", { CONST_INT, CONST_DOUBLE }}, \
990 {"consttable_operand", { SYMBOL_REF, LABEL_REF, CONST, \
991 CONST_INT, CONST_DOUBLE }}, \
992 {"s390_plus_operand", { PLUS }}, \
993 {"s390_alc_comparison", { LTU, GTU, LEU, GEU }}, \
994 {"s390_slb_comparison", { LTU, GTU, LEU, GEU }},
996 /* Specify the machine mode that this machine uses for the index in the
997 tablejump instruction. */
998 #define CASE_VECTOR_MODE (TARGET_64BIT ? DImode : SImode)
1000 /* Value is 1 if truncating an integer of INPREC bits to OUTPREC bits
1001 is done just by pretending it is already truncated. */
1002 #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
1004 /* Specify the machine mode that pointers have.
1005 After generation of rtl, the compiler makes no further distinction
1006 between pointers and any other objects of this machine mode. */
1007 #define Pmode ((enum machine_mode) (TARGET_64BIT ? DImode : SImode))
1009 /* This is -1 for "pointer mode" extend. See ptr_extend in s390.md. */
1010 #define POINTERS_EXTEND_UNSIGNED -1
1012 /* A function address in a call instruction is a byte address (for
1013 indexing purposes) so give the MEM rtx a byte's mode. */
1014 #define FUNCTION_MODE QImode
1016 /* This macro definition sets up a default value for `main' to return. */
1017 #define DEFAULT_MAIN_RETURN c_expand_return (integer_zero_node)
1019 #endif