OSDN Git Service

(ASM_OUTPUT_ASCII): Wrap in `do { ... } while (0)'.
[pf3gnuchains/gcc-fork.git] / gcc / config / m68k / m68kv4.h
1 /* Target definitions for GNU compiler for mc680x0 running System V.4
2    Copyright (C) 1991, 1993 Free Software Foundation, Inc.
3
4    Written by Ron Guilmette (rfg@ncd.com) and Fred Fish (fnf@cygnus.com).
5
6 This file is part of GNU CC.
7
8 GNU CC 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 GNU CC 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 GNU CC; see the file COPYING.  If not, write to
20 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
21
22 /* Use SGS_* macros to control compilation in m68k.md */
23
24 #define SGS_SWITCH_TABLES       /* Different switch table handling */
25
26 #include "m68k/sgs.h"           /* The m68k/SVR4 assembler is SGS based */
27 #include "svr4.h"               /* Pick up the generic SVR4 macros */
28
29 /* See m68k.h.  7 means 68020 with 68881.  */
30
31 #ifndef TARGET_DEFAULT
32 #define TARGET_DEFAULT (5 /*68020*/ + 2 /*68881*/)
33 #endif
34
35 /*  Override the definition of NO_DOLLAR_IN_LABEL in svr4.h, for special
36     g++ assembler names.  When this is defined, g++ uses embedded '.'
37     characters and some m68k assemblers have problems with this.  The
38     chances are much greater that any particular assembler will permit
39     embedded '$' characters. */
40
41 #undef NO_DOLLAR_IN_LABEL
42
43 /* Define PCC_STATIC_STRUCT_RETURN if the convention on the target machine
44    is to use the nonreentrant technique for returning structure and union
45    values, as commonly implemented by the AT&T Portable C Compiler (PCC).
46    When defined, the gcc option -fpcc-struct-return can be used to cause
47    this form to be generated.  When undefined, the option does nothing.
48    For m68k SVR4, the convention is to use a reentrant technique compatible
49    with the gcc default, so override the definition of this macro in m68k.h */
50
51 #undef PCC_STATIC_STRUCT_RETURN
52
53 /* Provide a set of pre-definitions and pre-assertions appropriate for
54    the m68k running svr4.  __svr4__ is our extension.  */
55
56 #define CPP_PREDEFINES \
57   "-Dm68k -Dunix -D__svr4__ -D__motorola__ \
58  -Asystem(unix) -Asystem(svr4) -Acpu(m68k) -Amachine(m68k)"
59
60 /* Test to see if the target includes a 68881 by default, and use CPP_SPEC
61    to control whether or not __HAVE_68881__ is defined by default or not.
62    If a 68881 is the default, gcc will use inline 68881 instructions, by
63    predefining __HAVE_68881__, unless -msoft-float is specified.
64    If a 68881 is not the default, gcc will only define __HAVE_68881__ if
65    -m68881 is specified. */
66
67 #if TARGET_DEFAULT & 2
68 #define CPP_SPEC "%{!msoft-float:-D__HAVE_68881__}"
69 #else
70 #define CPP_SPEC "%{m68881:-D__HAVE_68881__}"
71 #endif
72
73 /* Output assembler code to FILE to increment profiler label # LABELNO
74    for profiling a function entry.  We override the definition in m68k.h
75    and match the way the native m68k/SVR4 compiler does profiling, with the
76    address of the profile counter in a1, not a0, and using bsr rather
77    than jsr. */
78
79 #undef FUNCTION_PROFILER
80 #define FUNCTION_PROFILER(FILE, LABELNO)                                \
81   asm_fprintf ((FILE), "\tlea.l\t(%LLP%d,%Rpc),%Ra1\n\tbsr\t_mcount\n", \
82                (LABELNO))
83
84 /* Local common symbols are declared to the assembler with ".lcomm" rather
85    than ".bss", so override the definition in svr4.h */
86
87 #undef BSS_ASM_OP
88 #define BSS_ASM_OP      ".lcomm"
89
90 /* Register in which address to store a structure value is passed to a
91    function.  The default in m68k.h is a1.  For m68k/SVR4 it is a0. */
92
93 #undef STRUCT_VALUE_REGNUM
94 #define STRUCT_VALUE_REGNUM 8
95
96 #define ASM_COMMENT_START "#"
97
98 #undef TYPE_OPERAND_FMT
99 #define TYPE_OPERAND_FMT      "@%s"
100
101 /* Define how the m68k registers should be numbered for Dwarf output.
102    The numbering provided here should be compatible with the native
103    SVR4 SDB debugger in the m68k/SVR4 reference port, where d0-d7
104    are 0-7, a0-a8 are 8-15, and fp0-fp7 are 16-23. */
105
106 #define DBX_REGISTER_NUMBER(REGNO) (REGNO)
107
108 /* The ASM_OUTPUT_SKIP macro is first defined in m68k.h, using ".skip".
109    It is then overridden by m68k/sgs.h to use ".space", and again by svr4.h
110    to use ".zero".  The m68k/SVR4 assembler uses ".space", so repeat the
111    definition from m68k/sgs.h here.  Note that ASM_NO_SKIP_IN_TEXT is
112    defined in m68k/sgs.h, so we don't have to repeat it here. */
113
114 #undef ASM_OUTPUT_SKIP
115 #define ASM_OUTPUT_SKIP(FILE,SIZE)  \
116   fprintf (FILE, "\t%s %u\n", SPACE_ASM_OP, (SIZE))
117
118 /* 1 if N is a possible register number for a function value.
119    For m68k/SVR4 allow d0, a0, or fp0 as return registers, for integral,
120    pointer, or floating types, respectively. Reject fp0 if not using a
121    68881 coprocessor. */
122
123 #undef FUNCTION_VALUE_REGNO_P
124 #define FUNCTION_VALUE_REGNO_P(N) \
125   ((N) == 0 || (N) == 8 || (TARGET_68881 && (N) == 16))
126
127 /* Define this to be true when FUNCTION_VALUE_REGNO_P is true for
128    more than one register.  */
129
130 #undef NEEDS_UNTYPED_CALL
131 #define NEEDS_UNTYPED_CALL 1
132
133 /* Define how to generate (in the callee) the output value of a function
134    and how to find (in the caller) the value returned by a function.  VALTYPE
135    is the data type of the value (as a tree).  If the precise function being
136    called is known, FUNC is its FUNCTION_DECL; otherwise, FUNC is 0.
137    For m68k/SVR4 generate the result in d0, a0, or fp0 as appropriate. */
138    
139 #undef FUNCTION_VALUE
140 #define FUNCTION_VALUE(VALTYPE, FUNC)                                   \
141   (TREE_CODE (VALTYPE) == REAL_TYPE && TARGET_68881                     \
142    ? gen_rtx (REG, TYPE_MODE (VALTYPE), 16)                             \
143    : (TREE_CODE (VALTYPE) == POINTER_TYPE                               \
144       ? gen_rtx (REG, TYPE_MODE (VALTYPE), 8)                           \
145       : gen_rtx (REG, TYPE_MODE (VALTYPE), 0)))
146
147 /* For compatibility with the large body of existing code which does not
148    always properly declare external functions returning pointer types, the
149    m68k/SVR4 convention is to copy the value returned for pointer functions
150    from a0 to d0 in the function epilogue, so that callers that have
151    neglected to properly declare the callee can still find the correct return
152    value. */
153
154 extern int current_function_returns_pointer;
155 #define FUNCTION_EXTRA_EPILOGUE(FILE, SIZE)                             \
156 do {                                                                    \
157   if ((current_function_returns_pointer) &&                             \
158       ! find_equiv_reg (0, get_last_insn (), 0, 0, 0, 8, Pmode))        \
159     asm_fprintf (FILE, "\tmov.l %Ra0,%Rd0\n");                          \
160 } while (0);
161
162 /* Define how to find the value returned by a library function assuming the
163    value has mode MODE.
164    For m68k/SVR4 look for integer values in d0, pointer values in d0
165    (returned in both d0 and a0), and floating values in fp0. */
166
167 #undef LIBCALL_VALUE
168 #define LIBCALL_VALUE(MODE)                                             \
169   (((MODE) == SFmode || (MODE) == DFmode) && TARGET_68881               \
170    ? gen_rtx (REG, (MODE), 16)                                          \
171    : gen_rtx (REG, (MODE), 0))
172
173 /* Boundary (in *bits*) on which stack pointer should be aligned.
174    The m68k/SVR4 convention is to keep the stack pointer longword aligned. */
175  
176 #undef STACK_BOUNDARY
177 #define STACK_BOUNDARY 32
178
179 /* Alignment of field after `int : 0' in a structure.
180    For m68k/SVR4, this is the next longword boundary. */
181
182 #undef EMPTY_FIELD_BOUNDARY
183 #define EMPTY_FIELD_BOUNDARY 32
184
185 /* No data type wants to be aligned rounder than this.
186    For m68k/SVR4, some types (doubles for example) are aligned on 8 byte
187    boundaries */
188         
189 #undef BIGGEST_ALIGNMENT
190 #define BIGGEST_ALIGNMENT 64
191
192 /* SVR4 m68k assembler is bitching on the `comm i,1,1' which askes for 
193    1 byte alignment. Don't generate alignment for COMMON seems to be
194    safer until we the assembler is fixed. */
195 #undef ASM_OUTPUT_ALIGNED_COMMON
196 /* Same problem with this one.  */
197 #undef ASM_OUTPUT_ALIGNED_LOCAL
198
199 /* The `string' directive on m68k svr4 does not handle string with
200    escape char (ie., `\') right. Use normal way to output ASCII bytes
201    seems to be safer. */
202 #undef ASM_OUTPUT_ASCII
203 #define ASM_OUTPUT_ASCII(FILE,PTR,LEN)                          \
204 do {                                                            \
205   register int sp = 0, lp = 0, ch;                              \
206   fprintf ((FILE), "\t%s ", BYTE_ASM_OP);                       \
207   do {                                                          \
208     ch = (PTR)[sp];                                             \
209     if (ch > ' ' && ! (ch & 0x80) && ch != '\\')                \
210       {                                                         \
211         fprintf ((FILE), "'%c", ch);                            \
212       }                                                         \
213     else                                                        \
214       {                                                         \
215         fprintf ((FILE), "0x%x", ch);                           \
216       }                                                         \
217     if (++sp < (LEN))                                           \
218       {                                                         \
219         if ((sp % 10) == 0)                                     \
220           {                                                     \
221             fprintf ((FILE), "\n\t%s ", BYTE_ASM_OP);           \
222           }                                                     \
223         else                                                    \
224           {                                                     \
225             putc (',', (FILE));                                 \
226           }                                                     \
227       }                                                         \
228   } while (sp < (LEN));                                         \
229   putc ('\n', (FILE));                                          \
230 } while (0)
231
232 /* SVR4 m68k assembler is bitching on the syntax `2.b'.
233    So use the "LLDnnn-LLnnn" format.  Define LLDnnn after the table.  */
234
235 #undef ASM_OUTPUT_CASE_END
236 #define ASM_OUTPUT_CASE_END(FILE,NUM,TABLE)                             \
237 do {                                                                    \
238   if (switch_table_difference_label_flag)                               \
239     asm_fprintf ((FILE), "\t%s %LLD%d,%LL%d\n", SET_ASM_OP, (NUM), (NUM));\
240   switch_table_difference_label_flag = 0;                               \
241 } while (0)
242
243 int switch_table_difference_label_flag;
244
245 #undef ASM_OUTPUT_COMMON
246 #undef ASM_OUTPUT_LOCAL
247 #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED)  \
248 ( fputs (".comm ", (FILE)),                     \
249   assemble_name ((FILE), (NAME)),               \
250   fprintf ((FILE), ",%u\n", (SIZE)))
251
252 #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED)  \
253 ( fputs (".lcomm ", (FILE)),                    \
254   assemble_name ((FILE), (NAME)),               \
255   fprintf ((FILE), ",%u\n", (SIZE)))
256
257 /* Override the definition in svr4.h. In m68k svr4, using swbeg is the 
258    standard way to do switch table. */
259 #undef ASM_OUTPUT_BEFORE_CASE_LABEL
260 #define ASM_OUTPUT_BEFORE_CASE_LABEL(FILE,PREFIX,NUM,TABLE)             \
261   fprintf ((FILE), "\t%s &%d\n", SWBEG_ASM_OP, XVECLEN (PATTERN (TABLE), 1));
262
263 /* In m68k svr4, a symbol_ref rtx can be a valid PIC operand if it is an
264    operand of a function call. */
265 #undef LEGITIMATE_PIC_OPERAND_P
266 #define LEGITIMATE_PIC_OPERAND_P(X) \
267   (! symbolic_operand (X, VOIDmode) \
268    || ((GET_CODE(X) == SYMBOL_REF) && SYMBOL_REF_FLAG(X)))
269
270 /* Turn off function cse if we are doing PIC. We always want function call
271    to be done as `bsr foo@PLTPC', so it will force the assembler to create 
272    the PLT entry for `foo'. Doing function cse will cause the address of `foo'
273    to be loaded into a register, which is exactly what we want to avoid when
274    we are doing PIC on svr4 m68k. */
275 #undef OVERRIDE_OPTIONS
276 #define OVERRIDE_OPTIONS                \
277 {                                       \
278   if (flag_pic) flag_no_function_cse = 1; \
279   if (! TARGET_68020 && flag_pic == 2)  \
280     error("-fPIC is not currently supported on the 68000 or 68010\n");  \
281 }