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