]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/config/m68k/linux.h
Merge from gcc-2.8
[thirdparty/gcc.git] / gcc / config / m68k / linux.h
1 /* Definitions for Motorola 68k running Linux-based GNU systems with
2 ELF format.
3 Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
4
5 This file is part of GNU CC.
6
7 GNU CC 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 1, or (at your option)
10 any later version.
11
12 GNU CC 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 GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
21
22 #define LINUX_DEFAULT_ELF
23 #define MOTOROLA /* Use Motorola syntax */
24 #define USE_GAS /* But GAS wants jbsr instead of jsr */
25
26 #include <m68k/m68k.h>
27
28 /* Make sure CC1 is undefined. */
29 #undef CC1_SPEC
30
31 #include <linux.h> /* some common stuff */
32
33 #undef TARGET_VERSION
34 #define TARGET_VERSION fprintf (stderr, " (68k GNU/Linux with ELF)");
35
36 /* 68020 with 68881 */
37 #define TARGET_DEFAULT (MASK_BITFIELD|MASK_68881|MASK_68020)
38
39 /* for 68k machines this only needs to be TRUE for the 68000 */
40
41 #undef STRICT_ALIGNMENT
42 #define STRICT_ALIGNMENT 0
43
44 #undef SUBTARGET_SWITCHES
45 #define SUBTARGET_SWITCHES {"ieee-fp", 0},
46
47 /* Here are four prefixes that are used by asm_fprintf to
48 facilitate customization for alternate assembler syntaxes.
49 Machines with no likelihood of an alternate syntax need not
50 define these and need not use asm_fprintf. */
51
52 /* The prefix for register names. Note that REGISTER_NAMES
53 is supposed to include this prefix. Also note that this is NOT an
54 fprintf format string, it is a literal string */
55
56 #undef REGISTER_PREFIX
57 #define REGISTER_PREFIX "%"
58
59 /* The prefix for local (compiler generated) labels.
60 These labels will not appear in the symbol table. */
61
62 #undef LOCAL_LABEL_PREFIX
63 #define LOCAL_LABEL_PREFIX "."
64
65 /* The prefix to add to user-visible assembler symbols. */
66
67 #undef USER_LABEL_PREFIX
68 #define USER_LABEL_PREFIX ""
69
70 #define ASM_COMMENT_START "|"
71
72 /* How to refer to registers in assembler output.
73 This sequence is indexed by compiler's hard-register-number.
74 Motorola format uses different register names than defined in m68k.h. */
75
76 #undef REGISTER_NAMES
77
78 #ifndef SUPPORT_SUN_FPA
79
80 #define REGISTER_NAMES \
81 {"%d0", "%d1", "%d2", "%d3", "%d4", "%d5", "%d6", "%d7", \
82 "%a0", "%a1", "%a2", "%a3", "%a4", "%a5", "%a6", "%sp", \
83 "%fp0", "%fp1", "%fp2", "%fp3", "%fp4", "%fp5", "%fp6", "%fp7" }
84
85 #else /* SUPPORTED_SUN_FPA */
86
87 #define REGISTER_NAMES \
88 {"%d0", "%d1", "%d2", "%d3", "%d4", "%d5", "%d6", "%d7", \
89 "%a0", "%a1", "%a2", "%a3", "%a4", "%a5", "%a6", "%sp", \
90 "%fp0", "%fp1", "%fp2", "%fp3", "%fp4", "%fp5", "%fp6", "%fp7", \
91 "%fpa0", "%fpa1", "%fpa2", "%fpa3", "%fpa4", "%fpa5", "%fpa6", "%fpa7", \
92 "%fpa8", "%fpa9", "%fpa10","%fpa11","%fpa12","%fpa13","%fpa14","%fpa15", \
93 "%fpa16","%fpa17","%fpa18","%fpa19","%fpa20","%fpa21","%fpa22","%fpa23", \
94 "%fpa24","%fpa25","%fpa26","%fpa27","%fpa28","%fpa29","%fpa30","%fpa31" }
95
96 #endif /* defined SUPPORT_SUN_FPA */
97
98 #undef SIZE_TYPE
99 #define SIZE_TYPE "unsigned int"
100
101 #undef PTRDIFF_TYPE
102 #define PTRDIFF_TYPE "int"
103
104 #undef WCHAR_TYPE
105 #define WCHAR_TYPE "long int"
106
107 #undef WCHAR_TYPE_SIZE
108 #define WCHAR_TYPE_SIZE BITS_PER_WORD
109
110 #define CPP_PREDEFINES \
111 "-D__ELF__ -Dunix -Dmc68000 -Dmc68020 -Dlinux -Asystem(unix) -Asystem(posix) -Acpu(m68k) -Amachine(m68k)"
112
113 #undef CPP_SPEC
114 #ifdef USE_GNULIBC_1
115 #if TARGET_DEFAULT & MASK_68881
116 #define CPP_SPEC \
117 "%{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{!msoft-float:-D__HAVE_68881__} %{posix:-D_POSIX_SOURCE}"
118 #else
119 #define CPP_SPEC \
120 "%{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{m68881:-D__HAVE_68881__} %{posix:-D_POSIX_SOURCE}"
121 #endif
122 #else
123 #if TARGET_DEFAULT & MASK_68881
124 #define CPP_SPEC \
125 "%{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{!msoft-float:-D__HAVE_68881__} %{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
126 #else
127 #define CPP_SPEC \
128 "%{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{m68881:-D__HAVE_68881__} %{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
129 #endif
130 #endif
131
132 /* We override the ASM_SPEC from svr4.h because we must pass -m68040 down
133 to the assembler. */
134 #undef ASM_SPEC
135 #define ASM_SPEC \
136 "%{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Yd,*} %{Wa,*:%*} \
137 %{m68040} %{m68060:-m68040}"
138
139 /* Provide a LINK_SPEC appropriate for GNU/Linux. Here we provide support
140 for the special GCC options -static and -shared, which allow us to
141 link things in one of these three modes by applying the appropriate
142 combinations of options at link-time. We like to support here for
143 as many of the other GNU linker options as possible. But I don't
144 have the time to search for those flags. I am sure how to add
145 support for -soname shared_object_name. H.J.
146
147 I took out %{v:%{!V:-V}}. It is too much :-(. They can use
148 -Wl,-V.
149
150 When the -shared link option is used a final link is not being
151 done. */
152
153 /* If ELF is the default format, we should not use /lib/elf. */
154
155 #undef LINK_SPEC
156 #ifdef USE_GNULIBC_1
157 #ifndef LINUX_DEFAULT_ELF
158 #define LINK_SPEC "-m m68kelf %{shared} %{symbolic:-shared -Bsymbolic} \
159 %{!shared:%{!symbolic: \
160 %{!static: \
161 %{rdynamic:-export-dynamic} \
162 %{!dynamic-linker*:-dynamic-linker /lib/elf/ld-linux.so.1} \
163 %{!rpath*:-rpath /lib/elf/}} %{static}}}"
164 #else
165 #define LINK_SPEC "-m m68kelf %{shared} %{symbolic:-shared -Bsymbolic} \
166 %{!shared:%{!symbolic: \
167 %{!static: \
168 %{rdynamic:-export-dynamic} \
169 %{!dynamic-linker*:-dynamic-linker /lib/ld-linux.so.1}} \
170 %{static}}}"
171 #endif
172 #else
173 #define LINK_SPEC "-m m68kelf %{shared} \
174 %{!shared: \
175 %{!static: \
176 %{rdynamic:-export-dynamic} \
177 %{!dynamic-linker*:-dynamic-linker /lib/ld.so.1}} \
178 %{static}}"
179 #endif
180
181 /* For compatibility with linux/a.out */
182
183 #undef PCC_BITFIELD_TYPE_MATTERS
184
185 /* Currently, JUMP_TABLES_IN_TEXT_SECTION must be defined in order to
186 keep switch tables in the text section. */
187
188 #define JUMP_TABLES_IN_TEXT_SECTION 1
189
190 /* Use the default action for outputting the case label. */
191 #undef ASM_OUTPUT_CASE_LABEL
192 #define ASM_RETURN_CASE_JUMP \
193 do { \
194 if (TARGET_5200) \
195 return "ext%.l %0\n\tjmp %%pc@(2,%0:l)"; \
196 else \
197 return "jmp %%pc@(2,%0:w)"; \
198 } while (0)
199
200 /* This is how to output an assembler line that says to advance the
201 location counter to a multiple of 2**LOG bytes. */
202
203 #undef ASM_OUTPUT_ALIGN
204 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
205 if ((LOG) > 0) \
206 fprintf ((FILE), "\t%s \t%u\n", ALIGN_ASM_OP, 1 << (LOG));
207
208 /* If defined, a C expression whose value is a string containing the
209 assembler operation to identify the following data as uninitialized global
210 data. */
211
212 #define BSS_SECTION_ASM_OP ".section\t.bss"
213
214 /* A C statement (sans semicolon) to output to the stdio stream
215 FILE the assembler definition of uninitialized global DECL named
216 NAME whose size is SIZE bytes and alignment is ALIGN bytes.
217 Try to use asm_output_aligned_bss to implement this macro. */
218
219 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
220 asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
221
222 /* Output assembler code to FILE to increment profiler label # LABELNO
223 for profiling a function entry. */
224
225 #undef FUNCTION_PROFILER
226 #define FUNCTION_PROFILER(FILE, LABELNO) \
227 { \
228 asm_fprintf (FILE, "\tlea (%LLP%d,%Rpc),%Ra1\n", (LABELNO)); \
229 if (flag_pic) \
230 fprintf (FILE, "\tbsr.l _mcount@PLTPC\n"); \
231 else \
232 fprintf (FILE, "\tjbsr _mcount\n"); \
233 }
234
235 /* How to renumber registers for dbx and gdb.
236 On the Sun-3, the floating point registers have numbers
237 18 to 25, not 16 to 23 as they do in the compiler. */
238
239 #define DBX_REGISTER_NUMBER(REGNO) ((REGNO) < 16 ? (REGNO) : (REGNO) + 2)
240
241 /* Do not break .stabs pseudos into continuations. */
242
243 #define DBX_CONTIN_LENGTH 0
244
245 /* Allow folding division by zero. */
246 #define REAL_INFINITY
247
248 /* 1 if N is a possible register number for a function value. For
249 m68k/SVR4 allow d0, a0, or fp0 as return registers, for integral,
250 pointer, or floating types, respectively. Reject fp0 if not using
251 a 68881 coprocessor. */
252
253 #undef FUNCTION_VALUE_REGNO_P
254 #define FUNCTION_VALUE_REGNO_P(N) \
255 ((N) == 0 || (N) == 8 || (TARGET_68881 && (N) == 16))
256
257 /* Define this to be true when FUNCTION_VALUE_REGNO_P is true for
258 more than one register. */
259
260 #undef NEEDS_UNTYPED_CALL
261 #define NEEDS_UNTYPED_CALL 1
262
263 /* Define how to generate (in the callee) the output value of a
264 function and how to find (in the caller) the value returned by a
265 function. VALTYPE is the data type of the value (as a tree). If
266 the precise function being called is known, FUNC is its
267 FUNCTION_DECL; otherwise, FUNC is 0. For m68k/SVR4 generate the
268 result in d0, a0, or fp0 as appropriate. */
269
270 #undef FUNCTION_VALUE
271 #define FUNCTION_VALUE(VALTYPE, FUNC) \
272 (TREE_CODE (VALTYPE) == REAL_TYPE && TARGET_68881 \
273 ? gen_rtx (REG, TYPE_MODE (VALTYPE), 16) \
274 : (POINTER_TYPE_P (VALTYPE) \
275 ? gen_rtx (REG, TYPE_MODE (VALTYPE), 8) \
276 : gen_rtx (REG, TYPE_MODE (VALTYPE), 0)))
277
278 /* For compatibility with the large body of existing code which does
279 not always properly declare external functions returning pointer
280 types, the m68k/SVR4 convention is to copy the value returned for
281 pointer functions from a0 to d0 in the function epilogue, so that
282 callers that have neglected to properly declare the callee can
283 still find the correct return value. */
284
285 extern int current_function_returns_pointer;
286 #define FUNCTION_EXTRA_EPILOGUE(FILE, SIZE) \
287 do { \
288 if ((current_function_returns_pointer) && \
289 ! find_equiv_reg (0, get_last_insn (), 0, 0, 0, 8, Pmode)) \
290 asm_fprintf (FILE, "\tmove.l %Ra0,%Rd0\n"); \
291 } while (0);
292
293 /* Define how to find the value returned by a library function
294 assuming the value has mode MODE.
295 For m68k/SVR4 look for integer values in d0, pointer values in d0
296 (returned in both d0 and a0), and floating values in fp0. */
297
298 #undef LIBCALL_VALUE
299 #define LIBCALL_VALUE(MODE) \
300 ((((MODE) == SFmode || (MODE) == DFmode || (MODE) == XFmode) \
301 && TARGET_68881) \
302 ? gen_rtx (REG, (MODE), 16) \
303 : gen_rtx (REG, (MODE), 0))
304
305 /* In m68k svr4, a symbol_ref rtx can be a valid PIC operand if it is
306 an operand of a function call. */
307 #undef LEGITIMATE_PIC_OPERAND_P
308 #define LEGITIMATE_PIC_OPERAND_P(X) \
309 ((! symbolic_operand (X, VOIDmode) \
310 && ! (GET_CODE (X) == CONST_DOUBLE && CONST_DOUBLE_MEM (X) \
311 && GET_CODE (CONST_DOUBLE_MEM (X)) == MEM \
312 && symbolic_operand (XEXP (CONST_DOUBLE_MEM (X), 0), VOIDmode))) \
313 || (GET_CODE (X) == SYMBOL_REF && SYMBOL_REF_FLAG (X)))
314
315 /* Turn off function cse if we are doing PIC. We always want function
316 call to be done as `bsr foo@PLTPC', so it will force the assembler
317 to create the PLT entry for `foo'. Doing function cse will cause
318 the address of `foo' to be loaded into a register, which is exactly
319 what we want to avoid when we are doing PIC on svr4 m68k. */
320 #undef SUBTARGET_OVERRIDE_OPTIONS
321 #define SUBTARGET_OVERRIDE_OPTIONS \
322 if (flag_pic) flag_no_function_cse = 1;
323
324 /* For m68k SVR4, structures are returned using the reentrant
325 technique. */
326 #undef PCC_STATIC_STRUCT_RETURN
327 #define DEFAULT_PCC_STRUCT_RETURN 0
328
329 /* Finalize the trampoline by flushing the insn cache. */
330
331 #undef FINALIZE_TRAMPOLINE
332 #define FINALIZE_TRAMPOLINE(TRAMP) \
333 emit_library_call (gen_rtx (SYMBOL_REF, Pmode, "__clear_cache"), \
334 0, VOIDmode, 2, TRAMP, Pmode, \
335 plus_constant (TRAMP, TRAMPOLINE_SIZE), Pmode);
336
337 /* Clear the instruction cache from `beg' to `end'. This makes an
338 inline system call to SYS_cacheflush. The arguments are as
339 follows:
340
341 cacheflush (addr, scope, cache, len)
342
343 addr - the start address for the flush
344 scope - the scope of the flush (see the cpush insn)
345 cache - which cache to flush (see the cpush insn)
346 len - a factor relating to the number of flushes to perform:
347 len/16 lines, or len/4096 pages. */
348
349 #define CLEAR_INSN_CACHE(BEG, END) \
350 { \
351 register unsigned long _beg __asm ("%d1") = (unsigned long) (BEG); \
352 unsigned long _end = (unsigned long) (END); \
353 register unsigned long _len __asm ("%d4") = (_end - _beg + 32); \
354 __asm __volatile \
355 ("move%.l %#123, %/d0\n\t" /* system call nr */ \
356 "move%.l %#1, %/d2\n\t" /* clear lines */ \
357 "move%.l %#3, %/d3\n\t" /* insn+data caches */ \
358 "trap %#0" \
359 : /* no outputs */ \
360 : "d" (_beg), "d" (_len) \
361 : "%d0", "%d2", "%d3"); \
362 }
363 \f
364 /* Output code to add DELTA to the first argument, and then jump to FUNCTION.
365 Used for C++ multiple inheritance. */
366 #define ASM_OUTPUT_MI_THUNK(FILE, THUNK_FNDECL, DELTA, FUNCTION) \
367 do { \
368 if (DELTA > 0 && DELTA <= 8) \
369 asm_fprintf (FILE, "\taddq.l %I%d,4(%Rsp)\n", DELTA); \
370 else if (DELTA < 0 && DELTA >= -8) \
371 asm_fprintf (FILE, "\tsubq.l %I%d,4(%Rsp)\n", -DELTA); \
372 else \
373 asm_fprintf (FILE, "\tadd.l %I%d,4(%Rsp)\n", DELTA); \
374 \
375 if (flag_pic) \
376 { \
377 fprintf (FILE, "\tbra.l "); \
378 assemble_name \
379 (FILE, IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (FUNCTION))); \
380 fprintf (FILE, "@PLTPC\n"); \
381 } \
382 else \
383 { \
384 fprintf (FILE, "\tjmp "); \
385 assemble_name \
386 (FILE, IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (FUNCTION))); \
387 fprintf (FILE, "\n"); \
388 } \
389 } while (0)