1 /* Definitions of target machine for GNU compiler,
2 for m68k (including m68010) NetBSD platforms using the
4 Copyright (C) 2002 Free Software Foundation, Inc.
5 Contributed by Wasabi Systems. Inc.
7 This file is derived from <m68k/m68kv4.h>, <m68k/m68kelf.h>,
10 This file is part of GNU CC.
12 GNU CC is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 1, or (at your option)
17 GNU CC is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with GNU CC; see the file COPYING. If not, write to
24 the Free Software Foundation, 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. */
27 #define TARGET_OS_CPP_BUILTINS() \
30 NETBSD_OS_CPP_BUILTINS_ELF(); \
31 builtin_define ("__m68k__"); \
32 builtin_define ("__SVR4_ABI__"); \
33 builtin_define ("__motorola__"); \
34 builtin_assert ("cpu=m68k"); \
35 builtin_assert ("machine=m68k"); \
39 /* Default target comes from config.gcc */
41 #define TARGET_DEFAULT TARGET_CPU_DEFAULT
44 /* Don't try using XFmode on the 68010. */
45 #if TARGET_DEFAULT == 0
46 #undef LONG_DOUBLE_TYPE_SIZE
47 #define LONG_DOUBLE_TYPE_SIZE 64
51 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64
55 { "cpp_cpu_default_spec", CPP_CPU_DEFAULT_SPEC }, \
56 { "cpp_cpu_spec", CPP_CPU_SPEC }, \
57 { "cpp_fpu_spec", CPP_FPU_SPEC }, \
58 { "asm_default_spec", ASM_DEFAULT_SPEC }, \
59 { "netbsd_cpp_spec", NETBSD_CPP_SPEC },
62 #define CPP_CPU_SPEC \
63 "%{m68010:-D__mc68010__} \
64 %{m68020:-D__mc68020__} \
65 %{m68030:-D__mc68030__} \
66 %{m68040:-D__mc68040__} \
67 %(cpp_cpu_default_spec)"
71 #if TARGET_DEFAULT & MASK_68020
72 #define TARGET_VERSION fprintf (stderr, " (NetBSD/m68k ELF)");
73 #define CPP_CPU_DEFAULT_SPEC "%{!m680*:-D__mc68020__}"
74 #define ASM_DEFAULT_SPEC "%{!m680*:-m68020}"
76 #define TARGET_VERSION fprintf (stderr, " (NetBSD/68010 ELF)");
77 #define CPP_CPU_DEFAULT_SPEC "%{!m680*:-D__mc68010__}"
78 #define ASM_DEFAULT_SPEC "%{!m680*:-m68010}"
82 #if TARGET_DEFAULT & MASK_68881
83 #define CPP_FPU_SPEC "%{!msoft-float:-D__HAVE_68881__ -D__HAVE_FPU__}"
85 #define CPP_FPU_SPEC "%{m68881:-D__HAVE_68881__ -D__HAVE_FPU__}"
89 /* Provide a CPP_SPEC appropriate for NetBSD m68k targets. Currently we
90 deal with the GCC option '-posix', as well as an indication as to
91 whether or not use of the FPU is allowed. */
95 "%(netbsd_cpp_spec) %(cpp_cpu_spec) %(cpp_fpu_spec)"
98 /* Provide an ASM_SPEC appropriate for NetBSD m68k ELF targets. We pass
99 on some CPU options, as well as PIC code generation options. */
103 " %| %(asm_default_spec) \
104 %{m68010} %{m68020} %{m68030} %{m68040} %{m68060} \
105 %{fpic:-k} %{fPIC:-k -K}"
107 /* Provide a LINK_SPEC appropriate for a NetBSD/m68k ELF target.
108 This is a copy of LINK_SPEC from <netbsd-elf.h> tweaked for
121 %{rdynamic:-export-dynamic} \
122 %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.elf_so}} \
126 /* Output assembler code to FILE to increment profiler label # LABELNO
127 for profiling a function only. */
129 #undef FUNCTION_PROFILER
130 #define FUNCTION_PROFILER(FILE, LABELNO) \
133 asm_fprintf (FILE, "\tlea (%LLP%d,%Rpc),%Ra1\n", (LABELNO)); \
135 fprintf (FILE, "\tbsr.l __mcount@PLTPC\n"); \
137 fprintf (FILE, "\tjbsr __mcount\n"); \
142 /* Make gcc agree with <machine/ansi.h> */
145 #define SIZE_TYPE "unsigned int"
148 #define PTRDIFF_TYPE "int"
152 Here is a bunch of stuff lifted from m68kelf.h. We don't use that
153 file directly, because it has a lot of baggage we don't want. */
155 #define MOTOROLA /* Use Motorola syntax */
156 #define USE_GAS /* But GAS wants jbsr instead of jsr */
159 /* The prefix for register names. Note that REGISTER_NAMES
160 is supposed to include this prefix. Also note that this is NOT an
161 fprintf format string, it is a literal string. */
163 #undef REGISTER_PREFIX
164 #define REGISTER_PREFIX "%"
167 /* The prefix for local (compiler generated) lables.
168 These labels will not appear in the symbol table. */
170 #undef LOCAL_LABEL_PREFIX
171 #define LOCAL_LABEL_PREFIX "."
174 /* The prefix to add to user-visible assembler symbols. */
176 #undef USER_LABEL_PREFIX
177 #define USER_LABEL_PREFIX ""
180 /* The prefix for immediate operands. */
182 #undef IMMEDIATE_PREFIX
183 #define IMMEDIATE_PREFIX "#"
186 #undef ASM_COMMENT_START
187 #define ASM_COMMENT_START "|"
190 /* How to refer to registers in assembler output.
191 This sequence is indexed by compiler's hard-register-number.
192 Motorola format uses different register names than defined in m68k.h.
193 We also take this chance to convert 'a6' to 'fp' */
195 #undef REGISTER_NAMES
197 #ifndef SUPPORT_SUN_FPA
199 #define REGISTER_NAMES \
200 {"%d0", "%d1", "%d2", "%d3", "%d4", "%d5", "%d6", "%d7", \
201 "%a0", "%a1", "%a2", "%a3", "%a4", "%a5", "%fp", "%sp", \
202 "%fp0", "%fp1", "%fp2", "%fp3", "%fp4", "%fp5", "%fp6", "%fp7" }
204 #else /* SUPPORT_SUN_FPA */
206 #define REGISTER_NAMES \
207 {"%d0", "%d1", "%d2", "%d3", "%d4", "%d5", "%d6", "%d7", \
208 "%a0", "%a1", "%a2", "%a3", "%a4", "%a5", "%fp", "%sp", \
209 "%fp0", "%fp1", "%fp2", "%fp3", "%fp4", "%fp5", "%fp6", "%fp7", \
210 "%fpa0", "%fpa1", "%fpa2", "%fpa3", "%fpa4", "%fpa5", "%fpa6","%fpa7", \
211 "%fpa8", "%fpa9", "%fpa10","%fpa11","%fpa12","%fpa13","%fpa14","%fpa15", \
212 "%fpa16","%fpa17","%fpa18","%fpa19","%fpa20","%fpa21","%fpa22","%fpa23", \
213 "%fpa24","%fpa25","%fpa26","%fpa27","%fpa28","%fpa29","%fpa30","%fpa31" }
215 #endif /* ! SUPPORT_SUN_FPA */
218 /* Currently, JUMP_TABLES_IN_TEXT_SECTION must be defined in order to
219 keep switch tables in the text section. */
221 #undef JUMP_TABLES_IN_TEXT_SECTION
222 #define JUMP_TABLES_IN_TEXT_SECTION 1
225 /* Use the default action for outputting the case label. */
226 #undef ASM_OUTPUT_CASE_LABEL
227 #define ASM_RETURN_CASE_JUMP \
231 return "ext%.l %0\n\tjmp %%pc@(2,%0:l)"; \
233 return "jmp %%pc@(2,%0:w)"; \
238 /* This is how to output an assembler line that says to advance the
239 location counter to a multiple of 2**LOG bytes. */
241 #undef ASM_OUTPUT_ALIGN
242 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
246 fprintf ((FILE), "%s%u\n", ALIGN_ASM_OP, 1 << (LOG)); \
251 /* If defined, a C expression whose value is a string containing the
252 assembler operation to identify the following data as uninitialized global
255 #define BSS_SECTION_ASM_OP ".section\t.bss"
258 /* Like `ASM_OUTPUT_BSS' except takes the required alignment as a
259 separate, explicit argument. If you define this macro, it is used
260 in place of `ASM_OUTPUT_BSS', and gives you more flexibility in
261 handling the required alignment of the variable. The alignment is
262 specified as the number of bits.
264 Try to use function `asm_output_aligned_bss' defined in file
265 `varasm.c' when defining this macro. */
267 #undef ASM_OUTPUT_ALIGNED_BSS
268 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
269 asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
272 #undef ASM_OUTPUT_COMMON
273 #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED) \
274 ( fputs (".comm ", (FILE)), \
275 assemble_name ((FILE), (NAME)), \
276 fprintf ((FILE), ",%u\n", (SIZE)))
278 #undef ASM_OUTPUT_LOCAL
279 #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED) \
280 ( fputs (".lcomm ", (FILE)), \
281 assemble_name ((FILE), (NAME)), \
282 fprintf ((FILE), ",%u\n", (SIZE)))
285 /* Turn off function cse if we are doing PIC. We always want function
286 call to be done as `bsr foo@PLTPC', so it will force the assembler
287 to create the PLT entry for `foo'. Doing function cse will cause
288 the address of `foo' to be loaded into a register, which is exactly
289 what we want to avoid when we are doing PIC on svr4 m68k. */
291 #undef SUBTARGET_OVERRIDE_OPTIONS
292 #define SUBTARGET_OVERRIDE_OPTIONS \
293 if (flag_pic) flag_no_function_cse = 1;
297 This is the end of the chunk lifted from m68kelf.h */
301 The following chunk is more or less lifted from m68kv4.h.
302 We'd like to just #include that file, but it has not yet
303 been converted to the new include style.
305 Should there be a m68kv4-abi.h ?? */
308 /* Register in which address to store a structure value is passed to a
309 function. The default in m68k.h is a1. For m68k/SVR4 it is a0. */
311 #undef STRUCT_VALUE_REGNUM
312 #define STRUCT_VALUE_REGNUM 8
315 /* Register in which static-chain is passed to a function. The
316 default isn m68k.h is a0, but that is already the struct value
317 regnum. Make it a1 instead. */
319 #undef STATIC_CHAIN_REGNUM
320 #define STATIC_CHAIN_REGNUM 9
323 /* Now to renumber registers for dbx and gdb.
324 We use the Sun-3 convention, which is:
325 floating point registers have numbers 18 to 25, not
326 16 to 23 as they do in the compiler. */
328 #undef DBX_REGISTER_NUMBER
329 #define DBX_REGISTER_NUMBER(REGNO) ((REGNO) < 16 ? (REGNO) : (REGNO) + 2)
332 /* 1 if N is a possible register number for a function value. For
333 m68k/SVR4 allow d0, a0, or fp0 as return registers, for integral,
334 pointer, or floating types, respectively. Reject fp0 if not using
335 a 68881 coprocessor. */
337 #undef FUNCTION_VALUE_REGNO_P
338 #define FUNCTION_VALUE_REGNO_P(N) \
339 ((N) == 0 || (N) == 8 || (TARGET_68881 && (N) == 16))
342 /* Define this to be true when FUNCTION_VALUE_REGNO_P is true for
343 more than one register. */
345 #undef NEEDS_UNTYPED_CALL
346 #define NEEDS_UNTYPED_CALL 1
349 /* Define how to generate (in the callee) the output value of a
350 function and how to find (in the caller) the value returned by a
351 function. VALTYPE is the data type of the value (as a tree). If
352 the precise function being called is known, FUNC is its
353 FUNCTION_DECL; otherwise, FUNC is 0. For m68k/SVR4 generate the
354 result in d0, a0, or fp0 as appropriate. */
356 #undef FUNCTION_VALUE
357 #define FUNCTION_VALUE(VALTYPE, FUNC) \
358 (TREE_CODE (VALTYPE) == REAL_TYPE && TARGET_68881 \
359 ? gen_rtx_REG (TYPE_MODE (VALTYPE), 16) \
360 : (POINTER_TYPE_P (VALTYPE) \
361 ? gen_rtx_REG (TYPE_MODE (VALTYPE), 8) \
362 : gen_rtx_REG (TYPE_MODE (VALTYPE), 0)))
365 /* For compatibility with the large body of existing code which does
366 not always properly declare external functions returning pointer
367 types, the m68k/SVR4 convention is to copy the value returned for
368 pointer functions from a0 to d0 in the function epilogue, so that
369 callers that have neglected to properly declare the callee can
370 still find the correct return value. */
372 extern int current_function_returns_pointer
;
373 #define FUNCTION_EXTRA_EPILOGUE(FILE, SIZE) \
376 if (current_function_returns_pointer \
377 && ! find_equiv_reg (0, get_last_insn (), 0, 0, 0, 8, Pmode)) \
378 asm_fprintf (FILE, "\tmove.l %Ra0,%Rd0\n"); \
383 /* Define how to find the value returned by a library function
384 assuming the value has mode MODE.
385 For m68k/SVR4 look for integer values in d0, pointer values in d0
386 (returned in both d0 and a0), and floating values in fp0. */
389 #define LIBCALL_VALUE(MODE) \
390 ((((MODE) == SFmode || (MODE) == DFmode || (MODE) == XFmode) \
392 ? gen_rtx_REG (MODE, 16) \
393 : gen_rtx_REG (MODE, 0))
396 /* Boundary (in *bits*) on which stack pointer should be aligned.
397 The m68k/SVR4 convention is to keep the stack pointer longword aligned. */
399 #undef STACK_BOUNDARY
400 #define STACK_BOUNDARY 32
403 /* Alignment of field after `int : 0' in a structure.
404 For m68k/SVR4, this is the next longword boundary. */
406 #undef EMPTY_FIELD_BOUNDARY
407 #define EMPTY_FIELD_BOUNDARY 32
410 /* No data type wants to be aligned rounder than this.
411 For m68k/SVR4, some types (doubles for example) are aligned on 8 byte
414 #undef BIGGEST_ALIGNMENT
415 #define BIGGEST_ALIGNMENT 64
418 /* In m68k svr4, a symbol_ref rtx can be a valid PIC operand if it is
419 an operand of a function call. */
421 #undef LEGITIMATE_PIC_OPERAND_P
422 #define LEGITIMATE_PIC_OPERAND_P(X) \
423 ((! symbolic_operand (X, VOIDmode) \
424 && ! (GET_CODE (X) == CONST_DOUBLE && mem_for_const_double (X) \
425 && GET_CODE (mem_for_const_double (X)) == MEM \
426 && symbolic_operand (XEXP (mem_for_const_double (X), 0), \
428 || (GET_CODE (X) == SYMBOL_REF && SYMBOL_REF_FLAG (X)) \
429 || PCREL_GENERAL_OPERAND_OK)
432 /* For m68k SVR4, structures are returned using the reentrant
435 #undef PCC_STATIC_STRUCT_RETURN
438 /* The svr4 ABI for the m68k says that records and unions are returned
441 #undef DEFAULT_PCC_STRUCT_RETURN
442 #define DEFAULT_PCC_STRUCT_RETURN 1
445 /* Output code to add DELTA to the first argument, and then jump to FUNCTION.
446 Used for C++ multiple inheritance. */
448 #define ASM_OUTPUT_MI_THUNK(FILE, THUNK_FNDECL, DELTA, FUNCTION) \
451 if (DELTA > 0 && DELTA <= 8) \
452 asm_fprintf (FILE, "\taddq.l %I%d,4(%Rsp)\n", DELTA); \
453 else if (DELTA < 0 && DELTA >= -8) \
454 asm_fprintf (FILE, "\tsubq.l %I%d,4(%Rsp)\n", -DELTA); \
456 asm_fprintf (FILE, "\tadd.l %I%d,4(%Rsp)\n", DELTA); \
460 fprintf (FILE, "\tbra.l "); \
461 assemble_name (FILE, XSTR (XEXP (DECL_RTL (FUNCTION), 0), 0)); \
462 fprintf (FILE, "@PLTPC\n"); \
466 fprintf (FILE, "\tjmp "); \
467 assemble_name (FILE, XSTR (XEXP (DECL_RTL (FUNCTION), 0), 0)); \
468 fprintf (FILE, "\n"); \
474 /* Output assembler code for a block containing the constant parts
475 of a trampoline, leaving space for the variable parts. */
477 /* On m68k svr4, the trampoline is different from the generic version
478 in that we use a1 as the static call chain. */
480 #undef TRAMPOLINE_TEMPLATE
481 #define TRAMPOLINE_TEMPLATE(FILE) \
483 assemble_aligned_integer (2, GEN_INT (0x227a)); \
484 assemble_aligned_integer (2, GEN_INT (8)); \
485 assemble_aligned_integer (2, GEN_INT (0x2f3a)); \
486 assemble_aligned_integer (2, GEN_INT (8)); \
487 assemble_aligned_integer (2, GEN_INT (0x4e75)); \
488 assemble_aligned_integer (4, const0_rtx); \
489 assemble_aligned_integer (4, const0_rtx); \
492 /* Redefine since we are using a different trampoline */
493 #undef TRAMPOLINE_SIZE
494 #define TRAMPOLINE_SIZE 18
496 /* Emit RTL insns to initialize the variable parts of a trampoline.
497 FNADDR is an RTX for the address of the function's pure code.
498 CXT is an RTX for the static chain value for the function. */
500 #undef INITIALIZE_TRAMPOLINE
501 #define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) \
503 emit_move_insn (gen_rtx_MEM (SImode, plus_constant (TRAMP, 10)), CXT); \
504 emit_move_insn (gen_rtx_MEM (SImode, plus_constant (TRAMP, 14)), FNADDR); \
509 This is the end of the chunk lifted from m68kv4.h */