OSDN Git Service

* Check in merge from gcc2. See ChangeLog.12 for details.
[pf3gnuchains/gcc-fork.git] / gcc / config / m32r / m32r.h
1 /* Definitions of target machine for GNU compiler, Mitsubishi M32R cpu.
2    Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
3
4 This file is part of GNU CC.
5
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING.  If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA.  */
20
21 /* Things to do:
22 - longlong.h?
23 */
24
25 /* ??? Create elf.h and have svr4.h include it.  */
26 #include "svr4.h"
27
28 #undef SWITCH_TAKES_ARG
29 #undef WORD_SWITCH_TAKES_ARG
30 #undef HANDLE_SYSV_PRAGMA
31 #undef SIZE_TYPE
32 #undef PTRDIFF_TYPE
33 #undef WCHAR_TYPE
34 #undef WCHAR_TYPE_SIZE
35 #undef ASM_FILE_START
36 #undef ASM_OUTPUT_EXTERNAL_LIBCALL
37 \f
38 /* Print subsidiary information on the compiler version in use.  */
39 #define TARGET_VERSION fprintf (stderr, " (m32r)")
40
41
42 /* Switch  Recognition by gcc.c.  Add -G xx support */
43
44 #undef SWITCH_TAKES_ARG
45 #define SWITCH_TAKES_ARG(CHAR) \
46 (DEFAULT_SWITCH_TAKES_ARG (CHAR) || (CHAR) == 'G')
47
48 /* Names to predefine in the preprocessor for this target machine.  */
49 /* __M32R__ is defined by the existing compiler so we use that.  */
50 #define CPP_PREDEFINES "-Acpu(m32r) -Amachine(m32r) -D__M32R__"
51
52
53 #define CC1_SPEC "%{G*}"
54
55 /* Options to pass on to the assembler.  */
56 #undef  ASM_SPEC
57 #define ASM_SPEC "%{v}"
58
59 #if 0 /* not supported yet */
60 #undef  ASM_SPEC
61 #define ASM_SPEC "%{v} %{mrelax:-relax}"
62 #endif
63      
64
65 #undef ASM_FINAL_SPEC
66
67 #undef LINK_SPEC
68 #if 0 /* not supported yet */
69 #define LINK_SPEC "%{v} %{mrelax:-relax}"
70 #else
71 #define LINK_SPEC "%{v}"
72 #endif
73
74 #undef STARTFILE_SPEC
75 #define STARTFILE_SPEC "%{!shared:crt0.o%s crtsysc.o%s} crtinit.o%s"
76
77
78 #undef ENDFILE_SPEC
79 #define ENDFILE_SPEC "crtfini.o%s"
80
81      
82 #undef LIB_SPEC
83 \f
84 /* Run-time compilation parameters selecting different hardware subsets.  */
85
86 extern int target_flags;
87
88 /* If non-zero, tell the linker to do relaxing.
89    We don't do anything with the option, other than recognize it.
90    LINK_SPEC handles passing -relax to the linker.
91    This can cause incorrect debugging information as line numbers may
92    turn out wrong.  This shouldn't be specified unless accompanied with -O2
93    [where the user expects debugging information to be less accurate].  */
94 #define TARGET_RELAX_MASK 1
95
96 /* For miscellaneous debugging purposes.  */
97 #define TARGET_DEBUG_MASK 2
98 #define TARGET_DEBUG (target_flags & TARGET_DEBUG_MASK)
99
100 /* Align loops to 32 byte boundaries (cache line size).  */
101 /* ??? This option is experimental and is not documented.  */
102 #define TARGET_ALIGN_LOOPS_MASK 4
103 #define TARGET_ALIGN_LOOPS (target_flags & TARGET_ALIGN_LOOPS_MASK)
104
105 /* Use old compare/branch support (kept around for awhile for
106    comparison and backoff purposes).  */
107 /* ??? This option is experimental and is not documented.
108    Eventually it will be deleted.  */
109 #define TARGET_OLD_COMPARE_MASK 8
110 #define TARGET_OLD_COMPARE (target_flags & TARGET_OLD_COMPARE_MASK)
111
112 /* Target machine to compile for.  */
113 #define TARGET_M32R 1
114
115
116 /* Macro to define tables used to set the flags.
117    This is a list in braces of pairs in braces,
118    each pair being { "NAME", VALUE }
119    where VALUE is the bits to set or minus the bits to clear.
120    An empty string NAME is used to identify the default VALUE.  */
121
122 #define TARGET_SWITCHES \
123 { \
124 /*  { "relax",                  TARGET_RELAX_MASK },                    \
125     { "no-relax",               -TARGET_RELAX_MASK },*/                 \
126     { "debug",                  TARGET_DEBUG_MASK },                    \
127     { "align-loops",            TARGET_ALIGN_LOOPS_MASK },              \
128     { "no-align-loops",         -TARGET_ALIGN_LOOPS_MASK },             \
129     { "old-compare",            TARGET_OLD_COMPARE_MASK },              \
130     { "no-old-compare",         -TARGET_OLD_COMPARE_MASK },             \
131     SUBTARGET_SWITCHES                                                  \
132     { "", TARGET_DEFAULT }                                              \
133 }
134
135 #define TARGET_DEFAULT (0)
136
137 #define SUBTARGET_SWITCHES
138
139 /* This macro is similar to `TARGET_SWITCHES' but defines names of
140    command options that have values.  Its definition is an
141    initializer with a subgrouping for each command option.
142
143    Each subgrouping contains a string constant, that defines the
144    fixed part of the option name, and the address of a variable. 
145    The variable, type `char *', is set to the variable part of the
146    given option if the fixed part matches.  The actual option name
147    is made by appending `-m' to the specified name.
148
149    Here is an example which defines `-mshort-data-NUMBER'.  If the
150    given option is `-mshort-data-512', the variable `m88k_short_data'
151    will be set to the string `"512"'.
152
153         extern char *m88k_short_data;
154         #define TARGET_OPTIONS { { "short-data-", &m88k_short_data } }  */
155
156 extern char *m32r_model_string;
157 extern char *m32r_sdata_string;
158
159
160 #define TARGET_OPTIONS \
161 {                                               \
162   { "model=",   &m32r_model_string      },      \
163   { "sdata=",   &m32r_sdata_string      },      \
164 }
165
166 /* Code Models
167
168    Code models are used to select between two choices of two separate
169    possibilities (address space size, call insn to use):
170
171    small: addresses use 24 bits, use bl to make calls
172    medium: addresses use 32 bits, use bl to make calls (*1)
173    large: addresses use 32 bits, use seth/add3/jl to make calls (*2)
174
175    The fourth is "addresses use 24 bits, use seth/add3/jl to make calls" but
176    using this one doesn't make much sense.
177
178    (*1) The linker may eventually be able to relax seth/add3 -> ld24.
179    (*2) The linker may eventually be able to relax seth/add3/jl -> bl.
180
181    Internally these are recorded as TARGET_ADDR{24,32} and
182    TARGET_CALL{26,32}.
183
184    The __model__ attribute can be used to select the code model to use when
185    accessing particular objects.  */
186
187 enum m32r_model { M32R_MODEL_SMALL, M32R_MODEL_MEDIUM, M32R_MODEL_LARGE };
188
189 extern enum m32r_model m32r_model;
190 #define TARGET_MODEL_SMALL (m32r_model == M32R_MODEL_SMALL)
191 #define TARGET_MODEL_MEDIUM (m32r_model == M32R_MODEL_MEDIUM)
192 #define TARGET_MODEL_LARGE (m32r_model == M32R_MODEL_LARGE)
193 #define TARGET_ADDR24 (m32r_model == M32R_MODEL_SMALL)
194 #define TARGET_ADDR32 (! TARGET_ADDR24)
195 #define TARGET_CALL26 (! TARGET_CALL32)
196 #define TARGET_CALL32 (m32r_model == M32R_MODEL_LARGE)
197
198 /* The default is the small model.  */
199 #define M32R_MODEL_DEFAULT "small"
200
201 /* Small Data Area
202
203    The SDA consists of sections .sdata, .sbss, and .scommon.
204    .scommon isn't a real section, symbols in it have their section index
205    set to SHN_M32R_SCOMMON, though support for it exists in the linker script.
206
207    Two switches control the SDA:
208
209    -G NNN        - specifies the maximum size of variable to go in the SDA
210
211    -msdata=foo   - specifies how such variables are handled
212
213         -msdata=none  - small data area is disabled
214
215         -msdata=sdata - small data goes in the SDA, special code isn't
216                         generated to use it, and special relocs aren't
217                         generated
218
219         -msdata=use   - small data goes in the SDA, special code is generated
220                         to use the SDA and special relocs are generated
221
222    The SDA is not multilib'd, it isn't necessary.
223    MULTILIB_EXTRA_OPTS is set in tmake_file to -msdata=sdata so multilib'd
224    libraries have small data in .sdata/SHN_M32R_SCOMMON so programs that use
225    -msdata=use will successfully link with them (references in header files
226    will cause the compiler to emit code that refers to library objects in
227    .data).  ??? There can be a problem if the user passes a -G value greater
228    than the default and a library object in a header file is that size.
229    The default is 8 so this should be rare - if it occurs the user
230    is required to rebuild the libraries or use a smaller value for -G.
231 */
232
233 /* Maximum size of variables that go in .sdata/.sbss.
234    The -msdata=foo switch also controls how small variables are handled.  */
235 #define SDATA_DEFAULT_SIZE 8
236
237 extern int g_switch_value;              /* value of the -G xx switch */
238 extern int g_switch_set;                /* whether -G xx was passed.  */
239
240 enum m32r_sdata { M32R_SDATA_NONE, M32R_SDATA_SDATA, M32R_SDATA_USE };
241
242 extern enum m32r_sdata m32r_sdata;
243 #define TARGET_SDATA_NONE (m32r_sdata == M32R_SDATA_NONE)
244 #define TARGET_SDATA_SDATA (m32r_sdata == M32R_SDATA_SDATA)
245 #define TARGET_SDATA_USE (m32r_sdata == M32R_SDATA_USE)
246
247 /* Default is to disable the SDA
248    [for upward compatibility with previous toolchains].  */
249 #define M32R_SDATA_DEFAULT "none"
250
251 /* Define this macro as a C expression for the initializer of an array of
252    strings to tell the driver program which options are defaults for this
253    target and thus do not need to be handled specially when using
254    `MULTILIB_OPTIONS'.  */
255 #define MULTILIB_DEFAULTS { "mmodel=small", "m32r" }
256
257 /* Sometimes certain combinations of command options do not make
258    sense on a particular target machine.  You can define a macro
259    `OVERRIDE_OPTIONS' to take account of this.  This macro, if
260    defined, is executed once just after all the command options have
261    been parsed.
262
263    Don't use this macro to turn on various extra optimizations for
264    `-O'.  That is what `OPTIMIZATION_OPTIONS' is for.  */
265
266 #define OVERRIDE_OPTIONS \
267 do {                            \
268   /* These need to be done at start up.  It's convenient to do them here.  */ \
269   m32r_init ();                 \
270 } while (0)
271
272 /* Define this macro if debugging can be performed even without a
273    frame pointer.  If this macro is defined, GNU CC will turn on the
274    `-fomit-frame-pointer' option whenever `-O' is specified.  */
275 #define CAN_DEBUG_WITHOUT_FP
276 \f
277 /* Target machine storage layout.  */
278
279 /* Define to use software floating point emulator for REAL_ARITHMETIC and
280    decimal <-> binary conversion.  */
281 #define REAL_ARITHMETIC
282
283 /* Define this if most significant bit is lowest numbered
284    in instructions that operate on numbered bit-fields.  */
285 #define BITS_BIG_ENDIAN 1
286
287 /* Define this if most significant byte of a word is the lowest numbered.  */
288 #define BYTES_BIG_ENDIAN 1
289
290 /* Define this if most significant word of a multiword number is the lowest
291    numbered.  */
292 #define WORDS_BIG_ENDIAN 1
293
294 /* Define this macro if WORDS_BIG_ENDIAN is not constant.  This must
295    be a constant value with the same meaning as WORDS_BIG_ENDIAN,
296    which will be used only when compiling libgcc2.c.  Typically the
297    value will be set based on preprocessor defines.  */
298 /*#define LIBGCC2_WORDS_BIG_ENDIAN 1*/
299
300 /* Number of bits in an addressable storage unit.  */
301 #define BITS_PER_UNIT 8
302
303 /* Width in bits of a "word", which is the contents of a machine register.
304    Note that this is not necessarily the width of data type `int';
305    if using 16-bit ints on a 68000, this would still be 32.
306    But on a machine with 16-bit registers, this would be 16.  */
307 #define BITS_PER_WORD 32
308
309 /* Width of a word, in units (bytes).  */
310 #define UNITS_PER_WORD 4
311
312 /* Define this macro if it is advisable to hold scalars in registers
313    in a wider mode than that declared by the program.  In such cases, 
314    the value is constrained to be within the bounds of the declared
315    type, but kept valid in the wider mode.  The signedness of the
316    extension may differ from that of the type.  */
317 #define PROMOTE_MODE(MODE,UNSIGNEDP,TYPE) \
318 if (GET_MODE_CLASS (MODE) == MODE_INT           \
319     && GET_MODE_SIZE (MODE) < UNITS_PER_WORD)   \
320 {                                               \
321   (MODE) = SImode;                              \
322 }
323
324 /* Define this macro if the promotion described by `PROMOTE_MODE'
325    should also be done for outgoing function arguments.  */
326 /*#define PROMOTE_FUNCTION_ARGS*/
327
328 /* Likewise, if the function return value is promoted.
329    If defined, FUNCTION_VALUE must perform the same promotions done by
330    PROMOTE_MODE.  */
331 /*#define PROMOTE_FUNCTION_RETURN*/
332
333 /* Width in bits of a pointer.
334    See also the macro `Pmode' defined below.  */
335 #define POINTER_SIZE 32
336
337 /* Allocation boundary (in *bits*) for storing arguments in argument list.  */
338 #define PARM_BOUNDARY 32
339
340 /* Boundary (in *bits*) on which stack pointer should be aligned.  */
341 #define STACK_BOUNDARY 32
342
343 /* ALIGN FRAMES on word boundaries */
344 #define M32R_STACK_ALIGN(LOC) (((LOC)+3) & ~3)
345
346 /* Allocation boundary (in *bits*) for the code of a function.  */
347 #define FUNCTION_BOUNDARY 32
348
349 /* Alignment of field after `int : 0' in a structure.  */
350 #define EMPTY_FIELD_BOUNDARY 32
351
352 /* Every structure's size must be a multiple of this.  */
353 #define STRUCTURE_SIZE_BOUNDARY 8
354
355 /* A bitfield declared as `int' forces `int' alignment for the struct.  */
356 #define PCC_BITFIELD_TYPE_MATTERS 1
357
358 /* No data type wants to be aligned rounder than this.  */
359 #define BIGGEST_ALIGNMENT 32
360
361 /* The best alignment to use in cases where we have a choice.  */
362 #define FASTEST_ALIGNMENT 32
363
364 /* Make strings word-aligned so strcpy from constants will be faster.  */
365 #define CONSTANT_ALIGNMENT(EXP, ALIGN)  \
366   ((TREE_CODE (EXP) == STRING_CST       \
367     && (ALIGN) < FASTEST_ALIGNMENT)     \
368    ? FASTEST_ALIGNMENT : (ALIGN))
369
370 /* Make arrays of chars word-aligned for the same reasons.  */
371 #define DATA_ALIGNMENT(TYPE, ALIGN)             \
372   (TREE_CODE (TYPE) == ARRAY_TYPE               \
373    && TYPE_MODE (TREE_TYPE (TYPE)) == QImode    \
374    && (ALIGN) < FASTEST_ALIGNMENT ? FASTEST_ALIGNMENT : (ALIGN))
375
376 /* Set this nonzero if move instructions will actually fail to work
377    when given unaligned data.  */
378 #define STRICT_ALIGNMENT 1
379 \f
380 /* Layout of source language data types.  */
381
382 #define SHORT_TYPE_SIZE         16
383 #define INT_TYPE_SIZE           32
384 #define LONG_TYPE_SIZE          32
385 #define LONG_LONG_TYPE_SIZE     64
386 #define FLOAT_TYPE_SIZE         32
387 #define DOUBLE_TYPE_SIZE        64
388 #define LONG_DOUBLE_TYPE_SIZE   64
389
390 /* Define this as 1 if `char' should by default be signed; else as 0.  */
391 #define DEFAULT_SIGNED_CHAR 1
392
393 #define SIZE_TYPE "long unsigned int"
394 #define PTRDIFF_TYPE "long int"
395 #define WCHAR_TYPE "short unsigned int"
396 #define WCHAR_TYPE_SIZE 16
397
398 /* Define results of standard character escape sequences.  */
399 #define TARGET_BELL 007
400 #define TARGET_BS 010
401 #define TARGET_TAB 011
402 #define TARGET_NEWLINE 012
403 #define TARGET_VT 013
404 #define TARGET_FF 014
405 #define TARGET_CR 015
406 \f
407 /* Standard register usage.  */
408
409 /* Number of actual hardware registers.
410    The hardware registers are assigned numbers for the compiler
411    from 0 to just below FIRST_PSEUDO_REGISTER.
412    All registers that the compiler knows about must be given numbers,
413    even those that are not normally considered general registers.  */
414 #define FIRST_PSEUDO_REGISTER 18
415         
416 /* 1 for registers that have pervasive standard uses
417    and are not available for the register allocator.
418
419    0-3   - arguments/results
420    4-5   - call used [4 is used as a tmp during prologue/epilogue generation]
421    6     - call used, gptmp
422    7     - call used, static chain pointer
423    8-11  - call saved
424    12    - call saved [reserved for global pointer]
425    13    - frame pointer
426    14    - subroutine link register
427    15    - stack pointer
428    16    - arg pointer
429    17    - carry flag
430
431    
432    By default, the extension registers are not available.  */
433
434 #define FIXED_REGISTERS \
435 { 0, 0, 0, 0, 0, 0, 0, 0,       \
436   0, 0, 0, 0, 0, 0, 0, 1,       \
437   1, 0 }
438
439
440 /* 1 for registers not available across function calls.
441    These must include the FIXED_REGISTERS and also any
442    registers that can be used without being saved.
443    The latter must include the registers where values are returned
444    and the register where structure-value addresses are passed.
445    Aside from that, you can include as many other registers as you like.  */
446
447 #define CALL_USED_REGISTERS \
448 { 1, 1, 1, 1, 1, 1, 1, 1,       \
449   0, 0, 0, 0, 0, 0, 1, 1,       \
450   1, 1 }
451
452
453 /* Zero or more C statements that may conditionally modify two variables
454    `fixed_regs' and `call_used_regs' (both of type `char []') after they
455    have been initialized from the two preceding macros.
456
457    This is necessary in case the fixed or call-clobbered registers depend
458    on target flags.
459
460    You need not define this macro if it has no work to do.  */
461
462 /*#define CONDITIONAL_REGISTER_USAGE*/
463
464 /* If defined, an initializer for a vector of integers, containing the
465    numbers of hard registers in the order in which GNU CC should
466    prefer to use them (from most preferred to least).  */
467 #if 1 /* better for int code */
468 #define REG_ALLOC_ORDER \
469 { 4, 5, 6, 7, 2, 3, 8, 9, 10, 11, 12, 13, 14, 0, 1, 15, 16, 17 }
470 #else /* better for fp code at expense of int code */
471 #define REG_ALLOC_ORDER \
472 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 }
473 #endif
474
475 /* Return number of consecutive hard regs needed starting at reg REGNO
476    to hold something of mode MODE.
477    This is ordinarily the length in words of a value of mode MODE
478    but can be less for certain modes in special long registers.  */
479 #define HARD_REGNO_NREGS(REGNO, MODE) \
480 ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
481
482 /* Value is 1 if hard register REGNO can hold a value of machine-mode MODE.  */
483 extern unsigned int m32r_hard_regno_mode_ok[];
484 extern unsigned int m32r_mode_class[];
485 #define HARD_REGNO_MODE_OK(REGNO, MODE) \
486 ((m32r_hard_regno_mode_ok[REGNO] & m32r_mode_class[MODE]) != 0)
487
488 /* A C expression that is nonzero if it is desirable to choose
489    register allocation so as to avoid move instructions between a
490    value of mode MODE1 and a value of mode MODE2.
491
492    If `HARD_REGNO_MODE_OK (R, MODE1)' and `HARD_REGNO_MODE_OK (R,
493    MODE2)' are ever different for any R, then `MODES_TIEABLE_P (MODE1,
494    MODE2)' must be zero.  */
495
496 /* Tie QI/HI/SI modes together.  */
497 #define MODES_TIEABLE_P(MODE1, MODE2) \
498 (GET_MODE_CLASS (MODE1) == MODE_INT             \
499  && GET_MODE_CLASS (MODE2) == MODE_INT          \
500  && GET_MODE_SIZE (MODE1) <= UNITS_PER_WORD     \
501  && GET_MODE_SIZE (MODE2) <= UNITS_PER_WORD)
502 \f
503 /* Register classes and constants.  */
504
505 /* Define the classes of registers for register constraints in the
506    machine description.  Also define ranges of constants.
507
508    One of the classes must always be named ALL_REGS and include all hard regs.
509    If there is more than one class, another class must be named NO_REGS
510    and contain no registers.
511
512    The name GENERAL_REGS must be the name of a class (or an alias for
513    another name such as ALL_REGS).  This is the class of registers
514    that is allowed by "g" or "r" in a register constraint.
515    Also, registers outside this class are allocated only when
516    instructions express preferences for them.
517
518    The classes must be numbered in nondecreasing order; that is,
519    a larger-numbered class must never be contained completely
520    in a smaller-numbered class.
521
522    For any two classes, it is very desirable that there be another
523    class that represents their union.
524
525    It is important that any condition codes have class NO_REGS.
526    See `register_operand'.  */
527
528 enum reg_class {
529   NO_REGS, CARRY_REG, GENERAL_REGS, ALL_REGS, LIM_REG_CLASSES
530 };
531
532 #define N_REG_CLASSES (int) LIM_REG_CLASSES
533
534 /* Give names of register classes as strings for dump file.   */
535 #define REG_CLASS_NAMES \
536 { "NO_REGS", "CARRY_REG", "GENERAL_REGS", "ALL_REGS" }
537
538 /* Define which registers fit in which classes.
539    This is an initializer for a vector of HARD_REG_SET
540    of length N_REG_CLASSES.  */
541
542 #define REG_CLASS_CONTENTS \
543 { {0}, {0x20000}, {0x1ffff}, {0x3ffff} }
544
545
546 /* The same information, inverted:
547    Return the class number of the smallest class containing
548    reg number REGNO.  This could be a conditional expression
549    or could index an array.  */
550 extern enum reg_class m32r_regno_reg_class[FIRST_PSEUDO_REGISTER];
551 #define REGNO_REG_CLASS(REGNO) \
552 (m32r_regno_reg_class[REGNO])
553
554 /* The class value for index registers, and the one for base regs.  */
555 #define INDEX_REG_CLASS GENERAL_REGS
556 #define BASE_REG_CLASS GENERAL_REGS
557
558 /* Get reg_class from a letter such as appears in the machine description.  */
559 #define REG_CLASS_FROM_LETTER(C) NO_REGS
560
561 /* These assume that REGNO is a hard or pseudo reg number.
562    They give nonzero only if REGNO is a hard reg of the suitable class
563    or a pseudo reg currently allocated to a suitable hard reg.
564    Since they use reg_renumber, they are safe only once reg_renumber
565    has been allocated, which happens in local-alloc.c.  */
566 #define REGNO_OK_FOR_BASE_P(REGNO) \
567 ((REGNO) < FIRST_PSEUDO_REGISTER                        \
568  ? GPR_P (REGNO) || (REGNO) == ARG_POINTER_REGNUM       \
569  : GPR_P (reg_renumber[REGNO]))
570 #define REGNO_OK_FOR_INDEX_P(REGNO) REGNO_OK_FOR_BASE_P(REGNO)
571
572 /* Given an rtx X being reloaded into a reg required to be
573    in class CLASS, return the class of reg to actually use.
574    In general this is just CLASS; but on some machines
575    in some cases it is preferable to use a more restrictive class.  */
576 #define PREFERRED_RELOAD_CLASS(X,CLASS) \
577 (CLASS)
578
579 /* Return the maximum number of consecutive registers
580    needed to represent mode MODE in a register of class CLASS.  */
581 #define CLASS_MAX_NREGS(CLASS, MODE) \
582 ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
583
584 /* The letters I, J, K, L, M, N, O, P in a register constraint string
585    can be used to stand for particular ranges of immediate operands.
586    This macro defines what the ranges are.
587    C is the letter, and VALUE is a constant value.
588    Return 1 if VALUE is in the range specified by C.  */
589 /* 'I' is used for 8 bit signed immediates.
590    'J' is used for 16 bit signed immediates.
591    'K' is used for 16 bit unsigned immediates.
592    'L' is used for 16 bit immediates left shifted by 16 (sign ???).
593    'M' is used for 24 bit unsigned immediates.
594    'N' is used for any 32 bit non-symbolic value.
595    'O' is used for 5 bit unsigned immediates (shift count).
596    'P' is used for 16 bit signed immediates for compares
597        (values in the range -32767 to +32768).  */
598
599 /* local to this file */
600 #define INT8_P(X) ((unsigned) ((X) + 0x80) < 0x100)
601 #define INT16_P(X) ((unsigned) ((X) + 0x8000) < 0x10000)
602 #define CMP_INT16_P(X) ((unsigned) ((X) - 1 + 0x8000) < 0x10000)
603 #define UINT16_P(X) ((unsigned) (X) < 0x10000)
604 #define UPPER16_P(X) (((X) & ~0xffff0000) == 0)
605 #define UINT24_P(X) ((unsigned) (X) < 0x1000000)
606 #define INT32_P(X) ((X) >= (-(HOST_WIDE_INT) 0x7fffffff - 1) \
607                     && (X) <= (unsigned HOST_WIDE_INT) 0xffffffff)
608 #define UINT5_P(X) ((unsigned) (X) < 32)
609
610 #define CONST_OK_FOR_LETTER_P(VALUE, C) \
611 ((C) == 'I' ? INT8_P (VALUE)            \
612  : (C) == 'J' ? INT16_P (VALUE) \
613  : (C) == 'K' ? UINT16_P (VALUE)        \
614  : (C) == 'L' ? UPPER16_P (VALUE)       \
615  : (C) == 'M' ? UINT24_P (VALUE)        \
616  : (C) == 'N' ? INT32_P (VALUE)         \
617  : (C) == 'O' ? UINT5_P (VALUE)         \
618  : (C) == 'P' ? CMP_INT16_P (VALUE)     \
619  : 0)
620
621 /* Similar, but for floating constants, and defining letters G and H.
622    Here VALUE is the CONST_DOUBLE rtx itself.
623    For the m32r, handle a few constants inline.
624    ??? We needn't treat DI and DF modes differently, but for now we do.  */
625 #define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) \
626 ((C) == 'G' ? easy_di_const (VALUE) \
627  : (C) == 'H' ? easy_df_const (VALUE) \
628  : 0)
629
630 /* A C expression that defines the optional machine-dependent constraint
631    letters that can be used to segregate specific types of operands,
632    usually memory references, for the target machine.  It should return 1 if
633    VALUE corresponds to the operand type represented by the constraint letter
634    C.  If C is not defined as an extra constraint, the value returned should
635    be 0 regardless of VALUE.  */
636 /* Q is for symbolic addresses loadable with ld24.
637    R is for symbolic addresses when ld24 can't be used.
638    S is for an 8 bit signed integer in the range +128 to -127 */
639
640 #define INVERTED_SIGNED_8BIT(VAL) ((VAL) >= -127 && (VAL) <= 128)
641
642 #define EXTRA_CONSTRAINT(VALUE, C) \
643 ((C) == 'Q' \
644  ? ((TARGET_ADDR24 && GET_CODE (VALUE) == LABEL_REF) \
645     || addr24_operand (VALUE, VOIDmode)) \
646  : (C) == 'R' \
647  ? ((TARGET_ADDR32 && GET_CODE (VALUE) == LABEL_REF) \
648     || addr32_operand (VALUE, VOIDmode)) \
649  : (C) == 'S' \
650  ?  ((GET_CODE (VALUE) == CONST_INT) && INVERTED_SIGNED_8BIT (INTVAL (VALUE))) \
651  : 0)
652 \f
653 /* Stack layout and stack pointer usage.  */
654
655 /* Define this macro if pushing a word onto the stack moves the stack
656    pointer to a smaller address.  */
657 #define STACK_GROWS_DOWNWARD
658
659 /* Define this if the nominal address of the stack frame
660    is at the high-address end of the local variables;
661    that is, each additional local variable allocated
662    goes at a more negative offset from the frame pointer.  */
663 /*#define FRAME_GROWS_DOWNWARD*/
664
665 /* Offset from frame pointer to start allocating local variables at.
666    If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
667    first local allocated.  Otherwise, it is the offset to the BEGINNING
668    of the first local allocated.  */
669 /* The frame pointer points at the same place as the stack pointer, except if
670    alloca has been called.  */
671 #define STARTING_FRAME_OFFSET \
672 M32R_STACK_ALIGN (current_function_outgoing_args_size)
673
674 /* Offset from the stack pointer register to the first location at which
675    outgoing arguments are placed.  */
676 #define STACK_POINTER_OFFSET 0
677
678 /* Offset of first parameter from the argument pointer register value.  */
679 #define FIRST_PARM_OFFSET(FNDECL) 0
680
681 /* A C expression whose value is RTL representing the address in a
682    stack frame where the pointer to the caller's frame is stored.
683    Assume that FRAMEADDR is an RTL expression for the address of the
684    stack frame itself.
685
686    If you don't define this macro, the default is to return the value
687    of FRAMEADDR--that is, the stack frame address is also the address
688    of the stack word that points to the previous frame.  */
689 /*define DYNAMIC_CHAIN_ADDRESS (FRAMEADDR)*/
690
691 /* A C expression whose value is RTL representing the value of the
692    return address for the frame COUNT steps up from the current frame.
693    FRAMEADDR is the frame pointer of the COUNT frame, or the frame
694    pointer of the COUNT - 1 frame if `RETURN_ADDR_IN_PREVIOUS_FRAME'
695    is defined.  */
696 /* The current return address is in r14.  */
697 #if 0 /* The default value should work.  */
698 #define RETURN_ADDR_RTX(COUNT, FRAME) \
699 (((COUNT) == -1)                                \
700  ? gen_rtx (REG, Pmode, 14)                     \
701  : copy_to_reg (gen_rtx (MEM, Pmode,            \
702                          memory_address (Pmode, plus_constant ((FRAME), UNITS_PER_WORD)))))
703 #endif
704
705 /* Register to use for pushing function arguments.  */
706 #define STACK_POINTER_REGNUM 15
707
708 /* Base register for access to local variables of the function.  */
709 #define FRAME_POINTER_REGNUM 13
710
711 /* Base register for access to arguments of the function.  */
712 #define ARG_POINTER_REGNUM 16
713
714 /* The register number of the return address pointer register, which
715    is used to access the current function's return address from the
716    stack.  On some machines, the return address is not at a fixed
717    offset from the frame pointer or stack pointer or argument
718    pointer.  This register can be defined to point to the return
719    address on the stack, and then be converted by `ELIMINABLE_REGS'
720    into either the frame pointer or stack pointer.
721
722    Do not define this macro unless there is no other way to get the
723    return address from the stack.  */
724 /* ??? revisit */
725 /* #define RETURN_ADDRESS_POINTER_REGNUM */
726
727 /* Register in which static-chain is passed to a function.  This must
728    not be a register used by the prologue.  */
729 #define STATIC_CHAIN_REGNUM 7
730
731 /* These aren't official macros.  */
732 #define PROLOGUE_TMP_REGNUM 4
733 #define RETURN_ADDR_REGNUM 14
734 /* #define GP_REGNUM 12 */
735 #define CARRY_REGNUM 17
736 #define M32R_MAX_INT_REGS 16
737
738      
739 #define GPR_P(REGNO) ((unsigned) (REGNO) < M32R_MAX_INT_REGS)
740 \f
741 /* Eliminating the frame and arg pointers.  */
742
743 /* A C expression which is nonzero if a function must have and use a
744    frame pointer.  This expression is evaluated in the reload pass.
745    If its value is nonzero the function will have a frame pointer.  */
746 #define FRAME_POINTER_REQUIRED \
747 (current_function_calls_alloca)
748
749 #if 0
750 /* C statement to store the difference between the frame pointer
751    and the stack pointer values immediately after the function prologue.
752    If `ELIMINABLE_REGS' is defined, this macro will be not be used and
753    need not be defined.  */
754 #define INITIAL_FRAME_POINTER_OFFSET(VAR) \
755 ((VAR) = m32r_compute_frame_size (get_frame_size ()))
756 #endif
757
758 /* If defined, this macro specifies a table of register pairs used to
759    eliminate unneeded registers that point into the stack frame.  If
760    it is not defined, the only elimination attempted by the compiler
761    is to replace references to the frame pointer with references to
762    the stack pointer.
763
764    Note that the elimination of the argument pointer with the stack
765    pointer is specified first since that is the preferred elimination.  */
766
767 #define ELIMINABLE_REGS \
768 {{ FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM },                        \
769  { ARG_POINTER_REGNUM,   STACK_POINTER_REGNUM },                        \
770  { ARG_POINTER_REGNUM,   FRAME_POINTER_REGNUM }}                        \
771
772 /* A C expression that returns non-zero if the compiler is allowed to
773    try to replace register number FROM-REG with register number
774    TO-REG.  This macro need only be defined if `ELIMINABLE_REGS' is
775    defined, and will usually be the constant 1, since most of the
776    cases preventing register elimination are things that the compiler
777    already knows about.  */
778
779 #define CAN_ELIMINATE(FROM, TO) \
780 ((FROM) == ARG_POINTER_REGNUM && (TO) == STACK_POINTER_REGNUM           \
781  ? ! frame_pointer_needed                                               \
782  : 1)
783
784 /* This macro is similar to `INITIAL_FRAME_POINTER_OFFSET'.  It
785    specifies the initial difference between the specified pair of
786    registers.  This macro must be defined if `ELIMINABLE_REGS' is
787    defined.  */
788
789 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
790 {                                                                       \
791   int size = m32r_compute_frame_size (get_frame_size ());               \
792                                                                         \
793  if ((FROM) == FRAME_POINTER_REGNUM && (TO) == STACK_POINTER_REGNUM)    \
794    (OFFSET) = 0;                                                        \
795  else if ((FROM) == ARG_POINTER_REGNUM && (TO) == FRAME_POINTER_REGNUM) \
796    (OFFSET) = size - current_function_pretend_args_size;                \
797  else if ((FROM) == ARG_POINTER_REGNUM && (TO) == STACK_POINTER_REGNUM) \
798    (OFFSET) = size - current_function_pretend_args_size;                \
799   else                                                                  \
800     abort ();                                                           \
801 }
802 \f
803 /* Function argument passing.  */
804
805 /* When a prototype says `char' or `short', really pass an `int'.  */
806 #define PROMOTE_PROTOTYPES
807
808 /* If defined, the maximum amount of space required for outgoing
809    arguments will be computed and placed into the variable
810    `current_function_outgoing_args_size'.  No space will be pushed
811    onto the stack for each call; instead, the function prologue should
812    increase the stack frame size by this amount.  */
813 #define ACCUMULATE_OUTGOING_ARGS
814
815 /* Define this macro if functions should assume that stack space has
816    been allocated for arguments even when their values are passed in
817    registers.
818
819    The value of this macro is the size, in bytes, of the area
820    reserved for arguments passed in registers for the function
821    represented by FNDECL.
822
823    This space can be allocated by the caller, or be a part of the
824    machine-dependent stack frame: `OUTGOING_REG_PARM_STACK_SPACE' says
825    which.  */
826 #if 0
827 #define REG_PARM_STACK_SPACE(FNDECL) \
828 (M32R_MAX_PARM_REGS * UNITS_PER_WORD)
829 #endif
830
831 /* Value is the number of bytes of arguments automatically
832    popped when returning from a subroutine call.
833    FUNDECL is the declaration node of the function (as a tree),
834    FUNTYPE is the data type of the function (as a tree),
835    or for a library call it is an identifier node for the subroutine name.
836    SIZE is the number of bytes of arguments passed on the stack.  */
837 #define RETURN_POPS_ARGS(DECL, FUNTYPE, SIZE) 0
838
839 /* Define a data type for recording info about an argument list
840    during the scan of that argument list.  This data type should
841    hold all necessary information about the function itself
842    and about the args processed so far, enough to enable macros
843    such as FUNCTION_ARG to determine where the next arg should go.  */
844 #define CUMULATIVE_ARGS int
845
846 /* Initialize a variable CUM of type CUMULATIVE_ARGS
847    for a call to a function whose data type is FNTYPE.
848    For a library call, FNTYPE is 0.  */
849 #define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME,INDIRECT) \
850 ((CUM) = 0)
851
852 /* The number of registers used for parameter passing.  Local to this file.  */
853 #define M32R_MAX_PARM_REGS 4
854
855 /* 1 if N is a possible register number for function argument passing.  */
856 #define FUNCTION_ARG_REGNO_P(N) \
857 ((unsigned) (N) < M32R_MAX_PARM_REGS)
858
859 /* The ROUND_ADVANCE* macros are local to this file.  */
860 /* Round SIZE up to a word boundary.  */
861 #define ROUND_ADVANCE(SIZE) \
862 (((SIZE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
863
864 /* Round arg MODE/TYPE up to the next word boundary.  */
865 #define ROUND_ADVANCE_ARG(MODE, TYPE) \
866 ((MODE) == BLKmode                              \
867  ? ROUND_ADVANCE (int_size_in_bytes (TYPE))     \
868  : ROUND_ADVANCE (GET_MODE_SIZE (MODE)))
869
870 /* Round CUM up to the necessary point for argument MODE/TYPE.  */
871 #if 0
872 #define ROUND_ADVANCE_CUM(CUM, MODE, TYPE) \
873 ((((MODE) == BLKmode ? TYPE_ALIGN (TYPE) : GET_MODE_BITSIZE (MODE)) \
874   > BITS_PER_WORD)      \
875  ? ((CUM) + 1 & ~1)     \
876  : (CUM))
877 #else
878 #define ROUND_ADVANCE_CUM(CUM, MODE, TYPE) (CUM)
879 #endif
880
881 /* Return boolean indicating arg of type TYPE and mode MODE will be passed in
882    a reg.  This includes arguments that have to be passed by reference as the
883    pointer to them is passed in a reg if one is available (and that is what
884    we're given).
885    This macro is only used in this file.  */
886 #define PASS_IN_REG_P(CUM, MODE, TYPE, NAMED) \
887 (ROUND_ADVANCE_CUM ((CUM), (MODE), (TYPE)) < M32R_MAX_PARM_REGS)
888
889 /* Determine where to put an argument to a function.
890    Value is zero to push the argument on the stack,
891    or a hard register in which to store the argument.
892
893    MODE is the argument's machine mode.
894    TYPE is the data type of the argument (as a tree).
895     This is null for libcalls where that information may
896     not be available.
897    CUM is a variable of type CUMULATIVE_ARGS which gives info about
898     the preceding args and about the function being called.
899    NAMED is nonzero if this argument is a named parameter
900     (otherwise it is an extra parameter matching an ellipsis).  */
901 /* On the M32R the first M32R_MAX_PARM_REGS args are normally in registers
902    and the rest are pushed.  */
903 #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
904 (PASS_IN_REG_P ((CUM), (MODE), (TYPE), (NAMED))                         \
905  ? gen_rtx (REG, (MODE), ROUND_ADVANCE_CUM ((CUM), (MODE), (TYPE)))     \
906  : 0)
907
908 /* ??? Quick hack to try to get varargs working the normal way.  */
909 #define FUNCTION_INCOMING_ARG(CUM, MODE, TYPE, NAMED) \
910 (((! current_function_varargs || (NAMED))                               \
911   && PASS_IN_REG_P ((CUM), (MODE), (TYPE), (NAMED)))                    \
912  ? gen_rtx (REG, (MODE), ROUND_ADVANCE_CUM ((CUM), (MODE), (TYPE)))     \
913  : 0)
914
915 /* A C expression for the number of words, at the beginning of an
916    argument, must be put in registers.  The value must be zero for
917    arguments that are passed entirely in registers or that are entirely
918    pushed on the stack.
919
920    On some machines, certain arguments must be passed partially in
921    registers and partially in memory.  On these machines, typically the
922    first @var{n} words of arguments are passed in registers, and the rest
923    on the stack.  If a multi-word argument (a @code{double} or a
924    structure) crosses that boundary, its first few words must be passed
925    in registers and the rest must be pushed.  This macro tells the
926    compiler when this occurs, and how many of the words should go in
927    registers.  */
928 #define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) \
929   function_arg_partial_nregs (&CUM, (int)MODE, TYPE, NAMED)
930
931 /* A C expression that indicates when an argument must be passed by
932    reference.  If nonzero for an argument, a copy of that argument is
933    made in memory and a pointer to the argument is passed instead of
934    the argument itself.  The pointer is passed in whatever way is
935    appropriate for passing a pointer to that type.  */
936 /* All arguments greater than 8 bytes are passed this way.  */
937 #define FUNCTION_ARG_PASS_BY_REFERENCE(CUM, MODE, TYPE, NAMED) \
938 ((TYPE) && int_size_in_bytes (TYPE) > 8)
939
940 /* Update the data in CUM to advance over an argument
941    of mode MODE and data type TYPE.
942    (TYPE is null for libcalls where that information may not be available.)  */
943 #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \
944 ((CUM) = (ROUND_ADVANCE_CUM ((CUM), (MODE), (TYPE)) \
945           + ROUND_ADVANCE_ARG ((MODE), (TYPE))))
946
947 /* If defined, a C expression that gives the alignment boundary, in bits,
948    of an argument with the specified mode and type.  If it is not defined, 
949    PARM_BOUNDARY is used for all arguments.  */
950 #if 0
951 /* We assume PARM_BOUNDARY == UNITS_PER_WORD here.  */
952 #define FUNCTION_ARG_BOUNDARY(MODE, TYPE) \
953 (((TYPE) ? TYPE_ALIGN (TYPE) : GET_MODE_BITSIZE (MODE)) <= PARM_BOUNDARY \
954  ? PARM_BOUNDARY \
955  : 2 * PARM_BOUNDARY)
956 #endif
957
958 #if 0
959 /* If defined, is a C expression that produces the machine-specific
960    code for a call to `__builtin_saveregs'.  This code will be moved
961    to the very beginning of the function, before any parameter access
962    are made.  The return value of this function should be an RTX that
963    contains the value to use as the return of `__builtin_saveregs'.
964
965    The argument ARGS is a `tree_list' containing the arguments that
966    were passed to `__builtin_saveregs'.
967
968    If this macro is not defined, the compiler will output an ordinary
969    call to the library function `__builtin_saveregs'.  */
970 extern struct rtx *m32r_expand_builtin_savergs ();
971 #define EXPAND_BUILTIN_SAVEREGS(ARGS) m32r_expand_builtin_saveregs (ARGS)
972 #endif
973
974 /* This macro offers an alternative
975    to using `__builtin_saveregs' and defining the macro
976    `EXPAND_BUILTIN_SAVEREGS'.  Use it to store the anonymous register
977    arguments into the stack so that all the arguments appear to have
978    been passed consecutively on the stack.  Once this is done, you
979    can use the standard implementation of varargs that works for
980    machines that pass all their arguments on the stack.
981
982    The argument ARGS_SO_FAR is the `CUMULATIVE_ARGS' data structure,
983    containing the values that obtain after processing of the named
984    arguments.  The arguments MODE and TYPE describe the last named
985    argument--its machine mode and its data type as a tree node.
986
987    The macro implementation should do two things: first, push onto the
988    stack all the argument registers *not* used for the named
989    arguments, and second, store the size of the data thus pushed into
990    the `int'-valued variable whose name is supplied as the argument
991    PRETEND_SIZE.  The value that you store here will serve as
992    additional offset for setting up the stack frame.
993
994    If the argument NO_RTL is nonzero, it means that the
995    arguments of the function are being analyzed for the second time.
996    This happens for an inline function, which is not actually
997    compiled until the end of the source file.  The macro
998    `SETUP_INCOMING_VARARGS' should not generate any instructions in
999    this case.  */
1000
1001 #define SETUP_INCOMING_VARARGS(ARGS_SO_FAR, MODE, TYPE, PRETEND_SIZE, NO_RTL) \
1002 m32r_setup_incoming_varargs (&ARGS_SO_FAR, MODE, TYPE, &PRETEND_SIZE, NO_RTL)
1003 \f
1004 /* Function results.  */
1005
1006 /* Define how to find the value returned by a function.
1007    VALTYPE is the data type of the value (as a tree).
1008    If the precise function being called is known, FUNC is its FUNCTION_DECL;
1009    otherwise, FUNC is 0.  */
1010 #define FUNCTION_VALUE(VALTYPE, FUNC) gen_rtx (REG, TYPE_MODE (VALTYPE), 0)
1011
1012 /* Define how to find the value returned by a library function
1013    assuming the value has mode MODE.  */
1014 #define LIBCALL_VALUE(MODE) gen_rtx (REG, MODE, 0)
1015
1016 /* 1 if N is a possible register number for a function value
1017    as seen by the caller.  */
1018 /* ??? What about r1 in DI/DF values.  */
1019 #define FUNCTION_VALUE_REGNO_P(N) ((N) == 0)
1020
1021 /* A C expression which can inhibit the returning of certain function
1022    values in registers, based on the type of value.  A nonzero value says
1023    to return the function value in memory, just as large structures are
1024    always returned.  Here TYPE will be a C expression of type `tree',
1025    representing the data type of the value.  */
1026 #define RETURN_IN_MEMORY(TYPE) \
1027 (int_size_in_bytes (TYPE) > 8)
1028
1029 /* Tell GCC to use RETURN_IN_MEMORY.  */
1030 #define DEFAULT_PCC_STRUCT_RETURN 0
1031
1032 /* Register in which address to store a structure value
1033    is passed to a function, or 0 to use `invisible' first argument.  */
1034 #define STRUCT_VALUE 0
1035 \f
1036 /* Function entry and exit.  */
1037
1038 /* Initialize data used by insn expanders.  This is called from
1039    init_emit, once for each function, before code is generated.  */
1040 #define INIT_EXPANDERS m32r_init_expanders ()
1041
1042 /* This macro generates the assembly code for function entry.
1043    FILE is a stdio stream to output the code to.
1044    SIZE is an int: how many units of temporary storage to allocate.
1045    Refer to the array `regs_ever_live' to determine which registers
1046    to save; `regs_ever_live[I]' is nonzero if register number I
1047    is ever used in the function.  This macro is responsible for
1048    knowing which registers should not be saved even if used.  */
1049 #define FUNCTION_PROLOGUE(FILE, SIZE) \
1050 m32r_output_function_prologue (FILE, SIZE)
1051
1052 /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
1053    the stack pointer does not matter.  The value is tested only in
1054    functions that have frame pointers.
1055    No definition is equivalent to always zero.  */
1056 #define EXIT_IGNORE_STACK 1
1057
1058 /* This macro generates the assembly code for function exit,
1059    on machines that need it.  If FUNCTION_EPILOGUE is not defined
1060    then individual return instructions are generated for each
1061    return statement.  Args are same as for FUNCTION_PROLOGUE.
1062
1063    The function epilogue should not depend on the current stack pointer!
1064    It should use the frame pointer only.  This is mandatory because
1065    of alloca; we also take advantage of it to omit stack adjustments
1066    before returning.  */
1067 #define FUNCTION_EPILOGUE(FILE, SIZE) \
1068 m32r_output_function_epilogue (FILE, SIZE)
1069
1070 /* Output assembler code to FILE to increment profiler label # LABELNO
1071    for profiling a function entry.  */
1072 #define FUNCTION_PROFILER(FILE, LABELNO)
1073 \f
1074 /* Trampolines.  */
1075
1076 /* On the M32R, the trampoline is
1077
1078         ld24 r7,STATIC
1079         ld24 r6,FUNCTION
1080         jmp r6
1081         nop
1082
1083    ??? Need addr32 support.
1084 */
1085
1086 /* Length in bytes of the trampoline for entering a nested function.  */
1087 #define TRAMPOLINE_SIZE 12
1088
1089 /* Emit RTL insns to initialize the variable parts of a trampoline.
1090    FNADDR is an RTX for the address of the function's pure code.
1091    CXT is an RTX for the static chain value for the function.  */
1092 #define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) \
1093 do { \
1094   emit_move_insn (gen_rtx (MEM, SImode, plus_constant (TRAMP, 0)), \
1095                   plus_constant ((CXT), 0xe7000000)); \
1096   emit_move_insn (gen_rtx (MEM, SImode, plus_constant (TRAMP, 4)), \
1097                   plus_constant ((FNADDR), 0xe6000000)); \
1098   emit_move_insn (gen_rtx (MEM, SImode, plus_constant (TRAMP, 8)), \
1099                   GEN_INT (0x1fc67000)); \
1100   emit_insn (gen_flush_icache (validize_mem (gen_rtx (MEM, SImode, TRAMP)))); \
1101 } while (0)
1102 \f
1103 /* Library calls.  */
1104
1105 /* Generate calls to memcpy, memcmp and memset.  */
1106 #define TARGET_MEM_FUNCTIONS
1107 \f
1108 /* Addressing modes, and classification of registers for them.  */
1109
1110 /* Maximum number of registers that can appear in a valid memory address.  */
1111 #define MAX_REGS_PER_ADDRESS 1
1112
1113 /* We have post-inc load and pre-dec,pre-inc store,
1114    but only for 4 byte vals.  */
1115 #if 0
1116 #define HAVE_PRE_DECREMENT
1117 #define HAVE_PRE_INCREMENT
1118 #define HAVE_POST_INCREMENT
1119 #endif
1120
1121 /* Recognize any constant value that is a valid address.  */
1122 #define CONSTANT_ADDRESS_P(X) \
1123 (GET_CODE (X) == LABEL_REF || GET_CODE (X) == SYMBOL_REF        \
1124  || GET_CODE (X) == CONST_INT || GET_CODE (X) == CONST)
1125
1126 /* Nonzero if the constant value X is a legitimate general operand.
1127    We don't allow (plus symbol large-constant) as the relocations can't
1128    describe it.  INTVAL > 32767 handles both 16 bit and 24 bit relocations.
1129    We allow all CONST_DOUBLE's as the md file patterns will force the
1130    constant to memory if they can't handle them.  */
1131
1132 #define LEGITIMATE_CONSTANT_P(X) \
1133 (! (GET_CODE (X) == CONST \
1134     && GET_CODE (XEXP (X, 0)) == PLUS \
1135     && GET_CODE (XEXP (XEXP (X, 0), 0)) == SYMBOL_REF \
1136     && GET_CODE (XEXP (XEXP (X, 0), 1)) == CONST_INT \
1137     && (unsigned HOST_WIDE_INT) INTVAL (XEXP (XEXP (X, 0), 1)) > 32767))
1138
1139 /* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
1140    and check its validity for a certain class.
1141    We have two alternate definitions for each of them.
1142    The usual definition accepts all pseudo regs; the other rejects
1143    them unless they have been allocated suitable hard regs.
1144    The symbol REG_OK_STRICT causes the latter definition to be used.
1145
1146    Most source files want to accept pseudo regs in the hope that
1147    they will get allocated to the class that the insn wants them to be in.
1148    Source files for reload pass need to be strict.
1149    After reload, it makes no difference, since pseudo regs have
1150    been eliminated by then.  */
1151
1152 #ifdef REG_OK_STRICT
1153
1154 /* Nonzero if X is a hard reg that can be used as a base reg.  */
1155 #define REG_OK_FOR_BASE_P(X) GPR_P (REGNO (X))
1156 /* Nonzero if X is a hard reg that can be used as an index.  */
1157 #define REG_OK_FOR_INDEX_P(X) REG_OK_FOR_BASE_P (X)
1158
1159 #else
1160
1161 /* Nonzero if X is a hard reg that can be used as a base reg
1162    or if it is a pseudo reg.  */
1163 #define REG_OK_FOR_BASE_P(X) \
1164 (GPR_P (REGNO (X))                      \
1165  || (REGNO (X)) == ARG_POINTER_REGNUM   \
1166  || REGNO (X) >= FIRST_PSEUDO_REGISTER)
1167 /* Nonzero if X is a hard reg that can be used as an index
1168    or if it is a pseudo reg.  */
1169 #define REG_OK_FOR_INDEX_P(X) REG_OK_FOR_BASE_P (X)
1170
1171 #endif
1172
1173 /* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression
1174    that is a valid memory address for an instruction.
1175    The MODE argument is the machine mode for the MEM expression
1176    that wants to use this address.  */
1177
1178 /* local to this file */
1179 #define RTX_OK_FOR_BASE_P(X) \
1180 (REG_P (X) && REG_OK_FOR_BASE_P (X))
1181
1182 /* local to this file */
1183 #define RTX_OK_FOR_OFFSET_P(X) \
1184 (GET_CODE (X) == CONST_INT && INT16_P (INTVAL (X)))
1185
1186 /* local to this file */
1187 #define LEGITIMATE_OFFSET_ADDRESS_P(MODE, X) \
1188 (GET_CODE (X) == PLUS                           \
1189  && RTX_OK_FOR_BASE_P (XEXP (X, 0))             \
1190  && RTX_OK_FOR_OFFSET_P (XEXP (X, 1)))
1191
1192 /* local to this file */
1193 #define LEGITIMATE_LO_SUM_ADDRESS_P(MODE, X) \
1194 (GET_CODE (X) == LO_SUM                         \
1195  && RTX_OK_FOR_BASE_P (XEXP (X, 0))             \
1196  && CONSTANT_P (XEXP (X, 1)))
1197
1198 #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \
1199 { if (RTX_OK_FOR_BASE_P (X))                            \
1200     goto ADDR;                                          \
1201   if (LEGITIMATE_OFFSET_ADDRESS_P ((MODE), (X)))        \
1202     goto ADDR;                                          \
1203   if (LEGITIMATE_LO_SUM_ADDRESS_P ((MODE), (X)))        \
1204     goto ADDR;                                          \
1205 }
1206
1207 /* Try machine-dependent ways of modifying an illegitimate address
1208    to be legitimate.  If we find one, return the new, valid address.
1209    This macro is used in only one place: `memory_address' in explow.c.
1210
1211    OLDX is the address as it was before break_out_memory_refs was called.
1212    In some cases it is useful to look at this to decide what needs to be done.
1213
1214    MODE and WIN are passed so that this macro can use
1215    GO_IF_LEGITIMATE_ADDRESS.
1216
1217    It is always safe for this macro to do nothing.  It exists to recognize
1218    opportunities to optimize the output.
1219
1220    ??? Is there anything useful we can do here for the M32R?  */
1221
1222 #define LEGITIMIZE_ADDRESS(X, OLDX, MODE, WIN)
1223
1224 /* Go to LABEL if ADDR (a legitimate address expression)
1225    has an effect that depends on the machine mode it is used for.  */
1226 #define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR, LABEL) \
1227 do {                                    \
1228   if (GET_CODE (ADDR) == PRE_DEC)       \
1229     goto LABEL;                         \
1230   if (GET_CODE (ADDR) == PRE_INC)       \
1231     goto LABEL;                         \
1232   if (GET_CODE (ADDR) == POST_INC)      \
1233     goto LABEL;                         \
1234 } while (0)
1235 \f
1236 /* Condition code usage.  */
1237
1238 /* Given a comparison code (EQ, NE, etc.) and the first operand of a COMPARE,
1239    return the mode to be used for the comparison.  */
1240 #define SELECT_CC_MODE(OP, X, Y) \
1241 ((enum machine_mode)m32r_select_cc_mode ((int)OP, X, Y))
1242
1243 /* Return non-zero if SELECT_CC_MODE will never return MODE for a
1244    floating point inequality comparison.  */
1245 #define REVERSIBLE_CC_MODE(MODE) 1 /*???*/
1246 \f
1247 /* Costs.  */
1248
1249 /* ??? I'm quite sure I don't understand enough of the subtleties involved
1250    in choosing the right numbers to use here, but there doesn't seem to be
1251    enough documentation on this.  What I've done is define an insn to cost
1252    4 "units" and work from there.  COSTS_N_INSNS (N) is defined as (N) * 4 - 2
1253    so that seems reasonable.  Some values are supposed to be defined relative
1254    to each other and thus aren't necessarily related to COSTS_N_INSNS.  */
1255
1256 /* Compute the cost of computing a constant rtl expression RTX
1257    whose rtx-code is CODE.  The body of this macro is a portion
1258    of a switch statement.  If the code is computed here,
1259    return it with a return statement.  Otherwise, break from the switch.  */
1260 /* Small integers are as cheap as registers.  4 byte values can be fetched
1261    as immediate constants - let's give that the cost of an extra insn.  */
1262 #define CONST_COSTS(X, CODE, OUTER_CODE) \
1263   case CONST_INT :                                              \
1264     if (INT16_P (INTVAL (X)))                                   \
1265       return 0;                                                 \
1266     /* fall through */                                          \
1267   case CONST :                                                  \
1268   case LABEL_REF :                                              \
1269   case SYMBOL_REF :                                             \
1270     return 4;                                                   \
1271   case CONST_DOUBLE :                                           \
1272     {                                                           \
1273       rtx high, low;                                            \
1274       split_double (X, &high, &low);                            \
1275       return 4 * (!INT16_P (INTVAL (high))                      \
1276                   + !INT16_P (INTVAL (low)));                   \
1277     }
1278
1279 /* Compute the cost of an address.  */
1280 #define ADDRESS_COST(ADDR) m32r_address_cost (ADDR)
1281
1282 /* Compute extra cost of moving data between one register class
1283    and another.  */
1284 #define REGISTER_MOVE_COST(CLASS1, CLASS2) 2
1285
1286 /* Compute the cost of moving data between registers and memory.  */
1287 /* Memory is 3 times as expensive as registers.
1288    ??? Is that the right way to look at it?  */
1289 #define MEMORY_MOVE_COST(MODE,CLASS,IN) \
1290 (GET_MODE_SIZE (MODE) <= UNITS_PER_WORD ? 6 : 12)
1291
1292 /* The cost of a branch insn.  */
1293 /* A value of 2 here causes GCC to avoid using branches in comparisons like
1294    while (a < N && a).  Branches aren't that expensive on the M32R so
1295    we define this as 1.  Defining it as 2 had a heavy hit in fp-bit.c.  */
1296 #define BRANCH_COST 1
1297
1298 /* Provide the costs of a rtl expression.  This is in the body of a
1299    switch on CODE.  The purpose for the cost of MULT is to encourage
1300    `synth_mult' to find a synthetic multiply when reasonable.
1301
1302    If we need more than 12 insns to do a multiply, then go out-of-line,
1303    since the call overhead will be < 10% of the cost of the multiply.  */
1304 #define RTX_COSTS(X, CODE, OUTER_CODE) \
1305   case MULT :                                           \
1306     return COSTS_N_INSNS (3);                           \
1307   case DIV :                                            \
1308   case UDIV :                                           \
1309   case MOD :                                            \
1310   case UMOD :                                           \
1311     return COSTS_N_INSNS (10);                          \
1312
1313 /* Nonzero if access to memory by bytes is slow and undesirable.
1314    For RISC chips, it means that access to memory by bytes is no
1315    better than access by words when possible, so grab a whole word
1316    and maybe make use of that.  */
1317 #define SLOW_BYTE_ACCESS 1
1318
1319 /* Define this macro if it is as good or better to call a constant
1320    function address than to call an address kept in a register.  */
1321 #define NO_FUNCTION_CSE
1322
1323 /* Define this macro if it is as good or better for a function to call
1324    itself with an explicit address than to call an address kept in a
1325    register.  */
1326 #define NO_RECURSIVE_FUNCTION_CSE
1327
1328 /* Enable the register move pass.
1329    This is useful for machines with only 2 address instructions.
1330    It's not currently enabled by default because on the stanford benchmarks
1331    the improvement wasn't significant and in a couple of cases caused a
1332    significant de-optimization.  */
1333 /* #define ENABLE_REGMOVE_PASS */
1334
1335 /* A C statement (sans semicolon) to update the integer variable COST based on
1336    the relationship between INSN that is dependent on DEP_INSN through the
1337    dependence LINK.  The default is to make no adjustment to COST.  This can be
1338    used for example to specify to the scheduler that an output- or
1339    anti-dependence does not incur the same cost as a data-dependence.  */
1340
1341 /* #define ADJUST_COST(INSN,LINK,DEP_INSN,COST)                         \
1342   (COST) = m32r_adjust_cost (INSN, LINK, DEP_INSN, COST) */
1343
1344 /* A C statement (sans semicolon) to update the integer scheduling
1345    priority `INSN_PRIORITY(INSN)'.  Reduce the priority to execute
1346    the INSN earlier, increase the priority to execute INSN later.
1347    Do not define this macro if you do not need to adjust the
1348    scheduling priorities of insns.  */
1349 /* #define ADJUST_PRIORITY (INSN) */
1350
1351 /* Macro to determine whether the Haifa scheduler is used.  */
1352 #ifdef HAIFA
1353 #define HAIFA_P 1
1354 #else
1355 #define HAIFA_P 0
1356 #endif
1357
1358 /* Indicate how many instructions can be issued at the same time.  */
1359 #define ISSUE_RATE 2
1360
1361 /* When the `length' insn attribute is used, this macro specifies the
1362    value to be assigned to the address of the first insn in a
1363    function.  If not specified, 0 is used.  */
1364 #define FIRST_INSN_ADDRESS m32r_first_insn_address ()
1365
1366 \f
1367 /* Section selection.  */
1368
1369 #define TEXT_SECTION_ASM_OP     "\t.section .text"
1370 #define DATA_SECTION_ASM_OP     "\t.section .data"
1371 #define RODATA_SECTION_ASM_OP   "\t.section .rodata"
1372 #define BSS_SECTION_ASM_OP      "\t.section .bss"
1373 #define SDATA_SECTION_ASM_OP    "\t.section .sdata"
1374 #define SBSS_SECTION_ASM_OP     "\t.section .sbss"
1375 /* This one is for svr4.h.  */
1376 #undef CONST_SECTION_ASM_OP
1377 #define CONST_SECTION_ASM_OP    "\t.section .rodata"
1378
1379 /* A list of names for sections other than the standard two, which are
1380    `in_text' and `in_data'.  You need not define this macro
1381    on a system with no other sections (that GCC needs to use).  */
1382 #undef EXTRA_SECTIONS
1383 #define EXTRA_SECTIONS in_sdata, in_sbss, in_const, in_ctors, in_dtors
1384
1385 /* One or more functions to be defined in "varasm.c".  These
1386    functions should do jobs analogous to those of `text_section' and
1387    `data_section', for your additional sections.  Do not define this
1388    macro if you do not define `EXTRA_SECTIONS'.  */
1389 #undef EXTRA_SECTION_FUNCTIONS
1390 #define EXTRA_SECTION_FUNCTIONS \
1391 CONST_SECTION_FUNCTION \
1392 CTORS_SECTION_FUNCTION \
1393 DTORS_SECTION_FUNCTION \
1394 SDATA_SECTION_FUNCTION \
1395 SBSS_SECTION_FUNCTION
1396
1397 #define SDATA_SECTION_FUNCTION                                          \
1398 void                                                                    \
1399 sdata_section ()                                                        \
1400 {                                                                       \
1401   if (in_section != in_sdata)                                           \
1402     {                                                                   \
1403       fprintf (asm_out_file, "%s\n", SDATA_SECTION_ASM_OP);             \
1404       in_section = in_sdata;                                            \
1405     }                                                                   \
1406 }                                                                       \
1407
1408 #define SBSS_SECTION_FUNCTION                                           \
1409 void                                                                    \
1410 sbss_section ()                                                         \
1411 {                                                                       \
1412   if (in_section != in_sbss)                                            \
1413     {                                                                   \
1414       fprintf (asm_out_file, "%s\n", SBSS_SECTION_ASM_OP);              \
1415       in_section = in_sbss;                                             \
1416     }                                                                   \
1417 }                                                                       \
1418
1419 /* A C statement or statements to switch to the appropriate section for
1420    output of EXP.  You can assume that EXP is either a `VAR_DECL' node
1421    or a constant of some sort.  RELOC indicates whether the initial value
1422    of EXP requires link-time relocations.  */
1423 extern void m32r_select_section ();
1424 #undef SELECT_SECTION
1425 #define SELECT_SECTION(EXP, RELOC) m32r_select_section ((EXP), (RELOC))
1426
1427 /* A C statement or statements to switch to the appropriate section for
1428    output of RTX in mode MODE.  You can assume that RTX
1429    is some kind of constant in RTL.  The argument MODE is redundant
1430    except in the case of a `const_int' rtx.  Select the section by
1431    calling `text_section' or one of the alternatives for other
1432    sections.
1433
1434    Do not define this macro if you put all constants in the read-only
1435    data section.  */
1436
1437 #undef SELECT_RTX_SECTION
1438
1439 /* Define this macro if jump tables (for tablejump insns) should be
1440    output in the text section, along with the assembler instructions.
1441    Otherwise, the readonly data section is used.
1442    This macro is irrelevant if there is no separate readonly data section.  */
1443 /*#define JUMP_TABLES_IN_TEXT_SECTION*/
1444
1445 /* Define this macro if references to a symbol must be treated
1446    differently depending on something about the variable or
1447    function named by the symbol (such as what section it is in).
1448
1449    The macro definition, if any, is executed immediately after the
1450    rtl for DECL or other node is created.
1451    The value of the rtl will be a `mem' whose address is a
1452    `symbol_ref'.
1453
1454    The usual thing for this macro to do is to store a flag in the
1455    `symbol_ref' (such as `SYMBOL_REF_FLAG') or to store a modified
1456    name string in the `symbol_ref' (if one bit is not enough
1457    information).  */
1458
1459 #define SDATA_FLAG_CHAR '@'
1460 /* Small objects are recorded with no prefix for space efficiency since
1461    they'll be the most common.  This isn't the case if the user passes
1462    -mmodel={medium|large} and one could choose to not mark symbols that
1463    are the default, but that complicates things.  */
1464 /*#define SMALL_FLAG_CHAR '#'*/
1465 #define MEDIUM_FLAG_CHAR '%'
1466 #define LARGE_FLAG_CHAR '&'
1467
1468 #define SDATA_NAME_P(NAME) (*(NAME) == SDATA_FLAG_CHAR)
1469 /*#define SMALL_NAME_P(NAME) (*(NAME) == SMALL_FLAG_CHAR)*/
1470 #define SMALL_NAME_P(NAME) (! ENCODED_NAME_P (NAME) && ! LIT_NAME_P (NAME))
1471 #define MEDIUM_NAME_P(NAME) (*(NAME) == MEDIUM_FLAG_CHAR)
1472 #define LARGE_NAME_P(NAME) (*(NAME) == LARGE_FLAG_CHAR)
1473 /* For string literals, etc.  */
1474 #define LIT_NAME_P(NAME) ((NAME)[0] == '*' && (NAME)[1] == '.')
1475
1476 #define ENCODED_NAME_P(SYMBOL_NAME) \
1477 (SDATA_NAME_P (SYMBOL_NAME) \
1478  /*|| SMALL_NAME_P (SYMBOL_NAME)*/ \
1479  || MEDIUM_NAME_P (SYMBOL_NAME) \
1480  || LARGE_NAME_P (SYMBOL_NAME))
1481
1482 #define ENCODE_SECTION_INFO(DECL) m32r_encode_section_info (DECL)
1483
1484 /* Decode SYM_NAME and store the real name part in VAR, sans
1485    the characters that encode section info.  Define this macro if
1486    ENCODE_SECTION_INFO alters the symbol's name string.  */
1487 /* Note that we have to handle symbols like "%*start".  */
1488 #define STRIP_NAME_ENCODING(VAR, SYMBOL_NAME) \
1489 do {                                                    \
1490   (VAR) = (SYMBOL_NAME) + ENCODED_NAME_P (SYMBOL_NAME); \
1491   (VAR) += *(VAR) == '*';                               \
1492 } while (0)
1493 \f
1494 /* PIC */
1495
1496 /* The register number of the register used to address a table of static
1497    data addresses in memory.  In some cases this register is defined by a
1498    processor's ``application binary interface'' (ABI).  When this macro
1499    is defined, RTL is generated for this register once, as with the stack
1500    pointer and frame pointer registers.  If this macro is not defined, it
1501    is up to the machine-dependent files to allocate such a register (if
1502    necessary).  */
1503 /*#define PIC_OFFSET_TABLE_REGNUM 12*/
1504
1505 /* Define this macro if the register defined by PIC_OFFSET_TABLE_REGNUM is
1506    clobbered by calls.  Do not define this macro if PIC_OFFSET_TABLE_REGNUM
1507    is not defined.  */
1508 /* This register is call-saved on the M32R.  */
1509 /*#define PIC_OFFSET_TABLE_REG_CALL_CLOBBERED*/
1510
1511 /* By generating position-independent code, when two different programs (A
1512    and B) share a common library (libC.a), the text of the library can be
1513    shared whether or not the library is linked at the same address for both
1514    programs.  In some of these environments, position-independent code
1515    requires not only the use of different addressing modes, but also
1516    special code to enable the use of these addressing modes.
1517
1518    The FINALIZE_PIC macro serves as a hook to emit these special
1519    codes once the function is being compiled into assembly code, but not
1520    before.  (It is not done before, because in the case of compiling an
1521    inline function, it would lead to multiple PIC prologues being
1522    included in functions which used inline functions and were compiled to
1523    assembly language.)  */
1524
1525 /*#define FINALIZE_PIC m32r_finalize_pic ()*/
1526
1527 /* A C expression that is nonzero if X is a legitimate immediate
1528    operand on the target machine when generating position independent code.
1529    You can assume that X satisfies CONSTANT_P, so you need not
1530    check this.  You can also assume `flag_pic' is true, so you need not
1531    check it either.  You need not define this macro if all constants
1532    (including SYMBOL_REF) can be immediate operands when generating
1533    position independent code.  */
1534 /*#define LEGITIMATE_PIC_OPERAND_P(X)*/
1535 \f
1536 /* Control the assembler format that we output.  */
1537
1538 /* Output at beginning of assembler file.  */
1539 #define ASM_FILE_START(FILE) m32r_asm_file_start (FILE)
1540
1541 /* A C string constant describing how to begin a comment in the target
1542    assembler language.  The compiler assumes that the comment will
1543    end at the end of the line.  */
1544 #define ASM_COMMENT_START ";"
1545
1546 /* Output to assembler file text saying following lines
1547    may contain character constants, extra white space, comments, etc.  */
1548 #define ASM_APP_ON ""
1549
1550 /* Output to assembler file text saying following lines
1551    no longer contain unusual constructs.  */
1552 #define ASM_APP_OFF ""
1553
1554 /* This is how to output an assembler line defining a `char' constant.  */
1555 #define ASM_OUTPUT_CHAR(FILE, VALUE) \
1556 do {                                            \
1557   fprintf (FILE, "\t.byte\t");                  \
1558   output_addr_const (FILE, (VALUE));            \
1559   fprintf (FILE, "\n");                         \
1560 } while (0)
1561
1562 /* This is how to output an assembler line defining a `short' constant.  */
1563 #define ASM_OUTPUT_SHORT(FILE, VALUE) \
1564 do {                                            \
1565   fprintf (FILE, "\t.hword\t");                 \
1566   output_addr_const (FILE, (VALUE));            \
1567   fprintf (FILE, "\n");                         \
1568 } while (0)
1569
1570 /* This is how to output an assembler line defining an `int' constant.
1571    We also handle symbol output here.  */
1572 #define ASM_OUTPUT_INT(FILE, VALUE) \
1573 do {                                                    \
1574   fprintf (FILE, "\t.word\t");                          \
1575   output_addr_const (FILE, (VALUE));                    \
1576   fprintf (FILE, "\n");                                 \
1577 } while (0)
1578
1579 /* This is how to output an assembler line defining a `float' constant.  */
1580 #define ASM_OUTPUT_FLOAT(FILE, VALUE) \
1581 do {                                                    \
1582   long t;                                               \
1583   char str[30];                                         \
1584   REAL_VALUE_TO_TARGET_SINGLE ((VALUE), t);             \
1585   REAL_VALUE_TO_DECIMAL ((VALUE), "%.20e", str);        \
1586   fprintf (FILE, "\t.word\t0x%lx %s %s\n",              \
1587            t, ASM_COMMENT_START, str);                  \
1588 } while (0)
1589
1590 /* This is how to output an assembler line defining a `double' constant.  */
1591 #define ASM_OUTPUT_DOUBLE(FILE, VALUE) \
1592 do {                                                    \
1593   long t[2];                                            \
1594   char str[30];                                         \
1595   REAL_VALUE_TO_TARGET_DOUBLE ((VALUE), t);             \
1596   REAL_VALUE_TO_DECIMAL ((VALUE), "%.20e", str);        \
1597   fprintf (FILE, "\t.word\t0x%lx %s %s\n\t.word\t0x%lx\n", \
1598            t[0], ASM_COMMENT_START, str, t[1]);         \
1599 } while (0)
1600
1601 /* This is how to output an assembler line for a numeric constant byte.  */
1602 #define ASM_OUTPUT_BYTE(FILE, VALUE)  \
1603   fprintf (FILE, "\t%s\t0x%x\n", ASM_BYTE_OP, (VALUE))
1604
1605 /* The assembler's parentheses characters.  */
1606 #define ASM_OPEN_PAREN "("
1607 #define ASM_CLOSE_PAREN ")"
1608
1609 /* This is how to output the definition of a user-level label named NAME,
1610    such as the label on a static function or variable NAME.  */
1611 /* On the M32R we need to ensure the next instruction starts on a 32 bit
1612    boundary [the previous insn must either be 2 16 bit insns or 1 32 bit].  */
1613 #define ASM_OUTPUT_LABEL(FILE, NAME) \
1614 do {                                    \
1615   assemble_name (FILE, NAME);           \
1616   fputs (":\n", FILE);                  \
1617 } while (0)
1618
1619 /* This is how to output a command to make the user-level label named NAME
1620    defined for reference from other files.  */
1621 #define ASM_GLOBALIZE_LABEL(FILE, NAME) \
1622 do {                            \
1623   fputs ("\t.global\t", FILE);  \
1624   assemble_name (FILE, NAME);   \
1625   fputs ("\n", FILE);           \
1626 } while (0)
1627
1628 /* This is how to output a reference to a user-level label named NAME.
1629    `assemble_name' uses this.  */
1630 #undef ASM_OUTPUT_LABELREF
1631 #define ASM_OUTPUT_LABELREF(FILE, NAME) \
1632 do {                                                    \
1633   char * real_name;                                     \
1634   STRIP_NAME_ENCODING (real_name, (NAME));              \
1635   fprintf (FILE, "%s%s", USER_LABEL_PREFIX, real_name); \
1636 } while (0)           
1637
1638 /* Store in OUTPUT a string (made with alloca) containing
1639    an assembler-name for a local static variable named NAME.
1640    LABELNO is an integer which is different for each call.  */
1641 #define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO) \
1642 do {                                                    \
1643   (OUTPUT) = (char *) alloca (strlen ((NAME)) + 10);    \
1644   sprintf ((OUTPUT), "%s.%d", (NAME), (LABELNO));       \
1645 } while (0)
1646
1647 /* How to refer to registers in assembler output.
1648    This sequence is indexed by compiler's hard-register-number (see above).  */
1649 #define REGISTER_NAMES \
1650 {                                                       \
1651   "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",       \
1652   "r8", "r9", "r10", "r11", "r12", "fp", "lr", "sp",    \
1653   "ap", "cbit"                                          \
1654 }
1655
1656 /* If defined, a C initializer for an array of structures containing
1657    a name and a register number.  This macro defines additional names
1658    for hard registers, thus allowing the `asm' option in declarations
1659    to refer to registers using alternate names.  */
1660 #define ADDITIONAL_REGISTER_NAMES \
1661 {                                       \
1662   /*{ "gp", GP_REGNUM },*/              \
1663   { "r13", FRAME_POINTER_REGNUM },      \
1664   { "r14", RETURN_ADDR_REGNUM },        \
1665   { "r15", STACK_POINTER_REGNUM },      \
1666 }
1667
1668 /* A C expression which evaluates to true if CODE is a valid
1669    punctuation character for use in the `PRINT_OPERAND' macro.  */
1670 extern char m32r_punct_chars[];
1671 #define PRINT_OPERAND_PUNCT_VALID_P(CHAR) \
1672 m32r_punct_chars[(unsigned char) (CHAR)]
1673
1674 /* Print operand X (an rtx) in assembler syntax to file FILE.
1675    CODE is a letter or dot (`z' in `%z0') or 0 if no letter was specified.
1676    For `%' followed by punctuation, CODE is the punctuation and X is null.  */
1677 #define PRINT_OPERAND(FILE, X, CODE) \
1678 m32r_print_operand (FILE, X, CODE)
1679
1680 /* A C compound statement to output to stdio stream STREAM the
1681    assembler syntax for an instruction operand that is a memory
1682    reference whose address is ADDR.  ADDR is an RTL expression.
1683
1684    On some machines, the syntax for a symbolic address depends on
1685    the section that the address refers to.  On these machines,
1686    define the macro `ENCODE_SECTION_INFO' to store the information
1687    into the `symbol_ref', and then check for it here.  */
1688 #define PRINT_OPERAND_ADDRESS(FILE, ADDR) \
1689 m32r_print_operand_address (FILE, ADDR)
1690
1691 /* If defined, C string expressions to be used for the `%R', `%L',
1692    `%U', and `%I' options of `asm_fprintf' (see `final.c').  These
1693    are useful when a single `md' file must support multiple assembler
1694    formats.  In that case, the various `tm.h' files can define these
1695    macros differently.  */
1696 #define REGISTER_PREFIX ""
1697 #define LOCAL_LABEL_PREFIX ".L"
1698 #define USER_LABEL_PREFIX ""
1699 #define IMMEDIATE_PREFIX "#"
1700
1701 /* This is how to output an element of a case-vector that is absolute.  */
1702 #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE)  \
1703 do {                                                    \
1704   char label[30];                                       \
1705   ASM_GENERATE_INTERNAL_LABEL (label, "L", VALUE);      \
1706   fprintf (FILE, "\t.word\t");                          \
1707   assemble_name (FILE, label);                          \
1708   fprintf (FILE, "\n");                                 \
1709 } while (0)
1710
1711 /* This is how to output an element of a case-vector that is relative.  */
1712 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
1713 do {                                                    \
1714   char label[30];                                       \
1715   ASM_GENERATE_INTERNAL_LABEL (label, "L", VALUE);      \
1716   fprintf (FILE, "\t.word\t");                          \
1717   assemble_name (FILE, label);                          \
1718   fprintf (FILE, "-");                                  \
1719   ASM_GENERATE_INTERNAL_LABEL (label, "L", REL);        \
1720   assemble_name (FILE, label);                          \
1721   fprintf (FILE, ")\n");                                \
1722 } while (0)
1723
1724 /* The desired alignment for the location counter at the beginning
1725    of a loop.  */
1726 /* On the M32R, align loops to 32 byte boundaries (cache line size)
1727    if -malign-loops.  */
1728 #define LOOP_ALIGN(LABEL) (TARGET_ALIGN_LOOPS ? 5 : 0)
1729
1730 /* This is how to output an assembler line
1731    that says to advance the location counter
1732    to a multiple of 2**LOG bytes.  */
1733 /* .balign is used to avoid confusion.  */
1734 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
1735 do { if ((LOG) != 0) fprintf (FILE, "\t.balign %d\n", 1 << (LOG)); } while (0)
1736
1737 /* Like `ASM_OUTPUT_COMMON' except takes the required alignment as a
1738    separate, explicit argument.  If you define this macro, it is used in
1739    place of `ASM_OUTPUT_COMMON', and gives you more flexibility in
1740    handling the required alignment of the variable.  The alignment is
1741    specified as the number of bits.  */
1742
1743 #define SCOMMON_ASM_OP ".scomm"
1744
1745 #undef ASM_OUTPUT_ALIGNED_COMMON
1746 #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \
1747 do {                                                                    \
1748   if (! TARGET_SDATA_NONE                                               \
1749       && (SIZE) > 0 && (SIZE) <= g_switch_value)                        \
1750     fprintf ((FILE), "\t%s\t", SCOMMON_ASM_OP);                         \
1751   else                                                                  \
1752     fprintf ((FILE), "\t%s\t", COMMON_ASM_OP);                          \
1753   assemble_name ((FILE), (NAME));                                       \
1754   fprintf ((FILE), ",%u,%u\n", (SIZE), (ALIGN) / BITS_PER_UNIT);        \
1755 } while (0)
1756
1757 #if 0 /* not needed, delete later */
1758 /* Like `ASM_OUTPUT_LOCAL' except takes the required alignment as a
1759    separate, explicit argument.  If you define this macro, it is used in
1760    place of `ASM_OUTPUT_LOCAL', and gives you more flexibility in
1761    handling the required alignment of the variable.  The alignment is
1762    specified as the number of bits.  */
1763
1764 #undef ASM_OUTPUT_ALIGNED_LOCAL
1765 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
1766 do {                                                                    \
1767   if ((SIZE) > 0 && (SIZE) <= g_switch_value)                           \
1768     {                                                                   \
1769       sbss_section ();                                                  \
1770       ASM_OUTPUT_ALIGN (FILE, exact_log2 (ALIGN / BITS_PER_UNIT));      \
1771       ASM_OUTPUT_LABEL (FILE, NAME);                                    \
1772       ASM_OUTPUT_SKIP (FILE, SIZE);                                     \
1773       if (!flag_inhibit_size_directive)                                 \
1774         {                                                               \
1775           fprintf (FILE, "\t%s\t ", SIZE_ASM_OP);                       \
1776           assemble_name (FILE, NAME);                                   \
1777           fprintf (FILE, ",%d\n",  SIZE);                               \
1778         }                                                               \
1779     }                                                                   \
1780   else                                                                  \
1781     {                                                                   \
1782       /* This is copied from svr4.h.  */                                \
1783       fprintf ((FILE), "\t%s\t", LOCAL_ASM_OP);                         \
1784       assemble_name ((FILE), (NAME));                                   \
1785       fprintf ((FILE), "\n");                                           \
1786       ASM_OUTPUT_ALIGNED_COMMON (FILE, NAME, SIZE, ALIGN);              \
1787     }                                                                   \
1788 } while (0)
1789 #endif
1790
1791 /* Like `ASM_OUTPUT_BSS' except takes the required alignment as a
1792    separate, explicit argument.  If you define this macro, it is used in
1793    place of `ASM_OUTPUT_BSS', and gives you more flexibility in
1794    handling the required alignment of the variable.  The alignment is
1795    specified as the number of bits.
1796
1797    For the M32R we need sbss support.  */
1798
1799 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
1800 do {                                                                    \
1801   ASM_GLOBALIZE_LABEL (FILE, NAME);                                     \
1802   ASM_OUTPUT_ALIGNED_COMMON (FILE, NAME, SIZE, ALIGN);                  \
1803 } while (0)
1804 \f
1805 /* Debugging information.  */
1806
1807 /* Generate DBX and DWARF debugging information.  */
1808 #define DBX_DEBUGGING_INFO
1809 #define DWARF_DEBUGGING_INFO
1810
1811 /* Prefer STABS (for now).  */
1812 #undef PREFERRED_DEBUGGING_TYPE
1813 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
1814
1815 /* How to renumber registers for dbx and gdb.  */
1816 #define DBX_REGISTER_NUMBER(REGNO) (REGNO)
1817
1818 /* Turn off splitting of long stabs.  */
1819 #define DBX_CONTIN_LENGTH 0
1820 \f
1821 /* Miscellaneous.  */
1822
1823 /* Specify the machine mode that this machine uses
1824    for the index in the tablejump instruction.  */
1825 #define CASE_VECTOR_MODE Pmode
1826
1827 /* Define as C expression which evaluates to nonzero if the tablejump
1828    instruction expects the table to contain offsets from the address of the
1829    table.
1830    Do not define this if the table should contain absolute addresses. */
1831 /* It's not clear what PIC will look like or whether we want to use -fpic
1832    for the embedded form currently being talked about.  For now require -fpic
1833    to get pc relative switch tables.  */
1834 /*#define CASE_VECTOR_PC_RELATIVE 1 */
1835
1836 /* Define if operations between registers always perform the operation
1837    on the full register even if a narrower mode is specified.  */
1838 #define WORD_REGISTER_OPERATIONS
1839
1840 /* Define if loading in MODE, an integral mode narrower than BITS_PER_WORD
1841    will either zero-extend or sign-extend.  The value of this macro should
1842    be the code that says which one of the two operations is implicitly
1843    done, NIL if none.  */
1844 #define LOAD_EXTEND_OP(MODE) ZERO_EXTEND
1845
1846 /* Specify the tree operation to be used to convert reals to integers.  */
1847 #define IMPLICIT_FIX_EXPR FIX_ROUND_EXPR
1848
1849 /* This is the kind of divide that is easiest to do in the general case.  */
1850 #define EASY_DIV_EXPR TRUNC_DIV_EXPR
1851
1852 /* Max number of bytes we can move from memory to memory
1853    in one reasonably fast instruction.  */
1854 #define MOVE_MAX 4
1855
1856 /* Define this to be nonzero if shift instructions ignore all but the low-order
1857    few bits.  */
1858 #define SHIFT_COUNT_TRUNCATED 1
1859
1860 /* Value is 1 if truncating an integer of INPREC bits to OUTPREC bits
1861    is done just by pretending it is already truncated.  */
1862 #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
1863
1864 /* We assume that the store-condition-codes instructions store 0 for false
1865    and some other value for true.  This is the value stored for true.  */
1866 #define STORE_FLAG_VALUE 1
1867
1868 /* Specify the machine mode that pointers have.
1869    After generation of rtl, the compiler makes no further distinction
1870    between pointers and any other objects of this machine mode.  */
1871 /* ??? The M32R doesn't have full 32 bit pointers, but making this PSImode has
1872    it's own problems (you have to add extendpsisi2 and truncsipsi2).
1873    Try to avoid it.  */
1874 #define Pmode SImode
1875
1876 /* A function address in a call instruction.  */
1877 #define FUNCTION_MODE SImode
1878
1879 /* A C expression whose value is nonzero if IDENTIFIER with arguments ARGS
1880    is a valid machine specific attribute for DECL.
1881    The attributes in ATTRIBUTES have previously been assigned to TYPE.  */
1882 #define VALID_MACHINE_DECL_ATTRIBUTE(DECL, ATTRIBUTES, IDENTIFIER, ARGS) \
1883 m32r_valid_machine_decl_attribute (DECL, ATTRIBUTES, IDENTIFIER, ARGS)
1884
1885 /* A C expression that returns zero if the attributes on TYPE1 and TYPE2 are
1886    incompatible, one if they are compatible, and two if they are
1887    nearly compatible (which causes a warning to be generated).  */
1888 #define COMP_TYPE_ATTRIBUTES(TYPE1, TYPE2) \
1889 m32r_comp_type_attributes (TYPE1, TYPE2)
1890
1891 /* Give newly defined TYPE some default attributes.  */
1892 #define SET_DEFAULT_TYPE_ATTRIBUTES(TYPE) \
1893 m32r_set_default_type_attributes (TYPE)
1894 \f
1895 /* Define the information needed to generate branch and scc insns.  This is
1896    stored from the compare operation.  Note that we can't use "rtx" here
1897    since it hasn't been defined!  */
1898 extern struct rtx_def * m32r_compare_op0;
1899 extern struct rtx_def * m32r_compare_op1;
1900
1901 /* M32R function types.   */
1902 enum m32r_function_type
1903 {
1904   M32R_FUNCTION_UNKNOWN, M32R_FUNCTION_NORMAL, M32R_FUNCTION_INTERRUPT
1905 };
1906 #define M32R_INTERRUPT_P(TYPE) \
1907 ((TYPE) == M32R_FUNCTION_INTERRUPT)
1908
1909 /* Define this if you have defined special-purpose predicates in the
1910    file `MACHINE.c'.  This macro is called within an initializer of an
1911    array of structures.  The first field in the structure is the name
1912    of a predicate and the second field is an array of rtl codes.  For
1913    each predicate, list all rtl codes that can be in expressions
1914    matched by the predicate.  The list should have a trailing comma.  */
1915
1916 #define PREDICATE_CODES                                                 \
1917 { "conditional_move_operand",   { REG, SUBREG, CONST_INT }},            \
1918 { "carry_compare_operand",      { EQ, NE }},                            \
1919 { "eqne_comparison_operator",   { EQ, NE }},                            \
1920 { "signed_comparison_operator", { EQ, NE, LT, LE, GT, GE }},            \
1921 { "move_dest_operand",          { REG, SUBREG, MEM }},                  \
1922 { "move_src_operand",           { REG, SUBREG, MEM, CONST_INT,          \
1923                                   CONST_DOUBLE, LABEL_REF, CONST,       \
1924                                   SYMBOL_REF }},                        \
1925 { "move_double_src_operand",    { REG, SUBREG, MEM, CONST_INT,          \
1926                                   CONST_DOUBLE }},                      \
1927 { "two_insn_const_operand",     { CONST_INT }},                         \
1928 { "symbolic_operand",           { SYMBOL_REF, LABEL_REF, CONST }},      \
1929 { "reg_or_int16_operand",       { REG, SUBREG, CONST_INT }},            \
1930 { "reg_or_uint16_operand",      { REG, SUBREG, CONST_INT }},            \
1931 { "reg_or_cmp_int16_operand",   { REG, SUBREG, CONST_INT }},            \
1932 { "reg_or_zero_operand",        { REG, SUBREG, CONST_INT }},            \
1933 { "cmp_int16_operand",          { CONST_INT }},                         \
1934 { "call_address_operand",       { SYMBOL_REF, LABEL_REF, CONST }},      \
1935 { "small_insn_p",               { INSN, CALL_INSN, JUMP_INSN }},        \
1936 { "large_insn_p",               { INSN, CALL_INSN, JUMP_INSN }},
1937
1938 /* Functions declared in m32r.c */
1939 #ifndef PROTO
1940 #if defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined (__STDC__)
1941 #define PROTO(ARGS) ARGS
1942 #else
1943 #define PROTO(ARGS) ()
1944 #endif
1945 #endif
1946
1947 #ifdef BUFSIZE          /* stdio.h has been included, ok to use FILE * */
1948 #define STDIO_PROTO(ARGS) PROTO(ARGS)
1949 #else
1950 #define STDIO_PROTO(ARGS) ()
1951 #endif
1952
1953 #ifndef TREE_CODE
1954 union tree_node;
1955 #define Tree union tree_node *
1956 #else
1957 #define Tree tree
1958 #endif
1959
1960 #ifndef RTX_CODE
1961 struct rtx_def;
1962 #define Rtx struct rtx_def *
1963 #else
1964 #define Rtx rtx
1965 #endif
1966
1967 extern void sbss_section                        PROTO((void));
1968 extern void sdata_section                       PROTO((void));
1969 extern void m32r_init                           PROTO((void));
1970 extern int  m32r_valid_machine_decl_attribute   PROTO((Tree, Tree, Tree, Tree));
1971 extern int  m32r_comp_type_attributes           PROTO((Tree, Tree));
1972 extern void m32r_select_section                 PROTO((Tree, int));
1973 extern void m32r_encode_section_info            PROTO((Tree));
1974 extern void m32r_init_expanders                 PROTO((void));
1975 extern int  call_address_operand                PROTO((Rtx, int));
1976 extern int  call_operand                        PROTO((Rtx, int));
1977 extern int  symbolic_operand                    PROTO((Rtx, int));
1978 extern int  small_data_operand                  PROTO((Rtx, int));
1979 extern int  addr24_operand                      PROTO((Rtx, int));
1980 extern int  addr32_operand                      PROTO((Rtx, int));
1981 extern int  call26_operand                      PROTO((Rtx, int));
1982 extern int  seth_add3_operand                   PROTO((Rtx, int));
1983 extern int  cmp_int16_operand                   PROTO((Rtx, int));
1984 extern int  uint16_operand                      PROTO((Rtx, int));
1985 extern int  reg_or_int16_operand                PROTO((Rtx, int));
1986 extern int  reg_or_uint16_operand               PROTO((Rtx, int));
1987 extern int  reg_or_cmp_nt16_operand             PROTO((Rtx, int));
1988 extern int  two_insn_const_operand              PROTO((Rtx, int));
1989 extern int  move_src_operand                    PROTO((Rtx, int));
1990 extern int  move_double_src_operand             PROTO((Rtx, int));
1991 extern int  move_dest_operand                   PROTO((Rtx, int));
1992 extern int  easy_di_const                       PROTO((Rtx));
1993 extern int  easy_df_const                       PROTO((Rtx));
1994 extern int  eqne_comparison_operator            PROTO((Rtx, int));
1995 extern int  signed_comparison_operator          PROTO((Rtx, int));
1996 extern int  memreg_operand                      PROTO((Rtx, int));
1997 extern int  small_insn_p                        PROTO((Rtx, int));
1998 extern int  large_insn_p                        PROTO((Rtx, int));
1999 extern int  m32r_select_cc_mode                 PROTO((int, Rtx, Rtx));
2000 extern Rtx  gen_compare                         PROTO((int, Rtx, Rtx, int));
2001 extern int  function_arg_partial_nregs          PROTO((CUMULATIVE_ARGS *,
2002                                                        int, Tree, int));
2003 extern void m32r_setup_incoming_varargs         PROTO((CUMULATIVE_ARGS *,
2004                                                        int, Tree, int *,
2005                                                        int));
2006 extern int  m32r_address_code                   PROTO((Rtx));
2007 extern enum m32r_function_type m32r_compute_function_type
2008                                                 PROTO((Tree));
2009 extern unsigned m32r_compute_frame_size         PROTO((int));
2010 extern int  m32r_first_insn_address             PROTO((void));
2011 extern void m32r_output_function_prologue       STDIO_PROTO((FILE *, int));
2012 extern void m32r_output_function_epilogue       STDIO_PROTO((FILE *, int));
2013 extern void m32r_finalize_pic                   PROTO((void));
2014 extern void m32r_initialize_trampoline          PROTO((Rtx, Rtx, Rtx));
2015 extern void m32r_asm_file_start                 STDIO_PROTO((FILE *));
2016 extern void m32r_print_operand                  STDIO_PROTO((FILE *, Rtx, int));
2017 extern void m32r_print_operand_address          STDIO_PROTO((FILE *, Rtx));
2018 extern int  zero_and_one                        PROTO((Rtx, Rtx));
2019 extern int  conditional_move_operand            PROTO((Rtx, int));
2020 extern int  carry_compare_operand               PROTO((Rtx, int));
2021 extern char *emit_cond_move                     PROTO((Rtx *, Rtx));
2022
2023 /* Needed by a peephole optimisation.  */
2024 #define PRESERVE_DEATH_INFO_REGNO_P(regno) (regno < FIRST_PSEUDO_REGISTER)