OSDN Git Service

* rtl.h (addr_diff_vec_flags): New typedef.
[pf3gnuchains/gcc-fork.git] / gcc / config / m68k / m68kv4.h
1 /* Target definitions for GNU compiler for mc680x0 running System V.4
2    Copyright (C) 1991, 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
3    Contributed by Ron Guilmette (rfg@monkeys.com) and
4    Fred Fish (fnf@cygnus.com).
5
6 This file is part of GNU CC.
7
8 GNU CC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12
13 GNU CC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GNU CC; see the file COPYING.  If not, write to
20 the Free Software Foundation, 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA.  */
22
23 /* Use SGS_* macros to control compilation in m68k.md */
24
25 #define SGS_SWITCH_TABLES       /* Different switch table handling */
26
27 #include "m68k/sgs.h"           /* The m68k/SVR4 assembler is SGS based */
28
29 /* The SGS assembler requires a special definition of
30    ASM_IDENTIFY_GCC.  We combine the m68k/sgs.h and the svr4.h
31    definitions below.  */
32 #undef ASM_IDENTIFY_GCC
33
34 #include "svr4.h"               /* Pick up the generic SVR4 macros */
35
36 /* See m68k.h.  7 means 68020 with 68881.  */
37
38 #ifndef TARGET_DEFAULT
39 #define TARGET_DEFAULT (MASK_BITFIELD|MASK_68881|MASK_68020)
40 #endif
41
42 /* When using an SGS assembler, modify the name of the artificial label which
43    identifies this file as having been compiled with gcc, and the macro that
44    emits such a label in the assembly output, to use '%' rather than '.'  */
45
46 #undef ASM_IDENTIFY_GCC
47 #define ASM_IDENTIFY_GCC(FILE)                                          \
48 do                                                                      \
49   {                                                                     \
50     if (write_symbols != DBX_DEBUG)                                     \
51       fputs ("gcc2_compiled%:\n", FILE);                                \
52   }                                                                     \
53 while (0)
54
55 /*  Override the definition of NO_DOLLAR_IN_LABEL in svr4.h, for special
56     g++ assembler names.  When this is defined, g++ uses embedded '.'
57     characters and some m68k assemblers have problems with this.  The
58     chances are much greater that any particular assembler will permit
59     embedded '$' characters. */
60
61 #undef NO_DOLLAR_IN_LABEL
62
63 /* Define PCC_STATIC_STRUCT_RETURN if the convention on the target machine
64    is to use the nonreentrant technique for returning structure and union
65    values, as commonly implemented by the AT&T Portable C Compiler (PCC).
66    When defined, the gcc option -fpcc-struct-return can be used to cause
67    this form to be generated.  When undefined, the option does nothing.
68    For m68k SVR4, the convention is to use a reentrant technique compatible
69    with the gcc default, so override the definition of this macro in m68k.h */
70
71 #undef PCC_STATIC_STRUCT_RETURN
72
73 /* Provide a set of pre-definitions and pre-assertions appropriate for
74    the m68k running svr4.  __svr4__ is our extension.  */
75
76 #define CPP_PREDEFINES \
77   "-Dm68k -Dunix -D__svr4__ -D__motorola__ \
78  -Asystem(unix) -Asystem(svr4) -Acpu(m68k) -Amachine(m68k)"
79
80 /* Test to see if the target includes a 68881 by default, and use CPP_SPEC
81    to control whether or not __HAVE_68881__ is defined by default or not.
82    If a 68881 is the default, gcc will use inline 68881 instructions, by
83    predefining __HAVE_68881__, unless -msoft-float is specified.
84    If a 68881 is not the default, gcc will only define __HAVE_68881__ if
85    -m68881 is specified. */
86
87 #if TARGET_DEFAULT & MASK_68881
88 #define CPP_SPEC "%{!msoft-float:-D__HAVE_68881__}"
89 #else
90 #define CPP_SPEC "%{m68881:-D__HAVE_68881__}"
91 #endif
92
93 /* Output assembler code to FILE to increment profiler label # LABELNO
94    for profiling a function entry.  We override the definition in m68k.h
95    and match the way the native m68k/SVR4 compiler does profiling, with the
96    address of the profile counter in a1, not a0, and using bsr rather
97    than jsr. */
98
99 #undef FUNCTION_PROFILER
100 #define FUNCTION_PROFILER(FILE, LABELNO)                                \
101   asm_fprintf ((FILE), "\tlea.l\t(%LLP%d,%Rpc),%Ra1\n\tbsr\t_mcount\n", \
102                (LABELNO))
103
104 /* Local common symbols are declared to the assembler with ".lcomm" rather
105    than ".bss", so override the definition in svr4.h */
106 /* ??? svr4.h no longer defines this, and this is only used by m68k/amix.h.  */
107
108 #undef BSS_ASM_OP
109 #define BSS_ASM_OP      ".lcomm"
110
111 /* Register in which address to store a structure value is passed to a
112    function.  The default in m68k.h is a1.  For m68k/SVR4 it is a0. */
113
114 #undef STRUCT_VALUE_REGNUM
115 #define STRUCT_VALUE_REGNUM 8
116
117 /* Register in which static-chain is passed to a function.  The
118    default in m68k.h is a0, but that is already the struct value
119    regnum.  Make it a1 instead.  */
120
121 #undef STATIC_CHAIN_REGNUM
122 #define STATIC_CHAIN_REGNUM 9
123
124 #define ASM_COMMENT_START "#"
125
126 #undef TYPE_OPERAND_FMT
127 #define TYPE_OPERAND_FMT      "@%s"
128
129 /* Define how the m68k registers should be numbered for Dwarf output.
130    The numbering provided here should be compatible with the native
131    SVR4 SDB debugger in the m68k/SVR4 reference port, where d0-d7
132    are 0-7, a0-a8 are 8-15, and fp0-fp7 are 16-23. */
133
134 #define DBX_REGISTER_NUMBER(REGNO) (REGNO)
135
136 /* The ASM_OUTPUT_SKIP macro is first defined in m68k.h, using ".skip".
137    It is then overridden by m68k/sgs.h to use ".space", and again by svr4.h
138    to use ".zero".  The m68k/SVR4 assembler uses ".space", so repeat the
139    definition from m68k/sgs.h here.  Note that ASM_NO_SKIP_IN_TEXT is
140    defined in m68k/sgs.h, so we don't have to repeat it here. */
141
142 #undef ASM_OUTPUT_SKIP
143 #define ASM_OUTPUT_SKIP(FILE,SIZE)  \
144   fprintf (FILE, "\t%s %u\n", SPACE_ASM_OP, (SIZE))
145
146 /* 1 if N is a possible register number for a function value.
147    For m68k/SVR4 allow d0, a0, or fp0 as return registers, for integral,
148    pointer, or floating types, respectively. Reject fp0 if not using a
149    68881 coprocessor. */
150
151 #undef FUNCTION_VALUE_REGNO_P
152 #define FUNCTION_VALUE_REGNO_P(N) \
153   ((N) == 0 || (N) == 8 || (TARGET_68881 && (N) == 16))
154
155 /* Define this to be true when FUNCTION_VALUE_REGNO_P is true for
156    more than one register.  */
157
158 #undef NEEDS_UNTYPED_CALL
159 #define NEEDS_UNTYPED_CALL 1
160
161 /* Define how to generate (in the callee) the output value of a function
162    and how to find (in the caller) the value returned by a function.  VALTYPE
163    is the data type of the value (as a tree).  If the precise function being
164    called is known, FUNC is its FUNCTION_DECL; otherwise, FUNC is 0.
165    For m68k/SVR4 generate the result in d0, a0, or fp0 as appropriate. */
166    
167 #undef FUNCTION_VALUE
168 #define FUNCTION_VALUE(VALTYPE, FUNC)                                   \
169   (TREE_CODE (VALTYPE) == REAL_TYPE && TARGET_68881                     \
170    ? gen_rtx (REG, TYPE_MODE (VALTYPE), 16)                             \
171    : (POINTER_TYPE_P (VALTYPE)                                          \
172       ? gen_rtx (REG, TYPE_MODE (VALTYPE), 8)                           \
173       : gen_rtx (REG, TYPE_MODE (VALTYPE), 0)))
174
175 /* For compatibility with the large body of existing code which does not
176    always properly declare external functions returning pointer types, the
177    m68k/SVR4 convention is to copy the value returned for pointer functions
178    from a0 to d0 in the function epilogue, so that callers that have
179    neglected to properly declare the callee can still find the correct return
180    value. */
181
182 extern int current_function_returns_pointer;
183 #define FUNCTION_EXTRA_EPILOGUE(FILE, SIZE)                             \
184 do {                                                                    \
185   if ((current_function_returns_pointer) &&                             \
186       ! find_equiv_reg (0, get_last_insn (), 0, 0, 0, 8, Pmode))        \
187     asm_fprintf (FILE, "\tmov.l %Ra0,%Rd0\n");                          \
188 } while (0);
189
190 /* Define how to find the value returned by a library function assuming the
191    value has mode MODE.
192    For m68k/SVR4 look for integer values in d0, pointer values in d0
193    (returned in both d0 and a0), and floating values in fp0. */
194
195 #undef LIBCALL_VALUE
196 #define LIBCALL_VALUE(MODE)                                             \
197   ((((MODE) == SFmode || (MODE) == DFmode || (MODE) == XFmode)          \
198     && TARGET_68881)                                                    \
199    ? gen_rtx (REG, (MODE), 16)                                          \
200    : gen_rtx (REG, (MODE), 0))
201
202 /* Boundary (in *bits*) on which stack pointer should be aligned.
203    The m68k/SVR4 convention is to keep the stack pointer longword aligned. */
204  
205 #undef STACK_BOUNDARY
206 #define STACK_BOUNDARY 32
207
208 /* Alignment of field after `int : 0' in a structure.
209    For m68k/SVR4, this is the next longword boundary. */
210
211 #undef EMPTY_FIELD_BOUNDARY
212 #define EMPTY_FIELD_BOUNDARY 32
213
214 /* No data type wants to be aligned rounder than this.
215    For m68k/SVR4, some types (doubles for example) are aligned on 8 byte
216    boundaries */
217         
218 #undef BIGGEST_ALIGNMENT
219 #define BIGGEST_ALIGNMENT 64
220
221 /* SVR4 m68k assembler is bitching on the `comm i,1,1' which asks for 
222    1 byte alignment. Don't generate alignment for COMMON seems to be
223    safer until we the assembler is fixed. */
224 #undef ASM_OUTPUT_ALIGNED_COMMON
225 /* Same problem with this one.  */
226 #undef ASM_OUTPUT_ALIGNED_LOCAL
227
228 /* The `string' directive on m68k svr4 does not handle string with
229    escape char (ie., `\') right. Use normal way to output ASCII bytes
230    seems to be safer. */
231 #undef ASM_OUTPUT_ASCII
232 #define ASM_OUTPUT_ASCII(FILE,PTR,LEN)                          \
233 do {                                                            \
234   register int sp = 0, lp = 0, ch;                              \
235   fprintf ((FILE), "\t%s ", BYTE_ASM_OP);                       \
236   do {                                                          \
237     ch = (PTR)[sp];                                             \
238     if (ch > ' ' && ! (ch & 0x80) && ch != '\\')                \
239       {                                                         \
240         fprintf ((FILE), "'%c", ch);                            \
241       }                                                         \
242     else                                                        \
243       {                                                         \
244         fprintf ((FILE), "0x%x", ch);                           \
245       }                                                         \
246     if (++sp < (LEN))                                           \
247       {                                                         \
248         if ((sp % 10) == 0)                                     \
249           {                                                     \
250             fprintf ((FILE), "\n\t%s ", BYTE_ASM_OP);           \
251           }                                                     \
252         else                                                    \
253           {                                                     \
254             putc (',', (FILE));                                 \
255           }                                                     \
256       }                                                         \
257   } while (sp < (LEN));                                         \
258   putc ('\n', (FILE));                                          \
259 } while (0)
260
261 /* SVR4 m68k assembler is bitching on the syntax `2.b'.
262    So use the "LLDnnn-LLnnn" format.  Define LLDnnn after the table.  */
263
264 #undef ASM_OUTPUT_CASE_END
265 #define ASM_OUTPUT_CASE_END(FILE,NUM,TABLE)                             \
266 do {                                                                    \
267   if (switch_table_difference_label_flag)                               \
268     asm_fprintf ((FILE), "\t%s %LLD%d,%LL%d\n", SET_ASM_OP, (NUM), (NUM));\
269   switch_table_difference_label_flag = 0;                               \
270 } while (0)
271
272 int switch_table_difference_label_flag;
273
274 #undef ASM_OUTPUT_COMMON
275 #undef ASM_OUTPUT_LOCAL
276 #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED)  \
277 ( fputs (".comm ", (FILE)),                     \
278   assemble_name ((FILE), (NAME)),               \
279   fprintf ((FILE), ",%u\n", (SIZE)))
280
281 #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED)  \
282 ( fputs (".lcomm ", (FILE)),                    \
283   assemble_name ((FILE), (NAME)),               \
284   fprintf ((FILE), ",%u\n", (SIZE)))
285
286 /* Override the definition in svr4.h. In m68k svr4, using swbeg is the 
287    standard way to do switch table. */
288 #undef ASM_OUTPUT_BEFORE_CASE_LABEL
289 #define ASM_OUTPUT_BEFORE_CASE_LABEL(FILE,PREFIX,NUM,TABLE)             \
290   fprintf ((FILE), "\t%s &%d\n", SWBEG_ASM_OP, XVECLEN (PATTERN (TABLE), 1));
291
292 /* In m68k svr4, a symbol_ref rtx can be a valid PIC operand if it is an
293    operand of a function call. */
294 #undef LEGITIMATE_PIC_OPERAND_P
295 #define LEGITIMATE_PIC_OPERAND_P(X) \
296   ((! symbolic_operand (X, VOIDmode) \
297     && ! (GET_CODE (X) == CONST_DOUBLE && CONST_DOUBLE_MEM (X)  \
298           && GET_CODE (CONST_DOUBLE_MEM (X)) == MEM             \
299           && symbolic_operand (XEXP (CONST_DOUBLE_MEM (X), 0), VOIDmode))) \
300    || (GET_CODE (X) == SYMBOL_REF && SYMBOL_REF_FLAG (X)))
301
302 /* Turn off function cse if we are doing PIC. We always want function call
303    to be done as `bsr foo@PLTPC', so it will force the assembler to create 
304    the PLT entry for `foo'. Doing function cse will cause the address of `foo'
305    to be loaded into a register, which is exactly what we want to avoid when
306    we are doing PIC on svr4 m68k. */
307 #undef OVERRIDE_OPTIONS
308 #define OVERRIDE_OPTIONS                \
309 {                                       \
310   if (flag_pic) flag_no_function_cse = 1; \
311   if (! TARGET_68020 && flag_pic == 2)  \
312     error("-fPIC is not currently supported on the 68000 or 68010\n");  \
313 }
314
315 /* Output assembler code for a block containing the constant parts
316    of a trampoline, leaving space for the variable parts.  */
317
318 /* On m68k svr4, the trampoline is different from the generic version
319    in that we use a1 as the static call chain.  */
320
321 #undef TRAMPOLINE_TEMPLATE
322 #define TRAMPOLINE_TEMPLATE(FILE)                                       \
323 {                                                                       \
324   ASM_OUTPUT_SHORT (FILE, gen_rtx (CONST_INT, VOIDmode, 0x227a));       \
325   ASM_OUTPUT_SHORT (FILE, gen_rtx (CONST_INT, VOIDmode, 8));            \
326   ASM_OUTPUT_SHORT (FILE, gen_rtx (CONST_INT, VOIDmode, 0x2f3a));       \
327   ASM_OUTPUT_SHORT (FILE, gen_rtx (CONST_INT, VOIDmode, 8));            \
328   ASM_OUTPUT_SHORT (FILE, gen_rtx (CONST_INT, VOIDmode, 0x4e75));       \
329   ASM_OUTPUT_INT (FILE, const0_rtx);                                    \
330   ASM_OUTPUT_INT (FILE, const0_rtx);                                    \
331 }
332
333 /* Redefine since we are using a different trampoline */
334 #undef TRAMPOLINE_SIZE
335 #define TRAMPOLINE_SIZE 18
336
337 /* Emit RTL insns to initialize the variable parts of a trampoline.
338    FNADDR is an RTX for the address of the function's pure code.
339    CXT is an RTX for the static chain value for the function.  */
340
341 #undef INITIALIZE_TRAMPOLINE
342 #define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT)                       \
343 {                                                                       \
344   emit_move_insn (gen_rtx (MEM, SImode, plus_constant (TRAMP, 10)), CXT); \
345   emit_move_insn (gen_rtx (MEM, SImode, plus_constant (TRAMP, 14)), FNADDR); \
346 }