1 /* Configuration file for an m68k OpenBSD target.
2    Copyright (C) 1999 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 2, 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 __HAVE_68881__ in preprocessor, unless -msoft-float is specified.
22    This will control the use of inline 68881 insns in certain macros.  */
23 #undef CPP_SPEC
24 #define CPP_SPEC "%{!msoft-float:-D__HAVE_68881__ -D__HAVE_FPU__} " \
25 		 OBSD_CPP_SPEC
26 
27 /* Run-time target specifications.  */
28 #define TARGET_OS_CPP_BUILTINS()			\
29   do							\
30     {							\
31       OPENBSD_OS_CPP_BUILTINS_ELF();			\
32       builtin_define ("__m68k__");			\
33       builtin_define ("__SVR4_ABI__");			\
34       builtin_define ("__motorola__");			\
35       builtin_define ("__mc68000__");			\
36       builtin_define ("__mc68020__");			\
37     }							\
38   while (0)
39 
40 /* m68k as needs to know about the processor subtype.  */
41 #undef ASM_SPEC
42 #define ASM_SPEC "%| %{m68030} %{m68040} %{m68060} %{fpic:-k} %{fPIC:-k -K}"
43 
44 #undef LINK_SPEC
45 #define LINK_SPEC \
46   "%{!shared:%{!nostdlib:%{!r*:%{!e*:-e __start}}}} \
47    %{shared:-shared} %{R*} \
48    %{static:-Bstatic} \
49    %{!static:-Bdynamic} \
50    %{assert*} \
51    %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.so}"
52 
53 /* As an elf system, we need crtbegin/crtend stuff.  */
54 #undef STARTFILE_SPEC
55 #define STARTFILE_SPEC "\
56         %{!shared: %{pg:gcrt0%O%s} %{!pg:%{p:gcrt0%O%s} %{!p:crt0%O%s}} \
57         crtbegin%O%s} %{shared:crtbeginS%O%s}"
58 #undef ENDFILE_SPEC
59 #define ENDFILE_SPEC "%{!shared:crtend%O%s} %{shared:crtendS%O%s}"
60 
61 /* Layout of source language data types.  */
62 
63 /* This must agree with <machine/_types.h> */
64 #undef SIZE_TYPE
65 #define SIZE_TYPE "long unsigned int"
66 
67 #undef PTRDIFF_TYPE
68 #define PTRDIFF_TYPE "long int"
69 
70 #undef INTMAX_TYPE
71 #define INTMAX_TYPE "long long int"
72 
73 #undef UINTMAX_TYPE
74 #define UINTMAX_TYPE "long long unsigned int"
75 
76 #undef WCHAR_TYPE
77 #define WCHAR_TYPE "int"
78 
79 #undef WCHAR_TYPE_SIZE
80 #define WCHAR_TYPE_SIZE 32
81 
82 
83 #undef FUNCTION_PROFILER
84 #define FUNCTION_PROFILER(FILE, LABELNO)				\
85 do									\
86   {									\
87     asm_fprintf (FILE, "\tlea (%LLP%d,%Rpc),%Ra1\n", (LABELNO));	\
88     if (flag_pic)							\
89       fprintf (FILE, "\tbsr.l __mcount@PLTPC\n");			\
90     else								\
91       fprintf (FILE, "\tjbsr __mcount\n");				\
92   }									\
93 while (0)
94 
95 /* The prefix for register names.  Note that REGISTER_NAMES
96    is supposed to include this prefix.  Also note that this is NOT an
97    fprintf format string, it is a literal string.  */
98 
99 #undef REGISTER_PREFIX
100 #define REGISTER_PREFIX "%"
101 
102 
103 /* The prefix for local (compiler generated) lables.
104    These labels will not appear in the symbol table.  */
105 
106 #undef LOCAL_LABEL_PREFIX
107 #define LOCAL_LABEL_PREFIX "."
108 
109 
110 /* The prefix to add to user-visible assembler symbols.  */
111 
112 #undef USER_LABEL_PREFIX
113 #define USER_LABEL_PREFIX ""
114 
115 
116 /* The prefix for immediate operands.  */
117 
118 #undef IMMEDIATE_PREFIX
119 #define IMMEDIATE_PREFIX "#"
120 
121 
122 #undef ASM_COMMENT_START
123 #define ASM_COMMENT_START "|"
124 
125 
126 /* How to refer to registers in assembler output.
127    This sequence is indexed by compiler's hard-register-number.
128    Motorola format uses different register names than defined in m68k.h.
129    We also take this chance to convert 'a6' to 'fp' */
130 
131 #undef REGISTER_NAMES
132 
133 #ifndef SUPPORT_SUN_FPA
134 
135 #define REGISTER_NAMES							\
136 {"%d0",   "%d1",   "%d2",   "%d3",   "%d4",   "%d5",   "%d6",   "%d7",	\
137  "%a0",   "%a1",   "%a2",   "%a3",   "%a4",   "%a5",   "%fp",   "%sp",	\
138  "%fp0",  "%fp1",  "%fp2",  "%fp3",  "%fp4",  "%fp5",  "%fp6",  "%fp7" }
139 
140 #else /* SUPPORT_SUN_FPA */
141 
142 #define REGISTER_NAMES							\
143 {"%d0",   "%d1",   "%d2",   "%d3",   "%d4",   "%d5",   "%d6",   "%d7",	\
144  "%a0",   "%a1",   "%a2",   "%a3",   "%a4",   "%a5",   "%fp",   "%sp",	\
145  "%fp0",  "%fp1",  "%fp2",  "%fp3",  "%fp4",  "%fp5",  "%fp6",  "%fp7",	\
146  "%fpa0", "%fpa1", "%fpa2", "%fpa3", "%fpa4", "%fpa5", "%fpa6","%fpa7",	\
147  "%fpa8", "%fpa9", "%fpa10","%fpa11","%fpa12","%fpa13","%fpa14","%fpa15", \
148  "%fpa16","%fpa17","%fpa18","%fpa19","%fpa20","%fpa21","%fpa22","%fpa23", \
149  "%fpa24","%fpa25","%fpa26","%fpa27","%fpa28","%fpa29","%fpa30","%fpa31" }
150 
151 #endif /* ! SUPPORT_SUN_FPA */
152 
153 
154 /* Currently, JUMP_TABLES_IN_TEXT_SECTION must be defined in order to
155    keep switch tables in the text section.  */
156 
157 #undef JUMP_TABLES_IN_TEXT_SECTION
158 #define JUMP_TABLES_IN_TEXT_SECTION 1
159 
160 
161 /* Use the default action for outputting the case label.  */
162 #undef ASM_OUTPUT_CASE_LABEL
163 #define ASM_RETURN_CASE_JUMP				\
164   do {							\
165     if (TARGET_5200)					\
166       {							\
167 	if (ADDRESS_REG_P (operands[0]))		\
168 	  return "jmp %%pc@(2,%0:l)";			\
169 	else						\
170 	  return "ext%.l %0\n\tjmp %%pc@(2,%0:l)";	\
171       }							\
172     else						\
173       return "jmp %%pc@(2,%0:w)";			\
174   } while (0)
175 
176 
177 /* This is how to output an assembler line that says to advance the
178    location counter to a multiple of 2**LOG bytes.  */
179 
180 #undef ASM_OUTPUT_ALIGN
181 #define ASM_OUTPUT_ALIGN(FILE,LOG)					\
182 do									\
183   {									\
184     if ((LOG) > 0)							\
185       fprintf ((FILE), "%s%u\n", ALIGN_ASM_OP, 1 << (LOG));		\
186   }									\
187 while (0)
188 
189 
190 /* If defined, a C expression whose value is a string containing the
191    assembler operation to identify the following data as uninitialized global
192    data.  */
193 
194 #define BSS_SECTION_ASM_OP	".section\t.bss"
195 
196 
197 /* Like `ASM_OUTPUT_BSS' except takes the required alignment as a
198    separate, explicit argument.  If you define this macro, it is used
199    in place of `ASM_OUTPUT_BSS', and gives you more flexibility in
200    handling the required alignment of the variable.  The alignment is
201    specified as the number of bits.
202 
203    Try to use function `asm_output_aligned_bss' defined in file
204    `varasm.c' when defining this macro.  */
205 
206 #undef ASM_OUTPUT_ALIGNED_BSS
207 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN)		\
208   asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
209 
210 
211 #undef ASM_OUTPUT_COMMON
212 #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED)			\
213 ( fputs (".comm ", (FILE)),						\
214   assemble_name ((FILE), (NAME)),					\
215   fprintf ((FILE), ",%u\n", (SIZE)))
216 
217 #undef ASM_OUTPUT_LOCAL
218 #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED)			\
219 ( fputs (".lcomm ", (FILE)),						\
220   assemble_name ((FILE), (NAME)),					\
221   fprintf ((FILE), ",%u\n", (SIZE)))
222 
223 
224 /* XXX
225    This is the end of the chunk lifted from m68kelf.h  */
226 
227 
228 /* XXX
229    The following chunk is more or less lifted from m68kv4.h.
230    We'd like to just #include that file, but it has not yet
231    been converted to the new include style.
232 
233    Should there be a m68kv4-abi.h ??  */
234 
235 
236 /* Register in which address to store a structure value is passed to a
237    function.  The default in m68k.h is a1.  For m68k/SVR4 it is a0. */
238 
239 #undef STRUCT_VALUE_REGNUM
240 #define STRUCT_VALUE_REGNUM 8
241 
242 
243 /* Register in which static-chain is passed to a function.  The
244    default isn m68k.h is a0, but that is already the struct value
245    regnum.  Make it a1 instead.  */
246 
247 #undef STATIC_CHAIN_REGNUM
248 #define STATIC_CHAIN_REGNUM 9
249 
250 
251 /* Now to renumber registers for dbx and gdb.
252    We use the Sun-3 convention, which is:
253    floating point registers have numbers 18 to 25, not
254    16 to 23 as they do in the compiler.  */
255 
256 #undef DBX_REGISTER_NUMBER
257 #define DBX_REGISTER_NUMBER(REGNO) ((REGNO) < 16 ? (REGNO) : (REGNO) + 2)
258 
259 
260 /* 1 if N is a possible register number for a function value.  For
261    m68k/SVR4 allow d0, a0, or fp0 as return registers, for integral,
262    pointer, or floating types, respectively.  Reject fp0 if not using
263    a 68881 coprocessor.  */
264 
265 #undef FUNCTION_VALUE_REGNO_P
266 #define FUNCTION_VALUE_REGNO_P(N)					\
267   ((N) == 0 || (N) == 8 || (TARGET_68881 && (N) == 16))
268 
269 
270 /* Define this to be true when FUNCTION_VALUE_REGNO_P is true for
271    more than one register.  */
272 
273 #undef NEEDS_UNTYPED_CALL
274 #define NEEDS_UNTYPED_CALL 1
275 
276 
277 /* Define how to generate (in the callee) the output value of a
278    function and how to find (in the caller) the value returned by a
279    function.  VALTYPE is the data type of the value (as a tree).  If
280    the precise function being called is known, FUNC is its
281    FUNCTION_DECL; otherwise, FUNC is 0.  For m68k/SVR4 generate the
282    result in d0, a0, or fp0 as appropriate. */
283 
284 #undef FUNCTION_VALUE
285 #define FUNCTION_VALUE(VALTYPE, FUNC)					\
286   (TREE_CODE (VALTYPE) == REAL_TYPE && TARGET_68881			\
287    ? gen_rtx_REG (TYPE_MODE (VALTYPE), 16)				\
288    : (POINTER_TYPE_P (VALTYPE)						\
289       ? gen_rtx_REG (TYPE_MODE (VALTYPE), 8)				\
290       : gen_rtx_REG (TYPE_MODE (VALTYPE), 0)))
291 
292 
293 /* For compatibility with the large body of existing code which does
294    not always properly declare external functions returning pointer
295    types, the m68k/SVR4 convention is to copy the value returned for
296    pointer functions from a0 to d0 in the function epilogue, so that
297    callers that have neglected to properly declare the callee can
298    still find the correct return value.  */
299 
300 extern int current_function_returns_pointer;
301 #define FUNCTION_EXTRA_EPILOGUE(FILE, SIZE) 				\
302 do									\
303   {									\
304     if (current_function_returns_pointer				\
305 	&& ! find_equiv_reg (0, get_last_insn (), 0, 0, 0, 8, Pmode))	\
306       asm_fprintf (FILE, "\tmove.l %Ra0,%Rd0\n");			\
307   }									\
308 while (0)
309 
310 
311 /* Define how to find the value returned by a library function
312    assuming the value has mode MODE.
313    For m68k/SVR4 look for integer values in d0, pointer values in d0
314    (returned in both d0 and a0), and floating values in fp0.  */
315 
316 #undef LIBCALL_VALUE
317 #define LIBCALL_VALUE(MODE)						\
318   ((((MODE) == SFmode || (MODE) == DFmode || (MODE) == XFmode)		\
319     && TARGET_68881)							\
320    ? gen_rtx_REG (MODE, 16)						\
321    : gen_rtx_REG (MODE, 0))
322 
323 
324 /* Boundary (in *bits*) on which stack pointer should be aligned.
325    The m68k/SVR4 convention is to keep the stack pointer longword aligned. */
326 
327 #undef STACK_BOUNDARY
328 #define STACK_BOUNDARY 32
329 
330 
331 /* Alignment of field after `int : 0' in a structure.
332    For m68k/SVR4, this is the next longword boundary. */
333 
334 #undef EMPTY_FIELD_BOUNDARY
335 #define EMPTY_FIELD_BOUNDARY 32
336 
337 
338 /* No data type wants to be aligned rounder than this.
339    For m68k/SVR4, some types (doubles for example) are aligned on 8 byte
340    boundaries */
341 
342 #undef BIGGEST_ALIGNMENT
343 #define BIGGEST_ALIGNMENT 64
344 
345 
346 /* For m68k SVR4, structures are returned using the reentrant
347    technique. */
348 
349 #undef PCC_STATIC_STRUCT_RETURN
350 
351 
352 /* The svr4 ABI for the m68k says that records and unions are returned
353    in memory.  */
354 
355 #undef DEFAULT_PCC_STRUCT_RETURN
356 #define DEFAULT_PCC_STRUCT_RETURN 1
357 
358 /* Output assembler code for a block containing the constant parts
359    of a trampoline, leaving space for the variable parts.  */
360 
361 /* On m68k svr4, the trampoline is different from the generic version
362    in that we use a1 as the static call chain.  */
363 
364 #undef TRAMPOLINE_TEMPLATE
365 #define TRAMPOLINE_TEMPLATE(FILE)					\
366 {									\
367   assemble_aligned_integer (2, GEN_INT (0x227a));			\
368   assemble_aligned_integer (2, GEN_INT (8));				\
369   assemble_aligned_integer (2, GEN_INT (0x2f3a));			\
370   assemble_aligned_integer (2, GEN_INT (8));				\
371   assemble_aligned_integer (2, GEN_INT (0x4e75));			\
372   assemble_aligned_integer (4, const0_rtx);				\
373   assemble_aligned_integer (4, const0_rtx);				\
374 }
375 
376 /* Redefine since we are using a different trampoline */
377 #undef TRAMPOLINE_SIZE
378 #define TRAMPOLINE_SIZE 18
379 
380 /* Emit RTL insns to initialize the variable parts of a trampoline.
381    FNADDR is an RTX for the address of the function's pure code.
382    CXT is an RTX for the static chain value for the function.  */
383 
384 #undef INITIALIZE_TRAMPOLINE
385 #define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT)			\
386 {									\
387   emit_move_insn (gen_rtx_MEM (SImode, plus_constant (TRAMP, 10)), CXT); \
388   emit_move_insn (gen_rtx_MEM (SImode, plus_constant (TRAMP, 14)), FNADDR); \
389 }
390 
391 
392 /* XXX
393    This is the end of the chunk lifted from m68kv4.h  */
394