OSDN Git Service

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