OSDN Git Service

2000-06-09 Gabriel Dos Reis <gdr@codesourcery.com>
[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 Free Software Foundation, Inc.
3    Contributed by David S. Miller (davem@caip.rutgers.edu)
4
5 This file is part of GNU CC.
6
7 GNU CC 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 GNU CC 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 GNU CC; 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 SPARC_BI_ARCH
23
24 #define LINUX_DEFAULT_ELF
25
26 /* Don't assume anything about the header files. */
27 #define NO_IMPLICIT_EXTERN_C
28
29 #undef DEFAULT_VTABLE_THUNKS
30 #define DEFAULT_VTABLE_THUNKS 1
31
32 #include <sparc/sysv4.h>
33
34 #undef MD_EXEC_PREFIX
35 #undef MD_STARTFILE_PREFIX
36
37 #if TARGET_CPU_DEFAULT == TARGET_CPU_v9 || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc
38 /* A 64 bit v9 compiler with stack-bias,
39    in a Medium/Low code model environment.  */
40
41 #undef TARGET_DEFAULT
42 #define TARGET_DEFAULT \
43   (MASK_V9 + MASK_PTR64 + MASK_64BIT /* + MASK_HARD_QUAD */ \
44    + MASK_STACK_BIAS + MASK_APP_REGS + MASK_EPILOGUE + MASK_FPU + MASK_LONG_DOUBLE_128)
45 #endif
46
47 /* Output at beginning of assembler file.  */
48 /* The .file command should always begin the output.  */
49 #undef ASM_FILE_START
50 #define ASM_FILE_START(FILE)                                            \
51   do {                                                                  \
52         output_file_directive (FILE, main_input_filename);              \
53         fprintf (FILE, "\t.version\t\"01.01\"\n");                      \
54   } while (0)
55   
56 #undef ASM_CPU_DEFAULT_SPEC
57 #define ASM_CPU_DEFAULT_SPEC "-Av9a"
58
59 #ifdef SPARC_BI_ARCH
60
61 #undef CPP_ARCH32_SPEC
62 #define CPP_ARCH32_SPEC "%{mlong-double-128:-D__LONG_DOUBLE_128__} \
63 -D__SIZE_TYPE__=unsigned\\ int -D__PTRDIFF_TYPE__=int \
64 -D__GCC_NEW_VARARGS__ -Acpu(sparc) -Amachine(sparc)"
65
66 #endif
67
68 /* Provide a STARTFILE_SPEC appropriate for GNU/Linux.  Here we add
69    the GNU/Linux magical crtbegin.o file (see crtstuff.c) which
70    provides part of the support for getting C++ file-scope static
71    object constructed before entering `main'. */
72    
73 #undef  STARTFILE_SPEC
74
75 #define STARTFILE_SPEC32 \
76   "%{!shared: \
77      %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}}\
78    crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
79
80 #define STARTFILE_SPEC64 \
81   "%{!shared: \
82      %{pg:/usr/lib64/gcrt1.o%s} %{!pg:%{p:/usr/lib64/gcrt1.o%s} %{!p:/usr/lib64/crt1.o%s}}}\
83    /usr/lib64/crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
84    
85 #ifdef SPARC_BI_ARCH
86
87 #if DEFAULT_ARCH32_P
88 #define STARTFILE_SPEC "\
89 %{m32:" STARTFILE_SPEC32 "} \
90 %{m64:" STARTFILE_SPEC64 "} \
91 %{!m32:%{!m64:" STARTFILE_SPEC32 "}}"
92 #else
93 #define STARTFILE_SPEC "\
94 %{m32:" STARTFILE_SPEC32 "} \
95 %{m64:" STARTFILE_SPEC64 "} \
96 %{!m32:%{!m64:" STARTFILE_SPEC64 "}}"
97 #endif
98
99 #else
100
101 #define STARTFILE_SPEC STARTFILE_SPEC64
102
103 #endif
104
105 /* Provide a ENDFILE_SPEC appropriate for GNU/Linux.  Here we tack on
106    the GNU/Linux magical crtend.o file (see crtstuff.c) which
107    provides part of the support for getting C++ file-scope static
108    object constructed before entering `main', followed by a normal
109    GNU/Linux "finalizer" file, `crtn.o'.  */
110
111 #undef  ENDFILE_SPEC
112
113 #define ENDFILE_SPEC32 \
114   "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s"
115
116 #define ENDFILE_SPEC64 \
117   "%{!shared:crtend.o%s} %{shared:crtendS.o%s} /usr/lib64/crtn.o%s"
118   
119 #ifdef SPARC_BI_ARCH
120
121 #if DEFAULT_ARCH32_P
122 #define ENDFILE_SPEC "\
123 %{m32:" ENDFILE_SPEC32 "} \
124 %{m64:" ENDFILE_SPEC64 "} \
125 %{!m32:%{!m64:" ENDFILE_SPEC32 "}}"
126 #else
127 #define ENDFILE_SPEC "\
128 %{m32:" ENDFILE_SPEC32 "} \
129 %{m64:" ENDFILE_SPEC64 "} \
130 %{!m32:%{!m64:" ENDFILE_SPEC64 "}}"
131 #endif
132
133 #else
134
135 #define ENDFILE_SPEC ENDFILE_SPEC64
136
137 #endif
138
139 #undef TARGET_VERSION
140 #define TARGET_VERSION fprintf (stderr, " (sparc64 GNU/Linux with ELF)");
141
142 /* The default code model.  */
143 #undef SPARC_DEFAULT_CMODEL
144 #define SPARC_DEFAULT_CMODEL CM_MEDLOW
145
146 #undef SUBTARGET_SWITCHES
147 #define SUBTARGET_SWITCHES \
148 {"long-double-64", -MASK_LONG_DOUBLE_128, "Use 64 bit long doubles" }, \
149 {"long-double-128", MASK_LONG_DOUBLE_128, "Use 128 bit long doubles" },
150
151 #undef WCHAR_TYPE
152 #define WCHAR_TYPE "int"
153
154 #undef WCHAR_TYPE_SIZE
155 #define WCHAR_TYPE_SIZE 32
156
157 #undef MAX_WCHAR_TYPE_SIZE
158
159 /* Define for support of TFmode long double and REAL_ARITHMETIC.
160    Sparc ABI says that long double is 4 words.  */
161 #undef LONG_DOUBLE_TYPE_SIZE
162 #define LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64)
163
164 /* Constant which presents upper bound of the above value.  */
165 #undef MAX_LONG_DOUBLE_TYPE_SIZE
166 #define MAX_LONG_DOUBLE_TYPE_SIZE 128
167
168 /* Define this to set long double type size to use in libgcc2.c, which can
169    not depend on target_flags.  */
170 #if defined(__arch64__) || defined(__LONG_DOUBLE_128__)
171 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 128
172 #else
173 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64
174 #endif
175
176 #undef CPP_PREDEFINES
177 #define CPP_PREDEFINES "-D__ELF__ -Dunix -D_LONGLONG -D__sparc__ -Dlinux -Asystem(unix) -Asystem(posix)"
178
179 #undef CPP_SUBTARGET_SPEC
180 #define CPP_SUBTARGET_SPEC "\
181 %{fPIC:-D__PIC__ -D__pic__} \
182 %{fpic:-D__PIC__ -D__pic__} \
183 %{posix:-D_POSIX_SOURCE} \
184 %{pthread:-D_REENTRANT} \
185 "
186
187 #undef LIB_SPEC
188 #define LIB_SPEC \
189   "%{shared: -lc} \
190    %{!shared: %{mieee-fp:-lieee} %{pthread:-lpthread} \
191      %{profile:-lc_p} %{!profile: -lc}}"
192
193 /* Provide a LINK_SPEC appropriate for GNU/Linux.  Here we provide support
194    for the special GCC options -static and -shared, which allow us to
195    link things in one of these three modes by applying the appropriate
196    combinations of options at link-time. We like to support here for
197    as many of the other GNU linker options as possible. But I don't
198    have the time to search for those flags. I am sure how to add
199    support for -soname shared_object_name. H.J.
200
201    I took out %{v:%{!V:-V}}. It is too much :-(. They can use
202    -Wl,-V.
203
204    When the -shared link option is used a final link is not being
205    done.  */
206
207 /* If ELF is the default format, we should not use /lib/elf. */
208
209 #ifdef SPARC_BI_ARCH
210
211 #undef SUBTARGET_EXTRA_SPECS
212 #define SUBTARGET_EXTRA_SPECS \
213   { "link_arch32",       LINK_ARCH32_SPEC },              \
214   { "link_arch64",       LINK_ARCH64_SPEC },              \
215   { "link_arch_default", LINK_ARCH_DEFAULT_SPEC },        \
216   { "link_arch",         LINK_ARCH_SPEC },
217     
218 #define LINK_ARCH32_SPEC "-m elf32_sparc -Y P,/usr/lib %{shared:-shared} \
219   %{!shared: \
220     %{!ibcs: \
221       %{!static: \
222         %{rdynamic:-export-dynamic} \
223         %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \
224         %{static:-static}}} \
225 "
226
227 #define LINK_ARCH64_SPEC "-m elf64_sparc -Y P,/usr/lib64 %{shared:-shared} \
228   %{!shared: \
229     %{!ibcs: \
230       %{!static: \
231         %{rdynamic:-export-dynamic} \
232         %{!dynamic-linker:-dynamic-linker /lib64/ld-linux.so.2}} \
233         %{static:-static}}} \
234 "
235
236 #define LINK_ARCH_SPEC "\
237 %{m32:%(link_arch32)} \
238 %{m64:%(link_arch64)} \
239 %{!m32:%{!m64:%(link_arch_default)}} \
240 "
241
242 #define LINK_ARCH_DEFAULT_SPEC \
243 (DEFAULT_ARCH32_P ? LINK_ARCH32_SPEC : LINK_ARCH64_SPEC)
244
245 #undef  LINK_SPEC
246 #define LINK_SPEC "\
247 %(link_arch) \
248 %{mlittle-endian:-EL} \
249 "
250
251 #undef  CC1_SPEC
252 #if DEFAULT_ARCH32_P
253 #define CC1_SPEC "\
254 %{sun4:} %{target:} \
255 %{mcypress:-mcpu=cypress} \
256 %{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \
257 %{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \
258 %{m64:-mptr64 -mstack-bias -mlong-double-128 \
259   %{!mcpu*:%{!mcypress:%{!msparclite:%{!mf930:%{!mf934:%{!mv8:%{!msupersparc:-mcpu=ultrasparc}}}}}}} \
260   %{!mno-vis:%{!mcpu=v9:-mvis}}} \
261 %{!m64:%{g*:%{!gs*:%{!gd*:%{!gx*:%{!gc*:-gstabs+}}}}}} \
262 "
263 #else
264 #define CC1_SPEC "\
265 %{sun4:} %{target:} \
266 %{mcypress:-mcpu=cypress} \
267 %{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \
268 %{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \
269 %{m32:-mptr32 -mno-stack-bias %{!mlong-double-128:-mlong-double-64} \
270   %{!mcpu*:%{!mcypress:%{!msparclite:%{!mf930:%{!mf934:%{!mv8:%{!msupersparc:-mcpu=cypress}}}}}}} \
271   %{g*:%{!gs*:%{!gd*:%{!gx*:%{!gc*:-gstabs+}}}}}} \
272 %{!m32:%{!mcpu*:-mcpu=ultrasparc}} \
273 %{!mno-vis:%{!m32:%{!mcpu=v9:-mvis}}} \
274 "
275 #endif
276
277 #if DEFAULT_ARCH32_P
278 #define MULTILIB_DEFAULTS { "m32" }
279 #else
280 #define MULTILIB_DEFAULTS { "m64" }
281 #endif
282
283 #else /* !SPARC_BI_ARCH */
284
285 #undef LINK_SPEC
286 #define LINK_ARCH_SPEC "-m elf64_sparc -Y P,/usr/lib64 %{shared:-shared} \
287   %{!shared: \
288     %{!ibcs: \
289       %{!static: \
290         %{rdynamic:-export-dynamic} \
291         %{!dynamic-linker:-dynamic-linker /lib64/ld-linux.so.2}} \
292         %{static:-static}}} \
293 %{mlittle-endian:-EL} \
294 "
295
296 #endif /* !SPARC_BI_ARCH */
297
298 /* The sun bundled assembler doesn't accept -Yd, (and neither does gas).
299    It's safe to pass -s always, even if -g is not used. */
300 #undef ASM_SPEC
301 #define ASM_SPEC "\
302 %{V} \
303 %{v:%{!V:-V}} \
304 %{!Qn:-Qy} \
305 %{n} \
306 %{T} \
307 %{Ym,*} \
308 %{Wa,*:%*} \
309 -s %{fpic:-K PIC} %{fPIC:-K PIC} \
310 %{mlittle-endian:-EL} \
311 %(asm_cpu) %(asm_arch) \
312 "
313
314 /* Same as sparc.h */
315 #undef DBX_REGISTER_NUMBER
316 #define DBX_REGISTER_NUMBER(REGNO) (REGNO)
317
318 /* System V Release 4 uses DWARF debugging info.  Buf DWARF1 doesn't do
319    64-bit anything, so we use DWARF2.  */
320
321 #undef DWARF2_DEBUGGING_INFO
322 #undef DWARF_DEBUGGING_INFO
323 #undef DBX_DEBUGGING_INFO
324 #define DWARF2_DEBUGGING_INFO
325 #define DBX_DEBUGGING_INFO
326
327 #undef PREFERRED_DEBUGGING_TYPE
328 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
329
330 #undef ASM_OUTPUT_ALIGNED_LOCAL
331 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN)               \
332 do {                                                                    \
333   fputs ("\t.local\t", (FILE));         \
334   assemble_name ((FILE), (NAME));                                       \
335   putc ('\n', (FILE));                                                  \
336   ASM_OUTPUT_ALIGNED_COMMON (FILE, NAME, SIZE, ALIGN);                  \
337 } while (0)
338
339 #undef COMMON_ASM_OP
340 #define COMMON_ASM_OP "\t.common"
341
342 /* This is how to output a definition of an internal numbered label where
343    PREFIX is the class of label and NUM is the number within the class.  */
344
345 #undef  ASM_OUTPUT_INTERNAL_LABEL
346 #define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM)      \
347   fprintf (FILE, ".L%s%d:\n", PREFIX, NUM)
348
349 /* This is how to output a reference to an internal numbered label where
350    PREFIX is the class of label and NUM is the number within the class.  */
351
352 #undef  ASM_OUTPUT_INTERNAL_LABELREF
353 #define ASM_OUTPUT_INTERNAL_LABELREF(FILE,PREFIX,NUM)   \
354   fprintf (FILE, ".L%s%d", PREFIX, NUM)
355
356 /* This is how to store into the string LABEL
357    the symbol_ref name of an internal numbered label where
358    PREFIX is the class of label and NUM is the number within the class.
359    This is suitable for output with `assemble_name'.  */
360
361 #undef  ASM_GENERATE_INTERNAL_LABEL
362 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM)   \
363   sprintf (LABEL, "*.L%s%d", PREFIX, NUM)
364
365 /* Define the names of various pseudo-ops used by the Sparc/svr4 assembler.
366    ??? If ints are 64 bits then UNALIGNED_INT_ASM_OP (defined elsewhere) is
367    misnamed.  These should all refer to explicit sizes (half/word/xword?),
368    anything other than short/int/long/etc.  */
369
370 #define UNALIGNED_DOUBLE_INT_ASM_OP     ".uaxword"
371
372 /* DWARF bits.  */
373
374 /* Follow Irix 6 and not the Dwarf2 draft in using 64-bit offsets. 
375    Obviously the Dwarf2 folks havn't tried to actually build systems
376    with their spec.  On a 64-bit system, only 64-bit relocs become
377    RELATIVE relocations.  */
378
379 /* #define DWARF_OFFSET_SIZE PTR_SIZE */
380 \f
381 #if TARGET_ARCH32
382 /* Override MACHINE_STATE_{SAVE,RESTORE} because we have special
383    traps available which can get and set the condition codes
384    reliably.  */
385 #undef MACHINE_STATE_SAVE
386 #define MACHINE_STATE_SAVE(ID)                          \
387   unsigned long int ms_flags, ms_saveret;               \
388   asm volatile("ta      0x20\n\t"                       \
389                "mov     %%g1, %0\n\t"                   \
390                "mov     %%g2, %1\n\t"                   \
391                : "=r" (ms_flags), "=r" (ms_saveret));
392
393 #undef MACHINE_STATE_RESTORE
394 #define MACHINE_STATE_RESTORE(ID)                       \
395   asm volatile("mov     %0, %%g1\n\t"                   \
396                "mov     %1, %%g2\n\t"                   \
397                "ta      0x21\n\t"                       \
398                : /* no outputs */                       \
399                : "r" (ms_flags), "r" (ms_saveret));
400 #endif /* sparc32 */
401
402 /* A C statement (sans semicolon) to output an element in the table of
403    global constructors.  */
404 #undef ASM_OUTPUT_CONSTRUCTOR
405 #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME)                               \
406   do {                                                                  \
407     ctors_section ();                                                   \
408     fprintf (FILE, "\t%s\t ", TARGET_ARCH64 ? ASM_LONGLONG : INT_ASM_OP); \
409     assemble_name (FILE, NAME);                                         \
410     fprintf (FILE, "\n");                                               \
411   } while (0)
412
413 /* A C statement (sans semicolon) to output an element in the table of
414    global destructors.  */
415 #undef ASM_OUTPUT_DESTRUCTOR
416 #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME)                                \
417   do {                                                                  \
418     dtors_section ();                                                   \
419     fprintf (FILE, "\t%s\t ", TARGET_ARCH64 ? ASM_LONGLONG : INT_ASM_OP); \
420     assemble_name (FILE, NAME);                                         \
421     fprintf (FILE, "\n");                                               \
422   } while (0)