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