1 /* Definitions of target machine for GNU compiler. MIPS R3000 version with
2 GOFAST floating point library.
3 Copyright (C) 1994, 1997 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)
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. */
23 #define OBJECT_FORMAT_ELF
25 /* Until we figure out what MIPS ELF targets normally use, just do
27 #ifndef PREFERRED_DEBUGGING_TYPE
28 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
31 /* Mostly like ECOFF. */
33 #include "mips/ecoff.h"
35 /* We need to use .esize and .etype instead of .size and .type to
36 avoid conflicting with ELF directives. */
38 #define PUT_SDB_SIZE(a) \
40 extern FILE *asm_out_text_file; \
41 fprintf (asm_out_text_file, "\t.esize\t%d;", (a)); \
45 #define PUT_SDB_TYPE(a) \
47 extern FILE *asm_out_text_file; \
48 fprintf (asm_out_text_file, "\t.etype\t0x%x;", (a)); \
51 /* Biggest alignment supported by the object file format of this
52 machine. Use this macro to limit the alignment which can be
53 specified using the `__attribute__ ((aligned (N)))' construct. If
54 not defined, the default value is `BIGGEST_ALIGNMENT'. */
56 #define MAX_OFILE_ALIGNMENT (32768*8)
58 /* A C statement to output something to the assembler file to switch to section
59 NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or
60 NULL_TREE. Some target formats do not support arbitrary sections. Do not
61 define this macro in such cases. */
63 #define ASM_OUTPUT_SECTION_NAME(F, DECL, NAME, RELOC) \
65 extern FILE *asm_out_text_file; \
66 if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \
67 fprintf (asm_out_text_file, "\t.section %s,\"ax\",@progbits\n", (NAME)); \
68 else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC)) \
69 fprintf (F, "\t.section %s,\"a\",@progbits\n", (NAME)); \
71 fprintf (F, "\t.section %s,\"aw\",@progbits\n", (NAME)); \
74 /* The following macro defines the format used to output the second
75 operand of the .type assembler directive. Different svr4 assemblers
76 expect various different forms for this operand. The one given here
77 is just a default. You may need to override it in your machine-
78 specific tm.h file (depending upon the particulars of your assembler). */
80 #define TYPE_OPERAND_FMT "@%s"
82 /* Define the strings used for the special svr4 .type and .size directives.
83 These strings generally do not vary from one system running svr4 to
84 another, but if a given system (e.g. m88k running svr) needs to use
85 different pseudo-op names for these, they may be overridden in the
86 file which includes this one. */
90 #define TYPE_ASM_OP ".type"
91 #define SIZE_ASM_OP ".size"
93 /* These macros generate the special .type and .size directives which
94 are used to set the corresponding fields of the linker symbol table
95 entries in an ELF object file under SVR4. These macros also output
96 the starting labels for the relevant functions/objects. */
98 /* Write the extra assembler code needed to declare an object properly. */
100 #undef ASM_DECLARE_OBJECT_NAME
101 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \
103 fprintf (FILE, "\t%s\t ", TYPE_ASM_OP); \
104 assemble_name (FILE, NAME); \
106 fprintf (FILE, TYPE_OPERAND_FMT, "object"); \
108 size_directive_output = 0; \
109 if (!flag_inhibit_size_directive && DECL_SIZE (DECL)) \
111 size_directive_output = 1; \
112 fprintf (FILE, "\t%s\t ", SIZE_ASM_OP); \
113 assemble_name (FILE, NAME); \
114 fprintf (FILE, ",%d\n", int_size_in_bytes (TREE_TYPE (DECL))); \
116 mips_declare_object (FILE, NAME, "", ":\n", 0); \
119 /* Output the size directive for a decl in rest_of_decl_compilation
120 in the case where we did not do so before the initializer.
121 Once we find the error_mark_node, we know that the value of
122 size_directive_output was set
123 by ASM_DECLARE_OBJECT_NAME when it was run for the same decl. */
125 #undef ASM_FINISH_DECLARE_OBJECT
126 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END) \
128 char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \
129 if (!flag_inhibit_size_directive && DECL_SIZE (DECL) \
130 && ! AT_END && TOP_LEVEL \
131 && DECL_INITIAL (DECL) == error_mark_node \
132 && !size_directive_output) \
134 size_directive_output = 1; \
135 fprintf (FILE, "\t%s\t ", SIZE_ASM_OP); \
136 assemble_name (FILE, name); \
137 fprintf (FILE, ",%d\n", int_size_in_bytes (TREE_TYPE (DECL))); \
141 #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2) \
142 do { fputc ( '\t', FILE); \
143 assemble_name (FILE, LABEL1); \
144 fputs ( " = ", FILE); \
145 assemble_name (FILE, LABEL2); \
146 fputc ( '\n', FILE); \
149 /* Note about .weak vs. .weakext
150 The mips native assemblers support .weakext, but not .weak.
151 mips-elf gas supports .weak, but not .weakext.
152 mips-elf gas has been changed to support both .weak and .weakext,
153 but until that support is generally available, the 'if' below
156 #define ASM_WEAKEN_LABEL(FILE,NAME) ASM_OUTPUT_WEAK_ALIAS(FILE,NAME,0)
157 #define ASM_OUTPUT_WEAK_ALIAS(FILE,NAME,VALUE) \
160 fputs ("\t.weak\t", FILE); \
162 fputs ("\t.weakext\t", FILE); \
163 assemble_name (FILE, NAME); \
167 assemble_name (FILE, VALUE); \
169 fputc ('\n', FILE); \
172 #define UNIQUE_SECTION(DECL,RELOC) \
174 int len, size, sec; \
175 char *name, *string, *prefix; \
176 static char *prefixes[4][2] = { \
177 { ".text.", ".gnu.linkonce.t." }, \
178 { ".rodata.", ".gnu.linkonce.r." }, \
179 { ".data.", ".gnu.linkonce.d." }, \
180 { ".sdata.", ".gnu.linkonce.s." } \
183 name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL)); \
184 size = int_size_in_bytes (TREE_TYPE (decl)); \
186 /* Determine the base section we are interested in: \
187 0=text, 1=rodata, 2=data, 3=sdata. */ \
188 if (TREE_CODE (DECL) == FUNCTION_DECL) \
190 else if ((TARGET_EMBEDDED_PIC || TARGET_MIPS16) \
191 && TREE_CODE (decl) == STRING_CST \
192 && !flag_writable_strings) \
194 /* For embedded position independent code, put constant strings \
195 in the text section, because the data section is limited to \
196 64K in size. For mips16 code, put strings in the text \
197 section so that a PC relative load instruction can be used to \
198 get their address. */ \
201 else if (TARGET_EMBEDDED_DATA) \
203 /* For embedded applications, always put an object in read-only data \
204 if possible, in order to reduce RAM usage. */ \
206 if (DECL_READONLY_SECTION (DECL, RELOC)) \
208 else if (size > 0 && size <= mips_section_threshold) \
215 /* For hosted applications, always put an object in small data if \
216 possible, as this gives the best performance. */ \
218 if (size > 0 && size <= mips_section_threshold) \
220 else if (DECL_READONLY_SECTION (DECL, RELOC)) \
226 prefix = prefixes[sec][DECL_ONE_ONLY (DECL)]; \
227 len = strlen (name) + strlen (prefix); \
228 string = alloca (len + 1); \
229 sprintf (string, "%s%s", prefix, name); \
231 DECL_SECTION_NAME (DECL) = build_string (len, string); \