]>
Commit | Line | Data |
---|---|---|
79e68feb | 1 | /* Output variables, constants and external declarations, for GNU compiler. |
06ceef4e RK |
2 | Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, |
3 | 1998, 1999, 2000 Free Software Foundation, Inc. | |
79e68feb RS |
4 | |
5 | This file is part of GNU CC. | |
6 | ||
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. | |
11 | ||
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. | |
16 | ||
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 | |
e9fa0c7c RK |
19 | the Free Software Foundation, 59 Temple Place - Suite 330, |
20 | Boston, MA 02111-1307, USA. */ | |
79e68feb RS |
21 | |
22 | ||
23 | /* This file handles generation of all the assembler code | |
24 | *except* the instructions of a function. | |
25 | This includes declarations of variables and their initial values. | |
26 | ||
27 | We also output the assembler code for constants stored in memory | |
28 | and are responsible for combining constants with the same value. */ | |
29 | ||
e9a25f70 | 30 | #include "config.h" |
670ee920 | 31 | #include "system.h" |
79e68feb | 32 | #include <setjmp.h> |
79e68feb RS |
33 | #include "rtl.h" |
34 | #include "tree.h" | |
35 | #include "flags.h" | |
57632c51 | 36 | #include "function.h" |
79e68feb RS |
37 | #include "expr.h" |
38 | #include "hard-reg-set.h" | |
39 | #include "regs.h" | |
9a631e8e | 40 | #include "defaults.h" |
fbd40359 | 41 | #include "output.h" |
24b09b50 | 42 | #include "real.h" |
10f0ad3d | 43 | #include "toplev.h" |
50b2596f | 44 | #include "dbxout.h" |
e016950d | 45 | #include "sdbout.h" |
79e68feb | 46 | #include "obstack.h" |
bd7cf17e | 47 | #include "hashtab.h" |
3d6f7931 | 48 | #include "c-pragma.h" |
87ff9c8e | 49 | #include "ggc.h" |
aa388f29 | 50 | #include "tm_p.h" |
79e68feb | 51 | |
b4ac57ab | 52 | #ifdef XCOFF_DEBUGGING_INFO |
f246a305 | 53 | #include "xcoffout.h" |
b4ac57ab RS |
54 | #endif |
55 | ||
073b0524 RK |
56 | #ifndef TRAMPOLINE_ALIGNMENT |
57 | #define TRAMPOLINE_ALIGNMENT FUNCTION_BOUNDARY | |
58 | #endif | |
59 | ||
79e68feb | 60 | #ifndef ASM_STABS_OP |
0a3e1f45 | 61 | #define ASM_STABS_OP "\t.stabs\t" |
79e68feb RS |
62 | #endif |
63 | ||
7c6d4120 RK |
64 | /* Define the prefix to use when check_memory_usage_flag is enable. */ |
65 | #ifdef NO_DOLLAR_IN_LABEL | |
66 | #ifdef NO_DOT_IN_LABEL | |
67 | #define CHKR_PREFIX "chkr_prefix_" | |
68 | #else /* !NO_DOT_IN_LABEL */ | |
69 | #define CHKR_PREFIX "chkr." | |
70 | #endif | |
956d6950 | 71 | #else /* !NO_DOLLAR_IN_LABEL */ |
7c6d4120 RK |
72 | #define CHKR_PREFIX "chkr$" |
73 | #endif | |
74 | #define CHKR_PREFIX_SIZE (sizeof (CHKR_PREFIX) - 1) | |
75 | ||
79e68feb RS |
76 | /* File in which assembler code is being written. */ |
77 | ||
78 | extern FILE *asm_out_file; | |
79 | ||
80 | /* The (assembler) name of the first globally-visible object output. */ | |
3b304f5b ZW |
81 | const char *first_global_object_name; |
82 | const char *weak_global_object_name; | |
79e68feb | 83 | |
79e68feb RS |
84 | extern struct obstack permanent_obstack; |
85 | #define obstack_chunk_alloc xmalloc | |
79e68feb | 86 | |
36edd3cc BS |
87 | struct addr_const; |
88 | struct constant_descriptor; | |
89 | struct rtx_const; | |
90 | struct pool_constant; | |
91 | ||
92 | #define MAX_RTX_HASH_TABLE 61 | |
93 | ||
94 | struct varasm_status | |
95 | { | |
96 | /* Hash facility for making memory-constants | |
97 | from constant rtl-expressions. It is used on RISC machines | |
98 | where immediate integer arguments and constant addresses are restricted | |
99 | so that such constants must be stored in memory. | |
100 | ||
101 | This pool of constants is reinitialized for each function | |
102 | so each function gets its own constants-pool that comes right before | |
103 | it. */ | |
104 | struct constant_descriptor **x_const_rtx_hash_table; | |
94b01be3 | 105 | struct pool_constant **x_const_rtx_sym_hash_table; |
36edd3cc BS |
106 | |
107 | /* Pointers to first and last constant in pool. */ | |
108 | struct pool_constant *x_first_pool, *x_last_pool; | |
109 | ||
110 | /* Current offset in constant pool (does not include any machine-specific | |
111 | header. */ | |
112 | int x_pool_offset; | |
113 | ||
114 | /* Chain of all CONST_DOUBLE rtx's constructed for the current function. | |
115 | They are chained through the CONST_DOUBLE_CHAIN. | |
116 | A CONST_DOUBLE rtx has CONST_DOUBLE_MEM != cc0_rtx iff it is on this chain. | |
117 | In that case, CONST_DOUBLE_MEM is either a MEM, | |
118 | or const0_rtx if no MEM has been made for this CONST_DOUBLE yet. */ | |
119 | rtx x_const_double_chain; | |
120 | }; | |
121 | ||
01d939e8 BS |
122 | #define const_rtx_hash_table (cfun->varasm->x_const_rtx_hash_table) |
123 | #define const_rtx_sym_hash_table (cfun->varasm->x_const_rtx_sym_hash_table) | |
124 | #define first_pool (cfun->varasm->x_first_pool) | |
125 | #define last_pool (cfun->varasm->x_last_pool) | |
126 | #define pool_offset (cfun->varasm->x_pool_offset) | |
127 | #define const_double_chain (cfun->varasm->x_const_double_chain) | |
36edd3cc | 128 | |
79e68feb RS |
129 | /* Number for making the label on the next |
130 | constant that is stored in memory. */ | |
131 | ||
132 | int const_labelno; | |
133 | ||
134 | /* Number for making the label on the next | |
135 | static variable internal to a function. */ | |
136 | ||
137 | int var_labelno; | |
138 | ||
dcc8e5e6 RS |
139 | /* Carry information from ASM_DECLARE_OBJECT_NAME |
140 | to ASM_FINISH_DECLARE_OBJECT. */ | |
141 | ||
142 | int size_directive_output; | |
143 | ||
cbed4565 RS |
144 | /* The last decl for which assemble_variable was called, |
145 | if it did ASM_DECLARE_OBJECT_NAME. | |
146 | If the last call to assemble_variable didn't do that, | |
147 | this holds 0. */ | |
148 | ||
149 | tree last_assemble_variable_decl; | |
150 | ||
58782098 KG |
151 | static const char *strip_reg_name PARAMS ((const char *)); |
152 | static int contains_pointers_p PARAMS ((tree)); | |
153 | static void decode_addr_const PARAMS ((tree, struct addr_const *)); | |
154 | static int const_hash PARAMS ((tree)); | |
155 | static int compare_constant PARAMS ((tree, | |
5a13eaa4 | 156 | struct constant_descriptor *)); |
990e8954 | 157 | static const unsigned char *compare_constant_1 PARAMS ((tree, const unsigned char *)); |
58782098 KG |
158 | static struct constant_descriptor *record_constant PARAMS ((tree)); |
159 | static void record_constant_1 PARAMS ((tree)); | |
160 | static tree copy_constant PARAMS ((tree)); | |
161 | static void output_constant_def_contents PARAMS ((tree, int, int)); | |
162 | static void decode_rtx_const PARAMS ((enum machine_mode, rtx, | |
5a13eaa4 | 163 | struct rtx_const *)); |
58782098 KG |
164 | static int const_hash_rtx PARAMS ((enum machine_mode, rtx)); |
165 | static int compare_constant_rtx PARAMS ((enum machine_mode, rtx, | |
5a13eaa4 | 166 | struct constant_descriptor *)); |
58782098 | 167 | static struct constant_descriptor *record_constant_rtx PARAMS ((enum machine_mode, |
5a13eaa4 | 168 | rtx)); |
58782098 KG |
169 | static struct pool_constant *find_pool_constant PARAMS ((struct function *, rtx)); |
170 | static void mark_constant_pool PARAMS ((void)); | |
171 | static void mark_constants PARAMS ((rtx)); | |
172 | static int output_addressed_constants PARAMS ((tree)); | |
173 | static void output_after_function_constants PARAMS ((void)); | |
a25f1211 | 174 | static int array_size_for_constructor PARAMS ((tree)); |
58782098 | 175 | static void output_constructor PARAMS ((tree, int)); |
341a243e | 176 | #ifdef ASM_WEAKEN_LABEL |
63ad61ed | 177 | static void remove_from_pending_weak_list PARAMS ((const char *)); |
341a243e | 178 | #endif |
0e05e8ea | 179 | #ifdef ASM_OUTPUT_BSS |
3cce094d | 180 | static void asm_output_bss PARAMS ((FILE *, tree, const char *, int, int)); |
0e05e8ea | 181 | #endif |
cab634f2 | 182 | #ifdef BSS_SECTION_ASM_OP |
0e05e8ea | 183 | #ifdef ASM_OUTPUT_ALIGNED_BSS |
3cce094d KG |
184 | static void asm_output_aligned_bss PARAMS ((FILE *, tree, const char *, |
185 | int, int)); | |
0e05e8ea | 186 | #endif |
cab634f2 | 187 | #endif /* BSS_SECTION_ASM_OP */ |
58782098 | 188 | static void mark_pool_constant PARAMS ((struct pool_constant *)); |
58782098 | 189 | static void mark_const_hash_entry PARAMS ((void *)); |
bd7cf17e JJ |
190 | static int mark_const_str_htab_1 PARAMS ((void **, void *)); |
191 | static void mark_const_str_htab PARAMS ((void *)); | |
192 | static hashval_t const_str_htab_hash PARAMS ((const void *x)); | |
193 | static int const_str_htab_eq PARAMS ((const void *x, const void *y)); | |
194 | static void const_str_htab_del PARAMS ((void *)); | |
3cce094d | 195 | static void asm_emit_uninitialised PARAMS ((tree, const char*, int, int)); |
79e68feb | 196 | \f |
e5887033 DE |
197 | static enum in_section { no_section, in_text, in_data, in_named |
198 | #ifdef BSS_SECTION_ASM_OP | |
199 | , in_bss | |
200 | #endif | |
0021b564 JM |
201 | #ifdef EH_FRAME_SECTION_ASM_OP |
202 | , in_eh_frame | |
203 | #endif | |
79e68feb | 204 | #ifdef EXTRA_SECTIONS |
e5887033 | 205 | , EXTRA_SECTIONS |
79e68feb | 206 | #endif |
e5887033 | 207 | } in_section = no_section; |
79e68feb | 208 | |
8a425a05 | 209 | /* Return a non-zero value if DECL has a section attribute. */ |
a56e7c08 | 210 | #ifndef IN_NAMED_SECTION |
8a425a05 DE |
211 | #define IN_NAMED_SECTION(DECL) \ |
212 | ((TREE_CODE (DECL) == FUNCTION_DECL || TREE_CODE (DECL) == VAR_DECL) \ | |
213 | && DECL_SECTION_NAME (DECL) != NULL_TREE) | |
a56e7c08 NC |
214 | #endif |
215 | ||
8a425a05 | 216 | /* Text of section name when in_section == in_named. */ |
520a57c8 | 217 | static const char *in_named_name; |
8a425a05 | 218 | |
79e68feb RS |
219 | /* Define functions like text_section for any extra sections. */ |
220 | #ifdef EXTRA_SECTION_FUNCTIONS | |
221 | EXTRA_SECTION_FUNCTIONS | |
222 | #endif | |
223 | ||
224 | /* Tell assembler to switch to text section. */ | |
225 | ||
226 | void | |
227 | text_section () | |
228 | { | |
229 | if (in_section != in_text) | |
230 | { | |
b93a436e | 231 | fprintf (asm_out_file, "%s\n", TEXT_SECTION_ASM_OP); |
79e68feb RS |
232 | in_section = in_text; |
233 | } | |
234 | } | |
235 | ||
79e68feb RS |
236 | /* Tell assembler to switch to data section. */ |
237 | ||
238 | void | |
239 | data_section () | |
240 | { | |
241 | if (in_section != in_data) | |
242 | { | |
b93a436e | 243 | if (flag_shared_data) |
79e68feb RS |
244 | { |
245 | #ifdef SHARED_SECTION_ASM_OP | |
b93a436e | 246 | fprintf (asm_out_file, "%s\n", SHARED_SECTION_ASM_OP); |
79e68feb | 247 | #else |
b93a436e | 248 | fprintf (asm_out_file, "%s\n", DATA_SECTION_ASM_OP); |
79e68feb RS |
249 | #endif |
250 | } | |
b93a436e JL |
251 | else |
252 | fprintf (asm_out_file, "%s\n", DATA_SECTION_ASM_OP); | |
79e68feb RS |
253 | |
254 | in_section = in_data; | |
255 | } | |
256 | } | |
3167de5b AM |
257 | /* Tell assembler to ALWAYS switch to data section, in case |
258 | it's not sure where it it. */ | |
259 | ||
260 | void | |
261 | force_data_section () | |
262 | { | |
263 | in_section = no_section; | |
264 | data_section (); | |
265 | } | |
79e68feb | 266 | |
7c6d68c8 RS |
267 | /* Tell assembler to switch to read-only data section. This is normally |
268 | the text section. */ | |
269 | ||
270 | void | |
271 | readonly_data_section () | |
272 | { | |
273 | #ifdef READONLY_DATA_SECTION | |
274 | READONLY_DATA_SECTION (); /* Note this can call data_section. */ | |
275 | #else | |
276 | text_section (); | |
277 | #endif | |
278 | } | |
279 | ||
0f41302f | 280 | /* Determine if we're in the text section. */ |
79e68feb RS |
281 | |
282 | int | |
283 | in_text_section () | |
284 | { | |
285 | return in_section == in_text; | |
286 | } | |
8a425a05 | 287 | |
0f41302f | 288 | /* Determine if we're in the data section. */ |
6f2f3db7 | 289 | |
274351ba RK |
290 | int |
291 | in_data_section () | |
292 | { | |
293 | return in_section == in_data; | |
294 | } | |
6f2f3db7 | 295 | |
2ffe831c DE |
296 | /* Tell assembler to change to section NAME for DECL. |
297 | If DECL is NULL, just switch to section NAME. | |
ad4ff310 JM |
298 | If NAME is NULL, get the name from DECL. |
299 | If RELOC is 1, the initializer for DECL contains relocs. */ | |
8a425a05 DE |
300 | |
301 | void | |
ad4ff310 | 302 | named_section (decl, name, reloc) |
2ffe831c | 303 | tree decl; |
87e11268 | 304 | const char *name; |
91813b28 | 305 | int reloc ATTRIBUTE_UNUSED; |
8a425a05 | 306 | { |
2f939d94 | 307 | if (decl != NULL_TREE && !DECL_P (decl)) |
2ffe831c DE |
308 | abort (); |
309 | if (name == NULL) | |
310 | name = TREE_STRING_POINTER (DECL_SECTION_NAME (decl)); | |
311 | ||
8a425a05 DE |
312 | if (in_section != in_named || strcmp (name, in_named_name)) |
313 | { | |
8a425a05 | 314 | #ifdef ASM_OUTPUT_SECTION_NAME |
ad4ff310 | 315 | ASM_OUTPUT_SECTION_NAME (asm_out_file, decl, name, reloc); |
8a425a05 DE |
316 | #else |
317 | /* Section attributes are not supported if this macro isn't provided - | |
318 | some host formats don't support them at all. The front-end should | |
319 | already have flagged this as an error. */ | |
320 | abort (); | |
321 | #endif | |
e9a25f70 | 322 | |
a8a05998 | 323 | in_named_name = ggc_strdup (name); |
e9a25f70 | 324 | in_section = in_named; |
8a425a05 DE |
325 | } |
326 | } | |
4d1065ed | 327 | |
ad4ff310 JM |
328 | #ifdef ASM_OUTPUT_SECTION_NAME |
329 | #ifndef UNIQUE_SECTION | |
330 | #define UNIQUE_SECTION(DECL,RELOC) \ | |
331 | do { \ | |
332 | int len; \ | |
ec940faa KG |
333 | const char *name; \ |
334 | char *string; \ | |
ad4ff310 JM |
335 | \ |
336 | name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL)); \ | |
337 | /* Strip off any encoding in name. */ \ | |
338 | STRIP_NAME_ENCODING (name, name); \ | |
339 | \ | |
340 | len = strlen (name) + 1; \ | |
341 | string = alloca (len + 1); \ | |
342 | sprintf (string, ".%s", name); \ | |
343 | \ | |
344 | DECL_SECTION_NAME (DECL) = build_string (len, string); \ | |
345 | } while (0) | |
346 | #endif | |
347 | #ifndef UNIQUE_SECTION_P | |
348 | #define UNIQUE_SECTION_P(DECL) 0 | |
349 | #endif | |
350 | #endif | |
351 | ||
e5887033 DE |
352 | #ifdef BSS_SECTION_ASM_OP |
353 | ||
354 | /* Tell the assembler to switch to the bss section. */ | |
355 | ||
356 | void | |
da2c5447 | 357 | bss_section () |
e5887033 DE |
358 | { |
359 | if (in_section != in_bss) | |
360 | { | |
e5887033 | 361 | #ifdef SHARED_BSS_SECTION_ASM_OP |
b93a436e JL |
362 | if (flag_shared_data) |
363 | fprintf (asm_out_file, "%s\n", SHARED_BSS_SECTION_ASM_OP); | |
364 | else | |
e5887033 | 365 | #endif |
b93a436e | 366 | fprintf (asm_out_file, "%s\n", BSS_SECTION_ASM_OP); |
e5887033 DE |
367 | |
368 | in_section = in_bss; | |
369 | } | |
370 | } | |
371 | ||
372 | #ifdef ASM_OUTPUT_BSS | |
373 | ||
374 | /* Utility function for ASM_OUTPUT_BSS for targets to use if | |
375 | they don't support alignments in .bss. | |
376 | ??? It is believed that this function will work in most cases so such | |
377 | support is localized here. */ | |
378 | ||
379 | static void | |
91fddd7c | 380 | asm_output_bss (file, decl, name, size, rounded) |
e5887033 | 381 | FILE *file; |
05b13f59 | 382 | tree decl ATTRIBUTE_UNUSED; |
3cce094d | 383 | const char *name; |
05b13f59 | 384 | int size ATTRIBUTE_UNUSED, rounded; |
e5887033 DE |
385 | { |
386 | ASM_GLOBALIZE_LABEL (file, name); | |
387 | bss_section (); | |
91fddd7c DE |
388 | #ifdef ASM_DECLARE_OBJECT_NAME |
389 | last_assemble_variable_decl = decl; | |
390 | ASM_DECLARE_OBJECT_NAME (file, name, decl); | |
391 | #else | |
392 | /* Standard thing is just output label for the object. */ | |
e5887033 | 393 | ASM_OUTPUT_LABEL (file, name); |
91fddd7c | 394 | #endif /* ASM_DECLARE_OBJECT_NAME */ |
e5887033 DE |
395 | ASM_OUTPUT_SKIP (file, rounded); |
396 | } | |
397 | ||
398 | #endif | |
399 | ||
400 | #ifdef ASM_OUTPUT_ALIGNED_BSS | |
401 | ||
402 | /* Utility function for targets to use in implementing | |
403 | ASM_OUTPUT_ALIGNED_BSS. | |
404 | ??? It is believed that this function will work in most cases so such | |
405 | support is localized here. */ | |
406 | ||
407 | static void | |
91fddd7c | 408 | asm_output_aligned_bss (file, decl, name, size, align) |
e5887033 | 409 | FILE *file; |
91fddd7c | 410 | tree decl; |
3cce094d | 411 | const char *name; |
e5887033 DE |
412 | int size, align; |
413 | { | |
414 | ASM_GLOBALIZE_LABEL (file, name); | |
415 | bss_section (); | |
416 | ASM_OUTPUT_ALIGN (file, floor_log2 (align / BITS_PER_UNIT)); | |
91fddd7c DE |
417 | #ifdef ASM_DECLARE_OBJECT_NAME |
418 | last_assemble_variable_decl = decl; | |
419 | ASM_DECLARE_OBJECT_NAME (file, name, decl); | |
420 | #else | |
421 | /* Standard thing is just output label for the object. */ | |
e5887033 | 422 | ASM_OUTPUT_LABEL (file, name); |
91fddd7c | 423 | #endif /* ASM_DECLARE_OBJECT_NAME */ |
f8bc3367 | 424 | ASM_OUTPUT_SKIP (file, size ? size : 1); |
e5887033 DE |
425 | } |
426 | ||
427 | #endif | |
428 | ||
429 | #endif /* BSS_SECTION_ASM_OP */ | |
430 | ||
0021b564 JM |
431 | #ifdef EH_FRAME_SECTION_ASM_OP |
432 | void | |
5dd33f4b | 433 | eh_frame_section () |
0021b564 JM |
434 | { |
435 | if (in_section != in_eh_frame) | |
436 | { | |
437 | fprintf (asm_out_file, "%s\n", EH_FRAME_SECTION_ASM_OP); | |
438 | in_section = in_eh_frame; | |
439 | } | |
440 | } | |
441 | #endif | |
442 | ||
4d1065ed DE |
443 | /* Switch to the section for function DECL. |
444 | ||
445 | If DECL is NULL_TREE, switch to the text section. | |
446 | ??? It's not clear that we will ever be passed NULL_TREE, but it's | |
447 | safer to handle it. */ | |
448 | ||
449 | void | |
450 | function_section (decl) | |
451 | tree decl; | |
452 | { | |
453 | if (decl != NULL_TREE | |
454 | && DECL_SECTION_NAME (decl) != NULL_TREE) | |
ad4ff310 | 455 | named_section (decl, (char *) 0, 0); |
8b43265c JL |
456 | else |
457 | text_section (); | |
4d1065ed | 458 | } |
f9da1f35 DE |
459 | |
460 | /* Switch to section for variable DECL. | |
461 | ||
462 | RELOC is the `reloc' argument to SELECT_SECTION. */ | |
463 | ||
464 | void | |
465 | variable_section (decl, reloc) | |
466 | tree decl; | |
467 | int reloc; | |
468 | { | |
469 | if (IN_NAMED_SECTION (decl)) | |
ad4ff310 | 470 | named_section (decl, NULL, reloc); |
f9da1f35 DE |
471 | else |
472 | { | |
473 | /* C++ can have const variables that get initialized from constructors, | |
474 | and thus can not be in a readonly section. We prevent this by | |
475 | verifying that the initial value is constant for objects put in a | |
476 | readonly section. | |
477 | ||
478 | error_mark_node is used by the C front end to indicate that the | |
479 | initializer has not been seen yet. In this case, we assume that | |
e5887033 DE |
480 | the initializer must be constant. |
481 | ||
482 | C++ uses error_mark_node for variables that have complicated | |
483 | initializers, but these variables go in BSS so we won't be called | |
484 | for them. */ | |
485 | ||
f9da1f35 DE |
486 | #ifdef SELECT_SECTION |
487 | SELECT_SECTION (decl, reloc); | |
488 | #else | |
ad4ff310 | 489 | if (DECL_READONLY_SECTION (decl, reloc)) |
f9da1f35 DE |
490 | readonly_data_section (); |
491 | else | |
492 | data_section (); | |
493 | #endif | |
494 | } | |
495 | } | |
6adb4e3a MS |
496 | |
497 | /* Tell assembler to switch to the section for the exception handling | |
498 | table. */ | |
499 | ||
500 | void | |
501 | exception_section () | |
502 | { | |
0021b564 JM |
503 | #if defined (EXCEPTION_SECTION) |
504 | EXCEPTION_SECTION (); | |
505 | #else | |
6adb4e3a | 506 | #ifdef ASM_OUTPUT_SECTION_NAME |
ad4ff310 | 507 | named_section (NULL_TREE, ".gcc_except_table", 0); |
6adb4e3a MS |
508 | #else |
509 | if (flag_pic) | |
510 | data_section (); | |
511 | else | |
6adb4e3a MS |
512 | readonly_data_section (); |
513 | #endif | |
514 | #endif | |
515 | } | |
79e68feb RS |
516 | \f |
517 | /* Create the rtl to represent a function, for a function definition. | |
518 | DECL is a FUNCTION_DECL node which describes which function. | |
519 | The rtl is stored into DECL. */ | |
520 | ||
521 | void | |
522 | make_function_rtl (decl) | |
523 | tree decl; | |
524 | { | |
63ad61ed ZW |
525 | const char *name; |
526 | const char *new_name; | |
527 | ||
528 | if (DECL_RTL (decl) != 0) | |
529 | { | |
530 | /* ??? Another way to do this would be to do what halfpic.c does | |
531 | and maintain a hashed table of such critters. */ | |
532 | /* ??? Another way to do this would be to pass a flag bit to | |
533 | ENCODE_SECTION_INFO saying whether this is a new decl or not. */ | |
534 | /* Let the target reassign the RTL if it wants. | |
535 | This is necessary, for example, when one machine specific | |
536 | decl attribute overrides another. */ | |
537 | #ifdef REDO_SECTION_INFO_P | |
538 | if (REDO_SECTION_INFO_P (decl)) | |
539 | ENCODE_SECTION_INFO (decl); | |
540 | #endif | |
541 | return; | |
542 | } | |
543 | ||
544 | name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)); | |
545 | new_name = name; | |
79e68feb | 546 | |
7d26bd16 JM |
547 | /* Rename a nested function to avoid conflicts, unless it's a member of |
548 | a local class, in which case the class name is already unique. */ | |
79e68feb | 549 | if (decl_function_context (decl) != 0 |
7d26bd16 | 550 | && ! TYPE_P (DECL_CONTEXT (decl)) |
79e68feb RS |
551 | && DECL_INITIAL (decl) != 0 |
552 | && DECL_RTL (decl) == 0) | |
553 | { | |
554 | char *label; | |
79e68feb | 555 | ASM_FORMAT_PRIVATE_NAME (label, name, var_labelno); |
79e68feb | 556 | var_labelno++; |
63ad61ed | 557 | new_name = label; |
79e68feb | 558 | } |
63ad61ed ZW |
559 | /* When -fprefix-function-name is used, every function name is |
560 | prefixed. Even static functions are prefixed because they | |
561 | could be declared latter. Note that a nested function name | |
562 | is not prefixed. */ | |
563 | else if (flag_prefix_function_name) | |
7c6d4120 | 564 | { |
63ad61ed ZW |
565 | size_t name_len = IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (decl)); |
566 | char *pname; | |
76095e2f | 567 | |
63ad61ed ZW |
568 | pname = alloca (name_len + CHKR_PREFIX_SIZE + 1); |
569 | memcpy (pname, CHKR_PREFIX, CHKR_PREFIX_SIZE); | |
570 | memcpy (pname + CHKR_PREFIX_SIZE, name, name_len + 1); | |
571 | new_name = pname; | |
7c6d4120 | 572 | } |
79e68feb | 573 | |
63ad61ed | 574 | if (name != new_name) |
79e68feb | 575 | { |
63ad61ed ZW |
576 | DECL_ASSEMBLER_NAME (decl) = get_identifier (new_name); |
577 | name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)); | |
d9525bec | 578 | } |
63ad61ed ZW |
579 | |
580 | DECL_RTL (decl) | |
581 | = gen_rtx_MEM (DECL_MODE (decl), | |
582 | gen_rtx_SYMBOL_REF (Pmode, name)); | |
583 | ||
584 | /* Optionally set flags or add text to the name to record | |
585 | information such as that it is a function name. If the name | |
586 | is changed, the macro ASM_OUTPUT_LABELREF will have to know | |
587 | how to strip this information. */ | |
588 | #ifdef ENCODE_SECTION_INFO | |
589 | ENCODE_SECTION_INFO (decl); | |
79e68feb | 590 | #endif |
79e68feb RS |
591 | } |
592 | ||
63ad61ed | 593 | |
b4ac57ab RS |
594 | /* Given NAME, a putative register name, discard any customary prefixes. */ |
595 | ||
87e11268 | 596 | static const char * |
b4ac57ab | 597 | strip_reg_name (name) |
87e11268 | 598 | const char *name; |
b4ac57ab RS |
599 | { |
600 | #ifdef REGISTER_PREFIX | |
601 | if (!strncmp (name, REGISTER_PREFIX, strlen (REGISTER_PREFIX))) | |
602 | name += strlen (REGISTER_PREFIX); | |
603 | #endif | |
604 | if (name[0] == '%' || name[0] == '#') | |
605 | name++; | |
606 | return name; | |
607 | } | |
dcfedcd0 | 608 | \f |
79e68feb RS |
609 | /* Decode an `asm' spec for a declaration as a register name. |
610 | Return the register number, or -1 if nothing specified, | |
c09e6498 RS |
611 | or -2 if the ASMSPEC is not `cc' or `memory' and is not recognized, |
612 | or -3 if ASMSPEC is `cc' and is not recognized, | |
613 | or -4 if ASMSPEC is `memory' and is not recognized. | |
dcfedcd0 RK |
614 | Accept an exact spelling or a decimal number. |
615 | Prefixes such as % are optional. */ | |
79e68feb RS |
616 | |
617 | int | |
618 | decode_reg_name (asmspec) | |
87e11268 | 619 | const char *asmspec; |
79e68feb RS |
620 | { |
621 | if (asmspec != 0) | |
622 | { | |
623 | int i; | |
624 | ||
b4ac57ab RS |
625 | /* Get rid of confusing prefixes. */ |
626 | asmspec = strip_reg_name (asmspec); | |
627 | ||
fff9e713 MT |
628 | /* Allow a decimal number as a "register name". */ |
629 | for (i = strlen (asmspec) - 1; i >= 0; i--) | |
630 | if (! (asmspec[i] >= '0' && asmspec[i] <= '9')) | |
631 | break; | |
632 | if (asmspec[0] != 0 && i < 0) | |
633 | { | |
634 | i = atoi (asmspec); | |
635 | if (i < FIRST_PSEUDO_REGISTER && i >= 0) | |
636 | return i; | |
637 | else | |
638 | return -2; | |
639 | } | |
640 | ||
79e68feb | 641 | for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) |
b4ac57ab RS |
642 | if (reg_names[i][0] |
643 | && ! strcmp (asmspec, strip_reg_name (reg_names[i]))) | |
79e68feb RS |
644 | return i; |
645 | ||
79e68feb RS |
646 | #ifdef ADDITIONAL_REGISTER_NAMES |
647 | { | |
87e11268 | 648 | static struct { const char *name; int number; } table[] |
79e68feb RS |
649 | = ADDITIONAL_REGISTER_NAMES; |
650 | ||
b6a1cbae | 651 | for (i = 0; i < (int) ARRAY_SIZE (table); i++) |
79e68feb RS |
652 | if (! strcmp (asmspec, table[i].name)) |
653 | return table[i].number; | |
79e68feb RS |
654 | } |
655 | #endif /* ADDITIONAL_REGISTER_NAMES */ | |
656 | ||
c09e6498 RS |
657 | if (!strcmp (asmspec, "memory")) |
658 | return -4; | |
659 | ||
dcfedcd0 RK |
660 | if (!strcmp (asmspec, "cc")) |
661 | return -3; | |
662 | ||
79e68feb RS |
663 | return -2; |
664 | } | |
665 | ||
666 | return -1; | |
667 | } | |
668 | \f | |
669 | /* Create the DECL_RTL for a declaration for a static or external variable | |
670 | or static or external function. | |
671 | ASMSPEC, if not 0, is the string which the user specified | |
672 | as the assembler symbol name. | |
673 | TOP_LEVEL is nonzero if this is a file-scope variable. | |
674 | ||
675 | This is never called for PARM_DECL nodes. */ | |
676 | ||
677 | void | |
678 | make_decl_rtl (decl, asmspec, top_level) | |
679 | tree decl; | |
87e11268 | 680 | const char *asmspec; |
79e68feb RS |
681 | int top_level; |
682 | { | |
63ad61ed ZW |
683 | const char *name = 0; |
684 | const char *new_name = 0; | |
ca695ac9 JB |
685 | int reg_number; |
686 | ||
63ad61ed ZW |
687 | /* For a duplicate declaration, we can be called twice on the |
688 | same DECL node. Don't discard the RTL already made. */ | |
689 | if (DECL_RTL (decl) != 0) | |
79e68feb | 690 | { |
63ad61ed ZW |
691 | /* If the old RTL had the wrong mode, fix the mode. */ |
692 | if (GET_MODE (DECL_RTL (decl)) != DECL_MODE (decl)) | |
693 | { | |
694 | rtx rtl = DECL_RTL (decl); | |
695 | PUT_MODE (rtl, DECL_MODE (decl)); | |
696 | } | |
76095e2f | 697 | |
63ad61ed ZW |
698 | /* ??? Another way to do this would be to do what halfpic.c does |
699 | and maintain a hashed table of such critters. */ | |
700 | /* ??? Another way to do this would be to pass a flag bit to | |
701 | ENCODE_SECTION_INFO saying whether this is a new decl or not. */ | |
702 | /* Let the target reassign the RTL if it wants. | |
703 | This is necessary, for example, when one machine specific | |
704 | decl attribute overrides another. */ | |
705 | #ifdef REDO_SECTION_INFO_P | |
706 | if (REDO_SECTION_INFO_P (decl)) | |
707 | ENCODE_SECTION_INFO (decl); | |
708 | #endif | |
709 | return; | |
79e68feb RS |
710 | } |
711 | ||
63ad61ed ZW |
712 | new_name = name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)); |
713 | ||
714 | reg_number = decode_reg_name (asmspec); | |
715 | if (reg_number == -2) | |
8f820299 ZW |
716 | { |
717 | /* ASMSPEC is given, and not the name of a register. Mark the | |
718 | name with a star so assemble_name won't munge it. */ | |
719 | char *starred = alloca (strlen (asmspec) + 2); | |
720 | starred[0] = '*'; | |
721 | strcpy (starred + 1, asmspec); | |
722 | new_name = starred; | |
723 | } | |
63ad61ed ZW |
724 | |
725 | if (TREE_CODE (decl) != FUNCTION_DECL && DECL_REGISTER (decl)) | |
79e68feb | 726 | { |
79e68feb | 727 | /* First detect errors in declaring global registers. */ |
63ad61ed ZW |
728 | if (reg_number == -1) |
729 | error_with_decl (decl, "register name not specified for `%s'"); | |
730 | else if (reg_number < 0) | |
731 | error_with_decl (decl, "invalid register name for `%s'"); | |
732 | else if (TYPE_MODE (TREE_TYPE (decl)) == BLKmode) | |
12266a61 RK |
733 | error_with_decl (decl, |
734 | "data type of `%s' isn't suitable for a register"); | |
63ad61ed | 735 | else if (! HARD_REGNO_MODE_OK (reg_number, TYPE_MODE (TREE_TYPE (decl)))) |
12266a61 | 736 | error_with_decl (decl, |
63ad61ed | 737 | "register specified for `%s' isn't suitable for data type"); |
79e68feb | 738 | /* Now handle properly declared static register variables. */ |
63ad61ed | 739 | else |
79e68feb RS |
740 | { |
741 | int nregs; | |
12266a61 | 742 | |
79e68feb RS |
743 | if (DECL_INITIAL (decl) != 0 && top_level) |
744 | { | |
745 | DECL_INITIAL (decl) = 0; | |
746 | error ("global register variable has initial value"); | |
747 | } | |
79e68feb RS |
748 | if (TREE_THIS_VOLATILE (decl)) |
749 | warning ("volatile register variables don't work as you might wish"); | |
31e4b1c0 RK |
750 | |
751 | /* If the user specified one of the eliminables registers here, | |
752 | e.g., FRAME_POINTER_REGNUM, we don't want to get this variable | |
753 | confused with that register and be eliminated. Although this | |
754 | usage is somewhat suspect, we nevertheless use the following | |
755 | kludge to avoid setting DECL_RTL to frame_pointer_rtx. */ | |
756 | ||
757 | DECL_RTL (decl) | |
38a448ca | 758 | = gen_rtx_REG (DECL_MODE (decl), FIRST_PSEUDO_REGISTER); |
31e4b1c0 | 759 | REGNO (DECL_RTL (decl)) = reg_number; |
79e68feb RS |
760 | REG_USERVAR_P (DECL_RTL (decl)) = 1; |
761 | ||
762 | if (top_level) | |
763 | { | |
ad800eb1 RK |
764 | /* Make this register global, so not usable for anything |
765 | else. */ | |
1cb36a98 RH |
766 | #ifdef ASM_DECLARE_REGISTER_GLOBAL |
767 | ASM_DECLARE_REGISTER_GLOBAL (asm_out_file, decl, reg_number, name); | |
768 | #endif | |
79e68feb RS |
769 | nregs = HARD_REGNO_NREGS (reg_number, DECL_MODE (decl)); |
770 | while (nregs > 0) | |
ad800eb1 | 771 | globalize_reg (reg_number + --nregs); |
79e68feb | 772 | } |
79e68feb | 773 | |
63ad61ed ZW |
774 | /* As a register variable, it has no section. */ |
775 | return; | |
776 | } | |
777 | } | |
0a5152d0 | 778 | |
63ad61ed ZW |
779 | /* Now handle ordinary static variables and functions (in memory). |
780 | Also handle vars declared register invalidly. */ | |
781 | ||
782 | if (reg_number >= 0 || reg_number == -3) | |
783 | error_with_decl (decl, | |
784 | "register name given for non-register variable `%s'"); | |
785 | ||
786 | /* Specifying a section attribute on a variable forces it into a | |
787 | non-.bss section, and thus it cannot be common. */ | |
788 | if (TREE_CODE (decl) == VAR_DECL | |
789 | && DECL_SECTION_NAME (decl) != NULL_TREE | |
790 | && DECL_INITIAL (decl) == NULL_TREE | |
791 | && DECL_COMMON (decl)) | |
792 | DECL_COMMON (decl) = 0; | |
793 | ||
794 | /* Can't use just the variable's own name for a variable | |
795 | whose scope is less than the whole file, unless it's a member | |
796 | of a local class (which will already be unambiguous). | |
797 | Concatenate a distinguishing number. */ | |
798 | if (!top_level && !TREE_PUBLIC (decl) | |
799 | && ! (DECL_CONTEXT (decl) && TYPE_P (DECL_CONTEXT (decl))) | |
800 | && asmspec == 0) | |
801 | { | |
802 | char *label; | |
803 | ASM_FORMAT_PRIVATE_NAME (label, name, var_labelno); | |
804 | var_labelno++; | |
805 | new_name = label; | |
806 | } | |
76095e2f | 807 | |
63ad61ed ZW |
808 | /* When -fprefix-function-name is used, the functions |
809 | names are prefixed. Only nested function names are not | |
810 | prefixed. */ | |
811 | else if (flag_prefix_function_name && TREE_CODE (decl) == FUNCTION_DECL) | |
812 | { | |
813 | size_t name_len = IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (decl)); | |
814 | char *pname; | |
7c6d4120 | 815 | |
63ad61ed ZW |
816 | pname = alloca (name_len + CHKR_PREFIX_SIZE + 1); |
817 | memcpy (pname, CHKR_PREFIX, CHKR_PREFIX_SIZE); | |
818 | memcpy (pname + CHKR_PREFIX_SIZE, name, name_len + 1); | |
819 | new_name = pname; | |
79e68feb | 820 | } |
63ad61ed ZW |
821 | |
822 | if (name != new_name) | |
ff8f4401 | 823 | { |
63ad61ed ZW |
824 | DECL_ASSEMBLER_NAME (decl) = get_identifier (new_name); |
825 | name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)); | |
826 | } | |
d9525bec | 827 | |
63ad61ed ZW |
828 | /* If this variable is to be treated as volatile, show its |
829 | tree node has side effects. */ | |
830 | if ((flag_volatile_global && TREE_CODE (decl) == VAR_DECL | |
831 | && TREE_PUBLIC (decl)) | |
832 | || ((flag_volatile_static && TREE_CODE (decl) == VAR_DECL | |
833 | && (TREE_PUBLIC (decl) || TREE_STATIC (decl))))) | |
834 | TREE_SIDE_EFFECTS (decl) = 1; | |
835 | ||
836 | DECL_RTL (decl) = gen_rtx_MEM (DECL_MODE (decl), | |
837 | gen_rtx_SYMBOL_REF (Pmode, name)); | |
838 | if (TREE_CODE (decl) != FUNCTION_DECL) | |
839 | set_mem_attributes (DECL_RTL (decl), decl, 1); | |
840 | ||
841 | /* Optionally set flags or add text to the name to record information | |
842 | such as that it is a function name. | |
843 | If the name is changed, the macro ASM_OUTPUT_LABELREF | |
844 | will have to know how to strip this information. */ | |
845 | #ifdef ENCODE_SECTION_INFO | |
846 | ENCODE_SECTION_INFO (decl); | |
d9525bec | 847 | #endif |
79e68feb | 848 | } |
4724d87a RS |
849 | |
850 | /* Make the rtl for variable VAR be volatile. | |
851 | Use this only for static variables. */ | |
852 | ||
fcbaecc6 | 853 | void |
4724d87a RS |
854 | make_var_volatile (var) |
855 | tree var; | |
856 | { | |
857 | if (GET_CODE (DECL_RTL (var)) != MEM) | |
858 | abort (); | |
859 | ||
860 | MEM_VOLATILE_P (DECL_RTL (var)) = 1; | |
861 | } | |
79e68feb | 862 | \f |
d447ec6f RS |
863 | /* Output alignment directive to align for constant expression EXP. */ |
864 | ||
865 | void | |
866 | assemble_constant_align (exp) | |
867 | tree exp; | |
868 | { | |
869 | int align; | |
870 | ||
871 | /* Align the location counter as required by EXP's data type. */ | |
872 | align = TYPE_ALIGN (TREE_TYPE (exp)); | |
873 | #ifdef CONSTANT_ALIGNMENT | |
874 | align = CONSTANT_ALIGNMENT (exp, align); | |
875 | #endif | |
876 | ||
877 | if (align > BITS_PER_UNIT) | |
878 | ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT)); | |
879 | } | |
880 | ||
79e68feb RS |
881 | /* Output a string of literal assembler code |
882 | for an `asm' keyword used between functions. */ | |
883 | ||
884 | void | |
885 | assemble_asm (string) | |
886 | tree string; | |
887 | { | |
888 | app_enable (); | |
889 | ||
890 | if (TREE_CODE (string) == ADDR_EXPR) | |
891 | string = TREE_OPERAND (string, 0); | |
892 | ||
893 | fprintf (asm_out_file, "\t%s\n", TREE_STRING_POINTER (string)); | |
894 | } | |
895 | ||
9bb2e4fe RS |
896 | #if 0 /* This should no longer be needed, because |
897 | flag_gnu_linker should be 0 on these systems, | |
898 | which should prevent any output | |
899 | if ASM_OUTPUT_CONSTRUCTOR and ASM_OUTPUT_DESTRUCTOR are absent. */ | |
79e68feb RS |
900 | #if !(defined(DBX_DEBUGGING_INFO) && !defined(FASCIST_ASSEMBLER)) |
901 | #ifndef ASM_OUTPUT_CONSTRUCTOR | |
902 | #define ASM_OUTPUT_CONSTRUCTOR(file, name) | |
903 | #endif | |
904 | #ifndef ASM_OUTPUT_DESTRUCTOR | |
905 | #define ASM_OUTPUT_DESTRUCTOR(file, name) | |
906 | #endif | |
907 | #endif | |
9bb2e4fe | 908 | #endif /* 0 */ |
79e68feb RS |
909 | |
910 | /* Record an element in the table of global destructors. | |
911 | How this is done depends on what sort of assembler and linker | |
912 | are in use. | |
913 | ||
914 | NAME should be the name of a global function to be called | |
915 | at exit time. This name is output using assemble_name. */ | |
916 | ||
917 | void | |
918 | assemble_destructor (name) | |
d9bba9c3 | 919 | const char *name; |
79e68feb RS |
920 | { |
921 | #ifdef ASM_OUTPUT_DESTRUCTOR | |
922 | ASM_OUTPUT_DESTRUCTOR (asm_out_file, name); | |
923 | #else | |
924 | if (flag_gnu_linker) | |
925 | { | |
926 | /* Now tell GNU LD that this is part of the static destructor set. */ | |
927 | /* This code works for any machine provided you use GNU as/ld. */ | |
e8638df0 | 928 | fprintf (asm_out_file, "%s\"___DTOR_LIST__\",22,0,0,", ASM_STABS_OP); |
79e68feb RS |
929 | assemble_name (asm_out_file, name); |
930 | fputc ('\n', asm_out_file); | |
931 | } | |
932 | #endif | |
933 | } | |
934 | ||
935 | /* Likewise for global constructors. */ | |
936 | ||
937 | void | |
938 | assemble_constructor (name) | |
d9bba9c3 | 939 | const char *name; |
79e68feb RS |
940 | { |
941 | #ifdef ASM_OUTPUT_CONSTRUCTOR | |
942 | ASM_OUTPUT_CONSTRUCTOR (asm_out_file, name); | |
943 | #else | |
944 | if (flag_gnu_linker) | |
945 | { | |
946 | /* Now tell GNU LD that this is part of the static constructor set. */ | |
947 | /* This code works for any machine provided you use GNU as/ld. */ | |
e8638df0 | 948 | fprintf (asm_out_file, "%s\"___CTOR_LIST__\",22,0,0,", ASM_STABS_OP); |
79e68feb RS |
949 | assemble_name (asm_out_file, name); |
950 | fputc ('\n', asm_out_file); | |
951 | } | |
952 | #endif | |
953 | } | |
954 | ||
955 | /* Likewise for entries we want to record for garbage collection. | |
956 | Garbage collection is still under development. */ | |
957 | ||
958 | void | |
959 | assemble_gc_entry (name) | |
d9bba9c3 | 960 | const char *name; |
79e68feb RS |
961 | { |
962 | #ifdef ASM_OUTPUT_GC_ENTRY | |
963 | ASM_OUTPUT_GC_ENTRY (asm_out_file, name); | |
964 | #else | |
965 | if (flag_gnu_linker) | |
966 | { | |
967 | /* Now tell GNU LD that this is part of the static constructor set. */ | |
e8638df0 | 968 | fprintf (asm_out_file, "%s\"___PTR_LIST__\",22,0,0,", ASM_STABS_OP); |
79e68feb RS |
969 | assemble_name (asm_out_file, name); |
970 | fputc ('\n', asm_out_file); | |
971 | } | |
972 | #endif | |
973 | } | |
974 | \f | |
97adc6ed ILT |
975 | /* CONSTANT_POOL_BEFORE_FUNCTION may be defined as an expression with |
976 | a non-zero value if the constant pool should be output before the | |
977 | start of the function, or a zero value if the pool should output | |
978 | after the end of the function. The default is to put it before the | |
979 | start. */ | |
980 | ||
981 | #ifndef CONSTANT_POOL_BEFORE_FUNCTION | |
982 | #define CONSTANT_POOL_BEFORE_FUNCTION 1 | |
983 | #endif | |
984 | ||
79e68feb RS |
985 | /* Output assembler code for the constant pool of a function and associated |
986 | with defining the name of the function. DECL describes the function. | |
987 | NAME is the function's name. For the constant pool, we use the current | |
988 | constant pool data. */ | |
989 | ||
990 | void | |
991 | assemble_start_function (decl, fnname) | |
992 | tree decl; | |
3cce094d | 993 | const char *fnname; |
79e68feb RS |
994 | { |
995 | int align; | |
996 | ||
997 | /* The following code does not need preprocessing in the assembler. */ | |
998 | ||
999 | app_disable (); | |
1000 | ||
97adc6ed ILT |
1001 | if (CONSTANT_POOL_BEFORE_FUNCTION) |
1002 | output_constant_pool (fnname, decl); | |
79e68feb | 1003 | |
c30ac676 DE |
1004 | #ifdef ASM_OUTPUT_SECTION_NAME |
1005 | /* If the function is to be put in its own section and it's not in a section | |
1006 | already, indicate so. */ | |
ad4ff310 JM |
1007 | if ((flag_function_sections |
1008 | && DECL_SECTION_NAME (decl) == NULL_TREE) | |
1009 | || UNIQUE_SECTION_P (decl)) | |
1010 | UNIQUE_SECTION (decl, 0); | |
c30ac676 DE |
1011 | #endif |
1012 | ||
4d1065ed | 1013 | function_section (decl); |
79e68feb RS |
1014 | |
1015 | /* Tell assembler to move to target machine's alignment for functions. */ | |
1016 | align = floor_log2 (FUNCTION_BOUNDARY / BITS_PER_UNIT); | |
1017 | if (align > 0) | |
b93a436e | 1018 | ASM_OUTPUT_ALIGN (asm_out_file, align); |
79e68feb | 1019 | |
efa3896a GK |
1020 | /* Handle a user-specified function alignment. |
1021 | Note that we still need to align to FUNCTION_BOUNDARY, as above, | |
1022 | because ASM_OUTPUT_MAX_SKIP_ALIGN might not do any alignment at all. */ | |
1023 | if (align_functions_log > align) | |
1024 | { | |
1025 | #ifdef ASM_OUTPUT_MAX_SKIP_ALIGN | |
1026 | ASM_OUTPUT_MAX_SKIP_ALIGN (asm_out_file, | |
1027 | align_functions_log, align_functions-1); | |
1028 | #else | |
1029 | ASM_OUTPUT_ALIGN (asm_out_file, align_functions_log); | |
1030 | #endif | |
1031 | } | |
1032 | ||
79e68feb RS |
1033 | #ifdef ASM_OUTPUT_FUNCTION_PREFIX |
1034 | ASM_OUTPUT_FUNCTION_PREFIX (asm_out_file, fnname); | |
1035 | #endif | |
1036 | ||
1037 | #ifdef SDB_DEBUGGING_INFO | |
1038 | /* Output SDB definition of the function. */ | |
1039 | if (write_symbols == SDB_DEBUG) | |
1040 | sdbout_mark_begin_function (); | |
1041 | #endif | |
1042 | ||
1043 | #ifdef DBX_DEBUGGING_INFO | |
e5c90c23 | 1044 | /* Output DBX definition of the function. */ |
79e68feb | 1045 | if (write_symbols == DBX_DEBUG) |
e5c90c23 | 1046 | dbxout_begin_function (decl); |
79e68feb RS |
1047 | #endif |
1048 | ||
1049 | /* Make function name accessible from other files, if appropriate. */ | |
1050 | ||
1051 | if (TREE_PUBLIC (decl)) | |
1052 | { | |
ee830309 | 1053 | if (! first_global_object_name) |
06bb02f7 | 1054 | { |
ec940faa | 1055 | const char *p; |
3b304f5b ZW |
1056 | char *name; |
1057 | ||
1058 | STRIP_NAME_ENCODING (p, fnname); | |
1059 | name = permalloc (strlen (p) + 1); | |
1060 | strcpy (name, p); | |
ee830309 JM |
1061 | |
1062 | if (! DECL_WEAK (decl) && ! DECL_ONE_ONLY (decl)) | |
3b304f5b | 1063 | first_global_object_name = name; |
ee830309 | 1064 | else |
3b304f5b | 1065 | weak_global_object_name = name; |
06bb02f7 RK |
1066 | } |
1067 | ||
daefd78b JM |
1068 | #ifdef ASM_WEAKEN_LABEL |
1069 | if (DECL_WEAK (decl)) | |
ec99e58f RL |
1070 | { |
1071 | ASM_WEAKEN_LABEL (asm_out_file, fnname); | |
1072 | /* Remove this function from the pending weak list so that | |
1073 | we do not emit multiple .weak directives for it. */ | |
1074 | remove_from_pending_weak_list | |
1075 | (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl))); | |
1076 | } | |
48ad5afd | 1077 | else |
daefd78b | 1078 | #endif |
48ad5afd | 1079 | ASM_GLOBALIZE_LABEL (asm_out_file, fnname); |
79e68feb RS |
1080 | } |
1081 | ||
1082 | /* Do any machine/system dependent processing of the function name */ | |
8bd16853 | 1083 | #ifdef ASM_DECLARE_FUNCTION_NAME |
b93a436e | 1084 | ASM_DECLARE_FUNCTION_NAME (asm_out_file, fnname, current_function_decl); |
8bd16853 | 1085 | #else |
b93a436e JL |
1086 | /* Standard thing is just output label for the function. */ |
1087 | ASM_OUTPUT_LABEL (asm_out_file, fnname); | |
79e68feb RS |
1088 | #endif /* ASM_DECLARE_FUNCTION_NAME */ |
1089 | } | |
1090 | ||
1091 | /* Output assembler code associated with defining the size of the | |
1092 | function. DECL describes the function. NAME is the function's name. */ | |
1093 | ||
1094 | void | |
1095 | assemble_end_function (decl, fnname) | |
1096 | tree decl; | |
d9bba9c3 | 1097 | const char *fnname; |
79e68feb RS |
1098 | { |
1099 | #ifdef ASM_DECLARE_FUNCTION_SIZE | |
1100 | ASM_DECLARE_FUNCTION_SIZE (asm_out_file, fnname, decl); | |
1101 | #endif | |
97adc6ed | 1102 | if (! CONSTANT_POOL_BEFORE_FUNCTION) |
83488369 RK |
1103 | { |
1104 | output_constant_pool (fnname, decl); | |
1105 | function_section (decl); /* need to switch back */ | |
1106 | } | |
8839fca4 ILT |
1107 | |
1108 | /* Output any constants which should appear after the function. */ | |
1109 | output_after_function_constants (); | |
79e68feb RS |
1110 | } |
1111 | \f | |
1112 | /* Assemble code to leave SIZE bytes of zeros. */ | |
1113 | ||
1114 | void | |
1115 | assemble_zeros (size) | |
1116 | int size; | |
1117 | { | |
3c350eb3 CB |
1118 | /* Do no output if -fsyntax-only. */ |
1119 | if (flag_syntax_only) | |
1120 | return; | |
1121 | ||
79e68feb RS |
1122 | #ifdef ASM_NO_SKIP_IN_TEXT |
1123 | /* The `space' pseudo in the text section outputs nop insns rather than 0s, | |
1124 | so we must output 0s explicitly in the text section. */ | |
1125 | if (ASM_NO_SKIP_IN_TEXT && in_text_section ()) | |
1126 | { | |
1127 | int i; | |
1128 | ||
1129 | for (i = 0; i < size - 20; i += 20) | |
1130 | { | |
1131 | #ifdef ASM_BYTE_OP | |
1132 | fprintf (asm_out_file, | |
e8638df0 | 1133 | "%s0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n", ASM_BYTE_OP); |
79e68feb RS |
1134 | #else |
1135 | fprintf (asm_out_file, | |
1136 | "\tbyte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n"); | |
1137 | #endif | |
1138 | } | |
1139 | if (i < size) | |
1140 | { | |
1141 | #ifdef ASM_BYTE_OP | |
e8638df0 | 1142 | fprintf (asm_out_file, "%s0", ASM_BYTE_OP); |
79e68feb RS |
1143 | #else |
1144 | fprintf (asm_out_file, "\tbyte 0"); | |
1145 | #endif | |
1146 | i++; | |
1147 | for (; i < size; i++) | |
1148 | fprintf (asm_out_file, ",0"); | |
1149 | fprintf (asm_out_file, "\n"); | |
1150 | } | |
1151 | } | |
1152 | else | |
1153 | #endif | |
41fe4d9e | 1154 | if (size > 0) |
b93a436e | 1155 | ASM_OUTPUT_SKIP (asm_out_file, size); |
79e68feb RS |
1156 | } |
1157 | ||
a785e67e RS |
1158 | /* Assemble an alignment pseudo op for an ALIGN-bit boundary. */ |
1159 | ||
1160 | void | |
1161 | assemble_align (align) | |
1162 | int align; | |
1163 | { | |
1164 | if (align > BITS_PER_UNIT) | |
1165 | ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT)); | |
1166 | } | |
1167 | ||
79e68feb RS |
1168 | /* Assemble a string constant with the specified C string as contents. */ |
1169 | ||
1170 | void | |
1171 | assemble_string (p, size) | |
9b3142b3 | 1172 | const char *p; |
79e68feb RS |
1173 | int size; |
1174 | { | |
79e68feb RS |
1175 | int pos = 0; |
1176 | int maximum = 2000; | |
1177 | ||
1178 | /* If the string is very long, split it up. */ | |
1179 | ||
1180 | while (pos < size) | |
1181 | { | |
1182 | int thissize = size - pos; | |
1183 | if (thissize > maximum) | |
1184 | thissize = maximum; | |
1185 | ||
b93a436e | 1186 | ASM_OUTPUT_ASCII (asm_out_file, p, thissize); |
79e68feb RS |
1187 | |
1188 | pos += thissize; | |
1189 | p += thissize; | |
1190 | } | |
1191 | } | |
69249c1b | 1192 | |
79e68feb | 1193 | \f |
b8694195 NC |
1194 | #if defined ASM_OUTPUT_ALIGNED_DECL_LOCAL |
1195 | #define ASM_EMIT_LOCAL(decl, name, size, rounded) \ | |
1196 | ASM_OUTPUT_ALIGNED_DECL_LOCAL (asm_out_file, decl, name, size, DECL_ALIGN (decl)) | |
1197 | #else | |
1198 | #if defined ASM_OUTPUT_ALIGNED_LOCAL | |
1199 | #define ASM_EMIT_LOCAL(decl, name, size, rounded) \ | |
1200 | ASM_OUTPUT_ALIGNED_LOCAL (asm_out_file, name, size, DECL_ALIGN (decl)) | |
1201 | #else | |
1202 | #define ASM_EMIT_LOCAL(decl, name, size, rounded) \ | |
1203 | ASM_OUTPUT_LOCAL (asm_out_file, name, size, rounded) | |
1204 | #endif | |
1205 | #endif | |
1206 | ||
1207 | #if defined ASM_OUTPUT_ALIGNED_BSS | |
1208 | #define ASM_EMIT_BSS(decl, name, size, rounded) \ | |
1209 | ASM_OUTPUT_ALIGNED_BSS (asm_out_file, decl, name, size, DECL_ALIGN (decl)) | |
1210 | #else | |
1211 | #if defined ASM_OUTPUT_BSS | |
1212 | #define ASM_EMIT_BSS(decl, name, size, rounded) \ | |
1213 | ASM_OUTPUT_BSS (asm_out_file, decl, name, size, rounded) | |
1214 | #else | |
1215 | #undef ASM_EMIT_BSS | |
1216 | #endif | |
1217 | #endif | |
1218 | ||
1219 | #if defined ASM_OUTPUT_ALIGNED_DECL_COMMON | |
1220 | #define ASM_EMIT_COMMON(decl, name, size, rounded) \ | |
1221 | ASM_OUTPUT_ALIGNED_DECL_COMMON (asm_out_file, decl, name, size, DECL_ALIGN (decl)) | |
1222 | #else | |
1223 | #if defined ASM_OUTPUT_ALIGNED_COMMON | |
1224 | #define ASM_EMIT_COMMON(decl, name, size, rounded) \ | |
1225 | ASM_OUTPUT_ALIGNED_COMMON (asm_out_file, name, size, DECL_ALIGN (decl)) | |
1226 | #else | |
1227 | #define ASM_EMIT_COMMON(decl, name, size, rounded) \ | |
1228 | ASM_OUTPUT_COMMON (asm_out_file, name, size, rounded) | |
1229 | #endif | |
1230 | #endif | |
1231 | ||
1232 | static void | |
1233 | asm_emit_uninitialised (decl, name, size, rounded) | |
1234 | tree decl; | |
3cce094d | 1235 | const char * name; |
05b13f59 | 1236 | int size ATTRIBUTE_UNUSED; |
95d75019 | 1237 | int rounded ATTRIBUTE_UNUSED; |
b8694195 | 1238 | { |
a56e7c08 NC |
1239 | enum |
1240 | { | |
b8694195 NC |
1241 | asm_dest_common, |
1242 | asm_dest_bss, | |
1243 | asm_dest_local | |
1244 | } | |
1245 | destination = asm_dest_local; | |
1246 | ||
1247 | if (TREE_PUBLIC (decl)) | |
1248 | { | |
1249 | #if defined ASM_EMIT_BSS | |
1250 | if (! DECL_COMMON (decl)) | |
1251 | destination = asm_dest_bss; | |
1252 | else | |
1253 | #endif | |
1254 | destination = asm_dest_common; | |
1255 | } | |
1256 | ||
1257 | if (flag_shared_data) | |
1258 | { | |
1259 | switch (destination) | |
1260 | { | |
1261 | #ifdef ASM_OUTPUT_SHARED_BSS | |
1262 | case asm_dest_bss: | |
1263 | ASM_OUTPUT_SHARED_BSS (asm_out_file, decl, name, size, rounded); | |
1264 | return; | |
1265 | #endif | |
1266 | #ifdef ASM_OUTPUT_SHARED_COMMON | |
1267 | case asm_dest_common: | |
1268 | ASM_OUTPUT_SHARED_COMMON (asm_out_file, name, size, rounded); | |
1269 | return; | |
1270 | #endif | |
1271 | #ifdef ASM_OUTPUT_SHARED_LOCAL | |
1272 | case asm_dest_local: | |
1273 | ASM_OUTPUT_SHARED_LOCAL (asm_out_file, name, size, rounded); | |
1274 | return; | |
1275 | #endif | |
1276 | default: | |
1277 | break; | |
1278 | } | |
1279 | } | |
1280 | ||
a56e7c08 NC |
1281 | #ifdef ASM_OUTPUT_SECTION_NAME |
1282 | /* We already know that DECL_SECTION_NAME() == NULL. */ | |
1283 | if (flag_data_sections != 0 || UNIQUE_SECTION_P (decl)) | |
4edee0e6 | 1284 | UNIQUE_SECTION (decl, 0); |
a56e7c08 NC |
1285 | #endif |
1286 | ||
b8694195 NC |
1287 | switch (destination) |
1288 | { | |
1289 | #ifdef ASM_EMIT_BSS | |
1290 | case asm_dest_bss: | |
1291 | ASM_EMIT_BSS (decl, name, size, rounded); | |
1292 | break; | |
1293 | #endif | |
1294 | case asm_dest_common: | |
1295 | ASM_EMIT_COMMON (decl, name, size, rounded); | |
1296 | break; | |
1297 | case asm_dest_local: | |
1298 | ASM_EMIT_LOCAL (decl, name, size, rounded); | |
1299 | break; | |
1300 | default: | |
1301 | abort (); | |
1302 | } | |
1303 | ||
1304 | return; | |
1305 | } | |
1306 | ||
79e68feb RS |
1307 | /* Assemble everything that is needed for a variable or function declaration. |
1308 | Not used for automatic variables, and not used for function definitions. | |
1309 | Should not be called for variables of incomplete structure type. | |
1310 | ||
1311 | TOP_LEVEL is nonzero if this variable has file scope. | |
1312 | AT_END is nonzero if this is the special handling, at end of compilation, | |
ff8f4401 RS |
1313 | to define things that have had only tentative definitions. |
1314 | DONT_OUTPUT_DATA if nonzero means don't actually output the | |
1315 | initial value (that will be done by the caller). */ | |
79e68feb RS |
1316 | |
1317 | void | |
ff8f4401 | 1318 | assemble_variable (decl, top_level, at_end, dont_output_data) |
79e68feb | 1319 | tree decl; |
c84e2712 | 1320 | int top_level ATTRIBUTE_UNUSED; |
95d75019 | 1321 | int at_end ATTRIBUTE_UNUSED; |
5a13eaa4 | 1322 | int dont_output_data; |
79e68feb | 1323 | { |
3cce094d | 1324 | register const char *name; |
f8344bea | 1325 | unsigned int align; |
79e68feb | 1326 | int reloc = 0; |
edbc355b | 1327 | enum in_section saved_in_section; |
79e68feb | 1328 | |
cbed4565 RS |
1329 | last_assemble_variable_decl = 0; |
1330 | ||
79e68feb RS |
1331 | if (GET_CODE (DECL_RTL (decl)) == REG) |
1332 | { | |
1333 | /* Do output symbol info for global register variables, but do nothing | |
1334 | else for them. */ | |
1335 | ||
1336 | if (TREE_ASM_WRITTEN (decl)) | |
1337 | return; | |
1338 | TREE_ASM_WRITTEN (decl) = 1; | |
1339 | ||
3c350eb3 CB |
1340 | /* Do no output if -fsyntax-only. */ |
1341 | if (flag_syntax_only) | |
1342 | return; | |
1343 | ||
b4ac57ab | 1344 | #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO) |
b93a436e JL |
1345 | /* File-scope global variables are output here. */ |
1346 | if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG) | |
1347 | && top_level) | |
1348 | dbxout_symbol (decl, 0); | |
79e68feb RS |
1349 | #endif |
1350 | #ifdef SDB_DEBUGGING_INFO | |
b93a436e JL |
1351 | if (write_symbols == SDB_DEBUG && top_level |
1352 | /* Leave initialized global vars for end of compilation; | |
1353 | see comment in compile_file. */ | |
1354 | && (TREE_PUBLIC (decl) == 0 || DECL_INITIAL (decl) == 0)) | |
1355 | sdbout_symbol (decl, 0); | |
79e68feb RS |
1356 | #endif |
1357 | ||
a94dbf2c JM |
1358 | /* Don't output any DWARF debugging information for variables here. |
1359 | In the case of local variables, the information for them is output | |
1360 | when we do our recursive traversal of the tree representation for | |
1361 | the entire containing function. In the case of file-scope variables, | |
1362 | we output information for all of them at the very end of compilation | |
1363 | while we are doing our final traversal of the chain of file-scope | |
1364 | declarations. */ | |
79e68feb RS |
1365 | |
1366 | return; | |
1367 | } | |
1368 | ||
d36d70cc | 1369 | /* Normally no need to say anything here for external references, |
9faa82d8 | 1370 | since assemble_external is called by the language-specific code |
d36d70cc | 1371 | when a declaration is first seen. */ |
79e68feb | 1372 | |
44fe2e80 | 1373 | if (DECL_EXTERNAL (decl)) |
79e68feb RS |
1374 | return; |
1375 | ||
1376 | /* Output no assembler code for a function declaration. | |
1377 | Only definitions of functions output anything. */ | |
1378 | ||
1379 | if (TREE_CODE (decl) == FUNCTION_DECL) | |
1380 | return; | |
1381 | ||
1382 | /* If type was incomplete when the variable was declared, | |
1383 | see if it is complete now. */ | |
1384 | ||
1385 | if (DECL_SIZE (decl) == 0) | |
1386 | layout_decl (decl, 0); | |
1387 | ||
1388 | /* Still incomplete => don't allocate it; treat the tentative defn | |
1389 | (which is what it must have been) as an `extern' reference. */ | |
1390 | ||
ff8f4401 | 1391 | if (!dont_output_data && DECL_SIZE (decl) == 0) |
79e68feb RS |
1392 | { |
1393 | error_with_file_and_line (DECL_SOURCE_FILE (decl), | |
1394 | DECL_SOURCE_LINE (decl), | |
ea80ee44 | 1395 | "storage size of `%s' isn't known", |
79e68feb | 1396 | IDENTIFIER_POINTER (DECL_NAME (decl))); |
1c1a7ba4 | 1397 | TREE_ASM_WRITTEN (decl) = 1; |
79e68feb RS |
1398 | return; |
1399 | } | |
1400 | ||
1401 | /* The first declaration of a variable that comes through this function | |
1402 | decides whether it is global (in C, has external linkage) | |
1403 | or local (in C, has internal linkage). So do nothing more | |
1404 | if this function has already run. */ | |
1405 | ||
1406 | if (TREE_ASM_WRITTEN (decl)) | |
1407 | return; | |
1408 | ||
1409 | TREE_ASM_WRITTEN (decl) = 1; | |
1410 | ||
3c350eb3 CB |
1411 | /* Do no output if -fsyntax-only. */ |
1412 | if (flag_syntax_only) | |
1413 | return; | |
1414 | ||
809d6575 | 1415 | app_disable (); |
79e68feb | 1416 | |
770ae6cc RK |
1417 | if (! dont_output_data |
1418 | && ! host_integerp (DECL_SIZE_UNIT (decl), 1)) | |
ff8f4401 | 1419 | { |
770ae6cc RK |
1420 | error_with_decl (decl, "size of variable `%s' is too large"); |
1421 | goto finish; | |
79e68feb RS |
1422 | } |
1423 | ||
1424 | name = XSTR (XEXP (DECL_RTL (decl), 0), 0); | |
f796d997 JM |
1425 | if (TREE_PUBLIC (decl) && DECL_NAME (decl) |
1426 | && ! first_global_object_name | |
1427 | && ! (DECL_COMMON (decl) && (DECL_INITIAL (decl) == 0 | |
1428 | || DECL_INITIAL (decl) == error_mark_node)) | |
1429 | && ! DECL_WEAK (decl) | |
1430 | && ! DECL_ONE_ONLY (decl)) | |
1431 | { | |
ec940faa | 1432 | const char *p; |
3b304f5b | 1433 | char *xname; |
f796d997 JM |
1434 | |
1435 | STRIP_NAME_ENCODING (p, name); | |
3b304f5b ZW |
1436 | xname = permalloc (strlen (p) + 1); |
1437 | strcpy (xname, p); | |
1438 | first_global_object_name = xname; | |
f796d997 JM |
1439 | } |
1440 | ||
8a198bd2 JW |
1441 | /* Compute the alignment of this data. */ |
1442 | ||
1443 | align = DECL_ALIGN (decl); | |
1444 | ||
1445 | /* In the case for initialing an array whose length isn't specified, | |
1446 | where we have not yet been able to do the layout, | |
1447 | figure out the proper alignment now. */ | |
1448 | if (dont_output_data && DECL_SIZE (decl) == 0 | |
1449 | && TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE) | |
1450 | align = MAX (align, TYPE_ALIGN (TREE_TYPE (TREE_TYPE (decl)))); | |
1451 | ||
1452 | /* Some object file formats have a maximum alignment which they support. | |
1453 | In particular, a.out format supports a maximum alignment of 4. */ | |
1454 | #ifndef MAX_OFILE_ALIGNMENT | |
1455 | #define MAX_OFILE_ALIGNMENT BIGGEST_ALIGNMENT | |
1456 | #endif | |
1457 | if (align > MAX_OFILE_ALIGNMENT) | |
1458 | { | |
1459 | warning_with_decl (decl, | |
44ec7e59 CM |
1460 | "alignment of `%s' is greater than maximum object file alignment. Using %d.", |
1461 | MAX_OFILE_ALIGNMENT/BITS_PER_UNIT); | |
8a198bd2 JW |
1462 | align = MAX_OFILE_ALIGNMENT; |
1463 | } | |
1464 | ||
1465 | /* On some machines, it is good to increase alignment sometimes. */ | |
1466 | #ifdef DATA_ALIGNMENT | |
1467 | align = DATA_ALIGNMENT (TREE_TYPE (decl), align); | |
1468 | #endif | |
1469 | #ifdef CONSTANT_ALIGNMENT | |
1470 | if (DECL_INITIAL (decl) != 0 && DECL_INITIAL (decl) != error_mark_node) | |
1471 | align = CONSTANT_ALIGNMENT (DECL_INITIAL (decl), align); | |
1472 | #endif | |
1473 | ||
1474 | /* Reset the alignment in case we have made it tighter, so we can benefit | |
1475 | from it in get_pointer_alignment. */ | |
1476 | DECL_ALIGN (decl) = align; | |
1477 | ||
79e68feb RS |
1478 | /* Handle uninitialized definitions. */ |
1479 | ||
e5887033 DE |
1480 | if ((DECL_INITIAL (decl) == 0 || DECL_INITIAL (decl) == error_mark_node) |
1481 | /* If the target can't output uninitialized but not common global data | |
1482 | in .bss, then we have to use .data. */ | |
b8694195 | 1483 | #if ! defined ASM_EMIT_BSS |
cd98bf12 | 1484 | && DECL_COMMON (decl) |
e5887033 | 1485 | #endif |
a56e7c08 | 1486 | && DECL_SECTION_NAME (decl) == NULL_TREE |
e5887033 | 1487 | && ! dont_output_data) |
79e68feb | 1488 | { |
770ae6cc RK |
1489 | unsigned HOST_WIDE_INT size = tree_low_cst (DECL_SIZE_UNIT (decl), 1); |
1490 | unsigned HOST_WIDE_INT rounded = size; | |
79e68feb | 1491 | |
79e68feb RS |
1492 | /* Don't allocate zero bytes of common, |
1493 | since that means "undefined external" in the linker. */ | |
770ae6cc RK |
1494 | if (size == 0) |
1495 | rounded = 1; | |
1496 | ||
79e68feb RS |
1497 | /* Round size up to multiple of BIGGEST_ALIGNMENT bits |
1498 | so that each uninitialized object starts on such a boundary. */ | |
1499 | rounded += (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - 1; | |
1500 | rounded = (rounded / (BIGGEST_ALIGNMENT / BITS_PER_UNIT) | |
1501 | * (BIGGEST_ALIGNMENT / BITS_PER_UNIT)); | |
4bcfa7a8 | 1502 | |
ec1bff50 HPN |
1503 | /* Don't continue this line--convex cc version 4.1 would lose. */ |
1504 | #if !defined(ASM_OUTPUT_ALIGNED_COMMON) && !defined(ASM_OUTPUT_ALIGNED_DECL_COMMON) && !defined(ASM_OUTPUT_ALIGNED_BSS) | |
4cf7705a | 1505 | if ((unsigned HOST_WIDE_INT) DECL_ALIGN (decl) / BITS_PER_UNIT > rounded) |
4bcfa7a8 CM |
1506 | warning_with_decl |
1507 | (decl, "requested alignment for %s is greater than implemented alignment of %d.",rounded); | |
1508 | #endif | |
1509 | ||
edbc355b RS |
1510 | #ifdef DBX_DEBUGGING_INFO |
1511 | /* File-scope global variables are output here. */ | |
1512 | if (write_symbols == DBX_DEBUG && top_level) | |
1513 | dbxout_symbol (decl, 0); | |
1514 | #endif | |
1515 | #ifdef SDB_DEBUGGING_INFO | |
1516 | if (write_symbols == SDB_DEBUG && top_level | |
1517 | /* Leave initialized global vars for end of compilation; | |
1518 | see comment in compile_file. */ | |
1519 | && (TREE_PUBLIC (decl) == 0 || DECL_INITIAL (decl) == 0)) | |
1520 | sdbout_symbol (decl, 0); | |
1521 | #endif | |
1522 | ||
a94dbf2c JM |
1523 | /* Don't output any DWARF debugging information for variables here. |
1524 | In the case of local variables, the information for them is output | |
1525 | when we do our recursive traversal of the tree representation for | |
1526 | the entire containing function. In the case of file-scope variables, | |
1527 | we output information for all of them at the very end of compilation | |
1528 | while we are doing our final traversal of the chain of file-scope | |
1529 | declarations. */ | |
edbc355b | 1530 | |
e5887033 DE |
1531 | #if 0 /* ??? We should either delete this or add a comment describing what |
1532 | it was intended to do and why we shouldn't delete it. */ | |
79e68feb RS |
1533 | if (flag_shared_data) |
1534 | data_section (); | |
1535 | #endif | |
b8694195 | 1536 | asm_emit_uninitialised (decl, name, size, rounded); |
e5887033 | 1537 | |
b4ac57ab | 1538 | goto finish; |
79e68feb RS |
1539 | } |
1540 | ||
e5887033 DE |
1541 | /* Handle initialized definitions. |
1542 | Also handle uninitialized global definitions if -fno-common and the | |
1543 | target doesn't support ASM_OUTPUT_BSS. */ | |
79e68feb RS |
1544 | |
1545 | /* First make the assembler name(s) global if appropriate. */ | |
1546 | if (TREE_PUBLIC (decl) && DECL_NAME (decl)) | |
1547 | { | |
daefd78b | 1548 | #ifdef ASM_WEAKEN_LABEL |
ec99e58f RL |
1549 | if (DECL_WEAK (decl)) |
1550 | { | |
1551 | ASM_WEAKEN_LABEL (asm_out_file, name); | |
1552 | /* Remove this variable from the pending weak list so that | |
1553 | we do not emit multiple .weak directives for it. */ | |
1554 | remove_from_pending_weak_list | |
1555 | (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl))); | |
1556 | } | |
48ad5afd | 1557 | else |
daefd78b | 1558 | #endif |
48ad5afd | 1559 | ASM_GLOBALIZE_LABEL (asm_out_file, name); |
79e68feb RS |
1560 | } |
1561 | #if 0 | |
1562 | for (d = equivalents; d; d = TREE_CHAIN (d)) | |
1563 | { | |
1564 | tree e = TREE_VALUE (d); | |
1565 | if (TREE_PUBLIC (e) && DECL_NAME (e)) | |
1566 | ASM_GLOBALIZE_LABEL (asm_out_file, | |
1567 | XSTR (XEXP (DECL_RTL (e), 0), 0)); | |
1568 | } | |
1569 | #endif | |
1570 | ||
1571 | /* Output any data that we will need to use the address of. */ | |
2e9effae RS |
1572 | if (DECL_INITIAL (decl) == error_mark_node) |
1573 | reloc = contains_pointers_p (TREE_TYPE (decl)); | |
1574 | else if (DECL_INITIAL (decl)) | |
79e68feb RS |
1575 | reloc = output_addressed_constants (DECL_INITIAL (decl)); |
1576 | ||
ad4ff310 | 1577 | #ifdef ASM_OUTPUT_SECTION_NAME |
a56e7c08 | 1578 | if ((flag_data_sections != 0 && DECL_SECTION_NAME (decl) == NULL_TREE) |
7d0756fb | 1579 | || UNIQUE_SECTION_P (decl)) |
ad4ff310 JM |
1580 | UNIQUE_SECTION (decl, reloc); |
1581 | #endif | |
1582 | ||
f9da1f35 DE |
1583 | /* Switch to the appropriate section. */ |
1584 | variable_section (decl, reloc); | |
79e68feb | 1585 | |
a8e2f179 RS |
1586 | /* dbxout.c needs to know this. */ |
1587 | if (in_text_section ()) | |
1588 | DECL_IN_TEXT_SECTION (decl) = 1; | |
1589 | ||
edbc355b RS |
1590 | /* Record current section so we can restore it if dbxout.c clobbers it. */ |
1591 | saved_in_section = in_section; | |
1592 | ||
1593 | /* Output the dbx info now that we have chosen the section. */ | |
1594 | ||
1595 | #ifdef DBX_DEBUGGING_INFO | |
1596 | /* File-scope global variables are output here. */ | |
1597 | if (write_symbols == DBX_DEBUG && top_level) | |
1598 | dbxout_symbol (decl, 0); | |
1599 | #endif | |
1600 | #ifdef SDB_DEBUGGING_INFO | |
1601 | if (write_symbols == SDB_DEBUG && top_level | |
1602 | /* Leave initialized global vars for end of compilation; | |
1603 | see comment in compile_file. */ | |
1604 | && (TREE_PUBLIC (decl) == 0 || DECL_INITIAL (decl) == 0)) | |
1605 | sdbout_symbol (decl, 0); | |
1606 | #endif | |
1607 | ||
1608 | /* Don't output any DWARF debugging information for variables here. | |
1609 | In the case of local variables, the information for them is output | |
1610 | when we do our recursive traversal of the tree representation for | |
1611 | the entire containing function. In the case of file-scope variables, | |
1612 | we output information for all of them at the very end of compilation | |
1613 | while we are doing our final traversal of the chain of file-scope | |
1614 | declarations. */ | |
1615 | ||
a8e2f179 RS |
1616 | /* If the debugging output changed sections, reselect the section |
1617 | that's supposed to be selected. */ | |
edbc355b | 1618 | if (in_section != saved_in_section) |
f9da1f35 | 1619 | variable_section (decl, reloc); |
edbc355b | 1620 | |
8a198bd2 | 1621 | /* Output the alignment of this data. */ |
79e68feb | 1622 | if (align > BITS_PER_UNIT) |
8a198bd2 JW |
1623 | ASM_OUTPUT_ALIGN (asm_out_file, |
1624 | floor_log2 (DECL_ALIGN (decl) / BITS_PER_UNIT)); | |
79e68feb RS |
1625 | |
1626 | /* Do any machine/system dependent processing of the object. */ | |
8bd16853 | 1627 | #ifdef ASM_DECLARE_OBJECT_NAME |
b93a436e JL |
1628 | last_assemble_variable_decl = decl; |
1629 | ASM_DECLARE_OBJECT_NAME (asm_out_file, name, decl); | |
8bd16853 | 1630 | #else |
b93a436e JL |
1631 | /* Standard thing is just output label for the object. */ |
1632 | ASM_OUTPUT_LABEL (asm_out_file, name); | |
79e68feb RS |
1633 | #endif /* ASM_DECLARE_OBJECT_NAME */ |
1634 | ||
ff8f4401 | 1635 | if (!dont_output_data) |
79e68feb | 1636 | { |
ff8f4401 RS |
1637 | if (DECL_INITIAL (decl)) |
1638 | /* Output the actual data. */ | |
770ae6cc RK |
1639 | output_constant (DECL_INITIAL (decl), |
1640 | tree_low_cst (DECL_SIZE_UNIT (decl), 1)); | |
ff8f4401 RS |
1641 | else |
1642 | /* Leave space for it. */ | |
770ae6cc | 1643 | assemble_zeros (tree_low_cst (DECL_SIZE_UNIT (decl), 1)); |
79e68feb | 1644 | } |
b4ac57ab RS |
1645 | |
1646 | finish: | |
1647 | #ifdef XCOFF_DEBUGGING_INFO | |
1648 | /* Unfortunately, the IBM assembler cannot handle stabx before the actual | |
1649 | declaration. When something like ".stabx "aa:S-2",aa,133,0" is emitted | |
1650 | and `aa' hasn't been output yet, the assembler generates a stab entry with | |
1651 | a value of zero, in addition to creating an unnecessary external entry | |
6dc42e49 | 1652 | for `aa'. Hence, we must postpone dbxout_symbol to here at the end. */ |
b4ac57ab RS |
1653 | |
1654 | /* File-scope global variables are output here. */ | |
1655 | if (write_symbols == XCOFF_DEBUG && top_level) | |
05be4cea JW |
1656 | { |
1657 | saved_in_section = in_section; | |
1658 | ||
1659 | dbxout_symbol (decl, 0); | |
1660 | ||
1661 | if (in_section != saved_in_section) | |
f9da1f35 | 1662 | variable_section (decl, reloc); |
05be4cea | 1663 | } |
b4ac57ab RS |
1664 | #else |
1665 | /* There must be a statement after a label. */ | |
1666 | ; | |
1667 | #endif | |
79e68feb RS |
1668 | } |
1669 | ||
2e9effae RS |
1670 | /* Return 1 if type TYPE contains any pointers. */ |
1671 | ||
1672 | static int | |
1673 | contains_pointers_p (type) | |
1674 | tree type; | |
1675 | { | |
1676 | switch (TREE_CODE (type)) | |
1677 | { | |
1678 | case POINTER_TYPE: | |
1679 | case REFERENCE_TYPE: | |
1680 | /* I'm not sure whether OFFSET_TYPE needs this treatment, | |
1681 | so I'll play safe and return 1. */ | |
1682 | case OFFSET_TYPE: | |
1683 | return 1; | |
1684 | ||
1685 | case RECORD_TYPE: | |
1686 | case UNION_TYPE: | |
1687 | case QUAL_UNION_TYPE: | |
1688 | { | |
1689 | tree fields; | |
1690 | /* For a type that has fields, see if the fields have pointers. */ | |
1691 | for (fields = TYPE_FIELDS (type); fields; fields = TREE_CHAIN (fields)) | |
ce49ea8a JM |
1692 | if (TREE_CODE (fields) == FIELD_DECL |
1693 | && contains_pointers_p (TREE_TYPE (fields))) | |
2e9effae RS |
1694 | return 1; |
1695 | return 0; | |
1696 | } | |
1697 | ||
1698 | case ARRAY_TYPE: | |
1699 | /* An array type contains pointers if its element type does. */ | |
1700 | return contains_pointers_p (TREE_TYPE (type)); | |
1701 | ||
1702 | default: | |
1703 | return 0; | |
1704 | } | |
1705 | } | |
1706 | ||
79e68feb | 1707 | /* Output something to declare an external symbol to the assembler. |
fff9e713 MT |
1708 | (Most assemblers don't need this, so we normally output nothing.) |
1709 | Do nothing if DECL is not external. */ | |
79e68feb RS |
1710 | |
1711 | void | |
1712 | assemble_external (decl) | |
91813b28 | 1713 | tree decl ATTRIBUTE_UNUSED; |
79e68feb | 1714 | { |
79e68feb | 1715 | #ifdef ASM_OUTPUT_EXTERNAL |
2f939d94 | 1716 | if (DECL_P (decl) && DECL_EXTERNAL (decl) && TREE_PUBLIC (decl)) |
79e68feb | 1717 | { |
fff9e713 MT |
1718 | rtx rtl = DECL_RTL (decl); |
1719 | ||
1720 | if (GET_CODE (rtl) == MEM && GET_CODE (XEXP (rtl, 0)) == SYMBOL_REF | |
1721 | && ! SYMBOL_REF_USED (XEXP (rtl, 0))) | |
1722 | { | |
1723 | /* Some systems do require some output. */ | |
1724 | SYMBOL_REF_USED (XEXP (rtl, 0)) = 1; | |
1725 | ASM_OUTPUT_EXTERNAL (asm_out_file, decl, XSTR (XEXP (rtl, 0), 0)); | |
1726 | } | |
79e68feb RS |
1727 | } |
1728 | #endif | |
1729 | } | |
1730 | ||
1731 | /* Similar, for calling a library function FUN. */ | |
1732 | ||
1733 | void | |
1734 | assemble_external_libcall (fun) | |
c84e2712 | 1735 | rtx fun ATTRIBUTE_UNUSED; |
79e68feb RS |
1736 | { |
1737 | #ifdef ASM_OUTPUT_EXTERNAL_LIBCALL | |
b93a436e JL |
1738 | /* Declare library function name external when first used, if nec. */ |
1739 | if (! SYMBOL_REF_USED (fun)) | |
79e68feb | 1740 | { |
b93a436e JL |
1741 | SYMBOL_REF_USED (fun) = 1; |
1742 | ASM_OUTPUT_EXTERNAL_LIBCALL (asm_out_file, fun); | |
79e68feb RS |
1743 | } |
1744 | #endif | |
1745 | } | |
1746 | ||
1747 | /* Declare the label NAME global. */ | |
1748 | ||
1749 | void | |
1750 | assemble_global (name) | |
d9bba9c3 | 1751 | const char *name; |
79e68feb RS |
1752 | { |
1753 | ASM_GLOBALIZE_LABEL (asm_out_file, name); | |
1754 | } | |
1755 | ||
1756 | /* Assemble a label named NAME. */ | |
1757 | ||
1758 | void | |
1759 | assemble_label (name) | |
d9bba9c3 | 1760 | const char *name; |
79e68feb | 1761 | { |
b93a436e | 1762 | ASM_OUTPUT_LABEL (asm_out_file, name); |
79e68feb RS |
1763 | } |
1764 | ||
1765 | /* Output to FILE a reference to the assembler name of a C-level name NAME. | |
1766 | If NAME starts with a *, the rest of NAME is output verbatim. | |
1767 | Otherwise NAME is transformed in an implementation-defined way | |
1768 | (usually by the addition of an underscore). | |
1769 | Many macros in the tm file are defined to call this function. */ | |
1770 | ||
1771 | void | |
1772 | assemble_name (file, name) | |
1773 | FILE *file; | |
ec940faa | 1774 | const char *name; |
79e68feb | 1775 | { |
ec940faa | 1776 | const char *real_name; |
a94dbf2c | 1777 | tree id; |
648fb7cf RK |
1778 | |
1779 | STRIP_NAME_ENCODING (real_name, name); | |
7c6d4120 | 1780 | if (flag_prefix_function_name |
da61dec9 | 1781 | && ! memcmp (real_name, CHKR_PREFIX, CHKR_PREFIX_SIZE)) |
7c6d4120 | 1782 | real_name = real_name + CHKR_PREFIX_SIZE; |
87907387 | 1783 | |
a94dbf2c JM |
1784 | id = maybe_get_identifier (real_name); |
1785 | if (id) | |
1786 | TREE_SYMBOL_REFERENCED (id) = 1; | |
03e42132 | 1787 | |
79e68feb | 1788 | if (name[0] == '*') |
b93a436e | 1789 | fputs (&name[1], file); |
79e68feb | 1790 | else |
b93a436e | 1791 | ASM_OUTPUT_LABELREF (file, name); |
79e68feb RS |
1792 | } |
1793 | ||
1794 | /* Allocate SIZE bytes writable static space with a gensym name | |
1795 | and return an RTX to refer to its address. */ | |
1796 | ||
1797 | rtx | |
1798 | assemble_static_space (size) | |
1799 | int size; | |
1800 | { | |
1801 | char name[12]; | |
520a57c8 | 1802 | const char *namestring; |
79e68feb | 1803 | rtx x; |
79e68feb RS |
1804 | |
1805 | #if 0 | |
1806 | if (flag_shared_data) | |
1807 | data_section (); | |
1808 | #endif | |
1809 | ||
1810 | ASM_GENERATE_INTERNAL_LABEL (name, "LF", const_labelno); | |
1811 | ++const_labelno; | |
a8a05998 | 1812 | namestring = ggc_strdup (name); |
79e68feb | 1813 | |
b93a436e | 1814 | x = gen_rtx_SYMBOL_REF (Pmode, namestring); |
ca695ac9 | 1815 | |
e9a25f70 | 1816 | #ifdef ASM_OUTPUT_ALIGNED_DECL_LOCAL |
b93a436e JL |
1817 | ASM_OUTPUT_ALIGNED_DECL_LOCAL (asm_out_file, NULL_TREE, name, size, |
1818 | BIGGEST_ALIGNMENT); | |
e9a25f70 | 1819 | #else |
79e68feb | 1820 | #ifdef ASM_OUTPUT_ALIGNED_LOCAL |
b93a436e | 1821 | ASM_OUTPUT_ALIGNED_LOCAL (asm_out_file, name, size, BIGGEST_ALIGNMENT); |
79e68feb | 1822 | #else |
e016950d KG |
1823 | { |
1824 | /* Round size up to multiple of BIGGEST_ALIGNMENT bits | |
1825 | so that each uninitialized object starts on such a boundary. */ | |
47c3ed98 KG |
1826 | /* Variable `rounded' might or might not be used in ASM_OUTPUT_LOCAL. */ |
1827 | int rounded ATTRIBUTE_UNUSED | |
1828 | = ((size + (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - 1) | |
1829 | / (BIGGEST_ALIGNMENT / BITS_PER_UNIT) | |
1830 | * (BIGGEST_ALIGNMENT / BITS_PER_UNIT)); | |
e016950d KG |
1831 | ASM_OUTPUT_LOCAL (asm_out_file, name, size, rounded); |
1832 | } | |
e9a25f70 | 1833 | #endif |
79e68feb RS |
1834 | #endif |
1835 | return x; | |
1836 | } | |
1837 | ||
1838 | /* Assemble the static constant template for function entry trampolines. | |
1839 | This is done at most once per compilation. | |
1840 | Returns an RTX for the address of the template. */ | |
1841 | ||
f0e969bd | 1842 | #ifdef TRAMPOLINE_TEMPLATE |
79e68feb RS |
1843 | rtx |
1844 | assemble_trampoline_template () | |
1845 | { | |
1846 | char label[256]; | |
fc608b03 | 1847 | const char *name; |
79e68feb RS |
1848 | int align; |
1849 | ||
37552631 | 1850 | /* By default, put trampoline templates in read-only data section. */ |
f49acdb4 | 1851 | |
37552631 RS |
1852 | #ifdef TRAMPOLINE_SECTION |
1853 | TRAMPOLINE_SECTION (); | |
1854 | #else | |
c8c29f85 | 1855 | readonly_data_section (); |
37552631 | 1856 | #endif |
f49acdb4 | 1857 | |
79e68feb | 1858 | /* Write the assembler code to define one. */ |
073b0524 | 1859 | align = floor_log2 (TRAMPOLINE_ALIGNMENT / BITS_PER_UNIT); |
79e68feb RS |
1860 | if (align > 0) |
1861 | ASM_OUTPUT_ALIGN (asm_out_file, align); | |
1862 | ||
1863 | ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LTRAMP", 0); | |
1864 | TRAMPOLINE_TEMPLATE (asm_out_file); | |
1865 | ||
1866 | /* Record the rtl to refer to it. */ | |
1867 | ASM_GENERATE_INTERNAL_LABEL (label, "LTRAMP", 0); | |
a8a05998 | 1868 | name = ggc_strdup (label); |
38a448ca | 1869 | return gen_rtx_SYMBOL_REF (Pmode, name); |
79e68feb | 1870 | } |
f0e969bd | 1871 | #endif |
79e68feb RS |
1872 | \f |
1873 | /* Assemble the integer constant X into an object of SIZE bytes. | |
1874 | X must be either a CONST_INT or CONST_DOUBLE. | |
1875 | ||
1876 | Return 1 if we were able to output the constant, otherwise 0. If FORCE is | |
1877 | non-zero, abort if we can't output the constant. */ | |
1878 | ||
1879 | int | |
1880 | assemble_integer (x, size, force) | |
1881 | rtx x; | |
1882 | int size; | |
1883 | int force; | |
1884 | { | |
1885 | /* First try to use the standard 1, 2, 4, 8, and 16 byte | |
0f41302f | 1886 | ASM_OUTPUT... macros. */ |
79e68feb RS |
1887 | |
1888 | switch (size) | |
1889 | { | |
1890 | #ifdef ASM_OUTPUT_CHAR | |
1891 | case 1: | |
1892 | ASM_OUTPUT_CHAR (asm_out_file, x); | |
1893 | return 1; | |
1894 | #endif | |
1895 | ||
1896 | #ifdef ASM_OUTPUT_SHORT | |
1897 | case 2: | |
1898 | ASM_OUTPUT_SHORT (asm_out_file, x); | |
1899 | return 1; | |
1900 | #endif | |
1901 | ||
1902 | #ifdef ASM_OUTPUT_INT | |
1903 | case 4: | |
1904 | ASM_OUTPUT_INT (asm_out_file, x); | |
1905 | return 1; | |
1906 | #endif | |
1907 | ||
1908 | #ifdef ASM_OUTPUT_DOUBLE_INT | |
1909 | case 8: | |
1910 | ASM_OUTPUT_DOUBLE_INT (asm_out_file, x); | |
1911 | return 1; | |
1912 | #endif | |
1913 | ||
1914 | #ifdef ASM_OUTPUT_QUADRUPLE_INT | |
1915 | case 16: | |
1916 | ASM_OUTPUT_QUADRUPLE_INT (asm_out_file, x); | |
1917 | return 1; | |
1918 | #endif | |
1919 | } | |
1920 | ||
1921 | /* If we couldn't do it that way, there are two other possibilities: First, | |
1922 | if the machine can output an explicit byte and this is a 1 byte constant, | |
1923 | we can use ASM_OUTPUT_BYTE. */ | |
1924 | ||
1925 | #ifdef ASM_OUTPUT_BYTE | |
1926 | if (size == 1 && GET_CODE (x) == CONST_INT) | |
1927 | { | |
1928 | ASM_OUTPUT_BYTE (asm_out_file, INTVAL (x)); | |
1929 | return 1; | |
1930 | } | |
1931 | #endif | |
1932 | ||
1933 | /* Finally, if SIZE is larger than a single word, try to output the constant | |
1934 | one word at a time. */ | |
1935 | ||
1936 | if (size > UNITS_PER_WORD) | |
1937 | { | |
1938 | int i; | |
1939 | enum machine_mode mode | |
1940 | = mode_for_size (size * BITS_PER_UNIT, MODE_INT, 0); | |
1941 | rtx word; | |
1942 | ||
1943 | for (i = 0; i < size / UNITS_PER_WORD; i++) | |
1944 | { | |
1945 | word = operand_subword (x, i, 0, mode); | |
1946 | ||
1947 | if (word == 0) | |
1948 | break; | |
1949 | ||
fff9e713 MT |
1950 | if (! assemble_integer (word, UNITS_PER_WORD, 0)) |
1951 | break; | |
79e68feb RS |
1952 | } |
1953 | ||
1954 | if (i == size / UNITS_PER_WORD) | |
1955 | return 1; | |
fff9e713 MT |
1956 | /* If we output at least one word and then could not finish, |
1957 | there is no valid way to continue. */ | |
1958 | if (i > 0) | |
1959 | abort (); | |
79e68feb RS |
1960 | } |
1961 | ||
1962 | if (force) | |
1963 | abort (); | |
1964 | ||
1965 | return 0; | |
1966 | } | |
1967 | \f | |
1968 | /* Assemble the floating-point constant D into an object of size MODE. */ | |
1969 | ||
1970 | void | |
1971 | assemble_real (d, mode) | |
1972 | REAL_VALUE_TYPE d; | |
1973 | enum machine_mode mode; | |
1974 | { | |
1975 | jmp_buf output_constant_handler; | |
1976 | ||
1977 | if (setjmp (output_constant_handler)) | |
1978 | { | |
1979 | error ("floating point trap outputting a constant"); | |
1980 | #ifdef REAL_IS_NOT_DOUBLE | |
da61dec9 | 1981 | memset ((char *) &d, 0, sizeof d); |
79e68feb RS |
1982 | d = dconst0; |
1983 | #else | |
1984 | d = 0; | |
1985 | #endif | |
1986 | } | |
1987 | ||
1988 | set_float_handler (output_constant_handler); | |
1989 | ||
1990 | switch (mode) | |
1991 | { | |
b7526ea5 RS |
1992 | #ifdef ASM_OUTPUT_BYTE_FLOAT |
1993 | case QFmode: | |
1994 | ASM_OUTPUT_BYTE_FLOAT (asm_out_file, d); | |
1995 | break; | |
1996 | #endif | |
1997 | #ifdef ASM_OUTPUT_SHORT_FLOAT | |
1998 | case HFmode: | |
1999 | ASM_OUTPUT_SHORT_FLOAT (asm_out_file, d); | |
2000 | break; | |
2001 | #endif | |
32c03bfb RK |
2002 | #ifdef ASM_OUTPUT_THREE_QUARTER_FLOAT |
2003 | case TQFmode: | |
2004 | ASM_OUTPUT_THREE_QUARTER_FLOAT (asm_out_file, d); | |
2005 | break; | |
2006 | #endif | |
79e68feb RS |
2007 | #ifdef ASM_OUTPUT_FLOAT |
2008 | case SFmode: | |
2009 | ASM_OUTPUT_FLOAT (asm_out_file, d); | |
2010 | break; | |
2011 | #endif | |
2012 | ||
2013 | #ifdef ASM_OUTPUT_DOUBLE | |
2014 | case DFmode: | |
2015 | ASM_OUTPUT_DOUBLE (asm_out_file, d); | |
2016 | break; | |
2017 | #endif | |
2018 | ||
2019 | #ifdef ASM_OUTPUT_LONG_DOUBLE | |
2c7ff63c | 2020 | case XFmode: |
79e68feb RS |
2021 | case TFmode: |
2022 | ASM_OUTPUT_LONG_DOUBLE (asm_out_file, d); | |
2023 | break; | |
2024 | #endif | |
2025 | ||
2026 | default: | |
2027 | abort (); | |
2028 | } | |
2029 | ||
37366632 | 2030 | set_float_handler (NULL_PTR); |
79e68feb RS |
2031 | } |
2032 | \f | |
2033 | /* Here we combine duplicate floating constants to make | |
2034 | CONST_DOUBLE rtx's, and force those out to memory when necessary. */ | |
2035 | ||
4db92e9a | 2036 | /* Return a CONST_DOUBLE or CONST_INT for a value specified as a pair of ints. |
79e68feb RS |
2037 | For an integer, I0 is the low-order word and I1 is the high-order word. |
2038 | For a real number, I0 is the word with the low address | |
2039 | and I1 is the word with the high address. */ | |
2040 | ||
2041 | rtx | |
2042 | immed_double_const (i0, i1, mode) | |
37366632 | 2043 | HOST_WIDE_INT i0, i1; |
79e68feb RS |
2044 | enum machine_mode mode; |
2045 | { | |
2046 | register rtx r; | |
79e68feb | 2047 | |
ab8ab9d0 SC |
2048 | if (GET_MODE_CLASS (mode) == MODE_INT |
2049 | || GET_MODE_CLASS (mode) == MODE_PARTIAL_INT) | |
79e68feb RS |
2050 | { |
2051 | /* We clear out all bits that don't belong in MODE, unless they and our | |
2052 | sign bit are all one. So we get either a reasonable negative value | |
2053 | or a reasonable unsigned value for this mode. */ | |
2054 | int width = GET_MODE_BITSIZE (mode); | |
37366632 RK |
2055 | if (width < HOST_BITS_PER_WIDE_INT |
2056 | && ((i0 & ((HOST_WIDE_INT) (-1) << (width - 1))) | |
2057 | != ((HOST_WIDE_INT) (-1) << (width - 1)))) | |
2058 | i0 &= ((HOST_WIDE_INT) 1 << width) - 1, i1 = 0; | |
2059 | else if (width == HOST_BITS_PER_WIDE_INT | |
79e68feb RS |
2060 | && ! (i1 == ~0 && i0 < 0)) |
2061 | i1 = 0; | |
37366632 | 2062 | else if (width > 2 * HOST_BITS_PER_WIDE_INT) |
79e68feb RS |
2063 | /* We cannot represent this value as a constant. */ |
2064 | abort (); | |
2065 | ||
2ba3a0ec JW |
2066 | /* If this would be an entire word for the target, but is not for |
2067 | the host, then sign-extend on the host so that the number will look | |
2068 | the same way on the host that it would on the target. | |
2069 | ||
2070 | For example, when building a 64 bit alpha hosted 32 bit sparc | |
2071 | targeted compiler, then we want the 32 bit unsigned value -1 to be | |
2072 | represented as a 64 bit value -1, and not as 0x00000000ffffffff. | |
2073 | The later confuses the sparc backend. */ | |
2074 | ||
2075 | if (BITS_PER_WORD < HOST_BITS_PER_WIDE_INT && BITS_PER_WORD == width | |
2076 | && (i0 & ((HOST_WIDE_INT) 1 << (width - 1)))) | |
2077 | i0 |= ((HOST_WIDE_INT) (-1) << width); | |
2078 | ||
37366632 | 2079 | /* If MODE fits within HOST_BITS_PER_WIDE_INT, always use a CONST_INT. |
79e68feb RS |
2080 | |
2081 | ??? Strictly speaking, this is wrong if we create a CONST_INT | |
2082 | for a large unsigned constant with the size of MODE being | |
37366632 RK |
2083 | HOST_BITS_PER_WIDE_INT and later try to interpret that constant in a |
2084 | wider mode. In that case we will mis-interpret it as a negative | |
2085 | number. | |
79e68feb RS |
2086 | |
2087 | Unfortunately, the only alternative is to make a CONST_DOUBLE | |
2088 | for any constant in any mode if it is an unsigned constant larger | |
2089 | than the maximum signed integer in an int on the host. However, | |
2090 | doing this will break everyone that always expects to see a CONST_INT | |
2091 | for SImode and smaller. | |
2092 | ||
2093 | We have always been making CONST_INTs in this case, so nothing new | |
2094 | is being broken. */ | |
2095 | ||
37366632 | 2096 | if (width <= HOST_BITS_PER_WIDE_INT) |
7bcac048 | 2097 | i1 = (i0 < 0) ? ~(HOST_WIDE_INT) 0 : 0; |
79e68feb RS |
2098 | |
2099 | /* If this integer fits in one word, return a CONST_INT. */ | |
2100 | if ((i1 == 0 && i0 >= 0) | |
2101 | || (i1 == ~0 && i0 < 0)) | |
37366632 | 2102 | return GEN_INT (i0); |
79e68feb RS |
2103 | |
2104 | /* We use VOIDmode for integers. */ | |
2105 | mode = VOIDmode; | |
2106 | } | |
2107 | ||
2108 | /* Search the chain for an existing CONST_DOUBLE with the right value. | |
2109 | If one is found, return it. */ | |
01d939e8 | 2110 | if (cfun != 0) |
36edd3cc BS |
2111 | for (r = const_double_chain; r; r = CONST_DOUBLE_CHAIN (r)) |
2112 | if (CONST_DOUBLE_LOW (r) == i0 && CONST_DOUBLE_HIGH (r) == i1 | |
2113 | && GET_MODE (r) == mode) | |
2114 | return r; | |
79e68feb | 2115 | |
1f8f4a0b | 2116 | /* No; make a new one and add it to the chain. */ |
f8a83ee3 | 2117 | r = gen_rtx_CONST_DOUBLE (mode, const0_rtx, i0, i1); |
79e68feb | 2118 | |
36edd3cc BS |
2119 | /* Don't touch const_double_chain if not inside any function. */ |
2120 | if (current_function_decl != 0) | |
5145eda8 RS |
2121 | { |
2122 | CONST_DOUBLE_CHAIN (r) = const_double_chain; | |
2123 | const_double_chain = r; | |
2124 | } | |
79e68feb | 2125 | |
79e68feb RS |
2126 | return r; |
2127 | } | |
2128 | ||
2129 | /* Return a CONST_DOUBLE for a specified `double' value | |
2130 | and machine mode. */ | |
2131 | ||
2132 | rtx | |
2133 | immed_real_const_1 (d, mode) | |
2134 | REAL_VALUE_TYPE d; | |
2135 | enum machine_mode mode; | |
2136 | { | |
2137 | union real_extract u; | |
2138 | register rtx r; | |
79e68feb RS |
2139 | |
2140 | /* Get the desired `double' value as a sequence of ints | |
2141 | since that is how they are stored in a CONST_DOUBLE. */ | |
2142 | ||
2143 | u.d = d; | |
2144 | ||
4cf7705a RK |
2145 | /* Detect special cases. But be careful we don't use a CONST_DOUBLE |
2146 | that's from a parent function since it may be in its constant pool. */ | |
2147 | if (REAL_VALUES_IDENTICAL (dconst0, d) | |
2148 | && (cfun == 0 || decl_function_context (current_function_decl) == 0)) | |
79e68feb | 2149 | return CONST0_RTX (mode); |
4cf7705a | 2150 | |
12194c38 RS |
2151 | /* Check for NaN first, because some ports (specifically the i386) do not |
2152 | emit correct ieee-fp code by default, and thus will generate a core | |
2153 | dump here if we pass a NaN to REAL_VALUES_EQUAL and if REAL_VALUES_EQUAL | |
2154 | does a floating point comparison. */ | |
4cf7705a RK |
2155 | else if ((! REAL_VALUE_ISNAN (d) && REAL_VALUES_EQUAL (dconst1, d)) |
2156 | && (cfun == 0 | |
2157 | || decl_function_context (current_function_decl) == 0)) | |
79e68feb RS |
2158 | return CONST1_RTX (mode); |
2159 | ||
800d5c9e RH |
2160 | if (sizeof u == sizeof (HOST_WIDE_INT)) |
2161 | return immed_double_const (u.i[0], 0, mode); | |
37366632 | 2162 | if (sizeof u == 2 * sizeof (HOST_WIDE_INT)) |
79e68feb RS |
2163 | return immed_double_const (u.i[0], u.i[1], mode); |
2164 | ||
2165 | /* The rest of this function handles the case where | |
2166 | a float value requires more than 2 ints of space. | |
2167 | It will be deleted as dead code on machines that don't need it. */ | |
2168 | ||
2169 | /* Search the chain for an existing CONST_DOUBLE with the right value. | |
2170 | If one is found, return it. */ | |
01d939e8 | 2171 | if (cfun != 0) |
36edd3cc | 2172 | for (r = const_double_chain; r; r = CONST_DOUBLE_CHAIN (r)) |
da61dec9 | 2173 | if (! memcmp ((char *) &CONST_DOUBLE_LOW (r), (char *) &u, sizeof u) |
36edd3cc BS |
2174 | && GET_MODE (r) == mode) |
2175 | return r; | |
79e68feb RS |
2176 | |
2177 | /* No; make a new one and add it to the chain. | |
2178 | ||
2179 | We may be called by an optimizer which may be discarding any memory | |
2180 | allocated during its processing (such as combine and loop). However, | |
2181 | we will be leaving this constant on the chain, so we cannot tolerate | |
1f8f4a0b | 2182 | freed memory. */ |
79e68feb RS |
2183 | r = rtx_alloc (CONST_DOUBLE); |
2184 | PUT_MODE (r, mode); | |
da61dec9 | 2185 | memcpy ((char *) &CONST_DOUBLE_LOW (r), (char *) &u, sizeof u); |
79e68feb | 2186 | |
f8a83ee3 ZW |
2187 | /* If we aren't inside a function, don't put r on the |
2188 | const_double_chain. */ | |
36edd3cc | 2189 | if (current_function_decl != 0) |
5145eda8 RS |
2190 | { |
2191 | CONST_DOUBLE_CHAIN (r) = const_double_chain; | |
2192 | const_double_chain = r; | |
2193 | } | |
f8a83ee3 ZW |
2194 | else |
2195 | CONST_DOUBLE_CHAIN (r) = NULL_RTX; | |
79e68feb RS |
2196 | |
2197 | /* Store const0_rtx in CONST_DOUBLE_MEM since this CONST_DOUBLE is on the | |
2198 | chain, but has not been allocated memory. Actual use of CONST_DOUBLE_MEM | |
2199 | is only through force_const_mem. */ | |
2200 | ||
2201 | CONST_DOUBLE_MEM (r) = const0_rtx; | |
2202 | ||
2203 | return r; | |
2204 | } | |
2205 | ||
2206 | /* Return a CONST_DOUBLE rtx for a value specified by EXP, | |
2207 | which must be a REAL_CST tree node. */ | |
2208 | ||
2209 | rtx | |
2210 | immed_real_const (exp) | |
2211 | tree exp; | |
2212 | { | |
2213 | return immed_real_const_1 (TREE_REAL_CST (exp), TYPE_MODE (TREE_TYPE (exp))); | |
2214 | } | |
2215 | ||
2216 | /* At the end of a function, forget the memory-constants | |
2217 | previously made for CONST_DOUBLEs. Mark them as not on real_constant_chain. | |
2218 | Also clear out real_constant_chain and clear out all the chain-pointers. */ | |
2219 | ||
2220 | void | |
2221 | clear_const_double_mem () | |
2222 | { | |
2223 | register rtx r, next; | |
2224 | ||
2225 | for (r = const_double_chain; r; r = next) | |
2226 | { | |
2227 | next = CONST_DOUBLE_CHAIN (r); | |
2228 | CONST_DOUBLE_CHAIN (r) = 0; | |
2229 | CONST_DOUBLE_MEM (r) = cc0_rtx; | |
2230 | } | |
2231 | const_double_chain = 0; | |
2232 | } | |
2233 | \f | |
2234 | /* Given an expression EXP with a constant value, | |
2235 | reduce it to the sum of an assembler symbol and an integer. | |
2236 | Store them both in the structure *VALUE. | |
2237 | Abort if EXP does not reduce. */ | |
2238 | ||
2239 | struct addr_const | |
2240 | { | |
2241 | rtx base; | |
fb351073 | 2242 | HOST_WIDE_INT offset; |
79e68feb RS |
2243 | }; |
2244 | ||
2245 | static void | |
2246 | decode_addr_const (exp, value) | |
2247 | tree exp; | |
2248 | struct addr_const *value; | |
2249 | { | |
2250 | register tree target = TREE_OPERAND (exp, 0); | |
2251 | register int offset = 0; | |
2252 | register rtx x; | |
2253 | ||
2254 | while (1) | |
2255 | { | |
2256 | if (TREE_CODE (target) == COMPONENT_REF | |
770ae6cc | 2257 | && host_integerp (byte_position (TREE_OPERAND (target, 1)), 0)) |
665f2503 | 2258 | |
79e68feb | 2259 | { |
770ae6cc | 2260 | offset += int_byte_position (TREE_OPERAND (target, 1)); |
79e68feb RS |
2261 | target = TREE_OPERAND (target, 0); |
2262 | } | |
2263 | else if (TREE_CODE (target) == ARRAY_REF) | |
2264 | { | |
770ae6cc RK |
2265 | offset += (tree_low_cst (TYPE_SIZE_UNIT (TREE_TYPE (target)), 1) |
2266 | * tree_low_cst (TREE_OPERAND (target, 1), 0)); | |
79e68feb RS |
2267 | target = TREE_OPERAND (target, 0); |
2268 | } | |
2269 | else | |
2270 | break; | |
2271 | } | |
2272 | ||
2273 | switch (TREE_CODE (target)) | |
2274 | { | |
2275 | case VAR_DECL: | |
2276 | case FUNCTION_DECL: | |
2277 | x = DECL_RTL (target); | |
2278 | break; | |
2279 | ||
2280 | case LABEL_DECL: | |
b93a436e JL |
2281 | x = gen_rtx_MEM (FUNCTION_MODE, |
2282 | gen_rtx_LABEL_REF (VOIDmode, | |
2283 | label_rtx (TREE_OPERAND (exp, 0)))); | |
79e68feb RS |
2284 | break; |
2285 | ||
2286 | case REAL_CST: | |
2287 | case STRING_CST: | |
2288 | case COMPLEX_CST: | |
2289 | case CONSTRUCTOR: | |
2cf55b55 | 2290 | case INTEGER_CST: |
79e68feb RS |
2291 | x = TREE_CST_RTL (target); |
2292 | break; | |
2293 | ||
2294 | default: | |
2295 | abort (); | |
2296 | } | |
2297 | ||
b93a436e JL |
2298 | if (GET_CODE (x) != MEM) |
2299 | abort (); | |
2300 | x = XEXP (x, 0); | |
79e68feb RS |
2301 | |
2302 | value->base = x; | |
2303 | value->offset = offset; | |
2304 | } | |
2305 | \f | |
1f8f4a0b MM |
2306 | struct rtx_const |
2307 | { | |
2308 | #ifdef ONLY_INT_FIELDS | |
2309 | unsigned int kind : 16; | |
2310 | unsigned int mode : 16; | |
2311 | #else | |
2312 | enum kind kind : 16; | |
2313 | enum machine_mode mode : 16; | |
2314 | #endif | |
2315 | union { | |
2316 | union real_extract du; | |
2317 | struct addr_const addr; | |
2318 | struct {HOST_WIDE_INT high, low;} di; | |
2319 | } un; | |
2320 | }; | |
2321 | ||
79e68feb RS |
2322 | /* Uniquize all constants that appear in memory. |
2323 | Each constant in memory thus far output is recorded | |
2324 | in `const_hash_table' with a `struct constant_descriptor' | |
2325 | that contains a polish representation of the value of | |
2326 | the constant. | |
2327 | ||
2328 | We cannot store the trees in the hash table | |
2329 | because the trees may be temporary. */ | |
2330 | ||
2331 | struct constant_descriptor | |
2332 | { | |
2333 | struct constant_descriptor *next; | |
520a57c8 | 2334 | const char *label; |
14a774a9 | 2335 | rtx rtl; |
37357796 RE |
2336 | /* Make sure the data is reasonably aligned. */ |
2337 | union | |
2338 | { | |
2339 | unsigned char contents[1]; | |
2340 | #ifdef HAVE_LONG_DOUBLE | |
2341 | long double d; | |
2342 | #else | |
2343 | double d; | |
2344 | #endif | |
2345 | } u; | |
79e68feb RS |
2346 | }; |
2347 | ||
2348 | #define HASHBITS 30 | |
2349 | #define MAX_HASH_TABLE 1009 | |
2350 | static struct constant_descriptor *const_hash_table[MAX_HASH_TABLE]; | |
2351 | ||
bd7cf17e JJ |
2352 | #define STRHASH(x) ((hashval_t)((long)(x) >> 3)) |
2353 | ||
2354 | struct deferred_string | |
2355 | { | |
520a57c8 | 2356 | const char *label; |
bd7cf17e JJ |
2357 | tree exp; |
2358 | int labelno; | |
2359 | }; | |
2360 | ||
2361 | static htab_t const_str_htab; | |
2362 | ||
76095e2f RH |
2363 | /* Mark a const_hash_table descriptor for GC. */ |
2364 | ||
2365 | static void | |
2366 | mark_const_hash_entry (ptr) | |
2367 | void *ptr; | |
2368 | { | |
2369 | struct constant_descriptor *desc = * (struct constant_descriptor **) ptr; | |
2370 | ||
2371 | while (desc) | |
2372 | { | |
14a774a9 | 2373 | ggc_mark_rtx (desc->rtl); |
76095e2f RH |
2374 | desc = desc->next; |
2375 | } | |
2376 | } | |
2377 | ||
bd7cf17e JJ |
2378 | /* Mark the hash-table element X (which is really a pointer to an |
2379 | struct deferred_string *). */ | |
2380 | ||
2381 | static int | |
2382 | mark_const_str_htab_1 (x, data) | |
2383 | void **x; | |
2384 | void *data ATTRIBUTE_UNUSED; | |
2385 | { | |
2386 | ggc_mark_tree (((struct deferred_string *) *x)->exp); | |
2387 | return 1; | |
2388 | } | |
2389 | ||
2390 | /* Mark a const_str_htab for GC. */ | |
2391 | ||
2392 | static void | |
2393 | mark_const_str_htab (htab) | |
2394 | void *htab; | |
2395 | { | |
2396 | htab_traverse (*((htab_t *) htab), mark_const_str_htab_1, NULL); | |
2397 | } | |
2398 | ||
2399 | /* Returns a hash code for X (which is a really a | |
2400 | struct deferred_string *). */ | |
2401 | ||
2402 | static hashval_t | |
2403 | const_str_htab_hash (x) | |
2404 | const void *x; | |
2405 | { | |
ce1cc601 | 2406 | return STRHASH (((const struct deferred_string *) x)->label); |
bd7cf17e JJ |
2407 | } |
2408 | ||
2409 | /* Returns non-zero if the value represented by X (which is really a | |
2410 | struct deferred_string *) is the same as that given by Y | |
2411 | (which is really a char *). */ | |
2412 | ||
2413 | static int | |
2414 | const_str_htab_eq (x, y) | |
2415 | const void *x; | |
2416 | const void *y; | |
2417 | { | |
ce1cc601 | 2418 | return (((const struct deferred_string *) x)->label == (const char *) y); |
bd7cf17e JJ |
2419 | } |
2420 | ||
2421 | /* Delete the hash table entry dfsp. */ | |
2422 | ||
2423 | static void | |
2424 | const_str_htab_del (dfsp) | |
2425 | void *dfsp; | |
2426 | { | |
2427 | free (dfsp); | |
2428 | } | |
2429 | ||
79e68feb RS |
2430 | /* Compute a hash code for a constant expression. */ |
2431 | ||
5a13eaa4 | 2432 | static int |
79e68feb RS |
2433 | const_hash (exp) |
2434 | tree exp; | |
2435 | { | |
3cce094d | 2436 | register const char *p; |
79e68feb RS |
2437 | register int len, hi, i; |
2438 | register enum tree_code code = TREE_CODE (exp); | |
2439 | ||
a9d07d6e RK |
2440 | /* Either set P and LEN to the address and len of something to hash and |
2441 | exit the switch or return a value. */ | |
2442 | ||
2443 | switch (code) | |
79e68feb | 2444 | { |
a9d07d6e | 2445 | case INTEGER_CST: |
2afaa41c GM |
2446 | p = (char *) &TREE_INT_CST (exp); |
2447 | len = sizeof TREE_INT_CST (exp); | |
a9d07d6e RK |
2448 | break; |
2449 | ||
2450 | case REAL_CST: | |
79e68feb RS |
2451 | p = (char *) &TREE_REAL_CST (exp); |
2452 | len = sizeof TREE_REAL_CST (exp); | |
a9d07d6e | 2453 | break; |
79e68feb | 2454 | |
a9d07d6e RK |
2455 | case STRING_CST: |
2456 | p = TREE_STRING_POINTER (exp); | |
2457 | len = TREE_STRING_LENGTH (exp); | |
2458 | break; | |
79e68feb | 2459 | |
a9d07d6e RK |
2460 | case COMPLEX_CST: |
2461 | return (const_hash (TREE_REALPART (exp)) * 5 | |
2462 | + const_hash (TREE_IMAGPART (exp))); | |
2463 | ||
2464 | case CONSTRUCTOR: | |
2465 | if (TREE_CODE (TREE_TYPE (exp)) == SET_TYPE) | |
79e68feb | 2466 | { |
3cce094d KG |
2467 | char *tmp; |
2468 | ||
a9d07d6e | 2469 | len = int_size_in_bytes (TREE_TYPE (exp)); |
3cce094d KG |
2470 | tmp = (char *) alloca (len); |
2471 | get_set_constructor_bytes (exp, (unsigned char *) tmp, len); | |
2472 | p = tmp; | |
a9d07d6e RK |
2473 | break; |
2474 | } | |
2475 | else | |
2476 | { | |
2477 | register tree link; | |
2478 | ||
2479 | /* For record type, include the type in the hashing. | |
2480 | We do not do so for array types | |
2481 | because (1) the sizes of the elements are sufficient | |
2482 | and (2) distinct array types can have the same constructor. | |
2483 | Instead, we include the array size because the constructor could | |
2484 | be shorter. */ | |
2485 | if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE) | |
7bcac048 | 2486 | hi = ((unsigned long) TREE_TYPE (exp) & ((1 << HASHBITS) - 1)) |
a9d07d6e RK |
2487 | % MAX_HASH_TABLE; |
2488 | else | |
2489 | hi = ((5 + int_size_in_bytes (TREE_TYPE (exp))) | |
2490 | & ((1 << HASHBITS) - 1)) % MAX_HASH_TABLE; | |
2491 | ||
2492 | for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link)) | |
2493 | if (TREE_VALUE (link)) | |
2494 | hi | |
2495 | = (hi * 603 + const_hash (TREE_VALUE (link))) % MAX_HASH_TABLE; | |
2496 | ||
2497 | return hi; | |
79e68feb | 2498 | } |
79e68feb | 2499 | |
a9d07d6e RK |
2500 | case ADDR_EXPR: |
2501 | { | |
2502 | struct addr_const value; | |
2503 | ||
2504 | decode_addr_const (exp, &value); | |
2505 | if (GET_CODE (value.base) == SYMBOL_REF) | |
2506 | { | |
2507 | /* Don't hash the address of the SYMBOL_REF; | |
2508 | only use the offset and the symbol name. */ | |
2509 | hi = value.offset; | |
2510 | p = XSTR (value.base, 0); | |
2511 | for (i = 0; p[i] != 0; i++) | |
2512 | hi = ((hi * 613) + (unsigned) (p[i])); | |
2513 | } | |
2514 | else if (GET_CODE (value.base) == LABEL_REF) | |
2515 | hi = value.offset + CODE_LABEL_NUMBER (XEXP (value.base, 0)) * 13; | |
6a651371 KG |
2516 | else |
2517 | abort(); | |
a9d07d6e RK |
2518 | |
2519 | hi &= (1 << HASHBITS) - 1; | |
2520 | hi %= MAX_HASH_TABLE; | |
2521 | } | |
79e68feb | 2522 | return hi; |
a9d07d6e RK |
2523 | |
2524 | case PLUS_EXPR: | |
2525 | case MINUS_EXPR: | |
2526 | return (const_hash (TREE_OPERAND (exp, 0)) * 9 | |
2527 | + const_hash (TREE_OPERAND (exp, 1))); | |
2528 | ||
2529 | case NOP_EXPR: | |
2530 | case CONVERT_EXPR: | |
2531 | case NON_LVALUE_EXPR: | |
2532 | return const_hash (TREE_OPERAND (exp, 0)) * 7 + 2; | |
e9a25f70 JL |
2533 | |
2534 | default: | |
990e8954 NS |
2535 | /* A language specific constant. Just hash the code. */ |
2536 | return code % MAX_HASH_TABLE; | |
79e68feb | 2537 | } |
79e68feb RS |
2538 | |
2539 | /* Compute hashing function */ | |
2540 | hi = len; | |
2541 | for (i = 0; i < len; i++) | |
0f41302f | 2542 | hi = ((hi * 613) + (unsigned) (p[i])); |
79e68feb RS |
2543 | |
2544 | hi &= (1 << HASHBITS) - 1; | |
2545 | hi %= MAX_HASH_TABLE; | |
2546 | return hi; | |
2547 | } | |
2548 | \f | |
2549 | /* Compare a constant expression EXP with a constant-descriptor DESC. | |
2550 | Return 1 if DESC describes a constant with the same value as EXP. */ | |
2551 | ||
2552 | static int | |
2553 | compare_constant (exp, desc) | |
2554 | tree exp; | |
2555 | struct constant_descriptor *desc; | |
2556 | { | |
37357796 | 2557 | return 0 != compare_constant_1 (exp, desc->u.contents); |
79e68feb RS |
2558 | } |
2559 | ||
2560 | /* Compare constant expression EXP with a substring P of a constant descriptor. | |
2561 | If they match, return a pointer to the end of the substring matched. | |
2562 | If they do not match, return 0. | |
2563 | ||
2564 | Since descriptors are written in polish prefix notation, | |
2565 | this function can be used recursively to test one operand of EXP | |
2566 | against a subdescriptor, and if it succeeds it returns the | |
2567 | address of the subdescriptor for the next operand. */ | |
2568 | ||
990e8954 | 2569 | static const unsigned char * |
79e68feb RS |
2570 | compare_constant_1 (exp, p) |
2571 | tree exp; | |
990e8954 | 2572 | const unsigned char *p; |
79e68feb | 2573 | { |
990e8954 | 2574 | register const unsigned char *strp; |
79e68feb RS |
2575 | register int len; |
2576 | register enum tree_code code = TREE_CODE (exp); | |
2577 | ||
2578 | if (code != (enum tree_code) *p++) | |
2579 | return 0; | |
2580 | ||
a9d07d6e RK |
2581 | /* Either set STRP, P and LEN to pointers and length to compare and exit the |
2582 | switch, or return the result of the comparison. */ | |
2583 | ||
2584 | switch (code) | |
79e68feb | 2585 | { |
a9d07d6e | 2586 | case INTEGER_CST: |
79e68feb RS |
2587 | /* Integer constants are the same only if the same width of type. */ |
2588 | if (*p++ != TYPE_PRECISION (TREE_TYPE (exp))) | |
2589 | return 0; | |
a9d07d6e | 2590 | |
2afaa41c GM |
2591 | strp = (unsigned char *) &TREE_INT_CST (exp); |
2592 | len = sizeof TREE_INT_CST (exp); | |
a9d07d6e RK |
2593 | break; |
2594 | ||
2595 | case REAL_CST: | |
79e68feb RS |
2596 | /* Real constants are the same only if the same width of type. */ |
2597 | if (*p++ != TYPE_PRECISION (TREE_TYPE (exp))) | |
2598 | return 0; | |
a9d07d6e | 2599 | |
990e8954 | 2600 | strp = (unsigned char *) &TREE_REAL_CST (exp); |
79e68feb | 2601 | len = sizeof TREE_REAL_CST (exp); |
a9d07d6e RK |
2602 | break; |
2603 | ||
2604 | case STRING_CST: | |
79e68feb RS |
2605 | if (flag_writable_strings) |
2606 | return 0; | |
a9d07d6e | 2607 | |
c8d8ed65 | 2608 | if ((enum machine_mode) *p++ != TYPE_MODE (TREE_TYPE (exp))) |
f163668c RK |
2609 | return 0; |
2610 | ||
ce1cc601 | 2611 | strp = (const unsigned char *)TREE_STRING_POINTER (exp); |
79e68feb | 2612 | len = TREE_STRING_LENGTH (exp); |
da61dec9 | 2613 | if (memcmp ((char *) &TREE_STRING_LENGTH (exp), p, |
79e68feb RS |
2614 | sizeof TREE_STRING_LENGTH (exp))) |
2615 | return 0; | |
a9d07d6e | 2616 | |
79e68feb | 2617 | p += sizeof TREE_STRING_LENGTH (exp); |
a9d07d6e | 2618 | break; |
79e68feb | 2619 | |
a9d07d6e RK |
2620 | case COMPLEX_CST: |
2621 | p = compare_constant_1 (TREE_REALPART (exp), p); | |
2622 | if (p == 0) | |
79e68feb | 2623 | return 0; |
79e68feb | 2624 | |
a9d07d6e | 2625 | return compare_constant_1 (TREE_IMAGPART (exp), p); |
79e68feb | 2626 | |
a9d07d6e RK |
2627 | case CONSTRUCTOR: |
2628 | if (TREE_CODE (TREE_TYPE (exp)) == SET_TYPE) | |
eb528802 | 2629 | { |
a9d07d6e | 2630 | int xlen = len = int_size_in_bytes (TREE_TYPE (exp)); |
3cce094d | 2631 | unsigned char *tmp = (unsigned char *) alloca (len); |
a9d07d6e | 2632 | |
f9e158c3 | 2633 | get_set_constructor_bytes (exp, tmp, len); |
990e8954 | 2634 | strp = (unsigned char *) tmp; |
da61dec9 | 2635 | if (memcmp ((char *) &xlen, p, sizeof xlen)) |
eb528802 | 2636 | return 0; |
eb528802 | 2637 | |
a9d07d6e RK |
2638 | p += sizeof xlen; |
2639 | break; | |
2640 | } | |
2641 | else | |
77fa0940 | 2642 | { |
a9d07d6e RK |
2643 | register tree link; |
2644 | int length = list_length (CONSTRUCTOR_ELTS (exp)); | |
2645 | tree type; | |
14a774a9 | 2646 | enum machine_mode mode = TYPE_MODE (TREE_TYPE (exp)); |
e5e809f4 JL |
2647 | int have_purpose = 0; |
2648 | ||
2649 | for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link)) | |
2650 | if (TREE_PURPOSE (link)) | |
2651 | have_purpose = 1; | |
a9d07d6e | 2652 | |
da61dec9 | 2653 | if (memcmp ((char *) &length, p, sizeof length)) |
a9d07d6e RK |
2654 | return 0; |
2655 | ||
2656 | p += sizeof length; | |
2657 | ||
2658 | /* For record constructors, insist that the types match. | |
e5e809f4 JL |
2659 | For arrays, just verify both constructors are for arrays. |
2660 | Then insist that either both or none have any TREE_PURPOSE | |
2661 | values. */ | |
a9d07d6e RK |
2662 | if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE) |
2663 | type = TREE_TYPE (exp); | |
2664 | else | |
2665 | type = 0; | |
2666 | ||
da61dec9 | 2667 | if (memcmp ((char *) &type, p, sizeof type)) |
a9d07d6e RK |
2668 | return 0; |
2669 | ||
14a774a9 RK |
2670 | if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE) |
2671 | { | |
da61dec9 | 2672 | if (memcmp ((char *) &mode, p, sizeof mode)) |
14a774a9 RK |
2673 | return 0; |
2674 | ||
2675 | p += sizeof mode; | |
2676 | } | |
2677 | ||
a9d07d6e RK |
2678 | p += sizeof type; |
2679 | ||
da61dec9 | 2680 | if (memcmp ((char *) &have_purpose, p, sizeof have_purpose)) |
e5e809f4 JL |
2681 | return 0; |
2682 | ||
2683 | p += sizeof have_purpose; | |
2684 | ||
a9d07d6e RK |
2685 | /* For arrays, insist that the size in bytes match. */ |
2686 | if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE) | |
77fa0940 | 2687 | { |
e5e809f4 JL |
2688 | HOST_WIDE_INT size = int_size_in_bytes (TREE_TYPE (exp)); |
2689 | ||
da61dec9 | 2690 | if (memcmp ((char *) &size, p, sizeof size)) |
77fa0940 | 2691 | return 0; |
a9d07d6e RK |
2692 | |
2693 | p += sizeof size; | |
77fa0940 | 2694 | } |
a9d07d6e RK |
2695 | |
2696 | for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link)) | |
77fa0940 | 2697 | { |
a9d07d6e RK |
2698 | if (TREE_VALUE (link)) |
2699 | { | |
2700 | if ((p = compare_constant_1 (TREE_VALUE (link), p)) == 0) | |
2701 | return 0; | |
2702 | } | |
2703 | else | |
2704 | { | |
2705 | tree zero = 0; | |
77fa0940 | 2706 | |
da61dec9 | 2707 | if (memcmp ((char *) &zero, p, sizeof zero)) |
e5e809f4 JL |
2708 | return 0; |
2709 | ||
2710 | p += sizeof zero; | |
2711 | } | |
2712 | ||
2713 | if (TREE_PURPOSE (link) | |
2714 | && TREE_CODE (TREE_PURPOSE (link)) == FIELD_DECL) | |
2715 | { | |
da61dec9 | 2716 | if (memcmp ((char *) &TREE_PURPOSE (link), p, |
e5e809f4 JL |
2717 | sizeof TREE_PURPOSE (link))) |
2718 | return 0; | |
2719 | ||
2720 | p += sizeof TREE_PURPOSE (link); | |
2721 | } | |
2722 | else if (TREE_PURPOSE (link)) | |
2723 | { | |
2724 | if ((p = compare_constant_1 (TREE_PURPOSE (link), p)) == 0) | |
2725 | return 0; | |
2726 | } | |
2727 | else if (have_purpose) | |
2728 | { | |
2729 | int zero = 0; | |
2730 | ||
da61dec9 | 2731 | if (memcmp ((char *) &zero, p, sizeof zero)) |
a9d07d6e RK |
2732 | return 0; |
2733 | ||
2734 | p += sizeof zero; | |
2735 | } | |
77fa0940 | 2736 | } |
a9d07d6e RK |
2737 | |
2738 | return p; | |
77fa0940 RK |
2739 | } |
2740 | ||
a9d07d6e RK |
2741 | case ADDR_EXPR: |
2742 | { | |
2743 | struct addr_const value; | |
2744 | ||
2745 | decode_addr_const (exp, &value); | |
990e8954 | 2746 | strp = (unsigned char *) &value.offset; |
a9d07d6e RK |
2747 | len = sizeof value.offset; |
2748 | /* Compare the offset. */ | |
2749 | while (--len >= 0) | |
2750 | if (*p++ != *strp++) | |
2751 | return 0; | |
2752 | ||
2753 | /* Compare symbol name. */ | |
ce1cc601 KG |
2754 | strp = (const unsigned char *) XSTR (value.base, 0); |
2755 | len = strlen ((const char *) strp) + 1; | |
a9d07d6e RK |
2756 | } |
2757 | break; | |
2758 | ||
2759 | case PLUS_EXPR: | |
2760 | case MINUS_EXPR: | |
fa212801 | 2761 | case RANGE_EXPR: |
79e68feb | 2762 | p = compare_constant_1 (TREE_OPERAND (exp, 0), p); |
a9d07d6e RK |
2763 | if (p == 0) |
2764 | return 0; | |
2765 | ||
2766 | return compare_constant_1 (TREE_OPERAND (exp, 1), p); | |
2767 | ||
2768 | case NOP_EXPR: | |
2769 | case CONVERT_EXPR: | |
2770 | case NON_LVALUE_EXPR: | |
2771 | return compare_constant_1 (TREE_OPERAND (exp, 0), p); | |
e9a25f70 JL |
2772 | |
2773 | default: | |
990e8954 NS |
2774 | if (lang_expand_constant) |
2775 | { | |
2776 | exp = (*lang_expand_constant) (exp); | |
2777 | return compare_constant_1 (exp, p); | |
2778 | } | |
2779 | return 0; | |
79e68feb RS |
2780 | } |
2781 | ||
2782 | /* Compare constant contents. */ | |
2783 | while (--len >= 0) | |
2784 | if (*p++ != *strp++) | |
2785 | return 0; | |
2786 | ||
2787 | return p; | |
2788 | } | |
2789 | \f | |
2790 | /* Construct a constant descriptor for the expression EXP. | |
2791 | It is up to the caller to enter the descriptor in the hash table. */ | |
2792 | ||
2793 | static struct constant_descriptor * | |
2794 | record_constant (exp) | |
2795 | tree exp; | |
2796 | { | |
387e854a RK |
2797 | struct constant_descriptor *next = 0; |
2798 | char *label = 0; | |
14a774a9 | 2799 | rtx rtl = 0; |
cac16ef9 | 2800 | int pad; |
79e68feb | 2801 | |
14a774a9 | 2802 | /* Make a struct constant_descriptor. The first three pointers will |
387e854a RK |
2803 | be filled in later. Here we just leave space for them. */ |
2804 | ||
2805 | obstack_grow (&permanent_obstack, (char *) &next, sizeof next); | |
2806 | obstack_grow (&permanent_obstack, (char *) &label, sizeof label); | |
14a774a9 | 2807 | obstack_grow (&permanent_obstack, (char *) &rtl, sizeof rtl); |
cac16ef9 RH |
2808 | |
2809 | /* Align the descriptor for the data payload. */ | |
2810 | pad = (offsetof (struct constant_descriptor, u) | |
2811 | - offsetof(struct constant_descriptor, rtl) | |
2812 | - sizeof(next->rtl)); | |
2813 | if (pad > 0) | |
2814 | obstack_blank (&permanent_obstack, pad); | |
2815 | ||
79e68feb RS |
2816 | record_constant_1 (exp); |
2817 | return (struct constant_descriptor *) obstack_finish (&permanent_obstack); | |
2818 | } | |
2819 | ||
2820 | /* Add a description of constant expression EXP | |
2821 | to the object growing in `permanent_obstack'. | |
2822 | No need to return its address; the caller will get that | |
2823 | from the obstack when the object is complete. */ | |
2824 | ||
2825 | static void | |
2826 | record_constant_1 (exp) | |
2827 | tree exp; | |
2828 | { | |
ce1cc601 | 2829 | register const unsigned char *strp; |
79e68feb RS |
2830 | register int len; |
2831 | register enum tree_code code = TREE_CODE (exp); | |
2832 | ||
2833 | obstack_1grow (&permanent_obstack, (unsigned int) code); | |
2834 | ||
2871d24f | 2835 | switch (code) |
79e68feb | 2836 | { |
2871d24f | 2837 | case INTEGER_CST: |
79e68feb | 2838 | obstack_1grow (&permanent_obstack, TYPE_PRECISION (TREE_TYPE (exp))); |
2afaa41c GM |
2839 | strp = (unsigned char *) &TREE_INT_CST (exp); |
2840 | len = sizeof TREE_INT_CST (exp); | |
2871d24f RK |
2841 | break; |
2842 | ||
2843 | case REAL_CST: | |
79e68feb | 2844 | obstack_1grow (&permanent_obstack, TYPE_PRECISION (TREE_TYPE (exp))); |
990e8954 | 2845 | strp = (unsigned char *) &TREE_REAL_CST (exp); |
79e68feb | 2846 | len = sizeof TREE_REAL_CST (exp); |
2871d24f RK |
2847 | break; |
2848 | ||
2849 | case STRING_CST: | |
79e68feb RS |
2850 | if (flag_writable_strings) |
2851 | return; | |
2871d24f | 2852 | |
f163668c | 2853 | obstack_1grow (&permanent_obstack, TYPE_MODE (TREE_TYPE (exp))); |
ce1cc601 | 2854 | strp = (const unsigned char *) TREE_STRING_POINTER (exp); |
79e68feb RS |
2855 | len = TREE_STRING_LENGTH (exp); |
2856 | obstack_grow (&permanent_obstack, (char *) &TREE_STRING_LENGTH (exp), | |
2857 | sizeof TREE_STRING_LENGTH (exp)); | |
2871d24f RK |
2858 | break; |
2859 | ||
2860 | case COMPLEX_CST: | |
79e68feb RS |
2861 | record_constant_1 (TREE_REALPART (exp)); |
2862 | record_constant_1 (TREE_IMAGPART (exp)); | |
2863 | return; | |
79e68feb | 2864 | |
2871d24f RK |
2865 | case CONSTRUCTOR: |
2866 | if (TREE_CODE (TREE_TYPE (exp)) == SET_TYPE) | |
eb528802 | 2867 | { |
2871d24f RK |
2868 | int nbytes = int_size_in_bytes (TREE_TYPE (exp)); |
2869 | obstack_grow (&permanent_obstack, &nbytes, sizeof (nbytes)); | |
2870 | obstack_blank (&permanent_obstack, nbytes); | |
2871 | get_set_constructor_bytes | |
2491d239 PB |
2872 | (exp, (unsigned char *) permanent_obstack.next_free-nbytes, |
2873 | nbytes); | |
2871d24f | 2874 | return; |
eb528802 | 2875 | } |
2871d24f | 2876 | else |
77fa0940 | 2877 | { |
2871d24f RK |
2878 | register tree link; |
2879 | int length = list_length (CONSTRUCTOR_ELTS (exp)); | |
14a774a9 | 2880 | enum machine_mode mode = TYPE_MODE (TREE_TYPE (exp)); |
2871d24f | 2881 | tree type; |
e5e809f4 JL |
2882 | int have_purpose = 0; |
2883 | ||
2884 | for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link)) | |
2885 | if (TREE_PURPOSE (link)) | |
2886 | have_purpose = 1; | |
2871d24f RK |
2887 | |
2888 | obstack_grow (&permanent_obstack, (char *) &length, sizeof length); | |
2889 | ||
2890 | /* For record constructors, insist that the types match. | |
14a774a9 RK |
2891 | For arrays, just verify both constructors are for arrays |
2892 | of the same mode. Then insist that either both or none | |
2893 | have any TREE_PURPOSE values. */ | |
2871d24f RK |
2894 | if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE) |
2895 | type = TREE_TYPE (exp); | |
77fa0940 | 2896 | else |
2871d24f | 2897 | type = 0; |
14a774a9 | 2898 | |
2871d24f | 2899 | obstack_grow (&permanent_obstack, (char *) &type, sizeof type); |
14a774a9 RK |
2900 | if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE) |
2901 | obstack_grow (&permanent_obstack, &mode, sizeof mode); | |
2902 | ||
e5e809f4 JL |
2903 | obstack_grow (&permanent_obstack, (char *) &have_purpose, |
2904 | sizeof have_purpose); | |
2871d24f RK |
2905 | |
2906 | /* For arrays, insist that the size in bytes match. */ | |
2907 | if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE) | |
77fa0940 | 2908 | { |
e5e809f4 | 2909 | HOST_WIDE_INT size = int_size_in_bytes (TREE_TYPE (exp)); |
2871d24f RK |
2910 | obstack_grow (&permanent_obstack, (char *) &size, sizeof size); |
2911 | } | |
77fa0940 | 2912 | |
2871d24f RK |
2913 | for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link)) |
2914 | { | |
2915 | if (TREE_VALUE (link)) | |
2916 | record_constant_1 (TREE_VALUE (link)); | |
2917 | else | |
2918 | { | |
2919 | tree zero = 0; | |
2920 | ||
e5e809f4 JL |
2921 | obstack_grow (&permanent_obstack, |
2922 | (char *) &zero, sizeof zero); | |
2923 | } | |
2924 | ||
2925 | if (TREE_PURPOSE (link) | |
2926 | && TREE_CODE (TREE_PURPOSE (link)) == FIELD_DECL) | |
2927 | obstack_grow (&permanent_obstack, | |
2928 | (char *) &TREE_PURPOSE (link), | |
2929 | sizeof TREE_PURPOSE (link)); | |
2930 | else if (TREE_PURPOSE (link)) | |
2931 | record_constant_1 (TREE_PURPOSE (link)); | |
2932 | else if (have_purpose) | |
2933 | { | |
2934 | int zero = 0; | |
2935 | ||
2871d24f RK |
2936 | obstack_grow (&permanent_obstack, |
2937 | (char *) &zero, sizeof zero); | |
2938 | } | |
77fa0940 RK |
2939 | } |
2940 | } | |
79e68feb | 2941 | return; |
2871d24f RK |
2942 | |
2943 | case ADDR_EXPR: | |
2944 | { | |
2945 | struct addr_const value; | |
2946 | ||
2947 | decode_addr_const (exp, &value); | |
2948 | /* Record the offset. */ | |
2949 | obstack_grow (&permanent_obstack, | |
2950 | (char *) &value.offset, sizeof value.offset); | |
e67cd9f8 RH |
2951 | |
2952 | switch (GET_CODE (value.base)) | |
2953 | { | |
2954 | case SYMBOL_REF: | |
2955 | /* Record the symbol name. */ | |
2956 | obstack_grow (&permanent_obstack, XSTR (value.base, 0), | |
2957 | strlen (XSTR (value.base, 0)) + 1); | |
2958 | break; | |
2959 | case LABEL_REF: | |
2960 | /* Record the address of the CODE_LABEL. It may not have | |
2961 | been emitted yet, so it's UID may be zero. But pointer | |
2962 | identity is good enough. */ | |
2963 | obstack_grow (&permanent_obstack, &XEXP (value.base, 0), | |
2964 | sizeof (rtx)); | |
2965 | break; | |
2966 | default: | |
2967 | abort (); | |
2968 | } | |
2871d24f | 2969 | } |
79e68feb | 2970 | return; |
2871d24f RK |
2971 | |
2972 | case PLUS_EXPR: | |
2973 | case MINUS_EXPR: | |
fa212801 | 2974 | case RANGE_EXPR: |
79e68feb RS |
2975 | record_constant_1 (TREE_OPERAND (exp, 0)); |
2976 | record_constant_1 (TREE_OPERAND (exp, 1)); | |
2977 | return; | |
2871d24f RK |
2978 | |
2979 | case NOP_EXPR: | |
2980 | case CONVERT_EXPR: | |
2981 | case NON_LVALUE_EXPR: | |
79e68feb RS |
2982 | record_constant_1 (TREE_OPERAND (exp, 0)); |
2983 | return; | |
2871d24f RK |
2984 | |
2985 | default: | |
990e8954 NS |
2986 | if (lang_expand_constant) |
2987 | { | |
2988 | exp = (*lang_expand_constant) (exp); | |
2989 | record_constant_1 (exp); | |
2990 | } | |
2991 | return; | |
79e68feb RS |
2992 | } |
2993 | ||
2994 | /* Record constant contents. */ | |
2995 | obstack_grow (&permanent_obstack, strp, len); | |
2996 | } | |
2997 | \f | |
ff8f4401 RS |
2998 | /* Record a list of constant expressions that were passed to |
2999 | output_constant_def but that could not be output right away. */ | |
3000 | ||
3001 | struct deferred_constant | |
3002 | { | |
3003 | struct deferred_constant *next; | |
3004 | tree exp; | |
3005 | int reloc; | |
3006 | int labelno; | |
3007 | }; | |
3008 | ||
3009 | static struct deferred_constant *deferred_constants; | |
3010 | ||
8839fca4 ILT |
3011 | /* Another list of constants which should be output after the |
3012 | function. */ | |
3013 | static struct deferred_constant *after_function_constants; | |
3014 | ||
ff8f4401 RS |
3015 | /* Nonzero means defer output of addressed subconstants |
3016 | (i.e., those for which output_constant_def is called.) */ | |
3017 | static int defer_addressed_constants_flag; | |
3018 | ||
3019 | /* Start deferring output of subconstants. */ | |
3020 | ||
3021 | void | |
3022 | defer_addressed_constants () | |
3023 | { | |
3024 | defer_addressed_constants_flag++; | |
3025 | } | |
3026 | ||
3027 | /* Stop deferring output of subconstants, | |
3028 | and output now all those that have been deferred. */ | |
3029 | ||
3030 | void | |
3031 | output_deferred_addressed_constants () | |
3032 | { | |
3033 | struct deferred_constant *p, *next; | |
3034 | ||
3035 | defer_addressed_constants_flag--; | |
3036 | ||
3037 | if (defer_addressed_constants_flag > 0) | |
3038 | return; | |
3039 | ||
3040 | for (p = deferred_constants; p; p = next) | |
3041 | { | |
3042 | output_constant_def_contents (p->exp, p->reloc, p->labelno); | |
3043 | next = p->next; | |
3044 | free (p); | |
3045 | } | |
3046 | ||
3047 | deferred_constants = 0; | |
3048 | } | |
d12516f1 | 3049 | |
8839fca4 ILT |
3050 | /* Output any constants which should appear after a function. */ |
3051 | ||
3052 | static void | |
3053 | output_after_function_constants () | |
3054 | { | |
3055 | struct deferred_constant *p, *next; | |
3056 | ||
3057 | for (p = after_function_constants; p; p = next) | |
3058 | { | |
3059 | output_constant_def_contents (p->exp, p->reloc, p->labelno); | |
3060 | next = p->next; | |
3061 | free (p); | |
3062 | } | |
3063 | ||
3064 | after_function_constants = 0; | |
3065 | } | |
3066 | ||
d12516f1 RS |
3067 | /* Make a copy of the whole tree structure for a constant. |
3068 | This handles the same types of nodes that compare_constant | |
3069 | and record_constant handle. */ | |
3070 | ||
3071 | static tree | |
3072 | copy_constant (exp) | |
3073 | tree exp; | |
3074 | { | |
3075 | switch (TREE_CODE (exp)) | |
3076 | { | |
310bbbf4 JW |
3077 | case ADDR_EXPR: |
3078 | /* For ADDR_EXPR, we do not want to copy the decl whose address | |
3079 | is requested. We do want to copy constants though. */ | |
3080 | if (TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp, 0))) == 'c') | |
3081 | return build1 (TREE_CODE (exp), TREE_TYPE (exp), | |
3082 | copy_constant (TREE_OPERAND (exp, 0))); | |
3083 | else | |
3084 | return copy_node (exp); | |
3085 | ||
d12516f1 RS |
3086 | case INTEGER_CST: |
3087 | case REAL_CST: | |
3088 | case STRING_CST: | |
d12516f1 RS |
3089 | return copy_node (exp); |
3090 | ||
3091 | case COMPLEX_CST: | |
28eb1cb8 RK |
3092 | return build_complex (TREE_TYPE (exp), |
3093 | copy_constant (TREE_REALPART (exp)), | |
d12516f1 RS |
3094 | copy_constant (TREE_IMAGPART (exp))); |
3095 | ||
3096 | case PLUS_EXPR: | |
3097 | case MINUS_EXPR: | |
3098 | return build (TREE_CODE (exp), TREE_TYPE (exp), | |
3099 | copy_constant (TREE_OPERAND (exp, 0)), | |
3100 | copy_constant (TREE_OPERAND (exp, 1))); | |
3101 | ||
3102 | case NOP_EXPR: | |
3103 | case CONVERT_EXPR: | |
a9d07d6e | 3104 | case NON_LVALUE_EXPR: |
d12516f1 RS |
3105 | return build1 (TREE_CODE (exp), TREE_TYPE (exp), |
3106 | copy_constant (TREE_OPERAND (exp, 0))); | |
3107 | ||
3108 | case CONSTRUCTOR: | |
3109 | { | |
3110 | tree copy = copy_node (exp); | |
3111 | tree list = copy_list (CONSTRUCTOR_ELTS (exp)); | |
3112 | tree tail; | |
3113 | ||
bb31ce0a | 3114 | CONSTRUCTOR_ELTS (copy) = list; |
d12516f1 RS |
3115 | for (tail = list; tail; tail = TREE_CHAIN (tail)) |
3116 | TREE_VALUE (tail) = copy_constant (TREE_VALUE (tail)); | |
474bda6c PB |
3117 | if (TREE_CODE (TREE_TYPE (exp)) == SET_TYPE) |
3118 | for (tail = list; tail; tail = TREE_CHAIN (tail)) | |
3119 | TREE_PURPOSE (tail) = copy_constant (TREE_PURPOSE (tail)); | |
d12516f1 RS |
3120 | |
3121 | return copy; | |
3122 | } | |
3123 | ||
3124 | default: | |
3125 | abort (); | |
3126 | } | |
3127 | } | |
ff8f4401 | 3128 | \f |
79e68feb RS |
3129 | /* Return an rtx representing a reference to constant data in memory |
3130 | for the constant expression EXP. | |
ff8f4401 | 3131 | |
79e68feb RS |
3132 | If assembler code for such a constant has already been output, |
3133 | return an rtx to refer to it. | |
ff8f4401 RS |
3134 | Otherwise, output such a constant in memory (or defer it for later) |
3135 | and generate an rtx for it. | |
3136 | ||
bd7cf17e JJ |
3137 | If DEFER is non-zero, the output of string constants can be deferred |
3138 | and output only if referenced in the function after all optimizations. | |
3139 | ||
ff8f4401 | 3140 | The TREE_CST_RTL of EXP is set up to point to that rtx. |
79e68feb RS |
3141 | The const_hash_table records which constants already have label strings. */ |
3142 | ||
3143 | rtx | |
bd7cf17e | 3144 | output_constant_def (exp, defer) |
79e68feb | 3145 | tree exp; |
bd7cf17e | 3146 | int defer; |
79e68feb | 3147 | { |
ff8f4401 | 3148 | register int hash; |
79e68feb | 3149 | register struct constant_descriptor *desc; |
bd7cf17e | 3150 | struct deferred_string **defstr; |
79e68feb | 3151 | char label[256]; |
79e68feb | 3152 | int reloc; |
14a774a9 | 3153 | int found = 1; |
bd7cf17e JJ |
3154 | int after_function = 0; |
3155 | int labelno = -1; | |
79e68feb | 3156 | |
79e68feb RS |
3157 | if (TREE_CST_RTL (exp)) |
3158 | return TREE_CST_RTL (exp); | |
3159 | ||
3160 | /* Make sure any other constants whose addresses appear in EXP | |
3161 | are assigned label numbers. */ | |
3162 | ||
3163 | reloc = output_addressed_constants (exp); | |
3164 | ||
3165 | /* Compute hash code of EXP. Search the descriptors for that hash code | |
3166 | to see if any of them describes EXP. If yes, the descriptor records | |
3167 | the label number already assigned. */ | |
3168 | ||
00f07fb9 | 3169 | hash = const_hash (exp) % MAX_HASH_TABLE; |
ca695ac9 | 3170 | |
00f07fb9 RK |
3171 | for (desc = const_hash_table[hash]; desc; desc = desc->next) |
3172 | if (compare_constant (exp, desc)) | |
14a774a9 | 3173 | break; |
ca695ac9 | 3174 | |
14a774a9 | 3175 | if (desc == 0) |
00f07fb9 RK |
3176 | { |
3177 | /* No constant equal to EXP is known to have been output. | |
3178 | Make a constant descriptor to enter EXP in the hash table. | |
3179 | Assign the label number and record it in the descriptor for | |
3180 | future calls to this function to find. */ | |
ca695ac9 | 3181 | |
00f07fb9 | 3182 | /* Create a string containing the label name, in LABEL. */ |
bd7cf17e JJ |
3183 | labelno = const_labelno++; |
3184 | ASM_GENERATE_INTERNAL_LABEL (label, "LC", labelno); | |
00f07fb9 RK |
3185 | |
3186 | desc = record_constant (exp); | |
3187 | desc->next = const_hash_table[hash]; | |
a8a05998 | 3188 | desc->label = ggc_strdup (label); |
00f07fb9 | 3189 | const_hash_table[hash] = desc; |
ca695ac9 | 3190 | |
1f8f4a0b | 3191 | /* We have a symbol name; construct the SYMBOL_REF and the MEM. */ |
14a774a9 RK |
3192 | desc->rtl |
3193 | = gen_rtx_MEM (TYPE_MODE (TREE_TYPE (exp)), | |
3194 | gen_rtx_SYMBOL_REF (Pmode, desc->label)); | |
00f07fb9 | 3195 | |
289c5b45 | 3196 | set_mem_attributes (desc->rtl, exp, 1); |
14a774a9 RK |
3197 | |
3198 | found = 0; | |
3199 | } | |
3200 | ||
3201 | TREE_CST_RTL (exp) = desc->rtl; | |
79e68feb RS |
3202 | |
3203 | /* Optionally set flags or add text to the name to record information | |
3204 | such as that it is a function name. If the name is changed, the macro | |
8a425a05 | 3205 | ASM_OUTPUT_LABELREF will have to know how to strip this information. */ |
79e68feb RS |
3206 | #ifdef ENCODE_SECTION_INFO |
3207 | ENCODE_SECTION_INFO (exp); | |
3208 | #endif | |
3209 | ||
bd7cf17e JJ |
3210 | #ifdef CONSTANT_AFTER_FUNCTION_P |
3211 | if (current_function_decl != 0 | |
3212 | && CONSTANT_AFTER_FUNCTION_P (exp)) | |
3213 | after_function = 1; | |
3214 | #endif | |
3215 | ||
3216 | if (found | |
3217 | && STRING_POOL_ADDRESS_P (XEXP (desc->rtl, 0)) | |
3218 | && (!defer || defer_addressed_constants_flag || after_function)) | |
3219 | { | |
3220 | defstr = (struct deferred_string **) | |
3221 | htab_find_slot_with_hash (const_str_htab, desc->label, | |
3222 | STRHASH (desc->label), NO_INSERT); | |
3223 | if (defstr) | |
3224 | { | |
3225 | /* If the string is currently deferred but we need to output it now, | |
3226 | remove it from deferred string hash table. */ | |
3227 | found = 0; | |
3228 | labelno = (*defstr)->labelno; | |
3229 | STRING_POOL_ADDRESS_P (XEXP (desc->rtl, 0)) = 0; | |
3230 | htab_clear_slot (const_str_htab, (void **) defstr); | |
3231 | } | |
3232 | } | |
3233 | ||
ff8f4401 RS |
3234 | /* If this is the first time we've seen this particular constant, |
3235 | output it (or defer its output for later). */ | |
14a774a9 | 3236 | if (! found) |
79e68feb | 3237 | { |
8839fca4 | 3238 | if (defer_addressed_constants_flag || after_function) |
ff8f4401 RS |
3239 | { |
3240 | struct deferred_constant *p; | |
3241 | p = (struct deferred_constant *) xmalloc (sizeof (struct deferred_constant)); | |
3242 | ||
d12516f1 | 3243 | p->exp = copy_constant (exp); |
ff8f4401 | 3244 | p->reloc = reloc; |
bd7cf17e | 3245 | p->labelno = labelno; |
8839fca4 ILT |
3246 | if (after_function) |
3247 | { | |
3248 | p->next = after_function_constants; | |
3249 | after_function_constants = p; | |
3250 | } | |
3251 | else | |
3252 | { | |
3253 | p->next = deferred_constants; | |
3254 | deferred_constants = p; | |
3255 | } | |
ff8f4401 RS |
3256 | } |
3257 | else | |
3c350eb3 CB |
3258 | { |
3259 | /* Do no output if -fsyntax-only. */ | |
3260 | if (! flag_syntax_only) | |
bd7cf17e JJ |
3261 | { |
3262 | if (TREE_CODE (exp) != STRING_CST | |
3263 | || !defer | |
3264 | || flag_writable_strings | |
3265 | || (defstr = (struct deferred_string **) | |
3266 | htab_find_slot_with_hash (const_str_htab, | |
3267 | desc->label, | |
3268 | STRHASH (desc->label), | |
3269 | INSERT)) == NULL) | |
3270 | output_constant_def_contents (exp, reloc, labelno); | |
3271 | else | |
3272 | { | |
3273 | struct deferred_string *p; | |
3274 | ||
3275 | p = (struct deferred_string *) | |
3276 | xmalloc (sizeof (struct deferred_string)); | |
3277 | ||
3278 | p->exp = copy_constant (exp); | |
3279 | p->label = desc->label; | |
3280 | p->labelno = labelno; | |
3281 | *defstr = p; | |
3282 | STRING_POOL_ADDRESS_P (XEXP (desc->rtl, 0)) = 1; | |
3283 | } | |
3284 | } | |
3c350eb3 | 3285 | } |
ff8f4401 RS |
3286 | } |
3287 | ||
3288 | return TREE_CST_RTL (exp); | |
3289 | } | |
3290 | ||
3291 | /* Now output assembler code to define the label for EXP, | |
3292 | and follow it with the data of EXP. */ | |
79e68feb | 3293 | |
ff8f4401 RS |
3294 | static void |
3295 | output_constant_def_contents (exp, reloc, labelno) | |
3296 | tree exp; | |
3297 | int reloc; | |
3298 | int labelno; | |
3299 | { | |
3300 | int align; | |
3301 | ||
8a425a05 | 3302 | if (IN_NAMED_SECTION (exp)) |
ad4ff310 | 3303 | named_section (exp, NULL, reloc); |
8a425a05 DE |
3304 | else |
3305 | { | |
3306 | /* First switch to text section, except for writable strings. */ | |
79e68feb | 3307 | #ifdef SELECT_SECTION |
8a425a05 | 3308 | SELECT_SECTION (exp, reloc); |
79e68feb | 3309 | #else |
8a425a05 DE |
3310 | if (((TREE_CODE (exp) == STRING_CST) && flag_writable_strings) |
3311 | || (flag_pic && reloc)) | |
3312 | data_section (); | |
3313 | else | |
3314 | readonly_data_section (); | |
79e68feb | 3315 | #endif |
8a425a05 | 3316 | } |
79e68feb | 3317 | |
ff8f4401 RS |
3318 | /* Align the location counter as required by EXP's data type. */ |
3319 | align = TYPE_ALIGN (TREE_TYPE (exp)); | |
79e68feb | 3320 | #ifdef CONSTANT_ALIGNMENT |
ff8f4401 | 3321 | align = CONSTANT_ALIGNMENT (exp, align); |
79e68feb RS |
3322 | #endif |
3323 | ||
ff8f4401 | 3324 | if (align > BITS_PER_UNIT) |
b93a436e | 3325 | ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT)); |
79e68feb | 3326 | |
ff8f4401 RS |
3327 | /* Output the label itself. */ |
3328 | ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LC", labelno); | |
79e68feb | 3329 | |
ff8f4401 RS |
3330 | /* Output the value of EXP. */ |
3331 | output_constant (exp, | |
3332 | (TREE_CODE (exp) == STRING_CST | |
3333 | ? TREE_STRING_LENGTH (exp) | |
3334 | : int_size_in_bytes (TREE_TYPE (exp)))); | |
79e68feb | 3335 | |
79e68feb RS |
3336 | } |
3337 | \f | |
79e68feb RS |
3338 | /* Structure to represent sufficient information about a constant so that |
3339 | it can be output when the constant pool is output, so that function | |
3340 | integration can be done, and to simplify handling on machines that reference | |
3341 | constant pool as base+displacement. */ | |
3342 | ||
3343 | struct pool_constant | |
3344 | { | |
3345 | struct constant_descriptor *desc; | |
94b01be3 | 3346 | struct pool_constant *next, *next_sym; |
520a57c8 | 3347 | const char *label; |
79e68feb | 3348 | rtx constant; |
94b01be3 | 3349 | enum machine_mode mode; |
79e68feb RS |
3350 | int labelno; |
3351 | int align; | |
3352 | int offset; | |
91674c37 | 3353 | int mark; |
79e68feb RS |
3354 | }; |
3355 | ||
79e68feb RS |
3356 | /* Hash code for a SYMBOL_REF with CONSTANT_POOL_ADDRESS_P true. |
3357 | The argument is XSTR (... , 0) */ | |
3358 | ||
3359 | #define SYMHASH(LABEL) \ | |
7bcac048 | 3360 | ((((unsigned long) (LABEL)) & ((1 << HASHBITS) - 1)) % MAX_RTX_HASH_TABLE) |
79e68feb | 3361 | \f |
36edd3cc | 3362 | /* Initialize constant pool hashing for a new function. */ |
79e68feb RS |
3363 | |
3364 | void | |
36edd3cc BS |
3365 | init_varasm_status (f) |
3366 | struct function *f; | |
79e68feb | 3367 | { |
36edd3cc BS |
3368 | struct varasm_status *p; |
3369 | p = (struct varasm_status *) xmalloc (sizeof (struct varasm_status)); | |
3370 | f->varasm = p; | |
3371 | p->x_const_rtx_hash_table | |
57632c51 | 3372 | = ((struct constant_descriptor **) |
1f8f4a0b | 3373 | xcalloc (MAX_RTX_HASH_TABLE, sizeof (struct constant_descriptor *))); |
36edd3cc | 3374 | p->x_const_rtx_sym_hash_table |
94b01be3 JJ |
3375 | = ((struct pool_constant **) |
3376 | xcalloc (MAX_RTX_HASH_TABLE, sizeof (struct pool_constant *))); | |
79e68feb | 3377 | |
36edd3cc BS |
3378 | p->x_first_pool = p->x_last_pool = 0; |
3379 | p->x_pool_offset = 0; | |
3380 | p->x_const_double_chain = 0; | |
57632c51 | 3381 | } |
e2ecd91c | 3382 | |
87ff9c8e RH |
3383 | /* Mark PC for GC. */ |
3384 | ||
3385 | static void | |
3386 | mark_pool_constant (pc) | |
3387 | struct pool_constant *pc; | |
3388 | { | |
3389 | while (pc) | |
3390 | { | |
1f8f4a0b | 3391 | ggc_mark (pc); |
87ff9c8e RH |
3392 | ggc_mark_rtx (pc->constant); |
3393 | pc = pc->next; | |
3394 | } | |
3395 | } | |
3396 | ||
3397 | /* Mark P for GC. */ | |
3398 | ||
3399 | void | |
fa51b01b RH |
3400 | mark_varasm_status (p) |
3401 | struct varasm_status *p; | |
87ff9c8e | 3402 | { |
fa51b01b RH |
3403 | if (p == NULL) |
3404 | return; | |
3405 | ||
87ff9c8e RH |
3406 | mark_pool_constant (p->x_first_pool); |
3407 | ggc_mark_rtx (p->x_const_double_chain); | |
3408 | } | |
3409 | ||
21cd906e MM |
3410 | /* Clear out all parts of the state in F that can safely be discarded |
3411 | after the function has been compiled, to let garbage collection | |
0a8a198c | 3412 | reclaim the memory. */ |
21cd906e | 3413 | |
e2ecd91c | 3414 | void |
0a8a198c | 3415 | free_varasm_status (f) |
e2ecd91c BS |
3416 | struct function *f; |
3417 | { | |
21cd906e | 3418 | struct varasm_status *p; |
1f8f4a0b | 3419 | int i; |
21cd906e | 3420 | |
21cd906e | 3421 | p = f->varasm; |
1f8f4a0b MM |
3422 | |
3423 | /* Clear out the hash tables. */ | |
3424 | for (i = 0; i < MAX_RTX_HASH_TABLE; ++i) | |
3425 | { | |
3426 | struct constant_descriptor* cd; | |
1f8f4a0b MM |
3427 | |
3428 | cd = p->x_const_rtx_hash_table[i]; | |
3429 | while (cd) { | |
3430 | struct constant_descriptor* next = cd->next; | |
3431 | free (cd); | |
3432 | cd = next; | |
3433 | } | |
1f8f4a0b MM |
3434 | } |
3435 | ||
e2ecd91c BS |
3436 | free (p->x_const_rtx_hash_table); |
3437 | free (p->x_const_rtx_sym_hash_table); | |
fa51b01b RH |
3438 | free (p); |
3439 | f->varasm = NULL; | |
e2ecd91c | 3440 | } |
57632c51 | 3441 | \f |
79e68feb RS |
3442 | enum kind { RTX_DOUBLE, RTX_INT }; |
3443 | ||
79e68feb RS |
3444 | /* Express an rtx for a constant integer (perhaps symbolic) |
3445 | as the sum of a symbol or label plus an explicit integer. | |
3446 | They are stored into VALUE. */ | |
3447 | ||
3448 | static void | |
3449 | decode_rtx_const (mode, x, value) | |
3450 | enum machine_mode mode; | |
3451 | rtx x; | |
3452 | struct rtx_const *value; | |
3453 | { | |
3454 | /* Clear the whole structure, including any gaps. */ | |
da61dec9 | 3455 | memset (value, 0, sizeof (struct rtx_const)); |
79e68feb | 3456 | |
0f41302f | 3457 | value->kind = RTX_INT; /* Most usual kind. */ |
79e68feb RS |
3458 | value->mode = mode; |
3459 | ||
3460 | switch (GET_CODE (x)) | |
3461 | { | |
3462 | case CONST_DOUBLE: | |
3463 | value->kind = RTX_DOUBLE; | |
56e2d435 | 3464 | if (GET_MODE (x) != VOIDmode) |
0b19a5b9 RK |
3465 | { |
3466 | value->mode = GET_MODE (x); | |
da61dec9 JM |
3467 | memcpy ((char *) &value->un.du, |
3468 | (char *) &CONST_DOUBLE_LOW (x), sizeof value->un.du); | |
0b19a5b9 RK |
3469 | } |
3470 | else | |
3471 | { | |
3472 | value->un.di.low = CONST_DOUBLE_LOW (x); | |
3473 | value->un.di.high = CONST_DOUBLE_HIGH (x); | |
3474 | } | |
79e68feb RS |
3475 | break; |
3476 | ||
3477 | case CONST_INT: | |
3478 | value->un.addr.offset = INTVAL (x); | |
3479 | break; | |
3480 | ||
3481 | case SYMBOL_REF: | |
3482 | case LABEL_REF: | |
3d037392 | 3483 | case PC: |
79e68feb RS |
3484 | value->un.addr.base = x; |
3485 | break; | |
3486 | ||
3487 | case CONST: | |
3488 | x = XEXP (x, 0); | |
422be3c3 | 3489 | if (GET_CODE (x) == PLUS && GET_CODE (XEXP (x, 1)) == CONST_INT) |
79e68feb RS |
3490 | { |
3491 | value->un.addr.base = XEXP (x, 0); | |
79e68feb RS |
3492 | value->un.addr.offset = INTVAL (XEXP (x, 1)); |
3493 | } | |
422be3c3 | 3494 | else if (GET_CODE (x) == MINUS && GET_CODE (XEXP (x, 1)) == CONST_INT) |
79e68feb RS |
3495 | { |
3496 | value->un.addr.base = XEXP (x, 0); | |
79e68feb RS |
3497 | value->un.addr.offset = - INTVAL (XEXP (x, 1)); |
3498 | } | |
3499 | else | |
422be3c3 AO |
3500 | { |
3501 | value->un.addr.base = x; | |
3502 | value->un.addr.offset = 0; | |
3503 | } | |
79e68feb RS |
3504 | break; |
3505 | ||
3506 | default: | |
3507 | abort (); | |
3508 | } | |
3509 | ||
3510 | if (value->kind == RTX_INT && value->un.addr.base != 0) | |
3511 | switch (GET_CODE (value->un.addr.base)) | |
3512 | { | |
3513 | case SYMBOL_REF: | |
79e68feb | 3514 | /* Use the string's address, not the SYMBOL_REF's address, |
241a1bcc | 3515 | for the sake of addresses of library routines. */ |
dd1bd863 | 3516 | value->un.addr.base = (rtx) XSTR (value->un.addr.base, 0); |
241a1bcc FS |
3517 | break; |
3518 | ||
3519 | case LABEL_REF: | |
3520 | /* For a LABEL_REF, compare labels. */ | |
79e68feb | 3521 | value->un.addr.base = XEXP (value->un.addr.base, 0); |
e9a25f70 JL |
3522 | |
3523 | default: | |
3524 | break; | |
79e68feb RS |
3525 | } |
3526 | } | |
3527 | ||
57632c51 RS |
3528 | /* Given a MINUS expression, simplify it if both sides |
3529 | include the same symbol. */ | |
3530 | ||
3531 | rtx | |
3532 | simplify_subtraction (x) | |
3533 | rtx x; | |
3534 | { | |
3535 | struct rtx_const val0, val1; | |
3536 | ||
3537 | decode_rtx_const (GET_MODE (x), XEXP (x, 0), &val0); | |
3538 | decode_rtx_const (GET_MODE (x), XEXP (x, 1), &val1); | |
3539 | ||
3540 | if (val0.un.addr.base == val1.un.addr.base) | |
3541 | return GEN_INT (val0.un.addr.offset - val1.un.addr.offset); | |
3542 | return x; | |
3543 | } | |
3544 | ||
79e68feb RS |
3545 | /* Compute a hash code for a constant RTL expression. */ |
3546 | ||
5a13eaa4 | 3547 | static int |
79e68feb RS |
3548 | const_hash_rtx (mode, x) |
3549 | enum machine_mode mode; | |
3550 | rtx x; | |
3551 | { | |
f8344bea MH |
3552 | register int hi; |
3553 | register size_t i; | |
79e68feb RS |
3554 | |
3555 | struct rtx_const value; | |
3556 | decode_rtx_const (mode, x, &value); | |
3557 | ||
3558 | /* Compute hashing function */ | |
3559 | hi = 0; | |
3560 | for (i = 0; i < sizeof value / sizeof (int); i++) | |
3561 | hi += ((int *) &value)[i]; | |
3562 | ||
3563 | hi &= (1 << HASHBITS) - 1; | |
3564 | hi %= MAX_RTX_HASH_TABLE; | |
3565 | return hi; | |
3566 | } | |
3567 | ||
3568 | /* Compare a constant rtl object X with a constant-descriptor DESC. | |
3569 | Return 1 if DESC describes a constant with the same value as X. */ | |
3570 | ||
3571 | static int | |
3572 | compare_constant_rtx (mode, x, desc) | |
3573 | enum machine_mode mode; | |
3574 | rtx x; | |
3575 | struct constant_descriptor *desc; | |
3576 | { | |
37357796 | 3577 | register int *p = (int *) desc->u.contents; |
79e68feb RS |
3578 | register int *strp; |
3579 | register int len; | |
3580 | struct rtx_const value; | |
3581 | ||
3582 | decode_rtx_const (mode, x, &value); | |
3583 | strp = (int *) &value; | |
3584 | len = sizeof value / sizeof (int); | |
3585 | ||
3586 | /* Compare constant contents. */ | |
3587 | while (--len >= 0) | |
3588 | if (*p++ != *strp++) | |
3589 | return 0; | |
3590 | ||
3591 | return 1; | |
3592 | } | |
3593 | ||
3594 | /* Construct a constant descriptor for the rtl-expression X. | |
3595 | It is up to the caller to enter the descriptor in the hash table. */ | |
3596 | ||
3597 | static struct constant_descriptor * | |
3598 | record_constant_rtx (mode, x) | |
3599 | enum machine_mode mode; | |
3600 | rtx x; | |
3601 | { | |
3602 | struct constant_descriptor *ptr; | |
79e68feb | 3603 | |
1f8f4a0b | 3604 | ptr = ((struct constant_descriptor *) |
37357796 RE |
3605 | xcalloc (1, (offsetof (struct constant_descriptor, u) |
3606 | + sizeof (struct rtx_const)))); | |
3607 | decode_rtx_const (mode, x, (struct rtx_const *) ptr->u.contents); | |
79e68feb | 3608 | |
1f8f4a0b | 3609 | return ptr; |
79e68feb RS |
3610 | } |
3611 | \f | |
3612 | /* Given a constant rtx X, make (or find) a memory constant for its value | |
3613 | and return a MEM rtx to refer to it in memory. */ | |
3614 | ||
3615 | rtx | |
3616 | force_const_mem (mode, x) | |
3617 | enum machine_mode mode; | |
3618 | rtx x; | |
3619 | { | |
3620 | register int hash; | |
3621 | register struct constant_descriptor *desc; | |
3622 | char label[256]; | |
520a57c8 | 3623 | const char *found = 0; |
79e68feb RS |
3624 | rtx def; |
3625 | ||
3626 | /* If we want this CONST_DOUBLE in the same mode as it is in memory | |
3627 | (this will always be true for floating CONST_DOUBLEs that have been | |
3628 | placed in memory, but not for VOIDmode (integer) CONST_DOUBLEs), | |
3629 | use the previous copy. Otherwise, make a new one. Note that in | |
3630 | the unlikely event that this same CONST_DOUBLE is used in two different | |
3631 | modes in an alternating fashion, we will allocate a lot of different | |
3632 | memory locations, but this should be extremely rare. */ | |
3633 | ||
36edd3cc BS |
3634 | if (GET_CODE (x) == CONST_DOUBLE |
3635 | && GET_CODE (CONST_DOUBLE_MEM (x)) == MEM | |
3636 | && GET_MODE (CONST_DOUBLE_MEM (x)) == mode) | |
3637 | return CONST_DOUBLE_MEM (x); | |
79e68feb RS |
3638 | |
3639 | /* Compute hash code of X. Search the descriptors for that hash code | |
3640 | to see if any of them describes X. If yes, the descriptor records | |
3641 | the label number already assigned. */ | |
3642 | ||
3643 | hash = const_hash_rtx (mode, x); | |
3644 | ||
3645 | for (desc = const_rtx_hash_table[hash]; desc; desc = desc->next) | |
3646 | if (compare_constant_rtx (mode, x, desc)) | |
3647 | { | |
3648 | found = desc->label; | |
3649 | break; | |
3650 | } | |
3651 | ||
3652 | if (found == 0) | |
3653 | { | |
3654 | register struct pool_constant *pool; | |
79e68feb RS |
3655 | int align; |
3656 | ||
3657 | /* No constant equal to X is known to have been output. | |
3658 | Make a constant descriptor to enter X in the hash table. | |
3659 | Assign the label number and record it in the descriptor for | |
3660 | future calls to this function to find. */ | |
3661 | ||
3662 | desc = record_constant_rtx (mode, x); | |
3663 | desc->next = const_rtx_hash_table[hash]; | |
3664 | const_rtx_hash_table[hash] = desc; | |
3665 | ||
3666 | /* Align the location counter as required by EXP's data type. */ | |
3667 | align = (mode == VOIDmode) ? UNITS_PER_WORD : GET_MODE_SIZE (mode); | |
3668 | if (align > BIGGEST_ALIGNMENT / BITS_PER_UNIT) | |
3669 | align = BIGGEST_ALIGNMENT / BITS_PER_UNIT; | |
e5e8a8bf JW |
3670 | #ifdef CONSTANT_ALIGNMENT |
3671 | align = CONSTANT_ALIGNMENT (make_tree (type_for_mode (mode, 0), x), | |
3672 | align * BITS_PER_UNIT) / BITS_PER_UNIT; | |
3673 | #endif | |
79e68feb RS |
3674 | |
3675 | pool_offset += align - 1; | |
3676 | pool_offset &= ~ (align - 1); | |
3677 | ||
3678 | /* Allocate a pool constant descriptor, fill it in, and chain it in. */ | |
3679 | ||
1f8f4a0b | 3680 | pool = (struct pool_constant *) ggc_alloc (sizeof (struct pool_constant)); |
79e68feb RS |
3681 | pool->desc = desc; |
3682 | pool->constant = x; | |
3683 | pool->mode = mode; | |
3684 | pool->labelno = const_labelno; | |
3685 | pool->align = align; | |
3686 | pool->offset = pool_offset; | |
d2ce9169 | 3687 | pool->mark = 1; |
79e68feb RS |
3688 | pool->next = 0; |
3689 | ||
3690 | if (last_pool == 0) | |
3691 | first_pool = pool; | |
3692 | else | |
3693 | last_pool->next = pool; | |
3694 | ||
3695 | last_pool = pool; | |
3696 | pool_offset += GET_MODE_SIZE (mode); | |
3697 | ||
3698 | /* Create a string containing the label name, in LABEL. */ | |
3699 | ASM_GENERATE_INTERNAL_LABEL (label, "LC", const_labelno); | |
3700 | ||
3701 | ++const_labelno; | |
3702 | ||
a8a05998 | 3703 | desc->label = found = ggc_strdup (label); |
79e68feb RS |
3704 | |
3705 | /* Add label to symbol hash table. */ | |
3706 | hash = SYMHASH (found); | |
94b01be3 JJ |
3707 | pool->label = found; |
3708 | pool->next_sym = const_rtx_sym_hash_table[hash]; | |
3709 | const_rtx_sym_hash_table[hash] = pool; | |
79e68feb RS |
3710 | } |
3711 | ||
3712 | /* We have a symbol name; construct the SYMBOL_REF and the MEM. */ | |
3713 | ||
38a448ca | 3714 | def = gen_rtx_MEM (mode, gen_rtx_SYMBOL_REF (Pmode, found)); |
289c5b45 | 3715 | set_mem_attributes (def, type_for_mode (mode, 0), 1); |
79e68feb | 3716 | RTX_UNCHANGING_P (def) = 1; |
289c5b45 | 3717 | |
79e68feb RS |
3718 | /* Mark the symbol_ref as belonging to this constants pool. */ |
3719 | CONSTANT_POOL_ADDRESS_P (XEXP (def, 0)) = 1; | |
3720 | current_function_uses_const_pool = 1; | |
3721 | ||
36edd3cc BS |
3722 | if (GET_CODE (x) == CONST_DOUBLE) |
3723 | { | |
3724 | if (CONST_DOUBLE_MEM (x) == cc0_rtx) | |
3725 | { | |
3726 | CONST_DOUBLE_CHAIN (x) = const_double_chain; | |
3727 | const_double_chain = x; | |
3728 | } | |
3729 | CONST_DOUBLE_MEM (x) = def; | |
3730 | } | |
79e68feb RS |
3731 | |
3732 | return def; | |
3733 | } | |
3734 | \f | |
3735 | /* Given a SYMBOL_REF with CONSTANT_POOL_ADDRESS_P true, return a pointer to | |
3736 | the corresponding pool_constant structure. */ | |
3737 | ||
3738 | static struct pool_constant * | |
36edd3cc BS |
3739 | find_pool_constant (f, addr) |
3740 | struct function *f; | |
79e68feb RS |
3741 | rtx addr; |
3742 | { | |
94b01be3 | 3743 | struct pool_constant *pool; |
3cce094d | 3744 | const char *label = XSTR (addr, 0); |
79e68feb | 3745 | |
94b01be3 JJ |
3746 | for (pool = f->varasm->x_const_rtx_sym_hash_table[SYMHASH (label)]; pool; |
3747 | pool = pool->next_sym) | |
3748 | if (pool->label == label) | |
3749 | return pool; | |
79e68feb RS |
3750 | |
3751 | abort (); | |
3752 | } | |
3753 | ||
3754 | /* Given a constant pool SYMBOL_REF, return the corresponding constant. */ | |
3755 | ||
3756 | rtx | |
3757 | get_pool_constant (addr) | |
3758 | rtx addr; | |
3759 | { | |
01d939e8 | 3760 | return (find_pool_constant (cfun, addr))->constant; |
36edd3cc BS |
3761 | } |
3762 | ||
3763 | /* Likewise, but for the constant pool of a specific function. */ | |
3764 | ||
3765 | rtx | |
3766 | get_pool_constant_for_function (f, addr) | |
3767 | struct function *f; | |
3768 | rtx addr; | |
3769 | { | |
3770 | return (find_pool_constant (f, addr))->constant; | |
79e68feb RS |
3771 | } |
3772 | ||
3773 | /* Similar, return the mode. */ | |
3774 | ||
3775 | enum machine_mode | |
3776 | get_pool_mode (addr) | |
3777 | rtx addr; | |
3778 | { | |
01d939e8 | 3779 | return (find_pool_constant (cfun, addr))->mode; |
36edd3cc BS |
3780 | } |
3781 | ||
3782 | enum machine_mode | |
3783 | get_pool_mode_for_function (f, addr) | |
3784 | struct function *f; | |
3785 | rtx addr; | |
3786 | { | |
3787 | return (find_pool_constant (f, addr))->mode; | |
79e68feb RS |
3788 | } |
3789 | ||
3790 | /* Similar, return the offset in the constant pool. */ | |
3791 | ||
3792 | int | |
3793 | get_pool_offset (addr) | |
3794 | rtx addr; | |
3795 | { | |
01d939e8 | 3796 | return (find_pool_constant (cfun, addr))->offset; |
79e68feb RS |
3797 | } |
3798 | ||
3799 | /* Return the size of the constant pool. */ | |
3800 | ||
3801 | int | |
3802 | get_pool_size () | |
3803 | { | |
3804 | return pool_offset; | |
3805 | } | |
3806 | \f | |
3807 | /* Write all the constants in the constant pool. */ | |
3808 | ||
3809 | void | |
3810 | output_constant_pool (fnname, fndecl) | |
d9bba9c3 | 3811 | const char *fnname ATTRIBUTE_UNUSED; |
c84e2712 | 3812 | tree fndecl ATTRIBUTE_UNUSED; |
79e68feb RS |
3813 | { |
3814 | struct pool_constant *pool; | |
3815 | rtx x; | |
3816 | union real_extract u; | |
3817 | ||
91674c37 ILT |
3818 | /* It is possible for gcc to call force_const_mem and then to later |
3819 | discard the instructions which refer to the constant. In such a | |
3820 | case we do not need to output the constant. */ | |
8f0e7be4 | 3821 | mark_constant_pool (); |
91674c37 | 3822 | |
79e68feb RS |
3823 | #ifdef ASM_OUTPUT_POOL_PROLOGUE |
3824 | ASM_OUTPUT_POOL_PROLOGUE (asm_out_file, fnname, fndecl, pool_offset); | |
3825 | #endif | |
3826 | ||
3827 | for (pool = first_pool; pool; pool = pool->next) | |
3828 | { | |
085ce8c6 RH |
3829 | rtx tmp; |
3830 | ||
79e68feb RS |
3831 | x = pool->constant; |
3832 | ||
d2ce9169 | 3833 | if (! pool->mark) |
91674c37 ILT |
3834 | continue; |
3835 | ||
79e68feb RS |
3836 | /* See if X is a LABEL_REF (or a CONST referring to a LABEL_REF) |
3837 | whose CODE_LABEL has been deleted. This can occur if a jump table | |
3838 | is eliminated by optimization. If so, write a constant of zero | |
7b2b3f1f RK |
3839 | instead. Note that this can also happen by turning the |
3840 | CODE_LABEL into a NOTE. */ | |
085ce8c6 RH |
3841 | /* ??? This seems completely and utterly wrong. Certainly it's |
3842 | not true for NOTE_INSN_DELETED_LABEL, but I disbelieve proper | |
3843 | functioning even with INSN_DELETED_P and friends. */ | |
3844 | ||
3845 | tmp = x; | |
3846 | switch (GET_CODE (x)) | |
3847 | { | |
3848 | case CONST: | |
3849 | if (GET_CODE (XEXP (x, 0)) != PLUS | |
3850 | || GET_CODE (XEXP (XEXP (x, 0), 0)) != LABEL_REF) | |
3851 | break; | |
3852 | tmp = XEXP (XEXP (x, 0), 0); | |
3853 | /* FALLTHRU */ | |
3854 | ||
3855 | case LABEL_REF: | |
3856 | tmp = XEXP (x, 0); | |
3857 | if (INSN_DELETED_P (tmp) | |
3858 | || (GET_CODE (tmp) == NOTE | |
3859 | && NOTE_LINE_NUMBER (tmp) == NOTE_INSN_DELETED)) | |
3860 | { | |
3861 | abort (); | |
3862 | x = const0_rtx; | |
3863 | } | |
3864 | break; | |
3865 | ||
3866 | default: | |
3867 | break; | |
3868 | } | |
79e68feb RS |
3869 | |
3870 | /* First switch to correct section. */ | |
3871 | #ifdef SELECT_RTX_SECTION | |
3872 | SELECT_RTX_SECTION (pool->mode, x); | |
3873 | #else | |
3874 | readonly_data_section (); | |
3875 | #endif | |
3876 | ||
3877 | #ifdef ASM_OUTPUT_SPECIAL_POOL_ENTRY | |
3878 | ASM_OUTPUT_SPECIAL_POOL_ENTRY (asm_out_file, x, pool->mode, | |
3879 | pool->align, pool->labelno, done); | |
3880 | #endif | |
3881 | ||
3882 | if (pool->align > 1) | |
0003feb2 | 3883 | ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (pool->align)); |
79e68feb RS |
3884 | |
3885 | /* Output the label. */ | |
3886 | ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LC", pool->labelno); | |
3887 | ||
3888 | /* Output the value of the constant itself. */ | |
3889 | switch (GET_MODE_CLASS (pool->mode)) | |
3890 | { | |
3891 | case MODE_FLOAT: | |
3892 | if (GET_CODE (x) != CONST_DOUBLE) | |
3893 | abort (); | |
3894 | ||
da61dec9 | 3895 | memcpy ((char *) &u, (char *) &CONST_DOUBLE_LOW (x), sizeof u); |
79e68feb RS |
3896 | assemble_real (u.d, pool->mode); |
3897 | break; | |
3898 | ||
3899 | case MODE_INT: | |
ab8ab9d0 | 3900 | case MODE_PARTIAL_INT: |
79e68feb RS |
3901 | assemble_integer (x, GET_MODE_SIZE (pool->mode), 1); |
3902 | break; | |
3903 | ||
3904 | default: | |
3905 | abort (); | |
3906 | } | |
3907 | ||
29a82058 JL |
3908 | #ifdef ASM_OUTPUT_SPECIAL_POOL_ENTRY |
3909 | done: ; | |
3910 | #endif | |
3911 | ||
7f83c0e7 JL |
3912 | } |
3913 | ||
5c8c0abd ILT |
3914 | #ifdef ASM_OUTPUT_POOL_EPILOGUE |
3915 | ASM_OUTPUT_POOL_EPILOGUE (asm_out_file, fnname, fndecl, pool_offset); | |
3916 | #endif | |
3917 | ||
79e68feb RS |
3918 | /* Done with this pool. */ |
3919 | first_pool = last_pool = 0; | |
3920 | } | |
91674c37 ILT |
3921 | |
3922 | /* Look through the instructions for this function, and mark all the | |
3923 | entries in the constant pool which are actually being used. */ | |
3924 | ||
3925 | static void | |
3926 | mark_constant_pool () | |
3927 | { | |
3928 | register rtx insn; | |
d2ce9169 | 3929 | struct pool_constant *pool; |
91674c37 | 3930 | |
bd7cf17e | 3931 | if (first_pool == 0 && htab_elements (const_str_htab) == 0) |
91674c37 ILT |
3932 | return; |
3933 | ||
d2ce9169 RK |
3934 | for (pool = first_pool; pool; pool = pool->next) |
3935 | pool->mark = 0; | |
3936 | ||
91674c37 | 3937 | for (insn = get_insns (); insn; insn = NEXT_INSN (insn)) |
2c3c49de | 3938 | if (INSN_P (insn)) |
91674c37 ILT |
3939 | mark_constants (PATTERN (insn)); |
3940 | ||
3941 | for (insn = current_function_epilogue_delay_list; | |
3942 | insn; | |
3943 | insn = XEXP (insn, 1)) | |
2c3c49de | 3944 | if (INSN_P (insn)) |
91674c37 | 3945 | mark_constants (PATTERN (insn)); |
0e3df013 CB |
3946 | |
3947 | /* It's possible that the only reference to a symbol is in a symbol | |
3948 | that's in the constant pool. This happens in Fortran under some | |
3949 | situations. (When the constant contains the address of another | |
3950 | constant, and only the first is used directly in an insn.) | |
3951 | This is potentially suboptimal if there's ever a possibility of | |
3952 | backwards (in pool order) 2'd level references. However, it's | |
3953 | not clear that 2'd level references can happen. */ | |
3954 | for (pool = first_pool; pool; pool = pool->next) | |
3955 | { | |
94b01be3 | 3956 | struct pool_constant *tem; |
3cce094d | 3957 | const char *label; |
0e3df013 CB |
3958 | |
3959 | /* skip unmarked entries; no insn refers to them. */ | |
3960 | if (!pool->mark) | |
3961 | continue; | |
3962 | ||
6b7ef0e0 JL |
3963 | /* Skip everything except SYMBOL_REFs. */ |
3964 | if (GET_CODE (pool->constant) != SYMBOL_REF) | |
ef178af3 | 3965 | continue; |
0e3df013 CB |
3966 | label = XSTR (pool->constant, 0); |
3967 | ||
3968 | /* Be sure the symbol's value is marked. */ | |
94b01be3 JJ |
3969 | for (tem = const_rtx_sym_hash_table[SYMHASH (label)]; tem; |
3970 | tem = tem->next) | |
3971 | if (tem->label == label) | |
3972 | tem->mark = 1; | |
0e3df013 CB |
3973 | /* If we didn't find it, there's something truly wrong here, but it |
3974 | will be announced by the assembler. */ | |
3975 | } | |
91674c37 ILT |
3976 | } |
3977 | ||
3978 | static void | |
3979 | mark_constants (x) | |
3980 | register rtx x; | |
3981 | { | |
3982 | register int i; | |
6f7d635c | 3983 | register const char *format_ptr; |
91674c37 ILT |
3984 | |
3985 | if (x == 0) | |
3986 | return; | |
3987 | ||
3988 | if (GET_CODE (x) == SYMBOL_REF) | |
3989 | { | |
3990 | if (CONSTANT_POOL_ADDRESS_P (x)) | |
01d939e8 | 3991 | find_pool_constant (cfun, x)->mark = 1; |
bd7cf17e JJ |
3992 | else if (STRING_POOL_ADDRESS_P (x)) |
3993 | { | |
3994 | struct deferred_string **defstr; | |
3995 | ||
3996 | defstr = (struct deferred_string **) | |
3997 | htab_find_slot_with_hash (const_str_htab, XSTR (x, 0), | |
3998 | STRHASH (XSTR (x, 0)), NO_INSERT); | |
3999 | if (defstr) | |
4000 | { | |
4001 | struct deferred_string *p = *defstr; | |
4002 | ||
4003 | STRING_POOL_ADDRESS_P (x) = 0; | |
4004 | output_constant_def_contents (p->exp, 0, p->labelno); | |
4005 | htab_clear_slot (const_str_htab, (void **) defstr); | |
4006 | } | |
4007 | } | |
91674c37 ILT |
4008 | return; |
4009 | } | |
eb7b11fd | 4010 | /* Never search inside a CONST_DOUBLE, because CONST_DOUBLE_MEM may be |
36edd3cc | 4011 | a MEM, but does not constitute a use of that MEM. */ |
eb7b11fd JW |
4012 | else if (GET_CODE (x) == CONST_DOUBLE) |
4013 | return; | |
91674c37 ILT |
4014 | |
4015 | /* Insns may appear inside a SEQUENCE. Only check the patterns of | |
4016 | insns, not any notes that may be attached. We don't want to mark | |
4017 | a constant just because it happens to appear in a REG_EQUIV note. */ | |
2c3c49de | 4018 | if (INSN_P (x)) |
91674c37 ILT |
4019 | { |
4020 | mark_constants (PATTERN (x)); | |
4021 | return; | |
4022 | } | |
4023 | ||
4024 | format_ptr = GET_RTX_FORMAT (GET_CODE (x)); | |
4025 | ||
4026 | for (i = 0; i < GET_RTX_LENGTH (GET_CODE (x)); i++) | |
4027 | { | |
4028 | switch (*format_ptr++) | |
4029 | { | |
4030 | case 'e': | |
4031 | mark_constants (XEXP (x, i)); | |
4032 | break; | |
4033 | ||
4034 | case 'E': | |
4035 | if (XVEC (x, i) != 0) | |
4036 | { | |
4037 | register int j; | |
4038 | ||
4039 | for (j = 0; j < XVECLEN (x, i); j++) | |
4040 | mark_constants (XVECEXP (x, i, j)); | |
4041 | } | |
4042 | break; | |
4043 | ||
4044 | case 'S': | |
4045 | case 's': | |
4046 | case '0': | |
4047 | case 'i': | |
4048 | case 'w': | |
4049 | case 'n': | |
4050 | case 'u': | |
4051 | break; | |
4052 | ||
4053 | default: | |
4054 | abort (); | |
4055 | } | |
4056 | } | |
4057 | } | |
79e68feb RS |
4058 | \f |
4059 | /* Find all the constants whose addresses are referenced inside of EXP, | |
4060 | and make sure assembler code with a label has been output for each one. | |
4061 | Indicate whether an ADDR_EXPR has been encountered. */ | |
4062 | ||
5a13eaa4 | 4063 | static int |
79e68feb RS |
4064 | output_addressed_constants (exp) |
4065 | tree exp; | |
4066 | { | |
4067 | int reloc = 0; | |
4068 | ||
c165f94f CC |
4069 | /* Give the front-end a chance to convert VALUE to something that |
4070 | looks more like a constant to the back-end. */ | |
4071 | if (lang_expand_constant) | |
4072 | exp = (*lang_expand_constant) (exp); | |
4073 | ||
79e68feb RS |
4074 | switch (TREE_CODE (exp)) |
4075 | { | |
4076 | case ADDR_EXPR: | |
4077 | { | |
4078 | register tree constant = TREE_OPERAND (exp, 0); | |
4079 | ||
4080 | while (TREE_CODE (constant) == COMPONENT_REF) | |
4081 | { | |
4082 | constant = TREE_OPERAND (constant, 0); | |
4083 | } | |
4084 | ||
4085 | if (TREE_CODE_CLASS (TREE_CODE (constant)) == 'c' | |
4086 | || TREE_CODE (constant) == CONSTRUCTOR) | |
4087 | /* No need to do anything here | |
4088 | for addresses of variables or functions. */ | |
bd7cf17e | 4089 | output_constant_def (constant, 0); |
79e68feb RS |
4090 | } |
4091 | reloc = 1; | |
4092 | break; | |
4093 | ||
4094 | case PLUS_EXPR: | |
4095 | case MINUS_EXPR: | |
4096 | reloc = output_addressed_constants (TREE_OPERAND (exp, 0)); | |
4097 | reloc |= output_addressed_constants (TREE_OPERAND (exp, 1)); | |
4098 | break; | |
4099 | ||
4100 | case NOP_EXPR: | |
4101 | case CONVERT_EXPR: | |
37a52112 | 4102 | case NON_LVALUE_EXPR: |
79e68feb RS |
4103 | reloc = output_addressed_constants (TREE_OPERAND (exp, 0)); |
4104 | break; | |
4105 | ||
4106 | case CONSTRUCTOR: | |
4107 | { | |
4108 | register tree link; | |
4109 | for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link)) | |
4110 | if (TREE_VALUE (link) != 0) | |
4111 | reloc |= output_addressed_constants (TREE_VALUE (link)); | |
4112 | } | |
4113 | break; | |
4114 | ||
e9a25f70 | 4115 | default: |
79e68feb RS |
4116 | break; |
4117 | } | |
4118 | return reloc; | |
4119 | } | |
4120 | \f | |
14a774a9 RK |
4121 | /* Return nonzero if VALUE is a valid constant-valued expression |
4122 | for use in initializing a static variable; one that can be an | |
4123 | element of a "constant" initializer. | |
4124 | ||
4125 | Return null_pointer_node if the value is absolute; | |
4126 | if it is relocatable, return the variable that determines the relocation. | |
4127 | We assume that VALUE has been folded as much as possible; | |
4128 | therefore, we do not need to check for such things as | |
4129 | arithmetic-combinations of integers. */ | |
4130 | ||
4131 | tree | |
4132 | initializer_constant_valid_p (value, endtype) | |
4133 | tree value; | |
4134 | tree endtype; | |
4135 | { | |
99740276 MM |
4136 | /* Give the front-end a chance to convert VALUE to something that |
4137 | looks more like a constant to the back-end. */ | |
4138 | if (lang_expand_constant) | |
4139 | value = (*lang_expand_constant) (value); | |
4140 | ||
14a774a9 RK |
4141 | switch (TREE_CODE (value)) |
4142 | { | |
4143 | case CONSTRUCTOR: | |
4144 | if ((TREE_CODE (TREE_TYPE (value)) == UNION_TYPE | |
4145 | || TREE_CODE (TREE_TYPE (value)) == RECORD_TYPE) | |
4146 | && TREE_CONSTANT (value) | |
4147 | && CONSTRUCTOR_ELTS (value)) | |
4148 | return | |
4149 | initializer_constant_valid_p (TREE_VALUE (CONSTRUCTOR_ELTS (value)), | |
4150 | endtype); | |
4151 | ||
4152 | return TREE_STATIC (value) ? null_pointer_node : 0; | |
4153 | ||
4154 | case INTEGER_CST: | |
4155 | case REAL_CST: | |
4156 | case STRING_CST: | |
4157 | case COMPLEX_CST: | |
4158 | return null_pointer_node; | |
4159 | ||
4160 | case ADDR_EXPR: | |
8c8de5fc | 4161 | return staticp (TREE_OPERAND (value, 0)) ? TREE_OPERAND (value, 0) : 0; |
14a774a9 RK |
4162 | |
4163 | case NON_LVALUE_EXPR: | |
4164 | return initializer_constant_valid_p (TREE_OPERAND (value, 0), endtype); | |
4165 | ||
4166 | case CONVERT_EXPR: | |
4167 | case NOP_EXPR: | |
4168 | /* Allow conversions between pointer types. */ | |
4169 | if (POINTER_TYPE_P (TREE_TYPE (value)) | |
4170 | && POINTER_TYPE_P (TREE_TYPE (TREE_OPERAND (value, 0)))) | |
4171 | return initializer_constant_valid_p (TREE_OPERAND (value, 0), endtype); | |
4172 | ||
4173 | /* Allow conversions between real types. */ | |
4174 | if (FLOAT_TYPE_P (TREE_TYPE (value)) | |
4175 | && FLOAT_TYPE_P (TREE_TYPE (TREE_OPERAND (value, 0)))) | |
4176 | return initializer_constant_valid_p (TREE_OPERAND (value, 0), endtype); | |
4177 | ||
4178 | /* Allow length-preserving conversions between integer types. */ | |
4179 | if (INTEGRAL_TYPE_P (TREE_TYPE (value)) | |
4180 | && INTEGRAL_TYPE_P (TREE_TYPE (TREE_OPERAND (value, 0))) | |
4181 | && (TYPE_PRECISION (TREE_TYPE (value)) | |
4182 | == TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (value, 0))))) | |
4183 | return initializer_constant_valid_p (TREE_OPERAND (value, 0), endtype); | |
4184 | ||
4185 | /* Allow conversions between other integer types only if | |
4186 | explicit value. */ | |
4187 | if (INTEGRAL_TYPE_P (TREE_TYPE (value)) | |
4188 | && INTEGRAL_TYPE_P (TREE_TYPE (TREE_OPERAND (value, 0)))) | |
4189 | { | |
4190 | tree inner = initializer_constant_valid_p (TREE_OPERAND (value, 0), | |
4191 | endtype); | |
4192 | if (inner == null_pointer_node) | |
4193 | return null_pointer_node; | |
4194 | break; | |
4195 | } | |
4196 | ||
4197 | /* Allow (int) &foo provided int is as wide as a pointer. */ | |
4198 | if (INTEGRAL_TYPE_P (TREE_TYPE (value)) | |
4199 | && POINTER_TYPE_P (TREE_TYPE (TREE_OPERAND (value, 0))) | |
4200 | && (TYPE_PRECISION (TREE_TYPE (value)) | |
4201 | >= TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (value, 0))))) | |
4202 | return initializer_constant_valid_p (TREE_OPERAND (value, 0), | |
4203 | endtype); | |
4204 | ||
4205 | /* Likewise conversions from int to pointers, but also allow | |
4206 | conversions from 0. */ | |
4207 | if (POINTER_TYPE_P (TREE_TYPE (value)) | |
4208 | && INTEGRAL_TYPE_P (TREE_TYPE (TREE_OPERAND (value, 0)))) | |
4209 | { | |
4210 | if (integer_zerop (TREE_OPERAND (value, 0))) | |
4211 | return null_pointer_node; | |
4212 | else if (TYPE_PRECISION (TREE_TYPE (value)) | |
4213 | <= TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (value, 0)))) | |
4214 | return initializer_constant_valid_p (TREE_OPERAND (value, 0), | |
4215 | endtype); | |
4216 | } | |
4217 | ||
4218 | /* Allow conversions to union types if the value inside is okay. */ | |
4219 | if (TREE_CODE (TREE_TYPE (value)) == UNION_TYPE) | |
4220 | return initializer_constant_valid_p (TREE_OPERAND (value, 0), | |
4221 | endtype); | |
4222 | break; | |
4223 | ||
4224 | case PLUS_EXPR: | |
4225 | if (! INTEGRAL_TYPE_P (endtype) | |
4226 | || TYPE_PRECISION (endtype) >= POINTER_SIZE) | |
4227 | { | |
4228 | tree valid0 = initializer_constant_valid_p (TREE_OPERAND (value, 0), | |
4229 | endtype); | |
4230 | tree valid1 = initializer_constant_valid_p (TREE_OPERAND (value, 1), | |
4231 | endtype); | |
4232 | /* If either term is absolute, use the other terms relocation. */ | |
4233 | if (valid0 == null_pointer_node) | |
4234 | return valid1; | |
4235 | if (valid1 == null_pointer_node) | |
4236 | return valid0; | |
4237 | } | |
4238 | break; | |
4239 | ||
4240 | case MINUS_EXPR: | |
4241 | if (! INTEGRAL_TYPE_P (endtype) | |
4242 | || TYPE_PRECISION (endtype) >= POINTER_SIZE) | |
4243 | { | |
4244 | tree valid0 = initializer_constant_valid_p (TREE_OPERAND (value, 0), | |
4245 | endtype); | |
4246 | tree valid1 = initializer_constant_valid_p (TREE_OPERAND (value, 1), | |
4247 | endtype); | |
4248 | /* Win if second argument is absolute. */ | |
4249 | if (valid1 == null_pointer_node) | |
4250 | return valid0; | |
4251 | /* Win if both arguments have the same relocation. | |
4252 | Then the value is absolute. */ | |
4253 | if (valid0 == valid1 && valid0 != 0) | |
4254 | return null_pointer_node; | |
4255 | } | |
4256 | ||
4257 | /* Support differences between labels. */ | |
4258 | if (INTEGRAL_TYPE_P (endtype)) | |
4259 | { | |
4260 | tree op0, op1; | |
4261 | op0 = TREE_OPERAND (value, 0); | |
4262 | op1 = TREE_OPERAND (value, 1); | |
4263 | STRIP_NOPS (op0); | |
4264 | STRIP_NOPS (op1); | |
4265 | ||
4266 | if (TREE_CODE (op0) == ADDR_EXPR | |
4267 | && TREE_CODE (TREE_OPERAND (op0, 0)) == LABEL_DECL | |
4268 | && TREE_CODE (op1) == ADDR_EXPR | |
4269 | && TREE_CODE (TREE_OPERAND (op1, 0)) == LABEL_DECL) | |
4270 | return null_pointer_node; | |
4271 | } | |
4272 | break; | |
4273 | ||
4274 | default: | |
4275 | break; | |
4276 | } | |
4277 | ||
4278 | return 0; | |
4279 | } | |
4280 | \f | |
79e68feb RS |
4281 | /* Output assembler code for constant EXP to FILE, with no label. |
4282 | This includes the pseudo-op such as ".int" or ".byte", and a newline. | |
4283 | Assumes output_addressed_constants has been done on EXP already. | |
4284 | ||
4285 | Generate exactly SIZE bytes of assembler data, padding at the end | |
4286 | with zeros if necessary. SIZE must always be specified. | |
4287 | ||
4288 | SIZE is important for structure constructors, | |
4289 | since trailing members may have been omitted from the constructor. | |
4290 | It is also important for initialization of arrays from string constants | |
4291 | since the full length of the string constant might not be wanted. | |
4292 | It is also needed for initialization of unions, where the initializer's | |
4293 | type is just one member, and that may not be as long as the union. | |
4294 | ||
4295 | There a case in which we would fail to output exactly SIZE bytes: | |
4296 | for a structure constructor that wants to produce more than SIZE bytes. | |
4297 | But such constructors will never be generated for any possible input. */ | |
4298 | ||
4299 | void | |
4300 | output_constant (exp, size) | |
4301 | register tree exp; | |
4302 | register int size; | |
4303 | { | |
4304 | register enum tree_code code = TREE_CODE (TREE_TYPE (exp)); | |
79e68feb | 4305 | |
e697e20a MM |
4306 | /* Some front-ends use constants other than the standard |
4307 | language-indepdent varieties, but which may still be output | |
4308 | directly. Give the front-end a chance to convert EXP to a | |
4309 | language-independent representation. */ | |
4310 | if (lang_expand_constant) | |
4311 | exp = (*lang_expand_constant) (exp); | |
4312 | ||
e9996db7 | 4313 | if (size == 0 || flag_syntax_only) |
79e68feb RS |
4314 | return; |
4315 | ||
be1ad04c | 4316 | /* Eliminate the NON_LVALUE_EXPR_EXPR that makes a cast not be an lvalue. |
b81cdf54 | 4317 | That way we get the constant (we hope) inside it. Also, strip off any |
16214ee3 RK |
4318 | NOP_EXPR that converts between two record, union, array, or set types |
4319 | or a CONVERT_EXPR that converts to a union TYPE. */ | |
be1ad04c RK |
4320 | while ((TREE_CODE (exp) == NOP_EXPR |
4321 | && (TREE_TYPE (exp) == TREE_TYPE (TREE_OPERAND (exp, 0)) | |
4e1bf5f5 | 4322 | || AGGREGATE_TYPE_P (TREE_TYPE (exp)))) |
16214ee3 RK |
4323 | || (TREE_CODE (exp) == CONVERT_EXPR |
4324 | && code == UNION_TYPE) | |
be1ad04c | 4325 | || TREE_CODE (exp) == NON_LVALUE_EXPR) |
16214ee3 RK |
4326 | { |
4327 | exp = TREE_OPERAND (exp, 0); | |
4328 | code = TREE_CODE (TREE_TYPE (exp)); | |
4329 | } | |
be1ad04c | 4330 | |
fff9e713 MT |
4331 | /* Allow a constructor with no elements for any data type. |
4332 | This means to fill the space with zeros. */ | |
77fa0940 | 4333 | if (TREE_CODE (exp) == CONSTRUCTOR && CONSTRUCTOR_ELTS (exp) == 0) |
fff9e713 | 4334 | { |
b93a436e | 4335 | assemble_zeros (size); |
fff9e713 MT |
4336 | return; |
4337 | } | |
4338 | ||
79e68feb RS |
4339 | switch (code) |
4340 | { | |
644ea577 RS |
4341 | case CHAR_TYPE: |
4342 | case BOOLEAN_TYPE: | |
79e68feb RS |
4343 | case INTEGER_TYPE: |
4344 | case ENUMERAL_TYPE: | |
4345 | case POINTER_TYPE: | |
4346 | case REFERENCE_TYPE: | |
4347 | /* ??? What about (int)((float)(int)&foo + 4) */ | |
4348 | while (TREE_CODE (exp) == NOP_EXPR || TREE_CODE (exp) == CONVERT_EXPR | |
4349 | || TREE_CODE (exp) == NON_LVALUE_EXPR) | |
4350 | exp = TREE_OPERAND (exp, 0); | |
4351 | ||
37366632 | 4352 | if (! assemble_integer (expand_expr (exp, NULL_RTX, VOIDmode, |
79e68feb RS |
4353 | EXPAND_INITIALIZER), |
4354 | size, 0)) | |
4355 | error ("initializer for integer value is too complicated"); | |
4356 | size = 0; | |
4357 | break; | |
4358 | ||
4359 | case REAL_TYPE: | |
4360 | if (TREE_CODE (exp) != REAL_CST) | |
4361 | error ("initializer for floating value is not a floating constant"); | |
4362 | ||
4363 | assemble_real (TREE_REAL_CST (exp), | |
4364 | mode_for_size (size * BITS_PER_UNIT, MODE_FLOAT, 0)); | |
4365 | size = 0; | |
4366 | break; | |
4367 | ||
4368 | case COMPLEX_TYPE: | |
4369 | output_constant (TREE_REALPART (exp), size / 2); | |
4370 | output_constant (TREE_IMAGPART (exp), size / 2); | |
4371 | size -= (size / 2) * 2; | |
4372 | break; | |
4373 | ||
4374 | case ARRAY_TYPE: | |
4375 | if (TREE_CODE (exp) == CONSTRUCTOR) | |
4376 | { | |
4377 | output_constructor (exp, size); | |
4378 | return; | |
4379 | } | |
4380 | else if (TREE_CODE (exp) == STRING_CST) | |
4381 | { | |
4382 | int excess = 0; | |
4383 | ||
4384 | if (size > TREE_STRING_LENGTH (exp)) | |
4385 | { | |
4386 | excess = size - TREE_STRING_LENGTH (exp); | |
4387 | size = TREE_STRING_LENGTH (exp); | |
4388 | } | |
4389 | ||
4390 | assemble_string (TREE_STRING_POINTER (exp), size); | |
4391 | size = excess; | |
4392 | } | |
4393 | else | |
4394 | abort (); | |
4395 | break; | |
4396 | ||
4397 | case RECORD_TYPE: | |
4398 | case UNION_TYPE: | |
4399 | if (TREE_CODE (exp) == CONSTRUCTOR) | |
4400 | output_constructor (exp, size); | |
4401 | else | |
4402 | abort (); | |
4403 | return; | |
474bda6c PB |
4404 | |
4405 | case SET_TYPE: | |
4406 | if (TREE_CODE (exp) == INTEGER_CST) | |
4407 | assemble_integer (expand_expr (exp, NULL_RTX, | |
4408 | VOIDmode, EXPAND_INITIALIZER), | |
af13b0fb | 4409 | size, 1); |
474bda6c PB |
4410 | else if (TREE_CODE (exp) == CONSTRUCTOR) |
4411 | { | |
af13b0fb DE |
4412 | unsigned char *buffer = (unsigned char *) alloca (size); |
4413 | if (get_set_constructor_bytes (exp, buffer, size)) | |
474bda6c | 4414 | abort (); |
b029f99a | 4415 | assemble_string ((char *) buffer, size); |
474bda6c PB |
4416 | } |
4417 | else | |
4418 | error ("unknown set constructor type"); | |
4419 | return; | |
e9a25f70 JL |
4420 | |
4421 | default: | |
4422 | break; /* ??? */ | |
79e68feb RS |
4423 | } |
4424 | ||
4425 | if (size > 0) | |
4426 | assemble_zeros (size); | |
4427 | } | |
ca695ac9 | 4428 | |
79e68feb | 4429 | \f |
a25f1211 RH |
4430 | /* Subroutine of output_constructor, used for computing the size of |
4431 | arrays of unspecified length. VAL must be a CONSTRUCTOR of an array | |
4432 | type with an unspecified upper bound. */ | |
4433 | ||
4434 | static int | |
4435 | array_size_for_constructor (val) | |
4436 | tree val; | |
4437 | { | |
4438 | tree max_index, i; | |
4439 | ||
4440 | if (!val || TREE_CODE (val) != CONSTRUCTOR | |
4441 | || TREE_CODE (TREE_TYPE (val)) != ARRAY_TYPE | |
4442 | || TYPE_DOMAIN (TREE_TYPE (val)) == NULL_TREE | |
4443 | || TYPE_MAX_VALUE (TYPE_DOMAIN (TREE_TYPE (val))) != NULL_TREE | |
4444 | || TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (val))) == NULL_TREE) | |
4445 | abort (); | |
4446 | ||
4447 | max_index = NULL_TREE; | |
4448 | for (i = CONSTRUCTOR_ELTS (val); i ; i = TREE_CHAIN (i)) | |
4449 | { | |
4450 | tree index = TREE_PURPOSE (i); | |
4451 | ||
4452 | if (TREE_CODE (index) == RANGE_EXPR) | |
4453 | index = TREE_OPERAND (index, 1); | |
4454 | if (max_index == NULL_TREE || tree_int_cst_lt (max_index, index)) | |
4455 | max_index = index; | |
4456 | } | |
4457 | ||
4458 | /* ??? I'm fairly certain if there were no elements, we shouldn't have | |
4459 | created the constructor in the first place. */ | |
4460 | if (max_index == NULL_TREE) | |
4461 | abort (); | |
4462 | ||
4463 | /* Compute the total number of array elements. */ | |
4464 | i = fold (build (MINUS_EXPR, TREE_TYPE (max_index), max_index, | |
4465 | TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (val))))); | |
4466 | i = fold (build (PLUS_EXPR, TREE_TYPE (i), i, | |
4467 | convert (TREE_TYPE (i), integer_one_node))); | |
4468 | ||
4469 | /* Multiply by the array element unit size to find number of bytes. */ | |
4470 | i = fold (build (MULT_EXPR, TREE_TYPE (max_index), i, | |
4471 | TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (val))))); | |
4472 | ||
4473 | return tree_low_cst (i, 1); | |
4474 | } | |
4475 | ||
4476 | /* Subroutine of output_constant, used for CONSTRUCTORs (aggregate constants). | |
79e68feb RS |
4477 | Generate at least SIZE bytes, padding if necessary. */ |
4478 | ||
5a13eaa4 | 4479 | static void |
79e68feb RS |
4480 | output_constructor (exp, size) |
4481 | tree exp; | |
4482 | int size; | |
4483 | { | |
85f3d674 | 4484 | tree type = TREE_TYPE (exp); |
79e68feb | 4485 | register tree link, field = 0; |
85f3d674 | 4486 | tree min_index = 0; |
79e68feb RS |
4487 | /* Number of bytes output or skipped so far. |
4488 | In other words, current position within the constructor. */ | |
85f3d674 | 4489 | HOST_WIDE_INT total_bytes = 0; |
79e68feb RS |
4490 | /* Non-zero means BYTE contains part of a byte, to be output. */ |
4491 | int byte_buffer_in_use = 0; | |
a544cfd2 | 4492 | register int byte = 0; |
79e68feb | 4493 | |
37366632 | 4494 | if (HOST_BITS_PER_WIDE_INT < BITS_PER_UNIT) |
79e68feb RS |
4495 | abort (); |
4496 | ||
85f3d674 RK |
4497 | if (TREE_CODE (type) == RECORD_TYPE) |
4498 | field = TYPE_FIELDS (type); | |
79e68feb | 4499 | |
85f3d674 RK |
4500 | if (TREE_CODE (type) == ARRAY_TYPE |
4501 | && TYPE_DOMAIN (type) != 0) | |
4502 | min_index = TYPE_MIN_VALUE (TYPE_DOMAIN (type)); | |
13b457e7 | 4503 | |
79e68feb RS |
4504 | /* As LINK goes through the elements of the constant, |
4505 | FIELD goes through the structure fields, if the constant is a structure. | |
4506 | if the constant is a union, then we override this, | |
4507 | by getting the field from the TREE_LIST element. | |
43f7bed5 VM |
4508 | But the constant could also be an array. Then FIELD is zero. |
4509 | ||
4510 | There is always a maximum of one element in the chain LINK for unions | |
4511 | (even if the initializer in a source program incorrectly contains | |
4512 | more one). */ | |
79e68feb RS |
4513 | for (link = CONSTRUCTOR_ELTS (exp); |
4514 | link; | |
4515 | link = TREE_CHAIN (link), | |
4516 | field = field ? TREE_CHAIN (field) : 0) | |
4517 | { | |
4518 | tree val = TREE_VALUE (link); | |
3181cbfd RS |
4519 | tree index = 0; |
4520 | ||
85f3d674 RK |
4521 | /* The element in a union constructor specifies the proper field |
4522 | or index. */ | |
4523 | if ((TREE_CODE (type) == RECORD_TYPE || TREE_CODE (type) == UNION_TYPE | |
4524 | || TREE_CODE (type) == QUAL_UNION_TYPE) | |
4525 | && TREE_PURPOSE (link) != 0) | |
4526 | field = TREE_PURPOSE (link); | |
3181cbfd | 4527 | |
85f3d674 | 4528 | else if (TREE_CODE (type) == ARRAY_TYPE) |
3181cbfd RS |
4529 | index = TREE_PURPOSE (link); |
4530 | ||
79e68feb | 4531 | /* Eliminate the marker that makes a cast not be an lvalue. */ |
d964285c CH |
4532 | if (val != 0) |
4533 | STRIP_NOPS (val); | |
79e68feb | 4534 | |
8311a11f PB |
4535 | if (index && TREE_CODE (index) == RANGE_EXPR) |
4536 | { | |
4537 | register int fieldsize | |
85f3d674 RK |
4538 | = int_size_in_bytes (TREE_TYPE (type)); |
4539 | HOST_WIDE_INT lo_index = tree_low_cst (TREE_OPERAND (index, 0), 0); | |
4540 | HOST_WIDE_INT hi_index = tree_low_cst (TREE_OPERAND (index, 1), 0); | |
8311a11f | 4541 | HOST_WIDE_INT index; |
85f3d674 | 4542 | |
8311a11f PB |
4543 | for (index = lo_index; index <= hi_index; index++) |
4544 | { | |
4545 | /* Output the element's initial value. */ | |
4546 | if (val == 0) | |
4547 | assemble_zeros (fieldsize); | |
4548 | else | |
4549 | output_constant (val, fieldsize); | |
4550 | ||
4551 | /* Count its size. */ | |
4552 | total_bytes += fieldsize; | |
4553 | } | |
4554 | } | |
4555 | else if (field == 0 || !DECL_BIT_FIELD (field)) | |
79e68feb | 4556 | { |
3181cbfd RS |
4557 | /* An element that is not a bit-field. */ |
4558 | ||
79e68feb RS |
4559 | register int fieldsize; |
4560 | /* Since this structure is static, | |
4561 | we know the positions are constant. */ | |
85f3d674 | 4562 | HOST_WIDE_INT pos = field ? int_byte_position (field) : 0; |
770ae6cc | 4563 | |
3181cbfd | 4564 | if (index != 0) |
85f3d674 RK |
4565 | pos = (tree_low_cst (TYPE_SIZE_UNIT (TREE_TYPE (val)), 1) |
4566 | * (tree_low_cst (index, 0) - tree_low_cst (min_index, 0))); | |
79e68feb | 4567 | |
3181cbfd | 4568 | /* Output any buffered-up bit-fields preceding this element. */ |
79e68feb RS |
4569 | if (byte_buffer_in_use) |
4570 | { | |
4571 | ASM_OUTPUT_BYTE (asm_out_file, byte); | |
4572 | total_bytes++; | |
4573 | byte_buffer_in_use = 0; | |
4574 | } | |
4575 | ||
4576 | /* Advance to offset of this element. | |
4577 | Note no alignment needed in an array, since that is guaranteed | |
4578 | if each element has the proper size. */ | |
85f3d674 | 4579 | if ((field != 0 || index != 0) && pos != total_bytes) |
79e68feb | 4580 | { |
85f3d674 RK |
4581 | assemble_zeros (pos - total_bytes); |
4582 | total_bytes = pos; | |
79e68feb | 4583 | } |
ca2eed21 | 4584 | |
85f3d674 RK |
4585 | else if (field != 0 && DECL_PACKED (field)) |
4586 | /* Some assemblers automaticallly align a datum according to its | |
4587 | size if no align directive is specified. The datum, however, | |
4588 | may be declared with 'packed' attribute, so we have to disable | |
4589 | such a feature. */ | |
4590 | ASM_OUTPUT_ALIGN (asm_out_file, 0); | |
79e68feb RS |
4591 | |
4592 | /* Determine size this element should occupy. */ | |
4593 | if (field) | |
a25f1211 RH |
4594 | { |
4595 | if (DECL_SIZE_UNIT (field)) | |
4596 | fieldsize = tree_low_cst (DECL_SIZE_UNIT (field), 1); | |
4597 | else | |
4598 | { | |
4599 | /* If DECL_SIZE is not set, then this must be an array | |
4600 | of unspecified length. The initialized value must | |
4601 | be a CONSTRUCTOR, and we take the length from the | |
4602 | last initialized element. */ | |
4603 | fieldsize = array_size_for_constructor (val); | |
4604 | } | |
4605 | } | |
79e68feb | 4606 | else |
85f3d674 | 4607 | fieldsize = int_size_in_bytes (TREE_TYPE (type)); |
79e68feb RS |
4608 | |
4609 | /* Output the element's initial value. */ | |
4610 | if (val == 0) | |
4611 | assemble_zeros (fieldsize); | |
4612 | else | |
4613 | output_constant (val, fieldsize); | |
4614 | ||
4615 | /* Count its size. */ | |
4616 | total_bytes += fieldsize; | |
4617 | } | |
4618 | else if (val != 0 && TREE_CODE (val) != INTEGER_CST) | |
4619 | error ("invalid initial value for member `%s'", | |
4620 | IDENTIFIER_POINTER (DECL_NAME (field))); | |
4621 | else | |
4622 | { | |
4623 | /* Element that is a bit-field. */ | |
4624 | ||
770ae6cc RK |
4625 | HOST_WIDE_INT next_offset = int_bit_position (field); |
4626 | HOST_WIDE_INT end_offset | |
4627 | = (next_offset + tree_low_cst (DECL_SIZE (field), 1)); | |
79e68feb RS |
4628 | |
4629 | if (val == 0) | |
4630 | val = integer_zero_node; | |
4631 | ||
4632 | /* If this field does not start in this (or, next) byte, | |
4633 | skip some bytes. */ | |
4634 | if (next_offset / BITS_PER_UNIT != total_bytes) | |
4635 | { | |
4636 | /* Output remnant of any bit field in previous bytes. */ | |
4637 | if (byte_buffer_in_use) | |
4638 | { | |
4639 | ASM_OUTPUT_BYTE (asm_out_file, byte); | |
4640 | total_bytes++; | |
4641 | byte_buffer_in_use = 0; | |
4642 | } | |
4643 | ||
4644 | /* If still not at proper byte, advance to there. */ | |
4645 | if (next_offset / BITS_PER_UNIT != total_bytes) | |
4646 | { | |
4647 | assemble_zeros (next_offset / BITS_PER_UNIT - total_bytes); | |
4648 | total_bytes = next_offset / BITS_PER_UNIT; | |
4649 | } | |
4650 | } | |
4651 | ||
4652 | if (! byte_buffer_in_use) | |
4653 | byte = 0; | |
4654 | ||
4655 | /* We must split the element into pieces that fall within | |
4656 | separate bytes, and combine each byte with previous or | |
4657 | following bit-fields. */ | |
4658 | ||
b4ac57ab | 4659 | /* next_offset is the offset n fbits from the beginning of |
79e68feb RS |
4660 | the structure to the next bit of this element to be processed. |
4661 | end_offset is the offset of the first bit past the end of | |
4662 | this element. */ | |
4663 | while (next_offset < end_offset) | |
4664 | { | |
4665 | int this_time; | |
e7105755 JW |
4666 | int shift; |
4667 | HOST_WIDE_INT value; | |
85f3d674 RK |
4668 | HOST_WIDE_INT next_byte = next_offset / BITS_PER_UNIT; |
4669 | HOST_WIDE_INT next_bit = next_offset % BITS_PER_UNIT; | |
79e68feb RS |
4670 | |
4671 | /* Advance from byte to byte | |
4672 | within this element when necessary. */ | |
4673 | while (next_byte != total_bytes) | |
4674 | { | |
4675 | ASM_OUTPUT_BYTE (asm_out_file, byte); | |
4676 | total_bytes++; | |
4677 | byte = 0; | |
4678 | } | |
4679 | ||
4680 | /* Number of bits we can process at once | |
4681 | (all part of the same byte). */ | |
4682 | this_time = MIN (end_offset - next_offset, | |
4683 | BITS_PER_UNIT - next_bit); | |
f76b9db2 | 4684 | if (BYTES_BIG_ENDIAN) |
79e68feb | 4685 | { |
f76b9db2 ILT |
4686 | /* On big-endian machine, take the most significant bits |
4687 | first (of the bits that are significant) | |
4688 | and put them into bytes from the most significant end. */ | |
4689 | shift = end_offset - next_offset - this_time; | |
85f3d674 | 4690 | |
f76b9db2 | 4691 | /* Don't try to take a bunch of bits that cross |
dfb2c079 HB |
4692 | the word boundary in the INTEGER_CST. We can |
4693 | only select bits from the LOW or HIGH part | |
4694 | not from both. */ | |
f76b9db2 ILT |
4695 | if (shift < HOST_BITS_PER_WIDE_INT |
4696 | && shift + this_time > HOST_BITS_PER_WIDE_INT) | |
4697 | { | |
8b1cb95b GK |
4698 | this_time = shift + this_time - HOST_BITS_PER_WIDE_INT; |
4699 | shift = HOST_BITS_PER_WIDE_INT; | |
f76b9db2 ILT |
4700 | } |
4701 | ||
4702 | /* Now get the bits from the appropriate constant word. */ | |
4703 | if (shift < HOST_BITS_PER_WIDE_INT) | |
85f3d674 | 4704 | value = TREE_INT_CST_LOW (val); |
f76b9db2 ILT |
4705 | else if (shift < 2 * HOST_BITS_PER_WIDE_INT) |
4706 | { | |
4707 | value = TREE_INT_CST_HIGH (val); | |
4708 | shift -= HOST_BITS_PER_WIDE_INT; | |
4709 | } | |
4710 | else | |
4711 | abort (); | |
85f3d674 | 4712 | |
dfb2c079 HB |
4713 | /* Get the result. This works only when: |
4714 | 1 <= this_time <= HOST_BITS_PER_WIDE_INT. */ | |
f76b9db2 | 4715 | byte |= (((value >> shift) |
dfb2c079 | 4716 | & (((HOST_WIDE_INT) 2 << (this_time - 1)) - 1)) |
f76b9db2 | 4717 | << (BITS_PER_UNIT - this_time - next_bit)); |
79e68feb RS |
4718 | } |
4719 | else | |
79e68feb | 4720 | { |
f76b9db2 ILT |
4721 | /* On little-endian machines, |
4722 | take first the least significant bits of the value | |
4723 | and pack them starting at the least significant | |
4724 | bits of the bytes. */ | |
770ae6cc RK |
4725 | shift = next_offset - int_bit_position (field); |
4726 | ||
f76b9db2 | 4727 | /* Don't try to take a bunch of bits that cross |
dfb2c079 HB |
4728 | the word boundary in the INTEGER_CST. We can |
4729 | only select bits from the LOW or HIGH part | |
4730 | not from both. */ | |
f76b9db2 ILT |
4731 | if (shift < HOST_BITS_PER_WIDE_INT |
4732 | && shift + this_time > HOST_BITS_PER_WIDE_INT) | |
770ae6cc | 4733 | this_time = (HOST_BITS_PER_WIDE_INT - shift); |
f76b9db2 ILT |
4734 | |
4735 | /* Now get the bits from the appropriate constant word. */ | |
e9a25f70 | 4736 | if (shift < HOST_BITS_PER_WIDE_INT) |
f76b9db2 ILT |
4737 | value = TREE_INT_CST_LOW (val); |
4738 | else if (shift < 2 * HOST_BITS_PER_WIDE_INT) | |
4739 | { | |
4740 | value = TREE_INT_CST_HIGH (val); | |
4741 | shift -= HOST_BITS_PER_WIDE_INT; | |
4742 | } | |
4743 | else | |
4744 | abort (); | |
770ae6cc | 4745 | |
dfb2c079 HB |
4746 | /* Get the result. This works only when: |
4747 | 1 <= this_time <= HOST_BITS_PER_WIDE_INT. */ | |
f76b9db2 | 4748 | byte |= (((value >> shift) |
dfb2c079 | 4749 | & (((HOST_WIDE_INT) 2 << (this_time - 1)) - 1)) |
f76b9db2 | 4750 | << next_bit); |
79e68feb | 4751 | } |
85f3d674 | 4752 | |
79e68feb RS |
4753 | next_offset += this_time; |
4754 | byte_buffer_in_use = 1; | |
4755 | } | |
4756 | } | |
4757 | } | |
85f3d674 | 4758 | |
79e68feb RS |
4759 | if (byte_buffer_in_use) |
4760 | { | |
4761 | ASM_OUTPUT_BYTE (asm_out_file, byte); | |
4762 | total_bytes++; | |
4763 | } | |
85f3d674 | 4764 | |
79e68feb RS |
4765 | if (total_bytes < size) |
4766 | assemble_zeros (size - total_bytes); | |
4767 | } | |
ca695ac9 | 4768 | |
0e9264a2 JL |
4769 | #ifdef HANDLE_PRAGMA_WEAK |
4770 | /* Add function NAME to the weak symbols list. VALUE is a weak alias | |
4771 | associatd with NAME. */ | |
4772 | ||
4773 | int | |
4774 | add_weak (name, value) | |
63ad61ed ZW |
4775 | const char *name; |
4776 | const char *value; | |
0e9264a2 JL |
4777 | { |
4778 | struct weak_syms *weak; | |
4779 | ||
4780 | weak = (struct weak_syms *) permalloc (sizeof (struct weak_syms)); | |
4781 | ||
4782 | if (weak == NULL) | |
4783 | return 0; | |
4784 | ||
4785 | weak->next = weak_decls; | |
4786 | weak->name = name; | |
4787 | weak->value = value; | |
4788 | weak_decls = weak; | |
4789 | ||
4790 | return 1; | |
4791 | } | |
4792 | #endif /* HANDLE_PRAGMA_WEAK */ | |
4793 | ||
4b8af8d9 JM |
4794 | /* Declare DECL to be a weak symbol. */ |
4795 | ||
4796 | void | |
4797 | declare_weak (decl) | |
4798 | tree decl; | |
4799 | { | |
4800 | if (! TREE_PUBLIC (decl)) | |
4801 | error_with_decl (decl, "weak declaration of `%s' must be public"); | |
daefd78b JM |
4802 | else if (TREE_ASM_WRITTEN (decl)) |
4803 | error_with_decl (decl, "weak declaration of `%s' must precede definition"); | |
4804 | else if (SUPPORTS_WEAK) | |
4805 | DECL_WEAK (decl) = 1; | |
0e9264a2 JL |
4806 | #ifdef HANDLE_PRAGMA_WEAK |
4807 | add_weak (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)), NULL); | |
4808 | #endif | |
4b8af8d9 JM |
4809 | } |
4810 | ||
4811 | /* Emit any pending weak declarations. */ | |
4812 | ||
e2af664c NC |
4813 | #ifdef HANDLE_PRAGMA_WEAK |
4814 | struct weak_syms * weak_decls; | |
4815 | #endif | |
4816 | ||
4b8af8d9 JM |
4817 | void |
4818 | weak_finish () | |
4819 | { | |
4820 | #ifdef HANDLE_PRAGMA_WEAK | |
4821 | if (HANDLE_PRAGMA_WEAK) | |
4822 | { | |
eb0430f0 MM |
4823 | struct weak_syms *t; |
4824 | for (t = weak_decls; t; t = t->next) | |
4b8af8d9 | 4825 | { |
ec99e58f RL |
4826 | if (t->name) |
4827 | { | |
4828 | ASM_WEAKEN_LABEL (asm_out_file, t->name); | |
4829 | if (t->value) | |
4830 | ASM_OUTPUT_DEF (asm_out_file, t->name, t->value); | |
4831 | } | |
4832 | } | |
4833 | } | |
4834 | #endif | |
4835 | } | |
4836 | ||
4837 | /* Remove NAME from the pending list of weak symbols. This prevents | |
4838 | the compiler from emitting multiple .weak directives which confuses | |
4839 | some assemblers. */ | |
341a243e | 4840 | #ifdef ASM_WEAKEN_LABEL |
ec99e58f RL |
4841 | static void |
4842 | remove_from_pending_weak_list (name) | |
63ad61ed | 4843 | const char *name ATTRIBUTE_UNUSED; |
ec99e58f RL |
4844 | { |
4845 | #ifdef HANDLE_PRAGMA_WEAK | |
4846 | if (HANDLE_PRAGMA_WEAK) | |
4847 | { | |
4848 | struct weak_syms *t; | |
4849 | for (t = weak_decls; t; t = t->next) | |
4850 | { | |
548191a4 | 4851 | if (t->name && strcmp (name, t->name) == 0) |
ec99e58f | 4852 | t->name = NULL; |
4b8af8d9 JM |
4853 | } |
4854 | } | |
4855 | #endif | |
4856 | } | |
341a243e | 4857 | #endif |
4b8af8d9 JM |
4858 | |
4859 | void | |
4860 | assemble_alias (decl, target) | |
91813b28 | 4861 | tree decl, target ATTRIBUTE_UNUSED; |
4b8af8d9 | 4862 | { |
3cce094d | 4863 | const char *name; |
4b8af8d9 | 4864 | |
0f41302f | 4865 | make_decl_rtl (decl, (char *) 0, 1); |
4b8af8d9 JM |
4866 | name = XSTR (XEXP (DECL_RTL (decl), 0), 0); |
4867 | ||
4927276d | 4868 | #ifdef ASM_OUTPUT_DEF |
4b8af8d9 JM |
4869 | /* Make name accessible from other files, if appropriate. */ |
4870 | ||
4871 | if (TREE_PUBLIC (decl)) | |
4872 | { | |
daefd78b JM |
4873 | #ifdef ASM_WEAKEN_LABEL |
4874 | if (DECL_WEAK (decl)) | |
ec99e58f RL |
4875 | { |
4876 | ASM_WEAKEN_LABEL (asm_out_file, name); | |
4877 | /* Remove this function from the pending weak list so that | |
4878 | we do not emit multiple .weak directives for it. */ | |
4879 | remove_from_pending_weak_list | |
4880 | (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl))); | |
4881 | } | |
48ad5afd | 4882 | else |
daefd78b | 4883 | #endif |
48ad5afd | 4884 | ASM_GLOBALIZE_LABEL (asm_out_file, name); |
4b8af8d9 JM |
4885 | } |
4886 | ||
e4faf1eb NC |
4887 | #ifdef ASM_OUTPUT_DEF_FROM_DECLS |
4888 | ASM_OUTPUT_DEF_FROM_DECLS (asm_out_file, decl, target); | |
4889 | #else | |
4b8af8d9 | 4890 | ASM_OUTPUT_DEF (asm_out_file, name, IDENTIFIER_POINTER (target)); |
e4faf1eb | 4891 | #endif |
daefd78b | 4892 | TREE_ASM_WRITTEN (decl) = 1; |
4b8af8d9 | 4893 | #else |
4927276d JM |
4894 | #ifdef ASM_OUTPUT_WEAK_ALIAS |
4895 | if (! DECL_WEAK (decl)) | |
4896 | warning ("only weak aliases are supported in this configuration"); | |
4897 | ||
4898 | ASM_OUTPUT_WEAK_ALIAS (asm_out_file, name, IDENTIFIER_POINTER (target)); | |
4899 | TREE_ASM_WRITTEN (decl) = 1; | |
4900 | #else | |
4901 | warning ("alias definitions not supported in this configuration; ignored"); | |
4902 | #endif | |
4b8af8d9 JM |
4903 | #endif |
4904 | } | |
f796d997 JM |
4905 | |
4906 | /* This determines whether or not we support link-once semantics. */ | |
4907 | #ifndef SUPPORTS_ONE_ONLY | |
4908 | #ifdef MAKE_DECL_ONE_ONLY | |
4909 | #define SUPPORTS_ONE_ONLY 1 | |
4910 | #else | |
4911 | #define SUPPORTS_ONE_ONLY 0 | |
4912 | #endif | |
4913 | #endif | |
4914 | ||
4915 | /* Returns 1 if the target configuration supports defining public symbols | |
4916 | so that one of them will be chosen at link time instead of generating a | |
4917 | multiply-defined symbol error, whether through the use of weak symbols or | |
4918 | a target-specific mechanism for having duplicates discarded. */ | |
4919 | ||
4920 | int | |
4921 | supports_one_only () | |
4922 | { | |
4923 | if (SUPPORTS_ONE_ONLY) | |
4924 | return 1; | |
4925 | return SUPPORTS_WEAK; | |
4926 | } | |
4927 | ||
4928 | /* Set up DECL as a public symbol that can be defined in multiple | |
4929 | translation units without generating a linker error. */ | |
4930 | ||
4931 | void | |
4932 | make_decl_one_only (decl) | |
4933 | tree decl; | |
4934 | { | |
4935 | if (TREE_CODE (decl) != VAR_DECL && TREE_CODE (decl) != FUNCTION_DECL) | |
4936 | abort (); | |
4937 | ||
4938 | TREE_PUBLIC (decl) = 1; | |
4939 | ||
4940 | if (TREE_CODE (decl) == VAR_DECL | |
4941 | && (DECL_INITIAL (decl) == 0 || DECL_INITIAL (decl) == error_mark_node)) | |
4942 | DECL_COMMON (decl) = 1; | |
4943 | else if (SUPPORTS_ONE_ONLY) | |
4944 | { | |
4945 | #ifdef MAKE_DECL_ONE_ONLY | |
4946 | MAKE_DECL_ONE_ONLY (decl); | |
4947 | #endif | |
4948 | DECL_ONE_ONLY (decl) = 1; | |
4949 | } | |
4950 | else if (SUPPORTS_WEAK) | |
4951 | DECL_WEAK (decl) = 1; | |
4952 | else | |
4953 | abort (); | |
4954 | } | |
76095e2f RH |
4955 | |
4956 | void | |
4957 | init_varasm_once () | |
4958 | { | |
bd7cf17e JJ |
4959 | const_str_htab = htab_create (128, const_str_htab_hash, const_str_htab_eq, |
4960 | const_str_htab_del); | |
14a774a9 | 4961 | ggc_add_root (const_hash_table, MAX_HASH_TABLE, sizeof const_hash_table[0], |
76095e2f | 4962 | mark_const_hash_entry); |
bd7cf17e JJ |
4963 | ggc_add_root (&const_str_htab, 1, sizeof const_str_htab, |
4964 | mark_const_str_htab); | |
76095e2f | 4965 | } |
ce152ef8 AM |
4966 | |
4967 | /* Extra support for EH values. */ | |
4968 | void | |
4969 | assemble_eh_label (name) | |
4970 | const char *name; | |
4971 | { | |
4972 | #ifdef ASM_OUTPUT_EH_LABEL | |
4973 | ASM_OUTPUT_EH_LABEL (asm_out_file, name); | |
4974 | #else | |
4975 | assemble_label (name); | |
4976 | #endif | |
4977 | } | |
4978 | ||
4979 | /* Assemble an alignment pseudo op for an ALIGN-bit boundary. */ | |
4980 | ||
4981 | void | |
4982 | assemble_eh_align (align) | |
4983 | int align; | |
4984 | { | |
4985 | #ifdef ASM_OUTPUT_EH_ALIGN | |
4986 | if (align > BITS_PER_UNIT) | |
4987 | ASM_OUTPUT_EH_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT)); | |
4988 | #else | |
4989 | assemble_align (align); | |
4990 | #endif | |
4991 | } | |
4992 | ||
4993 | ||
4994 | /* On some platforms, we may want to specify a special mechansim to | |
4995 | output EH data when generating with a function.. */ | |
4996 | int | |
4997 | assemble_eh_integer (x, size, force) | |
4998 | rtx x; | |
4999 | int size; | |
5000 | int force; | |
5001 | { | |
5002 | ||
5003 | switch (size) | |
5004 | { | |
5005 | #ifdef ASM_OUTPUT_EH_CHAR | |
5006 | case 1: | |
5007 | ASM_OUTPUT_EH_CHAR (asm_out_file, x); | |
5008 | return 1; | |
5009 | #endif | |
5010 | ||
5011 | #ifdef ASM_OUTPUT_EH_SHORT | |
5012 | case 2: | |
5013 | ASM_OUTPUT_EH_SHORT (asm_out_file, x); | |
5014 | return 1; | |
5015 | #endif | |
5016 | ||
5017 | #ifdef ASM_OUTPUT_EH_INT | |
5018 | case 4: | |
5019 | ASM_OUTPUT_EH_INT (asm_out_file, x); | |
5020 | return 1; | |
5021 | #endif | |
5022 | ||
5023 | #ifdef ASM_OUTPUT_EH_DOUBLE_INT | |
5024 | case 8: | |
5025 | ASM_OUTPUT_EH_DOUBLE_INT (asm_out_file, x); | |
5026 | return 1; | |
5027 | #endif | |
5028 | ||
5029 | default: | |
5030 | break; | |
5031 | } | |
5032 | return (assemble_integer (x, size, force)); | |
5033 | } | |
5034 | ||
5035 | ||
5036 |