* config/sh/sh.h (CLASS_MAX_NREGS): If TARGET_SHMEDIA, and the given
[official-gcc.git] / gcc / config / sh / sh.h
blobe5d0677ed60e787331680726234a57c6ffa126dd
1 /* Definitions of target machine for GNU compiler for Hitachi / SuperH SH.
2 Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
3 2003 Free Software Foundation, Inc.
4 Contributed by Steve Chamberlain (sac@cygnus.com).
5 Improved by Jim Wilson (wilson@cygnus.com).
7 This file is part of GNU CC.
9 GNU CC is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2, or (at your option)
12 any later version.
14 GNU CC is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with GNU CC; see the file COPYING. If not, write to
21 the Free Software Foundation, 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA. */
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_SH3: \
52 builtin_define ("__sh3__"); \
53 builtin_define ("__SH3__"); \
54 if (TARGET_HARD_SH4) \
55 builtin_define ("__SH4_NOFPU__"); \
56 break; \
57 case PROCESSOR_SH3E: \
58 builtin_define (TARGET_HARD_SH4 ? "__SH4_SINGLE_ONLY__" : "__SH3E__"); \
59 break; \
60 case PROCESSOR_SH4: \
61 builtin_define (TARGET_FPU_SINGLE ? "__SH4_SINGLE__" : "__SH4__"); \
62 break; \
63 case PROCESSOR_SH5: \
64 { \
65 builtin_define_with_value ("__SH5__", \
66 TARGET_SHMEDIA64 ? "64" : "32", 0); \
67 builtin_define_with_value ("__SHMEDIA__", \
68 TARGET_SHMEDIA ? "1" : "0", 0); \
69 if (! TARGET_FPU_DOUBLE) \
70 builtin_define ("__SH4_NOFPU__"); \
71 } \
72 } \
73 if (TARGET_HITACHI) \
74 builtin_define ("__HITACHI__"); \
75 builtin_define (TARGET_LITTLE_ENDIAN \
76 ? "__LITTLE_ENDIAN__" : "__BIG_ENDIAN__"); \
77 if (flag_pic) \
78 { \
79 builtin_define ("__pic__"); \
80 builtin_define ("__PIC__"); \
81 } \
82 TARGET_OBJFMT_CPP_BUILTINS (); \
83 } while (0)
85 /* We can not debug without a frame pointer. */
86 /* #define CAN_DEBUG_WITHOUT_FP */
88 #define CONDITIONAL_REGISTER_USAGE do \
89 { \
90 int regno; \
91 for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno ++) \
92 if (! VALID_REGISTER_P (regno)) \
93 fixed_regs[regno] = call_used_regs[regno] = 1; \
94 /* R8 and R9 are call-clobbered on SH5, but not on earlier SH ABIs. */ \
95 if (TARGET_SH5) \
96 call_used_regs[FIRST_GENERAL_REG + 8] \
97 = call_used_regs[FIRST_GENERAL_REG + 9] = 1; \
98 if (TARGET_SHMEDIA) \
99 { \
100 regno_reg_class[FIRST_GENERAL_REG] = GENERAL_REGS; \
101 CLEAR_HARD_REG_SET (reg_class_contents[FP0_REGS]); \
102 regno_reg_class[FIRST_FP_REG] = FP_REGS; \
104 if (flag_pic) \
105 fixed_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \
106 /* Hitachi saves and restores mac registers on call. */ \
107 if (TARGET_HITACHI && ! TARGET_NOMACSAVE) \
109 call_used_regs[MACH_REG] = 0; \
110 call_used_regs[MACL_REG] = 0; \
112 for (regno = FIRST_FP_REG + (TARGET_LITTLE_ENDIAN != 0); \
113 regno <= LAST_FP_REG; regno += 2) \
114 SET_HARD_REG_BIT (reg_class_contents[DF_HI_REGS], regno); \
115 if (TARGET_SHMEDIA) \
117 for (regno = FIRST_TARGET_REG; regno <= LAST_TARGET_REG; regno ++)\
118 if (! fixed_regs[regno] && call_used_regs[regno]) \
119 SET_HARD_REG_BIT (reg_class_contents[SIBCALL_REGS], regno); \
121 else \
122 for (regno = FIRST_GENERAL_REG; regno <= LAST_GENERAL_REG; regno++) \
123 if (! fixed_regs[regno] && call_used_regs[regno]) \
124 SET_HARD_REG_BIT (reg_class_contents[SIBCALL_REGS], regno); \
125 } while (0)
127 /* ??? Need to write documentation for all SH options and add it to the
128 invoke.texi file. */
130 /* Run-time compilation parameters selecting different hardware subsets. */
132 extern int target_flags;
133 #define ISIZE_BIT (1<<1)
134 #define DALIGN_BIT (1<<6)
135 #define SH1_BIT (1<<8)
136 #define SH2_BIT (1<<9)
137 #define SH3_BIT (1<<10)
138 #define SH_E_BIT (1<<11)
139 #define HARD_SH4_BIT (1<<5)
140 #define FPU_SINGLE_BIT (1<<7)
141 #define SH4_BIT (1<<12)
142 #define FMOVD_BIT (1<<4)
143 #define SH5_BIT (1<<0)
144 #define SPACE_BIT (1<<13)
145 #define BIGTABLE_BIT (1<<14)
146 #define RELAX_BIT (1<<15)
147 #define USERMODE_BIT (1<<16)
148 #define HITACHI_BIT (1<<22)
149 #define NOMACSAVE_BIT (1<<23)
150 #define PREFERGOT_BIT (1<<24)
151 #define PADSTRUCT_BIT (1<<28)
152 #define LITTLE_ENDIAN_BIT (1<<29)
153 #define IEEE_BIT (1<<30)
155 /* Nonzero if we should dump out instruction size info. */
156 #define TARGET_DUMPISIZE (target_flags & ISIZE_BIT)
158 /* Nonzero to align doubles on 64 bit boundaries. */
159 #define TARGET_ALIGN_DOUBLE (target_flags & DALIGN_BIT)
161 /* Nonzero if we should generate code using type 1 insns. */
162 #define TARGET_SH1 (target_flags & SH1_BIT)
164 /* Nonzero if we should generate code using type 2 insns. */
165 #define TARGET_SH2 (target_flags & SH2_BIT)
167 /* Nonzero if we should generate code using type 2E insns. */
168 #define TARGET_SH2E ((target_flags & SH_E_BIT) && TARGET_SH2)
170 /* Nonzero if we should generate code using type 3 insns. */
171 #define TARGET_SH3 (target_flags & SH3_BIT)
173 /* Nonzero if we should generate code using type 3E insns. */
174 #define TARGET_SH3E ((target_flags & SH_E_BIT) && TARGET_SH3)
176 /* Nonzero if the cache line size is 32. */
177 #define TARGET_CACHE32 (target_flags & HARD_SH4_BIT || TARGET_SH5)
179 /* Nonzero if we schedule for a superscalar implementation. */
180 #define TARGET_SUPERSCALAR (target_flags & HARD_SH4_BIT)
182 /* Nonzero if the target has separate instruction and data caches. */
183 #define TARGET_HARVARD (target_flags & HARD_SH4_BIT)
185 /* Nonzero if compiling for SH4 hardware (to be used for insn costs etc.) */
186 #define TARGET_HARD_SH4 (target_flags & HARD_SH4_BIT)
188 /* Nonzero if the default precision of th FPU is single */
189 #define TARGET_FPU_SINGLE (target_flags & FPU_SINGLE_BIT)
191 /* Nonzero if a double-precision FPU is available. */
192 #define TARGET_FPU_DOUBLE (target_flags & SH4_BIT)
194 /* Nonzero if an FPU is available. */
195 #define TARGET_FPU_ANY (TARGET_SH2E || TARGET_FPU_DOUBLE)
197 /* Nonzero if we should generate code using type 4 insns. */
198 #define TARGET_SH4 ((target_flags & SH4_BIT) && (target_flags & SH1_BIT))
200 /* Nonzero if we should generate code for a SH5 CPU (either ISA). */
201 #define TARGET_SH5 (target_flags & SH5_BIT)
203 /* Nonzero if we should generate code using the SHcompact instruction
204 set and 32-bit ABI. */
205 #define TARGET_SHCOMPACT (TARGET_SH5 && TARGET_SH1)
207 /* Nonzero if we should generate code using the SHmedia instruction
208 set and ABI. */
209 #define TARGET_SHMEDIA (TARGET_SH5 && ! TARGET_SH1)
211 /* Nonzero if we should generate code using the SHmedia ISA and 32-bit
212 ABI. */
213 #define TARGET_SHMEDIA32 (TARGET_SH5 && ! TARGET_SH1 \
214 && (target_flags & SH_E_BIT))
216 /* Nonzero if we should generate code using the SHmedia ISA and 64-bit
217 ABI. */
218 #define TARGET_SHMEDIA64 (TARGET_SH5 && ! TARGET_SH1 \
219 && ! (target_flags & SH_E_BIT))
221 /* Nonzero if we should generate code using SHmedia FPU instructions. */
222 #define TARGET_SHMEDIA_FPU (TARGET_SHMEDIA && TARGET_FPU_DOUBLE)
223 /* Nonzero if we should generate fmovd. */
224 #define TARGET_FMOVD (target_flags & FMOVD_BIT)
226 /* Nonzero if we respect NANs. */
227 #define TARGET_IEEE (target_flags & IEEE_BIT)
229 /* Nonzero if we should generate smaller code rather than faster code. */
230 #define TARGET_SMALLCODE (target_flags & SPACE_BIT)
232 /* Nonzero to use long jump tables. */
233 #define TARGET_BIGTABLE (target_flags & BIGTABLE_BIT)
235 /* Nonzero to generate pseudo-ops needed by the assembler and linker
236 to do function call relaxing. */
237 #define TARGET_RELAX (target_flags & RELAX_BIT)
239 /* Nonzero if using Hitachi's calling convention. */
240 #define TARGET_HITACHI (target_flags & HITACHI_BIT)
242 /* Nonzero if not saving macl/mach when using -mhitachi */
243 #define TARGET_NOMACSAVE (target_flags & NOMACSAVE_BIT)
245 /* Nonzero if padding structures to a multiple of 4 bytes. This is
246 incompatible with Hitachi's compiler, and gives unusual structure layouts
247 which confuse programmers.
248 ??? This option is not useful, but is retained in case there are people
249 who are still relying on it. It may be deleted in the future. */
250 #define TARGET_PADSTRUCT (target_flags & PADSTRUCT_BIT)
252 /* Nonzero if generating code for a little endian SH. */
253 #define TARGET_LITTLE_ENDIAN (target_flags & LITTLE_ENDIAN_BIT)
255 /* Nonzero if we should do everything in userland. */
256 #define TARGET_USERMODE (target_flags & USERMODE_BIT)
258 /* Nonzero if we should prefer @GOT calls when generating PIC. */
259 #define TARGET_PREFERGOT (target_flags & PREFERGOT_BIT)
261 #define SELECT_SH1 (SH1_BIT)
262 #define SELECT_SH2 (SH2_BIT | SELECT_SH1)
263 #define SELECT_SH2E (SH_E_BIT | SH2_BIT | SH1_BIT | FPU_SINGLE_BIT)
264 #define SELECT_SH3 (SH3_BIT | SELECT_SH2)
265 #define SELECT_SH3E (SH_E_BIT | FPU_SINGLE_BIT | SELECT_SH3)
266 #define SELECT_SH4_NOFPU (HARD_SH4_BIT | SELECT_SH3)
267 #define SELECT_SH4_SINGLE_ONLY (HARD_SH4_BIT | SELECT_SH3E)
268 #define SELECT_SH4 (SH4_BIT | SH_E_BIT | HARD_SH4_BIT | SELECT_SH3)
269 #define SELECT_SH4_SINGLE (FPU_SINGLE_BIT | SELECT_SH4)
270 #define SELECT_SH5_64 (SH5_BIT | SH4_BIT)
271 #define SELECT_SH5_64_NOFPU (SH5_BIT)
272 #define SELECT_SH5_32 (SH5_BIT | SH4_BIT | SH_E_BIT)
273 #define SELECT_SH5_32_NOFPU (SH5_BIT | SH_E_BIT)
274 #define SELECT_SH5_COMPACT (SH5_BIT | SH4_BIT | SELECT_SH3E)
275 #define SELECT_SH5_COMPACT_NOFPU (SH5_BIT | SELECT_SH3)
277 /* Reset all target-selection flags. */
278 #define TARGET_NONE -(SH1_BIT | SH2_BIT | SH3_BIT | SH_E_BIT | SH4_BIT \
279 | HARD_SH4_BIT | FPU_SINGLE_BIT | SH5_BIT)
281 #define TARGET_SWITCHES \
282 { {"1", TARGET_NONE, "" }, \
283 {"1", SELECT_SH1, "" }, \
284 {"2", TARGET_NONE, "" }, \
285 {"2", SELECT_SH2, "" }, \
286 {"2e", TARGET_NONE, "" }, \
287 {"2e", SELECT_SH2E, "" }, \
288 {"3", TARGET_NONE, "" }, \
289 {"3", SELECT_SH3, "" }, \
290 {"3e", TARGET_NONE, "" }, \
291 {"3e", SELECT_SH3E, "" }, \
292 {"4-single-only", TARGET_NONE, "" }, \
293 {"4-single-only", SELECT_SH4_SINGLE_ONLY, "" }, \
294 {"4-single", TARGET_NONE, "" }, \
295 {"4-single", SELECT_SH4_SINGLE, "" }, \
296 {"4-nofpu", TARGET_NONE, "" }, \
297 {"4-nofpu", SELECT_SH4_NOFPU, "" }, \
298 {"4", TARGET_NONE, "" }, \
299 {"4", SELECT_SH4, "" }, \
300 {"5-64media", TARGET_NONE, "" }, \
301 {"5-64media", SELECT_SH5_64, "Generate 64-bit SHmedia code" }, \
302 {"5-64media-nofpu", TARGET_NONE, "" }, \
303 {"5-64media-nofpu", SELECT_SH5_64_NOFPU, "Generate 64-bit FPU-less SHmedia code" }, \
304 {"5-32media", TARGET_NONE, "" }, \
305 {"5-32media", SELECT_SH5_32, "Generate 32-bit SHmedia code" }, \
306 {"5-32media-nofpu", TARGET_NONE, "" }, \
307 {"5-32media-nofpu", SELECT_SH5_32_NOFPU, "Generate 32-bit FPU-less SHmedia code" }, \
308 {"5-compact", TARGET_NONE, "" }, \
309 {"5-compact", SELECT_SH5_COMPACT, "Generate SHcompact code" }, \
310 {"5-compact-nofpu", TARGET_NONE, "" }, \
311 {"5-compact-nofpu", SELECT_SH5_COMPACT_NOFPU, "Generate FPU-less SHcompact code" }, \
312 {"b", -LITTLE_ENDIAN_BIT, "" }, \
313 {"bigtable", BIGTABLE_BIT, "" }, \
314 {"dalign", DALIGN_BIT, "" }, \
315 {"fmovd", FMOVD_BIT, "" }, \
316 {"hitachi", HITACHI_BIT, "" }, \
317 {"nomacsave", NOMACSAVE_BIT, "" }, \
318 {"ieee", IEEE_BIT, "" }, \
319 {"isize", ISIZE_BIT, "" }, \
320 {"l", LITTLE_ENDIAN_BIT, "" }, \
321 {"no-ieee", -IEEE_BIT, "" }, \
322 {"padstruct", PADSTRUCT_BIT, "" }, \
323 {"prefergot", PREFERGOT_BIT, "" }, \
324 {"relax", RELAX_BIT, "" }, \
325 {"space", SPACE_BIT, "" }, \
326 {"usermode", USERMODE_BIT, "" }, \
327 SUBTARGET_SWITCHES \
328 {"", TARGET_DEFAULT, "" } \
331 /* This are meant to be redefined in the host dependent files */
332 #define SUBTARGET_SWITCHES
334 /* This defaults us to big-endian. */
335 #ifndef TARGET_ENDIAN_DEFAULT
336 #define TARGET_ENDIAN_DEFAULT 0
337 #endif
339 #ifndef TARGET_CPU_DEFAULT
340 #define TARGET_CPU_DEFAULT SELECT_SH1
341 #endif
343 #define TARGET_DEFAULT (TARGET_CPU_DEFAULT|TARGET_ENDIAN_DEFAULT)
345 #define CPP_SPEC " %(subtarget_cpp_spec) "
347 #ifndef SUBTARGET_CPP_SPEC
348 #define SUBTARGET_CPP_SPEC ""
349 #endif
351 #ifndef SUBTARGET_EXTRA_SPECS
352 #define SUBTARGET_EXTRA_SPECS
353 #endif
355 #define EXTRA_SPECS \
356 { "subtarget_cpp_spec", SUBTARGET_CPP_SPEC }, \
357 { "link_emul_prefix", LINK_EMUL_PREFIX }, \
358 { "link_default_cpu_emul", LINK_DEFAULT_CPU_EMUL }, \
359 { "subtarget_link_emul_suffix", SUBTARGET_LINK_EMUL_SUFFIX }, \
360 { "subtarget_link_spec", SUBTARGET_LINK_SPEC }, \
361 { "subtarget_asm_endian_spec", SUBTARGET_ASM_ENDIAN_SPEC }, \
362 SUBTARGET_EXTRA_SPECS
364 #define ASM_SPEC "%(subtarget_asm_endian_spec) %{mrelax:-relax}"
366 #ifndef SUBTARGET_ASM_ENDIAN_SPEC
367 #if TARGET_ENDIAN_DEFAULT == LITTLE_ENDIAN_BIT
368 #define SUBTARGET_ASM_ENDIAN_SPEC "%{mb:-big} %{!mb:-little}"
369 #else
370 #define SUBTARGET_ASM_ENDIAN_SPEC "%{ml:-little} %{!ml:-big}"
371 #endif
372 #endif
374 #define LINK_EMUL_PREFIX "sh%{ml:l}"
376 #if TARGET_CPU_DEFAULT & SH5_BIT
377 #if TARGET_CPU_DEFAULT & SH_E_BIT
378 #define LINK_DEFAULT_CPU_EMUL "32"
379 #else
380 #define LINK_DEFAULT_CPU_EMUL "64"
381 #endif /* SH_E_BIT */
382 #else
383 #define LINK_DEFAULT_CPU_EMUL ""
384 #endif /* SH5_BIT */
386 #define SUBTARGET_LINK_EMUL_SUFFIX ""
387 #define SUBTARGET_LINK_SPEC ""
389 /* svr4.h redefines LINK_SPEC inappropriately, so go via SH_LINK_SPEC,
390 so that we can undo the damage without code replication. */
391 #define LINK_SPEC SH_LINK_SPEC
393 #define SH_LINK_SPEC "\
394 -m %(link_emul_prefix)\
395 %{m5-compact*|m5-32media*:32}\
396 %{m5-64media*:64}\
397 %{!m1:%{!m2:%{!m3*:%{!m4*:%{!m5*:%(link_default_cpu_emul)}}}}}\
398 %(subtarget_link_emul_suffix) \
399 %{mrelax:-relax} %(subtarget_link_spec)"
401 #define OPTIMIZATION_OPTIONS(LEVEL,SIZE) \
402 do { \
403 if (LEVEL) \
404 flag_omit_frame_pointer = -1; \
405 if (SIZE) \
406 target_flags |= SPACE_BIT; \
407 } while (0)
409 #define ASSEMBLER_DIALECT assembler_dialect
411 extern int assembler_dialect;
413 #define OVERRIDE_OPTIONS \
414 do { \
415 int regno; \
417 sh_cpu = CPU_SH1; \
418 assembler_dialect = 0; \
419 if (TARGET_SH2) \
420 sh_cpu = CPU_SH2; \
421 if (TARGET_SH2E) \
422 sh_cpu = CPU_SH2E; \
423 if (TARGET_SH3) \
424 sh_cpu = CPU_SH3; \
425 if (TARGET_SH3E) \
426 sh_cpu = CPU_SH3E; \
427 if (TARGET_SH4) \
429 assembler_dialect = 1; \
430 sh_cpu = CPU_SH4; \
432 if (TARGET_SH5) \
434 sh_cpu = CPU_SH5; \
435 target_flags |= DALIGN_BIT; \
436 if (TARGET_FPU_ANY \
437 && ! (TARGET_SHCOMPACT && TARGET_LITTLE_ENDIAN)) \
438 target_flags |= FMOVD_BIT; \
439 if (TARGET_SHMEDIA) \
441 /* There are no delay slots on SHmedia. */ \
442 flag_delayed_branch = 0; \
443 /* Relaxation isn't yet supported for SHmedia */ \
444 target_flags &= ~RELAX_BIT; \
446 if (profile_flag || profile_arc_flag) \
448 warning ("Profiling is not supported on this target."); \
449 profile_flag = profile_arc_flag = 0; \
452 else \
454 /* Only the sh64-elf assembler fully supports .quad properly. */\
455 targetm.asm_out.aligned_op.di = NULL; \
456 targetm.asm_out.unaligned_op.di = NULL; \
458 if (TARGET_FMOVD) \
459 reg_class_from_letter['e'] = NO_REGS; \
461 for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++) \
462 if (! VALID_REGISTER_P (regno)) \
463 sh_register_names[regno][0] = '\0'; \
465 for (regno = 0; regno < ADDREGNAMES_SIZE; regno++) \
466 if (! VALID_REGISTER_P (ADDREGNAMES_REGNO (regno))) \
467 sh_additional_register_names[regno][0] = '\0'; \
469 if (flag_omit_frame_pointer < 0) \
471 /* The debugging information is sufficient, \
472 but gdb doesn't implement this yet */ \
473 if (0) \
474 flag_omit_frame_pointer \
475 = (PREFERRED_DEBUGGING_TYPE == DWARF_DEBUG \
476 || PREFERRED_DEBUGGING_TYPE == DWARF2_DEBUG); \
477 else \
478 flag_omit_frame_pointer = 0; \
481 if (flag_pic && ! TARGET_PREFERGOT) \
482 flag_no_function_cse = 1; \
484 if (SMALL_REGISTER_CLASSES) \
486 /* Never run scheduling before reload, since that can \
487 break global alloc, and generates slower code anyway due \
488 to the pressure on R0. */ \
489 flag_schedule_insns = 0; \
492 /* Allocation boundary (in *bytes*) for the code of a function. \
493 SH1: 32 bit alignment is faster, because instructions are always \
494 fetched as a pair from a longword boundary. \
495 SH2 .. SH5 : align to cache line start. */ \
496 if (align_functions == 0) \
497 align_functions \
498 = TARGET_SMALLCODE ? FUNCTION_BOUNDARY/8 : (1 << CACHE_LOG); \
499 } while (0)
501 /* Target machine storage layout. */
503 /* Define this if most significant bit is lowest numbered
504 in instructions that operate on numbered bit-fields. */
506 #define BITS_BIG_ENDIAN 0
508 /* Define this if most significant byte of a word is the lowest numbered. */
509 #define BYTES_BIG_ENDIAN (TARGET_LITTLE_ENDIAN == 0)
511 /* Define this if most significant word of a multiword number is the lowest
512 numbered. */
513 #define WORDS_BIG_ENDIAN (TARGET_LITTLE_ENDIAN == 0)
515 /* Define this to set the endianness to use in libgcc2.c, which can
516 not depend on target_flags. */
517 #if defined(__LITTLE_ENDIAN__)
518 #define LIBGCC2_WORDS_BIG_ENDIAN 0
519 #else
520 #define LIBGCC2_WORDS_BIG_ENDIAN 1
521 #endif
523 #define MAX_BITS_PER_WORD 64
525 #define MAX_LONG_TYPE_SIZE MAX_BITS_PER_WORD
527 /* Width in bits of an `int'. We want just 32-bits, even if words are
528 longer. */
529 #define INT_TYPE_SIZE 32
531 /* Width in bits of a `long'. */
532 #define LONG_TYPE_SIZE (TARGET_SHMEDIA64 ? 64 : 32)
534 /* Width in bits of a `long long'. */
535 #define LONG_LONG_TYPE_SIZE 64
537 /* Width in bits of a `long double'. */
538 #define LONG_DOUBLE_TYPE_SIZE 64
540 /* Width of a word, in units (bytes). */
541 #define UNITS_PER_WORD (TARGET_SHMEDIA ? 8 : 4)
542 #define MIN_UNITS_PER_WORD 4
544 /* Width in bits of a pointer.
545 See also the macro `Pmode' defined below. */
546 #define POINTER_SIZE (TARGET_SHMEDIA64 ? 64 : 32)
548 /* Allocation boundary (in *bits*) for storing arguments in argument list. */
549 #define PARM_BOUNDARY (TARGET_SH5 ? 64 : 32)
551 /* Boundary (in *bits*) on which stack pointer should be aligned. */
552 #define STACK_BOUNDARY BIGGEST_ALIGNMENT
554 /* The log (base 2) of the cache line size, in bytes. Processors prior to
555 SH2 have no actual cache, but they fetch code in chunks of 4 bytes.
556 The SH2/3 have 16 byte cache lines, and the SH4 has a 32 byte cache line */
557 #define CACHE_LOG (TARGET_CACHE32 ? 5 : TARGET_SH2 ? 4 : 2)
559 /* ABI given & required minimum allocation boundary (in *bits*) for the
560 code of a function. */
561 #define FUNCTION_BOUNDARY (16 << TARGET_SHMEDIA)
563 /* On SH5, the lowest bit is used to indicate SHmedia functions, so
564 the vbit must go into the delta field of
565 pointers-to-member-functions. */
566 #define TARGET_PTRMEMFUNC_VBIT_LOCATION \
567 (TARGET_SH5 ? ptrmemfunc_vbit_in_delta : ptrmemfunc_vbit_in_pfn)
569 /* Alignment of field after `int : 0' in a structure. */
570 #define EMPTY_FIELD_BOUNDARY 32
572 /* No data type wants to be aligned rounder than this. */
573 #define BIGGEST_ALIGNMENT (TARGET_ALIGN_DOUBLE ? 64 : 32)
575 /* The best alignment to use in cases where we have a choice. */
576 #define FASTEST_ALIGNMENT (TARGET_SH5 ? 64 : 32)
578 /* Make strings word-aligned so strcpy from constants will be faster. */
579 #define CONSTANT_ALIGNMENT(EXP, ALIGN) \
580 ((TREE_CODE (EXP) == STRING_CST \
581 && (ALIGN) < FASTEST_ALIGNMENT) \
582 ? FASTEST_ALIGNMENT : (ALIGN))
584 /* Make arrays of chars word-aligned for the same reasons. */
585 #define DATA_ALIGNMENT(TYPE, ALIGN) \
586 (TREE_CODE (TYPE) == ARRAY_TYPE \
587 && TYPE_MODE (TREE_TYPE (TYPE)) == QImode \
588 && (ALIGN) < FASTEST_ALIGNMENT ? FASTEST_ALIGNMENT : (ALIGN))
590 /* Number of bits which any structure or union's size must be a
591 multiple of. Each structure or union's size is rounded up to a
592 multiple of this. */
593 #define STRUCTURE_SIZE_BOUNDARY (TARGET_PADSTRUCT ? 32 : 8)
595 /* Set this nonzero if move instructions will actually fail to work
596 when given unaligned data. */
597 #define STRICT_ALIGNMENT 1
599 /* If LABEL_AFTER_BARRIER demands an alignment, return its base 2 logarithm. */
600 #define LABEL_ALIGN_AFTER_BARRIER(LABEL_AFTER_BARRIER) \
601 barrier_align (LABEL_AFTER_BARRIER)
603 #define LOOP_ALIGN(A_LABEL) \
604 ((! optimize || TARGET_HARVARD || TARGET_SMALLCODE) \
605 ? 0 : sh_loop_align (A_LABEL))
607 #define LABEL_ALIGN(A_LABEL) \
609 (PREV_INSN (A_LABEL) \
610 && GET_CODE (PREV_INSN (A_LABEL)) == INSN \
611 && GET_CODE (PATTERN (PREV_INSN (A_LABEL))) == UNSPEC_VOLATILE \
612 && XINT (PATTERN (PREV_INSN (A_LABEL)), 1) == UNSPECV_ALIGN) \
613 /* explicit alignment insn in constant tables. */ \
614 ? INTVAL (XVECEXP (PATTERN (PREV_INSN (A_LABEL)), 0, 0)) \
615 : 0)
617 /* Jump tables must be 32 bit aligned, no matter the size of the element. */
618 #define ADDR_VEC_ALIGN(ADDR_VEC) 2
620 /* The base two logarithm of the known minimum alignment of an insn length. */
621 #define INSN_LENGTH_ALIGNMENT(A_INSN) \
622 (GET_CODE (A_INSN) == INSN \
623 ? 1 << TARGET_SHMEDIA \
624 : GET_CODE (A_INSN) == JUMP_INSN || GET_CODE (A_INSN) == CALL_INSN \
625 ? 1 << TARGET_SHMEDIA \
626 : CACHE_LOG)
628 /* Standard register usage. */
630 /* Register allocation for the Hitachi calling convention:
632 r0 arg return
633 r1..r3 scratch
634 r4..r7 args in
635 r8..r13 call saved
636 r14 frame pointer/call saved
637 r15 stack pointer
638 ap arg pointer (doesn't really exist, always eliminated)
639 pr subroutine return address
640 t t bit
641 mach multiply/accumulate result, high part
642 macl multiply/accumulate result, low part.
643 fpul fp/int communication register
644 rap return address pointer register
645 fr0 fp arg return
646 fr1..fr3 scratch floating point registers
647 fr4..fr11 fp args in
648 fr12..fr15 call saved floating point registers */
650 #define MAX_REGISTER_NAME_LENGTH 5
651 extern char sh_register_names[][MAX_REGISTER_NAME_LENGTH + 1];
653 #define SH_REGISTER_NAMES_INITIALIZER \
655 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
656 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", \
657 "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", \
658 "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31", \
659 "r32", "r33", "r34", "r35", "r36", "r37", "r38", "r39", \
660 "r40", "r41", "r42", "r43", "r44", "r45", "r46", "r47", \
661 "r48", "r49", "r50", "r51", "r52", "r53", "r54", "r55", \
662 "r56", "r57", "r58", "r59", "r60", "r61", "r62", "r63", \
663 "fr0", "fr1", "fr2", "fr3", "fr4", "fr5", "fr6", "fr7", \
664 "fr8", "fr9", "fr10", "fr11", "fr12", "fr13", "fr14", "fr15", \
665 "fr16", "fr17", "fr18", "fr19", "fr20", "fr21", "fr22", "fr23", \
666 "fr24", "fr25", "fr26", "fr27", "fr28", "fr29", "fr30", "fr31", \
667 "fr32", "fr33", "fr34", "fr35", "fr36", "fr37", "fr38", "fr39", \
668 "fr40", "fr41", "fr42", "fr43", "fr44", "fr45", "fr46", "fr47", \
669 "fr48", "fr49", "fr50", "fr51", "fr52", "fr53", "fr54", "fr55", \
670 "fr56", "fr57", "fr58", "fr59", "fr60", "fr61", "fr62", "fr63", \
671 "tr0", "tr1", "tr2", "tr3", "tr4", "tr5", "tr6", "tr7", \
672 "xd0", "xd2", "xd4", "xd6", "xd8", "xd10", "xd12", "xd14", \
673 "gbr", "ap", "pr", "t", "mach", "macl", "fpul", "fpscr", \
674 "rap" \
677 #define DEBUG_REGISTER_NAMES SH_REGISTER_NAMES_INITIALIZER
679 #define REGNAMES_ARR_INDEX_1(index) \
680 (sh_register_names[index])
681 #define REGNAMES_ARR_INDEX_2(index) \
682 REGNAMES_ARR_INDEX_1 ((index)), REGNAMES_ARR_INDEX_1 ((index)+1)
683 #define REGNAMES_ARR_INDEX_4(index) \
684 REGNAMES_ARR_INDEX_2 ((index)), REGNAMES_ARR_INDEX_2 ((index)+2)
685 #define REGNAMES_ARR_INDEX_8(index) \
686 REGNAMES_ARR_INDEX_4 ((index)), REGNAMES_ARR_INDEX_4 ((index)+4)
687 #define REGNAMES_ARR_INDEX_16(index) \
688 REGNAMES_ARR_INDEX_8 ((index)), REGNAMES_ARR_INDEX_8 ((index)+8)
689 #define REGNAMES_ARR_INDEX_32(index) \
690 REGNAMES_ARR_INDEX_16 ((index)), REGNAMES_ARR_INDEX_16 ((index)+16)
691 #define REGNAMES_ARR_INDEX_64(index) \
692 REGNAMES_ARR_INDEX_32 ((index)), REGNAMES_ARR_INDEX_32 ((index)+32)
694 #define REGISTER_NAMES \
696 REGNAMES_ARR_INDEX_64 (0), \
697 REGNAMES_ARR_INDEX_64 (64), \
698 REGNAMES_ARR_INDEX_8 (128), \
699 REGNAMES_ARR_INDEX_8 (136), \
700 REGNAMES_ARR_INDEX_8 (144), \
701 REGNAMES_ARR_INDEX_1 (152) \
704 #define ADDREGNAMES_SIZE 32
705 #define MAX_ADDITIONAL_REGISTER_NAME_LENGTH 4
706 extern char sh_additional_register_names[ADDREGNAMES_SIZE] \
707 [MAX_ADDITIONAL_REGISTER_NAME_LENGTH + 1];
709 #define SH_ADDITIONAL_REGISTER_NAMES_INITIALIZER \
711 "dr0", "dr2", "dr4", "dr6", "dr8", "dr10", "dr12", "dr14", \
712 "dr16", "dr18", "dr20", "dr22", "dr24", "dr26", "dr28", "dr30", \
713 "dr32", "dr34", "dr36", "dr38", "dr40", "dr42", "dr44", "dr46", \
714 "dr48", "dr50", "dr52", "dr54", "dr56", "dr58", "dr60", "dr62" \
717 #define ADDREGNAMES_REGNO(index) \
718 ((index < 32) ? (FIRST_FP_REG + (index) * 2) \
719 : (-1))
721 #define ADDREGNAMES_ARR_INDEX_1(index) \
722 { (sh_additional_register_names[index]), ADDREGNAMES_REGNO (index) }
723 #define ADDREGNAMES_ARR_INDEX_2(index) \
724 ADDREGNAMES_ARR_INDEX_1 ((index)), ADDREGNAMES_ARR_INDEX_1 ((index)+1)
725 #define ADDREGNAMES_ARR_INDEX_4(index) \
726 ADDREGNAMES_ARR_INDEX_2 ((index)), ADDREGNAMES_ARR_INDEX_2 ((index)+2)
727 #define ADDREGNAMES_ARR_INDEX_8(index) \
728 ADDREGNAMES_ARR_INDEX_4 ((index)), ADDREGNAMES_ARR_INDEX_4 ((index)+4)
729 #define ADDREGNAMES_ARR_INDEX_16(index) \
730 ADDREGNAMES_ARR_INDEX_8 ((index)), ADDREGNAMES_ARR_INDEX_8 ((index)+8)
731 #define ADDREGNAMES_ARR_INDEX_32(index) \
732 ADDREGNAMES_ARR_INDEX_16 ((index)), ADDREGNAMES_ARR_INDEX_16 ((index)+16)
734 #define ADDITIONAL_REGISTER_NAMES \
736 ADDREGNAMES_ARR_INDEX_32 (0) \
739 /* Number of actual hardware registers.
740 The hardware registers are assigned numbers for the compiler
741 from 0 to just below FIRST_PSEUDO_REGISTER.
742 All registers that the compiler knows about must be given numbers,
743 even those that are not normally considered general registers. */
745 /* There are many other relevant definitions in sh.md's md_constants. */
747 #define FIRST_GENERAL_REG R0_REG
748 #define LAST_GENERAL_REG (FIRST_GENERAL_REG + (TARGET_SHMEDIA ? 63 : 15))
749 #define FIRST_FP_REG DR0_REG
750 #define LAST_FP_REG (FIRST_FP_REG + \
751 (TARGET_SHMEDIA_FPU ? 63 : TARGET_SH2E ? 15 : -1))
752 #define FIRST_XD_REG XD0_REG
753 #define LAST_XD_REG (FIRST_XD_REG + ((TARGET_SH4 && TARGET_FMOVD) ? 7 : -1))
754 #define FIRST_TARGET_REG TR0_REG
755 #define LAST_TARGET_REG (FIRST_TARGET_REG + (TARGET_SHMEDIA ? 7 : -1))
757 #define GENERAL_REGISTER_P(REGNO) \
758 IN_RANGE ((REGNO), FIRST_GENERAL_REG, LAST_GENERAL_REG)
760 #define GENERAL_OR_AP_REGISTER_P(REGNO) \
761 (GENERAL_REGISTER_P (REGNO) || ((REGNO) == AP_REG))
763 #define FP_REGISTER_P(REGNO) \
764 ((REGNO) >= FIRST_FP_REG && (REGNO) <= LAST_FP_REG)
766 #define XD_REGISTER_P(REGNO) \
767 ((REGNO) >= FIRST_XD_REG && (REGNO) <= LAST_XD_REG)
769 #define FP_OR_XD_REGISTER_P(REGNO) \
770 (FP_REGISTER_P (REGNO) || XD_REGISTER_P (REGNO))
772 #define FP_ANY_REGISTER_P(REGNO) \
773 (FP_REGISTER_P (REGNO) || XD_REGISTER_P (REGNO) || (REGNO) == FPUL_REG)
775 #define SPECIAL_REGISTER_P(REGNO) \
776 ((REGNO) == GBR_REG || (REGNO) == T_REG \
777 || (REGNO) == MACH_REG || (REGNO) == MACL_REG)
779 #define TARGET_REGISTER_P(REGNO) \
780 ((REGNO) >= FIRST_TARGET_REG && (REGNO) <= LAST_TARGET_REG)
782 #define SHMEDIA_REGISTER_P(REGNO) \
783 (GENERAL_REGISTER_P (REGNO) || FP_REGISTER_P (REGNO) \
784 || TARGET_REGISTER_P (REGNO))
786 /* This is to be used in CONDITIONAL_REGISTER_USAGE, to mark registers
787 that should be fixed. */
788 #define VALID_REGISTER_P(REGNO) \
789 (SHMEDIA_REGISTER_P (REGNO) || XD_REGISTER_P (REGNO) \
790 || (REGNO) == AP_REG || (REGNO) == RAP_REG \
791 || (TARGET_SH1 && (SPECIAL_REGISTER_P (REGNO) || (REGNO) == PR_REG)) \
792 || (TARGET_SH2E && (REGNO) == FPUL_REG))
794 /* The mode that should be generally used to store a register by
795 itself in the stack, or to load it back. */
796 #define REGISTER_NATURAL_MODE(REGNO) \
797 (FP_REGISTER_P (REGNO) ? SFmode \
798 : XD_REGISTER_P (REGNO) ? DFmode \
799 : TARGET_SHMEDIA && ! HARD_REGNO_CALL_PART_CLOBBERED ((REGNO), DImode) \
800 ? DImode \
801 : SImode)
803 #define FIRST_PSEUDO_REGISTER 153
805 /* 1 for registers that have pervasive standard uses
806 and are not available for the register allocator.
808 Mach register is fixed 'cause it's only 10 bits wide for SH1.
809 It is 32 bits wide for SH2. */
811 #define FIXED_REGISTERS \
813 /* Regular registers. */ \
814 0, 0, 0, 0, 0, 0, 0, 0, \
815 0, 0, 0, 0, 0, 0, 0, 1, \
816 /* r16 is reserved, r18 is the former pr. */ \
817 1, 0, 0, 0, 0, 0, 0, 0, \
818 /* r24 is reserved for the OS; r25, for the assembler or linker. */ \
819 /* r26 is a global variable data pointer; r27 is for constants. */ \
820 1, 1, 1, 1, 0, 0, 0, 0, \
821 0, 0, 0, 0, 0, 0, 0, 0, \
822 0, 0, 0, 0, 0, 0, 0, 0, \
823 0, 0, 0, 0, 0, 0, 0, 0, \
824 0, 0, 0, 0, 0, 0, 0, 1, \
825 /* FP registers. */ \
826 0, 0, 0, 0, 0, 0, 0, 0, \
827 0, 0, 0, 0, 0, 0, 0, 0, \
828 0, 0, 0, 0, 0, 0, 0, 0, \
829 0, 0, 0, 0, 0, 0, 0, 0, \
830 0, 0, 0, 0, 0, 0, 0, 0, \
831 0, 0, 0, 0, 0, 0, 0, 0, \
832 0, 0, 0, 0, 0, 0, 0, 0, \
833 0, 0, 0, 0, 0, 0, 0, 0, \
834 /* Branch target registers. */ \
835 0, 0, 0, 0, 0, 0, 0, 0, \
836 /* XD registers. */ \
837 0, 0, 0, 0, 0, 0, 0, 0, \
838 /*"gbr", "ap", "pr", "t", "mach", "macl", "fpul", "fpscr", */ \
839 1, 1, 1, 1, 1, 1, 0, 1, \
840 /*"rap" */ \
841 1, \
844 /* 1 for registers not available across function calls.
845 These must include the FIXED_REGISTERS and also any
846 registers that can be used without being saved.
847 The latter must include the registers where values are returned
848 and the register where structure-value addresses are passed.
849 Aside from that, you can include as many other registers as you like. */
851 #define CALL_USED_REGISTERS \
853 /* Regular registers. */ \
854 1, 1, 1, 1, 1, 1, 1, 1, \
855 /* R8 and R9 are call-clobbered on SH5, but not on earlier SH ABIs. \
856 Only the lower 32bits of R10-R14 are guaranteed to be preserved \
857 across SH5 function calls. */ \
858 0, 0, 0, 0, 0, 0, 0, 1, \
859 1, 1, 0, 1, 1, 1, 1, 1, \
860 1, 1, 1, 1, 0, 0, 0, 0, \
861 0, 0, 0, 0, 1, 1, 1, 1, \
862 1, 1, 1, 1, 0, 0, 0, 0, \
863 0, 0, 0, 0, 0, 0, 0, 0, \
864 0, 0, 0, 0, 1, 1, 1, 1, \
865 /* FP registers. */ \
866 1, 1, 1, 1, 1, 1, 1, 1, \
867 1, 1, 1, 1, 0, 0, 0, 0, \
868 1, 1, 1, 1, 1, 1, 1, 1, \
869 1, 1, 1, 1, 1, 1, 1, 1, \
870 1, 1, 1, 1, 0, 0, 0, 0, \
871 0, 0, 0, 0, 0, 0, 0, 0, \
872 0, 0, 0, 0, 0, 0, 0, 0, \
873 0, 0, 0, 0, 0, 0, 0, 0, \
874 /* Branch target registers. */ \
875 1, 1, 1, 1, 1, 0, 0, 0, \
876 /* XD registers. */ \
877 1, 1, 1, 1, 1, 1, 0, 0, \
878 /*"gbr", "ap", "pr", "t", "mach", "macl", "fpul", "fpscr", */ \
879 1, 1, 0, 1, 1, 1, 1, 1, \
880 /*"rap" */ \
881 1, \
884 /* Only the lower 32-bits of R10-R14 are guaranteed to be preserved
885 across SHcompact function calls. We can't tell whether a called
886 function is SHmedia or SHcompact, so we assume it may be when
887 compiling SHmedia code with the 32-bit ABI, since that's the only
888 ABI that can be linked with SHcompact code. */
889 #define HARD_REGNO_CALL_PART_CLOBBERED(REGNO,MODE) \
890 (TARGET_SHMEDIA32 \
891 && GET_MODE_SIZE (MODE) > 4 \
892 && (((REGNO) >= FIRST_GENERAL_REG + 10 \
893 && (REGNO) <= FIRST_GENERAL_REG + 14) \
894 || (REGNO) == PR_MEDIA_REG))
896 /* Return number of consecutive hard regs needed starting at reg REGNO
897 to hold something of mode MODE.
898 This is ordinarily the length in words of a value of mode MODE
899 but can be less for certain modes in special long registers.
901 On the SH all but the XD regs are UNITS_PER_WORD bits wide. */
903 #define HARD_REGNO_NREGS(REGNO, MODE) \
904 (XD_REGISTER_P (REGNO) \
905 ? (GET_MODE_SIZE (MODE) / (2 * UNITS_PER_WORD)) \
906 : (TARGET_SHMEDIA && FP_REGISTER_P (REGNO)) \
907 ? ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD/2 - 1) / (UNITS_PER_WORD/2)) \
908 : ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)) \
910 /* Value is 1 if hard register REGNO can hold a value of machine-mode MODE.
911 We can allow any mode in any general register. The special registers
912 only allow SImode. Don't allow any mode in the PR. */
914 /* We cannot hold DCmode values in the XD registers because alter_reg
915 handles subregs of them incorrectly. We could work around this by
916 spacing the XD registers like the DR registers, but this would require
917 additional memory in every compilation to hold larger register vectors.
918 We could hold SFmode / SCmode values in XD registers, but that
919 would require a tertiary reload when reloading from / to memory,
920 and a secondary reload to reload from / to general regs; that
921 seems to be a loosing proposition. */
922 /* We want to allow TImode FP regs so that when V4SFmode is loaded as TImode,
923 it won't be ferried through GP registers first. */
924 #define HARD_REGNO_MODE_OK(REGNO, MODE) \
925 (SPECIAL_REGISTER_P (REGNO) ? (MODE) == SImode \
926 : (REGNO) == FPUL_REG ? (MODE) == SImode || (MODE) == SFmode \
927 : FP_REGISTER_P (REGNO) && (MODE) == SFmode \
928 ? 1 \
929 : (MODE) == V2SFmode \
930 ? ((FP_REGISTER_P (REGNO) && ((REGNO) - FIRST_FP_REG) % 2 == 0) \
931 || GENERAL_REGISTER_P (REGNO)) \
932 : (MODE) == V4SFmode \
933 ? ((FP_REGISTER_P (REGNO) && ((REGNO) - FIRST_FP_REG) % 4 == 0) \
934 || (! TARGET_SHMEDIA && GENERAL_REGISTER_P (REGNO))) \
935 : (MODE) == V16SFmode \
936 ? (TARGET_SHMEDIA \
937 ? (FP_REGISTER_P (REGNO) && ((REGNO) - FIRST_FP_REG) % 16 == 0) \
938 : (REGNO) == FIRST_XD_REG) \
939 : FP_REGISTER_P (REGNO) \
940 ? ((MODE) == SFmode || (MODE) == SImode \
941 || ((TARGET_SH2E || TARGET_SHMEDIA) && (MODE) == SCmode) \
942 || (((TARGET_SH4 && (MODE) == DFmode) || (MODE) == DCmode \
943 || (TARGET_SHMEDIA && ((MODE) == DFmode || (MODE) == DImode \
944 || (MODE) == V2SFmode || (MODE) == TImode))) \
945 && (((REGNO) - FIRST_FP_REG) & 1) == 0)) \
946 : XD_REGISTER_P (REGNO) \
947 ? (MODE) == DFmode \
948 : TARGET_REGISTER_P (REGNO) \
949 ? ((MODE) == DImode || (MODE) == SImode) \
950 : (REGNO) == PR_REG ? 0 \
951 : (REGNO) == FPSCR_REG ? (MODE) == PSImode \
952 : 1)
954 /* Value is 1 if MODE is a supported vector mode. */
955 #define VECTOR_MODE_SUPPORTED_P(MODE) \
956 ((TARGET_FPU_ANY \
957 && ((MODE) == V2SFmode || (MODE) == V4SFmode || (MODE) == V16SFmode)) \
958 || (TARGET_SHMEDIA \
959 && ((MODE) == V8QImode || (MODE) == V2HImode || (MODE) == V4HImode \
960 || (MODE) == V2SImode)))
962 /* Value is 1 if it is a good idea to tie two pseudo registers
963 when one has mode MODE1 and one has mode MODE2.
964 If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2,
965 for any hard reg, then this must be 0 for correct output.
966 That's the case for xd registers: we don't hold SFmode values in
967 them, so we can't tie an SFmode pseudos with one in another
968 floating-point mode. */
970 #define MODES_TIEABLE_P(MODE1, MODE2) \
971 ((MODE1) == (MODE2) \
972 || (GET_MODE_CLASS (MODE1) == GET_MODE_CLASS (MODE2) \
973 && (TARGET_SHMEDIA ? ((GET_MODE_SIZE (MODE1) <= 4) \
974 && (GET_MODE_SIZE (MODE2) <= 4)) \
975 : ((MODE1) != SFmode && (MODE2) != SFmode))))
977 /* A C expression that is nonzero if hard register NEW_REG can be
978 considered for use as a rename register for OLD_REG register */
980 #define HARD_REGNO_RENAME_OK(OLD_REG, NEW_REG) \
981 sh_hard_regno_rename_ok (OLD_REG, NEW_REG)
983 /* Specify the registers used for certain standard purposes.
984 The values of these macros are register numbers. */
986 /* Define this if the program counter is overloaded on a register. */
987 /* #define PC_REGNUM 15*/
989 /* Register to use for pushing function arguments. */
990 #define STACK_POINTER_REGNUM SP_REG
992 /* Base register for access to local variables of the function. */
993 #define FRAME_POINTER_REGNUM FP_REG
995 /* Fake register that holds the address on the stack of the
996 current function's return address. */
997 #define RETURN_ADDRESS_POINTER_REGNUM RAP_REG
999 /* Register to hold the addressing base for position independent
1000 code access to data items. */
1001 #define PIC_OFFSET_TABLE_REGNUM (flag_pic ? PIC_REG : INVALID_REGNUM)
1003 #define GOT_SYMBOL_NAME "*_GLOBAL_OFFSET_TABLE_"
1005 /* Value should be nonzero if functions must have frame pointers.
1006 Zero means the frame pointer need not be set up (and parms may be accessed
1007 via the stack pointer) in functions that seem suitable. */
1009 #define FRAME_POINTER_REQUIRED 0
1011 /* Definitions for register eliminations.
1013 We have three registers that can be eliminated on the SH. First, the
1014 frame pointer register can often be eliminated in favor of the stack
1015 pointer register. Secondly, the argument pointer register can always be
1016 eliminated; it is replaced with either the stack or frame pointer.
1017 Third, there is the return address pointer, which can also be replaced
1018 with either the stack or the frame pointer. */
1020 /* This is an array of structures. Each structure initializes one pair
1021 of eliminable registers. The "from" register number is given first,
1022 followed by "to". Eliminations of the same "from" register are listed
1023 in order of preference. */
1025 /* If you add any registers here that are not actually hard registers,
1026 and that have any alternative of elimination that doesn't always
1027 apply, you need to amend calc_live_regs to exclude it, because
1028 reload spills all eliminable registers where it sees an
1029 can_eliminate == 0 entry, thus making them 'live' .
1030 If you add any hard registers that can be eliminated in different
1031 ways, you have to patch reload to spill them only when all alternatives
1032 of elimination fail. */
1034 #define ELIMINABLE_REGS \
1035 {{ FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
1036 { RETURN_ADDRESS_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
1037 { RETURN_ADDRESS_POINTER_REGNUM, FRAME_POINTER_REGNUM}, \
1038 { ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
1039 { ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM},}
1041 /* Given FROM and TO register numbers, say whether this elimination
1042 is allowed. */
1043 #define CAN_ELIMINATE(FROM, TO) \
1044 (!((FROM) == FRAME_POINTER_REGNUM && FRAME_POINTER_REQUIRED))
1046 /* Define the offset between two registers, one to be eliminated, and the other
1047 its replacement, at the start of a routine. */
1049 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
1050 OFFSET = initial_elimination_offset ((FROM), (TO))
1052 /* Base register for access to arguments of the function. */
1053 #define ARG_POINTER_REGNUM AP_REG
1055 /* Register in which the static-chain is passed to a function. */
1056 #define STATIC_CHAIN_REGNUM (TARGET_SH5 ? 1 : 3)
1058 /* The register in which a struct value address is passed. */
1060 #define STRUCT_VALUE_REGNUM 2
1062 /* If the structure value address is not passed in a register, define
1063 `STRUCT_VALUE' as an expression returning an RTX for the place
1064 where the address is passed. If it returns 0, the address is
1065 passed as an "invisible" first argument. */
1067 /* The Hitachi calling convention doesn't quite fit into this scheme since
1068 the address is passed like an invisible argument, but one that is always
1069 passed in memory. */
1070 #define STRUCT_VALUE \
1071 (TARGET_HITACHI ? 0 : gen_rtx_REG (Pmode, STRUCT_VALUE_REGNUM))
1073 #define RETURN_IN_MEMORY(TYPE) \
1074 (TARGET_SH5 \
1075 ? ((TYPE_MODE (TYPE) == BLKmode \
1076 ? (unsigned HOST_WIDE_INT) int_size_in_bytes (TYPE) \
1077 : GET_MODE_SIZE (TYPE_MODE (TYPE))) > 8) \
1078 : (TYPE_MODE (TYPE) == BLKmode \
1079 || TARGET_HITACHI && TREE_CODE (TYPE) == RECORD_TYPE))
1081 /* Don't default to pcc-struct-return, because we have already specified
1082 exactly how to return structures in the RETURN_IN_MEMORY macro. */
1084 #define DEFAULT_PCC_STRUCT_RETURN 0
1086 #define SHMEDIA_REGS_STACK_ADJUST() \
1087 (TARGET_SHCOMPACT && current_function_has_nonlocal_label \
1088 ? (8 * (/* r28-r35 */ 8 + /* r44-r59 */ 16 + /* tr5-tr7 */ 3) \
1089 + (TARGET_FPU_ANY ? 4 * (/* fr36 - fr63 */ 28) : 0)) \
1090 : 0)
1093 /* Define the classes of registers for register constraints in the
1094 machine description. Also define ranges of constants.
1096 One of the classes must always be named ALL_REGS and include all hard regs.
1097 If there is more than one class, another class must be named NO_REGS
1098 and contain no registers.
1100 The name GENERAL_REGS must be the name of a class (or an alias for
1101 another name such as ALL_REGS). This is the class of registers
1102 that is allowed by "g" or "r" in a register constraint.
1103 Also, registers outside this class are allocated only when
1104 instructions express preferences for them.
1106 The classes must be numbered in nondecreasing order; that is,
1107 a larger-numbered class must never be contained completely
1108 in a smaller-numbered class.
1110 For any two classes, it is very desirable that there be another
1111 class that represents their union. */
1113 /* The SH has two sorts of general registers, R0 and the rest. R0 can
1114 be used as the destination of some of the arithmetic ops. There are
1115 also some special purpose registers; the T bit register, the
1116 Procedure Return Register and the Multiply Accumulate Registers. */
1117 /* Place GENERAL_REGS after FPUL_REGS so that it will be preferred by
1118 reg_class_subunion. We don't want to have an actual union class
1119 of these, because it would only be used when both classes are calculated
1120 to give the same cost, but there is only one FPUL register.
1121 Besides, regclass fails to notice the different REGISTER_MOVE_COSTS
1122 applying to the actual instruction alternative considered. E.g., the
1123 y/r alternative of movsi_ie is considered to have no more cost that
1124 the r/r alternative, which is patently untrue. */
1126 enum reg_class
1128 NO_REGS,
1129 R0_REGS,
1130 PR_REGS,
1131 T_REGS,
1132 MAC_REGS,
1133 FPUL_REGS,
1134 SIBCALL_REGS,
1135 GENERAL_REGS,
1136 FP0_REGS,
1137 FP_REGS,
1138 DF_HI_REGS,
1139 DF_REGS,
1140 FPSCR_REGS,
1141 GENERAL_FP_REGS,
1142 TARGET_REGS,
1143 ALL_REGS,
1144 LIM_REG_CLASSES
1147 #define N_REG_CLASSES (int) LIM_REG_CLASSES
1149 /* Give names of register classes as strings for dump file. */
1150 #define REG_CLASS_NAMES \
1152 "NO_REGS", \
1153 "R0_REGS", \
1154 "PR_REGS", \
1155 "T_REGS", \
1156 "MAC_REGS", \
1157 "FPUL_REGS", \
1158 "SIBCALL_REGS", \
1159 "GENERAL_REGS", \
1160 "FP0_REGS", \
1161 "FP_REGS", \
1162 "DF_HI_REGS", \
1163 "DF_REGS", \
1164 "FPSCR_REGS", \
1165 "GENERAL_FP_REGS", \
1166 "TARGET_REGS", \
1167 "ALL_REGS", \
1170 /* Define which registers fit in which classes.
1171 This is an initializer for a vector of HARD_REG_SET
1172 of length N_REG_CLASSES. */
1174 #define REG_CLASS_CONTENTS \
1176 /* NO_REGS: */ \
1177 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 }, \
1178 /* R0_REGS: */ \
1179 { 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000 }, \
1180 /* PR_REGS: */ \
1181 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00040000 }, \
1182 /* T_REGS: */ \
1183 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00080000 }, \
1184 /* MAC_REGS: */ \
1185 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00300000 }, \
1186 /* FPUL_REGS: */ \
1187 { 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00400000 }, \
1188 /* SIBCALL_REGS: Initialized in CONDITIONAL_REGISTER_USAGE. */ \
1189 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 }, \
1190 /* GENERAL_REGS: */ \
1191 { 0xffffffff, 0xffffffff, 0x00000000, 0x00000000, 0x01020000 }, \
1192 /* FP0_REGS: */ \
1193 { 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000 }, \
1194 /* FP_REGS: */ \
1195 { 0x00000000, 0x00000000, 0xffffffff, 0xffffffff, 0x00000000 }, \
1196 /* DF_HI_REGS: Initialized in CONDITIONAL_REGISTER_USAGE. */ \
1197 { 0x00000000, 0x00000000, 0xffffffff, 0xffffffff, 0x0000ff00 }, \
1198 /* DF_REGS: */ \
1199 { 0x00000000, 0x00000000, 0xffffffff, 0xffffffff, 0x0000ff00 }, \
1200 /* FPSCR_REGS: */ \
1201 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00800000 }, \
1202 /* GENERAL_FP_REGS: */ \
1203 { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x0102ff00 }, \
1204 /* TARGET_REGS: */ \
1205 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000000ff }, \
1206 /* ALL_REGS: */ \
1207 { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x01ffffff }, \
1210 /* The same information, inverted:
1211 Return the class number of the smallest class containing
1212 reg number REGNO. This could be a conditional expression
1213 or could index an array. */
1215 extern int regno_reg_class[FIRST_PSEUDO_REGISTER];
1216 #define REGNO_REG_CLASS(REGNO) regno_reg_class[(REGNO)]
1218 /* When defined, the compiler allows registers explicitly used in the
1219 rtl to be used as spill registers but prevents the compiler from
1220 extending the lifetime of these registers. */
1222 #define SMALL_REGISTER_CLASSES (! TARGET_SHMEDIA)
1224 /* The order in which register should be allocated. */
1225 /* Sometimes FP0_REGS becomes the preferred class of a floating point pseudo,
1226 and GENERAL_FP_REGS the alternate class. Since FP0 is likely to be
1227 spilled or used otherwise, we better have the FP_REGS allocated first. */
1228 #define REG_ALLOC_ORDER \
1229 { 65, 66, 67, 68, 69, 70, 71, 64, \
1230 72, 73, 74, 75, 76, 77, 78, 79, \
1231 136,137,138,139,140,141,142,143, \
1232 80, 81, 82, 83, 84, 85, 86, 87, \
1233 88, 89, 90, 91, 92, 93, 94, 95, \
1234 96, 97, 98, 99,100,101,102,103, \
1235 104,105,106,107,108,109,110,111, \
1236 112,113,114,115,116,117,118,119, \
1237 120,121,122,123,124,125,126,127, \
1238 151, 1, 2, 3, 7, 6, 5, 4, \
1239 0, 8, 9, 10, 11, 12, 13, 14, \
1240 16, 17, 18, 19, 20, 21, 22, 23, \
1241 24, 25, 26, 27, 28, 29, 30, 31, \
1242 32, 33, 34, 35, 36, 37, 38, 39, \
1243 40, 41, 42, 43, 44, 45, 46, 47, \
1244 48, 49, 50, 51, 52, 53, 54, 55, \
1245 56, 57, 58, 59, 60, 61, 62, 63, \
1246 150, 15,145,146,147,144,148,149, \
1247 128,129,130,131,132,133,134,135, \
1248 152 }
1250 /* The class value for index registers, and the one for base regs. */
1251 #define INDEX_REG_CLASS (TARGET_SHMEDIA ? GENERAL_REGS : R0_REGS)
1252 #define BASE_REG_CLASS GENERAL_REGS
1254 /* Get reg_class from a letter such as appears in the machine
1255 description. */
1256 extern enum reg_class reg_class_from_letter[];
1258 #define REG_CLASS_FROM_LETTER(C) \
1259 ( ISLOWER (C) ? reg_class_from_letter[(C)-'a'] : NO_REGS )
1261 /* The letters I, J, K, L and M in a register constraint string
1262 can be used to stand for particular ranges of immediate operands.
1263 This macro defines what the ranges are.
1264 C is the letter, and VALUE is a constant value.
1265 Return 1 if VALUE is in the range specified by C.
1266 I: arithmetic operand -127..128, as used in add, sub, etc
1267 J: arithmetic operand -32768..32767, as used in SHmedia movi and shori
1268 K: shift operand 1,2,8 or 16
1269 L: logical operand 0..255, as used in and, or, etc.
1270 M: constant 1
1271 N: constant 0
1272 O: arithmetic operand -32..31, as used in SHmedia beqi, bnei and xori
1273 P: arithmetic operand -512..511, as used in SHmedia andi, ori
1276 #define CONST_OK_FOR_I(VALUE) (((HOST_WIDE_INT)(VALUE))>= -128 \
1277 && ((HOST_WIDE_INT)(VALUE)) <= 127)
1278 #define CONST_OK_FOR_J(VALUE) (((HOST_WIDE_INT)(VALUE)) >= -32768 \
1279 && ((HOST_WIDE_INT)(VALUE)) <= 32767)
1280 #define CONST_OK_FOR_K(VALUE) ((VALUE)==1||(VALUE)==2||(VALUE)==8||(VALUE)==16)
1281 #define CONST_OK_FOR_L(VALUE) (((HOST_WIDE_INT)(VALUE))>= 0 \
1282 && ((HOST_WIDE_INT)(VALUE)) <= 255)
1283 #define CONST_OK_FOR_M(VALUE) ((VALUE)==1)
1284 #define CONST_OK_FOR_N(VALUE) ((VALUE)==0)
1285 #define CONST_OK_FOR_O(VALUE) (((HOST_WIDE_INT)(VALUE)) >= -32 \
1286 && ((HOST_WIDE_INT)(VALUE)) <= 31)
1287 #define CONST_OK_FOR_P(VALUE) (((HOST_WIDE_INT)(VALUE)) >= -512 \
1288 && ((HOST_WIDE_INT)(VALUE)) <= 511)
1289 #define CONST_OK_FOR_LETTER_P(VALUE, C) \
1290 ((C) == 'I' ? CONST_OK_FOR_I (VALUE) \
1291 : (C) == 'J' ? CONST_OK_FOR_J (VALUE) \
1292 : (C) == 'K' ? CONST_OK_FOR_K (VALUE) \
1293 : (C) == 'L' ? CONST_OK_FOR_L (VALUE) \
1294 : (C) == 'M' ? CONST_OK_FOR_M (VALUE) \
1295 : (C) == 'N' ? CONST_OK_FOR_N (VALUE) \
1296 : (C) == 'O' ? CONST_OK_FOR_O (VALUE) \
1297 : (C) == 'P' ? CONST_OK_FOR_P (VALUE) \
1298 : 0)
1300 /* Similar, but for floating constants, and defining letters G and H.
1301 Here VALUE is the CONST_DOUBLE rtx itself. */
1303 #define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) \
1304 ((C) == 'G' ? (fp_zero_operand (VALUE) && fldi_ok ()) \
1305 : (C) == 'H' ? (fp_one_operand (VALUE) && fldi_ok ()) \
1306 : (C) == 'F')
1308 /* Given an rtx X being reloaded into a reg required to be
1309 in class CLASS, return the class of reg to actually use.
1310 In general this is just CLASS; but on some machines
1311 in some cases it is preferable to use a more restrictive class. */
1313 #define PREFERRED_RELOAD_CLASS(X, CLASS) \
1314 ((CLASS) == NO_REGS && TARGET_SHMEDIA \
1315 && (GET_CODE (X) == CONST_DOUBLE \
1316 || GET_CODE (X) == SYMBOL_REF) \
1317 ? GENERAL_REGS \
1318 : (CLASS)) \
1320 #define SECONDARY_OUTPUT_RELOAD_CLASS(CLASS,MODE,X) \
1321 ((((REGCLASS_HAS_FP_REG (CLASS) \
1322 && (GET_CODE (X) == REG \
1323 && (GENERAL_OR_AP_REGISTER_P (REGNO (X)) \
1324 || (FP_REGISTER_P (REGNO (X)) && (MODE) == SImode \
1325 && TARGET_FMOVD)))) \
1326 || (REGCLASS_HAS_GENERAL_REG (CLASS) \
1327 && GET_CODE (X) == REG \
1328 && FP_REGISTER_P (REGNO (X)))) \
1329 && ! TARGET_SHMEDIA \
1330 && ((MODE) == SFmode || (MODE) == SImode)) \
1331 ? FPUL_REGS \
1332 : (((CLASS) == FPUL_REGS \
1333 || (REGCLASS_HAS_FP_REG (CLASS) \
1334 && ! TARGET_SHMEDIA && MODE == SImode)) \
1335 && (GET_CODE (X) == MEM \
1336 || (GET_CODE (X) == REG \
1337 && (REGNO (X) >= FIRST_PSEUDO_REGISTER \
1338 || REGNO (X) == T_REG \
1339 || system_reg_operand (X, VOIDmode))))) \
1340 ? GENERAL_REGS \
1341 : ((CLASS) == TARGET_REGS \
1342 || (TARGET_SHMEDIA && (CLASS) == SIBCALL_REGS)) \
1343 ? ((target_operand ((X), (MODE)) \
1344 && ! target_reg_operand ((X), (MODE))) \
1345 ? NO_REGS : GENERAL_REGS) \
1346 : (((CLASS) == MAC_REGS || (CLASS) == PR_REGS) \
1347 && GET_CODE (X) == REG && ! GENERAL_REGISTER_P (REGNO (X)) \
1348 && (CLASS) != REGNO_REG_CLASS (REGNO (X))) \
1349 ? GENERAL_REGS \
1350 : ((CLASS) != GENERAL_REGS && GET_CODE (X) == REG \
1351 && TARGET_REGISTER_P (REGNO (X))) \
1352 ? GENERAL_REGS : NO_REGS)
1354 #define SECONDARY_INPUT_RELOAD_CLASS(CLASS,MODE,X) \
1355 ((REGCLASS_HAS_FP_REG (CLASS) \
1356 && ! TARGET_SHMEDIA \
1357 && immediate_operand ((X), (MODE)) \
1358 && ! ((fp_zero_operand (X) || fp_one_operand (X)) \
1359 && (MODE) == SFmode && fldi_ok ())) \
1360 ? R0_REGS \
1361 : (CLASS == FPUL_REGS \
1362 && ((GET_CODE (X) == REG \
1363 && (REGNO (X) == MACL_REG || REGNO (X) == MACH_REG \
1364 || REGNO (X) == T_REG)))) \
1365 ? GENERAL_REGS \
1366 : CLASS == FPUL_REGS && immediate_operand ((X), (MODE)) \
1367 ? (GET_CODE (X) == CONST_INT && CONST_OK_FOR_I (INTVAL (X)) \
1368 ? GENERAL_REGS \
1369 : R0_REGS) \
1370 : (CLASS == FPSCR_REGS \
1371 && ((GET_CODE (X) == REG && REGNO (X) >= FIRST_PSEUDO_REGISTER) \
1372 || (GET_CODE (X) == MEM && GET_CODE (XEXP ((X), 0)) == PLUS)))\
1373 ? GENERAL_REGS \
1374 : (REGCLASS_HAS_FP_REG (CLASS) \
1375 && TARGET_SHMEDIA \
1376 && immediate_operand ((X), (MODE)) \
1377 && (X) != CONST0_RTX (GET_MODE (X)) \
1378 && GET_MODE (X) != V4SFmode) \
1379 ? GENERAL_REGS \
1380 : SECONDARY_OUTPUT_RELOAD_CLASS((CLASS),(MODE),(X)))
1382 /* Return the maximum number of consecutive registers
1383 needed to represent mode MODE in a register of class CLASS.
1385 If TARGET_SHMEDIA, we need two FP registers per word.
1386 Otherwise we will need at most one register per word. */
1387 #define CLASS_MAX_NREGS(CLASS, MODE) \
1388 (TARGET_SHMEDIA \
1389 && TEST_HARD_REG_BIT (reg_class_contents[CLASS], FIRST_FP_REG) \
1390 ? (GET_MODE_SIZE (MODE) + UNITS_PER_WORD/2 - 1) / (UNITS_PER_WORD/2) \
1391 : (GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
1393 /* If defined, gives a class of registers that cannot be used as the
1394 operand of a SUBREG that changes the mode of the object illegally. */
1395 /* ??? We need to renumber the internal numbers for the frnn registers
1396 when in little endian in order to allow mode size changes. */
1398 #define CANNOT_CHANGE_MODE_CLASS(FROM, TO) \
1399 sh_cannot_change_mode_class (FROM, TO)
1401 /* Stack layout; function entry, exit and calling. */
1403 /* Define the number of registers that can hold parameters.
1404 These macros are used only in other macro definitions below. */
1406 #define NPARM_REGS(MODE) \
1407 (TARGET_FPU_ANY && (MODE) == SFmode \
1408 ? (TARGET_SH5 ? 12 : 8) \
1409 : TARGET_SH4 && (GET_MODE_CLASS (MODE) == MODE_FLOAT \
1410 || GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT) \
1411 ? (TARGET_SH5 ? 12 : 8) \
1412 : (TARGET_SH5 ? 8 : 4))
1414 #define FIRST_PARM_REG (FIRST_GENERAL_REG + (TARGET_SH5 ? 2 : 4))
1415 #define FIRST_RET_REG (FIRST_GENERAL_REG + (TARGET_SH5 ? 2 : 0))
1417 #define FIRST_FP_PARM_REG (FIRST_FP_REG + (TARGET_SH5 ? 0 : 4))
1418 #define FIRST_FP_RET_REG FIRST_FP_REG
1420 /* Define this if pushing a word on the stack
1421 makes the stack pointer a smaller address. */
1422 #define STACK_GROWS_DOWNWARD
1424 /* Define this macro if the addresses of local variable slots are at
1425 negative offsets from the frame pointer.
1427 The SH only has positive indexes, so grow the frame up. */
1428 /* #define FRAME_GROWS_DOWNWARD */
1430 /* Offset from the frame pointer to the first local variable slot to
1431 be allocated. */
1432 #define STARTING_FRAME_OFFSET 0
1434 /* If we generate an insn to push BYTES bytes,
1435 this says how many the stack pointer really advances by. */
1436 /* Don't define PUSH_ROUNDING, since the hardware doesn't do this.
1437 When PUSH_ROUNDING is not defined, PARM_BOUNDARY will cause gcc to
1438 do correct alignment. */
1439 #if 0
1440 #define PUSH_ROUNDING(NPUSHED) (((NPUSHED) + 3) & ~3)
1441 #endif
1443 /* Offset of first parameter from the argument pointer register value. */
1444 #define FIRST_PARM_OFFSET(FNDECL) 0
1446 /* Value is the number of byte of arguments automatically
1447 popped when returning from a subroutine call.
1448 FUNDECL is the declaration node of the function (as a tree),
1449 FUNTYPE is the data type of the function (as a tree),
1450 or for a library call it is an identifier node for the subroutine name.
1451 SIZE is the number of bytes of arguments passed on the stack.
1453 On the SH, the caller does not pop any of its arguments that were passed
1454 on the stack. */
1455 #define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE) 0
1457 /* Value is the number of bytes of arguments automatically popped when
1458 calling a subroutine.
1459 CUM is the accumulated argument list.
1461 On SHcompact, the call trampoline pops arguments off the stack. */
1462 #define CALL_POPS_ARGS(CUM) (TARGET_SHCOMPACT ? (CUM).stack_regs * 8 : 0)
1464 /* Nonzero if we do not know how to pass TYPE solely in registers.
1465 Values that come in registers with inconvenient padding are stored
1466 to memory at the function start. */
1468 #define MUST_PASS_IN_STACK(MODE,TYPE) \
1469 ((TYPE) != 0 \
1470 && (TREE_CODE (TYPE_SIZE (TYPE)) != INTEGER_CST \
1471 || TREE_ADDRESSABLE (TYPE)))
1472 /* Some subroutine macros specific to this machine. */
1474 #define BASE_RETURN_VALUE_REG(MODE) \
1475 ((TARGET_FPU_ANY && ((MODE) == SFmode)) \
1476 ? FIRST_FP_RET_REG \
1477 : TARGET_FPU_ANY && (MODE) == SCmode \
1478 ? FIRST_FP_RET_REG \
1479 : (TARGET_FPU_DOUBLE \
1480 && ((MODE) == DFmode || (MODE) == SFmode \
1481 || (MODE) == DCmode || (MODE) == SCmode )) \
1482 ? FIRST_FP_RET_REG \
1483 : FIRST_RET_REG)
1485 #define BASE_ARG_REG(MODE) \
1486 ((TARGET_SH2E && ((MODE) == SFmode)) \
1487 ? FIRST_FP_PARM_REG \
1488 : TARGET_SH4 && (GET_MODE_CLASS (MODE) == MODE_FLOAT \
1489 || GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT)\
1490 ? FIRST_FP_PARM_REG \
1491 : FIRST_PARM_REG)
1493 /* Define how to find the value returned by a function.
1494 VALTYPE is the data type of the value (as a tree).
1495 If the precise function being called is known, FUNC is its FUNCTION_DECL;
1496 otherwise, FUNC is 0.
1497 For the SH, this is like LIBCALL_VALUE, except that we must change the
1498 mode like PROMOTE_MODE does.
1499 ??? PROMOTE_MODE is ignored for non-scalar types. The set of types
1500 tested here has to be kept in sync with the one in explow.c:promote_mode. */
1502 #define FUNCTION_VALUE(VALTYPE, FUNC) \
1503 gen_rtx (REG, \
1504 ((GET_MODE_CLASS (TYPE_MODE (VALTYPE)) == MODE_INT \
1505 && GET_MODE_SIZE (TYPE_MODE (VALTYPE)) < UNITS_PER_WORD \
1506 && (TREE_CODE (VALTYPE) == INTEGER_TYPE \
1507 || TREE_CODE (VALTYPE) == ENUMERAL_TYPE \
1508 || TREE_CODE (VALTYPE) == BOOLEAN_TYPE \
1509 || TREE_CODE (VALTYPE) == CHAR_TYPE \
1510 || TREE_CODE (VALTYPE) == REAL_TYPE \
1511 || TREE_CODE (VALTYPE) == OFFSET_TYPE)) \
1512 ? (TARGET_SHMEDIA ? DImode : SImode) : TYPE_MODE (VALTYPE)), \
1513 BASE_RETURN_VALUE_REG (TYPE_MODE (VALTYPE)))
1515 /* Define how to find the value returned by a library function
1516 assuming the value has mode MODE. */
1517 #define LIBCALL_VALUE(MODE) \
1518 gen_rtx_REG ((MODE), BASE_RETURN_VALUE_REG (MODE));
1520 /* 1 if N is a possible register number for a function value. */
1521 #define FUNCTION_VALUE_REGNO_P(REGNO) \
1522 ((REGNO) == FIRST_RET_REG || (TARGET_SH2E && (REGNO) == FIRST_FP_RET_REG) \
1523 || (TARGET_SHMEDIA_FPU && (REGNO) == FIRST_FP_RET_REG))
1525 /* 1 if N is a possible register number for function argument passing. */
1526 #define FUNCTION_ARG_REGNO_P(REGNO) \
1527 (((REGNO) >= FIRST_PARM_REG && (REGNO) < (FIRST_PARM_REG \
1528 + NPARM_REGS (SImode))) \
1529 || (TARGET_FPU_ANY \
1530 && (REGNO) >= FIRST_FP_PARM_REG && (REGNO) < (FIRST_FP_PARM_REG \
1531 + NPARM_REGS (SFmode))))
1533 /* Define a data type for recording info about an argument list
1534 during the scan of that argument list. This data type should
1535 hold all necessary information about the function itself
1536 and about the args processed so far, enough to enable macros
1537 such as FUNCTION_ARG to determine where the next arg should go.
1539 On SH, this is a single integer, which is a number of words
1540 of arguments scanned so far (including the invisible argument,
1541 if any, which holds the structure-value-address).
1542 Thus NARGREGS or more means all following args should go on the stack. */
1544 enum sh_arg_class { SH_ARG_INT = 0, SH_ARG_FLOAT = 1 };
1545 struct sh_args {
1546 int arg_count[2];
1547 int force_mem;
1548 /* Nonzero if a prototype is available for the function. */
1549 int prototype_p;
1550 /* The number of an odd floating-point register, that should be used
1551 for the next argument of type float. */
1552 int free_single_fp_reg;
1553 /* Whether we're processing an outgoing function call. */
1554 int outgoing;
1555 /* The number of general-purpose registers that should have been
1556 used to pass partial arguments, that are passed totally on the
1557 stack. On SHcompact, a call trampoline will pop them off the
1558 stack before calling the actual function, and, if the called
1559 function is implemented in SHcompact mode, the incoming arguments
1560 decoder will push such arguments back onto the stack. For
1561 incoming arguments, STACK_REGS also takes into account other
1562 arguments passed by reference, that the decoder will also push
1563 onto the stack. */
1564 int stack_regs;
1565 /* The number of general-purpose registers that should have been
1566 used to pass arguments, if the arguments didn't have to be passed
1567 by reference. */
1568 int byref_regs;
1569 /* Set by SHCOMPACT_BYREF if the current argument is to be passed by
1570 reference. */
1571 int byref;
1573 /* call_cookie is a bitmask used by call expanders, as well as
1574 function prologue and epilogues, to allow SHcompact to comply
1575 with the SH5 32-bit ABI, that requires 64-bit registers to be
1576 used even though only the lower 32-bit half is visible in
1577 SHcompact mode. The strategy is to call SHmedia trampolines.
1579 The alternatives for each of the argument-passing registers are
1580 (a) leave it unchanged; (b) pop it off the stack; (c) load its
1581 contents from the address in it; (d) add 8 to it, storing the
1582 result in the next register, then (c); (e) copy it from some
1583 floating-point register,
1585 Regarding copies from floating-point registers, r2 may only be
1586 copied from dr0. r3 may be copied from dr0 or dr2. r4 maybe
1587 copied from dr0, dr2 or dr4. r5 maybe copied from dr0, dr2,
1588 dr4 or dr6. r6 may be copied from dr0, dr2, dr4, dr6 or dr8.
1589 r7 through to r9 may be copied from dr0, dr2, dr4, dr8, dr8 or
1590 dr10.
1592 The bit mask is structured as follows:
1594 - 1 bit to tell whether to set up a return trampoline.
1596 - 3 bits to count the number consecutive registers to pop off the
1597 stack.
1599 - 4 bits for each of r9, r8, r7 and r6.
1601 - 3 bits for each of r5, r4, r3 and r2.
1603 - 3 bits set to 0 (the most significant ones)
1605 3 2 1 0
1606 1098 7654 3210 9876 5432 1098 7654 3210
1607 FLPF LPFL PFLP FFLP FFLP FFLP FFLP SSST
1608 2223 3344 4555 6666 7777 8888 9999 SSS-
1610 - If F is set, the register must be copied from an FP register,
1611 whose number is encoded in the remaining bits.
1613 - Else, if L is set, the register must be loaded from the address
1614 contained in it. If the P bit is *not* set, the address of the
1615 following dword should be computed first, and stored in the
1616 following register.
1618 - Else, if P is set, the register alone should be popped off the
1619 stack.
1621 - After all this processing, the number of registers represented
1622 in SSS will be popped off the stack. This is an optimization
1623 for pushing/popping consecutive registers, typically used for
1624 varargs and large arguments partially passed in registers.
1626 - If T is set, a return trampoline will be set up for 64-bit
1627 return values to be split into 2 32-bit registers. */
1628 #define CALL_COOKIE_RET_TRAMP_SHIFT 0
1629 #define CALL_COOKIE_RET_TRAMP(VAL) ((VAL) << CALL_COOKIE_RET_TRAMP_SHIFT)
1630 #define CALL_COOKIE_STACKSEQ_SHIFT 1
1631 #define CALL_COOKIE_STACKSEQ(VAL) ((VAL) << CALL_COOKIE_STACKSEQ_SHIFT)
1632 #define CALL_COOKIE_STACKSEQ_GET(COOKIE) \
1633 (((COOKIE) >> CALL_COOKIE_STACKSEQ_SHIFT) & 7)
1634 #define CALL_COOKIE_INT_REG_SHIFT(REG) \
1635 (4 * (7 - (REG)) + (((REG) <= 2) ? ((REG) - 2) : 1) + 3)
1636 #define CALL_COOKIE_INT_REG(REG, VAL) \
1637 ((VAL) << CALL_COOKIE_INT_REG_SHIFT (REG))
1638 #define CALL_COOKIE_INT_REG_GET(COOKIE, REG) \
1639 (((COOKIE) >> CALL_COOKIE_INT_REG_SHIFT (REG)) & ((REG) < 4 ? 7 : 15))
1640 long call_cookie;
1643 #define CUMULATIVE_ARGS struct sh_args
1645 #define GET_SH_ARG_CLASS(MODE) \
1646 ((TARGET_FPU_ANY && (MODE) == SFmode) \
1647 ? SH_ARG_FLOAT \
1648 /* There's no mention of complex float types in the SH5 ABI, so we
1649 should presumably handle them as aggregate types. */ \
1650 : TARGET_SH5 && GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT \
1651 ? SH_ARG_INT \
1652 : TARGET_FPU_DOUBLE && (GET_MODE_CLASS (MODE) == MODE_FLOAT \
1653 || GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT) \
1654 ? SH_ARG_FLOAT : SH_ARG_INT)
1656 #define ROUND_ADVANCE(SIZE) \
1657 (((SIZE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
1659 /* Round a register number up to a proper boundary for an arg of mode
1660 MODE.
1662 The SH doesn't care about double alignment, so we only
1663 round doubles to even regs when asked to explicitly. */
1665 #define ROUND_REG(CUM, MODE) \
1666 (((TARGET_ALIGN_DOUBLE \
1667 || (TARGET_SH4 && ((MODE) == DFmode || (MODE) == DCmode) \
1668 && (CUM).arg_count[(int) SH_ARG_FLOAT] < NPARM_REGS (MODE)))\
1669 && GET_MODE_UNIT_SIZE ((MODE)) > UNITS_PER_WORD) \
1670 ? ((CUM).arg_count[(int) GET_SH_ARG_CLASS (MODE)] \
1671 + ((CUM).arg_count[(int) GET_SH_ARG_CLASS (MODE)] & 1)) \
1672 : (CUM).arg_count[(int) GET_SH_ARG_CLASS (MODE)])
1674 /* Initialize a variable CUM of type CUMULATIVE_ARGS
1675 for a call to a function whose data type is FNTYPE.
1676 For a library call, FNTYPE is 0.
1678 On SH, the offset always starts at 0: the first parm reg is always
1679 the same reg for a given argument class.
1681 For TARGET_HITACHI, the structure value pointer is passed in memory. */
1683 #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, INDIRECT) \
1684 do { \
1685 (CUM).arg_count[(int) SH_ARG_INT] = 0; \
1686 (CUM).arg_count[(int) SH_ARG_FLOAT] = 0; \
1687 (CUM).force_mem \
1688 = (TARGET_HITACHI && FNTYPE \
1689 && aggregate_value_p (TREE_TYPE (FNTYPE))); \
1690 (CUM).prototype_p = (FNTYPE) && TYPE_ARG_TYPES (FNTYPE); \
1691 (CUM).arg_count[(int) SH_ARG_INT] \
1692 = (TARGET_SH5 && (FNTYPE) \
1693 && aggregate_value_p (TREE_TYPE (FNTYPE))); \
1694 (CUM).free_single_fp_reg = 0; \
1695 (CUM).outgoing = 1; \
1696 (CUM).stack_regs = 0; \
1697 (CUM).byref_regs = 0; \
1698 (CUM).byref = 0; \
1699 (CUM).call_cookie \
1700 = (CALL_COOKIE_RET_TRAMP \
1701 (TARGET_SHCOMPACT && (FNTYPE) \
1702 && (CUM).arg_count[(int) SH_ARG_INT] == 0 \
1703 && (TYPE_MODE (TREE_TYPE (FNTYPE)) == BLKmode \
1704 ? int_size_in_bytes (TREE_TYPE (FNTYPE)) \
1705 : GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (FNTYPE)))) > 4 \
1706 && (BASE_RETURN_VALUE_REG (TYPE_MODE (TREE_TYPE \
1707 (FNTYPE))) \
1708 == FIRST_RET_REG))); \
1709 } while (0)
1711 #define INIT_CUMULATIVE_LIBCALL_ARGS(CUM, MODE, LIBNAME) \
1712 do { \
1713 INIT_CUMULATIVE_ARGS ((CUM), NULL_TREE, (LIBNAME), 0); \
1714 (CUM).call_cookie \
1715 = (CALL_COOKIE_RET_TRAMP \
1716 (TARGET_SHCOMPACT && GET_MODE_SIZE (MODE) > 4 \
1717 && BASE_RETURN_VALUE_REG (MODE) == FIRST_RET_REG)); \
1718 } while (0)
1720 #define INIT_CUMULATIVE_INCOMING_ARGS(CUM, FNTYPE, LIBNAME) \
1721 do { \
1722 INIT_CUMULATIVE_ARGS ((CUM), (FNTYPE), (LIBNAME), 0); \
1723 (CUM).outgoing = 0; \
1724 } while (0)
1726 /* Update the data in CUM to advance over an argument
1727 of mode MODE and data type TYPE.
1728 (TYPE is null for libcalls where that information may not be
1729 available.) */
1731 #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \
1732 if ((CUM).force_mem) \
1733 (CUM).force_mem = 0; \
1734 else if (TARGET_SH5) \
1736 tree TYPE_ = ((CUM).byref && (TYPE) \
1737 ? TREE_TYPE (TYPE) \
1738 : (TYPE)); \
1739 enum machine_mode MODE_ = ((CUM).byref && (TYPE) \
1740 ? TYPE_MODE (TYPE_) \
1741 : (MODE)); \
1742 int dwords = (((CUM).byref \
1743 ? (CUM).byref \
1744 : (MODE_) == BLKmode \
1745 ? int_size_in_bytes (TYPE_) \
1746 : GET_MODE_SIZE (MODE_)) + 7) / 8; \
1747 int numregs = MIN (dwords, NPARM_REGS (SImode) \
1748 - (CUM).arg_count[(int) SH_ARG_INT]); \
1750 if (numregs) \
1752 (CUM).arg_count[(int) SH_ARG_INT] += numregs; \
1753 if (TARGET_SHCOMPACT \
1754 && SHCOMPACT_FORCE_ON_STACK (MODE_, TYPE_)) \
1756 (CUM).call_cookie \
1757 |= CALL_COOKIE_INT_REG (((CUM).arg_count[(int) SH_ARG_INT] \
1758 - numregs), 1); \
1759 /* N.B. We want this also for outgoing. */\
1760 (CUM).stack_regs += numregs; \
1762 else if ((CUM).byref) \
1764 if (! (CUM).outgoing) \
1765 (CUM).stack_regs += numregs; \
1766 (CUM).byref_regs += numregs; \
1767 (CUM).byref = 0; \
1768 do \
1769 (CUM).call_cookie \
1770 |= CALL_COOKIE_INT_REG (((CUM).arg_count[(int) SH_ARG_INT] \
1771 - numregs), 2); \
1772 while (--numregs); \
1773 (CUM).call_cookie \
1774 |= CALL_COOKIE_INT_REG (((CUM).arg_count[(int) SH_ARG_INT] \
1775 - 1), 1); \
1777 else if (dwords > numregs) \
1779 int pushregs = numregs; \
1781 if (TARGET_SHCOMPACT) \
1782 (CUM).stack_regs += numregs; \
1783 while (pushregs < NPARM_REGS (SImode) - 1 \
1784 && (CALL_COOKIE_INT_REG_GET \
1785 ((CUM).call_cookie, \
1786 NPARM_REGS (SImode) - pushregs) \
1787 == 1)) \
1789 (CUM).call_cookie \
1790 &= ~ CALL_COOKIE_INT_REG (NPARM_REGS (SImode) \
1791 - pushregs, 1); \
1792 pushregs++; \
1794 if (numregs == NPARM_REGS (SImode)) \
1795 (CUM).call_cookie \
1796 |= CALL_COOKIE_INT_REG (0, 1) \
1797 | CALL_COOKIE_STACKSEQ (numregs - 1); \
1798 else \
1799 (CUM).call_cookie \
1800 |= CALL_COOKIE_STACKSEQ (numregs); \
1803 if (GET_SH_ARG_CLASS (MODE_) == SH_ARG_FLOAT \
1804 && ((NAMED) || ! (CUM).prototype_p)) \
1806 if ((MODE_) == SFmode && (CUM).free_single_fp_reg) \
1807 (CUM).free_single_fp_reg = 0; \
1808 else if ((CUM).arg_count[(int) SH_ARG_FLOAT] \
1809 < NPARM_REGS (SFmode)) \
1811 int numfpregs \
1812 = MIN ((GET_MODE_SIZE (MODE_) + 7) / 8 * 2, \
1813 NPARM_REGS (SFmode) \
1814 - (CUM).arg_count[(int) SH_ARG_FLOAT]); \
1816 (CUM).arg_count[(int) SH_ARG_FLOAT] += numfpregs; \
1818 if (TARGET_SHCOMPACT && ! (CUM).prototype_p) \
1820 if ((CUM).outgoing && numregs > 0) \
1821 do \
1823 (CUM).call_cookie \
1824 |= (CALL_COOKIE_INT_REG \
1825 ((CUM).arg_count[(int) SH_ARG_INT] \
1826 - numregs + ((numfpregs - 2) / 2), \
1827 4 + ((CUM).arg_count[(int) SH_ARG_FLOAT] \
1828 - numfpregs) / 2)); \
1830 while (numfpregs -= 2); \
1832 else if ((MODE_) == SFmode && (NAMED) \
1833 && ((CUM).arg_count[(int) SH_ARG_FLOAT] \
1834 < NPARM_REGS (SFmode))) \
1835 (CUM).free_single_fp_reg \
1836 = FIRST_FP_PARM_REG - numfpregs \
1837 + (CUM).arg_count[(int) SH_ARG_FLOAT] + 1; \
1841 else if (! TARGET_SH4 || PASS_IN_REG_P ((CUM), (MODE), (TYPE))) \
1842 ((CUM).arg_count[(int) GET_SH_ARG_CLASS (MODE)] \
1843 = (ROUND_REG ((CUM), (MODE)) \
1844 + ((MODE) == BLKmode \
1845 ? ROUND_ADVANCE (int_size_in_bytes (TYPE)) \
1846 : ROUND_ADVANCE (GET_MODE_SIZE (MODE)))))
1848 /* Return boolean indicating arg of mode MODE will be passed in a reg.
1849 This macro is only used in this file. */
1851 #define PASS_IN_REG_P(CUM, MODE, TYPE) \
1852 (((TYPE) == 0 \
1853 || (! TREE_ADDRESSABLE ((tree)(TYPE)) \
1854 && (! TARGET_HITACHI || ! AGGREGATE_TYPE_P (TYPE)))) \
1855 && ! (CUM).force_mem \
1856 && (TARGET_SH2E \
1857 ? ((MODE) == BLKmode \
1858 ? (((CUM).arg_count[(int) SH_ARG_INT] * UNITS_PER_WORD \
1859 + int_size_in_bytes (TYPE)) \
1860 <= NPARM_REGS (SImode) * UNITS_PER_WORD) \
1861 : ((ROUND_REG((CUM), (MODE)) \
1862 + HARD_REGNO_NREGS (BASE_ARG_REG (MODE), (MODE))) \
1863 <= NPARM_REGS (MODE))) \
1864 : ROUND_REG ((CUM), (MODE)) < NPARM_REGS (MODE)))
1866 /* Define where to put the arguments to a function.
1867 Value is zero to push the argument on the stack,
1868 or a hard register in which to store the argument.
1870 MODE is the argument's machine mode.
1871 TYPE is the data type of the argument (as a tree).
1872 This is null for libcalls where that information may
1873 not be available.
1874 CUM is a variable of type CUMULATIVE_ARGS which gives info about
1875 the preceding args and about the function being called.
1876 NAMED is nonzero if this argument is a named parameter
1877 (otherwise it is an extra parameter matching an ellipsis).
1879 On SH the first args are normally in registers
1880 and the rest are pushed. Any arg that starts within the first
1881 NPARM_REGS words is at least partially passed in a register unless
1882 its data type forbids. */
1884 #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
1885 ((! TARGET_SH5 \
1886 && PASS_IN_REG_P ((CUM), (MODE), (TYPE)) \
1887 && ((NAMED) || !TARGET_HITACHI)) \
1888 ? gen_rtx_REG ((MODE), \
1889 ((BASE_ARG_REG (MODE) + ROUND_REG ((CUM), (MODE))) \
1890 ^ ((MODE) == SFmode && TARGET_SH4 \
1891 && TARGET_LITTLE_ENDIAN != 0))) \
1892 : TARGET_SH5 \
1893 ? ((MODE) == VOIDmode && TARGET_SHCOMPACT \
1894 ? GEN_INT ((CUM).call_cookie) \
1895 /* The following test assumes unnamed arguments are promoted to \
1896 DFmode. */ \
1897 : (MODE) == SFmode && (CUM).free_single_fp_reg \
1898 ? SH5_PROTOTYPED_FLOAT_ARG ((CUM), (MODE), (CUM).free_single_fp_reg) \
1899 : (GET_SH_ARG_CLASS (MODE) == SH_ARG_FLOAT \
1900 && ((NAMED) || ! (CUM).prototype_p) \
1901 && (CUM).arg_count[(int) SH_ARG_FLOAT] < NPARM_REGS (SFmode)) \
1902 ? ((! (CUM).prototype_p && TARGET_SHMEDIA) \
1903 ? SH5_PROTOTYPELESS_FLOAT_ARG ((CUM), (MODE)) \
1904 : SH5_PROTOTYPED_FLOAT_ARG ((CUM), (MODE), \
1905 FIRST_FP_PARM_REG \
1906 + (CUM).arg_count[(int) SH_ARG_FLOAT])) \
1907 : ((CUM).arg_count[(int) SH_ARG_INT] < NPARM_REGS (SImode) \
1908 && (! TARGET_SHCOMPACT \
1909 || (! SHCOMPACT_FORCE_ON_STACK ((MODE), (TYPE)) \
1910 && ! SH5_WOULD_BE_PARTIAL_NREGS ((CUM), (MODE), \
1911 (TYPE), (NAMED))))) \
1912 ? gen_rtx_REG ((MODE), (FIRST_PARM_REG \
1913 + (CUM).arg_count[(int) SH_ARG_INT])) \
1914 : 0) \
1915 : 0)
1917 /* Whether an argument must be passed by reference. On SHcompact, we
1918 pretend arguments wider than 32-bits that would have been passed in
1919 registers are passed by reference, so that an SHmedia trampoline
1920 loads them into the full 64-bits registers. */
1921 #define FUNCTION_ARG_PASS_BY_REFERENCE(CUM,MODE,TYPE,NAMED) \
1922 (MUST_PASS_IN_STACK ((MODE), (TYPE)) \
1923 || SHCOMPACT_BYREF ((CUM), (MODE), (TYPE), (NAMED)))
1925 #define SHCOMPACT_BYREF(CUM, MODE, TYPE, NAMED) \
1926 ((CUM).byref \
1927 = (TARGET_SHCOMPACT \
1928 && (CUM).arg_count[(int) SH_ARG_INT] < NPARM_REGS (SImode) \
1929 && (! (NAMED) || GET_SH_ARG_CLASS (MODE) == SH_ARG_INT \
1930 || (GET_SH_ARG_CLASS (MODE) == SH_ARG_FLOAT \
1931 && ((CUM).arg_count[(int) SH_ARG_FLOAT] \
1932 >= NPARM_REGS (SFmode)))) \
1933 && ((MODE) == BLKmode ? int_size_in_bytes (TYPE) \
1934 : GET_MODE_SIZE (MODE)) > 4 \
1935 && ! SHCOMPACT_FORCE_ON_STACK ((MODE), (TYPE)) \
1936 && ! SH5_WOULD_BE_PARTIAL_NREGS ((CUM), (MODE), \
1937 (TYPE), (NAMED))) \
1938 ? ((MODE) == BLKmode ? int_size_in_bytes (TYPE) \
1939 : GET_MODE_SIZE (MODE)) \
1940 : 0)
1942 /* If an argument of size 5, 6 or 7 bytes is to be passed in a 64-bit
1943 register in SHcompact mode, it must be padded in the most
1944 significant end. This means that passing it by reference wouldn't
1945 pad properly on a big-endian machine. In this particular case, we
1946 pass this argument on the stack, in a way that the call trampoline
1947 will load its value into the appropriate register. */
1948 #define SHCOMPACT_FORCE_ON_STACK(MODE,TYPE) \
1949 ((MODE) == BLKmode \
1950 && TARGET_SHCOMPACT \
1951 && ! TARGET_LITTLE_ENDIAN \
1952 && int_size_in_bytes (TYPE) > 4 \
1953 && int_size_in_bytes (TYPE) < 8)
1955 /* Minimum alignment for an argument to be passed by callee-copy
1956 reference. We need such arguments to be aligned to 8 byte
1957 boundaries, because they'll be loaded using quad loads. */
1958 #define SH_MIN_ALIGN_FOR_CALLEE_COPY (8 * BITS_PER_UNIT)
1960 #define FUNCTION_ARG_CALLEE_COPIES(CUM,MODE,TYPE,NAMED) \
1961 ((CUM).outgoing \
1962 && (((MODE) == BLKmode ? TYPE_ALIGN (TYPE) \
1963 : GET_MODE_ALIGNMENT (MODE)) \
1964 % SH_MIN_ALIGN_FOR_CALLEE_COPY == 0))
1966 /* The SH5 ABI requires floating-point arguments to be passed to
1967 functions without a prototype in both an FP register and a regular
1968 register or the stack. When passing the argument in both FP and
1969 general-purpose registers, list the FP register first. */
1970 #define SH5_PROTOTYPELESS_FLOAT_ARG(CUM,MODE) \
1971 (gen_rtx_PARALLEL \
1972 ((MODE), \
1973 gen_rtvec (2, \
1974 gen_rtx_EXPR_LIST \
1975 (VOIDmode, \
1976 ((CUM).arg_count[(int) SH_ARG_INT] < NPARM_REGS (SImode) \
1977 ? gen_rtx_REG ((MODE), FIRST_FP_PARM_REG \
1978 + (CUM).arg_count[(int) SH_ARG_FLOAT]) \
1979 : NULL_RTX), \
1980 const0_rtx), \
1981 gen_rtx_EXPR_LIST \
1982 (VOIDmode, \
1983 ((CUM).arg_count[(int) SH_ARG_INT] < NPARM_REGS (SImode) \
1984 ? gen_rtx_REG ((MODE), FIRST_PARM_REG \
1985 + (CUM).arg_count[(int) SH_ARG_INT]) \
1986 : gen_rtx_REG ((MODE), FIRST_FP_PARM_REG \
1987 + (CUM).arg_count[(int) SH_ARG_FLOAT])), \
1988 const0_rtx))))
1990 /* The SH5 ABI requires regular registers or stack slots to be
1991 reserved for floating-point arguments. Registers are taken care of
1992 in FUNCTION_ARG_ADVANCE, but stack slots must be reserved here.
1993 Unfortunately, there's no way to just reserve a stack slot, so
1994 we'll end up needlessly storing a copy of the argument in the
1995 stack. For incoming arguments, however, the PARALLEL will be
1996 optimized to the register-only form, and the value in the stack
1997 slot won't be used at all. */
1998 #define SH5_PROTOTYPED_FLOAT_ARG(CUM,MODE,REG) \
1999 ((CUM).arg_count[(int) SH_ARG_INT] < NPARM_REGS (SImode) \
2000 ? gen_rtx_REG ((MODE), (REG)) \
2001 : gen_rtx_PARALLEL ((MODE), \
2002 gen_rtvec (2, \
2003 gen_rtx_EXPR_LIST \
2004 (VOIDmode, NULL_RTX, \
2005 const0_rtx), \
2006 gen_rtx_EXPR_LIST \
2007 (VOIDmode, gen_rtx_REG ((MODE), \
2008 (REG)), \
2009 const0_rtx))))
2011 #define STRICT_ARGUMENT_NAMING TARGET_SH5
2013 #define PRETEND_OUTGOING_VARARGS_NAMED (! TARGET_HITACHI && ! TARGET_SH5)
2015 /* For an arg passed partly in registers and partly in memory,
2016 this is the number of registers used.
2017 For args passed entirely in registers or entirely in memory, zero.
2019 We sometimes split args. */
2021 #define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) \
2022 ((! TARGET_SH5 \
2023 && PASS_IN_REG_P ((CUM), (MODE), (TYPE)) \
2024 && ! TARGET_SH4 \
2025 && (ROUND_REG ((CUM), (MODE)) \
2026 + ((MODE) != BLKmode \
2027 ? ROUND_ADVANCE (GET_MODE_SIZE (MODE)) \
2028 : ROUND_ADVANCE (int_size_in_bytes (TYPE))) \
2029 > NPARM_REGS (MODE))) \
2030 ? NPARM_REGS (MODE) - ROUND_REG ((CUM), (MODE)) \
2031 : (SH5_WOULD_BE_PARTIAL_NREGS ((CUM), (MODE), (TYPE), (NAMED)) \
2032 && ! TARGET_SHCOMPACT) \
2033 ? NPARM_REGS (SImode) - (CUM).arg_count[(int) SH_ARG_INT] \
2034 : 0)
2036 #define SH5_WOULD_BE_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) \
2037 (TARGET_SH5 && ((MODE) == BLKmode || (MODE) == TImode) \
2038 && ((CUM).arg_count[(int) SH_ARG_INT] \
2039 + (int_size_in_bytes (TYPE) + 7) / 8) > NPARM_REGS (SImode))
2041 /* Perform any needed actions needed for a function that is receiving a
2042 variable number of arguments. */
2044 /* We actually emit the code in sh_expand_prologue. We used to use
2045 a static variable to flag that we need to emit this code, but that
2046 doesn't when inlining, when functions are deferred and then emitted
2047 later. Fortunately, we already have two flags that are part of struct
2048 function that tell if a function uses varargs or stdarg. */
2049 #define SETUP_INCOMING_VARARGS(ASF, MODE, TYPE, PAS, ST) do \
2050 if (! current_function_stdarg) \
2051 abort (); \
2052 while (0)
2054 /* Define the `__builtin_va_list' type for the ABI. */
2055 #define BUILD_VA_LIST_TYPE(VALIST) \
2056 (VALIST) = sh_build_va_list ()
2058 /* Implement `va_start' for varargs and stdarg. */
2059 #define EXPAND_BUILTIN_VA_START(valist, nextarg) \
2060 sh_va_start (valist, nextarg)
2062 /* Implement `va_arg'. */
2063 #define EXPAND_BUILTIN_VA_ARG(valist, type) \
2064 sh_va_arg (valist, type)
2066 /* Call the function profiler with a given profile label.
2067 We use two .aligns, so as to make sure that both the .long is aligned
2068 on a 4 byte boundary, and that the .long is a fixed distance (2 bytes)
2069 from the trapa instruction. */
2071 #define FUNCTION_PROFILER(STREAM,LABELNO) \
2073 fprintf((STREAM), "\t.align\t2\n"); \
2074 fprintf((STREAM), "\ttrapa\t#33\n"); \
2075 fprintf((STREAM), "\t.align\t2\n"); \
2076 asm_fprintf((STREAM), "\t.long\t%LLP%d\n", (LABELNO)); \
2079 /* Define this macro if the code for function profiling should come
2080 before the function prologue. Normally, the profiling code comes
2081 after. */
2083 #define PROFILE_BEFORE_PROLOGUE
2085 /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
2086 the stack pointer does not matter. The value is tested only in
2087 functions that have frame pointers.
2088 No definition is equivalent to always zero. */
2090 #define EXIT_IGNORE_STACK 1
2093 On the SH, the trampoline looks like
2094 2 0002 D202 mov.l l2,r2
2095 1 0000 D301 mov.l l1,r3
2096 3 0004 422B jmp @r2
2097 4 0006 0009 nop
2098 5 0008 00000000 l1: .long area
2099 6 000c 00000000 l2: .long function */
2101 /* Length in units of the trampoline for entering a nested function. */
2102 #define TRAMPOLINE_SIZE (TARGET_SHMEDIA64 ? 40 : TARGET_SH5 ? 24 : 16)
2104 /* Alignment required for a trampoline in bits . */
2105 #define TRAMPOLINE_ALIGNMENT \
2106 ((CACHE_LOG < 3 || (TARGET_SMALLCODE && ! TARGET_HARVARD)) ? 32 \
2107 : TARGET_SHMEDIA ? 256 : 64)
2109 /* Emit RTL insns to initialize the variable parts of a trampoline.
2110 FNADDR is an RTX for the address of the function's pure code.
2111 CXT is an RTX for the static chain value for the function. */
2113 #define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) \
2114 sh_initialize_trampoline ((TRAMP), (FNADDR), (CXT))
2116 /* On SH5, trampolines are SHmedia code, so add 1 to the address. */
2118 #define TRAMPOLINE_ADJUST_ADDRESS(TRAMP) do \
2120 if (TARGET_SHMEDIA) \
2121 (TRAMP) = expand_simple_binop (Pmode, PLUS, (TRAMP), GEN_INT (1), \
2122 gen_reg_rtx (Pmode), 0, \
2123 OPTAB_LIB_WIDEN); \
2124 } while (0)
2126 /* A C expression whose value is RTL representing the value of the return
2127 address for the frame COUNT steps up from the current frame.
2128 FRAMEADDR is already the frame pointer of the COUNT frame, so we
2129 can ignore COUNT. */
2131 #define RETURN_ADDR_RTX(COUNT, FRAME) \
2132 (((COUNT) == 0) \
2133 ? get_hard_reg_initial_val (Pmode, TARGET_SHMEDIA ? PR_MEDIA_REG : PR_REG) \
2134 : (rtx) 0)
2136 /* A C expression whose value is RTL representing the location of the
2137 incoming return address at the beginning of any function, before the
2138 prologue. This RTL is either a REG, indicating that the return
2139 value is saved in REG, or a MEM representing a location in
2140 the stack. */
2141 #define INCOMING_RETURN_ADDR_RTX \
2142 gen_rtx_REG (Pmode, TARGET_SHMEDIA ? PR_MEDIA_REG : PR_REG)
2144 /* Generate necessary RTL for __builtin_saveregs(). */
2145 #define EXPAND_BUILTIN_SAVEREGS() sh_builtin_saveregs ()
2147 /* Addressing modes, and classification of registers for them. */
2148 #define HAVE_POST_INCREMENT TARGET_SH1
2149 #define HAVE_PRE_DECREMENT TARGET_SH1
2151 #define USE_LOAD_POST_INCREMENT(mode) ((mode == SImode || mode == DImode) \
2152 ? 0 : TARGET_SH1)
2153 #define USE_LOAD_PRE_DECREMENT(mode) 0
2154 #define USE_STORE_POST_INCREMENT(mode) 0
2155 #define USE_STORE_PRE_DECREMENT(mode) ((mode == SImode || mode == DImode) \
2156 ? 0 : TARGET_SH1)
2158 #define MOVE_BY_PIECES_P(SIZE, ALIGN) (move_by_pieces_ninsns (SIZE, ALIGN) \
2159 < (TARGET_SMALLCODE ? 2 : \
2160 ((ALIGN >= 32) ? 16 : 2)))
2162 /* Macros to check register numbers against specific register classes. */
2164 /* These assume that REGNO is a hard or pseudo reg number.
2165 They give nonzero only if REGNO is a hard reg of the suitable class
2166 or a pseudo reg currently allocated to a suitable hard reg.
2167 Since they use reg_renumber, they are safe only once reg_renumber
2168 has been allocated, which happens in local-alloc.c. */
2170 #define REGNO_OK_FOR_BASE_P(REGNO) \
2171 (GENERAL_OR_AP_REGISTER_P (REGNO) \
2172 || GENERAL_OR_AP_REGISTER_P (reg_renumber[(REGNO)]))
2173 #define REGNO_OK_FOR_INDEX_P(REGNO) \
2174 (TARGET_SHMEDIA \
2175 ? (GENERAL_REGISTER_P (REGNO) \
2176 || GENERAL_REGISTER_P ((unsigned) reg_renumber[(REGNO)])) \
2177 : (REGNO) == R0_REG || (unsigned) reg_renumber[(REGNO)] == R0_REG)
2179 /* Maximum number of registers that can appear in a valid memory
2180 address. */
2182 #define MAX_REGS_PER_ADDRESS 2
2184 /* Recognize any constant value that is a valid address. */
2186 #define CONSTANT_ADDRESS_P(X) (GET_CODE (X) == LABEL_REF)
2188 /* Nonzero if the constant value X is a legitimate general operand. */
2190 #define LEGITIMATE_CONSTANT_P(X) \
2191 (TARGET_SHMEDIA \
2192 ? ((GET_MODE (X) != DFmode \
2193 && GET_MODE_CLASS (GET_MODE (X)) != MODE_VECTOR_FLOAT) \
2194 || (X) == CONST0_RTX (GET_MODE (X)) \
2195 || ! TARGET_SHMEDIA_FPU \
2196 || TARGET_SHMEDIA64) \
2197 : (GET_CODE (X) != CONST_DOUBLE \
2198 || GET_MODE (X) == DFmode || GET_MODE (X) == SFmode \
2199 || (TARGET_SH2E && (fp_zero_operand (X) || fp_one_operand (X)))))
2201 /* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
2202 and check its validity for a certain class.
2203 We have two alternate definitions for each of them.
2204 The usual definition accepts all pseudo regs; the other rejects
2205 them unless they have been allocated suitable hard regs.
2206 The symbol REG_OK_STRICT causes the latter definition to be used. */
2208 #ifndef REG_OK_STRICT
2210 /* Nonzero if X is a hard reg that can be used as a base reg
2211 or if it is a pseudo reg. */
2212 #define REG_OK_FOR_BASE_P(X) \
2213 (GENERAL_OR_AP_REGISTER_P (REGNO (X)) || REGNO (X) >= FIRST_PSEUDO_REGISTER)
2215 /* Nonzero if X is a hard reg that can be used as an index
2216 or if it is a pseudo reg. */
2217 #define REG_OK_FOR_INDEX_P(X) \
2218 ((TARGET_SHMEDIA ? GENERAL_REGISTER_P (REGNO (X)) \
2219 : REGNO (X) == R0_REG) || REGNO (X) >= FIRST_PSEUDO_REGISTER)
2221 /* Nonzero if X/OFFSET is a hard reg that can be used as an index
2222 or if X is a pseudo reg. */
2223 #define SUBREG_OK_FOR_INDEX_P(X, OFFSET) \
2224 ((TARGET_SHMEDIA ? GENERAL_REGISTER_P (REGNO (X)) \
2225 : REGNO (X) == R0_REG && OFFSET == 0) || REGNO (X) >= FIRST_PSEUDO_REGISTER)
2227 #else
2229 /* Nonzero if X is a hard reg that can be used as a base reg. */
2230 #define REG_OK_FOR_BASE_P(X) \
2231 REGNO_OK_FOR_BASE_P (REGNO (X))
2233 /* Nonzero if X is a hard reg that can be used as an index. */
2234 #define REG_OK_FOR_INDEX_P(X) \
2235 REGNO_OK_FOR_INDEX_P (REGNO (X))
2237 /* Nonzero if X/OFFSET is a hard reg that can be used as an index. */
2238 #define SUBREG_OK_FOR_INDEX_P(X, OFFSET) \
2239 (REGNO_OK_FOR_INDEX_P (REGNO (X)) && (OFFSET) == 0)
2241 #endif
2243 /* The 'Q' constraint is a pc relative load operand. */
2244 #define EXTRA_CONSTRAINT_Q(OP) \
2245 (GET_CODE (OP) == MEM \
2246 && ((GET_CODE (XEXP ((OP), 0)) == LABEL_REF) \
2247 || (GET_CODE (XEXP ((OP), 0)) == CONST \
2248 && GET_CODE (XEXP (XEXP ((OP), 0), 0)) == PLUS \
2249 && GET_CODE (XEXP (XEXP (XEXP ((OP), 0), 0), 0)) == LABEL_REF \
2250 && GET_CODE (XEXP (XEXP (XEXP ((OP), 0), 0), 1)) == CONST_INT)))
2252 /* The `S' constraint is a 16-bit constant, literal or symbolic. */
2253 #define EXTRA_CONSTRAINT_S(OP) \
2254 (GET_CODE (OP) == CONST \
2255 && GET_CODE (XEXP ((OP), 0)) == SIGN_EXTEND \
2256 && GET_MODE (XEXP ((OP), 0)) == DImode \
2257 && GET_CODE (XEXP (XEXP ((OP), 0), 0)) == TRUNCATE \
2258 && GET_MODE (XEXP (XEXP ((OP), 0), 0)) == HImode \
2259 && (MOVI_SHORI_BASE_OPERAND_P (XEXP (XEXP (XEXP ((OP), 0), 0), 0)) \
2260 || (GET_CODE (XEXP (XEXP (XEXP ((OP), 0), 0), 0)) == ASHIFTRT \
2261 && (MOVI_SHORI_BASE_OPERAND_P \
2262 (XEXP (XEXP (XEXP (XEXP ((OP), 0), 0), 0), 0))) \
2263 && GET_CODE (XEXP (XEXP (XEXP (XEXP ((OP), 0), 0), 0), \
2264 1)) == CONST_INT)))
2266 /* Check whether OP is a datalabel unspec. */
2267 #define DATALABEL_REF_NO_CONST_P(OP) \
2268 (GET_CODE (OP) == UNSPEC \
2269 && XINT ((OP), 1) == UNSPEC_DATALABEL \
2270 && XVECLEN ((OP), 0) == 1 \
2271 && (GET_CODE (XVECEXP ((OP), 0, 0)) == SYMBOL_REF \
2272 || GET_CODE (XVECEXP ((OP), 0, 0)) == LABEL_REF))
2274 /* Check whether OP is a datalabel unspec, possibly enclosed within a
2275 CONST. */
2276 #define DATALABEL_REF_P(OP) \
2277 ((GET_CODE (OP) == CONST && DATALABEL_REF_NO_CONST_P (XEXP ((OP), 0))) \
2278 || DATALABEL_REF_NO_CONST_P (OP))
2280 #define GOT_ENTRY_P(OP) \
2281 (GET_CODE (OP) == CONST && GET_CODE (XEXP ((OP), 0)) == UNSPEC \
2282 && XINT (XEXP ((OP), 0), 1) == UNSPEC_GOT)
2284 #define GOTPLT_ENTRY_P(OP) \
2285 (GET_CODE (OP) == CONST && GET_CODE (XEXP ((OP), 0)) == UNSPEC \
2286 && XINT (XEXP ((OP), 0), 1) == UNSPEC_GOTPLT)
2288 #define UNSPEC_GOTOFF_P(OP) \
2289 (GET_CODE (OP) == UNSPEC && XINT ((OP), 1) == UNSPEC_GOTOFF)
2291 #define GOTOFF_P(OP) \
2292 (GET_CODE (OP) == CONST \
2293 && (UNSPEC_GOTOFF_P (XEXP ((OP), 0)) \
2294 || (GET_CODE (XEXP ((OP), 0)) == PLUS \
2295 && UNSPEC_GOTOFF_P (XEXP (XEXP ((OP), 0), 0)) \
2296 && GET_CODE (XEXP (XEXP ((OP), 0), 1)) == CONST_INT)))
2298 #define PIC_ADDR_P(OP) \
2299 (GET_CODE (OP) == CONST && GET_CODE (XEXP ((OP), 0)) == UNSPEC \
2300 && XINT (XEXP ((OP), 0), 1) == UNSPEC_PIC)
2302 #define NON_PIC_REFERENCE_P(OP) \
2303 (GET_CODE (OP) == LABEL_REF || GET_CODE (OP) == SYMBOL_REF \
2304 || DATALABEL_REF_P (OP) \
2305 || (GET_CODE (OP) == CONST && GET_CODE (XEXP ((OP), 0)) == PLUS \
2306 && (GET_CODE (XEXP (XEXP ((OP), 0), 0)) == SYMBOL_REF \
2307 || DATALABEL_REF_P (XEXP (XEXP ((OP), 0), 0))) \
2308 && GET_CODE (XEXP (XEXP ((OP), 0), 1)) == CONST_INT))
2310 #define PIC_REFERENCE_P(OP) \
2311 (GOT_ENTRY_P (OP) || GOTPLT_ENTRY_P (OP) \
2312 || GOTOFF_P (OP) || PIC_ADDR_P (OP))
2314 #define MOVI_SHORI_BASE_OPERAND_P(OP) \
2315 (flag_pic ? PIC_REFERENCE_P (OP) : NON_PIC_REFERENCE_P (OP))
2317 /* The `T' constraint is a label or a symbol. */
2318 #define EXTRA_CONSTRAINT_T(OP) \
2319 (NON_PIC_REFERENCE_P (OP))
2321 /* A zero in any shape or form. */
2322 #define EXTRA_CONSTRAINT_U(OP) \
2323 ((OP) == CONST0_RTX (GET_MODE (OP)))
2325 /* Any vector constant we can handle. */
2326 #define EXTRA_CONSTRAINT_W(OP) \
2327 (GET_CODE (OP) == CONST_VECTOR \
2328 && (sh_rep_vec ((OP), VOIDmode) \
2329 || (HOST_BITS_PER_WIDE_INT >= 64 \
2330 ? sh_const_vec ((OP), VOIDmode) \
2331 : sh_1el_vec ((OP), VOIDmode))))
2333 #define EXTRA_CONSTRAINT_Z(OP) \
2334 (GET_CODE (OP) == CONST_INT \
2335 && (INTVAL (OP) == (unsigned) 0xffffffff \
2336 || INTVAL (OP) == (HOST_WIDE_INT) -1 << 32))
2338 #define EXTRA_CONSTRAINT(OP, C) \
2339 ((C) == 'Q' ? EXTRA_CONSTRAINT_Q (OP) \
2340 : (C) == 'S' ? EXTRA_CONSTRAINT_S (OP) \
2341 : (C) == 'T' ? EXTRA_CONSTRAINT_T (OP) \
2342 : (C) == 'U' ? EXTRA_CONSTRAINT_U (OP) \
2343 : (C) == 'W' ? EXTRA_CONSTRAINT_W (OP) \
2344 : (C) == 'Z' ? EXTRA_CONSTRAINT_Z (OP) \
2345 : 0)
2347 /* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression
2348 that is a valid memory address for an instruction.
2349 The MODE argument is the machine mode for the MEM expression
2350 that wants to use this address. */
2352 #define MODE_DISP_OK_4(X,MODE) \
2353 (GET_MODE_SIZE (MODE) == 4 && (unsigned) INTVAL (X) < 64 \
2354 && ! (INTVAL (X) & 3) && ! (TARGET_SH2E && (MODE) == SFmode))
2356 #define MODE_DISP_OK_8(X,MODE) \
2357 ((GET_MODE_SIZE(MODE)==8) && ((unsigned)INTVAL(X)<60) \
2358 && ! (INTVAL(X) & 3) && ! (TARGET_SH4 && (MODE) == DFmode))
2360 #define BASE_REGISTER_RTX_P(X) \
2361 ((GET_CODE (X) == REG && REG_OK_FOR_BASE_P (X)) \
2362 || (GET_CODE (X) == SUBREG \
2363 && GET_CODE (SUBREG_REG (X)) == REG \
2364 && REG_OK_FOR_BASE_P (SUBREG_REG (X))))
2366 /* Since this must be r0, which is a single register class, we must check
2367 SUBREGs more carefully, to be sure that we don't accept one that extends
2368 outside the class. */
2369 #define INDEX_REGISTER_RTX_P(X) \
2370 ((GET_CODE (X) == REG && REG_OK_FOR_INDEX_P (X)) \
2371 || (GET_CODE (X) == SUBREG \
2372 && GET_CODE (SUBREG_REG (X)) == REG \
2373 && SUBREG_OK_FOR_INDEX_P (SUBREG_REG (X), SUBREG_BYTE (X))))
2375 /* Jump to LABEL if X is a valid address RTX. This must also take
2376 REG_OK_STRICT into account when deciding about valid registers, but it uses
2377 the above macros so we are in luck.
2379 Allow REG
2380 REG+disp
2381 REG+r0
2382 REG++
2383 --REG */
2385 /* ??? The SH2e does not have the REG+disp addressing mode when loading values
2386 into the FRx registers. We implement this by setting the maximum offset
2387 to zero when the value is SFmode. This also restricts loading of SFmode
2388 values into the integer registers, but that can't be helped. */
2390 /* The SH allows a displacement in a QI or HI amode, but only when the
2391 other operand is R0. GCC doesn't handle this very well, so we forgo
2392 all of that.
2394 A legitimate index for a QI or HI is 0, SI can be any number 0..63,
2395 DI can be any number 0..60. */
2397 #define GO_IF_LEGITIMATE_INDEX(MODE, OP, LABEL) \
2398 do { \
2399 if (GET_CODE (OP) == CONST_INT) \
2401 if (TARGET_SHMEDIA) \
2403 int MODE_SIZE = GET_MODE_SIZE (MODE); \
2404 if (! (INTVAL (OP) & (MODE_SIZE - 1)) \
2405 && INTVAL (OP) >= -512 * MODE_SIZE \
2406 && INTVAL (OP) < 512 * MODE_SIZE) \
2407 goto LABEL; \
2408 else \
2409 break; \
2411 if (MODE_DISP_OK_4 ((OP), (MODE))) goto LABEL; \
2412 if (MODE_DISP_OK_8 ((OP), (MODE))) goto LABEL; \
2414 } while(0)
2416 #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, LABEL) \
2418 if (BASE_REGISTER_RTX_P (X)) \
2419 goto LABEL; \
2420 else if ((GET_CODE (X) == POST_INC || GET_CODE (X) == PRE_DEC) \
2421 && ! TARGET_SHMEDIA \
2422 && BASE_REGISTER_RTX_P (XEXP ((X), 0))) \
2423 goto LABEL; \
2424 else if (GET_CODE (X) == PLUS \
2425 && ((MODE) != PSImode || reload_completed)) \
2427 rtx xop0 = XEXP ((X), 0); \
2428 rtx xop1 = XEXP ((X), 1); \
2429 if (GET_MODE_SIZE (MODE) <= 8 && BASE_REGISTER_RTX_P (xop0)) \
2430 GO_IF_LEGITIMATE_INDEX ((MODE), xop1, LABEL); \
2431 if (GET_MODE_SIZE (MODE) <= 4 \
2432 || (TARGET_SHMEDIA && GET_MODE_SIZE (MODE) <= 8) \
2433 || (TARGET_SH4 && TARGET_FMOVD && MODE == DFmode)) \
2435 if (BASE_REGISTER_RTX_P (xop1) && INDEX_REGISTER_RTX_P (xop0))\
2436 goto LABEL; \
2437 if (INDEX_REGISTER_RTX_P (xop1) && BASE_REGISTER_RTX_P (xop0))\
2438 goto LABEL; \
2443 /* Try machine-dependent ways of modifying an illegitimate address
2444 to be legitimate. If we find one, return the new, valid address.
2445 This macro is used in only one place: `memory_address' in explow.c.
2447 OLDX is the address as it was before break_out_memory_refs was called.
2448 In some cases it is useful to look at this to decide what needs to be done.
2450 MODE and WIN are passed so that this macro can use
2451 GO_IF_LEGITIMATE_ADDRESS.
2453 It is always safe for this macro to do nothing. It exists to recognize
2454 opportunities to optimize the output.
2456 For the SH, if X is almost suitable for indexing, but the offset is
2457 out of range, convert it into a normal form so that cse has a chance
2458 of reducing the number of address registers used. */
2460 #define LEGITIMIZE_ADDRESS(X,OLDX,MODE,WIN) \
2462 if (flag_pic) \
2463 (X) = legitimize_pic_address (OLDX, MODE, NULL_RTX); \
2464 if (GET_CODE (X) == PLUS \
2465 && (GET_MODE_SIZE (MODE) == 4 \
2466 || GET_MODE_SIZE (MODE) == 8) \
2467 && GET_CODE (XEXP ((X), 1)) == CONST_INT \
2468 && BASE_REGISTER_RTX_P (XEXP ((X), 0)) \
2469 && ! TARGET_SHMEDIA \
2470 && ! (TARGET_SH4 && (MODE) == DFmode) \
2471 && ! (TARGET_SH2E && (MODE) == SFmode)) \
2473 rtx index_rtx = XEXP ((X), 1); \
2474 HOST_WIDE_INT offset = INTVAL (index_rtx), offset_base; \
2475 rtx sum; \
2477 GO_IF_LEGITIMATE_INDEX ((MODE), index_rtx, WIN); \
2478 /* On rare occasions, we might get an unaligned pointer \
2479 that is indexed in a way to give an aligned address. \
2480 Therefore, keep the lower two bits in offset_base. */ \
2481 /* Instead of offset_base 128..131 use 124..127, so that \
2482 simple add suffices. */ \
2483 if (offset > 127) \
2485 offset_base = ((offset + 4) & ~60) - 4; \
2487 else \
2488 offset_base = offset & ~60; \
2489 /* Sometimes the normal form does not suit DImode. We \
2490 could avoid that by using smaller ranges, but that \
2491 would give less optimized code when SImode is \
2492 prevalent. */ \
2493 if (GET_MODE_SIZE (MODE) + offset - offset_base <= 64) \
2495 sum = expand_binop (Pmode, add_optab, XEXP ((X), 0), \
2496 GEN_INT (offset_base), NULL_RTX, 0, \
2497 OPTAB_LIB_WIDEN); \
2499 (X) = gen_rtx_PLUS (Pmode, sum, GEN_INT (offset - offset_base)); \
2500 goto WIN; \
2505 /* A C compound statement that attempts to replace X, which is an address
2506 that needs reloading, with a valid memory address for an operand of
2507 mode MODE. WIN is a C statement label elsewhere in the code.
2509 Like for LEGITIMIZE_ADDRESS, for the SH we try to get a normal form
2510 of the address. That will allow inheritance of the address reloads. */
2512 #define LEGITIMIZE_RELOAD_ADDRESS(X,MODE,OPNUM,TYPE,IND_LEVELS,WIN) \
2514 if (GET_CODE (X) == PLUS \
2515 && (GET_MODE_SIZE (MODE) == 4 || GET_MODE_SIZE (MODE) == 8) \
2516 && GET_CODE (XEXP (X, 1)) == CONST_INT \
2517 && BASE_REGISTER_RTX_P (XEXP (X, 0)) \
2518 && ! TARGET_SHMEDIA \
2519 && ! (TARGET_SH4 && (MODE) == DFmode) \
2520 && ! ((MODE) == PSImode && (TYPE) == RELOAD_FOR_INPUT_ADDRESS)) \
2522 rtx index_rtx = XEXP (X, 1); \
2523 HOST_WIDE_INT offset = INTVAL (index_rtx), offset_base; \
2524 rtx sum; \
2526 if (TARGET_SH2E && MODE == SFmode) \
2528 X = copy_rtx (X); \
2529 push_reload (index_rtx, NULL_RTX, &XEXP (X, 1), NULL, \
2530 INDEX_REG_CLASS, Pmode, VOIDmode, 0, 0, (OPNUM), \
2531 (TYPE)); \
2532 goto WIN; \
2534 /* Instead of offset_base 128..131 use 124..127, so that \
2535 simple add suffices. */ \
2536 if (offset > 127) \
2538 offset_base = ((offset + 4) & ~60) - 4; \
2540 else \
2541 offset_base = offset & ~60; \
2542 /* Sometimes the normal form does not suit DImode. We \
2543 could avoid that by using smaller ranges, but that \
2544 would give less optimized code when SImode is \
2545 prevalent. */ \
2546 if (GET_MODE_SIZE (MODE) + offset - offset_base <= 64) \
2548 sum = gen_rtx (PLUS, Pmode, XEXP (X, 0), \
2549 GEN_INT (offset_base)); \
2550 X = gen_rtx (PLUS, Pmode, sum, GEN_INT (offset - offset_base));\
2551 push_reload (sum, NULL_RTX, &XEXP (X, 0), NULL, \
2552 BASE_REG_CLASS, Pmode, VOIDmode, 0, 0, (OPNUM), \
2553 (TYPE)); \
2554 goto WIN; \
2557 /* We must re-recognize what we created before. */ \
2558 else if (GET_CODE (X) == PLUS \
2559 && (GET_MODE_SIZE (MODE) == 4 || GET_MODE_SIZE (MODE) == 8) \
2560 && GET_CODE (XEXP (X, 0)) == PLUS \
2561 && GET_CODE (XEXP (XEXP (X, 0), 1)) == CONST_INT \
2562 && BASE_REGISTER_RTX_P (XEXP (XEXP (X, 0), 0)) \
2563 && GET_CODE (XEXP (X, 1)) == CONST_INT \
2564 && ! TARGET_SHMEDIA \
2565 && ! (TARGET_SH2E && MODE == SFmode)) \
2567 /* Because this address is so complex, we know it must have \
2568 been created by LEGITIMIZE_RELOAD_ADDRESS before; thus, \
2569 it is already unshared, and needs no further unsharing. */ \
2570 push_reload (XEXP ((X), 0), NULL_RTX, &XEXP ((X), 0), NULL, \
2571 BASE_REG_CLASS, Pmode, VOIDmode, 0, 0, (OPNUM), (TYPE));\
2572 goto WIN; \
2576 /* Go to LABEL if ADDR (a legitimate address expression)
2577 has an effect that depends on the machine mode it is used for.
2579 ??? Strictly speaking, we should also include all indexed addressing,
2580 because the index scale factor is the length of the operand.
2581 However, the impact of GO_IF_MODE_DEPENDENT_ADDRESS would be to
2582 high if we did that. So we rely on reload to fix things up. */
2584 #define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR,LABEL) \
2586 if (GET_CODE(ADDR) == PRE_DEC || GET_CODE(ADDR) == POST_INC) \
2587 goto LABEL; \
2590 /* Specify the machine mode that this machine uses
2591 for the index in the tablejump instruction. */
2592 #define CASE_VECTOR_MODE ((! optimize || TARGET_BIGTABLE) ? SImode : HImode)
2594 #define CASE_VECTOR_SHORTEN_MODE(MIN_OFFSET, MAX_OFFSET, BODY) \
2595 ((MIN_OFFSET) >= 0 && (MAX_OFFSET) <= 127 \
2596 ? (ADDR_DIFF_VEC_FLAGS (BODY).offset_unsigned = 0, QImode) \
2597 : (MIN_OFFSET) >= 0 && (MAX_OFFSET) <= 255 \
2598 ? (ADDR_DIFF_VEC_FLAGS (BODY).offset_unsigned = 1, QImode) \
2599 : (MIN_OFFSET) >= -32768 && (MAX_OFFSET) <= 32767 ? HImode \
2600 : SImode)
2602 /* Define as C expression which evaluates to nonzero if the tablejump
2603 instruction expects the table to contain offsets from the address of the
2604 table.
2605 Do not define this if the table should contain absolute addresses. */
2606 #define CASE_VECTOR_PC_RELATIVE 1
2608 /* Define it here, so that it doesn't get bumped to 64-bits on SHmedia. */
2609 #define FLOAT_TYPE_SIZE 32
2611 /* Since the SH2e has only `float' support, it is desirable to make all
2612 floating point types equivalent to `float'. */
2613 #define DOUBLE_TYPE_SIZE ((TARGET_SH2E && ! TARGET_SH4) ? 32 : 64)
2615 /* 'char' is signed by default. */
2616 #define DEFAULT_SIGNED_CHAR 1
2618 /* The type of size_t unsigned int. */
2619 #define SIZE_TYPE (TARGET_SH5 ? "long unsigned int" : "unsigned int")
2621 #undef PTRDIFF_TYPE
2622 #define PTRDIFF_TYPE (TARGET_SH5 ? "long int" : "int")
2624 #define WCHAR_TYPE "short unsigned int"
2625 #define WCHAR_TYPE_SIZE 16
2627 #define SH_ELF_WCHAR_TYPE "long int"
2629 /* Don't cse the address of the function being compiled. */
2630 /*#define NO_RECURSIVE_FUNCTION_CSE 1*/
2632 /* Max number of bytes we can move from memory to memory
2633 in one reasonably fast instruction. */
2634 #define MOVE_MAX (TARGET_SHMEDIA ? 8 : 4)
2636 /* Maximum value possibly taken by MOVE_MAX. Must be defined whenever
2637 MOVE_MAX is not a compile-time constant. */
2638 #define MAX_MOVE_MAX 8
2640 /* Max number of bytes we want move_by_pieces to be able to copy
2641 efficiently. */
2642 #define MOVE_MAX_PIECES (TARGET_SH4 || TARGET_SHMEDIA ? 8 : 4)
2644 /* Define if operations between registers always perform the operation
2645 on the full register even if a narrower mode is specified. */
2646 #define WORD_REGISTER_OPERATIONS
2648 /* Define if loading in MODE, an integral mode narrower than BITS_PER_WORD
2649 will either zero-extend or sign-extend. The value of this macro should
2650 be the code that says which one of the two operations is implicitly
2651 done, NIL if none. */
2652 /* For SHmedia, we can truncate to QImode easier using zero extension. */
2653 /* FP registers can load SImode values, but don't implicitly sign-extend
2654 them to DImode. */
2655 #define LOAD_EXTEND_OP(MODE) \
2656 (((MODE) == QImode && TARGET_SHMEDIA) ? ZERO_EXTEND \
2657 : (MODE) != SImode ? SIGN_EXTEND : NIL)
2659 /* Define if loading short immediate values into registers sign extends. */
2660 #define SHORT_IMMEDIATES_SIGN_EXTEND
2662 /* Nonzero if access to memory by bytes is no faster than for words. */
2663 #define SLOW_BYTE_ACCESS 1
2665 /* We assume that the store-condition-codes instructions store 0 for false
2666 and some other value for true. This is the value stored for true. */
2668 #define STORE_FLAG_VALUE 1
2670 /* Immediate shift counts are truncated by the output routines (or was it
2671 the assembler?). Shift counts in a register are truncated by SH. Note
2672 that the native compiler puts too large (> 32) immediate shift counts
2673 into a register and shifts by the register, letting the SH decide what
2674 to do instead of doing that itself. */
2675 /* ??? The library routines in lib1funcs.asm truncate the shift count.
2676 However, the SH3 has hardware shifts that do not truncate exactly as gcc
2677 expects - the sign bit is significant - so it appears that we need to
2678 leave this zero for correct SH3 code. */
2679 #define SHIFT_COUNT_TRUNCATED (! TARGET_SH3)
2681 /* All integers have the same format so truncation is easy. */
2682 #define TRULY_NOOP_TRUNCATION(OUTPREC,INPREC) 1
2684 /* Define this if addresses of constant functions
2685 shouldn't be put through pseudo regs where they can be cse'd.
2686 Desirable on machines where ordinary constants are expensive
2687 but a CALL with constant address is cheap. */
2688 /*#define NO_FUNCTION_CSE 1*/
2690 /* Chars and shorts should be passed as ints. */
2691 #define PROMOTE_PROTOTYPES 1
2693 /* The machine modes of pointers and functions. */
2694 #define Pmode (TARGET_SHMEDIA64 ? DImode : SImode)
2695 #define FUNCTION_MODE Pmode
2697 /* The multiply insn on the SH1 and the divide insns on the SH1 and SH2
2698 are actually function calls with some special constraints on arguments
2699 and register usage.
2701 These macros tell reorg that the references to arguments and
2702 register clobbers for insns of type sfunc do not appear to happen
2703 until after the millicode call. This allows reorg to put insns
2704 which set the argument registers into the delay slot of the millicode
2705 call -- thus they act more like traditional CALL_INSNs.
2707 get_attr_is_sfunc will try to recognize the given insn, so make sure to
2708 filter out things it will not accept -- SEQUENCE, USE and CLOBBER insns
2709 in particular. */
2711 #define INSN_SETS_ARE_DELAYED(X) \
2712 ((GET_CODE (X) == INSN \
2713 && GET_CODE (PATTERN (X)) != SEQUENCE \
2714 && GET_CODE (PATTERN (X)) != USE \
2715 && GET_CODE (PATTERN (X)) != CLOBBER \
2716 && get_attr_is_sfunc (X)))
2718 #define INSN_REFERENCES_ARE_DELAYED(X) \
2719 ((GET_CODE (X) == INSN \
2720 && GET_CODE (PATTERN (X)) != SEQUENCE \
2721 && GET_CODE (PATTERN (X)) != USE \
2722 && GET_CODE (PATTERN (X)) != CLOBBER \
2723 && get_attr_is_sfunc (X)))
2726 /* Position Independent Code. */
2728 /* The prefix used to mark SYMBOL_REFs that refer to data symbols. */
2729 #define SH_DATALABEL_ENCODING "#"
2731 /* Return true if SYM_NAME starts with SH_DATALABEL_ENCODING. */
2732 #define DATALABEL_SYMNAME_P(SYM_NAME) \
2733 (SH_DATALABEL_ENCODING[1] ? (abort (), 0) : \
2734 (SYM_NAME)[0] == SH_DATALABEL_ENCODING[0])
2736 /* Skip an optional SH_DATALABEL_ENCODING in the beginning of
2737 SYM_NAME. Then, remove a leading *, like the default definition in
2738 output.h. */
2739 #define STRIP_DATALABEL_ENCODING(VAR, SYM_NAME) \
2740 (VAR) = (SYM_NAME) + (DATALABEL_SYMNAME_P (SYM_NAME) \
2741 ? strlen (SH_DATALABEL_ENCODING) : 0)
2743 /* We can't directly access anything that contains a symbol,
2744 nor can we indirect via the constant pool. */
2745 #define LEGITIMATE_PIC_OPERAND_P(X) \
2746 (! nonpic_symbol_mentioned_p (X) \
2747 && (GET_CODE (X) != SYMBOL_REF \
2748 || ! CONSTANT_POOL_ADDRESS_P (X) \
2749 || ! nonpic_symbol_mentioned_p (get_pool_constant (X))))
2751 #define SYMBOLIC_CONST_P(X) \
2752 ((GET_CODE (X) == SYMBOL_REF || GET_CODE (X) == LABEL_REF) \
2753 && nonpic_symbol_mentioned_p (X))
2755 /* Compute the cost of an address. For the SH, all valid addresses are
2756 the same cost. Use a slightly higher cost for reg + reg addressing,
2757 since it increases pressure on r0. */
2759 #define ADDRESS_COST(X) (GET_CODE (X) == PLUS && ! CONSTANT_P (XEXP (X, 1)) \
2760 && ! TARGET_SHMEDIA \
2761 ? 1 : 0)
2763 /* Compute extra cost of moving data between one register class
2764 and another. */
2766 /* If SECONDARY*_RELOAD_CLASS says something about the src/dst pair, regclass
2767 uses this information. Hence, the general register <-> floating point
2768 register information here is not used for SFmode. */
2770 #define REGCLASS_HAS_GENERAL_REG(CLASS) \
2771 ((CLASS) == GENERAL_REGS || (CLASS) == R0_REGS \
2772 || (! TARGET_SHMEDIA && (CLASS) == SIBCALL_REGS))
2774 #define REGCLASS_HAS_FP_REG(CLASS) \
2775 ((CLASS) == FP0_REGS || (CLASS) == FP_REGS \
2776 || (CLASS) == DF_REGS || (CLASS) == DF_HI_REGS)
2778 #define REGISTER_MOVE_COST(MODE, SRCCLASS, DSTCLASS) \
2779 sh_register_move_cost ((MODE), (SRCCLASS), (DSTCLASS))
2781 /* ??? Perhaps make MEMORY_MOVE_COST depend on compiler option? This
2782 would be so that people with slow memory systems could generate
2783 different code that does fewer memory accesses. */
2785 /* A C expression for the cost of a branch instruction. A value of 1
2786 is the default; other values are interpreted relative to that.
2787 The SH1 does not have delay slots, hence we get a pipeline stall
2788 at every branch. The SH4 is superscalar, so the single delay slot
2789 is not sufficient to keep both pipelines filled. */
2790 #define BRANCH_COST (TARGET_SH5 ? 1 : ! TARGET_SH2 || TARGET_HARD_SH4 ? 2 : 1)
2792 /* Assembler output control. */
2794 /* A C string constant describing how to begin a comment in the target
2795 assembler language. The compiler assumes that the comment will end at
2796 the end of the line. */
2797 #define ASM_COMMENT_START "!"
2799 /* The text to go at the start of the assembler file. */
2800 #define ASM_FILE_START(STREAM) \
2801 output_file_start (STREAM)
2803 #define ASM_APP_ON ""
2804 #define ASM_APP_OFF ""
2805 #define FILE_ASM_OP "\t.file\n"
2806 #define SET_ASM_OP "\t.set\t"
2808 /* How to change between sections. */
2810 #define TEXT_SECTION_ASM_OP (TARGET_SHMEDIA32 ? "\t.section\t.text..SHmedia32,\"ax\"" : "\t.text")
2811 #define DATA_SECTION_ASM_OP "\t.data"
2813 #if defined CRT_BEGIN || defined CRT_END
2814 /* Arrange for TEXT_SECTION_ASM_OP to be a compile-time constant. */
2815 # undef TEXT_SECTION_ASM_OP
2816 # if __SHMEDIA__ == 1 && __SH5__ == 32
2817 # define TEXT_SECTION_ASM_OP "\t.section\t.text..SHmedia32,\"ax\""
2818 # else
2819 # define TEXT_SECTION_ASM_OP "\t.text"
2820 # endif
2821 #endif
2824 /* If defined, a C expression whose value is a string containing the
2825 assembler operation to identify the following data as
2826 uninitialized global data. If not defined, and neither
2827 `ASM_OUTPUT_BSS' nor `ASM_OUTPUT_ALIGNED_BSS' are defined,
2828 uninitialized global data will be output in the data section if
2829 `-fno-common' is passed, otherwise `ASM_OUTPUT_COMMON' will be
2830 used. */
2831 #ifndef BSS_SECTION_ASM_OP
2832 #define BSS_SECTION_ASM_OP "\t.section\t.bss"
2833 #endif
2835 /* Like `ASM_OUTPUT_BSS' except takes the required alignment as a
2836 separate, explicit argument. If you define this macro, it is used
2837 in place of `ASM_OUTPUT_BSS', and gives you more flexibility in
2838 handling the required alignment of the variable. The alignment is
2839 specified as the number of bits.
2841 Try to use function `asm_output_aligned_bss' defined in file
2842 `varasm.c' when defining this macro. */
2843 #ifndef ASM_OUTPUT_ALIGNED_BSS
2844 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
2845 asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
2846 #endif
2848 /* Define this so that jump tables go in same section as the current function,
2849 which could be text or it could be a user defined section. */
2850 #define JUMP_TABLES_IN_TEXT_SECTION 1
2852 #undef DO_GLOBAL_CTORS_BODY
2853 #define DO_GLOBAL_CTORS_BODY \
2855 typedef (*pfunc)(); \
2856 extern pfunc __ctors[]; \
2857 extern pfunc __ctors_end[]; \
2858 pfunc *p; \
2859 for (p = __ctors_end; p > __ctors; ) \
2861 (*--p)(); \
2865 #undef DO_GLOBAL_DTORS_BODY
2866 #define DO_GLOBAL_DTORS_BODY \
2868 typedef (*pfunc)(); \
2869 extern pfunc __dtors[]; \
2870 extern pfunc __dtors_end[]; \
2871 pfunc *p; \
2872 for (p = __dtors; p < __dtors_end; p++) \
2874 (*p)(); \
2878 #define ASM_OUTPUT_REG_PUSH(file, v) \
2879 fprintf ((file), "\tmov.l\tr%d,@-r15\n", (v));
2881 #define ASM_OUTPUT_REG_POP(file, v) \
2882 fprintf ((file), "\tmov.l\t@r15+,r%d\n", (v));
2884 /* DBX register number for a given compiler register number. */
2885 /* GDB has FPUL at 23 and FP0 at 25, so we must add one to all FP registers
2886 to match gdb. */
2887 /* svr4.h undefines this macro, yet we really want to use the same numbers
2888 for coff as for elf, so we go via another macro: SH_DBX_REGISTER_NUMBER. */
2889 /* expand_builtin_init_dwarf_reg_sizes uses this to test if a
2890 register exists, so we should return -1 for invalid register numbers. */
2891 #define DBX_REGISTER_NUMBER(REGNO) SH_DBX_REGISTER_NUMBER (REGNO)
2893 #define SH_DBX_REGISTER_NUMBER(REGNO) \
2894 (GENERAL_REGISTER_P (REGNO) \
2895 ? ((REGNO) - FIRST_GENERAL_REG) \
2896 : FP_REGISTER_P (REGNO) \
2897 ? ((REGNO) - FIRST_FP_REG + (TARGET_SH5 ? (TARGET_SHCOMPACT ? 245 \
2898 : 77) : 25)) \
2899 : XD_REGISTER_P (REGNO) \
2900 ? ((REGNO) - FIRST_XD_REG + (TARGET_SH5 ? 289 : 87)) \
2901 : TARGET_REGISTER_P (REGNO) \
2902 ? ((REGNO) - FIRST_TARGET_REG + 68) \
2903 : (REGNO) == PR_REG \
2904 ? (TARGET_SH5 ? 241 : 17) \
2905 : (REGNO) == PR_MEDIA_REG \
2906 ? (TARGET_SH5 ? 18 : -1) \
2907 : (REGNO) == T_REG \
2908 ? (TARGET_SH5 ? 242 : 18) \
2909 : (REGNO) == GBR_REG \
2910 ? (TARGET_SH5 ? 238 : 19) \
2911 : (REGNO) == MACH_REG \
2912 ? (TARGET_SH5 ? 239 : 20) \
2913 : (REGNO) == MACL_REG \
2914 ? (TARGET_SH5 ? 240 : 21) \
2915 : (REGNO) == FPUL_REG \
2916 ? (TARGET_SH5 ? 244 : 23) \
2917 : -1)
2919 /* This is how to output a reference to a user-level label named NAME. */
2920 #define ASM_OUTPUT_LABELREF(FILE, NAME) \
2921 do \
2923 const char * lname; \
2925 STRIP_DATALABEL_ENCODING (lname, (NAME)); \
2926 if (lname[0] == '*') \
2927 fputs (lname + 1, (FILE)); \
2928 else \
2929 asm_fprintf ((FILE), "%U%s", lname); \
2931 while (0)
2933 /* This is how to output a reference to a symbol_ref. On SH5,
2934 references to non-code symbols must be preceded by `datalabel'. */
2935 #define ASM_OUTPUT_SYMBOL_REF(FILE,SYM) \
2936 do \
2938 if (TARGET_SH5 \
2939 && (DATALABEL_SYMNAME_P (XSTR ((SYM), 0)) \
2940 || CONSTANT_POOL_ADDRESS_P (SYM))) \
2941 fputs ("datalabel ", (FILE)); \
2942 assemble_name ((FILE), XSTR ((SYM), 0)); \
2944 while (0)
2946 /* This is how to output an assembler line
2947 that says to advance the location counter
2948 to a multiple of 2**LOG bytes. */
2950 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
2951 if ((LOG) != 0) \
2952 fprintf ((FILE), "\t.align %d\n", (LOG))
2954 /* Globalizing directive for a label. */
2955 #define GLOBAL_ASM_OP "\t.global\t"
2957 /* #define ASM_OUTPUT_CASE_END(STREAM,NUM,TABLE) */
2959 /* Output a relative address table. */
2961 #define ASM_OUTPUT_ADDR_DIFF_ELT(STREAM,BODY,VALUE,REL) \
2962 switch (GET_MODE (BODY)) \
2964 case SImode: \
2965 if (TARGET_SH5) \
2967 asm_fprintf ((STREAM), "\t.long\t%LL%d-datalabel %LL%d\n", \
2968 (VALUE), (REL)); \
2969 break; \
2971 asm_fprintf ((STREAM), "\t.long\t%LL%d-%LL%d\n", (VALUE),(REL)); \
2972 break; \
2973 case HImode: \
2974 if (TARGET_SH5) \
2976 asm_fprintf ((STREAM), "\t.word\t%LL%d-datalabel %LL%d\n", \
2977 (VALUE), (REL)); \
2978 break; \
2980 asm_fprintf ((STREAM), "\t.word\t%LL%d-%LL%d\n", (VALUE),(REL)); \
2981 break; \
2982 case QImode: \
2983 if (TARGET_SH5) \
2985 asm_fprintf ((STREAM), "\t.byte\t%LL%d-datalabel %LL%d\n", \
2986 (VALUE), (REL)); \
2987 break; \
2989 asm_fprintf ((STREAM), "\t.byte\t%LL%d-%LL%d\n", (VALUE),(REL)); \
2990 break; \
2991 default: \
2992 break; \
2995 /* Output an absolute table element. */
2997 #define ASM_OUTPUT_ADDR_VEC_ELT(STREAM,VALUE) \
2998 if (! optimize || TARGET_BIGTABLE) \
2999 asm_fprintf ((STREAM), "\t.long\t%LL%d\n", (VALUE)); \
3000 else \
3001 asm_fprintf ((STREAM), "\t.word\t%LL%d\n", (VALUE));
3004 /* A C statement to be executed just prior to the output of
3005 assembler code for INSN, to modify the extracted operands so
3006 they will be output differently.
3008 Here the argument OPVEC is the vector containing the operands
3009 extracted from INSN, and NOPERANDS is the number of elements of
3010 the vector which contain meaningful data for this insn.
3011 The contents of this vector are what will be used to convert the insn
3012 template into assembler code, so you can change the assembler output
3013 by changing the contents of the vector. */
3015 #define FINAL_PRESCAN_INSN(INSN, OPVEC, NOPERANDS) \
3016 final_prescan_insn ((INSN), (OPVEC), (NOPERANDS))
3018 /* Print operand X (an rtx) in assembler syntax to file FILE.
3019 CODE is a letter or dot (`z' in `%z0') or 0 if no letter was specified.
3020 For `%' followed by punctuation, CODE is the punctuation and X is null. */
3022 #define PRINT_OPERAND(STREAM, X, CODE) print_operand ((STREAM), (X), (CODE))
3024 /* Print a memory address as an operand to reference that memory location. */
3026 #define PRINT_OPERAND_ADDRESS(STREAM,X) print_operand_address ((STREAM), (X))
3028 #define PRINT_OPERAND_PUNCT_VALID_P(CHAR) \
3029 ((CHAR) == '.' || (CHAR) == '#' || (CHAR) == '@' || (CHAR) == ',' \
3030 || (CHAR) == '$'|| (CHAR) == '\'')
3032 /* Recognize machine-specific patterns that may appear within
3033 constants. Used for PIC-specific UNSPECs. */
3034 #define OUTPUT_ADDR_CONST_EXTRA(STREAM, X, FAIL) \
3035 do \
3036 if (GET_CODE (X) == UNSPEC && XVECLEN ((X), 0) == 1) \
3038 switch (XINT ((X), 1)) \
3040 case UNSPEC_DATALABEL: \
3041 fputs ("datalabel ", (STREAM)); \
3042 output_addr_const ((STREAM), XVECEXP ((X), 0, 0)); \
3043 break; \
3044 case UNSPEC_PIC: \
3045 /* GLOBAL_OFFSET_TABLE or local symbols, no suffix. */ \
3046 output_addr_const ((STREAM), XVECEXP ((X), 0, 0)); \
3047 break; \
3048 case UNSPEC_GOT: \
3049 output_addr_const ((STREAM), XVECEXP ((X), 0, 0)); \
3050 fputs ("@GOT", (STREAM)); \
3051 break; \
3052 case UNSPEC_GOTOFF: \
3053 output_addr_const ((STREAM), XVECEXP ((X), 0, 0)); \
3054 fputs ("@GOTOFF", (STREAM)); \
3055 break; \
3056 case UNSPEC_PLT: \
3057 output_addr_const ((STREAM), XVECEXP ((X), 0, 0)); \
3058 fputs ("@PLT", (STREAM)); \
3059 break; \
3060 case UNSPEC_GOTPLT: \
3061 output_addr_const ((STREAM), XVECEXP ((X), 0, 0)); \
3062 fputs ("@GOTPLT", (STREAM)); \
3063 break; \
3064 case UNSPEC_CALLER: \
3066 char name[32]; \
3067 /* LPCS stands for Label for PIC Call Site. */ \
3068 ASM_GENERATE_INTERNAL_LABEL \
3069 (name, "LPCS", INTVAL (XVECEXP ((X), 0, 0))); \
3070 assemble_name ((STREAM), name); \
3072 break; \
3073 default: \
3074 goto FAIL; \
3076 break; \
3078 else \
3079 goto FAIL; \
3080 while (0)
3083 extern struct rtx_def *sh_compare_op0;
3084 extern struct rtx_def *sh_compare_op1;
3086 /* Which processor to schedule for. The elements of the enumeration must
3087 match exactly the cpu attribute in the sh.md file. */
3089 enum processor_type {
3090 PROCESSOR_SH1,
3091 PROCESSOR_SH2,
3092 PROCESSOR_SH2E,
3093 PROCESSOR_SH3,
3094 PROCESSOR_SH3E,
3095 PROCESSOR_SH4,
3096 PROCESSOR_SH5
3099 #define sh_cpu_attr ((enum attr_cpu)sh_cpu)
3100 extern enum processor_type sh_cpu;
3102 extern int optimize; /* needed for gen_casesi. */
3104 enum mdep_reorg_phase_e
3106 SH_BEFORE_MDEP_REORG,
3107 SH_INSERT_USES_LABELS,
3108 SH_SHORTEN_BRANCHES0,
3109 SH_FIXUP_PCLOAD,
3110 SH_SHORTEN_BRANCHES1,
3111 SH_AFTER_MDEP_REORG
3114 extern enum mdep_reorg_phase_e mdep_reorg_phase;
3116 #define MACHINE_DEPENDENT_REORG(X) machine_dependent_reorg(X)
3118 /* Generate calls to memcpy, memcmp and memset. */
3120 #define TARGET_MEM_FUNCTIONS
3122 /* Handle Hitachi compiler's pragmas. */
3123 #define REGISTER_TARGET_PRAGMAS() do { \
3124 c_register_pragma (0, "interrupt", sh_pr_interrupt); \
3125 c_register_pragma (0, "trapa", sh_pr_trapa); \
3126 c_register_pragma (0, "nosave_low_regs", sh_pr_nosave_low_regs); \
3127 } while (0)
3129 /* Set when processing a function with pragma interrupt turned on. */
3131 extern int pragma_interrupt;
3133 /* Set when processing a function with interrupt attribute. */
3135 extern int current_function_interrupt;
3137 /* Set to an RTX containing the address of the stack to switch to
3138 for interrupt functions. */
3139 extern struct rtx_def *sp_switch;
3141 extern int rtx_equal_function_value_matters;
3144 /* Instructions with unfilled delay slots take up an
3145 extra two bytes for the nop in the delay slot.
3146 sh-dsp parallel processing insns are four bytes long. */
3148 #define ADJUST_INSN_LENGTH(X, LENGTH) \
3149 (LENGTH) += sh_insn_length_adjustment (X);
3151 /* Define the codes that are matched by predicates in sh.c. */
3152 #define PREDICATE_CODES \
3153 {"and_operand", {SUBREG, REG, CONST_INT}}, \
3154 {"any_register_operand", {SUBREG, REG}}, \
3155 {"arith_operand", {SUBREG, REG, CONST_INT}}, \
3156 {"arith_reg_dest", {SUBREG, REG}}, \
3157 {"arith_reg_operand", {SUBREG, REG}}, \
3158 {"arith_reg_or_0_operand", {SUBREG, REG, CONST_INT, CONST_VECTOR}}, \
3159 {"binary_float_operator", {PLUS, MINUS, MULT, DIV}}, \
3160 {"binary_logical_operator", {AND, IOR, XOR}}, \
3161 {"commutative_float_operator", {PLUS, MULT}}, \
3162 {"equality_comparison_operator", {EQ,NE}}, \
3163 {"extend_reg_operand", {SUBREG, REG, TRUNCATE}}, \
3164 {"extend_reg_or_0_operand", {SUBREG, REG, TRUNCATE, CONST_INT}}, \
3165 {"fp_arith_reg_operand", {SUBREG, REG}}, \
3166 {"fpscr_operand", {REG}}, \
3167 {"fpul_operand", {REG}}, \
3168 {"general_extend_operand", {SUBREG, REG, MEM, TRUNCATE}}, \
3169 {"general_movsrc_operand", {SUBREG, REG, CONST_INT, CONST_DOUBLE, MEM}}, \
3170 {"general_movdst_operand", {SUBREG, REG, MEM}}, \
3171 {"greater_comparison_operator", {GT,GE,GTU,GEU}}, \
3172 {"int_gpr_dest", {SUBREG, REG}}, \
3173 {"inqhi_operand", {TRUNCATE}}, \
3174 {"less_comparison_operator", {LT,LE,LTU,LEU}}, \
3175 {"logical_operand", {SUBREG, REG, CONST_INT}}, \
3176 {"mextr_bit_offset", {CONST_INT}}, \
3177 {"noncommutative_float_operator", {MINUS, DIV}}, \
3178 {"shmedia_6bit_operand", {SUBREG, REG, CONST_INT}}, \
3179 {"sh_register_operand", {REG, SUBREG, CONST_INT}}, \
3180 {"target_reg_operand", {SUBREG, REG}}, \
3181 {"target_operand", {SUBREG, REG, LABEL_REF, SYMBOL_REF, CONST, UNSPEC}},\
3182 {"trunc_hi_operand", {SUBREG, REG, TRUNCATE}}, \
3183 {"register_operand", {SUBREG, REG}}, \
3184 {"sh_const_vec", {CONST_VECTOR}}, \
3185 {"sh_1el_vec", {CONST_VECTOR, PARALLEL}}, \
3186 {"sh_rep_vec", {CONST_VECTOR, PARALLEL}}, \
3187 {"symbol_ref_operand", {SYMBOL_REF}}, \
3188 {"unary_float_operator", {ABS, NEG, SQRT}}, \
3190 #define SPECIAL_MODE_PREDICATES \
3191 "any_register_operand", \
3192 "int_gpr_dest", \
3193 "trunc_hi_operand", \
3194 /* This line intentionally left blank. */
3196 #define any_register_operand register_operand
3198 /* Define this macro if it is advisable to hold scalars in registers
3199 in a wider mode than that declared by the program. In such cases,
3200 the value is constrained to be within the bounds of the declared
3201 type, but kept valid in the wider mode. The signedness of the
3202 extension may differ from that of the type.
3204 Leaving the unsignedp unchanged gives better code than always setting it
3205 to 0. This is despite the fact that we have only signed char and short
3206 load instructions. */
3207 #define PROMOTE_MODE(MODE, UNSIGNEDP, TYPE) \
3208 if (GET_MODE_CLASS (MODE) == MODE_INT \
3209 && GET_MODE_SIZE (MODE) < UNITS_PER_WORD) \
3210 (UNSIGNEDP) = ((MODE) == SImode ? 0 : (UNSIGNEDP)), \
3211 (MODE) = (TARGET_SH1 ? SImode : DImode);
3213 /* Defining PROMOTE_FUNCTION_ARGS eliminates some unnecessary zero/sign
3214 extensions applied to char/short functions arguments. Defining
3215 PROMOTE_FUNCTION_RETURN does the same for function returns. */
3217 #define PROMOTE_FUNCTION_ARGS
3218 #define PROMOTE_FUNCTION_RETURN
3220 #define MAX_FIXED_MODE_SIZE (TARGET_SH5 ? 128 : 64)
3222 /* ??? Define ACCUMULATE_OUTGOING_ARGS? This is more efficient than pushing
3223 and poping arguments. However, we do have push/pop instructions, and
3224 rather limited offsets (4 bits) in load/store instructions, so it isn't
3225 clear if this would give better code. If implemented, should check for
3226 compatibility problems. */
3228 #define SH_DYNAMIC_SHIFT_COST \
3229 (TARGET_HARD_SH4 ? 1 : TARGET_SH3 ? (TARGET_SMALLCODE ? 1 : 2) : 20)
3232 #define NUM_MODES_FOR_MODE_SWITCHING { FP_MODE_NONE }
3234 #define OPTIMIZE_MODE_SWITCHING(ENTITY) TARGET_SH4
3236 #define NORMAL_MODE(ENTITY) \
3237 (sh_cfun_interrupt_handler_p () ? FP_MODE_NONE \
3238 : TARGET_FPU_SINGLE ? FP_MODE_SINGLE \
3239 : FP_MODE_DOUBLE)
3241 #define EPILOGUE_USES(REGNO) ((TARGET_SH2E || TARGET_SH4) \
3242 && (REGNO) == FPSCR_REG)
3244 #define MODE_NEEDED(ENTITY, INSN) \
3245 (recog_memoized (INSN) >= 0 \
3246 ? get_attr_fp_mode (INSN) \
3247 : FP_MODE_NONE)
3249 #define MODE_PRIORITY_TO_MODE(ENTITY, N) \
3250 ((TARGET_FPU_SINGLE != 0) ^ (N) ? FP_MODE_SINGLE : FP_MODE_DOUBLE)
3252 #define EMIT_MODE_SET(ENTITY, MODE, HARD_REGS_LIVE) \
3253 fpscr_set_from_mem ((MODE), (HARD_REGS_LIVE))
3255 #define MD_CAN_REDIRECT_BRANCH(INSN, SEQ) \
3256 sh_can_redirect_branch ((INSN), (SEQ))
3258 #define DWARF_FRAME_RETURN_COLUMN \
3259 (TARGET_SH5 ? DWARF_FRAME_REGNUM (PR_MEDIA_REG) : DWARF_FRAME_REGNUM (PR_REG))
3261 #define EH_RETURN_DATA_REGNO(N) \
3262 ((N) < 4 ? (N) + (TARGET_SH5 ? 2 : 4) : INVALID_REGNUM)
3264 #define EH_RETURN_STACKADJ_RTX gen_rtx_REG (Pmode, STATIC_CHAIN_REGNUM)
3266 #if (defined CRT_BEGIN || defined CRT_END) && ! __SHMEDIA__
3267 /* SH constant pool breaks the devices in crtstuff.c to control section
3268 in where code resides. We have to write it as asm code. */
3269 #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
3270 asm (SECTION_OP "\n\
3271 mov.l 1f,r1\n\
3272 mova 2f,r0\n\
3273 braf r1\n\
3274 lds r0,pr\n\
3275 0: .p2align 2\n\
3276 1: .long " USER_LABEL_PREFIX #FUNC " - 0b\n\
3277 2:\n" TEXT_SECTION_ASM_OP);
3278 #endif /* (defined CRT_BEGIN || defined CRT_END) && ! __SHMEDIA__ */
3280 #define ALLOCATE_INITIAL_VALUE(hard_reg) \
3281 (REGNO (hard_reg) == (TARGET_SH5 ? PR_MEDIA_REG : PR_REG) \
3282 ? (current_function_is_leaf && ! sh_pr_n_sets () \
3283 ? (hard_reg) \
3284 : gen_rtx_MEM (Pmode, TARGET_SH5 \
3285 ? (plus_constant (arg_pointer_rtx, \
3286 TARGET_SHMEDIA64 ? -8 : -4)) \
3287 : frame_pointer_rtx)) \
3288 : NULL_RTX)
3290 #endif /* ! GCC_SH_H */