1 /* Definitions of target machine for GCC, for SPARC running Solaris 2
2 Copyright 1992, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2004, 2005,
3 2006, 2007, 2008, 2010, 2011 Free Software Foundation, Inc.
4 Contributed by Ron Guilmette (rfg@netcom.com).
5 Additional changes by David V. Henkel-Wallace (gumby@cygnus.com).
7 This file is part of GCC.
9 GCC is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3, or (at your option)
14 GCC is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with GCC; see the file COPYING3. If not see
21 <http://www.gnu.org/licenses/>. */
23 /* Solaris allows 64-bit out and global registers to be used in 32-bit mode.
24 sparc_override_options will disable V8+ if either not generating V9 code
25 or generating 64-bit code. */
27 #ifdef TARGET_64BIT_DEFAULT
28 #define TARGET_DEFAULT \
29 (MASK_V9 + MASK_64BIT + MASK_PTR64 + MASK_STACK_BIAS + \
30 MASK_V8PLUS + MASK_APP_REGS + MASK_FPU + MASK_LONG_DOUBLE_128)
32 #define TARGET_DEFAULT \
33 (MASK_V8PLUS + MASK_APP_REGS + MASK_FPU + MASK_LONG_DOUBLE_128)
36 /* The default code model used to be CM_MEDANY on Solaris
37 but even Sun eventually found it to be quite wasteful
38 and changed it to CM_MEDMID in the Studio 9 compiler. */
39 #undef SPARC_DEFAULT_CMODEL
40 #define SPARC_DEFAULT_CMODEL CM_MEDMID
42 /* Select a format to encode pointers in exception handling data. CODE
43 is 0 for data, 1 for code labels, 2 for function pointers. GLOBAL is
44 true if the symbol may be affected by dynamic relocations.
46 Some Solaris dynamic linkers don't handle unaligned section relative
47 relocs properly, so force them to be aligned. */
48 #ifndef HAVE_AS_SPARC_UA_PCREL
49 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL) \
50 ((flag_pic || GLOBAL) ? DW_EH_PE_aligned : DW_EH_PE_absptr)
55 /* Supposedly the same as vanilla sparc svr4, except for the stuff below: */
57 /* This is here rather than in sparc.h because it's not known what
58 other assemblers will accept. */
61 #define AS_SPARC64_FLAG "-xarch=v9"
63 #define AS_SPARC64_FLAG "-TSO -64 -Av9"
66 #undef ASM_CPU32_DEFAULT_SPEC
67 #define ASM_CPU32_DEFAULT_SPEC ""
68 #undef ASM_CPU64_DEFAULT_SPEC
69 #define ASM_CPU64_DEFAULT_SPEC AS_SPARC64_FLAG
71 #if TARGET_CPU_DEFAULT == TARGET_CPU_v9
72 #undef CPP_CPU64_DEFAULT_SPEC
73 #define CPP_CPU64_DEFAULT_SPEC ""
74 #undef ASM_CPU32_DEFAULT_SPEC
75 #define ASM_CPU32_DEFAULT_SPEC "-xarch=v8plus"
76 #undef ASM_CPU_DEFAULT_SPEC
77 #define ASM_CPU_DEFAULT_SPEC ASM_CPU32_DEFAULT_SPEC
80 #if TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc
81 #undef CPP_CPU64_DEFAULT_SPEC
82 #define CPP_CPU64_DEFAULT_SPEC ""
83 #undef ASM_CPU32_DEFAULT_SPEC
84 #define ASM_CPU32_DEFAULT_SPEC "-xarch=v8plusa"
85 #undef ASM_CPU64_DEFAULT_SPEC
86 #define ASM_CPU64_DEFAULT_SPEC AS_SPARC64_FLAG "a"
87 #undef ASM_CPU_DEFAULT_SPEC
88 #define ASM_CPU_DEFAULT_SPEC ASM_CPU32_DEFAULT_SPEC
91 #if TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc3
92 #undef CPP_CPU64_DEFAULT_SPEC
93 #define CPP_CPU64_DEFAULT_SPEC ""
94 #undef ASM_CPU32_DEFAULT_SPEC
95 #define ASM_CPU32_DEFAULT_SPEC "-xarch=v8plusb"
96 #undef ASM_CPU64_DEFAULT_SPEC
97 #define ASM_CPU64_DEFAULT_SPEC AS_SPARC64_FLAG "b"
98 #undef ASM_CPU_DEFAULT_SPEC
99 #define ASM_CPU_DEFAULT_SPEC ASM_CPU32_DEFAULT_SPEC
102 #if TARGET_CPU_DEFAULT == TARGET_CPU_niagara
103 #undef CPP_CPU64_DEFAULT_SPEC
104 #define CPP_CPU64_DEFAULT_SPEC ""
105 #undef ASM_CPU32_DEFAULT_SPEC
106 #define ASM_CPU32_DEFAULT_SPEC "-xarch=v8plusb"
107 #undef ASM_CPU64_DEFAULT_SPEC
108 #define ASM_CPU64_DEFAULT_SPEC AS_SPARC64_FLAG "b"
109 #undef ASM_CPU_DEFAULT_SPEC
110 #define ASM_CPU_DEFAULT_SPEC ASM_CPU32_DEFAULT_SPEC
113 #if TARGET_CPU_DEFAULT == TARGET_CPU_niagara2
114 #undef CPP_CPU64_DEFAULT_SPEC
115 #define CPP_CPU64_DEFAULT_SPEC ""
116 #undef ASM_CPU32_DEFAULT_SPEC
117 #define ASM_CPU32_DEFAULT_SPEC "-xarch=v8plusb"
118 #undef ASM_CPU64_DEFAULT_SPEC
119 #define ASM_CPU64_DEFAULT_SPEC AS_SPARC64_FLAG "b"
120 #undef ASM_CPU_DEFAULT_SPEC
121 #define ASM_CPU_DEFAULT_SPEC ASM_CPU32_DEFAULT_SPEC
124 #if TARGET_CPU_DEFAULT == TARGET_CPU_niagara3
125 #undef CPP_CPU64_DEFAULT_SPEC
126 #define CPP_CPU64_DEFAULT_SPEC ""
127 #undef ASM_CPU32_DEFAULT_SPEC
128 #define ASM_CPU32_DEFAULT_SPEC "-xarch=v8plus" AS_NIAGARA3_FLAG
129 #undef ASM_CPU64_DEFAULT_SPEC
130 #define ASM_CPU64_DEFAULT_SPEC AS_SPARC64_FLAG AS_NIAGARA3_FLAG
131 #undef ASM_CPU_DEFAULT_SPEC
132 #define ASM_CPU_DEFAULT_SPEC ASM_CPU32_DEFAULT_SPEC
135 #if TARGET_CPU_DEFAULT == TARGET_CPU_niagara4
136 #undef CPP_CPU64_DEFAULT_SPEC
137 #define CPP_CPU64_DEFAULT_SPEC ""
138 #undef ASM_CPU32_DEFAULT_SPEC
139 #define ASM_CPU32_DEFAULT_SPEC "-xarch=v8plusb"
140 #undef ASM_CPU64_DEFAULT_SPEC
141 #define ASM_CPU64_DEFAULT_SPEC AS_SPARC64_FLAG "b"
142 #undef ASM_CPU_DEFAULT_SPEC
143 #define ASM_CPU_DEFAULT_SPEC ASM_CPU32_DEFAULT_SPEC
146 /* Both Sun as and GNU as understand -K PIC. */
148 #define ASM_SPEC ASM_SPEC_BASE ASM_PIC_SPEC
151 #define CPP_CPU_SPEC "\
152 %{mcpu=sparclet|mcpu=tsc701:-D__sparclet__} \
153 %{mcpu=sparclite|mcpu-f930|mcpu=f934:-D__sparclite__} \
154 %{mcpu=v8:" DEF_ARCH32_SPEC("-D__sparcv8") "} \
155 %{mcpu=supersparc:-D__supersparc__ " DEF_ARCH32_SPEC("-D__sparcv8") "} \
156 %{mcpu=v9|mcpu=ultrasparc|mcpu=ultrasparc3|mcpu=niagara|mcpu=niagara2|mcpu=niagara3|mcpu=niagara4:" DEF_ARCH32_SPEC("-D__sparcv8") "} \
157 %{!mcpu*:%(cpp_cpu_default)} \
160 #undef CPP_CPU_DEFAULT_SPEC
161 #define CPP_CPU_DEFAULT_SPEC \
162 (DEFAULT_ARCH32_P ? "\
163 %{m64:" CPP_CPU64_DEFAULT_SPEC "} \
164 %{!m64:" CPP_CPU32_DEFAULT_SPEC "} \
166 %{m32:" CPP_CPU32_DEFAULT_SPEC "} \
167 %{!m32:" CPP_CPU64_DEFAULT_SPEC "} \
170 #undef CPP_ARCH32_SPEC
171 #define CPP_ARCH32_SPEC ""
172 #undef CPP_ARCH64_SPEC
173 #define CPP_ARCH64_SPEC "-D__arch64__ -D__sparcv9"
176 #define CPP_ARCH_SPEC "\
177 %{m32:%(cpp_arch32)} \
178 %{m64:%(cpp_arch64)} \
179 %{!m32:%{!m64:%(cpp_arch_default)}} \
182 /* -mcpu=native handling only makes sense with compiler running on
184 #if defined(__sparc__) && defined(__SVR4)
185 extern const char *host_detect_local_cpu (int argc
, const char **argv
);
186 # define EXTRA_SPEC_FUNCTIONS \
187 { "local_cpu_detect", host_detect_local_cpu },
189 # define MCPU_MTUNE_NATIVE_SPECS \
190 " %{mcpu=native:%<mcpu=native %:local_cpu_detect(cpu)}" \
191 " %{mtune=native:%<mtune=native %:local_cpu_detect(tune)}"
193 # define MCPU_MTUNE_NATIVE_SPECS ""
196 #define DRIVER_SELF_SPECS MCPU_MTUNE_NATIVE_SPECS
201 %{m64:%{m32:%emay not use both -m32 and -m64}} \
202 %{m64:-mptr64 -mstack-bias -mno-v8plus \
203 %{!mcpu*:-%{!mv8plus:mcpu=v9}}} \
207 %{m32:%{m64:%emay not use both -m32 and -m64}} \
208 %{m32:-mptr32 -mno-stack-bias \
209 %{!mcpu*:%{!mv8plus:-mcpu=v9}}} \
210 %{mv8plus:-m32 -mptr32 -mno-stack-bias \
211 %{!mcpu*:-mcpu=v9}} \
215 /* Support for a compile-time default CPU, et cetera. The rules are:
216 --with-cpu is ignored if -mcpu is specified.
217 --with-tune is ignored if -mtune is specified.
218 --with-float is ignored if -mhard-float, -msoft-float, -mfpu, or -mno-fpu
220 In the SPARC_BI_ARCH compiler we cannot pass %{!mcpu=*:-mcpu=%(VALUE)}
221 here, otherwise say -mcpu=v7 would be passed even when -m64.
222 CC1_SPEC above takes care of this instead. */
223 #undef OPTION_DEFAULT_SPECS
225 #define OPTION_DEFAULT_SPECS \
226 {"cpu", "%{!m64:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
227 {"tune", "%{!mtune=*:-mtune=%(VALUE)}" }, \
228 {"float", "%{!msoft-float:%{!mhard-float:%{!mfpu:%{!mno-fpu:-m%(VALUE)-float}}}}" }
230 #define OPTION_DEFAULT_SPECS \
231 {"cpu", "%{!m32:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
232 {"tune", "%{!mtune=*:-mtune=%(VALUE)}" }, \
233 {"float", "%{!msoft-float:%{!mhard-float:%{!mfpu:%{!mno-fpu:-m%(VALUE)-float}}}}" }
237 #define ASM_CPU_SPEC "\
238 %{mcpu=v9:" DEF_ARCH32_SPEC("-xarch=v8plus") DEF_ARCH64_SPEC(AS_SPARC64_FLAG) "} \
239 %{mcpu=ultrasparc:" DEF_ARCH32_SPEC("-xarch=v8plusa") DEF_ARCH64_SPEC(AS_SPARC64_FLAG "a") "} \
240 %{mcpu=ultrasparc3:" DEF_ARCH32_SPEC("-xarch=v8plusb") DEF_ARCH64_SPEC(AS_SPARC64_FLAG "b") "} \
241 %{mcpu=niagara:" DEF_ARCH32_SPEC("-xarch=v8plusb") DEF_ARCH64_SPEC(AS_SPARC64_FLAG "b") "} \
242 %{mcpu=niagara2:" DEF_ARCH32_SPEC("-xarch=v8plusb") DEF_ARCH64_SPEC(AS_SPARC64_FLAG "b") "} \
243 %{mcpu=niagara3:" DEF_ARCH32_SPEC("-xarch=v8plus" AS_NIAGARA3_FLAG) DEF_ARCH64_SPEC(AS_SPARC64_FLAG AS_NIAGARA3_FLAG) "} \
244 %{mcpu=niagara4:" DEF_ARCH32_SPEC("-xarch=v8plus" AS_NIAGARA3_FLAG) DEF_ARCH64_SPEC(AS_SPARC64_FLAG AS_NIAGARA3_FLAG) "} \
245 %{!mcpu=niagara4:%{!mcpu=niagara3:%{!mcpu=niagara2:%{!mcpu=niagara:%{!mcpu=ultrasparc3:%{!mcpu=ultrasparc:%{!mcpu=v9:%{mcpu*:" DEF_ARCH32_SPEC("-xarch=v8") DEF_ARCH64_SPEC(AS_SPARC64_FLAG) "}}}}}}}} \
246 %{!mcpu*:%(asm_cpu_default)} \
249 #undef ASM_ARCH32_SPEC
250 #define ASM_ARCH32_SPEC ""
252 #undef ASM_ARCH64_SPEC
253 #define ASM_ARCH64_SPEC ""
255 #undef ASM_ARCH_DEFAULT_SPEC
256 #define ASM_ARCH_DEFAULT_SPEC ""
259 #define ASM_ARCH_SPEC ""
262 /* Since binutils 2.21, GNU ld supports new *_sol2 emulations to strictly
263 follow the Solaris 2 ABI. Prefer them if present. */
264 #ifdef HAVE_LD_SOL2_EMULATION
265 #define ARCH32_EMULATION "elf32_sparc_sol2"
266 #define ARCH64_EMULATION "elf64_sparc_sol2"
268 #define ARCH32_EMULATION "elf32_sparc"
269 #define ARCH64_EMULATION "elf64_sparc"
273 #define ARCH64_SUBDIR "sparcv9"
275 #define SUBTARGET_CPU_EXTRA_SPECS
279 /* Register the Solaris-specific #pragma directives. */
280 #define REGISTER_TARGET_PRAGMAS() solaris_register_pragmas ()
282 #if defined(USE_GAS) && defined(HAVE_AS_TLS)
283 /* Use GNU extensions to TLS support. */
284 #undef TARGET_SUN_TLS
285 #undef TARGET_GNU_TLS
286 #define TARGET_SUN_TLS 0
287 #define TARGET_GNU_TLS 1
290 #undef LOCAL_LABEL_PREFIX
291 #define LOCAL_LABEL_PREFIX "."
293 /* The Solaris 2 assembler uses .skip, not .zero, so put this back. */
294 #undef ASM_OUTPUT_SKIP
295 #define ASM_OUTPUT_SKIP(FILE,SIZE) \
296 fprintf (FILE, "\t.skip %u\n", (int)(SIZE))
298 /* This is how to store into the string LABEL
299 the symbol_ref name of an internal numbered label where
300 PREFIX is the class of label and NUM is the number within the class.
301 This is suitable for output with `assemble_name'. */
303 #undef ASM_GENERATE_INTERNAL_LABEL
304 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \
305 sprintf ((LABEL), "*.L%s%lu", (PREFIX), (unsigned long)(NUM))
307 /* The native TLS-enabled assembler requires the directive #tls_object
308 to be put on objects in TLS sections (as of v7.1). This is not
309 required by GNU as but supported on SPARC. */
310 #undef ASM_DECLARE_OBJECT_NAME
311 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \
314 HOST_WIDE_INT size; \
316 if (targetm.have_tls && DECL_THREAD_LOCAL_P (DECL)) \
317 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "tls_object"); \
319 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object"); \
321 size_directive_output = 0; \
322 if (!flag_inhibit_size_directive \
323 && (DECL) && DECL_SIZE (DECL)) \
325 size_directive_output = 1; \
326 size = int_size_in_bytes (TREE_TYPE (DECL)); \
327 ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, size); \
330 ASM_OUTPUT_LABEL (FILE, NAME); \
334 /* Output a simple call for .init/.fini. */
335 #define ASM_OUTPUT_CALL(FILE, FN) \
338 fprintf (FILE, "\tcall\t"); \
339 targetm.asm_out.print_operand (FILE, XEXP (DECL_RTL (FN), 0), 0); \
340 fprintf (FILE, "\n\tnop\n"); \
345 /* This is how to output an assembler line that says to advance
346 the location counter to a multiple of 2**LOG bytes using the
347 NOP instruction as padding. The filler pattern doesn't work
349 #define ASM_OUTPUT_ALIGN_WITH_NOP(FILE,LOG) \
351 fprintf (FILE, "\t.align %d,0x1000000\n", (1<<(LOG)))
353 /* Use Solaris ELF section syntax with Sun as. */
354 #undef TARGET_ASM_NAMED_SECTION
355 #define TARGET_ASM_NAMED_SECTION sparc_solaris_elf_asm_named_section
357 /* Sun as requires doublequoted section names on SPARC. While GNU as
358 supports that, too, we prefer the standard variant. */
359 #undef SECTION_NAME_FORMAT
360 #define SECTION_NAME_FORMAT "\"%s\""
361 #endif /* !USE_GAS */
363 /* Undefine this so that attribute((init_priority)) works with GNU ld. */
365 #undef CTORS_SECTION_ASM_OP
366 #undef DTORS_SECTION_ASM_OP
371 /* Define for support of TFmode long double.
372 SPARC ABI says that long double is 4 words. */
373 #define LONG_DOUBLE_TYPE_SIZE 128
375 /* Solaris's _Qp_* library routine implementation clobbers the output
376 memory before the inputs are fully consumed. */
378 #undef TARGET_BUGGY_QP_LIB
379 #define TARGET_BUGGY_QP_LIB 1
381 #undef SUN_CONVERSION_LIBFUNCS
382 #define SUN_CONVERSION_LIBFUNCS 1
384 #undef DITF_CONVERSION_LIBFUNCS
385 #define DITF_CONVERSION_LIBFUNCS 1
387 #undef SUN_INTEGER_MULTIPLY_64
388 #define SUN_INTEGER_MULTIPLY_64 1