1/* Definitions of target machine for GNU compiler.  Generic IRIX version.
2   Copyright (C) 1993, 1995, 1996, 1998, 2000,
3   2001, 2002, 2003, 2004 Free Software Foundation, Inc.
4
5This file is part of GCC.
6
7GCC 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
12GCC 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 GCC; see the file COPYING.  If not, write to
19the Free Software Foundation, 51 Franklin Street, Fifth Floor,
20Boston, MA 02110-1301, USA.  */
21
22/* We are compiling for IRIX now.  */
23#undef TARGET_IRIX
24#define TARGET_IRIX 1
25
26/* The size in bytes of a DWARF field indicating an offset or length
27   relative to a debug info section, specified to be 4 bytes in the DWARF-2
28   specification.  The SGI/MIPS ABI defines it to be the same as PTR_SIZE.  */
29#define DWARF_OFFSET_SIZE PTR_SIZE
30
31/* The size in bytes of the initial length field in a debug info
32   section.  The DWARF 3 (draft) specification defines this to be
33   either 4 or 12 (with a 4-byte "escape" word when it's 12), but the
34   SGI/MIPS ABI predates this standard and defines it to be the same
35   as DWARF_OFFSET_SIZE.  */
36#define DWARF_INITIAL_LENGTH_SIZE DWARF_OFFSET_SIZE
37
38/* MIPS assemblers don't have the usual .set foo,bar construct;
39   .set is used for assembler options instead.  */
40#undef SET_ASM_OP
41#define ASM_OUTPUT_DEF(FILE, LABEL1, LABEL2)			\
42  do								\
43    {								\
44      fputc ('\t', FILE);					\
45      assemble_name (FILE, LABEL1);				\
46      fputs (" = ", FILE);					\
47      assemble_name (FILE, LABEL2);				\
48      fputc ('\n', FILE);					\
49    }								\
50  while (0)
51
52/* The MIPSpro o32 linker warns about not linking .comment sections.  */
53#undef IDENT_ASM_OP
54
55#undef LOCAL_LABEL_PREFIX
56#define LOCAL_LABEL_PREFIX (TARGET_NEWABI ? "." : "$")
57
58#undef ASM_DECLARE_OBJECT_NAME
59#define ASM_DECLARE_OBJECT_NAME mips_declare_object_name
60
61#undef ASM_FINISH_DECLARE_OBJECT
62#define ASM_FINISH_DECLARE_OBJECT mips_finish_declare_object
63
64/* Also do this for libcalls.  */
65#undef TARGET_ASM_EXTERNAL_LIBCALL
66#define TARGET_ASM_EXTERNAL_LIBCALL irix_output_external_libcall
67
68/* The linker needs a space after "-o".  */
69#define SWITCHES_NEED_SPACES "o"
70
71/* Specify wchar_t types.  */
72#undef WCHAR_TYPE
73#define WCHAR_TYPE (Pmode == DImode ? "int" : "long int")
74
75#undef WCHAR_TYPE_SIZE
76#define WCHAR_TYPE_SIZE INT_TYPE_SIZE
77
78/* Same for wint_t.  */
79#undef WINT_TYPE
80#define WINT_TYPE (Pmode == DImode ? "int" : "long int")
81
82#undef WINT_TYPE_SIZE
83#define WINT_TYPE_SIZE 32
84
85/* Plain char is unsigned in the SGI compiler.  */
86#undef DEFAULT_SIGNED_CHAR
87#define DEFAULT_SIGNED_CHAR 0
88
89#define WORD_SWITCH_TAKES_ARG(STR)			\
90  (DEFAULT_WORD_SWITCH_TAKES_ARG (STR)			\
91   || strcmp (STR, "rpath") == 0)
92
93#define TARGET_OS_CPP_BUILTINS()				\
94  do								\
95    {								\
96      builtin_define_std ("host_mips");				\
97      builtin_define_std ("sgi");				\
98      builtin_define_std ("unix");				\
99      builtin_define_std ("SYSTYPE_SVR4");			\
100      builtin_define ("_MODERN_C");				\
101      builtin_define ("_SVR4_SOURCE");				\
102      builtin_define ("__DSO__");				\
103      builtin_assert ("system=unix");				\
104      builtin_assert ("system=svr4");				\
105      builtin_assert ("machine=sgi");				\
106								\
107      if (mips_abi == ABI_32)					\
108	{							\
109	  builtin_define ("_ABIO32=1");				\
110	  builtin_define ("_MIPS_SIM=_ABIO32");			\
111	  builtin_define ("_MIPS_SZINT=32");			\
112	  builtin_define ("_MIPS_SZLONG=32");			\
113	  builtin_define ("_MIPS_SZPTR=32");			\
114	}							\
115      else if (mips_abi == ABI_64)				\
116	{							\
117	  builtin_define ("_ABI64=3");				\
118	  builtin_define ("_MIPS_SIM=_ABI64");			\
119	  builtin_define ("_MIPS_SZINT=32");			\
120	  builtin_define ("_MIPS_SZLONG=64");			\
121	  builtin_define ("_MIPS_SZPTR=64");			\
122	}							\
123      else							\
124	{							\
125	  builtin_define ("_ABIN32=2");				\
126	  builtin_define ("_MIPS_SIM=_ABIN32");			\
127	  builtin_define ("_MIPS_SZINT=32");			\
128	  builtin_define ("_MIPS_SZLONG=32");			\
129	  builtin_define ("_MIPS_SZPTR=32");			\
130        }							\
131								\
132      if (!ISA_MIPS1 && !ISA_MIPS2)				\
133	builtin_define ("_COMPILER_VERSION=601");		\
134								\
135      if (!TARGET_FLOAT64)					\
136	builtin_define ("_MIPS_FPSET=16");			\
137      else							\
138	builtin_define ("_MIPS_FPSET=32");			\
139								\
140      /* We must always define _LONGLONG, even when -ansi is	\
141	 used, because IRIX 5 system header files require it.	\
142	 This is OK, because gcc never warns when long long	\
143	 is used in system header files.			\
144								\
145	 An alternative would be to support the SGI builtin	\
146	 type __long_long.  */					\
147      builtin_define ("_LONGLONG");				\
148								\
149      /* IRIX 6.5.18 and above provide many ISO C99		\
150	 features protected by the __c99 macro.			\
151	 libstdc++ v3 needs them as well.  */			\
152      if (TARGET_IRIX6)						\
153	if (flag_isoc99 || c_dialect_cxx ())			\
154	  builtin_define ("__c99");				\
155								\
156      /* The GNU C++ standard library requires that		\
157	 __EXTENSIONS__ and _SGI_SOURCE be defined on at	\
158	 least IRIX 6.2 and probably all IRIX 6 prior to 6.5.	\
159	 We don't need this on IRIX 6.5 itself, but it		\
160	 shouldn't hurt other than the namespace pollution.  */	\
161      if (!flag_iso || (TARGET_IRIX6 && c_dialect_cxx ()))	\
162	{							\
163	  builtin_define ("__EXTENSIONS__");			\
164	  builtin_define ("_SGI_SOURCE");			\
165	}							\
166    }								\
167  while (0)
168
169#undef SUBTARGET_CC1_SPEC
170#define SUBTARGET_CC1_SPEC "%{static: -mno-abicalls}"
171
172#undef INIT_SECTION_ASM_OP
173#define INIT_SECTION_ASM_OP "\t.section\t.gcc_init,\"ax\",@progbits"
174
175#undef FINI_SECTION_ASM_OP
176#define FINI_SECTION_ASM_OP "\t.section\t.gcc_fini,\"ax\",@progbits"
177
178#ifdef IRIX_USING_GNU_LD
179#define IRIX_NO_UNRESOLVED ""
180#else
181#define IRIX_NO_UNRESOLVED "-no_unresolved"
182#endif
183
184/* Generic part of the LINK_SPEC.  */
185#undef LINK_SPEC
186#define LINK_SPEC "\
187%{G*} %{EB} %{EL} %{mips1} %{mips2} %{mips3} %{mips4} \
188%{bestGnum} %{shared} %{non_shared} \
189%{call_shared} %{no_archive} %{exact_version} \
190%{!shared: \
191  %{!non_shared: %{!call_shared:%{!r: -call_shared " IRIX_NO_UNRESOLVED "}}}} \
192%{rpath} -init __gcc_init -fini __gcc_fini " IRIX_SUBTARGET_LINK_SPEC
193
194/* A linker error can empirically be avoided by removing duplicate
195   library search directories.  */
196#define LINK_ELIMINATE_DUPLICATE_LDIRECTORIES 1
197
198/* Add -g to mips.h default to avoid confusing gas with local symbols
199   generated from stabs info.  */
200#undef NM_FLAGS
201#define NM_FLAGS "-Bng"
202
203/* The system header files are C++ aware.  */
204/* ??? Unfortunately, most but not all of the headers are C++ aware.
205   Specifically, curses.h is not, and as a consequence, defining this
206   used to prevent libg++ building.  This is no longer the case so
207   define it again to prevent other problems, e.g. with getopt in
208   unistd.h.  We still need some way to fix just those files that need
209   fixing.  */
210#define NO_IMPLICIT_EXTERN_C 1
211
212/* -G is incompatible with -KPIC which is the default, so only allow objects
213   in the small data section if the user explicitly asks for it.  */
214#undef MIPS_DEFAULT_GVALUE
215#define MIPS_DEFAULT_GVALUE 0
216
217/* The native o32 IRIX linker does not support merging without a
218   special elspec(5) file.  */
219#ifndef IRIX_USING_GNU_LD
220#undef HAVE_GAS_SHF_MERGE
221#define HAVE_GAS_SHF_MERGE 0
222#endif
223