1 /* Definitions of target machine for GNU compiler for Hitachi Super-H.
2 Copyright (C) 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
3 Contributed by Steve Chamberlain (sac@cygnus.com).
4 Improved by Jim Wilson (wilson@cygnus.com).
6 This file is part of GNU CC.
8 GNU CC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
13 GNU CC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GNU CC; see the file COPYING. If not, write to
20 the Free Software Foundation, 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
24 #define TARGET_VERSION \
25 fputs (" (Hitachi SH)", stderr);
27 /* Generate SDB debugging information. */
29 #define SDB_DEBUGGING_INFO
31 /* Output DBX (stabs) debugging information if doing -gstabs. */
37 #define CPP_SPEC "%{ml:-D__LITTLE_ENDIAN__} \
43 #define CPP_PREDEFINES "-D__sh__ -Acpu(sh) -Amachine(sh)"
45 #define ASM_SPEC "%{ml:-little} %{mrelax:-relax}"
47 #define LINK_SPEC "%{ml:-m shl} %{mrelax:-relax}"
49 /* We can not debug without a frame pointer. */
50 /* #define CAN_DEBUG_WITHOUT_FP */
52 #define CONDITIONAL_REGISTER_USAGE \
56 for (regno = FIRST_FP_REG; regno <= LAST_FP_REG; regno++) \
57 fixed_regs[regno] = call_used_regs[regno] = 1; \
59 /* Hitachi saves and restores mac registers on call. */ \
62 call_used_regs[MACH_REG] = 0; \
63 call_used_regs[MACL_REG] = 0; \
66 /* ??? Need to write documentation for all SH options and add it to the
69 /* Run-time compilation parameters selecting different hardware subsets. */
71 extern int target_flags
;
72 #define ISIZE_BIT (1<<1)
73 #define DALIGN_BIT (1<<6)
74 #define SH0_BIT (1<<7)
75 #define SH1_BIT (1<<8)
76 #define SH2_BIT (1<<9)
77 #define SH3_BIT (1<<10)
78 #define SH3E_BIT (1<<11)
79 #define SPACE_BIT (1<<13)
80 #define BIGTABLE_BIT (1<<14)
81 #define RELAX_BIT (1<<15)
82 #define HITACHI_BIT (1<<22)
83 #define PADSTRUCT_BIT (1<<28)
84 #define LITTLE_ENDIAN_BIT (1<<29)
86 /* Nonzero if we should dump out instruction size info. */
87 #define TARGET_DUMPISIZE (target_flags & ISIZE_BIT)
89 /* Nonzero to align doubles on 64 bit boundaries. */
90 #define TARGET_ALIGN_DOUBLE (target_flags & DALIGN_BIT)
92 /* Nonzero if we should generate code using type 0 insns. */
93 /* ??? Is there such a thing as SH0? If not, we should delete all
95 #define TARGET_SH0 (target_flags & SH0_BIT)
97 /* Nonzero if we should generate code using type 1 insns. */
98 #define TARGET_SH1 (target_flags & SH1_BIT)
100 /* Nonzero if we should generate code using type 2 insns. */
101 #define TARGET_SH2 (target_flags & SH2_BIT)
103 /* Nonzero if we should generate code using type 3 insns. */
104 #define TARGET_SH3 (target_flags & SH3_BIT)
106 /* Nonzero if we should generate code using type 3E insns. */
107 #define TARGET_SH3E (target_flags & SH3E_BIT)
109 /* Nonzero if we should generate smaller code rather than faster code. */
110 #define TARGET_SMALLCODE (target_flags & SPACE_BIT)
112 /* Nonzero to use long jump tables. */
113 #define TARGET_BIGTABLE (target_flags & BIGTABLE_BIT)
115 /* Nonzero to generate pseudo-ops needed by the assembler and linker
116 to do function call relaxing. */
117 #define TARGET_RELAX (target_flags & RELAX_BIT)
119 /* Nonzero if using Hitachi's calling convention. */
120 #define TARGET_HITACHI (target_flags & HITACHI_BIT)
122 /* Nonzero if padding structures to a multiple of 4 bytes. This is
123 incompatible with Hitachi's compiler, and gives unusual structure layouts
124 which confuse programmers.
125 ??? This option is not useful, but is retained in case there are people
126 who are still relying on it. It may be deleted in the future. */
127 #define TARGET_PADSTRUCT (target_flags & PADSTRUCT_BIT)
129 /* Nonzero if generating code for a little endian SH. */
130 #define TARGET_LITTLE_ENDIAN (target_flags & LITTLE_ENDIAN_BIT)
132 #define TARGET_SWITCHES \
136 {"3", SH3_BIT|SH2_BIT}, \
137 {"3e", SH3E_BIT|SH3_BIT|SH2_BIT}, \
138 {"b", -LITTLE_ENDIAN_BIT}, \
139 {"bigtable", BIGTABLE_BIT}, \
140 {"dalign", DALIGN_BIT}, \
141 {"hitachi", HITACHI_BIT}, \
142 {"isize", ISIZE_BIT}, \
143 {"l", LITTLE_ENDIAN_BIT}, \
144 {"padstruct", PADSTRUCT_BIT}, \
145 {"relax", RELAX_BIT}, \
146 {"space", SPACE_BIT}, \
147 {"", TARGET_DEFAULT} \
150 #define TARGET_DEFAULT (0)
152 #define OVERRIDE_OPTIONS \
164 /* Never run scheduling before reload, since that can \
165 break global alloc, and generates slower code anyway due \
166 to the pressure on R0. */ \
167 flag_schedule_insns = 0; \
170 /* Target machine storage layout. */
172 /* Define to use software floating point emulator for REAL_ARITHMETIC and
173 decimal <-> binary conversion. */
174 #define REAL_ARITHMETIC
176 /* Define this if most significant bit is lowest numbered
177 in instructions that operate on numbered bit-fields. */
179 #define BITS_BIG_ENDIAN 0
181 /* Define this if most significant byte of a word is the lowest numbered. */
182 #define BYTES_BIG_ENDIAN (TARGET_LITTLE_ENDIAN == 0)
184 /* Define this if most significant word of a multiword number is the lowest
186 #define WORDS_BIG_ENDIAN (TARGET_LITTLE_ENDIAN == 0)
188 /* Define this to set the endianness to use in libgcc2.c, which can
189 not depend on target_flags. */
190 #if defined(__LITTLE_ENDIAN__)
191 #define LIBGCC2_WORDS_BIG_ENDIAN 0
193 #define LIBGCC2_WORDS_BIG_ENDIAN 1
196 /* Number of bits in an addressable storage unit. */
197 #define BITS_PER_UNIT 8
199 /* Width in bits of a "word", which is the contents of a machine register.
200 Note that this is not necessarily the width of data type `int';
201 if using 16-bit ints on a 68000, this would still be 32.
202 But on a machine with 16-bit registers, this would be 16. */
203 #define BITS_PER_WORD 32
204 #define MAX_BITS_PER_WORD 32
206 /* Width of a word, in units (bytes). */
207 #define UNITS_PER_WORD 4
209 /* Width in bits of a pointer.
210 See also the macro `Pmode' defined below. */
211 #define POINTER_SIZE 32
213 /* Allocation boundary (in *bits*) for storing arguments in argument list. */
214 #define PARM_BOUNDARY 32
216 /* Boundary (in *bits*) on which stack pointer should be aligned. */
217 #define STACK_BOUNDARY 32
219 /* Allocation boundary (in *bits*) for the code of a function.
220 32 bit alignment is faster, because instructions are always fetched as a
221 pair from a longword boundary. */
222 /* ??? Perhaps also define ASM_OUTPUT_ALIGN_CODE and/or ASM_OUTPUT_LOOP_ALIGN
223 so as to align jump targets and/or loops to 4 byte boundaries when not
224 optimizing for space? */
225 #define FUNCTION_BOUNDARY (TARGET_SMALLCODE ? 16 : 32)
227 /* Alignment of field after `int : 0' in a structure. */
228 #define EMPTY_FIELD_BOUNDARY 32
230 /* No data type wants to be aligned rounder than this. */
231 #define BIGGEST_ALIGNMENT (TARGET_ALIGN_DOUBLE ? 64 : 32)
233 /* The best alignment to use in cases where we have a choice. */
234 #define FASTEST_ALIGNMENT 32
236 /* Make strings word-aligned so strcpy from constants will be faster. */
237 #define CONSTANT_ALIGNMENT(EXP, ALIGN) \
238 ((TREE_CODE (EXP) == STRING_CST \
239 && (ALIGN) < FASTEST_ALIGNMENT) \
240 ? FASTEST_ALIGNMENT : (ALIGN))
242 /* Make arrays of chars word-aligned for the same reasons. */
243 #define DATA_ALIGNMENT(TYPE, ALIGN) \
244 (TREE_CODE (TYPE) == ARRAY_TYPE \
245 && TYPE_MODE (TREE_TYPE (TYPE)) == QImode \
246 && (ALIGN) < FASTEST_ALIGNMENT ? FASTEST_ALIGNMENT : (ALIGN))
248 /* Number of bits which any structure or union's size must be a
249 multiple of. Each structure or union's size is rounded up to a
251 #define STRUCTURE_SIZE_BOUNDARY (TARGET_PADSTRUCT ? 32 : 8)
253 /* Set this nonzero if move instructions will actually fail to work
254 when given unaligned data. */
255 #define STRICT_ALIGNMENT 1
257 /* Standard register usage. */
259 /* Register allocation for the Hitachi calling convention:
265 r14 frame pointer/call saved
267 ap arg pointer (doesn't really exist, always eliminated)
268 pr subroutine return address
270 mach multiply/accumulate result, high part
271 macl multiply/accumulate result, low part.
272 fpul fp/int communication register
274 fr1..fr3 scratch floating point registers
276 fr12..fr15 call saved floating point registers */
278 /* Number of actual hardware registers.
279 The hardware registers are assigned numbers for the compiler
280 from 0 to just below FIRST_PSEUDO_REGISTER.
281 All registers that the compiler knows about must be given numbers,
282 even those that are not normally considered general registers. */
290 #define SPECIAL_REG(REGNO) ((REGNO) >= 18 && (REGNO) <= 21)
292 /* Number 23 is unused. Reserved for future expansion. */
293 #define FIRST_FP_REG 24
294 #define LAST_FP_REG 39
296 #define FIRST_PSEUDO_REGISTER 40
298 /* 1 for registers that have pervasive standard uses
299 and are not available for the register allocator.
301 Mach register is fixed 'cause it's only 10 bits wide for SH1.
302 It is 32 bits wide for SH2. */
304 #define FIXED_REGISTERS \
317 /* 1 for registers not available across function calls.
318 These must include the FIXED_REGISTERS and also any
319 registers that can be used without being saved.
320 The latter must include the registers where values are returned
321 and the register where structure-value addresses are passed.
322 Aside from that, you can include as many other registers as you like. */
324 #define CALL_USED_REGISTERS \
337 /* Return number of consecutive hard regs needed starting at reg REGNO
338 to hold something of mode MODE.
339 This is ordinarily the length in words of a value of mode MODE
340 but can be less for certain modes in special long registers.
342 On the SH regs are UNITS_PER_WORD bits wide. */
344 #define HARD_REGNO_NREGS(REGNO, MODE) \
345 (((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD))
347 /* Value is 1 if hard register REGNO can hold a value of machine-mode MODE.
348 We can allow any mode in any general register. The special registers
349 only allow SImode. Don't allow any mode in the PR. */
351 #define HARD_REGNO_MODE_OK(REGNO, MODE) \
352 (SPECIAL_REG (REGNO) ? (MODE) == SImode \
353 : (REGNO) == FPUL_REG ? (MODE) == SImode || (MODE) == SFmode \
354 : (REGNO) >= FIRST_FP_REG && (REGNO) <= LAST_FP_REG ? (MODE) == SFmode \
355 : (REGNO) == PR_REG ? 0 \
358 /* Value is 1 if it is a good idea to tie two pseudo registers
359 when one has mode MODE1 and one has mode MODE2.
360 If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2,
361 for any hard reg, then this must be 0 for correct output. */
363 #define MODES_TIEABLE_P(MODE1, MODE2) \
364 ((MODE1) == (MODE2) || GET_MODE_CLASS (MODE1) == GET_MODE_CLASS (MODE2))
366 /* Specify the registers used for certain standard purposes.
367 The values of these macros are register numbers. */
369 /* Define this if the program counter is overloaded on a register. */
370 /* #define PC_REGNUM 15*/
372 /* Register to use for pushing function arguments. */
373 #define STACK_POINTER_REGNUM 15
375 /* Base register for access to local variables of the function. */
376 #define FRAME_POINTER_REGNUM 14
378 /* Value should be nonzero if functions must have frame pointers.
379 Zero means the frame pointer need not be set up (and parms may be accessed
380 via the stack pointer) in functions that seem suitable. */
382 #define FRAME_POINTER_REQUIRED 0
384 /* Definitions for register eliminations.
386 We have two registers that can be eliminated on the SH. First, the
387 frame pointer register can often be eliminated in favor of the stack
388 pointer register. Secondly, the argument pointer register can always be
389 eliminated; it is replaced with either the stack or frame pointer. */
391 /* This is an array of structures. Each structure initializes one pair
392 of eliminable registers. The "from" register number is given first,
393 followed by "to". Eliminations of the same "from" register are listed
394 in order of preference. */
396 #define ELIMINABLE_REGS \
397 {{ FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
398 { ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
399 { ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM},}
401 /* Given FROM and TO register numbers, say whether this elimination
403 #define CAN_ELIMINATE(FROM, TO) \
404 (!((FROM) == FRAME_POINTER_REGNUM && FRAME_POINTER_REQUIRED))
406 /* Define the offset between two registers, one to be eliminated, and the other
407 its replacement, at the start of a routine. */
409 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
410 OFFSET = initial_elimination_offset (FROM, TO)
412 /* Base register for access to arguments of the function. */
413 #define ARG_POINTER_REGNUM 16
415 /* Register in which the static-chain is passed to a function. */
416 #define STATIC_CHAIN_REGNUM 13
418 /* The register in which a struct value address is passed. */
420 #define STRUCT_VALUE_REGNUM 2
422 /* If the structure value address is not passed in a register, define
423 `STRUCT_VALUE' as an expression returning an RTX for the place
424 where the address is passed. If it returns 0, the address is
425 passed as an "invisible" first argument. */
427 /*#define STRUCT_VALUE ((rtx)0)*/
429 /* Don't default to pcc-struct-return, because we have already specified
430 exactly how to return structures in the RETURN_IN_MEMORY macro. */
432 #define DEFAULT_PCC_STRUCT_RETURN 0
434 /* Define the classes of registers for register constraints in the
435 machine description. Also define ranges of constants.
437 One of the classes must always be named ALL_REGS and include all hard regs.
438 If there is more than one class, another class must be named NO_REGS
439 and contain no registers.
441 The name GENERAL_REGS must be the name of a class (or an alias for
442 another name such as ALL_REGS). This is the class of registers
443 that is allowed by "g" or "r" in a register constraint.
444 Also, registers outside this class are allocated only when
445 instructions express preferences for them.
447 The classes must be numbered in nondecreasing order; that is,
448 a larger-numbered class must never be contained completely
449 in a smaller-numbered class.
451 For any two classes, it is very desirable that there be another
452 class that represents their union. */
454 /* The SH has two sorts of general registers, R0 and the rest. R0 can
455 be used as the destination of some of the arithmetic ops. There are
456 also some special purpose registers; the T bit register, the
457 Procedure Return Register and the Multiply Accumulate Registers. */
474 #define N_REG_CLASSES (int) LIM_REG_CLASSES
476 /* Give names of register classes as strings for dump file. */
477 #define REG_CLASS_NAMES \
491 /* Define which registers fit in which classes.
492 This is an initializer for a vector of HARD_REG_SET
493 of length N_REG_CLASSES. */
495 #define REG_CLASS_CONTENTS \
497 { 0x00000000, 0x00000000 }, /* NO_REGS */ \
498 { 0x00000001, 0x00000000 }, /* R0_REGS */ \
499 { 0x00020000, 0x00000000 }, /* PR_REGS */ \
500 { 0x00040000, 0x00000000 }, /* T_REGS */ \
501 { 0x00300000, 0x00000000 }, /* MAC_REGS */ \
502 { 0x0001FFFF, 0x00000000 }, /* GENERAL_REGS */ \
503 { 0x00400000, 0x00000000 }, /* FPUL_REGS */ \
504 { 0x01000000, 0x00000000 }, /* FP0_REGS */ \
505 { 0xFF000000, 0x000000FF }, /* FP_REGS */ \
506 { 0xFF7FFFFF, 0x000000FF }, /* ALL_REGS */ \
509 /* The same information, inverted:
510 Return the class number of the smallest class containing
511 reg number REGNO. This could be a conditional expression
512 or could index an array. */
514 extern int regno_reg_class
[];
515 #define REGNO_REG_CLASS(REGNO) regno_reg_class[REGNO]
517 /* When defined, the compiler allows registers explicitly used in the
518 rtl to be used as spill registers but prevents the compiler from
519 extending the lifetime of these registers. */
521 #define SMALL_REGISTER_CLASSES
523 /* The order in which register should be allocated. */
524 #define REG_ALLOC_ORDER \
525 { 1,2,3,7,6,5,4,0,8,9,10,11,12,13,14, \
526 24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39, \
527 22,15,16,17,18,19,20,21,23 }
529 /* The class value for index registers, and the one for base regs. */
530 #define INDEX_REG_CLASS R0_REGS
531 #define BASE_REG_CLASS GENERAL_REGS
533 /* Get reg_class from a letter such as appears in the machine
535 extern enum reg_class reg_class_from_letter
[];
537 #define REG_CLASS_FROM_LETTER(C) \
538 ( (C) >= 'a' && (C) <= 'z' ? reg_class_from_letter[(C)-'a'] : NO_REGS )
540 /* The letters I, J, K, L and M in a register constraint string
541 can be used to stand for particular ranges of immediate operands.
542 This macro defines what the ranges are.
543 C is the letter, and VALUE is a constant value.
544 Return 1 if VALUE is in the range specified by C.
545 I: arithmetic operand -127..128, as used in add, sub, etc
546 K: shift operand 1,2,8 or 16
547 L: logical operand 0..255, as used in and, or, etc.
551 #define CONST_OK_FOR_I(VALUE) (((int)(VALUE))>= -128 && ((int)(VALUE)) <= 127)
552 #define CONST_OK_FOR_K(VALUE) ((VALUE)==1||(VALUE)==2||(VALUE)==8||(VALUE)==16)
553 #define CONST_OK_FOR_L(VALUE) (((int)(VALUE))>= 0 && ((int)(VALUE)) <= 255)
554 #define CONST_OK_FOR_M(VALUE) ((VALUE)==1)
555 #define CONST_OK_FOR_N(VALUE) ((VALUE)==0)
556 #define CONST_OK_FOR_LETTER_P(VALUE, C) \
557 ((C) == 'I' ? CONST_OK_FOR_I (VALUE) \
558 : (C) == 'K' ? CONST_OK_FOR_K (VALUE) \
559 : (C) == 'L' ? CONST_OK_FOR_L (VALUE) \
560 : (C) == 'M' ? CONST_OK_FOR_M (VALUE) \
561 : (C) == 'N' ? CONST_OK_FOR_N (VALUE) \
564 /* Similar, but for floating constants, and defining letters G and H.
565 Here VALUE is the CONST_DOUBLE rtx itself. */
567 #define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) \
568 ((C) == 'G' ? fp_zero_operand (VALUE) \
569 : (C) == 'H' ? fp_one_operand (VALUE) \
572 /* Given an rtx X being reloaded into a reg required to be
573 in class CLASS, return the class of reg to actually use.
574 In general this is just CLASS; but on some machines
575 in some cases it is preferable to use a more restrictive class. */
577 #define PREFERRED_RELOAD_CLASS(X, CLASS) CLASS
579 /* Return the maximum number of consecutive registers
580 needed to represent mode MODE in a register of class CLASS.
582 On SH this is the size of MODE in words. */
583 #define CLASS_MAX_NREGS(CLASS, MODE) \
584 ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
586 /* Stack layout; function entry, exit and calling. */
588 /* Define the number of registers that can hold parameters.
589 These macros are used only in other macro definitions below. */
591 #define NPARM_REGS(MODE) \
592 ((TARGET_SH3E && ((MODE) == SFmode)) ? 8 : 4)
594 #define FIRST_PARM_REG 4
595 #define FIRST_RET_REG 0
597 #define FIRST_FP_PARM_REG (FIRST_FP_REG + 4)
598 #define FIRST_FP_RET_REG FIRST_FP_REG
600 /* Define this if pushing a word on the stack
601 makes the stack pointer a smaller address. */
602 #define STACK_GROWS_DOWNWARD
604 /* Define this macro if the addresses of local variable slots are at
605 negative offsets from the frame pointer.
607 The SH only has positive indexes, so grow the frame up. */
608 /* #define FRAME_GROWS_DOWNWARD */
610 /* Offset from the frame pointer to the first local variable slot to
612 #define STARTING_FRAME_OFFSET 0
614 /* If we generate an insn to push BYTES bytes,
615 this says how many the stack pointer really advances by. */
616 #define PUSH_ROUNDING(NPUSHED) (((NPUSHED) + 3) & ~3)
618 /* Offset of first parameter from the argument pointer register value. */
619 #define FIRST_PARM_OFFSET(FNDECL) 0
621 /* Value is the number of byte of arguments automatically
622 popped when returning from a subroutine call.
623 FUNDECL is the declaration node of the function (as a tree),
624 FUNTYPE is the data type of the function (as a tree),
625 or for a library call it is an identifier node for the subroutine name.
626 SIZE is the number of bytes of arguments passed on the stack.
628 On the SH, the caller does not pop any of its arguments that were passed
630 #define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE) 0
632 /* Some subroutine macros specific to this machine. */
634 #define BASE_RETURN_VALUE_REG(MODE) \
635 ((TARGET_SH3E && ((MODE) == SFmode)) \
639 #define BASE_ARG_REG(MODE) \
640 ((TARGET_SH3E && ((MODE) == SFmode)) \
641 ? FIRST_FP_PARM_REG \
644 /* Define how to find the value returned by a function.
645 VALTYPE is the data type of the value (as a tree).
646 If the precise function being called is known, FUNC is its FUNCTION_DECL;
647 otherwise, FUNC is 0. */
649 #define FUNCTION_VALUE(VALTYPE, FUNC) \
650 LIBCALL_VALUE (TYPE_MODE (VALTYPE))
652 /* Define how to find the value returned by a library function
653 assuming the value has mode MODE. */
654 #define LIBCALL_VALUE(MODE) \
655 gen_rtx (REG, MODE, BASE_RETURN_VALUE_REG (MODE));
657 /* 1 if N is a possible register number for a function value. */
658 #define FUNCTION_VALUE_REGNO_P(REGNO) \
659 ((REGNO) == FIRST_RET_REG || (TARGET_SH3E && (REGNO) == FIRST_FP_RET_REG))
661 /* 1 if N is a possible register number for function argument passing. */
662 #define FUNCTION_ARG_REGNO_P(REGNO) \
663 (((REGNO) >= FIRST_PARM_REG && (REGNO) < (FIRST_PARM_REG + 4)) \
665 && (REGNO) >= FIRST_FP_PARM_REG && (REGNO) < (FIRST_FP_PARM_REG + 8)))
667 /* Define a data type for recording info about an argument list
668 during the scan of that argument list. This data type should
669 hold all necessary information about the function itself
670 and about the args processed so far, enough to enable macros
671 such as FUNCTION_ARG to determine where the next arg should go.
673 On SH, this is a single integer, which is a number of words
674 of arguments scanned so far (including the invisible argument,
675 if any, which holds the structure-value-address).
676 Thus NARGREGS or more means all following args should go on the stack. */
678 enum sh_arg_class
{ SH_ARG_INT
= 0, SH_ARG_FLOAT
= 1 };
683 #define CUMULATIVE_ARGS struct sh_args
685 #define GET_SH_ARG_CLASS(MODE) \
686 ((TARGET_SH3E && ((MODE) == SFmode)) ? SH_ARG_FLOAT : SH_ARG_INT)
688 #define ROUND_ADVANCE(SIZE) \
689 ((SIZE + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
691 /* Round a register number up to a proper boundary for an arg of mode
694 The SH doesn't care about double alignment, so we only
695 round doubles to even regs when asked to explicitly. */
697 #define ROUND_REG(CUM, MODE) \
698 ((TARGET_ALIGN_DOUBLE \
699 && GET_MODE_UNIT_SIZE ((MODE)) > UNITS_PER_WORD) \
700 ? ((CUM).arg_count[(int) GET_SH_ARG_CLASS (MODE)] \
701 + ((CUM).arg_count[(int) GET_SH_ARG_CLASS (MODE)] & 1)) \
702 : (CUM).arg_count[(int) GET_SH_ARG_CLASS (MODE)])
704 /* Initialize a variable CUM of type CUMULATIVE_ARGS
705 for a call to a function whose data type is FNTYPE.
706 For a library call, FNTYPE is 0.
708 On SH, the offset always starts at 0: the first parm reg is always
711 #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME) \
713 (CUM).arg_count[(int) SH_ARG_INT] = 0; \
714 (CUM).arg_count[(int) SH_ARG_FLOAT] = 0; \
717 /* Update the data in CUM to advance over an argument
718 of mode MODE and data type TYPE.
719 (TYPE is null for libcalls where that information may not be
722 #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \
723 ((CUM).arg_count[(int) GET_SH_ARG_CLASS (MODE)] = \
724 (ROUND_REG ((CUM), (MODE)) \
725 + ((MODE) != BLKmode \
726 ? ROUND_ADVANCE (GET_MODE_SIZE (MODE)) \
727 : ROUND_ADVANCE (int_size_in_bytes (TYPE)))))
729 /* Return boolean indicating arg of mode MODE will be passed in a reg.
730 This macro is only used in this file. */
732 #define PASS_IN_REG_P(CUM, MODE, TYPE) \
733 (ROUND_REG ((CUM), (MODE)) < NPARM_REGS (MODE) \
734 && ((TYPE) == 0 || ! TREE_ADDRESSABLE ((tree)(TYPE))) \
735 && (! TARGET_SH3E || (ROUND_REG((CUM), (MODE)) + (GET_MODE_SIZE(MODE)/4) <= NPARM_REGS (MODE))))
737 /* Define where to put the arguments to a function.
738 Value is zero to push the argument on the stack,
739 or a hard register in which to store the argument.
741 MODE is the argument's machine mode.
742 TYPE is the data type of the argument (as a tree).
743 This is null for libcalls where that information may
745 CUM is a variable of type CUMULATIVE_ARGS which gives info about
746 the preceding args and about the function being called.
747 NAMED is nonzero if this argument is a named parameter
748 (otherwise it is an extra parameter matching an ellipsis).
750 On SH the first args are normally in registers
751 and the rest are pushed. Any arg that starts within the first
752 NPARM_REGS words is at least partially passed in a register unless
753 its data type forbids. */
755 #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
756 ((PASS_IN_REG_P ((CUM), (MODE), (TYPE)) \
757 && (NAMED || TARGET_SH3E)) \
758 ? gen_rtx (REG, (MODE), \
759 (BASE_ARG_REG (MODE) + ROUND_REG ((CUM), (MODE)))) \
762 /* For an arg passed partly in registers and partly in memory,
763 this is the number of registers used.
764 For args passed entirely in registers or entirely in memory, zero.
766 We sometimes split args. */
768 #define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) \
769 ((PASS_IN_REG_P ((CUM), (MODE), (TYPE)) \
770 && (NAMED || TARGET_SH3E) \
771 && (ROUND_REG ((CUM), (MODE)) \
773 ? ROUND_ADVANCE (GET_MODE_SIZE (MODE)) \
774 : ROUND_ADVANCE (int_size_in_bytes (TYPE))) \
775 - NPARM_REGS (MODE) > 0)) \
776 ? NPARM_REGS (MODE) - ROUND_REG ((CUM), (MODE)) \
779 extern int current_function_anonymous_args
;
781 /* Perform any needed actions needed for a function that is receiving a
782 variable number of arguments. */
784 #define SETUP_INCOMING_VARARGS(ASF, MODE, TYPE, PAS, ST) \
785 current_function_anonymous_args = 1;
787 /* Call the function profiler with a given profile label.
788 We use two .aligns, so as to make sure that both the .long is aligned
789 on a 4 byte boundary, and that the .long is a fixed distance (2 bytes)
790 from the trapa instruction. */
792 #define FUNCTION_PROFILER(STREAM,LABELNO) \
794 fprintf(STREAM, " .align 2\n"); \
795 fprintf(STREAM, " trapa #33\n"); \
796 fprintf(STREAM, " .align 2\n"); \
797 fprintf(STREAM, " .long LP%d\n", (LABELNO)); \
800 /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
801 the stack pointer does not matter. The value is tested only in
802 functions that have frame pointers.
803 No definition is equivalent to always zero. */
805 #define EXIT_IGNORE_STACK 1
807 /* Generate the assembly code for function exit
808 Just dump out any accumulated constant table. */
810 #define FUNCTION_EPILOGUE(STREAM, SIZE) function_epilogue (STREAM, SIZE)
812 /* Output assembler code for a block containing the constant parts
813 of a trampoline, leaving space for the variable parts.
815 On the SH, the trampoline looks like
816 1 0000 D301 mov.l l1,r3
817 2 0002 DD02 mov.l l2,r13
820 5 0008 00000000 l1: .long function
821 6 000c 00000000 l2: .long area */
822 #define TRAMPOLINE_TEMPLATE(FILE) \
824 fprintf ((FILE), " .word 0xd301\n"); \
825 fprintf ((FILE), " .word 0xdd02\n"); \
826 fprintf ((FILE), " .word 0x4d2b\n"); \
827 fprintf ((FILE), " .word 0x200b\n"); \
828 fprintf ((FILE), " .long 0\n"); \
829 fprintf ((FILE), " .long 0\n"); \
832 /* Length in units of the trampoline for entering a nested function. */
833 #define TRAMPOLINE_SIZE 16
835 /* Alignment required for a trampoline in units. */
836 #define TRAMPOLINE_ALIGN 4
838 /* Emit RTL insns to initialize the variable parts of a trampoline.
839 FNADDR is an RTX for the address of the function's pure code.
840 CXT is an RTX for the static chain value for the function. */
842 #define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) \
844 emit_move_insn (gen_rtx (MEM, SImode, plus_constant ((TRAMP), 8)), \
846 emit_move_insn (gen_rtx (MEM, SImode, plus_constant ((TRAMP), 12)), \
850 /* Generate necessary RTL for __builtin_saveregs().
851 ARGLIST is the argument list; see expr.c. */
852 extern struct rtx_def
*sh_builtin_saveregs ();
853 #define EXPAND_BUILTIN_SAVEREGS(ARGLIST) sh_builtin_saveregs (ARGLIST)
855 /* Addressing modes, and classification of registers for them. */
856 #define HAVE_POST_INCREMENT 1
857 /*#define HAVE_PRE_INCREMENT 1*/
858 /*#define HAVE_POST_DECREMENT 1*/
859 #define HAVE_PRE_DECREMENT 1
861 /* Macros to check register numbers against specific register classes. */
863 /* These assume that REGNO is a hard or pseudo reg number.
864 They give nonzero only if REGNO is a hard reg of the suitable class
865 or a pseudo reg currently allocated to a suitable hard reg.
866 Since they use reg_renumber, they are safe only once reg_renumber
867 has been allocated, which happens in local-alloc.c. */
869 #define REGNO_OK_FOR_BASE_P(REGNO) \
870 ((REGNO) < PR_REG || (unsigned) reg_renumber[(REGNO)] < PR_REG)
871 #define REGNO_OK_FOR_INDEX_P(REGNO) \
872 ((REGNO) == 0 || (unsigned) reg_renumber[(REGNO)] == 0)
874 /* Maximum number of registers that can appear in a valid memory
877 #define MAX_REGS_PER_ADDRESS 2
879 /* Recognize any constant value that is a valid address. */
881 #define CONSTANT_ADDRESS_P(X) (GET_CODE (X) == LABEL_REF)
883 /* Nonzero if the constant value X is a legitimate general operand. */
885 /* ??? Should modify this to accept CONST_DOUBLE, and then modify the
886 constant pool table code to fix loads of CONST_DOUBLEs. If that doesn't
887 work well, then we can at least handle simple CONST_DOUBLEs here
890 #define LEGITIMATE_CONSTANT_P(X) \
891 (GET_CODE (X) != CONST_DOUBLE \
892 || (TARGET_SH3E && (fp_zero_operand (X) || fp_one_operand (X))))
894 /* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
895 and check its validity for a certain class.
896 We have two alternate definitions for each of them.
897 The usual definition accepts all pseudo regs; the other rejects
898 them unless they have been allocated suitable hard regs.
899 The symbol REG_OK_STRICT causes the latter definition to be used. */
901 #ifndef REG_OK_STRICT
903 /* Nonzero if X is a hard reg that can be used as a base reg
904 or if it is a pseudo reg. */
905 #define REG_OK_FOR_BASE_P(X) \
906 (REGNO (X) <= 16 || REGNO (X) >= FIRST_PSEUDO_REGISTER)
908 /* Nonzero if X is a hard reg that can be used as an index
909 or if it is a pseudo reg. */
910 #define REG_OK_FOR_INDEX_P(X) \
911 (REGNO (X) == 0 || REGNO (X) >= FIRST_PSEUDO_REGISTER)
913 /* Nonzero if X/OFFSET is a hard reg that can be used as an index
914 or if X is a pseudo reg. */
915 #define SUBREG_OK_FOR_INDEX_P(X, OFFSET) \
916 ((REGNO (X) == 0 && OFFSET == 0) || REGNO (X) >= FIRST_PSEUDO_REGISTER)
920 /* Nonzero if X is a hard reg that can be used as a base reg. */
921 #define REG_OK_FOR_BASE_P(X) \
922 REGNO_OK_FOR_BASE_P (REGNO (X))
924 /* Nonzero if X is a hard reg that can be used as an index. */
925 #define REG_OK_FOR_INDEX_P(X) \
926 REGNO_OK_FOR_INDEX_P (REGNO (X))
928 /* Nonzero if X/OFFSET is a hard reg that can be used as an index. */
929 #define SUBREG_OK_FOR_INDEX_P(X, OFFSET) \
930 (REGNO_OK_FOR_INDEX_P (REGNO (X)) && OFFSET == 0)
934 /* The 'Q' constraint is a pc relative load operand. */
935 #define EXTRA_CONSTRAINT_Q(OP) \
936 (GET_CODE (OP) == MEM && \
937 ((GET_CODE (XEXP (OP, 0)) == LABEL_REF) \
938 || (GET_CODE (XEXP (OP, 0)) == CONST \
939 && GET_CODE (XEXP (XEXP (OP, 0), 0)) == PLUS \
940 && GET_CODE (XEXP (XEXP (XEXP (OP, 0), 0), 0)) == LABEL_REF \
941 && GET_CODE (XEXP (XEXP (XEXP (OP, 0), 0), 1)) == CONST_INT)))
943 #define EXTRA_CONSTRAINT(OP, C) \
944 ((C) == 'Q' ? EXTRA_CONSTRAINT_Q (OP) \
947 /* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression
948 that is a valid memory address for an instruction.
949 The MODE argument is the machine mode for the MEM expression
950 that wants to use this address.
952 The other macros defined here are used only in GO_IF_LEGITIMATE_ADDRESS. */
954 #define MODE_DISP_OK_4(X,MODE) \
955 (GET_MODE_SIZE (MODE) == 4 && (unsigned) INTVAL (X) < 64 \
956 && ! (INTVAL (X) & 3) && ! (TARGET_SH3E && MODE == SFmode))
957 #define MODE_DISP_OK_8(X,MODE) ((GET_MODE_SIZE(MODE)==8) && ((unsigned)INTVAL(X)<60) && (!(INTVAL(X) &3)))
959 #define BASE_REGISTER_RTX_P(X) \
960 ((GET_CODE (X) == REG && REG_OK_FOR_BASE_P (X)) \
961 || (GET_CODE (X) == SUBREG \
962 && GET_CODE (SUBREG_REG (X)) == REG \
963 && REG_OK_FOR_BASE_P (SUBREG_REG (X))))
965 /* Since this must be r0, which is a single register class, we must check
966 SUBREGs more carefully, to be sure that we don't accept one that extends
967 outside the class. */
968 #define INDEX_REGISTER_RTX_P(X) \
969 ((GET_CODE (X) == REG && REG_OK_FOR_INDEX_P (X)) \
970 || (GET_CODE (X) == SUBREG \
971 && GET_CODE (SUBREG_REG (X)) == REG \
972 && SUBREG_OK_FOR_INDEX_P (SUBREG_REG (X), SUBREG_WORD (X))))
974 /* Jump to LABEL if X is a valid address RTX. This must also take
975 REG_OK_STRICT into account when deciding about valid registers, but it uses
976 the above macros so we are in luck.
984 /* ??? The SH3e does not have the REG+disp addressing mode when loading values
985 into the FRx registers. We implement this by setting the maximum offset
986 to zero when the value is SFmode. This also restricts loading of SFmode
987 values into the integer registers, but that can't be helped. */
989 /* The SH allows a displacement in a QI or HI amode, but only when the
990 other operand is R0. GCC doesn't handle this very well, so we forgo
993 A legitimate index for a QI or HI is 0, SI can be any number 0..63,
994 DI can be any number 0..60. */
996 #define GO_IF_LEGITIMATE_INDEX(MODE, OP, LABEL) \
998 if (GET_CODE (OP) == CONST_INT) \
1000 if (MODE_DISP_OK_4 (OP, MODE)) goto LABEL; \
1001 if (MODE_DISP_OK_8 (OP, MODE)) goto LABEL; \
1005 #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, LABEL) \
1007 if (BASE_REGISTER_RTX_P (X)) \
1009 else if ((GET_CODE (X) == POST_INC || GET_CODE (X) == PRE_DEC) \
1010 && BASE_REGISTER_RTX_P (XEXP (X, 0))) \
1012 else if (GET_CODE (X) == PLUS) \
1014 rtx xop0 = XEXP (X, 0); \
1015 rtx xop1 = XEXP (X, 1); \
1016 if (GET_MODE_SIZE (MODE) <= 8 && BASE_REGISTER_RTX_P (xop0)) \
1017 GO_IF_LEGITIMATE_INDEX (MODE, xop1, LABEL); \
1018 if (GET_MODE_SIZE (MODE) <= 4) \
1020 if (BASE_REGISTER_RTX_P (xop1) && INDEX_REGISTER_RTX_P (xop0))\
1022 if (INDEX_REGISTER_RTX_P (xop1) && BASE_REGISTER_RTX_P (xop0))\
1028 /* Try machine-dependent ways of modifying an illegitimate address
1029 to be legitimate. If we find one, return the new, valid address.
1030 This macro is used in only one place: `memory_address' in explow.c.
1032 OLDX is the address as it was before break_out_memory_refs was called.
1033 In some cases it is useful to look at this to decide what needs to be done.
1035 MODE and WIN are passed so that this macro can use
1036 GO_IF_LEGITIMATE_ADDRESS.
1038 It is always safe for this macro to do nothing. It exists to recognize
1039 opportunities to optimize the output. */
1041 #define LEGITIMIZE_ADDRESS(X,OLDX,MODE,WIN) ;
1043 /* Go to LABEL if ADDR (a legitimate address expression)
1044 has an effect that depends on the machine mode it is used for. */
1045 #define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR,LABEL) \
1047 if (GET_CODE(ADDR) == PRE_DEC || GET_CODE(ADDR) == POST_INC) \
1051 /* Specify the machine mode that this machine uses
1052 for the index in the tablejump instruction. */
1053 #define CASE_VECTOR_MODE (TARGET_BIGTABLE ? SImode : HImode)
1055 /* Define this if the tablejump instruction expects the table
1056 to contain offsets from the address of the table.
1057 Do not define this if the table should contain absolute addresses. */
1058 #define CASE_VECTOR_PC_RELATIVE
1060 /* Specify the tree operation to be used to convert reals to integers. */
1061 #define IMPLICIT_FIX_EXPR FIX_ROUND_EXPR
1063 /* This is the kind of divide that is easiest to do in the general case. */
1064 #define EASY_DIV_EXPR TRUNC_DIV_EXPR
1066 /* Since the SH3e has only `float' support, it is desirable to make all
1067 floating point types equivalent to `float'. */
1068 #define DOUBLE_TYPE_SIZE (TARGET_SH3E ? 32 : 64)
1070 /* 'char' is signed by default. */
1071 #define DEFAULT_SIGNED_CHAR 1
1073 /* The type of size_t unsigned int. */
1074 #define SIZE_TYPE "unsigned int"
1076 #define WCHAR_TYPE "short unsigned int"
1077 #define WCHAR_TYPE_SIZE 16
1079 /* Don't cse the address of the function being compiled. */
1080 /*#define NO_RECURSIVE_FUNCTION_CSE 1*/
1082 /* Max number of bytes we can move from memory to memory
1083 in one reasonably fast instruction. */
1086 /* Define if operations between registers always perform the operation
1087 on the full register even if a narrower mode is specified. */
1088 #define WORD_REGISTER_OPERATIONS
1090 /* Define if loading in MODE, an integral mode narrower than BITS_PER_WORD
1091 will either zero-extend or sign-extend. The value of this macro should
1092 be the code that says which one of the two operations is implicitly
1093 done, NIL if none. */
1094 #define LOAD_EXTEND_OP(MODE) SIGN_EXTEND
1096 /* Define this if zero-extension is slow (more than one real instruction).
1097 On the SH, it's only one instruction. */
1098 /* #define SLOW_ZERO_EXTEND */
1100 /* Nonzero if access to memory by bytes is slow and undesirable. */
1101 #define SLOW_BYTE_ACCESS 0
1103 /* We assume that the store-condition-codes instructions store 0 for false
1104 and some other value for true. This is the value stored for true. */
1106 #define STORE_FLAG_VALUE 1
1108 /* Immediate shift counts are truncated by the output routines (or was it
1109 the assembler?). Shift counts in a register are truncated by SH. Note
1110 that the native compiler puts too large (> 32) immediate shift counts
1111 into a register and shifts by the register, letting the SH decide what
1112 to do instead of doing that itself. */
1113 /* ??? This is defined, but the library routines in lib1funcs.asm do not
1114 truncate the shift count. This may result in incorrect results for
1115 unusual cases. Truncating the shift counts in the library routines would
1116 make them faster. However, the SH3 has hardware shifts that do not
1117 truncate, so it appears that we need to leave this undefined for correct
1118 SH3 code. We can still using truncation in the library routines though to
1119 make them faster. */
1120 #define SHIFT_COUNT_TRUNCATED 1
1122 /* All integers have the same format so truncation is easy. */
1123 #define TRULY_NOOP_TRUNCATION(OUTPREC,INPREC) 1
1125 /* Define this if addresses of constant functions
1126 shouldn't be put through pseudo regs where they can be cse'd.
1127 Desirable on machines where ordinary constants are expensive
1128 but a CALL with constant address is cheap. */
1129 /*#define NO_FUNCTION_CSE 1*/
1131 /* Chars and shorts should be passed as ints. */
1132 #define PROMOTE_PROTOTYPES 1
1134 /* The machine modes of pointers and functions. */
1135 #define Pmode SImode
1136 #define FUNCTION_MODE Pmode
1138 /* The relative costs of various types of constants. Note that cse.c defines
1139 REG = 1, SUBREG = 2, any node = (2 + sum of subnodes). */
1141 #define CONST_COSTS(RTX, CODE, OUTER_CODE) \
1143 if (INTVAL (RTX) == 0) \
1145 else if (CONST_OK_FOR_I (INTVAL (RTX))) \
1147 else if ((OUTER_CODE == AND || OUTER_CODE == IOR || OUTER_CODE == XOR) \
1148 && CONST_OK_FOR_L (INTVAL (RTX))) \
1156 case CONST_DOUBLE: \
1159 #define RTX_COSTS(X, CODE, OUTER_CODE) \
1161 return COSTS_N_INSNS (andcosts (X)); \
1163 return COSTS_N_INSNS (multcosts (X)); \
1167 return COSTS_N_INSNS (shiftcosts (X)) ; \
1172 return COSTS_N_INSNS (20); \
1177 /* The multiply insn on the SH1 and the divide insns on the SH1 and SH2
1178 are actually function calls with some special constraints on arguments
1181 These macros tell reorg that the references to arguments and
1182 register clobbers for insns of type sfunc do not appear to happen
1183 until after the millicode call. This allows reorg to put insns
1184 which set the argument registers into the delay slot of the millicode
1185 call -- thus they act more like traditional CALL_INSNs.
1187 get_attr_type will try to recognize the given insn, so make sure to
1188 filter out things it will not accept -- SEQUENCE, USE and CLOBBER insns
1191 #define INSN_SETS_ARE_DELAYED(X) \
1192 ((GET_CODE (X) == INSN \
1193 && GET_CODE (PATTERN (X)) != SEQUENCE \
1194 && GET_CODE (PATTERN (X)) != USE \
1195 && GET_CODE (PATTERN (X)) != CLOBBER \
1196 && get_attr_type (X) == TYPE_SFUNC))
1198 #define INSN_REFERENCES_ARE_DELAYED(X) \
1199 ((GET_CODE (X) == INSN \
1200 && GET_CODE (PATTERN (X)) != SEQUENCE \
1201 && GET_CODE (PATTERN (X)) != USE \
1202 && GET_CODE (PATTERN (X)) != CLOBBER \
1203 && get_attr_type (X) == TYPE_SFUNC))
1205 /* Compute the cost of an address. For the SH, all valid addresses are
1207 /* ??? Perhaps we should make reg+reg addresses have higher cost because
1208 they add to register pressure on r0. */
1210 #define ADDRESS_COST(RTX) 1
1212 /* Compute extra cost of moving data between one register class
1215 On the SH it is hard to move into the T reg, but simple to load
1218 #define REGISTER_MOVE_COST(SRCCLASS, DSTCLASS) \
1219 (((DSTCLASS == T_REGS) || (DSTCLASS == PR_REG)) ? 10 \
1220 : ((DSTCLASS == FP_REGS && SRCCLASS == GENERAL_REGS) \
1221 || (DSTCLASS == GENERAL_REGS && SRCCLASS == FP_REGS)) ? 4 \
1224 /* ??? Perhaps make MEMORY_MOVE_COST depend on compiler option? This
1225 would be so that people would slow memory systems could generate
1226 different code that does fewer memory accesses. */
1228 /* Assembler output control. */
1230 /* The text to go at the start of the assembler file. */
1231 #define ASM_FILE_START(STREAM) \
1232 output_file_start (STREAM, f_options, \
1233 sizeof f_options / sizeof f_options[0], \
1234 W_options, sizeof W_options / sizeof W_options[0]);
1236 #define ASM_FILE_END(STREAM)
1238 #define ASM_APP_ON ""
1239 #define ASM_APP_OFF ""
1240 #define FILE_ASM_OP "\t.file\n"
1241 #define IDENT_ASM_OP "\t.ident\n"
1243 /* How to change between sections. */
1245 #define TEXT_SECTION_ASM_OP "\t.text"
1246 #define DATA_SECTION_ASM_OP "\t.data"
1247 #define CTORS_SECTION_ASM_OP "\t.section\t.ctors\n"
1248 #define DTORS_SECTION_ASM_OP "\t.section\t.dtors\n"
1249 #define EXTRA_SECTIONS in_ctors, in_dtors
1250 #define EXTRA_SECTION_FUNCTIONS \
1254 if (in_section != in_ctors) \
1256 fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP); \
1257 in_section = in_ctors; \
1263 if (in_section != in_dtors) \
1265 fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP); \
1266 in_section = in_dtors; \
1270 /* Define this so that jump tables go in same section as the current function,
1271 which could be text or it could be a user defined section. */
1272 #define JUMP_TABLES_IN_TEXT_SECTION
1274 /* A C statement to output something to the assembler file to switch to section
1275 NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or
1276 NULL_TREE. Some target formats do not support arbitrary sections. Do not
1277 define this macro in such cases. */
1279 #define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME) \
1280 do { fprintf (FILE, ".section\t%s\n", NAME); } while (0)
1282 #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
1283 do { ctors_section(); fprintf(FILE,"\t.long\t_%s\n", NAME); } while (0)
1285 #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
1286 do { dtors_section(); fprintf(FILE,"\t.long\t_%s\n", NAME); } while (0)
1288 #undef DO_GLOBAL_CTORS_BODY
1290 #define DO_GLOBAL_CTORS_BODY \
1292 typedef (*pfunc)(); \
1293 extern pfunc __ctors[]; \
1294 extern pfunc __ctors_end[]; \
1296 for (p = __ctors_end; p > __ctors; ) \
1302 #undef DO_GLOBAL_DTORS_BODY
1303 #define DO_GLOBAL_DTORS_BODY \
1305 typedef (*pfunc)(); \
1306 extern pfunc __dtors[]; \
1307 extern pfunc __dtors_end[]; \
1309 for (p = __dtors; p < __dtors_end; p++) \
1315 #define ASM_OUTPUT_REG_PUSH(file, v) \
1316 fprintf (file, "\tmov.l r%s,-@r15\n", v);
1318 #define ASM_OUTPUT_REG_POP(file, v) \
1319 fprintf (file, "\tmov.l @r15+,r%s\n", v);
1321 /* The assembler's names for the registers. RFP need not always be used as
1322 the Real framepointer; it can also be used as a normal general register.
1323 Note that the name `fp' is horribly misleading since `fp' is in fact only
1324 the argument-and-return-context pointer. */
1325 #define REGISTER_NAMES \
1327 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
1328 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", \
1329 "ap", "pr", "t", "gbr", "mach","macl", "fpul", "X", \
1330 "fr0","fr1","fr2", "fr3", "fr4", "fr5", "fr6", "fr7", \
1331 "fr8","fr9","fr10","fr11","fr12","fr13","fr14","fr15",\
1334 /* DBX register number for a given compiler register number. */
1335 /* GDB has FPUL at 23 and FP0 at 25, so we must add one to all FP registers
1337 #define DBX_REGISTER_NUMBER(REGNO) \
1338 (((REGNO) >= 22 && (REGNO) <= 39) ? ((REGNO) + 1) : (REGNO))
1340 /* Output a label definition. */
1341 #define ASM_OUTPUT_LABEL(FILE,NAME) \
1342 do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0)
1344 /* This is how to output an assembler line
1345 that says to advance the location counter
1346 to a multiple of 2**LOG bytes. */
1348 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
1350 fprintf (FILE, "\t.align %d\n", LOG)
1352 /* Output a function label definition. */
1353 #define ASM_DECLARE_FUNCTION_NAME(STREAM,NAME,DECL) \
1354 ASM_OUTPUT_LABEL(STREAM, NAME)
1356 /* Output a globalising directive for a label. */
1357 #define ASM_GLOBALIZE_LABEL(STREAM,NAME) \
1358 (fprintf (STREAM, "\t.global\t"), \
1359 assemble_name (STREAM, NAME), \
1360 fputc ('\n',STREAM))
1362 /* Output a reference to a label. */
1363 #define ASM_OUTPUT_LABELREF(STREAM,NAME) \
1364 fprintf (STREAM, "_%s", NAME)
1366 /* Make an internal label into a string. */
1367 #define ASM_GENERATE_INTERNAL_LABEL(STRING, PREFIX, NUM) \
1368 sprintf (STRING, "*%s%d", PREFIX, NUM)
1370 /* Output an internal label definition. */
1371 #define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM) \
1372 fprintf (FILE, "%s%d:\n", PREFIX, NUM)
1374 /* #define ASM_OUTPUT_CASE_END(STREAM,NUM,TABLE) */
1376 /* Construct a private name. */
1377 #define ASM_FORMAT_PRIVATE_NAME(OUTVAR,NAME,NUMBER) \
1378 ((OUTVAR) = (char *) alloca (strlen (NAME) + 10), \
1379 sprintf ((OUTVAR), "%s.%d", (NAME), (NUMBER)))
1381 /* Jump tables must be 32 bit aligned, no matter the size of the element. */
1382 #define ASM_OUTPUT_CASE_LABEL(STREAM,PREFIX,NUM,TABLE) \
1383 fprintf (STREAM, "\t.align 2\n%s%d:\n", PREFIX, NUM);
1385 /* Output a relative address table. */
1387 #define ASM_OUTPUT_ADDR_DIFF_ELT(STREAM,VALUE,REL) \
1388 if (TARGET_BIGTABLE) \
1389 fprintf (STREAM, "\t.long L%d-L%d\n", VALUE,REL); \
1391 fprintf (STREAM, "\t.word L%d-L%d\n", VALUE,REL); \
1393 /* Output an absolute table element. */
1395 #define ASM_OUTPUT_ADDR_VEC_ELT(STREAM,VALUE) \
1396 if (TARGET_BIGTABLE) \
1397 fprintf (STREAM, "\t.long L%d\n", VALUE); \
1399 fprintf (STREAM, "\t.word L%d\n", VALUE); \
1401 /* Output various types of constants. */
1403 /* This is how to output an assembler line defining a `double'. */
1405 #define ASM_OUTPUT_DOUBLE(FILE,VALUE) \
1406 do { char dstr[30]; \
1407 REAL_VALUE_TO_DECIMAL ((VALUE), "%.20e", dstr); \
1408 fprintf (FILE, "\t.double %s\n", dstr); \
1411 /* This is how to output an assembler line defining a `float' constant. */
1412 #define ASM_OUTPUT_FLOAT(FILE,VALUE) \
1413 do { char dstr[30]; \
1414 REAL_VALUE_TO_DECIMAL ((VALUE), "%.20e", dstr); \
1415 fprintf (FILE, "\t.float %s\n", dstr); \
1418 #define ASM_OUTPUT_INT(STREAM, EXP) \
1419 (fprintf (STREAM, "\t.long\t"), \
1420 output_addr_const (STREAM, (EXP)), \
1421 fputc ('\n', STREAM))
1423 #define ASM_OUTPUT_SHORT(STREAM, EXP) \
1424 (fprintf (STREAM, "\t.short\t"), \
1425 output_addr_const (STREAM, (EXP)), \
1426 fputc ('\n', STREAM))
1428 #define ASM_OUTPUT_CHAR(STREAM, EXP) \
1429 (fprintf (STREAM, "\t.byte\t"), \
1430 output_addr_const (STREAM, (EXP)), \
1431 fputc ('\n', STREAM))
1433 #define ASM_OUTPUT_BYTE(STREAM, VALUE) \
1434 fprintf (STREAM, "\t.byte\t%d\n", VALUE) \
1436 /* This is how to output an assembler line
1437 that says to advance the location counter by SIZE bytes. */
1439 #define ASM_OUTPUT_SKIP(FILE,SIZE) \
1440 fprintf (FILE, "\t.space %d\n", (SIZE))
1442 /* This says how to output an assembler line
1443 to define a global common symbol. */
1445 #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED) \
1446 ( fputs ("\t.comm ", (FILE)), \
1447 assemble_name ((FILE), (NAME)), \
1448 fprintf ((FILE), ",%d\n", (SIZE)))
1450 /* This says how to output an assembler line
1451 to define a local common symbol. */
1453 #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE,ROUNDED) \
1454 ( fputs ("\t.lcomm ", (FILE)), \
1455 assemble_name ((FILE), (NAME)), \
1456 fprintf ((FILE), ",%d\n", (SIZE)))
1458 /* The assembler's parentheses characters. */
1459 #define ASM_OPEN_PAREN "("
1460 #define ASM_CLOSE_PAREN ")"
1462 /* Target characters. */
1463 #define TARGET_BELL 007
1464 #define TARGET_BS 010
1465 #define TARGET_TAB 011
1466 #define TARGET_NEWLINE 012
1467 #define TARGET_VT 013
1468 #define TARGET_FF 014
1469 #define TARGET_CR 015
1471 /* Only perform branch elimination (by making instructions conditional) if
1472 we're optimizing. Otherwise it's of no use anyway. */
1473 #define FINAL_PRESCAN_INSN(INSN, OPVEC, NOPERANDS) \
1474 final_prescan_insn (INSN, OPVEC, NOPERANDS)
1476 /* Print operand X (an rtx) in assembler syntax to file FILE.
1477 CODE is a letter or dot (`z' in `%z0') or 0 if no letter was specified.
1478 For `%' followed by punctuation, CODE is the punctuation and X is null. */
1480 #define PRINT_OPERAND(STREAM, X, CODE) print_operand (STREAM, X, CODE)
1482 /* Print a memory address as an operand to reference that memory location. */
1484 #define PRINT_OPERAND_ADDRESS(STREAM,X) print_operand_address (STREAM, X)
1486 #define PRINT_OPERAND_PUNCT_VALID_P(CHAR) \
1487 ((CHAR)=='.' || (CHAR) == '#' || (CHAR)=='@')
1489 extern struct rtx_def
*sh_compare_op0
;
1490 extern struct rtx_def
*sh_compare_op1
;
1491 extern struct rtx_def
*prepare_scc_operands();
1493 /* Which processor to schedule for. The elements of the enumeration must
1494 match exactly the cpu attribute in the sh.md file. */
1496 enum processor_type
{
1504 #define sh_cpu_attr ((enum attr_cpu)sh_cpu)
1505 extern enum processor_type sh_cpu
;
1507 /* Declare functions defined in sh.c and used in templates. */
1509 extern char *output_branch();
1510 extern char *output_shift();
1511 extern char *output_movedouble();
1512 extern char *output_movepcrel();
1513 extern char *output_jump_label_table();
1514 extern char *output_far_jump();
1516 #define MACHINE_DEPENDENT_REORG(X) machine_dependent_reorg(X)
1518 /* Generate calls to memcpy, memcmp and memset. */
1520 #define TARGET_MEM_FUNCTIONS
1522 /* Define this macro if you want to implement any pragmas. If defined, it
1523 is a C expression to be executed when #pragma is seen. The
1524 argument FILE is the stdio input stream from which the source
1525 text can be read. CH is the first character after the #pragma. The
1526 result of the expression is the terminating character found
1527 (newline or EOF). */
1528 #define HANDLE_PRAGMA(FILE, CH) handle_pragma (FILE, CH)
1530 /* Set when processing a function with pragma interrupt turned on. */
1532 extern int pragma_interrupt
;
1534 #define MOVE_RATIO (TARGET_SMALLCODE ? 2 : 16)
1536 /* Instructions with unfilled delay slots take up an extra two bytes for
1537 the nop in the delay slot. */
1539 #define ADJUST_INSN_LENGTH(X, LENGTH) \
1540 if (((GET_CODE (X) == INSN \
1541 && GET_CODE (PATTERN (X)) != SEQUENCE \
1542 && GET_CODE (PATTERN (X)) != USE \
1543 && GET_CODE (PATTERN (X)) != CLOBBER) \
1544 || GET_CODE (X) == CALL_INSN \
1545 || (GET_CODE (X) == JUMP_INSN \
1546 && GET_CODE (PATTERN (X)) != ADDR_DIFF_VEC \
1547 && GET_CODE (PATTERN (X)) != ADDR_VEC)) \
1548 && get_attr_needs_delay_slot (X) == NEEDS_DELAY_SLOT_YES) \
1551 /* Enable a bug fix for the shorten_branches pass. */
1552 #define SHORTEN_WITH_ADJUST_INSN_LENGTH
1554 /* Define the codes that are matched by predicates in sh.c. */
1555 #define PREDICATE_CODES \
1556 {"arith_reg_operand", {SUBREG, REG}}, \
1557 {"arith_operand", {SUBREG, REG, CONST_INT}}, \
1558 {"arith_reg_or_0_operand", {SUBREG, REG, CONST_INT}}, \
1559 {"logical_operand", {SUBREG, REG, CONST_INT}}, \
1560 {"general_movsrc_operand", {SUBREG, REG, CONST_INT, MEM}}, \
1561 {"general_movdst_operand", {SUBREG, REG, CONST_INT, MEM}},
1563 /* Define this macro if it is advisable to hold scalars in registers
1564 in a wider mode than that declared by the program. In such cases,
1565 the value is constrained to be within the bounds of the declared
1566 type, but kept valid in the wider mode. The signedness of the
1567 extension may differ from that of the type.
1569 Leaving the unsignedp unchanged gives better code than always setting it
1570 to 0. This is despite the fact that we have only signed char and short
1571 load instructions. */
1572 #define PROMOTE_MODE(MODE, UNSIGNEDP, TYPE) \
1573 if (GET_MODE_CLASS (MODE) == MODE_INT \
1574 && GET_MODE_SIZE (MODE) < UNITS_PER_WORD) \
1577 /* Defining PROMOTE_FUNCTION_ARGS eliminates some unnecessary zero/sign
1578 extensions applied to char/short functions arguments. Defining
1579 PROMOTE_FUNCTION_RETURN does the same for function returns. */
1581 #define PROMOTE_FUNCTION_ARGS
1582 #define PROMOTE_FUNCTION_RETURN
1584 /* ??? Define ACCUMULATE_OUTGOING_ARGS? This is more efficient than pushing
1585 and poping arguments. However, we do have push/pop instructions, and
1586 rather limited offsets (4 bits) in load/store instructions, so it isn't
1587 clear if this would give better code. If implemented, should check for
1588 compatibility problems. */
1590 /* ??? Define ADJUST_COSTS? */
1592 /* For the sake of libgcc2.c, indicate target supports atexit. */