This commit was manufactured by cvs2svn to create branch
[official-gcc.git] / gcc / config / sparc / linux64.h
blob0204cbe382902f9c8f64c4cc1f2b44d03ab0c090
1 /* Definitions for 64-bit SPARC running Linux-based GNU systems with ELF.
2 Copyright 1996, 1997, 1998, 2000, 2002, 2003 Free Software Foundation, Inc.
3 Contributed by David S. Miller (davem@caip.rutgers.edu)
5 This file is part of GCC.
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 2, or (at your option)
10 any later version.
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.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
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__"); \
29 builtin_assert ("system=linux"); \
30 builtin_assert ("system=unix"); \
31 builtin_assert ("system=posix"); \
32 } \
33 while (0)
35 /* Don't assume anything about the header files. */
36 #define NO_IMPLICIT_EXTERN_C
38 #undef MD_EXEC_PREFIX
39 #undef MD_STARTFILE_PREFIX
41 #if TARGET_CPU_DEFAULT == TARGET_CPU_v9 || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc
42 /* A 64 bit v9 compiler with stack-bias,
43 in a Medium/Low code model environment. */
45 #undef TARGET_DEFAULT
46 #define TARGET_DEFAULT \
47 (MASK_V9 + MASK_PTR64 + MASK_64BIT /* + MASK_HARD_QUAD */ \
48 + MASK_STACK_BIAS + MASK_APP_REGS + MASK_FPU + MASK_LONG_DOUBLE_128)
49 #endif
51 #undef ASM_CPU_DEFAULT_SPEC
52 #define ASM_CPU_DEFAULT_SPEC "-Av9a"
54 #ifdef SPARC_BI_ARCH
56 #undef CPP_ARCH32_SPEC
57 #define CPP_ARCH32_SPEC "%{mlong-double-128:-D__LONG_DOUBLE_128__}"
59 #endif
61 /* Provide a STARTFILE_SPEC appropriate for GNU/Linux. Here we add
62 the GNU/Linux magical crtbegin.o file (see crtstuff.c) which
63 provides part of the support for getting C++ file-scope static
64 object constructed before entering `main'. */
66 #undef STARTFILE_SPEC
68 #ifdef HAVE_LD_PIE
69 #define STARTFILE_SPEC \
70 "%{!shared:%{pg|p:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}}\
71 crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbeginS.o%s}"
72 #else
73 #define STARTFILE_SPEC \
74 "%{!shared:%{pg|p:gcrt1.o%s;:crt1.o%s}}\
75 crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbeginS.o%s}"
76 #endif
78 /* Provide a ENDFILE_SPEC appropriate for GNU/Linux. Here we tack on
79 the GNU/Linux magical crtend.o file (see crtstuff.c) which
80 provides part of the support for getting C++ file-scope static
81 object constructed before entering `main', followed by a normal
82 GNU/Linux "finalizer" file, `crtn.o'. */
84 #undef ENDFILE_SPEC
86 #define ENDFILE_SPEC \
87 "%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s\
88 %{ffast-math|funsafe-math-optimizations:crtfastmath.o%s}"
90 /* The GNU C++ standard library requires that these macros be defined. */
91 #undef CPLUSPLUS_CPP_SPEC
92 #define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
94 #undef TARGET_VERSION
95 #define TARGET_VERSION fprintf (stderr, " (sparc64 GNU/Linux with ELF)");
97 /* The default code model. */
98 #undef SPARC_DEFAULT_CMODEL
99 #define SPARC_DEFAULT_CMODEL CM_MEDLOW
101 #undef SUBTARGET_SWITCHES
102 #define SUBTARGET_SWITCHES \
103 {"long-double-64", -MASK_LONG_DOUBLE_128, N_("Use 64 bit long doubles") }, \
104 {"long-double-128", MASK_LONG_DOUBLE_128, N_("Use 128 bit long doubles") },
106 #undef WCHAR_TYPE
107 #define WCHAR_TYPE "int"
109 #undef WCHAR_TYPE_SIZE
110 #define WCHAR_TYPE_SIZE 32
112 /* Define for support of TFmode long double.
113 SPARC ABI says that long double is 4 words. */
114 #undef LONG_DOUBLE_TYPE_SIZE
115 #define LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64)
117 /* Constant which presents upper bound of the above value. */
118 #undef MAX_LONG_DOUBLE_TYPE_SIZE
119 #define MAX_LONG_DOUBLE_TYPE_SIZE 128
121 /* Define this to set long double type size to use in libgcc2.c, which can
122 not depend on target_flags. */
123 #if defined(__arch64__) || defined(__LONG_DOUBLE_128__)
124 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 128
125 #else
126 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64
127 #endif
129 #undef CPP_SUBTARGET_SPEC
130 #define CPP_SUBTARGET_SPEC "\
131 %{fPIC|fpic|fPIE|fpie:-D__PIC__ -D__pic__} \
132 %{posix:-D_POSIX_SOURCE} \
133 %{pthread:-D_REENTRANT} \
136 #undef LIB_SPEC
137 #define LIB_SPEC \
138 "%{pthread:-lpthread} \
139 %{shared:-lc} \
140 %{!shared: %{mieee-fp:-lieee} %{profile:-lc_p}%{!profile:-lc}}"
142 /* Provide a LINK_SPEC appropriate for GNU/Linux. Here we provide support
143 for the special GCC options -static and -shared, which allow us to
144 link things in one of these three modes by applying the appropriate
145 combinations of options at link-time. We like to support here for
146 as many of the other GNU linker options as possible. But I don't
147 have the time to search for those flags. I am sure how to add
148 support for -soname shared_object_name. H.J.
150 I took out %{v:%{!V:-V}}. It is too much :-(. They can use
151 -Wl,-V.
153 When the -shared link option is used a final link is not being
154 done. */
156 /* If ELF is the default format, we should not use /lib/elf. */
158 #ifdef SPARC_BI_ARCH
160 #undef SUBTARGET_EXTRA_SPECS
161 #define SUBTARGET_EXTRA_SPECS \
162 { "link_arch32", LINK_ARCH32_SPEC }, \
163 { "link_arch64", LINK_ARCH64_SPEC }, \
164 { "link_arch_default", LINK_ARCH_DEFAULT_SPEC }, \
165 { "link_arch", LINK_ARCH_SPEC },
167 #define LINK_ARCH32_SPEC "-m elf32_sparc -Y P,/usr/lib %{shared:-shared} \
168 %{!shared: \
169 %{!ibcs: \
170 %{!static: \
171 %{rdynamic:-export-dynamic} \
172 %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \
173 %{static:-static}}} \
176 #define LINK_ARCH64_SPEC "-m elf64_sparc -Y P,/usr/lib64 %{shared:-shared} \
177 %{!shared: \
178 %{!ibcs: \
179 %{!static: \
180 %{rdynamic:-export-dynamic} \
181 %{!dynamic-linker:-dynamic-linker /lib64/ld-linux.so.2}} \
182 %{static:-static}}} \
185 #define LINK_ARCH_SPEC "\
186 %{m32:%(link_arch32)} \
187 %{m64:%(link_arch64)} \
188 %{!m32:%{!m64:%(link_arch_default)}} \
191 #define LINK_ARCH_DEFAULT_SPEC \
192 (DEFAULT_ARCH32_P ? LINK_ARCH32_SPEC : LINK_ARCH64_SPEC)
194 #undef LINK_SPEC
195 #define LINK_SPEC "\
196 %(link_arch) \
197 %{mlittle-endian:-EL} \
198 %{!mno-relax:%{!r:-relax}} \
201 #undef CC1_SPEC
202 #if DEFAULT_ARCH32_P
203 #define CC1_SPEC "\
204 %{sun4:} %{target:} \
205 %{mcypress:-mcpu=cypress} \
206 %{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \
207 %{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \
208 %{m32:%{m64:%emay not use both -m32 and -m64}} \
209 %{m64:-mptr64 -mstack-bias -mlong-double-128 \
210 %{!mcpu*:%{!mcypress:%{!msparclite:%{!mf930:%{!mf934:%{!mv8:%{!msupersparc:-mcpu=ultrasparc}}}}}}} \
211 %{!mno-vis:%{!mcpu=v9:-mvis}}} \
213 #else
214 #define CC1_SPEC "\
215 %{sun4:} %{target:} \
216 %{mcypress:-mcpu=cypress} \
217 %{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \
218 %{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \
219 %{m32:%{m64:%emay not use both -m32 and -m64}} \
220 %{m32:-mptr32 -mno-stack-bias %{!mlong-double-128:-mlong-double-64} \
221 %{!mcpu*:%{!mcypress:%{!msparclite:%{!mf930:%{!mf934:%{!mv8:%{!msupersparc:-mcpu=cypress}}}}}}}} \
222 %{!m32:%{!mcpu*:-mcpu=ultrasparc}} \
223 %{!mno-vis:%{!m32:%{!mcpu=v9:-mvis}}} \
225 #endif
227 #if DEFAULT_ARCH32_P
228 #define MULTILIB_DEFAULTS { "m32" }
229 #else
230 #define MULTILIB_DEFAULTS { "m64" }
231 #endif
233 #else /* !SPARC_BI_ARCH */
235 #undef LINK_SPEC
236 #define LINK_SPEC "-m elf64_sparc -Y P,/usr/lib64 %{shared:-shared} \
237 %{!shared: \
238 %{!ibcs: \
239 %{!static: \
240 %{rdynamic:-export-dynamic} \
241 %{!dynamic-linker:-dynamic-linker /lib64/ld-linux.so.2}} \
242 %{static:-static}}} \
243 %{mlittle-endian:-EL} \
244 %{!mno-relax:%{!r:-relax}} \
247 #endif /* !SPARC_BI_ARCH */
249 /* The sun bundled assembler doesn't accept -Yd, (and neither does gas).
250 It's safe to pass -s always, even if -g is not used. */
251 #undef ASM_SPEC
252 #define ASM_SPEC "\
253 %{V} \
254 %{v:%{!V:-V}} \
255 %{!Qn:-Qy} \
256 %{n} \
257 %{T} \
258 %{Ym,*} \
259 %{Wa,*:%*} \
260 -s %{fpic|fPIC|fpie|fPIE:-K PIC} \
261 %{mlittle-endian:-EL} \
262 %(asm_cpu) %(asm_arch) %(asm_relax)"
264 /* Same as sparc.h */
265 #undef DBX_REGISTER_NUMBER
266 #define DBX_REGISTER_NUMBER(REGNO) (REGNO)
268 #define DWARF2_DEBUGGING_INFO 1
269 #define DBX_DEBUGGING_INFO 1
271 #undef ASM_OUTPUT_ALIGNED_LOCAL
272 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
273 do { \
274 fputs ("\t.local\t", (FILE)); \
275 assemble_name ((FILE), (NAME)); \
276 putc ('\n', (FILE)); \
277 ASM_OUTPUT_ALIGNED_COMMON (FILE, NAME, SIZE, ALIGN); \
278 } while (0)
280 #undef COMMON_ASM_OP
281 #define COMMON_ASM_OP "\t.common\t"
283 #undef LOCAL_LABEL_PREFIX
284 #define LOCAL_LABEL_PREFIX "."
286 /* This is how to output a reference to an internal numbered label where
287 PREFIX is the class of label and NUM is the number within the class. */
289 #undef ASM_OUTPUT_INTERNAL_LABELREF
290 #define ASM_OUTPUT_INTERNAL_LABELREF(FILE,PREFIX,NUM) \
291 fprintf (FILE, ".L%s%d", PREFIX, NUM)
293 /* This is how to store into the string LABEL
294 the symbol_ref name of an internal numbered label where
295 PREFIX is the class of label and NUM is the number within the class.
296 This is suitable for output with `assemble_name'. */
298 #undef ASM_GENERATE_INTERNAL_LABEL
299 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \
300 sprintf (LABEL, "*.L%s%ld", PREFIX, (long)(NUM))
302 /* DWARF bits. */
304 /* Follow Irix 6 and not the Dwarf2 draft in using 64-bit offsets.
305 Obviously the Dwarf2 folks haven't tried to actually build systems
306 with their spec. On a 64-bit system, only 64-bit relocs become
307 RELATIVE relocations. */
309 /* #define DWARF_OFFSET_SIZE PTR_SIZE */
311 #undef DITF_CONVERSION_LIBFUNCS
312 #define DITF_CONVERSION_LIBFUNCS 1
314 #if defined(HAVE_LD_EH_FRAME_HDR)
315 #define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
316 #endif
318 #ifdef HAVE_AS_TLS
319 #undef TARGET_SUN_TLS
320 #undef TARGET_GNU_TLS
321 #define TARGET_SUN_TLS 0
322 #define TARGET_GNU_TLS 1
323 #endif
325 /* Don't be different from other Linux platforms in this regard. */
326 #define HANDLE_PRAGMA_PACK_PUSH_POP
328 /* We use GNU ld so undefine this so that attribute((init_priority)) works. */
329 #undef CTORS_SECTION_ASM_OP
330 #undef DTORS_SECTION_ASM_OP
332 #define TARGET_ASM_FILE_END file_end_indicate_exec_stack
334 #define TARGET_HAS_F_SETLKW
336 #undef LINK_GCC_C_SEQUENCE_SPEC
337 #define LINK_GCC_C_SEQUENCE_SPEC \
338 "%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}"
340 /* Do code reading to identify a signal frame, and set the frame
341 state data appropriately. See unwind-dw2.c for the structs. */
343 /* Handle multilib correctly. */
344 #if defined(__arch64__)
345 /* 64-bit SPARC version */
346 #define MD_FALLBACK_FRAME_STATE_FOR(CONTEXT, FS, SUCCESS) \
347 do { \
348 unsigned int *pc_ = (CONTEXT)->ra; \
349 long new_cfa_, i_; \
350 long regs_off_, fpu_save_off_; \
351 long this_cfa_, fpu_save_; \
353 if (pc_[0] != 0x82102065 /* mov NR_rt_sigreturn, %g1 */ \
354 || pc_[1] != 0x91d0206d) /* ta 0x6d */ \
355 break; \
356 regs_off_ = 192 + 128; \
357 fpu_save_off_ = regs_off_ + (16 * 8) + (3 * 8) + (2 * 4); \
358 this_cfa_ = (long) (CONTEXT)->cfa; \
359 new_cfa_ = *(long *)(((CONTEXT)->cfa) + (regs_off_ + (14 * 8))); \
360 new_cfa_ += 2047; /* Stack bias */ \
361 fpu_save_ = *(long *)((this_cfa_) + (fpu_save_off_)); \
362 (FS)->cfa_how = CFA_REG_OFFSET; \
363 (FS)->cfa_reg = 14; \
364 (FS)->cfa_offset = new_cfa_ - (long) (CONTEXT)->cfa; \
365 for (i_ = 1; i_ < 16; ++i_) \
367 (FS)->regs.reg[i_].how = REG_SAVED_OFFSET; \
368 (FS)->regs.reg[i_].loc.offset = \
369 this_cfa_ + (regs_off_ + (i_ * 8)) - new_cfa_; \
371 for (i_ = 0; i_ < 16; ++i_) \
373 (FS)->regs.reg[i_ + 16].how = REG_SAVED_OFFSET; \
374 (FS)->regs.reg[i_ + 16].loc.offset = \
375 this_cfa_ + (i_ * 8) - new_cfa_; \
377 if (fpu_save_) \
379 for (i_ = 0; i_ < 64; ++i_) \
381 if (i_ > 32 && (i_ & 0x1)) \
382 continue; \
383 (FS)->regs.reg[i_ + 32].how = REG_SAVED_OFFSET; \
384 (FS)->regs.reg[i_ + 32].loc.offset = \
385 (fpu_save_ + (i_ * 4)) - new_cfa_; \
388 /* Stick return address into %g0, same trick Alpha uses. */ \
389 (FS)->regs.reg[0].how = REG_SAVED_OFFSET; \
390 (FS)->regs.reg[0].loc.offset = \
391 this_cfa_ + (regs_off_ + (16 * 8) + 8) - new_cfa_; \
392 (FS)->retaddr_column = 0; \
393 goto SUCCESS; \
394 } while (0)
395 #else
396 /* 32-bit SPARC version */
397 #define MD_FALLBACK_FRAME_STATE_FOR(CONTEXT, FS, SUCCESS) \
398 do { \
399 unsigned int *pc_ = (CONTEXT)->ra; \
400 int new_cfa_, i_, oldstyle_; \
401 int regs_off_, fpu_save_off_; \
402 int fpu_save_, this_cfa_; \
404 if (pc_[1] != 0x91d02010) /* ta 0x10 */ \
405 break; \
406 if (pc_[0] == 0x821020d8) /* mov NR_sigreturn, %g1 */ \
407 oldstyle_ = 1; \
408 else if (pc_[0] == 0x82102065) /* mov NR_rt_sigreturn, %g1 */ \
409 oldstyle_ = 0; \
410 else \
411 break; \
412 if (oldstyle_) \
414 regs_off_ = 96; \
415 fpu_save_off_ = regs_off_ + (4 * 4) + (16 * 4); \
417 else \
419 regs_off_ = 96 + 128; \
420 fpu_save_off_ = regs_off_ + (4 * 4) + (16 * 4) + (2 * 4); \
422 this_cfa_ = (int) (CONTEXT)->cfa; \
423 new_cfa_ = *(int *)(((CONTEXT)->cfa) + (regs_off_+(4*4)+(14 * 4))); \
424 fpu_save_ = *(int *)((this_cfa_) + (fpu_save_off_)); \
425 (FS)->cfa_how = CFA_REG_OFFSET; \
426 (FS)->cfa_reg = 14; \
427 (FS)->cfa_offset = new_cfa_ - (int) (CONTEXT)->cfa; \
428 for (i_ = 1; i_ < 16; ++i_) \
430 if (i_ == 14) \
431 continue; \
432 (FS)->regs.reg[i_].how = REG_SAVED_OFFSET; \
433 (FS)->regs.reg[i_].loc.offset = \
434 this_cfa_ + (regs_off_+(4 * 4)+(i_ * 4)) - new_cfa_; \
436 for (i_ = 0; i_ < 16; ++i_) \
438 (FS)->regs.reg[i_ + 16].how = REG_SAVED_OFFSET; \
439 (FS)->regs.reg[i_ + 16].loc.offset = \
440 this_cfa_ + (i_ * 4) - new_cfa_; \
442 if (fpu_save_) \
444 for (i_ = 0; i_ < 32; ++i_) \
446 (FS)->regs.reg[i_ + 32].how = REG_SAVED_OFFSET; \
447 (FS)->regs.reg[i_ + 32].loc.offset = \
448 (fpu_save_ + (i_ * 4)) - new_cfa_; \
451 /* Stick return address into %g0, same trick Alpha uses. */ \
452 (FS)->regs.reg[0].how = REG_SAVED_OFFSET; \
453 (FS)->regs.reg[0].loc.offset = this_cfa_+(regs_off_+4)-new_cfa_; \
454 (FS)->retaddr_column = 0; \
455 goto SUCCESS; \
456 } while (0)
457 #endif