OSDN Git Service

gcc/
[pf3gnuchains/gcc-fork.git] / gcc / config / m68k / m68k.h
1 /* Definitions of target machine for GCC for Motorola 680x0/ColdFire.
2    Copyright (C) 1987, 1988, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
3    2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
4
5 This file is part of GCC.
6
7 GCC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 GCC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING.  If not, write to
19 the Free Software Foundation, 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA.  */
21
22 /* We need to have MOTOROLA always defined (either 0 or 1) because we use
23    if-statements and ?: on it.  This way we have compile-time error checking
24    for both the MOTOROLA and MIT code paths.  We do rely on the host compiler
25    to optimize away all constant tests.  */
26 #ifdef MOTOROLA
27 # undef MOTOROLA
28 # define MOTOROLA 1  /* Use the Motorola assembly syntax.  */
29 # define TARGET_VERSION fprintf (stderr, " (68k, Motorola syntax)")
30 #else
31 # define TARGET_VERSION fprintf (stderr, " (68k, MIT syntax)")
32 # define MOTOROLA 0  /* Use the MIT assembly syntax.  */
33 #endif
34
35 /* Handle --with-cpu default option from configure script.  */
36 #define OPTION_DEFAULT_SPECS                                            \
37   { "cpu",   "%{!mc68000:%{!m68000:%{!m68302:%{!m68010:%{!mc68020:%{!m68020:\
38 %{!m68030:%{!m68040:%{!m68020-40:%{!m68020-60:%{!m68060:%{!mcpu32:\
39 %{!m68332:%{!m5200:%{!m5206e:%{!m528x:%{!m5307:%{!m5407:%{!mcfv4e:\
40 %{!mcpu=*:%{!march=*:-%(VALUE)}}}}}}}}}}}}}}}}}}}}}" },
41
42 /* Pass flags to gas indicating which type of processor we have.  This
43    can be simplified when we can rely on the assembler supporting .cpu
44    and .arch directives.  */
45
46 #define ASM_CPU_SPEC "\
47 %{m68851}%{mno-68851} %{m68881}%{mno-68881} %{msoft-float:-mno-float} \
48 %{m68000}%{m68302}%{mc68000}%{m68010}%{m68020}%{mc68020}%{m68030}\
49 %{m68040}%{m68020-40:-m68040}%{m68020-60:-m68040}\
50 %{m68060}%{mcpu32}%{m68332}%{m5200}%{m5206e}%{m528x}%{m5307}%{m5407}%{mcfv4e}\
51 %{mcpu=*:-mcpu=%*}%{march=*:-march=%*}\
52 "
53
54 #define ASM_SPEC "%(asm_cpu_spec)"
55
56 #define EXTRA_SPECS                                     \
57   { "asm_cpu_spec", ASM_CPU_SPEC },                     \
58   SUBTARGET_EXTRA_SPECS
59
60 #define SUBTARGET_EXTRA_SPECS
61
62 /* Note that some other tm.h files include this one and then override
63    many of the definitions that relate to assembler syntax.  */
64
65 #define TARGET_CPU_CPP_BUILTINS()                                       \
66   do                                                                    \
67     {                                                                   \
68       builtin_define ("__m68k__");                                      \
69       builtin_define_std ("mc68000");                                   \
70       /* The other mc680x0 macros have traditionally been derived       \
71          from the tuning setting.  For example, -m68020-60 defines      \
72          m68060, even though it generates pure 68020 code.  */          \
73       switch (m68k_tune)                                                \
74         {                                                               \
75         case u68010:                                                    \
76           builtin_define_std ("mc68010");                               \
77           break;                                                        \
78                                                                         \
79         case u68020:                                                    \
80           builtin_define_std ("mc68020");                               \
81           break;                                                        \
82                                                                         \
83         case u68030:                                                    \
84           builtin_define_std ("mc68030");                               \
85           break;                                                        \
86                                                                         \
87         case u68040:                                                    \
88           builtin_define_std ("mc68040");                               \
89           break;                                                        \
90                                                                         \
91         case u68060:                                                    \
92           builtin_define_std ("mc68060");                               \
93           break;                                                        \
94                                                                         \
95         case u68020_60:                                                 \
96           builtin_define_std ("mc68060");                               \
97           /* Fall through.  */                                          \
98         case u68020_40:                                                 \
99           builtin_define_std ("mc68040");                               \
100           builtin_define_std ("mc68030");                               \
101           builtin_define_std ("mc68020");                               \
102           break;                                                        \
103                                                                         \
104         case ucpu32:                                                    \
105           builtin_define_std ("mc68332");                               \
106           builtin_define_std ("mcpu32");                                \
107           builtin_define_std ("mc68020");                               \
108           break;                                                        \
109                                                                         \
110         case ucfv2:                                                     \
111           builtin_define ("__mcfv2__");                                 \
112           break;                                                        \
113                                                                         \
114         case ucfv3:                                                     \
115           builtin_define ("__mcfv3__");                                 \
116           break;                                                        \
117                                                                         \
118         case ucfv4:                                                     \
119           builtin_define ("__mcfv4__");                                 \
120           break;                                                        \
121                                                                         \
122         case ucfv4e:                                                    \
123           builtin_define ("__mcfv4e__");                                \
124           break;                                                        \
125                                                                         \
126         case ucfv5:                                                     \
127           builtin_define ("__mcfv5__");                                 \
128           break;                                                        \
129                                                                         \
130         default:                                                        \
131           break;                                                        \
132         }                                                               \
133                                                                         \
134       if (TARGET_68881)                                                 \
135         builtin_define ("__HAVE_68881__");                              \
136                                                                         \
137       if (TARGET_COLDFIRE)                                              \
138         {                                                               \
139           const char *tmp;                                              \
140                                                                         \
141           tmp = m68k_cpp_cpu_ident ("cf");                              \
142           if (tmp)                                                      \
143             builtin_define (tmp);                                       \
144           tmp = m68k_cpp_cpu_family ("cf");                             \
145           if (tmp)                                                      \
146             builtin_define (tmp);                                       \
147           builtin_define ("__mcoldfire__");                             \
148                                                                         \
149           if (TARGET_ISAC)                                              \
150             builtin_define ("__mcfisac__");                             \
151           else if (TARGET_ISAB)                                         \
152             {                                                           \
153               builtin_define ("__mcfisab__");                           \
154               /* ISA_B: Legacy 5407 defines.  */                        \
155               builtin_define ("__mcf5400__");                           \
156               builtin_define ("__mcf5407__");                           \
157             }                                                           \
158           else if (TARGET_ISAAPLUS)                                     \
159             {                                                           \
160               builtin_define ("__mcfisaaplus__");                       \
161               /* ISA_A+: legacy defines.  */                            \
162               builtin_define ("__mcf528x__");                           \
163               builtin_define ("__mcf5200__");                           \
164             }                                                           \
165           else                                                          \
166             {                                                           \
167               builtin_define ("__mcfisaa__");                           \
168               /* ISA_A: legacy defines.  */                             \
169               switch (m68k_tune)                                        \
170                 {                                                       \
171                 case ucfv2:                                             \
172                   builtin_define ("__mcf5200__");                       \
173                   break;                                                \
174                                                                         \
175                 case ucfv3:                                             \
176                   builtin_define ("__mcf5307__");                       \
177                   builtin_define ("__mcf5300__");                       \
178                   break;                                                \
179                                                                         \
180                 default:                                                \
181                   break;                                                \
182                 }                                                       \
183             }                                                           \
184         }                                                               \
185                                                                         \
186       if (TARGET_COLDFIRE_FPU)                                          \
187         builtin_define ("__mcffpu__");                                  \
188                                                                         \
189       if (TARGET_CF_HWDIV)                                              \
190         builtin_define ("__mcfhwdiv__");                                \
191                                                                         \
192       builtin_assert ("cpu=m68k");                                      \
193       builtin_assert ("machine=m68k");                                  \
194     }                                                                   \
195   while (0)
196
197 /* Classify the groups of pseudo-ops used to assemble QI, HI and SI
198    quantities.  */
199 #define INT_OP_STANDARD 0       /* .byte, .short, .long */
200 #define INT_OP_DOT_WORD 1       /* .byte, .word, .long */
201 #define INT_OP_NO_DOT   2       /* byte, short, long */
202 #define INT_OP_DC       3       /* dc.b, dc.w, dc.l */
203
204 /* Set the default.  */
205 #define INT_OP_GROUP INT_OP_DOT_WORD
206
207 /* Bit values used by m68k-devices.def to identify processor capabilities.  */
208 #define FL_BITFIELD  (1 << 0)    /* Support bitfield instructions.  */
209 #define FL_68881     (1 << 1)    /* (Default) support for 68881/2.  */
210 #define FL_COLDFIRE  (1 << 2)    /* ColdFire processor.  */
211 #define FL_CF_HWDIV  (1 << 3)    /* ColdFire hardware divide supported.  */
212 #define FL_CF_MAC    (1 << 4)    /* ColdFire MAC unit supported.  */
213 #define FL_CF_EMAC   (1 << 5)    /* ColdFire eMAC unit supported.  */
214 #define FL_CF_EMAC_B (1 << 6)    /* ColdFire eMAC-B unit supported.  */
215 #define FL_CF_USP    (1 << 7)    /* ColdFire User Stack Pointer supported.  */
216 #define FL_CF_FPU    (1 << 8)    /* ColdFire FPU supported.  */
217 #define FL_ISA_68000 (1 << 9)
218 #define FL_ISA_68010 (1 << 10)
219 #define FL_ISA_68020 (1 << 11)
220 #define FL_ISA_68040 (1 << 12)
221 #define FL_ISA_A     (1 << 13)
222 #define FL_ISA_APLUS (1 << 14)
223 #define FL_ISA_B     (1 << 15)
224 #define FL_ISA_C     (1 << 16)
225 #define FL_MMU       0   /* Used by multilib machinery.  */
226
227 #define TARGET_68010            ((m68k_cpu_flags & FL_ISA_68010) != 0)
228 #define TARGET_68020            ((m68k_cpu_flags & FL_ISA_68020) != 0)
229 #define TARGET_68040            ((m68k_cpu_flags & FL_ISA_68040) != 0)
230 #define TARGET_COLDFIRE         ((m68k_cpu_flags & FL_COLDFIRE) != 0)
231 #define TARGET_COLDFIRE_FPU     (m68k_fpu == FPUTYPE_COLDFIRE)
232 #define TARGET_68881            (m68k_fpu == FPUTYPE_68881)
233
234 /* Size (in bytes) of FPU registers.  */
235 #define TARGET_FP_REG_SIZE      (TARGET_COLDFIRE ? 8 : 12)
236
237 #define TARGET_ISAAPLUS         ((m68k_cpu_flags & FL_ISA_APLUS) != 0)
238 #define TARGET_ISAB             ((m68k_cpu_flags & FL_ISA_B) != 0)
239 #define TARGET_ISAC             ((m68k_cpu_flags & FL_ISA_C) != 0)
240
241 #define TUNE_68000      (m68k_tune == u68000)
242 #define TUNE_68010      (m68k_tune == u68010)
243 #define TUNE_68000_10   (TUNE_68000 || TUNE_68010)
244 #define TUNE_68030      (m68k_tune == u68030 \
245                          || m68k_tune == u68020_40 \
246                          || m68k_tune == u68020_60)
247 #define TUNE_68040      (m68k_tune == u68040 \
248                          || m68k_tune == u68020_40 \
249                          || m68k_tune == u68020_60)
250 #define TUNE_68060      (m68k_tune == u68060 || m68k_tune == u68020_60)
251 #define TUNE_68040_60   (TUNE_68040 || TUNE_68060)
252 #define TUNE_CPU32      (m68k_tune == ucpu32)
253 #define TUNE_CFV2       (m68k_tune == ucfv2)
254
255 #define OVERRIDE_OPTIONS   override_options()
256
257 /* These are meant to be redefined in the host dependent files */
258 #define SUBTARGET_OVERRIDE_OPTIONS
259 \f
260 /* target machine storage layout */
261
262 /* "long double" is the same as "double" on ColdFire targets.  */
263
264 #define LONG_DOUBLE_TYPE_SIZE (TARGET_COLDFIRE ? 64 : 80)
265
266 /* We need to know the size of long double at compile-time in libgcc2.  */
267
268 #ifdef __mcoldfire__
269 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64
270 #else
271 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 80
272 #endif
273
274 /* Set the value of FLT_EVAL_METHOD in float.h.  When using 68040 fp
275    instructions, we get proper intermediate rounding, otherwise we
276    get extended precision results.  */
277 #define TARGET_FLT_EVAL_METHOD ((TARGET_68040 || ! TARGET_68881) ? 0 : 2)
278
279 #define BITS_BIG_ENDIAN 1
280 #define BYTES_BIG_ENDIAN 1
281 #define WORDS_BIG_ENDIAN 1
282
283 #define UNITS_PER_WORD 4
284
285 #define PARM_BOUNDARY (TARGET_SHORT ? 16 : 32)
286 #define STACK_BOUNDARY 16
287 #define FUNCTION_BOUNDARY 16
288 #define EMPTY_FIELD_BOUNDARY 16
289
290 /* No data type wants to be aligned rounder than this.
291    Most published ABIs say that ints should be aligned on 16 bit
292    boundaries, but CPUs with 32-bit busses get better performance
293    aligned on 32-bit boundaries.  ColdFires without a misalignment
294    module require 32-bit alignment.  */
295 #define BIGGEST_ALIGNMENT (TARGET_ALIGN_INT ? 32 : 16)
296
297 #define STRICT_ALIGNMENT (TARGET_STRICT_ALIGNMENT)
298
299 #define INT_TYPE_SIZE (TARGET_SHORT ? 16 : 32)
300
301 /* Define these to avoid dependence on meaning of `int'.  */
302 #define WCHAR_TYPE "long int"
303 #define WCHAR_TYPE_SIZE 32
304
305 /* Maximum number of library IDs we permit with -mid-shared-library.  */
306 #define MAX_LIBRARY_ID 255
307
308 \f
309 /* Standard register usage.  */
310
311 /* For the m68k, we give the data registers numbers 0-7,
312    the address registers numbers 010-017 (8-15),
313    and the 68881 floating point registers numbers 020-027 (16-24).
314    We also have a fake `arg-pointer' register 030 (25) used for
315    register elimination.  */
316 #define FIRST_PSEUDO_REGISTER 25
317
318 /* All m68k targets (except AmigaOS) use %a5 as the PIC register  */
319 #define PIC_OFFSET_TABLE_REGNUM (flag_pic ? 13 : INVALID_REGNUM)
320
321 /* 1 for registers that have pervasive standard uses
322    and are not available for the register allocator.
323    On the m68k, only the stack pointer is such.
324    Our fake arg-pointer is obviously fixed as well.  */
325 #define FIXED_REGISTERS        \
326  {/* Data registers.  */       \
327   0, 0, 0, 0, 0, 0, 0, 0,      \
328                                \
329   /* Address registers.  */    \
330   0, 0, 0, 0, 0, 0, 0, 1,      \
331                                \
332   /* Floating point registers  \
333      (if available).  */       \
334   0, 0, 0, 0, 0, 0, 0, 0,      \
335                                \
336   /* Arg pointer.  */          \
337   1 }
338
339 /* 1 for registers not available across function calls.
340    These must include the FIXED_REGISTERS and also any
341    registers that can be used without being saved.
342    The latter must include the registers where values are returned
343    and the register where structure-value addresses are passed.
344    Aside from that, you can include as many other registers as you like.  */
345 #define CALL_USED_REGISTERS     \
346  {/* Data registers.  */        \
347   1, 1, 0, 0, 0, 0, 0, 0,       \
348                                 \
349   /* Address registers.  */     \
350   1, 1, 0, 0, 0, 0, 0, 1,       \
351                                 \
352   /* Floating point registers   \
353      (if available).  */        \
354   1, 1, 0, 0, 0, 0, 0, 0,       \
355                                 \
356   /* Arg pointer.  */           \
357   1 }
358
359 #define REG_ALLOC_ORDER         \
360 { /* d0/d1/a0/a1 */             \
361   0, 1, 8, 9,                   \
362   /* d2-d7 */                   \
363   2, 3, 4, 5, 6, 7,             \
364   /* a2-a7/arg */               \
365   10, 11, 12, 13, 14, 15, 24,   \
366   /* fp0-fp7 */                 \
367   16, 17, 18, 19, 20, 21, 22, 23\
368 }
369
370
371 /* Make sure everything's fine if we *don't* have a given processor.
372    This assumes that putting a register in fixed_regs will keep the
373    compiler's mitts completely off it.  We don't bother to zero it out
374    of register classes.  */
375 #define CONDITIONAL_REGISTER_USAGE                              \
376 {                                                               \
377   int i;                                                        \
378   HARD_REG_SET x;                                               \
379   if (!TARGET_HARD_FLOAT)                                       \
380     {                                                           \
381       COPY_HARD_REG_SET (x, reg_class_contents[(int)FP_REGS]);  \
382       for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)               \
383         if (TEST_HARD_REG_BIT (x, i))                           \
384           fixed_regs[i] = call_used_regs[i] = 1;                \
385     }                                                           \
386   if (PIC_OFFSET_TABLE_REGNUM != INVALID_REGNUM)                \
387     fixed_regs[PIC_OFFSET_TABLE_REGNUM]                         \
388       = call_used_regs[PIC_OFFSET_TABLE_REGNUM] = 1;            \
389 }
390
391 /* On the m68k, ordinary registers hold 32 bits worth;
392    for the 68881 registers, a single register is always enough for
393    anything that can be stored in them at all.  */
394 #define HARD_REGNO_NREGS(REGNO, MODE)   \
395   ((REGNO) >= 16 ? GET_MODE_NUNITS (MODE)       \
396    : ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD))
397
398 /* A C expression that is nonzero if hard register NEW_REG can be
399    considered for use as a rename register for OLD_REG register.  */
400
401 #define HARD_REGNO_RENAME_OK(OLD_REG, NEW_REG) \
402   m68k_hard_regno_rename_ok (OLD_REG, NEW_REG)
403
404 /* Value is true if hard register REGNO can hold a value of machine-mode MODE.
405    On the 68000, the cpu registers can hold any mode except bytes in
406    address registers, the 68881 registers can hold only SFmode or DFmode.  */
407
408 #define HARD_REGNO_MODE_OK(REGNO, MODE) \
409   m68k_regno_mode_ok ((REGNO), (MODE))
410
411 #define MODES_TIEABLE_P(MODE1, MODE2)                   \
412   (! TARGET_HARD_FLOAT                                  \
413    || ((GET_MODE_CLASS (MODE1) == MODE_FLOAT            \
414         || GET_MODE_CLASS (MODE1) == MODE_COMPLEX_FLOAT)        \
415        == (GET_MODE_CLASS (MODE2) == MODE_FLOAT         \
416            || GET_MODE_CLASS (MODE2) == MODE_COMPLEX_FLOAT)))
417
418 /* Specify the registers used for certain standard purposes.
419    The values of these macros are register numbers.  */
420
421 #define STACK_POINTER_REGNUM 15
422
423 /* Most m68k targets use %a6 as a frame pointer.  The AmigaOS
424    ABI uses %a6 for shared library calls, therefore the frame
425    pointer is shifted to %a5 on this target.  */
426 #define FRAME_POINTER_REGNUM 14
427
428 #define FRAME_POINTER_REQUIRED 0
429
430 /* Base register for access to arguments of the function.
431  * This isn't a hardware register. It will be eliminated to the
432  * stack pointer or frame pointer.
433  */
434 #define ARG_POINTER_REGNUM 24
435
436 #define STATIC_CHAIN_REGNUM 8
437
438 /* Register in which address to store a structure value
439    is passed to a function.  */
440 #define M68K_STRUCT_VALUE_REGNUM 9
441
442 \f
443
444 /* The m68k has three kinds of registers, so eight classes would be
445    a complete set.  One of them is not needed.  */
446 enum reg_class {
447   NO_REGS, DATA_REGS,
448   ADDR_REGS, FP_REGS,
449   GENERAL_REGS, DATA_OR_FP_REGS,
450   ADDR_OR_FP_REGS, ALL_REGS,
451   LIM_REG_CLASSES };
452
453 #define N_REG_CLASSES (int) LIM_REG_CLASSES
454
455 #define REG_CLASS_NAMES \
456  { "NO_REGS", "DATA_REGS",              \
457    "ADDR_REGS", "FP_REGS",              \
458    "GENERAL_REGS", "DATA_OR_FP_REGS",   \
459    "ADDR_OR_FP_REGS", "ALL_REGS" }
460
461 #define REG_CLASS_CONTENTS \
462 {                                       \
463   {0x00000000},  /* NO_REGS */          \
464   {0x000000ff},  /* DATA_REGS */        \
465   {0x0100ff00},  /* ADDR_REGS */        \
466   {0x00ff0000},  /* FP_REGS */          \
467   {0x0100ffff},  /* GENERAL_REGS */     \
468   {0x00ff00ff},  /* DATA_OR_FP_REGS */  \
469   {0x01ffff00},  /* ADDR_OR_FP_REGS */  \
470   {0x01ffffff},  /* ALL_REGS */         \
471 }
472
473 extern enum reg_class regno_reg_class[];
474 #define REGNO_REG_CLASS(REGNO) (regno_reg_class[(REGNO)])
475 #define INDEX_REG_CLASS GENERAL_REGS
476 #define BASE_REG_CLASS ADDR_REGS
477
478 /* We do a trick here to modify the effective constraints on the
479    machine description; we zorch the constraint letters that aren't
480    appropriate for a specific target.  This allows us to guarantee
481    that a specific kind of register will not be used for a given target
482    without fiddling with the register classes above.  */
483 #define REG_CLASS_FROM_LETTER(C) \
484   ((C) == 'a' ? ADDR_REGS :                     \
485    ((C) == 'd' ? DATA_REGS :                    \
486     ((C) == 'f' ? (TARGET_HARD_FLOAT ?          \
487                    FP_REGS : NO_REGS) :         \
488      NO_REGS)))
489
490 /* For the m68k, `I' is used for the range 1 to 8
491    allowed as immediate shift counts and in addq.
492    `J' is used for the range of signed numbers that fit in 16 bits.
493    `K' is for numbers that moveq can't handle.
494    `L' is for range -8 to -1, range of values that can be added with subq.
495    `M' is for numbers that moveq+notb can't handle.
496    'N' is for range 24 to 31, rotatert:SI 8 to 1 expressed as rotate.
497    'O' is for 16 (for rotate using swap).
498    'P' is for range 8 to 15, rotatert:HI 8 to 1 expressed as rotate.  */
499 #define CONST_OK_FOR_LETTER_P(VALUE, C) \
500   ((C) == 'I' ? (VALUE) > 0 && (VALUE) <= 8 : \
501    (C) == 'J' ? (VALUE) >= -0x8000 && (VALUE) <= 0x7FFF : \
502    (C) == 'K' ? (VALUE) < -0x80 || (VALUE) >= 0x80 : \
503    (C) == 'L' ? (VALUE) < 0 && (VALUE) >= -8 : \
504    (C) == 'M' ? (VALUE) < -0x100 || (VALUE) >= 0x100 : \
505    (C) == 'N' ? (VALUE) >= 24 && (VALUE) <= 31 : \
506    (C) == 'O' ? (VALUE) == 16 : \
507    (C) == 'P' ? (VALUE) >= 8 && (VALUE) <= 15 : 0)
508
509 /* "G" defines all of the floating constants that are *NOT* 68881
510    constants.  This is so 68881 constants get reloaded and the
511    fpmovecr is used.  */
512 #define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C)  \
513   ((C) == 'G' ? ! (TARGET_68881 && standard_68881_constant_p (VALUE)) : 0 )
514
515 /* `Q' means address register indirect addressing mode.
516    `S' is for operands that satisfy 'm' when -mpcrel is in effect.
517    `T' is for operands that satisfy 's' when -mpcrel is not in effect.
518    `U' is for register offset addressing.  */
519 #define EXTRA_CONSTRAINT(OP,CODE)                       \
520   (((CODE) == 'S')                                      \
521    ? (TARGET_PCREL                                      \
522       && GET_CODE (OP) == MEM                           \
523       && (GET_CODE (XEXP (OP, 0)) == SYMBOL_REF         \
524           || GET_CODE (XEXP (OP, 0)) == LABEL_REF       \
525           || GET_CODE (XEXP (OP, 0)) == CONST))         \
526    :                                                    \
527   (((CODE) == 'T')                                      \
528    ? ( !TARGET_PCREL                                    \
529       && (GET_CODE (OP) == SYMBOL_REF                   \
530           || GET_CODE (OP) == LABEL_REF                 \
531           || GET_CODE (OP) == CONST))                   \
532    :                                                    \
533   (((CODE) == 'Q')                                      \
534    ? (GET_CODE (OP) == MEM                              \
535       && GET_CODE (XEXP (OP, 0)) == REG)                \
536    :                                                    \
537   (((CODE) == 'U')                                      \
538    ? (GET_CODE (OP) == MEM                              \
539       && GET_CODE (XEXP (OP, 0)) == PLUS                \
540       && GET_CODE (XEXP (XEXP (OP, 0), 0)) == REG       \
541       && GET_CODE (XEXP (XEXP (OP, 0), 1)) == CONST_INT) \
542    :                                                    \
543    0))))
544
545 /* On the m68k, use a data reg if possible when the
546    value is a constant in the range where moveq could be used
547    and we ensure that QImodes are reloaded into data regs.  */
548 #define PREFERRED_RELOAD_CLASS(X,CLASS)  \
549   ((GET_CODE (X) == CONST_INT                   \
550     && (unsigned) (INTVAL (X) + 0x80) < 0x100   \
551     && (CLASS) != ADDR_REGS)                    \
552    ? DATA_REGS                                  \
553    : (GET_MODE (X) == QImode && (CLASS) != ADDR_REGS) \
554    ? DATA_REGS                                  \
555    : (GET_CODE (X) == CONST_DOUBLE                                      \
556       && GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT)                   \
557    ? (TARGET_HARD_FLOAT && (CLASS == FP_REGS || CLASS == DATA_OR_FP_REGS) \
558       ? FP_REGS : NO_REGS)                                              \
559    : (TARGET_PCREL                              \
560       && (GET_CODE (X) == SYMBOL_REF || GET_CODE (X) == CONST \
561           || GET_CODE (X) == LABEL_REF))        \
562    ? ADDR_REGS                                  \
563    : (CLASS))
564
565 /* Force QImode output reloads from subregs to be allocated to data regs,
566    since QImode stores from address regs are not supported.  We make the
567    assumption that if the class is not ADDR_REGS, then it must be a superset
568    of DATA_REGS.  */
569 #define LIMIT_RELOAD_CLASS(MODE, CLASS) \
570   (((MODE) == QImode && (CLASS) != ADDR_REGS)   \
571    ? DATA_REGS                                  \
572    : (CLASS))
573
574 /* On the m68k, this is the size of MODE in words,
575    except in the FP regs, where a single reg is always enough.  */
576 #define CLASS_MAX_NREGS(CLASS, MODE)    \
577  ((CLASS) == FP_REGS ? 1 \
578   : ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD))
579
580 /* Moves between fp regs and other regs are two insns.  */
581 #define REGISTER_MOVE_COST(MODE, CLASS1, CLASS2)        \
582   (((CLASS1) == FP_REGS && (CLASS2) != FP_REGS)         \
583     || ((CLASS2) == FP_REGS && (CLASS1) != FP_REGS)     \
584     ? 4 : 2)
585 \f
586 /* Stack layout; function entry, exit and calling.  */
587
588 #define STACK_GROWS_DOWNWARD
589 #define FRAME_GROWS_DOWNWARD 1
590 #define STARTING_FRAME_OFFSET 0
591
592 /* On the 680x0, sp@- in a byte insn really pushes a word.
593    On the ColdFire, sp@- in a byte insn pushes just a byte.  */
594 #define PUSH_ROUNDING(BYTES) (TARGET_COLDFIRE ? BYTES : ((BYTES) + 1) & ~1)
595
596 #define FIRST_PARM_OFFSET(FNDECL) 8
597
598 /* On the 68000, the RTS insn cannot pop anything.
599    On the 68010, the RTD insn may be used to pop them if the number
600      of args is fixed, but if the number is variable then the caller
601      must pop them all.  RTD can't be used for library calls now
602      because the library is compiled with the Unix compiler.
603    Use of RTD is a selectable option, since it is incompatible with
604    standard Unix calling sequences.  If the option is not selected,
605    the caller must always pop the args.  */
606 #define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE)   \
607   ((TARGET_RTD && (!(FUNDECL) || TREE_CODE (FUNDECL) != IDENTIFIER_NODE)        \
608     && (TYPE_ARG_TYPES (FUNTYPE) == 0                           \
609         || (TREE_VALUE (tree_last (TYPE_ARG_TYPES (FUNTYPE)))   \
610             == void_type_node)))                                \
611    ? (SIZE) : 0)
612
613 /* On the m68k the return value is always in D0.  */
614 #define FUNCTION_VALUE(VALTYPE, FUNC)  \
615   gen_rtx_REG (TYPE_MODE (VALTYPE), 0)
616
617 /* On the m68k the return value is always in D0.  */
618 #define LIBCALL_VALUE(MODE)  gen_rtx_REG (MODE, 0)
619
620 /* On the m68k, D0 is the only register used.  */
621 #define FUNCTION_VALUE_REGNO_P(N) ((N) == 0)
622
623 /* Define this to be true when FUNCTION_VALUE_REGNO_P is true for
624    more than one register.
625    XXX This macro is m68k specific and used only for m68kemb.h.  */
626 #define NEEDS_UNTYPED_CALL 0
627
628 #define PCC_STATIC_STRUCT_RETURN
629
630 /* On the m68k, all arguments are usually pushed on the stack.  */
631 #define FUNCTION_ARG_REGNO_P(N) 0
632 \f
633 /* On the m68k, this is a single integer, which is a number of bytes
634    of arguments scanned so far.  */
635 #define CUMULATIVE_ARGS int
636
637 /* On the m68k, the offset starts at 0.  */
638 #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, INDIRECT, N_NAMED_ARGS) \
639  ((CUM) = 0)
640
641 #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED)    \
642  ((CUM) += ((MODE) != BLKmode                   \
643             ? (GET_MODE_SIZE (MODE) + 3) & ~3   \
644             : (int_size_in_bytes (TYPE) + 3) & ~3))
645
646 /* On the m68k all args are always pushed.  */
647 #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) 0
648
649 #define FUNCTION_PROFILER(FILE, LABELNO)  \
650   asm_fprintf (FILE, "\tlea %LLP%d,%Ra0\n\tjsr mcount\n", (LABELNO))
651
652 #define EXIT_IGNORE_STACK 1
653
654 /* Determine if the epilogue should be output as RTL.
655    You should override this if you define FUNCTION_EXTRA_EPILOGUE.
656
657    XXX This macro is m68k-specific and only used in m68k.md.  */
658 #define USE_RETURN_INSN use_return_insn ()
659
660 /* Output assembler code for a block containing the constant parts
661    of a trampoline, leaving space for the variable parts.
662
663    On the m68k, the trampoline looks like this:
664      movl #STATIC,a0
665      jmp  FUNCTION
666
667    WARNING: Targets that may run on 68040+ cpus must arrange for
668    the instruction cache to be flushed.  Previous incarnations of
669    the m68k trampoline code attempted to get around this by either
670    using an out-of-line transfer function or pc-relative data, but
671    the fact remains that the code to jump to the transfer function
672    or the code to load the pc-relative data needs to be flushed
673    just as much as the "variable" portion of the trampoline.
674    Recognizing that a cache flush is going to be required anyway,
675    dispense with such notions and build a smaller trampoline.
676
677    Since more instructions are required to move a template into
678    place than to create it on the spot, don't use a template.  */
679
680 #define TRAMPOLINE_SIZE 12
681 #define TRAMPOLINE_ALIGNMENT 16
682
683 /* Targets redefine this to invoke code to either flush the cache,
684    or enable stack execution (or both).  */
685 #ifndef FINALIZE_TRAMPOLINE
686 #define FINALIZE_TRAMPOLINE(TRAMP)
687 #endif
688
689 /* We generate a two-instructions program at address TRAMP :
690         movea.l &CXT,%a0
691         jmp FNADDR  */
692 #define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT)                       \
693 {                                                                       \
694   emit_move_insn (gen_rtx_MEM (HImode, TRAMP), GEN_INT(0x207C));        \
695   emit_move_insn (gen_rtx_MEM (SImode, plus_constant (TRAMP, 2)), CXT); \
696   emit_move_insn (gen_rtx_MEM (HImode, plus_constant (TRAMP, 6)),       \
697                   GEN_INT(0x4EF9));                                     \
698   emit_move_insn (gen_rtx_MEM (SImode, plus_constant (TRAMP, 8)), FNADDR); \
699   FINALIZE_TRAMPOLINE(TRAMP);                                           \
700 }
701
702 /* This is the library routine that is used to transfer control from the
703    trampoline to the actual nested function.  It is defined for backward
704    compatibility, for linking with object code that used the old trampoline
705    definition.
706
707    A colon is used with no explicit operands to cause the template string
708    to be scanned for %-constructs.
709
710    The function name __transfer_from_trampoline is not actually used.
711    The function definition just permits use of "asm with operands"
712    (though the operand list is empty).  */
713 #define TRANSFER_FROM_TRAMPOLINE                                \
714 void                                                            \
715 __transfer_from_trampoline ()                                   \
716 {                                                               \
717   register char *a0 asm ("%a0");                                \
718   asm (GLOBAL_ASM_OP "___trampoline");                          \
719   asm ("___trampoline:");                                       \
720   asm volatile ("move%.l %0,%@" : : "m" (a0[22]));              \
721   asm volatile ("move%.l %1,%0" : "=a" (a0) : "m" (a0[18]));    \
722   asm ("rts":);                                                 \
723 }
724 \f
725 /* There are two registers that can always be eliminated on the m68k.
726    The frame pointer and the arg pointer can be replaced by either the
727    hard frame pointer or to the stack pointer, depending upon the
728    circumstances.  The hard frame pointer is not used before reload and
729    so it is not eligible for elimination.  */
730 #define ELIMINABLE_REGS                                 \
731 {{ ARG_POINTER_REGNUM, STACK_POINTER_REGNUM },          \
732  { ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM },          \
733  { FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM }}
734
735 #define CAN_ELIMINATE(FROM, TO) \
736   ((TO) == STACK_POINTER_REGNUM ? ! frame_pointer_needed : 1)
737
738 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET)                    \
739   (OFFSET) = m68k_initial_elimination_offset(FROM, TO)
740 \f
741 /* Addressing modes, and classification of registers for them.  */
742
743 #define HAVE_POST_INCREMENT 1
744 #define HAVE_PRE_DECREMENT 1
745
746 /* Macros to check register numbers against specific register classes.  */
747
748 #define REGNO_OK_FOR_INDEX_P(REGNO) \
749 ((REGNO) < 16 || (unsigned) reg_renumber[REGNO] < 16)
750 #define REGNO_OK_FOR_BASE_P(REGNO) \
751 (((REGNO) ^ 010) < 8 || (unsigned) (reg_renumber[REGNO] ^ 010) < 8)
752 #define REGNO_OK_FOR_DATA_P(REGNO) \
753 ((REGNO) < 8 || (unsigned) reg_renumber[REGNO] < 8)
754 #define REGNO_OK_FOR_FP_P(REGNO) \
755 (((REGNO) ^ 020) < 8 || (unsigned) (reg_renumber[REGNO] ^ 020) < 8)
756
757 /* Now macros that check whether X is a register and also,
758    strictly, whether it is in a specified class.
759
760    These macros are specific to the m68k, and may be used only
761    in code for printing assembler insns and in conditions for
762    define_optimization.  */
763
764 /* 1 if X is a data register.  */
765 #define DATA_REG_P(X) (REG_P (X) && REGNO_OK_FOR_DATA_P (REGNO (X)))
766
767 /* 1 if X is an fp register.  */
768 #define FP_REG_P(X) (REG_P (X) && REGNO_OK_FOR_FP_P (REGNO (X)))
769
770 /* 1 if X is an address register  */
771 #define ADDRESS_REG_P(X) (REG_P (X) && REGNO_OK_FOR_BASE_P (REGNO (X)))
772 \f
773
774 #define MAX_REGS_PER_ADDRESS 2
775
776 #define CONSTANT_ADDRESS_P(X)   \
777   (GET_CODE (X) == LABEL_REF || GET_CODE (X) == SYMBOL_REF              \
778    || GET_CODE (X) == CONST_INT || GET_CODE (X) == CONST                \
779    || GET_CODE (X) == HIGH)
780
781 /* Nonzero if the constant value X is a legitimate general operand.
782    It is given that X satisfies CONSTANT_P or is a CONST_DOUBLE.  */
783 #define LEGITIMATE_CONSTANT_P(X) (GET_MODE (X) != XFmode)
784
785 #ifndef REG_OK_STRICT
786 #define PCREL_GENERAL_OPERAND_OK 0
787 #else
788 #define PCREL_GENERAL_OPERAND_OK (TARGET_PCREL)
789 #endif
790
791 #define LEGITIMATE_PIC_OPERAND_P(X)     \
792   (! symbolic_operand (X, VOIDmode)                             \
793    || (GET_CODE (X) == SYMBOL_REF && SYMBOL_REF_FLAG (X))       \
794    || PCREL_GENERAL_OPERAND_OK)
795
796 #ifndef REG_OK_STRICT
797
798 /* Nonzero if X is a hard reg that can be used as an index
799    or if it is a pseudo reg.  */
800 #define REG_OK_FOR_INDEX_P(X) ((REGNO (X) ^ 020) >= 8)
801 /* Nonzero if X is a hard reg that can be used as a base reg
802    or if it is a pseudo reg.  */
803 #define REG_OK_FOR_BASE_P(X) ((REGNO (X) & ~027) != 0)
804
805 #else
806
807 /* Nonzero if X is a hard reg that can be used as an index.  */
808 #define REG_OK_FOR_INDEX_P(X) REGNO_OK_FOR_INDEX_P (REGNO (X))
809 /* Nonzero if X is a hard reg that can be used as a base reg.  */
810 #define REG_OK_FOR_BASE_P(X) REGNO_OK_FOR_BASE_P (REGNO (X))
811
812 #endif
813 \f
814 /* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression
815    that is a valid memory address for an instruction.
816    The MODE argument is the machine mode for the MEM expression
817    that wants to use this address.
818
819    When generating PIC, an address involving a SYMBOL_REF is legitimate
820    if and only if it is the sum of pic_offset_table_rtx and the SYMBOL_REF.
821    We use LEGITIMATE_PIC_OPERAND_P to throw out the illegitimate addresses,
822    and we explicitly check for the sum of pic_offset_table_rtx and a SYMBOL_REF.
823
824    Likewise for a LABEL_REF when generating PIC.
825
826    The other macros defined here are used only in GO_IF_LEGITIMATE_ADDRESS.  */
827
828 /* Allow SUBREG everywhere we allow REG.  This results in better code.  It
829    also makes function inlining work when inline functions are called with
830    arguments that are SUBREGs.  */
831
832 #define LEGITIMATE_BASE_REG_P(X)   \
833   ((GET_CODE (X) == REG && REG_OK_FOR_BASE_P (X))       \
834    || (GET_CODE (X) == SUBREG                           \
835        && GET_CODE (SUBREG_REG (X)) == REG              \
836        && REG_OK_FOR_BASE_P (SUBREG_REG (X))))
837
838 #define INDIRECTABLE_1_ADDRESS_P(X)  \
839   ((CONSTANT_ADDRESS_P (X) && (!flag_pic || LEGITIMATE_PIC_OPERAND_P (X))) \
840    || LEGITIMATE_BASE_REG_P (X)                                         \
841    || ((GET_CODE (X) == PRE_DEC || GET_CODE (X) == POST_INC)            \
842        && LEGITIMATE_BASE_REG_P (XEXP (X, 0)))                          \
843    || (GET_CODE (X) == PLUS                                             \
844        && LEGITIMATE_BASE_REG_P (XEXP (X, 0))                           \
845        && GET_CODE (XEXP (X, 1)) == CONST_INT                           \
846        && (TARGET_68020                                                 \
847            || ((unsigned) INTVAL (XEXP (X, 1)) + 0x8000) < 0x10000))    \
848    || (GET_CODE (X) == PLUS && XEXP (X, 0) == pic_offset_table_rtx      \
849        && flag_pic && GET_CODE (XEXP (X, 1)) == SYMBOL_REF)             \
850    || (GET_CODE (X) == PLUS && XEXP (X, 0) == pic_offset_table_rtx      \
851        && flag_pic && GET_CODE (XEXP (X, 1)) == LABEL_REF))
852
853 #define GO_IF_NONINDEXED_ADDRESS(X, ADDR)  \
854 { if (INDIRECTABLE_1_ADDRESS_P (X)) goto ADDR; }
855
856 /* Only labels on dispatch tables are valid for indexing from.  */
857 #define GO_IF_INDEXABLE_BASE(X, ADDR)                           \
858 { rtx temp;                                                     \
859   if (GET_CODE (X) == LABEL_REF                                 \
860       && (temp = next_nonnote_insn (XEXP (X, 0))) != 0          \
861       && GET_CODE (temp) == JUMP_INSN                           \
862       && (GET_CODE (PATTERN (temp)) == ADDR_VEC                 \
863           || GET_CODE (PATTERN (temp)) == ADDR_DIFF_VEC))       \
864     goto ADDR;                                                  \
865   if (LEGITIMATE_BASE_REG_P (X)) goto ADDR; }
866
867 #define GO_IF_INDEXING(X, ADDR) \
868 { if (GET_CODE (X) == PLUS && LEGITIMATE_INDEX_P (XEXP (X, 0)))         \
869     { GO_IF_INDEXABLE_BASE (XEXP (X, 1), ADDR); }                       \
870   if (GET_CODE (X) == PLUS && LEGITIMATE_INDEX_P (XEXP (X, 1)))         \
871     { GO_IF_INDEXABLE_BASE (XEXP (X, 0), ADDR); } }
872
873 #define GO_IF_INDEXED_ADDRESS(X, ADDR)   \
874 { GO_IF_INDEXING (X, ADDR);                                             \
875   if (GET_CODE (X) == PLUS)                                             \
876     { if (GET_CODE (XEXP (X, 1)) == CONST_INT                           \
877           && (TARGET_68020 || (unsigned) INTVAL (XEXP (X, 1)) + 0x80 < 0x100))          \
878         { rtx go_temp = XEXP (X, 0); GO_IF_INDEXING (go_temp, ADDR); }  \
879       if (GET_CODE (XEXP (X, 0)) == CONST_INT                           \
880           && (TARGET_68020 || (unsigned) INTVAL (XEXP (X, 0)) + 0x80 < 0x100))          \
881         { rtx go_temp = XEXP (X, 1); GO_IF_INDEXING (go_temp, ADDR); } } }
882
883 /* ColdFire/5200 does not allow HImode index registers.  */
884 #define LEGITIMATE_INDEX_REG_P(X)   \
885   ((GET_CODE (X) == REG && REG_OK_FOR_INDEX_P (X))      \
886    || (! TARGET_COLDFIRE                                        \
887        && GET_CODE (X) == SIGN_EXTEND                   \
888        && GET_CODE (XEXP (X, 0)) == REG                 \
889        && GET_MODE (XEXP (X, 0)) == HImode              \
890        && REG_OK_FOR_INDEX_P (XEXP (X, 0)))             \
891    || (GET_CODE (X) == SUBREG                           \
892        && GET_CODE (SUBREG_REG (X)) == REG              \
893        && REG_OK_FOR_INDEX_P (SUBREG_REG (X))))
894
895 #define LEGITIMATE_INDEX_P(X)   \
896    (LEGITIMATE_INDEX_REG_P (X)                          \
897     || ((TARGET_68020 || TARGET_COLDFIRE) && GET_CODE (X) == MULT \
898         && LEGITIMATE_INDEX_REG_P (XEXP (X, 0))         \
899         && GET_CODE (XEXP (X, 1)) == CONST_INT          \
900         && (INTVAL (XEXP (X, 1)) == 2                   \
901             || INTVAL (XEXP (X, 1)) == 4                \
902             || (INTVAL (XEXP (X, 1)) == 8               \
903                 && (TARGET_COLDFIRE_FPU || !TARGET_COLDFIRE)))))
904
905 /* Coldfire FPU only accepts addressing modes 2-5 */
906 #define GO_IF_COLDFIRE_FPU_LEGITIMATE_ADDRESS(MODE, X, ADDR)            \
907 { if (LEGITIMATE_BASE_REG_P (X)                                         \
908       || ((GET_CODE (X) == PRE_DEC || GET_CODE (X) == POST_INC)         \
909           && LEGITIMATE_BASE_REG_P (XEXP (X, 0)))                       \
910       || ((GET_CODE (X) == PLUS) && LEGITIMATE_BASE_REG_P (XEXP (X, 0)) \
911           && (GET_CODE (XEXP (X, 1)) == CONST_INT)                      \
912           && ((((unsigned) INTVAL (XEXP (X, 1)) + 0x8000) < 0x10000)))) \
913   goto ADDR;}
914
915 /* If pic, we accept INDEX+LABEL, which is what do_tablejump makes.  */
916 #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR)                         \
917 { if (TARGET_COLDFIRE_FPU && (GET_MODE_CLASS (MODE) == MODE_FLOAT))     \
918     {                                                                   \
919       GO_IF_COLDFIRE_FPU_LEGITIMATE_ADDRESS (MODE, X, ADDR);            \
920     }                                                                   \
921   else                                                                  \
922     {                                                                   \
923       GO_IF_NONINDEXED_ADDRESS (X, ADDR);                               \
924       GO_IF_INDEXED_ADDRESS (X, ADDR);                                  \
925       if (flag_pic && MODE == CASE_VECTOR_MODE && GET_CODE (X) == PLUS  \
926           && LEGITIMATE_INDEX_P (XEXP (X, 0))                           \
927           && GET_CODE (XEXP (X, 1)) == LABEL_REF)                       \
928         goto ADDR;                                                      \
929     }}
930
931 /* Don't call memory_address_noforce for the address to fetch
932    the switch offset.  This address is ok as it stands (see above),
933    but memory_address_noforce would alter it.  */
934 #define PIC_CASE_VECTOR_ADDRESS(index) index
935 \f
936 /* For the 68000, we handle X+REG by loading X into a register R and
937    using R+REG.  R will go in an address reg and indexing will be used.
938    However, if REG is a broken-out memory address or multiplication,
939    nothing needs to be done because REG can certainly go in an address reg.  */
940 #define COPY_ONCE(Y) if (!copied) { Y = copy_rtx (Y); copied = ch = 1; }
941 #define LEGITIMIZE_ADDRESS(X,OLDX,MODE,WIN)   \
942 { register int ch = (X) != (OLDX);                                      \
943   if (GET_CODE (X) == PLUS)                                             \
944     { int copied = 0;                                                   \
945       if (GET_CODE (XEXP (X, 0)) == MULT)                               \
946         { COPY_ONCE (X); XEXP (X, 0) = force_operand (XEXP (X, 0), 0);} \
947       if (GET_CODE (XEXP (X, 1)) == MULT)                               \
948         { COPY_ONCE (X); XEXP (X, 1) = force_operand (XEXP (X, 1), 0);} \
949       if (ch && GET_CODE (XEXP (X, 1)) == REG                           \
950           && GET_CODE (XEXP (X, 0)) == REG)                             \
951         { if (TARGET_COLDFIRE_FPU                                       \
952               && GET_MODE_CLASS (MODE) == MODE_FLOAT)                   \
953             { COPY_ONCE (X); X = force_operand (X, 0);}                 \
954           goto WIN; }                                                   \
955       if (ch) { GO_IF_LEGITIMATE_ADDRESS (MODE, X, WIN); }              \
956       if (GET_CODE (XEXP (X, 0)) == REG                                 \
957                || (GET_CODE (XEXP (X, 0)) == SIGN_EXTEND                \
958                    && GET_CODE (XEXP (XEXP (X, 0), 0)) == REG           \
959                    && GET_MODE (XEXP (XEXP (X, 0), 0)) == HImode))      \
960         { register rtx temp = gen_reg_rtx (Pmode);                      \
961           register rtx val = force_operand (XEXP (X, 1), 0);            \
962           emit_move_insn (temp, val);                                   \
963           COPY_ONCE (X);                                                \
964           XEXP (X, 1) = temp;                                           \
965           if (TARGET_COLDFIRE_FPU && GET_MODE_CLASS (MODE) == MODE_FLOAT \
966               && GET_CODE (XEXP (X, 0)) == REG)                         \
967             X = force_operand (X, 0);                                   \
968           goto WIN; }                                                   \
969       else if (GET_CODE (XEXP (X, 1)) == REG                            \
970                || (GET_CODE (XEXP (X, 1)) == SIGN_EXTEND                \
971                    && GET_CODE (XEXP (XEXP (X, 1), 0)) == REG           \
972                    && GET_MODE (XEXP (XEXP (X, 1), 0)) == HImode))      \
973         { register rtx temp = gen_reg_rtx (Pmode);                      \
974           register rtx val = force_operand (XEXP (X, 0), 0);            \
975           emit_move_insn (temp, val);                                   \
976           COPY_ONCE (X);                                                \
977           XEXP (X, 0) = temp;                                           \
978           if (TARGET_COLDFIRE_FPU && GET_MODE_CLASS (MODE) == MODE_FLOAT \
979               && GET_CODE (XEXP (X, 1)) == REG)                         \
980             X = force_operand (X, 0);                                   \
981           goto WIN; }}}
982
983 /* On the 68000, only predecrement and postincrement address depend thus
984    (the amount of decrement or increment being the length of the operand).
985    These are now treated generically in recog.c.  */
986 #define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR,LABEL)
987 \f
988 #define CASE_VECTOR_MODE HImode
989 #define CASE_VECTOR_PC_RELATIVE 1
990
991 #define DEFAULT_SIGNED_CHAR 1
992 #define MOVE_MAX 4
993 #define SLOW_BYTE_ACCESS 0
994
995 #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
996
997 #define STORE_FLAG_VALUE (-1)
998
999 #define Pmode SImode
1000 #define FUNCTION_MODE QImode
1001
1002 \f
1003 /* Tell final.c how to eliminate redundant test instructions.  */
1004
1005 /* Here we define machine-dependent flags and fields in cc_status
1006    (see `conditions.h').  */
1007
1008 /* Set if the cc value is actually in the 68881, so a floating point
1009    conditional branch must be output.  */
1010 #define CC_IN_68881 04000
1011
1012 /* On the 68000, all the insns to store in an address register fail to
1013    set the cc's.  However, in some cases these instructions can make it
1014    possibly invalid to use the saved cc's.  In those cases we clear out
1015    some or all of the saved cc's so they won't be used.  */
1016 #define NOTICE_UPDATE_CC(EXP,INSN) notice_update_cc (EXP, INSN)
1017
1018 #define OUTPUT_JUMP(NORMAL, FLOAT, NO_OV)  \
1019 do { if (cc_prev_status.flags & CC_IN_68881)                    \
1020     return FLOAT;                                               \
1021   if (cc_prev_status.flags & CC_NO_OVERFLOW)                    \
1022     return NO_OV;                                               \
1023   return NORMAL; } while (0)
1024 \f
1025 /* Control the assembler format that we output.  */
1026
1027 #define ASM_APP_ON "#APP\n"
1028 #define ASM_APP_OFF "#NO_APP\n"
1029 #define TEXT_SECTION_ASM_OP "\t.text"
1030 #define DATA_SECTION_ASM_OP "\t.data"
1031 #define GLOBAL_ASM_OP "\t.globl\t"
1032 #define REGISTER_PREFIX ""
1033 #define LOCAL_LABEL_PREFIX ""
1034 #define USER_LABEL_PREFIX "_"
1035 #define IMMEDIATE_PREFIX "#"
1036
1037 #define REGISTER_NAMES \
1038 {REGISTER_PREFIX"d0", REGISTER_PREFIX"d1", REGISTER_PREFIX"d2", \
1039  REGISTER_PREFIX"d3", REGISTER_PREFIX"d4", REGISTER_PREFIX"d5", \
1040  REGISTER_PREFIX"d6", REGISTER_PREFIX"d7",                      \
1041  REGISTER_PREFIX"a0", REGISTER_PREFIX"a1", REGISTER_PREFIX"a2", \
1042  REGISTER_PREFIX"a3", REGISTER_PREFIX"a4", REGISTER_PREFIX"a5", \
1043  REGISTER_PREFIX"a6", REGISTER_PREFIX"sp",                      \
1044  REGISTER_PREFIX"fp0", REGISTER_PREFIX"fp1", REGISTER_PREFIX"fp2", \
1045  REGISTER_PREFIX"fp3", REGISTER_PREFIX"fp4", REGISTER_PREFIX"fp5", \
1046  REGISTER_PREFIX"fp6", REGISTER_PREFIX"fp7", REGISTER_PREFIX"argptr" }
1047
1048 #define M68K_FP_REG_NAME REGISTER_PREFIX"fp"
1049
1050 /* Return a register name by index, handling %fp nicely.
1051    We don't replace %fp for targets that don't map it to %a6
1052    since it may confuse GAS.  */
1053 #define M68K_REGNAME(r) ( \
1054   ((FRAME_POINTER_REGNUM == 14) \
1055     && ((r) == FRAME_POINTER_REGNUM) \
1056     && frame_pointer_needed) ? \
1057     M68K_FP_REG_NAME : reg_names[(r)])
1058
1059 /* On the Sun-3, the floating point registers have numbers
1060    18 to 25, not 16 to 23 as they do in the compiler.  */
1061 #define DBX_REGISTER_NUMBER(REGNO) ((REGNO) < 16 ? (REGNO) : (REGNO) + 2)
1062
1063 /* Before the prologue, RA is at 0(%sp).  */
1064 #define INCOMING_RETURN_ADDR_RTX \
1065   gen_rtx_MEM (VOIDmode, gen_rtx_REG (VOIDmode, STACK_POINTER_REGNUM))
1066
1067 /* After the prologue, RA is at 4(AP) in the current frame.  */
1068 #define RETURN_ADDR_RTX(COUNT, FRAME)                                      \
1069   ((COUNT) == 0                                                            \
1070    ? gen_rtx_MEM (Pmode, plus_constant (arg_pointer_rtx, UNITS_PER_WORD)) \
1071    : gen_rtx_MEM (Pmode, plus_constant (FRAME, UNITS_PER_WORD)))
1072
1073 /* We must not use the DBX register numbers for the DWARF 2 CFA column
1074    numbers because that maps to numbers beyond FIRST_PSEUDO_REGISTER.
1075    Instead use the identity mapping.  */
1076 #define DWARF_FRAME_REGNUM(REG) REG
1077
1078 /* Before the prologue, the top of the frame is at 4(%sp).  */
1079 #define INCOMING_FRAME_SP_OFFSET 4
1080
1081 /* Describe how we implement __builtin_eh_return.  */
1082 #define EH_RETURN_DATA_REGNO(N) \
1083   ((N) < 2 ? (N) : INVALID_REGNUM)
1084 #define EH_RETURN_STACKADJ_RTX  gen_rtx_REG (Pmode, 8)
1085 #define EH_RETURN_HANDLER_RTX                                       \
1086   gen_rtx_MEM (Pmode,                                               \
1087                gen_rtx_PLUS (Pmode, arg_pointer_rtx,                \
1088                              plus_constant (EH_RETURN_STACKADJ_RTX, \
1089                                             UNITS_PER_WORD)))
1090
1091 /* Select a format to encode pointers in exception handling data.  CODE
1092    is 0 for data, 1 for code labels, 2 for function pointers.  GLOBAL is
1093    true if the symbol may be affected by dynamic relocations.  */
1094 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL)                         \
1095   (flag_pic                                                                \
1096    ? ((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel | DW_EH_PE_sdata4 \
1097    : DW_EH_PE_absptr)
1098
1099 #define ASM_OUTPUT_LABELREF(FILE,NAME)  \
1100   asm_fprintf (FILE, "%U%s", NAME)
1101
1102 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM)   \
1103   sprintf (LABEL, "*%s%s%ld", LOCAL_LABEL_PREFIX, PREFIX, (long)(NUM))
1104
1105 #define ASM_OUTPUT_REG_PUSH(FILE,REGNO)  \
1106   asm_fprintf (FILE, "\tmovel %s,%Rsp@-\n", reg_names[REGNO])
1107 #define ASM_OUTPUT_REG_POP(FILE,REGNO)  \
1108   asm_fprintf (FILE, "\tmovel %Rsp@+,%s\n", reg_names[REGNO])
1109
1110 /* The m68k does not use absolute case-vectors, but we must define this macro
1111    anyway.  */
1112 #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE)  \
1113   asm_fprintf (FILE, "\t.long %LL%d\n", VALUE)
1114
1115 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL)  \
1116   asm_fprintf (FILE, "\t.word %LL%d-%LL%d\n", VALUE, REL)
1117
1118 /* We don't have a way to align to more than a two-byte boundary, so do the
1119    best we can and don't complain.  */
1120 #define ASM_OUTPUT_ALIGN(FILE,LOG)      \
1121   if ((LOG) >= 1)                       \
1122     fprintf (FILE, "\t.even\n");
1123
1124 #define ASM_OUTPUT_SKIP(FILE,SIZE)  \
1125   fprintf (FILE, "\t.skip %u\n", (int)(SIZE))
1126
1127 #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED)  \
1128 ( fputs (".comm ", (FILE)),                     \
1129   assemble_name ((FILE), (NAME)),               \
1130   fprintf ((FILE), ",%u\n", (int)(ROUNDED)))
1131
1132 #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED)  \
1133 ( fputs (".lcomm ", (FILE)),                    \
1134   assemble_name ((FILE), (NAME)),               \
1135   fprintf ((FILE), ",%u\n", (int)(ROUNDED)))
1136
1137 /* Output a float value (represented as a C double) as an immediate operand.
1138    This macro is m68k-specific.  */
1139 #define ASM_OUTPUT_FLOAT_OPERAND(CODE,FILE,VALUE)               \
1140  do {                                                           \
1141       if (CODE == 'f')                                          \
1142         {                                                       \
1143           char dstr[30];                                        \
1144           real_to_decimal (dstr, &(VALUE), sizeof (dstr), 9, 0); \
1145           asm_fprintf ((FILE), "%I0r%s", dstr);                 \
1146         }                                                       \
1147       else                                                      \
1148         {                                                       \
1149           long l;                                               \
1150           REAL_VALUE_TO_TARGET_SINGLE (VALUE, l);               \
1151           asm_fprintf ((FILE), "%I0x%lx", l);                   \
1152         }                                                       \
1153      } while (0)
1154
1155 /* Output a double value (represented as a C double) as an immediate operand.
1156    This macro is m68k-specific.  */
1157 #define ASM_OUTPUT_DOUBLE_OPERAND(FILE,VALUE)                           \
1158  do { char dstr[30];                                                    \
1159       real_to_decimal (dstr, &(VALUE), sizeof (dstr), 0, 1);            \
1160       asm_fprintf (FILE, "%I0r%s", dstr);                               \
1161     } while (0)
1162
1163 /* Note, long double immediate operands are not actually
1164    generated by m68k.md.  */
1165 #define ASM_OUTPUT_LONG_DOUBLE_OPERAND(FILE,VALUE)                      \
1166  do { char dstr[30];                                                    \
1167       real_to_decimal (dstr, &(VALUE), sizeof (dstr), 0, 1);            \
1168       asm_fprintf (FILE, "%I0r%s", dstr);                               \
1169     } while (0)
1170
1171 /* On the 68000, we use several CODE characters:
1172    '.' for dot needed in Motorola-style opcode names.
1173    '-' for an operand pushing on the stack:
1174        sp@-, -(sp) or -(%sp) depending on the style of syntax.
1175    '+' for an operand pushing on the stack:
1176        sp@+, (sp)+ or (%sp)+ depending on the style of syntax.
1177    '@' for a reference to the top word on the stack:
1178        sp@, (sp) or (%sp) depending on the style of syntax.
1179    '#' for an immediate operand prefix (# in MIT and Motorola syntax
1180        but & in SGS syntax).
1181    '!' for the fpcr register (used in some float-to-fixed conversions).
1182    '$' for the letter `s' in an op code, but only on the 68040.
1183    '&' for the letter `d' in an op code, but only on the 68040.
1184    '/' for register prefix needed by longlong.h.
1185
1186    'b' for byte insn (no effect, on the Sun; this is for the ISI).
1187    'd' to force memory addressing to be absolute, not relative.
1188    'f' for float insn (print a CONST_DOUBLE as a float rather than in hex)
1189    'o' for operands to go directly to output_operand_address (bypassing
1190        print_operand_address--used only for SYMBOL_REFs under TARGET_PCREL)
1191    'x' for float insn (print a CONST_DOUBLE as a float rather than in hex),
1192        or print pair of registers as rx:ry.  */
1193
1194 #define PRINT_OPERAND_PUNCT_VALID_P(CODE)                               \
1195   ((CODE) == '.' || (CODE) == '#' || (CODE) == '-'                      \
1196    || (CODE) == '+' || (CODE) == '@' || (CODE) == '!'                   \
1197    || (CODE) == '$' || (CODE) == '&' || (CODE) == '/')
1198
1199
1200 /* See m68k.c for the m68k specific codes.  */
1201 #define PRINT_OPERAND(FILE, X, CODE) print_operand (FILE, X, CODE)
1202
1203 #define PRINT_OPERAND_ADDRESS(FILE, ADDR) print_operand_address (FILE, ADDR)
1204
1205 /* Values used in the MICROARCH argument to M68K_DEVICE.  */
1206 enum uarch_type
1207 {
1208   u68000,
1209   u68010,
1210   u68020,
1211   u68020_40,
1212   u68020_60,
1213   u68030,
1214   u68040,
1215   u68060,
1216   ucpu32,
1217   ucfv2,
1218   ucfv3,
1219   ucfv4,
1220   ucfv4e,
1221   ucfv5,
1222   unk_arch
1223 };
1224
1225 /* An enumeration of all supported target devices.  */
1226 enum target_device
1227 {
1228 #define M68K_DEVICE(NAME,ENUM_VALUE,FAMILY,MULTILIB,MICROARCH,ISA,FLAGS) \
1229   ENUM_VALUE,
1230 #include "m68k-devices.def"
1231 #undef M68K_DEVICE
1232   unk_device
1233 };
1234
1235 enum fpu_type
1236 {
1237   FPUTYPE_NONE,
1238   FPUTYPE_68881,
1239   FPUTYPE_COLDFIRE
1240 };
1241
1242 /* Variables in m68k.c; see there for details.  */
1243 extern const char *m68k_library_id_string;
1244 extern int m68k_last_compare_had_fp_operands;
1245 extern enum target_device m68k_cpu;
1246 extern enum uarch_type m68k_tune;
1247 extern enum fpu_type m68k_fpu;
1248 extern unsigned int m68k_cpu_flags;