Do not allow -mgp32 -mfp64; Fix int/long printf warning
[official-gcc.git] / gcc / config / mips / elf64.h
blobe07ce469af0f0576be715d15db108f2893842fb3
1 /* Definitions of target machine for GNU compiler. MIPS R4000 version with
2 GOFAST floating point library.
3 Copyright (C) 1994, 1995, 1996, 1997, 1999, 2000 Free Software Foundation, Inc.
5 This file is part of GNU CC.
7 GNU CC 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.
12 GNU CC 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.
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
22 #define OBJECT_FORMAT_ELF
24 /* Default to -mips3. */
25 #define TARGET_DEFAULT MASK_FLOAT64|MASK_64BIT
26 #define MIPS_ISA_DEFAULT 3
28 /* Until we figure out what MIPS ELF targets normally use, just do
29 stabs in ELF. */
30 #ifndef PREFERRED_DEBUGGING_TYPE
31 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
32 #endif
34 /* US Software GOFAST library support. */
35 #include "gofast.h"
36 #define INIT_SUBTARGET_OPTABS INIT_GOFAST_OPTABS
38 #include "mips/mips.h"
40 #undef CPP_PREDEFINES
41 #define CPP_PREDEFINES "-Dmips -DMIPSEB -DR4000 -D_mips -D_MIPSEB -D_R4000"
43 /* I would rather put this in CPP_PREDEFINES, but the gcc driver
44 doesn't handle -U options in CPP_PREDEFINES. */
45 #undef SUBTARGET_CPP_SPEC
46 #define SUBTARGET_CPP_SPEC "\
47 %{!mips1:%{!mips2:-U__mips -D__mips=3 -D__mips64}}"
49 /* Use memcpy, et. al., rather than bcopy. */
50 #define TARGET_MEM_FUNCTIONS
52 /* Biggest alignment supported by the object file format of this
53 machine. Use this macro to limit the alignment which can be
54 specified using the `__attribute__ ((aligned (N)))' construct. If
55 not defined, the default value is `BIGGEST_ALIGNMENT'. */
57 #undef MAX_OFILE_ALIGNMENT
58 #define MAX_OFILE_ALIGNMENT (32768*8)
60 /* We need to use .esize and .etype instead of .size and .type to
61 avoid conflicting with ELF directives. */
62 #undef PUT_SDB_SIZE
63 #define PUT_SDB_SIZE(a) \
64 do { \
65 extern FILE *asm_out_text_file; \
66 fprintf (asm_out_text_file, "\t.esize\t%d;", (a)); \
67 } while (0)
69 #undef PUT_SDB_TYPE
70 #define PUT_SDB_TYPE(a) \
71 do { \
72 extern FILE *asm_out_text_file; \
73 fprintf (asm_out_text_file, "\t.etype\t0x%x;", (a)); \
74 } while (0)
76 /* Switch into a generic section. */
77 #undef TARGET_ASM_NAMED_SECTION
78 #define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section
80 /* Given that Irix has it's own headers, not having TARGET_GAS here
81 seems a mistake. If we actually need to be prepared for file
82 switching, then we need a custom TARGET_ASM_NAMED_SECTION too. */
84 #undef TEXT_SECTION
85 #define TEXT_SECTION() \
86 do { \
87 if (TARGET_FILE_SWITCHING) \
88 abort (); \
89 fputs (TEXT_SECTION_ASM_OP, asm_out_file); \
90 fputc ('\n', asm_out_file); \
91 } while (0)
93 /* The following macro defines the format used to output the second
94 operand of the .type assembler directive. Different svr4 assemblers
95 expect various different forms for this operand. The one given here
96 is just a default. You may need to override it in your machine-
97 specific tm.h file (depending upon the particulars of your assembler). */
99 #define TYPE_OPERAND_FMT "@%s"
101 /* Define the strings used for the special svr4 .type and .size directives.
102 These strings generally do not vary from one system running svr4 to
103 another, but if a given system (e.g. m88k running svr) needs to use
104 different pseudo-op names for these, they may be overridden in the
105 file which includes this one. */
107 #undef TYPE_ASM_OP
108 #undef SIZE_ASM_OP
109 #define TYPE_ASM_OP "\t.type\t"
110 #define SIZE_ASM_OP "\t.size\t"
112 /* These macros generate the special .type and .size directives which
113 are used to set the corresponding fields of the linker symbol table
114 entries in an ELF object file under SVR4. These macros also output
115 the starting labels for the relevant functions/objects. */
117 /* Write the extra assembler code needed to declare an object properly. */
119 #undef ASM_DECLARE_OBJECT_NAME
120 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \
121 do { \
122 fprintf (FILE, "%s", TYPE_ASM_OP); \
123 assemble_name (FILE, NAME); \
124 putc (',', FILE); \
125 fprintf (FILE, TYPE_OPERAND_FMT, "object"); \
126 putc ('\n', FILE); \
127 size_directive_output = 0; \
128 if (!flag_inhibit_size_directive && DECL_SIZE (DECL)) \
130 size_directive_output = 1; \
131 fprintf (FILE, "%s", SIZE_ASM_OP); \
132 assemble_name (FILE, NAME); \
133 fprintf (FILE, ",%d\n", int_size_in_bytes (TREE_TYPE (DECL))); \
135 mips_declare_object (FILE, NAME, "", ":\n", 0); \
136 } while (0)
138 /* Output the size directive for a decl in rest_of_decl_compilation
139 in the case where we did not do so before the initializer.
140 Once we find the error_mark_node, we know that the value of
141 size_directive_output was set
142 by ASM_DECLARE_OBJECT_NAME when it was run for the same decl. */
144 #undef ASM_FINISH_DECLARE_OBJECT
145 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END) \
146 do { \
147 const char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \
148 if (!flag_inhibit_size_directive && DECL_SIZE (DECL) \
149 && ! AT_END && TOP_LEVEL \
150 && DECL_INITIAL (DECL) == error_mark_node \
151 && !size_directive_output) \
153 size_directive_output = 1; \
154 fprintf (FILE, "%s", SIZE_ASM_OP); \
155 assemble_name (FILE, name); \
156 fprintf (FILE, ","); \
157 fprintf (FILE, HOST_WIDE_INT_PRINT_DEC, \
158 int_size_in_bytes (TREE_TYPE (DECL))); \
159 fprintf (FILE, "\n"); \
161 } while (0)
163 #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2) \
164 do { fputc ( '\t', FILE); \
165 assemble_name (FILE, LABEL1); \
166 fputs ( " = ", FILE); \
167 assemble_name (FILE, LABEL2); \
168 fputc ( '\n', FILE); \
169 } while (0)
171 /* Note about .weak vs. .weakext
172 The mips native assemblers support .weakext, but not .weak.
173 mips-elf gas supports .weak, but not .weakext.
174 mips-elf gas has been changed to support both .weak and .weakext,
175 but until that support is generally available, the 'if' below
176 should serve. */
178 #undef ASM_WEAKEN_LABEL
179 #define ASM_WEAKEN_LABEL(FILE,NAME) ASM_OUTPUT_WEAK_ALIAS(FILE,NAME,0)
180 #define ASM_OUTPUT_WEAK_ALIAS(FILE,NAME,VALUE) \
181 do { \
182 if (TARGET_GAS) \
183 fputs ("\t.weak\t", FILE); \
184 else \
185 fputs ("\t.weakext\t", FILE); \
186 assemble_name (FILE, NAME); \
187 if (VALUE) \
189 fputc (' ', FILE); \
190 assemble_name (FILE, VALUE); \
192 fputc ('\n', FILE); \
193 } while (0)
195 #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
196 #undef UNIQUE_SECTION
197 #define UNIQUE_SECTION(DECL,RELOC) \
198 do { \
199 int len, size, sec; \
200 char *name, *string, *prefix; \
201 static char *prefixes[4][2] = { \
202 { ".text.", ".gnu.linkonce.t." }, \
203 { ".rodata.", ".gnu.linkonce.r." }, \
204 { ".data.", ".gnu.linkonce.d." }, \
205 { ".sdata.", ".gnu.linkonce.s." } \
206 }; \
208 name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL)); \
209 size = int_size_in_bytes (TREE_TYPE (decl)); \
211 /* Determine the base section we are interested in: \
212 0=text, 1=rodata, 2=data, 3=sdata, [4=bss]. */ \
213 if (TREE_CODE (DECL) == FUNCTION_DECL) \
214 sec = 0; \
215 else if (DECL_INITIAL (DECL) == 0 \
216 || DECL_INITIAL (DECL) == error_mark_node) \
217 sec = 2; \
218 else if ((TARGET_EMBEDDED_PIC || TARGET_MIPS16) \
219 && TREE_CODE (decl) == STRING_CST \
220 && !flag_writable_strings) \
222 /* For embedded position independent code, put constant strings \
223 in the text section, because the data section is limited to \
224 64K in size. For mips16 code, put strings in the text \
225 section so that a PC relative load instruction can be used to \
226 get their address. */ \
227 sec = 0; \
229 else if (TARGET_EMBEDDED_DATA) \
231 /* For embedded applications, always put an object in read-only data \
232 if possible, in order to reduce RAM usage. */ \
234 if (DECL_READONLY_SECTION (DECL, RELOC)) \
235 sec = 1; \
236 else if (size > 0 && size <= mips_section_threshold) \
237 sec = 3; \
238 else \
239 sec = 2; \
241 else \
243 /* For hosted applications, always put an object in small data if \
244 possible, as this gives the best performance. */ \
246 if (size > 0 && size <= mips_section_threshold) \
247 sec = 3; \
248 else if (DECL_READONLY_SECTION (DECL, RELOC)) \
249 sec = 1; \
250 else \
251 sec = 2; \
254 prefix = prefixes[sec][DECL_ONE_ONLY (DECL)]; \
255 len = strlen (name) + strlen (prefix); \
256 string = alloca (len + 1); \
257 sprintf (string, "%s%s", prefix, name); \
259 DECL_SECTION_NAME (DECL) = build_string (len, string); \
260 } while (0)
262 /* A list of other sections which the compiler might be "in" at any
263 given time. */
264 #undef EXTRA_SECTIONS
265 #define EXTRA_SECTIONS in_sdata, in_rdata
267 #undef EXTRA_SECTION_FUNCTIONS
268 #define EXTRA_SECTION_FUNCTIONS \
269 SECTION_FUNCTION_TEMPLATE(sdata_section, in_sdata, SDATA_SECTION_ASM_OP) \
270 SECTION_FUNCTION_TEMPLATE(rdata_section, in_rdata, RDATA_SECTION_ASM_OP)
272 #define SECTION_FUNCTION_TEMPLATE(FN, ENUM, OP) \
273 void FN () \
275 if (in_section != ENUM) \
277 fprintf (asm_out_file, "%s\n", OP); \
278 in_section = ENUM; \
282 /* On elf, we *do* have support for the .init and .fini sections, and we
283 can put stuff in there to be executed before and after `main'. We let
284 crtstuff.c and other files know this by defining the following symbols.
285 The definitions say how to change sections to the .init and .fini
286 sections. This is the same for all known elf assemblers. */
288 #undef INIT_SECTION_ASM_OP
289 #define INIT_SECTION_ASM_OP "\t.section\t.init"
290 #undef FINI_SECTION_ASM_OP
291 #define FINI_SECTION_ASM_OP "\t.section\t.fini"
293 /* Don't set the target flags, this is done by the linker script */
294 #undef LIB_SPEC
295 #define LIB_SPEC ""
297 #undef STARTFILE_SPEC
298 #define STARTFILE_SPEC "crti%O%s crtbegin%O%s %{!mno-crt0:crt0%O%s}"
300 #undef ENDFILE_SPEC
301 #define ENDFILE_SPEC "crtend%O%s crtn%O%s"