* expr.c (do_tablejump): Let CASE_VECTOR_PC_RELATIVE be an
[official-gcc.git] / gcc / config / sh / sh.h
blob4a7f094a1e04565c74a82aba29b393fed7b1f18b
1 /* Definitions of target machine for GNU compiler for Hitachi Super-H.
2 Copyright (C) 1993, 1994, 1995, 1996, 1997 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)
11 any later version.
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 /* Unfortunately, insn-attrtab.c doesn't include insn-codes.h. We can't
28 include it here, because hconfig.h is also included by gencodes.c . */
29 extern int code_for_indirect_jump_scratch;
31 /* Generate SDB debugging information. */
33 #define SDB_DEBUGGING_INFO
35 /* Output DBX (stabs) debugging information if doing -gstabs. */
37 #include "dbxcoff.h"
39 #define SDB_DELIM ";"
41 #define CPP_SPEC "%{ml:-D__LITTLE_ENDIAN__} \
42 %{m1:-D__sh1__} \
43 %{m2:-D__sh2__} \
44 %{m3:-D__sh3__} \
45 %{m3e:-D__SH3E__} \
46 %{!m1:%{!m2:%{!m3:%{!m3e:-D__sh1__}}}}"
48 #define CPP_PREDEFINES "-D__sh__ -Acpu(sh) -Amachine(sh)"
50 #define ASM_SPEC "%{ml:-little} %{mrelax:-relax}"
52 #define LINK_SPEC "%{ml:-m shl} %{mrelax:-relax}"
54 /* We can not debug without a frame pointer. */
55 /* #define CAN_DEBUG_WITHOUT_FP */
57 #define CONDITIONAL_REGISTER_USAGE \
58 if (! TARGET_SH3E) \
59 { \
60 int regno; \
61 for (regno = FIRST_FP_REG; regno <= LAST_FP_REG; regno++) \
62 fixed_regs[regno] = call_used_regs[regno] = 1; \
63 fixed_regs[FPUL_REG] = call_used_regs[FPUL_REG] = 1; \
64 } \
65 /* Hitachi saves and restores mac registers on call. */ \
66 if (TARGET_HITACHI) \
67 { \
68 call_used_regs[MACH_REG] = 0; \
69 call_used_regs[MACL_REG] = 0; \
72 /* ??? Need to write documentation for all SH options and add it to the
73 invoke.texi file. */
75 /* Run-time compilation parameters selecting different hardware subsets. */
77 extern int target_flags;
78 #define ISIZE_BIT (1<<1)
79 #define DALIGN_BIT (1<<6)
80 #define SH1_BIT (1<<8)
81 #define SH2_BIT (1<<9)
82 #define SH3_BIT (1<<10)
83 #define SH3E_BIT (1<<11)
84 #define SPACE_BIT (1<<13)
85 #define BIGTABLE_BIT (1<<14)
86 #define RELAX_BIT (1<<15)
87 #define HITACHI_BIT (1<<22)
88 #define PADSTRUCT_BIT (1<<28)
89 #define LITTLE_ENDIAN_BIT (1<<29)
90 #define IEEE_BIT (1<<30)
92 /* Nonzero if we should dump out instruction size info. */
93 #define TARGET_DUMPISIZE (target_flags & ISIZE_BIT)
95 /* Nonzero to align doubles on 64 bit boundaries. */
96 #define TARGET_ALIGN_DOUBLE (target_flags & DALIGN_BIT)
98 /* Nonzero if we should generate code using type 1 insns. */
99 #define TARGET_SH1 (target_flags & SH1_BIT)
101 /* Nonzero if we should generate code using type 2 insns. */
102 #define TARGET_SH2 (target_flags & SH2_BIT)
104 /* Nonzero if we should generate code using type 3 insns. */
105 #define TARGET_SH3 (target_flags & SH3_BIT)
107 /* Nonzero if we should generate code using type 3E insns. */
108 #define TARGET_SH3E (target_flags & SH3E_BIT)
110 /* Nonzero if we respect NANs. */
111 #define TARGET_IEEE (target_flags & IEEE_BIT)
113 /* Nonzero if we should generate smaller code rather than faster code. */
114 #define TARGET_SMALLCODE (target_flags & SPACE_BIT)
116 /* Nonzero to use long jump tables. */
117 #define TARGET_BIGTABLE (target_flags & BIGTABLE_BIT)
119 /* Nonzero to generate pseudo-ops needed by the assembler and linker
120 to do function call relaxing. */
121 #define TARGET_RELAX (target_flags & RELAX_BIT)
123 /* Nonzero if using Hitachi's calling convention. */
124 #define TARGET_HITACHI (target_flags & HITACHI_BIT)
126 /* Nonzero if padding structures to a multiple of 4 bytes. This is
127 incompatible with Hitachi's compiler, and gives unusual structure layouts
128 which confuse programmers.
129 ??? This option is not useful, but is retained in case there are people
130 who are still relying on it. It may be deleted in the future. */
131 #define TARGET_PADSTRUCT (target_flags & PADSTRUCT_BIT)
133 /* Nonzero if generating code for a little endian SH. */
134 #define TARGET_LITTLE_ENDIAN (target_flags & LITTLE_ENDIAN_BIT)
136 #define TARGET_SWITCHES \
137 { {"1", SH1_BIT}, \
138 {"2", SH2_BIT}, \
139 {"3", SH3_BIT|SH2_BIT}, \
140 {"3e", SH3E_BIT|SH3_BIT|SH2_BIT}, \
141 {"b", -LITTLE_ENDIAN_BIT}, \
142 {"bigtable", BIGTABLE_BIT}, \
143 {"dalign", DALIGN_BIT}, \
144 {"hitachi", HITACHI_BIT}, \
145 {"ieee", IEEE_BIT}, \
146 {"isize", ISIZE_BIT}, \
147 {"l", LITTLE_ENDIAN_BIT}, \
148 {"no-ieee", -IEEE_BIT}, \
149 {"padstruct", PADSTRUCT_BIT}, \
150 {"relax", RELAX_BIT}, \
151 {"space", SPACE_BIT}, \
152 SUBTARGET_SWITCHES \
153 {"", TARGET_DEFAULT} \
156 /* This are meant to be redefined in the host dependent files */
157 #define SUBTARGET_SWITCHES
159 #define TARGET_DEFAULT (0)
161 #define PRESERVE_DEATH_INFO_REGNO_P(regno) (TARGET_RELAX || optimize)
163 #define ASSEMBLER_DIALECT 0 /* will allow to distinguish b[tf].s and b[tf]/s . */
164 #define OVERRIDE_OPTIONS \
165 do { \
166 sh_cpu = CPU_SH1; \
167 if (TARGET_SH2) \
168 sh_cpu = CPU_SH2; \
169 if (TARGET_SH3) \
170 sh_cpu = CPU_SH3; \
171 if (TARGET_SH3E) \
172 sh_cpu = CPU_SH3E; \
174 /* Never run scheduling before reload, since that can \
175 break global alloc, and generates slower code anyway due \
176 to the pressure on R0. */ \
177 flag_schedule_insns = 0; \
178 sh_addr_diff_vec_mode = TARGET_BIGTABLE ? SImode : HImode; \
179 } while (0)
181 /* Target machine storage layout. */
183 /* Define to use software floating point emulator for REAL_ARITHMETIC and
184 decimal <-> binary conversion. */
185 #define REAL_ARITHMETIC
187 /* Define this if most significant bit is lowest numbered
188 in instructions that operate on numbered bit-fields. */
190 #define BITS_BIG_ENDIAN 0
192 /* Define this if most significant byte of a word is the lowest numbered. */
193 #define BYTES_BIG_ENDIAN (TARGET_LITTLE_ENDIAN == 0)
195 /* Define this if most significant word of a multiword number is the lowest
196 numbered. */
197 #define WORDS_BIG_ENDIAN (TARGET_LITTLE_ENDIAN == 0)
199 /* Define this to set the endianness to use in libgcc2.c, which can
200 not depend on target_flags. */
201 #if defined(__LITTLE_ENDIAN__)
202 #define LIBGCC2_WORDS_BIG_ENDIAN 0
203 #else
204 #define LIBGCC2_WORDS_BIG_ENDIAN 1
205 #endif
207 /* Number of bits in an addressable storage unit. */
208 #define BITS_PER_UNIT 8
210 /* Width in bits of a "word", which is the contents of a machine register.
211 Note that this is not necessarily the width of data type `int';
212 if using 16-bit ints on a 68000, this would still be 32.
213 But on a machine with 16-bit registers, this would be 16. */
214 #define BITS_PER_WORD 32
215 #define MAX_BITS_PER_WORD 32
217 /* Width of a word, in units (bytes). */
218 #define UNITS_PER_WORD 4
220 /* Width in bits of a pointer.
221 See also the macro `Pmode' defined below. */
222 #define POINTER_SIZE 32
224 /* Allocation boundary (in *bits*) for storing arguments in argument list. */
225 #define PARM_BOUNDARY 32
227 /* Boundary (in *bits*) on which stack pointer should be aligned. */
228 #define STACK_BOUNDARY 32
230 /* The log (base 2) of the cache line size, in bytes. Processors prior to
231 SH3 have no actual cache, but they fetch code in chunks of 4 bytes. */
232 #define CACHE_LOG (TARGET_SH3 ? 4 : 2)
234 /* Allocation boundary (in *bits*) for the code of a function.
235 32 bit alignment is faster, because instructions are always fetched as a
236 pair from a longword boundary. */
237 #define FUNCTION_BOUNDARY (TARGET_SMALLCODE ? 16 : (1 << CACHE_LOG) * 8)
239 /* Alignment of field after `int : 0' in a structure. */
240 #define EMPTY_FIELD_BOUNDARY 32
242 /* No data type wants to be aligned rounder than this. */
243 #define BIGGEST_ALIGNMENT (TARGET_ALIGN_DOUBLE ? 64 : 32)
245 /* The best alignment to use in cases where we have a choice. */
246 #define FASTEST_ALIGNMENT 32
248 /* Make strings word-aligned so strcpy from constants will be faster. */
249 #define CONSTANT_ALIGNMENT(EXP, ALIGN) \
250 ((TREE_CODE (EXP) == STRING_CST \
251 && (ALIGN) < FASTEST_ALIGNMENT) \
252 ? FASTEST_ALIGNMENT : (ALIGN))
254 /* Make arrays of chars word-aligned for the same reasons. */
255 #define DATA_ALIGNMENT(TYPE, ALIGN) \
256 (TREE_CODE (TYPE) == ARRAY_TYPE \
257 && TYPE_MODE (TREE_TYPE (TYPE)) == QImode \
258 && (ALIGN) < FASTEST_ALIGNMENT ? FASTEST_ALIGNMENT : (ALIGN))
260 /* Number of bits which any structure or union's size must be a
261 multiple of. Each structure or union's size is rounded up to a
262 multiple of this. */
263 #define STRUCTURE_SIZE_BOUNDARY (TARGET_PADSTRUCT ? 32 : 8)
265 /* Set this nonzero if move instructions will actually fail to work
266 when given unaligned data. */
267 #define STRICT_ALIGNMENT 1
269 /* Standard register usage. */
271 /* Register allocation for the Hitachi calling convention:
273 r0 arg return
274 r1..r3 scratch
275 r4..r7 args in
276 r8..r13 call saved
277 r14 frame pointer/call saved
278 r15 stack pointer
279 ap arg pointer (doesn't really exist, always eliminated)
280 pr subroutine return address
281 t t bit
282 mach multiply/accumulate result, high part
283 macl multiply/accumulate result, low part.
284 fpul fp/int communication register
285 rap return address pointer register
286 fr0 fp arg return
287 fr1..fr3 scratch floating point registers
288 fr4..fr11 fp args in
289 fr12..fr15 call saved floating point registers */
291 /* Number of actual hardware registers.
292 The hardware registers are assigned numbers for the compiler
293 from 0 to just below FIRST_PSEUDO_REGISTER.
294 All registers that the compiler knows about must be given numbers,
295 even those that are not normally considered general registers. */
297 #define AP_REG 16
298 #define PR_REG 17
299 #define T_REG 18
300 #define GBR_REG 19
301 #define MACH_REG 20
302 #define MACL_REG 21
303 #define SPECIAL_REG(REGNO) ((REGNO) >= 18 && (REGNO) <= 21)
304 #define FPUL_REG 22
305 #define RAP_REG 23
306 #define FIRST_FP_REG 24
307 #define LAST_FP_REG 39
309 #define FIRST_PSEUDO_REGISTER 40
311 /* 1 for registers that have pervasive standard uses
312 and are not available for the register allocator.
314 Mach register is fixed 'cause it's only 10 bits wide for SH1.
315 It is 32 bits wide for SH2. */
317 #define FIXED_REGISTERS \
318 { 0, 0, 0, 0, \
319 0, 0, 0, 0, \
320 0, 0, 0, 0, \
321 0, 0, 0, 1, \
322 1, 1, 1, 1, \
323 1, 1, 0, 1, \
324 0, 0, 0, 0, \
325 0, 0, 0, 0, \
326 0, 0, 0, 0, \
327 0, 0, 0, 0, \
330 /* 1 for registers not available across function calls.
331 These must include the FIXED_REGISTERS and also any
332 registers that can be used without being saved.
333 The latter must include the registers where values are returned
334 and the register where structure-value addresses are passed.
335 Aside from that, you can include as many other registers as you like. */
337 #define CALL_USED_REGISTERS \
338 { 1, 1, 1, 1, \
339 1, 1, 1, 1, \
340 0, 0, 0, 0, \
341 0, 0, 0, 1, \
342 1, 0, 1, 1, \
343 1, 1, 1, 1, \
344 1, 1, 1, 1, \
345 1, 1, 1, 1, \
346 1, 1, 1, 1, \
347 0, 0, 0, 0, \
350 /* Return number of consecutive hard regs needed starting at reg REGNO
351 to hold something of mode MODE.
352 This is ordinarily the length in words of a value of mode MODE
353 but can be less for certain modes in special long registers.
355 On the SH regs are UNITS_PER_WORD bits wide. */
357 #define HARD_REGNO_NREGS(REGNO, MODE) \
358 (((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD))
360 /* Value is 1 if hard register REGNO can hold a value of machine-mode MODE.
361 We can allow any mode in any general register. The special registers
362 only allow SImode. Don't allow any mode in the PR. */
364 #define HARD_REGNO_MODE_OK(REGNO, MODE) \
365 (SPECIAL_REG (REGNO) ? (MODE) == SImode \
366 : (REGNO) == FPUL_REG ? (MODE) == SImode || (MODE) == SFmode \
367 : (REGNO) >= FIRST_FP_REG && (REGNO) <= LAST_FP_REG ? (MODE) == SFmode \
368 : (REGNO) == PR_REG ? 0 \
369 : 1)
371 /* Value is 1 if it is a good idea to tie two pseudo registers
372 when one has mode MODE1 and one has mode MODE2.
373 If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2,
374 for any hard reg, then this must be 0 for correct output. */
376 #define MODES_TIEABLE_P(MODE1, MODE2) \
377 ((MODE1) == (MODE2) || GET_MODE_CLASS (MODE1) == GET_MODE_CLASS (MODE2))
379 /* Specify the registers used for certain standard purposes.
380 The values of these macros are register numbers. */
382 /* Define this if the program counter is overloaded on a register. */
383 /* #define PC_REGNUM 15*/
385 /* Register to use for pushing function arguments. */
386 #define STACK_POINTER_REGNUM 15
388 /* Base register for access to local variables of the function. */
389 #define FRAME_POINTER_REGNUM 14
391 /* Fake register that holds the address on the stack of the
392 current function's return address. */
393 #define RETURN_ADDRESS_POINTER_REGNUM 23
395 /* Value should be nonzero if functions must have frame pointers.
396 Zero means the frame pointer need not be set up (and parms may be accessed
397 via the stack pointer) in functions that seem suitable. */
399 #define FRAME_POINTER_REQUIRED 0
401 /* Definitions for register eliminations.
403 We have three registers that can be eliminated on the SH. First, the
404 frame pointer register can often be eliminated in favor of the stack
405 pointer register. Secondly, the argument pointer register can always be
406 eliminated; it is replaced with either the stack or frame pointer.
407 Third, there is the return address pointer, which can also be replaced
408 with either the stack or the frame pointer. */
410 /* This is an array of structures. Each structure initializes one pair
411 of eliminable registers. The "from" register number is given first,
412 followed by "to". Eliminations of the same "from" register are listed
413 in order of preference. */
415 /* If you add any registers here that are not actually hard registers,
416 and that have any alternative of elimination that doesn't always
417 apply, you need to amend calc_live_regs to exclude it, because
418 reload spills all eliminable registers where it sees an
419 can_eliminate == 0 entry, thus making them 'live' .
420 If you add any hard registers that can be eliminated in different
421 ways, you have to patch reload to spill them only when all alternatives
422 of elimination fail. */
424 #define ELIMINABLE_REGS \
425 {{ FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
426 { RETURN_ADDRESS_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
427 { RETURN_ADDRESS_POINTER_REGNUM, FRAME_POINTER_REGNUM}, \
428 { ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
429 { ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM},}
431 /* Given FROM and TO register numbers, say whether this elimination
432 is allowed. */
433 #define CAN_ELIMINATE(FROM, TO) \
434 (!((FROM) == FRAME_POINTER_REGNUM && FRAME_POINTER_REQUIRED))
436 /* Define the offset between two registers, one to be eliminated, and the other
437 its replacement, at the start of a routine. */
439 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
440 OFFSET = initial_elimination_offset ((FROM), (TO))
442 /* Base register for access to arguments of the function. */
443 #define ARG_POINTER_REGNUM 16
445 /* Register in which the static-chain is passed to a function. */
446 #define STATIC_CHAIN_REGNUM 13
448 /* The register in which a struct value address is passed. */
450 #define STRUCT_VALUE_REGNUM 2
452 /* If the structure value address is not passed in a register, define
453 `STRUCT_VALUE' as an expression returning an RTX for the place
454 where the address is passed. If it returns 0, the address is
455 passed as an "invisible" first argument. */
457 /*#define STRUCT_VALUE ((rtx)0)*/
459 /* Don't default to pcc-struct-return, because we have already specified
460 exactly how to return structures in the RETURN_IN_MEMORY macro. */
462 #define DEFAULT_PCC_STRUCT_RETURN 0
464 /* Define the classes of registers for register constraints in the
465 machine description. Also define ranges of constants.
467 One of the classes must always be named ALL_REGS and include all hard regs.
468 If there is more than one class, another class must be named NO_REGS
469 and contain no registers.
471 The name GENERAL_REGS must be the name of a class (or an alias for
472 another name such as ALL_REGS). This is the class of registers
473 that is allowed by "g" or "r" in a register constraint.
474 Also, registers outside this class are allocated only when
475 instructions express preferences for them.
477 The classes must be numbered in nondecreasing order; that is,
478 a larger-numbered class must never be contained completely
479 in a smaller-numbered class.
481 For any two classes, it is very desirable that there be another
482 class that represents their union. */
484 /* The SH has two sorts of general registers, R0 and the rest. R0 can
485 be used as the destination of some of the arithmetic ops. There are
486 also some special purpose registers; the T bit register, the
487 Procedure Return Register and the Multiply Accumulate Registers. */
488 /* Place GENERAL_REGS after FPUL_REGS so that it will be preferred by
489 reg_class_subunion. We don't want to have an actual union class
490 of these, because it would only be used when both classes are calculated
491 to give the same cost, but there is only one FPUL register.
492 Besides, regclass fails to notice the different REGISTER_MOVE_COSTS
493 applying to the actual instruction alternative considered. E.g., the
494 y/r alternative of movsi_ie is considered to have no more cost that
495 the r/r alternative, which is patently untrue. */
497 enum reg_class
499 NO_REGS,
500 R0_REGS,
501 PR_REGS,
502 T_REGS,
503 MAC_REGS,
504 FPUL_REGS,
505 GENERAL_REGS,
506 FP0_REGS,
507 FP_REGS,
508 GENERAL_FP_REGS,
509 ALL_REGS,
510 LIM_REG_CLASSES
513 #define N_REG_CLASSES (int) LIM_REG_CLASSES
515 /* Give names of register classes as strings for dump file. */
516 #define REG_CLASS_NAMES \
518 "NO_REGS", \
519 "R0_REGS", \
520 "PR_REGS", \
521 "T_REGS", \
522 "MAC_REGS", \
523 "FPUL_REGS", \
524 "GENERAL_REGS", \
525 "FP0_REGS", \
526 "FP_REGS", \
527 "GENERAL_FP_REGS", \
528 "ALL_REGS", \
531 /* Define which registers fit in which classes.
532 This is an initializer for a vector of HARD_REG_SET
533 of length N_REG_CLASSES. */
535 #define REG_CLASS_CONTENTS \
537 { 0x00000000, 0x00000000 }, /* NO_REGS */ \
538 { 0x00000001, 0x00000000 }, /* R0_REGS */ \
539 { 0x00020000, 0x00000000 }, /* PR_REGS */ \
540 { 0x00040000, 0x00000000 }, /* T_REGS */ \
541 { 0x00300000, 0x00000000 }, /* MAC_REGS */ \
542 { 0x00400000, 0x00000000 }, /* FPUL_REGS */ \
543 { 0x0081FFFF, 0x00000000 }, /* GENERAL_REGS */ \
544 { 0x01000000, 0x00000000 }, /* FP0_REGS */ \
545 { 0xFF000000, 0x000000FF }, /* FP_REGS */ \
546 { 0xFF81FFFF, 0x000000FF }, /* GENERAL_FP_REGS */ \
547 { 0xFFFFFFFF, 0x000000FF }, /* ALL_REGS */ \
550 /* The same information, inverted:
551 Return the class number of the smallest class containing
552 reg number REGNO. This could be a conditional expression
553 or could index an array. */
555 extern int regno_reg_class[];
556 #define REGNO_REG_CLASS(REGNO) regno_reg_class[(REGNO)]
558 /* When defined, the compiler allows registers explicitly used in the
559 rtl to be used as spill registers but prevents the compiler from
560 extending the lifetime of these registers. */
562 #define SMALL_REGISTER_CLASSES 1
564 /* The order in which register should be allocated. */
565 /* Sometimes FP0_REGS becomes the preferred class of a floating point pseudo,
566 and GENERAL_FP_REGS the alternate class. Since FP0 is likely to be
567 spilled or used otherwise, we better have the FP_REGS allocated first. */
568 #define REG_ALLOC_ORDER \
569 { 25,26,27,28,29,30,31,24,32,33,34,35,36,37,38,39, \
570 1,2,3,7,6,5,4,0,8,9,10,11,12,13,14, \
571 22,15,16,17,18,19,20,21,23 }
573 /* The class value for index registers, and the one for base regs. */
574 #define INDEX_REG_CLASS R0_REGS
575 #define BASE_REG_CLASS GENERAL_REGS
577 /* Get reg_class from a letter such as appears in the machine
578 description. */
579 extern enum reg_class reg_class_from_letter[];
581 #define REG_CLASS_FROM_LETTER(C) \
582 ( (C) >= 'a' && (C) <= 'z' ? reg_class_from_letter[(C)-'a'] : NO_REGS )
584 /* The letters I, J, K, L and M in a register constraint string
585 can be used to stand for particular ranges of immediate operands.
586 This macro defines what the ranges are.
587 C is the letter, and VALUE is a constant value.
588 Return 1 if VALUE is in the range specified by C.
589 I: arithmetic operand -127..128, as used in add, sub, etc
590 K: shift operand 1,2,8 or 16
591 L: logical operand 0..255, as used in and, or, etc.
592 M: constant 1
593 N: constant 0 */
595 #define CONST_OK_FOR_I(VALUE) (((int)(VALUE))>= -128 && ((int)(VALUE)) <= 127)
596 #define CONST_OK_FOR_K(VALUE) ((VALUE)==1||(VALUE)==2||(VALUE)==8||(VALUE)==16)
597 #define CONST_OK_FOR_L(VALUE) (((int)(VALUE))>= 0 && ((int)(VALUE)) <= 255)
598 #define CONST_OK_FOR_M(VALUE) ((VALUE)==1)
599 #define CONST_OK_FOR_N(VALUE) ((VALUE)==0)
600 #define CONST_OK_FOR_LETTER_P(VALUE, C) \
601 ((C) == 'I' ? CONST_OK_FOR_I (VALUE) \
602 : (C) == 'K' ? CONST_OK_FOR_K (VALUE) \
603 : (C) == 'L' ? CONST_OK_FOR_L (VALUE) \
604 : (C) == 'M' ? CONST_OK_FOR_M (VALUE) \
605 : (C) == 'N' ? CONST_OK_FOR_N (VALUE) \
606 : 0)
608 /* Similar, but for floating constants, and defining letters G and H.
609 Here VALUE is the CONST_DOUBLE rtx itself. */
611 #define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) \
612 ((C) == 'G' ? fp_zero_operand (VALUE) \
613 : (C) == 'H' ? fp_one_operand (VALUE) \
614 : (C) == 'F')
616 /* Given an rtx X being reloaded into a reg required to be
617 in class CLASS, return the class of reg to actually use.
618 In general this is just CLASS; but on some machines
619 in some cases it is preferable to use a more restrictive class. */
621 #define PREFERRED_RELOAD_CLASS(X, CLASS) (CLASS)
623 #define SECONDARY_OUTPUT_RELOAD_CLASS(CLASS,MODE,X) \
624 ((((((CLASS) == FP_REGS || (CLASS) == FP0_REGS) \
625 && (GET_CODE (X) == REG && REGNO (X) <= AP_REG)) \
626 || (((CLASS) == GENERAL_REGS || (CLASS) == R0_REGS) \
627 && GET_CODE (X) == REG \
628 && REGNO (X) >= FIRST_FP_REG && REGNO (X) <= LAST_FP_REG)) \
629 && MODE == SFmode) \
630 ? FPUL_REGS \
631 : ((CLASS) == FPUL_REGS \
632 && (GET_CODE (X) == MEM \
633 || GET_CODE (X) == REG && REGNO (X) >= FIRST_PSEUDO_REGISTER))\
634 ? GENERAL_REGS \
635 : (((CLASS) == MAC_REGS || (CLASS) == PR_REGS) \
636 && GET_CODE (X) == REG && REGNO (X) > 15 \
637 && (CLASS) != REGNO_REG_CLASS (REGNO (X))) \
638 ? GENERAL_REGS : NO_REGS)
640 #define SECONDARY_INPUT_RELOAD_CLASS(CLASS,MODE,X) \
641 ((((CLASS) == FP_REGS || (CLASS) == FP0_REGS) \
642 && immediate_operand ((X), (MODE)) \
643 && ! (fp_zero_operand (X) || fp_one_operand (X))) \
644 ? R0_REGS : SECONDARY_OUTPUT_RELOAD_CLASS((CLASS),(MODE),(X)))
646 /* Return the maximum number of consecutive registers
647 needed to represent mode MODE in a register of class CLASS.
649 On SH this is the size of MODE in words. */
650 #define CLASS_MAX_NREGS(CLASS, MODE) \
651 ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
653 /* Stack layout; function entry, exit and calling. */
655 /* Define the number of registers that can hold parameters.
656 These macros are used only in other macro definitions below. */
658 #define NPARM_REGS(MODE) \
659 (TARGET_SH3E && (MODE) == SFmode \
660 ? 8 \
661 : 4)
663 #define FIRST_PARM_REG 4
664 #define FIRST_RET_REG 0
666 #define FIRST_FP_PARM_REG (FIRST_FP_REG + 4)
667 #define FIRST_FP_RET_REG FIRST_FP_REG
669 /* Define this if pushing a word on the stack
670 makes the stack pointer a smaller address. */
671 #define STACK_GROWS_DOWNWARD
673 /* Define this macro if the addresses of local variable slots are at
674 negative offsets from the frame pointer.
676 The SH only has positive indexes, so grow the frame up. */
677 /* #define FRAME_GROWS_DOWNWARD */
679 /* Offset from the frame pointer to the first local variable slot to
680 be allocated. */
681 #define STARTING_FRAME_OFFSET 0
683 /* If we generate an insn to push BYTES bytes,
684 this says how many the stack pointer really advances by. */
685 /* Don't define PUSH_ROUNDING, since the hardware doesn't do this.
686 When PUSH_ROUNDING is not defined, PARM_BOUNDARY will cause gcc to
687 do correct alignment. */
688 #if 0
689 #define PUSH_ROUNDING(NPUSHED) (((NPUSHED) + 3) & ~3)
690 #endif
692 /* Offset of first parameter from the argument pointer register value. */
693 #define FIRST_PARM_OFFSET(FNDECL) 0
695 /* Value is the number of byte of arguments automatically
696 popped when returning from a subroutine call.
697 FUNDECL is the declaration node of the function (as a tree),
698 FUNTYPE is the data type of the function (as a tree),
699 or for a library call it is an identifier node for the subroutine name.
700 SIZE is the number of bytes of arguments passed on the stack.
702 On the SH, the caller does not pop any of its arguments that were passed
703 on the stack. */
704 #define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE) 0
706 /* Some subroutine macros specific to this machine. */
708 #define BASE_RETURN_VALUE_REG(MODE) \
709 ((TARGET_SH3E && ((MODE) == SFmode)) \
710 ? FIRST_FP_RET_REG \
711 : FIRST_RET_REG)
713 #define BASE_ARG_REG(MODE) \
714 ((TARGET_SH3E && ((MODE) == SFmode)) \
715 ? FIRST_FP_PARM_REG \
716 : FIRST_PARM_REG)
718 /* Define how to find the value returned by a function.
719 VALTYPE is the data type of the value (as a tree).
720 If the precise function being called is known, FUNC is its FUNCTION_DECL;
721 otherwise, FUNC is 0. */
723 #define FUNCTION_VALUE(VALTYPE, FUNC) \
724 LIBCALL_VALUE (TYPE_MODE (VALTYPE))
726 /* Define how to find the value returned by a library function
727 assuming the value has mode MODE. */
728 #define LIBCALL_VALUE(MODE) \
729 gen_rtx (REG, (MODE), BASE_RETURN_VALUE_REG (MODE));
731 /* 1 if N is a possible register number for a function value. */
732 #define FUNCTION_VALUE_REGNO_P(REGNO) \
733 ((REGNO) == FIRST_RET_REG || (TARGET_SH3E && (REGNO) == FIRST_FP_RET_REG))
735 /* 1 if N is a possible register number for function argument passing. */
736 #define FUNCTION_ARG_REGNO_P(REGNO) \
737 (((REGNO) >= FIRST_PARM_REG && (REGNO) < (FIRST_PARM_REG + 4)) \
738 || (TARGET_SH3E \
739 && (REGNO) >= FIRST_FP_PARM_REG && (REGNO) < (FIRST_FP_PARM_REG + 8)))
741 /* Define a data type for recording info about an argument list
742 during the scan of that argument list. This data type should
743 hold all necessary information about the function itself
744 and about the args processed so far, enough to enable macros
745 such as FUNCTION_ARG to determine where the next arg should go.
747 On SH, this is a single integer, which is a number of words
748 of arguments scanned so far (including the invisible argument,
749 if any, which holds the structure-value-address).
750 Thus NARGREGS or more means all following args should go on the stack. */
752 enum sh_arg_class { SH_ARG_INT = 0, SH_ARG_FLOAT = 1 };
753 struct sh_args {
754 int arg_count[2];
757 #define CUMULATIVE_ARGS struct sh_args
759 #define GET_SH_ARG_CLASS(MODE) \
760 ((TARGET_SH3E && ((MODE) == SFmode)) ? SH_ARG_FLOAT : SH_ARG_INT)
762 #define ROUND_ADVANCE(SIZE) \
763 (((SIZE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
765 /* Round a register number up to a proper boundary for an arg of mode
766 MODE.
768 The SH doesn't care about double alignment, so we only
769 round doubles to even regs when asked to explicitly. */
771 #define ROUND_REG(CUM, MODE) \
772 ((TARGET_ALIGN_DOUBLE \
773 && GET_MODE_UNIT_SIZE ((MODE)) > UNITS_PER_WORD) \
774 ? ((CUM).arg_count[(int) GET_SH_ARG_CLASS (MODE)] \
775 + ((CUM).arg_count[(int) GET_SH_ARG_CLASS (MODE)] & 1)) \
776 : (CUM).arg_count[(int) GET_SH_ARG_CLASS (MODE)])
778 /* Initialize a variable CUM of type CUMULATIVE_ARGS
779 for a call to a function whose data type is FNTYPE.
780 For a library call, FNTYPE is 0.
782 On SH, the offset always starts at 0: the first parm reg is always
783 the same reg for a given argument class. */
785 #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, INDIRECT) \
786 do { \
787 (CUM).arg_count[(int) SH_ARG_INT] = 0; \
788 (CUM).arg_count[(int) SH_ARG_FLOAT] = 0; \
789 } while (0)
791 /* Update the data in CUM to advance over an argument
792 of mode MODE and data type TYPE.
793 (TYPE is null for libcalls where that information may not be
794 available.) */
796 #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \
797 ((CUM).arg_count[(int) GET_SH_ARG_CLASS (MODE)] = \
798 (ROUND_REG ((CUM), (MODE)) \
799 + ((MODE) != BLKmode \
800 ? ROUND_ADVANCE (GET_MODE_SIZE (MODE)) \
801 : ROUND_ADVANCE (int_size_in_bytes (TYPE)))))
803 /* Return boolean indicating arg of mode MODE will be passed in a reg.
804 This macro is only used in this file. */
806 #define PASS_IN_REG_P(CUM, MODE, TYPE) \
807 (((TYPE) == 0 || ! TREE_ADDRESSABLE ((tree)(TYPE))) \
808 && (TARGET_SH3E \
809 ? ((MODE) == BLKmode \
810 ? (((CUM).arg_count[(int) SH_ARG_INT] * UNITS_PER_WORD \
811 + int_size_in_bytes (TYPE)) \
812 <= NPARM_REGS (SImode) * UNITS_PER_WORD) \
813 : ((ROUND_REG((CUM), (MODE)) \
814 + HARD_REGNO_NREGS (BASE_ARG_REG (MODE), (MODE))) \
815 <= NPARM_REGS (MODE))) \
816 : ROUND_REG ((CUM), (MODE)) < NPARM_REGS (MODE)))
818 /* Define where to put the arguments to a function.
819 Value is zero to push the argument on the stack,
820 or a hard register in which to store the argument.
822 MODE is the argument's machine mode.
823 TYPE is the data type of the argument (as a tree).
824 This is null for libcalls where that information may
825 not be available.
826 CUM is a variable of type CUMULATIVE_ARGS which gives info about
827 the preceding args and about the function being called.
828 NAMED is nonzero if this argument is a named parameter
829 (otherwise it is an extra parameter matching an ellipsis).
831 On SH the first args are normally in registers
832 and the rest are pushed. Any arg that starts within the first
833 NPARM_REGS words is at least partially passed in a register unless
834 its data type forbids. */
836 #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
837 ((PASS_IN_REG_P ((CUM), (MODE), (TYPE)) \
838 && ((NAMED) || TARGET_SH3E)) \
839 ? gen_rtx (REG, (MODE), \
840 (BASE_ARG_REG (MODE) + ROUND_REG ((CUM), (MODE)))) \
841 : 0)
843 /* For an arg passed partly in registers and partly in memory,
844 this is the number of registers used.
845 For args passed entirely in registers or entirely in memory, zero.
847 We sometimes split args. */
849 #define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) \
850 ((PASS_IN_REG_P ((CUM), (MODE), (TYPE)) \
851 && ((NAMED) || TARGET_SH3E) \
852 && (ROUND_REG ((CUM), (MODE)) \
853 + (MODE != BLKmode \
854 ? ROUND_ADVANCE (GET_MODE_SIZE (MODE)) \
855 : ROUND_ADVANCE (int_size_in_bytes (TYPE))) \
856 - NPARM_REGS (MODE) > 0)) \
857 ? NPARM_REGS (MODE) - ROUND_REG ((CUM), (MODE)) \
858 : 0)
860 extern int current_function_anonymous_args;
862 /* Perform any needed actions needed for a function that is receiving a
863 variable number of arguments. */
865 #define SETUP_INCOMING_VARARGS(ASF, MODE, TYPE, PAS, ST) \
866 current_function_anonymous_args = 1;
868 /* Call the function profiler with a given profile label.
869 We use two .aligns, so as to make sure that both the .long is aligned
870 on a 4 byte boundary, and that the .long is a fixed distance (2 bytes)
871 from the trapa instruction. */
873 #define FUNCTION_PROFILER(STREAM,LABELNO) \
875 fprintf((STREAM), "\t.align\t2\n"); \
876 fprintf((STREAM), "\ttrapa\t#33\n"); \
877 fprintf((STREAM), "\t.align\t2\n"); \
878 asm_fprintf((STREAM), "\t.long\t%LLP%d\n", (LABELNO)); \
881 /* Define this macro if the code for function profiling should come
882 before the function prologue. Normally, the profiling code comes
883 after. */
885 #define PROFILE_BEFORE_PROLOGUE
887 /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
888 the stack pointer does not matter. The value is tested only in
889 functions that have frame pointers.
890 No definition is equivalent to always zero. */
892 #define EXIT_IGNORE_STACK 1
894 /* Generate the assembly code for function exit
895 Just dump out any accumulated constant table. */
897 #define FUNCTION_EPILOGUE(STREAM, SIZE) function_epilogue ((STREAM), (SIZE))
900 On the SH, the trampoline looks like
901 2 0002 DD02 mov.l l2,r13
902 1 0000 D301 mov.l l1,r3
903 3 0004 4D2B jmp @r13
904 4 0006 0009 nop
905 5 0008 00000000 l1: .long function
906 6 000c 00000000 l2: .long area */
908 /* Length in units of the trampoline for entering a nested function. */
909 #define TRAMPOLINE_SIZE 16
911 /* Alignment required for a trampoline in bits . */
912 #define TRAMPOLINE_ALIGNMENT \
913 ((CACHE_LOG < 3 || TARGET_SMALLCODE) ? 32 : 64) \
915 /* Emit RTL insns to initialize the variable parts of a trampoline.
916 FNADDR is an RTX for the address of the function's pure code.
917 CXT is an RTX for the static chain value for the function. */
919 #define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) \
921 emit_move_insn (gen_rtx (MEM, SImode, (TRAMP)), \
922 GEN_INT (TARGET_LITTLE_ENDIAN ? 0xd301dd02 : 0xdd02d301));\
923 emit_move_insn (gen_rtx (MEM, SImode, plus_constant ((TRAMP), 4)), \
924 GEN_INT (TARGET_LITTLE_ENDIAN ? 0x00094d2b : 0x4d2b0009));\
925 emit_move_insn (gen_rtx (MEM, SImode, plus_constant ((TRAMP), 8)), \
926 (CXT)); \
927 emit_move_insn (gen_rtx (MEM, SImode, plus_constant ((TRAMP), 12)), \
928 (FNADDR)); \
931 /* A C expression whose value is RTL representing the value of the return
932 address for the frame COUNT steps up from the current frame.
933 FRAMEADDR is already the frame pointer of the COUNT frame, so we
934 can ignore COUNT. */
936 #define RETURN_ADDR_RTX(COUNT, FRAME) \
937 (((COUNT) == 0) \
938 ? gen_rtx (MEM, Pmode, gen_rtx (REG, Pmode, RETURN_ADDRESS_POINTER_REGNUM)) \
939 : (rtx) 0)
941 /* Generate necessary RTL for __builtin_saveregs().
942 ARGLIST is the argument list; see expr.c. */
943 extern struct rtx_def *sh_builtin_saveregs ();
944 #define EXPAND_BUILTIN_SAVEREGS(ARGLIST) sh_builtin_saveregs (ARGLIST)
946 /* Addressing modes, and classification of registers for them. */
947 #define HAVE_POST_INCREMENT 1
948 /*#define HAVE_PRE_INCREMENT 1*/
949 /*#define HAVE_POST_DECREMENT 1*/
950 #define HAVE_PRE_DECREMENT 1
952 /* Macros to check register numbers against specific register classes. */
954 /* These assume that REGNO is a hard or pseudo reg number.
955 They give nonzero only if REGNO is a hard reg of the suitable class
956 or a pseudo reg currently allocated to a suitable hard reg.
957 Since they use reg_renumber, they are safe only once reg_renumber
958 has been allocated, which happens in local-alloc.c. */
960 #define REGNO_OK_FOR_BASE_P(REGNO) \
961 ((REGNO) < PR_REG || (unsigned) reg_renumber[(REGNO)] < PR_REG)
962 #define REGNO_OK_FOR_INDEX_P(REGNO) \
963 ((REGNO) == 0 || (unsigned) reg_renumber[(REGNO)] == 0)
965 /* Maximum number of registers that can appear in a valid memory
966 address. */
968 #define MAX_REGS_PER_ADDRESS 2
970 /* Recognize any constant value that is a valid address. */
972 #define CONSTANT_ADDRESS_P(X) (GET_CODE (X) == LABEL_REF)
974 /* Nonzero if the constant value X is a legitimate general operand. */
976 #define LEGITIMATE_CONSTANT_P(X) \
977 (GET_CODE (X) != CONST_DOUBLE \
978 || GET_MODE (X) == DFmode || GET_MODE (X) == SFmode \
979 || (TARGET_SH3E && (fp_zero_operand (X) || fp_one_operand (X))))
981 /* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
982 and check its validity for a certain class.
983 We have two alternate definitions for each of them.
984 The usual definition accepts all pseudo regs; the other rejects
985 them unless they have been allocated suitable hard regs.
986 The symbol REG_OK_STRICT causes the latter definition to be used. */
988 #ifndef REG_OK_STRICT
990 /* Nonzero if X is a hard reg that can be used as a base reg
991 or if it is a pseudo reg. */
992 #define REG_OK_FOR_BASE_P(X) \
993 (REGNO (X) <= 16 || REGNO (X) >= FIRST_PSEUDO_REGISTER)
995 /* Nonzero if X is a hard reg that can be used as an index
996 or if it is a pseudo reg. */
997 #define REG_OK_FOR_INDEX_P(X) \
998 (REGNO (X) == 0 || REGNO (X) >= FIRST_PSEUDO_REGISTER)
1000 /* Nonzero if X/OFFSET is a hard reg that can be used as an index
1001 or if X is a pseudo reg. */
1002 #define SUBREG_OK_FOR_INDEX_P(X, OFFSET) \
1003 ((REGNO (X) == 0 && OFFSET == 0) || REGNO (X) >= FIRST_PSEUDO_REGISTER)
1005 #else
1007 /* Nonzero if X is a hard reg that can be used as a base reg. */
1008 #define REG_OK_FOR_BASE_P(X) \
1009 REGNO_OK_FOR_BASE_P (REGNO (X))
1011 /* Nonzero if X is a hard reg that can be used as an index. */
1012 #define REG_OK_FOR_INDEX_P(X) \
1013 REGNO_OK_FOR_INDEX_P (REGNO (X))
1015 /* Nonzero if X/OFFSET is a hard reg that can be used as an index. */
1016 #define SUBREG_OK_FOR_INDEX_P(X, OFFSET) \
1017 (REGNO_OK_FOR_INDEX_P (REGNO (X)) && (OFFSET) == 0)
1019 #endif
1021 /* The 'Q' constraint is a pc relative load operand. */
1022 #define EXTRA_CONSTRAINT_Q(OP) \
1023 (GET_CODE (OP) == MEM && \
1024 ((GET_CODE (XEXP ((OP), 0)) == LABEL_REF) \
1025 || (GET_CODE (XEXP ((OP), 0)) == CONST \
1026 && GET_CODE (XEXP (XEXP ((OP), 0), 0)) == PLUS \
1027 && GET_CODE (XEXP (XEXP (XEXP ((OP), 0), 0), 0)) == LABEL_REF \
1028 && GET_CODE (XEXP (XEXP (XEXP ((OP), 0), 0), 1)) == CONST_INT)))
1030 #define EXTRA_CONSTRAINT(OP, C) \
1031 ((C) == 'Q' ? EXTRA_CONSTRAINT_Q (OP) \
1032 : 0)
1034 /* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression
1035 that is a valid memory address for an instruction.
1036 The MODE argument is the machine mode for the MEM expression
1037 that wants to use this address.
1039 The other macros defined here are used only in GO_IF_LEGITIMATE_ADDRESS. */
1041 #define MODE_DISP_OK_4(X,MODE) \
1042 (GET_MODE_SIZE (MODE) == 4 && (unsigned) INTVAL (X) < 64 \
1043 && ! (INTVAL (X) & 3) && ! (TARGET_SH3E && (MODE) == SFmode))
1044 #define MODE_DISP_OK_8(X,MODE) ((GET_MODE_SIZE(MODE)==8) && ((unsigned)INTVAL(X)<60) && (!(INTVAL(X) &3)))
1046 #define BASE_REGISTER_RTX_P(X) \
1047 ((GET_CODE (X) == REG && REG_OK_FOR_BASE_P (X)) \
1048 || (GET_CODE (X) == SUBREG \
1049 && GET_CODE (SUBREG_REG (X)) == REG \
1050 && REG_OK_FOR_BASE_P (SUBREG_REG (X))))
1052 /* Since this must be r0, which is a single register class, we must check
1053 SUBREGs more carefully, to be sure that we don't accept one that extends
1054 outside the class. */
1055 #define INDEX_REGISTER_RTX_P(X) \
1056 ((GET_CODE (X) == REG && REG_OK_FOR_INDEX_P (X)) \
1057 || (GET_CODE (X) == SUBREG \
1058 && GET_CODE (SUBREG_REG (X)) == REG \
1059 && SUBREG_OK_FOR_INDEX_P (SUBREG_REG (X), SUBREG_WORD (X))))
1061 /* Jump to LABEL if X is a valid address RTX. This must also take
1062 REG_OK_STRICT into account when deciding about valid registers, but it uses
1063 the above macros so we are in luck.
1065 Allow REG
1066 REG+disp
1067 REG+r0
1068 REG++
1069 --REG */
1071 /* ??? The SH3e does not have the REG+disp addressing mode when loading values
1072 into the FRx registers. We implement this by setting the maximum offset
1073 to zero when the value is SFmode. This also restricts loading of SFmode
1074 values into the integer registers, but that can't be helped. */
1076 /* The SH allows a displacement in a QI or HI amode, but only when the
1077 other operand is R0. GCC doesn't handle this very well, so we forgo
1078 all of that.
1080 A legitimate index for a QI or HI is 0, SI can be any number 0..63,
1081 DI can be any number 0..60. */
1083 #define GO_IF_LEGITIMATE_INDEX(MODE, OP, LABEL) \
1084 do { \
1085 if (GET_CODE (OP) == CONST_INT) \
1087 if (MODE_DISP_OK_4 ((OP), (MODE))) goto LABEL; \
1088 if (MODE_DISP_OK_8 ((OP), (MODE))) goto LABEL; \
1090 } while(0)
1092 #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, LABEL) \
1094 if (BASE_REGISTER_RTX_P (X)) \
1095 goto LABEL; \
1096 else if ((GET_CODE (X) == POST_INC || GET_CODE (X) == PRE_DEC) \
1097 && BASE_REGISTER_RTX_P (XEXP ((X), 0))) \
1098 goto LABEL; \
1099 else if (GET_CODE (X) == PLUS && MODE != PSImode) \
1101 rtx xop0 = XEXP ((X), 0); \
1102 rtx xop1 = XEXP ((X), 1); \
1103 if (GET_MODE_SIZE (MODE) <= 8 && BASE_REGISTER_RTX_P (xop0)) \
1104 GO_IF_LEGITIMATE_INDEX ((MODE), xop1, LABEL); \
1105 if (GET_MODE_SIZE (MODE) <= 4) \
1107 if (BASE_REGISTER_RTX_P (xop1) && INDEX_REGISTER_RTX_P (xop0))\
1108 goto LABEL; \
1109 if (INDEX_REGISTER_RTX_P (xop1) && BASE_REGISTER_RTX_P (xop0))\
1110 goto LABEL; \
1115 /* Try machine-dependent ways of modifying an illegitimate address
1116 to be legitimate. If we find one, return the new, valid address.
1117 This macro is used in only one place: `memory_address' in explow.c.
1119 OLDX is the address as it was before break_out_memory_refs was called.
1120 In some cases it is useful to look at this to decide what needs to be done.
1122 MODE and WIN are passed so that this macro can use
1123 GO_IF_LEGITIMATE_ADDRESS.
1125 It is always safe for this macro to do nothing. It exists to recognize
1126 opportunities to optimize the output.
1128 For the SH, if X is almost suitable for indexing, but the offset is
1129 out of range, convert it into a normal form so that cse has a chance
1130 of reducing the number of address registers used. */
1132 #define LEGITIMIZE_ADDRESS(X,OLDX,MODE,WIN) \
1134 if (GET_CODE (X) == PLUS \
1135 && (GET_MODE_SIZE (MODE) == 4 \
1136 || GET_MODE_SIZE (MODE) == 8) \
1137 && GET_CODE (XEXP ((X), 1)) == CONST_INT \
1138 && BASE_REGISTER_RTX_P (XEXP ((X), 0)) \
1139 && ! (TARGET_SH3E && (MODE) == SFmode)) \
1141 rtx index_rtx = XEXP ((X), 1); \
1142 HOST_WIDE_INT offset = INTVAL (index_rtx), offset_base; \
1143 rtx sum; \
1145 GO_IF_LEGITIMATE_INDEX ((MODE), index_rtx, WIN); \
1146 /* On rare occasions, we might get an unaligned pointer \
1147 that is indexed in a way to give an aligned address. \
1148 Therefore, keep the lower two bits in offset_base. */ \
1149 /* Instead of offset_base 128..131 use 124..127, so that \
1150 simple add suffices. */ \
1151 if (offset > 127) \
1153 offset_base = ((offset + 4) & ~60) - 4; \
1155 else \
1156 offset_base = offset & ~60; \
1157 /* Sometimes the normal form does not suit DImode. We \
1158 could avoid that by using smaller ranges, but that \
1159 would give less optimized code when SImode is \
1160 prevalent. */ \
1161 if (GET_MODE_SIZE (MODE) + offset - offset_base <= 64) \
1163 sum = expand_binop (Pmode, add_optab, XEXP ((X), 0), \
1164 GEN_INT (offset_base), NULL_RTX, 0, \
1165 OPTAB_LIB_WIDEN); \
1167 (X) = gen_rtx (PLUS, Pmode, sum, GEN_INT (offset - offset_base)); \
1168 goto WIN; \
1173 /* Go to LABEL if ADDR (a legitimate address expression)
1174 has an effect that depends on the machine mode it is used for.
1176 ??? Strictly speaking, we should also include all indexed addressing,
1177 because the index scale factor is the length of the operand.
1178 However, the impact of GO_IF_MODE_DEPENDENT_ADDRESS would be to
1179 high if we did that. So we rely on reload to fix things up. */
1181 #define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR,LABEL) \
1183 if (GET_CODE(ADDR) == PRE_DEC || GET_CODE(ADDR) == POST_INC) \
1184 goto LABEL; \
1187 /* Specify the machine mode that this machine uses
1188 for the index in the tablejump instruction. */
1189 #define CASE_VECTOR_MODE (TARGET_BIGTABLE ? SImode : HImode)
1191 /* Define as C expression which evaluates to nonzero if the tablejump
1192 instruction expects the table to contain offsets from the address of the
1193 table.
1194 Do not define this if the table should contain absolute addresses. */
1195 #define CASE_VECTOR_PC_RELATIVE 1
1197 /* Specify the tree operation to be used to convert reals to integers. */
1198 #define IMPLICIT_FIX_EXPR FIX_ROUND_EXPR
1200 /* This is the kind of divide that is easiest to do in the general case. */
1201 #define EASY_DIV_EXPR TRUNC_DIV_EXPR
1203 /* Since the SH3e has only `float' support, it is desirable to make all
1204 floating point types equivalent to `float'. */
1205 #define DOUBLE_TYPE_SIZE (TARGET_SH3E ? 32 : 64)
1207 /* 'char' is signed by default. */
1208 #define DEFAULT_SIGNED_CHAR 1
1210 /* The type of size_t unsigned int. */
1211 #define SIZE_TYPE "unsigned int"
1213 #define WCHAR_TYPE "short unsigned int"
1214 #define WCHAR_TYPE_SIZE 16
1216 /* Don't cse the address of the function being compiled. */
1217 /*#define NO_RECURSIVE_FUNCTION_CSE 1*/
1219 /* Max number of bytes we can move from memory to memory
1220 in one reasonably fast instruction. */
1221 #define MOVE_MAX 4
1223 /* Define if operations between registers always perform the operation
1224 on the full register even if a narrower mode is specified. */
1225 #define WORD_REGISTER_OPERATIONS
1227 /* Define if loading in MODE, an integral mode narrower than BITS_PER_WORD
1228 will either zero-extend or sign-extend. The value of this macro should
1229 be the code that says which one of the two operations is implicitly
1230 done, NIL if none. */
1231 #define LOAD_EXTEND_OP(MODE) SIGN_EXTEND
1233 /* Define if loading short immediate values into registers sign extends. */
1234 #define SHORT_IMMEDIATES_SIGN_EXTEND
1236 /* Define this if zero-extension is slow (more than one real instruction).
1237 On the SH, it's only one instruction. */
1238 /* #define SLOW_ZERO_EXTEND */
1240 /* Nonzero if access to memory by bytes is slow and undesirable. */
1241 #define SLOW_BYTE_ACCESS 0
1243 /* We assume that the store-condition-codes instructions store 0 for false
1244 and some other value for true. This is the value stored for true. */
1246 #define STORE_FLAG_VALUE 1
1248 /* Immediate shift counts are truncated by the output routines (or was it
1249 the assembler?). Shift counts in a register are truncated by SH. Note
1250 that the native compiler puts too large (> 32) immediate shift counts
1251 into a register and shifts by the register, letting the SH decide what
1252 to do instead of doing that itself. */
1253 /* ??? The library routines in lib1funcs.asm truncate the shift count.
1254 However, the SH3 has hardware shifts that do not truncate exactly as gcc
1255 expects - the sign bit is significant - so it appears that we need to
1256 leave this zero for correct SH3 code. */
1257 #define SHIFT_COUNT_TRUNCATED (! TARGET_SH3)
1259 /* All integers have the same format so truncation is easy. */
1260 #define TRULY_NOOP_TRUNCATION(OUTPREC,INPREC) 1
1262 /* Define this if addresses of constant functions
1263 shouldn't be put through pseudo regs where they can be cse'd.
1264 Desirable on machines where ordinary constants are expensive
1265 but a CALL with constant address is cheap. */
1266 /*#define NO_FUNCTION_CSE 1*/
1268 /* Chars and shorts should be passed as ints. */
1269 #define PROMOTE_PROTOTYPES 1
1271 /* The machine modes of pointers and functions. */
1272 #define Pmode SImode
1273 #define FUNCTION_MODE Pmode
1275 /* The relative costs of various types of constants. Note that cse.c defines
1276 REG = 1, SUBREG = 2, any node = (2 + sum of subnodes). */
1278 #define CONST_COSTS(RTX, CODE, OUTER_CODE) \
1279 case CONST_INT: \
1280 if (INTVAL (RTX) == 0) \
1281 return 0; \
1282 else if (CONST_OK_FOR_I (INTVAL (RTX))) \
1283 return 1; \
1284 else if (((OUTER_CODE) == AND || (OUTER_CODE) == IOR || (OUTER_CODE) == XOR) \
1285 && CONST_OK_FOR_L (INTVAL (RTX))) \
1286 return 1; \
1287 else \
1288 return 8; \
1289 case CONST: \
1290 case LABEL_REF: \
1291 case SYMBOL_REF: \
1292 return 5; \
1293 case CONST_DOUBLE: \
1294 return 10;
1296 #define RTX_COSTS(X, CODE, OUTER_CODE) \
1297 case AND: \
1298 return COSTS_N_INSNS (andcosts (X)); \
1299 case MULT: \
1300 return COSTS_N_INSNS (multcosts (X)); \
1301 case ASHIFT: \
1302 case ASHIFTRT: \
1303 case LSHIFTRT: \
1304 return COSTS_N_INSNS (shiftcosts (X)) ; \
1305 case DIV: \
1306 case UDIV: \
1307 case MOD: \
1308 case UMOD: \
1309 return COSTS_N_INSNS (20); \
1310 case FLOAT: \
1311 case FIX: \
1312 return 100;
1314 /* The multiply insn on the SH1 and the divide insns on the SH1 and SH2
1315 are actually function calls with some special constraints on arguments
1316 and register usage.
1318 These macros tell reorg that the references to arguments and
1319 register clobbers for insns of type sfunc do not appear to happen
1320 until after the millicode call. This allows reorg to put insns
1321 which set the argument registers into the delay slot of the millicode
1322 call -- thus they act more like traditional CALL_INSNs.
1324 get_attr_type will try to recognize the given insn, so make sure to
1325 filter out things it will not accept -- SEQUENCE, USE and CLOBBER insns
1326 in particular. */
1328 #define INSN_SETS_ARE_DELAYED(X) \
1329 ((GET_CODE (X) == INSN \
1330 && GET_CODE (PATTERN (X)) != SEQUENCE \
1331 && GET_CODE (PATTERN (X)) != USE \
1332 && GET_CODE (PATTERN (X)) != CLOBBER \
1333 && get_attr_type (X) == TYPE_SFUNC))
1335 #define INSN_REFERENCES_ARE_DELAYED(X) \
1336 ((GET_CODE (X) == INSN \
1337 && GET_CODE (PATTERN (X)) != SEQUENCE \
1338 && GET_CODE (PATTERN (X)) != USE \
1339 && GET_CODE (PATTERN (X)) != CLOBBER \
1340 && get_attr_type (X) == TYPE_SFUNC))
1342 /* Compute the cost of an address. For the SH, all valid addresses are
1343 the same cost. */
1344 /* ??? Perhaps we should make reg+reg addresses have higher cost because
1345 they add to register pressure on r0. */
1347 #define ADDRESS_COST(RTX) 1
1349 /* Compute extra cost of moving data between one register class
1350 and another. */
1352 #define REGISTER_MOVE_COST(SRCCLASS, DSTCLASS) \
1353 ((DSTCLASS) == PR_REG ? 10 \
1354 : (((DSTCLASS) == FP_REGS && (SRCCLASS) == GENERAL_REGS) \
1355 || ((DSTCLASS) == GENERAL_REGS && (SRCCLASS) == FP_REGS)) ? 4 \
1356 : 1)
1358 /* ??? Perhaps make MEMORY_MOVE_COST depend on compiler option? This
1359 would be so that people would slow memory systems could generate
1360 different code that does fewer memory accesses. */
1362 /* Assembler output control. */
1364 /* A C string constant describing how to begin a comment in the target
1365 assembler language. The compiler assumes that the comment will end at
1366 the end of the line. */
1367 #define ASM_COMMENT_START "!"
1369 /* The text to go at the start of the assembler file. */
1370 #define ASM_FILE_START(STREAM) \
1371 output_file_start (STREAM)
1373 #define ASM_FILE_END(STREAM)
1375 #define ASM_APP_ON ""
1376 #define ASM_APP_OFF ""
1377 #define FILE_ASM_OP "\t.file\n"
1378 #define IDENT_ASM_OP "\t.ident\n"
1379 #define SET_ASM_OP ".set"
1381 /* How to change between sections. */
1383 #define TEXT_SECTION_ASM_OP "\t.text"
1384 #define DATA_SECTION_ASM_OP "\t.data"
1385 #define CTORS_SECTION_ASM_OP "\t.section\t.ctors\n"
1386 #define DTORS_SECTION_ASM_OP "\t.section\t.dtors\n"
1387 #define EXTRA_SECTIONS in_ctors, in_dtors
1388 #define EXTRA_SECTION_FUNCTIONS \
1389 void \
1390 ctors_section() \
1392 if (in_section != in_ctors) \
1394 fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP); \
1395 in_section = in_ctors; \
1398 void \
1399 dtors_section() \
1401 if (in_section != in_dtors) \
1403 fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP); \
1404 in_section = in_dtors; \
1408 /* Define this so that jump tables go in same section as the current function,
1409 which could be text or it could be a user defined section. */
1410 #define JUMP_TABLES_IN_TEXT_SECTION
1412 /* A C statement to output something to the assembler file to switch to section
1413 NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or
1414 NULL_TREE. Some target formats do not support arbitrary sections. Do not
1415 define this macro in such cases. */
1417 #define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \
1418 do { fprintf (FILE, ".section\t%s\n", NAME); } while (0)
1420 #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
1421 do { ctors_section(); asm_fprintf((FILE),"\t.long\t%U%s\n", (NAME)); } while (0)
1423 #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
1424 do { dtors_section(); asm_fprintf((FILE),"\t.long\t%U%s\n", (NAME)); } while (0)
1426 #undef DO_GLOBAL_CTORS_BODY
1428 #define DO_GLOBAL_CTORS_BODY \
1430 typedef (*pfunc)(); \
1431 extern pfunc __ctors[]; \
1432 extern pfunc __ctors_end[]; \
1433 pfunc *p; \
1434 for (p = __ctors_end; p > __ctors; ) \
1436 (*--p)(); \
1440 #undef DO_GLOBAL_DTORS_BODY
1441 #define DO_GLOBAL_DTORS_BODY \
1443 typedef (*pfunc)(); \
1444 extern pfunc __dtors[]; \
1445 extern pfunc __dtors_end[]; \
1446 pfunc *p; \
1447 for (p = __dtors; p < __dtors_end; p++) \
1449 (*p)(); \
1453 #define ASM_OUTPUT_REG_PUSH(file, v) \
1454 fprintf ((file), "\tmov.l\tr%s,-@r15\n", (v));
1456 #define ASM_OUTPUT_REG_POP(file, v) \
1457 fprintf ((file), "\tmov.l\t@r15+,r%s\n", (v));
1459 /* The assembler's names for the registers. RFP need not always be used as
1460 the Real framepointer; it can also be used as a normal general register.
1461 Note that the name `fp' is horribly misleading since `fp' is in fact only
1462 the argument-and-return-context pointer. */
1463 #define REGISTER_NAMES \
1465 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
1466 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", \
1467 "ap", "pr", "t", "gbr", "mach","macl", "fpul","rap", \
1468 "fr0","fr1","fr2", "fr3", "fr4", "fr5", "fr6", "fr7", \
1469 "fr8","fr9","fr10","fr11","fr12","fr13","fr14","fr15",\
1472 /* DBX register number for a given compiler register number. */
1473 /* GDB has FPUL at 23 and FP0 at 25, so we must add one to all FP registers
1474 to match gdb. */
1475 #define DBX_REGISTER_NUMBER(REGNO) \
1476 (((REGNO) >= 22 && (REGNO) <= 39) ? ((REGNO) + 1) : (REGNO))
1478 /* Output a label definition. */
1479 #define ASM_OUTPUT_LABEL(FILE,NAME) \
1480 do { assemble_name ((FILE), (NAME)); fputs (":\n", (FILE)); } while (0)
1482 /* This is how to output an assembler line
1483 that says to advance the location counter
1484 to a multiple of 2**LOG bytes. */
1486 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
1487 if ((LOG) != 0) \
1488 fprintf ((FILE), "\t.align %d\n", (LOG))
1490 /* Output a function label definition. */
1491 #define ASM_DECLARE_FUNCTION_NAME(STREAM,NAME,DECL) \
1492 ASM_OUTPUT_LABEL((STREAM), (NAME))
1494 /* Output a globalising directive for a label. */
1495 #define ASM_GLOBALIZE_LABEL(STREAM,NAME) \
1496 (fprintf ((STREAM), "\t.global\t"), \
1497 assemble_name ((STREAM), (NAME)), \
1498 fputc ('\n', (STREAM)))
1500 /* The prefix to add to user-visible assembler symbols. */
1502 #define USER_LABEL_PREFIX "_"
1504 /* The prefix to add to an internally generated label. */
1506 #define LOCAL_LABEL_PREFIX ""
1508 /* Make an internal label into a string. */
1509 #define ASM_GENERATE_INTERNAL_LABEL(STRING, PREFIX, NUM) \
1510 sprintf ((STRING), "*%s%s%d", LOCAL_LABEL_PREFIX, (PREFIX), (NUM))
1512 /* Output an internal label definition. */
1513 #define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM) \
1514 asm_fprintf ((FILE), "%L%s%d:\n", (PREFIX), (NUM))
1516 /* #define ASM_OUTPUT_CASE_END(STREAM,NUM,TABLE) */
1518 /* Construct a private name. */
1519 #define ASM_FORMAT_PRIVATE_NAME(OUTVAR,NAME,NUMBER) \
1520 ((OUTVAR) = (char *) alloca (strlen (NAME) + 10), \
1521 sprintf ((OUTVAR), "%s.%d", (NAME), (NUMBER)))
1523 /* Jump tables must be 32 bit aligned, no matter the size of the element. */
1524 #define ASM_OUTPUT_CASE_LABEL(STREAM,PREFIX,NUM,TABLE) \
1525 fprintf ((STREAM), "\t.align 2\n%s%d:\n", (PREFIX), (NUM));
1527 /* Output a relative address table. */
1529 #define ASM_OUTPUT_ADDR_DIFF_ELT(STREAM,VALUE,REL) \
1530 switch (sh_addr_diff_vec_mode) \
1532 case SImode: \
1533 asm_fprintf ((STREAM), "\t.long\t%LL%d-%LL%d\n", (VALUE),(REL)); \
1534 break; \
1535 case HImode: \
1536 asm_fprintf ((STREAM), "\t.word\t%LL%d-%LL%d\n", (VALUE),(REL)); \
1537 break; \
1538 case QImode: \
1539 asm_fprintf ((STREAM), "\t.byte\t%LL%d-%LL%d\n", (VALUE),(REL)); \
1540 break; \
1543 /* Output an absolute table element. */
1545 #define ASM_OUTPUT_ADDR_VEC_ELT(STREAM,VALUE) \
1546 if (TARGET_BIGTABLE) \
1547 asm_fprintf ((STREAM), "\t.long\t%LL%d\n", (VALUE)); \
1548 else \
1549 asm_fprintf ((STREAM), "\t.word\t%LL%d\n", (VALUE)); \
1551 /* Output various types of constants. */
1553 /* This is how to output an assembler line defining a `double'. */
1555 #define ASM_OUTPUT_DOUBLE(FILE,VALUE) \
1556 do { char dstr[30]; \
1557 REAL_VALUE_TO_DECIMAL ((VALUE), "%.20e", dstr); \
1558 fprintf ((FILE), "\t.double %s\n", dstr); \
1559 } while (0)
1561 /* This is how to output an assembler line defining a `float' constant. */
1562 #define ASM_OUTPUT_FLOAT(FILE,VALUE) \
1563 do { char dstr[30]; \
1564 REAL_VALUE_TO_DECIMAL ((VALUE), "%.20e", dstr); \
1565 fprintf ((FILE), "\t.float %s\n", dstr); \
1566 } while (0)
1568 #define ASM_OUTPUT_INT(STREAM, EXP) \
1569 (fprintf ((STREAM), "\t.long\t"), \
1570 output_addr_const ((STREAM), (EXP)), \
1571 fputc ('\n', (STREAM)))
1573 #define ASM_OUTPUT_SHORT(STREAM, EXP) \
1574 (fprintf ((STREAM), "\t.short\t"), \
1575 output_addr_const ((STREAM), (EXP)), \
1576 fputc ('\n', (STREAM)))
1578 #define ASM_OUTPUT_CHAR(STREAM, EXP) \
1579 (fprintf ((STREAM), "\t.byte\t"), \
1580 output_addr_const ((STREAM), (EXP)), \
1581 fputc ('\n', (STREAM)))
1583 #define ASM_OUTPUT_BYTE(STREAM, VALUE) \
1584 fprintf ((STREAM), "\t.byte\t%d\n", (VALUE)) \
1586 /* The next two are used for debug info when compiling with -gdwarf. */
1587 #define UNALIGNED_SHORT_ASM_OP ".uaword"
1588 #define UNALIGNED_INT_ASM_OP ".ualong"
1590 /* Loop alignment is now done in machine_dependent_reorg, so that
1591 branch shortening can know about it. */
1593 /* This is how to output an assembler line
1594 that says to advance the location counter by SIZE bytes. */
1596 #define ASM_OUTPUT_SKIP(FILE,SIZE) \
1597 fprintf ((FILE), "\t.space %d\n", (SIZE))
1599 /* This says how to output an assembler line
1600 to define a global common symbol. */
1602 #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED) \
1603 ( fputs ("\t.comm ", (FILE)), \
1604 assemble_name ((FILE), (NAME)), \
1605 fprintf ((FILE), ",%d\n", (SIZE)))
1607 /* This says how to output an assembler line
1608 to define a local common symbol. */
1610 #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED) \
1611 ( fputs ("\t.lcomm ", (FILE)), \
1612 assemble_name ((FILE), (NAME)), \
1613 fprintf ((FILE), ",%d\n", (SIZE)))
1615 /* The assembler's parentheses characters. */
1616 #define ASM_OPEN_PAREN "("
1617 #define ASM_CLOSE_PAREN ")"
1619 /* Target characters. */
1620 #define TARGET_BELL 007
1621 #define TARGET_BS 010
1622 #define TARGET_TAB 011
1623 #define TARGET_NEWLINE 012
1624 #define TARGET_VT 013
1625 #define TARGET_FF 014
1626 #define TARGET_CR 015
1628 /* A C statement to be executed just prior to the output of
1629 assembler code for INSN, to modify the extracted operands so
1630 they will be output differently.
1632 Here the argument OPVEC is the vector containing the operands
1633 extracted from INSN, and NOPERANDS is the number of elements of
1634 the vector which contain meaningful data for this insn.
1635 The contents of this vector are what will be used to convert the insn
1636 template into assembler code, so you can change the assembler output
1637 by changing the contents of the vector. */
1639 #define FINAL_PRESCAN_INSN(INSN, OPVEC, NOPERANDS) \
1640 final_prescan_insn ((INSN), (OPVEC), (NOPERANDS))
1642 /* Print operand X (an rtx) in assembler syntax to file FILE.
1643 CODE is a letter or dot (`z' in `%z0') or 0 if no letter was specified.
1644 For `%' followed by punctuation, CODE is the punctuation and X is null. */
1646 #define PRINT_OPERAND(STREAM, X, CODE) print_operand ((STREAM), (X), (CODE))
1648 /* Print a memory address as an operand to reference that memory location. */
1650 #define PRINT_OPERAND_ADDRESS(STREAM,X) print_operand_address ((STREAM), (X))
1652 #define PRINT_OPERAND_PUNCT_VALID_P(CHAR) \
1653 ((CHAR) == '.' || (CHAR) == '#' || (CHAR) == '@' || (CHAR) == ',' \
1654 || (CHAR) == '$')
1656 extern struct rtx_def *sh_compare_op0;
1657 extern struct rtx_def *sh_compare_op1;
1658 extern struct rtx_def *prepare_scc_operands();
1660 /* Which processor to schedule for. The elements of the enumeration must
1661 match exactly the cpu attribute in the sh.md file. */
1663 enum processor_type {
1664 PROCESSOR_SH1,
1665 PROCESSOR_SH2,
1666 PROCESSOR_SH3,
1667 PROCESSOR_SH3E
1670 #define sh_cpu_attr ((enum attr_cpu)sh_cpu)
1671 extern enum processor_type sh_cpu;
1673 extern enum machine_mode sh_addr_diff_vec_mode;
1675 extern int optimize; /* needed for gen_casesi, and addr_diff_vec_adjust. */
1677 /* Declare functions defined in sh.c and used in templates. */
1679 extern char *output_branch();
1680 extern char *output_ieee_ccmpeq();
1681 extern char *output_branchy_insn();
1682 extern char *output_shift();
1683 extern char *output_movedouble();
1684 extern char *output_movepcrel();
1685 extern char *output_jump_label_table();
1686 extern char *output_far_jump();
1688 enum mdep_reorg_phase_e
1690 SH_BEFORE_MDEP_REORG,
1691 SH_INSERT_USES_LABELS,
1692 SH_SHORTEN_BRANCHES0,
1693 SH_FIXUP_PCLOAD,
1694 SH_SHORTEN_BRANCHES1,
1695 SH_AFTER_MDEP_REORG
1698 void machine_dependent_reorg ();
1699 int short_cbranch_p ();
1700 int med_branch_p ();
1701 int braf_branch_p ();
1702 int align_length ();
1703 int addr_diff_vec_adjust ();
1704 struct rtx_def *sfunc_uses_reg ();
1706 #define MACHINE_DEPENDENT_REORG(X) machine_dependent_reorg(X)
1708 /* Generate calls to memcpy, memcmp and memset. */
1710 #define TARGET_MEM_FUNCTIONS
1712 /* Define this macro if you want to implement any pragmas. If defined, it
1713 is a C expression to be executed when #pragma is seen. The
1714 argument FILE is the stdio input stream from which the source
1715 text can be read. CH is the first character after the #pragma. The
1716 result of the expression is the terminating character found
1717 (newline or EOF). */
1718 #define HANDLE_PRAGMA(FILE, NODE) handle_pragma ((FILE), (NODE))
1720 /* Set when processing a function with pragma interrupt turned on. */
1722 extern int pragma_interrupt;
1724 /* Set to an RTX containing the address of the stack to switch to
1725 for interrupt functions. */
1726 extern struct rtx_def *sp_switch;
1728 /* A C expression whose value is nonzero if IDENTIFIER with arguments ARGS
1729 is a valid machine specific attribute for DECL.
1730 The attributes in ATTRIBUTES have previously been assigned to DECL. */
1731 extern int sh_valid_machine_decl_attribute ();
1732 #define VALID_MACHINE_DECL_ATTRIBUTE(DECL, ATTRIBUTES, IDENTIFIER, ARGS) \
1733 sh_valid_machine_decl_attribute (DECL, ATTRIBUTES, IDENTIFIER, ARGS)
1736 #define MOVE_RATIO (TARGET_SMALLCODE ? 2 : 16)
1738 /* Instructions with unfilled delay slots take up an extra two bytes for
1739 the nop in the delay slot. Instructions at the start of loops, or
1740 after unconditional branches, may take up extra room when they are
1741 aligned. ??? We would get more accurate results if we did instruction
1742 alignment based on the value of INSN_CURRENT_ADDRESS; the approach used
1743 here is too conservative. */
1745 #define ADJUST_INSN_LENGTH(X, LENGTH) \
1746 if (((GET_CODE (X) == INSN \
1747 && GET_CODE (PATTERN (X)) != USE \
1748 && GET_CODE (PATTERN (X)) != CLOBBER) \
1749 || GET_CODE (X) == CALL_INSN \
1750 || (GET_CODE (X) == JUMP_INSN \
1751 && GET_CODE (PATTERN (X)) != ADDR_DIFF_VEC \
1752 && GET_CODE (PATTERN (X)) != ADDR_VEC)) \
1753 && GET_CODE (PATTERN (NEXT_INSN (PREV_INSN (X)))) != SEQUENCE \
1754 && get_attr_needs_delay_slot (X) == NEEDS_DELAY_SLOT_YES) \
1755 (LENGTH) += 2; \
1756 if (GET_CODE (X) == INSN \
1757 && GET_CODE (PATTERN (X)) == UNSPEC_VOLATILE \
1758 && XINT (PATTERN (X), 1) == 7) \
1759 (LENGTH) -= addr_diff_vec_adjust (X, LENGTH); \
1760 if (GET_CODE (X) == INSN \
1761 && GET_CODE (PATTERN (X)) == UNSPEC_VOLATILE \
1762 && XINT (PATTERN (X), 1) == 1) \
1763 (LENGTH) = align_length (X); \
1764 if (GET_CODE (X) == JUMP_INSN \
1765 && GET_CODE (PATTERN (X)) == ADDR_DIFF_VEC) \
1767 /* The code before an ADDR_DIFF_VEC is even aligned, \
1768 thus any odd estimate is wrong. */ \
1769 (LENGTH) &= ~1; \
1770 /* If not optimizing, the alignment is implicit. */ \
1771 if (! optimize) \
1772 (LENGTH) += 2; \
1775 /* Enable a bug fix for the shorten_branches pass. */
1776 #define SHORTEN_WITH_ADJUST_INSN_LENGTH
1778 /* Define the codes that are matched by predicates in sh.c. */
1779 #define PREDICATE_CODES \
1780 {"arith_operand", {SUBREG, REG, CONST_INT}}, \
1781 {"arith_reg_operand", {SUBREG, REG}}, \
1782 {"arith_reg_or_0_operand", {SUBREG, REG, CONST_INT}}, \
1783 {"braf_label_ref_operand", {LABEL_REF}}, \
1784 {"general_movsrc_operand", {SUBREG, REG, CONST_INT, MEM}}, \
1785 {"general_movdst_operand", {SUBREG, REG, CONST_INT, MEM}}, \
1786 {"logical_operand", {SUBREG, REG, CONST_INT}}, \
1787 {"register_operand", {SUBREG, REG}},
1789 /* Define this macro if it is advisable to hold scalars in registers
1790 in a wider mode than that declared by the program. In such cases,
1791 the value is constrained to be within the bounds of the declared
1792 type, but kept valid in the wider mode. The signedness of the
1793 extension may differ from that of the type.
1795 Leaving the unsignedp unchanged gives better code than always setting it
1796 to 0. This is despite the fact that we have only signed char and short
1797 load instructions. */
1798 #define PROMOTE_MODE(MODE, UNSIGNEDP, TYPE) \
1799 if (GET_MODE_CLASS (MODE) == MODE_INT \
1800 && GET_MODE_SIZE (MODE) < UNITS_PER_WORD) \
1801 (MODE) = SImode;
1803 /* Defining PROMOTE_FUNCTION_ARGS eliminates some unnecessary zero/sign
1804 extensions applied to char/short functions arguments. Defining
1805 PROMOTE_FUNCTION_RETURN does the same for function returns. */
1807 #define PROMOTE_FUNCTION_ARGS
1808 #define PROMOTE_FUNCTION_RETURN
1810 /* ??? Define ACCUMULATE_OUTGOING_ARGS? This is more efficient than pushing
1811 and poping arguments. However, we do have push/pop instructions, and
1812 rather limited offsets (4 bits) in load/store instructions, so it isn't
1813 clear if this would give better code. If implemented, should check for
1814 compatibility problems. */
1816 /* A C statement (sans semicolon) to update the integer variable COST
1817 based on the relationship between INSN that is dependent on
1818 DEP_INSN through the dependence LINK. The default is to make no
1819 adjustment to COST. This can be used for example to specify to
1820 the scheduler that an output- or anti-dependence does not incur
1821 the same cost as a data-dependence. */
1823 #define ADJUST_COST(insn,link,dep_insn,cost) \
1824 do { \
1825 rtx reg; \
1827 if (GET_CODE(insn) == CALL_INSN) \
1829 /* The only input for a call that is timing-critical is the \
1830 function's address. */ \
1831 rtx call = PATTERN (insn); \
1833 if (GET_CODE (call) == PARALLEL) \
1834 call = XVECEXP (call, 0 ,0); \
1835 if (GET_CODE (call) == SET) \
1836 call = SET_SRC (call); \
1837 if (GET_CODE (call) == CALL && GET_CODE (XEXP (call, 0)) == MEM \
1838 && ! reg_set_p (XEXP (XEXP (call, 0), 0), dep_insn)) \
1839 (cost) = 0; \
1841 /* All sfunc calls are parallels with at least four components. \
1842 Exploit this to avoid unnecessary calls to sfunc_uses_reg. */ \
1843 else if (GET_CODE (PATTERN (insn)) == PARALLEL \
1844 && XVECLEN (PATTERN (insn), 0) >= 4 \
1845 && (reg = sfunc_uses_reg (insn))) \
1847 /* Likewise, the most timing critical input for an sfuncs call \
1848 is the function address. However, sfuncs typically start \
1849 using their arguments pretty quickly. \
1850 Assume a four cycle delay before they are needed. */ \
1851 if (! reg_set_p (reg, dep_insn)) \
1852 cost -= 4; \
1854 /* Adjust load_si / pcload_si type insns latency. Use the known \
1855 nominal latency and form of the insn to speed up the check. */ \
1856 else if (cost == 3 \
1857 && GET_CODE (PATTERN (dep_insn)) == SET \
1858 /* Latency for dmpy type insns is also 3, so check the that \
1859 it's actually a move insn. */ \
1860 && general_movsrc_operand (SET_SRC (PATTERN (dep_insn)), SImode))\
1861 cost = 2; \
1862 } while (0) \
1864 /* Since the SH architecture lacks negative address offsets,
1865 the givs should be sorted smallest to largest so combine_givs
1866 has maximum opportunity to combine givs. */
1867 #define GIV_SORT_CRITERION(X, Y) \
1868 if (GET_CODE ((X)->add_val) == CONST_INT \
1869 && GET_CODE ((Y)->add_val) == CONST_INT) \
1870 return INTVAL ((X)->add_val) - INTVAL ((Y)->add_val);
1872 /* For the sake of libgcc2.c, indicate target supports atexit. */
1873 #define HAVE_ATEXIT
1875 #define SH_DYNAMIC_SHIFT_COST (TARGET_SH3 ? (TARGET_SMALLCODE ? 1 : 2) : 20)