OSDN Git Service

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