OSDN Git Service

2001-08-11 H.J. Lu <hjl@gnu.org>
[pf3gnuchains/gcc-fork.git] / gcc / config / mips / linux.h
1 /* Definitions for MIPS running Linux-based GNU systems with ELF format.
2    Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
3
4 This file is part of GNU CC.
5
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING.  If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA.  */
20
21 #include "gofast.h"
22
23 /* US Software GOFAST library support.  */
24 #define INIT_SUBTARGET_OPTABS INIT_GOFAST_OPTABS
25
26 #include "mips/mips.h"
27
28 #undef WCHAR_TYPE
29 #define WCHAR_TYPE "int"
30
31 #undef WCHAR_TYPE_SIZE
32 #define WCHAR_TYPE_SIZE 32
33
34 /* If defined, a C expression whose value is a string containing the
35    assembler operation to identify the following data as
36    uninitialized global data.  If not defined, and neither
37    `ASM_OUTPUT_BSS' nor `ASM_OUTPUT_ALIGNED_BSS' are defined,
38    uninitialized global data will be output in the data section if
39    `-fno-common' is passed, otherwise `ASM_OUTPUT_COMMON' will be
40    used.  */
41 #define BSS_SECTION_ASM_OP      "\t.section\t.bss"
42
43 #define SBSS_SECTION_ASM_OP     "\t.section .sbss"
44
45 /* Like `ASM_OUTPUT_BSS' except takes the required alignment as a
46    separate, explicit argument.  If you define this macro, it is used
47    in place of `ASM_OUTPUT_BSS', and gives you more flexibility in
48    handling the required alignment of the variable.  The alignment is
49    specified as the number of bits.
50
51    Try to use function `asm_output_aligned_bss' defined in file
52    `varasm.c' when defining this macro. */
53 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN)   \
54 do {                                                            \
55   ASM_GLOBALIZE_LABEL (FILE, NAME);                             \
56   if (SIZE > 0 && SIZE <= mips_section_threshold)               \
57     sbss_section ();                                            \
58   else                                                          \
59     bss_section ();                                             \
60   ASM_OUTPUT_ALIGN (FILE, floor_log2 (ALIGN / BITS_PER_UNIT));  \
61   last_assemble_variable_decl = DECL;                           \
62   ASM_DECLARE_OBJECT_NAME (FILE, NAME, DECL);                   \
63   ASM_OUTPUT_SKIP (FILE, SIZE ? SIZE : 1);                      \
64 } while (0)
65
66 /* These macros generate the special .type and .size directives which
67    are used to set the corresponding fields of the linker symbol table
68    entries in an ELF object file under SVR4.  These macros also output
69    the starting labels for the relevant functions/objects.  */
70
71 /* Write the extra assembler code needed to declare an object properly.  */
72
73 #undef ASM_DECLARE_OBJECT_NAME
74 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL)               \
75   do {                                                          \
76     fprintf (FILE, "%s", TYPE_ASM_OP);                          \
77     assemble_name (FILE, NAME);                                 \
78     putc (',', FILE);                                           \
79     fprintf (FILE, TYPE_OPERAND_FMT, "object");                 \
80     putc ('\n', FILE);                                          \
81     size_directive_output = 0;                                  \
82     if (!flag_inhibit_size_directive && DECL_SIZE (DECL))       \
83       {                                                         \
84         size_directive_output = 1;                              \
85         fprintf (FILE, "%s", SIZE_ASM_OP);                      \
86         assemble_name (FILE, NAME);                             \
87         fprintf (FILE, ",%d\n",                                 \
88                  int_size_in_bytes (TREE_TYPE (DECL)));         \
89       }                                                         \
90     mips_declare_object (FILE, NAME, "", ":\n", 0);             \
91   } while (0)
92
93 #undef UNIQUE_SECTION
94 #define UNIQUE_SECTION(DECL,RELOC) \
95   mips_unique_section ((DECL), (RELOC))
96
97 /* A list of other sections which the compiler might be "in" at any
98    given time.  */
99 #undef EXTRA_SECTIONS
100 #define EXTRA_SECTIONS in_sdata, in_sbss, in_rdata
101  
102 #undef EXTRA_SECTION_FUNCTIONS
103 #define EXTRA_SECTION_FUNCTIONS                                         \
104   SECTION_FUNCTION_TEMPLATE(sdata_section, in_sdata, SDATA_SECTION_ASM_OP) \
105   SECTION_FUNCTION_TEMPLATE(sbss_section, in_sbss, SBSS_SECTION_ASM_OP) \
106   SECTION_FUNCTION_TEMPLATE(rdata_section, in_rdata, RDATA_SECTION_ASM_OP)
107
108 #define SECTION_FUNCTION_TEMPLATE(FN, ENUM, OP)                 \
109 void FN ()                                                      \
110 {                                                               \
111   if (in_section != ENUM)                                       \
112     {                                                           \
113       fprintf (asm_out_file, "%s\n", OP);                       \
114       in_section = ENUM;                                        \
115     }                                                           \
116 }
117
118 /* A C statement (sans semicolon) to output an element in the table of
119    global constructors.  */
120 #undef ASM_OUTPUT_CONSTRUCTOR
121 #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME)                         \
122   do {                                                            \
123     ctors_section ();                                             \
124     fprintf (FILE, "\t%s\t", TARGET_LONG64 ? ".dword" : ".word"); \
125     assemble_name (FILE, NAME);                                   \
126     fprintf (FILE, "\n");                                         \
127   } while (0)
128
129
130 /* A C statement (sans semicolon) to output an element in the table of
131    global destructors.  */
132 #undef ASM_OUTPUT_DESTRUCTOR
133 #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME)                          \
134   do {                                                            \
135     dtors_section ();                                             \
136     fprintf (FILE, "\t%s\t", TARGET_LONG64 ? ".dword" : ".word"); \
137     assemble_name (FILE, NAME);                                   \
138     fprintf (FILE, "\n");                                         \
139   } while (0)
140
141 #undef TARGET_VERSION
142 #if TARGET_ENDIAN_DEFAULT == 0
143 #define TARGET_VERSION fprintf (stderr, " (MIPSel GNU/Linux with ELF)");
144 #else
145 #define TARGET_VERSION fprintf (stderr, " (MIPS GNU/Linux with ELF)");
146 #endif
147
148 #undef MD_EXEC_PREFIX
149 #undef MD_STARTFILE_PREFIX
150
151 /* Required to keep collect2.c happy */
152 #undef OBJECT_FORMAT_COFF
153
154 /* If we don't set MASK_ABICALLS, we can't default to PIC. */
155 #undef TARGET_DEFAULT
156 #define TARGET_DEFAULT (MASK_ABICALLS|MASK_GAS)
157
158 /* Specify predefined symbols in preprocessor.  */
159 #undef CPP_PREDEFINES
160 #if TARGET_ENDIAN_DEFAULT == 0
161 #define CPP_PREDEFINES "-DMIPSEL -D_MIPSEL -Dunix -Dmips -D_mips \
162 -DR3000 -D_R3000 -Dlinux -Asystem=posix -Acpu=mips \
163 -Amachine=mips -D__ELF__ -D__PIC__ -D__pic__"
164 #else
165 #define CPP_PREDEFINES "-DMIPSEB -D_MIPSEB -Dunix -Dmips -D_mips \
166 -DR3000 -D_R3000 -Dlinux -Asystem=posix -Acpu=mips \
167 -Amachine=mips -D__ELF__ -D__PIC__ -D__pic__"
168 #endif
169
170 #undef SUBTARGET_CPP_SIZE_SPEC
171 #define SUBTARGET_CPP_SIZE_SPEC "\
172 %{mabi=32: -D__SIZE_TYPE__=unsigned\\ int -D__PTRDIFF_TYPE__=int} \
173 %{mabi=n32: -D__SIZE_TYPE__=unsigned\\ int -D__PTRDIFF_TYPE__=int} \
174 %{mabi=64: -D__SIZE_TYPE__=long\\ unsigned\\ int -D__PTRDIFF_TYPE__=long\\ int} \
175 %{!mabi*: -D__SIZE_TYPE__=unsigned\\ int -D__PTRDIFF_TYPE__=int}"
176
177 /* We must make -mips3 do what -mlong64 used to do.  */
178 /* ??? If no mipsX option given, but a mabi=X option is, then should set
179    _MIPS_ISA based on the mabi=X option.  */
180 /* ??? If no mabi=X option give, but a mipsX option is, then should set
181    _MIPS_SIM based on the mipsX option.  */
182 /* ??? Same for _MIPS_SZINT.  */
183 /* ??? Same for _MIPS_SZPTR.  */
184 /* ??? Same for __SIZE_TYPE and __PTRDIFF_TYPE.  */
185 #undef SUBTARGET_CPP_SPEC
186 #define SUBTARGET_CPP_SPEC "\
187 %{mfp32: -D_MIPS_FPSET=16} \
188 %{mfp64: -D_MIPS_FPSET=32} \
189 %{!mfp*: -D_MIPS_FPSET=32} \
190 %{mips1: -D_MIPS_ISA=_MIPS_ISA_MIPS1} \
191 %{mips2: -D_MIPS_ISA=_MIPS_ISA_MIPS2} \
192 %{mips3: -D_MIPS_ISA=_MIPS_ISA_MIPS3} \
193 %{mips4: -D_MIPS_ISA=_MIPS_ISA_MIPS4} \
194 %{!mips*: -D_MIPS_ISA=_MIPS_ISA_MIPS1} \
195 %{mabi=32: -D_MIPS_SIM=_MIPS_SIM_ABI32} \
196 %{mabi=n32: -D_ABIN32=2 -D_MIPS_SIM=_ABIN32} \
197 %{mabi=64: -D_ABI64=3 -D_MIPS_SIM=_ABI64} \
198 %{!mabi*: -D_MIPS_SIM=_MIPS_SIM_ABI32}  \
199 %{!mint64: -D_MIPS_SZINT=32}%{mint64: -D_MIPS_SZINT=64} \
200 %{mabi=32: -D_MIPS_SZLONG=32} \
201 %{mabi=n32: -D_MIPS_SZLONG=32} \
202 %{mabi=64: -D_MIPS_SZLONG=64} \
203 %{!mabi*: -D_MIPS_SZLONG=32} \
204 %{mabi=32: -D_MIPS_SZPTR=32} \
205 %{mabi=n32: -D_MIPS_SZPTR=32} \
206 %{mabi=64: -D_MIPS_SZPTR=64} \
207 %{!mabi*: -D_MIPS_SZPTR=32} \
208 %{!mips*: -U__mips -D__mips} \
209 %{mabi=32: -U__mips64} \
210 %{mabi=n32: -D__mips64} \
211 %{mabi=64: -U__mips64} \
212 %{!mabi*: -U__mips64} \
213 %{fno-PIC:-U__PIC__ -U__pic__} %{fno-pic:-U__PIC__ -U__pic__} \
214 %{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} \
215 %{pthread:-D_REENTRANT}"
216
217 /* The GNU C++ standard library requires that these macros be defined.  */
218 #undef CPLUSPLUS_CPP_SPEC
219 #define CPLUSPLUS_CPP_SPEC "\
220 -D__LANGUAGE_C_PLUS_PLUS -D_LANGUAGE_C_PLUS_PLUS \
221 -D_GNU_SOURCE %(cpp) \
222 "
223
224 /* From iris5.h */
225 /* -G is incompatible with -KPIC which is the default, so only allow objects
226    in the small data section if the user explicitly asks for it.  */
227 #undef MIPS_DEFAULT_GVALUE
228 #define MIPS_DEFAULT_GVALUE 0
229
230 /* Borrowed from sparc/linux.h */
231 #undef LINK_SPEC
232 #define LINK_SPEC \
233  "%(endian_spec) \
234   %{shared:-shared} \
235   %{!shared: \
236     %{!ibcs: \
237       %{!static: \
238         %{rdynamic:-export-dynamic} \
239         %{!dynamic-linker:-dynamic-linker /lib/ld.so.1}} \
240         %{static:-static}}}"
241
242
243 #undef SUBTARGET_ASM_SPEC
244 #define SUBTARGET_ASM_SPEC "\
245 %{mabi=64: -64} \
246 %{!fno-PIC:%{!fno-pic:-KPIC}} \
247 %{fno-PIC:-non_shared} %{fno-pic:-non_shared}"
248
249 /* The MIPS assembler has different syntax for .set. We set it to
250    .dummy to trap any errors.  */
251 #undef SET_ASM_OP
252 #define SET_ASM_OP "\t.dummy\t"
253
254 #undef ASM_OUTPUT_DEF
255 #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2)                              \
256  do {                                                                   \
257         fputc ( '\t', FILE);                                            \
258         assemble_name (FILE, LABEL1);                                   \
259         fputs ( " = ", FILE);                                           \
260         assemble_name (FILE, LABEL2);                                   \
261         fputc ( '\n', FILE);                                            \
262  } while (0)
263
264 #undef ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL
265 #define ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL(FILE, SY, HI, LO)     \
266   do {                                                                  \
267         fputc ('\t', FILE);                                             \
268         assemble_name (FILE, SY);                                       \
269         fputc ('=', FILE);                                              \
270         assemble_name (FILE, HI);                                       \
271         fputc ('-', FILE);                                              \
272         assemble_name (FILE, LO);                                       \
273   } while (0)
274
275 #undef ASM_DECLARE_FUNCTION_NAME
276 #define ASM_DECLARE_FUNCTION_NAME(STREAM, NAME, DECL)                   \
277   do {                                                                  \
278     if (!flag_inhibit_size_directive)                                   \
279       {                                                                 \
280         fputs ("\t.ent\t", STREAM);                                     \
281         assemble_name (STREAM, NAME);                                   \
282         putc ('\n', STREAM);                                            \
283       }                                                                 \
284     fprintf (STREAM, "\t%s\t ", TYPE_ASM_OP);                           \
285     assemble_name (STREAM, NAME);                                       \
286     putc (',', STREAM);                                                 \
287     fprintf (STREAM, TYPE_OPERAND_FMT, "function");                     \
288     putc ('\n', STREAM);                                                \
289     assemble_name (STREAM, NAME);                                       \
290     fputs (":\n", STREAM);                                              \
291   } while (0)
292
293 #undef ASM_DECLARE_FUNCTION_SIZE
294 #define ASM_DECLARE_FUNCTION_SIZE(STREAM, NAME, DECL)                   \
295   do {                                                                  \
296     if (!flag_inhibit_size_directive)                                   \
297       {                                                                 \
298         fputs ("\t.end\t", STREAM);                                     \
299         assemble_name (STREAM, NAME);                                   \
300         putc ('\n', STREAM);                                            \
301       }                                                                 \
302   } while (0)
303
304 /* Tell function_prologue in mips.c that we have already output the .ent/.end
305    pseudo-ops.  */
306 #define FUNCTION_NAME_ALREADY_DECLARED