OSDN Git Service

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