freebsd.h revision 204762
11590Srgrimes/* Definitions for MIPS varients running FreeBSD with ELF format 21590Srgrimes Copyright (C) 2008 Free Software Foundation, Inc. 31590Srgrimes Continued by David O'Brien <obrien@freebsd.org> 41590Srgrimes 51590SrgrimesThis file is part of GCC. 61590Srgrimes 71590SrgrimesGCC is free software; you can redistribute it and/or modify 81590Srgrimesit under the terms of the GNU General Public License as published by 91590Srgrimesthe Free Software Foundation; either version 2, or (at your option) 101590Srgrimesany later version. 111590Srgrimes 121590SrgrimesGCC is distributed in the hope that it will be useful, 131590Srgrimesbut WITHOUT ANY WARRANTY; without even the implied warranty of 141590SrgrimesMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 151590SrgrimesGNU General Public License for more details. 161590Srgrimes 171590SrgrimesYou should have received a copy of the GNU General Public License 181590Srgrimesalong with GCC; see the file COPYING. If not, write to 191590Srgrimesthe Free Software Foundation, 51 Franklin Street, Fifth Floor, 201590SrgrimesBoston, MA 02110-1301, USA. */ 211590Srgrimes 221590Srgrimes/* $FreeBSD: head/contrib/gcc/config/mips/freebsd.h 204762 2010-03-05 16:56:08Z imp $ */ 231590Srgrimes 241590Srgrimes/* This defines which switch letters take arguments. -G is a MIPS 251590Srgrimes special. */ 261590Srgrimes 271590Srgrimes#undef SWITCH_TAKES_ARG 281590Srgrimes#define SWITCH_TAKES_ARG(CHAR) \ 291590Srgrimes (FBSD_SWITCH_TAKES_ARG (CHAR) \ 301590Srgrimes || (CHAR) == 'R' \ 311590Srgrimes || (CHAR) == 'G') 321590Srgrimes 331590Srgrimes#undef SUBTARGET_EXTRA_SPECS /* mips.h bogusly defines it. */ 341590Srgrimes#define SUBTARGET_EXTRA_SPECS \ 3527978Scharnier { "fbsd_dynamic_linker", FBSD_DYNAMIC_LINKER}, \ 361590Srgrimes { "fbsd_link_spec", FBSD_LINK_SPEC } 371590Srgrimes 381590Srgrimes/* config/mips/mips.h defines CC1_SPEC, 391590Srgrimes but gives us an "out" with SUBTARGET_CC1_SPEC. */ 401590Srgrimes#undef SUBTARGET_CC1_SPEC 4127978Scharnier#define SUBTARGET_CC1_SPEC "%{profile:-p}" 421590Srgrimes 4327978Scharnier/* Provide a LINK_SPEC appropriate for FreeBSD. Here we provide support 4427978Scharnier for the special GCC options -static and -shared, which allow us to 4550477Speter link things in one of these three modes by applying the appropriate 461590Srgrimes combinations of options at link-time. We like to support here for 471590Srgrimes as many of the other GNU linker options as possible. But I don't 481590Srgrimes have the time to search for those flags. I am sure how to add 491590Srgrimes support for -soname shared_object_name. H.J. 501590Srgrimes 5118485Sbde When the -shared link option is used a final link is not being 5227978Scharnier done. */ 5374593Sache 5420156Sache#define FBSD_LINK_SPEC "\ 551590Srgrimes %{p:%nconsider using `-pg' instead of `-p' with gprof(1) } \ 5627978Scharnier %{v:-V} \ 5720156Sache %{assert*} %{R*} %{rpath*} %{defsym*} \ 589992Sache %{shared:-Bshareable %{h*} %{soname*}} \ 5927978Scharnier %{!shared: \ 6020156Sache %{!static: \ 611590Srgrimes %{rdynamic: -export-dynamic} \ 621590Srgrimes %{!dynamic-linker:-dynamic-linker %(fbsd_dynamic_linker) }} \ 631590Srgrimes %{static:-Bstatic}} \ 641590Srgrimes %{symbolic:-Bsymbolic} " 651590Srgrimes 661590Srgrimes#undef LINK_SPEC 671590Srgrimes#define LINK_SPEC "\ 6820165Sache %{G*} %{mips1} %{mips2} %{mips3} %{mips4} \ 691590Srgrimes %{mips32} %{mips32r2} %{mips64} %{mips64r2} \ 701590Srgrimes %{bestGnum} %{call_shared} %{no_archive} %{exact_version} \ 711590Srgrimes %{mabi=32:-melf32%{EB:b}%{EL:l}tsmip_fbsd} \ 721590Srgrimes %{mabi=n32:-melf32%{EB:b}%{EL:l}tsmipn32_fbsd} \ 731590Srgrimes %{mabi=64:-melf64%{EB:b}%{EL:l}tsmip_fbsd} \ 741590Srgrimes %{mabi=o64:-melf64%{EB:b}%{EL:l}tsmip_fbsd} \ 758874Srgrimes %(fbsd_link_spec) \ 761590Srgrimes %(endian_spec) \ 771590Srgrimes %(fbsd_link_spec)" 781590Srgrimes 791590Srgrimes 801590Srgrimes/* Reset our STARTFILE_SPEC which was properly set in config/freebsd.h 811590Srgrimes but trashed by config/mips/elf.h. */ 821590Srgrimes#undef STARTFILE_SPEC 8327978Scharnier#define STARTFILE_SPEC FBSD_STARTFILE_SPEC 8435659Ssteve 8527978Scharnier/* Provide an ENDFILE_SPEC appropriate for FreeBSD/i386. */ 8627978Scharnier#undef ENDFILE_SPEC 871590Srgrimes#define ENDFILE_SPEC FBSD_ENDFILE_SPEC 881590Srgrimes 891590Srgrimes/* Reset our LIB_SPEC which was properly set in config/freebsd.h 901590Srgrimes but trashed by config/mips/elf.h. */ 911590Srgrimes#undef LIB_SPEC 9218485Sbde#define LIB_SPEC FBSD_LIB_SPEC 931590Srgrimes 941590Srgrimes/* config/mips/mips.h defines CPP_SPEC, and it expects SUBTARGET_CPP_SPEC. */ 951590Srgrimes#undef SUBTARGET_CPP_SPEC 961590Srgrimes#define SUBTARGET_CPP_SPEC FBSD_CPP_SPEC 971590Srgrimes 9874593Sache 991590Srgrimes/************************[ Target stuff ]***********************************/ 10011758Sache 10174593Sache/* Define the actual types of some ANSI-mandated types. 10211758Sache Needs to agree with <machine/ansi.h>. GCC defaults come from c-decl.c, 10324360Simp c-common.c, and config/<arch>/<arch>.h. */ 1041590Srgrimes 1051590Srgrimes#undef TARGET_DEFAULT 1061590Srgrimes#define TARGET_DEFAULT (MASK_ABICALLS | MASK_SOFT_FLOAT) 1071590Srgrimes 1081590Srgrimes#if TARGET_ENDIAN_DEFAULT != 0 1091590Srgrimes#define TARGET_VERSION fprintf (stderr, " (FreeBSD/mips)"); 11027978Scharnier#else 1111590Srgrimes#define TARGET_VERSION fprintf (stderr, " (FreeBSD/mipsel)"); 11235659Ssteve#endif 11335659Ssteve 11435659Ssteve/* The generic MIPS TARGET_CPU_CPP_BUILTINS are incorrect for FreeBSD. 11535659Ssteve Specifically, they define too many namespace-invasive macros. Override 11635659Ssteve them here. Note this is structured for easy comparison to the version 11735659Ssteve in mips.h. */ 11827978Scharnier 11927978Scharnier#undef TARGET_CPU_CPP_BUILTINS 1201590Srgrimes#define TARGET_CPU_CPP_BUILTINS() \ 1211590Srgrimes do \ 12227978Scharnier { \ 1231590Srgrimes builtin_assert ("machine=mips"); \ 1241590Srgrimes builtin_assert ("cpu=mips"); \ 1251590Srgrimes builtin_define ("__mips__"); \ 1261590Srgrimes \ 1271590Srgrimes if (TARGET_64BIT) \ 1281590Srgrimes builtin_define ("__mips64__"); \ 1291590Srgrimes \ 1301590Srgrimes if (TARGET_FLOAT64) \ 1311590Srgrimes builtin_define ("__mips_fpr=64"); \ 1321590Srgrimes else \ 1331590Srgrimes builtin_define ("__mips_fpr=32"); \ 1341590Srgrimes \ 1351590Srgrimes if (TARGET_MIPS16) \ 1361590Srgrimes builtin_define ("__mips16"); \ 1371590Srgrimes \ 1381590Srgrimes if (mips_abi == ABI_N32) \ 1391590Srgrimes { \ 1401590Srgrimes builtin_define ("__mips_n32"); \ 1411590Srgrimes builtin_define ("_ABIN32=2"); \ 1421590Srgrimes builtin_define ("_MIPS_SIM=_ABIN32"); \ 1431590Srgrimes builtin_define ("_MIPS_SZLONG=32"); \ 14427978Scharnier builtin_define ("_MIPS_SZPTR=32"); \ 14527978Scharnier } \ 1461590Srgrimes else if (mips_abi == ABI_64) \ 1471590Srgrimes { \ 1481590Srgrimes builtin_define ("__mips_n64"); \ 1491590Srgrimes builtin_define ("_ABI64=3"); \ 1501590Srgrimes builtin_define ("_MIPS_SIM=_ABI64"); \ 1511590Srgrimes builtin_define ("_MIPS_SZLONG=64"); \ 1521590Srgrimes builtin_define ("_MIPS_SZPTR=64"); \ 1531590Srgrimes } \ 1541590Srgrimes else if (mips_abi == ABI_O64) \ 1551590Srgrimes { \ 1565239Sats builtin_define ("__mips_o64"); \ 15720165Sache builtin_define ("_ABIO64=4"); \ 1581590Srgrimes builtin_define ("_MIPS_SIM=_ABIO64"); \ 1591590Srgrimes builtin_define ("_MIPS_SZLONG=64"); \ 1601590Srgrimes builtin_define ("_MIPS_SZPTR=64"); \ 1611590Srgrimes } \ 1621590Srgrimes else if (mips_abi == ABI_EABI) \ 1631590Srgrimes { \ 1649992Sache builtin_define ("__mips_eabi"); \ 16589572Sdillon builtin_define ("_ABIEMB=5"); \ 16674593Sache builtin_define ("_MIPS_SIM=_ABIEMB"); \ 16774593Sache if (TARGET_LONG64) \ 16874593Sache builtin_define ("_MIPS_SZLONG=64"); \ 16985639Sdillon else \ 17020165Sache builtin_define ("_MIPS_SZLONG=32"); \ 17120165Sache if (TARGET_64BIT) \ 17274593Sache builtin_define ("_MIPS_SZPTR=64"); \ 17320165Sache else \ 1741590Srgrimes builtin_define ("_MIPS_SZPTR=32"); \ 1751590Srgrimes } \ 1761590Srgrimes else \ 17774593Sache { \ 1781590Srgrimes builtin_define ("__mips_o32"); \ 1791590Srgrimes builtin_define ("_ABIO32=1"); \ 1801590Srgrimes builtin_define ("_MIPS_SIM=_ABIO32"); \ 1811590Srgrimes builtin_define ("_MIPS_SZLONG=32"); \ 1821590Srgrimes builtin_define ("_MIPS_SZPTR=32"); \ 1831590Srgrimes } \ 1841590Srgrimes if (TARGET_FLOAT64) \ 1851590Srgrimes builtin_define ("_MIPS_FPSET=32"); \ 1861590Srgrimes else \ 1871590Srgrimes builtin_define ("_MIPS_FPSET=16"); \ 1881590Srgrimes \ 1891590Srgrimes builtin_define ("_MIPS_SZINT=32"); \ 1901590Srgrimes \ 1911590Srgrimes MIPS_CPP_SET_PROCESSOR ("_MIPS_ARCH", mips_arch_info); \ 1921590Srgrimes MIPS_CPP_SET_PROCESSOR ("_MIPS_TUNE", mips_tune_info); \ 1931590Srgrimes \ 1941590Srgrimes if (ISA_MIPS1) \ 1951590Srgrimes { \ 1961590Srgrimes builtin_define ("__mips=1"); \ 19727978Scharnier builtin_define ("_MIPS_ISA=_MIPS_ISA_MIPS1"); \ 19827978Scharnier } \ 19927978Scharnier else if (ISA_MIPS2) \ 20027978Scharnier { \ 20127978Scharnier builtin_define ("__mips=2"); \ 20227978Scharnier builtin_define ("_MIPS_ISA=_MIPS_ISA_MIPS2"); \ 20327978Scharnier } \ 20427978Scharnier else if (ISA_MIPS3) \ 20535659Ssteve { \ 20635659Ssteve builtin_define ("__mips=3"); \ 20727978Scharnier builtin_define ("_MIPS_ISA=_MIPS_ISA_MIPS3"); \ 2081590Srgrimes } \ 20935659Ssteve else if (ISA_MIPS4) \ 2101590Srgrimes { \ 2111590Srgrimes builtin_define ("__mips=4"); \ 2121590Srgrimes builtin_define ("_MIPS_ISA=_MIPS_ISA_MIPS4"); \ 21335659Ssteve } \ 21435659Ssteve else if (ISA_MIPS32) \ 2151590Srgrimes { \ 2161590Srgrimes builtin_define ("__mips=32"); \ 21735659Ssteve builtin_define ("_MIPS_ISA=_MIPS_ISA_MIPS32"); \ 2181590Srgrimes builtin_define ("__mips_isa_rev=1"); \ 2191590Srgrimes } \ 22035659Ssteve else if (ISA_MIPS32R2) \ 22135659Ssteve { \ 2221590Srgrimes builtin_define ("__mips=32"); \ 223 builtin_define ("_MIPS_ISA=_MIPS_ISA_MIPS32"); \ 224 builtin_define ("__mips_isa_rev=2"); \ 225 } \ 226 else if (ISA_MIPS64) \ 227 { \ 228 builtin_define ("__mips=64"); \ 229 builtin_define ("_MIPS_ISA=_MIPS_ISA_MIPS64"); \ 230 builtin_define ("__mips_isa_rev=1"); \ 231 } \ 232/* else if (ISA_MIPS64R2) \ 233 { \ 234 builtin_define ("__mips=64"); \ 235 builtin_define ("_MIPS_ISA=_MIPS_ISA_MIPS64"); \ 236 builtin_define ("__mips_isa_rev=2"); \ 237 } \ 238*/ \ 239 if (TARGET_HARD_FLOAT) \ 240 builtin_define ("__mips_hard_float"); \ 241 else if (TARGET_SOFT_FLOAT) \ 242 builtin_define ("__mips_soft_float"); \ 243 \ 244 if (TARGET_SINGLE_FLOAT) \ 245 builtin_define ("__mips_single_float"); \ 246 \ 247 if (TARGET_BIG_ENDIAN) \ 248 builtin_define ("__MIPSEB__"); \ 249 else \ 250 builtin_define ("__MIPSEL__"); \ 251 \ 252 /* No language dialect defines. */ \ 253 if (TARGET_ABICALLS) \ 254 builtin_define ("__ABICALLS__"); \ 255 } \ 256 while (0) 257 258/* Default ABI and ISA */ 259#undef DRIVER_SELF_SPECS 260#if MIPS_ABI_DEFAULT == ABI_N32 261#define DRIVER_SELF_SPECS \ 262 "%{!EB:%{!EL:%(endian_spec)}}", \ 263 "%{!march=*: -march=mips64}", \ 264 "%{!mabi=*: -mabi=n32}" 265#elif MIPS_ABI_DEFAULT == ABI_64 266#define DRIVER_SELF_SPECS \ 267 "%{!EB:%{!EL:%(endian_spec)}}", \ 268 "%{!march=*: -march=mips64}", \ 269 "%{!mabi=*: -mabi=64}" 270#elif MIPS_ABI_DEFAULT == ABI_O64 271#define DRIVER_SELF_SPECS \ 272 "%{!EB:%{!EL:%(endian_spec)}}", \ 273 "%{!march=*: -march=mips64}", \ 274 "%{!mabi=*: -mabi=o64}" 275#else /* default to o32 */ 276#define DRIVER_SELF_SPECS \ 277 "%{!EB:%{!EL:%(endian_spec)}}", \ 278 "%{!march=*: -march=mips32}", \ 279 "%{!mabi=*: -mabi=32}" 280#endif 281 282#if 0 283/* Don't default to pcc-struct-return, we want to retain compatibility with 284 older gcc versions AND pcc-struct-return is nonreentrant. 285 (even though the SVR4 ABI for the i386 says that records and unions are 286 returned in memory). */ 287 288#undef DEFAULT_PCC_STRUCT_RETURN 289#define DEFAULT_PCC_STRUCT_RETURN 0 290#endif 291 292 293/************************[ Assembler stuff ]********************************/ 294 295#undef SUBTARGET_ASM_SPEC 296#define SUBTARGET_ASM_SPEC \ 297 "%{!mno-abicalls: %{!fno-PIC:%{!fno-pic:-KPIC}}}" 298 299/* -G is incompatible with -KPIC which is the default, so only allow objects 300 in the small data section if the user explicitly asks for it. */ 301 302#undef MIPS_DEFAULT_GVALUE 303#define MIPS_DEFAULT_GVALUE 0 304 305/* If defined, a C expression whose value is a string containing the 306 assembler operation to identify the following data as 307 uninitialized global data. If not defined, and neither 308 `ASM_OUTPUT_BSS' nor `ASM_OUTPUT_ALIGNED_BSS' are defined, 309 uninitialized global data will be output in the data section if 310 `-fno-common' is passed, otherwise `ASM_OUTPUT_COMMON' will be 311 used. */ 312#undef BSS_SECTION_ASM_OP 313#define BSS_SECTION_ASM_OP "\t.section\t.bss" 314 315/* Like `ASM_OUTPUT_BSS' except takes the required alignment as a 316 separate, explicit argument. If you define this macro, it is used 317 in place of `ASM_OUTPUT_BSS', and gives you more flexibility in 318 handling the required alignment of the variable. The alignment is 319 specified as the number of bits. 320 321 Try to use function `asm_output_aligned_bss' defined in file 322 `varasm.c' when defining this macro. */ 323#undef ASM_OUTPUT_ALIGNED_BSS 324#define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \ 325 asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN) 326 327/* Standard AT&T UNIX 'as' local label spelling. */ 328#undef LOCAL_LABEL_PREFIX 329#define LOCAL_LABEL_PREFIX "." 330 331/* Currently we don't support 128bit long doubles, so for now we force 332 n32 to be 64bit. */ 333#undef LONG_DOUBLE_TYPE_SIZE 334#define LONG_DOUBLE_TYPE_SIZE 64 335 336#ifdef IN_LIBGCC2 337#undef LIBGCC2_LONG_DOUBLE_TYPE_SIZE 338#define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64 339#endif 340 341/************************[ Debugger stuff ]*********************************/ 342 343