1 /* Definitions of target machine for GCC, for SPARC running Solaris 2 2 Copyright (C) 1992-2015 Free Software Foundation, Inc. 3 Contributed by Ron Guilmette (rfg@netcom.com). 4 Additional changes by David V. Henkel-Wallace (gumby@cygnus.com). 5 6 This file is part of GCC. 7 8 GCC is free software; you can redistribute it and/or modify 9 it under the terms of the GNU General Public License as published by 10 the Free Software Foundation; either version 3, or (at your option) 11 any later version. 12 13 GCC is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 GNU General Public License for more details. 17 18 You should have received a copy of the GNU General Public License 19 along with GCC; see the file COPYING3. If not see 20 <http://www.gnu.org/licenses/>. */ 21 22 /* Solaris allows 64-bit out and global registers to be used in 32-bit mode. 23 sparc_override_options will disable V8+ if either not generating V9 code 24 or generating 64-bit code. */ 25 #undef TARGET_DEFAULT 26 #ifdef TARGET_64BIT_DEFAULT 27 #define TARGET_DEFAULT \ 28 (MASK_V9 + MASK_64BIT + MASK_PTR64 + MASK_STACK_BIAS + \ 29 MASK_V8PLUS + MASK_APP_REGS + MASK_FPU + MASK_LONG_DOUBLE_128) 30 #else 31 #define TARGET_DEFAULT \ 32 (MASK_V8PLUS + MASK_APP_REGS + MASK_FPU + MASK_LONG_DOUBLE_128) 33 #endif 34 35 /* The default code model used to be CM_MEDANY on Solaris 36 but even Sun eventually found it to be quite wasteful 37 and changed it to CM_MEDMID in the Studio 9 compiler. */ 38 #undef SPARC_DEFAULT_CMODEL 39 #define SPARC_DEFAULT_CMODEL CM_MEDMID 40 41 /* Select a format to encode pointers in exception handling data. CODE 42 is 0 for data, 1 for code labels, 2 for function pointers. GLOBAL is 43 true if the symbol may be affected by dynamic relocations. 44 45 Some Solaris dynamic linkers don't handle unaligned section relative 46 relocs properly, so force them to be aligned. */ 47 #ifndef HAVE_AS_SPARC_UA_PCREL 48 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL) \ 49 ((flag_pic || GLOBAL) ? DW_EH_PE_aligned : DW_EH_PE_absptr) 50 #endif 51 52 53 54 /* Supposedly the same as vanilla sparc svr4, except for the stuff below: */ 55 56 /* If the assembler supports -xarch=sparc4, we switch to the explicit 57 word size selection mechanism available both in GNU as and Sun as, 58 for the Niagara4 and above configurations. */ 59 #ifdef HAVE_AS_SPARC4 60 61 #define AS_SPARC32_FLAG "" 62 #define AS_SPARC64_FLAG "" 63 64 #ifndef USE_GAS 65 #undef ASM_ARCH32_SPEC 66 #define ASM_ARCH32_SPEC "-m32" 67 #undef ASM_ARCH64_SPEC 68 #define ASM_ARCH64_SPEC "-m64" 69 #endif 70 71 /* Both Sun as and GNU as understand -K PIC. */ 72 #undef ASM_SPEC 73 #define ASM_SPEC ASM_SPEC_BASE " %(asm_arch)" ASM_PIC_SPEC 74 75 #else /* HAVE_AS_SPARC4 */ 76 77 #define AS_SPARC32_FLAG "-xarch=v8plus" 78 #define AS_SPARC64_FLAG "-xarch=v9" 79 80 #undef AS_NIAGARA4_FLAG 81 #define AS_NIAGARA4_FLAG AS_NIAGARA3_FLAG 82 83 #undef ASM_ARCH32_SPEC 84 #define ASM_ARCH32_SPEC "" 85 86 #undef ASM_ARCH64_SPEC 87 #define ASM_ARCH64_SPEC "" 88 89 #undef ASM_ARCH_DEFAULT_SPEC 90 #define ASM_ARCH_DEFAULT_SPEC "" 91 92 #undef ASM_ARCH_SPEC 93 #define ASM_ARCH_SPEC "" 94 95 /* Both Sun as and GNU as understand -K PIC. */ 96 #undef ASM_SPEC 97 #define ASM_SPEC ASM_SPEC_BASE ASM_PIC_SPEC 98 99 #endif /* HAVE_AS_SPARC4 */ 100 101 102 #undef ASM_CPU32_DEFAULT_SPEC 103 #define ASM_CPU32_DEFAULT_SPEC "" 104 #undef ASM_CPU64_DEFAULT_SPEC 105 #define ASM_CPU64_DEFAULT_SPEC "-xarch=v9" 106 107 #if TARGET_CPU_DEFAULT == TARGET_CPU_v9 108 #undef CPP_CPU64_DEFAULT_SPEC 109 #define CPP_CPU64_DEFAULT_SPEC "" 110 #undef ASM_CPU32_DEFAULT_SPEC 111 #define ASM_CPU32_DEFAULT_SPEC "-xarch=v8plus" 112 #endif 113 114 #if TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc 115 #undef CPP_CPU64_DEFAULT_SPEC 116 #define CPP_CPU64_DEFAULT_SPEC "" 117 #undef ASM_CPU32_DEFAULT_SPEC 118 #define ASM_CPU32_DEFAULT_SPEC "-xarch=v8plusa" 119 #undef ASM_CPU64_DEFAULT_SPEC 120 #define ASM_CPU64_DEFAULT_SPEC "-xarch=v9a" 121 #endif 122 123 #if TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc3 124 #undef CPP_CPU64_DEFAULT_SPEC 125 #define CPP_CPU64_DEFAULT_SPEC "" 126 #undef ASM_CPU32_DEFAULT_SPEC 127 #define ASM_CPU32_DEFAULT_SPEC "-xarch=v8plusb" 128 #undef ASM_CPU64_DEFAULT_SPEC 129 #define ASM_CPU64_DEFAULT_SPEC "-xarch=v9b" 130 #endif 131 132 #if TARGET_CPU_DEFAULT == TARGET_CPU_niagara 133 #undef CPP_CPU64_DEFAULT_SPEC 134 #define CPP_CPU64_DEFAULT_SPEC "" 135 #undef ASM_CPU32_DEFAULT_SPEC 136 #define ASM_CPU32_DEFAULT_SPEC "-xarch=v8plusb" 137 #undef ASM_CPU64_DEFAULT_SPEC 138 #define ASM_CPU64_DEFAULT_SPEC "-xarch=v9b" 139 #endif 140 141 #if TARGET_CPU_DEFAULT == TARGET_CPU_niagara2 142 #undef CPP_CPU64_DEFAULT_SPEC 143 #define CPP_CPU64_DEFAULT_SPEC "" 144 #undef ASM_CPU32_DEFAULT_SPEC 145 #define ASM_CPU32_DEFAULT_SPEC "-xarch=v8plusb" 146 #undef ASM_CPU64_DEFAULT_SPEC 147 #define ASM_CPU64_DEFAULT_SPEC "-xarch=v9b" 148 #endif 149 150 #if TARGET_CPU_DEFAULT == TARGET_CPU_niagara3 151 #undef CPP_CPU64_DEFAULT_SPEC 152 #define CPP_CPU64_DEFAULT_SPEC "" 153 #undef ASM_CPU32_DEFAULT_SPEC 154 #define ASM_CPU32_DEFAULT_SPEC "-xarch=v8plus" AS_NIAGARA3_FLAG 155 #undef ASM_CPU64_DEFAULT_SPEC 156 #define ASM_CPU64_DEFAULT_SPEC "-xarch=v9" AS_NIAGARA3_FLAG 157 #endif 158 159 #if TARGET_CPU_DEFAULT == TARGET_CPU_niagara4 160 #undef CPP_CPU64_DEFAULT_SPEC 161 #define CPP_CPU64_DEFAULT_SPEC "" 162 #undef ASM_CPU32_DEFAULT_SPEC 163 #define ASM_CPU32_DEFAULT_SPEC AS_SPARC32_FLAG AS_NIAGARA4_FLAG 164 #undef ASM_CPU64_DEFAULT_SPEC 165 #define ASM_CPU64_DEFAULT_SPEC AS_SPARC64_FLAG AS_NIAGARA4_FLAG 166 #endif 167 168 #undef CPP_CPU_SPEC 169 #define CPP_CPU_SPEC "\ 170 %{mcpu=sparclet|mcpu=tsc701:-D__sparclet__} \ 171 %{mcpu=sparclite|mcpu-f930|mcpu=f934:-D__sparclite__} \ 172 %{mcpu=v8:" DEF_ARCH32_SPEC("-D__sparcv8") "} \ 173 %{mcpu=supersparc:-D__supersparc__ " DEF_ARCH32_SPEC("-D__sparcv8") "} \ 174 %{mcpu=v9|mcpu=ultrasparc|mcpu=ultrasparc3|mcpu=niagara|mcpu=niagara2|mcpu=niagara3|mcpu=niagara4:" DEF_ARCH32_SPEC("-D__sparcv8") "} \ 175 %{!mcpu*:%(cpp_cpu_default)} \ 176 " 177 178 #undef CPP_CPU_DEFAULT_SPEC 179 #define CPP_CPU_DEFAULT_SPEC \ 180 (DEFAULT_ARCH32_P ? "\ 181 %{m64:" CPP_CPU64_DEFAULT_SPEC "} \ 182 %{!m64:" CPP_CPU32_DEFAULT_SPEC "} \ 183 " : "\ 184 %{m32:" CPP_CPU32_DEFAULT_SPEC "} \ 185 %{!m32:" CPP_CPU64_DEFAULT_SPEC "} \ 186 ") 187 188 #undef CPP_ARCH32_SPEC 189 #define CPP_ARCH32_SPEC "" 190 #undef CPP_ARCH64_SPEC 191 #define CPP_ARCH64_SPEC "-D__arch64__ -D__sparcv9" 192 193 #undef CPP_ARCH_SPEC 194 #define CPP_ARCH_SPEC "\ 195 %{m32:%(cpp_arch32)} \ 196 %{m64:%(cpp_arch64)} \ 197 %{!m32:%{!m64:%(cpp_arch_default)}} \ 198 " 199 200 /* -mcpu=native handling only makes sense with compiler running on 201 a SPARC chip. */ 202 #if defined(__sparc__) && defined(__SVR4) 203 extern const char *host_detect_local_cpu (int argc, const char **argv); 204 # define EXTRA_SPEC_FUNCTIONS \ 205 { "local_cpu_detect", host_detect_local_cpu }, 206 207 # define MCPU_MTUNE_NATIVE_SPECS \ 208 " %{mcpu=native:%<mcpu=native %:local_cpu_detect(cpu)}" \ 209 " %{mtune=native:%<mtune=native %:local_cpu_detect(tune)}" 210 #else 211 # define MCPU_MTUNE_NATIVE_SPECS "" 212 #endif 213 214 #define DRIVER_SELF_SPECS MCPU_MTUNE_NATIVE_SPECS 215 216 #undef CC1_SPEC 217 #if DEFAULT_ARCH32_P 218 #define CC1_SPEC "\ 219 %{m64:%{m32:%emay not use both -m32 and -m64}} \ 220 %{m64:-mptr64 -mstack-bias -mno-v8plus \ 221 %{!mcpu*:-%{!mv8plus:mcpu=v9}}} \ 222 " 223 #else 224 #define CC1_SPEC "\ 225 %{m32:%{m64:%emay not use both -m32 and -m64}} \ 226 %{m32:-mptr32 -mno-stack-bias \ 227 %{!mcpu*:%{!mv8plus:-mcpu=v9}}} \ 228 %{mv8plus:-m32 -mptr32 -mno-stack-bias \ 229 %{!mcpu*:-mcpu=v9}} \ 230 " 231 #endif 232 233 /* Support for a compile-time default CPU, et cetera. The rules are: 234 --with-cpu is ignored if -mcpu is specified. 235 --with-tune is ignored if -mtune is specified. 236 --with-float is ignored if -mhard-float, -msoft-float, -mfpu, or -mno-fpu 237 are specified. 238 In the SPARC_BI_ARCH compiler we cannot pass %{!mcpu=*:-mcpu=%(VALUE)} 239 here, otherwise say -mcpu=v7 would be passed even when -m64. 240 CC1_SPEC above takes care of this instead. */ 241 #undef OPTION_DEFAULT_SPECS 242 #if DEFAULT_ARCH32_P 243 #define OPTION_DEFAULT_SPECS \ 244 {"cpu", "%{!m64:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \ 245 {"tune", "%{!mtune=*:-mtune=%(VALUE)}" }, \ 246 {"float", "%{!msoft-float:%{!mhard-float:%{!mfpu:%{!mno-fpu:-m%(VALUE)-float}}}}" } 247 #else 248 #define OPTION_DEFAULT_SPECS \ 249 {"cpu", "%{!m32:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \ 250 {"tune", "%{!mtune=*:-mtune=%(VALUE)}" }, \ 251 {"float", "%{!msoft-float:%{!mhard-float:%{!mfpu:%{!mno-fpu:-m%(VALUE)-float}}}}" } 252 #endif 253 254 #undef ASM_CPU_SPEC 255 #define ASM_CPU_SPEC "\ 256 %{mcpu=v9:" DEF_ARCH32_SPEC("-xarch=v8plus") DEF_ARCH64_SPEC("-xarch=v9") "} \ 257 %{mcpu=ultrasparc:" DEF_ARCH32_SPEC("-xarch=v8plusa") DEF_ARCH64_SPEC("-xarch=v9a") "} \ 258 %{mcpu=ultrasparc3:" DEF_ARCH32_SPEC("-xarch=v8plusb") DEF_ARCH64_SPEC("-xarch=v9b") "} \ 259 %{mcpu=niagara:" DEF_ARCH32_SPEC("-xarch=v8plusb") DEF_ARCH64_SPEC("-xarch=v9b") "} \ 260 %{mcpu=niagara2:" DEF_ARCH32_SPEC("-xarch=v8plusb") DEF_ARCH64_SPEC("-xarch=v9b") "} \ 261 %{mcpu=niagara3:" DEF_ARCH32_SPEC("-xarch=v8plus" AS_NIAGARA3_FLAG) DEF_ARCH64_SPEC("-xarch=v9" AS_NIAGARA3_FLAG) "} \ 262 %{mcpu=niagara4:" DEF_ARCH32_SPEC(AS_SPARC32_FLAG AS_NIAGARA4_FLAG) DEF_ARCH64_SPEC(AS_SPARC64_FLAG AS_NIAGARA4_FLAG) "} \ 263 %{!mcpu=niagara4:%{!mcpu=niagara3:%{!mcpu=niagara2:%{!mcpu=niagara:%{!mcpu=ultrasparc3:%{!mcpu=ultrasparc:%{!mcpu=v9:%{mcpu*:" DEF_ARCH32_SPEC("-xarch=v8") DEF_ARCH64_SPEC("-xarch=v9") "}}}}}}}} \ 264 %{!mcpu*:%(asm_cpu_default)} \ 265 " 266 267 #ifdef USE_GLD 268 /* Since binutils 2.21, GNU ld supports new *_sol2 emulations to strictly 269 follow the Solaris 2 ABI. Prefer them if present. */ 270 #ifdef HAVE_LD_SOL2_EMULATION 271 #define ARCH32_EMULATION "elf32_sparc_sol2" 272 #define ARCH64_EMULATION "elf64_sparc_sol2" 273 #else 274 #define ARCH32_EMULATION "elf32_sparc" 275 #define ARCH64_EMULATION "elf64_sparc" 276 #endif 277 #endif 278 279 #define ARCH64_SUBDIR "sparcv9" 280 281 #define SUBTARGET_CPU_EXTRA_SPECS 282 283 #define ENDFILE_ARCH_SPEC "" 284 285 286 287 /* Register the Solaris-specific #pragma directives. */ 288 #define REGISTER_TARGET_PRAGMAS() solaris_register_pragmas () 289 290 #if defined(USE_GAS) && defined(HAVE_AS_TLS) 291 /* Use GNU extensions to TLS support. */ 292 #undef TARGET_SUN_TLS 293 #undef TARGET_GNU_TLS 294 #define TARGET_SUN_TLS 0 295 #define TARGET_GNU_TLS 1 296 #endif 297 298 #undef LOCAL_LABEL_PREFIX 299 #define LOCAL_LABEL_PREFIX "." 300 301 /* The Solaris 2 assembler uses .skip, not .zero, so put this back. */ 302 #undef ASM_OUTPUT_SKIP 303 #define ASM_OUTPUT_SKIP(FILE,SIZE) \ 304 fprintf (FILE, "\t.skip %u\n", (int)(SIZE)) 305 306 /* This is how to store into the string LABEL 307 the symbol_ref name of an internal numbered label where 308 PREFIX is the class of label and NUM is the number within the class. 309 This is suitable for output with `assemble_name'. */ 310 311 #undef ASM_GENERATE_INTERNAL_LABEL 312 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \ 313 sprintf ((LABEL), "*.L%s%lu", (PREFIX), (unsigned long)(NUM)) 314 315 /* The native TLS-enabled assembler requires the directive #tls_object 316 to be put on objects in TLS sections (as of v7.1). This is not 317 required by GNU as but supported on SPARC. */ 318 #undef ASM_DECLARE_OBJECT_NAME 319 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \ 320 do \ 321 { \ 322 HOST_WIDE_INT size; \ 323 \ 324 if (targetm.have_tls && DECL_THREAD_LOCAL_P (DECL)) \ 325 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "tls_object"); \ 326 else \ 327 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object"); \ 328 \ 329 size_directive_output = 0; \ 330 if (!flag_inhibit_size_directive \ 331 && (DECL) && DECL_SIZE (DECL)) \ 332 { \ 333 size_directive_output = 1; \ 334 size = int_size_in_bytes (TREE_TYPE (DECL)); \ 335 ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, size); \ 336 } \ 337 \ 338 ASM_OUTPUT_LABEL (FILE, NAME); \ 339 } \ 340 while (0) 341 342 /* Output a simple call for .init/.fini. */ 343 #define ASM_OUTPUT_CALL(FILE, FN) \ 344 do \ 345 { \ 346 fprintf (FILE, "\tcall\t"); \ 347 targetm.asm_out.print_operand (FILE, XEXP (DECL_RTL (FN), 0), 0); \ 348 fprintf (FILE, "\n\tnop\n"); \ 349 } \ 350 while (0) 351 352 /* Solaris as has a bug: a .common directive in .tbss or .tdata section 353 behaves as .tls_common rather than normal non-TLS .common. */ 354 #undef ASM_OUTPUT_ALIGNED_COMMON 355 #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \ 356 do \ 357 { \ 358 if (TARGET_SUN_TLS \ 359 && in_section \ 360 && ((in_section->common.flags & SECTION_TLS) == SECTION_TLS)) \ 361 switch_to_section (bss_section); \ 362 fprintf ((FILE), "%s", COMMON_ASM_OP); \ 363 assemble_name ((FILE), (NAME)); \ 364 fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED",%u\n", \ 365 (SIZE), (ALIGN) / BITS_PER_UNIT); \ 366 } \ 367 while (0) 368 369 #ifndef USE_GAS 370 /* This is how to output an assembler line that says to advance 371 the location counter to a multiple of 2**LOG bytes using the 372 NOP instruction as padding. The filler pattern doesn't work 373 with GNU as. */ 374 #define ASM_OUTPUT_ALIGN_WITH_NOP(FILE,LOG) \ 375 if ((LOG) != 0) \ 376 fprintf (FILE, "\t.align %d,0x1000000\n", (1<<(LOG))) 377 378 /* Use Solaris ELF section syntax with Sun as. */ 379 #undef TARGET_ASM_NAMED_SECTION 380 #define TARGET_ASM_NAMED_SECTION sparc_solaris_elf_asm_named_section 381 382 /* Sun as requires doublequoted section names on SPARC. While GNU as 383 supports that, too, we prefer the standard variant. */ 384 #define SECTION_NAME_FORMAT "\"%s\"" 385 #endif /* !USE_GAS */ 386 387 /* Undefine this so that attribute((init_priority)) works with GNU ld. */ 388 #ifdef USE_GLD 389 #undef CTORS_SECTION_ASM_OP 390 #undef DTORS_SECTION_ASM_OP 391 #endif 392 393 394 395 /* Define for support of TFmode long double. 396 SPARC ABI says that long double is 4 words. */ 397 #define LONG_DOUBLE_TYPE_SIZE 128 398 399 /* Solaris's _Qp_* library routine implementation clobbers the output 400 memory before the inputs are fully consumed. */ 401 402 #undef TARGET_BUGGY_QP_LIB 403 #define TARGET_BUGGY_QP_LIB 1 404 405 #undef SUN_CONVERSION_LIBFUNCS 406 #define SUN_CONVERSION_LIBFUNCS 1 407 408 #undef DITF_CONVERSION_LIBFUNCS 409 #define DITF_CONVERSION_LIBFUNCS 1 410 411 #undef SUN_INTEGER_MULTIPLY_64 412 #define SUN_INTEGER_MULTIPLY_64 1 413 414 #undef SPARC_LOW_FE_EXCEPT_VALUES 415 #define SPARC_LOW_FE_EXCEPT_VALUES 1 416