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