1 /* Definitions of target machine for GNU compiler for Hitachi / SuperH SH.
2 Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
3 Free Software Foundation, Inc.
4 Contributed by Steve Chamberlain (sac@cygnus.com).
5 Improved by Jim Wilson (wilson@cygnus.com).
7 This file is part of GNU CC.
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)
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.
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. */
27 #define TARGET_VERSION \
28 fputs (" (Hitachi SH)", stderr);
30 /* Unfortunately, insn-attrtab.c doesn't include insn-codes.h. We can't
31 include it here, because hconfig.h is also included by gencodes.c . */
32 /* ??? No longer true. */
33 extern int code_for_indirect_jump_scratch;
35 /* Generate SDB debugging information. */
37 #define SDB_DEBUGGING_INFO
39 /* Output DBX (stabs) debugging information if doing -gstabs. */
46 %{m5-64media|m5-64media-nofpu|m5-32media|m5-32media-nofpu:-D__SHMEDIA__=1} \
47 %{m5-compact|m5-compact-nofpu:-D__SHMEDIA__=0} \
48 %{m5-64media|m5-64media-nofpu:-D__SH5__=64 -D__LONG_MAX__=9223372036854775807L} \
49 %{m5-32media|m5-32media-nofpu|m5-compact|m5-compact-nofpu:-D__SH5__=32} \
50 %{m5-64media-nofpu|m5-32media-nofpu|m5-compact-nofpu:-D__SH4_NOFPU__} \
55 %{m4-single-only:-D__SH4_SINGLE_ONLY__} \
56 %{m4-single:-D__SH4_SINGLE__} \
57 %{m4-nofpu:-D__sh3__ -D__SH4_NOFPU__} \
59 %{!m1:%{!m2:%{!m3*:%{!m4*:%{!m5*:%(cpp_default_cpu_spec)}}}}} \
60 %{mhitachi:-D__HITACHI__} \
61 %(subtarget_cpp_spec) \
62 %(subtarget_cpp_ptr_spec) \
63 %(subtarget_cpp_endian_spec) "
65 #ifndef SUBTARGET_CPP_ENDIAN_SPEC
66 #define SUBTARGET_CPP_ENDIAN_SPEC "%{ml:-D__LITTLE_ENDIAN__}"
69 #ifndef SUBTARGET_CPP_SPEC
70 #define SUBTARGET_CPP_SPEC ""
73 #ifndef CPP_DEFAULT_CPU_SPEC
74 #define CPP_DEFAULT_CPU_SPEC "-D__sh1__"
77 #ifndef SUBTARGET_CPP_PTR_SPEC
78 #define SUBTARGET_CPP_PTR_SPEC "\
79 %{m5-64media|m5-64media-nofpu|m5-32media|m5-32media-nofpu|m5-compact|m5-compact-nofpu:-D__SIZE_TYPE__=long\\ unsigned\\ int -D__PTRDIFF_TYPE__=long\\ int} \
80 %{!m5-64media:%{!m5-64media-nofpu:%{!m5-32media:%{!m5-32media-nofpu:%{!m5-compact:%{!m5-compact-nofpu:-D__SIZE_TYPE__=unsigned\\ int -D__PTRDIFF_TYPE__=int}}}}}} \
85 { "subtarget_cpp_spec", SUBTARGET_CPP_SPEC }, \
86 { "subtarget_cpp_endian_spec", SUBTARGET_CPP_ENDIAN_SPEC }, \
87 { "subtarget_cpp_ptr_spec", SUBTARGET_CPP_PTR_SPEC }, \
88 { "cpp_default_cpu_spec", CPP_DEFAULT_CPU_SPEC },
90 #define CPP_PREDEFINES "-D__sh__ -Acpu=sh -Amachine=sh"
92 #define ASM_SPEC "%{ml:-little} %{mrelax:-relax}"
94 #define LINK_SPEC "%{ml:-m shl} %{mrelax:-relax}"
96 /* We can not debug without a frame pointer. */
97 /* #define CAN_DEBUG_WITHOUT_FP */
99 #define CONDITIONAL_REGISTER_USAGE do \
102 for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno ++) \
103 if (! VALID_REGISTER_P (regno)) \
104 fixed_regs[regno] = call_used_regs[regno] = 1; \
105 /* R8 and R9 are call-clobbered on SH5, but not on earlier SH ABIs. */ \
107 call_used_regs[FIRST_GENERAL_REG + 8] \
108 = call_used_regs[FIRST_GENERAL_REG + 9] = 1; \
109 if (TARGET_SHMEDIA) \
111 regno_reg_class[FIRST_GENERAL_REG] = GENERAL_REGS; \
112 CLEAR_HARD_REG_SET (reg_class_contents[FP0_REGS]); \
113 regno_reg_class[FIRST_FP_REG] = FP_REGS; \
116 fixed_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \
117 /* Hitachi saves and restores mac registers on call. */ \
118 if (TARGET_HITACHI && ! TARGET_NOMACSAVE) \
120 call_used_regs[MACH_REG] = 0; \
121 call_used_regs[MACL_REG] = 0; \
123 if (TARGET_SHMEDIA) \
125 for (regno = FIRST_TARGET_REG; regno <= LAST_TARGET_REG; regno ++)\
126 if (! fixed_regs[regno] && call_used_regs[regno]) \
127 SET_HARD_REG_BIT (reg_class_contents[SIBCALL_REGS], regno); \
130 for (regno = FIRST_GENERAL_REG; regno <= LAST_GENERAL_REG; regno++) \
131 if (! fixed_regs[regno] && call_used_regs[regno]) \
132 SET_HARD_REG_BIT (reg_class_contents[SIBCALL_REGS], regno); \
135 /* ??? Need to write documentation for all SH options and add it to the
138 /* Run-time compilation parameters selecting different hardware subsets. */
140 extern int target_flags;
141 #define ISIZE_BIT (1<<1)
142 #define DALIGN_BIT (1<<6)
143 #define SH1_BIT (1<<8)
144 #define SH2_BIT (1<<9)
145 #define SH3_BIT (1<<10)
146 #define SH3E_BIT (1<<11)
147 #define HARD_SH4_BIT (1<<5)
148 #define FPU_SINGLE_BIT (1<<7)
149 #define SH4_BIT (1<<12)
150 #define FMOVD_BIT (1<<4)
151 #define SH5_BIT (1<<0)
152 #define SPACE_BIT (1<<13)
153 #define BIGTABLE_BIT (1<<14)
154 #define RELAX_BIT (1<<15)
155 #define USERMODE_BIT (1<<16)
156 #define HITACHI_BIT (1<<22)
157 #define NOMACSAVE_BIT (1<<23)
158 #define PREFERGOT_BIT (1<<24)
159 #define PADSTRUCT_BIT (1<<28)
160 #define LITTLE_ENDIAN_BIT (1<<29)
161 #define IEEE_BIT (1<<30)
163 /* Nonzero if we should dump out instruction size info. */
164 #define TARGET_DUMPISIZE (target_flags & ISIZE_BIT)
166 /* Nonzero to align doubles on 64 bit boundaries. */
167 #define TARGET_ALIGN_DOUBLE (target_flags & DALIGN_BIT)
169 /* Nonzero if we should generate code using type 1 insns. */
170 #define TARGET_SH1 (target_flags & SH1_BIT)
172 /* Nonzero if we should generate code using type 2 insns. */
173 #define TARGET_SH2 (target_flags & SH2_BIT)
175 /* Nonzero if we should generate code using type 3 insns. */
176 #define TARGET_SH3 (target_flags & SH3_BIT)
178 /* Nonzero if we should generate code using type 3E insns. */
179 #define TARGET_SH3E ((target_flags & SH3E_BIT) && (target_flags & SH1_BIT))
181 /* Nonzero if the cache line size is 32. */
182 #define TARGET_CACHE32 (target_flags & HARD_SH4_BIT || TARGET_SH5)
184 /* Nonzero if we schedule for a superscalar implementation. */
185 #define TARGET_SUPERSCALAR (target_flags & HARD_SH4_BIT)
187 /* Nonzero if the target has separate instruction and data caches. */
188 #define TARGET_HARVARD (target_flags & HARD_SH4_BIT)
190 /* Nonzero if compiling for SH4 hardware (to be used for insn costs etc.) */
191 #define TARGET_HARD_SH4 (target_flags & HARD_SH4_BIT)
193 /* Nonzero if the default precision of th FPU is single */
194 #define TARGET_FPU_SINGLE (target_flags & FPU_SINGLE_BIT)
196 /* Nonzero if a double-precision FPU is available. */
197 #define TARGET_FPU_DOUBLE (target_flags & SH4_BIT)
199 /* Nonzero if an FPU is available. */
200 #define TARGET_FPU_ANY (TARGET_SH3E || TARGET_FPU_DOUBLE)
202 /* Nonzero if we should generate code using type 4 insns. */
203 #define TARGET_SH4 ((target_flags & SH4_BIT) && (target_flags & SH1_BIT))
205 /* Nonzero if we should generate code for a SH5 CPU (either ISA). */
206 #define TARGET_SH5 (target_flags & SH5_BIT)
208 /* Nonzero if we should generate code using the SHcompact instruction
209 set and 32-bit ABI. */
210 #define TARGET_SHCOMPACT (TARGET_SH5 && TARGET_SH1)
212 /* Nonzero if we should generate code using the SHmedia instruction
214 #define TARGET_SHMEDIA (TARGET_SH5 && ! TARGET_SH1)
216 /* Nonzero if we should generate code using the SHmedia ISA and 32-bit
218 #define TARGET_SHMEDIA32 (TARGET_SH5 && ! TARGET_SH1 \
219 && (target_flags & SH3E_BIT))
221 /* Nonzero if we should generate code using the SHmedia ISA and 64-bit
223 #define TARGET_SHMEDIA64 (TARGET_SH5 && ! TARGET_SH1 \
224 && ! (target_flags & SH3E_BIT))
226 /* Nonzero if we should generate code using SHmedia FPU instructions. */
227 #define TARGET_SHMEDIA_FPU (TARGET_SHMEDIA && TARGET_FPU_DOUBLE)
228 /* Nonzero if we should generate fmovd. */
229 #define TARGET_FMOVD (target_flags & FMOVD_BIT)
231 /* Nonzero if we respect NANs. */
232 #define TARGET_IEEE (target_flags & IEEE_BIT)
234 /* Nonzero if we should generate smaller code rather than faster code. */
235 #define TARGET_SMALLCODE (target_flags & SPACE_BIT)
237 /* Nonzero to use long jump tables. */
238 #define TARGET_BIGTABLE (target_flags & BIGTABLE_BIT)
240 /* Nonzero to generate pseudo-ops needed by the assembler and linker
241 to do function call relaxing. */
242 #define TARGET_RELAX (target_flags & RELAX_BIT)
244 /* Nonzero if using Hitachi's calling convention. */
245 #define TARGET_HITACHI (target_flags & HITACHI_BIT)
247 /* Nonzero if not saving macl/mach when using -mhitachi */
248 #define TARGET_NOMACSAVE (target_flags & NOMACSAVE_BIT)
250 /* Nonzero if padding structures to a multiple of 4 bytes. This is
251 incompatible with Hitachi's compiler, and gives unusual structure layouts
252 which confuse programmers.
253 ??? This option is not useful, but is retained in case there are people
254 who are still relying on it. It may be deleted in the future. */
255 #define TARGET_PADSTRUCT (target_flags & PADSTRUCT_BIT)
257 /* Nonzero if generating code for a little endian SH. */
258 #define TARGET_LITTLE_ENDIAN (target_flags & LITTLE_ENDIAN_BIT)
260 /* Nonzero if we should do everything in userland. */
261 #define TARGET_USERMODE (target_flags & USERMODE_BIT)
263 /* Nonzero if we should prefer @GOT calls when generating PIC. */
264 #define TARGET_PREFERGOT (target_flags & PREFERGOT_BIT)
266 /* Reset all target-selection flags. */
267 #define TARGET_NONE -(SH1_BIT | SH2_BIT | SH3_BIT | SH3E_BIT | SH4_BIT \
268 | HARD_SH4_BIT | FPU_SINGLE_BIT | SH5_BIT)
270 #define TARGET_SWITCHES \
271 { {"1", TARGET_NONE, "" }, \
272 {"1", SH1_BIT, "" }, \
273 {"2", TARGET_NONE, "" }, \
274 {"2", SH2_BIT|SH1_BIT, "" }, \
275 {"3", TARGET_NONE, "" }, \
276 {"3", SH3_BIT|SH2_BIT|SH1_BIT, "" }, \
277 {"3e", TARGET_NONE, "" }, \
278 {"3e", SH3E_BIT|SH3_BIT|SH2_BIT|SH1_BIT|FPU_SINGLE_BIT, "" }, \
279 {"4-single-only", TARGET_NONE, "" }, \
280 {"4-single-only", SH3E_BIT|SH3_BIT|SH2_BIT|SH1_BIT|HARD_SH4_BIT|FPU_SINGLE_BIT, "" }, \
281 {"4-single", TARGET_NONE, "" }, \
282 {"4-single", SH4_BIT|SH3E_BIT|SH3_BIT|SH2_BIT|SH1_BIT|HARD_SH4_BIT|FPU_SINGLE_BIT, "" },\
283 {"4-nofpu", TARGET_NONE, "" }, \
284 {"4-nofpu", SH3_BIT|SH2_BIT|SH1_BIT|HARD_SH4_BIT, "" },\
285 {"4", TARGET_NONE, "" }, \
286 {"4", SH4_BIT|SH3E_BIT|SH3_BIT|SH2_BIT|SH1_BIT|HARD_SH4_BIT, "" }, \
287 {"5-64media", TARGET_NONE, "" }, \
288 {"5-64media", SH5_BIT|SH4_BIT, "Generate 64-bit SHmedia code" }, \
289 {"5-64media-nofpu", TARGET_NONE, "" }, \
290 {"5-64media-nofpu", SH5_BIT, "Generate 64-bit FPU-less SHmedia code" }, \
291 {"5-32media", TARGET_NONE, "" }, \
292 {"5-32media", SH5_BIT|SH4_BIT|SH3E_BIT, "Generate 32-bit SHmedia code" }, \
293 {"5-32media-nofpu", TARGET_NONE, "" }, \
294 {"5-32media-nofpu", SH5_BIT|SH3E_BIT, "Generate 32-bit FPU-less SHmedia code" }, \
295 {"5-compact", TARGET_NONE, "" }, \
296 {"5-compact", SH5_BIT|SH4_BIT|SH3E_BIT|SH3_BIT|SH2_BIT|SH1_BIT|FPU_SINGLE_BIT, "Generate SHcompact code" }, \
297 {"5-compact-nofpu", TARGET_NONE, "" }, \
298 {"5-compact-nofpu", SH5_BIT|SH3_BIT|SH2_BIT|SH1_BIT, "Generate FPU-less SHcompact code" }, \
299 {"b", -LITTLE_ENDIAN_BIT, "" }, \
300 {"bigtable", BIGTABLE_BIT, "" }, \
301 {"dalign", DALIGN_BIT, "" }, \
302 {"fmovd", FMOVD_BIT, "" }, \
303 {"hitachi", HITACHI_BIT, "" }, \
304 {"nomacsave", NOMACSAVE_BIT, "" }, \
305 {"ieee", IEEE_BIT, "" }, \
306 {"isize", ISIZE_BIT, "" }, \
307 {"l", LITTLE_ENDIAN_BIT, "" }, \
308 {"no-ieee", -IEEE_BIT, "" }, \
309 {"padstruct", PADSTRUCT_BIT, "" }, \
310 {"prefergot", PREFERGOT_BIT, "" }, \
311 {"relax", RELAX_BIT, "" }, \
312 {"space", SPACE_BIT, "" }, \
313 {"usermode", USERMODE_BIT, "" }, \
315 {"", TARGET_DEFAULT, "" } \
318 /* This are meant to be redefined in the host dependent files */
319 #define SUBTARGET_SWITCHES
321 #define TARGET_DEFAULT (SH1_BIT)
323 #define OPTIMIZATION_OPTIONS(LEVEL,SIZE) \
326 flag_omit_frame_pointer = -1; \
328 target_flags |= SPACE_BIT; \
331 #define ASSEMBLER_DIALECT assembler_dialect
333 extern int assembler_dialect;
335 #define OVERRIDE_OPTIONS \
340 assembler_dialect = 0; \
349 assembler_dialect = 1; \
355 target_flags |= DALIGN_BIT; \
356 if (TARGET_FPU_ANY) \
357 target_flags |= FMOVD_BIT; \
358 if (TARGET_SHMEDIA) \
360 /* There are no delay slots on SHmedia. */ \
361 flag_delayed_branch = 0; \
362 /* Relaxation isn't yet supported for SHmedia */ \
363 target_flags &= ~RELAX_BIT; \
365 if (profile_flag || profile_arc_flag) \
367 warning ("Profiling is not supported on this target."); \
368 profile_flag = profile_arc_flag = 0; \
373 /* Only the sh64-elf assembler fully supports .quad properly. */\
374 targetm.asm_out.aligned_op.di = NULL; \
375 targetm.asm_out.unaligned_op.di = NULL; \
378 for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++) \
379 if (! VALID_REGISTER_P (regno)) \
380 sh_register_names[regno][0] = '\0'; \
382 for (regno = 0; regno < ADDREGNAMES_SIZE; regno++) \
383 if (! VALID_REGISTER_P (ADDREGNAMES_REGNO (regno))) \
384 sh_additional_register_names[regno][0] = '\0'; \
386 if (flag_omit_frame_pointer < 0) \
388 /* The debugging information is sufficient, \
389 but gdb doesn't implement this yet */ \
391 flag_omit_frame_pointer \
392 = (PREFERRED_DEBUGGING_TYPE == DWARF_DEBUG \
393 || PREFERRED_DEBUGGING_TYPE == DWARF2_DEBUG); \
395 flag_omit_frame_pointer = 0; \
398 if (flag_pic && ! TARGET_PREFERGOT) \
399 flag_no_function_cse = 1; \
401 /* Never run scheduling before reload, since that can \
402 break global alloc, and generates slower code anyway due \
403 to the pressure on R0. */ \
404 flag_schedule_insns = 0; \
407 /* Target machine storage layout. */
409 /* Define to use software floating point emulator for REAL_ARITHMETIC and
410 decimal <-> binary conversion. */
411 #define REAL_ARITHMETIC
413 /* Define this if most significant bit is lowest numbered
414 in instructions that operate on numbered bit-fields. */
416 #define BITS_BIG_ENDIAN 0
418 /* Define this if most significant byte of a word is the lowest numbered. */
419 #define BYTES_BIG_ENDIAN (TARGET_LITTLE_ENDIAN == 0)
421 /* Define this if most significant word of a multiword number is the lowest
423 #define WORDS_BIG_ENDIAN (TARGET_LITTLE_ENDIAN == 0)
425 /* Define this to set the endianness to use in libgcc2.c, which can
426 not depend on target_flags. */
427 #if defined(__LITTLE_ENDIAN__)
428 #define LIBGCC2_WORDS_BIG_ENDIAN 0
430 #define LIBGCC2_WORDS_BIG_ENDIAN 1
433 /* Width in bits of a "word", which is the contents of a machine register.
434 Note that this is not necessarily the width of data type `int';
435 if using 16-bit ints on a 68000, this would still be 32.
436 But on a machine with 16-bit registers, this would be 16. */
437 #define BITS_PER_WORD (TARGET_SHMEDIA ? 64 : 32)
438 #define MAX_BITS_PER_WORD 64
440 #define MAX_LONG_TYPE_SIZE MAX_BITS_PER_WORD
442 /* Width in bits of an `int'. We want just 32-bits, even if words are
444 #define INT_TYPE_SIZE 32
446 /* Width in bits of a `long'. */
447 #define LONG_TYPE_SIZE (TARGET_SHMEDIA64 ? 64 : 32)
449 /* Width in bits of a `long long'. */
450 #define LONG_LONG_TYPE_SIZE 64
452 /* Width in bits of a `long double'. */
453 #define LONG_DOUBLE_TYPE_SIZE 64
455 /* Width of a word, in units (bytes). */
456 #define UNITS_PER_WORD (TARGET_SHMEDIA ? 8 : 4)
457 #define MIN_UNITS_PER_WORD 4
459 /* Width in bits of a pointer.
460 See also the macro `Pmode' defined below. */
461 #define POINTER_SIZE (TARGET_SHMEDIA64 ? 64 : 32)
463 /* Allocation boundary (in *bits*) for storing arguments in argument list. */
464 #define PARM_BOUNDARY (TARGET_SH5 ? 64 : 32)
466 /* Boundary (in *bits*) on which stack pointer should be aligned. */
467 #define STACK_BOUNDARY BIGGEST_ALIGNMENT
469 /* The log (base 2) of the cache line size, in bytes. Processors prior to
470 SH2 have no actual cache, but they fetch code in chunks of 4 bytes.
471 The SH2/3 have 16 byte cache lines, and the SH4 has a 32 byte cache line */
472 #define CACHE_LOG (TARGET_CACHE32 ? 5 : TARGET_SH2 ? 4 : 2)
474 /* Allocation boundary (in *bits*) for the code of a function.
475 32 bit alignment is faster, because instructions are always fetched as a
476 pair from a longword boundary. */
477 #define FUNCTION_BOUNDARY \
478 (TARGET_SMALLCODE ? 16 << TARGET_SHMEDIA : (1 << CACHE_LOG) * 8)
480 /* On SH5, the lowest bit is used to indicate SHmedia functions, so
481 the vbit must go into the delta field of
482 pointers-to-member-functions. */
483 #define TARGET_PTRMEMFUNC_VBIT_LOCATION \
484 (TARGET_SH5 ? ptrmemfunc_vbit_in_delta : ptrmemfunc_vbit_in_pfn)
486 /* Alignment of field after `int : 0' in a structure. */
487 #define EMPTY_FIELD_BOUNDARY 32
489 /* No data type wants to be aligned rounder than this. */
490 #define BIGGEST_ALIGNMENT (TARGET_ALIGN_DOUBLE ? 64 : 32)
492 /* The best alignment to use in cases where we have a choice. */
493 #define FASTEST_ALIGNMENT (TARGET_SH5 ? 64 : 32)
495 /* Make strings word-aligned so strcpy from constants will be faster. */
496 #define CONSTANT_ALIGNMENT(EXP, ALIGN) \
497 ((TREE_CODE (EXP) == STRING_CST \
498 && (ALIGN) < FASTEST_ALIGNMENT) \
499 ? FASTEST_ALIGNMENT : (ALIGN))
501 #ifndef MAX_OFILE_ALIGNMENT
502 #define MAX_OFILE_ALIGNMENT 128
505 /* Make arrays of chars word-aligned for the same reasons. */
506 #define DATA_ALIGNMENT(TYPE, ALIGN) \
507 (TREE_CODE (TYPE) == ARRAY_TYPE \
508 && TYPE_MODE (TREE_TYPE (TYPE)) == QImode \
509 && (ALIGN) < FASTEST_ALIGNMENT ? FASTEST_ALIGNMENT : (ALIGN))
511 /* Number of bits which any structure or union's size must be a
512 multiple of. Each structure or union's size is rounded up to a
514 #define STRUCTURE_SIZE_BOUNDARY (TARGET_PADSTRUCT ? 32 : 8)
516 /* Set this nonzero if move instructions will actually fail to work
517 when given unaligned data. */
518 #define STRICT_ALIGNMENT 1
520 /* If LABEL_AFTER_BARRIER demands an alignment, return its base 2 logarithm. */
521 #define LABEL_ALIGN_AFTER_BARRIER(LABEL_AFTER_BARRIER) \
522 barrier_align (LABEL_AFTER_BARRIER)
524 #define LOOP_ALIGN(A_LABEL) \
525 ((! optimize || TARGET_HARVARD || TARGET_SMALLCODE) \
526 ? 0 : sh_loop_align (A_LABEL))
528 #define LABEL_ALIGN(A_LABEL) \
530 (PREV_INSN (A_LABEL) \
531 && GET_CODE (PREV_INSN (A_LABEL)) == INSN \
532 && GET_CODE (PATTERN (PREV_INSN (A_LABEL))) == UNSPEC_VOLATILE \
533 && XINT (PATTERN (PREV_INSN (A_LABEL)), 1) == UNSPECV_ALIGN) \
534 /* explicit alignment insn in constant tables. */ \
535 ? INTVAL (XVECEXP (PATTERN (PREV_INSN (A_LABEL)), 0, 0)) \
538 /* Jump tables must be 32 bit aligned, no matter the size of the element. */
539 #define ADDR_VEC_ALIGN(ADDR_VEC) 2
541 /* The base two logarithm of the known minimum alignment of an insn length. */
542 #define INSN_LENGTH_ALIGNMENT(A_INSN) \
543 (GET_CODE (A_INSN) == INSN \
544 ? 1 << TARGET_SHMEDIA \
545 : GET_CODE (A_INSN) == JUMP_INSN || GET_CODE (A_INSN) == CALL_INSN \
546 ? 1 << TARGET_SHMEDIA \
549 /* Standard register usage. */
551 /* Register allocation for the Hitachi calling convention:
557 r14 frame pointer/call saved
559 ap arg pointer (doesn't really exist, always eliminated)
560 pr subroutine return address
562 mach multiply/accumulate result, high part
563 macl multiply/accumulate result, low part.
564 fpul fp/int communication register
565 rap return address pointer register
567 fr1..fr3 scratch floating point registers
569 fr12..fr15 call saved floating point registers */
571 #define MAX_REGISTER_NAME_LENGTH 5
572 extern char sh_register_names[][MAX_REGISTER_NAME_LENGTH + 1];
574 #define SH_REGISTER_NAMES_INITIALIZER \
576 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
577 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", \
578 "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", \
579 "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31", \
580 "r32", "r33", "r34", "r35", "r36", "r37", "r38", "r39", \
581 "r40", "r41", "r42", "r43", "r44", "r45", "r46", "r47", \
582 "r48", "r49", "r50", "r51", "r52", "r53", "r54", "r55", \
583 "r56", "r57", "r58", "r59", "r60", "r61", "r62", "r63", \
584 "fr0", "fr1", "fr2", "fr3", "fr4", "fr5", "fr6", "fr7", \
585 "fr8", "fr9", "fr10", "fr11", "fr12", "fr13", "fr14", "fr15", \
586 "fr16", "fr17", "fr18", "fr19", "fr20", "fr21", "fr22", "fr23", \
587 "fr24", "fr25", "fr26", "fr27", "fr28", "fr29", "fr30", "fr31", \
588 "fr32", "fr33", "fr34", "fr35", "fr36", "fr37", "fr38", "fr39", \
589 "fr40", "fr41", "fr42", "fr43", "fr44", "fr45", "fr46", "fr47", \
590 "fr48", "fr49", "fr50", "fr51", "fr52", "fr53", "fr54", "fr55", \
591 "fr56", "fr57", "fr58", "fr59", "fr60", "fr61", "fr62", "fr63", \
592 "tr0", "tr1", "tr2", "tr3", "tr4", "tr5", "tr6", "tr7", \
593 "xd0", "xd2", "xd4", "xd6", "xd8", "xd10", "xd12", "xd14", \
594 "gbr", "ap", "pr", "t", "mach", "macl", "fpul", "fpscr", \
598 #define DEBUG_REGISTER_NAMES SH_REGISTER_NAMES_INITIALIZER
600 #define REGNAMES_ARR_INDEX_1(index) \
601 (sh_register_names[index])
602 #define REGNAMES_ARR_INDEX_2(index) \
603 REGNAMES_ARR_INDEX_1 ((index)), REGNAMES_ARR_INDEX_1 ((index)+1)
604 #define REGNAMES_ARR_INDEX_4(index) \
605 REGNAMES_ARR_INDEX_2 ((index)), REGNAMES_ARR_INDEX_2 ((index)+2)
606 #define REGNAMES_ARR_INDEX_8(index) \
607 REGNAMES_ARR_INDEX_4 ((index)), REGNAMES_ARR_INDEX_4 ((index)+4)
608 #define REGNAMES_ARR_INDEX_16(index) \
609 REGNAMES_ARR_INDEX_8 ((index)), REGNAMES_ARR_INDEX_8 ((index)+8)
610 #define REGNAMES_ARR_INDEX_32(index) \
611 REGNAMES_ARR_INDEX_16 ((index)), REGNAMES_ARR_INDEX_16 ((index)+16)
612 #define REGNAMES_ARR_INDEX_64(index) \
613 REGNAMES_ARR_INDEX_32 ((index)), REGNAMES_ARR_INDEX_32 ((index)+32)
615 #define REGISTER_NAMES \
617 REGNAMES_ARR_INDEX_64 (0), \
618 REGNAMES_ARR_INDEX_64 (64), \
619 REGNAMES_ARR_INDEX_8 (128), \
620 REGNAMES_ARR_INDEX_8 (136), \
621 REGNAMES_ARR_INDEX_8 (144), \
622 REGNAMES_ARR_INDEX_1 (152) \
625 #define ADDREGNAMES_SIZE 32
626 #define MAX_ADDITIONAL_REGISTER_NAME_LENGTH 4
627 extern char sh_additional_register_names[ADDREGNAMES_SIZE] \
628 [MAX_ADDITIONAL_REGISTER_NAME_LENGTH + 1];
630 #define SH_ADDITIONAL_REGISTER_NAMES_INITIALIZER \
632 "dr0", "dr2", "dr4", "dr6", "dr8", "dr10", "dr12", "dr14", \
633 "dr16", "dr18", "dr20", "dr22", "dr24", "dr26", "dr28", "dr30", \
634 "dr32", "dr34", "dr36", "dr38", "dr40", "dr42", "dr44", "dr46", \
635 "dr48", "dr50", "dr52", "dr54", "dr56", "dr58", "dr60", "dr62" \
638 #define ADDREGNAMES_REGNO(index) \
639 ((index < 32) ? (FIRST_FP_REG + (index) * 2) \
642 #define ADDREGNAMES_ARR_INDEX_1(index) \
643 { (sh_additional_register_names[index]), ADDREGNAMES_REGNO (index) }
644 #define ADDREGNAMES_ARR_INDEX_2(index) \
645 ADDREGNAMES_ARR_INDEX_1 ((index)), ADDREGNAMES_ARR_INDEX_1 ((index)+1)
646 #define ADDREGNAMES_ARR_INDEX_4(index) \
647 ADDREGNAMES_ARR_INDEX_2 ((index)), ADDREGNAMES_ARR_INDEX_2 ((index)+2)
648 #define ADDREGNAMES_ARR_INDEX_8(index) \
649 ADDREGNAMES_ARR_INDEX_4 ((index)), ADDREGNAMES_ARR_INDEX_4 ((index)+4)
650 #define ADDREGNAMES_ARR_INDEX_16(index) \
651 ADDREGNAMES_ARR_INDEX_8 ((index)), ADDREGNAMES_ARR_INDEX_8 ((index)+8)
652 #define ADDREGNAMES_ARR_INDEX_32(index) \
653 ADDREGNAMES_ARR_INDEX_16 ((index)), ADDREGNAMES_ARR_INDEX_16 ((index)+16)
655 #define ADDITIONAL_REGISTER_NAMES \
657 ADDREGNAMES_ARR_INDEX_32 (0) \
660 /* Number of actual hardware registers.
661 The hardware registers are assigned numbers for the compiler
662 from 0 to just below FIRST_PSEUDO_REGISTER.
663 All registers that the compiler knows about must be given numbers,
664 even those that are not normally considered general registers. */
666 /* There are many other relevant definitions in sh.md's md_constants. */
668 #define FIRST_GENERAL_REG R0_REG
669 #define LAST_GENERAL_REG (FIRST_GENERAL_REG + (TARGET_SHMEDIA ? 63 : 15))
670 #define FIRST_FP_REG DR0_REG
671 #define LAST_FP_REG (FIRST_FP_REG + \
672 (TARGET_SHMEDIA_FPU ? 63 : TARGET_SH3E ? 15 : -1))
673 #define FIRST_XD_REG XD0_REG
674 #define LAST_XD_REG (FIRST_XD_REG + ((TARGET_SH4 && TARGET_FMOVD) ? 7 : -1))
675 #define FIRST_TARGET_REG TR0_REG
676 #define LAST_TARGET_REG (FIRST_TARGET_REG + (TARGET_SHMEDIA ? 7 : -1))
678 #define GENERAL_REGISTER_P(REGNO) \
679 IN_RANGE ((REGNO), FIRST_GENERAL_REG, LAST_GENERAL_REG)
681 #define GENERAL_OR_AP_REGISTER_P(REGNO) \
682 (GENERAL_REGISTER_P (REGNO) || ((REGNO) == AP_REG))
684 #define FP_REGISTER_P(REGNO) \
685 ((REGNO) >= FIRST_FP_REG && (REGNO) <= LAST_FP_REG)
687 #define XD_REGISTER_P(REGNO) \
688 ((REGNO) >= FIRST_XD_REG && (REGNO) <= LAST_XD_REG)
690 #define FP_OR_XD_REGISTER_P(REGNO) \
691 (FP_REGISTER_P (REGNO) || XD_REGISTER_P (REGNO))
693 #define FP_ANY_REGISTER_P(REGNO) \
694 (FP_REGISTER_P (REGNO) || XD_REGISTER_P (REGNO) || (REGNO) == FPUL_REG)
696 #define SPECIAL_REGISTER_P(REGNO) \
697 ((REGNO) == GBR_REG || (REGNO) == T_REG \
698 || (REGNO) == MACH_REG || (REGNO) == MACL_REG)
700 #define TARGET_REGISTER_P(REGNO) \
701 ((REGNO) >= FIRST_TARGET_REG && (REGNO) <= LAST_TARGET_REG)
703 #define SHMEDIA_REGISTER_P(REGNO) \
704 (GENERAL_REGISTER_P (REGNO) || FP_REGISTER_P (REGNO) \
705 || TARGET_REGISTER_P (REGNO))
707 /* This is to be used in CONDITIONAL_REGISTER_USAGE, to mark registers
708 that should be fixed. */
709 #define VALID_REGISTER_P(REGNO) \
710 (SHMEDIA_REGISTER_P (REGNO) || XD_REGISTER_P (REGNO) \
711 || (REGNO) == AP_REG || (REGNO) == RAP_REG \
712 || (TARGET_SH1 && (SPECIAL_REGISTER_P (REGNO) || (REGNO) == PR_REG)) \
713 || (TARGET_SH3E && (REGNO) == FPUL_REG))
715 /* The mode that should be generally used to store a register by
716 itself in the stack, or to load it back. */
717 #define REGISTER_NATURAL_MODE(REGNO) \
718 (FP_REGISTER_P (REGNO) ? SFmode \
719 : XD_REGISTER_P (REGNO) ? DFmode \
720 : TARGET_SHMEDIA && ! HARD_REGNO_CALL_PART_CLOBBERED ((REGNO), DImode) \
724 #define FIRST_PSEUDO_REGISTER 153
726 /* 1 for registers that have pervasive standard uses
727 and are not available for the register allocator.
729 Mach register is fixed 'cause it's only 10 bits wide for SH1.
730 It is 32 bits wide for SH2. */
732 #define FIXED_REGISTERS \
734 /* Regular registers. */ \
735 0, 0, 0, 0, 0, 0, 0, 0, \
736 0, 0, 0, 0, 0, 0, 0, 1, \
737 /* r16 is reserved, r18 is the former pr. */ \
738 1, 0, 0, 0, 0, 0, 0, 0, \
739 /* r24 is reserved for the OS; r25, for the assembler or linker. */ \
740 /* r26 is a global variable data pointer; r27 is for constants. */ \
741 1, 1, 1, 1, 0, 0, 0, 0, \
742 0, 0, 0, 0, 0, 0, 0, 0, \
743 0, 0, 0, 0, 0, 0, 0, 0, \
744 0, 0, 0, 0, 0, 0, 0, 0, \
745 0, 0, 0, 0, 0, 0, 0, 1, \
746 /* FP registers. */ \
747 0, 0, 0, 0, 0, 0, 0, 0, \
748 0, 0, 0, 0, 0, 0, 0, 0, \
749 0, 0, 0, 0, 0, 0, 0, 0, \
750 0, 0, 0, 0, 0, 0, 0, 0, \
751 0, 0, 0, 0, 0, 0, 0, 0, \
752 0, 0, 0, 0, 0, 0, 0, 0, \
753 0, 0, 0, 0, 0, 0, 0, 0, \
754 0, 0, 0, 0, 0, 0, 0, 0, \
755 /* Branch target registers. */ \
756 0, 0, 0, 0, 0, 0, 0, 0, \
757 /* XD registers. */ \
758 0, 0, 0, 0, 0, 0, 0, 0, \
759 /*"gbr", "ap", "pr", "t", "mach", "macl", "fpul", "fpscr", */ \
760 1, 1, 1, 1, 1, 1, 0, 1, \
765 /* 1 for registers not available across function calls.
766 These must include the FIXED_REGISTERS and also any
767 registers that can be used without being saved.
768 The latter must include the registers where values are returned
769 and the register where structure-value addresses are passed.
770 Aside from that, you can include as many other registers as you like. */
772 #define CALL_USED_REGISTERS \
774 /* Regular registers. */ \
775 1, 1, 1, 1, 1, 1, 1, 1, \
776 /* R8 and R9 are call-clobbered on SH5, but not on earlier SH ABIs. \
777 Only the lower 32bits of R10-R14 are guaranteed to be preserved \
778 across SH5 function calls. */ \
779 0, 0, 0, 0, 0, 0, 0, 1, \
780 1, 1, 0, 1, 1, 1, 1, 1, \
781 1, 1, 1, 1, 0, 0, 0, 0, \
782 0, 0, 0, 0, 1, 1, 1, 1, \
783 1, 1, 1, 1, 0, 0, 0, 0, \
784 0, 0, 0, 0, 0, 0, 0, 0, \
785 0, 0, 0, 0, 1, 1, 1, 1, \
786 /* FP registers. */ \
787 1, 1, 1, 1, 1, 1, 1, 1, \
788 1, 1, 1, 1, 0, 0, 0, 0, \
789 1, 1, 1, 1, 1, 1, 1, 1, \
790 1, 1, 1, 1, 1, 1, 1, 1, \
791 1, 1, 1, 1, 0, 0, 0, 0, \
792 0, 0, 0, 0, 0, 0, 0, 0, \
793 0, 0, 0, 0, 0, 0, 0, 0, \
794 0, 0, 0, 0, 0, 0, 0, 0, \
795 /* Branch target registers. */ \
796 1, 1, 1, 1, 1, 0, 0, 0, \
797 /* XD registers. */ \
798 1, 1, 1, 1, 1, 1, 0, 0, \
799 /*"gbr", "ap", "pr", "t", "mach", "macl", "fpul", "fpscr", */ \
800 1, 1, 0, 1, 1, 1, 1, 1, \
805 /* Only the lower 32-bits of R10-R14 are guaranteed to be preserved
806 across SHcompact function calls. We can't tell whether a called
807 function is SHmedia or SHcompact, so we assume it may be when
808 compiling SHmedia code with the 32-bit ABI, since that's the only
809 ABI that can be linked with SHcompact code. */
810 #define HARD_REGNO_CALL_PART_CLOBBERED(REGNO,MODE) \
812 && GET_MODE_SIZE (MODE) > 4 \
813 && (((REGNO) >= FIRST_GENERAL_REG + 10 \
814 && (REGNO) <= FIRST_GENERAL_REG + 14) \
815 || (REGNO) == PR_MEDIA_REG))
817 /* Return number of consecutive hard regs needed starting at reg REGNO
818 to hold something of mode MODE.
819 This is ordinarily the length in words of a value of mode MODE
820 but can be less for certain modes in special long registers.
822 On the SH all but the XD regs are UNITS_PER_WORD bits wide. */
824 #define HARD_REGNO_NREGS(REGNO, MODE) \
825 (XD_REGISTER_P (REGNO) \
826 ? (GET_MODE_SIZE (MODE) / (2 * UNITS_PER_WORD)) \
827 : (TARGET_SHMEDIA && FP_REGISTER_P (REGNO)) \
828 ? ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD/2 - 1) / (UNITS_PER_WORD/2)) \
829 : ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)) \
831 /* Value is 1 if hard register REGNO can hold a value of machine-mode MODE.
832 We can allow any mode in any general register. The special registers
833 only allow SImode. Don't allow any mode in the PR. */
835 /* We cannot hold DCmode values in the XD registers because alter_reg
836 handles subregs of them incorrectly. We could work around this by
837 spacing the XD registers like the DR registers, but this would require
838 additional memory in every compilation to hold larger register vectors.
839 We could hold SFmode / SCmode values in XD registers, but that
840 would require a tertiary reload when reloading from / to memory,
841 and a secondary reload to reload from / to general regs; that
842 seems to be a loosing proposition. */
843 #define HARD_REGNO_MODE_OK(REGNO, MODE) \
844 (SPECIAL_REGISTER_P (REGNO) ? (MODE) == SImode \
845 : (REGNO) == FPUL_REG ? (MODE) == SImode || (MODE) == SFmode \
846 : FP_REGISTER_P (REGNO) && (MODE) == SFmode \
848 : (MODE) == V2SFmode \
849 ? (FP_REGISTER_P (REGNO) && ((REGNO) - FIRST_FP_REG) % 2 == 0) \
850 : (MODE) == V4SFmode \
851 ? (FP_REGISTER_P (REGNO) && ((REGNO) - FIRST_FP_REG) % 4 == 0) \
852 : (MODE) == V16SFmode \
854 ? (FP_REGISTER_P (REGNO) && ((REGNO) - FIRST_FP_REG) % 16 == 0) \
855 : (REGNO) == FIRST_XD_REG) \
856 : FP_REGISTER_P (REGNO) \
857 ? ((MODE) == SFmode \
858 || (TARGET_SHMEDIA && (MODE) == SImode) \
859 || ((TARGET_SH3E || TARGET_SHMEDIA) && (MODE) == SCmode) \
860 || (((TARGET_SH4 && (MODE) == DFmode) || (MODE) == DCmode \
861 || (TARGET_SHMEDIA && ((MODE) == DFmode || (MODE) == DImode \
862 || (MODE) == V2SFmode))) \
863 && (((REGNO) - FIRST_FP_REG) & 1) == 0)) \
864 : XD_REGISTER_P (REGNO) \
866 : TARGET_REGISTER_P (REGNO) \
867 ? ((MODE) == DImode || (MODE) == SImode) \
868 : (REGNO) == PR_REG ? 0 \
869 : (REGNO) == FPSCR_REG ? (MODE) == PSImode \
872 /* Value is 1 if MODE is a supported vector mode. */
873 #define VECTOR_MODE_SUPPORTED_P(MODE) \
875 && ((MODE) == V2SFmode || (MODE) == V4SFmode || (MODE) == V16SFmode))
877 /* Value is 1 if it is a good idea to tie two pseudo registers
878 when one has mode MODE1 and one has mode MODE2.
879 If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2,
880 for any hard reg, then this must be 0 for correct output.
881 That's the case for xd registers: we don't hold SFmode values in
882 them, so we can't tie an SFmode pseudos with one in another
883 floating-point mode. */
885 #define MODES_TIEABLE_P(MODE1, MODE2) \
886 ((MODE1) == (MODE2) \
887 || (GET_MODE_CLASS (MODE1) == GET_MODE_CLASS (MODE2) \
888 && (TARGET_SHMEDIA ? ((GET_MODE_SIZE (MODE1) <= 4) \
889 && (GET_MODE_SIZE (MODE2) <= 4)) \
890 : ((MODE1) != SFmode && (MODE2) != SFmode))))
892 /* Specify the registers used for certain standard purposes.
893 The values of these macros are register numbers. */
895 /* Define this if the program counter is overloaded on a register. */
896 /* #define PC_REGNUM 15*/
898 /* Register to use for pushing function arguments. */
899 #define STACK_POINTER_REGNUM SP_REG
901 /* Base register for access to local variables of the function. */
902 #define FRAME_POINTER_REGNUM FP_REG
904 /* Fake register that holds the address on the stack of the
905 current function's return address. */
906 #define RETURN_ADDRESS_POINTER_REGNUM RAP_REG
908 /* Register to hold the addressing base for position independent
909 code access to data items. */
910 #define PIC_OFFSET_TABLE_REGNUM PIC_REG
912 #define GOT_SYMBOL_NAME "*_GLOBAL_OFFSET_TABLE_"
914 /* Value should be nonzero if functions must have frame pointers.
915 Zero means the frame pointer need not be set up (and parms may be accessed
916 via the stack pointer) in functions that seem suitable. */
918 #define FRAME_POINTER_REQUIRED 0
920 /* Definitions for register eliminations.
922 We have three registers that can be eliminated on the SH. First, the
923 frame pointer register can often be eliminated in favor of the stack
924 pointer register. Secondly, the argument pointer register can always be
925 eliminated; it is replaced with either the stack or frame pointer.
926 Third, there is the return address pointer, which can also be replaced
927 with either the stack or the frame pointer. */
929 /* This is an array of structures. Each structure initializes one pair
930 of eliminable registers. The "from" register number is given first,
931 followed by "to". Eliminations of the same "from" register are listed
932 in order of preference. */
934 /* If you add any registers here that are not actually hard registers,
935 and that have any alternative of elimination that doesn't always
936 apply, you need to amend calc_live_regs to exclude it, because
937 reload spills all eliminable registers where it sees an
938 can_eliminate == 0 entry, thus making them 'live' .
939 If you add any hard registers that can be eliminated in different
940 ways, you have to patch reload to spill them only when all alternatives
941 of elimination fail. */
943 #define ELIMINABLE_REGS \
944 {{ FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
945 { RETURN_ADDRESS_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
946 { RETURN_ADDRESS_POINTER_REGNUM, FRAME_POINTER_REGNUM}, \
947 { ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
948 { ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM},}
950 /* Given FROM and TO register numbers, say whether this elimination
952 #define CAN_ELIMINATE(FROM, TO) \
953 (!((FROM) == FRAME_POINTER_REGNUM && FRAME_POINTER_REQUIRED))
955 /* Define the offset between two registers, one to be eliminated, and the other
956 its replacement, at the start of a routine. */
958 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
959 OFFSET = initial_elimination_offset ((FROM), (TO))
961 /* Base register for access to arguments of the function. */
962 #define ARG_POINTER_REGNUM AP_REG
964 /* Register in which the static-chain is passed to a function. */
965 #define STATIC_CHAIN_REGNUM (TARGET_SH5 ? 1 : 3)
967 /* The register in which a struct value address is passed. */
969 #define STRUCT_VALUE_REGNUM 2
971 /* If the structure value address is not passed in a register, define
972 `STRUCT_VALUE' as an expression returning an RTX for the place
973 where the address is passed. If it returns 0, the address is
974 passed as an "invisible" first argument. */
976 /* The Hitachi calling convention doesn't quite fit into this scheme since
977 the address is passed like an invisible argument, but one that is always
979 #define STRUCT_VALUE \
980 (TARGET_HITACHI ? 0 : gen_rtx_REG (Pmode, STRUCT_VALUE_REGNUM))
982 #define RETURN_IN_MEMORY(TYPE) \
984 ? ((TYPE_MODE (TYPE) == BLKmode \
985 ? int_size_in_bytes (TYPE) \
986 : GET_MODE_SIZE (TYPE_MODE (TYPE))) > 8) \
987 : (TYPE_MODE (TYPE) == BLKmode \
988 || TARGET_HITACHI && TREE_CODE (TYPE) == RECORD_TYPE))
990 /* Don't default to pcc-struct-return, because we have already specified
991 exactly how to return structures in the RETURN_IN_MEMORY macro. */
993 #define DEFAULT_PCC_STRUCT_RETURN 0
995 #define SHMEDIA_REGS_STACK_ADJUST() \
996 (TARGET_SHCOMPACT && current_function_has_nonlocal_label \
997 ? (8 * (/* r28-r35 */ 8 + /* r44-r59 */ 16 + /* tr5-tr7 */ 3) \
998 + (TARGET_FPU_ANY ? 4 * (/* fr36 - fr63 */ 28) : 0)) \
1002 /* Define the classes of registers for register constraints in the
1003 machine description. Also define ranges of constants.
1005 One of the classes must always be named ALL_REGS and include all hard regs.
1006 If there is more than one class, another class must be named NO_REGS
1007 and contain no registers.
1009 The name GENERAL_REGS must be the name of a class (or an alias for
1010 another name such as ALL_REGS). This is the class of registers
1011 that is allowed by "g" or "r" in a register constraint.
1012 Also, registers outside this class are allocated only when
1013 instructions express preferences for them.
1015 The classes must be numbered in nondecreasing order; that is,
1016 a larger-numbered class must never be contained completely
1017 in a smaller-numbered class.
1019 For any two classes, it is very desirable that there be another
1020 class that represents their union. */
1022 /* The SH has two sorts of general registers, R0 and the rest. R0 can
1023 be used as the destination of some of the arithmetic ops. There are
1024 also some special purpose registers; the T bit register, the
1025 Procedure Return Register and the Multiply Accumulate Registers. */
1026 /* Place GENERAL_REGS after FPUL_REGS so that it will be preferred by
1027 reg_class_subunion. We don't want to have an actual union class
1028 of these, because it would only be used when both classes are calculated
1029 to give the same cost, but there is only one FPUL register.
1030 Besides, regclass fails to notice the different REGISTER_MOVE_COSTS
1031 applying to the actual instruction alternative considered. E.g., the
1032 y/r alternative of movsi_ie is considered to have no more cost that
1033 the r/r alternative, which is patently untrue. */
1055 #define N_REG_CLASSES (int) LIM_REG_CLASSES
1057 /* Give names of register classes as strings for dump file. */
1058 #define REG_CLASS_NAMES \
1072 "GENERAL_FP_REGS", \
1077 /* Define which registers fit in which classes.
1078 This is an initializer for a vector of HARD_REG_SET
1079 of length N_REG_CLASSES. */
1081 #define REG_CLASS_CONTENTS \
1084 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 }, \
1086 { 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000 }, \
1088 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00040000 }, \
1090 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00080000 }, \
1092 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00300000 }, \
1094 { 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00400000 }, \
1095 /* SIBCALL_REGS: Initialized in CONDITIONAL_REGISTER_USAGE. */ \
1096 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 }, \
1097 /* GENERAL_REGS: */ \
1098 { 0xffffffff, 0xffffffff, 0x00000000, 0x00000000, 0x01020000 }, \
1100 { 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000 }, \
1102 { 0x00000000, 0x00000000, 0xffffffff, 0xffffffff, 0x00000000 }, \
1104 { 0x00000000, 0x00000000, 0xffffffff, 0xffffffff, 0x0000ff00 }, \
1106 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00800000 }, \
1107 /* GENERAL_FP_REGS: */ \
1108 { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x0102ff00 }, \
1109 /* TARGET_REGS: */ \
1110 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000000ff }, \
1112 { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x01ffffff }, \
1115 /* The same information, inverted:
1116 Return the class number of the smallest class containing
1117 reg number REGNO. This could be a conditional expression
1118 or could index an array. */
1120 extern int regno_reg_class[FIRST_PSEUDO_REGISTER];
1121 #define REGNO_REG_CLASS(REGNO) regno_reg_class[(REGNO)]
1123 /* When defined, the compiler allows registers explicitly used in the
1124 rtl to be used as spill registers but prevents the compiler from
1125 extending the lifetime of these registers. */
1127 #define SMALL_REGISTER_CLASSES (! TARGET_SHMEDIA)
1129 /* The order in which register should be allocated. */
1130 /* Sometimes FP0_REGS becomes the preferred class of a floating point pseudo,
1131 and GENERAL_FP_REGS the alternate class. Since FP0 is likely to be
1132 spilled or used otherwise, we better have the FP_REGS allocated first. */
1133 #define REG_ALLOC_ORDER \
1134 { 65, 66, 67, 68, 69, 70, 71, 64, \
1135 72, 73, 74, 75, 76, 77, 78, 79, \
1136 136,137,138,139,140,141,142,143, \
1137 80, 81, 82, 83, 84, 85, 86, 87, \
1138 88, 89, 90, 91, 92, 93, 94, 95, \
1139 96, 97, 98, 99,100,101,102,103, \
1140 104,105,106,107,108,109,110,111, \
1141 112,113,114,115,116,117,118,119, \
1142 120,121,122,123,124,125,126,127, \
1143 151, 1, 2, 3, 7, 6, 5, 4, \
1144 0, 8, 9, 10, 11, 12, 13, 14, \
1145 16, 17, 18, 19, 20, 21, 22, 23, \
1146 24, 25, 26, 27, 28, 29, 30, 31, \
1147 32, 33, 34, 35, 36, 37, 38, 39, \
1148 40, 41, 42, 43, 44, 45, 46, 47, \
1149 48, 49, 50, 51, 52, 53, 54, 55, \
1150 56, 57, 58, 59, 60, 61, 62, 63, \
1151 150, 15,145,146,147,144,148,149, \
1152 128,129,130,131,132,133,134,135, \
1155 /* The class value for index registers, and the one for base regs. */
1156 #define INDEX_REG_CLASS (TARGET_SHMEDIA ? GENERAL_REGS : R0_REGS)
1157 #define BASE_REG_CLASS GENERAL_REGS
1159 /* Get reg_class from a letter such as appears in the machine
1161 extern const enum reg_class reg_class_from_letter[];
1163 #define REG_CLASS_FROM_LETTER(C) \
1164 ( ISLOWER (C) ? reg_class_from_letter[(C)-'a'] : NO_REGS )
1166 /* The letters I, J, K, L and M in a register constraint string
1167 can be used to stand for particular ranges of immediate operands.
1168 This macro defines what the ranges are.
1169 C is the letter, and VALUE is a constant value.
1170 Return 1 if VALUE is in the range specified by C.
1171 I: arithmetic operand -127..128, as used in add, sub, etc
1172 J: arithmetic operand -32768..32767, as used in SHmedia movi and shori
1173 K: shift operand 1,2,8 or 16
1174 L: logical operand 0..255, as used in and, or, etc.
1177 O: arithmetic operand -32..31, as used in SHmedia beqi, bnei and xori
1178 P: arithmetic operand -512..511, as used in SHmedia andi, ori
1181 #define CONST_OK_FOR_I(VALUE) (((HOST_WIDE_INT)(VALUE))>= -128 \
1182 && ((HOST_WIDE_INT)(VALUE)) <= 127)
1183 #define CONST_OK_FOR_J(VALUE) (((HOST_WIDE_INT)(VALUE)) >= -32768 \
1184 && ((HOST_WIDE_INT)(VALUE)) <= 32767)
1185 #define CONST_OK_FOR_K(VALUE) ((VALUE)==1||(VALUE)==2||(VALUE)==8||(VALUE)==16)
1186 #define CONST_OK_FOR_L(VALUE) (((HOST_WIDE_INT)(VALUE))>= 0 \
1187 && ((HOST_WIDE_INT)(VALUE)) <= 255)
1188 #define CONST_OK_FOR_M(VALUE) ((VALUE)==1)
1189 #define CONST_OK_FOR_N(VALUE) ((VALUE)==0)
1190 #define CONST_OK_FOR_O(VALUE) (((HOST_WIDE_INT)(VALUE)) >= -32 \
1191 && ((HOST_WIDE_INT)(VALUE)) <= 31)
1192 #define CONST_OK_FOR_P(VALUE) (((HOST_WIDE_INT)(VALUE)) >= -512 \
1193 && ((HOST_WIDE_INT)(VALUE)) <= 511)
1194 #define CONST_OK_FOR_LETTER_P(VALUE, C) \
1195 ((C) == 'I' ? CONST_OK_FOR_I (VALUE) \
1196 : (C) == 'J' ? CONST_OK_FOR_J (VALUE) \
1197 : (C) == 'K' ? CONST_OK_FOR_K (VALUE) \
1198 : (C) == 'L' ? CONST_OK_FOR_L (VALUE) \
1199 : (C) == 'M' ? CONST_OK_FOR_M (VALUE) \
1200 : (C) == 'N' ? CONST_OK_FOR_N (VALUE) \
1201 : (C) == 'O' ? CONST_OK_FOR_O (VALUE) \
1202 : (C) == 'P' ? CONST_OK_FOR_P (VALUE) \
1205 /* Similar, but for floating constants, and defining letters G and H.
1206 Here VALUE is the CONST_DOUBLE rtx itself. */
1208 #define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) \
1209 ((C) == 'G' ? (fp_zero_operand (VALUE) && fldi_ok ()) \
1210 : (C) == 'H' ? (fp_one_operand (VALUE) && fldi_ok ()) \
1213 /* Given an rtx X being reloaded into a reg required to be
1214 in class CLASS, return the class of reg to actually use.
1215 In general this is just CLASS; but on some machines
1216 in some cases it is preferable to use a more restrictive class. */
1218 #define PREFERRED_RELOAD_CLASS(X, CLASS) \
1219 ((CLASS) == NO_REGS && TARGET_SHMEDIA \
1220 && (GET_CODE (X) == CONST_DOUBLE \
1221 || GET_CODE (X) == SYMBOL_REF) \
1225 #define SECONDARY_OUTPUT_RELOAD_CLASS(CLASS,MODE,X) \
1226 ((((((CLASS) == FP_REGS || (CLASS) == FP0_REGS \
1227 || (CLASS) == DF_REGS) \
1228 && (GET_CODE (X) == REG && GENERAL_OR_AP_REGISTER_P (REGNO (X)))) \
1229 || (((CLASS) == GENERAL_REGS || (CLASS) == R0_REGS) \
1230 && GET_CODE (X) == REG \
1231 && FP_REGISTER_P (REGNO (X)))) \
1232 && ! TARGET_SHMEDIA \
1233 && MODE == SFmode) \
1235 : ((CLASS) == FPUL_REGS \
1236 && (GET_CODE (X) == MEM \
1237 || (GET_CODE (X) == REG \
1238 && (REGNO (X) >= FIRST_PSEUDO_REGISTER \
1239 || REGNO (X) == T_REG \
1240 || system_reg_operand (X, VOIDmode))))) \
1242 : (((CLASS) == FP_REGS || (CLASS) == DF_REGS) && TARGET_SHMEDIA \
1243 && immediate_operand ((X), (MODE))) \
1245 : ((CLASS) == TARGET_REGS \
1246 || (TARGET_SHMEDIA && (CLASS) == SIBCALL_REGS)) \
1247 ? ((target_operand ((X), (MODE)) \
1248 && ! target_reg_operand ((X), (MODE))) \
1249 ? NO_REGS : GENERAL_REGS) \
1250 : (((CLASS) == MAC_REGS || (CLASS) == PR_REGS) \
1251 && GET_CODE (X) == REG && ! GENERAL_REGISTER_P (REGNO (X)) \
1252 && (CLASS) != REGNO_REG_CLASS (REGNO (X))) \
1253 ? GENERAL_REGS : NO_REGS)
1255 #define SECONDARY_INPUT_RELOAD_CLASS(CLASS,MODE,X) \
1256 ((((CLASS) == FP_REGS || (CLASS) == FP0_REGS || (CLASS) == DF_REGS) \
1257 && ! TARGET_SHMEDIA \
1258 && immediate_operand ((X), (MODE)) \
1259 && ! ((fp_zero_operand (X) || fp_one_operand (X)) \
1260 && (MODE) == SFmode && fldi_ok ())) \
1262 : (CLASS == FPUL_REGS \
1263 && ((GET_CODE (X) == REG \
1264 && (REGNO (X) == MACL_REG || REGNO (X) == MACH_REG \
1265 || REGNO (X) == T_REG)))) \
1267 : CLASS == FPUL_REGS && immediate_operand ((X), (MODE)) \
1268 ? (GET_CODE (X) == CONST_INT && CONST_OK_FOR_I (INTVAL (X)) \
1271 : (CLASS == FPSCR_REGS \
1272 && ((GET_CODE (X) == REG && REGNO (X) >= FIRST_PSEUDO_REGISTER) \
1273 || (GET_CODE (X) == MEM && GET_CODE (XEXP ((X), 0)) == PLUS)))\
1275 : SECONDARY_OUTPUT_RELOAD_CLASS((CLASS),(MODE),(X)))
1277 /* Return the maximum number of consecutive registers
1278 needed to represent mode MODE in a register of class CLASS.
1280 On SH this is the size of MODE in words. */
1281 #define CLASS_MAX_NREGS(CLASS, MODE) \
1282 ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
1284 /* If defined, gives a class of registers that cannot be used as the
1285 operand of a SUBREG that changes the mode of the object illegally. */
1287 #define CLASS_CANNOT_CHANGE_MODE DF_REGS
1289 /* Defines illegal mode changes for CLASS_CANNOT_CHANGE_MODE. */
1291 #define CLASS_CANNOT_CHANGE_MODE_P(FROM,TO) \
1292 (GET_MODE_SIZE (FROM) != GET_MODE_SIZE (TO))
1294 /* Stack layout; function entry, exit and calling. */
1296 /* Define the number of registers that can hold parameters.
1297 These macros are used only in other macro definitions below. */
1299 #define NPARM_REGS(MODE) \
1300 (TARGET_FPU_ANY && (MODE) == SFmode \
1301 ? (TARGET_SH5 ? 12 : 8) \
1302 : TARGET_SH4 && (GET_MODE_CLASS (MODE) == MODE_FLOAT \
1303 || GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT) \
1304 ? (TARGET_SH5 ? 12 : 8) \
1305 : (TARGET_SH5 ? 8 : 4))
1307 #define FIRST_PARM_REG (FIRST_GENERAL_REG + (TARGET_SH5 ? 2 : 4))
1308 #define FIRST_RET_REG (FIRST_GENERAL_REG + (TARGET_SH5 ? 2 : 0))
1310 #define FIRST_FP_PARM_REG (FIRST_FP_REG + (TARGET_SH5 ? 0 : 4))
1311 #define FIRST_FP_RET_REG FIRST_FP_REG
1313 /* Define this if pushing a word on the stack
1314 makes the stack pointer a smaller address. */
1315 #define STACK_GROWS_DOWNWARD
1317 /* Define this macro if the addresses of local variable slots are at
1318 negative offsets from the frame pointer.
1320 The SH only has positive indexes, so grow the frame up. */
1321 /* #define FRAME_GROWS_DOWNWARD */
1323 /* Offset from the frame pointer to the first local variable slot to
1325 #define STARTING_FRAME_OFFSET 0
1327 /* If we generate an insn to push BYTES bytes,
1328 this says how many the stack pointer really advances by. */
1329 /* Don't define PUSH_ROUNDING, since the hardware doesn't do this.
1330 When PUSH_ROUNDING is not defined, PARM_BOUNDARY will cause gcc to
1331 do correct alignment. */
1333 #define PUSH_ROUNDING(NPUSHED) (((NPUSHED) + 3) & ~3)
1336 /* Offset of first parameter from the argument pointer register value. */
1337 #define FIRST_PARM_OFFSET(FNDECL) 0
1339 /* Value is the number of byte of arguments automatically
1340 popped when returning from a subroutine call.
1341 FUNDECL is the declaration node of the function (as a tree),
1342 FUNTYPE is the data type of the function (as a tree),
1343 or for a library call it is an identifier node for the subroutine name.
1344 SIZE is the number of bytes of arguments passed on the stack.
1346 On the SH, the caller does not pop any of its arguments that were passed
1348 #define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE) 0
1350 /* Value is the number of bytes of arguments automatically popped when
1351 calling a subroutine.
1352 CUM is the accumulated argument list.
1354 On SHcompact, the call trampoline pops arguments off the stack. */
1355 #define CALL_POPS_ARGS(CUM) (TARGET_SHCOMPACT ? (CUM).stack_regs * 8 : 0)
1357 /* Nonzero if we do not know how to pass TYPE solely in registers.
1358 Values that come in registers with inconvenient padding are stored
1359 to memory at the function start. */
1361 #define MUST_PASS_IN_STACK(MODE,TYPE) \
1363 && (TREE_CODE (TYPE_SIZE (TYPE)) != INTEGER_CST \
1364 || TREE_ADDRESSABLE (TYPE)))
1365 /* Some subroutine macros specific to this machine. */
1367 #define BASE_RETURN_VALUE_REG(MODE) \
1368 ((TARGET_FPU_ANY && ((MODE) == SFmode)) \
1369 ? FIRST_FP_RET_REG \
1370 : TARGET_FPU_ANY && (MODE) == SCmode \
1371 ? FIRST_FP_RET_REG \
1372 : (TARGET_FPU_DOUBLE \
1373 && ((MODE) == DFmode || (MODE) == SFmode \
1374 || (MODE) == DCmode || (MODE) == SCmode )) \
1375 ? FIRST_FP_RET_REG \
1378 #define BASE_ARG_REG(MODE) \
1379 ((TARGET_SH3E && ((MODE) == SFmode)) \
1380 ? FIRST_FP_PARM_REG \
1381 : TARGET_SH4 && (GET_MODE_CLASS (MODE) == MODE_FLOAT \
1382 || GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT)\
1383 ? FIRST_FP_PARM_REG \
1386 /* Define how to find the value returned by a function.
1387 VALTYPE is the data type of the value (as a tree).
1388 If the precise function being called is known, FUNC is its FUNCTION_DECL;
1389 otherwise, FUNC is 0.
1390 For the SH, this is like LIBCALL_VALUE, except that we must change the
1391 mode like PROMOTE_MODE does.
1392 ??? PROMOTE_MODE is ignored for non-scalar types. The set of types
1393 tested here has to be kept in sync with the one in explow.c:promote_mode. */
1395 #define FUNCTION_VALUE(VALTYPE, FUNC) \
1397 ((GET_MODE_CLASS (TYPE_MODE (VALTYPE)) == MODE_INT \
1398 && GET_MODE_SIZE (TYPE_MODE (VALTYPE)) < UNITS_PER_WORD \
1399 && (TREE_CODE (VALTYPE) == INTEGER_TYPE \
1400 || TREE_CODE (VALTYPE) == ENUMERAL_TYPE \
1401 || TREE_CODE (VALTYPE) == BOOLEAN_TYPE \
1402 || TREE_CODE (VALTYPE) == CHAR_TYPE \
1403 || TREE_CODE (VALTYPE) == REAL_TYPE \
1404 || TREE_CODE (VALTYPE) == OFFSET_TYPE)) \
1405 ? (TARGET_SHMEDIA ? DImode : SImode) : TYPE_MODE (VALTYPE)), \
1406 BASE_RETURN_VALUE_REG (TYPE_MODE (VALTYPE)))
1408 /* Define how to find the value returned by a library function
1409 assuming the value has mode MODE. */
1410 #define LIBCALL_VALUE(MODE) \
1411 gen_rtx_REG ((MODE), BASE_RETURN_VALUE_REG (MODE));
1413 /* 1 if N is a possible register number for a function value. */
1414 #define FUNCTION_VALUE_REGNO_P(REGNO) \
1415 ((REGNO) == FIRST_RET_REG || (TARGET_SH3E && (REGNO) == FIRST_FP_RET_REG) \
1416 || (TARGET_SHMEDIA_FPU && (REGNO) == FIRST_FP_RET_REG))
1418 /* 1 if N is a possible register number for function argument passing. */
1419 #define FUNCTION_ARG_REGNO_P(REGNO) \
1420 (((REGNO) >= FIRST_PARM_REG && (REGNO) < (FIRST_PARM_REG \
1421 + NPARM_REGS (SImode))) \
1422 || (TARGET_FPU_ANY \
1423 && (REGNO) >= FIRST_FP_PARM_REG && (REGNO) < (FIRST_FP_PARM_REG \
1424 + NPARM_REGS (SFmode))))
1426 /* Define a data type for recording info about an argument list
1427 during the scan of that argument list. This data type should
1428 hold all necessary information about the function itself
1429 and about the args processed so far, enough to enable macros
1430 such as FUNCTION_ARG to determine where the next arg should go.
1432 On SH, this is a single integer, which is a number of words
1433 of arguments scanned so far (including the invisible argument,
1434 if any, which holds the structure-value-address).
1435 Thus NARGREGS or more means all following args should go on the stack. */
1437 enum sh_arg_class { SH_ARG_INT = 0, SH_ARG_FLOAT = 1 };
1441 /* Non-zero if a prototype is available for the function. */
1443 /* The number of an odd floating-point register, that should be used
1444 for the next argument of type float. */
1445 int free_single_fp_reg;
1446 /* Whether we're processing an outgoing function call. */
1448 /* The number of general-purpose registers that should have been
1449 used to pass partial arguments, that are passed totally on the
1450 stack. On SHcompact, a call trampoline will pop them off the
1451 stack before calling the actual function, and, if the called
1452 function is implemented in SHcompact mode, the incoming arguments
1453 decoder will push such arguments back onto the stack. For
1454 incoming arguments, STACK_REGS also takes into account other
1455 arguments passed by reference, that the decoder will also push
1458 /* The number of general-purpose registers that should have been
1459 used to pass arguments, if the arguments didn't have to be passed
1462 /* Set by SHCOMPACT_BYREF if the current argument is to be passed by
1466 /* call_cookie is a bitmask used by call expanders, as well as
1467 function prologue and epilogues, to allow SHcompact to comply
1468 with the SH5 32-bit ABI, that requires 64-bit registers to be
1469 used even though only the lower 32-bit half is visible in
1470 SHcompact mode. The strategy is to call SHmedia trampolines.
1472 The alternatives for each of the argument-passing registers are
1473 (a) leave it unchanged; (b) pop it off the stack; (c) load its
1474 contents from the address in it; (d) add 8 to it, storing the
1475 result in the next register, then (c); (e) copy it from some
1476 floating-point register,
1478 Regarding copies from floating-point registers, r2 may only be
1479 copied from dr0. r3 may be copied from dr0 or dr2. r4 maybe
1480 copied from dr0, dr2 or dr4. r5 maybe copied from dr0, dr2,
1481 dr4 or dr6. r6 may be copied from dr0, dr2, dr4, dr6 or dr8.
1482 r7 through to r9 may be copied from dr0, dr2, dr4, dr8, dr8 or
1485 The bit mask is structured as follows:
1487 - 1 bit to tell whether to set up a return trampoline.
1489 - 3 bits to count the number consecutive registers to pop off the
1492 - 4 bits for each of r9, r8, r7 and r6.
1494 - 3 bits for each of r5, r4, r3 and r2.
1496 - 3 bits set to 0 (the most significant ones)
1499 1098 7654 3210 9876 5432 1098 7654 3210
1500 FLPF LPFL PFLP FFLP FFLP FFLP FFLP SSST
1501 2223 3344 4555 6666 7777 8888 9999 SSS-
1503 - If F is set, the register must be copied from an FP register,
1504 whose number is encoded in the remaining bits.
1506 - Else, if L is set, the register must be loaded from the address
1507 contained in it. If the P bit is *not* set, the address of the
1508 following dword should be computed first, and stored in the
1511 - Else, if P is set, the register alone should be popped off the
1514 - After all this processing, the number of registers represented
1515 in SSS will be popped off the stack. This is an optimization
1516 for pushing/popping consecutive registers, typically used for
1517 varargs and large arguments partially passed in registers.
1519 - If T is set, a return trampoline will be set up for 64-bit
1520 return values to be split into 2 32-bit registers. */
1521 #define CALL_COOKIE_RET_TRAMP_SHIFT 0
1522 #define CALL_COOKIE_RET_TRAMP(VAL) ((VAL) << CALL_COOKIE_RET_TRAMP_SHIFT)
1523 #define CALL_COOKIE_STACKSEQ_SHIFT 1
1524 #define CALL_COOKIE_STACKSEQ(VAL) ((VAL) << CALL_COOKIE_STACKSEQ_SHIFT)
1525 #define CALL_COOKIE_STACKSEQ_GET(COOKIE) \
1526 (((COOKIE) >> CALL_COOKIE_STACKSEQ_SHIFT) & 7)
1527 #define CALL_COOKIE_INT_REG_SHIFT(REG) \
1528 (4 * (7 - (REG)) + (((REG) <= 2) ? ((REG) - 2) : 1) + 3)
1529 #define CALL_COOKIE_INT_REG(REG, VAL) \
1530 ((VAL) << CALL_COOKIE_INT_REG_SHIFT (REG))
1531 #define CALL_COOKIE_INT_REG_GET(COOKIE, REG) \
1532 (((COOKIE) >> CALL_COOKIE_INT_REG_SHIFT (REG)) & ((REG) < 4 ? 7 : 15))
1536 #define CUMULATIVE_ARGS struct sh_args
1538 #define GET_SH_ARG_CLASS(MODE) \
1539 ((TARGET_FPU_ANY && (MODE) == SFmode) \
1541 /* There's no mention of complex float types in the SH5 ABI, so we
1542 should presumably handle them as aggregate types. */ \
1543 : TARGET_SH5 && GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT \
1545 : TARGET_FPU_DOUBLE && (GET_MODE_CLASS (MODE) == MODE_FLOAT \
1546 || GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT) \
1547 ? SH_ARG_FLOAT : SH_ARG_INT)
1549 #define ROUND_ADVANCE(SIZE) \
1550 (((SIZE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
1552 /* Round a register number up to a proper boundary for an arg of mode
1555 The SH doesn't care about double alignment, so we only
1556 round doubles to even regs when asked to explicitly. */
1558 #define ROUND_REG(CUM, MODE) \
1559 (((TARGET_ALIGN_DOUBLE \
1560 || (TARGET_SH4 && ((MODE) == DFmode || (MODE) == DCmode) \
1561 && (CUM).arg_count[(int) SH_ARG_FLOAT] < NPARM_REGS (MODE)))\
1562 && GET_MODE_UNIT_SIZE ((MODE)) > UNITS_PER_WORD) \
1563 ? ((CUM).arg_count[(int) GET_SH_ARG_CLASS (MODE)] \
1564 + ((CUM).arg_count[(int) GET_SH_ARG_CLASS (MODE)] & 1)) \
1565 : (CUM).arg_count[(int) GET_SH_ARG_CLASS (MODE)])
1567 /* Initialize a variable CUM of type CUMULATIVE_ARGS
1568 for a call to a function whose data type is FNTYPE.
1569 For a library call, FNTYPE is 0.
1571 On SH, the offset always starts at 0: the first parm reg is always
1572 the same reg for a given argument class.
1574 For TARGET_HITACHI, the structure value pointer is passed in memory. */
1576 #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, INDIRECT) \
1578 (CUM).arg_count[(int) SH_ARG_INT] = 0; \
1579 (CUM).arg_count[(int) SH_ARG_FLOAT] = 0; \
1581 = (TARGET_HITACHI && FNTYPE \
1582 && aggregate_value_p (TREE_TYPE (FNTYPE))); \
1583 (CUM).prototype_p = (FNTYPE) && TYPE_ARG_TYPES (FNTYPE); \
1584 (CUM).arg_count[(int) SH_ARG_INT] \
1585 = (TARGET_SH5 && (FNTYPE) \
1586 && aggregate_value_p (TREE_TYPE (FNTYPE))); \
1587 (CUM).free_single_fp_reg = 0; \
1588 (CUM).outgoing = 1; \
1589 (CUM).stack_regs = 0; \
1590 (CUM).byref_regs = 0; \
1593 = (CALL_COOKIE_RET_TRAMP \
1594 (TARGET_SHCOMPACT && (FNTYPE) \
1595 && (CUM).arg_count[(int) SH_ARG_INT] == 0 \
1596 && (TYPE_MODE (TREE_TYPE (FNTYPE)) == BLKmode \
1597 ? int_size_in_bytes (TREE_TYPE (FNTYPE)) \
1598 : GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (FNTYPE)))) > 4 \
1599 && (BASE_RETURN_VALUE_REG (TYPE_MODE (TREE_TYPE \
1601 == FIRST_RET_REG))); \
1604 #define INIT_CUMULATIVE_LIBCALL_ARGS(CUM, MODE, LIBNAME) \
1606 INIT_CUMULATIVE_ARGS ((CUM), NULL_TREE, (LIBNAME), 0); \
1608 = (CALL_COOKIE_RET_TRAMP \
1609 (TARGET_SHCOMPACT && GET_MODE_SIZE (MODE) > 4 \
1610 && BASE_RETURN_VALUE_REG (MODE) == FIRST_RET_REG)); \
1613 #define INIT_CUMULATIVE_INCOMING_ARGS(CUM, FNTYPE, LIBNAME) \
1615 INIT_CUMULATIVE_ARGS ((CUM), (FNTYPE), (LIBNAME), 0); \
1616 (CUM).outgoing = 0; \
1619 /* FIXME: This is overly conservative. A SHcompact function that
1620 receives arguments ``by reference'' will have them stored in its
1621 own stack frame, so it must not pass pointers or references to
1622 these arguments to other functions by means of sibling calls. */
1623 #define FUNCTION_OK_FOR_SIBCALL(DECL) \
1624 (! TARGET_SHCOMPACT || current_function_args_info.stack_regs == 0)
1626 /* Update the data in CUM to advance over an argument
1627 of mode MODE and data type TYPE.
1628 (TYPE is null for libcalls where that information may not be
1631 #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \
1632 if ((CUM).force_mem) \
1633 (CUM).force_mem = 0; \
1634 else if (TARGET_SH5) \
1636 tree TYPE_ = ((CUM).byref && (TYPE) \
1637 ? TREE_TYPE (TYPE) \
1639 enum machine_mode MODE_ = ((CUM).byref && (TYPE) \
1640 ? TYPE_MODE (TYPE_) \
1642 int dwords = (((CUM).byref \
1644 : (MODE_) == BLKmode \
1645 ? int_size_in_bytes (TYPE_) \
1646 : GET_MODE_SIZE (MODE_)) + 7) / 8; \
1647 int numregs = MIN (dwords, NPARM_REGS (SImode) \
1648 - (CUM).arg_count[(int) SH_ARG_INT]); \
1652 (CUM).arg_count[(int) SH_ARG_INT] += numregs; \
1653 if (TARGET_SHCOMPACT \
1654 && SHCOMPACT_FORCE_ON_STACK (MODE_, TYPE_)) \
1656 |= CALL_COOKIE_INT_REG (((CUM).arg_count[(int) SH_ARG_INT] \
1658 else if ((CUM).byref) \
1660 if (! (CUM).outgoing) \
1661 (CUM).stack_regs += numregs; \
1662 (CUM).byref_regs += numregs; \
1666 |= CALL_COOKIE_INT_REG (((CUM).arg_count[(int) SH_ARG_INT] \
1668 while (--numregs); \
1670 |= CALL_COOKIE_INT_REG (((CUM).arg_count[(int) SH_ARG_INT] \
1673 else if (dwords > numregs) \
1675 int pushregs = numregs; \
1677 if (TARGET_SHCOMPACT) \
1678 (CUM).stack_regs += numregs; \
1679 while (pushregs < NPARM_REGS (SImode) - 1 \
1680 && (CALL_COOKIE_INT_REG_GET \
1681 ((CUM).call_cookie, \
1682 NPARM_REGS (SImode) - pushregs) \
1686 &= ~ CALL_COOKIE_INT_REG (NPARM_REGS (SImode) \
1690 if (numregs == NPARM_REGS (SImode)) \
1692 |= CALL_COOKIE_INT_REG (0, 1) \
1693 | CALL_COOKIE_STACKSEQ (numregs - 1); \
1696 |= CALL_COOKIE_STACKSEQ (numregs); \
1699 if (GET_SH_ARG_CLASS (MODE_) == SH_ARG_FLOAT \
1700 && ((NAMED) || ! (CUM).prototype_p)) \
1702 if ((MODE_) == SFmode && (CUM).free_single_fp_reg) \
1703 (CUM).free_single_fp_reg = 0; \
1704 else if ((CUM).arg_count[(int) SH_ARG_FLOAT] \
1705 < NPARM_REGS (SFmode)) \
1708 = MIN ((GET_MODE_SIZE (MODE_) + 7) / 8 * 2, \
1709 NPARM_REGS (SFmode) \
1710 - (CUM).arg_count[(int) SH_ARG_FLOAT]); \
1712 (CUM).arg_count[(int) SH_ARG_FLOAT] += numfpregs; \
1714 if (TARGET_SHCOMPACT && ! (CUM).prototype_p) \
1716 if ((CUM).outgoing && numregs > 0) \
1720 |= (CALL_COOKIE_INT_REG \
1721 ((CUM).arg_count[(int) SH_ARG_INT] \
1722 - numregs + ((numfpregs - 2) / 2), \
1723 4 + ((CUM).arg_count[(int) SH_ARG_FLOAT] \
1724 - numfpregs) / 2)); \
1726 while (numfpregs -= 2); \
1728 else if ((MODE_) == SFmode && (NAMED) \
1729 && ((CUM).arg_count[(int) SH_ARG_FLOAT] \
1730 < NPARM_REGS (SFmode))) \
1731 (CUM).free_single_fp_reg \
1732 = FIRST_FP_PARM_REG - numfpregs \
1733 + (CUM).arg_count[(int) SH_ARG_FLOAT] + 1; \
1737 else if (! TARGET_SH4 || PASS_IN_REG_P ((CUM), (MODE), (TYPE))) \
1738 ((CUM).arg_count[(int) GET_SH_ARG_CLASS (MODE)] \
1739 = (ROUND_REG ((CUM), (MODE)) \
1740 + ((MODE) == BLKmode \
1741 ? ROUND_ADVANCE (int_size_in_bytes (TYPE)) \
1742 : ROUND_ADVANCE (GET_MODE_SIZE (MODE)))))
1744 /* Return boolean indicating arg of mode MODE will be passed in a reg.
1745 This macro is only used in this file. */
1747 #define PASS_IN_REG_P(CUM, MODE, TYPE) \
1749 || (! TREE_ADDRESSABLE ((tree)(TYPE)) \
1750 && (! TARGET_HITACHI || ! AGGREGATE_TYPE_P (TYPE)))) \
1751 && ! (CUM).force_mem \
1753 ? ((MODE) == BLKmode \
1754 ? (((CUM).arg_count[(int) SH_ARG_INT] * UNITS_PER_WORD \
1755 + int_size_in_bytes (TYPE)) \
1756 <= NPARM_REGS (SImode) * UNITS_PER_WORD) \
1757 : ((ROUND_REG((CUM), (MODE)) \
1758 + HARD_REGNO_NREGS (BASE_ARG_REG (MODE), (MODE))) \
1759 <= NPARM_REGS (MODE))) \
1760 : ROUND_REG ((CUM), (MODE)) < NPARM_REGS (MODE)))
1762 /* Define where to put the arguments to a function.
1763 Value is zero to push the argument on the stack,
1764 or a hard register in which to store the argument.
1766 MODE is the argument's machine mode.
1767 TYPE is the data type of the argument (as a tree).
1768 This is null for libcalls where that information may
1770 CUM is a variable of type CUMULATIVE_ARGS which gives info about
1771 the preceding args and about the function being called.
1772 NAMED is nonzero if this argument is a named parameter
1773 (otherwise it is an extra parameter matching an ellipsis).
1775 On SH the first args are normally in registers
1776 and the rest are pushed. Any arg that starts within the first
1777 NPARM_REGS words is at least partially passed in a register unless
1778 its data type forbids. */
1780 #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
1782 && PASS_IN_REG_P ((CUM), (MODE), (TYPE)) \
1784 || (! TARGET_HITACHI && (TARGET_SH3E || ! current_function_varargs)))) \
1785 ? gen_rtx_REG ((MODE), \
1786 ((BASE_ARG_REG (MODE) + ROUND_REG ((CUM), (MODE))) \
1787 ^ ((MODE) == SFmode && TARGET_SH4 \
1788 && TARGET_LITTLE_ENDIAN != 0))) \
1790 ? ((MODE) == VOIDmode && TARGET_SHCOMPACT \
1791 ? GEN_INT ((CUM).call_cookie) \
1792 /* The following test assumes unnamed arguments are promoted to \
1794 : (MODE) == SFmode && (CUM).free_single_fp_reg \
1795 ? SH5_PROTOTYPED_FLOAT_ARG ((CUM), (MODE), (CUM).free_single_fp_reg) \
1796 : (GET_SH_ARG_CLASS (MODE) == SH_ARG_FLOAT \
1797 && ((NAMED) || ! (CUM).prototype_p) \
1798 && (CUM).arg_count[(int) SH_ARG_FLOAT] < NPARM_REGS (SFmode)) \
1799 ? ((! (CUM).prototype_p && TARGET_SHMEDIA) \
1800 ? SH5_PROTOTYPELESS_FLOAT_ARG ((CUM), (MODE)) \
1801 : SH5_PROTOTYPED_FLOAT_ARG ((CUM), (MODE), \
1803 + (CUM).arg_count[(int) SH_ARG_FLOAT])) \
1804 : ((CUM).arg_count[(int) SH_ARG_INT] < NPARM_REGS (SImode) \
1805 && (! TARGET_SHCOMPACT \
1806 || (! SHCOMPACT_FORCE_ON_STACK ((MODE), (TYPE)) \
1807 && ! SH5_WOULD_BE_PARTIAL_NREGS ((CUM), (MODE), \
1808 (TYPE), (NAMED))))) \
1809 ? gen_rtx_REG ((MODE), (FIRST_PARM_REG \
1810 + (CUM).arg_count[(int) SH_ARG_INT])) \
1814 /* Whether an argument must be passed by reference. On SHcompact, we
1815 pretend arguments wider than 32-bits that would have been passed in
1816 registers are passed by reference, so that an SHmedia trampoline
1817 loads them into the full 64-bits registers. */
1818 #define FUNCTION_ARG_PASS_BY_REFERENCE(CUM,MODE,TYPE,NAMED) \
1819 (MUST_PASS_IN_STACK ((MODE), (TYPE)) \
1820 || SHCOMPACT_BYREF ((CUM), (MODE), (TYPE), (NAMED)))
1822 #define SHCOMPACT_BYREF(CUM, MODE, TYPE, NAMED) \
1824 = (TARGET_SHCOMPACT \
1825 && (CUM).arg_count[(int) SH_ARG_INT] < NPARM_REGS (SImode) \
1826 && (! (NAMED) || GET_SH_ARG_CLASS (MODE) == SH_ARG_INT \
1827 || (GET_SH_ARG_CLASS (MODE) == SH_ARG_FLOAT \
1828 && ((CUM).arg_count[(int) SH_ARG_FLOAT] \
1829 >= NPARM_REGS (SFmode)))) \
1830 && ((MODE) == BLKmode ? int_size_in_bytes (TYPE) \
1831 : GET_MODE_SIZE (MODE)) > 4 \
1832 && ! SHCOMPACT_FORCE_ON_STACK ((MODE), (TYPE)) \
1833 && ! SH5_WOULD_BE_PARTIAL_NREGS ((CUM), (MODE), \
1835 ? ((MODE) == BLKmode ? int_size_in_bytes (TYPE) \
1836 : GET_MODE_SIZE (MODE)) \
1839 /* If an argument of size 5, 6 or 7 bytes is to be passed in a 64-bit
1840 register in SHcompact mode, it must be padded in the most
1841 significant end. This means that passing it by reference wouldn't
1842 pad properly on a big-endian machine. In this particular case, we
1843 pass this argument on the stack, in a way that the call trampoline
1844 will load its value into the appropriate register. */
1845 #define SHCOMPACT_FORCE_ON_STACK(MODE,TYPE) \
1846 ((MODE) == BLKmode \
1847 && TARGET_SHCOMPACT \
1848 && ! TARGET_LITTLE_ENDIAN \
1849 && int_size_in_bytes (TYPE) > 4 \
1850 && int_size_in_bytes (TYPE) < 8)
1852 /* Minimum alignment for an argument to be passed by callee-copy
1853 reference. We need such arguments to be aligned to 8 byte
1854 boundaries, because they'll be loaded using quad loads. */
1855 #define SH_MIN_ALIGN_FOR_CALLEE_COPY (8 * BITS_PER_UNIT)
1857 #define FUNCTION_ARG_CALLEE_COPIES(CUM,MODE,TYPE,NAMED) \
1859 && (((MODE) == BLKmode ? TYPE_ALIGN (TYPE) \
1860 : GET_MODE_ALIGNMENT (MODE)) \
1861 % SH_MIN_ALIGN_FOR_CALLEE_COPY == 0))
1863 /* The SH5 ABI requires floating-point arguments to be passed to
1864 functions without a prototype in both an FP register and a regular
1865 register or the stack. When passing the argument in both FP and
1866 general-purpose registers, list the FP register first. */
1867 #define SH5_PROTOTYPELESS_FLOAT_ARG(CUM,MODE) \
1873 ((CUM).arg_count[(int) SH_ARG_INT] < NPARM_REGS (SImode) \
1874 ? gen_rtx_REG ((MODE), FIRST_FP_PARM_REG \
1875 + (CUM).arg_count[(int) SH_ARG_FLOAT]) \
1880 ((CUM).arg_count[(int) SH_ARG_INT] < NPARM_REGS (SImode) \
1881 ? gen_rtx_REG ((MODE), FIRST_PARM_REG \
1882 + (CUM).arg_count[(int) SH_ARG_INT]) \
1883 : gen_rtx_REG ((MODE), FIRST_FP_PARM_REG \
1884 + (CUM).arg_count[(int) SH_ARG_FLOAT])), \
1887 /* The SH5 ABI requires regular registers or stack slots to be
1888 reserved for floating-point arguments. Registers are taken care of
1889 in FUNCTION_ARG_ADVANCE, but stack slots must be reserved here.
1890 Unfortunately, there's no way to just reserve a stack slot, so
1891 we'll end up needlessly storing a copy of the argument in the
1892 stack. For incoming arguments, however, the PARALLEL will be
1893 optimized to the register-only form, and the value in the stack
1894 slot won't be used at all. */
1895 #define SH5_PROTOTYPED_FLOAT_ARG(CUM,MODE,REG) \
1896 ((CUM).arg_count[(int) SH_ARG_INT] < NPARM_REGS (SImode) \
1897 ? gen_rtx_REG ((MODE), (REG)) \
1898 : gen_rtx_PARALLEL ((MODE), \
1901 (VOIDmode, NULL_RTX, \
1904 (VOIDmode, gen_rtx_REG ((MODE), \
1908 #define STRICT_ARGUMENT_NAMING TARGET_SH5
1910 #define PRETEND_OUTGOING_VARARGS_NAMED (! TARGET_HITACHI && ! TARGET_SH5)
1912 /* For an arg passed partly in registers and partly in memory,
1913 this is the number of registers used.
1914 For args passed entirely in registers or entirely in memory, zero.
1916 We sometimes split args. */
1918 #define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) \
1920 && PASS_IN_REG_P ((CUM), (MODE), (TYPE)) \
1922 && (ROUND_REG ((CUM), (MODE)) \
1923 + ((MODE) != BLKmode \
1924 ? ROUND_ADVANCE (GET_MODE_SIZE (MODE)) \
1925 : ROUND_ADVANCE (int_size_in_bytes (TYPE))) \
1926 > NPARM_REGS (MODE))) \
1927 ? NPARM_REGS (MODE) - ROUND_REG ((CUM), (MODE)) \
1928 : (SH5_WOULD_BE_PARTIAL_NREGS ((CUM), (MODE), (TYPE), (NAMED)) \
1929 && ! TARGET_SHCOMPACT) \
1930 ? NPARM_REGS (SImode) - (CUM).arg_count[(int) SH_ARG_INT] \
1933 #define SH5_WOULD_BE_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) \
1934 (TARGET_SH5 && (MODE) == BLKmode \
1935 && ((CUM).arg_count[(int) SH_ARG_INT] \
1936 + (int_size_in_bytes (TYPE) + 7) / 8) > NPARM_REGS (SImode))
1938 /* Perform any needed actions needed for a function that is receiving a
1939 variable number of arguments. */
1941 /* We actually emit the code in sh_expand_prologue. We used to use
1942 a static variable to flag that we need to emit this code, but that
1943 doesn't when inlining, when functions are deferred and then emitted
1944 later. Fortunately, we already have two flags that are part of struct
1945 function that tell if a function uses varargs or stdarg. */
1946 #define SETUP_INCOMING_VARARGS(ASF, MODE, TYPE, PAS, ST) do \
1947 if (! current_function_varargs && ! current_function_stdarg) \
1951 /* Define the `__builtin_va_list' type for the ABI. */
1952 #define BUILD_VA_LIST_TYPE(VALIST) \
1953 (VALIST) = sh_build_va_list ()
1955 /* Implement `va_start' for varargs and stdarg. */
1956 #define EXPAND_BUILTIN_VA_START(stdarg, valist, nextarg) \
1957 sh_va_start (stdarg, valist, nextarg)
1959 /* Implement `va_arg'. */
1960 #define EXPAND_BUILTIN_VA_ARG(valist, type) \
1961 sh_va_arg (valist, type)
1963 /* Call the function profiler with a given profile label.
1964 We use two .aligns, so as to make sure that both the .long is aligned
1965 on a 4 byte boundary, and that the .long is a fixed distance (2 bytes)
1966 from the trapa instruction. */
1968 #define FUNCTION_PROFILER(STREAM,LABELNO) \
1970 fprintf((STREAM), "\t.align\t2\n"); \
1971 fprintf((STREAM), "\ttrapa\t#33\n"); \
1972 fprintf((STREAM), "\t.align\t2\n"); \
1973 asm_fprintf((STREAM), "\t.long\t%LLP%d\n", (LABELNO)); \
1976 /* Define this macro if the code for function profiling should come
1977 before the function prologue. Normally, the profiling code comes
1980 #define PROFILE_BEFORE_PROLOGUE
1982 /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
1983 the stack pointer does not matter. The value is tested only in
1984 functions that have frame pointers.
1985 No definition is equivalent to always zero. */
1987 #define EXIT_IGNORE_STACK 1
1990 On the SH, the trampoline looks like
1991 2 0002 D202 mov.l l2,r2
1992 1 0000 D301 mov.l l1,r3
1995 5 0008 00000000 l1: .long area
1996 6 000c 00000000 l2: .long function */
1998 /* Length in units of the trampoline for entering a nested function. */
1999 #define TRAMPOLINE_SIZE (TARGET_SHMEDIA64 ? 40 : TARGET_SH5 ? 32 : 16)
2001 /* Alignment required for a trampoline in bits . */
2002 #define TRAMPOLINE_ALIGNMENT \
2003 ((CACHE_LOG < 3 || (TARGET_SMALLCODE && ! TARGET_HARVARD)) ? 32 : 64)
2005 /* Emit RTL insns to initialize the variable parts of a trampoline.
2006 FNADDR is an RTX for the address of the function's pure code.
2007 CXT is an RTX for the static chain value for the function. */
2009 #define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) do \
2013 rtx tramp_templ = gen_rtx_SYMBOL_REF (Pmode, \
2014 "__GCC_nested_trampoline"); \
2015 int fixed_len = TRAMPOLINE_SIZE - 2 * GET_MODE_SIZE (Pmode); \
2017 tramp_templ = gen_datalabel_ref (tramp_templ); \
2018 emit_block_move (gen_rtx_MEM (BLKmode, (TRAMP)), \
2019 gen_rtx_MEM (BLKmode, tramp_templ), \
2020 GEN_INT (fixed_len)); \
2021 emit_move_insn (gen_rtx_MEM (Pmode, plus_constant ((TRAMP), \
2024 emit_move_insn (gen_rtx_MEM (Pmode, \
2025 plus_constant ((TRAMP), \
2027 + GET_MODE_SIZE (Pmode))), \
2029 emit_insn (gen_ic_invalidate_line (TRAMP)); \
2032 emit_move_insn (gen_rtx_MEM (SImode, (TRAMP)), \
2033 GEN_INT (trunc_int_for_mode \
2034 (TARGET_LITTLE_ENDIAN ? 0xd301d202 : 0xd202d301,\
2036 emit_move_insn (gen_rtx_MEM (SImode, plus_constant ((TRAMP), 4)), \
2037 GEN_INT (TARGET_LITTLE_ENDIAN ? 0x0009422b : 0x422b0009));\
2038 emit_move_insn (gen_rtx_MEM (SImode, plus_constant ((TRAMP), 8)), \
2040 emit_move_insn (gen_rtx_MEM (SImode, plus_constant ((TRAMP), 12)), \
2042 if (TARGET_HARVARD) \
2044 if (TARGET_USERMODE) \
2045 emit_library_call (gen_rtx_SYMBOL_REF (Pmode, "__ic_invalidate"),\
2046 0, VOIDmode, 1, (TRAMP), SImode); \
2048 emit_insn (gen_ic_invalidate_line (TRAMP)); \
2052 /* On SH5, trampolines are SHmedia code, so add 1 to the address. */
2054 #define TRAMPOLINE_ADJUST_ADDRESS(TRAMP) do \
2057 (TRAMP) = expand_simple_binop (Pmode, PLUS, (TRAMP), GEN_INT (1), \
2058 gen_reg_rtx (Pmode), 0, \
2062 /* A C expression whose value is RTL representing the value of the return
2063 address for the frame COUNT steps up from the current frame.
2064 FRAMEADDR is already the frame pointer of the COUNT frame, so we
2065 can ignore COUNT. */
2067 #define RETURN_ADDR_RTX(COUNT, FRAME) \
2069 ? get_hard_reg_initial_val (Pmode, PR_REG) \
2072 /* Generate necessary RTL for __builtin_saveregs(). */
2073 #define EXPAND_BUILTIN_SAVEREGS() sh_builtin_saveregs ()
2075 /* Addressing modes, and classification of registers for them. */
2076 #define HAVE_POST_INCREMENT TARGET_SH1
2077 /*#define HAVE_PRE_INCREMENT 1*/
2078 /*#define HAVE_POST_DECREMENT 1*/
2079 #define HAVE_PRE_DECREMENT TARGET_SH1
2081 #define USE_LOAD_POST_INCREMENT(mode) ((mode == SImode || mode == DImode) \
2083 #define USE_LOAD_PRE_DECREMENT(mode) 0
2084 #define USE_STORE_POST_INCREMENT(mode) 0
2085 #define USE_STORE_PRE_DECREMENT(mode) ((mode == SImode || mode == DImode) \
2088 #define MOVE_BY_PIECES_P(SIZE, ALIGN) (move_by_pieces_ninsns (SIZE, ALIGN) \
2089 < (TARGET_SMALLCODE ? 2 : \
2090 ((ALIGN >= 32) ? 16 : 2)))
2092 /* Macros to check register numbers against specific register classes. */
2094 /* These assume that REGNO is a hard or pseudo reg number.
2095 They give nonzero only if REGNO is a hard reg of the suitable class
2096 or a pseudo reg currently allocated to a suitable hard reg.
2097 Since they use reg_renumber, they are safe only once reg_renumber
2098 has been allocated, which happens in local-alloc.c. */
2100 #define REGNO_OK_FOR_BASE_P(REGNO) \
2101 (GENERAL_OR_AP_REGISTER_P (REGNO) \
2102 || GENERAL_OR_AP_REGISTER_P (reg_renumber[(REGNO)]))
2103 #define REGNO_OK_FOR_INDEX_P(REGNO) \
2105 ? (GENERAL_REGISTER_P (REGNO) \
2106 || GENERAL_REGISTER_P ((unsigned) reg_renumber[(REGNO)])) \
2107 : (REGNO) == R0_REG || (unsigned) reg_renumber[(REGNO)] == R0_REG)
2109 /* Maximum number of registers that can appear in a valid memory
2112 #define MAX_REGS_PER_ADDRESS 2
2114 /* Recognize any constant value that is a valid address. */
2116 #define CONSTANT_ADDRESS_P(X) (GET_CODE (X) == LABEL_REF)
2118 /* Nonzero if the constant value X is a legitimate general operand. */
2120 #define LEGITIMATE_CONSTANT_P(X) \
2122 ? (GET_MODE (X) != DFmode \
2123 || (X) == CONST0_RTX (GET_MODE (X)) \
2124 || ! TARGET_SHMEDIA_FPU \
2125 || TARGET_SHMEDIA64) \
2126 : (GET_CODE (X) != CONST_DOUBLE \
2127 || GET_MODE (X) == DFmode || GET_MODE (X) == SFmode \
2128 || (TARGET_SH3E && (fp_zero_operand (X) || fp_one_operand (X)))))
2130 /* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
2131 and check its validity for a certain class.
2132 We have two alternate definitions for each of them.
2133 The usual definition accepts all pseudo regs; the other rejects
2134 them unless they have been allocated suitable hard regs.
2135 The symbol REG_OK_STRICT causes the latter definition to be used. */
2137 #ifndef REG_OK_STRICT
2139 /* Nonzero if X is a hard reg that can be used as a base reg
2140 or if it is a pseudo reg. */
2141 #define REG_OK_FOR_BASE_P(X) \
2142 (GENERAL_OR_AP_REGISTER_P (REGNO (X)) || REGNO (X) >= FIRST_PSEUDO_REGISTER)
2144 /* Nonzero if X is a hard reg that can be used as an index
2145 or if it is a pseudo reg. */
2146 #define REG_OK_FOR_INDEX_P(X) \
2147 ((TARGET_SHMEDIA ? GENERAL_REGISTER_P (REGNO (X)) \
2148 : REGNO (X) == R0_REG) || REGNO (X) >= FIRST_PSEUDO_REGISTER)
2150 /* Nonzero if X/OFFSET is a hard reg that can be used as an index
2151 or if X is a pseudo reg. */
2152 #define SUBREG_OK_FOR_INDEX_P(X, OFFSET) \
2153 ((TARGET_SHMEDIA ? GENERAL_REGISTER_P (REGNO (X)) \
2154 : REGNO (X) == R0_REG && OFFSET == 0) || REGNO (X) >= FIRST_PSEUDO_REGISTER)
2158 /* Nonzero if X is a hard reg that can be used as a base reg. */
2159 #define REG_OK_FOR_BASE_P(X) \
2160 REGNO_OK_FOR_BASE_P (REGNO (X))
2162 /* Nonzero if X is a hard reg that can be used as an index. */
2163 #define REG_OK_FOR_INDEX_P(X) \
2164 REGNO_OK_FOR_INDEX_P (REGNO (X))
2166 /* Nonzero if X/OFFSET is a hard reg that can be used as an index. */
2167 #define SUBREG_OK_FOR_INDEX_P(X, OFFSET) \
2168 (REGNO_OK_FOR_INDEX_P (REGNO (X)) && (OFFSET) == 0)
2172 /* The 'Q' constraint is a pc relative load operand. */
2173 #define EXTRA_CONSTRAINT_Q(OP) \
2174 (GET_CODE (OP) == MEM \
2175 && ((GET_CODE (XEXP ((OP), 0)) == LABEL_REF) \
2176 || (GET_CODE (XEXP ((OP), 0)) == CONST \
2177 && GET_CODE (XEXP (XEXP ((OP), 0), 0)) == PLUS \
2178 && GET_CODE (XEXP (XEXP (XEXP ((OP), 0), 0), 0)) == LABEL_REF \
2179 && GET_CODE (XEXP (XEXP (XEXP ((OP), 0), 0), 1)) == CONST_INT)))
2181 /* The `S' constraint is a 16-bit constant, literal or symbolic. */
2182 #define EXTRA_CONSTRAINT_S(OP) \
2183 (GET_CODE (OP) == CONST \
2184 && GET_CODE (XEXP ((OP), 0)) == SIGN_EXTEND \
2185 && GET_MODE (XEXP ((OP), 0)) == DImode \
2186 && GET_CODE (XEXP (XEXP ((OP), 0), 0)) == TRUNCATE \
2187 && GET_MODE (XEXP (XEXP ((OP), 0), 0)) == HImode \
2188 && (MOVI_SHORI_BASE_OPERAND_P (XEXP (XEXP (XEXP ((OP), 0), 0), 0)) \
2189 || (GET_CODE (XEXP (XEXP (XEXP ((OP), 0), 0), 0)) == ASHIFTRT \
2190 && (MOVI_SHORI_BASE_OPERAND_P \
2191 (XEXP (XEXP (XEXP (XEXP ((OP), 0), 0), 0), 0))) \
2192 && GET_CODE (XEXP (XEXP (XEXP (XEXP ((OP), 0), 0), 0), \
2195 /* Check whether OP is a datalabel unspec. */
2196 #define DATALABEL_REF_NO_CONST_P(OP) \
2197 (GET_CODE (OP) == UNSPEC \
2198 && XINT ((OP), 1) == UNSPEC_DATALABEL \
2199 && XVECLEN ((OP), 0) == 1 \
2200 && (GET_CODE (XVECEXP ((OP), 0, 0)) == SYMBOL_REF \
2201 || GET_CODE (XVECEXP ((OP), 0, 0)) == LABEL_REF))
2203 /* Check whether OP is a datalabel unspec, possibly enclosed within a
2205 #define DATALABEL_REF_P(OP) \
2206 ((GET_CODE (OP) == CONST && DATALABEL_REF_NO_CONST_P (XEXP ((OP), 0))) \
2207 || DATALABEL_REF_NO_CONST_P (OP))
2209 #define GOT_ENTRY_P(OP) \
2210 (GET_CODE (OP) == CONST && GET_CODE (XEXP ((OP), 0)) == UNSPEC \
2211 && XINT (XEXP ((OP), 0), 1) == UNSPEC_GOT)
2213 #define GOTPLT_ENTRY_P(OP) \
2214 (GET_CODE (OP) == CONST && GET_CODE (XEXP ((OP), 0)) == UNSPEC \
2215 && XINT (XEXP ((OP), 0), 1) == UNSPEC_GOTPLT)
2217 #define GOTOFF_P(OP) \
2218 (GET_CODE (OP) == CONST && GET_CODE (XEXP ((OP), 0)) == UNSPEC \
2219 && XINT (XEXP ((OP), 0), 1) == UNSPEC_GOTOFF)
2221 #define PIC_ADDR_P(OP) \
2222 (GET_CODE (OP) == CONST && GET_CODE (XEXP ((OP), 0)) == UNSPEC \
2223 && XINT (XEXP ((OP), 0), 1) == UNSPEC_PIC)
2225 #define NON_PIC_REFERENCE_P(OP) \
2226 (GET_CODE (OP) == LABEL_REF || GET_CODE (OP) == SYMBOL_REF \
2227 || DATALABEL_REF_P (OP) \
2228 || (GET_CODE (OP) == CONST && GET_CODE (XEXP ((OP), 0)) == PLUS \
2229 && (GET_CODE (XEXP (XEXP ((OP), 0), 0)) == SYMBOL_REF \
2230 || DATALABEL_REF_P (XEXP (XEXP ((OP), 0), 0))) \
2231 && GET_CODE (XEXP (XEXP ((OP), 0), 1)) == CONST_INT))
2233 #define PIC_REFERENCE_P(OP) \
2234 (GOT_ENTRY_P (OP) || GOTPLT_ENTRY_P (OP) \
2235 || GOTOFF_P (OP) || PIC_ADDR_P (OP))
2237 #define MOVI_SHORI_BASE_OPERAND_P(OP) \
2238 (flag_pic ? PIC_REFERENCE_P (OP) : NON_PIC_REFERENCE_P (OP))
2240 /* The `T' constraint is a label or a symbol. */
2241 #define EXTRA_CONSTRAINT_T(OP) \
2242 (NON_PIC_REFERENCE_P (OP))
2244 #define EXTRA_CONSTRAINT(OP, C) \
2245 ((C) == 'Q' ? EXTRA_CONSTRAINT_Q (OP) \
2246 : (C) == 'S' ? EXTRA_CONSTRAINT_S (OP) \
2247 : (C) == 'T' ? EXTRA_CONSTRAINT_T (OP) \
2250 /* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression
2251 that is a valid memory address for an instruction.
2252 The MODE argument is the machine mode for the MEM expression
2253 that wants to use this address. */
2255 #define MODE_DISP_OK_4(X,MODE) \
2256 (GET_MODE_SIZE (MODE) == 4 && (unsigned) INTVAL (X) < 64 \
2257 && ! (INTVAL (X) & 3) && ! (TARGET_SH3E && (MODE) == SFmode))
2259 #define MODE_DISP_OK_8(X,MODE) \
2260 ((GET_MODE_SIZE(MODE)==8) && ((unsigned)INTVAL(X)<60) \
2261 && ! (INTVAL(X) & 3) && ! (TARGET_SH4 && (MODE) == DFmode))
2263 #define BASE_REGISTER_RTX_P(X) \
2264 ((GET_CODE (X) == REG && REG_OK_FOR_BASE_P (X)) \
2265 || (GET_CODE (X) == SUBREG \
2266 && GET_CODE (SUBREG_REG (X)) == REG \
2267 && REG_OK_FOR_BASE_P (SUBREG_REG (X))))
2269 /* Since this must be r0, which is a single register class, we must check
2270 SUBREGs more carefully, to be sure that we don't accept one that extends
2271 outside the class. */
2272 #define INDEX_REGISTER_RTX_P(X) \
2273 ((GET_CODE (X) == REG && REG_OK_FOR_INDEX_P (X)) \
2274 || (GET_CODE (X) == SUBREG \
2275 && GET_CODE (SUBREG_REG (X)) == REG \
2276 && SUBREG_OK_FOR_INDEX_P (SUBREG_REG (X), SUBREG_BYTE (X))))
2278 /* Jump to LABEL if X is a valid address RTX. This must also take
2279 REG_OK_STRICT into account when deciding about valid registers, but it uses
2280 the above macros so we are in luck.
2288 /* ??? The SH3e does not have the REG+disp addressing mode when loading values
2289 into the FRx registers. We implement this by setting the maximum offset
2290 to zero when the value is SFmode. This also restricts loading of SFmode
2291 values into the integer registers, but that can't be helped. */
2293 /* The SH allows a displacement in a QI or HI amode, but only when the
2294 other operand is R0. GCC doesn't handle this very well, so we forgo
2297 A legitimate index for a QI or HI is 0, SI can be any number 0..63,
2298 DI can be any number 0..60. */
2300 #define GO_IF_LEGITIMATE_INDEX(MODE, OP, LABEL) \
2302 if (GET_CODE (OP) == CONST_INT) \
2304 if (TARGET_SHMEDIA) \
2306 int MODE_SIZE = GET_MODE_SIZE (MODE); \
2307 if (! (INTVAL (OP) & (MODE_SIZE - 1)) \
2308 && INTVAL (OP) >= -512 * MODE_SIZE \
2309 && INTVAL (OP) < 512 * MODE_SIZE) \
2314 if (MODE_DISP_OK_4 ((OP), (MODE))) goto LABEL; \
2315 if (MODE_DISP_OK_8 ((OP), (MODE))) goto LABEL; \
2319 #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, LABEL) \
2321 if (BASE_REGISTER_RTX_P (X)) \
2323 else if ((GET_CODE (X) == POST_INC || GET_CODE (X) == PRE_DEC) \
2324 && ! TARGET_SHMEDIA \
2325 && BASE_REGISTER_RTX_P (XEXP ((X), 0))) \
2327 else if (GET_CODE (X) == PLUS \
2328 && ((MODE) != PSImode || reload_completed)) \
2330 rtx xop0 = XEXP ((X), 0); \
2331 rtx xop1 = XEXP ((X), 1); \
2332 if (GET_MODE_SIZE (MODE) <= 8 && BASE_REGISTER_RTX_P (xop0)) \
2333 GO_IF_LEGITIMATE_INDEX ((MODE), xop1, LABEL); \
2334 if (GET_MODE_SIZE (MODE) <= 4 \
2335 || (TARGET_SHMEDIA && GET_MODE_SIZE (MODE) <= 8) \
2336 || (TARGET_SH4 && TARGET_FMOVD && MODE == DFmode)) \
2338 if (BASE_REGISTER_RTX_P (xop1) && INDEX_REGISTER_RTX_P (xop0))\
2340 if (INDEX_REGISTER_RTX_P (xop1) && BASE_REGISTER_RTX_P (xop0))\
2346 /* Try machine-dependent ways of modifying an illegitimate address
2347 to be legitimate. If we find one, return the new, valid address.
2348 This macro is used in only one place: `memory_address' in explow.c.
2350 OLDX is the address as it was before break_out_memory_refs was called.
2351 In some cases it is useful to look at this to decide what needs to be done.
2353 MODE and WIN are passed so that this macro can use
2354 GO_IF_LEGITIMATE_ADDRESS.
2356 It is always safe for this macro to do nothing. It exists to recognize
2357 opportunities to optimize the output.
2359 For the SH, if X is almost suitable for indexing, but the offset is
2360 out of range, convert it into a normal form so that cse has a chance
2361 of reducing the number of address registers used. */
2363 #define LEGITIMIZE_ADDRESS(X,OLDX,MODE,WIN) \
2366 (X) = legitimize_pic_address (OLDX, MODE, NULL_RTX); \
2367 if (GET_CODE (X) == PLUS \
2368 && (GET_MODE_SIZE (MODE) == 4 \
2369 || GET_MODE_SIZE (MODE) == 8) \
2370 && GET_CODE (XEXP ((X), 1)) == CONST_INT \
2371 && BASE_REGISTER_RTX_P (XEXP ((X), 0)) \
2372 && ! TARGET_SHMEDIA \
2373 && ! (TARGET_SH4 && (MODE) == DFmode) \
2374 && ! (TARGET_SH3E && (MODE) == SFmode)) \
2376 rtx index_rtx = XEXP ((X), 1); \
2377 HOST_WIDE_INT offset = INTVAL (index_rtx), offset_base; \
2380 GO_IF_LEGITIMATE_INDEX ((MODE), index_rtx, WIN); \
2381 /* On rare occasions, we might get an unaligned pointer \
2382 that is indexed in a way to give an aligned address. \
2383 Therefore, keep the lower two bits in offset_base. */ \
2384 /* Instead of offset_base 128..131 use 124..127, so that \
2385 simple add suffices. */ \
2388 offset_base = ((offset + 4) & ~60) - 4; \
2391 offset_base = offset & ~60; \
2392 /* Sometimes the normal form does not suit DImode. We \
2393 could avoid that by using smaller ranges, but that \
2394 would give less optimized code when SImode is \
2396 if (GET_MODE_SIZE (MODE) + offset - offset_base <= 64) \
2398 sum = expand_binop (Pmode, add_optab, XEXP ((X), 0), \
2399 GEN_INT (offset_base), NULL_RTX, 0, \
2402 (X) = gen_rtx_PLUS (Pmode, sum, GEN_INT (offset - offset_base)); \
2408 /* A C compound statement that attempts to replace X, which is an address
2409 that needs reloading, with a valid memory address for an operand of
2410 mode MODE. WIN is a C statement label elsewhere in the code.
2412 Like for LEGITIMIZE_ADDRESS, for the SH we try to get a normal form
2413 of the address. That will allow inheritance of the address reloads. */
2415 #define LEGITIMIZE_RELOAD_ADDRESS(X,MODE,OPNUM,TYPE,IND_LEVELS,WIN) \
2417 if (GET_CODE (X) == PLUS \
2418 && (GET_MODE_SIZE (MODE) == 4 || GET_MODE_SIZE (MODE) == 8) \
2419 && GET_CODE (XEXP (X, 1)) == CONST_INT \
2420 && BASE_REGISTER_RTX_P (XEXP (X, 0)) \
2421 && ! TARGET_SHMEDIA \
2422 && ! (TARGET_SH4 && (MODE) == DFmode) \
2423 && ! ((MODE) == PSImode && (TYPE) == RELOAD_FOR_INPUT_ADDRESS)) \
2425 rtx index_rtx = XEXP (X, 1); \
2426 HOST_WIDE_INT offset = INTVAL (index_rtx), offset_base; \
2429 if (TARGET_SH3E && MODE == SFmode) \
2432 push_reload (index_rtx, NULL_RTX, &XEXP (X, 1), NULL, \
2433 INDEX_REG_CLASS, Pmode, VOIDmode, 0, 0, (OPNUM), \
2437 /* Instead of offset_base 128..131 use 124..127, so that \
2438 simple add suffices. */ \
2441 offset_base = ((offset + 4) & ~60) - 4; \
2444 offset_base = offset & ~60; \
2445 /* Sometimes the normal form does not suit DImode. We \
2446 could avoid that by using smaller ranges, but that \
2447 would give less optimized code when SImode is \
2449 if (GET_MODE_SIZE (MODE) + offset - offset_base <= 64) \
2451 sum = gen_rtx (PLUS, Pmode, XEXP (X, 0), \
2452 GEN_INT (offset_base)); \
2453 X = gen_rtx (PLUS, Pmode, sum, GEN_INT (offset - offset_base));\
2454 push_reload (sum, NULL_RTX, &XEXP (X, 0), NULL, \
2455 BASE_REG_CLASS, Pmode, VOIDmode, 0, 0, (OPNUM), \
2460 /* We must re-recognize what we created before. */ \
2461 else if (GET_CODE (X) == PLUS \
2462 && (GET_MODE_SIZE (MODE) == 4 || GET_MODE_SIZE (MODE) == 8) \
2463 && GET_CODE (XEXP (X, 0)) == PLUS \
2464 && GET_CODE (XEXP (XEXP (X, 0), 1)) == CONST_INT \
2465 && BASE_REGISTER_RTX_P (XEXP (XEXP (X, 0), 0)) \
2466 && GET_CODE (XEXP (X, 1)) == CONST_INT \
2467 && ! TARGET_SHMEDIA \
2468 && ! (TARGET_SH3E && MODE == SFmode)) \
2470 /* Because this address is so complex, we know it must have \
2471 been created by LEGITIMIZE_RELOAD_ADDRESS before; thus, \
2472 it is already unshared, and needs no further unsharing. */ \
2473 push_reload (XEXP ((X), 0), NULL_RTX, &XEXP ((X), 0), NULL, \
2474 BASE_REG_CLASS, Pmode, VOIDmode, 0, 0, (OPNUM), (TYPE));\
2479 /* Go to LABEL if ADDR (a legitimate address expression)
2480 has an effect that depends on the machine mode it is used for.
2482 ??? Strictly speaking, we should also include all indexed addressing,
2483 because the index scale factor is the length of the operand.
2484 However, the impact of GO_IF_MODE_DEPENDENT_ADDRESS would be to
2485 high if we did that. So we rely on reload to fix things up. */
2487 #define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR,LABEL) \
2489 if (GET_CODE(ADDR) == PRE_DEC || GET_CODE(ADDR) == POST_INC) \
2493 /* Specify the machine mode that this machine uses
2494 for the index in the tablejump instruction. */
2495 #define CASE_VECTOR_MODE (TARGET_BIGTABLE ? SImode : HImode)
2497 #define CASE_VECTOR_SHORTEN_MODE(MIN_OFFSET, MAX_OFFSET, BODY) \
2498 ((MIN_OFFSET) >= 0 && (MAX_OFFSET) <= 127 \
2499 ? (ADDR_DIFF_VEC_FLAGS (BODY).offset_unsigned = 0, QImode) \
2500 : (MIN_OFFSET) >= 0 && (MAX_OFFSET) <= 255 \
2501 ? (ADDR_DIFF_VEC_FLAGS (BODY).offset_unsigned = 1, QImode) \
2502 : (MIN_OFFSET) >= -32768 && (MAX_OFFSET) <= 32767 ? HImode \
2505 /* Define as C expression which evaluates to nonzero if the tablejump
2506 instruction expects the table to contain offsets from the address of the
2508 Do not define this if the table should contain absolute addresses. */
2509 #define CASE_VECTOR_PC_RELATIVE 1
2511 /* Define it here, so that it doesn't get bumped to 64-bits on SHmedia. */
2512 #define FLOAT_TYPE_SIZE 32
2514 /* Since the SH3e has only `float' support, it is desirable to make all
2515 floating point types equivalent to `float'. */
2516 #define DOUBLE_TYPE_SIZE ((TARGET_SH3E && ! TARGET_SH4) ? 32 : 64)
2518 /* 'char' is signed by default. */
2519 #define DEFAULT_SIGNED_CHAR 1
2521 /* We -Define SIZE_TYPE in CPP_SPEC. */
2522 #define NO_BUILTIN_SIZE_TYPE 1
2524 /* The type of size_t unsigned int. */
2525 #define SIZE_TYPE (TARGET_SH5 ? "long unsigned int" : "unsigned int")
2527 #define NO_BUILTIN_PTRDIFF_TYPE 1
2530 #define PTRDIFF_TYPE (TARGET_SH5 ? "long int" : "int")
2532 #define WCHAR_TYPE "short unsigned int"
2533 #define WCHAR_TYPE_SIZE 16
2535 /* Don't cse the address of the function being compiled. */
2536 /*#define NO_RECURSIVE_FUNCTION_CSE 1*/
2538 /* Max number of bytes we can move from memory to memory
2539 in one reasonably fast instruction. */
2540 #define MOVE_MAX (TARGET_SHMEDIA ? 8 : 4)
2542 /* Maximum value possibly taken by MOVE_MAX. Must be defined whenever
2543 MOVE_MAX is not a compile-time constant. */
2544 #define MAX_MOVE_MAX 8
2546 /* Max number of bytes we want move_by_pieces to be able to copy
2548 #define MOVE_MAX_PIECES (TARGET_SH4 || TARGET_SHMEDIA ? 8 : 4)
2550 /* Define if operations between registers always perform the operation
2551 on the full register even if a narrower mode is specified. */
2552 #define WORD_REGISTER_OPERATIONS
2554 /* Define if loading in MODE, an integral mode narrower than BITS_PER_WORD
2555 will either zero-extend or sign-extend. The value of this macro should
2556 be the code that says which one of the two operations is implicitly
2557 done, NIL if none. */
2558 #define LOAD_EXTEND_OP(MODE) SIGN_EXTEND
2560 /* Define if loading short immediate values into registers sign extends. */
2561 #define SHORT_IMMEDIATES_SIGN_EXTEND
2563 /* Nonzero if access to memory by bytes is no faster than for words. */
2564 #define SLOW_BYTE_ACCESS 1
2566 /* We assume that the store-condition-codes instructions store 0 for false
2567 and some other value for true. This is the value stored for true. */
2569 #define STORE_FLAG_VALUE 1
2571 /* Immediate shift counts are truncated by the output routines (or was it
2572 the assembler?). Shift counts in a register are truncated by SH. Note
2573 that the native compiler puts too large (> 32) immediate shift counts
2574 into a register and shifts by the register, letting the SH decide what
2575 to do instead of doing that itself. */
2576 /* ??? The library routines in lib1funcs.asm truncate the shift count.
2577 However, the SH3 has hardware shifts that do not truncate exactly as gcc
2578 expects - the sign bit is significant - so it appears that we need to
2579 leave this zero for correct SH3 code. */
2580 #define SHIFT_COUNT_TRUNCATED (! TARGET_SH3)
2582 /* All integers have the same format so truncation is easy. */
2583 #define TRULY_NOOP_TRUNCATION(OUTPREC,INPREC) 1
2585 /* Define this if addresses of constant functions
2586 shouldn't be put through pseudo regs where they can be cse'd.
2587 Desirable on machines where ordinary constants are expensive
2588 but a CALL with constant address is cheap. */
2589 /*#define NO_FUNCTION_CSE 1*/
2591 /* Chars and shorts should be passed as ints. */
2592 #define PROMOTE_PROTOTYPES 1
2594 /* The machine modes of pointers and functions. */
2595 #define Pmode (TARGET_SHMEDIA64 ? DImode : SImode)
2596 #define FUNCTION_MODE Pmode
2598 /* The relative costs of various types of constants. */
2600 #define CONST_COSTS(RTX, CODE, OUTER_CODE) \
2602 if (TARGET_SHMEDIA) \
2604 if (CONST_OK_FOR_J (INTVAL (RTX))) \
2605 return COSTS_N_INSNS (1); \
2606 else if (CONST_OK_FOR_J (INTVAL (RTX) >> 16)) \
2607 return COSTS_N_INSNS (2); \
2608 else if (CONST_OK_FOR_J ((INTVAL (RTX) >> 16) >> 16)) \
2609 return COSTS_N_INSNS (3); \
2611 return COSTS_N_INSNS (4); \
2613 if (CONST_OK_FOR_I (INTVAL (RTX))) \
2615 else if (((OUTER_CODE) == AND || (OUTER_CODE) == IOR || (OUTER_CODE) == XOR) \
2616 && CONST_OK_FOR_L (INTVAL (RTX))) \
2623 if (TARGET_SHMEDIA64) \
2624 return COSTS_N_INSNS (4); \
2625 if (TARGET_SHMEDIA32) \
2626 return COSTS_N_INSNS (2); \
2628 case CONST_DOUBLE: \
2629 if (TARGET_SHMEDIA) \
2630 return COSTS_N_INSNS (4); \
2634 #define RTX_COSTS(X, CODE, OUTER_CODE) \
2636 return COSTS_N_INSNS (addsubcosts (X)); \
2638 return COSTS_N_INSNS (andcosts (X)); \
2640 return COSTS_N_INSNS (multcosts (X)); \
2644 return COSTS_N_INSNS (shiftcosts (X)); \
2649 return COSTS_N_INSNS (20); \
2654 /* The multiply insn on the SH1 and the divide insns on the SH1 and SH2
2655 are actually function calls with some special constraints on arguments
2658 These macros tell reorg that the references to arguments and
2659 register clobbers for insns of type sfunc do not appear to happen
2660 until after the millicode call. This allows reorg to put insns
2661 which set the argument registers into the delay slot of the millicode
2662 call -- thus they act more like traditional CALL_INSNs.
2664 get_attr_is_sfunc will try to recognize the given insn, so make sure to
2665 filter out things it will not accept -- SEQUENCE, USE and CLOBBER insns
2668 #define INSN_SETS_ARE_DELAYED(X) \
2669 ((GET_CODE (X) == INSN \
2670 && GET_CODE (PATTERN (X)) != SEQUENCE \
2671 && GET_CODE (PATTERN (X)) != USE \
2672 && GET_CODE (PATTERN (X)) != CLOBBER \
2673 && get_attr_is_sfunc (X)))
2675 #define INSN_REFERENCES_ARE_DELAYED(X) \
2676 ((GET_CODE (X) == INSN \
2677 && GET_CODE (PATTERN (X)) != SEQUENCE \
2678 && GET_CODE (PATTERN (X)) != USE \
2679 && GET_CODE (PATTERN (X)) != CLOBBER \
2680 && get_attr_is_sfunc (X)))
2683 /* Position Independent Code. */
2684 /* Define this macro if references to a symbol must be treated
2685 differently depending on something about the variable or function
2686 named by the symbol (such as what section it is in).
2688 On SH, if using PIC, mark a SYMBOL_REF for a non-global symbol
2689 so that we may access it using GOTOFF instead of GOT. */
2691 #define ENCODE_SECTION_INFO(DECL) \
2696 rtx rtl = (TREE_CODE_CLASS (TREE_CODE (DECL)) != 'd' \
2697 ? TREE_CST_RTL (DECL) : DECL_RTL (DECL)); \
2699 SYMBOL_REF_FLAG (XEXP (rtl, 0)) = \
2700 (TREE_CODE_CLASS (TREE_CODE (DECL)) != 'd' \
2701 || ! TREE_PUBLIC (DECL)); \
2705 rtx rtl = (TREE_CODE_CLASS (TREE_CODE (DECL)) != 'd' \
2706 ? TREE_CST_RTL (DECL) \
2707 : TREE_CODE (DECL) != VAR_DECL \
2709 : DECL_RTL (DECL)); \
2711 if (rtl && GET_CODE (rtl) == MEM \
2712 && GET_CODE (XEXP (rtl, 0)) == SYMBOL_REF) \
2713 XEXP (rtl, 0) = gen_datalabel_ref (XEXP (rtl, 0)); \
2718 /* The prefix used to mark SYMBOL_REFs that refer to data symbols. */
2719 #define SH_DATALABEL_ENCODING "#"
2721 /* Return true if SYM_NAME starts with SH_DATALABEL_ENCODING. */
2722 #define DATALABEL_SYMNAME_P(SYM_NAME) \
2723 (SH_DATALABEL_ENCODING[1] ? (abort (), 0) : \
2724 (SYM_NAME)[0] == SH_DATALABEL_ENCODING[0])
2726 /* Skip an optional SH_DATALABEL_ENCODING in the beginning of
2727 SYM_NAME. Then, remove a leading *, like the default definition in
2729 #define STRIP_DATALABEL_ENCODING(VAR, SYM_NAME) \
2730 (VAR) = (SYM_NAME) + (DATALABEL_SYMNAME_P (SYM_NAME) \
2731 ? strlen (SH_DATALABEL_ENCODING) : 0)
2732 #define STRIP_NAME_ENCODING(VAR, SYM_NAME) \
2733 STRIP_DATALABEL_ENCODING((VAR), (SYM_NAME)), \
2734 (VAR) += (*(VAR) == '*')
2736 /* We can't directly access anything that contains a symbol,
2737 nor can we indirect via the constant pool. */
2738 #define LEGITIMATE_PIC_OPERAND_P(X) \
2739 (! nonpic_symbol_mentioned_p (X) \
2740 && (! CONSTANT_POOL_ADDRESS_P (X) \
2741 || ! nonpic_symbol_mentioned_p (get_pool_constant (X))))
2743 #define SYMBOLIC_CONST_P(X) \
2744 ((GET_CODE (X) == SYMBOL_REF || GET_CODE (X) == LABEL_REF) \
2745 && nonpic_symbol_mentioned_p (X))
2747 /* Compute the cost of an address. For the SH, all valid addresses are
2748 the same cost. Use a slightly higher cost for reg + reg addressing,
2749 since it increases pressure on r0. */
2751 #define ADDRESS_COST(X) (GET_CODE (X) == PLUS && ! CONSTANT_P (XEXP (X, 1)) \
2752 && ! TARGET_SHMEDIA \
2755 /* Compute extra cost of moving data between one register class
2758 /* Regclass always uses 2 for moves in the same register class;
2759 If SECONDARY*_RELOAD_CLASS says something about the src/dst pair,
2760 it uses this information. Hence, the general register <-> floating point
2761 register information here is not used for SFmode. */
2762 #define REGISTER_MOVE_COST(MODE, SRCCLASS, DSTCLASS) \
2763 (((((DSTCLASS) == T_REGS) || ((DSTCLASS) == PR_REGS)) ? 10 \
2764 : ((((DSTCLASS) == FP0_REGS || (DSTCLASS) == FP_REGS || (DSTCLASS) == DF_REGS) \
2765 && ((SRCCLASS) == GENERAL_REGS || (SRCCLASS) == R0_REGS)) \
2766 || (((DSTCLASS) == GENERAL_REGS || (DSTCLASS) == R0_REGS) \
2767 && ((SRCCLASS) == FP0_REGS || (SRCCLASS) == FP_REGS \
2768 || (SRCCLASS) == DF_REGS))) \
2769 ? (TARGET_SHMEDIA ? 2 \
2770 : TARGET_FMOVD ? 8 : 12) \
2771 : (((DSTCLASS) == FPUL_REGS \
2772 && ((SRCCLASS) == GENERAL_REGS || (SRCCLASS) == R0_REGS)) \
2773 || (SRCCLASS == FPUL_REGS \
2774 && ((DSTCLASS) == GENERAL_REGS || (DSTCLASS) == R0_REGS))) \
2776 : (((DSTCLASS) == FPUL_REGS \
2777 && ((SRCCLASS) == PR_REGS || (SRCCLASS) == MAC_REGS \
2778 || (SRCCLASS) == T_REGS)) \
2779 || ((SRCCLASS) == FPUL_REGS \
2780 && ((DSTCLASS) == PR_REGS || (DSTCLASS) == MAC_REGS))) \
2782 : (((SRCCLASS) == TARGET_REGS && (DSTCLASS) != GENERAL_REGS) \
2783 || ((DSTCLASS) == TARGET_REGS && (SRCCLASS) != GENERAL_REGS)) \
2785 : (((SRCCLASS) == FPSCR_REGS && (DSTCLASS) != GENERAL_REGS) \
2786 || ((DSTCLASS) == FPSCR_REGS && (SRCCLASS) != GENERAL_REGS)) \
2788 : 2) * ((MODE) == V16SFmode ? 8 : (MODE) == V4SFmode ? 2 : 1))
2790 /* ??? Perhaps make MEMORY_MOVE_COST depend on compiler option? This
2791 would be so that people with slow memory systems could generate
2792 different code that does fewer memory accesses. */
2794 /* A C expression for the cost of a branch instruction. A value of 1
2795 is the default; other values are interpreted relative to that.
2796 The SH1 does not have delay slots, hence we get a pipeline stall
2797 at every branch. The SH4 is superscalar, so the single delay slot
2798 is not sufficient to keep both pipelines filled. */
2799 #define BRANCH_COST (TARGET_SH5 ? 1 : ! TARGET_SH2 || TARGET_HARD_SH4 ? 2 : 1)
2801 /* Assembler output control. */
2803 /* A C string constant describing how to begin a comment in the target
2804 assembler language. The compiler assumes that the comment will end at
2805 the end of the line. */
2806 #define ASM_COMMENT_START "!"
2808 /* The text to go at the start of the assembler file. */
2809 #define ASM_FILE_START(STREAM) \
2810 output_file_start (STREAM)
2812 #define ASM_FILE_END(STREAM)
2814 #define ASM_APP_ON ""
2815 #define ASM_APP_OFF ""
2816 #define FILE_ASM_OP "\t.file\n"
2817 #define IDENT_ASM_OP "\t.ident\t"
2818 #define SET_ASM_OP "\t.set\t"
2820 /* How to change between sections. */
2822 #define TEXT_SECTION_ASM_OP (TARGET_SHMEDIA32 ? "\t.section\t.text..SHmedia32,\"ax\"" : "\t.text")
2823 #define DATA_SECTION_ASM_OP "\t.data"
2825 #if defined CRT_BEGIN || defined CRT_END
2826 /* Arrange for TEXT_SECTION_ASM_OP to be a compile-time constant. */
2827 # undef TEXT_SECTION_ASM_OP
2828 # if __SHMEDIA__ == 1 && __SH5__ == 32
2829 # define TEXT_SECTION_ASM_OP "\t.section\t.text..SHmedia32,\"ax\""
2831 # define TEXT_SECTION_ASM_OP "\t.text"
2836 /* If defined, a C expression whose value is a string containing the
2837 assembler operation to identify the following data as
2838 uninitialized global data. If not defined, and neither
2839 `ASM_OUTPUT_BSS' nor `ASM_OUTPUT_ALIGNED_BSS' are defined,
2840 uninitialized global data will be output in the data section if
2841 `-fno-common' is passed, otherwise `ASM_OUTPUT_COMMON' will be
2843 #ifndef BSS_SECTION_ASM_OP
2844 #define BSS_SECTION_ASM_OP "\t.section\t.bss"
2847 /* Like `ASM_OUTPUT_BSS' except takes the required alignment as a
2848 separate, explicit argument. If you define this macro, it is used
2849 in place of `ASM_OUTPUT_BSS', and gives you more flexibility in
2850 handling the required alignment of the variable. The alignment is
2851 specified as the number of bits.
2853 Try to use function `asm_output_aligned_bss' defined in file
2854 `varasm.c' when defining this macro. */
2855 #ifndef ASM_OUTPUT_ALIGNED_BSS
2856 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
2857 asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
2860 /* Define this so that jump tables go in same section as the current function,
2861 which could be text or it could be a user defined section. */
2862 #define JUMP_TABLES_IN_TEXT_SECTION 1
2864 /* Switch into a generic section. */
2865 #define TARGET_ASM_NAMED_SECTION sh_asm_named_section
2867 #undef DO_GLOBAL_CTORS_BODY
2868 #define DO_GLOBAL_CTORS_BODY \
2870 typedef (*pfunc)(); \
2871 extern pfunc __ctors[]; \
2872 extern pfunc __ctors_end[]; \
2874 for (p = __ctors_end; p > __ctors; ) \
2880 #undef DO_GLOBAL_DTORS_BODY
2881 #define DO_GLOBAL_DTORS_BODY \
2883 typedef (*pfunc)(); \
2884 extern pfunc __dtors[]; \
2885 extern pfunc __dtors_end[]; \
2887 for (p = __dtors; p < __dtors_end; p++) \
2893 #define ASM_OUTPUT_REG_PUSH(file, v) \
2894 fprintf ((file), "\tmov.l\tr%d,@-r15\n", (v));
2896 #define ASM_OUTPUT_REG_POP(file, v) \
2897 fprintf ((file), "\tmov.l\t@r15+,r%d\n", (v));
2899 /* DBX register number for a given compiler register number. */
2900 /* GDB has FPUL at 23 and FP0 at 25, so we must add one to all FP registers
2902 /* If you change this macro, make sure you update it in elf.h too. */
2903 #define DBX_REGISTER_NUMBER(REGNO) \
2904 (GENERAL_REGISTER_P (REGNO) \
2905 ? ((REGNO) - FIRST_GENERAL_REG) \
2906 : FP_REGISTER_P (REGNO) \
2907 ? ((REGNO) - FIRST_FP_REG + (TARGET_SH5 ? (TARGET_SHCOMPACT ? 245 \
2909 : XD_REGISTER_P (REGNO) \
2910 ? ((REGNO) - FIRST_XD_REG + (TARGET_SH5 ? 289 : 87)) \
2911 : TARGET_REGISTER_P (REGNO) \
2912 ? ((REGNO) - FIRST_TARGET_REG + 68) \
2913 : (REGNO) == PR_REG \
2914 ? (TARGET_SH5 ? 241 : 17) \
2915 : (REGNO) == T_REG \
2916 ? (TARGET_SH5 ? 242 : 18) \
2917 : (REGNO) == GBR_REG \
2918 ? (TARGET_SH5 ? 238 : 19) \
2919 : (REGNO) == MACH_REG \
2920 ? (TARGET_SH5 ? 239 : 20) \
2921 : (REGNO) == MACL_REG \
2922 ? (TARGET_SH5 ? 240 : 21) \
2923 : (REGNO) == FPUL_REG \
2924 ? (TARGET_SH5 ? 244 : 23) \
2927 /* This is how to output a reference to a user-level label named NAME. */
2928 #define ASM_OUTPUT_LABELREF(FILE, NAME) \
2933 STRIP_DATALABEL_ENCODING (lname, (NAME)); \
2934 if (lname[0] == '*') \
2935 fputs (lname + 1, (FILE)); \
2937 asm_fprintf ((FILE), "%U%s", lname); \
2941 /* This is how to output a reference to a symbol_ref. On SH5,
2942 references to non-code symbols must be preceded by `datalabel'. */
2943 #define ASM_OUTPUT_SYMBOL_REF(FILE,SYM) \
2947 && (DATALABEL_SYMNAME_P (XSTR ((SYM), 0)) \
2948 || CONSTANT_POOL_ADDRESS_P (SYM))) \
2949 fputs ("datalabel ", (FILE)); \
2950 assemble_name ((FILE), XSTR ((SYM), 0)); \
2954 /* Output a label definition. */
2955 #define ASM_OUTPUT_LABEL(FILE,NAME) \
2956 do { assemble_name ((FILE), (NAME)); fputs (":\n", (FILE)); } while (0)
2958 /* This is how to output an assembler line
2959 that says to advance the location counter
2960 to a multiple of 2**LOG bytes. */
2962 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
2964 fprintf ((FILE), "\t.align %d\n", (LOG))
2966 /* Output a function label definition. */
2967 #define ASM_DECLARE_FUNCTION_NAME(STREAM,NAME,DECL) \
2968 ASM_OUTPUT_LABEL((STREAM), (NAME))
2970 /* Output a globalising directive for a label. */
2971 #define ASM_GLOBALIZE_LABEL(STREAM,NAME) \
2972 (fprintf ((STREAM), "\t.global\t"), \
2973 assemble_name ((STREAM), (NAME)), \
2974 fputc ('\n', (STREAM)))
2976 /* The prefix to add to user-visible assembler symbols. */
2978 #define USER_LABEL_PREFIX "_"
2980 /* The prefix to add to an internally generated label. */
2982 #define LOCAL_LABEL_PREFIX ""
2984 /* Make an internal label into a string. */
2985 #define ASM_GENERATE_INTERNAL_LABEL(STRING, PREFIX, NUM) \
2986 sprintf ((STRING), "*%s%s%ld", LOCAL_LABEL_PREFIX, (PREFIX), (long)(NUM))
2988 /* Output an internal label definition. */
2989 #define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM) \
2990 asm_fprintf ((FILE), "%L%s%d:\n", (PREFIX), (NUM))
2992 /* #define ASM_OUTPUT_CASE_END(STREAM,NUM,TABLE) */
2994 /* Construct a private name. */
2995 #define ASM_FORMAT_PRIVATE_NAME(OUTVAR,NAME,NUMBER) \
2996 ((OUTVAR) = (char *) alloca (strlen (NAME) + 10), \
2997 sprintf ((OUTVAR), "%s.%d", (NAME), (NUMBER)))
2999 /* Output a relative address table. */
3001 #define ASM_OUTPUT_ADDR_DIFF_ELT(STREAM,BODY,VALUE,REL) \
3002 switch (GET_MODE (BODY)) \
3007 asm_fprintf ((STREAM), "\t.long\t%LL%d-datalabel %LL%d\n", \
3011 asm_fprintf ((STREAM), "\t.long\t%LL%d-%LL%d\n", (VALUE),(REL)); \
3016 asm_fprintf ((STREAM), "\t.word\t%LL%d-datalabel %LL%d\n", \
3020 asm_fprintf ((STREAM), "\t.word\t%LL%d-%LL%d\n", (VALUE),(REL)); \
3025 asm_fprintf ((STREAM), "\t.byte\t%LL%d-datalabel %LL%d\n", \
3029 asm_fprintf ((STREAM), "\t.byte\t%LL%d-%LL%d\n", (VALUE),(REL)); \
3035 /* Output an absolute table element. */
3037 #define ASM_OUTPUT_ADDR_VEC_ELT(STREAM,VALUE) \
3038 if (TARGET_BIGTABLE) \
3039 asm_fprintf ((STREAM), "\t.long\t%LL%d\n", (VALUE)); \
3041 asm_fprintf ((STREAM), "\t.word\t%LL%d\n", (VALUE)); \
3043 /* Output various types of constants. */
3045 /* Loop alignment is now done in machine_dependent_reorg, so that
3046 branch shortening can know about it. */
3048 /* This is how to output an assembler line
3049 that says to advance the location counter by SIZE bytes. */
3051 #define ASM_OUTPUT_SKIP(FILE,SIZE) \
3052 fprintf ((FILE), "\t.space %d\n", (SIZE))
3054 /* This says how to output an assembler line
3055 to define a global common symbol. */
3057 #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED) \
3058 ( fputs ("\t.comm ", (FILE)), \
3059 assemble_name ((FILE), (NAME)), \
3060 fprintf ((FILE), ",%d\n", (SIZE)))
3062 /* This says how to output an assembler line
3063 to define a local common symbol. */
3065 #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED) \
3066 ( fputs ("\t.lcomm ", (FILE)), \
3067 assemble_name ((FILE), (NAME)), \
3068 fprintf ((FILE), ",%d\n", (SIZE)))
3070 /* A C statement to be executed just prior to the output of
3071 assembler code for INSN, to modify the extracted operands so
3072 they will be output differently.
3074 Here the argument OPVEC is the vector containing the operands
3075 extracted from INSN, and NOPERANDS is the number of elements of
3076 the vector which contain meaningful data for this insn.
3077 The contents of this vector are what will be used to convert the insn
3078 template into assembler code, so you can change the assembler output
3079 by changing the contents of the vector. */
3081 #define FINAL_PRESCAN_INSN(INSN, OPVEC, NOPERANDS) \
3082 final_prescan_insn ((INSN), (OPVEC), (NOPERANDS))
3084 /* Print operand X (an rtx) in assembler syntax to file FILE.
3085 CODE is a letter or dot (`z' in `%z0') or 0 if no letter was specified.
3086 For `%' followed by punctuation, CODE is the punctuation and X is null. */
3088 #define PRINT_OPERAND(STREAM, X, CODE) print_operand ((STREAM), (X), (CODE))
3090 /* Print a memory address as an operand to reference that memory location. */
3092 #define PRINT_OPERAND_ADDRESS(STREAM,X) print_operand_address ((STREAM), (X))
3094 #define PRINT_OPERAND_PUNCT_VALID_P(CHAR) \
3095 ((CHAR) == '.' || (CHAR) == '#' || (CHAR) == '@' || (CHAR) == ',' \
3098 /* Recognize machine-specific patterns that may appear within
3099 constants. Used for PIC-specific UNSPECs. */
3100 #define OUTPUT_ADDR_CONST_EXTRA(STREAM, X, FAIL) \
3102 if (GET_CODE (X) == UNSPEC && XVECLEN ((X), 0) == 1) \
3104 switch (XINT ((X), 1)) \
3106 case UNSPEC_DATALABEL: \
3107 fputs ("datalabel ", (STREAM)); \
3108 output_addr_const ((STREAM), XVECEXP ((X), 0, 0)); \
3111 /* GLOBAL_OFFSET_TABLE or local symbols, no suffix. */ \
3112 output_addr_const ((STREAM), XVECEXP ((X), 0, 0)); \
3115 output_addr_const ((STREAM), XVECEXP ((X), 0, 0)); \
3116 fputs ("@GOT", (STREAM)); \
3118 case UNSPEC_GOTOFF: \
3119 output_addr_const ((STREAM), XVECEXP ((X), 0, 0)); \
3120 fputs ("@GOTOFF", (STREAM)); \
3123 output_addr_const ((STREAM), XVECEXP ((X), 0, 0)); \
3124 fputs ("@PLT", (STREAM)); \
3126 case UNSPEC_GOTPLT: \
3127 output_addr_const ((STREAM), XVECEXP ((X), 0, 0)); \
3128 fputs ("@GOTPLT", (STREAM)); \
3130 case UNSPEC_CALLER: \
3133 /* LPCS stands for Label for PIC Call Site. */ \
3134 ASM_GENERATE_INTERNAL_LABEL \
3135 (name, "LPCS", INTVAL (XVECEXP ((X), 0, 0))); \
3136 assemble_name ((STREAM), name); \
3149 extern struct rtx_def *sh_compare_op0;
3150 extern struct rtx_def *sh_compare_op1;
3152 /* Which processor to schedule for. The elements of the enumeration must
3153 match exactly the cpu attribute in the sh.md file. */
3155 enum processor_type {
3164 #define sh_cpu_attr ((enum attr_cpu)sh_cpu)
3165 extern enum processor_type sh_cpu;
3167 extern int optimize; /* needed for gen_casesi. */
3169 enum mdep_reorg_phase_e
3171 SH_BEFORE_MDEP_REORG,
3172 SH_INSERT_USES_LABELS,
3173 SH_SHORTEN_BRANCHES0,
3175 SH_SHORTEN_BRANCHES1,
3179 extern enum mdep_reorg_phase_e mdep_reorg_phase;
3181 #define MACHINE_DEPENDENT_REORG(X) machine_dependent_reorg(X)
3183 /* Generate calls to memcpy, memcmp and memset. */
3185 #define TARGET_MEM_FUNCTIONS
3187 /* Handle Hitachi compiler's pragmas. */
3188 #define REGISTER_TARGET_PRAGMAS(PFILE) do { \
3189 cpp_register_pragma (PFILE, 0, "interrupt", sh_pr_interrupt); \
3190 cpp_register_pragma (PFILE, 0, "trapa", sh_pr_trapa); \
3191 cpp_register_pragma (PFILE, 0, "nosave_low_regs", sh_pr_nosave_low_regs); \
3194 /* Set when processing a function with pragma interrupt turned on. */
3196 extern int pragma_interrupt;
3198 /* Set when processing a function with interrupt attribute. */
3200 extern int current_function_interrupt;
3202 /* Set to an RTX containing the address of the stack to switch to
3203 for interrupt functions. */
3204 extern struct rtx_def *sp_switch;
3206 extern int rtx_equal_function_value_matters;
3207 extern struct rtx_def *fpscr_rtx;
3210 /* Instructions with unfilled delay slots take up an
3211 extra two bytes for the nop in the delay slot.
3212 sh-dsp parallel processing insns are four bytes long. */
3214 #define ADJUST_INSN_LENGTH(X, LENGTH) \
3215 (LENGTH) += sh_insn_length_adjustment (X);
3217 /* Define the codes that are matched by predicates in sh.c. */
3218 #define PREDICATE_CODES \
3219 {"arith_operand", {SUBREG, REG, CONST_INT}}, \
3220 {"arith_reg_operand", {SUBREG, REG}}, \
3221 {"arith_reg_or_0_operand", {SUBREG, REG, CONST_INT}}, \
3222 {"binary_float_operator", {PLUS, MULT}}, \
3223 {"commutative_float_operator", {PLUS, MULT}}, \
3224 {"fp_arith_reg_operand", {SUBREG, REG}}, \
3225 {"fpscr_operand", {REG}}, \
3226 {"fpul_operand", {REG}}, \
3227 {"general_movsrc_operand", {SUBREG, REG, CONST_INT, CONST_DOUBLE, MEM}}, \
3228 {"general_movdst_operand", {SUBREG, REG, MEM}}, \
3229 {"logical_operand", {SUBREG, REG, CONST_INT}}, \
3230 {"noncommutative_float_operator", {MINUS, DIV}}, \
3231 {"shmedia_6bit_operand", {SUBREG, REG, CONST_INT}}, \
3232 {"target_reg_operand", {SUBREG, REG}}, \
3233 {"target_operand", {SUBREG, REG, LABEL_REF, SYMBOL_REF}}, \
3234 {"register_operand", {SUBREG, REG}}, \
3235 {"symbol_ref_operand", {SYMBOL_REF}},
3237 /* Define this macro if it is advisable to hold scalars in registers
3238 in a wider mode than that declared by the program. In such cases,
3239 the value is constrained to be within the bounds of the declared
3240 type, but kept valid in the wider mode. The signedness of the
3241 extension may differ from that of the type.
3243 Leaving the unsignedp unchanged gives better code than always setting it
3244 to 0. This is despite the fact that we have only signed char and short
3245 load instructions. */
3246 #define PROMOTE_MODE(MODE, UNSIGNEDP, TYPE) \
3247 if (GET_MODE_CLASS (MODE) == MODE_INT \
3248 && GET_MODE_SIZE (MODE) < UNITS_PER_WORD) \
3249 (UNSIGNEDP) = ((MODE) == SImode ? 0 : (UNSIGNEDP)), \
3250 (MODE) = (TARGET_SH1 ? SImode : DImode);
3252 /* Defining PROMOTE_FUNCTION_ARGS eliminates some unnecessary zero/sign
3253 extensions applied to char/short functions arguments. Defining
3254 PROMOTE_FUNCTION_RETURN does the same for function returns. */
3256 #define PROMOTE_FUNCTION_ARGS
3257 #define PROMOTE_FUNCTION_RETURN
3259 /* ??? Define ACCUMULATE_OUTGOING_ARGS? This is more efficient than pushing
3260 and poping arguments. However, we do have push/pop instructions, and
3261 rather limited offsets (4 bits) in load/store instructions, so it isn't
3262 clear if this would give better code. If implemented, should check for
3263 compatibility problems. */
3265 #define SH_DYNAMIC_SHIFT_COST \
3266 (TARGET_HARD_SH4 ? 1 : TARGET_SH3 ? (TARGET_SMALLCODE ? 1 : 2) : 20)
3269 #define NUM_MODES_FOR_MODE_SWITCHING { FP_MODE_NONE }
3271 #define OPTIMIZE_MODE_SWITCHING(ENTITY) TARGET_SH4
3273 #define NORMAL_MODE(ENTITY) \
3274 (TARGET_FPU_SINGLE ? FP_MODE_SINGLE : FP_MODE_DOUBLE)
3276 #define EPILOGUE_USES(REGNO) ((TARGET_SH3E || TARGET_SH4) \
3277 && (REGNO) == FPSCR_REG)
3279 #define MODE_NEEDED(ENTITY, INSN) \
3280 (recog_memoized (INSN) >= 0 \
3281 ? get_attr_fp_mode (INSN) \
3284 #define MODE_PRIORITY_TO_MODE(ENTITY, N) \
3285 ((TARGET_FPU_SINGLE != 0) ^ (N) ? FP_MODE_SINGLE : FP_MODE_DOUBLE)
3287 #define EMIT_MODE_SET(ENTITY, MODE, HARD_REGS_LIVE) \
3288 fpscr_set_from_mem ((MODE), (HARD_REGS_LIVE))
3290 #define MD_CAN_REDIRECT_BRANCH(INSN, SEQ) \
3291 sh_can_redirect_branch ((INSN), (SEQ))
3293 #if (defined CRT_BEGIN || defined CRT_END) && ! __SHMEDIA__
3294 /* SH constant pool breaks the devices in crtstuff.c to control section
3295 in where code resides. We have to write it as asm code. */
3296 #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
3297 asm (SECTION_OP "\n\
3303 1: .long " USER_LABEL_PREFIX #FUNC " - 0b\n\
3304 2:\n" TEXT_SECTION_ASM_OP);
3305 #endif /* (defined CRT_BEGIN || defined CRT_END) && ! __SHMEDIA__ */
3307 #define ALLOCATE_INITIAL_VALUE(hard_reg) \
3308 (REGNO (hard_reg) == PR_REG \
3309 ? (current_function_is_leaf && ! sh_pr_n_sets () \
3311 : gen_rtx_MEM (Pmode, arg_pointer_rtx)) \
3314 #endif /* ! GCC_SH_H */