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 *));
194 static void asm_emit_uninitialised
PROTO((tree
, char *, int, int));
196 static enum in_section
{ no_section
, in_text
, in_data
, in_named
197 #ifdef BSS_SECTION_ASM_OP
200 #ifdef EH_FRAME_SECTION_ASM_OP
203 #ifdef EXTRA_SECTIONS
206 } in_section
= no_section
;
208 /* Return a non-zero value if DECL has a section attribute. */
209 #define IN_NAMED_SECTION(DECL) \
210 ((TREE_CODE (DECL) == FUNCTION_DECL || TREE_CODE (DECL) == VAR_DECL) \
211 && DECL_SECTION_NAME (DECL) != NULL_TREE)
213 /* Text of section name when in_section == in_named. */
214 static char *in_named_name
;
216 /* Define functions like text_section for any extra sections. */
217 #ifdef EXTRA_SECTION_FUNCTIONS
218 EXTRA_SECTION_FUNCTIONS
221 /* Tell assembler to switch to text section. */
226 if (in_section
!= in_text
)
228 fprintf (asm_out_file
, "%s\n", TEXT_SECTION_ASM_OP
);
229 in_section
= in_text
;
233 /* Tell assembler to switch to data section. */
238 if (in_section
!= in_data
)
240 if (flag_shared_data
)
242 #ifdef SHARED_SECTION_ASM_OP
243 fprintf (asm_out_file
, "%s\n", SHARED_SECTION_ASM_OP
);
245 fprintf (asm_out_file
, "%s\n", DATA_SECTION_ASM_OP
);
249 fprintf (asm_out_file
, "%s\n", DATA_SECTION_ASM_OP
);
251 in_section
= in_data
;
254 /* Tell assembler to ALWAYS switch to data section, in case
255 it's not sure where it it. */
258 force_data_section ()
260 in_section
= no_section
;
264 /* Tell assembler to switch to read-only data section. This is normally
268 readonly_data_section ()
270 #ifdef READONLY_DATA_SECTION
271 READONLY_DATA_SECTION (); /* Note this can call data_section. */
277 /* Determine if we're in the text section. */
282 return in_section
== in_text
;
285 /* Determine if we're in the data section. */
290 return in_section
== in_data
;
293 /* Tell assembler to change to section NAME for DECL.
294 If DECL is NULL, just switch to section NAME.
295 If NAME is NULL, get the name from DECL.
296 If RELOC is 1, the initializer for DECL contains relocs. */
299 named_section (decl
, name
, reloc
)
302 int reloc ATTRIBUTE_UNUSED
;
304 if (decl
!= NULL_TREE
305 && TREE_CODE_CLASS (TREE_CODE (decl
)) != 'd')
308 name
= TREE_STRING_POINTER (DECL_SECTION_NAME (decl
));
310 if (in_section
!= in_named
|| strcmp (name
, in_named_name
))
312 #ifdef ASM_OUTPUT_SECTION_NAME
313 ASM_OUTPUT_SECTION_NAME (asm_out_file
, decl
, name
, reloc
);
315 /* Section attributes are not supported if this macro isn't provided -
316 some host formats don't support them at all. The front-end should
317 already have flagged this as an error. */
321 in_named_name
= ggc_alloc_string (name
, -1);
322 in_section
= in_named
;
326 #ifdef ASM_OUTPUT_SECTION_NAME
327 #ifndef UNIQUE_SECTION
328 #define UNIQUE_SECTION(DECL,RELOC) \
334 name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL)); \
335 /* Strip off any encoding in name. */ \
336 STRIP_NAME_ENCODING (name, name); \
338 len = strlen (name) + 1; \
339 string = alloca (len + 1); \
340 sprintf (string, ".%s", name); \
342 DECL_SECTION_NAME (DECL) = build_string (len, string); \
345 #ifndef UNIQUE_SECTION_P
346 #define UNIQUE_SECTION_P(DECL) 0
350 #ifdef BSS_SECTION_ASM_OP
352 /* Tell the assembler to switch to the bss section. */
357 if (in_section
!= in_bss
)
359 #ifdef SHARED_BSS_SECTION_ASM_OP
360 if (flag_shared_data
)
361 fprintf (asm_out_file
, "%s\n", SHARED_BSS_SECTION_ASM_OP
);
364 fprintf (asm_out_file
, "%s\n", BSS_SECTION_ASM_OP
);
370 #ifdef ASM_OUTPUT_BSS
372 /* Utility function for ASM_OUTPUT_BSS for targets to use if
373 they don't support alignments in .bss.
374 ??? It is believed that this function will work in most cases so such
375 support is localized here. */
378 asm_output_bss (file
, decl
, name
, size
, rounded
)
384 ASM_GLOBALIZE_LABEL (file
, name
);
386 #ifdef ASM_DECLARE_OBJECT_NAME
387 last_assemble_variable_decl
= decl
;
388 ASM_DECLARE_OBJECT_NAME (file
, name
, decl
);
390 /* Standard thing is just output label for the object. */
391 ASM_OUTPUT_LABEL (file
, name
);
392 #endif /* ASM_DECLARE_OBJECT_NAME */
393 ASM_OUTPUT_SKIP (file
, rounded
);
398 #ifdef ASM_OUTPUT_ALIGNED_BSS
400 /* Utility function for targets to use in implementing
401 ASM_OUTPUT_ALIGNED_BSS.
402 ??? It is believed that this function will work in most cases so such
403 support is localized here. */
406 asm_output_aligned_bss (file
, decl
, name
, size
, align
)
412 ASM_GLOBALIZE_LABEL (file
, name
);
414 ASM_OUTPUT_ALIGN (file
, floor_log2 (align
/ BITS_PER_UNIT
));
415 #ifdef ASM_DECLARE_OBJECT_NAME
416 last_assemble_variable_decl
= decl
;
417 ASM_DECLARE_OBJECT_NAME (file
, name
, decl
);
419 /* Standard thing is just output label for the object. */
420 ASM_OUTPUT_LABEL (file
, name
);
421 #endif /* ASM_DECLARE_OBJECT_NAME */
422 ASM_OUTPUT_SKIP (file
, size
? size
: 1);
427 #endif /* BSS_SECTION_ASM_OP */
429 #ifdef EH_FRAME_SECTION_ASM_OP
433 if (in_section
!= in_eh_frame
)
435 fprintf (asm_out_file
, "%s\n", EH_FRAME_SECTION_ASM_OP
);
436 in_section
= in_eh_frame
;
441 /* Switch to the section for function DECL.
443 If DECL is NULL_TREE, switch to the text section.
444 ??? It's not clear that we will ever be passed NULL_TREE, but it's
445 safer to handle it. */
448 function_section (decl
)
451 if (decl
!= NULL_TREE
452 && DECL_SECTION_NAME (decl
) != NULL_TREE
)
453 named_section (decl
, (char *) 0, 0);
458 /* Switch to section for variable DECL.
460 RELOC is the `reloc' argument to SELECT_SECTION. */
463 variable_section (decl
, reloc
)
467 if (IN_NAMED_SECTION (decl
))
468 named_section (decl
, NULL
, reloc
);
471 /* C++ can have const variables that get initialized from constructors,
472 and thus can not be in a readonly section. We prevent this by
473 verifying that the initial value is constant for objects put in a
476 error_mark_node is used by the C front end to indicate that the
477 initializer has not been seen yet. In this case, we assume that
478 the initializer must be constant.
480 C++ uses error_mark_node for variables that have complicated
481 initializers, but these variables go in BSS so we won't be called
484 #ifdef SELECT_SECTION
485 SELECT_SECTION (decl
, reloc
);
487 if (DECL_READONLY_SECTION (decl
, reloc
))
488 readonly_data_section ();
495 /* Tell assembler to switch to the section for the exception handling
501 #if defined (EXCEPTION_SECTION)
502 EXCEPTION_SECTION ();
504 #ifdef ASM_OUTPUT_SECTION_NAME
505 named_section (NULL_TREE
, ".gcc_except_table", 0);
510 readonly_data_section ();
515 /* Create the rtl to represent a function, for a function definition.
516 DECL is a FUNCTION_DECL node which describes which function.
517 The rtl is stored into DECL. */
520 make_function_rtl (decl
)
523 char *name
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
));
524 char *new_name
= name
;
526 /* Rename a nested function to avoid conflicts. */
527 if (decl_function_context (decl
) != 0
528 && DECL_INITIAL (decl
) != 0
529 && DECL_RTL (decl
) == 0)
533 name
= IDENTIFIER_POINTER (DECL_NAME (decl
));
534 ASM_FORMAT_PRIVATE_NAME (label
, name
, var_labelno
);
535 name
= ggc_alloc_string (label
, -1);
540 /* When -fprefix-function-name is used, every function name is
541 prefixed. Even static functions are prefixed because they
542 could be declared latter. Note that a nested function name
544 if (flag_prefix_function_name
)
546 size_t name_len
= strlen (name
);
548 new_name
= ggc_alloc_string (NULL
, name_len
+ CHKR_PREFIX_SIZE
);
549 memcpy (new_name
, CHKR_PREFIX
, CHKR_PREFIX_SIZE
);
550 memcpy (new_name
+ CHKR_PREFIX_SIZE
, name
, name_len
+ 1);
555 if (DECL_RTL (decl
) == 0)
558 = gen_rtx_MEM (DECL_MODE (decl
),
559 gen_rtx_SYMBOL_REF (Pmode
, name
));
561 /* Optionally set flags or add text to the name to record information
562 such as that it is a function name. If the name is changed, the macro
563 ASM_OUTPUT_LABELREF will have to know how to strip this information. */
564 #ifdef ENCODE_SECTION_INFO
565 ENCODE_SECTION_INFO (decl
);
570 /* ??? Another way to do this would be to do what halfpic.c does
571 and maintain a hashed table of such critters. */
572 /* ??? Another way to do this would be to pass a flag bit to
573 ENCODE_SECTION_INFO saying whether this is a new decl or not. */
574 /* Let the target reassign the RTL if it wants.
575 This is necessary, for example, when one machine specific
576 decl attribute overrides another. */
577 #ifdef REDO_SECTION_INFO_P
578 if (REDO_SECTION_INFO_P (decl
))
579 ENCODE_SECTION_INFO (decl
);
583 /* Record at least one function has been defined. */
584 function_defined
= 1;
587 /* Given NAME, a putative register name, discard any customary prefixes. */
590 strip_reg_name (name
)
593 #ifdef REGISTER_PREFIX
594 if (!strncmp (name
, REGISTER_PREFIX
, strlen (REGISTER_PREFIX
)))
595 name
+= strlen (REGISTER_PREFIX
);
597 if (name
[0] == '%' || name
[0] == '#')
602 /* Decode an `asm' spec for a declaration as a register name.
603 Return the register number, or -1 if nothing specified,
604 or -2 if the ASMSPEC is not `cc' or `memory' and is not recognized,
605 or -3 if ASMSPEC is `cc' and is not recognized,
606 or -4 if ASMSPEC is `memory' and is not recognized.
607 Accept an exact spelling or a decimal number.
608 Prefixes such as % are optional. */
611 decode_reg_name (asmspec
)
618 /* Get rid of confusing prefixes. */
619 asmspec
= strip_reg_name (asmspec
);
621 /* Allow a decimal number as a "register name". */
622 for (i
= strlen (asmspec
) - 1; i
>= 0; i
--)
623 if (! (asmspec
[i
] >= '0' && asmspec
[i
] <= '9'))
625 if (asmspec
[0] != 0 && i
< 0)
628 if (i
< FIRST_PSEUDO_REGISTER
&& i
>= 0)
634 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; i
++)
636 && ! strcmp (asmspec
, strip_reg_name (reg_names
[i
])))
639 #ifdef ADDITIONAL_REGISTER_NAMES
641 static struct { const char *name
; int number
; } table
[]
642 = ADDITIONAL_REGISTER_NAMES
;
644 for (i
= 0; i
< (int)(sizeof (table
) / sizeof (table
[0])); i
++)
645 if (! strcmp (asmspec
, table
[i
].name
))
646 return table
[i
].number
;
648 #endif /* ADDITIONAL_REGISTER_NAMES */
650 if (!strcmp (asmspec
, "memory"))
653 if (!strcmp (asmspec
, "cc"))
662 /* Create the DECL_RTL for a declaration for a static or external variable
663 or static or external function.
664 ASMSPEC, if not 0, is the string which the user specified
665 as the assembler symbol name.
666 TOP_LEVEL is nonzero if this is a file-scope variable.
668 This is never called for PARM_DECL nodes. */
671 make_decl_rtl (decl
, asmspec
, top_level
)
676 register char *name
= 0;
679 reg_number
= decode_reg_name (asmspec
);
681 if (DECL_ASSEMBLER_NAME (decl
) != NULL_TREE
)
682 name
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
));
684 if (reg_number
== -2)
686 /* ASMSPEC is given, and not the name of a register. */
687 size_t len
= strlen (asmspec
);
689 name
= ggc_alloc_string (NULL
, len
+ 1);
691 memcpy (&name
[1], asmspec
, len
+ 1);
694 /* For a duplicate declaration, we can be called twice on the
695 same DECL node. Don't discard the RTL already made. */
696 if (DECL_RTL (decl
) == 0)
698 /* First detect errors in declaring global registers. */
699 if (TREE_CODE (decl
) != FUNCTION_DECL
700 && DECL_REGISTER (decl
) && reg_number
== -1)
701 error_with_decl (decl
,
702 "register name not specified for `%s'");
703 else if (TREE_CODE (decl
) != FUNCTION_DECL
704 && DECL_REGISTER (decl
) && reg_number
< 0)
705 error_with_decl (decl
,
706 "invalid register name for `%s'");
707 else if ((reg_number
>= 0 || reg_number
== -3)
708 && (TREE_CODE (decl
) == FUNCTION_DECL
709 && ! DECL_REGISTER (decl
)))
710 error_with_decl (decl
,
711 "register name given for non-register variable `%s'");
712 else if (TREE_CODE (decl
) != FUNCTION_DECL
713 && DECL_REGISTER (decl
)
714 && TYPE_MODE (TREE_TYPE (decl
)) == BLKmode
)
715 error_with_decl (decl
,
716 "data type of `%s' isn't suitable for a register");
717 else if (TREE_CODE (decl
) != FUNCTION_DECL
&& DECL_REGISTER (decl
)
718 && ! HARD_REGNO_MODE_OK (reg_number
,
719 TYPE_MODE (TREE_TYPE (decl
))))
720 error_with_decl (decl
,
721 "register number for `%s' isn't suitable for data type");
722 /* Now handle properly declared static register variables. */
723 else if (TREE_CODE (decl
) != FUNCTION_DECL
&& DECL_REGISTER (decl
))
727 if (DECL_INITIAL (decl
) != 0 && top_level
)
729 DECL_INITIAL (decl
) = 0;
730 error ("global register variable has initial value");
732 if (fixed_regs
[reg_number
] == 0
733 && function_defined
&& top_level
)
734 error ("global register variable follows a function definition");
735 if (TREE_THIS_VOLATILE (decl
))
736 warning ("volatile register variables don't work as you might wish");
738 /* If the user specified one of the eliminables registers here,
739 e.g., FRAME_POINTER_REGNUM, we don't want to get this variable
740 confused with that register and be eliminated. Although this
741 usage is somewhat suspect, we nevertheless use the following
742 kludge to avoid setting DECL_RTL to frame_pointer_rtx. */
745 = gen_rtx_REG (DECL_MODE (decl
), FIRST_PSEUDO_REGISTER
);
746 REGNO (DECL_RTL (decl
)) = reg_number
;
747 REG_USERVAR_P (DECL_RTL (decl
)) = 1;
751 /* Make this register global, so not usable for anything
753 #ifdef ASM_DECLARE_REGISTER_GLOBAL
754 ASM_DECLARE_REGISTER_GLOBAL (asm_out_file
, decl
, reg_number
, name
);
756 nregs
= HARD_REGNO_NREGS (reg_number
, DECL_MODE (decl
));
758 globalize_reg (reg_number
+ --nregs
);
761 /* Specifying a section attribute on a variable forces it into a
762 non-.bss section, and thus it cannot be common. */
763 else if (TREE_CODE (decl
) == VAR_DECL
764 && DECL_SECTION_NAME (decl
) != NULL_TREE
765 && DECL_INITIAL (decl
) == NULL_TREE
766 && DECL_COMMON (decl
))
767 DECL_COMMON (decl
) = 0;
769 /* Now handle ordinary static variables and functions (in memory).
770 Also handle vars declared register invalidly. */
771 if (DECL_RTL (decl
) == 0)
773 /* Can't use just the variable's own name for a variable
774 whose scope is less than the whole file.
775 Concatenate a distinguishing number. */
776 if (!top_level
&& !TREE_PUBLIC (decl
) && asmspec
== 0)
780 ASM_FORMAT_PRIVATE_NAME (label
, name
, var_labelno
);
781 name
= ggc_alloc_string (label
, -1);
788 /* When -fprefix-function-name is used, the functions
789 names are prefixed. Only nested function names are not
791 if (flag_prefix_function_name
&& TREE_CODE (decl
) == FUNCTION_DECL
)
793 size_t name_len
= strlen (name
);
796 new_name
= ggc_alloc_string (NULL
, name_len
+ CHKR_PREFIX_SIZE
);
797 memcpy (new_name
, CHKR_PREFIX
, CHKR_PREFIX_SIZE
);
798 memcpy (new_name
+ CHKR_PREFIX_SIZE
, name
, name_len
+ 1);
802 DECL_RTL (decl
) = gen_rtx_MEM (DECL_MODE (decl
),
803 gen_rtx_SYMBOL_REF (Pmode
, name
));
804 MEM_ALIAS_SET (DECL_RTL (decl
)) = get_alias_set (decl
);
806 /* If this variable is to be treated as volatile, show its
807 tree node has side effects. If it has side effects, either
808 because of this test or from TREE_THIS_VOLATILE also
809 being set, show the MEM is volatile. */
810 if (flag_volatile_global
&& TREE_CODE (decl
) == VAR_DECL
811 && TREE_PUBLIC (decl
))
812 TREE_SIDE_EFFECTS (decl
) = 1;
813 else if (flag_volatile_static
&& TREE_CODE (decl
) == VAR_DECL
814 && (TREE_PUBLIC (decl
) || TREE_STATIC (decl
)))
815 TREE_SIDE_EFFECTS (decl
) = 1;
817 if (TREE_SIDE_EFFECTS (decl
))
818 MEM_VOLATILE_P (DECL_RTL (decl
)) = 1;
820 if (TREE_READONLY (decl
))
821 RTX_UNCHANGING_P (DECL_RTL (decl
)) = 1;
822 MEM_SET_IN_STRUCT_P (DECL_RTL (decl
),
823 AGGREGATE_TYPE_P (TREE_TYPE (decl
)));
825 /* Optionally set flags or add text to the name to record information
826 such as that it is a function name.
827 If the name is changed, the macro ASM_OUTPUT_LABELREF
828 will have to know how to strip this information. */
829 #ifdef ENCODE_SECTION_INFO
830 ENCODE_SECTION_INFO (decl
);
836 /* If the old RTL had the wrong mode, fix the mode. */
837 if (GET_MODE (DECL_RTL (decl
)) != DECL_MODE (decl
))
839 rtx rtl
= DECL_RTL (decl
);
840 PUT_MODE (rtl
, DECL_MODE (decl
));
843 /* ??? Another way to do this would be to do what halfpic.c does
844 and maintain a hashed table of such critters. */
845 /* ??? Another way to do this would be to pass a flag bit to
846 ENCODE_SECTION_INFO saying whether this is a new decl or not. */
847 /* Let the target reassign the RTL if it wants.
848 This is necessary, for example, when one machine specific
849 decl attribute overrides another. */
850 #ifdef REDO_SECTION_INFO_P
851 if (REDO_SECTION_INFO_P (decl
))
852 ENCODE_SECTION_INFO (decl
);
857 /* Make the rtl for variable VAR be volatile.
858 Use this only for static variables. */
861 make_var_volatile (var
)
864 if (GET_CODE (DECL_RTL (var
)) != MEM
)
867 MEM_VOLATILE_P (DECL_RTL (var
)) = 1;
870 /* Output alignment directive to align for constant expression EXP. */
873 assemble_constant_align (exp
)
878 /* Align the location counter as required by EXP's data type. */
879 align
= TYPE_ALIGN (TREE_TYPE (exp
));
880 #ifdef CONSTANT_ALIGNMENT
881 align
= CONSTANT_ALIGNMENT (exp
, align
);
884 if (align
> BITS_PER_UNIT
)
885 ASM_OUTPUT_ALIGN (asm_out_file
, floor_log2 (align
/ BITS_PER_UNIT
));
888 /* Output a string of literal assembler code
889 for an `asm' keyword used between functions. */
892 assemble_asm (string
)
897 if (TREE_CODE (string
) == ADDR_EXPR
)
898 string
= TREE_OPERAND (string
, 0);
900 fprintf (asm_out_file
, "\t%s\n", TREE_STRING_POINTER (string
));
903 #if 0 /* This should no longer be needed, because
904 flag_gnu_linker should be 0 on these systems,
905 which should prevent any output
906 if ASM_OUTPUT_CONSTRUCTOR and ASM_OUTPUT_DESTRUCTOR are absent. */
907 #if !(defined(DBX_DEBUGGING_INFO) && !defined(FASCIST_ASSEMBLER))
908 #ifndef ASM_OUTPUT_CONSTRUCTOR
909 #define ASM_OUTPUT_CONSTRUCTOR(file, name)
911 #ifndef ASM_OUTPUT_DESTRUCTOR
912 #define ASM_OUTPUT_DESTRUCTOR(file, name)
917 /* Record an element in the table of global destructors.
918 How this is done depends on what sort of assembler and linker
921 NAME should be the name of a global function to be called
922 at exit time. This name is output using assemble_name. */
925 assemble_destructor (name
)
928 #ifdef ASM_OUTPUT_DESTRUCTOR
929 ASM_OUTPUT_DESTRUCTOR (asm_out_file
, name
);
933 /* Now tell GNU LD that this is part of the static destructor set. */
934 /* This code works for any machine provided you use GNU as/ld. */
935 fprintf (asm_out_file
, "%s \"___DTOR_LIST__\",22,0,0,", ASM_STABS_OP
);
936 assemble_name (asm_out_file
, name
);
937 fputc ('\n', asm_out_file
);
942 /* Likewise for global constructors. */
945 assemble_constructor (name
)
948 #ifdef ASM_OUTPUT_CONSTRUCTOR
949 ASM_OUTPUT_CONSTRUCTOR (asm_out_file
, name
);
953 /* Now tell GNU LD that this is part of the static constructor set. */
954 /* This code works for any machine provided you use GNU as/ld. */
955 fprintf (asm_out_file
, "%s \"___CTOR_LIST__\",22,0,0,", ASM_STABS_OP
);
956 assemble_name (asm_out_file
, name
);
957 fputc ('\n', asm_out_file
);
962 /* Likewise for entries we want to record for garbage collection.
963 Garbage collection is still under development. */
966 assemble_gc_entry (name
)
969 #ifdef ASM_OUTPUT_GC_ENTRY
970 ASM_OUTPUT_GC_ENTRY (asm_out_file
, name
);
974 /* Now tell GNU LD that this is part of the static constructor set. */
975 fprintf (asm_out_file
, "%s \"___PTR_LIST__\",22,0,0,", ASM_STABS_OP
);
976 assemble_name (asm_out_file
, name
);
977 fputc ('\n', asm_out_file
);
982 /* CONSTANT_POOL_BEFORE_FUNCTION may be defined as an expression with
983 a non-zero value if the constant pool should be output before the
984 start of the function, or a zero value if the pool should output
985 after the end of the function. The default is to put it before the
988 #ifndef CONSTANT_POOL_BEFORE_FUNCTION
989 #define CONSTANT_POOL_BEFORE_FUNCTION 1
992 /* Output assembler code for the constant pool of a function and associated
993 with defining the name of the function. DECL describes the function.
994 NAME is the function's name. For the constant pool, we use the current
995 constant pool data. */
998 assemble_start_function (decl
, fnname
)
1004 /* The following code does not need preprocessing in the assembler. */
1008 if (CONSTANT_POOL_BEFORE_FUNCTION
)
1009 output_constant_pool (fnname
, decl
);
1011 #ifdef ASM_OUTPUT_SECTION_NAME
1012 /* If the function is to be put in its own section and it's not in a section
1013 already, indicate so. */
1014 if ((flag_function_sections
1015 && DECL_SECTION_NAME (decl
) == NULL_TREE
)
1016 || UNIQUE_SECTION_P (decl
))
1017 UNIQUE_SECTION (decl
, 0);
1020 function_section (decl
);
1022 /* Tell assembler to move to target machine's alignment for functions. */
1023 align
= floor_log2 (FUNCTION_BOUNDARY
/ BITS_PER_UNIT
);
1025 ASM_OUTPUT_ALIGN (asm_out_file
, align
);
1027 /* Handle a user-specified function alignment.
1028 Note that we still need to align to FUNCTION_BOUNDARY, as above,
1029 because ASM_OUTPUT_MAX_SKIP_ALIGN might not do any alignment at all. */
1030 if (align_functions_log
> align
)
1032 #ifdef ASM_OUTPUT_MAX_SKIP_ALIGN
1033 ASM_OUTPUT_MAX_SKIP_ALIGN (asm_out_file
,
1034 align_functions_log
, align_functions
-1);
1036 ASM_OUTPUT_ALIGN (asm_out_file
, align_functions_log
);
1040 #ifdef ASM_OUTPUT_FUNCTION_PREFIX
1041 ASM_OUTPUT_FUNCTION_PREFIX (asm_out_file
, fnname
);
1044 #ifdef SDB_DEBUGGING_INFO
1045 /* Output SDB definition of the function. */
1046 if (write_symbols
== SDB_DEBUG
)
1047 sdbout_mark_begin_function ();
1050 #ifdef DBX_DEBUGGING_INFO
1051 /* Output DBX definition of the function. */
1052 if (write_symbols
== DBX_DEBUG
)
1053 dbxout_begin_function (decl
);
1056 /* Make function name accessible from other files, if appropriate. */
1058 if (TREE_PUBLIC (decl
))
1060 if (! first_global_object_name
)
1065 if (! DECL_WEAK (decl
) && ! DECL_ONE_ONLY (decl
))
1066 name
= &first_global_object_name
;
1068 name
= &weak_global_object_name
;
1070 STRIP_NAME_ENCODING (p
, fnname
);
1071 *name
= permalloc (strlen (p
) + 1);
1075 #ifdef ASM_WEAKEN_LABEL
1076 if (DECL_WEAK (decl
))
1078 ASM_WEAKEN_LABEL (asm_out_file
, fnname
);
1079 /* Remove this function from the pending weak list so that
1080 we do not emit multiple .weak directives for it. */
1081 remove_from_pending_weak_list
1082 (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)));
1086 ASM_GLOBALIZE_LABEL (asm_out_file
, fnname
);
1089 /* Do any machine/system dependent processing of the function name */
1090 #ifdef ASM_DECLARE_FUNCTION_NAME
1091 ASM_DECLARE_FUNCTION_NAME (asm_out_file
, fnname
, current_function_decl
);
1093 /* Standard thing is just output label for the function. */
1094 ASM_OUTPUT_LABEL (asm_out_file
, fnname
);
1095 #endif /* ASM_DECLARE_FUNCTION_NAME */
1098 /* Output assembler code associated with defining the size of the
1099 function. DECL describes the function. NAME is the function's name. */
1102 assemble_end_function (decl
, fnname
)
1106 #ifdef ASM_DECLARE_FUNCTION_SIZE
1107 ASM_DECLARE_FUNCTION_SIZE (asm_out_file
, fnname
, decl
);
1109 if (! CONSTANT_POOL_BEFORE_FUNCTION
)
1111 output_constant_pool (fnname
, decl
);
1112 function_section (decl
); /* need to switch back */
1115 /* Output any constants which should appear after the function. */
1116 output_after_function_constants ();
1119 /* Assemble code to leave SIZE bytes of zeros. */
1122 assemble_zeros (size
)
1125 /* Do no output if -fsyntax-only. */
1126 if (flag_syntax_only
)
1129 #ifdef ASM_NO_SKIP_IN_TEXT
1130 /* The `space' pseudo in the text section outputs nop insns rather than 0s,
1131 so we must output 0s explicitly in the text section. */
1132 if (ASM_NO_SKIP_IN_TEXT
&& in_text_section ())
1136 for (i
= 0; i
< size
- 20; i
+= 20)
1139 fprintf (asm_out_file
,
1140 "%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
);
1142 fprintf (asm_out_file
,
1143 "\tbyte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n");
1149 fprintf (asm_out_file
, "%s 0", ASM_BYTE_OP
);
1151 fprintf (asm_out_file
, "\tbyte 0");
1154 for (; i
< size
; i
++)
1155 fprintf (asm_out_file
, ",0");
1156 fprintf (asm_out_file
, "\n");
1162 ASM_OUTPUT_SKIP (asm_out_file
, size
);
1165 /* Assemble an alignment pseudo op for an ALIGN-bit boundary. */
1168 assemble_align (align
)
1171 if (align
> BITS_PER_UNIT
)
1172 ASM_OUTPUT_ALIGN (asm_out_file
, floor_log2 (align
/ BITS_PER_UNIT
));
1175 /* Assemble a string constant with the specified C string as contents. */
1178 assemble_string (p
, size
)
1185 /* If the string is very long, split it up. */
1189 int thissize
= size
- pos
;
1190 if (thissize
> maximum
)
1193 ASM_OUTPUT_ASCII (asm_out_file
, p
, thissize
);
1201 #if defined ASM_OUTPUT_ALIGNED_DECL_LOCAL
1202 #define ASM_EMIT_LOCAL(decl, name, size, rounded) \
1203 ASM_OUTPUT_ALIGNED_DECL_LOCAL (asm_out_file, decl, name, size, DECL_ALIGN (decl))
1205 #if defined ASM_OUTPUT_ALIGNED_LOCAL
1206 #define ASM_EMIT_LOCAL(decl, name, size, rounded) \
1207 ASM_OUTPUT_ALIGNED_LOCAL (asm_out_file, name, size, DECL_ALIGN (decl))
1209 #define ASM_EMIT_LOCAL(decl, name, size, rounded) \
1210 ASM_OUTPUT_LOCAL (asm_out_file, name, size, rounded)
1214 #if defined ASM_OUTPUT_ALIGNED_BSS
1215 #define ASM_EMIT_BSS(decl, name, size, rounded) \
1216 ASM_OUTPUT_ALIGNED_BSS (asm_out_file, decl, name, size, DECL_ALIGN (decl))
1218 #if defined ASM_OUTPUT_BSS
1219 #define ASM_EMIT_BSS(decl, name, size, rounded) \
1220 ASM_OUTPUT_BSS (asm_out_file, decl, name, size, rounded)
1226 #if defined ASM_OUTPUT_ALIGNED_DECL_COMMON
1227 #define ASM_EMIT_COMMON(decl, name, size, rounded) \
1228 ASM_OUTPUT_ALIGNED_DECL_COMMON (asm_out_file, decl, name, size, DECL_ALIGN (decl))
1230 #if defined ASM_OUTPUT_ALIGNED_COMMON
1231 #define ASM_EMIT_COMMON(decl, name, size, rounded) \
1232 ASM_OUTPUT_ALIGNED_COMMON (asm_out_file, name, size, DECL_ALIGN (decl))
1234 #define ASM_EMIT_COMMON(decl, name, size, rounded) \
1235 ASM_OUTPUT_COMMON (asm_out_file, name, size, rounded)
1240 asm_emit_uninitialised (decl
, name
, size
, rounded
)
1244 int rounded ATTRIBUTE_UNUSED
;
1251 destination
= asm_dest_local
;
1253 if (TREE_PUBLIC (decl
))
1255 #if defined ASM_EMIT_BSS
1256 if (! DECL_COMMON (decl
))
1257 destination
= asm_dest_bss
;
1260 destination
= asm_dest_common
;
1263 if (flag_shared_data
)
1265 switch (destination
)
1267 #ifdef ASM_OUTPUT_SHARED_BSS
1269 ASM_OUTPUT_SHARED_BSS (asm_out_file
, decl
, name
, size
, rounded
);
1272 #ifdef ASM_OUTPUT_SHARED_COMMON
1273 case asm_dest_common
:
1274 ASM_OUTPUT_SHARED_COMMON (asm_out_file
, name
, size
, rounded
);
1277 #ifdef ASM_OUTPUT_SHARED_LOCAL
1278 case asm_dest_local
:
1279 ASM_OUTPUT_SHARED_LOCAL (asm_out_file
, name
, size
, rounded
);
1287 switch (destination
)
1291 ASM_EMIT_BSS (decl
, name
, size
, rounded
);
1294 case asm_dest_common
:
1295 ASM_EMIT_COMMON (decl
, name
, size
, rounded
);
1297 case asm_dest_local
:
1298 ASM_EMIT_LOCAL (decl
, name
, size
, rounded
);
1307 /* Assemble everything that is needed for a variable or function declaration.
1308 Not used for automatic variables, and not used for function definitions.
1309 Should not be called for variables of incomplete structure type.
1311 TOP_LEVEL is nonzero if this variable has file scope.
1312 AT_END is nonzero if this is the special handling, at end of compilation,
1313 to define things that have had only tentative definitions.
1314 DONT_OUTPUT_DATA if nonzero means don't actually output the
1315 initial value (that will be done by the caller). */
1318 assemble_variable (decl
, top_level
, at_end
, dont_output_data
)
1320 int top_level ATTRIBUTE_UNUSED
;
1321 int at_end ATTRIBUTE_UNUSED
;
1322 int dont_output_data
;
1324 register char *name
;
1326 tree size_tree
= NULL_TREE
;
1328 enum in_section saved_in_section
;
1330 last_assemble_variable_decl
= 0;
1332 if (GET_CODE (DECL_RTL (decl
)) == REG
)
1334 /* Do output symbol info for global register variables, but do nothing
1337 if (TREE_ASM_WRITTEN (decl
))
1339 TREE_ASM_WRITTEN (decl
) = 1;
1341 /* Do no output if -fsyntax-only. */
1342 if (flag_syntax_only
)
1345 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
1346 /* File-scope global variables are output here. */
1347 if ((write_symbols
== DBX_DEBUG
|| write_symbols
== XCOFF_DEBUG
)
1349 dbxout_symbol (decl
, 0);
1351 #ifdef SDB_DEBUGGING_INFO
1352 if (write_symbols
== SDB_DEBUG
&& top_level
1353 /* Leave initialized global vars for end of compilation;
1354 see comment in compile_file. */
1355 && (TREE_PUBLIC (decl
) == 0 || DECL_INITIAL (decl
) == 0))
1356 sdbout_symbol (decl
, 0);
1359 /* Don't output any DWARF debugging information for variables here.
1360 In the case of local variables, the information for them is output
1361 when we do our recursive traversal of the tree representation for
1362 the entire containing function. In the case of file-scope variables,
1363 we output information for all of them at the very end of compilation
1364 while we are doing our final traversal of the chain of file-scope
1370 /* Normally no need to say anything here for external references,
1371 since assemble_external is called by the language-specific code
1372 when a declaration is first seen. */
1374 if (DECL_EXTERNAL (decl
))
1377 /* Output no assembler code for a function declaration.
1378 Only definitions of functions output anything. */
1380 if (TREE_CODE (decl
) == FUNCTION_DECL
)
1383 /* If type was incomplete when the variable was declared,
1384 see if it is complete now. */
1386 if (DECL_SIZE (decl
) == 0)
1387 layout_decl (decl
, 0);
1389 /* Still incomplete => don't allocate it; treat the tentative defn
1390 (which is what it must have been) as an `extern' reference. */
1392 if (!dont_output_data
&& DECL_SIZE (decl
) == 0)
1394 error_with_file_and_line (DECL_SOURCE_FILE (decl
),
1395 DECL_SOURCE_LINE (decl
),
1396 "storage size of `%s' isn't known",
1397 IDENTIFIER_POINTER (DECL_NAME (decl
)));
1398 TREE_ASM_WRITTEN (decl
) = 1;
1402 /* The first declaration of a variable that comes through this function
1403 decides whether it is global (in C, has external linkage)
1404 or local (in C, has internal linkage). So do nothing more
1405 if this function has already run. */
1407 if (TREE_ASM_WRITTEN (decl
))
1410 TREE_ASM_WRITTEN (decl
) = 1;
1412 /* Do no output if -fsyntax-only. */
1413 if (flag_syntax_only
)
1418 if (! dont_output_data
)
1422 if (TREE_CODE (DECL_SIZE (decl
)) != INTEGER_CST
)
1425 /* This is better than explicit arithmetic, since it avoids overflow. */
1426 size_tree
= size_binop (CEIL_DIV_EXPR
,
1427 DECL_SIZE (decl
), size_int (BITS_PER_UNIT
));
1429 size
= TREE_INT_CST_LOW (size_tree
);
1430 if (TREE_INT_CST_HIGH (size_tree
) != 0
1431 || size
!= TREE_INT_CST_LOW (size_tree
))
1433 error_with_decl (decl
, "size of variable `%s' is too large");
1438 name
= XSTR (XEXP (DECL_RTL (decl
), 0), 0);
1440 if (TREE_PUBLIC (decl
) && DECL_NAME (decl
)
1441 && ! first_global_object_name
1442 && ! (DECL_COMMON (decl
) && (DECL_INITIAL (decl
) == 0
1443 || DECL_INITIAL (decl
) == error_mark_node
))
1444 && ! DECL_WEAK (decl
)
1445 && ! DECL_ONE_ONLY (decl
))
1449 STRIP_NAME_ENCODING (p
, name
);
1450 first_global_object_name
= permalloc (strlen (p
) + 1);
1451 strcpy (first_global_object_name
, p
);
1454 /* Compute the alignment of this data. */
1456 align
= DECL_ALIGN (decl
);
1458 /* In the case for initialing an array whose length isn't specified,
1459 where we have not yet been able to do the layout,
1460 figure out the proper alignment now. */
1461 if (dont_output_data
&& DECL_SIZE (decl
) == 0
1462 && TREE_CODE (TREE_TYPE (decl
)) == ARRAY_TYPE
)
1463 align
= MAX (align
, TYPE_ALIGN (TREE_TYPE (TREE_TYPE (decl
))));
1465 /* Some object file formats have a maximum alignment which they support.
1466 In particular, a.out format supports a maximum alignment of 4. */
1467 #ifndef MAX_OFILE_ALIGNMENT
1468 #define MAX_OFILE_ALIGNMENT BIGGEST_ALIGNMENT
1470 if (align
> MAX_OFILE_ALIGNMENT
)
1472 warning_with_decl (decl
,
1473 "alignment of `%s' is greater than maximum object file alignment. Using %d.",
1474 MAX_OFILE_ALIGNMENT
/BITS_PER_UNIT
);
1475 align
= MAX_OFILE_ALIGNMENT
;
1478 /* On some machines, it is good to increase alignment sometimes. */
1479 #ifdef DATA_ALIGNMENT
1480 align
= DATA_ALIGNMENT (TREE_TYPE (decl
), align
);
1482 #ifdef CONSTANT_ALIGNMENT
1483 if (DECL_INITIAL (decl
) != 0 && DECL_INITIAL (decl
) != error_mark_node
)
1484 align
= CONSTANT_ALIGNMENT (DECL_INITIAL (decl
), align
);
1487 /* Reset the alignment in case we have made it tighter, so we can benefit
1488 from it in get_pointer_alignment. */
1489 DECL_ALIGN (decl
) = align
;
1491 /* Handle uninitialized definitions. */
1493 if ((DECL_INITIAL (decl
) == 0 || DECL_INITIAL (decl
) == error_mark_node
)
1494 /* If the target can't output uninitialized but not common global data
1495 in .bss, then we have to use .data. */
1496 #if ! defined ASM_EMIT_BSS
1497 && DECL_COMMON (decl
)
1499 && DECL_SECTION_NAME (decl
) == 0
1500 && ! dont_output_data
)
1502 int size
= TREE_INT_CST_LOW (size_tree
);
1505 /* Don't allocate zero bytes of common,
1506 since that means "undefined external" in the linker. */
1507 if (size
== 0) rounded
= 1;
1508 /* Round size up to multiple of BIGGEST_ALIGNMENT bits
1509 so that each uninitialized object starts on such a boundary. */
1510 rounded
+= (BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
) - 1;
1511 rounded
= (rounded
/ (BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
)
1512 * (BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
));
1514 #if !defined(ASM_OUTPUT_ALIGNED_COMMON) && !defined(ASM_OUTPUT_ALIGNED_BSS)
1515 if ( (DECL_ALIGN (decl
) / BITS_PER_UNIT
) > rounded
)
1517 (decl
, "requested alignment for %s is greater than implemented alignment of %d.",rounded
);
1520 #ifdef DBX_DEBUGGING_INFO
1521 /* File-scope global variables are output here. */
1522 if (write_symbols
== DBX_DEBUG
&& top_level
)
1523 dbxout_symbol (decl
, 0);
1525 #ifdef SDB_DEBUGGING_INFO
1526 if (write_symbols
== SDB_DEBUG
&& top_level
1527 /* Leave initialized global vars for end of compilation;
1528 see comment in compile_file. */
1529 && (TREE_PUBLIC (decl
) == 0 || DECL_INITIAL (decl
) == 0))
1530 sdbout_symbol (decl
, 0);
1533 /* Don't output any DWARF debugging information for variables here.
1534 In the case of local variables, the information for them is output
1535 when we do our recursive traversal of the tree representation for
1536 the entire containing function. In the case of file-scope variables,
1537 we output information for all of them at the very end of compilation
1538 while we are doing our final traversal of the chain of file-scope
1541 #if 0 /* ??? We should either delete this or add a comment describing what
1542 it was intended to do and why we shouldn't delete it. */
1543 if (flag_shared_data
)
1546 asm_emit_uninitialised (decl
, name
, size
, rounded
);
1551 /* Handle initialized definitions.
1552 Also handle uninitialized global definitions if -fno-common and the
1553 target doesn't support ASM_OUTPUT_BSS. */
1555 /* First make the assembler name(s) global if appropriate. */
1556 if (TREE_PUBLIC (decl
) && DECL_NAME (decl
))
1558 #ifdef ASM_WEAKEN_LABEL
1559 if (DECL_WEAK (decl
))
1561 ASM_WEAKEN_LABEL (asm_out_file
, name
);
1562 /* Remove this variable from the pending weak list so that
1563 we do not emit multiple .weak directives for it. */
1564 remove_from_pending_weak_list
1565 (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)));
1569 ASM_GLOBALIZE_LABEL (asm_out_file
, name
);
1572 for (d
= equivalents
; d
; d
= TREE_CHAIN (d
))
1574 tree e
= TREE_VALUE (d
);
1575 if (TREE_PUBLIC (e
) && DECL_NAME (e
))
1576 ASM_GLOBALIZE_LABEL (asm_out_file
,
1577 XSTR (XEXP (DECL_RTL (e
), 0), 0));
1581 /* Output any data that we will need to use the address of. */
1582 if (DECL_INITIAL (decl
) == error_mark_node
)
1583 reloc
= contains_pointers_p (TREE_TYPE (decl
));
1584 else if (DECL_INITIAL (decl
))
1585 reloc
= output_addressed_constants (DECL_INITIAL (decl
));
1587 #ifdef ASM_OUTPUT_SECTION_NAME
1588 if ((flag_data_sections
!= 0
1589 && DECL_SECTION_NAME (decl
) == NULL_TREE
)
1590 || UNIQUE_SECTION_P (decl
))
1591 UNIQUE_SECTION (decl
, reloc
);
1594 /* Switch to the appropriate section. */
1595 variable_section (decl
, reloc
);
1597 /* dbxout.c needs to know this. */
1598 if (in_text_section ())
1599 DECL_IN_TEXT_SECTION (decl
) = 1;
1601 /* Record current section so we can restore it if dbxout.c clobbers it. */
1602 saved_in_section
= in_section
;
1604 /* Output the dbx info now that we have chosen the section. */
1606 #ifdef DBX_DEBUGGING_INFO
1607 /* File-scope global variables are output here. */
1608 if (write_symbols
== DBX_DEBUG
&& top_level
)
1609 dbxout_symbol (decl
, 0);
1611 #ifdef SDB_DEBUGGING_INFO
1612 if (write_symbols
== SDB_DEBUG
&& top_level
1613 /* Leave initialized global vars for end of compilation;
1614 see comment in compile_file. */
1615 && (TREE_PUBLIC (decl
) == 0 || DECL_INITIAL (decl
) == 0))
1616 sdbout_symbol (decl
, 0);
1619 /* Don't output any DWARF debugging information for variables here.
1620 In the case of local variables, the information for them is output
1621 when we do our recursive traversal of the tree representation for
1622 the entire containing function. In the case of file-scope variables,
1623 we output information for all of them at the very end of compilation
1624 while we are doing our final traversal of the chain of file-scope
1627 /* If the debugging output changed sections, reselect the section
1628 that's supposed to be selected. */
1629 if (in_section
!= saved_in_section
)
1630 variable_section (decl
, reloc
);
1632 /* Output the alignment of this data. */
1633 if (align
> BITS_PER_UNIT
)
1634 ASM_OUTPUT_ALIGN (asm_out_file
,
1635 floor_log2 (DECL_ALIGN (decl
) / BITS_PER_UNIT
));
1637 /* Do any machine/system dependent processing of the object. */
1638 #ifdef ASM_DECLARE_OBJECT_NAME
1639 last_assemble_variable_decl
= decl
;
1640 ASM_DECLARE_OBJECT_NAME (asm_out_file
, name
, decl
);
1642 /* Standard thing is just output label for the object. */
1643 ASM_OUTPUT_LABEL (asm_out_file
, name
);
1644 #endif /* ASM_DECLARE_OBJECT_NAME */
1646 if (!dont_output_data
)
1648 if (DECL_INITIAL (decl
))
1649 /* Output the actual data. */
1650 output_constant (DECL_INITIAL (decl
), TREE_INT_CST_LOW (size_tree
));
1652 /* Leave space for it. */
1653 assemble_zeros (TREE_INT_CST_LOW (size_tree
));
1657 #ifdef XCOFF_DEBUGGING_INFO
1658 /* Unfortunately, the IBM assembler cannot handle stabx before the actual
1659 declaration. When something like ".stabx "aa:S-2",aa,133,0" is emitted
1660 and `aa' hasn't been output yet, the assembler generates a stab entry with
1661 a value of zero, in addition to creating an unnecessary external entry
1662 for `aa'. Hence, we must postpone dbxout_symbol to here at the end. */
1664 /* File-scope global variables are output here. */
1665 if (write_symbols
== XCOFF_DEBUG
&& top_level
)
1667 saved_in_section
= in_section
;
1669 dbxout_symbol (decl
, 0);
1671 if (in_section
!= saved_in_section
)
1672 variable_section (decl
, reloc
);
1675 /* There must be a statement after a label. */
1680 /* Return 1 if type TYPE contains any pointers. */
1683 contains_pointers_p (type
)
1686 switch (TREE_CODE (type
))
1689 case REFERENCE_TYPE
:
1690 /* I'm not sure whether OFFSET_TYPE needs this treatment,
1691 so I'll play safe and return 1. */
1697 case QUAL_UNION_TYPE
:
1700 /* For a type that has fields, see if the fields have pointers. */
1701 for (fields
= TYPE_FIELDS (type
); fields
; fields
= TREE_CHAIN (fields
))
1702 if (TREE_CODE (fields
) == FIELD_DECL
1703 && contains_pointers_p (TREE_TYPE (fields
)))
1709 /* An array type contains pointers if its element type does. */
1710 return contains_pointers_p (TREE_TYPE (type
));
1717 /* Output something to declare an external symbol to the assembler.
1718 (Most assemblers don't need this, so we normally output nothing.)
1719 Do nothing if DECL is not external. */
1722 assemble_external (decl
)
1723 tree decl ATTRIBUTE_UNUSED
;
1725 #ifdef ASM_OUTPUT_EXTERNAL
1726 if (TREE_CODE_CLASS (TREE_CODE (decl
)) == 'd'
1727 && DECL_EXTERNAL (decl
) && TREE_PUBLIC (decl
))
1729 rtx rtl
= DECL_RTL (decl
);
1731 if (GET_CODE (rtl
) == MEM
&& GET_CODE (XEXP (rtl
, 0)) == SYMBOL_REF
1732 && ! SYMBOL_REF_USED (XEXP (rtl
, 0)))
1734 /* Some systems do require some output. */
1735 SYMBOL_REF_USED (XEXP (rtl
, 0)) = 1;
1736 ASM_OUTPUT_EXTERNAL (asm_out_file
, decl
, XSTR (XEXP (rtl
, 0), 0));
1742 /* Similar, for calling a library function FUN. */
1745 assemble_external_libcall (fun
)
1746 rtx fun ATTRIBUTE_UNUSED
;
1748 #ifdef ASM_OUTPUT_EXTERNAL_LIBCALL
1749 /* Declare library function name external when first used, if nec. */
1750 if (! SYMBOL_REF_USED (fun
))
1752 SYMBOL_REF_USED (fun
) = 1;
1753 ASM_OUTPUT_EXTERNAL_LIBCALL (asm_out_file
, fun
);
1758 /* Declare the label NAME global. */
1761 assemble_global (name
)
1764 ASM_GLOBALIZE_LABEL (asm_out_file
, name
);
1767 /* Assemble a label named NAME. */
1770 assemble_label (name
)
1773 ASM_OUTPUT_LABEL (asm_out_file
, name
);
1776 /* Output to FILE a reference to the assembler name of a C-level name NAME.
1777 If NAME starts with a *, the rest of NAME is output verbatim.
1778 Otherwise NAME is transformed in an implementation-defined way
1779 (usually by the addition of an underscore).
1780 Many macros in the tm file are defined to call this function. */
1783 assemble_name (file
, name
)
1787 const char *real_name
;
1790 STRIP_NAME_ENCODING (real_name
, name
);
1791 if (flag_prefix_function_name
1792 && ! bcmp (real_name
, CHKR_PREFIX
, CHKR_PREFIX_SIZE
))
1793 real_name
= real_name
+ CHKR_PREFIX_SIZE
;
1795 id
= maybe_get_identifier (real_name
);
1797 TREE_SYMBOL_REFERENCED (id
) = 1;
1800 fputs (&name
[1], file
);
1802 ASM_OUTPUT_LABELREF (file
, name
);
1805 /* Allocate SIZE bytes writable static space with a gensym name
1806 and return an RTX to refer to its address. */
1809 assemble_static_space (size
)
1817 if (flag_shared_data
)
1821 ASM_GENERATE_INTERNAL_LABEL (name
, "LF", const_labelno
);
1823 namestring
= ggc_alloc_string (name
, -1);
1825 x
= gen_rtx_SYMBOL_REF (Pmode
, namestring
);
1827 #ifdef ASM_OUTPUT_ALIGNED_DECL_LOCAL
1828 ASM_OUTPUT_ALIGNED_DECL_LOCAL (asm_out_file
, NULL_TREE
, name
, size
,
1831 #ifdef ASM_OUTPUT_ALIGNED_LOCAL
1832 ASM_OUTPUT_ALIGNED_LOCAL (asm_out_file
, name
, size
, BIGGEST_ALIGNMENT
);
1835 /* Round size up to multiple of BIGGEST_ALIGNMENT bits
1836 so that each uninitialized object starts on such a boundary. */
1837 /* Variable `rounded' might or might not be used in ASM_OUTPUT_LOCAL. */
1838 int rounded ATTRIBUTE_UNUSED
1839 = ((size
+ (BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
) - 1)
1840 / (BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
)
1841 * (BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
));
1842 ASM_OUTPUT_LOCAL (asm_out_file
, name
, size
, rounded
);
1849 /* Assemble the static constant template for function entry trampolines.
1850 This is done at most once per compilation.
1851 Returns an RTX for the address of the template. */
1853 #ifdef TRAMPOLINE_TEMPLATE
1855 assemble_trampoline_template ()
1861 /* By default, put trampoline templates in read-only data section. */
1863 #ifdef TRAMPOLINE_SECTION
1864 TRAMPOLINE_SECTION ();
1866 readonly_data_section ();
1869 /* Write the assembler code to define one. */
1870 align
= floor_log2 (TRAMPOLINE_ALIGNMENT
/ BITS_PER_UNIT
);
1872 ASM_OUTPUT_ALIGN (asm_out_file
, align
);
1874 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, "LTRAMP", 0);
1875 TRAMPOLINE_TEMPLATE (asm_out_file
);
1877 /* Record the rtl to refer to it. */
1878 ASM_GENERATE_INTERNAL_LABEL (label
, "LTRAMP", 0);
1879 name
= ggc_alloc_string (label
, -1);
1880 return gen_rtx_SYMBOL_REF (Pmode
, name
);
1884 /* Assemble the integer constant X into an object of SIZE bytes.
1885 X must be either a CONST_INT or CONST_DOUBLE.
1887 Return 1 if we were able to output the constant, otherwise 0. If FORCE is
1888 non-zero, abort if we can't output the constant. */
1891 assemble_integer (x
, size
, force
)
1896 /* First try to use the standard 1, 2, 4, 8, and 16 byte
1897 ASM_OUTPUT... macros. */
1901 #ifdef ASM_OUTPUT_CHAR
1903 ASM_OUTPUT_CHAR (asm_out_file
, x
);
1907 #ifdef ASM_OUTPUT_SHORT
1909 ASM_OUTPUT_SHORT (asm_out_file
, x
);
1913 #ifdef ASM_OUTPUT_INT
1915 ASM_OUTPUT_INT (asm_out_file
, x
);
1919 #ifdef ASM_OUTPUT_DOUBLE_INT
1921 ASM_OUTPUT_DOUBLE_INT (asm_out_file
, x
);
1925 #ifdef ASM_OUTPUT_QUADRUPLE_INT
1927 ASM_OUTPUT_QUADRUPLE_INT (asm_out_file
, x
);
1932 /* If we couldn't do it that way, there are two other possibilities: First,
1933 if the machine can output an explicit byte and this is a 1 byte constant,
1934 we can use ASM_OUTPUT_BYTE. */
1936 #ifdef ASM_OUTPUT_BYTE
1937 if (size
== 1 && GET_CODE (x
) == CONST_INT
)
1939 ASM_OUTPUT_BYTE (asm_out_file
, INTVAL (x
));
1944 /* Finally, if SIZE is larger than a single word, try to output the constant
1945 one word at a time. */
1947 if (size
> UNITS_PER_WORD
)
1950 enum machine_mode mode
1951 = mode_for_size (size
* BITS_PER_UNIT
, MODE_INT
, 0);
1954 for (i
= 0; i
< size
/ UNITS_PER_WORD
; i
++)
1956 word
= operand_subword (x
, i
, 0, mode
);
1961 if (! assemble_integer (word
, UNITS_PER_WORD
, 0))
1965 if (i
== size
/ UNITS_PER_WORD
)
1967 /* If we output at least one word and then could not finish,
1968 there is no valid way to continue. */
1979 /* Assemble the floating-point constant D into an object of size MODE. */
1982 assemble_real (d
, mode
)
1984 enum machine_mode mode
;
1986 jmp_buf output_constant_handler
;
1988 if (setjmp (output_constant_handler
))
1990 error ("floating point trap outputting a constant");
1991 #ifdef REAL_IS_NOT_DOUBLE
1992 bzero ((char *) &d
, sizeof d
);
1999 set_float_handler (output_constant_handler
);
2003 #ifdef ASM_OUTPUT_BYTE_FLOAT
2005 ASM_OUTPUT_BYTE_FLOAT (asm_out_file
, d
);
2008 #ifdef ASM_OUTPUT_SHORT_FLOAT
2010 ASM_OUTPUT_SHORT_FLOAT (asm_out_file
, d
);
2013 #ifdef ASM_OUTPUT_THREE_QUARTER_FLOAT
2015 ASM_OUTPUT_THREE_QUARTER_FLOAT (asm_out_file
, d
);
2018 #ifdef ASM_OUTPUT_FLOAT
2020 ASM_OUTPUT_FLOAT (asm_out_file
, d
);
2024 #ifdef ASM_OUTPUT_DOUBLE
2026 ASM_OUTPUT_DOUBLE (asm_out_file
, d
);
2030 #ifdef ASM_OUTPUT_LONG_DOUBLE
2033 ASM_OUTPUT_LONG_DOUBLE (asm_out_file
, d
);
2041 set_float_handler (NULL_PTR
);
2044 /* Here we combine duplicate floating constants to make
2045 CONST_DOUBLE rtx's, and force those out to memory when necessary. */
2047 /* Return a CONST_DOUBLE or CONST_INT for a value specified as a pair of ints.
2048 For an integer, I0 is the low-order word and I1 is the high-order word.
2049 For a real number, I0 is the word with the low address
2050 and I1 is the word with the high address. */
2053 immed_double_const (i0
, i1
, mode
)
2054 HOST_WIDE_INT i0
, i1
;
2055 enum machine_mode mode
;
2059 if (GET_MODE_CLASS (mode
) == MODE_INT
2060 || GET_MODE_CLASS (mode
) == MODE_PARTIAL_INT
)
2062 /* We clear out all bits that don't belong in MODE, unless they and our
2063 sign bit are all one. So we get either a reasonable negative value
2064 or a reasonable unsigned value for this mode. */
2065 int width
= GET_MODE_BITSIZE (mode
);
2066 if (width
< HOST_BITS_PER_WIDE_INT
2067 && ((i0
& ((HOST_WIDE_INT
) (-1) << (width
- 1)))
2068 != ((HOST_WIDE_INT
) (-1) << (width
- 1))))
2069 i0
&= ((HOST_WIDE_INT
) 1 << width
) - 1, i1
= 0;
2070 else if (width
== HOST_BITS_PER_WIDE_INT
2071 && ! (i1
== ~0 && i0
< 0))
2073 else if (width
> 2 * HOST_BITS_PER_WIDE_INT
)
2074 /* We cannot represent this value as a constant. */
2077 /* If this would be an entire word for the target, but is not for
2078 the host, then sign-extend on the host so that the number will look
2079 the same way on the host that it would on the target.
2081 For example, when building a 64 bit alpha hosted 32 bit sparc
2082 targeted compiler, then we want the 32 bit unsigned value -1 to be
2083 represented as a 64 bit value -1, and not as 0x00000000ffffffff.
2084 The later confuses the sparc backend. */
2086 if (BITS_PER_WORD
< HOST_BITS_PER_WIDE_INT
&& BITS_PER_WORD
== width
2087 && (i0
& ((HOST_WIDE_INT
) 1 << (width
- 1))))
2088 i0
|= ((HOST_WIDE_INT
) (-1) << width
);
2090 /* If MODE fits within HOST_BITS_PER_WIDE_INT, always use a CONST_INT.
2092 ??? Strictly speaking, this is wrong if we create a CONST_INT
2093 for a large unsigned constant with the size of MODE being
2094 HOST_BITS_PER_WIDE_INT and later try to interpret that constant in a
2095 wider mode. In that case we will mis-interpret it as a negative
2098 Unfortunately, the only alternative is to make a CONST_DOUBLE
2099 for any constant in any mode if it is an unsigned constant larger
2100 than the maximum signed integer in an int on the host. However,
2101 doing this will break everyone that always expects to see a CONST_INT
2102 for SImode and smaller.
2104 We have always been making CONST_INTs in this case, so nothing new
2107 if (width
<= HOST_BITS_PER_WIDE_INT
)
2108 i1
= (i0
< 0) ? ~(HOST_WIDE_INT
) 0 : 0;
2110 /* If this integer fits in one word, return a CONST_INT. */
2111 if ((i1
== 0 && i0
>= 0)
2112 || (i1
== ~0 && i0
< 0))
2113 return GEN_INT (i0
);
2115 /* We use VOIDmode for integers. */
2119 /* Search the chain for an existing CONST_DOUBLE with the right value.
2120 If one is found, return it. */
2121 if (current_function
!= 0)
2122 for (r
= const_double_chain
; r
; r
= CONST_DOUBLE_CHAIN (r
))
2123 if (CONST_DOUBLE_LOW (r
) == i0
&& CONST_DOUBLE_HIGH (r
) == i1
2124 && GET_MODE (r
) == mode
)
2127 /* No; make a new one and add it to the chain.
2129 We may be called by an optimizer which may be discarding any memory
2130 allocated during its processing (such as combine and loop). However,
2131 we will be leaving this constant on the chain, so we cannot tolerate
2132 freed memory. So switch to saveable_obstack for this allocation
2133 and then switch back if we were in current_obstack. */
2135 push_obstacks_nochange ();
2136 rtl_in_saveable_obstack ();
2137 r
= gen_rtx_CONST_DOUBLE (mode
, NULL_RTX
, i0
, i1
);
2140 /* Don't touch const_double_chain if not inside any function. */
2141 if (current_function_decl
!= 0)
2143 CONST_DOUBLE_CHAIN (r
) = const_double_chain
;
2144 const_double_chain
= r
;
2147 /* Store const0_rtx in mem-slot since this CONST_DOUBLE is on the chain.
2148 Actual use of mem-slot is only through force_const_mem. */
2150 CONST_DOUBLE_MEM (r
) = const0_rtx
;
2155 /* Return a CONST_DOUBLE for a specified `double' value
2156 and machine mode. */
2159 immed_real_const_1 (d
, mode
)
2161 enum machine_mode mode
;
2163 union real_extract u
;
2166 /* Get the desired `double' value as a sequence of ints
2167 since that is how they are stored in a CONST_DOUBLE. */
2171 /* Detect special cases. */
2173 if (REAL_VALUES_IDENTICAL (dconst0
, d
))
2174 return CONST0_RTX (mode
);
2175 /* Check for NaN first, because some ports (specifically the i386) do not
2176 emit correct ieee-fp code by default, and thus will generate a core
2177 dump here if we pass a NaN to REAL_VALUES_EQUAL and if REAL_VALUES_EQUAL
2178 does a floating point comparison. */
2179 else if (! REAL_VALUE_ISNAN (d
) && REAL_VALUES_EQUAL (dconst1
, d
))
2180 return CONST1_RTX (mode
);
2182 if (sizeof u
== sizeof (HOST_WIDE_INT
))
2183 return immed_double_const (u
.i
[0], 0, mode
);
2184 if (sizeof u
== 2 * sizeof (HOST_WIDE_INT
))
2185 return immed_double_const (u
.i
[0], u
.i
[1], mode
);
2187 /* The rest of this function handles the case where
2188 a float value requires more than 2 ints of space.
2189 It will be deleted as dead code on machines that don't need it. */
2191 /* Search the chain for an existing CONST_DOUBLE with the right value.
2192 If one is found, return it. */
2193 if (current_function
!= 0)
2194 for (r
= const_double_chain
; r
; r
= CONST_DOUBLE_CHAIN (r
))
2195 if (! bcmp ((char *) &CONST_DOUBLE_LOW (r
), (char *) &u
, sizeof u
)
2196 && GET_MODE (r
) == mode
)
2199 /* No; make a new one and add it to the chain.
2201 We may be called by an optimizer which may be discarding any memory
2202 allocated during its processing (such as combine and loop). However,
2203 we will be leaving this constant on the chain, so we cannot tolerate
2204 freed memory. So switch to saveable_obstack for this allocation
2205 and then switch back if we were in current_obstack. */
2206 push_obstacks_nochange ();
2207 rtl_in_saveable_obstack ();
2208 r
= rtx_alloc (CONST_DOUBLE
);
2211 bcopy ((char *) &u
, (char *) &CONST_DOUBLE_LOW (r
), sizeof u
);
2213 /* Don't touch const_double_chain if not inside any function. */
2214 if (current_function_decl
!= 0)
2216 CONST_DOUBLE_CHAIN (r
) = const_double_chain
;
2217 const_double_chain
= r
;
2220 /* Store const0_rtx in CONST_DOUBLE_MEM since this CONST_DOUBLE is on the
2221 chain, but has not been allocated memory. Actual use of CONST_DOUBLE_MEM
2222 is only through force_const_mem. */
2224 CONST_DOUBLE_MEM (r
) = const0_rtx
;
2229 /* Return a CONST_DOUBLE rtx for a value specified by EXP,
2230 which must be a REAL_CST tree node. */
2233 immed_real_const (exp
)
2236 return immed_real_const_1 (TREE_REAL_CST (exp
), TYPE_MODE (TREE_TYPE (exp
)));
2239 /* At the end of a function, forget the memory-constants
2240 previously made for CONST_DOUBLEs. Mark them as not on real_constant_chain.
2241 Also clear out real_constant_chain and clear out all the chain-pointers. */
2244 clear_const_double_mem ()
2246 register rtx r
, next
;
2248 for (r
= const_double_chain
; r
; r
= next
)
2250 next
= CONST_DOUBLE_CHAIN (r
);
2251 CONST_DOUBLE_CHAIN (r
) = 0;
2252 CONST_DOUBLE_MEM (r
) = cc0_rtx
;
2254 const_double_chain
= 0;
2257 /* Given an expression EXP with a constant value,
2258 reduce it to the sum of an assembler symbol and an integer.
2259 Store them both in the structure *VALUE.
2260 Abort if EXP does not reduce. */
2265 HOST_WIDE_INT offset
;
2269 decode_addr_const (exp
, value
)
2271 struct addr_const
*value
;
2273 register tree target
= TREE_OPERAND (exp
, 0);
2274 register int offset
= 0;
2279 if (TREE_CODE (target
) == COMPONENT_REF
2280 && (TREE_CODE (DECL_FIELD_BITPOS (TREE_OPERAND (target
, 1)))
2283 offset
+= TREE_INT_CST_LOW (DECL_FIELD_BITPOS (TREE_OPERAND (target
, 1))) / BITS_PER_UNIT
;
2284 target
= TREE_OPERAND (target
, 0);
2286 else if (TREE_CODE (target
) == ARRAY_REF
)
2288 if (TREE_CODE (TREE_OPERAND (target
, 1)) != INTEGER_CST
2289 || TREE_CODE (TYPE_SIZE (TREE_TYPE (target
))) != INTEGER_CST
)
2291 offset
+= ((TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (target
)))
2292 * TREE_INT_CST_LOW (TREE_OPERAND (target
, 1)))
2294 target
= TREE_OPERAND (target
, 0);
2300 switch (TREE_CODE (target
))
2304 x
= DECL_RTL (target
);
2308 x
= gen_rtx_MEM (FUNCTION_MODE
,
2309 gen_rtx_LABEL_REF (VOIDmode
,
2310 label_rtx (TREE_OPERAND (exp
, 0))));
2318 x
= TREE_CST_RTL (target
);
2325 if (GET_CODE (x
) != MEM
)
2330 value
->offset
= offset
;
2333 /* Uniquize all constants that appear in memory.
2334 Each constant in memory thus far output is recorded
2335 in `const_hash_table' with a `struct constant_descriptor'
2336 that contains a polish representation of the value of
2339 We cannot store the trees in the hash table
2340 because the trees may be temporary. */
2342 struct constant_descriptor
2344 struct constant_descriptor
*next
;
2350 #define MAX_HASH_TABLE 1009
2351 static struct constant_descriptor
*const_hash_table
[MAX_HASH_TABLE
];
2353 /* Mark a const_hash_table descriptor for GC. */
2356 mark_const_hash_entry (ptr
)
2359 struct constant_descriptor
*desc
= * (struct constant_descriptor
**) ptr
;
2363 ggc_mark_string (desc
->label
);
2368 /* Compute a hash code for a constant expression. */
2375 register int len
, hi
, i
;
2376 register enum tree_code code
= TREE_CODE (exp
);
2378 /* Either set P and LEN to the address and len of something to hash and
2379 exit the switch or return a value. */
2384 p
= (char *) &TREE_INT_CST_LOW (exp
);
2385 len
= 2 * sizeof TREE_INT_CST_LOW (exp
);
2389 p
= (char *) &TREE_REAL_CST (exp
);
2390 len
= sizeof TREE_REAL_CST (exp
);
2394 p
= TREE_STRING_POINTER (exp
);
2395 len
= TREE_STRING_LENGTH (exp
);
2399 return (const_hash (TREE_REALPART (exp
)) * 5
2400 + const_hash (TREE_IMAGPART (exp
)));
2403 if (TREE_CODE (TREE_TYPE (exp
)) == SET_TYPE
)
2405 len
= int_size_in_bytes (TREE_TYPE (exp
));
2406 p
= (char *) alloca (len
);
2407 get_set_constructor_bytes (exp
, (unsigned char *) p
, len
);
2414 /* For record type, include the type in the hashing.
2415 We do not do so for array types
2416 because (1) the sizes of the elements are sufficient
2417 and (2) distinct array types can have the same constructor.
2418 Instead, we include the array size because the constructor could
2420 if (TREE_CODE (TREE_TYPE (exp
)) == RECORD_TYPE
)
2421 hi
= ((unsigned long) TREE_TYPE (exp
) & ((1 << HASHBITS
) - 1))
2424 hi
= ((5 + int_size_in_bytes (TREE_TYPE (exp
)))
2425 & ((1 << HASHBITS
) - 1)) % MAX_HASH_TABLE
;
2427 for (link
= CONSTRUCTOR_ELTS (exp
); link
; link
= TREE_CHAIN (link
))
2428 if (TREE_VALUE (link
))
2430 = (hi
* 603 + const_hash (TREE_VALUE (link
))) % MAX_HASH_TABLE
;
2437 struct addr_const value
;
2439 decode_addr_const (exp
, &value
);
2440 if (GET_CODE (value
.base
) == SYMBOL_REF
)
2442 /* Don't hash the address of the SYMBOL_REF;
2443 only use the offset and the symbol name. */
2445 p
= XSTR (value
.base
, 0);
2446 for (i
= 0; p
[i
] != 0; i
++)
2447 hi
= ((hi
* 613) + (unsigned) (p
[i
]));
2449 else if (GET_CODE (value
.base
) == LABEL_REF
)
2450 hi
= value
.offset
+ CODE_LABEL_NUMBER (XEXP (value
.base
, 0)) * 13;
2454 hi
&= (1 << HASHBITS
) - 1;
2455 hi
%= MAX_HASH_TABLE
;
2461 return (const_hash (TREE_OPERAND (exp
, 0)) * 9
2462 + const_hash (TREE_OPERAND (exp
, 1)));
2466 case NON_LVALUE_EXPR
:
2467 return const_hash (TREE_OPERAND (exp
, 0)) * 7 + 2;
2473 /* Compute hashing function */
2475 for (i
= 0; i
< len
; i
++)
2476 hi
= ((hi
* 613) + (unsigned) (p
[i
]));
2478 hi
&= (1 << HASHBITS
) - 1;
2479 hi
%= MAX_HASH_TABLE
;
2483 /* Compare a constant expression EXP with a constant-descriptor DESC.
2484 Return 1 if DESC describes a constant with the same value as EXP. */
2487 compare_constant (exp
, desc
)
2489 struct constant_descriptor
*desc
;
2491 return 0 != compare_constant_1 (exp
, desc
->contents
);
2494 /* Compare constant expression EXP with a substring P of a constant descriptor.
2495 If they match, return a pointer to the end of the substring matched.
2496 If they do not match, return 0.
2498 Since descriptors are written in polish prefix notation,
2499 this function can be used recursively to test one operand of EXP
2500 against a subdescriptor, and if it succeeds it returns the
2501 address of the subdescriptor for the next operand. */
2504 compare_constant_1 (exp
, p
)
2508 register char *strp
;
2510 register enum tree_code code
= TREE_CODE (exp
);
2512 if (code
!= (enum tree_code
) *p
++)
2515 /* Either set STRP, P and LEN to pointers and length to compare and exit the
2516 switch, or return the result of the comparison. */
2521 /* Integer constants are the same only if the same width of type. */
2522 if (*p
++ != TYPE_PRECISION (TREE_TYPE (exp
)))
2525 strp
= (char *) &TREE_INT_CST_LOW (exp
);
2526 len
= 2 * sizeof TREE_INT_CST_LOW (exp
);
2530 /* Real constants are the same only if the same width of type. */
2531 if (*p
++ != TYPE_PRECISION (TREE_TYPE (exp
)))
2534 strp
= (char *) &TREE_REAL_CST (exp
);
2535 len
= sizeof TREE_REAL_CST (exp
);
2539 if (flag_writable_strings
)
2542 if (*p
++ != TYPE_MODE (TREE_TYPE (exp
)))
2545 strp
= TREE_STRING_POINTER (exp
);
2546 len
= TREE_STRING_LENGTH (exp
);
2547 if (bcmp ((char *) &TREE_STRING_LENGTH (exp
), p
,
2548 sizeof TREE_STRING_LENGTH (exp
)))
2551 p
+= sizeof TREE_STRING_LENGTH (exp
);
2555 p
= compare_constant_1 (TREE_REALPART (exp
), p
);
2559 return compare_constant_1 (TREE_IMAGPART (exp
), p
);
2562 if (TREE_CODE (TREE_TYPE (exp
)) == SET_TYPE
)
2564 int xlen
= len
= int_size_in_bytes (TREE_TYPE (exp
));
2566 strp
= (char *) alloca (len
);
2567 get_set_constructor_bytes (exp
, (unsigned char *) strp
, len
);
2568 if (bcmp ((char *) &xlen
, p
, sizeof xlen
))
2577 int length
= list_length (CONSTRUCTOR_ELTS (exp
));
2579 int have_purpose
= 0;
2581 for (link
= CONSTRUCTOR_ELTS (exp
); link
; link
= TREE_CHAIN (link
))
2582 if (TREE_PURPOSE (link
))
2585 if (bcmp ((char *) &length
, p
, sizeof length
))
2590 /* For record constructors, insist that the types match.
2591 For arrays, just verify both constructors are for arrays.
2592 Then insist that either both or none have any TREE_PURPOSE
2594 if (TREE_CODE (TREE_TYPE (exp
)) == RECORD_TYPE
)
2595 type
= TREE_TYPE (exp
);
2599 if (bcmp ((char *) &type
, p
, sizeof type
))
2604 if (bcmp ((char *) &have_purpose
, p
, sizeof have_purpose
))
2607 p
+= sizeof have_purpose
;
2609 /* For arrays, insist that the size in bytes match. */
2610 if (TREE_CODE (TREE_TYPE (exp
)) == ARRAY_TYPE
)
2612 HOST_WIDE_INT size
= int_size_in_bytes (TREE_TYPE (exp
));
2614 if (bcmp ((char *) &size
, p
, sizeof size
))
2620 for (link
= CONSTRUCTOR_ELTS (exp
); link
; link
= TREE_CHAIN (link
))
2622 if (TREE_VALUE (link
))
2624 if ((p
= compare_constant_1 (TREE_VALUE (link
), p
)) == 0)
2631 if (bcmp ((char *) &zero
, p
, sizeof zero
))
2637 if (TREE_PURPOSE (link
)
2638 && TREE_CODE (TREE_PURPOSE (link
)) == FIELD_DECL
)
2640 if (bcmp ((char *) &TREE_PURPOSE (link
), p
,
2641 sizeof TREE_PURPOSE (link
)))
2644 p
+= sizeof TREE_PURPOSE (link
);
2646 else if (TREE_PURPOSE (link
))
2648 if ((p
= compare_constant_1 (TREE_PURPOSE (link
), p
)) == 0)
2651 else if (have_purpose
)
2655 if (bcmp ((char *) &zero
, p
, sizeof zero
))
2667 struct addr_const value
;
2669 decode_addr_const (exp
, &value
);
2670 strp
= (char *) &value
.offset
;
2671 len
= sizeof value
.offset
;
2672 /* Compare the offset. */
2674 if (*p
++ != *strp
++)
2677 /* Compare symbol name. */
2678 strp
= XSTR (value
.base
, 0);
2679 len
= strlen (strp
) + 1;
2686 p
= compare_constant_1 (TREE_OPERAND (exp
, 0), p
);
2690 return compare_constant_1 (TREE_OPERAND (exp
, 1), p
);
2694 case NON_LVALUE_EXPR
:
2695 return compare_constant_1 (TREE_OPERAND (exp
, 0), p
);
2701 /* Compare constant contents. */
2703 if (*p
++ != *strp
++)
2709 /* Construct a constant descriptor for the expression EXP.
2710 It is up to the caller to enter the descriptor in the hash table. */
2712 static struct constant_descriptor
*
2713 record_constant (exp
)
2716 struct constant_descriptor
*next
= 0;
2719 /* Make a struct constant_descriptor. The first two pointers will
2720 be filled in later. Here we just leave space for them. */
2722 obstack_grow (&permanent_obstack
, (char *) &next
, sizeof next
);
2723 obstack_grow (&permanent_obstack
, (char *) &label
, sizeof label
);
2724 record_constant_1 (exp
);
2725 return (struct constant_descriptor
*) obstack_finish (&permanent_obstack
);
2728 /* Add a description of constant expression EXP
2729 to the object growing in `permanent_obstack'.
2730 No need to return its address; the caller will get that
2731 from the obstack when the object is complete. */
2734 record_constant_1 (exp
)
2737 register char *strp
;
2739 register enum tree_code code
= TREE_CODE (exp
);
2741 obstack_1grow (&permanent_obstack
, (unsigned int) code
);
2746 obstack_1grow (&permanent_obstack
, TYPE_PRECISION (TREE_TYPE (exp
)));
2747 strp
= (char *) &TREE_INT_CST_LOW (exp
);
2748 len
= 2 * sizeof TREE_INT_CST_LOW (exp
);
2752 obstack_1grow (&permanent_obstack
, TYPE_PRECISION (TREE_TYPE (exp
)));
2753 strp
= (char *) &TREE_REAL_CST (exp
);
2754 len
= sizeof TREE_REAL_CST (exp
);
2758 if (flag_writable_strings
)
2761 obstack_1grow (&permanent_obstack
, TYPE_MODE (TREE_TYPE (exp
)));
2762 strp
= TREE_STRING_POINTER (exp
);
2763 len
= TREE_STRING_LENGTH (exp
);
2764 obstack_grow (&permanent_obstack
, (char *) &TREE_STRING_LENGTH (exp
),
2765 sizeof TREE_STRING_LENGTH (exp
));
2769 record_constant_1 (TREE_REALPART (exp
));
2770 record_constant_1 (TREE_IMAGPART (exp
));
2774 if (TREE_CODE (TREE_TYPE (exp
)) == SET_TYPE
)
2776 int nbytes
= int_size_in_bytes (TREE_TYPE (exp
));
2777 obstack_grow (&permanent_obstack
, &nbytes
, sizeof (nbytes
));
2778 obstack_blank (&permanent_obstack
, nbytes
);
2779 get_set_constructor_bytes
2780 (exp
, (unsigned char *) permanent_obstack
.next_free
-nbytes
,
2787 int length
= list_length (CONSTRUCTOR_ELTS (exp
));
2789 int have_purpose
= 0;
2791 for (link
= CONSTRUCTOR_ELTS (exp
); link
; link
= TREE_CHAIN (link
))
2792 if (TREE_PURPOSE (link
))
2795 obstack_grow (&permanent_obstack
, (char *) &length
, sizeof length
);
2797 /* For record constructors, insist that the types match.
2798 For arrays, just verify both constructors are for arrays.
2799 Then insist that either both or none have any TREE_PURPOSE
2801 if (TREE_CODE (TREE_TYPE (exp
)) == RECORD_TYPE
)
2802 type
= TREE_TYPE (exp
);
2805 obstack_grow (&permanent_obstack
, (char *) &type
, sizeof type
);
2806 obstack_grow (&permanent_obstack
, (char *) &have_purpose
,
2807 sizeof have_purpose
);
2809 /* For arrays, insist that the size in bytes match. */
2810 if (TREE_CODE (TREE_TYPE (exp
)) == ARRAY_TYPE
)
2812 HOST_WIDE_INT size
= int_size_in_bytes (TREE_TYPE (exp
));
2813 obstack_grow (&permanent_obstack
, (char *) &size
, sizeof size
);
2816 for (link
= CONSTRUCTOR_ELTS (exp
); link
; link
= TREE_CHAIN (link
))
2818 if (TREE_VALUE (link
))
2819 record_constant_1 (TREE_VALUE (link
));
2824 obstack_grow (&permanent_obstack
,
2825 (char *) &zero
, sizeof zero
);
2828 if (TREE_PURPOSE (link
)
2829 && TREE_CODE (TREE_PURPOSE (link
)) == FIELD_DECL
)
2830 obstack_grow (&permanent_obstack
,
2831 (char *) &TREE_PURPOSE (link
),
2832 sizeof TREE_PURPOSE (link
));
2833 else if (TREE_PURPOSE (link
))
2834 record_constant_1 (TREE_PURPOSE (link
));
2835 else if (have_purpose
)
2839 obstack_grow (&permanent_obstack
,
2840 (char *) &zero
, sizeof zero
);
2848 struct addr_const value
;
2850 decode_addr_const (exp
, &value
);
2851 /* Record the offset. */
2852 obstack_grow (&permanent_obstack
,
2853 (char *) &value
.offset
, sizeof value
.offset
);
2854 /* Record the symbol name. */
2855 obstack_grow (&permanent_obstack
, XSTR (value
.base
, 0),
2856 strlen (XSTR (value
.base
, 0)) + 1);
2863 record_constant_1 (TREE_OPERAND (exp
, 0));
2864 record_constant_1 (TREE_OPERAND (exp
, 1));
2869 case NON_LVALUE_EXPR
:
2870 record_constant_1 (TREE_OPERAND (exp
, 0));
2877 /* Record constant contents. */
2878 obstack_grow (&permanent_obstack
, strp
, len
);
2881 /* Record a list of constant expressions that were passed to
2882 output_constant_def but that could not be output right away. */
2884 struct deferred_constant
2886 struct deferred_constant
*next
;
2892 static struct deferred_constant
*deferred_constants
;
2894 /* Another list of constants which should be output after the
2896 static struct deferred_constant
*after_function_constants
;
2898 /* Nonzero means defer output of addressed subconstants
2899 (i.e., those for which output_constant_def is called.) */
2900 static int defer_addressed_constants_flag
;
2902 /* Start deferring output of subconstants. */
2905 defer_addressed_constants ()
2907 defer_addressed_constants_flag
++;
2910 /* Stop deferring output of subconstants,
2911 and output now all those that have been deferred. */
2914 output_deferred_addressed_constants ()
2916 struct deferred_constant
*p
, *next
;
2918 defer_addressed_constants_flag
--;
2920 if (defer_addressed_constants_flag
> 0)
2923 for (p
= deferred_constants
; p
; p
= next
)
2925 output_constant_def_contents (p
->exp
, p
->reloc
, p
->labelno
);
2930 deferred_constants
= 0;
2933 /* Output any constants which should appear after a function. */
2936 output_after_function_constants ()
2938 struct deferred_constant
*p
, *next
;
2940 for (p
= after_function_constants
; p
; p
= next
)
2942 output_constant_def_contents (p
->exp
, p
->reloc
, p
->labelno
);
2947 after_function_constants
= 0;
2950 /* Make a copy of the whole tree structure for a constant.
2951 This handles the same types of nodes that compare_constant
2952 and record_constant handle. */
2958 switch (TREE_CODE (exp
))
2961 /* For ADDR_EXPR, we do not want to copy the decl whose address
2962 is requested. We do want to copy constants though. */
2963 if (TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp
, 0))) == 'c')
2964 return build1 (TREE_CODE (exp
), TREE_TYPE (exp
),
2965 copy_constant (TREE_OPERAND (exp
, 0)));
2967 return copy_node (exp
);
2972 return copy_node (exp
);
2975 return build_complex (TREE_TYPE (exp
),
2976 copy_constant (TREE_REALPART (exp
)),
2977 copy_constant (TREE_IMAGPART (exp
)));
2981 return build (TREE_CODE (exp
), TREE_TYPE (exp
),
2982 copy_constant (TREE_OPERAND (exp
, 0)),
2983 copy_constant (TREE_OPERAND (exp
, 1)));
2987 case NON_LVALUE_EXPR
:
2988 return build1 (TREE_CODE (exp
), TREE_TYPE (exp
),
2989 copy_constant (TREE_OPERAND (exp
, 0)));
2993 tree copy
= copy_node (exp
);
2994 tree list
= copy_list (CONSTRUCTOR_ELTS (exp
));
2997 CONSTRUCTOR_ELTS (copy
) = list
;
2998 for (tail
= list
; tail
; tail
= TREE_CHAIN (tail
))
2999 TREE_VALUE (tail
) = copy_constant (TREE_VALUE (tail
));
3000 if (TREE_CODE (TREE_TYPE (exp
)) == SET_TYPE
)
3001 for (tail
= list
; tail
; tail
= TREE_CHAIN (tail
))
3002 TREE_PURPOSE (tail
) = copy_constant (TREE_PURPOSE (tail
));
3012 /* Return an rtx representing a reference to constant data in memory
3013 for the constant expression EXP.
3015 If assembler code for such a constant has already been output,
3016 return an rtx to refer to it.
3017 Otherwise, output such a constant in memory (or defer it for later)
3018 and generate an rtx for it.
3020 The TREE_CST_RTL of EXP is set up to point to that rtx.
3021 The const_hash_table records which constants already have label strings. */
3024 output_constant_def (exp
)
3028 register struct constant_descriptor
*desc
;
3034 if (TREE_CST_RTL (exp
))
3035 return TREE_CST_RTL (exp
);
3037 /* Make sure any other constants whose addresses appear in EXP
3038 are assigned label numbers. */
3040 reloc
= output_addressed_constants (exp
);
3042 /* Compute hash code of EXP. Search the descriptors for that hash code
3043 to see if any of them describes EXP. If yes, the descriptor records
3044 the label number already assigned. */
3046 hash
= const_hash (exp
) % MAX_HASH_TABLE
;
3048 for (desc
= const_hash_table
[hash
]; desc
; desc
= desc
->next
)
3049 if (compare_constant (exp
, desc
))
3051 found
= desc
->label
;
3057 /* No constant equal to EXP is known to have been output.
3058 Make a constant descriptor to enter EXP in the hash table.
3059 Assign the label number and record it in the descriptor for
3060 future calls to this function to find. */
3062 /* Create a string containing the label name, in LABEL. */
3063 ASM_GENERATE_INTERNAL_LABEL (label
, "LC", const_labelno
);
3065 desc
= record_constant (exp
);
3066 desc
->next
= const_hash_table
[hash
];
3067 desc
->label
= ggc_alloc_string (label
, -1);
3068 const_hash_table
[hash
] = desc
;
3071 /* We have a symbol name; construct the SYMBOL_REF and the MEM. */
3073 push_obstacks_nochange ();
3074 if (TREE_PERMANENT (exp
))
3075 end_temporary_allocation ();
3077 def
= gen_rtx_SYMBOL_REF (Pmode
, desc
->label
);
3080 = gen_rtx_MEM (TYPE_MODE (TREE_TYPE (exp
)), def
);
3081 RTX_UNCHANGING_P (TREE_CST_RTL (exp
)) = 1;
3082 if (AGGREGATE_TYPE_P (TREE_TYPE (exp
)))
3083 MEM_SET_IN_STRUCT_P (TREE_CST_RTL (exp
), 1);
3087 /* Optionally set flags or add text to the name to record information
3088 such as that it is a function name. If the name is changed, the macro
3089 ASM_OUTPUT_LABELREF will have to know how to strip this information. */
3090 #ifdef ENCODE_SECTION_INFO
3091 ENCODE_SECTION_INFO (exp
);
3094 /* If this is the first time we've seen this particular constant,
3095 output it (or defer its output for later). */
3098 int after_function
= 0;
3100 #ifdef CONSTANT_AFTER_FUNCTION_P
3101 if (current_function_decl
!= 0
3102 && CONSTANT_AFTER_FUNCTION_P (exp
))
3106 if (defer_addressed_constants_flag
|| after_function
)
3108 struct deferred_constant
*p
;
3109 p
= (struct deferred_constant
*) xmalloc (sizeof (struct deferred_constant
));
3111 push_obstacks_nochange ();
3112 suspend_momentary ();
3113 p
->exp
= copy_constant (exp
);
3116 p
->labelno
= const_labelno
++;
3119 p
->next
= after_function_constants
;
3120 after_function_constants
= p
;
3124 p
->next
= deferred_constants
;
3125 deferred_constants
= p
;
3130 /* Do no output if -fsyntax-only. */
3131 if (! flag_syntax_only
)
3132 output_constant_def_contents (exp
, reloc
, const_labelno
);
3137 return TREE_CST_RTL (exp
);
3140 /* Now output assembler code to define the label for EXP,
3141 and follow it with the data of EXP. */
3144 output_constant_def_contents (exp
, reloc
, labelno
)
3151 if (IN_NAMED_SECTION (exp
))
3152 named_section (exp
, NULL
, reloc
);
3155 /* First switch to text section, except for writable strings. */
3156 #ifdef SELECT_SECTION
3157 SELECT_SECTION (exp
, reloc
);
3159 if (((TREE_CODE (exp
) == STRING_CST
) && flag_writable_strings
)
3160 || (flag_pic
&& reloc
))
3163 readonly_data_section ();
3167 /* Align the location counter as required by EXP's data type. */
3168 align
= TYPE_ALIGN (TREE_TYPE (exp
));
3169 #ifdef CONSTANT_ALIGNMENT
3170 align
= CONSTANT_ALIGNMENT (exp
, align
);
3173 if (align
> BITS_PER_UNIT
)
3174 ASM_OUTPUT_ALIGN (asm_out_file
, floor_log2 (align
/ BITS_PER_UNIT
));
3176 /* Output the label itself. */
3177 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, "LC", labelno
);
3179 /* Output the value of EXP. */
3180 output_constant (exp
,
3181 (TREE_CODE (exp
) == STRING_CST
3182 ? TREE_STRING_LENGTH (exp
)
3183 : int_size_in_bytes (TREE_TYPE (exp
))));
3187 /* Structure to represent sufficient information about a constant so that
3188 it can be output when the constant pool is output, so that function
3189 integration can be done, and to simplify handling on machines that reference
3190 constant pool as base+displacement. */
3192 struct pool_constant
3194 struct constant_descriptor
*desc
;
3195 struct pool_constant
*next
;
3196 enum machine_mode mode
;
3204 /* Structure used to maintain hash table mapping symbols used to their
3205 corresponding constants. */
3210 struct pool_constant
*pool
;
3211 struct pool_sym
*next
;
3214 /* Hash code for a SYMBOL_REF with CONSTANT_POOL_ADDRESS_P true.
3215 The argument is XSTR (... , 0) */
3217 #define SYMHASH(LABEL) \
3218 ((((unsigned long) (LABEL)) & ((1 << HASHBITS) - 1)) % MAX_RTX_HASH_TABLE)
3220 /* Initialize constant pool hashing for a new function. */
3223 init_varasm_status (f
)
3226 struct varasm_status
*p
;
3227 p
= (struct varasm_status
*) xmalloc (sizeof (struct varasm_status
));
3229 p
->x_const_rtx_hash_table
3230 = ((struct constant_descriptor
**)
3231 xmalloc (MAX_RTX_HASH_TABLE
* sizeof (struct constant_descriptor
*)));
3232 p
->x_const_rtx_sym_hash_table
3233 = ((struct pool_sym
**)
3234 xmalloc (MAX_RTX_HASH_TABLE
* sizeof (struct pool_sym
*)));
3235 bzero ((char *) p
->x_const_rtx_hash_table
,
3236 MAX_RTX_HASH_TABLE
* sizeof (struct constant_descriptor
*));
3237 bzero ((char *) p
->x_const_rtx_sym_hash_table
,
3238 MAX_RTX_HASH_TABLE
* sizeof (struct pool_sym
*));
3240 p
->x_first_pool
= p
->x_last_pool
= 0;
3241 p
->x_pool_offset
= 0;
3242 p
->x_const_double_chain
= 0;
3245 /* Mark PC for GC. */
3248 mark_pool_constant (pc
)
3249 struct pool_constant
*pc
;
3253 ggc_mark_rtx (pc
->constant
);
3258 /* Mark PPS for GC. */
3261 mark_pool_sym_hash_table (pps
)
3262 struct pool_sym
**pps
;
3264 struct pool_sym
*ps
;
3267 for (i
= 0; i
< MAX_RTX_HASH_TABLE
; ++i
)
3268 for (ps
= pps
[i
]; ps
; ps
= ps
->next
)
3269 ggc_mark_string (ps
->label
);
3272 /* Mark P for GC. */
3275 mark_varasm_status (p
)
3276 struct varasm_status
*p
;
3281 mark_pool_constant (p
->x_first_pool
);
3282 mark_pool_sym_hash_table (p
->x_const_rtx_sym_hash_table
);
3283 ggc_mark_rtx (p
->x_const_double_chain
);
3286 /* Clear out all parts of the state in F that can safely be discarded
3287 after the function has been compiled, to let garbage collection
3288 reclaim the memory. */
3291 free_varasm_status (f
)
3294 struct varasm_status
*p
;
3297 free (p
->x_const_rtx_hash_table
);
3298 free (p
->x_const_rtx_sym_hash_table
);
3303 enum kind
{ RTX_DOUBLE
, RTX_INT
};
3307 #ifdef ONLY_INT_FIELDS
3308 unsigned int kind
: 16;
3309 unsigned int mode
: 16;
3311 enum kind kind
: 16;
3312 enum machine_mode mode
: 16;
3315 union real_extract du
;
3316 struct addr_const addr
;
3317 struct {HOST_WIDE_INT high
, low
;} di
;
3321 /* Express an rtx for a constant integer (perhaps symbolic)
3322 as the sum of a symbol or label plus an explicit integer.
3323 They are stored into VALUE. */
3326 decode_rtx_const (mode
, x
, value
)
3327 enum machine_mode mode
;
3329 struct rtx_const
*value
;
3331 /* Clear the whole structure, including any gaps. */
3334 int *p
= (int *) value
;
3335 int *end
= (int *) (value
+ 1);
3340 value
->kind
= RTX_INT
; /* Most usual kind. */
3343 switch (GET_CODE (x
))
3346 value
->kind
= RTX_DOUBLE
;
3347 if (GET_MODE (x
) != VOIDmode
)
3349 value
->mode
= GET_MODE (x
);
3350 bcopy ((char *) &CONST_DOUBLE_LOW (x
),
3351 (char *) &value
->un
.du
, sizeof value
->un
.du
);
3355 value
->un
.di
.low
= CONST_DOUBLE_LOW (x
);
3356 value
->un
.di
.high
= CONST_DOUBLE_HIGH (x
);
3361 value
->un
.addr
.offset
= INTVAL (x
);
3367 value
->un
.addr
.base
= x
;
3372 if (GET_CODE (x
) == PLUS
)
3374 value
->un
.addr
.base
= XEXP (x
, 0);
3375 if (GET_CODE (XEXP (x
, 1)) != CONST_INT
)
3377 value
->un
.addr
.offset
= INTVAL (XEXP (x
, 1));
3379 else if (GET_CODE (x
) == MINUS
)
3381 value
->un
.addr
.base
= XEXP (x
, 0);
3382 if (GET_CODE (XEXP (x
, 1)) != CONST_INT
)
3384 value
->un
.addr
.offset
= - INTVAL (XEXP (x
, 1));
3394 if (value
->kind
== RTX_INT
&& value
->un
.addr
.base
!= 0)
3395 switch (GET_CODE (value
->un
.addr
.base
))
3399 /* Use the string's address, not the SYMBOL_REF's address,
3400 for the sake of addresses of library routines.
3401 For a LABEL_REF, compare labels. */
3402 value
->un
.addr
.base
= XEXP (value
->un
.addr
.base
, 0);
3409 /* Given a MINUS expression, simplify it if both sides
3410 include the same symbol. */
3413 simplify_subtraction (x
)
3416 struct rtx_const val0
, val1
;
3418 decode_rtx_const (GET_MODE (x
), XEXP (x
, 0), &val0
);
3419 decode_rtx_const (GET_MODE (x
), XEXP (x
, 1), &val1
);
3421 if (val0
.un
.addr
.base
== val1
.un
.addr
.base
)
3422 return GEN_INT (val0
.un
.addr
.offset
- val1
.un
.addr
.offset
);
3426 /* Compute a hash code for a constant RTL expression. */
3429 const_hash_rtx (mode
, x
)
3430 enum machine_mode mode
;
3436 struct rtx_const value
;
3437 decode_rtx_const (mode
, x
, &value
);
3439 /* Compute hashing function */
3441 for (i
= 0; i
< sizeof value
/ sizeof (int); i
++)
3442 hi
+= ((int *) &value
)[i
];
3444 hi
&= (1 << HASHBITS
) - 1;
3445 hi
%= MAX_RTX_HASH_TABLE
;
3449 /* Compare a constant rtl object X with a constant-descriptor DESC.
3450 Return 1 if DESC describes a constant with the same value as X. */
3453 compare_constant_rtx (mode
, x
, desc
)
3454 enum machine_mode mode
;
3456 struct constant_descriptor
*desc
;
3458 register int *p
= (int *) desc
->contents
;
3461 struct rtx_const value
;
3463 decode_rtx_const (mode
, x
, &value
);
3464 strp
= (int *) &value
;
3465 len
= sizeof value
/ sizeof (int);
3467 /* Compare constant contents. */
3469 if (*p
++ != *strp
++)
3475 /* Construct a constant descriptor for the rtl-expression X.
3476 It is up to the caller to enter the descriptor in the hash table. */
3478 static struct constant_descriptor
*
3479 record_constant_rtx (mode
, x
)
3480 enum machine_mode mode
;
3483 struct constant_descriptor
*ptr
;
3485 struct rtx_const value
;
3487 decode_rtx_const (mode
, x
, &value
);
3489 /* Put these things in the saveable obstack so we can ensure it won't
3490 be freed if we are called from combine or some other phase that discards
3491 memory allocated from function_obstack (current_obstack). */
3492 obstack_grow (saveable_obstack
, &ptr
, sizeof ptr
);
3493 obstack_grow (saveable_obstack
, &label
, sizeof label
);
3495 /* Record constant contents. */
3496 obstack_grow (saveable_obstack
, &value
, sizeof value
);
3498 return (struct constant_descriptor
*) obstack_finish (saveable_obstack
);
3501 /* Given a constant rtx X, make (or find) a memory constant for its value
3502 and return a MEM rtx to refer to it in memory. */
3505 force_const_mem (mode
, x
)
3506 enum machine_mode mode
;
3510 register struct constant_descriptor
*desc
;
3515 /* If we want this CONST_DOUBLE in the same mode as it is in memory
3516 (this will always be true for floating CONST_DOUBLEs that have been
3517 placed in memory, but not for VOIDmode (integer) CONST_DOUBLEs),
3518 use the previous copy. Otherwise, make a new one. Note that in
3519 the unlikely event that this same CONST_DOUBLE is used in two different
3520 modes in an alternating fashion, we will allocate a lot of different
3521 memory locations, but this should be extremely rare. */
3523 if (GET_CODE (x
) == CONST_DOUBLE
3524 && GET_CODE (CONST_DOUBLE_MEM (x
)) == MEM
3525 && GET_MODE (CONST_DOUBLE_MEM (x
)) == mode
)
3526 return CONST_DOUBLE_MEM (x
);
3528 /* Compute hash code of X. Search the descriptors for that hash code
3529 to see if any of them describes X. If yes, the descriptor records
3530 the label number already assigned. */
3532 hash
= const_hash_rtx (mode
, x
);
3534 for (desc
= const_rtx_hash_table
[hash
]; desc
; desc
= desc
->next
)
3535 if (compare_constant_rtx (mode
, x
, desc
))
3537 found
= desc
->label
;
3543 register struct pool_constant
*pool
;
3544 register struct pool_sym
*sym
;
3547 /* No constant equal to X is known to have been output.
3548 Make a constant descriptor to enter X in the hash table.
3549 Assign the label number and record it in the descriptor for
3550 future calls to this function to find. */
3552 desc
= record_constant_rtx (mode
, x
);
3553 desc
->next
= const_rtx_hash_table
[hash
];
3554 const_rtx_hash_table
[hash
] = desc
;
3556 /* Align the location counter as required by EXP's data type. */
3557 align
= (mode
== VOIDmode
) ? UNITS_PER_WORD
: GET_MODE_SIZE (mode
);
3558 if (align
> BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
)
3559 align
= BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
;
3560 #ifdef CONSTANT_ALIGNMENT
3561 align
= CONSTANT_ALIGNMENT (make_tree (type_for_mode (mode
, 0), x
),
3562 align
* BITS_PER_UNIT
) / BITS_PER_UNIT
;
3565 pool_offset
+= align
- 1;
3566 pool_offset
&= ~ (align
- 1);
3568 /* If RTL is not being placed into the saveable obstack, make a
3569 copy of X that is in the saveable obstack in case we are
3570 being called from combine or some other phase that discards
3571 memory it allocates. We used to only do this if it is a
3572 CONST; however, reload can allocate a CONST_INT when
3573 eliminating registers. */
3574 if (rtl_obstack
!= saveable_obstack
3575 && (GET_CODE (x
) == CONST
|| GET_CODE (x
) == CONST_INT
))
3577 push_obstacks_nochange ();
3578 rtl_in_saveable_obstack ();
3580 if (GET_CODE (x
) == CONST
)
3581 x
= gen_rtx_CONST (GET_MODE (x
),
3582 gen_rtx_PLUS (GET_MODE (x
),
3583 XEXP (XEXP (x
, 0), 0),
3584 XEXP (XEXP (x
, 0), 1)));
3586 x
= GEN_INT (INTVAL (x
));
3591 /* Allocate a pool constant descriptor, fill it in, and chain it in. */
3593 pool
= (struct pool_constant
*) savealloc (sizeof (struct pool_constant
));
3597 pool
->labelno
= const_labelno
;
3598 pool
->align
= align
;
3599 pool
->offset
= pool_offset
;
3606 last_pool
->next
= pool
;
3609 pool_offset
+= GET_MODE_SIZE (mode
);
3611 /* Create a string containing the label name, in LABEL. */
3612 ASM_GENERATE_INTERNAL_LABEL (label
, "LC", const_labelno
);
3616 desc
->label
= found
= ggc_alloc_string (label
, -1);
3618 /* Add label to symbol hash table. */
3619 hash
= SYMHASH (found
);
3620 sym
= (struct pool_sym
*) savealloc (sizeof (struct pool_sym
));
3623 sym
->next
= const_rtx_sym_hash_table
[hash
];
3624 const_rtx_sym_hash_table
[hash
] = sym
;
3627 /* We have a symbol name; construct the SYMBOL_REF and the MEM. */
3629 def
= gen_rtx_MEM (mode
, gen_rtx_SYMBOL_REF (Pmode
, found
));
3631 RTX_UNCHANGING_P (def
) = 1;
3632 /* Mark the symbol_ref as belonging to this constants pool. */
3633 CONSTANT_POOL_ADDRESS_P (XEXP (def
, 0)) = 1;
3634 current_function_uses_const_pool
= 1;
3636 if (GET_CODE (x
) == CONST_DOUBLE
)
3638 if (CONST_DOUBLE_MEM (x
) == cc0_rtx
)
3640 CONST_DOUBLE_CHAIN (x
) = const_double_chain
;
3641 const_double_chain
= x
;
3643 CONST_DOUBLE_MEM (x
) = def
;
3649 /* Given a SYMBOL_REF with CONSTANT_POOL_ADDRESS_P true, return a pointer to
3650 the corresponding pool_constant structure. */
3652 static struct pool_constant
*
3653 find_pool_constant (f
, addr
)
3657 struct pool_sym
*sym
;
3658 char *label
= XSTR (addr
, 0);
3660 for (sym
= f
->varasm
->x_const_rtx_sym_hash_table
[SYMHASH (label
)]; sym
; sym
= sym
->next
)
3661 if (sym
->label
== label
)
3667 /* Given a constant pool SYMBOL_REF, return the corresponding constant. */
3670 get_pool_constant (addr
)
3673 return (find_pool_constant (current_function
, addr
))->constant
;
3676 /* Likewise, but for the constant pool of a specific function. */
3679 get_pool_constant_for_function (f
, addr
)
3683 return (find_pool_constant (f
, addr
))->constant
;
3686 /* Similar, return the mode. */
3689 get_pool_mode (addr
)
3692 return (find_pool_constant (current_function
, addr
))->mode
;
3696 get_pool_mode_for_function (f
, addr
)
3700 return (find_pool_constant (f
, addr
))->mode
;
3703 /* Similar, return the offset in the constant pool. */
3706 get_pool_offset (addr
)
3709 return (find_pool_constant (current_function
, addr
))->offset
;
3712 /* Return the size of the constant pool. */
3720 /* Write all the constants in the constant pool. */
3723 output_constant_pool (fnname
, fndecl
)
3724 char *fnname ATTRIBUTE_UNUSED
;
3725 tree fndecl ATTRIBUTE_UNUSED
;
3727 struct pool_constant
*pool
;
3729 union real_extract u
;
3731 /* It is possible for gcc to call force_const_mem and then to later
3732 discard the instructions which refer to the constant. In such a
3733 case we do not need to output the constant. */
3734 mark_constant_pool ();
3736 #ifdef ASM_OUTPUT_POOL_PROLOGUE
3737 ASM_OUTPUT_POOL_PROLOGUE (asm_out_file
, fnname
, fndecl
, pool_offset
);
3740 for (pool
= first_pool
; pool
; pool
= pool
->next
)
3747 /* See if X is a LABEL_REF (or a CONST referring to a LABEL_REF)
3748 whose CODE_LABEL has been deleted. This can occur if a jump table
3749 is eliminated by optimization. If so, write a constant of zero
3750 instead. Note that this can also happen by turning the
3751 CODE_LABEL into a NOTE. */
3752 if (((GET_CODE (x
) == LABEL_REF
3753 && (INSN_DELETED_P (XEXP (x
, 0))
3754 || GET_CODE (XEXP (x
, 0)) == NOTE
)))
3755 || (GET_CODE (x
) == CONST
&& GET_CODE (XEXP (x
, 0)) == PLUS
3756 && GET_CODE (XEXP (XEXP (x
, 0), 0)) == LABEL_REF
3757 && (INSN_DELETED_P (XEXP (XEXP (XEXP (x
, 0), 0), 0))
3758 || GET_CODE (XEXP (XEXP (XEXP (x
, 0), 0), 0)) == NOTE
)))
3761 /* First switch to correct section. */
3762 #ifdef SELECT_RTX_SECTION
3763 SELECT_RTX_SECTION (pool
->mode
, x
);
3765 readonly_data_section ();
3768 #ifdef ASM_OUTPUT_SPECIAL_POOL_ENTRY
3769 ASM_OUTPUT_SPECIAL_POOL_ENTRY (asm_out_file
, x
, pool
->mode
,
3770 pool
->align
, pool
->labelno
, done
);
3773 if (pool
->align
> 1)
3774 ASM_OUTPUT_ALIGN (asm_out_file
, floor_log2 (pool
->align
));
3776 /* Output the label. */
3777 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, "LC", pool
->labelno
);
3779 /* Output the value of the constant itself. */
3780 switch (GET_MODE_CLASS (pool
->mode
))
3783 if (GET_CODE (x
) != CONST_DOUBLE
)
3786 bcopy ((char *) &CONST_DOUBLE_LOW (x
), (char *) &u
, sizeof u
);
3787 assemble_real (u
.d
, pool
->mode
);
3791 case MODE_PARTIAL_INT
:
3792 assemble_integer (x
, GET_MODE_SIZE (pool
->mode
), 1);
3799 #ifdef ASM_OUTPUT_SPECIAL_POOL_ENTRY
3805 #ifdef ASM_OUTPUT_POOL_EPILOGUE
3806 ASM_OUTPUT_POOL_EPILOGUE (asm_out_file
, fnname
, fndecl
, pool_offset
);
3809 /* Done with this pool. */
3810 first_pool
= last_pool
= 0;
3813 /* Look through the instructions for this function, and mark all the
3814 entries in the constant pool which are actually being used. */
3817 mark_constant_pool ()
3820 struct pool_constant
*pool
;
3822 if (first_pool
== 0)
3825 for (pool
= first_pool
; pool
; pool
= pool
->next
)
3828 for (insn
= get_insns (); insn
; insn
= NEXT_INSN (insn
))
3829 if (GET_RTX_CLASS (GET_CODE (insn
)) == 'i')
3830 mark_constants (PATTERN (insn
));
3832 for (insn
= current_function_epilogue_delay_list
;
3834 insn
= XEXP (insn
, 1))
3835 if (GET_RTX_CLASS (GET_CODE (insn
)) == 'i')
3836 mark_constants (PATTERN (insn
));
3838 /* It's possible that the only reference to a symbol is in a symbol
3839 that's in the constant pool. This happens in Fortran under some
3840 situations. (When the constant contains the address of another
3841 constant, and only the first is used directly in an insn.)
3842 This is potentially suboptimal if there's ever a possibility of
3843 backwards (in pool order) 2'd level references. However, it's
3844 not clear that 2'd level references can happen. */
3845 for (pool
= first_pool
; pool
; pool
= pool
->next
)
3847 struct pool_sym
*sym
;
3850 /* skip unmarked entries; no insn refers to them. */
3854 /* Skip everything except SYMBOL_REFs. */
3855 if (GET_CODE (pool
->constant
) != SYMBOL_REF
)
3857 label
= XSTR (pool
->constant
, 0);
3859 /* Be sure the symbol's value is marked. */
3860 for (sym
= const_rtx_sym_hash_table
[SYMHASH (label
)]; sym
;
3862 if (sym
->label
== label
)
3863 sym
->pool
->mark
= 1;
3864 /* If we didn't find it, there's something truly wrong here, but it
3865 will be announced by the assembler. */
3874 register const char *format_ptr
;
3879 if (GET_CODE (x
) == SYMBOL_REF
)
3881 if (CONSTANT_POOL_ADDRESS_P (x
))
3882 find_pool_constant (current_function
, x
)->mark
= 1;
3885 /* Never search inside a CONST_DOUBLE, because CONST_DOUBLE_MEM may be
3886 a MEM, but does not constitute a use of that MEM. */
3887 else if (GET_CODE (x
) == CONST_DOUBLE
)
3890 /* Insns may appear inside a SEQUENCE. Only check the patterns of
3891 insns, not any notes that may be attached. We don't want to mark
3892 a constant just because it happens to appear in a REG_EQUIV note. */
3893 if (GET_RTX_CLASS (GET_CODE (x
)) == 'i')
3895 mark_constants (PATTERN (x
));
3899 format_ptr
= GET_RTX_FORMAT (GET_CODE (x
));
3901 for (i
= 0; i
< GET_RTX_LENGTH (GET_CODE (x
)); i
++)
3903 switch (*format_ptr
++)
3906 mark_constants (XEXP (x
, i
));
3910 if (XVEC (x
, i
) != 0)
3914 for (j
= 0; j
< XVECLEN (x
, i
); j
++)
3915 mark_constants (XVECEXP (x
, i
, j
));
3934 /* Find all the constants whose addresses are referenced inside of EXP,
3935 and make sure assembler code with a label has been output for each one.
3936 Indicate whether an ADDR_EXPR has been encountered. */
3939 output_addressed_constants (exp
)
3944 switch (TREE_CODE (exp
))
3948 register tree constant
= TREE_OPERAND (exp
, 0);
3950 while (TREE_CODE (constant
) == COMPONENT_REF
)
3952 constant
= TREE_OPERAND (constant
, 0);
3955 if (TREE_CODE_CLASS (TREE_CODE (constant
)) == 'c'
3956 || TREE_CODE (constant
) == CONSTRUCTOR
)
3957 /* No need to do anything here
3958 for addresses of variables or functions. */
3959 output_constant_def (constant
);
3966 reloc
= output_addressed_constants (TREE_OPERAND (exp
, 0));
3967 reloc
|= output_addressed_constants (TREE_OPERAND (exp
, 1));
3972 case NON_LVALUE_EXPR
:
3973 reloc
= output_addressed_constants (TREE_OPERAND (exp
, 0));
3979 for (link
= CONSTRUCTOR_ELTS (exp
); link
; link
= TREE_CHAIN (link
))
3980 if (TREE_VALUE (link
) != 0)
3981 reloc
|= output_addressed_constants (TREE_VALUE (link
));
3991 /* Output assembler code for constant EXP to FILE, with no label.
3992 This includes the pseudo-op such as ".int" or ".byte", and a newline.
3993 Assumes output_addressed_constants has been done on EXP already.
3995 Generate exactly SIZE bytes of assembler data, padding at the end
3996 with zeros if necessary. SIZE must always be specified.
3998 SIZE is important for structure constructors,
3999 since trailing members may have been omitted from the constructor.
4000 It is also important for initialization of arrays from string constants
4001 since the full length of the string constant might not be wanted.
4002 It is also needed for initialization of unions, where the initializer's
4003 type is just one member, and that may not be as long as the union.
4005 There a case in which we would fail to output exactly SIZE bytes:
4006 for a structure constructor that wants to produce more than SIZE bytes.
4007 But such constructors will never be generated for any possible input. */
4010 output_constant (exp
, size
)
4014 register enum tree_code code
= TREE_CODE (TREE_TYPE (exp
));
4016 /* Some front-ends use constants other than the standard
4017 language-indepdent varieties, but which may still be output
4018 directly. Give the front-end a chance to convert EXP to a
4019 language-independent representation. */
4020 if (lang_expand_constant
)
4021 exp
= (*lang_expand_constant
) (exp
);
4023 if (size
== 0 || flag_syntax_only
)
4026 /* Eliminate the NON_LVALUE_EXPR_EXPR that makes a cast not be an lvalue.
4027 That way we get the constant (we hope) inside it. Also, strip off any
4028 NOP_EXPR that converts between two record, union, array, or set types. */
4029 while ((TREE_CODE (exp
) == NOP_EXPR
4030 && (TREE_TYPE (exp
) == TREE_TYPE (TREE_OPERAND (exp
, 0))
4031 || AGGREGATE_TYPE_P (TREE_TYPE (exp
))))
4032 || TREE_CODE (exp
) == NON_LVALUE_EXPR
)
4033 exp
= TREE_OPERAND (exp
, 0);
4035 /* Allow a constructor with no elements for any data type.
4036 This means to fill the space with zeros. */
4037 if (TREE_CODE (exp
) == CONSTRUCTOR
&& CONSTRUCTOR_ELTS (exp
) == 0)
4039 assemble_zeros (size
);
4050 case REFERENCE_TYPE
:
4051 /* ??? What about (int)((float)(int)&foo + 4) */
4052 while (TREE_CODE (exp
) == NOP_EXPR
|| TREE_CODE (exp
) == CONVERT_EXPR
4053 || TREE_CODE (exp
) == NON_LVALUE_EXPR
)
4054 exp
= TREE_OPERAND (exp
, 0);
4056 if (! assemble_integer (expand_expr (exp
, NULL_RTX
, VOIDmode
,
4057 EXPAND_INITIALIZER
),
4059 error ("initializer for integer value is too complicated");
4064 if (TREE_CODE (exp
) != REAL_CST
)
4065 error ("initializer for floating value is not a floating constant");
4067 assemble_real (TREE_REAL_CST (exp
),
4068 mode_for_size (size
* BITS_PER_UNIT
, MODE_FLOAT
, 0));
4073 output_constant (TREE_REALPART (exp
), size
/ 2);
4074 output_constant (TREE_IMAGPART (exp
), size
/ 2);
4075 size
-= (size
/ 2) * 2;
4079 if (TREE_CODE (exp
) == CONSTRUCTOR
)
4081 output_constructor (exp
, size
);
4084 else if (TREE_CODE (exp
) == STRING_CST
)
4088 if (size
> TREE_STRING_LENGTH (exp
))
4090 excess
= size
- TREE_STRING_LENGTH (exp
);
4091 size
= TREE_STRING_LENGTH (exp
);
4094 assemble_string (TREE_STRING_POINTER (exp
), size
);
4103 if (TREE_CODE (exp
) == CONSTRUCTOR
)
4104 output_constructor (exp
, size
);
4110 if (TREE_CODE (exp
) == INTEGER_CST
)
4111 assemble_integer (expand_expr (exp
, NULL_RTX
,
4112 VOIDmode
, EXPAND_INITIALIZER
),
4114 else if (TREE_CODE (exp
) == CONSTRUCTOR
)
4116 unsigned char *buffer
= (unsigned char *) alloca (size
);
4117 if (get_set_constructor_bytes (exp
, buffer
, size
))
4119 assemble_string ((char *) buffer
, size
);
4122 error ("unknown set constructor type");
4130 assemble_zeros (size
);
4134 /* Subroutine of output_constant, used for CONSTRUCTORs
4135 (aggregate constants).
4136 Generate at least SIZE bytes, padding if necessary. */
4139 output_constructor (exp
, size
)
4143 register tree link
, field
= 0;
4144 HOST_WIDE_INT min_index
= 0;
4145 /* Number of bytes output or skipped so far.
4146 In other words, current position within the constructor. */
4147 int total_bytes
= 0;
4148 /* Non-zero means BYTE contains part of a byte, to be output. */
4149 int byte_buffer_in_use
= 0;
4152 if (HOST_BITS_PER_WIDE_INT
< BITS_PER_UNIT
)
4155 if (TREE_CODE (TREE_TYPE (exp
)) == RECORD_TYPE
)
4156 field
= TYPE_FIELDS (TREE_TYPE (exp
));
4158 if (TREE_CODE (TREE_TYPE (exp
)) == ARRAY_TYPE
4159 && TYPE_DOMAIN (TREE_TYPE (exp
)) != 0)
4161 = TREE_INT_CST_LOW (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (exp
))));
4163 /* As LINK goes through the elements of the constant,
4164 FIELD goes through the structure fields, if the constant is a structure.
4165 if the constant is a union, then we override this,
4166 by getting the field from the TREE_LIST element.
4167 But the constant could also be an array. Then FIELD is zero.
4169 There is always a maximum of one element in the chain LINK for unions
4170 (even if the initializer in a source program incorrectly contains
4172 for (link
= CONSTRUCTOR_ELTS (exp
);
4174 link
= TREE_CHAIN (link
),
4175 field
= field
? TREE_CHAIN (field
) : 0)
4177 tree val
= TREE_VALUE (link
);
4180 /* the element in a union constructor specifies the proper field. */
4182 if (TREE_CODE (TREE_TYPE (exp
)) == RECORD_TYPE
4183 || TREE_CODE (TREE_TYPE (exp
)) == UNION_TYPE
)
4185 /* if available, use the type given by link */
4186 if (TREE_PURPOSE (link
) != 0)
4187 field
= TREE_PURPOSE (link
);
4190 if (TREE_CODE (TREE_TYPE (exp
)) == ARRAY_TYPE
)
4191 index
= TREE_PURPOSE (link
);
4193 /* Eliminate the marker that makes a cast not be an lvalue. */
4197 if (index
&& TREE_CODE (index
) == RANGE_EXPR
)
4199 register int fieldsize
4200 = int_size_in_bytes (TREE_TYPE (TREE_TYPE (exp
)));
4201 HOST_WIDE_INT lo_index
= TREE_INT_CST_LOW (TREE_OPERAND (index
, 0));
4202 HOST_WIDE_INT hi_index
= TREE_INT_CST_LOW (TREE_OPERAND (index
, 1));
4203 HOST_WIDE_INT index
;
4204 for (index
= lo_index
; index
<= hi_index
; index
++)
4206 /* Output the element's initial value. */
4208 assemble_zeros (fieldsize
);
4210 output_constant (val
, fieldsize
);
4212 /* Count its size. */
4213 total_bytes
+= fieldsize
;
4216 else if (field
== 0 || !DECL_BIT_FIELD (field
))
4218 /* An element that is not a bit-field. */
4220 register int fieldsize
;
4221 /* Since this structure is static,
4222 we know the positions are constant. */
4223 int bitpos
= (field
? (TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field
))
4227 bitpos
= (TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (val
)))
4229 * (TREE_INT_CST_LOW (index
) - min_index
));
4231 /* Output any buffered-up bit-fields preceding this element. */
4232 if (byte_buffer_in_use
)
4234 ASM_OUTPUT_BYTE (asm_out_file
, byte
);
4236 byte_buffer_in_use
= 0;
4239 /* Advance to offset of this element.
4240 Note no alignment needed in an array, since that is guaranteed
4241 if each element has the proper size. */
4242 if ((field
!= 0 || index
!= 0) && bitpos
!= total_bytes
)
4244 assemble_zeros (bitpos
- total_bytes
);
4245 total_bytes
= bitpos
;
4248 /* Determine size this element should occupy. */
4251 if (TREE_CODE (DECL_SIZE (field
)) != INTEGER_CST
)
4253 if (TREE_INT_CST_LOW (DECL_SIZE (field
)) > 100000)
4255 /* This avoids overflow trouble. */
4256 tree size_tree
= size_binop (CEIL_DIV_EXPR
,
4258 size_int (BITS_PER_UNIT
));
4259 fieldsize
= TREE_INT_CST_LOW (size_tree
);
4263 fieldsize
= TREE_INT_CST_LOW (DECL_SIZE (field
));
4264 fieldsize
= (fieldsize
+ BITS_PER_UNIT
- 1) / BITS_PER_UNIT
;
4268 fieldsize
= int_size_in_bytes (TREE_TYPE (TREE_TYPE (exp
)));
4270 /* Output the element's initial value. */
4272 assemble_zeros (fieldsize
);
4274 output_constant (val
, fieldsize
);
4276 /* Count its size. */
4277 total_bytes
+= fieldsize
;
4279 else if (val
!= 0 && TREE_CODE (val
) != INTEGER_CST
)
4280 error ("invalid initial value for member `%s'",
4281 IDENTIFIER_POINTER (DECL_NAME (field
)));
4284 /* Element that is a bit-field. */
4286 int next_offset
= TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field
));
4288 = (next_offset
+ TREE_INT_CST_LOW (DECL_SIZE (field
)));
4291 val
= integer_zero_node
;
4293 /* If this field does not start in this (or, next) byte,
4295 if (next_offset
/ BITS_PER_UNIT
!= total_bytes
)
4297 /* Output remnant of any bit field in previous bytes. */
4298 if (byte_buffer_in_use
)
4300 ASM_OUTPUT_BYTE (asm_out_file
, byte
);
4302 byte_buffer_in_use
= 0;
4305 /* If still not at proper byte, advance to there. */
4306 if (next_offset
/ BITS_PER_UNIT
!= total_bytes
)
4308 assemble_zeros (next_offset
/ BITS_PER_UNIT
- total_bytes
);
4309 total_bytes
= next_offset
/ BITS_PER_UNIT
;
4313 if (! byte_buffer_in_use
)
4316 /* We must split the element into pieces that fall within
4317 separate bytes, and combine each byte with previous or
4318 following bit-fields. */
4320 /* next_offset is the offset n fbits from the beginning of
4321 the structure to the next bit of this element to be processed.
4322 end_offset is the offset of the first bit past the end of
4324 while (next_offset
< end_offset
)
4328 HOST_WIDE_INT value
;
4329 int next_byte
= next_offset
/ BITS_PER_UNIT
;
4330 int next_bit
= next_offset
% BITS_PER_UNIT
;
4332 /* Advance from byte to byte
4333 within this element when necessary. */
4334 while (next_byte
!= total_bytes
)
4336 ASM_OUTPUT_BYTE (asm_out_file
, byte
);
4341 /* Number of bits we can process at once
4342 (all part of the same byte). */
4343 this_time
= MIN (end_offset
- next_offset
,
4344 BITS_PER_UNIT
- next_bit
);
4345 if (BYTES_BIG_ENDIAN
)
4347 /* On big-endian machine, take the most significant bits
4348 first (of the bits that are significant)
4349 and put them into bytes from the most significant end. */
4350 shift
= end_offset
- next_offset
- this_time
;
4351 /* Don't try to take a bunch of bits that cross
4352 the word boundary in the INTEGER_CST. */
4353 if (shift
< HOST_BITS_PER_WIDE_INT
4354 && shift
+ this_time
> HOST_BITS_PER_WIDE_INT
)
4356 this_time
-= (HOST_BITS_PER_WIDE_INT
- shift
);
4357 shift
= HOST_BITS_PER_WIDE_INT
;
4360 /* Now get the bits from the appropriate constant word. */
4361 if (shift
< HOST_BITS_PER_WIDE_INT
)
4363 value
= TREE_INT_CST_LOW (val
);
4365 else if (shift
< 2 * HOST_BITS_PER_WIDE_INT
)
4367 value
= TREE_INT_CST_HIGH (val
);
4368 shift
-= HOST_BITS_PER_WIDE_INT
;
4372 byte
|= (((value
>> shift
)
4373 & (((HOST_WIDE_INT
) 1 << this_time
) - 1))
4374 << (BITS_PER_UNIT
- this_time
- next_bit
));
4378 /* On little-endian machines,
4379 take first the least significant bits of the value
4380 and pack them starting at the least significant
4381 bits of the bytes. */
4382 shift
= (next_offset
4383 - TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field
)));
4384 /* Don't try to take a bunch of bits that cross
4385 the word boundary in the INTEGER_CST. */
4386 if (shift
< HOST_BITS_PER_WIDE_INT
4387 && shift
+ this_time
> HOST_BITS_PER_WIDE_INT
)
4389 this_time
-= (HOST_BITS_PER_WIDE_INT
- shift
);
4390 shift
= HOST_BITS_PER_WIDE_INT
;
4393 /* Now get the bits from the appropriate constant word. */
4394 if (shift
< HOST_BITS_PER_WIDE_INT
)
4395 value
= TREE_INT_CST_LOW (val
);
4396 else if (shift
< 2 * HOST_BITS_PER_WIDE_INT
)
4398 value
= TREE_INT_CST_HIGH (val
);
4399 shift
-= HOST_BITS_PER_WIDE_INT
;
4403 byte
|= (((value
>> shift
)
4404 & (((HOST_WIDE_INT
) 1 << this_time
) - 1))
4407 next_offset
+= this_time
;
4408 byte_buffer_in_use
= 1;
4412 if (byte_buffer_in_use
)
4414 ASM_OUTPUT_BYTE (asm_out_file
, byte
);
4417 if (total_bytes
< size
)
4418 assemble_zeros (size
- total_bytes
);
4421 #ifdef HANDLE_PRAGMA_WEAK
4422 /* Add function NAME to the weak symbols list. VALUE is a weak alias
4423 associatd with NAME. */
4426 add_weak (name
, value
)
4430 struct weak_syms
*weak
;
4432 weak
= (struct weak_syms
*) permalloc (sizeof (struct weak_syms
));
4437 weak
->next
= weak_decls
;
4439 weak
->value
= value
;
4444 #endif /* HANDLE_PRAGMA_WEAK */
4446 /* Declare DECL to be a weak symbol. */
4452 if (! TREE_PUBLIC (decl
))
4453 error_with_decl (decl
, "weak declaration of `%s' must be public");
4454 else if (TREE_ASM_WRITTEN (decl
))
4455 error_with_decl (decl
, "weak declaration of `%s' must precede definition");
4456 else if (SUPPORTS_WEAK
)
4457 DECL_WEAK (decl
) = 1;
4458 #ifdef HANDLE_PRAGMA_WEAK
4459 add_weak (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)), NULL
);
4463 /* Emit any pending weak declarations. */
4465 #ifdef HANDLE_PRAGMA_WEAK
4466 struct weak_syms
* weak_decls
;
4472 #ifdef HANDLE_PRAGMA_WEAK
4473 if (HANDLE_PRAGMA_WEAK
)
4475 struct weak_syms
*t
;
4476 for (t
= weak_decls
; t
; t
= t
->next
)
4480 ASM_WEAKEN_LABEL (asm_out_file
, t
->name
);
4482 ASM_OUTPUT_DEF (asm_out_file
, t
->name
, t
->value
);
4489 /* Remove NAME from the pending list of weak symbols. This prevents
4490 the compiler from emitting multiple .weak directives which confuses
4492 #ifdef ASM_WEAKEN_LABEL
4494 remove_from_pending_weak_list (name
)
4495 char *name ATTRIBUTE_UNUSED
;
4497 #ifdef HANDLE_PRAGMA_WEAK
4498 if (HANDLE_PRAGMA_WEAK
)
4500 struct weak_syms
*t
;
4501 for (t
= weak_decls
; t
; t
= t
->next
)
4503 if (t
->name
&& strcmp (name
, t
->name
) == 0)
4512 assemble_alias (decl
, target
)
4513 tree decl
, target ATTRIBUTE_UNUSED
;
4517 make_decl_rtl (decl
, (char *) 0, 1);
4518 name
= XSTR (XEXP (DECL_RTL (decl
), 0), 0);
4520 #ifdef ASM_OUTPUT_DEF
4521 /* Make name accessible from other files, if appropriate. */
4523 if (TREE_PUBLIC (decl
))
4525 #ifdef ASM_WEAKEN_LABEL
4526 if (DECL_WEAK (decl
))
4528 ASM_WEAKEN_LABEL (asm_out_file
, name
);
4529 /* Remove this function from the pending weak list so that
4530 we do not emit multiple .weak directives for it. */
4531 remove_from_pending_weak_list
4532 (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)));
4536 ASM_GLOBALIZE_LABEL (asm_out_file
, name
);
4539 #ifdef ASM_OUTPUT_DEF_FROM_DECLS
4540 ASM_OUTPUT_DEF_FROM_DECLS (asm_out_file
, decl
, target
);
4542 ASM_OUTPUT_DEF (asm_out_file
, name
, IDENTIFIER_POINTER (target
));
4544 TREE_ASM_WRITTEN (decl
) = 1;
4546 #ifdef ASM_OUTPUT_WEAK_ALIAS
4547 if (! DECL_WEAK (decl
))
4548 warning ("only weak aliases are supported in this configuration");
4550 ASM_OUTPUT_WEAK_ALIAS (asm_out_file
, name
, IDENTIFIER_POINTER (target
));
4551 TREE_ASM_WRITTEN (decl
) = 1;
4553 warning ("alias definitions not supported in this configuration; ignored");
4558 /* This determines whether or not we support link-once semantics. */
4559 #ifndef SUPPORTS_ONE_ONLY
4560 #ifdef MAKE_DECL_ONE_ONLY
4561 #define SUPPORTS_ONE_ONLY 1
4563 #define SUPPORTS_ONE_ONLY 0
4567 /* Returns 1 if the target configuration supports defining public symbols
4568 so that one of them will be chosen at link time instead of generating a
4569 multiply-defined symbol error, whether through the use of weak symbols or
4570 a target-specific mechanism for having duplicates discarded. */
4573 supports_one_only ()
4575 if (SUPPORTS_ONE_ONLY
)
4577 return SUPPORTS_WEAK
;
4580 /* Set up DECL as a public symbol that can be defined in multiple
4581 translation units without generating a linker error. */
4584 make_decl_one_only (decl
)
4587 if (TREE_CODE (decl
) != VAR_DECL
&& TREE_CODE (decl
) != FUNCTION_DECL
)
4590 TREE_PUBLIC (decl
) = 1;
4592 if (TREE_CODE (decl
) == VAR_DECL
4593 && (DECL_INITIAL (decl
) == 0 || DECL_INITIAL (decl
) == error_mark_node
))
4594 DECL_COMMON (decl
) = 1;
4595 else if (SUPPORTS_ONE_ONLY
)
4597 #ifdef MAKE_DECL_ONE_ONLY
4598 MAKE_DECL_ONE_ONLY (decl
);
4600 DECL_ONE_ONLY (decl
) = 1;
4602 else if (SUPPORTS_WEAK
)
4603 DECL_WEAK (decl
) = 1;
4611 ggc_add_root (const_hash_table
, MAX_HASH_TABLE
, sizeof(const_hash_table
[0]),
4612 mark_const_hash_entry
);
4613 ggc_add_string_root (&in_named_name
, 1);