OSDN Git Service

* config.gcc: Don't mention MAX_LONG_TYPE_SIZE.
[pf3gnuchains/gcc-fork.git] / 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 Free Software Foundation, Inc.
3    Contributed by David S. Miller (davem@caip.rutgers.edu)
4
5 This file is part of GCC.
6
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.
11
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.
16
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.  */
21
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)
34
35 /* Don't assume anything about the header files.  */
36 #define NO_IMPLICIT_EXTERN_C
37
38 #undef MD_EXEC_PREFIX
39 #undef MD_STARTFILE_PREFIX
40
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.  */
44
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
50
51 #undef ASM_CPU_DEFAULT_SPEC
52 #define ASM_CPU_DEFAULT_SPEC "-Av9a"
53
54 #ifdef SPARC_BI_ARCH
55
56 #undef CPP_ARCH32_SPEC
57 #define CPP_ARCH32_SPEC "%{mlong-double-128:-D__LONG_DOUBLE_128__}"
58
59 #endif
60
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'.  */
65    
66 #undef  STARTFILE_SPEC
67
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
77
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'.  */
83
84 #undef  ENDFILE_SPEC
85
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}"
89
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)"
93
94 #undef TARGET_VERSION
95 #define TARGET_VERSION fprintf (stderr, " (sparc64 GNU/Linux with ELF)");
96
97 /* The default code model.  */
98 #undef SPARC_DEFAULT_CMODEL
99 #define SPARC_DEFAULT_CMODEL CM_MEDLOW
100
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") },
105
106 #undef WCHAR_TYPE
107 #define WCHAR_TYPE "int"
108
109 #undef WCHAR_TYPE_SIZE
110 #define WCHAR_TYPE_SIZE 32
111
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)
116
117 /* Define this to set long double type size to use in libgcc2.c, which can
118    not depend on target_flags.  */
119 #if defined(__arch64__) || defined(__LONG_DOUBLE_128__)
120 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 128
121 #else
122 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64
123 #endif
124
125 #undef CPP_SUBTARGET_SPEC
126 #define CPP_SUBTARGET_SPEC "\
127 %{fPIC|fpic|fPIE|fpie:-D__PIC__ -D__pic__} \
128 %{posix:-D_POSIX_SOURCE} \
129 %{pthread:-D_REENTRANT} \
130 "
131
132 #undef LIB_SPEC
133 #define LIB_SPEC \
134   "%{pthread:-lpthread} \
135    %{shared:-lc} \
136    %{!shared: %{mieee-fp:-lieee} %{profile:-lc_p}%{!profile:-lc}}"
137
138 /* Provide a LINK_SPEC appropriate for GNU/Linux.  Here we provide support
139    for the special GCC options -static and -shared, which allow us to
140    link things in one of these three modes by applying the appropriate
141    combinations of options at link-time. We like to support here for
142    as many of the other GNU linker options as possible. But I don't
143    have the time to search for those flags. I am sure how to add
144    support for -soname shared_object_name. H.J.
145
146    I took out %{v:%{!V:-V}}. It is too much :-(. They can use
147    -Wl,-V.
148
149    When the -shared link option is used a final link is not being
150    done.  */
151
152 /* If ELF is the default format, we should not use /lib/elf.  */
153
154 #ifdef SPARC_BI_ARCH
155
156 #undef SUBTARGET_EXTRA_SPECS
157 #define SUBTARGET_EXTRA_SPECS \
158   { "link_arch32",       LINK_ARCH32_SPEC },              \
159   { "link_arch64",       LINK_ARCH64_SPEC },              \
160   { "link_arch_default", LINK_ARCH_DEFAULT_SPEC },        \
161   { "link_arch",         LINK_ARCH_SPEC },
162     
163 #define LINK_ARCH32_SPEC "-m elf32_sparc -Y P,/usr/lib %{shared:-shared} \
164   %{!shared: \
165     %{!ibcs: \
166       %{!static: \
167         %{rdynamic:-export-dynamic} \
168         %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \
169         %{static:-static}}} \
170 "
171
172 #define LINK_ARCH64_SPEC "-m elf64_sparc -Y P,/usr/lib64 %{shared:-shared} \
173   %{!shared: \
174     %{!ibcs: \
175       %{!static: \
176         %{rdynamic:-export-dynamic} \
177         %{!dynamic-linker:-dynamic-linker /lib64/ld-linux.so.2}} \
178         %{static:-static}}} \
179 "
180
181 #define LINK_ARCH_SPEC "\
182 %{m32:%(link_arch32)} \
183 %{m64:%(link_arch64)} \
184 %{!m32:%{!m64:%(link_arch_default)}} \
185 "
186
187 #define LINK_ARCH_DEFAULT_SPEC \
188 (DEFAULT_ARCH32_P ? LINK_ARCH32_SPEC : LINK_ARCH64_SPEC)
189
190 #undef  LINK_SPEC
191 #define LINK_SPEC "\
192 %(link_arch) \
193 %{mlittle-endian:-EL} \
194 %{!mno-relax:%{!r:-relax}} \
195 "
196
197 #undef  CC1_SPEC
198 #if DEFAULT_ARCH32_P
199 #define CC1_SPEC "\
200 %{sun4:} %{target:} \
201 %{mcypress:-mcpu=cypress} \
202 %{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \
203 %{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \
204 %{m32:%{m64:%emay not use both -m32 and -m64}} \
205 %{m64:-mptr64 -mstack-bias -mlong-double-128 \
206   %{!mcpu*:%{!mcypress:%{!msparclite:%{!mf930:%{!mf934:%{!mv8:%{!msupersparc:-mcpu=ultrasparc}}}}}}} \
207   %{!mno-vis:%{!mcpu=v9:-mvis}}} \
208 "
209 #else
210 #define CC1_SPEC "\
211 %{sun4:} %{target:} \
212 %{mcypress:-mcpu=cypress} \
213 %{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \
214 %{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \
215 %{m32:%{m64:%emay not use both -m32 and -m64}} \
216 %{m32:-mptr32 -mno-stack-bias %{!mlong-double-128:-mlong-double-64} \
217   %{!mcpu*:%{!mcypress:%{!msparclite:%{!mf930:%{!mf934:%{!mv8:%{!msupersparc:-mcpu=cypress}}}}}}}} \
218 %{!m32:%{!mcpu*:-mcpu=ultrasparc}} \
219 %{!mno-vis:%{!m32:%{!mcpu=v9:-mvis}}} \
220 "
221 #endif
222
223 #if DEFAULT_ARCH32_P
224 #define MULTILIB_DEFAULTS { "m32" }
225 #else
226 #define MULTILIB_DEFAULTS { "m64" }
227 #endif
228
229 #else /* !SPARC_BI_ARCH */
230
231 #undef LINK_SPEC
232 #define LINK_SPEC "-m elf64_sparc -Y P,/usr/lib64 %{shared:-shared} \
233   %{!shared: \
234     %{!ibcs: \
235       %{!static: \
236         %{rdynamic:-export-dynamic} \
237         %{!dynamic-linker:-dynamic-linker /lib64/ld-linux.so.2}} \
238         %{static:-static}}} \
239 %{mlittle-endian:-EL} \
240 %{!mno-relax:%{!r:-relax}} \
241 "
242
243 #endif /* !SPARC_BI_ARCH */
244
245 /* The sun bundled assembler doesn't accept -Yd, (and neither does gas).
246    It's safe to pass -s always, even if -g is not used.  */
247 #undef ASM_SPEC
248 #define ASM_SPEC "\
249 %{V} \
250 %{v:%{!V:-V}} \
251 %{!Qn:-Qy} \
252 %{n} \
253 %{T} \
254 %{Ym,*} \
255 %{Wa,*:%*} \
256 -s %{fpic|fPIC|fpie|fPIE:-K PIC} \
257 %{mlittle-endian:-EL} \
258 %(asm_cpu) %(asm_arch) %(asm_relax)"
259
260 /* Same as sparc.h */
261 #undef DBX_REGISTER_NUMBER
262 #define DBX_REGISTER_NUMBER(REGNO) (REGNO)
263
264 #define DWARF2_DEBUGGING_INFO 1
265 #define DBX_DEBUGGING_INFO 1
266
267 #undef ASM_OUTPUT_ALIGNED_LOCAL
268 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN)               \
269 do {                                                                    \
270   fputs ("\t.local\t", (FILE));         \
271   assemble_name ((FILE), (NAME));                                       \
272   putc ('\n', (FILE));                                                  \
273   ASM_OUTPUT_ALIGNED_COMMON (FILE, NAME, SIZE, ALIGN);                  \
274 } while (0)
275
276 #undef COMMON_ASM_OP
277 #define COMMON_ASM_OP "\t.common\t"
278
279 #undef  LOCAL_LABEL_PREFIX
280 #define LOCAL_LABEL_PREFIX  "."
281
282 /* This is how to output a reference to an internal numbered label where
283    PREFIX is the class of label and NUM is the number within the class.  */
284
285 #undef  ASM_OUTPUT_INTERNAL_LABELREF
286 #define ASM_OUTPUT_INTERNAL_LABELREF(FILE,PREFIX,NUM)   \
287   fprintf (FILE, ".L%s%d", PREFIX, NUM)
288
289 /* This is how to store into the string LABEL
290    the symbol_ref name of an internal numbered label where
291    PREFIX is the class of label and NUM is the number within the class.
292    This is suitable for output with `assemble_name'.  */
293
294 #undef  ASM_GENERATE_INTERNAL_LABEL
295 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM)   \
296   sprintf (LABEL, "*.L%s%ld", PREFIX, (long)(NUM))
297
298 /* DWARF bits.  */
299
300 /* Follow Irix 6 and not the Dwarf2 draft in using 64-bit offsets. 
301    Obviously the Dwarf2 folks haven't tried to actually build systems
302    with their spec.  On a 64-bit system, only 64-bit relocs become
303    RELATIVE relocations.  */
304
305 /* #define DWARF_OFFSET_SIZE PTR_SIZE */
306
307 #if defined(HAVE_LD_EH_FRAME_HDR)
308 #define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
309 #endif
310 \f
311 #ifdef HAVE_AS_TLS
312 #undef TARGET_SUN_TLS
313 #undef TARGET_GNU_TLS
314 #define TARGET_SUN_TLS 0
315 #define TARGET_GNU_TLS 1
316 #endif
317 \f
318 /* Don't be different from other Linux platforms in this regard.  */
319 #define HANDLE_PRAGMA_PACK_PUSH_POP
320
321 /* We use GNU ld so undefine this so that attribute((init_priority)) works.  */
322 #undef CTORS_SECTION_ASM_OP
323 #undef DTORS_SECTION_ASM_OP
324
325 #define TARGET_ASM_FILE_END file_end_indicate_exec_stack
326
327 #undef LINK_GCC_C_SEQUENCE_SPEC
328 #define LINK_GCC_C_SEQUENCE_SPEC \
329   "%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}"
330
331 /* Do code reading to identify a signal frame, and set the frame
332    state data appropriately.  See unwind-dw2.c for the structs.  */
333
334 /* Handle multilib correctly.  */
335 #if defined(__arch64__)
336 /* 64-bit SPARC version */
337 #define MD_FALLBACK_FRAME_STATE_FOR(CONTEXT, FS, SUCCESS)               \
338   do {                                                                  \
339     unsigned int *pc_ = (CONTEXT)->ra;                                  \
340     long new_cfa_, i_;                                                  \
341     long regs_off_, fpu_save_off_;                                      \
342     long this_cfa_, fpu_save_;                                          \
343                                                                         \
344     if (pc_[0] != 0x82102065            /* mov NR_rt_sigreturn, %g1 */  \
345         || pc_[1] != 0x91d0206d)                /* ta 0x6d */           \
346       break;                                                            \
347     regs_off_ = 192 + 128;                                              \
348     fpu_save_off_ = regs_off_ + (16 * 8) + (3 * 8) + (2 * 4);           \
349     this_cfa_ = (long) (CONTEXT)->cfa;                                  \
350     new_cfa_ = *(long *)(((CONTEXT)->cfa) + (regs_off_ + (14 * 8)));    \
351     new_cfa_ += 2047; /* Stack bias */                                  \
352     fpu_save_ = *(long *)((this_cfa_) + (fpu_save_off_));               \
353     (FS)->cfa_how = CFA_REG_OFFSET;                                     \
354     (FS)->cfa_reg = 14;                                                 \
355     (FS)->cfa_offset = new_cfa_ - (long) (CONTEXT)->cfa;                \
356     for (i_ = 1; i_ < 16; ++i_)                                         \
357       {                                                                 \
358         (FS)->regs.reg[i_].how = REG_SAVED_OFFSET;                      \
359         (FS)->regs.reg[i_].loc.offset =                                 \
360           this_cfa_ + (regs_off_ + (i_ * 8)) - new_cfa_;                \
361       }                                                                 \
362     for (i_ = 0; i_ < 16; ++i_)                                         \
363       {                                                                 \
364         (FS)->regs.reg[i_ + 16].how = REG_SAVED_OFFSET;                 \
365         (FS)->regs.reg[i_ + 16].loc.offset =                            \
366           this_cfa_ + (i_ * 8) - new_cfa_;                              \
367       }                                                                 \
368     if (fpu_save_)                                                      \
369       {                                                                 \
370         for (i_ = 0; i_ < 64; ++i_)                                     \
371           {                                                             \
372             if (i_ > 32 && (i_ & 0x1))                                  \
373               continue;                                                 \
374             (FS)->regs.reg[i_ + 32].how = REG_SAVED_OFFSET;             \
375             (FS)->regs.reg[i_ + 32].loc.offset =                        \
376               (fpu_save_ + (i_ * 4)) - new_cfa_;                        \
377           }                                                             \
378       }                                                                 \
379     /* Stick return address into %g0, same trick Alpha uses.  */        \
380     (FS)->regs.reg[0].how = REG_SAVED_OFFSET;                           \
381     (FS)->regs.reg[0].loc.offset =                                      \
382       this_cfa_ + (regs_off_ + (16 * 8) + 8) - new_cfa_;                \
383     (FS)->retaddr_column = 0;                                           \
384     goto SUCCESS;                                                       \
385   } while (0)
386 #else
387 /* 32-bit SPARC version */
388 #define MD_FALLBACK_FRAME_STATE_FOR(CONTEXT, FS, SUCCESS)               \
389   do {                                                                  \
390     unsigned int *pc_ = (CONTEXT)->ra;                                  \
391     int new_cfa_, i_, oldstyle_;                                        \
392     int regs_off_, fpu_save_off_;                                       \
393     int fpu_save_, this_cfa_;                                           \
394                                                                         \
395     if (pc_[1] != 0x91d02010)           /* ta 0x10 */                   \
396       break;                                                            \
397     if (pc_[0] == 0x821020d8)           /* mov NR_sigreturn, %g1 */     \
398       oldstyle_ = 1;                                                    \
399     else if (pc_[0] == 0x82102065)      /* mov NR_rt_sigreturn, %g1 */  \
400       oldstyle_ = 0;                                                    \
401     else                                                                \
402       break;                                                            \
403     if (oldstyle_)                                                      \
404       {                                                                 \
405         regs_off_ = 96;                                                 \
406         fpu_save_off_ = regs_off_ + (4 * 4) + (16 * 4);                 \
407       }                                                                 \
408     else                                                                \
409       {                                                                 \
410         regs_off_ = 96 + 128;                                           \
411         fpu_save_off_ = regs_off_ + (4 * 4) + (16 * 4) + (2 * 4);       \
412       }                                                                 \
413     this_cfa_ = (int) (CONTEXT)->cfa;                                   \
414     new_cfa_ = *(int *)(((CONTEXT)->cfa) + (regs_off_+(4*4)+(14 * 4))); \
415     fpu_save_ = *(int *)((this_cfa_) + (fpu_save_off_));                \
416     (FS)->cfa_how = CFA_REG_OFFSET;                                     \
417     (FS)->cfa_reg = 14;                                                 \
418     (FS)->cfa_offset = new_cfa_ - (int) (CONTEXT)->cfa;                 \
419     for (i_ = 1; i_ < 16; ++i_)                                         \
420       {                                                                 \
421         if (i_ == 14)                                                   \
422           continue;                                                     \
423         (FS)->regs.reg[i_].how = REG_SAVED_OFFSET;                      \
424         (FS)->regs.reg[i_].loc.offset =                                 \
425            this_cfa_ + (regs_off_+(4 * 4)+(i_ * 4)) - new_cfa_;         \
426       }                                                                 \
427     for (i_ = 0; i_ < 16; ++i_)                                         \
428       {                                                                 \
429         (FS)->regs.reg[i_ + 16].how = REG_SAVED_OFFSET;                 \
430         (FS)->regs.reg[i_ + 16].loc.offset =                            \
431           this_cfa_ + (i_ * 4) - new_cfa_;                              \
432       }                                                                 \
433     if (fpu_save_)                                                      \
434       {                                                                 \
435         for (i_ = 0; i_ < 32; ++i_)                                     \
436           {                                                             \
437             (FS)->regs.reg[i_ + 32].how = REG_SAVED_OFFSET;             \
438             (FS)->regs.reg[i_ + 32].loc.offset =                        \
439               (fpu_save_ + (i_ * 4)) - new_cfa_;                        \
440           }                                                             \
441       }                                                                 \
442     /* Stick return address into %g0, same trick Alpha uses.  */        \
443     (FS)->regs.reg[0].how = REG_SAVED_OFFSET;                           \
444     (FS)->regs.reg[0].loc.offset = this_cfa_+(regs_off_+4)-new_cfa_;    \
445     (FS)->retaddr_column = 0;                                           \
446     goto SUCCESS;                                                       \
447   } while (0)
448 #endif