combine.c (subst): Use CLASS_CANNOT_CHANGE_MODE and CLASS_CANNOT_CHANGE_MODE_P instea...
[gcc.git] / gcc / config / sh / sh.h
1 /* Definitions of target machine for GNU compiler for Hitachi Super-H.
2 Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000
3 Free Software Foundation, Inc.
4 Contributed by Steve Chamberlain (sac@cygnus.com).
5 Improved by Jim Wilson (wilson@cygnus.com).
6
7 This file is part of GNU CC.
8
9 GNU CC is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2, or (at your option)
12 any later version.
13
14 GNU CC is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with GNU CC; see the file COPYING. If not, write to
21 the Free Software Foundation, 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA. */
23
24
25 #define TARGET_VERSION \
26 fputs (" (Hitachi SH)", stderr);
27
28 /* Unfortunately, insn-attrtab.c doesn't include insn-codes.h. We can't
29 include it here, because hconfig.h is also included by gencodes.c . */
30 extern int code_for_indirect_jump_scratch;
31
32 /* Generate SDB debugging information. */
33
34 #define SDB_DEBUGGING_INFO
35
36 /* Output DBX (stabs) debugging information if doing -gstabs. */
37
38 #include "dbxcoff.h"
39
40 #define SDB_DELIM ";"
41
42 #define CPP_SPEC "%{ml:-D__LITTLE_ENDIAN__} \
43 %{m1:-D__sh1__} \
44 %{m2:-D__sh2__} \
45 %{m3:-D__sh3__} \
46 %{m3e:-D__SH3E__} \
47 %{m4-single-only:-D__SH4_SINGLE_ONLY__} \
48 %{m4-single:-D__SH4_SINGLE__} \
49 %{m4:-D__SH4__} \
50 %{!m1:%{!m2:%{!m3:%{!m3e:%{!m4:%{!m4-single:%{!m4-single-only:-D__sh1__}}}}}}} \
51 %{mnomacsave:-D__NOMACSAVE__} \
52 %{mhitachi:-D__HITACHI__}"
53
54 #define CPP_PREDEFINES "-D__sh__ -Acpu(sh) -Amachine(sh)"
55
56 #define ASM_SPEC "%{ml:-little} %{mrelax:-relax}"
57
58 #define LINK_SPEC "%{ml:-m shl} %{mrelax:-relax}"
59
60 /* We can not debug without a frame pointer. */
61 /* #define CAN_DEBUG_WITHOUT_FP */
62
63 #define CONDITIONAL_REGISTER_USAGE \
64 if (! TARGET_SH4 || ! TARGET_FMOVD) \
65 { \
66 int regno; \
67 for (regno = FIRST_XD_REG; regno <= LAST_XD_REG; regno++) \
68 fixed_regs[regno] = call_used_regs[regno] = 1; \
69 if (! TARGET_SH4) \
70 { \
71 if (! TARGET_SH3E) \
72 { \
73 int regno; \
74 for (regno = FIRST_FP_REG; regno <= LAST_FP_REG; regno++) \
75 fixed_regs[regno] = call_used_regs[regno] = 1; \
76 fixed_regs[FPUL_REG] = call_used_regs[FPUL_REG] = 1; \
77 } \
78 } \
79 } \
80 /* Hitachi saves and restores mac registers on call. */ \
81 if (TARGET_HITACHI && ! TARGET_NOMACSAVE) \
82 { \
83 call_used_regs[MACH_REG] = 0; \
84 call_used_regs[MACL_REG] = 0; \
85 }
86 \f
87 /* ??? Need to write documentation for all SH options and add it to the
88 invoke.texi file. */
89
90 /* Run-time compilation parameters selecting different hardware subsets. */
91
92 extern int target_flags;
93 #define ISIZE_BIT (1<<1)
94 #define DALIGN_BIT (1<<6)
95 #define SH1_BIT (1<<8)
96 #define SH2_BIT (1<<9)
97 #define SH3_BIT (1<<10)
98 #define SH3E_BIT (1<<11)
99 #define HARD_SH4_BIT (1<<5)
100 #define FPU_SINGLE_BIT (1<<7)
101 #define SH4_BIT (1<<12)
102 #define FMOVD_BIT (1<<4)
103 #define SPACE_BIT (1<<13)
104 #define BIGTABLE_BIT (1<<14)
105 #define RELAX_BIT (1<<15)
106 #define HITACHI_BIT (1<<22)
107 #define NOMACSAVE_BIT (1<<23)
108 #define PADSTRUCT_BIT (1<<28)
109 #define LITTLE_ENDIAN_BIT (1<<29)
110 #define IEEE_BIT (1<<30)
111
112 /* Nonzero if we should dump out instruction size info. */
113 #define TARGET_DUMPISIZE (target_flags & ISIZE_BIT)
114
115 /* Nonzero to align doubles on 64 bit boundaries. */
116 #define TARGET_ALIGN_DOUBLE (target_flags & DALIGN_BIT)
117
118 /* Nonzero if we should generate code using type 1 insns. */
119 #define TARGET_SH1 (target_flags & SH1_BIT)
120
121 /* Nonzero if we should generate code using type 2 insns. */
122 #define TARGET_SH2 (target_flags & SH2_BIT)
123
124 /* Nonzero if we should generate code using type 3 insns. */
125 #define TARGET_SH3 (target_flags & SH3_BIT)
126
127 /* Nonzero if we should generate code using type 3E insns. */
128 #define TARGET_SH3E (target_flags & SH3E_BIT)
129
130 /* Nonzero if the cache line size is 32. */
131 #define TARGET_CACHE32 (target_flags & HARD_SH4_BIT)
132
133 /* Nonzero if we schedule for a superscalar implementation. */
134 #define TARGET_SUPERSCALAR (target_flags & HARD_SH4_BIT)
135
136 /* Nonzero if the target has separate instruction and data caches. */
137 #define TARGET_HARVARD (target_flags & HARD_SH4_BIT)
138
139 /* Nonzero if compiling for SH4 hardware (to be used for insn costs etc.) */
140 #define TARGET_HARD_SH4 (target_flags & HARD_SH4_BIT)
141
142 /* Nonzero if the default precision of th FPU is single */
143 #define TARGET_FPU_SINGLE (target_flags & FPU_SINGLE_BIT)
144
145 /* Nonzero if we should generate code using type 4 insns. */
146 #define TARGET_SH4 (target_flags & SH4_BIT)
147
148 /* Nonzero if we should generate fmovd. */
149 #define TARGET_FMOVD (target_flags & FMOVD_BIT)
150
151 /* Nonzero if we respect NANs. */
152 #define TARGET_IEEE (target_flags & IEEE_BIT)
153
154 /* Nonzero if we should generate smaller code rather than faster code. */
155 #define TARGET_SMALLCODE (target_flags & SPACE_BIT)
156
157 /* Nonzero to use long jump tables. */
158 #define TARGET_BIGTABLE (target_flags & BIGTABLE_BIT)
159
160 /* Nonzero to generate pseudo-ops needed by the assembler and linker
161 to do function call relaxing. */
162 #define TARGET_RELAX (target_flags & RELAX_BIT)
163
164 /* Nonzero if using Hitachi's calling convention. */
165 #define TARGET_HITACHI (target_flags & HITACHI_BIT)
166
167 /* Nonzero if not saving macl/mach when using -mhitachi */
168 #define TARGET_NOMACSAVE (target_flags & NOMACSAVE_BIT)
169
170 /* Nonzero if padding structures to a multiple of 4 bytes. This is
171 incompatible with Hitachi's compiler, and gives unusual structure layouts
172 which confuse programmers.
173 ??? This option is not useful, but is retained in case there are people
174 who are still relying on it. It may be deleted in the future. */
175 #define TARGET_PADSTRUCT (target_flags & PADSTRUCT_BIT)
176
177 /* Nonzero if generating code for a little endian SH. */
178 #define TARGET_LITTLE_ENDIAN (target_flags & LITTLE_ENDIAN_BIT)
179
180 #define TARGET_SWITCHES \
181 { {"1", SH1_BIT}, \
182 {"2", SH2_BIT}, \
183 {"3", SH3_BIT|SH2_BIT}, \
184 {"3e", SH3E_BIT|SH3_BIT|SH2_BIT|FPU_SINGLE_BIT}, \
185 {"4-single-only", SH3E_BIT|SH3_BIT|SH2_BIT|SH3E_BIT|HARD_SH4_BIT|FPU_SINGLE_BIT}, \
186 {"4-single", SH4_BIT|SH3E_BIT|SH3_BIT|SH2_BIT|HARD_SH4_BIT|FPU_SINGLE_BIT},\
187 {"4", SH4_BIT|SH3E_BIT|SH3_BIT|SH2_BIT|HARD_SH4_BIT}, \
188 {"b", -LITTLE_ENDIAN_BIT}, \
189 {"bigtable", BIGTABLE_BIT}, \
190 {"dalign", DALIGN_BIT}, \
191 {"fmovd", FMOVD_BIT}, \
192 {"hitachi", HITACHI_BIT}, \
193 {"nomacsave", NOMACSAVE_BIT}, \
194 {"ieee", IEEE_BIT}, \
195 {"isize", ISIZE_BIT}, \
196 {"l", LITTLE_ENDIAN_BIT}, \
197 {"no-ieee", -IEEE_BIT}, \
198 {"padstruct", PADSTRUCT_BIT}, \
199 {"relax", RELAX_BIT}, \
200 {"space", SPACE_BIT}, \
201 SUBTARGET_SWITCHES \
202 {"", TARGET_DEFAULT} \
203 }
204
205 /* This are meant to be redefined in the host dependent files */
206 #define SUBTARGET_SWITCHES
207
208 #define TARGET_DEFAULT (0)
209
210 #define OPTIMIZATION_OPTIONS(LEVEL,SIZE) \
211 do { \
212 if (LEVEL) \
213 flag_omit_frame_pointer = -1; \
214 if (SIZE) \
215 target_flags |= SPACE_BIT; \
216 } while (0)
217
218 #define ASSEMBLER_DIALECT assembler_dialect
219
220 extern int assembler_dialect;
221
222 #define OVERRIDE_OPTIONS \
223 do { \
224 sh_cpu = CPU_SH1; \
225 assembler_dialect = 0; \
226 if (TARGET_SH2) \
227 sh_cpu = CPU_SH2; \
228 if (TARGET_SH3) \
229 sh_cpu = CPU_SH3; \
230 if (TARGET_SH3E) \
231 sh_cpu = CPU_SH3E; \
232 if (TARGET_SH4) \
233 { \
234 assembler_dialect = 1; \
235 sh_cpu = CPU_SH4; \
236 } \
237 if (! TARGET_SH4 || ! TARGET_FMOVD) \
238 { \
239 /* Prevent usage of explicit register names for variables \
240 for registers not present / not addressable in the \
241 target architecture. */ \
242 int regno; \
243 for (regno = (TARGET_SH3E) ? 17 : 0; \
244 regno <= 24; regno++) \
245 fp_reg_names[regno][0] = 0; \
246 } \
247 if (flag_omit_frame_pointer < 0) \
248 /* The debugging information is sufficient, \
249 but gdb doesn't implement this yet */ \
250 if (0) \
251 flag_omit_frame_pointer \
252 = (PREFERRED_DEBUGGING_TYPE == DWARF_DEBUG \
253 || PREFERRED_DEBUGGING_TYPE == DWARF2_DEBUG); \
254 else \
255 flag_omit_frame_pointer = 0; \
256 \
257 /* Never run scheduling before reload, since that can \
258 break global alloc, and generates slower code anyway due \
259 to the pressure on R0. */ \
260 flag_schedule_insns = 0; \
261 } while (0)
262 \f
263 /* Target machine storage layout. */
264
265 /* Define to use software floating point emulator for REAL_ARITHMETIC and
266 decimal <-> binary conversion. */
267 #define REAL_ARITHMETIC
268
269 /* Define this if most significant bit is lowest numbered
270 in instructions that operate on numbered bit-fields. */
271
272 #define BITS_BIG_ENDIAN 0
273
274 /* Define this if most significant byte of a word is the lowest numbered. */
275 #define BYTES_BIG_ENDIAN (TARGET_LITTLE_ENDIAN == 0)
276
277 /* Define this if most significant word of a multiword number is the lowest
278 numbered. */
279 #define WORDS_BIG_ENDIAN (TARGET_LITTLE_ENDIAN == 0)
280
281 /* Define this to set the endianness to use in libgcc2.c, which can
282 not depend on target_flags. */
283 #if defined(__LITTLE_ENDIAN__)
284 #define LIBGCC2_WORDS_BIG_ENDIAN 0
285 #else
286 #define LIBGCC2_WORDS_BIG_ENDIAN 1
287 #endif
288
289 /* Number of bits in an addressable storage unit. */
290 #define BITS_PER_UNIT 8
291
292 /* Width in bits of a "word", which is the contents of a machine register.
293 Note that this is not necessarily the width of data type `int';
294 if using 16-bit ints on a 68000, this would still be 32.
295 But on a machine with 16-bit registers, this would be 16. */
296 #define BITS_PER_WORD 32
297 #define MAX_BITS_PER_WORD 32
298
299 /* Width of a word, in units (bytes). */
300 #define UNITS_PER_WORD 4
301
302 /* Width in bits of a pointer.
303 See also the macro `Pmode' defined below. */
304 #define POINTER_SIZE 32
305
306 /* Allocation boundary (in *bits*) for storing arguments in argument list. */
307 #define PARM_BOUNDARY 32
308
309 /* Boundary (in *bits*) on which stack pointer should be aligned. */
310 #define STACK_BOUNDARY BIGGEST_ALIGNMENT
311
312 /* The log (base 2) of the cache line size, in bytes. Processors prior to
313 SH2 have no actual cache, but they fetch code in chunks of 4 bytes.
314 The SH2/3 have 16 byte cache lines, and the SH4 has a 32 byte cache line */
315 #define CACHE_LOG (TARGET_CACHE32 ? 5 : TARGET_SH2 ? 4 : 2)
316
317 /* Allocation boundary (in *bits*) for the code of a function.
318 32 bit alignment is faster, because instructions are always fetched as a
319 pair from a longword boundary. */
320 #define FUNCTION_BOUNDARY (TARGET_SMALLCODE ? 16 : (1 << CACHE_LOG) * 8)
321
322 /* Alignment of field after `int : 0' in a structure. */
323 #define EMPTY_FIELD_BOUNDARY 32
324
325 /* No data type wants to be aligned rounder than this. */
326 #define BIGGEST_ALIGNMENT (TARGET_ALIGN_DOUBLE ? 64 : 32)
327
328 /* The best alignment to use in cases where we have a choice. */
329 #define FASTEST_ALIGNMENT 32
330
331 /* Make strings word-aligned so strcpy from constants will be faster. */
332 #define CONSTANT_ALIGNMENT(EXP, ALIGN) \
333 ((TREE_CODE (EXP) == STRING_CST \
334 && (ALIGN) < FASTEST_ALIGNMENT) \
335 ? FASTEST_ALIGNMENT : (ALIGN))
336
337 #ifndef MAX_OFILE_ALIGNMENT
338 #define MAX_OFILE_ALIGNMENT 128
339 #endif
340
341 /* Make arrays of chars word-aligned for the same reasons. */
342 #define DATA_ALIGNMENT(TYPE, ALIGN) \
343 (TREE_CODE (TYPE) == ARRAY_TYPE \
344 && TYPE_MODE (TREE_TYPE (TYPE)) == QImode \
345 && (ALIGN) < FASTEST_ALIGNMENT ? FASTEST_ALIGNMENT : (ALIGN))
346
347 /* Number of bits which any structure or union's size must be a
348 multiple of. Each structure or union's size is rounded up to a
349 multiple of this. */
350 #define STRUCTURE_SIZE_BOUNDARY (TARGET_PADSTRUCT ? 32 : 8)
351
352 /* Set this nonzero if move instructions will actually fail to work
353 when given unaligned data. */
354 #define STRICT_ALIGNMENT 1
355
356 /* If LABEL_AFTER_BARRIER demands an alignment, return its base 2 logarithm. */
357 #define LABEL_ALIGN_AFTER_BARRIER(LABEL_AFTER_BARRIER) \
358 barrier_align (LABEL_AFTER_BARRIER)
359
360 #define LOOP_ALIGN(A_LABEL) \
361 ((! optimize || TARGET_HARVARD || TARGET_SMALLCODE) \
362 ? 0 : sh_loop_align (A_LABEL))
363
364 #define LABEL_ALIGN(A_LABEL) \
365 ( \
366 (PREV_INSN (A_LABEL) \
367 && GET_CODE (PREV_INSN (A_LABEL)) == INSN \
368 && GET_CODE (PATTERN (PREV_INSN (A_LABEL))) == UNSPEC_VOLATILE \
369 && XINT (PATTERN (PREV_INSN (A_LABEL)), 1) == 1) \
370 /* explicit alignment insn in constant tables. */ \
371 ? INTVAL (XVECEXP (PATTERN (PREV_INSN (A_LABEL)), 0, 0)) \
372 : 0)
373
374 /* Jump tables must be 32 bit aligned, no matter the size of the element. */
375 #define ADDR_VEC_ALIGN(ADDR_VEC) 2
376
377 /* The base two logarithm of the known minimum alignment of an insn length. */
378 #define INSN_LENGTH_ALIGNMENT(A_INSN) \
379 (GET_CODE (A_INSN) == INSN \
380 ? 1 \
381 : GET_CODE (A_INSN) == JUMP_INSN || GET_CODE (A_INSN) == CALL_INSN \
382 ? 1 \
383 : CACHE_LOG)
384 \f
385 /* Standard register usage. */
386
387 /* Register allocation for the Hitachi calling convention:
388
389 r0 arg return
390 r1..r3 scratch
391 r4..r7 args in
392 r8..r13 call saved
393 r14 frame pointer/call saved
394 r15 stack pointer
395 ap arg pointer (doesn't really exist, always eliminated)
396 pr subroutine return address
397 t t bit
398 mach multiply/accumulate result, high part
399 macl multiply/accumulate result, low part.
400 fpul fp/int communication register
401 rap return address pointer register
402 fr0 fp arg return
403 fr1..fr3 scratch floating point registers
404 fr4..fr11 fp args in
405 fr12..fr15 call saved floating point registers */
406
407 /* Number of actual hardware registers.
408 The hardware registers are assigned numbers for the compiler
409 from 0 to just below FIRST_PSEUDO_REGISTER.
410 All registers that the compiler knows about must be given numbers,
411 even those that are not normally considered general registers. */
412
413 #define AP_REG 16
414 #define PR_REG 17
415 #define T_REG 18
416 #define GBR_REG 19
417 #define MACH_REG 20
418 #define MACL_REG 21
419 #define SPECIAL_REG(REGNO) ((REGNO) >= 18 && (REGNO) <= 21)
420 #define FPUL_REG 22
421 #define RAP_REG 23
422 #define FIRST_FP_REG 24
423 #define LAST_FP_REG 39
424 #define FIRST_XD_REG 40
425 #define LAST_XD_REG 47
426 #define FPSCR_REG 48
427
428 #define FIRST_PSEUDO_REGISTER 49
429
430 /* 1 for registers that have pervasive standard uses
431 and are not available for the register allocator.
432
433 Mach register is fixed 'cause it's only 10 bits wide for SH1.
434 It is 32 bits wide for SH2. */
435
436 #define FIXED_REGISTERS \
437 { 0, 0, 0, 0, \
438 0, 0, 0, 0, \
439 0, 0, 0, 0, \
440 0, 0, 0, 1, \
441 1, 1, 1, 1, \
442 1, 1, 0, 1, \
443 0, 0, 0, 0, \
444 0, 0, 0, 0, \
445 0, 0, 0, 0, \
446 0, 0, 0, 0, \
447 0, 0, 0, 0, \
448 0, 0, 0, 0, \
449 1, \
450 }
451
452 /* 1 for registers not available across function calls.
453 These must include the FIXED_REGISTERS and also any
454 registers that can be used without being saved.
455 The latter must include the registers where values are returned
456 and the register where structure-value addresses are passed.
457 Aside from that, you can include as many other registers as you like. */
458
459 #define CALL_USED_REGISTERS \
460 { 1, 1, 1, 1, \
461 1, 1, 1, 1, \
462 0, 0, 0, 0, \
463 0, 0, 0, 1, \
464 1, 0, 1, 1, \
465 1, 1, 1, 1, \
466 1, 1, 1, 1, \
467 1, 1, 1, 1, \
468 1, 1, 1, 1, \
469 0, 0, 0, 0, \
470 1, 1, 1, 1, \
471 1, 1, 0, 0, \
472 1, \
473 }
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
480 On the SH all but the XD regs are UNITS_PER_WORD bits wide. */
481
482 #define HARD_REGNO_NREGS(REGNO, MODE) \
483 ((REGNO) >= FIRST_XD_REG && (REGNO) <= LAST_XD_REG \
484 ? (GET_MODE_SIZE (MODE) / (2 * UNITS_PER_WORD)) \
485 : ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)) \
486
487 /* Value is 1 if hard register REGNO can hold a value of machine-mode MODE.
488 We can allow any mode in any general register. The special registers
489 only allow SImode. Don't allow any mode in the PR. */
490
491 /* We cannot hold DCmode values in the XD registers because alter_reg
492 handles subregs of them incorrectly. We could work around this by
493 spacing the XD registers like the DR registers, but this would require
494 additional memory in every compilation to hold larger register vectors.
495 We could hold SFmode / SCmode values in XD registers, but that
496 would require a tertiary reload when reloading from / to memory,
497 and a secondary reload to reload from / to general regs; that
498 seems to be a loosing proposition. */
499 #define HARD_REGNO_MODE_OK(REGNO, MODE) \
500 (SPECIAL_REG (REGNO) ? (MODE) == SImode \
501 : (REGNO) == FPUL_REG ? (MODE) == SImode || (MODE) == SFmode \
502 : (REGNO) >= FIRST_FP_REG && (REGNO) <= LAST_FP_REG && (MODE) == SFmode \
503 ? 1 \
504 : (REGNO) >= FIRST_FP_REG && (REGNO) <= LAST_FP_REG \
505 ? ((MODE) == SFmode \
506 || (TARGET_SH3E && (MODE) == SCmode) \
507 || (((TARGET_SH4 && (MODE) == DFmode) || (MODE) == DCmode) \
508 && (((REGNO) - FIRST_FP_REG) & 1) == 0)) \
509 : (REGNO) >= FIRST_XD_REG && (REGNO) <= LAST_XD_REG \
510 ? (MODE) == DFmode \
511 : (REGNO) == PR_REG ? 0 \
512 : (REGNO) == FPSCR_REG ? (MODE) == PSImode \
513 : 1)
514
515 /* Value is 1 if it is a good idea to tie two pseudo registers
516 when one has mode MODE1 and one has mode MODE2.
517 If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2,
518 for any hard reg, then this must be 0 for correct output. */
519
520 #define MODES_TIEABLE_P(MODE1, MODE2) \
521 ((MODE1) == (MODE2) || GET_MODE_CLASS (MODE1) == GET_MODE_CLASS (MODE2))
522
523 /* Specify the registers used for certain standard purposes.
524 The values of these macros are register numbers. */
525
526 /* Define this if the program counter is overloaded on a register. */
527 /* #define PC_REGNUM 15*/
528
529 /* Register to use for pushing function arguments. */
530 #define STACK_POINTER_REGNUM 15
531
532 /* Base register for access to local variables of the function. */
533 #define FRAME_POINTER_REGNUM 14
534
535 /* Fake register that holds the address on the stack of the
536 current function's return address. */
537 #define RETURN_ADDRESS_POINTER_REGNUM 23
538
539 /* Value should be nonzero if functions must have frame pointers.
540 Zero means the frame pointer need not be set up (and parms may be accessed
541 via the stack pointer) in functions that seem suitable. */
542
543 #define FRAME_POINTER_REQUIRED 0
544
545 /* Definitions for register eliminations.
546
547 We have three registers that can be eliminated on the SH. First, the
548 frame pointer register can often be eliminated in favor of the stack
549 pointer register. Secondly, the argument pointer register can always be
550 eliminated; it is replaced with either the stack or frame pointer.
551 Third, there is the return address pointer, which can also be replaced
552 with either the stack or the frame pointer. */
553
554 /* This is an array of structures. Each structure initializes one pair
555 of eliminable registers. The "from" register number is given first,
556 followed by "to". Eliminations of the same "from" register are listed
557 in order of preference. */
558
559 /* If you add any registers here that are not actually hard registers,
560 and that have any alternative of elimination that doesn't always
561 apply, you need to amend calc_live_regs to exclude it, because
562 reload spills all eliminable registers where it sees an
563 can_eliminate == 0 entry, thus making them 'live' .
564 If you add any hard registers that can be eliminated in different
565 ways, you have to patch reload to spill them only when all alternatives
566 of elimination fail. */
567
568 #define ELIMINABLE_REGS \
569 {{ FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
570 { RETURN_ADDRESS_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
571 { RETURN_ADDRESS_POINTER_REGNUM, FRAME_POINTER_REGNUM}, \
572 { ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
573 { ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM},}
574
575 /* Given FROM and TO register numbers, say whether this elimination
576 is allowed. */
577 #define CAN_ELIMINATE(FROM, TO) \
578 (!((FROM) == FRAME_POINTER_REGNUM && FRAME_POINTER_REQUIRED))
579
580 /* Define the offset between two registers, one to be eliminated, and the other
581 its replacement, at the start of a routine. */
582
583 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
584 OFFSET = initial_elimination_offset ((FROM), (TO))
585
586 /* Base register for access to arguments of the function. */
587 #define ARG_POINTER_REGNUM 16
588
589 /* Register in which the static-chain is passed to a function. */
590 #define STATIC_CHAIN_REGNUM 13
591
592 /* The register in which a struct value address is passed. */
593
594 #define STRUCT_VALUE_REGNUM 2
595
596 /* If the structure value address is not passed in a register, define
597 `STRUCT_VALUE' as an expression returning an RTX for the place
598 where the address is passed. If it returns 0, the address is
599 passed as an "invisible" first argument. */
600
601 /* The Hitachi calling convention doesn't quite fit into this scheme since
602 the address is passed like an invisible argument, but one that is always
603 passed in memory. */
604 #define STRUCT_VALUE \
605 (TARGET_HITACHI ? 0 : gen_rtx_REG (Pmode, STRUCT_VALUE_REGNUM))
606
607 #define RETURN_IN_MEMORY(TYPE) \
608 (TYPE_MODE (TYPE) == BLKmode \
609 || TARGET_HITACHI && TREE_CODE (TYPE) == RECORD_TYPE)
610
611 /* Don't default to pcc-struct-return, because we have already specified
612 exactly how to return structures in the RETURN_IN_MEMORY macro. */
613
614 #define DEFAULT_PCC_STRUCT_RETURN 0
615 \f
616 /* Define the classes of registers for register constraints in the
617 machine description. Also define ranges of constants.
618
619 One of the classes must always be named ALL_REGS and include all hard regs.
620 If there is more than one class, another class must be named NO_REGS
621 and contain no registers.
622
623 The name GENERAL_REGS must be the name of a class (or an alias for
624 another name such as ALL_REGS). This is the class of registers
625 that is allowed by "g" or "r" in a register constraint.
626 Also, registers outside this class are allocated only when
627 instructions express preferences for them.
628
629 The classes must be numbered in nondecreasing order; that is,
630 a larger-numbered class must never be contained completely
631 in a smaller-numbered class.
632
633 For any two classes, it is very desirable that there be another
634 class that represents their union. */
635
636 /* The SH has two sorts of general registers, R0 and the rest. R0 can
637 be used as the destination of some of the arithmetic ops. There are
638 also some special purpose registers; the T bit register, the
639 Procedure Return Register and the Multiply Accumulate Registers. */
640 /* Place GENERAL_REGS after FPUL_REGS so that it will be preferred by
641 reg_class_subunion. We don't want to have an actual union class
642 of these, because it would only be used when both classes are calculated
643 to give the same cost, but there is only one FPUL register.
644 Besides, regclass fails to notice the different REGISTER_MOVE_COSTS
645 applying to the actual instruction alternative considered. E.g., the
646 y/r alternative of movsi_ie is considered to have no more cost that
647 the r/r alternative, which is patently untrue. */
648
649 enum reg_class
650 {
651 NO_REGS,
652 R0_REGS,
653 PR_REGS,
654 T_REGS,
655 MAC_REGS,
656 FPUL_REGS,
657 GENERAL_REGS,
658 FP0_REGS,
659 FP_REGS,
660 DF_REGS,
661 FPSCR_REGS,
662 GENERAL_FP_REGS,
663 ALL_REGS,
664 LIM_REG_CLASSES
665 };
666
667 #define N_REG_CLASSES (int) LIM_REG_CLASSES
668
669 /* Give names of register classes as strings for dump file. */
670 #define REG_CLASS_NAMES \
671 { \
672 "NO_REGS", \
673 "R0_REGS", \
674 "PR_REGS", \
675 "T_REGS", \
676 "MAC_REGS", \
677 "FPUL_REGS", \
678 "GENERAL_REGS", \
679 "FP0_REGS", \
680 "FP_REGS", \
681 "DF_REGS", \
682 "FPSCR_REGS", \
683 "GENERAL_FP_REGS", \
684 "ALL_REGS", \
685 }
686
687 /* Define which registers fit in which classes.
688 This is an initializer for a vector of HARD_REG_SET
689 of length N_REG_CLASSES. */
690
691 #define REG_CLASS_CONTENTS \
692 { \
693 { 0x00000000, 0x00000000 }, /* NO_REGS */ \
694 { 0x00000001, 0x00000000 }, /* R0_REGS */ \
695 { 0x00020000, 0x00000000 }, /* PR_REGS */ \
696 { 0x00040000, 0x00000000 }, /* T_REGS */ \
697 { 0x00300000, 0x00000000 }, /* MAC_REGS */ \
698 { 0x00400000, 0x00000000 }, /* FPUL_REGS */ \
699 { 0x0081FFFF, 0x00000000 }, /* GENERAL_REGS */ \
700 { 0x01000000, 0x00000000 }, /* FP0_REGS */ \
701 { 0xFF000000, 0x000000FF }, /* FP_REGS */ \
702 { 0xFF000000, 0x0000FFFF }, /* DF_REGS */ \
703 { 0x00000000, 0x00010000 }, /* FPSCR_REGS */ \
704 { 0xFF81FFFF, 0x0000FFFF }, /* GENERAL_FP_REGS */ \
705 { 0xFFFFFFFF, 0x0001FFFF }, /* ALL_REGS */ \
706 }
707
708 /* The same information, inverted:
709 Return the class number of the smallest class containing
710 reg number REGNO. This could be a conditional expression
711 or could index an array. */
712
713 extern int regno_reg_class[];
714 #define REGNO_REG_CLASS(REGNO) regno_reg_class[(REGNO)]
715
716 /* When defined, the compiler allows registers explicitly used in the
717 rtl to be used as spill registers but prevents the compiler from
718 extending the lifetime of these registers. */
719
720 #define SMALL_REGISTER_CLASSES 1
721
722 /* The order in which register should be allocated. */
723 /* Sometimes FP0_REGS becomes the preferred class of a floating point pseudo,
724 and GENERAL_FP_REGS the alternate class. Since FP0 is likely to be
725 spilled or used otherwise, we better have the FP_REGS allocated first. */
726 #define REG_ALLOC_ORDER \
727 { 25,26,27,28,29,30,31,24,32,33,34,35,36,37,38,39, \
728 40,41,42,43,44,45,46,47,48, \
729 1,2,3,7,6,5,4,0,8,9,10,11,12,13,14, \
730 22,15,16,17,18,19,20,21,23 }
731
732 /* The class value for index registers, and the one for base regs. */
733 #define INDEX_REG_CLASS R0_REGS
734 #define BASE_REG_CLASS GENERAL_REGS
735
736 /* Get reg_class from a letter such as appears in the machine
737 description. */
738 extern enum reg_class reg_class_from_letter[];
739
740 #define REG_CLASS_FROM_LETTER(C) \
741 ( (C) >= 'a' && (C) <= 'z' ? reg_class_from_letter[(C)-'a'] : NO_REGS )
742 \f
743 /* The letters I, J, K, L and M in a register constraint string
744 can be used to stand for particular ranges of immediate operands.
745 This macro defines what the ranges are.
746 C is the letter, and VALUE is a constant value.
747 Return 1 if VALUE is in the range specified by C.
748 I: arithmetic operand -127..128, as used in add, sub, etc
749 K: shift operand 1,2,8 or 16
750 L: logical operand 0..255, as used in and, or, etc.
751 M: constant 1
752 N: constant 0 */
753
754 #define CONST_OK_FOR_I(VALUE) (((HOST_WIDE_INT)(VALUE))>= -128 \
755 && ((HOST_WIDE_INT)(VALUE)) <= 127)
756 #define CONST_OK_FOR_K(VALUE) ((VALUE)==1||(VALUE)==2||(VALUE)==8||(VALUE)==16)
757 #define CONST_OK_FOR_L(VALUE) (((HOST_WIDE_INT)(VALUE))>= 0 \
758 && ((HOST_WIDE_INT)(VALUE)) <= 255)
759 #define CONST_OK_FOR_M(VALUE) ((VALUE)==1)
760 #define CONST_OK_FOR_N(VALUE) ((VALUE)==0)
761 #define CONST_OK_FOR_LETTER_P(VALUE, C) \
762 ((C) == 'I' ? CONST_OK_FOR_I (VALUE) \
763 : (C) == 'K' ? CONST_OK_FOR_K (VALUE) \
764 : (C) == 'L' ? CONST_OK_FOR_L (VALUE) \
765 : (C) == 'M' ? CONST_OK_FOR_M (VALUE) \
766 : (C) == 'N' ? CONST_OK_FOR_N (VALUE) \
767 : 0)
768
769 /* Similar, but for floating constants, and defining letters G and H.
770 Here VALUE is the CONST_DOUBLE rtx itself. */
771
772 #define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) \
773 ((C) == 'G' ? (fp_zero_operand (VALUE) && fldi_ok ()) \
774 : (C) == 'H' ? (fp_one_operand (VALUE) && fldi_ok ()) \
775 : (C) == 'F')
776
777 /* Given an rtx X being reloaded into a reg required to be
778 in class CLASS, return the class of reg to actually use.
779 In general this is just CLASS; but on some machines
780 in some cases it is preferable to use a more restrictive class. */
781
782 #define PREFERRED_RELOAD_CLASS(X, CLASS) (CLASS)
783
784 #define SECONDARY_OUTPUT_RELOAD_CLASS(CLASS,MODE,X) \
785 ((((((CLASS) == FP_REGS || (CLASS) == FP0_REGS \
786 || (CLASS) == DF_REGS) \
787 && (GET_CODE (X) == REG && REGNO (X) <= AP_REG)) \
788 || (((CLASS) == GENERAL_REGS || (CLASS) == R0_REGS) \
789 && GET_CODE (X) == REG \
790 && REGNO (X) >= FIRST_FP_REG && REGNO (X) <= LAST_FP_REG)) \
791 && MODE == SFmode) \
792 ? FPUL_REGS \
793 : ((CLASS) == FPUL_REGS \
794 && (GET_CODE (X) == MEM \
795 || (GET_CODE (X) == REG \
796 && (REGNO (X) >= FIRST_PSEUDO_REGISTER \
797 || system_reg_operand (X, VOIDmode))))) \
798 ? GENERAL_REGS \
799 : (((CLASS) == MAC_REGS || (CLASS) == PR_REGS) \
800 && GET_CODE (X) == REG && REGNO (X) > 15 \
801 && (CLASS) != REGNO_REG_CLASS (REGNO (X))) \
802 ? GENERAL_REGS : NO_REGS)
803
804 #define SECONDARY_INPUT_RELOAD_CLASS(CLASS,MODE,X) \
805 ((((CLASS) == FP_REGS || (CLASS) == FP0_REGS || (CLASS) == DF_REGS) \
806 && immediate_operand ((X), (MODE)) \
807 && ! ((fp_zero_operand (X) || fp_one_operand (X)) \
808 && (MODE) == SFmode && fldi_ok ())) \
809 ? R0_REGS \
810 : CLASS == FPUL_REGS && immediate_operand ((X), (MODE)) \
811 ? (GET_CODE (X) == CONST_INT && CONST_OK_FOR_I (INTVAL (X)) \
812 ? GENERAL_REGS \
813 : R0_REGS) \
814 : (CLASS == FPSCR_REGS \
815 && ((GET_CODE (X) == REG && REGNO (X) >= FIRST_PSEUDO_REGISTER) \
816 || (GET_CODE (X) == MEM && GET_CODE (XEXP ((X), 0)) == PLUS)))\
817 ? GENERAL_REGS \
818 : SECONDARY_OUTPUT_RELOAD_CLASS((CLASS),(MODE),(X)))
819
820 /* Return the maximum number of consecutive registers
821 needed to represent mode MODE in a register of class CLASS.
822
823 On SH this is the size of MODE in words. */
824 #define CLASS_MAX_NREGS(CLASS, MODE) \
825 ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
826
827 /* If defined, gives a class of registers that cannot be used as the
828 operand of a SUBREG that changes the mode of the object illegally. */
829
830 #define CLASS_CANNOT_CHANGE_MODE DF_REGS
831
832 /* Defines illegal mode changes for CLASS_CANNOT_CHANGE_MODE. */
833
834 #define CLASS_CANNOT_CHANGE_MODE_P(FROM,TO) \
835 (GET_MODE_SIZE (FROM) != GET_MODE_SIZE (TO))
836 \f
837 /* Stack layout; function entry, exit and calling. */
838
839 /* Define the number of registers that can hold parameters.
840 These macros are used only in other macro definitions below. */
841
842 #define NPARM_REGS(MODE) \
843 (TARGET_SH3E && (MODE) == SFmode \
844 ? 8 \
845 : TARGET_SH4 && (GET_MODE_CLASS (MODE) == MODE_FLOAT \
846 || GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT) \
847 ? 8 \
848 : 4)
849
850 #define FIRST_PARM_REG 4
851 #define FIRST_RET_REG 0
852
853 #define FIRST_FP_PARM_REG (FIRST_FP_REG + 4)
854 #define FIRST_FP_RET_REG FIRST_FP_REG
855
856 /* Define this if pushing a word on the stack
857 makes the stack pointer a smaller address. */
858 #define STACK_GROWS_DOWNWARD
859
860 /* Define this macro if the addresses of local variable slots are at
861 negative offsets from the frame pointer.
862
863 The SH only has positive indexes, so grow the frame up. */
864 /* #define FRAME_GROWS_DOWNWARD */
865
866 /* Offset from the frame pointer to the first local variable slot to
867 be allocated. */
868 #define STARTING_FRAME_OFFSET 0
869
870 /* If we generate an insn to push BYTES bytes,
871 this says how many the stack pointer really advances by. */
872 /* Don't define PUSH_ROUNDING, since the hardware doesn't do this.
873 When PUSH_ROUNDING is not defined, PARM_BOUNDARY will cause gcc to
874 do correct alignment. */
875 #if 0
876 #define PUSH_ROUNDING(NPUSHED) (((NPUSHED) + 3) & ~3)
877 #endif
878
879 /* Offset of first parameter from the argument pointer register value. */
880 #define FIRST_PARM_OFFSET(FNDECL) 0
881
882 /* Value is the number of byte of arguments automatically
883 popped when returning from a subroutine call.
884 FUNDECL is the declaration node of the function (as a tree),
885 FUNTYPE is the data type of the function (as a tree),
886 or for a library call it is an identifier node for the subroutine name.
887 SIZE is the number of bytes of arguments passed on the stack.
888
889 On the SH, the caller does not pop any of its arguments that were passed
890 on the stack. */
891 #define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE) 0
892
893 /* Nonzero if we do not know how to pass TYPE solely in registers.
894 Values that come in registers with inconvenient padding are stored
895 to memory at the function start. */
896
897 #define MUST_PASS_IN_STACK(MODE,TYPE) \
898 ((TYPE) != 0 \
899 && (TREE_CODE (TYPE_SIZE (TYPE)) != INTEGER_CST \
900 || TREE_ADDRESSABLE (TYPE)))
901 /* Some subroutine macros specific to this machine. */
902
903 #define BASE_RETURN_VALUE_REG(MODE) \
904 ((TARGET_SH3E && ((MODE) == SFmode)) \
905 ? FIRST_FP_RET_REG \
906 : TARGET_SH3E && (MODE) == SCmode \
907 ? FIRST_FP_RET_REG \
908 : (TARGET_SH4 \
909 && ((MODE) == DFmode || (MODE) == SFmode \
910 || (MODE) == DCmode || (MODE) == SCmode )) \
911 ? FIRST_FP_RET_REG \
912 : FIRST_RET_REG)
913
914 #define BASE_ARG_REG(MODE) \
915 ((TARGET_SH3E && ((MODE) == SFmode)) \
916 ? FIRST_FP_PARM_REG \
917 : TARGET_SH4 && (GET_MODE_CLASS (MODE) == MODE_FLOAT \
918 || GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT)\
919 ? FIRST_FP_PARM_REG \
920 : FIRST_PARM_REG)
921
922 /* Define how to find the value returned by a function.
923 VALTYPE is the data type of the value (as a tree).
924 If the precise function being called is known, FUNC is its FUNCTION_DECL;
925 otherwise, FUNC is 0.
926 For the SH, this is like LIBCALL_VALUE, except that we must change the
927 mode like PROMOTE_MODE does.
928 ??? PROMOTE_MODE is ignored for non-scalar types. The set of types
929 tested here has to be kept in sync with the one in explow.c:promote_mode. */
930
931 #define FUNCTION_VALUE(VALTYPE, FUNC) \
932 gen_rtx (REG, \
933 ((GET_MODE_CLASS (TYPE_MODE (VALTYPE)) == MODE_INT \
934 && GET_MODE_SIZE (TYPE_MODE (VALTYPE)) < UNITS_PER_WORD \
935 && (TREE_CODE (VALTYPE) == INTEGER_TYPE \
936 || TREE_CODE (VALTYPE) == ENUMERAL_TYPE \
937 || TREE_CODE (VALTYPE) == BOOLEAN_TYPE \
938 || TREE_CODE (VALTYPE) == CHAR_TYPE \
939 || TREE_CODE (VALTYPE) == REAL_TYPE \
940 || TREE_CODE (VALTYPE) == OFFSET_TYPE)) \
941 ? SImode : TYPE_MODE (VALTYPE)), \
942 BASE_RETURN_VALUE_REG (TYPE_MODE (VALTYPE)))
943
944 /* Define how to find the value returned by a library function
945 assuming the value has mode MODE. */
946 #define LIBCALL_VALUE(MODE) \
947 gen_rtx_REG ((MODE), BASE_RETURN_VALUE_REG (MODE));
948
949 /* 1 if N is a possible register number for a function value. */
950 #define FUNCTION_VALUE_REGNO_P(REGNO) \
951 ((REGNO) == FIRST_RET_REG || (TARGET_SH3E && (REGNO) == FIRST_FP_RET_REG))
952
953 /* 1 if N is a possible register number for function argument passing. */
954 #define FUNCTION_ARG_REGNO_P(REGNO) \
955 (((REGNO) >= FIRST_PARM_REG && (REGNO) < (FIRST_PARM_REG + 4)) \
956 || (TARGET_SH3E \
957 && (REGNO) >= FIRST_FP_PARM_REG && (REGNO) < (FIRST_FP_PARM_REG + 8)))
958 \f
959 /* Define a data type for recording info about an argument list
960 during the scan of that argument list. This data type should
961 hold all necessary information about the function itself
962 and about the args processed so far, enough to enable macros
963 such as FUNCTION_ARG to determine where the next arg should go.
964
965 On SH, this is a single integer, which is a number of words
966 of arguments scanned so far (including the invisible argument,
967 if any, which holds the structure-value-address).
968 Thus NARGREGS or more means all following args should go on the stack. */
969
970 enum sh_arg_class { SH_ARG_INT = 0, SH_ARG_FLOAT = 1 };
971 struct sh_args {
972 int arg_count[2];
973 int force_mem;
974 };
975
976 #define CUMULATIVE_ARGS struct sh_args
977
978 #define GET_SH_ARG_CLASS(MODE) \
979 ((TARGET_SH3E && (MODE) == SFmode) \
980 ? SH_ARG_FLOAT \
981 : TARGET_SH4 && (GET_MODE_CLASS (MODE) == MODE_FLOAT \
982 || GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT) \
983 ? SH_ARG_FLOAT : SH_ARG_INT)
984
985 #define ROUND_ADVANCE(SIZE) \
986 (((SIZE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
987
988 /* Round a register number up to a proper boundary for an arg of mode
989 MODE.
990
991 The SH doesn't care about double alignment, so we only
992 round doubles to even regs when asked to explicitly. */
993
994 #define ROUND_REG(CUM, MODE) \
995 (((TARGET_ALIGN_DOUBLE \
996 || (TARGET_SH4 && ((MODE) == DFmode || (MODE) == DCmode) \
997 && (CUM).arg_count[(int) SH_ARG_FLOAT] < NPARM_REGS (MODE)))\
998 && GET_MODE_UNIT_SIZE ((MODE)) > UNITS_PER_WORD) \
999 ? ((CUM).arg_count[(int) GET_SH_ARG_CLASS (MODE)] \
1000 + ((CUM).arg_count[(int) GET_SH_ARG_CLASS (MODE)] & 1)) \
1001 : (CUM).arg_count[(int) GET_SH_ARG_CLASS (MODE)])
1002
1003 /* Initialize a variable CUM of type CUMULATIVE_ARGS
1004 for a call to a function whose data type is FNTYPE.
1005 For a library call, FNTYPE is 0.
1006
1007 On SH, the offset always starts at 0: the first parm reg is always
1008 the same reg for a given argument class.
1009
1010 For TARGET_HITACHI, the structure value pointer is passed in memory. */
1011
1012 #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, INDIRECT) \
1013 do { \
1014 (CUM).arg_count[(int) SH_ARG_INT] = 0; \
1015 (CUM).arg_count[(int) SH_ARG_FLOAT] = 0; \
1016 (CUM).force_mem \
1017 = (TARGET_HITACHI && FNTYPE \
1018 && aggregate_value_p (TREE_TYPE (FNTYPE))); \
1019 } while (0)
1020
1021 /* Update the data in CUM to advance over an argument
1022 of mode MODE and data type TYPE.
1023 (TYPE is null for libcalls where that information may not be
1024 available.) */
1025
1026 #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \
1027 if ((CUM).force_mem) \
1028 (CUM).force_mem = 0; \
1029 else if (! TARGET_SH4 || PASS_IN_REG_P ((CUM), (MODE), (TYPE))) \
1030 ((CUM).arg_count[(int) GET_SH_ARG_CLASS (MODE)] \
1031 = (ROUND_REG ((CUM), (MODE)) \
1032 + ((MODE) == BLKmode \
1033 ? ROUND_ADVANCE (int_size_in_bytes (TYPE)) \
1034 : ROUND_ADVANCE (GET_MODE_SIZE (MODE)))))
1035
1036 /* Return boolean indicating arg of mode MODE will be passed in a reg.
1037 This macro is only used in this file. */
1038
1039 #define PASS_IN_REG_P(CUM, MODE, TYPE) \
1040 (((TYPE) == 0 \
1041 || (! TREE_ADDRESSABLE ((tree)(TYPE)) \
1042 && (! TARGET_HITACHI || ! AGGREGATE_TYPE_P (TYPE)))) \
1043 && ! (CUM).force_mem \
1044 && (TARGET_SH3E \
1045 ? ((MODE) == BLKmode \
1046 ? (((CUM).arg_count[(int) SH_ARG_INT] * UNITS_PER_WORD \
1047 + int_size_in_bytes (TYPE)) \
1048 <= NPARM_REGS (SImode) * UNITS_PER_WORD) \
1049 : ((ROUND_REG((CUM), (MODE)) \
1050 + HARD_REGNO_NREGS (BASE_ARG_REG (MODE), (MODE))) \
1051 <= NPARM_REGS (MODE))) \
1052 : ROUND_REG ((CUM), (MODE)) < NPARM_REGS (MODE)))
1053
1054 /* Define where to put the arguments to a function.
1055 Value is zero to push the argument on the stack,
1056 or a hard register in which to store the argument.
1057
1058 MODE is the argument's machine mode.
1059 TYPE is the data type of the argument (as a tree).
1060 This is null for libcalls where that information may
1061 not be available.
1062 CUM is a variable of type CUMULATIVE_ARGS which gives info about
1063 the preceding args and about the function being called.
1064 NAMED is nonzero if this argument is a named parameter
1065 (otherwise it is an extra parameter matching an ellipsis).
1066
1067 On SH the first args are normally in registers
1068 and the rest are pushed. Any arg that starts within the first
1069 NPARM_REGS words is at least partially passed in a register unless
1070 its data type forbids. */
1071
1072 #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
1073 ((PASS_IN_REG_P ((CUM), (MODE), (TYPE)) \
1074 && ((NAMED) \
1075 || (! TARGET_HITACHI && (TARGET_SH3E || ! current_function_varargs)))) \
1076 ? gen_rtx_REG ((MODE), \
1077 ((BASE_ARG_REG (MODE) + ROUND_REG ((CUM), (MODE))) \
1078 ^ ((MODE) == SFmode && TARGET_SH4 \
1079 && TARGET_LITTLE_ENDIAN != 0))) \
1080 : 0)
1081
1082 #define PRETEND_OUTGOING_VARARGS_NAMED (! TARGET_HITACHI)
1083
1084 /* For an arg passed partly in registers and partly in memory,
1085 this is the number of registers used.
1086 For args passed entirely in registers or entirely in memory, zero.
1087
1088 We sometimes split args. */
1089
1090 #define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) \
1091 ((PASS_IN_REG_P ((CUM), (MODE), (TYPE)) \
1092 && ! TARGET_SH4 \
1093 && (ROUND_REG ((CUM), (MODE)) \
1094 + ((MODE) != BLKmode \
1095 ? ROUND_ADVANCE (GET_MODE_SIZE (MODE)) \
1096 : ROUND_ADVANCE (int_size_in_bytes (TYPE))) \
1097 > NPARM_REGS (MODE))) \
1098 ? NPARM_REGS (MODE) - ROUND_REG ((CUM), (MODE)) \
1099 : 0)
1100
1101 extern int current_function_anonymous_args;
1102
1103 /* Perform any needed actions needed for a function that is receiving a
1104 variable number of arguments. */
1105
1106 #define SETUP_INCOMING_VARARGS(ASF, MODE, TYPE, PAS, ST) \
1107 current_function_anonymous_args = 1;
1108
1109 /* Define the `__builtin_va_list' type for the ABI. */
1110 #define BUILD_VA_LIST_TYPE(VALIST) \
1111 (VALIST) = sh_build_va_list ()
1112
1113 /* Implement `va_start' for varargs and stdarg. */
1114 #define EXPAND_BUILTIN_VA_START(stdarg, valist, nextarg) \
1115 sh_va_start (stdarg, valist, nextarg)
1116
1117 /* Implement `va_arg'. */
1118 #define EXPAND_BUILTIN_VA_ARG(valist, type) \
1119 sh_va_arg (valist, type)
1120
1121 /* Call the function profiler with a given profile label.
1122 We use two .aligns, so as to make sure that both the .long is aligned
1123 on a 4 byte boundary, and that the .long is a fixed distance (2 bytes)
1124 from the trapa instruction. */
1125
1126 #define FUNCTION_PROFILER(STREAM,LABELNO) \
1127 { \
1128 fprintf((STREAM), "\t.align\t2\n"); \
1129 fprintf((STREAM), "\ttrapa\t#33\n"); \
1130 fprintf((STREAM), "\t.align\t2\n"); \
1131 asm_fprintf((STREAM), "\t.long\t%LLP%d\n", (LABELNO)); \
1132 }
1133
1134 /* Define this macro if the code for function profiling should come
1135 before the function prologue. Normally, the profiling code comes
1136 after. */
1137
1138 #define PROFILE_BEFORE_PROLOGUE
1139
1140 /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
1141 the stack pointer does not matter. The value is tested only in
1142 functions that have frame pointers.
1143 No definition is equivalent to always zero. */
1144
1145 #define EXIT_IGNORE_STACK 1
1146
1147 /* Generate the assembly code for function exit
1148 Just dump out any accumulated constant table. */
1149
1150 #define FUNCTION_EPILOGUE(STREAM, SIZE) function_epilogue ((STREAM), (SIZE))
1151
1152 /*
1153 On the SH, the trampoline looks like
1154 2 0002 DD02 mov.l l2,r13
1155 1 0000 D301 mov.l l1,r3
1156 3 0004 4D2B jmp @r13
1157 4 0006 0009 nop
1158 5 0008 00000000 l1: .long function
1159 6 000c 00000000 l2: .long area */
1160
1161 /* Length in units of the trampoline for entering a nested function. */
1162 #define TRAMPOLINE_SIZE 16
1163
1164 /* Alignment required for a trampoline in bits . */
1165 #define TRAMPOLINE_ALIGNMENT \
1166 ((CACHE_LOG < 3 || (TARGET_SMALLCODE && ! TARGET_HARVARD)) ? 32 : 64)
1167
1168 /* Emit RTL insns to initialize the variable parts of a trampoline.
1169 FNADDR is an RTX for the address of the function's pure code.
1170 CXT is an RTX for the static chain value for the function. */
1171
1172 #define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) \
1173 { \
1174 emit_move_insn (gen_rtx_MEM (SImode, (TRAMP)), \
1175 GEN_INT (TARGET_LITTLE_ENDIAN ? 0xd301dd02 : 0xdd02d301));\
1176 emit_move_insn (gen_rtx_MEM (SImode, plus_constant ((TRAMP), 4)), \
1177 GEN_INT (TARGET_LITTLE_ENDIAN ? 0x00094d2b : 0x4d2b0009));\
1178 emit_move_insn (gen_rtx_MEM (SImode, plus_constant ((TRAMP), 8)), \
1179 (CXT)); \
1180 emit_move_insn (gen_rtx_MEM (SImode, plus_constant ((TRAMP), 12)), \
1181 (FNADDR)); \
1182 if (TARGET_HARVARD) \
1183 emit_insn (gen_ic_invalidate_line (TRAMP)); \
1184 }
1185
1186 /* A C expression whose value is RTL representing the value of the return
1187 address for the frame COUNT steps up from the current frame.
1188 FRAMEADDR is already the frame pointer of the COUNT frame, so we
1189 can ignore COUNT. */
1190
1191 #define RETURN_ADDR_RTX(COUNT, FRAME) \
1192 (((COUNT) == 0) \
1193 ? gen_rtx_MEM (Pmode, gen_rtx_REG (Pmode, RETURN_ADDRESS_POINTER_REGNUM)) \
1194 : (rtx) 0)
1195 \f
1196 /* Generate necessary RTL for __builtin_saveregs(). */
1197 #define EXPAND_BUILTIN_SAVEREGS() sh_builtin_saveregs ()
1198 \f
1199 /* Addressing modes, and classification of registers for them. */
1200 #define HAVE_POST_INCREMENT 1
1201 /*#define HAVE_PRE_INCREMENT 1*/
1202 /*#define HAVE_POST_DECREMENT 1*/
1203 #define HAVE_PRE_DECREMENT 1
1204
1205 #define USE_LOAD_POST_INCREMENT(mode) ((mode == SImode || mode == DImode) \
1206 ? 0 : 1)
1207 #define USE_LOAD_PRE_DECREMENT(mode) 0
1208 #define USE_STORE_POST_INCREMENT(mode) 0
1209 #define USE_STORE_PRE_DECREMENT(mode) ((mode == SImode || mode == DImode) \
1210 ? 0 : 1)
1211
1212 #define MOVE_BY_PIECES_P(SIZE, ALIGN) (move_by_pieces_ninsns (SIZE, ALIGN) \
1213 < (TARGET_SMALLCODE ? 2 : \
1214 ((ALIGN >= 32) ? 16 : 2)))
1215
1216 /* Macros to check register numbers against specific register classes. */
1217
1218 /* These assume that REGNO is a hard or pseudo reg number.
1219 They give nonzero only if REGNO is a hard reg of the suitable class
1220 or a pseudo reg currently allocated to a suitable hard reg.
1221 Since they use reg_renumber, they are safe only once reg_renumber
1222 has been allocated, which happens in local-alloc.c. */
1223
1224 #define REGNO_OK_FOR_BASE_P(REGNO) \
1225 ((REGNO) < PR_REG || (unsigned) reg_renumber[(REGNO)] < PR_REG)
1226 #define REGNO_OK_FOR_INDEX_P(REGNO) \
1227 ((REGNO) == 0 || (unsigned) reg_renumber[(REGNO)] == 0)
1228
1229 /* Maximum number of registers that can appear in a valid memory
1230 address. */
1231
1232 #define MAX_REGS_PER_ADDRESS 2
1233
1234 /* Recognize any constant value that is a valid address. */
1235
1236 #define CONSTANT_ADDRESS_P(X) (GET_CODE (X) == LABEL_REF)
1237
1238 /* Nonzero if the constant value X is a legitimate general operand. */
1239
1240 #define LEGITIMATE_CONSTANT_P(X) \
1241 (GET_CODE (X) != CONST_DOUBLE \
1242 || GET_MODE (X) == DFmode || GET_MODE (X) == SFmode \
1243 || (TARGET_SH3E && (fp_zero_operand (X) || fp_one_operand (X))))
1244
1245 /* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
1246 and check its validity for a certain class.
1247 We have two alternate definitions for each of them.
1248 The usual definition accepts all pseudo regs; the other rejects
1249 them unless they have been allocated suitable hard regs.
1250 The symbol REG_OK_STRICT causes the latter definition to be used. */
1251
1252 #ifndef REG_OK_STRICT
1253
1254 /* Nonzero if X is a hard reg that can be used as a base reg
1255 or if it is a pseudo reg. */
1256 #define REG_OK_FOR_BASE_P(X) \
1257 (REGNO (X) <= 16 || REGNO (X) >= FIRST_PSEUDO_REGISTER)
1258
1259 /* Nonzero if X is a hard reg that can be used as an index
1260 or if it is a pseudo reg. */
1261 #define REG_OK_FOR_INDEX_P(X) \
1262 (REGNO (X) == 0 || REGNO (X) >= FIRST_PSEUDO_REGISTER)
1263
1264 /* Nonzero if X/OFFSET is a hard reg that can be used as an index
1265 or if X is a pseudo reg. */
1266 #define SUBREG_OK_FOR_INDEX_P(X, OFFSET) \
1267 ((REGNO (X) == 0 && OFFSET == 0) || REGNO (X) >= FIRST_PSEUDO_REGISTER)
1268
1269 #else
1270
1271 /* Nonzero if X is a hard reg that can be used as a base reg. */
1272 #define REG_OK_FOR_BASE_P(X) \
1273 REGNO_OK_FOR_BASE_P (REGNO (X))
1274
1275 /* Nonzero if X is a hard reg that can be used as an index. */
1276 #define REG_OK_FOR_INDEX_P(X) \
1277 REGNO_OK_FOR_INDEX_P (REGNO (X))
1278
1279 /* Nonzero if X/OFFSET is a hard reg that can be used as an index. */
1280 #define SUBREG_OK_FOR_INDEX_P(X, OFFSET) \
1281 (REGNO_OK_FOR_INDEX_P (REGNO (X)) && (OFFSET) == 0)
1282
1283 #endif
1284
1285 /* The 'Q' constraint is a pc relative load operand. */
1286 #define EXTRA_CONSTRAINT_Q(OP) \
1287 (GET_CODE (OP) == MEM && \
1288 ((GET_CODE (XEXP ((OP), 0)) == LABEL_REF) \
1289 || (GET_CODE (XEXP ((OP), 0)) == CONST \
1290 && GET_CODE (XEXP (XEXP ((OP), 0), 0)) == PLUS \
1291 && GET_CODE (XEXP (XEXP (XEXP ((OP), 0), 0), 0)) == LABEL_REF \
1292 && GET_CODE (XEXP (XEXP (XEXP ((OP), 0), 0), 1)) == CONST_INT)))
1293
1294 #define EXTRA_CONSTRAINT(OP, C) \
1295 ((C) == 'Q' ? EXTRA_CONSTRAINT_Q (OP) \
1296 : 0)
1297 \f
1298 /* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression
1299 that is a valid memory address for an instruction.
1300 The MODE argument is the machine mode for the MEM expression
1301 that wants to use this address. */
1302
1303 #define MODE_DISP_OK_4(X,MODE) \
1304 (GET_MODE_SIZE (MODE) == 4 && (unsigned) INTVAL (X) < 64 \
1305 && ! (INTVAL (X) & 3) && ! (TARGET_SH3E && (MODE) == SFmode))
1306
1307 #define MODE_DISP_OK_8(X,MODE) \
1308 ((GET_MODE_SIZE(MODE)==8) && ((unsigned)INTVAL(X)<60) \
1309 && ! (INTVAL(X) & 3) && ! (TARGET_SH4 && (MODE) == DFmode))
1310
1311 #define BASE_REGISTER_RTX_P(X) \
1312 ((GET_CODE (X) == REG && REG_OK_FOR_BASE_P (X)) \
1313 || (GET_CODE (X) == SUBREG \
1314 && GET_CODE (SUBREG_REG (X)) == REG \
1315 && REG_OK_FOR_BASE_P (SUBREG_REG (X))))
1316
1317 /* Since this must be r0, which is a single register class, we must check
1318 SUBREGs more carefully, to be sure that we don't accept one that extends
1319 outside the class. */
1320 #define INDEX_REGISTER_RTX_P(X) \
1321 ((GET_CODE (X) == REG && REG_OK_FOR_INDEX_P (X)) \
1322 || (GET_CODE (X) == SUBREG \
1323 && GET_CODE (SUBREG_REG (X)) == REG \
1324 && SUBREG_OK_FOR_INDEX_P (SUBREG_REG (X), SUBREG_WORD (X))))
1325
1326 /* Jump to LABEL if X is a valid address RTX. This must also take
1327 REG_OK_STRICT into account when deciding about valid registers, but it uses
1328 the above macros so we are in luck.
1329
1330 Allow REG
1331 REG+disp
1332 REG+r0
1333 REG++
1334 --REG */
1335
1336 /* ??? The SH3e does not have the REG+disp addressing mode when loading values
1337 into the FRx registers. We implement this by setting the maximum offset
1338 to zero when the value is SFmode. This also restricts loading of SFmode
1339 values into the integer registers, but that can't be helped. */
1340
1341 /* The SH allows a displacement in a QI or HI amode, but only when the
1342 other operand is R0. GCC doesn't handle this very well, so we forgo
1343 all of that.
1344
1345 A legitimate index for a QI or HI is 0, SI can be any number 0..63,
1346 DI can be any number 0..60. */
1347
1348 #define GO_IF_LEGITIMATE_INDEX(MODE, OP, LABEL) \
1349 do { \
1350 if (GET_CODE (OP) == CONST_INT) \
1351 { \
1352 if (MODE_DISP_OK_4 ((OP), (MODE))) goto LABEL; \
1353 if (MODE_DISP_OK_8 ((OP), (MODE))) goto LABEL; \
1354 } \
1355 } while(0)
1356
1357 #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, LABEL) \
1358 { \
1359 if (BASE_REGISTER_RTX_P (X)) \
1360 goto LABEL; \
1361 else if ((GET_CODE (X) == POST_INC || GET_CODE (X) == PRE_DEC) \
1362 && BASE_REGISTER_RTX_P (XEXP ((X), 0))) \
1363 goto LABEL; \
1364 else if (GET_CODE (X) == PLUS \
1365 && ((MODE) != PSImode || reload_completed)) \
1366 { \
1367 rtx xop0 = XEXP ((X), 0); \
1368 rtx xop1 = XEXP ((X), 1); \
1369 if (GET_MODE_SIZE (MODE) <= 8 && BASE_REGISTER_RTX_P (xop0)) \
1370 GO_IF_LEGITIMATE_INDEX ((MODE), xop1, LABEL); \
1371 if (GET_MODE_SIZE (MODE) <= 4 \
1372 || (TARGET_SH4 && TARGET_FMOVD && MODE == DFmode)) \
1373 { \
1374 if (BASE_REGISTER_RTX_P (xop1) && INDEX_REGISTER_RTX_P (xop0))\
1375 goto LABEL; \
1376 if (INDEX_REGISTER_RTX_P (xop1) && BASE_REGISTER_RTX_P (xop0))\
1377 goto LABEL; \
1378 } \
1379 } \
1380 }
1381 \f
1382 /* Try machine-dependent ways of modifying an illegitimate address
1383 to be legitimate. If we find one, return the new, valid address.
1384 This macro is used in only one place: `memory_address' in explow.c.
1385
1386 OLDX is the address as it was before break_out_memory_refs was called.
1387 In some cases it is useful to look at this to decide what needs to be done.
1388
1389 MODE and WIN are passed so that this macro can use
1390 GO_IF_LEGITIMATE_ADDRESS.
1391
1392 It is always safe for this macro to do nothing. It exists to recognize
1393 opportunities to optimize the output.
1394
1395 For the SH, if X is almost suitable for indexing, but the offset is
1396 out of range, convert it into a normal form so that cse has a chance
1397 of reducing the number of address registers used. */
1398
1399 #define LEGITIMIZE_ADDRESS(X,OLDX,MODE,WIN) \
1400 { \
1401 if (GET_CODE (X) == PLUS \
1402 && (GET_MODE_SIZE (MODE) == 4 \
1403 || GET_MODE_SIZE (MODE) == 8) \
1404 && GET_CODE (XEXP ((X), 1)) == CONST_INT \
1405 && BASE_REGISTER_RTX_P (XEXP ((X), 0)) \
1406 && ! (TARGET_SH4 && (MODE) == DFmode) \
1407 && ! (TARGET_SH3E && (MODE) == SFmode)) \
1408 { \
1409 rtx index_rtx = XEXP ((X), 1); \
1410 HOST_WIDE_INT offset = INTVAL (index_rtx), offset_base; \
1411 rtx sum; \
1412 \
1413 GO_IF_LEGITIMATE_INDEX ((MODE), index_rtx, WIN); \
1414 /* On rare occasions, we might get an unaligned pointer \
1415 that is indexed in a way to give an aligned address. \
1416 Therefore, keep the lower two bits in offset_base. */ \
1417 /* Instead of offset_base 128..131 use 124..127, so that \
1418 simple add suffices. */ \
1419 if (offset > 127) \
1420 { \
1421 offset_base = ((offset + 4) & ~60) - 4; \
1422 } \
1423 else \
1424 offset_base = offset & ~60; \
1425 /* Sometimes the normal form does not suit DImode. We \
1426 could avoid that by using smaller ranges, but that \
1427 would give less optimized code when SImode is \
1428 prevalent. */ \
1429 if (GET_MODE_SIZE (MODE) + offset - offset_base <= 64) \
1430 { \
1431 sum = expand_binop (Pmode, add_optab, XEXP ((X), 0), \
1432 GEN_INT (offset_base), NULL_RTX, 0, \
1433 OPTAB_LIB_WIDEN); \
1434 \
1435 (X) = gen_rtx_PLUS (Pmode, sum, GEN_INT (offset - offset_base)); \
1436 goto WIN; \
1437 } \
1438 } \
1439 }
1440
1441 /* A C compound statement that attempts to replace X, which is an address
1442 that needs reloading, with a valid memory address for an operand of
1443 mode MODE. WIN is a C statement label elsewhere in the code.
1444
1445 Like for LEGITIMIZE_ADDRESS, for the SH we try to get a normal form
1446 of the address. That will allow inheritance of the address reloads. */
1447
1448 #define LEGITIMIZE_RELOAD_ADDRESS(X,MODE,OPNUM,TYPE,IND_LEVELS,WIN) \
1449 { \
1450 if (GET_CODE (X) == PLUS \
1451 && (GET_MODE_SIZE (MODE) == 4 || GET_MODE_SIZE (MODE) == 8) \
1452 && GET_CODE (XEXP (X, 1)) == CONST_INT \
1453 && BASE_REGISTER_RTX_P (XEXP (X, 0)) \
1454 && ! (TARGET_SH4 && (MODE) == DFmode) \
1455 && ! ((MODE) == PSImode && (TYPE) == RELOAD_FOR_INPUT_ADDRESS)) \
1456 { \
1457 rtx index_rtx = XEXP (X, 1); \
1458 HOST_WIDE_INT offset = INTVAL (index_rtx), offset_base; \
1459 rtx sum; \
1460 \
1461 if (TARGET_SH3E && MODE == SFmode) \
1462 { \
1463 X = copy_rtx (X); \
1464 push_reload (index_rtx, NULL_RTX, &XEXP (X, 1), NULL_PTR, \
1465 INDEX_REG_CLASS, Pmode, VOIDmode, 0, 0, (OPNUM), \
1466 (TYPE)); \
1467 goto WIN; \
1468 } \
1469 /* Instead of offset_base 128..131 use 124..127, so that \
1470 simple add suffices. */ \
1471 if (offset > 127) \
1472 { \
1473 offset_base = ((offset + 4) & ~60) - 4; \
1474 } \
1475 else \
1476 offset_base = offset & ~60; \
1477 /* Sometimes the normal form does not suit DImode. We \
1478 could avoid that by using smaller ranges, but that \
1479 would give less optimized code when SImode is \
1480 prevalent. */ \
1481 if (GET_MODE_SIZE (MODE) + offset - offset_base <= 64) \
1482 { \
1483 sum = gen_rtx (PLUS, Pmode, XEXP (X, 0), \
1484 GEN_INT (offset_base)); \
1485 X = gen_rtx (PLUS, Pmode, sum, GEN_INT (offset - offset_base));\
1486 push_reload (sum, NULL_RTX, &XEXP (X, 0), NULL_PTR, \
1487 BASE_REG_CLASS, Pmode, VOIDmode, 0, 0, (OPNUM), \
1488 (TYPE)); \
1489 goto WIN; \
1490 } \
1491 } \
1492 /* We must re-recognize what we created before. */ \
1493 else if (GET_CODE (X) == PLUS \
1494 && (GET_MODE_SIZE (MODE) == 4 || GET_MODE_SIZE (MODE) == 8) \
1495 && GET_CODE (XEXP (X, 0)) == PLUS \
1496 && GET_CODE (XEXP (XEXP (X, 0), 1)) == CONST_INT \
1497 && BASE_REGISTER_RTX_P (XEXP (XEXP (X, 0), 0)) \
1498 && GET_CODE (XEXP (X, 1)) == CONST_INT \
1499 && ! (TARGET_SH3E && MODE == SFmode)) \
1500 { \
1501 /* Because this address is so complex, we know it must have \
1502 been created by LEGITIMIZE_RELOAD_ADDRESS before; thus, \
1503 it is already unshared, and needs no further unsharing. */ \
1504 push_reload (XEXP ((X), 0), NULL_RTX, &XEXP ((X), 0), NULL_PTR, \
1505 BASE_REG_CLASS, Pmode, VOIDmode, 0, 0, (OPNUM), (TYPE));\
1506 goto WIN; \
1507 } \
1508 }
1509
1510 /* Go to LABEL if ADDR (a legitimate address expression)
1511 has an effect that depends on the machine mode it is used for.
1512
1513 ??? Strictly speaking, we should also include all indexed addressing,
1514 because the index scale factor is the length of the operand.
1515 However, the impact of GO_IF_MODE_DEPENDENT_ADDRESS would be to
1516 high if we did that. So we rely on reload to fix things up. */
1517
1518 #define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR,LABEL) \
1519 { \
1520 if (GET_CODE(ADDR) == PRE_DEC || GET_CODE(ADDR) == POST_INC) \
1521 goto LABEL; \
1522 }
1523 \f
1524 /* Specify the machine mode that this machine uses
1525 for the index in the tablejump instruction. */
1526 #define CASE_VECTOR_MODE (TARGET_BIGTABLE ? SImode : HImode)
1527
1528 #define CASE_VECTOR_SHORTEN_MODE(MIN_OFFSET, MAX_OFFSET, BODY) \
1529 ((MIN_OFFSET) >= 0 && (MAX_OFFSET) <= 127 \
1530 ? (ADDR_DIFF_VEC_FLAGS (BODY).offset_unsigned = 0, QImode) \
1531 : (MIN_OFFSET) >= 0 && (MAX_OFFSET) <= 255 \
1532 ? (ADDR_DIFF_VEC_FLAGS (BODY).offset_unsigned = 1, QImode) \
1533 : (MIN_OFFSET) >= -32768 && (MAX_OFFSET) <= 32767 ? HImode \
1534 : SImode)
1535
1536 /* Define as C expression which evaluates to nonzero if the tablejump
1537 instruction expects the table to contain offsets from the address of the
1538 table.
1539 Do not define this if the table should contain absolute addresses. */
1540 #define CASE_VECTOR_PC_RELATIVE 1
1541
1542 /* Specify the tree operation to be used to convert reals to integers. */
1543 #define IMPLICIT_FIX_EXPR FIX_ROUND_EXPR
1544
1545 /* This is the kind of divide that is easiest to do in the general case. */
1546 #define EASY_DIV_EXPR TRUNC_DIV_EXPR
1547
1548 /* Since the SH3e has only `float' support, it is desirable to make all
1549 floating point types equivalent to `float'. */
1550 #define DOUBLE_TYPE_SIZE ((TARGET_SH3E && ! TARGET_SH4) ? 32 : 64)
1551
1552 /* 'char' is signed by default. */
1553 #define DEFAULT_SIGNED_CHAR 1
1554
1555 /* The type of size_t unsigned int. */
1556 #define SIZE_TYPE "unsigned int"
1557
1558 #define WCHAR_TYPE "short unsigned int"
1559 #define WCHAR_TYPE_SIZE 16
1560
1561 /* Don't cse the address of the function being compiled. */
1562 /*#define NO_RECURSIVE_FUNCTION_CSE 1*/
1563
1564 /* Max number of bytes we can move from memory to memory
1565 in one reasonably fast instruction. */
1566 #define MOVE_MAX 4
1567
1568 /* Max number of bytes we want move_by_pieces to be able to copy
1569 efficiently. */
1570 #define MOVE_MAX_PIECES (TARGET_SH4 ? 8 : 4)
1571
1572 /* Define if operations between registers always perform the operation
1573 on the full register even if a narrower mode is specified. */
1574 #define WORD_REGISTER_OPERATIONS
1575
1576 /* Define if loading in MODE, an integral mode narrower than BITS_PER_WORD
1577 will either zero-extend or sign-extend. The value of this macro should
1578 be the code that says which one of the two operations is implicitly
1579 done, NIL if none. */
1580 #define LOAD_EXTEND_OP(MODE) SIGN_EXTEND
1581
1582 /* Define if loading short immediate values into registers sign extends. */
1583 #define SHORT_IMMEDIATES_SIGN_EXTEND
1584
1585 /* Define this if zero-extension is slow (more than one real instruction).
1586 On the SH, it's only one instruction. */
1587 /* #define SLOW_ZERO_EXTEND */
1588
1589 /* Nonzero if access to memory by bytes is no faster than for words. */
1590 #define SLOW_BYTE_ACCESS 1
1591
1592 /* Force sizeof(bool) == 1 to maintain binary compatibility; otherwise, the
1593 change in SLOW_BYTE_ACCESS would have changed it to 4. */
1594
1595 /* This used to use INT_TYPE_SIZE / CHAR_TYPE_SIZE, but these are
1596 not guaranteed to be defined when BOOL_TYPE_SIZE is used. */
1597 #define BOOL_TYPE_SIZE (flag_new_abi ? BITS_PER_WORD : BITS_PER_UNIT)
1598
1599 /* We assume that the store-condition-codes instructions store 0 for false
1600 and some other value for true. This is the value stored for true. */
1601
1602 #define STORE_FLAG_VALUE 1
1603
1604 /* Immediate shift counts are truncated by the output routines (or was it
1605 the assembler?). Shift counts in a register are truncated by SH. Note
1606 that the native compiler puts too large (> 32) immediate shift counts
1607 into a register and shifts by the register, letting the SH decide what
1608 to do instead of doing that itself. */
1609 /* ??? The library routines in lib1funcs.asm truncate the shift count.
1610 However, the SH3 has hardware shifts that do not truncate exactly as gcc
1611 expects - the sign bit is significant - so it appears that we need to
1612 leave this zero for correct SH3 code. */
1613 #define SHIFT_COUNT_TRUNCATED (! TARGET_SH3)
1614
1615 /* All integers have the same format so truncation is easy. */
1616 #define TRULY_NOOP_TRUNCATION(OUTPREC,INPREC) 1
1617
1618 /* Define this if addresses of constant functions
1619 shouldn't be put through pseudo regs where they can be cse'd.
1620 Desirable on machines where ordinary constants are expensive
1621 but a CALL with constant address is cheap. */
1622 /*#define NO_FUNCTION_CSE 1*/
1623
1624 /* Chars and shorts should be passed as ints. */
1625 #define PROMOTE_PROTOTYPES 1
1626
1627 /* The machine modes of pointers and functions. */
1628 #define Pmode SImode
1629 #define FUNCTION_MODE Pmode
1630
1631 /* The relative costs of various types of constants. Note that cse.c defines
1632 REG = 1, SUBREG = 2, any node = (2 + sum of subnodes). */
1633
1634 #define CONST_COSTS(RTX, CODE, OUTER_CODE) \
1635 case CONST_INT: \
1636 if (INTVAL (RTX) == 0) \
1637 return 0; \
1638 else if (CONST_OK_FOR_I (INTVAL (RTX))) \
1639 return 1; \
1640 else if (((OUTER_CODE) == AND || (OUTER_CODE) == IOR || (OUTER_CODE) == XOR) \
1641 && CONST_OK_FOR_L (INTVAL (RTX))) \
1642 return 1; \
1643 else \
1644 return 8; \
1645 case CONST: \
1646 case LABEL_REF: \
1647 case SYMBOL_REF: \
1648 return 5; \
1649 case CONST_DOUBLE: \
1650 return 10;
1651
1652 #define RTX_COSTS(X, CODE, OUTER_CODE) \
1653 case PLUS: \
1654 return (COSTS_N_INSNS (1) \
1655 + rtx_cost (XEXP ((X), 0), PLUS) \
1656 + (rtx_equal_p (XEXP ((X), 0), XEXP ((X), 1))\
1657 ? 0 : rtx_cost (XEXP ((X), 1), PLUS)));\
1658 case AND: \
1659 return COSTS_N_INSNS (andcosts (X)); \
1660 case MULT: \
1661 return COSTS_N_INSNS (multcosts (X)); \
1662 case ASHIFT: \
1663 case ASHIFTRT: \
1664 case LSHIFTRT: \
1665 /* Add one extra unit for the matching constraint. \
1666 Otherwise loop strength reduction would think that\
1667 a shift with different sourc and destination is \
1668 as cheap as adding a constant to a register. */ \
1669 return (COSTS_N_INSNS (shiftcosts (X)) \
1670 + rtx_cost (XEXP ((X), 0), (CODE)) \
1671 + 1); \
1672 case DIV: \
1673 case UDIV: \
1674 case MOD: \
1675 case UMOD: \
1676 return COSTS_N_INSNS (20); \
1677 case FLOAT: \
1678 case FIX: \
1679 return 100;
1680
1681 /* The multiply insn on the SH1 and the divide insns on the SH1 and SH2
1682 are actually function calls with some special constraints on arguments
1683 and register usage.
1684
1685 These macros tell reorg that the references to arguments and
1686 register clobbers for insns of type sfunc do not appear to happen
1687 until after the millicode call. This allows reorg to put insns
1688 which set the argument registers into the delay slot of the millicode
1689 call -- thus they act more like traditional CALL_INSNs.
1690
1691 get_attr_is_sfunc will try to recognize the given insn, so make sure to
1692 filter out things it will not accept -- SEQUENCE, USE and CLOBBER insns
1693 in particular. */
1694
1695 #define INSN_SETS_ARE_DELAYED(X) \
1696 ((GET_CODE (X) == INSN \
1697 && GET_CODE (PATTERN (X)) != SEQUENCE \
1698 && GET_CODE (PATTERN (X)) != USE \
1699 && GET_CODE (PATTERN (X)) != CLOBBER \
1700 && get_attr_is_sfunc (X)))
1701
1702 #define INSN_REFERENCES_ARE_DELAYED(X) \
1703 ((GET_CODE (X) == INSN \
1704 && GET_CODE (PATTERN (X)) != SEQUENCE \
1705 && GET_CODE (PATTERN (X)) != USE \
1706 && GET_CODE (PATTERN (X)) != CLOBBER \
1707 && get_attr_is_sfunc (X)))
1708
1709 /* Compute the cost of an address. For the SH, all valid addresses are
1710 the same cost. */
1711 /* ??? Perhaps we should make reg+reg addresses have higher cost because
1712 they add to register pressure on r0. */
1713
1714 #define ADDRESS_COST(RTX) 1
1715
1716 /* Compute extra cost of moving data between one register class
1717 and another. */
1718
1719 /* Regclass always uses 2 for moves in the same register class;
1720 If SECONDARY*_RELOAD_CLASS says something about the src/dst pair,
1721 it uses this information. Hence, the general register <-> floating point
1722 register information here is not used for SFmode. */
1723 #define REGISTER_MOVE_COST(SRCCLASS, DSTCLASS) \
1724 ((((DSTCLASS) == T_REGS) || ((DSTCLASS) == PR_REGS)) ? 10 \
1725 : ((((DSTCLASS) == FP0_REGS || (DSTCLASS) == FP_REGS || (DSTCLASS) == DF_REGS) \
1726 && ((SRCCLASS) == GENERAL_REGS || (SRCCLASS) == R0_REGS)) \
1727 || (((DSTCLASS) == GENERAL_REGS || (DSTCLASS) == R0_REGS) \
1728 && ((SRCCLASS) == FP0_REGS || (SRCCLASS) == FP_REGS \
1729 || (SRCCLASS) == DF_REGS))) \
1730 ? TARGET_FMOVD ? 8 : 12 \
1731 : (((DSTCLASS) == FPUL_REGS \
1732 && ((SRCCLASS) == GENERAL_REGS || (SRCCLASS) == R0_REGS)) \
1733 || (SRCCLASS == FPUL_REGS \
1734 && ((DSTCLASS) == GENERAL_REGS || (DSTCLASS) == R0_REGS))) \
1735 ? 5 \
1736 : (((DSTCLASS) == FPUL_REGS \
1737 && ((SRCCLASS) == PR_REGS || (SRCCLASS) == MAC_REGS \
1738 || (SRCCLASS) == T_REGS)) \
1739 || ((SRCCLASS) == FPUL_REGS \
1740 && ((DSTCLASS) == PR_REGS || (DSTCLASS) == MAC_REGS))) \
1741 ? 7 \
1742 : 2)
1743
1744 /* ??? Perhaps make MEMORY_MOVE_COST depend on compiler option? This
1745 would be so that people with slow memory systems could generate
1746 different code that does fewer memory accesses. */
1747
1748 /* A C expression for the cost of a branch instruction. A value of 1
1749 is the default; other values are interpreted relative to that.
1750 The SH1 does not have delay slots, hence we get a pipeline stall
1751 at every branch. The SH4 is superscalar, so the single delay slot
1752 is not sufficient to keep both pipelines filled. */
1753 #define BRANCH_COST (! TARGET_SH2 || TARGET_HARD_SH4 ? 2 : 1)
1754 \f
1755 /* Assembler output control. */
1756
1757 /* A C string constant describing how to begin a comment in the target
1758 assembler language. The compiler assumes that the comment will end at
1759 the end of the line. */
1760 #define ASM_COMMENT_START "!"
1761
1762 /* The text to go at the start of the assembler file. */
1763 #define ASM_FILE_START(STREAM) \
1764 output_file_start (STREAM)
1765
1766 #define ASM_FILE_END(STREAM)
1767
1768 #define ASM_APP_ON ""
1769 #define ASM_APP_OFF ""
1770 #define FILE_ASM_OP "\t.file\n"
1771 #define IDENT_ASM_OP "\t.ident\n"
1772 #define SET_ASM_OP ".set"
1773
1774 /* How to change between sections. */
1775
1776 #define TEXT_SECTION_ASM_OP "\t.text"
1777 #define DATA_SECTION_ASM_OP "\t.data"
1778 #define CTORS_SECTION_ASM_OP "\t.section\t.ctors\n"
1779 #define DTORS_SECTION_ASM_OP "\t.section\t.dtors\n"
1780 #define EXTRA_SECTIONS in_ctors, in_dtors
1781 #define EXTRA_SECTION_FUNCTIONS \
1782 void \
1783 ctors_section() \
1784 { \
1785 if (in_section != in_ctors) \
1786 { \
1787 fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP); \
1788 in_section = in_ctors; \
1789 } \
1790 } \
1791 void \
1792 dtors_section() \
1793 { \
1794 if (in_section != in_dtors) \
1795 { \
1796 fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP); \
1797 in_section = in_dtors; \
1798 } \
1799 }
1800
1801 /* If defined, a C expression whose value is a string containing the
1802 assembler operation to identify the following data as
1803 uninitialized global data. If not defined, and neither
1804 `ASM_OUTPUT_BSS' nor `ASM_OUTPUT_ALIGNED_BSS' are defined,
1805 uninitialized global data will be output in the data section if
1806 `-fno-common' is passed, otherwise `ASM_OUTPUT_COMMON' will be
1807 used. */
1808 #ifndef BSS_SECTION_ASM_OP
1809 #define BSS_SECTION_ASM_OP ".section\t.bss"
1810 #endif
1811
1812 /* Like `ASM_OUTPUT_BSS' except takes the required alignment as a
1813 separate, explicit argument. If you define this macro, it is used
1814 in place of `ASM_OUTPUT_BSS', and gives you more flexibility in
1815 handling the required alignment of the variable. The alignment is
1816 specified as the number of bits.
1817
1818 Try to use function `asm_output_aligned_bss' defined in file
1819 `varasm.c' when defining this macro. */
1820 #ifndef ASM_OUTPUT_ALIGNED_BSS
1821 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
1822 asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
1823 #endif
1824
1825 /* Define this so that jump tables go in same section as the current function,
1826 which could be text or it could be a user defined section. */
1827 #define JUMP_TABLES_IN_TEXT_SECTION 1
1828
1829 /* A C statement to output something to the assembler file to switch to section
1830 NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or
1831 NULL_TREE. Some target formats do not support arbitrary sections. Do not
1832 define this macro in such cases. */
1833
1834 #define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \
1835 do { fprintf (FILE, ".section\t%s\n", NAME); } while (0)
1836
1837 #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
1838 do { ctors_section(); asm_fprintf((FILE),"\t.long\t%U%s\n", (NAME)); } while (0)
1839
1840 #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
1841 do { dtors_section(); asm_fprintf((FILE),"\t.long\t%U%s\n", (NAME)); } while (0)
1842
1843 #undef DO_GLOBAL_CTORS_BODY
1844
1845 #define DO_GLOBAL_CTORS_BODY \
1846 { \
1847 typedef (*pfunc)(); \
1848 extern pfunc __ctors[]; \
1849 extern pfunc __ctors_end[]; \
1850 pfunc *p; \
1851 for (p = __ctors_end; p > __ctors; ) \
1852 { \
1853 (*--p)(); \
1854 } \
1855 }
1856
1857 #undef DO_GLOBAL_DTORS_BODY
1858 #define DO_GLOBAL_DTORS_BODY \
1859 { \
1860 typedef (*pfunc)(); \
1861 extern pfunc __dtors[]; \
1862 extern pfunc __dtors_end[]; \
1863 pfunc *p; \
1864 for (p = __dtors; p < __dtors_end; p++) \
1865 { \
1866 (*p)(); \
1867 } \
1868 }
1869
1870 #define ASM_OUTPUT_REG_PUSH(file, v) \
1871 fprintf ((file), "\tmov.l\tr%d,-@r15\n", (v));
1872
1873 #define ASM_OUTPUT_REG_POP(file, v) \
1874 fprintf ((file), "\tmov.l\t@r15+,r%d\n", (v));
1875
1876 /* The assembler's names for the registers. RFP need not always be used as
1877 the Real framepointer; it can also be used as a normal general register.
1878 Note that the name `fp' is horribly misleading since `fp' is in fact only
1879 the argument-and-return-context pointer. */
1880
1881 extern char fp_reg_names[][5];
1882
1883 #define REGISTER_NAMES \
1884 { \
1885 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
1886 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", \
1887 "ap", "pr", "t", "gbr", "mach","macl", fp_reg_names[16], "rap", \
1888 fp_reg_names[0], fp_reg_names[1] , fp_reg_names[2], fp_reg_names[3], \
1889 fp_reg_names[4], fp_reg_names[5], fp_reg_names[6], fp_reg_names[7], \
1890 fp_reg_names[8], fp_reg_names[9], fp_reg_names[10], fp_reg_names[11], \
1891 fp_reg_names[12], fp_reg_names[13], fp_reg_names[14], fp_reg_names[15], \
1892 fp_reg_names[17], fp_reg_names[18], fp_reg_names[19], fp_reg_names[20], \
1893 fp_reg_names[21], fp_reg_names[22], fp_reg_names[23], fp_reg_names[24], \
1894 "fpscr", \
1895 }
1896
1897 #define DEBUG_REGISTER_NAMES \
1898 { \
1899 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
1900 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", \
1901 "ap", "pr", "t", "gbr", "mach","macl", "fpul","rap", \
1902 "fr0","fr1","fr2", "fr3", "fr4", "fr5", "fr6", "fr7", \
1903 "fr8","fr9","fr10","fr11","fr12","fr13","fr14","fr15",\
1904 "xd0","xd2","xd4", "xd6", "xd8", "xd10","xd12","xd14", \
1905 "fpscr", \
1906 }
1907
1908 /* DBX register number for a given compiler register number. */
1909 /* GDB has FPUL at 23 and FP0 at 25, so we must add one to all FP registers
1910 to match gdb. */
1911 #define DBX_REGISTER_NUMBER(REGNO) \
1912 (((REGNO) >= 22 && (REGNO) <= 39) ? ((REGNO) + 1) : (REGNO))
1913
1914 /* Output a label definition. */
1915 #define ASM_OUTPUT_LABEL(FILE,NAME) \
1916 do { assemble_name ((FILE), (NAME)); fputs (":\n", (FILE)); } while (0)
1917
1918 /* This is how to output an assembler line
1919 that says to advance the location counter
1920 to a multiple of 2**LOG bytes. */
1921
1922 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
1923 if ((LOG) != 0) \
1924 fprintf ((FILE), "\t.align %d\n", (LOG))
1925
1926 /* Output a function label definition. */
1927 #define ASM_DECLARE_FUNCTION_NAME(STREAM,NAME,DECL) \
1928 ASM_OUTPUT_LABEL((STREAM), (NAME))
1929
1930 /* Output a globalising directive for a label. */
1931 #define ASM_GLOBALIZE_LABEL(STREAM,NAME) \
1932 (fprintf ((STREAM), "\t.global\t"), \
1933 assemble_name ((STREAM), (NAME)), \
1934 fputc ('\n', (STREAM)))
1935
1936 /* The prefix to add to user-visible assembler symbols. */
1937
1938 #define USER_LABEL_PREFIX "_"
1939
1940 /* The prefix to add to an internally generated label. */
1941
1942 #define LOCAL_LABEL_PREFIX ""
1943
1944 /* Make an internal label into a string. */
1945 #define ASM_GENERATE_INTERNAL_LABEL(STRING, PREFIX, NUM) \
1946 sprintf ((STRING), "*%s%s%ld", LOCAL_LABEL_PREFIX, (PREFIX), (long)(NUM))
1947
1948 /* Output an internal label definition. */
1949 #define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM) \
1950 asm_fprintf ((FILE), "%L%s%d:\n", (PREFIX), (NUM))
1951
1952 /* #define ASM_OUTPUT_CASE_END(STREAM,NUM,TABLE) */
1953
1954 /* Construct a private name. */
1955 #define ASM_FORMAT_PRIVATE_NAME(OUTVAR,NAME,NUMBER) \
1956 ((OUTVAR) = (char *) alloca (strlen (NAME) + 10), \
1957 sprintf ((OUTVAR), "%s.%d", (NAME), (NUMBER)))
1958
1959 /* Output a relative address table. */
1960
1961 #define ASM_OUTPUT_ADDR_DIFF_ELT(STREAM,BODY,VALUE,REL) \
1962 switch (GET_MODE (BODY)) \
1963 { \
1964 case SImode: \
1965 asm_fprintf ((STREAM), "\t.long\t%LL%d-%LL%d\n", (VALUE),(REL)); \
1966 break; \
1967 case HImode: \
1968 asm_fprintf ((STREAM), "\t.word\t%LL%d-%LL%d\n", (VALUE),(REL)); \
1969 break; \
1970 case QImode: \
1971 asm_fprintf ((STREAM), "\t.byte\t%LL%d-%LL%d\n", (VALUE),(REL)); \
1972 break; \
1973 default: \
1974 break; \
1975 }
1976
1977 /* Output an absolute table element. */
1978
1979 #define ASM_OUTPUT_ADDR_VEC_ELT(STREAM,VALUE) \
1980 if (TARGET_BIGTABLE) \
1981 asm_fprintf ((STREAM), "\t.long\t%LL%d\n", (VALUE)); \
1982 else \
1983 asm_fprintf ((STREAM), "\t.word\t%LL%d\n", (VALUE)); \
1984
1985 /* Output various types of constants. */
1986
1987 /* This is how to output an assembler line defining a `double'. */
1988
1989 #define ASM_OUTPUT_DOUBLE(FILE,VALUE) \
1990 do { char dstr[30]; \
1991 REAL_VALUE_TO_DECIMAL ((VALUE), "%.20e", dstr); \
1992 fprintf ((FILE), "\t.double %s\n", dstr); \
1993 } while (0)
1994
1995 /* This is how to output an assembler line defining a `float' constant. */
1996 #define ASM_OUTPUT_FLOAT(FILE,VALUE) \
1997 do { char dstr[30]; \
1998 REAL_VALUE_TO_DECIMAL ((VALUE), "%.20e", dstr); \
1999 fprintf ((FILE), "\t.float %s\n", dstr); \
2000 } while (0)
2001
2002 #define ASM_OUTPUT_INT(STREAM, EXP) \
2003 (fprintf ((STREAM), "\t.long\t"), \
2004 output_addr_const ((STREAM), (EXP)), \
2005 fputc ('\n', (STREAM)))
2006
2007 #define ASM_OUTPUT_SHORT(STREAM, EXP) \
2008 (fprintf ((STREAM), "\t.short\t"), \
2009 output_addr_const ((STREAM), (EXP)), \
2010 fputc ('\n', (STREAM)))
2011
2012 #define ASM_OUTPUT_CHAR(STREAM, EXP) \
2013 (fprintf ((STREAM), "\t.byte\t"), \
2014 output_addr_const ((STREAM), (EXP)), \
2015 fputc ('\n', (STREAM)))
2016
2017 #define ASM_OUTPUT_BYTE(STREAM, VALUE) \
2018 fprintf ((STREAM), "\t.byte\t%d\n", (VALUE)) \
2019
2020 /* The next two are used for debug info when compiling with -gdwarf. */
2021 #define UNALIGNED_SHORT_ASM_OP ".uaword"
2022 #define UNALIGNED_INT_ASM_OP ".ualong"
2023
2024 /* Loop alignment is now done in machine_dependent_reorg, so that
2025 branch shortening can know about it. */
2026
2027 /* This is how to output an assembler line
2028 that says to advance the location counter by SIZE bytes. */
2029
2030 #define ASM_OUTPUT_SKIP(FILE,SIZE) \
2031 fprintf ((FILE), "\t.space %d\n", (SIZE))
2032
2033 /* This says how to output an assembler line
2034 to define a global common symbol. */
2035
2036 #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED) \
2037 ( fputs ("\t.comm ", (FILE)), \
2038 assemble_name ((FILE), (NAME)), \
2039 fprintf ((FILE), ",%d\n", (SIZE)))
2040
2041 /* This says how to output an assembler line
2042 to define a local common symbol. */
2043
2044 #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED) \
2045 ( fputs ("\t.lcomm ", (FILE)), \
2046 assemble_name ((FILE), (NAME)), \
2047 fprintf ((FILE), ",%d\n", (SIZE)))
2048
2049 /* The assembler's parentheses characters. */
2050 #define ASM_OPEN_PAREN "("
2051 #define ASM_CLOSE_PAREN ")"
2052
2053 /* Target characters. */
2054 #define TARGET_BELL 007
2055 #define TARGET_BS 010
2056 #define TARGET_TAB 011
2057 #define TARGET_NEWLINE 012
2058 #define TARGET_VT 013
2059 #define TARGET_FF 014
2060 #define TARGET_CR 015
2061 \f
2062 /* A C statement to be executed just prior to the output of
2063 assembler code for INSN, to modify the extracted operands so
2064 they will be output differently.
2065
2066 Here the argument OPVEC is the vector containing the operands
2067 extracted from INSN, and NOPERANDS is the number of elements of
2068 the vector which contain meaningful data for this insn.
2069 The contents of this vector are what will be used to convert the insn
2070 template into assembler code, so you can change the assembler output
2071 by changing the contents of the vector. */
2072
2073 #define FINAL_PRESCAN_INSN(INSN, OPVEC, NOPERANDS) \
2074 final_prescan_insn ((INSN), (OPVEC), (NOPERANDS))
2075
2076 /* Print operand X (an rtx) in assembler syntax to file FILE.
2077 CODE is a letter or dot (`z' in `%z0') or 0 if no letter was specified.
2078 For `%' followed by punctuation, CODE is the punctuation and X is null. */
2079
2080 #define PRINT_OPERAND(STREAM, X, CODE) print_operand ((STREAM), (X), (CODE))
2081
2082 /* Print a memory address as an operand to reference that memory location. */
2083
2084 #define PRINT_OPERAND_ADDRESS(STREAM,X) print_operand_address ((STREAM), (X))
2085
2086 #define PRINT_OPERAND_PUNCT_VALID_P(CHAR) \
2087 ((CHAR) == '.' || (CHAR) == '#' || (CHAR) == '@' || (CHAR) == ',' \
2088 || (CHAR) == '$')
2089 \f
2090 extern struct rtx_def *sh_compare_op0;
2091 extern struct rtx_def *sh_compare_op1;
2092
2093 /* Which processor to schedule for. The elements of the enumeration must
2094 match exactly the cpu attribute in the sh.md file. */
2095
2096 enum processor_type {
2097 PROCESSOR_SH1,
2098 PROCESSOR_SH2,
2099 PROCESSOR_SH3,
2100 PROCESSOR_SH3E,
2101 PROCESSOR_SH4
2102 };
2103
2104 #define sh_cpu_attr ((enum attr_cpu)sh_cpu)
2105 extern enum processor_type sh_cpu;
2106
2107 extern int optimize; /* needed for gen_casesi. */
2108
2109 enum mdep_reorg_phase_e
2110 {
2111 SH_BEFORE_MDEP_REORG,
2112 SH_INSERT_USES_LABELS,
2113 SH_SHORTEN_BRANCHES0,
2114 SH_FIXUP_PCLOAD,
2115 SH_SHORTEN_BRANCHES1,
2116 SH_AFTER_MDEP_REORG
2117 };
2118
2119 extern enum mdep_reorg_phase_e mdep_reorg_phase;
2120
2121 #define MACHINE_DEPENDENT_REORG(X) machine_dependent_reorg(X)
2122
2123 /* Generate calls to memcpy, memcmp and memset. */
2124
2125 #define TARGET_MEM_FUNCTIONS
2126
2127 /* Define this macro if you want to implement any pragmas. If defined, it
2128 is a C expression whose value is 1 if the pragma was handled by the
2129 macro, zero otherwise. */
2130 #define HANDLE_PRAGMA(GETC, UNGETC, NODE) sh_handle_pragma (GETC, UNGETC, NODE)
2131
2132 /* Set when processing a function with pragma interrupt turned on. */
2133
2134 extern int pragma_interrupt;
2135
2136 /* Set to an RTX containing the address of the stack to switch to
2137 for interrupt functions. */
2138 extern struct rtx_def *sp_switch;
2139
2140 /* A C expression whose value is nonzero if IDENTIFIER with arguments ARGS
2141 is a valid machine specific attribute for DECL.
2142 The attributes in ATTRIBUTES have previously been assigned to DECL. */
2143 #define VALID_MACHINE_DECL_ATTRIBUTE(DECL, ATTRIBUTES, IDENTIFIER, ARGS) \
2144 sh_valid_machine_decl_attribute (DECL, ATTRIBUTES, IDENTIFIER, ARGS)
2145
2146 #define PRAGMA_INSERT_ATTRIBUTES(node, pattr, prefix_attr) \
2147 sh_pragma_insert_attributes (node, pattr, prefix_attr)
2148
2149 extern int rtx_equal_function_value_matters;
2150 extern struct rtx_def *fpscr_rtx;
2151
2152 \f
2153 /* Instructions with unfilled delay slots take up an
2154 extra two bytes for the nop in the delay slot.
2155 sh-dsp parallel processing insns are four bytes long. */
2156
2157 #define ADJUST_INSN_LENGTH(X, LENGTH) \
2158 (LENGTH) += sh_insn_length_adjustment (X);
2159 \f
2160 /* Define the codes that are matched by predicates in sh.c. */
2161 #define PREDICATE_CODES \
2162 {"arith_operand", {SUBREG, REG, CONST_INT}}, \
2163 {"arith_reg_operand", {SUBREG, REG}}, \
2164 {"arith_reg_or_0_operand", {SUBREG, REG, CONST_INT}}, \
2165 {"binary_float_operator", {PLUS, MULT}}, \
2166 {"commutative_float_operator", {PLUS, MULT}}, \
2167 {"fp_arith_reg_operand", {SUBREG, REG}}, \
2168 {"fp_extended_operand", {SUBREG, REG, FLOAT_EXTEND}}, \
2169 {"fpscr_operand", {REG}}, \
2170 {"general_movsrc_operand", {SUBREG, REG, CONST_INT, MEM}}, \
2171 {"general_movdst_operand", {SUBREG, REG, CONST_INT, MEM}}, \
2172 {"logical_operand", {SUBREG, REG, CONST_INT}}, \
2173 {"noncommutative_float_operator", {MINUS, DIV}}, \
2174 {"register_operand", {SUBREG, REG}},
2175
2176 /* Define this macro if it is advisable to hold scalars in registers
2177 in a wider mode than that declared by the program. In such cases,
2178 the value is constrained to be within the bounds of the declared
2179 type, but kept valid in the wider mode. The signedness of the
2180 extension may differ from that of the type.
2181
2182 Leaving the unsignedp unchanged gives better code than always setting it
2183 to 0. This is despite the fact that we have only signed char and short
2184 load instructions. */
2185 #define PROMOTE_MODE(MODE, UNSIGNEDP, TYPE) \
2186 if (GET_MODE_CLASS (MODE) == MODE_INT \
2187 && GET_MODE_SIZE (MODE) < UNITS_PER_WORD) \
2188 (MODE) = SImode;
2189
2190 /* Defining PROMOTE_FUNCTION_ARGS eliminates some unnecessary zero/sign
2191 extensions applied to char/short functions arguments. Defining
2192 PROMOTE_FUNCTION_RETURN does the same for function returns. */
2193
2194 #define PROMOTE_FUNCTION_ARGS
2195 #define PROMOTE_FUNCTION_RETURN
2196
2197 /* ??? Define ACCUMULATE_OUTGOING_ARGS? This is more efficient than pushing
2198 and poping arguments. However, we do have push/pop instructions, and
2199 rather limited offsets (4 bits) in load/store instructions, so it isn't
2200 clear if this would give better code. If implemented, should check for
2201 compatibility problems. */
2202
2203 /* A C statement (sans semicolon) to update the integer variable COST
2204 based on the relationship between INSN that is dependent on
2205 DEP_INSN through the dependence LINK. The default is to make no
2206 adjustment to COST. This can be used for example to specify to
2207 the scheduler that an output- or anti-dependence does not incur
2208 the same cost as a data-dependence. */
2209
2210 #define ADJUST_COST(insn,link,dep_insn,cost) \
2211 do { \
2212 rtx reg; \
2213 \
2214 if (GET_CODE(insn) == CALL_INSN) \
2215 { \
2216 /* The only input for a call that is timing-critical is the \
2217 function's address. */ \
2218 rtx call = PATTERN (insn); \
2219 \
2220 if (GET_CODE (call) == PARALLEL) \
2221 call = XVECEXP (call, 0 ,0); \
2222 if (GET_CODE (call) == SET) \
2223 call = SET_SRC (call); \
2224 if (GET_CODE (call) == CALL && GET_CODE (XEXP (call, 0)) == MEM \
2225 && ! reg_set_p (XEXP (XEXP (call, 0), 0), dep_insn)) \
2226 (cost) = 0; \
2227 } \
2228 /* All sfunc calls are parallels with at least four components. \
2229 Exploit this to avoid unnecessary calls to sfunc_uses_reg. */ \
2230 else if (GET_CODE (PATTERN (insn)) == PARALLEL \
2231 && XVECLEN (PATTERN (insn), 0) >= 4 \
2232 && (reg = sfunc_uses_reg (insn))) \
2233 { \
2234 /* Likewise, the most timing critical input for an sfuncs call \
2235 is the function address. However, sfuncs typically start \
2236 using their arguments pretty quickly. \
2237 Assume a four cycle delay before they are needed. */ \
2238 if (! reg_set_p (reg, dep_insn)) \
2239 cost -= TARGET_SUPERSCALAR ? 40 : 4; \
2240 } \
2241 /* Adjust load_si / pcload_si type insns latency. Use the known \
2242 nominal latency and form of the insn to speed up the check. */ \
2243 else if (cost == 3 \
2244 && GET_CODE (PATTERN (dep_insn)) == SET \
2245 /* Latency for dmpy type insns is also 3, so check the that \
2246 it's actually a move insn. */ \
2247 && general_movsrc_operand (SET_SRC (PATTERN (dep_insn)), SImode))\
2248 cost = 2; \
2249 else if (cost == 30 \
2250 && GET_CODE (PATTERN (dep_insn)) == SET \
2251 && GET_MODE (SET_SRC (PATTERN (dep_insn))) == SImode) \
2252 cost = 20; \
2253 } while (0) \
2254
2255 #define SH_DYNAMIC_SHIFT_COST \
2256 (TARGET_HARD_SH4 ? 1 : TARGET_SH3 ? (TARGET_SMALLCODE ? 1 : 2) : 20)
2257
2258
2259 #define NUM_MODES_FOR_MODE_SWITCHING { FP_MODE_NONE }
2260
2261 #define OPTIMIZE_MODE_SWITCHING(ENTITY) TARGET_SH4
2262
2263 #define NORMAL_MODE(ENTITY) \
2264 (TARGET_FPU_SINGLE ? FP_MODE_SINGLE : FP_MODE_DOUBLE)
2265
2266 #define EPILOGUE_USES(REGNO) (TARGET_SH4 && (REGNO) == FPSCR_REG)
2267
2268 #define MODE_NEEDED(ENTITY, INSN) \
2269 (recog_memoized (INSN) >= 0 \
2270 ? get_attr_fp_mode (INSN) \
2271 : FP_MODE_NONE)
2272
2273 #define MODE_PRIORITY_TO_MODE(ENTITY, N) \
2274 ((TARGET_FPU_SINGLE != 0) ^ (N) ? FP_MODE_SINGLE : FP_MODE_DOUBLE)
2275
2276 #define EMIT_MODE_SET(ENTITY, MODE, HARD_REGS_LIVE) \
2277 fpscr_set_from_mem ((MODE), (HARD_REGS_LIVE))
2278
2279 #define DWARF_LINE_MIN_INSTR_LENGTH 2