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 #define FUNCTION_BOUNDARY (TARGET_SMALLCODE ? 16 : 32)
224 /* Alignment of field after `int : 0' in a structure. */
225 #define EMPTY_FIELD_BOUNDARY 32
227 /* No data type wants to be aligned rounder than this. */
228 #define BIGGEST_ALIGNMENT (TARGET_ALIGN_DOUBLE ? 64 : 32)
230 /* The best alignment to use in cases where we have a choice. */
231 #define FASTEST_ALIGNMENT 32
233 /* Make strings word-aligned so strcpy from constants will be faster. */
234 #define CONSTANT_ALIGNMENT(EXP, ALIGN) \
235 ((TREE_CODE (EXP) == STRING_CST \
236 && (ALIGN) < FASTEST_ALIGNMENT) \
237 ? FASTEST_ALIGNMENT : (ALIGN))
239 /* Make arrays of chars word-aligned for the same reasons. */
240 #define DATA_ALIGNMENT(TYPE, ALIGN) \
241 (TREE_CODE (TYPE) == ARRAY_TYPE \
242 && TYPE_MODE (TREE_TYPE (TYPE)) == QImode \
243 && (ALIGN) < FASTEST_ALIGNMENT ? FASTEST_ALIGNMENT : (ALIGN))
245 /* Number of bits which any structure or union's size must be a
246 multiple of. Each structure or union's size is rounded up to a
248 #define STRUCTURE_SIZE_BOUNDARY (TARGET_PADSTRUCT ? 32 : 8)
250 /* Set this nonzero if move instructions will actually fail to work
251 when given unaligned data. */
252 #define STRICT_ALIGNMENT 1
254 /* Standard register usage. */
256 /* Register allocation for the Hitachi calling convention:
262 r14 frame pointer/call saved
264 ap arg pointer (doesn't really exist, always eliminated)
265 pr subroutine return address
267 mach multiply/accumulate result, high part
268 macl multiply/accumulate result, low part.
269 fpul fp/int communication register
270 rap return address pointer register
272 fr1..fr3 scratch floating point registers
274 fr12..fr15 call saved floating point registers */
276 /* Number of actual hardware registers.
277 The hardware registers are assigned numbers for the compiler
278 from 0 to just below FIRST_PSEUDO_REGISTER.
279 All registers that the compiler knows about must be given numbers,
280 even those that are not normally considered general registers. */
288 #define SPECIAL_REG(REGNO) ((REGNO) >= 18 && (REGNO) <= 21)
291 #define FIRST_FP_REG 24
292 #define LAST_FP_REG 39
294 #define FIRST_PSEUDO_REGISTER 40
296 /* 1 for registers that have pervasive standard uses
297 and are not available for the register allocator.
299 Mach register is fixed 'cause it's only 10 bits wide for SH1.
300 It is 32 bits wide for SH2. */
302 #define FIXED_REGISTERS \
315 /* 1 for registers not available across function calls.
316 These must include the FIXED_REGISTERS and also any
317 registers that can be used without being saved.
318 The latter must include the registers where values are returned
319 and the register where structure-value addresses are passed.
320 Aside from that, you can include as many other registers as you like. */
322 #define CALL_USED_REGISTERS \
335 /* Return number of consecutive hard regs needed starting at reg REGNO
336 to hold something of mode MODE.
337 This is ordinarily the length in words of a value of mode MODE
338 but can be less for certain modes in special long registers.
340 On the SH regs are UNITS_PER_WORD bits wide. */
342 #define HARD_REGNO_NREGS(REGNO, MODE) \
343 (((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD))
345 /* Value is 1 if hard register REGNO can hold a value of machine-mode MODE.
346 We can allow any mode in any general register. The special registers
347 only allow SImode. Don't allow any mode in the PR. */
349 #define HARD_REGNO_MODE_OK(REGNO, MODE) \
350 (SPECIAL_REG (REGNO) ? (MODE) == SImode \
351 : (REGNO) == FPUL_REG ? (MODE) == SImode || (MODE) == SFmode \
352 : (REGNO) >= FIRST_FP_REG && (REGNO) <= LAST_FP_REG ? (MODE) == SFmode \
353 : (REGNO) == PR_REG ? 0 \
356 /* Value is 1 if it is a good idea to tie two pseudo registers
357 when one has mode MODE1 and one has mode MODE2.
358 If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2,
359 for any hard reg, then this must be 0 for correct output. */
361 #define MODES_TIEABLE_P(MODE1, MODE2) \
362 ((MODE1) == (MODE2) || GET_MODE_CLASS (MODE1) == GET_MODE_CLASS (MODE2))
364 /* Specify the registers used for certain standard purposes.
365 The values of these macros are register numbers. */
367 /* Define this if the program counter is overloaded on a register. */
368 /* #define PC_REGNUM 15*/
370 /* Register to use for pushing function arguments. */
371 #define STACK_POINTER_REGNUM 15
373 /* Base register for access to local variables of the function. */
374 #define FRAME_POINTER_REGNUM 14
376 /* Fake register that holds the address on the stack of the
377 current function's return address. */
378 #define RETURN_ADDRESS_POINTER_REGNUM 23
380 /* Value should be nonzero if functions must have frame pointers.
381 Zero means the frame pointer need not be set up (and parms may be accessed
382 via the stack pointer) in functions that seem suitable. */
384 #define FRAME_POINTER_REQUIRED 0
386 /* Definitions for register eliminations.
388 We have two registers that can be eliminated on the SH. First, the
389 frame pointer register can often be eliminated in favor of the stack
390 pointer register. Secondly, the argument pointer register can always be
391 eliminated; it is replaced with either the stack or frame pointer. */
393 /* This is an array of structures. Each structure initializes one pair
394 of eliminable registers. The "from" register number is given first,
395 followed by "to". Eliminations of the same "from" register are listed
396 in order of preference. */
398 #define ELIMINABLE_REGS \
399 {{ FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
400 { RETURN_ADDRESS_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
401 { RETURN_ADDRESS_POINTER_REGNUM, FRAME_POINTER_REGNUM}, \
402 { ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
403 { ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM},}
405 /* Given FROM and TO register numbers, say whether this elimination
407 #define CAN_ELIMINATE(FROM, TO) \
408 (!((FROM) == FRAME_POINTER_REGNUM && FRAME_POINTER_REQUIRED))
410 /* Define the offset between two registers, one to be eliminated, and the other
411 its replacement, at the start of a routine. */
413 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
414 OFFSET = initial_elimination_offset (FROM, TO)
416 /* Base register for access to arguments of the function. */
417 #define ARG_POINTER_REGNUM 16
419 /* Register in which the static-chain is passed to a function. */
420 #define STATIC_CHAIN_REGNUM 13
422 /* The register in which a struct value address is passed. */
424 #define STRUCT_VALUE_REGNUM 2
426 /* If the structure value address is not passed in a register, define
427 `STRUCT_VALUE' as an expression returning an RTX for the place
428 where the address is passed. If it returns 0, the address is
429 passed as an "invisible" first argument. */
431 /*#define STRUCT_VALUE ((rtx)0)*/
433 /* Don't default to pcc-struct-return, because we have already specified
434 exactly how to return structures in the RETURN_IN_MEMORY macro. */
436 #define DEFAULT_PCC_STRUCT_RETURN 0
438 /* Define the classes of registers for register constraints in the
439 machine description. Also define ranges of constants.
441 One of the classes must always be named ALL_REGS and include all hard regs.
442 If there is more than one class, another class must be named NO_REGS
443 and contain no registers.
445 The name GENERAL_REGS must be the name of a class (or an alias for
446 another name such as ALL_REGS). This is the class of registers
447 that is allowed by "g" or "r" in a register constraint.
448 Also, registers outside this class are allocated only when
449 instructions express preferences for them.
451 The classes must be numbered in nondecreasing order; that is,
452 a larger-numbered class must never be contained completely
453 in a smaller-numbered class.
455 For any two classes, it is very desirable that there be another
456 class that represents their union. */
458 /* The SH has two sorts of general registers, R0 and the rest. R0 can
459 be used as the destination of some of the arithmetic ops. There are
460 also some special purpose registers; the T bit register, the
461 Procedure Return Register and the Multiply Accumulate Registers. */
479 #define N_REG_CLASSES (int) LIM_REG_CLASSES
481 /* Give names of register classes as strings for dump file. */
482 #define REG_CLASS_NAMES \
497 /* Define which registers fit in which classes.
498 This is an initializer for a vector of HARD_REG_SET
499 of length N_REG_CLASSES. */
501 #define REG_CLASS_CONTENTS \
503 { 0x00000000, 0x00000000 }, /* NO_REGS */ \
504 { 0x00000001, 0x00000000 }, /* R0_REGS */ \
505 { 0x00020000, 0x00000000 }, /* PR_REGS */ \
506 { 0x00040000, 0x00000000 }, /* T_REGS */ \
507 { 0x00300000, 0x00000000 }, /* MAC_REGS */ \
508 { 0x0001FFFF, 0x00000000 }, /* GENERAL_REGS */ \
509 { 0x00400000, 0x00000000 }, /* FPUL_REGS */ \
510 { 0x01000000, 0x00000000 }, /* FP0_REGS */ \
511 { 0xFF000000, 0x000000FF }, /* FP_REGS */ \
512 { 0xFF01FFFF, 0x000000FF }, /* GENERAL_FP_REGS */ \
513 { 0xFF7FFFFF, 0x000000FF }, /* ALL_REGS */ \
516 /* The same information, inverted:
517 Return the class number of the smallest class containing
518 reg number REGNO. This could be a conditional expression
519 or could index an array. */
521 extern int regno_reg_class[];
522 #define REGNO_REG_CLASS(REGNO) regno_reg_class[REGNO]
524 /* When defined, the compiler allows registers explicitly used in the
525 rtl to be used as spill registers but prevents the compiler from
526 extending the lifetime of these registers. */
528 #define SMALL_REGISTER_CLASSES
530 /* The order in which register should be allocated. */
531 #define REG_ALLOC_ORDER \
532 { 1,2,3,7,6,5,4,0,8,9,10,11,12,13,14, \
533 24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39, \
534 22,15,16,17,18,19,20,21,23 }
536 /* The class value for index registers, and the one for base regs. */
537 #define INDEX_REG_CLASS R0_REGS
538 #define BASE_REG_CLASS GENERAL_REGS
540 /* Get reg_class from a letter such as appears in the machine
542 extern enum reg_class reg_class_from_letter[];
544 #define REG_CLASS_FROM_LETTER(C) \
545 ( (C) >= 'a' && (C) <= 'z' ? reg_class_from_letter[(C)-'a'] : NO_REGS )
547 /* The letters I, J, K, L and M in a register constraint string
548 can be used to stand for particular ranges of immediate operands.
549 This macro defines what the ranges are.
550 C is the letter, and VALUE is a constant value.
551 Return 1 if VALUE is in the range specified by C.
552 I: arithmetic operand -127..128, as used in add, sub, etc
553 K: shift operand 1,2,8 or 16
554 L: logical operand 0..255, as used in and, or, etc.
558 #define CONST_OK_FOR_I(VALUE) (((int)(VALUE))>= -128 && ((int)(VALUE)) <= 127)
559 #define CONST_OK_FOR_K(VALUE) ((VALUE)==1||(VALUE)==2||(VALUE)==8||(VALUE)==16)
560 #define CONST_OK_FOR_L(VALUE) (((int)(VALUE))>= 0 && ((int)(VALUE)) <= 255)
561 #define CONST_OK_FOR_M(VALUE) ((VALUE)==1)
562 #define CONST_OK_FOR_N(VALUE) ((VALUE)==0)
563 #define CONST_OK_FOR_LETTER_P(VALUE, C) \
564 ((C) == 'I' ? CONST_OK_FOR_I (VALUE) \
565 : (C) == 'K' ? CONST_OK_FOR_K (VALUE) \
566 : (C) == 'L' ? CONST_OK_FOR_L (VALUE) \
567 : (C) == 'M' ? CONST_OK_FOR_M (VALUE) \
568 : (C) == 'N' ? CONST_OK_FOR_N (VALUE) \
571 /* Similar, but for floating constants, and defining letters G and H.
572 Here VALUE is the CONST_DOUBLE rtx itself. */
574 #define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) \
575 ((C) == 'G' ? fp_zero_operand (VALUE) \
576 : (C) == 'H' ? fp_one_operand (VALUE) \
579 /* Given an rtx X being reloaded into a reg required to be
580 in class CLASS, return the class of reg to actually use.
581 In general this is just CLASS; but on some machines
582 in some cases it is preferable to use a more restrictive class. */
584 #define PREFERRED_RELOAD_CLASS(X, CLASS) CLASS
586 /* Return the maximum number of consecutive registers
587 needed to represent mode MODE in a register of class CLASS.
589 On SH this is the size of MODE in words. */
590 #define CLASS_MAX_NREGS(CLASS, MODE) \
591 ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
593 /* Stack layout; function entry, exit and calling. */
595 /* Define the number of registers that can hold parameters.
596 These macros are used only in other macro definitions below. */
598 #define NPARM_REGS(MODE) \
599 ((TARGET_SH3E && ((MODE) == SFmode)) ? 8 : 4)
601 #define FIRST_PARM_REG 4
602 #define FIRST_RET_REG 0
604 #define FIRST_FP_PARM_REG (FIRST_FP_REG + 4)
605 #define FIRST_FP_RET_REG FIRST_FP_REG
607 /* Define this if pushing a word on the stack
608 makes the stack pointer a smaller address. */
609 #define STACK_GROWS_DOWNWARD
611 /* Define this macro if the addresses of local variable slots are at
612 negative offsets from the frame pointer.
614 The SH only has positive indexes, so grow the frame up. */
615 /* #define FRAME_GROWS_DOWNWARD */
617 /* Offset from the frame pointer to the first local variable slot to
619 #define STARTING_FRAME_OFFSET 0
621 /* If we generate an insn to push BYTES bytes,
622 this says how many the stack pointer really advances by. */
623 #define PUSH_ROUNDING(NPUSHED) (((NPUSHED) + 3) & ~3)
625 /* Offset of first parameter from the argument pointer register value. */
626 #define FIRST_PARM_OFFSET(FNDECL) 0
628 /* Value is the number of byte of arguments automatically
629 popped when returning from a subroutine call.
630 FUNDECL is the declaration node of the function (as a tree),
631 FUNTYPE is the data type of the function (as a tree),
632 or for a library call it is an identifier node for the subroutine name.
633 SIZE is the number of bytes of arguments passed on the stack.
635 On the SH, the caller does not pop any of its arguments that were passed
637 #define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE) 0
639 /* Some subroutine macros specific to this machine. */
641 #define BASE_RETURN_VALUE_REG(MODE) \
642 ((TARGET_SH3E && ((MODE) == SFmode)) \
646 #define BASE_ARG_REG(MODE) \
647 ((TARGET_SH3E && ((MODE) == SFmode)) \
648 ? FIRST_FP_PARM_REG \
651 /* Define how to find the value returned by a function.
652 VALTYPE is the data type of the value (as a tree).
653 If the precise function being called is known, FUNC is its FUNCTION_DECL;
654 otherwise, FUNC is 0. */
656 #define FUNCTION_VALUE(VALTYPE, FUNC) \
657 LIBCALL_VALUE (TYPE_MODE (VALTYPE))
659 /* Define how to find the value returned by a library function
660 assuming the value has mode MODE. */
661 #define LIBCALL_VALUE(MODE) \
662 gen_rtx (REG, MODE, BASE_RETURN_VALUE_REG (MODE));
664 /* 1 if N is a possible register number for a function value. */
665 #define FUNCTION_VALUE_REGNO_P(REGNO) \
666 ((REGNO) == FIRST_RET_REG || (TARGET_SH3E && (REGNO) == FIRST_FP_RET_REG))
668 /* 1 if N is a possible register number for function argument passing. */
669 #define FUNCTION_ARG_REGNO_P(REGNO) \
670 (((REGNO) >= FIRST_PARM_REG && (REGNO) < (FIRST_PARM_REG + 4)) \
672 && (REGNO) >= FIRST_FP_PARM_REG && (REGNO) < (FIRST_FP_PARM_REG + 8)))
674 /* Define a data type for recording info about an argument list
675 during the scan of that argument list. This data type should
676 hold all necessary information about the function itself
677 and about the args processed so far, enough to enable macros
678 such as FUNCTION_ARG to determine where the next arg should go.
680 On SH, this is a single integer, which is a number of words
681 of arguments scanned so far (including the invisible argument,
682 if any, which holds the structure-value-address).
683 Thus NARGREGS or more means all following args should go on the stack. */
685 enum sh_arg_class { SH_ARG_INT = 0, SH_ARG_FLOAT = 1 };
690 #define CUMULATIVE_ARGS struct sh_args
692 #define GET_SH_ARG_CLASS(MODE) \
693 ((TARGET_SH3E && ((MODE) == SFmode)) ? SH_ARG_FLOAT : SH_ARG_INT)
695 #define ROUND_ADVANCE(SIZE) \
696 ((SIZE + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
698 /* Round a register number up to a proper boundary for an arg of mode
701 The SH doesn't care about double alignment, so we only
702 round doubles to even regs when asked to explicitly. */
704 #define ROUND_REG(CUM, MODE) \
705 ((TARGET_ALIGN_DOUBLE \
706 && GET_MODE_UNIT_SIZE ((MODE)) > UNITS_PER_WORD) \
707 ? ((CUM).arg_count[(int) GET_SH_ARG_CLASS (MODE)] \
708 + ((CUM).arg_count[(int) GET_SH_ARG_CLASS (MODE)] & 1)) \
709 : (CUM).arg_count[(int) GET_SH_ARG_CLASS (MODE)])
711 /* Initialize a variable CUM of type CUMULATIVE_ARGS
712 for a call to a function whose data type is FNTYPE.
713 For a library call, FNTYPE is 0.
715 On SH, the offset always starts at 0: the first parm reg is always
718 #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, INDIRECT) \
720 (CUM).arg_count[(int) SH_ARG_INT] = 0; \
721 (CUM).arg_count[(int) SH_ARG_FLOAT] = 0; \
724 /* Update the data in CUM to advance over an argument
725 of mode MODE and data type TYPE.
726 (TYPE is null for libcalls where that information may not be
729 #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \
730 ((CUM).arg_count[(int) GET_SH_ARG_CLASS (MODE)] = \
731 (ROUND_REG ((CUM), (MODE)) \
732 + ((MODE) != BLKmode \
733 ? ROUND_ADVANCE (GET_MODE_SIZE (MODE)) \
734 : ROUND_ADVANCE (int_size_in_bytes (TYPE)))))
736 /* Return boolean indicating arg of mode MODE will be passed in a reg.
737 This macro is only used in this file. */
739 #define PASS_IN_REG_P(CUM, MODE, TYPE) \
740 (ROUND_REG ((CUM), (MODE)) < NPARM_REGS (MODE) \
741 && ((TYPE) == 0 || ! TREE_ADDRESSABLE ((tree)(TYPE))) \
742 && (! TARGET_SH3E || (ROUND_REG((CUM), (MODE)) + (GET_MODE_SIZE(MODE)/4) <= NPARM_REGS (MODE))))
744 /* Define where to put the arguments to a function.
745 Value is zero to push the argument on the stack,
746 or a hard register in which to store the argument.
748 MODE is the argument's machine mode.
749 TYPE is the data type of the argument (as a tree).
750 This is null for libcalls where that information may
752 CUM is a variable of type CUMULATIVE_ARGS which gives info about
753 the preceding args and about the function being called.
754 NAMED is nonzero if this argument is a named parameter
755 (otherwise it is an extra parameter matching an ellipsis).
757 On SH the first args are normally in registers
758 and the rest are pushed. Any arg that starts within the first
759 NPARM_REGS words is at least partially passed in a register unless
760 its data type forbids. */
762 #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
763 ((PASS_IN_REG_P ((CUM), (MODE), (TYPE)) \
764 && (NAMED || TARGET_SH3E)) \
765 ? gen_rtx (REG, (MODE), \
766 (BASE_ARG_REG (MODE) + ROUND_REG ((CUM), (MODE)))) \
769 /* For an arg passed partly in registers and partly in memory,
770 this is the number of registers used.
771 For args passed entirely in registers or entirely in memory, zero.
773 We sometimes split args. */
775 #define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) \
776 ((PASS_IN_REG_P ((CUM), (MODE), (TYPE)) \
777 && (NAMED || TARGET_SH3E) \
778 && (ROUND_REG ((CUM), (MODE)) \
780 ? ROUND_ADVANCE (GET_MODE_SIZE (MODE)) \
781 : ROUND_ADVANCE (int_size_in_bytes (TYPE))) \
782 - NPARM_REGS (MODE) > 0)) \
783 ? NPARM_REGS (MODE) - ROUND_REG ((CUM), (MODE)) \
786 extern int current_function_anonymous_args;
788 /* Perform any needed actions needed for a function that is receiving a
789 variable number of arguments. */
791 #define SETUP_INCOMING_VARARGS(ASF, MODE, TYPE, PAS, ST) \
792 current_function_anonymous_args = 1;
794 /* Call the function profiler with a given profile label.
795 We use two .aligns, so as to make sure that both the .long is aligned
796 on a 4 byte boundary, and that the .long is a fixed distance (2 bytes)
797 from the trapa instruction. */
799 #define FUNCTION_PROFILER(STREAM,LABELNO) \
801 fprintf(STREAM, " .align 2\n"); \
802 fprintf(STREAM, " trapa #33\n"); \
803 fprintf(STREAM, " .align 2\n"); \
804 fprintf(STREAM, " .long LP%d\n", (LABELNO)); \
807 /* Define this macro if the code for function profiling should come
808 before the function prologue. Normally, the profiling code comes
811 #define PROFILE_BEFORE_PROLOGUE
813 /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
814 the stack pointer does not matter. The value is tested only in
815 functions that have frame pointers.
816 No definition is equivalent to always zero. */
818 #define EXIT_IGNORE_STACK 1
820 /* Generate the assembly code for function exit
821 Just dump out any accumulated constant table. */
823 #define FUNCTION_EPILOGUE(STREAM, SIZE) function_epilogue (STREAM, SIZE)
825 /* Output assembler code for a block containing the constant parts
826 of a trampoline, leaving space for the variable parts.
828 On the SH, the trampoline looks like
829 1 0000 D301 mov.l l1,r3
830 2 0002 DD02 mov.l l2,r13
833 5 0008 00000000 l1: .long function
834 6 000c 00000000 l2: .long area */
835 #define TRAMPOLINE_TEMPLATE(FILE) \
837 fprintf ((FILE), " .word 0xd301\n"); \
838 fprintf ((FILE), " .word 0xdd02\n"); \
839 fprintf ((FILE), " .word 0x4d2b\n"); \
840 fprintf ((FILE), " .word 0x200b\n"); \
841 fprintf ((FILE), " .long 0\n"); \
842 fprintf ((FILE), " .long 0\n"); \
845 /* Length in units of the trampoline for entering a nested function. */
846 #define TRAMPOLINE_SIZE 16
848 /* Alignment required for a trampoline in units. */
849 #define TRAMPOLINE_ALIGN 4
851 /* Emit RTL insns to initialize the variable parts of a trampoline.
852 FNADDR is an RTX for the address of the function's pure code.
853 CXT is an RTX for the static chain value for the function. */
855 #define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) \
857 emit_move_insn (gen_rtx (MEM, SImode, plus_constant ((TRAMP), 8)), \
859 emit_move_insn (gen_rtx (MEM, SImode, plus_constant ((TRAMP), 12)), \
863 /* A C expression whose value is RTL representing the value of the return
864 address for the frame COUNT steps up from the current frame.
865 FRAMEADDR is already the frame pointer of the COUNT frame, so we
868 #define RETURN_ADDR_RTX(COUNT, FRAME) \
870 ? gen_rtx (MEM, Pmode, gen_rtx (REG, Pmode, RETURN_ADDRESS_POINTER_REGNUM)) \
873 /* Generate necessary RTL for __builtin_saveregs().
874 ARGLIST is the argument list; see expr.c. */
875 extern struct rtx_def *sh_builtin_saveregs ();
876 #define EXPAND_BUILTIN_SAVEREGS(ARGLIST) sh_builtin_saveregs (ARGLIST)
878 /* Addressing modes, and classification of registers for them. */
879 #define HAVE_POST_INCREMENT 1
880 /*#define HAVE_PRE_INCREMENT 1*/
881 /*#define HAVE_POST_DECREMENT 1*/
882 #define HAVE_PRE_DECREMENT 1
884 /* Macros to check register numbers against specific register classes. */
886 /* These assume that REGNO is a hard or pseudo reg number.
887 They give nonzero only if REGNO is a hard reg of the suitable class
888 or a pseudo reg currently allocated to a suitable hard reg.
889 Since they use reg_renumber, they are safe only once reg_renumber
890 has been allocated, which happens in local-alloc.c. */
892 #define REGNO_OK_FOR_BASE_P(REGNO) \
893 ((REGNO) < PR_REG || (unsigned) reg_renumber[(REGNO)] < PR_REG)
894 #define REGNO_OK_FOR_INDEX_P(REGNO) \
895 ((REGNO) == 0 || (unsigned) reg_renumber[(REGNO)] == 0)
897 /* Maximum number of registers that can appear in a valid memory
900 #define MAX_REGS_PER_ADDRESS 2
902 /* Recognize any constant value that is a valid address. */
904 #define CONSTANT_ADDRESS_P(X) (GET_CODE (X) == LABEL_REF)
906 /* Nonzero if the constant value X is a legitimate general operand. */
908 /* ??? Should modify this to accept CONST_DOUBLE, and then modify the
909 constant pool table code to fix loads of CONST_DOUBLEs. If that doesn't
910 work well, then we can at least handle simple CONST_DOUBLEs here
913 #define LEGITIMATE_CONSTANT_P(X) \
914 (GET_CODE (X) != CONST_DOUBLE \
915 || (TARGET_SH3E && (fp_zero_operand (X) || fp_one_operand (X))))
917 /* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
918 and check its validity for a certain class.
919 We have two alternate definitions for each of them.
920 The usual definition accepts all pseudo regs; the other rejects
921 them unless they have been allocated suitable hard regs.
922 The symbol REG_OK_STRICT causes the latter definition to be used. */
924 #ifndef REG_OK_STRICT
926 /* Nonzero if X is a hard reg that can be used as a base reg
927 or if it is a pseudo reg. */
928 #define REG_OK_FOR_BASE_P(X) \
929 (REGNO (X) <= 16 || REGNO (X) >= FIRST_PSEUDO_REGISTER)
931 /* Nonzero if X is a hard reg that can be used as an index
932 or if it is a pseudo reg. */
933 #define REG_OK_FOR_INDEX_P(X) \
934 (REGNO (X) == 0 || REGNO (X) >= FIRST_PSEUDO_REGISTER)
936 /* Nonzero if X/OFFSET is a hard reg that can be used as an index
937 or if X is a pseudo reg. */
938 #define SUBREG_OK_FOR_INDEX_P(X, OFFSET) \
939 ((REGNO (X) == 0 && OFFSET == 0) || REGNO (X) >= FIRST_PSEUDO_REGISTER)
943 /* Nonzero if X is a hard reg that can be used as a base reg. */
944 #define REG_OK_FOR_BASE_P(X) \
945 REGNO_OK_FOR_BASE_P (REGNO (X))
947 /* Nonzero if X is a hard reg that can be used as an index. */
948 #define REG_OK_FOR_INDEX_P(X) \
949 REGNO_OK_FOR_INDEX_P (REGNO (X))
951 /* Nonzero if X/OFFSET is a hard reg that can be used as an index. */
952 #define SUBREG_OK_FOR_INDEX_P(X, OFFSET) \
953 (REGNO_OK_FOR_INDEX_P (REGNO (X)) && OFFSET == 0)
957 /* The 'Q' constraint is a pc relative load operand. */
958 #define EXTRA_CONSTRAINT_Q(OP) \
959 (GET_CODE (OP) == MEM && \
960 ((GET_CODE (XEXP (OP, 0)) == LABEL_REF) \
961 || (GET_CODE (XEXP (OP, 0)) == CONST \
962 && GET_CODE (XEXP (XEXP (OP, 0), 0)) == PLUS \
963 && GET_CODE (XEXP (XEXP (XEXP (OP, 0), 0), 0)) == LABEL_REF \
964 && GET_CODE (XEXP (XEXP (XEXP (OP, 0), 0), 1)) == CONST_INT)))
966 #define EXTRA_CONSTRAINT(OP, C) \
967 ((C) == 'Q' ? EXTRA_CONSTRAINT_Q (OP) \
970 /* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression
971 that is a valid memory address for an instruction.
972 The MODE argument is the machine mode for the MEM expression
973 that wants to use this address.
975 The other macros defined here are used only in GO_IF_LEGITIMATE_ADDRESS. */
977 #define MODE_DISP_OK_4(X,MODE) \
978 (GET_MODE_SIZE (MODE) == 4 && (unsigned) INTVAL (X) < 64 \
979 && ! (INTVAL (X) & 3) && ! (TARGET_SH3E && MODE == SFmode))
980 #define MODE_DISP_OK_8(X,MODE) ((GET_MODE_SIZE(MODE)==8) && ((unsigned)INTVAL(X)<60) && (!(INTVAL(X) &3)))
982 #define BASE_REGISTER_RTX_P(X) \
983 ((GET_CODE (X) == REG && REG_OK_FOR_BASE_P (X)) \
984 || (GET_CODE (X) == SUBREG \
985 && GET_CODE (SUBREG_REG (X)) == REG \
986 && REG_OK_FOR_BASE_P (SUBREG_REG (X))))
988 /* Since this must be r0, which is a single register class, we must check
989 SUBREGs more carefully, to be sure that we don't accept one that extends
990 outside the class. */
991 #define INDEX_REGISTER_RTX_P(X) \
992 ((GET_CODE (X) == REG && REG_OK_FOR_INDEX_P (X)) \
993 || (GET_CODE (X) == SUBREG \
994 && GET_CODE (SUBREG_REG (X)) == REG \
995 && SUBREG_OK_FOR_INDEX_P (SUBREG_REG (X), SUBREG_WORD (X))))
997 /* Jump to LABEL if X is a valid address RTX. This must also take
998 REG_OK_STRICT into account when deciding about valid registers, but it uses
999 the above macros so we are in luck.
1007 /* ??? The SH3e does not have the REG+disp addressing mode when loading values
1008 into the FRx registers. We implement this by setting the maximum offset
1009 to zero when the value is SFmode. This also restricts loading of SFmode
1010 values into the integer registers, but that can't be helped. */
1012 /* The SH allows a displacement in a QI or HI amode, but only when the
1013 other operand is R0. GCC doesn't handle this very well, so we forgo
1016 A legitimate index for a QI or HI is 0, SI can be any number 0..63,
1017 DI can be any number 0..60. */
1019 #define GO_IF_LEGITIMATE_INDEX(MODE, OP, LABEL) \
1021 if (GET_CODE (OP) == CONST_INT) \
1023 if (MODE_DISP_OK_4 (OP, MODE)) goto LABEL; \
1024 if (MODE_DISP_OK_8 (OP, MODE)) goto LABEL; \
1028 #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, LABEL) \
1030 if (BASE_REGISTER_RTX_P (X)) \
1032 else if ((GET_CODE (X) == POST_INC || GET_CODE (X) == PRE_DEC) \
1033 && BASE_REGISTER_RTX_P (XEXP (X, 0))) \
1035 else if (GET_CODE (X) == PLUS) \
1037 rtx xop0 = XEXP (X, 0); \
1038 rtx xop1 = XEXP (X, 1); \
1039 if (GET_MODE_SIZE (MODE) <= 8 && BASE_REGISTER_RTX_P (xop0)) \
1040 GO_IF_LEGITIMATE_INDEX (MODE, xop1, LABEL); \
1041 if (GET_MODE_SIZE (MODE) <= 4) \
1043 if (BASE_REGISTER_RTX_P (xop1) && INDEX_REGISTER_RTX_P (xop0))\
1045 if (INDEX_REGISTER_RTX_P (xop1) && BASE_REGISTER_RTX_P (xop0))\
1051 /* Try machine-dependent ways of modifying an illegitimate address
1052 to be legitimate. If we find one, return the new, valid address.
1053 This macro is used in only one place: `memory_address' in explow.c.
1055 OLDX is the address as it was before break_out_memory_refs was called.
1056 In some cases it is useful to look at this to decide what needs to be done.
1058 MODE and WIN are passed so that this macro can use
1059 GO_IF_LEGITIMATE_ADDRESS.
1061 It is always safe for this macro to do nothing. It exists to recognize
1062 opportunities to optimize the output.
1064 For the SH, if X is almost suitable for indexing, but the offset is
1065 out of range, convert it into a normal form so that cse has a chance
1066 of reducing the number of address registers used. */
1068 #define LEGITIMIZE_ADDRESS(X,OLDX,MODE,WIN) \
1070 if (GET_CODE (X) == PLUS \
1071 && (GET_MODE_SIZE (MODE) == 4 \
1072 || GET_MODE_SIZE (MODE) == 8) \
1073 && GET_CODE (XEXP (X, 1)) == CONST_INT \
1074 && BASE_REGISTER_RTX_P (XEXP (X, 0)) \
1075 && ! (TARGET_SH3E && MODE == SFmode)) \
1077 rtx index_rtx = XEXP (X, 1); \
1078 HOST_WIDE_INT offset = INTVAL (index_rtx), offset_base; \
1081 GO_IF_LEGITIMATE_INDEX (MODE, index_rtx, WIN); \
1082 /* On rare occasions, we might get an unaligned pointer \
1083 that is indexed in a way to give an aligned address. \
1084 Therefore, keep the lower two bits in offset_base. */ \
1085 /* Instead of offset_base 128..131 use 124..127, so that \
1086 simple add suffices. */ \
1089 offset_base = ((offset + 4) & ~60) - 4; \
1092 offset_base = offset & ~60; \
1093 /* Sometimes the normal form does not suit DImode. We \
1094 could avoid that by using smaller ranges, but that \
1095 would give less optimized code when SImode is \
1097 if (GET_MODE_SIZE (MODE) + offset - offset_base <= 64) \
1099 sum = expand_binop (Pmode, add_optab, XEXP (X, 0), \
1100 GEN_INT (offset_base), NULL_RTX, 0, \
1103 (X) = gen_rtx (PLUS, Pmode, sum, GEN_INT (offset - offset_base)); \
1109 /* Go to LABEL if ADDR (a legitimate address expression)
1110 has an effect that depends on the machine mode it is used for. */
1111 #define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR,LABEL) \
1113 if (GET_CODE(ADDR) == PRE_DEC || GET_CODE(ADDR) == POST_INC) \
1117 /* Specify the machine mode that this machine uses
1118 for the index in the tablejump instruction. */
1119 #define CASE_VECTOR_MODE (TARGET_BIGTABLE ? SImode : HImode)
1121 /* Define this if the tablejump instruction expects the table
1122 to contain offsets from the address of the table.
1123 Do not define this if the table should contain absolute addresses. */
1124 #define CASE_VECTOR_PC_RELATIVE
1126 /* Specify the tree operation to be used to convert reals to integers. */
1127 #define IMPLICIT_FIX_EXPR FIX_ROUND_EXPR
1129 /* This is the kind of divide that is easiest to do in the general case. */
1130 #define EASY_DIV_EXPR TRUNC_DIV_EXPR
1132 /* Since the SH3e has only `float' support, it is desirable to make all
1133 floating point types equivalent to `float'. */
1134 #define DOUBLE_TYPE_SIZE (TARGET_SH3E ? 32 : 64)
1136 /* 'char' is signed by default. */
1137 #define DEFAULT_SIGNED_CHAR 1
1139 /* The type of size_t unsigned int. */
1140 #define SIZE_TYPE "unsigned int"
1142 #define WCHAR_TYPE "short unsigned int"
1143 #define WCHAR_TYPE_SIZE 16
1145 /* Don't cse the address of the function being compiled. */
1146 /*#define NO_RECURSIVE_FUNCTION_CSE 1*/
1148 /* Max number of bytes we can move from memory to memory
1149 in one reasonably fast instruction. */
1152 /* Define if operations between registers always perform the operation
1153 on the full register even if a narrower mode is specified. */
1154 #define WORD_REGISTER_OPERATIONS
1156 /* Define if loading in MODE, an integral mode narrower than BITS_PER_WORD
1157 will either zero-extend or sign-extend. The value of this macro should
1158 be the code that says which one of the two operations is implicitly
1159 done, NIL if none. */
1160 #define LOAD_EXTEND_OP(MODE) SIGN_EXTEND
1162 /* Define if loading short immediate values into registers sign extends. */
1163 #define SHORT_IMMEDIATES_SIGN_EXTEND
1165 /* Define this if zero-extension is slow (more than one real instruction).
1166 On the SH, it's only one instruction. */
1167 /* #define SLOW_ZERO_EXTEND */
1169 /* Nonzero if access to memory by bytes is slow and undesirable. */
1170 #define SLOW_BYTE_ACCESS 0
1172 /* We assume that the store-condition-codes instructions store 0 for false
1173 and some other value for true. This is the value stored for true. */
1175 #define STORE_FLAG_VALUE 1
1177 /* Immediate shift counts are truncated by the output routines (or was it
1178 the assembler?). Shift counts in a register are truncated by SH. Note
1179 that the native compiler puts too large (> 32) immediate shift counts
1180 into a register and shifts by the register, letting the SH decide what
1181 to do instead of doing that itself. */
1182 /* ??? This is defined, but the library routines in lib1funcs.asm do not
1183 truncate the shift count. This may result in incorrect results for
1184 unusual cases. Truncating the shift counts in the library routines would
1185 make them faster. However, the SH3 has hardware shifts that do not
1186 truncate, so it appears that we need to leave this undefined for correct
1187 SH3 code. We can still using truncation in the library routines though to
1188 make them faster. */
1189 #define SHIFT_COUNT_TRUNCATED 1
1191 /* All integers have the same format so truncation is easy. */
1192 #define TRULY_NOOP_TRUNCATION(OUTPREC,INPREC) 1
1194 /* Define this if addresses of constant functions
1195 shouldn't be put through pseudo regs where they can be cse'd.
1196 Desirable on machines where ordinary constants are expensive
1197 but a CALL with constant address is cheap. */
1198 /*#define NO_FUNCTION_CSE 1*/
1200 /* Chars and shorts should be passed as ints. */
1201 #define PROMOTE_PROTOTYPES 1
1203 /* The machine modes of pointers and functions. */
1204 #define Pmode SImode
1205 #define FUNCTION_MODE Pmode
1207 /* The relative costs of various types of constants. Note that cse.c defines
1208 REG = 1, SUBREG = 2, any node = (2 + sum of subnodes). */
1210 #define CONST_COSTS(RTX, CODE, OUTER_CODE) \
1212 if (INTVAL (RTX) == 0) \
1214 else if (CONST_OK_FOR_I (INTVAL (RTX))) \
1216 else if ((OUTER_CODE == AND || OUTER_CODE == IOR || OUTER_CODE == XOR) \
1217 && CONST_OK_FOR_L (INTVAL (RTX))) \
1225 case CONST_DOUBLE: \
1228 #define RTX_COSTS(X, CODE, OUTER_CODE) \
1230 return COSTS_N_INSNS (andcosts (X)); \
1232 return COSTS_N_INSNS (multcosts (X)); \
1236 return COSTS_N_INSNS (shiftcosts (X)) ; \
1241 return COSTS_N_INSNS (20); \
1246 /* The multiply insn on the SH1 and the divide insns on the SH1 and SH2
1247 are actually function calls with some special constraints on arguments
1250 These macros tell reorg that the references to arguments and
1251 register clobbers for insns of type sfunc do not appear to happen
1252 until after the millicode call. This allows reorg to put insns
1253 which set the argument registers into the delay slot of the millicode
1254 call -- thus they act more like traditional CALL_INSNs.
1256 get_attr_type will try to recognize the given insn, so make sure to
1257 filter out things it will not accept -- SEQUENCE, USE and CLOBBER insns
1260 #define INSN_SETS_ARE_DELAYED(X) \
1261 ((GET_CODE (X) == INSN \
1262 && GET_CODE (PATTERN (X)) != SEQUENCE \
1263 && GET_CODE (PATTERN (X)) != USE \
1264 && GET_CODE (PATTERN (X)) != CLOBBER \
1265 && get_attr_type (X) == TYPE_SFUNC))
1267 #define INSN_REFERENCES_ARE_DELAYED(X) \
1268 ((GET_CODE (X) == INSN \
1269 && GET_CODE (PATTERN (X)) != SEQUENCE \
1270 && GET_CODE (PATTERN (X)) != USE \
1271 && GET_CODE (PATTERN (X)) != CLOBBER \
1272 && get_attr_type (X) == TYPE_SFUNC))
1274 /* Compute the cost of an address. For the SH, all valid addresses are
1276 /* ??? Perhaps we should make reg+reg addresses have higher cost because
1277 they add to register pressure on r0. */
1279 #define ADDRESS_COST(RTX) 1
1281 /* Compute extra cost of moving data between one register class
1284 On the SH it is hard to move into the T reg, but simple to load
1287 #define REGISTER_MOVE_COST(SRCCLASS, DSTCLASS) \
1288 (((DSTCLASS == T_REGS) || (DSTCLASS == PR_REG)) ? 10 \
1289 : ((DSTCLASS == FP_REGS && SRCCLASS == GENERAL_REGS) \
1290 || (DSTCLASS == GENERAL_REGS && SRCCLASS == FP_REGS)) ? 4 \
1293 /* ??? Perhaps make MEMORY_MOVE_COST depend on compiler option? This
1294 would be so that people would slow memory systems could generate
1295 different code that does fewer memory accesses. */
1297 /* Assembler output control. */
1299 /* A C string constant describing how to begin a comment in the target
1300 assembler language. The compiler assumes that the comment will end at
1301 the end of the line. */
1302 #define ASM_COMMENT_START "!"
1304 /* The text to go at the start of the assembler file. */
1305 #define ASM_FILE_START(STREAM) \
1306 output_file_start (STREAM)
1308 #define ASM_FILE_END(STREAM)
1310 #define ASM_APP_ON ""
1311 #define ASM_APP_OFF ""
1312 #define FILE_ASM_OP "\t.file\n"
1313 #define IDENT_ASM_OP "\t.ident\n"
1314 #define SET_ASM_OP ".set"
1316 /* How to change between sections. */
1318 #define TEXT_SECTION_ASM_OP "\t.text"
1319 #define DATA_SECTION_ASM_OP "\t.data"
1320 #define CTORS_SECTION_ASM_OP "\t.section\t.ctors\n"
1321 #define DTORS_SECTION_ASM_OP "\t.section\t.dtors\n"
1322 #define EXTRA_SECTIONS in_ctors, in_dtors
1323 #define EXTRA_SECTION_FUNCTIONS \
1327 if (in_section != in_ctors) \
1329 fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP); \
1330 in_section = in_ctors; \
1336 if (in_section != in_dtors) \
1338 fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP); \
1339 in_section = in_dtors; \
1343 /* Define this so that jump tables go in same section as the current function,
1344 which could be text or it could be a user defined section. */
1345 #define JUMP_TABLES_IN_TEXT_SECTION
1347 /* A C statement to output something to the assembler file to switch to section
1348 NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or
1349 NULL_TREE. Some target formats do not support arbitrary sections. Do not
1350 define this macro in such cases. */
1352 #define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME) \
1353 do { fprintf (FILE, ".section\t%s\n", NAME); } while (0)
1355 #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
1356 do { ctors_section(); fprintf(FILE,"\t.long\t_%s\n", NAME); } while (0)
1358 #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
1359 do { dtors_section(); fprintf(FILE,"\t.long\t_%s\n", NAME); } while (0)
1361 #undef DO_GLOBAL_CTORS_BODY
1363 #define DO_GLOBAL_CTORS_BODY \
1365 typedef (*pfunc)(); \
1366 extern pfunc __ctors[]; \
1367 extern pfunc __ctors_end[]; \
1369 for (p = __ctors_end; p > __ctors; ) \
1375 #undef DO_GLOBAL_DTORS_BODY
1376 #define DO_GLOBAL_DTORS_BODY \
1378 typedef (*pfunc)(); \
1379 extern pfunc __dtors[]; \
1380 extern pfunc __dtors_end[]; \
1382 for (p = __dtors; p < __dtors_end; p++) \
1388 #define ASM_OUTPUT_REG_PUSH(file, v) \
1389 fprintf (file, "\tmov.l r%s,-@r15\n", v);
1391 #define ASM_OUTPUT_REG_POP(file, v) \
1392 fprintf (file, "\tmov.l @r15+,r%s\n", v);
1394 /* The assembler's names for the registers. RFP need not always be used as
1395 the Real framepointer; it can also be used as a normal general register.
1396 Note that the name `fp' is horribly misleading since `fp' is in fact only
1397 the argument-and-return-context pointer. */
1398 #define REGISTER_NAMES \
1400 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
1401 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", \
1402 "ap", "pr", "t", "gbr", "mach","macl", "fpul","rap", \
1403 "fr0","fr1","fr2", "fr3", "fr4", "fr5", "fr6", "fr7", \
1404 "fr8","fr9","fr10","fr11","fr12","fr13","fr14","fr15",\
1407 /* DBX register number for a given compiler register number. */
1408 /* GDB has FPUL at 23 and FP0 at 25, so we must add one to all FP registers
1410 #define DBX_REGISTER_NUMBER(REGNO) \
1411 (((REGNO) >= 22 && (REGNO) <= 39) ? ((REGNO) + 1) : (REGNO))
1413 /* Output a label definition. */
1414 #define ASM_OUTPUT_LABEL(FILE,NAME) \
1415 do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0)
1417 /* This is how to output an assembler line
1418 that says to advance the location counter
1419 to a multiple of 2**LOG bytes. */
1421 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
1423 fprintf (FILE, "\t.align %d\n", LOG)
1425 /* Output a function label definition. */
1426 #define ASM_DECLARE_FUNCTION_NAME(STREAM,NAME,DECL) \
1427 ASM_OUTPUT_LABEL(STREAM, NAME)
1429 /* Output a globalising directive for a label. */
1430 #define ASM_GLOBALIZE_LABEL(STREAM,NAME) \
1431 (fprintf (STREAM, "\t.global\t"), \
1432 assemble_name (STREAM, NAME), \
1433 fputc ('\n',STREAM))
1435 /* The prefix to add to user-visible assembler symbols. */
1437 #define USER_LABEL_PREFIX "_"
1439 /* Make an internal label into a string. */
1440 #define ASM_GENERATE_INTERNAL_LABEL(STRING, PREFIX, NUM) \
1441 sprintf (STRING, "*%s%d", PREFIX, NUM)
1443 /* Output an internal label definition. */
1444 #define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM) \
1445 fprintf (FILE, "%s%d:\n", PREFIX, NUM)
1447 /* #define ASM_OUTPUT_CASE_END(STREAM,NUM,TABLE) */
1449 /* Construct a private name. */
1450 #define ASM_FORMAT_PRIVATE_NAME(OUTVAR,NAME,NUMBER) \
1451 ((OUTVAR) = (char *) alloca (strlen (NAME) + 10), \
1452 sprintf ((OUTVAR), "%s.%d", (NAME), (NUMBER)))
1454 /* Jump tables must be 32 bit aligned, no matter the size of the element. */
1455 #define ASM_OUTPUT_CASE_LABEL(STREAM,PREFIX,NUM,TABLE) \
1456 fprintf (STREAM, "\t.align 2\n%s%d:\n", PREFIX, NUM);
1458 /* Output a relative address table. */
1460 #define ASM_OUTPUT_ADDR_DIFF_ELT(STREAM,VALUE,REL) \
1461 if (TARGET_BIGTABLE) \
1462 fprintf (STREAM, "\t.long L%d-L%d\n", VALUE,REL); \
1464 fprintf (STREAM, "\t.word L%d-L%d\n", VALUE,REL); \
1466 /* Output an absolute table element. */
1468 #define ASM_OUTPUT_ADDR_VEC_ELT(STREAM,VALUE) \
1469 if (TARGET_BIGTABLE) \
1470 fprintf (STREAM, "\t.long L%d\n", VALUE); \
1472 fprintf (STREAM, "\t.word L%d\n", VALUE); \
1474 /* Output various types of constants. */
1476 /* This is how to output an assembler line defining a `double'. */
1478 #define ASM_OUTPUT_DOUBLE(FILE,VALUE) \
1479 do { char dstr[30]; \
1480 REAL_VALUE_TO_DECIMAL ((VALUE), "%.20e", dstr); \
1481 fprintf (FILE, "\t.double %s\n", dstr); \
1484 /* This is how to output an assembler line defining a `float' constant. */
1485 #define ASM_OUTPUT_FLOAT(FILE,VALUE) \
1486 do { char dstr[30]; \
1487 REAL_VALUE_TO_DECIMAL ((VALUE), "%.20e", dstr); \
1488 fprintf (FILE, "\t.float %s\n", dstr); \
1491 #define ASM_OUTPUT_INT(STREAM, EXP) \
1492 (fprintf (STREAM, "\t.long\t"), \
1493 output_addr_const (STREAM, (EXP)), \
1494 fputc ('\n', STREAM))
1496 #define ASM_OUTPUT_SHORT(STREAM, EXP) \
1497 (fprintf (STREAM, "\t.short\t"), \
1498 output_addr_const (STREAM, (EXP)), \
1499 fputc ('\n', STREAM))
1501 #define ASM_OUTPUT_CHAR(STREAM, EXP) \
1502 (fprintf (STREAM, "\t.byte\t"), \
1503 output_addr_const (STREAM, (EXP)), \
1504 fputc ('\n', STREAM))
1506 #define ASM_OUTPUT_BYTE(STREAM, VALUE) \
1507 fprintf (STREAM, "\t.byte\t%d\n", VALUE) \
1509 /* Align loops and labels after unconditional branches to get faster
1512 #define ASM_OUTPUT_LOOP_ALIGN(FILE) \
1513 if (! TARGET_SMALLCODE) \
1514 ASM_OUTPUT_ALIGN ((FILE), 2)
1516 #define ASM_OUTPUT_ALIGN_CODE(FILE) \
1517 if (! TARGET_SMALLCODE) \
1518 ASM_OUTPUT_ALIGN ((FILE), (TARGET_SH3 || TARGET_SH3E) ? 4 : 2)
1520 /* This is how to output an assembler line
1521 that says to advance the location counter by SIZE bytes. */
1523 #define ASM_OUTPUT_SKIP(FILE,SIZE) \
1524 fprintf (FILE, "\t.space %d\n", (SIZE))
1526 /* This says how to output an assembler line
1527 to define a global common symbol. */
1529 #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED) \
1530 ( fputs ("\t.comm ", (FILE)), \
1531 assemble_name ((FILE), (NAME)), \
1532 fprintf ((FILE), ",%d\n", (SIZE)))
1534 /* This says how to output an assembler line
1535 to define a local common symbol. */
1537 #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE,ROUNDED) \
1538 ( fputs ("\t.lcomm ", (FILE)), \
1539 assemble_name ((FILE), (NAME)), \
1540 fprintf ((FILE), ",%d\n", (SIZE)))
1542 /* The assembler's parentheses characters. */
1543 #define ASM_OPEN_PAREN "("
1544 #define ASM_CLOSE_PAREN ")"
1546 /* Target characters. */
1547 #define TARGET_BELL 007
1548 #define TARGET_BS 010
1549 #define TARGET_TAB 011
1550 #define TARGET_NEWLINE 012
1551 #define TARGET_VT 013
1552 #define TARGET_FF 014
1553 #define TARGET_CR 015
1555 /* Only perform branch elimination (by making instructions conditional) if
1556 we're optimizing. Otherwise it's of no use anyway. */
1557 #define FINAL_PRESCAN_INSN(INSN, OPVEC, NOPERANDS) \
1558 final_prescan_insn (INSN, OPVEC, NOPERANDS)
1560 /* Print operand X (an rtx) in assembler syntax to file FILE.
1561 CODE is a letter or dot (`z' in `%z0') or 0 if no letter was specified.
1562 For `%' followed by punctuation, CODE is the punctuation and X is null. */
1564 #define PRINT_OPERAND(STREAM, X, CODE) print_operand (STREAM, X, CODE)
1566 /* Print a memory address as an operand to reference that memory location. */
1568 #define PRINT_OPERAND_ADDRESS(STREAM,X) print_operand_address (STREAM, X)
1570 #define PRINT_OPERAND_PUNCT_VALID_P(CHAR) \
1571 ((CHAR)=='.' || (CHAR) == '#' || (CHAR)=='@')
1573 extern struct rtx_def *sh_compare_op0;
1574 extern struct rtx_def *sh_compare_op1;
1575 extern struct rtx_def *prepare_scc_operands();
1577 /* Which processor to schedule for. The elements of the enumeration must
1578 match exactly the cpu attribute in the sh.md file. */
1580 enum processor_type {
1588 #define sh_cpu_attr ((enum attr_cpu)sh_cpu)
1589 extern enum processor_type sh_cpu;
1591 /* Declare functions defined in sh.c and used in templates. */
1593 extern char *output_branch();
1594 extern char *output_shift();
1595 extern char *output_movedouble();
1596 extern char *output_movepcrel();
1597 extern char *output_jump_label_table();
1598 extern char *output_far_jump();
1600 #define MACHINE_DEPENDENT_REORG(X) machine_dependent_reorg(X)
1602 /* Generate calls to memcpy, memcmp and memset. */
1604 #define TARGET_MEM_FUNCTIONS
1606 /* Define this macro if you want to implement any pragmas. If defined, it
1607 is a C expression to be executed when #pragma is seen. The
1608 argument FILE is the stdio input stream from which the source
1609 text can be read. CH is the first character after the #pragma. The
1610 result of the expression is the terminating character found
1611 (newline or EOF). */
1612 #define HANDLE_PRAGMA(FILE, NODE) handle_pragma (FILE, NODE)
1614 /* Set when processing a function with pragma interrupt turned on. */
1616 extern int pragma_interrupt;
1618 #define MOVE_RATIO (TARGET_SMALLCODE ? 2 : 16)
1620 /* Instructions with unfilled delay slots take up an extra two bytes for
1621 the nop in the delay slot. Instructions at the start of loops, or
1622 after unconditional branches, may take up extra room when they are
1623 aligned. ??? We would get more accurate results if we did instruction
1624 alignment based on the value of INSN_CURRENT_ADDRESS; the approach used
1625 here is too conservative. */
1627 #define ADJUST_INSN_LENGTH(X, LENGTH) \
1628 if (((GET_CODE (X) == INSN \
1629 && GET_CODE (PATTERN (X)) != SEQUENCE \
1630 && GET_CODE (PATTERN (X)) != USE \
1631 && GET_CODE (PATTERN (X)) != CLOBBER) \
1632 || GET_CODE (X) == CALL_INSN \
1633 || (GET_CODE (X) == JUMP_INSN \
1634 && GET_CODE (PATTERN (X)) != ADDR_DIFF_VEC \
1635 && GET_CODE (PATTERN (X)) != ADDR_VEC)) \
1636 && get_attr_needs_delay_slot (X) == NEEDS_DELAY_SLOT_YES) \
1638 if (! TARGET_SMALLCODE) \
1641 for (aip = PREV_INSN (X); aip; aip = PREV_INSN (aip)) \
1643 if (GET_CODE (aip) == BARRIER) \
1645 if (TARGET_SH3 || TARGET_SH3E) \
1651 else if ((GET_CODE (aip) == NOTE \
1652 && NOTE_LINE_NUMBER (aip) == NOTE_INSN_LOOP_BEG)) \
1657 else if (GET_CODE (aip) != NOTE \
1658 && GET_CODE (aip) != CODE_LABEL) \
1663 /* Enable a bug fix for the shorten_branches pass. */
1664 #define SHORTEN_WITH_ADJUST_INSN_LENGTH
1666 /* Define the codes that are matched by predicates in sh.c. */
1667 #define PREDICATE_CODES \
1668 {"arith_reg_operand", {SUBREG, REG}}, \
1669 {"arith_operand", {SUBREG, REG, CONST_INT}}, \
1670 {"arith_reg_or_0_operand", {SUBREG, REG, CONST_INT}}, \
1671 {"logical_operand", {SUBREG, REG, CONST_INT}}, \
1672 {"general_movsrc_operand", {SUBREG, REG, CONST_INT, MEM}}, \
1673 {"general_movdst_operand", {SUBREG, REG, CONST_INT, MEM}},
1675 /* Define this macro if it is advisable to hold scalars in registers
1676 in a wider mode than that declared by the program. In such cases,
1677 the value is constrained to be within the bounds of the declared
1678 type, but kept valid in the wider mode. The signedness of the
1679 extension may differ from that of the type.
1681 Leaving the unsignedp unchanged gives better code than always setting it
1682 to 0. This is despite the fact that we have only signed char and short
1683 load instructions. */
1684 #define PROMOTE_MODE(MODE, UNSIGNEDP, TYPE) \
1685 if (GET_MODE_CLASS (MODE) == MODE_INT \
1686 && GET_MODE_SIZE (MODE) < UNITS_PER_WORD) \
1689 /* Defining PROMOTE_FUNCTION_ARGS eliminates some unnecessary zero/sign
1690 extensions applied to char/short functions arguments. Defining
1691 PROMOTE_FUNCTION_RETURN does the same for function returns. */
1693 #define PROMOTE_FUNCTION_ARGS
1694 #define PROMOTE_FUNCTION_RETURN
1696 /* ??? Define ACCUMULATE_OUTGOING_ARGS? This is more efficient than pushing
1697 and poping arguments. However, we do have push/pop instructions, and
1698 rather limited offsets (4 bits) in load/store instructions, so it isn't
1699 clear if this would give better code. If implemented, should check for
1700 compatibility problems. */
1702 /* ??? Define ADJUST_COSTS? */
1704 /* Since the SH architecture lacks negative address offsets,
1705 the givs should be sorted smallest to largest so combine_givs
1706 has maximum opportunity to combine givs. */
1707 #define GIV_SORT_CRITERION(X, Y) \
1708 if (GET_CODE ((X)->add_val) == CONST_INT \
1709 && GET_CODE ((Y)->add_val) == CONST_INT) \
1710 return INTVAL ((X)->add_val) - INTVAL ((Y)->add_val);
1712 /* For the sake of libgcc2.c, indicate target supports atexit. */