OSDN Git Service

* config.gcc: Don't mention MAX_LONG_TYPE_SIZE.
[pf3gnuchains/gcc-fork.git] / gcc / config / mips / iris5.h
1 /* Definitions of target machine for GNU compiler.  IRIX version 5.
2    Copyright (C) 1993, 1995, 1996, 1998, 2000,
3    2001, 2002, 2003, 2004 Free Software Foundation, Inc.
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 /* We are compiling for IRIX now.  */
23 #undef TARGET_IRIX
24 #define TARGET_IRIX 1
25
26 /* Allow some special handling for IRIX 5.  */
27 #undef TARGET_IRIX5
28 #define TARGET_IRIX5 1
29
30 #define ABICALLS_ASM_OP "\t.option pic2"
31
32 /* ??? This is correct, but not very useful, because there is no file that
33    uses this macro.  */
34 /* ??? The best way to handle global constructors under ELF is to use .init
35    and .fini sections.  Unfortunately, there is apparently no way to get
36    the IRIX 5.x (x <= 2) assembler to create these sections.  So we instead
37    use collect.  The linker can create these sections via -init and -fini
38    options, but using this would require modifying how crtstuff works, and
39    I will leave that for another time (or someone else).  */
40 #define OBJECT_FORMAT_ELF
41 #define HAS_INIT_SECTION
42 #define LD_INIT_SWITCH "-init"
43 #define LD_FINI_SWITCH "-fini"
44
45 /* The linker needs a space after "-o".  */
46 #define SWITCHES_NEED_SPACES "o"
47
48 /* Specify wchar_t types.  */
49 #undef  WCHAR_TYPE
50 #undef  WCHAR_TYPE_SIZE
51
52 #define WCHAR_TYPE     "int"
53 #define WCHAR_TYPE_SIZE        INT_TYPE_SIZE
54
55 /* Plain char is unsigned in the SGI compiler.  */
56 #undef DEFAULT_SIGNED_CHAR
57 #define DEFAULT_SIGNED_CHAR 0
58
59 #define WORD_SWITCH_TAKES_ARG(STR)                      \
60  (DEFAULT_WORD_SWITCH_TAKES_ARG (STR)                   \
61   || !strcmp (STR, "rpath"))
62
63 /* We must pass -D_LONGLONG always, even when -ansi is used, because IRIX 5
64    system header files require it.  This is OK, because gcc never warns
65    when long long is used in system header files.  Alternatively, we can
66    add support for the SGI builtin type __long_long.  */
67
68 #define TARGET_OS_CPP_BUILTINS()                        \
69     do {                                                \
70         builtin_define_std ("host_mips");               \
71         builtin_define_std ("sgi");                     \
72         builtin_define_std ("unix");                    \
73         builtin_define_std ("SYSTYPE_SVR4");            \
74         builtin_define ("_LONGLONG");                   \
75         builtin_define ("_MODERN_C");                   \
76         builtin_define ("_SVR4_SOURCE");                \
77         builtin_define ("__DSO__");                     \
78         builtin_define ("_ABIO32=1");                   \
79         builtin_define ("_MIPS_SIM=_ABIO32");           \
80         builtin_define ("_MIPS_SZPTR=32");              \
81         builtin_assert ("system=unix");                 \
82         builtin_assert ("system=svr4");                 \
83         builtin_assert ("machine=sgi");                 \
84                                                         \
85      if (!TARGET_FLOAT64)                               \
86         builtin_define ("_MIPS_FPSET=16");              \
87      else                                               \
88         builtin_define ("_MIPS_FPSET=32");              \
89                                                         \
90      if (!TARGET_INT64)                                 \
91         builtin_define ("_MIPS_SZINT=32");              \
92      else                                               \
93         builtin_define ("_MIPS_SZINT=64");              \
94                                                         \
95      if (!TARGET_LONG64)                                \
96         builtin_define ("_MIPS_SZLONG=32");             \
97      else                                               \
98         builtin_define ("_MIPS_SZLONG=64");             \
99                                                         \
100      if (!flag_iso)                                     \
101        {                                                \
102          builtin_define ("__EXTENSIONS__");             \
103          builtin_define ("_SGI_SOURCE");                \
104        }                                                \
105 } while (0);
106
107 #undef SUBTARGET_CC1_SPEC
108 #define SUBTARGET_CC1_SPEC "%{static: -mno-abicalls}"
109
110 /* Override mips.h default: the IRIX 5 assembler warns about -O3:
111
112    as1: Warning: <file>.s, line 1: Binasm file dictates -pic: 2
113    uld:
114    No ucode object file linked -- please use -O2 or lower.
115    
116    So avoid passing it in the first place.  */
117 #undef SUBTARGET_ASM_OPTIMIZING_SPEC
118 #define SUBTARGET_ASM_OPTIMIZING_SPEC "\
119 %{noasmopt:-O0} \
120 %{!noasmopt:%{O|O1|O2|O3:-O2}}"
121
122 #undef LINK_SPEC
123 #define LINK_SPEC "\
124 %{G*} %{EB} %{EL} %{mips1} %{mips2} %{mips3} \
125 %{bestGnum} %{shared} %{non_shared} \
126 %{call_shared} %{no_archive} %{exact_version} \
127 %{static: -non_shared} \
128 %{!static: \
129   %{!shared:%{!non_shared:%{!call_shared: -call_shared -no_unresolved}}}} \
130 %{rpath} \
131 -_SYSTYPE_SVR4"
132
133 /* We now support shared libraries.  */
134 #undef STARTFILE_SPEC
135 #define STARTFILE_SPEC "\
136 %{!static: \
137   %{!shared:%{pg:gcrt1.o%s}%{!pg:%{p:mcrt1.o%s libprof1.a%s}%{!p:crt1.o%s}}}} \
138 %{static: \
139   %{pg:gcrt1.o%s} \
140   %{!pg:%{p:/usr/lib/nonshared/mcrt1.o%s libprof1.a%s} \
141   %{!p:/usr/lib/nonshared/crt1.o%s}}}"
142
143 #undef LIB_SPEC
144 #define LIB_SPEC "%{!shared:%{p:-lprof1} %{pg:-lprof1} -lc}"
145
146 #undef ENDFILE_SPEC
147 #define ENDFILE_SPEC "%{!shared:crtn.o%s}"
148
149 /* We do not want to run mips-tfile!  */
150 #undef ASM_FINAL_SPEC
151
152 /* The system header files are C++ aware.  */
153 /* ??? Unfortunately, most but not all of the headers are C++ aware.
154    Specifically, curses.h is not, and as a consequence, defining this
155    used to prevent libg++ building.  This is no longer the case so
156    define it again to prevent other problems, e.g. with getopt in
157    unistd.h.  We still need some way to fix just those files that need
158    fixing.  */
159 #define NO_IMPLICIT_EXTERN_C 1
160
161 /* We don't support debugging info for now.  */
162 #undef DBX_DEBUGGING_INFO
163 #undef MIPS_DEBUGGING_INFO
164 #undef PREFERRED_DEBUGGING_TYPE
165
166 /* Likewise, the assembler doesn't handle DWARF2 directives.  */
167 #define DWARF2_UNWIND_INFO 0
168
169 #undef MACHINE_TYPE
170 #define MACHINE_TYPE "SGI running IRIX 5.x"
171
172 /* Always use 1 for .file number.  I [meissner@osf.org] wonder why
173    IRIX needs this.  */
174
175 #undef SET_FILE_NUMBER
176 #define SET_FILE_NUMBER() num_source_filenames = 1
177
178 /* Put out a label after a .loc.  I [meissner@osf.org] wonder why
179    IRIX needs this.  */
180
181 #undef LABEL_AFTER_LOC
182 #define LABEL_AFTER_LOC(STREAM) fprintf (STREAM, "LM%d:\n", ++sym_lineno)
183
184  /* Dollar signs are OK in IRIX 5 but not in IRIX 3.  */
185 #undef DOLLARS_IN_IDENTIFIERS
186 #undef NO_DOLLAR_IN_LABEL
187
188 /* -G is incompatible with -KPIC which is the default, so only allow objects
189    in the small data section if the user explicitly asks for it.  */
190 #undef MIPS_DEFAULT_GVALUE
191 #define MIPS_DEFAULT_GVALUE 0
192
193 /* Some assemblers have a bug that causes backslash escaped chars in .ascii
194    to be misassembled, so avoid it by using .byte instead.  Write the original
195    string in a comment, partly to improve readability and partly for the sake
196    of scan-assembler-type tests.  */
197 #undef ASM_OUTPUT_ASCII
198 #define ASM_OUTPUT_ASCII(FILE,PTR,LEN)                          \
199 do {                                                            \
200   const unsigned char *s_ = (const unsigned char *)(PTR);       \
201   unsigned len_ = (LEN);                                        \
202   unsigned i_;                                                  \
203   mips_output_ascii (FILE, (const char *) s_, len_, "\t# ");    \
204   for (i_ = 0; i_ < len_; s_++, i_++)                           \
205     {                                                           \
206       if ((i_ % 8) == 0)                                        \
207         fputs ("\n\t.byte\t", (FILE));                          \
208       fprintf ((FILE), "%s0x%x", (i_%8?",":""), *s_);           \
209     }                                                           \
210   fputs ("\n", (FILE));                                         \
211 } while (0)
212
213 /* Also do this for libcalls.  */
214 #undef TARGET_ASM_EXTERNAL_LIBCALL
215 #define TARGET_ASM_EXTERNAL_LIBCALL irix_output_external_libcall
216
217 /* This does for functions what ASM_DECLARE_OBJECT_NAME does for variables.
218    This is used indirectly by ASM_OUTPUT_EXTERNAL.  */
219 #define ASM_DECLARE_FUNCTION_SIZE(STREAM, NAME, DECL)   \
220 do {                                                    \
221   tree name_tree = get_identifier (NAME);               \
222   TREE_ASM_WRITTEN (name_tree) = 1;                     \
223 } while (0)
224
225 /* This is how we tell the assembler that a symbol is weak.  */
226
227 #define ASM_OUTPUT_WEAK_ALIAS(FILE, NAME, VALUE)        \
228   do                                                    \
229     {                                                   \
230       (*targetm.asm_out.globalize_label) (FILE, NAME);  \
231       fputs ("\t.weakext\t", FILE);                     \
232       assemble_name (FILE, NAME);                       \
233       if (VALUE)                                        \
234         {                                               \
235           fputc (' ', FILE);                            \
236           assemble_name (FILE, VALUE);                  \
237         }                                               \
238       fputc ('\n', FILE);                               \
239     }                                                   \
240   while (0)
241
242 #define ASM_WEAKEN_LABEL(FILE, NAME) ASM_OUTPUT_WEAK_ALIAS(FILE, NAME, 0)
243
244 /* Handle #pragma weak and #pragma pack.  */
245 #define HANDLE_SYSV_PRAGMA 1