* target.h (asm_out.byte_op, asm_out.aligned_op, asm_out.unaligned_op,
[official-gcc.git] / gcc / varasm.c
blob87d81e38ba3371d6d46ea15f2e1b41a31572fd3c
1 /* Output variables, constants and external declarations, for GNU compiler.
2 Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997,
3 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
5 This file is part of GCC.
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.
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.
17 You should have received a copy of the GNU General Public License
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. */
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.
27 We also output the assembler code for constants stored in memory
28 and are responsible for combining constants with the same value. */
30 #include "config.h"
31 #include "system.h"
32 #include "rtl.h"
33 #include "tree.h"
34 #include "flags.h"
35 #include "function.h"
36 #include "expr.h"
37 #include "hard-reg-set.h"
38 #include "regs.h"
39 #include "output.h"
40 #include "real.h"
41 #include "toplev.h"
42 #include "obstack.h"
43 #include "hashtab.h"
44 #include "c-pragma.h"
45 #include "ggc.h"
46 #include "langhooks.h"
47 #include "tm_p.h"
48 #include "debug.h"
49 #include "target.h"
51 #ifdef XCOFF_DEBUGGING_INFO
52 #include "xcoffout.h" /* Needed for external data
53 declarations for e.g. AIX 4.x. */
54 #endif
56 #ifndef TRAMPOLINE_ALIGNMENT
57 #define TRAMPOLINE_ALIGNMENT FUNCTION_BOUNDARY
58 #endif
60 #ifndef ASM_STABS_OP
61 #define ASM_STABS_OP "\t.stabs\t"
62 #endif
64 /* The (assembler) name of the first globally-visible object output. */
65 const char *first_global_object_name;
66 const char *weak_global_object_name;
68 extern struct obstack permanent_obstack;
69 #define obstack_chunk_alloc xmalloc
71 struct addr_const;
72 struct constant_descriptor;
73 struct rtx_const;
74 struct pool_constant;
76 #define MAX_RTX_HASH_TABLE 61
78 struct varasm_status
80 /* Hash facility for making memory-constants
81 from constant rtl-expressions. It is used on RISC machines
82 where immediate integer arguments and constant addresses are restricted
83 so that such constants must be stored in memory.
85 This pool of constants is reinitialized for each function
86 so each function gets its own constants-pool that comes right before
87 it. */
88 struct constant_descriptor **x_const_rtx_hash_table;
89 struct pool_constant **x_const_rtx_sym_hash_table;
91 /* Pointers to first and last constant in pool. */
92 struct pool_constant *x_first_pool, *x_last_pool;
94 /* Current offset in constant pool (does not include any machine-specific
95 header). */
96 HOST_WIDE_INT x_pool_offset;
98 /* Chain of all CONST_DOUBLE rtx's constructed for the current function.
99 They are chained through the CONST_DOUBLE_CHAIN. */
100 rtx x_const_double_chain;
103 #define const_rtx_hash_table (cfun->varasm->x_const_rtx_hash_table)
104 #define const_rtx_sym_hash_table (cfun->varasm->x_const_rtx_sym_hash_table)
105 #define first_pool (cfun->varasm->x_first_pool)
106 #define last_pool (cfun->varasm->x_last_pool)
107 #define pool_offset (cfun->varasm->x_pool_offset)
108 #define const_double_chain (cfun->varasm->x_const_double_chain)
110 /* Number for making the label on the next
111 constant that is stored in memory. */
113 int const_labelno;
115 /* Number for making the label on the next
116 static variable internal to a function. */
118 int var_labelno;
120 /* Carry information from ASM_DECLARE_OBJECT_NAME
121 to ASM_FINISH_DECLARE_OBJECT. */
123 int size_directive_output;
125 /* The last decl for which assemble_variable was called,
126 if it did ASM_DECLARE_OBJECT_NAME.
127 If the last call to assemble_variable didn't do that,
128 this holds 0. */
130 tree last_assemble_variable_decl;
132 /* RTX_UNCHANGING_P in a MEM can mean it is stored into, for initialization.
133 So giving constant the alias set for the type will allow such
134 initializations to appear to conflict with the load of the constant. We
135 avoid this by giving all constants an alias set for just constants.
136 Since there will be no stores to that a alias set, nothing will ever
137 conflict with them. */
139 static HOST_WIDE_INT const_alias_set;
141 static const char *strip_reg_name PARAMS ((const char *));
142 static int contains_pointers_p PARAMS ((tree));
143 static void assemble_real_1 PARAMS ((PTR));
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,
147 struct constant_descriptor *));
148 static const unsigned char *compare_constant_1 PARAMS ((tree, const unsigned char *));
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,
154 struct rtx_const *));
155 static int const_hash_rtx PARAMS ((enum machine_mode, rtx));
156 static int compare_constant_rtx PARAMS ((enum machine_mode, rtx,
157 struct constant_descriptor *));
158 static struct constant_descriptor *record_constant_rtx PARAMS ((enum machine_mode,
159 rtx));
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));
163 static int mark_constant PARAMS ((rtx *current_rtx, void *data));
164 static int output_addressed_constants PARAMS ((tree));
165 static void output_after_function_constants PARAMS ((void));
166 static unsigned HOST_WIDE_INT array_size_for_constructor PARAMS ((tree));
167 static unsigned min_align PARAMS ((unsigned, unsigned));
168 static void output_constructor PARAMS ((tree, HOST_WIDE_INT,
169 unsigned int));
170 #ifdef ASM_WEAKEN_LABEL
171 static void remove_from_pending_weak_list PARAMS ((const char *));
172 #endif
173 static int in_named_entry_eq PARAMS ((const PTR, const PTR));
174 static hashval_t in_named_entry_hash PARAMS ((const PTR));
175 #ifdef ASM_OUTPUT_BSS
176 static void asm_output_bss PARAMS ((FILE *, tree, const char *, int, int));
177 #endif
178 #ifdef BSS_SECTION_ASM_OP
179 #ifdef ASM_OUTPUT_ALIGNED_BSS
180 static void asm_output_aligned_bss PARAMS ((FILE *, tree, const char *,
181 int, int));
182 #endif
183 #endif /* BSS_SECTION_ASM_OP */
184 static void mark_pool_constant PARAMS ((struct pool_constant *));
185 static void mark_const_hash_entry PARAMS ((void *));
186 static int mark_const_str_htab_1 PARAMS ((void **, void *));
187 static void mark_const_str_htab PARAMS ((void *));
188 static hashval_t const_str_htab_hash PARAMS ((const void *x));
189 static int const_str_htab_eq PARAMS ((const void *x, const void *y));
190 static void const_str_htab_del PARAMS ((void *));
191 static void asm_emit_uninitialised PARAMS ((tree, const char*, int, int));
192 static void resolve_unique_section PARAMS ((tree, int));
194 static enum in_section { no_section, in_text, in_data, in_named
195 #ifdef BSS_SECTION_ASM_OP
196 , in_bss
197 #endif
198 #ifdef CTORS_SECTION_ASM_OP
199 , in_ctors
200 #endif
201 #ifdef DTORS_SECTION_ASM_OP
202 , in_dtors
203 #endif
204 #ifdef EXTRA_SECTIONS
205 , EXTRA_SECTIONS
206 #endif
207 } in_section = no_section;
209 /* Return a non-zero value if DECL has a section attribute. */
210 #ifndef IN_NAMED_SECTION
211 #define IN_NAMED_SECTION(DECL) \
212 ((TREE_CODE (DECL) == FUNCTION_DECL || TREE_CODE (DECL) == VAR_DECL) \
213 && DECL_SECTION_NAME (DECL) != NULL_TREE)
214 #endif
216 /* Text of section name when in_section == in_named. */
217 static const char *in_named_name;
219 /* Hash table of flags that have been used for a particular named section. */
221 struct in_named_entry
223 const char *name;
224 unsigned int flags;
225 bool declared;
228 static htab_t in_named_htab;
230 /* Define functions like text_section for any extra sections. */
231 #ifdef EXTRA_SECTION_FUNCTIONS
232 EXTRA_SECTION_FUNCTIONS
233 #endif
235 /* Tell assembler to switch to text section. */
237 void
238 text_section ()
240 if (in_section != in_text)
242 #ifdef TEXT_SECTION
243 TEXT_SECTION ();
244 #else
245 fprintf (asm_out_file, "%s\n", TEXT_SECTION_ASM_OP);
246 #endif
247 in_section = in_text;
251 /* Tell assembler to switch to data section. */
253 void
254 data_section ()
256 if (in_section != in_data)
258 if (flag_shared_data)
260 #ifdef SHARED_SECTION_ASM_OP
261 fprintf (asm_out_file, "%s\n", SHARED_SECTION_ASM_OP);
262 #else
263 fprintf (asm_out_file, "%s\n", DATA_SECTION_ASM_OP);
264 #endif
266 else
267 fprintf (asm_out_file, "%s\n", DATA_SECTION_ASM_OP);
269 in_section = in_data;
272 /* Tell assembler to ALWAYS switch to data section, in case
273 it's not sure where it is. */
275 void
276 force_data_section ()
278 in_section = no_section;
279 data_section ();
282 /* Tell assembler to switch to read-only data section. This is normally
283 the text section. */
285 void
286 readonly_data_section ()
288 #ifdef READONLY_DATA_SECTION
289 READONLY_DATA_SECTION (); /* Note this can call data_section. */
290 #else
291 text_section ();
292 #endif
295 /* Determine if we're in the text section. */
298 in_text_section ()
300 return in_section == in_text;
303 /* Determine if we're in the data section. */
306 in_data_section ()
308 return in_section == in_data;
311 /* Helper routines for maintaining in_named_htab. */
313 static int
314 in_named_entry_eq (p1, p2)
315 const PTR p1;
316 const PTR p2;
318 const struct in_named_entry *old = p1;
319 const char *new = p2;
321 return strcmp (old->name, new) == 0;
324 static hashval_t
325 in_named_entry_hash (p)
326 const PTR p;
328 const struct in_named_entry *old = p;
329 return htab_hash_string (old->name);
332 /* If SECTION has been seen before as a named section, return the flags
333 that were used. Otherwise, return 0. Note, that 0 is a perfectly valid
334 set of flags for a section to have, so 0 does not mean that the section
335 has not been seen. */
337 unsigned int
338 get_named_section_flags (section)
339 const char *section;
341 struct in_named_entry **slot;
343 slot = (struct in_named_entry**)
344 htab_find_slot_with_hash (in_named_htab, section,
345 htab_hash_string (section), NO_INSERT);
347 return slot ? (*slot)->flags : 0;
350 /* Returns true if the section has been declared before. Sets internal
351 flag on this section in in_named_hash so subsequent calls on this
352 section will return false. */
354 bool
355 named_section_first_declaration (name)
356 const char *name;
358 struct in_named_entry **slot;
360 slot = (struct in_named_entry**)
361 htab_find_slot_with_hash (in_named_htab, name,
362 htab_hash_string (name), NO_INSERT);
363 if (! (*slot)->declared)
365 (*slot)->declared = true;
366 return true;
368 else
370 return false;
375 /* Record FLAGS for SECTION. If SECTION was previously recorded with a
376 different set of flags, return false. */
378 bool
379 set_named_section_flags (section, flags)
380 const char *section;
381 unsigned int flags;
383 struct in_named_entry **slot, *entry;
385 slot = (struct in_named_entry**)
386 htab_find_slot_with_hash (in_named_htab, section,
387 htab_hash_string (section), INSERT);
388 entry = *slot;
390 if (!entry)
392 entry = (struct in_named_entry *) xmalloc (sizeof (*entry));
393 *slot = entry;
394 entry->name = ggc_strdup (section);
395 entry->flags = flags;
396 entry->declared = false;
398 else if (entry->flags != flags)
399 return false;
401 return true;
404 /* Tell assembler to change to section NAME with attributes FLAGS. */
406 void
407 named_section_flags (name, flags)
408 const char *name;
409 unsigned int flags;
411 if (in_section != in_named || strcmp (name, in_named_name) != 0)
413 if (! set_named_section_flags (name, flags))
414 abort ();
416 (* targetm.asm_out.named_section) (name, flags);
418 if (flags & SECTION_FORGET)
419 in_section = no_section;
420 else
422 in_named_name = ggc_strdup (name);
423 in_section = in_named;
428 /* Tell assembler to change to section NAME for DECL.
429 If DECL is NULL, just switch to section NAME.
430 If NAME is NULL, get the name from DECL.
431 If RELOC is 1, the initializer for DECL contains relocs. */
433 void
434 named_section (decl, name, reloc)
435 tree decl;
436 const char *name;
437 int reloc;
439 unsigned int flags;
441 if (decl != NULL_TREE && !DECL_P (decl))
442 abort ();
443 if (name == NULL)
444 name = TREE_STRING_POINTER (DECL_SECTION_NAME (decl));
446 flags = (* targetm.section_type_flags) (decl, name, reloc);
448 /* Sanity check user variables for flag changes. Non-user
449 section flag changes will abort in named_section_flags. */
450 if (decl && ! set_named_section_flags (name, flags))
452 error_with_decl (decl, "%s causes a section type conflict");
453 flags = get_named_section_flags (name);
456 named_section_flags (name, flags);
459 /* If required, set DECL_SECTION_NAME to a unique name. */
461 static void
462 resolve_unique_section (decl, reloc)
463 tree decl;
464 int reloc ATTRIBUTE_UNUSED;
466 if (DECL_SECTION_NAME (decl) == NULL_TREE
467 && (flag_function_sections
468 || (targetm.have_named_sections
469 && DECL_ONE_ONLY (decl))))
470 UNIQUE_SECTION (decl, reloc);
473 #ifdef BSS_SECTION_ASM_OP
475 /* Tell the assembler to switch to the bss section. */
477 void
478 bss_section ()
480 if (in_section != in_bss)
482 #ifdef SHARED_BSS_SECTION_ASM_OP
483 if (flag_shared_data)
484 fprintf (asm_out_file, "%s\n", SHARED_BSS_SECTION_ASM_OP);
485 else
486 #endif
487 fprintf (asm_out_file, "%s\n", BSS_SECTION_ASM_OP);
489 in_section = in_bss;
493 #ifdef ASM_OUTPUT_BSS
495 /* Utility function for ASM_OUTPUT_BSS for targets to use if
496 they don't support alignments in .bss.
497 ??? It is believed that this function will work in most cases so such
498 support is localized here. */
500 static void
501 asm_output_bss (file, decl, name, size, rounded)
502 FILE *file;
503 tree decl ATTRIBUTE_UNUSED;
504 const char *name;
505 int size ATTRIBUTE_UNUSED, rounded;
507 ASM_GLOBALIZE_LABEL (file, name);
508 bss_section ();
509 #ifdef ASM_DECLARE_OBJECT_NAME
510 last_assemble_variable_decl = decl;
511 ASM_DECLARE_OBJECT_NAME (file, name, decl);
512 #else
513 /* Standard thing is just output label for the object. */
514 ASM_OUTPUT_LABEL (file, name);
515 #endif /* ASM_DECLARE_OBJECT_NAME */
516 ASM_OUTPUT_SKIP (file, rounded);
519 #endif
521 #ifdef ASM_OUTPUT_ALIGNED_BSS
523 /* Utility function for targets to use in implementing
524 ASM_OUTPUT_ALIGNED_BSS.
525 ??? It is believed that this function will work in most cases so such
526 support is localized here. */
528 static void
529 asm_output_aligned_bss (file, decl, name, size, align)
530 FILE *file;
531 tree decl ATTRIBUTE_UNUSED;
532 const char *name;
533 int size, align;
535 ASM_GLOBALIZE_LABEL (file, name);
536 bss_section ();
537 ASM_OUTPUT_ALIGN (file, floor_log2 (align / BITS_PER_UNIT));
538 #ifdef ASM_DECLARE_OBJECT_NAME
539 last_assemble_variable_decl = decl;
540 ASM_DECLARE_OBJECT_NAME (file, name, decl);
541 #else
542 /* Standard thing is just output label for the object. */
543 ASM_OUTPUT_LABEL (file, name);
544 #endif /* ASM_DECLARE_OBJECT_NAME */
545 ASM_OUTPUT_SKIP (file, size ? size : 1);
548 #endif
550 #endif /* BSS_SECTION_ASM_OP */
552 /* Switch to the section for function DECL.
554 If DECL is NULL_TREE, switch to the text section.
555 ??? It's not clear that we will ever be passed NULL_TREE, but it's
556 safer to handle it. */
558 void
559 function_section (decl)
560 tree decl;
562 if (decl != NULL_TREE
563 && DECL_SECTION_NAME (decl) != NULL_TREE)
564 named_section (decl, (char *) 0, 0);
565 else
566 text_section ();
569 /* Switch to section for variable DECL.
571 RELOC is the `reloc' argument to SELECT_SECTION. */
573 void
574 variable_section (decl, reloc)
575 tree decl;
576 int reloc;
578 if (IN_NAMED_SECTION (decl))
579 named_section (decl, NULL, reloc);
580 else
582 /* C++ can have const variables that get initialized from constructors,
583 and thus can not be in a readonly section. We prevent this by
584 verifying that the initial value is constant for objects put in a
585 readonly section.
587 error_mark_node is used by the C front end to indicate that the
588 initializer has not been seen yet. In this case, we assume that
589 the initializer must be constant.
591 C++ uses error_mark_node for variables that have complicated
592 initializers, but these variables go in BSS so we won't be called
593 for them. */
595 #ifdef SELECT_SECTION
596 SELECT_SECTION (decl, reloc, DECL_ALIGN (decl));
597 #else
598 if (DECL_READONLY_SECTION (decl, reloc))
599 readonly_data_section ();
600 else
601 data_section ();
602 #endif
606 /* Tell assembler to switch to the section for the exception handling
607 table. */
609 void
610 default_exception_section ()
612 if (targetm.have_named_sections)
613 named_section (NULL_TREE, ".gcc_except_table", 0);
614 else if (flag_pic)
615 data_section ();
616 else
617 readonly_data_section ();
620 /* Tell assembler to switch to the section for string merging. */
622 void
623 mergeable_string_section (decl, align, flags)
624 tree decl ATTRIBUTE_UNUSED;
625 unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED;
626 unsigned int flags ATTRIBUTE_UNUSED;
628 #ifdef HAVE_GAS_SHF_MERGE
629 if (flag_merge_constants
630 && TREE_CODE (decl) == STRING_CST
631 && TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE
632 && align <= 256
633 && TREE_STRING_LENGTH (decl) >= int_size_in_bytes (TREE_TYPE (decl)))
635 enum machine_mode mode;
636 unsigned int modesize;
637 const char *str;
638 int i, j, len, unit;
639 char name[30];
641 mode = TYPE_MODE (TREE_TYPE (TREE_TYPE (decl)));
642 modesize = GET_MODE_BITSIZE (mode);
643 if (modesize >= 8 && modesize <= 256
644 && (modesize & (modesize - 1)) == 0)
646 if (align < modesize)
647 align = modesize;
649 str = TREE_STRING_POINTER (decl);
650 len = TREE_STRING_LENGTH (decl);
651 unit = GET_MODE_SIZE (mode);
653 /* Check for embedded NUL characters. */
654 for (i = 0; i < len; i += unit)
656 for (j = 0; j < unit; j++)
657 if (str [i + j] != '\0')
658 break;
659 if (j == unit)
660 break;
662 if (i == len - unit)
664 sprintf (name, ".rodata.str%d.%d", modesize / 8,
665 (int) (align / 8));
666 flags |= (modesize / 8) | SECTION_MERGE | SECTION_STRINGS;
667 if (!i && modesize < align)
669 /* A "" string with requested alignment greater than
670 character size might cause a problem:
671 if some other string required even bigger
672 alignment than "", then linker might think the
673 "" is just part of padding after some other string
674 and not put it into the hash table initially.
675 But this means "" could have smaller alignment
676 than requested. */
677 #ifdef ASM_OUTPUT_SECTION_START
678 named_section_flags (name, flags);
679 ASM_OUTPUT_SECTION_START (asm_out_file);
680 #else
681 readonly_data_section ();
682 #endif
683 return;
686 named_section_flags (name, flags);
687 return;
691 #endif
692 readonly_data_section ();
695 /* Tell assembler to switch to the section for constant merging. */
697 void
698 mergeable_constant_section (mode, align, flags)
699 enum machine_mode mode ATTRIBUTE_UNUSED;
700 unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED;
701 unsigned int flags ATTRIBUTE_UNUSED;
703 #ifdef HAVE_GAS_SHF_MERGE
704 unsigned int modesize = GET_MODE_BITSIZE (mode);
706 if (flag_merge_constants
707 && mode != VOIDmode
708 && mode != BLKmode
709 && modesize <= align
710 && align >= 8
711 && align <= 256
712 && (align & (align - 1)) == 0)
714 char name[24];
716 sprintf (name, ".rodata.cst%d", (int) (align / 8));
717 flags |= (align / 8) | SECTION_MERGE;
718 named_section_flags (name, flags);
719 return;
721 #endif
722 readonly_data_section ();
725 /* Given NAME, a putative register name, discard any customary prefixes. */
727 static const char *
728 strip_reg_name (name)
729 const char *name;
731 #ifdef REGISTER_PREFIX
732 if (!strncmp (name, REGISTER_PREFIX, strlen (REGISTER_PREFIX)))
733 name += strlen (REGISTER_PREFIX);
734 #endif
735 if (name[0] == '%' || name[0] == '#')
736 name++;
737 return name;
740 /* Decode an `asm' spec for a declaration as a register name.
741 Return the register number, or -1 if nothing specified,
742 or -2 if the ASMSPEC is not `cc' or `memory' and is not recognized,
743 or -3 if ASMSPEC is `cc' and is not recognized,
744 or -4 if ASMSPEC is `memory' and is not recognized.
745 Accept an exact spelling or a decimal number.
746 Prefixes such as % are optional. */
749 decode_reg_name (asmspec)
750 const char *asmspec;
752 if (asmspec != 0)
754 int i;
756 /* Get rid of confusing prefixes. */
757 asmspec = strip_reg_name (asmspec);
759 /* Allow a decimal number as a "register name". */
760 for (i = strlen (asmspec) - 1; i >= 0; i--)
761 if (! ISDIGIT (asmspec[i]))
762 break;
763 if (asmspec[0] != 0 && i < 0)
765 i = atoi (asmspec);
766 if (i < FIRST_PSEUDO_REGISTER && i >= 0)
767 return i;
768 else
769 return -2;
772 for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
773 if (reg_names[i][0]
774 && ! strcmp (asmspec, strip_reg_name (reg_names[i])))
775 return i;
777 #ifdef ADDITIONAL_REGISTER_NAMES
779 static const struct { const char *const name; const int number; } table[]
780 = ADDITIONAL_REGISTER_NAMES;
782 for (i = 0; i < (int) ARRAY_SIZE (table); i++)
783 if (! strcmp (asmspec, table[i].name))
784 return table[i].number;
786 #endif /* ADDITIONAL_REGISTER_NAMES */
788 if (!strcmp (asmspec, "memory"))
789 return -4;
791 if (!strcmp (asmspec, "cc"))
792 return -3;
794 return -2;
797 return -1;
800 /* Create the DECL_RTL for a VAR_DECL or FUNCTION_DECL. DECL should
801 have static storage duration. In other words, it should not be an
802 automatic variable, including PARM_DECLs.
804 There is, however, one exception: this function handles variables
805 explicitly placed in a particular register by the user.
807 ASMSPEC, if not 0, is the string which the user specified as the
808 assembler symbol name.
810 This is never called for PARM_DECL nodes. */
812 void
813 make_decl_rtl (decl, asmspec)
814 tree decl;
815 const char *asmspec;
817 int top_level = (DECL_CONTEXT (decl) == NULL_TREE);
818 const char *name = 0;
819 const char *new_name = 0;
820 int reg_number;
821 rtx x;
823 /* Check that we are not being given an automatic variable. */
824 /* A weak alias has TREE_PUBLIC set but not the other bits. */
825 if (TREE_CODE (decl) == PARM_DECL
826 || TREE_CODE (decl) == RESULT_DECL
827 || (TREE_CODE (decl) == VAR_DECL
828 && !TREE_STATIC (decl)
829 && !TREE_PUBLIC (decl)
830 && !DECL_EXTERNAL (decl)
831 && !DECL_REGISTER (decl)))
832 abort ();
833 /* And that we were not given a type or a label. */
834 else if (TREE_CODE (decl) == TYPE_DECL
835 || TREE_CODE (decl) == LABEL_DECL)
836 abort ();
838 /* For a duplicate declaration, we can be called twice on the
839 same DECL node. Don't discard the RTL already made. */
840 if (DECL_RTL_SET_P (decl))
842 /* If the old RTL had the wrong mode, fix the mode. */
843 if (GET_MODE (DECL_RTL (decl)) != DECL_MODE (decl))
845 rtx rtl = DECL_RTL (decl);
846 PUT_MODE (rtl, DECL_MODE (decl));
849 /* ??? Another way to do this would be to do what halfpic.c does
850 and maintain a hashed table of such critters. */
851 /* ??? Another way to do this would be to pass a flag bit to
852 ENCODE_SECTION_INFO saying whether this is a new decl or not. */
853 /* Let the target reassign the RTL if it wants.
854 This is necessary, for example, when one machine specific
855 decl attribute overrides another. */
856 #ifdef REDO_SECTION_INFO_P
857 if (REDO_SECTION_INFO_P (decl))
858 ENCODE_SECTION_INFO (decl);
859 #endif
860 return;
863 new_name = name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
865 reg_number = decode_reg_name (asmspec);
866 if (reg_number == -2)
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;
876 if (TREE_CODE (decl) != FUNCTION_DECL && DECL_REGISTER (decl))
878 /* First detect errors in declaring global registers. */
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)
884 error_with_decl (decl,
885 "data type of `%s' isn't suitable for a register");
886 else if (! HARD_REGNO_MODE_OK (reg_number, TYPE_MODE (TREE_TYPE (decl))))
887 error_with_decl (decl,
888 "register specified for `%s' isn't suitable for data type");
889 /* Now handle properly declared static register variables. */
890 else
892 int nregs;
894 if (DECL_INITIAL (decl) != 0 && TREE_STATIC (decl))
896 DECL_INITIAL (decl) = 0;
897 error ("global register variable has initial value");
899 if (TREE_THIS_VOLATILE (decl))
900 warning ("volatile register variables don't work as you might wish");
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
904 confused with that register and be eliminated. Although this
905 usage is somewhat suspect, we nevertheless use the following
906 kludge to avoid setting DECL_RTL to frame_pointer_rtx. */
908 SET_DECL_RTL (decl,
909 gen_rtx_REG (DECL_MODE (decl),
910 FIRST_PSEUDO_REGISTER));
911 REGNO (DECL_RTL (decl)) = reg_number;
912 REG_USERVAR_P (DECL_RTL (decl)) = 1;
914 if (TREE_STATIC (decl))
916 /* Make this register global, so not usable for anything
917 else. */
918 #ifdef ASM_DECLARE_REGISTER_GLOBAL
919 ASM_DECLARE_REGISTER_GLOBAL (asm_out_file, decl, reg_number, name);
920 #endif
921 nregs = HARD_REGNO_NREGS (reg_number, DECL_MODE (decl));
922 while (nregs > 0)
923 globalize_reg (reg_number + --nregs);
926 /* As a register variable, it has no section. */
927 return;
931 /* Now handle ordinary static variables and functions (in memory).
932 Also handle vars declared register invalidly. */
934 if (reg_number >= 0 || reg_number == -3)
935 error_with_decl (decl,
936 "register name given for non-register variable `%s'");
938 /* Specifying a section attribute on a variable forces it into a
939 non-.bss section, and thus it cannot be common. */
940 if (TREE_CODE (decl) == VAR_DECL
941 && DECL_SECTION_NAME (decl) != NULL_TREE
942 && DECL_INITIAL (decl) == NULL_TREE
943 && DECL_COMMON (decl))
944 DECL_COMMON (decl) = 0;
946 /* Can't use just the variable's own name for a variable
947 whose scope is less than the whole file, unless it's a member
948 of a local class (which will already be unambiguous).
949 Concatenate a distinguishing number. */
950 if (!top_level && !TREE_PUBLIC (decl)
951 && ! (DECL_CONTEXT (decl) && TYPE_P (DECL_CONTEXT (decl)))
952 && asmspec == 0
953 && name == IDENTIFIER_POINTER (DECL_NAME (decl)))
955 char *label;
957 ASM_FORMAT_PRIVATE_NAME (label, name, var_labelno);
958 var_labelno++;
959 new_name = label;
962 if (name != new_name)
964 SET_DECL_ASSEMBLER_NAME (decl, get_identifier (new_name));
965 name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
968 /* If this variable is to be treated as volatile, show its
969 tree node has side effects. */
970 if ((flag_volatile_global && TREE_CODE (decl) == VAR_DECL
971 && TREE_PUBLIC (decl))
972 || ((flag_volatile_static && TREE_CODE (decl) == VAR_DECL
973 && (TREE_PUBLIC (decl) || TREE_STATIC (decl)))))
974 TREE_SIDE_EFFECTS (decl) = 1;
976 x = gen_rtx_MEM (DECL_MODE (decl), gen_rtx_SYMBOL_REF (Pmode, name));
977 SYMBOL_REF_WEAK (XEXP (x, 0)) = DECL_WEAK (decl);
978 if (TREE_CODE (decl) != FUNCTION_DECL)
979 set_mem_attributes (x, decl, 1);
980 SET_DECL_RTL (decl, x);
982 /* Optionally set flags or add text to the name to record information
983 such as that it is a function name.
984 If the name is changed, the macro ASM_OUTPUT_LABELREF
985 will have to know how to strip this information. */
986 #ifdef ENCODE_SECTION_INFO
987 ENCODE_SECTION_INFO (decl);
988 #endif
991 /* Make the rtl for variable VAR be volatile.
992 Use this only for static variables. */
994 void
995 make_var_volatile (var)
996 tree var;
998 if (GET_CODE (DECL_RTL (var)) != MEM)
999 abort ();
1001 MEM_VOLATILE_P (DECL_RTL (var)) = 1;
1004 /* Output alignment directive to align for constant expression EXP. */
1006 void
1007 assemble_constant_align (exp)
1008 tree exp;
1010 int align;
1012 /* Align the location counter as required by EXP's data type. */
1013 align = TYPE_ALIGN (TREE_TYPE (exp));
1014 #ifdef CONSTANT_ALIGNMENT
1015 align = CONSTANT_ALIGNMENT (exp, align);
1016 #endif
1018 if (align > BITS_PER_UNIT)
1020 ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT));
1024 /* Output a string of literal assembler code
1025 for an `asm' keyword used between functions. */
1027 void
1028 assemble_asm (string)
1029 tree string;
1031 app_enable ();
1033 if (TREE_CODE (string) == ADDR_EXPR)
1034 string = TREE_OPERAND (string, 0);
1036 fprintf (asm_out_file, "\t%s\n", TREE_STRING_POINTER (string));
1039 /* Record an element in the table of global destructors. SYMBOL is
1040 a SYMBOL_REF of the function to be called; PRIORITY is a number
1041 between 0 and MAX_INIT_PRIORITY. */
1043 void
1044 default_stabs_asm_out_destructor (symbol, priority)
1045 rtx symbol;
1046 int priority ATTRIBUTE_UNUSED;
1048 /* Tell GNU LD that this is part of the static destructor set.
1049 This will work for any system that uses stabs, most usefully
1050 aout systems. */
1051 fprintf (asm_out_file, "%s\"___DTOR_LIST__\",22,0,0,", ASM_STABS_OP);
1052 assemble_name (asm_out_file, XSTR (symbol, 0));
1053 fputc ('\n', asm_out_file);
1056 void
1057 default_named_section_asm_out_destructor (symbol, priority)
1058 rtx symbol;
1059 int priority;
1061 const char *section = ".dtors";
1062 char buf[16];
1064 /* ??? This only works reliably with the GNU linker. */
1065 if (priority != DEFAULT_INIT_PRIORITY)
1067 sprintf (buf, ".dtors.%.5u",
1068 /* Invert the numbering so the linker puts us in the proper
1069 order; constructors are run from right to left, and the
1070 linker sorts in increasing order. */
1071 MAX_INIT_PRIORITY - priority);
1072 section = buf;
1075 named_section_flags (section, SECTION_WRITE);
1076 assemble_align (POINTER_SIZE);
1077 assemble_integer (symbol, POINTER_SIZE / BITS_PER_UNIT, POINTER_SIZE, 1);
1080 #ifdef DTORS_SECTION_ASM_OP
1081 void
1082 dtors_section ()
1084 if (in_section != in_dtors)
1086 in_section = in_dtors;
1087 fputs (DTORS_SECTION_ASM_OP, asm_out_file);
1088 fputc ('\n', asm_out_file);
1092 void
1093 default_dtor_section_asm_out_destructor (symbol, priority)
1094 rtx symbol;
1095 int priority ATTRIBUTE_UNUSED;
1097 dtors_section ();
1098 assemble_align (POINTER_SIZE);
1099 assemble_integer (symbol, POINTER_SIZE / BITS_PER_UNIT, POINTER_SIZE, 1);
1101 #endif
1103 /* Likewise for global constructors. */
1105 void
1106 default_stabs_asm_out_constructor (symbol, priority)
1107 rtx symbol;
1108 int priority ATTRIBUTE_UNUSED;
1110 /* Tell GNU LD that this is part of the static destructor set.
1111 This will work for any system that uses stabs, most usefully
1112 aout systems. */
1113 fprintf (asm_out_file, "%s\"___CTOR_LIST__\",22,0,0,", ASM_STABS_OP);
1114 assemble_name (asm_out_file, XSTR (symbol, 0));
1115 fputc ('\n', asm_out_file);
1118 void
1119 default_named_section_asm_out_constructor (symbol, priority)
1120 rtx symbol;
1121 int priority;
1123 const char *section = ".ctors";
1124 char buf[16];
1126 /* ??? This only works reliably with the GNU linker. */
1127 if (priority != DEFAULT_INIT_PRIORITY)
1129 sprintf (buf, ".ctors.%.5u",
1130 /* Invert the numbering so the linker puts us in the proper
1131 order; constructors are run from right to left, and the
1132 linker sorts in increasing order. */
1133 MAX_INIT_PRIORITY - priority);
1134 section = buf;
1137 named_section_flags (section, SECTION_WRITE);
1138 assemble_align (POINTER_SIZE);
1139 assemble_integer (symbol, POINTER_SIZE / BITS_PER_UNIT, POINTER_SIZE, 1);
1142 #ifdef CTORS_SECTION_ASM_OP
1143 void
1144 ctors_section ()
1146 if (in_section != in_ctors)
1148 in_section = in_ctors;
1149 fputs (CTORS_SECTION_ASM_OP, asm_out_file);
1150 fputc ('\n', asm_out_file);
1154 void
1155 default_ctor_section_asm_out_constructor (symbol, priority)
1156 rtx symbol;
1157 int priority ATTRIBUTE_UNUSED;
1159 ctors_section ();
1160 assemble_align (POINTER_SIZE);
1161 assemble_integer (symbol, POINTER_SIZE / BITS_PER_UNIT, POINTER_SIZE, 1);
1163 #endif
1165 /* CONSTANT_POOL_BEFORE_FUNCTION may be defined as an expression with
1166 a non-zero value if the constant pool should be output before the
1167 start of the function, or a zero value if the pool should output
1168 after the end of the function. The default is to put it before the
1169 start. */
1171 #ifndef CONSTANT_POOL_BEFORE_FUNCTION
1172 #define CONSTANT_POOL_BEFORE_FUNCTION 1
1173 #endif
1175 /* Output assembler code for the constant pool of a function and associated
1176 with defining the name of the function. DECL describes the function.
1177 NAME is the function's name. For the constant pool, we use the current
1178 constant pool data. */
1180 void
1181 assemble_start_function (decl, fnname)
1182 tree decl;
1183 const char *fnname;
1185 int align;
1187 /* The following code does not need preprocessing in the assembler. */
1189 app_disable ();
1191 if (CONSTANT_POOL_BEFORE_FUNCTION)
1192 output_constant_pool (fnname, decl);
1194 resolve_unique_section (decl, 0);
1195 function_section (decl);
1197 /* Tell assembler to move to target machine's alignment for functions. */
1198 align = floor_log2 (FUNCTION_BOUNDARY / BITS_PER_UNIT);
1199 if (align > 0)
1201 ASM_OUTPUT_ALIGN (asm_out_file, align);
1204 /* Handle a user-specified function alignment.
1205 Note that we still need to align to FUNCTION_BOUNDARY, as above,
1206 because ASM_OUTPUT_MAX_SKIP_ALIGN might not do any alignment at all. */
1207 if (align_functions_log > align)
1209 #ifdef ASM_OUTPUT_MAX_SKIP_ALIGN
1210 ASM_OUTPUT_MAX_SKIP_ALIGN (asm_out_file,
1211 align_functions_log, align_functions-1);
1212 #else
1213 ASM_OUTPUT_ALIGN (asm_out_file, align_functions_log);
1214 #endif
1217 #ifdef ASM_OUTPUT_FUNCTION_PREFIX
1218 ASM_OUTPUT_FUNCTION_PREFIX (asm_out_file, fnname);
1219 #endif
1221 (*debug_hooks->begin_function) (decl);
1223 /* Make function name accessible from other files, if appropriate. */
1225 if (TREE_PUBLIC (decl))
1227 if (! first_global_object_name)
1229 const char *p;
1230 char *name;
1232 STRIP_NAME_ENCODING (p, fnname);
1233 name = permalloc (strlen (p) + 1);
1234 strcpy (name, p);
1236 if (! DECL_WEAK (decl) && ! DECL_ONE_ONLY (decl))
1237 first_global_object_name = name;
1238 else
1239 weak_global_object_name = name;
1242 #ifdef ASM_WEAKEN_LABEL
1243 if (DECL_WEAK (decl))
1245 ASM_WEAKEN_LABEL (asm_out_file, fnname);
1246 /* Remove this function from the pending weak list so that
1247 we do not emit multiple .weak directives for it. */
1248 remove_from_pending_weak_list
1249 (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
1251 else
1252 #endif
1253 ASM_GLOBALIZE_LABEL (asm_out_file, fnname);
1256 /* Do any machine/system dependent processing of the function name */
1257 #ifdef ASM_DECLARE_FUNCTION_NAME
1258 ASM_DECLARE_FUNCTION_NAME (asm_out_file, fnname, current_function_decl);
1259 #else
1260 /* Standard thing is just output label for the function. */
1261 ASM_OUTPUT_LABEL (asm_out_file, fnname);
1262 #endif /* ASM_DECLARE_FUNCTION_NAME */
1265 /* Output assembler code associated with defining the size of the
1266 function. DECL describes the function. NAME is the function's name. */
1268 void
1269 assemble_end_function (decl, fnname)
1270 tree decl;
1271 const char *fnname;
1273 #ifdef ASM_DECLARE_FUNCTION_SIZE
1274 ASM_DECLARE_FUNCTION_SIZE (asm_out_file, fnname, decl);
1275 #endif
1276 if (! CONSTANT_POOL_BEFORE_FUNCTION)
1278 output_constant_pool (fnname, decl);
1279 function_section (decl); /* need to switch back */
1282 /* Output any constants which should appear after the function. */
1283 output_after_function_constants ();
1286 /* Assemble code to leave SIZE bytes of zeros. */
1288 void
1289 assemble_zeros (size)
1290 int size;
1292 /* Do no output if -fsyntax-only. */
1293 if (flag_syntax_only)
1294 return;
1296 #ifdef ASM_NO_SKIP_IN_TEXT
1297 /* The `space' pseudo in the text section outputs nop insns rather than 0s,
1298 so we must output 0s explicitly in the text section. */
1299 if (ASM_NO_SKIP_IN_TEXT && in_text_section ())
1301 int i;
1302 for (i = 0; i < size; i++)
1303 assemble_integer (const0_rtx, 1, BITS_PER_UNIT, 1);
1305 else
1306 #endif
1307 if (size > 0)
1308 ASM_OUTPUT_SKIP (asm_out_file, size);
1311 /* Assemble an alignment pseudo op for an ALIGN-bit boundary. */
1313 void
1314 assemble_align (align)
1315 int align;
1317 if (align > BITS_PER_UNIT)
1319 ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT));
1323 /* Assemble a string constant with the specified C string as contents. */
1325 void
1326 assemble_string (p, size)
1327 const char *p;
1328 int size;
1330 int pos = 0;
1331 int maximum = 2000;
1333 /* If the string is very long, split it up. */
1335 while (pos < size)
1337 int thissize = size - pos;
1338 if (thissize > maximum)
1339 thissize = maximum;
1341 ASM_OUTPUT_ASCII (asm_out_file, p, thissize);
1343 pos += thissize;
1344 p += thissize;
1349 #if defined ASM_OUTPUT_ALIGNED_DECL_LOCAL
1350 #define ASM_EMIT_LOCAL(decl, name, size, rounded) \
1351 ASM_OUTPUT_ALIGNED_DECL_LOCAL (asm_out_file, decl, name, size, DECL_ALIGN (decl))
1352 #else
1353 #if defined ASM_OUTPUT_ALIGNED_LOCAL
1354 #define ASM_EMIT_LOCAL(decl, name, size, rounded) \
1355 ASM_OUTPUT_ALIGNED_LOCAL (asm_out_file, name, size, DECL_ALIGN (decl))
1356 #else
1357 #define ASM_EMIT_LOCAL(decl, name, size, rounded) \
1358 ASM_OUTPUT_LOCAL (asm_out_file, name, size, rounded)
1359 #endif
1360 #endif
1362 #if defined ASM_OUTPUT_ALIGNED_BSS
1363 #define ASM_EMIT_BSS(decl, name, size, rounded) \
1364 ASM_OUTPUT_ALIGNED_BSS (asm_out_file, decl, name, size, DECL_ALIGN (decl))
1365 #else
1366 #if defined ASM_OUTPUT_BSS
1367 #define ASM_EMIT_BSS(decl, name, size, rounded) \
1368 ASM_OUTPUT_BSS (asm_out_file, decl, name, size, rounded)
1369 #else
1370 #undef ASM_EMIT_BSS
1371 #endif
1372 #endif
1374 #if defined ASM_OUTPUT_ALIGNED_DECL_COMMON
1375 #define ASM_EMIT_COMMON(decl, name, size, rounded) \
1376 ASM_OUTPUT_ALIGNED_DECL_COMMON (asm_out_file, decl, name, size, DECL_ALIGN (decl))
1377 #else
1378 #if defined ASM_OUTPUT_ALIGNED_COMMON
1379 #define ASM_EMIT_COMMON(decl, name, size, rounded) \
1380 ASM_OUTPUT_ALIGNED_COMMON (asm_out_file, name, size, DECL_ALIGN (decl))
1381 #else
1382 #define ASM_EMIT_COMMON(decl, name, size, rounded) \
1383 ASM_OUTPUT_COMMON (asm_out_file, name, size, rounded)
1384 #endif
1385 #endif
1387 static void
1388 asm_emit_uninitialised (decl, name, size, rounded)
1389 tree decl;
1390 const char * name;
1391 int size ATTRIBUTE_UNUSED;
1392 int rounded ATTRIBUTE_UNUSED;
1394 enum
1396 asm_dest_common,
1397 asm_dest_bss,
1398 asm_dest_local
1400 destination = asm_dest_local;
1402 if (TREE_PUBLIC (decl))
1404 #if defined ASM_EMIT_BSS
1405 if (! DECL_COMMON (decl))
1406 destination = asm_dest_bss;
1407 else
1408 #endif
1409 destination = asm_dest_common;
1412 if (flag_shared_data)
1414 switch (destination)
1416 #ifdef ASM_OUTPUT_SHARED_BSS
1417 case asm_dest_bss:
1418 ASM_OUTPUT_SHARED_BSS (asm_out_file, decl, name, size, rounded);
1419 return;
1420 #endif
1421 #ifdef ASM_OUTPUT_SHARED_COMMON
1422 case asm_dest_common:
1423 ASM_OUTPUT_SHARED_COMMON (asm_out_file, name, size, rounded);
1424 return;
1425 #endif
1426 #ifdef ASM_OUTPUT_SHARED_LOCAL
1427 case asm_dest_local:
1428 ASM_OUTPUT_SHARED_LOCAL (asm_out_file, name, size, rounded);
1429 return;
1430 #endif
1431 default:
1432 break;
1436 resolve_unique_section (decl, 0);
1438 switch (destination)
1440 #ifdef ASM_EMIT_BSS
1441 case asm_dest_bss:
1442 ASM_EMIT_BSS (decl, name, size, rounded);
1443 break;
1444 #endif
1445 case asm_dest_common:
1446 ASM_EMIT_COMMON (decl, name, size, rounded);
1447 break;
1448 case asm_dest_local:
1449 ASM_EMIT_LOCAL (decl, name, size, rounded);
1450 break;
1451 default:
1452 abort ();
1455 return;
1458 /* Assemble everything that is needed for a variable or function declaration.
1459 Not used for automatic variables, and not used for function definitions.
1460 Should not be called for variables of incomplete structure type.
1462 TOP_LEVEL is nonzero if this variable has file scope.
1463 AT_END is nonzero if this is the special handling, at end of compilation,
1464 to define things that have had only tentative definitions.
1465 DONT_OUTPUT_DATA if nonzero means don't actually output the
1466 initial value (that will be done by the caller). */
1468 void
1469 assemble_variable (decl, top_level, at_end, dont_output_data)
1470 tree decl;
1471 int top_level ATTRIBUTE_UNUSED;
1472 int at_end ATTRIBUTE_UNUSED;
1473 int dont_output_data;
1475 const char *name;
1476 unsigned int align;
1477 int reloc = 0;
1478 rtx decl_rtl;
1480 last_assemble_variable_decl = 0;
1482 /* Normally no need to say anything here for external references,
1483 since assemble_external is called by the language-specific code
1484 when a declaration is first seen. */
1486 if (DECL_EXTERNAL (decl))
1487 return;
1489 /* Output no assembler code for a function declaration.
1490 Only definitions of functions output anything. */
1492 if (TREE_CODE (decl) == FUNCTION_DECL)
1493 return;
1495 /* Do nothing for global register variables. */
1496 if (DECL_RTL_SET_P (decl) && GET_CODE (DECL_RTL (decl)) == REG)
1498 TREE_ASM_WRITTEN (decl) = 1;
1499 return;
1502 /* If type was incomplete when the variable was declared,
1503 see if it is complete now. */
1505 if (DECL_SIZE (decl) == 0)
1506 layout_decl (decl, 0);
1508 /* Still incomplete => don't allocate it; treat the tentative defn
1509 (which is what it must have been) as an `extern' reference. */
1511 if (!dont_output_data && DECL_SIZE (decl) == 0)
1513 error_with_file_and_line (DECL_SOURCE_FILE (decl),
1514 DECL_SOURCE_LINE (decl),
1515 "storage size of `%s' isn't known",
1516 IDENTIFIER_POINTER (DECL_NAME (decl)));
1517 TREE_ASM_WRITTEN (decl) = 1;
1518 return;
1521 /* The first declaration of a variable that comes through this function
1522 decides whether it is global (in C, has external linkage)
1523 or local (in C, has internal linkage). So do nothing more
1524 if this function has already run. */
1526 if (TREE_ASM_WRITTEN (decl))
1527 return;
1529 /* Make sure ENCODE_SECTION_INFO is invoked before we set ASM_WRITTEN. */
1530 decl_rtl = DECL_RTL (decl);
1532 TREE_ASM_WRITTEN (decl) = 1;
1534 /* Do no output if -fsyntax-only. */
1535 if (flag_syntax_only)
1536 return;
1538 app_disable ();
1540 if (! dont_output_data
1541 && ! host_integerp (DECL_SIZE_UNIT (decl), 1))
1543 error_with_decl (decl, "size of variable `%s' is too large");
1544 return;
1547 name = XSTR (XEXP (decl_rtl, 0), 0);
1548 if (TREE_PUBLIC (decl) && DECL_NAME (decl)
1549 && ! first_global_object_name
1550 && ! (DECL_COMMON (decl) && (DECL_INITIAL (decl) == 0
1551 || DECL_INITIAL (decl) == error_mark_node))
1552 && ! DECL_WEAK (decl)
1553 && ! DECL_ONE_ONLY (decl))
1555 const char *p;
1556 char *xname;
1558 STRIP_NAME_ENCODING (p, name);
1559 xname = permalloc (strlen (p) + 1);
1560 strcpy (xname, p);
1561 first_global_object_name = xname;
1564 /* Compute the alignment of this data. */
1566 align = DECL_ALIGN (decl);
1568 /* In the case for initialing an array whose length isn't specified,
1569 where we have not yet been able to do the layout,
1570 figure out the proper alignment now. */
1571 if (dont_output_data && DECL_SIZE (decl) == 0
1572 && TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE)
1573 align = MAX (align, TYPE_ALIGN (TREE_TYPE (TREE_TYPE (decl))));
1575 /* Some object file formats have a maximum alignment which they support.
1576 In particular, a.out format supports a maximum alignment of 4. */
1577 #ifndef MAX_OFILE_ALIGNMENT
1578 #define MAX_OFILE_ALIGNMENT BIGGEST_ALIGNMENT
1579 #endif
1580 if (align > MAX_OFILE_ALIGNMENT)
1582 warning_with_decl (decl,
1583 "alignment of `%s' is greater than maximum object file alignment. Using %d",
1584 MAX_OFILE_ALIGNMENT/BITS_PER_UNIT);
1585 align = MAX_OFILE_ALIGNMENT;
1588 /* On some machines, it is good to increase alignment sometimes. */
1589 if (! DECL_USER_ALIGN (decl))
1591 #ifdef DATA_ALIGNMENT
1592 align = DATA_ALIGNMENT (TREE_TYPE (decl), align);
1593 #endif
1594 #ifdef CONSTANT_ALIGNMENT
1595 if (DECL_INITIAL (decl) != 0 && DECL_INITIAL (decl) != error_mark_node)
1596 align = CONSTANT_ALIGNMENT (DECL_INITIAL (decl), align);
1597 #endif
1600 /* Reset the alignment in case we have made it tighter, so we can benefit
1601 from it in get_pointer_alignment. */
1602 DECL_ALIGN (decl) = align;
1603 set_mem_align (decl_rtl, align);
1605 /* Handle uninitialized definitions. */
1607 if ((DECL_INITIAL (decl) == 0 || DECL_INITIAL (decl) == error_mark_node)
1608 /* If the target can't output uninitialized but not common global data
1609 in .bss, then we have to use .data. */
1610 #if ! defined ASM_EMIT_BSS
1611 && DECL_COMMON (decl)
1612 #endif
1613 && DECL_SECTION_NAME (decl) == NULL_TREE
1614 && ! dont_output_data)
1616 unsigned HOST_WIDE_INT size = tree_low_cst (DECL_SIZE_UNIT (decl), 1);
1617 unsigned HOST_WIDE_INT rounded = size;
1619 /* Don't allocate zero bytes of common,
1620 since that means "undefined external" in the linker. */
1621 if (size == 0)
1622 rounded = 1;
1624 /* Round size up to multiple of BIGGEST_ALIGNMENT bits
1625 so that each uninitialized object starts on such a boundary. */
1626 rounded += (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - 1;
1627 rounded = (rounded / (BIGGEST_ALIGNMENT / BITS_PER_UNIT)
1628 * (BIGGEST_ALIGNMENT / BITS_PER_UNIT));
1630 /* Don't continue this line--convex cc version 4.1 would lose. */
1631 #if !defined(ASM_OUTPUT_ALIGNED_COMMON) && !defined(ASM_OUTPUT_ALIGNED_DECL_COMMON) && !defined(ASM_OUTPUT_ALIGNED_BSS)
1632 if ((unsigned HOST_WIDE_INT) DECL_ALIGN (decl) / BITS_PER_UNIT > rounded)
1633 warning_with_decl
1634 (decl, "requested alignment for %s is greater than implemented alignment of %d",rounded);
1635 #endif
1637 asm_emit_uninitialised (decl, name, size, rounded);
1639 return;
1642 /* Handle initialized definitions.
1643 Also handle uninitialized global definitions if -fno-common and the
1644 target doesn't support ASM_OUTPUT_BSS. */
1646 /* First make the assembler name(s) global if appropriate. */
1647 if (TREE_PUBLIC (decl) && DECL_NAME (decl))
1649 #ifdef ASM_WEAKEN_LABEL
1650 if (DECL_WEAK (decl))
1652 ASM_WEAKEN_LABEL (asm_out_file, name);
1653 /* Remove this variable from the pending weak list so that
1654 we do not emit multiple .weak directives for it. */
1655 remove_from_pending_weak_list
1656 (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
1658 else
1659 #endif
1660 ASM_GLOBALIZE_LABEL (asm_out_file, name);
1663 /* Output any data that we will need to use the address of. */
1664 if (DECL_INITIAL (decl) == error_mark_node)
1665 reloc = contains_pointers_p (TREE_TYPE (decl)) ? 3 : 0;
1666 else if (DECL_INITIAL (decl))
1667 reloc = output_addressed_constants (DECL_INITIAL (decl));
1669 /* Switch to the appropriate section. */
1670 resolve_unique_section (decl, reloc);
1671 variable_section (decl, reloc);
1673 /* dbxout.c needs to know this. */
1674 if (in_text_section ())
1675 DECL_IN_TEXT_SECTION (decl) = 1;
1677 /* Output the alignment of this data. */
1678 if (align > BITS_PER_UNIT)
1680 ASM_OUTPUT_ALIGN (asm_out_file,
1681 floor_log2 (DECL_ALIGN (decl) / BITS_PER_UNIT));
1684 /* Do any machine/system dependent processing of the object. */
1685 #ifdef ASM_DECLARE_OBJECT_NAME
1686 last_assemble_variable_decl = decl;
1687 ASM_DECLARE_OBJECT_NAME (asm_out_file, name, decl);
1688 #else
1689 /* Standard thing is just output label for the object. */
1690 ASM_OUTPUT_LABEL (asm_out_file, name);
1691 #endif /* ASM_DECLARE_OBJECT_NAME */
1693 if (!dont_output_data)
1695 if (DECL_INITIAL (decl))
1696 /* Output the actual data. */
1697 output_constant (DECL_INITIAL (decl),
1698 tree_low_cst (DECL_SIZE_UNIT (decl), 1),
1699 align);
1700 else
1701 /* Leave space for it. */
1702 assemble_zeros (tree_low_cst (DECL_SIZE_UNIT (decl), 1));
1706 /* Return 1 if type TYPE contains any pointers. */
1708 static int
1709 contains_pointers_p (type)
1710 tree type;
1712 switch (TREE_CODE (type))
1714 case POINTER_TYPE:
1715 case REFERENCE_TYPE:
1716 /* I'm not sure whether OFFSET_TYPE needs this treatment,
1717 so I'll play safe and return 1. */
1718 case OFFSET_TYPE:
1719 return 1;
1721 case RECORD_TYPE:
1722 case UNION_TYPE:
1723 case QUAL_UNION_TYPE:
1725 tree fields;
1726 /* For a type that has fields, see if the fields have pointers. */
1727 for (fields = TYPE_FIELDS (type); fields; fields = TREE_CHAIN (fields))
1728 if (TREE_CODE (fields) == FIELD_DECL
1729 && contains_pointers_p (TREE_TYPE (fields)))
1730 return 1;
1731 return 0;
1734 case ARRAY_TYPE:
1735 /* An array type contains pointers if its element type does. */
1736 return contains_pointers_p (TREE_TYPE (type));
1738 default:
1739 return 0;
1743 /* Output something to declare an external symbol to the assembler.
1744 (Most assemblers don't need this, so we normally output nothing.)
1745 Do nothing if DECL is not external. */
1747 void
1748 assemble_external (decl)
1749 tree decl ATTRIBUTE_UNUSED;
1751 /* Because most platforms do not define ASM_OUTPUT_EXTERNAL, the
1752 main body of this code is only rarely exercised. To provide some
1753 testing, on all platforms, we make sure that the ASM_OUT_FILE is
1754 open. If it's not, we should not be calling this function. */
1755 if (!asm_out_file)
1756 abort ();
1758 #ifdef ASM_OUTPUT_EXTERNAL
1759 if (DECL_P (decl) && DECL_EXTERNAL (decl) && TREE_PUBLIC (decl))
1761 rtx rtl = DECL_RTL (decl);
1763 if (GET_CODE (rtl) == MEM && GET_CODE (XEXP (rtl, 0)) == SYMBOL_REF
1764 && ! SYMBOL_REF_USED (XEXP (rtl, 0)))
1766 /* Some systems do require some output. */
1767 SYMBOL_REF_USED (XEXP (rtl, 0)) = 1;
1768 ASM_OUTPUT_EXTERNAL (asm_out_file, decl, XSTR (XEXP (rtl, 0), 0));
1771 #endif
1774 /* Similar, for calling a library function FUN. */
1776 void
1777 assemble_external_libcall (fun)
1778 rtx fun ATTRIBUTE_UNUSED;
1780 #ifdef ASM_OUTPUT_EXTERNAL_LIBCALL
1781 /* Declare library function name external when first used, if nec. */
1782 if (! SYMBOL_REF_USED (fun))
1784 SYMBOL_REF_USED (fun) = 1;
1785 ASM_OUTPUT_EXTERNAL_LIBCALL (asm_out_file, fun);
1787 #endif
1790 /* Declare the label NAME global. */
1792 void
1793 assemble_global (name)
1794 const char *name ATTRIBUTE_UNUSED;
1796 ASM_GLOBALIZE_LABEL (asm_out_file, name);
1799 /* Assemble a label named NAME. */
1801 void
1802 assemble_label (name)
1803 const char *name;
1805 ASM_OUTPUT_LABEL (asm_out_file, name);
1808 /* Output to FILE a reference to the assembler name of a C-level name NAME.
1809 If NAME starts with a *, the rest of NAME is output verbatim.
1810 Otherwise NAME is transformed in an implementation-defined way
1811 (usually by the addition of an underscore).
1812 Many macros in the tm file are defined to call this function. */
1814 void
1815 assemble_name (file, name)
1816 FILE *file;
1817 const char *name;
1819 const char *real_name;
1820 tree id;
1822 STRIP_NAME_ENCODING (real_name, name);
1824 id = maybe_get_identifier (real_name);
1825 if (id)
1826 TREE_SYMBOL_REFERENCED (id) = 1;
1828 if (name[0] == '*')
1829 fputs (&name[1], file);
1830 else
1831 ASM_OUTPUT_LABELREF (file, name);
1834 /* Allocate SIZE bytes writable static space with a gensym name
1835 and return an RTX to refer to its address. */
1838 assemble_static_space (size)
1839 int size;
1841 char name[12];
1842 const char *namestring;
1843 rtx x;
1845 #if 0
1846 if (flag_shared_data)
1847 data_section ();
1848 #endif
1850 ASM_GENERATE_INTERNAL_LABEL (name, "LF", const_labelno);
1851 ++const_labelno;
1852 namestring = ggc_strdup (name);
1854 x = gen_rtx_SYMBOL_REF (Pmode, namestring);
1856 #ifdef ASM_OUTPUT_ALIGNED_DECL_LOCAL
1857 ASM_OUTPUT_ALIGNED_DECL_LOCAL (asm_out_file, NULL_TREE, name, size,
1858 BIGGEST_ALIGNMENT);
1859 #else
1860 #ifdef ASM_OUTPUT_ALIGNED_LOCAL
1861 ASM_OUTPUT_ALIGNED_LOCAL (asm_out_file, name, size, BIGGEST_ALIGNMENT);
1862 #else
1864 /* Round size up to multiple of BIGGEST_ALIGNMENT bits
1865 so that each uninitialized object starts on such a boundary. */
1866 /* Variable `rounded' might or might not be used in ASM_OUTPUT_LOCAL. */
1867 int rounded ATTRIBUTE_UNUSED
1868 = ((size + (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - 1)
1869 / (BIGGEST_ALIGNMENT / BITS_PER_UNIT)
1870 * (BIGGEST_ALIGNMENT / BITS_PER_UNIT));
1871 ASM_OUTPUT_LOCAL (asm_out_file, name, size, rounded);
1873 #endif
1874 #endif
1875 return x;
1878 /* Assemble the static constant template for function entry trampolines.
1879 This is done at most once per compilation.
1880 Returns an RTX for the address of the template. */
1882 #ifdef TRAMPOLINE_TEMPLATE
1884 assemble_trampoline_template ()
1886 char label[256];
1887 const char *name;
1888 int align;
1890 /* By default, put trampoline templates in read-only data section. */
1892 #ifdef TRAMPOLINE_SECTION
1893 TRAMPOLINE_SECTION ();
1894 #else
1895 readonly_data_section ();
1896 #endif
1898 /* Write the assembler code to define one. */
1899 align = floor_log2 (TRAMPOLINE_ALIGNMENT / BITS_PER_UNIT);
1900 if (align > 0)
1902 ASM_OUTPUT_ALIGN (asm_out_file, align);
1905 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LTRAMP", 0);
1906 TRAMPOLINE_TEMPLATE (asm_out_file);
1908 /* Record the rtl to refer to it. */
1909 ASM_GENERATE_INTERNAL_LABEL (label, "LTRAMP", 0);
1910 name = ggc_strdup (label);
1911 return gen_rtx_SYMBOL_REF (Pmode, name);
1913 #endif
1915 /* A and B are either alignments or offsets. Return the minimum alignment
1916 that may be assumed after adding the two together. */
1918 static inline unsigned
1919 min_align (a, b)
1920 unsigned int a, b;
1922 return (a | b) & -(a | b);
1925 /* Return the assembler directive for creating a given kind of integer
1926 object. SIZE is the number of bytes in the object and ALIGNED_P
1927 indicates whether it is known to be aligned. Return NULL if the
1928 assembly dialect has no such directive.
1930 The returned string should be printed at the start of a new line and
1931 be followed immediately by the object's initial value. */
1933 const char *
1934 integer_asm_op (size, aligned_p)
1935 int size;
1936 int aligned_p;
1938 struct asm_int_op *ops;
1940 if (aligned_p)
1941 ops = &targetm.asm_out.aligned_op;
1942 else
1943 ops = &targetm.asm_out.unaligned_op;
1945 switch (size)
1947 case 1:
1948 return targetm.asm_out.byte_op;
1949 case 2:
1950 return ops->hi;
1951 case 4:
1952 return ops->si;
1953 case 8:
1954 return ops->di;
1955 case 16:
1956 return ops->ti;
1957 default:
1958 return NULL;
1962 /* Use directive OP to assemble an integer object X. Print OP at the
1963 start of the line, followed immediately by the value of X. */
1965 void
1966 assemble_integer_with_op (op, x)
1967 const char *op;
1968 rtx x;
1970 fputs (op, asm_out_file);
1971 output_addr_const (asm_out_file, x);
1972 fputc ('\n', asm_out_file);
1975 /* The default implementation of the asm_out.integer target hook. */
1977 bool
1978 default_assemble_integer (x, size, aligned_p)
1979 rtx x ATTRIBUTE_UNUSED;
1980 unsigned int size ATTRIBUTE_UNUSED;
1981 int aligned_p ATTRIBUTE_UNUSED;
1983 const char *op = integer_asm_op (size, aligned_p);
1984 return op && (assemble_integer_with_op (op, x), true);
1987 /* Assemble the integer constant X into an object of SIZE bytes. ALIGN is
1988 the alignment of the integer in bits. Return 1 if we were able to output
1989 the constant, otherwise 0. If FORCE is non-zero, abort if we can't output
1990 the constant. */
1992 bool
1993 assemble_integer (x, size, align, force)
1994 rtx x;
1995 unsigned int size;
1996 unsigned int align;
1997 int force;
1999 int aligned_p;
2001 aligned_p = (align >= MIN (size * BITS_PER_UNIT, BIGGEST_ALIGNMENT));
2003 /* See if the target hook can handle this kind of object. */
2004 if ((*targetm.asm_out.integer) (x, size, aligned_p))
2005 return true;
2007 /* If the object is a multi-byte one, try splitting it up. Split
2008 it into words it if is multi-word, otherwise split it into bytes. */
2009 if (size > 1)
2011 enum machine_mode omode, imode;
2012 unsigned int subalign;
2013 unsigned int subsize, i;
2015 subsize = size > UNITS_PER_WORD? UNITS_PER_WORD : 1;
2016 subalign = MIN (align, subsize * BITS_PER_UNIT);
2017 omode = mode_for_size (subsize * BITS_PER_UNIT, MODE_INT, 0);
2018 imode = mode_for_size (size * BITS_PER_UNIT, MODE_INT, 0);
2020 for (i = 0; i < size; i += subsize)
2022 rtx partial = simplify_subreg (omode, x, imode, i);
2023 if (!partial || !assemble_integer (partial, subsize, subalign, 0))
2024 break;
2026 if (i == size)
2027 return true;
2029 /* If we've printed some of it, but not all of it, there's no going
2030 back now. */
2031 if (i > 0)
2032 abort ();
2035 if (force)
2036 abort ();
2038 return false;
2041 /* Assemble the floating-point constant D into an object of size MODE. */
2042 struct assemble_real_args
2044 REAL_VALUE_TYPE *d;
2045 enum machine_mode mode;
2048 static void
2049 assemble_real_1 (p)
2050 PTR p;
2052 struct assemble_real_args *args = (struct assemble_real_args *) p;
2053 REAL_VALUE_TYPE *d = args->d;
2054 enum machine_mode mode = args->mode;
2056 switch (mode)
2058 #ifdef ASM_OUTPUT_BYTE_FLOAT
2059 case QFmode:
2060 ASM_OUTPUT_BYTE_FLOAT (asm_out_file, *d);
2061 break;
2062 #endif
2063 #ifdef ASM_OUTPUT_SHORT_FLOAT
2064 case HFmode:
2065 ASM_OUTPUT_SHORT_FLOAT (asm_out_file, *d);
2066 break;
2067 #endif
2068 #ifdef ASM_OUTPUT_THREE_QUARTER_FLOAT
2069 case TQFmode:
2070 ASM_OUTPUT_THREE_QUARTER_FLOAT (asm_out_file, *d);
2071 break;
2072 #endif
2073 #ifdef ASM_OUTPUT_FLOAT
2074 case SFmode:
2075 ASM_OUTPUT_FLOAT (asm_out_file, *d);
2076 break;
2077 #endif
2079 #ifdef ASM_OUTPUT_DOUBLE
2080 case DFmode:
2081 ASM_OUTPUT_DOUBLE (asm_out_file, *d);
2082 break;
2083 #endif
2085 #ifdef ASM_OUTPUT_LONG_DOUBLE
2086 case XFmode:
2087 case TFmode:
2088 ASM_OUTPUT_LONG_DOUBLE (asm_out_file, *d);
2089 break;
2090 #endif
2092 default:
2093 abort ();
2097 void
2098 assemble_real (d, mode, align)
2099 REAL_VALUE_TYPE d;
2100 enum machine_mode mode;
2101 unsigned int align;
2103 struct assemble_real_args args;
2104 args.d = &d;
2105 args.mode = mode;
2107 /* We cannot emit unaligned floating point constants. This is slightly
2108 complicated in that we don't know what "unaligned" means exactly. */
2109 #ifdef BIGGEST_FIELD_ALIGNMENT
2110 if (align >= BIGGEST_FIELD_ALIGNMENT)
2112 else
2113 #endif
2114 if (align < GET_MODE_ALIGNMENT (mode))
2115 abort ();
2117 if (do_float_handler (assemble_real_1, (PTR) &args))
2118 return;
2120 internal_error ("floating point trap outputting a constant");
2123 /* Here we combine duplicate floating constants to make
2124 CONST_DOUBLE rtx's, and force those out to memory when necessary. */
2126 /* Return a CONST_DOUBLE or CONST_INT for a value specified as a pair of ints.
2127 For an integer, I0 is the low-order word and I1 is the high-order word.
2128 For a real number, I0 is the word with the low address
2129 and I1 is the word with the high address. */
2132 immed_double_const (i0, i1, mode)
2133 HOST_WIDE_INT i0, i1;
2134 enum machine_mode mode;
2136 rtx r;
2138 if (GET_MODE_CLASS (mode) == MODE_INT
2139 || GET_MODE_CLASS (mode) == MODE_PARTIAL_INT)
2141 /* We clear out all bits that don't belong in MODE, unless they and our
2142 sign bit are all one. So we get either a reasonable negative value
2143 or a reasonable unsigned value for this mode. */
2144 int width = GET_MODE_BITSIZE (mode);
2145 if (width < HOST_BITS_PER_WIDE_INT
2146 && ((i0 & ((HOST_WIDE_INT) (-1) << (width - 1)))
2147 != ((HOST_WIDE_INT) (-1) << (width - 1))))
2148 i0 &= ((HOST_WIDE_INT) 1 << width) - 1, i1 = 0;
2149 else if (width == HOST_BITS_PER_WIDE_INT
2150 && ! (i1 == ~0 && i0 < 0))
2151 i1 = 0;
2152 else if (width > 2 * HOST_BITS_PER_WIDE_INT)
2153 /* We cannot represent this value as a constant. */
2154 abort ();
2156 /* If this would be an entire word for the target, but is not for
2157 the host, then sign-extend on the host so that the number will look
2158 the same way on the host that it would on the target.
2160 For example, when building a 64 bit alpha hosted 32 bit sparc
2161 targeted compiler, then we want the 32 bit unsigned value -1 to be
2162 represented as a 64 bit value -1, and not as 0x00000000ffffffff.
2163 The later confuses the sparc backend. */
2165 if (width < HOST_BITS_PER_WIDE_INT
2166 && (i0 & ((HOST_WIDE_INT) 1 << (width - 1))))
2167 i0 |= ((HOST_WIDE_INT) (-1) << width);
2169 /* If MODE fits within HOST_BITS_PER_WIDE_INT, always use a CONST_INT.
2171 ??? Strictly speaking, this is wrong if we create a CONST_INT
2172 for a large unsigned constant with the size of MODE being
2173 HOST_BITS_PER_WIDE_INT and later try to interpret that constant in a
2174 wider mode. In that case we will mis-interpret it as a negative
2175 number.
2177 Unfortunately, the only alternative is to make a CONST_DOUBLE
2178 for any constant in any mode if it is an unsigned constant larger
2179 than the maximum signed integer in an int on the host. However,
2180 doing this will break everyone that always expects to see a CONST_INT
2181 for SImode and smaller.
2183 We have always been making CONST_INTs in this case, so nothing new
2184 is being broken. */
2186 if (width <= HOST_BITS_PER_WIDE_INT)
2187 i1 = (i0 < 0) ? ~(HOST_WIDE_INT) 0 : 0;
2189 /* If this integer fits in one word, return a CONST_INT. */
2190 if ((i1 == 0 && i0 >= 0)
2191 || (i1 == ~0 && i0 < 0))
2192 return GEN_INT (i0);
2194 /* We use VOIDmode for integers. */
2195 mode = VOIDmode;
2198 /* Search the chain for an existing CONST_DOUBLE with the right value.
2199 If one is found, return it. */
2200 if (cfun != 0)
2201 for (r = const_double_chain; r; r = CONST_DOUBLE_CHAIN (r))
2202 if (CONST_DOUBLE_LOW (r) == i0 && CONST_DOUBLE_HIGH (r) == i1
2203 && GET_MODE (r) == mode)
2204 return r;
2206 /* No; make a new one and add it to the chain. */
2207 r = gen_rtx_CONST_DOUBLE (mode, i0, i1);
2209 /* Don't touch const_double_chain if not inside any function. */
2210 if (current_function_decl != 0)
2212 CONST_DOUBLE_CHAIN (r) = const_double_chain;
2213 const_double_chain = r;
2216 return r;
2219 /* Return a CONST_DOUBLE for a specified `double' value
2220 and machine mode. */
2223 immed_real_const_1 (d, mode)
2224 REAL_VALUE_TYPE d;
2225 enum machine_mode mode;
2227 union real_extract u;
2228 rtx r;
2230 /* Get the desired `double' value as a sequence of ints
2231 since that is how they are stored in a CONST_DOUBLE. */
2233 u.d = d;
2235 /* Detect special cases. Check for NaN first, because some ports
2236 (specifically the i386) do not emit correct ieee-fp code by default, and
2237 thus will generate a core dump here if we pass a NaN to REAL_VALUES_EQUAL
2238 and if REAL_VALUES_EQUAL does a floating point comparison. */
2239 if (! REAL_VALUE_ISNAN (d) && REAL_VALUES_IDENTICAL (dconst0, d))
2240 return CONST0_RTX (mode);
2241 else if (! REAL_VALUE_ISNAN (d) && REAL_VALUES_EQUAL (dconst1, d))
2242 return CONST1_RTX (mode);
2243 else if (! REAL_VALUE_ISNAN (d) && REAL_VALUES_EQUAL (dconst2, d))
2244 return CONST2_RTX (mode);
2246 if (sizeof u == sizeof (HOST_WIDE_INT))
2247 return immed_double_const (u.i[0], 0, mode);
2248 if (sizeof u == 2 * sizeof (HOST_WIDE_INT))
2249 return immed_double_const (u.i[0], u.i[1], mode);
2251 /* The rest of this function handles the case where
2252 a float value requires more than 2 ints of space.
2253 It will be deleted as dead code on machines that don't need it. */
2255 /* Search the chain for an existing CONST_DOUBLE with the right value.
2256 If one is found, return it. */
2257 if (cfun != 0)
2258 for (r = const_double_chain; r; r = CONST_DOUBLE_CHAIN (r))
2259 if (! memcmp ((char *) &CONST_DOUBLE_LOW (r), (char *) &u, sizeof u)
2260 && GET_MODE (r) == mode)
2261 return r;
2263 /* No; make a new one and add it to the chain.
2265 We may be called by an optimizer which may be discarding any memory
2266 allocated during its processing (such as combine and loop). However,
2267 we will be leaving this constant on the chain, so we cannot tolerate
2268 freed memory. */
2269 r = rtx_alloc (CONST_DOUBLE);
2270 PUT_MODE (r, mode);
2271 memcpy ((char *) &CONST_DOUBLE_LOW (r), (char *) &u, sizeof u);
2273 /* If we aren't inside a function, don't put r on the
2274 const_double_chain. */
2275 if (current_function_decl != 0)
2277 CONST_DOUBLE_CHAIN (r) = const_double_chain;
2278 const_double_chain = r;
2280 else
2281 CONST_DOUBLE_CHAIN (r) = NULL_RTX;
2283 return r;
2286 /* Return a CONST_DOUBLE rtx for a value specified by EXP,
2287 which must be a REAL_CST tree node. */
2290 immed_real_const (exp)
2291 tree exp;
2293 return immed_real_const_1 (TREE_REAL_CST (exp), TYPE_MODE (TREE_TYPE (exp)));
2296 /* At the end of a function, forget the memory-constants
2297 previously made for CONST_DOUBLEs. Mark them as not on real_constant_chain.
2298 Also clear out real_constant_chain and clear out all the chain-pointers. */
2300 void
2301 clear_const_double_mem ()
2303 rtx r, next;
2305 for (r = const_double_chain; r; r = next)
2307 next = CONST_DOUBLE_CHAIN (r);
2308 CONST_DOUBLE_CHAIN (r) = 0;
2310 const_double_chain = 0;
2313 /* Given an expression EXP with a constant value,
2314 reduce it to the sum of an assembler symbol and an integer.
2315 Store them both in the structure *VALUE.
2316 Abort if EXP does not reduce. */
2318 struct addr_const
2320 rtx base;
2321 HOST_WIDE_INT offset;
2324 static void
2325 decode_addr_const (exp, value)
2326 tree exp;
2327 struct addr_const *value;
2329 tree target = TREE_OPERAND (exp, 0);
2330 int offset = 0;
2331 rtx x;
2333 while (1)
2335 if (TREE_CODE (target) == COMPONENT_REF
2336 && host_integerp (byte_position (TREE_OPERAND (target, 1)), 0))
2339 offset += int_byte_position (TREE_OPERAND (target, 1));
2340 target = TREE_OPERAND (target, 0);
2342 else if (TREE_CODE (target) == ARRAY_REF
2343 || TREE_CODE (target) == ARRAY_RANGE_REF)
2345 offset += (tree_low_cst (TYPE_SIZE_UNIT (TREE_TYPE (target)), 1)
2346 * tree_low_cst (TREE_OPERAND (target, 1), 0));
2347 target = TREE_OPERAND (target, 0);
2349 else
2350 break;
2353 switch (TREE_CODE (target))
2355 case VAR_DECL:
2356 case FUNCTION_DECL:
2357 x = DECL_RTL (target);
2358 break;
2360 case LABEL_DECL:
2361 x = gen_rtx_MEM (FUNCTION_MODE,
2362 gen_rtx_LABEL_REF (VOIDmode,
2363 label_rtx (TREE_OPERAND (exp, 0))));
2364 break;
2366 case REAL_CST:
2367 case STRING_CST:
2368 case COMPLEX_CST:
2369 case CONSTRUCTOR:
2370 case INTEGER_CST:
2371 x = TREE_CST_RTL (target);
2372 break;
2374 default:
2375 abort ();
2378 if (GET_CODE (x) != MEM)
2379 abort ();
2380 x = XEXP (x, 0);
2382 value->base = x;
2383 value->offset = offset;
2386 enum kind { RTX_DOUBLE, RTX_INT };
2387 struct rtx_const
2389 ENUM_BITFIELD(kind) kind : 16;
2390 ENUM_BITFIELD(machine_mode) mode : 16;
2391 union {
2392 union real_extract du;
2393 struct addr_const addr;
2394 struct {HOST_WIDE_INT high, low;} di;
2395 } un;
2398 /* Uniquize all constants that appear in memory.
2399 Each constant in memory thus far output is recorded
2400 in `const_hash_table' with a `struct constant_descriptor'
2401 that contains a polish representation of the value of
2402 the constant.
2404 We cannot store the trees in the hash table
2405 because the trees may be temporary. */
2407 struct constant_descriptor
2409 struct constant_descriptor *next;
2410 const char *label;
2411 rtx rtl;
2412 /* Make sure the data is reasonably aligned. */
2413 union
2415 unsigned char contents[1];
2416 #ifdef HAVE_LONG_DOUBLE
2417 long double d;
2418 #else
2419 double d;
2420 #endif
2421 } u;
2424 #define HASHBITS 30
2425 #define MAX_HASH_TABLE 1009
2426 static struct constant_descriptor *const_hash_table[MAX_HASH_TABLE];
2428 /* We maintain a hash table of STRING_CST values. Unless we are asked to force
2429 out a string constant, we defer output of the constants until we know
2430 they are actually used. This will be if something takes its address or if
2431 there is a usage of the string in the RTL of a function. */
2433 #define STRHASH(x) ((hashval_t)((long)(x) >> 3))
2435 struct deferred_string
2437 const char *label;
2438 tree exp;
2439 int labelno;
2442 static htab_t const_str_htab;
2444 /* Mark a const_hash_table descriptor for GC. */
2446 static void
2447 mark_const_hash_entry (ptr)
2448 void *ptr;
2450 struct constant_descriptor *desc = * (struct constant_descriptor **) ptr;
2452 while (desc)
2454 ggc_mark_rtx (desc->rtl);
2455 desc = desc->next;
2459 /* Mark the hash-table element X (which is really a pointer to an
2460 struct deferred_string *). */
2462 static int
2463 mark_const_str_htab_1 (x, data)
2464 void **x;
2465 void *data ATTRIBUTE_UNUSED;
2467 ggc_mark_tree (((struct deferred_string *) *x)->exp);
2468 return 1;
2471 /* Mark a const_str_htab for GC. */
2473 static void
2474 mark_const_str_htab (htab)
2475 void *htab;
2477 htab_traverse (*((htab_t *) htab), mark_const_str_htab_1, NULL);
2480 /* Returns a hash code for X (which is a really a
2481 struct deferred_string *). */
2483 static hashval_t
2484 const_str_htab_hash (x)
2485 const void *x;
2487 return STRHASH (((const struct deferred_string *) x)->label);
2490 /* Returns non-zero if the value represented by X (which is really a
2491 struct deferred_string *) is the same as that given by Y
2492 (which is really a char *). */
2494 static int
2495 const_str_htab_eq (x, y)
2496 const void *x;
2497 const void *y;
2499 return (((const struct deferred_string *) x)->label == (const char *) y);
2502 /* Delete the hash table entry dfsp. */
2504 static void
2505 const_str_htab_del (dfsp)
2506 void *dfsp;
2508 free (dfsp);
2511 /* Compute a hash code for a constant expression. */
2513 static int
2514 const_hash (exp)
2515 tree exp;
2517 const char *p;
2518 int len, hi, i;
2519 enum tree_code code = TREE_CODE (exp);
2521 /* Either set P and LEN to the address and len of something to hash and
2522 exit the switch or return a value. */
2524 switch (code)
2526 case INTEGER_CST:
2527 p = (char *) &TREE_INT_CST (exp);
2528 len = sizeof TREE_INT_CST (exp);
2529 break;
2531 case REAL_CST:
2532 p = (char *) &TREE_REAL_CST (exp);
2533 len = sizeof TREE_REAL_CST (exp);
2534 break;
2536 case STRING_CST:
2537 p = TREE_STRING_POINTER (exp);
2538 len = TREE_STRING_LENGTH (exp);
2539 break;
2541 case COMPLEX_CST:
2542 return (const_hash (TREE_REALPART (exp)) * 5
2543 + const_hash (TREE_IMAGPART (exp)));
2545 case CONSTRUCTOR:
2546 if (TREE_CODE (TREE_TYPE (exp)) == SET_TYPE)
2548 char *tmp;
2550 len = int_size_in_bytes (TREE_TYPE (exp));
2551 tmp = (char *) alloca (len);
2552 get_set_constructor_bytes (exp, (unsigned char *) tmp, len);
2553 p = tmp;
2554 break;
2556 else
2558 tree link;
2560 /* For record type, include the type in the hashing.
2561 We do not do so for array types
2562 because (1) the sizes of the elements are sufficient
2563 and (2) distinct array types can have the same constructor.
2564 Instead, we include the array size because the constructor could
2565 be shorter. */
2566 if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE)
2567 hi = ((unsigned long) TREE_TYPE (exp) & ((1 << HASHBITS) - 1))
2568 % MAX_HASH_TABLE;
2569 else
2570 hi = ((5 + int_size_in_bytes (TREE_TYPE (exp)))
2571 & ((1 << HASHBITS) - 1)) % MAX_HASH_TABLE;
2573 for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link))
2574 if (TREE_VALUE (link))
2576 = (hi * 603 + const_hash (TREE_VALUE (link))) % MAX_HASH_TABLE;
2578 return hi;
2581 case ADDR_EXPR:
2583 struct addr_const value;
2585 decode_addr_const (exp, &value);
2586 if (GET_CODE (value.base) == SYMBOL_REF)
2588 /* Don't hash the address of the SYMBOL_REF;
2589 only use the offset and the symbol name. */
2590 hi = value.offset;
2591 p = XSTR (value.base, 0);
2592 for (i = 0; p[i] != 0; i++)
2593 hi = ((hi * 613) + (unsigned) (p[i]));
2595 else if (GET_CODE (value.base) == LABEL_REF)
2596 hi = value.offset + CODE_LABEL_NUMBER (XEXP (value.base, 0)) * 13;
2597 else
2598 abort();
2600 hi &= (1 << HASHBITS) - 1;
2601 hi %= MAX_HASH_TABLE;
2603 return hi;
2605 case PLUS_EXPR:
2606 case MINUS_EXPR:
2607 return (const_hash (TREE_OPERAND (exp, 0)) * 9
2608 + const_hash (TREE_OPERAND (exp, 1)));
2610 case NOP_EXPR:
2611 case CONVERT_EXPR:
2612 case NON_LVALUE_EXPR:
2613 return const_hash (TREE_OPERAND (exp, 0)) * 7 + 2;
2615 default:
2616 /* A language specific constant. Just hash the code. */
2617 return (int) code % MAX_HASH_TABLE;
2620 /* Compute hashing function */
2621 hi = len;
2622 for (i = 0; i < len; i++)
2623 hi = ((hi * 613) + (unsigned) (p[i]));
2625 hi &= (1 << HASHBITS) - 1;
2626 hi %= MAX_HASH_TABLE;
2627 return hi;
2630 /* Compare a constant expression EXP with a constant-descriptor DESC.
2631 Return 1 if DESC describes a constant with the same value as EXP. */
2633 static int
2634 compare_constant (exp, desc)
2635 tree exp;
2636 struct constant_descriptor *desc;
2638 return 0 != compare_constant_1 (exp, desc->u.contents);
2641 /* Compare constant expression EXP with a substring P of a constant descriptor.
2642 If they match, return a pointer to the end of the substring matched.
2643 If they do not match, return 0.
2645 Since descriptors are written in polish prefix notation,
2646 this function can be used recursively to test one operand of EXP
2647 against a subdescriptor, and if it succeeds it returns the
2648 address of the subdescriptor for the next operand. */
2650 static const unsigned char *
2651 compare_constant_1 (exp, p)
2652 tree exp;
2653 const unsigned char *p;
2655 const unsigned char *strp;
2656 int len;
2657 enum tree_code code = TREE_CODE (exp);
2659 if (code != (enum tree_code) *p++)
2660 return 0;
2662 /* Either set STRP, P and LEN to pointers and length to compare and exit the
2663 switch, or return the result of the comparison. */
2665 switch (code)
2667 case INTEGER_CST:
2668 /* Integer constants are the same only if the same width of type. */
2669 if (*p++ != TYPE_PRECISION (TREE_TYPE (exp)))
2670 return 0;
2672 strp = (unsigned char *) &TREE_INT_CST (exp);
2673 len = sizeof TREE_INT_CST (exp);
2674 break;
2676 case REAL_CST:
2677 /* Real constants are the same only if the same width of type. */
2678 if (*p++ != TYPE_PRECISION (TREE_TYPE (exp)))
2679 return 0;
2681 strp = (unsigned char *) &TREE_REAL_CST (exp);
2682 len = sizeof TREE_REAL_CST (exp);
2683 break;
2685 case STRING_CST:
2686 if (flag_writable_strings)
2687 return 0;
2689 if ((enum machine_mode) *p++ != TYPE_MODE (TREE_TYPE (exp)))
2690 return 0;
2692 strp = (const unsigned char *)TREE_STRING_POINTER (exp);
2693 len = TREE_STRING_LENGTH (exp);
2694 if (memcmp ((char *) &TREE_STRING_LENGTH (exp), p,
2695 sizeof TREE_STRING_LENGTH (exp)))
2696 return 0;
2698 p += sizeof TREE_STRING_LENGTH (exp);
2699 break;
2701 case COMPLEX_CST:
2702 p = compare_constant_1 (TREE_REALPART (exp), p);
2703 if (p == 0)
2704 return 0;
2706 return compare_constant_1 (TREE_IMAGPART (exp), p);
2708 case CONSTRUCTOR:
2709 if (TREE_CODE (TREE_TYPE (exp)) == SET_TYPE)
2711 int xlen = len = int_size_in_bytes (TREE_TYPE (exp));
2712 unsigned char *tmp = (unsigned char *) alloca (len);
2714 get_set_constructor_bytes (exp, tmp, len);
2715 strp = (unsigned char *) tmp;
2716 if (memcmp ((char *) &xlen, p, sizeof xlen))
2717 return 0;
2719 p += sizeof xlen;
2720 break;
2722 else
2724 tree link;
2725 int length = list_length (CONSTRUCTOR_ELTS (exp));
2726 tree type;
2727 enum machine_mode mode = TYPE_MODE (TREE_TYPE (exp));
2728 int have_purpose = 0;
2730 for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link))
2731 if (TREE_PURPOSE (link))
2732 have_purpose = 1;
2734 if (memcmp ((char *) &length, p, sizeof length))
2735 return 0;
2737 p += sizeof length;
2739 /* For record constructors, insist that the types match.
2740 For arrays, just verify both constructors are for arrays.
2741 Then insist that either both or none have any TREE_PURPOSE
2742 values. */
2743 if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE)
2744 type = TREE_TYPE (exp);
2745 else
2746 type = 0;
2748 if (memcmp ((char *) &type, p, sizeof type))
2749 return 0;
2751 if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE)
2753 if (memcmp ((char *) &mode, p, sizeof mode))
2754 return 0;
2756 p += sizeof mode;
2759 p += sizeof type;
2761 if (memcmp ((char *) &have_purpose, p, sizeof have_purpose))
2762 return 0;
2764 p += sizeof have_purpose;
2766 /* For arrays, insist that the size in bytes match. */
2767 if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE)
2769 HOST_WIDE_INT size = int_size_in_bytes (TREE_TYPE (exp));
2771 if (memcmp ((char *) &size, p, sizeof size))
2772 return 0;
2774 p += sizeof size;
2777 for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link))
2779 if (TREE_VALUE (link))
2781 if ((p = compare_constant_1 (TREE_VALUE (link), p)) == 0)
2782 return 0;
2784 else
2786 tree zero = 0;
2788 if (memcmp ((char *) &zero, p, sizeof zero))
2789 return 0;
2791 p += sizeof zero;
2794 if (TREE_PURPOSE (link)
2795 && TREE_CODE (TREE_PURPOSE (link)) == FIELD_DECL)
2797 if (memcmp ((char *) &TREE_PURPOSE (link), p,
2798 sizeof TREE_PURPOSE (link)))
2799 return 0;
2801 p += sizeof TREE_PURPOSE (link);
2803 else if (TREE_PURPOSE (link))
2805 if ((p = compare_constant_1 (TREE_PURPOSE (link), p)) == 0)
2806 return 0;
2808 else if (have_purpose)
2810 int zero = 0;
2812 if (memcmp ((char *) &zero, p, sizeof zero))
2813 return 0;
2815 p += sizeof zero;
2819 return p;
2822 case ADDR_EXPR:
2824 struct addr_const value;
2826 decode_addr_const (exp, &value);
2827 strp = (unsigned char *) &value.offset;
2828 len = sizeof value.offset;
2829 /* Compare the offset. */
2830 while (--len >= 0)
2831 if (*p++ != *strp++)
2832 return 0;
2834 /* Compare symbol name. */
2835 strp = (const unsigned char *) XSTR (value.base, 0);
2836 len = strlen ((const char *) strp) + 1;
2838 break;
2840 case PLUS_EXPR:
2841 case MINUS_EXPR:
2842 case RANGE_EXPR:
2843 p = compare_constant_1 (TREE_OPERAND (exp, 0), p);
2844 if (p == 0)
2845 return 0;
2847 return compare_constant_1 (TREE_OPERAND (exp, 1), p);
2849 case NOP_EXPR:
2850 case CONVERT_EXPR:
2851 case NON_LVALUE_EXPR:
2852 return compare_constant_1 (TREE_OPERAND (exp, 0), p);
2854 default:
2856 tree new = (*lang_hooks.expand_constant) (exp);
2858 if (new != exp)
2859 return compare_constant_1 (new, p);
2860 else
2861 return 0;
2865 /* Compare constant contents. */
2866 while (--len >= 0)
2867 if (*p++ != *strp++)
2868 return 0;
2870 return p;
2873 /* Construct a constant descriptor for the expression EXP.
2874 It is up to the caller to enter the descriptor in the hash table. */
2876 static struct constant_descriptor *
2877 record_constant (exp)
2878 tree exp;
2880 struct constant_descriptor *next = 0;
2881 char *label = 0;
2882 rtx rtl = 0;
2883 int pad;
2885 /* Make a struct constant_descriptor. The first three pointers will
2886 be filled in later. Here we just leave space for them. */
2888 obstack_grow (&permanent_obstack, (char *) &next, sizeof next);
2889 obstack_grow (&permanent_obstack, (char *) &label, sizeof label);
2890 obstack_grow (&permanent_obstack, (char *) &rtl, sizeof rtl);
2892 /* Align the descriptor for the data payload. */
2893 pad = (offsetof (struct constant_descriptor, u)
2894 - offsetof(struct constant_descriptor, rtl)
2895 - sizeof(next->rtl));
2896 if (pad > 0)
2897 obstack_blank (&permanent_obstack, pad);
2899 record_constant_1 (exp);
2900 return (struct constant_descriptor *) obstack_finish (&permanent_obstack);
2903 /* Add a description of constant expression EXP
2904 to the object growing in `permanent_obstack'.
2905 No need to return its address; the caller will get that
2906 from the obstack when the object is complete. */
2908 static void
2909 record_constant_1 (exp)
2910 tree exp;
2912 const unsigned char *strp;
2913 int len;
2914 enum tree_code code = TREE_CODE (exp);
2916 obstack_1grow (&permanent_obstack, (unsigned int) code);
2918 switch (code)
2920 case INTEGER_CST:
2921 obstack_1grow (&permanent_obstack, TYPE_PRECISION (TREE_TYPE (exp)));
2922 strp = (unsigned char *) &TREE_INT_CST (exp);
2923 len = sizeof TREE_INT_CST (exp);
2924 break;
2926 case REAL_CST:
2927 obstack_1grow (&permanent_obstack, TYPE_PRECISION (TREE_TYPE (exp)));
2928 strp = (unsigned char *) &TREE_REAL_CST (exp);
2929 len = sizeof TREE_REAL_CST (exp);
2930 break;
2932 case STRING_CST:
2933 if (flag_writable_strings)
2934 return;
2936 obstack_1grow (&permanent_obstack, TYPE_MODE (TREE_TYPE (exp)));
2937 strp = (const unsigned char *) TREE_STRING_POINTER (exp);
2938 len = TREE_STRING_LENGTH (exp);
2939 obstack_grow (&permanent_obstack, (char *) &TREE_STRING_LENGTH (exp),
2940 sizeof TREE_STRING_LENGTH (exp));
2941 break;
2943 case COMPLEX_CST:
2944 record_constant_1 (TREE_REALPART (exp));
2945 record_constant_1 (TREE_IMAGPART (exp));
2946 return;
2948 case CONSTRUCTOR:
2949 if (TREE_CODE (TREE_TYPE (exp)) == SET_TYPE)
2951 int nbytes = int_size_in_bytes (TREE_TYPE (exp));
2952 obstack_grow (&permanent_obstack, &nbytes, sizeof (nbytes));
2953 obstack_blank (&permanent_obstack, nbytes);
2954 get_set_constructor_bytes
2955 (exp, (unsigned char *) permanent_obstack.next_free-nbytes,
2956 nbytes);
2957 return;
2959 else
2961 tree link;
2962 int length = list_length (CONSTRUCTOR_ELTS (exp));
2963 enum machine_mode mode = TYPE_MODE (TREE_TYPE (exp));
2964 tree type;
2965 int have_purpose = 0;
2967 for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link))
2968 if (TREE_PURPOSE (link))
2969 have_purpose = 1;
2971 obstack_grow (&permanent_obstack, (char *) &length, sizeof length);
2973 /* For record constructors, insist that the types match.
2974 For arrays, just verify both constructors are for arrays
2975 of the same mode. Then insist that either both or none
2976 have any TREE_PURPOSE values. */
2977 if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE)
2978 type = TREE_TYPE (exp);
2979 else
2980 type = 0;
2982 obstack_grow (&permanent_obstack, (char *) &type, sizeof type);
2983 if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE)
2984 obstack_grow (&permanent_obstack, &mode, sizeof mode);
2986 obstack_grow (&permanent_obstack, (char *) &have_purpose,
2987 sizeof have_purpose);
2989 /* For arrays, insist that the size in bytes match. */
2990 if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE)
2992 HOST_WIDE_INT size = int_size_in_bytes (TREE_TYPE (exp));
2993 obstack_grow (&permanent_obstack, (char *) &size, sizeof size);
2996 for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link))
2998 if (TREE_VALUE (link))
2999 record_constant_1 (TREE_VALUE (link));
3000 else
3002 tree zero = 0;
3004 obstack_grow (&permanent_obstack,
3005 (char *) &zero, sizeof zero);
3008 if (TREE_PURPOSE (link)
3009 && TREE_CODE (TREE_PURPOSE (link)) == FIELD_DECL)
3010 obstack_grow (&permanent_obstack,
3011 (char *) &TREE_PURPOSE (link),
3012 sizeof TREE_PURPOSE (link));
3013 else if (TREE_PURPOSE (link))
3014 record_constant_1 (TREE_PURPOSE (link));
3015 else if (have_purpose)
3017 int zero = 0;
3019 obstack_grow (&permanent_obstack,
3020 (char *) &zero, sizeof zero);
3024 return;
3026 case ADDR_EXPR:
3028 struct addr_const value;
3030 decode_addr_const (exp, &value);
3031 /* Record the offset. */
3032 obstack_grow (&permanent_obstack,
3033 (char *) &value.offset, sizeof value.offset);
3035 switch (GET_CODE (value.base))
3037 case SYMBOL_REF:
3038 /* Record the symbol name. */
3039 obstack_grow (&permanent_obstack, XSTR (value.base, 0),
3040 strlen (XSTR (value.base, 0)) + 1);
3041 break;
3042 case LABEL_REF:
3043 /* Record the address of the CODE_LABEL. It may not have
3044 been emitted yet, so it's UID may be zero. But pointer
3045 identity is good enough. */
3046 obstack_grow (&permanent_obstack, &XEXP (value.base, 0),
3047 sizeof (rtx));
3048 break;
3049 default:
3050 abort ();
3053 return;
3055 case PLUS_EXPR:
3056 case MINUS_EXPR:
3057 case RANGE_EXPR:
3058 record_constant_1 (TREE_OPERAND (exp, 0));
3059 record_constant_1 (TREE_OPERAND (exp, 1));
3060 return;
3062 case NOP_EXPR:
3063 case CONVERT_EXPR:
3064 case NON_LVALUE_EXPR:
3065 record_constant_1 (TREE_OPERAND (exp, 0));
3066 return;
3068 default:
3070 tree new = (*lang_hooks.expand_constant) (exp);
3072 if (new != exp)
3073 record_constant_1 (exp);
3074 return;
3078 /* Record constant contents. */
3079 obstack_grow (&permanent_obstack, strp, len);
3082 /* Record a list of constant expressions that were passed to
3083 output_constant_def but that could not be output right away. */
3085 struct deferred_constant
3087 struct deferred_constant *next;
3088 tree exp;
3089 int reloc;
3090 int labelno;
3093 static struct deferred_constant *deferred_constants;
3095 /* Another list of constants which should be output after the
3096 function. */
3097 static struct deferred_constant *after_function_constants;
3099 /* Nonzero means defer output of addressed subconstants
3100 (i.e., those for which output_constant_def is called.) */
3101 static int defer_addressed_constants_flag;
3103 /* Start deferring output of subconstants. */
3105 void
3106 defer_addressed_constants ()
3108 defer_addressed_constants_flag++;
3111 /* Stop deferring output of subconstants,
3112 and output now all those that have been deferred. */
3114 void
3115 output_deferred_addressed_constants ()
3117 struct deferred_constant *p, *next;
3119 defer_addressed_constants_flag--;
3121 if (defer_addressed_constants_flag > 0)
3122 return;
3124 for (p = deferred_constants; p; p = next)
3126 output_constant_def_contents (p->exp, p->reloc, p->labelno);
3127 next = p->next;
3128 free (p);
3131 deferred_constants = 0;
3134 /* Output any constants which should appear after a function. */
3136 static void
3137 output_after_function_constants ()
3139 struct deferred_constant *p, *next;
3141 for (p = after_function_constants; p; p = next)
3143 output_constant_def_contents (p->exp, p->reloc, p->labelno);
3144 next = p->next;
3145 free (p);
3148 after_function_constants = 0;
3151 /* Make a copy of the whole tree structure for a constant.
3152 This handles the same types of nodes that compare_constant
3153 and record_constant handle. */
3155 static tree
3156 copy_constant (exp)
3157 tree exp;
3159 switch (TREE_CODE (exp))
3161 case ADDR_EXPR:
3162 /* For ADDR_EXPR, we do not want to copy the decl whose address
3163 is requested. We do want to copy constants though. */
3164 if (TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp, 0))) == 'c')
3165 return build1 (TREE_CODE (exp), TREE_TYPE (exp),
3166 copy_constant (TREE_OPERAND (exp, 0)));
3167 else
3168 return copy_node (exp);
3170 case INTEGER_CST:
3171 case REAL_CST:
3172 case STRING_CST:
3173 return copy_node (exp);
3175 case COMPLEX_CST:
3176 return build_complex (TREE_TYPE (exp),
3177 copy_constant (TREE_REALPART (exp)),
3178 copy_constant (TREE_IMAGPART (exp)));
3180 case PLUS_EXPR:
3181 case MINUS_EXPR:
3182 return build (TREE_CODE (exp), TREE_TYPE (exp),
3183 copy_constant (TREE_OPERAND (exp, 0)),
3184 copy_constant (TREE_OPERAND (exp, 1)));
3186 case NOP_EXPR:
3187 case CONVERT_EXPR:
3188 case NON_LVALUE_EXPR:
3189 return build1 (TREE_CODE (exp), TREE_TYPE (exp),
3190 copy_constant (TREE_OPERAND (exp, 0)));
3192 case CONSTRUCTOR:
3194 tree copy = copy_node (exp);
3195 tree list = copy_list (CONSTRUCTOR_ELTS (exp));
3196 tree tail;
3198 CONSTRUCTOR_ELTS (copy) = list;
3199 for (tail = list; tail; tail = TREE_CHAIN (tail))
3200 TREE_VALUE (tail) = copy_constant (TREE_VALUE (tail));
3201 if (TREE_CODE (TREE_TYPE (exp)) == SET_TYPE)
3202 for (tail = list; tail; tail = TREE_CHAIN (tail))
3203 TREE_PURPOSE (tail) = copy_constant (TREE_PURPOSE (tail));
3205 return copy;
3208 default:
3209 abort ();
3213 /* Return an rtx representing a reference to constant data in memory
3214 for the constant expression EXP.
3216 If assembler code for such a constant has already been output,
3217 return an rtx to refer to it.
3218 Otherwise, output such a constant in memory (or defer it for later)
3219 and generate an rtx for it.
3221 If DEFER is non-zero, the output of string constants can be deferred
3222 and output only if referenced in the function after all optimizations.
3224 The TREE_CST_RTL of EXP is set up to point to that rtx.
3225 The const_hash_table records which constants already have label strings. */
3228 output_constant_def (exp, defer)
3229 tree exp;
3230 int defer;
3232 int hash;
3233 struct constant_descriptor *desc;
3234 struct deferred_string **defstr;
3235 char label[256];
3236 int reloc;
3237 int found = 1;
3238 int after_function = 0;
3239 int labelno = -1;
3240 rtx rtl;
3242 /* We can't just use the saved RTL if this is a defererred string constant
3243 and we are not to defer anymode. */
3244 if (TREE_CODE (exp) != INTEGER_CST && TREE_CST_RTL (exp)
3245 && (defer || !STRING_POOL_ADDRESS_P (XEXP (TREE_CST_RTL (exp), 0))))
3246 return TREE_CST_RTL (exp);
3248 /* Make sure any other constants whose addresses appear in EXP
3249 are assigned label numbers. */
3251 reloc = output_addressed_constants (exp);
3253 /* Compute hash code of EXP. Search the descriptors for that hash code
3254 to see if any of them describes EXP. If yes, the descriptor records
3255 the label number already assigned. */
3257 hash = const_hash (exp) % MAX_HASH_TABLE;
3259 for (desc = const_hash_table[hash]; desc; desc = desc->next)
3260 if (compare_constant (exp, desc))
3261 break;
3263 if (desc == 0)
3265 /* No constant equal to EXP is known to have been output.
3266 Make a constant descriptor to enter EXP in the hash table.
3267 Assign the label number and record it in the descriptor for
3268 future calls to this function to find. */
3270 /* Create a string containing the label name, in LABEL. */
3271 labelno = const_labelno++;
3272 ASM_GENERATE_INTERNAL_LABEL (label, "LC", labelno);
3274 desc = record_constant (exp);
3275 desc->next = const_hash_table[hash];
3276 desc->label = ggc_strdup (label);
3277 const_hash_table[hash] = desc;
3279 /* We have a symbol name; construct the SYMBOL_REF and the MEM. */
3280 rtl = desc->rtl
3281 = gen_rtx_MEM (TYPE_MODE (TREE_TYPE (exp)),
3282 gen_rtx_SYMBOL_REF (Pmode, desc->label));
3284 set_mem_attributes (rtl, exp, 1);
3285 set_mem_alias_set (rtl, 0);
3286 set_mem_alias_set (rtl, const_alias_set);
3288 found = 0;
3290 else
3291 rtl = desc->rtl;
3293 if (TREE_CODE (exp) != INTEGER_CST)
3294 TREE_CST_RTL (exp) = rtl;
3296 /* Optionally set flags or add text to the name to record information
3297 such as that it is a function name. If the name is changed, the macro
3298 ASM_OUTPUT_LABELREF will have to know how to strip this information. */
3299 #ifdef ENCODE_SECTION_INFO
3300 /* A previously-processed constant would already have section info
3301 encoded in it. */
3302 if (! found)
3304 ENCODE_SECTION_INFO (exp);
3305 desc->rtl = rtl;
3306 desc->label = XSTR (XEXP (desc->rtl, 0), 0);
3308 #endif
3310 #ifdef CONSTANT_AFTER_FUNCTION_P
3311 if (current_function_decl != 0
3312 && CONSTANT_AFTER_FUNCTION_P (exp))
3313 after_function = 1;
3314 #endif
3316 if (found
3317 && STRING_POOL_ADDRESS_P (XEXP (rtl, 0))
3318 && (!defer || defer_addressed_constants_flag || after_function))
3320 defstr = (struct deferred_string **)
3321 htab_find_slot_with_hash (const_str_htab, desc->label,
3322 STRHASH (desc->label), NO_INSERT);
3323 if (defstr)
3325 /* If the string is currently deferred but we need to output it now,
3326 remove it from deferred string hash table. */
3327 found = 0;
3328 labelno = (*defstr)->labelno;
3329 STRING_POOL_ADDRESS_P (XEXP (rtl, 0)) = 0;
3330 htab_clear_slot (const_str_htab, (void **) defstr);
3334 /* If this is the first time we've seen this particular constant,
3335 output it (or defer its output for later). */
3336 if (! found)
3338 if (defer_addressed_constants_flag || after_function)
3340 struct deferred_constant *p
3341 = (struct deferred_constant *)
3342 xmalloc (sizeof (struct deferred_constant));
3344 p->exp = copy_constant (exp);
3345 p->reloc = reloc;
3346 p->labelno = labelno;
3347 if (after_function)
3349 p->next = after_function_constants;
3350 after_function_constants = p;
3352 else
3354 p->next = deferred_constants;
3355 deferred_constants = p;
3358 else
3360 /* Do no output if -fsyntax-only. */
3361 if (! flag_syntax_only)
3363 if (TREE_CODE (exp) != STRING_CST
3364 || !defer
3365 || flag_writable_strings
3366 || (defstr = (struct deferred_string **)
3367 htab_find_slot_with_hash (const_str_htab,
3368 desc->label,
3369 STRHASH (desc->label),
3370 INSERT)) == NULL)
3371 output_constant_def_contents (exp, reloc, labelno);
3372 else
3374 struct deferred_string *p;
3376 p = (struct deferred_string *)
3377 xmalloc (sizeof (struct deferred_string));
3379 p->exp = copy_constant (exp);
3380 p->label = desc->label;
3381 p->labelno = labelno;
3382 *defstr = p;
3383 STRING_POOL_ADDRESS_P (XEXP (rtl, 0)) = 1;
3389 return rtl;
3392 /* Now output assembler code to define the label for EXP,
3393 and follow it with the data of EXP. */
3395 static void
3396 output_constant_def_contents (exp, reloc, labelno)
3397 tree exp;
3398 int reloc;
3399 int labelno;
3401 int align;
3403 /* Align the location counter as required by EXP's data type. */
3404 align = TYPE_ALIGN (TREE_TYPE (exp));
3405 #ifdef CONSTANT_ALIGNMENT
3406 align = CONSTANT_ALIGNMENT (exp, align);
3407 #endif
3409 if (IN_NAMED_SECTION (exp))
3410 named_section (exp, NULL, reloc);
3411 else
3413 /* First switch to text section, except for writable strings. */
3414 #ifdef SELECT_SECTION
3415 SELECT_SECTION (exp, reloc, align);
3416 #else
3417 if (((TREE_CODE (exp) == STRING_CST) && flag_writable_strings)
3418 || (flag_pic && reloc))
3419 data_section ();
3420 else
3421 readonly_data_section ();
3422 #endif
3425 if (align > BITS_PER_UNIT)
3427 ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT));
3430 /* Output the label itself. */
3431 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LC", labelno);
3433 /* Output the value of EXP. */
3434 output_constant (exp,
3435 (TREE_CODE (exp) == STRING_CST
3436 ? MAX (TREE_STRING_LENGTH (exp),
3437 int_size_in_bytes (TREE_TYPE (exp)))
3438 : int_size_in_bytes (TREE_TYPE (exp))),
3439 align);
3443 /* Structure to represent sufficient information about a constant so that
3444 it can be output when the constant pool is output, so that function
3445 integration can be done, and to simplify handling on machines that reference
3446 constant pool as base+displacement. */
3448 struct pool_constant
3450 struct constant_descriptor *desc;
3451 struct pool_constant *next, *next_sym;
3452 rtx constant;
3453 enum machine_mode mode;
3454 int labelno;
3455 unsigned int align;
3456 HOST_WIDE_INT offset;
3457 int mark;
3460 /* Hash code for a SYMBOL_REF with CONSTANT_POOL_ADDRESS_P true.
3461 The argument is XSTR (... , 0) */
3463 #define SYMHASH(LABEL) \
3464 ((((unsigned long) (LABEL)) & ((1 << HASHBITS) - 1)) % MAX_RTX_HASH_TABLE)
3466 /* Initialize constant pool hashing for a new function. */
3468 void
3469 init_varasm_status (f)
3470 struct function *f;
3472 struct varasm_status *p;
3473 p = (struct varasm_status *) xmalloc (sizeof (struct varasm_status));
3474 f->varasm = p;
3475 p->x_const_rtx_hash_table
3476 = ((struct constant_descriptor **)
3477 xcalloc (MAX_RTX_HASH_TABLE, sizeof (struct constant_descriptor *)));
3478 p->x_const_rtx_sym_hash_table
3479 = ((struct pool_constant **)
3480 xcalloc (MAX_RTX_HASH_TABLE, sizeof (struct pool_constant *)));
3482 p->x_first_pool = p->x_last_pool = 0;
3483 p->x_pool_offset = 0;
3484 p->x_const_double_chain = 0;
3487 /* Mark PC for GC. */
3489 static void
3490 mark_pool_constant (pc)
3491 struct pool_constant *pc;
3493 while (pc)
3495 ggc_mark (pc);
3496 ggc_mark_rtx (pc->constant);
3497 ggc_mark_rtx (pc->desc->rtl);
3498 pc = pc->next;
3502 /* Mark P for GC. */
3504 void
3505 mark_varasm_status (p)
3506 struct varasm_status *p;
3508 if (p == NULL)
3509 return;
3511 mark_pool_constant (p->x_first_pool);
3512 ggc_mark_rtx (p->x_const_double_chain);
3515 /* Clear out all parts of the state in F that can safely be discarded
3516 after the function has been compiled, to let garbage collection
3517 reclaim the memory. */
3519 void
3520 free_varasm_status (f)
3521 struct function *f;
3523 struct varasm_status *p;
3524 int i;
3526 p = f->varasm;
3528 /* Clear out the hash tables. */
3529 for (i = 0; i < MAX_RTX_HASH_TABLE; ++i)
3531 struct constant_descriptor *cd;
3533 cd = p->x_const_rtx_hash_table[i];
3534 while (cd)
3536 struct constant_descriptor *next = cd->next;
3538 free (cd);
3539 cd = next;
3543 free (p->x_const_rtx_hash_table);
3544 free (p->x_const_rtx_sym_hash_table);
3545 free (p);
3547 f->varasm = NULL;
3551 /* Express an rtx for a constant integer (perhaps symbolic)
3552 as the sum of a symbol or label plus an explicit integer.
3553 They are stored into VALUE. */
3555 static void
3556 decode_rtx_const (mode, x, value)
3557 enum machine_mode mode;
3558 rtx x;
3559 struct rtx_const *value;
3561 /* Clear the whole structure, including any gaps. */
3562 memset (value, 0, sizeof (struct rtx_const));
3564 value->kind = RTX_INT; /* Most usual kind. */
3565 value->mode = mode;
3567 switch (GET_CODE (x))
3569 case CONST_DOUBLE:
3570 value->kind = RTX_DOUBLE;
3571 if (GET_MODE (x) != VOIDmode)
3573 value->mode = GET_MODE (x);
3574 memcpy ((char *) &value->un.du,
3575 (char *) &CONST_DOUBLE_LOW (x), sizeof value->un.du);
3577 else
3579 value->un.di.low = CONST_DOUBLE_LOW (x);
3580 value->un.di.high = CONST_DOUBLE_HIGH (x);
3582 break;
3584 case CONST_INT:
3585 value->un.addr.offset = INTVAL (x);
3586 break;
3588 case SYMBOL_REF:
3589 case LABEL_REF:
3590 case PC:
3591 value->un.addr.base = x;
3592 break;
3594 case CONST:
3595 x = XEXP (x, 0);
3596 if (GET_CODE (x) == PLUS && GET_CODE (XEXP (x, 1)) == CONST_INT)
3598 value->un.addr.base = XEXP (x, 0);
3599 value->un.addr.offset = INTVAL (XEXP (x, 1));
3601 else if (GET_CODE (x) == MINUS && GET_CODE (XEXP (x, 1)) == CONST_INT)
3603 value->un.addr.base = XEXP (x, 0);
3604 value->un.addr.offset = - INTVAL (XEXP (x, 1));
3606 else
3608 value->un.addr.base = x;
3609 value->un.addr.offset = 0;
3611 break;
3613 default:
3614 abort ();
3617 if (value->kind == RTX_INT && value->un.addr.base != 0)
3618 switch (GET_CODE (value->un.addr.base))
3620 case SYMBOL_REF:
3621 /* Use the string's address, not the SYMBOL_REF's address,
3622 for the sake of addresses of library routines. */
3623 value->un.addr.base = (rtx) XSTR (value->un.addr.base, 0);
3624 break;
3626 case LABEL_REF:
3627 /* For a LABEL_REF, compare labels. */
3628 value->un.addr.base = XEXP (value->un.addr.base, 0);
3630 default:
3631 break;
3635 /* Given a MINUS expression, simplify it if both sides
3636 include the same symbol. */
3639 simplify_subtraction (x)
3640 rtx x;
3642 struct rtx_const val0, val1;
3644 decode_rtx_const (GET_MODE (x), XEXP (x, 0), &val0);
3645 decode_rtx_const (GET_MODE (x), XEXP (x, 1), &val1);
3647 if (val0.un.addr.base == val1.un.addr.base)
3648 return GEN_INT (val0.un.addr.offset - val1.un.addr.offset);
3649 return x;
3652 /* Compute a hash code for a constant RTL expression. */
3654 static int
3655 const_hash_rtx (mode, x)
3656 enum machine_mode mode;
3657 rtx x;
3659 int hi;
3660 size_t i;
3662 struct rtx_const value;
3663 decode_rtx_const (mode, x, &value);
3665 /* Compute hashing function */
3666 hi = 0;
3667 for (i = 0; i < sizeof value / sizeof (int); i++)
3668 hi += ((int *) &value)[i];
3670 hi &= (1 << HASHBITS) - 1;
3671 hi %= MAX_RTX_HASH_TABLE;
3672 return hi;
3675 /* Compare a constant rtl object X with a constant-descriptor DESC.
3676 Return 1 if DESC describes a constant with the same value as X. */
3678 static int
3679 compare_constant_rtx (mode, x, desc)
3680 enum machine_mode mode;
3681 rtx x;
3682 struct constant_descriptor *desc;
3684 int *p = (int *) desc->u.contents;
3685 int *strp;
3686 int len;
3687 struct rtx_const value;
3689 decode_rtx_const (mode, x, &value);
3690 strp = (int *) &value;
3691 len = sizeof value / sizeof (int);
3693 /* Compare constant contents. */
3694 while (--len >= 0)
3695 if (*p++ != *strp++)
3696 return 0;
3698 return 1;
3701 /* Construct a constant descriptor for the rtl-expression X.
3702 It is up to the caller to enter the descriptor in the hash table. */
3704 static struct constant_descriptor *
3705 record_constant_rtx (mode, x)
3706 enum machine_mode mode;
3707 rtx x;
3709 struct constant_descriptor *ptr;
3711 ptr = ((struct constant_descriptor *)
3712 xcalloc (1, (offsetof (struct constant_descriptor, u)
3713 + sizeof (struct rtx_const))));
3714 decode_rtx_const (mode, x, (struct rtx_const *) ptr->u.contents);
3716 return ptr;
3719 /* Given a constant rtx X, return a MEM for the location in memory at which
3720 this constant has been placed. Return 0 if it not has been placed yet. */
3723 mem_for_const_double (x)
3724 rtx x;
3726 enum machine_mode mode = GET_MODE (x);
3727 struct constant_descriptor *desc;
3729 for (desc = const_rtx_hash_table[const_hash_rtx (mode, x)]; desc;
3730 desc = desc->next)
3731 if (compare_constant_rtx (mode, x, desc))
3732 return desc->rtl;
3734 return 0;
3737 /* Given a constant rtx X, make (or find) a memory constant for its value
3738 and return a MEM rtx to refer to it in memory. */
3741 force_const_mem (mode, x)
3742 enum machine_mode mode;
3743 rtx x;
3745 int hash;
3746 struct constant_descriptor *desc;
3747 char label[256];
3748 rtx def;
3749 struct pool_constant *pool;
3750 unsigned int align;
3752 /* Compute hash code of X. Search the descriptors for that hash code
3753 to see if any of them describes X. If yes, we have an rtx to use. */
3754 hash = const_hash_rtx (mode, x);
3755 for (desc = const_rtx_hash_table[hash]; desc; desc = desc->next)
3756 if (compare_constant_rtx (mode, x, desc))
3757 return desc->rtl;
3759 /* No constant equal to X is known to have been output.
3760 Make a constant descriptor to enter X in the hash table
3761 and make a MEM for it. */
3762 desc = record_constant_rtx (mode, x);
3763 desc->next = const_rtx_hash_table[hash];
3764 const_rtx_hash_table[hash] = desc;
3766 /* Align the location counter as required by EXP's data type. */
3767 align = GET_MODE_ALIGNMENT (mode == VOIDmode ? word_mode : mode);
3768 #ifdef CONSTANT_ALIGNMENT
3769 align = CONSTANT_ALIGNMENT (make_tree (type_for_mode (mode, 0), x), align);
3770 #endif
3772 pool_offset += (align / BITS_PER_UNIT) - 1;
3773 pool_offset &= ~ ((align / BITS_PER_UNIT) - 1);
3775 if (GET_CODE (x) == LABEL_REF)
3776 LABEL_PRESERVE_P (XEXP (x, 0)) = 1;
3778 /* Allocate a pool constant descriptor, fill it in, and chain it in. */
3779 pool = (struct pool_constant *) ggc_alloc (sizeof (struct pool_constant));
3780 pool->desc = desc;
3781 pool->constant = x;
3782 pool->mode = mode;
3783 pool->labelno = const_labelno;
3784 pool->align = align;
3785 pool->offset = pool_offset;
3786 pool->mark = 1;
3787 pool->next = 0;
3789 if (last_pool == 0)
3790 first_pool = pool;
3791 else
3792 last_pool->next = pool;
3794 last_pool = pool;
3795 pool_offset += GET_MODE_SIZE (mode);
3797 /* Create a string containing the label name, in LABEL. */
3798 ASM_GENERATE_INTERNAL_LABEL (label, "LC", const_labelno);
3800 ++const_labelno;
3802 /* Construct the SYMBOL_REF and the MEM. */
3804 pool->desc->rtl = def
3805 = gen_rtx_MEM (mode, gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (label)));
3806 set_mem_alias_set (def, const_alias_set);
3807 set_mem_attributes (def, type_for_mode (mode, 0), 1);
3808 RTX_UNCHANGING_P (def) = 1;
3810 /* Add label to symbol hash table. */
3811 hash = SYMHASH (XSTR (XEXP (def, 0), 0));
3812 pool->next_sym = const_rtx_sym_hash_table[hash];
3813 const_rtx_sym_hash_table[hash] = pool;
3815 /* Mark the symbol_ref as belonging to this constants pool. */
3816 CONSTANT_POOL_ADDRESS_P (XEXP (def, 0)) = 1;
3817 current_function_uses_const_pool = 1;
3819 return def;
3822 /* Given a SYMBOL_REF with CONSTANT_POOL_ADDRESS_P true, return a pointer to
3823 the corresponding pool_constant structure. */
3825 static struct pool_constant *
3826 find_pool_constant (f, addr)
3827 struct function *f;
3828 rtx addr;
3830 struct pool_constant *pool;
3831 const char *label = XSTR (addr, 0);
3833 for (pool = f->varasm->x_const_rtx_sym_hash_table[SYMHASH (label)]; pool;
3834 pool = pool->next_sym)
3835 if (XSTR (XEXP (pool->desc->rtl, 0), 0) == label)
3836 return pool;
3838 abort ();
3841 /* Given a constant pool SYMBOL_REF, return the corresponding constant. */
3844 get_pool_constant (addr)
3845 rtx addr;
3847 return (find_pool_constant (cfun, addr))->constant;
3850 /* Likewise, but for the constant pool of a specific function. */
3853 get_pool_constant_for_function (f, addr)
3854 struct function *f;
3855 rtx addr;
3857 return (find_pool_constant (f, addr))->constant;
3860 /* Similar, return the mode. */
3862 enum machine_mode
3863 get_pool_mode (addr)
3864 rtx addr;
3866 return (find_pool_constant (cfun, addr))->mode;
3869 enum machine_mode
3870 get_pool_mode_for_function (f, addr)
3871 struct function *f;
3872 rtx addr;
3874 return (find_pool_constant (f, addr))->mode;
3877 /* Similar, return the offset in the constant pool. */
3880 get_pool_offset (addr)
3881 rtx addr;
3883 return (find_pool_constant (cfun, addr))->offset;
3886 /* Return the size of the constant pool. */
3889 get_pool_size ()
3891 return pool_offset;
3894 /* Write all the constants in the constant pool. */
3896 void
3897 output_constant_pool (fnname, fndecl)
3898 const char *fnname ATTRIBUTE_UNUSED;
3899 tree fndecl ATTRIBUTE_UNUSED;
3901 struct pool_constant *pool;
3902 rtx x;
3903 union real_extract u;
3905 /* It is possible for gcc to call force_const_mem and then to later
3906 discard the instructions which refer to the constant. In such a
3907 case we do not need to output the constant. */
3908 mark_constant_pool ();
3910 #ifdef ASM_OUTPUT_POOL_PROLOGUE
3911 ASM_OUTPUT_POOL_PROLOGUE (asm_out_file, fnname, fndecl, pool_offset);
3912 #endif
3914 for (pool = first_pool; pool; pool = pool->next)
3916 rtx tmp;
3918 x = pool->constant;
3920 if (! pool->mark)
3921 continue;
3923 /* See if X is a LABEL_REF (or a CONST referring to a LABEL_REF)
3924 whose CODE_LABEL has been deleted. This can occur if a jump table
3925 is eliminated by optimization. If so, write a constant of zero
3926 instead. Note that this can also happen by turning the
3927 CODE_LABEL into a NOTE. */
3928 /* ??? This seems completely and utterly wrong. Certainly it's
3929 not true for NOTE_INSN_DELETED_LABEL, but I disbelieve proper
3930 functioning even with INSN_DELETED_P and friends. */
3932 tmp = x;
3933 switch (GET_CODE (x))
3935 case CONST:
3936 if (GET_CODE (XEXP (x, 0)) != PLUS
3937 || GET_CODE (XEXP (XEXP (x, 0), 0)) != LABEL_REF)
3938 break;
3939 tmp = XEXP (XEXP (x, 0), 0);
3940 /* FALLTHRU */
3942 case LABEL_REF:
3943 tmp = XEXP (x, 0);
3944 if (INSN_DELETED_P (tmp)
3945 || (GET_CODE (tmp) == NOTE
3946 && NOTE_LINE_NUMBER (tmp) == NOTE_INSN_DELETED))
3948 abort ();
3949 x = const0_rtx;
3951 break;
3953 default:
3954 break;
3957 /* First switch to correct section. */
3958 #ifdef SELECT_RTX_SECTION
3959 SELECT_RTX_SECTION (pool->mode, x, pool->align);
3960 #else
3961 readonly_data_section ();
3962 #endif
3964 #ifdef ASM_OUTPUT_SPECIAL_POOL_ENTRY
3965 ASM_OUTPUT_SPECIAL_POOL_ENTRY (asm_out_file, x, pool->mode,
3966 pool->align, pool->labelno, done);
3967 #endif
3969 assemble_align (pool->align);
3971 /* Output the label. */
3972 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LC", pool->labelno);
3974 /* Output the value of the constant itself. */
3975 switch (GET_MODE_CLASS (pool->mode))
3977 case MODE_FLOAT:
3978 if (GET_CODE (x) != CONST_DOUBLE)
3979 abort ();
3981 memcpy ((char *) &u, (char *) &CONST_DOUBLE_LOW (x), sizeof u);
3982 assemble_real (u.d, pool->mode, pool->align);
3983 break;
3985 case MODE_INT:
3986 case MODE_PARTIAL_INT:
3987 assemble_integer (x, GET_MODE_SIZE (pool->mode), pool->align, 1);
3988 break;
3990 default:
3991 abort ();
3994 #ifdef ASM_OUTPUT_SPECIAL_POOL_ENTRY
3995 done: ;
3996 #endif
3999 #ifdef ASM_OUTPUT_POOL_EPILOGUE
4000 ASM_OUTPUT_POOL_EPILOGUE (asm_out_file, fnname, fndecl, pool_offset);
4001 #endif
4003 /* Done with this pool. */
4004 first_pool = last_pool = 0;
4007 /* Look through the instructions for this function, and mark all the
4008 entries in the constant pool which are actually being used.
4009 Emit used deferred strings. */
4011 static void
4012 mark_constant_pool ()
4014 rtx insn;
4015 struct pool_constant *pool;
4017 if (first_pool == 0 && htab_elements (const_str_htab) == 0)
4018 return;
4020 for (pool = first_pool; pool; pool = pool->next)
4021 pool->mark = 0;
4023 for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
4024 if (INSN_P (insn))
4025 mark_constants (PATTERN (insn));
4027 for (insn = current_function_epilogue_delay_list;
4028 insn;
4029 insn = XEXP (insn, 1))
4030 if (INSN_P (insn))
4031 mark_constants (PATTERN (insn));
4034 /* Look through appropriate parts of X, marking all entries in the
4035 constant pool which are actually being used. Entries that are only
4036 referenced by other constants are also marked as used. Emit
4037 deferred strings that are used. */
4039 static void
4040 mark_constants (x)
4041 rtx x;
4043 int i;
4044 const char *format_ptr;
4046 if (x == 0)
4047 return;
4049 if (GET_CODE (x) == SYMBOL_REF)
4051 mark_constant (&x, NULL);
4052 return;
4055 /* Insns may appear inside a SEQUENCE. Only check the patterns of
4056 insns, not any notes that may be attached. We don't want to mark
4057 a constant just because it happens to appear in a REG_EQUIV note. */
4058 if (INSN_P (x))
4060 mark_constants (PATTERN (x));
4061 return;
4064 format_ptr = GET_RTX_FORMAT (GET_CODE (x));
4066 for (i = 0; i < GET_RTX_LENGTH (GET_CODE (x)); i++)
4068 switch (*format_ptr++)
4070 case 'e':
4071 mark_constants (XEXP (x, i));
4072 break;
4074 case 'E':
4075 if (XVEC (x, i) != 0)
4077 int j;
4079 for (j = 0; j < XVECLEN (x, i); j++)
4080 mark_constants (XVECEXP (x, i, j));
4082 break;
4084 case 'S':
4085 case 's':
4086 case '0':
4087 case 'i':
4088 case 'w':
4089 case 'n':
4090 case 'u':
4091 break;
4093 default:
4094 abort ();
4099 /* Given a SYMBOL_REF CURRENT_RTX, mark it and all constants it refers
4100 to as used. Emit referenced deferred strings. This function can
4101 be used with for_each_rtx to mark all SYMBOL_REFs in an rtx. */
4103 static int
4104 mark_constant (current_rtx, data)
4105 rtx *current_rtx;
4106 void *data ATTRIBUTE_UNUSED;
4108 rtx x = *current_rtx;
4110 if (x == NULL_RTX)
4111 return 0;
4113 else if (GET_CODE (x) == SYMBOL_REF)
4115 if (CONSTANT_POOL_ADDRESS_P (x))
4117 struct pool_constant *pool = find_pool_constant (cfun, x);
4118 if (pool->mark == 0) {
4119 pool->mark = 1;
4120 for_each_rtx (&(pool->constant), &mark_constant, NULL);
4122 else
4123 return -1;
4125 else if (STRING_POOL_ADDRESS_P (x))
4127 struct deferred_string **defstr;
4129 defstr = (struct deferred_string **)
4130 htab_find_slot_with_hash (const_str_htab, XSTR (x, 0),
4131 STRHASH (XSTR (x, 0)), NO_INSERT);
4132 if (defstr)
4134 struct deferred_string *p = *defstr;
4136 STRING_POOL_ADDRESS_P (x) = 0;
4137 output_constant_def_contents (p->exp, 0, p->labelno);
4138 htab_clear_slot (const_str_htab, (void **) defstr);
4142 return 0;
4145 /* Find all the constants whose addresses are referenced inside of EXP,
4146 and make sure assembler code with a label has been output for each one.
4147 Indicate whether an ADDR_EXPR has been encountered. */
4149 static int
4150 output_addressed_constants (exp)
4151 tree exp;
4153 int reloc = 0;
4154 tree tem;
4156 /* Give the front-end a chance to convert VALUE to something that
4157 looks more like a constant to the back-end. */
4158 exp = (*lang_hooks.expand_constant) (exp);
4160 switch (TREE_CODE (exp))
4162 case ADDR_EXPR:
4163 /* Go inside any operations that get_inner_reference can handle and see
4164 if what's inside is a constant: no need to do anything here for
4165 addresses of variables or functions. */
4166 for (tem = TREE_OPERAND (exp, 0); handled_component_p (tem);
4167 tem = TREE_OPERAND (tem, 0))
4170 if (TREE_CODE_CLASS (TREE_CODE (tem)) == 'c'
4171 || TREE_CODE (tem) == CONSTRUCTOR)
4172 output_constant_def (tem, 0);
4174 if (TREE_PUBLIC (tem))
4175 reloc |= 2;
4176 else
4177 reloc |= 1;
4178 break;
4180 case PLUS_EXPR:
4181 case MINUS_EXPR:
4182 reloc = output_addressed_constants (TREE_OPERAND (exp, 0));
4183 reloc |= output_addressed_constants (TREE_OPERAND (exp, 1));
4184 break;
4186 case NOP_EXPR:
4187 case CONVERT_EXPR:
4188 case NON_LVALUE_EXPR:
4189 reloc = output_addressed_constants (TREE_OPERAND (exp, 0));
4190 break;
4192 case CONSTRUCTOR:
4193 for (tem = CONSTRUCTOR_ELTS (exp); tem; tem = TREE_CHAIN (tem))
4194 if (TREE_VALUE (tem) != 0)
4195 reloc |= output_addressed_constants (TREE_VALUE (tem));
4197 break;
4199 default:
4200 break;
4202 return reloc;
4205 /* Return nonzero if VALUE is a valid constant-valued expression
4206 for use in initializing a static variable; one that can be an
4207 element of a "constant" initializer.
4209 Return null_pointer_node if the value is absolute;
4210 if it is relocatable, return the variable that determines the relocation.
4211 We assume that VALUE has been folded as much as possible;
4212 therefore, we do not need to check for such things as
4213 arithmetic-combinations of integers. */
4215 tree
4216 initializer_constant_valid_p (value, endtype)
4217 tree value;
4218 tree endtype;
4220 /* Give the front-end a chance to convert VALUE to something that
4221 looks more like a constant to the back-end. */
4222 value = (*lang_hooks.expand_constant) (value);
4224 switch (TREE_CODE (value))
4226 case CONSTRUCTOR:
4227 if ((TREE_CODE (TREE_TYPE (value)) == UNION_TYPE
4228 || TREE_CODE (TREE_TYPE (value)) == RECORD_TYPE)
4229 && TREE_CONSTANT (value)
4230 && CONSTRUCTOR_ELTS (value))
4231 return
4232 initializer_constant_valid_p (TREE_VALUE (CONSTRUCTOR_ELTS (value)),
4233 endtype);
4235 return TREE_STATIC (value) ? null_pointer_node : 0;
4237 case INTEGER_CST:
4238 case REAL_CST:
4239 case STRING_CST:
4240 case COMPLEX_CST:
4241 return null_pointer_node;
4243 case ADDR_EXPR:
4244 case FDESC_EXPR:
4245 return staticp (TREE_OPERAND (value, 0)) ? TREE_OPERAND (value, 0) : 0;
4247 case VIEW_CONVERT_EXPR:
4248 case NON_LVALUE_EXPR:
4249 return initializer_constant_valid_p (TREE_OPERAND (value, 0), endtype);
4251 case CONVERT_EXPR:
4252 case NOP_EXPR:
4253 /* Allow conversions between pointer types. */
4254 if (POINTER_TYPE_P (TREE_TYPE (value))
4255 && POINTER_TYPE_P (TREE_TYPE (TREE_OPERAND (value, 0))))
4256 return initializer_constant_valid_p (TREE_OPERAND (value, 0), endtype);
4258 /* Allow conversions between real types. */
4259 if (FLOAT_TYPE_P (TREE_TYPE (value))
4260 && FLOAT_TYPE_P (TREE_TYPE (TREE_OPERAND (value, 0))))
4261 return initializer_constant_valid_p (TREE_OPERAND (value, 0), endtype);
4263 /* Allow length-preserving conversions between integer types. */
4264 if (INTEGRAL_TYPE_P (TREE_TYPE (value))
4265 && INTEGRAL_TYPE_P (TREE_TYPE (TREE_OPERAND (value, 0)))
4266 && (TYPE_PRECISION (TREE_TYPE (value))
4267 == TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (value, 0)))))
4268 return initializer_constant_valid_p (TREE_OPERAND (value, 0), endtype);
4270 /* Allow conversions between other integer types only if
4271 explicit value. */
4272 if (INTEGRAL_TYPE_P (TREE_TYPE (value))
4273 && INTEGRAL_TYPE_P (TREE_TYPE (TREE_OPERAND (value, 0))))
4275 tree inner = initializer_constant_valid_p (TREE_OPERAND (value, 0),
4276 endtype);
4277 if (inner == null_pointer_node)
4278 return null_pointer_node;
4279 break;
4282 /* Allow (int) &foo provided int is as wide as a pointer. */
4283 if (INTEGRAL_TYPE_P (TREE_TYPE (value))
4284 && POINTER_TYPE_P (TREE_TYPE (TREE_OPERAND (value, 0)))
4285 && (TYPE_PRECISION (TREE_TYPE (value))
4286 >= TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (value, 0)))))
4287 return initializer_constant_valid_p (TREE_OPERAND (value, 0),
4288 endtype);
4290 /* Likewise conversions from int to pointers, but also allow
4291 conversions from 0. */
4292 if (POINTER_TYPE_P (TREE_TYPE (value))
4293 && INTEGRAL_TYPE_P (TREE_TYPE (TREE_OPERAND (value, 0))))
4295 if (integer_zerop (TREE_OPERAND (value, 0)))
4296 return null_pointer_node;
4297 else if (TYPE_PRECISION (TREE_TYPE (value))
4298 <= TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (value, 0))))
4299 return initializer_constant_valid_p (TREE_OPERAND (value, 0),
4300 endtype);
4303 /* Allow conversions to union types if the value inside is okay. */
4304 if (TREE_CODE (TREE_TYPE (value)) == UNION_TYPE)
4305 return initializer_constant_valid_p (TREE_OPERAND (value, 0),
4306 endtype);
4307 break;
4309 case PLUS_EXPR:
4310 if (! INTEGRAL_TYPE_P (endtype)
4311 || TYPE_PRECISION (endtype) >= POINTER_SIZE)
4313 tree valid0 = initializer_constant_valid_p (TREE_OPERAND (value, 0),
4314 endtype);
4315 tree valid1 = initializer_constant_valid_p (TREE_OPERAND (value, 1),
4316 endtype);
4317 /* If either term is absolute, use the other terms relocation. */
4318 if (valid0 == null_pointer_node)
4319 return valid1;
4320 if (valid1 == null_pointer_node)
4321 return valid0;
4323 break;
4325 case MINUS_EXPR:
4326 if (! INTEGRAL_TYPE_P (endtype)
4327 || TYPE_PRECISION (endtype) >= POINTER_SIZE)
4329 tree valid0 = initializer_constant_valid_p (TREE_OPERAND (value, 0),
4330 endtype);
4331 tree valid1 = initializer_constant_valid_p (TREE_OPERAND (value, 1),
4332 endtype);
4333 /* Win if second argument is absolute. */
4334 if (valid1 == null_pointer_node)
4335 return valid0;
4336 /* Win if both arguments have the same relocation.
4337 Then the value is absolute. */
4338 if (valid0 == valid1 && valid0 != 0)
4339 return null_pointer_node;
4341 /* Since GCC guarantees that string constants are unique in the
4342 generated code, a subtraction between two copies of the same
4343 constant string is absolute. */
4344 if (valid0 && TREE_CODE (valid0) == STRING_CST &&
4345 valid1 && TREE_CODE (valid1) == STRING_CST &&
4346 TREE_STRING_POINTER (valid0) == TREE_STRING_POINTER (valid1))
4347 return null_pointer_node;
4350 /* Support differences between labels. */
4351 if (INTEGRAL_TYPE_P (endtype))
4353 tree op0, op1;
4354 op0 = TREE_OPERAND (value, 0);
4355 op1 = TREE_OPERAND (value, 1);
4356 STRIP_NOPS (op0);
4357 STRIP_NOPS (op1);
4359 if (TREE_CODE (op0) == ADDR_EXPR
4360 && TREE_CODE (TREE_OPERAND (op0, 0)) == LABEL_DECL
4361 && TREE_CODE (op1) == ADDR_EXPR
4362 && TREE_CODE (TREE_OPERAND (op1, 0)) == LABEL_DECL)
4363 return null_pointer_node;
4365 break;
4367 default:
4368 break;
4371 return 0;
4374 /* Output assembler code for constant EXP to FILE, with no label.
4375 This includes the pseudo-op such as ".int" or ".byte", and a newline.
4376 Assumes output_addressed_constants has been done on EXP already.
4378 Generate exactly SIZE bytes of assembler data, padding at the end
4379 with zeros if necessary. SIZE must always be specified.
4381 SIZE is important for structure constructors,
4382 since trailing members may have been omitted from the constructor.
4383 It is also important for initialization of arrays from string constants
4384 since the full length of the string constant might not be wanted.
4385 It is also needed for initialization of unions, where the initializer's
4386 type is just one member, and that may not be as long as the union.
4388 There a case in which we would fail to output exactly SIZE bytes:
4389 for a structure constructor that wants to produce more than SIZE bytes.
4390 But such constructors will never be generated for any possible input.
4392 ALIGN is the alignment of the data in bits. */
4394 void
4395 output_constant (exp, size, align)
4396 tree exp;
4397 HOST_WIDE_INT size;
4398 unsigned int align;
4400 enum tree_code code;
4401 HOST_WIDE_INT thissize;
4403 /* Some front-ends use constants other than the standard language-indepdent
4404 varieties, but which may still be output directly. Give the front-end a
4405 chance to convert EXP to a language-independent representation. */
4406 exp = (*lang_hooks.expand_constant) (exp);
4408 if (size == 0 || flag_syntax_only)
4409 return;
4411 /* Eliminate any conversions since we'll be outputting the underlying
4412 constant. */
4413 while (TREE_CODE (exp) == NOP_EXPR || TREE_CODE (exp) == CONVERT_EXPR
4414 || TREE_CODE (exp) == NON_LVALUE_EXPR
4415 || TREE_CODE (exp) == VIEW_CONVERT_EXPR)
4416 exp = TREE_OPERAND (exp, 0);
4418 code = TREE_CODE (TREE_TYPE (exp));
4419 thissize = int_size_in_bytes (TREE_TYPE (exp));
4421 /* Allow a constructor with no elements for any data type.
4422 This means to fill the space with zeros. */
4423 if (TREE_CODE (exp) == CONSTRUCTOR && CONSTRUCTOR_ELTS (exp) == 0)
4425 assemble_zeros (size);
4426 return;
4429 if (TREE_CODE (exp) == FDESC_EXPR)
4431 #ifdef ASM_OUTPUT_FDESC
4432 HOST_WIDE_INT part = tree_low_cst (TREE_OPERAND (exp, 1), 0);
4433 tree decl = TREE_OPERAND (exp, 0);
4434 ASM_OUTPUT_FDESC (asm_out_file, decl, part);
4435 #else
4436 abort ();
4437 #endif
4438 return;
4441 /* Now output the underlying data. If we've handling the padding, return.
4442 Otherwise, break and ensure THISSIZE is the size written. */
4443 switch (code)
4445 case CHAR_TYPE:
4446 case BOOLEAN_TYPE:
4447 case INTEGER_TYPE:
4448 case ENUMERAL_TYPE:
4449 case POINTER_TYPE:
4450 case REFERENCE_TYPE:
4451 if (! assemble_integer (expand_expr (exp, NULL_RTX, VOIDmode,
4452 EXPAND_INITIALIZER),
4453 size, align, 0))
4454 error ("initializer for integer value is too complicated");
4455 break;
4457 case REAL_TYPE:
4458 if (TREE_CODE (exp) != REAL_CST)
4459 error ("initializer for floating value is not a floating constant");
4461 assemble_real (TREE_REAL_CST (exp),
4462 mode_for_size (size * BITS_PER_UNIT, MODE_FLOAT, 0),
4463 align);
4464 break;
4466 case COMPLEX_TYPE:
4467 output_constant (TREE_REALPART (exp), thissize / 2, align);
4468 output_constant (TREE_IMAGPART (exp), thissize / 2,
4469 min_align (align, BITS_PER_UNIT * (thissize / 2)));
4470 break;
4472 case ARRAY_TYPE:
4473 if (TREE_CODE (exp) == CONSTRUCTOR)
4475 output_constructor (exp, size, align);
4476 return;
4478 else if (TREE_CODE (exp) == STRING_CST)
4480 thissize = MIN (TREE_STRING_LENGTH (exp), size);
4481 assemble_string (TREE_STRING_POINTER (exp), thissize);
4483 else
4484 abort ();
4485 break;
4487 case RECORD_TYPE:
4488 case UNION_TYPE:
4489 if (TREE_CODE (exp) == CONSTRUCTOR)
4490 output_constructor (exp, size, align);
4491 else
4492 abort ();
4493 return;
4495 case SET_TYPE:
4496 if (TREE_CODE (exp) == INTEGER_CST)
4497 assemble_integer (expand_expr (exp, NULL_RTX,
4498 VOIDmode, EXPAND_INITIALIZER),
4499 thissize, align, 1);
4500 else if (TREE_CODE (exp) == CONSTRUCTOR)
4502 unsigned char *buffer = (unsigned char *) alloca (thissize);
4503 if (get_set_constructor_bytes (exp, buffer, thissize))
4504 abort ();
4505 assemble_string ((char *) buffer, thissize);
4507 else
4508 error ("unknown set constructor type");
4509 return;
4511 case ERROR_MARK:
4512 return;
4514 default:
4515 abort ();
4518 size -= thissize;
4519 if (size > 0)
4520 assemble_zeros (size);
4524 /* Subroutine of output_constructor, used for computing the size of
4525 arrays of unspecified length. VAL must be a CONSTRUCTOR of an array
4526 type with an unspecified upper bound. */
4528 static unsigned HOST_WIDE_INT
4529 array_size_for_constructor (val)
4530 tree val;
4532 tree max_index, i;
4534 /* This code used to attempt to handle string constants that are not
4535 arrays of single-bytes, but nothing else does, so there's no point in
4536 doing it here. */
4537 if (TREE_CODE (val) == STRING_CST)
4538 return TREE_STRING_LENGTH (val);
4540 max_index = NULL_TREE;
4541 for (i = CONSTRUCTOR_ELTS (val); i ; i = TREE_CHAIN (i))
4543 tree index = TREE_PURPOSE (i);
4545 if (TREE_CODE (index) == RANGE_EXPR)
4546 index = TREE_OPERAND (index, 1);
4547 if (max_index == NULL_TREE || tree_int_cst_lt (max_index, index))
4548 max_index = index;
4551 if (max_index == NULL_TREE)
4552 return 0;
4554 /* Compute the total number of array elements. */
4555 i = size_binop (MINUS_EXPR, convert (sizetype, max_index),
4556 convert (sizetype,
4557 TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (val)))));
4558 i = size_binop (PLUS_EXPR, i, convert (sizetype, integer_one_node));
4560 /* Multiply by the array element unit size to find number of bytes. */
4561 i = size_binop (MULT_EXPR, i, TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (val))));
4563 return tree_low_cst (i, 1);
4566 /* Subroutine of output_constant, used for CONSTRUCTORs (aggregate constants).
4567 Generate at least SIZE bytes, padding if necessary. */
4569 static void
4570 output_constructor (exp, size, align)
4571 tree exp;
4572 HOST_WIDE_INT size;
4573 unsigned int align;
4575 tree type = TREE_TYPE (exp);
4576 tree link, field = 0;
4577 tree min_index = 0;
4578 /* Number of bytes output or skipped so far.
4579 In other words, current position within the constructor. */
4580 HOST_WIDE_INT total_bytes = 0;
4581 /* Non-zero means BYTE contains part of a byte, to be output. */
4582 int byte_buffer_in_use = 0;
4583 int byte = 0;
4585 if (HOST_BITS_PER_WIDE_INT < BITS_PER_UNIT)
4586 abort ();
4588 if (TREE_CODE (type) == RECORD_TYPE)
4589 field = TYPE_FIELDS (type);
4591 if (TREE_CODE (type) == ARRAY_TYPE
4592 && TYPE_DOMAIN (type) != 0)
4593 min_index = TYPE_MIN_VALUE (TYPE_DOMAIN (type));
4595 /* As LINK goes through the elements of the constant,
4596 FIELD goes through the structure fields, if the constant is a structure.
4597 if the constant is a union, then we override this,
4598 by getting the field from the TREE_LIST element.
4599 But the constant could also be an array. Then FIELD is zero.
4601 There is always a maximum of one element in the chain LINK for unions
4602 (even if the initializer in a source program incorrectly contains
4603 more one). */
4604 for (link = CONSTRUCTOR_ELTS (exp);
4605 link;
4606 link = TREE_CHAIN (link),
4607 field = field ? TREE_CHAIN (field) : 0)
4609 tree val = TREE_VALUE (link);
4610 tree index = 0;
4612 /* The element in a union constructor specifies the proper field
4613 or index. */
4614 if ((TREE_CODE (type) == RECORD_TYPE || TREE_CODE (type) == UNION_TYPE
4615 || TREE_CODE (type) == QUAL_UNION_TYPE)
4616 && TREE_PURPOSE (link) != 0)
4617 field = TREE_PURPOSE (link);
4619 else if (TREE_CODE (type) == ARRAY_TYPE)
4620 index = TREE_PURPOSE (link);
4622 /* Eliminate the marker that makes a cast not be an lvalue. */
4623 if (val != 0)
4624 STRIP_NOPS (val);
4626 if (index && TREE_CODE (index) == RANGE_EXPR)
4628 unsigned HOST_WIDE_INT fieldsize
4629 = int_size_in_bytes (TREE_TYPE (type));
4630 HOST_WIDE_INT lo_index = tree_low_cst (TREE_OPERAND (index, 0), 0);
4631 HOST_WIDE_INT hi_index = tree_low_cst (TREE_OPERAND (index, 1), 0);
4632 HOST_WIDE_INT index;
4633 unsigned int align2 = min_align (align, fieldsize * BITS_PER_UNIT);
4635 for (index = lo_index; index <= hi_index; index++)
4637 /* Output the element's initial value. */
4638 if (val == 0)
4639 assemble_zeros (fieldsize);
4640 else
4641 output_constant (val, fieldsize, align2);
4643 /* Count its size. */
4644 total_bytes += fieldsize;
4647 else if (field == 0 || !DECL_BIT_FIELD (field))
4649 /* An element that is not a bit-field. */
4651 unsigned HOST_WIDE_INT fieldsize;
4652 /* Since this structure is static,
4653 we know the positions are constant. */
4654 HOST_WIDE_INT pos = field ? int_byte_position (field) : 0;
4655 unsigned int align2;
4657 if (index != 0)
4658 pos = (tree_low_cst (TYPE_SIZE_UNIT (TREE_TYPE (val)), 1)
4659 * (tree_low_cst (index, 0) - tree_low_cst (min_index, 0)));
4661 /* Output any buffered-up bit-fields preceding this element. */
4662 if (byte_buffer_in_use)
4664 assemble_integer (GEN_INT (byte), 1, BITS_PER_UNIT, 1);
4665 total_bytes++;
4666 byte_buffer_in_use = 0;
4669 /* Advance to offset of this element.
4670 Note no alignment needed in an array, since that is guaranteed
4671 if each element has the proper size. */
4672 if ((field != 0 || index != 0) && pos != total_bytes)
4674 assemble_zeros (pos - total_bytes);
4675 total_bytes = pos;
4678 /* Find the alignment of this element. */
4679 align2 = min_align (align, BITS_PER_UNIT * pos);
4681 /* Determine size this element should occupy. */
4682 if (field)
4684 fieldsize = 0;
4686 /* If this is an array with an unspecified upper bound,
4687 the initializer determines the size. */
4688 /* ??? This ought to only checked if DECL_SIZE_UNIT is NULL,
4689 but we cannot do this until the deprecated support for
4690 initializing zero-length array members is removed. */
4691 if (TREE_CODE (TREE_TYPE (field)) == ARRAY_TYPE
4692 && TYPE_DOMAIN (TREE_TYPE (field))
4693 && ! TYPE_MAX_VALUE (TYPE_DOMAIN (TREE_TYPE (field))))
4695 fieldsize = array_size_for_constructor (val);
4696 /* Given a non-empty initialization, this field had
4697 better be last. */
4698 if (fieldsize != 0 && TREE_CHAIN (field) != NULL_TREE)
4699 abort ();
4701 else if (DECL_SIZE_UNIT (field))
4703 /* ??? This can't be right. If the decl size overflows
4704 a host integer we will silently emit no data. */
4705 if (host_integerp (DECL_SIZE_UNIT (field), 1))
4706 fieldsize = tree_low_cst (DECL_SIZE_UNIT (field), 1);
4709 else
4710 fieldsize = int_size_in_bytes (TREE_TYPE (type));
4712 /* Output the element's initial value. */
4713 if (val == 0)
4714 assemble_zeros (fieldsize);
4715 else
4716 output_constant (val, fieldsize, align2);
4718 /* Count its size. */
4719 total_bytes += fieldsize;
4721 else if (val != 0 && TREE_CODE (val) != INTEGER_CST)
4722 error ("invalid initial value for member `%s'",
4723 IDENTIFIER_POINTER (DECL_NAME (field)));
4724 else
4726 /* Element that is a bit-field. */
4728 HOST_WIDE_INT next_offset = int_bit_position (field);
4729 HOST_WIDE_INT end_offset
4730 = (next_offset + tree_low_cst (DECL_SIZE (field), 1));
4732 if (val == 0)
4733 val = integer_zero_node;
4735 /* If this field does not start in this (or, next) byte,
4736 skip some bytes. */
4737 if (next_offset / BITS_PER_UNIT != total_bytes)
4739 /* Output remnant of any bit field in previous bytes. */
4740 if (byte_buffer_in_use)
4742 assemble_integer (GEN_INT (byte), 1, BITS_PER_UNIT, 1);
4743 total_bytes++;
4744 byte_buffer_in_use = 0;
4747 /* If still not at proper byte, advance to there. */
4748 if (next_offset / BITS_PER_UNIT != total_bytes)
4750 assemble_zeros (next_offset / BITS_PER_UNIT - total_bytes);
4751 total_bytes = next_offset / BITS_PER_UNIT;
4755 if (! byte_buffer_in_use)
4756 byte = 0;
4758 /* We must split the element into pieces that fall within
4759 separate bytes, and combine each byte with previous or
4760 following bit-fields. */
4762 /* next_offset is the offset n fbits from the beginning of
4763 the structure to the next bit of this element to be processed.
4764 end_offset is the offset of the first bit past the end of
4765 this element. */
4766 while (next_offset < end_offset)
4768 int this_time;
4769 int shift;
4770 HOST_WIDE_INT value;
4771 HOST_WIDE_INT next_byte = next_offset / BITS_PER_UNIT;
4772 HOST_WIDE_INT next_bit = next_offset % BITS_PER_UNIT;
4774 /* Advance from byte to byte
4775 within this element when necessary. */
4776 while (next_byte != total_bytes)
4778 assemble_integer (GEN_INT (byte), 1, BITS_PER_UNIT, 1);
4779 total_bytes++;
4780 byte = 0;
4783 /* Number of bits we can process at once
4784 (all part of the same byte). */
4785 this_time = MIN (end_offset - next_offset,
4786 BITS_PER_UNIT - next_bit);
4787 if (BYTES_BIG_ENDIAN)
4789 /* On big-endian machine, take the most significant bits
4790 first (of the bits that are significant)
4791 and put them into bytes from the most significant end. */
4792 shift = end_offset - next_offset - this_time;
4794 /* Don't try to take a bunch of bits that cross
4795 the word boundary in the INTEGER_CST. We can
4796 only select bits from the LOW or HIGH part
4797 not from both. */
4798 if (shift < HOST_BITS_PER_WIDE_INT
4799 && shift + this_time > HOST_BITS_PER_WIDE_INT)
4801 this_time = shift + this_time - HOST_BITS_PER_WIDE_INT;
4802 shift = HOST_BITS_PER_WIDE_INT;
4805 /* Now get the bits from the appropriate constant word. */
4806 if (shift < HOST_BITS_PER_WIDE_INT)
4807 value = TREE_INT_CST_LOW (val);
4808 else if (shift < 2 * HOST_BITS_PER_WIDE_INT)
4810 value = TREE_INT_CST_HIGH (val);
4811 shift -= HOST_BITS_PER_WIDE_INT;
4813 else
4814 abort ();
4816 /* Get the result. This works only when:
4817 1 <= this_time <= HOST_BITS_PER_WIDE_INT. */
4818 byte |= (((value >> shift)
4819 & (((HOST_WIDE_INT) 2 << (this_time - 1)) - 1))
4820 << (BITS_PER_UNIT - this_time - next_bit));
4822 else
4824 /* On little-endian machines,
4825 take first the least significant bits of the value
4826 and pack them starting at the least significant
4827 bits of the bytes. */
4828 shift = next_offset - int_bit_position (field);
4830 /* Don't try to take a bunch of bits that cross
4831 the word boundary in the INTEGER_CST. We can
4832 only select bits from the LOW or HIGH part
4833 not from both. */
4834 if (shift < HOST_BITS_PER_WIDE_INT
4835 && shift + this_time > HOST_BITS_PER_WIDE_INT)
4836 this_time = (HOST_BITS_PER_WIDE_INT - shift);
4838 /* Now get the bits from the appropriate constant word. */
4839 if (shift < HOST_BITS_PER_WIDE_INT)
4840 value = TREE_INT_CST_LOW (val);
4841 else if (shift < 2 * HOST_BITS_PER_WIDE_INT)
4843 value = TREE_INT_CST_HIGH (val);
4844 shift -= HOST_BITS_PER_WIDE_INT;
4846 else
4847 abort ();
4849 /* Get the result. This works only when:
4850 1 <= this_time <= HOST_BITS_PER_WIDE_INT. */
4851 byte |= (((value >> shift)
4852 & (((HOST_WIDE_INT) 2 << (this_time - 1)) - 1))
4853 << next_bit);
4856 next_offset += this_time;
4857 byte_buffer_in_use = 1;
4862 if (byte_buffer_in_use)
4864 assemble_integer (GEN_INT (byte), 1, BITS_PER_UNIT, 1);
4865 total_bytes++;
4868 if (total_bytes < size)
4869 assemble_zeros (size - total_bytes);
4873 /* This structure contains any weak symbol declarations waiting
4874 to be emitted. */
4875 struct weak_syms
4877 struct weak_syms * next;
4878 const char * name;
4879 const char * value;
4882 static struct weak_syms * weak_decls;
4884 /* Add function NAME to the weak symbols list. VALUE is a weak alias
4885 associated with NAME. */
4888 add_weak (name, value)
4889 const char *name;
4890 const char *value;
4892 struct weak_syms *weak;
4894 weak = (struct weak_syms *) xmalloc (sizeof (struct weak_syms));
4896 if (weak == NULL)
4897 return 0;
4899 weak->next = weak_decls;
4900 weak->name = name;
4901 weak->value = value;
4902 weak_decls = weak;
4904 return 1;
4907 /* Declare DECL to be a weak symbol. */
4909 void
4910 declare_weak (decl)
4911 tree decl;
4913 if (! TREE_PUBLIC (decl))
4914 error_with_decl (decl, "weak declaration of `%s' must be public");
4915 else if (TREE_ASM_WRITTEN (decl))
4916 error_with_decl (decl, "weak declaration of `%s' must precede definition");
4917 else if (SUPPORTS_WEAK)
4918 add_weak (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)), NULL);
4919 else
4920 warning_with_decl (decl, "weak declaration of `%s' not supported");
4922 DECL_WEAK (decl) = 1;
4925 /* Emit any pending weak declarations. */
4927 void
4928 weak_finish ()
4930 if (SUPPORTS_WEAK)
4932 struct weak_syms *t;
4933 for (t = weak_decls; t; t = t->next)
4935 #ifdef ASM_OUTPUT_WEAK_ALIAS
4936 ASM_OUTPUT_WEAK_ALIAS (asm_out_file, t->name, t->value);
4937 #else
4938 #ifdef ASM_WEAKEN_LABEL
4939 if (t->value)
4940 abort ();
4941 ASM_WEAKEN_LABEL (asm_out_file, t->name);
4942 #endif
4943 #endif
4948 /* Remove NAME from the pending list of weak symbols. This prevents
4949 the compiler from emitting multiple .weak directives which confuses
4950 some assemblers. */
4951 #ifdef ASM_WEAKEN_LABEL
4952 static void
4953 remove_from_pending_weak_list (name)
4954 const char *name;
4956 struct weak_syms *t;
4957 struct weak_syms **p;
4959 for (p = &weak_decls; *p; )
4961 t = *p;
4962 if (strcmp (name, t->name) == 0)
4964 *p = t->next;
4965 free (t);
4967 else
4968 p = &(t->next);
4971 #endif /* ASM_WEAKEN_LABEL */
4973 /* Emit an assembler directive to make the symbol for DECL an alias to
4974 the symbol for TARGET. */
4976 void
4977 assemble_alias (decl, target)
4978 tree decl, target ATTRIBUTE_UNUSED;
4980 const char *name;
4982 /* We must force creation of DECL_RTL for debug info generation, even though
4983 we don't use it here. */
4984 make_decl_rtl (decl, NULL);
4986 name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
4988 #ifdef ASM_OUTPUT_DEF
4989 /* Make name accessible from other files, if appropriate. */
4991 if (TREE_PUBLIC (decl))
4993 #ifdef ASM_WEAKEN_LABEL
4994 if (DECL_WEAK (decl))
4996 ASM_WEAKEN_LABEL (asm_out_file, name);
4997 /* Remove this function from the pending weak list so that
4998 we do not emit multiple .weak directives for it. */
4999 remove_from_pending_weak_list
5000 (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
5002 else
5003 #endif
5004 ASM_GLOBALIZE_LABEL (asm_out_file, name);
5007 #ifdef ASM_OUTPUT_DEF_FROM_DECLS
5008 ASM_OUTPUT_DEF_FROM_DECLS (asm_out_file, decl, target);
5009 #else
5010 ASM_OUTPUT_DEF (asm_out_file, name, IDENTIFIER_POINTER (target));
5011 #endif
5012 TREE_ASM_WRITTEN (decl) = 1;
5013 #else
5014 #ifdef ASM_OUTPUT_WEAK_ALIAS
5015 if (! DECL_WEAK (decl))
5016 warning ("only weak aliases are supported in this configuration");
5018 ASM_OUTPUT_WEAK_ALIAS (asm_out_file, name, IDENTIFIER_POINTER (target));
5019 TREE_ASM_WRITTEN (decl) = 1;
5020 #else
5021 warning ("alias definitions not supported in this configuration; ignored");
5022 #endif
5023 #endif
5026 /* Returns 1 if the target configuration supports defining public symbols
5027 so that one of them will be chosen at link time instead of generating a
5028 multiply-defined symbol error, whether through the use of weak symbols or
5029 a target-specific mechanism for having duplicates discarded. */
5032 supports_one_only ()
5034 if (SUPPORTS_ONE_ONLY)
5035 return 1;
5036 return SUPPORTS_WEAK;
5039 /* Set up DECL as a public symbol that can be defined in multiple
5040 translation units without generating a linker error. */
5042 void
5043 make_decl_one_only (decl)
5044 tree decl;
5046 if (TREE_CODE (decl) != VAR_DECL && TREE_CODE (decl) != FUNCTION_DECL)
5047 abort ();
5049 TREE_PUBLIC (decl) = 1;
5051 if (TREE_CODE (decl) == VAR_DECL
5052 && (DECL_INITIAL (decl) == 0 || DECL_INITIAL (decl) == error_mark_node))
5053 DECL_COMMON (decl) = 1;
5054 else if (SUPPORTS_ONE_ONLY)
5056 #ifdef MAKE_DECL_ONE_ONLY
5057 MAKE_DECL_ONE_ONLY (decl);
5058 #endif
5059 DECL_ONE_ONLY (decl) = 1;
5061 else if (SUPPORTS_WEAK)
5062 DECL_WEAK (decl) = 1;
5063 else
5064 abort ();
5067 void
5068 init_varasm_once ()
5070 const_str_htab = htab_create (128, const_str_htab_hash, const_str_htab_eq,
5071 const_str_htab_del);
5072 in_named_htab = htab_create (31, in_named_entry_hash,
5073 in_named_entry_eq, NULL);
5075 ggc_add_root (const_hash_table, MAX_HASH_TABLE, sizeof const_hash_table[0],
5076 mark_const_hash_entry);
5077 ggc_add_root (&const_str_htab, 1, sizeof const_str_htab,
5078 mark_const_str_htab);
5080 const_alias_set = new_alias_set ();
5083 /* Select a set of attributes for section NAME based on the properties
5084 of DECL and whether or not RELOC indicates that DECL's initializer
5085 might contain runtime relocations.
5087 We make the section read-only and executable for a function decl,
5088 read-only for a const data decl, and writable for a non-const data decl. */
5090 unsigned int
5091 default_section_type_flags (decl, name, reloc)
5092 tree decl;
5093 const char *name;
5094 int reloc;
5096 unsigned int flags;
5098 if (decl && TREE_CODE (decl) == FUNCTION_DECL)
5099 flags = SECTION_CODE;
5100 else if (decl && DECL_READONLY_SECTION (decl, reloc))
5101 flags = 0;
5102 else
5103 flags = SECTION_WRITE;
5105 if (decl && DECL_ONE_ONLY (decl))
5106 flags |= SECTION_LINKONCE;
5108 if (strcmp (name, ".bss") == 0
5109 || strncmp (name, ".bss.", 5) == 0
5110 || strncmp (name, ".gnu.linkonce.b.", 16) == 0
5111 || strcmp (name, ".sbss") == 0
5112 || strncmp (name, ".sbss.", 6) == 0
5113 || strncmp (name, ".gnu.linkonce.sb.", 17) == 0)
5114 flags |= SECTION_BSS;
5116 return flags;
5119 /* Output assembly to switch to section NAME with attribute FLAGS.
5120 Four variants for common object file formats. */
5122 void
5123 default_no_named_section (name, flags)
5124 const char *name ATTRIBUTE_UNUSED;
5125 unsigned int flags ATTRIBUTE_UNUSED;
5127 /* Some object formats don't support named sections at all. The
5128 front-end should already have flagged this as an error. */
5129 abort ();
5132 void
5133 default_elf_asm_named_section (name, flags)
5134 const char *name;
5135 unsigned int flags;
5137 char flagchars[10], *f = flagchars;
5138 const char *type;
5140 if (! named_section_first_declaration (name))
5142 fprintf (asm_out_file, "\t.section\t%s\n", name);
5143 return;
5146 if (!(flags & SECTION_DEBUG))
5147 *f++ = 'a';
5148 if (flags & SECTION_WRITE)
5149 *f++ = 'w';
5150 if (flags & SECTION_CODE)
5151 *f++ = 'x';
5152 if (flags & SECTION_SMALL)
5153 *f++ = 's';
5154 if (flags & SECTION_MERGE)
5155 *f++ = 'M';
5156 if (flags & SECTION_STRINGS)
5157 *f++ = 'S';
5158 *f = '\0';
5160 if (flags & SECTION_BSS)
5161 type = "nobits";
5162 else
5163 type = "progbits";
5165 if (flags & SECTION_ENTSIZE)
5166 fprintf (asm_out_file, "\t.section\t%s,\"%s\",@%s,%d\n",
5167 name, flagchars, type, flags & SECTION_ENTSIZE);
5168 else
5169 fprintf (asm_out_file, "\t.section\t%s,\"%s\",@%s\n",
5170 name, flagchars, type);
5173 void
5174 default_coff_asm_named_section (name, flags)
5175 const char *name;
5176 unsigned int flags;
5178 char flagchars[8], *f = flagchars;
5180 if (flags & SECTION_WRITE)
5181 *f++ = 'w';
5182 if (flags & SECTION_CODE)
5183 *f++ = 'x';
5184 *f = '\0';
5186 fprintf (asm_out_file, "\t.section\t%s,\"%s\"\n", name, flagchars);
5189 void
5190 default_pe_asm_named_section (name, flags)
5191 const char *name;
5192 unsigned int flags;
5194 default_coff_asm_named_section (name, flags);
5196 if (flags & SECTION_LINKONCE)
5198 /* Functions may have been compiled at various levels of
5199 optimization so we can't use `same_size' here.
5200 Instead, have the linker pick one. */
5201 fprintf (asm_out_file, "\t.linkonce %s\n",
5202 (flags & SECTION_CODE ? "discard" : "same_size"));
5206 /* Used for vtable gc in GNU binutils. Record that the pointer at OFFSET
5207 from SYMBOL is used in all classes derived from SYMBOL. */
5209 void
5210 assemble_vtable_entry (symbol, offset)
5211 rtx symbol;
5212 HOST_WIDE_INT offset;
5214 fputs ("\t.vtable_entry ", asm_out_file);
5215 output_addr_const (asm_out_file, symbol);
5216 fputs (", ", asm_out_file);
5217 fprintf (asm_out_file, HOST_WIDE_INT_PRINT_DEC, offset);
5218 fputc ('\n', asm_out_file);
5221 /* Used for vtable gc in GNU binutils. Record the class hierarchy by noting
5222 that the vtable symbol CHILD is derived from the vtable symbol PARENT. */
5224 void
5225 assemble_vtable_inherit (child, parent)
5226 rtx child, parent;
5228 fputs ("\t.vtable_inherit ", asm_out_file);
5229 output_addr_const (asm_out_file, child);
5230 fputs (", ", asm_out_file);
5231 output_addr_const (asm_out_file, parent);
5232 fputc ('\n', asm_out_file);