]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/config/sparc/linux64.h
i386.h (OPTION_DEFAULT_SPECS): Avoid -mcpu default when -march is specified.
[thirdparty/gcc.git] / gcc / config / sparc / linux64.h
CommitLineData
956d6950 1/* Definitions for 64-bit SPARC running Linux-based GNU systems with ELF.
5bbcd587 2 Copyright 1996, 1997, 1998, 2000, 2002 Free Software Foundation, Inc.
bfe87013
DE
3 Contributed by David S. Miller (davem@caip.rutgers.edu)
4
5This file is part of GNU CC.
6
7GNU CC is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2, or (at your option)
10any later version.
11
12GNU CC is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with GNU CC; see the file COPYING. If not, write to
19the Free Software Foundation, 59 Temple Place - Suite 330,
20Boston, MA 02111-1307, USA. */
21
9b8466f4
NB
22#define TARGET_OS_CPP_BUILTINS() \
23 do \
24 { \
25 builtin_define_std ("unix"); \
26 builtin_define_std ("linux"); \
27 builtin_define ("_LONGLONG"); \
28 builtin_define ("__gnu_linux__"); \
9b8466f4
NB
29 builtin_assert ("system=unix"); \
30 builtin_assert ("system=posix"); \
31 } \
32 while (0)
33
a0a301fc 34#define LINUX_DEFAULT_ELF
bfe87013 35
80ffc95e 36/* Don't assume anything about the header files. */
bfe87013
DE
37#define NO_IMPLICIT_EXTERN_C
38
bfe87013
DE
39#undef MD_EXEC_PREFIX
40#undef MD_STARTFILE_PREFIX
41
345a6161
DM
42#if TARGET_CPU_DEFAULT == TARGET_CPU_v9 || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc
43/* A 64 bit v9 compiler with stack-bias,
44 in a Medium/Low code model environment. */
45
46#undef TARGET_DEFAULT
47#define TARGET_DEFAULT \
48 (MASK_V9 + MASK_PTR64 + MASK_64BIT /* + MASK_HARD_QUAD */ \
33074e5f 49 + MASK_STACK_BIAS + MASK_APP_REGS + MASK_FPU + MASK_LONG_DOUBLE_128)
345a6161
DM
50#endif
51
a0a301fc
DE
52#undef ASM_CPU_DEFAULT_SPEC
53#define ASM_CPU_DEFAULT_SPEC "-Av9a"
bfe87013 54
4710d3eb
JJ
55#ifdef SPARC_BI_ARCH
56
57#undef CPP_ARCH32_SPEC
9b8466f4 58#define CPP_ARCH32_SPEC "%{mlong-double-128:-D__LONG_DOUBLE_128__}"
4710d3eb
JJ
59
60#endif
61
956d6950
JL
62/* Provide a STARTFILE_SPEC appropriate for GNU/Linux. Here we add
63 the GNU/Linux magical crtbegin.o file (see crtstuff.c) which
bfe87013 64 provides part of the support for getting C++ file-scope static
80ffc95e 65 object constructed before entering `main'. */
bfe87013
DE
66
67#undef STARTFILE_SPEC
345a6161 68
24a4dd31 69#ifdef HAVE_LD_PIE
5bbcd587 70#define STARTFILE_SPEC \
24a4dd31
JJ
71 "%{!shared:%{pg|p:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}}\
72 crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbeginS.o%s}"
73#else
74#define STARTFILE_SPEC \
75 "%{!shared:%{pg|p:gcrt1.o%s;:crt1.o%s}}\
76 crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbeginS.o%s}"
77#endif
bfe87013 78
956d6950
JL
79/* Provide a ENDFILE_SPEC appropriate for GNU/Linux. Here we tack on
80 the GNU/Linux magical crtend.o file (see crtstuff.c) which
bfe87013
DE
81 provides part of the support for getting C++ file-scope static
82 object constructed before entering `main', followed by a normal
956d6950 83 GNU/Linux "finalizer" file, `crtn.o'. */
bfe87013
DE
84
85#undef ENDFILE_SPEC
345a6161 86
5bbcd587 87#define ENDFILE_SPEC \
24a4dd31 88 "%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s\
5bbcd587 89 %{ffast-math|funsafe-math-optimizations:crtfastmath.o%s}"
345a6161 90
2be1602e
DM
91/* The GNU C++ standard library requires that these macros be defined. */
92#undef CPLUSPLUS_CPP_SPEC
93#define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
94
345a6161
DM
95#undef TARGET_VERSION
96#define TARGET_VERSION fprintf (stderr, " (sparc64 GNU/Linux with ELF)");
a0a301fc
DE
97
98/* The default code model. */
99#undef SPARC_DEFAULT_CMODEL
be3f1ff5 100#define SPARC_DEFAULT_CMODEL CM_MEDLOW
bfe87013 101
4710d3eb 102#undef SUBTARGET_SWITCHES
047142d3
PT
103#define SUBTARGET_SWITCHES \
104{"long-double-64", -MASK_LONG_DOUBLE_128, N_("Use 64 bit long doubles") }, \
105{"long-double-128", MASK_LONG_DOUBLE_128, N_("Use 128 bit long doubles") },
4710d3eb 106
bfe87013 107#undef WCHAR_TYPE
247cfc5c
JJ
108#define WCHAR_TYPE "int"
109
bfe87013 110#undef WCHAR_TYPE_SIZE
247cfc5c
JJ
111#define WCHAR_TYPE_SIZE 32
112
ba31d94e 113/* Define for support of TFmode long double.
56149abc 114 SPARC ABI says that long double is 4 words. */
a0a301fc 115#undef LONG_DOUBLE_TYPE_SIZE
4710d3eb
JJ
116#define LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64)
117
118/* Constant which presents upper bound of the above value. */
119#undef MAX_LONG_DOUBLE_TYPE_SIZE
120#define MAX_LONG_DOUBLE_TYPE_SIZE 128
121
122/* Define this to set long double type size to use in libgcc2.c, which can
123 not depend on target_flags. */
124#if defined(__arch64__) || defined(__LONG_DOUBLE_128__)
125#define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 128
126#else
127#define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64
128#endif
345a6161 129
a0a301fc
DE
130#undef CPP_SUBTARGET_SPEC
131#define CPP_SUBTARGET_SPEC "\
24a4dd31 132%{fPIC|fpic|fPIE|fpie:-D__PIC__ -D__pic__} \
bfe87013 133%{posix:-D_POSIX_SOURCE} \
afc96791 134%{pthread:-D_REENTRANT} \
bfe87013 135"
afc96791 136
bfe87013
DE
137#undef LIB_SPEC
138#define LIB_SPEC \
17772b2a
JJ
139 "%{pthread:-lpthread} \
140 %{shared:-lc} \
141 %{!shared: %{mieee-fp:-lieee} %{profile:-lc_p}%{!profile:-lc}}"
bfe87013 142
956d6950 143/* Provide a LINK_SPEC appropriate for GNU/Linux. Here we provide support
bfe87013
DE
144 for the special GCC options -static and -shared, which allow us to
145 link things in one of these three modes by applying the appropriate
146 combinations of options at link-time. We like to support here for
147 as many of the other GNU linker options as possible. But I don't
148 have the time to search for those flags. I am sure how to add
149 support for -soname shared_object_name. H.J.
150
151 I took out %{v:%{!V:-V}}. It is too much :-(. They can use
152 -Wl,-V.
153
154 When the -shared link option is used a final link is not being
155 done. */
156
80ffc95e 157/* If ELF is the default format, we should not use /lib/elf. */
bfe87013 158
345a6161
DM
159#ifdef SPARC_BI_ARCH
160
161#undef SUBTARGET_EXTRA_SPECS
162#define SUBTARGET_EXTRA_SPECS \
163 { "link_arch32", LINK_ARCH32_SPEC }, \
164 { "link_arch64", LINK_ARCH64_SPEC }, \
165 { "link_arch_default", LINK_ARCH_DEFAULT_SPEC }, \
166 { "link_arch", LINK_ARCH_SPEC },
167
168#define LINK_ARCH32_SPEC "-m elf32_sparc -Y P,/usr/lib %{shared:-shared} \
169 %{!shared: \
170 %{!ibcs: \
171 %{!static: \
172 %{rdynamic:-export-dynamic} \
173 %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \
174 %{static:-static}}} \
175"
176
177#define LINK_ARCH64_SPEC "-m elf64_sparc -Y P,/usr/lib64 %{shared:-shared} \
178 %{!shared: \
179 %{!ibcs: \
180 %{!static: \
181 %{rdynamic:-export-dynamic} \
182 %{!dynamic-linker:-dynamic-linker /lib64/ld-linux.so.2}} \
183 %{static:-static}}} \
184"
185
186#define LINK_ARCH_SPEC "\
187%{m32:%(link_arch32)} \
188%{m64:%(link_arch64)} \
189%{!m32:%{!m64:%(link_arch_default)}} \
190"
191
192#define LINK_ARCH_DEFAULT_SPEC \
193(DEFAULT_ARCH32_P ? LINK_ARCH32_SPEC : LINK_ARCH64_SPEC)
194
bfe87013 195#undef LINK_SPEC
345a6161
DM
196#define LINK_SPEC "\
197%(link_arch) \
198%{mlittle-endian:-EL} \
e95b1e6a 199%{!mno-relax:%{!r:-relax}} \
345a6161
DM
200"
201
202#undef CC1_SPEC
203#if DEFAULT_ARCH32_P
204#define CC1_SPEC "\
205%{sun4:} %{target:} \
206%{mcypress:-mcpu=cypress} \
207%{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \
208%{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \
d6964c30 209%{m32:%{m64:%emay not use both -m32 and -m64}} \
4710d3eb 210%{m64:-mptr64 -mstack-bias -mlong-double-128 \
247cfc5c
JJ
211 %{!mcpu*:%{!mcypress:%{!msparclite:%{!mf930:%{!mf934:%{!mv8:%{!msupersparc:-mcpu=ultrasparc}}}}}}} \
212 %{!mno-vis:%{!mcpu=v9:-mvis}}} \
345a6161
DM
213"
214#else
215#define CC1_SPEC "\
216%{sun4:} %{target:} \
217%{mcypress:-mcpu=cypress} \
218%{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \
219%{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \
d6964c30 220%{m32:%{m64:%emay not use both -m32 and -m64}} \
4710d3eb 221%{m32:-mptr32 -mno-stack-bias %{!mlong-double-128:-mlong-double-64} \
b25c3a22 222 %{!mcpu*:%{!mcypress:%{!msparclite:%{!mf930:%{!mf934:%{!mv8:%{!msupersparc:-mcpu=cypress}}}}}}}} \
9ce13279 223%{!m32:%{!mcpu*:-mcpu=ultrasparc}} \
247cfc5c 224%{!mno-vis:%{!m32:%{!mcpu=v9:-mvis}}} \
345a6161
DM
225"
226#endif
227
228#if DEFAULT_ARCH32_P
229#define MULTILIB_DEFAULTS { "m32" }
230#else
231#define MULTILIB_DEFAULTS { "m64" }
232#endif
233
234#else /* !SPARC_BI_ARCH */
235
236#undef LINK_SPEC
e95b1e6a 237#define LINK_SPEC "-m elf64_sparc -Y P,/usr/lib64 %{shared:-shared} \
bfe87013
DE
238 %{!shared: \
239 %{!ibcs: \
240 %{!static: \
241 %{rdynamic:-export-dynamic} \
345a6161 242 %{!dynamic-linker:-dynamic-linker /lib64/ld-linux.so.2}} \
bfe87013
DE
243 %{static:-static}}} \
244%{mlittle-endian:-EL} \
e95b1e6a 245%{!mno-relax:%{!r:-relax}} \
bfe87013
DE
246"
247
345a6161
DM
248#endif /* !SPARC_BI_ARCH */
249
bfe87013 250/* The sun bundled assembler doesn't accept -Yd, (and neither does gas).
80ffc95e 251 It's safe to pass -s always, even if -g is not used. */
bfe87013
DE
252#undef ASM_SPEC
253#define ASM_SPEC "\
254%{V} \
255%{v:%{!V:-V}} \
256%{!Qn:-Qy} \
257%{n} \
258%{T} \
259%{Ym,*} \
260%{Wa,*:%*} \
24a4dd31 261-s %{fpic|fPIC|fpie|fPIE:-K PIC} \
bfe87013 262%{mlittle-endian:-EL} \
e95b1e6a 263%(asm_cpu) %(asm_arch) %(asm_relax)"
bfe87013
DE
264
265/* Same as sparc.h */
266#undef DBX_REGISTER_NUMBER
267#define DBX_REGISTER_NUMBER(REGNO) (REGNO)
268
269/* System V Release 4 uses DWARF debugging info. Buf DWARF1 doesn't do
270 64-bit anything, so we use DWARF2. */
271
bfe87013 272#undef DWARF_DEBUGGING_INFO
23532de9
JT
273#define DWARF2_DEBUGGING_INFO 1
274#define DBX_DEBUGGING_INFO 1
bfe87013 275
bfe87013
DE
276#undef ASM_OUTPUT_ALIGNED_LOCAL
277#define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
278do { \
279 fputs ("\t.local\t", (FILE)); \
280 assemble_name ((FILE), (NAME)); \
281 putc ('\n', (FILE)); \
282 ASM_OUTPUT_ALIGNED_COMMON (FILE, NAME, SIZE, ALIGN); \
283} while (0)
284
285#undef COMMON_ASM_OP
471b6f1b 286#define COMMON_ASM_OP "\t.common\t"
bfe87013 287
59f96879
RH
288#undef LOCAL_LABEL_PREFIX
289#define LOCAL_LABEL_PREFIX "."
290
bfe87013
DE
291/* This is how to output a reference to an internal numbered label where
292 PREFIX is the class of label and NUM is the number within the class. */
293
294#undef ASM_OUTPUT_INTERNAL_LABELREF
295#define ASM_OUTPUT_INTERNAL_LABELREF(FILE,PREFIX,NUM) \
296 fprintf (FILE, ".L%s%d", PREFIX, NUM)
297
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'. */
302
303#undef ASM_GENERATE_INTERNAL_LABEL
304#define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \
e59f7d3d 305 sprintf (LABEL, "*.L%s%ld", PREFIX, (long)(NUM))
bfe87013 306
bfe87013
DE
307/* DWARF bits. */
308
309/* Follow Irix 6 and not the Dwarf2 draft in using 64-bit offsets.
d6a7951f 310 Obviously the Dwarf2 folks haven't tried to actually build systems
bfe87013
DE
311 with their spec. On a 64-bit system, only 64-bit relocs become
312 RELATIVE relocations. */
313
314/* #define DWARF_OFFSET_SIZE PTR_SIZE */
275b60d6
JJ
315
316#if defined(HAVE_LD_EH_FRAME_HDR)
317#define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
318#endif
f7e0e539 319\f
b5de1a27
DM
320/* Don't be different from other Linux platforms in this regard. */
321#define HANDLE_PRAGMA_PACK_PUSH_POP
7a31a340
DM
322
323/* We use GNU ld so undefine this so that attribute((init_priority)) works. */
324#undef CTORS_SECTION_ASM_OP
325#undef DTORS_SECTION_ASM_OP
db430d26 326
3edc56a9
JJ
327#define ASM_FILE_END(FILE) \
328 do { \
329 named_section_flags (".note.GNU-stack", \
330 SECTION_DEBUG \
331 | (trampolines_created ? SECTION_CODE : 0)); \
332 } while (0)
333
db430d26
DM
334/* Do code reading to identify a signal frame, and set the frame
335 state data appropriately. See unwind-dw2.c for the structs. */
336
db430d26
DM
337/* Handle multilib correctly. */
338#if defined(__arch64__)
56149abc 339/* 64-bit SPARC version */
db430d26
DM
340#define MD_FALLBACK_FRAME_STATE_FOR(CONTEXT, FS, SUCCESS) \
341 do { \
342 unsigned int *pc_ = (CONTEXT)->ra; \
343 long new_cfa_, i_; \
344 long regs_off_, fpu_save_off_; \
345 long this_cfa_, fpu_save_; \
346 \
347 if (pc_[0] != 0x82102065 /* mov NR_rt_sigreturn, %g1 */ \
348 || pc_[1] != 0x91d0206d) /* ta 0x6d */ \
349 break; \
350 regs_off_ = 192 + 128; \
351 fpu_save_off_ = regs_off_ + (16 * 8) + (3 * 8) + (2 * 4); \
352 this_cfa_ = (long) (CONTEXT)->cfa; \
353 new_cfa_ = *(long *)(((CONTEXT)->cfa) + (regs_off_ + (14 * 8))); \
3ef3f384 354 new_cfa_ += 2047; /* Stack bias */ \
db430d26
DM
355 fpu_save_ = *(long *)((this_cfa_) + (fpu_save_off_)); \
356 (FS)->cfa_how = CFA_REG_OFFSET; \
357 (FS)->cfa_reg = 14; \
358 (FS)->cfa_offset = new_cfa_ - (long) (CONTEXT)->cfa; \
359 for (i_ = 1; i_ < 16; ++i_) \
360 { \
db430d26
DM
361 (FS)->regs.reg[i_].how = REG_SAVED_OFFSET; \
362 (FS)->regs.reg[i_].loc.offset = \
363 this_cfa_ + (regs_off_ + (i_ * 8)) - new_cfa_; \
364 } \
365 for (i_ = 0; i_ < 16; ++i_) \
366 { \
367 (FS)->regs.reg[i_ + 16].how = REG_SAVED_OFFSET; \
368 (FS)->regs.reg[i_ + 16].loc.offset = \
369 this_cfa_ + (i_ * 8) - new_cfa_; \
370 } \
371 if (fpu_save_) \
372 { \
373 for (i_ = 0; i_ < 64; ++i_) \
374 { \
375 if (i_ > 32 && (i_ & 0x1)) \
376 continue; \
377 (FS)->regs.reg[i_ + 32].how = REG_SAVED_OFFSET; \
378 (FS)->regs.reg[i_ + 32].loc.offset = \
379 (fpu_save_ + (i_ * 4)) - new_cfa_; \
380 } \
381 } \
382 /* Stick return address into %g0, same trick Alpha uses. */ \
383 (FS)->regs.reg[0].how = REG_SAVED_OFFSET; \
384 (FS)->regs.reg[0].loc.offset = \
385 this_cfa_ + (regs_off_ + (16 * 8) + 8) - new_cfa_; \
386 (FS)->retaddr_column = 0; \
387 goto SUCCESS; \
388 } while (0)
389#else
56149abc 390/* 32-bit SPARC version */
db430d26
DM
391#define MD_FALLBACK_FRAME_STATE_FOR(CONTEXT, FS, SUCCESS) \
392 do { \
393 unsigned int *pc_ = (CONTEXT)->ra; \
394 int new_cfa_, i_, oldstyle_; \
395 int regs_off_, fpu_save_off_; \
396 int fpu_save_, this_cfa_; \
397 \
398 if (pc_[1] != 0x91d02010) /* ta 0x10 */ \
399 break; \
400 if (pc_[0] == 0x821020d8) /* mov NR_sigreturn, %g1 */ \
401 oldstyle_ = 1; \
402 else if (pc_[0] == 0x82102065) /* mov NR_rt_sigreturn, %g1 */ \
403 oldstyle_ = 0; \
404 else \
405 break; \
406 if (oldstyle_) \
407 { \
408 regs_off_ = 96; \
409 fpu_save_off_ = regs_off_ + (4 * 4) + (16 * 4); \
410 } \
411 else \
412 { \
413 regs_off_ = 96 + 128; \
414 fpu_save_off_ = regs_off_ + (4 * 4) + (16 * 4) + (2 * 4); \
415 } \
416 this_cfa_ = (int) (CONTEXT)->cfa; \
417 new_cfa_ = *(int *)(((CONTEXT)->cfa) + (regs_off_+(4*4)+(14 * 4))); \
418 fpu_save_ = *(int *)((this_cfa_) + (fpu_save_off_)); \
419 (FS)->cfa_how = CFA_REG_OFFSET; \
420 (FS)->cfa_reg = 14; \
421 (FS)->cfa_offset = new_cfa_ - (int) (CONTEXT)->cfa; \
422 for (i_ = 1; i_ < 16; ++i_) \
423 { \
424 if (i_ == 14) \
425 continue; \
426 (FS)->regs.reg[i_].how = REG_SAVED_OFFSET; \
427 (FS)->regs.reg[i_].loc.offset = \
428 this_cfa_ + (regs_off_+(4 * 4)+(i_ * 4)) - new_cfa_; \
429 } \
430 for (i_ = 0; i_ < 16; ++i_) \
431 { \
432 (FS)->regs.reg[i_ + 16].how = REG_SAVED_OFFSET; \
433 (FS)->regs.reg[i_ + 16].loc.offset = \
434 this_cfa_ + (i_ * 4) - new_cfa_; \
435 } \
436 if (fpu_save_) \
437 { \
438 for (i_ = 0; i_ < 32; ++i_) \
439 { \
440 (FS)->regs.reg[i_ + 32].how = REG_SAVED_OFFSET; \
441 (FS)->regs.reg[i_ + 32].loc.offset = \
442 (fpu_save_ + (i_ * 4)) - new_cfa_; \
443 } \
444 } \
445 /* Stick return address into %g0, same trick Alpha uses. */ \
446 (FS)->regs.reg[0].how = REG_SAVED_OFFSET; \
447 (FS)->regs.reg[0].loc.offset = this_cfa_+(regs_off_+4)-new_cfa_; \
448 (FS)->retaddr_column = 0; \
449 goto SUCCESS; \
450 } while (0)
451#endif