OSDN Git Service

* sh.h (CONST_DOUBLE_OK_FOR_LETTER_P): always true for 'F' .
[pf3gnuchains/gcc-fork.git] / gcc / config / sh / sh.h
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).
5
6 This file is part of GNU CC.
7
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.
12
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.
17
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.  */
22
23
24 #define TARGET_VERSION \
25   fputs (" (Hitachi SH)", stderr);
26
27 /* Generate SDB debugging information.  */
28
29 #define SDB_DEBUGGING_INFO
30
31 /* Output DBX (stabs) debugging information if doing -gstabs.  */
32
33 #include "dbxcoff.h"
34
35 #define SDB_DELIM ";"
36
37 #define CPP_SPEC "%{ml:-D__LITTLE_ENDIAN__} \
38 %{m1:-D__sh1__} \
39 %{m2:-D__sh2__} \
40 %{m3:-D__sh3__} \
41 %{m3e:-D__SH3E__}"
42
43 #define CPP_PREDEFINES "-D__sh__ -Acpu(sh) -Amachine(sh)"
44
45 #define ASM_SPEC  "%{ml:-little} %{mrelax:-relax}"
46
47 #define LINK_SPEC "%{ml:-m shl} %{mrelax:-relax}"
48
49 /* We can not debug without a frame pointer.  */
50 /* #define CAN_DEBUG_WITHOUT_FP */
51
52 #define CONDITIONAL_REGISTER_USAGE                              \
53   if (! TARGET_SH3E)                                            \
54     {                                                           \
55       int regno;                                                \
56       for (regno = FIRST_FP_REG; regno <= LAST_FP_REG; regno++) \
57         fixed_regs[regno] = call_used_regs[regno] = 1;          \
58     }                                                           \
59   /* Hitachi saves and restores mac registers on call.  */      \
60   if (TARGET_HITACHI)                                           \
61     {                                                           \
62       call_used_regs[MACH_REG] = 0;                             \
63       call_used_regs[MACL_REG] = 0;                             \
64     }
65 \f
66 /* ??? Need to write documentation for all SH options and add it to the
67    invoke.texi file.  */
68
69 /* Run-time compilation parameters selecting different hardware subsets.  */
70
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)
85
86 /* Nonzero if we should dump out instruction size info.  */
87 #define TARGET_DUMPISIZE  (target_flags & ISIZE_BIT)
88
89 /* Nonzero to align doubles on 64 bit boundaries.  */
90 #define TARGET_ALIGN_DOUBLE (target_flags & DALIGN_BIT)
91
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
94    references to it.  */
95 #define TARGET_SH0 (target_flags & SH0_BIT)
96
97 /* Nonzero if we should generate code using type 1 insns.  */
98 #define TARGET_SH1 (target_flags & SH1_BIT)
99
100 /* Nonzero if we should generate code using type 2 insns.  */
101 #define TARGET_SH2 (target_flags & SH2_BIT)
102
103 /* Nonzero if we should generate code using type 3 insns.  */
104 #define TARGET_SH3 (target_flags & SH3_BIT)
105
106 /* Nonzero if we should generate code using type 3E insns.  */
107 #define TARGET_SH3E (target_flags & SH3E_BIT)
108
109 /* Nonzero if we should generate smaller code rather than faster code.  */
110 #define TARGET_SMALLCODE   (target_flags & SPACE_BIT)
111
112 /* Nonzero to use long jump tables.  */
113 #define TARGET_BIGTABLE     (target_flags & BIGTABLE_BIT)
114
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)
118
119 /* Nonzero if using Hitachi's calling convention.  */
120 #define TARGET_HITACHI          (target_flags & HITACHI_BIT)
121
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)
128
129 /* Nonzero if generating code for a little endian SH.  */
130 #define TARGET_LITTLE_ENDIAN     (target_flags & LITTLE_ENDIAN_BIT)
131
132 #define TARGET_SWITCHES                         \
133 { {"0",         SH0_BIT},                       \
134   {"1",         SH1_BIT},                       \
135   {"2",         SH2_BIT},                       \
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}                 \
148 }
149
150 #define TARGET_DEFAULT  (0)
151
152 #define PRESERVE_DEATH_INFO_REGNO_P(regno) (TARGET_RELAX || optimize)
153
154 #define OVERRIDE_OPTIONS                                        \
155 do {                                                            \
156   sh_cpu = CPU_SH0;                                             \
157   if (TARGET_SH1)                                               \
158     sh_cpu = CPU_SH1;                                           \
159   if (TARGET_SH2)                                               \
160     sh_cpu = CPU_SH2;                                           \
161   if (TARGET_SH3)                                               \
162     sh_cpu = CPU_SH3;                                           \
163   if (TARGET_SH3E)                                              \
164     sh_cpu = CPU_SH3E;                                          \
165                                                                 \
166   /* Never run scheduling before reload, since that can         \
167      break global alloc, and generates slower code anyway due   \
168      to the pressure on R0.  */                                 \
169   flag_schedule_insns = 0;                                      \
170 } while (0)
171 \f
172 /* Target machine storage layout.  */
173
174 /* Define to use software floating point emulator for REAL_ARITHMETIC and
175    decimal <-> binary conversion.  */
176 #define REAL_ARITHMETIC
177
178 /* Define this if most significant bit is lowest numbered
179    in instructions that operate on numbered bit-fields.  */
180
181 #define BITS_BIG_ENDIAN  0
182
183 /* Define this if most significant byte of a word is the lowest numbered.  */
184 #define BYTES_BIG_ENDIAN (TARGET_LITTLE_ENDIAN == 0)
185
186 /* Define this if most significant word of a multiword number is the lowest
187    numbered.  */
188 #define WORDS_BIG_ENDIAN (TARGET_LITTLE_ENDIAN == 0)
189
190 /* Define this to set the endianness to use in libgcc2.c, which can
191    not depend on target_flags.  */
192 #if defined(__LITTLE_ENDIAN__)
193 #define LIBGCC2_WORDS_BIG_ENDIAN 0
194 #else
195 #define LIBGCC2_WORDS_BIG_ENDIAN 1
196 #endif
197
198 /* Number of bits in an addressable storage unit.  */
199 #define BITS_PER_UNIT  8
200
201 /* Width in bits of a "word", which is the contents of a machine register.
202    Note that this is not necessarily the width of data type `int';
203    if using 16-bit ints on a 68000, this would still be 32.
204    But on a machine with 16-bit registers, this would be 16.  */
205 #define BITS_PER_WORD  32
206 #define MAX_BITS_PER_WORD 32
207
208 /* Width of a word, in units (bytes).  */
209 #define UNITS_PER_WORD  4
210
211 /* Width in bits of a pointer.
212    See also the macro `Pmode' defined below.  */
213 #define POINTER_SIZE  32
214
215 /* Allocation boundary (in *bits*) for storing arguments in argument list.  */
216 #define PARM_BOUNDARY   32
217
218 /* Boundary (in *bits*) on which stack pointer should be aligned.  */
219 #define STACK_BOUNDARY  32
220
221 /* Allocation boundary (in *bits*) for the code of a function.
222    32 bit alignment is faster, because instructions are always fetched as a
223    pair from a longword boundary.  */
224 #define FUNCTION_BOUNDARY  (TARGET_SMALLCODE ? 16 : 32)
225
226 /* Alignment of field after `int : 0' in a structure.  */
227 #define EMPTY_FIELD_BOUNDARY  32
228
229 /* No data type wants to be aligned rounder than this.  */
230 #define BIGGEST_ALIGNMENT  (TARGET_ALIGN_DOUBLE ? 64 : 32)
231
232 /* The best alignment to use in cases where we have a choice.  */
233 #define FASTEST_ALIGNMENT 32
234
235 /* Make strings word-aligned so strcpy from constants will be faster.  */
236 #define CONSTANT_ALIGNMENT(EXP, ALIGN)  \
237   ((TREE_CODE (EXP) == STRING_CST       \
238     && (ALIGN) < FASTEST_ALIGNMENT)     \
239     ? FASTEST_ALIGNMENT : (ALIGN))
240
241 /* Make arrays of chars word-aligned for the same reasons.  */
242 #define DATA_ALIGNMENT(TYPE, ALIGN)             \
243   (TREE_CODE (TYPE) == ARRAY_TYPE               \
244    && TYPE_MODE (TREE_TYPE (TYPE)) == QImode    \
245    && (ALIGN) < FASTEST_ALIGNMENT ? FASTEST_ALIGNMENT : (ALIGN))
246
247 /* Number of bits which any structure or union's size must be a
248    multiple of.  Each structure or union's size is rounded up to a
249    multiple of this.  */
250 #define STRUCTURE_SIZE_BOUNDARY (TARGET_PADSTRUCT ? 32 : 8)
251
252 /* Set this nonzero if move instructions will actually fail to work
253    when given unaligned data.  */
254 #define STRICT_ALIGNMENT 1
255 \f
256 /* Standard register usage.  */
257
258 /* Register allocation for the Hitachi calling convention:
259
260         r0              arg return
261         r1..r3          scratch
262         r4..r7          args in
263         r8..r13         call saved
264         r14             frame pointer/call saved
265         r15             stack pointer
266         ap              arg pointer (doesn't really exist, always eliminated)
267         pr              subroutine return address
268         t               t bit
269         mach            multiply/accumulate result, high part
270         macl            multiply/accumulate result, low part.
271         fpul            fp/int communication register
272         rap             return address pointer register
273         fr0             fp arg return
274         fr1..fr3        scratch floating point registers
275         fr4..fr11       fp args in
276         fr12..fr15      call saved floating point registers  */
277
278 /* Number of actual hardware registers.
279    The hardware registers are assigned numbers for the compiler
280    from 0 to just below FIRST_PSEUDO_REGISTER.
281    All registers that the compiler knows about must be given numbers,
282    even those that are not normally considered general registers.  */
283
284 #define AP_REG   16
285 #define PR_REG   17
286 #define T_REG    18
287 #define GBR_REG  19
288 #define MACH_REG 20
289 #define MACL_REG 21
290 #define SPECIAL_REG(REGNO) ((REGNO) >= 18 && (REGNO) <= 21)
291 #define FPUL_REG 22
292 #define RAP_REG 23
293 #define FIRST_FP_REG 24
294 #define LAST_FP_REG 39
295
296 #define FIRST_PSEUDO_REGISTER 40
297
298 /* 1 for registers that have pervasive standard uses
299    and are not available for the register allocator.
300
301    Mach register is fixed 'cause it's only 10 bits wide for SH1.
302    It is 32 bits wide for SH2.  */
303
304 #define FIXED_REGISTERS         \
305   { 0,  0,  0,  0,              \
306     0,  0,  0,  0,              \
307     0,  0,  0,  0,              \
308     0,  0,  0,  1,              \
309     1,  1,  1,  1,              \
310     1,  1,  1,  1,              \
311     0,  0,  0,  0,              \
312     0,  0,  0,  0,              \
313     0,  0,  0,  0,              \
314     0,  0,  0,  0               \
315 }
316
317 /* 1 for registers not available across function calls.
318    These must include the FIXED_REGISTERS and also any
319    registers that can be used without being saved.
320    The latter must include the registers where values are returned
321    and the register where structure-value addresses are passed.
322    Aside from that, you can include as many other registers as you like.  */
323
324 #define CALL_USED_REGISTERS     \
325   { 1,  1,  1,  1,              \
326     1,  1,  1,  1,              \
327     0,  0,  0,  0,              \
328     0,  0,  0,  1,              \
329     1,  0,  1,  1,              \
330     1,  1,  1,  1,              \
331     1,  1,  1,  1,              \
332     1,  1,  1,  1,              \
333     1,  1,  1,  1,              \
334     0,  0,  0,  0               \
335 }
336
337 /* Return number of consecutive hard regs needed starting at reg REGNO
338    to hold something of mode MODE.
339    This is ordinarily the length in words of a value of mode MODE
340    but can be less for certain modes in special long registers.
341
342    On the SH regs are UNITS_PER_WORD bits wide.  */
343
344 #define HARD_REGNO_NREGS(REGNO, MODE) \
345    (((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD))
346
347 /* Value is 1 if hard register REGNO can hold a value of machine-mode MODE.
348    We can allow any mode in any general register.  The special registers
349    only allow SImode.  Don't allow any mode in the PR.  */
350
351 #define HARD_REGNO_MODE_OK(REGNO, MODE)         \
352   (SPECIAL_REG (REGNO) ? (MODE) == SImode       \
353    : (REGNO) == FPUL_REG ? (MODE) == SImode || (MODE) == SFmode \
354    : (REGNO) >= FIRST_FP_REG && (REGNO) <= LAST_FP_REG ? (MODE) == SFmode \
355    : (REGNO) == PR_REG ? 0                      \
356    : 1)
357
358 /* Value is 1 if it is a good idea to tie two pseudo registers
359    when one has mode MODE1 and one has mode MODE2.
360    If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2,
361    for any hard reg, then this must be 0 for correct output.  */
362
363 #define MODES_TIEABLE_P(MODE1, MODE2) \
364   ((MODE1) == (MODE2) || GET_MODE_CLASS (MODE1) == GET_MODE_CLASS (MODE2))
365
366 /* Specify the registers used for certain standard purposes.
367    The values of these macros are register numbers.  */
368
369 /* Define this if the program counter is overloaded on a register.  */
370 /* #define PC_REGNUM            15*/
371
372 /* Register to use for pushing function arguments.  */
373 #define STACK_POINTER_REGNUM    15
374
375 /* Base register for access to local variables of the function.  */
376 #define FRAME_POINTER_REGNUM    14
377
378 /* Fake register that holds the address on the stack of the
379    current function's return address.  */
380 #define RETURN_ADDRESS_POINTER_REGNUM 23
381
382 /* Value should be nonzero if functions must have frame pointers.
383    Zero means the frame pointer need not be set up (and parms may be accessed
384    via the stack pointer) in functions that seem suitable.  */
385
386 #define FRAME_POINTER_REQUIRED  0
387
388 /* Definitions for register eliminations.
389
390    We have two registers that can be eliminated on the SH.  First, the
391    frame pointer register can often be eliminated in favor of the stack
392    pointer register.  Secondly, the argument pointer register can always be
393    eliminated; it is replaced with either the stack or frame pointer.  */
394
395 /* This is an array of structures.  Each structure initializes one pair
396    of eliminable registers.  The "from" register number is given first,
397    followed by "to".  Eliminations of the same "from" register are listed
398    in order of preference.  */
399
400 #define ELIMINABLE_REGS                                         \
401 {{ FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM},                 \
402  { RETURN_ADDRESS_POINTER_REGNUM, STACK_POINTER_REGNUM},        \
403  { RETURN_ADDRESS_POINTER_REGNUM, FRAME_POINTER_REGNUM},        \
404  { ARG_POINTER_REGNUM, STACK_POINTER_REGNUM},                   \
405  { ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM},}
406
407 /* Given FROM and TO register numbers, say whether this elimination
408    is allowed.  */
409 #define CAN_ELIMINATE(FROM, TO) \
410   (!((FROM) == FRAME_POINTER_REGNUM && FRAME_POINTER_REQUIRED))
411
412 /* Define the offset between two registers, one to be eliminated, and the other
413    its replacement, at the start of a routine.  */
414
415 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
416   OFFSET = initial_elimination_offset (FROM, TO)
417
418 /* Base register for access to arguments of the function.  */
419 #define ARG_POINTER_REGNUM      16
420
421 /* Register in which the static-chain is passed to a function.  */
422 #define STATIC_CHAIN_REGNUM     13
423
424 /* The register in which a struct value address is passed.  */
425
426 #define STRUCT_VALUE_REGNUM 2
427
428 /* If the structure value address is not passed in a register, define
429    `STRUCT_VALUE' as an expression returning an RTX for the place
430    where the address is passed.  If it returns 0, the address is
431    passed as an "invisible" first argument.  */
432
433 /*#define STRUCT_VALUE ((rtx)0)*/
434
435 /* Don't default to pcc-struct-return, because we have already specified
436    exactly how to return structures in the RETURN_IN_MEMORY macro.  */
437
438 #define DEFAULT_PCC_STRUCT_RETURN 0
439 \f
440 /* Define the classes of registers for register constraints in the
441    machine description.  Also define ranges of constants.
442
443    One of the classes must always be named ALL_REGS and include all hard regs.
444    If there is more than one class, another class must be named NO_REGS
445    and contain no registers.
446
447    The name GENERAL_REGS must be the name of a class (or an alias for
448    another name such as ALL_REGS).  This is the class of registers
449    that is allowed by "g" or "r" in a register constraint.
450    Also, registers outside this class are allocated only when
451    instructions express preferences for them.
452
453    The classes must be numbered in nondecreasing order; that is,
454    a larger-numbered class must never be contained completely
455    in a smaller-numbered class.
456
457    For any two classes, it is very desirable that there be another
458    class that represents their union.  */
459
460 /* The SH has two sorts of general registers, R0 and the rest.  R0 can
461    be used as the destination of some of the arithmetic ops. There are
462    also some special purpose registers; the T bit register, the
463    Procedure Return Register and the Multiply Accumulate Registers.  */
464
465 enum reg_class
466 {
467   NO_REGS,
468   R0_REGS,
469   PR_REGS,
470   T_REGS,
471   MAC_REGS,
472   GENERAL_REGS,
473   FPUL_REGS,
474   FP0_REGS,
475   FP_REGS,
476   GENERAL_FP_REGS,
477   ALL_REGS,
478   LIM_REG_CLASSES
479 };
480
481 #define N_REG_CLASSES  (int) LIM_REG_CLASSES
482
483 /* Give names of register classes as strings for dump file.  */
484 #define REG_CLASS_NAMES \
485 {                       \
486   "NO_REGS",            \
487   "R0_REGS",            \
488   "PR_REGS",            \
489   "T_REGS",             \
490   "MAC_REGS",           \
491   "GENERAL_REGS",       \
492   "FPUL_REGS",          \
493   "FP0_REGS",           \
494   "FP_REGS",            \
495   "GENERAL_FP_REGS",    \
496   "ALL_REGS",           \
497 }
498
499 /* Define which registers fit in which classes.
500    This is an initializer for a vector of HARD_REG_SET
501    of length N_REG_CLASSES.  */
502
503 #define REG_CLASS_CONTENTS                              \
504 {                                                       \
505   { 0x00000000, 0x00000000 }, /* NO_REGS        */      \
506   { 0x00000001, 0x00000000 }, /* R0_REGS        */      \
507   { 0x00020000, 0x00000000 }, /* PR_REGS        */      \
508   { 0x00040000, 0x00000000 }, /* T_REGS         */      \
509   { 0x00300000, 0x00000000 }, /* MAC_REGS       */      \
510   { 0x0001FFFF, 0x00000000 }, /* GENERAL_REGS   */      \
511   { 0x00400000, 0x00000000 }, /* FPUL_REGS      */      \
512   { 0x01000000, 0x00000000 }, /* FP0_REGS       */      \
513   { 0xFF000000, 0x000000FF }, /* FP_REGS        */      \
514   { 0xFF01FFFF, 0x000000FF }, /* GENERAL_FP_REGS */     \
515   { 0xFF7FFFFF, 0x000000FF }, /* ALL_REGS       */      \
516 }
517
518 /* The same information, inverted:
519    Return the class number of the smallest class containing
520    reg number REGNO.  This could be a conditional expression
521    or could index an array.  */
522
523 extern int regno_reg_class[];
524 #define REGNO_REG_CLASS(REGNO) regno_reg_class[REGNO]
525
526 /* When defined, the compiler allows registers explicitly used in the
527    rtl to be used as spill registers but prevents the compiler from
528    extending the lifetime of these registers.  */
529
530 #define SMALL_REGISTER_CLASSES
531
532 /* The order in which register should be allocated.  */
533 #define REG_ALLOC_ORDER \
534   { 1,2,3,7,6,5,4,0,8,9,10,11,12,13,14,                 \
535     24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,    \
536     22,15,16,17,18,19,20,21,23 }
537
538 /* The class value for index registers, and the one for base regs.  */
539 #define INDEX_REG_CLASS  R0_REGS
540 #define BASE_REG_CLASS   GENERAL_REGS
541
542 /* Get reg_class from a letter such as appears in the machine
543    description.  */
544 extern enum reg_class reg_class_from_letter[];
545
546 #define REG_CLASS_FROM_LETTER(C) \
547    ( (C) >= 'a' && (C) <= 'z' ? reg_class_from_letter[(C)-'a'] : NO_REGS )
548 \f
549 /* The letters I, J, K, L and M in a register constraint string
550    can be used to stand for particular ranges of immediate operands.
551    This macro defines what the ranges are.
552    C is the letter, and VALUE is a constant value.
553    Return 1 if VALUE is in the range specified by C.
554         I: arithmetic operand -127..128, as used in add, sub, etc
555         K: shift operand 1,2,8 or 16
556         L: logical operand 0..255, as used in and, or, etc.
557         M: constant 1
558         N: constant 0  */
559
560 #define CONST_OK_FOR_I(VALUE) (((int)(VALUE))>= -128 && ((int)(VALUE)) <= 127)
561 #define CONST_OK_FOR_K(VALUE) ((VALUE)==1||(VALUE)==2||(VALUE)==8||(VALUE)==16)
562 #define CONST_OK_FOR_L(VALUE) (((int)(VALUE))>=    0 && ((int)(VALUE)) <= 255)
563 #define CONST_OK_FOR_M(VALUE) ((VALUE)==1)
564 #define CONST_OK_FOR_N(VALUE) ((VALUE)==0)
565 #define CONST_OK_FOR_LETTER_P(VALUE, C)         \
566      ((C) == 'I' ? CONST_OK_FOR_I (VALUE)       \
567     : (C) == 'K' ? CONST_OK_FOR_K (VALUE)       \
568     : (C) == 'L' ? CONST_OK_FOR_L (VALUE)       \
569     : (C) == 'M' ? CONST_OK_FOR_M (VALUE)       \
570     : (C) == 'N' ? CONST_OK_FOR_N (VALUE)       \
571     : 0)
572
573 /* Similar, but for floating constants, and defining letters G and H.
574    Here VALUE is the CONST_DOUBLE rtx itself.  */
575
576 #define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C)  \
577 ((C) == 'G' ? fp_zero_operand (VALUE)           \
578  : (C) == 'H' ? fp_one_operand (VALUE)          \
579  : (C) == 'F')
580
581 /* Given an rtx X being reloaded into a reg required to be
582    in class CLASS, return the class of reg to actually use.
583    In general this is just CLASS; but on some machines
584    in some cases it is preferable to use a more restrictive class.  */
585
586 #define PREFERRED_RELOAD_CLASS(X, CLASS) CLASS
587
588 /* Return the maximum number of consecutive registers
589    needed to represent mode MODE in a register of class CLASS.
590
591    On SH this is the size of MODE in words.  */
592 #define CLASS_MAX_NREGS(CLASS, MODE) \
593      ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
594 \f
595 /* Stack layout; function entry, exit and calling.  */
596
597 /* Define the number of registers that can hold parameters.
598    These macros are used only in other macro definitions below.  */
599
600 #define NPARM_REGS(MODE) \
601   ((TARGET_SH3E && ((MODE) == SFmode)) ? 8 : 4)
602
603 #define FIRST_PARM_REG 4
604 #define FIRST_RET_REG  0
605
606 #define FIRST_FP_PARM_REG (FIRST_FP_REG + 4)
607 #define FIRST_FP_RET_REG FIRST_FP_REG
608
609 /* Define this if pushing a word on the stack
610    makes the stack pointer a smaller address.  */
611 #define STACK_GROWS_DOWNWARD
612
613 /*  Define this macro if the addresses of local variable slots are at
614     negative offsets from the frame pointer.
615
616     The SH only has positive indexes, so grow the frame up.  */
617 /* #define FRAME_GROWS_DOWNWARD */
618
619 /* Offset from the frame pointer to the first local variable slot to
620    be allocated.  */
621 #define STARTING_FRAME_OFFSET  0
622
623 /* If we generate an insn to push BYTES bytes,
624    this says how many the stack pointer really advances by.  */
625 #define PUSH_ROUNDING(NPUSHED)  (((NPUSHED) + 3) & ~3)
626
627 /* Offset of first parameter from the argument pointer register value.  */
628 #define FIRST_PARM_OFFSET(FNDECL)  0
629
630 /* Value is the number of byte of arguments automatically
631    popped when returning from a subroutine call.
632    FUNDECL is the declaration node of the function (as a tree),
633    FUNTYPE is the data type of the function (as a tree),
634    or for a library call it is an identifier node for the subroutine name.
635    SIZE is the number of bytes of arguments passed on the stack.
636
637    On the SH, the caller does not pop any of its arguments that were passed
638    on the stack.  */
639 #define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE)  0
640
641 /* Some subroutine macros specific to this machine. */
642
643 #define BASE_RETURN_VALUE_REG(MODE) \
644   ((TARGET_SH3E && ((MODE) == SFmode))                  \
645    ? FIRST_FP_RET_REG                                   \
646    : FIRST_RET_REG)
647
648 #define BASE_ARG_REG(MODE) \
649   ((TARGET_SH3E && ((MODE) == SFmode))                  \
650    ? FIRST_FP_PARM_REG                                  \
651    : FIRST_PARM_REG)
652
653 /* Define how to find the value returned by a function.
654    VALTYPE is the data type of the value (as a tree).
655    If the precise function being called is known, FUNC is its FUNCTION_DECL;
656    otherwise, FUNC is 0.  */
657
658 #define FUNCTION_VALUE(VALTYPE, FUNC) \
659   LIBCALL_VALUE (TYPE_MODE (VALTYPE))
660      
661 /* Define how to find the value returned by a library function
662    assuming the value has mode MODE.  */
663 #define LIBCALL_VALUE(MODE) \
664   gen_rtx (REG, MODE, BASE_RETURN_VALUE_REG (MODE));
665
666 /* 1 if N is a possible register number for a function value. */
667 #define FUNCTION_VALUE_REGNO_P(REGNO) \
668   ((REGNO) == FIRST_RET_REG || (TARGET_SH3E && (REGNO) == FIRST_FP_RET_REG))
669
670 /* 1 if N is a possible register number for function argument passing.  */
671 #define FUNCTION_ARG_REGNO_P(REGNO) \
672   (((REGNO) >= FIRST_PARM_REG && (REGNO) < (FIRST_PARM_REG + 4))        \
673    || (TARGET_SH3E                                                      \
674        && (REGNO) >= FIRST_FP_PARM_REG && (REGNO) < (FIRST_FP_PARM_REG + 8)))
675 \f
676 /* Define a data type for recording info about an argument list
677    during the scan of that argument list.  This data type should
678    hold all necessary information about the function itself
679    and about the args processed so far, enough to enable macros
680    such as FUNCTION_ARG to determine where the next arg should go.
681
682    On SH, this is a single integer, which is a number of words
683    of arguments scanned so far (including the invisible argument,
684    if any, which holds the structure-value-address).
685    Thus NARGREGS or more means all following args should go on the stack.  */
686
687 enum sh_arg_class { SH_ARG_INT = 0, SH_ARG_FLOAT = 1 };
688 struct sh_args {
689     int arg_count[2];
690 };
691
692 #define CUMULATIVE_ARGS  struct sh_args
693
694 #define GET_SH_ARG_CLASS(MODE) \
695   ((TARGET_SH3E && ((MODE) == SFmode)) ? SH_ARG_FLOAT : SH_ARG_INT)
696
697 #define ROUND_ADVANCE(SIZE) \
698   ((SIZE + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
699
700 /* Round a register number up to a proper boundary for an arg of mode
701    MODE.
702
703    The SH doesn't care about double alignment, so we only
704    round doubles to even regs when asked to explicitly.  */
705
706 #define ROUND_REG(CUM, MODE) \
707    ((TARGET_ALIGN_DOUBLE                                        \
708      && GET_MODE_UNIT_SIZE ((MODE)) > UNITS_PER_WORD)           \
709     ? ((CUM).arg_count[(int) GET_SH_ARG_CLASS (MODE)]           \
710        + ((CUM).arg_count[(int) GET_SH_ARG_CLASS (MODE)] & 1))  \
711     : (CUM).arg_count[(int) GET_SH_ARG_CLASS (MODE)])
712
713 /* Initialize a variable CUM of type CUMULATIVE_ARGS
714    for a call to a function whose data type is FNTYPE.
715    For a library call, FNTYPE is 0.
716
717    On SH, the offset always starts at 0: the first parm reg is always
718    the same reg.  */
719
720 #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, INDIRECT) \
721   do {                                                          \
722     (CUM).arg_count[(int) SH_ARG_INT] = 0;                      \
723     (CUM).arg_count[(int) SH_ARG_FLOAT] = 0;                    \
724   } while (0)
725
726 /* Update the data in CUM to advance over an argument
727    of mode MODE and data type TYPE.
728    (TYPE is null for libcalls where that information may not be
729    available.)  */
730
731 #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED)    \
732  ((CUM).arg_count[(int) GET_SH_ARG_CLASS (MODE)] =      \
733           (ROUND_REG ((CUM), (MODE))                    \
734            + ((MODE) != BLKmode                         \
735               ? ROUND_ADVANCE (GET_MODE_SIZE (MODE))    \
736               : ROUND_ADVANCE (int_size_in_bytes (TYPE)))))
737
738 /* Return boolean indicating arg of mode MODE will be passed in a reg.
739    This macro is only used in this file. */
740
741 #define PASS_IN_REG_P(CUM, MODE, TYPE) \
742   (ROUND_REG ((CUM), (MODE)) < NPARM_REGS (MODE)                \
743    && ((TYPE) == 0 || ! TREE_ADDRESSABLE ((tree)(TYPE)))        \
744    && (! TARGET_SH3E || (ROUND_REG((CUM), (MODE)) + (GET_MODE_SIZE(MODE)/4) <= NPARM_REGS (MODE))))
745
746 /* Define where to put the arguments to a function.
747    Value is zero to push the argument on the stack,
748    or a hard register in which to store the argument.
749
750    MODE is the argument's machine mode.
751    TYPE is the data type of the argument (as a tree).
752     This is null for libcalls where that information may
753     not be available.
754    CUM is a variable of type CUMULATIVE_ARGS which gives info about
755     the preceding args and about the function being called.
756    NAMED is nonzero if this argument is a named parameter
757     (otherwise it is an extra parameter matching an ellipsis).
758
759    On SH the first args are normally in registers
760    and the rest are pushed.  Any arg that starts within the first
761    NPARM_REGS words is at least partially passed in a register unless
762    its data type forbids.  */
763
764 #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
765   ((PASS_IN_REG_P ((CUM), (MODE), (TYPE))                       \
766     && (NAMED || TARGET_SH3E))                                  \
767    ? gen_rtx (REG, (MODE),                                      \
768               (BASE_ARG_REG (MODE) + ROUND_REG ((CUM), (MODE)))) \
769    : 0)
770
771 /* For an arg passed partly in registers and partly in memory,
772    this is the number of registers used.
773    For args passed entirely in registers or entirely in memory, zero.
774
775    We sometimes split args.  */
776
777 #define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) \
778   ((PASS_IN_REG_P ((CUM), (MODE), (TYPE))                       \
779     && (NAMED || TARGET_SH3E)                                   \
780     && (ROUND_REG ((CUM), (MODE))                               \
781         + (MODE != BLKmode                                      \
782            ? ROUND_ADVANCE (GET_MODE_SIZE (MODE))               \
783            : ROUND_ADVANCE (int_size_in_bytes (TYPE)))          \
784         - NPARM_REGS (MODE) > 0))                               \
785    ? NPARM_REGS (MODE) - ROUND_REG ((CUM), (MODE))              \
786    : 0)
787
788 extern int current_function_anonymous_args;
789
790 /* Perform any needed actions needed for a function that is receiving a
791    variable number of arguments.  */
792
793 #define SETUP_INCOMING_VARARGS(ASF, MODE, TYPE, PAS, ST) \
794   current_function_anonymous_args = 1;
795
796 /* Call the function profiler with a given profile label.
797    We use two .aligns, so as to make sure that both the .long is aligned
798    on a 4 byte boundary, and that the .long is a fixed distance (2 bytes)
799    from the trapa instruction.  */
800
801 #define FUNCTION_PROFILER(STREAM,LABELNO)                       \
802 {                                                               \
803         fprintf(STREAM, "       .align  2\n");                  \
804         fprintf(STREAM, "       trapa   #33\n");                \
805         fprintf(STREAM, "       .align  2\n");                  \
806         fprintf(STREAM, "       .long   LP%d\n", (LABELNO));    \
807 }
808
809 /* Define this macro if the code for function profiling should come
810    before the function prologue.  Normally, the profiling code comes
811    after.  */
812
813 #define PROFILE_BEFORE_PROLOGUE
814
815 /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
816    the stack pointer does not matter.  The value is tested only in
817    functions that have frame pointers.
818    No definition is equivalent to always zero.  */
819
820 #define EXIT_IGNORE_STACK 1
821
822 /* Generate the assembly code for function exit
823    Just dump out any accumulated constant table.  */
824
825 #define FUNCTION_EPILOGUE(STREAM, SIZE)  function_epilogue (STREAM, SIZE)
826
827 /* Output assembler code for a block containing the constant parts
828    of a trampoline, leaving space for the variable parts.
829
830    On the SH, the trampoline looks like
831    1 0000 D301                  mov.l   l1,r3
832    2 0002 DD02                  mov.l   l2,r13
833    3 0004 4D2B                  jmp     @r13
834    4 0006 200B                  or      r0,r0
835    5 0008 00000000      l1:     .long   function
836    6 000c 00000000      l2:     .long   area  */
837 #define TRAMPOLINE_TEMPLATE(FILE)               \
838 {                                               \
839   fprintf ((FILE), "    .word   0xd301\n");     \
840   fprintf ((FILE), "    .word   0xdd02\n");     \
841   fprintf ((FILE), "    .word   0x4d2b\n");     \
842   fprintf ((FILE), "    .word   0x200b\n");     \
843   fprintf ((FILE), "    .long   0\n");          \
844   fprintf ((FILE), "    .long   0\n");          \
845 }
846
847 /* Length in units of the trampoline for entering a nested function.  */
848 #define TRAMPOLINE_SIZE  16
849
850 /* Alignment required for a trampoline in units.  */
851 #define TRAMPOLINE_ALIGN  4
852
853 /* Emit RTL insns to initialize the variable parts of a trampoline.
854    FNADDR is an RTX for the address of the function's pure code.
855    CXT is an RTX for the static chain value for the function.  */
856
857 #define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT)                       \
858 {                                                                       \
859   emit_move_insn (gen_rtx (MEM, SImode, plus_constant ((TRAMP), 8)),    \
860                   (CXT));                                               \
861   emit_move_insn (gen_rtx (MEM, SImode, plus_constant ((TRAMP), 12)),   \
862                   (FNADDR));                                            \
863 }
864
865 /* A C expression whose value is RTL representing the value of the return
866    address for the frame COUNT steps up from the current frame.
867    FRAMEADDR is already the frame pointer of the COUNT frame, so we
868    can ignore COUNT.  */
869
870 #define RETURN_ADDR_RTX(COUNT, FRAME)   \
871   ((COUNT == 0)                         \
872    ? gen_rtx (MEM, Pmode, gen_rtx (REG, Pmode, RETURN_ADDRESS_POINTER_REGNUM)) \
873    : (rtx) 0)
874 \f
875 /* Generate necessary RTL for __builtin_saveregs().
876    ARGLIST is the argument list; see expr.c.  */
877 extern struct rtx_def *sh_builtin_saveregs ();
878 #define EXPAND_BUILTIN_SAVEREGS(ARGLIST) sh_builtin_saveregs (ARGLIST)
879 \f
880 /* Addressing modes, and classification of registers for them.  */
881 #define HAVE_POST_INCREMENT  1
882 /*#define HAVE_PRE_INCREMENT   1*/
883 /*#define HAVE_POST_DECREMENT  1*/
884 #define HAVE_PRE_DECREMENT   1
885
886 /* Macros to check register numbers against specific register classes.  */
887
888 /* These assume that REGNO is a hard or pseudo reg number.
889    They give nonzero only if REGNO is a hard reg of the suitable class
890    or a pseudo reg currently allocated to a suitable hard reg.
891    Since they use reg_renumber, they are safe only once reg_renumber
892    has been allocated, which happens in local-alloc.c.  */
893
894 #define REGNO_OK_FOR_BASE_P(REGNO) \
895   ((REGNO) < PR_REG || (unsigned) reg_renumber[(REGNO)] < PR_REG)
896 #define REGNO_OK_FOR_INDEX_P(REGNO) \
897   ((REGNO) == 0 || (unsigned) reg_renumber[(REGNO)] == 0)
898
899 /* Maximum number of registers that can appear in a valid memory
900    address.  */
901
902 #define MAX_REGS_PER_ADDRESS 2
903
904 /* Recognize any constant value that is a valid address.  */
905
906 #define CONSTANT_ADDRESS_P(X)   (GET_CODE (X) == LABEL_REF)
907
908 /* Nonzero if the constant value X is a legitimate general operand.  */
909
910 #define LEGITIMATE_CONSTANT_P(X) \
911   (GET_CODE (X) != CONST_DOUBLE                                         \
912    || GET_MODE (X) == DFmode || GET_MODE (X) == SFmode                  \
913    || (TARGET_SH3E && (fp_zero_operand (X) || fp_one_operand (X))))
914
915 /* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
916    and check its validity for a certain class.
917    We have two alternate definitions for each of them.
918    The usual definition accepts all pseudo regs; the other rejects
919    them unless they have been allocated suitable hard regs.
920    The symbol REG_OK_STRICT causes the latter definition to be used.  */
921
922 #ifndef REG_OK_STRICT
923
924 /* Nonzero if X is a hard reg that can be used as a base reg
925    or if it is a pseudo reg.  */
926 #define REG_OK_FOR_BASE_P(X) \
927   (REGNO (X) <= 16 || REGNO (X) >= FIRST_PSEUDO_REGISTER)
928
929 /* Nonzero if X is a hard reg that can be used as an index
930    or if it is a pseudo reg.  */
931 #define REG_OK_FOR_INDEX_P(X) \
932   (REGNO (X) == 0 || REGNO (X) >= FIRST_PSEUDO_REGISTER)
933
934 /* Nonzero if X/OFFSET is a hard reg that can be used as an index
935    or if X is a pseudo reg.  */
936 #define SUBREG_OK_FOR_INDEX_P(X, OFFSET) \
937   ((REGNO (X) == 0 && OFFSET == 0) || REGNO (X) >= FIRST_PSEUDO_REGISTER)
938
939 #else
940
941 /* Nonzero if X is a hard reg that can be used as a base reg.  */
942 #define REG_OK_FOR_BASE_P(X) \
943   REGNO_OK_FOR_BASE_P (REGNO (X))
944
945 /* Nonzero if X is a hard reg that can be used as an index.  */
946 #define REG_OK_FOR_INDEX_P(X) \
947   REGNO_OK_FOR_INDEX_P (REGNO (X))
948
949 /* Nonzero if X/OFFSET is a hard reg that can be used as an index.  */
950 #define SUBREG_OK_FOR_INDEX_P(X, OFFSET) \
951   (REGNO_OK_FOR_INDEX_P (REGNO (X)) && OFFSET == 0)
952
953 #endif
954
955 /* The 'Q' constraint is a pc relative load operand.  */
956 #define EXTRA_CONSTRAINT_Q(OP)                                          \
957   (GET_CODE (OP) == MEM &&                                              \
958    ((GET_CODE (XEXP (OP, 0)) == LABEL_REF)                              \
959     || (GET_CODE (XEXP (OP, 0)) == CONST                                \
960         && GET_CODE (XEXP (XEXP (OP, 0), 0)) == PLUS                    \
961         && GET_CODE (XEXP (XEXP (XEXP (OP, 0), 0), 0)) == LABEL_REF     \
962         && GET_CODE (XEXP (XEXP (XEXP (OP, 0), 0), 1)) == CONST_INT)))
963
964 #define EXTRA_CONSTRAINT(OP, C)         \
965   ((C) == 'Q' ? EXTRA_CONSTRAINT_Q (OP) \
966    : 0)
967 \f
968 /* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression
969    that is a valid memory address for an instruction.
970    The MODE argument is the machine mode for the MEM expression
971    that wants to use this address.
972
973    The other macros defined here are used only in GO_IF_LEGITIMATE_ADDRESS.  */
974
975 #define MODE_DISP_OK_4(X,MODE) \
976 (GET_MODE_SIZE (MODE) == 4 && (unsigned) INTVAL (X) < 64        \
977  && ! (INTVAL (X) & 3) && ! (TARGET_SH3E && MODE == SFmode))
978 #define MODE_DISP_OK_8(X,MODE) ((GET_MODE_SIZE(MODE)==8) && ((unsigned)INTVAL(X)<60) && (!(INTVAL(X) &3)))
979
980 #define BASE_REGISTER_RTX_P(X)                          \
981   ((GET_CODE (X) == REG && REG_OK_FOR_BASE_P (X))       \
982    || (GET_CODE (X) == SUBREG                           \
983        && GET_CODE (SUBREG_REG (X)) == REG              \
984        && REG_OK_FOR_BASE_P (SUBREG_REG (X))))
985
986 /* Since this must be r0, which is a single register class, we must check
987    SUBREGs more carefully, to be sure that we don't accept one that extends
988    outside the class.  */
989 #define INDEX_REGISTER_RTX_P(X)                         \
990   ((GET_CODE (X) == REG && REG_OK_FOR_INDEX_P (X))      \
991    || (GET_CODE (X) == SUBREG                           \
992        && GET_CODE (SUBREG_REG (X)) == REG              \
993        && SUBREG_OK_FOR_INDEX_P (SUBREG_REG (X), SUBREG_WORD (X))))
994
995 /* Jump to LABEL if X is a valid address RTX.  This must also take
996    REG_OK_STRICT into account when deciding about valid registers, but it uses
997    the above macros so we are in luck.
998
999    Allow  REG
1000           REG+disp
1001           REG+r0
1002           REG++
1003           --REG  */
1004
1005 /* ??? The SH3e does not have the REG+disp addressing mode when loading values
1006    into the FRx registers.  We implement this by setting the maximum offset
1007    to zero when the value is SFmode.  This also restricts loading of SFmode
1008    values into the integer registers, but that can't be helped.  */
1009
1010 /* The SH allows a displacement in a QI or HI amode, but only when the
1011    other operand is R0. GCC doesn't handle this very well, so we forgo
1012    all of that.
1013
1014    A legitimate index for a QI or HI is 0, SI can be any number 0..63,
1015    DI can be any number 0..60.  */
1016
1017 #define GO_IF_LEGITIMATE_INDEX(MODE, OP, LABEL)                         \
1018   do {                                                                  \
1019     if (GET_CODE (OP) == CONST_INT)                                     \
1020       {                                                                 \
1021         if (MODE_DISP_OK_4 (OP, MODE))  goto LABEL;                     \
1022         if (MODE_DISP_OK_8 (OP, MODE))  goto LABEL;                     \
1023       }                                                                 \
1024   } while(0)
1025
1026 #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, LABEL)                        \
1027 {                                                                       \
1028   if (BASE_REGISTER_RTX_P (X))                                          \
1029     goto LABEL;                                                         \
1030   else if ((GET_CODE (X) == POST_INC || GET_CODE (X) == PRE_DEC)        \
1031            && BASE_REGISTER_RTX_P (XEXP (X, 0)))                        \
1032     goto LABEL;                                                         \
1033   else if (GET_CODE (X) == PLUS)                                        \
1034     {                                                                   \
1035       rtx xop0 = XEXP (X, 0);                                           \
1036       rtx xop1 = XEXP (X, 1);                                           \
1037       if (GET_MODE_SIZE (MODE) <= 8 && BASE_REGISTER_RTX_P (xop0))      \
1038         GO_IF_LEGITIMATE_INDEX (MODE, xop1, LABEL);                     \
1039       if (GET_MODE_SIZE (MODE) <= 4)                                    \
1040         {                                                               \
1041           if (BASE_REGISTER_RTX_P (xop1) && INDEX_REGISTER_RTX_P (xop0))\
1042             goto LABEL;                                                 \
1043           if (INDEX_REGISTER_RTX_P (xop1) && BASE_REGISTER_RTX_P (xop0))\
1044             goto LABEL;                                                 \
1045         }                                                               \
1046     }                                                                   \
1047 }
1048 \f
1049 /* Try machine-dependent ways of modifying an illegitimate address
1050    to be legitimate.  If we find one, return the new, valid address.
1051    This macro is used in only one place: `memory_address' in explow.c.
1052
1053    OLDX is the address as it was before break_out_memory_refs was called.
1054    In some cases it is useful to look at this to decide what needs to be done.
1055
1056    MODE and WIN are passed so that this macro can use
1057    GO_IF_LEGITIMATE_ADDRESS.
1058
1059    It is always safe for this macro to do nothing.  It exists to recognize
1060    opportunities to optimize the output.
1061
1062    For the SH, if X is almost suitable for indexing, but the offset is
1063    out of range, convert it into a normal form so that cse has a chance
1064    of reducing the number of address registers used.  */
1065
1066 #define LEGITIMIZE_ADDRESS(X,OLDX,MODE,WIN)                     \
1067 {                                                               \
1068   if (GET_CODE (X) == PLUS                                      \
1069       && (GET_MODE_SIZE (MODE) == 4                             \
1070           || GET_MODE_SIZE (MODE) == 8)                         \
1071       && GET_CODE (XEXP (X, 1)) == CONST_INT                    \
1072       && BASE_REGISTER_RTX_P (XEXP (X, 0))                      \
1073       && ! (TARGET_SH3E && MODE == SFmode))                     \
1074     {                                                           \
1075       rtx index_rtx = XEXP (X, 1);                              \
1076       HOST_WIDE_INT offset = INTVAL (index_rtx), offset_base;   \
1077       rtx sum;                                                  \
1078                                                                 \
1079       GO_IF_LEGITIMATE_INDEX (MODE, index_rtx, WIN);            \
1080       /* On rare occasions, we might get an unaligned pointer   \
1081          that is indexed in a way to give an aligned address.   \
1082          Therefore, keep the lower two bits in offset_base.  */ \
1083       /* Instead of offset_base 128..131 use 124..127, so that  \
1084          simple add suffices.  */                               \
1085       if (offset > 127)                                         \
1086         {                                                       \
1087           offset_base = ((offset + 4) & ~60) - 4;               \
1088         }                                                       \
1089       else                                                      \
1090         offset_base = offset & ~60;                             \
1091       /* Sometimes the normal form does not suit DImode.  We    \
1092          could avoid that by using smaller ranges, but that     \
1093          would give less optimized code when SImode is          \
1094          prevalent.  */                                         \
1095       if (GET_MODE_SIZE (MODE) + offset - offset_base <= 64)    \
1096         {                                                       \
1097           sum = expand_binop (Pmode, add_optab, XEXP (X, 0),    \
1098                               GEN_INT (offset_base), NULL_RTX, 0, \
1099                               OPTAB_LIB_WIDEN);                 \
1100                                                                 \
1101           (X) = gen_rtx (PLUS, Pmode, sum, GEN_INT (offset - offset_base)); \
1102           goto WIN;                                             \
1103         }                                                       \
1104     }                                                           \
1105 }
1106
1107 /* Go to LABEL if ADDR (a legitimate address expression)
1108    has an effect that depends on the machine mode it is used for.  */
1109 #define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR,LABEL)                        \
1110 {                                                                       \
1111   if (GET_CODE(ADDR) == PRE_DEC || GET_CODE(ADDR) == POST_INC)          \
1112     goto LABEL;                                                         \
1113 }
1114 \f
1115 /* Specify the machine mode that this machine uses
1116    for the index in the tablejump instruction.  */
1117 #define CASE_VECTOR_MODE (TARGET_BIGTABLE ? SImode : HImode)
1118
1119 /* Define this if the tablejump instruction expects the table
1120    to contain offsets from the address of the table.
1121    Do not define this if the table should contain absolute addresses.  */
1122 #define CASE_VECTOR_PC_RELATIVE
1123
1124 /* Specify the tree operation to be used to convert reals to integers.  */
1125 #define IMPLICIT_FIX_EXPR  FIX_ROUND_EXPR
1126
1127 /* This is the kind of divide that is easiest to do in the general case.  */
1128 #define EASY_DIV_EXPR  TRUNC_DIV_EXPR
1129
1130 /* Since the SH3e has only `float' support, it is desirable to make all
1131    floating point types equivalent to `float'.  */
1132 #define DOUBLE_TYPE_SIZE (TARGET_SH3E ? 32 : 64)
1133
1134 /* 'char' is signed by default.  */
1135 #define DEFAULT_SIGNED_CHAR  1
1136
1137 /* The type of size_t unsigned int.  */
1138 #define SIZE_TYPE "unsigned int"
1139
1140 #define WCHAR_TYPE "short unsigned int"
1141 #define WCHAR_TYPE_SIZE 16
1142
1143 /* Don't cse the address of the function being compiled.  */
1144 /*#define NO_RECURSIVE_FUNCTION_CSE 1*/
1145
1146 /* Max number of bytes we can move from memory to memory
1147    in one reasonably fast instruction.  */
1148 #define MOVE_MAX 4
1149
1150 /* Define if operations between registers always perform the operation
1151    on the full register even if a narrower mode is specified.  */
1152 #define WORD_REGISTER_OPERATIONS
1153
1154 /* Define if loading in MODE, an integral mode narrower than BITS_PER_WORD
1155    will either zero-extend or sign-extend.  The value of this macro should
1156    be the code that says which one of the two operations is implicitly
1157    done, NIL if none.  */
1158 #define LOAD_EXTEND_OP(MODE) SIGN_EXTEND
1159
1160 /* Define if loading short immediate values into registers sign extends.  */
1161 #define SHORT_IMMEDIATES_SIGN_EXTEND
1162
1163 /* Define this if zero-extension is slow (more than one real instruction).
1164    On the SH, it's only one instruction.  */
1165 /* #define SLOW_ZERO_EXTEND */
1166
1167 /* Nonzero if access to memory by bytes is slow and undesirable.  */
1168 #define SLOW_BYTE_ACCESS 0
1169
1170 /* We assume that the store-condition-codes instructions store 0 for false
1171    and some other value for true.  This is the value stored for true.  */
1172
1173 #define STORE_FLAG_VALUE 1
1174
1175 /* Immediate shift counts are truncated by the output routines (or was it
1176    the assembler?).  Shift counts in a register are truncated by SH.  Note
1177    that the native compiler puts too large (> 32) immediate shift counts
1178    into a register and shifts by the register, letting the SH decide what
1179    to do instead of doing that itself.  */
1180 /* ??? This is defined, but the library routines in lib1funcs.asm do not
1181    truncate the shift count.  This may result in incorrect results for
1182    unusual cases.  Truncating the shift counts in the library routines would
1183    make them faster.  However, the SH3 has hardware shifts that do not
1184    truncate, so it appears that we need to leave this undefined for correct
1185    SH3 code.  We can still using truncation in the library routines though to
1186    make them faster.  */
1187 #define SHIFT_COUNT_TRUNCATED 1
1188
1189 /* All integers have the same format so truncation is easy.  */
1190 #define TRULY_NOOP_TRUNCATION(OUTPREC,INPREC)  1
1191
1192 /* Define this if addresses of constant functions
1193    shouldn't be put through pseudo regs where they can be cse'd.
1194    Desirable on machines where ordinary constants are expensive
1195    but a CALL with constant address is cheap.  */
1196 /*#define NO_FUNCTION_CSE 1*/
1197
1198 /* Chars and shorts should be passed as ints.  */
1199 #define PROMOTE_PROTOTYPES 1
1200
1201 /* The machine modes of pointers and functions.  */
1202 #define Pmode  SImode
1203 #define FUNCTION_MODE  Pmode
1204
1205 /* The relative costs of various types of constants.  Note that cse.c defines
1206    REG = 1, SUBREG = 2, any node = (2 + sum of subnodes).  */
1207
1208 #define CONST_COSTS(RTX, CODE, OUTER_CODE)      \
1209   case CONST_INT:                               \
1210     if (INTVAL (RTX) == 0)                      \
1211       return 0;                                 \
1212     else if (CONST_OK_FOR_I (INTVAL (RTX)))     \
1213       return 1;                                 \
1214     else if ((OUTER_CODE == AND || OUTER_CODE == IOR || OUTER_CODE == XOR) \
1215              && CONST_OK_FOR_L (INTVAL (RTX)))  \
1216       return 1;                                 \
1217     else                                        \
1218       return 8;                                 \
1219   case CONST:                                   \
1220   case LABEL_REF:                               \
1221   case SYMBOL_REF:                              \
1222     return 5;                                   \
1223   case CONST_DOUBLE:                            \
1224       return 10;
1225
1226 #define RTX_COSTS(X, CODE, OUTER_CODE)                  \
1227   case AND:                                             \
1228     return COSTS_N_INSNS (andcosts (X));                \
1229   case MULT:                                            \
1230     return COSTS_N_INSNS (multcosts (X));               \
1231   case ASHIFT:                                          \
1232   case ASHIFTRT:                                        \
1233   case LSHIFTRT:                                        \
1234     return COSTS_N_INSNS (shiftcosts (X)) ;             \
1235   case DIV:                                             \
1236   case UDIV:                                            \
1237   case MOD:                                             \
1238   case UMOD:                                            \
1239     return COSTS_N_INSNS (20);                          \
1240   case FLOAT:                                           \
1241   case FIX:                                             \
1242     return 100;
1243
1244 /* The multiply insn on the SH1 and the divide insns on the SH1 and SH2
1245    are actually function calls with some special constraints on arguments
1246    and register usage.
1247
1248    These macros tell reorg that the references to arguments and
1249    register clobbers for insns of type sfunc do not appear to happen
1250    until after the millicode call.  This allows reorg to put insns
1251    which set the argument registers into the delay slot of the millicode
1252    call -- thus they act more like traditional CALL_INSNs.
1253
1254    get_attr_type will try to recognize the given insn, so make sure to
1255    filter out things it will not accept -- SEQUENCE, USE and CLOBBER insns
1256    in particular.  */
1257
1258 #define INSN_SETS_ARE_DELAYED(X)                \
1259   ((GET_CODE (X) == INSN                        \
1260     && GET_CODE (PATTERN (X)) != SEQUENCE       \
1261     && GET_CODE (PATTERN (X)) != USE            \
1262     && GET_CODE (PATTERN (X)) != CLOBBER        \
1263     && get_attr_type (X) == TYPE_SFUNC))
1264
1265 #define INSN_REFERENCES_ARE_DELAYED(X)          \
1266   ((GET_CODE (X) == INSN                        \
1267     && GET_CODE (PATTERN (X)) != SEQUENCE       \
1268     && GET_CODE (PATTERN (X)) != USE            \
1269     && GET_CODE (PATTERN (X)) != CLOBBER        \
1270     && get_attr_type (X) == TYPE_SFUNC))
1271
1272 /* Compute the cost of an address.  For the SH, all valid addresses are
1273    the same cost.  */
1274 /* ??? Perhaps we should make reg+reg addresses have higher cost because
1275    they add to register pressure on r0.  */
1276
1277 #define ADDRESS_COST(RTX) 1
1278
1279 /* Compute extra cost of moving data between one register class
1280    and another.
1281
1282    On the SH it is hard to move into the T reg, but simple to load
1283    from it.  */
1284
1285 #define REGISTER_MOVE_COST(SRCCLASS, DSTCLASS) \
1286   (((DSTCLASS == T_REGS) || (DSTCLASS == PR_REG)) ? 10          \
1287    : ((DSTCLASS == FP_REGS && SRCCLASS == GENERAL_REGS)         \
1288       || (DSTCLASS == GENERAL_REGS && SRCCLASS == FP_REGS)) ? 4 \
1289    : 1)
1290
1291 /* ??? Perhaps make MEMORY_MOVE_COST depend on compiler option?  This
1292    would be so that people would slow memory systems could generate
1293    different code that does fewer memory accesses.  */
1294 \f
1295 /* Assembler output control.  */
1296
1297 /* A C string constant describing how to begin a comment in the target
1298    assembler language.  The compiler assumes that the comment will end at
1299    the end of the line.  */
1300 #define ASM_COMMENT_START "!"
1301
1302 /* The text to go at the start of the assembler file.  */
1303 #define ASM_FILE_START(STREAM) \
1304   output_file_start (STREAM)
1305
1306 #define ASM_FILE_END(STREAM)
1307
1308 #define ASM_APP_ON              ""
1309 #define ASM_APP_OFF             ""
1310 #define FILE_ASM_OP             "\t.file\n"
1311 #define IDENT_ASM_OP            "\t.ident\n"
1312 #define SET_ASM_OP              ".set"
1313
1314 /* How to change between sections.  */
1315
1316 #define TEXT_SECTION_ASM_OP             "\t.text"
1317 #define DATA_SECTION_ASM_OP             "\t.data"
1318 #define CTORS_SECTION_ASM_OP            "\t.section\t.ctors\n"
1319 #define DTORS_SECTION_ASM_OP            "\t.section\t.dtors\n"
1320 #define EXTRA_SECTIONS                  in_ctors, in_dtors
1321 #define EXTRA_SECTION_FUNCTIONS                                 \
1322 void                                                            \
1323 ctors_section()                                                 \
1324 {                                                               \
1325   if (in_section != in_ctors)                                   \
1326     {                                                           \
1327       fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP);     \
1328       in_section = in_ctors;                                    \
1329     }                                                           \
1330 }                                                               \
1331 void                                                            \
1332 dtors_section()                                                 \
1333 {                                                               \
1334   if (in_section != in_dtors)                                   \
1335     {                                                           \
1336       fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP);     \
1337       in_section = in_dtors;                                    \
1338     }                                                           \
1339 }
1340
1341 /* Define this so that jump tables go in same section as the current function,
1342    which could be text or it could be a user defined section.  */
1343 #define JUMP_TABLES_IN_TEXT_SECTION
1344
1345 /* A C statement to output something to the assembler file to switch to section
1346    NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or
1347    NULL_TREE.  Some target formats do not support arbitrary sections.  Do not
1348    define this macro in such cases.  */
1349
1350 #define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME) \
1351    do { fprintf (FILE, ".section\t%s\n", NAME); } while (0)
1352
1353 #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
1354    do { ctors_section();  fprintf(FILE,"\t.long\t_%s\n", NAME); } while (0)
1355
1356 #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
1357    do {  dtors_section();  fprintf(FILE,"\t.long\t_%s\n", NAME); } while (0)
1358
1359 #undef DO_GLOBAL_CTORS_BODY
1360
1361 #define DO_GLOBAL_CTORS_BODY                    \
1362 {                                               \
1363   typedef (*pfunc)();                           \
1364   extern pfunc __ctors[];                       \
1365   extern pfunc __ctors_end[];                   \
1366   pfunc *p;                                     \
1367   for (p = __ctors_end; p > __ctors; )          \
1368     {                                           \
1369       (*--p)();                                 \
1370     }                                           \
1371 }
1372
1373 #undef DO_GLOBAL_DTORS_BODY
1374 #define DO_GLOBAL_DTORS_BODY                    \
1375 {                                               \
1376   typedef (*pfunc)();                           \
1377   extern pfunc __dtors[];                       \
1378   extern pfunc __dtors_end[];                   \
1379   pfunc *p;                                     \
1380   for (p = __dtors; p < __dtors_end; p++)       \
1381     {                                           \
1382       (*p)();                                   \
1383     }                                           \
1384 }
1385
1386 #define ASM_OUTPUT_REG_PUSH(file, v) \
1387   fprintf (file, "\tmov.l       r%s,-@r15\n", v);
1388
1389 #define ASM_OUTPUT_REG_POP(file, v) \
1390   fprintf (file, "\tmov.l       @r15+,r%s\n", v);
1391
1392 /* The assembler's names for the registers.  RFP need not always be used as
1393    the Real framepointer; it can also be used as a normal general register.
1394    Note that the name `fp' is horribly misleading since `fp' is in fact only
1395    the argument-and-return-context pointer.  */
1396 #define REGISTER_NAMES                                  \
1397 {                                                       \
1398   "r0", "r1", "r2",  "r3",  "r4",  "r5",  "r6",  "r7",  \
1399   "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", \
1400   "ap", "pr", "t",  "gbr", "mach","macl", "fpul","rap", \
1401   "fr0","fr1","fr2", "fr3", "fr4", "fr5", "fr6", "fr7", \
1402   "fr8","fr9","fr10","fr11","fr12","fr13","fr14","fr15",\
1403 }
1404
1405 /* DBX register number for a given compiler register number.  */
1406 /* GDB has FPUL at 23 and FP0 at 25, so we must add one to all FP registers
1407    to match gdb.  */
1408 #define DBX_REGISTER_NUMBER(REGNO)      \
1409   (((REGNO) >= 22 && (REGNO) <= 39) ? ((REGNO) + 1) : (REGNO))
1410
1411 /* Output a label definition.  */
1412 #define ASM_OUTPUT_LABEL(FILE,NAME) \
1413   do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0)
1414
1415 /* This is how to output an assembler line
1416    that says to advance the location counter
1417    to a multiple of 2**LOG bytes.  */
1418
1419 #define ASM_OUTPUT_ALIGN(FILE,LOG)      \
1420   if ((LOG) != 0)                       \
1421     fprintf (FILE, "\t.align %d\n", LOG)
1422
1423 /* Output a function label definition.  */
1424 #define ASM_DECLARE_FUNCTION_NAME(STREAM,NAME,DECL) \
1425     ASM_OUTPUT_LABEL(STREAM, NAME)
1426
1427 /* Output a globalising directive for a label.  */
1428 #define ASM_GLOBALIZE_LABEL(STREAM,NAME)        \
1429   (fprintf (STREAM, "\t.global\t"),             \
1430    assemble_name (STREAM, NAME),                \
1431    fputc ('\n',STREAM))
1432
1433 /* The prefix to add to user-visible assembler symbols. */
1434
1435 #define USER_LABEL_PREFIX "_"
1436
1437 /* Make an internal label into a string.  */
1438 #define ASM_GENERATE_INTERNAL_LABEL(STRING, PREFIX, NUM) \
1439   sprintf (STRING, "*%s%d", PREFIX, NUM)
1440
1441 /* Output an internal label definition.  */
1442 #define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM) \
1443   fprintf (FILE, "%s%d:\n", PREFIX, NUM)
1444
1445 /* #define ASM_OUTPUT_CASE_END(STREAM,NUM,TABLE)            */
1446
1447 /* Construct a private name.  */
1448 #define ASM_FORMAT_PRIVATE_NAME(OUTVAR,NAME,NUMBER)     \
1449   ((OUTVAR) = (char *) alloca (strlen (NAME) + 10),     \
1450    sprintf ((OUTVAR), "%s.%d", (NAME), (NUMBER)))
1451
1452 /* Jump tables must be 32 bit aligned, no matter the size of the element.  */
1453 #define ASM_OUTPUT_CASE_LABEL(STREAM,PREFIX,NUM,TABLE) \
1454   fprintf (STREAM, "\t.align 2\n%s%d:\n",  PREFIX, NUM);
1455
1456 /* Output a relative address table.  */
1457
1458 #define ASM_OUTPUT_ADDR_DIFF_ELT(STREAM,VALUE,REL)                      \
1459   if (TARGET_BIGTABLE)                                                  \
1460     fprintf (STREAM, "\t.long   L%d-L%d\n", VALUE,REL);                 \
1461   else                                                                  \
1462     fprintf (STREAM, "\t.word   L%d-L%d\n", VALUE,REL);                 \
1463
1464 /* Output an absolute table element.  */
1465
1466 #define ASM_OUTPUT_ADDR_VEC_ELT(STREAM,VALUE)                           \
1467   if (TARGET_BIGTABLE)                                                  \
1468     fprintf (STREAM, "\t.long   L%d\n", VALUE);                         \
1469   else                                                                  \
1470     fprintf (STREAM, "\t.word   L%d\n", VALUE);                         \
1471
1472 /* Output various types of constants.  */
1473
1474 /* This is how to output an assembler line defining a `double'.  */
1475
1476 #define ASM_OUTPUT_DOUBLE(FILE,VALUE)                   \
1477 do { char dstr[30];                                     \
1478      REAL_VALUE_TO_DECIMAL ((VALUE), "%.20e", dstr);    \
1479      fprintf (FILE, "\t.double %s\n", dstr);            \
1480    } while (0)
1481
1482 /* This is how to output an assembler line defining a `float' constant.  */
1483 #define ASM_OUTPUT_FLOAT(FILE,VALUE)                    \
1484 do { char dstr[30];                                     \
1485      REAL_VALUE_TO_DECIMAL ((VALUE), "%.20e", dstr);    \
1486      fprintf (FILE, "\t.float %s\n", dstr);             \
1487    } while (0)
1488
1489 #define ASM_OUTPUT_INT(STREAM, EXP)     \
1490   (fprintf (STREAM, "\t.long\t"),       \
1491    output_addr_const (STREAM, (EXP)),   \
1492    fputc ('\n', STREAM))
1493
1494 #define ASM_OUTPUT_SHORT(STREAM, EXP)   \
1495   (fprintf (STREAM, "\t.short\t"),      \
1496    output_addr_const (STREAM, (EXP)),   \
1497    fputc ('\n', STREAM))
1498
1499 #define ASM_OUTPUT_CHAR(STREAM, EXP)    \
1500   (fprintf (STREAM, "\t.byte\t"),       \
1501    output_addr_const (STREAM, (EXP)),   \
1502    fputc ('\n', STREAM))
1503
1504 #define ASM_OUTPUT_BYTE(STREAM, VALUE)          \
1505   fprintf (STREAM, "\t.byte\t%d\n", VALUE)      \
1506
1507 /* Align loops and labels after unconditional branches to get faster
1508    code.  */
1509
1510 #define ASM_OUTPUT_LOOP_ALIGN(FILE)     \
1511   if (! TARGET_SMALLCODE)               \
1512     ASM_OUTPUT_ALIGN ((FILE), 2)
1513
1514 #define ASM_OUTPUT_ALIGN_CODE(FILE)     \
1515   if (! TARGET_SMALLCODE)               \
1516     ASM_OUTPUT_ALIGN ((FILE), (TARGET_SH3 || TARGET_SH3E) ? 4 : 2)
1517
1518 /* This is how to output an assembler line
1519    that says to advance the location counter by SIZE bytes.  */
1520
1521 #define ASM_OUTPUT_SKIP(FILE,SIZE) \
1522   fprintf (FILE, "\t.space %d\n", (SIZE))
1523
1524 /* This says how to output an assembler line
1525    to define a global common symbol.  */
1526
1527 #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED)    \
1528 ( fputs ("\t.comm ", (FILE)),                   \
1529   assemble_name ((FILE), (NAME)),               \
1530   fprintf ((FILE), ",%d\n", (SIZE)))
1531
1532 /* This says how to output an assembler line
1533    to define a local common symbol.  */
1534
1535 #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE,ROUNDED)      \
1536 ( fputs ("\t.lcomm ", (FILE)),                          \
1537   assemble_name ((FILE), (NAME)),                       \
1538   fprintf ((FILE), ",%d\n", (SIZE)))
1539
1540 /* The assembler's parentheses characters.  */
1541 #define ASM_OPEN_PAREN "("
1542 #define ASM_CLOSE_PAREN ")"
1543
1544 /* Target characters.  */
1545 #define TARGET_BELL     007
1546 #define TARGET_BS       010
1547 #define TARGET_TAB      011
1548 #define TARGET_NEWLINE  012
1549 #define TARGET_VT       013
1550 #define TARGET_FF       014
1551 #define TARGET_CR       015
1552 \f
1553 /* Only perform branch elimination (by making instructions conditional) if
1554    we're optimizing.  Otherwise it's of no use anyway.  */
1555 #define FINAL_PRESCAN_INSN(INSN, OPVEC, NOPERANDS) \
1556   final_prescan_insn (INSN, OPVEC, NOPERANDS)
1557
1558 /* Print operand X (an rtx) in assembler syntax to file FILE.
1559    CODE is a letter or dot (`z' in `%z0') or 0 if no letter was specified.
1560    For `%' followed by punctuation, CODE is the punctuation and X is null.  */
1561
1562 #define PRINT_OPERAND(STREAM, X, CODE)  print_operand (STREAM, X, CODE)
1563
1564 /* Print a memory address as an operand to reference that memory location.  */
1565
1566 #define PRINT_OPERAND_ADDRESS(STREAM,X)  print_operand_address (STREAM, X)
1567
1568 #define PRINT_OPERAND_PUNCT_VALID_P(CHAR) \
1569   ((CHAR)=='.' || (CHAR) == '#' || (CHAR)=='@')
1570 \f
1571 extern struct rtx_def *sh_compare_op0;
1572 extern struct rtx_def *sh_compare_op1;
1573 extern struct rtx_def *prepare_scc_operands();
1574
1575 /* Which processor to schedule for.  The elements of the enumeration must
1576    match exactly the cpu attribute in the sh.md file.  */
1577
1578 enum processor_type {
1579   PROCESSOR_SH0,
1580   PROCESSOR_SH1,
1581   PROCESSOR_SH2,
1582   PROCESSOR_SH3,
1583   PROCESSOR_SH3E
1584 };
1585
1586 #define sh_cpu_attr ((enum attr_cpu)sh_cpu)
1587 extern enum processor_type sh_cpu;
1588
1589 /* Declare functions defined in sh.c and used in templates.  */
1590
1591 extern char *output_branch();
1592 extern char *output_shift();
1593 extern char *output_movedouble();
1594 extern char *output_movepcrel();
1595 extern char *output_jump_label_table();
1596 extern char *output_far_jump();
1597
1598 #define MACHINE_DEPENDENT_REORG(X) machine_dependent_reorg(X)
1599
1600 /* Generate calls to memcpy, memcmp and memset.  */
1601
1602 #define TARGET_MEM_FUNCTIONS
1603
1604 /* Define this macro if you want to implement any pragmas.  If defined, it
1605    is a C expression to be executed when #pragma is seen.  The
1606    argument FILE is the stdio input stream from which the source
1607    text can be read.  CH is the first character after the #pragma.  The
1608    result of the expression is the terminating character found
1609    (newline or EOF).  */
1610 #define HANDLE_PRAGMA(FILE, NODE) handle_pragma (FILE, NODE)
1611
1612 /* Set when processing a function with pragma interrupt turned on.  */
1613
1614 extern int pragma_interrupt;
1615
1616 #define MOVE_RATIO (TARGET_SMALLCODE ? 2 : 16)
1617 \f
1618 /* Instructions with unfilled delay slots take up an extra two bytes for
1619    the nop in the delay slot.  Instructions at the start of loops, or
1620    after unconditional branches, may take up extra room when they are
1621    aligned.  ??? We would get more accurate results if we did instruction
1622    alignment based on the value of INSN_CURRENT_ADDRESS; the approach used
1623    here is too conservative.  */
1624
1625 #define ADJUST_INSN_LENGTH(X, LENGTH)                           \
1626   if (((GET_CODE (X) == INSN                                    \
1627         && GET_CODE (PATTERN (X)) != SEQUENCE                   \
1628         && GET_CODE (PATTERN (X)) != USE                        \
1629         && GET_CODE (PATTERN (X)) != CLOBBER)                   \
1630        || GET_CODE (X) == CALL_INSN                             \
1631        || (GET_CODE (X) == JUMP_INSN                            \
1632            && GET_CODE (PATTERN (X)) != ADDR_DIFF_VEC           \
1633            && GET_CODE (PATTERN (X)) != ADDR_VEC))              \
1634       && get_attr_needs_delay_slot (X) == NEEDS_DELAY_SLOT_YES) \
1635     LENGTH += 2;                                                \
1636   if (! TARGET_SMALLCODE)                                       \
1637     {                                                           \
1638        rtx aip;                                                 \
1639        for (aip = PREV_INSN (X); aip; aip = PREV_INSN (aip))    \
1640          {                                                      \
1641            if (GET_CODE (aip) == BARRIER)                       \
1642              {                                                  \
1643                if (TARGET_SH3 || TARGET_SH3E)                   \
1644                  LENGTH += 14;                                  \
1645                else                                             \
1646                  LENGTH += 2;                                   \
1647                break;                                           \
1648              }                                                  \
1649            else if ((GET_CODE (aip) == NOTE                     \
1650                      && NOTE_LINE_NUMBER (aip) == NOTE_INSN_LOOP_BEG)) \
1651              {                                                  \
1652                LENGTH += 2;                                     \
1653                break;                                           \
1654              }                                                  \
1655            else if (GET_CODE (aip) != NOTE                      \
1656                     && GET_CODE (aip) != CODE_LABEL)            \
1657              break;                                             \
1658          }                                                      \
1659     }
1660
1661 /* Enable a bug fix for the shorten_branches pass.  */
1662 #define SHORTEN_WITH_ADJUST_INSN_LENGTH
1663 \f
1664 /* Define the codes that are matched by predicates in sh.c.  */
1665 #define PREDICATE_CODES \
1666   {"arith_reg_operand", {SUBREG, REG}},                                 \
1667   {"arith_operand", {SUBREG, REG, CONST_INT}},                          \
1668   {"arith_reg_or_0_operand", {SUBREG, REG, CONST_INT}},                 \
1669   {"logical_operand", {SUBREG, REG, CONST_INT}},                        \
1670   {"general_movsrc_operand", {SUBREG, REG, CONST_INT, MEM}},            \
1671   {"general_movdst_operand", {SUBREG, REG, CONST_INT, MEM}},
1672
1673 /* Define this macro if it is advisable to hold scalars in registers
1674    in a wider mode than that declared by the program.  In such cases, 
1675    the value is constrained to be within the bounds of the declared
1676    type, but kept valid in the wider mode.  The signedness of the
1677    extension may differ from that of the type.
1678
1679    Leaving the unsignedp unchanged gives better code than always setting it
1680    to 0.  This is despite the fact that we have only signed char and short
1681    load instructions.  */
1682 #define PROMOTE_MODE(MODE, UNSIGNEDP, TYPE) \
1683   if (GET_MODE_CLASS (MODE) == MODE_INT                 \
1684       && GET_MODE_SIZE (MODE) < UNITS_PER_WORD)         \
1685     MODE = SImode;
1686
1687 /* Defining PROMOTE_FUNCTION_ARGS eliminates some unnecessary zero/sign
1688    extensions applied to char/short functions arguments.  Defining
1689    PROMOTE_FUNCTION_RETURN does the same for function returns.  */
1690
1691 #define PROMOTE_FUNCTION_ARGS
1692 #define PROMOTE_FUNCTION_RETURN
1693
1694 /* ??? Define ACCUMULATE_OUTGOING_ARGS?  This is more efficient than pushing
1695    and poping arguments.  However, we do have push/pop instructions, and
1696    rather limited offsets (4 bits) in load/store instructions, so it isn't
1697    clear if this would give better code.  If implemented, should check for
1698    compatibility problems.  */
1699
1700 /* ??? Define ADJUST_COSTS?  */
1701
1702 /* Since the SH architecture lacks negative address offsets,
1703    the givs should be sorted smallest to largest so combine_givs
1704    has maximum opportunity to combine givs.  */
1705 #define GIV_SORT_CRITERION(X, Y)        \
1706   if (GET_CODE ((X)->add_val) == CONST_INT              \
1707       && GET_CODE ((Y)->add_val) == CONST_INT)          \
1708     return INTVAL ((X)->add_val) - INTVAL ((Y)->add_val);
1709
1710 /* For the sake of libgcc2.c, indicate target supports atexit.  */
1711 #define HAVE_ATEXIT