freebsd.h revision 208737
1/* Definitions for MIPS varients running FreeBSD with ELF format
2   Copyright (C) 2008 Free Software Foundation, Inc.
3   Continued by David O'Brien <obrien@freebsd.org>
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2, or (at your option)
10any later version.
11
12GCC is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with GCC; see the file COPYING.  If not, write to
19the Free Software Foundation, 51 Franklin Street, Fifth Floor,
20Boston, MA 02110-1301, USA.  */
21
22/* $FreeBSD: head/contrib/gcc/config/mips/freebsd.h 208737 2010-06-02 11:06:03Z jmallett $ */
23
24/* This defines which switch letters take arguments.  -G is a MIPS
25   special.  */
26
27#undef  SWITCH_TAKES_ARG
28#define SWITCH_TAKES_ARG(CHAR)		\
29  (FBSD_SWITCH_TAKES_ARG (CHAR)		\
30   || (CHAR) == 'R'			\
31   || (CHAR) == 'G')
32
33#undef  SUBTARGET_EXTRA_SPECS	/* mips.h bogusly defines it.  */
34#define SUBTARGET_EXTRA_SPECS \
35  { "fbsd_dynamic_linker",	FBSD_DYNAMIC_LINKER}, \
36  { "fbsd_link_spec",		FBSD_LINK_SPEC }
37
38/* config/mips/mips.h defines CC1_SPEC,
39   but gives us an "out" with SUBTARGET_CC1_SPEC.  */
40#undef  SUBTARGET_CC1_SPEC
41#define SUBTARGET_CC1_SPEC "%{profile:-p}"
42
43/* Provide a LINK_SPEC appropriate for FreeBSD.  Here we provide support
44   for the special GCC options -static and -shared, which allow us to
45   link things in one of these three modes by applying the appropriate
46   combinations of options at link-time. We like to support here for
47   as many of the other GNU linker options as possible. But I don't
48   have the time to search for those flags. I am sure how to add
49   support for -soname shared_object_name. H.J.
50
51   When the -shared link option is used a final link is not being
52   done.  */
53
54#define FBSD_LINK_SPEC "\
55    %{p:%nconsider using `-pg' instead of `-p' with gprof(1) } \
56    %{v:-V} \
57    %{assert*} %{R*} %{rpath*} %{defsym*} \
58    %{shared:-Bshareable %{h*} %{soname*}} \
59    %{!shared: \
60      %{!static: \
61	%{rdynamic: -export-dynamic} \
62	%{!dynamic-linker:-dynamic-linker %(fbsd_dynamic_linker) }} \
63      %{static:-Bstatic}} \
64    %{symbolic:-Bsymbolic} "
65
66#undef	LINK_SPEC
67#define LINK_SPEC "\
68    %{EB} %{EL} %(endian_spec) \
69    %{G*} %{mips1} %{mips2} %{mips3} %{mips4} \
70    %{mips32} %{mips32r2} %{mips64} %{mips64r2} \
71    %{bestGnum} %{call_shared} %{no_archive} %{exact_version} \
72    %{mabi=32:-melf32%{EB:b}%{EL:l}tsmip_fbsd} \
73    %{mabi=n32:-melf32%{EB:b}%{EL:l}tsmipn32_fbsd} \
74    %{mabi=64:-melf64%{EB:b}%{EL:l}tsmip_fbsd} \
75    %{mabi=o64:-melf64%{EB:b}%{EL:l}tsmip_fbsd} \
76    %(fbsd_link_spec)"
77
78#undef	LINK_GCC_C_SEQUENCE_SPEC
79#define LINK_GCC_C_SEQUENCE_SPEC \
80  "%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}"
81
82/* Reset our STARTFILE_SPEC which was properly set in config/freebsd.h
83   but trashed by config/mips/elf.h.  */
84#undef  STARTFILE_SPEC
85#define STARTFILE_SPEC	FBSD_STARTFILE_SPEC
86
87/* Provide an ENDFILE_SPEC appropriate for FreeBSD/mips.  */
88#undef  ENDFILE_SPEC
89#define ENDFILE_SPEC	FBSD_ENDFILE_SPEC
90
91/* Reset our LIB_SPEC which was properly set in config/freebsd.h
92   but trashed by config/mips/elf.h.  */
93#undef  LIB_SPEC
94#define LIB_SPEC	FBSD_LIB_SPEC
95
96/* config/mips/mips.h defines CPP_SPEC, and it expects SUBTARGET_CPP_SPEC.  */
97#undef  SUBTARGET_CPP_SPEC
98#define SUBTARGET_CPP_SPEC FBSD_CPP_SPEC
99
100
101/************************[  Target stuff  ]***********************************/
102
103/* Define the actual types of some ANSI-mandated types.
104   Needs to agree with <machine/ansi.h>.  GCC defaults come from c-decl.c,
105   c-common.c, and config/<arch>/<arch>.h.  */
106
107#undef TARGET_DEFAULT
108#define TARGET_DEFAULT (MASK_ABICALLS | MASK_SOFT_FLOAT)
109
110#if TARGET_ENDIAN_DEFAULT != 0
111#define TARGET_VERSION	fprintf (stderr, " (FreeBSD/mips)");
112#else
113#define TARGET_VERSION	fprintf (stderr, " (FreeBSD/mipsel)");
114#endif
115
116/* The generic MIPS TARGET_CPU_CPP_BUILTINS are incorrect for FreeBSD.
117   Specifically, they define too many namespace-invasive macros.  Override
118   them here.  Note this is structured for easy comparison to the version
119   in mips.h.  */
120
121#undef  TARGET_CPU_CPP_BUILTINS
122#define TARGET_CPU_CPP_BUILTINS()				\
123  do								\
124    {								\
125      builtin_assert ("machine=mips");				\
126      builtin_assert ("cpu=mips");				\
127      builtin_define ("__mips__");				\
128								\
129      if (TARGET_64BIT)						\
130	builtin_define ("__mips64");				\
131								\
132      if (TARGET_FLOAT64)					\
133	builtin_define ("__mips_fpr=64");			\
134      else							\
135	builtin_define ("__mips_fpr=32");			\
136								\
137      if (TARGET_MIPS16)					\
138	builtin_define ("__mips16");				\
139								\
140      if (mips_abi == ABI_N32)                                  \
141        {                                                       \
142          builtin_define ("__mips_n32");                        \
143          builtin_define ("_ABIN32=2");                         \
144          builtin_define ("_MIPS_SIM=_ABIN32");                 \
145          builtin_define ("_MIPS_SZLONG=32");                   \
146          builtin_define ("_MIPS_SZPTR=32");                    \
147        }                                                       \
148      else if (mips_abi == ABI_64)                              \
149        {                                                       \
150          builtin_define ("__mips_n64");                        \
151          builtin_define ("_ABI64=3");                          \
152          builtin_define ("_MIPS_SIM=_ABI64");                  \
153          builtin_define ("_MIPS_SZLONG=64");                   \
154          builtin_define ("_MIPS_SZPTR=64");                    \
155        }                                                       \
156      else if (mips_abi == ABI_O64)                             \
157        {                                                       \
158          builtin_define ("__mips_o64");                        \
159          builtin_define ("_ABIO64=4");                         \
160          builtin_define ("_MIPS_SIM=_ABIO64");                 \
161          builtin_define ("_MIPS_SZLONG=64");                   \
162          builtin_define ("_MIPS_SZPTR=64");                    \
163        }                                                       \
164      else if (mips_abi == ABI_EABI)                            \
165        {                                                       \
166          builtin_define ("__mips_eabi");                       \
167          builtin_define ("_ABIEMB=5");                         \
168          builtin_define ("_MIPS_SIM=_ABIEMB");                 \
169          if (TARGET_LONG64)                                    \
170            builtin_define ("_MIPS_SZLONG=64");                 \
171          else                                                  \
172            builtin_define ("_MIPS_SZLONG=32");                 \
173          if (TARGET_64BIT)                                     \
174            builtin_define ("_MIPS_SZPTR=64");                  \
175          else                                                  \
176            builtin_define ("_MIPS_SZPTR=32");                  \
177        }                                                       \
178      else                                                      \
179        {                                                       \
180          builtin_define ("__mips_o32");                        \
181          builtin_define ("_ABIO32=1");                         \
182          builtin_define ("_MIPS_SIM=_ABIO32");                 \
183          builtin_define ("_MIPS_SZLONG=32");                   \
184          builtin_define ("_MIPS_SZPTR=32");                    \
185        }                                                       \
186      if (TARGET_FLOAT64)                                       \
187        builtin_define ("_MIPS_FPSET=32");                      \
188      else                                                      \
189        builtin_define ("_MIPS_FPSET=16");                      \
190                                                                \
191      builtin_define ("_MIPS_SZINT=32");                        \
192								\
193      MIPS_CPP_SET_PROCESSOR ("_MIPS_ARCH", mips_arch_info);	\
194      MIPS_CPP_SET_PROCESSOR ("_MIPS_TUNE", mips_tune_info);	\
195								\
196      if (ISA_MIPS1)                                            \
197        {                                                       \
198          builtin_define ("__mips=1");                          \
199          builtin_define ("_MIPS_ISA=_MIPS_ISA_MIPS1");         \
200	}							\
201      else if (ISA_MIPS2)                                       \
202        {                                                       \
203          builtin_define ("__mips=2");                          \
204          builtin_define ("_MIPS_ISA=_MIPS_ISA_MIPS2");         \
205	}							\
206      else if (ISA_MIPS3)					\
207        {                                                       \
208          builtin_define ("__mips=3");                          \
209          builtin_define ("_MIPS_ISA=_MIPS_ISA_MIPS3");         \
210	}							\
211      else if (ISA_MIPS4)					\
212        {                                                       \
213          builtin_define ("__mips=4");                          \
214          builtin_define ("_MIPS_ISA=_MIPS_ISA_MIPS4");         \
215	}							\
216      else if (ISA_MIPS32)					\
217	{							\
218	  builtin_define ("__mips=32");				\
219          builtin_define ("_MIPS_ISA=_MIPS_ISA_MIPS32");        \
220	  builtin_define ("__mips_isa_rev=1");			\
221	}							\
222      else if (ISA_MIPS32R2)					\
223	{							\
224	  builtin_define ("__mips=32");				\
225          builtin_define ("_MIPS_ISA=_MIPS_ISA_MIPS32");        \
226	  builtin_define ("__mips_isa_rev=2");			\
227	}							\
228      else if (ISA_MIPS64)					\
229	{							\
230	  builtin_define ("__mips=64");				\
231          builtin_define ("_MIPS_ISA=_MIPS_ISA_MIPS64");        \
232	  builtin_define ("__mips_isa_rev=1");			\
233	}							\
234      else if (ISA_MIPS64R2)					\
235	{							\
236	  builtin_define ("__mips=64");				\
237          builtin_define ("_MIPS_ISA=_MIPS_ISA_MIPS64");        \
238	  builtin_define ("__mips_isa_rev=2");			\
239	}							\
240	    							\
241      if (TARGET_HARD_FLOAT)					\
242	builtin_define ("__mips_hard_float");			\
243      else if (TARGET_SOFT_FLOAT)				\
244	builtin_define ("__mips_soft_float");			\
245								\
246      if (TARGET_SINGLE_FLOAT)					\
247	builtin_define ("__mips_single_float");			\
248								\
249      if (TARGET_BIG_ENDIAN)					\
250	builtin_define ("__MIPSEB__");				\
251      else							\
252	builtin_define ("__MIPSEL__");				\
253								\
254      /* No language dialect defines.  */			\
255      if (TARGET_ABICALLS)					\
256	builtin_define ("__ABICALLS__");			\
257    }								\
258  while (0)
259
260/* Default ABI and ISA */
261/*
262 * XXX/juli
263 * Shouldn't this also be dependent on !mips*?
264 */
265#ifdef MIPS_CPU_STRING_DEFAULT
266#define DRIVER_SELF_ISA_SPEC	"%{!march=*: -march=" MIPS_CPU_STRING_DEFAULT "}"
267#else
268#define	DRIVER_SELF_ISA_SPEC	"%{!march=*: -march=from-abi}"
269#endif
270
271#undef DRIVER_SELF_SPECS
272#if MIPS_ABI_DEFAULT == ABI_N32
273#define DRIVER_SELF_SPECS \
274	"%{!EB:%{!EL:%(endian_spec)}}", \
275	"%{!mabi=*: -mabi=n32}", \
276	DRIVER_SELF_ISA_SPEC
277#elif MIPS_ABI_DEFAULT == ABI_64
278#define DRIVER_SELF_SPECS \
279	"%{!EB:%{!EL:%(endian_spec)}}", \
280	"%{!mabi=*: -mabi=64}", \
281	DRIVER_SELF_ISA_SPEC
282#elif MIPS_ABI_DEFAULT == ABI_O64
283#define DRIVER_SELF_SPECS \
284	"%{!EB:%{!EL:%(endian_spec)}}", \
285	"%{!mabi=*: -mabi=o64}", \
286	DRIVER_SELF_ISA_SPEC
287#else /* default to o32 */
288#define DRIVER_SELF_SPECS \
289	"%{!EB:%{!EL:%(endian_spec)}}", \
290	"%{!mabi=*: -mabi=32}", \
291	DRIVER_SELF_ISA_SPEC
292#endif
293
294#if 0
295/* Don't default to pcc-struct-return, we want to retain compatibility with
296   older gcc versions AND pcc-struct-return is nonreentrant.
297   (even though the SVR4 ABI for the i386 says that records and unions are
298   returned in memory).  */
299
300#undef  DEFAULT_PCC_STRUCT_RETURN
301#define DEFAULT_PCC_STRUCT_RETURN 0
302#endif
303
304
305/************************[  Assembler stuff  ]********************************/
306
307#undef  SUBTARGET_ASM_SPEC
308#define SUBTARGET_ASM_SPEC \
309  "%{!mno-abicalls: %{!fno-PIC:%{!fno-pic:-KPIC}}}"
310
311/* -G is incompatible with -KPIC which is the default, so only allow objects
312   in the small data section if the user explicitly asks for it.  */
313
314#undef  MIPS_DEFAULT_GVALUE
315#define MIPS_DEFAULT_GVALUE 0
316
317/* If defined, a C expression whose value is a string containing the
318   assembler operation to identify the following data as
319   uninitialized global data.  If not defined, and neither
320   `ASM_OUTPUT_BSS' nor `ASM_OUTPUT_ALIGNED_BSS' are defined,
321   uninitialized global data will be output in the data section if
322   `-fno-common' is passed, otherwise `ASM_OUTPUT_COMMON' will be
323   used.  */
324#undef  BSS_SECTION_ASM_OP
325#define BSS_SECTION_ASM_OP "\t.section\t.bss"
326
327/* Like `ASM_OUTPUT_BSS' except takes the required alignment as a
328   separate, explicit argument.  If you define this macro, it is used
329   in place of `ASM_OUTPUT_BSS', and gives you more flexibility in
330   handling the required alignment of the variable.  The alignment is
331   specified as the number of bits.
332
333   Try to use function `asm_output_aligned_bss' defined in file
334   `varasm.c' when defining this macro.  */
335#undef  ASM_OUTPUT_ALIGNED_BSS
336#define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
337  asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
338
339/* Standard AT&T UNIX 'as' local label spelling.  */
340#undef  LOCAL_LABEL_PREFIX
341#define LOCAL_LABEL_PREFIX "."
342
343/* Currently we don't support 128bit long doubles, so for now we force
344   n32 to be 64bit.  */
345#undef	LONG_DOUBLE_TYPE_SIZE
346#define	LONG_DOUBLE_TYPE_SIZE 64
347
348#ifdef IN_LIBGCC2
349#undef	LIBGCC2_LONG_DOUBLE_TYPE_SIZE
350#define	LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64
351#endif
352
353/************************[  Debugger stuff  ]*********************************/
354
355