* target.h (asm_out.byte_op, asm_out.aligned_op, asm_out.unaligned_op,
[official-gcc.git] / gcc / config / m68k / m68kv4.h
blobd2bb108bd992fdb32387a4d6b43bfdcd9818d279
1 /* Target definitions for GNU compiler for mc680x0 running System V.4
2 Copyright (C) 1991, 1993, 1994, 1995, 1996, 1998, 1999, 2000
3 Free Software Foundation, Inc.
4 Contributed by Ron Guilmette (rfg@monkeys.com) and
5 Fred Fish (fnf@cygnus.com).
7 This file is part of GNU CC.
9 GNU CC is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2, or (at your option)
12 any later version.
14 GNU CC is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with GNU CC; see the file COPYING. If not, write to
21 the Free Software Foundation, 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA. */
24 /* Use SGS_* macros to control compilation in m68k.md */
26 #define SGS_SWITCH_TABLES /* Different switch table handling */
28 /* TODO: convert includes to ${tm_file} list in config.gcc. */
29 #include "m68k/sgs.h" /* The m68k/SVR4 assembler is SGS based */
31 #include "dbxelf.h"
32 #include "elfos.h"
33 #include "svr4.h" /* Pick up the generic SVR4 macros */
35 /* See m68k.h. 7 means 68020 with 68881. */
37 #ifndef TARGET_DEFAULT
38 #define TARGET_DEFAULT (MASK_BITFIELD|MASK_68881|MASK_68020)
39 #endif
41 /* Override the definition of NO_DOLLAR_IN_LABEL in svr4.h, for special
42 g++ assembler names. When this is defined, g++ uses embedded '.'
43 characters and some m68k assemblers have problems with this. The
44 chances are much greater that any particular assembler will permit
45 embedded '$' characters. */
47 #undef NO_DOLLAR_IN_LABEL
49 /* Define PCC_STATIC_STRUCT_RETURN if the convention on the target machine
50 is to use the nonreentrant technique for returning structure and union
51 values, as commonly implemented by the AT&T Portable C Compiler (PCC).
52 When defined, the gcc option -fpcc-struct-return can be used to cause
53 this form to be generated. When undefined, the option does nothing.
54 For m68k SVR4, the convention is to use a reentrant technique compatible
55 with the gcc default, so override the definition of this macro in m68k.h */
57 #undef PCC_STATIC_STRUCT_RETURN
59 /* Provide a set of pre-definitions and pre-assertions appropriate for
60 the m68k running svr4. __svr4__ is our extension. */
62 #define CPP_PREDEFINES \
63 "-Dm68k -Dunix -D__svr4__ -D__motorola__ \
64 -Asystem=unix -Asystem=svr4 -Acpu=m68k -Amachine=m68k"
66 /* Test to see if the target includes a 68881 by default, and use CPP_SPEC
67 to control whether or not __HAVE_68881__ is defined by default or not.
68 If a 68881 is the default, gcc will use inline 68881 instructions, by
69 predefining __HAVE_68881__, unless -msoft-float is specified.
70 If a 68881 is not the default, gcc will only define __HAVE_68881__ if
71 -m68881 is specified. */
73 #if TARGET_DEFAULT & MASK_68881
74 #define CPP_SPEC "%{!msoft-float:-D__HAVE_68881__}"
75 #else
76 #define CPP_SPEC "%{m68881:-D__HAVE_68881__}"
77 #endif
79 /* Output assembler code to FILE to increment profiler label # LABELNO
80 for profiling a function entry. We override the definition in m68k.h
81 and match the way the native m68k/SVR4 compiler does profiling, with the
82 address of the profile counter in a1, not a0, and using bsr rather
83 than jsr. */
85 #undef FUNCTION_PROFILER
86 #define FUNCTION_PROFILER(FILE, LABELNO) \
87 asm_fprintf ((FILE), "\tlea.l\t(%LLP%d,%Rpc),%Ra1\n\tbsr\t_mcount\n", \
88 (LABELNO))
90 /* Local common symbols are declared to the assembler with ".lcomm" rather
91 than ".bss", so override the definition in svr4.h */
92 /* ??? svr4.h no longer defines this, and this is only used by m68k/amix.h. */
94 #undef BSS_ASM_OP
95 #define BSS_ASM_OP "\t.lcomm\t"
97 /* Register in which address to store a structure value is passed to a
98 function. The default in m68k.h is a1. For m68k/SVR4 it is a0. */
100 #undef STRUCT_VALUE_REGNUM
101 #define STRUCT_VALUE_REGNUM 8
103 /* Register in which static-chain is passed to a function. The
104 default in m68k.h is a0, but that is already the struct value
105 regnum. Make it a1 instead. */
107 #undef STATIC_CHAIN_REGNUM
108 #define STATIC_CHAIN_REGNUM 9
110 #define ASM_COMMENT_START "#"
112 #undef TYPE_OPERAND_FMT
113 #define TYPE_OPERAND_FMT "@%s"
115 /* Define how the m68k registers should be numbered for Dwarf output.
116 The numbering provided here should be compatible with the native
117 SVR4 SDB debugger in the m68k/SVR4 reference port, where d0-d7
118 are 0-7, a0-a8 are 8-15, and fp0-fp7 are 16-23. */
120 #define DBX_REGISTER_NUMBER(REGNO) (REGNO)
122 /* The ASM_OUTPUT_SKIP macro is first defined in m68k.h, using ".skip".
123 It is then overridden by m68k/sgs.h to use ".space", and again by svr4.h
124 to use ".zero". The m68k/SVR4 assembler uses ".space", so repeat the
125 definition from m68k/sgs.h here. Note that ASM_NO_SKIP_IN_TEXT is
126 defined in m68k/sgs.h, so we don't have to repeat it here. */
128 #undef ASM_OUTPUT_SKIP
129 #define ASM_OUTPUT_SKIP(FILE,SIZE) \
130 fprintf (FILE, "%s%u\n", SPACE_ASM_OP, (SIZE))
132 /* 1 if N is a possible register number for a function value.
133 For m68k/SVR4 allow d0, a0, or fp0 as return registers, for integral,
134 pointer, or floating types, respectively. Reject fp0 if not using a
135 68881 coprocessor. */
137 #undef FUNCTION_VALUE_REGNO_P
138 #define FUNCTION_VALUE_REGNO_P(N) \
139 ((N) == 0 || (N) == 8 || (TARGET_68881 && (N) == 16))
141 /* Define this to be true when FUNCTION_VALUE_REGNO_P is true for
142 more than one register. */
144 #undef NEEDS_UNTYPED_CALL
145 #define NEEDS_UNTYPED_CALL 1
147 /* Define how to generate (in the callee) the output value of a function
148 and how to find (in the caller) the value returned by a function. VALTYPE
149 is the data type of the value (as a tree). If the precise function being
150 called is known, FUNC is its FUNCTION_DECL; otherwise, FUNC is 0.
151 For m68k/SVR4 generate the result in d0, a0, or fp0 as appropriate. */
153 #undef FUNCTION_VALUE
154 #define FUNCTION_VALUE(VALTYPE, FUNC) \
155 (TREE_CODE (VALTYPE) == REAL_TYPE && TARGET_68881 \
156 ? gen_rtx_REG (TYPE_MODE (VALTYPE), 16) \
157 : (POINTER_TYPE_P (VALTYPE) \
158 ? gen_rtx_REG (TYPE_MODE (VALTYPE), 8) \
159 : gen_rtx_REG (TYPE_MODE (VALTYPE), 0)))
161 /* For compatibility with the large body of existing code which does not
162 always properly declare external functions returning pointer types, the
163 m68k/SVR4 convention is to copy the value returned for pointer functions
164 from a0 to d0 in the function epilogue, so that callers that have
165 neglected to properly declare the callee can still find the correct return
166 value. */
168 #define FUNCTION_EXTRA_EPILOGUE(FILE, SIZE) \
169 do { \
170 if (current_function_returns_pointer \
171 && ! find_equiv_reg (0, get_last_insn (), 0, 0, 0, 8, Pmode)) \
172 asm_fprintf (FILE, "\tmov.l %Ra0,%Rd0\n"); \
173 } while (0);
175 /* Define how to find the value returned by a library function assuming the
176 value has mode MODE.
177 For m68k/SVR4 look for integer values in d0, pointer values in d0
178 (returned in both d0 and a0), and floating values in fp0. */
180 #undef LIBCALL_VALUE
181 #define LIBCALL_VALUE(MODE) \
182 ((((MODE) == SFmode || (MODE) == DFmode || (MODE) == XFmode) \
183 && TARGET_68881) \
184 ? gen_rtx_REG ((MODE), 16) \
185 : gen_rtx_REG ((MODE), 0))
187 /* Boundary (in *bits*) on which stack pointer should be aligned.
188 The m68k/SVR4 convention is to keep the stack pointer longword aligned. */
190 #undef STACK_BOUNDARY
191 #define STACK_BOUNDARY 32
193 /* Alignment of field after `int : 0' in a structure.
194 For m68k/SVR4, this is the next longword boundary. */
196 #undef EMPTY_FIELD_BOUNDARY
197 #define EMPTY_FIELD_BOUNDARY 32
199 /* No data type wants to be aligned rounder than this.
200 For m68k/SVR4, some types (doubles for example) are aligned on 8 byte
201 boundaries */
203 #undef BIGGEST_ALIGNMENT
204 #define BIGGEST_ALIGNMENT 64
206 /* SVR4 m68k assembler is bitching on the `comm i,1,1' which asks for
207 1 byte alignment. Don't generate alignment for COMMON seems to be
208 safer until we the assembler is fixed. */
209 #undef ASM_OUTPUT_ALIGNED_COMMON
210 /* Same problem with this one. */
211 #undef ASM_OUTPUT_ALIGNED_LOCAL
213 /* The `string' directive on m68k svr4 does not handle string with
214 escape char (ie., `\') right. Use normal way to output ASCII bytes
215 seems to be safer. */
216 #undef ASM_OUTPUT_ASCII
217 #define ASM_OUTPUT_ASCII(FILE,PTR,LEN) \
218 do { \
219 register size_t sp = 0, limit = (LEN); \
220 fputs (integer_asm_op (1, TRUE), (FILE)); \
221 do { \
222 int ch = (PTR)[sp]; \
223 if (ch > ' ' && ! (ch & 0x80) && ch != '\\') \
225 fprintf ((FILE), "'%c", ch); \
227 else \
229 fprintf ((FILE), "0x%x", ch); \
231 if (++sp < limit) \
233 if ((sp % 10) == 0) \
235 fprintf ((FILE), "\n%s", integer_asm_op (1, TRUE)); \
237 else \
239 putc (',', (FILE)); \
242 } while (sp < limit); \
243 putc ('\n', (FILE)); \
244 } while (0)
246 /* SVR4 m68k assembler is bitching on the syntax `2.b'.
247 So use the "LLDnnn-LLnnn" format. Define LLDnnn after the table. */
249 #undef ASM_OUTPUT_CASE_END
250 #define ASM_OUTPUT_CASE_END(FILE,NUM,TABLE) \
251 do { \
252 if (switch_table_difference_label_flag) \
253 asm_fprintf ((FILE), "%s%LLD%d,%LL%d\n", SET_ASM_OP, (NUM), (NUM)); \
254 switch_table_difference_label_flag = 0; \
255 } while (0)
257 int switch_table_difference_label_flag;
259 #undef ASM_OUTPUT_COMMON
260 #undef ASM_OUTPUT_LOCAL
261 #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED) \
262 ( fputs (".comm ", (FILE)), \
263 assemble_name ((FILE), (NAME)), \
264 fprintf ((FILE), ",%u\n", (SIZE)))
266 #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED) \
267 ( fputs (".lcomm ", (FILE)), \
268 assemble_name ((FILE), (NAME)), \
269 fprintf ((FILE), ",%u\n", (SIZE)))
271 /* Override the definition in svr4.h. In m68k svr4, using swbeg is the
272 standard way to do switch table. */
273 #undef ASM_OUTPUT_BEFORE_CASE_LABEL
274 #define ASM_OUTPUT_BEFORE_CASE_LABEL(FILE,PREFIX,NUM,TABLE) \
275 fprintf ((FILE), "%s&%d\n", SWBEG_ASM_OP, XVECLEN (PATTERN (TABLE), 1));
277 /* In m68k svr4, a symbol_ref rtx can be a valid PIC operand if it is an
278 operand of a function call. */
279 #undef LEGITIMATE_PIC_OPERAND_P
280 #define LEGITIMATE_PIC_OPERAND_P(X) \
281 ((! symbolic_operand (X, VOIDmode) \
282 && ! (GET_CODE (X) == CONST_DOUBLE && mem_for_const_double (X) != 0 \
283 && GET_CODE (mem_for_const_double (X)) == MEM \
284 && symbolic_operand (XEXP (mem_for_const_double (X), 0), \
285 VOIDmode))) \
286 || (GET_CODE (X) == SYMBOL_REF && SYMBOL_REF_FLAG (X)) \
287 || PCREL_GENERAL_OPERAND_OK)
289 /* Turn off function cse if we are doing PIC. We always want function call
290 to be done as `bsr foo@PLTPC', so it will force the assembler to create
291 the PLT entry for `foo'. Doing function cse will cause the address of `foo'
292 to be loaded into a register, which is exactly what we want to avoid when
293 we are doing PIC on svr4 m68k. */
294 #undef OVERRIDE_OPTIONS
295 #define OVERRIDE_OPTIONS \
297 if (flag_pic) flag_no_function_cse = 1; \
298 if (! TARGET_68020 && flag_pic == 2) \
299 error("-fPIC is not currently supported on the 68000 or 68010\n"); \
302 /* Output assembler code for a block containing the constant parts
303 of a trampoline, leaving space for the variable parts. */
305 /* On m68k svr4, the trampoline is different from the generic version
306 in that we use a1 as the static call chain. */
308 #undef TRAMPOLINE_TEMPLATE
309 #define TRAMPOLINE_TEMPLATE(FILE) \
311 assemble_aligned_integer (2, GEN_INT (0x227a)); \
312 assemble_aligned_integer (2, GEN_INT (8)); \
313 assemble_aligned_integer (2, GEN_INT (0x2f3a)); \
314 assemble_aligned_integer (2, GEN_INT (8)); \
315 assemble_aligned_integer (2, GEN_INT (0x4e75)); \
316 assemble_aligned_integer (4, const0_rtx); \
317 assemble_aligned_integer (4, const0_rtx); \
320 /* Redefine since we are using a different trampoline */
321 #undef TRAMPOLINE_SIZE
322 #define TRAMPOLINE_SIZE 18
324 /* Emit RTL insns to initialize the variable parts of a trampoline.
325 FNADDR is an RTX for the address of the function's pure code.
326 CXT is an RTX for the static chain value for the function. */
328 #undef INITIALIZE_TRAMPOLINE
329 #define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) \
331 emit_move_insn (gen_rtx_MEM (SImode, plus_constant (TRAMP, 10)), CXT); \
332 emit_move_insn (gen_rtx_MEM (SImode, plus_constant (TRAMP, 14)), FNADDR); \