]>
git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/config/sparc/sol2.h
1 /* Definitions of target machine for GCC, for SPARC running Solaris 2
2 Copyright (C) 1992-2020 Free Software Foundation, Inc.
3 Contributed by Ron Guilmette (rfg@netcom.com).
4 Additional changes by David V. Henkel-Wallace (gumby@cygnus.com).
6 This file is part of GCC.
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)
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.
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/>. */
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. */
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)
31 #define TARGET_DEFAULT \
32 (MASK_V8PLUS + MASK_APP_REGS + MASK_FPU + MASK_LONG_DOUBLE_128)
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
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.
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)
54 /* Supposedly the same as vanilla sparc svr4, except for the stuff below: */
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. */
61 #define AS_SPARC32_FLAG ""
62 #define AS_SPARC64_FLAG ""
65 #undef ASM_ARCH32_SPEC
66 #define ASM_ARCH32_SPEC "-m32"
67 #undef ASM_ARCH64_SPEC
68 #define ASM_ARCH64_SPEC "-m64"
71 /* Both Sun as and GNU as understand -K PIC. */
73 #define ASM_SPEC ASM_SPEC_BASE " %(asm_arch)" ASM_PIC_SPEC
75 #else /* HAVE_AS_SPARC4 */
77 #define AS_SPARC32_FLAG "-xarch=v8plus"
78 #define AS_SPARC64_FLAG "-xarch=v9"
80 #undef AS_NIAGARA4_FLAG
81 #define AS_NIAGARA4_FLAG AS_NIAGARA3_FLAG
83 #undef ASM_ARCH32_SPEC
84 #define ASM_ARCH32_SPEC ""
86 #undef ASM_ARCH64_SPEC
87 #define ASM_ARCH64_SPEC ""
89 #undef ASM_ARCH_DEFAULT_SPEC
90 #define ASM_ARCH_DEFAULT_SPEC ""
93 #define ASM_ARCH_SPEC ""
95 /* Both Sun as and GNU as understand -K PIC. */
97 #define ASM_SPEC ASM_SPEC_BASE ASM_PIC_SPEC
99 #endif /* HAVE_AS_SPARC4 */
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"
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"
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"
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"
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"
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"
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
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
168 #if TARGET_CPU_DEFAULT == TARGET_CPU_niagara7
169 #undef CPP_CPU64_DEFAULT_SPEC
170 #define CPP_CPU64_DEFAULT_SPEC ""
171 #undef ASM_CPU32_DEFAULT_SPEC
172 #define ASM_CPU32_DEFAULT_SPEC AS_SPARC32_FLAG AS_NIAGARA7_FLAG
173 #undef ASM_CPU64_DEFAULT_SPEC
174 #define ASM_CPU64_DEFAULT_SPEC AS_SPARC64_FLAG AS_NIAGARA7_FLAG
177 #if TARGET_CPU_DEFAULT == TARGET_CPU_m8
178 #undef CPP_CPU64_DEFAULT_SPEC
179 #define CPP_CPU64_DEFAULT_SPEC ""
180 #undef ASM_CPU32_DEFAULT_SPEC
181 #define ASM_CPU32_DEFAULT_SPEC AS_SPARC32_FLAG AS_M8_FLAG
182 #undef ASM_CPU64_DEFAULT_SPEC
183 #define ASM_CPU64_DEFAULT_SPEC AS_SPARC64_FLAG AS_M8_FLAG
187 #define CPP_CPU_SPEC "\
188 %{mcpu=sparclet|mcpu=tsc701:-D__sparclet__} \
189 %{mcpu=sparclite|mcpu-f930|mcpu=f934:-D__sparclite__} \
190 %{mcpu=v8:" DEF_ARCH32_SPEC("-D__sparcv8") "} \
191 %{mcpu=supersparc:-D__supersparc__ " DEF_ARCH32_SPEC("-D__sparcv8") "} \
192 %{mcpu=v9|mcpu=ultrasparc|mcpu=ultrasparc3|mcpu=niagara|mcpu=niagara2|mcpu=niagara3|mcpu=niagara4|mcpu=niagara7|mcpu=m8:" DEF_ARCH32_SPEC("-D__sparcv8") "} \
193 %{!mcpu*:%(cpp_cpu_default)} \
196 #undef CPP_CPU_DEFAULT_SPEC
197 #define CPP_CPU_DEFAULT_SPEC \
198 (DEFAULT_ARCH32_P ? "\
199 %{m64:" CPP_CPU64_DEFAULT_SPEC "} \
200 %{!m64:" CPP_CPU32_DEFAULT_SPEC "} \
202 %{m32:" CPP_CPU32_DEFAULT_SPEC "} \
203 %{!m32:" CPP_CPU64_DEFAULT_SPEC "} \
206 #undef CPP_ARCH32_SPEC
207 #define CPP_ARCH32_SPEC ""
208 #undef CPP_ARCH64_SPEC
209 #define CPP_ARCH64_SPEC "-D__arch64__ -D__sparcv9"
212 #define CPP_ARCH_SPEC "\
213 %{m32:%(cpp_arch32)} \
214 %{m64:%(cpp_arch64)} \
215 %{!m32:%{!m64:%(cpp_arch_default)}} \
218 /* -mcpu=native handling only makes sense with compiler running on
220 #if defined(__sparc__) && defined(__SVR4)
221 extern const char *host_detect_local_cpu (int argc
, const char **argv
);
222 # define EXTRA_SPEC_FUNCTIONS \
223 { "local_cpu_detect", host_detect_local_cpu },
225 # define MCPU_MTUNE_NATIVE_SPECS \
226 " %{mcpu=native:%<mcpu=native %:local_cpu_detect(cpu)}" \
227 " %{mtune=native:%<mtune=native %:local_cpu_detect(tune)}"
229 # define MCPU_MTUNE_NATIVE_SPECS ""
232 #define DRIVER_SELF_SPECS MCPU_MTUNE_NATIVE_SPECS
237 %{m64:%{m32:%emay not use both -m32 and -m64}} \
238 %{m64:-mptr64 -mstack-bias -mno-v8plus \
239 %{!mcpu*:-%{!mv8plus:mcpu=v9}}} \
243 %{m32:%{m64:%emay not use both -m32 and -m64}} \
244 %{m32:-mptr32 -mno-stack-bias \
245 %{!mcpu*:%{!mv8plus:-mcpu=v9}}} \
246 %{mv8plus:-m32 -mptr32 -mno-stack-bias \
247 %{!mcpu*:-mcpu=v9}} \
251 /* Support for a compile-time default CPU, et cetera. The rules are:
252 --with-cpu is ignored if -mcpu is specified; likewise --with-cpu-32
254 --with-tune is ignored if -mtune is specified; likewise --with-tune-32
256 --with-float is ignored if -mhard-float, -msoft-float, -mfpu, or -mno-fpu
258 In the SPARC_BI_ARCH compiler we cannot pass %{!mcpu=*:-mcpu=%(VALUE)}
259 here, otherwise say -mcpu=v7 would be passed even when -m64.
260 CC1_SPEC above takes care of this instead.
262 Note that the order of the cpu* and tune* options matters: the
263 config.gcc file always sets with_cpu to some value, even if the
264 user didn't use --with-cpu when invoking the configure script.
265 This value is based on the target name. Therefore we have to make
266 sure that --with-cpu-32 takes precedence to --with-cpu in < v9
267 systems, and that --with-cpu-64 takes precedence to --with-cpu in
268 >= v9 systems. As for the tune* options, in some platforms
269 config.gcc also sets a default value for it if the user didn't use
270 --with-tune when invoking the configure script. */
271 #undef OPTION_DEFAULT_SPECS
273 #define OPTION_DEFAULT_SPECS \
274 {"cpu_32", "%{!m64:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
275 {"cpu_64", "%{m64:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
276 {"cpu", "%{!m64:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
277 {"tune_32", "%{!m64:%{!mtune=*:-mtune=%(VALUE)}}" }, \
278 {"tune_64", "%{m64:%{!mtune=*:-mtune=%(VALUE)}}" }, \
279 {"tune", "%{!mtune=*:-mtune=%(VALUE)}" }, \
280 {"float", "%{!msoft-float:%{!mhard-float:%{!mfpu:%{!mno-fpu:-m%(VALUE)-float}}}}" }
282 #define OPTION_DEFAULT_SPECS \
283 {"cpu_32", "%{m32:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
284 {"cpu_64", "%{!m32:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
285 {"cpu", "%{!m32:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
286 {"tune_32", "%{m32:%{!mtune=*:-mtune=%(VALUE)}}" }, \
287 {"tune_64", "%{!m32:%{!mtune=*:-mtune=%(VALUE)}}" }, \
288 {"tune", "%{!mtune=*:-mtune=%(VALUE)}" }, \
289 {"float", "%{!msoft-float:%{!mhard-float:%{!mfpu:%{!mno-fpu:-m%(VALUE)-float}}}}" }
293 #define ASM_CPU_SPEC "\
294 %{mcpu=v9:" DEF_ARCH32_SPEC("-xarch=v8plus") DEF_ARCH64_SPEC("-xarch=v9") "} \
295 %{mcpu=ultrasparc:" DEF_ARCH32_SPEC("-xarch=v8plusa") DEF_ARCH64_SPEC("-xarch=v9a") "} \
296 %{mcpu=ultrasparc3:" DEF_ARCH32_SPEC("-xarch=v8plusb") DEF_ARCH64_SPEC("-xarch=v9b") "} \
297 %{mcpu=niagara:" DEF_ARCH32_SPEC("-xarch=v8plusb") DEF_ARCH64_SPEC("-xarch=v9b") "} \
298 %{mcpu=niagara2:" DEF_ARCH32_SPEC("-xarch=v8plusb") DEF_ARCH64_SPEC("-xarch=v9b") "} \
299 %{mcpu=niagara3:" DEF_ARCH32_SPEC("-xarch=v8plus" AS_NIAGARA3_FLAG) DEF_ARCH64_SPEC("-xarch=v9" AS_NIAGARA3_FLAG) "} \
300 %{mcpu=niagara4:" DEF_ARCH32_SPEC(AS_SPARC32_FLAG AS_NIAGARA4_FLAG) DEF_ARCH64_SPEC(AS_SPARC64_FLAG AS_NIAGARA4_FLAG) "} \
301 %{mcpu=niagara7:" DEF_ARCH32_SPEC(AS_SPARC32_FLAG AS_NIAGARA7_FLAG) DEF_ARCH64_SPEC(AS_SPARC64_FLAG AS_NIAGARA7_FLAG) "} \
302 %{mcpu=m8:" DEF_ARCH32_SPEC(AS_SPARC32_FLAG AS_M8_FLAG) DEF_ARCH64_SPEC(AS_SPARC64_FLAG AS_M8_FLAG) "} \
303 %{!mcpu=m8:%{!mcpu=niagara7:%{!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") "}}}}}}}}}} \
304 %{!mcpu*:%(asm_cpu_default)} \
308 /* Since binutils 2.21, GNU ld supports new *_sol2 emulations to strictly
309 follow the Solaris 2 ABI. Prefer them if present. */
310 #ifdef HAVE_LD_SOL2_EMULATION
311 #define ARCH32_EMULATION "elf32_sparc_sol2"
312 #define ARCH64_EMULATION "elf64_sparc_sol2"
314 #define ARCH32_EMULATION "elf32_sparc"
315 #define ARCH64_EMULATION "elf64_sparc"
319 #define ARCH64_SUBDIR "sparcv9"
321 #define SUBTARGET_CPU_EXTRA_SPECS
323 #define ENDFILE_ARCH_SPEC ""
325 /* -fsanitize=address is currently only supported for 32-bit. */
326 #define ASAN_REJECT_SPEC \
327 DEF_ARCH64_SPEC("%e-fsanitize=address is not supported in this configuration")
330 /* Register the Solaris-specific #pragma directives. */
331 #define REGISTER_TARGET_PRAGMAS() solaris_register_pragmas ()
333 #if defined(USE_GAS) && defined(HAVE_AS_TLS)
334 /* Use GNU extensions to TLS support. */
335 #undef TARGET_SUN_TLS
336 #undef TARGET_GNU_TLS
337 #define TARGET_SUN_TLS 0
338 #define TARGET_GNU_TLS 1
341 #undef LOCAL_LABEL_PREFIX
342 #define LOCAL_LABEL_PREFIX "."
344 /* The Solaris 2 assembler uses .skip, not .zero, so put this back. */
345 #undef ASM_OUTPUT_SKIP
346 #define ASM_OUTPUT_SKIP(FILE,SIZE) \
347 fprintf (FILE, "\t.skip %u\n", (int)(SIZE))
349 /* This is how to store into the string LABEL
350 the symbol_ref name of an internal numbered label where
351 PREFIX is the class of label and NUM is the number within the class.
352 This is suitable for output with `assemble_name'. */
354 #undef ASM_GENERATE_INTERNAL_LABEL
355 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \
356 sprintf ((LABEL), "*.L%s%lu", (PREFIX), (unsigned long)(NUM))
358 /* The native TLS-enabled assembler requires the directive #tls_object
359 to be put on objects in TLS sections (as of v7.1). This is not
360 required by GNU as but supported on SPARC. */
361 #undef ASM_DECLARE_OBJECT_NAME
362 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \
365 HOST_WIDE_INT size; \
367 if (targetm.have_tls && DECL_THREAD_LOCAL_P (DECL)) \
368 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "tls_object"); \
370 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object"); \
372 size_directive_output = 0; \
373 if (!flag_inhibit_size_directive \
374 && (DECL) && DECL_SIZE (DECL)) \
376 size_directive_output = 1; \
377 size = int_size_in_bytes (TREE_TYPE (DECL)); \
378 ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, size); \
381 ASM_OUTPUT_LABEL (FILE, NAME); \
385 /* Output a simple call for .init/.fini. */
386 #define ASM_OUTPUT_CALL(FILE, FN) \
389 fprintf (FILE, "\tcall\t"); \
390 targetm.asm_out.print_operand (FILE, XEXP (DECL_RTL (FN), 0), 0); \
391 fprintf (FILE, "\n\tnop\n"); \
395 /* Solaris as has a bug: a .common directive in .tbss or .tdata section
396 behaves as .tls_common rather than normal non-TLS .common. */
397 #undef ASM_OUTPUT_ALIGNED_COMMON
398 #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \
403 && ((in_section->common.flags & SECTION_TLS) == SECTION_TLS)) \
404 switch_to_section (bss_section); \
405 fprintf ((FILE), "%s", COMMON_ASM_OP); \
406 assemble_name ((FILE), (NAME)); \
407 fprintf ((FILE), "," HOST_WIDE_INT_PRINT_UNSIGNED",%u\n", \
408 (SIZE), (ALIGN) / BITS_PER_UNIT); \
413 /* This is how to output an assembler line that says to advance
414 the location counter to a multiple of 2**LOG bytes using the
415 NOP instruction as padding. The filler pattern doesn't work
417 #define ASM_OUTPUT_ALIGN_WITH_NOP(FILE,LOG) \
419 fprintf (FILE, "\t.align %d,0x1000000\n", (1 << (LOG)))
421 /* Use Solaris ELF section syntax with Sun as. */
422 #undef TARGET_ASM_NAMED_SECTION
423 #define TARGET_ASM_NAMED_SECTION sparc_solaris_elf_asm_named_section
425 /* Sun as requires doublequoted section names on SPARC. While GNU as
426 supports that, too, we prefer the standard variant. */
427 #define SECTION_NAME_FORMAT "\"%s\""
428 #endif /* !USE_GAS */
430 /* Undefine this so that attribute((init_priority)) works with GNU ld. */
432 #undef CTORS_SECTION_ASM_OP
433 #undef DTORS_SECTION_ASM_OP
438 /* Define for support of TFmode long double.
439 SPARC ABI says that long double is 4 words. */
440 #define LONG_DOUBLE_TYPE_SIZE 128
442 /* Solaris's _Qp_* library routine implementation clobbers the output
443 memory before the inputs are fully consumed. */
445 #undef TARGET_BUGGY_QP_LIB
446 #define TARGET_BUGGY_QP_LIB 1
448 #undef SUN_CONVERSION_LIBFUNCS
449 #define SUN_CONVERSION_LIBFUNCS 1
451 #undef DITF_CONVERSION_LIBFUNCS
452 #define DITF_CONVERSION_LIBFUNCS 1
454 #undef SUN_INTEGER_MULTIPLY_64
455 #define SUN_INTEGER_MULTIPLY_64 1
457 #undef SPARC_LOW_FE_EXCEPT_VALUES
458 #define SPARC_LOW_FE_EXCEPT_VALUES 1