* defaults.h (FRAME_GROWS_DOWNWARD): Define to 0 if not defined.
[official-gcc.git] / gcc / config / sh / sh.h
blobfafa09e2631ce20e8ff8ca146a4f79ac58e20fc1
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 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)
12 any later version.
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. */
24 #ifndef GCC_SH_H
25 #define GCC_SH_H
27 #define TARGET_VERSION \
28 fputs (" (Hitachi SH)", stderr);
30 /* Unfortunately, insn-attrtab.c doesn't include insn-codes.h. We can't
31 include it here, because bconfig.h is also included by gencodes.c . */
32 /* ??? No longer true. */
33 extern int code_for_indirect_jump_scratch;
35 #define TARGET_CPU_CPP_BUILTINS() \
36 do { \
37 builtin_define ("__sh__"); \
38 builtin_assert ("cpu=sh"); \
39 builtin_assert ("machine=sh"); \
40 switch ((int) sh_cpu) \
41 { \
42 case PROCESSOR_SH1: \
43 builtin_define ("__sh1__"); \
44 break; \
45 case PROCESSOR_SH2: \
46 builtin_define ("__sh2__"); \
47 break; \
48 case PROCESSOR_SH2E: \
49 builtin_define ("__SH2E__"); \
50 break; \
51 case PROCESSOR_SH2A: \
52 builtin_define ("__SH2A__"); \
53 builtin_define (TARGET_SH2A_DOUBLE \
54 ? (TARGET_FPU_SINGLE ? "__SH2A_SINGLE__" : "__SH2A_DOUBLE__") \
55 : TARGET_FPU_ANY ? "__SH2A_SINGLE_ONLY__" \
56 : "__SH2A_NOFPU__"); \
57 break; \
58 case PROCESSOR_SH3: \
59 builtin_define ("__sh3__"); \
60 builtin_define ("__SH3__"); \
61 if (TARGET_HARD_SH4) \
62 builtin_define ("__SH4_NOFPU__"); \
63 break; \
64 case PROCESSOR_SH3E: \
65 builtin_define (TARGET_HARD_SH4 ? "__SH4_SINGLE_ONLY__" : "__SH3E__"); \
66 break; \
67 case PROCESSOR_SH4: \
68 builtin_define (TARGET_FPU_SINGLE ? "__SH4_SINGLE__" : "__SH4__"); \
69 break; \
70 case PROCESSOR_SH4A: \
71 builtin_define ("__SH4A__"); \
72 builtin_define (TARGET_SH4 \
73 ? (TARGET_FPU_SINGLE ? "__SH4_SINGLE__" : "__SH4__") \
74 : TARGET_FPU_ANY ? "__SH4_SINGLE_ONLY__" \
75 : "__SH4_NOFPU__"); \
76 break; \
77 case PROCESSOR_SH5: \
78 { \
79 builtin_define_with_value ("__SH5__", \
80 TARGET_SHMEDIA64 ? "64" : "32", 0); \
81 builtin_define_with_value ("__SHMEDIA__", \
82 TARGET_SHMEDIA ? "1" : "0", 0); \
83 if (! TARGET_FPU_DOUBLE) \
84 builtin_define ("__SH4_NOFPU__"); \
85 } \
86 } \
87 if (TARGET_FPU_ANY) \
88 builtin_define ("__SH_FPU_ANY__"); \
89 if (TARGET_FPU_DOUBLE) \
90 builtin_define ("__SH_FPU_DOUBLE__"); \
91 if (TARGET_HITACHI) \
92 builtin_define ("__HITACHI__"); \
93 builtin_define (TARGET_LITTLE_ENDIAN \
94 ? "__LITTLE_ENDIAN__" : "__BIG_ENDIAN__"); \
95 if (flag_pic) \
96 { \
97 builtin_define ("__pic__"); \
98 builtin_define ("__PIC__"); \
99 } \
100 } while (0)
102 /* We can not debug without a frame pointer. */
103 /* #define CAN_DEBUG_WITHOUT_FP */
105 #define CONDITIONAL_REGISTER_USAGE do \
107 int regno; \
108 for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno ++) \
109 if (! VALID_REGISTER_P (regno)) \
110 fixed_regs[regno] = call_used_regs[regno] = 1; \
111 /* R8 and R9 are call-clobbered on SH5, but not on earlier SH ABIs. */ \
112 if (TARGET_SH5) \
114 call_used_regs[FIRST_GENERAL_REG + 8] \
115 = call_used_regs[FIRST_GENERAL_REG + 9] = 1; \
116 call_really_used_regs[FIRST_GENERAL_REG + 8] \
117 = call_really_used_regs[FIRST_GENERAL_REG + 9] = 1; \
119 if (TARGET_SHMEDIA) \
121 regno_reg_class[FIRST_GENERAL_REG] = GENERAL_REGS; \
122 CLEAR_HARD_REG_SET (reg_class_contents[FP0_REGS]); \
123 regno_reg_class[FIRST_FP_REG] = FP_REGS; \
125 if (flag_pic) \
127 fixed_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \
128 call_used_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \
130 /* Renesas saves and restores mac registers on call. */ \
131 if (TARGET_HITACHI && ! TARGET_NOMACSAVE) \
133 call_really_used_regs[MACH_REG] = 0; \
134 call_really_used_regs[MACL_REG] = 0; \
136 for (regno = FIRST_FP_REG + (TARGET_LITTLE_ENDIAN != 0); \
137 regno <= LAST_FP_REG; regno += 2) \
138 SET_HARD_REG_BIT (reg_class_contents[DF_HI_REGS], regno); \
139 if (TARGET_SHMEDIA) \
141 for (regno = FIRST_TARGET_REG; regno <= LAST_TARGET_REG; regno ++)\
142 if (! fixed_regs[regno] && call_really_used_regs[regno]) \
143 SET_HARD_REG_BIT (reg_class_contents[SIBCALL_REGS], regno); \
145 else \
146 for (regno = FIRST_GENERAL_REG; regno <= LAST_GENERAL_REG; regno++) \
147 if (! fixed_regs[regno] && call_really_used_regs[regno]) \
148 SET_HARD_REG_BIT (reg_class_contents[SIBCALL_REGS], regno); \
149 } while (0)
151 /* Nonzero if this is an ELF target - compile time only */
152 #define TARGET_ELF 0
154 /* Nonzero if we should generate code using type 2E insns. */
155 #define TARGET_SH2E (TARGET_SH2 && TARGET_SH_E)
157 /* Nonzero if we should generate code using type 2A insns. */
158 #define TARGET_SH2A TARGET_HARD_SH2A
159 /* Nonzero if we should generate code using type 2A SF insns. */
160 #define TARGET_SH2A_SINGLE (TARGET_SH2A && TARGET_SH2E)
161 /* Nonzero if we should generate code using type 2A DF insns. */
162 #define TARGET_SH2A_DOUBLE (TARGET_HARD_SH2A_DOUBLE && TARGET_SH2A)
164 /* Nonzero if we should generate code using type 3E insns. */
165 #define TARGET_SH3E (TARGET_SH3 && TARGET_SH_E)
167 /* Nonzero if the cache line size is 32. */
168 #define TARGET_CACHE32 (TARGET_HARD_SH4 || TARGET_SH5)
170 /* Nonzero if we schedule for a superscalar implementation. */
171 #define TARGET_SUPERSCALAR TARGET_HARD_SH4
173 /* Nonzero if the target has separate instruction and data caches. */
174 #define TARGET_HARVARD (TARGET_HARD_SH4 || TARGET_SH5)
176 /* Nonzero if a double-precision FPU is available. */
177 #define TARGET_FPU_DOUBLE \
178 ((target_flags & MASK_SH4) != 0 || TARGET_SH2A_DOUBLE)
180 /* Nonzero if an FPU is available. */
181 #define TARGET_FPU_ANY (TARGET_SH2E || TARGET_FPU_DOUBLE)
183 /* Nonzero if we should generate code using type 4 insns. */
184 #undef TARGET_SH4
185 #define TARGET_SH4 ((target_flags & MASK_SH4) != 0 && TARGET_SH1)
187 /* Nonzero if we're generating code for the common subset of
188 instructions present on both SH4a and SH4al-dsp. */
189 #define TARGET_SH4A_ARCH TARGET_SH4A
191 /* Nonzero if we're generating code for SH4a, unless the use of the
192 FPU is disabled (which makes it compatible with SH4al-dsp). */
193 #define TARGET_SH4A_FP (TARGET_SH4A_ARCH && TARGET_FPU_ANY)
195 /* Nonzero if we should generate code using the SHcompact instruction
196 set and 32-bit ABI. */
197 #define TARGET_SHCOMPACT (TARGET_SH5 && TARGET_SH1)
199 /* Nonzero if we should generate code using the SHmedia instruction
200 set and ABI. */
201 #define TARGET_SHMEDIA (TARGET_SH5 && ! TARGET_SH1)
203 /* Nonzero if we should generate code using the SHmedia ISA and 32-bit
204 ABI. */
205 #define TARGET_SHMEDIA32 (TARGET_SH5 && ! TARGET_SH1 && TARGET_SH_E)
207 /* Nonzero if we should generate code using the SHmedia ISA and 64-bit
208 ABI. */
209 #define TARGET_SHMEDIA64 (TARGET_SH5 && ! TARGET_SH1 && ! TARGET_SH_E)
211 /* Nonzero if we should generate code using SHmedia FPU instructions. */
212 #define TARGET_SHMEDIA_FPU (TARGET_SHMEDIA && TARGET_FPU_DOUBLE)
214 /* This is not used by the SH2E calling convention */
215 #define TARGET_VARARGS_PRETEND_ARGS(FUN_DECL) \
216 (TARGET_SH1 && ! TARGET_SH2E && ! TARGET_SH5 \
217 && ! (TARGET_HITACHI || sh_attr_renesas_p (FUN_DECL)))
219 #ifndef TARGET_CPU_DEFAULT
220 #define TARGET_CPU_DEFAULT SELECT_SH1
221 #define SUPPORT_SH1 1
222 #define SUPPORT_SH2E 1
223 #define SUPPORT_SH4 1
224 #define SUPPORT_SH4_SINGLE 1
225 #define SUPPORT_SH2A 1
226 #define SUPPORT_SH2A_SINGLE 1
227 #endif
229 #define TARGET_DIVIDE_INV \
230 (sh_div_strategy == SH_DIV_INV || sh_div_strategy == SH_DIV_INV_MINLAT \
231 || sh_div_strategy == SH_DIV_INV20U || sh_div_strategy == SH_DIV_INV20L \
232 || sh_div_strategy == SH_DIV_INV_CALL \
233 || sh_div_strategy == SH_DIV_INV_CALL2 || sh_div_strategy == SH_DIV_INV_FP)
234 #define TARGET_DIVIDE_FP (sh_div_strategy == SH_DIV_FP)
235 #define TARGET_DIVIDE_INV_FP (sh_div_strategy == SH_DIV_INV_FP)
236 #define TARGET_DIVIDE_CALL2 (sh_div_strategy == SH_DIV_CALL2)
237 #define TARGET_DIVIDE_INV_MINLAT (sh_div_strategy == SH_DIV_INV_MINLAT)
238 #define TARGET_DIVIDE_INV20U (sh_div_strategy == SH_DIV_INV20U)
239 #define TARGET_DIVIDE_INV20L (sh_div_strategy == SH_DIV_INV20L)
240 #define TARGET_DIVIDE_INV_CALL (sh_div_strategy == SH_DIV_INV_CALL)
241 #define TARGET_DIVIDE_INV_CALL2 (sh_div_strategy == SH_DIV_INV_CALL2)
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 \
246 | MASK_FPU_SINGLE)
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 \
261 | SELECT_SH3)
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)
274 #if SUPPORT_SH1
275 #define SUPPORT_SH2 1
276 #endif
277 #if SUPPORT_SH2
278 #define SUPPORT_SH3 1
279 #endif
280 #if SUPPORT_SH3
281 #define SUPPORT_SH4_NOFPU 1
282 #endif
283 #if SUPPORT_SH4_NOFPU
284 #define SUPPORT_SH4A_NOFPU 1
285 #define SUPPORT_SH4AL 1
286 #define SUPPORT_SH2A_NOFPU 1
287 #endif
289 #if SUPPORT_SH2E
290 #define SUPPORT_SH3E 1
291 #endif
292 #if SUPPORT_SH3E
293 #define SUPPORT_SH4_SINGLE_ONLY 1
294 #define SUPPORT_SH4A_SINGLE_ONLY 1
295 #define SUPPORT_SH2A_SINGLE_ONLY 1
296 #endif
298 #if SUPPORT_SH4
299 #define SUPPORT_SH4A 1
300 #endif
302 #if SUPPORT_SH4_SINGLE
303 #define SUPPORT_SH4A_SINGLE 1
304 #endif
306 #if SUPPORT_SH5_COMPAT
307 #define SUPPORT_SH5_32MEDIA 1
308 #endif
310 #if SUPPORT_SH5_COMPACT_NOFPU
311 #define SUPPORT_SH5_32MEDIA_NOFPU 1
312 #endif
314 #define SUPPORT_ANY_SH5_32MEDIA \
315 (SUPPORT_SH5_32MEDIA || SUPPORT_SH5_32MEDIA_NOFPU)
316 #define SUPPORT_ANY_SH5_64MEDIA \
317 (SUPPORT_SH5_64MEDIA || SUPPORT_SH5_64MEDIA_NOFPU)
318 #define SUPPORT_ANY_SH5 \
319 (SUPPORT_ANY_SH5_32MEDIA || SUPPORT_ANY_SH5_64MEDIA)
321 /* Reset all target-selection flags. */
322 #define MASK_ARCH (MASK_SH1 | MASK_SH2 | MASK_SH3 | MASK_SH_E | MASK_SH4 \
323 | MASK_HARD_SH2A | MASK_HARD_SH2A_DOUBLE | MASK_SH4A \
324 | MASK_HARD_SH4 | MASK_FPU_SINGLE | MASK_SH5)
326 /* This defaults us to big-endian. */
327 #ifndef TARGET_ENDIAN_DEFAULT
328 #define TARGET_ENDIAN_DEFAULT 0
329 #endif
331 #ifndef TARGET_OPT_DEFAULT
332 #define TARGET_OPT_DEFAULT MASK_ADJUST_UNROLL
333 #endif
335 #define TARGET_DEFAULT \
336 (TARGET_CPU_DEFAULT | TARGET_ENDIAN_DEFAULT | TARGET_OPT_DEFAULT)
338 #ifndef SH_MULTILIB_CPU_DEFAULT
339 #define SH_MULTILIB_CPU_DEFAULT "m1"
340 #endif
342 #if TARGET_ENDIAN_DEFAULT
343 #define MULTILIB_DEFAULTS { "ml", SH_MULTILIB_CPU_DEFAULT }
344 #else
345 #define MULTILIB_DEFAULTS { "mb", SH_MULTILIB_CPU_DEFAULT }
346 #endif
348 #define CPP_SPEC " %(subtarget_cpp_spec) "
350 #ifndef SUBTARGET_CPP_SPEC
351 #define SUBTARGET_CPP_SPEC ""
352 #endif
354 #ifndef SUBTARGET_EXTRA_SPECS
355 #define SUBTARGET_EXTRA_SPECS
356 #endif
358 #define EXTRA_SPECS \
359 { "subtarget_cpp_spec", SUBTARGET_CPP_SPEC }, \
360 { "link_emul_prefix", LINK_EMUL_PREFIX }, \
361 { "link_default_cpu_emul", LINK_DEFAULT_CPU_EMUL }, \
362 { "subtarget_link_emul_suffix", SUBTARGET_LINK_EMUL_SUFFIX }, \
363 { "subtarget_link_spec", SUBTARGET_LINK_SPEC }, \
364 { "subtarget_asm_endian_spec", SUBTARGET_ASM_ENDIAN_SPEC }, \
365 { "subtarget_asm_relax_spec", SUBTARGET_ASM_RELAX_SPEC }, \
366 { "subtarget_asm_isa_spec", SUBTARGET_ASM_ISA_SPEC }, \
367 { "subtarget_asm_spec", SUBTARGET_ASM_SPEC }, \
368 SUBTARGET_EXTRA_SPECS
370 #if TARGET_CPU_DEFAULT & MASK_HARD_SH4
371 #define SUBTARGET_ASM_RELAX_SPEC "%{!m1:%{!m2:%{!m3*:%{!m5*:-isa=sh4}}}}"
372 #else
373 #define SUBTARGET_ASM_RELAX_SPEC "%{m4*:-isa=sh4}"
374 #endif
376 #define SH_ASM_SPEC \
377 "%(subtarget_asm_endian_spec) %{mrelax:-relax %(subtarget_asm_relax_spec)}\
378 %(subtarget_asm_isa_spec) %(subtarget_asm_spec)\
379 %{m2a:--isa=sh2a} \
380 %{m2a-single:--isa=sh2a} \
381 %{m2a-single-only:--isa=sh2a} \
382 %{m2a-nofpu:--isa=sh2a-nofpu} \
383 %{m5-compact*:--isa=SHcompact} \
384 %{m5-32media*:--isa=SHmedia --abi=32} \
385 %{m5-64media*:--isa=SHmedia --abi=64} \
386 %{m4al:-dsp} %{mcut2-workaround:-cut2-workaround}"
388 #define ASM_SPEC SH_ASM_SPEC
390 #ifndef SUBTARGET_ASM_ENDIAN_SPEC
391 #if TARGET_ENDIAN_DEFAULT == MASK_LITTLE_ENDIAN
392 #define SUBTARGET_ASM_ENDIAN_SPEC "%{mb:-big} %{!mb:-little}"
393 #else
394 #define SUBTARGET_ASM_ENDIAN_SPEC "%{ml:-little} %{!ml:-big}"
395 #endif
396 #endif
398 #if STRICT_NOFPU == 1
399 /* Strict nofpu means that the compiler should tell the assembler
400 to reject FPU instructions. E.g. from ASM inserts. */
401 #if TARGET_CPU_DEFAULT & MASK_HARD_SH4 && !(TARGET_CPU_DEFAULT & MASK_SH_E)
402 #define SUBTARGET_ASM_ISA_SPEC "%{!m1:%{!m2:%{!m3*:%{m4-nofpu|!m4*:%{!m5:-isa=sh4-nofpu}}}}}"
403 #else
404 /* If there were an -isa option for sh5-nofpu then it would also go here. */
405 #define SUBTARGET_ASM_ISA_SPEC \
406 "%{m4-nofpu:-isa=sh4-nofpu} " ASM_ISA_DEFAULT_SPEC
407 #endif
408 #else /* ! STRICT_NOFPU */
409 #define SUBTARGET_ASM_ISA_SPEC ASM_ISA_DEFAULT_SPEC
410 #endif
412 #ifndef SUBTARGET_ASM_SPEC
413 #define SUBTARGET_ASM_SPEC ""
414 #endif
416 #if TARGET_ENDIAN_DEFAULT == MASK_LITTLE_ENDIAN
417 #define LINK_EMUL_PREFIX "sh%{!mb:l}"
418 #else
419 #define LINK_EMUL_PREFIX "sh%{ml:l}"
420 #endif
422 #if TARGET_CPU_DEFAULT & MASK_SH5
423 #if TARGET_CPU_DEFAULT & MASK_SH_E
424 #define LINK_DEFAULT_CPU_EMUL "32"
425 #if TARGET_CPU_DEFAULT & MASK_SH1
426 #define ASM_ISA_SPEC_DEFAULT "--isa=SHcompact"
427 #else
428 #define ASM_ISA_SPEC_DEFAULT "--isa=SHmedia --abi=32"
429 #endif /* MASK_SH1 */
430 #else /* !MASK_SH_E */
431 #define LINK_DEFAULT_CPU_EMUL "64"
432 #define ASM_ISA_SPEC_DEFAULT "--isa=SHmedia --abi=64"
433 #endif /* MASK_SH_E */
434 #define ASM_ISA_DEFAULT_SPEC \
435 " %{!m1:%{!m2*:%{!m3*:%{!m4*:%{!m5*:" ASM_ISA_SPEC_DEFAULT "}}}}}"
436 #else /* !MASK_SH5 */
437 #define LINK_DEFAULT_CPU_EMUL ""
438 #define ASM_ISA_DEFAULT_SPEC ""
439 #endif /* MASK_SH5 */
441 #define SUBTARGET_LINK_EMUL_SUFFIX ""
442 #define SUBTARGET_LINK_SPEC ""
444 /* svr4.h redefines LINK_SPEC inappropriately, so go via SH_LINK_SPEC,
445 so that we can undo the damage without code replication. */
446 #define LINK_SPEC SH_LINK_SPEC
448 #define SH_LINK_SPEC "\
449 -m %(link_emul_prefix)\
450 %{m5-compact*|m5-32media*:32}\
451 %{m5-64media*:64}\
452 %{!m1:%{!m2:%{!m3*:%{!m4*:%{!m5*:%(link_default_cpu_emul)}}}}}\
453 %(subtarget_link_emul_suffix) \
454 %{mrelax:-relax} %(subtarget_link_spec)"
456 #ifndef SH_DIV_STR_FOR_SIZE
457 #define SH_DIV_STR_FOR_SIZE "call"
458 #endif
460 #define DRIVER_SELF_SPECS "%{m2a:%{ml:%eSH2a does not support little-endian}}"
461 #define OPTIMIZATION_OPTIONS(LEVEL,SIZE) \
462 do { \
463 if (LEVEL) \
465 flag_omit_frame_pointer = -1; \
466 if (! SIZE) \
467 sh_div_str = "inv:minlat"; \
469 if (SIZE) \
471 target_flags |= MASK_SMALLCODE; \
472 sh_div_str = SH_DIV_STR_FOR_SIZE ; \
474 /* We can't meaningfully test TARGET_SHMEDIA here, because -m options \
475 haven't been parsed yet, hence we';d read only the default. \
476 sh_target_reg_class will return NO_REGS if this is not SHMEDIA, so \
477 it's OK to always set flag_branch_target_load_optimize. */ \
478 if (LEVEL > 1) \
480 flag_branch_target_load_optimize = 1; \
481 if (! (SIZE)) \
482 target_flags |= MASK_SAVE_ALL_TARGET_REGS; \
484 /* Likewise, we can't meaningfully test TARGET_SH2E / TARGET_IEEE \
485 here, so leave it to OVERRIDE_OPTIONS to set \
486 flag_finite_math_only. We set it to 2 here so we know if the user \
487 explicitly requested this to be on or off. */ \
488 flag_finite_math_only = 2; \
489 } while (0)
491 #define ASSEMBLER_DIALECT assembler_dialect
493 extern int assembler_dialect;
495 enum sh_divide_strategy_e {
496 SH_DIV_CALL,
497 SH_DIV_CALL2,
498 SH_DIV_FP,
499 SH_DIV_INV,
500 SH_DIV_INV_MINLAT,
501 SH_DIV_INV20U,
502 SH_DIV_INV20L,
503 SH_DIV_INV_CALL,
504 SH_DIV_INV_CALL2,
505 SH_DIV_INV_FP
508 extern enum sh_divide_strategy_e sh_div_strategy;
510 #ifndef SH_DIV_STRATEGY_DEFAULT
511 #define SH_DIV_STRATEGY_DEFAULT SH_DIV_CALL
512 #endif
514 #define OVERRIDE_OPTIONS \
515 do { \
516 int regno; \
518 if (flag_finite_math_only == 2) \
519 flag_finite_math_only \
520 = !flag_signaling_nans && TARGET_SH2E && ! TARGET_IEEE; \
521 if (TARGET_SH2E && !flag_finite_math_only) \
522 target_flags |= MASK_IEEE; \
523 sh_cpu = CPU_SH1; \
524 assembler_dialect = 0; \
525 if (TARGET_SH2) \
526 sh_cpu = CPU_SH2; \
527 if (TARGET_SH2E) \
528 sh_cpu = CPU_SH2E; \
529 if (TARGET_SH2A) \
531 sh_cpu = CPU_SH2A; \
532 if (TARGET_SH2A_DOUBLE) \
533 target_flags |= MASK_FMOVD; \
535 if (TARGET_SH3) \
536 sh_cpu = CPU_SH3; \
537 if (TARGET_SH3E) \
538 sh_cpu = CPU_SH3E; \
539 if (TARGET_SH4) \
541 assembler_dialect = 1; \
542 sh_cpu = CPU_SH4; \
544 if (TARGET_SH4A_ARCH) \
546 assembler_dialect = 1; \
547 sh_cpu = CPU_SH4A; \
549 if (TARGET_SH5) \
551 sh_cpu = CPU_SH5; \
552 target_flags |= MASK_ALIGN_DOUBLE; \
553 if (TARGET_SHMEDIA_FPU) \
554 target_flags |= MASK_FMOVD; \
555 if (TARGET_SHMEDIA) \
557 /* There are no delay slots on SHmedia. */ \
558 flag_delayed_branch = 0; \
559 /* Relaxation isn't yet supported for SHmedia */ \
560 target_flags &= ~MASK_RELAX; \
561 /* After reload, if conversion does little good but can cause \
562 ICEs: \
563 - find_if_block doesn't do anything for SH because we don't\
564 have conditional execution patterns. (We use conditional\
565 move patterns, which are handled differently, and only \
566 before reload). \
567 - find_cond_trap doesn't do anything for the SH because we \
568 don't have conditional traps. \
569 - find_if_case_1 uses redirect_edge_and_branch_force in \
570 the only path that does an optimization, and this causes \
571 an ICE when branch targets are in registers. \
572 - find_if_case_2 doesn't do anything for the SHmedia after \
573 reload except when it can redirect a tablejump - and \
574 that's rather rare. */ \
575 flag_if_conversion2 = 0; \
576 if (! strcmp (sh_div_str, "call")) \
577 sh_div_strategy = SH_DIV_CALL; \
578 else if (! strcmp (sh_div_str, "call2")) \
579 sh_div_strategy = SH_DIV_CALL2; \
580 if (! strcmp (sh_div_str, "fp") && TARGET_FPU_ANY) \
581 sh_div_strategy = SH_DIV_FP; \
582 else if (! strcmp (sh_div_str, "inv")) \
583 sh_div_strategy = SH_DIV_INV; \
584 else if (! strcmp (sh_div_str, "inv:minlat")) \
585 sh_div_strategy = SH_DIV_INV_MINLAT; \
586 else if (! strcmp (sh_div_str, "inv20u")) \
587 sh_div_strategy = SH_DIV_INV20U; \
588 else if (! strcmp (sh_div_str, "inv20l")) \
589 sh_div_strategy = SH_DIV_INV20L; \
590 else if (! strcmp (sh_div_str, "inv:call2")) \
591 sh_div_strategy = SH_DIV_INV_CALL2; \
592 else if (! strcmp (sh_div_str, "inv:call")) \
593 sh_div_strategy = SH_DIV_INV_CALL; \
594 else if (! strcmp (sh_div_str, "inv:fp")) \
596 if (TARGET_FPU_ANY) \
597 sh_div_strategy = SH_DIV_INV_FP; \
598 else \
599 sh_div_strategy = SH_DIV_INV; \
602 /* -fprofile-arcs needs a working libgcov . In unified tree \
603 configurations with newlib, this requires to configure with \
604 --with-newlib --with-headers. But there is no way to check \
605 here we have a working libgcov, so just assume that we have. */\
606 if (profile_flag) \
607 warning (0, "Profiling is still experimental for this target.");\
609 else \
611 /* Only the sh64-elf assembler fully supports .quad properly. */\
612 targetm.asm_out.aligned_op.di = NULL; \
613 targetm.asm_out.unaligned_op.di = NULL; \
615 if (sh_divsi3_libfunc[0]) \
616 ; /* User supplied - leave it alone. */ \
617 else if (TARGET_HARD_SH4 && TARGET_SH2E) \
618 sh_divsi3_libfunc = "__sdivsi3_i4"; \
619 else if (TARGET_SH5) \
621 if (TARGET_FPU_ANY && TARGET_SH1) \
622 sh_divsi3_libfunc = "__sdivsi3_i4"; \
623 else \
624 sh_divsi3_libfunc = "__sdivsi3_1"; \
626 else \
627 sh_divsi3_libfunc = "__sdivsi3"; \
628 if (TARGET_FMOVD) \
629 reg_class_from_letter['e' - 'a'] = NO_REGS; \
631 for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++) \
632 if (! VALID_REGISTER_P (regno)) \
633 sh_register_names[regno][0] = '\0'; \
635 for (regno = 0; regno < ADDREGNAMES_SIZE; regno++) \
636 if (! VALID_REGISTER_P (ADDREGNAMES_REGNO (regno))) \
637 sh_additional_register_names[regno][0] = '\0'; \
639 if (flag_omit_frame_pointer < 0) \
641 /* The debugging information is sufficient, \
642 but gdb doesn't implement this yet */ \
643 if (0) \
644 flag_omit_frame_pointer \
645 = (PREFERRED_DEBUGGING_TYPE == DWARF2_DEBUG); \
646 else \
647 flag_omit_frame_pointer = 0; \
650 if ((flag_pic && ! TARGET_PREFERGOT) \
651 || (TARGET_SHMEDIA && !TARGET_PT_FIXED)) \
652 flag_no_function_cse = 1; \
654 if (SMALL_REGISTER_CLASSES) \
656 /* Never run scheduling before reload, since that can \
657 break global alloc, and generates slower code anyway due \
658 to the pressure on R0. */ \
659 /* Enable sched1 for SH4; ready queue will be reordered by \
660 the target hooks when pressure is high. We can not do this for \
661 SH3 and lower as they give spill failures for R0. */ \
662 if (!TARGET_HARD_SH4) \
663 flag_schedule_insns = 0; \
666 if (align_loops == 0) \
667 align_loops = 1 << (TARGET_SH5 ? 3 : 2); \
668 if (align_jumps == 0) \
669 align_jumps = 1 << CACHE_LOG; \
670 else if (align_jumps < (TARGET_SHMEDIA ? 4 : 2)) \
671 align_jumps = TARGET_SHMEDIA ? 4 : 2; \
673 /* Allocation boundary (in *bytes*) for the code of a function. \
674 SH1: 32 bit alignment is faster, because instructions are always \
675 fetched as a pair from a longword boundary. \
676 SH2 .. SH5 : align to cache line start. */ \
677 if (align_functions == 0) \
678 align_functions \
679 = TARGET_SMALLCODE ? FUNCTION_BOUNDARY/8 : (1 << CACHE_LOG); \
680 /* The linker relaxation code breaks when a function contains \
681 alignments that are larger than that at the start of a \
682 compilation unit. */ \
683 if (TARGET_RELAX) \
685 int min_align \
686 = align_loops > align_jumps ? align_loops : align_jumps; \
688 /* Also take possible .long constants / mova tables int account. */\
689 if (min_align < 4) \
690 min_align = 4; \
691 if (align_functions < min_align) \
692 align_functions = min_align; \
694 } while (0)
696 /* Target machine storage layout. */
698 /* Define this if most significant bit is lowest numbered
699 in instructions that operate on numbered bit-fields. */
701 #define BITS_BIG_ENDIAN 0
703 /* Define this if most significant byte of a word is the lowest numbered. */
704 #define BYTES_BIG_ENDIAN (TARGET_LITTLE_ENDIAN == 0)
706 /* Define this if most significant word of a multiword number is the lowest
707 numbered. */
708 #define WORDS_BIG_ENDIAN (TARGET_LITTLE_ENDIAN == 0)
710 /* Define this to set the endianness to use in libgcc2.c, which can
711 not depend on target_flags. */
712 #if defined(__LITTLE_ENDIAN__)
713 #define LIBGCC2_WORDS_BIG_ENDIAN 0
714 #else
715 #define LIBGCC2_WORDS_BIG_ENDIAN 1
716 #endif
718 #define MAX_BITS_PER_WORD 64
720 /* Width in bits of an `int'. We want just 32-bits, even if words are
721 longer. */
722 #define INT_TYPE_SIZE 32
724 /* Width in bits of a `long'. */
725 #define LONG_TYPE_SIZE (TARGET_SHMEDIA64 ? 64 : 32)
727 /* Width in bits of a `long long'. */
728 #define LONG_LONG_TYPE_SIZE 64
730 /* Width in bits of a `long double'. */
731 #define LONG_DOUBLE_TYPE_SIZE 64
733 /* Width of a word, in units (bytes). */
734 #define UNITS_PER_WORD (TARGET_SHMEDIA ? 8 : 4)
735 #define MIN_UNITS_PER_WORD 4
737 /* Scaling factor for Dwarf data offsets for CFI information.
738 The dwarf2out.c default would use -UNITS_PER_WORD, which is -8 for
739 SHmedia; however, since we do partial register saves for the registers
740 visible to SHcompact, and for target registers for SHMEDIA32, we have
741 to allow saves that are only 4-byte aligned. */
742 #define DWARF_CIE_DATA_ALIGNMENT -4
744 /* Width in bits of a pointer.
745 See also the macro `Pmode' defined below. */
746 #define POINTER_SIZE (TARGET_SHMEDIA64 ? 64 : 32)
748 /* Allocation boundary (in *bits*) for storing arguments in argument list. */
749 #define PARM_BOUNDARY (TARGET_SH5 ? 64 : 32)
751 /* Boundary (in *bits*) on which stack pointer should be aligned. */
752 #define STACK_BOUNDARY BIGGEST_ALIGNMENT
754 /* The log (base 2) of the cache line size, in bytes. Processors prior to
755 SH2 have no actual cache, but they fetch code in chunks of 4 bytes.
756 The SH2/3 have 16 byte cache lines, and the SH4 has a 32 byte cache line */
757 #define CACHE_LOG (TARGET_CACHE32 ? 5 : TARGET_SH2 ? 4 : 2)
759 /* ABI given & required minimum allocation boundary (in *bits*) for the
760 code of a function. */
761 #define FUNCTION_BOUNDARY (16 << TARGET_SHMEDIA)
763 /* On SH5, the lowest bit is used to indicate SHmedia functions, so
764 the vbit must go into the delta field of
765 pointers-to-member-functions. */
766 #define TARGET_PTRMEMFUNC_VBIT_LOCATION \
767 (TARGET_SH5 ? ptrmemfunc_vbit_in_delta : ptrmemfunc_vbit_in_pfn)
769 /* Alignment of field after `int : 0' in a structure. */
770 #define EMPTY_FIELD_BOUNDARY 32
772 /* No data type wants to be aligned rounder than this. */
773 #define BIGGEST_ALIGNMENT (TARGET_ALIGN_DOUBLE ? 64 : 32)
775 /* The best alignment to use in cases where we have a choice. */
776 #define FASTEST_ALIGNMENT (TARGET_SH5 ? 64 : 32)
778 /* Make strings word-aligned so strcpy from constants will be faster. */
779 #define CONSTANT_ALIGNMENT(EXP, ALIGN) \
780 ((TREE_CODE (EXP) == STRING_CST \
781 && (ALIGN) < FASTEST_ALIGNMENT) \
782 ? FASTEST_ALIGNMENT : (ALIGN))
784 /* get_mode_alignment assumes complex values are always held in multiple
785 registers, but that is not the case on the SH; CQImode and CHImode are
786 held in a single integer register. SH5 also holds CSImode and SCmode
787 values in integer registers. This is relevant for argument passing on
788 SHcompact as we use a stack temp in order to pass CSImode by reference. */
789 #define LOCAL_ALIGNMENT(TYPE, ALIGN) \
790 ((GET_MODE_CLASS (TYPE_MODE (TYPE)) == MODE_COMPLEX_INT \
791 || GET_MODE_CLASS (TYPE_MODE (TYPE)) == MODE_COMPLEX_FLOAT) \
792 ? (unsigned) MIN (BIGGEST_ALIGNMENT, GET_MODE_BITSIZE (TYPE_MODE (TYPE))) \
793 : (unsigned) ALIGN)
795 /* Make arrays of chars word-aligned for the same reasons. */
796 #define DATA_ALIGNMENT(TYPE, ALIGN) \
797 (TREE_CODE (TYPE) == ARRAY_TYPE \
798 && TYPE_MODE (TREE_TYPE (TYPE)) == QImode \
799 && (ALIGN) < FASTEST_ALIGNMENT ? FASTEST_ALIGNMENT : (ALIGN))
801 /* Number of bits which any structure or union's size must be a
802 multiple of. Each structure or union's size is rounded up to a
803 multiple of this. */
804 #define STRUCTURE_SIZE_BOUNDARY (TARGET_PADSTRUCT ? 32 : 8)
806 /* Set this nonzero if move instructions will actually fail to work
807 when given unaligned data. */
808 #define STRICT_ALIGNMENT 1
810 /* If LABEL_AFTER_BARRIER demands an alignment, return its base 2 logarithm. */
811 #define LABEL_ALIGN_AFTER_BARRIER(LABEL_AFTER_BARRIER) \
812 barrier_align (LABEL_AFTER_BARRIER)
814 #define LOOP_ALIGN(A_LABEL) \
815 ((! optimize || TARGET_HARD_SH4 || TARGET_SMALLCODE) \
816 ? 0 : sh_loop_align (A_LABEL))
818 #define LABEL_ALIGN(A_LABEL) \
820 (PREV_INSN (A_LABEL) \
821 && GET_CODE (PREV_INSN (A_LABEL)) == INSN \
822 && GET_CODE (PATTERN (PREV_INSN (A_LABEL))) == UNSPEC_VOLATILE \
823 && XINT (PATTERN (PREV_INSN (A_LABEL)), 1) == UNSPECV_ALIGN) \
824 /* explicit alignment insn in constant tables. */ \
825 ? INTVAL (XVECEXP (PATTERN (PREV_INSN (A_LABEL)), 0, 0)) \
826 : 0)
828 /* Jump tables must be 32 bit aligned, no matter the size of the element. */
829 #define ADDR_VEC_ALIGN(ADDR_VEC) 2
831 /* The base two logarithm of the known minimum alignment of an insn length. */
832 #define INSN_LENGTH_ALIGNMENT(A_INSN) \
833 (GET_CODE (A_INSN) == INSN \
834 ? 1 << TARGET_SHMEDIA \
835 : GET_CODE (A_INSN) == JUMP_INSN || GET_CODE (A_INSN) == CALL_INSN \
836 ? 1 << TARGET_SHMEDIA \
837 : CACHE_LOG)
839 /* Standard register usage. */
841 /* Register allocation for the Renesas calling convention:
843 r0 arg return
844 r1..r3 scratch
845 r4..r7 args in
846 r8..r13 call saved
847 r14 frame pointer/call saved
848 r15 stack pointer
849 ap arg pointer (doesn't really exist, always eliminated)
850 pr subroutine return address
851 t t bit
852 mach multiply/accumulate result, high part
853 macl multiply/accumulate result, low part.
854 fpul fp/int communication register
855 rap return address pointer register
856 fr0 fp arg return
857 fr1..fr3 scratch floating point registers
858 fr4..fr11 fp args in
859 fr12..fr15 call saved floating point registers */
861 #define MAX_REGISTER_NAME_LENGTH 5
862 extern char sh_register_names[][MAX_REGISTER_NAME_LENGTH + 1];
864 #define SH_REGISTER_NAMES_INITIALIZER \
866 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
867 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", \
868 "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", \
869 "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31", \
870 "r32", "r33", "r34", "r35", "r36", "r37", "r38", "r39", \
871 "r40", "r41", "r42", "r43", "r44", "r45", "r46", "r47", \
872 "r48", "r49", "r50", "r51", "r52", "r53", "r54", "r55", \
873 "r56", "r57", "r58", "r59", "r60", "r61", "r62", "r63", \
874 "fr0", "fr1", "fr2", "fr3", "fr4", "fr5", "fr6", "fr7", \
875 "fr8", "fr9", "fr10", "fr11", "fr12", "fr13", "fr14", "fr15", \
876 "fr16", "fr17", "fr18", "fr19", "fr20", "fr21", "fr22", "fr23", \
877 "fr24", "fr25", "fr26", "fr27", "fr28", "fr29", "fr30", "fr31", \
878 "fr32", "fr33", "fr34", "fr35", "fr36", "fr37", "fr38", "fr39", \
879 "fr40", "fr41", "fr42", "fr43", "fr44", "fr45", "fr46", "fr47", \
880 "fr48", "fr49", "fr50", "fr51", "fr52", "fr53", "fr54", "fr55", \
881 "fr56", "fr57", "fr58", "fr59", "fr60", "fr61", "fr62", "fr63", \
882 "tr0", "tr1", "tr2", "tr3", "tr4", "tr5", "tr6", "tr7", \
883 "xd0", "xd2", "xd4", "xd6", "xd8", "xd10", "xd12", "xd14", \
884 "gbr", "ap", "pr", "t", "mach", "macl", "fpul", "fpscr", \
885 "rap" \
888 #define REGNAMES_ARR_INDEX_1(index) \
889 (sh_register_names[index])
890 #define REGNAMES_ARR_INDEX_2(index) \
891 REGNAMES_ARR_INDEX_1 ((index)), REGNAMES_ARR_INDEX_1 ((index)+1)
892 #define REGNAMES_ARR_INDEX_4(index) \
893 REGNAMES_ARR_INDEX_2 ((index)), REGNAMES_ARR_INDEX_2 ((index)+2)
894 #define REGNAMES_ARR_INDEX_8(index) \
895 REGNAMES_ARR_INDEX_4 ((index)), REGNAMES_ARR_INDEX_4 ((index)+4)
896 #define REGNAMES_ARR_INDEX_16(index) \
897 REGNAMES_ARR_INDEX_8 ((index)), REGNAMES_ARR_INDEX_8 ((index)+8)
898 #define REGNAMES_ARR_INDEX_32(index) \
899 REGNAMES_ARR_INDEX_16 ((index)), REGNAMES_ARR_INDEX_16 ((index)+16)
900 #define REGNAMES_ARR_INDEX_64(index) \
901 REGNAMES_ARR_INDEX_32 ((index)), REGNAMES_ARR_INDEX_32 ((index)+32)
903 #define REGISTER_NAMES \
905 REGNAMES_ARR_INDEX_64 (0), \
906 REGNAMES_ARR_INDEX_64 (64), \
907 REGNAMES_ARR_INDEX_8 (128), \
908 REGNAMES_ARR_INDEX_8 (136), \
909 REGNAMES_ARR_INDEX_8 (144), \
910 REGNAMES_ARR_INDEX_1 (152) \
913 #define ADDREGNAMES_SIZE 32
914 #define MAX_ADDITIONAL_REGISTER_NAME_LENGTH 4
915 extern char sh_additional_register_names[ADDREGNAMES_SIZE] \
916 [MAX_ADDITIONAL_REGISTER_NAME_LENGTH + 1];
918 #define SH_ADDITIONAL_REGISTER_NAMES_INITIALIZER \
920 "dr0", "dr2", "dr4", "dr6", "dr8", "dr10", "dr12", "dr14", \
921 "dr16", "dr18", "dr20", "dr22", "dr24", "dr26", "dr28", "dr30", \
922 "dr32", "dr34", "dr36", "dr38", "dr40", "dr42", "dr44", "dr46", \
923 "dr48", "dr50", "dr52", "dr54", "dr56", "dr58", "dr60", "dr62" \
926 #define ADDREGNAMES_REGNO(index) \
927 ((index < 32) ? (FIRST_FP_REG + (index) * 2) \
928 : (-1))
930 #define ADDREGNAMES_ARR_INDEX_1(index) \
931 { (sh_additional_register_names[index]), ADDREGNAMES_REGNO (index) }
932 #define ADDREGNAMES_ARR_INDEX_2(index) \
933 ADDREGNAMES_ARR_INDEX_1 ((index)), ADDREGNAMES_ARR_INDEX_1 ((index)+1)
934 #define ADDREGNAMES_ARR_INDEX_4(index) \
935 ADDREGNAMES_ARR_INDEX_2 ((index)), ADDREGNAMES_ARR_INDEX_2 ((index)+2)
936 #define ADDREGNAMES_ARR_INDEX_8(index) \
937 ADDREGNAMES_ARR_INDEX_4 ((index)), ADDREGNAMES_ARR_INDEX_4 ((index)+4)
938 #define ADDREGNAMES_ARR_INDEX_16(index) \
939 ADDREGNAMES_ARR_INDEX_8 ((index)), ADDREGNAMES_ARR_INDEX_8 ((index)+8)
940 #define ADDREGNAMES_ARR_INDEX_32(index) \
941 ADDREGNAMES_ARR_INDEX_16 ((index)), ADDREGNAMES_ARR_INDEX_16 ((index)+16)
943 #define ADDITIONAL_REGISTER_NAMES \
945 ADDREGNAMES_ARR_INDEX_32 (0) \
948 /* Number of actual hardware registers.
949 The hardware registers are assigned numbers for the compiler
950 from 0 to just below FIRST_PSEUDO_REGISTER.
951 All registers that the compiler knows about must be given numbers,
952 even those that are not normally considered general registers. */
954 /* There are many other relevant definitions in sh.md's md_constants. */
956 #define FIRST_GENERAL_REG R0_REG
957 #define LAST_GENERAL_REG (FIRST_GENERAL_REG + (TARGET_SHMEDIA ? 63 : 15))
958 #define FIRST_FP_REG DR0_REG
959 #define LAST_FP_REG (FIRST_FP_REG + \
960 (TARGET_SHMEDIA_FPU ? 63 : TARGET_SH2E ? 15 : -1))
961 #define FIRST_XD_REG XD0_REG
962 #define LAST_XD_REG (FIRST_XD_REG + ((TARGET_SH4 && TARGET_FMOVD) ? 7 : -1))
963 #define FIRST_TARGET_REG TR0_REG
964 #define LAST_TARGET_REG (FIRST_TARGET_REG + (TARGET_SHMEDIA ? 7 : -1))
966 #define GENERAL_REGISTER_P(REGNO) \
967 IN_RANGE ((REGNO), \
968 (unsigned HOST_WIDE_INT) FIRST_GENERAL_REG, \
969 (unsigned HOST_WIDE_INT) LAST_GENERAL_REG)
971 #define GENERAL_OR_AP_REGISTER_P(REGNO) \
972 (GENERAL_REGISTER_P (REGNO) || ((REGNO) == AP_REG))
974 #define FP_REGISTER_P(REGNO) \
975 ((int) (REGNO) >= FIRST_FP_REG && (int) (REGNO) <= LAST_FP_REG)
977 #define XD_REGISTER_P(REGNO) \
978 ((int) (REGNO) >= FIRST_XD_REG && (int) (REGNO) <= LAST_XD_REG)
980 #define FP_OR_XD_REGISTER_P(REGNO) \
981 (FP_REGISTER_P (REGNO) || XD_REGISTER_P (REGNO))
983 #define FP_ANY_REGISTER_P(REGNO) \
984 (FP_REGISTER_P (REGNO) || XD_REGISTER_P (REGNO) || (REGNO) == FPUL_REG)
986 #define SPECIAL_REGISTER_P(REGNO) \
987 ((REGNO) == GBR_REG || (REGNO) == T_REG \
988 || (REGNO) == MACH_REG || (REGNO) == MACL_REG)
990 #define TARGET_REGISTER_P(REGNO) \
991 ((int) (REGNO) >= FIRST_TARGET_REG && (int) (REGNO) <= LAST_TARGET_REG)
993 #define SHMEDIA_REGISTER_P(REGNO) \
994 (GENERAL_REGISTER_P (REGNO) || FP_REGISTER_P (REGNO) \
995 || TARGET_REGISTER_P (REGNO))
997 /* This is to be used in CONDITIONAL_REGISTER_USAGE, to mark registers
998 that should be fixed. */
999 #define VALID_REGISTER_P(REGNO) \
1000 (SHMEDIA_REGISTER_P (REGNO) || XD_REGISTER_P (REGNO) \
1001 || (REGNO) == AP_REG || (REGNO) == RAP_REG \
1002 || (TARGET_SH1 && (SPECIAL_REGISTER_P (REGNO) || (REGNO) == PR_REG)) \
1003 || (TARGET_SH2E && (REGNO) == FPUL_REG))
1005 /* The mode that should be generally used to store a register by
1006 itself in the stack, or to load it back. */
1007 #define REGISTER_NATURAL_MODE(REGNO) \
1008 (FP_REGISTER_P (REGNO) ? SFmode \
1009 : XD_REGISTER_P (REGNO) ? DFmode \
1010 : TARGET_SHMEDIA && ! HARD_REGNO_CALL_PART_CLOBBERED ((REGNO), DImode) \
1011 ? DImode \
1012 : SImode)
1014 #define FIRST_PSEUDO_REGISTER 153
1016 /* 1 for registers that have pervasive standard uses
1017 and are not available for the register allocator.
1019 Mach register is fixed 'cause it's only 10 bits wide for SH1.
1020 It is 32 bits wide for SH2. */
1022 #define FIXED_REGISTERS \
1024 /* Regular registers. */ \
1025 0, 0, 0, 0, 0, 0, 0, 0, \
1026 0, 0, 0, 0, 0, 0, 0, 1, \
1027 /* r16 is reserved, r18 is the former pr. */ \
1028 1, 0, 0, 0, 0, 0, 0, 0, \
1029 /* r24 is reserved for the OS; r25, for the assembler or linker. */ \
1030 /* r26 is a global variable data pointer; r27 is for constants. */ \
1031 1, 1, 1, 1, 0, 0, 0, 0, \
1032 0, 0, 0, 0, 0, 0, 0, 0, \
1033 0, 0, 0, 0, 0, 0, 0, 0, \
1034 0, 0, 0, 0, 0, 0, 0, 0, \
1035 0, 0, 0, 0, 0, 0, 0, 1, \
1036 /* FP registers. */ \
1037 0, 0, 0, 0, 0, 0, 0, 0, \
1038 0, 0, 0, 0, 0, 0, 0, 0, \
1039 0, 0, 0, 0, 0, 0, 0, 0, \
1040 0, 0, 0, 0, 0, 0, 0, 0, \
1041 0, 0, 0, 0, 0, 0, 0, 0, \
1042 0, 0, 0, 0, 0, 0, 0, 0, \
1043 0, 0, 0, 0, 0, 0, 0, 0, \
1044 0, 0, 0, 0, 0, 0, 0, 0, \
1045 /* Branch target registers. */ \
1046 0, 0, 0, 0, 0, 0, 0, 0, \
1047 /* XD registers. */ \
1048 0, 0, 0, 0, 0, 0, 0, 0, \
1049 /*"gbr", "ap", "pr", "t", "mach", "macl", "fpul", "fpscr", */ \
1050 1, 1, 1, 1, 1, 1, 0, 1, \
1051 /*"rap" */ \
1052 1, \
1055 /* 1 for registers not available across function calls.
1056 These must include the FIXED_REGISTERS and also any
1057 registers that can be used without being saved.
1058 The latter must include the registers where values are returned
1059 and the register where structure-value addresses are passed.
1060 Aside from that, you can include as many other registers as you like. */
1062 #define CALL_USED_REGISTERS \
1064 /* Regular registers. */ \
1065 1, 1, 1, 1, 1, 1, 1, 1, \
1066 /* R8 and R9 are call-clobbered on SH5, but not on earlier SH ABIs. \
1067 Only the lower 32bits of R10-R14 are guaranteed to be preserved \
1068 across SH5 function calls. */ \
1069 0, 0, 0, 0, 0, 0, 0, 1, \
1070 1, 1, 1, 1, 1, 1, 1, 1, \
1071 1, 1, 1, 1, 0, 0, 0, 0, \
1072 0, 0, 0, 0, 1, 1, 1, 1, \
1073 1, 1, 1, 1, 0, 0, 0, 0, \
1074 0, 0, 0, 0, 0, 0, 0, 0, \
1075 0, 0, 0, 0, 1, 1, 1, 1, \
1076 /* FP registers. */ \
1077 1, 1, 1, 1, 1, 1, 1, 1, \
1078 1, 1, 1, 1, 0, 0, 0, 0, \
1079 1, 1, 1, 1, 1, 1, 1, 1, \
1080 1, 1, 1, 1, 1, 1, 1, 1, \
1081 1, 1, 1, 1, 0, 0, 0, 0, \
1082 0, 0, 0, 0, 0, 0, 0, 0, \
1083 0, 0, 0, 0, 0, 0, 0, 0, \
1084 0, 0, 0, 0, 0, 0, 0, 0, \
1085 /* Branch target registers. */ \
1086 1, 1, 1, 1, 1, 0, 0, 0, \
1087 /* XD registers. */ \
1088 1, 1, 1, 1, 1, 1, 0, 0, \
1089 /*"gbr", "ap", "pr", "t", "mach", "macl", "fpul", "fpscr", */ \
1090 1, 1, 1, 1, 1, 1, 1, 1, \
1091 /*"rap" */ \
1092 1, \
1095 /* CONDITIONAL_REGISTER_USAGE might want to make a register call-used, yet
1096 fixed, like PIC_OFFSET_TABLE_REGNUM. */
1097 #define CALL_REALLY_USED_REGISTERS CALL_USED_REGISTERS
1099 /* Only the lower 32-bits of R10-R14 are guaranteed to be preserved
1100 across SHcompact function calls. We can't tell whether a called
1101 function is SHmedia or SHcompact, so we assume it may be when
1102 compiling SHmedia code with the 32-bit ABI, since that's the only
1103 ABI that can be linked with SHcompact code. */
1104 #define HARD_REGNO_CALL_PART_CLOBBERED(REGNO,MODE) \
1105 (TARGET_SHMEDIA32 \
1106 && GET_MODE_SIZE (MODE) > 4 \
1107 && (((REGNO) >= FIRST_GENERAL_REG + 10 \
1108 && (REGNO) <= FIRST_GENERAL_REG + 15) \
1109 || TARGET_REGISTER_P (REGNO) \
1110 || (REGNO) == PR_MEDIA_REG))
1112 /* Return number of consecutive hard regs needed starting at reg REGNO
1113 to hold something of mode MODE.
1114 This is ordinarily the length in words of a value of mode MODE
1115 but can be less for certain modes in special long registers.
1117 On the SH all but the XD regs are UNITS_PER_WORD bits wide. */
1119 #define HARD_REGNO_NREGS(REGNO, MODE) \
1120 (XD_REGISTER_P (REGNO) \
1121 ? ((GET_MODE_SIZE (MODE) + (2*UNITS_PER_WORD - 1)) / (2*UNITS_PER_WORD)) \
1122 : (TARGET_SHMEDIA && FP_REGISTER_P (REGNO)) \
1123 ? ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD/2 - 1) / (UNITS_PER_WORD/2)) \
1124 : ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD))
1126 /* Value is 1 if hard register REGNO can hold a value of machine-mode MODE.
1127 We can allow any mode in any general register. The special registers
1128 only allow SImode. Don't allow any mode in the PR. */
1130 /* We cannot hold DCmode values in the XD registers because alter_reg
1131 handles subregs of them incorrectly. We could work around this by
1132 spacing the XD registers like the DR registers, but this would require
1133 additional memory in every compilation to hold larger register vectors.
1134 We could hold SFmode / SCmode values in XD registers, but that
1135 would require a tertiary reload when reloading from / to memory,
1136 and a secondary reload to reload from / to general regs; that
1137 seems to be a loosing proposition. */
1138 /* We want to allow TImode FP regs so that when V4SFmode is loaded as TImode,
1139 it won't be ferried through GP registers first. */
1140 #define HARD_REGNO_MODE_OK(REGNO, MODE) \
1141 (SPECIAL_REGISTER_P (REGNO) ? (MODE) == SImode \
1142 : (REGNO) == FPUL_REG ? (MODE) == SImode || (MODE) == SFmode \
1143 : FP_REGISTER_P (REGNO) && (MODE) == SFmode \
1144 ? 1 \
1145 : (MODE) == V2SFmode \
1146 ? ((FP_REGISTER_P (REGNO) && ((REGNO) - FIRST_FP_REG) % 2 == 0) \
1147 || GENERAL_REGISTER_P (REGNO)) \
1148 : (MODE) == V4SFmode \
1149 ? ((FP_REGISTER_P (REGNO) && ((REGNO) - FIRST_FP_REG) % 4 == 0) \
1150 || (! TARGET_SHMEDIA && GENERAL_REGISTER_P (REGNO))) \
1151 : (MODE) == V16SFmode \
1152 ? (TARGET_SHMEDIA \
1153 ? (FP_REGISTER_P (REGNO) && ((REGNO) - FIRST_FP_REG) % 16 == 0) \
1154 : (REGNO) == FIRST_XD_REG) \
1155 : FP_REGISTER_P (REGNO) \
1156 ? ((MODE) == SFmode || (MODE) == SImode \
1157 || ((TARGET_SH2E || TARGET_SHMEDIA) && (MODE) == SCmode) \
1158 || ((((TARGET_SH4 || TARGET_SH2A_DOUBLE) && (MODE) == DFmode) || (MODE) == DCmode \
1159 || (TARGET_SHMEDIA && ((MODE) == DFmode || (MODE) == DImode \
1160 || (MODE) == V2SFmode || (MODE) == TImode))) \
1161 && (((REGNO) - FIRST_FP_REG) & 1) == 0) \
1162 || ((TARGET_SH4 || TARGET_SHMEDIA) \
1163 && (MODE) == TImode \
1164 && (((REGNO) - FIRST_FP_REG) & 3) == 0)) \
1165 : XD_REGISTER_P (REGNO) \
1166 ? (MODE) == DFmode \
1167 : TARGET_REGISTER_P (REGNO) \
1168 ? ((MODE) == DImode || (MODE) == SImode || (MODE) == PDImode) \
1169 : (REGNO) == PR_REG ? (MODE) == SImode \
1170 : (REGNO) == FPSCR_REG ? (MODE) == PSImode \
1171 : 1)
1173 /* Value is 1 if it is a good idea to tie two pseudo registers
1174 when one has mode MODE1 and one has mode MODE2.
1175 If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2,
1176 for any hard reg, then this must be 0 for correct output.
1177 That's the case for xd registers: we don't hold SFmode values in
1178 them, so we can't tie an SFmode pseudos with one in another
1179 floating-point mode. */
1181 #define MODES_TIEABLE_P(MODE1, MODE2) \
1182 ((MODE1) == (MODE2) \
1183 || (TARGET_SHMEDIA \
1184 && GET_MODE_SIZE (MODE1) == GET_MODE_SIZE (MODE2) \
1185 && INTEGRAL_MODE_P (MODE1) && INTEGRAL_MODE_P (MODE2)) \
1186 || (GET_MODE_CLASS (MODE1) == GET_MODE_CLASS (MODE2) \
1187 && (TARGET_SHMEDIA ? ((GET_MODE_SIZE (MODE1) <= 4) \
1188 && (GET_MODE_SIZE (MODE2) <= 4)) \
1189 : ((MODE1) != SFmode && (MODE2) != SFmode))))
1191 /* A C expression that is nonzero if hard register NEW_REG can be
1192 considered for use as a rename register for OLD_REG register */
1194 #define HARD_REGNO_RENAME_OK(OLD_REG, NEW_REG) \
1195 sh_hard_regno_rename_ok (OLD_REG, NEW_REG)
1197 /* Specify the registers used for certain standard purposes.
1198 The values of these macros are register numbers. */
1200 /* Define this if the program counter is overloaded on a register. */
1201 /* #define PC_REGNUM 15*/
1203 /* Register to use for pushing function arguments. */
1204 #define STACK_POINTER_REGNUM SP_REG
1206 /* Base register for access to local variables of the function. */
1207 #define FRAME_POINTER_REGNUM FP_REG
1209 /* Fake register that holds the address on the stack of the
1210 current function's return address. */
1211 #define RETURN_ADDRESS_POINTER_REGNUM RAP_REG
1213 /* Register to hold the addressing base for position independent
1214 code access to data items. */
1215 #define PIC_OFFSET_TABLE_REGNUM (flag_pic ? PIC_REG : INVALID_REGNUM)
1217 #define GOT_SYMBOL_NAME "*_GLOBAL_OFFSET_TABLE_"
1219 /* Value should be nonzero if functions must have frame pointers.
1220 Zero means the frame pointer need not be set up (and parms may be accessed
1221 via the stack pointer) in functions that seem suitable. */
1223 #define FRAME_POINTER_REQUIRED 0
1225 /* Definitions for register eliminations.
1227 We have three registers that can be eliminated on the SH. First, the
1228 frame pointer register can often be eliminated in favor of the stack
1229 pointer register. Secondly, the argument pointer register can always be
1230 eliminated; it is replaced with either the stack or frame pointer.
1231 Third, there is the return address pointer, which can also be replaced
1232 with either the stack or the frame pointer. */
1234 /* This is an array of structures. Each structure initializes one pair
1235 of eliminable registers. The "from" register number is given first,
1236 followed by "to". Eliminations of the same "from" register are listed
1237 in order of preference. */
1239 /* If you add any registers here that are not actually hard registers,
1240 and that have any alternative of elimination that doesn't always
1241 apply, you need to amend calc_live_regs to exclude it, because
1242 reload spills all eliminable registers where it sees an
1243 can_eliminate == 0 entry, thus making them 'live' .
1244 If you add any hard registers that can be eliminated in different
1245 ways, you have to patch reload to spill them only when all alternatives
1246 of elimination fail. */
1248 #define ELIMINABLE_REGS \
1249 {{ FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
1250 { RETURN_ADDRESS_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
1251 { RETURN_ADDRESS_POINTER_REGNUM, FRAME_POINTER_REGNUM}, \
1252 { ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
1253 { ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM},}
1255 /* Given FROM and TO register numbers, say whether this elimination
1256 is allowed. */
1257 #define CAN_ELIMINATE(FROM, TO) \
1258 (!((FROM) == FRAME_POINTER_REGNUM && FRAME_POINTER_REQUIRED))
1260 /* Define the offset between two registers, one to be eliminated, and the other
1261 its replacement, at the start of a routine. */
1263 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
1264 OFFSET = initial_elimination_offset ((FROM), (TO))
1266 /* Base register for access to arguments of the function. */
1267 #define ARG_POINTER_REGNUM AP_REG
1269 /* Register in which the static-chain is passed to a function. */
1270 #define STATIC_CHAIN_REGNUM (TARGET_SH5 ? 1 : 3)
1272 /* Don't default to pcc-struct-return, because we have already specified
1273 exactly how to return structures in the TARGET_RETURN_IN_MEMORY
1274 target hook. */
1276 #define DEFAULT_PCC_STRUCT_RETURN 0
1278 #define SHMEDIA_REGS_STACK_ADJUST() \
1279 (TARGET_SHCOMPACT && current_function_has_nonlocal_label \
1280 ? (8 * (/* r28-r35 */ 8 + /* r44-r59 */ 16 + /* tr5-tr7 */ 3) \
1281 + (TARGET_FPU_ANY ? 4 * (/* fr36 - fr63 */ 28) : 0)) \
1282 : 0)
1285 /* Define the classes of registers for register constraints in the
1286 machine description. Also define ranges of constants.
1288 One of the classes must always be named ALL_REGS and include all hard regs.
1289 If there is more than one class, another class must be named NO_REGS
1290 and contain no registers.
1292 The name GENERAL_REGS must be the name of a class (or an alias for
1293 another name such as ALL_REGS). This is the class of registers
1294 that is allowed by "g" or "r" in a register constraint.
1295 Also, registers outside this class are allocated only when
1296 instructions express preferences for them.
1298 The classes must be numbered in nondecreasing order; that is,
1299 a larger-numbered class must never be contained completely
1300 in a smaller-numbered class.
1302 For any two classes, it is very desirable that there be another
1303 class that represents their union. */
1305 /* The SH has two sorts of general registers, R0 and the rest. R0 can
1306 be used as the destination of some of the arithmetic ops. There are
1307 also some special purpose registers; the T bit register, the
1308 Procedure Return Register and the Multiply Accumulate Registers. */
1309 /* Place GENERAL_REGS after FPUL_REGS so that it will be preferred by
1310 reg_class_subunion. We don't want to have an actual union class
1311 of these, because it would only be used when both classes are calculated
1312 to give the same cost, but there is only one FPUL register.
1313 Besides, regclass fails to notice the different REGISTER_MOVE_COSTS
1314 applying to the actual instruction alternative considered. E.g., the
1315 y/r alternative of movsi_ie is considered to have no more cost that
1316 the r/r alternative, which is patently untrue. */
1318 enum reg_class
1320 NO_REGS,
1321 R0_REGS,
1322 PR_REGS,
1323 T_REGS,
1324 MAC_REGS,
1325 FPUL_REGS,
1326 SIBCALL_REGS,
1327 GENERAL_REGS,
1328 FP0_REGS,
1329 FP_REGS,
1330 DF_HI_REGS,
1331 DF_REGS,
1332 FPSCR_REGS,
1333 GENERAL_FP_REGS,
1334 TARGET_REGS,
1335 ALL_REGS,
1336 LIM_REG_CLASSES
1339 #define N_REG_CLASSES (int) LIM_REG_CLASSES
1341 /* Give names of register classes as strings for dump file. */
1342 #define REG_CLASS_NAMES \
1344 "NO_REGS", \
1345 "R0_REGS", \
1346 "PR_REGS", \
1347 "T_REGS", \
1348 "MAC_REGS", \
1349 "FPUL_REGS", \
1350 "SIBCALL_REGS", \
1351 "GENERAL_REGS", \
1352 "FP0_REGS", \
1353 "FP_REGS", \
1354 "DF_HI_REGS", \
1355 "DF_REGS", \
1356 "FPSCR_REGS", \
1357 "GENERAL_FP_REGS", \
1358 "TARGET_REGS", \
1359 "ALL_REGS", \
1362 /* Define which registers fit in which classes.
1363 This is an initializer for a vector of HARD_REG_SET
1364 of length N_REG_CLASSES. */
1366 #define REG_CLASS_CONTENTS \
1368 /* NO_REGS: */ \
1369 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 }, \
1370 /* R0_REGS: */ \
1371 { 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000 }, \
1372 /* PR_REGS: */ \
1373 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00040000 }, \
1374 /* T_REGS: */ \
1375 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00080000 }, \
1376 /* MAC_REGS: */ \
1377 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00300000 }, \
1378 /* FPUL_REGS: */ \
1379 { 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00400000 }, \
1380 /* SIBCALL_REGS: Initialized in CONDITIONAL_REGISTER_USAGE. */ \
1381 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 }, \
1382 /* GENERAL_REGS: */ \
1383 { 0xffffffff, 0xffffffff, 0x00000000, 0x00000000, 0x01020000 }, \
1384 /* FP0_REGS: */ \
1385 { 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000 }, \
1386 /* FP_REGS: */ \
1387 { 0x00000000, 0x00000000, 0xffffffff, 0xffffffff, 0x00000000 }, \
1388 /* DF_HI_REGS: Initialized in CONDITIONAL_REGISTER_USAGE. */ \
1389 { 0x00000000, 0x00000000, 0xffffffff, 0xffffffff, 0x0000ff00 }, \
1390 /* DF_REGS: */ \
1391 { 0x00000000, 0x00000000, 0xffffffff, 0xffffffff, 0x0000ff00 }, \
1392 /* FPSCR_REGS: */ \
1393 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00800000 }, \
1394 /* GENERAL_FP_REGS: */ \
1395 { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x0102ff00 }, \
1396 /* TARGET_REGS: */ \
1397 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000000ff }, \
1398 /* ALL_REGS: */ \
1399 { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x01ffffff }, \
1402 /* The same information, inverted:
1403 Return the class number of the smallest class containing
1404 reg number REGNO. This could be a conditional expression
1405 or could index an array. */
1407 extern enum reg_class regno_reg_class[FIRST_PSEUDO_REGISTER];
1408 #define REGNO_REG_CLASS(REGNO) regno_reg_class[(REGNO)]
1410 /* When defined, the compiler allows registers explicitly used in the
1411 rtl to be used as spill registers but prevents the compiler from
1412 extending the lifetime of these registers. */
1414 #define SMALL_REGISTER_CLASSES (! TARGET_SHMEDIA)
1416 /* The order in which register should be allocated. */
1417 /* Sometimes FP0_REGS becomes the preferred class of a floating point pseudo,
1418 and GENERAL_FP_REGS the alternate class. Since FP0 is likely to be
1419 spilled or used otherwise, we better have the FP_REGS allocated first. */
1420 #define REG_ALLOC_ORDER \
1421 {/* Caller-saved FPRs */ \
1422 65, 66, 67, 68, 69, 70, 71, 64, \
1423 72, 73, 74, 75, 80, 81, 82, 83, \
1424 84, 85, 86, 87, 88, 89, 90, 91, \
1425 92, 93, 94, 95, 96, 97, 98, 99, \
1426 /* Callee-saved FPRs */ \
1427 76, 77, 78, 79,100,101,102,103, \
1428 104,105,106,107,108,109,110,111, \
1429 112,113,114,115,116,117,118,119, \
1430 120,121,122,123,124,125,126,127, \
1431 136,137,138,139,140,141,142,143, \
1432 /* FPSCR */ 151, \
1433 /* Caller-saved GPRs (except 8/9 on SH1-4) */ \
1434 1, 2, 3, 7, 6, 5, 4, 0, \
1435 8, 9, 17, 19, 20, 21, 22, 23, \
1436 36, 37, 38, 39, 40, 41, 42, 43, \
1437 60, 61, 62, \
1438 /* SH1-4 callee-saved saved GPRs / SH5 partially-saved GPRs */ \
1439 10, 11, 12, 13, 14, 18, \
1440 /* SH5 callee-saved GPRs */ \
1441 28, 29, 30, 31, 32, 33, 34, 35, \
1442 44, 45, 46, 47, 48, 49, 50, 51, \
1443 52, 53, 54, 55, 56, 57, 58, 59, \
1444 /* FPUL */ 150, \
1445 /* SH5 branch target registers */ \
1446 128,129,130,131,132,133,134,135, \
1447 /* Fixed registers */ \
1448 15, 16, 24, 25, 26, 27, 63,144, \
1449 145,146,147,148,149,152 }
1451 /* The class value for index registers, and the one for base regs. */
1452 #define INDEX_REG_CLASS \
1453 (!ALLOW_INDEXED_ADDRESS ? NO_REGS : TARGET_SHMEDIA ? GENERAL_REGS : R0_REGS)
1454 #define BASE_REG_CLASS GENERAL_REGS
1456 /* Get reg_class from a letter such as appears in the machine
1457 description. */
1458 extern enum reg_class reg_class_from_letter[];
1460 /* We might use 'Rxx' constraints in the future for exotic reg classes.*/
1461 #define REG_CLASS_FROM_CONSTRAINT(C, STR) \
1462 (ISLOWER (C) ? reg_class_from_letter[(C)-'a'] : NO_REGS )
1464 /* Overview of uppercase letter constraints:
1465 A: Addresses (constraint len == 3)
1466 Ac4: sh4 cache operations
1467 Ac5: sh5 cache operations
1468 Bxx: miscellaneous constraints
1469 Bsc: SCRATCH - for the scratch register in movsi_ie in the
1470 fldi0 / fldi0 cases
1471 C: Constants other than only CONST_INT (constraint len == 3)
1472 C16: 16 bit constant, literal or symbolic
1473 Csy: label or symbol
1474 Cpg: non-explicit constants that can be directly loaded into a general
1475 purpose register in PIC code. like 's' except we don't allow
1476 PIC_DIRECT_ADDR_P
1477 IJKLMNOP: CONT_INT constants
1478 Ixx: signed xx bit
1479 J16: 0xffffffff00000000 | 0x00000000ffffffff
1480 Kxx: unsigned xx bit
1481 M: 1
1482 N: 0
1483 P27: 1 | 2 | 8 | 16
1484 Q: pc relative load operand
1485 Rxx: reserved for exotic register classes.
1486 S: extra memory (storage) constraints (constraint len == 3)
1487 Sua: unaligned memory operations
1488 W: vector
1489 Z: zero in any mode
1491 unused CONST_INT constraint letters: LO
1492 unused EXTRA_CONSTRAINT letters: D T U Y */
1494 #define CONSTRAINT_LEN(C,STR) \
1495 (((C) == 'A' || (C) == 'B' || (C) == 'C' \
1496 || (C) == 'I' || (C) == 'J' || (C) == 'K' || (C) == 'P' \
1497 || (C) == 'R' || (C) == 'S') \
1498 ? 3 : DEFAULT_CONSTRAINT_LEN ((C), (STR)))
1500 /* The letters I, J, K, L and M in a register constraint string
1501 can be used to stand for particular ranges of immediate operands.
1502 This macro defines what the ranges are.
1503 C is the letter, and VALUE is a constant value.
1504 Return 1 if VALUE is in the range specified by C.
1505 I08: arithmetic operand -127..128, as used in add, sub, etc
1506 I16: arithmetic operand -32768..32767, as used in SHmedia movi and shori
1507 P27: shift operand 1,2,8 or 16
1508 K08: logical operand 0..255, as used in and, or, etc.
1509 M: constant 1
1510 N: constant 0
1511 I06: arithmetic operand -32..31, as used in SHmedia beqi, bnei and xori
1512 I10: arithmetic operand -512..511, as used in SHmedia andi, ori
1515 #define CONST_OK_FOR_I06(VALUE) (((HOST_WIDE_INT)(VALUE)) >= -32 \
1516 && ((HOST_WIDE_INT)(VALUE)) <= 31)
1517 #define CONST_OK_FOR_I08(VALUE) (((HOST_WIDE_INT)(VALUE))>= -128 \
1518 && ((HOST_WIDE_INT)(VALUE)) <= 127)
1519 #define CONST_OK_FOR_I10(VALUE) (((HOST_WIDE_INT)(VALUE)) >= -512 \
1520 && ((HOST_WIDE_INT)(VALUE)) <= 511)
1521 #define CONST_OK_FOR_I16(VALUE) (((HOST_WIDE_INT)(VALUE)) >= -32768 \
1522 && ((HOST_WIDE_INT)(VALUE)) <= 32767)
1523 #define CONST_OK_FOR_I20(VALUE) (((HOST_WIDE_INT)(VALUE)) >= -524288 \
1524 && ((HOST_WIDE_INT)(VALUE)) <= 524287 \
1525 && TARGET_SH2A)
1526 #define CONST_OK_FOR_I(VALUE, STR) \
1527 ((STR)[1] == '0' && (STR)[2] == '6' ? CONST_OK_FOR_I06 (VALUE) \
1528 : (STR)[1] == '0' && (STR)[2] == '8' ? CONST_OK_FOR_I08 (VALUE) \
1529 : (STR)[1] == '1' && (STR)[2] == '0' ? CONST_OK_FOR_I10 (VALUE) \
1530 : (STR)[1] == '1' && (STR)[2] == '6' ? CONST_OK_FOR_I16 (VALUE) \
1531 : (STR)[1] == '2' && (STR)[2] == '0' ? CONST_OK_FOR_I20 (VALUE) \
1532 : 0)
1534 #define CONST_OK_FOR_J16(VALUE) \
1535 ((HOST_BITS_PER_WIDE_INT >= 64 && (VALUE) == (HOST_WIDE_INT) 0xffffffff) \
1536 || (HOST_BITS_PER_WIDE_INT >= 64 && (VALUE) == (HOST_WIDE_INT) -1 << 32))
1537 #define CONST_OK_FOR_J(VALUE, STR) \
1538 ((STR)[1] == '1' && (STR)[2] == '6' ? CONST_OK_FOR_J16 (VALUE) \
1539 : 0)
1541 #define CONST_OK_FOR_K08(VALUE) (((HOST_WIDE_INT)(VALUE))>= 0 \
1542 && ((HOST_WIDE_INT)(VALUE)) <= 255)
1543 #define CONST_OK_FOR_K(VALUE, STR) \
1544 ((STR)[1] == '0' && (STR)[2] == '8' ? CONST_OK_FOR_K08 (VALUE) \
1545 : 0)
1546 #define CONST_OK_FOR_P27(VALUE) \
1547 ((VALUE)==1||(VALUE)==2||(VALUE)==8||(VALUE)==16)
1548 #define CONST_OK_FOR_P(VALUE, STR) \
1549 ((STR)[1] == '2' && (STR)[2] == '7' ? CONST_OK_FOR_P27 (VALUE) \
1550 : 0)
1551 #define CONST_OK_FOR_M(VALUE) ((VALUE)==1)
1552 #define CONST_OK_FOR_N(VALUE) ((VALUE)==0)
1553 #define CONST_OK_FOR_CONSTRAINT_P(VALUE, C, STR) \
1554 ((C) == 'I' ? CONST_OK_FOR_I ((VALUE), (STR)) \
1555 : (C) == 'J' ? CONST_OK_FOR_J ((VALUE), (STR)) \
1556 : (C) == 'K' ? CONST_OK_FOR_K ((VALUE), (STR)) \
1557 : (C) == 'M' ? CONST_OK_FOR_M (VALUE) \
1558 : (C) == 'N' ? CONST_OK_FOR_N (VALUE) \
1559 : (C) == 'P' ? CONST_OK_FOR_P ((VALUE), (STR)) \
1560 : 0)
1562 /* Similar, but for floating constants, and defining letters G and H.
1563 Here VALUE is the CONST_DOUBLE rtx itself. */
1565 #define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) \
1566 ((C) == 'G' ? (fp_zero_operand (VALUE) && fldi_ok ()) \
1567 : (C) == 'H' ? (fp_one_operand (VALUE) && fldi_ok ()) \
1568 : (C) == 'F')
1570 /* Given an rtx X being reloaded into a reg required to be
1571 in class CLASS, return the class of reg to actually use.
1572 In general this is just CLASS; but on some machines
1573 in some cases it is preferable to use a more restrictive class. */
1575 #define PREFERRED_RELOAD_CLASS(X, CLASS) \
1576 ((CLASS) == NO_REGS && TARGET_SHMEDIA \
1577 && (GET_CODE (X) == CONST_DOUBLE \
1578 || GET_CODE (X) == SYMBOL_REF \
1579 || PIC_DIRECT_ADDR_P (X)) \
1580 ? GENERAL_REGS \
1581 : (CLASS)) \
1583 #define SECONDARY_INOUT_RELOAD_CLASS(CLASS,MODE,X,ELSE) \
1584 ((((REGCLASS_HAS_FP_REG (CLASS) \
1585 && (GET_CODE (X) == REG \
1586 && (GENERAL_OR_AP_REGISTER_P (REGNO (X)) \
1587 || (FP_REGISTER_P (REGNO (X)) && (MODE) == SImode \
1588 && TARGET_FMOVD)))) \
1589 || (REGCLASS_HAS_GENERAL_REG (CLASS) \
1590 && GET_CODE (X) == REG \
1591 && FP_REGISTER_P (REGNO (X)))) \
1592 && ! TARGET_SHMEDIA \
1593 && ((MODE) == SFmode || (MODE) == SImode)) \
1594 ? FPUL_REGS \
1595 : (((CLASS) == FPUL_REGS \
1596 || (REGCLASS_HAS_FP_REG (CLASS) \
1597 && ! TARGET_SHMEDIA && MODE == SImode)) \
1598 && (GET_CODE (X) == MEM \
1599 || (GET_CODE (X) == REG \
1600 && (REGNO (X) >= FIRST_PSEUDO_REGISTER \
1601 || REGNO (X) == T_REG \
1602 || system_reg_operand (X, VOIDmode))))) \
1603 ? GENERAL_REGS \
1604 : (((CLASS) == TARGET_REGS \
1605 || (TARGET_SHMEDIA && (CLASS) == SIBCALL_REGS)) \
1606 && !EXTRA_CONSTRAINT_Csy (X) \
1607 && (GET_CODE (X) != REG || ! GENERAL_REGISTER_P (REGNO (X)))) \
1608 ? GENERAL_REGS \
1609 : (((CLASS) == MAC_REGS || (CLASS) == PR_REGS) \
1610 && GET_CODE (X) == REG && ! GENERAL_REGISTER_P (REGNO (X)) \
1611 && (CLASS) != REGNO_REG_CLASS (REGNO (X))) \
1612 ? GENERAL_REGS \
1613 : ((CLASS) != GENERAL_REGS && GET_CODE (X) == REG \
1614 && TARGET_REGISTER_P (REGNO (X))) \
1615 ? GENERAL_REGS : (ELSE))
1617 #define SECONDARY_OUTPUT_RELOAD_CLASS(CLASS,MODE,X) \
1618 SECONDARY_INOUT_RELOAD_CLASS(CLASS,MODE,X,NO_REGS)
1620 #define SECONDARY_INPUT_RELOAD_CLASS(CLASS,MODE,X) \
1621 ((REGCLASS_HAS_FP_REG (CLASS) \
1622 && ! TARGET_SHMEDIA \
1623 && immediate_operand ((X), (MODE)) \
1624 && ! ((fp_zero_operand (X) || fp_one_operand (X)) \
1625 && (MODE) == SFmode && fldi_ok ())) \
1626 ? R0_REGS \
1627 : ((CLASS) == FPUL_REGS \
1628 && ((GET_CODE (X) == REG \
1629 && (REGNO (X) == MACL_REG || REGNO (X) == MACH_REG \
1630 || REGNO (X) == T_REG)) \
1631 || GET_CODE (X) == PLUS)) \
1632 ? GENERAL_REGS \
1633 : (CLASS) == FPUL_REGS && immediate_operand ((X), (MODE)) \
1634 ? (GET_CODE (X) == CONST_INT && CONST_OK_FOR_I08 (INTVAL (X)) \
1635 ? GENERAL_REGS \
1636 : R0_REGS) \
1637 : ((CLASS) == FPSCR_REGS \
1638 && ((GET_CODE (X) == REG && REGNO (X) >= FIRST_PSEUDO_REGISTER) \
1639 || (GET_CODE (X) == MEM && GET_CODE (XEXP ((X), 0)) == PLUS)))\
1640 ? GENERAL_REGS \
1641 : (REGCLASS_HAS_FP_REG (CLASS) \
1642 && TARGET_SHMEDIA \
1643 && immediate_operand ((X), (MODE)) \
1644 && (X) != CONST0_RTX (GET_MODE (X)) \
1645 && GET_MODE (X) != V4SFmode) \
1646 ? GENERAL_REGS \
1647 : (((MODE) == QImode || (MODE) == HImode) \
1648 && TARGET_SHMEDIA && inqhi_operand ((X), (MODE))) \
1649 ? GENERAL_REGS \
1650 : (TARGET_SHMEDIA && (CLASS) == GENERAL_REGS \
1651 && (GET_CODE (X) == LABEL_REF || PIC_DIRECT_ADDR_P (X))) \
1652 ? TARGET_REGS \
1653 : SECONDARY_INOUT_RELOAD_CLASS((CLASS),(MODE),(X), NO_REGS))
1655 /* Return the maximum number of consecutive registers
1656 needed to represent mode MODE in a register of class CLASS.
1658 If TARGET_SHMEDIA, we need two FP registers per word.
1659 Otherwise we will need at most one register per word. */
1660 #define CLASS_MAX_NREGS(CLASS, MODE) \
1661 (TARGET_SHMEDIA \
1662 && TEST_HARD_REG_BIT (reg_class_contents[CLASS], FIRST_FP_REG) \
1663 ? (GET_MODE_SIZE (MODE) + UNITS_PER_WORD/2 - 1) / (UNITS_PER_WORD/2) \
1664 : (GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
1666 /* If defined, gives a class of registers that cannot be used as the
1667 operand of a SUBREG that changes the mode of the object illegally. */
1668 /* ??? We need to renumber the internal numbers for the frnn registers
1669 when in little endian in order to allow mode size changes. */
1671 #define CANNOT_CHANGE_MODE_CLASS(FROM, TO, CLASS) \
1672 sh_cannot_change_mode_class (FROM, TO, CLASS)
1674 /* Stack layout; function entry, exit and calling. */
1676 /* Define the number of registers that can hold parameters.
1677 These macros are used only in other macro definitions below. */
1679 #define NPARM_REGS(MODE) \
1680 (TARGET_FPU_ANY && (MODE) == SFmode \
1681 ? (TARGET_SH5 ? 12 : 8) \
1682 : (TARGET_SH4 || TARGET_SH2A_DOUBLE) && (GET_MODE_CLASS (MODE) == MODE_FLOAT \
1683 || GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT) \
1684 ? (TARGET_SH5 ? 12 : 8) \
1685 : (TARGET_SH5 ? 8 : 4))
1687 #define FIRST_PARM_REG (FIRST_GENERAL_REG + (TARGET_SH5 ? 2 : 4))
1688 #define FIRST_RET_REG (FIRST_GENERAL_REG + (TARGET_SH5 ? 2 : 0))
1690 #define FIRST_FP_PARM_REG (FIRST_FP_REG + (TARGET_SH5 ? 0 : 4))
1691 #define FIRST_FP_RET_REG FIRST_FP_REG
1693 /* Define this if pushing a word on the stack
1694 makes the stack pointer a smaller address. */
1695 #define STACK_GROWS_DOWNWARD
1697 /* Define this macro to non-zero if the addresses of local variable slots
1698 are at negative offsets from the frame pointer.
1700 The SH only has positive indexes, so grow the frame up. */
1701 #define FRAME_GROWS_DOWNWARD 0
1703 /* Offset from the frame pointer to the first local variable slot to
1704 be allocated. */
1705 #define STARTING_FRAME_OFFSET 0
1707 /* If we generate an insn to push BYTES bytes,
1708 this says how many the stack pointer really advances by. */
1709 /* Don't define PUSH_ROUNDING, since the hardware doesn't do this.
1710 When PUSH_ROUNDING is not defined, PARM_BOUNDARY will cause gcc to
1711 do correct alignment. */
1712 #if 0
1713 #define PUSH_ROUNDING(NPUSHED) (((NPUSHED) + 3) & ~3)
1714 #endif
1716 /* Offset of first parameter from the argument pointer register value. */
1717 #define FIRST_PARM_OFFSET(FNDECL) 0
1719 /* Value is the number of byte of arguments automatically
1720 popped when returning from a subroutine call.
1721 FUNDECL is the declaration node of the function (as a tree),
1722 FUNTYPE is the data type of the function (as a tree),
1723 or for a library call it is an identifier node for the subroutine name.
1724 SIZE is the number of bytes of arguments passed on the stack.
1726 On the SH, the caller does not pop any of its arguments that were passed
1727 on the stack. */
1728 #define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE) 0
1730 /* Value is the number of bytes of arguments automatically popped when
1731 calling a subroutine.
1732 CUM is the accumulated argument list.
1734 On SHcompact, the call trampoline pops arguments off the stack. */
1735 #define CALL_POPS_ARGS(CUM) (TARGET_SHCOMPACT ? (CUM).stack_regs * 8 : 0)
1737 /* Some subroutine macros specific to this machine. */
1739 #define BASE_RETURN_VALUE_REG(MODE) \
1740 ((TARGET_FPU_ANY && ((MODE) == SFmode)) \
1741 ? FIRST_FP_RET_REG \
1742 : TARGET_FPU_ANY && (MODE) == SCmode \
1743 ? FIRST_FP_RET_REG \
1744 : (TARGET_FPU_DOUBLE \
1745 && ((MODE) == DFmode || (MODE) == SFmode \
1746 || (MODE) == DCmode || (MODE) == SCmode )) \
1747 ? FIRST_FP_RET_REG \
1748 : FIRST_RET_REG)
1750 #define BASE_ARG_REG(MODE) \
1751 ((TARGET_SH2E && ((MODE) == SFmode)) \
1752 ? FIRST_FP_PARM_REG \
1753 : (TARGET_SH4 || TARGET_SH2A_DOUBLE) && (GET_MODE_CLASS (MODE) == MODE_FLOAT \
1754 || GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT)\
1755 ? FIRST_FP_PARM_REG \
1756 : FIRST_PARM_REG)
1758 /* Define how to find the value returned by a function.
1759 VALTYPE is the data type of the value (as a tree).
1760 If the precise function being called is known, FUNC is its FUNCTION_DECL;
1761 otherwise, FUNC is 0.
1762 For the SH, this is like LIBCALL_VALUE, except that we must change the
1763 mode like PROMOTE_MODE does.
1764 ??? PROMOTE_MODE is ignored for non-scalar types. The set of types
1765 tested here has to be kept in sync with the one in explow.c:promote_mode. */
1767 #define FUNCTION_VALUE(VALTYPE, FUNC) \
1768 gen_rtx_REG ( \
1769 ((GET_MODE_CLASS (TYPE_MODE (VALTYPE)) == MODE_INT \
1770 && GET_MODE_SIZE (TYPE_MODE (VALTYPE)) < 4 \
1771 && (TREE_CODE (VALTYPE) == INTEGER_TYPE \
1772 || TREE_CODE (VALTYPE) == ENUMERAL_TYPE \
1773 || TREE_CODE (VALTYPE) == BOOLEAN_TYPE \
1774 || TREE_CODE (VALTYPE) == CHAR_TYPE \
1775 || TREE_CODE (VALTYPE) == REAL_TYPE \
1776 || TREE_CODE (VALTYPE) == OFFSET_TYPE)) \
1777 && sh_promote_prototypes (VALTYPE) \
1778 ? (TARGET_SHMEDIA64 ? DImode : SImode) : TYPE_MODE (VALTYPE)), \
1779 BASE_RETURN_VALUE_REG (TYPE_MODE (VALTYPE)))
1781 /* Define how to find the value returned by a library function
1782 assuming the value has mode MODE. */
1783 #define LIBCALL_VALUE(MODE) \
1784 gen_rtx_REG ((MODE), BASE_RETURN_VALUE_REG (MODE));
1786 /* 1 if N is a possible register number for a function value. */
1787 #define FUNCTION_VALUE_REGNO_P(REGNO) \
1788 ((REGNO) == FIRST_RET_REG || (TARGET_SH2E && (REGNO) == FIRST_FP_RET_REG) \
1789 || (TARGET_SHMEDIA_FPU && (REGNO) == FIRST_FP_RET_REG))
1791 /* 1 if N is a possible register number for function argument passing. */
1792 /* ??? There are some callers that pass REGNO as int, and others that pass
1793 it as unsigned. We get warnings unless we do casts everywhere. */
1794 #define FUNCTION_ARG_REGNO_P(REGNO) \
1795 (((unsigned) (REGNO) >= (unsigned) FIRST_PARM_REG \
1796 && (unsigned) (REGNO) < (unsigned) (FIRST_PARM_REG + NPARM_REGS (SImode)))\
1797 || (TARGET_FPU_ANY \
1798 && (unsigned) (REGNO) >= (unsigned) FIRST_FP_PARM_REG \
1799 && (unsigned) (REGNO) < (unsigned) (FIRST_FP_PARM_REG \
1800 + NPARM_REGS (SFmode))))
1802 /* Define a data type for recording info about an argument list
1803 during the scan of that argument list. This data type should
1804 hold all necessary information about the function itself
1805 and about the args processed so far, enough to enable macros
1806 such as FUNCTION_ARG to determine where the next arg should go.
1808 On SH, this is a single integer, which is a number of words
1809 of arguments scanned so far (including the invisible argument,
1810 if any, which holds the structure-value-address).
1811 Thus NARGREGS or more means all following args should go on the stack. */
1813 enum sh_arg_class { SH_ARG_INT = 0, SH_ARG_FLOAT = 1 };
1814 struct sh_args {
1815 int arg_count[2];
1816 int force_mem;
1817 /* Nonzero if a prototype is available for the function. */
1818 int prototype_p;
1819 /* The number of an odd floating-point register, that should be used
1820 for the next argument of type float. */
1821 int free_single_fp_reg;
1822 /* Whether we're processing an outgoing function call. */
1823 int outgoing;
1824 /* The number of general-purpose registers that should have been
1825 used to pass partial arguments, that are passed totally on the
1826 stack. On SHcompact, a call trampoline will pop them off the
1827 stack before calling the actual function, and, if the called
1828 function is implemented in SHcompact mode, the incoming arguments
1829 decoder will push such arguments back onto the stack. For
1830 incoming arguments, STACK_REGS also takes into account other
1831 arguments passed by reference, that the decoder will also push
1832 onto the stack. */
1833 int stack_regs;
1834 /* The number of general-purpose registers that should have been
1835 used to pass arguments, if the arguments didn't have to be passed
1836 by reference. */
1837 int byref_regs;
1838 /* Set as by shcompact_byref if the current argument is to be passed
1839 by reference. */
1840 int byref;
1842 /* call_cookie is a bitmask used by call expanders, as well as
1843 function prologue and epilogues, to allow SHcompact to comply
1844 with the SH5 32-bit ABI, that requires 64-bit registers to be
1845 used even though only the lower 32-bit half is visible in
1846 SHcompact mode. The strategy is to call SHmedia trampolines.
1848 The alternatives for each of the argument-passing registers are
1849 (a) leave it unchanged; (b) pop it off the stack; (c) load its
1850 contents from the address in it; (d) add 8 to it, storing the
1851 result in the next register, then (c); (e) copy it from some
1852 floating-point register,
1854 Regarding copies from floating-point registers, r2 may only be
1855 copied from dr0. r3 may be copied from dr0 or dr2. r4 maybe
1856 copied from dr0, dr2 or dr4. r5 maybe copied from dr0, dr2,
1857 dr4 or dr6. r6 may be copied from dr0, dr2, dr4, dr6 or dr8.
1858 r7 through to r9 may be copied from dr0, dr2, dr4, dr8, dr8 or
1859 dr10.
1861 The bit mask is structured as follows:
1863 - 1 bit to tell whether to set up a return trampoline.
1865 - 3 bits to count the number consecutive registers to pop off the
1866 stack.
1868 - 4 bits for each of r9, r8, r7 and r6.
1870 - 3 bits for each of r5, r4, r3 and r2.
1872 - 3 bits set to 0 (the most significant ones)
1874 3 2 1 0
1875 1098 7654 3210 9876 5432 1098 7654 3210
1876 FLPF LPFL PFLP FFLP FFLP FFLP FFLP SSST
1877 2223 3344 4555 6666 7777 8888 9999 SSS-
1879 - If F is set, the register must be copied from an FP register,
1880 whose number is encoded in the remaining bits.
1882 - Else, if L is set, the register must be loaded from the address
1883 contained in it. If the P bit is *not* set, the address of the
1884 following dword should be computed first, and stored in the
1885 following register.
1887 - Else, if P is set, the register alone should be popped off the
1888 stack.
1890 - After all this processing, the number of registers represented
1891 in SSS will be popped off the stack. This is an optimization
1892 for pushing/popping consecutive registers, typically used for
1893 varargs and large arguments partially passed in registers.
1895 - If T is set, a return trampoline will be set up for 64-bit
1896 return values to be split into 2 32-bit registers. */
1897 #define CALL_COOKIE_RET_TRAMP_SHIFT 0
1898 #define CALL_COOKIE_RET_TRAMP(VAL) ((VAL) << CALL_COOKIE_RET_TRAMP_SHIFT)
1899 #define CALL_COOKIE_STACKSEQ_SHIFT 1
1900 #define CALL_COOKIE_STACKSEQ(VAL) ((VAL) << CALL_COOKIE_STACKSEQ_SHIFT)
1901 #define CALL_COOKIE_STACKSEQ_GET(COOKIE) \
1902 (((COOKIE) >> CALL_COOKIE_STACKSEQ_SHIFT) & 7)
1903 #define CALL_COOKIE_INT_REG_SHIFT(REG) \
1904 (4 * (7 - (REG)) + (((REG) <= 2) ? ((REG) - 2) : 1) + 3)
1905 #define CALL_COOKIE_INT_REG(REG, VAL) \
1906 ((VAL) << CALL_COOKIE_INT_REG_SHIFT (REG))
1907 #define CALL_COOKIE_INT_REG_GET(COOKIE, REG) \
1908 (((COOKIE) >> CALL_COOKIE_INT_REG_SHIFT (REG)) & ((REG) < 4 ? 7 : 15))
1909 long call_cookie;
1911 /* This is set to nonzero when the call in question must use the Renesas ABI,
1912 even without the -mrenesas option. */
1913 int renesas_abi;
1916 #define CUMULATIVE_ARGS struct sh_args
1918 #define GET_SH_ARG_CLASS(MODE) \
1919 ((TARGET_FPU_ANY && (MODE) == SFmode) \
1920 ? SH_ARG_FLOAT \
1921 /* There's no mention of complex float types in the SH5 ABI, so we
1922 should presumably handle them as aggregate types. */ \
1923 : TARGET_SH5 && GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT \
1924 ? SH_ARG_INT \
1925 : TARGET_FPU_DOUBLE && (GET_MODE_CLASS (MODE) == MODE_FLOAT \
1926 || GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT) \
1927 ? SH_ARG_FLOAT : SH_ARG_INT)
1929 #define ROUND_ADVANCE(SIZE) \
1930 (((SIZE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
1932 /* Round a register number up to a proper boundary for an arg of mode
1933 MODE.
1935 The SH doesn't care about double alignment, so we only
1936 round doubles to even regs when asked to explicitly. */
1938 #define ROUND_REG(CUM, MODE) \
1939 (((TARGET_ALIGN_DOUBLE \
1940 || ((TARGET_SH4 || TARGET_SH2A_DOUBLE) && ((MODE) == DFmode || (MODE) == DCmode) \
1941 && (CUM).arg_count[(int) SH_ARG_FLOAT] < NPARM_REGS (MODE)))\
1942 && GET_MODE_UNIT_SIZE ((MODE)) > UNITS_PER_WORD) \
1943 ? ((CUM).arg_count[(int) GET_SH_ARG_CLASS (MODE)] \
1944 + ((CUM).arg_count[(int) GET_SH_ARG_CLASS (MODE)] & 1)) \
1945 : (CUM).arg_count[(int) GET_SH_ARG_CLASS (MODE)])
1947 /* Initialize a variable CUM of type CUMULATIVE_ARGS
1948 for a call to a function whose data type is FNTYPE.
1949 For a library call, FNTYPE is 0.
1951 On SH, the offset always starts at 0: the first parm reg is always
1952 the same reg for a given argument class.
1954 For TARGET_HITACHI, the structure value pointer is passed in memory. */
1956 #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, FNDECL, N_NAMED_ARGS) \
1957 sh_init_cumulative_args (& (CUM), (FNTYPE), (LIBNAME), (FNDECL), (N_NAMED_ARGS), VOIDmode)
1959 #define INIT_CUMULATIVE_LIBCALL_ARGS(CUM, MODE, LIBNAME) \
1960 sh_init_cumulative_args (& (CUM), NULL_TREE, (LIBNAME), NULL_TREE, 0, (MODE))
1962 #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \
1963 sh_function_arg_advance (&(CUM), (MODE), (TYPE), (NAMED))
1964 #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
1965 sh_function_arg (&(CUM), (MODE), (TYPE), (NAMED))
1967 /* Return boolean indicating arg of mode MODE will be passed in a reg.
1968 This macro is only used in this file. */
1970 #define PASS_IN_REG_P(CUM, MODE, TYPE) \
1971 (((TYPE) == 0 \
1972 || (! TREE_ADDRESSABLE ((tree)(TYPE)) \
1973 && (! (TARGET_HITACHI || (CUM).renesas_abi) \
1974 || ! (AGGREGATE_TYPE_P (TYPE) \
1975 || (!TARGET_FPU_ANY \
1976 && (GET_MODE_CLASS (MODE) == MODE_FLOAT \
1977 && GET_MODE_SIZE (MODE) > GET_MODE_SIZE (SFmode))))))) \
1978 && ! (CUM).force_mem \
1979 && (TARGET_SH2E \
1980 ? ((MODE) == BLKmode \
1981 ? (((CUM).arg_count[(int) SH_ARG_INT] * UNITS_PER_WORD \
1982 + int_size_in_bytes (TYPE)) \
1983 <= NPARM_REGS (SImode) * UNITS_PER_WORD) \
1984 : ((ROUND_REG((CUM), (MODE)) \
1985 + HARD_REGNO_NREGS (BASE_ARG_REG (MODE), (MODE))) \
1986 <= NPARM_REGS (MODE))) \
1987 : ROUND_REG ((CUM), (MODE)) < NPARM_REGS (MODE)))
1989 /* By accident we got stuck with passing SCmode on SH4 little endian
1990 in two registers that are nominally successive - which is different from
1991 two single SFmode values, where we take endianness translation into
1992 account. That does not work at all if an odd number of registers is
1993 already in use, so that got fixed, but library functions are still more
1994 likely to use complex numbers without mixing them with SFmode arguments
1995 (which in C would have to be structures), so for the sake of ABI
1996 compatibility the way SCmode values are passed when an even number of
1997 FP registers is in use remains different from a pair of SFmode values for
1998 now.
1999 I.e.:
2000 foo (double); a: fr5,fr4
2001 foo (float a, float b); a: fr5 b: fr4
2002 foo (__complex float a); a.real fr4 a.imag: fr5 - for consistency,
2003 this should be the other way round...
2004 foo (float a, __complex float b); a: fr5 b.real: fr4 b.imag: fr7 */
2005 #define FUNCTION_ARG_SCmode_WART 1
2007 /* If an argument of size 5, 6 or 7 bytes is to be passed in a 64-bit
2008 register in SHcompact mode, it must be padded in the most
2009 significant end. This means that passing it by reference wouldn't
2010 pad properly on a big-endian machine. In this particular case, we
2011 pass this argument on the stack, in a way that the call trampoline
2012 will load its value into the appropriate register. */
2013 #define SHCOMPACT_FORCE_ON_STACK(MODE,TYPE) \
2014 ((MODE) == BLKmode \
2015 && TARGET_SHCOMPACT \
2016 && ! TARGET_LITTLE_ENDIAN \
2017 && int_size_in_bytes (TYPE) > 4 \
2018 && int_size_in_bytes (TYPE) < 8)
2020 /* Minimum alignment for an argument to be passed by callee-copy
2021 reference. We need such arguments to be aligned to 8 byte
2022 boundaries, because they'll be loaded using quad loads. */
2023 #define SH_MIN_ALIGN_FOR_CALLEE_COPY (8 * BITS_PER_UNIT)
2025 /* The SH5 ABI requires floating-point arguments to be passed to
2026 functions without a prototype in both an FP register and a regular
2027 register or the stack. When passing the argument in both FP and
2028 general-purpose registers, list the FP register first. */
2029 #define SH5_PROTOTYPELESS_FLOAT_ARG(CUM,MODE) \
2030 (gen_rtx_PARALLEL \
2031 ((MODE), \
2032 gen_rtvec (2, \
2033 gen_rtx_EXPR_LIST \
2034 (VOIDmode, \
2035 ((CUM).arg_count[(int) SH_ARG_INT] < NPARM_REGS (SImode) \
2036 ? gen_rtx_REG ((MODE), FIRST_FP_PARM_REG \
2037 + (CUM).arg_count[(int) SH_ARG_FLOAT]) \
2038 : NULL_RTX), \
2039 const0_rtx), \
2040 gen_rtx_EXPR_LIST \
2041 (VOIDmode, \
2042 ((CUM).arg_count[(int) SH_ARG_INT] < NPARM_REGS (SImode) \
2043 ? gen_rtx_REG ((MODE), FIRST_PARM_REG \
2044 + (CUM).arg_count[(int) SH_ARG_INT]) \
2045 : gen_rtx_REG ((MODE), FIRST_FP_PARM_REG \
2046 + (CUM).arg_count[(int) SH_ARG_FLOAT])), \
2047 const0_rtx))))
2049 /* The SH5 ABI requires regular registers or stack slots to be
2050 reserved for floating-point arguments. Registers are taken care of
2051 in FUNCTION_ARG_ADVANCE, but stack slots must be reserved here.
2052 Unfortunately, there's no way to just reserve a stack slot, so
2053 we'll end up needlessly storing a copy of the argument in the
2054 stack. For incoming arguments, however, the PARALLEL will be
2055 optimized to the register-only form, and the value in the stack
2056 slot won't be used at all. */
2057 #define SH5_PROTOTYPED_FLOAT_ARG(CUM,MODE,REG) \
2058 ((CUM).arg_count[(int) SH_ARG_INT] < NPARM_REGS (SImode) \
2059 ? gen_rtx_REG ((MODE), (REG)) \
2060 : gen_rtx_PARALLEL ((MODE), \
2061 gen_rtvec (2, \
2062 gen_rtx_EXPR_LIST \
2063 (VOIDmode, NULL_RTX, \
2064 const0_rtx), \
2065 gen_rtx_EXPR_LIST \
2066 (VOIDmode, gen_rtx_REG ((MODE), \
2067 (REG)), \
2068 const0_rtx))))
2070 #define SH5_WOULD_BE_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) \
2071 (TARGET_SH5 \
2072 && ((MODE) == BLKmode || (MODE) == TImode || (MODE) == CDImode \
2073 || (MODE) == DCmode) \
2074 && ((CUM).arg_count[(int) SH_ARG_INT] \
2075 + (int_size_in_bytes (TYPE) + 7) / 8) > NPARM_REGS (SImode))
2077 /* Perform any needed actions needed for a function that is receiving a
2078 variable number of arguments. */
2080 /* Implement `va_start' for varargs and stdarg. */
2081 #define EXPAND_BUILTIN_VA_START(valist, nextarg) \
2082 sh_va_start (valist, nextarg)
2084 /* Call the function profiler with a given profile label.
2085 We use two .aligns, so as to make sure that both the .long is aligned
2086 on a 4 byte boundary, and that the .long is a fixed distance (2 bytes)
2087 from the trapa instruction. */
2089 #define FUNCTION_PROFILER(STREAM,LABELNO) \
2091 if (TARGET_SHMEDIA) \
2093 fprintf((STREAM), "\tmovi\t33,r0\n"); \
2094 fprintf((STREAM), "\ttrapa\tr0\n"); \
2095 asm_fprintf((STREAM), "\t.long\t%LLP%d\n", (LABELNO)); \
2097 else \
2099 fprintf((STREAM), "\t.align\t2\n"); \
2100 fprintf((STREAM), "\ttrapa\t#33\n"); \
2101 fprintf((STREAM), "\t.align\t2\n"); \
2102 asm_fprintf((STREAM), "\t.long\t%LLP%d\n", (LABELNO)); \
2106 /* Define this macro if the code for function profiling should come
2107 before the function prologue. Normally, the profiling code comes
2108 after. */
2110 #define PROFILE_BEFORE_PROLOGUE
2112 /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
2113 the stack pointer does not matter. The value is tested only in
2114 functions that have frame pointers.
2115 No definition is equivalent to always zero. */
2117 #define EXIT_IGNORE_STACK 1
2120 On the SH, the trampoline looks like
2121 2 0002 D202 mov.l l2,r2
2122 1 0000 D301 mov.l l1,r3
2123 3 0004 422B jmp @r2
2124 4 0006 0009 nop
2125 5 0008 00000000 l1: .long area
2126 6 000c 00000000 l2: .long function */
2128 /* Length in units of the trampoline for entering a nested function. */
2129 #define TRAMPOLINE_SIZE (TARGET_SHMEDIA64 ? 40 : TARGET_SH5 ? 24 : 16)
2131 /* Alignment required for a trampoline in bits . */
2132 #define TRAMPOLINE_ALIGNMENT \
2133 ((CACHE_LOG < 3 || (TARGET_SMALLCODE && ! TARGET_HARVARD)) ? 32 \
2134 : TARGET_SHMEDIA ? 256 : 64)
2136 /* Emit RTL insns to initialize the variable parts of a trampoline.
2137 FNADDR is an RTX for the address of the function's pure code.
2138 CXT is an RTX for the static chain value for the function. */
2140 #define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) \
2141 sh_initialize_trampoline ((TRAMP), (FNADDR), (CXT))
2143 /* On SH5, trampolines are SHmedia code, so add 1 to the address. */
2145 #define TRAMPOLINE_ADJUST_ADDRESS(TRAMP) do \
2147 if (TARGET_SHMEDIA) \
2148 (TRAMP) = expand_simple_binop (Pmode, PLUS, (TRAMP), const1_rtx, \
2149 gen_reg_rtx (Pmode), 0, \
2150 OPTAB_LIB_WIDEN); \
2151 } while (0)
2153 /* A C expression whose value is RTL representing the value of the return
2154 address for the frame COUNT steps up from the current frame.
2155 FRAMEADDR is already the frame pointer of the COUNT frame, so we
2156 can ignore COUNT. */
2158 #define RETURN_ADDR_RTX(COUNT, FRAME) \
2159 (((COUNT) == 0) ? sh_get_pr_initial_val () : (rtx) 0)
2161 /* A C expression whose value is RTL representing the location of the
2162 incoming return address at the beginning of any function, before the
2163 prologue. This RTL is either a REG, indicating that the return
2164 value is saved in REG, or a MEM representing a location in
2165 the stack. */
2166 #define INCOMING_RETURN_ADDR_RTX \
2167 gen_rtx_REG (Pmode, TARGET_SHMEDIA ? PR_MEDIA_REG : PR_REG)
2169 /* Addressing modes, and classification of registers for them. */
2170 #define HAVE_POST_INCREMENT TARGET_SH1
2171 #define HAVE_PRE_DECREMENT TARGET_SH1
2173 #define USE_LOAD_POST_INCREMENT(mode) ((mode == SImode || mode == DImode) \
2174 ? 0 : TARGET_SH1)
2175 #define USE_LOAD_PRE_DECREMENT(mode) 0
2176 #define USE_STORE_POST_INCREMENT(mode) 0
2177 #define USE_STORE_PRE_DECREMENT(mode) ((mode == SImode || mode == DImode) \
2178 ? 0 : TARGET_SH1)
2180 #define MOVE_BY_PIECES_P(SIZE, ALIGN) \
2181 (move_by_pieces_ninsns (SIZE, ALIGN, MOVE_MAX_PIECES + 1) \
2182 < (TARGET_SMALLCODE ? 2 : ((ALIGN >= 32) ? 16 : 2)))
2184 #define STORE_BY_PIECES_P(SIZE, ALIGN) \
2185 (move_by_pieces_ninsns (SIZE, ALIGN, STORE_MAX_PIECES + 1) \
2186 < (TARGET_SMALLCODE ? 2 : ((ALIGN >= 32) ? 16 : 2)))
2188 /* Macros to check register numbers against specific register classes. */
2190 /* These assume that REGNO is a hard or pseudo reg number.
2191 They give nonzero only if REGNO is a hard reg of the suitable class
2192 or a pseudo reg currently allocated to a suitable hard reg.
2193 Since they use reg_renumber, they are safe only once reg_renumber
2194 has been allocated, which happens in local-alloc.c. */
2196 #define REGNO_OK_FOR_BASE_P(REGNO) \
2197 (GENERAL_OR_AP_REGISTER_P (REGNO) \
2198 || GENERAL_OR_AP_REGISTER_P (reg_renumber[(REGNO)]))
2199 #define REGNO_OK_FOR_INDEX_P(REGNO) \
2200 (TARGET_SHMEDIA \
2201 ? (GENERAL_REGISTER_P (REGNO) \
2202 || GENERAL_REGISTER_P ((unsigned) reg_renumber[(REGNO)])) \
2203 : (REGNO) == R0_REG || (unsigned) reg_renumber[(REGNO)] == R0_REG)
2205 /* Maximum number of registers that can appear in a valid memory
2206 address. */
2208 #define MAX_REGS_PER_ADDRESS 2
2210 /* Recognize any constant value that is a valid address. */
2212 #define CONSTANT_ADDRESS_P(X) (GET_CODE (X) == LABEL_REF)
2214 /* Nonzero if the constant value X is a legitimate general operand. */
2216 #define LEGITIMATE_CONSTANT_P(X) \
2217 (TARGET_SHMEDIA \
2218 ? ((GET_MODE (X) != DFmode \
2219 && GET_MODE_CLASS (GET_MODE (X)) != MODE_VECTOR_FLOAT) \
2220 || (X) == CONST0_RTX (GET_MODE (X)) \
2221 || ! TARGET_SHMEDIA_FPU \
2222 || TARGET_SHMEDIA64) \
2223 : (GET_CODE (X) != CONST_DOUBLE \
2224 || GET_MODE (X) == DFmode || GET_MODE (X) == SFmode \
2225 || (TARGET_SH2E && (fp_zero_operand (X) || fp_one_operand (X)))))
2227 /* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
2228 and check its validity for a certain class.
2229 We have two alternate definitions for each of them.
2230 The usual definition accepts all pseudo regs; the other rejects
2231 them unless they have been allocated suitable hard regs.
2232 The symbol REG_OK_STRICT causes the latter definition to be used. */
2234 #ifndef REG_OK_STRICT
2236 /* Nonzero if X is a hard reg that can be used as a base reg
2237 or if it is a pseudo reg. */
2238 #define REG_OK_FOR_BASE_P(X) \
2239 (GENERAL_OR_AP_REGISTER_P (REGNO (X)) || REGNO (X) >= FIRST_PSEUDO_REGISTER)
2241 /* Nonzero if X is a hard reg that can be used as an index
2242 or if it is a pseudo reg. */
2243 #define REG_OK_FOR_INDEX_P(X) \
2244 ((TARGET_SHMEDIA ? GENERAL_REGISTER_P (REGNO (X)) \
2245 : REGNO (X) == R0_REG) || REGNO (X) >= FIRST_PSEUDO_REGISTER)
2247 /* Nonzero if X/OFFSET is a hard reg that can be used as an index
2248 or if X is a pseudo reg. */
2249 #define SUBREG_OK_FOR_INDEX_P(X, OFFSET) \
2250 ((TARGET_SHMEDIA ? GENERAL_REGISTER_P (REGNO (X)) \
2251 : REGNO (X) == R0_REG && OFFSET == 0) || REGNO (X) >= FIRST_PSEUDO_REGISTER)
2253 #else
2255 /* Nonzero if X is a hard reg that can be used as a base reg. */
2256 #define REG_OK_FOR_BASE_P(X) \
2257 REGNO_OK_FOR_BASE_P (REGNO (X))
2259 /* Nonzero if X is a hard reg that can be used as an index. */
2260 #define REG_OK_FOR_INDEX_P(X) \
2261 REGNO_OK_FOR_INDEX_P (REGNO (X))
2263 /* Nonzero if X/OFFSET is a hard reg that can be used as an index. */
2264 #define SUBREG_OK_FOR_INDEX_P(X, OFFSET) \
2265 (REGNO_OK_FOR_INDEX_P (REGNO (X)) && (OFFSET) == 0)
2267 #endif
2269 /* The 'Q' constraint is a pc relative load operand. */
2270 #define EXTRA_CONSTRAINT_Q(OP) \
2271 (GET_CODE (OP) == MEM \
2272 && ((GET_CODE (XEXP ((OP), 0)) == LABEL_REF) \
2273 || (GET_CODE (XEXP ((OP), 0)) == CONST \
2274 && GET_CODE (XEXP (XEXP ((OP), 0), 0)) == PLUS \
2275 && GET_CODE (XEXP (XEXP (XEXP ((OP), 0), 0), 0)) == LABEL_REF \
2276 && GET_CODE (XEXP (XEXP (XEXP ((OP), 0), 0), 1)) == CONST_INT)))
2278 /* Extra address constraints. */
2279 #define EXTRA_CONSTRAINT_A(OP, STR) 0
2281 /* Constraint for selecting FLDI0 or FLDI1 instruction. If the clobber
2282 operand is not SCRATCH (i.e. REG) then R0 is probably being
2283 used, hence mova is being used, hence do not select this pattern */
2284 #define EXTRA_CONSTRAINT_Bsc(OP) (GET_CODE(OP) == SCRATCH)
2285 #define EXTRA_CONSTRAINT_B(OP, STR) \
2286 ((STR)[1] == 's' && (STR)[2] == 'c' ? EXTRA_CONSTRAINT_Bsc (OP) \
2287 : 0)
2289 /* The `C16' constraint is a 16-bit constant, literal or symbolic. */
2290 #define EXTRA_CONSTRAINT_C16(OP) \
2291 (GET_CODE (OP) == CONST \
2292 && GET_CODE (XEXP ((OP), 0)) == SIGN_EXTEND \
2293 && (GET_MODE (XEXP ((OP), 0)) == DImode \
2294 || GET_MODE (XEXP ((OP), 0)) == SImode) \
2295 && GET_CODE (XEXP (XEXP ((OP), 0), 0)) == TRUNCATE \
2296 && GET_MODE (XEXP (XEXP ((OP), 0), 0)) == HImode \
2297 && (MOVI_SHORI_BASE_OPERAND_P (XEXP (XEXP (XEXP ((OP), 0), 0), 0)) \
2298 || (GET_CODE (XEXP (XEXP (XEXP ((OP), 0), 0), 0)) == ASHIFTRT \
2299 && (MOVI_SHORI_BASE_OPERAND_P \
2300 (XEXP (XEXP (XEXP (XEXP ((OP), 0), 0), 0), 0))) \
2301 && GET_CODE (XEXP (XEXP (XEXP (XEXP ((OP), 0), 0), 0), \
2302 1)) == CONST_INT)))
2304 /* Check whether OP is a datalabel unspec. */
2305 #define DATALABEL_REF_NO_CONST_P(OP) \
2306 (GET_CODE (OP) == UNSPEC \
2307 && XINT ((OP), 1) == UNSPEC_DATALABEL \
2308 && XVECLEN ((OP), 0) == 1 \
2309 && GET_CODE (XVECEXP ((OP), 0, 0)) == LABEL_REF)
2311 #define GOT_ENTRY_P(OP) \
2312 (GET_CODE (OP) == CONST && GET_CODE (XEXP ((OP), 0)) == UNSPEC \
2313 && XINT (XEXP ((OP), 0), 1) == UNSPEC_GOT)
2315 #define GOTPLT_ENTRY_P(OP) \
2316 (GET_CODE (OP) == CONST && GET_CODE (XEXP ((OP), 0)) == UNSPEC \
2317 && XINT (XEXP ((OP), 0), 1) == UNSPEC_GOTPLT)
2319 #define UNSPEC_GOTOFF_P(OP) \
2320 (GET_CODE (OP) == UNSPEC && XINT ((OP), 1) == UNSPEC_GOTOFF)
2322 #define GOTOFF_P(OP) \
2323 (GET_CODE (OP) == CONST \
2324 && (UNSPEC_GOTOFF_P (XEXP ((OP), 0)) \
2325 || (GET_CODE (XEXP ((OP), 0)) == PLUS \
2326 && UNSPEC_GOTOFF_P (XEXP (XEXP ((OP), 0), 0)) \
2327 && GET_CODE (XEXP (XEXP ((OP), 0), 1)) == CONST_INT)))
2329 #define PIC_ADDR_P(OP) \
2330 (GET_CODE (OP) == CONST && GET_CODE (XEXP ((OP), 0)) == UNSPEC \
2331 && XINT (XEXP ((OP), 0), 1) == UNSPEC_PIC)
2333 #define PIC_OFFSET_P(OP) \
2334 (PIC_ADDR_P (OP) \
2335 && GET_CODE (XVECEXP (XEXP ((OP), 0), 0, 0)) == MINUS \
2336 && reg_mentioned_p (pc_rtx, XEXP (XVECEXP (XEXP ((OP), 0), 0, 0), 1)))
2338 #define PIC_DIRECT_ADDR_P(OP) \
2339 (PIC_ADDR_P (OP) && GET_CODE (XVECEXP (XEXP ((OP), 0), 0, 0)) != MINUS)
2341 #define NON_PIC_REFERENCE_P(OP) \
2342 (GET_CODE (OP) == LABEL_REF || GET_CODE (OP) == SYMBOL_REF \
2343 || (GET_CODE (OP) == CONST \
2344 && (GET_CODE (XEXP ((OP), 0)) == LABEL_REF \
2345 || GET_CODE (XEXP ((OP), 0)) == SYMBOL_REF \
2346 || DATALABEL_REF_NO_CONST_P (XEXP ((OP), 0)))) \
2347 || (GET_CODE (OP) == CONST && GET_CODE (XEXP ((OP), 0)) == PLUS \
2348 && (GET_CODE (XEXP (XEXP ((OP), 0), 0)) == SYMBOL_REF \
2349 || GET_CODE (XEXP (XEXP ((OP), 0), 0)) == LABEL_REF \
2350 || DATALABEL_REF_NO_CONST_P (XEXP (XEXP ((OP), 0), 0))) \
2351 && GET_CODE (XEXP (XEXP ((OP), 0), 1)) == CONST_INT))
2353 #define PIC_REFERENCE_P(OP) \
2354 (GOT_ENTRY_P (OP) || GOTPLT_ENTRY_P (OP) \
2355 || GOTOFF_P (OP) || PIC_ADDR_P (OP))
2357 #define MOVI_SHORI_BASE_OPERAND_P(OP) \
2358 (flag_pic \
2359 ? (GOT_ENTRY_P (OP) || GOTPLT_ENTRY_P (OP) || GOTOFF_P (OP) \
2360 || PIC_OFFSET_P (OP)) \
2361 : NON_PIC_REFERENCE_P (OP))
2363 /* The `Csy' constraint is a label or a symbol. */
2364 #define EXTRA_CONSTRAINT_Csy(OP) \
2365 (NON_PIC_REFERENCE_P (OP) || PIC_DIRECT_ADDR_P (OP))
2367 /* A zero in any shape or form. */
2368 #define EXTRA_CONSTRAINT_Z(OP) \
2369 ((OP) == CONST0_RTX (GET_MODE (OP)))
2371 /* Any vector constant we can handle. */
2372 #define EXTRA_CONSTRAINT_W(OP) \
2373 (GET_CODE (OP) == CONST_VECTOR \
2374 && (sh_rep_vec ((OP), VOIDmode) \
2375 || (HOST_BITS_PER_WIDE_INT >= 64 \
2376 ? sh_const_vec ((OP), VOIDmode) \
2377 : sh_1el_vec ((OP), VOIDmode))))
2379 /* A non-explicit constant that can be loaded directly into a general purpose
2380 register. This is like 's' except we don't allow PIC_DIRECT_ADDR_P. */
2381 #define EXTRA_CONSTRAINT_Cpg(OP) \
2382 (CONSTANT_P (OP) \
2383 && GET_CODE (OP) != CONST_INT \
2384 && GET_CODE (OP) != CONST_DOUBLE \
2385 && (!flag_pic \
2386 || (LEGITIMATE_PIC_OPERAND_P (OP) \
2387 && (! PIC_ADDR_P (OP) || PIC_OFFSET_P (OP)) \
2388 && GET_CODE (OP) != LABEL_REF)))
2389 #define EXTRA_CONSTRAINT_C(OP, STR) \
2390 ((STR)[1] == '1' && (STR)[2] == '6' ? EXTRA_CONSTRAINT_C16 (OP) \
2391 : (STR)[1] == 's' && (STR)[2] == 'y' ? EXTRA_CONSTRAINT_Csy (OP) \
2392 : (STR)[1] == 'p' && (STR)[2] == 'g' ? EXTRA_CONSTRAINT_Cpg (OP) \
2393 : 0)
2395 #define EXTRA_MEMORY_CONSTRAINT(C,STR) ((C) == 'S')
2396 #define EXTRA_CONSTRAINT_Sr0(OP) \
2397 (memory_operand((OP), GET_MODE (OP)) \
2398 && ! refers_to_regno_p (R0_REG, R0_REG + 1, OP, (rtx *)0))
2399 #define EXTRA_CONSTRAINT_Sua(OP) \
2400 (memory_operand((OP), GET_MODE (OP)) \
2401 && GET_CODE (XEXP (OP, 0)) != PLUS)
2402 #define EXTRA_CONSTRAINT_S(OP, STR) \
2403 ((STR)[1] == 'r' && (STR)[2] == '0' ? EXTRA_CONSTRAINT_Sr0 (OP) \
2404 : (STR)[1] == 'u' && (STR)[2] == 'a' ? EXTRA_CONSTRAINT_Sua (OP) \
2405 : 0)
2407 #define EXTRA_CONSTRAINT_STR(OP, C, STR) \
2408 ((C) == 'Q' ? EXTRA_CONSTRAINT_Q (OP) \
2409 : (C) == 'A' ? EXTRA_CONSTRAINT_A ((OP), (STR)) \
2410 : (C) == 'B' ? EXTRA_CONSTRAINT_B ((OP), (STR)) \
2411 : (C) == 'C' ? EXTRA_CONSTRAINT_C ((OP), (STR)) \
2412 : (C) == 'S' ? EXTRA_CONSTRAINT_S ((OP), (STR)) \
2413 : (C) == 'W' ? EXTRA_CONSTRAINT_W (OP) \
2414 : (C) == 'Z' ? EXTRA_CONSTRAINT_Z (OP) \
2415 : 0)
2417 /* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression
2418 that is a valid memory address for an instruction.
2419 The MODE argument is the machine mode for the MEM expression
2420 that wants to use this address. */
2422 #define MODE_DISP_OK_4(X,MODE) \
2423 (GET_MODE_SIZE (MODE) == 4 && (unsigned) INTVAL (X) < 64 \
2424 && ! (INTVAL (X) & 3) && ! (TARGET_SH2E && (MODE) == SFmode))
2426 #define MODE_DISP_OK_8(X,MODE) \
2427 ((GET_MODE_SIZE(MODE)==8) && ((unsigned)INTVAL(X)<60) \
2428 && ! (INTVAL(X) & 3) && ! (TARGET_SH4 && (MODE) == DFmode))
2430 #undef MODE_DISP_OK_4
2431 #define MODE_DISP_OK_4(X,MODE) \
2432 ((GET_MODE_SIZE (MODE) == 4 && (unsigned) INTVAL (X) < 64 \
2433 && ! (INTVAL (X) & 3) && ! (TARGET_SH2E && (MODE) == SFmode)) \
2434 || ((GET_MODE_SIZE(MODE)==4) && ((unsigned)INTVAL(X)<16383) \
2435 && ! (INTVAL(X) & 3) && TARGET_SH2A))
2437 #undef MODE_DISP_OK_8
2438 #define MODE_DISP_OK_8(X,MODE) \
2439 (((GET_MODE_SIZE(MODE)==8) && ((unsigned)INTVAL(X)<60) \
2440 && ! (INTVAL(X) & 3) && ! ((TARGET_SH4 || TARGET_SH2A) && (MODE) == DFmode)) \
2441 || ((GET_MODE_SIZE(MODE)==8) && ((unsigned)INTVAL(X)<8192) \
2442 && ! (INTVAL(X) & (TARGET_SH2A_DOUBLE ? 7 : 3)) && (TARGET_SH2A && (MODE) == DFmode)))
2444 #define BASE_REGISTER_RTX_P(X) \
2445 ((GET_CODE (X) == REG && REG_OK_FOR_BASE_P (X)) \
2446 || (GET_CODE (X) == SUBREG \
2447 && TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (GET_MODE ((X))), \
2448 GET_MODE_BITSIZE (GET_MODE (SUBREG_REG (X)))) \
2449 && GET_CODE (SUBREG_REG (X)) == REG \
2450 && REG_OK_FOR_BASE_P (SUBREG_REG (X))))
2452 /* Since this must be r0, which is a single register class, we must check
2453 SUBREGs more carefully, to be sure that we don't accept one that extends
2454 outside the class. */
2455 #define INDEX_REGISTER_RTX_P(X) \
2456 ((GET_CODE (X) == REG && REG_OK_FOR_INDEX_P (X)) \
2457 || (GET_CODE (X) == SUBREG \
2458 && TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (GET_MODE ((X))), \
2459 GET_MODE_BITSIZE (GET_MODE (SUBREG_REG (X)))) \
2460 && GET_CODE (SUBREG_REG (X)) == REG \
2461 && SUBREG_OK_FOR_INDEX_P (SUBREG_REG (X), SUBREG_BYTE (X))))
2463 /* Jump to LABEL if X is a valid address RTX. This must also take
2464 REG_OK_STRICT into account when deciding about valid registers, but it uses
2465 the above macros so we are in luck.
2467 Allow REG
2468 REG+disp
2469 REG+r0
2470 REG++
2471 --REG */
2473 /* ??? The SH2e does not have the REG+disp addressing mode when loading values
2474 into the FRx registers. We implement this by setting the maximum offset
2475 to zero when the value is SFmode. This also restricts loading of SFmode
2476 values into the integer registers, but that can't be helped. */
2478 /* The SH allows a displacement in a QI or HI amode, but only when the
2479 other operand is R0. GCC doesn't handle this very well, so we forgo
2480 all of that.
2482 A legitimate index for a QI or HI is 0, SI can be any number 0..63,
2483 DI can be any number 0..60. */
2485 #define GO_IF_LEGITIMATE_INDEX(MODE, OP, LABEL) \
2486 do { \
2487 if (GET_CODE (OP) == CONST_INT) \
2489 if (TARGET_SHMEDIA) \
2491 int MODE_SIZE; \
2492 /* Check if this the address of an unaligned load / store. */\
2493 if ((MODE) == VOIDmode) \
2495 if (CONST_OK_FOR_I06 (INTVAL (OP))) \
2496 goto LABEL; \
2497 break; \
2499 MODE_SIZE = GET_MODE_SIZE (MODE); \
2500 if (! (INTVAL (OP) & (MODE_SIZE - 1)) \
2501 && INTVAL (OP) >= -512 * MODE_SIZE \
2502 && INTVAL (OP) < 512 * MODE_SIZE) \
2503 goto LABEL; \
2504 else \
2505 break; \
2507 if (MODE_DISP_OK_4 ((OP), (MODE))) goto LABEL; \
2508 if (MODE_DISP_OK_8 ((OP), (MODE))) goto LABEL; \
2510 } while(0)
2512 #define ALLOW_INDEXED_ADDRESS \
2513 ((!TARGET_SHMEDIA32 && !TARGET_SHCOMPACT) || TARGET_ALLOW_INDEXED_ADDRESS)
2515 #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, LABEL) \
2517 if (BASE_REGISTER_RTX_P (X)) \
2518 goto LABEL; \
2519 else if ((GET_CODE (X) == POST_INC || GET_CODE (X) == PRE_DEC) \
2520 && ! TARGET_SHMEDIA \
2521 && BASE_REGISTER_RTX_P (XEXP ((X), 0))) \
2522 goto LABEL; \
2523 else if (GET_CODE (X) == PLUS \
2524 && ((MODE) != PSImode || reload_completed)) \
2526 rtx xop0 = XEXP ((X), 0); \
2527 rtx xop1 = XEXP ((X), 1); \
2528 if (GET_MODE_SIZE (MODE) <= 8 && BASE_REGISTER_RTX_P (xop0)) \
2529 GO_IF_LEGITIMATE_INDEX ((MODE), xop1, LABEL); \
2530 if ((ALLOW_INDEXED_ADDRESS || GET_MODE (X) == DImode \
2531 || ((xop0 == stack_pointer_rtx || xop0 == frame_pointer_rtx) \
2532 && REG_P (xop1) && REGNO (xop1) == R0_REG) \
2533 || ((xop1 == stack_pointer_rtx || xop1 == frame_pointer_rtx) \
2534 && REG_P (xop0) && REGNO (xop0) == R0_REG)) \
2535 && ((!TARGET_SHMEDIA && GET_MODE_SIZE (MODE) <= 4) \
2536 || (TARGET_SHMEDIA && GET_MODE_SIZE (MODE) <= 8) \
2537 || ((TARGET_SH4 || TARGET_SH2A_DOUBLE) \
2538 && TARGET_FMOVD && MODE == DFmode))) \
2540 if (BASE_REGISTER_RTX_P (xop1) && INDEX_REGISTER_RTX_P (xop0))\
2541 goto LABEL; \
2542 if (INDEX_REGISTER_RTX_P (xop1) && BASE_REGISTER_RTX_P (xop0))\
2543 goto LABEL; \
2548 /* Try machine-dependent ways of modifying an illegitimate address
2549 to be legitimate. If we find one, return the new, valid address.
2550 This macro is used in only one place: `memory_address' in explow.c.
2552 OLDX is the address as it was before break_out_memory_refs was called.
2553 In some cases it is useful to look at this to decide what needs to be done.
2555 MODE and WIN are passed so that this macro can use
2556 GO_IF_LEGITIMATE_ADDRESS.
2558 It is always safe for this macro to do nothing. It exists to recognize
2559 opportunities to optimize the output.
2561 For the SH, if X is almost suitable for indexing, but the offset is
2562 out of range, convert it into a normal form so that cse has a chance
2563 of reducing the number of address registers used. */
2565 #define LEGITIMIZE_ADDRESS(X,OLDX,MODE,WIN) \
2567 if (flag_pic) \
2568 (X) = legitimize_pic_address (OLDX, MODE, NULL_RTX); \
2569 if (GET_CODE (X) == PLUS \
2570 && (GET_MODE_SIZE (MODE) == 4 \
2571 || GET_MODE_SIZE (MODE) == 8) \
2572 && GET_CODE (XEXP ((X), 1)) == CONST_INT \
2573 && BASE_REGISTER_RTX_P (XEXP ((X), 0)) \
2574 && ! TARGET_SHMEDIA \
2575 && ! ((TARGET_SH4 || TARGET_SH2A_DOUBLE) && (MODE) == DFmode) \
2576 && ! (TARGET_SH2E && (MODE) == SFmode)) \
2578 rtx index_rtx = XEXP ((X), 1); \
2579 HOST_WIDE_INT offset = INTVAL (index_rtx), offset_base; \
2580 rtx sum; \
2582 GO_IF_LEGITIMATE_INDEX ((MODE), index_rtx, WIN); \
2583 /* On rare occasions, we might get an unaligned pointer \
2584 that is indexed in a way to give an aligned address. \
2585 Therefore, keep the lower two bits in offset_base. */ \
2586 /* Instead of offset_base 128..131 use 124..127, so that \
2587 simple add suffices. */ \
2588 if (offset > 127) \
2590 offset_base = ((offset + 4) & ~60) - 4; \
2592 else \
2593 offset_base = offset & ~60; \
2594 /* Sometimes the normal form does not suit DImode. We \
2595 could avoid that by using smaller ranges, but that \
2596 would give less optimized code when SImode is \
2597 prevalent. */ \
2598 if (GET_MODE_SIZE (MODE) + offset - offset_base <= 64) \
2600 sum = expand_binop (Pmode, add_optab, XEXP ((X), 0), \
2601 GEN_INT (offset_base), NULL_RTX, 0, \
2602 OPTAB_LIB_WIDEN); \
2604 (X) = gen_rtx_PLUS (Pmode, sum, GEN_INT (offset - offset_base)); \
2605 goto WIN; \
2610 /* A C compound statement that attempts to replace X, which is an address
2611 that needs reloading, with a valid memory address for an operand of
2612 mode MODE. WIN is a C statement label elsewhere in the code.
2614 Like for LEGITIMIZE_ADDRESS, for the SH we try to get a normal form
2615 of the address. That will allow inheritance of the address reloads. */
2617 #define LEGITIMIZE_RELOAD_ADDRESS(X,MODE,OPNUM,TYPE,IND_LEVELS,WIN) \
2619 if (GET_CODE (X) == PLUS \
2620 && (GET_MODE_SIZE (MODE) == 4 || GET_MODE_SIZE (MODE) == 8) \
2621 && GET_CODE (XEXP (X, 1)) == CONST_INT \
2622 && BASE_REGISTER_RTX_P (XEXP (X, 0)) \
2623 && ! TARGET_SHMEDIA \
2624 && ! (TARGET_SH4 && (MODE) == DFmode) \
2625 && ! ((MODE) == PSImode && (TYPE) == RELOAD_FOR_INPUT_ADDRESS) \
2626 && (ALLOW_INDEXED_ADDRESS \
2627 || XEXP ((X), 0) == stack_pointer_rtx \
2628 || XEXP ((X), 0) == frame_pointer_rtx)) \
2630 rtx index_rtx = XEXP (X, 1); \
2631 HOST_WIDE_INT offset = INTVAL (index_rtx), offset_base; \
2632 rtx sum; \
2634 if (TARGET_SH2A && (MODE) == DFmode && (offset & 0x7)) \
2636 push_reload (X, NULL_RTX, &X, NULL, \
2637 BASE_REG_CLASS, Pmode, VOIDmode, 0, 0, (OPNUM), \
2638 (TYPE)); \
2639 goto WIN; \
2641 if (TARGET_SH2E && MODE == SFmode) \
2643 X = copy_rtx (X); \
2644 push_reload (index_rtx, NULL_RTX, &XEXP (X, 1), NULL, \
2645 R0_REGS, Pmode, VOIDmode, 0, 0, (OPNUM), \
2646 (TYPE)); \
2647 goto WIN; \
2649 /* Instead of offset_base 128..131 use 124..127, so that \
2650 simple add suffices. */ \
2651 if (offset > 127) \
2653 offset_base = ((offset + 4) & ~60) - 4; \
2655 else \
2656 offset_base = offset & ~60; \
2657 /* Sometimes the normal form does not suit DImode. We \
2658 could avoid that by using smaller ranges, but that \
2659 would give less optimized code when SImode is \
2660 prevalent. */ \
2661 if (GET_MODE_SIZE (MODE) + offset - offset_base <= 64) \
2663 sum = gen_rtx_PLUS (Pmode, XEXP (X, 0), \
2664 GEN_INT (offset_base)); \
2665 X = gen_rtx_PLUS (Pmode, sum, GEN_INT (offset - offset_base));\
2666 push_reload (sum, NULL_RTX, &XEXP (X, 0), NULL, \
2667 BASE_REG_CLASS, Pmode, VOIDmode, 0, 0, (OPNUM), \
2668 (TYPE)); \
2669 goto WIN; \
2672 /* We must re-recognize what we created before. */ \
2673 else if (GET_CODE (X) == PLUS \
2674 && (GET_MODE_SIZE (MODE) == 4 || GET_MODE_SIZE (MODE) == 8) \
2675 && GET_CODE (XEXP (X, 0)) == PLUS \
2676 && GET_CODE (XEXP (XEXP (X, 0), 1)) == CONST_INT \
2677 && BASE_REGISTER_RTX_P (XEXP (XEXP (X, 0), 0)) \
2678 && GET_CODE (XEXP (X, 1)) == CONST_INT \
2679 && ! TARGET_SHMEDIA \
2680 && ! (TARGET_SH2E && MODE == SFmode)) \
2682 /* Because this address is so complex, we know it must have \
2683 been created by LEGITIMIZE_RELOAD_ADDRESS before; thus, \
2684 it is already unshared, and needs no further unsharing. */ \
2685 push_reload (XEXP ((X), 0), NULL_RTX, &XEXP ((X), 0), NULL, \
2686 BASE_REG_CLASS, Pmode, VOIDmode, 0, 0, (OPNUM), (TYPE));\
2687 goto WIN; \
2691 /* Go to LABEL if ADDR (a legitimate address expression)
2692 has an effect that depends on the machine mode it is used for.
2694 ??? Strictly speaking, we should also include all indexed addressing,
2695 because the index scale factor is the length of the operand.
2696 However, the impact of GO_IF_MODE_DEPENDENT_ADDRESS would be to
2697 high if we did that. So we rely on reload to fix things up. */
2699 #define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR,LABEL) \
2701 if (GET_CODE(ADDR) == PRE_DEC || GET_CODE(ADDR) == POST_INC) \
2702 goto LABEL; \
2705 /* Specify the machine mode that this machine uses
2706 for the index in the tablejump instruction. */
2707 #define CASE_VECTOR_MODE ((! optimize || TARGET_BIGTABLE) ? SImode : HImode)
2709 #define CASE_VECTOR_SHORTEN_MODE(MIN_OFFSET, MAX_OFFSET, BODY) \
2710 ((MIN_OFFSET) >= 0 && (MAX_OFFSET) <= 127 \
2711 ? (ADDR_DIFF_VEC_FLAGS (BODY).offset_unsigned = 0, QImode) \
2712 : (MIN_OFFSET) >= 0 && (MAX_OFFSET) <= 255 \
2713 ? (ADDR_DIFF_VEC_FLAGS (BODY).offset_unsigned = 1, QImode) \
2714 : (MIN_OFFSET) >= -32768 && (MAX_OFFSET) <= 32767 ? HImode \
2715 : SImode)
2717 /* Define as C expression which evaluates to nonzero if the tablejump
2718 instruction expects the table to contain offsets from the address of the
2719 table.
2720 Do not define this if the table should contain absolute addresses. */
2721 #define CASE_VECTOR_PC_RELATIVE 1
2723 /* Define it here, so that it doesn't get bumped to 64-bits on SHmedia. */
2724 #define FLOAT_TYPE_SIZE 32
2726 /* Since the SH2e has only `float' support, it is desirable to make all
2727 floating point types equivalent to `float'. */
2728 #define DOUBLE_TYPE_SIZE ((TARGET_SH2E && ! TARGET_SH4 && ! TARGET_SH2A_DOUBLE) ? 32 : 64)
2730 /* 'char' is signed by default. */
2731 #define DEFAULT_SIGNED_CHAR 1
2733 /* The type of size_t unsigned int. */
2734 #define SIZE_TYPE (TARGET_SH5 ? "long unsigned int" : "unsigned int")
2736 #undef PTRDIFF_TYPE
2737 #define PTRDIFF_TYPE (TARGET_SH5 ? "long int" : "int")
2739 #define WCHAR_TYPE "short unsigned int"
2740 #define WCHAR_TYPE_SIZE 16
2742 #define SH_ELF_WCHAR_TYPE "long int"
2744 /* Max number of bytes we can move from memory to memory
2745 in one reasonably fast instruction. */
2746 #define MOVE_MAX (TARGET_SHMEDIA ? 8 : 4)
2748 /* Maximum value possibly taken by MOVE_MAX. Must be defined whenever
2749 MOVE_MAX is not a compile-time constant. */
2750 #define MAX_MOVE_MAX 8
2752 /* Max number of bytes we want move_by_pieces to be able to copy
2753 efficiently. */
2754 #define MOVE_MAX_PIECES (TARGET_SH4 || TARGET_SHMEDIA ? 8 : 4)
2756 /* Define if operations between registers always perform the operation
2757 on the full register even if a narrower mode is specified. */
2758 #define WORD_REGISTER_OPERATIONS
2760 /* Define if loading in MODE, an integral mode narrower than BITS_PER_WORD
2761 will either zero-extend or sign-extend. The value of this macro should
2762 be the code that says which one of the two operations is implicitly
2763 done, UNKNOWN if none. */
2764 /* For SHmedia, we can truncate to QImode easier using zero extension. */
2765 /* FP registers can load SImode values, but don't implicitly sign-extend
2766 them to DImode. */
2767 #define LOAD_EXTEND_OP(MODE) \
2768 (((MODE) == QImode && TARGET_SHMEDIA) ? ZERO_EXTEND \
2769 : (MODE) != SImode ? SIGN_EXTEND : UNKNOWN)
2771 /* Define if loading short immediate values into registers sign extends. */
2772 #define SHORT_IMMEDIATES_SIGN_EXTEND
2774 /* Nonzero if access to memory by bytes is no faster than for words. */
2775 #define SLOW_BYTE_ACCESS 1
2777 /* Immediate shift counts are truncated by the output routines (or was it
2778 the assembler?). Shift counts in a register are truncated by SH. Note
2779 that the native compiler puts too large (> 32) immediate shift counts
2780 into a register and shifts by the register, letting the SH decide what
2781 to do instead of doing that itself. */
2782 /* ??? The library routines in lib1funcs.asm truncate the shift count.
2783 However, the SH3 has hardware shifts that do not truncate exactly as gcc
2784 expects - the sign bit is significant - so it appears that we need to
2785 leave this zero for correct SH3 code. */
2786 #define SHIFT_COUNT_TRUNCATED (! TARGET_SH3 && ! TARGET_SH2A)
2788 /* All integers have the same format so truncation is easy. */
2789 /* But SHmedia must sign-extend DImode when truncating to SImode. */
2790 #define TRULY_NOOP_TRUNCATION(OUTPREC,INPREC) \
2791 (!TARGET_SHMEDIA || (INPREC) < 64 || (OUTPREC) >= 64)
2793 /* Define this if addresses of constant functions
2794 shouldn't be put through pseudo regs where they can be cse'd.
2795 Desirable on machines where ordinary constants are expensive
2796 but a CALL with constant address is cheap. */
2797 /*#define NO_FUNCTION_CSE 1*/
2799 /* The machine modes of pointers and functions. */
2800 #define Pmode (TARGET_SHMEDIA64 ? DImode : SImode)
2801 #define FUNCTION_MODE Pmode
2803 /* The multiply insn on the SH1 and the divide insns on the SH1 and SH2
2804 are actually function calls with some special constraints on arguments
2805 and register usage.
2807 These macros tell reorg that the references to arguments and
2808 register clobbers for insns of type sfunc do not appear to happen
2809 until after the millicode call. This allows reorg to put insns
2810 which set the argument registers into the delay slot of the millicode
2811 call -- thus they act more like traditional CALL_INSNs.
2813 get_attr_is_sfunc will try to recognize the given insn, so make sure to
2814 filter out things it will not accept -- SEQUENCE, USE and CLOBBER insns
2815 in particular. */
2817 #define INSN_SETS_ARE_DELAYED(X) \
2818 ((GET_CODE (X) == INSN \
2819 && GET_CODE (PATTERN (X)) != SEQUENCE \
2820 && GET_CODE (PATTERN (X)) != USE \
2821 && GET_CODE (PATTERN (X)) != CLOBBER \
2822 && get_attr_is_sfunc (X)))
2824 #define INSN_REFERENCES_ARE_DELAYED(X) \
2825 ((GET_CODE (X) == INSN \
2826 && GET_CODE (PATTERN (X)) != SEQUENCE \
2827 && GET_CODE (PATTERN (X)) != USE \
2828 && GET_CODE (PATTERN (X)) != CLOBBER \
2829 && get_attr_is_sfunc (X)))
2832 /* Position Independent Code. */
2834 /* We can't directly access anything that contains a symbol,
2835 nor can we indirect via the constant pool. */
2836 #define LEGITIMATE_PIC_OPERAND_P(X) \
2837 ((! nonpic_symbol_mentioned_p (X) \
2838 && (GET_CODE (X) != SYMBOL_REF \
2839 || ! CONSTANT_POOL_ADDRESS_P (X) \
2840 || ! nonpic_symbol_mentioned_p (get_pool_constant (X)))) \
2841 || (TARGET_SHMEDIA && GET_CODE (X) == LABEL_REF))
2843 #define SYMBOLIC_CONST_P(X) \
2844 ((GET_CODE (X) == SYMBOL_REF || GET_CODE (X) == LABEL_REF) \
2845 && nonpic_symbol_mentioned_p (X))
2847 /* Compute extra cost of moving data between one register class
2848 and another. */
2850 /* If SECONDARY*_RELOAD_CLASS says something about the src/dst pair, regclass
2851 uses this information. Hence, the general register <-> floating point
2852 register information here is not used for SFmode. */
2854 #define REGCLASS_HAS_GENERAL_REG(CLASS) \
2855 ((CLASS) == GENERAL_REGS || (CLASS) == R0_REGS \
2856 || (! TARGET_SHMEDIA && (CLASS) == SIBCALL_REGS))
2858 #define REGCLASS_HAS_FP_REG(CLASS) \
2859 ((CLASS) == FP0_REGS || (CLASS) == FP_REGS \
2860 || (CLASS) == DF_REGS || (CLASS) == DF_HI_REGS)
2862 #define REGISTER_MOVE_COST(MODE, SRCCLASS, DSTCLASS) \
2863 sh_register_move_cost ((MODE), (SRCCLASS), (DSTCLASS))
2865 /* ??? Perhaps make MEMORY_MOVE_COST depend on compiler option? This
2866 would be so that people with slow memory systems could generate
2867 different code that does fewer memory accesses. */
2869 /* A C expression for the cost of a branch instruction. A value of 1
2870 is the default; other values are interpreted relative to that.
2871 The SH1 does not have delay slots, hence we get a pipeline stall
2872 at every branch. The SH4 is superscalar, so the single delay slot
2873 is not sufficient to keep both pipelines filled. */
2874 #define BRANCH_COST (TARGET_SH5 ? 1 : ! TARGET_SH2 || TARGET_HARD_SH4 ? 2 : 1)
2876 /* Assembler output control. */
2878 /* A C string constant describing how to begin a comment in the target
2879 assembler language. The compiler assumes that the comment will end at
2880 the end of the line. */
2881 #define ASM_COMMENT_START "!"
2883 #define ASM_APP_ON ""
2884 #define ASM_APP_OFF ""
2885 #define FILE_ASM_OP "\t.file\n"
2886 #define SET_ASM_OP "\t.set\t"
2888 /* How to change between sections. */
2890 #define TEXT_SECTION_ASM_OP (TARGET_SHMEDIA32 ? "\t.section\t.text..SHmedia32,\"ax\"" : "\t.text")
2891 #define DATA_SECTION_ASM_OP "\t.data"
2893 #if defined CRT_BEGIN || defined CRT_END
2894 /* Arrange for TEXT_SECTION_ASM_OP to be a compile-time constant. */
2895 # undef TEXT_SECTION_ASM_OP
2896 # if __SHMEDIA__ == 1 && __SH5__ == 32
2897 # define TEXT_SECTION_ASM_OP "\t.section\t.text..SHmedia32,\"ax\""
2898 # else
2899 # define TEXT_SECTION_ASM_OP "\t.text"
2900 # endif
2901 #endif
2904 /* If defined, a C expression whose value is a string containing the
2905 assembler operation to identify the following data as
2906 uninitialized global data. If not defined, and neither
2907 `ASM_OUTPUT_BSS' nor `ASM_OUTPUT_ALIGNED_BSS' are defined,
2908 uninitialized global data will be output in the data section if
2909 `-fno-common' is passed, otherwise `ASM_OUTPUT_COMMON' will be
2910 used. */
2911 #ifndef BSS_SECTION_ASM_OP
2912 #define BSS_SECTION_ASM_OP "\t.section\t.bss"
2913 #endif
2915 /* Like `ASM_OUTPUT_BSS' except takes the required alignment as a
2916 separate, explicit argument. If you define this macro, it is used
2917 in place of `ASM_OUTPUT_BSS', and gives you more flexibility in
2918 handling the required alignment of the variable. The alignment is
2919 specified as the number of bits.
2921 Try to use function `asm_output_aligned_bss' defined in file
2922 `varasm.c' when defining this macro. */
2923 #ifndef ASM_OUTPUT_ALIGNED_BSS
2924 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
2925 asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
2926 #endif
2928 /* Define this so that jump tables go in same section as the current function,
2929 which could be text or it could be a user defined section. */
2930 #define JUMP_TABLES_IN_TEXT_SECTION 1
2932 #undef DO_GLOBAL_CTORS_BODY
2933 #define DO_GLOBAL_CTORS_BODY \
2935 typedef (*pfunc)(); \
2936 extern pfunc __ctors[]; \
2937 extern pfunc __ctors_end[]; \
2938 pfunc *p; \
2939 for (p = __ctors_end; p > __ctors; ) \
2941 (*--p)(); \
2945 #undef DO_GLOBAL_DTORS_BODY
2946 #define DO_GLOBAL_DTORS_BODY \
2948 typedef (*pfunc)(); \
2949 extern pfunc __dtors[]; \
2950 extern pfunc __dtors_end[]; \
2951 pfunc *p; \
2952 for (p = __dtors; p < __dtors_end; p++) \
2954 (*p)(); \
2958 #define ASM_OUTPUT_REG_PUSH(file, v) \
2960 if (TARGET_SHMEDIA) \
2962 fprintf ((file), "\taddi.l\tr15,-8,r15\n"); \
2963 fprintf ((file), "\tst.q\tr15,0,r%d\n", (v)); \
2965 else \
2966 fprintf ((file), "\tmov.l\tr%d,@-r15\n", (v)); \
2969 #define ASM_OUTPUT_REG_POP(file, v) \
2971 if (TARGET_SHMEDIA) \
2973 fprintf ((file), "\tld.q\tr15,0,r%d\n", (v)); \
2974 fprintf ((file), "\taddi.l\tr15,8,r15\n"); \
2976 else \
2977 fprintf ((file), "\tmov.l\t@r15+,r%d\n", (v)); \
2980 /* DBX register number for a given compiler register number. */
2981 /* GDB has FPUL at 23 and FP0 at 25, so we must add one to all FP registers
2982 to match gdb. */
2983 /* svr4.h undefines this macro, yet we really want to use the same numbers
2984 for coff as for elf, so we go via another macro: SH_DBX_REGISTER_NUMBER. */
2985 /* expand_builtin_init_dwarf_reg_sizes uses this to test if a
2986 register exists, so we should return -1 for invalid register numbers. */
2987 #define DBX_REGISTER_NUMBER(REGNO) SH_DBX_REGISTER_NUMBER (REGNO)
2989 /* SHcompact PR_REG used to use the encoding 241, and SHcompact FP registers
2990 used to use the encodings 245..260, but that doesn't make sense:
2991 PR_REG and PR_MEDIA_REG are actually the same register, and likewise
2992 the FP registers stay the same when switching between compact and media
2993 mode. Hence, we also need to use the same dwarf frame columns.
2994 Likewise, we need to support unwind information for SHmedia registers
2995 even in compact code. */
2996 #define SH_DBX_REGISTER_NUMBER(REGNO) \
2997 (IN_RANGE ((REGNO), \
2998 (unsigned HOST_WIDE_INT) FIRST_GENERAL_REG, \
2999 FIRST_GENERAL_REG + (TARGET_SH5 ? 63U :15U)) \
3000 ? ((unsigned) (REGNO) - FIRST_GENERAL_REG) \
3001 : ((int) (REGNO) >= FIRST_FP_REG \
3002 && ((int) (REGNO) \
3003 <= (FIRST_FP_REG + \
3004 ((TARGET_SH5 && TARGET_FPU_ANY) ? 63 : TARGET_SH2E ? 15 : -1)))) \
3005 ? ((unsigned) (REGNO) - FIRST_FP_REG \
3006 + (TARGET_SH5 ? 77 : 25)) \
3007 : XD_REGISTER_P (REGNO) \
3008 ? ((unsigned) (REGNO) - FIRST_XD_REG + (TARGET_SH5 ? 289 : 87)) \
3009 : TARGET_REGISTER_P (REGNO) \
3010 ? ((unsigned) (REGNO) - FIRST_TARGET_REG + 68) \
3011 : (REGNO) == PR_REG \
3012 ? (TARGET_SH5 ? 18 : 17) \
3013 : (REGNO) == PR_MEDIA_REG \
3014 ? (TARGET_SH5 ? 18 : (unsigned) -1) \
3015 : (REGNO) == T_REG \
3016 ? (TARGET_SH5 ? 242 : 18) \
3017 : (REGNO) == GBR_REG \
3018 ? (TARGET_SH5 ? 238 : 19) \
3019 : (REGNO) == MACH_REG \
3020 ? (TARGET_SH5 ? 239 : 20) \
3021 : (REGNO) == MACL_REG \
3022 ? (TARGET_SH5 ? 240 : 21) \
3023 : (REGNO) == FPUL_REG \
3024 ? (TARGET_SH5 ? 244 : 23) \
3025 : (unsigned) -1)
3027 /* This is how to output a reference to a symbol_ref. On SH5,
3028 references to non-code symbols must be preceded by `datalabel'. */
3029 #define ASM_OUTPUT_SYMBOL_REF(FILE,SYM) \
3030 do \
3032 if (TARGET_SH5 && !SYMBOL_REF_FUNCTION_P (SYM)) \
3033 fputs ("datalabel ", (FILE)); \
3034 assemble_name ((FILE), XSTR ((SYM), 0)); \
3036 while (0)
3038 /* This is how to output an assembler line
3039 that says to advance the location counter
3040 to a multiple of 2**LOG bytes. */
3042 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
3043 if ((LOG) != 0) \
3044 fprintf ((FILE), "\t.align %d\n", (LOG))
3046 /* Globalizing directive for a label. */
3047 #define GLOBAL_ASM_OP "\t.global\t"
3049 /* #define ASM_OUTPUT_CASE_END(STREAM,NUM,TABLE) */
3051 /* Output a relative address table. */
3053 #define ASM_OUTPUT_ADDR_DIFF_ELT(STREAM,BODY,VALUE,REL) \
3054 switch (GET_MODE (BODY)) \
3056 case SImode: \
3057 if (TARGET_SH5) \
3059 asm_fprintf ((STREAM), "\t.long\t%LL%d-datalabel %LL%d\n", \
3060 (VALUE), (REL)); \
3061 break; \
3063 asm_fprintf ((STREAM), "\t.long\t%LL%d-%LL%d\n", (VALUE),(REL)); \
3064 break; \
3065 case HImode: \
3066 if (TARGET_SH5) \
3068 asm_fprintf ((STREAM), "\t.word\t%LL%d-datalabel %LL%d\n", \
3069 (VALUE), (REL)); \
3070 break; \
3072 asm_fprintf ((STREAM), "\t.word\t%LL%d-%LL%d\n", (VALUE),(REL)); \
3073 break; \
3074 case QImode: \
3075 if (TARGET_SH5) \
3077 asm_fprintf ((STREAM), "\t.byte\t%LL%d-datalabel %LL%d\n", \
3078 (VALUE), (REL)); \
3079 break; \
3081 asm_fprintf ((STREAM), "\t.byte\t%LL%d-%LL%d\n", (VALUE),(REL)); \
3082 break; \
3083 default: \
3084 break; \
3087 /* Output an absolute table element. */
3089 #define ASM_OUTPUT_ADDR_VEC_ELT(STREAM,VALUE) \
3090 if (! optimize || TARGET_BIGTABLE) \
3091 asm_fprintf ((STREAM), "\t.long\t%LL%d\n", (VALUE)); \
3092 else \
3093 asm_fprintf ((STREAM), "\t.word\t%LL%d\n", (VALUE));
3096 /* A C statement to be executed just prior to the output of
3097 assembler code for INSN, to modify the extracted operands so
3098 they will be output differently.
3100 Here the argument OPVEC is the vector containing the operands
3101 extracted from INSN, and NOPERANDS is the number of elements of
3102 the vector which contain meaningful data for this insn.
3103 The contents of this vector are what will be used to convert the insn
3104 template into assembler code, so you can change the assembler output
3105 by changing the contents of the vector. */
3107 #define FINAL_PRESCAN_INSN(INSN, OPVEC, NOPERANDS) \
3108 final_prescan_insn ((INSN), (OPVEC), (NOPERANDS))
3110 /* Print operand X (an rtx) in assembler syntax to file FILE.
3111 CODE is a letter or dot (`z' in `%z0') or 0 if no letter was specified.
3112 For `%' followed by punctuation, CODE is the punctuation and X is null. */
3114 #define PRINT_OPERAND(STREAM, X, CODE) print_operand ((STREAM), (X), (CODE))
3116 /* Print a memory address as an operand to reference that memory location. */
3118 #define PRINT_OPERAND_ADDRESS(STREAM,X) print_operand_address ((STREAM), (X))
3120 #define PRINT_OPERAND_PUNCT_VALID_P(CHAR) \
3121 ((CHAR) == '.' || (CHAR) == '#' || (CHAR) == '@' || (CHAR) == ',' \
3122 || (CHAR) == '$' || (CHAR) == '\'' || (CHAR) == '>')
3124 /* Recognize machine-specific patterns that may appear within
3125 constants. Used for PIC-specific UNSPECs. */
3126 #define OUTPUT_ADDR_CONST_EXTRA(STREAM, X, FAIL) \
3127 do \
3128 if (GET_CODE (X) == UNSPEC && XVECLEN ((X), 0) == 1) \
3130 switch (XINT ((X), 1)) \
3132 case UNSPEC_DATALABEL: \
3133 fputs ("datalabel ", (STREAM)); \
3134 output_addr_const ((STREAM), XVECEXP ((X), 0, 0)); \
3135 break; \
3136 case UNSPEC_PIC: \
3137 /* GLOBAL_OFFSET_TABLE or local symbols, no suffix. */ \
3138 output_addr_const ((STREAM), XVECEXP ((X), 0, 0)); \
3139 break; \
3140 case UNSPEC_GOT: \
3141 output_addr_const ((STREAM), XVECEXP ((X), 0, 0)); \
3142 fputs ("@GOT", (STREAM)); \
3143 break; \
3144 case UNSPEC_GOTOFF: \
3145 output_addr_const ((STREAM), XVECEXP ((X), 0, 0)); \
3146 fputs ("@GOTOFF", (STREAM)); \
3147 break; \
3148 case UNSPEC_PLT: \
3149 output_addr_const ((STREAM), XVECEXP ((X), 0, 0)); \
3150 fputs ("@PLT", (STREAM)); \
3151 break; \
3152 case UNSPEC_GOTPLT: \
3153 output_addr_const ((STREAM), XVECEXP ((X), 0, 0)); \
3154 fputs ("@GOTPLT", (STREAM)); \
3155 break; \
3156 case UNSPEC_DTPOFF: \
3157 output_addr_const ((STREAM), XVECEXP ((X), 0, 0)); \
3158 fputs ("@DTPOFF", (STREAM)); \
3159 break; \
3160 case UNSPEC_GOTTPOFF: \
3161 output_addr_const ((STREAM), XVECEXP ((X), 0, 0)); \
3162 fputs ("@GOTTPOFF", (STREAM)); \
3163 break; \
3164 case UNSPEC_TPOFF: \
3165 output_addr_const ((STREAM), XVECEXP ((X), 0, 0)); \
3166 fputs ("@TPOFF", (STREAM)); \
3167 break; \
3168 case UNSPEC_CALLER: \
3170 char name[32]; \
3171 /* LPCS stands for Label for PIC Call Site. */ \
3172 ASM_GENERATE_INTERNAL_LABEL \
3173 (name, "LPCS", INTVAL (XVECEXP ((X), 0, 0))); \
3174 assemble_name ((STREAM), name); \
3176 break; \
3177 default: \
3178 goto FAIL; \
3180 break; \
3182 else \
3183 goto FAIL; \
3184 while (0)
3187 extern struct rtx_def *sh_compare_op0;
3188 extern struct rtx_def *sh_compare_op1;
3190 /* Which processor to schedule for. The elements of the enumeration must
3191 match exactly the cpu attribute in the sh.md file. */
3193 enum processor_type {
3194 PROCESSOR_SH1,
3195 PROCESSOR_SH2,
3196 PROCESSOR_SH2E,
3197 PROCESSOR_SH2A,
3198 PROCESSOR_SH3,
3199 PROCESSOR_SH3E,
3200 PROCESSOR_SH4,
3201 PROCESSOR_SH4A,
3202 PROCESSOR_SH5
3205 #define sh_cpu_attr ((enum attr_cpu)sh_cpu)
3206 extern enum processor_type sh_cpu;
3208 extern int optimize; /* needed for gen_casesi. */
3210 enum mdep_reorg_phase_e
3212 SH_BEFORE_MDEP_REORG,
3213 SH_INSERT_USES_LABELS,
3214 SH_SHORTEN_BRANCHES0,
3215 SH_FIXUP_PCLOAD,
3216 SH_SHORTEN_BRANCHES1,
3217 SH_AFTER_MDEP_REORG
3220 extern enum mdep_reorg_phase_e mdep_reorg_phase;
3222 /* Handle Renesas compiler's pragmas. */
3223 #define REGISTER_TARGET_PRAGMAS() do { \
3224 c_register_pragma (0, "interrupt", sh_pr_interrupt); \
3225 c_register_pragma (0, "trapa", sh_pr_trapa); \
3226 c_register_pragma (0, "nosave_low_regs", sh_pr_nosave_low_regs); \
3227 } while (0)
3229 /* Set when processing a function with pragma interrupt turned on. */
3231 extern int pragma_interrupt;
3233 /* Set when processing a function with interrupt attribute. */
3235 extern int current_function_interrupt;
3237 /* Set to an RTX containing the address of the stack to switch to
3238 for interrupt functions. */
3239 extern struct rtx_def *sp_switch;
3242 /* Instructions with unfilled delay slots take up an
3243 extra two bytes for the nop in the delay slot.
3244 sh-dsp parallel processing insns are four bytes long. */
3246 #define ADJUST_INSN_LENGTH(X, LENGTH) \
3247 (LENGTH) += sh_insn_length_adjustment (X);
3249 /* Define this macro if it is advisable to hold scalars in registers
3250 in a wider mode than that declared by the program. In such cases,
3251 the value is constrained to be within the bounds of the declared
3252 type, but kept valid in the wider mode. The signedness of the
3253 extension may differ from that of the type.
3255 Leaving the unsignedp unchanged gives better code than always setting it
3256 to 0. This is despite the fact that we have only signed char and short
3257 load instructions. */
3258 #define PROMOTE_MODE(MODE, UNSIGNEDP, TYPE) \
3259 if (GET_MODE_CLASS (MODE) == MODE_INT \
3260 && GET_MODE_SIZE (MODE) < 4/* ! UNITS_PER_WORD */)\
3261 (UNSIGNEDP) = ((MODE) == SImode ? 0 : (UNSIGNEDP)), \
3262 (MODE) = (TARGET_SH1 ? SImode \
3263 : TARGET_SHMEDIA32 ? SImode : DImode);
3265 #define MAX_FIXED_MODE_SIZE (TARGET_SH5 ? 128 : 64)
3267 #define SIDI_OFF (TARGET_LITTLE_ENDIAN ? 0 : 4)
3269 /* ??? Define ACCUMULATE_OUTGOING_ARGS? This is more efficient than pushing
3270 and popping arguments. However, we do have push/pop instructions, and
3271 rather limited offsets (4 bits) in load/store instructions, so it isn't
3272 clear if this would give better code. If implemented, should check for
3273 compatibility problems. */
3275 #define SH_DYNAMIC_SHIFT_COST \
3276 (TARGET_HARD_SH4 ? 1 : TARGET_SH3 ? (TARGET_SMALLCODE ? 1 : 2) : 20)
3279 #define NUM_MODES_FOR_MODE_SWITCHING { FP_MODE_NONE }
3281 #define OPTIMIZE_MODE_SWITCHING(ENTITY) (TARGET_SH4 || TARGET_SH2A_DOUBLE)
3283 #define ACTUAL_NORMAL_MODE(ENTITY) \
3284 (TARGET_FPU_SINGLE ? FP_MODE_SINGLE : FP_MODE_DOUBLE)
3286 #define NORMAL_MODE(ENTITY) \
3287 (sh_cfun_interrupt_handler_p () \
3288 ? (TARGET_FMOVD ? FP_MODE_DOUBLE : FP_MODE_NONE) \
3289 : ACTUAL_NORMAL_MODE (ENTITY))
3291 #define MODE_ENTRY(ENTITY) NORMAL_MODE (ENTITY)
3293 #define MODE_EXIT(ENTITY) \
3294 (sh_cfun_attr_renesas_p () ? FP_MODE_NONE : NORMAL_MODE (ENTITY))
3296 #define EPILOGUE_USES(REGNO) ((TARGET_SH2E || TARGET_SH4) \
3297 && (REGNO) == FPSCR_REG)
3299 #define MODE_NEEDED(ENTITY, INSN) \
3300 (recog_memoized (INSN) >= 0 \
3301 ? get_attr_fp_mode (INSN) \
3302 : FP_MODE_NONE)
3304 #define MODE_AFTER(MODE, INSN) \
3305 (TARGET_HITACHI \
3306 && recog_memoized (INSN) >= 0 \
3307 && get_attr_fp_set (INSN) != FP_SET_NONE \
3308 ? (int) get_attr_fp_set (INSN) \
3309 : (MODE))
3311 #define MODE_PRIORITY_TO_MODE(ENTITY, N) \
3312 ((TARGET_FPU_SINGLE != 0) ^ (N) ? FP_MODE_SINGLE : FP_MODE_DOUBLE)
3314 #define EMIT_MODE_SET(ENTITY, MODE, HARD_REGS_LIVE) \
3315 fpscr_set_from_mem ((MODE), (HARD_REGS_LIVE))
3317 #define MD_CAN_REDIRECT_BRANCH(INSN, SEQ) \
3318 sh_can_redirect_branch ((INSN), (SEQ))
3320 #define DWARF_FRAME_RETURN_COLUMN \
3321 (TARGET_SH5 ? DWARF_FRAME_REGNUM (PR_MEDIA_REG) : DWARF_FRAME_REGNUM (PR_REG))
3323 #define EH_RETURN_DATA_REGNO(N) \
3324 ((N) < 4 ? (N) + (TARGET_SH5 ? 2U : 4U) : INVALID_REGNUM)
3326 #define EH_RETURN_STACKADJ_REGNO STATIC_CHAIN_REGNUM
3327 #define EH_RETURN_STACKADJ_RTX gen_rtx_REG (Pmode, EH_RETURN_STACKADJ_REGNO)
3329 /* We have to distinguish between code and data, so that we apply
3330 datalabel where and only where appropriate. Use sdataN for data. */
3331 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \
3332 ((flag_pic && (GLOBAL) ? DW_EH_PE_indirect : 0) \
3333 | (flag_pic ? DW_EH_PE_pcrel : DW_EH_PE_absptr) \
3334 | ((CODE) ? 0 : (TARGET_SHMEDIA64 ? DW_EH_PE_sdata8 : DW_EH_PE_sdata4)))
3336 /* Handle special EH pointer encodings. Absolute, pc-relative, and
3337 indirect are handled automatically. */
3338 #define ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX(FILE, ENCODING, SIZE, ADDR, DONE) \
3339 do { \
3340 if (((ENCODING) & 0xf) != DW_EH_PE_sdata4 \
3341 && ((ENCODING) & 0xf) != DW_EH_PE_sdata8) \
3343 gcc_assert (GET_CODE (ADDR) == SYMBOL_REF); \
3344 SYMBOL_REF_FLAGS (ADDR) |= SYMBOL_FLAG_FUNCTION; \
3345 if (0) goto DONE; \
3347 } while (0)
3349 #if (defined CRT_BEGIN || defined CRT_END) && ! __SHMEDIA__
3350 /* SH constant pool breaks the devices in crtstuff.c to control section
3351 in where code resides. We have to write it as asm code. */
3352 #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
3353 asm (SECTION_OP "\n\
3354 mov.l 1f,r1\n\
3355 mova 2f,r0\n\
3356 braf r1\n\
3357 lds r0,pr\n\
3358 0: .p2align 2\n\
3359 1: .long " USER_LABEL_PREFIX #FUNC " - 0b\n\
3360 2:\n" TEXT_SECTION_ASM_OP);
3361 #endif /* (defined CRT_BEGIN || defined CRT_END) && ! __SHMEDIA__ */
3363 #define ALLOCATE_INITIAL_VALUE(hard_reg) \
3364 (REGNO (hard_reg) == (TARGET_SHMEDIA ? PR_MEDIA_REG : PR_REG) \
3365 ? (current_function_is_leaf \
3366 && ! sh_pr_n_sets () \
3367 && ! (TARGET_SHCOMPACT \
3368 && ((current_function_args_info.call_cookie \
3369 & ~ CALL_COOKIE_RET_TRAMP (1)) \
3370 || current_function_has_nonlocal_label)) \
3371 ? (hard_reg) \
3372 : gen_rtx_MEM (Pmode, return_address_pointer_rtx)) \
3373 : NULL_RTX)
3375 #define SIMULTANEOUS_PREFETCHES 2
3377 /* FIXME: middle-end support for highpart optimizations is missing. */
3378 #define high_life_started reload_in_progress
3380 #endif /* ! GCC_SH_H */