1 /* Definitions of target machine for GNU compiler, for MIPS NetBSD systems. 2 Copyright (C) 1993, 1995, 1996, 1997, 1999, 2000, 2001, 2002, 2003, 2004, 3 2007 Free Software Foundation, Inc. 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 3, 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 COPYING3. If not see 19 <http://www.gnu.org/licenses/>. */ 20 21 22 /* Define default target values. */ 23 24 #undef MACHINE_TYPE 25 #if TARGET_ENDIAN_DEFAULT != 0 26 #define MACHINE_TYPE "NetBSD/mipseb ELF" 27 #else 28 #define MACHINE_TYPE "NetBSD/mipsel ELF" 29 #endif 30 31 #define TARGET_OS_CPP_BUILTINS() \ 32 do \ 33 { \ 34 NETBSD_OS_CPP_BUILTINS_ELF(); \ 35 builtin_define ("__NO_LEADING_UNDERSCORES__"); \ 36 builtin_define ("__GP_SUPPORT__"); \ 37 if (TARGET_LONG64) \ 38 builtin_define ("__LONG64"); \ 39 \ 40 if (TARGET_ABICALLS) \ 41 builtin_define ("__ABICALLS__"); \ 42 \ 43 /* The GNU C++ standard library requires this. */ \ 44 if (c_dialect_cxx ()) \ 45 builtin_define ("_GNU_SOURCE"); \ 46 \ 47 if (mips_abi == ABI_N32) \ 48 { \ 49 builtin_define ("__mips_n32"); \ 50 builtin_define ("_ABIN32=2"); \ 51 builtin_define ("_MIPS_SIM=_ABIN32"); \ 52 builtin_define ("_MIPS_SZLONG=32"); \ 53 builtin_define ("_MIPS_SZPTR=32"); \ 54 } \ 55 else if (mips_abi == ABI_64) \ 56 { \ 57 builtin_define ("__mips_n64"); \ 58 builtin_define ("_ABI64=3"); \ 59 builtin_define ("_MIPS_SIM=_ABI64"); \ 60 builtin_define ("_MIPS_SZLONG=64"); \ 61 builtin_define ("_MIPS_SZPTR=64"); \ 62 } \ 63 else if (mips_abi == ABI_O64) \ 64 { \ 65 builtin_define ("__mips_o64"); \ 66 builtin_define ("_ABIO64=4"); \ 67 builtin_define ("_MIPS_SIM=_ABIO64"); \ 68 builtin_define ("_MIPS_SZLONG=64"); \ 69 builtin_define ("_MIPS_SZPTR=64"); \ 70 } \ 71 else if (mips_abi == ABI_EABI) \ 72 { \ 73 builtin_define ("__mips_eabi"); \ 74 builtin_define ("_ABIEMB=5"); \ 75 builtin_define ("_MIPS_SIM=_ABIEMB"); \ 76 if (TARGET_LONG64) \ 77 builtin_define ("_MIPS_SZLONG=64"); \ 78 else \ 79 builtin_define ("_MIPS_SZLONG=32"); \ 80 if (TARGET_64BIT) \ 81 builtin_define ("_MIPS_SZPTR=64"); \ 82 else \ 83 builtin_define ("_MIPS_SZPTR=32"); \ 84 } \ 85 else \ 86 { \ 87 builtin_define ("__mips_o32"); \ 88 builtin_define ("_ABIO32=1"); \ 89 builtin_define ("_MIPS_SIM=_ABIO32"); \ 90 builtin_define ("_MIPS_SZLONG=32"); \ 91 builtin_define ("_MIPS_SZPTR=32"); \ 92 } \ 93 if (TARGET_FLOAT64) \ 94 builtin_define ("_MIPS_FPSET=32"); \ 95 else \ 96 builtin_define ("_MIPS_FPSET=16"); \ 97 \ 98 builtin_define ("_MIPS_SZINT=32"); \ 99 } while (0) 100 101 /* The generic MIPS TARGET_CPU_CPP_BUILTINS are incorrect for NetBSD. 102 Specifically, they define too many namespace-invasive macros. Override 103 them here. Note this is structured for easy comparison to the version 104 in mips.h. 105 106 FIXME: This probably isn't the best solution. But in the absence 107 of something better, it will have to do, for now. */ 108 109 #undef TARGET_CPU_CPP_BUILTINS 110 #define TARGET_CPU_CPP_BUILTINS() \ 111 do \ 112 { \ 113 builtin_assert ("cpu=mips"); \ 114 builtin_define ("__mips__"); \ 115 builtin_define ("_mips"); \ 116 \ 117 /* No _R3000 or _R4000. */ \ 118 if (TARGET_64BIT) \ 119 builtin_define ("__mips64"); \ 120 \ 121 if (TARGET_FLOAT64) \ 122 builtin_define ("__mips_fpr=64"); \ 123 else \ 124 builtin_define ("__mips_fpr=32"); \ 125 \ 126 if (TARGET_MIPS16) \ 127 builtin_define ("__mips16"); \ 128 \ 129 MIPS_CPP_SET_PROCESSOR ("_MIPS_ARCH", mips_arch_info); \ 130 MIPS_CPP_SET_PROCESSOR ("_MIPS_TUNE", mips_tune_info); \ 131 \ 132 if (ISA_MIPS1) \ 133 builtin_define ("__mips=1"); \ 134 else if (ISA_MIPS2) \ 135 builtin_define ("__mips=2"); \ 136 else if (ISA_MIPS3) \ 137 builtin_define ("__mips=3"); \ 138 else if (ISA_MIPS4) \ 139 builtin_define ("__mips=4"); \ 140 else if (ISA_MIPS32) \ 141 { \ 142 builtin_define ("__mips=32"); \ 143 builtin_define ("__mips_isa_rev=1"); \ 144 } \ 145 else if (ISA_MIPS32R2) \ 146 { \ 147 builtin_define ("__mips=32"); \ 148 builtin_define ("__mips_isa_rev=2"); \ 149 } \ 150 else if (ISA_MIPS64) \ 151 { \ 152 builtin_define ("__mips=64"); \ 153 builtin_define ("__mips_isa_rev=1"); \ 154 } \ 155 else if (ISA_MIPS64R2) \ 156 { \ 157 builtin_define ("__mips=64"); \ 158 builtin_define ("__mips_isa_rev=2"); \ 159 } \ 160 \ 161 if (TARGET_HARD_FLOAT) \ 162 builtin_define ("__mips_hard_float"); \ 163 else if (TARGET_SOFT_FLOAT) \ 164 builtin_define ("__mips_soft_float"); \ 165 \ 166 if (TARGET_SINGLE_FLOAT) \ 167 builtin_define ("__mips_single_float"); \ 168 \ 169 if (TARGET_BIG_ENDIAN) \ 170 builtin_define ("__MIPSEB__"); \ 171 else \ 172 builtin_define ("__MIPSEL__"); \ 173 \ 174 /* No language dialect defines. */ \ 175 \ 176 /* ABIs handled in TARGET_OS_CPP_BUILTINS. */ \ 177 } \ 178 while (0) 179 180 181 /* Clean up after the generic MIPS/ELF configuration. */ 182 #undef MD_EXEC_PREFIX 183 #undef MD_STARTFILE_PREFIX 184 185 /* Extra specs we need. */ 186 #undef SUBTARGET_EXTRA_SPECS 187 #define SUBTARGET_EXTRA_SPECS \ 188 { "netbsd_cpp_spec", NETBSD_CPP_SPEC }, \ 189 { "netbsd_link_spec", NETBSD_LINK_SPEC_ELF }, \ 190 { "netbsd_entry_point", NETBSD_ENTRY_POINT }, 191 192 /* Provide a SUBTARGET_CPP_SPEC appropriate for NetBSD. */ 193 194 #undef SUBTARGET_CPP_SPEC 195 #define SUBTARGET_CPP_SPEC "%(netbsd_cpp_spec)" 196 197 /* Provide a LINK_SPEC appropriate for a NetBSD/mips target. 198 This is a copy of LINK_SPEC from <netbsd-elf.h> tweaked for 199 the MIPS target. */ 200 201 #undef LINK_SPEC 202 #define LINK_SPEC \ 203 "%{EL:-m elf32ltsmip} \ 204 %{EB:-m elf32btsmip} \ 205 %(endian_spec) \ 206 %{G*} %{mips1} %{mips2} %{mips3} %{mips4} \ 207 %{mips32} %{mips32r2} %{mips64} %{mips64r2} \ 208 %{bestGnum} %{call_shared} %{no_archive} %{exact_version} \ 209 %(netbsd_link_spec)" 210 211 #define NETBSD_ENTRY_POINT "__start" 212 213 #undef SUBTARGET_ASM_SPEC 214 #define SUBTARGET_ASM_SPEC \ 215 "%{!mno-abicalls: \ 216 %{!fno-PIC:%{!fno-pic:-KPIC}}}" 217 218 219 /* -G is incompatible with -KPIC which is the default, so only allow objects 220 in the small data section if the user explicitly asks for it. */ 221 222 #undef MIPS_DEFAULT_GVALUE 223 #define MIPS_DEFAULT_GVALUE 0 224 225 226 /* This defines which switch letters take arguments. -G is a MIPS 227 special. */ 228 229 #undef SWITCH_TAKES_ARG 230 #define SWITCH_TAKES_ARG(CHAR) \ 231 (DEFAULT_SWITCH_TAKES_ARG (CHAR) \ 232 || (CHAR) == 'R' \ 233 || (CHAR) == 'G') 234 235 236 #undef ASM_FINAL_SPEC 237 #undef SET_ASM_OP 238 239 240 /* NetBSD hasn't historically provided _flush_cache(), but rather 241 _cacheflush(), which takes the same arguments as the former. */ 242 #undef CACHE_FLUSH_FUNC 243 #define CACHE_FLUSH_FUNC "_cacheflush" 244 245 246 /* Make gcc agree with <machine/ansi.h> */ 247 248 #undef SIZE_TYPE 249 #define SIZE_TYPE ((POINTER_SIZE == 64 || TARGET_NEWABI) \ 250 ? "long unsigned int" : "unsigned int") 251 252 #undef PTRDIFF_TYPE 253 #define PTRDIFF_TYPE ((POINTER_SIZE == 64 || TARGET_NEWABI) \ 254 ? "long int" : "int") 255 256 #undef WCHAR_TYPE 257 #define WCHAR_TYPE "int" 258 259 #undef WCHAR_TYPE_SIZE 260 #define WCHAR_TYPE_SIZE 32 261 262 #undef WINT_TYPE 263 #define WINT_TYPE "int" 264 265 #undef TARGET_WRITABLE_EH_FRAME 266 #define TARGET_WRITABLE_EH_FRAME (flag_pic && TARGET_SHARED) 267