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