OSDN Git Service

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