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