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