]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/config/sparc/linux64.h
builtins.c (expand_builtin_memcpy): Remove endp argument and endp != 0 handling.
[thirdparty/gcc.git] / gcc / config / sparc / linux64.h
CommitLineData
956d6950 1/* Definitions for 64-bit SPARC running Linux-based GNU systems with ELF.
5bbcd587 2 Copyright 1996, 1997, 1998, 2000, 2002 Free Software Foundation, Inc.
bfe87013
DE
3 Contributed by David S. Miller (davem@caip.rutgers.edu)
4
5This file is part of GNU CC.
6
7GNU CC is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2, or (at your option)
10any later version.
11
12GNU CC is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with GNU CC; see the file COPYING. If not, write to
19the Free Software Foundation, 59 Temple Place - Suite 330,
20Boston, MA 02111-1307, USA. */
21
9b8466f4
NB
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__"); \
9b8466f4
NB
29 builtin_assert ("system=unix"); \
30 builtin_assert ("system=posix"); \
31 } \
32 while (0)
33
a0a301fc 34#define LINUX_DEFAULT_ELF
bfe87013 35
80ffc95e 36/* Don't assume anything about the header files. */
bfe87013
DE
37#define NO_IMPLICIT_EXTERN_C
38
bfe87013
DE
39#undef MD_EXEC_PREFIX
40#undef MD_STARTFILE_PREFIX
41
345a6161
DM
42#if TARGET_CPU_DEFAULT == TARGET_CPU_v9 || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc
43/* A 64 bit v9 compiler with stack-bias,
44 in a Medium/Low code model environment. */
45
46#undef TARGET_DEFAULT
47#define TARGET_DEFAULT \
48 (MASK_V9 + MASK_PTR64 + MASK_64BIT /* + MASK_HARD_QUAD */ \
33074e5f 49 + MASK_STACK_BIAS + MASK_APP_REGS + MASK_FPU + MASK_LONG_DOUBLE_128)
345a6161
DM
50#endif
51
a0a301fc
DE
52#undef ASM_CPU_DEFAULT_SPEC
53#define ASM_CPU_DEFAULT_SPEC "-Av9a"
bfe87013 54
4710d3eb
JJ
55#ifdef SPARC_BI_ARCH
56
57#undef CPP_ARCH32_SPEC
9b8466f4 58#define CPP_ARCH32_SPEC "%{mlong-double-128:-D__LONG_DOUBLE_128__}"
4710d3eb
JJ
59
60#endif
61
956d6950
JL
62/* Provide a STARTFILE_SPEC appropriate for GNU/Linux. Here we add
63 the GNU/Linux magical crtbegin.o file (see crtstuff.c) which
bfe87013 64 provides part of the support for getting C++ file-scope static
80ffc95e 65 object constructed before entering `main'. */
bfe87013
DE
66
67#undef STARTFILE_SPEC
345a6161 68
5bbcd587
JJ
69#define STARTFILE_SPEC \
70 "%{!shared:%{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}}\
71 crti.o%s %{static:crtbeginT.o%s}\
275b60d6 72 %{!static:%{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}}"
bfe87013 73
956d6950
JL
74/* Provide a ENDFILE_SPEC appropriate for GNU/Linux. Here we tack on
75 the GNU/Linux magical crtend.o file (see crtstuff.c) which
bfe87013
DE
76 provides part of the support for getting C++ file-scope static
77 object constructed before entering `main', followed by a normal
956d6950 78 GNU/Linux "finalizer" file, `crtn.o'. */
bfe87013
DE
79
80#undef ENDFILE_SPEC
345a6161 81
5bbcd587
JJ
82#define ENDFILE_SPEC \
83 "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s\
84 %{ffast-math|funsafe-math-optimizations:crtfastmath.o%s}"
345a6161 85
2be1602e
DM
86/* The GNU C++ standard library requires that these macros be defined. */
87#undef CPLUSPLUS_CPP_SPEC
88#define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
89
345a6161
DM
90#undef TARGET_VERSION
91#define TARGET_VERSION fprintf (stderr, " (sparc64 GNU/Linux with ELF)");
a0a301fc
DE
92
93/* The default code model. */
94#undef SPARC_DEFAULT_CMODEL
be3f1ff5 95#define SPARC_DEFAULT_CMODEL CM_MEDLOW
bfe87013 96
4710d3eb 97#undef SUBTARGET_SWITCHES
047142d3
PT
98#define SUBTARGET_SWITCHES \
99{"long-double-64", -MASK_LONG_DOUBLE_128, N_("Use 64 bit long doubles") }, \
100{"long-double-128", MASK_LONG_DOUBLE_128, N_("Use 128 bit long doubles") },
4710d3eb 101
bfe87013 102#undef WCHAR_TYPE
247cfc5c
JJ
103#define WCHAR_TYPE "int"
104
bfe87013 105#undef WCHAR_TYPE_SIZE
247cfc5c
JJ
106#define WCHAR_TYPE_SIZE 32
107
ba31d94e 108/* Define for support of TFmode long double.
56149abc 109 SPARC ABI says that long double is 4 words. */
a0a301fc 110#undef LONG_DOUBLE_TYPE_SIZE
4710d3eb
JJ
111#define LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64)
112
113/* Constant which presents upper bound of the above value. */
114#undef MAX_LONG_DOUBLE_TYPE_SIZE
115#define MAX_LONG_DOUBLE_TYPE_SIZE 128
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
345a6161 124
a0a301fc
DE
125#undef CPP_SUBTARGET_SPEC
126#define CPP_SUBTARGET_SPEC "\
bfe87013
DE
127%{fPIC:-D__PIC__ -D__pic__} \
128%{fpic:-D__PIC__ -D__pic__} \
bfe87013 129%{posix:-D_POSIX_SOURCE} \
afc96791 130%{pthread:-D_REENTRANT} \
bfe87013 131"
afc96791 132
bfe87013
DE
133#undef LIB_SPEC
134#define LIB_SPEC \
17772b2a
JJ
135 "%{pthread:-lpthread} \
136 %{shared:-lc} \
137 %{!shared: %{mieee-fp:-lieee} %{profile:-lc_p}%{!profile:-lc}}"
bfe87013 138
956d6950 139/* Provide a LINK_SPEC appropriate for GNU/Linux. Here we provide support
bfe87013
DE
140 for the special GCC options -static and -shared, which allow us to
141 link things in one of these three modes by applying the appropriate
142 combinations of options at link-time. We like to support here for
143 as many of the other GNU linker options as possible. But I don't
144 have the time to search for those flags. I am sure how to add
145 support for -soname shared_object_name. H.J.
146
147 I took out %{v:%{!V:-V}}. It is too much :-(. They can use
148 -Wl,-V.
149
150 When the -shared link option is used a final link is not being
151 done. */
152
80ffc95e 153/* If ELF is the default format, we should not use /lib/elf. */
bfe87013 154
345a6161
DM
155#ifdef SPARC_BI_ARCH
156
157#undef SUBTARGET_EXTRA_SPECS
158#define SUBTARGET_EXTRA_SPECS \
159 { "link_arch32", LINK_ARCH32_SPEC }, \
160 { "link_arch64", LINK_ARCH64_SPEC }, \
161 { "link_arch_default", LINK_ARCH_DEFAULT_SPEC }, \
162 { "link_arch", LINK_ARCH_SPEC },
163
164#define LINK_ARCH32_SPEC "-m elf32_sparc -Y P,/usr/lib %{shared:-shared} \
165 %{!shared: \
166 %{!ibcs: \
167 %{!static: \
168 %{rdynamic:-export-dynamic} \
169 %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \
170 %{static:-static}}} \
171"
172
173#define LINK_ARCH64_SPEC "-m elf64_sparc -Y P,/usr/lib64 %{shared:-shared} \
174 %{!shared: \
175 %{!ibcs: \
176 %{!static: \
177 %{rdynamic:-export-dynamic} \
178 %{!dynamic-linker:-dynamic-linker /lib64/ld-linux.so.2}} \
179 %{static:-static}}} \
180"
181
182#define LINK_ARCH_SPEC "\
183%{m32:%(link_arch32)} \
184%{m64:%(link_arch64)} \
185%{!m32:%{!m64:%(link_arch_default)}} \
186"
187
188#define LINK_ARCH_DEFAULT_SPEC \
189(DEFAULT_ARCH32_P ? LINK_ARCH32_SPEC : LINK_ARCH64_SPEC)
190
bfe87013 191#undef LINK_SPEC
345a6161
DM
192#define LINK_SPEC "\
193%(link_arch) \
194%{mlittle-endian:-EL} \
e95b1e6a 195%{!mno-relax:%{!r:-relax}} \
345a6161
DM
196"
197
198#undef CC1_SPEC
199#if DEFAULT_ARCH32_P
200#define CC1_SPEC "\
201%{sun4:} %{target:} \
202%{mcypress:-mcpu=cypress} \
203%{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \
204%{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \
d6964c30 205%{m32:%{m64:%emay not use both -m32 and -m64}} \
4710d3eb 206%{m64:-mptr64 -mstack-bias -mlong-double-128 \
247cfc5c
JJ
207 %{!mcpu*:%{!mcypress:%{!msparclite:%{!mf930:%{!mf934:%{!mv8:%{!msupersparc:-mcpu=ultrasparc}}}}}}} \
208 %{!mno-vis:%{!mcpu=v9:-mvis}}} \
345a6161
DM
209"
210#else
211#define CC1_SPEC "\
212%{sun4:} %{target:} \
213%{mcypress:-mcpu=cypress} \
214%{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \
215%{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \
d6964c30 216%{m32:%{m64:%emay not use both -m32 and -m64}} \
4710d3eb 217%{m32:-mptr32 -mno-stack-bias %{!mlong-double-128:-mlong-double-64} \
b25c3a22 218 %{!mcpu*:%{!mcypress:%{!msparclite:%{!mf930:%{!mf934:%{!mv8:%{!msupersparc:-mcpu=cypress}}}}}}}} \
9ce13279 219%{!m32:%{!mcpu*:-mcpu=ultrasparc}} \
247cfc5c 220%{!mno-vis:%{!m32:%{!mcpu=v9:-mvis}}} \
345a6161
DM
221"
222#endif
223
224#if DEFAULT_ARCH32_P
225#define MULTILIB_DEFAULTS { "m32" }
226#else
227#define MULTILIB_DEFAULTS { "m64" }
228#endif
229
230#else /* !SPARC_BI_ARCH */
231
232#undef LINK_SPEC
e95b1e6a 233#define LINK_SPEC "-m elf64_sparc -Y P,/usr/lib64 %{shared:-shared} \
bfe87013
DE
234 %{!shared: \
235 %{!ibcs: \
236 %{!static: \
237 %{rdynamic:-export-dynamic} \
345a6161 238 %{!dynamic-linker:-dynamic-linker /lib64/ld-linux.so.2}} \
bfe87013
DE
239 %{static:-static}}} \
240%{mlittle-endian:-EL} \
e95b1e6a 241%{!mno-relax:%{!r:-relax}} \
bfe87013
DE
242"
243
345a6161
DM
244#endif /* !SPARC_BI_ARCH */
245
bfe87013 246/* The sun bundled assembler doesn't accept -Yd, (and neither does gas).
80ffc95e 247 It's safe to pass -s always, even if -g is not used. */
bfe87013
DE
248#undef ASM_SPEC
249#define ASM_SPEC "\
250%{V} \
251%{v:%{!V:-V}} \
252%{!Qn:-Qy} \
253%{n} \
254%{T} \
255%{Ym,*} \
256%{Wa,*:%*} \
257-s %{fpic:-K PIC} %{fPIC:-K PIC} \
258%{mlittle-endian:-EL} \
e95b1e6a 259%(asm_cpu) %(asm_arch) %(asm_relax)"
bfe87013
DE
260
261/* Same as sparc.h */
262#undef DBX_REGISTER_NUMBER
263#define DBX_REGISTER_NUMBER(REGNO) (REGNO)
264
265/* System V Release 4 uses DWARF debugging info. Buf DWARF1 doesn't do
266 64-bit anything, so we use DWARF2. */
267
bfe87013 268#undef DWARF_DEBUGGING_INFO
23532de9
JT
269#define DWARF2_DEBUGGING_INFO 1
270#define DBX_DEBUGGING_INFO 1
bfe87013 271
bfe87013
DE
272#undef ASM_OUTPUT_ALIGNED_LOCAL
273#define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
274do { \
275 fputs ("\t.local\t", (FILE)); \
276 assemble_name ((FILE), (NAME)); \
277 putc ('\n', (FILE)); \
278 ASM_OUTPUT_ALIGNED_COMMON (FILE, NAME, SIZE, ALIGN); \
279} while (0)
280
281#undef COMMON_ASM_OP
471b6f1b 282#define COMMON_ASM_OP "\t.common\t"
bfe87013 283
59f96879
RH
284#undef LOCAL_LABEL_PREFIX
285#define LOCAL_LABEL_PREFIX "."
286
bfe87013
DE
287/* This is how to output a reference to an internal numbered label where
288 PREFIX is the class of label and NUM is the number within the class. */
289
290#undef ASM_OUTPUT_INTERNAL_LABELREF
291#define ASM_OUTPUT_INTERNAL_LABELREF(FILE,PREFIX,NUM) \
292 fprintf (FILE, ".L%s%d", PREFIX, NUM)
293
294/* This is how to store into the string LABEL
295 the symbol_ref name of an internal numbered label where
296 PREFIX is the class of label and NUM is the number within the class.
297 This is suitable for output with `assemble_name'. */
298
299#undef ASM_GENERATE_INTERNAL_LABEL
300#define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \
e59f7d3d 301 sprintf (LABEL, "*.L%s%ld", PREFIX, (long)(NUM))
bfe87013 302
bfe87013
DE
303/* DWARF bits. */
304
305/* Follow Irix 6 and not the Dwarf2 draft in using 64-bit offsets.
d6a7951f 306 Obviously the Dwarf2 folks haven't tried to actually build systems
bfe87013
DE
307 with their spec. On a 64-bit system, only 64-bit relocs become
308 RELATIVE relocations. */
309
310/* #define DWARF_OFFSET_SIZE PTR_SIZE */
275b60d6
JJ
311
312#if defined(HAVE_LD_EH_FRAME_HDR)
313#define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
314#endif
f7e0e539 315\f
b5de1a27
DM
316/* Don't be different from other Linux platforms in this regard. */
317#define HANDLE_PRAGMA_PACK_PUSH_POP
7a31a340
DM
318
319/* We use GNU ld so undefine this so that attribute((init_priority)) works. */
320#undef CTORS_SECTION_ASM_OP
321#undef DTORS_SECTION_ASM_OP
db430d26
DM
322
323/* Do code reading to identify a signal frame, and set the frame
324 state data appropriately. See unwind-dw2.c for the structs. */
325
db430d26
DM
326/* Handle multilib correctly. */
327#if defined(__arch64__)
56149abc 328/* 64-bit SPARC version */
db430d26
DM
329#define MD_FALLBACK_FRAME_STATE_FOR(CONTEXT, FS, SUCCESS) \
330 do { \
331 unsigned int *pc_ = (CONTEXT)->ra; \
332 long new_cfa_, i_; \
333 long regs_off_, fpu_save_off_; \
334 long this_cfa_, fpu_save_; \
335 \
336 if (pc_[0] != 0x82102065 /* mov NR_rt_sigreturn, %g1 */ \
337 || pc_[1] != 0x91d0206d) /* ta 0x6d */ \
338 break; \
339 regs_off_ = 192 + 128; \
340 fpu_save_off_ = regs_off_ + (16 * 8) + (3 * 8) + (2 * 4); \
341 this_cfa_ = (long) (CONTEXT)->cfa; \
342 new_cfa_ = *(long *)(((CONTEXT)->cfa) + (regs_off_ + (14 * 8))); \
3ef3f384 343 new_cfa_ += 2047; /* Stack bias */ \
db430d26
DM
344 fpu_save_ = *(long *)((this_cfa_) + (fpu_save_off_)); \
345 (FS)->cfa_how = CFA_REG_OFFSET; \
346 (FS)->cfa_reg = 14; \
347 (FS)->cfa_offset = new_cfa_ - (long) (CONTEXT)->cfa; \
348 for (i_ = 1; i_ < 16; ++i_) \
349 { \
db430d26
DM
350 (FS)->regs.reg[i_].how = REG_SAVED_OFFSET; \
351 (FS)->regs.reg[i_].loc.offset = \
352 this_cfa_ + (regs_off_ + (i_ * 8)) - new_cfa_; \
353 } \
354 for (i_ = 0; i_ < 16; ++i_) \
355 { \
356 (FS)->regs.reg[i_ + 16].how = REG_SAVED_OFFSET; \
357 (FS)->regs.reg[i_ + 16].loc.offset = \
358 this_cfa_ + (i_ * 8) - new_cfa_; \
359 } \
360 if (fpu_save_) \
361 { \
362 for (i_ = 0; i_ < 64; ++i_) \
363 { \
364 if (i_ > 32 && (i_ & 0x1)) \
365 continue; \
366 (FS)->regs.reg[i_ + 32].how = REG_SAVED_OFFSET; \
367 (FS)->regs.reg[i_ + 32].loc.offset = \
368 (fpu_save_ + (i_ * 4)) - new_cfa_; \
369 } \
370 } \
371 /* Stick return address into %g0, same trick Alpha uses. */ \
372 (FS)->regs.reg[0].how = REG_SAVED_OFFSET; \
373 (FS)->regs.reg[0].loc.offset = \
374 this_cfa_ + (regs_off_ + (16 * 8) + 8) - new_cfa_; \
375 (FS)->retaddr_column = 0; \
376 goto SUCCESS; \
377 } while (0)
378#else
56149abc 379/* 32-bit SPARC version */
db430d26
DM
380#define MD_FALLBACK_FRAME_STATE_FOR(CONTEXT, FS, SUCCESS) \
381 do { \
382 unsigned int *pc_ = (CONTEXT)->ra; \
383 int new_cfa_, i_, oldstyle_; \
384 int regs_off_, fpu_save_off_; \
385 int fpu_save_, this_cfa_; \
386 \
387 if (pc_[1] != 0x91d02010) /* ta 0x10 */ \
388 break; \
389 if (pc_[0] == 0x821020d8) /* mov NR_sigreturn, %g1 */ \
390 oldstyle_ = 1; \
391 else if (pc_[0] == 0x82102065) /* mov NR_rt_sigreturn, %g1 */ \
392 oldstyle_ = 0; \
393 else \
394 break; \
395 if (oldstyle_) \
396 { \
397 regs_off_ = 96; \
398 fpu_save_off_ = regs_off_ + (4 * 4) + (16 * 4); \
399 } \
400 else \
401 { \
402 regs_off_ = 96 + 128; \
403 fpu_save_off_ = regs_off_ + (4 * 4) + (16 * 4) + (2 * 4); \
404 } \
405 this_cfa_ = (int) (CONTEXT)->cfa; \
406 new_cfa_ = *(int *)(((CONTEXT)->cfa) + (regs_off_+(4*4)+(14 * 4))); \
407 fpu_save_ = *(int *)((this_cfa_) + (fpu_save_off_)); \
408 (FS)->cfa_how = CFA_REG_OFFSET; \
409 (FS)->cfa_reg = 14; \
410 (FS)->cfa_offset = new_cfa_ - (int) (CONTEXT)->cfa; \
411 for (i_ = 1; i_ < 16; ++i_) \
412 { \
413 if (i_ == 14) \
414 continue; \
415 (FS)->regs.reg[i_].how = REG_SAVED_OFFSET; \
416 (FS)->regs.reg[i_].loc.offset = \
417 this_cfa_ + (regs_off_+(4 * 4)+(i_ * 4)) - new_cfa_; \
418 } \
419 for (i_ = 0; i_ < 16; ++i_) \
420 { \
421 (FS)->regs.reg[i_ + 16].how = REG_SAVED_OFFSET; \
422 (FS)->regs.reg[i_ + 16].loc.offset = \
423 this_cfa_ + (i_ * 4) - new_cfa_; \
424 } \
425 if (fpu_save_) \
426 { \
427 for (i_ = 0; i_ < 32; ++i_) \
428 { \
429 (FS)->regs.reg[i_ + 32].how = REG_SAVED_OFFSET; \
430 (FS)->regs.reg[i_ + 32].loc.offset = \
431 (fpu_save_ + (i_ * 4)) - new_cfa_; \
432 } \
433 } \
434 /* Stick return address into %g0, same trick Alpha uses. */ \
435 (FS)->regs.reg[0].how = REG_SAVED_OFFSET; \
436 (FS)->regs.reg[0].loc.offset = this_cfa_+(regs_off_+4)-new_cfa_; \
437 (FS)->retaddr_column = 0; \
438 goto SUCCESS; \
439 } while (0)
440#endif