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