]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/config/m68k/netbsd-elf.h
200x-xx-xx Richard Sandiford <richard@codesourcery.com> Nathan Sidwell <nathan@codeso...
[thirdparty/gcc.git] / gcc / config / m68k / netbsd-elf.h
1 /* Definitions of target machine for GNU compiler,
2 for m68k (including m68010) NetBSD platforms using the
3 ELF object format.
4 Copyright (C) 2002, 2003, 2004, 2006 Free Software Foundation, Inc.
5 Contributed by Wasabi Systems. Inc.
6
7 This file is derived from <m68k/m68kv4.h>, <m68k/m68kelf.h>,
8 and <m68k/linux.h>.
9
10 This file is part of GCC.
11
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)
15 any later version.
16
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.
21
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. */
26
27 #define TARGET_OS_CPP_BUILTINS() \
28 do \
29 { \
30 NETBSD_OS_CPP_BUILTINS_ELF(); \
31 builtin_define ("__m68k__"); \
32 builtin_define ("__SVR4_ABI__"); \
33 builtin_define ("__motorola__"); \
34 if (TARGET_HARD_FLOAT) \
35 builtin_define ("__HAVE_FPU__"); \
36 } \
37 while (0)
38
39 /* Don't try using XFmode on the 68010. */
40 #undef LONG_DOUBLE_TYPE_SIZE
41 #define LONG_DOUBLE_TYPE_SIZE (TARGET_68020 ? 80 : 64)
42
43 #ifdef __mc68010__
44 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64
45 #else
46 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 80
47 #endif
48
49 #undef SUBTARGET_EXTRA_SPECS
50 #define SUBTARGET_EXTRA_SPECS \
51 { "netbsd_entry_point", NETBSD_ENTRY_POINT },
52
53
54 #undef TARGET_VERSION
55 #define TARGET_VERSION \
56 fprintf (stderr, \
57 TARGET_68010 \
58 ? " (NetBSD/68010 ELF)" \
59 : " (NetBSD/m68k ELF)");
60
61
62 /* Provide a CPP_SPEC appropriate for NetBSD m68k targets. Currently we
63 deal with the GCC option '-posix', as well as an indication as to
64 whether or not use of the FPU is allowed. */
65
66 #undef CPP_SPEC
67 #define CPP_SPEC NETBSD_CPP_SPEC
68
69
70 /* Provide an ASM_SPEC appropriate for NetBSD m68k ELF targets. We need
71 to passn PIC code generation options. */
72
73 #undef ASM_SPEC
74 #define ASM_SPEC "%(asm_cpu_spec) %{fpic|fpie:-k} %{fPIC|fPIE:-k -K}"
75
76 #define AS_NEEDS_DASH_FOR_PIPED_INPUT
77
78 /* Provide a LINK_SPEC appropriate for a NetBSD/m68k ELF target. */
79
80 #undef LINK_SPEC
81 #define LINK_SPEC NETBSD_LINK_SPEC_ELF
82
83 #define NETBSD_ENTRY_POINT "_start"
84
85 /* Output assembler code to FILE to increment profiler label # LABELNO
86 for profiling a function only. */
87
88 #undef FUNCTION_PROFILER
89 #define FUNCTION_PROFILER(FILE, LABELNO) \
90 do \
91 { \
92 asm_fprintf (FILE, "\tlea (%LLP%d,%Rpc),%Ra1\n", (LABELNO)); \
93 if (flag_pic) \
94 fprintf (FILE, "\tbsr.l __mcount@PLTPC\n"); \
95 else \
96 fprintf (FILE, "\tjbsr __mcount\n"); \
97 } \
98 while (0)
99
100
101 /* Make gcc agree with <machine/ansi.h> */
102
103 #undef SIZE_TYPE
104 #define SIZE_TYPE "unsigned int"
105
106 #undef PTRDIFF_TYPE
107 #define PTRDIFF_TYPE "int"
108
109
110 /* XXX
111 Here is a bunch of stuff lifted from m68kelf.h. We don't use that
112 file directly, because it has a lot of baggage we don't want. */
113
114
115 /* The prefix for register names. Note that REGISTER_NAMES
116 is supposed to include this prefix. Also note that this is NOT an
117 fprintf format string, it is a literal string. */
118
119 #undef REGISTER_PREFIX
120 #define REGISTER_PREFIX "%"
121
122
123 /* The prefix for local (compiler generated) lables.
124 These labels will not appear in the symbol table. */
125
126 #undef LOCAL_LABEL_PREFIX
127 #define LOCAL_LABEL_PREFIX "."
128
129
130 /* The prefix to add to user-visible assembler symbols. */
131
132 #undef USER_LABEL_PREFIX
133 #define USER_LABEL_PREFIX ""
134
135
136 /* The prefix for immediate operands. */
137
138 #undef IMMEDIATE_PREFIX
139 #define IMMEDIATE_PREFIX "#"
140
141
142 #undef ASM_COMMENT_START
143 #define ASM_COMMENT_START "|"
144
145
146 /* Currently, JUMP_TABLES_IN_TEXT_SECTION must be defined in order to
147 keep switch tables in the text section. */
148
149 #undef JUMP_TABLES_IN_TEXT_SECTION
150 #define JUMP_TABLES_IN_TEXT_SECTION 1
151
152
153 /* Use the default action for outputting the case label. */
154 #undef ASM_OUTPUT_CASE_LABEL
155 #define ASM_RETURN_CASE_JUMP \
156 do { \
157 if (TARGET_COLDFIRE) \
158 { \
159 if (ADDRESS_REG_P (operands[0])) \
160 return "jmp %%pc@(2,%0:l)"; \
161 else \
162 return "ext%.l %0\n\tjmp %%pc@(2,%0:l)"; \
163 } \
164 else \
165 return "jmp %%pc@(2,%0:w)"; \
166 } while (0)
167
168
169 /* This is how to output an assembler line that says to advance the
170 location counter to a multiple of 2**LOG bytes. */
171
172 #undef ASM_OUTPUT_ALIGN
173 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
174 do \
175 { \
176 if ((LOG) > 0) \
177 fprintf ((FILE), "%s%u\n", ALIGN_ASM_OP, 1 << (LOG)); \
178 } \
179 while (0)
180
181
182 /* If defined, a C expression whose value is a string containing the
183 assembler operation to identify the following data as uninitialized global
184 data. */
185
186 #define BSS_SECTION_ASM_OP ".section\t.bss"
187
188
189 /* Like `ASM_OUTPUT_BSS' except takes the required alignment as a
190 separate, explicit argument. If you define this macro, it is used
191 in place of `ASM_OUTPUT_BSS', and gives you more flexibility in
192 handling the required alignment of the variable. The alignment is
193 specified as the number of bits.
194
195 Try to use function `asm_output_aligned_bss' defined in file
196 `varasm.c' when defining this macro. */
197
198 #undef ASM_OUTPUT_ALIGNED_BSS
199 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
200 asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
201
202
203 #undef ASM_OUTPUT_COMMON
204 #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED) \
205 ( fputs (".comm ", (FILE)), \
206 assemble_name ((FILE), (NAME)), \
207 fprintf ((FILE), ",%u\n", (int)(SIZE)))
208
209 #undef ASM_OUTPUT_LOCAL
210 #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED) \
211 ( fputs (".lcomm ", (FILE)), \
212 assemble_name ((FILE), (NAME)), \
213 fprintf ((FILE), ",%u\n", (int)(SIZE)))
214
215
216 /* XXX
217 This is the end of the chunk lifted from m68kelf.h */
218
219
220 /* XXX
221 The following chunk is more or less lifted from m68kv4.h.
222 We'd like to just #include that file, but it has not yet
223 been converted to the new include style.
224
225 Should there be a m68kv4-abi.h ?? */
226
227
228 /* Register in which address to store a structure value is passed to a
229 function. The default in m68k.h is a1. For m68k/SVR4 it is a0. */
230
231 #undef M68K_STRUCT_VALUE_REGNUM
232 #define M68K_STRUCT_VALUE_REGNUM 8
233
234
235 /* Register in which static-chain is passed to a function. The
236 default isn m68k.h is a0, but that is already the struct value
237 regnum. Make it a1 instead. */
238
239 #undef STATIC_CHAIN_REGNUM
240 #define STATIC_CHAIN_REGNUM 9
241
242
243 /* Now to renumber registers for dbx and gdb.
244 We use the Sun-3 convention, which is:
245 floating point registers have numbers 18 to 25, not
246 16 to 23 as they do in the compiler. */
247
248 #undef DBX_REGISTER_NUMBER
249 #define DBX_REGISTER_NUMBER(REGNO) ((REGNO) < 16 ? (REGNO) : (REGNO) + 2)
250
251
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. */
256
257 #undef FUNCTION_VALUE_REGNO_P
258 #define FUNCTION_VALUE_REGNO_P(N) \
259 ((N) == 0 || (N) == 8 || (TARGET_68881 && (N) == 16))
260
261
262 /* Define this to be true when FUNCTION_VALUE_REGNO_P is true for
263 more than one register. */
264
265 #undef NEEDS_UNTYPED_CALL
266 #define NEEDS_UNTYPED_CALL 1
267
268
269 /* Define how to generate (in the callee) the output value of a
270 function and how to find (in the caller) the value returned by a
271 function. VALTYPE is the data type of the value (as a tree). If
272 the precise function being called is known, FUNC is its
273 FUNCTION_DECL; otherwise, FUNC is 0. For m68k/SVR4 generate the
274 result in d0, a0, or fp0 as appropriate. */
275
276 #undef FUNCTION_VALUE
277 #define FUNCTION_VALUE(VALTYPE, FUNC) \
278 m68k_function_value (VALTYPE, FUNC)
279
280
281 /* For compatibility with the large body of existing code which does
282 not always properly declare external functions returning pointer
283 types, the m68k/SVR4 convention is to copy the value returned for
284 pointer functions from a0 to d0 in the function epilogue, so that
285 callers that have neglected to properly declare the callee can
286 still find the correct return value. */
287
288 extern int current_function_returns_pointer;
289 #define FUNCTION_EXTRA_EPILOGUE(FILE, SIZE) \
290 do \
291 { \
292 if (current_function_returns_pointer \
293 && ! find_equiv_reg (0, get_last_insn (), 0, 0, 0, 8, Pmode)) \
294 asm_fprintf (FILE, "\tmove.l %Ra0,%Rd0\n"); \
295 } \
296 while (0)
297
298
299 /* Define how to find the value returned by a library function
300 assuming the value has mode MODE.
301 For m68k/SVR4 look for integer values in d0, pointer values in d0
302 (returned in both d0 and a0), and floating values in fp0. */
303
304 #undef LIBCALL_VALUE
305 #define LIBCALL_VALUE(MODE) \
306 m68k_libcall_value (MODE)
307
308
309 /* Boundary (in *bits*) on which stack pointer should be aligned.
310 The m68k/SVR4 convention is to keep the stack pointer longword aligned. */
311
312 #undef STACK_BOUNDARY
313 #define STACK_BOUNDARY 32
314
315
316 /* Alignment of field after `int : 0' in a structure.
317 For m68k/SVR4, this is the next longword boundary. */
318
319 #undef EMPTY_FIELD_BOUNDARY
320 #define EMPTY_FIELD_BOUNDARY 32
321
322
323 /* No data type wants to be aligned rounder than this.
324 For m68k/SVR4, some types (doubles for example) are aligned on 8 byte
325 boundaries */
326
327 #undef BIGGEST_ALIGNMENT
328 #define BIGGEST_ALIGNMENT 64
329
330
331 /* For m68k SVR4, structures are returned using the reentrant
332 technique. */
333
334 #undef PCC_STATIC_STRUCT_RETURN
335
336
337 /* The svr4 ABI for the m68k says that records and unions are returned
338 in memory. */
339
340 #undef DEFAULT_PCC_STRUCT_RETURN
341 #define DEFAULT_PCC_STRUCT_RETURN 1
342
343 /* Output assembler code for a block containing the constant parts
344 of a trampoline, leaving space for the variable parts. */
345
346 /* On m68k svr4, the trampoline is different from the generic version
347 in that we use a1 as the static call chain. */
348
349 #undef TRAMPOLINE_TEMPLATE
350 #define TRAMPOLINE_TEMPLATE(FILE) \
351 { \
352 assemble_aligned_integer (2, GEN_INT (0x227a)); \
353 assemble_aligned_integer (2, GEN_INT (8)); \
354 assemble_aligned_integer (2, GEN_INT (0x2f3a)); \
355 assemble_aligned_integer (2, GEN_INT (8)); \
356 assemble_aligned_integer (2, GEN_INT (0x4e75)); \
357 assemble_aligned_integer (4, const0_rtx); \
358 assemble_aligned_integer (4, const0_rtx); \
359 }
360
361 /* Redefine since we are using a different trampoline */
362 #undef TRAMPOLINE_SIZE
363 #define TRAMPOLINE_SIZE 18
364
365 /* Emit RTL insns to initialize the variable parts of a trampoline.
366 FNADDR is an RTX for the address of the function's pure code.
367 CXT is an RTX for the static chain value for the function. */
368
369 #undef INITIALIZE_TRAMPOLINE
370 #define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) \
371 { \
372 emit_move_insn (gen_rtx_MEM (SImode, plus_constant (TRAMP, 10)), CXT); \
373 emit_move_insn (gen_rtx_MEM (SImode, plus_constant (TRAMP, 14)), FNADDR); \
374 }
375
376
377 /* XXX
378 This is the end of the chunk lifted from m68kv4.h */