]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/gcc/config/sparc/linux64.h
This commit was generated by cvs2svn to compensate for changes in r163356,
[FreeBSD/FreeBSD.git] / contrib / gcc / config / sparc / linux64.h
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)
5
6 This file is part of GCC.
7
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.
12
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.
17
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.  */
22
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)
35
36 /* Don't assume anything about the header files.  */
37 #define NO_IMPLICIT_EXTERN_C
38
39 #undef MD_EXEC_PREFIX
40 #undef MD_STARTFILE_PREFIX
41
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.  */
47
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
53
54 #undef ASM_CPU_DEFAULT_SPEC
55 #define ASM_CPU_DEFAULT_SPEC "-Av9a"
56
57 #ifdef SPARC_BI_ARCH
58
59 #undef CPP_ARCH32_SPEC
60 #define CPP_ARCH32_SPEC "%{mlong-double-128:-D__LONG_DOUBLE_128__}"
61
62 #endif
63
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'.  */
68    
69 #undef  STARTFILE_SPEC
70
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
80
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'.  */
86
87 #undef  ENDFILE_SPEC
88
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}"
92
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)"
96
97 #undef TARGET_VERSION
98 #define TARGET_VERSION fprintf (stderr, " (sparc64 GNU/Linux with ELF)");
99
100 /* The default code model.  */
101 #undef SPARC_DEFAULT_CMODEL
102 #define SPARC_DEFAULT_CMODEL CM_MEDLOW
103
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") },
108
109 #undef WCHAR_TYPE
110 #define WCHAR_TYPE "int"
111
112 #undef WCHAR_TYPE_SIZE
113 #define WCHAR_TYPE_SIZE 32
114
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)
119
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
123
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
128 #else
129 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64
130 #endif
131
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} \
137 "
138
139 #undef LIB_SPEC
140 #define LIB_SPEC \
141   "%{pthread:-lpthread} \
142    %{shared:-lc} \
143    %{!shared: %{mieee-fp:-lieee} %{profile:-lc_p}%{!profile:-lc}}"
144
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.
152
153    I took out %{v:%{!V:-V}}. It is too much :-(. They can use
154    -Wl,-V.
155
156    When the -shared link option is used a final link is not being
157    done.  */
158
159 /* If ELF is the default format, we should not use /lib/elf.  */
160
161 #ifdef SPARC_BI_ARCH
162
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 },
169     
170 #define LINK_ARCH32_SPEC "-m elf32_sparc -Y P,/usr/lib %{shared:-shared} \
171   %{!shared: \
172     %{!ibcs: \
173       %{!static: \
174         %{rdynamic:-export-dynamic} \
175         %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \
176         %{static:-static}}} \
177 "
178
179 #define LINK_ARCH64_SPEC "-m elf64_sparc -Y P,/usr/lib64 %{shared:-shared} \
180   %{!shared: \
181     %{!ibcs: \
182       %{!static: \
183         %{rdynamic:-export-dynamic} \
184         %{!dynamic-linker:-dynamic-linker /lib64/ld-linux.so.2}} \
185         %{static:-static}}} \
186 "
187
188 #define LINK_ARCH_SPEC "\
189 %{m32:%(link_arch32)} \
190 %{m64:%(link_arch64)} \
191 %{!m32:%{!m64:%(link_arch_default)}} \
192 "
193
194 #define LINK_ARCH_DEFAULT_SPEC \
195 (DEFAULT_ARCH32_P ? LINK_ARCH32_SPEC : LINK_ARCH64_SPEC)
196
197 #undef  LINK_SPEC
198 #define LINK_SPEC "\
199 %(link_arch) \
200 %{mlittle-endian:-EL} \
201 %{!mno-relax:%{!r:-relax}} \
202 "
203
204 #undef  CC1_SPEC
205 #if DEFAULT_ARCH32_P
206 #define CC1_SPEC "\
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}}} \
215 "
216 #else
217 #define CC1_SPEC "\
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}}} \
227 "
228 #endif
229
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
234      are specified.
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
239 #if DEFAULT_ARCH32_P
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}}}}" }
244 #else
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}}}}" }
249 #endif
250
251 #if DEFAULT_ARCH32_P
252 #define MULTILIB_DEFAULTS { "m32" }
253 #else
254 #define MULTILIB_DEFAULTS { "m64" }
255 #endif
256
257 #else /* !SPARC_BI_ARCH */
258
259 #undef LINK_SPEC
260 #define LINK_SPEC "-m elf64_sparc -Y P,/usr/lib64 %{shared:-shared} \
261   %{!shared: \
262     %{!ibcs: \
263       %{!static: \
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}} \
269 "
270
271 #endif /* !SPARC_BI_ARCH */
272
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.  */
275 #undef ASM_SPEC
276 #define ASM_SPEC "\
277 %{V} \
278 %{v:%{!V:-V}} \
279 %{!Qn:-Qy} \
280 %{n} \
281 %{T} \
282 %{Ym,*} \
283 %{Wa,*:%*} \
284 -s %{fpic|fPIC|fpie|fPIE:-K PIC} \
285 %{mlittle-endian:-EL} \
286 %(asm_cpu) %(asm_arch) %(asm_relax)"
287
288 /* Same as sparc.h */
289 #undef DBX_REGISTER_NUMBER
290 #define DBX_REGISTER_NUMBER(REGNO) (REGNO)
291
292 #define DWARF2_DEBUGGING_INFO 1
293 #define DBX_DEBUGGING_INFO 1
294
295 #undef ASM_OUTPUT_ALIGNED_LOCAL
296 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN)               \
297 do {                                                                    \
298   fputs ("\t.local\t", (FILE));         \
299   assemble_name ((FILE), (NAME));                                       \
300   putc ('\n', (FILE));                                                  \
301   ASM_OUTPUT_ALIGNED_COMMON (FILE, NAME, SIZE, ALIGN);                  \
302 } while (0)
303
304 #undef COMMON_ASM_OP
305 #define COMMON_ASM_OP "\t.common\t"
306
307 #undef  LOCAL_LABEL_PREFIX
308 #define LOCAL_LABEL_PREFIX  "."
309
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.  */
312
313 #undef  ASM_OUTPUT_INTERNAL_LABELREF
314 #define ASM_OUTPUT_INTERNAL_LABELREF(FILE,PREFIX,NUM)   \
315   fprintf (FILE, ".L%s%d", PREFIX, NUM)
316
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'.  */
321
322 #undef  ASM_GENERATE_INTERNAL_LABEL
323 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM)   \
324   sprintf (LABEL, "*.L%s%ld", PREFIX, (long)(NUM))
325
326 /* DWARF bits.  */
327
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.  */
332
333 /* #define DWARF_OFFSET_SIZE PTR_SIZE */
334
335 #undef DITF_CONVERSION_LIBFUNCS
336 #define DITF_CONVERSION_LIBFUNCS 1
337
338 #if defined(HAVE_LD_EH_FRAME_HDR)
339 #define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
340 #endif
341 \f
342 #ifdef HAVE_AS_TLS
343 #undef TARGET_SUN_TLS
344 #undef TARGET_GNU_TLS
345 #define TARGET_SUN_TLS 0
346 #define TARGET_GNU_TLS 1
347 #endif
348 \f
349 /* Don't be different from other Linux platforms in this regard.  */
350 #define HANDLE_PRAGMA_PACK_PUSH_POP
351
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
355
356 #define TARGET_ASM_FILE_END file_end_indicate_exec_stack
357
358 /* Determine whether the the entire c99 runtime is present in the
359    runtime library.  */
360 #define TARGET_C99_FUNCTIONS 1
361
362 #define TARGET_HAS_F_SETLKW
363
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}"
367
368 /* Do code reading to identify a signal frame, and set the frame
369    state data appropriately.  See unwind-dw2.c for the structs.  */
370
371 /* Handle multilib correctly.  */
372 #if defined(__arch64__)
373 /* 64-bit SPARC version */
374 #define MD_FALLBACK_FRAME_STATE_FOR(CONTEXT, FS, SUCCESS)               \
375   do {                                                                  \
376     unsigned int *pc_ = (CONTEXT)->ra;                                  \
377     long new_cfa_, i_;                                                  \
378     long regs_off_, fpu_save_off_;                                      \
379     long this_cfa_, fpu_save_;                                          \
380                                                                         \
381     if (pc_[0] != 0x82102065            /* mov NR_rt_sigreturn, %g1 */  \
382         || pc_[1] != 0x91d0206d)                /* ta 0x6d */           \
383       break;                                                            \
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_)                                         \
394       {                                                                 \
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_;                \
398       }                                                                 \
399     for (i_ = 0; i_ < 16; ++i_)                                         \
400       {                                                                 \
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_;                              \
404       }                                                                 \
405     if (fpu_save_)                                                      \
406       {                                                                 \
407         for (i_ = 0; i_ < 64; ++i_)                                     \
408           {                                                             \
409             if (i_ > 32 && (i_ & 0x1))                                  \
410               continue;                                                 \
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_;                        \
414           }                                                             \
415       }                                                                 \
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;                                           \
421     goto SUCCESS;                                                       \
422   } while (0)
423 #else
424 /* 32-bit SPARC version */
425 #define MD_FALLBACK_FRAME_STATE_FOR(CONTEXT, FS, SUCCESS)               \
426   do {                                                                  \
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_;                                           \
431                                                                         \
432     if (pc_[1] != 0x91d02010)           /* ta 0x10 */                   \
433       break;                                                            \
434     if (pc_[0] == 0x821020d8)           /* mov NR_sigreturn, %g1 */     \
435       oldstyle_ = 1;                                                    \
436     else if (pc_[0] == 0x82102065)      /* mov NR_rt_sigreturn, %g1 */  \
437       oldstyle_ = 0;                                                    \
438     else                                                                \
439       break;                                                            \
440     if (oldstyle_)                                                      \
441       {                                                                 \
442         regs_off_ = 96;                                                 \
443         fpu_save_off_ = regs_off_ + (4 * 4) + (16 * 4);                 \
444       }                                                                 \
445     else                                                                \
446       {                                                                 \
447         regs_off_ = 96 + 128;                                           \
448         fpu_save_off_ = regs_off_ + (4 * 4) + (16 * 4) + (2 * 4);       \
449       }                                                                 \
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_)                                         \
457       {                                                                 \
458         if (i_ == 14)                                                   \
459           continue;                                                     \
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_;         \
463       }                                                                 \
464     for (i_ = 0; i_ < 16; ++i_)                                         \
465       {                                                                 \
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_;                              \
469       }                                                                 \
470     if (fpu_save_)                                                      \
471       {                                                                 \
472         for (i_ = 0; i_ < 32; ++i_)                                     \
473           {                                                             \
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_;                        \
477           }                                                             \
478       }                                                                 \
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;                                           \
483     goto SUCCESS;                                                       \
484   } while (0)
485 #endif