OSDN Git Service

(ASM_COMMENT_START): Define.
[pf3gnuchains/gcc-fork.git] / gcc / config / m68k / linux.h
1 /* Definitions for Motorola 68k running Linux with ELF format.
2    Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
3
4 This file is part of GNU CC.
5
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 1, or (at your option)
9 any later version.
10
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING.  If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA.  */
20
21 #define LINUX_DEFAULT_ELF
22 #define MOTOROLA                /* Use Motorola syntax */
23 #define USE_GAS                 /* But GAS wants jbsr instead of jsr */
24
25 #include <m68k/m68k.h>
26 #include <linux.h>              /* some common stuff */
27
28 #undef TARGET_VERSION
29 #define TARGET_VERSION fprintf (stderr, " (68k Linux/ELF)");
30
31 /* 68020 with 68881 */
32 #define TARGET_DEFAULT (MASK_BITFIELD|MASK_68881|MASK_68020)
33
34 /* for 68k machines this only needs to be TRUE for the 68000 */
35
36 #undef STRICT_ALIGNMENT     
37 #define STRICT_ALIGNMENT 0
38
39 #undef SUBTARGET_SWITCHES
40 #define SUBTARGET_SWITCHES      {"ieee-fp", 0},
41
42 /* Here are four prefixes that are used by asm_fprintf to
43    facilitate customization for alternate assembler syntaxes.
44    Machines with no likelihood of an alternate syntax need not
45    define these and need not use asm_fprintf.  */
46
47 /* The prefix for register names.  Note that REGISTER_NAMES
48    is supposed to include this prefix. Also note that this is NOT an
49    fprintf format string, it is a literal string */
50
51 #undef REGISTER_PREFIX
52 #define REGISTER_PREFIX "%"
53
54 /* The prefix for local (compiler generated) labels.
55    These labels will not appear in the symbol table. */
56
57 #undef LOCAL_LABEL_PREFIX
58 #define LOCAL_LABEL_PREFIX "."
59
60 /* The prefix to add to user-visible assembler symbols. */
61
62 #undef USER_LABEL_PREFIX
63 #define USER_LABEL_PREFIX ""
64
65 #define ASM_COMMENT_START "|"
66
67 /* How to refer to registers in assembler output.
68    This sequence is indexed by compiler's hard-register-number.
69    Motorola format uses different register names than defined in m68k.h. */
70
71 #undef REGISTER_NAMES
72
73 #ifndef SUPPORT_SUN_FPA
74
75 #define REGISTER_NAMES \
76 {"%d0", "%d1", "%d2", "%d3", "%d4", "%d5", "%d6", "%d7", \
77  "%a0", "%a1", "%a2", "%a3", "%a4", "%a5", "%a6", "%sp", \
78  "%fp0", "%fp1", "%fp2", "%fp3", "%fp4", "%fp5", "%fp6", "%fp7" }
79
80 #else /* SUPPORTED_SUN_FPA */
81
82 #define REGISTER_NAMES \
83 {"%d0", "%d1", "%d2", "%d3", "%d4", "%d5", "%d6", "%d7", \
84  "%a0", "%a1", "%a2", "%a3", "%a4", "%a5", "%a6", "%sp", \
85  "%fp0", "%fp1", "%fp2", "%fp3", "%fp4", "%fp5", "%fp6", "%fp7", \
86  "%fpa0", "%fpa1", "%fpa2", "%fpa3", "%fpa4", "%fpa5", "%fpa6", "%fpa7", \
87  "%fpa8", "%fpa9", "%fpa10","%fpa11","%fpa12","%fpa13","%fpa14","%fpa15", \
88  "%fpa16","%fpa17","%fpa18","%fpa19","%fpa20","%fpa21","%fpa22","%fpa23", \
89  "%fpa24","%fpa25","%fpa26","%fpa27","%fpa28","%fpa29","%fpa30","%fpa31" }
90
91 #endif /* defined SUPPORT_SUN_FPA */
92
93 #undef SIZE_TYPE
94 #define SIZE_TYPE "unsigned int"
95  
96 #undef PTRDIFF_TYPE
97 #define PTRDIFF_TYPE "int"
98   
99 #undef WCHAR_TYPE
100 #define WCHAR_TYPE "long int"
101    
102 #undef WCHAR_TYPE_SIZE
103 #define WCHAR_TYPE_SIZE BITS_PER_WORD
104
105 #define CPP_PREDEFINES \
106   "-D__ELF__ -Dunix -Dmc68000 -Dmc68020 -Dlinux -Asystem(unix) -Asystem(posix) -Acpu(m68k) -Amachine(m68k)"
107
108 #undef CPP_SPEC
109 #if TARGET_DEFAULT & MASK_68881
110 #define CPP_SPEC \
111   "%{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{!msoft-float:-D__HAVE_68881__} %{posix:-D_POSIX_SOURCE}"
112 #else
113 #define CPP_SPEC \
114   "%{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{m68881:-D__HAVE_68881__} %{posix:-D_POSIX_SOURCE}"
115 #endif
116
117 /* We override the ASM_SPEC from svr4.h because we must pass -m68040 down
118    to the assembler.  */
119 #undef ASM_SPEC
120 #define ASM_SPEC \
121   "%{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Yd,*} %{Wa,*:%*} \
122 %{m68040} %{m68060:-m68040}"
123
124 /* Provide a LINK_SPEC appropriate for Linux.  Here we provide support
125    for the special GCC options -static and -shared, which allow us to
126    link things in one of these three modes by applying the appropriate
127    combinations of options at link-time.  We like to support here for
128    as many of the other GNU linker options as possible.  But I don't
129    have the time to search for those flags.  I am sure how to add
130    support for -soname shared_object_name. H.J.
131
132    I took out %{v:%{!V:-V}}.  It is too much :-(.  They can use
133    -Wl,-V.
134
135    When the -shared link option is used a final link is not being
136    done.  */
137
138 /* If ELF is the default format, we should not use /lib/elf. */
139
140 #undef  LINK_SPEC
141 #ifndef LINUX_DEFAULT_ELF
142 #define LINK_SPEC "-m m68kelf %{shared} %{symbolic:-shared -Bsymbolic} \
143   %{!shared:%{!symbolic: \
144     %{!static: \
145       %{rdynamic:-export-dynamic} \
146       %{!dynamic-linker*:-dynamic-linker /lib/elf/ld-linux.so.1} \
147       %{!rpath*:-rpath /lib/elf/}} %{static}}}"
148 #else
149 #define LINK_SPEC "-m m68kelf %{shared} %{symbolic:-shared -Bsymbolic} \
150   %{!shared:%{!symbolic: \
151     %{!static: \
152       %{rdynamic:-export-dynamic} \
153       %{!dynamic-linker*:-dynamic-linker /lib/ld-linux.so.1}} \
154     %{static}}}"
155 #endif
156
157 /* For compatibility with linux/a.out */
158
159 #undef PCC_BITFIELD_TYPE_MATTERS
160
161 /* Currently, JUMP_TABLES_IN_TEXT_SECTION must be defined in order to
162    keep switch tables in the text section.  */
163    
164 #define JUMP_TABLES_IN_TEXT_SECTION 1
165
166 /* Use the default action for outputting the case label.  */
167 #undef ASM_OUTPUT_CASE_LABEL
168 #define ASM_RETURN_CASE_JUMP                    \
169   do {                                          \
170     if (TARGET_5200)                            \
171       return "ext%.l %0\n\tjmp %%pc@(2,%0:l)";  \
172     else                                        \
173       return "jmp %%pc@(2,%0:w)";               \
174   } while (0)
175
176 /* This is how to output an assembler line that says to advance the
177    location counter to a multiple of 2**LOG bytes.  */
178
179 #undef ASM_OUTPUT_ALIGN
180 #define ASM_OUTPUT_ALIGN(FILE,LOG)                              \
181   if ((LOG) > 0)                                                \
182     fprintf ((FILE), "\t%s \t%u\n", ALIGN_ASM_OP, 1 << (LOG));
183
184 /* If defined, a C expression whose value is a string containing the
185    assembler operation to identify the following data as uninitialized global
186    data.  */
187
188 #define BSS_SECTION_ASM_OP ".section\t.bss"
189
190 /* A C statement (sans semicolon) to output to the stdio stream
191    FILE the assembler definition of uninitialized global DECL named
192    NAME whose size is SIZE bytes and alignment is ALIGN bytes.
193    Try to use asm_output_aligned_bss to implement this macro.  */
194
195 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
196   asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
197
198 /* Output assembler code to FILE to increment profiler label # LABELNO
199    for profiling a function entry.  */
200
201 #undef FUNCTION_PROFILER
202 #define FUNCTION_PROFILER(FILE, LABELNO) \
203 {                                                                       \
204   asm_fprintf (FILE, "\tlea (%LLP%d,%Rpc),%Ra1\n", (LABELNO));          \
205   if (flag_pic)                                                         \
206     fprintf (FILE, "\tbsr.l _mcount@PLTPC\n");                          \
207   else                                                                  \
208     fprintf (FILE, "\tjbsr _mcount\n");                                 \
209 }
210
211 /* How to renumber registers for dbx and gdb.
212    On the Sun-3, the floating point registers have numbers
213    18 to 25, not 16 to 23 as they do in the compiler.  */
214
215 #define DBX_REGISTER_NUMBER(REGNO) ((REGNO) < 16 ? (REGNO) : (REGNO) + 2)
216
217 /* Do not break .stabs pseudos into continuations.  */
218
219 #define DBX_CONTIN_LENGTH 0
220
221 /* Allow folding division by zero.  */
222 #define REAL_INFINITY
223
224 /* 1 if N is a possible register number for a function value.  For
225    m68k/SVR4 allow d0, a0, or fp0 as return registers, for integral,
226    pointer, or floating types, respectively.  Reject fp0 if not using
227    a 68881 coprocessor.  */
228
229 #undef FUNCTION_VALUE_REGNO_P
230 #define FUNCTION_VALUE_REGNO_P(N) \
231   ((N) == 0 || (N) == 8 || (TARGET_68881 && (N) == 16))
232
233 /* Define this to be true when FUNCTION_VALUE_REGNO_P is true for
234    more than one register.  */
235
236 #undef NEEDS_UNTYPED_CALL
237 #define NEEDS_UNTYPED_CALL 1
238
239 /* Define how to generate (in the callee) the output value of a
240    function and how to find (in the caller) the value returned by a
241    function.  VALTYPE is the data type of the value (as a tree).  If
242    the precise function being called is known, FUNC is its
243    FUNCTION_DECL; otherwise, FUNC is 0.  For m68k/SVR4 generate the
244    result in d0, a0, or fp0 as appropriate. */
245    
246 #undef FUNCTION_VALUE
247 #define FUNCTION_VALUE(VALTYPE, FUNC)                                   \
248   (TREE_CODE (VALTYPE) == REAL_TYPE && TARGET_68881                     \
249    ? gen_rtx (REG, TYPE_MODE (VALTYPE), 16)                             \
250    : (POINTER_TYPE_P (VALTYPE)                                          \
251       ? gen_rtx (REG, TYPE_MODE (VALTYPE), 8)                           \
252       : gen_rtx (REG, TYPE_MODE (VALTYPE), 0)))
253
254 /* For compatibility with the large body of existing code which does
255    not always properly declare external functions returning pointer
256    types, the m68k/SVR4 convention is to copy the value returned for
257    pointer functions from a0 to d0 in the function epilogue, so that
258    callers that have neglected to properly declare the callee can
259    still find the correct return value.  */
260
261 extern int current_function_returns_pointer;
262 #define FUNCTION_EXTRA_EPILOGUE(FILE, SIZE)                             \
263 do {                                                                    \
264   if ((current_function_returns_pointer) &&                             \
265       ! find_equiv_reg (0, get_last_insn (), 0, 0, 0, 8, Pmode))        \
266     asm_fprintf (FILE, "\tmove.l %Ra0,%Rd0\n");                         \
267 } while (0);
268
269 /* Define how to find the value returned by a library function
270    assuming the value has mode MODE.
271    For m68k/SVR4 look for integer values in d0, pointer values in d0
272    (returned in both d0 and a0), and floating values in fp0.  */
273
274 #undef LIBCALL_VALUE
275 #define LIBCALL_VALUE(MODE)                                             \
276   ((((MODE) == SFmode || (MODE) == DFmode || (MODE) == XFmode)          \
277     && TARGET_68881)                                                    \
278    ? gen_rtx (REG, (MODE), 16)                                          \
279    : gen_rtx (REG, (MODE), 0))
280
281 /* In m68k svr4, a symbol_ref rtx can be a valid PIC operand if it is
282    an operand of a function call. */
283 #undef LEGITIMATE_PIC_OPERAND_P
284 #define LEGITIMATE_PIC_OPERAND_P(X) \
285   ((! symbolic_operand (X, VOIDmode) \
286     && ! (GET_CODE (X) == CONST_DOUBLE && CONST_DOUBLE_MEM (X)  \
287           && GET_CODE (CONST_DOUBLE_MEM (X)) == MEM             \
288           && symbolic_operand (XEXP (CONST_DOUBLE_MEM (X), 0), VOIDmode))) \
289    || (GET_CODE (X) == SYMBOL_REF && SYMBOL_REF_FLAG (X)))
290
291 /* Turn off function cse if we are doing PIC. We always want function
292    call to be done as `bsr foo@PLTPC', so it will force the assembler
293    to create the PLT entry for `foo'.  Doing function cse will cause
294    the address of `foo' to be loaded into a register, which is exactly
295    what we want to avoid when we are doing PIC on svr4 m68k.  */
296 #undef SUBTARGET_OVERRIDE_OPTIONS
297 #define SUBTARGET_OVERRIDE_OPTIONS \
298   if (flag_pic) flag_no_function_cse = 1;
299
300 /* For m68k SVR4, structures are returned using the reentrant
301    technique. */
302 #undef PCC_STATIC_STRUCT_RETURN
303 #define DEFAULT_PCC_STRUCT_RETURN 0
304
305 /* Finalize the trampoline by flushing the insn cache.  */
306
307 #undef FINALIZE_TRAMPOLINE
308 #define FINALIZE_TRAMPOLINE(TRAMP)                                      \
309   emit_library_call (gen_rtx (SYMBOL_REF, Pmode, "__clear_cache"),      \
310                      0, VOIDmode, 2, TRAMP, Pmode,                      \
311                      plus_constant (TRAMP, TRAMPOLINE_SIZE), Pmode);
312
313 /* Clear the instruction cache from `beg' to `end'.  This makes an
314    inline system call to SYS_cacheflush.  The arguments are as
315    follows:
316
317         cacheflush (addr, scope, cache, len)
318
319    addr   - the start address for the flush
320    scope  - the scope of the flush (see the cpush insn)
321    cache  - which cache to flush (see the cpush insn)
322    len    - a factor relating to the number of flushes to perform:
323             len/16 lines, or len/4096 pages.  */
324
325 #define CLEAR_INSN_CACHE(BEG, END)                                      \
326 {                                                                       \
327   register unsigned long _beg __asm ("%d1") = (unsigned long) (BEG);    \
328   unsigned long _end = (unsigned long) (END);                           \
329   register unsigned long _len __asm ("%d4") = (_end - _beg + 32);       \
330   __asm __volatile                                                      \
331     ("move%.l %#123, %/d0\n\t"  /* system call nr */                    \
332      "move%.l %#1, %/d2\n\t"    /* clear lines */                       \
333      "move%.l %#3, %/d3\n\t"    /* insn+data caches */                  \
334      "trap %#0"                                                         \
335      : /* no outputs */                                                 \
336      : "d" (_beg), "d" (_len)                                           \
337      : "%d0", "%d2", "%d3");                                            \
338 }
339 \f
340 /* Output code to add DELTA to the first argument, and then jump to FUNCTION.
341    Used for C++ multiple inheritance.  */
342 #define ASM_OUTPUT_MI_THUNK(FILE, THUNK_FNDECL, DELTA, FUNCTION)        \
343 do {                                                                    \
344   if (DELTA > 0 && DELTA <= 8)                                          \
345     asm_fprintf (FILE, "\taddq.l %I%d,4(%Rsp)\n", DELTA);               \
346   else if (DELTA < 0 && DELTA >= -8)                                    \
347     asm_fprintf (FILE, "\tsubq.l %I%d,4(%Rsp)\n", -DELTA);              \
348   else                                                                  \
349     asm_fprintf (FILE, "\tadd.l %I%d,4(%Rsp)\n", DELTA);                \
350                                                                         \
351   if (flag_pic)                                                         \
352     {                                                                   \
353       fprintf (FILE, "\tbra.l ");                                       \
354       assemble_name                                                     \
355         (FILE, IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (FUNCTION)));    \
356       fprintf (FILE, "@PLTPC\n");                                       \
357     }                                                                   \
358   else                                                                  \
359     {                                                                   \
360       fprintf (FILE, "\tjmp ");                                         \
361       assemble_name                                                     \
362         (FILE, IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (FUNCTION)));    \
363       fprintf (FILE, "\n");                                             \
364     }                                                                   \
365 } while (0)