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