* config/i386/uwin.h: Remove SUBTARGET_PROLOGUE.
[official-gcc.git] / gcc / config / m68k / linux.h
blob9e81a0a810964b2886a2e92ae4e92219076ed7cf
1 /* Definitions for Motorola 68k running Linux-based GNU systems with
2 ELF format.
3 Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2002, 2003 Free Software Foundation, Inc.
5 This file is part of GNU CC.
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
22 #define LINUX_DEFAULT_ELF
23 #define MOTOROLA /* Use Motorola syntax */
24 #define USE_GAS /* But GAS wants jbsr instead of jsr */
26 /* TODO: convert includes to ${tm_file} list in config.gcc. */
27 #include <m68k/m68k.h>
29 /* Make sure CC1 is undefined. */
30 #undef CC1_SPEC
32 #include "dbxelf.h"
33 #include "elfos.h"
34 #include "svr4.h"
35 #include <linux.h> /* some common stuff */
37 #undef TARGET_VERSION
38 #define TARGET_VERSION fprintf (stderr, " (68k GNU/Linux with ELF)");
40 /* 68020 with 68881 */
41 #define TARGET_DEFAULT (MASK_BITFIELD|MASK_68881|MASK_68020)
43 /* for 68k machines this only needs to be TRUE for the 68000 */
45 #undef STRICT_ALIGNMENT
46 #define STRICT_ALIGNMENT 0
48 #undef SUBTARGET_SWITCHES
49 #define SUBTARGET_SWITCHES {"ieee-fp", 0, \
50 N_("Use IEEE math for fp comparisons")},
52 /* Here are four prefixes that are used by asm_fprintf to
53 facilitate customization for alternate assembler syntaxes.
54 Machines with no likelihood of an alternate syntax need not
55 define these and need not use asm_fprintf. */
57 /* The prefix for register names. Note that REGISTER_NAMES
58 is supposed to include this prefix. Also note that this is NOT an
59 fprintf format string, it is a literal string */
61 #undef REGISTER_PREFIX
62 #define REGISTER_PREFIX "%"
64 /* The prefix for local (compiler generated) labels.
65 These labels will not appear in the symbol table. */
67 #undef LOCAL_LABEL_PREFIX
68 #define LOCAL_LABEL_PREFIX "."
70 /* The prefix to add to user-visible assembler symbols. */
72 #undef USER_LABEL_PREFIX
73 #define USER_LABEL_PREFIX ""
75 #define ASM_COMMENT_START "|"
77 /* How to refer to registers in assembler output.
78 This sequence is indexed by compiler's hard-register-number.
79 Motorola format uses different register names than defined in m68k.h. */
81 #undef REGISTER_NAMES
83 #define REGISTER_NAMES \
84 {"%d0", "%d1", "%d2", "%d3", "%d4", "%d5", "%d6", "%d7", \
85 "%a0", "%a1", "%a2", "%a3", "%a4", "%a5", "%a6", "%sp", \
86 "%fp0", "%fp1", "%fp2", "%fp3", "%fp4", "%fp5", "%fp6", "%fp7" }
88 #undef SIZE_TYPE
89 #define SIZE_TYPE "unsigned int"
91 #undef PTRDIFF_TYPE
92 #define PTRDIFF_TYPE "int"
94 #undef WCHAR_TYPE
95 #define WCHAR_TYPE "long int"
97 #undef WCHAR_TYPE_SIZE
98 #define WCHAR_TYPE_SIZE BITS_PER_WORD
100 /* Target OS builtins. */
101 #define TARGET_OS_CPP_BUILTINS() \
102 do \
104 builtin_define_std ("mc68000"); \
105 builtin_define_std ("mc68020"); \
106 builtin_define_std ("linux"); \
107 builtin_define_std ("unix"); \
108 builtin_define ("__gnu_linux__"); \
109 builtin_assert ("system=unix"); \
110 builtin_assert ("system=posix"); \
112 while (0)
114 #define TARGET_OBJFMT_CPP_BUILTINS() \
115 do \
117 builtin_define ("__ELF__"); \
119 while (0)
121 #undef CPP_SPEC
122 #if TARGET_DEFAULT & MASK_68881
123 #define CPP_SPEC \
124 "%{fPIC|fpic|fPIE|fpie:-D__PIC__ -D__pic__} %{!msoft-float:-D__HAVE_68881__} %{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
125 #else
126 #define CPP_SPEC \
127 "%{fPIC|fpic|fPIE|fpie:-D__PIC__ -D__pic__} %{m68881:-D__HAVE_68881__} %{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
128 #endif
130 /* We override the ASM_SPEC from svr4.h because we must pass -m68040 down
131 to the assembler. */
132 #undef ASM_SPEC
133 #define ASM_SPEC \
134 "%{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Yd,*} %{Wa,*:%*} \
135 %{m68040} %{m68060:-m68040}"
137 /* Provide a LINK_SPEC appropriate for GNU/Linux. Here we provide support
138 for the special GCC options -static and -shared, which allow us to
139 link things in one of these three modes by applying the appropriate
140 combinations of options at link-time. We like to support here for
141 as many of the other GNU linker options as possible. But I don't
142 have the time to search for those flags. I am sure how to add
143 support for -soname shared_object_name. H.J.
145 I took out %{v:%{!V:-V}}. It is too much :-(. They can use
146 -Wl,-V.
148 When the -shared link option is used a final link is not being
149 done. */
151 /* If ELF is the default format, we should not use /lib/elf. */
153 #undef LINK_SPEC
154 #define LINK_SPEC "-m m68kelf %{shared} \
155 %{!shared: \
156 %{!static: \
157 %{rdynamic:-export-dynamic} \
158 %{!dynamic-linker*:-dynamic-linker /lib/ld.so.1}} \
159 %{static}}"
161 /* For compatibility with linux/a.out */
163 #undef PCC_BITFIELD_TYPE_MATTERS
165 /* Currently, JUMP_TABLES_IN_TEXT_SECTION must be defined in order to
166 keep switch tables in the text section. */
168 #define JUMP_TABLES_IN_TEXT_SECTION 1
170 /* Use the default action for outputting the case label. */
171 #undef ASM_OUTPUT_CASE_LABEL
172 #define ASM_RETURN_CASE_JUMP \
173 do { \
174 if (TARGET_5200) \
176 if (ADDRESS_REG_P (operands[0])) \
177 return "jmp %%pc@(2,%0:l)"; \
178 else \
179 return "ext%.l %0\n\tjmp %%pc@(2,%0:l)"; \
181 else \
182 return "jmp %%pc@(2,%0:w)"; \
183 } while (0)
185 /* This is how to output an assembler line that says to advance the
186 location counter to a multiple of 2**LOG bytes. */
188 #undef ASM_OUTPUT_ALIGN
189 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
190 if ((LOG) > 0) \
191 fprintf ((FILE), "%s%u\n", ALIGN_ASM_OP, 1 << (LOG));
193 /* If defined, a C expression whose value is a string containing the
194 assembler operation to identify the following data as uninitialized global
195 data. */
197 #define BSS_SECTION_ASM_OP "\t.section\t.bss"
199 /* A C statement (sans semicolon) to output to the stdio stream
200 FILE the assembler definition of uninitialized global DECL named
201 NAME whose size is SIZE bytes and alignment is ALIGN bytes.
202 Try to use asm_output_aligned_bss to implement this macro. */
204 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
205 asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
207 /* Output assembler code to FILE to increment profiler label # LABELNO
208 for profiling a function entry. */
210 #undef FUNCTION_PROFILER
211 #define FUNCTION_PROFILER(FILE, LABELNO) \
213 asm_fprintf (FILE, "\tlea (%LLP%d,%Rpc),%Ra1\n", (LABELNO)); \
214 if (flag_pic) \
215 fprintf (FILE, "\tbsr.l _mcount@PLTPC\n"); \
216 else \
217 fprintf (FILE, "\tjbsr _mcount\n"); \
220 /* How to renumber registers for dbx and gdb.
221 On the Sun-3, the floating point registers have numbers
222 18 to 25, not 16 to 23 as they do in the compiler. */
224 #define DBX_REGISTER_NUMBER(REGNO) ((REGNO) < 16 ? (REGNO) : (REGNO) + 2)
226 /* Do not break .stabs pseudos into continuations. */
228 #define DBX_CONTIN_LENGTH 0
230 /* 1 if N is a possible register number for a function value. For
231 m68k/SVR4 allow d0, a0, or fp0 as return registers, for integral,
232 pointer, or floating types, respectively. Reject fp0 if not using
233 a 68881 coprocessor. */
235 #undef FUNCTION_VALUE_REGNO_P
236 #define FUNCTION_VALUE_REGNO_P(N) \
237 ((N) == 0 || (N) == 8 || (TARGET_68881 && (N) == 16))
239 /* Define this to be true when FUNCTION_VALUE_REGNO_P is true for
240 more than one register. */
242 #undef NEEDS_UNTYPED_CALL
243 #define NEEDS_UNTYPED_CALL 1
245 /* Define how to generate (in the callee) the output value of a
246 function and how to find (in the caller) the value returned by a
247 function. VALTYPE is the data type of the value (as a tree). If
248 the precise function being called is known, FUNC is its
249 FUNCTION_DECL; otherwise, FUNC is 0. For m68k/SVR4 generate the
250 result in d0, a0, or fp0 as appropriate. */
252 #undef FUNCTION_VALUE
253 #define FUNCTION_VALUE(VALTYPE, FUNC) \
254 (TREE_CODE (VALTYPE) == REAL_TYPE && TARGET_68881 \
255 ? gen_rtx_REG (TYPE_MODE (VALTYPE), 16) \
256 : (POINTER_TYPE_P (VALTYPE) \
257 ? gen_rtx_REG (TYPE_MODE (VALTYPE), 8) \
258 : gen_rtx_REG (TYPE_MODE (VALTYPE), 0)))
260 /* For compatibility with the large body of existing code which does
261 not always properly declare external functions returning pointer
262 types, the m68k/SVR4 convention is to copy the value returned for
263 pointer functions from a0 to d0 in the function epilogue, so that
264 callers that have neglected to properly declare the callee can
265 still find the correct return value. */
267 #define FUNCTION_EXTRA_EPILOGUE(FILE, SIZE) \
268 do { \
269 if (current_function_returns_pointer \
270 && ! find_equiv_reg (0, get_last_insn (), 0, 0, 0, 8, Pmode)) \
271 asm_fprintf (FILE, "\tmove.l %Ra0,%Rd0\n"); \
272 } while (0);
274 /* Define how to find the value returned by a library function
275 assuming the value has mode MODE.
276 For m68k/SVR4 look for integer values in d0, pointer values in d0
277 (returned in both d0 and a0), and floating values in fp0. */
279 #undef LIBCALL_VALUE
280 #define LIBCALL_VALUE(MODE) \
281 ((((MODE) == SFmode || (MODE) == DFmode || (MODE) == XFmode) \
282 && TARGET_68881) \
283 ? gen_rtx_REG ((MODE), 16) \
284 : gen_rtx_REG ((MODE), 0))
286 /* In m68k svr4, a symbol_ref rtx can be a valid PIC operand if it is
287 an operand of a function call. */
288 #undef LEGITIMATE_PIC_OPERAND_P
289 #define LEGITIMATE_PIC_OPERAND_P(X) \
290 ((! symbolic_operand (X, VOIDmode) \
291 && ! (GET_CODE (X) == CONST_DOUBLE && mem_for_const_double (X) != 0 \
292 && GET_CODE (mem_for_const_double (X)) == MEM \
293 && symbolic_operand (XEXP (mem_for_const_double (X), 0), \
294 VOIDmode))) \
295 || (GET_CODE (X) == SYMBOL_REF && SYMBOL_REF_FLAG (X)) \
296 || PCREL_GENERAL_OPERAND_OK)
298 /* For m68k SVR4, structures are returned using the reentrant
299 technique. */
300 #undef PCC_STATIC_STRUCT_RETURN
301 #define DEFAULT_PCC_STRUCT_RETURN 0
303 /* Finalize the trampoline by flushing the insn cache. */
305 #undef FINALIZE_TRAMPOLINE
306 #define FINALIZE_TRAMPOLINE(TRAMP) \
307 emit_library_call (gen_rtx_SYMBOL_REF (Pmode, "__clear_cache"), \
308 0, VOIDmode, 2, TRAMP, Pmode, \
309 plus_constant (TRAMP, TRAMPOLINE_SIZE), Pmode);
311 /* Clear the instruction cache from `beg' to `end'. This makes an
312 inline system call to SYS_cacheflush. The arguments are as
313 follows:
315 cacheflush (addr, scope, cache, len)
317 addr - the start address for the flush
318 scope - the scope of the flush (see the cpush insn)
319 cache - which cache to flush (see the cpush insn)
320 len - a factor relating to the number of flushes to perform:
321 len/16 lines, or len/4096 pages. */
323 #define CLEAR_INSN_CACHE(BEG, END) \
325 register unsigned long _beg __asm ("%d1") = (unsigned long) (BEG); \
326 unsigned long _end = (unsigned long) (END); \
327 register unsigned long _len __asm ("%d4") = (_end - _beg + 32); \
328 __asm __volatile \
329 ("move%.l %#123, %/d0\n\t" /* system call nr */ \
330 "move%.l %#1, %/d2\n\t" /* clear lines */ \
331 "move%.l %#3, %/d3\n\t" /* insn+data caches */ \
332 "trap %#0" \
333 : /* no outputs */ \
334 : "d" (_beg), "d" (_len) \
335 : "%d0", "%d2", "%d3"); \