OSDN Git Service

ed9ba6b70336284c1ca2d524cb8d47e3fac33a07
[pf3gnuchains/gcc-fork.git] / gcc / config / m68k / linux.h
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.
4
5 This file is part of GNU CC.
6
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.
11
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.
16
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.  */
21
22 #undef TARGET_VERSION
23 #define TARGET_VERSION fprintf (stderr, " (68k GNU/Linux with ELF)");
24
25 /* 68020 with 68881 */
26 #define TARGET_DEFAULT (MASK_BITFIELD|MASK_68881|MASK_68020)
27
28 /* for 68k machines this only needs to be TRUE for the 68000 */
29
30 #undef STRICT_ALIGNMENT     
31 #define STRICT_ALIGNMENT 0
32
33 #undef SUBTARGET_SWITCHES
34 #define SUBTARGET_SWITCHES      {"ieee-fp", 0, \
35   N_("Use IEEE math for fp comparisons")},
36
37 /* Here are four prefixes that are used by asm_fprintf to
38    facilitate customization for alternate assembler syntaxes.
39    Machines with no likelihood of an alternate syntax need not
40    define these and need not use asm_fprintf.  */
41
42 /* The prefix for register names.  Note that REGISTER_NAMES
43    is supposed to include this prefix. Also note that this is NOT an
44    fprintf format string, it is a literal string */
45
46 #undef REGISTER_PREFIX
47 #define REGISTER_PREFIX "%"
48
49 /* The prefix for local (compiler generated) labels.
50    These labels will not appear in the symbol table.  */
51
52 #undef LOCAL_LABEL_PREFIX
53 #define LOCAL_LABEL_PREFIX "."
54
55 /* The prefix to add to user-visible assembler symbols.  */
56
57 #undef USER_LABEL_PREFIX
58 #define USER_LABEL_PREFIX ""
59
60 #define ASM_COMMENT_START "|"
61
62 /* How to refer to registers in assembler output.
63    This sequence is indexed by compiler's hard-register-number.
64    Motorola format uses different register names than defined in m68k.h.  */
65
66 #undef REGISTER_NAMES
67
68 #define REGISTER_NAMES \
69 {"%d0", "%d1", "%d2", "%d3", "%d4", "%d5", "%d6", "%d7", \
70  "%a0", "%a1", "%a2", "%a3", "%a4", "%a5", "%a6", "%sp", \
71  "%fp0", "%fp1", "%fp2", "%fp3", "%fp4", "%fp5", "%fp6", "%fp7" }
72
73 #undef SIZE_TYPE
74 #define SIZE_TYPE "unsigned int"
75  
76 #undef PTRDIFF_TYPE
77 #define PTRDIFF_TYPE "int"
78   
79 #undef WCHAR_TYPE
80 #define WCHAR_TYPE "long int"
81    
82 #undef WCHAR_TYPE_SIZE
83 #define WCHAR_TYPE_SIZE BITS_PER_WORD
84
85 /* Target OS builtins.  */
86 #define TARGET_OS_CPP_BUILTINS()                \
87   do                                            \
88     {                                           \
89         builtin_define_std ("mc68000");         \
90         builtin_define_std ("mc68020");         \
91         builtin_define_std ("linux");           \
92         builtin_define_std ("unix");            \
93         builtin_define ("__gnu_linux__");       \
94         builtin_assert ("system=unix");         \
95         builtin_assert ("system=posix");        \
96    }                                            \
97   while (0)
98
99 #define TARGET_OBJFMT_CPP_BUILTINS()            \
100   do                                            \
101     {                                           \
102         builtin_define ("__ELF__");             \
103     }                                           \
104   while (0)
105
106 #undef CPP_SPEC
107 #if TARGET_DEFAULT & MASK_68881
108 #define CPP_SPEC \
109   "%{fPIC|fpic|fPIE|fpie:-D__PIC__ -D__pic__} %{!msoft-float:-D__HAVE_68881__} %{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
110 #else
111 #define CPP_SPEC \
112   "%{fPIC|fpic|fPIE|fpie:-D__PIC__ -D__pic__} %{m68881:-D__HAVE_68881__} %{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
113 #endif
114
115 /* We override the ASM_SPEC from svr4.h because we must pass -m68040 down
116    to the assembler.  */
117 #undef ASM_SPEC
118 #define ASM_SPEC \
119   "%{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Yd,*} %{Wa,*:%*} \
120 %{m68040} %{m68060:-m68040}"
121
122 /* Provide a LINK_SPEC appropriate for GNU/Linux.  Here we provide support
123    for the special GCC options -static and -shared, which allow us to
124    link things in one of these three modes by applying the appropriate
125    combinations of options at link-time.  We like to support here for
126    as many of the other GNU linker options as possible.  But I don't
127    have the time to search for those flags.  I am sure how to add
128    support for -soname shared_object_name. H.J.
129
130    I took out %{v:%{!V:-V}}.  It is too much :-(.  They can use
131    -Wl,-V.
132
133    When the -shared link option is used a final link is not being
134    done.  */
135
136 /* If ELF is the default format, we should not use /lib/elf.  */
137
138 #undef  LINK_SPEC
139 #define LINK_SPEC "-m m68kelf %{shared} \
140   %{!shared: \
141     %{!static: \
142       %{rdynamic:-export-dynamic} \
143       %{!dynamic-linker*:-dynamic-linker /lib/ld.so.1}} \
144     %{static}}"
145
146 /* For compatibility with linux/a.out */
147
148 #undef PCC_BITFIELD_TYPE_MATTERS
149
150 /* Currently, JUMP_TABLES_IN_TEXT_SECTION must be defined in order to
151    keep switch tables in the text section.  */
152    
153 #define JUMP_TABLES_IN_TEXT_SECTION 1
154
155 /* Use the default action for outputting the case label.  */
156 #undef ASM_OUTPUT_CASE_LABEL
157 #define ASM_RETURN_CASE_JUMP                            \
158   do {                                                  \
159     if (TARGET_COLDFIRE)                                \
160       {                                                 \
161         if (ADDRESS_REG_P (operands[0]))                \
162           return "jmp %%pc@(2,%0:l)";                   \
163         else                                            \
164           return "ext%.l %0\n\tjmp %%pc@(2,%0:l)";      \
165       }                                                 \
166     else                                                \
167       return "jmp %%pc@(2,%0:w)";                       \
168   } while (0)
169
170 /* This is how to output an assembler line that says to advance the
171    location counter to a multiple of 2**LOG bytes.  */
172
173 #undef ASM_OUTPUT_ALIGN
174 #define ASM_OUTPUT_ALIGN(FILE,LOG)                              \
175   if ((LOG) > 0)                                                \
176     fprintf ((FILE), "%s%u\n", ALIGN_ASM_OP, 1 << (LOG));
177
178 /* If defined, a C expression whose value is a string containing the
179    assembler operation to identify the following data as uninitialized global
180    data.  */
181
182 #define BSS_SECTION_ASM_OP "\t.section\t.bss"
183
184 /* A C statement (sans semicolon) to output to the stdio stream
185    FILE the assembler definition of uninitialized global DECL named
186    NAME whose size is SIZE bytes and alignment is ALIGN bytes.
187    Try to use asm_output_aligned_bss to implement this macro.  */
188
189 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
190   asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
191
192 /* Output assembler code to FILE to increment profiler label # LABELNO
193    for profiling a function entry.  */
194
195 #undef FUNCTION_PROFILER
196 #define FUNCTION_PROFILER(FILE, LABELNO) \
197 {                                                                       \
198   asm_fprintf (FILE, "\tlea (%LLP%d,%Rpc),%Ra1\n", (LABELNO));          \
199   if (flag_pic)                                                         \
200     fprintf (FILE, "\tbsr.l _mcount@PLTPC\n");                          \
201   else                                                                  \
202     fprintf (FILE, "\tjbsr _mcount\n");                                 \
203 }
204
205 /* How to renumber registers for dbx and gdb.
206    On the Sun-3, the floating point registers have numbers
207    18 to 25, not 16 to 23 as they do in the compiler.  */
208
209 #define DBX_REGISTER_NUMBER(REGNO) ((REGNO) < 16 ? (REGNO) : (REGNO) + 2)
210
211 /* Do not break .stabs pseudos into continuations.  */
212
213 #define DBX_CONTIN_LENGTH 0
214
215 /* 1 if N is a possible register number for a function value.  For
216    m68k/SVR4 allow d0, a0, or fp0 as return registers, for integral,
217    pointer, or floating types, respectively.  Reject fp0 if not using
218    a 68881 coprocessor.  */
219
220 #undef FUNCTION_VALUE_REGNO_P
221 #define FUNCTION_VALUE_REGNO_P(N) \
222   ((N) == 0 || (N) == 8 || (TARGET_68881 && (N) == 16))
223
224 /* Define this to be true when FUNCTION_VALUE_REGNO_P is true for
225    more than one register.  */
226
227 #undef NEEDS_UNTYPED_CALL
228 #define NEEDS_UNTYPED_CALL 1
229
230 /* Define how to generate (in the callee) the output value of a
231    function and how to find (in the caller) the value returned by a
232    function.  VALTYPE is the data type of the value (as a tree).  If
233    the precise function being called is known, FUNC is its
234    FUNCTION_DECL; otherwise, FUNC is 0.  For m68k/SVR4 generate the
235    result in d0, a0, or fp0 as appropriate.  */
236    
237 #undef FUNCTION_VALUE
238 #define FUNCTION_VALUE(VALTYPE, FUNC)                                   \
239   (TREE_CODE (VALTYPE) == REAL_TYPE && TARGET_68881                     \
240    ? gen_rtx_REG (TYPE_MODE (VALTYPE), 16)                              \
241    : (POINTER_TYPE_P (VALTYPE)                                          \
242       ? gen_rtx_REG (TYPE_MODE (VALTYPE), 8)                            \
243       : gen_rtx_REG (TYPE_MODE (VALTYPE), 0)))
244
245 /* For compatibility with the large body of existing code which does
246    not always properly declare external functions returning pointer
247    types, the m68k/SVR4 convention is to copy the value returned for
248    pointer functions from a0 to d0 in the function epilogue, so that
249    callers that have neglected to properly declare the callee can
250    still find the correct return value.  */
251
252 #define FUNCTION_EXTRA_EPILOGUE(FILE, SIZE)                             \
253 do {                                                                    \
254   if (current_function_returns_pointer                                  \
255       && ! find_equiv_reg (0, get_last_insn (), 0, 0, 0, 8, Pmode))     \
256     asm_fprintf (FILE, "\tmove.l %Ra0,%Rd0\n");                         \
257 } while (0);
258
259 /* Define how to find the value returned by a library function
260    assuming the value has mode MODE.
261    For m68k/SVR4 look for integer values in d0, pointer values in d0
262    (returned in both d0 and a0), and floating values in fp0.  */
263
264 #undef LIBCALL_VALUE
265 #define LIBCALL_VALUE(MODE)                                             \
266   ((((MODE) == SFmode || (MODE) == DFmode || (MODE) == XFmode)          \
267     && TARGET_68881)                                                    \
268    ? gen_rtx_REG ((MODE), 16)                                           \
269    : gen_rtx_REG ((MODE), 0))
270
271 /* For m68k SVR4, structures are returned using the reentrant
272    technique.  */
273 #undef PCC_STATIC_STRUCT_RETURN
274 #define DEFAULT_PCC_STRUCT_RETURN 0
275
276 /* Finalize the trampoline by flushing the insn cache.  */
277
278 #undef FINALIZE_TRAMPOLINE
279 #define FINALIZE_TRAMPOLINE(TRAMP)                                      \
280   emit_library_call (gen_rtx_SYMBOL_REF (Pmode, "__clear_cache"),       \
281                      0, VOIDmode, 2, TRAMP, Pmode,                      \
282                      plus_constant (TRAMP, TRAMPOLINE_SIZE), Pmode);
283
284 /* Clear the instruction cache from `beg' to `end'.  This makes an
285    inline system call to SYS_cacheflush.  The arguments are as
286    follows:
287
288         cacheflush (addr, scope, cache, len)
289
290    addr   - the start address for the flush
291    scope  - the scope of the flush (see the cpush insn)
292    cache  - which cache to flush (see the cpush insn)
293    len    - a factor relating to the number of flushes to perform:
294             len/16 lines, or len/4096 pages.  */
295
296 #define CLEAR_INSN_CACHE(BEG, END)                                      \
297 {                                                                       \
298   register unsigned long _beg __asm ("%d1") = (unsigned long) (BEG);    \
299   unsigned long _end = (unsigned long) (END);                           \
300   register unsigned long _len __asm ("%d4") = (_end - _beg + 32);       \
301   __asm __volatile                                                      \
302     ("move%.l %#123, %/d0\n\t"  /* system call nr */                    \
303      "move%.l %#1, %/d2\n\t"    /* clear lines */                       \
304      "move%.l %#3, %/d3\n\t"    /* insn+data caches */                  \
305      "trap %#0"                                                         \
306      : /* no outputs */                                                 \
307      : "d" (_beg), "d" (_len)                                           \
308      : "%d0", "%d2", "%d3");                                            \
309 }
310
311 #define TARGET_ASM_FILE_END file_end_indicate_exec_stack