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 #if defined ASM_OUTPUT_ALIGNED_DECL_LOCAL
1201 #define ASM_EMIT_LOCAL(decl, name, size, rounded) \
1202 ASM_OUTPUT_ALIGNED_DECL_LOCAL (asm_out_file, decl, name, size, DECL_ALIGN (decl))
1204 #if defined ASM_OUTPUT_ALIGNED_LOCAL
1205 #define ASM_EMIT_LOCAL(decl, name, size, rounded) \
1206 ASM_OUTPUT_ALIGNED_LOCAL (asm_out_file, name, size, DECL_ALIGN (decl))
1208 #define ASM_EMIT_LOCAL(decl, name, size, rounded) \
1209 ASM_OUTPUT_LOCAL (asm_out_file, name, size, rounded)
1213 #if defined ASM_OUTPUT_ALIGNED_BSS
1214 #define ASM_EMIT_BSS(decl, name, size, rounded) \
1215 ASM_OUTPUT_ALIGNED_BSS (asm_out_file, decl, name, size, DECL_ALIGN (decl))
1217 #if defined ASM_OUTPUT_BSS
1218 #define ASM_EMIT_BSS(decl, name, size, rounded) \
1219 ASM_OUTPUT_BSS (asm_out_file, decl, name, size, rounded)
1225 #if defined ASM_OUTPUT_ALIGNED_DECL_COMMON
1226 #define ASM_EMIT_COMMON(decl, name, size, rounded) \
1227 ASM_OUTPUT_ALIGNED_DECL_COMMON (asm_out_file, decl, name, size, DECL_ALIGN (decl))
1229 #if defined ASM_OUTPUT_ALIGNED_COMMON
1230 #define ASM_EMIT_COMMON(decl, name, size, rounded) \
1231 ASM_OUTPUT_ALIGNED_COMMON (asm_out_file, name, size, DECL_ALIGN (decl))
1233 #define ASM_EMIT_COMMON(decl, name, size, rounded) \
1234 ASM_OUTPUT_COMMON (asm_out_file, name, size, rounded)
1239 asm_emit_uninitialised (decl
, name
, size
, rounded
)
1250 destination
= asm_dest_local
;
1252 if (TREE_PUBLIC (decl
))
1254 #if defined ASM_EMIT_BSS
1255 if (! DECL_COMMON (decl
))
1256 destination
= asm_dest_bss
;
1259 destination
= asm_dest_common
;
1262 if (flag_shared_data
)
1264 switch (destination
)
1266 #ifdef ASM_OUTPUT_SHARED_BSS
1268 ASM_OUTPUT_SHARED_BSS (asm_out_file
, decl
, name
, size
, rounded
);
1271 #ifdef ASM_OUTPUT_SHARED_COMMON
1272 case asm_dest_common
:
1273 ASM_OUTPUT_SHARED_COMMON (asm_out_file
, name
, size
, rounded
);
1276 #ifdef ASM_OUTPUT_SHARED_LOCAL
1277 case asm_dest_local
:
1278 ASM_OUTPUT_SHARED_LOCAL (asm_out_file
, name
, size
, rounded
);
1286 switch (destination
)
1290 ASM_EMIT_BSS (decl
, name
, size
, rounded
);
1293 case asm_dest_common
:
1294 ASM_EMIT_COMMON (decl
, name
, size
, rounded
);
1296 case asm_dest_local
:
1297 ASM_EMIT_LOCAL (decl
, name
, size
, rounded
);
1306 /* Assemble everything that is needed for a variable or function declaration.
1307 Not used for automatic variables, and not used for function definitions.
1308 Should not be called for variables of incomplete structure type.
1310 TOP_LEVEL is nonzero if this variable has file scope.
1311 AT_END is nonzero if this is the special handling, at end of compilation,
1312 to define things that have had only tentative definitions.
1313 DONT_OUTPUT_DATA if nonzero means don't actually output the
1314 initial value (that will be done by the caller). */
1317 assemble_variable (decl
, top_level
, at_end
, dont_output_data
)
1319 int top_level ATTRIBUTE_UNUSED
;
1321 int dont_output_data
;
1323 register char *name
;
1325 tree size_tree
= NULL_TREE
;
1327 enum in_section saved_in_section
;
1329 last_assemble_variable_decl
= 0;
1331 if (GET_CODE (DECL_RTL (decl
)) == REG
)
1333 /* Do output symbol info for global register variables, but do nothing
1336 if (TREE_ASM_WRITTEN (decl
))
1338 TREE_ASM_WRITTEN (decl
) = 1;
1340 /* Do no output if -fsyntax-only. */
1341 if (flag_syntax_only
)
1344 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
1345 /* File-scope global variables are output here. */
1346 if ((write_symbols
== DBX_DEBUG
|| write_symbols
== XCOFF_DEBUG
)
1348 dbxout_symbol (decl
, 0);
1350 #ifdef SDB_DEBUGGING_INFO
1351 if (write_symbols
== SDB_DEBUG
&& top_level
1352 /* Leave initialized global vars for end of compilation;
1353 see comment in compile_file. */
1354 && (TREE_PUBLIC (decl
) == 0 || DECL_INITIAL (decl
) == 0))
1355 sdbout_symbol (decl
, 0);
1358 /* Don't output any DWARF debugging information for variables here.
1359 In the case of local variables, the information for them is output
1360 when we do our recursive traversal of the tree representation for
1361 the entire containing function. In the case of file-scope variables,
1362 we output information for all of them at the very end of compilation
1363 while we are doing our final traversal of the chain of file-scope
1369 /* Normally no need to say anything here for external references,
1370 since assemble_external is called by the language-specific code
1371 when a declaration is first seen. */
1373 if (DECL_EXTERNAL (decl
))
1376 /* Output no assembler code for a function declaration.
1377 Only definitions of functions output anything. */
1379 if (TREE_CODE (decl
) == FUNCTION_DECL
)
1382 /* If type was incomplete when the variable was declared,
1383 see if it is complete now. */
1385 if (DECL_SIZE (decl
) == 0)
1386 layout_decl (decl
, 0);
1388 /* Still incomplete => don't allocate it; treat the tentative defn
1389 (which is what it must have been) as an `extern' reference. */
1391 if (!dont_output_data
&& DECL_SIZE (decl
) == 0)
1393 error_with_file_and_line (DECL_SOURCE_FILE (decl
),
1394 DECL_SOURCE_LINE (decl
),
1395 "storage size of `%s' isn't known",
1396 IDENTIFIER_POINTER (DECL_NAME (decl
)));
1397 TREE_ASM_WRITTEN (decl
) = 1;
1401 /* The first declaration of a variable that comes through this function
1402 decides whether it is global (in C, has external linkage)
1403 or local (in C, has internal linkage). So do nothing more
1404 if this function has already run. */
1406 if (TREE_ASM_WRITTEN (decl
))
1409 TREE_ASM_WRITTEN (decl
) = 1;
1411 /* Do no output if -fsyntax-only. */
1412 if (flag_syntax_only
)
1417 if (! dont_output_data
)
1421 if (TREE_CODE (DECL_SIZE (decl
)) != INTEGER_CST
)
1424 /* This is better than explicit arithmetic, since it avoids overflow. */
1425 size_tree
= size_binop (CEIL_DIV_EXPR
,
1426 DECL_SIZE (decl
), size_int (BITS_PER_UNIT
));
1428 size
= TREE_INT_CST_LOW (size_tree
);
1429 if (TREE_INT_CST_HIGH (size_tree
) != 0
1430 || size
!= TREE_INT_CST_LOW (size_tree
))
1432 error_with_decl (decl
, "size of variable `%s' is too large");
1437 name
= XSTR (XEXP (DECL_RTL (decl
), 0), 0);
1439 if (TREE_PUBLIC (decl
) && DECL_NAME (decl
)
1440 && ! first_global_object_name
1441 && ! (DECL_COMMON (decl
) && (DECL_INITIAL (decl
) == 0
1442 || DECL_INITIAL (decl
) == error_mark_node
))
1443 && ! DECL_WEAK (decl
)
1444 && ! DECL_ONE_ONLY (decl
))
1448 STRIP_NAME_ENCODING (p
, name
);
1449 first_global_object_name
= permalloc (strlen (p
) + 1);
1450 strcpy (first_global_object_name
, p
);
1453 /* Compute the alignment of this data. */
1455 align
= DECL_ALIGN (decl
);
1457 /* In the case for initialing an array whose length isn't specified,
1458 where we have not yet been able to do the layout,
1459 figure out the proper alignment now. */
1460 if (dont_output_data
&& DECL_SIZE (decl
) == 0
1461 && TREE_CODE (TREE_TYPE (decl
)) == ARRAY_TYPE
)
1462 align
= MAX (align
, TYPE_ALIGN (TREE_TYPE (TREE_TYPE (decl
))));
1464 /* Some object file formats have a maximum alignment which they support.
1465 In particular, a.out format supports a maximum alignment of 4. */
1466 #ifndef MAX_OFILE_ALIGNMENT
1467 #define MAX_OFILE_ALIGNMENT BIGGEST_ALIGNMENT
1469 if (align
> MAX_OFILE_ALIGNMENT
)
1471 warning_with_decl (decl
,
1472 "alignment of `%s' is greater than maximum object file alignment. Using %d.",
1473 MAX_OFILE_ALIGNMENT
/BITS_PER_UNIT
);
1474 align
= MAX_OFILE_ALIGNMENT
;
1477 /* On some machines, it is good to increase alignment sometimes. */
1478 #ifdef DATA_ALIGNMENT
1479 align
= DATA_ALIGNMENT (TREE_TYPE (decl
), align
);
1481 #ifdef CONSTANT_ALIGNMENT
1482 if (DECL_INITIAL (decl
) != 0 && DECL_INITIAL (decl
) != error_mark_node
)
1483 align
= CONSTANT_ALIGNMENT (DECL_INITIAL (decl
), align
);
1486 /* Reset the alignment in case we have made it tighter, so we can benefit
1487 from it in get_pointer_alignment. */
1488 DECL_ALIGN (decl
) = align
;
1490 /* Handle uninitialized definitions. */
1492 if ((DECL_INITIAL (decl
) == 0 || DECL_INITIAL (decl
) == error_mark_node
)
1493 /* If the target can't output uninitialized but not common global data
1494 in .bss, then we have to use .data. */
1495 #if ! defined ASM_EMIT_BSS
1496 && DECL_COMMON (decl
)
1498 && DECL_SECTION_NAME (decl
) == 0
1499 && ! dont_output_data
)
1501 int size
= TREE_INT_CST_LOW (size_tree
);
1504 /* Don't allocate zero bytes of common,
1505 since that means "undefined external" in the linker. */
1506 if (size
== 0) rounded
= 1;
1507 /* Round size up to multiple of BIGGEST_ALIGNMENT bits
1508 so that each uninitialized object starts on such a boundary. */
1509 rounded
+= (BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
) - 1;
1510 rounded
= (rounded
/ (BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
)
1511 * (BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
));
1513 #if !defined(ASM_OUTPUT_ALIGNED_COMMON) && !defined(ASM_OUTPUT_ALIGNED_BSS)
1514 if ( (DECL_ALIGN (decl
) / BITS_PER_UNIT
) > rounded
)
1516 (decl
, "requested alignment for %s is greater than implemented alignment of %d.",rounded
);
1519 #ifdef DBX_DEBUGGING_INFO
1520 /* File-scope global variables are output here. */
1521 if (write_symbols
== DBX_DEBUG
&& top_level
)
1522 dbxout_symbol (decl
, 0);
1524 #ifdef SDB_DEBUGGING_INFO
1525 if (write_symbols
== SDB_DEBUG
&& top_level
1526 /* Leave initialized global vars for end of compilation;
1527 see comment in compile_file. */
1528 && (TREE_PUBLIC (decl
) == 0 || DECL_INITIAL (decl
) == 0))
1529 sdbout_symbol (decl
, 0);
1532 /* Don't output any DWARF debugging information for variables here.
1533 In the case of local variables, the information for them is output
1534 when we do our recursive traversal of the tree representation for
1535 the entire containing function. In the case of file-scope variables,
1536 we output information for all of them at the very end of compilation
1537 while we are doing our final traversal of the chain of file-scope
1540 #if 0 /* ??? We should either delete this or add a comment describing what
1541 it was intended to do and why we shouldn't delete it. */
1542 if (flag_shared_data
)
1545 asm_emit_uninitialised (decl
, name
, size
, rounded
);
1550 /* Handle initialized definitions.
1551 Also handle uninitialized global definitions if -fno-common and the
1552 target doesn't support ASM_OUTPUT_BSS. */
1554 /* First make the assembler name(s) global if appropriate. */
1555 if (TREE_PUBLIC (decl
) && DECL_NAME (decl
))
1557 #ifdef ASM_WEAKEN_LABEL
1558 if (DECL_WEAK (decl
))
1560 ASM_WEAKEN_LABEL (asm_out_file
, name
);
1561 /* Remove this variable from the pending weak list so that
1562 we do not emit multiple .weak directives for it. */
1563 remove_from_pending_weak_list
1564 (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)));
1568 ASM_GLOBALIZE_LABEL (asm_out_file
, name
);
1571 for (d
= equivalents
; d
; d
= TREE_CHAIN (d
))
1573 tree e
= TREE_VALUE (d
);
1574 if (TREE_PUBLIC (e
) && DECL_NAME (e
))
1575 ASM_GLOBALIZE_LABEL (asm_out_file
,
1576 XSTR (XEXP (DECL_RTL (e
), 0), 0));
1580 /* Output any data that we will need to use the address of. */
1581 if (DECL_INITIAL (decl
) == error_mark_node
)
1582 reloc
= contains_pointers_p (TREE_TYPE (decl
));
1583 else if (DECL_INITIAL (decl
))
1584 reloc
= output_addressed_constants (DECL_INITIAL (decl
));
1586 #ifdef ASM_OUTPUT_SECTION_NAME
1587 if ((flag_data_sections
!= 0
1588 && DECL_SECTION_NAME (decl
) == NULL_TREE
)
1589 || UNIQUE_SECTION_P (decl
))
1590 UNIQUE_SECTION (decl
, reloc
);
1593 /* Switch to the appropriate section. */
1594 variable_section (decl
, reloc
);
1596 /* dbxout.c needs to know this. */
1597 if (in_text_section ())
1598 DECL_IN_TEXT_SECTION (decl
) = 1;
1600 /* Record current section so we can restore it if dbxout.c clobbers it. */
1601 saved_in_section
= in_section
;
1603 /* Output the dbx info now that we have chosen the section. */
1605 #ifdef DBX_DEBUGGING_INFO
1606 /* File-scope global variables are output here. */
1607 if (write_symbols
== DBX_DEBUG
&& top_level
)
1608 dbxout_symbol (decl
, 0);
1610 #ifdef SDB_DEBUGGING_INFO
1611 if (write_symbols
== SDB_DEBUG
&& top_level
1612 /* Leave initialized global vars for end of compilation;
1613 see comment in compile_file. */
1614 && (TREE_PUBLIC (decl
) == 0 || DECL_INITIAL (decl
) == 0))
1615 sdbout_symbol (decl
, 0);
1618 /* Don't output any DWARF debugging information for variables here.
1619 In the case of local variables, the information for them is output
1620 when we do our recursive traversal of the tree representation for
1621 the entire containing function. In the case of file-scope variables,
1622 we output information for all of them at the very end of compilation
1623 while we are doing our final traversal of the chain of file-scope
1626 /* If the debugging output changed sections, reselect the section
1627 that's supposed to be selected. */
1628 if (in_section
!= saved_in_section
)
1629 variable_section (decl
, reloc
);
1631 /* Output the alignment of this data. */
1632 if (align
> BITS_PER_UNIT
)
1633 ASM_OUTPUT_ALIGN (asm_out_file
,
1634 floor_log2 (DECL_ALIGN (decl
) / BITS_PER_UNIT
));
1636 /* Do any machine/system dependent processing of the object. */
1637 #ifdef ASM_DECLARE_OBJECT_NAME
1638 last_assemble_variable_decl
= decl
;
1639 ASM_DECLARE_OBJECT_NAME (asm_out_file
, name
, decl
);
1641 /* Standard thing is just output label for the object. */
1642 ASM_OUTPUT_LABEL (asm_out_file
, name
);
1643 #endif /* ASM_DECLARE_OBJECT_NAME */
1645 if (!dont_output_data
)
1647 if (DECL_INITIAL (decl
))
1648 /* Output the actual data. */
1649 output_constant (DECL_INITIAL (decl
), TREE_INT_CST_LOW (size_tree
));
1651 /* Leave space for it. */
1652 assemble_zeros (TREE_INT_CST_LOW (size_tree
));
1656 #ifdef XCOFF_DEBUGGING_INFO
1657 /* Unfortunately, the IBM assembler cannot handle stabx before the actual
1658 declaration. When something like ".stabx "aa:S-2",aa,133,0" is emitted
1659 and `aa' hasn't been output yet, the assembler generates a stab entry with
1660 a value of zero, in addition to creating an unnecessary external entry
1661 for `aa'. Hence, we must postpone dbxout_symbol to here at the end. */
1663 /* File-scope global variables are output here. */
1664 if (write_symbols
== XCOFF_DEBUG
&& top_level
)
1666 saved_in_section
= in_section
;
1668 dbxout_symbol (decl
, 0);
1670 if (in_section
!= saved_in_section
)
1671 variable_section (decl
, reloc
);
1674 /* There must be a statement after a label. */
1679 /* Return 1 if type TYPE contains any pointers. */
1682 contains_pointers_p (type
)
1685 switch (TREE_CODE (type
))
1688 case REFERENCE_TYPE
:
1689 /* I'm not sure whether OFFSET_TYPE needs this treatment,
1690 so I'll play safe and return 1. */
1696 case QUAL_UNION_TYPE
:
1699 /* For a type that has fields, see if the fields have pointers. */
1700 for (fields
= TYPE_FIELDS (type
); fields
; fields
= TREE_CHAIN (fields
))
1701 if (TREE_CODE (fields
) == FIELD_DECL
1702 && contains_pointers_p (TREE_TYPE (fields
)))
1708 /* An array type contains pointers if its element type does. */
1709 return contains_pointers_p (TREE_TYPE (type
));
1716 /* Output something to declare an external symbol to the assembler.
1717 (Most assemblers don't need this, so we normally output nothing.)
1718 Do nothing if DECL is not external. */
1721 assemble_external (decl
)
1722 tree decl ATTRIBUTE_UNUSED
;
1724 #ifdef ASM_OUTPUT_EXTERNAL
1725 if (TREE_CODE_CLASS (TREE_CODE (decl
)) == 'd'
1726 && DECL_EXTERNAL (decl
) && TREE_PUBLIC (decl
))
1728 rtx rtl
= DECL_RTL (decl
);
1730 if (GET_CODE (rtl
) == MEM
&& GET_CODE (XEXP (rtl
, 0)) == SYMBOL_REF
1731 && ! SYMBOL_REF_USED (XEXP (rtl
, 0)))
1733 /* Some systems do require some output. */
1734 SYMBOL_REF_USED (XEXP (rtl
, 0)) = 1;
1735 ASM_OUTPUT_EXTERNAL (asm_out_file
, decl
, XSTR (XEXP (rtl
, 0), 0));
1741 /* Similar, for calling a library function FUN. */
1744 assemble_external_libcall (fun
)
1745 rtx fun ATTRIBUTE_UNUSED
;
1747 #ifdef ASM_OUTPUT_EXTERNAL_LIBCALL
1748 /* Declare library function name external when first used, if nec. */
1749 if (! SYMBOL_REF_USED (fun
))
1751 SYMBOL_REF_USED (fun
) = 1;
1752 ASM_OUTPUT_EXTERNAL_LIBCALL (asm_out_file
, fun
);
1757 /* Declare the label NAME global. */
1760 assemble_global (name
)
1763 ASM_GLOBALIZE_LABEL (asm_out_file
, name
);
1766 /* Assemble a label named NAME. */
1769 assemble_label (name
)
1772 ASM_OUTPUT_LABEL (asm_out_file
, name
);
1775 /* Output to FILE a reference to the assembler name of a C-level name NAME.
1776 If NAME starts with a *, the rest of NAME is output verbatim.
1777 Otherwise NAME is transformed in an implementation-defined way
1778 (usually by the addition of an underscore).
1779 Many macros in the tm file are defined to call this function. */
1782 assemble_name (file
, name
)
1786 const char *real_name
;
1789 STRIP_NAME_ENCODING (real_name
, name
);
1790 if (flag_prefix_function_name
1791 && ! bcmp (real_name
, CHKR_PREFIX
, CHKR_PREFIX_SIZE
))
1792 real_name
= real_name
+ CHKR_PREFIX_SIZE
;
1794 id
= maybe_get_identifier (real_name
);
1796 TREE_SYMBOL_REFERENCED (id
) = 1;
1799 fputs (&name
[1], file
);
1801 ASM_OUTPUT_LABELREF (file
, name
);
1804 /* Allocate SIZE bytes writable static space with a gensym name
1805 and return an RTX to refer to its address. */
1808 assemble_static_space (size
)
1816 if (flag_shared_data
)
1820 ASM_GENERATE_INTERNAL_LABEL (name
, "LF", const_labelno
);
1822 namestring
= ggc_alloc_string (name
, -1);
1824 x
= gen_rtx_SYMBOL_REF (Pmode
, namestring
);
1826 #ifdef ASM_OUTPUT_ALIGNED_DECL_LOCAL
1827 ASM_OUTPUT_ALIGNED_DECL_LOCAL (asm_out_file
, NULL_TREE
, name
, size
,
1830 #ifdef ASM_OUTPUT_ALIGNED_LOCAL
1831 ASM_OUTPUT_ALIGNED_LOCAL (asm_out_file
, name
, size
, BIGGEST_ALIGNMENT
);
1834 /* Round size up to multiple of BIGGEST_ALIGNMENT bits
1835 so that each uninitialized object starts on such a boundary. */
1836 /* Variable `rounded' might or might not be used in ASM_OUTPUT_LOCAL. */
1837 int rounded ATTRIBUTE_UNUSED
1838 = ((size
+ (BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
) - 1)
1839 / (BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
)
1840 * (BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
));
1841 ASM_OUTPUT_LOCAL (asm_out_file
, name
, size
, rounded
);
1848 /* Assemble the static constant template for function entry trampolines.
1849 This is done at most once per compilation.
1850 Returns an RTX for the address of the template. */
1852 #ifdef TRAMPOLINE_TEMPLATE
1854 assemble_trampoline_template ()
1860 /* By default, put trampoline templates in read-only data section. */
1862 #ifdef TRAMPOLINE_SECTION
1863 TRAMPOLINE_SECTION ();
1865 readonly_data_section ();
1868 /* Write the assembler code to define one. */
1869 align
= floor_log2 (TRAMPOLINE_ALIGNMENT
/ BITS_PER_UNIT
);
1871 ASM_OUTPUT_ALIGN (asm_out_file
, align
);
1873 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, "LTRAMP", 0);
1874 TRAMPOLINE_TEMPLATE (asm_out_file
);
1876 /* Record the rtl to refer to it. */
1877 ASM_GENERATE_INTERNAL_LABEL (label
, "LTRAMP", 0);
1878 name
= ggc_alloc_string (label
, -1);
1879 return gen_rtx_SYMBOL_REF (Pmode
, name
);
1883 /* Assemble the integer constant X into an object of SIZE bytes.
1884 X must be either a CONST_INT or CONST_DOUBLE.
1886 Return 1 if we were able to output the constant, otherwise 0. If FORCE is
1887 non-zero, abort if we can't output the constant. */
1890 assemble_integer (x
, size
, force
)
1895 /* First try to use the standard 1, 2, 4, 8, and 16 byte
1896 ASM_OUTPUT... macros. */
1900 #ifdef ASM_OUTPUT_CHAR
1902 ASM_OUTPUT_CHAR (asm_out_file
, x
);
1906 #ifdef ASM_OUTPUT_SHORT
1908 ASM_OUTPUT_SHORT (asm_out_file
, x
);
1912 #ifdef ASM_OUTPUT_INT
1914 ASM_OUTPUT_INT (asm_out_file
, x
);
1918 #ifdef ASM_OUTPUT_DOUBLE_INT
1920 ASM_OUTPUT_DOUBLE_INT (asm_out_file
, x
);
1924 #ifdef ASM_OUTPUT_QUADRUPLE_INT
1926 ASM_OUTPUT_QUADRUPLE_INT (asm_out_file
, x
);
1931 /* If we couldn't do it that way, there are two other possibilities: First,
1932 if the machine can output an explicit byte and this is a 1 byte constant,
1933 we can use ASM_OUTPUT_BYTE. */
1935 #ifdef ASM_OUTPUT_BYTE
1936 if (size
== 1 && GET_CODE (x
) == CONST_INT
)
1938 ASM_OUTPUT_BYTE (asm_out_file
, INTVAL (x
));
1943 /* Finally, if SIZE is larger than a single word, try to output the constant
1944 one word at a time. */
1946 if (size
> UNITS_PER_WORD
)
1949 enum machine_mode mode
1950 = mode_for_size (size
* BITS_PER_UNIT
, MODE_INT
, 0);
1953 for (i
= 0; i
< size
/ UNITS_PER_WORD
; i
++)
1955 word
= operand_subword (x
, i
, 0, mode
);
1960 if (! assemble_integer (word
, UNITS_PER_WORD
, 0))
1964 if (i
== size
/ UNITS_PER_WORD
)
1966 /* If we output at least one word and then could not finish,
1967 there is no valid way to continue. */
1978 /* Assemble the floating-point constant D into an object of size MODE. */
1981 assemble_real (d
, mode
)
1983 enum machine_mode mode
;
1985 jmp_buf output_constant_handler
;
1987 if (setjmp (output_constant_handler
))
1989 error ("floating point trap outputting a constant");
1990 #ifdef REAL_IS_NOT_DOUBLE
1991 bzero ((char *) &d
, sizeof d
);
1998 set_float_handler (output_constant_handler
);
2002 #ifdef ASM_OUTPUT_BYTE_FLOAT
2004 ASM_OUTPUT_BYTE_FLOAT (asm_out_file
, d
);
2007 #ifdef ASM_OUTPUT_SHORT_FLOAT
2009 ASM_OUTPUT_SHORT_FLOAT (asm_out_file
, d
);
2012 #ifdef ASM_OUTPUT_THREE_QUARTER_FLOAT
2014 ASM_OUTPUT_THREE_QUARTER_FLOAT (asm_out_file
, d
);
2017 #ifdef ASM_OUTPUT_FLOAT
2019 ASM_OUTPUT_FLOAT (asm_out_file
, d
);
2023 #ifdef ASM_OUTPUT_DOUBLE
2025 ASM_OUTPUT_DOUBLE (asm_out_file
, d
);
2029 #ifdef ASM_OUTPUT_LONG_DOUBLE
2032 ASM_OUTPUT_LONG_DOUBLE (asm_out_file
, d
);
2040 set_float_handler (NULL_PTR
);
2043 /* Here we combine duplicate floating constants to make
2044 CONST_DOUBLE rtx's, and force those out to memory when necessary. */
2046 /* Return a CONST_DOUBLE or CONST_INT for a value specified as a pair of ints.
2047 For an integer, I0 is the low-order word and I1 is the high-order word.
2048 For a real number, I0 is the word with the low address
2049 and I1 is the word with the high address. */
2052 immed_double_const (i0
, i1
, mode
)
2053 HOST_WIDE_INT i0
, i1
;
2054 enum machine_mode mode
;
2058 if (GET_MODE_CLASS (mode
) == MODE_INT
2059 || GET_MODE_CLASS (mode
) == MODE_PARTIAL_INT
)
2061 /* We clear out all bits that don't belong in MODE, unless they and our
2062 sign bit are all one. So we get either a reasonable negative value
2063 or a reasonable unsigned value for this mode. */
2064 int width
= GET_MODE_BITSIZE (mode
);
2065 if (width
< HOST_BITS_PER_WIDE_INT
2066 && ((i0
& ((HOST_WIDE_INT
) (-1) << (width
- 1)))
2067 != ((HOST_WIDE_INT
) (-1) << (width
- 1))))
2068 i0
&= ((HOST_WIDE_INT
) 1 << width
) - 1, i1
= 0;
2069 else if (width
== HOST_BITS_PER_WIDE_INT
2070 && ! (i1
== ~0 && i0
< 0))
2072 else if (width
> 2 * HOST_BITS_PER_WIDE_INT
)
2073 /* We cannot represent this value as a constant. */
2076 /* If this would be an entire word for the target, but is not for
2077 the host, then sign-extend on the host so that the number will look
2078 the same way on the host that it would on the target.
2080 For example, when building a 64 bit alpha hosted 32 bit sparc
2081 targeted compiler, then we want the 32 bit unsigned value -1 to be
2082 represented as a 64 bit value -1, and not as 0x00000000ffffffff.
2083 The later confuses the sparc backend. */
2085 if (BITS_PER_WORD
< HOST_BITS_PER_WIDE_INT
&& BITS_PER_WORD
== width
2086 && (i0
& ((HOST_WIDE_INT
) 1 << (width
- 1))))
2087 i0
|= ((HOST_WIDE_INT
) (-1) << width
);
2089 /* If MODE fits within HOST_BITS_PER_WIDE_INT, always use a CONST_INT.
2091 ??? Strictly speaking, this is wrong if we create a CONST_INT
2092 for a large unsigned constant with the size of MODE being
2093 HOST_BITS_PER_WIDE_INT and later try to interpret that constant in a
2094 wider mode. In that case we will mis-interpret it as a negative
2097 Unfortunately, the only alternative is to make a CONST_DOUBLE
2098 for any constant in any mode if it is an unsigned constant larger
2099 than the maximum signed integer in an int on the host. However,
2100 doing this will break everyone that always expects to see a CONST_INT
2101 for SImode and smaller.
2103 We have always been making CONST_INTs in this case, so nothing new
2106 if (width
<= HOST_BITS_PER_WIDE_INT
)
2107 i1
= (i0
< 0) ? ~(HOST_WIDE_INT
) 0 : 0;
2109 /* If this integer fits in one word, return a CONST_INT. */
2110 if ((i1
== 0 && i0
>= 0)
2111 || (i1
== ~0 && i0
< 0))
2112 return GEN_INT (i0
);
2114 /* We use VOIDmode for integers. */
2118 /* Search the chain for an existing CONST_DOUBLE with the right value.
2119 If one is found, return it. */
2120 if (current_function
!= 0)
2121 for (r
= const_double_chain
; r
; r
= CONST_DOUBLE_CHAIN (r
))
2122 if (CONST_DOUBLE_LOW (r
) == i0
&& CONST_DOUBLE_HIGH (r
) == i1
2123 && GET_MODE (r
) == mode
)
2126 /* No; make a new one and add it to the chain.
2128 We may be called by an optimizer which may be discarding any memory
2129 allocated during its processing (such as combine and loop). However,
2130 we will be leaving this constant on the chain, so we cannot tolerate
2131 freed memory. So switch to saveable_obstack for this allocation
2132 and then switch back if we were in current_obstack. */
2134 push_obstacks_nochange ();
2135 rtl_in_saveable_obstack ();
2136 r
= gen_rtx_CONST_DOUBLE (mode
, NULL_RTX
, i0
, i1
);
2139 /* Don't touch const_double_chain if not inside any function. */
2140 if (current_function_decl
!= 0)
2142 CONST_DOUBLE_CHAIN (r
) = const_double_chain
;
2143 const_double_chain
= r
;
2146 /* Store const0_rtx in mem-slot since this CONST_DOUBLE is on the chain.
2147 Actual use of mem-slot is only through force_const_mem. */
2149 CONST_DOUBLE_MEM (r
) = const0_rtx
;
2154 /* Return a CONST_DOUBLE for a specified `double' value
2155 and machine mode. */
2158 immed_real_const_1 (d
, mode
)
2160 enum machine_mode mode
;
2162 union real_extract u
;
2165 /* Get the desired `double' value as a sequence of ints
2166 since that is how they are stored in a CONST_DOUBLE. */
2170 /* Detect special cases. */
2172 if (REAL_VALUES_IDENTICAL (dconst0
, d
))
2173 return CONST0_RTX (mode
);
2174 /* Check for NaN first, because some ports (specifically the i386) do not
2175 emit correct ieee-fp code by default, and thus will generate a core
2176 dump here if we pass a NaN to REAL_VALUES_EQUAL and if REAL_VALUES_EQUAL
2177 does a floating point comparison. */
2178 else if (! REAL_VALUE_ISNAN (d
) && REAL_VALUES_EQUAL (dconst1
, d
))
2179 return CONST1_RTX (mode
);
2181 if (sizeof u
== sizeof (HOST_WIDE_INT
))
2182 return immed_double_const (u
.i
[0], 0, mode
);
2183 if (sizeof u
== 2 * sizeof (HOST_WIDE_INT
))
2184 return immed_double_const (u
.i
[0], u
.i
[1], mode
);
2186 /* The rest of this function handles the case where
2187 a float value requires more than 2 ints of space.
2188 It will be deleted as dead code on machines that don't need it. */
2190 /* Search the chain for an existing CONST_DOUBLE with the right value.
2191 If one is found, return it. */
2192 if (current_function
!= 0)
2193 for (r
= const_double_chain
; r
; r
= CONST_DOUBLE_CHAIN (r
))
2194 if (! bcmp ((char *) &CONST_DOUBLE_LOW (r
), (char *) &u
, sizeof u
)
2195 && GET_MODE (r
) == mode
)
2198 /* No; make a new one and add it to the chain.
2200 We may be called by an optimizer which may be discarding any memory
2201 allocated during its processing (such as combine and loop). However,
2202 we will be leaving this constant on the chain, so we cannot tolerate
2203 freed memory. So switch to saveable_obstack for this allocation
2204 and then switch back if we were in current_obstack. */
2205 push_obstacks_nochange ();
2206 rtl_in_saveable_obstack ();
2207 r
= rtx_alloc (CONST_DOUBLE
);
2210 bcopy ((char *) &u
, (char *) &CONST_DOUBLE_LOW (r
), sizeof u
);
2212 /* Don't touch const_double_chain if not inside any function. */
2213 if (current_function_decl
!= 0)
2215 CONST_DOUBLE_CHAIN (r
) = const_double_chain
;
2216 const_double_chain
= r
;
2219 /* Store const0_rtx in CONST_DOUBLE_MEM since this CONST_DOUBLE is on the
2220 chain, but has not been allocated memory. Actual use of CONST_DOUBLE_MEM
2221 is only through force_const_mem. */
2223 CONST_DOUBLE_MEM (r
) = const0_rtx
;
2228 /* Return a CONST_DOUBLE rtx for a value specified by EXP,
2229 which must be a REAL_CST tree node. */
2232 immed_real_const (exp
)
2235 return immed_real_const_1 (TREE_REAL_CST (exp
), TYPE_MODE (TREE_TYPE (exp
)));
2238 /* At the end of a function, forget the memory-constants
2239 previously made for CONST_DOUBLEs. Mark them as not on real_constant_chain.
2240 Also clear out real_constant_chain and clear out all the chain-pointers. */
2243 clear_const_double_mem ()
2245 register rtx r
, next
;
2247 for (r
= const_double_chain
; r
; r
= next
)
2249 next
= CONST_DOUBLE_CHAIN (r
);
2250 CONST_DOUBLE_CHAIN (r
) = 0;
2251 CONST_DOUBLE_MEM (r
) = cc0_rtx
;
2253 const_double_chain
= 0;
2256 /* Given an expression EXP with a constant value,
2257 reduce it to the sum of an assembler symbol and an integer.
2258 Store them both in the structure *VALUE.
2259 Abort if EXP does not reduce. */
2264 HOST_WIDE_INT offset
;
2268 decode_addr_const (exp
, value
)
2270 struct addr_const
*value
;
2272 register tree target
= TREE_OPERAND (exp
, 0);
2273 register int offset
= 0;
2278 if (TREE_CODE (target
) == COMPONENT_REF
2279 && (TREE_CODE (DECL_FIELD_BITPOS (TREE_OPERAND (target
, 1)))
2282 offset
+= TREE_INT_CST_LOW (DECL_FIELD_BITPOS (TREE_OPERAND (target
, 1))) / BITS_PER_UNIT
;
2283 target
= TREE_OPERAND (target
, 0);
2285 else if (TREE_CODE (target
) == ARRAY_REF
)
2287 if (TREE_CODE (TREE_OPERAND (target
, 1)) != INTEGER_CST
2288 || TREE_CODE (TYPE_SIZE (TREE_TYPE (target
))) != INTEGER_CST
)
2290 offset
+= ((TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (target
)))
2291 * TREE_INT_CST_LOW (TREE_OPERAND (target
, 1)))
2293 target
= TREE_OPERAND (target
, 0);
2299 switch (TREE_CODE (target
))
2303 x
= DECL_RTL (target
);
2307 x
= gen_rtx_MEM (FUNCTION_MODE
,
2308 gen_rtx_LABEL_REF (VOIDmode
,
2309 label_rtx (TREE_OPERAND (exp
, 0))));
2317 x
= TREE_CST_RTL (target
);
2324 if (GET_CODE (x
) != MEM
)
2329 value
->offset
= offset
;
2332 /* Uniquize all constants that appear in memory.
2333 Each constant in memory thus far output is recorded
2334 in `const_hash_table' with a `struct constant_descriptor'
2335 that contains a polish representation of the value of
2338 We cannot store the trees in the hash table
2339 because the trees may be temporary. */
2341 struct constant_descriptor
2343 struct constant_descriptor
*next
;
2349 #define MAX_HASH_TABLE 1009
2350 static struct constant_descriptor
*const_hash_table
[MAX_HASH_TABLE
];
2352 /* Mark a const_hash_table descriptor for GC. */
2355 mark_const_hash_entry (ptr
)
2358 struct constant_descriptor
*desc
= * (struct constant_descriptor
**) ptr
;
2362 ggc_mark_string (desc
->label
);
2367 /* Compute a hash code for a constant expression. */
2374 register int len
, hi
, i
;
2375 register enum tree_code code
= TREE_CODE (exp
);
2377 /* Either set P and LEN to the address and len of something to hash and
2378 exit the switch or return a value. */
2383 p
= (char *) &TREE_INT_CST_LOW (exp
);
2384 len
= 2 * sizeof TREE_INT_CST_LOW (exp
);
2388 p
= (char *) &TREE_REAL_CST (exp
);
2389 len
= sizeof TREE_REAL_CST (exp
);
2393 p
= TREE_STRING_POINTER (exp
);
2394 len
= TREE_STRING_LENGTH (exp
);
2398 return (const_hash (TREE_REALPART (exp
)) * 5
2399 + const_hash (TREE_IMAGPART (exp
)));
2402 if (TREE_CODE (TREE_TYPE (exp
)) == SET_TYPE
)
2404 len
= int_size_in_bytes (TREE_TYPE (exp
));
2405 p
= (char *) alloca (len
);
2406 get_set_constructor_bytes (exp
, (unsigned char *) p
, len
);
2413 /* For record type, include the type in the hashing.
2414 We do not do so for array types
2415 because (1) the sizes of the elements are sufficient
2416 and (2) distinct array types can have the same constructor.
2417 Instead, we include the array size because the constructor could
2419 if (TREE_CODE (TREE_TYPE (exp
)) == RECORD_TYPE
)
2420 hi
= ((unsigned long) TREE_TYPE (exp
) & ((1 << HASHBITS
) - 1))
2423 hi
= ((5 + int_size_in_bytes (TREE_TYPE (exp
)))
2424 & ((1 << HASHBITS
) - 1)) % MAX_HASH_TABLE
;
2426 for (link
= CONSTRUCTOR_ELTS (exp
); link
; link
= TREE_CHAIN (link
))
2427 if (TREE_VALUE (link
))
2429 = (hi
* 603 + const_hash (TREE_VALUE (link
))) % MAX_HASH_TABLE
;
2436 struct addr_const value
;
2438 decode_addr_const (exp
, &value
);
2439 if (GET_CODE (value
.base
) == SYMBOL_REF
)
2441 /* Don't hash the address of the SYMBOL_REF;
2442 only use the offset and the symbol name. */
2444 p
= XSTR (value
.base
, 0);
2445 for (i
= 0; p
[i
] != 0; i
++)
2446 hi
= ((hi
* 613) + (unsigned) (p
[i
]));
2448 else if (GET_CODE (value
.base
) == LABEL_REF
)
2449 hi
= value
.offset
+ CODE_LABEL_NUMBER (XEXP (value
.base
, 0)) * 13;
2453 hi
&= (1 << HASHBITS
) - 1;
2454 hi
%= MAX_HASH_TABLE
;
2460 return (const_hash (TREE_OPERAND (exp
, 0)) * 9
2461 + const_hash (TREE_OPERAND (exp
, 1)));
2465 case NON_LVALUE_EXPR
:
2466 return const_hash (TREE_OPERAND (exp
, 0)) * 7 + 2;
2472 /* Compute hashing function */
2474 for (i
= 0; i
< len
; i
++)
2475 hi
= ((hi
* 613) + (unsigned) (p
[i
]));
2477 hi
&= (1 << HASHBITS
) - 1;
2478 hi
%= MAX_HASH_TABLE
;
2482 /* Compare a constant expression EXP with a constant-descriptor DESC.
2483 Return 1 if DESC describes a constant with the same value as EXP. */
2486 compare_constant (exp
, desc
)
2488 struct constant_descriptor
*desc
;
2490 return 0 != compare_constant_1 (exp
, desc
->contents
);
2493 /* Compare constant expression EXP with a substring P of a constant descriptor.
2494 If they match, return a pointer to the end of the substring matched.
2495 If they do not match, return 0.
2497 Since descriptors are written in polish prefix notation,
2498 this function can be used recursively to test one operand of EXP
2499 against a subdescriptor, and if it succeeds it returns the
2500 address of the subdescriptor for the next operand. */
2503 compare_constant_1 (exp
, p
)
2507 register char *strp
;
2509 register enum tree_code code
= TREE_CODE (exp
);
2511 if (code
!= (enum tree_code
) *p
++)
2514 /* Either set STRP, P and LEN to pointers and length to compare and exit the
2515 switch, or return the result of the comparison. */
2520 /* Integer constants are the same only if the same width of type. */
2521 if (*p
++ != TYPE_PRECISION (TREE_TYPE (exp
)))
2524 strp
= (char *) &TREE_INT_CST_LOW (exp
);
2525 len
= 2 * sizeof TREE_INT_CST_LOW (exp
);
2529 /* Real constants are the same only if the same width of type. */
2530 if (*p
++ != TYPE_PRECISION (TREE_TYPE (exp
)))
2533 strp
= (char *) &TREE_REAL_CST (exp
);
2534 len
= sizeof TREE_REAL_CST (exp
);
2538 if (flag_writable_strings
)
2541 if (*p
++ != TYPE_MODE (TREE_TYPE (exp
)))
2544 strp
= TREE_STRING_POINTER (exp
);
2545 len
= TREE_STRING_LENGTH (exp
);
2546 if (bcmp ((char *) &TREE_STRING_LENGTH (exp
), p
,
2547 sizeof TREE_STRING_LENGTH (exp
)))
2550 p
+= sizeof TREE_STRING_LENGTH (exp
);
2554 p
= compare_constant_1 (TREE_REALPART (exp
), p
);
2558 return compare_constant_1 (TREE_IMAGPART (exp
), p
);
2561 if (TREE_CODE (TREE_TYPE (exp
)) == SET_TYPE
)
2563 int xlen
= len
= int_size_in_bytes (TREE_TYPE (exp
));
2565 strp
= (char *) alloca (len
);
2566 get_set_constructor_bytes (exp
, (unsigned char *) strp
, len
);
2567 if (bcmp ((char *) &xlen
, p
, sizeof xlen
))
2576 int length
= list_length (CONSTRUCTOR_ELTS (exp
));
2578 int have_purpose
= 0;
2580 for (link
= CONSTRUCTOR_ELTS (exp
); link
; link
= TREE_CHAIN (link
))
2581 if (TREE_PURPOSE (link
))
2584 if (bcmp ((char *) &length
, p
, sizeof length
))
2589 /* For record constructors, insist that the types match.
2590 For arrays, just verify both constructors are for arrays.
2591 Then insist that either both or none have any TREE_PURPOSE
2593 if (TREE_CODE (TREE_TYPE (exp
)) == RECORD_TYPE
)
2594 type
= TREE_TYPE (exp
);
2598 if (bcmp ((char *) &type
, p
, sizeof type
))
2603 if (bcmp ((char *) &have_purpose
, p
, sizeof have_purpose
))
2606 p
+= sizeof have_purpose
;
2608 /* For arrays, insist that the size in bytes match. */
2609 if (TREE_CODE (TREE_TYPE (exp
)) == ARRAY_TYPE
)
2611 HOST_WIDE_INT size
= int_size_in_bytes (TREE_TYPE (exp
));
2613 if (bcmp ((char *) &size
, p
, sizeof size
))
2619 for (link
= CONSTRUCTOR_ELTS (exp
); link
; link
= TREE_CHAIN (link
))
2621 if (TREE_VALUE (link
))
2623 if ((p
= compare_constant_1 (TREE_VALUE (link
), p
)) == 0)
2630 if (bcmp ((char *) &zero
, p
, sizeof zero
))
2636 if (TREE_PURPOSE (link
)
2637 && TREE_CODE (TREE_PURPOSE (link
)) == FIELD_DECL
)
2639 if (bcmp ((char *) &TREE_PURPOSE (link
), p
,
2640 sizeof TREE_PURPOSE (link
)))
2643 p
+= sizeof TREE_PURPOSE (link
);
2645 else if (TREE_PURPOSE (link
))
2647 if ((p
= compare_constant_1 (TREE_PURPOSE (link
), p
)) == 0)
2650 else if (have_purpose
)
2654 if (bcmp ((char *) &zero
, p
, sizeof zero
))
2666 struct addr_const value
;
2668 decode_addr_const (exp
, &value
);
2669 strp
= (char *) &value
.offset
;
2670 len
= sizeof value
.offset
;
2671 /* Compare the offset. */
2673 if (*p
++ != *strp
++)
2676 /* Compare symbol name. */
2677 strp
= XSTR (value
.base
, 0);
2678 len
= strlen (strp
) + 1;
2685 p
= compare_constant_1 (TREE_OPERAND (exp
, 0), p
);
2689 return compare_constant_1 (TREE_OPERAND (exp
, 1), p
);
2693 case NON_LVALUE_EXPR
:
2694 return compare_constant_1 (TREE_OPERAND (exp
, 0), p
);
2700 /* Compare constant contents. */
2702 if (*p
++ != *strp
++)
2708 /* Construct a constant descriptor for the expression EXP.
2709 It is up to the caller to enter the descriptor in the hash table. */
2711 static struct constant_descriptor
*
2712 record_constant (exp
)
2715 struct constant_descriptor
*next
= 0;
2718 /* Make a struct constant_descriptor. The first two pointers will
2719 be filled in later. Here we just leave space for them. */
2721 obstack_grow (&permanent_obstack
, (char *) &next
, sizeof next
);
2722 obstack_grow (&permanent_obstack
, (char *) &label
, sizeof label
);
2723 record_constant_1 (exp
);
2724 return (struct constant_descriptor
*) obstack_finish (&permanent_obstack
);
2727 /* Add a description of constant expression EXP
2728 to the object growing in `permanent_obstack'.
2729 No need to return its address; the caller will get that
2730 from the obstack when the object is complete. */
2733 record_constant_1 (exp
)
2736 register char *strp
;
2738 register enum tree_code code
= TREE_CODE (exp
);
2740 obstack_1grow (&permanent_obstack
, (unsigned int) code
);
2745 obstack_1grow (&permanent_obstack
, TYPE_PRECISION (TREE_TYPE (exp
)));
2746 strp
= (char *) &TREE_INT_CST_LOW (exp
);
2747 len
= 2 * sizeof TREE_INT_CST_LOW (exp
);
2751 obstack_1grow (&permanent_obstack
, TYPE_PRECISION (TREE_TYPE (exp
)));
2752 strp
= (char *) &TREE_REAL_CST (exp
);
2753 len
= sizeof TREE_REAL_CST (exp
);
2757 if (flag_writable_strings
)
2760 obstack_1grow (&permanent_obstack
, TYPE_MODE (TREE_TYPE (exp
)));
2761 strp
= TREE_STRING_POINTER (exp
);
2762 len
= TREE_STRING_LENGTH (exp
);
2763 obstack_grow (&permanent_obstack
, (char *) &TREE_STRING_LENGTH (exp
),
2764 sizeof TREE_STRING_LENGTH (exp
));
2768 record_constant_1 (TREE_REALPART (exp
));
2769 record_constant_1 (TREE_IMAGPART (exp
));
2773 if (TREE_CODE (TREE_TYPE (exp
)) == SET_TYPE
)
2775 int nbytes
= int_size_in_bytes (TREE_TYPE (exp
));
2776 obstack_grow (&permanent_obstack
, &nbytes
, sizeof (nbytes
));
2777 obstack_blank (&permanent_obstack
, nbytes
);
2778 get_set_constructor_bytes
2779 (exp
, (unsigned char *) permanent_obstack
.next_free
-nbytes
,
2786 int length
= list_length (CONSTRUCTOR_ELTS (exp
));
2788 int have_purpose
= 0;
2790 for (link
= CONSTRUCTOR_ELTS (exp
); link
; link
= TREE_CHAIN (link
))
2791 if (TREE_PURPOSE (link
))
2794 obstack_grow (&permanent_obstack
, (char *) &length
, sizeof length
);
2796 /* For record constructors, insist that the types match.
2797 For arrays, just verify both constructors are for arrays.
2798 Then insist that either both or none have any TREE_PURPOSE
2800 if (TREE_CODE (TREE_TYPE (exp
)) == RECORD_TYPE
)
2801 type
= TREE_TYPE (exp
);
2804 obstack_grow (&permanent_obstack
, (char *) &type
, sizeof type
);
2805 obstack_grow (&permanent_obstack
, (char *) &have_purpose
,
2806 sizeof have_purpose
);
2808 /* For arrays, insist that the size in bytes match. */
2809 if (TREE_CODE (TREE_TYPE (exp
)) == ARRAY_TYPE
)
2811 HOST_WIDE_INT size
= int_size_in_bytes (TREE_TYPE (exp
));
2812 obstack_grow (&permanent_obstack
, (char *) &size
, sizeof size
);
2815 for (link
= CONSTRUCTOR_ELTS (exp
); link
; link
= TREE_CHAIN (link
))
2817 if (TREE_VALUE (link
))
2818 record_constant_1 (TREE_VALUE (link
));
2823 obstack_grow (&permanent_obstack
,
2824 (char *) &zero
, sizeof zero
);
2827 if (TREE_PURPOSE (link
)
2828 && TREE_CODE (TREE_PURPOSE (link
)) == FIELD_DECL
)
2829 obstack_grow (&permanent_obstack
,
2830 (char *) &TREE_PURPOSE (link
),
2831 sizeof TREE_PURPOSE (link
));
2832 else if (TREE_PURPOSE (link
))
2833 record_constant_1 (TREE_PURPOSE (link
));
2834 else if (have_purpose
)
2838 obstack_grow (&permanent_obstack
,
2839 (char *) &zero
, sizeof zero
);
2847 struct addr_const value
;
2849 decode_addr_const (exp
, &value
);
2850 /* Record the offset. */
2851 obstack_grow (&permanent_obstack
,
2852 (char *) &value
.offset
, sizeof value
.offset
);
2853 /* Record the symbol name. */
2854 obstack_grow (&permanent_obstack
, XSTR (value
.base
, 0),
2855 strlen (XSTR (value
.base
, 0)) + 1);
2862 record_constant_1 (TREE_OPERAND (exp
, 0));
2863 record_constant_1 (TREE_OPERAND (exp
, 1));
2868 case NON_LVALUE_EXPR
:
2869 record_constant_1 (TREE_OPERAND (exp
, 0));
2876 /* Record constant contents. */
2877 obstack_grow (&permanent_obstack
, strp
, len
);
2880 /* Record a list of constant expressions that were passed to
2881 output_constant_def but that could not be output right away. */
2883 struct deferred_constant
2885 struct deferred_constant
*next
;
2891 static struct deferred_constant
*deferred_constants
;
2893 /* Another list of constants which should be output after the
2895 static struct deferred_constant
*after_function_constants
;
2897 /* Nonzero means defer output of addressed subconstants
2898 (i.e., those for which output_constant_def is called.) */
2899 static int defer_addressed_constants_flag
;
2901 /* Start deferring output of subconstants. */
2904 defer_addressed_constants ()
2906 defer_addressed_constants_flag
++;
2909 /* Stop deferring output of subconstants,
2910 and output now all those that have been deferred. */
2913 output_deferred_addressed_constants ()
2915 struct deferred_constant
*p
, *next
;
2917 defer_addressed_constants_flag
--;
2919 if (defer_addressed_constants_flag
> 0)
2922 for (p
= deferred_constants
; p
; p
= next
)
2924 output_constant_def_contents (p
->exp
, p
->reloc
, p
->labelno
);
2929 deferred_constants
= 0;
2932 /* Output any constants which should appear after a function. */
2935 output_after_function_constants ()
2937 struct deferred_constant
*p
, *next
;
2939 for (p
= after_function_constants
; p
; p
= next
)
2941 output_constant_def_contents (p
->exp
, p
->reloc
, p
->labelno
);
2946 after_function_constants
= 0;
2949 /* Make a copy of the whole tree structure for a constant.
2950 This handles the same types of nodes that compare_constant
2951 and record_constant handle. */
2957 switch (TREE_CODE (exp
))
2960 /* For ADDR_EXPR, we do not want to copy the decl whose address
2961 is requested. We do want to copy constants though. */
2962 if (TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp
, 0))) == 'c')
2963 return build1 (TREE_CODE (exp
), TREE_TYPE (exp
),
2964 copy_constant (TREE_OPERAND (exp
, 0)));
2966 return copy_node (exp
);
2971 return copy_node (exp
);
2974 return build_complex (TREE_TYPE (exp
),
2975 copy_constant (TREE_REALPART (exp
)),
2976 copy_constant (TREE_IMAGPART (exp
)));
2980 return build (TREE_CODE (exp
), TREE_TYPE (exp
),
2981 copy_constant (TREE_OPERAND (exp
, 0)),
2982 copy_constant (TREE_OPERAND (exp
, 1)));
2986 case NON_LVALUE_EXPR
:
2987 return build1 (TREE_CODE (exp
), TREE_TYPE (exp
),
2988 copy_constant (TREE_OPERAND (exp
, 0)));
2992 tree copy
= copy_node (exp
);
2993 tree list
= copy_list (CONSTRUCTOR_ELTS (exp
));
2996 CONSTRUCTOR_ELTS (copy
) = list
;
2997 for (tail
= list
; tail
; tail
= TREE_CHAIN (tail
))
2998 TREE_VALUE (tail
) = copy_constant (TREE_VALUE (tail
));
2999 if (TREE_CODE (TREE_TYPE (exp
)) == SET_TYPE
)
3000 for (tail
= list
; tail
; tail
= TREE_CHAIN (tail
))
3001 TREE_PURPOSE (tail
) = copy_constant (TREE_PURPOSE (tail
));
3011 /* Return an rtx representing a reference to constant data in memory
3012 for the constant expression EXP.
3014 If assembler code for such a constant has already been output,
3015 return an rtx to refer to it.
3016 Otherwise, output such a constant in memory (or defer it for later)
3017 and generate an rtx for it.
3019 The TREE_CST_RTL of EXP is set up to point to that rtx.
3020 The const_hash_table records which constants already have label strings. */
3023 output_constant_def (exp
)
3027 register struct constant_descriptor
*desc
;
3033 if (TREE_CST_RTL (exp
))
3034 return TREE_CST_RTL (exp
);
3036 /* Make sure any other constants whose addresses appear in EXP
3037 are assigned label numbers. */
3039 reloc
= output_addressed_constants (exp
);
3041 /* Compute hash code of EXP. Search the descriptors for that hash code
3042 to see if any of them describes EXP. If yes, the descriptor records
3043 the label number already assigned. */
3045 hash
= const_hash (exp
) % MAX_HASH_TABLE
;
3047 for (desc
= const_hash_table
[hash
]; desc
; desc
= desc
->next
)
3048 if (compare_constant (exp
, desc
))
3050 found
= desc
->label
;
3056 /* No constant equal to EXP is known to have been output.
3057 Make a constant descriptor to enter EXP in the hash table.
3058 Assign the label number and record it in the descriptor for
3059 future calls to this function to find. */
3061 /* Create a string containing the label name, in LABEL. */
3062 ASM_GENERATE_INTERNAL_LABEL (label
, "LC", const_labelno
);
3064 desc
= record_constant (exp
);
3065 desc
->next
= const_hash_table
[hash
];
3066 desc
->label
= ggc_alloc_string (label
, -1);
3067 const_hash_table
[hash
] = desc
;
3070 /* We have a symbol name; construct the SYMBOL_REF and the MEM. */
3072 push_obstacks_nochange ();
3073 if (TREE_PERMANENT (exp
))
3074 end_temporary_allocation ();
3076 def
= gen_rtx_SYMBOL_REF (Pmode
, desc
->label
);
3079 = gen_rtx_MEM (TYPE_MODE (TREE_TYPE (exp
)), def
);
3080 RTX_UNCHANGING_P (TREE_CST_RTL (exp
)) = 1;
3081 if (AGGREGATE_TYPE_P (TREE_TYPE (exp
)))
3082 MEM_SET_IN_STRUCT_P (TREE_CST_RTL (exp
), 1);
3086 /* Optionally set flags or add text to the name to record information
3087 such as that it is a function name. If the name is changed, the macro
3088 ASM_OUTPUT_LABELREF will have to know how to strip this information. */
3089 #ifdef ENCODE_SECTION_INFO
3090 ENCODE_SECTION_INFO (exp
);
3093 /* If this is the first time we've seen this particular constant,
3094 output it (or defer its output for later). */
3097 int after_function
= 0;
3099 #ifdef CONSTANT_AFTER_FUNCTION_P
3100 if (current_function_decl
!= 0
3101 && CONSTANT_AFTER_FUNCTION_P (exp
))
3105 if (defer_addressed_constants_flag
|| after_function
)
3107 struct deferred_constant
*p
;
3108 p
= (struct deferred_constant
*) xmalloc (sizeof (struct deferred_constant
));
3110 push_obstacks_nochange ();
3111 suspend_momentary ();
3112 p
->exp
= copy_constant (exp
);
3115 p
->labelno
= const_labelno
++;
3118 p
->next
= after_function_constants
;
3119 after_function_constants
= p
;
3123 p
->next
= deferred_constants
;
3124 deferred_constants
= p
;
3129 /* Do no output if -fsyntax-only. */
3130 if (! flag_syntax_only
)
3131 output_constant_def_contents (exp
, reloc
, const_labelno
);
3136 return TREE_CST_RTL (exp
);
3139 /* Now output assembler code to define the label for EXP,
3140 and follow it with the data of EXP. */
3143 output_constant_def_contents (exp
, reloc
, labelno
)
3150 if (IN_NAMED_SECTION (exp
))
3151 named_section (exp
, NULL
, reloc
);
3154 /* First switch to text section, except for writable strings. */
3155 #ifdef SELECT_SECTION
3156 SELECT_SECTION (exp
, reloc
);
3158 if (((TREE_CODE (exp
) == STRING_CST
) && flag_writable_strings
)
3159 || (flag_pic
&& reloc
))
3162 readonly_data_section ();
3166 /* Align the location counter as required by EXP's data type. */
3167 align
= TYPE_ALIGN (TREE_TYPE (exp
));
3168 #ifdef CONSTANT_ALIGNMENT
3169 align
= CONSTANT_ALIGNMENT (exp
, align
);
3172 if (align
> BITS_PER_UNIT
)
3173 ASM_OUTPUT_ALIGN (asm_out_file
, floor_log2 (align
/ BITS_PER_UNIT
));
3175 /* Output the label itself. */
3176 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, "LC", labelno
);
3178 /* Output the value of EXP. */
3179 output_constant (exp
,
3180 (TREE_CODE (exp
) == STRING_CST
3181 ? TREE_STRING_LENGTH (exp
)
3182 : int_size_in_bytes (TREE_TYPE (exp
))));
3186 /* Structure to represent sufficient information about a constant so that
3187 it can be output when the constant pool is output, so that function
3188 integration can be done, and to simplify handling on machines that reference
3189 constant pool as base+displacement. */
3191 struct pool_constant
3193 struct constant_descriptor
*desc
;
3194 struct pool_constant
*next
;
3195 enum machine_mode mode
;
3203 /* Structure used to maintain hash table mapping symbols used to their
3204 corresponding constants. */
3209 struct pool_constant
*pool
;
3210 struct pool_sym
*next
;
3213 /* Hash code for a SYMBOL_REF with CONSTANT_POOL_ADDRESS_P true.
3214 The argument is XSTR (... , 0) */
3216 #define SYMHASH(LABEL) \
3217 ((((unsigned long) (LABEL)) & ((1 << HASHBITS) - 1)) % MAX_RTX_HASH_TABLE)
3219 /* Initialize constant pool hashing for a new function. */
3222 init_varasm_status (f
)
3225 struct varasm_status
*p
;
3226 p
= (struct varasm_status
*) xmalloc (sizeof (struct varasm_status
));
3228 p
->x_const_rtx_hash_table
3229 = ((struct constant_descriptor
**)
3230 xmalloc (MAX_RTX_HASH_TABLE
* sizeof (struct constant_descriptor
*)));
3231 p
->x_const_rtx_sym_hash_table
3232 = ((struct pool_sym
**)
3233 xmalloc (MAX_RTX_HASH_TABLE
* sizeof (struct pool_sym
*)));
3234 bzero ((char *) p
->x_const_rtx_hash_table
,
3235 MAX_RTX_HASH_TABLE
* sizeof (struct constant_descriptor
*));
3236 bzero ((char *) p
->x_const_rtx_sym_hash_table
,
3237 MAX_RTX_HASH_TABLE
* sizeof (struct pool_sym
*));
3239 p
->x_first_pool
= p
->x_last_pool
= 0;
3240 p
->x_pool_offset
= 0;
3241 p
->x_const_double_chain
= 0;
3244 /* Mark PC for GC. */
3247 mark_pool_constant (pc
)
3248 struct pool_constant
*pc
;
3252 ggc_mark_rtx (pc
->constant
);
3257 /* Mark PPS for GC. */
3260 mark_pool_sym_hash_table (pps
)
3261 struct pool_sym
**pps
;
3263 struct pool_sym
*ps
;
3266 for (i
= 0; i
< MAX_RTX_HASH_TABLE
; ++i
)
3267 for (ps
= pps
[i
]; ps
; ps
= ps
->next
)
3268 ggc_mark_string (ps
->label
);
3271 /* Mark P for GC. */
3274 mark_varasm_status (p
)
3275 struct varasm_status
*p
;
3280 mark_pool_constant (p
->x_first_pool
);
3281 mark_pool_sym_hash_table (p
->x_const_rtx_sym_hash_table
);
3282 ggc_mark_rtx (p
->x_const_double_chain
);
3285 /* Clear out all parts of the state in F that can safely be discarded
3286 after the function has been compiled, to let garbage collection
3287 reclaim the memory. */
3290 free_varasm_status (f
)
3293 struct varasm_status
*p
;
3296 free (p
->x_const_rtx_hash_table
);
3297 free (p
->x_const_rtx_sym_hash_table
);
3302 enum kind
{ RTX_DOUBLE
, RTX_INT
};
3306 #ifdef ONLY_INT_FIELDS
3307 unsigned int kind
: 16;
3308 unsigned int mode
: 16;
3310 enum kind kind
: 16;
3311 enum machine_mode mode
: 16;
3314 union real_extract du
;
3315 struct addr_const addr
;
3316 struct {HOST_WIDE_INT high
, low
;} di
;
3320 /* Express an rtx for a constant integer (perhaps symbolic)
3321 as the sum of a symbol or label plus an explicit integer.
3322 They are stored into VALUE. */
3325 decode_rtx_const (mode
, x
, value
)
3326 enum machine_mode mode
;
3328 struct rtx_const
*value
;
3330 /* Clear the whole structure, including any gaps. */
3333 int *p
= (int *) value
;
3334 int *end
= (int *) (value
+ 1);
3339 value
->kind
= RTX_INT
; /* Most usual kind. */
3342 switch (GET_CODE (x
))
3345 value
->kind
= RTX_DOUBLE
;
3346 if (GET_MODE (x
) != VOIDmode
)
3348 value
->mode
= GET_MODE (x
);
3349 bcopy ((char *) &CONST_DOUBLE_LOW (x
),
3350 (char *) &value
->un
.du
, sizeof value
->un
.du
);
3354 value
->un
.di
.low
= CONST_DOUBLE_LOW (x
);
3355 value
->un
.di
.high
= CONST_DOUBLE_HIGH (x
);
3360 value
->un
.addr
.offset
= INTVAL (x
);
3366 value
->un
.addr
.base
= x
;
3371 if (GET_CODE (x
) == PLUS
)
3373 value
->un
.addr
.base
= XEXP (x
, 0);
3374 if (GET_CODE (XEXP (x
, 1)) != CONST_INT
)
3376 value
->un
.addr
.offset
= INTVAL (XEXP (x
, 1));
3378 else if (GET_CODE (x
) == MINUS
)
3380 value
->un
.addr
.base
= XEXP (x
, 0);
3381 if (GET_CODE (XEXP (x
, 1)) != CONST_INT
)
3383 value
->un
.addr
.offset
= - INTVAL (XEXP (x
, 1));
3393 if (value
->kind
== RTX_INT
&& value
->un
.addr
.base
!= 0)
3394 switch (GET_CODE (value
->un
.addr
.base
))
3398 /* Use the string's address, not the SYMBOL_REF's address,
3399 for the sake of addresses of library routines.
3400 For a LABEL_REF, compare labels. */
3401 value
->un
.addr
.base
= XEXP (value
->un
.addr
.base
, 0);
3408 /* Given a MINUS expression, simplify it if both sides
3409 include the same symbol. */
3412 simplify_subtraction (x
)
3415 struct rtx_const val0
, val1
;
3417 decode_rtx_const (GET_MODE (x
), XEXP (x
, 0), &val0
);
3418 decode_rtx_const (GET_MODE (x
), XEXP (x
, 1), &val1
);
3420 if (val0
.un
.addr
.base
== val1
.un
.addr
.base
)
3421 return GEN_INT (val0
.un
.addr
.offset
- val1
.un
.addr
.offset
);
3425 /* Compute a hash code for a constant RTL expression. */
3428 const_hash_rtx (mode
, x
)
3429 enum machine_mode mode
;
3435 struct rtx_const value
;
3436 decode_rtx_const (mode
, x
, &value
);
3438 /* Compute hashing function */
3440 for (i
= 0; i
< sizeof value
/ sizeof (int); i
++)
3441 hi
+= ((int *) &value
)[i
];
3443 hi
&= (1 << HASHBITS
) - 1;
3444 hi
%= MAX_RTX_HASH_TABLE
;
3448 /* Compare a constant rtl object X with a constant-descriptor DESC.
3449 Return 1 if DESC describes a constant with the same value as X. */
3452 compare_constant_rtx (mode
, x
, desc
)
3453 enum machine_mode mode
;
3455 struct constant_descriptor
*desc
;
3457 register int *p
= (int *) desc
->contents
;
3460 struct rtx_const value
;
3462 decode_rtx_const (mode
, x
, &value
);
3463 strp
= (int *) &value
;
3464 len
= sizeof value
/ sizeof (int);
3466 /* Compare constant contents. */
3468 if (*p
++ != *strp
++)
3474 /* Construct a constant descriptor for the rtl-expression X.
3475 It is up to the caller to enter the descriptor in the hash table. */
3477 static struct constant_descriptor
*
3478 record_constant_rtx (mode
, x
)
3479 enum machine_mode mode
;
3482 struct constant_descriptor
*ptr
;
3484 struct rtx_const value
;
3486 decode_rtx_const (mode
, x
, &value
);
3488 /* Put these things in the saveable obstack so we can ensure it won't
3489 be freed if we are called from combine or some other phase that discards
3490 memory allocated from function_obstack (current_obstack). */
3491 obstack_grow (saveable_obstack
, &ptr
, sizeof ptr
);
3492 obstack_grow (saveable_obstack
, &label
, sizeof label
);
3494 /* Record constant contents. */
3495 obstack_grow (saveable_obstack
, &value
, sizeof value
);
3497 return (struct constant_descriptor
*) obstack_finish (saveable_obstack
);
3500 /* Given a constant rtx X, make (or find) a memory constant for its value
3501 and return a MEM rtx to refer to it in memory. */
3504 force_const_mem (mode
, x
)
3505 enum machine_mode mode
;
3509 register struct constant_descriptor
*desc
;
3514 /* If we want this CONST_DOUBLE in the same mode as it is in memory
3515 (this will always be true for floating CONST_DOUBLEs that have been
3516 placed in memory, but not for VOIDmode (integer) CONST_DOUBLEs),
3517 use the previous copy. Otherwise, make a new one. Note that in
3518 the unlikely event that this same CONST_DOUBLE is used in two different
3519 modes in an alternating fashion, we will allocate a lot of different
3520 memory locations, but this should be extremely rare. */
3522 if (GET_CODE (x
) == CONST_DOUBLE
3523 && GET_CODE (CONST_DOUBLE_MEM (x
)) == MEM
3524 && GET_MODE (CONST_DOUBLE_MEM (x
)) == mode
)
3525 return CONST_DOUBLE_MEM (x
);
3527 /* Compute hash code of X. Search the descriptors for that hash code
3528 to see if any of them describes X. If yes, the descriptor records
3529 the label number already assigned. */
3531 hash
= const_hash_rtx (mode
, x
);
3533 for (desc
= const_rtx_hash_table
[hash
]; desc
; desc
= desc
->next
)
3534 if (compare_constant_rtx (mode
, x
, desc
))
3536 found
= desc
->label
;
3542 register struct pool_constant
*pool
;
3543 register struct pool_sym
*sym
;
3546 /* No constant equal to X is known to have been output.
3547 Make a constant descriptor to enter X in the hash table.
3548 Assign the label number and record it in the descriptor for
3549 future calls to this function to find. */
3551 desc
= record_constant_rtx (mode
, x
);
3552 desc
->next
= const_rtx_hash_table
[hash
];
3553 const_rtx_hash_table
[hash
] = desc
;
3555 /* Align the location counter as required by EXP's data type. */
3556 align
= (mode
== VOIDmode
) ? UNITS_PER_WORD
: GET_MODE_SIZE (mode
);
3557 if (align
> BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
)
3558 align
= BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
;
3559 #ifdef CONSTANT_ALIGNMENT
3560 align
= CONSTANT_ALIGNMENT (make_tree (type_for_mode (mode
, 0), x
),
3561 align
* BITS_PER_UNIT
) / BITS_PER_UNIT
;
3564 pool_offset
+= align
- 1;
3565 pool_offset
&= ~ (align
- 1);
3567 /* If RTL is not being placed into the saveable obstack, make a
3568 copy of X that is in the saveable obstack in case we are
3569 being called from combine or some other phase that discards
3570 memory it allocates. We used to only do this if it is a
3571 CONST; however, reload can allocate a CONST_INT when
3572 eliminating registers. */
3573 if (rtl_obstack
!= saveable_obstack
3574 && (GET_CODE (x
) == CONST
|| GET_CODE (x
) == CONST_INT
))
3576 push_obstacks_nochange ();
3577 rtl_in_saveable_obstack ();
3579 if (GET_CODE (x
) == CONST
)
3580 x
= gen_rtx_CONST (GET_MODE (x
),
3581 gen_rtx_PLUS (GET_MODE (x
),
3582 XEXP (XEXP (x
, 0), 0),
3583 XEXP (XEXP (x
, 0), 1)));
3585 x
= GEN_INT (INTVAL (x
));
3590 /* Allocate a pool constant descriptor, fill it in, and chain it in. */
3592 pool
= (struct pool_constant
*) savealloc (sizeof (struct pool_constant
));
3596 pool
->labelno
= const_labelno
;
3597 pool
->align
= align
;
3598 pool
->offset
= pool_offset
;
3605 last_pool
->next
= pool
;
3608 pool_offset
+= GET_MODE_SIZE (mode
);
3610 /* Create a string containing the label name, in LABEL. */
3611 ASM_GENERATE_INTERNAL_LABEL (label
, "LC", const_labelno
);
3615 desc
->label
= found
= ggc_alloc_string (label
, -1);
3617 /* Add label to symbol hash table. */
3618 hash
= SYMHASH (found
);
3619 sym
= (struct pool_sym
*) savealloc (sizeof (struct pool_sym
));
3622 sym
->next
= const_rtx_sym_hash_table
[hash
];
3623 const_rtx_sym_hash_table
[hash
] = sym
;
3626 /* We have a symbol name; construct the SYMBOL_REF and the MEM. */
3628 def
= gen_rtx_MEM (mode
, gen_rtx_SYMBOL_REF (Pmode
, found
));
3630 RTX_UNCHANGING_P (def
) = 1;
3631 /* Mark the symbol_ref as belonging to this constants pool. */
3632 CONSTANT_POOL_ADDRESS_P (XEXP (def
, 0)) = 1;
3633 current_function_uses_const_pool
= 1;
3635 if (GET_CODE (x
) == CONST_DOUBLE
)
3637 if (CONST_DOUBLE_MEM (x
) == cc0_rtx
)
3639 CONST_DOUBLE_CHAIN (x
) = const_double_chain
;
3640 const_double_chain
= x
;
3642 CONST_DOUBLE_MEM (x
) = def
;
3648 /* Given a SYMBOL_REF with CONSTANT_POOL_ADDRESS_P true, return a pointer to
3649 the corresponding pool_constant structure. */
3651 static struct pool_constant
*
3652 find_pool_constant (f
, addr
)
3656 struct pool_sym
*sym
;
3657 char *label
= XSTR (addr
, 0);
3659 for (sym
= f
->varasm
->x_const_rtx_sym_hash_table
[SYMHASH (label
)]; sym
; sym
= sym
->next
)
3660 if (sym
->label
== label
)
3666 /* Given a constant pool SYMBOL_REF, return the corresponding constant. */
3669 get_pool_constant (addr
)
3672 return (find_pool_constant (current_function
, addr
))->constant
;
3675 /* Likewise, but for the constant pool of a specific function. */
3678 get_pool_constant_for_function (f
, addr
)
3682 return (find_pool_constant (f
, addr
))->constant
;
3685 /* Similar, return the mode. */
3688 get_pool_mode (addr
)
3691 return (find_pool_constant (current_function
, addr
))->mode
;
3695 get_pool_mode_for_function (f
, addr
)
3699 return (find_pool_constant (f
, addr
))->mode
;
3702 /* Similar, return the offset in the constant pool. */
3705 get_pool_offset (addr
)
3708 return (find_pool_constant (current_function
, addr
))->offset
;
3711 /* Return the size of the constant pool. */
3719 /* Write all the constants in the constant pool. */
3722 output_constant_pool (fnname
, fndecl
)
3723 char *fnname ATTRIBUTE_UNUSED
;
3724 tree fndecl ATTRIBUTE_UNUSED
;
3726 struct pool_constant
*pool
;
3728 union real_extract u
;
3730 /* It is possible for gcc to call force_const_mem and then to later
3731 discard the instructions which refer to the constant. In such a
3732 case we do not need to output the constant. */
3733 mark_constant_pool ();
3735 #ifdef ASM_OUTPUT_POOL_PROLOGUE
3736 ASM_OUTPUT_POOL_PROLOGUE (asm_out_file
, fnname
, fndecl
, pool_offset
);
3739 for (pool
= first_pool
; pool
; pool
= pool
->next
)
3746 /* See if X is a LABEL_REF (or a CONST referring to a LABEL_REF)
3747 whose CODE_LABEL has been deleted. This can occur if a jump table
3748 is eliminated by optimization. If so, write a constant of zero
3749 instead. Note that this can also happen by turning the
3750 CODE_LABEL into a NOTE. */
3751 if (((GET_CODE (x
) == LABEL_REF
3752 && (INSN_DELETED_P (XEXP (x
, 0))
3753 || GET_CODE (XEXP (x
, 0)) == NOTE
)))
3754 || (GET_CODE (x
) == CONST
&& GET_CODE (XEXP (x
, 0)) == PLUS
3755 && GET_CODE (XEXP (XEXP (x
, 0), 0)) == LABEL_REF
3756 && (INSN_DELETED_P (XEXP (XEXP (XEXP (x
, 0), 0), 0))
3757 || GET_CODE (XEXP (XEXP (XEXP (x
, 0), 0), 0)) == NOTE
)))
3760 /* First switch to correct section. */
3761 #ifdef SELECT_RTX_SECTION
3762 SELECT_RTX_SECTION (pool
->mode
, x
);
3764 readonly_data_section ();
3767 #ifdef ASM_OUTPUT_SPECIAL_POOL_ENTRY
3768 ASM_OUTPUT_SPECIAL_POOL_ENTRY (asm_out_file
, x
, pool
->mode
,
3769 pool
->align
, pool
->labelno
, done
);
3772 if (pool
->align
> 1)
3773 ASM_OUTPUT_ALIGN (asm_out_file
, floor_log2 (pool
->align
));
3775 /* Output the label. */
3776 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, "LC", pool
->labelno
);
3778 /* Output the value of the constant itself. */
3779 switch (GET_MODE_CLASS (pool
->mode
))
3782 if (GET_CODE (x
) != CONST_DOUBLE
)
3785 bcopy ((char *) &CONST_DOUBLE_LOW (x
), (char *) &u
, sizeof u
);
3786 assemble_real (u
.d
, pool
->mode
);
3790 case MODE_PARTIAL_INT
:
3791 assemble_integer (x
, GET_MODE_SIZE (pool
->mode
), 1);
3798 #ifdef ASM_OUTPUT_SPECIAL_POOL_ENTRY
3804 #ifdef ASM_OUTPUT_POOL_EPILOGUE
3805 ASM_OUTPUT_POOL_EPILOGUE (asm_out_file
, fnname
, fndecl
, pool_offset
);
3808 /* Done with this pool. */
3809 first_pool
= last_pool
= 0;
3812 /* Look through the instructions for this function, and mark all the
3813 entries in the constant pool which are actually being used. */
3816 mark_constant_pool ()
3819 struct pool_constant
*pool
;
3821 if (first_pool
== 0)
3824 for (pool
= first_pool
; pool
; pool
= pool
->next
)
3827 for (insn
= get_insns (); insn
; insn
= NEXT_INSN (insn
))
3828 if (GET_RTX_CLASS (GET_CODE (insn
)) == 'i')
3829 mark_constants (PATTERN (insn
));
3831 for (insn
= current_function_epilogue_delay_list
;
3833 insn
= XEXP (insn
, 1))
3834 if (GET_RTX_CLASS (GET_CODE (insn
)) == 'i')
3835 mark_constants (PATTERN (insn
));
3837 /* It's possible that the only reference to a symbol is in a symbol
3838 that's in the constant pool. This happens in Fortran under some
3839 situations. (When the constant contains the address of another
3840 constant, and only the first is used directly in an insn.)
3841 This is potentially suboptimal if there's ever a possibility of
3842 backwards (in pool order) 2'd level references. However, it's
3843 not clear that 2'd level references can happen. */
3844 for (pool
= first_pool
; pool
; pool
= pool
->next
)
3846 struct pool_sym
*sym
;
3849 /* skip unmarked entries; no insn refers to them. */
3853 /* Skip everything except SYMBOL_REFs. */
3854 if (GET_CODE (pool
->constant
) != SYMBOL_REF
)
3856 label
= XSTR (pool
->constant
, 0);
3858 /* Be sure the symbol's value is marked. */
3859 for (sym
= const_rtx_sym_hash_table
[SYMHASH (label
)]; sym
;
3861 if (sym
->label
== label
)
3862 sym
->pool
->mark
= 1;
3863 /* If we didn't find it, there's something truly wrong here, but it
3864 will be announced by the assembler. */
3873 register const char *format_ptr
;
3878 if (GET_CODE (x
) == SYMBOL_REF
)
3880 if (CONSTANT_POOL_ADDRESS_P (x
))
3881 find_pool_constant (current_function
, x
)->mark
= 1;
3884 /* Never search inside a CONST_DOUBLE, because CONST_DOUBLE_MEM may be
3885 a MEM, but does not constitute a use of that MEM. */
3886 else if (GET_CODE (x
) == CONST_DOUBLE
)
3889 /* Insns may appear inside a SEQUENCE. Only check the patterns of
3890 insns, not any notes that may be attached. We don't want to mark
3891 a constant just because it happens to appear in a REG_EQUIV note. */
3892 if (GET_RTX_CLASS (GET_CODE (x
)) == 'i')
3894 mark_constants (PATTERN (x
));
3898 format_ptr
= GET_RTX_FORMAT (GET_CODE (x
));
3900 for (i
= 0; i
< GET_RTX_LENGTH (GET_CODE (x
)); i
++)
3902 switch (*format_ptr
++)
3905 mark_constants (XEXP (x
, i
));
3909 if (XVEC (x
, i
) != 0)
3913 for (j
= 0; j
< XVECLEN (x
, i
); j
++)
3914 mark_constants (XVECEXP (x
, i
, j
));
3933 /* Find all the constants whose addresses are referenced inside of EXP,
3934 and make sure assembler code with a label has been output for each one.
3935 Indicate whether an ADDR_EXPR has been encountered. */
3938 output_addressed_constants (exp
)
3943 switch (TREE_CODE (exp
))
3947 register tree constant
= TREE_OPERAND (exp
, 0);
3949 while (TREE_CODE (constant
) == COMPONENT_REF
)
3951 constant
= TREE_OPERAND (constant
, 0);
3954 if (TREE_CODE_CLASS (TREE_CODE (constant
)) == 'c'
3955 || TREE_CODE (constant
) == CONSTRUCTOR
)
3956 /* No need to do anything here
3957 for addresses of variables or functions. */
3958 output_constant_def (constant
);
3965 reloc
= output_addressed_constants (TREE_OPERAND (exp
, 0));
3966 reloc
|= output_addressed_constants (TREE_OPERAND (exp
, 1));
3971 case NON_LVALUE_EXPR
:
3972 reloc
= output_addressed_constants (TREE_OPERAND (exp
, 0));
3978 for (link
= CONSTRUCTOR_ELTS (exp
); link
; link
= TREE_CHAIN (link
))
3979 if (TREE_VALUE (link
) != 0)
3980 reloc
|= output_addressed_constants (TREE_VALUE (link
));
3990 /* Output assembler code for constant EXP to FILE, with no label.
3991 This includes the pseudo-op such as ".int" or ".byte", and a newline.
3992 Assumes output_addressed_constants has been done on EXP already.
3994 Generate exactly SIZE bytes of assembler data, padding at the end
3995 with zeros if necessary. SIZE must always be specified.
3997 SIZE is important for structure constructors,
3998 since trailing members may have been omitted from the constructor.
3999 It is also important for initialization of arrays from string constants
4000 since the full length of the string constant might not be wanted.
4001 It is also needed for initialization of unions, where the initializer's
4002 type is just one member, and that may not be as long as the union.
4004 There a case in which we would fail to output exactly SIZE bytes:
4005 for a structure constructor that wants to produce more than SIZE bytes.
4006 But such constructors will never be generated for any possible input. */
4009 output_constant (exp
, size
)
4013 register enum tree_code code
= TREE_CODE (TREE_TYPE (exp
));
4015 /* Some front-ends use constants other than the standard
4016 language-indepdent varieties, but which may still be output
4017 directly. Give the front-end a chance to convert EXP to a
4018 language-independent representation. */
4019 if (lang_expand_constant
)
4020 exp
= (*lang_expand_constant
) (exp
);
4022 if (size
== 0 || flag_syntax_only
)
4025 /* Eliminate the NON_LVALUE_EXPR_EXPR that makes a cast not be an lvalue.
4026 That way we get the constant (we hope) inside it. Also, strip off any
4027 NOP_EXPR that converts between two record, union, array, or set types. */
4028 while ((TREE_CODE (exp
) == NOP_EXPR
4029 && (TREE_TYPE (exp
) == TREE_TYPE (TREE_OPERAND (exp
, 0))
4030 || AGGREGATE_TYPE_P (TREE_TYPE (exp
))))
4031 || TREE_CODE (exp
) == NON_LVALUE_EXPR
)
4032 exp
= TREE_OPERAND (exp
, 0);
4034 /* Allow a constructor with no elements for any data type.
4035 This means to fill the space with zeros. */
4036 if (TREE_CODE (exp
) == CONSTRUCTOR
&& CONSTRUCTOR_ELTS (exp
) == 0)
4038 assemble_zeros (size
);
4049 case REFERENCE_TYPE
:
4050 /* ??? What about (int)((float)(int)&foo + 4) */
4051 while (TREE_CODE (exp
) == NOP_EXPR
|| TREE_CODE (exp
) == CONVERT_EXPR
4052 || TREE_CODE (exp
) == NON_LVALUE_EXPR
)
4053 exp
= TREE_OPERAND (exp
, 0);
4055 if (! assemble_integer (expand_expr (exp
, NULL_RTX
, VOIDmode
,
4056 EXPAND_INITIALIZER
),
4058 error ("initializer for integer value is too complicated");
4063 if (TREE_CODE (exp
) != REAL_CST
)
4064 error ("initializer for floating value is not a floating constant");
4066 assemble_real (TREE_REAL_CST (exp
),
4067 mode_for_size (size
* BITS_PER_UNIT
, MODE_FLOAT
, 0));
4072 output_constant (TREE_REALPART (exp
), size
/ 2);
4073 output_constant (TREE_IMAGPART (exp
), size
/ 2);
4074 size
-= (size
/ 2) * 2;
4078 if (TREE_CODE (exp
) == CONSTRUCTOR
)
4080 output_constructor (exp
, size
);
4083 else if (TREE_CODE (exp
) == STRING_CST
)
4087 if (size
> TREE_STRING_LENGTH (exp
))
4089 excess
= size
- TREE_STRING_LENGTH (exp
);
4090 size
= TREE_STRING_LENGTH (exp
);
4093 assemble_string (TREE_STRING_POINTER (exp
), size
);
4102 if (TREE_CODE (exp
) == CONSTRUCTOR
)
4103 output_constructor (exp
, size
);
4109 if (TREE_CODE (exp
) == INTEGER_CST
)
4110 assemble_integer (expand_expr (exp
, NULL_RTX
,
4111 VOIDmode
, EXPAND_INITIALIZER
),
4113 else if (TREE_CODE (exp
) == CONSTRUCTOR
)
4115 unsigned char *buffer
= (unsigned char *) alloca (size
);
4116 if (get_set_constructor_bytes (exp
, buffer
, size
))
4118 assemble_string ((char *) buffer
, size
);
4121 error ("unknown set constructor type");
4129 assemble_zeros (size
);
4133 /* Subroutine of output_constant, used for CONSTRUCTORs
4134 (aggregate constants).
4135 Generate at least SIZE bytes, padding if necessary. */
4138 output_constructor (exp
, size
)
4142 register tree link
, field
= 0;
4143 HOST_WIDE_INT min_index
= 0;
4144 /* Number of bytes output or skipped so far.
4145 In other words, current position within the constructor. */
4146 int total_bytes
= 0;
4147 /* Non-zero means BYTE contains part of a byte, to be output. */
4148 int byte_buffer_in_use
= 0;
4151 if (HOST_BITS_PER_WIDE_INT
< BITS_PER_UNIT
)
4154 if (TREE_CODE (TREE_TYPE (exp
)) == RECORD_TYPE
)
4155 field
= TYPE_FIELDS (TREE_TYPE (exp
));
4157 if (TREE_CODE (TREE_TYPE (exp
)) == ARRAY_TYPE
4158 && TYPE_DOMAIN (TREE_TYPE (exp
)) != 0)
4160 = TREE_INT_CST_LOW (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (exp
))));
4162 /* As LINK goes through the elements of the constant,
4163 FIELD goes through the structure fields, if the constant is a structure.
4164 if the constant is a union, then we override this,
4165 by getting the field from the TREE_LIST element.
4166 But the constant could also be an array. Then FIELD is zero.
4168 There is always a maximum of one element in the chain LINK for unions
4169 (even if the initializer in a source program incorrectly contains
4171 for (link
= CONSTRUCTOR_ELTS (exp
);
4173 link
= TREE_CHAIN (link
),
4174 field
= field
? TREE_CHAIN (field
) : 0)
4176 tree val
= TREE_VALUE (link
);
4179 /* the element in a union constructor specifies the proper field. */
4181 if (TREE_CODE (TREE_TYPE (exp
)) == RECORD_TYPE
4182 || TREE_CODE (TREE_TYPE (exp
)) == UNION_TYPE
)
4184 /* if available, use the type given by link */
4185 if (TREE_PURPOSE (link
) != 0)
4186 field
= TREE_PURPOSE (link
);
4189 if (TREE_CODE (TREE_TYPE (exp
)) == ARRAY_TYPE
)
4190 index
= TREE_PURPOSE (link
);
4192 /* Eliminate the marker that makes a cast not be an lvalue. */
4196 if (index
&& TREE_CODE (index
) == RANGE_EXPR
)
4198 register int fieldsize
4199 = int_size_in_bytes (TREE_TYPE (TREE_TYPE (exp
)));
4200 HOST_WIDE_INT lo_index
= TREE_INT_CST_LOW (TREE_OPERAND (index
, 0));
4201 HOST_WIDE_INT hi_index
= TREE_INT_CST_LOW (TREE_OPERAND (index
, 1));
4202 HOST_WIDE_INT index
;
4203 for (index
= lo_index
; index
<= hi_index
; index
++)
4205 /* Output the element's initial value. */
4207 assemble_zeros (fieldsize
);
4209 output_constant (val
, fieldsize
);
4211 /* Count its size. */
4212 total_bytes
+= fieldsize
;
4215 else if (field
== 0 || !DECL_BIT_FIELD (field
))
4217 /* An element that is not a bit-field. */
4219 register int fieldsize
;
4220 /* Since this structure is static,
4221 we know the positions are constant. */
4222 int bitpos
= (field
? (TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field
))
4226 bitpos
= (TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (val
)))
4228 * (TREE_INT_CST_LOW (index
) - min_index
));
4230 /* Output any buffered-up bit-fields preceding this element. */
4231 if (byte_buffer_in_use
)
4233 ASM_OUTPUT_BYTE (asm_out_file
, byte
);
4235 byte_buffer_in_use
= 0;
4238 /* Advance to offset of this element.
4239 Note no alignment needed in an array, since that is guaranteed
4240 if each element has the proper size. */
4241 if ((field
!= 0 || index
!= 0) && bitpos
!= total_bytes
)
4243 assemble_zeros (bitpos
- total_bytes
);
4244 total_bytes
= bitpos
;
4247 /* Determine size this element should occupy. */
4250 if (TREE_CODE (DECL_SIZE (field
)) != INTEGER_CST
)
4252 if (TREE_INT_CST_LOW (DECL_SIZE (field
)) > 100000)
4254 /* This avoids overflow trouble. */
4255 tree size_tree
= size_binop (CEIL_DIV_EXPR
,
4257 size_int (BITS_PER_UNIT
));
4258 fieldsize
= TREE_INT_CST_LOW (size_tree
);
4262 fieldsize
= TREE_INT_CST_LOW (DECL_SIZE (field
));
4263 fieldsize
= (fieldsize
+ BITS_PER_UNIT
- 1) / BITS_PER_UNIT
;
4267 fieldsize
= int_size_in_bytes (TREE_TYPE (TREE_TYPE (exp
)));
4269 /* Output the element's initial value. */
4271 assemble_zeros (fieldsize
);
4273 output_constant (val
, fieldsize
);
4275 /* Count its size. */
4276 total_bytes
+= fieldsize
;
4278 else if (val
!= 0 && TREE_CODE (val
) != INTEGER_CST
)
4279 error ("invalid initial value for member `%s'",
4280 IDENTIFIER_POINTER (DECL_NAME (field
)));
4283 /* Element that is a bit-field. */
4285 int next_offset
= TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field
));
4287 = (next_offset
+ TREE_INT_CST_LOW (DECL_SIZE (field
)));
4290 val
= integer_zero_node
;
4292 /* If this field does not start in this (or, next) byte,
4294 if (next_offset
/ BITS_PER_UNIT
!= total_bytes
)
4296 /* Output remnant of any bit field in previous bytes. */
4297 if (byte_buffer_in_use
)
4299 ASM_OUTPUT_BYTE (asm_out_file
, byte
);
4301 byte_buffer_in_use
= 0;
4304 /* If still not at proper byte, advance to there. */
4305 if (next_offset
/ BITS_PER_UNIT
!= total_bytes
)
4307 assemble_zeros (next_offset
/ BITS_PER_UNIT
- total_bytes
);
4308 total_bytes
= next_offset
/ BITS_PER_UNIT
;
4312 if (! byte_buffer_in_use
)
4315 /* We must split the element into pieces that fall within
4316 separate bytes, and combine each byte with previous or
4317 following bit-fields. */
4319 /* next_offset is the offset n fbits from the beginning of
4320 the structure to the next bit of this element to be processed.
4321 end_offset is the offset of the first bit past the end of
4323 while (next_offset
< end_offset
)
4327 HOST_WIDE_INT value
;
4328 int next_byte
= next_offset
/ BITS_PER_UNIT
;
4329 int next_bit
= next_offset
% BITS_PER_UNIT
;
4331 /* Advance from byte to byte
4332 within this element when necessary. */
4333 while (next_byte
!= total_bytes
)
4335 ASM_OUTPUT_BYTE (asm_out_file
, byte
);
4340 /* Number of bits we can process at once
4341 (all part of the same byte). */
4342 this_time
= MIN (end_offset
- next_offset
,
4343 BITS_PER_UNIT
- next_bit
);
4344 if (BYTES_BIG_ENDIAN
)
4346 /* On big-endian machine, take the most significant bits
4347 first (of the bits that are significant)
4348 and put them into bytes from the most significant end. */
4349 shift
= end_offset
- next_offset
- this_time
;
4350 /* Don't try to take a bunch of bits that cross
4351 the word boundary in the INTEGER_CST. */
4352 if (shift
< HOST_BITS_PER_WIDE_INT
4353 && shift
+ this_time
> HOST_BITS_PER_WIDE_INT
)
4355 this_time
-= (HOST_BITS_PER_WIDE_INT
- shift
);
4356 shift
= HOST_BITS_PER_WIDE_INT
;
4359 /* Now get the bits from the appropriate constant word. */
4360 if (shift
< HOST_BITS_PER_WIDE_INT
)
4362 value
= TREE_INT_CST_LOW (val
);
4364 else if (shift
< 2 * HOST_BITS_PER_WIDE_INT
)
4366 value
= TREE_INT_CST_HIGH (val
);
4367 shift
-= HOST_BITS_PER_WIDE_INT
;
4371 byte
|= (((value
>> shift
)
4372 & (((HOST_WIDE_INT
) 1 << this_time
) - 1))
4373 << (BITS_PER_UNIT
- this_time
- next_bit
));
4377 /* On little-endian machines,
4378 take first the least significant bits of the value
4379 and pack them starting at the least significant
4380 bits of the bytes. */
4381 shift
= (next_offset
4382 - TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field
)));
4383 /* Don't try to take a bunch of bits that cross
4384 the word boundary in the INTEGER_CST. */
4385 if (shift
< HOST_BITS_PER_WIDE_INT
4386 && shift
+ this_time
> HOST_BITS_PER_WIDE_INT
)
4388 this_time
-= (HOST_BITS_PER_WIDE_INT
- shift
);
4389 shift
= HOST_BITS_PER_WIDE_INT
;
4392 /* Now get the bits from the appropriate constant word. */
4393 if (shift
< HOST_BITS_PER_WIDE_INT
)
4394 value
= TREE_INT_CST_LOW (val
);
4395 else if (shift
< 2 * HOST_BITS_PER_WIDE_INT
)
4397 value
= TREE_INT_CST_HIGH (val
);
4398 shift
-= HOST_BITS_PER_WIDE_INT
;
4402 byte
|= (((value
>> shift
)
4403 & (((HOST_WIDE_INT
) 1 << this_time
) - 1))
4406 next_offset
+= this_time
;
4407 byte_buffer_in_use
= 1;
4411 if (byte_buffer_in_use
)
4413 ASM_OUTPUT_BYTE (asm_out_file
, byte
);
4416 if (total_bytes
< size
)
4417 assemble_zeros (size
- total_bytes
);
4420 #ifdef HANDLE_PRAGMA_WEAK
4421 /* Add function NAME to the weak symbols list. VALUE is a weak alias
4422 associatd with NAME. */
4425 add_weak (name
, value
)
4429 struct weak_syms
*weak
;
4431 weak
= (struct weak_syms
*) permalloc (sizeof (struct weak_syms
));
4436 weak
->next
= weak_decls
;
4438 weak
->value
= value
;
4443 #endif /* HANDLE_PRAGMA_WEAK */
4445 /* Declare DECL to be a weak symbol. */
4451 if (! TREE_PUBLIC (decl
))
4452 error_with_decl (decl
, "weak declaration of `%s' must be public");
4453 else if (TREE_ASM_WRITTEN (decl
))
4454 error_with_decl (decl
, "weak declaration of `%s' must precede definition");
4455 else if (SUPPORTS_WEAK
)
4456 DECL_WEAK (decl
) = 1;
4457 #ifdef HANDLE_PRAGMA_WEAK
4458 add_weak (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)), NULL
);
4462 /* Emit any pending weak declarations. */
4464 #ifdef HANDLE_PRAGMA_WEAK
4465 struct weak_syms
* weak_decls
;
4471 #ifdef HANDLE_PRAGMA_WEAK
4472 if (HANDLE_PRAGMA_WEAK
)
4474 struct weak_syms
*t
;
4475 for (t
= weak_decls
; t
; t
= t
->next
)
4479 ASM_WEAKEN_LABEL (asm_out_file
, t
->name
);
4481 ASM_OUTPUT_DEF (asm_out_file
, t
->name
, t
->value
);
4488 /* Remove NAME from the pending list of weak symbols. This prevents
4489 the compiler from emitting multiple .weak directives which confuses
4491 #ifdef ASM_WEAKEN_LABEL
4493 remove_from_pending_weak_list (name
)
4494 char *name ATTRIBUTE_UNUSED
;
4496 #ifdef HANDLE_PRAGMA_WEAK
4497 if (HANDLE_PRAGMA_WEAK
)
4499 struct weak_syms
*t
;
4500 for (t
= weak_decls
; t
; t
= t
->next
)
4502 if (t
->name
&& strcmp (name
, t
->name
) == 0)
4511 assemble_alias (decl
, target
)
4512 tree decl
, target ATTRIBUTE_UNUSED
;
4516 make_decl_rtl (decl
, (char *) 0, 1);
4517 name
= XSTR (XEXP (DECL_RTL (decl
), 0), 0);
4519 #ifdef ASM_OUTPUT_DEF
4520 /* Make name accessible from other files, if appropriate. */
4522 if (TREE_PUBLIC (decl
))
4524 #ifdef ASM_WEAKEN_LABEL
4525 if (DECL_WEAK (decl
))
4527 ASM_WEAKEN_LABEL (asm_out_file
, name
);
4528 /* Remove this function from the pending weak list so that
4529 we do not emit multiple .weak directives for it. */
4530 remove_from_pending_weak_list
4531 (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)));
4535 ASM_GLOBALIZE_LABEL (asm_out_file
, name
);
4538 #ifdef ASM_OUTPUT_DEF_FROM_DECLS
4539 ASM_OUTPUT_DEF_FROM_DECLS (asm_out_file
, decl
, target
);
4541 ASM_OUTPUT_DEF (asm_out_file
, name
, IDENTIFIER_POINTER (target
));
4543 TREE_ASM_WRITTEN (decl
) = 1;
4545 #ifdef ASM_OUTPUT_WEAK_ALIAS
4546 if (! DECL_WEAK (decl
))
4547 warning ("only weak aliases are supported in this configuration");
4549 ASM_OUTPUT_WEAK_ALIAS (asm_out_file
, name
, IDENTIFIER_POINTER (target
));
4550 TREE_ASM_WRITTEN (decl
) = 1;
4552 warning ("alias definitions not supported in this configuration; ignored");
4557 /* This determines whether or not we support link-once semantics. */
4558 #ifndef SUPPORTS_ONE_ONLY
4559 #ifdef MAKE_DECL_ONE_ONLY
4560 #define SUPPORTS_ONE_ONLY 1
4562 #define SUPPORTS_ONE_ONLY 0
4566 /* Returns 1 if the target configuration supports defining public symbols
4567 so that one of them will be chosen at link time instead of generating a
4568 multiply-defined symbol error, whether through the use of weak symbols or
4569 a target-specific mechanism for having duplicates discarded. */
4572 supports_one_only ()
4574 if (SUPPORTS_ONE_ONLY
)
4576 return SUPPORTS_WEAK
;
4579 /* Set up DECL as a public symbol that can be defined in multiple
4580 translation units without generating a linker error. */
4583 make_decl_one_only (decl
)
4586 if (TREE_CODE (decl
) != VAR_DECL
&& TREE_CODE (decl
) != FUNCTION_DECL
)
4589 TREE_PUBLIC (decl
) = 1;
4591 if (TREE_CODE (decl
) == VAR_DECL
4592 && (DECL_INITIAL (decl
) == 0 || DECL_INITIAL (decl
) == error_mark_node
))
4593 DECL_COMMON (decl
) = 1;
4594 else if (SUPPORTS_ONE_ONLY
)
4596 #ifdef MAKE_DECL_ONE_ONLY
4597 MAKE_DECL_ONE_ONLY (decl
);
4599 DECL_ONE_ONLY (decl
) = 1;
4601 else if (SUPPORTS_WEAK
)
4602 DECL_WEAK (decl
) = 1;
4610 ggc_add_root (const_hash_table
, MAX_HASH_TABLE
, sizeof(const_hash_table
[0]),
4611 mark_const_hash_entry
);
4612 ggc_add_string_root (&in_named_name
, 1);