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)
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() \
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"); \
36 /* Don't assume anything about the header files. */
37 #define NO_IMPLICIT_EXTERN_C
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. */
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)
54 #undef ASM_CPU_DEFAULT_SPEC
55 #define ASM_CPU_DEFAULT_SPEC "-Av9a"
59 #undef CPP_ARCH32_SPEC
60 #define CPP_ARCH32_SPEC "%{mlong-double-128:-D__LONG_DOUBLE_128__}"
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'. */
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}"
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}"
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'. */
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)"
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") },
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 /* Constant which presents upper bound of the above value. */
121 #undef MAX_LONG_DOUBLE_TYPE_SIZE
122 #define MAX_LONG_DOUBLE_TYPE_SIZE 128
124 /* Define this to set long double type size to use in libgcc2.c, which can
125 not depend on target_flags. */
126 #if defined(__arch64__) || defined(__LONG_DOUBLE_128__)
127 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 128
129 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64
132 #undef CPP_SUBTARGET_SPEC
133 #define CPP_SUBTARGET_SPEC "\
134 %{fPIC|fpic|fPIE|fpie:-D__PIC__ -D__pic__} \
135 %{posix:-D_POSIX_SOURCE} \
136 %{pthread:-D_REENTRANT} \
141 "%{pthread:-lpthread} \
143 %{!shared: %{mieee-fp:-lieee} %{profile:-lc_p}%{!profile:-lc}}"
145 /* Provide a LINK_SPEC appropriate for GNU/Linux. Here we provide support
146 for the special GCC options -static and -shared, which allow us to
147 link things in one of these three modes by applying the appropriate
148 combinations of options at link-time. We like to support here for
149 as many of the other GNU linker options as possible. But I don't
150 have the time to search for those flags. I am sure how to add
151 support for -soname shared_object_name. H.J.
153 I took out %{v:%{!V:-V}}. It is too much :-(. They can use
156 When the -shared link option is used a final link is not being
159 /* If ELF is the default format, we should not use /lib/elf. */
163 #undef SUBTARGET_EXTRA_SPECS
164 #define SUBTARGET_EXTRA_SPECS \
165 { "link_arch32", LINK_ARCH32_SPEC }, \
166 { "link_arch64", LINK_ARCH64_SPEC }, \
167 { "link_arch_default", LINK_ARCH_DEFAULT_SPEC }, \
168 { "link_arch", LINK_ARCH_SPEC },
170 #define LINK_ARCH32_SPEC "-m elf32_sparc -Y P,/usr/lib %{shared:-shared} \
174 %{rdynamic:-export-dynamic} \
175 %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \
176 %{static:-static}}} \
179 #define LINK_ARCH64_SPEC "-m elf64_sparc -Y P,/usr/lib64 %{shared:-shared} \
183 %{rdynamic:-export-dynamic} \
184 %{!dynamic-linker:-dynamic-linker /lib64/ld-linux.so.2}} \
185 %{static:-static}}} \
188 #define LINK_ARCH_SPEC "\
189 %{m32:%(link_arch32)} \
190 %{m64:%(link_arch64)} \
191 %{!m32:%{!m64:%(link_arch_default)}} \
194 #define LINK_ARCH_DEFAULT_SPEC \
195 (DEFAULT_ARCH32_P ? LINK_ARCH32_SPEC : LINK_ARCH64_SPEC)
200 %{mlittle-endian:-EL} \
201 %{!mno-relax:%{!r:-relax}} \
207 %{sun4:} %{target:} \
208 %{mcypress:-mcpu=cypress} \
209 %{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \
210 %{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \
211 %{m32:%{m64:%emay not use both -m32 and -m64}} \
212 %{m64:-mptr64 -mstack-bias -mlong-double-128 \
213 %{!mcpu*:%{!mcypress:%{!msparclite:%{!mf930:%{!mf934:%{!mv8:%{!msupersparc:-mcpu=ultrasparc}}}}}}} \
214 %{!mno-vis:%{!mcpu=v9:-mvis}}} \
218 %{sun4:} %{target:} \
219 %{mcypress:-mcpu=cypress} \
220 %{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \
221 %{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \
222 %{m32:%{m64:%emay not use both -m32 and -m64}} \
223 %{m32:-mptr32 -mno-stack-bias %{!mlong-double-128:-mlong-double-64} \
224 %{!mcpu*:%{!mcypress:%{!msparclite:%{!mf930:%{!mf934:%{!mv8:%{!msupersparc:-mcpu=cypress}}}}}}}} \
225 %{!m32:%{!mcpu*:-mcpu=ultrasparc}} \
226 %{!mno-vis:%{!m32:%{!mcpu=v9:-mvis}}} \
230 /* Support for a compile-time default CPU, et cetera. The rules are:
231 --with-cpu is ignored if -mcpu is specified.
232 --with-tune is ignored if -mtune is specified.
233 --with-float is ignored if -mhard-float, -msoft-float, -mfpu, or -mno-fpu
235 In the SPARC_BI_ARCH compiler we cannot pass %{!mcpu=*:-mcpu=%(VALUE)}
236 here, otherwise say -mcpu=v7 would be passed even when -m64.
237 CC1_SPEC above takes care of this instead. */
238 #undef OPTION_DEFAULT_SPECS
240 #define OPTION_DEFAULT_SPECS \
241 {"cpu", "%{!m64:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
242 {"tune", "%{!mtune=*:-mtune=%(VALUE)}" }, \
243 {"float", "%{!msoft-float:%{!mhard-float:%{!fpu:%{!no-fpu:-m%(VALUE)-float}}}}" }
245 #define OPTION_DEFAULT_SPECS \
246 {"cpu", "%{!m32:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
247 {"tune", "%{!mtune=*:-mtune=%(VALUE)}" }, \
248 {"float", "%{!msoft-float:%{!mhard-float:%{!fpu:%{!no-fpu:-m%(VALUE)-float}}}}" }
252 #define MULTILIB_DEFAULTS { "m32" }
254 #define MULTILIB_DEFAULTS { "m64" }
257 #else /* !SPARC_BI_ARCH */
260 #define LINK_SPEC "-m elf64_sparc -Y P,/usr/lib64 %{shared:-shared} \
264 %{rdynamic:-export-dynamic} \
265 %{!dynamic-linker:-dynamic-linker /lib64/ld-linux.so.2}} \
266 %{static:-static}}} \
267 %{mlittle-endian:-EL} \
268 %{!mno-relax:%{!r:-relax}} \
271 #endif /* !SPARC_BI_ARCH */
273 /* The sun bundled assembler doesn't accept -Yd, (and neither does gas).
274 It's safe to pass -s always, even if -g is not used. */
284 -s %{fpic|fPIC|fpie|fPIE:-K PIC} \
285 %{mlittle-endian:-EL} \
286 %(asm_cpu) %(asm_arch) %(asm_relax)"
288 /* Same as sparc.h */
289 #undef DBX_REGISTER_NUMBER
290 #define DBX_REGISTER_NUMBER(REGNO) (REGNO)
292 #define DWARF2_DEBUGGING_INFO 1
293 #define DBX_DEBUGGING_INFO 1
295 #undef ASM_OUTPUT_ALIGNED_LOCAL
296 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
298 fputs ("\t.local\t", (FILE)); \
299 assemble_name ((FILE), (NAME)); \
300 putc ('\n', (FILE)); \
301 ASM_OUTPUT_ALIGNED_COMMON (FILE, NAME, SIZE, ALIGN); \
305 #define COMMON_ASM_OP "\t.common\t"
307 #undef LOCAL_LABEL_PREFIX
308 #define LOCAL_LABEL_PREFIX "."
310 /* This is how to output a reference to an internal numbered label where
311 PREFIX is the class of label and NUM is the number within the class. */
313 #undef ASM_OUTPUT_INTERNAL_LABELREF
314 #define ASM_OUTPUT_INTERNAL_LABELREF(FILE,PREFIX,NUM) \
315 fprintf (FILE, ".L%s%d", PREFIX, NUM)
317 /* This is how to store into the string LABEL
318 the symbol_ref name of an internal numbered label where
319 PREFIX is the class of label and NUM is the number within the class.
320 This is suitable for output with `assemble_name'. */
322 #undef ASM_GENERATE_INTERNAL_LABEL
323 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \
324 sprintf (LABEL, "*.L%s%ld", PREFIX, (long)(NUM))
328 /* Follow Irix 6 and not the Dwarf2 draft in using 64-bit offsets.
329 Obviously the Dwarf2 folks haven't tried to actually build systems
330 with their spec. On a 64-bit system, only 64-bit relocs become
331 RELATIVE relocations. */
333 /* #define DWARF_OFFSET_SIZE PTR_SIZE */
335 #undef DITF_CONVERSION_LIBFUNCS
336 #define DITF_CONVERSION_LIBFUNCS 1
338 #if defined(HAVE_LD_EH_FRAME_HDR)
339 #define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
343 #undef TARGET_SUN_TLS
344 #undef TARGET_GNU_TLS
345 #define TARGET_SUN_TLS 0
346 #define TARGET_GNU_TLS 1
349 /* Don't be different from other Linux platforms in this regard. */
350 #define HANDLE_PRAGMA_PACK_PUSH_POP
352 /* We use GNU ld so undefine this so that attribute((init_priority)) works. */
353 #undef CTORS_SECTION_ASM_OP
354 #undef DTORS_SECTION_ASM_OP
356 #define TARGET_ASM_FILE_END file_end_indicate_exec_stack
358 /* Determine whether the the entire c99 runtime is present in the
360 #define TARGET_C99_FUNCTIONS 1
362 #define TARGET_HAS_F_SETLKW
364 #undef LINK_GCC_C_SEQUENCE_SPEC
365 #define LINK_GCC_C_SEQUENCE_SPEC \
366 "%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}"
368 /* Do code reading to identify a signal frame, and set the frame
369 state data appropriately. See unwind-dw2.c for the structs. */
371 /* Handle multilib correctly. */
372 #if defined(__arch64__)
373 /* 64-bit SPARC version */
374 #define MD_FALLBACK_FRAME_STATE_FOR(CONTEXT, FS, SUCCESS) \
376 unsigned int *pc_ = (CONTEXT)->ra; \
378 long regs_off_, fpu_save_off_; \
379 long this_cfa_, fpu_save_; \
381 if (pc_[0] != 0x82102065 /* mov NR_rt_sigreturn, %g1 */ \
382 || pc_[1] != 0x91d0206d) /* ta 0x6d */ \
384 regs_off_ = 192 + 128; \
385 fpu_save_off_ = regs_off_ + (16 * 8) + (3 * 8) + (2 * 4); \
386 this_cfa_ = (long) (CONTEXT)->cfa; \
387 new_cfa_ = *(long *)(((CONTEXT)->cfa) + (regs_off_ + (14 * 8))); \
388 new_cfa_ += 2047; /* Stack bias */ \
389 fpu_save_ = *(long *)((this_cfa_) + (fpu_save_off_)); \
390 (FS)->cfa_how = CFA_REG_OFFSET; \
391 (FS)->cfa_reg = 14; \
392 (FS)->cfa_offset = new_cfa_ - (long) (CONTEXT)->cfa; \
393 for (i_ = 1; i_ < 16; ++i_) \
395 (FS)->regs.reg[i_].how = REG_SAVED_OFFSET; \
396 (FS)->regs.reg[i_].loc.offset = \
397 this_cfa_ + (regs_off_ + (i_ * 8)) - new_cfa_; \
399 for (i_ = 0; i_ < 16; ++i_) \
401 (FS)->regs.reg[i_ + 16].how = REG_SAVED_OFFSET; \
402 (FS)->regs.reg[i_ + 16].loc.offset = \
403 this_cfa_ + (i_ * 8) - new_cfa_; \
407 for (i_ = 0; i_ < 64; ++i_) \
409 if (i_ > 32 && (i_ & 0x1)) \
411 (FS)->regs.reg[i_ + 32].how = REG_SAVED_OFFSET; \
412 (FS)->regs.reg[i_ + 32].loc.offset = \
413 (fpu_save_ + (i_ * 4)) - new_cfa_; \
416 /* Stick return address into %g0, same trick Alpha uses. */ \
417 (FS)->regs.reg[0].how = REG_SAVED_OFFSET; \
418 (FS)->regs.reg[0].loc.offset = \
419 this_cfa_ + (regs_off_ + (16 * 8) + 8) - new_cfa_; \
420 (FS)->retaddr_column = 0; \
424 /* 32-bit SPARC version */
425 #define MD_FALLBACK_FRAME_STATE_FOR(CONTEXT, FS, SUCCESS) \
427 unsigned int *pc_ = (CONTEXT)->ra; \
428 int new_cfa_, i_, oldstyle_; \
429 int regs_off_, fpu_save_off_; \
430 int fpu_save_, this_cfa_; \
432 if (pc_[1] != 0x91d02010) /* ta 0x10 */ \
434 if (pc_[0] == 0x821020d8) /* mov NR_sigreturn, %g1 */ \
436 else if (pc_[0] == 0x82102065) /* mov NR_rt_sigreturn, %g1 */ \
443 fpu_save_off_ = regs_off_ + (4 * 4) + (16 * 4); \
447 regs_off_ = 96 + 128; \
448 fpu_save_off_ = regs_off_ + (4 * 4) + (16 * 4) + (2 * 4); \
450 this_cfa_ = (int) (CONTEXT)->cfa; \
451 new_cfa_ = *(int *)(((CONTEXT)->cfa) + (regs_off_+(4*4)+(14 * 4))); \
452 fpu_save_ = *(int *)((this_cfa_) + (fpu_save_off_)); \
453 (FS)->cfa_how = CFA_REG_OFFSET; \
454 (FS)->cfa_reg = 14; \
455 (FS)->cfa_offset = new_cfa_ - (int) (CONTEXT)->cfa; \
456 for (i_ = 1; i_ < 16; ++i_) \
460 (FS)->regs.reg[i_].how = REG_SAVED_OFFSET; \
461 (FS)->regs.reg[i_].loc.offset = \
462 this_cfa_ + (regs_off_+(4 * 4)+(i_ * 4)) - new_cfa_; \
464 for (i_ = 0; i_ < 16; ++i_) \
466 (FS)->regs.reg[i_ + 16].how = REG_SAVED_OFFSET; \
467 (FS)->regs.reg[i_ + 16].loc.offset = \
468 this_cfa_ + (i_ * 4) - new_cfa_; \
472 for (i_ = 0; i_ < 32; ++i_) \
474 (FS)->regs.reg[i_ + 32].how = REG_SAVED_OFFSET; \
475 (FS)->regs.reg[i_ + 32].loc.offset = \
476 (fpu_save_ + (i_ * 4)) - new_cfa_; \
479 /* Stick return address into %g0, same trick Alpha uses. */ \
480 (FS)->regs.reg[0].how = REG_SAVED_OFFSET; \
481 (FS)->regs.reg[0].loc.offset = this_cfa_+(regs_off_+4)-new_cfa_; \
482 (FS)->retaddr_column = 0; \