1 /* Definitions of target machine for GNU compiler for Renesas / SuperH SH.
2 Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
3 2003, 2004, 2005, 2006 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 GCC.
9 GCC 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 GCC 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 GCC; see the file COPYING. If not, write to
21 the Free Software Foundation, 51 Franklin Street, Fifth Floor,
22 Boston, MA 02110-1301, USA. */
27 #include "config/vxworks-dummy.h"
29 #define TARGET_VERSION \
30 fputs (" (Hitachi SH)", stderr);
32 /* Unfortunately, insn-attrtab.c doesn't include insn-codes.h. We can't
33 include it here, because bconfig.h is also included by gencodes.c . */
34 /* ??? No longer true. */
35 extern int code_for_indirect_jump_scratch;
37 #define TARGET_CPU_CPP_BUILTINS() \
39 builtin_define ("__sh__"); \
40 builtin_assert ("cpu=sh"); \
41 builtin_assert ("machine=sh"); \
42 switch ((int) sh_cpu) \
45 builtin_define ("__sh1__"); \
48 builtin_define ("__sh2__"); \
50 case PROCESSOR_SH2E: \
51 builtin_define ("__SH2E__"); \
53 case PROCESSOR_SH2A: \
54 builtin_define ("__SH2A__"); \
55 builtin_define (TARGET_SH2A_DOUBLE \
56 ? (TARGET_FPU_SINGLE ? "__SH2A_SINGLE__" : "__SH2A_DOUBLE__") \
57 : TARGET_FPU_ANY ? "__SH2A_SINGLE_ONLY__" \
58 : "__SH2A_NOFPU__"); \
61 builtin_define ("__sh3__"); \
62 builtin_define ("__SH3__"); \
63 if (TARGET_HARD_SH4) \
64 builtin_define ("__SH4_NOFPU__"); \
66 case PROCESSOR_SH3E: \
67 builtin_define (TARGET_HARD_SH4 ? "__SH4_SINGLE_ONLY__" : "__SH3E__"); \
70 builtin_define (TARGET_FPU_SINGLE ? "__SH4_SINGLE__" : "__SH4__"); \
72 case PROCESSOR_SH4A: \
73 builtin_define ("__SH4A__"); \
74 builtin_define (TARGET_SH4 \
75 ? (TARGET_FPU_SINGLE ? "__SH4_SINGLE__" : "__SH4__") \
76 : TARGET_FPU_ANY ? "__SH4_SINGLE_ONLY__" \
81 builtin_define_with_value ("__SH5__", \
82 TARGET_SHMEDIA64 ? "64" : "32", 0); \
83 builtin_define_with_value ("__SHMEDIA__", \
84 TARGET_SHMEDIA ? "1" : "0", 0); \
85 if (! TARGET_FPU_DOUBLE) \
86 builtin_define ("__SH4_NOFPU__"); \
90 builtin_define ("__SH_FPU_ANY__"); \
91 if (TARGET_FPU_DOUBLE) \
92 builtin_define ("__SH_FPU_DOUBLE__"); \
94 builtin_define ("__HITACHI__"); \
95 builtin_define (TARGET_LITTLE_ENDIAN \
96 ? "__LITTLE_ENDIAN__" : "__BIG_ENDIAN__"); \
99 /* We can not debug without a frame pointer. */
100 /* #define CAN_DEBUG_WITHOUT_FP */
102 #define CONDITIONAL_REGISTER_USAGE do \
105 for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno ++) \
106 if (! VALID_REGISTER_P (regno)) \
107 fixed_regs[regno] = call_used_regs[regno] = 1; \
108 /* R8 and R9 are call-clobbered on SH5, but not on earlier SH ABIs. */ \
111 call_used_regs[FIRST_GENERAL_REG + 8] \
112 = call_used_regs[FIRST_GENERAL_REG + 9] = 1; \
113 call_really_used_regs[FIRST_GENERAL_REG + 8] \
114 = call_really_used_regs[FIRST_GENERAL_REG + 9] = 1; \
116 if (TARGET_SHMEDIA) \
118 regno_reg_class[FIRST_GENERAL_REG] = GENERAL_REGS; \
119 CLEAR_HARD_REG_SET (reg_class_contents[FP0_REGS]); \
120 regno_reg_class[FIRST_FP_REG] = FP_REGS; \
124 fixed_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \
125 call_used_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \
127 /* Renesas saves and restores mac registers on call. */ \
128 if (TARGET_HITACHI && ! TARGET_NOMACSAVE) \
130 call_really_used_regs[MACH_REG] = 0; \
131 call_really_used_regs[MACL_REG] = 0; \
133 for (regno = FIRST_FP_REG + (TARGET_LITTLE_ENDIAN != 0); \
134 regno <= LAST_FP_REG; regno += 2) \
135 SET_HARD_REG_BIT (reg_class_contents[DF_HI_REGS], regno); \
136 if (TARGET_SHMEDIA) \
138 for (regno = FIRST_TARGET_REG; regno <= LAST_TARGET_REG; regno ++)\
139 if (! fixed_regs[regno] && call_really_used_regs[regno]) \
140 SET_HARD_REG_BIT (reg_class_contents[SIBCALL_REGS], regno); \
143 for (regno = FIRST_GENERAL_REG; regno <= LAST_GENERAL_REG; regno++) \
144 if (! fixed_regs[regno] && call_really_used_regs[regno]) \
145 SET_HARD_REG_BIT (reg_class_contents[SIBCALL_REGS], regno); \
148 /* Nonzero if this is an ELF target - compile time only */
151 /* Nonzero if we should generate code using type 2E insns. */
152 #define TARGET_SH2E (TARGET_SH2 && TARGET_SH_E)
154 /* Nonzero if we should generate code using type 2A insns. */
155 #define TARGET_SH2A TARGET_HARD_SH2A
156 /* Nonzero if we should generate code using type 2A SF insns. */
157 #define TARGET_SH2A_SINGLE (TARGET_SH2A && TARGET_SH2E)
158 /* Nonzero if we should generate code using type 2A DF insns. */
159 #define TARGET_SH2A_DOUBLE (TARGET_HARD_SH2A_DOUBLE && TARGET_SH2A)
161 /* Nonzero if we should generate code using type 3E insns. */
162 #define TARGET_SH3E (TARGET_SH3 && TARGET_SH_E)
164 /* Nonzero if the cache line size is 32. */
165 #define TARGET_CACHE32 (TARGET_HARD_SH4 || TARGET_SH5)
167 /* Nonzero if we schedule for a superscalar implementation. */
168 #define TARGET_SUPERSCALAR TARGET_HARD_SH4
170 /* Nonzero if the target has separate instruction and data caches. */
171 #define TARGET_HARVARD (TARGET_HARD_SH4 || TARGET_SH5)
173 /* Nonzero if a double-precision FPU is available. */
174 #define TARGET_FPU_DOUBLE \
175 ((target_flags & MASK_SH4) != 0 || TARGET_SH2A_DOUBLE)
177 /* Nonzero if an FPU is available. */
178 #define TARGET_FPU_ANY (TARGET_SH2E || TARGET_FPU_DOUBLE)
180 /* Nonzero if we should generate code using type 4 insns. */
182 #define TARGET_SH4 ((target_flags & MASK_SH4) != 0 && TARGET_SH1)
184 /* Nonzero if we're generating code for the common subset of
185 instructions present on both SH4a and SH4al-dsp. */
186 #define TARGET_SH4A_ARCH TARGET_SH4A
188 /* Nonzero if we're generating code for SH4a, unless the use of the
189 FPU is disabled (which makes it compatible with SH4al-dsp). */
190 #define TARGET_SH4A_FP (TARGET_SH4A_ARCH && TARGET_FPU_ANY)
192 /* Nonzero if we should generate code using the SHcompact instruction
193 set and 32-bit ABI. */
194 #define TARGET_SHCOMPACT (TARGET_SH5 && TARGET_SH1)
196 /* Nonzero if we should generate code using the SHmedia instruction
198 #define TARGET_SHMEDIA (TARGET_SH5 && ! TARGET_SH1)
200 /* Nonzero if we should generate code using the SHmedia ISA and 32-bit
202 #define TARGET_SHMEDIA32 (TARGET_SH5 && ! TARGET_SH1 && TARGET_SH_E)
204 /* Nonzero if we should generate code using the SHmedia ISA and 64-bit
206 #define TARGET_SHMEDIA64 (TARGET_SH5 && ! TARGET_SH1 && ! TARGET_SH_E)
208 /* Nonzero if we should generate code using SHmedia FPU instructions. */
209 #define TARGET_SHMEDIA_FPU (TARGET_SHMEDIA && TARGET_FPU_DOUBLE)
211 /* This is not used by the SH2E calling convention */
212 #define TARGET_VARARGS_PRETEND_ARGS(FUN_DECL) \
213 (TARGET_SH1 && ! TARGET_SH2E && ! TARGET_SH5 \
214 && ! (TARGET_HITACHI || sh_attr_renesas_p (FUN_DECL)))
216 #ifndef TARGET_CPU_DEFAULT
217 #define TARGET_CPU_DEFAULT SELECT_SH1
218 #define SUPPORT_SH1 1
219 #define SUPPORT_SH2E 1
220 #define SUPPORT_SH4 1
221 #define SUPPORT_SH4_SINGLE 1
222 #define SUPPORT_SH2A 1
223 #define SUPPORT_SH2A_SINGLE 1
226 #define TARGET_DIVIDE_INV \
227 (sh_div_strategy == SH_DIV_INV || sh_div_strategy == SH_DIV_INV_MINLAT \
228 || sh_div_strategy == SH_DIV_INV20U || sh_div_strategy == SH_DIV_INV20L \
229 || sh_div_strategy == SH_DIV_INV_CALL \
230 || sh_div_strategy == SH_DIV_INV_CALL2 || sh_div_strategy == SH_DIV_INV_FP)
231 #define TARGET_DIVIDE_FP (sh_div_strategy == SH_DIV_FP)
232 #define TARGET_DIVIDE_INV_FP (sh_div_strategy == SH_DIV_INV_FP)
233 #define TARGET_DIVIDE_CALL2 (sh_div_strategy == SH_DIV_CALL2)
234 #define TARGET_DIVIDE_INV_MINLAT (sh_div_strategy == SH_DIV_INV_MINLAT)
235 #define TARGET_DIVIDE_INV20U (sh_div_strategy == SH_DIV_INV20U)
236 #define TARGET_DIVIDE_INV20L (sh_div_strategy == SH_DIV_INV20L)
237 #define TARGET_DIVIDE_INV_CALL (sh_div_strategy == SH_DIV_INV_CALL)
238 #define TARGET_DIVIDE_INV_CALL2 (sh_div_strategy == SH_DIV_INV_CALL2)
239 #define TARGET_DIVIDE_CALL_DIV1 (sh_div_strategy == SH_DIV_CALL_DIV1)
240 #define TARGET_DIVIDE_CALL_FP (sh_div_strategy == SH_DIV_CALL_FP)
241 #define TARGET_DIVIDE_CALL_TABLE (sh_div_strategy == SH_DIV_CALL_TABLE)
243 #define SELECT_SH1 (MASK_SH1)
244 #define SELECT_SH2 (MASK_SH2 | SELECT_SH1)
245 #define SELECT_SH2E (MASK_SH_E | MASK_SH2 | MASK_SH1 \
247 #define SELECT_SH2A (MASK_SH_E | MASK_HARD_SH2A \
248 | MASK_HARD_SH2A_DOUBLE \
249 | MASK_SH2 | MASK_SH1)
250 #define SELECT_SH2A_NOFPU (MASK_HARD_SH2A | MASK_SH2 | MASK_SH1)
251 #define SELECT_SH2A_SINGLE_ONLY (MASK_SH_E | MASK_HARD_SH2A | MASK_SH2 \
252 | MASK_SH1 | MASK_FPU_SINGLE)
253 #define SELECT_SH2A_SINGLE (MASK_SH_E | MASK_HARD_SH2A \
254 | MASK_FPU_SINGLE | MASK_HARD_SH2A_DOUBLE \
255 | MASK_SH2 | MASK_SH1)
256 #define SELECT_SH3 (MASK_SH3 | SELECT_SH2)
257 #define SELECT_SH3E (MASK_SH_E | MASK_FPU_SINGLE | SELECT_SH3)
258 #define SELECT_SH4_NOFPU (MASK_HARD_SH4 | SELECT_SH3)
259 #define SELECT_SH4_SINGLE_ONLY (MASK_HARD_SH4 | SELECT_SH3E)
260 #define SELECT_SH4 (MASK_SH4 | MASK_SH_E | MASK_HARD_SH4 \
262 #define SELECT_SH4_SINGLE (MASK_FPU_SINGLE | SELECT_SH4)
263 #define SELECT_SH4A_NOFPU (MASK_SH4A | SELECT_SH4_NOFPU)
264 #define SELECT_SH4A_SINGLE_ONLY (MASK_SH4A | SELECT_SH4_SINGLE_ONLY)
265 #define SELECT_SH4A (MASK_SH4A | SELECT_SH4)
266 #define SELECT_SH4A_SINGLE (MASK_SH4A | SELECT_SH4_SINGLE)
267 #define SELECT_SH5_64MEDIA (MASK_SH5 | MASK_SH4)
268 #define SELECT_SH5_64MEDIA_NOFPU (MASK_SH5)
269 #define SELECT_SH5_32MEDIA (MASK_SH5 | MASK_SH4 | MASK_SH_E)
270 #define SELECT_SH5_32MEDIA_NOFPU (MASK_SH5 | MASK_SH_E)
271 #define SELECT_SH5_COMPACT (MASK_SH5 | MASK_SH4 | SELECT_SH3E)
272 #define SELECT_SH5_COMPACT_NOFPU (MASK_SH5 | SELECT_SH3)
275 #define SUPPORT_SH2 1
278 #define SUPPORT_SH3 1
279 #define SUPPORT_SH2A_NOFPU 1
282 #define SUPPORT_SH4_NOFPU 1
284 #if SUPPORT_SH4_NOFPU
285 #define SUPPORT_SH4A_NOFPU 1
286 #define SUPPORT_SH4AL 1
290 #define SUPPORT_SH3E 1
291 #define SUPPORT_SH2A_SINGLE_ONLY 1
294 #define SUPPORT_SH4_SINGLE_ONLY 1
296 #if SUPPORT_SH4_SINGLE_ONLY
297 #define SUPPORT_SH4A_SINGLE_ONLY 1
301 #define SUPPORT_SH4A 1
304 #if SUPPORT_SH4_SINGLE
305 #define SUPPORT_SH4A_SINGLE 1
308 #if SUPPORT_SH5_COMPAT
309 #define SUPPORT_SH5_32MEDIA 1
312 #if SUPPORT_SH5_COMPACT_NOFPU
313 #define SUPPORT_SH5_32MEDIA_NOFPU 1
316 #define SUPPORT_ANY_SH5_32MEDIA \
317 (SUPPORT_SH5_32MEDIA || SUPPORT_SH5_32MEDIA_NOFPU)
318 #define SUPPORT_ANY_SH5_64MEDIA \
319 (SUPPORT_SH5_64MEDIA || SUPPORT_SH5_64MEDIA_NOFPU)
320 #define SUPPORT_ANY_SH5 \
321 (SUPPORT_ANY_SH5_32MEDIA || SUPPORT_ANY_SH5_64MEDIA)
323 /* Reset all target-selection flags. */
324 #define MASK_ARCH (MASK_SH1 | MASK_SH2 | MASK_SH3 | MASK_SH_E | MASK_SH4 \
325 | MASK_HARD_SH2A | MASK_HARD_SH2A_DOUBLE | MASK_SH4A \
326 | MASK_HARD_SH4 | MASK_FPU_SINGLE | MASK_SH5)
328 /* This defaults us to big-endian. */
329 #ifndef TARGET_ENDIAN_DEFAULT
330 #define TARGET_ENDIAN_DEFAULT 0
333 #ifndef TARGET_OPT_DEFAULT
334 #define TARGET_OPT_DEFAULT MASK_ADJUST_UNROLL
337 #define TARGET_DEFAULT \
338 (TARGET_CPU_DEFAULT | TARGET_ENDIAN_DEFAULT | TARGET_OPT_DEFAULT)
340 #ifndef SH_MULTILIB_CPU_DEFAULT
341 #define SH_MULTILIB_CPU_DEFAULT "m1"
344 #if TARGET_ENDIAN_DEFAULT
345 #define MULTILIB_DEFAULTS { "ml", SH_MULTILIB_CPU_DEFAULT }
347 #define MULTILIB_DEFAULTS { "mb", SH_MULTILIB_CPU_DEFAULT }
350 #define CPP_SPEC " %(subtarget_cpp_spec) "
352 #ifndef SUBTARGET_CPP_SPEC
353 #define SUBTARGET_CPP_SPEC ""
356 #ifndef SUBTARGET_EXTRA_SPECS
357 #define SUBTARGET_EXTRA_SPECS
360 #define EXTRA_SPECS \
361 { "subtarget_cpp_spec", SUBTARGET_CPP_SPEC }, \
362 { "link_emul_prefix", LINK_EMUL_PREFIX }, \
363 { "link_default_cpu_emul", LINK_DEFAULT_CPU_EMUL }, \
364 { "subtarget_link_emul_suffix", SUBTARGET_LINK_EMUL_SUFFIX }, \
365 { "subtarget_link_spec", SUBTARGET_LINK_SPEC }, \
366 { "subtarget_asm_endian_spec", SUBTARGET_ASM_ENDIAN_SPEC }, \
367 { "subtarget_asm_relax_spec", SUBTARGET_ASM_RELAX_SPEC }, \
368 { "subtarget_asm_isa_spec", SUBTARGET_ASM_ISA_SPEC }, \
369 { "subtarget_asm_spec", SUBTARGET_ASM_SPEC }, \
370 SUBTARGET_EXTRA_SPECS
372 #if TARGET_CPU_DEFAULT & MASK_HARD_SH4
373 #define SUBTARGET_ASM_RELAX_SPEC "%{!m1:%{!m2:%{!m3*:%{!m5*:-isa=sh4-up}}}}"
375 #define SUBTARGET_ASM_RELAX_SPEC "%{m4*:-isa=sh4-up}"
378 #define SH_ASM_SPEC \
379 "%(subtarget_asm_endian_spec) %{mrelax:-relax %(subtarget_asm_relax_spec)}\
380 %(subtarget_asm_isa_spec) %(subtarget_asm_spec)\
382 %{m2a-single:--isa=sh2a} \
383 %{m2a-single-only:--isa=sh2a} \
384 %{m2a-nofpu:--isa=sh2a-nofpu} \
385 %{m5-compact*:--isa=SHcompact} \
386 %{m5-32media*:--isa=SHmedia --abi=32} \
387 %{m5-64media*:--isa=SHmedia --abi=64} \
388 %{m4al:-dsp} %{mcut2-workaround:-cut2-workaround}"
390 #define ASM_SPEC SH_ASM_SPEC
392 #ifndef SUBTARGET_ASM_ENDIAN_SPEC
393 #if TARGET_ENDIAN_DEFAULT == MASK_LITTLE_ENDIAN
394 #define SUBTARGET_ASM_ENDIAN_SPEC "%{mb:-big} %{!mb:-little}"
396 #define SUBTARGET_ASM_ENDIAN_SPEC "%{ml:-little} %{!ml:-big}"
400 #if STRICT_NOFPU == 1
401 /* Strict nofpu means that the compiler should tell the assembler
402 to reject FPU instructions. E.g. from ASM inserts. */
403 #if TARGET_CPU_DEFAULT & MASK_HARD_SH4 && !(TARGET_CPU_DEFAULT & MASK_SH_E)
404 #define SUBTARGET_ASM_ISA_SPEC "%{!m1:%{!m2:%{!m3*:%{m4-nofpu|!m4*:%{!m5:-isa=sh4-nofpu}}}}}"
406 /* If there were an -isa option for sh5-nofpu then it would also go here. */
407 #define SUBTARGET_ASM_ISA_SPEC \
408 "%{m4-nofpu:-isa=sh4-nofpu} " ASM_ISA_DEFAULT_SPEC
410 #else /* ! STRICT_NOFPU */
411 #define SUBTARGET_ASM_ISA_SPEC ASM_ISA_DEFAULT_SPEC
414 #ifndef SUBTARGET_ASM_SPEC
415 #define SUBTARGET_ASM_SPEC ""
418 #if TARGET_ENDIAN_DEFAULT == MASK_LITTLE_ENDIAN
419 #define LINK_EMUL_PREFIX "sh%{!mb:l}"
421 #define LINK_EMUL_PREFIX "sh%{ml:l}"
424 #if TARGET_CPU_DEFAULT & MASK_SH5
425 #if TARGET_CPU_DEFAULT & MASK_SH_E
426 #define LINK_DEFAULT_CPU_EMUL "32"
427 #if TARGET_CPU_DEFAULT & MASK_SH1
428 #define ASM_ISA_SPEC_DEFAULT "--isa=SHcompact"
430 #define ASM_ISA_SPEC_DEFAULT "--isa=SHmedia --abi=32"
431 #endif /* MASK_SH1 */
432 #else /* !MASK_SH_E */
433 #define LINK_DEFAULT_CPU_EMUL "64"
434 #define ASM_ISA_SPEC_DEFAULT "--isa=SHmedia --abi=64"
435 #endif /* MASK_SH_E */
436 #define ASM_ISA_DEFAULT_SPEC \
437 " %{!m1:%{!m2*:%{!m3*:%{!m4*:%{!m5*:" ASM_ISA_SPEC_DEFAULT "}}}}}"
438 #else /* !MASK_SH5 */
439 #define LINK_DEFAULT_CPU_EMUL ""
440 #define ASM_ISA_DEFAULT_SPEC ""
441 #endif /* MASK_SH5 */
443 #define SUBTARGET_LINK_EMUL_SUFFIX ""
444 #define SUBTARGET_LINK_SPEC ""
446 /* svr4.h redefines LINK_SPEC inappropriately, so go via SH_LINK_SPEC,
447 so that we can undo the damage without code replication. */
448 #define LINK_SPEC SH_LINK_SPEC
450 #define SH_LINK_SPEC "\
451 -m %(link_emul_prefix)\
452 %{m5-compact*|m5-32media*:32}\
454 %{!m1:%{!m2:%{!m3*:%{!m4*:%{!m5*:%(link_default_cpu_emul)}}}}}\
455 %(subtarget_link_emul_suffix) \
456 %{mrelax:-relax} %(subtarget_link_spec)"
458 #ifndef SH_DIV_STR_FOR_SIZE
459 #define SH_DIV_STR_FOR_SIZE "call"
462 #define DRIVER_SELF_SPECS "%{m2a:%{ml:%eSH2a does not support little-endian}}"
463 #define OPTIMIZATION_OPTIONS(LEVEL,SIZE) \
467 flag_omit_frame_pointer = -1; \
469 sh_div_str = "inv:minlat"; \
473 target_flags |= MASK_SMALLCODE; \
474 sh_div_str = SH_DIV_STR_FOR_SIZE ; \
478 TARGET_CBRANCHDI4 = 1; \
479 TARGET_EXPAND_CBRANCHDI4 = 1; \
481 /* We can't meaningfully test TARGET_SHMEDIA here, because -m options \
482 haven't been parsed yet, hence we'd read only the default. \
483 sh_target_reg_class will return NO_REGS if this is not SHMEDIA, so \
484 it's OK to always set flag_branch_target_load_optimize. */ \
487 flag_branch_target_load_optimize = 1; \
489 target_flags |= MASK_SAVE_ALL_TARGET_REGS; \
491 /* Likewise, we can't meaningfully test TARGET_SH2E / TARGET_IEEE \
492 here, so leave it to OVERRIDE_OPTIONS to set \
493 flag_finite_math_only. We set it to 2 here so we know if the user \
494 explicitly requested this to be on or off. */ \
495 flag_finite_math_only = 2; \
496 /* If flag_schedule_insns is 1, we set it to 2 here so we know if \
497 the user explicitly requested this to be on or off. */ \
498 if (flag_schedule_insns > 0) \
499 flag_schedule_insns = 2; \
501 set_param_value ("simultaneous-prefetches", 2); \
504 #define ASSEMBLER_DIALECT assembler_dialect
506 extern int assembler_dialect;
508 enum sh_divide_strategy_e {
509 /* SH5 strategies. */
512 SH_DIV_FP, /* We could do this also for SH4. */
520 /* SH1 .. SH4 strategies. Because of the small number of registers
521 available, the compiler uses knowledge of the actual set of registers
522 being clobbered by the different functions called. */
523 SH_DIV_CALL_DIV1, /* No FPU, medium size, highest latency. */
524 SH_DIV_CALL_FP, /* FPU needed, small size, high latency. */
525 SH_DIV_CALL_TABLE, /* No FPU, large size, medium latency. */
529 extern enum sh_divide_strategy_e sh_div_strategy;
531 #ifndef SH_DIV_STRATEGY_DEFAULT
532 #define SH_DIV_STRATEGY_DEFAULT SH_DIV_CALL
535 #define SUBTARGET_OVERRIDE_OPTIONS (void) 0
537 #define OVERRIDE_OPTIONS \
541 SUBTARGET_OVERRIDE_OPTIONS; \
542 if (flag_finite_math_only == 2) \
543 flag_finite_math_only \
544 = !flag_signaling_nans && TARGET_SH2E && ! TARGET_IEEE; \
545 if (TARGET_SH2E && !flag_finite_math_only) \
546 target_flags |= MASK_IEEE; \
548 assembler_dialect = 0; \
556 if (TARGET_SH2A_DOUBLE) \
557 target_flags |= MASK_FMOVD; \
565 assembler_dialect = 1; \
568 if (TARGET_SH4A_ARCH) \
570 assembler_dialect = 1; \
576 target_flags |= MASK_ALIGN_DOUBLE; \
577 if (TARGET_SHMEDIA_FPU) \
578 target_flags |= MASK_FMOVD; \
579 if (TARGET_SHMEDIA) \
581 /* There are no delay slots on SHmedia. */ \
582 flag_delayed_branch = 0; \
583 /* Relaxation isn't yet supported for SHmedia */ \
584 target_flags &= ~MASK_RELAX; \
585 /* After reload, if conversion does little good but can cause \
587 - find_if_block doesn't do anything for SH because we don't\
588 have conditional execution patterns. (We use conditional\
589 move patterns, which are handled differently, and only \
591 - find_cond_trap doesn't do anything for the SH because we \
592 don't have conditional traps. \
593 - find_if_case_1 uses redirect_edge_and_branch_force in \
594 the only path that does an optimization, and this causes \
595 an ICE when branch targets are in registers. \
596 - find_if_case_2 doesn't do anything for the SHmedia after \
597 reload except when it can redirect a tablejump - and \
598 that's rather rare. */ \
599 flag_if_conversion2 = 0; \
600 if (! strcmp (sh_div_str, "call")) \
601 sh_div_strategy = SH_DIV_CALL; \
602 else if (! strcmp (sh_div_str, "call2")) \
603 sh_div_strategy = SH_DIV_CALL2; \
604 if (! strcmp (sh_div_str, "fp") && TARGET_FPU_ANY) \
605 sh_div_strategy = SH_DIV_FP; \
606 else if (! strcmp (sh_div_str, "inv")) \
607 sh_div_strategy = SH_DIV_INV; \
608 else if (! strcmp (sh_div_str, "inv:minlat")) \
609 sh_div_strategy = SH_DIV_INV_MINLAT; \
610 else if (! strcmp (sh_div_str, "inv20u")) \
611 sh_div_strategy = SH_DIV_INV20U; \
612 else if (! strcmp (sh_div_str, "inv20l")) \
613 sh_div_strategy = SH_DIV_INV20L; \
614 else if (! strcmp (sh_div_str, "inv:call2")) \
615 sh_div_strategy = SH_DIV_INV_CALL2; \
616 else if (! strcmp (sh_div_str, "inv:call")) \
617 sh_div_strategy = SH_DIV_INV_CALL; \
618 else if (! strcmp (sh_div_str, "inv:fp")) \
620 if (TARGET_FPU_ANY) \
621 sh_div_strategy = SH_DIV_INV_FP; \
623 sh_div_strategy = SH_DIV_INV; \
625 TARGET_CBRANCHDI4 = 0; \
627 /* -fprofile-arcs needs a working libgcov . In unified tree \
628 configurations with newlib, this requires to configure with \
629 --with-newlib --with-headers. But there is no way to check \
630 here we have a working libgcov, so just assume that we have. */\
632 warning (0, "profiling is still experimental for this target");\
636 /* Only the sh64-elf assembler fully supports .quad properly. */\
637 targetm.asm_out.aligned_op.di = NULL; \
638 targetm.asm_out.unaligned_op.di = NULL; \
642 if (! strcmp (sh_div_str, "call-div1")) \
643 sh_div_strategy = SH_DIV_CALL_DIV1; \
644 else if (! strcmp (sh_div_str, "call-fp") \
645 && (TARGET_FPU_DOUBLE \
646 || (TARGET_HARD_SH4 && TARGET_SH2E) \
647 || (TARGET_SHCOMPACT && TARGET_FPU_ANY))) \
648 sh_div_strategy = SH_DIV_CALL_FP; \
649 else if (! strcmp (sh_div_str, "call-table") && TARGET_SH2) \
650 sh_div_strategy = SH_DIV_CALL_TABLE; \
652 /* Pick one that makes most sense for the target in general. \
653 It is not much good to use different functions depending \
654 on -Os, since then we'll end up with two different functions \
655 when some of the code is compiled for size, and some for \
658 /* SH4 tends to emphasize speed. */ \
659 if (TARGET_HARD_SH4) \
660 sh_div_strategy = SH_DIV_CALL_TABLE; \
661 /* These have their own way of doing things. */ \
662 else if (TARGET_SH2A) \
663 sh_div_strategy = SH_DIV_INTRINSIC; \
664 /* ??? Should we use the integer SHmedia function instead? */ \
665 else if (TARGET_SHCOMPACT && TARGET_FPU_ANY) \
666 sh_div_strategy = SH_DIV_CALL_FP; \
667 /* SH1 .. SH3 cores often go into small-footprint systems, so \
668 default to the smallest implementation available. */ \
669 else if (TARGET_SH2) /* ??? EXPERIMENTAL */ \
670 sh_div_strategy = SH_DIV_CALL_TABLE; \
672 sh_div_strategy = SH_DIV_CALL_DIV1; \
675 TARGET_PRETEND_CMOVE = 0; \
676 if (sh_divsi3_libfunc[0]) \
677 ; /* User supplied - leave it alone. */ \
678 else if (TARGET_DIVIDE_CALL_FP) \
679 sh_divsi3_libfunc = "__sdivsi3_i4"; \
680 else if (TARGET_DIVIDE_CALL_TABLE) \
681 sh_divsi3_libfunc = "__sdivsi3_i4i"; \
682 else if (TARGET_SH5) \
683 sh_divsi3_libfunc = "__sdivsi3_1"; \
685 sh_divsi3_libfunc = "__sdivsi3"; \
686 if (sh_branch_cost == -1) \
688 = TARGET_SH5 ? 1 : ! TARGET_SH2 || TARGET_HARD_SH4 ? 2 : 1; \
690 reg_class_from_letter['e' - 'a'] = NO_REGS; \
692 for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++) \
693 if (! VALID_REGISTER_P (regno)) \
694 sh_register_names[regno][0] = '\0'; \
696 for (regno = 0; regno < ADDREGNAMES_SIZE; regno++) \
697 if (! VALID_REGISTER_P (ADDREGNAMES_REGNO (regno))) \
698 sh_additional_register_names[regno][0] = '\0'; \
700 if (flag_omit_frame_pointer < 0) \
702 /* The debugging information is sufficient, \
703 but gdb doesn't implement this yet */ \
705 flag_omit_frame_pointer \
706 = (PREFERRED_DEBUGGING_TYPE == DWARF2_DEBUG); \
708 flag_omit_frame_pointer = 0; \
711 if ((flag_pic && ! TARGET_PREFERGOT) \
712 || (TARGET_SHMEDIA && !TARGET_PT_FIXED)) \
713 flag_no_function_cse = 1; \
715 if (SMALL_REGISTER_CLASSES) \
717 /* Never run scheduling before reload, since that can \
718 break global alloc, and generates slower code anyway due \
719 to the pressure on R0. */ \
720 /* Enable sched1 for SH4; ready queue will be reordered by \
721 the target hooks when pressure is high. We can not do this for \
722 SH3 and lower as they give spill failures for R0. */ \
723 if (!TARGET_HARD_SH4) \
724 flag_schedule_insns = 0; \
725 /* ??? Current exception handling places basic block boundaries \
726 after call_insns. It causes the high pressure on R0 and gives \
727 spill failures for R0 in reload. See PR 22553 and the thread \
729 <http://gcc.gnu.org/ml/gcc-patches/2005-10/msg00816.html>. */ \
730 else if (flag_exceptions) \
732 if (flag_schedule_insns == 1) \
733 warning (0, "ignoring -fschedule-insns because of exception handling bug"); \
734 flag_schedule_insns = 0; \
738 if (align_loops == 0) \
739 align_loops = 1 << (TARGET_SH5 ? 3 : 2); \
740 if (align_jumps == 0) \
741 align_jumps = 1 << CACHE_LOG; \
742 else if (align_jumps < (TARGET_SHMEDIA ? 4 : 2)) \
743 align_jumps = TARGET_SHMEDIA ? 4 : 2; \
745 /* Allocation boundary (in *bytes*) for the code of a function. \
746 SH1: 32 bit alignment is faster, because instructions are always \
747 fetched as a pair from a longword boundary. \
748 SH2 .. SH5 : align to cache line start. */ \
749 if (align_functions == 0) \
751 = TARGET_SMALLCODE ? FUNCTION_BOUNDARY/8 : (1 << CACHE_LOG); \
752 /* The linker relaxation code breaks when a function contains \
753 alignments that are larger than that at the start of a \
754 compilation unit. */ \
758 = align_loops > align_jumps ? align_loops : align_jumps; \
760 /* Also take possible .long constants / mova tables int account. */\
763 if (align_functions < min_align) \
764 align_functions = min_align; \
768 /* Target machine storage layout. */
770 /* Define this if most significant bit is lowest numbered
771 in instructions that operate on numbered bit-fields. */
773 #define BITS_BIG_ENDIAN 0
775 /* Define this if most significant byte of a word is the lowest numbered. */
776 #define BYTES_BIG_ENDIAN (TARGET_LITTLE_ENDIAN == 0)
778 /* Define this if most significant word of a multiword number is the lowest
780 #define WORDS_BIG_ENDIAN (TARGET_LITTLE_ENDIAN == 0)
782 /* Define this to set the endianness to use in libgcc2.c, which can
783 not depend on target_flags. */
784 #if defined(__LITTLE_ENDIAN__)
785 #define LIBGCC2_WORDS_BIG_ENDIAN 0
787 #define LIBGCC2_WORDS_BIG_ENDIAN 1
790 #define MAX_BITS_PER_WORD 64
792 /* Width in bits of an `int'. We want just 32-bits, even if words are
794 #define INT_TYPE_SIZE 32
796 /* Width in bits of a `long'. */
797 #define LONG_TYPE_SIZE (TARGET_SHMEDIA64 ? 64 : 32)
799 /* Width in bits of a `long long'. */
800 #define LONG_LONG_TYPE_SIZE 64
802 /* Width in bits of a `long double'. */
803 #define LONG_DOUBLE_TYPE_SIZE 64
805 /* Width of a word, in units (bytes). */
806 #define UNITS_PER_WORD (TARGET_SHMEDIA ? 8 : 4)
807 #define MIN_UNITS_PER_WORD 4
809 /* Scaling factor for Dwarf data offsets for CFI information.
810 The dwarf2out.c default would use -UNITS_PER_WORD, which is -8 for
811 SHmedia; however, since we do partial register saves for the registers
812 visible to SHcompact, and for target registers for SHMEDIA32, we have
813 to allow saves that are only 4-byte aligned. */
814 #define DWARF_CIE_DATA_ALIGNMENT -4
816 /* Width in bits of a pointer.
817 See also the macro `Pmode' defined below. */
818 #define POINTER_SIZE (TARGET_SHMEDIA64 ? 64 : 32)
820 /* Allocation boundary (in *bits*) for storing arguments in argument list. */
821 #define PARM_BOUNDARY (TARGET_SH5 ? 64 : 32)
823 /* Boundary (in *bits*) on which stack pointer should be aligned. */
824 #define STACK_BOUNDARY BIGGEST_ALIGNMENT
826 /* The log (base 2) of the cache line size, in bytes. Processors prior to
827 SH2 have no actual cache, but they fetch code in chunks of 4 bytes.
828 The SH2/3 have 16 byte cache lines, and the SH4 has a 32 byte cache line */
829 #define CACHE_LOG (TARGET_CACHE32 ? 5 : TARGET_SH2 ? 4 : 2)
831 /* ABI given & required minimum allocation boundary (in *bits*) for the
832 code of a function. */
833 #define FUNCTION_BOUNDARY (16 << TARGET_SHMEDIA)
835 /* On SH5, the lowest bit is used to indicate SHmedia functions, so
836 the vbit must go into the delta field of
837 pointers-to-member-functions. */
838 #define TARGET_PTRMEMFUNC_VBIT_LOCATION \
839 (TARGET_SH5 ? ptrmemfunc_vbit_in_delta : ptrmemfunc_vbit_in_pfn)
841 /* Alignment of field after `int : 0' in a structure. */
842 #define EMPTY_FIELD_BOUNDARY 32
844 /* No data type wants to be aligned rounder than this. */
845 #define BIGGEST_ALIGNMENT (TARGET_ALIGN_DOUBLE ? 64 : 32)
847 /* The best alignment to use in cases where we have a choice. */
848 #define FASTEST_ALIGNMENT (TARGET_SH5 ? 64 : 32)
850 /* Make strings word-aligned so strcpy from constants will be faster. */
851 #define CONSTANT_ALIGNMENT(EXP, ALIGN) \
852 ((TREE_CODE (EXP) == STRING_CST \
853 && (ALIGN) < FASTEST_ALIGNMENT) \
854 ? FASTEST_ALIGNMENT : (ALIGN))
856 /* get_mode_alignment assumes complex values are always held in multiple
857 registers, but that is not the case on the SH; CQImode and CHImode are
858 held in a single integer register. SH5 also holds CSImode and SCmode
859 values in integer registers. This is relevant for argument passing on
860 SHcompact as we use a stack temp in order to pass CSImode by reference. */
861 #define LOCAL_ALIGNMENT(TYPE, ALIGN) \
862 ((GET_MODE_CLASS (TYPE_MODE (TYPE)) == MODE_COMPLEX_INT \
863 || GET_MODE_CLASS (TYPE_MODE (TYPE)) == MODE_COMPLEX_FLOAT) \
864 ? (unsigned) MIN (BIGGEST_ALIGNMENT, GET_MODE_BITSIZE (TYPE_MODE (TYPE))) \
865 : (unsigned) DATA_ALIGNMENT(TYPE, ALIGN))
867 /* Make arrays of chars word-aligned for the same reasons. */
868 #define DATA_ALIGNMENT(TYPE, ALIGN) \
869 (TREE_CODE (TYPE) == ARRAY_TYPE \
870 && TYPE_MODE (TREE_TYPE (TYPE)) == QImode \
871 && (ALIGN) < FASTEST_ALIGNMENT ? FASTEST_ALIGNMENT : (ALIGN))
873 /* Number of bits which any structure or union's size must be a
874 multiple of. Each structure or union's size is rounded up to a
876 #define STRUCTURE_SIZE_BOUNDARY (TARGET_PADSTRUCT ? 32 : 8)
878 /* Set this nonzero if move instructions will actually fail to work
879 when given unaligned data. */
880 #define STRICT_ALIGNMENT 1
882 /* If LABEL_AFTER_BARRIER demands an alignment, return its base 2 logarithm. */
883 #define LABEL_ALIGN_AFTER_BARRIER(LABEL_AFTER_BARRIER) \
884 barrier_align (LABEL_AFTER_BARRIER)
886 #define LOOP_ALIGN(A_LABEL) \
887 ((! optimize || TARGET_HARD_SH4 || TARGET_SMALLCODE) \
888 ? 0 : sh_loop_align (A_LABEL))
890 #define LABEL_ALIGN(A_LABEL) \
892 (PREV_INSN (A_LABEL) \
893 && GET_CODE (PREV_INSN (A_LABEL)) == INSN \
894 && GET_CODE (PATTERN (PREV_INSN (A_LABEL))) == UNSPEC_VOLATILE \
895 && XINT (PATTERN (PREV_INSN (A_LABEL)), 1) == UNSPECV_ALIGN) \
896 /* explicit alignment insn in constant tables. */ \
897 ? INTVAL (XVECEXP (PATTERN (PREV_INSN (A_LABEL)), 0, 0)) \
900 /* Jump tables must be 32 bit aligned, no matter the size of the element. */
901 #define ADDR_VEC_ALIGN(ADDR_VEC) 2
903 /* The base two logarithm of the known minimum alignment of an insn length. */
904 #define INSN_LENGTH_ALIGNMENT(A_INSN) \
905 (GET_CODE (A_INSN) == INSN \
906 ? 1 << TARGET_SHMEDIA \
907 : GET_CODE (A_INSN) == JUMP_INSN || GET_CODE (A_INSN) == CALL_INSN \
908 ? 1 << TARGET_SHMEDIA \
911 /* Standard register usage. */
913 /* Register allocation for the Renesas calling convention:
919 r14 frame pointer/call saved
921 ap arg pointer (doesn't really exist, always eliminated)
922 pr subroutine return address
924 mach multiply/accumulate result, high part
925 macl multiply/accumulate result, low part.
926 fpul fp/int communication register
927 rap return address pointer register
929 fr1..fr3 scratch floating point registers
931 fr12..fr15 call saved floating point registers */
933 #define MAX_REGISTER_NAME_LENGTH 5
934 extern char sh_register_names[][MAX_REGISTER_NAME_LENGTH + 1];
936 #define SH_REGISTER_NAMES_INITIALIZER \
938 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
939 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", \
940 "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", \
941 "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31", \
942 "r32", "r33", "r34", "r35", "r36", "r37", "r38", "r39", \
943 "r40", "r41", "r42", "r43", "r44", "r45", "r46", "r47", \
944 "r48", "r49", "r50", "r51", "r52", "r53", "r54", "r55", \
945 "r56", "r57", "r58", "r59", "r60", "r61", "r62", "r63", \
946 "fr0", "fr1", "fr2", "fr3", "fr4", "fr5", "fr6", "fr7", \
947 "fr8", "fr9", "fr10", "fr11", "fr12", "fr13", "fr14", "fr15", \
948 "fr16", "fr17", "fr18", "fr19", "fr20", "fr21", "fr22", "fr23", \
949 "fr24", "fr25", "fr26", "fr27", "fr28", "fr29", "fr30", "fr31", \
950 "fr32", "fr33", "fr34", "fr35", "fr36", "fr37", "fr38", "fr39", \
951 "fr40", "fr41", "fr42", "fr43", "fr44", "fr45", "fr46", "fr47", \
952 "fr48", "fr49", "fr50", "fr51", "fr52", "fr53", "fr54", "fr55", \
953 "fr56", "fr57", "fr58", "fr59", "fr60", "fr61", "fr62", "fr63", \
954 "tr0", "tr1", "tr2", "tr3", "tr4", "tr5", "tr6", "tr7", \
955 "xd0", "xd2", "xd4", "xd6", "xd8", "xd10", "xd12", "xd14", \
956 "gbr", "ap", "pr", "t", "mach", "macl", "fpul", "fpscr", \
960 #define REGNAMES_ARR_INDEX_1(index) \
961 (sh_register_names[index])
962 #define REGNAMES_ARR_INDEX_2(index) \
963 REGNAMES_ARR_INDEX_1 ((index)), REGNAMES_ARR_INDEX_1 ((index)+1)
964 #define REGNAMES_ARR_INDEX_4(index) \
965 REGNAMES_ARR_INDEX_2 ((index)), REGNAMES_ARR_INDEX_2 ((index)+2)
966 #define REGNAMES_ARR_INDEX_8(index) \
967 REGNAMES_ARR_INDEX_4 ((index)), REGNAMES_ARR_INDEX_4 ((index)+4)
968 #define REGNAMES_ARR_INDEX_16(index) \
969 REGNAMES_ARR_INDEX_8 ((index)), REGNAMES_ARR_INDEX_8 ((index)+8)
970 #define REGNAMES_ARR_INDEX_32(index) \
971 REGNAMES_ARR_INDEX_16 ((index)), REGNAMES_ARR_INDEX_16 ((index)+16)
972 #define REGNAMES_ARR_INDEX_64(index) \
973 REGNAMES_ARR_INDEX_32 ((index)), REGNAMES_ARR_INDEX_32 ((index)+32)
975 #define REGISTER_NAMES \
977 REGNAMES_ARR_INDEX_64 (0), \
978 REGNAMES_ARR_INDEX_64 (64), \
979 REGNAMES_ARR_INDEX_8 (128), \
980 REGNAMES_ARR_INDEX_8 (136), \
981 REGNAMES_ARR_INDEX_8 (144), \
982 REGNAMES_ARR_INDEX_2 (152) \
985 #define ADDREGNAMES_SIZE 32
986 #define MAX_ADDITIONAL_REGISTER_NAME_LENGTH 4
987 extern char sh_additional_register_names[ADDREGNAMES_SIZE] \
988 [MAX_ADDITIONAL_REGISTER_NAME_LENGTH + 1];
990 #define SH_ADDITIONAL_REGISTER_NAMES_INITIALIZER \
992 "dr0", "dr2", "dr4", "dr6", "dr8", "dr10", "dr12", "dr14", \
993 "dr16", "dr18", "dr20", "dr22", "dr24", "dr26", "dr28", "dr30", \
994 "dr32", "dr34", "dr36", "dr38", "dr40", "dr42", "dr44", "dr46", \
995 "dr48", "dr50", "dr52", "dr54", "dr56", "dr58", "dr60", "dr62" \
998 #define ADDREGNAMES_REGNO(index) \
999 ((index < 32) ? (FIRST_FP_REG + (index) * 2) \
1002 #define ADDREGNAMES_ARR_INDEX_1(index) \
1003 { (sh_additional_register_names[index]), ADDREGNAMES_REGNO (index) }
1004 #define ADDREGNAMES_ARR_INDEX_2(index) \
1005 ADDREGNAMES_ARR_INDEX_1 ((index)), ADDREGNAMES_ARR_INDEX_1 ((index)+1)
1006 #define ADDREGNAMES_ARR_INDEX_4(index) \
1007 ADDREGNAMES_ARR_INDEX_2 ((index)), ADDREGNAMES_ARR_INDEX_2 ((index)+2)
1008 #define ADDREGNAMES_ARR_INDEX_8(index) \
1009 ADDREGNAMES_ARR_INDEX_4 ((index)), ADDREGNAMES_ARR_INDEX_4 ((index)+4)
1010 #define ADDREGNAMES_ARR_INDEX_16(index) \
1011 ADDREGNAMES_ARR_INDEX_8 ((index)), ADDREGNAMES_ARR_INDEX_8 ((index)+8)
1012 #define ADDREGNAMES_ARR_INDEX_32(index) \
1013 ADDREGNAMES_ARR_INDEX_16 ((index)), ADDREGNAMES_ARR_INDEX_16 ((index)+16)
1015 #define ADDITIONAL_REGISTER_NAMES \
1017 ADDREGNAMES_ARR_INDEX_32 (0) \
1020 /* Number of actual hardware registers.
1021 The hardware registers are assigned numbers for the compiler
1022 from 0 to just below FIRST_PSEUDO_REGISTER.
1023 All registers that the compiler knows about must be given numbers,
1024 even those that are not normally considered general registers. */
1026 /* There are many other relevant definitions in sh.md's md_constants. */
1028 #define FIRST_GENERAL_REG R0_REG
1029 #define LAST_GENERAL_REG (FIRST_GENERAL_REG + (TARGET_SHMEDIA ? 63 : 15))
1030 #define FIRST_FP_REG DR0_REG
1031 #define LAST_FP_REG (FIRST_FP_REG + \
1032 (TARGET_SHMEDIA_FPU ? 63 : TARGET_SH2E ? 15 : -1))
1033 #define FIRST_XD_REG XD0_REG
1034 #define LAST_XD_REG (FIRST_XD_REG + ((TARGET_SH4 && TARGET_FMOVD) ? 7 : -1))
1035 #define FIRST_TARGET_REG TR0_REG
1036 #define LAST_TARGET_REG (FIRST_TARGET_REG + (TARGET_SHMEDIA ? 7 : -1))
1038 #define GENERAL_REGISTER_P(REGNO) \
1039 IN_RANGE ((REGNO), \
1040 (unsigned HOST_WIDE_INT) FIRST_GENERAL_REG, \
1041 (unsigned HOST_WIDE_INT) LAST_GENERAL_REG)
1043 #define GENERAL_OR_AP_REGISTER_P(REGNO) \
1044 (GENERAL_REGISTER_P (REGNO) || ((REGNO) == AP_REG) \
1045 || ((REGNO) == FRAME_POINTER_REGNUM))
1047 #define FP_REGISTER_P(REGNO) \
1048 ((int) (REGNO) >= FIRST_FP_REG && (int) (REGNO) <= LAST_FP_REG)
1050 #define XD_REGISTER_P(REGNO) \
1051 ((int) (REGNO) >= FIRST_XD_REG && (int) (REGNO) <= LAST_XD_REG)
1053 #define FP_OR_XD_REGISTER_P(REGNO) \
1054 (FP_REGISTER_P (REGNO) || XD_REGISTER_P (REGNO))
1056 #define FP_ANY_REGISTER_P(REGNO) \
1057 (FP_REGISTER_P (REGNO) || XD_REGISTER_P (REGNO) || (REGNO) == FPUL_REG)
1059 #define SPECIAL_REGISTER_P(REGNO) \
1060 ((REGNO) == GBR_REG || (REGNO) == T_REG \
1061 || (REGNO) == MACH_REG || (REGNO) == MACL_REG)
1063 #define TARGET_REGISTER_P(REGNO) \
1064 ((int) (REGNO) >= FIRST_TARGET_REG && (int) (REGNO) <= LAST_TARGET_REG)
1066 #define SHMEDIA_REGISTER_P(REGNO) \
1067 (GENERAL_REGISTER_P (REGNO) || FP_REGISTER_P (REGNO) \
1068 || TARGET_REGISTER_P (REGNO))
1070 /* This is to be used in CONDITIONAL_REGISTER_USAGE, to mark registers
1071 that should be fixed. */
1072 #define VALID_REGISTER_P(REGNO) \
1073 (SHMEDIA_REGISTER_P (REGNO) || XD_REGISTER_P (REGNO) \
1074 || (REGNO) == AP_REG || (REGNO) == RAP_REG \
1075 || (REGNO) == FRAME_POINTER_REGNUM \
1076 || (TARGET_SH1 && (SPECIAL_REGISTER_P (REGNO) || (REGNO) == PR_REG)) \
1077 || (TARGET_SH2E && (REGNO) == FPUL_REG))
1079 /* The mode that should be generally used to store a register by
1080 itself in the stack, or to load it back. */
1081 #define REGISTER_NATURAL_MODE(REGNO) \
1082 (FP_REGISTER_P (REGNO) ? SFmode \
1083 : XD_REGISTER_P (REGNO) ? DFmode \
1084 : TARGET_SHMEDIA && ! HARD_REGNO_CALL_PART_CLOBBERED ((REGNO), DImode) \
1088 #define FIRST_PSEUDO_REGISTER 154
1090 /* Don't count soft frame pointer. */
1091 #define DWARF_FRAME_REGISTERS (FIRST_PSEUDO_REGISTER - 1)
1093 /* 1 for registers that have pervasive standard uses
1094 and are not available for the register allocator.
1096 Mach register is fixed 'cause it's only 10 bits wide for SH1.
1097 It is 32 bits wide for SH2. */
1099 #define FIXED_REGISTERS \
1101 /* Regular registers. */ \
1102 0, 0, 0, 0, 0, 0, 0, 0, \
1103 0, 0, 0, 0, 0, 0, 0, 1, \
1104 /* r16 is reserved, r18 is the former pr. */ \
1105 1, 0, 0, 0, 0, 0, 0, 0, \
1106 /* r24 is reserved for the OS; r25, for the assembler or linker. */ \
1107 /* r26 is a global variable data pointer; r27 is for constants. */ \
1108 1, 1, 1, 1, 0, 0, 0, 0, \
1109 0, 0, 0, 0, 0, 0, 0, 0, \
1110 0, 0, 0, 0, 0, 0, 0, 0, \
1111 0, 0, 0, 0, 0, 0, 0, 0, \
1112 0, 0, 0, 0, 0, 0, 0, 1, \
1113 /* FP registers. */ \
1114 0, 0, 0, 0, 0, 0, 0, 0, \
1115 0, 0, 0, 0, 0, 0, 0, 0, \
1116 0, 0, 0, 0, 0, 0, 0, 0, \
1117 0, 0, 0, 0, 0, 0, 0, 0, \
1118 0, 0, 0, 0, 0, 0, 0, 0, \
1119 0, 0, 0, 0, 0, 0, 0, 0, \
1120 0, 0, 0, 0, 0, 0, 0, 0, \
1121 0, 0, 0, 0, 0, 0, 0, 0, \
1122 /* Branch target registers. */ \
1123 0, 0, 0, 0, 0, 0, 0, 0, \
1124 /* XD registers. */ \
1125 0, 0, 0, 0, 0, 0, 0, 0, \
1126 /*"gbr", "ap", "pr", "t", "mach", "macl", "fpul", "fpscr", */ \
1127 1, 1, 1, 1, 1, 1, 0, 1, \
1132 /* 1 for registers not available across function calls.
1133 These must include the FIXED_REGISTERS and also any
1134 registers that can be used without being saved.
1135 The latter must include the registers where values are returned
1136 and the register where structure-value addresses are passed.
1137 Aside from that, you can include as many other registers as you like. */
1139 #define CALL_USED_REGISTERS \
1141 /* Regular registers. */ \
1142 1, 1, 1, 1, 1, 1, 1, 1, \
1143 /* R8 and R9 are call-clobbered on SH5, but not on earlier SH ABIs. \
1144 Only the lower 32bits of R10-R14 are guaranteed to be preserved \
1145 across SH5 function calls. */ \
1146 0, 0, 0, 0, 0, 0, 0, 1, \
1147 1, 1, 1, 1, 1, 1, 1, 1, \
1148 1, 1, 1, 1, 0, 0, 0, 0, \
1149 0, 0, 0, 0, 1, 1, 1, 1, \
1150 1, 1, 1, 1, 0, 0, 0, 0, \
1151 0, 0, 0, 0, 0, 0, 0, 0, \
1152 0, 0, 0, 0, 1, 1, 1, 1, \
1153 /* FP registers. */ \
1154 1, 1, 1, 1, 1, 1, 1, 1, \
1155 1, 1, 1, 1, 0, 0, 0, 0, \
1156 1, 1, 1, 1, 1, 1, 1, 1, \
1157 1, 1, 1, 1, 1, 1, 1, 1, \
1158 1, 1, 1, 1, 0, 0, 0, 0, \
1159 0, 0, 0, 0, 0, 0, 0, 0, \
1160 0, 0, 0, 0, 0, 0, 0, 0, \
1161 0, 0, 0, 0, 0, 0, 0, 0, \
1162 /* Branch target registers. */ \
1163 1, 1, 1, 1, 1, 0, 0, 0, \
1164 /* XD registers. */ \
1165 1, 1, 1, 1, 1, 1, 0, 0, \
1166 /*"gbr", "ap", "pr", "t", "mach", "macl", "fpul", "fpscr", */ \
1167 1, 1, 1, 1, 1, 1, 1, 1, \
1172 /* CONDITIONAL_REGISTER_USAGE might want to make a register call-used, yet
1173 fixed, like PIC_OFFSET_TABLE_REGNUM. */
1174 #define CALL_REALLY_USED_REGISTERS CALL_USED_REGISTERS
1176 /* Only the lower 32-bits of R10-R14 are guaranteed to be preserved
1177 across SHcompact function calls. We can't tell whether a called
1178 function is SHmedia or SHcompact, so we assume it may be when
1179 compiling SHmedia code with the 32-bit ABI, since that's the only
1180 ABI that can be linked with SHcompact code. */
1181 #define HARD_REGNO_CALL_PART_CLOBBERED(REGNO,MODE) \
1183 && GET_MODE_SIZE (MODE) > 4 \
1184 && (((REGNO) >= FIRST_GENERAL_REG + 10 \
1185 && (REGNO) <= FIRST_GENERAL_REG + 15) \
1186 || TARGET_REGISTER_P (REGNO) \
1187 || (REGNO) == PR_MEDIA_REG))
1189 /* Return number of consecutive hard regs needed starting at reg REGNO
1190 to hold something of mode MODE.
1191 This is ordinarily the length in words of a value of mode MODE
1192 but can be less for certain modes in special long registers.
1194 On the SH all but the XD regs are UNITS_PER_WORD bits wide. */
1196 #define HARD_REGNO_NREGS(REGNO, MODE) \
1197 (XD_REGISTER_P (REGNO) \
1198 ? ((GET_MODE_SIZE (MODE) + (2*UNITS_PER_WORD - 1)) / (2*UNITS_PER_WORD)) \
1199 : (TARGET_SHMEDIA && FP_REGISTER_P (REGNO)) \
1200 ? ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD/2 - 1) / (UNITS_PER_WORD/2)) \
1201 : ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD))
1203 /* Value is 1 if hard register REGNO can hold a value of machine-mode MODE.
1204 We can allow any mode in any general register. The special registers
1205 only allow SImode. Don't allow any mode in the PR. */
1207 /* We cannot hold DCmode values in the XD registers because alter_reg
1208 handles subregs of them incorrectly. We could work around this by
1209 spacing the XD registers like the DR registers, but this would require
1210 additional memory in every compilation to hold larger register vectors.
1211 We could hold SFmode / SCmode values in XD registers, but that
1212 would require a tertiary reload when reloading from / to memory,
1213 and a secondary reload to reload from / to general regs; that
1214 seems to be a loosing proposition. */
1215 /* We want to allow TImode FP regs so that when V4SFmode is loaded as TImode,
1216 it won't be ferried through GP registers first. */
1217 #define HARD_REGNO_MODE_OK(REGNO, MODE) \
1218 (SPECIAL_REGISTER_P (REGNO) ? (MODE) == SImode \
1219 : (REGNO) == FPUL_REG ? (MODE) == SImode || (MODE) == SFmode \
1220 : FP_REGISTER_P (REGNO) && (MODE) == SFmode \
1222 : (MODE) == V2SFmode \
1223 ? ((FP_REGISTER_P (REGNO) && ((REGNO) - FIRST_FP_REG) % 2 == 0) \
1224 || GENERAL_REGISTER_P (REGNO)) \
1225 : (MODE) == V4SFmode \
1226 ? ((FP_REGISTER_P (REGNO) && ((REGNO) - FIRST_FP_REG) % 4 == 0) \
1227 || GENERAL_REGISTER_P (REGNO)) \
1228 : (MODE) == V16SFmode \
1230 ? (FP_REGISTER_P (REGNO) && ((REGNO) - FIRST_FP_REG) % 16 == 0) \
1231 : (REGNO) == FIRST_XD_REG) \
1232 : FP_REGISTER_P (REGNO) \
1233 ? ((MODE) == SFmode || (MODE) == SImode \
1234 || ((TARGET_SH2E || TARGET_SHMEDIA) && (MODE) == SCmode) \
1235 || ((((TARGET_SH4 || TARGET_SH2A_DOUBLE) && (MODE) == DFmode) || (MODE) == DCmode \
1236 || (TARGET_SHMEDIA && ((MODE) == DFmode || (MODE) == DImode \
1237 || (MODE) == V2SFmode || (MODE) == TImode))) \
1238 && (((REGNO) - FIRST_FP_REG) & 1) == 0) \
1239 || ((TARGET_SH4 || TARGET_SHMEDIA) \
1240 && (MODE) == TImode \
1241 && (((REGNO) - FIRST_FP_REG) & 3) == 0)) \
1242 : XD_REGISTER_P (REGNO) \
1243 ? (MODE) == DFmode \
1244 : TARGET_REGISTER_P (REGNO) \
1245 ? ((MODE) == DImode || (MODE) == SImode || (MODE) == PDImode) \
1246 : (REGNO) == PR_REG ? (MODE) == SImode \
1247 : (REGNO) == FPSCR_REG ? (MODE) == PSImode \
1250 /* Value is 1 if it is a good idea to tie two pseudo registers
1251 when one has mode MODE1 and one has mode MODE2.
1252 If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2,
1253 for any hard reg, then this must be 0 for correct output.
1254 That's the case for xd registers: we don't hold SFmode values in
1255 them, so we can't tie an SFmode pseudos with one in another
1256 floating-point mode. */
1258 #define MODES_TIEABLE_P(MODE1, MODE2) \
1259 ((MODE1) == (MODE2) \
1260 || (TARGET_SHMEDIA \
1261 && GET_MODE_SIZE (MODE1) == GET_MODE_SIZE (MODE2) \
1262 && INTEGRAL_MODE_P (MODE1) && INTEGRAL_MODE_P (MODE2)) \
1263 || (GET_MODE_CLASS (MODE1) == GET_MODE_CLASS (MODE2) \
1264 && (TARGET_SHMEDIA ? ((GET_MODE_SIZE (MODE1) <= 4) \
1265 && (GET_MODE_SIZE (MODE2) <= 4)) \
1266 : ((MODE1) != SFmode && (MODE2) != SFmode))))
1268 /* A C expression that is nonzero if hard register NEW_REG can be
1269 considered for use as a rename register for OLD_REG register */
1271 #define HARD_REGNO_RENAME_OK(OLD_REG, NEW_REG) \
1272 sh_hard_regno_rename_ok (OLD_REG, NEW_REG)
1274 /* Specify the registers used for certain standard purposes.
1275 The values of these macros are register numbers. */
1277 /* Define this if the program counter is overloaded on a register. */
1278 /* #define PC_REGNUM 15*/
1280 /* Register to use for pushing function arguments. */
1281 #define STACK_POINTER_REGNUM SP_REG
1283 /* Base register for access to local variables of the function. */
1284 #define HARD_FRAME_POINTER_REGNUM FP_REG
1286 /* Base register for access to local variables of the function. */
1287 #define FRAME_POINTER_REGNUM 153
1289 /* Fake register that holds the address on the stack of the
1290 current function's return address. */
1291 #define RETURN_ADDRESS_POINTER_REGNUM RAP_REG
1293 /* Register to hold the addressing base for position independent
1294 code access to data items. */
1295 #define PIC_OFFSET_TABLE_REGNUM (flag_pic ? PIC_REG : INVALID_REGNUM)
1297 #define GOT_SYMBOL_NAME "*_GLOBAL_OFFSET_TABLE_"
1299 /* Value should be nonzero if functions must have frame pointers.
1300 Zero means the frame pointer need not be set up (and parms may be accessed
1301 via the stack pointer) in functions that seem suitable. */
1303 #define FRAME_POINTER_REQUIRED 0
1305 /* Definitions for register eliminations.
1307 We have three registers that can be eliminated on the SH. First, the
1308 frame pointer register can often be eliminated in favor of the stack
1309 pointer register. Secondly, the argument pointer register can always be
1310 eliminated; it is replaced with either the stack or frame pointer.
1311 Third, there is the return address pointer, which can also be replaced
1312 with either the stack or the frame pointer. */
1314 /* This is an array of structures. Each structure initializes one pair
1315 of eliminable registers. The "from" register number is given first,
1316 followed by "to". Eliminations of the same "from" register are listed
1317 in order of preference. */
1319 /* If you add any registers here that are not actually hard registers,
1320 and that have any alternative of elimination that doesn't always
1321 apply, you need to amend calc_live_regs to exclude it, because
1322 reload spills all eliminable registers where it sees an
1323 can_eliminate == 0 entry, thus making them 'live' .
1324 If you add any hard registers that can be eliminated in different
1325 ways, you have to patch reload to spill them only when all alternatives
1326 of elimination fail. */
1328 #define ELIMINABLE_REGS \
1329 {{ HARD_FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
1330 { FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
1331 { FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}, \
1332 { RETURN_ADDRESS_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
1333 { RETURN_ADDRESS_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}, \
1334 { ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
1335 { ARG_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM},}
1337 /* Given FROM and TO register numbers, say whether this elimination
1339 #define CAN_ELIMINATE(FROM, TO) \
1340 (!((FROM) == HARD_FRAME_POINTER_REGNUM && FRAME_POINTER_REQUIRED))
1342 /* Define the offset between two registers, one to be eliminated, and the other
1343 its replacement, at the start of a routine. */
1345 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
1346 OFFSET = initial_elimination_offset ((FROM), (TO))
1348 /* Base register for access to arguments of the function. */
1349 #define ARG_POINTER_REGNUM AP_REG
1351 /* Register in which the static-chain is passed to a function. */
1352 #define STATIC_CHAIN_REGNUM (TARGET_SH5 ? 1 : 3)
1354 /* Don't default to pcc-struct-return, because we have already specified
1355 exactly how to return structures in the TARGET_RETURN_IN_MEMORY
1358 #define DEFAULT_PCC_STRUCT_RETURN 0
1360 #define SHMEDIA_REGS_STACK_ADJUST() \
1361 (TARGET_SHCOMPACT && current_function_has_nonlocal_label \
1362 ? (8 * (/* r28-r35 */ 8 + /* r44-r59 */ 16 + /* tr5-tr7 */ 3) \
1363 + (TARGET_FPU_ANY ? 4 * (/* fr36 - fr63 */ 28) : 0)) \
1367 /* Define the classes of registers for register constraints in the
1368 machine description. Also define ranges of constants.
1370 One of the classes must always be named ALL_REGS and include all hard regs.
1371 If there is more than one class, another class must be named NO_REGS
1372 and contain no registers.
1374 The name GENERAL_REGS must be the name of a class (or an alias for
1375 another name such as ALL_REGS). This is the class of registers
1376 that is allowed by "g" or "r" in a register constraint.
1377 Also, registers outside this class are allocated only when
1378 instructions express preferences for them.
1380 The classes must be numbered in nondecreasing order; that is,
1381 a larger-numbered class must never be contained completely
1382 in a smaller-numbered class.
1384 For any two classes, it is very desirable that there be another
1385 class that represents their union. */
1387 /* The SH has two sorts of general registers, R0 and the rest. R0 can
1388 be used as the destination of some of the arithmetic ops. There are
1389 also some special purpose registers; the T bit register, the
1390 Procedure Return Register and the Multiply Accumulate Registers. */
1391 /* Place GENERAL_REGS after FPUL_REGS so that it will be preferred by
1392 reg_class_subunion. We don't want to have an actual union class
1393 of these, because it would only be used when both classes are calculated
1394 to give the same cost, but there is only one FPUL register.
1395 Besides, regclass fails to notice the different REGISTER_MOVE_COSTS
1396 applying to the actual instruction alternative considered. E.g., the
1397 y/r alternative of movsi_ie is considered to have no more cost that
1398 the r/r alternative, which is patently untrue. */
1422 #define N_REG_CLASSES (int) LIM_REG_CLASSES
1424 /* Give names of register classes as strings for dump file. */
1425 #define REG_CLASS_NAMES \
1440 "GENERAL_FP_REGS", \
1441 "GENERAL_DF_REGS", \
1446 /* Define which registers fit in which classes.
1447 This is an initializer for a vector of HARD_REG_SET
1448 of length N_REG_CLASSES. */
1450 #define REG_CLASS_CONTENTS \
1453 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 }, \
1455 { 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000 }, \
1457 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00040000 }, \
1459 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00080000 }, \
1461 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00300000 }, \
1463 { 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00400000 }, \
1464 /* SIBCALL_REGS: Initialized in CONDITIONAL_REGISTER_USAGE. */ \
1465 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 }, \
1466 /* GENERAL_REGS: */ \
1467 { 0xffffffff, 0xffffffff, 0x00000000, 0x00000000, 0x03020000 }, \
1469 { 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000 }, \
1471 { 0x00000000, 0x00000000, 0xffffffff, 0xffffffff, 0x00000000 }, \
1472 /* DF_HI_REGS: Initialized in CONDITIONAL_REGISTER_USAGE. */ \
1473 { 0x00000000, 0x00000000, 0xffffffff, 0xffffffff, 0x0000ff00 }, \
1475 { 0x00000000, 0x00000000, 0xffffffff, 0xffffffff, 0x0000ff00 }, \
1477 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00800000 }, \
1478 /* GENERAL_FP_REGS: */ \
1479 { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x03020000 }, \
1480 /* GENERAL_DF_REGS: */ \
1481 { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x0302ff00 }, \
1482 /* TARGET_REGS: */ \
1483 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000000ff }, \
1485 { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x03ffffff }, \
1488 /* The same information, inverted:
1489 Return the class number of the smallest class containing
1490 reg number REGNO. This could be a conditional expression
1491 or could index an array. */
1493 extern enum reg_class regno_reg_class[FIRST_PSEUDO_REGISTER];
1494 #define REGNO_REG_CLASS(REGNO) regno_reg_class[(REGNO)]
1496 /* When defined, the compiler allows registers explicitly used in the
1497 rtl to be used as spill registers but prevents the compiler from
1498 extending the lifetime of these registers. */
1500 #define SMALL_REGISTER_CLASSES (! TARGET_SHMEDIA)
1502 /* The order in which register should be allocated. */
1503 /* Sometimes FP0_REGS becomes the preferred class of a floating point pseudo,
1504 and GENERAL_FP_REGS the alternate class. Since FP0 is likely to be
1505 spilled or used otherwise, we better have the FP_REGS allocated first. */
1506 #define REG_ALLOC_ORDER \
1507 {/* Caller-saved FPRs */ \
1508 65, 66, 67, 68, 69, 70, 71, 64, \
1509 72, 73, 74, 75, 80, 81, 82, 83, \
1510 84, 85, 86, 87, 88, 89, 90, 91, \
1511 92, 93, 94, 95, 96, 97, 98, 99, \
1512 /* Callee-saved FPRs */ \
1513 76, 77, 78, 79,100,101,102,103, \
1514 104,105,106,107,108,109,110,111, \
1515 112,113,114,115,116,117,118,119, \
1516 120,121,122,123,124,125,126,127, \
1517 136,137,138,139,140,141,142,143, \
1519 /* Caller-saved GPRs (except 8/9 on SH1-4) */ \
1520 1, 2, 3, 7, 6, 5, 4, 0, \
1521 8, 9, 17, 19, 20, 21, 22, 23, \
1522 36, 37, 38, 39, 40, 41, 42, 43, \
1524 /* SH1-4 callee-saved saved GPRs / SH5 partially-saved GPRs */ \
1525 10, 11, 12, 13, 14, 18, \
1526 /* SH5 callee-saved GPRs */ \
1527 28, 29, 30, 31, 32, 33, 34, 35, \
1528 44, 45, 46, 47, 48, 49, 50, 51, \
1529 52, 53, 54, 55, 56, 57, 58, 59, \
1531 /* SH5 branch target registers */ \
1532 128,129,130,131,132,133,134,135, \
1533 /* Fixed registers */ \
1534 15, 16, 24, 25, 26, 27, 63,144, \
1535 145,146,147,148,149,152,153 }
1537 /* The class value for index registers, and the one for base regs. */
1538 #define INDEX_REG_CLASS \
1539 (!ALLOW_INDEXED_ADDRESS ? NO_REGS : TARGET_SHMEDIA ? GENERAL_REGS : R0_REGS)
1540 #define BASE_REG_CLASS GENERAL_REGS
1542 /* Get reg_class from a letter such as appears in the machine
1544 extern enum reg_class reg_class_from_letter[];
1546 /* We might use 'Rxx' constraints in the future for exotic reg classes.*/
1547 #define REG_CLASS_FROM_CONSTRAINT(C, STR) \
1548 (ISLOWER (C) ? reg_class_from_letter[(C)-'a'] : NO_REGS )
1550 /* Overview of uppercase letter constraints:
1551 A: Addresses (constraint len == 3)
1552 Ac4: sh4 cache operations
1553 Ac5: sh5 cache operations
1554 Bxx: miscellaneous constraints
1555 Bsc: SCRATCH - for the scratch register in movsi_ie in the
1557 C: Constants other than only CONST_INT (constraint len == 3)
1558 Css: signed 16-bit constant, literal or symbolic
1559 Csu: unsigned 16-bit constant, literal or symbolic
1560 Csy: label or symbol
1561 Cpg: non-explicit constants that can be directly loaded into a general
1562 purpose register in PIC code. like 's' except we don't allow
1564 IJKLMNOP: CONT_INT constants
1566 J16: 0xffffffff00000000 | 0x00000000ffffffff
1567 Kxx: unsigned xx bit
1571 Q: pc relative load operand
1572 Rxx: reserved for exotic register classes.
1573 S: extra memory (storage) constraints (constraint len == 3)
1574 Sua: unaligned memory operations
1578 unused CONST_INT constraint letters: LO
1579 unused EXTRA_CONSTRAINT letters: D T U Y */
1581 #define CONSTRAINT_LEN(C,STR) \
1582 (((C) == 'A' || (C) == 'B' || (C) == 'C' \
1583 || (C) == 'I' || (C) == 'J' || (C) == 'K' || (C) == 'P' \
1584 || (C) == 'R' || (C) == 'S') \
1585 ? 3 : DEFAULT_CONSTRAINT_LEN ((C), (STR)))
1587 /* The letters I, J, K, L and M in a register constraint string
1588 can be used to stand for particular ranges of immediate operands.
1589 This macro defines what the ranges are.
1590 C is the letter, and VALUE is a constant value.
1591 Return 1 if VALUE is in the range specified by C.
1592 I08: arithmetic operand -127..128, as used in add, sub, etc
1593 I16: arithmetic operand -32768..32767, as used in SHmedia movi
1594 K16: arithmetic operand 0..65535, as used in SHmedia shori
1595 P27: shift operand 1,2,8 or 16
1596 K08: logical operand 0..255, as used in and, or, etc.
1599 I06: arithmetic operand -32..31, as used in SHmedia beqi, bnei and xori
1600 I10: arithmetic operand -512..511, as used in SHmedia andi, ori
1603 #define CONST_OK_FOR_I06(VALUE) (((HOST_WIDE_INT)(VALUE)) >= -32 \
1604 && ((HOST_WIDE_INT)(VALUE)) <= 31)
1605 #define CONST_OK_FOR_I08(VALUE) (((HOST_WIDE_INT)(VALUE))>= -128 \
1606 && ((HOST_WIDE_INT)(VALUE)) <= 127)
1607 #define CONST_OK_FOR_I10(VALUE) (((HOST_WIDE_INT)(VALUE)) >= -512 \
1608 && ((HOST_WIDE_INT)(VALUE)) <= 511)
1609 #define CONST_OK_FOR_I16(VALUE) (((HOST_WIDE_INT)(VALUE)) >= -32768 \
1610 && ((HOST_WIDE_INT)(VALUE)) <= 32767)
1611 #define CONST_OK_FOR_I20(VALUE) (((HOST_WIDE_INT)(VALUE)) >= -524288 \
1612 && ((HOST_WIDE_INT)(VALUE)) <= 524287 \
1614 #define CONST_OK_FOR_I(VALUE, STR) \
1615 ((STR)[1] == '0' && (STR)[2] == '6' ? CONST_OK_FOR_I06 (VALUE) \
1616 : (STR)[1] == '0' && (STR)[2] == '8' ? CONST_OK_FOR_I08 (VALUE) \
1617 : (STR)[1] == '1' && (STR)[2] == '0' ? CONST_OK_FOR_I10 (VALUE) \
1618 : (STR)[1] == '1' && (STR)[2] == '6' ? CONST_OK_FOR_I16 (VALUE) \
1619 : (STR)[1] == '2' && (STR)[2] == '0' ? CONST_OK_FOR_I20 (VALUE) \
1622 #define CONST_OK_FOR_J16(VALUE) \
1623 ((HOST_BITS_PER_WIDE_INT >= 64 && (VALUE) == (HOST_WIDE_INT) 0xffffffff) \
1624 || (HOST_BITS_PER_WIDE_INT >= 64 && (VALUE) == (HOST_WIDE_INT) -1 << 32))
1625 #define CONST_OK_FOR_J(VALUE, STR) \
1626 ((STR)[1] == '1' && (STR)[2] == '6' ? CONST_OK_FOR_J16 (VALUE) \
1629 #define CONST_OK_FOR_K08(VALUE) (((HOST_WIDE_INT)(VALUE))>= 0 \
1630 && ((HOST_WIDE_INT)(VALUE)) <= 255)
1631 #define CONST_OK_FOR_K16(VALUE) (((HOST_WIDE_INT)(VALUE))>= 0 \
1632 && ((HOST_WIDE_INT)(VALUE)) <= 65535)
1633 #define CONST_OK_FOR_K(VALUE, STR) \
1634 ((STR)[1] == '0' && (STR)[2] == '8' ? CONST_OK_FOR_K08 (VALUE) \
1635 : (STR)[1] == '1' && (STR)[2] == '6' ? CONST_OK_FOR_K16 (VALUE) \
1637 #define CONST_OK_FOR_P27(VALUE) \
1638 ((VALUE)==1||(VALUE)==2||(VALUE)==8||(VALUE)==16)
1639 #define CONST_OK_FOR_P(VALUE, STR) \
1640 ((STR)[1] == '2' && (STR)[2] == '7' ? CONST_OK_FOR_P27 (VALUE) \
1642 #define CONST_OK_FOR_M(VALUE) ((VALUE)==1)
1643 #define CONST_OK_FOR_N(VALUE) ((VALUE)==0)
1644 #define CONST_OK_FOR_CONSTRAINT_P(VALUE, C, STR) \
1645 ((C) == 'I' ? CONST_OK_FOR_I ((VALUE), (STR)) \
1646 : (C) == 'J' ? CONST_OK_FOR_J ((VALUE), (STR)) \
1647 : (C) == 'K' ? CONST_OK_FOR_K ((VALUE), (STR)) \
1648 : (C) == 'M' ? CONST_OK_FOR_M (VALUE) \
1649 : (C) == 'N' ? CONST_OK_FOR_N (VALUE) \
1650 : (C) == 'P' ? CONST_OK_FOR_P ((VALUE), (STR)) \
1653 /* Similar, but for floating constants, and defining letters G and H.
1654 Here VALUE is the CONST_DOUBLE rtx itself. */
1656 #define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) \
1657 ((C) == 'G' ? (fp_zero_operand (VALUE) && fldi_ok ()) \
1658 : (C) == 'H' ? (fp_one_operand (VALUE) && fldi_ok ()) \
1661 /* Given an rtx X being reloaded into a reg required to be
1662 in class CLASS, return the class of reg to actually use.
1663 In general this is just CLASS; but on some machines
1664 in some cases it is preferable to use a more restrictive class. */
1666 #define PREFERRED_RELOAD_CLASS(X, CLASS) \
1667 ((CLASS) == NO_REGS && TARGET_SHMEDIA \
1668 && (GET_CODE (X) == CONST_DOUBLE \
1669 || GET_CODE (X) == SYMBOL_REF \
1670 || PIC_DIRECT_ADDR_P (X)) \
1675 #define SECONDARY_INOUT_RELOAD_CLASS(CLASS,MODE,X,ELSE) \
1676 ((((REGCLASS_HAS_FP_REG (CLASS) \
1677 && (GET_CODE (X) == REG \
1678 && (GENERAL_OR_AP_REGISTER_P (REGNO (X)) \
1679 || (FP_REGISTER_P (REGNO (X)) && (MODE) == SImode \
1680 && TARGET_FMOVD)))) \
1681 || (REGCLASS_HAS_GENERAL_REG (CLASS) \
1682 && GET_CODE (X) == REG \
1683 && FP_REGISTER_P (REGNO (X)))) \
1684 && ! TARGET_SHMEDIA \
1685 && ((MODE) == SFmode || (MODE) == SImode)) \
1687 : (((CLASS) == FPUL_REGS \
1688 || (REGCLASS_HAS_FP_REG (CLASS) \
1689 && ! TARGET_SHMEDIA && MODE == SImode)) \
1690 && (GET_CODE (X) == MEM \
1691 || (GET_CODE (X) == REG \
1692 && (REGNO (X) >= FIRST_PSEUDO_REGISTER \
1693 || REGNO (X) == T_REG \
1694 || system_reg_operand (X, VOIDmode))))) \
1696 : (((CLASS) == TARGET_REGS \
1697 || (TARGET_SHMEDIA && (CLASS) == SIBCALL_REGS)) \
1698 && !EXTRA_CONSTRAINT_Csy (X) \
1699 && (GET_CODE (X) != REG || ! GENERAL_REGISTER_P (REGNO (X)))) \
1701 : (((CLASS) == MAC_REGS || (CLASS) == PR_REGS) \
1702 && GET_CODE (X) == REG && ! GENERAL_REGISTER_P (REGNO (X)) \
1703 && (CLASS) != REGNO_REG_CLASS (REGNO (X))) \
1705 : ((CLASS) != GENERAL_REGS && GET_CODE (X) == REG \
1706 && TARGET_REGISTER_P (REGNO (X))) \
1707 ? GENERAL_REGS : (ELSE))
1709 #define SECONDARY_OUTPUT_RELOAD_CLASS(CLASS,MODE,X) \
1710 SECONDARY_INOUT_RELOAD_CLASS(CLASS,MODE,X,NO_REGS)
1712 #define SECONDARY_INPUT_RELOAD_CLASS(CLASS,MODE,X) \
1713 ((REGCLASS_HAS_FP_REG (CLASS) \
1714 && ! TARGET_SHMEDIA \
1715 && immediate_operand ((X), (MODE)) \
1716 && ! ((fp_zero_operand (X) || fp_one_operand (X)) \
1717 && (MODE) == SFmode && fldi_ok ())) \
1719 : ((CLASS) == FPUL_REGS \
1720 && ((GET_CODE (X) == REG \
1721 && (REGNO (X) == MACL_REG || REGNO (X) == MACH_REG \
1722 || REGNO (X) == T_REG)) \
1723 || GET_CODE (X) == PLUS)) \
1725 : (CLASS) == FPUL_REGS && immediate_operand ((X), (MODE)) \
1726 ? (GET_CODE (X) == CONST_INT && CONST_OK_FOR_I08 (INTVAL (X)) \
1729 : ((CLASS) == FPSCR_REGS \
1730 && ((GET_CODE (X) == REG && REGNO (X) >= FIRST_PSEUDO_REGISTER) \
1731 || (GET_CODE (X) == MEM && GET_CODE (XEXP ((X), 0)) == PLUS)))\
1733 : (REGCLASS_HAS_FP_REG (CLASS) \
1735 && immediate_operand ((X), (MODE)) \
1736 && (X) != CONST0_RTX (GET_MODE (X)) \
1737 && GET_MODE (X) != V4SFmode) \
1739 : (((MODE) == QImode || (MODE) == HImode) \
1740 && TARGET_SHMEDIA && inqhi_operand ((X), (MODE))) \
1742 : (TARGET_SHMEDIA && (CLASS) == GENERAL_REGS \
1743 && (GET_CODE (X) == LABEL_REF || PIC_DIRECT_ADDR_P (X))) \
1745 : SECONDARY_INOUT_RELOAD_CLASS((CLASS),(MODE),(X), NO_REGS))
1748 /* Return the maximum number of consecutive registers
1749 needed to represent mode MODE in a register of class CLASS.
1751 If TARGET_SHMEDIA, we need two FP registers per word.
1752 Otherwise we will need at most one register per word. */
1753 #define CLASS_MAX_NREGS(CLASS, MODE) \
1755 && TEST_HARD_REG_BIT (reg_class_contents[CLASS], FIRST_FP_REG) \
1756 ? (GET_MODE_SIZE (MODE) + UNITS_PER_WORD/2 - 1) / (UNITS_PER_WORD/2) \
1757 : (GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
1759 /* If defined, gives a class of registers that cannot be used as the
1760 operand of a SUBREG that changes the mode of the object illegally. */
1761 /* ??? We need to renumber the internal numbers for the frnn registers
1762 when in little endian in order to allow mode size changes. */
1764 #define CANNOT_CHANGE_MODE_CLASS(FROM, TO, CLASS) \
1765 sh_cannot_change_mode_class (FROM, TO, CLASS)
1767 /* Stack layout; function entry, exit and calling. */
1769 /* Define the number of registers that can hold parameters.
1770 These macros are used only in other macro definitions below. */
1772 #define NPARM_REGS(MODE) \
1773 (TARGET_FPU_ANY && (MODE) == SFmode \
1774 ? (TARGET_SH5 ? 12 : 8) \
1775 : (TARGET_SH4 || TARGET_SH2A_DOUBLE) && (GET_MODE_CLASS (MODE) == MODE_FLOAT \
1776 || GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT) \
1777 ? (TARGET_SH5 ? 12 : 8) \
1778 : (TARGET_SH5 ? 8 : 4))
1780 #define FIRST_PARM_REG (FIRST_GENERAL_REG + (TARGET_SH5 ? 2 : 4))
1781 #define FIRST_RET_REG (FIRST_GENERAL_REG + (TARGET_SH5 ? 2 : 0))
1783 #define FIRST_FP_PARM_REG (FIRST_FP_REG + (TARGET_SH5 ? 0 : 4))
1784 #define FIRST_FP_RET_REG FIRST_FP_REG
1786 /* Define this if pushing a word on the stack
1787 makes the stack pointer a smaller address. */
1788 #define STACK_GROWS_DOWNWARD
1790 /* Define this macro to nonzero if the addresses of local variable slots
1791 are at negative offsets from the frame pointer. */
1792 #define FRAME_GROWS_DOWNWARD 1
1794 /* Offset from the frame pointer to the first local variable slot to
1796 #define STARTING_FRAME_OFFSET 0
1798 /* If we generate an insn to push BYTES bytes,
1799 this says how many the stack pointer really advances by. */
1800 /* Don't define PUSH_ROUNDING, since the hardware doesn't do this.
1801 When PUSH_ROUNDING is not defined, PARM_BOUNDARY will cause gcc to
1802 do correct alignment. */
1804 #define PUSH_ROUNDING(NPUSHED) (((NPUSHED) + 3) & ~3)
1807 /* Offset of first parameter from the argument pointer register value. */
1808 #define FIRST_PARM_OFFSET(FNDECL) 0
1810 /* Value is the number of byte of arguments automatically
1811 popped when returning from a subroutine call.
1812 FUNDECL is the declaration node of the function (as a tree),
1813 FUNTYPE is the data type of the function (as a tree),
1814 or for a library call it is an identifier node for the subroutine name.
1815 SIZE is the number of bytes of arguments passed on the stack.
1817 On the SH, the caller does not pop any of its arguments that were passed
1819 #define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE) 0
1821 /* Value is the number of bytes of arguments automatically popped when
1822 calling a subroutine.
1823 CUM is the accumulated argument list.
1825 On SHcompact, the call trampoline pops arguments off the stack. */
1826 #define CALL_POPS_ARGS(CUM) (TARGET_SHCOMPACT ? (CUM).stack_regs * 8 : 0)
1828 /* Some subroutine macros specific to this machine. */
1830 #define BASE_RETURN_VALUE_REG(MODE) \
1831 ((TARGET_FPU_ANY && ((MODE) == SFmode)) \
1832 ? FIRST_FP_RET_REG \
1833 : TARGET_FPU_ANY && (MODE) == SCmode \
1834 ? FIRST_FP_RET_REG \
1835 : (TARGET_FPU_DOUBLE \
1836 && ((MODE) == DFmode || (MODE) == SFmode \
1837 || (MODE) == DCmode || (MODE) == SCmode )) \
1838 ? FIRST_FP_RET_REG \
1841 #define BASE_ARG_REG(MODE) \
1842 ((TARGET_SH2E && ((MODE) == SFmode)) \
1843 ? FIRST_FP_PARM_REG \
1844 : (TARGET_SH4 || TARGET_SH2A_DOUBLE) && (GET_MODE_CLASS (MODE) == MODE_FLOAT \
1845 || GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT)\
1846 ? FIRST_FP_PARM_REG \
1849 /* Define how to find the value returned by a function.
1850 VALTYPE is the data type of the value (as a tree).
1851 If the precise function being called is known, FUNC is its FUNCTION_DECL;
1852 otherwise, FUNC is 0.
1853 For the SH, this is like LIBCALL_VALUE, except that we must change the
1854 mode like PROMOTE_MODE does.
1855 ??? PROMOTE_MODE is ignored for non-scalar types. The set of types
1856 tested here has to be kept in sync with the one in explow.c:promote_mode. */
1858 #define FUNCTION_VALUE(VALTYPE, FUNC) \
1860 ((GET_MODE_CLASS (TYPE_MODE (VALTYPE)) == MODE_INT \
1861 && GET_MODE_SIZE (TYPE_MODE (VALTYPE)) < 4 \
1862 && (TREE_CODE (VALTYPE) == INTEGER_TYPE \
1863 || TREE_CODE (VALTYPE) == ENUMERAL_TYPE \
1864 || TREE_CODE (VALTYPE) == BOOLEAN_TYPE \
1865 || TREE_CODE (VALTYPE) == REAL_TYPE \
1866 || TREE_CODE (VALTYPE) == OFFSET_TYPE)) \
1867 && sh_promote_prototypes (VALTYPE) \
1868 ? (TARGET_SHMEDIA64 ? DImode : SImode) : TYPE_MODE (VALTYPE)), \
1869 BASE_RETURN_VALUE_REG (TYPE_MODE (VALTYPE)))
1871 /* Define how to find the value returned by a library function
1872 assuming the value has mode MODE. */
1873 #define LIBCALL_VALUE(MODE) \
1874 gen_rtx_REG ((MODE), BASE_RETURN_VALUE_REG (MODE));
1876 /* 1 if N is a possible register number for a function value. */
1877 #define FUNCTION_VALUE_REGNO_P(REGNO) \
1878 ((REGNO) == FIRST_RET_REG || (TARGET_SH2E && (REGNO) == FIRST_FP_RET_REG) \
1879 || (TARGET_SHMEDIA_FPU && (REGNO) == FIRST_FP_RET_REG))
1881 /* 1 if N is a possible register number for function argument passing. */
1882 /* ??? There are some callers that pass REGNO as int, and others that pass
1883 it as unsigned. We get warnings unless we do casts everywhere. */
1884 #define FUNCTION_ARG_REGNO_P(REGNO) \
1885 (((unsigned) (REGNO) >= (unsigned) FIRST_PARM_REG \
1886 && (unsigned) (REGNO) < (unsigned) (FIRST_PARM_REG + NPARM_REGS (SImode)))\
1887 || (TARGET_FPU_ANY \
1888 && (unsigned) (REGNO) >= (unsigned) FIRST_FP_PARM_REG \
1889 && (unsigned) (REGNO) < (unsigned) (FIRST_FP_PARM_REG \
1890 + NPARM_REGS (SFmode))))
1892 /* Define a data type for recording info about an argument list
1893 during the scan of that argument list. This data type should
1894 hold all necessary information about the function itself
1895 and about the args processed so far, enough to enable macros
1896 such as FUNCTION_ARG to determine where the next arg should go.
1898 On SH, this is a single integer, which is a number of words
1899 of arguments scanned so far (including the invisible argument,
1900 if any, which holds the structure-value-address).
1901 Thus NARGREGS or more means all following args should go on the stack. */
1903 enum sh_arg_class { SH_ARG_INT = 0, SH_ARG_FLOAT = 1 };
1907 /* Nonzero if a prototype is available for the function. */
1909 /* The number of an odd floating-point register, that should be used
1910 for the next argument of type float. */
1911 int free_single_fp_reg;
1912 /* Whether we're processing an outgoing function call. */
1914 /* The number of general-purpose registers that should have been
1915 used to pass partial arguments, that are passed totally on the
1916 stack. On SHcompact, a call trampoline will pop them off the
1917 stack before calling the actual function, and, if the called
1918 function is implemented in SHcompact mode, the incoming arguments
1919 decoder will push such arguments back onto the stack. For
1920 incoming arguments, STACK_REGS also takes into account other
1921 arguments passed by reference, that the decoder will also push
1924 /* The number of general-purpose registers that should have been
1925 used to pass arguments, if the arguments didn't have to be passed
1928 /* Set as by shcompact_byref if the current argument is to be passed
1932 /* call_cookie is a bitmask used by call expanders, as well as
1933 function prologue and epilogues, to allow SHcompact to comply
1934 with the SH5 32-bit ABI, that requires 64-bit registers to be
1935 used even though only the lower 32-bit half is visible in
1936 SHcompact mode. The strategy is to call SHmedia trampolines.
1938 The alternatives for each of the argument-passing registers are
1939 (a) leave it unchanged; (b) pop it off the stack; (c) load its
1940 contents from the address in it; (d) add 8 to it, storing the
1941 result in the next register, then (c); (e) copy it from some
1942 floating-point register,
1944 Regarding copies from floating-point registers, r2 may only be
1945 copied from dr0. r3 may be copied from dr0 or dr2. r4 maybe
1946 copied from dr0, dr2 or dr4. r5 maybe copied from dr0, dr2,
1947 dr4 or dr6. r6 may be copied from dr0, dr2, dr4, dr6 or dr8.
1948 r7 through to r9 may be copied from dr0, dr2, dr4, dr8, dr8 or
1951 The bit mask is structured as follows:
1953 - 1 bit to tell whether to set up a return trampoline.
1955 - 3 bits to count the number consecutive registers to pop off the
1958 - 4 bits for each of r9, r8, r7 and r6.
1960 - 3 bits for each of r5, r4, r3 and r2.
1962 - 3 bits set to 0 (the most significant ones)
1965 1098 7654 3210 9876 5432 1098 7654 3210
1966 FLPF LPFL PFLP FFLP FFLP FFLP FFLP SSST
1967 2223 3344 4555 6666 7777 8888 9999 SSS-
1969 - If F is set, the register must be copied from an FP register,
1970 whose number is encoded in the remaining bits.
1972 - Else, if L is set, the register must be loaded from the address
1973 contained in it. If the P bit is *not* set, the address of the
1974 following dword should be computed first, and stored in the
1977 - Else, if P is set, the register alone should be popped off the
1980 - After all this processing, the number of registers represented
1981 in SSS will be popped off the stack. This is an optimization
1982 for pushing/popping consecutive registers, typically used for
1983 varargs and large arguments partially passed in registers.
1985 - If T is set, a return trampoline will be set up for 64-bit
1986 return values to be split into 2 32-bit registers. */
1989 /* This is set to nonzero when the call in question must use the Renesas ABI,
1990 even without the -mrenesas option. */
1994 #define CALL_COOKIE_RET_TRAMP_SHIFT 0
1995 #define CALL_COOKIE_RET_TRAMP(VAL) ((VAL) << CALL_COOKIE_RET_TRAMP_SHIFT)
1996 #define CALL_COOKIE_STACKSEQ_SHIFT 1
1997 #define CALL_COOKIE_STACKSEQ(VAL) ((VAL) << CALL_COOKIE_STACKSEQ_SHIFT)
1998 #define CALL_COOKIE_STACKSEQ_GET(COOKIE) \
1999 (((COOKIE) >> CALL_COOKIE_STACKSEQ_SHIFT) & 7)
2000 #define CALL_COOKIE_INT_REG_SHIFT(REG) \
2001 (4 * (7 - (REG)) + (((REG) <= 2) ? ((REG) - 2) : 1) + 3)
2002 #define CALL_COOKIE_INT_REG(REG, VAL) \
2003 ((VAL) << CALL_COOKIE_INT_REG_SHIFT (REG))
2004 #define CALL_COOKIE_INT_REG_GET(COOKIE, REG) \
2005 (((COOKIE) >> CALL_COOKIE_INT_REG_SHIFT (REG)) & ((REG) < 4 ? 7 : 15))
2007 #define CUMULATIVE_ARGS struct sh_args
2009 #define GET_SH_ARG_CLASS(MODE) \
2010 ((TARGET_FPU_ANY && (MODE) == SFmode) \
2012 /* There's no mention of complex float types in the SH5 ABI, so we
2013 should presumably handle them as aggregate types. */ \
2014 : TARGET_SH5 && GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT \
2016 : TARGET_FPU_DOUBLE && (GET_MODE_CLASS (MODE) == MODE_FLOAT \
2017 || GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT) \
2018 ? SH_ARG_FLOAT : SH_ARG_INT)
2020 #define ROUND_ADVANCE(SIZE) \
2021 (((SIZE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
2023 /* Round a register number up to a proper boundary for an arg of mode
2026 The SH doesn't care about double alignment, so we only
2027 round doubles to even regs when asked to explicitly. */
2029 #define ROUND_REG(CUM, MODE) \
2030 (((TARGET_ALIGN_DOUBLE \
2031 || ((TARGET_SH4 || TARGET_SH2A_DOUBLE) && ((MODE) == DFmode || (MODE) == DCmode) \
2032 && (CUM).arg_count[(int) SH_ARG_FLOAT] < NPARM_REGS (MODE)))\
2033 && GET_MODE_UNIT_SIZE ((MODE)) > UNITS_PER_WORD) \
2034 ? ((CUM).arg_count[(int) GET_SH_ARG_CLASS (MODE)] \
2035 + ((CUM).arg_count[(int) GET_SH_ARG_CLASS (MODE)] & 1)) \
2036 : (CUM).arg_count[(int) GET_SH_ARG_CLASS (MODE)])
2038 /* Initialize a variable CUM of type CUMULATIVE_ARGS
2039 for a call to a function whose data type is FNTYPE.
2040 For a library call, FNTYPE is 0.
2042 On SH, the offset always starts at 0: the first parm reg is always
2043 the same reg for a given argument class.
2045 For TARGET_HITACHI, the structure value pointer is passed in memory. */
2047 #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, FNDECL, N_NAMED_ARGS) \
2048 sh_init_cumulative_args (& (CUM), (FNTYPE), (LIBNAME), (FNDECL), (N_NAMED_ARGS), VOIDmode)
2050 #define INIT_CUMULATIVE_LIBCALL_ARGS(CUM, MODE, LIBNAME) \
2051 sh_init_cumulative_args (& (CUM), NULL_TREE, (LIBNAME), NULL_TREE, 0, (MODE))
2053 #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \
2054 sh_function_arg_advance (&(CUM), (MODE), (TYPE), (NAMED))
2055 #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
2056 sh_function_arg (&(CUM), (MODE), (TYPE), (NAMED))
2058 /* Return boolean indicating arg of mode MODE will be passed in a reg.
2059 This macro is only used in this file. */
2061 #define PASS_IN_REG_P(CUM, MODE, TYPE) \
2063 || (! TREE_ADDRESSABLE ((tree)(TYPE)) \
2064 && (! (TARGET_HITACHI || (CUM).renesas_abi) \
2065 || ! (AGGREGATE_TYPE_P (TYPE) \
2066 || (!TARGET_FPU_ANY \
2067 && (GET_MODE_CLASS (MODE) == MODE_FLOAT \
2068 && GET_MODE_SIZE (MODE) > GET_MODE_SIZE (SFmode))))))) \
2069 && ! (CUM).force_mem \
2071 ? ((MODE) == BLKmode \
2072 ? (((CUM).arg_count[(int) SH_ARG_INT] * UNITS_PER_WORD \
2073 + int_size_in_bytes (TYPE)) \
2074 <= NPARM_REGS (SImode) * UNITS_PER_WORD) \
2075 : ((ROUND_REG((CUM), (MODE)) \
2076 + HARD_REGNO_NREGS (BASE_ARG_REG (MODE), (MODE))) \
2077 <= NPARM_REGS (MODE))) \
2078 : ROUND_REG ((CUM), (MODE)) < NPARM_REGS (MODE)))
2080 /* By accident we got stuck with passing SCmode on SH4 little endian
2081 in two registers that are nominally successive - which is different from
2082 two single SFmode values, where we take endianness translation into
2083 account. That does not work at all if an odd number of registers is
2084 already in use, so that got fixed, but library functions are still more
2085 likely to use complex numbers without mixing them with SFmode arguments
2086 (which in C would have to be structures), so for the sake of ABI
2087 compatibility the way SCmode values are passed when an even number of
2088 FP registers is in use remains different from a pair of SFmode values for
2091 foo (double); a: fr5,fr4
2092 foo (float a, float b); a: fr5 b: fr4
2093 foo (__complex float a); a.real fr4 a.imag: fr5 - for consistency,
2094 this should be the other way round...
2095 foo (float a, __complex float b); a: fr5 b.real: fr4 b.imag: fr7 */
2096 #define FUNCTION_ARG_SCmode_WART 1
2098 /* If an argument of size 5, 6 or 7 bytes is to be passed in a 64-bit
2099 register in SHcompact mode, it must be padded in the most
2100 significant end. This means that passing it by reference wouldn't
2101 pad properly on a big-endian machine. In this particular case, we
2102 pass this argument on the stack, in a way that the call trampoline
2103 will load its value into the appropriate register. */
2104 #define SHCOMPACT_FORCE_ON_STACK(MODE,TYPE) \
2105 ((MODE) == BLKmode \
2106 && TARGET_SHCOMPACT \
2107 && ! TARGET_LITTLE_ENDIAN \
2108 && int_size_in_bytes (TYPE) > 4 \
2109 && int_size_in_bytes (TYPE) < 8)
2111 /* Minimum alignment for an argument to be passed by callee-copy
2112 reference. We need such arguments to be aligned to 8 byte
2113 boundaries, because they'll be loaded using quad loads. */
2114 #define SH_MIN_ALIGN_FOR_CALLEE_COPY (8 * BITS_PER_UNIT)
2116 /* The SH5 ABI requires floating-point arguments to be passed to
2117 functions without a prototype in both an FP register and a regular
2118 register or the stack. When passing the argument in both FP and
2119 general-purpose registers, list the FP register first. */
2120 #define SH5_PROTOTYPELESS_FLOAT_ARG(CUM,MODE) \
2126 ((CUM).arg_count[(int) SH_ARG_INT] < NPARM_REGS (SImode) \
2127 ? gen_rtx_REG ((MODE), FIRST_FP_PARM_REG \
2128 + (CUM).arg_count[(int) SH_ARG_FLOAT]) \
2133 ((CUM).arg_count[(int) SH_ARG_INT] < NPARM_REGS (SImode) \
2134 ? gen_rtx_REG ((MODE), FIRST_PARM_REG \
2135 + (CUM).arg_count[(int) SH_ARG_INT]) \
2136 : gen_rtx_REG ((MODE), FIRST_FP_PARM_REG \
2137 + (CUM).arg_count[(int) SH_ARG_FLOAT])), \
2140 /* The SH5 ABI requires regular registers or stack slots to be
2141 reserved for floating-point arguments. Registers are taken care of
2142 in FUNCTION_ARG_ADVANCE, but stack slots must be reserved here.
2143 Unfortunately, there's no way to just reserve a stack slot, so
2144 we'll end up needlessly storing a copy of the argument in the
2145 stack. For incoming arguments, however, the PARALLEL will be
2146 optimized to the register-only form, and the value in the stack
2147 slot won't be used at all. */
2148 #define SH5_PROTOTYPED_FLOAT_ARG(CUM,MODE,REG) \
2149 ((CUM).arg_count[(int) SH_ARG_INT] < NPARM_REGS (SImode) \
2150 ? gen_rtx_REG ((MODE), (REG)) \
2151 : gen_rtx_PARALLEL ((MODE), \
2154 (VOIDmode, NULL_RTX, \
2157 (VOIDmode, gen_rtx_REG ((MODE), \
2161 #define SH5_WOULD_BE_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) \
2163 && ((MODE) == BLKmode || (MODE) == TImode || (MODE) == CDImode \
2164 || (MODE) == DCmode) \
2165 && ((CUM).arg_count[(int) SH_ARG_INT] \
2166 + (((MODE) == BLKmode ? int_size_in_bytes (TYPE) \
2167 : GET_MODE_SIZE (MODE)) \
2168 + 7) / 8) > NPARM_REGS (SImode))
2170 /* Perform any needed actions needed for a function that is receiving a
2171 variable number of arguments. */
2173 /* Implement `va_start' for varargs and stdarg. */
2174 #define EXPAND_BUILTIN_VA_START(valist, nextarg) \
2175 sh_va_start (valist, nextarg)
2177 /* Call the function profiler with a given profile label.
2178 We use two .aligns, so as to make sure that both the .long is aligned
2179 on a 4 byte boundary, and that the .long is a fixed distance (2 bytes)
2180 from the trapa instruction. */
2182 #define FUNCTION_PROFILER(STREAM,LABELNO) \
2184 if (TARGET_SHMEDIA) \
2186 fprintf((STREAM), "\tmovi\t33,r0\n"); \
2187 fprintf((STREAM), "\ttrapa\tr0\n"); \
2188 asm_fprintf((STREAM), "\t.long\t%LLP%d\n", (LABELNO)); \
2192 fprintf((STREAM), "\t.align\t2\n"); \
2193 fprintf((STREAM), "\ttrapa\t#33\n"); \
2194 fprintf((STREAM), "\t.align\t2\n"); \
2195 asm_fprintf((STREAM), "\t.long\t%LLP%d\n", (LABELNO)); \
2199 /* Define this macro if the code for function profiling should come
2200 before the function prologue. Normally, the profiling code comes
2203 #define PROFILE_BEFORE_PROLOGUE
2205 /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
2206 the stack pointer does not matter. The value is tested only in
2207 functions that have frame pointers.
2208 No definition is equivalent to always zero. */
2210 #define EXIT_IGNORE_STACK 1
2213 On the SH, the trampoline looks like
2214 2 0002 D202 mov.l l2,r2
2215 1 0000 D301 mov.l l1,r3
2218 5 0008 00000000 l1: .long area
2219 6 000c 00000000 l2: .long function */
2221 /* Length in units of the trampoline for entering a nested function. */
2222 #define TRAMPOLINE_SIZE (TARGET_SHMEDIA64 ? 40 : TARGET_SH5 ? 24 : 16)
2224 /* Alignment required for a trampoline in bits . */
2225 #define TRAMPOLINE_ALIGNMENT \
2226 ((CACHE_LOG < 3 || (TARGET_SMALLCODE && ! TARGET_HARVARD)) ? 32 \
2227 : TARGET_SHMEDIA ? 256 : 64)
2229 /* Emit RTL insns to initialize the variable parts of a trampoline.
2230 FNADDR is an RTX for the address of the function's pure code.
2231 CXT is an RTX for the static chain value for the function. */
2233 #define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) \
2234 sh_initialize_trampoline ((TRAMP), (FNADDR), (CXT))
2236 /* On SH5, trampolines are SHmedia code, so add 1 to the address. */
2238 #define TRAMPOLINE_ADJUST_ADDRESS(TRAMP) do \
2240 if (TARGET_SHMEDIA) \
2241 (TRAMP) = expand_simple_binop (Pmode, PLUS, (TRAMP), const1_rtx, \
2242 gen_reg_rtx (Pmode), 0, \
2246 /* A C expression whose value is RTL representing the value of the return
2247 address for the frame COUNT steps up from the current frame.
2248 FRAMEADDR is already the frame pointer of the COUNT frame, so we
2249 can ignore COUNT. */
2251 #define RETURN_ADDR_RTX(COUNT, FRAME) \
2252 (((COUNT) == 0) ? sh_get_pr_initial_val () : (rtx) 0)
2254 /* A C expression whose value is RTL representing the location of the
2255 incoming return address at the beginning of any function, before the
2256 prologue. This RTL is either a REG, indicating that the return
2257 value is saved in REG, or a MEM representing a location in
2259 #define INCOMING_RETURN_ADDR_RTX \
2260 gen_rtx_REG (Pmode, TARGET_SHMEDIA ? PR_MEDIA_REG : PR_REG)
2262 /* Addressing modes, and classification of registers for them. */
2263 #define HAVE_POST_INCREMENT TARGET_SH1
2264 #define HAVE_PRE_DECREMENT TARGET_SH1
2266 #define USE_LOAD_POST_INCREMENT(mode) ((mode == SImode || mode == DImode) \
2268 #define USE_LOAD_PRE_DECREMENT(mode) 0
2269 #define USE_STORE_POST_INCREMENT(mode) 0
2270 #define USE_STORE_PRE_DECREMENT(mode) ((mode == SImode || mode == DImode) \
2273 #define MOVE_BY_PIECES_P(SIZE, ALIGN) \
2274 (move_by_pieces_ninsns (SIZE, ALIGN, MOVE_MAX_PIECES + 1) \
2275 < (TARGET_SMALLCODE ? 2 : ((ALIGN >= 32) ? 16 : 2)))
2277 #define STORE_BY_PIECES_P(SIZE, ALIGN) \
2278 (move_by_pieces_ninsns (SIZE, ALIGN, STORE_MAX_PIECES + 1) \
2279 < (TARGET_SMALLCODE ? 2 : ((ALIGN >= 32) ? 16 : 2)))
2281 /* Macros to check register numbers against specific register classes. */
2283 /* These assume that REGNO is a hard or pseudo reg number.
2284 They give nonzero only if REGNO is a hard reg of the suitable class
2285 or a pseudo reg currently allocated to a suitable hard reg.
2286 Since they use reg_renumber, they are safe only once reg_renumber
2287 has been allocated, which happens in local-alloc.c. */
2289 #define REGNO_OK_FOR_BASE_P(REGNO) \
2290 (GENERAL_OR_AP_REGISTER_P (REGNO) \
2291 || GENERAL_OR_AP_REGISTER_P (reg_renumber[(REGNO)]))
2292 #define REGNO_OK_FOR_INDEX_P(REGNO) \
2294 ? (GENERAL_REGISTER_P (REGNO) \
2295 || GENERAL_REGISTER_P ((unsigned) reg_renumber[(REGNO)])) \
2296 : (REGNO) == R0_REG || (unsigned) reg_renumber[(REGNO)] == R0_REG)
2298 /* Maximum number of registers that can appear in a valid memory
2301 #define MAX_REGS_PER_ADDRESS 2
2303 /* Recognize any constant value that is a valid address. */
2305 #define CONSTANT_ADDRESS_P(X) (GET_CODE (X) == LABEL_REF)
2307 /* Nonzero if the constant value X is a legitimate general operand. */
2308 /* can_store_by_pieces constructs VOIDmode CONST_DOUBLEs. */
2310 #define LEGITIMATE_CONSTANT_P(X) \
2312 ? ((GET_MODE (X) != DFmode \
2313 && GET_MODE_CLASS (GET_MODE (X)) != MODE_VECTOR_FLOAT) \
2314 || (X) == CONST0_RTX (GET_MODE (X)) \
2315 || ! TARGET_SHMEDIA_FPU \
2316 || TARGET_SHMEDIA64) \
2317 : (GET_CODE (X) != CONST_DOUBLE \
2318 || GET_MODE (X) == DFmode || GET_MODE (X) == SFmode \
2319 || GET_MODE (X) == DImode || GET_MODE (X) == VOIDmode))
2321 /* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
2322 and check its validity for a certain class.
2323 We have two alternate definitions for each of them.
2324 The usual definition accepts all pseudo regs; the other rejects
2325 them unless they have been allocated suitable hard regs.
2326 The symbol REG_OK_STRICT causes the latter definition to be used. */
2328 #ifndef REG_OK_STRICT
2330 /* Nonzero if X is a hard reg that can be used as a base reg
2331 or if it is a pseudo reg. */
2332 #define REG_OK_FOR_BASE_P(X) \
2333 (GENERAL_OR_AP_REGISTER_P (REGNO (X)) || REGNO (X) >= FIRST_PSEUDO_REGISTER)
2335 /* Nonzero if X is a hard reg that can be used as an index
2336 or if it is a pseudo reg. */
2337 #define REG_OK_FOR_INDEX_P(X) \
2338 ((TARGET_SHMEDIA ? GENERAL_REGISTER_P (REGNO (X)) \
2339 : REGNO (X) == R0_REG) || REGNO (X) >= FIRST_PSEUDO_REGISTER)
2341 /* Nonzero if X/OFFSET is a hard reg that can be used as an index
2342 or if X is a pseudo reg. */
2343 #define SUBREG_OK_FOR_INDEX_P(X, OFFSET) \
2344 ((TARGET_SHMEDIA ? GENERAL_REGISTER_P (REGNO (X)) \
2345 : REGNO (X) == R0_REG && OFFSET == 0) || REGNO (X) >= FIRST_PSEUDO_REGISTER)
2349 /* Nonzero if X is a hard reg that can be used as a base reg. */
2350 #define REG_OK_FOR_BASE_P(X) \
2351 REGNO_OK_FOR_BASE_P (REGNO (X))
2353 /* Nonzero if X is a hard reg that can be used as an index. */
2354 #define REG_OK_FOR_INDEX_P(X) \
2355 REGNO_OK_FOR_INDEX_P (REGNO (X))
2357 /* Nonzero if X/OFFSET is a hard reg that can be used as an index. */
2358 #define SUBREG_OK_FOR_INDEX_P(X, OFFSET) \
2359 (REGNO_OK_FOR_INDEX_P (REGNO (X)) && (OFFSET) == 0)
2363 /* The 'Q' constraint is a pc relative load operand. */
2364 #define EXTRA_CONSTRAINT_Q(OP) \
2365 (GET_CODE (OP) == MEM \
2366 && ((GET_CODE (XEXP ((OP), 0)) == LABEL_REF) \
2367 || (GET_CODE (XEXP ((OP), 0)) == CONST \
2368 && GET_CODE (XEXP (XEXP ((OP), 0), 0)) == PLUS \
2369 && GET_CODE (XEXP (XEXP (XEXP ((OP), 0), 0), 0)) == LABEL_REF \
2370 && GET_CODE (XEXP (XEXP (XEXP ((OP), 0), 0), 1)) == CONST_INT)))
2372 /* Extra address constraints. */
2373 #define EXTRA_CONSTRAINT_A(OP, STR) 0
2375 /* Constraint for selecting FLDI0 or FLDI1 instruction. If the clobber
2376 operand is not SCRATCH (i.e. REG) then R0 is probably being
2377 used, hence mova is being used, hence do not select this pattern */
2378 #define EXTRA_CONSTRAINT_Bsc(OP) (GET_CODE(OP) == SCRATCH)
2379 #define EXTRA_CONSTRAINT_B(OP, STR) \
2380 ((STR)[1] == 's' && (STR)[2] == 'c' ? EXTRA_CONSTRAINT_Bsc (OP) \
2383 /* The `Css' constraint is a signed 16-bit constant, literal or symbolic. */
2384 #define EXTRA_CONSTRAINT_Css(OP) \
2385 (GET_CODE (OP) == CONST \
2386 && GET_CODE (XEXP ((OP), 0)) == SIGN_EXTEND \
2387 && (GET_MODE (XEXP ((OP), 0)) == DImode \
2388 || GET_MODE (XEXP ((OP), 0)) == SImode) \
2389 && GET_CODE (XEXP (XEXP ((OP), 0), 0)) == TRUNCATE \
2390 && GET_MODE (XEXP (XEXP ((OP), 0), 0)) == HImode \
2391 && (MOVI_SHORI_BASE_OPERAND_P (XEXP (XEXP (XEXP ((OP), 0), 0), 0)) \
2392 || (GET_CODE (XEXP (XEXP (XEXP ((OP), 0), 0), 0)) == ASHIFTRT \
2393 && (MOVI_SHORI_BASE_OPERAND_P \
2394 (XEXP (XEXP (XEXP (XEXP ((OP), 0), 0), 0), 0))) \
2395 && GET_CODE (XEXP (XEXP (XEXP (XEXP ((OP), 0), 0), 0), \
2398 /* The `Csu' constraint is an unsigned 16-bit constant, literal or symbolic. */
2399 #define EXTRA_CONSTRAINT_Csu(OP) \
2400 (GET_CODE (OP) == CONST \
2401 && GET_CODE (XEXP ((OP), 0)) == ZERO_EXTEND \
2402 && (GET_MODE (XEXP ((OP), 0)) == DImode \
2403 || GET_MODE (XEXP ((OP), 0)) == SImode) \
2404 && GET_CODE (XEXP (XEXP ((OP), 0), 0)) == TRUNCATE \
2405 && GET_MODE (XEXP (XEXP ((OP), 0), 0)) == HImode \
2406 && (MOVI_SHORI_BASE_OPERAND_P (XEXP (XEXP (XEXP ((OP), 0), 0), 0)) \
2407 || (GET_CODE (XEXP (XEXP (XEXP ((OP), 0), 0), 0)) == ASHIFTRT \
2408 && (MOVI_SHORI_BASE_OPERAND_P \
2409 (XEXP (XEXP (XEXP (XEXP ((OP), 0), 0), 0), 0))) \
2410 && GET_CODE (XEXP (XEXP (XEXP (XEXP ((OP), 0), 0), 0), \
2413 /* Check whether OP is a datalabel unspec. */
2414 #define DATALABEL_REF_NO_CONST_P(OP) \
2415 (GET_CODE (OP) == UNSPEC \
2416 && XINT ((OP), 1) == UNSPEC_DATALABEL \
2417 && XVECLEN ((OP), 0) == 1 \
2418 && GET_CODE (XVECEXP ((OP), 0, 0)) == LABEL_REF)
2420 #define GOT_ENTRY_P(OP) \
2421 (GET_CODE (OP) == CONST && GET_CODE (XEXP ((OP), 0)) == UNSPEC \
2422 && XINT (XEXP ((OP), 0), 1) == UNSPEC_GOT)
2424 #define GOTPLT_ENTRY_P(OP) \
2425 (GET_CODE (OP) == CONST && GET_CODE (XEXP ((OP), 0)) == UNSPEC \
2426 && XINT (XEXP ((OP), 0), 1) == UNSPEC_GOTPLT)
2428 #define UNSPEC_GOTOFF_P(OP) \
2429 (GET_CODE (OP) == UNSPEC && XINT ((OP), 1) == UNSPEC_GOTOFF)
2431 #define GOTOFF_P(OP) \
2432 (GET_CODE (OP) == CONST \
2433 && (UNSPEC_GOTOFF_P (XEXP ((OP), 0)) \
2434 || (GET_CODE (XEXP ((OP), 0)) == PLUS \
2435 && UNSPEC_GOTOFF_P (XEXP (XEXP ((OP), 0), 0)) \
2436 && GET_CODE (XEXP (XEXP ((OP), 0), 1)) == CONST_INT)))
2438 #define PIC_ADDR_P(OP) \
2439 (GET_CODE (OP) == CONST && GET_CODE (XEXP ((OP), 0)) == UNSPEC \
2440 && XINT (XEXP ((OP), 0), 1) == UNSPEC_PIC)
2442 #define PIC_OFFSET_P(OP) \
2444 && GET_CODE (XVECEXP (XEXP ((OP), 0), 0, 0)) == MINUS \
2445 && reg_mentioned_p (pc_rtx, XEXP (XVECEXP (XEXP ((OP), 0), 0, 0), 1)))
2447 #define PIC_DIRECT_ADDR_P(OP) \
2448 (PIC_ADDR_P (OP) && GET_CODE (XVECEXP (XEXP ((OP), 0), 0, 0)) != MINUS)
2450 #define NON_PIC_REFERENCE_P(OP) \
2451 (GET_CODE (OP) == LABEL_REF || GET_CODE (OP) == SYMBOL_REF \
2452 || (GET_CODE (OP) == CONST \
2453 && (GET_CODE (XEXP ((OP), 0)) == LABEL_REF \
2454 || GET_CODE (XEXP ((OP), 0)) == SYMBOL_REF \
2455 || DATALABEL_REF_NO_CONST_P (XEXP ((OP), 0)))) \
2456 || (GET_CODE (OP) == CONST && GET_CODE (XEXP ((OP), 0)) == PLUS \
2457 && (GET_CODE (XEXP (XEXP ((OP), 0), 0)) == SYMBOL_REF \
2458 || GET_CODE (XEXP (XEXP ((OP), 0), 0)) == LABEL_REF \
2459 || DATALABEL_REF_NO_CONST_P (XEXP (XEXP ((OP), 0), 0))) \
2460 && GET_CODE (XEXP (XEXP ((OP), 0), 1)) == CONST_INT))
2462 #define PIC_REFERENCE_P(OP) \
2463 (GOT_ENTRY_P (OP) || GOTPLT_ENTRY_P (OP) \
2464 || GOTOFF_P (OP) || PIC_ADDR_P (OP))
2466 #define MOVI_SHORI_BASE_OPERAND_P(OP) \
2468 ? (GOT_ENTRY_P (OP) || GOTPLT_ENTRY_P (OP) || GOTOFF_P (OP) \
2469 || PIC_OFFSET_P (OP)) \
2470 : NON_PIC_REFERENCE_P (OP))
2472 /* The `Csy' constraint is a label or a symbol. */
2473 #define EXTRA_CONSTRAINT_Csy(OP) \
2474 (NON_PIC_REFERENCE_P (OP) || PIC_DIRECT_ADDR_P (OP))
2476 /* A zero in any shape or form. */
2477 #define EXTRA_CONSTRAINT_Z(OP) \
2478 ((OP) == CONST0_RTX (GET_MODE (OP)))
2480 /* Any vector constant we can handle. */
2481 #define EXTRA_CONSTRAINT_W(OP) \
2482 (GET_CODE (OP) == CONST_VECTOR \
2483 && (sh_rep_vec ((OP), VOIDmode) \
2484 || (HOST_BITS_PER_WIDE_INT >= 64 \
2485 ? sh_const_vec ((OP), VOIDmode) \
2486 : sh_1el_vec ((OP), VOIDmode))))
2488 /* A non-explicit constant that can be loaded directly into a general purpose
2489 register. This is like 's' except we don't allow PIC_DIRECT_ADDR_P. */
2490 #define EXTRA_CONSTRAINT_Cpg(OP) \
2492 && GET_CODE (OP) != CONST_INT \
2493 && GET_CODE (OP) != CONST_DOUBLE \
2495 || (LEGITIMATE_PIC_OPERAND_P (OP) \
2496 && (! PIC_ADDR_P (OP) || PIC_OFFSET_P (OP)) \
2497 && GET_CODE (OP) != LABEL_REF)))
2498 #define EXTRA_CONSTRAINT_C(OP, STR) \
2499 ((STR)[1] == 's' && (STR)[2] == 's' ? EXTRA_CONSTRAINT_Css (OP) \
2500 : (STR)[1] == 's' && (STR)[2] == 'u' ? EXTRA_CONSTRAINT_Csu (OP) \
2501 : (STR)[1] == 's' && (STR)[2] == 'y' ? EXTRA_CONSTRAINT_Csy (OP) \
2502 : (STR)[1] == 'p' && (STR)[2] == 'g' ? EXTRA_CONSTRAINT_Cpg (OP) \
2505 #define EXTRA_MEMORY_CONSTRAINT(C,STR) ((C) == 'S')
2506 #define EXTRA_CONSTRAINT_Sr0(OP) \
2507 (memory_operand((OP), GET_MODE (OP)) \
2508 && ! refers_to_regno_p (R0_REG, R0_REG + 1, OP, (rtx *)0))
2509 #define EXTRA_CONSTRAINT_Sua(OP) \
2510 (memory_operand((OP), GET_MODE (OP)) \
2511 && GET_CODE (XEXP (OP, 0)) != PLUS)
2512 #define EXTRA_CONSTRAINT_S(OP, STR) \
2513 ((STR)[1] == 'r' && (STR)[2] == '0' ? EXTRA_CONSTRAINT_Sr0 (OP) \
2514 : (STR)[1] == 'u' && (STR)[2] == 'a' ? EXTRA_CONSTRAINT_Sua (OP) \
2517 #define EXTRA_CONSTRAINT_STR(OP, C, STR) \
2518 ((C) == 'Q' ? EXTRA_CONSTRAINT_Q (OP) \
2519 : (C) == 'A' ? EXTRA_CONSTRAINT_A ((OP), (STR)) \
2520 : (C) == 'B' ? EXTRA_CONSTRAINT_B ((OP), (STR)) \
2521 : (C) == 'C' ? EXTRA_CONSTRAINT_C ((OP), (STR)) \
2522 : (C) == 'S' ? EXTRA_CONSTRAINT_S ((OP), (STR)) \
2523 : (C) == 'W' ? EXTRA_CONSTRAINT_W (OP) \
2524 : (C) == 'Z' ? EXTRA_CONSTRAINT_Z (OP) \
2527 /* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression
2528 that is a valid memory address for an instruction.
2529 The MODE argument is the machine mode for the MEM expression
2530 that wants to use this address. */
2532 #define MODE_DISP_OK_4(X,MODE) \
2533 (GET_MODE_SIZE (MODE) == 4 && (unsigned) INTVAL (X) < 64 \
2534 && ! (INTVAL (X) & 3) && ! (TARGET_SH2E && (MODE) == SFmode))
2536 #define MODE_DISP_OK_8(X,MODE) \
2537 ((GET_MODE_SIZE(MODE)==8) && ((unsigned)INTVAL(X)<60) \
2538 && ! (INTVAL(X) & 3) && ! (TARGET_SH4 && (MODE) == DFmode))
2540 #undef MODE_DISP_OK_4
2541 #define MODE_DISP_OK_4(X,MODE) \
2542 ((GET_MODE_SIZE (MODE) == 4 && (unsigned) INTVAL (X) < 64 \
2543 && ! (INTVAL (X) & 3) && ! (TARGET_SH2E && (MODE) == SFmode)) \
2544 || ((GET_MODE_SIZE(MODE)==4) && ((unsigned)INTVAL(X)<16383) \
2545 && ! (INTVAL(X) & 3) && TARGET_SH2A))
2547 #undef MODE_DISP_OK_8
2548 #define MODE_DISP_OK_8(X,MODE) \
2549 (((GET_MODE_SIZE(MODE)==8) && ((unsigned)INTVAL(X)<60) \
2550 && ! (INTVAL(X) & 3) && ! ((TARGET_SH4 || TARGET_SH2A) && (MODE) == DFmode)) \
2551 || ((GET_MODE_SIZE(MODE)==8) && ((unsigned)INTVAL(X)<8192) \
2552 && ! (INTVAL(X) & (TARGET_SH2A_DOUBLE ? 7 : 3)) && (TARGET_SH2A && (MODE) == DFmode)))
2554 #define BASE_REGISTER_RTX_P(X) \
2555 ((GET_CODE (X) == REG && REG_OK_FOR_BASE_P (X)) \
2556 || (GET_CODE (X) == SUBREG \
2557 && TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (GET_MODE ((X))), \
2558 GET_MODE_BITSIZE (GET_MODE (SUBREG_REG (X)))) \
2559 && GET_CODE (SUBREG_REG (X)) == REG \
2560 && REG_OK_FOR_BASE_P (SUBREG_REG (X))))
2562 /* Since this must be r0, which is a single register class, we must check
2563 SUBREGs more carefully, to be sure that we don't accept one that extends
2564 outside the class. */
2565 #define INDEX_REGISTER_RTX_P(X) \
2566 ((GET_CODE (X) == REG && REG_OK_FOR_INDEX_P (X)) \
2567 || (GET_CODE (X) == SUBREG \
2568 && TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (GET_MODE ((X))), \
2569 GET_MODE_BITSIZE (GET_MODE (SUBREG_REG (X)))) \
2570 && GET_CODE (SUBREG_REG (X)) == REG \
2571 && SUBREG_OK_FOR_INDEX_P (SUBREG_REG (X), SUBREG_BYTE (X))))
2573 /* Jump to LABEL if X is a valid address RTX. This must also take
2574 REG_OK_STRICT into account when deciding about valid registers, but it uses
2575 the above macros so we are in luck.
2583 /* ??? The SH2e does not have the REG+disp addressing mode when loading values
2584 into the FRx registers. We implement this by setting the maximum offset
2585 to zero when the value is SFmode. This also restricts loading of SFmode
2586 values into the integer registers, but that can't be helped. */
2588 /* The SH allows a displacement in a QI or HI amode, but only when the
2589 other operand is R0. GCC doesn't handle this very well, so we forgo
2592 A legitimate index for a QI or HI is 0, SI can be any number 0..63,
2593 DI can be any number 0..60. */
2595 #define GO_IF_LEGITIMATE_INDEX(MODE, OP, LABEL) \
2597 if (GET_CODE (OP) == CONST_INT) \
2599 if (TARGET_SHMEDIA) \
2602 /* Check if this the address of an unaligned load / store. */\
2603 if ((MODE) == VOIDmode) \
2605 if (CONST_OK_FOR_I06 (INTVAL (OP))) \
2609 MODE_SIZE = GET_MODE_SIZE (MODE); \
2610 if (! (INTVAL (OP) & (MODE_SIZE - 1)) \
2611 && INTVAL (OP) >= -512 * MODE_SIZE \
2612 && INTVAL (OP) < 512 * MODE_SIZE) \
2617 if (MODE_DISP_OK_4 ((OP), (MODE))) goto LABEL; \
2618 if (MODE_DISP_OK_8 ((OP), (MODE))) goto LABEL; \
2622 #define ALLOW_INDEXED_ADDRESS \
2623 ((!TARGET_SHMEDIA32 && !TARGET_SHCOMPACT) || TARGET_ALLOW_INDEXED_ADDRESS)
2625 #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, LABEL) \
2627 if (BASE_REGISTER_RTX_P (X)) \
2629 else if ((GET_CODE (X) == POST_INC || GET_CODE (X) == PRE_DEC) \
2630 && ! TARGET_SHMEDIA \
2631 && BASE_REGISTER_RTX_P (XEXP ((X), 0))) \
2633 else if (GET_CODE (X) == PLUS \
2634 && ((MODE) != PSImode || reload_completed)) \
2636 rtx xop0 = XEXP ((X), 0); \
2637 rtx xop1 = XEXP ((X), 1); \
2638 if (GET_MODE_SIZE (MODE) <= 8 && BASE_REGISTER_RTX_P (xop0)) \
2639 GO_IF_LEGITIMATE_INDEX ((MODE), xop1, LABEL); \
2640 if ((ALLOW_INDEXED_ADDRESS || GET_MODE (X) == DImode \
2641 || ((xop0 == stack_pointer_rtx \
2642 || xop0 == hard_frame_pointer_rtx) \
2643 && REG_P (xop1) && REGNO (xop1) == R0_REG) \
2644 || ((xop1 == stack_pointer_rtx \
2645 || xop1 == hard_frame_pointer_rtx) \
2646 && REG_P (xop0) && REGNO (xop0) == R0_REG)) \
2647 && ((!TARGET_SHMEDIA && GET_MODE_SIZE (MODE) <= 4) \
2648 || (TARGET_SHMEDIA && GET_MODE_SIZE (MODE) <= 8) \
2649 || ((TARGET_SH4 || TARGET_SH2A_DOUBLE) \
2650 && TARGET_FMOVD && MODE == DFmode))) \
2652 if (BASE_REGISTER_RTX_P (xop1) && INDEX_REGISTER_RTX_P (xop0))\
2654 if (INDEX_REGISTER_RTX_P (xop1) && BASE_REGISTER_RTX_P (xop0))\
2660 /* Try machine-dependent ways of modifying an illegitimate address
2661 to be legitimate. If we find one, return the new, valid address.
2662 This macro is used in only one place: `memory_address' in explow.c.
2664 OLDX is the address as it was before break_out_memory_refs was called.
2665 In some cases it is useful to look at this to decide what needs to be done.
2667 MODE and WIN are passed so that this macro can use
2668 GO_IF_LEGITIMATE_ADDRESS.
2670 It is always safe for this macro to do nothing. It exists to recognize
2671 opportunities to optimize the output.
2673 For the SH, if X is almost suitable for indexing, but the offset is
2674 out of range, convert it into a normal form so that cse has a chance
2675 of reducing the number of address registers used. */
2677 #define LEGITIMIZE_ADDRESS(X,OLDX,MODE,WIN) \
2680 (X) = legitimize_pic_address (OLDX, MODE, NULL_RTX); \
2681 if (GET_CODE (X) == PLUS \
2682 && (GET_MODE_SIZE (MODE) == 4 \
2683 || GET_MODE_SIZE (MODE) == 8) \
2684 && GET_CODE (XEXP ((X), 1)) == CONST_INT \
2685 && BASE_REGISTER_RTX_P (XEXP ((X), 0)) \
2686 && ! TARGET_SHMEDIA \
2687 && ! ((TARGET_SH4 || TARGET_SH2A_DOUBLE) && (MODE) == DFmode) \
2688 && ! (TARGET_SH2E && (MODE) == SFmode)) \
2690 rtx index_rtx = XEXP ((X), 1); \
2691 HOST_WIDE_INT offset = INTVAL (index_rtx), offset_base; \
2694 GO_IF_LEGITIMATE_INDEX ((MODE), index_rtx, WIN); \
2695 /* On rare occasions, we might get an unaligned pointer \
2696 that is indexed in a way to give an aligned address. \
2697 Therefore, keep the lower two bits in offset_base. */ \
2698 /* Instead of offset_base 128..131 use 124..127, so that \
2699 simple add suffices. */ \
2702 offset_base = ((offset + 4) & ~60) - 4; \
2705 offset_base = offset & ~60; \
2706 /* Sometimes the normal form does not suit DImode. We \
2707 could avoid that by using smaller ranges, but that \
2708 would give less optimized code when SImode is \
2710 if (GET_MODE_SIZE (MODE) + offset - offset_base <= 64) \
2712 sum = expand_binop (Pmode, add_optab, XEXP ((X), 0), \
2713 GEN_INT (offset_base), NULL_RTX, 0, \
2716 (X) = gen_rtx_PLUS (Pmode, sum, GEN_INT (offset - offset_base)); \
2722 /* A C compound statement that attempts to replace X, which is an address
2723 that needs reloading, with a valid memory address for an operand of
2724 mode MODE. WIN is a C statement label elsewhere in the code.
2726 Like for LEGITIMIZE_ADDRESS, for the SH we try to get a normal form
2727 of the address. That will allow inheritance of the address reloads. */
2729 #define LEGITIMIZE_RELOAD_ADDRESS(X,MODE,OPNUM,TYPE,IND_LEVELS,WIN) \
2731 if (GET_CODE (X) == PLUS \
2732 && (GET_MODE_SIZE (MODE) == 4 || GET_MODE_SIZE (MODE) == 8) \
2733 && GET_CODE (XEXP (X, 1)) == CONST_INT \
2734 && BASE_REGISTER_RTX_P (XEXP (X, 0)) \
2735 && ! TARGET_SHMEDIA \
2736 && ! (TARGET_SH4 && (MODE) == DFmode) \
2737 && ! ((MODE) == PSImode && (TYPE) == RELOAD_FOR_INPUT_ADDRESS) \
2738 && (ALLOW_INDEXED_ADDRESS \
2739 || XEXP ((X), 0) == stack_pointer_rtx \
2740 || XEXP ((X), 0) == hard_frame_pointer_rtx)) \
2742 rtx index_rtx = XEXP (X, 1); \
2743 HOST_WIDE_INT offset = INTVAL (index_rtx), offset_base; \
2746 if (TARGET_SH2A && (MODE) == DFmode && (offset & 0x7)) \
2748 push_reload (X, NULL_RTX, &X, NULL, \
2749 BASE_REG_CLASS, Pmode, VOIDmode, 0, 0, (OPNUM), \
2753 if (TARGET_SH2E && MODE == SFmode) \
2756 push_reload (index_rtx, NULL_RTX, &XEXP (X, 1), NULL, \
2757 R0_REGS, Pmode, VOIDmode, 0, 0, (OPNUM), \
2761 /* Instead of offset_base 128..131 use 124..127, so that \
2762 simple add suffices. */ \
2765 offset_base = ((offset + 4) & ~60) - 4; \
2768 offset_base = offset & ~60; \
2769 /* Sometimes the normal form does not suit DImode. We \
2770 could avoid that by using smaller ranges, but that \
2771 would give less optimized code when SImode is \
2773 if (GET_MODE_SIZE (MODE) + offset - offset_base <= 64) \
2775 sum = gen_rtx_PLUS (Pmode, XEXP (X, 0), \
2776 GEN_INT (offset_base)); \
2777 X = gen_rtx_PLUS (Pmode, sum, GEN_INT (offset - offset_base));\
2778 push_reload (sum, NULL_RTX, &XEXP (X, 0), NULL, \
2779 BASE_REG_CLASS, Pmode, VOIDmode, 0, 0, (OPNUM), \
2784 /* We must re-recognize what we created before. */ \
2785 else if (GET_CODE (X) == PLUS \
2786 && (GET_MODE_SIZE (MODE) == 4 || GET_MODE_SIZE (MODE) == 8) \
2787 && GET_CODE (XEXP (X, 0)) == PLUS \
2788 && GET_CODE (XEXP (XEXP (X, 0), 1)) == CONST_INT \
2789 && BASE_REGISTER_RTX_P (XEXP (XEXP (X, 0), 0)) \
2790 && GET_CODE (XEXP (X, 1)) == CONST_INT \
2791 && ! TARGET_SHMEDIA \
2792 && ! (TARGET_SH2E && MODE == SFmode)) \
2794 /* Because this address is so complex, we know it must have \
2795 been created by LEGITIMIZE_RELOAD_ADDRESS before; thus, \
2796 it is already unshared, and needs no further unsharing. */ \
2797 push_reload (XEXP ((X), 0), NULL_RTX, &XEXP ((X), 0), NULL, \
2798 BASE_REG_CLASS, Pmode, VOIDmode, 0, 0, (OPNUM), (TYPE));\
2803 /* Go to LABEL if ADDR (a legitimate address expression)
2804 has an effect that depends on the machine mode it is used for.
2806 ??? Strictly speaking, we should also include all indexed addressing,
2807 because the index scale factor is the length of the operand.
2808 However, the impact of GO_IF_MODE_DEPENDENT_ADDRESS would be to
2809 high if we did that. So we rely on reload to fix things up.
2811 Auto-increment addressing is now treated in recog.c. */
2813 #define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR,LABEL)
2815 /* Specify the machine mode that this machine uses
2816 for the index in the tablejump instruction. */
2817 #define CASE_VECTOR_MODE ((! optimize || TARGET_BIGTABLE) ? SImode : HImode)
2819 #define CASE_VECTOR_SHORTEN_MODE(MIN_OFFSET, MAX_OFFSET, BODY) \
2820 ((MIN_OFFSET) >= 0 && (MAX_OFFSET) <= 127 \
2821 ? (ADDR_DIFF_VEC_FLAGS (BODY).offset_unsigned = 0, QImode) \
2822 : (MIN_OFFSET) >= 0 && (MAX_OFFSET) <= 255 \
2823 ? (ADDR_DIFF_VEC_FLAGS (BODY).offset_unsigned = 1, QImode) \
2824 : (MIN_OFFSET) >= -32768 && (MAX_OFFSET) <= 32767 ? HImode \
2827 /* Define as C expression which evaluates to nonzero if the tablejump
2828 instruction expects the table to contain offsets from the address of the
2830 Do not define this if the table should contain absolute addresses. */
2831 #define CASE_VECTOR_PC_RELATIVE 1
2833 /* Define it here, so that it doesn't get bumped to 64-bits on SHmedia. */
2834 #define FLOAT_TYPE_SIZE 32
2836 /* Since the SH2e has only `float' support, it is desirable to make all
2837 floating point types equivalent to `float'. */
2838 #define DOUBLE_TYPE_SIZE ((TARGET_SH2E && ! TARGET_SH4 && ! TARGET_SH2A_DOUBLE) ? 32 : 64)
2840 #if defined(__SH2E__) || defined(__SH3E__) || defined( __SH4_SINGLE_ONLY__)
2841 #define LIBGCC2_DOUBLE_TYPE_SIZE 32
2843 #define LIBGCC2_DOUBLE_TYPE_SIZE 64
2846 /* 'char' is signed by default. */
2847 #define DEFAULT_SIGNED_CHAR 1
2849 /* The type of size_t unsigned int. */
2850 #define SIZE_TYPE (TARGET_SH5 ? "long unsigned int" : "unsigned int")
2853 #define PTRDIFF_TYPE (TARGET_SH5 ? "long int" : "int")
2855 #define WCHAR_TYPE "short unsigned int"
2856 #define WCHAR_TYPE_SIZE 16
2858 #define SH_ELF_WCHAR_TYPE "long int"
2860 /* Max number of bytes we can move from memory to memory
2861 in one reasonably fast instruction. */
2862 #define MOVE_MAX (TARGET_SHMEDIA ? 8 : 4)
2864 /* Maximum value possibly taken by MOVE_MAX. Must be defined whenever
2865 MOVE_MAX is not a compile-time constant. */
2866 #define MAX_MOVE_MAX 8
2868 /* Max number of bytes we want move_by_pieces to be able to copy
2870 #define MOVE_MAX_PIECES (TARGET_SH4 || TARGET_SHMEDIA ? 8 : 4)
2872 /* Define if operations between registers always perform the operation
2873 on the full register even if a narrower mode is specified. */
2874 #define WORD_REGISTER_OPERATIONS
2876 /* Define if loading in MODE, an integral mode narrower than BITS_PER_WORD
2877 will either zero-extend or sign-extend. The value of this macro should
2878 be the code that says which one of the two operations is implicitly
2879 done, UNKNOWN if none. */
2880 /* For SHmedia, we can truncate to QImode easier using zero extension. */
2881 /* FP registers can load SImode values, but don't implicitly sign-extend
2883 #define LOAD_EXTEND_OP(MODE) \
2884 (((MODE) == QImode && TARGET_SHMEDIA) ? ZERO_EXTEND \
2885 : (MODE) != SImode ? SIGN_EXTEND : UNKNOWN)
2887 /* Define if loading short immediate values into registers sign extends. */
2888 #define SHORT_IMMEDIATES_SIGN_EXTEND
2890 /* Nonzero if access to memory by bytes is no faster than for words. */
2891 #define SLOW_BYTE_ACCESS 1
2893 /* Immediate shift counts are truncated by the output routines (or was it
2894 the assembler?). Shift counts in a register are truncated by SH. Note
2895 that the native compiler puts too large (> 32) immediate shift counts
2896 into a register and shifts by the register, letting the SH decide what
2897 to do instead of doing that itself. */
2898 /* ??? The library routines in lib1funcs.asm truncate the shift count.
2899 However, the SH3 has hardware shifts that do not truncate exactly as gcc
2900 expects - the sign bit is significant - so it appears that we need to
2901 leave this zero for correct SH3 code. */
2902 #define SHIFT_COUNT_TRUNCATED (! TARGET_SH3 && ! TARGET_SH2A)
2904 /* All integers have the same format so truncation is easy. */
2905 /* But SHmedia must sign-extend DImode when truncating to SImode. */
2906 #define TRULY_NOOP_TRUNCATION(OUTPREC,INPREC) \
2907 (!TARGET_SHMEDIA || (INPREC) < 64 || (OUTPREC) >= 64)
2909 /* Define this if addresses of constant functions
2910 shouldn't be put through pseudo regs where they can be cse'd.
2911 Desirable on machines where ordinary constants are expensive
2912 but a CALL with constant address is cheap. */
2913 /*#define NO_FUNCTION_CSE 1*/
2915 /* The machine modes of pointers and functions. */
2916 #define Pmode (TARGET_SHMEDIA64 ? DImode : SImode)
2917 #define FUNCTION_MODE Pmode
2919 /* The multiply insn on the SH1 and the divide insns on the SH1 and SH2
2920 are actually function calls with some special constraints on arguments
2923 These macros tell reorg that the references to arguments and
2924 register clobbers for insns of type sfunc do not appear to happen
2925 until after the millicode call. This allows reorg to put insns
2926 which set the argument registers into the delay slot of the millicode
2927 call -- thus they act more like traditional CALL_INSNs.
2929 get_attr_is_sfunc will try to recognize the given insn, so make sure to
2930 filter out things it will not accept -- SEQUENCE, USE and CLOBBER insns
2933 #define INSN_SETS_ARE_DELAYED(X) \
2934 ((GET_CODE (X) == INSN \
2935 && GET_CODE (PATTERN (X)) != SEQUENCE \
2936 && GET_CODE (PATTERN (X)) != USE \
2937 && GET_CODE (PATTERN (X)) != CLOBBER \
2938 && get_attr_is_sfunc (X)))
2940 #define INSN_REFERENCES_ARE_DELAYED(X) \
2941 ((GET_CODE (X) == INSN \
2942 && GET_CODE (PATTERN (X)) != SEQUENCE \
2943 && GET_CODE (PATTERN (X)) != USE \
2944 && GET_CODE (PATTERN (X)) != CLOBBER \
2945 && get_attr_is_sfunc (X)))
2948 /* Position Independent Code. */
2950 /* We can't directly access anything that contains a symbol,
2951 nor can we indirect via the constant pool. */
2952 #define LEGITIMATE_PIC_OPERAND_P(X) \
2953 ((! nonpic_symbol_mentioned_p (X) \
2954 && (GET_CODE (X) != SYMBOL_REF \
2955 || ! CONSTANT_POOL_ADDRESS_P (X) \
2956 || ! nonpic_symbol_mentioned_p (get_pool_constant (X)))) \
2957 || (TARGET_SHMEDIA && GET_CODE (X) == LABEL_REF))
2959 #define SYMBOLIC_CONST_P(X) \
2960 ((GET_CODE (X) == SYMBOL_REF || GET_CODE (X) == LABEL_REF) \
2961 && nonpic_symbol_mentioned_p (X))
2963 /* Compute extra cost of moving data between one register class
2966 /* If SECONDARY*_RELOAD_CLASS says something about the src/dst pair, regclass
2967 uses this information. Hence, the general register <-> floating point
2968 register information here is not used for SFmode. */
2970 #define REGCLASS_HAS_GENERAL_REG(CLASS) \
2971 ((CLASS) == GENERAL_REGS || (CLASS) == R0_REGS \
2972 || (! TARGET_SHMEDIA && (CLASS) == SIBCALL_REGS))
2974 #define REGCLASS_HAS_FP_REG(CLASS) \
2975 ((CLASS) == FP0_REGS || (CLASS) == FP_REGS \
2976 || (CLASS) == DF_REGS || (CLASS) == DF_HI_REGS)
2978 #define REGISTER_MOVE_COST(MODE, SRCCLASS, DSTCLASS) \
2979 sh_register_move_cost ((MODE), (SRCCLASS), (DSTCLASS))
2981 /* ??? Perhaps make MEMORY_MOVE_COST depend on compiler option? This
2982 would be so that people with slow memory systems could generate
2983 different code that does fewer memory accesses. */
2985 /* A C expression for the cost of a branch instruction. A value of 1
2986 is the default; other values are interpreted relative to that.
2987 The SH1 does not have delay slots, hence we get a pipeline stall
2988 at every branch. The SH4 is superscalar, so the single delay slot
2989 is not sufficient to keep both pipelines filled. */
2990 #define BRANCH_COST (TARGET_SH5 ? 1 : ! TARGET_SH2 || TARGET_HARD_SH4 ? 2 : 1)
2992 /* Assembler output control. */
2994 /* A C string constant describing how to begin a comment in the target
2995 assembler language. The compiler assumes that the comment will end at
2996 the end of the line. */
2997 #define ASM_COMMENT_START "!"
2999 #define ASM_APP_ON ""
3000 #define ASM_APP_OFF ""
3001 #define FILE_ASM_OP "\t.file\n"
3002 #define SET_ASM_OP "\t.set\t"
3004 /* How to change between sections. */
3006 #define TEXT_SECTION_ASM_OP (TARGET_SHMEDIA32 ? "\t.section\t.text..SHmedia32,\"ax\"" : "\t.text")
3007 #define DATA_SECTION_ASM_OP "\t.data"
3009 #if defined CRT_BEGIN || defined CRT_END
3010 /* Arrange for TEXT_SECTION_ASM_OP to be a compile-time constant. */
3011 # undef TEXT_SECTION_ASM_OP
3012 # if __SHMEDIA__ == 1 && __SH5__ == 32
3013 # define TEXT_SECTION_ASM_OP "\t.section\t.text..SHmedia32,\"ax\""
3015 # define TEXT_SECTION_ASM_OP "\t.text"
3020 /* If defined, a C expression whose value is a string containing the
3021 assembler operation to identify the following data as
3022 uninitialized global data. If not defined, and neither
3023 `ASM_OUTPUT_BSS' nor `ASM_OUTPUT_ALIGNED_BSS' are defined,
3024 uninitialized global data will be output in the data section if
3025 `-fno-common' is passed, otherwise `ASM_OUTPUT_COMMON' will be
3027 #ifndef BSS_SECTION_ASM_OP
3028 #define BSS_SECTION_ASM_OP "\t.section\t.bss"
3031 /* Like `ASM_OUTPUT_BSS' except takes the required alignment as a
3032 separate, explicit argument. If you define this macro, it is used
3033 in place of `ASM_OUTPUT_BSS', and gives you more flexibility in
3034 handling the required alignment of the variable. The alignment is
3035 specified as the number of bits.
3037 Try to use function `asm_output_aligned_bss' defined in file
3038 `varasm.c' when defining this macro. */
3039 #ifndef ASM_OUTPUT_ALIGNED_BSS
3040 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
3041 asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
3044 /* Define this so that jump tables go in same section as the current function,
3045 which could be text or it could be a user defined section. */
3046 #define JUMP_TABLES_IN_TEXT_SECTION 1
3048 #undef DO_GLOBAL_CTORS_BODY
3049 #define DO_GLOBAL_CTORS_BODY \
3051 typedef (*pfunc)(); \
3052 extern pfunc __ctors[]; \
3053 extern pfunc __ctors_end[]; \
3055 for (p = __ctors_end; p > __ctors; ) \
3061 #undef DO_GLOBAL_DTORS_BODY
3062 #define DO_GLOBAL_DTORS_BODY \
3064 typedef (*pfunc)(); \
3065 extern pfunc __dtors[]; \
3066 extern pfunc __dtors_end[]; \
3068 for (p = __dtors; p < __dtors_end; p++) \
3074 #define ASM_OUTPUT_REG_PUSH(file, v) \
3076 if (TARGET_SHMEDIA) \
3078 fprintf ((file), "\taddi.l\tr15,-8,r15\n"); \
3079 fprintf ((file), "\tst.q\tr15,0,r%d\n", (v)); \
3082 fprintf ((file), "\tmov.l\tr%d,@-r15\n", (v)); \
3085 #define ASM_OUTPUT_REG_POP(file, v) \
3087 if (TARGET_SHMEDIA) \
3089 fprintf ((file), "\tld.q\tr15,0,r%d\n", (v)); \
3090 fprintf ((file), "\taddi.l\tr15,8,r15\n"); \
3093 fprintf ((file), "\tmov.l\t@r15+,r%d\n", (v)); \
3096 /* DBX register number for a given compiler register number. */
3097 /* GDB has FPUL at 23 and FP0 at 25, so we must add one to all FP registers
3099 /* svr4.h undefines this macro, yet we really want to use the same numbers
3100 for coff as for elf, so we go via another macro: SH_DBX_REGISTER_NUMBER. */
3101 /* expand_builtin_init_dwarf_reg_sizes uses this to test if a
3102 register exists, so we should return -1 for invalid register numbers. */
3103 #define DBX_REGISTER_NUMBER(REGNO) SH_DBX_REGISTER_NUMBER (REGNO)
3105 /* SHcompact PR_REG used to use the encoding 241, and SHcompact FP registers
3106 used to use the encodings 245..260, but that doesn't make sense:
3107 PR_REG and PR_MEDIA_REG are actually the same register, and likewise
3108 the FP registers stay the same when switching between compact and media
3109 mode. Hence, we also need to use the same dwarf frame columns.
3110 Likewise, we need to support unwind information for SHmedia registers
3111 even in compact code. */
3112 #define SH_DBX_REGISTER_NUMBER(REGNO) \
3113 (IN_RANGE ((REGNO), \
3114 (unsigned HOST_WIDE_INT) FIRST_GENERAL_REG, \
3115 FIRST_GENERAL_REG + (TARGET_SH5 ? 63U :15U)) \
3116 ? ((unsigned) (REGNO) - FIRST_GENERAL_REG) \
3117 : ((int) (REGNO) >= FIRST_FP_REG \
3119 <= (FIRST_FP_REG + \
3120 ((TARGET_SH5 && TARGET_FPU_ANY) ? 63 : TARGET_SH2E ? 15 : -1)))) \
3121 ? ((unsigned) (REGNO) - FIRST_FP_REG \
3122 + (TARGET_SH5 ? 77 : 25)) \
3123 : XD_REGISTER_P (REGNO) \
3124 ? ((unsigned) (REGNO) - FIRST_XD_REG + (TARGET_SH5 ? 289 : 87)) \
3125 : TARGET_REGISTER_P (REGNO) \
3126 ? ((unsigned) (REGNO) - FIRST_TARGET_REG + 68) \
3127 : (REGNO) == PR_REG \
3128 ? (TARGET_SH5 ? 18 : 17) \
3129 : (REGNO) == PR_MEDIA_REG \
3130 ? (TARGET_SH5 ? 18 : (unsigned) -1) \
3131 : (REGNO) == T_REG \
3132 ? (TARGET_SH5 ? 242 : 18) \
3133 : (REGNO) == GBR_REG \
3134 ? (TARGET_SH5 ? 238 : 19) \
3135 : (REGNO) == MACH_REG \
3136 ? (TARGET_SH5 ? 239 : 20) \
3137 : (REGNO) == MACL_REG \
3138 ? (TARGET_SH5 ? 240 : 21) \
3139 : (REGNO) == FPUL_REG \
3140 ? (TARGET_SH5 ? 244 : 23) \
3143 /* This is how to output a reference to a symbol_ref. On SH5,
3144 references to non-code symbols must be preceded by `datalabel'. */
3145 #define ASM_OUTPUT_SYMBOL_REF(FILE,SYM) \
3148 if (TARGET_SH5 && !SYMBOL_REF_FUNCTION_P (SYM)) \
3149 fputs ("datalabel ", (FILE)); \
3150 assemble_name ((FILE), XSTR ((SYM), 0)); \
3154 /* This is how to output an assembler line
3155 that says to advance the location counter
3156 to a multiple of 2**LOG bytes. */
3158 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
3160 fprintf ((FILE), "\t.align %d\n", (LOG))
3162 /* Globalizing directive for a label. */
3163 #define GLOBAL_ASM_OP "\t.global\t"
3165 /* #define ASM_OUTPUT_CASE_END(STREAM,NUM,TABLE) */
3167 /* Output a relative address table. */
3169 #define ASM_OUTPUT_ADDR_DIFF_ELT(STREAM,BODY,VALUE,REL) \
3170 switch (GET_MODE (BODY)) \
3175 asm_fprintf ((STREAM), "\t.long\t%LL%d-datalabel %LL%d\n", \
3179 asm_fprintf ((STREAM), "\t.long\t%LL%d-%LL%d\n", (VALUE),(REL)); \
3184 asm_fprintf ((STREAM), "\t.word\t%LL%d-datalabel %LL%d\n", \
3188 asm_fprintf ((STREAM), "\t.word\t%LL%d-%LL%d\n", (VALUE),(REL)); \
3193 asm_fprintf ((STREAM), "\t.byte\t%LL%d-datalabel %LL%d\n", \
3197 asm_fprintf ((STREAM), "\t.byte\t%LL%d-%LL%d\n", (VALUE),(REL)); \
3203 /* Output an absolute table element. */
3205 #define ASM_OUTPUT_ADDR_VEC_ELT(STREAM,VALUE) \
3206 if (! optimize || TARGET_BIGTABLE) \
3207 asm_fprintf ((STREAM), "\t.long\t%LL%d\n", (VALUE)); \
3209 asm_fprintf ((STREAM), "\t.word\t%LL%d\n", (VALUE));
3212 /* A C statement to be executed just prior to the output of
3213 assembler code for INSN, to modify the extracted operands so
3214 they will be output differently.
3216 Here the argument OPVEC is the vector containing the operands
3217 extracted from INSN, and NOPERANDS is the number of elements of
3218 the vector which contain meaningful data for this insn.
3219 The contents of this vector are what will be used to convert the insn
3220 template into assembler code, so you can change the assembler output
3221 by changing the contents of the vector. */
3223 #define FINAL_PRESCAN_INSN(INSN, OPVEC, NOPERANDS) \
3224 final_prescan_insn ((INSN), (OPVEC), (NOPERANDS))
3226 /* Print operand X (an rtx) in assembler syntax to file FILE.
3227 CODE is a letter or dot (`z' in `%z0') or 0 if no letter was specified.
3228 For `%' followed by punctuation, CODE is the punctuation and X is null. */
3230 #define PRINT_OPERAND(STREAM, X, CODE) print_operand ((STREAM), (X), (CODE))
3232 /* Print a memory address as an operand to reference that memory location. */
3234 #define PRINT_OPERAND_ADDRESS(STREAM,X) print_operand_address ((STREAM), (X))
3236 #define PRINT_OPERAND_PUNCT_VALID_P(CHAR) \
3237 ((CHAR) == '.' || (CHAR) == '#' || (CHAR) == '@' || (CHAR) == ',' \
3238 || (CHAR) == '$' || (CHAR) == '\'' || (CHAR) == '>')
3240 /* Recognize machine-specific patterns that may appear within
3241 constants. Used for PIC-specific UNSPECs. */
3242 #define OUTPUT_ADDR_CONST_EXTRA(STREAM, X, FAIL) \
3244 if (GET_CODE (X) == UNSPEC && XVECLEN ((X), 0) == 1) \
3246 switch (XINT ((X), 1)) \
3248 case UNSPEC_DATALABEL: \
3249 fputs ("datalabel ", (STREAM)); \
3250 output_addr_const ((STREAM), XVECEXP ((X), 0, 0)); \
3253 /* GLOBAL_OFFSET_TABLE or local symbols, no suffix. */ \
3254 output_addr_const ((STREAM), XVECEXP ((X), 0, 0)); \
3257 output_addr_const ((STREAM), XVECEXP ((X), 0, 0)); \
3258 fputs ("@GOT", (STREAM)); \
3260 case UNSPEC_GOTOFF: \
3261 output_addr_const ((STREAM), XVECEXP ((X), 0, 0)); \
3262 fputs ("@GOTOFF", (STREAM)); \
3265 output_addr_const ((STREAM), XVECEXP ((X), 0, 0)); \
3266 fputs ("@PLT", (STREAM)); \
3268 case UNSPEC_GOTPLT: \
3269 output_addr_const ((STREAM), XVECEXP ((X), 0, 0)); \
3270 fputs ("@GOTPLT", (STREAM)); \
3272 case UNSPEC_DTPOFF: \
3273 output_addr_const ((STREAM), XVECEXP ((X), 0, 0)); \
3274 fputs ("@DTPOFF", (STREAM)); \
3276 case UNSPEC_GOTTPOFF: \
3277 output_addr_const ((STREAM), XVECEXP ((X), 0, 0)); \
3278 fputs ("@GOTTPOFF", (STREAM)); \
3280 case UNSPEC_TPOFF: \
3281 output_addr_const ((STREAM), XVECEXP ((X), 0, 0)); \
3282 fputs ("@TPOFF", (STREAM)); \
3284 case UNSPEC_CALLER: \
3287 /* LPCS stands for Label for PIC Call Site. */ \
3288 ASM_GENERATE_INTERNAL_LABEL \
3289 (name, "LPCS", INTVAL (XVECEXP ((X), 0, 0))); \
3290 assemble_name ((STREAM), name); \
3303 extern struct rtx_def *sh_compare_op0;
3304 extern struct rtx_def *sh_compare_op1;
3306 /* Which processor to schedule for. The elements of the enumeration must
3307 match exactly the cpu attribute in the sh.md file. */
3309 enum processor_type {
3321 #define sh_cpu_attr ((enum attr_cpu)sh_cpu)
3322 extern enum processor_type sh_cpu;
3324 extern int optimize; /* needed for gen_casesi. */
3326 enum mdep_reorg_phase_e
3328 SH_BEFORE_MDEP_REORG,
3329 SH_INSERT_USES_LABELS,
3330 SH_SHORTEN_BRANCHES0,
3332 SH_SHORTEN_BRANCHES1,
3336 extern enum mdep_reorg_phase_e mdep_reorg_phase;
3338 /* Handle Renesas compiler's pragmas. */
3339 #define REGISTER_TARGET_PRAGMAS() do { \
3340 c_register_pragma (0, "interrupt", sh_pr_interrupt); \
3341 c_register_pragma (0, "trapa", sh_pr_trapa); \
3342 c_register_pragma (0, "nosave_low_regs", sh_pr_nosave_low_regs); \
3345 extern tree sh_deferred_function_attributes;
3346 extern tree *sh_deferred_function_attributes_tail;
3348 /* Set when processing a function with interrupt attribute. */
3350 extern int current_function_interrupt;
3353 /* Instructions with unfilled delay slots take up an
3354 extra two bytes for the nop in the delay slot.
3355 sh-dsp parallel processing insns are four bytes long. */
3357 #define ADJUST_INSN_LENGTH(X, LENGTH) \
3358 (LENGTH) += sh_insn_length_adjustment (X);
3360 /* Define this macro if it is advisable to hold scalars in registers
3361 in a wider mode than that declared by the program. In such cases,
3362 the value is constrained to be within the bounds of the declared
3363 type, but kept valid in the wider mode. The signedness of the
3364 extension may differ from that of the type.
3366 Leaving the unsignedp unchanged gives better code than always setting it
3367 to 0. This is despite the fact that we have only signed char and short
3368 load instructions. */
3369 #define PROMOTE_MODE(MODE, UNSIGNEDP, TYPE) \
3370 if (GET_MODE_CLASS (MODE) == MODE_INT \
3371 && GET_MODE_SIZE (MODE) < 4/* ! UNITS_PER_WORD */)\
3372 (UNSIGNEDP) = ((MODE) == SImode ? 0 : (UNSIGNEDP)), \
3373 (MODE) = (TARGET_SH1 ? SImode \
3374 : TARGET_SHMEDIA32 ? SImode : DImode);
3376 #define MAX_FIXED_MODE_SIZE (TARGET_SH5 ? 128 : 64)
3378 #define SIDI_OFF (TARGET_LITTLE_ENDIAN ? 0 : 4)
3380 /* ??? Define ACCUMULATE_OUTGOING_ARGS? This is more efficient than pushing
3381 and popping arguments. However, we do have push/pop instructions, and
3382 rather limited offsets (4 bits) in load/store instructions, so it isn't
3383 clear if this would give better code. If implemented, should check for
3384 compatibility problems. */
3386 #define SH_DYNAMIC_SHIFT_COST \
3387 (TARGET_HARD_SH4 ? 1 : TARGET_SH3 ? (TARGET_SMALLCODE ? 1 : 2) : 20)
3390 #define NUM_MODES_FOR_MODE_SWITCHING { FP_MODE_NONE }
3392 #define OPTIMIZE_MODE_SWITCHING(ENTITY) (TARGET_SH4 || TARGET_SH2A_DOUBLE)
3394 #define ACTUAL_NORMAL_MODE(ENTITY) \
3395 (TARGET_FPU_SINGLE ? FP_MODE_SINGLE : FP_MODE_DOUBLE)
3397 #define NORMAL_MODE(ENTITY) \
3398 (sh_cfun_interrupt_handler_p () \
3399 ? (TARGET_FMOVD ? FP_MODE_DOUBLE : FP_MODE_NONE) \
3400 : ACTUAL_NORMAL_MODE (ENTITY))
3402 #define MODE_ENTRY(ENTITY) NORMAL_MODE (ENTITY)
3404 #define MODE_EXIT(ENTITY) \
3405 (sh_cfun_attr_renesas_p () ? FP_MODE_NONE : NORMAL_MODE (ENTITY))
3407 #define EPILOGUE_USES(REGNO) ((TARGET_SH2E || TARGET_SH4) \
3408 && (REGNO) == FPSCR_REG)
3410 #define MODE_NEEDED(ENTITY, INSN) \
3411 (recog_memoized (INSN) >= 0 \
3412 ? get_attr_fp_mode (INSN) \
3415 #define MODE_AFTER(MODE, INSN) \
3417 && recog_memoized (INSN) >= 0 \
3418 && get_attr_fp_set (INSN) != FP_SET_NONE \
3419 ? (int) get_attr_fp_set (INSN) \
3422 #define MODE_PRIORITY_TO_MODE(ENTITY, N) \
3423 ((TARGET_FPU_SINGLE != 0) ^ (N) ? FP_MODE_SINGLE : FP_MODE_DOUBLE)
3425 #define EMIT_MODE_SET(ENTITY, MODE, HARD_REGS_LIVE) \
3426 fpscr_set_from_mem ((MODE), (HARD_REGS_LIVE))
3428 #define MD_CAN_REDIRECT_BRANCH(INSN, SEQ) \
3429 sh_can_redirect_branch ((INSN), (SEQ))
3431 #define DWARF_FRAME_RETURN_COLUMN \
3432 (TARGET_SH5 ? DWARF_FRAME_REGNUM (PR_MEDIA_REG) : DWARF_FRAME_REGNUM (PR_REG))
3434 #define EH_RETURN_DATA_REGNO(N) \
3435 ((N) < 4 ? (N) + (TARGET_SH5 ? 2U : 4U) : INVALID_REGNUM)
3437 #define EH_RETURN_STACKADJ_REGNO STATIC_CHAIN_REGNUM
3438 #define EH_RETURN_STACKADJ_RTX gen_rtx_REG (Pmode, EH_RETURN_STACKADJ_REGNO)
3440 /* We have to distinguish between code and data, so that we apply
3441 datalabel where and only where appropriate. Use sdataN for data. */
3442 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \
3443 ((flag_pic && (GLOBAL) ? DW_EH_PE_indirect : 0) \
3444 | (flag_pic ? DW_EH_PE_pcrel : DW_EH_PE_absptr) \
3445 | ((CODE) ? 0 : (TARGET_SHMEDIA64 ? DW_EH_PE_sdata8 : DW_EH_PE_sdata4)))
3447 /* Handle special EH pointer encodings. Absolute, pc-relative, and
3448 indirect are handled automatically. */
3449 #define ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX(FILE, ENCODING, SIZE, ADDR, DONE) \
3451 if (((ENCODING) & 0xf) != DW_EH_PE_sdata4 \
3452 && ((ENCODING) & 0xf) != DW_EH_PE_sdata8) \
3454 gcc_assert (GET_CODE (ADDR) == SYMBOL_REF); \
3455 SYMBOL_REF_FLAGS (ADDR) |= SYMBOL_FLAG_FUNCTION; \
3460 #if (defined CRT_BEGIN || defined CRT_END) && ! __SHMEDIA__
3461 /* SH constant pool breaks the devices in crtstuff.c to control section
3462 in where code resides. We have to write it as asm code. */
3463 #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
3464 asm (SECTION_OP "\n\
3470 1: .long " USER_LABEL_PREFIX #FUNC " - 0b\n\
3471 2:\n" TEXT_SECTION_ASM_OP);
3472 #endif /* (defined CRT_BEGIN || defined CRT_END) && ! __SHMEDIA__ */
3474 /* FIXME: middle-end support for highpart optimizations is missing. */
3475 #define high_life_started reload_in_progress
3477 #endif /* ! GCC_SH_H */