OSDN Git Service

* config/s390/s390.c (s390_optimize_prolog): Do not save/restore
[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 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 GNU CC.
11
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 2, or (at your option)
15 any later version.
16
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.
21
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.  */
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       builtin_assert ("cpu=m68k");              \
35       builtin_assert ("machine=m68k");          \
36     }                                           \
37   while (0)
38
39 /* Default target comes from config.gcc */
40 #undef TARGET_DEFAULT
41 #define TARGET_DEFAULT TARGET_CPU_DEFAULT
42
43
44 /* Don't try using XFmode on the 68010.  */ 
45 #undef LONG_DOUBLE_TYPE_SIZE
46 #define LONG_DOUBLE_TYPE_SIZE                   \
47   ((TARGET_68020 || TARGET_68040 || TARGET_68040_ONLY || \
48     TARGET_68060) ? 96 : 64)
49
50 #ifdef __mc68010__
51 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64
52 #else
53 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 96
54 #endif
55
56 #define EXTRA_SPECS \
57   { "cpp_cpu_default_spec", CPP_CPU_DEFAULT_SPEC }, \
58   { "cpp_cpu_spec",         CPP_CPU_SPEC }, \
59   { "cpp_fpu_spec",         CPP_FPU_SPEC }, \
60   { "asm_default_spec",     ASM_DEFAULT_SPEC }, \
61   { "netbsd_cpp_spec",      NETBSD_CPP_SPEC }, \
62   { "netbsd_entry_point",   NETBSD_ENTRY_POINT },
63
64
65 #define CPP_CPU_SPEC \
66   "%{m68010:-D__mc68010__} \
67    %{m68020:-D__mc68020__} \
68    %{m68030:-D__mc68030__} \
69    %{m68040:-D__mc68040__} \
70    %(cpp_cpu_default_spec)"
71
72
73 #undef TARGET_VERSION
74 #if TARGET_DEFAULT & MASK_68020
75 #define TARGET_VERSION fprintf (stderr, " (NetBSD/m68k ELF)");
76 #define CPP_CPU_DEFAULT_SPEC "%{!m680*:-D__mc68020__}"
77 #define ASM_DEFAULT_SPEC "%{!m680*:-m68020}"
78 #else
79 #define TARGET_VERSION fprintf (stderr, " (NetBSD/68010 ELF)");
80 #define CPP_CPU_DEFAULT_SPEC "%{!m680*:-D__mc68010__}"
81 #define ASM_DEFAULT_SPEC "%{!m680*:-m68010}"
82 #endif
83
84
85 #if TARGET_DEFAULT & MASK_68881
86 #define CPP_FPU_SPEC "%{!msoft-float:-D__HAVE_68881__ -D__HAVE_FPU__}"
87 #else
88 #define CPP_FPU_SPEC "%{m68881:-D__HAVE_68881__ -D__HAVE_FPU__}"
89 #endif
90
91
92 /* Provide a CPP_SPEC appropriate for NetBSD m68k targets.  Currently we
93    deal with the GCC option '-posix', as well as an indication as to
94    whether or not use of the FPU is allowed.  */
95
96 #undef CPP_SPEC
97 #define CPP_SPEC \
98   "%(netbsd_cpp_spec) %(cpp_cpu_spec) %(cpp_fpu_spec)"
99
100
101 /* Provide an ASM_SPEC appropriate for NetBSD m68k ELF targets.  We pass
102    on some CPU options, as well as PIC code generation options.  */
103
104 #undef ASM_SPEC
105 #define ASM_SPEC \
106   "%(asm_default_spec) \
107     %{m68010} %{m68020} %{m68030} %{m68040} %{m68060} \
108     %{fpic:-k} %{fPIC:-k -K}"
109
110 #define AS_NEEDS_DASH_FOR_PIPED_INPUT
111
112 /* Provide a LINK_SPEC appropriate for a NetBSD/m68k ELF target.  */
113
114 #undef LINK_SPEC
115 #define LINK_SPEC NETBSD_LINK_SPEC_ELF
116
117 #define NETBSD_ENTRY_POINT "_start"
118
119 /* Output assembler code to FILE to increment profiler label # LABELNO
120    for profiling a function only.  */
121
122 #undef FUNCTION_PROFILER
123 #define FUNCTION_PROFILER(FILE, LABELNO)                                \
124 do                                                                      \
125   {                                                                     \
126     asm_fprintf (FILE, "\tlea (%LLP%d,%Rpc),%Ra1\n", (LABELNO));        \
127     if (flag_pic)                                                       \
128       fprintf (FILE, "\tbsr.l __mcount@PLTPC\n");                       \
129     else                                                                \
130       fprintf (FILE, "\tjbsr __mcount\n");                              \
131   }                                                                     \
132 while (0)
133
134
135 /* Make gcc agree with <machine/ansi.h>  */
136
137 #undef SIZE_TYPE
138 #define SIZE_TYPE "unsigned int"
139
140 #undef PTRDIFF_TYPE
141 #define PTRDIFF_TYPE "int"
142
143
144 /* XXX
145    Here is a bunch of stuff lifted from m68kelf.h.  We don't use that
146    file directly, because it has a lot of baggage we don't want.  */
147
148 #define MOTOROLA        /* Use Motorola syntax */
149 #define USE_GAS         /* But GAS wants jbsr instead of jsr */
150
151
152 /* The prefix for register names.  Note that REGISTER_NAMES
153    is supposed to include this prefix.  Also note that this is NOT an
154    fprintf format string, it is a literal string.  */
155
156 #undef REGISTER_PREFIX
157 #define REGISTER_PREFIX "%"
158
159
160 /* The prefix for local (compiler generated) lables.
161    These labels will not appear in the symbol table.  */
162
163 #undef LOCAL_LABEL_PREFIX
164 #define LOCAL_LABEL_PREFIX "."
165
166
167 /* The prefix to add to user-visible assembler symbols.  */
168
169 #undef USER_LABEL_PREFIX
170 #define USER_LABEL_PREFIX ""
171
172
173 /* The prefix for immediate operands.  */
174
175 #undef IMMEDIATE_PREFIX
176 #define IMMEDIATE_PREFIX "#"
177
178
179 #undef ASM_COMMENT_START
180 #define ASM_COMMENT_START "|"
181
182
183 /* How to refer to registers in assembler output.
184    This sequence is indexed by compiler's hard-register-number.
185    Motorola format uses different register names than defined in m68k.h.
186    We also take this chance to convert 'a6' to 'fp' */
187
188 #undef REGISTER_NAMES
189
190 #ifndef SUPPORT_SUN_FPA
191
192 #define REGISTER_NAMES                                                  \
193 {"%d0",   "%d1",   "%d2",   "%d3",   "%d4",   "%d5",   "%d6",   "%d7",  \
194  "%a0",   "%a1",   "%a2",   "%a3",   "%a4",   "%a5",   "%fp",   "%sp",  \
195  "%fp0",  "%fp1",  "%fp2",  "%fp3",  "%fp4",  "%fp5",  "%fp6",  "%fp7" }
196
197 #else /* SUPPORT_SUN_FPA */
198
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", \
203  "%fpa0", "%fpa1", "%fpa2", "%fpa3", "%fpa4", "%fpa5", "%fpa6","%fpa7", \
204  "%fpa8", "%fpa9", "%fpa10","%fpa11","%fpa12","%fpa13","%fpa14","%fpa15", \
205  "%fpa16","%fpa17","%fpa18","%fpa19","%fpa20","%fpa21","%fpa22","%fpa23", \
206  "%fpa24","%fpa25","%fpa26","%fpa27","%fpa28","%fpa29","%fpa30","%fpa31" }
207
208 #endif /* ! SUPPORT_SUN_FPA */
209
210
211 /* Currently, JUMP_TABLES_IN_TEXT_SECTION must be defined in order to
212    keep switch tables in the text section.  */
213
214 #undef JUMP_TABLES_IN_TEXT_SECTION
215 #define JUMP_TABLES_IN_TEXT_SECTION 1
216
217
218 /* Use the default action for outputting the case label.  */
219 #undef ASM_OUTPUT_CASE_LABEL
220 #define ASM_RETURN_CASE_JUMP                            \
221   do {                                                  \
222     if (TARGET_5200)                                    \
223       {                                                 \
224         if (ADDRESS_REG_P (operands[0]))                \
225           return "jmp %%pc@(2,%0:l)";                   \
226         else                                            \
227           return "ext%.l %0\n\tjmp %%pc@(2,%0:l)";      \
228       }                                                 \
229     else                                                \
230       return "jmp %%pc@(2,%0:w)";                       \
231   } while (0)
232
233
234 /* This is how to output an assembler line that says to advance the
235    location counter to a multiple of 2**LOG bytes.  */
236
237 #undef ASM_OUTPUT_ALIGN
238 #define ASM_OUTPUT_ALIGN(FILE,LOG)                                      \
239 do                                                                      \
240   {                                                                     \
241     if ((LOG) > 0)                                                      \
242       fprintf ((FILE), "%s%u\n", ALIGN_ASM_OP, 1 << (LOG));             \
243   }                                                                     \
244 while (0)
245
246
247 /* If defined, a C expression whose value is a string containing the
248    assembler operation to identify the following data as uninitialized global
249    data.  */
250
251 #define BSS_SECTION_ASM_OP      ".section\t.bss"
252
253
254 /* Like `ASM_OUTPUT_BSS' except takes the required alignment as a
255    separate, explicit argument.  If you define this macro, it is used
256    in place of `ASM_OUTPUT_BSS', and gives you more flexibility in
257    handling the required alignment of the variable.  The alignment is
258    specified as the number of bits.
259
260    Try to use function `asm_output_aligned_bss' defined in file
261    `varasm.c' when defining this macro.  */
262
263 #undef ASM_OUTPUT_ALIGNED_BSS
264 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN)           \
265   asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
266
267
268 #undef ASM_OUTPUT_COMMON
269 #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED)                    \
270 ( fputs (".comm ", (FILE)),                                             \
271   assemble_name ((FILE), (NAME)),                                       \
272   fprintf ((FILE), ",%u\n", (SIZE)))
273
274 #undef ASM_OUTPUT_LOCAL
275 #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED)                     \
276 ( fputs (".lcomm ", (FILE)),                                            \
277   assemble_name ((FILE), (NAME)),                                       \
278   fprintf ((FILE), ",%u\n", (SIZE)))
279
280
281 /* XXX
282    This is the end of the chunk lifted from m68kelf.h  */
283
284
285 /* XXX
286    The following chunk is more or less lifted from m68kv4.h.
287    We'd like to just #include that file, but it has not yet
288    been converted to the new include style.
289
290    Should there be a m68kv4-abi.h ??  */
291
292
293 /* Register in which address to store a structure value is passed to a
294    function.  The default in m68k.h is a1.  For m68k/SVR4 it is a0. */
295
296 #undef STRUCT_VALUE_REGNUM
297 #define STRUCT_VALUE_REGNUM 8
298
299
300 /* Register in which static-chain is passed to a function.  The
301    default isn m68k.h is a0, but that is already the struct value
302    regnum.  Make it a1 instead.  */
303
304 #undef STATIC_CHAIN_REGNUM
305 #define STATIC_CHAIN_REGNUM 9
306
307
308 /* Now to renumber registers for dbx and gdb.
309    We use the Sun-3 convention, which is:
310    floating point registers have numbers 18 to 25, not
311    16 to 23 as they do in the compiler.  */
312
313 #undef DBX_REGISTER_NUMBER
314 #define DBX_REGISTER_NUMBER(REGNO) ((REGNO) < 16 ? (REGNO) : (REGNO) + 2)
315
316
317 /* 1 if N is a possible register number for a function value.  For
318    m68k/SVR4 allow d0, a0, or fp0 as return registers, for integral,
319    pointer, or floating types, respectively.  Reject fp0 if not using
320    a 68881 coprocessor.  */
321
322 #undef FUNCTION_VALUE_REGNO_P
323 #define FUNCTION_VALUE_REGNO_P(N)                                       \
324   ((N) == 0 || (N) == 8 || (TARGET_68881 && (N) == 16))
325
326
327 /* Define this to be true when FUNCTION_VALUE_REGNO_P is true for
328    more than one register.  */
329
330 #undef NEEDS_UNTYPED_CALL
331 #define NEEDS_UNTYPED_CALL 1
332
333
334 /* Define how to generate (in the callee) the output value of a
335    function and how to find (in the caller) the value returned by a
336    function.  VALTYPE is the data type of the value (as a tree).  If
337    the precise function being called is known, FUNC is its
338    FUNCTION_DECL; otherwise, FUNC is 0.  For m68k/SVR4 generate the
339    result in d0, a0, or fp0 as appropriate. */
340
341 #undef FUNCTION_VALUE
342 #define FUNCTION_VALUE(VALTYPE, FUNC)                                   \
343   (TREE_CODE (VALTYPE) == REAL_TYPE && TARGET_68881                     \
344    ? gen_rtx_REG (TYPE_MODE (VALTYPE), 16)                              \
345    : (POINTER_TYPE_P (VALTYPE)                                          \
346       ? gen_rtx_REG (TYPE_MODE (VALTYPE), 8)                            \
347       : gen_rtx_REG (TYPE_MODE (VALTYPE), 0)))
348
349
350 /* For compatibility with the large body of existing code which does
351    not always properly declare external functions returning pointer
352    types, the m68k/SVR4 convention is to copy the value returned for
353    pointer functions from a0 to d0 in the function epilogue, so that
354    callers that have neglected to properly declare the callee can
355    still find the correct return value.  */
356
357 extern int current_function_returns_pointer;
358 #define FUNCTION_EXTRA_EPILOGUE(FILE, SIZE)                             \
359 do                                                                      \
360   {                                                                     \
361     if (current_function_returns_pointer                                \
362         && ! find_equiv_reg (0, get_last_insn (), 0, 0, 0, 8, Pmode))   \
363       asm_fprintf (FILE, "\tmove.l %Ra0,%Rd0\n");                       \
364   }                                                                     \
365 while (0)
366
367
368 /* Define how to find the value returned by a library function
369    assuming the value has mode MODE.
370    For m68k/SVR4 look for integer values in d0, pointer values in d0
371    (returned in both d0 and a0), and floating values in fp0.  */
372
373 #undef LIBCALL_VALUE
374 #define LIBCALL_VALUE(MODE)                                             \
375   ((((MODE) == SFmode || (MODE) == DFmode || (MODE) == XFmode)          \
376     && TARGET_68881)                                                    \
377    ? gen_rtx_REG (MODE, 16)                                             \
378    : gen_rtx_REG (MODE, 0))
379
380
381 /* Boundary (in *bits*) on which stack pointer should be aligned.
382    The m68k/SVR4 convention is to keep the stack pointer longword aligned. */
383
384 #undef STACK_BOUNDARY
385 #define STACK_BOUNDARY 32
386
387
388 /* Alignment of field after `int : 0' in a structure.
389    For m68k/SVR4, this is the next longword boundary. */
390
391 #undef EMPTY_FIELD_BOUNDARY
392 #define EMPTY_FIELD_BOUNDARY 32
393
394
395 /* No data type wants to be aligned rounder than this.
396    For m68k/SVR4, some types (doubles for example) are aligned on 8 byte
397    boundaries */
398
399 #undef BIGGEST_ALIGNMENT
400 #define BIGGEST_ALIGNMENT 64
401
402
403 /* In m68k svr4, a symbol_ref rtx can be a valid PIC operand if it is
404    an operand of a function call. */
405
406 #undef LEGITIMATE_PIC_OPERAND_P
407 #define LEGITIMATE_PIC_OPERAND_P(X)                                     \
408   ((! symbolic_operand (X, VOIDmode)                                    \
409     && ! (GET_CODE (X) == CONST_DOUBLE && mem_for_const_double (X)      \
410           && GET_CODE (mem_for_const_double (X)) == MEM                 \
411           && symbolic_operand (XEXP (mem_for_const_double (X), 0),      \
412                                VOIDmode)))                              \
413    || (GET_CODE (X) == SYMBOL_REF && SYMBOL_REF_FLAG (X))               \
414    || PCREL_GENERAL_OPERAND_OK)
415
416
417 /* For m68k SVR4, structures are returned using the reentrant
418    technique. */
419
420 #undef PCC_STATIC_STRUCT_RETURN
421
422
423 /* The svr4 ABI for the m68k says that records and unions are returned
424    in memory.  */
425
426 #undef DEFAULT_PCC_STRUCT_RETURN
427 #define DEFAULT_PCC_STRUCT_RETURN 1
428
429 /* Output assembler code for a block containing the constant parts
430    of a trampoline, leaving space for the variable parts.  */
431
432 /* On m68k svr4, the trampoline is different from the generic version
433    in that we use a1 as the static call chain.  */
434
435 #undef TRAMPOLINE_TEMPLATE
436 #define TRAMPOLINE_TEMPLATE(FILE)                                       \
437 {                                                                       \
438   assemble_aligned_integer (2, GEN_INT (0x227a));                       \
439   assemble_aligned_integer (2, GEN_INT (8));                            \
440   assemble_aligned_integer (2, GEN_INT (0x2f3a));                       \
441   assemble_aligned_integer (2, GEN_INT (8));                            \
442   assemble_aligned_integer (2, GEN_INT (0x4e75));                       \
443   assemble_aligned_integer (4, const0_rtx);                             \
444   assemble_aligned_integer (4, const0_rtx);                             \
445 }
446
447 /* Redefine since we are using a different trampoline */
448 #undef TRAMPOLINE_SIZE
449 #define TRAMPOLINE_SIZE 18
450
451 /* Emit RTL insns to initialize the variable parts of a trampoline.
452    FNADDR is an RTX for the address of the function's pure code.
453    CXT is an RTX for the static chain value for the function.  */
454
455 #undef INITIALIZE_TRAMPOLINE
456 #define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT)                       \
457 {                                                                       \
458   emit_move_insn (gen_rtx_MEM (SImode, plus_constant (TRAMP, 10)), CXT); \
459   emit_move_insn (gen_rtx_MEM (SImode, plus_constant (TRAMP, 14)), FNADDR); \
460 }
461
462
463 /* XXX
464    This is the end of the chunk lifted from m68kv4.h  */