]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/config/ia64/sysv4.h
target.h (gcc_target): Add asm_out.named_section, section_type_flags, have_named_sect...
[thirdparty/gcc.git] / gcc / config / ia64 / sysv4.h
1 /* Override definitions in elfos.h/svr4.h to be correct for IA64. */
2
3 /* We want DWARF2 as specified by the IA64 ABI. */
4 #undef PREFERRED_DEBUGGING_TYPE
5 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
6
7 /* Various pseudo-ops for which the Intel assembler uses non-standard
8 definitions. */
9
10 #undef ASM_BYTE_OP
11 #define ASM_BYTE_OP "\tdata1\t"
12
13 #undef STRING_ASM_OP
14 #define STRING_ASM_OP "\tstringz\t"
15
16 #undef SKIP_ASM_OP
17 #define SKIP_ASM_OP "\t.skip\t"
18
19 #undef COMMON_ASM_OP
20 #define COMMON_ASM_OP "\t.common\t"
21
22 #undef ASCII_DATA_ASM_OP
23 #define ASCII_DATA_ASM_OP "\tstring\t"
24
25 /* ??? Unfortunately, .lcomm doesn't work, because it puts things in either
26 .bss or .sbss, and we can't control the decision of which is used. When
27 I use .lcomm, I get a cryptic "Section group has no member" error from
28 the Intel simulator. So we must explicitly put variables in .bss
29 instead. This matters only if we care about the Intel assembler. */
30
31 /* This is asm_output_aligned_bss from varasm.c without the ASM_GLOBALIZE_LABEL
32 call at the beginning. */
33
34 /* This is for final.c, because it is used by ASM_DECLARE_OBJECT_NAME. */
35 extern int size_directive_output;
36
37 #undef ASM_OUTPUT_ALIGNED_LOCAL
38 #define ASM_OUTPUT_ALIGNED_DECL_LOCAL(FILE, DECL, NAME, SIZE, ALIGN) \
39 do { \
40 if ((DECL) \
41 && XSTR (XEXP (DECL_RTL (DECL), 0), 0)[0] == SDATA_NAME_FLAG_CHAR) \
42 sbss_section (); \
43 else \
44 bss_section (); \
45 ASM_OUTPUT_ALIGN (FILE, floor_log2 ((ALIGN) / BITS_PER_UNIT)); \
46 ASM_DECLARE_OBJECT_NAME (FILE, NAME, DECL); \
47 ASM_OUTPUT_SKIP (FILE, SIZE ? SIZE : 1); \
48 } while (0)
49
50 /* The # tells the Intel assembler that this is not a register name.
51 However, we can't emit the # in a label definition, so we set a variable
52 in ASM_OUTPUT_LABEL to control whether we want the postfix here or not.
53 We append the # to the label name, but since NAME can be an expression
54 we have to scan it for a non-label character and insert the # there. */
55
56 #undef ASM_OUTPUT_LABELREF
57 #define ASM_OUTPUT_LABELREF(STREAM, NAME) \
58 do \
59 { \
60 const char *real_name; \
61 const char *name_end; \
62 \
63 STRIP_NAME_ENCODING (real_name, NAME); \
64 name_end = strchr (real_name, '+'); \
65 \
66 fputs (user_label_prefix, STREAM); \
67 if (name_end) \
68 fwrite (real_name, name_end - real_name, 1, STREAM); \
69 else \
70 fputs (real_name, STREAM); \
71 \
72 if (ia64_asm_output_label) \
73 fputc ('#', STREAM); \
74 \
75 if (name_end) \
76 fputs (name_end, STREAM); \
77 } \
78 while (0)
79
80 /* Intel assembler requires both flags and type if declaring a non-predefined
81 section. */
82 #undef INIT_SECTION_ASM_OP
83 #define INIT_SECTION_ASM_OP "\t.section\t.init,\"ax\",\"progbits\""
84 #undef FINI_SECTION_ASM_OP
85 #define FINI_SECTION_ASM_OP "\t.section\t.fini,\"ax\",\"progbits\""
86 #undef CTORS_SECTION_ASM_OP
87 #define CTORS_SECTION_ASM_OP "\t.section\t.ctors,\"aw\",\"progbits\""
88 #undef DTORS_SECTION_ASM_OP
89 #define DTORS_SECTION_ASM_OP "\t.section\t.dtors,\"aw\",\"progbits\""
90
91 /* A C statement (sans semicolon) to output an element in the table of
92 global constructors. */
93 /* Must override this to get @fptr relocation. */
94 #undef ASM_OUTPUT_CONSTRUCTOR
95 #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
96 do { \
97 ctors_section (); \
98 if (TARGET_NO_PIC || TARGET_AUTO_PIC) \
99 fputs ("\tdata8\t ", FILE); \
100 else \
101 fputs ("\tdata8\t @fptr(", FILE); \
102 assemble_name (FILE, NAME); \
103 if (TARGET_NO_PIC || TARGET_AUTO_PIC) \
104 fputs ("\n", FILE); \
105 else \
106 fputs (")\n", FILE); \
107 } while (0)
108
109 /* A C statement (sans semicolon) to output an element in the table of
110 global destructors. */
111 /* Must override this to get @fptr relocation. */
112 #undef ASM_OUTPUT_DESTRUCTOR
113 #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
114 do { \
115 dtors_section (); \
116 if (TARGET_NO_PIC || TARGET_AUTO_PIC) \
117 fputs ("\tdata8\t ", FILE); \
118 else \
119 fputs ("\tdata8\t @fptr(", FILE); \
120 assemble_name (FILE, NAME); \
121 if (TARGET_NO_PIC || TARGET_AUTO_PIC) \
122 fputs ("\n", FILE); \
123 else \
124 fputs (")\n", FILE); \
125 } while (0)
126
127 /* svr4.h undefines this, so we need to define it here. */
128 #define DBX_REGISTER_NUMBER(REGNO) \
129 ia64_dbx_register_number(REGNO)
130
131 /* Things that svr4.h defines to the wrong type, because it assumes 32 bit
132 ints and 32 bit longs. */
133
134 #undef SIZE_TYPE
135 #define SIZE_TYPE "long unsigned int"
136
137 #undef PTRDIFF_TYPE
138 #define PTRDIFF_TYPE "long int"
139
140 #undef WCHAR_TYPE
141 #define WCHAR_TYPE "int"
142
143 #undef WCHAR_TYPE_SIZE
144 #define WCHAR_TYPE_SIZE 32
145
146 /* We redefine this to use the ia64 .proc pseudo-op. */
147
148 #undef ASM_DECLARE_FUNCTION_NAME
149 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
150 do { \
151 fputs ("\t.proc ", FILE); \
152 assemble_name (FILE, NAME); \
153 fputc ('\n', FILE); \
154 ASM_OUTPUT_LABEL (FILE, NAME); \
155 } while (0)
156
157 /* We redefine this to use the ia64 .endp pseudo-op. */
158
159 #undef ASM_DECLARE_FUNCTION_SIZE
160 #define ASM_DECLARE_FUNCTION_SIZE(FILE, NAME, DECL) \
161 do { \
162 fputs ("\t.endp ", FILE); \
163 assemble_name (FILE, NAME); \
164 fputc ('\n', FILE); \
165 } while (0)
166
167 /* A C expression which outputs to the stdio stream STREAM some appropriate
168 text to go at the start of an assembler file. */
169
170 /* ??? Looks like almost every port, except for a few original ones, get this
171 wrong. Must emit #NO_APP as first line of file to turn of special assembler
172 preprocessing of files. */
173
174 /* ??? Even worse, it doesn't work, because gas does not accept the tab chars
175 that dwarf2out.c emits when #NO_APP. */
176
177 /* ??? Unrelated, but dwarf2out.c emits unnecessary newlines after strings,
178 may as well fix at the same time. */
179
180 #undef ASM_FILE_START
181 #define ASM_FILE_START(STREAM) \
182 do { \
183 output_file_directive (STREAM, main_input_filename); \
184 emit_safe_across_calls (STREAM); \
185 } while (0)
186
187 /* Case label alignment is handled by ADDR_VEC_ALIGN now. */
188
189 #undef ASM_OUTPUT_BEFORE_CASE_LABEL
190 #define ASM_OUTPUT_BEFORE_CASE_LABEL(FILE,PREFIX,NUM,TABLE)
191
192 /* We override svr4.h so that we can support the sdata section. */
193
194 #undef SELECT_SECTION
195 #define SELECT_SECTION(DECL,RELOC) \
196 { \
197 if (TREE_CODE (DECL) == STRING_CST) \
198 { \
199 if (! flag_writable_strings) \
200 const_section (); \
201 else \
202 data_section (); \
203 } \
204 else if (TREE_CODE (DECL) == VAR_DECL) \
205 { \
206 if (XSTR (XEXP (DECL_RTL (DECL), 0), 0)[0] \
207 == SDATA_NAME_FLAG_CHAR) \
208 sdata_section (); \
209 /* ??? We need the extra ! RELOC check, because the default is to \
210 only check RELOC if flag_pic is set, and we don't set flag_pic \
211 (yet?). */ \
212 else if (DECL_READONLY_SECTION (DECL, RELOC) && ! (RELOC)) \
213 const_section (); \
214 else \
215 data_section (); \
216 } \
217 /* This could be a CONSTRUCTOR containing ADDR_EXPR of a VAR_DECL, \
218 in which case we can't put it in a shared library rodata. */ \
219 else if (flag_pic && (RELOC)) \
220 data_section (); \
221 else \
222 const_section (); \
223 }
224
225 /* Similarly for constant pool data. */
226
227 extern unsigned int ia64_section_threshold;
228 #undef SELECT_RTX_SECTION
229 #define SELECT_RTX_SECTION(MODE, RTX) \
230 { \
231 if (GET_MODE_SIZE (MODE) > 0 \
232 && GET_MODE_SIZE (MODE) <= ia64_section_threshold) \
233 sdata_section (); \
234 else if (flag_pic && symbolic_operand ((RTX), (MODE))) \
235 data_section (); \
236 else \
237 const_section (); \
238 }
239
240 #undef EXTRA_SECTIONS
241 #define EXTRA_SECTIONS in_const, in_ctors, in_dtors, in_sdata, in_sbss
242
243 #undef EXTRA_SECTION_FUNCTIONS
244 #define EXTRA_SECTION_FUNCTIONS \
245 CONST_SECTION_FUNCTION \
246 CTORS_SECTION_FUNCTION \
247 DTORS_SECTION_FUNCTION \
248 SDATA_SECTION_FUNCTION \
249 SBSS_SECTION_FUNCTION
250
251 #define SDATA_SECTION_ASM_OP "\t.sdata"
252
253 #define SDATA_SECTION_FUNCTION \
254 void \
255 sdata_section () \
256 { \
257 if (in_section != in_sdata) \
258 { \
259 fprintf (asm_out_file, "%s\n", SDATA_SECTION_ASM_OP); \
260 in_section = in_sdata; \
261 } \
262 }
263
264 #define SBSS_SECTION_ASM_OP "\t.sbss"
265
266 #define SBSS_SECTION_FUNCTION \
267 void \
268 sbss_section () \
269 { \
270 if (in_section != in_sbss) \
271 { \
272 fprintf (asm_out_file, "%s\n", SBSS_SECTION_ASM_OP); \
273 in_section = in_sbss; \
274 } \
275 }