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 PRESERVE_DEATH_INFO_REGNO_P(regno) (TARGET_RELAX || optimize)
154 #define OVERRIDE_OPTIONS \
166 /* Never run scheduling before reload, since that can \
167 break global alloc, and generates slower code anyway due \
168 to the pressure on R0. */ \
169 flag_schedule_insns = 0; \
172 /* Target machine storage layout. */
174 /* Define to use software floating point emulator for REAL_ARITHMETIC and
175 decimal <-> binary conversion. */
176 #define REAL_ARITHMETIC
178 /* Define this if most significant bit is lowest numbered
179 in instructions that operate on numbered bit-fields. */
181 #define BITS_BIG_ENDIAN 0
183 /* Define this if most significant byte of a word is the lowest numbered. */
184 #define BYTES_BIG_ENDIAN (TARGET_LITTLE_ENDIAN == 0)
186 /* Define this if most significant word of a multiword number is the lowest
188 #define WORDS_BIG_ENDIAN (TARGET_LITTLE_ENDIAN == 0)
190 /* Define this to set the endianness to use in libgcc2.c, which can
191 not depend on target_flags. */
192 #if defined(__LITTLE_ENDIAN__)
193 #define LIBGCC2_WORDS_BIG_ENDIAN 0
195 #define LIBGCC2_WORDS_BIG_ENDIAN 1
198 /* Number of bits in an addressable storage unit. */
199 #define BITS_PER_UNIT 8
201 /* Width in bits of a "word", which is the contents of a machine register.
202 Note that this is not necessarily the width of data type `int';
203 if using 16-bit ints on a 68000, this would still be 32.
204 But on a machine with 16-bit registers, this would be 16. */
205 #define BITS_PER_WORD 32
206 #define MAX_BITS_PER_WORD 32
208 /* Width of a word, in units (bytes). */
209 #define UNITS_PER_WORD 4
211 /* Width in bits of a pointer.
212 See also the macro `Pmode' defined below. */
213 #define POINTER_SIZE 32
215 /* Allocation boundary (in *bits*) for storing arguments in argument list. */
216 #define PARM_BOUNDARY 32
218 /* Boundary (in *bits*) on which stack pointer should be aligned. */
219 #define STACK_BOUNDARY 32
221 /* Allocation boundary (in *bits*) for the code of a function.
222 32 bit alignment is faster, because instructions are always fetched as a
223 pair from a longword boundary. */
224 #define FUNCTION_BOUNDARY (TARGET_SMALLCODE ? 16 : 32)
226 /* Alignment of field after `int : 0' in a structure. */
227 #define EMPTY_FIELD_BOUNDARY 32
229 /* No data type wants to be aligned rounder than this. */
230 #define BIGGEST_ALIGNMENT (TARGET_ALIGN_DOUBLE ? 64 : 32)
232 /* The best alignment to use in cases where we have a choice. */
233 #define FASTEST_ALIGNMENT 32
235 /* Make strings word-aligned so strcpy from constants will be faster. */
236 #define CONSTANT_ALIGNMENT(EXP, ALIGN) \
237 ((TREE_CODE (EXP) == STRING_CST \
238 && (ALIGN) < FASTEST_ALIGNMENT) \
239 ? FASTEST_ALIGNMENT : (ALIGN))
241 /* Make arrays of chars word-aligned for the same reasons. */
242 #define DATA_ALIGNMENT(TYPE, ALIGN) \
243 (TREE_CODE (TYPE) == ARRAY_TYPE \
244 && TYPE_MODE (TREE_TYPE (TYPE)) == QImode \
245 && (ALIGN) < FASTEST_ALIGNMENT ? FASTEST_ALIGNMENT : (ALIGN))
247 /* Number of bits which any structure or union's size must be a
248 multiple of. Each structure or union's size is rounded up to a
250 #define STRUCTURE_SIZE_BOUNDARY (TARGET_PADSTRUCT ? 32 : 8)
252 /* Set this nonzero if move instructions will actually fail to work
253 when given unaligned data. */
254 #define STRICT_ALIGNMENT 1
256 /* Standard register usage. */
258 /* Register allocation for the Hitachi calling convention:
264 r14 frame pointer/call saved
266 ap arg pointer (doesn't really exist, always eliminated)
267 pr subroutine return address
269 mach multiply/accumulate result, high part
270 macl multiply/accumulate result, low part.
271 fpul fp/int communication register
272 rap return address pointer 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)
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 /* Fake register that holds the address on the stack of the
379 current function's return address. */
380 #define RETURN_ADDRESS_POINTER_REGNUM 23
382 /* Value should be nonzero if functions must have frame pointers.
383 Zero means the frame pointer need not be set up (and parms may be accessed
384 via the stack pointer) in functions that seem suitable. */
386 #define FRAME_POINTER_REQUIRED 0
388 /* Definitions for register eliminations.
390 We have two registers that can be eliminated on the SH. First, the
391 frame pointer register can often be eliminated in favor of the stack
392 pointer register. Secondly, the argument pointer register can always be
393 eliminated; it is replaced with either the stack or frame pointer. */
395 /* This is an array of structures. Each structure initializes one pair
396 of eliminable registers. The "from" register number is given first,
397 followed by "to". Eliminations of the same "from" register are listed
398 in order of preference. */
400 #define ELIMINABLE_REGS \
401 {{ FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
402 { RETURN_ADDRESS_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
403 { RETURN_ADDRESS_POINTER_REGNUM, FRAME_POINTER_REGNUM}, \
404 { ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
405 { ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM},}
407 /* Given FROM and TO register numbers, say whether this elimination
409 #define CAN_ELIMINATE(FROM, TO) \
410 (!((FROM) == FRAME_POINTER_REGNUM && FRAME_POINTER_REQUIRED))
412 /* Define the offset between two registers, one to be eliminated, and the other
413 its replacement, at the start of a routine. */
415 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
416 OFFSET = initial_elimination_offset (FROM, TO)
418 /* Base register for access to arguments of the function. */
419 #define ARG_POINTER_REGNUM 16
421 /* Register in which the static-chain is passed to a function. */
422 #define STATIC_CHAIN_REGNUM 13
424 /* The register in which a struct value address is passed. */
426 #define STRUCT_VALUE_REGNUM 2
428 /* If the structure value address is not passed in a register, define
429 `STRUCT_VALUE' as an expression returning an RTX for the place
430 where the address is passed. If it returns 0, the address is
431 passed as an "invisible" first argument. */
433 /*#define STRUCT_VALUE ((rtx)0)*/
435 /* Don't default to pcc-struct-return, because we have already specified
436 exactly how to return structures in the RETURN_IN_MEMORY macro. */
438 #define DEFAULT_PCC_STRUCT_RETURN 0
440 /* Define the classes of registers for register constraints in the
441 machine description. Also define ranges of constants.
443 One of the classes must always be named ALL_REGS and include all hard regs.
444 If there is more than one class, another class must be named NO_REGS
445 and contain no registers.
447 The name GENERAL_REGS must be the name of a class (or an alias for
448 another name such as ALL_REGS). This is the class of registers
449 that is allowed by "g" or "r" in a register constraint.
450 Also, registers outside this class are allocated only when
451 instructions express preferences for them.
453 The classes must be numbered in nondecreasing order; that is,
454 a larger-numbered class must never be contained completely
455 in a smaller-numbered class.
457 For any two classes, it is very desirable that there be another
458 class that represents their union. */
460 /* The SH has two sorts of general registers, R0 and the rest. R0 can
461 be used as the destination of some of the arithmetic ops. There are
462 also some special purpose registers; the T bit register, the
463 Procedure Return Register and the Multiply Accumulate Registers. */
481 #define N_REG_CLASSES (int) LIM_REG_CLASSES
483 /* Give names of register classes as strings for dump file. */
484 #define REG_CLASS_NAMES \
499 /* Define which registers fit in which classes.
500 This is an initializer for a vector of HARD_REG_SET
501 of length N_REG_CLASSES. */
503 #define REG_CLASS_CONTENTS \
505 { 0x00000000, 0x00000000 }, /* NO_REGS */ \
506 { 0x00000001, 0x00000000 }, /* R0_REGS */ \
507 { 0x00020000, 0x00000000 }, /* PR_REGS */ \
508 { 0x00040000, 0x00000000 }, /* T_REGS */ \
509 { 0x00300000, 0x00000000 }, /* MAC_REGS */ \
510 { 0x0001FFFF, 0x00000000 }, /* GENERAL_REGS */ \
511 { 0x00400000, 0x00000000 }, /* FPUL_REGS */ \
512 { 0x01000000, 0x00000000 }, /* FP0_REGS */ \
513 { 0xFF000000, 0x000000FF }, /* FP_REGS */ \
514 { 0xFF01FFFF, 0x000000FF }, /* GENERAL_FP_REGS */ \
515 { 0xFF7FFFFF, 0x000000FF }, /* ALL_REGS */ \
518 /* The same information, inverted:
519 Return the class number of the smallest class containing
520 reg number REGNO. This could be a conditional expression
521 or could index an array. */
523 extern int regno_reg_class[];
524 #define REGNO_REG_CLASS(REGNO) regno_reg_class[REGNO]
526 /* When defined, the compiler allows registers explicitly used in the
527 rtl to be used as spill registers but prevents the compiler from
528 extending the lifetime of these registers. */
530 #define SMALL_REGISTER_CLASSES
532 /* The order in which register should be allocated. */
533 #define REG_ALLOC_ORDER \
534 { 1,2,3,7,6,5,4,0,8,9,10,11,12,13,14, \
535 24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39, \
536 22,15,16,17,18,19,20,21,23 }
538 /* The class value for index registers, and the one for base regs. */
539 #define INDEX_REG_CLASS R0_REGS
540 #define BASE_REG_CLASS GENERAL_REGS
542 /* Get reg_class from a letter such as appears in the machine
544 extern enum reg_class reg_class_from_letter[];
546 #define REG_CLASS_FROM_LETTER(C) \
547 ( (C) >= 'a' && (C) <= 'z' ? reg_class_from_letter[(C)-'a'] : NO_REGS )
549 /* The letters I, J, K, L and M in a register constraint string
550 can be used to stand for particular ranges of immediate operands.
551 This macro defines what the ranges are.
552 C is the letter, and VALUE is a constant value.
553 Return 1 if VALUE is in the range specified by C.
554 I: arithmetic operand -127..128, as used in add, sub, etc
555 K: shift operand 1,2,8 or 16
556 L: logical operand 0..255, as used in and, or, etc.
560 #define CONST_OK_FOR_I(VALUE) (((int)(VALUE))>= -128 && ((int)(VALUE)) <= 127)
561 #define CONST_OK_FOR_K(VALUE) ((VALUE)==1||(VALUE)==2||(VALUE)==8||(VALUE)==16)
562 #define CONST_OK_FOR_L(VALUE) (((int)(VALUE))>= 0 && ((int)(VALUE)) <= 255)
563 #define CONST_OK_FOR_M(VALUE) ((VALUE)==1)
564 #define CONST_OK_FOR_N(VALUE) ((VALUE)==0)
565 #define CONST_OK_FOR_LETTER_P(VALUE, C) \
566 ((C) == 'I' ? CONST_OK_FOR_I (VALUE) \
567 : (C) == 'K' ? CONST_OK_FOR_K (VALUE) \
568 : (C) == 'L' ? CONST_OK_FOR_L (VALUE) \
569 : (C) == 'M' ? CONST_OK_FOR_M (VALUE) \
570 : (C) == 'N' ? CONST_OK_FOR_N (VALUE) \
573 /* Similar, but for floating constants, and defining letters G and H.
574 Here VALUE is the CONST_DOUBLE rtx itself. */
576 #define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) \
577 ((C) == 'G' ? fp_zero_operand (VALUE) \
578 : (C) == 'H' ? fp_one_operand (VALUE) \
581 /* Given an rtx X being reloaded into a reg required to be
582 in class CLASS, return the class of reg to actually use.
583 In general this is just CLASS; but on some machines
584 in some cases it is preferable to use a more restrictive class. */
586 #define PREFERRED_RELOAD_CLASS(X, CLASS) CLASS
588 /* Return the maximum number of consecutive registers
589 needed to represent mode MODE in a register of class CLASS.
591 On SH this is the size of MODE in words. */
592 #define CLASS_MAX_NREGS(CLASS, MODE) \
593 ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
595 /* Stack layout; function entry, exit and calling. */
597 /* Define the number of registers that can hold parameters.
598 These macros are used only in other macro definitions below. */
600 #define NPARM_REGS(MODE) \
601 ((TARGET_SH3E && ((MODE) == SFmode)) ? 8 : 4)
603 #define FIRST_PARM_REG 4
604 #define FIRST_RET_REG 0
606 #define FIRST_FP_PARM_REG (FIRST_FP_REG + 4)
607 #define FIRST_FP_RET_REG FIRST_FP_REG
609 /* Define this if pushing a word on the stack
610 makes the stack pointer a smaller address. */
611 #define STACK_GROWS_DOWNWARD
613 /* Define this macro if the addresses of local variable slots are at
614 negative offsets from the frame pointer.
616 The SH only has positive indexes, so grow the frame up. */
617 /* #define FRAME_GROWS_DOWNWARD */
619 /* Offset from the frame pointer to the first local variable slot to
621 #define STARTING_FRAME_OFFSET 0
623 /* If we generate an insn to push BYTES bytes,
624 this says how many the stack pointer really advances by. */
625 #define PUSH_ROUNDING(NPUSHED) (((NPUSHED) + 3) & ~3)
627 /* Offset of first parameter from the argument pointer register value. */
628 #define FIRST_PARM_OFFSET(FNDECL) 0
630 /* Value is the number of byte of arguments automatically
631 popped when returning from a subroutine call.
632 FUNDECL is the declaration node of the function (as a tree),
633 FUNTYPE is the data type of the function (as a tree),
634 or for a library call it is an identifier node for the subroutine name.
635 SIZE is the number of bytes of arguments passed on the stack.
637 On the SH, the caller does not pop any of its arguments that were passed
639 #define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE) 0
641 /* Some subroutine macros specific to this machine. */
643 #define BASE_RETURN_VALUE_REG(MODE) \
644 ((TARGET_SH3E && ((MODE) == SFmode)) \
648 #define BASE_ARG_REG(MODE) \
649 ((TARGET_SH3E && ((MODE) == SFmode)) \
650 ? FIRST_FP_PARM_REG \
653 /* Define how to find the value returned by a function.
654 VALTYPE is the data type of the value (as a tree).
655 If the precise function being called is known, FUNC is its FUNCTION_DECL;
656 otherwise, FUNC is 0. */
658 #define FUNCTION_VALUE(VALTYPE, FUNC) \
659 LIBCALL_VALUE (TYPE_MODE (VALTYPE))
661 /* Define how to find the value returned by a library function
662 assuming the value has mode MODE. */
663 #define LIBCALL_VALUE(MODE) \
664 gen_rtx (REG, MODE, BASE_RETURN_VALUE_REG (MODE));
666 /* 1 if N is a possible register number for a function value. */
667 #define FUNCTION_VALUE_REGNO_P(REGNO) \
668 ((REGNO) == FIRST_RET_REG || (TARGET_SH3E && (REGNO) == FIRST_FP_RET_REG))
670 /* 1 if N is a possible register number for function argument passing. */
671 #define FUNCTION_ARG_REGNO_P(REGNO) \
672 (((REGNO) >= FIRST_PARM_REG && (REGNO) < (FIRST_PARM_REG + 4)) \
674 && (REGNO) >= FIRST_FP_PARM_REG && (REGNO) < (FIRST_FP_PARM_REG + 8)))
676 /* Define a data type for recording info about an argument list
677 during the scan of that argument list. This data type should
678 hold all necessary information about the function itself
679 and about the args processed so far, enough to enable macros
680 such as FUNCTION_ARG to determine where the next arg should go.
682 On SH, this is a single integer, which is a number of words
683 of arguments scanned so far (including the invisible argument,
684 if any, which holds the structure-value-address).
685 Thus NARGREGS or more means all following args should go on the stack. */
687 enum sh_arg_class { SH_ARG_INT = 0, SH_ARG_FLOAT = 1 };
692 #define CUMULATIVE_ARGS struct sh_args
694 #define GET_SH_ARG_CLASS(MODE) \
695 ((TARGET_SH3E && ((MODE) == SFmode)) ? SH_ARG_FLOAT : SH_ARG_INT)
697 #define ROUND_ADVANCE(SIZE) \
698 ((SIZE + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
700 /* Round a register number up to a proper boundary for an arg of mode
703 The SH doesn't care about double alignment, so we only
704 round doubles to even regs when asked to explicitly. */
706 #define ROUND_REG(CUM, MODE) \
707 ((TARGET_ALIGN_DOUBLE \
708 && GET_MODE_UNIT_SIZE ((MODE)) > UNITS_PER_WORD) \
709 ? ((CUM).arg_count[(int) GET_SH_ARG_CLASS (MODE)] \
710 + ((CUM).arg_count[(int) GET_SH_ARG_CLASS (MODE)] & 1)) \
711 : (CUM).arg_count[(int) GET_SH_ARG_CLASS (MODE)])
713 /* Initialize a variable CUM of type CUMULATIVE_ARGS
714 for a call to a function whose data type is FNTYPE.
715 For a library call, FNTYPE is 0.
717 On SH, the offset always starts at 0: the first parm reg is always
720 #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, INDIRECT) \
722 (CUM).arg_count[(int) SH_ARG_INT] = 0; \
723 (CUM).arg_count[(int) SH_ARG_FLOAT] = 0; \
726 /* Update the data in CUM to advance over an argument
727 of mode MODE and data type TYPE.
728 (TYPE is null for libcalls where that information may not be
731 #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \
732 ((CUM).arg_count[(int) GET_SH_ARG_CLASS (MODE)] = \
733 (ROUND_REG ((CUM), (MODE)) \
734 + ((MODE) != BLKmode \
735 ? ROUND_ADVANCE (GET_MODE_SIZE (MODE)) \
736 : ROUND_ADVANCE (int_size_in_bytes (TYPE)))))
738 /* Return boolean indicating arg of mode MODE will be passed in a reg.
739 This macro is only used in this file. */
741 #define PASS_IN_REG_P(CUM, MODE, TYPE) \
742 (ROUND_REG ((CUM), (MODE)) < NPARM_REGS (MODE) \
743 && ((TYPE) == 0 || ! TREE_ADDRESSABLE ((tree)(TYPE))) \
744 && (! TARGET_SH3E || (ROUND_REG((CUM), (MODE)) + (GET_MODE_SIZE(MODE)/4) <= NPARM_REGS (MODE))))
746 /* Define where to put the arguments to a function.
747 Value is zero to push the argument on the stack,
748 or a hard register in which to store the argument.
750 MODE is the argument's machine mode.
751 TYPE is the data type of the argument (as a tree).
752 This is null for libcalls where that information may
754 CUM is a variable of type CUMULATIVE_ARGS which gives info about
755 the preceding args and about the function being called.
756 NAMED is nonzero if this argument is a named parameter
757 (otherwise it is an extra parameter matching an ellipsis).
759 On SH the first args are normally in registers
760 and the rest are pushed. Any arg that starts within the first
761 NPARM_REGS words is at least partially passed in a register unless
762 its data type forbids. */
764 #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
765 ((PASS_IN_REG_P ((CUM), (MODE), (TYPE)) \
766 && (NAMED || TARGET_SH3E)) \
767 ? gen_rtx (REG, (MODE), \
768 (BASE_ARG_REG (MODE) + ROUND_REG ((CUM), (MODE)))) \
771 /* For an arg passed partly in registers and partly in memory,
772 this is the number of registers used.
773 For args passed entirely in registers or entirely in memory, zero.
775 We sometimes split args. */
777 #define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) \
778 ((PASS_IN_REG_P ((CUM), (MODE), (TYPE)) \
779 && (NAMED || TARGET_SH3E) \
780 && (ROUND_REG ((CUM), (MODE)) \
782 ? ROUND_ADVANCE (GET_MODE_SIZE (MODE)) \
783 : ROUND_ADVANCE (int_size_in_bytes (TYPE))) \
784 - NPARM_REGS (MODE) > 0)) \
785 ? NPARM_REGS (MODE) - ROUND_REG ((CUM), (MODE)) \
788 extern int current_function_anonymous_args;
790 /* Perform any needed actions needed for a function that is receiving a
791 variable number of arguments. */
793 #define SETUP_INCOMING_VARARGS(ASF, MODE, TYPE, PAS, ST) \
794 current_function_anonymous_args = 1;
796 /* Call the function profiler with a given profile label.
797 We use two .aligns, so as to make sure that both the .long is aligned
798 on a 4 byte boundary, and that the .long is a fixed distance (2 bytes)
799 from the trapa instruction. */
801 #define FUNCTION_PROFILER(STREAM,LABELNO) \
803 fprintf(STREAM, " .align 2\n"); \
804 fprintf(STREAM, " trapa #33\n"); \
805 fprintf(STREAM, " .align 2\n"); \
806 fprintf(STREAM, " .long LP%d\n", (LABELNO)); \
809 /* Define this macro if the code for function profiling should come
810 before the function prologue. Normally, the profiling code comes
813 #define PROFILE_BEFORE_PROLOGUE
815 /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
816 the stack pointer does not matter. The value is tested only in
817 functions that have frame pointers.
818 No definition is equivalent to always zero. */
820 #define EXIT_IGNORE_STACK 1
822 /* Generate the assembly code for function exit
823 Just dump out any accumulated constant table. */
825 #define FUNCTION_EPILOGUE(STREAM, SIZE) function_epilogue (STREAM, SIZE)
827 /* Output assembler code for a block containing the constant parts
828 of a trampoline, leaving space for the variable parts.
830 On the SH, the trampoline looks like
831 1 0000 D301 mov.l l1,r3
832 2 0002 DD02 mov.l l2,r13
835 5 0008 00000000 l1: .long function
836 6 000c 00000000 l2: .long area */
837 #define TRAMPOLINE_TEMPLATE(FILE) \
839 fprintf ((FILE), " .word 0xd301\n"); \
840 fprintf ((FILE), " .word 0xdd02\n"); \
841 fprintf ((FILE), " .word 0x4d2b\n"); \
842 fprintf ((FILE), " .word 0x200b\n"); \
843 fprintf ((FILE), " .long 0\n"); \
844 fprintf ((FILE), " .long 0\n"); \
847 /* Length in units of the trampoline for entering a nested function. */
848 #define TRAMPOLINE_SIZE 16
850 /* Alignment required for a trampoline in units. */
851 #define TRAMPOLINE_ALIGN 4
853 /* Emit RTL insns to initialize the variable parts of a trampoline.
854 FNADDR is an RTX for the address of the function's pure code.
855 CXT is an RTX for the static chain value for the function. */
857 #define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) \
859 emit_move_insn (gen_rtx (MEM, SImode, plus_constant ((TRAMP), 8)), \
861 emit_move_insn (gen_rtx (MEM, SImode, plus_constant ((TRAMP), 12)), \
865 /* A C expression whose value is RTL representing the value of the return
866 address for the frame COUNT steps up from the current frame.
867 FRAMEADDR is already the frame pointer of the COUNT frame, so we
870 #define RETURN_ADDR_RTX(COUNT, FRAME) \
872 ? gen_rtx (MEM, Pmode, gen_rtx (REG, Pmode, RETURN_ADDRESS_POINTER_REGNUM)) \
875 /* Generate necessary RTL for __builtin_saveregs().
876 ARGLIST is the argument list; see expr.c. */
877 extern struct rtx_def *sh_builtin_saveregs ();
878 #define EXPAND_BUILTIN_SAVEREGS(ARGLIST) sh_builtin_saveregs (ARGLIST)
880 /* Addressing modes, and classification of registers for them. */
881 #define HAVE_POST_INCREMENT 1
882 /*#define HAVE_PRE_INCREMENT 1*/
883 /*#define HAVE_POST_DECREMENT 1*/
884 #define HAVE_PRE_DECREMENT 1
886 /* Macros to check register numbers against specific register classes. */
888 /* These assume that REGNO is a hard or pseudo reg number.
889 They give nonzero only if REGNO is a hard reg of the suitable class
890 or a pseudo reg currently allocated to a suitable hard reg.
891 Since they use reg_renumber, they are safe only once reg_renumber
892 has been allocated, which happens in local-alloc.c. */
894 #define REGNO_OK_FOR_BASE_P(REGNO) \
895 ((REGNO) < PR_REG || (unsigned) reg_renumber[(REGNO)] < PR_REG)
896 #define REGNO_OK_FOR_INDEX_P(REGNO) \
897 ((REGNO) == 0 || (unsigned) reg_renumber[(REGNO)] == 0)
899 /* Maximum number of registers that can appear in a valid memory
902 #define MAX_REGS_PER_ADDRESS 2
904 /* Recognize any constant value that is a valid address. */
906 #define CONSTANT_ADDRESS_P(X) (GET_CODE (X) == LABEL_REF)
908 /* Nonzero if the constant value X is a legitimate general operand. */
910 #define LEGITIMATE_CONSTANT_P(X) \
911 (GET_CODE (X) != CONST_DOUBLE \
912 || GET_MODE (X) == DFmode || GET_MODE (X) == SFmode \
913 || (TARGET_SH3E && (fp_zero_operand (X) || fp_one_operand (X))))
915 /* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
916 and check its validity for a certain class.
917 We have two alternate definitions for each of them.
918 The usual definition accepts all pseudo regs; the other rejects
919 them unless they have been allocated suitable hard regs.
920 The symbol REG_OK_STRICT causes the latter definition to be used. */
922 #ifndef REG_OK_STRICT
924 /* Nonzero if X is a hard reg that can be used as a base reg
925 or if it is a pseudo reg. */
926 #define REG_OK_FOR_BASE_P(X) \
927 (REGNO (X) <= 16 || REGNO (X) >= FIRST_PSEUDO_REGISTER)
929 /* Nonzero if X is a hard reg that can be used as an index
930 or if it is a pseudo reg. */
931 #define REG_OK_FOR_INDEX_P(X) \
932 (REGNO (X) == 0 || REGNO (X) >= FIRST_PSEUDO_REGISTER)
934 /* Nonzero if X/OFFSET is a hard reg that can be used as an index
935 or if X is a pseudo reg. */
936 #define SUBREG_OK_FOR_INDEX_P(X, OFFSET) \
937 ((REGNO (X) == 0 && OFFSET == 0) || REGNO (X) >= FIRST_PSEUDO_REGISTER)
941 /* Nonzero if X is a hard reg that can be used as a base reg. */
942 #define REG_OK_FOR_BASE_P(X) \
943 REGNO_OK_FOR_BASE_P (REGNO (X))
945 /* Nonzero if X is a hard reg that can be used as an index. */
946 #define REG_OK_FOR_INDEX_P(X) \
947 REGNO_OK_FOR_INDEX_P (REGNO (X))
949 /* Nonzero if X/OFFSET is a hard reg that can be used as an index. */
950 #define SUBREG_OK_FOR_INDEX_P(X, OFFSET) \
951 (REGNO_OK_FOR_INDEX_P (REGNO (X)) && OFFSET == 0)
955 /* The 'Q' constraint is a pc relative load operand. */
956 #define EXTRA_CONSTRAINT_Q(OP) \
957 (GET_CODE (OP) == MEM && \
958 ((GET_CODE (XEXP (OP, 0)) == LABEL_REF) \
959 || (GET_CODE (XEXP (OP, 0)) == CONST \
960 && GET_CODE (XEXP (XEXP (OP, 0), 0)) == PLUS \
961 && GET_CODE (XEXP (XEXP (XEXP (OP, 0), 0), 0)) == LABEL_REF \
962 && GET_CODE (XEXP (XEXP (XEXP (OP, 0), 0), 1)) == CONST_INT)))
964 #define EXTRA_CONSTRAINT(OP, C) \
965 ((C) == 'Q' ? EXTRA_CONSTRAINT_Q (OP) \
968 /* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression
969 that is a valid memory address for an instruction.
970 The MODE argument is the machine mode for the MEM expression
971 that wants to use this address.
973 The other macros defined here are used only in GO_IF_LEGITIMATE_ADDRESS. */
975 #define MODE_DISP_OK_4(X,MODE) \
976 (GET_MODE_SIZE (MODE) == 4 && (unsigned) INTVAL (X) < 64 \
977 && ! (INTVAL (X) & 3) && ! (TARGET_SH3E && MODE == SFmode))
978 #define MODE_DISP_OK_8(X,MODE) ((GET_MODE_SIZE(MODE)==8) && ((unsigned)INTVAL(X)<60) && (!(INTVAL(X) &3)))
980 #define BASE_REGISTER_RTX_P(X) \
981 ((GET_CODE (X) == REG && REG_OK_FOR_BASE_P (X)) \
982 || (GET_CODE (X) == SUBREG \
983 && GET_CODE (SUBREG_REG (X)) == REG \
984 && REG_OK_FOR_BASE_P (SUBREG_REG (X))))
986 /* Since this must be r0, which is a single register class, we must check
987 SUBREGs more carefully, to be sure that we don't accept one that extends
988 outside the class. */
989 #define INDEX_REGISTER_RTX_P(X) \
990 ((GET_CODE (X) == REG && REG_OK_FOR_INDEX_P (X)) \
991 || (GET_CODE (X) == SUBREG \
992 && GET_CODE (SUBREG_REG (X)) == REG \
993 && SUBREG_OK_FOR_INDEX_P (SUBREG_REG (X), SUBREG_WORD (X))))
995 /* Jump to LABEL if X is a valid address RTX. This must also take
996 REG_OK_STRICT into account when deciding about valid registers, but it uses
997 the above macros so we are in luck.
1005 /* ??? The SH3e does not have the REG+disp addressing mode when loading values
1006 into the FRx registers. We implement this by setting the maximum offset
1007 to zero when the value is SFmode. This also restricts loading of SFmode
1008 values into the integer registers, but that can't be helped. */
1010 /* The SH allows a displacement in a QI or HI amode, but only when the
1011 other operand is R0. GCC doesn't handle this very well, so we forgo
1014 A legitimate index for a QI or HI is 0, SI can be any number 0..63,
1015 DI can be any number 0..60. */
1017 #define GO_IF_LEGITIMATE_INDEX(MODE, OP, LABEL) \
1019 if (GET_CODE (OP) == CONST_INT) \
1021 if (MODE_DISP_OK_4 (OP, MODE)) goto LABEL; \
1022 if (MODE_DISP_OK_8 (OP, MODE)) goto LABEL; \
1026 #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, LABEL) \
1028 if (BASE_REGISTER_RTX_P (X)) \
1030 else if ((GET_CODE (X) == POST_INC || GET_CODE (X) == PRE_DEC) \
1031 && BASE_REGISTER_RTX_P (XEXP (X, 0))) \
1033 else if (GET_CODE (X) == PLUS) \
1035 rtx xop0 = XEXP (X, 0); \
1036 rtx xop1 = XEXP (X, 1); \
1037 if (GET_MODE_SIZE (MODE) <= 8 && BASE_REGISTER_RTX_P (xop0)) \
1038 GO_IF_LEGITIMATE_INDEX (MODE, xop1, LABEL); \
1039 if (GET_MODE_SIZE (MODE) <= 4) \
1041 if (BASE_REGISTER_RTX_P (xop1) && INDEX_REGISTER_RTX_P (xop0))\
1043 if (INDEX_REGISTER_RTX_P (xop1) && BASE_REGISTER_RTX_P (xop0))\
1049 /* Try machine-dependent ways of modifying an illegitimate address
1050 to be legitimate. If we find one, return the new, valid address.
1051 This macro is used in only one place: `memory_address' in explow.c.
1053 OLDX is the address as it was before break_out_memory_refs was called.
1054 In some cases it is useful to look at this to decide what needs to be done.
1056 MODE and WIN are passed so that this macro can use
1057 GO_IF_LEGITIMATE_ADDRESS.
1059 It is always safe for this macro to do nothing. It exists to recognize
1060 opportunities to optimize the output.
1062 For the SH, if X is almost suitable for indexing, but the offset is
1063 out of range, convert it into a normal form so that cse has a chance
1064 of reducing the number of address registers used. */
1066 #define LEGITIMIZE_ADDRESS(X,OLDX,MODE,WIN) \
1068 if (GET_CODE (X) == PLUS \
1069 && (GET_MODE_SIZE (MODE) == 4 \
1070 || GET_MODE_SIZE (MODE) == 8) \
1071 && GET_CODE (XEXP (X, 1)) == CONST_INT \
1072 && BASE_REGISTER_RTX_P (XEXP (X, 0)) \
1073 && ! (TARGET_SH3E && MODE == SFmode)) \
1075 rtx index_rtx = XEXP (X, 1); \
1076 HOST_WIDE_INT offset = INTVAL (index_rtx), offset_base; \
1079 GO_IF_LEGITIMATE_INDEX (MODE, index_rtx, WIN); \
1080 /* On rare occasions, we might get an unaligned pointer \
1081 that is indexed in a way to give an aligned address. \
1082 Therefore, keep the lower two bits in offset_base. */ \
1083 /* Instead of offset_base 128..131 use 124..127, so that \
1084 simple add suffices. */ \
1087 offset_base = ((offset + 4) & ~60) - 4; \
1090 offset_base = offset & ~60; \
1091 /* Sometimes the normal form does not suit DImode. We \
1092 could avoid that by using smaller ranges, but that \
1093 would give less optimized code when SImode is \
1095 if (GET_MODE_SIZE (MODE) + offset - offset_base <= 64) \
1097 sum = expand_binop (Pmode, add_optab, XEXP (X, 0), \
1098 GEN_INT (offset_base), NULL_RTX, 0, \
1101 (X) = gen_rtx (PLUS, Pmode, sum, GEN_INT (offset - offset_base)); \
1107 /* Go to LABEL if ADDR (a legitimate address expression)
1108 has an effect that depends on the machine mode it is used for. */
1109 #define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR,LABEL) \
1111 if (GET_CODE(ADDR) == PRE_DEC || GET_CODE(ADDR) == POST_INC) \
1115 /* Specify the machine mode that this machine uses
1116 for the index in the tablejump instruction. */
1117 #define CASE_VECTOR_MODE (TARGET_BIGTABLE ? SImode : HImode)
1119 /* Define this if the tablejump instruction expects the table
1120 to contain offsets from the address of the table.
1121 Do not define this if the table should contain absolute addresses. */
1122 #define CASE_VECTOR_PC_RELATIVE
1124 /* Specify the tree operation to be used to convert reals to integers. */
1125 #define IMPLICIT_FIX_EXPR FIX_ROUND_EXPR
1127 /* This is the kind of divide that is easiest to do in the general case. */
1128 #define EASY_DIV_EXPR TRUNC_DIV_EXPR
1130 /* Since the SH3e has only `float' support, it is desirable to make all
1131 floating point types equivalent to `float'. */
1132 #define DOUBLE_TYPE_SIZE (TARGET_SH3E ? 32 : 64)
1134 /* 'char' is signed by default. */
1135 #define DEFAULT_SIGNED_CHAR 1
1137 /* The type of size_t unsigned int. */
1138 #define SIZE_TYPE "unsigned int"
1140 #define WCHAR_TYPE "short unsigned int"
1141 #define WCHAR_TYPE_SIZE 16
1143 /* Don't cse the address of the function being compiled. */
1144 /*#define NO_RECURSIVE_FUNCTION_CSE 1*/
1146 /* Max number of bytes we can move from memory to memory
1147 in one reasonably fast instruction. */
1150 /* Define if operations between registers always perform the operation
1151 on the full register even if a narrower mode is specified. */
1152 #define WORD_REGISTER_OPERATIONS
1154 /* Define if loading in MODE, an integral mode narrower than BITS_PER_WORD
1155 will either zero-extend or sign-extend. The value of this macro should
1156 be the code that says which one of the two operations is implicitly
1157 done, NIL if none. */
1158 #define LOAD_EXTEND_OP(MODE) SIGN_EXTEND
1160 /* Define if loading short immediate values into registers sign extends. */
1161 #define SHORT_IMMEDIATES_SIGN_EXTEND
1163 /* Define this if zero-extension is slow (more than one real instruction).
1164 On the SH, it's only one instruction. */
1165 /* #define SLOW_ZERO_EXTEND */
1167 /* Nonzero if access to memory by bytes is slow and undesirable. */
1168 #define SLOW_BYTE_ACCESS 0
1170 /* We assume that the store-condition-codes instructions store 0 for false
1171 and some other value for true. This is the value stored for true. */
1173 #define STORE_FLAG_VALUE 1
1175 /* Immediate shift counts are truncated by the output routines (or was it
1176 the assembler?). Shift counts in a register are truncated by SH. Note
1177 that the native compiler puts too large (> 32) immediate shift counts
1178 into a register and shifts by the register, letting the SH decide what
1179 to do instead of doing that itself. */
1180 /* ??? This is defined, but the library routines in lib1funcs.asm do not
1181 truncate the shift count. This may result in incorrect results for
1182 unusual cases. Truncating the shift counts in the library routines would
1183 make them faster. However, the SH3 has hardware shifts that do not
1184 truncate, so it appears that we need to leave this undefined for correct
1185 SH3 code. We can still using truncation in the library routines though to
1186 make them faster. */
1187 #define SHIFT_COUNT_TRUNCATED 1
1189 /* All integers have the same format so truncation is easy. */
1190 #define TRULY_NOOP_TRUNCATION(OUTPREC,INPREC) 1
1192 /* Define this if addresses of constant functions
1193 shouldn't be put through pseudo regs where they can be cse'd.
1194 Desirable on machines where ordinary constants are expensive
1195 but a CALL with constant address is cheap. */
1196 /*#define NO_FUNCTION_CSE 1*/
1198 /* Chars and shorts should be passed as ints. */
1199 #define PROMOTE_PROTOTYPES 1
1201 /* The machine modes of pointers and functions. */
1202 #define Pmode SImode
1203 #define FUNCTION_MODE Pmode
1205 /* The relative costs of various types of constants. Note that cse.c defines
1206 REG = 1, SUBREG = 2, any node = (2 + sum of subnodes). */
1208 #define CONST_COSTS(RTX, CODE, OUTER_CODE) \
1210 if (INTVAL (RTX) == 0) \
1212 else if (CONST_OK_FOR_I (INTVAL (RTX))) \
1214 else if ((OUTER_CODE == AND || OUTER_CODE == IOR || OUTER_CODE == XOR) \
1215 && CONST_OK_FOR_L (INTVAL (RTX))) \
1223 case CONST_DOUBLE: \
1226 #define RTX_COSTS(X, CODE, OUTER_CODE) \
1228 return COSTS_N_INSNS (andcosts (X)); \
1230 return COSTS_N_INSNS (multcosts (X)); \
1234 return COSTS_N_INSNS (shiftcosts (X)) ; \
1239 return COSTS_N_INSNS (20); \
1244 /* The multiply insn on the SH1 and the divide insns on the SH1 and SH2
1245 are actually function calls with some special constraints on arguments
1248 These macros tell reorg that the references to arguments and
1249 register clobbers for insns of type sfunc do not appear to happen
1250 until after the millicode call. This allows reorg to put insns
1251 which set the argument registers into the delay slot of the millicode
1252 call -- thus they act more like traditional CALL_INSNs.
1254 get_attr_type will try to recognize the given insn, so make sure to
1255 filter out things it will not accept -- SEQUENCE, USE and CLOBBER insns
1258 #define INSN_SETS_ARE_DELAYED(X) \
1259 ((GET_CODE (X) == INSN \
1260 && GET_CODE (PATTERN (X)) != SEQUENCE \
1261 && GET_CODE (PATTERN (X)) != USE \
1262 && GET_CODE (PATTERN (X)) != CLOBBER \
1263 && get_attr_type (X) == TYPE_SFUNC))
1265 #define INSN_REFERENCES_ARE_DELAYED(X) \
1266 ((GET_CODE (X) == INSN \
1267 && GET_CODE (PATTERN (X)) != SEQUENCE \
1268 && GET_CODE (PATTERN (X)) != USE \
1269 && GET_CODE (PATTERN (X)) != CLOBBER \
1270 && get_attr_type (X) == TYPE_SFUNC))
1272 /* Compute the cost of an address. For the SH, all valid addresses are
1274 /* ??? Perhaps we should make reg+reg addresses have higher cost because
1275 they add to register pressure on r0. */
1277 #define ADDRESS_COST(RTX) 1
1279 /* Compute extra cost of moving data between one register class
1282 On the SH it is hard to move into the T reg, but simple to load
1285 #define REGISTER_MOVE_COST(SRCCLASS, DSTCLASS) \
1286 (((DSTCLASS == T_REGS) || (DSTCLASS == PR_REG)) ? 10 \
1287 : ((DSTCLASS == FP_REGS && SRCCLASS == GENERAL_REGS) \
1288 || (DSTCLASS == GENERAL_REGS && SRCCLASS == FP_REGS)) ? 4 \
1291 /* ??? Perhaps make MEMORY_MOVE_COST depend on compiler option? This
1292 would be so that people would slow memory systems could generate
1293 different code that does fewer memory accesses. */
1295 /* Assembler output control. */
1297 /* A C string constant describing how to begin a comment in the target
1298 assembler language. The compiler assumes that the comment will end at
1299 the end of the line. */
1300 #define ASM_COMMENT_START "!"
1302 /* The text to go at the start of the assembler file. */
1303 #define ASM_FILE_START(STREAM) \
1304 output_file_start (STREAM)
1306 #define ASM_FILE_END(STREAM)
1308 #define ASM_APP_ON ""
1309 #define ASM_APP_OFF ""
1310 #define FILE_ASM_OP "\t.file\n"
1311 #define IDENT_ASM_OP "\t.ident\n"
1312 #define SET_ASM_OP ".set"
1314 /* How to change between sections. */
1316 #define TEXT_SECTION_ASM_OP "\t.text"
1317 #define DATA_SECTION_ASM_OP "\t.data"
1318 #define CTORS_SECTION_ASM_OP "\t.section\t.ctors\n"
1319 #define DTORS_SECTION_ASM_OP "\t.section\t.dtors\n"
1320 #define EXTRA_SECTIONS in_ctors, in_dtors
1321 #define EXTRA_SECTION_FUNCTIONS \
1325 if (in_section != in_ctors) \
1327 fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP); \
1328 in_section = in_ctors; \
1334 if (in_section != in_dtors) \
1336 fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP); \
1337 in_section = in_dtors; \
1341 /* Define this so that jump tables go in same section as the current function,
1342 which could be text or it could be a user defined section. */
1343 #define JUMP_TABLES_IN_TEXT_SECTION
1345 /* A C statement to output something to the assembler file to switch to section
1346 NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or
1347 NULL_TREE. Some target formats do not support arbitrary sections. Do not
1348 define this macro in such cases. */
1350 #define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME) \
1351 do { fprintf (FILE, ".section\t%s\n", NAME); } while (0)
1353 #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
1354 do { ctors_section(); fprintf(FILE,"\t.long\t_%s\n", NAME); } while (0)
1356 #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
1357 do { dtors_section(); fprintf(FILE,"\t.long\t_%s\n", NAME); } while (0)
1359 #undef DO_GLOBAL_CTORS_BODY
1361 #define DO_GLOBAL_CTORS_BODY \
1363 typedef (*pfunc)(); \
1364 extern pfunc __ctors[]; \
1365 extern pfunc __ctors_end[]; \
1367 for (p = __ctors_end; p > __ctors; ) \
1373 #undef DO_GLOBAL_DTORS_BODY
1374 #define DO_GLOBAL_DTORS_BODY \
1376 typedef (*pfunc)(); \
1377 extern pfunc __dtors[]; \
1378 extern pfunc __dtors_end[]; \
1380 for (p = __dtors; p < __dtors_end; p++) \
1386 #define ASM_OUTPUT_REG_PUSH(file, v) \
1387 fprintf (file, "\tmov.l r%s,-@r15\n", v);
1389 #define ASM_OUTPUT_REG_POP(file, v) \
1390 fprintf (file, "\tmov.l @r15+,r%s\n", v);
1392 /* The assembler's names for the registers. RFP need not always be used as
1393 the Real framepointer; it can also be used as a normal general register.
1394 Note that the name `fp' is horribly misleading since `fp' is in fact only
1395 the argument-and-return-context pointer. */
1396 #define REGISTER_NAMES \
1398 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
1399 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", \
1400 "ap", "pr", "t", "gbr", "mach","macl", "fpul","rap", \
1401 "fr0","fr1","fr2", "fr3", "fr4", "fr5", "fr6", "fr7", \
1402 "fr8","fr9","fr10","fr11","fr12","fr13","fr14","fr15",\
1405 /* DBX register number for a given compiler register number. */
1406 /* GDB has FPUL at 23 and FP0 at 25, so we must add one to all FP registers
1408 #define DBX_REGISTER_NUMBER(REGNO) \
1409 (((REGNO) >= 22 && (REGNO) <= 39) ? ((REGNO) + 1) : (REGNO))
1411 /* Output a label definition. */
1412 #define ASM_OUTPUT_LABEL(FILE,NAME) \
1413 do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0)
1415 /* This is how to output an assembler line
1416 that says to advance the location counter
1417 to a multiple of 2**LOG bytes. */
1419 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
1421 fprintf (FILE, "\t.align %d\n", LOG)
1423 /* Output a function label definition. */
1424 #define ASM_DECLARE_FUNCTION_NAME(STREAM,NAME,DECL) \
1425 ASM_OUTPUT_LABEL(STREAM, NAME)
1427 /* Output a globalising directive for a label. */
1428 #define ASM_GLOBALIZE_LABEL(STREAM,NAME) \
1429 (fprintf (STREAM, "\t.global\t"), \
1430 assemble_name (STREAM, NAME), \
1431 fputc ('\n',STREAM))
1433 /* The prefix to add to user-visible assembler symbols. */
1435 #define USER_LABEL_PREFIX "_"
1437 /* Make an internal label into a string. */
1438 #define ASM_GENERATE_INTERNAL_LABEL(STRING, PREFIX, NUM) \
1439 sprintf (STRING, "*%s%d", PREFIX, NUM)
1441 /* Output an internal label definition. */
1442 #define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM) \
1443 fprintf (FILE, "%s%d:\n", PREFIX, NUM)
1445 /* #define ASM_OUTPUT_CASE_END(STREAM,NUM,TABLE) */
1447 /* Construct a private name. */
1448 #define ASM_FORMAT_PRIVATE_NAME(OUTVAR,NAME,NUMBER) \
1449 ((OUTVAR) = (char *) alloca (strlen (NAME) + 10), \
1450 sprintf ((OUTVAR), "%s.%d", (NAME), (NUMBER)))
1452 /* Jump tables must be 32 bit aligned, no matter the size of the element. */
1453 #define ASM_OUTPUT_CASE_LABEL(STREAM,PREFIX,NUM,TABLE) \
1454 fprintf (STREAM, "\t.align 2\n%s%d:\n", PREFIX, NUM);
1456 /* Output a relative address table. */
1458 #define ASM_OUTPUT_ADDR_DIFF_ELT(STREAM,VALUE,REL) \
1459 if (TARGET_BIGTABLE) \
1460 fprintf (STREAM, "\t.long L%d-L%d\n", VALUE,REL); \
1462 fprintf (STREAM, "\t.word L%d-L%d\n", VALUE,REL); \
1464 /* Output an absolute table element. */
1466 #define ASM_OUTPUT_ADDR_VEC_ELT(STREAM,VALUE) \
1467 if (TARGET_BIGTABLE) \
1468 fprintf (STREAM, "\t.long L%d\n", VALUE); \
1470 fprintf (STREAM, "\t.word L%d\n", VALUE); \
1472 /* Output various types of constants. */
1474 /* This is how to output an assembler line defining a `double'. */
1476 #define ASM_OUTPUT_DOUBLE(FILE,VALUE) \
1477 do { char dstr[30]; \
1478 REAL_VALUE_TO_DECIMAL ((VALUE), "%.20e", dstr); \
1479 fprintf (FILE, "\t.double %s\n", dstr); \
1482 /* This is how to output an assembler line defining a `float' constant. */
1483 #define ASM_OUTPUT_FLOAT(FILE,VALUE) \
1484 do { char dstr[30]; \
1485 REAL_VALUE_TO_DECIMAL ((VALUE), "%.20e", dstr); \
1486 fprintf (FILE, "\t.float %s\n", dstr); \
1489 #define ASM_OUTPUT_INT(STREAM, EXP) \
1490 (fprintf (STREAM, "\t.long\t"), \
1491 output_addr_const (STREAM, (EXP)), \
1492 fputc ('\n', STREAM))
1494 #define ASM_OUTPUT_SHORT(STREAM, EXP) \
1495 (fprintf (STREAM, "\t.short\t"), \
1496 output_addr_const (STREAM, (EXP)), \
1497 fputc ('\n', STREAM))
1499 #define ASM_OUTPUT_CHAR(STREAM, EXP) \
1500 (fprintf (STREAM, "\t.byte\t"), \
1501 output_addr_const (STREAM, (EXP)), \
1502 fputc ('\n', STREAM))
1504 #define ASM_OUTPUT_BYTE(STREAM, VALUE) \
1505 fprintf (STREAM, "\t.byte\t%d\n", VALUE) \
1507 /* Align loops and labels after unconditional branches to get faster
1510 #define ASM_OUTPUT_LOOP_ALIGN(FILE) \
1511 if (! TARGET_SMALLCODE) \
1512 ASM_OUTPUT_ALIGN ((FILE), 2)
1514 #define ASM_OUTPUT_ALIGN_CODE(FILE) \
1515 if (! TARGET_SMALLCODE) \
1516 ASM_OUTPUT_ALIGN ((FILE), (TARGET_SH3 || TARGET_SH3E) ? 4 : 2)
1518 /* This is how to output an assembler line
1519 that says to advance the location counter by SIZE bytes. */
1521 #define ASM_OUTPUT_SKIP(FILE,SIZE) \
1522 fprintf (FILE, "\t.space %d\n", (SIZE))
1524 /* This says how to output an assembler line
1525 to define a global common symbol. */
1527 #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED) \
1528 ( fputs ("\t.comm ", (FILE)), \
1529 assemble_name ((FILE), (NAME)), \
1530 fprintf ((FILE), ",%d\n", (SIZE)))
1532 /* This says how to output an assembler line
1533 to define a local common symbol. */
1535 #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE,ROUNDED) \
1536 ( fputs ("\t.lcomm ", (FILE)), \
1537 assemble_name ((FILE), (NAME)), \
1538 fprintf ((FILE), ",%d\n", (SIZE)))
1540 /* The assembler's parentheses characters. */
1541 #define ASM_OPEN_PAREN "("
1542 #define ASM_CLOSE_PAREN ")"
1544 /* Target characters. */
1545 #define TARGET_BELL 007
1546 #define TARGET_BS 010
1547 #define TARGET_TAB 011
1548 #define TARGET_NEWLINE 012
1549 #define TARGET_VT 013
1550 #define TARGET_FF 014
1551 #define TARGET_CR 015
1553 /* Only perform branch elimination (by making instructions conditional) if
1554 we're optimizing. Otherwise it's of no use anyway. */
1555 #define FINAL_PRESCAN_INSN(INSN, OPVEC, NOPERANDS) \
1556 final_prescan_insn (INSN, OPVEC, NOPERANDS)
1558 /* Print operand X (an rtx) in assembler syntax to file FILE.
1559 CODE is a letter or dot (`z' in `%z0') or 0 if no letter was specified.
1560 For `%' followed by punctuation, CODE is the punctuation and X is null. */
1562 #define PRINT_OPERAND(STREAM, X, CODE) print_operand (STREAM, X, CODE)
1564 /* Print a memory address as an operand to reference that memory location. */
1566 #define PRINT_OPERAND_ADDRESS(STREAM,X) print_operand_address (STREAM, X)
1568 #define PRINT_OPERAND_PUNCT_VALID_P(CHAR) \
1569 ((CHAR)=='.' || (CHAR) == '#' || (CHAR)=='@')
1571 extern struct rtx_def *sh_compare_op0;
1572 extern struct rtx_def *sh_compare_op1;
1573 extern struct rtx_def *prepare_scc_operands();
1575 /* Which processor to schedule for. The elements of the enumeration must
1576 match exactly the cpu attribute in the sh.md file. */
1578 enum processor_type {
1586 #define sh_cpu_attr ((enum attr_cpu)sh_cpu)
1587 extern enum processor_type sh_cpu;
1589 /* Declare functions defined in sh.c and used in templates. */
1591 extern char *output_branch();
1592 extern char *output_shift();
1593 extern char *output_movedouble();
1594 extern char *output_movepcrel();
1595 extern char *output_jump_label_table();
1596 extern char *output_far_jump();
1598 #define MACHINE_DEPENDENT_REORG(X) machine_dependent_reorg(X)
1600 /* Generate calls to memcpy, memcmp and memset. */
1602 #define TARGET_MEM_FUNCTIONS
1604 /* Define this macro if you want to implement any pragmas. If defined, it
1605 is a C expression to be executed when #pragma is seen. The
1606 argument FILE is the stdio input stream from which the source
1607 text can be read. CH is the first character after the #pragma. The
1608 result of the expression is the terminating character found
1609 (newline or EOF). */
1610 #define HANDLE_PRAGMA(FILE, NODE) handle_pragma (FILE, NODE)
1612 /* Set when processing a function with pragma interrupt turned on. */
1614 extern int pragma_interrupt;
1616 #define MOVE_RATIO (TARGET_SMALLCODE ? 2 : 16)
1618 /* Instructions with unfilled delay slots take up an extra two bytes for
1619 the nop in the delay slot. Instructions at the start of loops, or
1620 after unconditional branches, may take up extra room when they are
1621 aligned. ??? We would get more accurate results if we did instruction
1622 alignment based on the value of INSN_CURRENT_ADDRESS; the approach used
1623 here is too conservative. */
1625 #define ADJUST_INSN_LENGTH(X, LENGTH) \
1626 if (((GET_CODE (X) == INSN \
1627 && GET_CODE (PATTERN (X)) != SEQUENCE \
1628 && GET_CODE (PATTERN (X)) != USE \
1629 && GET_CODE (PATTERN (X)) != CLOBBER) \
1630 || GET_CODE (X) == CALL_INSN \
1631 || (GET_CODE (X) == JUMP_INSN \
1632 && GET_CODE (PATTERN (X)) != ADDR_DIFF_VEC \
1633 && GET_CODE (PATTERN (X)) != ADDR_VEC)) \
1634 && get_attr_needs_delay_slot (X) == NEEDS_DELAY_SLOT_YES) \
1636 if (! TARGET_SMALLCODE) \
1639 for (aip = PREV_INSN (X); aip; aip = PREV_INSN (aip)) \
1641 if (GET_CODE (aip) == BARRIER) \
1643 if (TARGET_SH3 || TARGET_SH3E) \
1649 else if ((GET_CODE (aip) == NOTE \
1650 && NOTE_LINE_NUMBER (aip) == NOTE_INSN_LOOP_BEG)) \
1655 else if (GET_CODE (aip) != NOTE \
1656 && GET_CODE (aip) != CODE_LABEL) \
1661 /* Enable a bug fix for the shorten_branches pass. */
1662 #define SHORTEN_WITH_ADJUST_INSN_LENGTH
1664 /* Define the codes that are matched by predicates in sh.c. */
1665 #define PREDICATE_CODES \
1666 {"arith_reg_operand", {SUBREG, REG}}, \
1667 {"arith_operand", {SUBREG, REG, CONST_INT}}, \
1668 {"arith_reg_or_0_operand", {SUBREG, REG, CONST_INT}}, \
1669 {"logical_operand", {SUBREG, REG, CONST_INT}}, \
1670 {"general_movsrc_operand", {SUBREG, REG, CONST_INT, MEM}}, \
1671 {"general_movdst_operand", {SUBREG, REG, CONST_INT, MEM}},
1673 /* Define this macro if it is advisable to hold scalars in registers
1674 in a wider mode than that declared by the program. In such cases,
1675 the value is constrained to be within the bounds of the declared
1676 type, but kept valid in the wider mode. The signedness of the
1677 extension may differ from that of the type.
1679 Leaving the unsignedp unchanged gives better code than always setting it
1680 to 0. This is despite the fact that we have only signed char and short
1681 load instructions. */
1682 #define PROMOTE_MODE(MODE, UNSIGNEDP, TYPE) \
1683 if (GET_MODE_CLASS (MODE) == MODE_INT \
1684 && GET_MODE_SIZE (MODE) < UNITS_PER_WORD) \
1687 /* Defining PROMOTE_FUNCTION_ARGS eliminates some unnecessary zero/sign
1688 extensions applied to char/short functions arguments. Defining
1689 PROMOTE_FUNCTION_RETURN does the same for function returns. */
1691 #define PROMOTE_FUNCTION_ARGS
1692 #define PROMOTE_FUNCTION_RETURN
1694 /* ??? Define ACCUMULATE_OUTGOING_ARGS? This is more efficient than pushing
1695 and poping arguments. However, we do have push/pop instructions, and
1696 rather limited offsets (4 bits) in load/store instructions, so it isn't
1697 clear if this would give better code. If implemented, should check for
1698 compatibility problems. */
1700 /* ??? Define ADJUST_COSTS? */
1702 /* Since the SH architecture lacks negative address offsets,
1703 the givs should be sorted smallest to largest so combine_givs
1704 has maximum opportunity to combine givs. */
1705 #define GIV_SORT_CRITERION(X, Y) \
1706 if (GET_CODE ((X)->add_val) == CONST_INT \
1707 && GET_CODE ((Y)->add_val) == CONST_INT) \
1708 return INTVAL ((X)->add_val) - INTVAL ((Y)->add_val);
1710 /* For the sake of libgcc2.c, indicate target supports atexit. */