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