OSDN Git Service

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