]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/config/m68k/m68kv4.h
Merge in gcc2-ss-010999
[thirdparty/gcc.git] / gcc / config / m68k / m68kv4.h
1 /* Target definitions for GNU compiler for mc680x0 running System V.4
2 Copyright (C) 1991, 93, 94, 95, 96, 1998, 1999 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 #define FUNCTION_EXTRA_EPILOGUE(FILE, SIZE) \
183 do { \
184 if (current_function_returns_pointer \
185 && ! find_equiv_reg (0, get_last_insn (), 0, 0, 0, 8, Pmode)) \
186 asm_fprintf (FILE, "\tmov.l %Ra0,%Rd0\n"); \
187 } while (0);
188
189 /* Define how to find the value returned by a library function assuming the
190 value has mode MODE.
191 For m68k/SVR4 look for integer values in d0, pointer values in d0
192 (returned in both d0 and a0), and floating values in fp0. */
193
194 #undef LIBCALL_VALUE
195 #define LIBCALL_VALUE(MODE) \
196 ((((MODE) == SFmode || (MODE) == DFmode || (MODE) == XFmode) \
197 && TARGET_68881) \
198 ? gen_rtx_REG ((MODE), 16) \
199 : gen_rtx_REG ((MODE), 0))
200
201 /* Boundary (in *bits*) on which stack pointer should be aligned.
202 The m68k/SVR4 convention is to keep the stack pointer longword aligned. */
203
204 #undef STACK_BOUNDARY
205 #define STACK_BOUNDARY 32
206
207 /* Alignment of field after `int : 0' in a structure.
208 For m68k/SVR4, this is the next longword boundary. */
209
210 #undef EMPTY_FIELD_BOUNDARY
211 #define EMPTY_FIELD_BOUNDARY 32
212
213 /* No data type wants to be aligned rounder than this.
214 For m68k/SVR4, some types (doubles for example) are aligned on 8 byte
215 boundaries */
216
217 #undef BIGGEST_ALIGNMENT
218 #define BIGGEST_ALIGNMENT 64
219
220 /* SVR4 m68k assembler is bitching on the `comm i,1,1' which asks for
221 1 byte alignment. Don't generate alignment for COMMON seems to be
222 safer until we the assembler is fixed. */
223 #undef ASM_OUTPUT_ALIGNED_COMMON
224 /* Same problem with this one. */
225 #undef ASM_OUTPUT_ALIGNED_LOCAL
226
227 /* The `string' directive on m68k svr4 does not handle string with
228 escape char (ie., `\') right. Use normal way to output ASCII bytes
229 seems to be safer. */
230 #undef ASM_OUTPUT_ASCII
231 #define ASM_OUTPUT_ASCII(FILE,PTR,LEN) \
232 do { \
233 register int sp = 0, lp = 0, ch; \
234 fprintf ((FILE), "\t%s ", BYTE_ASM_OP); \
235 do { \
236 ch = (PTR)[sp]; \
237 if (ch > ' ' && ! (ch & 0x80) && ch != '\\') \
238 { \
239 fprintf ((FILE), "'%c", ch); \
240 } \
241 else \
242 { \
243 fprintf ((FILE), "0x%x", ch); \
244 } \
245 if (++sp < (LEN)) \
246 { \
247 if ((sp % 10) == 0) \
248 { \
249 fprintf ((FILE), "\n\t%s ", BYTE_ASM_OP); \
250 } \
251 else \
252 { \
253 putc (',', (FILE)); \
254 } \
255 } \
256 } while (sp < (LEN)); \
257 putc ('\n', (FILE)); \
258 } while (0)
259
260 /* SVR4 m68k assembler is bitching on the syntax `2.b'.
261 So use the "LLDnnn-LLnnn" format. Define LLDnnn after the table. */
262
263 #undef ASM_OUTPUT_CASE_END
264 #define ASM_OUTPUT_CASE_END(FILE,NUM,TABLE) \
265 do { \
266 if (switch_table_difference_label_flag) \
267 asm_fprintf ((FILE), "\t%s %LLD%d,%LL%d\n", SET_ASM_OP, (NUM), (NUM));\
268 switch_table_difference_label_flag = 0; \
269 } while (0)
270
271 int switch_table_difference_label_flag;
272
273 #undef ASM_OUTPUT_COMMON
274 #undef ASM_OUTPUT_LOCAL
275 #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED) \
276 ( fputs (".comm ", (FILE)), \
277 assemble_name ((FILE), (NAME)), \
278 fprintf ((FILE), ",%u\n", (SIZE)))
279
280 #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED) \
281 ( fputs (".lcomm ", (FILE)), \
282 assemble_name ((FILE), (NAME)), \
283 fprintf ((FILE), ",%u\n", (SIZE)))
284
285 /* Override the definition in svr4.h. In m68k svr4, using swbeg is the
286 standard way to do switch table. */
287 #undef ASM_OUTPUT_BEFORE_CASE_LABEL
288 #define ASM_OUTPUT_BEFORE_CASE_LABEL(FILE,PREFIX,NUM,TABLE) \
289 fprintf ((FILE), "\t%s &%d\n", SWBEG_ASM_OP, XVECLEN (PATTERN (TABLE), 1));
290
291 /* In m68k svr4, a symbol_ref rtx can be a valid PIC operand if it is an
292 operand of a function call. */
293 #undef LEGITIMATE_PIC_OPERAND_P
294 #define LEGITIMATE_PIC_OPERAND_P(X) \
295 ((! symbolic_operand (X, VOIDmode) \
296 && ! (GET_CODE (X) == CONST_DOUBLE && CONST_DOUBLE_MEM (X) \
297 && GET_CODE (CONST_DOUBLE_MEM (X)) == MEM \
298 && symbolic_operand (XEXP (CONST_DOUBLE_MEM (X), 0), VOIDmode))) \
299 || (GET_CODE (X) == SYMBOL_REF && SYMBOL_REF_FLAG (X)) \
300 || PCREL_GENERAL_OPERAND_OK)
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_INT (0x227a)); \
325 ASM_OUTPUT_SHORT (FILE, GEN_INT (8)); \
326 ASM_OUTPUT_SHORT (FILE, GEN_INT (0x2f3a)); \
327 ASM_OUTPUT_SHORT (FILE, GEN_INT (8)); \
328 ASM_OUTPUT_SHORT (FILE, GEN_INT (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 }