1182627Sobrien/* Definitions for MIPS varients running FreeBSD with ELF format 2182627Sobrien Copyright (C) 2008 Free Software Foundation, Inc. 3182627Sobrien Continued by David O'Brien <obrien@freebsd.org> 4182627Sobrien 5182627SobrienThis file is part of GCC. 6182627Sobrien 7182627SobrienGCC is free software; you can redistribute it and/or modify 8182627Sobrienit under the terms of the GNU General Public License as published by 9182627Sobrienthe Free Software Foundation; either version 2, or (at your option) 10182627Sobrienany later version. 11182627Sobrien 12182627SobrienGCC is distributed in the hope that it will be useful, 13182627Sobrienbut WITHOUT ANY WARRANTY; without even the implied warranty of 14182627SobrienMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15182627SobrienGNU General Public License for more details. 16182627Sobrien 17182627SobrienYou should have received a copy of the GNU General Public License 18182627Sobrienalong with GCC; see the file COPYING. If not, write to 19182627Sobrienthe Free Software Foundation, 51 Franklin Street, Fifth Floor, 20182627SobrienBoston, MA 02110-1301, USA. */ 21182627Sobrien 22182627Sobrien/* $FreeBSD$ */ 23182627Sobrien 24182627Sobrien/* This defines which switch letters take arguments. -G is a MIPS 25182627Sobrien special. */ 26182627Sobrien 27182627Sobrien#undef SWITCH_TAKES_ARG 28182627Sobrien#define SWITCH_TAKES_ARG(CHAR) \ 29182627Sobrien (FBSD_SWITCH_TAKES_ARG (CHAR) \ 30182627Sobrien || (CHAR) == 'R' \ 31182627Sobrien || (CHAR) == 'G') 32182627Sobrien 33182627Sobrien#undef SUBTARGET_EXTRA_SPECS /* mips.h bogusly defines it. */ 34182627Sobrien#define SUBTARGET_EXTRA_SPECS \ 35182627Sobrien { "fbsd_dynamic_linker", FBSD_DYNAMIC_LINKER}, \ 36182627Sobrien { "fbsd_link_spec", FBSD_LINK_SPEC } 37182627Sobrien 38182627Sobrien/* config/mips/mips.h defines CC1_SPEC, 39182627Sobrien but gives us an "out" with SUBTARGET_CC1_SPEC. */ 40182627Sobrien#undef SUBTARGET_CC1_SPEC 41182627Sobrien#define SUBTARGET_CC1_SPEC "%{profile:-p}" 42182627Sobrien 43182627Sobrien/* Provide a LINK_SPEC appropriate for FreeBSD. Here we provide support 44182627Sobrien for the special GCC options -static and -shared, which allow us to 45182627Sobrien link things in one of these three modes by applying the appropriate 46182627Sobrien combinations of options at link-time. We like to support here for 47182627Sobrien as many of the other GNU linker options as possible. But I don't 48182627Sobrien have the time to search for those flags. I am sure how to add 49182627Sobrien support for -soname shared_object_name. H.J. 50182627Sobrien 51182627Sobrien When the -shared link option is used a final link is not being 52182627Sobrien done. */ 53182627Sobrien 54182627Sobrien#define FBSD_LINK_SPEC "\ 55182627Sobrien %{p:%nconsider using `-pg' instead of `-p' with gprof(1) } \ 56182627Sobrien %{v:-V} \ 57182627Sobrien %{assert*} %{R*} %{rpath*} %{defsym*} \ 58182627Sobrien %{shared:-Bshareable %{h*} %{soname*}} \ 59238472Skib %{!static:--enable-new-dtags} \ 60182627Sobrien %{!shared: \ 61182627Sobrien %{!static: \ 62182627Sobrien %{rdynamic: -export-dynamic} \ 63182627Sobrien %{!dynamic-linker:-dynamic-linker %(fbsd_dynamic_linker) }} \ 64182627Sobrien %{static:-Bstatic}} \ 65182627Sobrien %{symbolic:-Bsymbolic} " 66182627Sobrien 67182627Sobrien#undef LINK_SPEC 68182627Sobrien#define LINK_SPEC "\ 69204772Simp %{EB} %{EL} %(endian_spec) \ 70204762Simp %{G*} %{mips1} %{mips2} %{mips3} %{mips4} \ 71204762Simp %{mips32} %{mips32r2} %{mips64} %{mips64r2} \ 72182627Sobrien %{bestGnum} %{call_shared} %{no_archive} %{exact_version} \ 73204762Simp %{mabi=32:-melf32%{EB:b}%{EL:l}tsmip_fbsd} \ 74204762Simp %{mabi=n32:-melf32%{EB:b}%{EL:l}tsmipn32_fbsd} \ 75204762Simp %{mabi=64:-melf64%{EB:b}%{EL:l}tsmip_fbsd} \ 76204762Simp %{mabi=o64:-melf64%{EB:b}%{EL:l}tsmip_fbsd} \ 77204762Simp %(fbsd_link_spec)" 78204762Simp 79208737Sjmallett#undef LINK_GCC_C_SEQUENCE_SPEC 80208737Sjmallett#define LINK_GCC_C_SEQUENCE_SPEC \ 81208737Sjmallett "%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}" 82208737Sjmallett 83182627Sobrien/* Reset our STARTFILE_SPEC which was properly set in config/freebsd.h 84182627Sobrien but trashed by config/mips/elf.h. */ 85182627Sobrien#undef STARTFILE_SPEC 86182627Sobrien#define STARTFILE_SPEC FBSD_STARTFILE_SPEC 87182627Sobrien 88204772Simp/* Provide an ENDFILE_SPEC appropriate for FreeBSD/mips. */ 89182627Sobrien#undef ENDFILE_SPEC 90182627Sobrien#define ENDFILE_SPEC FBSD_ENDFILE_SPEC 91182627Sobrien 92182627Sobrien/* Reset our LIB_SPEC which was properly set in config/freebsd.h 93182627Sobrien but trashed by config/mips/elf.h. */ 94182627Sobrien#undef LIB_SPEC 95182627Sobrien#define LIB_SPEC FBSD_LIB_SPEC 96182627Sobrien 97182627Sobrien/* config/mips/mips.h defines CPP_SPEC, and it expects SUBTARGET_CPP_SPEC. */ 98182627Sobrien#undef SUBTARGET_CPP_SPEC 99182627Sobrien#define SUBTARGET_CPP_SPEC FBSD_CPP_SPEC 100182627Sobrien 101182627Sobrien 102182627Sobrien/************************[ Target stuff ]***********************************/ 103182627Sobrien 104182627Sobrien/* Define the actual types of some ANSI-mandated types. 105182627Sobrien Needs to agree with <machine/ansi.h>. GCC defaults come from c-decl.c, 106182627Sobrien c-common.c, and config/<arch>/<arch>.h. */ 107182627Sobrien 108201855Simp#undef TARGET_DEFAULT 109201855Simp#define TARGET_DEFAULT (MASK_ABICALLS | MASK_SOFT_FLOAT) 110201855Simp 111182627Sobrien#if TARGET_ENDIAN_DEFAULT != 0 112182627Sobrien#define TARGET_VERSION fprintf (stderr, " (FreeBSD/mips)"); 113182627Sobrien#else 114182627Sobrien#define TARGET_VERSION fprintf (stderr, " (FreeBSD/mipsel)"); 115182627Sobrien#endif 116182627Sobrien 117182627Sobrien/* The generic MIPS TARGET_CPU_CPP_BUILTINS are incorrect for FreeBSD. 118182627Sobrien Specifically, they define too many namespace-invasive macros. Override 119182627Sobrien them here. Note this is structured for easy comparison to the version 120182627Sobrien in mips.h. */ 121182627Sobrien 122182627Sobrien#undef TARGET_CPU_CPP_BUILTINS 123182627Sobrien#define TARGET_CPU_CPP_BUILTINS() \ 124182627Sobrien do \ 125182627Sobrien { \ 126182627Sobrien builtin_assert ("machine=mips"); \ 127182627Sobrien builtin_assert ("cpu=mips"); \ 128182627Sobrien builtin_define ("__mips__"); \ 129182627Sobrien \ 130182627Sobrien if (TARGET_64BIT) \ 131208737Sjmallett builtin_define ("__mips64"); \ 132182627Sobrien \ 133182627Sobrien if (TARGET_FLOAT64) \ 134182627Sobrien builtin_define ("__mips_fpr=64"); \ 135182627Sobrien else \ 136182627Sobrien builtin_define ("__mips_fpr=32"); \ 137182627Sobrien \ 138182627Sobrien if (TARGET_MIPS16) \ 139182627Sobrien builtin_define ("__mips16"); \ 140182627Sobrien \ 141204549Simp if (mips_abi == ABI_N32) \ 142204549Simp { \ 143204549Simp builtin_define ("__mips_n32"); \ 144204549Simp builtin_define ("_ABIN32=2"); \ 145204549Simp builtin_define ("_MIPS_SIM=_ABIN32"); \ 146204549Simp builtin_define ("_MIPS_SZLONG=32"); \ 147204549Simp builtin_define ("_MIPS_SZPTR=32"); \ 148204549Simp } \ 149204549Simp else if (mips_abi == ABI_64) \ 150204549Simp { \ 151204549Simp builtin_define ("__mips_n64"); \ 152204549Simp builtin_define ("_ABI64=3"); \ 153204549Simp builtin_define ("_MIPS_SIM=_ABI64"); \ 154204549Simp builtin_define ("_MIPS_SZLONG=64"); \ 155204549Simp builtin_define ("_MIPS_SZPTR=64"); \ 156204549Simp } \ 157204549Simp else if (mips_abi == ABI_O64) \ 158204549Simp { \ 159204549Simp builtin_define ("__mips_o64"); \ 160204549Simp builtin_define ("_ABIO64=4"); \ 161204549Simp builtin_define ("_MIPS_SIM=_ABIO64"); \ 162204549Simp builtin_define ("_MIPS_SZLONG=64"); \ 163204549Simp builtin_define ("_MIPS_SZPTR=64"); \ 164204549Simp } \ 165204549Simp else if (mips_abi == ABI_EABI) \ 166204549Simp { \ 167204549Simp builtin_define ("__mips_eabi"); \ 168204549Simp builtin_define ("_ABIEMB=5"); \ 169204549Simp builtin_define ("_MIPS_SIM=_ABIEMB"); \ 170204549Simp if (TARGET_LONG64) \ 171204549Simp builtin_define ("_MIPS_SZLONG=64"); \ 172204549Simp else \ 173204549Simp builtin_define ("_MIPS_SZLONG=32"); \ 174204549Simp if (TARGET_64BIT) \ 175204549Simp builtin_define ("_MIPS_SZPTR=64"); \ 176204549Simp else \ 177204549Simp builtin_define ("_MIPS_SZPTR=32"); \ 178204549Simp } \ 179204549Simp else \ 180204549Simp { \ 181204549Simp builtin_define ("__mips_o32"); \ 182204549Simp builtin_define ("_ABIO32=1"); \ 183204549Simp builtin_define ("_MIPS_SIM=_ABIO32"); \ 184204549Simp builtin_define ("_MIPS_SZLONG=32"); \ 185204549Simp builtin_define ("_MIPS_SZPTR=32"); \ 186204549Simp } \ 187204549Simp if (TARGET_FLOAT64) \ 188204549Simp builtin_define ("_MIPS_FPSET=32"); \ 189204549Simp else \ 190204549Simp builtin_define ("_MIPS_FPSET=16"); \ 191204549Simp \ 192204549Simp builtin_define ("_MIPS_SZINT=32"); \ 193204549Simp \ 194182627Sobrien MIPS_CPP_SET_PROCESSOR ("_MIPS_ARCH", mips_arch_info); \ 195182627Sobrien MIPS_CPP_SET_PROCESSOR ("_MIPS_TUNE", mips_tune_info); \ 196182627Sobrien \ 197204549Simp if (ISA_MIPS1) \ 198204616Simp { \ 199204616Simp builtin_define ("__mips=1"); \ 200204616Simp builtin_define ("_MIPS_ISA=_MIPS_ISA_MIPS1"); \ 201204616Simp } \ 202204549Simp else if (ISA_MIPS2) \ 203204616Simp { \ 204204616Simp builtin_define ("__mips=2"); \ 205204616Simp builtin_define ("_MIPS_ISA=_MIPS_ISA_MIPS2"); \ 206204616Simp } \ 207204549Simp else if (ISA_MIPS3) \ 208204616Simp { \ 209204616Simp builtin_define ("__mips=3"); \ 210204616Simp builtin_define ("_MIPS_ISA=_MIPS_ISA_MIPS3"); \ 211204616Simp } \ 212182627Sobrien else if (ISA_MIPS4) \ 213204616Simp { \ 214204616Simp builtin_define ("__mips=4"); \ 215204616Simp builtin_define ("_MIPS_ISA=_MIPS_ISA_MIPS4"); \ 216204616Simp } \ 217182627Sobrien else if (ISA_MIPS32) \ 218182627Sobrien { \ 219182627Sobrien builtin_define ("__mips=32"); \ 220204616Simp builtin_define ("_MIPS_ISA=_MIPS_ISA_MIPS32"); \ 221182627Sobrien builtin_define ("__mips_isa_rev=1"); \ 222182627Sobrien } \ 223182627Sobrien else if (ISA_MIPS32R2) \ 224182627Sobrien { \ 225182627Sobrien builtin_define ("__mips=32"); \ 226204616Simp builtin_define ("_MIPS_ISA=_MIPS_ISA_MIPS32"); \ 227182627Sobrien builtin_define ("__mips_isa_rev=2"); \ 228182627Sobrien } \ 229182627Sobrien else if (ISA_MIPS64) \ 230182627Sobrien { \ 231182627Sobrien builtin_define ("__mips=64"); \ 232204616Simp builtin_define ("_MIPS_ISA=_MIPS_ISA_MIPS64"); \ 233182627Sobrien builtin_define ("__mips_isa_rev=1"); \ 234182627Sobrien } \ 235208737Sjmallett else if (ISA_MIPS64R2) \ 236204549Simp { \ 237204549Simp builtin_define ("__mips=64"); \ 238204616Simp builtin_define ("_MIPS_ISA=_MIPS_ISA_MIPS64"); \ 239204549Simp builtin_define ("__mips_isa_rev=2"); \ 240204549Simp } \ 241208737Sjmallett \ 242182627Sobrien if (TARGET_HARD_FLOAT) \ 243182627Sobrien builtin_define ("__mips_hard_float"); \ 244182627Sobrien else if (TARGET_SOFT_FLOAT) \ 245182627Sobrien builtin_define ("__mips_soft_float"); \ 246182627Sobrien \ 247182627Sobrien if (TARGET_SINGLE_FLOAT) \ 248182627Sobrien builtin_define ("__mips_single_float"); \ 249182627Sobrien \ 250182627Sobrien if (TARGET_BIG_ENDIAN) \ 251182627Sobrien builtin_define ("__MIPSEB__"); \ 252182627Sobrien else \ 253182627Sobrien builtin_define ("__MIPSEL__"); \ 254182627Sobrien \ 255182627Sobrien /* No language dialect defines. */ \ 256182627Sobrien if (TARGET_ABICALLS) \ 257182627Sobrien builtin_define ("__ABICALLS__"); \ 258182627Sobrien } \ 259182627Sobrien while (0) 260182627Sobrien 261204762Simp/* Default ABI and ISA */ 262208737Sjmallett/* 263208737Sjmallett * XXX/juli 264208737Sjmallett * Shouldn't this also be dependent on !mips*? 265208737Sjmallett */ 266208737Sjmallett#ifdef MIPS_CPU_STRING_DEFAULT 267208737Sjmallett#define DRIVER_SELF_ISA_SPEC "%{!march=*: -march=" MIPS_CPU_STRING_DEFAULT "}" 268208737Sjmallett#else 269208737Sjmallett#define DRIVER_SELF_ISA_SPEC "%{!march=*: -march=from-abi}" 270208737Sjmallett#endif 271208737Sjmallett 272204762Simp#undef DRIVER_SELF_SPECS 273204762Simp#if MIPS_ABI_DEFAULT == ABI_N32 274182627Sobrien#define DRIVER_SELF_SPECS \ 275204762Simp "%{!EB:%{!EL:%(endian_spec)}}", \ 276208737Sjmallett "%{!mabi=*: -mabi=n32}", \ 277208737Sjmallett DRIVER_SELF_ISA_SPEC 278204762Simp#elif MIPS_ABI_DEFAULT == ABI_64 279204762Simp#define DRIVER_SELF_SPECS \ 280204762Simp "%{!EB:%{!EL:%(endian_spec)}}", \ 281208737Sjmallett "%{!mabi=*: -mabi=64}", \ 282208737Sjmallett DRIVER_SELF_ISA_SPEC 283204762Simp#elif MIPS_ABI_DEFAULT == ABI_O64 284204762Simp#define DRIVER_SELF_SPECS \ 285204762Simp "%{!EB:%{!EL:%(endian_spec)}}", \ 286208737Sjmallett "%{!mabi=*: -mabi=o64}", \ 287208737Sjmallett DRIVER_SELF_ISA_SPEC 288204762Simp#else /* default to o32 */ 289204762Simp#define DRIVER_SELF_SPECS \ 290204762Simp "%{!EB:%{!EL:%(endian_spec)}}", \ 291208737Sjmallett "%{!mabi=*: -mabi=32}", \ 292208737Sjmallett DRIVER_SELF_ISA_SPEC 293182654Sobrien#endif 294182627Sobrien 295182627Sobrien#if 0 296182627Sobrien/* Don't default to pcc-struct-return, we want to retain compatibility with 297182627Sobrien older gcc versions AND pcc-struct-return is nonreentrant. 298182627Sobrien (even though the SVR4 ABI for the i386 says that records and unions are 299182627Sobrien returned in memory). */ 300182627Sobrien 301182627Sobrien#undef DEFAULT_PCC_STRUCT_RETURN 302182627Sobrien#define DEFAULT_PCC_STRUCT_RETURN 0 303182627Sobrien#endif 304182627Sobrien 305182627Sobrien 306182627Sobrien/************************[ Assembler stuff ]********************************/ 307182627Sobrien 308182627Sobrien#undef SUBTARGET_ASM_SPEC 309182627Sobrien#define SUBTARGET_ASM_SPEC \ 310182627Sobrien "%{!mno-abicalls: %{!fno-PIC:%{!fno-pic:-KPIC}}}" 311182627Sobrien 312182627Sobrien/* -G is incompatible with -KPIC which is the default, so only allow objects 313182627Sobrien in the small data section if the user explicitly asks for it. */ 314182627Sobrien 315182627Sobrien#undef MIPS_DEFAULT_GVALUE 316182627Sobrien#define MIPS_DEFAULT_GVALUE 0 317182627Sobrien 318182627Sobrien/* If defined, a C expression whose value is a string containing the 319182627Sobrien assembler operation to identify the following data as 320182627Sobrien uninitialized global data. If not defined, and neither 321182627Sobrien `ASM_OUTPUT_BSS' nor `ASM_OUTPUT_ALIGNED_BSS' are defined, 322182627Sobrien uninitialized global data will be output in the data section if 323182627Sobrien `-fno-common' is passed, otherwise `ASM_OUTPUT_COMMON' will be 324182627Sobrien used. */ 325182627Sobrien#undef BSS_SECTION_ASM_OP 326182627Sobrien#define BSS_SECTION_ASM_OP "\t.section\t.bss" 327182627Sobrien 328182627Sobrien/* Like `ASM_OUTPUT_BSS' except takes the required alignment as a 329182627Sobrien separate, explicit argument. If you define this macro, it is used 330182627Sobrien in place of `ASM_OUTPUT_BSS', and gives you more flexibility in 331182627Sobrien handling the required alignment of the variable. The alignment is 332182627Sobrien specified as the number of bits. 333182627Sobrien 334182627Sobrien Try to use function `asm_output_aligned_bss' defined in file 335182627Sobrien `varasm.c' when defining this macro. */ 336182627Sobrien#undef ASM_OUTPUT_ALIGNED_BSS 337182627Sobrien#define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \ 338182627Sobrien asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN) 339182627Sobrien 340182627Sobrien/* Standard AT&T UNIX 'as' local label spelling. */ 341182627Sobrien#undef LOCAL_LABEL_PREFIX 342182627Sobrien#define LOCAL_LABEL_PREFIX "." 343182627Sobrien 344204549Simp/* Currently we don't support 128bit long doubles, so for now we force 345204549Simp n32 to be 64bit. */ 346204549Simp#undef LONG_DOUBLE_TYPE_SIZE 347204549Simp#define LONG_DOUBLE_TYPE_SIZE 64 348204549Simp 349204549Simp#ifdef IN_LIBGCC2 350204549Simp#undef LIBGCC2_LONG_DOUBLE_TYPE_SIZE 351204549Simp#define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64 352204549Simp#endif 353182627Sobrien 354182627Sobrien/************************[ Debugger stuff ]*********************************/ 355233397Sgonzo#undef DBX_DEBUGGING_INFO 356233397Sgonzo#undef MIPS_DEBUGGING_INFO 357