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