OSDN Git Service

gcc/
[pf3gnuchains/gcc-fork.git] / gcc / config / sh / sh.h
1 /* Definitions of target machine for GNU compiler for Renesas / SuperH SH.
2    Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
3    2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
4    Free Software Foundation, Inc.
5    Contributed by Steve Chamberlain (sac@cygnus.com).
6    Improved by Jim Wilson (wilson@cygnus.com).
7
8 This file is part of GCC.
9
10 GCC is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 3, or (at your option)
13 any later version.
14
15 GCC is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with GCC; see the file COPYING3.  If not see
22 <http://www.gnu.org/licenses/>.  */
23
24 #ifndef GCC_SH_H
25 #define GCC_SH_H
26
27 #include "config/vxworks-dummy.h"
28
29 #define TARGET_VERSION \
30   fputs (" (Hitachi SH)", stderr);
31
32 /* Unfortunately, insn-attrtab.c doesn't include insn-codes.h.  We can't
33    include it here, because bconfig.h is also included by gencodes.c .  */
34 /* ??? No longer true.  */
35 extern int code_for_indirect_jump_scratch;
36
37 #define TARGET_CPU_CPP_BUILTINS() \
38 do { \
39   builtin_define ("__sh__"); \
40   builtin_assert ("cpu=sh"); \
41   builtin_assert ("machine=sh"); \
42   switch ((int) sh_cpu) \
43     { \
44     case PROCESSOR_SH1: \
45       builtin_define ("__sh1__"); \
46       break; \
47     case PROCESSOR_SH2: \
48       builtin_define ("__sh2__"); \
49       break; \
50     case PROCESSOR_SH2E: \
51       builtin_define ("__SH2E__"); \
52       break; \
53     case PROCESSOR_SH2A: \
54       builtin_define ("__SH2A__"); \
55       builtin_define (TARGET_SH2A_DOUBLE \
56                       ? (TARGET_FPU_SINGLE ? "__SH2A_SINGLE__" : "__SH2A_DOUBLE__") \
57                       : TARGET_FPU_ANY ? "__SH2A_SINGLE_ONLY__" \
58                       : "__SH2A_NOFPU__"); \
59       break; \
60     case PROCESSOR_SH3: \
61       builtin_define ("__sh3__"); \
62       builtin_define ("__SH3__"); \
63       if (TARGET_HARD_SH4) \
64         builtin_define ("__SH4_NOFPU__"); \
65       break; \
66     case PROCESSOR_SH3E: \
67       builtin_define (TARGET_HARD_SH4 ? "__SH4_SINGLE_ONLY__" : "__SH3E__"); \
68       break; \
69     case PROCESSOR_SH4: \
70       builtin_define (TARGET_FPU_SINGLE ? "__SH4_SINGLE__" : "__SH4__"); \
71       break; \
72     case PROCESSOR_SH4A: \
73       builtin_define ("__SH4A__"); \
74       builtin_define (TARGET_SH4 \
75                       ? (TARGET_FPU_SINGLE ? "__SH4_SINGLE__" : "__SH4__") \
76                       : TARGET_FPU_ANY ? "__SH4_SINGLE_ONLY__" \
77                       : "__SH4_NOFPU__"); \
78       break; \
79     case PROCESSOR_SH5: \
80       { \
81         builtin_define_with_value ("__SH5__", \
82                                    TARGET_SHMEDIA64 ? "64" : "32", 0); \
83         builtin_define_with_value ("__SHMEDIA__", \
84                                    TARGET_SHMEDIA ? "1" : "0", 0); \
85         if (! TARGET_FPU_DOUBLE) \
86           builtin_define ("__SH4_NOFPU__"); \
87       } \
88     } \
89   if (TARGET_FPU_ANY) \
90     builtin_define ("__SH_FPU_ANY__"); \
91   if (TARGET_FPU_DOUBLE) \
92     builtin_define ("__SH_FPU_DOUBLE__"); \
93   if (TARGET_HITACHI) \
94     builtin_define ("__HITACHI__"); \
95   if (TARGET_FMOVD) \
96     builtin_define ("__FMOVD_ENABLED__"); \
97   builtin_define (TARGET_LITTLE_ENDIAN \
98                   ? "__LITTLE_ENDIAN__" : "__BIG_ENDIAN__"); \
99 } while (0)
100
101 /* Value should be nonzero if functions must have frame pointers.
102    Zero means the frame pointer need not be set up (and parms may be accessed
103    via the stack pointer) in functions that seem suitable.  */
104
105 #ifndef SUBTARGET_FRAME_POINTER_REQUIRED
106 #define SUBTARGET_FRAME_POINTER_REQUIRED 0
107 #endif
108
109 #define CONDITIONAL_REGISTER_USAGE do                                   \
110 {                                                                       \
111   int regno;                                                            \
112   for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno ++)              \
113     if (! VALID_REGISTER_P (regno))                                     \
114       fixed_regs[regno] = call_used_regs[regno] = 1;                    \
115   /* R8 and R9 are call-clobbered on SH5, but not on earlier SH ABIs.  */ \
116   if (TARGET_SH5)                                                       \
117     {                                                                   \
118       call_used_regs[FIRST_GENERAL_REG + 8]                             \
119         = call_used_regs[FIRST_GENERAL_REG + 9] = 1;                    \
120       call_really_used_regs[FIRST_GENERAL_REG + 8]                      \
121         = call_really_used_regs[FIRST_GENERAL_REG + 9] = 1;             \
122     }                                                                   \
123   if (TARGET_SHMEDIA)                                                   \
124     {                                                                   \
125       regno_reg_class[FIRST_GENERAL_REG] = GENERAL_REGS;                \
126       CLEAR_HARD_REG_SET (reg_class_contents[FP0_REGS]);                \
127       regno_reg_class[FIRST_FP_REG] = FP_REGS;                          \
128     }                                                                   \
129   if (flag_pic)                                                         \
130     {                                                                   \
131       fixed_regs[PIC_OFFSET_TABLE_REGNUM] = 1;                          \
132       call_used_regs[PIC_OFFSET_TABLE_REGNUM] = 1;                      \
133     }                                                                   \
134   /* Renesas saves and restores mac registers on call.  */              \
135   if (TARGET_HITACHI && ! TARGET_NOMACSAVE)                             \
136     {                                                                   \
137       call_really_used_regs[MACH_REG] = 0;                              \
138       call_really_used_regs[MACL_REG] = 0;                              \
139     }                                                                   \
140   for (regno = FIRST_FP_REG + (TARGET_LITTLE_ENDIAN != 0);              \
141        regno <= LAST_FP_REG; regno += 2)                                \
142     SET_HARD_REG_BIT (reg_class_contents[DF_HI_REGS], regno);           \
143   if (TARGET_SHMEDIA)                                                   \
144     {                                                                   \
145       for (regno = FIRST_TARGET_REG; regno <= LAST_TARGET_REG; regno ++)\
146         if (! fixed_regs[regno] && call_really_used_regs[regno])        \
147           SET_HARD_REG_BIT (reg_class_contents[SIBCALL_REGS], regno);   \
148     }                                                                   \
149   else                                                                  \
150     for (regno = FIRST_GENERAL_REG; regno <= LAST_GENERAL_REG; regno++) \
151       if (! fixed_regs[regno] && call_really_used_regs[regno])          \
152         SET_HARD_REG_BIT (reg_class_contents[SIBCALL_REGS], regno);     \
153 } while (0)
154 \f
155 /* Nonzero if this is an ELF target - compile time only */
156 #define TARGET_ELF 0
157
158 /* Nonzero if we should generate code using type 2E insns.  */
159 #define TARGET_SH2E (TARGET_SH2 && TARGET_SH_E)
160
161 /* Nonzero if we should generate code using type 2A insns.  */
162 #define TARGET_SH2A TARGET_HARD_SH2A
163 /* Nonzero if we should generate code using type 2A SF insns.  */
164 #define TARGET_SH2A_SINGLE (TARGET_SH2A && TARGET_SH2E)
165 /* Nonzero if we should generate code using type 2A DF insns.  */
166 #define TARGET_SH2A_DOUBLE (TARGET_HARD_SH2A_DOUBLE && TARGET_SH2A)
167
168 /* Nonzero if we should generate code using type 3E insns.  */
169 #define TARGET_SH3E (TARGET_SH3 && TARGET_SH_E)
170
171 /* Nonzero if the cache line size is 32.  */
172 #define TARGET_CACHE32 (TARGET_HARD_SH4 || TARGET_SH5)
173
174 /* Nonzero if we schedule for a superscalar implementation.  */
175 #define TARGET_SUPERSCALAR TARGET_HARD_SH4
176
177 /* Nonzero if the target has separate instruction and data caches.  */
178 #define TARGET_HARVARD (TARGET_HARD_SH4 || TARGET_SH5)
179
180 /* Nonzero if a double-precision FPU is available.  */
181 #define TARGET_FPU_DOUBLE \
182   ((target_flags & MASK_SH4) != 0 || TARGET_SH2A_DOUBLE)
183
184 /* Nonzero if an FPU is available.  */
185 #define TARGET_FPU_ANY (TARGET_SH2E || TARGET_FPU_DOUBLE)
186
187 /* Nonzero if we should generate code using type 4 insns.  */
188 #undef TARGET_SH4
189 #define TARGET_SH4 ((target_flags & MASK_SH4) != 0 && TARGET_SH1)
190
191 /* Nonzero if we're generating code for the common subset of
192    instructions present on both SH4a and SH4al-dsp.  */
193 #define TARGET_SH4A_ARCH TARGET_SH4A
194
195 /* Nonzero if we're generating code for SH4a, unless the use of the
196    FPU is disabled (which makes it compatible with SH4al-dsp).  */
197 #define TARGET_SH4A_FP (TARGET_SH4A_ARCH && TARGET_FPU_ANY)
198
199 /* Nonzero if we should generate code using the SHcompact instruction
200    set and 32-bit ABI.  */
201 #define TARGET_SHCOMPACT (TARGET_SH5 && TARGET_SH1)
202
203 /* Nonzero if we should generate code using the SHmedia instruction
204    set and ABI.  */
205 #define TARGET_SHMEDIA (TARGET_SH5 && ! TARGET_SH1)
206
207 /* Nonzero if we should generate code using the SHmedia ISA and 32-bit
208    ABI.  */
209 #define TARGET_SHMEDIA32 (TARGET_SH5 && ! TARGET_SH1 && TARGET_SH_E)
210
211 /* Nonzero if we should generate code using the SHmedia ISA and 64-bit
212    ABI.  */
213 #define TARGET_SHMEDIA64 (TARGET_SH5 && ! TARGET_SH1 && ! TARGET_SH_E)
214
215 /* Nonzero if we should generate code using SHmedia FPU instructions.  */
216 #define TARGET_SHMEDIA_FPU (TARGET_SHMEDIA && TARGET_FPU_DOUBLE)
217
218 /* This is not used by the SH2E calling convention  */
219 #define TARGET_VARARGS_PRETEND_ARGS(FUN_DECL) \
220   (TARGET_SH1 && ! TARGET_SH2E && ! TARGET_SH5 \
221    && ! (TARGET_HITACHI || sh_attr_renesas_p (FUN_DECL)))
222
223 #ifndef TARGET_CPU_DEFAULT
224 #define TARGET_CPU_DEFAULT SELECT_SH1
225 #define SUPPORT_SH1 1
226 #define SUPPORT_SH2E 1
227 #define SUPPORT_SH4 1
228 #define SUPPORT_SH4_SINGLE 1
229 #define SUPPORT_SH2A 1
230 #define SUPPORT_SH2A_SINGLE 1
231 #endif
232
233 #define TARGET_DIVIDE_INV \
234   (sh_div_strategy == SH_DIV_INV || sh_div_strategy == SH_DIV_INV_MINLAT \
235    || sh_div_strategy == SH_DIV_INV20U || sh_div_strategy == SH_DIV_INV20L \
236    || sh_div_strategy == SH_DIV_INV_CALL \
237    || sh_div_strategy == SH_DIV_INV_CALL2 || sh_div_strategy == SH_DIV_INV_FP)
238 #define TARGET_DIVIDE_FP (sh_div_strategy == SH_DIV_FP)
239 #define TARGET_DIVIDE_INV_FP (sh_div_strategy == SH_DIV_INV_FP)
240 #define TARGET_DIVIDE_CALL2 (sh_div_strategy == SH_DIV_CALL2)
241 #define TARGET_DIVIDE_INV_MINLAT (sh_div_strategy == SH_DIV_INV_MINLAT)
242 #define TARGET_DIVIDE_INV20U (sh_div_strategy == SH_DIV_INV20U)
243 #define TARGET_DIVIDE_INV20L (sh_div_strategy == SH_DIV_INV20L)
244 #define TARGET_DIVIDE_INV_CALL (sh_div_strategy == SH_DIV_INV_CALL)
245 #define TARGET_DIVIDE_INV_CALL2 (sh_div_strategy == SH_DIV_INV_CALL2)
246 #define TARGET_DIVIDE_CALL_DIV1 (sh_div_strategy == SH_DIV_CALL_DIV1)
247 #define TARGET_DIVIDE_CALL_FP (sh_div_strategy == SH_DIV_CALL_FP)
248 #define TARGET_DIVIDE_CALL_TABLE (sh_div_strategy == SH_DIV_CALL_TABLE)
249
250 #define SELECT_SH1               (MASK_SH1)
251 #define SELECT_SH2               (MASK_SH2 | SELECT_SH1)
252 #define SELECT_SH2E              (MASK_SH_E | MASK_SH2 | MASK_SH1 \
253                                   | MASK_FPU_SINGLE)
254 #define SELECT_SH2A              (MASK_SH_E | MASK_HARD_SH2A \
255                                   | MASK_HARD_SH2A_DOUBLE \
256                                   | MASK_SH2 | MASK_SH1)
257 #define SELECT_SH2A_NOFPU        (MASK_HARD_SH2A | MASK_SH2 | MASK_SH1)
258 #define SELECT_SH2A_SINGLE_ONLY  (MASK_SH_E | MASK_HARD_SH2A | MASK_SH2 \
259                                   | MASK_SH1 | MASK_FPU_SINGLE)
260 #define SELECT_SH2A_SINGLE       (MASK_SH_E | MASK_HARD_SH2A \
261                                   | MASK_FPU_SINGLE | MASK_HARD_SH2A_DOUBLE \
262                                   | MASK_SH2 | MASK_SH1)
263 #define SELECT_SH3               (MASK_SH3 | SELECT_SH2)
264 #define SELECT_SH3E              (MASK_SH_E | MASK_FPU_SINGLE | SELECT_SH3)
265 #define SELECT_SH4_NOFPU         (MASK_HARD_SH4 | SELECT_SH3)
266 #define SELECT_SH4_SINGLE_ONLY   (MASK_HARD_SH4 | SELECT_SH3E)
267 #define SELECT_SH4               (MASK_SH4 | MASK_SH_E | MASK_HARD_SH4 \
268                                   | SELECT_SH3)
269 #define SELECT_SH4_SINGLE        (MASK_FPU_SINGLE | SELECT_SH4)
270 #define SELECT_SH4A_NOFPU        (MASK_SH4A | SELECT_SH4_NOFPU)
271 #define SELECT_SH4A_SINGLE_ONLY  (MASK_SH4A | SELECT_SH4_SINGLE_ONLY)
272 #define SELECT_SH4A              (MASK_SH4A | SELECT_SH4)
273 #define SELECT_SH4A_SINGLE       (MASK_SH4A | SELECT_SH4_SINGLE)
274 #define SELECT_SH5_64MEDIA       (MASK_SH5 | MASK_SH4)
275 #define SELECT_SH5_64MEDIA_NOFPU (MASK_SH5)
276 #define SELECT_SH5_32MEDIA       (MASK_SH5 | MASK_SH4 | MASK_SH_E)
277 #define SELECT_SH5_32MEDIA_NOFPU (MASK_SH5 | MASK_SH_E)
278 #define SELECT_SH5_COMPACT       (MASK_SH5 | MASK_SH4 | SELECT_SH3E)
279 #define SELECT_SH5_COMPACT_NOFPU (MASK_SH5 | SELECT_SH3)
280
281 #if SUPPORT_SH1
282 #define SUPPORT_SH2 1
283 #endif
284 #if SUPPORT_SH2
285 #define SUPPORT_SH3 1
286 #define SUPPORT_SH2A_NOFPU 1
287 #endif
288 #if SUPPORT_SH3
289 #define SUPPORT_SH4_NOFPU 1
290 #endif
291 #if SUPPORT_SH4_NOFPU
292 #define SUPPORT_SH4A_NOFPU 1
293 #define SUPPORT_SH4AL 1
294 #endif
295
296 #if SUPPORT_SH2E
297 #define SUPPORT_SH3E 1
298 #define SUPPORT_SH2A_SINGLE_ONLY 1
299 #endif
300 #if SUPPORT_SH3E
301 #define SUPPORT_SH4_SINGLE_ONLY 1
302 #endif
303 #if SUPPORT_SH4_SINGLE_ONLY
304 #define SUPPORT_SH4A_SINGLE_ONLY 1
305 #endif
306
307 #if SUPPORT_SH4
308 #define SUPPORT_SH4A 1
309 #endif
310
311 #if SUPPORT_SH4_SINGLE
312 #define SUPPORT_SH4A_SINGLE 1
313 #endif
314
315 #if SUPPORT_SH5_COMPAT
316 #define SUPPORT_SH5_32MEDIA 1
317 #endif
318
319 #if SUPPORT_SH5_COMPACT_NOFPU
320 #define SUPPORT_SH5_32MEDIA_NOFPU 1
321 #endif
322
323 #define SUPPORT_ANY_SH5_32MEDIA \
324   (SUPPORT_SH5_32MEDIA || SUPPORT_SH5_32MEDIA_NOFPU)
325 #define SUPPORT_ANY_SH5_64MEDIA \
326   (SUPPORT_SH5_64MEDIA || SUPPORT_SH5_64MEDIA_NOFPU)
327 #define SUPPORT_ANY_SH5 \
328   (SUPPORT_ANY_SH5_32MEDIA || SUPPORT_ANY_SH5_64MEDIA)
329
330 /* Reset all target-selection flags.  */
331 #define MASK_ARCH (MASK_SH1 | MASK_SH2 | MASK_SH3 | MASK_SH_E | MASK_SH4 \
332                    | MASK_HARD_SH2A | MASK_HARD_SH2A_DOUBLE | MASK_SH4A \
333                    | MASK_HARD_SH4 | MASK_FPU_SINGLE | MASK_SH5)
334
335 /* This defaults us to big-endian.  */
336 #ifndef TARGET_ENDIAN_DEFAULT
337 #define TARGET_ENDIAN_DEFAULT 0
338 #endif
339
340 #ifndef TARGET_OPT_DEFAULT
341 #define TARGET_OPT_DEFAULT  MASK_ADJUST_UNROLL
342 #endif
343
344 #define TARGET_DEFAULT \
345   (TARGET_CPU_DEFAULT | TARGET_ENDIAN_DEFAULT | TARGET_OPT_DEFAULT)
346
347 #ifndef SH_MULTILIB_CPU_DEFAULT
348 #define SH_MULTILIB_CPU_DEFAULT "m1"
349 #endif
350
351 #if TARGET_ENDIAN_DEFAULT
352 #define MULTILIB_DEFAULTS { "ml", SH_MULTILIB_CPU_DEFAULT }
353 #else
354 #define MULTILIB_DEFAULTS { "mb", SH_MULTILIB_CPU_DEFAULT }
355 #endif
356
357 #define CPP_SPEC " %(subtarget_cpp_spec) "
358
359 #ifndef SUBTARGET_CPP_SPEC
360 #define SUBTARGET_CPP_SPEC ""
361 #endif
362
363 #ifndef SUBTARGET_EXTRA_SPECS
364 #define SUBTARGET_EXTRA_SPECS
365 #endif
366
367 #define EXTRA_SPECS                                             \
368   { "subtarget_cpp_spec", SUBTARGET_CPP_SPEC },                 \
369   { "link_emul_prefix", LINK_EMUL_PREFIX },                     \
370   { "link_default_cpu_emul", LINK_DEFAULT_CPU_EMUL },           \
371   { "subtarget_link_emul_suffix", SUBTARGET_LINK_EMUL_SUFFIX }, \
372   { "subtarget_link_spec", SUBTARGET_LINK_SPEC },               \
373   { "subtarget_asm_endian_spec", SUBTARGET_ASM_ENDIAN_SPEC },   \
374   { "subtarget_asm_relax_spec", SUBTARGET_ASM_RELAX_SPEC },     \
375   { "subtarget_asm_isa_spec", SUBTARGET_ASM_ISA_SPEC },         \
376   { "subtarget_asm_spec", SUBTARGET_ASM_SPEC },                 \
377   SUBTARGET_EXTRA_SPECS
378
379 #if TARGET_CPU_DEFAULT & MASK_HARD_SH4
380 #define SUBTARGET_ASM_RELAX_SPEC "%{!m1:%{!m2:%{!m3*:%{!m5*:-isa=sh4-up}}}}"
381 #else
382 #define SUBTARGET_ASM_RELAX_SPEC "%{m4*:-isa=sh4-up}"
383 #endif
384
385 #define SH_ASM_SPEC \
386  "%(subtarget_asm_endian_spec) %{mrelax:-relax %(subtarget_asm_relax_spec)}\
387 %(subtarget_asm_isa_spec) %(subtarget_asm_spec)\
388 %{m2a:--isa=sh2a} \
389 %{m2a-single:--isa=sh2a} \
390 %{m2a-single-only:--isa=sh2a} \
391 %{m2a-nofpu:--isa=sh2a-nofpu} \
392 %{m5-compact*:--isa=SHcompact} \
393 %{m5-32media*:--isa=SHmedia --abi=32} \
394 %{m5-64media*:--isa=SHmedia --abi=64} \
395 %{m4al:-dsp} %{mcut2-workaround:-cut2-workaround}"
396
397 #define ASM_SPEC SH_ASM_SPEC
398
399 #ifndef SUBTARGET_ASM_ENDIAN_SPEC
400 #if TARGET_ENDIAN_DEFAULT == MASK_LITTLE_ENDIAN
401 #define SUBTARGET_ASM_ENDIAN_SPEC "%{mb:-big} %{!mb:-little}"
402 #else
403 #define SUBTARGET_ASM_ENDIAN_SPEC "%{ml:-little} %{!ml:-big}"
404 #endif
405 #endif
406
407 #if STRICT_NOFPU == 1
408 /* Strict nofpu means that the compiler should tell the assembler
409    to reject FPU instructions. E.g. from ASM inserts.  */
410 #if TARGET_CPU_DEFAULT & MASK_HARD_SH4 && !(TARGET_CPU_DEFAULT & MASK_SH_E)
411 #define SUBTARGET_ASM_ISA_SPEC "%{!m1:%{!m2:%{!m3*:%{m4-nofpu|!m4*:%{!m5:-isa=sh4-nofpu}}}}}"
412 #else
413 /* If there were an -isa option for sh5-nofpu then it would also go here. */
414 #define SUBTARGET_ASM_ISA_SPEC \
415  "%{m4-nofpu:-isa=sh4-nofpu} " ASM_ISA_DEFAULT_SPEC
416 #endif
417 #else /* ! STRICT_NOFPU */
418 #define SUBTARGET_ASM_ISA_SPEC ASM_ISA_DEFAULT_SPEC
419 #endif
420
421 #ifndef SUBTARGET_ASM_SPEC
422 #define SUBTARGET_ASM_SPEC ""
423 #endif
424
425 #if TARGET_ENDIAN_DEFAULT == MASK_LITTLE_ENDIAN
426 #define LINK_EMUL_PREFIX "sh%{!mb:l}"
427 #else
428 #define LINK_EMUL_PREFIX "sh%{ml:l}"
429 #endif
430
431 #if TARGET_CPU_DEFAULT & MASK_SH5
432 #if TARGET_CPU_DEFAULT & MASK_SH_E
433 #define LINK_DEFAULT_CPU_EMUL "32"
434 #if TARGET_CPU_DEFAULT & MASK_SH1
435 #define ASM_ISA_SPEC_DEFAULT "--isa=SHcompact"
436 #else
437 #define ASM_ISA_SPEC_DEFAULT "--isa=SHmedia --abi=32"
438 #endif /* MASK_SH1 */
439 #else /* !MASK_SH_E */
440 #define LINK_DEFAULT_CPU_EMUL "64"
441 #define ASM_ISA_SPEC_DEFAULT "--isa=SHmedia --abi=64"
442 #endif /* MASK_SH_E */
443 #define ASM_ISA_DEFAULT_SPEC \
444 " %{!m1:%{!m2*:%{!m3*:%{!m4*:%{!m5*:" ASM_ISA_SPEC_DEFAULT "}}}}}"
445 #else /* !MASK_SH5 */
446 #define LINK_DEFAULT_CPU_EMUL ""
447 #define ASM_ISA_DEFAULT_SPEC ""
448 #endif /* MASK_SH5 */
449
450 #define SUBTARGET_LINK_EMUL_SUFFIX ""
451 #define SUBTARGET_LINK_SPEC ""
452
453 /* svr4.h redefines LINK_SPEC inappropriately, so go via SH_LINK_SPEC,
454    so that we can undo the damage without code replication.  */
455 #define LINK_SPEC SH_LINK_SPEC
456
457 #define SH_LINK_SPEC "\
458 -m %(link_emul_prefix)\
459 %{m5-compact*|m5-32media*:32}\
460 %{m5-64media*:64}\
461 %{!m1:%{!m2:%{!m3*:%{!m4*:%{!m5*:%(link_default_cpu_emul)}}}}}\
462 %(subtarget_link_emul_suffix) \
463 %{mrelax:-relax} %(subtarget_link_spec)"
464
465 #ifndef SH_DIV_STR_FOR_SIZE
466 #define SH_DIV_STR_FOR_SIZE "call"
467 #endif
468
469 #define DRIVER_SELF_SPECS "%{m2a:%{ml:%eSH2a does not support little-endian}}"
470
471 #define ASSEMBLER_DIALECT assembler_dialect
472
473 extern int assembler_dialect;
474
475 enum sh_divide_strategy_e {
476   /* SH5 strategies.  */
477   SH_DIV_CALL,
478   SH_DIV_CALL2,
479   SH_DIV_FP, /* We could do this also for SH4.  */
480   SH_DIV_INV,
481   SH_DIV_INV_MINLAT,
482   SH_DIV_INV20U,
483   SH_DIV_INV20L,
484   SH_DIV_INV_CALL,
485   SH_DIV_INV_CALL2,
486   SH_DIV_INV_FP,
487   /* SH1 .. SH4 strategies.  Because of the small number of registers
488      available, the compiler uses knowledge of the actual set of registers
489      being clobbered by the different functions called.  */
490   SH_DIV_CALL_DIV1, /* No FPU, medium size, highest latency.  */
491   SH_DIV_CALL_FP,     /* FPU needed, small size, high latency.  */
492   SH_DIV_CALL_TABLE,  /* No FPU, large size, medium latency. */
493   SH_DIV_INTRINSIC
494 };
495
496 extern enum sh_divide_strategy_e sh_div_strategy;
497
498 #ifndef SH_DIV_STRATEGY_DEFAULT
499 #define SH_DIV_STRATEGY_DEFAULT SH_DIV_CALL
500 #endif
501
502 #define SUBTARGET_OVERRIDE_OPTIONS (void) 0
503
504 \f
505 /* Target machine storage layout.  */
506
507 /* Define this if most significant bit is lowest numbered
508    in instructions that operate on numbered bit-fields.  */
509
510 #define BITS_BIG_ENDIAN  0
511
512 /* Define this if most significant byte of a word is the lowest numbered.  */
513 #define BYTES_BIG_ENDIAN (TARGET_LITTLE_ENDIAN == 0)
514
515 /* Define this if most significant word of a multiword number is the lowest
516    numbered.  */
517 #define WORDS_BIG_ENDIAN (TARGET_LITTLE_ENDIAN == 0)
518
519 #define MAX_BITS_PER_WORD 64
520
521 /* Width in bits of an `int'.  We want just 32-bits, even if words are
522    longer.  */
523 #define INT_TYPE_SIZE 32
524
525 /* Width in bits of a `long'.  */
526 #define LONG_TYPE_SIZE (TARGET_SHMEDIA64 ? 64 : 32)
527
528 /* Width in bits of a `long long'.  */
529 #define LONG_LONG_TYPE_SIZE 64
530
531 /* Width in bits of a `long double'.  */
532 #define LONG_DOUBLE_TYPE_SIZE 64
533
534 /* Width of a word, in units (bytes).  */
535 #define UNITS_PER_WORD  (TARGET_SHMEDIA ? 8 : 4)
536 #define MIN_UNITS_PER_WORD 4
537
538 /* Scaling factor for Dwarf data offsets for CFI information.
539    The dwarf2out.c default would use -UNITS_PER_WORD, which is -8 for
540    SHmedia; however, since we do partial register saves for the registers
541    visible to SHcompact, and for target registers for SHMEDIA32, we have
542    to allow saves that are only 4-byte aligned.  */
543 #define DWARF_CIE_DATA_ALIGNMENT -4
544
545 /* Width in bits of a pointer.
546    See also the macro `Pmode' defined below.  */
547 #define POINTER_SIZE  (TARGET_SHMEDIA64 ? 64 : 32)
548
549 /* Allocation boundary (in *bits*) for storing arguments in argument list.  */
550 #define PARM_BOUNDARY   (TARGET_SH5 ? 64 : 32)
551
552 /* Boundary (in *bits*) on which stack pointer should be aligned.  */
553 #define STACK_BOUNDARY  BIGGEST_ALIGNMENT
554
555 /* The log (base 2) of the cache line size, in bytes.  Processors prior to
556    SH2 have no actual cache, but they fetch code in chunks of 4 bytes.
557    The SH2/3 have 16 byte cache lines, and the SH4 has a 32 byte cache line */
558 #define CACHE_LOG (TARGET_CACHE32 ? 5 : TARGET_SH2 ? 4 : 2)
559
560 /* ABI given & required minimum allocation boundary (in *bits*) for the
561    code of a function.  */
562 #define FUNCTION_BOUNDARY (16 << TARGET_SHMEDIA)
563
564 /* On SH5, the lowest bit is used to indicate SHmedia functions, so
565    the vbit must go into the delta field of
566    pointers-to-member-functions.  */
567 #define TARGET_PTRMEMFUNC_VBIT_LOCATION \
568   (TARGET_SH5 ? ptrmemfunc_vbit_in_delta : ptrmemfunc_vbit_in_pfn)
569
570 /* Alignment of field after `int : 0' in a structure.  */
571 #define EMPTY_FIELD_BOUNDARY  32
572
573 /* No data type wants to be aligned rounder than this.  */
574 #define BIGGEST_ALIGNMENT  (TARGET_ALIGN_DOUBLE ? 64 : 32)
575
576 /* The best alignment to use in cases where we have a choice.  */
577 #define FASTEST_ALIGNMENT (TARGET_SH5 ? 64 : 32)
578
579 /* Make strings word-aligned so strcpy from constants will be faster.  */
580 #define CONSTANT_ALIGNMENT(EXP, ALIGN)  \
581   ((TREE_CODE (EXP) == STRING_CST       \
582     && (ALIGN) < FASTEST_ALIGNMENT)     \
583     ? FASTEST_ALIGNMENT : (ALIGN))
584
585 /* get_mode_alignment assumes complex values are always held in multiple
586    registers, but that is not the case on the SH; CQImode and CHImode are
587    held in a single integer register.  SH5 also holds CSImode and SCmode
588    values in integer registers.  This is relevant for argument passing on
589    SHcompact as we use a stack temp in order to pass CSImode by reference.  */
590 #define LOCAL_ALIGNMENT(TYPE, ALIGN) \
591   ((GET_MODE_CLASS (TYPE_MODE (TYPE)) == MODE_COMPLEX_INT \
592     || GET_MODE_CLASS (TYPE_MODE (TYPE)) == MODE_COMPLEX_FLOAT) \
593    ? (unsigned) MIN (BIGGEST_ALIGNMENT, GET_MODE_BITSIZE (TYPE_MODE (TYPE))) \
594    : (unsigned) DATA_ALIGNMENT(TYPE, ALIGN))
595
596 /* Make arrays of chars word-aligned for the same reasons.  */
597 #define DATA_ALIGNMENT(TYPE, ALIGN)             \
598   (TREE_CODE (TYPE) == ARRAY_TYPE               \
599    && TYPE_MODE (TREE_TYPE (TYPE)) == QImode    \
600    && (ALIGN) < FASTEST_ALIGNMENT ? FASTEST_ALIGNMENT : (ALIGN))
601
602 /* Number of bits which any structure or union's size must be a
603    multiple of.  Each structure or union's size is rounded up to a
604    multiple of this.  */
605 #define STRUCTURE_SIZE_BOUNDARY (TARGET_PADSTRUCT ? 32 : 8)
606
607 /* Set this nonzero if move instructions will actually fail to work
608    when given unaligned data.  */
609 #define STRICT_ALIGNMENT 1
610
611 /* If LABEL_AFTER_BARRIER demands an alignment, return its base 2 logarithm.  */
612 #define LABEL_ALIGN_AFTER_BARRIER(LABEL_AFTER_BARRIER) \
613   barrier_align (LABEL_AFTER_BARRIER)
614
615 #define LOOP_ALIGN(A_LABEL) \
616   ((! optimize || TARGET_HARD_SH4 || optimize_size) \
617    ? 0 : sh_loop_align (A_LABEL))
618
619 #define LABEL_ALIGN(A_LABEL) \
620 (                                                                       \
621   (PREV_INSN (A_LABEL)                                                  \
622    && NONJUMP_INSN_P (PREV_INSN (A_LABEL))                              \
623    && GET_CODE (PATTERN (PREV_INSN (A_LABEL))) == UNSPEC_VOLATILE       \
624    && XINT (PATTERN (PREV_INSN (A_LABEL)), 1) == UNSPECV_ALIGN)         \
625    /* explicit alignment insn in constant tables.  */                   \
626   ? INTVAL (XVECEXP (PATTERN (PREV_INSN (A_LABEL)), 0, 0))              \
627   : 0)
628
629 /* Jump tables must be 32 bit aligned, no matter the size of the element.  */
630 #define ADDR_VEC_ALIGN(ADDR_VEC) 2
631
632 /* The base two logarithm of the known minimum alignment of an insn length.  */
633 #define INSN_LENGTH_ALIGNMENT(A_INSN)                                   \
634   (NONJUMP_INSN_P (A_INSN)                                              \
635    ? 1 << TARGET_SHMEDIA                                                \
636    : JUMP_P (A_INSN) || CALL_P (A_INSN)                                 \
637    ? 1 << TARGET_SHMEDIA                                                \
638    : CACHE_LOG)
639 \f
640 /* Standard register usage.  */
641
642 /* Register allocation for the Renesas calling convention:
643
644         r0              arg return
645         r1..r3          scratch
646         r4..r7          args in
647         r8..r13         call saved
648         r14             frame pointer/call saved
649         r15             stack pointer
650         ap              arg pointer (doesn't really exist, always eliminated)
651         pr              subroutine return address
652         t               t bit
653         mach            multiply/accumulate result, high part
654         macl            multiply/accumulate result, low part.
655         fpul            fp/int communication register
656         rap             return address pointer register
657         fr0             fp arg return
658         fr1..fr3        scratch floating point registers
659         fr4..fr11       fp args in
660         fr12..fr15      call saved floating point registers  */
661
662 #define MAX_REGISTER_NAME_LENGTH 5
663 extern char sh_register_names[][MAX_REGISTER_NAME_LENGTH + 1];
664
665 #define SH_REGISTER_NAMES_INITIALIZER                                   \
666 {                                                                       \
667   "r0",   "r1",   "r2",   "r3",   "r4",   "r5",   "r6",   "r7",         \
668   "r8",   "r9",   "r10",  "r11",  "r12",  "r13",  "r14",  "r15",        \
669   "r16",  "r17",  "r18",  "r19",  "r20",  "r21",  "r22",  "r23",        \
670   "r24",  "r25",  "r26",  "r27",  "r28",  "r29",  "r30",  "r31",        \
671   "r32",  "r33",  "r34",  "r35",  "r36",  "r37",  "r38",  "r39",        \
672   "r40",  "r41",  "r42",  "r43",  "r44",  "r45",  "r46",  "r47",        \
673   "r48",  "r49",  "r50",  "r51",  "r52",  "r53",  "r54",  "r55",        \
674   "r56",  "r57",  "r58",  "r59",  "r60",  "r61",  "r62",  "r63",        \
675   "fr0",  "fr1",  "fr2",  "fr3",  "fr4",  "fr5",  "fr6",  "fr7",        \
676   "fr8",  "fr9",  "fr10", "fr11", "fr12", "fr13", "fr14", "fr15",       \
677   "fr16", "fr17", "fr18", "fr19", "fr20", "fr21", "fr22", "fr23",       \
678   "fr24", "fr25", "fr26", "fr27", "fr28", "fr29", "fr30", "fr31",       \
679   "fr32", "fr33", "fr34", "fr35", "fr36", "fr37", "fr38", "fr39",       \
680   "fr40", "fr41", "fr42", "fr43", "fr44", "fr45", "fr46", "fr47",       \
681   "fr48", "fr49", "fr50", "fr51", "fr52", "fr53", "fr54", "fr55",       \
682   "fr56", "fr57", "fr58", "fr59", "fr60", "fr61", "fr62", "fr63",       \
683   "tr0",  "tr1",  "tr2",  "tr3",  "tr4",  "tr5",  "tr6",  "tr7",        \
684   "xd0",  "xd2",  "xd4",  "xd6",  "xd8",  "xd10", "xd12", "xd14",       \
685   "gbr",  "ap",   "pr",   "t",    "mach", "macl", "fpul", "fpscr",      \
686   "rap",  "sfp"                                                         \
687 }
688
689 #define REGNAMES_ARR_INDEX_1(index) \
690   (sh_register_names[index])
691 #define REGNAMES_ARR_INDEX_2(index) \
692   REGNAMES_ARR_INDEX_1 ((index)), REGNAMES_ARR_INDEX_1 ((index)+1)
693 #define REGNAMES_ARR_INDEX_4(index) \
694   REGNAMES_ARR_INDEX_2 ((index)), REGNAMES_ARR_INDEX_2 ((index)+2)
695 #define REGNAMES_ARR_INDEX_8(index) \
696   REGNAMES_ARR_INDEX_4 ((index)), REGNAMES_ARR_INDEX_4 ((index)+4)
697 #define REGNAMES_ARR_INDEX_16(index) \
698   REGNAMES_ARR_INDEX_8 ((index)), REGNAMES_ARR_INDEX_8 ((index)+8)
699 #define REGNAMES_ARR_INDEX_32(index) \
700   REGNAMES_ARR_INDEX_16 ((index)), REGNAMES_ARR_INDEX_16 ((index)+16)
701 #define REGNAMES_ARR_INDEX_64(index) \
702   REGNAMES_ARR_INDEX_32 ((index)), REGNAMES_ARR_INDEX_32 ((index)+32)
703
704 #define REGISTER_NAMES \
705 { \
706   REGNAMES_ARR_INDEX_64 (0), \
707   REGNAMES_ARR_INDEX_64 (64), \
708   REGNAMES_ARR_INDEX_8 (128), \
709   REGNAMES_ARR_INDEX_8 (136), \
710   REGNAMES_ARR_INDEX_8 (144), \
711   REGNAMES_ARR_INDEX_2 (152) \
712 }
713
714 #define ADDREGNAMES_SIZE 32
715 #define MAX_ADDITIONAL_REGISTER_NAME_LENGTH 4
716 extern char sh_additional_register_names[ADDREGNAMES_SIZE] \
717   [MAX_ADDITIONAL_REGISTER_NAME_LENGTH + 1];
718
719 #define SH_ADDITIONAL_REGISTER_NAMES_INITIALIZER                        \
720 {                                                                       \
721   "dr0",  "dr2",  "dr4",  "dr6",  "dr8",  "dr10", "dr12", "dr14",       \
722   "dr16", "dr18", "dr20", "dr22", "dr24", "dr26", "dr28", "dr30",       \
723   "dr32", "dr34", "dr36", "dr38", "dr40", "dr42", "dr44", "dr46",       \
724   "dr48", "dr50", "dr52", "dr54", "dr56", "dr58", "dr60", "dr62"        \
725 }
726
727 #define ADDREGNAMES_REGNO(index) \
728   ((index < 32) ? (FIRST_FP_REG + (index) * 2) \
729    : (-1))
730
731 #define ADDREGNAMES_ARR_INDEX_1(index) \
732   { (sh_additional_register_names[index]), ADDREGNAMES_REGNO (index) }
733 #define ADDREGNAMES_ARR_INDEX_2(index) \
734   ADDREGNAMES_ARR_INDEX_1 ((index)), ADDREGNAMES_ARR_INDEX_1 ((index)+1)
735 #define ADDREGNAMES_ARR_INDEX_4(index) \
736   ADDREGNAMES_ARR_INDEX_2 ((index)), ADDREGNAMES_ARR_INDEX_2 ((index)+2)
737 #define ADDREGNAMES_ARR_INDEX_8(index) \
738   ADDREGNAMES_ARR_INDEX_4 ((index)), ADDREGNAMES_ARR_INDEX_4 ((index)+4)
739 #define ADDREGNAMES_ARR_INDEX_16(index) \
740   ADDREGNAMES_ARR_INDEX_8 ((index)), ADDREGNAMES_ARR_INDEX_8 ((index)+8)
741 #define ADDREGNAMES_ARR_INDEX_32(index) \
742   ADDREGNAMES_ARR_INDEX_16 ((index)), ADDREGNAMES_ARR_INDEX_16 ((index)+16)
743
744 #define ADDITIONAL_REGISTER_NAMES \
745 {                                       \
746   ADDREGNAMES_ARR_INDEX_32 (0)          \
747 }
748
749 /* Number of actual hardware registers.
750    The hardware registers are assigned numbers for the compiler
751    from 0 to just below FIRST_PSEUDO_REGISTER.
752    All registers that the compiler knows about must be given numbers,
753    even those that are not normally considered general registers.  */
754
755 /* There are many other relevant definitions in sh.md's md_constants.  */
756
757 #define FIRST_GENERAL_REG R0_REG
758 #define LAST_GENERAL_REG (FIRST_GENERAL_REG + (TARGET_SHMEDIA ? 63 : 15))
759 #define FIRST_FP_REG DR0_REG
760 #define LAST_FP_REG  (FIRST_FP_REG + \
761                       (TARGET_SHMEDIA_FPU ? 63 : TARGET_SH2E ? 15 : -1))
762 #define FIRST_XD_REG XD0_REG
763 #define LAST_XD_REG  (FIRST_XD_REG + ((TARGET_SH4 && TARGET_FMOVD) ? 7 : -1))
764 #define FIRST_TARGET_REG TR0_REG
765 #define LAST_TARGET_REG  (FIRST_TARGET_REG + (TARGET_SHMEDIA ? 7 : -1))
766
767 /* Registers that can be accessed through bank0 or bank1 depending on sr.md.  */
768
769 #define FIRST_BANKED_REG R0_REG
770 #define LAST_BANKED_REG R7_REG
771
772 #define BANKED_REGISTER_P(REGNO)                       \
773   IN_RANGE ((REGNO),                                   \
774             (unsigned HOST_WIDE_INT) FIRST_BANKED_REG, \
775             (unsigned HOST_WIDE_INT) LAST_BANKED_REG)
776
777 #define GENERAL_REGISTER_P(REGNO) \
778   IN_RANGE ((REGNO), \
779             (unsigned HOST_WIDE_INT) FIRST_GENERAL_REG, \
780             (unsigned HOST_WIDE_INT) LAST_GENERAL_REG)
781
782 #define GENERAL_OR_AP_REGISTER_P(REGNO) \
783   (GENERAL_REGISTER_P (REGNO) || ((REGNO) == AP_REG)    \
784    || ((REGNO) == FRAME_POINTER_REGNUM))
785
786 #define FP_REGISTER_P(REGNO) \
787   ((int) (REGNO) >= FIRST_FP_REG && (int) (REGNO) <= LAST_FP_REG)
788
789 #define XD_REGISTER_P(REGNO) \
790   ((int) (REGNO) >= FIRST_XD_REG && (int) (REGNO) <= LAST_XD_REG)
791
792 #define FP_OR_XD_REGISTER_P(REGNO) \
793   (FP_REGISTER_P (REGNO) || XD_REGISTER_P (REGNO))
794
795 #define FP_ANY_REGISTER_P(REGNO) \
796   (FP_REGISTER_P (REGNO) || XD_REGISTER_P (REGNO) || (REGNO) == FPUL_REG)
797
798 #define SPECIAL_REGISTER_P(REGNO) \
799   ((REGNO) == GBR_REG || (REGNO) == T_REG \
800    || (REGNO) == MACH_REG || (REGNO) == MACL_REG)
801
802 #define TARGET_REGISTER_P(REGNO) \
803   ((int) (REGNO) >= FIRST_TARGET_REG && (int) (REGNO) <= LAST_TARGET_REG)
804
805 #define SHMEDIA_REGISTER_P(REGNO) \
806   (GENERAL_REGISTER_P (REGNO) || FP_REGISTER_P (REGNO) \
807    || TARGET_REGISTER_P (REGNO))
808
809 /* This is to be used in CONDITIONAL_REGISTER_USAGE, to mark registers
810    that should be fixed.  */
811 #define VALID_REGISTER_P(REGNO) \
812   (SHMEDIA_REGISTER_P (REGNO) || XD_REGISTER_P (REGNO) \
813    || (REGNO) == AP_REG || (REGNO) == RAP_REG \
814    || (REGNO) == FRAME_POINTER_REGNUM \
815    || (TARGET_SH1 && (SPECIAL_REGISTER_P (REGNO) || (REGNO) == PR_REG)) \
816    || (TARGET_SH2E && (REGNO) == FPUL_REG))
817
818 /* The mode that should be generally used to store a register by
819    itself in the stack, or to load it back.  */
820 #define REGISTER_NATURAL_MODE(REGNO) \
821   (FP_REGISTER_P (REGNO) ? SFmode \
822    : XD_REGISTER_P (REGNO) ? DFmode \
823    : TARGET_SHMEDIA && ! HARD_REGNO_CALL_PART_CLOBBERED ((REGNO), DImode) \
824    ? DImode \
825    : SImode)
826
827 #define FIRST_PSEUDO_REGISTER 154
828
829 /* Don't count soft frame pointer.  */
830 #define DWARF_FRAME_REGISTERS (FIRST_PSEUDO_REGISTER - 1)
831
832 /* 1 for registers that have pervasive standard uses
833    and are not available for the register allocator.
834
835    Mach register is fixed 'cause it's only 10 bits wide for SH1.
836    It is 32 bits wide for SH2.  */
837
838 #define FIXED_REGISTERS                                                 \
839 {                                                                       \
840 /* Regular registers.  */                                               \
841   0,      0,      0,      0,      0,      0,      0,      0,            \
842   0,      0,      0,      0,      0,      0,      0,      1,            \
843   /* r16 is reserved, r18 is the former pr.  */                         \
844   1,      0,      0,      0,      0,      0,      0,      0,            \
845   /* r24 is reserved for the OS; r25, for the assembler or linker.  */  \
846   /* r26 is a global variable data pointer; r27 is for constants.  */   \
847   1,      1,      1,      1,      0,      0,      0,      0,            \
848   0,      0,      0,      0,      0,      0,      0,      0,            \
849   0,      0,      0,      0,      0,      0,      0,      0,            \
850   0,      0,      0,      0,      0,      0,      0,      0,            \
851   0,      0,      0,      0,      0,      0,      0,      1,            \
852 /* FP registers.  */                                                    \
853   0,      0,      0,      0,      0,      0,      0,      0,            \
854   0,      0,      0,      0,      0,      0,      0,      0,            \
855   0,      0,      0,      0,      0,      0,      0,      0,            \
856   0,      0,      0,      0,      0,      0,      0,      0,            \
857   0,      0,      0,      0,      0,      0,      0,      0,            \
858   0,      0,      0,      0,      0,      0,      0,      0,            \
859   0,      0,      0,      0,      0,      0,      0,      0,            \
860   0,      0,      0,      0,      0,      0,      0,      0,            \
861 /* Branch target registers.  */                                         \
862   0,      0,      0,      0,      0,      0,      0,      0,            \
863 /* XD registers.  */                                                    \
864   0,      0,      0,      0,      0,      0,      0,      0,            \
865 /*"gbr",  "ap",   "pr",   "t",    "mach", "macl", "fpul", "fpscr", */   \
866   1,      1,      1,      1,      1,      1,      0,      1,            \
867 /*"rap",  "sfp" */                                                      \
868   1,      1,                                                            \
869 }
870
871 /* 1 for registers not available across function calls.
872    These must include the FIXED_REGISTERS and also any
873    registers that can be used without being saved.
874    The latter must include the registers where values are returned
875    and the register where structure-value addresses are passed.
876    Aside from that, you can include as many other registers as you like.  */
877
878 #define CALL_USED_REGISTERS                                             \
879 {                                                                       \
880 /* Regular registers.  */                                               \
881   1,      1,      1,      1,      1,      1,      1,      1,            \
882   /* R8 and R9 are call-clobbered on SH5, but not on earlier SH ABIs.   \
883      Only the lower 32bits of R10-R14 are guaranteed to be preserved    \
884      across SH5 function calls.  */                                     \
885   0,      0,      0,      0,      0,      0,      0,      1,            \
886   1,      1,      1,      1,      1,      1,      1,      1,            \
887   1,      1,      1,      1,      0,      0,      0,      0,            \
888   0,      0,      0,      0,      1,      1,      1,      1,            \
889   1,      1,      1,      1,      0,      0,      0,      0,            \
890   0,      0,      0,      0,      0,      0,      0,      0,            \
891   0,      0,      0,      0,      1,      1,      1,      1,            \
892 /* FP registers.  */                                                    \
893   1,      1,      1,      1,      1,      1,      1,      1,            \
894   1,      1,      1,      1,      0,      0,      0,      0,            \
895   1,      1,      1,      1,      1,      1,      1,      1,            \
896   1,      1,      1,      1,      1,      1,      1,      1,            \
897   1,      1,      1,      1,      0,      0,      0,      0,            \
898   0,      0,      0,      0,      0,      0,      0,      0,            \
899   0,      0,      0,      0,      0,      0,      0,      0,            \
900   0,      0,      0,      0,      0,      0,      0,      0,            \
901 /* Branch target registers.  */                                         \
902   1,      1,      1,      1,      1,      0,      0,      0,            \
903 /* XD registers.  */                                                    \
904   1,      1,      1,      1,      1,      1,      0,      0,            \
905 /*"gbr",  "ap",   "pr",   "t",    "mach", "macl", "fpul", "fpscr", */   \
906   1,      1,      1,      1,      1,      1,      1,      1,            \
907 /*"rap",  "sfp" */                                                      \
908   1,      1,                                                            \
909 }
910
911 /* CONDITIONAL_REGISTER_USAGE might want to make a register call-used, yet
912    fixed, like PIC_OFFSET_TABLE_REGNUM.  */
913 #define CALL_REALLY_USED_REGISTERS CALL_USED_REGISTERS
914
915 /* Only the lower 32-bits of R10-R14 are guaranteed to be preserved
916    across SHcompact function calls.  We can't tell whether a called
917    function is SHmedia or SHcompact, so we assume it may be when
918    compiling SHmedia code with the 32-bit ABI, since that's the only
919    ABI that can be linked with SHcompact code.  */
920 #define HARD_REGNO_CALL_PART_CLOBBERED(REGNO,MODE) \
921   (TARGET_SHMEDIA32 \
922    && GET_MODE_SIZE (MODE) > 4 \
923    && (((REGNO) >= FIRST_GENERAL_REG + 10 \
924         && (REGNO) <= FIRST_GENERAL_REG + 15) \
925        || TARGET_REGISTER_P (REGNO) \
926        || (REGNO) == PR_MEDIA_REG))
927
928 /* Return number of consecutive hard regs needed starting at reg REGNO
929    to hold something of mode MODE.
930    This is ordinarily the length in words of a value of mode MODE
931    but can be less for certain modes in special long registers.
932
933    On the SH all but the XD regs are UNITS_PER_WORD bits wide.  */
934
935 #define HARD_REGNO_NREGS(REGNO, MODE) \
936    (XD_REGISTER_P (REGNO) \
937     ? ((GET_MODE_SIZE (MODE) + (2*UNITS_PER_WORD - 1)) / (2*UNITS_PER_WORD)) \
938     : (TARGET_SHMEDIA && FP_REGISTER_P (REGNO)) \
939     ? ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD/2 - 1) / (UNITS_PER_WORD/2)) \
940     : ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD))
941
942 /* Value is 1 if hard register REGNO can hold a value of machine-mode MODE.  */
943
944 #define HARD_REGNO_MODE_OK(REGNO, MODE)         \
945   sh_hard_regno_mode_ok ((REGNO), (MODE))
946
947 /* Value is 1 if it is a good idea to tie two pseudo registers
948    when one has mode MODE1 and one has mode MODE2.
949    If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2,
950    for any hard reg, then this must be 0 for correct output.
951    That's the case for xd registers: we don't hold SFmode values in
952    them, so we can't tie an SFmode pseudos with one in another
953    floating-point mode.  */
954
955 #define MODES_TIEABLE_P(MODE1, MODE2) \
956   ((MODE1) == (MODE2) \
957    || (TARGET_SHMEDIA \
958        && GET_MODE_SIZE (MODE1) == GET_MODE_SIZE (MODE2) \
959        && INTEGRAL_MODE_P (MODE1) && INTEGRAL_MODE_P (MODE2)) \
960    || (GET_MODE_CLASS (MODE1) == GET_MODE_CLASS (MODE2) \
961        && (TARGET_SHMEDIA ? ((GET_MODE_SIZE (MODE1) <= 4) \
962                               && (GET_MODE_SIZE (MODE2) <= 4)) \
963                           : ((MODE1) != SFmode && (MODE2) != SFmode))))
964
965 /* A C expression that is nonzero if hard register NEW_REG can be
966    considered for use as a rename register for OLD_REG register */
967
968 #define HARD_REGNO_RENAME_OK(OLD_REG, NEW_REG) \
969    sh_hard_regno_rename_ok (OLD_REG, NEW_REG)
970
971 /* Specify the registers used for certain standard purposes.
972    The values of these macros are register numbers.  */
973
974 /* Define this if the program counter is overloaded on a register.  */
975 /* #define PC_REGNUM            15*/
976
977 /* Register to use for pushing function arguments.  */
978 #define STACK_POINTER_REGNUM    SP_REG
979
980 /* Base register for access to local variables of the function.  */
981 #define HARD_FRAME_POINTER_REGNUM       FP_REG
982
983 /* Base register for access to local variables of the function.  */
984 #define FRAME_POINTER_REGNUM    153
985
986 /* Fake register that holds the address on the stack of the
987    current function's return address.  */
988 #define RETURN_ADDRESS_POINTER_REGNUM RAP_REG
989
990 /* Register to hold the addressing base for position independent
991    code access to data items.  */
992 #define PIC_OFFSET_TABLE_REGNUM (flag_pic ? PIC_REG : INVALID_REGNUM)
993
994 #define GOT_SYMBOL_NAME "*_GLOBAL_OFFSET_TABLE_"
995
996 /* Definitions for register eliminations.
997
998    We have three registers that can be eliminated on the SH.  First, the
999    frame pointer register can often be eliminated in favor of the stack
1000    pointer register.  Secondly, the argument pointer register can always be
1001    eliminated; it is replaced with either the stack or frame pointer.
1002    Third, there is the return address pointer, which can also be replaced
1003    with either the stack or the frame pointer.  */
1004
1005 /* This is an array of structures.  Each structure initializes one pair
1006    of eliminable registers.  The "from" register number is given first,
1007    followed by "to".  Eliminations of the same "from" register are listed
1008    in order of preference.  */
1009
1010 /* If you add any registers here that are not actually hard registers,
1011    and that have any alternative of elimination that doesn't always
1012    apply, you need to amend calc_live_regs to exclude it, because
1013    reload spills all eliminable registers where it sees an
1014    can_eliminate == 0 entry, thus making them 'live' .
1015    If you add any hard registers that can be eliminated in different
1016    ways, you have to patch reload to spill them only when all alternatives
1017    of elimination fail.  */
1018
1019 #define ELIMINABLE_REGS                                         \
1020 {{ HARD_FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM},            \
1021  { FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM},                 \
1022  { FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM},            \
1023  { RETURN_ADDRESS_POINTER_REGNUM, STACK_POINTER_REGNUM},        \
1024  { RETURN_ADDRESS_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM},   \
1025  { ARG_POINTER_REGNUM, STACK_POINTER_REGNUM},                   \
1026  { ARG_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM},}
1027
1028 /* Define the offset between two registers, one to be eliminated, and the other
1029    its replacement, at the start of a routine.  */
1030
1031 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
1032   OFFSET = initial_elimination_offset ((FROM), (TO))
1033
1034 /* Base register for access to arguments of the function.  */
1035 #define ARG_POINTER_REGNUM      AP_REG
1036
1037 /* Register in which the static-chain is passed to a function.  */
1038 #define STATIC_CHAIN_REGNUM     (TARGET_SH5 ? 1 : 3)
1039
1040 /* Don't default to pcc-struct-return, because we have already specified
1041    exactly how to return structures in the TARGET_RETURN_IN_MEMORY
1042    target hook.  */
1043
1044 #define DEFAULT_PCC_STRUCT_RETURN 0
1045
1046 #define SHMEDIA_REGS_STACK_ADJUST() \
1047   (TARGET_SHCOMPACT && crtl->saves_all_registers \
1048    ? (8 * (/* r28-r35 */ 8 + /* r44-r59 */ 16 + /* tr5-tr7 */ 3) \
1049       + (TARGET_FPU_ANY ? 4 * (/* fr36 - fr63 */ 28) : 0)) \
1050    : 0)
1051
1052 \f
1053 /* Define the classes of registers for register constraints in the
1054    machine description.  Also define ranges of constants.
1055
1056    One of the classes must always be named ALL_REGS and include all hard regs.
1057    If there is more than one class, another class must be named NO_REGS
1058    and contain no registers.
1059
1060    The name GENERAL_REGS must be the name of a class (or an alias for
1061    another name such as ALL_REGS).  This is the class of registers
1062    that is allowed by "g" or "r" in a register constraint.
1063    Also, registers outside this class are allocated only when
1064    instructions express preferences for them.
1065
1066    The classes must be numbered in nondecreasing order; that is,
1067    a larger-numbered class must never be contained completely
1068    in a smaller-numbered class.
1069
1070    For any two classes, it is very desirable that there be another
1071    class that represents their union.  */
1072
1073 /* The SH has two sorts of general registers, R0 and the rest.  R0 can
1074    be used as the destination of some of the arithmetic ops. There are
1075    also some special purpose registers; the T bit register, the
1076    Procedure Return Register and the Multiply Accumulate Registers.  */
1077 /* Place GENERAL_REGS after FPUL_REGS so that it will be preferred by
1078    reg_class_subunion.  We don't want to have an actual union class
1079    of these, because it would only be used when both classes are calculated
1080    to give the same cost, but there is only one FPUL register.
1081    Besides, regclass fails to notice the different REGISTER_MOVE_COSTS
1082    applying to the actual instruction alternative considered.  E.g., the
1083    y/r alternative of movsi_ie is considered to have no more cost that
1084    the r/r alternative, which is patently untrue.  */
1085
1086 enum reg_class
1087 {
1088   NO_REGS,
1089   R0_REGS,
1090   PR_REGS,
1091   T_REGS,
1092   MAC_REGS,
1093   FPUL_REGS,
1094   SIBCALL_REGS,
1095   GENERAL_REGS,
1096   FP0_REGS,
1097   FP_REGS,
1098   DF_HI_REGS,
1099   DF_REGS,
1100   FPSCR_REGS,
1101   GENERAL_FP_REGS,
1102   GENERAL_DF_REGS,
1103   TARGET_REGS,
1104   ALL_REGS,
1105   LIM_REG_CLASSES
1106 };
1107
1108 #define N_REG_CLASSES  (int) LIM_REG_CLASSES
1109
1110 /* Give names of register classes as strings for dump file.  */
1111 #define REG_CLASS_NAMES \
1112 {                       \
1113   "NO_REGS",            \
1114   "R0_REGS",            \
1115   "PR_REGS",            \
1116   "T_REGS",             \
1117   "MAC_REGS",           \
1118   "FPUL_REGS",          \
1119   "SIBCALL_REGS",       \
1120   "GENERAL_REGS",       \
1121   "FP0_REGS",           \
1122   "FP_REGS",            \
1123   "DF_HI_REGS",         \
1124   "DF_REGS",            \
1125   "FPSCR_REGS",         \
1126   "GENERAL_FP_REGS",    \
1127   "GENERAL_DF_REGS",    \
1128   "TARGET_REGS",        \
1129   "ALL_REGS",           \
1130 }
1131
1132 /* Define which registers fit in which classes.
1133    This is an initializer for a vector of HARD_REG_SET
1134    of length N_REG_CLASSES.  */
1135
1136 #define REG_CLASS_CONTENTS                                              \
1137 {                                                                       \
1138 /* NO_REGS:  */                                                         \
1139   { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },       \
1140 /* R0_REGS:  */                                                         \
1141   { 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },       \
1142 /* PR_REGS:  */                                                         \
1143   { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00040000 },       \
1144 /* T_REGS:  */                                                          \
1145   { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00080000 },       \
1146 /* MAC_REGS:  */                                                        \
1147   { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00300000 },       \
1148 /* FPUL_REGS:  */                                                       \
1149   { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00400000 },       \
1150 /* SIBCALL_REGS: Initialized in CONDITIONAL_REGISTER_USAGE.  */ \
1151   { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },       \
1152 /* GENERAL_REGS:  */                                                    \
1153   { 0xffffffff, 0xffffffff, 0x00000000, 0x00000000, 0x03020000 },       \
1154 /* FP0_REGS:  */                                                        \
1155   { 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000 },       \
1156 /* FP_REGS:  */                                                         \
1157   { 0x00000000, 0x00000000, 0xffffffff, 0xffffffff, 0x00000000 },       \
1158 /* DF_HI_REGS:  Initialized in CONDITIONAL_REGISTER_USAGE.  */          \
1159   { 0x00000000, 0x00000000, 0xffffffff, 0xffffffff, 0x0000ff00 },       \
1160 /* DF_REGS:  */                                                         \
1161   { 0x00000000, 0x00000000, 0xffffffff, 0xffffffff, 0x0000ff00 },       \
1162 /* FPSCR_REGS:  */                                                      \
1163   { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00800000 },       \
1164 /* GENERAL_FP_REGS:  */                                                 \
1165   { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x03020000 },       \
1166 /* GENERAL_DF_REGS:  */                                                 \
1167   { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x0302ff00 },       \
1168 /* TARGET_REGS:  */                                                     \
1169   { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000000ff },       \
1170 /* ALL_REGS:  */                                                        \
1171   { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x03ffffff },       \
1172 }
1173
1174 /* The same information, inverted:
1175    Return the class number of the smallest class containing
1176    reg number REGNO.  This could be a conditional expression
1177    or could index an array.  */
1178
1179 extern enum reg_class regno_reg_class[FIRST_PSEUDO_REGISTER];
1180 #define REGNO_REG_CLASS(REGNO) regno_reg_class[(REGNO)]
1181
1182 /* The following macro defines cover classes for Integrated Register
1183    Allocator.  Cover classes is a set of non-intersected register
1184    classes covering all hard registers used for register allocation
1185    purpose.  Any move between two registers of a cover class should be
1186    cheaper than load or store of the registers.  The macro value is
1187    array of register classes with LIM_REG_CLASSES used as the end
1188    marker.  */
1189
1190 #define IRA_COVER_CLASSES                                                    \
1191 {                                                                            \
1192   GENERAL_REGS, FP_REGS, PR_REGS, T_REGS, MAC_REGS, TARGET_REGS,             \
1193   FPUL_REGS, LIM_REG_CLASSES                                                 \
1194 }
1195
1196 /* When this hook returns true for MODE, the compiler allows
1197    registers explicitly used in the rtl to be used as spill registers
1198    but prevents the compiler from extending the lifetime of these
1199    registers.  */
1200 #define TARGET_SMALL_REGISTER_CLASSES_FOR_MODE_P \
1201   sh_small_register_classes_for_mode_p
1202
1203 /* The order in which register should be allocated.  */
1204 /* Sometimes FP0_REGS becomes the preferred class of a floating point pseudo,
1205    and GENERAL_FP_REGS the alternate class.  Since FP0 is likely to be
1206    spilled or used otherwise, we better have the FP_REGS allocated first.  */
1207 #define REG_ALLOC_ORDER \
1208   {/* Caller-saved FPRs */ \
1209     65, 66, 67, 68, 69, 70, 71, 64, \
1210     72, 73, 74, 75, 80, 81, 82, 83, \
1211     84, 85, 86, 87, 88, 89, 90, 91, \
1212     92, 93, 94, 95, 96, 97, 98, 99, \
1213    /* Callee-saved FPRs */ \
1214     76, 77, 78, 79,100,101,102,103, \
1215    104,105,106,107,108,109,110,111, \
1216    112,113,114,115,116,117,118,119, \
1217    120,121,122,123,124,125,126,127, \
1218    136,137,138,139,140,141,142,143, \
1219    /* FPSCR */ 151, \
1220    /* Caller-saved GPRs (except 8/9 on SH1-4) */ \
1221      1,  2,  3,  7,  6,  5,  4,  0, \
1222      8,  9, 17, 19, 20, 21, 22, 23, \
1223     36, 37, 38, 39, 40, 41, 42, 43, \
1224     60, 61, 62, \
1225    /* SH1-4 callee-saved saved GPRs / SH5 partially-saved GPRs */ \
1226     10, 11, 12, 13, 14, 18, \
1227     /* SH5 callee-saved GPRs */ \
1228     28, 29, 30, 31, 32, 33, 34, 35, \
1229     44, 45, 46, 47, 48, 49, 50, 51, \
1230     52, 53, 54, 55, 56, 57, 58, 59, \
1231    /* FPUL */ 150, \
1232    /* SH5 branch target registers */ \
1233    128,129,130,131,132,133,134,135, \
1234    /* Fixed registers */ \
1235     15, 16, 24, 25, 26, 27, 63,144, \
1236    145,146,147,148,149,152,153 }
1237
1238 /* The class value for index registers, and the one for base regs.  */
1239 #define INDEX_REG_CLASS \
1240   (!ALLOW_INDEXED_ADDRESS ? NO_REGS : TARGET_SHMEDIA ? GENERAL_REGS : R0_REGS)
1241 #define BASE_REG_CLASS   GENERAL_REGS
1242 \f
1243 /* Defines for sh.md and constraints.md.  */
1244
1245 #define CONST_OK_FOR_I06(VALUE) (((HOST_WIDE_INT)(VALUE)) >= -32 \
1246                                  && ((HOST_WIDE_INT)(VALUE)) <= 31)
1247 #define CONST_OK_FOR_I08(VALUE) (((HOST_WIDE_INT)(VALUE))>= -128 \
1248                                  && ((HOST_WIDE_INT)(VALUE)) <= 127)
1249 #define CONST_OK_FOR_I10(VALUE) (((HOST_WIDE_INT)(VALUE)) >= -512 \
1250                                  && ((HOST_WIDE_INT)(VALUE)) <= 511)
1251 #define CONST_OK_FOR_I16(VALUE) (((HOST_WIDE_INT)(VALUE)) >= -32768 \
1252                                  && ((HOST_WIDE_INT)(VALUE)) <= 32767)
1253
1254 #define CONST_OK_FOR_J16(VALUE) \
1255   ((HOST_BITS_PER_WIDE_INT >= 64 && (VALUE) == (HOST_WIDE_INT) 0xffffffff) \
1256    || (HOST_BITS_PER_WIDE_INT >= 64 && (VALUE) == (HOST_WIDE_INT) -1 << 32))
1257
1258 #define CONST_OK_FOR_K08(VALUE) (((HOST_WIDE_INT)(VALUE))>= 0 \
1259                                  && ((HOST_WIDE_INT)(VALUE)) <= 255)
1260
1261 /* Given an rtx X being reloaded into a reg required to be
1262    in class CLASS, return the class of reg to actually use.
1263    In general this is just CLASS; but on some machines
1264    in some cases it is preferable to use a more restrictive class.  */
1265
1266 #define PREFERRED_RELOAD_CLASS(X, CLASS) \
1267   ((CLASS) == NO_REGS && TARGET_SHMEDIA \
1268    && (GET_CODE (X) == CONST_DOUBLE \
1269        || GET_CODE (X) == SYMBOL_REF \
1270        || PIC_ADDR_P (X)) \
1271    ? GENERAL_REGS \
1272    : (CLASS)) \
1273
1274 #if 0
1275 #define SECONDARY_INOUT_RELOAD_CLASS(CLASS,MODE,X,ELSE) \
1276   ((((REGCLASS_HAS_FP_REG (CLASS)                                       \
1277       && (REG_P (X)                                                     \
1278       && (GENERAL_OR_AP_REGISTER_P (REGNO (X))                          \
1279           || (FP_REGISTER_P (REGNO (X)) && (MODE) == SImode             \
1280               && TARGET_FMOVD))))                                       \
1281      || (REGCLASS_HAS_GENERAL_REG (CLASS)                               \
1282          && REG_P (X)                                                   \
1283          && FP_REGISTER_P (REGNO (X))))                                 \
1284     && ! TARGET_SHMEDIA                                                 \
1285     && ((MODE) == SFmode || (MODE) == SImode))                          \
1286    ? FPUL_REGS                                                          \
1287    : (((CLASS) == FPUL_REGS                                             \
1288        || (REGCLASS_HAS_FP_REG (CLASS)                                  \
1289            && ! TARGET_SHMEDIA && MODE == SImode))                      \
1290       && (MEM_P (X)                                                     \
1291           || (REG_P (X)                                                 \
1292               && (REGNO (X) >= FIRST_PSEUDO_REGISTER                    \
1293                   || REGNO (X) == T_REG                                 \
1294                   || system_reg_operand (X, VOIDmode)))))               \
1295    ? GENERAL_REGS                                                       \
1296    : (((CLASS) == TARGET_REGS                                           \
1297        || (TARGET_SHMEDIA && (CLASS) == SIBCALL_REGS))                  \
1298       && !satisfies_constraint_Csy (X)                                  \
1299       && (!REG_P (X) || ! GENERAL_REGISTER_P (REGNO (X))))              \
1300    ? GENERAL_REGS                                                       \
1301    : (((CLASS) == MAC_REGS || (CLASS) == PR_REGS)                       \
1302       && REG_P (X) && ! GENERAL_REGISTER_P (REGNO (X))                  \
1303       && (CLASS) != REGNO_REG_CLASS (REGNO (X)))                        \
1304    ? GENERAL_REGS                                                       \
1305    : ((CLASS) != GENERAL_REGS && REG_P (X)                              \
1306       && TARGET_REGISTER_P (REGNO (X)))                                 \
1307    ? GENERAL_REGS : (ELSE))
1308
1309 #define SECONDARY_OUTPUT_RELOAD_CLASS(CLASS,MODE,X) \
1310  SECONDARY_INOUT_RELOAD_CLASS(CLASS,MODE,X,NO_REGS)
1311
1312 #define SECONDARY_INPUT_RELOAD_CLASS(CLASS,MODE,X)  \
1313   ((REGCLASS_HAS_FP_REG (CLASS)                                         \
1314     && ! TARGET_SHMEDIA                                                 \
1315     && immediate_operand ((X), (MODE))                                  \
1316     && ! ((fp_zero_operand (X) || fp_one_operand (X))                   \
1317           && (MODE) == SFmode && fldi_ok ()))                           \
1318    ? R0_REGS                                                            \
1319    : ((CLASS) == FPUL_REGS                                              \
1320       && ((REG_P (X)                                                    \
1321            && (REGNO (X) == MACL_REG || REGNO (X) == MACH_REG           \
1322                || REGNO (X) == T_REG))                                  \
1323           || GET_CODE (X) == PLUS))                                     \
1324    ? GENERAL_REGS                                                       \
1325    : (CLASS) == FPUL_REGS && immediate_operand ((X), (MODE))            \
1326    ? (satisfies_constraint_I08 (X)                                      \
1327       ? GENERAL_REGS                                                    \
1328       : R0_REGS)                                                        \
1329    : ((CLASS) == FPSCR_REGS                                             \
1330       && ((REG_P (X) && REGNO (X) >= FIRST_PSEUDO_REGISTER)             \
1331           || (MEM_P (X) && GET_CODE (XEXP ((X), 0)) == PLUS)))          \
1332    ? GENERAL_REGS                                                       \
1333    : (REGCLASS_HAS_FP_REG (CLASS)                                       \
1334       && TARGET_SHMEDIA                                                 \
1335       && immediate_operand ((X), (MODE))                                \
1336       && (X) != CONST0_RTX (GET_MODE (X))                               \
1337       && GET_MODE (X) != V4SFmode)                                      \
1338    ? GENERAL_REGS                                                       \
1339    : (((MODE) == QImode || (MODE) == HImode)                            \
1340       && TARGET_SHMEDIA && inqhi_operand ((X), (MODE)))                 \
1341    ? GENERAL_REGS                                                       \
1342    : (TARGET_SHMEDIA && (CLASS) == GENERAL_REGS                         \
1343       && (GET_CODE (X) == LABEL_REF || PIC_ADDR_P (X)))                 \
1344    ? TARGET_REGS                                                        \
1345    : SECONDARY_INOUT_RELOAD_CLASS((CLASS),(MODE),(X), NO_REGS))
1346 #endif
1347
1348 /* Return the maximum number of consecutive registers
1349    needed to represent mode MODE in a register of class CLASS.
1350
1351    If TARGET_SHMEDIA, we need two FP registers per word.
1352    Otherwise we will need at most one register per word.  */
1353 #define CLASS_MAX_NREGS(CLASS, MODE) \
1354     (TARGET_SHMEDIA \
1355      && TEST_HARD_REG_BIT (reg_class_contents[CLASS], FIRST_FP_REG) \
1356      ? (GET_MODE_SIZE (MODE) + UNITS_PER_WORD/2 - 1) / (UNITS_PER_WORD/2) \
1357      : (GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
1358
1359 /* If defined, gives a class of registers that cannot be used as the
1360    operand of a SUBREG that changes the mode of the object illegally.  */
1361 /* ??? We need to renumber the internal numbers for the frnn registers
1362    when in little endian in order to allow mode size changes.  */
1363
1364 #define CANNOT_CHANGE_MODE_CLASS(FROM, TO, CLASS)                           \
1365   sh_cannot_change_mode_class (FROM, TO, CLASS)
1366 \f
1367 /* Stack layout; function entry, exit and calling.  */
1368
1369 /* Define the number of registers that can hold parameters.
1370    These macros are used only in other macro definitions below.  */
1371
1372 #define NPARM_REGS(MODE) \
1373   (TARGET_FPU_ANY && (MODE) == SFmode \
1374    ? (TARGET_SH5 ? 12 : 8) \
1375    : (TARGET_SH4 || TARGET_SH2A_DOUBLE) && (GET_MODE_CLASS (MODE) == MODE_FLOAT \
1376                     || GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT) \
1377    ? (TARGET_SH5 ? 12 : 8) \
1378    : (TARGET_SH5 ? 8 : 4))
1379
1380 #define FIRST_PARM_REG (FIRST_GENERAL_REG + (TARGET_SH5 ? 2 : 4))
1381 #define FIRST_RET_REG  (FIRST_GENERAL_REG + (TARGET_SH5 ? 2 : 0))
1382
1383 #define FIRST_FP_PARM_REG (FIRST_FP_REG + (TARGET_SH5 ? 0 : 4))
1384 #define FIRST_FP_RET_REG FIRST_FP_REG
1385
1386 /* Define this if pushing a word on the stack
1387    makes the stack pointer a smaller address.  */
1388 #define STACK_GROWS_DOWNWARD
1389
1390 /*  Define this macro to nonzero if the addresses of local variable slots
1391     are at negative offsets from the frame pointer.  */
1392 #define FRAME_GROWS_DOWNWARD 1
1393
1394 /* Offset from the frame pointer to the first local variable slot to
1395    be allocated.  */
1396 #define STARTING_FRAME_OFFSET  0
1397
1398 /* If we generate an insn to push BYTES bytes,
1399    this says how many the stack pointer really advances by.  */
1400 /* Don't define PUSH_ROUNDING, since the hardware doesn't do this.
1401    When PUSH_ROUNDING is not defined, PARM_BOUNDARY will cause gcc to
1402    do correct alignment.  */
1403 #if 0
1404 #define PUSH_ROUNDING(NPUSHED)  (((NPUSHED) + 3) & ~3)
1405 #endif
1406
1407 /* Offset of first parameter from the argument pointer register value.  */
1408 #define FIRST_PARM_OFFSET(FNDECL)  0
1409
1410 /* Value is the number of bytes of arguments automatically popped when
1411    calling a subroutine.
1412    CUM is the accumulated argument list.
1413
1414    On SHcompact, the call trampoline pops arguments off the stack.  */
1415 #define CALL_POPS_ARGS(CUM) (TARGET_SHCOMPACT ? (CUM).stack_regs * 8 : 0)
1416
1417 /* Some subroutine macros specific to this machine.  */
1418
1419 #define BASE_RETURN_VALUE_REG(MODE) \
1420   ((TARGET_FPU_ANY && ((MODE) == SFmode))                       \
1421    ? FIRST_FP_RET_REG                                   \
1422    : TARGET_FPU_ANY && (MODE) == SCmode         \
1423    ? FIRST_FP_RET_REG                                   \
1424    : (TARGET_FPU_DOUBLE                                 \
1425       && ((MODE) == DFmode || (MODE) == SFmode          \
1426           || (MODE) == DCmode || (MODE) == SCmode ))    \
1427    ? FIRST_FP_RET_REG                                   \
1428    : FIRST_RET_REG)
1429
1430 #define BASE_ARG_REG(MODE) \
1431   ((TARGET_SH2E && ((MODE) == SFmode))                  \
1432    ? FIRST_FP_PARM_REG                                  \
1433    : (TARGET_SH4 || TARGET_SH2A_DOUBLE) && (GET_MODE_CLASS (MODE) == MODE_FLOAT \
1434                     || GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT)\
1435    ? FIRST_FP_PARM_REG                                  \
1436    : FIRST_PARM_REG)
1437
1438 /* 1 if N is a possible register number for function argument passing.  */
1439 /* ??? There are some callers that pass REGNO as int, and others that pass
1440    it as unsigned.  We get warnings unless we do casts everywhere.  */
1441 #define FUNCTION_ARG_REGNO_P(REGNO) \
1442   (((unsigned) (REGNO) >= (unsigned) FIRST_PARM_REG                     \
1443     && (unsigned) (REGNO) < (unsigned) (FIRST_PARM_REG + NPARM_REGS (SImode)))\
1444    || (TARGET_FPU_ANY                                                   \
1445        && (unsigned) (REGNO) >= (unsigned) FIRST_FP_PARM_REG            \
1446        && (unsigned) (REGNO) < (unsigned) (FIRST_FP_PARM_REG            \
1447                                            + NPARM_REGS (SFmode))))
1448 \f
1449 /* Define a data type for recording info about an argument list
1450    during the scan of that argument list.  This data type should
1451    hold all necessary information about the function itself
1452    and about the args processed so far, enough to enable macros
1453    such as FUNCTION_ARG to determine where the next arg should go.
1454
1455    On SH, this is a single integer, which is a number of words
1456    of arguments scanned so far (including the invisible argument,
1457    if any, which holds the structure-value-address).
1458    Thus NARGREGS or more means all following args should go on the stack.  */
1459
1460 enum sh_arg_class { SH_ARG_INT = 0, SH_ARG_FLOAT = 1 };
1461 struct sh_args {
1462     int arg_count[2];
1463     int force_mem;
1464   /* Nonzero if a prototype is available for the function.  */
1465     int prototype_p;
1466   /* The number of an odd floating-point register, that should be used
1467      for the next argument of type float.  */
1468     int free_single_fp_reg;
1469   /* Whether we're processing an outgoing function call.  */
1470     int outgoing;
1471   /* The number of general-purpose registers that should have been
1472      used to pass partial arguments, that are passed totally on the
1473      stack.  On SHcompact, a call trampoline will pop them off the
1474      stack before calling the actual function, and, if the called
1475      function is implemented in SHcompact mode, the incoming arguments
1476      decoder will push such arguments back onto the stack.  For
1477      incoming arguments, STACK_REGS also takes into account other
1478      arguments passed by reference, that the decoder will also push
1479      onto the stack.  */
1480     int stack_regs;
1481   /* The number of general-purpose registers that should have been
1482      used to pass arguments, if the arguments didn't have to be passed
1483      by reference.  */
1484     int byref_regs;
1485   /* Set as by shcompact_byref if the current argument is to be passed
1486      by reference.  */
1487     int byref;
1488
1489   /* call_cookie is a bitmask used by call expanders, as well as
1490      function prologue and epilogues, to allow SHcompact to comply
1491      with the SH5 32-bit ABI, that requires 64-bit registers to be
1492      used even though only the lower 32-bit half is visible in
1493      SHcompact mode.  The strategy is to call SHmedia trampolines.
1494
1495      The alternatives for each of the argument-passing registers are
1496      (a) leave it unchanged; (b) pop it off the stack; (c) load its
1497      contents from the address in it; (d) add 8 to it, storing the
1498      result in the next register, then (c); (e) copy it from some
1499      floating-point register,
1500
1501      Regarding copies from floating-point registers, r2 may only be
1502      copied from dr0.  r3 may be copied from dr0 or dr2.  r4 maybe
1503      copied from dr0, dr2 or dr4.  r5 maybe copied from dr0, dr2,
1504      dr4 or dr6.  r6 may be copied from dr0, dr2, dr4, dr6 or dr8.
1505      r7 through to r9 may be copied from dr0, dr2, dr4, dr8, dr8 or
1506      dr10.
1507
1508      The bit mask is structured as follows:
1509
1510      - 1 bit to tell whether to set up a return trampoline.
1511
1512      - 3 bits to count the number consecutive registers to pop off the
1513        stack.
1514
1515      - 4 bits for each of r9, r8, r7 and r6.
1516
1517      - 3 bits for each of r5, r4, r3 and r2.
1518
1519      - 3 bits set to 0 (the most significant ones)
1520
1521         3           2            1           0
1522        1098 7654 3210 9876 5432 1098 7654 3210
1523        FLPF LPFL PFLP FFLP FFLP FFLP FFLP SSST
1524        2223 3344 4555 6666 7777 8888 9999 SSS-
1525
1526      - If F is set, the register must be copied from an FP register,
1527        whose number is encoded in the remaining bits.
1528
1529      - Else, if L is set, the register must be loaded from the address
1530        contained in it.  If the P bit is *not* set, the address of the
1531        following dword should be computed first, and stored in the
1532        following register.
1533
1534      - Else, if P is set, the register alone should be popped off the
1535        stack.
1536
1537      - After all this processing, the number of registers represented
1538        in SSS will be popped off the stack.  This is an optimization
1539        for pushing/popping consecutive registers, typically used for
1540        varargs and large arguments partially passed in registers.
1541
1542      - If T is set, a return trampoline will be set up for 64-bit
1543      return values to be split into 2 32-bit registers.  */
1544     long call_cookie;
1545
1546   /* This is set to nonzero when the call in question must use the Renesas ABI,
1547      even without the -mrenesas option.  */
1548     int renesas_abi;
1549 };
1550
1551 #define CALL_COOKIE_RET_TRAMP_SHIFT 0
1552 #define CALL_COOKIE_RET_TRAMP(VAL) ((VAL) << CALL_COOKIE_RET_TRAMP_SHIFT)
1553 #define CALL_COOKIE_STACKSEQ_SHIFT 1
1554 #define CALL_COOKIE_STACKSEQ(VAL) ((VAL) << CALL_COOKIE_STACKSEQ_SHIFT)
1555 #define CALL_COOKIE_STACKSEQ_GET(COOKIE) \
1556   (((COOKIE) >> CALL_COOKIE_STACKSEQ_SHIFT) & 7)
1557 #define CALL_COOKIE_INT_REG_SHIFT(REG) \
1558   (4 * (7 - (REG)) + (((REG) <= 2) ? ((REG) - 2) : 1) + 3)
1559 #define CALL_COOKIE_INT_REG(REG, VAL) \
1560   ((VAL) << CALL_COOKIE_INT_REG_SHIFT (REG))
1561 #define CALL_COOKIE_INT_REG_GET(COOKIE, REG) \
1562   (((COOKIE) >> CALL_COOKIE_INT_REG_SHIFT (REG)) & ((REG) < 4 ? 7 : 15))
1563
1564 #define CUMULATIVE_ARGS  struct sh_args
1565
1566 #define GET_SH_ARG_CLASS(MODE) \
1567   ((TARGET_FPU_ANY && (MODE) == SFmode) \
1568    ? SH_ARG_FLOAT \
1569    /* There's no mention of complex float types in the SH5 ABI, so we
1570       should presumably handle them as aggregate types.  */ \
1571    : TARGET_SH5 && GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT \
1572    ? SH_ARG_INT \
1573    : TARGET_FPU_DOUBLE && (GET_MODE_CLASS (MODE) == MODE_FLOAT \
1574                            || GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT) \
1575    ? SH_ARG_FLOAT : SH_ARG_INT)
1576
1577 #define ROUND_ADVANCE(SIZE) \
1578   (((SIZE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
1579
1580 /* Round a register number up to a proper boundary for an arg of mode
1581    MODE.
1582
1583    The SH doesn't care about double alignment, so we only
1584    round doubles to even regs when asked to explicitly.  */
1585
1586 #define ROUND_REG(CUM, MODE) \
1587    (((TARGET_ALIGN_DOUBLE                                       \
1588       || ((TARGET_SH4 || TARGET_SH2A_DOUBLE) && ((MODE) == DFmode || (MODE) == DCmode)  \
1589           && (CUM).arg_count[(int) SH_ARG_FLOAT] < NPARM_REGS (MODE)))\
1590      && GET_MODE_UNIT_SIZE ((MODE)) > UNITS_PER_WORD)           \
1591     ? ((CUM).arg_count[(int) GET_SH_ARG_CLASS (MODE)]           \
1592        + ((CUM).arg_count[(int) GET_SH_ARG_CLASS (MODE)] & 1))  \
1593     : (CUM).arg_count[(int) GET_SH_ARG_CLASS (MODE)])
1594
1595 /* Initialize a variable CUM of type CUMULATIVE_ARGS
1596    for a call to a function whose data type is FNTYPE.
1597    For a library call, FNTYPE is 0.
1598
1599    On SH, the offset always starts at 0: the first parm reg is always
1600    the same reg for a given argument class.
1601
1602    For TARGET_HITACHI, the structure value pointer is passed in memory.  */
1603
1604 #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, FNDECL, N_NAMED_ARGS) \
1605   sh_init_cumulative_args (& (CUM), (FNTYPE), (LIBNAME), (FNDECL), (N_NAMED_ARGS), VOIDmode)
1606
1607 #define INIT_CUMULATIVE_LIBCALL_ARGS(CUM, MODE, LIBNAME) \
1608   sh_init_cumulative_args (& (CUM), NULL_TREE, (LIBNAME), NULL_TREE, 0, (MODE))
1609
1610 /* Return boolean indicating arg of mode MODE will be passed in a reg.
1611    This macro is only used in this file.  */
1612
1613 #define PASS_IN_REG_P(CUM, MODE, TYPE) \
1614   (((TYPE) == 0 \
1615     || (! TREE_ADDRESSABLE ((TYPE)) \
1616         && (! (TARGET_HITACHI || (CUM).renesas_abi) \
1617             || ! (AGGREGATE_TYPE_P (TYPE) \
1618                   || (!TARGET_FPU_ANY \
1619                       && (GET_MODE_CLASS (MODE) == MODE_FLOAT \
1620                           && GET_MODE_SIZE (MODE) > GET_MODE_SIZE (SFmode))))))) \
1621    && ! (CUM).force_mem \
1622    && (TARGET_SH2E \
1623        ? ((MODE) == BLKmode \
1624           ? (((CUM).arg_count[(int) SH_ARG_INT] * UNITS_PER_WORD \
1625               + int_size_in_bytes (TYPE)) \
1626              <= NPARM_REGS (SImode) * UNITS_PER_WORD) \
1627           : ((ROUND_REG((CUM), (MODE)) \
1628               + HARD_REGNO_NREGS (BASE_ARG_REG (MODE), (MODE))) \
1629              <= NPARM_REGS (MODE))) \
1630        : ROUND_REG ((CUM), (MODE)) < NPARM_REGS (MODE)))
1631
1632 /* By accident we got stuck with passing SCmode on SH4 little endian
1633    in two registers that are nominally successive - which is different from
1634    two single SFmode values, where we take endianness translation into
1635    account.  That does not work at all if an odd number of registers is
1636    already in use, so that got fixed, but library functions are still more
1637    likely to use complex numbers without mixing them with SFmode arguments
1638    (which in C would have to be structures), so for the sake of ABI
1639    compatibility the way SCmode values are passed when an even number of
1640    FP registers is in use remains different from a pair of SFmode values for
1641    now.
1642    I.e.:
1643    foo (double); a: fr5,fr4
1644    foo (float a, float b); a: fr5 b: fr4
1645    foo (__complex float a); a.real fr4 a.imag: fr5 - for consistency,
1646                             this should be the other way round...
1647    foo (float a, __complex float b); a: fr5 b.real: fr4 b.imag: fr7  */
1648 #define FUNCTION_ARG_SCmode_WART 1
1649
1650 /* If an argument of size 5, 6 or 7 bytes is to be passed in a 64-bit
1651    register in SHcompact mode, it must be padded in the most
1652    significant end.  This means that passing it by reference wouldn't
1653    pad properly on a big-endian machine.  In this particular case, we
1654    pass this argument on the stack, in a way that the call trampoline
1655    will load its value into the appropriate register.  */
1656 #define SHCOMPACT_FORCE_ON_STACK(MODE,TYPE) \
1657   ((MODE) == BLKmode \
1658    && TARGET_SHCOMPACT \
1659    && ! TARGET_LITTLE_ENDIAN \
1660    && int_size_in_bytes (TYPE) > 4 \
1661    && int_size_in_bytes (TYPE) < 8)
1662
1663 /* Minimum alignment for an argument to be passed by callee-copy
1664    reference.  We need such arguments to be aligned to 8 byte
1665    boundaries, because they'll be loaded using quad loads.  */
1666 #define SH_MIN_ALIGN_FOR_CALLEE_COPY (8 * BITS_PER_UNIT)
1667
1668 /* The SH5 ABI requires floating-point arguments to be passed to
1669    functions without a prototype in both an FP register and a regular
1670    register or the stack.  When passing the argument in both FP and
1671    general-purpose registers, list the FP register first.  */
1672 #define SH5_PROTOTYPELESS_FLOAT_ARG(CUM,MODE) \
1673   (gen_rtx_PARALLEL                                                     \
1674    ((MODE),                                                             \
1675     gen_rtvec (2,                                                       \
1676                gen_rtx_EXPR_LIST                                        \
1677                (VOIDmode,                                               \
1678                 ((CUM).arg_count[(int) SH_ARG_INT] < NPARM_REGS (SImode) \
1679                  ? gen_rtx_REG ((MODE), FIRST_FP_PARM_REG               \
1680                                 + (CUM).arg_count[(int) SH_ARG_FLOAT])  \
1681                  : NULL_RTX),                                           \
1682                 const0_rtx),                                            \
1683                gen_rtx_EXPR_LIST                                        \
1684                (VOIDmode,                                               \
1685                 ((CUM).arg_count[(int) SH_ARG_INT] < NPARM_REGS (SImode) \
1686                  ? gen_rtx_REG ((MODE), FIRST_PARM_REG                  \
1687                                 + (CUM).arg_count[(int) SH_ARG_INT])    \
1688                  : gen_rtx_REG ((MODE), FIRST_FP_PARM_REG               \
1689                                 + (CUM).arg_count[(int) SH_ARG_FLOAT])), \
1690                 const0_rtx))))
1691
1692 /* The SH5 ABI requires regular registers or stack slots to be
1693    reserved for floating-point arguments.  Registers are taken care of
1694    in FUNCTION_ARG_ADVANCE, but stack slots must be reserved here.
1695    Unfortunately, there's no way to just reserve a stack slot, so
1696    we'll end up needlessly storing a copy of the argument in the
1697    stack.  For incoming arguments, however, the PARALLEL will be
1698    optimized to the register-only form, and the value in the stack
1699    slot won't be used at all.  */
1700 #define SH5_PROTOTYPED_FLOAT_ARG(CUM,MODE,REG) \
1701   ((CUM).arg_count[(int) SH_ARG_INT] < NPARM_REGS (SImode)              \
1702    ? gen_rtx_REG ((MODE), (REG))                                        \
1703    : gen_rtx_PARALLEL ((MODE),                                          \
1704                        gen_rtvec (2,                                    \
1705                                   gen_rtx_EXPR_LIST                     \
1706                                   (VOIDmode, NULL_RTX,                  \
1707                                    const0_rtx),                         \
1708                                   gen_rtx_EXPR_LIST                     \
1709                                   (VOIDmode, gen_rtx_REG ((MODE),       \
1710                                                           (REG)),       \
1711                                    const0_rtx))))
1712
1713 #define SH5_WOULD_BE_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) \
1714   (TARGET_SH5                                                   \
1715    && ((MODE) == BLKmode || (MODE) == TImode || (MODE) == CDImode \
1716        || (MODE) == DCmode) \
1717    && ((CUM).arg_count[(int) SH_ARG_INT]                        \
1718        + (((MODE) == BLKmode ? int_size_in_bytes (TYPE)         \
1719                              : GET_MODE_SIZE (MODE))            \
1720           + 7) / 8) > NPARM_REGS (SImode))
1721
1722 /* Perform any needed actions needed for a function that is receiving a
1723    variable number of arguments.  */
1724
1725 /* Call the function profiler with a given profile label.
1726    We use two .aligns, so as to make sure that both the .long is aligned
1727    on a 4 byte boundary, and that the .long is a fixed distance (2 bytes)
1728    from the trapa instruction.  */
1729
1730 #define FUNCTION_PROFILER(STREAM,LABELNO)                       \
1731 {                                                               \
1732   if (TARGET_SHMEDIA)                                           \
1733     {                                                           \
1734       fprintf((STREAM), "\tmovi\t33,r0\n");                     \
1735       fprintf((STREAM), "\ttrapa\tr0\n");                       \
1736       asm_fprintf((STREAM), "\t.long\t%LLP%d\n", (LABELNO));    \
1737     }                                                           \
1738   else                                                          \
1739     {                                                           \
1740       fprintf((STREAM), "\t.align\t2\n");                       \
1741       fprintf((STREAM), "\ttrapa\t#33\n");                      \
1742       fprintf((STREAM), "\t.align\t2\n");                       \
1743       asm_fprintf((STREAM), "\t.long\t%LLP%d\n", (LABELNO));    \
1744     }                                                           \
1745 }
1746
1747 /* Define this macro if the code for function profiling should come
1748    before the function prologue.  Normally, the profiling code comes
1749    after.  */
1750
1751 #define PROFILE_BEFORE_PROLOGUE
1752
1753 /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
1754    the stack pointer does not matter.  The value is tested only in
1755    functions that have frame pointers.
1756    No definition is equivalent to always zero.  */
1757
1758 #define EXIT_IGNORE_STACK 1
1759
1760 /*
1761    On the SH, the trampoline looks like
1762    2 0002 D202                  mov.l   l2,r2
1763    1 0000 D301                  mov.l   l1,r3
1764    3 0004 422B                  jmp     @r2
1765    4 0006 0009                  nop
1766    5 0008 00000000      l1:     .long   area
1767    6 000c 00000000      l2:     .long   function  */
1768
1769 /* Length in units of the trampoline for entering a nested function.  */
1770 #define TRAMPOLINE_SIZE  (TARGET_SHMEDIA64 ? 40 : TARGET_SH5 ? 24 : 16)
1771
1772 /* Alignment required for a trampoline in bits .  */
1773 #define TRAMPOLINE_ALIGNMENT \
1774   ((CACHE_LOG < 3 || (optimize_size && ! TARGET_HARVARD)) ? 32 \
1775    : TARGET_SHMEDIA ? 256 : 64)
1776
1777 /* A C expression whose value is RTL representing the value of the return
1778    address for the frame COUNT steps up from the current frame.
1779    FRAMEADDR is already the frame pointer of the COUNT frame, so we
1780    can ignore COUNT.  */
1781
1782 #define RETURN_ADDR_RTX(COUNT, FRAME)   \
1783   (((COUNT) == 0) ? sh_get_pr_initial_val () : (rtx) 0)
1784
1785 /* A C expression whose value is RTL representing the location of the
1786    incoming return address at the beginning of any function, before the
1787    prologue.  This RTL is either a REG, indicating that the return
1788    value is saved in REG, or a MEM representing a location in
1789    the stack.  */
1790 #define INCOMING_RETURN_ADDR_RTX \
1791   gen_rtx_REG (Pmode, TARGET_SHMEDIA ? PR_MEDIA_REG : PR_REG)
1792 \f
1793 /* Addressing modes, and classification of registers for them.  */
1794 #define HAVE_POST_INCREMENT  TARGET_SH1
1795 #define HAVE_PRE_DECREMENT   TARGET_SH1
1796
1797 #define USE_LOAD_POST_INCREMENT(mode)    ((mode == SImode || mode == DImode) \
1798                                            ? 0 : TARGET_SH1)
1799 #define USE_LOAD_PRE_DECREMENT(mode)     0
1800 #define USE_STORE_POST_INCREMENT(mode)   0
1801 #define USE_STORE_PRE_DECREMENT(mode)    ((mode == SImode || mode == DImode) \
1802                                            ? 0 : TARGET_SH1)
1803
1804 #define MOVE_BY_PIECES_P(SIZE, ALIGN) \
1805   (move_by_pieces_ninsns (SIZE, ALIGN, MOVE_MAX_PIECES + 1) \
1806    < (optimize_size ? 2 : ((ALIGN >= 32) ? 16 : 2)))
1807
1808 #define STORE_BY_PIECES_P(SIZE, ALIGN) \
1809   (move_by_pieces_ninsns (SIZE, ALIGN, STORE_MAX_PIECES + 1) \
1810    < (optimize_size ? 2 : ((ALIGN >= 32) ? 16 : 2)))
1811
1812 #define SET_BY_PIECES_P(SIZE, ALIGN) STORE_BY_PIECES_P(SIZE, ALIGN)
1813
1814 /* Macros to check register numbers against specific register classes.  */
1815
1816 /* These assume that REGNO is a hard or pseudo reg number.
1817    They give nonzero only if REGNO is a hard reg of the suitable class
1818    or a pseudo reg currently allocated to a suitable hard reg.
1819    Since they use reg_renumber, they are safe only once reg_renumber
1820    has been allocated, which happens in local-alloc.c.  */
1821
1822 #define REGNO_OK_FOR_BASE_P(REGNO) \
1823   (GENERAL_OR_AP_REGISTER_P (REGNO) \
1824    || GENERAL_OR_AP_REGISTER_P (reg_renumber[(REGNO)]))
1825 #define REGNO_OK_FOR_INDEX_P(REGNO) \
1826   (TARGET_SHMEDIA \
1827    ? (GENERAL_REGISTER_P (REGNO) \
1828       || GENERAL_REGISTER_P ((unsigned) reg_renumber[(REGNO)])) \
1829    : (REGNO) == R0_REG || (unsigned) reg_renumber[(REGNO)] == R0_REG)
1830
1831 /* Maximum number of registers that can appear in a valid memory
1832    address.  */
1833
1834 #define MAX_REGS_PER_ADDRESS 2
1835
1836 /* Recognize any constant value that is a valid address.  */
1837
1838 #define CONSTANT_ADDRESS_P(X)   (GET_CODE (X) == LABEL_REF)
1839
1840 /* Nonzero if the constant value X is a legitimate general operand.  */
1841 /* can_store_by_pieces constructs VOIDmode CONST_DOUBLEs.  */
1842
1843 #define LEGITIMATE_CONSTANT_P(X) \
1844   (TARGET_SHMEDIA                                                       \
1845    ? ((GET_MODE (X) != DFmode                                           \
1846        && GET_MODE_CLASS (GET_MODE (X)) != MODE_VECTOR_FLOAT)           \
1847       || (X) == CONST0_RTX (GET_MODE (X))                               \
1848       || ! TARGET_SHMEDIA_FPU                                           \
1849       || TARGET_SHMEDIA64)                                              \
1850    : (GET_CODE (X) != CONST_DOUBLE                                      \
1851       || GET_MODE (X) == DFmode || GET_MODE (X) == SFmode               \
1852       || GET_MODE (X) == DImode || GET_MODE (X) == VOIDmode))
1853
1854 /* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
1855    and check its validity for a certain class.
1856    The suitable hard regs are always accepted and all pseudo regs
1857    are also accepted if STRICT is not set.  */
1858
1859 /* Nonzero if X is a reg that can be used as a base reg.  */
1860 #define REG_OK_FOR_BASE_P(X, STRICT)                    \
1861   (GENERAL_OR_AP_REGISTER_P (REGNO (X))                 \
1862    || (!STRICT && REGNO (X) >= FIRST_PSEUDO_REGISTER))
1863
1864 /* Nonzero if X is a reg that can be used as an index.  */
1865 #define REG_OK_FOR_INDEX_P(X, STRICT)                   \
1866   ((TARGET_SHMEDIA ? GENERAL_REGISTER_P (REGNO (X))     \
1867     : REGNO (X) == R0_REG)                              \
1868    || (!STRICT && REGNO (X) >= FIRST_PSEUDO_REGISTER))
1869
1870 /* Nonzero if X/OFFSET is a reg that can be used as an index.  */
1871 #define SUBREG_OK_FOR_INDEX_P(X, OFFSET, STRICT)        \
1872   ((TARGET_SHMEDIA ? GENERAL_REGISTER_P (REGNO (X))     \
1873     : REGNO (X) == R0_REG && OFFSET == 0)               \
1874    || (!STRICT && REGNO (X) >= FIRST_PSEUDO_REGISTER))
1875
1876 /* Macros for extra constraints.  */
1877
1878 #define IS_PC_RELATIVE_LOAD_ADDR_P(OP)                                  \
1879   ((GET_CODE ((OP)) == LABEL_REF)                                       \
1880    || (GET_CODE ((OP)) == CONST                                         \
1881        && GET_CODE (XEXP ((OP), 0)) == PLUS                             \
1882        && GET_CODE (XEXP (XEXP ((OP), 0), 0)) == LABEL_REF              \
1883        && CONST_INT_P (XEXP (XEXP ((OP), 0), 1))))
1884
1885 #define IS_NON_EXPLICIT_CONSTANT_P(OP)                                  \
1886   (CONSTANT_P (OP)                                                      \
1887    && !CONST_INT_P (OP)                                 \
1888    && GET_CODE (OP) != CONST_DOUBLE                                     \
1889    && (!flag_pic                                                        \
1890        || (LEGITIMATE_PIC_OPERAND_P (OP)                                \
1891            && !PIC_ADDR_P (OP)                                          \
1892            && GET_CODE (OP) != LABEL_REF)))
1893
1894 /* Check whether OP is a datalabel unspec.  */
1895 #define DATALABEL_REF_NO_CONST_P(OP) \
1896   (GET_CODE (OP) == UNSPEC \
1897    && XINT ((OP), 1) == UNSPEC_DATALABEL \
1898    && XVECLEN ((OP), 0) == 1 \
1899    && GET_CODE (XVECEXP ((OP), 0, 0)) == LABEL_REF)
1900
1901 #define GOT_ENTRY_P(OP) \
1902   (GET_CODE (OP) == CONST && GET_CODE (XEXP ((OP), 0)) == UNSPEC \
1903    && XINT (XEXP ((OP), 0), 1) == UNSPEC_GOT)
1904
1905 #define GOTPLT_ENTRY_P(OP) \
1906   (GET_CODE (OP) == CONST && GET_CODE (XEXP ((OP), 0)) == UNSPEC \
1907    && XINT (XEXP ((OP), 0), 1) == UNSPEC_GOTPLT)
1908
1909 #define UNSPEC_GOTOFF_P(OP) \
1910   (GET_CODE (OP) == UNSPEC && XINT ((OP), 1) == UNSPEC_GOTOFF)
1911
1912 #define GOTOFF_P(OP) \
1913   (GET_CODE (OP) == CONST \
1914    && (UNSPEC_GOTOFF_P (XEXP ((OP), 0)) \
1915        || (GET_CODE (XEXP ((OP), 0)) == PLUS \
1916            && UNSPEC_GOTOFF_P (XEXP (XEXP ((OP), 0), 0)) \
1917            && CONST_INT_P (XEXP (XEXP ((OP), 0), 1)))))
1918
1919 #define PIC_ADDR_P(OP) \
1920   (GET_CODE (OP) == CONST && GET_CODE (XEXP ((OP), 0)) == UNSPEC \
1921    && XINT (XEXP ((OP), 0), 1) == UNSPEC_PIC)
1922
1923 #define PCREL_SYMOFF_P(OP) \
1924   (GET_CODE (OP) == CONST \
1925    && GET_CODE (XEXP ((OP), 0)) == UNSPEC \
1926    && XINT (XEXP ((OP), 0), 1) == UNSPEC_PCREL_SYMOFF)
1927
1928 #define NON_PIC_REFERENCE_P(OP) \
1929   (GET_CODE (OP) == LABEL_REF || GET_CODE (OP) == SYMBOL_REF \
1930    || (GET_CODE (OP) == CONST \
1931        && (GET_CODE (XEXP ((OP), 0)) == LABEL_REF \
1932            || GET_CODE (XEXP ((OP), 0)) == SYMBOL_REF \
1933            || DATALABEL_REF_NO_CONST_P (XEXP ((OP), 0)))) \
1934    || (GET_CODE (OP) == CONST && GET_CODE (XEXP ((OP), 0)) == PLUS \
1935        && (GET_CODE (XEXP (XEXP ((OP), 0), 0)) == SYMBOL_REF \
1936            || GET_CODE (XEXP (XEXP ((OP), 0), 0)) == LABEL_REF \
1937            || DATALABEL_REF_NO_CONST_P (XEXP (XEXP ((OP), 0), 0))) \
1938        && CONST_INT_P (XEXP (XEXP ((OP), 0), 1))))
1939
1940 #define PIC_REFERENCE_P(OP) \
1941   (GOT_ENTRY_P (OP) || GOTPLT_ENTRY_P (OP) \
1942    || GOTOFF_P (OP) || PIC_ADDR_P (OP))
1943
1944 #define MOVI_SHORI_BASE_OPERAND_P(OP) \
1945   (flag_pic \
1946    ? (GOT_ENTRY_P (OP) || GOTPLT_ENTRY_P (OP)  || GOTOFF_P (OP) \
1947       || PCREL_SYMOFF_P (OP)) \
1948    : NON_PIC_REFERENCE_P (OP))
1949 \f
1950 #define MAYBE_BASE_REGISTER_RTX_P(X, STRICT)                    \
1951   ((REG_P (X) && REG_OK_FOR_BASE_P (X, STRICT)) \
1952    || (GET_CODE (X) == SUBREG                                   \
1953        && TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (GET_MODE ((X))),     \
1954                                  GET_MODE_BITSIZE (GET_MODE (SUBREG_REG (X)))) \
1955        && REG_P (SUBREG_REG (X))                        \
1956        && REG_OK_FOR_BASE_P (SUBREG_REG (X), STRICT)))
1957
1958 /* Since this must be r0, which is a single register class, we must check
1959    SUBREGs more carefully, to be sure that we don't accept one that extends
1960    outside the class.  */
1961 #define MAYBE_INDEX_REGISTER_RTX_P(X, STRICT)                           \
1962   ((REG_P (X) && REG_OK_FOR_INDEX_P (X, STRICT))        \
1963    || (GET_CODE (X) == SUBREG                                   \
1964        && TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (GET_MODE ((X))), \
1965                                  GET_MODE_BITSIZE (GET_MODE (SUBREG_REG (X)))) \
1966        && REG_P (SUBREG_REG (X))                \
1967        && SUBREG_OK_FOR_INDEX_P (SUBREG_REG (X), SUBREG_BYTE (X), STRICT)))
1968
1969 #ifdef REG_OK_STRICT
1970 #define BASE_REGISTER_RTX_P(X) MAYBE_BASE_REGISTER_RTX_P(X, true)
1971 #define INDEX_REGISTER_RTX_P(X) MAYBE_INDEX_REGISTER_RTX_P(X, true)
1972 #else
1973 #define BASE_REGISTER_RTX_P(X) MAYBE_BASE_REGISTER_RTX_P(X, false)
1974 #define INDEX_REGISTER_RTX_P(X) MAYBE_INDEX_REGISTER_RTX_P(X, false)
1975 #endif
1976
1977 #define ALLOW_INDEXED_ADDRESS \
1978   ((!TARGET_SHMEDIA32 && !TARGET_SHCOMPACT) || TARGET_ALLOW_INDEXED_ADDRESS)
1979
1980 #define GO_IF_LEGITIMATE_INDEX(MODE, OP, WIN)   \
1981   do {                                          \
1982     if (sh_legitimate_index_p ((MODE), (OP)))   \
1983       goto WIN;                                 \
1984   } while (0)
1985 \f
1986 /* A C compound statement that attempts to replace X, which is an address
1987    that needs reloading, with a valid memory address for an operand of
1988    mode MODE.  WIN is a C statement label elsewhere in the code.  */
1989
1990 #define LEGITIMIZE_RELOAD_ADDRESS(X,MODE,OPNUM,TYPE,IND_LEVELS,WIN)     \
1991   do {                                                                  \
1992     if (sh_legitimize_reload_address (&(X), (MODE), (OPNUM), (TYPE)))   \
1993       goto WIN;                                                         \
1994   } while (0)
1995 \f
1996 /* Specify the machine mode that this machine uses
1997    for the index in the tablejump instruction.  */
1998 #define CASE_VECTOR_MODE ((! optimize || TARGET_BIGTABLE) ? SImode : HImode)
1999
2000 #define CASE_VECTOR_SHORTEN_MODE(MIN_OFFSET, MAX_OFFSET, BODY) \
2001 ((MIN_OFFSET) >= 0 && (MAX_OFFSET) <= 127 \
2002  ? (ADDR_DIFF_VEC_FLAGS (BODY).offset_unsigned = 0, QImode) \
2003  : (MIN_OFFSET) >= 0 && (MAX_OFFSET) <= 255 \
2004  ? (ADDR_DIFF_VEC_FLAGS (BODY).offset_unsigned = 1, QImode) \
2005  : (MIN_OFFSET) >= -32768 && (MAX_OFFSET) <= 32767 ? HImode \
2006  : SImode)
2007
2008 /* Define as C expression which evaluates to nonzero if the tablejump
2009    instruction expects the table to contain offsets from the address of the
2010    table.
2011    Do not define this if the table should contain absolute addresses.  */
2012 #define CASE_VECTOR_PC_RELATIVE 1
2013
2014 /* Define it here, so that it doesn't get bumped to 64-bits on SHmedia.  */
2015 #define FLOAT_TYPE_SIZE 32
2016
2017 /* Since the SH2e has only `float' support, it is desirable to make all
2018    floating point types equivalent to `float'.  */
2019 #define DOUBLE_TYPE_SIZE ((TARGET_SH2E && ! TARGET_SH4 && ! TARGET_SH2A_DOUBLE) ? 32 : 64)
2020
2021 /* 'char' is signed by default.  */
2022 #define DEFAULT_SIGNED_CHAR  1
2023
2024 /* The type of size_t unsigned int.  */
2025 #define SIZE_TYPE (TARGET_SH5 ? "long unsigned int" : "unsigned int")
2026
2027 #undef  PTRDIFF_TYPE
2028 #define PTRDIFF_TYPE (TARGET_SH5 ? "long int" : "int")
2029
2030 #define WCHAR_TYPE "short unsigned int"
2031 #define WCHAR_TYPE_SIZE 16
2032
2033 #define SH_ELF_WCHAR_TYPE "long int"
2034
2035 /* Max number of bytes we can move from memory to memory
2036    in one reasonably fast instruction.  */
2037 #define MOVE_MAX (TARGET_SHMEDIA ? 8 : 4)
2038
2039 /* Maximum value possibly taken by MOVE_MAX.  Must be defined whenever
2040    MOVE_MAX is not a compile-time constant.  */
2041 #define MAX_MOVE_MAX 8
2042
2043 /* Max number of bytes we want move_by_pieces to be able to copy
2044    efficiently.  */
2045 #define MOVE_MAX_PIECES (TARGET_SH4 || TARGET_SHMEDIA ? 8 : 4)
2046
2047 /* Define if operations between registers always perform the operation
2048    on the full register even if a narrower mode is specified.  */
2049 #define WORD_REGISTER_OPERATIONS
2050
2051 /* Define if loading in MODE, an integral mode narrower than BITS_PER_WORD
2052    will either zero-extend or sign-extend.  The value of this macro should
2053    be the code that says which one of the two operations is implicitly
2054    done, UNKNOWN if none.  */
2055 /* For SHmedia, we can truncate to QImode easier using zero extension.  */
2056 /* FP registers can load SImode values, but don't implicitly sign-extend
2057    them to DImode.  */
2058 #define LOAD_EXTEND_OP(MODE) \
2059  (((MODE) == QImode  && TARGET_SHMEDIA) ? ZERO_EXTEND \
2060   : (MODE) != SImode ? SIGN_EXTEND : UNKNOWN)
2061
2062 /* Define if loading short immediate values into registers sign extends.  */
2063 #define SHORT_IMMEDIATES_SIGN_EXTEND
2064
2065 /* Nonzero if access to memory by bytes is no faster than for words.  */
2066 #define SLOW_BYTE_ACCESS 1
2067
2068 /* Immediate shift counts are truncated by the output routines (or was it
2069    the assembler?).  Shift counts in a register are truncated by SH.  Note
2070    that the native compiler puts too large (> 32) immediate shift counts
2071    into a register and shifts by the register, letting the SH decide what
2072    to do instead of doing that itself.  */
2073 /* ??? The library routines in lib1funcs.asm truncate the shift count.
2074    However, the SH3 has hardware shifts that do not truncate exactly as gcc
2075    expects - the sign bit is significant - so it appears that we need to
2076    leave this zero for correct SH3 code.  */
2077 #define SHIFT_COUNT_TRUNCATED (! TARGET_SH3 && ! TARGET_SH2A)
2078
2079 /* All integers have the same format so truncation is easy.  */
2080 /* But SHmedia must sign-extend DImode when truncating to SImode.  */
2081 #define TRULY_NOOP_TRUNCATION(OUTPREC,INPREC) \
2082  (!TARGET_SHMEDIA || (INPREC) < 64 || (OUTPREC) >= 64)
2083
2084 /* Define this if addresses of constant functions
2085    shouldn't be put through pseudo regs where they can be cse'd.
2086    Desirable on machines where ordinary constants are expensive
2087    but a CALL with constant address is cheap.  */
2088 /*#define NO_FUNCTION_CSE 1*/
2089
2090 /* The machine modes of pointers and functions.  */
2091 #define Pmode  (TARGET_SHMEDIA64 ? DImode : SImode)
2092 #define FUNCTION_MODE  Pmode
2093
2094 /* The multiply insn on the SH1 and the divide insns on the SH1 and SH2
2095    are actually function calls with some special constraints on arguments
2096    and register usage.
2097
2098    These macros tell reorg that the references to arguments and
2099    register clobbers for insns of type sfunc do not appear to happen
2100    until after the millicode call.  This allows reorg to put insns
2101    which set the argument registers into the delay slot of the millicode
2102    call -- thus they act more like traditional CALL_INSNs.
2103
2104    get_attr_is_sfunc will try to recognize the given insn, so make sure to
2105    filter out things it will not accept -- SEQUENCE, USE and CLOBBER insns
2106    in particular.  */
2107
2108 #define INSN_SETS_ARE_DELAYED(X)                \
2109   ((NONJUMP_INSN_P (X)                  \
2110     && GET_CODE (PATTERN (X)) != SEQUENCE       \
2111     && GET_CODE (PATTERN (X)) != USE            \
2112     && GET_CODE (PATTERN (X)) != CLOBBER        \
2113     && get_attr_is_sfunc (X)))
2114
2115 #define INSN_REFERENCES_ARE_DELAYED(X)          \
2116   ((NONJUMP_INSN_P (X)                  \
2117     && GET_CODE (PATTERN (X)) != SEQUENCE       \
2118     && GET_CODE (PATTERN (X)) != USE            \
2119     && GET_CODE (PATTERN (X)) != CLOBBER        \
2120     && get_attr_is_sfunc (X)))
2121
2122 \f
2123 /* Position Independent Code.  */
2124
2125 /* We can't directly access anything that contains a symbol,
2126    nor can we indirect via the constant pool.  */
2127 #define LEGITIMATE_PIC_OPERAND_P(X)                             \
2128         ((! nonpic_symbol_mentioned_p (X)                       \
2129           && (GET_CODE (X) != SYMBOL_REF                        \
2130               || ! CONSTANT_POOL_ADDRESS_P (X)                  \
2131               || ! nonpic_symbol_mentioned_p (get_pool_constant (X)))) \
2132          || (TARGET_SHMEDIA && GET_CODE (X) == LABEL_REF))
2133
2134 #define SYMBOLIC_CONST_P(X)     \
2135 ((GET_CODE (X) == SYMBOL_REF || GET_CODE (X) == LABEL_REF)      \
2136   && nonpic_symbol_mentioned_p (X))
2137 \f
2138 /* Compute extra cost of moving data between one register class
2139    and another.  */
2140
2141 /* If SECONDARY*_RELOAD_CLASS says something about the src/dst pair, regclass
2142    uses this information.  Hence, the general register <-> floating point
2143    register information here is not used for SFmode.  */
2144
2145 #define REGCLASS_HAS_GENERAL_REG(CLASS) \
2146   ((CLASS) == GENERAL_REGS || (CLASS) == R0_REGS \
2147     || (! TARGET_SHMEDIA && (CLASS) == SIBCALL_REGS))
2148
2149 #define REGCLASS_HAS_FP_REG(CLASS) \
2150   ((CLASS) == FP0_REGS || (CLASS) == FP_REGS \
2151    || (CLASS) == DF_REGS || (CLASS) == DF_HI_REGS)
2152
2153 /* ??? Perhaps make MEMORY_MOVE_COST depend on compiler option?  This
2154    would be so that people with slow memory systems could generate
2155    different code that does fewer memory accesses.  */
2156
2157 /* A C expression for the cost of a branch instruction.  A value of 1
2158    is the default; other values are interpreted relative to that.
2159    The SH1 does not have delay slots, hence we get a pipeline stall
2160    at every branch.  The SH4 is superscalar, so the single delay slot
2161    is not sufficient to keep both pipelines filled.  */
2162 #define BRANCH_COST(speed_p, predictable_p) \
2163         (TARGET_SH5 ? 1 : ! TARGET_SH2 || TARGET_HARD_SH4 ? 2 : 1)
2164 \f
2165 /* Assembler output control.  */
2166
2167 /* A C string constant describing how to begin a comment in the target
2168    assembler language.  The compiler assumes that the comment will end at
2169    the end of the line.  */
2170 #define ASM_COMMENT_START "!"
2171
2172 #define ASM_APP_ON              ""
2173 #define ASM_APP_OFF             ""
2174 #define FILE_ASM_OP             "\t.file\n"
2175 #define SET_ASM_OP              "\t.set\t"
2176
2177 /* How to change between sections.  */
2178
2179 #define TEXT_SECTION_ASM_OP             (TARGET_SHMEDIA32 ? "\t.section\t.text..SHmedia32,\"ax\"" : "\t.text")
2180 #define DATA_SECTION_ASM_OP             "\t.data"
2181
2182 #if defined CRT_BEGIN || defined CRT_END
2183 /* Arrange for TEXT_SECTION_ASM_OP to be a compile-time constant.  */
2184 # undef TEXT_SECTION_ASM_OP
2185 # if __SHMEDIA__ == 1 && __SH5__ == 32
2186 #  define TEXT_SECTION_ASM_OP "\t.section\t.text..SHmedia32,\"ax\""
2187 # else
2188 #  define TEXT_SECTION_ASM_OP "\t.text"
2189 # endif
2190 #endif
2191
2192
2193 /* If defined, a C expression whose value is a string containing the
2194    assembler operation to identify the following data as
2195    uninitialized global data.  If not defined, and neither
2196    `ASM_OUTPUT_BSS' nor `ASM_OUTPUT_ALIGNED_BSS' are defined,
2197    uninitialized global data will be output in the data section if
2198    `-fno-common' is passed, otherwise `ASM_OUTPUT_COMMON' will be
2199    used.  */
2200 #ifndef BSS_SECTION_ASM_OP
2201 #define BSS_SECTION_ASM_OP      "\t.section\t.bss"
2202 #endif
2203
2204 /* Like `ASM_OUTPUT_BSS' except takes the required alignment as a
2205    separate, explicit argument.  If you define this macro, it is used
2206    in place of `ASM_OUTPUT_BSS', and gives you more flexibility in
2207    handling the required alignment of the variable.  The alignment is
2208    specified as the number of bits.
2209
2210    Try to use function `asm_output_aligned_bss' defined in file
2211    `varasm.c' when defining this macro.  */
2212 #ifndef ASM_OUTPUT_ALIGNED_BSS
2213 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
2214   asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
2215 #endif
2216
2217 /* Define this so that jump tables go in same section as the current function,
2218    which could be text or it could be a user defined section.  */
2219 #define JUMP_TABLES_IN_TEXT_SECTION 1
2220
2221 #undef DO_GLOBAL_CTORS_BODY
2222 #define DO_GLOBAL_CTORS_BODY                    \
2223 {                                               \
2224   typedef void (*pfunc) (void);                 \
2225   extern pfunc __ctors[];                       \
2226   extern pfunc __ctors_end[];                   \
2227   pfunc *p;                                     \
2228   for (p = __ctors_end; p > __ctors; )          \
2229     {                                           \
2230       (*--p)();                                 \
2231     }                                           \
2232 }
2233
2234 #undef DO_GLOBAL_DTORS_BODY
2235 #define DO_GLOBAL_DTORS_BODY                    \
2236 {                                               \
2237   typedef void (*pfunc) (void);                 \
2238   extern pfunc __dtors[];                       \
2239   extern pfunc __dtors_end[];                   \
2240   pfunc *p;                                     \
2241   for (p = __dtors; p < __dtors_end; p++)       \
2242     {                                           \
2243       (*p)();                                   \
2244     }                                           \
2245 }
2246
2247 #define ASM_OUTPUT_REG_PUSH(file, v) \
2248 {                                                       \
2249   if (TARGET_SHMEDIA)                                   \
2250     {                                                   \
2251       fprintf ((file), "\taddi.l\tr15,-8,r15\n");       \
2252       fprintf ((file), "\tst.q\tr15,0,r%d\n", (v));     \
2253     }                                                   \
2254   else                                                  \
2255     fprintf ((file), "\tmov.l\tr%d,@-r15\n", (v));      \
2256 }
2257
2258 #define ASM_OUTPUT_REG_POP(file, v) \
2259 {                                                       \
2260   if (TARGET_SHMEDIA)                                   \
2261     {                                                   \
2262       fprintf ((file), "\tld.q\tr15,0,r%d\n", (v));     \
2263       fprintf ((file), "\taddi.l\tr15,8,r15\n");        \
2264     }                                                   \
2265   else                                                  \
2266     fprintf ((file), "\tmov.l\t@r15+,r%d\n", (v));      \
2267 }
2268
2269 /* DBX register number for a given compiler register number.  */
2270 /* GDB has FPUL at 23 and FP0 at 25, so we must add one to all FP registers
2271    to match gdb.  */
2272 /* svr4.h undefines this macro, yet we really want to use the same numbers
2273    for coff as for elf, so we go via another macro: SH_DBX_REGISTER_NUMBER.  */
2274 /* expand_builtin_init_dwarf_reg_sizes uses this to test if a
2275    register exists, so we should return -1 for invalid register numbers.  */
2276 #define DBX_REGISTER_NUMBER(REGNO) SH_DBX_REGISTER_NUMBER (REGNO)
2277
2278 /* SHcompact PR_REG used to use the encoding 241, and SHcompact FP registers
2279    used to use the encodings 245..260, but that doesn't make sense:
2280    PR_REG and PR_MEDIA_REG are actually the same register, and likewise
2281    the FP registers stay the same when switching between compact and media
2282    mode.  Hence, we also need to use the same dwarf frame columns.
2283    Likewise, we need to support unwind information for SHmedia registers
2284    even in compact code.  */
2285 #define SH_DBX_REGISTER_NUMBER(REGNO) \
2286   (IN_RANGE ((REGNO), \
2287              (unsigned HOST_WIDE_INT) FIRST_GENERAL_REG, \
2288              FIRST_GENERAL_REG + (TARGET_SH5 ? 63U :15U)) \
2289    ? ((unsigned) (REGNO) - FIRST_GENERAL_REG) \
2290   : ((int) (REGNO) >= FIRST_FP_REG \
2291      && ((int) (REGNO) \
2292          <= (FIRST_FP_REG + \
2293              ((TARGET_SH5 && TARGET_FPU_ANY) ? 63 : TARGET_SH2E ? 15 : -1)))) \
2294    ? ((unsigned) (REGNO) - FIRST_FP_REG \
2295       + (TARGET_SH5 ? 77 : 25)) \
2296    : XD_REGISTER_P (REGNO) \
2297    ? ((unsigned) (REGNO) - FIRST_XD_REG + (TARGET_SH5 ? 289 : 87)) \
2298    : TARGET_REGISTER_P (REGNO) \
2299    ? ((unsigned) (REGNO) - FIRST_TARGET_REG + 68) \
2300    : (REGNO) == PR_REG \
2301    ? (TARGET_SH5 ? 18 : 17) \
2302    : (REGNO) == PR_MEDIA_REG \
2303    ? (TARGET_SH5 ? 18 : (unsigned) -1) \
2304    : (REGNO) == GBR_REG \
2305    ? (TARGET_SH5 ? 238 : 18) \
2306    : (REGNO) == MACH_REG \
2307    ? (TARGET_SH5 ? 239 : 20) \
2308    : (REGNO) == MACL_REG \
2309    ? (TARGET_SH5 ? 240 : 21) \
2310    : (REGNO) == T_REG \
2311    ? (TARGET_SH5 ? 242 : 22) \
2312    : (REGNO) == FPUL_REG \
2313    ? (TARGET_SH5 ? 244 : 23) \
2314    : (REGNO) == FPSCR_REG \
2315    ? (TARGET_SH5 ? 243 : 24) \
2316    : (unsigned) -1)
2317
2318 /* This is how to output a reference to a symbol_ref.  On SH5,
2319    references to non-code symbols must be preceded by `datalabel'.  */
2320 #define ASM_OUTPUT_SYMBOL_REF(FILE,SYM)                 \
2321   do                                                    \
2322     {                                                   \
2323       if (TARGET_SH5 && !SYMBOL_REF_FUNCTION_P (SYM))   \
2324         fputs ("datalabel ", (FILE));                   \
2325       assemble_name ((FILE), XSTR ((SYM), 0));          \
2326     }                                                   \
2327   while (0)
2328
2329 /* This is how to output an assembler line
2330    that says to advance the location counter
2331    to a multiple of 2**LOG bytes.  */
2332
2333 #define ASM_OUTPUT_ALIGN(FILE,LOG)      \
2334   if ((LOG) != 0)                       \
2335     fprintf ((FILE), "\t.align %d\n", (LOG))
2336
2337 /* Globalizing directive for a label.  */
2338 #define GLOBAL_ASM_OP "\t.global\t"
2339
2340 /* #define ASM_OUTPUT_CASE_END(STREAM,NUM,TABLE)            */
2341
2342 /* Output a relative address table.  */
2343
2344 #define ASM_OUTPUT_ADDR_DIFF_ELT(STREAM,BODY,VALUE,REL)                 \
2345   switch (GET_MODE (BODY))                                              \
2346     {                                                                   \
2347     case SImode:                                                        \
2348       if (TARGET_SH5)                                                   \
2349         {                                                               \
2350           asm_fprintf ((STREAM), "\t.long\t%LL%d-datalabel %LL%d\n",    \
2351                        (VALUE), (REL));                                 \
2352           break;                                                        \
2353         }                                                               \
2354       asm_fprintf ((STREAM), "\t.long\t%LL%d-%LL%d\n", (VALUE),(REL));  \
2355       break;                                                            \
2356     case HImode:                                                        \
2357       if (TARGET_SH5)                                                   \
2358         {                                                               \
2359           asm_fprintf ((STREAM), "\t.word\t%LL%d-datalabel %LL%d\n",    \
2360                        (VALUE), (REL));                                 \
2361           break;                                                        \
2362         }                                                               \
2363       asm_fprintf ((STREAM), "\t.word\t%LL%d-%LL%d\n", (VALUE),(REL));  \
2364       break;                                                            \
2365     case QImode:                                                        \
2366       if (TARGET_SH5)                                                   \
2367         {                                                               \
2368           asm_fprintf ((STREAM), "\t.byte\t%LL%d-datalabel %LL%d\n",    \
2369                        (VALUE), (REL));                                 \
2370           break;                                                        \
2371         }                                                               \
2372       asm_fprintf ((STREAM), "\t.byte\t%LL%d-%LL%d\n", (VALUE),(REL));  \
2373       break;                                                            \
2374     default:                                                            \
2375       break;                                                            \
2376     }
2377
2378 /* Output an absolute table element.  */
2379
2380 #define ASM_OUTPUT_ADDR_VEC_ELT(STREAM,VALUE)                           \
2381   if (! optimize || TARGET_BIGTABLE)                                    \
2382     asm_fprintf ((STREAM), "\t.long\t%LL%d\n", (VALUE));                \
2383   else                                                                  \
2384     asm_fprintf ((STREAM), "\t.word\t%LL%d\n", (VALUE));
2385
2386 \f
2387 /* A C statement to be executed just prior to the output of
2388    assembler code for INSN, to modify the extracted operands so
2389    they will be output differently.
2390
2391    Here the argument OPVEC is the vector containing the operands
2392    extracted from INSN, and NOPERANDS is the number of elements of
2393    the vector which contain meaningful data for this insn.
2394    The contents of this vector are what will be used to convert the insn
2395    template into assembler code, so you can change the assembler output
2396    by changing the contents of the vector.  */
2397
2398 #define FINAL_PRESCAN_INSN(INSN, OPVEC, NOPERANDS) \
2399   final_prescan_insn ((INSN), (OPVEC), (NOPERANDS))
2400
2401 /* Recognize machine-specific patterns that may appear within
2402    constants.  Used for PIC-specific UNSPECs.  */
2403 #define OUTPUT_ADDR_CONST_EXTRA(STREAM, X, FAIL) \
2404   do                                                                    \
2405     if (GET_CODE (X) == UNSPEC)                                         \
2406       {                                                                 \
2407         switch (XINT ((X), 1))                                          \
2408           {                                                             \
2409           case UNSPEC_DATALABEL:                                        \
2410             fputs ("datalabel ", (STREAM));                             \
2411             output_addr_const ((STREAM), XVECEXP ((X), 0, 0));          \
2412             break;                                                      \
2413           case UNSPEC_PIC:                                              \
2414             /* GLOBAL_OFFSET_TABLE or local symbols, no suffix.  */     \
2415             output_addr_const ((STREAM), XVECEXP ((X), 0, 0));          \
2416             break;                                                      \
2417           case UNSPEC_GOT:                                              \
2418             output_addr_const ((STREAM), XVECEXP ((X), 0, 0));          \
2419             fputs ("@GOT", (STREAM));                                   \
2420             break;                                                      \
2421           case UNSPEC_GOTOFF:                                           \
2422             output_addr_const ((STREAM), XVECEXP ((X), 0, 0));          \
2423             fputs ("@GOTOFF", (STREAM));                                \
2424             break;                                                      \
2425           case UNSPEC_PLT:                                              \
2426             output_addr_const ((STREAM), XVECEXP ((X), 0, 0));          \
2427             fputs ("@PLT", (STREAM));                                   \
2428             break;                                                      \
2429           case UNSPEC_GOTPLT:                                           \
2430             output_addr_const ((STREAM), XVECEXP ((X), 0, 0));          \
2431             fputs ("@GOTPLT", (STREAM));                                \
2432             break;                                                      \
2433           case UNSPEC_DTPOFF:                                           \
2434             output_addr_const ((STREAM), XVECEXP ((X), 0, 0));          \
2435             fputs ("@DTPOFF", (STREAM));                                \
2436             break;                                                      \
2437           case UNSPEC_GOTTPOFF:                                         \
2438             output_addr_const ((STREAM), XVECEXP ((X), 0, 0));          \
2439             fputs ("@GOTTPOFF", (STREAM));                              \
2440             break;                                                      \
2441           case UNSPEC_TPOFF:                                            \
2442             output_addr_const ((STREAM), XVECEXP ((X), 0, 0));          \
2443             fputs ("@TPOFF", (STREAM));                                 \
2444             break;                                                      \
2445           case UNSPEC_CALLER:                                           \
2446             {                                                           \
2447               char name[32];                                            \
2448               /* LPCS stands for Label for PIC Call Site.  */           \
2449               ASM_GENERATE_INTERNAL_LABEL                               \
2450                 (name, "LPCS", INTVAL (XVECEXP ((X), 0, 0)));           \
2451               assemble_name ((STREAM), name);                           \
2452             }                                                           \
2453             break;                                                      \
2454           case UNSPEC_EXTRACT_S16:                                      \
2455           case UNSPEC_EXTRACT_U16:                                      \
2456             {                                                           \
2457               rtx val, shift;                                           \
2458                                                                         \
2459               val = XVECEXP (X, 0, 0);                                  \
2460               shift = XVECEXP (X, 0, 1);                                \
2461               fputc ('(', STREAM);                                      \
2462               if (shift != const0_rtx)                                  \
2463                 fputc ('(', STREAM);                                    \
2464               if (GET_CODE (val) == CONST                               \
2465                   || GET_RTX_CLASS (GET_CODE (val)) != RTX_OBJ)         \
2466                 {                                                       \
2467                   fputc ('(', STREAM);                                  \
2468                   output_addr_const (STREAM, val);                      \
2469                   fputc (')', STREAM);                                  \
2470                 }                                                       \
2471               else                                                      \
2472                 output_addr_const (STREAM, val);                        \
2473               if (shift != const0_rtx)                                  \
2474                 {                                                       \
2475                   fputs (" >> ", STREAM);                               \
2476                   output_addr_const (STREAM, shift);                    \
2477                   fputc (')', STREAM);                                  \
2478                 }                                                       \
2479               fputs (" & 65535)", STREAM);                              \
2480             }                                                           \
2481             break;                                                      \
2482           case UNSPEC_SYMOFF:                                           \
2483             output_addr_const (STREAM, XVECEXP (X, 0, 0));              \
2484             fputc ('-', STREAM);                                        \
2485             if (GET_CODE (XVECEXP (X, 0, 1)) == CONST)                  \
2486               {                                                         \
2487                 fputc ('(', STREAM);                                    \
2488                 output_addr_const (STREAM, XVECEXP (X, 0, 1));          \
2489                 fputc (')', STREAM);                                    \
2490               }                                                         \
2491             else                                                        \
2492               output_addr_const (STREAM, XVECEXP (X, 0, 1));            \
2493             break;                                                      \
2494           case UNSPEC_PCREL_SYMOFF:                                     \
2495             output_addr_const (STREAM, XVECEXP (X, 0, 0));              \
2496             fputs ("-(", STREAM);                                       \
2497             output_addr_const (STREAM, XVECEXP (X, 0, 1));              \
2498             fputs ("-.)", STREAM);                                      \
2499             break;                                                      \
2500           default:                                                      \
2501             goto FAIL;                                                  \
2502           }                                                             \
2503         break;                                                          \
2504       }                                                                 \
2505     else                                                                \
2506       goto FAIL;                                                        \
2507   while (0)
2508
2509 \f
2510 extern struct rtx_def *sh_compare_op0;
2511 extern struct rtx_def *sh_compare_op1;
2512
2513 /* Which processor to schedule for.  The elements of the enumeration must
2514    match exactly the cpu attribute in the sh.md file.  */
2515
2516 enum processor_type {
2517   PROCESSOR_SH1,
2518   PROCESSOR_SH2,
2519   PROCESSOR_SH2E,
2520   PROCESSOR_SH2A,
2521   PROCESSOR_SH3,
2522   PROCESSOR_SH3E,
2523   PROCESSOR_SH4,
2524   PROCESSOR_SH4A,
2525   PROCESSOR_SH5
2526 };
2527
2528 #define sh_cpu_attr ((enum attr_cpu)sh_cpu)
2529 extern enum processor_type sh_cpu;
2530
2531 enum mdep_reorg_phase_e
2532 {
2533   SH_BEFORE_MDEP_REORG,
2534   SH_INSERT_USES_LABELS,
2535   SH_SHORTEN_BRANCHES0,
2536   SH_FIXUP_PCLOAD,
2537   SH_SHORTEN_BRANCHES1,
2538   SH_AFTER_MDEP_REORG
2539 };
2540
2541 extern enum mdep_reorg_phase_e mdep_reorg_phase;
2542
2543 /* Handle Renesas compiler's pragmas.  */
2544 #define REGISTER_TARGET_PRAGMAS() do {                                  \
2545   c_register_pragma (0, "interrupt", sh_pr_interrupt);                  \
2546   c_register_pragma (0, "trapa", sh_pr_trapa);                          \
2547   c_register_pragma (0, "nosave_low_regs", sh_pr_nosave_low_regs);      \
2548 } while (0)
2549
2550 extern tree sh_deferred_function_attributes;
2551 extern tree *sh_deferred_function_attributes_tail;
2552
2553 /* Set when processing a function with interrupt attribute.  */
2554
2555 extern int current_function_interrupt;
2556
2557 \f
2558 /* Instructions with unfilled delay slots take up an
2559    extra two bytes for the nop in the delay slot.
2560    sh-dsp parallel processing insns are four bytes long.  */
2561
2562 #define ADJUST_INSN_LENGTH(X, LENGTH)                           \
2563   (LENGTH) += sh_insn_length_adjustment (X);
2564 \f
2565 /* Define this macro if it is advisable to hold scalars in registers
2566    in a wider mode than that declared by the program.  In such cases,
2567    the value is constrained to be within the bounds of the declared
2568    type, but kept valid in the wider mode.  The signedness of the
2569    extension may differ from that of the type.
2570
2571    Leaving the unsignedp unchanged gives better code than always setting it
2572    to 0.  This is despite the fact that we have only signed char and short
2573    load instructions.  */
2574 #define PROMOTE_MODE(MODE, UNSIGNEDP, TYPE) \
2575   if (GET_MODE_CLASS (MODE) == MODE_INT                 \
2576       && GET_MODE_SIZE (MODE) < 4/* ! UNITS_PER_WORD */)\
2577     (UNSIGNEDP) = ((MODE) == SImode ? 0 : (UNSIGNEDP)), \
2578     (MODE) = (TARGET_SH1 ? SImode \
2579               : TARGET_SHMEDIA32 ? SImode : DImode);
2580
2581 #define MAX_FIXED_MODE_SIZE (TARGET_SH5 ? 128 : 64)
2582
2583 #define SIDI_OFF (TARGET_LITTLE_ENDIAN ? 0 : 4)
2584
2585 /* Better to allocate once the maximum space for outgoing args in the
2586    prologue rather than duplicate around each call.  */
2587 #define ACCUMULATE_OUTGOING_ARGS TARGET_ACCUMULATE_OUTGOING_ARGS
2588
2589 #define SH_DYNAMIC_SHIFT_COST \
2590   (TARGET_HARD_SH4 ? 1 : TARGET_SH3 ? (optimize_size ? 1 : 2) : 20)
2591
2592
2593 #define NUM_MODES_FOR_MODE_SWITCHING { FP_MODE_NONE }
2594
2595 #define OPTIMIZE_MODE_SWITCHING(ENTITY) (TARGET_SH4 || TARGET_SH2A_DOUBLE)
2596
2597 #define ACTUAL_NORMAL_MODE(ENTITY) \
2598   (TARGET_FPU_SINGLE ? FP_MODE_SINGLE : FP_MODE_DOUBLE)
2599
2600 #define NORMAL_MODE(ENTITY) \
2601   (sh_cfun_interrupt_handler_p () \
2602    ? (TARGET_FMOVD ? FP_MODE_DOUBLE : FP_MODE_NONE) \
2603    : ACTUAL_NORMAL_MODE (ENTITY))
2604
2605 #define MODE_ENTRY(ENTITY) NORMAL_MODE (ENTITY)
2606
2607 #define MODE_EXIT(ENTITY) \
2608   (sh_cfun_attr_renesas_p () ? FP_MODE_NONE : NORMAL_MODE (ENTITY))
2609
2610 #define EPILOGUE_USES(REGNO)       ((TARGET_SH2E || TARGET_SH4)         \
2611                                     && (REGNO) == FPSCR_REG)
2612
2613 #define MODE_NEEDED(ENTITY, INSN)                                       \
2614   (recog_memoized (INSN) >= 0                                           \
2615    ? get_attr_fp_mode (INSN)                                            \
2616    : FP_MODE_NONE)
2617
2618 #define MODE_AFTER(MODE, INSN)                  \
2619      (TARGET_HITACHI                            \
2620       && recog_memoized (INSN) >= 0             \
2621       && get_attr_fp_set (INSN) != FP_SET_NONE  \
2622       ? (int) get_attr_fp_set (INSN)            \
2623       : (MODE))
2624
2625 #define MODE_PRIORITY_TO_MODE(ENTITY, N) \
2626   ((TARGET_FPU_SINGLE != 0) ^ (N) ? FP_MODE_SINGLE : FP_MODE_DOUBLE)
2627
2628 #define EMIT_MODE_SET(ENTITY, MODE, HARD_REGS_LIVE) \
2629   fpscr_set_from_mem ((MODE), (HARD_REGS_LIVE))
2630
2631 #define MD_CAN_REDIRECT_BRANCH(INSN, SEQ) \
2632   sh_can_redirect_branch ((INSN), (SEQ))
2633
2634 #define DWARF_FRAME_RETURN_COLUMN \
2635   (TARGET_SH5 ? DWARF_FRAME_REGNUM (PR_MEDIA_REG) : DWARF_FRAME_REGNUM (PR_REG))
2636
2637 #define EH_RETURN_DATA_REGNO(N) \
2638   ((N) < 4 ? (N) + (TARGET_SH5 ? 2U : 4U) : INVALID_REGNUM)
2639
2640 #define EH_RETURN_STACKADJ_REGNO STATIC_CHAIN_REGNUM
2641 #define EH_RETURN_STACKADJ_RTX  gen_rtx_REG (Pmode, EH_RETURN_STACKADJ_REGNO)
2642
2643 /* We have to distinguish between code and data, so that we apply
2644    datalabel where and only where appropriate.  Use sdataN for data.  */
2645 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \
2646  ((flag_pic && (GLOBAL) ? DW_EH_PE_indirect : 0) \
2647   | (flag_pic ? DW_EH_PE_pcrel : DW_EH_PE_absptr) \
2648   | ((CODE) ? 0 : (TARGET_SHMEDIA64 ? DW_EH_PE_sdata8 : DW_EH_PE_sdata4)))
2649
2650 /* Handle special EH pointer encodings.  Absolute, pc-relative, and
2651    indirect are handled automatically.  */
2652 #define ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX(FILE, ENCODING, SIZE, ADDR, DONE) \
2653   do { \
2654     if (((ENCODING) & 0xf) != DW_EH_PE_sdata4 \
2655         && ((ENCODING) & 0xf) != DW_EH_PE_sdata8) \
2656       { \
2657         gcc_assert (GET_CODE (ADDR) == SYMBOL_REF); \
2658         SYMBOL_REF_FLAGS (ADDR) |= SYMBOL_FLAG_FUNCTION; \
2659         if (0) goto DONE; \
2660       } \
2661   } while (0)
2662
2663 #if (defined CRT_BEGIN || defined CRT_END) && ! __SHMEDIA__
2664 /* SH constant pool breaks the devices in crtstuff.c to control section
2665    in where code resides.  We have to write it as asm code.  */
2666 #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
2667    asm (SECTION_OP "\n\
2668         mov.l   1f,r1\n\
2669         mova    2f,r0\n\
2670         braf    r1\n\
2671         lds     r0,pr\n\
2672 0:      .p2align 2\n\
2673 1:      .long   " USER_LABEL_PREFIX #FUNC " - 0b\n\
2674 2:\n" TEXT_SECTION_ASM_OP);
2675 #endif /* (defined CRT_BEGIN || defined CRT_END) && ! __SHMEDIA__ */
2676
2677 /* FIXME: middle-end support for highpart optimizations is missing.  */
2678 #define high_life_started reload_in_progress
2679
2680 #endif /* ! GCC_SH_H */