OSDN Git Service

* c-parse.in (MODIFIED_WCHAR_TYPE): New macro.
[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, 2002 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 "mips/mips.h"
22 #include "mips/abi64.h"
23
24 #undef WCHAR_TYPE
25 #define WCHAR_TYPE "int"
26
27 #undef WCHAR_TYPE_SIZE
28 #define WCHAR_TYPE_SIZE 32
29
30 /* If defined, a C expression whose value is a string containing the
31    assembler operation to identify the following data as
32    uninitialized global data.  If not defined, and neither
33    `ASM_OUTPUT_BSS' nor `ASM_OUTPUT_ALIGNED_BSS' are defined,
34    uninitialized global data will be output in the data section if
35    `-fno-common' is passed, otherwise `ASM_OUTPUT_COMMON' will be
36    used.  */
37 #define BSS_SECTION_ASM_OP      "\t.section\t.bss"
38
39 #define SBSS_SECTION_ASM_OP     "\t.section .sbss"
40
41 /* Like `ASM_OUTPUT_BSS' except takes the required alignment as a
42    separate, explicit argument.  If you define this macro, it is used
43    in place of `ASM_OUTPUT_BSS', and gives you more flexibility in
44    handling the required alignment of the variable.  The alignment is
45    specified as the number of bits.
46
47    Try to use function `asm_output_aligned_bss' defined in file
48    `varasm.c' when defining this macro.  */
49 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN)   \
50 do {                                                            \
51   ASM_GLOBALIZE_LABEL (FILE, NAME);                             \
52   if (SIZE > 0 && SIZE <= mips_section_threshold)               \
53     sbss_section ();                                            \
54   else                                                          \
55     bss_section ();                                             \
56   ASM_OUTPUT_ALIGN (FILE, floor_log2 (ALIGN / BITS_PER_UNIT));  \
57   last_assemble_variable_decl = DECL;                           \
58   ASM_DECLARE_OBJECT_NAME (FILE, NAME, DECL);                   \
59   ASM_OUTPUT_SKIP (FILE, SIZE ? SIZE : 1);                      \
60 } while (0)
61
62 /* These macros generate the special .type and .size directives which
63    are used to set the corresponding fields of the linker symbol table
64    entries in an ELF object file under SVR4.  These macros also output
65    the starting labels for the relevant functions/objects.  */
66
67 /* Write the extra assembler code needed to declare an object properly.  */
68
69 #undef ASM_DECLARE_OBJECT_NAME
70 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL)               \
71   do {                                                          \
72     fprintf (FILE, "%s", TYPE_ASM_OP);                          \
73     assemble_name (FILE, NAME);                                 \
74     putc (',', FILE);                                           \
75     fprintf (FILE, TYPE_OPERAND_FMT, "object");                 \
76     putc ('\n', FILE);                                          \
77     size_directive_output = 0;                                  \
78     if (!flag_inhibit_size_directive && DECL_SIZE (DECL))       \
79       {                                                         \
80         size_directive_output = 1;                              \
81         fprintf (FILE, "%s", SIZE_ASM_OP);                      \
82         assemble_name (FILE, NAME);                             \
83         fprintf (FILE, ",");                                    \
84         fprintf (FILE, HOST_WIDE_INT_PRINT_DEC,                 \
85                  int_size_in_bytes (TREE_TYPE (DECL)));         \
86         fprintf (FILE, "\n");                                   \
87       }                                                         \
88     mips_declare_object (FILE, NAME, "", ":\n", 0);             \
89   } while (0)
90
91 #undef UNIQUE_SECTION
92 #define UNIQUE_SECTION(DECL,RELOC) \
93   mips_unique_section ((DECL), (RELOC))
94
95 /* A list of other sections which the compiler might be "in" at any
96    given time.  */
97 #undef EXTRA_SECTIONS
98 #define EXTRA_SECTIONS in_sdata, in_sbss, in_rdata
99
100 #undef EXTRA_SECTION_FUNCTIONS
101 #define EXTRA_SECTION_FUNCTIONS                                         \
102   SECTION_FUNCTION_TEMPLATE(sdata_section, in_sdata, SDATA_SECTION_ASM_OP) \
103   SECTION_FUNCTION_TEMPLATE(sbss_section, in_sbss, SBSS_SECTION_ASM_OP) \
104   SECTION_FUNCTION_TEMPLATE(rdata_section, in_rdata, RDATA_SECTION_ASM_OP)
105
106 #define SECTION_FUNCTION_TEMPLATE(FN, ENUM, OP)                 \
107 void FN ()                                                      \
108 {                                                               \
109   if (in_section != ENUM)                                       \
110     {                                                           \
111       fprintf (asm_out_file, "%s\n", OP);                       \
112       in_section = ENUM;                                        \
113     }                                                           \
114 }
115
116 #undef TARGET_VERSION
117 #if TARGET_ENDIAN_DEFAULT == 0
118 #define TARGET_VERSION fprintf (stderr, " (MIPSel GNU/Linux with ELF)");
119 #else
120 #define TARGET_VERSION fprintf (stderr, " (MIPS GNU/Linux with ELF)");
121 #endif
122
123 #undef MD_EXEC_PREFIX
124 #undef MD_STARTFILE_PREFIX
125
126 /* Required to keep collect2.c happy */
127 #undef OBJECT_FORMAT_COFF
128
129 /* If we don't set MASK_ABICALLS, we can't default to PIC.  */
130 #undef TARGET_DEFAULT
131 #define TARGET_DEFAULT (MASK_ABICALLS|MASK_GAS)
132
133 /* Specify predefined symbols in preprocessor.  */
134 #undef CPP_PREDEFINES
135 #if TARGET_ENDIAN_DEFAULT == 0
136 #define CPP_PREDEFINES "-DMIPSEL -D_MIPSEL -Dunix -Dmips -D_mips \
137 -DR3000 -D_R3000 -D__gnu_linux__ -Dlinux -Asystem=posix -Acpu=mips \
138 -Amachine=mips -D__ELF__ -D__PIC__ -D__pic__"
139 #else
140 #define CPP_PREDEFINES "-DMIPSEB -D_MIPSEB -Dunix -Dmips -D_mips \
141 -DR3000 -D_R3000 -D__gnu_linux__ -Dlinux -Asystem=posix -Acpu=mips \
142 -Amachine=mips -D__ELF__ -D__PIC__ -D__pic__"
143 #endif
144
145 /* We must make -mips3 do what -mlong64 used to do.  */
146 /* ??? If no mipsX option given, but a mabi=X option is, then should set
147    _MIPS_ISA based on the mabi=X option.  */
148 /* ??? If no mabi=X option give, but a mipsX option is, then should set
149    _MIPS_SIM based on the mipsX option.  */
150 /* ??? Same for _MIPS_SZINT.  */
151 /* ??? Same for _MIPS_SZPTR.  */
152 #undef SUBTARGET_CPP_SPEC
153 #define SUBTARGET_CPP_SPEC "\
154 %{mfp32: -D_MIPS_FPSET=16} \
155 %{mfp64: -D_MIPS_FPSET=32} \
156 %{!mfp*: -D_MIPS_FPSET=32} \
157 %{mips1: -D_MIPS_ISA=_MIPS_ISA_MIPS1} \
158 %{mips2: -D_MIPS_ISA=_MIPS_ISA_MIPS2} \
159 %{mips3: -D_MIPS_ISA=_MIPS_ISA_MIPS3} \
160 %{mips4: -D_MIPS_ISA=_MIPS_ISA_MIPS4} \
161 %{!mips*: -D_MIPS_ISA=_MIPS_ISA_MIPS1} \
162 %{mabi=32: -D_MIPS_SIM=_MIPS_SIM_ABI32} \
163 %{mabi=n32: -D_ABIN32=2 -D_MIPS_SIM=_ABIN32} \
164 %{mabi=64: -D_ABI64=3 -D_MIPS_SIM=_ABI64} \
165 %{!mabi*: -D_MIPS_SIM=_MIPS_SIM_ABI32}  \
166 %{!mint64: -D_MIPS_SZINT=32}%{mint64: -D_MIPS_SZINT=64} \
167 %{mabi=32: -D_MIPS_SZLONG=32} \
168 %{mabi=n32: -D_MIPS_SZLONG=32} \
169 %{mabi=64: -D_MIPS_SZLONG=64} \
170 %{!mabi*: -D_MIPS_SZLONG=32} \
171 %{mabi=32: -D_MIPS_SZPTR=32} \
172 %{mabi=n32: -D_MIPS_SZPTR=32} \
173 %{mabi=64: -D_MIPS_SZPTR=64} \
174 %{!mabi*: -D_MIPS_SZPTR=32} \
175 %{!mips*: -U__mips -D__mips} \
176 %{mabi=32: -U__mips64} \
177 %{mabi=n32: -D__mips64} \
178 %{mabi=64: -U__mips64} \
179 %{!mabi*: -U__mips64} \
180 %{fno-PIC:-U__PIC__ -U__pic__} %{fno-pic:-U__PIC__ -U__pic__} \
181 %{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} \
182 %{pthread:-D_REENTRANT}"
183
184 /* The GNU C++ standard library requires that these macros be defined.  */
185 #undef CPLUSPLUS_CPP_SPEC
186 #define CPLUSPLUS_CPP_SPEC "\
187 -D__LANGUAGE_C_PLUS_PLUS -D_LANGUAGE_C_PLUS_PLUS \
188 -D_GNU_SOURCE %(cpp) \
189 "
190
191 /* From iris5.h */
192 /* -G is incompatible with -KPIC which is the default, so only allow objects
193    in the small data section if the user explicitly asks for it.  */
194 #undef MIPS_DEFAULT_GVALUE
195 #define MIPS_DEFAULT_GVALUE 0
196
197 /* Borrowed from sparc/linux.h */
198 #undef LINK_SPEC
199 #define LINK_SPEC \
200  "%(endian_spec) \
201   %{shared:-shared} \
202   %{!shared: \
203     %{!ibcs: \
204       %{!static: \
205         %{rdynamic:-export-dynamic} \
206         %{!dynamic-linker:-dynamic-linker /lib/ld.so.1}} \
207         %{static:-static}}}"
208
209
210 #undef SUBTARGET_ASM_SPEC
211 #define SUBTARGET_ASM_SPEC "\
212 %{mabi=64: -64} \
213 %{!fno-PIC:%{!fno-pic:-KPIC}} \
214 %{fno-PIC:-non_shared} %{fno-pic:-non_shared}"
215
216 #undef SUBTARGET_ASM_DEBUGGING_SPEC
217 #define SUBTARGET_ASM_DEBUGGING_SPEC "-g0"
218
219 /* The MIPS assembler has different syntax for .set. We set it to
220    .dummy to trap any errors.  */
221 #undef SET_ASM_OP
222 #define SET_ASM_OP "\t.dummy\t"
223
224 #undef ASM_OUTPUT_DEF
225 #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2)                              \
226  do {                                                                   \
227         fputc ( '\t', FILE);                                            \
228         assemble_name (FILE, LABEL1);                                   \
229         fputs ( " = ", FILE);                                           \
230         assemble_name (FILE, LABEL2);                                   \
231         fputc ( '\n', FILE);                                            \
232  } while (0)
233
234 #undef ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL
235 #define ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL(FILE, SY, HI, LO)     \
236   do {                                                                  \
237         fputc ('\t', FILE);                                             \
238         assemble_name (FILE, SY);                                       \
239         fputc ('=', FILE);                                              \
240         assemble_name (FILE, HI);                                       \
241         fputc ('-', FILE);                                              \
242         assemble_name (FILE, LO);                                       \
243   } while (0)
244
245 #undef ASM_DECLARE_FUNCTION_NAME
246 #define ASM_DECLARE_FUNCTION_NAME(STREAM, NAME, DECL)                   \
247   do {                                                                  \
248     if (!flag_inhibit_size_directive)                                   \
249       {                                                                 \
250         fputs ("\t.ent\t", STREAM);                                     \
251         assemble_name (STREAM, NAME);                                   \
252         putc ('\n', STREAM);                                            \
253       }                                                                 \
254     fprintf (STREAM, "\t%s\t ", TYPE_ASM_OP);                           \
255     assemble_name (STREAM, NAME);                                       \
256     putc (',', STREAM);                                                 \
257     fprintf (STREAM, TYPE_OPERAND_FMT, "function");                     \
258     putc ('\n', STREAM);                                                \
259     assemble_name (STREAM, NAME);                                       \
260     fputs (":\n", STREAM);                                              \
261   } while (0)
262
263 #undef ASM_DECLARE_FUNCTION_SIZE
264 #define ASM_DECLARE_FUNCTION_SIZE(STREAM, NAME, DECL)                   \
265   do {                                                                  \
266     if (!flag_inhibit_size_directive)                                   \
267       {                                                                 \
268         fputs ("\t.end\t", STREAM);                                     \
269         assemble_name (STREAM, NAME);                                   \
270         putc ('\n', STREAM);                                            \
271       }                                                                 \
272   } while (0)
273
274 /* Tell function_prologue in mips.c that we have already output the .ent/.end
275    pseudo-ops.  */
276 #define FUNCTION_NAME_ALREADY_DECLARED
277
278 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL)                      \
279   (flag_pic                                                             \
280     ? ((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel | DW_EH_PE_sdata4\
281    : DW_EH_PE_absptr)
282
283 /* The glibc _mcount stub will save $v0 for us.  Don't mess with saving
284    it, since ASM_OUTPUT_REG_PUSH/ASM_OUTPUT_REG_POP do not work in the
285    presence of $gp-relative calls.  */
286 #undef ASM_OUTPUT_REG_PUSH
287 #undef ASM_OUTPUT_REG_POP