1 /* Definitions of target machine for GNU compiler,
2 for m68k (including m68010) NetBSD platforms using the
4 Copyright (C) 2002, 2003, 2004, 2006 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 GCC.
12 GCC 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 2, or (at your option)
17 GCC 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 GCC; see the file COPYING. If not, write to
24 the Free Software Foundation, 51 Franklin Street, Fifth Floor,
25 Boston, MA 02110-1301, 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__"); \
37 /* Default target comes from config.gcc */
39 #define TARGET_DEFAULT TARGET_CPU_DEFAULT
42 /* Don't try using XFmode on the 68010. */
43 #undef LONG_DOUBLE_TYPE_SIZE
44 #define LONG_DOUBLE_TYPE_SIZE (TARGET_68020 ? 80 : 64)
47 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64
49 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 80
53 { "cpp_cpu_default_spec", CPP_CPU_DEFAULT_SPEC }, \
54 { "cpp_cpu_spec", CPP_CPU_SPEC }, \
55 { "cpp_fpu_spec", CPP_FPU_SPEC }, \
56 { "asm_default_spec", ASM_DEFAULT_SPEC }, \
57 { "netbsd_cpp_spec", NETBSD_CPP_SPEC }, \
58 { "netbsd_entry_point", NETBSD_ENTRY_POINT },
61 #define CPP_CPU_SPEC \
62 "%{m68010:-D__mc68010__} \
63 %{m68020:-D__mc68020__} \
64 %{m68030:-D__mc68030__} \
65 %{m68040:-D__mc68040__} \
66 %(cpp_cpu_default_spec)"
70 #if TARGET_DEFAULT & MASK_68020
71 #define TARGET_VERSION fprintf (stderr, " (NetBSD/m68k ELF)");
72 #define CPP_CPU_DEFAULT_SPEC "%{!m680*:-D__mc68020__}"
73 #define ASM_DEFAULT_SPEC "%{!m680*:-m68020}"
75 #define TARGET_VERSION fprintf (stderr, " (NetBSD/68010 ELF)");
76 #define CPP_CPU_DEFAULT_SPEC "%{!m680*:-D__mc68010__}"
77 #define ASM_DEFAULT_SPEC "%{!m680*:-m68010}"
81 #if TARGET_DEFAULT & MASK_68881
82 #define CPP_FPU_SPEC "%{!msoft-float:-D__HAVE_68881__ -D__HAVE_FPU__}"
84 #define CPP_FPU_SPEC "%{m68881:-D__HAVE_68881__ -D__HAVE_FPU__}"
88 /* Provide a CPP_SPEC appropriate for NetBSD m68k targets. Currently we
89 deal with the GCC option '-posix', as well as an indication as to
90 whether or not use of the FPU is allowed. */
94 "%(netbsd_cpp_spec) %(cpp_cpu_spec) %(cpp_fpu_spec)"
97 /* Provide an ASM_SPEC appropriate for NetBSD m68k ELF targets. We pass
98 on some CPU options, as well as PIC code generation options. */
102 "%(asm_default_spec) \
103 %{m68010} %{m68020} %{m68030} %{m68040} %{m68060} \
104 %{fpic|fpie:-k} %{fPIC|fPIE:-k -K}"
106 #define AS_NEEDS_DASH_FOR_PIPED_INPUT
108 /* Provide a LINK_SPEC appropriate for a NetBSD/m68k ELF target. */
111 #define LINK_SPEC NETBSD_LINK_SPEC_ELF
113 #define NETBSD_ENTRY_POINT "_start"
115 /* Output assembler code to FILE to increment profiler label # LABELNO
116 for profiling a function only. */
118 #undef FUNCTION_PROFILER
119 #define FUNCTION_PROFILER(FILE, LABELNO) \
122 asm_fprintf (FILE, "\tlea (%LLP%d,%Rpc),%Ra1\n", (LABELNO)); \
124 fprintf (FILE, "\tbsr.l __mcount@PLTPC\n"); \
126 fprintf (FILE, "\tjbsr __mcount\n"); \
131 /* Make gcc agree with <machine/ansi.h> */
134 #define SIZE_TYPE "unsigned int"
137 #define PTRDIFF_TYPE "int"
141 Here is a bunch of stuff lifted from m68kelf.h. We don't use that
142 file directly, because it has a lot of baggage we don't want. */
145 /* The prefix for register names. Note that REGISTER_NAMES
146 is supposed to include this prefix. Also note that this is NOT an
147 fprintf format string, it is a literal string. */
149 #undef REGISTER_PREFIX
150 #define REGISTER_PREFIX "%"
153 /* The prefix for local (compiler generated) lables.
154 These labels will not appear in the symbol table. */
156 #undef LOCAL_LABEL_PREFIX
157 #define LOCAL_LABEL_PREFIX "."
160 /* The prefix to add to user-visible assembler symbols. */
162 #undef USER_LABEL_PREFIX
163 #define USER_LABEL_PREFIX ""
166 /* The prefix for immediate operands. */
168 #undef IMMEDIATE_PREFIX
169 #define IMMEDIATE_PREFIX "#"
172 #undef ASM_COMMENT_START
173 #define ASM_COMMENT_START "|"
176 /* Currently, JUMP_TABLES_IN_TEXT_SECTION must be defined in order to
177 keep switch tables in the text section. */
179 #undef JUMP_TABLES_IN_TEXT_SECTION
180 #define JUMP_TABLES_IN_TEXT_SECTION 1
183 /* Use the default action for outputting the case label. */
184 #undef ASM_OUTPUT_CASE_LABEL
185 #define ASM_RETURN_CASE_JUMP \
187 if (TARGET_COLDFIRE) \
189 if (ADDRESS_REG_P (operands[0])) \
190 return "jmp %%pc@(2,%0:l)"; \
192 return "ext%.l %0\n\tjmp %%pc@(2,%0:l)"; \
195 return "jmp %%pc@(2,%0:w)"; \
199 /* This is how to output an assembler line that says to advance the
200 location counter to a multiple of 2**LOG bytes. */
202 #undef ASM_OUTPUT_ALIGN
203 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
207 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 ".section\t.bss"
219 /* Like `ASM_OUTPUT_BSS' except takes the required alignment as a
220 separate, explicit argument. If you define this macro, it is used
221 in place of `ASM_OUTPUT_BSS', and gives you more flexibility in
222 handling the required alignment of the variable. The alignment is
223 specified as the number of bits.
225 Try to use function `asm_output_aligned_bss' defined in file
226 `varasm.c' when defining this macro. */
228 #undef ASM_OUTPUT_ALIGNED_BSS
229 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
230 asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
233 #undef ASM_OUTPUT_COMMON
234 #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED) \
235 ( fputs (".comm ", (FILE)), \
236 assemble_name ((FILE), (NAME)), \
237 fprintf ((FILE), ",%u\n", (int)(SIZE)))
239 #undef ASM_OUTPUT_LOCAL
240 #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED) \
241 ( fputs (".lcomm ", (FILE)), \
242 assemble_name ((FILE), (NAME)), \
243 fprintf ((FILE), ",%u\n", (int)(SIZE)))
247 This is the end of the chunk lifted from m68kelf.h */
251 The following chunk is more or less lifted from m68kv4.h.
252 We'd like to just #include that file, but it has not yet
253 been converted to the new include style.
255 Should there be a m68kv4-abi.h ?? */
258 /* Register in which address to store a structure value is passed to a
259 function. The default in m68k.h is a1. For m68k/SVR4 it is a0. */
261 #undef M68K_STRUCT_VALUE_REGNUM
262 #define M68K_STRUCT_VALUE_REGNUM 8
265 /* Register in which static-chain is passed to a function. The
266 default isn m68k.h is a0, but that is already the struct value
267 regnum. Make it a1 instead. */
269 #undef STATIC_CHAIN_REGNUM
270 #define STATIC_CHAIN_REGNUM 9
273 /* Now to renumber registers for dbx and gdb.
274 We use the Sun-3 convention, which is:
275 floating point registers have numbers 18 to 25, not
276 16 to 23 as they do in the compiler. */
278 #undef DBX_REGISTER_NUMBER
279 #define DBX_REGISTER_NUMBER(REGNO) ((REGNO) < 16 ? (REGNO) : (REGNO) + 2)
282 /* 1 if N is a possible register number for a function value. For
283 m68k/SVR4 allow d0, a0, or fp0 as return registers, for integral,
284 pointer, or floating types, respectively. Reject fp0 if not using
285 a 68881 coprocessor. */
287 #undef FUNCTION_VALUE_REGNO_P
288 #define FUNCTION_VALUE_REGNO_P(N) \
289 ((N) == 0 || (N) == 8 || (TARGET_68881 && (N) == 16))
292 /* Define this to be true when FUNCTION_VALUE_REGNO_P is true for
293 more than one register. */
295 #undef NEEDS_UNTYPED_CALL
296 #define NEEDS_UNTYPED_CALL 1
299 /* Define how to generate (in the callee) the output value of a
300 function and how to find (in the caller) the value returned by a
301 function. VALTYPE is the data type of the value (as a tree). If
302 the precise function being called is known, FUNC is its
303 FUNCTION_DECL; otherwise, FUNC is 0. For m68k/SVR4 generate the
304 result in d0, a0, or fp0 as appropriate. */
306 #undef FUNCTION_VALUE
307 #define FUNCTION_VALUE(VALTYPE, FUNC) \
308 m68k_function_value (VALTYPE, FUNC)
311 /* For compatibility with the large body of existing code which does
312 not always properly declare external functions returning pointer
313 types, the m68k/SVR4 convention is to copy the value returned for
314 pointer functions from a0 to d0 in the function epilogue, so that
315 callers that have neglected to properly declare the callee can
316 still find the correct return value. */
318 extern int current_function_returns_pointer;
319 #define FUNCTION_EXTRA_EPILOGUE(FILE, SIZE) \
322 if (current_function_returns_pointer \
323 && ! find_equiv_reg (0, get_last_insn (), 0, 0, 0, 8, Pmode)) \
324 asm_fprintf (FILE, "\tmove.l %Ra0,%Rd0\n"); \
329 /* Define how to find the value returned by a library function
330 assuming the value has mode MODE.
331 For m68k/SVR4 look for integer values in d0, pointer values in d0
332 (returned in both d0 and a0), and floating values in fp0. */
335 #define LIBCALL_VALUE(MODE) \
336 m68k_libcall_value (MODE)
339 /* Boundary (in *bits*) on which stack pointer should be aligned.
340 The m68k/SVR4 convention is to keep the stack pointer longword aligned. */
342 #undef STACK_BOUNDARY
343 #define STACK_BOUNDARY 32
346 /* Alignment of field after `int : 0' in a structure.
347 For m68k/SVR4, this is the next longword boundary. */
349 #undef EMPTY_FIELD_BOUNDARY
350 #define EMPTY_FIELD_BOUNDARY 32
353 /* No data type wants to be aligned rounder than this.
354 For m68k/SVR4, some types (doubles for example) are aligned on 8 byte
357 #undef BIGGEST_ALIGNMENT
358 #define BIGGEST_ALIGNMENT 64
361 /* For m68k SVR4, structures are returned using the reentrant
364 #undef PCC_STATIC_STRUCT_RETURN
367 /* The svr4 ABI for the m68k says that records and unions are returned
370 #undef DEFAULT_PCC_STRUCT_RETURN
371 #define DEFAULT_PCC_STRUCT_RETURN 1
373 /* Output assembler code for a block containing the constant parts
374 of a trampoline, leaving space for the variable parts. */
376 /* On m68k svr4, the trampoline is different from the generic version
377 in that we use a1 as the static call chain. */
379 #undef TRAMPOLINE_TEMPLATE
380 #define TRAMPOLINE_TEMPLATE(FILE) \
382 assemble_aligned_integer (2, GEN_INT (0x227a)); \
383 assemble_aligned_integer (2, GEN_INT (8)); \
384 assemble_aligned_integer (2, GEN_INT (0x2f3a)); \
385 assemble_aligned_integer (2, GEN_INT (8)); \
386 assemble_aligned_integer (2, GEN_INT (0x4e75)); \
387 assemble_aligned_integer (4, const0_rtx); \
388 assemble_aligned_integer (4, const0_rtx); \
391 /* Redefine since we are using a different trampoline */
392 #undef TRAMPOLINE_SIZE
393 #define TRAMPOLINE_SIZE 18
395 /* Emit RTL insns to initialize the variable parts of a trampoline.
396 FNADDR is an RTX for the address of the function's pure code.
397 CXT is an RTX for the static chain value for the function. */
399 #undef INITIALIZE_TRAMPOLINE
400 #define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) \
402 emit_move_insn (gen_rtx_MEM (SImode, plus_constant (TRAMP, 10)), CXT); \
403 emit_move_insn (gen_rtx_MEM (SImode, plus_constant (TRAMP, 14)), FNADDR); \
408 This is the end of the chunk lifted from m68kv4.h */