1 /* Output variables, constants and external declarations, for GNU compiler.
2 Copyright (C) 1987, 88, 89, 92-98, 1999 Free Software Foundation, Inc.
4 This file is part of GNU CC.
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING. If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
22 /* This file handles generation of all the assembler code
23 *except* the instructions of a function.
24 This includes declarations of variables and their initial values.
26 We also output the assembler code for constants stored in memory
27 and are responsible for combining constants with the same value. */
38 #include "hard-reg-set.h"
50 #ifdef XCOFF_DEBUGGING_INFO
54 #ifndef TRAMPOLINE_ALIGNMENT
55 #define TRAMPOLINE_ALIGNMENT FUNCTION_BOUNDARY
59 #define ASM_STABS_OP ".stabs"
62 /* Define the prefix to use when check_memory_usage_flag is enable. */
63 #ifdef NO_DOLLAR_IN_LABEL
64 #ifdef NO_DOT_IN_LABEL
65 #define CHKR_PREFIX "chkr_prefix_"
66 #else /* !NO_DOT_IN_LABEL */
67 #define CHKR_PREFIX "chkr."
69 #else /* !NO_DOLLAR_IN_LABEL */
70 #define CHKR_PREFIX "chkr$"
72 #define CHKR_PREFIX_SIZE (sizeof (CHKR_PREFIX) - 1)
74 /* File in which assembler code is being written. */
76 extern FILE *asm_out_file
;
78 /* The (assembler) name of the first globally-visible object output. */
79 char *first_global_object_name
;
80 char *weak_global_object_name
;
82 extern struct obstack
*current_obstack
;
83 extern struct obstack
*saveable_obstack
;
84 extern struct obstack
*rtl_obstack
;
85 extern struct obstack permanent_obstack
;
86 #define obstack_chunk_alloc xmalloc
89 struct constant_descriptor
;
93 #define MAX_RTX_HASH_TABLE 61
97 /* Hash facility for making memory-constants
98 from constant rtl-expressions. It is used on RISC machines
99 where immediate integer arguments and constant addresses are restricted
100 so that such constants must be stored in memory.
102 This pool of constants is reinitialized for each function
103 so each function gets its own constants-pool that comes right before
105 struct constant_descriptor
**x_const_rtx_hash_table
;
106 struct pool_sym
**x_const_rtx_sym_hash_table
;
108 /* Pointers to first and last constant in pool. */
109 struct pool_constant
*x_first_pool
, *x_last_pool
;
111 /* Current offset in constant pool (does not include any machine-specific
115 /* Chain of all CONST_DOUBLE rtx's constructed for the current function.
116 They are chained through the CONST_DOUBLE_CHAIN.
117 A CONST_DOUBLE rtx has CONST_DOUBLE_MEM != cc0_rtx iff it is on this chain.
118 In that case, CONST_DOUBLE_MEM is either a MEM,
119 or const0_rtx if no MEM has been made for this CONST_DOUBLE yet. */
120 rtx x_const_double_chain
;
123 #define const_rtx_hash_table (current_function->varasm->x_const_rtx_hash_table)
124 #define const_rtx_sym_hash_table (current_function->varasm->x_const_rtx_sym_hash_table)
125 #define first_pool (current_function->varasm->x_first_pool)
126 #define last_pool (current_function->varasm->x_last_pool)
127 #define pool_offset (current_function->varasm->x_pool_offset)
128 #define const_double_chain (current_function->varasm->x_const_double_chain)
130 /* Number for making the label on the next
131 constant that is stored in memory. */
135 /* Number for making the label on the next
136 static variable internal to a function. */
140 /* Carry information from ASM_DECLARE_OBJECT_NAME
141 to ASM_FINISH_DECLARE_OBJECT. */
143 int size_directive_output
;
145 /* The last decl for which assemble_variable was called,
146 if it did ASM_DECLARE_OBJECT_NAME.
147 If the last call to assemble_variable didn't do that,
150 tree last_assemble_variable_decl
;
152 /* Nonzero if at least one function definition has been seen. */
154 static int function_defined
;
156 static const char *strip_reg_name
PROTO((const char *));
157 static int contains_pointers_p
PROTO((tree
));
158 static void decode_addr_const
PROTO((tree
, struct addr_const
*));
159 static int const_hash
PROTO((tree
));
160 static int compare_constant
PROTO((tree
,
161 struct constant_descriptor
*));
162 static char *compare_constant_1
PROTO((tree
, char *));
163 static struct constant_descriptor
*record_constant
PROTO((tree
));
164 static void record_constant_1
PROTO((tree
));
165 static tree copy_constant
PROTO((tree
));
166 static void output_constant_def_contents
PROTO((tree
, int, int));
167 static void decode_rtx_const
PROTO((enum machine_mode
, rtx
,
168 struct rtx_const
*));
169 static int const_hash_rtx
PROTO((enum machine_mode
, rtx
));
170 static int compare_constant_rtx
PROTO((enum machine_mode
, rtx
,
171 struct constant_descriptor
*));
172 static struct constant_descriptor
*record_constant_rtx
PROTO((enum machine_mode
,
174 static struct pool_constant
*find_pool_constant
PROTO((struct function
*, rtx
));
175 static void mark_constant_pool
PROTO((void));
176 static void mark_constants
PROTO((rtx
));
177 static int output_addressed_constants
PROTO((tree
));
178 static void output_after_function_constants
PROTO((void));
179 static void output_constructor
PROTO((tree
, int));
180 #ifdef ASM_WEAKEN_LABEL
181 static void remove_from_pending_weak_list
PROTO ((char *));
183 #ifdef ASM_OUTPUT_BSS
184 static void asm_output_bss
PROTO((FILE *, tree
, char *, int, int));
186 #ifdef BSS_SECTION_ASM_OP
187 #ifdef ASM_OUTPUT_ALIGNED_BSS
188 static void asm_output_aligned_bss
PROTO((FILE *, tree
, char *, int, int));
190 #endif /* BSS_SECTION_ASM_OP */
191 static void mark_pool_constant
PROTO((struct pool_constant
*));
192 static void mark_pool_sym_hash_table
PROTO((struct pool_sym
**));
193 static void mark_const_hash_entry
PROTO((void *));
195 static enum in_section
{ no_section
, in_text
, in_data
, in_named
196 #ifdef BSS_SECTION_ASM_OP
199 #ifdef EH_FRAME_SECTION_ASM_OP
202 #ifdef EXTRA_SECTIONS
205 } in_section
= no_section
;
207 /* Return a non-zero value if DECL has a section attribute. */
208 #define IN_NAMED_SECTION(DECL) \
209 ((TREE_CODE (DECL) == FUNCTION_DECL || TREE_CODE (DECL) == VAR_DECL) \
210 && DECL_SECTION_NAME (DECL) != NULL_TREE)
212 /* Text of section name when in_section == in_named. */
213 static char *in_named_name
;
215 /* Define functions like text_section for any extra sections. */
216 #ifdef EXTRA_SECTION_FUNCTIONS
217 EXTRA_SECTION_FUNCTIONS
220 /* Tell assembler to switch to text section. */
225 if (in_section
!= in_text
)
227 fprintf (asm_out_file
, "%s\n", TEXT_SECTION_ASM_OP
);
228 in_section
= in_text
;
232 /* Tell assembler to switch to data section. */
237 if (in_section
!= in_data
)
239 if (flag_shared_data
)
241 #ifdef SHARED_SECTION_ASM_OP
242 fprintf (asm_out_file
, "%s\n", SHARED_SECTION_ASM_OP
);
244 fprintf (asm_out_file
, "%s\n", DATA_SECTION_ASM_OP
);
248 fprintf (asm_out_file
, "%s\n", DATA_SECTION_ASM_OP
);
250 in_section
= in_data
;
253 /* Tell assembler to ALWAYS switch to data section, in case
254 it's not sure where it it. */
257 force_data_section ()
259 in_section
= no_section
;
263 /* Tell assembler to switch to read-only data section. This is normally
267 readonly_data_section ()
269 #ifdef READONLY_DATA_SECTION
270 READONLY_DATA_SECTION (); /* Note this can call data_section. */
276 /* Determine if we're in the text section. */
281 return in_section
== in_text
;
284 /* Determine if we're in the data section. */
289 return in_section
== in_data
;
292 /* Tell assembler to change to section NAME for DECL.
293 If DECL is NULL, just switch to section NAME.
294 If NAME is NULL, get the name from DECL.
295 If RELOC is 1, the initializer for DECL contains relocs. */
298 named_section (decl
, name
, reloc
)
301 int reloc ATTRIBUTE_UNUSED
;
303 if (decl
!= NULL_TREE
304 && TREE_CODE_CLASS (TREE_CODE (decl
)) != 'd')
307 name
= TREE_STRING_POINTER (DECL_SECTION_NAME (decl
));
309 if (in_section
!= in_named
|| strcmp (name
, in_named_name
))
311 #ifdef ASM_OUTPUT_SECTION_NAME
312 ASM_OUTPUT_SECTION_NAME (asm_out_file
, decl
, name
, reloc
);
314 /* Section attributes are not supported if this macro isn't provided -
315 some host formats don't support them at all. The front-end should
316 already have flagged this as an error. */
320 in_named_name
= ggc_alloc_string (name
, -1);
321 in_section
= in_named
;
325 #ifdef ASM_OUTPUT_SECTION_NAME
326 #ifndef UNIQUE_SECTION
327 #define UNIQUE_SECTION(DECL,RELOC) \
333 name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL)); \
334 /* Strip off any encoding in name. */ \
335 STRIP_NAME_ENCODING (name, name); \
337 len = strlen (name) + 1; \
338 string = alloca (len + 1); \
339 sprintf (string, ".%s", name); \
341 DECL_SECTION_NAME (DECL) = build_string (len, string); \
344 #ifndef UNIQUE_SECTION_P
345 #define UNIQUE_SECTION_P(DECL) 0
349 #ifdef BSS_SECTION_ASM_OP
351 /* Tell the assembler to switch to the bss section. */
356 if (in_section
!= in_bss
)
358 #ifdef SHARED_BSS_SECTION_ASM_OP
359 if (flag_shared_data
)
360 fprintf (asm_out_file
, "%s\n", SHARED_BSS_SECTION_ASM_OP
);
363 fprintf (asm_out_file
, "%s\n", BSS_SECTION_ASM_OP
);
369 #ifdef ASM_OUTPUT_BSS
371 /* Utility function for ASM_OUTPUT_BSS for targets to use if
372 they don't support alignments in .bss.
373 ??? It is believed that this function will work in most cases so such
374 support is localized here. */
377 asm_output_bss (file
, decl
, name
, size
, rounded
)
383 ASM_GLOBALIZE_LABEL (file
, name
);
385 #ifdef ASM_DECLARE_OBJECT_NAME
386 last_assemble_variable_decl
= decl
;
387 ASM_DECLARE_OBJECT_NAME (file
, name
, decl
);
389 /* Standard thing is just output label for the object. */
390 ASM_OUTPUT_LABEL (file
, name
);
391 #endif /* ASM_DECLARE_OBJECT_NAME */
392 ASM_OUTPUT_SKIP (file
, rounded
);
397 #ifdef ASM_OUTPUT_ALIGNED_BSS
399 /* Utility function for targets to use in implementing
400 ASM_OUTPUT_ALIGNED_BSS.
401 ??? It is believed that this function will work in most cases so such
402 support is localized here. */
405 asm_output_aligned_bss (file
, decl
, name
, size
, align
)
411 ASM_GLOBALIZE_LABEL (file
, name
);
413 ASM_OUTPUT_ALIGN (file
, floor_log2 (align
/ BITS_PER_UNIT
));
414 #ifdef ASM_DECLARE_OBJECT_NAME
415 last_assemble_variable_decl
= decl
;
416 ASM_DECLARE_OBJECT_NAME (file
, name
, decl
);
418 /* Standard thing is just output label for the object. */
419 ASM_OUTPUT_LABEL (file
, name
);
420 #endif /* ASM_DECLARE_OBJECT_NAME */
421 ASM_OUTPUT_SKIP (file
, size
? size
: 1);
426 #endif /* BSS_SECTION_ASM_OP */
428 #ifdef EH_FRAME_SECTION_ASM_OP
432 if (in_section
!= in_eh_frame
)
434 fprintf (asm_out_file
, "%s\n", EH_FRAME_SECTION_ASM_OP
);
435 in_section
= in_eh_frame
;
440 /* Switch to the section for function DECL.
442 If DECL is NULL_TREE, switch to the text section.
443 ??? It's not clear that we will ever be passed NULL_TREE, but it's
444 safer to handle it. */
447 function_section (decl
)
450 if (decl
!= NULL_TREE
451 && DECL_SECTION_NAME (decl
) != NULL_TREE
)
452 named_section (decl
, (char *) 0, 0);
457 /* Switch to section for variable DECL.
459 RELOC is the `reloc' argument to SELECT_SECTION. */
462 variable_section (decl
, reloc
)
466 if (IN_NAMED_SECTION (decl
))
467 named_section (decl
, NULL
, reloc
);
470 /* C++ can have const variables that get initialized from constructors,
471 and thus can not be in a readonly section. We prevent this by
472 verifying that the initial value is constant for objects put in a
475 error_mark_node is used by the C front end to indicate that the
476 initializer has not been seen yet. In this case, we assume that
477 the initializer must be constant.
479 C++ uses error_mark_node for variables that have complicated
480 initializers, but these variables go in BSS so we won't be called
483 #ifdef SELECT_SECTION
484 SELECT_SECTION (decl
, reloc
);
486 if (DECL_READONLY_SECTION (decl
, reloc
))
487 readonly_data_section ();
494 /* Tell assembler to switch to the section for the exception handling
500 #if defined (EXCEPTION_SECTION)
501 EXCEPTION_SECTION ();
503 #ifdef ASM_OUTPUT_SECTION_NAME
504 named_section (NULL_TREE
, ".gcc_except_table", 0);
509 readonly_data_section ();
514 /* Create the rtl to represent a function, for a function definition.
515 DECL is a FUNCTION_DECL node which describes which function.
516 The rtl is stored into DECL. */
519 make_function_rtl (decl
)
522 char *name
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
));
523 char *new_name
= name
;
525 /* Rename a nested function to avoid conflicts. */
526 if (decl_function_context (decl
) != 0
527 && DECL_INITIAL (decl
) != 0
528 && DECL_RTL (decl
) == 0)
532 name
= IDENTIFIER_POINTER (DECL_NAME (decl
));
533 ASM_FORMAT_PRIVATE_NAME (label
, name
, var_labelno
);
534 name
= ggc_alloc_string (label
, -1);
539 /* When -fprefix-function-name is used, every function name is
540 prefixed. Even static functions are prefixed because they
541 could be declared latter. Note that a nested function name
543 if (flag_prefix_function_name
)
545 size_t name_len
= strlen (name
);
547 new_name
= ggc_alloc_string (NULL
, name_len
+ CHKR_PREFIX_SIZE
);
548 memcpy (new_name
, CHKR_PREFIX
, CHKR_PREFIX_SIZE
);
549 memcpy (new_name
+ CHKR_PREFIX_SIZE
, name
, name_len
+ 1);
554 if (DECL_RTL (decl
) == 0)
557 = gen_rtx_MEM (DECL_MODE (decl
),
558 gen_rtx_SYMBOL_REF (Pmode
, name
));
560 /* Optionally set flags or add text to the name to record information
561 such as that it is a function name. If the name is changed, the macro
562 ASM_OUTPUT_LABELREF will have to know how to strip this information. */
563 #ifdef ENCODE_SECTION_INFO
564 ENCODE_SECTION_INFO (decl
);
569 /* ??? Another way to do this would be to do what halfpic.c does
570 and maintain a hashed table of such critters. */
571 /* ??? Another way to do this would be to pass a flag bit to
572 ENCODE_SECTION_INFO saying whether this is a new decl or not. */
573 /* Let the target reassign the RTL if it wants.
574 This is necessary, for example, when one machine specific
575 decl attribute overrides another. */
576 #ifdef REDO_SECTION_INFO_P
577 if (REDO_SECTION_INFO_P (decl
))
578 ENCODE_SECTION_INFO (decl
);
582 /* Record at least one function has been defined. */
583 function_defined
= 1;
586 /* Given NAME, a putative register name, discard any customary prefixes. */
589 strip_reg_name (name
)
592 #ifdef REGISTER_PREFIX
593 if (!strncmp (name
, REGISTER_PREFIX
, strlen (REGISTER_PREFIX
)))
594 name
+= strlen (REGISTER_PREFIX
);
596 if (name
[0] == '%' || name
[0] == '#')
601 /* Decode an `asm' spec for a declaration as a register name.
602 Return the register number, or -1 if nothing specified,
603 or -2 if the ASMSPEC is not `cc' or `memory' and is not recognized,
604 or -3 if ASMSPEC is `cc' and is not recognized,
605 or -4 if ASMSPEC is `memory' and is not recognized.
606 Accept an exact spelling or a decimal number.
607 Prefixes such as % are optional. */
610 decode_reg_name (asmspec
)
617 /* Get rid of confusing prefixes. */
618 asmspec
= strip_reg_name (asmspec
);
620 /* Allow a decimal number as a "register name". */
621 for (i
= strlen (asmspec
) - 1; i
>= 0; i
--)
622 if (! (asmspec
[i
] >= '0' && asmspec
[i
] <= '9'))
624 if (asmspec
[0] != 0 && i
< 0)
627 if (i
< FIRST_PSEUDO_REGISTER
&& i
>= 0)
633 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; i
++)
635 && ! strcmp (asmspec
, strip_reg_name (reg_names
[i
])))
638 #ifdef ADDITIONAL_REGISTER_NAMES
640 static struct { const char *name
; int number
; } table
[]
641 = ADDITIONAL_REGISTER_NAMES
;
643 for (i
= 0; i
< (int)(sizeof (table
) / sizeof (table
[0])); i
++)
644 if (! strcmp (asmspec
, table
[i
].name
))
645 return table
[i
].number
;
647 #endif /* ADDITIONAL_REGISTER_NAMES */
649 if (!strcmp (asmspec
, "memory"))
652 if (!strcmp (asmspec
, "cc"))
661 /* Create the DECL_RTL for a declaration for a static or external variable
662 or static or external function.
663 ASMSPEC, if not 0, is the string which the user specified
664 as the assembler symbol name.
665 TOP_LEVEL is nonzero if this is a file-scope variable.
667 This is never called for PARM_DECL nodes. */
670 make_decl_rtl (decl
, asmspec
, top_level
)
675 register char *name
= 0;
678 reg_number
= decode_reg_name (asmspec
);
680 if (DECL_ASSEMBLER_NAME (decl
) != NULL_TREE
)
681 name
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
));
683 if (reg_number
== -2)
685 /* ASMSPEC is given, and not the name of a register. */
686 size_t len
= strlen (asmspec
);
688 name
= ggc_alloc_string (NULL
, len
+ 1);
690 memcpy (&name
[1], asmspec
, len
+ 1);
693 /* For a duplicate declaration, we can be called twice on the
694 same DECL node. Don't discard the RTL already made. */
695 if (DECL_RTL (decl
) == 0)
697 /* First detect errors in declaring global registers. */
698 if (TREE_CODE (decl
) != FUNCTION_DECL
699 && DECL_REGISTER (decl
) && reg_number
== -1)
700 error_with_decl (decl
,
701 "register name not specified for `%s'");
702 else if (TREE_CODE (decl
) != FUNCTION_DECL
703 && DECL_REGISTER (decl
) && reg_number
< 0)
704 error_with_decl (decl
,
705 "invalid register name for `%s'");
706 else if ((reg_number
>= 0 || reg_number
== -3)
707 && (TREE_CODE (decl
) == FUNCTION_DECL
708 && ! DECL_REGISTER (decl
)))
709 error_with_decl (decl
,
710 "register name given for non-register variable `%s'");
711 else if (TREE_CODE (decl
) != FUNCTION_DECL
712 && DECL_REGISTER (decl
)
713 && TYPE_MODE (TREE_TYPE (decl
)) == BLKmode
)
714 error_with_decl (decl
,
715 "data type of `%s' isn't suitable for a register");
716 else if (TREE_CODE (decl
) != FUNCTION_DECL
&& DECL_REGISTER (decl
)
717 && ! HARD_REGNO_MODE_OK (reg_number
,
718 TYPE_MODE (TREE_TYPE (decl
))))
719 error_with_decl (decl
,
720 "register number for `%s' isn't suitable for data type");
721 /* Now handle properly declared static register variables. */
722 else if (TREE_CODE (decl
) != FUNCTION_DECL
&& DECL_REGISTER (decl
))
726 if (DECL_INITIAL (decl
) != 0 && top_level
)
728 DECL_INITIAL (decl
) = 0;
729 error ("global register variable has initial value");
731 if (fixed_regs
[reg_number
] == 0
732 && function_defined
&& top_level
)
733 error ("global register variable follows a function definition");
734 if (TREE_THIS_VOLATILE (decl
))
735 warning ("volatile register variables don't work as you might wish");
737 /* If the user specified one of the eliminables registers here,
738 e.g., FRAME_POINTER_REGNUM, we don't want to get this variable
739 confused with that register and be eliminated. Although this
740 usage is somewhat suspect, we nevertheless use the following
741 kludge to avoid setting DECL_RTL to frame_pointer_rtx. */
744 = gen_rtx_REG (DECL_MODE (decl
), FIRST_PSEUDO_REGISTER
);
745 REGNO (DECL_RTL (decl
)) = reg_number
;
746 REG_USERVAR_P (DECL_RTL (decl
)) = 1;
750 /* Make this register global, so not usable for anything
752 #ifdef ASM_DECLARE_REGISTER_GLOBAL
753 ASM_DECLARE_REGISTER_GLOBAL (asm_out_file
, decl
, reg_number
, name
);
755 nregs
= HARD_REGNO_NREGS (reg_number
, DECL_MODE (decl
));
757 globalize_reg (reg_number
+ --nregs
);
760 /* Specifying a section attribute on a variable forces it into a
761 non-.bss section, and thus it cannot be common. */
762 else if (TREE_CODE (decl
) == VAR_DECL
763 && DECL_SECTION_NAME (decl
) != NULL_TREE
764 && DECL_INITIAL (decl
) == NULL_TREE
765 && DECL_COMMON (decl
))
766 DECL_COMMON (decl
) = 0;
768 /* Now handle ordinary static variables and functions (in memory).
769 Also handle vars declared register invalidly. */
770 if (DECL_RTL (decl
) == 0)
772 /* Can't use just the variable's own name for a variable
773 whose scope is less than the whole file.
774 Concatenate a distinguishing number. */
775 if (!top_level
&& !TREE_PUBLIC (decl
) && asmspec
== 0)
779 ASM_FORMAT_PRIVATE_NAME (label
, name
, var_labelno
);
780 name
= ggc_alloc_string (label
, -1);
787 /* When -fprefix-function-name is used, the functions
788 names are prefixed. Only nested function names are not
790 if (flag_prefix_function_name
&& TREE_CODE (decl
) == FUNCTION_DECL
)
792 size_t name_len
= strlen (name
);
795 new_name
= ggc_alloc_string (NULL
, name_len
+ CHKR_PREFIX_SIZE
);
796 memcpy (new_name
, CHKR_PREFIX
, CHKR_PREFIX_SIZE
);
797 memcpy (new_name
+ CHKR_PREFIX_SIZE
, name
, name_len
+ 1);
801 DECL_RTL (decl
) = gen_rtx_MEM (DECL_MODE (decl
),
802 gen_rtx_SYMBOL_REF (Pmode
, name
));
803 MEM_ALIAS_SET (DECL_RTL (decl
)) = get_alias_set (decl
);
805 /* If this variable is to be treated as volatile, show its
806 tree node has side effects. If it has side effects, either
807 because of this test or from TREE_THIS_VOLATILE also
808 being set, show the MEM is volatile. */
809 if (flag_volatile_global
&& TREE_CODE (decl
) == VAR_DECL
810 && TREE_PUBLIC (decl
))
811 TREE_SIDE_EFFECTS (decl
) = 1;
812 else if (flag_volatile_static
&& TREE_CODE (decl
) == VAR_DECL
813 && (TREE_PUBLIC (decl
) || TREE_STATIC (decl
)))
814 TREE_SIDE_EFFECTS (decl
) = 1;
816 if (TREE_SIDE_EFFECTS (decl
))
817 MEM_VOLATILE_P (DECL_RTL (decl
)) = 1;
819 if (TREE_READONLY (decl
))
820 RTX_UNCHANGING_P (DECL_RTL (decl
)) = 1;
821 MEM_SET_IN_STRUCT_P (DECL_RTL (decl
),
822 AGGREGATE_TYPE_P (TREE_TYPE (decl
)));
824 /* Optionally set flags or add text to the name to record information
825 such as that it is a function name.
826 If the name is changed, the macro ASM_OUTPUT_LABELREF
827 will have to know how to strip this information. */
828 #ifdef ENCODE_SECTION_INFO
829 ENCODE_SECTION_INFO (decl
);
835 /* If the old RTL had the wrong mode, fix the mode. */
836 if (GET_MODE (DECL_RTL (decl
)) != DECL_MODE (decl
))
838 rtx rtl
= DECL_RTL (decl
);
839 PUT_MODE (rtl
, DECL_MODE (decl
));
842 /* ??? Another way to do this would be to do what halfpic.c does
843 and maintain a hashed table of such critters. */
844 /* ??? Another way to do this would be to pass a flag bit to
845 ENCODE_SECTION_INFO saying whether this is a new decl or not. */
846 /* Let the target reassign the RTL if it wants.
847 This is necessary, for example, when one machine specific
848 decl attribute overrides another. */
849 #ifdef REDO_SECTION_INFO_P
850 if (REDO_SECTION_INFO_P (decl
))
851 ENCODE_SECTION_INFO (decl
);
856 /* Make the rtl for variable VAR be volatile.
857 Use this only for static variables. */
860 make_var_volatile (var
)
863 if (GET_CODE (DECL_RTL (var
)) != MEM
)
866 MEM_VOLATILE_P (DECL_RTL (var
)) = 1;
869 /* Output alignment directive to align for constant expression EXP. */
872 assemble_constant_align (exp
)
877 /* Align the location counter as required by EXP's data type. */
878 align
= TYPE_ALIGN (TREE_TYPE (exp
));
879 #ifdef CONSTANT_ALIGNMENT
880 align
= CONSTANT_ALIGNMENT (exp
, align
);
883 if (align
> BITS_PER_UNIT
)
884 ASM_OUTPUT_ALIGN (asm_out_file
, floor_log2 (align
/ BITS_PER_UNIT
));
887 /* Output a string of literal assembler code
888 for an `asm' keyword used between functions. */
891 assemble_asm (string
)
896 if (TREE_CODE (string
) == ADDR_EXPR
)
897 string
= TREE_OPERAND (string
, 0);
899 fprintf (asm_out_file
, "\t%s\n", TREE_STRING_POINTER (string
));
902 #if 0 /* This should no longer be needed, because
903 flag_gnu_linker should be 0 on these systems,
904 which should prevent any output
905 if ASM_OUTPUT_CONSTRUCTOR and ASM_OUTPUT_DESTRUCTOR are absent. */
906 #if !(defined(DBX_DEBUGGING_INFO) && !defined(FASCIST_ASSEMBLER))
907 #ifndef ASM_OUTPUT_CONSTRUCTOR
908 #define ASM_OUTPUT_CONSTRUCTOR(file, name)
910 #ifndef ASM_OUTPUT_DESTRUCTOR
911 #define ASM_OUTPUT_DESTRUCTOR(file, name)
916 /* Record an element in the table of global destructors.
917 How this is done depends on what sort of assembler and linker
920 NAME should be the name of a global function to be called
921 at exit time. This name is output using assemble_name. */
924 assemble_destructor (name
)
927 #ifdef ASM_OUTPUT_DESTRUCTOR
928 ASM_OUTPUT_DESTRUCTOR (asm_out_file
, name
);
932 /* Now tell GNU LD that this is part of the static destructor set. */
933 /* This code works for any machine provided you use GNU as/ld. */
934 fprintf (asm_out_file
, "%s \"___DTOR_LIST__\",22,0,0,", ASM_STABS_OP
);
935 assemble_name (asm_out_file
, name
);
936 fputc ('\n', asm_out_file
);
941 /* Likewise for global constructors. */
944 assemble_constructor (name
)
947 #ifdef ASM_OUTPUT_CONSTRUCTOR
948 ASM_OUTPUT_CONSTRUCTOR (asm_out_file
, name
);
952 /* Now tell GNU LD that this is part of the static constructor set. */
953 /* This code works for any machine provided you use GNU as/ld. */
954 fprintf (asm_out_file
, "%s \"___CTOR_LIST__\",22,0,0,", ASM_STABS_OP
);
955 assemble_name (asm_out_file
, name
);
956 fputc ('\n', asm_out_file
);
961 /* Likewise for entries we want to record for garbage collection.
962 Garbage collection is still under development. */
965 assemble_gc_entry (name
)
968 #ifdef ASM_OUTPUT_GC_ENTRY
969 ASM_OUTPUT_GC_ENTRY (asm_out_file
, name
);
973 /* Now tell GNU LD that this is part of the static constructor set. */
974 fprintf (asm_out_file
, "%s \"___PTR_LIST__\",22,0,0,", ASM_STABS_OP
);
975 assemble_name (asm_out_file
, name
);
976 fputc ('\n', asm_out_file
);
981 /* CONSTANT_POOL_BEFORE_FUNCTION may be defined as an expression with
982 a non-zero value if the constant pool should be output before the
983 start of the function, or a zero value if the pool should output
984 after the end of the function. The default is to put it before the
987 #ifndef CONSTANT_POOL_BEFORE_FUNCTION
988 #define CONSTANT_POOL_BEFORE_FUNCTION 1
991 /* Output assembler code for the constant pool of a function and associated
992 with defining the name of the function. DECL describes the function.
993 NAME is the function's name. For the constant pool, we use the current
994 constant pool data. */
997 assemble_start_function (decl
, fnname
)
1003 /* The following code does not need preprocessing in the assembler. */
1007 if (CONSTANT_POOL_BEFORE_FUNCTION
)
1008 output_constant_pool (fnname
, decl
);
1010 #ifdef ASM_OUTPUT_SECTION_NAME
1011 /* If the function is to be put in its own section and it's not in a section
1012 already, indicate so. */
1013 if ((flag_function_sections
1014 && DECL_SECTION_NAME (decl
) == NULL_TREE
)
1015 || UNIQUE_SECTION_P (decl
))
1016 UNIQUE_SECTION (decl
, 0);
1019 function_section (decl
);
1021 /* Tell assembler to move to target machine's alignment for functions. */
1022 align
= floor_log2 (FUNCTION_BOUNDARY
/ BITS_PER_UNIT
);
1024 ASM_OUTPUT_ALIGN (asm_out_file
, align
);
1026 /* Handle a user-specified function alignment.
1027 Note that we still need to align to FUNCTION_BOUNDARY, as above,
1028 because ASM_OUTPUT_MAX_SKIP_ALIGN might not do any alignment at all. */
1029 if (align_functions_log
> align
)
1031 #ifdef ASM_OUTPUT_MAX_SKIP_ALIGN
1032 ASM_OUTPUT_MAX_SKIP_ALIGN (asm_out_file
,
1033 align_functions_log
, align_functions
-1);
1035 ASM_OUTPUT_ALIGN (asm_out_file
, align_functions_log
);
1039 #ifdef ASM_OUTPUT_FUNCTION_PREFIX
1040 ASM_OUTPUT_FUNCTION_PREFIX (asm_out_file
, fnname
);
1043 #ifdef SDB_DEBUGGING_INFO
1044 /* Output SDB definition of the function. */
1045 if (write_symbols
== SDB_DEBUG
)
1046 sdbout_mark_begin_function ();
1049 #ifdef DBX_DEBUGGING_INFO
1050 /* Output DBX definition of the function. */
1051 if (write_symbols
== DBX_DEBUG
)
1052 dbxout_begin_function (decl
);
1055 /* Make function name accessible from other files, if appropriate. */
1057 if (TREE_PUBLIC (decl
))
1059 if (! first_global_object_name
)
1064 if (! DECL_WEAK (decl
) && ! DECL_ONE_ONLY (decl
))
1065 name
= &first_global_object_name
;
1067 name
= &weak_global_object_name
;
1069 STRIP_NAME_ENCODING (p
, fnname
);
1070 *name
= permalloc (strlen (p
) + 1);
1074 #ifdef ASM_WEAKEN_LABEL
1075 if (DECL_WEAK (decl
))
1077 ASM_WEAKEN_LABEL (asm_out_file
, fnname
);
1078 /* Remove this function from the pending weak list so that
1079 we do not emit multiple .weak directives for it. */
1080 remove_from_pending_weak_list
1081 (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)));
1085 ASM_GLOBALIZE_LABEL (asm_out_file
, fnname
);
1088 /* Do any machine/system dependent processing of the function name */
1089 #ifdef ASM_DECLARE_FUNCTION_NAME
1090 ASM_DECLARE_FUNCTION_NAME (asm_out_file
, fnname
, current_function_decl
);
1092 /* Standard thing is just output label for the function. */
1093 ASM_OUTPUT_LABEL (asm_out_file
, fnname
);
1094 #endif /* ASM_DECLARE_FUNCTION_NAME */
1097 /* Output assembler code associated with defining the size of the
1098 function. DECL describes the function. NAME is the function's name. */
1101 assemble_end_function (decl
, fnname
)
1105 #ifdef ASM_DECLARE_FUNCTION_SIZE
1106 ASM_DECLARE_FUNCTION_SIZE (asm_out_file
, fnname
, decl
);
1108 if (! CONSTANT_POOL_BEFORE_FUNCTION
)
1110 output_constant_pool (fnname
, decl
);
1111 function_section (decl
); /* need to switch back */
1114 /* Output any constants which should appear after the function. */
1115 output_after_function_constants ();
1118 /* Assemble code to leave SIZE bytes of zeros. */
1121 assemble_zeros (size
)
1124 /* Do no output if -fsyntax-only. */
1125 if (flag_syntax_only
)
1128 #ifdef ASM_NO_SKIP_IN_TEXT
1129 /* The `space' pseudo in the text section outputs nop insns rather than 0s,
1130 so we must output 0s explicitly in the text section. */
1131 if (ASM_NO_SKIP_IN_TEXT
&& in_text_section ())
1135 for (i
= 0; i
< size
- 20; i
+= 20)
1138 fprintf (asm_out_file
,
1139 "%s 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n", ASM_BYTE_OP
);
1141 fprintf (asm_out_file
,
1142 "\tbyte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n");
1148 fprintf (asm_out_file
, "%s 0", ASM_BYTE_OP
);
1150 fprintf (asm_out_file
, "\tbyte 0");
1153 for (; i
< size
; i
++)
1154 fprintf (asm_out_file
, ",0");
1155 fprintf (asm_out_file
, "\n");
1161 ASM_OUTPUT_SKIP (asm_out_file
, size
);
1164 /* Assemble an alignment pseudo op for an ALIGN-bit boundary. */
1167 assemble_align (align
)
1170 if (align
> BITS_PER_UNIT
)
1171 ASM_OUTPUT_ALIGN (asm_out_file
, floor_log2 (align
/ BITS_PER_UNIT
));
1174 /* Assemble a string constant with the specified C string as contents. */
1177 assemble_string (p
, size
)
1184 /* If the string is very long, split it up. */
1188 int thissize
= size
- pos
;
1189 if (thissize
> maximum
)
1192 ASM_OUTPUT_ASCII (asm_out_file
, p
, thissize
);
1200 /* Assemble everything that is needed for a variable or function declaration.
1201 Not used for automatic variables, and not used for function definitions.
1202 Should not be called for variables of incomplete structure type.
1204 TOP_LEVEL is nonzero if this variable has file scope.
1205 AT_END is nonzero if this is the special handling, at end of compilation,
1206 to define things that have had only tentative definitions.
1207 DONT_OUTPUT_DATA if nonzero means don't actually output the
1208 initial value (that will be done by the caller). */
1211 assemble_variable (decl
, top_level
, at_end
, dont_output_data
)
1213 int top_level ATTRIBUTE_UNUSED
;
1215 int dont_output_data
;
1217 register char *name
;
1219 tree size_tree
= NULL_TREE
;
1221 enum in_section saved_in_section
;
1223 last_assemble_variable_decl
= 0;
1225 if (GET_CODE (DECL_RTL (decl
)) == REG
)
1227 /* Do output symbol info for global register variables, but do nothing
1230 if (TREE_ASM_WRITTEN (decl
))
1232 TREE_ASM_WRITTEN (decl
) = 1;
1234 /* Do no output if -fsyntax-only. */
1235 if (flag_syntax_only
)
1238 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
1239 /* File-scope global variables are output here. */
1240 if ((write_symbols
== DBX_DEBUG
|| write_symbols
== XCOFF_DEBUG
)
1242 dbxout_symbol (decl
, 0);
1244 #ifdef SDB_DEBUGGING_INFO
1245 if (write_symbols
== SDB_DEBUG
&& top_level
1246 /* Leave initialized global vars for end of compilation;
1247 see comment in compile_file. */
1248 && (TREE_PUBLIC (decl
) == 0 || DECL_INITIAL (decl
) == 0))
1249 sdbout_symbol (decl
, 0);
1252 /* Don't output any DWARF debugging information for variables here.
1253 In the case of local variables, the information for them is output
1254 when we do our recursive traversal of the tree representation for
1255 the entire containing function. In the case of file-scope variables,
1256 we output information for all of them at the very end of compilation
1257 while we are doing our final traversal of the chain of file-scope
1263 /* Normally no need to say anything here for external references,
1264 since assemble_external is called by the language-specific code
1265 when a declaration is first seen. */
1267 if (DECL_EXTERNAL (decl
))
1270 /* Output no assembler code for a function declaration.
1271 Only definitions of functions output anything. */
1273 if (TREE_CODE (decl
) == FUNCTION_DECL
)
1276 /* If type was incomplete when the variable was declared,
1277 see if it is complete now. */
1279 if (DECL_SIZE (decl
) == 0)
1280 layout_decl (decl
, 0);
1282 /* Still incomplete => don't allocate it; treat the tentative defn
1283 (which is what it must have been) as an `extern' reference. */
1285 if (!dont_output_data
&& DECL_SIZE (decl
) == 0)
1287 error_with_file_and_line (DECL_SOURCE_FILE (decl
),
1288 DECL_SOURCE_LINE (decl
),
1289 "storage size of `%s' isn't known",
1290 IDENTIFIER_POINTER (DECL_NAME (decl
)));
1291 TREE_ASM_WRITTEN (decl
) = 1;
1295 /* The first declaration of a variable that comes through this function
1296 decides whether it is global (in C, has external linkage)
1297 or local (in C, has internal linkage). So do nothing more
1298 if this function has already run. */
1300 if (TREE_ASM_WRITTEN (decl
))
1303 TREE_ASM_WRITTEN (decl
) = 1;
1305 /* Do no output if -fsyntax-only. */
1306 if (flag_syntax_only
)
1311 if (! dont_output_data
)
1315 if (TREE_CODE (DECL_SIZE (decl
)) != INTEGER_CST
)
1318 /* This is better than explicit arithmetic, since it avoids overflow. */
1319 size_tree
= size_binop (CEIL_DIV_EXPR
,
1320 DECL_SIZE (decl
), size_int (BITS_PER_UNIT
));
1322 size
= TREE_INT_CST_LOW (size_tree
);
1323 if (TREE_INT_CST_HIGH (size_tree
) != 0
1324 || size
!= TREE_INT_CST_LOW (size_tree
))
1326 error_with_decl (decl
, "size of variable `%s' is too large");
1331 name
= XSTR (XEXP (DECL_RTL (decl
), 0), 0);
1333 if (TREE_PUBLIC (decl
) && DECL_NAME (decl
)
1334 && ! first_global_object_name
1335 && ! (DECL_COMMON (decl
) && (DECL_INITIAL (decl
) == 0
1336 || DECL_INITIAL (decl
) == error_mark_node
))
1337 && ! DECL_WEAK (decl
)
1338 && ! DECL_ONE_ONLY (decl
))
1342 STRIP_NAME_ENCODING (p
, name
);
1343 first_global_object_name
= permalloc (strlen (p
) + 1);
1344 strcpy (first_global_object_name
, p
);
1347 /* Compute the alignment of this data. */
1349 align
= DECL_ALIGN (decl
);
1351 /* In the case for initialing an array whose length isn't specified,
1352 where we have not yet been able to do the layout,
1353 figure out the proper alignment now. */
1354 if (dont_output_data
&& DECL_SIZE (decl
) == 0
1355 && TREE_CODE (TREE_TYPE (decl
)) == ARRAY_TYPE
)
1356 align
= MAX (align
, TYPE_ALIGN (TREE_TYPE (TREE_TYPE (decl
))));
1358 /* Some object file formats have a maximum alignment which they support.
1359 In particular, a.out format supports a maximum alignment of 4. */
1360 #ifndef MAX_OFILE_ALIGNMENT
1361 #define MAX_OFILE_ALIGNMENT BIGGEST_ALIGNMENT
1363 if (align
> MAX_OFILE_ALIGNMENT
)
1365 warning_with_decl (decl
,
1366 "alignment of `%s' is greater than maximum object file alignment. Using %d.",
1367 MAX_OFILE_ALIGNMENT
/BITS_PER_UNIT
);
1368 align
= MAX_OFILE_ALIGNMENT
;
1371 /* On some machines, it is good to increase alignment sometimes. */
1372 #ifdef DATA_ALIGNMENT
1373 align
= DATA_ALIGNMENT (TREE_TYPE (decl
), align
);
1375 #ifdef CONSTANT_ALIGNMENT
1376 if (DECL_INITIAL (decl
) != 0 && DECL_INITIAL (decl
) != error_mark_node
)
1377 align
= CONSTANT_ALIGNMENT (DECL_INITIAL (decl
), align
);
1380 /* Reset the alignment in case we have made it tighter, so we can benefit
1381 from it in get_pointer_alignment. */
1382 DECL_ALIGN (decl
) = align
;
1384 /* Handle uninitialized definitions. */
1386 if ((DECL_INITIAL (decl
) == 0 || DECL_INITIAL (decl
) == error_mark_node
)
1387 /* If the target can't output uninitialized but not common global data
1388 in .bss, then we have to use .data. */
1389 #if ! defined (ASM_OUTPUT_BSS) && ! defined (ASM_OUTPUT_ALIGNED_BSS)
1390 && DECL_COMMON (decl
)
1392 && DECL_SECTION_NAME (decl
) == 0
1393 && ! dont_output_data
)
1395 int size
= TREE_INT_CST_LOW (size_tree
);
1398 /* Don't allocate zero bytes of common,
1399 since that means "undefined external" in the linker. */
1400 if (size
== 0) rounded
= 1;
1401 /* Round size up to multiple of BIGGEST_ALIGNMENT bits
1402 so that each uninitialized object starts on such a boundary. */
1403 rounded
+= (BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
) - 1;
1404 rounded
= (rounded
/ (BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
)
1405 * (BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
));
1407 #if !defined(ASM_OUTPUT_ALIGNED_COMMON) && !defined(ASM_OUTPUT_ALIGNED_BSS)
1408 if ( (DECL_ALIGN (decl
) / BITS_PER_UNIT
) > rounded
)
1410 (decl
, "requested alignment for %s is greater than implemented alignment of %d.",rounded
);
1413 #ifdef DBX_DEBUGGING_INFO
1414 /* File-scope global variables are output here. */
1415 if (write_symbols
== DBX_DEBUG
&& top_level
)
1416 dbxout_symbol (decl
, 0);
1418 #ifdef SDB_DEBUGGING_INFO
1419 if (write_symbols
== SDB_DEBUG
&& top_level
1420 /* Leave initialized global vars for end of compilation;
1421 see comment in compile_file. */
1422 && (TREE_PUBLIC (decl
) == 0 || DECL_INITIAL (decl
) == 0))
1423 sdbout_symbol (decl
, 0);
1426 /* Don't output any DWARF debugging information for variables here.
1427 In the case of local variables, the information for them is output
1428 when we do our recursive traversal of the tree representation for
1429 the entire containing function. In the case of file-scope variables,
1430 we output information for all of them at the very end of compilation
1431 while we are doing our final traversal of the chain of file-scope
1434 #if 0 /* ??? We should either delete this or add a comment describing what
1435 it was intended to do and why we shouldn't delete it. */
1436 if (flag_shared_data
)
1440 if (TREE_PUBLIC (decl
)
1441 #if defined (ASM_OUTPUT_BSS) || defined (ASM_OUTPUT_ALIGNED_BSS)
1442 && DECL_COMMON (decl
)
1446 #ifdef ASM_OUTPUT_SHARED_COMMON
1447 if (flag_shared_data
)
1448 ASM_OUTPUT_SHARED_COMMON (asm_out_file
, name
, size
, rounded
);
1452 #ifdef ASM_OUTPUT_ALIGNED_DECL_COMMON
1453 ASM_OUTPUT_ALIGNED_DECL_COMMON (asm_out_file
, decl
, name
, size
,
1456 #ifdef ASM_OUTPUT_ALIGNED_COMMON
1457 ASM_OUTPUT_ALIGNED_COMMON (asm_out_file
, name
, size
,
1460 ASM_OUTPUT_COMMON (asm_out_file
, name
, size
, rounded
);
1465 #if defined (ASM_OUTPUT_BSS) || defined (ASM_OUTPUT_ALIGNED_BSS)
1466 else if (TREE_PUBLIC (decl
))
1468 #ifdef ASM_OUTPUT_SHARED_BSS
1469 if (flag_shared_data
)
1470 ASM_OUTPUT_SHARED_BSS (asm_out_file
, decl
, name
, size
, rounded
);
1474 #ifdef ASM_OUTPUT_ALIGNED_BSS
1475 ASM_OUTPUT_ALIGNED_BSS (asm_out_file
, decl
, name
, size
,
1478 ASM_OUTPUT_BSS (asm_out_file
, decl
, name
, size
, rounded
);
1482 #endif /* ASM_OUTPUT_BSS || ASM_OUTPUT_ALIGNED_BSS */
1485 #ifdef ASM_OUTPUT_SHARED_LOCAL
1486 if (flag_shared_data
)
1487 ASM_OUTPUT_SHARED_LOCAL (asm_out_file
, name
, size
, rounded
);
1491 #ifdef ASM_OUTPUT_ALIGNED_DECL_LOCAL
1492 ASM_OUTPUT_ALIGNED_DECL_LOCAL (asm_out_file
, decl
, name
, size
,
1495 #ifdef ASM_OUTPUT_ALIGNED_LOCAL
1496 ASM_OUTPUT_ALIGNED_LOCAL (asm_out_file
, name
, size
,
1499 ASM_OUTPUT_LOCAL (asm_out_file
, name
, size
, rounded
);
1507 /* Handle initialized definitions.
1508 Also handle uninitialized global definitions if -fno-common and the
1509 target doesn't support ASM_OUTPUT_BSS. */
1511 /* First make the assembler name(s) global if appropriate. */
1512 if (TREE_PUBLIC (decl
) && DECL_NAME (decl
))
1514 #ifdef ASM_WEAKEN_LABEL
1515 if (DECL_WEAK (decl
))
1517 ASM_WEAKEN_LABEL (asm_out_file
, name
);
1518 /* Remove this variable from the pending weak list so that
1519 we do not emit multiple .weak directives for it. */
1520 remove_from_pending_weak_list
1521 (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)));
1525 ASM_GLOBALIZE_LABEL (asm_out_file
, name
);
1528 for (d
= equivalents
; d
; d
= TREE_CHAIN (d
))
1530 tree e
= TREE_VALUE (d
);
1531 if (TREE_PUBLIC (e
) && DECL_NAME (e
))
1532 ASM_GLOBALIZE_LABEL (asm_out_file
,
1533 XSTR (XEXP (DECL_RTL (e
), 0), 0));
1537 /* Output any data that we will need to use the address of. */
1538 if (DECL_INITIAL (decl
) == error_mark_node
)
1539 reloc
= contains_pointers_p (TREE_TYPE (decl
));
1540 else if (DECL_INITIAL (decl
))
1541 reloc
= output_addressed_constants (DECL_INITIAL (decl
));
1543 #ifdef ASM_OUTPUT_SECTION_NAME
1544 if ((flag_data_sections
!= 0
1545 && DECL_SECTION_NAME (decl
) == NULL_TREE
)
1546 || UNIQUE_SECTION_P (decl
))
1547 UNIQUE_SECTION (decl
, reloc
);
1550 /* Switch to the appropriate section. */
1551 variable_section (decl
, reloc
);
1553 /* dbxout.c needs to know this. */
1554 if (in_text_section ())
1555 DECL_IN_TEXT_SECTION (decl
) = 1;
1557 /* Record current section so we can restore it if dbxout.c clobbers it. */
1558 saved_in_section
= in_section
;
1560 /* Output the dbx info now that we have chosen the section. */
1562 #ifdef DBX_DEBUGGING_INFO
1563 /* File-scope global variables are output here. */
1564 if (write_symbols
== DBX_DEBUG
&& top_level
)
1565 dbxout_symbol (decl
, 0);
1567 #ifdef SDB_DEBUGGING_INFO
1568 if (write_symbols
== SDB_DEBUG
&& top_level
1569 /* Leave initialized global vars for end of compilation;
1570 see comment in compile_file. */
1571 && (TREE_PUBLIC (decl
) == 0 || DECL_INITIAL (decl
) == 0))
1572 sdbout_symbol (decl
, 0);
1575 /* Don't output any DWARF debugging information for variables here.
1576 In the case of local variables, the information for them is output
1577 when we do our recursive traversal of the tree representation for
1578 the entire containing function. In the case of file-scope variables,
1579 we output information for all of them at the very end of compilation
1580 while we are doing our final traversal of the chain of file-scope
1583 /* If the debugging output changed sections, reselect the section
1584 that's supposed to be selected. */
1585 if (in_section
!= saved_in_section
)
1586 variable_section (decl
, reloc
);
1588 /* Output the alignment of this data. */
1589 if (align
> BITS_PER_UNIT
)
1590 ASM_OUTPUT_ALIGN (asm_out_file
,
1591 floor_log2 (DECL_ALIGN (decl
) / BITS_PER_UNIT
));
1593 /* Do any machine/system dependent processing of the object. */
1594 #ifdef ASM_DECLARE_OBJECT_NAME
1595 last_assemble_variable_decl
= decl
;
1596 ASM_DECLARE_OBJECT_NAME (asm_out_file
, name
, decl
);
1598 /* Standard thing is just output label for the object. */
1599 ASM_OUTPUT_LABEL (asm_out_file
, name
);
1600 #endif /* ASM_DECLARE_OBJECT_NAME */
1602 if (!dont_output_data
)
1604 if (DECL_INITIAL (decl
))
1605 /* Output the actual data. */
1606 output_constant (DECL_INITIAL (decl
), TREE_INT_CST_LOW (size_tree
));
1608 /* Leave space for it. */
1609 assemble_zeros (TREE_INT_CST_LOW (size_tree
));
1613 #ifdef XCOFF_DEBUGGING_INFO
1614 /* Unfortunately, the IBM assembler cannot handle stabx before the actual
1615 declaration. When something like ".stabx "aa:S-2",aa,133,0" is emitted
1616 and `aa' hasn't been output yet, the assembler generates a stab entry with
1617 a value of zero, in addition to creating an unnecessary external entry
1618 for `aa'. Hence, we must postpone dbxout_symbol to here at the end. */
1620 /* File-scope global variables are output here. */
1621 if (write_symbols
== XCOFF_DEBUG
&& top_level
)
1623 saved_in_section
= in_section
;
1625 dbxout_symbol (decl
, 0);
1627 if (in_section
!= saved_in_section
)
1628 variable_section (decl
, reloc
);
1631 /* There must be a statement after a label. */
1636 /* Return 1 if type TYPE contains any pointers. */
1639 contains_pointers_p (type
)
1642 switch (TREE_CODE (type
))
1645 case REFERENCE_TYPE
:
1646 /* I'm not sure whether OFFSET_TYPE needs this treatment,
1647 so I'll play safe and return 1. */
1653 case QUAL_UNION_TYPE
:
1656 /* For a type that has fields, see if the fields have pointers. */
1657 for (fields
= TYPE_FIELDS (type
); fields
; fields
= TREE_CHAIN (fields
))
1658 if (TREE_CODE (fields
) == FIELD_DECL
1659 && contains_pointers_p (TREE_TYPE (fields
)))
1665 /* An array type contains pointers if its element type does. */
1666 return contains_pointers_p (TREE_TYPE (type
));
1673 /* Output something to declare an external symbol to the assembler.
1674 (Most assemblers don't need this, so we normally output nothing.)
1675 Do nothing if DECL is not external. */
1678 assemble_external (decl
)
1679 tree decl ATTRIBUTE_UNUSED
;
1681 #ifdef ASM_OUTPUT_EXTERNAL
1682 if (TREE_CODE_CLASS (TREE_CODE (decl
)) == 'd'
1683 && DECL_EXTERNAL (decl
) && TREE_PUBLIC (decl
))
1685 rtx rtl
= DECL_RTL (decl
);
1687 if (GET_CODE (rtl
) == MEM
&& GET_CODE (XEXP (rtl
, 0)) == SYMBOL_REF
1688 && ! SYMBOL_REF_USED (XEXP (rtl
, 0)))
1690 /* Some systems do require some output. */
1691 SYMBOL_REF_USED (XEXP (rtl
, 0)) = 1;
1692 ASM_OUTPUT_EXTERNAL (asm_out_file
, decl
, XSTR (XEXP (rtl
, 0), 0));
1698 /* Similar, for calling a library function FUN. */
1701 assemble_external_libcall (fun
)
1702 rtx fun ATTRIBUTE_UNUSED
;
1704 #ifdef ASM_OUTPUT_EXTERNAL_LIBCALL
1705 /* Declare library function name external when first used, if nec. */
1706 if (! SYMBOL_REF_USED (fun
))
1708 SYMBOL_REF_USED (fun
) = 1;
1709 ASM_OUTPUT_EXTERNAL_LIBCALL (asm_out_file
, fun
);
1714 /* Declare the label NAME global. */
1717 assemble_global (name
)
1720 ASM_GLOBALIZE_LABEL (asm_out_file
, name
);
1723 /* Assemble a label named NAME. */
1726 assemble_label (name
)
1729 ASM_OUTPUT_LABEL (asm_out_file
, name
);
1732 /* Output to FILE a reference to the assembler name of a C-level name NAME.
1733 If NAME starts with a *, the rest of NAME is output verbatim.
1734 Otherwise NAME is transformed in an implementation-defined way
1735 (usually by the addition of an underscore).
1736 Many macros in the tm file are defined to call this function. */
1739 assemble_name (file
, name
)
1743 const char *real_name
;
1746 STRIP_NAME_ENCODING (real_name
, name
);
1747 if (flag_prefix_function_name
1748 && ! bcmp (real_name
, CHKR_PREFIX
, CHKR_PREFIX_SIZE
))
1749 real_name
= real_name
+ CHKR_PREFIX_SIZE
;
1751 id
= maybe_get_identifier (real_name
);
1753 TREE_SYMBOL_REFERENCED (id
) = 1;
1756 fputs (&name
[1], file
);
1758 ASM_OUTPUT_LABELREF (file
, name
);
1761 /* Allocate SIZE bytes writable static space with a gensym name
1762 and return an RTX to refer to its address. */
1765 assemble_static_space (size
)
1773 if (flag_shared_data
)
1777 ASM_GENERATE_INTERNAL_LABEL (name
, "LF", const_labelno
);
1779 namestring
= ggc_alloc_string (name
, -1);
1781 x
= gen_rtx_SYMBOL_REF (Pmode
, namestring
);
1783 #ifdef ASM_OUTPUT_ALIGNED_DECL_LOCAL
1784 ASM_OUTPUT_ALIGNED_DECL_LOCAL (asm_out_file
, NULL_TREE
, name
, size
,
1787 #ifdef ASM_OUTPUT_ALIGNED_LOCAL
1788 ASM_OUTPUT_ALIGNED_LOCAL (asm_out_file
, name
, size
, BIGGEST_ALIGNMENT
);
1791 /* Round size up to multiple of BIGGEST_ALIGNMENT bits
1792 so that each uninitialized object starts on such a boundary. */
1793 /* Variable `rounded' might or might not be used in ASM_OUTPUT_LOCAL. */
1794 int rounded ATTRIBUTE_UNUSED
1795 = ((size
+ (BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
) - 1)
1796 / (BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
)
1797 * (BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
));
1798 ASM_OUTPUT_LOCAL (asm_out_file
, name
, size
, rounded
);
1805 /* Assemble the static constant template for function entry trampolines.
1806 This is done at most once per compilation.
1807 Returns an RTX for the address of the template. */
1809 #ifdef TRAMPOLINE_TEMPLATE
1811 assemble_trampoline_template ()
1817 /* By default, put trampoline templates in read-only data section. */
1819 #ifdef TRAMPOLINE_SECTION
1820 TRAMPOLINE_SECTION ();
1822 readonly_data_section ();
1825 /* Write the assembler code to define one. */
1826 align
= floor_log2 (TRAMPOLINE_ALIGNMENT
/ BITS_PER_UNIT
);
1828 ASM_OUTPUT_ALIGN (asm_out_file
, align
);
1830 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, "LTRAMP", 0);
1831 TRAMPOLINE_TEMPLATE (asm_out_file
);
1833 /* Record the rtl to refer to it. */
1834 ASM_GENERATE_INTERNAL_LABEL (label
, "LTRAMP", 0);
1835 name
= ggc_alloc_string (label
, -1);
1836 return gen_rtx_SYMBOL_REF (Pmode
, name
);
1840 /* Assemble the integer constant X into an object of SIZE bytes.
1841 X must be either a CONST_INT or CONST_DOUBLE.
1843 Return 1 if we were able to output the constant, otherwise 0. If FORCE is
1844 non-zero, abort if we can't output the constant. */
1847 assemble_integer (x
, size
, force
)
1852 /* First try to use the standard 1, 2, 4, 8, and 16 byte
1853 ASM_OUTPUT... macros. */
1857 #ifdef ASM_OUTPUT_CHAR
1859 ASM_OUTPUT_CHAR (asm_out_file
, x
);
1863 #ifdef ASM_OUTPUT_SHORT
1865 ASM_OUTPUT_SHORT (asm_out_file
, x
);
1869 #ifdef ASM_OUTPUT_INT
1871 ASM_OUTPUT_INT (asm_out_file
, x
);
1875 #ifdef ASM_OUTPUT_DOUBLE_INT
1877 ASM_OUTPUT_DOUBLE_INT (asm_out_file
, x
);
1881 #ifdef ASM_OUTPUT_QUADRUPLE_INT
1883 ASM_OUTPUT_QUADRUPLE_INT (asm_out_file
, x
);
1888 /* If we couldn't do it that way, there are two other possibilities: First,
1889 if the machine can output an explicit byte and this is a 1 byte constant,
1890 we can use ASM_OUTPUT_BYTE. */
1892 #ifdef ASM_OUTPUT_BYTE
1893 if (size
== 1 && GET_CODE (x
) == CONST_INT
)
1895 ASM_OUTPUT_BYTE (asm_out_file
, INTVAL (x
));
1900 /* Finally, if SIZE is larger than a single word, try to output the constant
1901 one word at a time. */
1903 if (size
> UNITS_PER_WORD
)
1906 enum machine_mode mode
1907 = mode_for_size (size
* BITS_PER_UNIT
, MODE_INT
, 0);
1910 for (i
= 0; i
< size
/ UNITS_PER_WORD
; i
++)
1912 word
= operand_subword (x
, i
, 0, mode
);
1917 if (! assemble_integer (word
, UNITS_PER_WORD
, 0))
1921 if (i
== size
/ UNITS_PER_WORD
)
1923 /* If we output at least one word and then could not finish,
1924 there is no valid way to continue. */
1935 /* Assemble the floating-point constant D into an object of size MODE. */
1938 assemble_real (d
, mode
)
1940 enum machine_mode mode
;
1942 jmp_buf output_constant_handler
;
1944 if (setjmp (output_constant_handler
))
1946 error ("floating point trap outputting a constant");
1947 #ifdef REAL_IS_NOT_DOUBLE
1948 bzero ((char *) &d
, sizeof d
);
1955 set_float_handler (output_constant_handler
);
1959 #ifdef ASM_OUTPUT_BYTE_FLOAT
1961 ASM_OUTPUT_BYTE_FLOAT (asm_out_file
, d
);
1964 #ifdef ASM_OUTPUT_SHORT_FLOAT
1966 ASM_OUTPUT_SHORT_FLOAT (asm_out_file
, d
);
1969 #ifdef ASM_OUTPUT_THREE_QUARTER_FLOAT
1971 ASM_OUTPUT_THREE_QUARTER_FLOAT (asm_out_file
, d
);
1974 #ifdef ASM_OUTPUT_FLOAT
1976 ASM_OUTPUT_FLOAT (asm_out_file
, d
);
1980 #ifdef ASM_OUTPUT_DOUBLE
1982 ASM_OUTPUT_DOUBLE (asm_out_file
, d
);
1986 #ifdef ASM_OUTPUT_LONG_DOUBLE
1989 ASM_OUTPUT_LONG_DOUBLE (asm_out_file
, d
);
1997 set_float_handler (NULL_PTR
);
2000 /* Here we combine duplicate floating constants to make
2001 CONST_DOUBLE rtx's, and force those out to memory when necessary. */
2003 /* Return a CONST_DOUBLE or CONST_INT for a value specified as a pair of ints.
2004 For an integer, I0 is the low-order word and I1 is the high-order word.
2005 For a real number, I0 is the word with the low address
2006 and I1 is the word with the high address. */
2009 immed_double_const (i0
, i1
, mode
)
2010 HOST_WIDE_INT i0
, i1
;
2011 enum machine_mode mode
;
2015 if (GET_MODE_CLASS (mode
) == MODE_INT
2016 || GET_MODE_CLASS (mode
) == MODE_PARTIAL_INT
)
2018 /* We clear out all bits that don't belong in MODE, unless they and our
2019 sign bit are all one. So we get either a reasonable negative value
2020 or a reasonable unsigned value for this mode. */
2021 int width
= GET_MODE_BITSIZE (mode
);
2022 if (width
< HOST_BITS_PER_WIDE_INT
2023 && ((i0
& ((HOST_WIDE_INT
) (-1) << (width
- 1)))
2024 != ((HOST_WIDE_INT
) (-1) << (width
- 1))))
2025 i0
&= ((HOST_WIDE_INT
) 1 << width
) - 1, i1
= 0;
2026 else if (width
== HOST_BITS_PER_WIDE_INT
2027 && ! (i1
== ~0 && i0
< 0))
2029 else if (width
> 2 * HOST_BITS_PER_WIDE_INT
)
2030 /* We cannot represent this value as a constant. */
2033 /* If this would be an entire word for the target, but is not for
2034 the host, then sign-extend on the host so that the number will look
2035 the same way on the host that it would on the target.
2037 For example, when building a 64 bit alpha hosted 32 bit sparc
2038 targeted compiler, then we want the 32 bit unsigned value -1 to be
2039 represented as a 64 bit value -1, and not as 0x00000000ffffffff.
2040 The later confuses the sparc backend. */
2042 if (BITS_PER_WORD
< HOST_BITS_PER_WIDE_INT
&& BITS_PER_WORD
== width
2043 && (i0
& ((HOST_WIDE_INT
) 1 << (width
- 1))))
2044 i0
|= ((HOST_WIDE_INT
) (-1) << width
);
2046 /* If MODE fits within HOST_BITS_PER_WIDE_INT, always use a CONST_INT.
2048 ??? Strictly speaking, this is wrong if we create a CONST_INT
2049 for a large unsigned constant with the size of MODE being
2050 HOST_BITS_PER_WIDE_INT and later try to interpret that constant in a
2051 wider mode. In that case we will mis-interpret it as a negative
2054 Unfortunately, the only alternative is to make a CONST_DOUBLE
2055 for any constant in any mode if it is an unsigned constant larger
2056 than the maximum signed integer in an int on the host. However,
2057 doing this will break everyone that always expects to see a CONST_INT
2058 for SImode and smaller.
2060 We have always been making CONST_INTs in this case, so nothing new
2063 if (width
<= HOST_BITS_PER_WIDE_INT
)
2064 i1
= (i0
< 0) ? ~(HOST_WIDE_INT
) 0 : 0;
2066 /* If this integer fits in one word, return a CONST_INT. */
2067 if ((i1
== 0 && i0
>= 0)
2068 || (i1
== ~0 && i0
< 0))
2069 return GEN_INT (i0
);
2071 /* We use VOIDmode for integers. */
2075 /* Search the chain for an existing CONST_DOUBLE with the right value.
2076 If one is found, return it. */
2077 if (current_function
!= 0)
2078 for (r
= const_double_chain
; r
; r
= CONST_DOUBLE_CHAIN (r
))
2079 if (CONST_DOUBLE_LOW (r
) == i0
&& CONST_DOUBLE_HIGH (r
) == i1
2080 && GET_MODE (r
) == mode
)
2083 /* No; make a new one and add it to the chain.
2085 We may be called by an optimizer which may be discarding any memory
2086 allocated during its processing (such as combine and loop). However,
2087 we will be leaving this constant on the chain, so we cannot tolerate
2088 freed memory. So switch to saveable_obstack for this allocation
2089 and then switch back if we were in current_obstack. */
2091 push_obstacks_nochange ();
2092 rtl_in_saveable_obstack ();
2093 r
= gen_rtx_CONST_DOUBLE (mode
, NULL_RTX
, i0
, i1
);
2096 /* Don't touch const_double_chain if not inside any function. */
2097 if (current_function_decl
!= 0)
2099 CONST_DOUBLE_CHAIN (r
) = const_double_chain
;
2100 const_double_chain
= r
;
2103 /* Store const0_rtx in mem-slot since this CONST_DOUBLE is on the chain.
2104 Actual use of mem-slot is only through force_const_mem. */
2106 CONST_DOUBLE_MEM (r
) = const0_rtx
;
2111 /* Return a CONST_DOUBLE for a specified `double' value
2112 and machine mode. */
2115 immed_real_const_1 (d
, mode
)
2117 enum machine_mode mode
;
2119 union real_extract u
;
2122 /* Get the desired `double' value as a sequence of ints
2123 since that is how they are stored in a CONST_DOUBLE. */
2127 /* Detect special cases. */
2129 if (REAL_VALUES_IDENTICAL (dconst0
, d
))
2130 return CONST0_RTX (mode
);
2131 /* Check for NaN first, because some ports (specifically the i386) do not
2132 emit correct ieee-fp code by default, and thus will generate a core
2133 dump here if we pass a NaN to REAL_VALUES_EQUAL and if REAL_VALUES_EQUAL
2134 does a floating point comparison. */
2135 else if (! REAL_VALUE_ISNAN (d
) && REAL_VALUES_EQUAL (dconst1
, d
))
2136 return CONST1_RTX (mode
);
2138 if (sizeof u
== sizeof (HOST_WIDE_INT
))
2139 return immed_double_const (u
.i
[0], 0, mode
);
2140 if (sizeof u
== 2 * sizeof (HOST_WIDE_INT
))
2141 return immed_double_const (u
.i
[0], u
.i
[1], mode
);
2143 /* The rest of this function handles the case where
2144 a float value requires more than 2 ints of space.
2145 It will be deleted as dead code on machines that don't need it. */
2147 /* Search the chain for an existing CONST_DOUBLE with the right value.
2148 If one is found, return it. */
2149 if (current_function
!= 0)
2150 for (r
= const_double_chain
; r
; r
= CONST_DOUBLE_CHAIN (r
))
2151 if (! bcmp ((char *) &CONST_DOUBLE_LOW (r
), (char *) &u
, sizeof u
)
2152 && GET_MODE (r
) == mode
)
2155 /* No; make a new one and add it to the chain.
2157 We may be called by an optimizer which may be discarding any memory
2158 allocated during its processing (such as combine and loop). However,
2159 we will be leaving this constant on the chain, so we cannot tolerate
2160 freed memory. So switch to saveable_obstack for this allocation
2161 and then switch back if we were in current_obstack. */
2162 push_obstacks_nochange ();
2163 rtl_in_saveable_obstack ();
2164 r
= rtx_alloc (CONST_DOUBLE
);
2167 bcopy ((char *) &u
, (char *) &CONST_DOUBLE_LOW (r
), sizeof u
);
2169 /* Don't touch const_double_chain if not inside any function. */
2170 if (current_function_decl
!= 0)
2172 CONST_DOUBLE_CHAIN (r
) = const_double_chain
;
2173 const_double_chain
= r
;
2176 /* Store const0_rtx in CONST_DOUBLE_MEM since this CONST_DOUBLE is on the
2177 chain, but has not been allocated memory. Actual use of CONST_DOUBLE_MEM
2178 is only through force_const_mem. */
2180 CONST_DOUBLE_MEM (r
) = const0_rtx
;
2185 /* Return a CONST_DOUBLE rtx for a value specified by EXP,
2186 which must be a REAL_CST tree node. */
2189 immed_real_const (exp
)
2192 return immed_real_const_1 (TREE_REAL_CST (exp
), TYPE_MODE (TREE_TYPE (exp
)));
2195 /* At the end of a function, forget the memory-constants
2196 previously made for CONST_DOUBLEs. Mark them as not on real_constant_chain.
2197 Also clear out real_constant_chain and clear out all the chain-pointers. */
2200 clear_const_double_mem ()
2202 register rtx r
, next
;
2204 for (r
= const_double_chain
; r
; r
= next
)
2206 next
= CONST_DOUBLE_CHAIN (r
);
2207 CONST_DOUBLE_CHAIN (r
) = 0;
2208 CONST_DOUBLE_MEM (r
) = cc0_rtx
;
2210 const_double_chain
= 0;
2213 /* Given an expression EXP with a constant value,
2214 reduce it to the sum of an assembler symbol and an integer.
2215 Store them both in the structure *VALUE.
2216 Abort if EXP does not reduce. */
2221 HOST_WIDE_INT offset
;
2225 decode_addr_const (exp
, value
)
2227 struct addr_const
*value
;
2229 register tree target
= TREE_OPERAND (exp
, 0);
2230 register int offset
= 0;
2235 if (TREE_CODE (target
) == COMPONENT_REF
2236 && (TREE_CODE (DECL_FIELD_BITPOS (TREE_OPERAND (target
, 1)))
2239 offset
+= TREE_INT_CST_LOW (DECL_FIELD_BITPOS (TREE_OPERAND (target
, 1))) / BITS_PER_UNIT
;
2240 target
= TREE_OPERAND (target
, 0);
2242 else if (TREE_CODE (target
) == ARRAY_REF
)
2244 if (TREE_CODE (TREE_OPERAND (target
, 1)) != INTEGER_CST
2245 || TREE_CODE (TYPE_SIZE (TREE_TYPE (target
))) != INTEGER_CST
)
2247 offset
+= ((TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (target
)))
2248 * TREE_INT_CST_LOW (TREE_OPERAND (target
, 1)))
2250 target
= TREE_OPERAND (target
, 0);
2256 switch (TREE_CODE (target
))
2260 x
= DECL_RTL (target
);
2264 x
= gen_rtx_MEM (FUNCTION_MODE
,
2265 gen_rtx_LABEL_REF (VOIDmode
,
2266 label_rtx (TREE_OPERAND (exp
, 0))));
2274 x
= TREE_CST_RTL (target
);
2281 if (GET_CODE (x
) != MEM
)
2286 value
->offset
= offset
;
2289 /* Uniquize all constants that appear in memory.
2290 Each constant in memory thus far output is recorded
2291 in `const_hash_table' with a `struct constant_descriptor'
2292 that contains a polish representation of the value of
2295 We cannot store the trees in the hash table
2296 because the trees may be temporary. */
2298 struct constant_descriptor
2300 struct constant_descriptor
*next
;
2306 #define MAX_HASH_TABLE 1009
2307 static struct constant_descriptor
*const_hash_table
[MAX_HASH_TABLE
];
2309 /* Mark a const_hash_table descriptor for GC. */
2312 mark_const_hash_entry (ptr
)
2315 struct constant_descriptor
*desc
= * (struct constant_descriptor
**) ptr
;
2319 ggc_mark_string (desc
->label
);
2324 /* Compute a hash code for a constant expression. */
2331 register int len
, hi
, i
;
2332 register enum tree_code code
= TREE_CODE (exp
);
2334 /* Either set P and LEN to the address and len of something to hash and
2335 exit the switch or return a value. */
2340 p
= (char *) &TREE_INT_CST_LOW (exp
);
2341 len
= 2 * sizeof TREE_INT_CST_LOW (exp
);
2345 p
= (char *) &TREE_REAL_CST (exp
);
2346 len
= sizeof TREE_REAL_CST (exp
);
2350 p
= TREE_STRING_POINTER (exp
);
2351 len
= TREE_STRING_LENGTH (exp
);
2355 return (const_hash (TREE_REALPART (exp
)) * 5
2356 + const_hash (TREE_IMAGPART (exp
)));
2359 if (TREE_CODE (TREE_TYPE (exp
)) == SET_TYPE
)
2361 len
= int_size_in_bytes (TREE_TYPE (exp
));
2362 p
= (char *) alloca (len
);
2363 get_set_constructor_bytes (exp
, (unsigned char *) p
, len
);
2370 /* For record type, include the type in the hashing.
2371 We do not do so for array types
2372 because (1) the sizes of the elements are sufficient
2373 and (2) distinct array types can have the same constructor.
2374 Instead, we include the array size because the constructor could
2376 if (TREE_CODE (TREE_TYPE (exp
)) == RECORD_TYPE
)
2377 hi
= ((unsigned long) TREE_TYPE (exp
) & ((1 << HASHBITS
) - 1))
2380 hi
= ((5 + int_size_in_bytes (TREE_TYPE (exp
)))
2381 & ((1 << HASHBITS
) - 1)) % MAX_HASH_TABLE
;
2383 for (link
= CONSTRUCTOR_ELTS (exp
); link
; link
= TREE_CHAIN (link
))
2384 if (TREE_VALUE (link
))
2386 = (hi
* 603 + const_hash (TREE_VALUE (link
))) % MAX_HASH_TABLE
;
2393 struct addr_const value
;
2395 decode_addr_const (exp
, &value
);
2396 if (GET_CODE (value
.base
) == SYMBOL_REF
)
2398 /* Don't hash the address of the SYMBOL_REF;
2399 only use the offset and the symbol name. */
2401 p
= XSTR (value
.base
, 0);
2402 for (i
= 0; p
[i
] != 0; i
++)
2403 hi
= ((hi
* 613) + (unsigned) (p
[i
]));
2405 else if (GET_CODE (value
.base
) == LABEL_REF
)
2406 hi
= value
.offset
+ CODE_LABEL_NUMBER (XEXP (value
.base
, 0)) * 13;
2410 hi
&= (1 << HASHBITS
) - 1;
2411 hi
%= MAX_HASH_TABLE
;
2417 return (const_hash (TREE_OPERAND (exp
, 0)) * 9
2418 + const_hash (TREE_OPERAND (exp
, 1)));
2422 case NON_LVALUE_EXPR
:
2423 return const_hash (TREE_OPERAND (exp
, 0)) * 7 + 2;
2429 /* Compute hashing function */
2431 for (i
= 0; i
< len
; i
++)
2432 hi
= ((hi
* 613) + (unsigned) (p
[i
]));
2434 hi
&= (1 << HASHBITS
) - 1;
2435 hi
%= MAX_HASH_TABLE
;
2439 /* Compare a constant expression EXP with a constant-descriptor DESC.
2440 Return 1 if DESC describes a constant with the same value as EXP. */
2443 compare_constant (exp
, desc
)
2445 struct constant_descriptor
*desc
;
2447 return 0 != compare_constant_1 (exp
, desc
->contents
);
2450 /* Compare constant expression EXP with a substring P of a constant descriptor.
2451 If they match, return a pointer to the end of the substring matched.
2452 If they do not match, return 0.
2454 Since descriptors are written in polish prefix notation,
2455 this function can be used recursively to test one operand of EXP
2456 against a subdescriptor, and if it succeeds it returns the
2457 address of the subdescriptor for the next operand. */
2460 compare_constant_1 (exp
, p
)
2464 register char *strp
;
2466 register enum tree_code code
= TREE_CODE (exp
);
2468 if (code
!= (enum tree_code
) *p
++)
2471 /* Either set STRP, P and LEN to pointers and length to compare and exit the
2472 switch, or return the result of the comparison. */
2477 /* Integer constants are the same only if the same width of type. */
2478 if (*p
++ != TYPE_PRECISION (TREE_TYPE (exp
)))
2481 strp
= (char *) &TREE_INT_CST_LOW (exp
);
2482 len
= 2 * sizeof TREE_INT_CST_LOW (exp
);
2486 /* Real constants are the same only if the same width of type. */
2487 if (*p
++ != TYPE_PRECISION (TREE_TYPE (exp
)))
2490 strp
= (char *) &TREE_REAL_CST (exp
);
2491 len
= sizeof TREE_REAL_CST (exp
);
2495 if (flag_writable_strings
)
2498 if (*p
++ != TYPE_MODE (TREE_TYPE (exp
)))
2501 strp
= TREE_STRING_POINTER (exp
);
2502 len
= TREE_STRING_LENGTH (exp
);
2503 if (bcmp ((char *) &TREE_STRING_LENGTH (exp
), p
,
2504 sizeof TREE_STRING_LENGTH (exp
)))
2507 p
+= sizeof TREE_STRING_LENGTH (exp
);
2511 p
= compare_constant_1 (TREE_REALPART (exp
), p
);
2515 return compare_constant_1 (TREE_IMAGPART (exp
), p
);
2518 if (TREE_CODE (TREE_TYPE (exp
)) == SET_TYPE
)
2520 int xlen
= len
= int_size_in_bytes (TREE_TYPE (exp
));
2522 strp
= (char *) alloca (len
);
2523 get_set_constructor_bytes (exp
, (unsigned char *) strp
, len
);
2524 if (bcmp ((char *) &xlen
, p
, sizeof xlen
))
2533 int length
= list_length (CONSTRUCTOR_ELTS (exp
));
2535 int have_purpose
= 0;
2537 for (link
= CONSTRUCTOR_ELTS (exp
); link
; link
= TREE_CHAIN (link
))
2538 if (TREE_PURPOSE (link
))
2541 if (bcmp ((char *) &length
, p
, sizeof length
))
2546 /* For record constructors, insist that the types match.
2547 For arrays, just verify both constructors are for arrays.
2548 Then insist that either both or none have any TREE_PURPOSE
2550 if (TREE_CODE (TREE_TYPE (exp
)) == RECORD_TYPE
)
2551 type
= TREE_TYPE (exp
);
2555 if (bcmp ((char *) &type
, p
, sizeof type
))
2560 if (bcmp ((char *) &have_purpose
, p
, sizeof have_purpose
))
2563 p
+= sizeof have_purpose
;
2565 /* For arrays, insist that the size in bytes match. */
2566 if (TREE_CODE (TREE_TYPE (exp
)) == ARRAY_TYPE
)
2568 HOST_WIDE_INT size
= int_size_in_bytes (TREE_TYPE (exp
));
2570 if (bcmp ((char *) &size
, p
, sizeof size
))
2576 for (link
= CONSTRUCTOR_ELTS (exp
); link
; link
= TREE_CHAIN (link
))
2578 if (TREE_VALUE (link
))
2580 if ((p
= compare_constant_1 (TREE_VALUE (link
), p
)) == 0)
2587 if (bcmp ((char *) &zero
, p
, sizeof zero
))
2593 if (TREE_PURPOSE (link
)
2594 && TREE_CODE (TREE_PURPOSE (link
)) == FIELD_DECL
)
2596 if (bcmp ((char *) &TREE_PURPOSE (link
), p
,
2597 sizeof TREE_PURPOSE (link
)))
2600 p
+= sizeof TREE_PURPOSE (link
);
2602 else if (TREE_PURPOSE (link
))
2604 if ((p
= compare_constant_1 (TREE_PURPOSE (link
), p
)) == 0)
2607 else if (have_purpose
)
2611 if (bcmp ((char *) &zero
, p
, sizeof zero
))
2623 struct addr_const value
;
2625 decode_addr_const (exp
, &value
);
2626 strp
= (char *) &value
.offset
;
2627 len
= sizeof value
.offset
;
2628 /* Compare the offset. */
2630 if (*p
++ != *strp
++)
2633 /* Compare symbol name. */
2634 strp
= XSTR (value
.base
, 0);
2635 len
= strlen (strp
) + 1;
2642 p
= compare_constant_1 (TREE_OPERAND (exp
, 0), p
);
2646 return compare_constant_1 (TREE_OPERAND (exp
, 1), p
);
2650 case NON_LVALUE_EXPR
:
2651 return compare_constant_1 (TREE_OPERAND (exp
, 0), p
);
2657 /* Compare constant contents. */
2659 if (*p
++ != *strp
++)
2665 /* Construct a constant descriptor for the expression EXP.
2666 It is up to the caller to enter the descriptor in the hash table. */
2668 static struct constant_descriptor
*
2669 record_constant (exp
)
2672 struct constant_descriptor
*next
= 0;
2675 /* Make a struct constant_descriptor. The first two pointers will
2676 be filled in later. Here we just leave space for them. */
2678 obstack_grow (&permanent_obstack
, (char *) &next
, sizeof next
);
2679 obstack_grow (&permanent_obstack
, (char *) &label
, sizeof label
);
2680 record_constant_1 (exp
);
2681 return (struct constant_descriptor
*) obstack_finish (&permanent_obstack
);
2684 /* Add a description of constant expression EXP
2685 to the object growing in `permanent_obstack'.
2686 No need to return its address; the caller will get that
2687 from the obstack when the object is complete. */
2690 record_constant_1 (exp
)
2693 register char *strp
;
2695 register enum tree_code code
= TREE_CODE (exp
);
2697 obstack_1grow (&permanent_obstack
, (unsigned int) code
);
2702 obstack_1grow (&permanent_obstack
, TYPE_PRECISION (TREE_TYPE (exp
)));
2703 strp
= (char *) &TREE_INT_CST_LOW (exp
);
2704 len
= 2 * sizeof TREE_INT_CST_LOW (exp
);
2708 obstack_1grow (&permanent_obstack
, TYPE_PRECISION (TREE_TYPE (exp
)));
2709 strp
= (char *) &TREE_REAL_CST (exp
);
2710 len
= sizeof TREE_REAL_CST (exp
);
2714 if (flag_writable_strings
)
2717 obstack_1grow (&permanent_obstack
, TYPE_MODE (TREE_TYPE (exp
)));
2718 strp
= TREE_STRING_POINTER (exp
);
2719 len
= TREE_STRING_LENGTH (exp
);
2720 obstack_grow (&permanent_obstack
, (char *) &TREE_STRING_LENGTH (exp
),
2721 sizeof TREE_STRING_LENGTH (exp
));
2725 record_constant_1 (TREE_REALPART (exp
));
2726 record_constant_1 (TREE_IMAGPART (exp
));
2730 if (TREE_CODE (TREE_TYPE (exp
)) == SET_TYPE
)
2732 int nbytes
= int_size_in_bytes (TREE_TYPE (exp
));
2733 obstack_grow (&permanent_obstack
, &nbytes
, sizeof (nbytes
));
2734 obstack_blank (&permanent_obstack
, nbytes
);
2735 get_set_constructor_bytes
2736 (exp
, (unsigned char *) permanent_obstack
.next_free
-nbytes
,
2743 int length
= list_length (CONSTRUCTOR_ELTS (exp
));
2745 int have_purpose
= 0;
2747 for (link
= CONSTRUCTOR_ELTS (exp
); link
; link
= TREE_CHAIN (link
))
2748 if (TREE_PURPOSE (link
))
2751 obstack_grow (&permanent_obstack
, (char *) &length
, sizeof length
);
2753 /* For record constructors, insist that the types match.
2754 For arrays, just verify both constructors are for arrays.
2755 Then insist that either both or none have any TREE_PURPOSE
2757 if (TREE_CODE (TREE_TYPE (exp
)) == RECORD_TYPE
)
2758 type
= TREE_TYPE (exp
);
2761 obstack_grow (&permanent_obstack
, (char *) &type
, sizeof type
);
2762 obstack_grow (&permanent_obstack
, (char *) &have_purpose
,
2763 sizeof have_purpose
);
2765 /* For arrays, insist that the size in bytes match. */
2766 if (TREE_CODE (TREE_TYPE (exp
)) == ARRAY_TYPE
)
2768 HOST_WIDE_INT size
= int_size_in_bytes (TREE_TYPE (exp
));
2769 obstack_grow (&permanent_obstack
, (char *) &size
, sizeof size
);
2772 for (link
= CONSTRUCTOR_ELTS (exp
); link
; link
= TREE_CHAIN (link
))
2774 if (TREE_VALUE (link
))
2775 record_constant_1 (TREE_VALUE (link
));
2780 obstack_grow (&permanent_obstack
,
2781 (char *) &zero
, sizeof zero
);
2784 if (TREE_PURPOSE (link
)
2785 && TREE_CODE (TREE_PURPOSE (link
)) == FIELD_DECL
)
2786 obstack_grow (&permanent_obstack
,
2787 (char *) &TREE_PURPOSE (link
),
2788 sizeof TREE_PURPOSE (link
));
2789 else if (TREE_PURPOSE (link
))
2790 record_constant_1 (TREE_PURPOSE (link
));
2791 else if (have_purpose
)
2795 obstack_grow (&permanent_obstack
,
2796 (char *) &zero
, sizeof zero
);
2804 struct addr_const value
;
2806 decode_addr_const (exp
, &value
);
2807 /* Record the offset. */
2808 obstack_grow (&permanent_obstack
,
2809 (char *) &value
.offset
, sizeof value
.offset
);
2810 /* Record the symbol name. */
2811 obstack_grow (&permanent_obstack
, XSTR (value
.base
, 0),
2812 strlen (XSTR (value
.base
, 0)) + 1);
2819 record_constant_1 (TREE_OPERAND (exp
, 0));
2820 record_constant_1 (TREE_OPERAND (exp
, 1));
2825 case NON_LVALUE_EXPR
:
2826 record_constant_1 (TREE_OPERAND (exp
, 0));
2833 /* Record constant contents. */
2834 obstack_grow (&permanent_obstack
, strp
, len
);
2837 /* Record a list of constant expressions that were passed to
2838 output_constant_def but that could not be output right away. */
2840 struct deferred_constant
2842 struct deferred_constant
*next
;
2848 static struct deferred_constant
*deferred_constants
;
2850 /* Another list of constants which should be output after the
2852 static struct deferred_constant
*after_function_constants
;
2854 /* Nonzero means defer output of addressed subconstants
2855 (i.e., those for which output_constant_def is called.) */
2856 static int defer_addressed_constants_flag
;
2858 /* Start deferring output of subconstants. */
2861 defer_addressed_constants ()
2863 defer_addressed_constants_flag
++;
2866 /* Stop deferring output of subconstants,
2867 and output now all those that have been deferred. */
2870 output_deferred_addressed_constants ()
2872 struct deferred_constant
*p
, *next
;
2874 defer_addressed_constants_flag
--;
2876 if (defer_addressed_constants_flag
> 0)
2879 for (p
= deferred_constants
; p
; p
= next
)
2881 output_constant_def_contents (p
->exp
, p
->reloc
, p
->labelno
);
2886 deferred_constants
= 0;
2889 /* Output any constants which should appear after a function. */
2892 output_after_function_constants ()
2894 struct deferred_constant
*p
, *next
;
2896 for (p
= after_function_constants
; p
; p
= next
)
2898 output_constant_def_contents (p
->exp
, p
->reloc
, p
->labelno
);
2903 after_function_constants
= 0;
2906 /* Make a copy of the whole tree structure for a constant.
2907 This handles the same types of nodes that compare_constant
2908 and record_constant handle. */
2914 switch (TREE_CODE (exp
))
2917 /* For ADDR_EXPR, we do not want to copy the decl whose address
2918 is requested. We do want to copy constants though. */
2919 if (TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp
, 0))) == 'c')
2920 return build1 (TREE_CODE (exp
), TREE_TYPE (exp
),
2921 copy_constant (TREE_OPERAND (exp
, 0)));
2923 return copy_node (exp
);
2928 return copy_node (exp
);
2931 return build_complex (TREE_TYPE (exp
),
2932 copy_constant (TREE_REALPART (exp
)),
2933 copy_constant (TREE_IMAGPART (exp
)));
2937 return build (TREE_CODE (exp
), TREE_TYPE (exp
),
2938 copy_constant (TREE_OPERAND (exp
, 0)),
2939 copy_constant (TREE_OPERAND (exp
, 1)));
2943 case NON_LVALUE_EXPR
:
2944 return build1 (TREE_CODE (exp
), TREE_TYPE (exp
),
2945 copy_constant (TREE_OPERAND (exp
, 0)));
2949 tree copy
= copy_node (exp
);
2950 tree list
= copy_list (CONSTRUCTOR_ELTS (exp
));
2953 CONSTRUCTOR_ELTS (copy
) = list
;
2954 for (tail
= list
; tail
; tail
= TREE_CHAIN (tail
))
2955 TREE_VALUE (tail
) = copy_constant (TREE_VALUE (tail
));
2956 if (TREE_CODE (TREE_TYPE (exp
)) == SET_TYPE
)
2957 for (tail
= list
; tail
; tail
= TREE_CHAIN (tail
))
2958 TREE_PURPOSE (tail
) = copy_constant (TREE_PURPOSE (tail
));
2968 /* Return an rtx representing a reference to constant data in memory
2969 for the constant expression EXP.
2971 If assembler code for such a constant has already been output,
2972 return an rtx to refer to it.
2973 Otherwise, output such a constant in memory (or defer it for later)
2974 and generate an rtx for it.
2976 The TREE_CST_RTL of EXP is set up to point to that rtx.
2977 The const_hash_table records which constants already have label strings. */
2980 output_constant_def (exp
)
2984 register struct constant_descriptor
*desc
;
2990 if (TREE_CST_RTL (exp
))
2991 return TREE_CST_RTL (exp
);
2993 /* Make sure any other constants whose addresses appear in EXP
2994 are assigned label numbers. */
2996 reloc
= output_addressed_constants (exp
);
2998 /* Compute hash code of EXP. Search the descriptors for that hash code
2999 to see if any of them describes EXP. If yes, the descriptor records
3000 the label number already assigned. */
3002 hash
= const_hash (exp
) % MAX_HASH_TABLE
;
3004 for (desc
= const_hash_table
[hash
]; desc
; desc
= desc
->next
)
3005 if (compare_constant (exp
, desc
))
3007 found
= desc
->label
;
3013 /* No constant equal to EXP is known to have been output.
3014 Make a constant descriptor to enter EXP in the hash table.
3015 Assign the label number and record it in the descriptor for
3016 future calls to this function to find. */
3018 /* Create a string containing the label name, in LABEL. */
3019 ASM_GENERATE_INTERNAL_LABEL (label
, "LC", const_labelno
);
3021 desc
= record_constant (exp
);
3022 desc
->next
= const_hash_table
[hash
];
3023 desc
->label
= ggc_alloc_string (label
, -1);
3024 const_hash_table
[hash
] = desc
;
3027 /* We have a symbol name; construct the SYMBOL_REF and the MEM. */
3029 push_obstacks_nochange ();
3030 if (TREE_PERMANENT (exp
))
3031 end_temporary_allocation ();
3033 def
= gen_rtx_SYMBOL_REF (Pmode
, desc
->label
);
3036 = gen_rtx_MEM (TYPE_MODE (TREE_TYPE (exp
)), def
);
3037 RTX_UNCHANGING_P (TREE_CST_RTL (exp
)) = 1;
3038 if (AGGREGATE_TYPE_P (TREE_TYPE (exp
)))
3039 MEM_SET_IN_STRUCT_P (TREE_CST_RTL (exp
), 1);
3043 /* Optionally set flags or add text to the name to record information
3044 such as that it is a function name. If the name is changed, the macro
3045 ASM_OUTPUT_LABELREF will have to know how to strip this information. */
3046 #ifdef ENCODE_SECTION_INFO
3047 ENCODE_SECTION_INFO (exp
);
3050 /* If this is the first time we've seen this particular constant,
3051 output it (or defer its output for later). */
3054 int after_function
= 0;
3056 #ifdef CONSTANT_AFTER_FUNCTION_P
3057 if (current_function_decl
!= 0
3058 && CONSTANT_AFTER_FUNCTION_P (exp
))
3062 if (defer_addressed_constants_flag
|| after_function
)
3064 struct deferred_constant
*p
;
3065 p
= (struct deferred_constant
*) xmalloc (sizeof (struct deferred_constant
));
3067 push_obstacks_nochange ();
3068 suspend_momentary ();
3069 p
->exp
= copy_constant (exp
);
3072 p
->labelno
= const_labelno
++;
3075 p
->next
= after_function_constants
;
3076 after_function_constants
= p
;
3080 p
->next
= deferred_constants
;
3081 deferred_constants
= p
;
3086 /* Do no output if -fsyntax-only. */
3087 if (! flag_syntax_only
)
3088 output_constant_def_contents (exp
, reloc
, const_labelno
);
3093 return TREE_CST_RTL (exp
);
3096 /* Now output assembler code to define the label for EXP,
3097 and follow it with the data of EXP. */
3100 output_constant_def_contents (exp
, reloc
, labelno
)
3107 if (IN_NAMED_SECTION (exp
))
3108 named_section (exp
, NULL
, reloc
);
3111 /* First switch to text section, except for writable strings. */
3112 #ifdef SELECT_SECTION
3113 SELECT_SECTION (exp
, reloc
);
3115 if (((TREE_CODE (exp
) == STRING_CST
) && flag_writable_strings
)
3116 || (flag_pic
&& reloc
))
3119 readonly_data_section ();
3123 /* Align the location counter as required by EXP's data type. */
3124 align
= TYPE_ALIGN (TREE_TYPE (exp
));
3125 #ifdef CONSTANT_ALIGNMENT
3126 align
= CONSTANT_ALIGNMENT (exp
, align
);
3129 if (align
> BITS_PER_UNIT
)
3130 ASM_OUTPUT_ALIGN (asm_out_file
, floor_log2 (align
/ BITS_PER_UNIT
));
3132 /* Output the label itself. */
3133 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, "LC", labelno
);
3135 /* Output the value of EXP. */
3136 output_constant (exp
,
3137 (TREE_CODE (exp
) == STRING_CST
3138 ? TREE_STRING_LENGTH (exp
)
3139 : int_size_in_bytes (TREE_TYPE (exp
))));
3143 /* Structure to represent sufficient information about a constant so that
3144 it can be output when the constant pool is output, so that function
3145 integration can be done, and to simplify handling on machines that reference
3146 constant pool as base+displacement. */
3148 struct pool_constant
3150 struct constant_descriptor
*desc
;
3151 struct pool_constant
*next
;
3152 enum machine_mode mode
;
3160 /* Structure used to maintain hash table mapping symbols used to their
3161 corresponding constants. */
3166 struct pool_constant
*pool
;
3167 struct pool_sym
*next
;
3170 /* Hash code for a SYMBOL_REF with CONSTANT_POOL_ADDRESS_P true.
3171 The argument is XSTR (... , 0) */
3173 #define SYMHASH(LABEL) \
3174 ((((unsigned long) (LABEL)) & ((1 << HASHBITS) - 1)) % MAX_RTX_HASH_TABLE)
3176 /* Initialize constant pool hashing for a new function. */
3179 init_varasm_status (f
)
3182 struct varasm_status
*p
;
3183 p
= (struct varasm_status
*) xmalloc (sizeof (struct varasm_status
));
3185 p
->x_const_rtx_hash_table
3186 = ((struct constant_descriptor
**)
3187 xmalloc (MAX_RTX_HASH_TABLE
* sizeof (struct constant_descriptor
*)));
3188 p
->x_const_rtx_sym_hash_table
3189 = ((struct pool_sym
**)
3190 xmalloc (MAX_RTX_HASH_TABLE
* sizeof (struct pool_sym
*)));
3191 bzero ((char *) p
->x_const_rtx_hash_table
,
3192 MAX_RTX_HASH_TABLE
* sizeof (struct constant_descriptor
*));
3193 bzero ((char *) p
->x_const_rtx_sym_hash_table
,
3194 MAX_RTX_HASH_TABLE
* sizeof (struct pool_sym
*));
3196 p
->x_first_pool
= p
->x_last_pool
= 0;
3197 p
->x_pool_offset
= 0;
3198 p
->x_const_double_chain
= 0;
3201 /* Mark PC for GC. */
3204 mark_pool_constant (pc
)
3205 struct pool_constant
*pc
;
3209 ggc_mark_rtx (pc
->constant
);
3214 /* Mark PPS for GC. */
3217 mark_pool_sym_hash_table (pps
)
3218 struct pool_sym
**pps
;
3220 struct pool_sym
*ps
;
3223 for (i
= 0; i
< MAX_RTX_HASH_TABLE
; ++i
)
3224 for (ps
= pps
[i
]; ps
; ps
= ps
->next
)
3225 ggc_mark_string (ps
->label
);
3228 /* Mark P for GC. */
3231 mark_varasm_status (p
)
3232 struct varasm_status
*p
;
3237 mark_pool_constant (p
->x_first_pool
);
3238 mark_pool_sym_hash_table (p
->x_const_rtx_sym_hash_table
);
3239 ggc_mark_rtx (p
->x_const_double_chain
);
3242 /* Clear out all parts of the state in F that can safely be discarded
3243 after the function has been compiled, to let garbage collection
3244 reclaim the memory. */
3247 free_varasm_status (f
)
3250 struct varasm_status
*p
;
3253 free (p
->x_const_rtx_hash_table
);
3254 free (p
->x_const_rtx_sym_hash_table
);
3259 enum kind
{ RTX_DOUBLE
, RTX_INT
};
3263 #ifdef ONLY_INT_FIELDS
3264 unsigned int kind
: 16;
3265 unsigned int mode
: 16;
3267 enum kind kind
: 16;
3268 enum machine_mode mode
: 16;
3271 union real_extract du
;
3272 struct addr_const addr
;
3273 struct {HOST_WIDE_INT high
, low
;} di
;
3277 /* Express an rtx for a constant integer (perhaps symbolic)
3278 as the sum of a symbol or label plus an explicit integer.
3279 They are stored into VALUE. */
3282 decode_rtx_const (mode
, x
, value
)
3283 enum machine_mode mode
;
3285 struct rtx_const
*value
;
3287 /* Clear the whole structure, including any gaps. */
3290 int *p
= (int *) value
;
3291 int *end
= (int *) (value
+ 1);
3296 value
->kind
= RTX_INT
; /* Most usual kind. */
3299 switch (GET_CODE (x
))
3302 value
->kind
= RTX_DOUBLE
;
3303 if (GET_MODE (x
) != VOIDmode
)
3305 value
->mode
= GET_MODE (x
);
3306 bcopy ((char *) &CONST_DOUBLE_LOW (x
),
3307 (char *) &value
->un
.du
, sizeof value
->un
.du
);
3311 value
->un
.di
.low
= CONST_DOUBLE_LOW (x
);
3312 value
->un
.di
.high
= CONST_DOUBLE_HIGH (x
);
3317 value
->un
.addr
.offset
= INTVAL (x
);
3323 value
->un
.addr
.base
= x
;
3328 if (GET_CODE (x
) == PLUS
)
3330 value
->un
.addr
.base
= XEXP (x
, 0);
3331 if (GET_CODE (XEXP (x
, 1)) != CONST_INT
)
3333 value
->un
.addr
.offset
= INTVAL (XEXP (x
, 1));
3335 else if (GET_CODE (x
) == MINUS
)
3337 value
->un
.addr
.base
= XEXP (x
, 0);
3338 if (GET_CODE (XEXP (x
, 1)) != CONST_INT
)
3340 value
->un
.addr
.offset
= - INTVAL (XEXP (x
, 1));
3350 if (value
->kind
== RTX_INT
&& value
->un
.addr
.base
!= 0)
3351 switch (GET_CODE (value
->un
.addr
.base
))
3355 /* Use the string's address, not the SYMBOL_REF's address,
3356 for the sake of addresses of library routines.
3357 For a LABEL_REF, compare labels. */
3358 value
->un
.addr
.base
= XEXP (value
->un
.addr
.base
, 0);
3365 /* Given a MINUS expression, simplify it if both sides
3366 include the same symbol. */
3369 simplify_subtraction (x
)
3372 struct rtx_const val0
, val1
;
3374 decode_rtx_const (GET_MODE (x
), XEXP (x
, 0), &val0
);
3375 decode_rtx_const (GET_MODE (x
), XEXP (x
, 1), &val1
);
3377 if (val0
.un
.addr
.base
== val1
.un
.addr
.base
)
3378 return GEN_INT (val0
.un
.addr
.offset
- val1
.un
.addr
.offset
);
3382 /* Compute a hash code for a constant RTL expression. */
3385 const_hash_rtx (mode
, x
)
3386 enum machine_mode mode
;
3392 struct rtx_const value
;
3393 decode_rtx_const (mode
, x
, &value
);
3395 /* Compute hashing function */
3397 for (i
= 0; i
< sizeof value
/ sizeof (int); i
++)
3398 hi
+= ((int *) &value
)[i
];
3400 hi
&= (1 << HASHBITS
) - 1;
3401 hi
%= MAX_RTX_HASH_TABLE
;
3405 /* Compare a constant rtl object X with a constant-descriptor DESC.
3406 Return 1 if DESC describes a constant with the same value as X. */
3409 compare_constant_rtx (mode
, x
, desc
)
3410 enum machine_mode mode
;
3412 struct constant_descriptor
*desc
;
3414 register int *p
= (int *) desc
->contents
;
3417 struct rtx_const value
;
3419 decode_rtx_const (mode
, x
, &value
);
3420 strp
= (int *) &value
;
3421 len
= sizeof value
/ sizeof (int);
3423 /* Compare constant contents. */
3425 if (*p
++ != *strp
++)
3431 /* Construct a constant descriptor for the rtl-expression X.
3432 It is up to the caller to enter the descriptor in the hash table. */
3434 static struct constant_descriptor
*
3435 record_constant_rtx (mode
, x
)
3436 enum machine_mode mode
;
3439 struct constant_descriptor
*ptr
;
3441 struct rtx_const value
;
3443 decode_rtx_const (mode
, x
, &value
);
3445 /* Put these things in the saveable obstack so we can ensure it won't
3446 be freed if we are called from combine or some other phase that discards
3447 memory allocated from function_obstack (current_obstack). */
3448 obstack_grow (saveable_obstack
, &ptr
, sizeof ptr
);
3449 obstack_grow (saveable_obstack
, &label
, sizeof label
);
3451 /* Record constant contents. */
3452 obstack_grow (saveable_obstack
, &value
, sizeof value
);
3454 return (struct constant_descriptor
*) obstack_finish (saveable_obstack
);
3457 /* Given a constant rtx X, make (or find) a memory constant for its value
3458 and return a MEM rtx to refer to it in memory. */
3461 force_const_mem (mode
, x
)
3462 enum machine_mode mode
;
3466 register struct constant_descriptor
*desc
;
3471 /* If we want this CONST_DOUBLE in the same mode as it is in memory
3472 (this will always be true for floating CONST_DOUBLEs that have been
3473 placed in memory, but not for VOIDmode (integer) CONST_DOUBLEs),
3474 use the previous copy. Otherwise, make a new one. Note that in
3475 the unlikely event that this same CONST_DOUBLE is used in two different
3476 modes in an alternating fashion, we will allocate a lot of different
3477 memory locations, but this should be extremely rare. */
3479 if (GET_CODE (x
) == CONST_DOUBLE
3480 && GET_CODE (CONST_DOUBLE_MEM (x
)) == MEM
3481 && GET_MODE (CONST_DOUBLE_MEM (x
)) == mode
)
3482 return CONST_DOUBLE_MEM (x
);
3484 /* Compute hash code of X. Search the descriptors for that hash code
3485 to see if any of them describes X. If yes, the descriptor records
3486 the label number already assigned. */
3488 hash
= const_hash_rtx (mode
, x
);
3490 for (desc
= const_rtx_hash_table
[hash
]; desc
; desc
= desc
->next
)
3491 if (compare_constant_rtx (mode
, x
, desc
))
3493 found
= desc
->label
;
3499 register struct pool_constant
*pool
;
3500 register struct pool_sym
*sym
;
3503 /* No constant equal to X is known to have been output.
3504 Make a constant descriptor to enter X in the hash table.
3505 Assign the label number and record it in the descriptor for
3506 future calls to this function to find. */
3508 desc
= record_constant_rtx (mode
, x
);
3509 desc
->next
= const_rtx_hash_table
[hash
];
3510 const_rtx_hash_table
[hash
] = desc
;
3512 /* Align the location counter as required by EXP's data type. */
3513 align
= (mode
== VOIDmode
) ? UNITS_PER_WORD
: GET_MODE_SIZE (mode
);
3514 if (align
> BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
)
3515 align
= BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
;
3516 #ifdef CONSTANT_ALIGNMENT
3517 align
= CONSTANT_ALIGNMENT (make_tree (type_for_mode (mode
, 0), x
),
3518 align
* BITS_PER_UNIT
) / BITS_PER_UNIT
;
3521 pool_offset
+= align
- 1;
3522 pool_offset
&= ~ (align
- 1);
3524 /* If RTL is not being placed into the saveable obstack, make a
3525 copy of X that is in the saveable obstack in case we are
3526 being called from combine or some other phase that discards
3527 memory it allocates. We used to only do this if it is a
3528 CONST; however, reload can allocate a CONST_INT when
3529 eliminating registers. */
3530 if (rtl_obstack
!= saveable_obstack
3531 && (GET_CODE (x
) == CONST
|| GET_CODE (x
) == CONST_INT
))
3533 push_obstacks_nochange ();
3534 rtl_in_saveable_obstack ();
3536 if (GET_CODE (x
) == CONST
)
3537 x
= gen_rtx_CONST (GET_MODE (x
),
3538 gen_rtx_PLUS (GET_MODE (x
),
3539 XEXP (XEXP (x
, 0), 0),
3540 XEXP (XEXP (x
, 0), 1)));
3542 x
= GEN_INT (INTVAL (x
));
3547 /* Allocate a pool constant descriptor, fill it in, and chain it in. */
3549 pool
= (struct pool_constant
*) savealloc (sizeof (struct pool_constant
));
3553 pool
->labelno
= const_labelno
;
3554 pool
->align
= align
;
3555 pool
->offset
= pool_offset
;
3562 last_pool
->next
= pool
;
3565 pool_offset
+= GET_MODE_SIZE (mode
);
3567 /* Create a string containing the label name, in LABEL. */
3568 ASM_GENERATE_INTERNAL_LABEL (label
, "LC", const_labelno
);
3572 desc
->label
= found
= ggc_alloc_string (label
, -1);
3574 /* Add label to symbol hash table. */
3575 hash
= SYMHASH (found
);
3576 sym
= (struct pool_sym
*) savealloc (sizeof (struct pool_sym
));
3579 sym
->next
= const_rtx_sym_hash_table
[hash
];
3580 const_rtx_sym_hash_table
[hash
] = sym
;
3583 /* We have a symbol name; construct the SYMBOL_REF and the MEM. */
3585 def
= gen_rtx_MEM (mode
, gen_rtx_SYMBOL_REF (Pmode
, found
));
3587 RTX_UNCHANGING_P (def
) = 1;
3588 /* Mark the symbol_ref as belonging to this constants pool. */
3589 CONSTANT_POOL_ADDRESS_P (XEXP (def
, 0)) = 1;
3590 current_function_uses_const_pool
= 1;
3592 if (GET_CODE (x
) == CONST_DOUBLE
)
3594 if (CONST_DOUBLE_MEM (x
) == cc0_rtx
)
3596 CONST_DOUBLE_CHAIN (x
) = const_double_chain
;
3597 const_double_chain
= x
;
3599 CONST_DOUBLE_MEM (x
) = def
;
3605 /* Given a SYMBOL_REF with CONSTANT_POOL_ADDRESS_P true, return a pointer to
3606 the corresponding pool_constant structure. */
3608 static struct pool_constant
*
3609 find_pool_constant (f
, addr
)
3613 struct pool_sym
*sym
;
3614 char *label
= XSTR (addr
, 0);
3616 for (sym
= f
->varasm
->x_const_rtx_sym_hash_table
[SYMHASH (label
)]; sym
; sym
= sym
->next
)
3617 if (sym
->label
== label
)
3623 /* Given a constant pool SYMBOL_REF, return the corresponding constant. */
3626 get_pool_constant (addr
)
3629 return (find_pool_constant (current_function
, addr
))->constant
;
3632 /* Likewise, but for the constant pool of a specific function. */
3635 get_pool_constant_for_function (f
, addr
)
3639 return (find_pool_constant (f
, addr
))->constant
;
3642 /* Similar, return the mode. */
3645 get_pool_mode (addr
)
3648 return (find_pool_constant (current_function
, addr
))->mode
;
3652 get_pool_mode_for_function (f
, addr
)
3656 return (find_pool_constant (f
, addr
))->mode
;
3659 /* Similar, return the offset in the constant pool. */
3662 get_pool_offset (addr
)
3665 return (find_pool_constant (current_function
, addr
))->offset
;
3668 /* Return the size of the constant pool. */
3676 /* Write all the constants in the constant pool. */
3679 output_constant_pool (fnname
, fndecl
)
3680 char *fnname ATTRIBUTE_UNUSED
;
3681 tree fndecl ATTRIBUTE_UNUSED
;
3683 struct pool_constant
*pool
;
3685 union real_extract u
;
3687 /* It is possible for gcc to call force_const_mem and then to later
3688 discard the instructions which refer to the constant. In such a
3689 case we do not need to output the constant. */
3690 mark_constant_pool ();
3692 #ifdef ASM_OUTPUT_POOL_PROLOGUE
3693 ASM_OUTPUT_POOL_PROLOGUE (asm_out_file
, fnname
, fndecl
, pool_offset
);
3696 for (pool
= first_pool
; pool
; pool
= pool
->next
)
3703 /* See if X is a LABEL_REF (or a CONST referring to a LABEL_REF)
3704 whose CODE_LABEL has been deleted. This can occur if a jump table
3705 is eliminated by optimization. If so, write a constant of zero
3706 instead. Note that this can also happen by turning the
3707 CODE_LABEL into a NOTE. */
3708 if (((GET_CODE (x
) == LABEL_REF
3709 && (INSN_DELETED_P (XEXP (x
, 0))
3710 || GET_CODE (XEXP (x
, 0)) == NOTE
)))
3711 || (GET_CODE (x
) == CONST
&& GET_CODE (XEXP (x
, 0)) == PLUS
3712 && GET_CODE (XEXP (XEXP (x
, 0), 0)) == LABEL_REF
3713 && (INSN_DELETED_P (XEXP (XEXP (XEXP (x
, 0), 0), 0))
3714 || GET_CODE (XEXP (XEXP (XEXP (x
, 0), 0), 0)) == NOTE
)))
3717 /* First switch to correct section. */
3718 #ifdef SELECT_RTX_SECTION
3719 SELECT_RTX_SECTION (pool
->mode
, x
);
3721 readonly_data_section ();
3724 #ifdef ASM_OUTPUT_SPECIAL_POOL_ENTRY
3725 ASM_OUTPUT_SPECIAL_POOL_ENTRY (asm_out_file
, x
, pool
->mode
,
3726 pool
->align
, pool
->labelno
, done
);
3729 if (pool
->align
> 1)
3730 ASM_OUTPUT_ALIGN (asm_out_file
, floor_log2 (pool
->align
));
3732 /* Output the label. */
3733 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, "LC", pool
->labelno
);
3735 /* Output the value of the constant itself. */
3736 switch (GET_MODE_CLASS (pool
->mode
))
3739 if (GET_CODE (x
) != CONST_DOUBLE
)
3742 bcopy ((char *) &CONST_DOUBLE_LOW (x
), (char *) &u
, sizeof u
);
3743 assemble_real (u
.d
, pool
->mode
);
3747 case MODE_PARTIAL_INT
:
3748 assemble_integer (x
, GET_MODE_SIZE (pool
->mode
), 1);
3755 #ifdef ASM_OUTPUT_SPECIAL_POOL_ENTRY
3761 #ifdef ASM_OUTPUT_POOL_EPILOGUE
3762 ASM_OUTPUT_POOL_EPILOGUE (asm_out_file
, fnname
, fndecl
, pool_offset
);
3765 /* Done with this pool. */
3766 first_pool
= last_pool
= 0;
3769 /* Look through the instructions for this function, and mark all the
3770 entries in the constant pool which are actually being used. */
3773 mark_constant_pool ()
3776 struct pool_constant
*pool
;
3778 if (first_pool
== 0)
3781 for (pool
= first_pool
; pool
; pool
= pool
->next
)
3784 for (insn
= get_insns (); insn
; insn
= NEXT_INSN (insn
))
3785 if (GET_RTX_CLASS (GET_CODE (insn
)) == 'i')
3786 mark_constants (PATTERN (insn
));
3788 for (insn
= current_function_epilogue_delay_list
;
3790 insn
= XEXP (insn
, 1))
3791 if (GET_RTX_CLASS (GET_CODE (insn
)) == 'i')
3792 mark_constants (PATTERN (insn
));
3794 /* It's possible that the only reference to a symbol is in a symbol
3795 that's in the constant pool. This happens in Fortran under some
3796 situations. (When the constant contains the address of another
3797 constant, and only the first is used directly in an insn.)
3798 This is potentially suboptimal if there's ever a possibility of
3799 backwards (in pool order) 2'd level references. However, it's
3800 not clear that 2'd level references can happen. */
3801 for (pool
= first_pool
; pool
; pool
= pool
->next
)
3803 struct pool_sym
*sym
;
3806 /* skip unmarked entries; no insn refers to them. */
3810 /* Skip everything except SYMBOL_REFs. */
3811 if (GET_CODE (pool
->constant
) != SYMBOL_REF
)
3813 label
= XSTR (pool
->constant
, 0);
3815 /* Be sure the symbol's value is marked. */
3816 for (sym
= const_rtx_sym_hash_table
[SYMHASH (label
)]; sym
;
3818 if (sym
->label
== label
)
3819 sym
->pool
->mark
= 1;
3820 /* If we didn't find it, there's something truly wrong here, but it
3821 will be announced by the assembler. */
3830 register const char *format_ptr
;
3835 if (GET_CODE (x
) == SYMBOL_REF
)
3837 if (CONSTANT_POOL_ADDRESS_P (x
))
3838 find_pool_constant (current_function
, x
)->mark
= 1;
3841 /* Never search inside a CONST_DOUBLE, because CONST_DOUBLE_MEM may be
3842 a MEM, but does not constitute a use of that MEM. */
3843 else if (GET_CODE (x
) == CONST_DOUBLE
)
3846 /* Insns may appear inside a SEQUENCE. Only check the patterns of
3847 insns, not any notes that may be attached. We don't want to mark
3848 a constant just because it happens to appear in a REG_EQUIV note. */
3849 if (GET_RTX_CLASS (GET_CODE (x
)) == 'i')
3851 mark_constants (PATTERN (x
));
3855 format_ptr
= GET_RTX_FORMAT (GET_CODE (x
));
3857 for (i
= 0; i
< GET_RTX_LENGTH (GET_CODE (x
)); i
++)
3859 switch (*format_ptr
++)
3862 mark_constants (XEXP (x
, i
));
3866 if (XVEC (x
, i
) != 0)
3870 for (j
= 0; j
< XVECLEN (x
, i
); j
++)
3871 mark_constants (XVECEXP (x
, i
, j
));
3890 /* Find all the constants whose addresses are referenced inside of EXP,
3891 and make sure assembler code with a label has been output for each one.
3892 Indicate whether an ADDR_EXPR has been encountered. */
3895 output_addressed_constants (exp
)
3900 switch (TREE_CODE (exp
))
3904 register tree constant
= TREE_OPERAND (exp
, 0);
3906 while (TREE_CODE (constant
) == COMPONENT_REF
)
3908 constant
= TREE_OPERAND (constant
, 0);
3911 if (TREE_CODE_CLASS (TREE_CODE (constant
)) == 'c'
3912 || TREE_CODE (constant
) == CONSTRUCTOR
)
3913 /* No need to do anything here
3914 for addresses of variables or functions. */
3915 output_constant_def (constant
);
3922 reloc
= output_addressed_constants (TREE_OPERAND (exp
, 0));
3923 reloc
|= output_addressed_constants (TREE_OPERAND (exp
, 1));
3928 case NON_LVALUE_EXPR
:
3929 reloc
= output_addressed_constants (TREE_OPERAND (exp
, 0));
3935 for (link
= CONSTRUCTOR_ELTS (exp
); link
; link
= TREE_CHAIN (link
))
3936 if (TREE_VALUE (link
) != 0)
3937 reloc
|= output_addressed_constants (TREE_VALUE (link
));
3947 /* Output assembler code for constant EXP to FILE, with no label.
3948 This includes the pseudo-op such as ".int" or ".byte", and a newline.
3949 Assumes output_addressed_constants has been done on EXP already.
3951 Generate exactly SIZE bytes of assembler data, padding at the end
3952 with zeros if necessary. SIZE must always be specified.
3954 SIZE is important for structure constructors,
3955 since trailing members may have been omitted from the constructor.
3956 It is also important for initialization of arrays from string constants
3957 since the full length of the string constant might not be wanted.
3958 It is also needed for initialization of unions, where the initializer's
3959 type is just one member, and that may not be as long as the union.
3961 There a case in which we would fail to output exactly SIZE bytes:
3962 for a structure constructor that wants to produce more than SIZE bytes.
3963 But such constructors will never be generated for any possible input. */
3966 output_constant (exp
, size
)
3970 register enum tree_code code
= TREE_CODE (TREE_TYPE (exp
));
3972 /* Some front-ends use constants other than the standard
3973 language-indepdent varieties, but which may still be output
3974 directly. Give the front-end a chance to convert EXP to a
3975 language-independent representation. */
3976 if (lang_expand_constant
)
3977 exp
= (*lang_expand_constant
) (exp
);
3979 if (size
== 0 || flag_syntax_only
)
3982 /* Eliminate the NON_LVALUE_EXPR_EXPR that makes a cast not be an lvalue.
3983 That way we get the constant (we hope) inside it. Also, strip off any
3984 NOP_EXPR that converts between two record, union, array, or set types. */
3985 while ((TREE_CODE (exp
) == NOP_EXPR
3986 && (TREE_TYPE (exp
) == TREE_TYPE (TREE_OPERAND (exp
, 0))
3987 || AGGREGATE_TYPE_P (TREE_TYPE (exp
))))
3988 || TREE_CODE (exp
) == NON_LVALUE_EXPR
)
3989 exp
= TREE_OPERAND (exp
, 0);
3991 /* Allow a constructor with no elements for any data type.
3992 This means to fill the space with zeros. */
3993 if (TREE_CODE (exp
) == CONSTRUCTOR
&& CONSTRUCTOR_ELTS (exp
) == 0)
3995 assemble_zeros (size
);
4006 case REFERENCE_TYPE
:
4007 /* ??? What about (int)((float)(int)&foo + 4) */
4008 while (TREE_CODE (exp
) == NOP_EXPR
|| TREE_CODE (exp
) == CONVERT_EXPR
4009 || TREE_CODE (exp
) == NON_LVALUE_EXPR
)
4010 exp
= TREE_OPERAND (exp
, 0);
4012 if (! assemble_integer (expand_expr (exp
, NULL_RTX
, VOIDmode
,
4013 EXPAND_INITIALIZER
),
4015 error ("initializer for integer value is too complicated");
4020 if (TREE_CODE (exp
) != REAL_CST
)
4021 error ("initializer for floating value is not a floating constant");
4023 assemble_real (TREE_REAL_CST (exp
),
4024 mode_for_size (size
* BITS_PER_UNIT
, MODE_FLOAT
, 0));
4029 output_constant (TREE_REALPART (exp
), size
/ 2);
4030 output_constant (TREE_IMAGPART (exp
), size
/ 2);
4031 size
-= (size
/ 2) * 2;
4035 if (TREE_CODE (exp
) == CONSTRUCTOR
)
4037 output_constructor (exp
, size
);
4040 else if (TREE_CODE (exp
) == STRING_CST
)
4044 if (size
> TREE_STRING_LENGTH (exp
))
4046 excess
= size
- TREE_STRING_LENGTH (exp
);
4047 size
= TREE_STRING_LENGTH (exp
);
4050 assemble_string (TREE_STRING_POINTER (exp
), size
);
4059 if (TREE_CODE (exp
) == CONSTRUCTOR
)
4060 output_constructor (exp
, size
);
4066 if (TREE_CODE (exp
) == INTEGER_CST
)
4067 assemble_integer (expand_expr (exp
, NULL_RTX
,
4068 VOIDmode
, EXPAND_INITIALIZER
),
4070 else if (TREE_CODE (exp
) == CONSTRUCTOR
)
4072 unsigned char *buffer
= (unsigned char *) alloca (size
);
4073 if (get_set_constructor_bytes (exp
, buffer
, size
))
4075 assemble_string ((char *) buffer
, size
);
4078 error ("unknown set constructor type");
4086 assemble_zeros (size
);
4090 /* Subroutine of output_constant, used for CONSTRUCTORs
4091 (aggregate constants).
4092 Generate at least SIZE bytes, padding if necessary. */
4095 output_constructor (exp
, size
)
4099 register tree link
, field
= 0;
4100 HOST_WIDE_INT min_index
= 0;
4101 /* Number of bytes output or skipped so far.
4102 In other words, current position within the constructor. */
4103 int total_bytes
= 0;
4104 /* Non-zero means BYTE contains part of a byte, to be output. */
4105 int byte_buffer_in_use
= 0;
4108 if (HOST_BITS_PER_WIDE_INT
< BITS_PER_UNIT
)
4111 if (TREE_CODE (TREE_TYPE (exp
)) == RECORD_TYPE
)
4112 field
= TYPE_FIELDS (TREE_TYPE (exp
));
4114 if (TREE_CODE (TREE_TYPE (exp
)) == ARRAY_TYPE
4115 && TYPE_DOMAIN (TREE_TYPE (exp
)) != 0)
4117 = TREE_INT_CST_LOW (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (exp
))));
4119 /* As LINK goes through the elements of the constant,
4120 FIELD goes through the structure fields, if the constant is a structure.
4121 if the constant is a union, then we override this,
4122 by getting the field from the TREE_LIST element.
4123 But the constant could also be an array. Then FIELD is zero.
4125 There is always a maximum of one element in the chain LINK for unions
4126 (even if the initializer in a source program incorrectly contains
4128 for (link
= CONSTRUCTOR_ELTS (exp
);
4130 link
= TREE_CHAIN (link
),
4131 field
= field
? TREE_CHAIN (field
) : 0)
4133 tree val
= TREE_VALUE (link
);
4136 /* the element in a union constructor specifies the proper field. */
4138 if (TREE_CODE (TREE_TYPE (exp
)) == RECORD_TYPE
4139 || TREE_CODE (TREE_TYPE (exp
)) == UNION_TYPE
)
4141 /* if available, use the type given by link */
4142 if (TREE_PURPOSE (link
) != 0)
4143 field
= TREE_PURPOSE (link
);
4146 if (TREE_CODE (TREE_TYPE (exp
)) == ARRAY_TYPE
)
4147 index
= TREE_PURPOSE (link
);
4149 /* Eliminate the marker that makes a cast not be an lvalue. */
4153 if (index
&& TREE_CODE (index
) == RANGE_EXPR
)
4155 register int fieldsize
4156 = int_size_in_bytes (TREE_TYPE (TREE_TYPE (exp
)));
4157 HOST_WIDE_INT lo_index
= TREE_INT_CST_LOW (TREE_OPERAND (index
, 0));
4158 HOST_WIDE_INT hi_index
= TREE_INT_CST_LOW (TREE_OPERAND (index
, 1));
4159 HOST_WIDE_INT index
;
4160 for (index
= lo_index
; index
<= hi_index
; index
++)
4162 /* Output the element's initial value. */
4164 assemble_zeros (fieldsize
);
4166 output_constant (val
, fieldsize
);
4168 /* Count its size. */
4169 total_bytes
+= fieldsize
;
4172 else if (field
== 0 || !DECL_BIT_FIELD (field
))
4174 /* An element that is not a bit-field. */
4176 register int fieldsize
;
4177 /* Since this structure is static,
4178 we know the positions are constant. */
4179 int bitpos
= (field
? (TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field
))
4183 bitpos
= (TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (val
)))
4185 * (TREE_INT_CST_LOW (index
) - min_index
));
4187 /* Output any buffered-up bit-fields preceding this element. */
4188 if (byte_buffer_in_use
)
4190 ASM_OUTPUT_BYTE (asm_out_file
, byte
);
4192 byte_buffer_in_use
= 0;
4195 /* Advance to offset of this element.
4196 Note no alignment needed in an array, since that is guaranteed
4197 if each element has the proper size. */
4198 if ((field
!= 0 || index
!= 0) && bitpos
!= total_bytes
)
4200 assemble_zeros (bitpos
- total_bytes
);
4201 total_bytes
= bitpos
;
4204 /* Determine size this element should occupy. */
4207 if (TREE_CODE (DECL_SIZE (field
)) != INTEGER_CST
)
4209 if (TREE_INT_CST_LOW (DECL_SIZE (field
)) > 100000)
4211 /* This avoids overflow trouble. */
4212 tree size_tree
= size_binop (CEIL_DIV_EXPR
,
4214 size_int (BITS_PER_UNIT
));
4215 fieldsize
= TREE_INT_CST_LOW (size_tree
);
4219 fieldsize
= TREE_INT_CST_LOW (DECL_SIZE (field
));
4220 fieldsize
= (fieldsize
+ BITS_PER_UNIT
- 1) / BITS_PER_UNIT
;
4224 fieldsize
= int_size_in_bytes (TREE_TYPE (TREE_TYPE (exp
)));
4226 /* Output the element's initial value. */
4228 assemble_zeros (fieldsize
);
4230 output_constant (val
, fieldsize
);
4232 /* Count its size. */
4233 total_bytes
+= fieldsize
;
4235 else if (val
!= 0 && TREE_CODE (val
) != INTEGER_CST
)
4236 error ("invalid initial value for member `%s'",
4237 IDENTIFIER_POINTER (DECL_NAME (field
)));
4240 /* Element that is a bit-field. */
4242 int next_offset
= TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field
));
4244 = (next_offset
+ TREE_INT_CST_LOW (DECL_SIZE (field
)));
4247 val
= integer_zero_node
;
4249 /* If this field does not start in this (or, next) byte,
4251 if (next_offset
/ BITS_PER_UNIT
!= total_bytes
)
4253 /* Output remnant of any bit field in previous bytes. */
4254 if (byte_buffer_in_use
)
4256 ASM_OUTPUT_BYTE (asm_out_file
, byte
);
4258 byte_buffer_in_use
= 0;
4261 /* If still not at proper byte, advance to there. */
4262 if (next_offset
/ BITS_PER_UNIT
!= total_bytes
)
4264 assemble_zeros (next_offset
/ BITS_PER_UNIT
- total_bytes
);
4265 total_bytes
= next_offset
/ BITS_PER_UNIT
;
4269 if (! byte_buffer_in_use
)
4272 /* We must split the element into pieces that fall within
4273 separate bytes, and combine each byte with previous or
4274 following bit-fields. */
4276 /* next_offset is the offset n fbits from the beginning of
4277 the structure to the next bit of this element to be processed.
4278 end_offset is the offset of the first bit past the end of
4280 while (next_offset
< end_offset
)
4284 HOST_WIDE_INT value
;
4285 int next_byte
= next_offset
/ BITS_PER_UNIT
;
4286 int next_bit
= next_offset
% BITS_PER_UNIT
;
4288 /* Advance from byte to byte
4289 within this element when necessary. */
4290 while (next_byte
!= total_bytes
)
4292 ASM_OUTPUT_BYTE (asm_out_file
, byte
);
4297 /* Number of bits we can process at once
4298 (all part of the same byte). */
4299 this_time
= MIN (end_offset
- next_offset
,
4300 BITS_PER_UNIT
- next_bit
);
4301 if (BYTES_BIG_ENDIAN
)
4303 /* On big-endian machine, take the most significant bits
4304 first (of the bits that are significant)
4305 and put them into bytes from the most significant end. */
4306 shift
= end_offset
- next_offset
- this_time
;
4307 /* Don't try to take a bunch of bits that cross
4308 the word boundary in the INTEGER_CST. */
4309 if (shift
< HOST_BITS_PER_WIDE_INT
4310 && shift
+ this_time
> HOST_BITS_PER_WIDE_INT
)
4312 this_time
-= (HOST_BITS_PER_WIDE_INT
- shift
);
4313 shift
= HOST_BITS_PER_WIDE_INT
;
4316 /* Now get the bits from the appropriate constant word. */
4317 if (shift
< HOST_BITS_PER_WIDE_INT
)
4319 value
= TREE_INT_CST_LOW (val
);
4321 else if (shift
< 2 * HOST_BITS_PER_WIDE_INT
)
4323 value
= TREE_INT_CST_HIGH (val
);
4324 shift
-= HOST_BITS_PER_WIDE_INT
;
4328 byte
|= (((value
>> shift
)
4329 & (((HOST_WIDE_INT
) 1 << this_time
) - 1))
4330 << (BITS_PER_UNIT
- this_time
- next_bit
));
4334 /* On little-endian machines,
4335 take first the least significant bits of the value
4336 and pack them starting at the least significant
4337 bits of the bytes. */
4338 shift
= (next_offset
4339 - TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field
)));
4340 /* Don't try to take a bunch of bits that cross
4341 the word boundary in the INTEGER_CST. */
4342 if (shift
< HOST_BITS_PER_WIDE_INT
4343 && shift
+ this_time
> HOST_BITS_PER_WIDE_INT
)
4345 this_time
-= (HOST_BITS_PER_WIDE_INT
- shift
);
4346 shift
= HOST_BITS_PER_WIDE_INT
;
4349 /* Now get the bits from the appropriate constant word. */
4350 if (shift
< HOST_BITS_PER_WIDE_INT
)
4351 value
= TREE_INT_CST_LOW (val
);
4352 else if (shift
< 2 * HOST_BITS_PER_WIDE_INT
)
4354 value
= TREE_INT_CST_HIGH (val
);
4355 shift
-= HOST_BITS_PER_WIDE_INT
;
4359 byte
|= (((value
>> shift
)
4360 & (((HOST_WIDE_INT
) 1 << this_time
) - 1))
4363 next_offset
+= this_time
;
4364 byte_buffer_in_use
= 1;
4368 if (byte_buffer_in_use
)
4370 ASM_OUTPUT_BYTE (asm_out_file
, byte
);
4373 if (total_bytes
< size
)
4374 assemble_zeros (size
- total_bytes
);
4377 #ifdef HANDLE_PRAGMA_WEAK
4378 /* Add function NAME to the weak symbols list. VALUE is a weak alias
4379 associatd with NAME. */
4382 add_weak (name
, value
)
4386 struct weak_syms
*weak
;
4388 weak
= (struct weak_syms
*) permalloc (sizeof (struct weak_syms
));
4393 weak
->next
= weak_decls
;
4395 weak
->value
= value
;
4400 #endif /* HANDLE_PRAGMA_WEAK */
4402 /* Declare DECL to be a weak symbol. */
4408 if (! TREE_PUBLIC (decl
))
4409 error_with_decl (decl
, "weak declaration of `%s' must be public");
4410 else if (TREE_ASM_WRITTEN (decl
))
4411 error_with_decl (decl
, "weak declaration of `%s' must precede definition");
4412 else if (SUPPORTS_WEAK
)
4413 DECL_WEAK (decl
) = 1;
4414 #ifdef HANDLE_PRAGMA_WEAK
4415 add_weak (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)), NULL
);
4419 /* Emit any pending weak declarations. */
4421 #ifdef HANDLE_PRAGMA_WEAK
4422 struct weak_syms
* weak_decls
;
4428 #ifdef HANDLE_PRAGMA_WEAK
4429 if (HANDLE_PRAGMA_WEAK
)
4431 struct weak_syms
*t
;
4432 for (t
= weak_decls
; t
; t
= t
->next
)
4436 ASM_WEAKEN_LABEL (asm_out_file
, t
->name
);
4438 ASM_OUTPUT_DEF (asm_out_file
, t
->name
, t
->value
);
4445 /* Remove NAME from the pending list of weak symbols. This prevents
4446 the compiler from emitting multiple .weak directives which confuses
4448 #ifdef ASM_WEAKEN_LABEL
4450 remove_from_pending_weak_list (name
)
4451 char *name ATTRIBUTE_UNUSED
;
4453 #ifdef HANDLE_PRAGMA_WEAK
4454 if (HANDLE_PRAGMA_WEAK
)
4456 struct weak_syms
*t
;
4457 for (t
= weak_decls
; t
; t
= t
->next
)
4459 if (t
->name
&& strcmp (name
, t
->name
) == 0)
4468 assemble_alias (decl
, target
)
4469 tree decl
, target ATTRIBUTE_UNUSED
;
4473 make_decl_rtl (decl
, (char *) 0, 1);
4474 name
= XSTR (XEXP (DECL_RTL (decl
), 0), 0);
4476 #ifdef ASM_OUTPUT_DEF
4477 /* Make name accessible from other files, if appropriate. */
4479 if (TREE_PUBLIC (decl
))
4481 #ifdef ASM_WEAKEN_LABEL
4482 if (DECL_WEAK (decl
))
4484 ASM_WEAKEN_LABEL (asm_out_file
, name
);
4485 /* Remove this function from the pending weak list so that
4486 we do not emit multiple .weak directives for it. */
4487 remove_from_pending_weak_list
4488 (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)));
4492 ASM_GLOBALIZE_LABEL (asm_out_file
, name
);
4495 #ifdef ASM_OUTPUT_DEF_FROM_DECLS
4496 ASM_OUTPUT_DEF_FROM_DECLS (asm_out_file
, decl
, target
);
4498 ASM_OUTPUT_DEF (asm_out_file
, name
, IDENTIFIER_POINTER (target
));
4500 TREE_ASM_WRITTEN (decl
) = 1;
4502 #ifdef ASM_OUTPUT_WEAK_ALIAS
4503 if (! DECL_WEAK (decl
))
4504 warning ("only weak aliases are supported in this configuration");
4506 ASM_OUTPUT_WEAK_ALIAS (asm_out_file
, name
, IDENTIFIER_POINTER (target
));
4507 TREE_ASM_WRITTEN (decl
) = 1;
4509 warning ("alias definitions not supported in this configuration; ignored");
4514 /* This determines whether or not we support link-once semantics. */
4515 #ifndef SUPPORTS_ONE_ONLY
4516 #ifdef MAKE_DECL_ONE_ONLY
4517 #define SUPPORTS_ONE_ONLY 1
4519 #define SUPPORTS_ONE_ONLY 0
4523 /* Returns 1 if the target configuration supports defining public symbols
4524 so that one of them will be chosen at link time instead of generating a
4525 multiply-defined symbol error, whether through the use of weak symbols or
4526 a target-specific mechanism for having duplicates discarded. */
4529 supports_one_only ()
4531 if (SUPPORTS_ONE_ONLY
)
4533 return SUPPORTS_WEAK
;
4536 /* Set up DECL as a public symbol that can be defined in multiple
4537 translation units without generating a linker error. */
4540 make_decl_one_only (decl
)
4543 if (TREE_CODE (decl
) != VAR_DECL
&& TREE_CODE (decl
) != FUNCTION_DECL
)
4546 TREE_PUBLIC (decl
) = 1;
4548 if (TREE_CODE (decl
) == VAR_DECL
4549 && (DECL_INITIAL (decl
) == 0 || DECL_INITIAL (decl
) == error_mark_node
))
4550 DECL_COMMON (decl
) = 1;
4551 else if (SUPPORTS_ONE_ONLY
)
4553 #ifdef MAKE_DECL_ONE_ONLY
4554 MAKE_DECL_ONE_ONLY (decl
);
4556 DECL_ONE_ONLY (decl
) = 1;
4558 else if (SUPPORTS_WEAK
)
4559 DECL_WEAK (decl
) = 1;
4567 ggc_add_root (const_hash_table
, MAX_HASH_TABLE
, sizeof(const_hash_table
[0]),
4568 mark_const_hash_entry
);
4569 ggc_add_string_root (&in_named_name
, 1);