0ad1a5234a12cb6aa64f61cb6c571ba5289f2bf7
[gcc.git] / gcc / config / sparc / linux64.h
1 /* Definitions for 64-bit SPARC running Linux-based GNU systems with ELF.
2 Copyright 1996, 1997, 1998, 2000, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
3 2009, 2010, 2011 Free Software Foundation, Inc.
4 Contributed by David S. Miller (davem@caip.rutgers.edu)
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 #define TARGET_OS_CPP_BUILTINS() \
23 do \
24 { \
25 GNU_USER_TARGET_OS_CPP_BUILTINS(); \
26 if (TARGET_ARCH64) \
27 builtin_define ("_LONGLONG"); \
28 if (TARGET_ARCH32 \
29 && TARGET_LONG_DOUBLE_128) \
30 builtin_define ("__LONG_DOUBLE_128__"); \
31 } \
32 while (0)
33
34 #if TARGET_CPU_DEFAULT == TARGET_CPU_v9 \
35 || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc \
36 || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc3 \
37 || TARGET_CPU_DEFAULT == TARGET_CPU_niagara \
38 || TARGET_CPU_DEFAULT == TARGET_CPU_niagara2
39 /* A 64 bit v9 compiler with stack-bias,
40 in a Medium/Low code model environment. */
41
42 #undef TARGET_DEFAULT
43 #define TARGET_DEFAULT \
44 (MASK_V9 + MASK_PTR64 + MASK_64BIT /* + MASK_HARD_QUAD */ \
45 + MASK_STACK_BIAS + MASK_APP_REGS + MASK_FPU + MASK_LONG_DOUBLE_128)
46 #endif
47
48 /* This must be v9a not just v9 because by default we enable
49 -mvis. */
50 #undef ASM_CPU64_DEFAULT_SPEC
51 #define ASM_CPU64_DEFAULT_SPEC "-Av9a"
52
53 /* Provide a ENDFILE_SPEC appropriate for GNU/Linux. Here we tack on
54 the GNU/Linux magical crtend.o file (see crtstuff.c) which
55 provides part of the support for getting C++ file-scope static
56 object constructed before entering `main', followed by a normal
57 GNU/Linux "finalizer" file, `crtn.o'. */
58
59 #undef ENDFILE_SPEC
60 #define ENDFILE_SPEC \
61 "%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s\
62 %{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s}"
63
64 /* The default code model. */
65 #undef SPARC_DEFAULT_CMODEL
66 #define SPARC_DEFAULT_CMODEL CM_MEDLOW
67
68 #undef WCHAR_TYPE
69 #define WCHAR_TYPE "int"
70
71 #undef WCHAR_TYPE_SIZE
72 #define WCHAR_TYPE_SIZE 32
73
74 /* Define for support of TFmode long double.
75 SPARC ABI says that long double is 4 words. */
76 #undef LONG_DOUBLE_TYPE_SIZE
77 #define LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64)
78
79 /* Define this to set long double type size to use in libgcc2.c, which can
80 not depend on target_flags. */
81 #if defined(__arch64__) || defined(__LONG_DOUBLE_128__)
82 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 128
83 #else
84 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64
85 #endif
86
87 #undef CPP_SUBTARGET_SPEC
88 #define CPP_SUBTARGET_SPEC "\
89 %{posix:-D_POSIX_SOURCE} \
90 %{pthread:-D_REENTRANT} \
91 "
92
93 /* Provide a LINK_SPEC appropriate for GNU/Linux. Here we provide support
94 for the special GCC options -static and -shared, which allow us to
95 link things in one of these three modes by applying the appropriate
96 combinations of options at link-time.
97
98 When the -shared link option is used a final link is not being
99 done. */
100
101 #define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2"
102 #define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux.so.2"
103
104 #ifdef SPARC_BI_ARCH
105
106 #undef SUBTARGET_EXTRA_SPECS
107 #define SUBTARGET_EXTRA_SPECS \
108 { "link_arch32", LINK_ARCH32_SPEC }, \
109 { "link_arch64", LINK_ARCH64_SPEC }, \
110 { "link_arch_default", LINK_ARCH_DEFAULT_SPEC }, \
111 { "link_arch", LINK_ARCH_SPEC },
112
113 #define LINK_ARCH32_SPEC "-m elf32_sparc -Y P,%R/usr/lib %{shared:-shared} \
114 %{!shared: \
115 %{!static: \
116 %{rdynamic:-export-dynamic} \
117 -dynamic-linker " GNU_USER_DYNAMIC_LINKER32 "} \
118 %{static:-static}} \
119 "
120
121 #define LINK_ARCH64_SPEC "-m elf64_sparc -Y P,%R/usr/lib64 %{shared:-shared} \
122 %{!shared: \
123 %{!static: \
124 %{rdynamic:-export-dynamic} \
125 -dynamic-linker " GNU_USER_DYNAMIC_LINKER64 "} \
126 %{static:-static}} \
127 "
128
129 #define LINK_ARCH_SPEC "\
130 %{m32:%(link_arch32)} \
131 %{m64:%(link_arch64)} \
132 %{!m32:%{!m64:%(link_arch_default)}} \
133 "
134
135 #define LINK_ARCH_DEFAULT_SPEC \
136 (DEFAULT_ARCH32_P ? LINK_ARCH32_SPEC : LINK_ARCH64_SPEC)
137
138 #undef LINK_SPEC
139 #define LINK_SPEC "\
140 %(link_arch) \
141 %{mlittle-endian:-EL} \
142 %{!mno-relax:%{!r:-relax}} \
143 "
144
145 /* -mcpu=native handling only makes sense with compiler running on
146 a SPARC chip. */
147 #if defined(__sparc__)
148 extern const char *host_detect_local_cpu (int argc, const char **argv);
149 # define EXTRA_SPEC_FUNCTIONS \
150 { "local_cpu_detect", host_detect_local_cpu },
151
152 # define MCPU_MTUNE_NATIVE_SPECS \
153 " %{mcpu=native:%<mcpu=native %:local_cpu_detect(cpu)}" \
154 " %{mtune=native:%<mtune=native %:local_cpu_detect(tune)}"
155 #else
156 # define MCPU_MTUNE_NATIVE_SPECS ""
157 #endif
158
159 #define DRIVER_SELF_SPECS MCPU_MTUNE_NATIVE_SPECS
160
161 #undef CC1_SPEC
162 #if DEFAULT_ARCH32_P
163 #define CC1_SPEC "%{profile:-p} \
164 %{m32:%{m64:%emay not use both -m32 and -m64}} \
165 %{m64:-mptr64 -mstack-bias -mlong-double-128 \
166 %{!mcpu*:-mcpu=ultrasparc} \
167 %{!mno-vis:%{!mcpu=v9:-mvis}}} \
168 "
169 #else
170 #define CC1_SPEC "%{profile:-p} \
171 %{m32:%{m64:%emay not use both -m32 and -m64}} \
172 %{m32:-mptr32 -mno-stack-bias %{!mlong-double-128:-mlong-double-64} \
173 %{!mcpu*:-mcpu=cypress}} \
174 %{!m32:%{!mcpu*:-mcpu=ultrasparc}} \
175 %{!mno-vis:%{!m32:%{!mcpu=v9:-mvis}}} \
176 "
177 #endif
178
179 /* Support for a compile-time default CPU, et cetera. The rules are:
180 --with-cpu is ignored if -mcpu is specified.
181 --with-tune is ignored if -mtune is specified.
182 --with-float is ignored if -mhard-float, -msoft-float, -mfpu, or -mno-fpu
183 are specified.
184 In the SPARC_BI_ARCH compiler we cannot pass %{!mcpu=*:-mcpu=%(VALUE)}
185 here, otherwise say -mcpu=v7 would be passed even when -m64.
186 CC1_SPEC above takes care of this instead. */
187 #undef OPTION_DEFAULT_SPECS
188 #if DEFAULT_ARCH32_P
189 #define OPTION_DEFAULT_SPECS \
190 {"cpu", "%{!m64:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
191 {"tune", "%{!mtune=*:-mtune=%(VALUE)}" }, \
192 {"float", "%{!msoft-float:%{!mhard-float:%{!mfpu:%{!mno-fpu:-m%(VALUE)-float}}}}" }
193 #else
194 #define OPTION_DEFAULT_SPECS \
195 {"cpu", "%{!m32:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
196 {"tune", "%{!mtune=*:-mtune=%(VALUE)}" }, \
197 {"float", "%{!msoft-float:%{!mhard-float:%{!mfpu:%{!mno-fpu:-m%(VALUE)-float}}}}" }
198 #endif
199
200 #if DEFAULT_ARCH32_P
201 #define MULTILIB_DEFAULTS { "m32" }
202 #else
203 #define MULTILIB_DEFAULTS { "m64" }
204 #endif
205
206 #else /* !SPARC_BI_ARCH */
207
208 #undef LINK_SPEC
209 #define LINK_SPEC "-m elf64_sparc -Y P,%R/usr/lib64 %{shared:-shared} \
210 %{!shared: \
211 %{!static: \
212 %{rdynamic:-export-dynamic} \
213 -dynamic-linker " GNU_USER_DYNAMIC_LINKER64 "} \
214 %{static:-static}} \
215 %{mlittle-endian:-EL} \
216 %{!mno-relax:%{!r:-relax}} \
217 "
218
219 #endif /* !SPARC_BI_ARCH */
220
221 /* It's safe to pass -s always, even if -g is not used. */
222 #undef ASM_SPEC
223 #define ASM_SPEC "\
224 -s \
225 %{fpic|fPIC|fpie|fPIE:-K PIC} \
226 %{!.c:%{findirect-dispatch:-K PIC}} \
227 %{mlittle-endian:-EL} \
228 %(asm_cpu) %(asm_arch) %(asm_relax)"
229
230 #undef ASM_OUTPUT_ALIGNED_LOCAL
231 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
232 do { \
233 fputs ("\t.local\t", (FILE)); \
234 assemble_name ((FILE), (NAME)); \
235 putc ('\n', (FILE)); \
236 ASM_OUTPUT_ALIGNED_COMMON (FILE, NAME, SIZE, ALIGN); \
237 } while (0)
238
239 #undef COMMON_ASM_OP
240 #define COMMON_ASM_OP "\t.common\t"
241
242 #undef LOCAL_LABEL_PREFIX
243 #define LOCAL_LABEL_PREFIX "."
244
245 /* This is how to store into the string LABEL
246 the symbol_ref name of an internal numbered label where
247 PREFIX is the class of label and NUM is the number within the class.
248 This is suitable for output with `assemble_name'. */
249
250 #undef ASM_GENERATE_INTERNAL_LABEL
251 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \
252 sprintf (LABEL, "*.L%s%ld", PREFIX, (long)(NUM))
253
254 /* DWARF bits. */
255
256 /* Follow Irix 6 and not the Dwarf2 draft in using 64-bit offsets.
257 Obviously the Dwarf2 folks haven't tried to actually build systems
258 with their spec. On a 64-bit system, only 64-bit relocs become
259 RELATIVE relocations. */
260
261 /* #define DWARF_OFFSET_SIZE PTR_SIZE */
262
263 #undef DITF_CONVERSION_LIBFUNCS
264 #define DITF_CONVERSION_LIBFUNCS 1
265 \f
266 #ifdef HAVE_AS_TLS
267 #undef TARGET_SUN_TLS
268 #undef TARGET_GNU_TLS
269 #define TARGET_SUN_TLS 0
270 #define TARGET_GNU_TLS 1
271 #endif
272 \f
273 /* We use GNU ld so undefine this so that attribute((init_priority)) works. */
274 #undef CTORS_SECTION_ASM_OP
275 #undef DTORS_SECTION_ASM_OP
276
277 /* Static stack checking is supported by means of probes. */
278 #define STACK_CHECK_STATIC_BUILTIN 1
279
280 /* Linux currently uses RMO in uniprocessor mode, which is equivalent to
281 TMO, and TMO in multiprocessor mode. But they reserve the right to
282 change their minds. */
283 #undef SPARC_RELAXED_ORDERING
284 #define SPARC_RELAXED_ORDERING true
285
286 #undef NEED_INDICATE_EXEC_STACK
287 #define NEED_INDICATE_EXEC_STACK 1
288
289 #ifdef TARGET_LIBC_PROVIDES_SSP
290 /* sparc glibc provides __stack_chk_guard in [%g7 + 0x14],
291 sparc64 glibc provides it at [%g7 + 0x28]. */
292 #define TARGET_THREAD_SSP_OFFSET (TARGET_ARCH64 ? 0x28 : 0x14)
293 #endif
294
295 /* Define if long doubles should be mangled as 'g'. */
296 #define TARGET_ALTERNATE_LONG_DOUBLE_MANGLING
297
298 /* We use glibc _mcount for profiling. */
299 #undef NO_PROFILE_COUNTERS
300 #define NO_PROFILE_COUNTERS 1