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