freebsd.h revision 192599
1145256Sjkoshy/* Definitions for MIPS varients running FreeBSD with ELF format
2183033Sjkoshy   Copyright (C) 2008 Free Software Foundation, Inc.
3174395Sjkoshy   Continued by David O'Brien <obrien@freebsd.org>
4145256Sjkoshy
5145256SjkoshyThis file is part of GCC.
6174395Sjkoshy
7174395SjkoshyGCC is free software; you can redistribute it and/or modify
8174395Sjkoshyit under the terms of the GNU General Public License as published by
9145256Sjkoshythe Free Software Foundation; either version 2, or (at your option)
10145256Sjkoshyany later version.
11145256Sjkoshy
12145256SjkoshyGCC is distributed in the hope that it will be useful,
13145256Sjkoshybut WITHOUT ANY WARRANTY; without even the implied warranty of
14145256SjkoshyMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15145256SjkoshyGNU General Public License for more details.
16145256Sjkoshy
17145256SjkoshyYou should have received a copy of the GNU General Public License
18145256Sjkoshyalong with GCC; see the file COPYING.  If not, write to
19145256Sjkoshythe Free Software Foundation, 51 Franklin Street, Fifth Floor,
20145256SjkoshyBoston, MA 02110-1301, USA.  */
21145256Sjkoshy
22145256Sjkoshy/* $FreeBSD: head/contrib/gcc/config/mips/freebsd.h 192599 2009-05-22 20:07:39Z des $ */
23145256Sjkoshy
24145256Sjkoshy/* This defines which switch letters take arguments.  -G is a MIPS
25145256Sjkoshy   special.  */
26145256Sjkoshy
27145256Sjkoshy#undef  SWITCH_TAKES_ARG
28145256Sjkoshy#define SWITCH_TAKES_ARG(CHAR)		\
29145256Sjkoshy  (FBSD_SWITCH_TAKES_ARG (CHAR)		\
30145256Sjkoshy   || (CHAR) == 'R'			\
31145256Sjkoshy   || (CHAR) == 'G')
32145256Sjkoshy
33145256Sjkoshy#undef  SUBTARGET_EXTRA_SPECS	/* mips.h bogusly defines it.  */
34145256Sjkoshy#define SUBTARGET_EXTRA_SPECS \
35145256Sjkoshy  { "fbsd_dynamic_linker",	FBSD_DYNAMIC_LINKER}, \
36145256Sjkoshy  { "fbsd_link_spec",		FBSD_LINK_SPEC }
37145256Sjkoshy
38184802Sjkoshy/* config/mips/mips.h defines CC1_SPEC,
39184802Sjkoshy   but gives us an "out" with SUBTARGET_CC1_SPEC.  */
40184802Sjkoshy#undef  SUBTARGET_CC1_SPEC
41184802Sjkoshy#define SUBTARGET_CC1_SPEC "%{profile:-p}"
42147191Sjkoshy
43185363Sjkoshy/* Provide a LINK_SPEC appropriate for FreeBSD.  Here we provide support
44147191Sjkoshy   for the special GCC options -static and -shared, which allow us to
45184802Sjkoshy   link things in one of these three modes by applying the appropriate
46206089Sfabient   combinations of options at link-time. We like to support here for
47145256Sjkoshy   as many of the other GNU linker options as possible. But I don't
48184802Sjkoshy   have the time to search for those flags. I am sure how to add
49184802Sjkoshy   support for -soname shared_object_name. H.J.
50184802Sjkoshy
51206089Sfabient   When the -shared link option is used a final link is not being
52184802Sjkoshy   done.  */
53236238Sfabient
54236238Sfabient#define FBSD_LINK_SPEC "\
55236238Sfabient    %{p:%nconsider using `-pg' instead of `-p' with gprof(1) } \
56236238Sfabient    %{v:-V} \
57236238Sfabient    %{assert*} %{R*} %{rpath*} %{defsym*} \
58236238Sfabient    %{shared:-Bshareable %{h*} %{soname*}} \
59236238Sfabient    %{!shared: \
60184802Sjkoshy      %{!static: \
61184802Sjkoshy	%{rdynamic: -export-dynamic} \
62184802Sjkoshy	%{!dynamic-linker:-dynamic-linker %(fbsd_dynamic_linker) }} \
63184802Sjkoshy      %{static:-Bstatic}} \
64184802Sjkoshy    %{symbolic:-Bsymbolic} "
65184802Sjkoshy
66184802Sjkoshy#undef	LINK_SPEC
67184802Sjkoshy#define LINK_SPEC "\
68184802Sjkoshy    %{G*} %{mips1} %{mips2} %{mips3} %{mips4} %{mips32} %{mips32r2} %{mips64} \
69206089Sfabient    %{bestGnum} %{call_shared} %{no_archive} %{exact_version} \
70206089Sfabient    %(fbsd_link_spec) "
71184802Sjkoshy#if 0
72184802Sjkoshy    %(endian_spec)
73147191Sjkoshy#endif
74147191Sjkoshy
75185363Sjkoshy/* Reset our STARTFILE_SPEC which was properly set in config/freebsd.h
76185363Sjkoshy   but trashed by config/mips/elf.h.  */
77206089Sfabient#undef  STARTFILE_SPEC
78206089Sfabient#define STARTFILE_SPEC	FBSD_STARTFILE_SPEC
79147191Sjkoshy
80147191Sjkoshy/* Provide an ENDFILE_SPEC appropriate for FreeBSD/i386.  */
81147191Sjkoshy#undef  ENDFILE_SPEC
82145256Sjkoshy#define ENDFILE_SPEC	FBSD_ENDFILE_SPEC
83147191Sjkoshy
84147191Sjkoshy/* Reset our LIB_SPEC which was properly set in config/freebsd.h
85147191Sjkoshy   but trashed by config/mips/elf.h.  */
86145256Sjkoshy#undef  LIB_SPEC
87147191Sjkoshy#define LIB_SPEC	FBSD_LIB_SPEC
88145256Sjkoshy
89147191Sjkoshy/* config/mips/mips.h defines CPP_SPEC, and it expects SUBTARGET_CPP_SPEC.  */
90147191Sjkoshy#undef  SUBTARGET_CPP_SPEC
91185363Sjkoshy#define SUBTARGET_CPP_SPEC FBSD_CPP_SPEC
92185363Sjkoshy
93206089Sfabient
94206089Sfabient/************************[  Target stuff  ]***********************************/
95147191Sjkoshy
96147191Sjkoshy/* Define the actual types of some ANSI-mandated types.
97145256Sjkoshy   Needs to agree with <machine/ansi.h>.  GCC defaults come from c-decl.c,
98174395Sjkoshy   c-common.c, and config/<arch>/<arch>.h.  */
99174395Sjkoshy
100183033Sjkoshy#if TARGET_ENDIAN_DEFAULT != 0
101183033Sjkoshy#define TARGET_VERSION	fprintf (stderr, " (FreeBSD/mips)");
102174395Sjkoshy#else
103174395Sjkoshy#define TARGET_VERSION	fprintf (stderr, " (FreeBSD/mipsel)");
104174395Sjkoshy#endif
105174395Sjkoshy
106174395Sjkoshy/* The generic MIPS TARGET_CPU_CPP_BUILTINS are incorrect for FreeBSD.
107174395Sjkoshy   Specifically, they define too many namespace-invasive macros.  Override
108174395Sjkoshy   them here.  Note this is structured for easy comparison to the version
109174395Sjkoshy   in mips.h.  */
110174395Sjkoshy
111174395Sjkoshy#undef  TARGET_CPU_CPP_BUILTINS
112174395Sjkoshy#define TARGET_CPU_CPP_BUILTINS()				\
113174395Sjkoshy  do								\
114174395Sjkoshy    {								\
115174395Sjkoshy      builtin_assert ("machine=mips");				\
116179886Salc      builtin_assert ("cpu=mips");				\
117179886Salc      builtin_define ("__mips__");				\
118174395Sjkoshy								\
119174395Sjkoshy      if (TARGET_64BIT)						\
120174395Sjkoshy	builtin_define ("__mips64__");				\
121174395Sjkoshy								\
122236238Sfabient      if (TARGET_FLOAT64)					\
123236238Sfabient	builtin_define ("__mips_fpr=64");			\
124236238Sfabient      else							\
125236238Sfabient	builtin_define ("__mips_fpr=32");			\
126236238Sfabient								\
127236238Sfabient      if (TARGET_MIPS16)					\
128236238Sfabient	builtin_define ("__mips16");				\
129236238Sfabient								\
130236238Sfabient      MIPS_CPP_SET_PROCESSOR ("_MIPS_ARCH", mips_arch_info);	\
131145256Sjkoshy      MIPS_CPP_SET_PROCESSOR ("_MIPS_TUNE", mips_tune_info);	\
132145256Sjkoshy								\
133145256Sjkoshy      if (ISA_MIPS3)						\
134145256Sjkoshy	builtin_define ("__mips=3");				\
135174395Sjkoshy      else if (ISA_MIPS4)					\
136145256Sjkoshy	builtin_define ("__mips=4");				\
137184802Sjkoshy      else if (ISA_MIPS32)					\
138184802Sjkoshy	{							\
139184802Sjkoshy	  builtin_define ("__mips=32");				\
140184802Sjkoshy	  builtin_define ("__mips_isa_rev=1");			\
141184802Sjkoshy	}							\
142184802Sjkoshy      else if (ISA_MIPS32R2)					\
143145256Sjkoshy	{							\
144	  builtin_define ("__mips=32");				\
145	  builtin_define ("__mips_isa_rev=2");			\
146	}							\
147      else if (ISA_MIPS64)					\
148	{							\
149	  builtin_define ("__mips=64");				\
150	  builtin_define ("__mips_isa_rev=1");			\
151	}							\
152								\
153      if (TARGET_HARD_FLOAT)					\
154	builtin_define ("__mips_hard_float");			\
155      else if (TARGET_SOFT_FLOAT)				\
156	builtin_define ("__mips_soft_float");			\
157								\
158      if (TARGET_SINGLE_FLOAT)					\
159	builtin_define ("__mips_single_float");			\
160								\
161      if (TARGET_BIG_ENDIAN)					\
162	builtin_define ("__MIPSEB__");				\
163      else							\
164	builtin_define ("__MIPSEL__");				\
165								\
166      /* No language dialect defines.  */			\
167								\
168      if (mips_abi == ABI_EABI)					\
169	builtin_define ("__mips_eabi");				\
170      else if (mips_abi == ABI_N32)				\
171	builtin_define ("__mips_n32");				\
172      else if (mips_abi == ABI_64)				\
173	builtin_define ("__mips_n64");				\
174      else if (mips_abi == ABI_O64)				\
175	builtin_define ("__mips_o64");				\
176      else							\
177	builtin_define ("__mips_o32");				\
178								\
179      if (TARGET_ABICALLS)					\
180	builtin_define ("__ABICALLS__");			\
181    }								\
182  while (0)
183
184/* Default to the mips32 ISA */
185#undef  DRIVER_SELF_SPECS
186#define DRIVER_SELF_SPECS \
187  "%{!march=*: -march=mips32}"
188#if 0
189  "%{!EB:%{!EL:%(endian_spec)}}",
190#endif
191
192#if 0
193/* Don't default to pcc-struct-return, we want to retain compatibility with
194   older gcc versions AND pcc-struct-return is nonreentrant.
195   (even though the SVR4 ABI for the i386 says that records and unions are
196   returned in memory).  */
197
198#undef  DEFAULT_PCC_STRUCT_RETURN
199#define DEFAULT_PCC_STRUCT_RETURN 0
200#endif
201
202
203/************************[  Assembler stuff  ]********************************/
204
205#undef  SUBTARGET_ASM_SPEC
206#define SUBTARGET_ASM_SPEC \
207  "%{!mno-abicalls: %{!fno-PIC:%{!fno-pic:-KPIC}}}"
208
209/* -G is incompatible with -KPIC which is the default, so only allow objects
210   in the small data section if the user explicitly asks for it.  */
211
212#undef  MIPS_DEFAULT_GVALUE
213#define MIPS_DEFAULT_GVALUE 0
214
215/* If defined, a C expression whose value is a string containing the
216   assembler operation to identify the following data as
217   uninitialized global data.  If not defined, and neither
218   `ASM_OUTPUT_BSS' nor `ASM_OUTPUT_ALIGNED_BSS' are defined,
219   uninitialized global data will be output in the data section if
220   `-fno-common' is passed, otherwise `ASM_OUTPUT_COMMON' will be
221   used.  */
222#undef  BSS_SECTION_ASM_OP
223#define BSS_SECTION_ASM_OP "\t.section\t.bss"
224
225/* Like `ASM_OUTPUT_BSS' except takes the required alignment as a
226   separate, explicit argument.  If you define this macro, it is used
227   in place of `ASM_OUTPUT_BSS', and gives you more flexibility in
228   handling the required alignment of the variable.  The alignment is
229   specified as the number of bits.
230
231   Try to use function `asm_output_aligned_bss' defined in file
232   `varasm.c' when defining this macro.  */
233#undef  ASM_OUTPUT_ALIGNED_BSS
234#define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
235  asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
236
237/* Standard AT&T UNIX 'as' local label spelling.  */
238#undef  LOCAL_LABEL_PREFIX
239#define LOCAL_LABEL_PREFIX "."
240
241
242/************************[  Debugger stuff  ]*********************************/
243
244