* config/ia64/ia64.md: Define new attribute "empty".
[official-gcc.git] / gcc / config / sparc / linux64.h
blob78d657c27ecd74c3846fbb735226ae91d051bee2
1 /* Definitions for 64-bit SPARC running Linux-based GNU systems with ELF.
2 Copyright 1996, 1997, 1998, 2000, 2002, 2003, 2004
3 Free Software Foundation, Inc.
4 Contributed by David S. Miller (davem@caip.rutgers.edu)
6 This file is part of GCC.
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 2, or (at your option)
11 any later version.
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.
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING. If not, write to
20 the Free Software Foundation, 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
23 #define TARGET_OS_CPP_BUILTINS() \
24 do \
25 { \
26 builtin_define_std ("unix"); \
27 builtin_define_std ("linux"); \
28 builtin_define ("_LONGLONG"); \
29 builtin_define ("__gnu_linux__"); \
30 builtin_assert ("system=linux"); \
31 builtin_assert ("system=unix"); \
32 builtin_assert ("system=posix"); \
33 } \
34 while (0)
36 /* Don't assume anything about the header files. */
37 #define NO_IMPLICIT_EXTERN_C
39 #undef MD_EXEC_PREFIX
40 #undef MD_STARTFILE_PREFIX
42 #if TARGET_CPU_DEFAULT == TARGET_CPU_v9 \
43 || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc \
44 || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc3
45 /* A 64 bit v9 compiler with stack-bias,
46 in a Medium/Low code model environment. */
48 #undef TARGET_DEFAULT
49 #define TARGET_DEFAULT \
50 (MASK_V9 + MASK_PTR64 + MASK_64BIT /* + MASK_HARD_QUAD */ \
51 + MASK_STACK_BIAS + MASK_APP_REGS + MASK_FPU + MASK_LONG_DOUBLE_128)
52 #endif
54 #undef ASM_CPU_DEFAULT_SPEC
55 #define ASM_CPU_DEFAULT_SPEC "-Av9a"
57 #ifdef SPARC_BI_ARCH
59 #undef CPP_ARCH32_SPEC
60 #define CPP_ARCH32_SPEC "%{mlong-double-128:-D__LONG_DOUBLE_128__}"
62 #endif
64 /* Provide a STARTFILE_SPEC appropriate for GNU/Linux. Here we add
65 the GNU/Linux magical crtbegin.o file (see crtstuff.c) which
66 provides part of the support for getting C++ file-scope static
67 object constructed before entering `main'. */
69 #undef STARTFILE_SPEC
71 #ifdef HAVE_LD_PIE
72 #define STARTFILE_SPEC \
73 "%{!shared:%{pg|p:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}}\
74 crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbeginS.o%s}"
75 #else
76 #define STARTFILE_SPEC \
77 "%{!shared:%{pg|p:gcrt1.o%s;:crt1.o%s}}\
78 crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbeginS.o%s}"
79 #endif
81 /* Provide a ENDFILE_SPEC appropriate for GNU/Linux. Here we tack on
82 the GNU/Linux magical crtend.o file (see crtstuff.c) which
83 provides part of the support for getting C++ file-scope static
84 object constructed before entering `main', followed by a normal
85 GNU/Linux "finalizer" file, `crtn.o'. */
87 #undef ENDFILE_SPEC
89 #define ENDFILE_SPEC \
90 "%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s\
91 %{ffast-math|funsafe-math-optimizations:crtfastmath.o%s}"
93 /* The GNU C++ standard library requires that these macros be defined. */
94 #undef CPLUSPLUS_CPP_SPEC
95 #define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
97 #undef TARGET_VERSION
98 #define TARGET_VERSION fprintf (stderr, " (sparc64 GNU/Linux with ELF)");
100 /* The default code model. */
101 #undef SPARC_DEFAULT_CMODEL
102 #define SPARC_DEFAULT_CMODEL CM_MEDLOW
104 #undef SUBTARGET_SWITCHES
105 #define SUBTARGET_SWITCHES \
106 {"long-double-64", -MASK_LONG_DOUBLE_128, N_("Use 64 bit long doubles") }, \
107 {"long-double-128", MASK_LONG_DOUBLE_128, N_("Use 128 bit long doubles") },
109 #undef WCHAR_TYPE
110 #define WCHAR_TYPE "int"
112 #undef WCHAR_TYPE_SIZE
113 #define WCHAR_TYPE_SIZE 32
115 /* Define for support of TFmode long double.
116 SPARC ABI says that long double is 4 words. */
117 #undef LONG_DOUBLE_TYPE_SIZE
118 #define LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64)
120 /* Define this to set long double type size to use in libgcc2.c, which can
121 not depend on target_flags. */
122 #if defined(__arch64__) || defined(__LONG_DOUBLE_128__)
123 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 128
124 #else
125 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64
126 #endif
128 #undef CPP_SUBTARGET_SPEC
129 #define CPP_SUBTARGET_SPEC "\
130 %{fPIC|fpic|fPIE|fpie:-D__PIC__ -D__pic__} \
131 %{posix:-D_POSIX_SOURCE} \
132 %{pthread:-D_REENTRANT} \
135 #undef LIB_SPEC
136 #define LIB_SPEC \
137 "%{pthread:-lpthread} \
138 %{shared:-lc} \
139 %{!shared: %{mieee-fp:-lieee} %{profile:-lc_p}%{!profile:-lc}}"
141 /* Provide a LINK_SPEC appropriate for GNU/Linux. Here we provide support
142 for the special GCC options -static and -shared, which allow us to
143 link things in one of these three modes by applying the appropriate
144 combinations of options at link-time. We like to support here for
145 as many of the other GNU linker options as possible. But I don't
146 have the time to search for those flags. I am sure how to add
147 support for -soname shared_object_name. H.J.
149 I took out %{v:%{!V:-V}}. It is too much :-(. They can use
150 -Wl,-V.
152 When the -shared link option is used a final link is not being
153 done. */
155 /* If ELF is the default format, we should not use /lib/elf. */
157 #ifdef SPARC_BI_ARCH
159 #undef SUBTARGET_EXTRA_SPECS
160 #define SUBTARGET_EXTRA_SPECS \
161 { "link_arch32", LINK_ARCH32_SPEC }, \
162 { "link_arch64", LINK_ARCH64_SPEC }, \
163 { "link_arch_default", LINK_ARCH_DEFAULT_SPEC }, \
164 { "link_arch", LINK_ARCH_SPEC },
166 #define LINK_ARCH32_SPEC "-m elf32_sparc -Y P,/usr/lib %{shared:-shared} \
167 %{!shared: \
168 %{!ibcs: \
169 %{!static: \
170 %{rdynamic:-export-dynamic} \
171 %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \
172 %{static:-static}}} \
175 #define LINK_ARCH64_SPEC "-m elf64_sparc -Y P,/usr/lib64 %{shared:-shared} \
176 %{!shared: \
177 %{!ibcs: \
178 %{!static: \
179 %{rdynamic:-export-dynamic} \
180 %{!dynamic-linker:-dynamic-linker /lib64/ld-linux.so.2}} \
181 %{static:-static}}} \
184 #define LINK_ARCH_SPEC "\
185 %{m32:%(link_arch32)} \
186 %{m64:%(link_arch64)} \
187 %{!m32:%{!m64:%(link_arch_default)}} \
190 #define LINK_ARCH_DEFAULT_SPEC \
191 (DEFAULT_ARCH32_P ? LINK_ARCH32_SPEC : LINK_ARCH64_SPEC)
193 #undef LINK_SPEC
194 #define LINK_SPEC "\
195 %(link_arch) \
196 %{mlittle-endian:-EL} \
197 %{!mno-relax:%{!r:-relax}} \
200 #undef CC1_SPEC
201 #if DEFAULT_ARCH32_P
202 #define CC1_SPEC "\
203 %{sun4:} %{target:} \
204 %{mcypress:-mcpu=cypress} \
205 %{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \
206 %{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \
207 %{m32:%{m64:%emay not use both -m32 and -m64}} \
208 %{m64:-mptr64 -mstack-bias -mlong-double-128 \
209 %{!mcpu*:%{!mcypress:%{!msparclite:%{!mf930:%{!mf934:%{!mv8:%{!msupersparc:-mcpu=ultrasparc}}}}}}} \
210 %{!mno-vis:%{!mcpu=v9:-mvis}}} \
212 #else
213 #define CC1_SPEC "\
214 %{sun4:} %{target:} \
215 %{mcypress:-mcpu=cypress} \
216 %{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \
217 %{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \
218 %{m32:%{m64:%emay not use both -m32 and -m64}} \
219 %{m32:-mptr32 -mno-stack-bias %{!mlong-double-128:-mlong-double-64} \
220 %{!mcpu*:%{!mcypress:%{!msparclite:%{!mf930:%{!mf934:%{!mv8:%{!msupersparc:-mcpu=cypress}}}}}}}} \
221 %{!m32:%{!mcpu*:-mcpu=ultrasparc}} \
222 %{!mno-vis:%{!m32:%{!mcpu=v9:-mvis}}} \
224 #endif
226 /* Support for a compile-time default CPU, et cetera. The rules are:
227 --with-cpu is ignored if -mcpu is specified.
228 --with-tune is ignored if -mtune is specified.
229 --with-float is ignored if -mhard-float, -msoft-float, -mfpu, or -mno-fpu
230 are specified.
231 In the SPARC_BI_ARCH compiler we cannot pass %{!mcpu=*:-mcpu=%(VALUE)}
232 here, otherwise say -mcpu=v7 would be passed even when -m64.
233 CC1_SPEC above takes care of this instead. */
234 #undef OPTION_DEFAULT_SPECS
235 #if DEFAULT_ARCH32_P
236 #define OPTION_DEFAULT_SPECS \
237 {"cpu", "%{!m64:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
238 {"tune", "%{!mtune=*:-mtune=%(VALUE)}" }, \
239 {"float", "%{!msoft-float:%{!mhard-float:%{!fpu:%{!no-fpu:-m%(VALUE)-float}}}}" }
240 #else
241 #define OPTION_DEFAULT_SPECS \
242 {"cpu", "%{!m32:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
243 {"tune", "%{!mtune=*:-mtune=%(VALUE)}" }, \
244 {"float", "%{!msoft-float:%{!mhard-float:%{!fpu:%{!no-fpu:-m%(VALUE)-float}}}}" }
245 #endif
247 #if DEFAULT_ARCH32_P
248 #define MULTILIB_DEFAULTS { "m32" }
249 #else
250 #define MULTILIB_DEFAULTS { "m64" }
251 #endif
253 #else /* !SPARC_BI_ARCH */
255 #undef LINK_SPEC
256 #define LINK_SPEC "-m elf64_sparc -Y P,/usr/lib64 %{shared:-shared} \
257 %{!shared: \
258 %{!ibcs: \
259 %{!static: \
260 %{rdynamic:-export-dynamic} \
261 %{!dynamic-linker:-dynamic-linker /lib64/ld-linux.so.2}} \
262 %{static:-static}}} \
263 %{mlittle-endian:-EL} \
264 %{!mno-relax:%{!r:-relax}} \
267 #endif /* !SPARC_BI_ARCH */
269 /* The sun bundled assembler doesn't accept -Yd, (and neither does gas).
270 It's safe to pass -s always, even if -g is not used. */
271 #undef ASM_SPEC
272 #define ASM_SPEC "\
273 %{V} \
274 %{v:%{!V:-V}} \
275 %{!Qn:-Qy} \
276 %{n} \
277 %{T} \
278 %{Ym,*} \
279 %{Wa,*:%*} \
280 -s %{fpic|fPIC|fpie|fPIE:-K PIC} \
281 %{mlittle-endian:-EL} \
282 %(asm_cpu) %(asm_arch) %(asm_relax)"
284 /* Same as sparc.h */
285 #undef DBX_REGISTER_NUMBER
286 #define DBX_REGISTER_NUMBER(REGNO) (REGNO)
288 #define DWARF2_DEBUGGING_INFO 1
289 #define DBX_DEBUGGING_INFO 1
291 #undef ASM_OUTPUT_ALIGNED_LOCAL
292 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
293 do { \
294 fputs ("\t.local\t", (FILE)); \
295 assemble_name ((FILE), (NAME)); \
296 putc ('\n', (FILE)); \
297 ASM_OUTPUT_ALIGNED_COMMON (FILE, NAME, SIZE, ALIGN); \
298 } while (0)
300 #undef COMMON_ASM_OP
301 #define COMMON_ASM_OP "\t.common\t"
303 #undef LOCAL_LABEL_PREFIX
304 #define LOCAL_LABEL_PREFIX "."
306 /* This is how to output a reference to an internal numbered label where
307 PREFIX is the class of label and NUM is the number within the class. */
309 #undef ASM_OUTPUT_INTERNAL_LABELREF
310 #define ASM_OUTPUT_INTERNAL_LABELREF(FILE,PREFIX,NUM) \
311 fprintf (FILE, ".L%s%d", PREFIX, NUM)
313 /* This is how to store into the string LABEL
314 the symbol_ref name of an internal numbered label where
315 PREFIX is the class of label and NUM is the number within the class.
316 This is suitable for output with `assemble_name'. */
318 #undef ASM_GENERATE_INTERNAL_LABEL
319 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \
320 sprintf (LABEL, "*.L%s%ld", PREFIX, (long)(NUM))
322 /* DWARF bits. */
324 /* Follow Irix 6 and not the Dwarf2 draft in using 64-bit offsets.
325 Obviously the Dwarf2 folks haven't tried to actually build systems
326 with their spec. On a 64-bit system, only 64-bit relocs become
327 RELATIVE relocations. */
329 /* #define DWARF_OFFSET_SIZE PTR_SIZE */
331 #undef DITF_CONVERSION_LIBFUNCS
332 #define DITF_CONVERSION_LIBFUNCS 1
334 #if defined(HAVE_LD_EH_FRAME_HDR)
335 #define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
336 #endif
338 #ifdef HAVE_AS_TLS
339 #undef TARGET_SUN_TLS
340 #undef TARGET_GNU_TLS
341 #define TARGET_SUN_TLS 0
342 #define TARGET_GNU_TLS 1
343 #endif
345 /* Don't be different from other Linux platforms in this regard. */
346 #define HANDLE_PRAGMA_PACK_PUSH_POP
348 /* We use GNU ld so undefine this so that attribute((init_priority)) works. */
349 #undef CTORS_SECTION_ASM_OP
350 #undef DTORS_SECTION_ASM_OP
352 #define TARGET_ASM_FILE_END file_end_indicate_exec_stack
354 /* Determine whether the the entire c99 runtime is present in the
355 runtime library. */
356 #define TARGET_C99_FUNCTIONS 1
358 #define TARGET_HAS_F_SETLKW
360 #undef LINK_GCC_C_SEQUENCE_SPEC
361 #define LINK_GCC_C_SEQUENCE_SPEC \
362 "%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}"
364 /* Use --as-needed -lgcc_s for eh support. */
365 #ifdef HAVE_LD_AS_NEEDED
366 #define USE_LD_AS_NEEDED 1
367 #endif
369 /* Do code reading to identify a signal frame, and set the frame
370 state data appropriately. See unwind-dw2.c for the structs. */
372 /* Handle multilib correctly. */
373 #if defined(__arch64__)
374 /* 64-bit SPARC version */
375 #define MD_FALLBACK_FRAME_STATE_FOR(CONTEXT, FS, SUCCESS) \
376 do { \
377 unsigned int *pc_ = (CONTEXT)->ra; \
378 long new_cfa_, i_; \
379 long regs_off_, fpu_save_off_; \
380 long this_cfa_, fpu_save_; \
382 if (pc_[0] != 0x82102065 /* mov NR_rt_sigreturn, %g1 */ \
383 || pc_[1] != 0x91d0206d) /* ta 0x6d */ \
384 break; \
385 regs_off_ = 192 + 128; \
386 fpu_save_off_ = regs_off_ + (16 * 8) + (3 * 8) + (2 * 4); \
387 this_cfa_ = (long) (CONTEXT)->cfa; \
388 new_cfa_ = *(long *)(((CONTEXT)->cfa) + (regs_off_ + (14 * 8))); \
389 new_cfa_ += 2047; /* Stack bias */ \
390 fpu_save_ = *(long *)((this_cfa_) + (fpu_save_off_)); \
391 (FS)->cfa_how = CFA_REG_OFFSET; \
392 (FS)->cfa_reg = 14; \
393 (FS)->cfa_offset = new_cfa_ - (long) (CONTEXT)->cfa; \
394 for (i_ = 1; i_ < 16; ++i_) \
396 (FS)->regs.reg[i_].how = REG_SAVED_OFFSET; \
397 (FS)->regs.reg[i_].loc.offset = \
398 this_cfa_ + (regs_off_ + (i_ * 8)) - new_cfa_; \
400 for (i_ = 0; i_ < 16; ++i_) \
402 (FS)->regs.reg[i_ + 16].how = REG_SAVED_OFFSET; \
403 (FS)->regs.reg[i_ + 16].loc.offset = \
404 this_cfa_ + (i_ * 8) - new_cfa_; \
406 if (fpu_save_) \
408 for (i_ = 0; i_ < 64; ++i_) \
410 if (i_ > 32 && (i_ & 0x1)) \
411 continue; \
412 (FS)->regs.reg[i_ + 32].how = REG_SAVED_OFFSET; \
413 (FS)->regs.reg[i_ + 32].loc.offset = \
414 (fpu_save_ + (i_ * 4)) - new_cfa_; \
417 /* Stick return address into %g0, same trick Alpha uses. */ \
418 (FS)->regs.reg[0].how = REG_SAVED_OFFSET; \
419 (FS)->regs.reg[0].loc.offset = \
420 this_cfa_ + (regs_off_ + (16 * 8) + 8) - new_cfa_; \
421 (FS)->retaddr_column = 0; \
422 goto SUCCESS; \
423 } while (0)
424 #else
425 /* 32-bit SPARC version */
426 #define MD_FALLBACK_FRAME_STATE_FOR(CONTEXT, FS, SUCCESS) \
427 do { \
428 unsigned int *pc_ = (CONTEXT)->ra; \
429 int new_cfa_, i_, oldstyle_; \
430 int regs_off_, fpu_save_off_; \
431 int fpu_save_, this_cfa_; \
433 if (pc_[1] != 0x91d02010) /* ta 0x10 */ \
434 break; \
435 if (pc_[0] == 0x821020d8) /* mov NR_sigreturn, %g1 */ \
436 oldstyle_ = 1; \
437 else if (pc_[0] == 0x82102065) /* mov NR_rt_sigreturn, %g1 */ \
438 oldstyle_ = 0; \
439 else \
440 break; \
441 if (oldstyle_) \
443 regs_off_ = 96; \
444 fpu_save_off_ = regs_off_ + (4 * 4) + (16 * 4); \
446 else \
448 regs_off_ = 96 + 128; \
449 fpu_save_off_ = regs_off_ + (4 * 4) + (16 * 4) + (2 * 4); \
451 this_cfa_ = (int) (CONTEXT)->cfa; \
452 new_cfa_ = *(int *)(((CONTEXT)->cfa) + (regs_off_+(4*4)+(14 * 4))); \
453 fpu_save_ = *(int *)((this_cfa_) + (fpu_save_off_)); \
454 (FS)->cfa_how = CFA_REG_OFFSET; \
455 (FS)->cfa_reg = 14; \
456 (FS)->cfa_offset = new_cfa_ - (int) (CONTEXT)->cfa; \
457 for (i_ = 1; i_ < 16; ++i_) \
459 if (i_ == 14) \
460 continue; \
461 (FS)->regs.reg[i_].how = REG_SAVED_OFFSET; \
462 (FS)->regs.reg[i_].loc.offset = \
463 this_cfa_ + (regs_off_+(4 * 4)+(i_ * 4)) - new_cfa_; \
465 for (i_ = 0; i_ < 16; ++i_) \
467 (FS)->regs.reg[i_ + 16].how = REG_SAVED_OFFSET; \
468 (FS)->regs.reg[i_ + 16].loc.offset = \
469 this_cfa_ + (i_ * 4) - new_cfa_; \
471 if (fpu_save_) \
473 for (i_ = 0; i_ < 32; ++i_) \
475 (FS)->regs.reg[i_ + 32].how = REG_SAVED_OFFSET; \
476 (FS)->regs.reg[i_ + 32].loc.offset = \
477 (fpu_save_ + (i_ * 4)) - new_cfa_; \
480 /* Stick return address into %g0, same trick Alpha uses. */ \
481 (FS)->regs.reg[0].how = REG_SAVED_OFFSET; \
482 (FS)->regs.reg[0].loc.offset = this_cfa_+(regs_off_+4)-new_cfa_; \
483 (FS)->retaddr_column = 0; \
484 goto SUCCESS; \
485 } while (0)
486 #endif