gcc/ada/
[official-gcc.git] / gcc / config / sparc / sol2.h
blob2fcdc85c81f509bd07004511d3a751ed5aabd7b5
1 /* Definitions of target machine for GCC, for SPARC running Solaris 2
2 Copyright (C) 1992-2014 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)
11 any later version.
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. */
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
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)
50 #endif
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. */
59 #ifdef HAVE_AS_SPARC4
61 #define AS_SPARC32_FLAG ""
62 #define AS_SPARC64_FLAG ""
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
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
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 ""
92 #undef ASM_ARCH_SPEC
93 #define ASM_ARCH_SPEC ""
95 /* Both Sun as and GNU as understand -K PIC. */
96 #undef ASM_SPEC
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"
112 #endif
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
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
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
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
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
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
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)} \
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 "} \
188 #undef CPP_ARCH32_SPEC
189 #define CPP_ARCH32_SPEC ""
190 #undef CPP_ARCH64_SPEC
191 #define CPP_ARCH64_SPEC "-D__arch64__ -D__sparcv9"
193 #undef CPP_ARCH_SPEC
194 #define CPP_ARCH_SPEC "\
195 %{m32:%(cpp_arch32)} \
196 %{m64:%(cpp_arch64)} \
197 %{!m32:%{!m64:%(cpp_arch_default)}} \
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 },
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
214 #define DRIVER_SELF_SPECS MCPU_MTUNE_NATIVE_SPECS
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}}} \
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}} \
231 #endif
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
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)} \
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
279 #define ARCH64_SUBDIR "sparcv9"
281 #define SUBTARGET_CPU_EXTRA_SPECS
285 /* Register the Solaris-specific #pragma directives. */
286 #define REGISTER_TARGET_PRAGMAS() solaris_register_pragmas ()
288 #if defined(USE_GAS) && defined(HAVE_AS_TLS)
289 /* Use GNU extensions to TLS support. */
290 #undef TARGET_SUN_TLS
291 #undef TARGET_GNU_TLS
292 #define TARGET_SUN_TLS 0
293 #define TARGET_GNU_TLS 1
294 #endif
296 #undef LOCAL_LABEL_PREFIX
297 #define LOCAL_LABEL_PREFIX "."
299 /* The Solaris 2 assembler uses .skip, not .zero, so put this back. */
300 #undef ASM_OUTPUT_SKIP
301 #define ASM_OUTPUT_SKIP(FILE,SIZE) \
302 fprintf (FILE, "\t.skip %u\n", (int)(SIZE))
304 /* This is how to store into the string LABEL
305 the symbol_ref name of an internal numbered label where
306 PREFIX is the class of label and NUM is the number within the class.
307 This is suitable for output with `assemble_name'. */
309 #undef ASM_GENERATE_INTERNAL_LABEL
310 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \
311 sprintf ((LABEL), "*.L%s%lu", (PREFIX), (unsigned long)(NUM))
313 /* The native TLS-enabled assembler requires the directive #tls_object
314 to be put on objects in TLS sections (as of v7.1). This is not
315 required by GNU as but supported on SPARC. */
316 #undef ASM_DECLARE_OBJECT_NAME
317 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \
318 do \
320 HOST_WIDE_INT size; \
322 if (targetm.have_tls && DECL_THREAD_LOCAL_P (DECL)) \
323 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "tls_object"); \
324 else \
325 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object"); \
327 size_directive_output = 0; \
328 if (!flag_inhibit_size_directive \
329 && (DECL) && DECL_SIZE (DECL)) \
331 size_directive_output = 1; \
332 size = int_size_in_bytes (TREE_TYPE (DECL)); \
333 ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, size); \
336 ASM_OUTPUT_LABEL (FILE, NAME); \
338 while (0)
340 /* Output a simple call for .init/.fini. */
341 #define ASM_OUTPUT_CALL(FILE, FN) \
342 do \
344 fprintf (FILE, "\tcall\t"); \
345 targetm.asm_out.print_operand (FILE, XEXP (DECL_RTL (FN), 0), 0); \
346 fprintf (FILE, "\n\tnop\n"); \
348 while (0)
350 /* Solaris as has a bug: a .common directive in .tbss or .tdata section
351 behaves as .tls_common rather than normal non-TLS .common. */
352 #undef ASM_OUTPUT_ALIGNED_COMMON
353 #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \
354 do \
356 if (TARGET_SUN_TLS \
357 && in_section \
358 && ((in_section->common.flags & SECTION_TLS) == SECTION_TLS)) \
359 switch_to_section (bss_section); \
360 fprintf ((FILE), "%s", COMMON_ASM_OP); \
361 assemble_name ((FILE), (NAME)); \
362 fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED",%u\n", \
363 (SIZE), (ALIGN) / BITS_PER_UNIT); \
365 while (0)
367 #ifndef USE_GAS
368 /* This is how to output an assembler line that says to advance
369 the location counter to a multiple of 2**LOG bytes using the
370 NOP instruction as padding. The filler pattern doesn't work
371 with GNU as. */
372 #define ASM_OUTPUT_ALIGN_WITH_NOP(FILE,LOG) \
373 if ((LOG) != 0) \
374 fprintf (FILE, "\t.align %d,0x1000000\n", (1<<(LOG)))
376 /* Use Solaris ELF section syntax with Sun as. */
377 #undef TARGET_ASM_NAMED_SECTION
378 #define TARGET_ASM_NAMED_SECTION sparc_solaris_elf_asm_named_section
380 /* Sun as requires doublequoted section names on SPARC. While GNU as
381 supports that, too, we prefer the standard variant. */
382 #define SECTION_NAME_FORMAT "\"%s\""
383 #endif /* !USE_GAS */
385 /* Undefine this so that attribute((init_priority)) works with GNU ld. */
386 #ifdef USE_GLD
387 #undef CTORS_SECTION_ASM_OP
388 #undef DTORS_SECTION_ASM_OP
389 #endif
393 /* Define for support of TFmode long double.
394 SPARC ABI says that long double is 4 words. */
395 #define LONG_DOUBLE_TYPE_SIZE 128
397 /* Solaris's _Qp_* library routine implementation clobbers the output
398 memory before the inputs are fully consumed. */
400 #undef TARGET_BUGGY_QP_LIB
401 #define TARGET_BUGGY_QP_LIB 1
403 #undef SUN_CONVERSION_LIBFUNCS
404 #define SUN_CONVERSION_LIBFUNCS 1
406 #undef DITF_CONVERSION_LIBFUNCS
407 #define DITF_CONVERSION_LIBFUNCS 1
409 #undef SUN_INTEGER_MULTIPLY_64
410 #define SUN_INTEGER_MULTIPLY_64 1
412 #undef SPARC_LOW_FE_EXCEPT_VALUES
413 #define SPARC_LOW_FE_EXCEPT_VALUES 1