OSDN Git Service

25f2c383c0ad25d2371e06d4241406802079bc80
[pf3gnuchains/gcc-fork.git] / gcc / config / m68k / m68kelf.h
1 /* m68kelf support, derived from m68kv4.h */
2
3 /* Target definitions for GNU compiler for mc680x0 running System V.4
4    Copyright (C) 1991, 1993 Free Software Foundation, Inc.
5
6    Written by Ron Guilmette (rfg@netcom.com) and Fred Fish (fnf@cygnus.com).
7
8 This file is part of GNU CC.
9
10 GNU CC is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2, or (at your option)
13 any later version.
14
15 GNU CC is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with GNU CC; see the file COPYING.  If not, write to
22 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
23
24 /* #notinclude "m68k/sgs.h"     /* The m68k/SVR4 assembler is SGS based */
25
26 /* These are necessary for -fpic/-fPIC to work correctly.  */
27 #ifndef MOTOROLA
28 #define MOTOROLA                /* Use MOTOROLA syntax.  */
29 #endif
30 #ifdef  USE_GAS  /* when present, forces jsbr instead of jsr.  */
31 #undef  USE_GAS
32 #endif
33
34 #ifndef SWBEG_ASM_OP
35 #define SWBEG_ASM_OP ".swbeg"
36 #endif
37
38 /* Here are four prefixes that are used by asm_fprintf to
39    facilitate customization for alternate assembler syntaxes.
40    Machines with no likelihood of an alternate syntax need not
41    define these and need not use asm_fprintf.  */
42
43 /* The prefix for register names.  Note that REGISTER_NAMES
44    is supposed to include this prefix. Also note that this is NOT an
45    fprintf format string, it is a literal string */
46
47 #undef REGISTER_PREFIX
48 #define REGISTER_PREFIX "%"
49
50 /* The prefix for local (compiler generated) labels.
51    These labels will not appear in the symbol table. */
52
53 #undef LOCAL_LABEL_PREFIX
54 #define LOCAL_LABEL_PREFIX "."
55
56 /* The prefix to add to user-visible assembler symbols. */
57
58 #undef USER_LABEL_PREFIX
59 #define USER_LABEL_PREFIX ""
60
61 /* The prefix for immediate operands.  */
62
63 #undef  IMMEDIATE_PREFIX
64 #define IMMEDIATE_PREFIX "#"
65
66 /* In the machine description we can't use %R, because it will not be seen
67    by ASM_FPRINTF.  (Isn't that a design bug?).  */
68
69 #undef REGISTER_PREFIX_MD
70 #define REGISTER_PREFIX_MD "%%"
71
72 /* config/m68k.md has an explicit reference to the program counter,
73    prefix this by the register prefix.  */
74
75 #define ASM_RETURN_CASE_JUMP    return "jmp %%pc@(2,%0:w)"
76
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 
80    in m68k.h.  */
81
82 #undef REGISTER_NAMES
83
84 #define REGISTER_NAMES \
85 {"%d0",   "%d1",   "%d2",   "%d3",   "%d4",   "%d5",   "%d6",   "%d7",       \
86  "%a0",   "%a1",   "%a2",   "%a3",   "%a4",   "%a5",   "%a6",   "%sp",       \
87  "%fp0",  "%fp1",  "%fp2",  "%fp3",  "%fp4",  "%fp5",  "%fp6",  "%fp7" }
88
89 /* This is how to output an assembler line that says to advance the
90    location counter to a multiple of 2**LOG bytes.  */
91
92 #undef ASM_OUTPUT_ALIGN
93 #define ASM_OUTPUT_ALIGN(FILE,LOG)                              \
94   if ((LOG) > 0)                                                \
95     fprintf ((FILE), "\t%s \t%u\n", ALIGN_ASM_OP, 1 << (LOG));  \
96   else if ((LOG) > 31)                                          \
97     abort ();
98
99 /* Use proper assembler syntax for these macros.  */
100 #undef ASM_OUTPUT_REG_PUSH
101 #define ASM_OUTPUT_REG_PUSH(FILE,REGNO)  \
102   asm_fprintf (FILE, "\t%Omove.l %s,-(%Rsp)\n", reg_names[REGNO])
103
104 #undef ASM_OUTPUT_REG_POP
105 #define ASM_OUTPUT_REG_POP(FILE,REGNO)  \
106   asm_fprintf (FILE, "\t%Omove.l (%Rsp)+,%s\n", reg_names[REGNO])
107
108 /*  Override the definition of NO_DOLLAR_IN_LABEL in svr4.h, for special
109     g++ assembler names.  When this is defined, g++ uses embedded '.'
110     characters and some m68k assemblers have problems with this.  The
111     chances are much greater that any particular assembler will permit
112     embedded '$' characters. */
113
114 #undef NO_DOLLAR_IN_LABEL
115
116 /* Define PCC_STATIC_STRUCT_RETURN if the convention on the target machine
117    is to use the nonreentrant technique for returning structure and union
118    values, as commonly implemented by the AT&T Portable C Compiler (PCC).
119    When defined, the gcc option -fpcc-struct-return can be used to cause
120    this form to be generated.  When undefined, the option does nothing.
121    For m68k SVR4, the convention is to use a reentrant technique compatible
122    with the gcc default, so override the definition of this macro in m68k.h */
123
124 #undef PCC_STATIC_STRUCT_RETURN
125
126 /* Local common symbols are declared to the assembler with ".lcomm" rather
127    than ".bss", so override the definition in svr4.h */
128
129 #undef BSS_ASM_OP
130 #define BSS_ASM_OP      ".lcomm"
131
132 /* Register in which address to store a structure value is passed to a
133    function.  The default in m68k.h is a1.  For m68k/SVR4 it is a0. */
134
135 #undef STRUCT_VALUE_REGNUM
136 #define STRUCT_VALUE_REGNUM 8
137
138 #define ASM_COMMENT_START "|"
139
140 #undef TYPE_OPERAND_FMT
141 #define TYPE_OPERAND_FMT      "@%s"
142
143 /* Define how the m68k registers should be numbered for Dwarf output.
144    The numbering provided here should be compatible with the native
145    SVR4 SDB debugger in the m68k/SVR4 reference port, where d0-d7
146    are 0-7, a0-a8 are 8-15, and fp0-fp7 are 16-23. */
147
148 #undef DBX_REGISTER_NUMBER
149 #define DBX_REGISTER_NUMBER(REGNO) (REGNO)
150
151 /* The ASM_OUTPUT_SKIP macro is first defined in m68k.h, using ".skip".
152    It is then overridden by m68k/sgs.h to use ".space", and again by svr4.h
153    to use ".zero".  The m68k/SVR4 assembler uses ".space", so repeat the
154    definition from m68k/sgs.h here.  Note that ASM_NO_SKIP_IN_TEXT is
155    defined in m68k/sgs.h, so we don't have to repeat it here. */
156
157 #undef ASM_OUTPUT_SKIP
158 #define ASM_OUTPUT_SKIP(FILE,SIZE)  \
159   fprintf (FILE, "\t%s %u\n", SPACE_ASM_OP, (SIZE))
160
161 #if 0
162 /* SVR4 m68k assembler is bitching on the `comm i,1,1' which askes for 
163    1 byte alignment. Don't generate alignment for COMMON seems to be
164    safer until we the assembler is fixed. */
165 #undef ASM_OUTPUT_ALIGNED_COMMON
166 /* Same problem with this one.  */
167 #undef ASM_OUTPUT_ALIGNED_LOCAL
168 #endif
169
170 /* The `string' directive on m68k svr4 does not handle string with
171    escape char (ie., `\') right. Use normal way to output ASCII bytes
172    seems to be safer. */
173 #undef ASM_OUTPUT_ASCII
174 #define ASM_OUTPUT_ASCII(FILE,PTR,LEN)                          \
175 do {                                                            \
176   register int sp = 0, lp = 0, ch;                              \
177   fprintf ((FILE), "\t%s ", BYTE_ASM_OP);                       \
178   do {                                                          \
179     ch = (PTR)[sp];                                             \
180     if (ch > ' ' && ! (ch & 0x80) && ch != '\\')                \
181       {                                                         \
182         fprintf ((FILE), "'%c", ch);                            \
183       }                                                         \
184     else                                                        \
185       {                                                         \
186         fprintf ((FILE), "0x%x", ch);                           \
187       }                                                         \
188     if (++sp < (LEN))                                           \
189       {                                                         \
190         if ((sp % 10) == 0)                                     \
191           {                                                     \
192             fprintf ((FILE), "\n\t%s ", BYTE_ASM_OP);           \
193           }                                                     \
194         else                                                    \
195           {                                                     \
196             putc (',', (FILE));                                 \
197           }                                                     \
198       }                                                         \
199   } while (sp < (LEN));                                         \
200   putc ('\n', (FILE));                                          \
201 } while (0)
202
203 /* SVR4 m68k assembler is bitching on the syntax `2.b'.
204    So use the "LLDnnn-LLnnn" format.  Define LLDnnn after the table.  */
205
206 #undef ASM_OUTPUT_CASE_END
207 #define ASM_OUTPUT_CASE_END(FILE,NUM,TABLE)                             \
208 do {                                                                    \
209   if (switch_table_difference_label_flag)                               \
210     asm_fprintf ((FILE), "\t%s %LLD%d,%LL%d\n", SET_ASM_OP, (NUM), (NUM));\
211   switch_table_difference_label_flag = 0;                               \
212 } while (0)
213
214 extern int switch_table_difference_label_flag;
215
216 #undef ASM_OUTPUT_COMMON
217 #undef ASM_OUTPUT_LOCAL
218 #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED)  \
219 ( fputs (".comm ", (FILE)),                     \
220   assemble_name ((FILE), (NAME)),               \
221   fprintf ((FILE), ",%u\n", (SIZE)))
222
223 #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED)  \
224 ( fputs (".lcomm ", (FILE)),                    \
225   assemble_name ((FILE), (NAME)),               \
226   fprintf ((FILE), ",%u\n", (SIZE)))
227
228 /* Currently, JUMP_TABLES_IN_TEXT_SECTION must be defined in order to
229    keep switch tables in the text section. */
230    
231 #define JUMP_TABLES_IN_TEXT_SECTION 1
232
233 /* Override the definition in svr4.h. In m68k svr4, using swbeg is the 
234    standard way to do switch table. */
235 #undef ASM_OUTPUT_BEFORE_CASE_LABEL
236 #define ASM_OUTPUT_BEFORE_CASE_LABEL(FILE,PREFIX,NUM,TABLE)             \
237   fprintf ((FILE), "\t%s &%d\n", SWBEG_ASM_OP, XVECLEN (PATTERN (TABLE), 1));
238
239 /* In m68k svr4, a symbol_ref rtx can be a valid PIC operand if it is an
240    operand of a function call. */
241 #undef LEGITIMATE_PIC_OPERAND_P
242 #define LEGITIMATE_PIC_OPERAND_P(X) \
243   (! symbolic_operand (X, VOIDmode) \
244    || ((GET_CODE(X) == SYMBOL_REF) && SYMBOL_REF_FLAG(X)))
245
246 /* Turn off function cse if we are doing PIC. We always want function call
247    to be done as `bsr foo@PLTPC', so it will force the assembler to create 
248    the PLT entry for `foo'. Doing function cse will cause the address of `foo'
249    to be loaded into a register, which is exactly what we want to avoid when
250    we are doing PIC on svr4 m68k. */
251 #undef OVERRIDE_OPTIONS
252 #define OVERRIDE_OPTIONS                \
253 {                                       \
254   if (flag_pic) flag_no_function_cse = 1; \
255   if (! TARGET_68020 && flag_pic == 2)  \
256     error("-fPIC is not currently supported on the 68000 or 68010\n");  \
257 }
258 /* end of stuff from m68kv4.h */
259
260 #undef SGS_CMP_ORDER
261
262 #undef ENDFILE_SPEC
263 #define ENDFILE_SPEC "crtend.o%s"
264
265 #undef  STARTFILE_SPEC
266 #define STARTFILE_SPEC "crtbegin.o%s"