OSDN Git Service

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