]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/config/m32r/m32r.h
Update Copyright years for files modified in 2011 and/or 2012.
[thirdparty/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 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
4 Free Software Foundation, Inc.
5
6 This file is part of GCC.
7
8 GCC is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published
10 by the Free Software Foundation; either version 3, or (at your
11 option) any later version.
12
13 GCC is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
16 License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
21
22 /* Things to do:
23 - longlong.h?
24 */
25
26 #undef SIZE_TYPE
27 #undef PTRDIFF_TYPE
28 #undef WCHAR_TYPE
29 #undef WCHAR_TYPE_SIZE
30 #undef CPP_SPEC
31 #undef ASM_SPEC
32 #undef LINK_SPEC
33 #undef STARTFILE_SPEC
34 #undef ENDFILE_SPEC
35
36 #undef ASM_APP_ON
37 #undef ASM_APP_OFF
38 \f
39
40 /* M32R/X overrides. */
41
42 /* Additional flags for the preprocessor. */
43 #define CPP_CPU_SPEC "%{m32rx:-D__M32RX__ -D__m32rx__ -U__M32R2__ -U__m32r2__} \
44 %{m32r2:-D__M32R2__ -D__m32r2__ -U__M32RX__ -U__m32rx__} \
45 %{m32r:-U__M32RX__ -U__m32rx__ -U__M32R2__ -U__m32r2__} \
46 "
47
48 /* Assembler switches. */
49 #define ASM_CPU_SPEC \
50 "%{m32r} %{m32rx} %{m32r2} %{!O0: %{O*: -O}} --no-warn-explicit-parallel-conflicts"
51
52 /* Use m32rx specific crt0/crtinit/crtfini files. */
53 #define STARTFILE_CPU_SPEC "%{!shared:crt0.o%s} %{m32rx:m32rx/crtinit.o%s} %{!m32rx:crtinit.o%s}"
54 #define ENDFILE_CPU_SPEC "-lgloss %{m32rx:m32rx/crtfini.o%s} %{!m32rx:crtfini.o%s}"
55
56 /* Define this macro as a C expression for the initializer of an array of
57 strings to tell the driver program which options are defaults for this
58 target and thus do not need to be handled specially when using
59 `MULTILIB_OPTIONS'. */
60 #define SUBTARGET_MULTILIB_DEFAULTS , "m32r"
61
62 /* Number of additional registers the subtarget defines. */
63 #define SUBTARGET_NUM_REGISTERS 1
64
65 /* 1 for registers that cannot be allocated. */
66 #define SUBTARGET_FIXED_REGISTERS , 1
67
68 /* 1 for registers that are not available across function calls. */
69 #define SUBTARGET_CALL_USED_REGISTERS , 1
70
71 /* Order to allocate model specific registers. */
72 #define SUBTARGET_REG_ALLOC_ORDER , 19
73
74 /* Registers which are accumulators. */
75 #define SUBTARGET_REG_CLASS_ACCUM 0x80000
76
77 /* All registers added. */
78 #define SUBTARGET_REG_CLASS_ALL SUBTARGET_REG_CLASS_ACCUM
79
80 /* Additional accumulator registers. */
81 #define SUBTARGET_ACCUM_P(REGNO) ((REGNO) == 19)
82
83 /* Define additional register names. */
84 #define SUBTARGET_REGISTER_NAMES , "a1"
85 /* end M32R/X overrides. */
86
87 /* Names to predefine in the preprocessor for this target machine. */
88 /* __M32R__ is defined by the existing compiler so we use that. */
89 #define TARGET_CPU_CPP_BUILTINS() \
90 do \
91 { \
92 builtin_define ("__M32R__"); \
93 builtin_define ("__m32r__"); \
94 builtin_assert ("cpu=m32r"); \
95 builtin_assert ("machine=m32r"); \
96 builtin_define (TARGET_BIG_ENDIAN \
97 ? "__BIG_ENDIAN__" : "__LITTLE_ENDIAN__"); \
98 } \
99 while (0)
100
101 /* This macro defines names of additional specifications to put in the specs
102 that can be used in various specifications like CC1_SPEC. Its definition
103 is an initializer with a subgrouping for each command option.
104
105 Each subgrouping contains a string constant, that defines the
106 specification name, and a string constant that used by the GCC driver
107 program.
108
109 Do not define this macro if it does not need to do anything. */
110
111 #ifndef SUBTARGET_EXTRA_SPECS
112 #define SUBTARGET_EXTRA_SPECS
113 #endif
114
115 #ifndef ASM_CPU_SPEC
116 #define ASM_CPU_SPEC ""
117 #endif
118
119 #ifndef CPP_CPU_SPEC
120 #define CPP_CPU_SPEC ""
121 #endif
122
123 #ifndef CC1_CPU_SPEC
124 #define CC1_CPU_SPEC ""
125 #endif
126
127 #ifndef LINK_CPU_SPEC
128 #define LINK_CPU_SPEC ""
129 #endif
130
131 #ifndef STARTFILE_CPU_SPEC
132 #define STARTFILE_CPU_SPEC "%{!shared:crt0.o%s} crtinit.o%s"
133 #endif
134
135 #ifndef ENDFILE_CPU_SPEC
136 #define ENDFILE_CPU_SPEC "-lgloss crtfini.o%s"
137 #endif
138
139 #ifndef RELAX_SPEC
140 #if 0 /* Not supported yet. */
141 #define RELAX_SPEC "%{mrelax:-relax}"
142 #else
143 #define RELAX_SPEC ""
144 #endif
145 #endif
146
147 #define EXTRA_SPECS \
148 { "asm_cpu", ASM_CPU_SPEC }, \
149 { "cpp_cpu", CPP_CPU_SPEC }, \
150 { "cc1_cpu", CC1_CPU_SPEC }, \
151 { "link_cpu", LINK_CPU_SPEC }, \
152 { "startfile_cpu", STARTFILE_CPU_SPEC }, \
153 { "endfile_cpu", ENDFILE_CPU_SPEC }, \
154 { "relax", RELAX_SPEC }, \
155 SUBTARGET_EXTRA_SPECS
156
157 #define CPP_SPEC "%(cpp_cpu)"
158
159 #undef CC1_SPEC
160 #define CC1_SPEC "%{G*} %(cc1_cpu)"
161
162 /* Options to pass on to the assembler. */
163 #undef ASM_SPEC
164 #define ASM_SPEC "%(asm_cpu) %(relax) %{fpic|fpie:-K PIC} %{fPIC|fPIE:-K PIC}"
165
166 #define LINK_SPEC "%{v} %(link_cpu) %(relax)"
167
168 #undef STARTFILE_SPEC
169 #define STARTFILE_SPEC "%(startfile_cpu)"
170
171 #undef ENDFILE_SPEC
172 #define ENDFILE_SPEC "%(endfile_cpu)"
173
174 #undef LIB_SPEC
175 \f
176 /* Run-time compilation parameters selecting different hardware subsets. */
177
178 #define TARGET_M32R (! TARGET_M32RX && ! TARGET_M32R2)
179
180 #ifndef TARGET_LITTLE_ENDIAN
181 #define TARGET_LITTLE_ENDIAN 0
182 #endif
183 #define TARGET_BIG_ENDIAN (! TARGET_LITTLE_ENDIAN)
184
185 /* This defaults us to m32r. */
186 #ifndef TARGET_CPU_DEFAULT
187 #define TARGET_CPU_DEFAULT 0
188 #endif
189
190 #ifndef M32R_OPTS_H
191 #include "config/m32r/m32r-opts.h"
192 #endif
193
194 /* Define this macro as a C expression for the initializer of an array of
195 strings to tell the driver program which options are defaults for this
196 target and thus do not need to be handled specially when using
197 `MULTILIB_OPTIONS'. */
198 #ifndef SUBTARGET_MULTILIB_DEFAULTS
199 #define SUBTARGET_MULTILIB_DEFAULTS
200 #endif
201
202 #ifndef MULTILIB_DEFAULTS
203 #define MULTILIB_DEFAULTS { "mmodel=small" SUBTARGET_MULTILIB_DEFAULTS }
204 #endif
205
206 #ifndef SUBTARGET_OVERRIDE_OPTIONS
207 #define SUBTARGET_OVERRIDE_OPTIONS
208 #endif
209 \f
210 /* Target machine storage layout. */
211
212 /* Define this if most significant bit is lowest numbered
213 in instructions that operate on numbered bit-fields. */
214 #define BITS_BIG_ENDIAN 1
215
216 /* Define this if most significant byte of a word is the lowest numbered. */
217 #define BYTES_BIG_ENDIAN (TARGET_LITTLE_ENDIAN == 0)
218
219 /* Define this if most significant word of a multiword number is the lowest
220 numbered. */
221 #define WORDS_BIG_ENDIAN (TARGET_LITTLE_ENDIAN == 0)
222
223 /* Width of a word, in units (bytes). */
224 #define UNITS_PER_WORD 4
225
226 /* Define this macro if it is advisable to hold scalars in registers
227 in a wider mode than that declared by the program. In such cases,
228 the value is constrained to be within the bounds of the declared
229 type, but kept valid in the wider mode. The signedness of the
230 extension may differ from that of the type. */
231 #define PROMOTE_MODE(MODE, UNSIGNEDP, TYPE) \
232 if (GET_MODE_CLASS (MODE) == MODE_INT \
233 && GET_MODE_SIZE (MODE) < UNITS_PER_WORD) \
234 { \
235 (MODE) = SImode; \
236 }
237
238 /* Allocation boundary (in *bits*) for storing arguments in argument list. */
239 #define PARM_BOUNDARY 32
240
241 /* Boundary (in *bits*) on which stack pointer should be aligned. */
242 #define STACK_BOUNDARY 32
243
244 /* ALIGN FRAMES on word boundaries */
245 #define M32R_STACK_ALIGN(LOC) (((LOC) + 3) & ~ 3)
246
247 /* Allocation boundary (in *bits*) for the code of a function. */
248 #define FUNCTION_BOUNDARY 32
249
250 /* Alignment of field after `int : 0' in a structure. */
251 #define EMPTY_FIELD_BOUNDARY 32
252
253 /* Every structure's size must be a multiple of this. */
254 #define STRUCTURE_SIZE_BOUNDARY 8
255
256 /* A bit-field declared as `int' forces `int' alignment for the struct. */
257 #define PCC_BITFIELD_TYPE_MATTERS 1
258
259 /* No data type wants to be aligned rounder than this. */
260 #define BIGGEST_ALIGNMENT 32
261
262 /* The best alignment to use in cases where we have a choice. */
263 #define FASTEST_ALIGNMENT 32
264
265 /* Make strings word-aligned so strcpy from constants will be faster. */
266 #define CONSTANT_ALIGNMENT(EXP, ALIGN) \
267 ((TREE_CODE (EXP) == STRING_CST \
268 && (ALIGN) < FASTEST_ALIGNMENT) \
269 ? FASTEST_ALIGNMENT : (ALIGN))
270
271 /* Make arrays of chars word-aligned for the same reasons. */
272 #define DATA_ALIGNMENT(TYPE, ALIGN) \
273 (TREE_CODE (TYPE) == ARRAY_TYPE \
274 && TYPE_MODE (TREE_TYPE (TYPE)) == QImode \
275 && (ALIGN) < FASTEST_ALIGNMENT ? FASTEST_ALIGNMENT : (ALIGN))
276
277 /* Set this nonzero if move instructions will actually fail to work
278 when given unaligned data. */
279 #define STRICT_ALIGNMENT 1
280
281 /* Define LAVEL_ALIGN to calculate code length of PNOP at labels. */
282 #define LABEL_ALIGN(insn) 2
283 \f
284 /* Layout of source language data types. */
285
286 #define SHORT_TYPE_SIZE 16
287 #define INT_TYPE_SIZE 32
288 #define LONG_TYPE_SIZE 32
289 #define LONG_LONG_TYPE_SIZE 64
290 #define FLOAT_TYPE_SIZE 32
291 #define DOUBLE_TYPE_SIZE 64
292 #define LONG_DOUBLE_TYPE_SIZE 64
293
294 /* Define this as 1 if `char' should by default be signed; else as 0. */
295 #define DEFAULT_SIGNED_CHAR 1
296
297 #define SIZE_TYPE "long unsigned int"
298 #define PTRDIFF_TYPE "long int"
299 #define WCHAR_TYPE "short unsigned int"
300 #define WCHAR_TYPE_SIZE 16
301 \f
302 /* Standard register usage. */
303
304 /* Number of actual hardware registers.
305 The hardware registers are assigned numbers for the compiler
306 from 0 to just below FIRST_PSEUDO_REGISTER.
307 All registers that the compiler knows about must be given numbers,
308 even those that are not normally considered general registers. */
309
310 #define M32R_NUM_REGISTERS 19
311
312 #ifndef SUBTARGET_NUM_REGISTERS
313 #define SUBTARGET_NUM_REGISTERS 0
314 #endif
315
316 #define FIRST_PSEUDO_REGISTER (M32R_NUM_REGISTERS + SUBTARGET_NUM_REGISTERS)
317
318 /* 1 for registers that have pervasive standard uses
319 and are not available for the register allocator.
320
321 0-3 - arguments/results
322 4-5 - call used [4 is used as a tmp during prologue/epilogue generation]
323 6 - call used, gptmp
324 7 - call used, static chain pointer
325 8-11 - call saved
326 12 - call saved [reserved for global pointer]
327 13 - frame pointer
328 14 - subroutine link register
329 15 - stack pointer
330 16 - arg pointer
331 17 - carry flag
332 18 - accumulator
333 19 - accumulator 1 in the m32r/x
334 By default, the extension registers are not available. */
335
336 #ifndef SUBTARGET_FIXED_REGISTERS
337 #define SUBTARGET_FIXED_REGISTERS
338 #endif
339
340 #define FIXED_REGISTERS \
341 { \
342 0, 0, 0, 0, 0, 0, 0, 0, \
343 0, 0, 0, 0, 0, 0, 0, 1, \
344 1, 1, 1 \
345 SUBTARGET_FIXED_REGISTERS \
346 }
347
348 /* 1 for registers not available across function calls.
349 These must include the FIXED_REGISTERS and also any
350 registers that can be used without being saved.
351 The latter must include the registers where values are returned
352 and the register where structure-value addresses are passed.
353 Aside from that, you can include as many other registers as you like. */
354
355 #ifndef SUBTARGET_CALL_USED_REGISTERS
356 #define SUBTARGET_CALL_USED_REGISTERS
357 #endif
358
359 #define CALL_USED_REGISTERS \
360 { \
361 1, 1, 1, 1, 1, 1, 1, 1, \
362 0, 0, 0, 0, 0, 0, 1, 1, \
363 1, 1, 1 \
364 SUBTARGET_CALL_USED_REGISTERS \
365 }
366
367 #define CALL_REALLY_USED_REGISTERS CALL_USED_REGISTERS
368
369 /* If defined, an initializer for a vector of integers, containing the
370 numbers of hard registers in the order in which GCC should
371 prefer to use them (from most preferred to least). */
372
373 #ifndef SUBTARGET_REG_ALLOC_ORDER
374 #define SUBTARGET_REG_ALLOC_ORDER
375 #endif
376
377 #if 1 /* Better for int code. */
378 #define REG_ALLOC_ORDER \
379 { \
380 4, 5, 6, 7, 2, 3, 8, 9, 10, \
381 11, 12, 13, 14, 0, 1, 15, 16, 17, 18 \
382 SUBTARGET_REG_ALLOC_ORDER \
383 }
384
385 #else /* Better for fp code at expense of int code. */
386 #define REG_ALLOC_ORDER \
387 { \
388 0, 1, 2, 3, 4, 5, 6, 7, 8, \
389 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 \
390 SUBTARGET_REG_ALLOC_ORDER \
391 }
392 #endif
393
394 /* Return number of consecutive hard regs needed starting at reg REGNO
395 to hold something of mode MODE.
396 This is ordinarily the length in words of a value of mode MODE
397 but can be less for certain modes in special long registers. */
398 #define HARD_REGNO_NREGS(REGNO, MODE) \
399 ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
400
401 /* Value is 1 if hard register REGNO can hold a value of machine-mode MODE. */
402 extern const unsigned int m32r_hard_regno_mode_ok[FIRST_PSEUDO_REGISTER];
403 extern unsigned int m32r_mode_class[];
404 #define HARD_REGNO_MODE_OK(REGNO, MODE) \
405 ((m32r_hard_regno_mode_ok[REGNO] & m32r_mode_class[MODE]) != 0)
406
407 /* A C expression that is nonzero if it is desirable to choose
408 register allocation so as to avoid move instructions between a
409 value of mode MODE1 and a value of mode MODE2.
410
411 If `HARD_REGNO_MODE_OK (R, MODE1)' and `HARD_REGNO_MODE_OK (R,
412 MODE2)' are ever different for any R, then `MODES_TIEABLE_P (MODE1,
413 MODE2)' must be zero. */
414
415 /* Tie QI/HI/SI modes together. */
416 #define MODES_TIEABLE_P(MODE1, MODE2) \
417 ( GET_MODE_CLASS (MODE1) == MODE_INT \
418 && GET_MODE_CLASS (MODE2) == MODE_INT \
419 && GET_MODE_SIZE (MODE1) <= UNITS_PER_WORD \
420 && GET_MODE_SIZE (MODE2) <= UNITS_PER_WORD)
421
422 #define HARD_REGNO_RENAME_OK(OLD_REG, NEW_REG) \
423 m32r_hard_regno_rename_ok (OLD_REG, NEW_REG)
424 \f
425 /* Register classes and constants. */
426
427 /* Define the classes of registers for register constraints in the
428 machine description. Also define ranges of constants.
429
430 One of the classes must always be named ALL_REGS and include all hard regs.
431 If there is more than one class, another class must be named NO_REGS
432 and contain no registers.
433
434 The name GENERAL_REGS must be the name of a class (or an alias for
435 another name such as ALL_REGS). This is the class of registers
436 that is allowed by "g" or "r" in a register constraint.
437 Also, registers outside this class are allocated only when
438 instructions express preferences for them.
439
440 The classes must be numbered in nondecreasing order; that is,
441 a larger-numbered class must never be contained completely
442 in a smaller-numbered class.
443
444 For any two classes, it is very desirable that there be another
445 class that represents their union.
446
447 It is important that any condition codes have class NO_REGS.
448 See `register_operand'. */
449
450 enum reg_class
451 {
452 NO_REGS, CARRY_REG, ACCUM_REGS, GENERAL_REGS, ALL_REGS, LIM_REG_CLASSES
453 };
454
455 #define N_REG_CLASSES ((int) LIM_REG_CLASSES)
456
457 /* Give names of register classes as strings for dump file. */
458 #define REG_CLASS_NAMES \
459 { "NO_REGS", "CARRY_REG", "ACCUM_REGS", "GENERAL_REGS", "ALL_REGS" }
460
461 /* Define which registers fit in which classes.
462 This is an initializer for a vector of HARD_REG_SET
463 of length N_REG_CLASSES. */
464
465 #ifndef SUBTARGET_REG_CLASS_CARRY
466 #define SUBTARGET_REG_CLASS_CARRY 0
467 #endif
468
469 #ifndef SUBTARGET_REG_CLASS_ACCUM
470 #define SUBTARGET_REG_CLASS_ACCUM 0
471 #endif
472
473 #ifndef SUBTARGET_REG_CLASS_GENERAL
474 #define SUBTARGET_REG_CLASS_GENERAL 0
475 #endif
476
477 #ifndef SUBTARGET_REG_CLASS_ALL
478 #define SUBTARGET_REG_CLASS_ALL 0
479 #endif
480
481 #define REG_CLASS_CONTENTS \
482 { \
483 { 0x00000 }, \
484 { 0x20000 | SUBTARGET_REG_CLASS_CARRY }, \
485 { 0x40000 | SUBTARGET_REG_CLASS_ACCUM }, \
486 { 0x1ffff | SUBTARGET_REG_CLASS_GENERAL }, \
487 { 0x7ffff | SUBTARGET_REG_CLASS_ALL }, \
488 }
489
490 /* The same information, inverted:
491 Return the class number of the smallest class containing
492 reg number REGNO. This could be a conditional expression
493 or could index an array. */
494 extern enum reg_class m32r_regno_reg_class[FIRST_PSEUDO_REGISTER];
495 #define REGNO_REG_CLASS(REGNO) (m32r_regno_reg_class[REGNO])
496
497 /* The class value for index registers, and the one for base regs. */
498 #define INDEX_REG_CLASS GENERAL_REGS
499 #define BASE_REG_CLASS GENERAL_REGS
500
501 /* These assume that REGNO is a hard or pseudo reg number.
502 They give nonzero only if REGNO is a hard reg of the suitable class
503 or a pseudo reg currently allocated to a suitable hard reg.
504 Since they use reg_renumber, they are safe only once reg_renumber
505 has been allocated, which happens in reginfo.c during register
506 allocation. */
507 #define REGNO_OK_FOR_BASE_P(REGNO) \
508 ((REGNO) < FIRST_PSEUDO_REGISTER \
509 ? GPR_P (REGNO) || (REGNO) == ARG_POINTER_REGNUM \
510 : GPR_P (reg_renumber[REGNO]))
511
512 #define REGNO_OK_FOR_INDEX_P(REGNO) REGNO_OK_FOR_BASE_P(REGNO)
513
514 /* Return true if a value is inside a range. */
515 #define IN_RANGE_P(VALUE, LOW, HIGH) \
516 (((unsigned HOST_WIDE_INT)((VALUE) - (LOW))) \
517 <= ((unsigned HOST_WIDE_INT)((HIGH) - (LOW))))
518
519 /* Some range macros. */
520 #define INT16_P(X) ((X) >= - 0x8000 && (X) <= 0x7fff)
521 #define CMP_INT16_P(X) ((X) >= - 0x7fff && (X) <= 0x8000)
522 #define UINT16_P(X) (((unsigned HOST_WIDE_INT) (X)) <= 0x0000ffff)
523 #define UINT24_P(X) (((unsigned HOST_WIDE_INT) (X)) <= 0x00ffffff)
524 \f
525 /* Stack layout and stack pointer usage. */
526
527 /* Define this macro if pushing a word onto the stack moves the stack
528 pointer to a smaller address. */
529 #define STACK_GROWS_DOWNWARD
530
531 /* Offset from frame pointer to start allocating local variables at.
532 If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
533 first local allocated. Otherwise, it is the offset to the BEGINNING
534 of the first local allocated. */
535 /* The frame pointer points at the same place as the stack pointer, except if
536 alloca has been called. */
537 #define STARTING_FRAME_OFFSET \
538 M32R_STACK_ALIGN (crtl->outgoing_args_size)
539
540 /* Offset from the stack pointer register to the first location at which
541 outgoing arguments are placed. */
542 #define STACK_POINTER_OFFSET 0
543
544 /* Offset of first parameter from the argument pointer register value. */
545 #define FIRST_PARM_OFFSET(FNDECL) 0
546
547 /* Register to use for pushing function arguments. */
548 #define STACK_POINTER_REGNUM 15
549
550 /* Base register for access to local variables of the function. */
551 #define FRAME_POINTER_REGNUM 13
552
553 /* Base register for access to arguments of the function. */
554 #define ARG_POINTER_REGNUM 16
555
556 /* Register in which static-chain is passed to a function.
557 This must not be a register used by the prologue. */
558 #define STATIC_CHAIN_REGNUM 7
559
560 /* These aren't official macros. */
561 #define PROLOGUE_TMP_REGNUM 4
562 #define RETURN_ADDR_REGNUM 14
563 /* #define GP_REGNUM 12 */
564 #define CARRY_REGNUM 17
565 #define ACCUM_REGNUM 18
566 #define M32R_MAX_INT_REGS 16
567
568 #ifndef SUBTARGET_GPR_P
569 #define SUBTARGET_GPR_P(REGNO) 0
570 #endif
571
572 #ifndef SUBTARGET_ACCUM_P
573 #define SUBTARGET_ACCUM_P(REGNO) 0
574 #endif
575
576 #ifndef SUBTARGET_CARRY_P
577 #define SUBTARGET_CARRY_P(REGNO) 0
578 #endif
579
580 #define GPR_P(REGNO) (IN_RANGE_P ((REGNO), 0, 15) || SUBTARGET_GPR_P (REGNO))
581 #define ACCUM_P(REGNO) ((REGNO) == ACCUM_REGNUM || SUBTARGET_ACCUM_P (REGNO))
582 #define CARRY_P(REGNO) ((REGNO) == CARRY_REGNUM || SUBTARGET_CARRY_P (REGNO))
583 \f
584 /* Eliminating the frame and arg pointers. */
585
586 #if 0
587 /* C statement to store the difference between the frame pointer
588 and the stack pointer values immediately after the function prologue.
589 If `ELIMINABLE_REGS' is defined, this macro will be not be used and
590 need not be defined. */
591 #define INITIAL_FRAME_POINTER_OFFSET(VAR) \
592 ((VAR) = m32r_compute_frame_size (get_frame_size ()))
593 #endif
594
595 /* If defined, this macro specifies a table of register pairs used to
596 eliminate unneeded registers that point into the stack frame. If
597 it is not defined, the only elimination attempted by the compiler
598 is to replace references to the frame pointer with references to
599 the stack pointer.
600
601 Note that the elimination of the argument pointer with the stack
602 pointer is specified first since that is the preferred elimination. */
603
604 #define ELIMINABLE_REGS \
605 {{ FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM }, \
606 { ARG_POINTER_REGNUM, STACK_POINTER_REGNUM }, \
607 { ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM }}
608
609 /* This macro is similar to `INITIAL_FRAME_POINTER_OFFSET'. It
610 specifies the initial difference between the specified pair of
611 registers. This macro must be defined if `ELIMINABLE_REGS' is
612 defined. */
613
614 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
615 do \
616 { \
617 int size = m32r_compute_frame_size (get_frame_size ()); \
618 \
619 if ((FROM) == FRAME_POINTER_REGNUM && (TO) == STACK_POINTER_REGNUM) \
620 (OFFSET) = 0; \
621 else if ((FROM) == ARG_POINTER_REGNUM && (TO) == FRAME_POINTER_REGNUM) \
622 (OFFSET) = size - crtl->args.pretend_args_size; \
623 else if ((FROM) == ARG_POINTER_REGNUM && (TO) == STACK_POINTER_REGNUM) \
624 (OFFSET) = size - crtl->args.pretend_args_size; \
625 else \
626 gcc_unreachable (); \
627 } \
628 while (0)
629 \f
630 /* Function argument passing. */
631
632 /* If defined, the maximum amount of space required for outgoing
633 arguments will be computed and placed into the variable
634 `crtl->outgoing_args_size'. No space will be pushed
635 onto the stack for each call; instead, the function prologue should
636 increase the stack frame size by this amount. */
637 #define ACCUMULATE_OUTGOING_ARGS 1
638
639 /* Define a data type for recording info about an argument list
640 during the scan of that argument list. This data type should
641 hold all necessary information about the function itself
642 and about the args processed so far, enough to enable macros
643 such as FUNCTION_ARG to determine where the next arg should go. */
644 #define CUMULATIVE_ARGS int
645
646 /* Initialize a variable CUM of type CUMULATIVE_ARGS
647 for a call to a function whose data type is FNTYPE.
648 For a library call, FNTYPE is 0. */
649 #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, INDIRECT, N_NAMED_ARGS) \
650 ((CUM) = 0)
651
652 /* The number of registers used for parameter passing. Local to this file. */
653 #define M32R_MAX_PARM_REGS 4
654
655 /* 1 if N is a possible register number for function argument passing. */
656 #define FUNCTION_ARG_REGNO_P(N) \
657 ((unsigned) (N) < M32R_MAX_PARM_REGS)
658
659 \f
660 /* Function results. */
661
662 /* Tell GCC to use TARGET_RETURN_IN_MEMORY. */
663 #define DEFAULT_PCC_STRUCT_RETURN 0
664 \f
665 /* Function entry and exit. */
666
667 /* Initialize data used by insn expanders. This is called from
668 init_emit, once for each function, before code is generated. */
669 #define INIT_EXPANDERS m32r_init_expanders ()
670
671 /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
672 the stack pointer does not matter. The value is tested only in
673 functions that have frame pointers.
674 No definition is equivalent to always zero. */
675 #define EXIT_IGNORE_STACK 1
676
677 /* Output assembler code to FILE to increment profiler label # LABELNO
678 for profiling a function entry. */
679 #undef FUNCTION_PROFILER
680 #define FUNCTION_PROFILER(FILE, LABELNO) \
681 do \
682 { \
683 if (flag_pic) \
684 { \
685 fprintf (FILE, "\tld24 r14,#mcount\n"); \
686 fprintf (FILE, "\tadd r14,r12\n"); \
687 fprintf (FILE, "\tld r14,@r14\n"); \
688 fprintf (FILE, "\tjl r14\n"); \
689 } \
690 else \
691 { \
692 if (TARGET_ADDR24) \
693 fprintf (FILE, "\tbl mcount\n"); \
694 else \
695 { \
696 fprintf (FILE, "\tseth r14,#high(mcount)\n"); \
697 fprintf (FILE, "\tor3 r14,r14,#low(mcount)\n"); \
698 fprintf (FILE, "\tjl r14\n"); \
699 } \
700 } \
701 fprintf (FILE, "\taddi sp,#4\n"); \
702 } \
703 while (0)
704 \f
705 /* Trampolines. */
706
707 /* On the M32R, the trampoline is:
708
709 mv r7, lr -> bl L1 ; 178e 7e01
710 L1: add3 r6, lr, #L2-L1 ; 86ae 000c (L2 - L1 = 12)
711 mv lr, r7 -> ld r7,@r6+ ; 1e87 27e6
712 ld r6, @r6 -> jmp r6 ; 26c6 1fc6
713 L2: .word STATIC
714 .word FUNCTION */
715
716 #ifndef CACHE_FLUSH_FUNC
717 #define CACHE_FLUSH_FUNC "_flush_cache"
718 #endif
719 #ifndef CACHE_FLUSH_TRAP
720 #define CACHE_FLUSH_TRAP 12
721 #endif
722
723 /* Length in bytes of the trampoline for entering a nested function. */
724 #define TRAMPOLINE_SIZE 24
725
726 \f
727 #define RETURN_ADDR_RTX(COUNT, FRAME) m32r_return_addr (COUNT)
728
729 #define INCOMING_RETURN_ADDR_RTX gen_rtx_REG (Pmode, RETURN_ADDR_REGNUM)
730
731 /* Addressing modes, and classification of registers for them. */
732
733 /* Maximum number of registers that can appear in a valid memory address. */
734 #define MAX_REGS_PER_ADDRESS 1
735
736 /* We have post-inc load and pre-dec,pre-inc store,
737 but only for 4 byte vals. */
738 #define HAVE_PRE_DECREMENT 1
739 #define HAVE_PRE_INCREMENT 1
740 #define HAVE_POST_INCREMENT 1
741
742 /* Recognize any constant value that is a valid address. */
743 #define CONSTANT_ADDRESS_P(X) \
744 ( GET_CODE (X) == LABEL_REF \
745 || GET_CODE (X) == SYMBOL_REF \
746 || CONST_INT_P (X) \
747 || (GET_CODE (X) == CONST \
748 && ! (flag_pic && ! m32r_legitimate_pic_operand_p (X))))
749 \f
750 /* Condition code usage. */
751
752 /* Return nonzero if SELECT_CC_MODE will never return MODE for a
753 floating point inequality comparison. */
754 #define REVERSIBLE_CC_MODE(MODE) 1 /*???*/
755 \f
756 /* Costs. */
757
758 /* The cost of a branch insn. */
759 /* A value of 2 here causes GCC to avoid using branches in comparisons like
760 while (a < N && a). Branches aren't that expensive on the M32R so
761 we define this as 1. Defining it as 2 had a heavy hit in fp-bit.c. */
762 #define BRANCH_COST(speed_p, predictable_p) ((TARGET_BRANCH_COST) ? 2 : 1)
763
764 /* Nonzero if access to memory by bytes is slow and undesirable.
765 For RISC chips, it means that access to memory by bytes is no
766 better than access by words when possible, so grab a whole word
767 and maybe make use of that. */
768 #define SLOW_BYTE_ACCESS 1
769
770 /* Define this macro if it is as good or better to call a constant
771 function address than to call an address kept in a register. */
772 #define NO_FUNCTION_CSE
773 \f
774 /* Section selection. */
775
776 #define TEXT_SECTION_ASM_OP "\t.section .text"
777 #define DATA_SECTION_ASM_OP "\t.section .data"
778 #define BSS_SECTION_ASM_OP "\t.section .bss"
779
780 /* Define this macro if jump tables (for tablejump insns) should be
781 output in the text section, along with the assembler instructions.
782 Otherwise, the readonly data section is used.
783 This macro is irrelevant if there is no separate readonly data section. */
784 #define JUMP_TABLES_IN_TEXT_SECTION (flag_pic)
785 \f
786 /* Position Independent Code. */
787
788 /* The register number of the register used to address a table of static
789 data addresses in memory. In some cases this register is defined by a
790 processor's ``application binary interface'' (ABI). When this macro
791 is defined, RTL is generated for this register once, as with the stack
792 pointer and frame pointer registers. If this macro is not defined, it
793 is up to the machine-dependent files to allocate such a register (if
794 necessary). */
795 #define PIC_OFFSET_TABLE_REGNUM 12
796
797 /* Define this macro if the register defined by PIC_OFFSET_TABLE_REGNUM is
798 clobbered by calls. Do not define this macro if PIC_OFFSET_TABLE_REGNUM
799 is not defined. */
800 /* This register is call-saved on the M32R. */
801 /*#define PIC_OFFSET_TABLE_REG_CALL_CLOBBERED*/
802
803 /* A C expression that is nonzero if X is a legitimate immediate
804 operand on the target machine when generating position independent code.
805 You can assume that X satisfies CONSTANT_P, so you need not
806 check this. You can also assume `flag_pic' is true, so you need not
807 check it either. You need not define this macro if all constants
808 (including SYMBOL_REF) can be immediate operands when generating
809 position independent code. */
810 #define LEGITIMATE_PIC_OPERAND_P(X) m32r_legitimate_pic_operand_p (X)
811 \f
812 /* Control the assembler format that we output. */
813
814 /* A C string constant describing how to begin a comment in the target
815 assembler language. The compiler assumes that the comment will
816 end at the end of the line. */
817 #define ASM_COMMENT_START ";"
818
819 /* Output to assembler file text saying following lines
820 may contain character constants, extra white space, comments, etc. */
821 #define ASM_APP_ON ""
822
823 /* Output to assembler file text saying following lines
824 no longer contain unusual constructs. */
825 #define ASM_APP_OFF ""
826
827 /* Globalizing directive for a label. */
828 #define GLOBAL_ASM_OP "\t.global\t"
829
830 /* We do not use DBX_LINES_FUNCTION_RELATIVE or
831 dbxout_stab_value_internal_label_diff here because
832 we need to use .debugsym for the line label. */
833
834 #define DBX_OUTPUT_SOURCE_LINE(file, line, counter) \
835 do \
836 { \
837 const char * begin_label = \
838 XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0); \
839 char label[64]; \
840 ASM_GENERATE_INTERNAL_LABEL (label, "LM", counter); \
841 \
842 dbxout_begin_stabn_sline (line); \
843 assemble_name (file, label); \
844 putc ('-', file); \
845 assemble_name (file, begin_label); \
846 fputs ("\n\t.debugsym ", file); \
847 assemble_name (file, label); \
848 putc ('\n', file); \
849 counter += 1; \
850 } \
851 while (0)
852
853 /* How to refer to registers in assembler output.
854 This sequence is indexed by compiler's hard-register-number (see above). */
855 #ifndef SUBTARGET_REGISTER_NAMES
856 #define SUBTARGET_REGISTER_NAMES
857 #endif
858
859 #define REGISTER_NAMES \
860 { \
861 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
862 "r8", "r9", "r10", "r11", "r12", "fp", "lr", "sp", \
863 "ap", "cbit", "a0" \
864 SUBTARGET_REGISTER_NAMES \
865 }
866
867 /* If defined, a C initializer for an array of structures containing
868 a name and a register number. This macro defines additional names
869 for hard registers, thus allowing the `asm' option in declarations
870 to refer to registers using alternate names. */
871 #ifndef SUBTARGET_ADDITIONAL_REGISTER_NAMES
872 #define SUBTARGET_ADDITIONAL_REGISTER_NAMES
873 #endif
874
875 #define ADDITIONAL_REGISTER_NAMES \
876 { \
877 /*{ "gp", GP_REGNUM },*/ \
878 { "r13", FRAME_POINTER_REGNUM }, \
879 { "r14", RETURN_ADDR_REGNUM }, \
880 { "r15", STACK_POINTER_REGNUM }, \
881 SUBTARGET_ADDITIONAL_REGISTER_NAMES \
882 }
883
884 /* If defined, C string expressions to be used for the `%R', `%L',
885 `%U', and `%I' options of `asm_fprintf' (see `final.c'). These
886 are useful when a single `md' file must support multiple assembler
887 formats. In that case, the various `tm.h' files can define these
888 macros differently. */
889 #define REGISTER_PREFIX ""
890 #define LOCAL_LABEL_PREFIX ".L"
891 #define USER_LABEL_PREFIX ""
892 #define IMMEDIATE_PREFIX "#"
893
894 /* This is how to output an element of a case-vector that is absolute. */
895 #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \
896 do \
897 { \
898 char label[30]; \
899 ASM_GENERATE_INTERNAL_LABEL (label, "L", VALUE); \
900 fprintf (FILE, "\t.word\t"); \
901 assemble_name (FILE, label); \
902 fprintf (FILE, "\n"); \
903 } \
904 while (0)
905
906 /* This is how to output an element of a case-vector that is relative. */
907 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL)\
908 do \
909 { \
910 char label[30]; \
911 ASM_GENERATE_INTERNAL_LABEL (label, "L", VALUE); \
912 fprintf (FILE, "\t.word\t"); \
913 assemble_name (FILE, label); \
914 fprintf (FILE, "-"); \
915 ASM_GENERATE_INTERNAL_LABEL (label, "L", REL); \
916 assemble_name (FILE, label); \
917 fprintf (FILE, "\n"); \
918 } \
919 while (0)
920
921 /* The desired alignment for the location counter at the beginning
922 of a loop. */
923 /* On the M32R, align loops to 32 byte boundaries (cache line size)
924 if -malign-loops. */
925 #define LOOP_ALIGN(LABEL) (TARGET_ALIGN_LOOPS ? 5 : 0)
926
927 /* Define this to be the maximum number of insns to move around when moving
928 a loop test from the top of a loop to the bottom
929 and seeing whether to duplicate it. The default is thirty.
930
931 Loop unrolling currently doesn't like this optimization, so
932 disable doing if we are unrolling loops and saving space. */
933 #define LOOP_TEST_THRESHOLD (optimize_size \
934 && !flag_unroll_loops \
935 && !flag_unroll_all_loops ? 2 : 30)
936
937 /* This is how to output an assembler line
938 that says to advance the location counter
939 to a multiple of 2**LOG bytes. */
940 /* .balign is used to avoid confusion. */
941 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
942 do \
943 { \
944 if ((LOG) != 0) \
945 fprintf (FILE, "\t.balign %d\n", 1 << (LOG)); \
946 } \
947 while (0)
948
949 /* Like `ASM_OUTPUT_COMMON' except takes the required alignment as a
950 separate, explicit argument. If you define this macro, it is used in
951 place of `ASM_OUTPUT_COMMON', and gives you more flexibility in
952 handling the required alignment of the variable. The alignment is
953 specified as the number of bits. */
954
955 #define SCOMMON_ASM_OP "\t.scomm\t"
956
957 #undef ASM_OUTPUT_ALIGNED_COMMON
958 #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \
959 do \
960 { \
961 if (! TARGET_SDATA_NONE \
962 && (SIZE) > 0 \
963 && (SIZE) <= (unsigned HOST_WIDE_INT) g_switch_value) \
964 fprintf ((FILE), "%s", SCOMMON_ASM_OP); \
965 else \
966 fprintf ((FILE), "%s", COMMON_ASM_OP); \
967 assemble_name ((FILE), (NAME)); \
968 fprintf ((FILE), ",%u,%u\n", (int)(SIZE), (ALIGN) / BITS_PER_UNIT);\
969 } \
970 while (0)
971
972 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
973 do \
974 { \
975 if (! TARGET_SDATA_NONE \
976 && (SIZE) > 0 \
977 && (SIZE) <= (unsigned HOST_WIDE_INT) g_switch_value) \
978 switch_to_section (get_named_section (NULL, ".sbss", 0)); \
979 else \
980 switch_to_section (bss_section); \
981 ASM_OUTPUT_ALIGN (FILE, floor_log2 (ALIGN / BITS_PER_UNIT)); \
982 last_assemble_variable_decl = DECL; \
983 ASM_DECLARE_OBJECT_NAME (FILE, NAME, DECL); \
984 ASM_OUTPUT_SKIP (FILE, SIZE ? SIZE : 1); \
985 } \
986 while (0)
987 \f
988 /* Debugging information. */
989
990 /* Generate DBX and DWARF debugging information. */
991 #define DBX_DEBUGGING_INFO 1
992 #define DWARF2_DEBUGGING_INFO 1
993
994 /* Use DWARF2 debugging info by default. */
995 #undef PREFERRED_DEBUGGING_TYPE
996 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
997
998 /* Turn off splitting of long stabs. */
999 #define DBX_CONTIN_LENGTH 0
1000 \f
1001 /* Miscellaneous. */
1002
1003 /* Specify the machine mode that this machine uses
1004 for the index in the tablejump instruction. */
1005 #define CASE_VECTOR_MODE (flag_pic ? SImode : Pmode)
1006
1007 /* Define if operations between registers always perform the operation
1008 on the full register even if a narrower mode is specified. */
1009 #define WORD_REGISTER_OPERATIONS
1010
1011 /* Define if loading in MODE, an integral mode narrower than BITS_PER_WORD
1012 will either zero-extend or sign-extend. The value of this macro should
1013 be the code that says which one of the two operations is implicitly
1014 done, UNKNOWN if none. */
1015 #define LOAD_EXTEND_OP(MODE) ZERO_EXTEND
1016
1017 /* Max number of bytes we can move from memory
1018 to memory in one reasonably fast instruction. */
1019 #define MOVE_MAX 4
1020
1021 /* Define this to be nonzero if shift instructions ignore all but the low-order
1022 few bits. */
1023 #define SHIFT_COUNT_TRUNCATED 1
1024
1025 /* Value is 1 if truncating an integer of INPREC bits to OUTPREC bits
1026 is done just by pretending it is already truncated. */
1027 #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
1028
1029 /* Specify the machine mode that pointers have.
1030 After generation of rtl, the compiler makes no further distinction
1031 between pointers and any other objects of this machine mode. */
1032 /* ??? The M32R doesn't have full 32-bit pointers, but making this PSImode has
1033 its own problems (you have to add extendpsisi2 and truncsipsi2).
1034 Try to avoid it. */
1035 #define Pmode SImode
1036
1037 /* A function address in a call instruction. */
1038 #define FUNCTION_MODE SImode
1039 \f
1040 /* M32R function types. */
1041 enum m32r_function_type
1042 {
1043 M32R_FUNCTION_UNKNOWN, M32R_FUNCTION_NORMAL, M32R_FUNCTION_INTERRUPT
1044 };
1045
1046 #define M32R_INTERRUPT_P(TYPE) ((TYPE) == M32R_FUNCTION_INTERRUPT)
1047
1048 /* The maximum number of bytes to copy using pairs of load/store instructions.
1049 If a block is larger than this then a loop will be generated to copy
1050 MAX_MOVE_BYTES chunks at a time. The value of 32 is a semi-arbitrary choice.
1051 A customer uses Dhrystome as their benchmark, and Dhrystone has a 31 byte
1052 string copy in it. */
1053 #define MAX_MOVE_BYTES 32