1 /* Output variables, constants and external declarations, for GNU compiler.
2 Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997,
3 1998, 1999, 2000 Free Software Foundation, Inc.
5 This file is part of GNU CC.
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
23 /* This file handles generation of all the assembler code
24 *except* the instructions of a function.
25 This includes declarations of variables and their initial values.
27 We also output the assembler code for constants stored in memory
28 and are responsible for combining constants with the same value. */
38 #include "hard-reg-set.h"
52 #ifdef XCOFF_DEBUGGING_INFO
56 #ifndef TRAMPOLINE_ALIGNMENT
57 #define TRAMPOLINE_ALIGNMENT FUNCTION_BOUNDARY
61 #define ASM_STABS_OP "\t.stabs\t"
64 /* Define the prefix to use when check_memory_usage_flag is enable. */
65 #ifdef NO_DOLLAR_IN_LABEL
66 #ifdef NO_DOT_IN_LABEL
67 #define CHKR_PREFIX "chkr_prefix_"
68 #else /* !NO_DOT_IN_LABEL */
69 #define CHKR_PREFIX "chkr."
71 #else /* !NO_DOLLAR_IN_LABEL */
72 #define CHKR_PREFIX "chkr$"
74 #define CHKR_PREFIX_SIZE (sizeof (CHKR_PREFIX) - 1)
76 /* File in which assembler code is being written. */
78 extern FILE *asm_out_file
;
80 /* The (assembler) name of the first globally-visible object output. */
81 const char *first_global_object_name
;
82 const char *weak_global_object_name
;
84 extern struct obstack permanent_obstack
;
85 #define obstack_chunk_alloc xmalloc
88 struct constant_descriptor
;
92 #define MAX_RTX_HASH_TABLE 61
96 /* Hash facility for making memory-constants
97 from constant rtl-expressions. It is used on RISC machines
98 where immediate integer arguments and constant addresses are restricted
99 so that such constants must be stored in memory.
101 This pool of constants is reinitialized for each function
102 so each function gets its own constants-pool that comes right before
104 struct constant_descriptor
**x_const_rtx_hash_table
;
105 struct pool_constant
**x_const_rtx_sym_hash_table
;
107 /* Pointers to first and last constant in pool. */
108 struct pool_constant
*x_first_pool
, *x_last_pool
;
110 /* Current offset in constant pool (does not include any machine-specific
114 /* Chain of all CONST_DOUBLE rtx's constructed for the current function.
115 They are chained through the CONST_DOUBLE_CHAIN.
116 A CONST_DOUBLE rtx has CONST_DOUBLE_MEM != cc0_rtx iff it is on this chain.
117 In that case, CONST_DOUBLE_MEM is either a MEM,
118 or const0_rtx if no MEM has been made for this CONST_DOUBLE yet. */
119 rtx x_const_double_chain
;
122 #define const_rtx_hash_table (cfun->varasm->x_const_rtx_hash_table)
123 #define const_rtx_sym_hash_table (cfun->varasm->x_const_rtx_sym_hash_table)
124 #define first_pool (cfun->varasm->x_first_pool)
125 #define last_pool (cfun->varasm->x_last_pool)
126 #define pool_offset (cfun->varasm->x_pool_offset)
127 #define const_double_chain (cfun->varasm->x_const_double_chain)
129 /* Number for making the label on the next
130 constant that is stored in memory. */
134 /* Number for making the label on the next
135 static variable internal to a function. */
139 /* Carry information from ASM_DECLARE_OBJECT_NAME
140 to ASM_FINISH_DECLARE_OBJECT. */
142 int size_directive_output
;
144 /* The last decl for which assemble_variable was called,
145 if it did ASM_DECLARE_OBJECT_NAME.
146 If the last call to assemble_variable didn't do that,
149 tree last_assemble_variable_decl
;
151 static const char *strip_reg_name
PARAMS ((const char *));
152 static int contains_pointers_p
PARAMS ((tree
));
153 static void decode_addr_const
PARAMS ((tree
, struct addr_const
*));
154 static int const_hash
PARAMS ((tree
));
155 static int compare_constant
PARAMS ((tree
,
156 struct constant_descriptor
*));
157 static const unsigned char *compare_constant_1
PARAMS ((tree
, const unsigned char *));
158 static struct constant_descriptor
*record_constant
PARAMS ((tree
));
159 static void record_constant_1
PARAMS ((tree
));
160 static tree copy_constant
PARAMS ((tree
));
161 static void output_constant_def_contents
PARAMS ((tree
, int, int));
162 static void decode_rtx_const
PARAMS ((enum machine_mode
, rtx
,
163 struct rtx_const
*));
164 static int const_hash_rtx
PARAMS ((enum machine_mode
, rtx
));
165 static int compare_constant_rtx
PARAMS ((enum machine_mode
, rtx
,
166 struct constant_descriptor
*));
167 static struct constant_descriptor
*record_constant_rtx
PARAMS ((enum machine_mode
,
169 static struct pool_constant
*find_pool_constant
PARAMS ((struct function
*, rtx
));
170 static void mark_constant_pool
PARAMS ((void));
171 static void mark_constants
PARAMS ((rtx
));
172 static int output_addressed_constants
PARAMS ((tree
));
173 static void output_after_function_constants
PARAMS ((void));
174 static int array_size_for_constructor
PARAMS ((tree
));
175 static void output_constructor
PARAMS ((tree
, int));
176 #ifdef ASM_WEAKEN_LABEL
177 static void remove_from_pending_weak_list
PARAMS ((const char *));
179 #ifdef ASM_OUTPUT_BSS
180 static void asm_output_bss
PARAMS ((FILE *, tree
, const char *, int, int));
182 #ifdef BSS_SECTION_ASM_OP
183 #ifdef ASM_OUTPUT_ALIGNED_BSS
184 static void asm_output_aligned_bss
PARAMS ((FILE *, tree
, const char *,
187 #endif /* BSS_SECTION_ASM_OP */
188 static void mark_pool_constant
PARAMS ((struct pool_constant
*));
189 static void mark_const_hash_entry
PARAMS ((void *));
190 static int mark_const_str_htab_1
PARAMS ((void **, void *));
191 static void mark_const_str_htab
PARAMS ((void *));
192 static hashval_t const_str_htab_hash
PARAMS ((const void *x
));
193 static int const_str_htab_eq
PARAMS ((const void *x
, const void *y
));
194 static void const_str_htab_del
PARAMS ((void *));
195 static void asm_emit_uninitialised
PARAMS ((tree
, const char*, int, int));
197 static enum in_section
{ no_section
, in_text
, in_data
, in_named
198 #ifdef BSS_SECTION_ASM_OP
201 #ifdef EH_FRAME_SECTION_ASM_OP
204 #ifdef EXTRA_SECTIONS
207 } in_section
= no_section
;
209 /* Return a non-zero value if DECL has a section attribute. */
210 #ifndef IN_NAMED_SECTION
211 #define IN_NAMED_SECTION(DECL) \
212 ((TREE_CODE (DECL) == FUNCTION_DECL || TREE_CODE (DECL) == VAR_DECL) \
213 && DECL_SECTION_NAME (DECL) != NULL_TREE)
216 /* Text of section name when in_section == in_named. */
217 static const char *in_named_name
;
219 /* Define functions like text_section for any extra sections. */
220 #ifdef EXTRA_SECTION_FUNCTIONS
221 EXTRA_SECTION_FUNCTIONS
224 /* Tell assembler to switch to text section. */
229 if (in_section
!= in_text
)
231 fprintf (asm_out_file
, "%s\n", TEXT_SECTION_ASM_OP
);
232 in_section
= in_text
;
236 /* Tell assembler to switch to data section. */
241 if (in_section
!= in_data
)
243 if (flag_shared_data
)
245 #ifdef SHARED_SECTION_ASM_OP
246 fprintf (asm_out_file
, "%s\n", SHARED_SECTION_ASM_OP
);
248 fprintf (asm_out_file
, "%s\n", DATA_SECTION_ASM_OP
);
252 fprintf (asm_out_file
, "%s\n", DATA_SECTION_ASM_OP
);
254 in_section
= in_data
;
257 /* Tell assembler to ALWAYS switch to data section, in case
258 it's not sure where it it. */
261 force_data_section ()
263 in_section
= no_section
;
267 /* Tell assembler to switch to read-only data section. This is normally
271 readonly_data_section ()
273 #ifdef READONLY_DATA_SECTION
274 READONLY_DATA_SECTION (); /* Note this can call data_section. */
280 /* Determine if we're in the text section. */
285 return in_section
== in_text
;
288 /* Determine if we're in the data section. */
293 return in_section
== in_data
;
296 /* Tell assembler to change to section NAME for DECL.
297 If DECL is NULL, just switch to section NAME.
298 If NAME is NULL, get the name from DECL.
299 If RELOC is 1, the initializer for DECL contains relocs. */
302 named_section (decl
, name
, reloc
)
305 int reloc ATTRIBUTE_UNUSED
;
307 if (decl
!= NULL_TREE
&& !DECL_P (decl
))
310 name
= TREE_STRING_POINTER (DECL_SECTION_NAME (decl
));
312 if (in_section
!= in_named
|| strcmp (name
, in_named_name
))
314 #ifdef ASM_OUTPUT_SECTION_NAME
315 ASM_OUTPUT_SECTION_NAME (asm_out_file
, decl
, name
, reloc
);
317 /* Section attributes are not supported if this macro isn't provided -
318 some host formats don't support them at all. The front-end should
319 already have flagged this as an error. */
323 in_named_name
= ggc_strdup (name
);
324 in_section
= in_named
;
328 #ifdef ASM_OUTPUT_SECTION_NAME
329 #ifndef UNIQUE_SECTION
330 #define UNIQUE_SECTION(DECL,RELOC) \
336 name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL)); \
337 /* Strip off any encoding in name. */ \
338 STRIP_NAME_ENCODING (name, name); \
340 len = strlen (name) + 1; \
341 string = alloca (len + 1); \
342 sprintf (string, ".%s", name); \
344 DECL_SECTION_NAME (DECL) = build_string (len, string); \
347 #ifndef UNIQUE_SECTION_P
348 #define UNIQUE_SECTION_P(DECL) 0
352 #ifdef BSS_SECTION_ASM_OP
354 /* Tell the assembler to switch to the bss section. */
359 if (in_section
!= in_bss
)
361 #ifdef SHARED_BSS_SECTION_ASM_OP
362 if (flag_shared_data
)
363 fprintf (asm_out_file
, "%s\n", SHARED_BSS_SECTION_ASM_OP
);
366 fprintf (asm_out_file
, "%s\n", BSS_SECTION_ASM_OP
);
372 #ifdef ASM_OUTPUT_BSS
374 /* Utility function for ASM_OUTPUT_BSS for targets to use if
375 they don't support alignments in .bss.
376 ??? It is believed that this function will work in most cases so such
377 support is localized here. */
380 asm_output_bss (file
, decl
, name
, size
, rounded
)
382 tree decl ATTRIBUTE_UNUSED
;
384 int size ATTRIBUTE_UNUSED
, rounded
;
386 ASM_GLOBALIZE_LABEL (file
, name
);
388 #ifdef ASM_DECLARE_OBJECT_NAME
389 last_assemble_variable_decl
= decl
;
390 ASM_DECLARE_OBJECT_NAME (file
, name
, decl
);
392 /* Standard thing is just output label for the object. */
393 ASM_OUTPUT_LABEL (file
, name
);
394 #endif /* ASM_DECLARE_OBJECT_NAME */
395 ASM_OUTPUT_SKIP (file
, rounded
);
400 #ifdef ASM_OUTPUT_ALIGNED_BSS
402 /* Utility function for targets to use in implementing
403 ASM_OUTPUT_ALIGNED_BSS.
404 ??? It is believed that this function will work in most cases so such
405 support is localized here. */
408 asm_output_aligned_bss (file
, decl
, name
, size
, align
)
414 ASM_GLOBALIZE_LABEL (file
, name
);
416 ASM_OUTPUT_ALIGN (file
, floor_log2 (align
/ BITS_PER_UNIT
));
417 #ifdef ASM_DECLARE_OBJECT_NAME
418 last_assemble_variable_decl
= decl
;
419 ASM_DECLARE_OBJECT_NAME (file
, name
, decl
);
421 /* Standard thing is just output label for the object. */
422 ASM_OUTPUT_LABEL (file
, name
);
423 #endif /* ASM_DECLARE_OBJECT_NAME */
424 ASM_OUTPUT_SKIP (file
, size
? size
: 1);
429 #endif /* BSS_SECTION_ASM_OP */
431 #ifdef EH_FRAME_SECTION_ASM_OP
435 if (in_section
!= in_eh_frame
)
437 fprintf (asm_out_file
, "%s\n", EH_FRAME_SECTION_ASM_OP
);
438 in_section
= in_eh_frame
;
443 /* Switch to the section for function DECL.
445 If DECL is NULL_TREE, switch to the text section.
446 ??? It's not clear that we will ever be passed NULL_TREE, but it's
447 safer to handle it. */
450 function_section (decl
)
453 if (decl
!= NULL_TREE
454 && DECL_SECTION_NAME (decl
) != NULL_TREE
)
455 named_section (decl
, (char *) 0, 0);
460 /* Switch to section for variable DECL.
462 RELOC is the `reloc' argument to SELECT_SECTION. */
465 variable_section (decl
, reloc
)
469 if (IN_NAMED_SECTION (decl
))
470 named_section (decl
, NULL
, reloc
);
473 /* C++ can have const variables that get initialized from constructors,
474 and thus can not be in a readonly section. We prevent this by
475 verifying that the initial value is constant for objects put in a
478 error_mark_node is used by the C front end to indicate that the
479 initializer has not been seen yet. In this case, we assume that
480 the initializer must be constant.
482 C++ uses error_mark_node for variables that have complicated
483 initializers, but these variables go in BSS so we won't be called
486 #ifdef SELECT_SECTION
487 SELECT_SECTION (decl
, reloc
);
489 if (DECL_READONLY_SECTION (decl
, reloc
))
490 readonly_data_section ();
497 /* Tell assembler to switch to the section for the exception handling
503 #if defined (EXCEPTION_SECTION)
504 EXCEPTION_SECTION ();
506 #ifdef ASM_OUTPUT_SECTION_NAME
507 named_section (NULL_TREE
, ".gcc_except_table", 0);
512 readonly_data_section ();
517 /* Create the rtl to represent a function, for a function definition.
518 DECL is a FUNCTION_DECL node which describes which function.
519 The rtl is stored into DECL. */
522 make_function_rtl (decl
)
526 const char *new_name
;
528 if (DECL_RTL (decl
) != 0)
530 /* ??? Another way to do this would be to do what halfpic.c does
531 and maintain a hashed table of such critters. */
532 /* ??? Another way to do this would be to pass a flag bit to
533 ENCODE_SECTION_INFO saying whether this is a new decl or not. */
534 /* Let the target reassign the RTL if it wants.
535 This is necessary, for example, when one machine specific
536 decl attribute overrides another. */
537 #ifdef REDO_SECTION_INFO_P
538 if (REDO_SECTION_INFO_P (decl
))
539 ENCODE_SECTION_INFO (decl
);
544 name
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
));
547 /* Rename a nested function to avoid conflicts, unless it's a member of
548 a local class, in which case the class name is already unique. */
549 if (decl_function_context (decl
) != 0
550 && ! TYPE_P (DECL_CONTEXT (decl
))
551 && DECL_INITIAL (decl
) != 0
552 && DECL_RTL (decl
) == 0)
555 ASM_FORMAT_PRIVATE_NAME (label
, name
, var_labelno
);
559 /* When -fprefix-function-name is used, every function name is
560 prefixed. Even static functions are prefixed because they
561 could be declared latter. Note that a nested function name
563 else if (flag_prefix_function_name
)
565 size_t name_len
= IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (decl
));
568 pname
= alloca (name_len
+ CHKR_PREFIX_SIZE
+ 1);
569 memcpy (pname
, CHKR_PREFIX
, CHKR_PREFIX_SIZE
);
570 memcpy (pname
+ CHKR_PREFIX_SIZE
, name
, name_len
+ 1);
574 if (name
!= new_name
)
576 DECL_ASSEMBLER_NAME (decl
) = get_identifier (new_name
);
577 name
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
));
581 = gen_rtx_MEM (DECL_MODE (decl
),
582 gen_rtx_SYMBOL_REF (Pmode
, name
));
584 /* Optionally set flags or add text to the name to record
585 information such as that it is a function name. If the name
586 is changed, the macro ASM_OUTPUT_LABELREF will have to know
587 how to strip this information. */
588 #ifdef ENCODE_SECTION_INFO
589 ENCODE_SECTION_INFO (decl
);
594 /* Given NAME, a putative register name, discard any customary prefixes. */
597 strip_reg_name (name
)
600 #ifdef REGISTER_PREFIX
601 if (!strncmp (name
, REGISTER_PREFIX
, strlen (REGISTER_PREFIX
)))
602 name
+= strlen (REGISTER_PREFIX
);
604 if (name
[0] == '%' || name
[0] == '#')
609 /* Decode an `asm' spec for a declaration as a register name.
610 Return the register number, or -1 if nothing specified,
611 or -2 if the ASMSPEC is not `cc' or `memory' and is not recognized,
612 or -3 if ASMSPEC is `cc' and is not recognized,
613 or -4 if ASMSPEC is `memory' and is not recognized.
614 Accept an exact spelling or a decimal number.
615 Prefixes such as % are optional. */
618 decode_reg_name (asmspec
)
625 /* Get rid of confusing prefixes. */
626 asmspec
= strip_reg_name (asmspec
);
628 /* Allow a decimal number as a "register name". */
629 for (i
= strlen (asmspec
) - 1; i
>= 0; i
--)
630 if (! (asmspec
[i
] >= '0' && asmspec
[i
] <= '9'))
632 if (asmspec
[0] != 0 && i
< 0)
635 if (i
< FIRST_PSEUDO_REGISTER
&& i
>= 0)
641 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; i
++)
643 && ! strcmp (asmspec
, strip_reg_name (reg_names
[i
])))
646 #ifdef ADDITIONAL_REGISTER_NAMES
648 static struct { const char *name
; int number
; } table
[]
649 = ADDITIONAL_REGISTER_NAMES
;
651 for (i
= 0; i
< (int) ARRAY_SIZE (table
); i
++)
652 if (! strcmp (asmspec
, table
[i
].name
))
653 return table
[i
].number
;
655 #endif /* ADDITIONAL_REGISTER_NAMES */
657 if (!strcmp (asmspec
, "memory"))
660 if (!strcmp (asmspec
, "cc"))
669 /* Create the DECL_RTL for a declaration for a static or external variable
670 or static or external function.
671 ASMSPEC, if not 0, is the string which the user specified
672 as the assembler symbol name.
673 TOP_LEVEL is nonzero if this is a file-scope variable.
675 This is never called for PARM_DECL nodes. */
678 make_decl_rtl (decl
, asmspec
, top_level
)
683 const char *name
= 0;
684 const char *new_name
= 0;
687 /* For a duplicate declaration, we can be called twice on the
688 same DECL node. Don't discard the RTL already made. */
689 if (DECL_RTL (decl
) != 0)
691 /* If the old RTL had the wrong mode, fix the mode. */
692 if (GET_MODE (DECL_RTL (decl
)) != DECL_MODE (decl
))
694 rtx rtl
= DECL_RTL (decl
);
695 PUT_MODE (rtl
, DECL_MODE (decl
));
698 /* ??? Another way to do this would be to do what halfpic.c does
699 and maintain a hashed table of such critters. */
700 /* ??? Another way to do this would be to pass a flag bit to
701 ENCODE_SECTION_INFO saying whether this is a new decl or not. */
702 /* Let the target reassign the RTL if it wants.
703 This is necessary, for example, when one machine specific
704 decl attribute overrides another. */
705 #ifdef REDO_SECTION_INFO_P
706 if (REDO_SECTION_INFO_P (decl
))
707 ENCODE_SECTION_INFO (decl
);
712 new_name
= name
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
));
714 reg_number
= decode_reg_name (asmspec
);
715 if (reg_number
== -2)
717 /* ASMSPEC is given, and not the name of a register. Mark the
718 name with a star so assemble_name won't munge it. */
719 char *starred
= alloca (strlen (asmspec
) + 2);
721 strcpy (starred
+ 1, asmspec
);
725 if (TREE_CODE (decl
) != FUNCTION_DECL
&& DECL_REGISTER (decl
))
727 /* First detect errors in declaring global registers. */
728 if (reg_number
== -1)
729 error_with_decl (decl
, "register name not specified for `%s'");
730 else if (reg_number
< 0)
731 error_with_decl (decl
, "invalid register name for `%s'");
732 else if (TYPE_MODE (TREE_TYPE (decl
)) == BLKmode
)
733 error_with_decl (decl
,
734 "data type of `%s' isn't suitable for a register");
735 else if (! HARD_REGNO_MODE_OK (reg_number
, TYPE_MODE (TREE_TYPE (decl
))))
736 error_with_decl (decl
,
737 "register specified for `%s' isn't suitable for data type");
738 /* Now handle properly declared static register variables. */
743 if (DECL_INITIAL (decl
) != 0 && top_level
)
745 DECL_INITIAL (decl
) = 0;
746 error ("global register variable has initial value");
748 if (TREE_THIS_VOLATILE (decl
))
749 warning ("volatile register variables don't work as you might wish");
751 /* If the user specified one of the eliminables registers here,
752 e.g., FRAME_POINTER_REGNUM, we don't want to get this variable
753 confused with that register and be eliminated. Although this
754 usage is somewhat suspect, we nevertheless use the following
755 kludge to avoid setting DECL_RTL to frame_pointer_rtx. */
758 = gen_rtx_REG (DECL_MODE (decl
), FIRST_PSEUDO_REGISTER
);
759 REGNO (DECL_RTL (decl
)) = reg_number
;
760 REG_USERVAR_P (DECL_RTL (decl
)) = 1;
764 /* Make this register global, so not usable for anything
766 #ifdef ASM_DECLARE_REGISTER_GLOBAL
767 ASM_DECLARE_REGISTER_GLOBAL (asm_out_file
, decl
, reg_number
, name
);
769 nregs
= HARD_REGNO_NREGS (reg_number
, DECL_MODE (decl
));
771 globalize_reg (reg_number
+ --nregs
);
774 /* As a register variable, it has no section. */
779 /* Now handle ordinary static variables and functions (in memory).
780 Also handle vars declared register invalidly. */
782 if (reg_number
>= 0 || reg_number
== -3)
783 error_with_decl (decl
,
784 "register name given for non-register variable `%s'");
786 /* Specifying a section attribute on a variable forces it into a
787 non-.bss section, and thus it cannot be common. */
788 if (TREE_CODE (decl
) == VAR_DECL
789 && DECL_SECTION_NAME (decl
) != NULL_TREE
790 && DECL_INITIAL (decl
) == NULL_TREE
791 && DECL_COMMON (decl
))
792 DECL_COMMON (decl
) = 0;
794 /* Can't use just the variable's own name for a variable
795 whose scope is less than the whole file, unless it's a member
796 of a local class (which will already be unambiguous).
797 Concatenate a distinguishing number. */
798 if (!top_level
&& !TREE_PUBLIC (decl
)
799 && ! (DECL_CONTEXT (decl
) && TYPE_P (DECL_CONTEXT (decl
)))
803 ASM_FORMAT_PRIVATE_NAME (label
, name
, var_labelno
);
808 /* When -fprefix-function-name is used, the functions
809 names are prefixed. Only nested function names are not
811 else if (flag_prefix_function_name
&& TREE_CODE (decl
) == FUNCTION_DECL
)
813 size_t name_len
= IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (decl
));
816 pname
= alloca (name_len
+ CHKR_PREFIX_SIZE
+ 1);
817 memcpy (pname
, CHKR_PREFIX
, CHKR_PREFIX_SIZE
);
818 memcpy (pname
+ CHKR_PREFIX_SIZE
, name
, name_len
+ 1);
822 if (name
!= new_name
)
824 DECL_ASSEMBLER_NAME (decl
) = get_identifier (new_name
);
825 name
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
));
828 /* If this variable is to be treated as volatile, show its
829 tree node has side effects. */
830 if ((flag_volatile_global
&& TREE_CODE (decl
) == VAR_DECL
831 && TREE_PUBLIC (decl
))
832 || ((flag_volatile_static
&& TREE_CODE (decl
) == VAR_DECL
833 && (TREE_PUBLIC (decl
) || TREE_STATIC (decl
)))))
834 TREE_SIDE_EFFECTS (decl
) = 1;
836 DECL_RTL (decl
) = gen_rtx_MEM (DECL_MODE (decl
),
837 gen_rtx_SYMBOL_REF (Pmode
, name
));
838 if (TREE_CODE (decl
) != FUNCTION_DECL
)
839 set_mem_attributes (DECL_RTL (decl
), decl
, 1);
841 /* Optionally set flags or add text to the name to record information
842 such as that it is a function name.
843 If the name is changed, the macro ASM_OUTPUT_LABELREF
844 will have to know how to strip this information. */
845 #ifdef ENCODE_SECTION_INFO
846 ENCODE_SECTION_INFO (decl
);
850 /* Make the rtl for variable VAR be volatile.
851 Use this only for static variables. */
854 make_var_volatile (var
)
857 if (GET_CODE (DECL_RTL (var
)) != MEM
)
860 MEM_VOLATILE_P (DECL_RTL (var
)) = 1;
863 /* Output alignment directive to align for constant expression EXP. */
866 assemble_constant_align (exp
)
871 /* Align the location counter as required by EXP's data type. */
872 align
= TYPE_ALIGN (TREE_TYPE (exp
));
873 #ifdef CONSTANT_ALIGNMENT
874 align
= CONSTANT_ALIGNMENT (exp
, align
);
877 if (align
> BITS_PER_UNIT
)
878 ASM_OUTPUT_ALIGN (asm_out_file
, floor_log2 (align
/ BITS_PER_UNIT
));
881 /* Output a string of literal assembler code
882 for an `asm' keyword used between functions. */
885 assemble_asm (string
)
890 if (TREE_CODE (string
) == ADDR_EXPR
)
891 string
= TREE_OPERAND (string
, 0);
893 fprintf (asm_out_file
, "\t%s\n", TREE_STRING_POINTER (string
));
896 #if 0 /* This should no longer be needed, because
897 flag_gnu_linker should be 0 on these systems,
898 which should prevent any output
899 if ASM_OUTPUT_CONSTRUCTOR and ASM_OUTPUT_DESTRUCTOR are absent. */
900 #if !(defined(DBX_DEBUGGING_INFO) && !defined(FASCIST_ASSEMBLER))
901 #ifndef ASM_OUTPUT_CONSTRUCTOR
902 #define ASM_OUTPUT_CONSTRUCTOR(file, name)
904 #ifndef ASM_OUTPUT_DESTRUCTOR
905 #define ASM_OUTPUT_DESTRUCTOR(file, name)
910 /* Record an element in the table of global destructors.
911 How this is done depends on what sort of assembler and linker
914 NAME should be the name of a global function to be called
915 at exit time. This name is output using assemble_name. */
918 assemble_destructor (name
)
921 #ifdef ASM_OUTPUT_DESTRUCTOR
922 ASM_OUTPUT_DESTRUCTOR (asm_out_file
, name
);
926 /* Now tell GNU LD that this is part of the static destructor set. */
927 /* This code works for any machine provided you use GNU as/ld. */
928 fprintf (asm_out_file
, "%s\"___DTOR_LIST__\",22,0,0,", ASM_STABS_OP
);
929 assemble_name (asm_out_file
, name
);
930 fputc ('\n', asm_out_file
);
935 /* Likewise for global constructors. */
938 assemble_constructor (name
)
941 #ifdef ASM_OUTPUT_CONSTRUCTOR
942 ASM_OUTPUT_CONSTRUCTOR (asm_out_file
, name
);
946 /* Now tell GNU LD that this is part of the static constructor set. */
947 /* This code works for any machine provided you use GNU as/ld. */
948 fprintf (asm_out_file
, "%s\"___CTOR_LIST__\",22,0,0,", ASM_STABS_OP
);
949 assemble_name (asm_out_file
, name
);
950 fputc ('\n', asm_out_file
);
955 /* Likewise for entries we want to record for garbage collection.
956 Garbage collection is still under development. */
959 assemble_gc_entry (name
)
962 #ifdef ASM_OUTPUT_GC_ENTRY
963 ASM_OUTPUT_GC_ENTRY (asm_out_file
, name
);
967 /* Now tell GNU LD that this is part of the static constructor set. */
968 fprintf (asm_out_file
, "%s\"___PTR_LIST__\",22,0,0,", ASM_STABS_OP
);
969 assemble_name (asm_out_file
, name
);
970 fputc ('\n', asm_out_file
);
975 /* CONSTANT_POOL_BEFORE_FUNCTION may be defined as an expression with
976 a non-zero value if the constant pool should be output before the
977 start of the function, or a zero value if the pool should output
978 after the end of the function. The default is to put it before the
981 #ifndef CONSTANT_POOL_BEFORE_FUNCTION
982 #define CONSTANT_POOL_BEFORE_FUNCTION 1
985 /* Output assembler code for the constant pool of a function and associated
986 with defining the name of the function. DECL describes the function.
987 NAME is the function's name. For the constant pool, we use the current
988 constant pool data. */
991 assemble_start_function (decl
, fnname
)
997 /* The following code does not need preprocessing in the assembler. */
1001 if (CONSTANT_POOL_BEFORE_FUNCTION
)
1002 output_constant_pool (fnname
, decl
);
1004 #ifdef ASM_OUTPUT_SECTION_NAME
1005 /* If the function is to be put in its own section and it's not in a section
1006 already, indicate so. */
1007 if ((flag_function_sections
1008 && DECL_SECTION_NAME (decl
) == NULL_TREE
)
1009 || UNIQUE_SECTION_P (decl
))
1010 UNIQUE_SECTION (decl
, 0);
1013 function_section (decl
);
1015 /* Tell assembler to move to target machine's alignment for functions. */
1016 align
= floor_log2 (FUNCTION_BOUNDARY
/ BITS_PER_UNIT
);
1018 ASM_OUTPUT_ALIGN (asm_out_file
, align
);
1020 /* Handle a user-specified function alignment.
1021 Note that we still need to align to FUNCTION_BOUNDARY, as above,
1022 because ASM_OUTPUT_MAX_SKIP_ALIGN might not do any alignment at all. */
1023 if (align_functions_log
> align
)
1025 #ifdef ASM_OUTPUT_MAX_SKIP_ALIGN
1026 ASM_OUTPUT_MAX_SKIP_ALIGN (asm_out_file
,
1027 align_functions_log
, align_functions
-1);
1029 ASM_OUTPUT_ALIGN (asm_out_file
, align_functions_log
);
1033 #ifdef ASM_OUTPUT_FUNCTION_PREFIX
1034 ASM_OUTPUT_FUNCTION_PREFIX (asm_out_file
, fnname
);
1037 #ifdef SDB_DEBUGGING_INFO
1038 /* Output SDB definition of the function. */
1039 if (write_symbols
== SDB_DEBUG
)
1040 sdbout_mark_begin_function ();
1043 #ifdef DBX_DEBUGGING_INFO
1044 /* Output DBX definition of the function. */
1045 if (write_symbols
== DBX_DEBUG
)
1046 dbxout_begin_function (decl
);
1049 /* Make function name accessible from other files, if appropriate. */
1051 if (TREE_PUBLIC (decl
))
1053 if (! first_global_object_name
)
1058 STRIP_NAME_ENCODING (p
, fnname
);
1059 name
= permalloc (strlen (p
) + 1);
1062 if (! DECL_WEAK (decl
) && ! DECL_ONE_ONLY (decl
))
1063 first_global_object_name
= name
;
1065 weak_global_object_name
= name
;
1068 #ifdef ASM_WEAKEN_LABEL
1069 if (DECL_WEAK (decl
))
1071 ASM_WEAKEN_LABEL (asm_out_file
, fnname
);
1072 /* Remove this function from the pending weak list so that
1073 we do not emit multiple .weak directives for it. */
1074 remove_from_pending_weak_list
1075 (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)));
1079 ASM_GLOBALIZE_LABEL (asm_out_file
, fnname
);
1082 /* Do any machine/system dependent processing of the function name */
1083 #ifdef ASM_DECLARE_FUNCTION_NAME
1084 ASM_DECLARE_FUNCTION_NAME (asm_out_file
, fnname
, current_function_decl
);
1086 /* Standard thing is just output label for the function. */
1087 ASM_OUTPUT_LABEL (asm_out_file
, fnname
);
1088 #endif /* ASM_DECLARE_FUNCTION_NAME */
1091 /* Output assembler code associated with defining the size of the
1092 function. DECL describes the function. NAME is the function's name. */
1095 assemble_end_function (decl
, fnname
)
1099 #ifdef ASM_DECLARE_FUNCTION_SIZE
1100 ASM_DECLARE_FUNCTION_SIZE (asm_out_file
, fnname
, decl
);
1102 if (! CONSTANT_POOL_BEFORE_FUNCTION
)
1104 output_constant_pool (fnname
, decl
);
1105 function_section (decl
); /* need to switch back */
1108 /* Output any constants which should appear after the function. */
1109 output_after_function_constants ();
1112 /* Assemble code to leave SIZE bytes of zeros. */
1115 assemble_zeros (size
)
1118 /* Do no output if -fsyntax-only. */
1119 if (flag_syntax_only
)
1122 #ifdef ASM_NO_SKIP_IN_TEXT
1123 /* The `space' pseudo in the text section outputs nop insns rather than 0s,
1124 so we must output 0s explicitly in the text section. */
1125 if (ASM_NO_SKIP_IN_TEXT
&& in_text_section ())
1129 for (i
= 0; i
< size
- 20; i
+= 20)
1132 fprintf (asm_out_file
,
1133 "%s0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n", ASM_BYTE_OP
);
1135 fprintf (asm_out_file
,
1136 "\tbyte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n");
1142 fprintf (asm_out_file
, "%s0", ASM_BYTE_OP
);
1144 fprintf (asm_out_file
, "\tbyte 0");
1147 for (; i
< size
; i
++)
1148 fprintf (asm_out_file
, ",0");
1149 fprintf (asm_out_file
, "\n");
1155 ASM_OUTPUT_SKIP (asm_out_file
, size
);
1158 /* Assemble an alignment pseudo op for an ALIGN-bit boundary. */
1161 assemble_align (align
)
1164 if (align
> BITS_PER_UNIT
)
1165 ASM_OUTPUT_ALIGN (asm_out_file
, floor_log2 (align
/ BITS_PER_UNIT
));
1168 /* Assemble a string constant with the specified C string as contents. */
1171 assemble_string (p
, size
)
1178 /* If the string is very long, split it up. */
1182 int thissize
= size
- pos
;
1183 if (thissize
> maximum
)
1186 ASM_OUTPUT_ASCII (asm_out_file
, p
, thissize
);
1194 #if defined ASM_OUTPUT_ALIGNED_DECL_LOCAL
1195 #define ASM_EMIT_LOCAL(decl, name, size, rounded) \
1196 ASM_OUTPUT_ALIGNED_DECL_LOCAL (asm_out_file, decl, name, size, DECL_ALIGN (decl))
1198 #if defined ASM_OUTPUT_ALIGNED_LOCAL
1199 #define ASM_EMIT_LOCAL(decl, name, size, rounded) \
1200 ASM_OUTPUT_ALIGNED_LOCAL (asm_out_file, name, size, DECL_ALIGN (decl))
1202 #define ASM_EMIT_LOCAL(decl, name, size, rounded) \
1203 ASM_OUTPUT_LOCAL (asm_out_file, name, size, rounded)
1207 #if defined ASM_OUTPUT_ALIGNED_BSS
1208 #define ASM_EMIT_BSS(decl, name, size, rounded) \
1209 ASM_OUTPUT_ALIGNED_BSS (asm_out_file, decl, name, size, DECL_ALIGN (decl))
1211 #if defined ASM_OUTPUT_BSS
1212 #define ASM_EMIT_BSS(decl, name, size, rounded) \
1213 ASM_OUTPUT_BSS (asm_out_file, decl, name, size, rounded)
1219 #if defined ASM_OUTPUT_ALIGNED_DECL_COMMON
1220 #define ASM_EMIT_COMMON(decl, name, size, rounded) \
1221 ASM_OUTPUT_ALIGNED_DECL_COMMON (asm_out_file, decl, name, size, DECL_ALIGN (decl))
1223 #if defined ASM_OUTPUT_ALIGNED_COMMON
1224 #define ASM_EMIT_COMMON(decl, name, size, rounded) \
1225 ASM_OUTPUT_ALIGNED_COMMON (asm_out_file, name, size, DECL_ALIGN (decl))
1227 #define ASM_EMIT_COMMON(decl, name, size, rounded) \
1228 ASM_OUTPUT_COMMON (asm_out_file, name, size, rounded)
1233 asm_emit_uninitialised (decl
, name
, size
, rounded
)
1236 int size ATTRIBUTE_UNUSED
;
1237 int rounded ATTRIBUTE_UNUSED
;
1245 destination
= asm_dest_local
;
1247 if (TREE_PUBLIC (decl
))
1249 #if defined ASM_EMIT_BSS
1250 if (! DECL_COMMON (decl
))
1251 destination
= asm_dest_bss
;
1254 destination
= asm_dest_common
;
1257 if (flag_shared_data
)
1259 switch (destination
)
1261 #ifdef ASM_OUTPUT_SHARED_BSS
1263 ASM_OUTPUT_SHARED_BSS (asm_out_file
, decl
, name
, size
, rounded
);
1266 #ifdef ASM_OUTPUT_SHARED_COMMON
1267 case asm_dest_common
:
1268 ASM_OUTPUT_SHARED_COMMON (asm_out_file
, name
, size
, rounded
);
1271 #ifdef ASM_OUTPUT_SHARED_LOCAL
1272 case asm_dest_local
:
1273 ASM_OUTPUT_SHARED_LOCAL (asm_out_file
, name
, size
, rounded
);
1281 #ifdef ASM_OUTPUT_SECTION_NAME
1282 /* We already know that DECL_SECTION_NAME() == NULL. */
1283 if (flag_data_sections
!= 0 || UNIQUE_SECTION_P (decl
))
1284 UNIQUE_SECTION (decl
, 0);
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 const char *name
;
1327 enum in_section saved_in_section
;
1329 last_assemble_variable_decl
= 0;
1331 if (GET_CODE (DECL_RTL (decl
)) == REG
)
1333 /* Do output symbol info for global register variables, but do nothing
1336 if (TREE_ASM_WRITTEN (decl
))
1338 TREE_ASM_WRITTEN (decl
) = 1;
1340 /* Do no output if -fsyntax-only. */
1341 if (flag_syntax_only
)
1344 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
1345 /* File-scope global variables are output here. */
1346 if ((write_symbols
== DBX_DEBUG
|| write_symbols
== XCOFF_DEBUG
)
1348 dbxout_symbol (decl
, 0);
1350 #ifdef SDB_DEBUGGING_INFO
1351 if (write_symbols
== SDB_DEBUG
&& top_level
1352 /* Leave initialized global vars for end of compilation;
1353 see comment in compile_file. */
1354 && (TREE_PUBLIC (decl
) == 0 || DECL_INITIAL (decl
) == 0))
1355 sdbout_symbol (decl
, 0);
1358 /* Don't output any DWARF debugging information for variables here.
1359 In the case of local variables, the information for them is output
1360 when we do our recursive traversal of the tree representation for
1361 the entire containing function. In the case of file-scope variables,
1362 we output information for all of them at the very end of compilation
1363 while we are doing our final traversal of the chain of file-scope
1369 /* Normally no need to say anything here for external references,
1370 since assemble_external is called by the language-specific code
1371 when a declaration is first seen. */
1373 if (DECL_EXTERNAL (decl
))
1376 /* Output no assembler code for a function declaration.
1377 Only definitions of functions output anything. */
1379 if (TREE_CODE (decl
) == FUNCTION_DECL
)
1382 /* If type was incomplete when the variable was declared,
1383 see if it is complete now. */
1385 if (DECL_SIZE (decl
) == 0)
1386 layout_decl (decl
, 0);
1388 /* Still incomplete => don't allocate it; treat the tentative defn
1389 (which is what it must have been) as an `extern' reference. */
1391 if (!dont_output_data
&& DECL_SIZE (decl
) == 0)
1393 error_with_file_and_line (DECL_SOURCE_FILE (decl
),
1394 DECL_SOURCE_LINE (decl
),
1395 "storage size of `%s' isn't known",
1396 IDENTIFIER_POINTER (DECL_NAME (decl
)));
1397 TREE_ASM_WRITTEN (decl
) = 1;
1401 /* The first declaration of a variable that comes through this function
1402 decides whether it is global (in C, has external linkage)
1403 or local (in C, has internal linkage). So do nothing more
1404 if this function has already run. */
1406 if (TREE_ASM_WRITTEN (decl
))
1409 TREE_ASM_WRITTEN (decl
) = 1;
1411 /* Do no output if -fsyntax-only. */
1412 if (flag_syntax_only
)
1417 if (! dont_output_data
1418 && ! host_integerp (DECL_SIZE_UNIT (decl
), 1))
1420 error_with_decl (decl
, "size of variable `%s' is too large");
1424 name
= XSTR (XEXP (DECL_RTL (decl
), 0), 0);
1425 if (TREE_PUBLIC (decl
) && DECL_NAME (decl
)
1426 && ! first_global_object_name
1427 && ! (DECL_COMMON (decl
) && (DECL_INITIAL (decl
) == 0
1428 || DECL_INITIAL (decl
) == error_mark_node
))
1429 && ! DECL_WEAK (decl
)
1430 && ! DECL_ONE_ONLY (decl
))
1435 STRIP_NAME_ENCODING (p
, name
);
1436 xname
= permalloc (strlen (p
) + 1);
1438 first_global_object_name
= xname
;
1441 /* Compute the alignment of this data. */
1443 align
= DECL_ALIGN (decl
);
1445 /* In the case for initialing an array whose length isn't specified,
1446 where we have not yet been able to do the layout,
1447 figure out the proper alignment now. */
1448 if (dont_output_data
&& DECL_SIZE (decl
) == 0
1449 && TREE_CODE (TREE_TYPE (decl
)) == ARRAY_TYPE
)
1450 align
= MAX (align
, TYPE_ALIGN (TREE_TYPE (TREE_TYPE (decl
))));
1452 /* Some object file formats have a maximum alignment which they support.
1453 In particular, a.out format supports a maximum alignment of 4. */
1454 #ifndef MAX_OFILE_ALIGNMENT
1455 #define MAX_OFILE_ALIGNMENT BIGGEST_ALIGNMENT
1457 if (align
> MAX_OFILE_ALIGNMENT
)
1459 warning_with_decl (decl
,
1460 "alignment of `%s' is greater than maximum object file alignment. Using %d.",
1461 MAX_OFILE_ALIGNMENT
/BITS_PER_UNIT
);
1462 align
= MAX_OFILE_ALIGNMENT
;
1465 /* On some machines, it is good to increase alignment sometimes. */
1466 #ifdef DATA_ALIGNMENT
1467 align
= DATA_ALIGNMENT (TREE_TYPE (decl
), align
);
1469 #ifdef CONSTANT_ALIGNMENT
1470 if (DECL_INITIAL (decl
) != 0 && DECL_INITIAL (decl
) != error_mark_node
)
1471 align
= CONSTANT_ALIGNMENT (DECL_INITIAL (decl
), align
);
1474 /* Reset the alignment in case we have made it tighter, so we can benefit
1475 from it in get_pointer_alignment. */
1476 DECL_ALIGN (decl
) = align
;
1478 /* Handle uninitialized definitions. */
1480 if ((DECL_INITIAL (decl
) == 0 || DECL_INITIAL (decl
) == error_mark_node
)
1481 /* If the target can't output uninitialized but not common global data
1482 in .bss, then we have to use .data. */
1483 #if ! defined ASM_EMIT_BSS
1484 && DECL_COMMON (decl
)
1486 && DECL_SECTION_NAME (decl
) == NULL_TREE
1487 && ! dont_output_data
)
1489 unsigned HOST_WIDE_INT size
= tree_low_cst (DECL_SIZE_UNIT (decl
), 1);
1490 unsigned HOST_WIDE_INT rounded
= size
;
1492 /* Don't allocate zero bytes of common,
1493 since that means "undefined external" in the linker. */
1497 /* Round size up to multiple of BIGGEST_ALIGNMENT bits
1498 so that each uninitialized object starts on such a boundary. */
1499 rounded
+= (BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
) - 1;
1500 rounded
= (rounded
/ (BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
)
1501 * (BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
));
1503 /* Don't continue this line--convex cc version 4.1 would lose. */
1504 #if !defined(ASM_OUTPUT_ALIGNED_COMMON) && !defined(ASM_OUTPUT_ALIGNED_DECL_COMMON) && !defined(ASM_OUTPUT_ALIGNED_BSS)
1505 if ((unsigned HOST_WIDE_INT
) DECL_ALIGN (decl
) / BITS_PER_UNIT
> rounded
)
1507 (decl
, "requested alignment for %s is greater than implemented alignment of %d.",rounded
);
1510 #ifdef DBX_DEBUGGING_INFO
1511 /* File-scope global variables are output here. */
1512 if (write_symbols
== DBX_DEBUG
&& top_level
)
1513 dbxout_symbol (decl
, 0);
1515 #ifdef SDB_DEBUGGING_INFO
1516 if (write_symbols
== SDB_DEBUG
&& top_level
1517 /* Leave initialized global vars for end of compilation;
1518 see comment in compile_file. */
1519 && (TREE_PUBLIC (decl
) == 0 || DECL_INITIAL (decl
) == 0))
1520 sdbout_symbol (decl
, 0);
1523 /* Don't output any DWARF debugging information for variables here.
1524 In the case of local variables, the information for them is output
1525 when we do our recursive traversal of the tree representation for
1526 the entire containing function. In the case of file-scope variables,
1527 we output information for all of them at the very end of compilation
1528 while we are doing our final traversal of the chain of file-scope
1531 #if 0 /* ??? We should either delete this or add a comment describing what
1532 it was intended to do and why we shouldn't delete it. */
1533 if (flag_shared_data
)
1536 asm_emit_uninitialised (decl
, name
, size
, rounded
);
1541 /* Handle initialized definitions.
1542 Also handle uninitialized global definitions if -fno-common and the
1543 target doesn't support ASM_OUTPUT_BSS. */
1545 /* First make the assembler name(s) global if appropriate. */
1546 if (TREE_PUBLIC (decl
) && DECL_NAME (decl
))
1548 #ifdef ASM_WEAKEN_LABEL
1549 if (DECL_WEAK (decl
))
1551 ASM_WEAKEN_LABEL (asm_out_file
, name
);
1552 /* Remove this variable from the pending weak list so that
1553 we do not emit multiple .weak directives for it. */
1554 remove_from_pending_weak_list
1555 (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)));
1559 ASM_GLOBALIZE_LABEL (asm_out_file
, name
);
1562 for (d
= equivalents
; d
; d
= TREE_CHAIN (d
))
1564 tree e
= TREE_VALUE (d
);
1565 if (TREE_PUBLIC (e
) && DECL_NAME (e
))
1566 ASM_GLOBALIZE_LABEL (asm_out_file
,
1567 XSTR (XEXP (DECL_RTL (e
), 0), 0));
1571 /* Output any data that we will need to use the address of. */
1572 if (DECL_INITIAL (decl
) == error_mark_node
)
1573 reloc
= contains_pointers_p (TREE_TYPE (decl
));
1574 else if (DECL_INITIAL (decl
))
1575 reloc
= output_addressed_constants (DECL_INITIAL (decl
));
1577 #ifdef ASM_OUTPUT_SECTION_NAME
1578 if ((flag_data_sections
!= 0 && DECL_SECTION_NAME (decl
) == NULL_TREE
)
1579 || UNIQUE_SECTION_P (decl
))
1580 UNIQUE_SECTION (decl
, reloc
);
1583 /* Switch to the appropriate section. */
1584 variable_section (decl
, reloc
);
1586 /* dbxout.c needs to know this. */
1587 if (in_text_section ())
1588 DECL_IN_TEXT_SECTION (decl
) = 1;
1590 /* Record current section so we can restore it if dbxout.c clobbers it. */
1591 saved_in_section
= in_section
;
1593 /* Output the dbx info now that we have chosen the section. */
1595 #ifdef DBX_DEBUGGING_INFO
1596 /* File-scope global variables are output here. */
1597 if (write_symbols
== DBX_DEBUG
&& top_level
)
1598 dbxout_symbol (decl
, 0);
1600 #ifdef SDB_DEBUGGING_INFO
1601 if (write_symbols
== SDB_DEBUG
&& top_level
1602 /* Leave initialized global vars for end of compilation;
1603 see comment in compile_file. */
1604 && (TREE_PUBLIC (decl
) == 0 || DECL_INITIAL (decl
) == 0))
1605 sdbout_symbol (decl
, 0);
1608 /* Don't output any DWARF debugging information for variables here.
1609 In the case of local variables, the information for them is output
1610 when we do our recursive traversal of the tree representation for
1611 the entire containing function. In the case of file-scope variables,
1612 we output information for all of them at the very end of compilation
1613 while we are doing our final traversal of the chain of file-scope
1616 /* If the debugging output changed sections, reselect the section
1617 that's supposed to be selected. */
1618 if (in_section
!= saved_in_section
)
1619 variable_section (decl
, reloc
);
1621 /* Output the alignment of this data. */
1622 if (align
> BITS_PER_UNIT
)
1623 ASM_OUTPUT_ALIGN (asm_out_file
,
1624 floor_log2 (DECL_ALIGN (decl
) / BITS_PER_UNIT
));
1626 /* Do any machine/system dependent processing of the object. */
1627 #ifdef ASM_DECLARE_OBJECT_NAME
1628 last_assemble_variable_decl
= decl
;
1629 ASM_DECLARE_OBJECT_NAME (asm_out_file
, name
, decl
);
1631 /* Standard thing is just output label for the object. */
1632 ASM_OUTPUT_LABEL (asm_out_file
, name
);
1633 #endif /* ASM_DECLARE_OBJECT_NAME */
1635 if (!dont_output_data
)
1637 if (DECL_INITIAL (decl
))
1638 /* Output the actual data. */
1639 output_constant (DECL_INITIAL (decl
),
1640 tree_low_cst (DECL_SIZE_UNIT (decl
), 1));
1642 /* Leave space for it. */
1643 assemble_zeros (tree_low_cst (DECL_SIZE_UNIT (decl
), 1));
1647 #ifdef XCOFF_DEBUGGING_INFO
1648 /* Unfortunately, the IBM assembler cannot handle stabx before the actual
1649 declaration. When something like ".stabx "aa:S-2",aa,133,0" is emitted
1650 and `aa' hasn't been output yet, the assembler generates a stab entry with
1651 a value of zero, in addition to creating an unnecessary external entry
1652 for `aa'. Hence, we must postpone dbxout_symbol to here at the end. */
1654 /* File-scope global variables are output here. */
1655 if (write_symbols
== XCOFF_DEBUG
&& top_level
)
1657 saved_in_section
= in_section
;
1659 dbxout_symbol (decl
, 0);
1661 if (in_section
!= saved_in_section
)
1662 variable_section (decl
, reloc
);
1665 /* There must be a statement after a label. */
1670 /* Return 1 if type TYPE contains any pointers. */
1673 contains_pointers_p (type
)
1676 switch (TREE_CODE (type
))
1679 case REFERENCE_TYPE
:
1680 /* I'm not sure whether OFFSET_TYPE needs this treatment,
1681 so I'll play safe and return 1. */
1687 case QUAL_UNION_TYPE
:
1690 /* For a type that has fields, see if the fields have pointers. */
1691 for (fields
= TYPE_FIELDS (type
); fields
; fields
= TREE_CHAIN (fields
))
1692 if (TREE_CODE (fields
) == FIELD_DECL
1693 && contains_pointers_p (TREE_TYPE (fields
)))
1699 /* An array type contains pointers if its element type does. */
1700 return contains_pointers_p (TREE_TYPE (type
));
1707 /* Output something to declare an external symbol to the assembler.
1708 (Most assemblers don't need this, so we normally output nothing.)
1709 Do nothing if DECL is not external. */
1712 assemble_external (decl
)
1713 tree decl ATTRIBUTE_UNUSED
;
1715 #ifdef ASM_OUTPUT_EXTERNAL
1716 if (DECL_P (decl
) && DECL_EXTERNAL (decl
) && TREE_PUBLIC (decl
))
1718 rtx rtl
= DECL_RTL (decl
);
1720 if (GET_CODE (rtl
) == MEM
&& GET_CODE (XEXP (rtl
, 0)) == SYMBOL_REF
1721 && ! SYMBOL_REF_USED (XEXP (rtl
, 0)))
1723 /* Some systems do require some output. */
1724 SYMBOL_REF_USED (XEXP (rtl
, 0)) = 1;
1725 ASM_OUTPUT_EXTERNAL (asm_out_file
, decl
, XSTR (XEXP (rtl
, 0), 0));
1731 /* Similar, for calling a library function FUN. */
1734 assemble_external_libcall (fun
)
1735 rtx fun ATTRIBUTE_UNUSED
;
1737 #ifdef ASM_OUTPUT_EXTERNAL_LIBCALL
1738 /* Declare library function name external when first used, if nec. */
1739 if (! SYMBOL_REF_USED (fun
))
1741 SYMBOL_REF_USED (fun
) = 1;
1742 ASM_OUTPUT_EXTERNAL_LIBCALL (asm_out_file
, fun
);
1747 /* Declare the label NAME global. */
1750 assemble_global (name
)
1753 ASM_GLOBALIZE_LABEL (asm_out_file
, name
);
1756 /* Assemble a label named NAME. */
1759 assemble_label (name
)
1762 ASM_OUTPUT_LABEL (asm_out_file
, name
);
1765 /* Output to FILE a reference to the assembler name of a C-level name NAME.
1766 If NAME starts with a *, the rest of NAME is output verbatim.
1767 Otherwise NAME is transformed in an implementation-defined way
1768 (usually by the addition of an underscore).
1769 Many macros in the tm file are defined to call this function. */
1772 assemble_name (file
, name
)
1776 const char *real_name
;
1779 STRIP_NAME_ENCODING (real_name
, name
);
1780 if (flag_prefix_function_name
1781 && ! memcmp (real_name
, CHKR_PREFIX
, CHKR_PREFIX_SIZE
))
1782 real_name
= real_name
+ CHKR_PREFIX_SIZE
;
1784 id
= maybe_get_identifier (real_name
);
1786 TREE_SYMBOL_REFERENCED (id
) = 1;
1789 fputs (&name
[1], file
);
1791 ASM_OUTPUT_LABELREF (file
, name
);
1794 /* Allocate SIZE bytes writable static space with a gensym name
1795 and return an RTX to refer to its address. */
1798 assemble_static_space (size
)
1802 const char *namestring
;
1806 if (flag_shared_data
)
1810 ASM_GENERATE_INTERNAL_LABEL (name
, "LF", const_labelno
);
1812 namestring
= ggc_strdup (name
);
1814 x
= gen_rtx_SYMBOL_REF (Pmode
, namestring
);
1816 #ifdef ASM_OUTPUT_ALIGNED_DECL_LOCAL
1817 ASM_OUTPUT_ALIGNED_DECL_LOCAL (asm_out_file
, NULL_TREE
, name
, size
,
1820 #ifdef ASM_OUTPUT_ALIGNED_LOCAL
1821 ASM_OUTPUT_ALIGNED_LOCAL (asm_out_file
, name
, size
, BIGGEST_ALIGNMENT
);
1824 /* Round size up to multiple of BIGGEST_ALIGNMENT bits
1825 so that each uninitialized object starts on such a boundary. */
1826 /* Variable `rounded' might or might not be used in ASM_OUTPUT_LOCAL. */
1827 int rounded ATTRIBUTE_UNUSED
1828 = ((size
+ (BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
) - 1)
1829 / (BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
)
1830 * (BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
));
1831 ASM_OUTPUT_LOCAL (asm_out_file
, name
, size
, rounded
);
1838 /* Assemble the static constant template for function entry trampolines.
1839 This is done at most once per compilation.
1840 Returns an RTX for the address of the template. */
1842 #ifdef TRAMPOLINE_TEMPLATE
1844 assemble_trampoline_template ()
1850 /* By default, put trampoline templates in read-only data section. */
1852 #ifdef TRAMPOLINE_SECTION
1853 TRAMPOLINE_SECTION ();
1855 readonly_data_section ();
1858 /* Write the assembler code to define one. */
1859 align
= floor_log2 (TRAMPOLINE_ALIGNMENT
/ BITS_PER_UNIT
);
1861 ASM_OUTPUT_ALIGN (asm_out_file
, align
);
1863 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, "LTRAMP", 0);
1864 TRAMPOLINE_TEMPLATE (asm_out_file
);
1866 /* Record the rtl to refer to it. */
1867 ASM_GENERATE_INTERNAL_LABEL (label
, "LTRAMP", 0);
1868 name
= ggc_strdup (label
);
1869 return gen_rtx_SYMBOL_REF (Pmode
, name
);
1873 /* Assemble the integer constant X into an object of SIZE bytes.
1874 X must be either a CONST_INT or CONST_DOUBLE.
1876 Return 1 if we were able to output the constant, otherwise 0. If FORCE is
1877 non-zero, abort if we can't output the constant. */
1880 assemble_integer (x
, size
, force
)
1885 /* First try to use the standard 1, 2, 4, 8, and 16 byte
1886 ASM_OUTPUT... macros. */
1890 #ifdef ASM_OUTPUT_CHAR
1892 ASM_OUTPUT_CHAR (asm_out_file
, x
);
1896 #ifdef ASM_OUTPUT_SHORT
1898 ASM_OUTPUT_SHORT (asm_out_file
, x
);
1902 #ifdef ASM_OUTPUT_INT
1904 ASM_OUTPUT_INT (asm_out_file
, x
);
1908 #ifdef ASM_OUTPUT_DOUBLE_INT
1910 ASM_OUTPUT_DOUBLE_INT (asm_out_file
, x
);
1914 #ifdef ASM_OUTPUT_QUADRUPLE_INT
1916 ASM_OUTPUT_QUADRUPLE_INT (asm_out_file
, x
);
1921 /* If we couldn't do it that way, there are two other possibilities: First,
1922 if the machine can output an explicit byte and this is a 1 byte constant,
1923 we can use ASM_OUTPUT_BYTE. */
1925 #ifdef ASM_OUTPUT_BYTE
1926 if (size
== 1 && GET_CODE (x
) == CONST_INT
)
1928 ASM_OUTPUT_BYTE (asm_out_file
, INTVAL (x
));
1933 /* Finally, if SIZE is larger than a single word, try to output the constant
1934 one word at a time. */
1936 if (size
> UNITS_PER_WORD
)
1939 enum machine_mode mode
1940 = mode_for_size (size
* BITS_PER_UNIT
, MODE_INT
, 0);
1943 for (i
= 0; i
< size
/ UNITS_PER_WORD
; i
++)
1945 word
= operand_subword (x
, i
, 0, mode
);
1950 if (! assemble_integer (word
, UNITS_PER_WORD
, 0))
1954 if (i
== size
/ UNITS_PER_WORD
)
1956 /* If we output at least one word and then could not finish,
1957 there is no valid way to continue. */
1968 /* Assemble the floating-point constant D into an object of size MODE. */
1971 assemble_real (d
, mode
)
1973 enum machine_mode mode
;
1975 jmp_buf output_constant_handler
;
1977 if (setjmp (output_constant_handler
))
1979 error ("floating point trap outputting a constant");
1980 #ifdef REAL_IS_NOT_DOUBLE
1981 memset ((char *) &d
, 0, sizeof d
);
1988 set_float_handler (output_constant_handler
);
1992 #ifdef ASM_OUTPUT_BYTE_FLOAT
1994 ASM_OUTPUT_BYTE_FLOAT (asm_out_file
, d
);
1997 #ifdef ASM_OUTPUT_SHORT_FLOAT
1999 ASM_OUTPUT_SHORT_FLOAT (asm_out_file
, d
);
2002 #ifdef ASM_OUTPUT_THREE_QUARTER_FLOAT
2004 ASM_OUTPUT_THREE_QUARTER_FLOAT (asm_out_file
, d
);
2007 #ifdef ASM_OUTPUT_FLOAT
2009 ASM_OUTPUT_FLOAT (asm_out_file
, d
);
2013 #ifdef ASM_OUTPUT_DOUBLE
2015 ASM_OUTPUT_DOUBLE (asm_out_file
, d
);
2019 #ifdef ASM_OUTPUT_LONG_DOUBLE
2022 ASM_OUTPUT_LONG_DOUBLE (asm_out_file
, d
);
2030 set_float_handler (NULL_PTR
);
2033 /* Here we combine duplicate floating constants to make
2034 CONST_DOUBLE rtx's, and force those out to memory when necessary. */
2036 /* Return a CONST_DOUBLE or CONST_INT for a value specified as a pair of ints.
2037 For an integer, I0 is the low-order word and I1 is the high-order word.
2038 For a real number, I0 is the word with the low address
2039 and I1 is the word with the high address. */
2042 immed_double_const (i0
, i1
, mode
)
2043 HOST_WIDE_INT i0
, i1
;
2044 enum machine_mode mode
;
2048 if (GET_MODE_CLASS (mode
) == MODE_INT
2049 || GET_MODE_CLASS (mode
) == MODE_PARTIAL_INT
)
2051 /* We clear out all bits that don't belong in MODE, unless they and our
2052 sign bit are all one. So we get either a reasonable negative value
2053 or a reasonable unsigned value for this mode. */
2054 int width
= GET_MODE_BITSIZE (mode
);
2055 if (width
< HOST_BITS_PER_WIDE_INT
2056 && ((i0
& ((HOST_WIDE_INT
) (-1) << (width
- 1)))
2057 != ((HOST_WIDE_INT
) (-1) << (width
- 1))))
2058 i0
&= ((HOST_WIDE_INT
) 1 << width
) - 1, i1
= 0;
2059 else if (width
== HOST_BITS_PER_WIDE_INT
2060 && ! (i1
== ~0 && i0
< 0))
2062 else if (width
> 2 * HOST_BITS_PER_WIDE_INT
)
2063 /* We cannot represent this value as a constant. */
2066 /* If this would be an entire word for the target, but is not for
2067 the host, then sign-extend on the host so that the number will look
2068 the same way on the host that it would on the target.
2070 For example, when building a 64 bit alpha hosted 32 bit sparc
2071 targeted compiler, then we want the 32 bit unsigned value -1 to be
2072 represented as a 64 bit value -1, and not as 0x00000000ffffffff.
2073 The later confuses the sparc backend. */
2075 if (BITS_PER_WORD
< HOST_BITS_PER_WIDE_INT
&& BITS_PER_WORD
== width
2076 && (i0
& ((HOST_WIDE_INT
) 1 << (width
- 1))))
2077 i0
|= ((HOST_WIDE_INT
) (-1) << width
);
2079 /* If MODE fits within HOST_BITS_PER_WIDE_INT, always use a CONST_INT.
2081 ??? Strictly speaking, this is wrong if we create a CONST_INT
2082 for a large unsigned constant with the size of MODE being
2083 HOST_BITS_PER_WIDE_INT and later try to interpret that constant in a
2084 wider mode. In that case we will mis-interpret it as a negative
2087 Unfortunately, the only alternative is to make a CONST_DOUBLE
2088 for any constant in any mode if it is an unsigned constant larger
2089 than the maximum signed integer in an int on the host. However,
2090 doing this will break everyone that always expects to see a CONST_INT
2091 for SImode and smaller.
2093 We have always been making CONST_INTs in this case, so nothing new
2096 if (width
<= HOST_BITS_PER_WIDE_INT
)
2097 i1
= (i0
< 0) ? ~(HOST_WIDE_INT
) 0 : 0;
2099 /* If this integer fits in one word, return a CONST_INT. */
2100 if ((i1
== 0 && i0
>= 0)
2101 || (i1
== ~0 && i0
< 0))
2102 return GEN_INT (i0
);
2104 /* We use VOIDmode for integers. */
2108 /* Search the chain for an existing CONST_DOUBLE with the right value.
2109 If one is found, return it. */
2111 for (r
= const_double_chain
; r
; r
= CONST_DOUBLE_CHAIN (r
))
2112 if (CONST_DOUBLE_LOW (r
) == i0
&& CONST_DOUBLE_HIGH (r
) == i1
2113 && GET_MODE (r
) == mode
)
2116 /* No; make a new one and add it to the chain. */
2117 r
= gen_rtx_CONST_DOUBLE (mode
, const0_rtx
, i0
, i1
);
2119 /* Don't touch const_double_chain if not inside any function. */
2120 if (current_function_decl
!= 0)
2122 CONST_DOUBLE_CHAIN (r
) = const_double_chain
;
2123 const_double_chain
= r
;
2129 /* Return a CONST_DOUBLE for a specified `double' value
2130 and machine mode. */
2133 immed_real_const_1 (d
, mode
)
2135 enum machine_mode mode
;
2137 union real_extract u
;
2140 /* Get the desired `double' value as a sequence of ints
2141 since that is how they are stored in a CONST_DOUBLE. */
2145 /* Detect special cases. But be careful we don't use a CONST_DOUBLE
2146 that's from a parent function since it may be in its constant pool. */
2147 if (REAL_VALUES_IDENTICAL (dconst0
, d
)
2148 && (cfun
== 0 || decl_function_context (current_function_decl
) == 0))
2149 return CONST0_RTX (mode
);
2151 /* Check for NaN first, because some ports (specifically the i386) do not
2152 emit correct ieee-fp code by default, and thus will generate a core
2153 dump here if we pass a NaN to REAL_VALUES_EQUAL and if REAL_VALUES_EQUAL
2154 does a floating point comparison. */
2155 else if ((! REAL_VALUE_ISNAN (d
) && REAL_VALUES_EQUAL (dconst1
, d
))
2157 || decl_function_context (current_function_decl
) == 0))
2158 return CONST1_RTX (mode
);
2160 if (sizeof u
== sizeof (HOST_WIDE_INT
))
2161 return immed_double_const (u
.i
[0], 0, mode
);
2162 if (sizeof u
== 2 * sizeof (HOST_WIDE_INT
))
2163 return immed_double_const (u
.i
[0], u
.i
[1], mode
);
2165 /* The rest of this function handles the case where
2166 a float value requires more than 2 ints of space.
2167 It will be deleted as dead code on machines that don't need it. */
2169 /* Search the chain for an existing CONST_DOUBLE with the right value.
2170 If one is found, return it. */
2172 for (r
= const_double_chain
; r
; r
= CONST_DOUBLE_CHAIN (r
))
2173 if (! memcmp ((char *) &CONST_DOUBLE_LOW (r
), (char *) &u
, sizeof u
)
2174 && GET_MODE (r
) == mode
)
2177 /* No; make a new one and add it to the chain.
2179 We may be called by an optimizer which may be discarding any memory
2180 allocated during its processing (such as combine and loop). However,
2181 we will be leaving this constant on the chain, so we cannot tolerate
2183 r
= rtx_alloc (CONST_DOUBLE
);
2185 memcpy ((char *) &CONST_DOUBLE_LOW (r
), (char *) &u
, sizeof u
);
2187 /* If we aren't inside a function, don't put r on the
2188 const_double_chain. */
2189 if (current_function_decl
!= 0)
2191 CONST_DOUBLE_CHAIN (r
) = const_double_chain
;
2192 const_double_chain
= r
;
2195 CONST_DOUBLE_CHAIN (r
) = NULL_RTX
;
2197 /* Store const0_rtx in CONST_DOUBLE_MEM since this CONST_DOUBLE is on the
2198 chain, but has not been allocated memory. Actual use of CONST_DOUBLE_MEM
2199 is only through force_const_mem. */
2201 CONST_DOUBLE_MEM (r
) = const0_rtx
;
2206 /* Return a CONST_DOUBLE rtx for a value specified by EXP,
2207 which must be a REAL_CST tree node. */
2210 immed_real_const (exp
)
2213 return immed_real_const_1 (TREE_REAL_CST (exp
), TYPE_MODE (TREE_TYPE (exp
)));
2216 /* At the end of a function, forget the memory-constants
2217 previously made for CONST_DOUBLEs. Mark them as not on real_constant_chain.
2218 Also clear out real_constant_chain and clear out all the chain-pointers. */
2221 clear_const_double_mem ()
2223 register rtx r
, next
;
2225 for (r
= const_double_chain
; r
; r
= next
)
2227 next
= CONST_DOUBLE_CHAIN (r
);
2228 CONST_DOUBLE_CHAIN (r
) = 0;
2229 CONST_DOUBLE_MEM (r
) = cc0_rtx
;
2231 const_double_chain
= 0;
2234 /* Given an expression EXP with a constant value,
2235 reduce it to the sum of an assembler symbol and an integer.
2236 Store them both in the structure *VALUE.
2237 Abort if EXP does not reduce. */
2242 HOST_WIDE_INT offset
;
2246 decode_addr_const (exp
, value
)
2248 struct addr_const
*value
;
2250 register tree target
= TREE_OPERAND (exp
, 0);
2251 register int offset
= 0;
2256 if (TREE_CODE (target
) == COMPONENT_REF
2257 && host_integerp (byte_position (TREE_OPERAND (target
, 1)), 0))
2260 offset
+= int_byte_position (TREE_OPERAND (target
, 1));
2261 target
= TREE_OPERAND (target
, 0);
2263 else if (TREE_CODE (target
) == ARRAY_REF
)
2265 offset
+= (tree_low_cst (TYPE_SIZE_UNIT (TREE_TYPE (target
)), 1)
2266 * tree_low_cst (TREE_OPERAND (target
, 1), 0));
2267 target
= TREE_OPERAND (target
, 0);
2273 switch (TREE_CODE (target
))
2277 x
= DECL_RTL (target
);
2281 x
= gen_rtx_MEM (FUNCTION_MODE
,
2282 gen_rtx_LABEL_REF (VOIDmode
,
2283 label_rtx (TREE_OPERAND (exp
, 0))));
2291 x
= TREE_CST_RTL (target
);
2298 if (GET_CODE (x
) != MEM
)
2303 value
->offset
= offset
;
2308 #ifdef ONLY_INT_FIELDS
2309 unsigned int kind
: 16;
2310 unsigned int mode
: 16;
2312 enum kind kind
: 16;
2313 enum machine_mode mode
: 16;
2316 union real_extract du
;
2317 struct addr_const addr
;
2318 struct {HOST_WIDE_INT high
, low
;} di
;
2322 /* Uniquize all constants that appear in memory.
2323 Each constant in memory thus far output is recorded
2324 in `const_hash_table' with a `struct constant_descriptor'
2325 that contains a polish representation of the value of
2328 We cannot store the trees in the hash table
2329 because the trees may be temporary. */
2331 struct constant_descriptor
2333 struct constant_descriptor
*next
;
2336 /* Make sure the data is reasonably aligned. */
2339 unsigned char contents
[1];
2340 #ifdef HAVE_LONG_DOUBLE
2349 #define MAX_HASH_TABLE 1009
2350 static struct constant_descriptor
*const_hash_table
[MAX_HASH_TABLE
];
2352 #define STRHASH(x) ((hashval_t)((long)(x) >> 3))
2354 struct deferred_string
2361 static htab_t const_str_htab
;
2363 /* Mark a const_hash_table descriptor for GC. */
2366 mark_const_hash_entry (ptr
)
2369 struct constant_descriptor
*desc
= * (struct constant_descriptor
**) ptr
;
2373 ggc_mark_rtx (desc
->rtl
);
2378 /* Mark the hash-table element X (which is really a pointer to an
2379 struct deferred_string *). */
2382 mark_const_str_htab_1 (x
, data
)
2384 void *data ATTRIBUTE_UNUSED
;
2386 ggc_mark_tree (((struct deferred_string
*) *x
)->exp
);
2390 /* Mark a const_str_htab for GC. */
2393 mark_const_str_htab (htab
)
2396 htab_traverse (*((htab_t
*) htab
), mark_const_str_htab_1
, NULL
);
2399 /* Returns a hash code for X (which is a really a
2400 struct deferred_string *). */
2403 const_str_htab_hash (x
)
2406 return STRHASH (((const struct deferred_string
*) x
)->label
);
2409 /* Returns non-zero if the value represented by X (which is really a
2410 struct deferred_string *) is the same as that given by Y
2411 (which is really a char *). */
2414 const_str_htab_eq (x
, y
)
2418 return (((const struct deferred_string
*) x
)->label
== (const char *) y
);
2421 /* Delete the hash table entry dfsp. */
2424 const_str_htab_del (dfsp
)
2430 /* Compute a hash code for a constant expression. */
2436 register const char *p
;
2437 register int len
, hi
, i
;
2438 register enum tree_code code
= TREE_CODE (exp
);
2440 /* Either set P and LEN to the address and len of something to hash and
2441 exit the switch or return a value. */
2446 p
= (char *) &TREE_INT_CST (exp
);
2447 len
= sizeof TREE_INT_CST (exp
);
2451 p
= (char *) &TREE_REAL_CST (exp
);
2452 len
= sizeof TREE_REAL_CST (exp
);
2456 p
= TREE_STRING_POINTER (exp
);
2457 len
= TREE_STRING_LENGTH (exp
);
2461 return (const_hash (TREE_REALPART (exp
)) * 5
2462 + const_hash (TREE_IMAGPART (exp
)));
2465 if (TREE_CODE (TREE_TYPE (exp
)) == SET_TYPE
)
2469 len
= int_size_in_bytes (TREE_TYPE (exp
));
2470 tmp
= (char *) alloca (len
);
2471 get_set_constructor_bytes (exp
, (unsigned char *) tmp
, len
);
2479 /* For record type, include the type in the hashing.
2480 We do not do so for array types
2481 because (1) the sizes of the elements are sufficient
2482 and (2) distinct array types can have the same constructor.
2483 Instead, we include the array size because the constructor could
2485 if (TREE_CODE (TREE_TYPE (exp
)) == RECORD_TYPE
)
2486 hi
= ((unsigned long) TREE_TYPE (exp
) & ((1 << HASHBITS
) - 1))
2489 hi
= ((5 + int_size_in_bytes (TREE_TYPE (exp
)))
2490 & ((1 << HASHBITS
) - 1)) % MAX_HASH_TABLE
;
2492 for (link
= CONSTRUCTOR_ELTS (exp
); link
; link
= TREE_CHAIN (link
))
2493 if (TREE_VALUE (link
))
2495 = (hi
* 603 + const_hash (TREE_VALUE (link
))) % MAX_HASH_TABLE
;
2502 struct addr_const value
;
2504 decode_addr_const (exp
, &value
);
2505 if (GET_CODE (value
.base
) == SYMBOL_REF
)
2507 /* Don't hash the address of the SYMBOL_REF;
2508 only use the offset and the symbol name. */
2510 p
= XSTR (value
.base
, 0);
2511 for (i
= 0; p
[i
] != 0; i
++)
2512 hi
= ((hi
* 613) + (unsigned) (p
[i
]));
2514 else if (GET_CODE (value
.base
) == LABEL_REF
)
2515 hi
= value
.offset
+ CODE_LABEL_NUMBER (XEXP (value
.base
, 0)) * 13;
2519 hi
&= (1 << HASHBITS
) - 1;
2520 hi
%= MAX_HASH_TABLE
;
2526 return (const_hash (TREE_OPERAND (exp
, 0)) * 9
2527 + const_hash (TREE_OPERAND (exp
, 1)));
2531 case NON_LVALUE_EXPR
:
2532 return const_hash (TREE_OPERAND (exp
, 0)) * 7 + 2;
2535 /* A language specific constant. Just hash the code. */
2536 return code
% MAX_HASH_TABLE
;
2539 /* Compute hashing function */
2541 for (i
= 0; i
< len
; i
++)
2542 hi
= ((hi
* 613) + (unsigned) (p
[i
]));
2544 hi
&= (1 << HASHBITS
) - 1;
2545 hi
%= MAX_HASH_TABLE
;
2549 /* Compare a constant expression EXP with a constant-descriptor DESC.
2550 Return 1 if DESC describes a constant with the same value as EXP. */
2553 compare_constant (exp
, desc
)
2555 struct constant_descriptor
*desc
;
2557 return 0 != compare_constant_1 (exp
, desc
->u
.contents
);
2560 /* Compare constant expression EXP with a substring P of a constant descriptor.
2561 If they match, return a pointer to the end of the substring matched.
2562 If they do not match, return 0.
2564 Since descriptors are written in polish prefix notation,
2565 this function can be used recursively to test one operand of EXP
2566 against a subdescriptor, and if it succeeds it returns the
2567 address of the subdescriptor for the next operand. */
2569 static const unsigned char *
2570 compare_constant_1 (exp
, p
)
2572 const unsigned char *p
;
2574 register const unsigned char *strp
;
2576 register enum tree_code code
= TREE_CODE (exp
);
2578 if (code
!= (enum tree_code
) *p
++)
2581 /* Either set STRP, P and LEN to pointers and length to compare and exit the
2582 switch, or return the result of the comparison. */
2587 /* Integer constants are the same only if the same width of type. */
2588 if (*p
++ != TYPE_PRECISION (TREE_TYPE (exp
)))
2591 strp
= (unsigned char *) &TREE_INT_CST (exp
);
2592 len
= sizeof TREE_INT_CST (exp
);
2596 /* Real constants are the same only if the same width of type. */
2597 if (*p
++ != TYPE_PRECISION (TREE_TYPE (exp
)))
2600 strp
= (unsigned char *) &TREE_REAL_CST (exp
);
2601 len
= sizeof TREE_REAL_CST (exp
);
2605 if (flag_writable_strings
)
2608 if ((enum machine_mode
) *p
++ != TYPE_MODE (TREE_TYPE (exp
)))
2611 strp
= (const unsigned char *)TREE_STRING_POINTER (exp
);
2612 len
= TREE_STRING_LENGTH (exp
);
2613 if (memcmp ((char *) &TREE_STRING_LENGTH (exp
), p
,
2614 sizeof TREE_STRING_LENGTH (exp
)))
2617 p
+= sizeof TREE_STRING_LENGTH (exp
);
2621 p
= compare_constant_1 (TREE_REALPART (exp
), p
);
2625 return compare_constant_1 (TREE_IMAGPART (exp
), p
);
2628 if (TREE_CODE (TREE_TYPE (exp
)) == SET_TYPE
)
2630 int xlen
= len
= int_size_in_bytes (TREE_TYPE (exp
));
2631 unsigned char *tmp
= (unsigned char *) alloca (len
);
2633 get_set_constructor_bytes (exp
, tmp
, len
);
2634 strp
= (unsigned char *) tmp
;
2635 if (memcmp ((char *) &xlen
, p
, sizeof xlen
))
2644 int length
= list_length (CONSTRUCTOR_ELTS (exp
));
2646 enum machine_mode mode
= TYPE_MODE (TREE_TYPE (exp
));
2647 int have_purpose
= 0;
2649 for (link
= CONSTRUCTOR_ELTS (exp
); link
; link
= TREE_CHAIN (link
))
2650 if (TREE_PURPOSE (link
))
2653 if (memcmp ((char *) &length
, p
, sizeof length
))
2658 /* For record constructors, insist that the types match.
2659 For arrays, just verify both constructors are for arrays.
2660 Then insist that either both or none have any TREE_PURPOSE
2662 if (TREE_CODE (TREE_TYPE (exp
)) == RECORD_TYPE
)
2663 type
= TREE_TYPE (exp
);
2667 if (memcmp ((char *) &type
, p
, sizeof type
))
2670 if (TREE_CODE (TREE_TYPE (exp
)) == ARRAY_TYPE
)
2672 if (memcmp ((char *) &mode
, p
, sizeof mode
))
2680 if (memcmp ((char *) &have_purpose
, p
, sizeof have_purpose
))
2683 p
+= sizeof have_purpose
;
2685 /* For arrays, insist that the size in bytes match. */
2686 if (TREE_CODE (TREE_TYPE (exp
)) == ARRAY_TYPE
)
2688 HOST_WIDE_INT size
= int_size_in_bytes (TREE_TYPE (exp
));
2690 if (memcmp ((char *) &size
, p
, sizeof size
))
2696 for (link
= CONSTRUCTOR_ELTS (exp
); link
; link
= TREE_CHAIN (link
))
2698 if (TREE_VALUE (link
))
2700 if ((p
= compare_constant_1 (TREE_VALUE (link
), p
)) == 0)
2707 if (memcmp ((char *) &zero
, p
, sizeof zero
))
2713 if (TREE_PURPOSE (link
)
2714 && TREE_CODE (TREE_PURPOSE (link
)) == FIELD_DECL
)
2716 if (memcmp ((char *) &TREE_PURPOSE (link
), p
,
2717 sizeof TREE_PURPOSE (link
)))
2720 p
+= sizeof TREE_PURPOSE (link
);
2722 else if (TREE_PURPOSE (link
))
2724 if ((p
= compare_constant_1 (TREE_PURPOSE (link
), p
)) == 0)
2727 else if (have_purpose
)
2731 if (memcmp ((char *) &zero
, p
, sizeof zero
))
2743 struct addr_const value
;
2745 decode_addr_const (exp
, &value
);
2746 strp
= (unsigned char *) &value
.offset
;
2747 len
= sizeof value
.offset
;
2748 /* Compare the offset. */
2750 if (*p
++ != *strp
++)
2753 /* Compare symbol name. */
2754 strp
= (const unsigned char *) XSTR (value
.base
, 0);
2755 len
= strlen ((const char *) strp
) + 1;
2762 p
= compare_constant_1 (TREE_OPERAND (exp
, 0), p
);
2766 return compare_constant_1 (TREE_OPERAND (exp
, 1), p
);
2770 case NON_LVALUE_EXPR
:
2771 return compare_constant_1 (TREE_OPERAND (exp
, 0), p
);
2774 if (lang_expand_constant
)
2776 exp
= (*lang_expand_constant
) (exp
);
2777 return compare_constant_1 (exp
, p
);
2782 /* Compare constant contents. */
2784 if (*p
++ != *strp
++)
2790 /* Construct a constant descriptor for the expression EXP.
2791 It is up to the caller to enter the descriptor in the hash table. */
2793 static struct constant_descriptor
*
2794 record_constant (exp
)
2797 struct constant_descriptor
*next
= 0;
2802 /* Make a struct constant_descriptor. The first three pointers will
2803 be filled in later. Here we just leave space for them. */
2805 obstack_grow (&permanent_obstack
, (char *) &next
, sizeof next
);
2806 obstack_grow (&permanent_obstack
, (char *) &label
, sizeof label
);
2807 obstack_grow (&permanent_obstack
, (char *) &rtl
, sizeof rtl
);
2809 /* Align the descriptor for the data payload. */
2810 pad
= (offsetof (struct constant_descriptor
, u
)
2811 - offsetof(struct constant_descriptor
, rtl
)
2812 - sizeof(next
->rtl
));
2814 obstack_blank (&permanent_obstack
, pad
);
2816 record_constant_1 (exp
);
2817 return (struct constant_descriptor
*) obstack_finish (&permanent_obstack
);
2820 /* Add a description of constant expression EXP
2821 to the object growing in `permanent_obstack'.
2822 No need to return its address; the caller will get that
2823 from the obstack when the object is complete. */
2826 record_constant_1 (exp
)
2829 register const unsigned char *strp
;
2831 register enum tree_code code
= TREE_CODE (exp
);
2833 obstack_1grow (&permanent_obstack
, (unsigned int) code
);
2838 obstack_1grow (&permanent_obstack
, TYPE_PRECISION (TREE_TYPE (exp
)));
2839 strp
= (unsigned char *) &TREE_INT_CST (exp
);
2840 len
= sizeof TREE_INT_CST (exp
);
2844 obstack_1grow (&permanent_obstack
, TYPE_PRECISION (TREE_TYPE (exp
)));
2845 strp
= (unsigned char *) &TREE_REAL_CST (exp
);
2846 len
= sizeof TREE_REAL_CST (exp
);
2850 if (flag_writable_strings
)
2853 obstack_1grow (&permanent_obstack
, TYPE_MODE (TREE_TYPE (exp
)));
2854 strp
= (const unsigned char *) TREE_STRING_POINTER (exp
);
2855 len
= TREE_STRING_LENGTH (exp
);
2856 obstack_grow (&permanent_obstack
, (char *) &TREE_STRING_LENGTH (exp
),
2857 sizeof TREE_STRING_LENGTH (exp
));
2861 record_constant_1 (TREE_REALPART (exp
));
2862 record_constant_1 (TREE_IMAGPART (exp
));
2866 if (TREE_CODE (TREE_TYPE (exp
)) == SET_TYPE
)
2868 int nbytes
= int_size_in_bytes (TREE_TYPE (exp
));
2869 obstack_grow (&permanent_obstack
, &nbytes
, sizeof (nbytes
));
2870 obstack_blank (&permanent_obstack
, nbytes
);
2871 get_set_constructor_bytes
2872 (exp
, (unsigned char *) permanent_obstack
.next_free
-nbytes
,
2879 int length
= list_length (CONSTRUCTOR_ELTS (exp
));
2880 enum machine_mode mode
= TYPE_MODE (TREE_TYPE (exp
));
2882 int have_purpose
= 0;
2884 for (link
= CONSTRUCTOR_ELTS (exp
); link
; link
= TREE_CHAIN (link
))
2885 if (TREE_PURPOSE (link
))
2888 obstack_grow (&permanent_obstack
, (char *) &length
, sizeof length
);
2890 /* For record constructors, insist that the types match.
2891 For arrays, just verify both constructors are for arrays
2892 of the same mode. Then insist that either both or none
2893 have any TREE_PURPOSE values. */
2894 if (TREE_CODE (TREE_TYPE (exp
)) == RECORD_TYPE
)
2895 type
= TREE_TYPE (exp
);
2899 obstack_grow (&permanent_obstack
, (char *) &type
, sizeof type
);
2900 if (TREE_CODE (TREE_TYPE (exp
)) == ARRAY_TYPE
)
2901 obstack_grow (&permanent_obstack
, &mode
, sizeof mode
);
2903 obstack_grow (&permanent_obstack
, (char *) &have_purpose
,
2904 sizeof have_purpose
);
2906 /* For arrays, insist that the size in bytes match. */
2907 if (TREE_CODE (TREE_TYPE (exp
)) == ARRAY_TYPE
)
2909 HOST_WIDE_INT size
= int_size_in_bytes (TREE_TYPE (exp
));
2910 obstack_grow (&permanent_obstack
, (char *) &size
, sizeof size
);
2913 for (link
= CONSTRUCTOR_ELTS (exp
); link
; link
= TREE_CHAIN (link
))
2915 if (TREE_VALUE (link
))
2916 record_constant_1 (TREE_VALUE (link
));
2921 obstack_grow (&permanent_obstack
,
2922 (char *) &zero
, sizeof zero
);
2925 if (TREE_PURPOSE (link
)
2926 && TREE_CODE (TREE_PURPOSE (link
)) == FIELD_DECL
)
2927 obstack_grow (&permanent_obstack
,
2928 (char *) &TREE_PURPOSE (link
),
2929 sizeof TREE_PURPOSE (link
));
2930 else if (TREE_PURPOSE (link
))
2931 record_constant_1 (TREE_PURPOSE (link
));
2932 else if (have_purpose
)
2936 obstack_grow (&permanent_obstack
,
2937 (char *) &zero
, sizeof zero
);
2945 struct addr_const value
;
2947 decode_addr_const (exp
, &value
);
2948 /* Record the offset. */
2949 obstack_grow (&permanent_obstack
,
2950 (char *) &value
.offset
, sizeof value
.offset
);
2952 switch (GET_CODE (value
.base
))
2955 /* Record the symbol name. */
2956 obstack_grow (&permanent_obstack
, XSTR (value
.base
, 0),
2957 strlen (XSTR (value
.base
, 0)) + 1);
2960 /* Record the address of the CODE_LABEL. It may not have
2961 been emitted yet, so it's UID may be zero. But pointer
2962 identity is good enough. */
2963 obstack_grow (&permanent_obstack
, &XEXP (value
.base
, 0),
2975 record_constant_1 (TREE_OPERAND (exp
, 0));
2976 record_constant_1 (TREE_OPERAND (exp
, 1));
2981 case NON_LVALUE_EXPR
:
2982 record_constant_1 (TREE_OPERAND (exp
, 0));
2986 if (lang_expand_constant
)
2988 exp
= (*lang_expand_constant
) (exp
);
2989 record_constant_1 (exp
);
2994 /* Record constant contents. */
2995 obstack_grow (&permanent_obstack
, strp
, len
);
2998 /* Record a list of constant expressions that were passed to
2999 output_constant_def but that could not be output right away. */
3001 struct deferred_constant
3003 struct deferred_constant
*next
;
3009 static struct deferred_constant
*deferred_constants
;
3011 /* Another list of constants which should be output after the
3013 static struct deferred_constant
*after_function_constants
;
3015 /* Nonzero means defer output of addressed subconstants
3016 (i.e., those for which output_constant_def is called.) */
3017 static int defer_addressed_constants_flag
;
3019 /* Start deferring output of subconstants. */
3022 defer_addressed_constants ()
3024 defer_addressed_constants_flag
++;
3027 /* Stop deferring output of subconstants,
3028 and output now all those that have been deferred. */
3031 output_deferred_addressed_constants ()
3033 struct deferred_constant
*p
, *next
;
3035 defer_addressed_constants_flag
--;
3037 if (defer_addressed_constants_flag
> 0)
3040 for (p
= deferred_constants
; p
; p
= next
)
3042 output_constant_def_contents (p
->exp
, p
->reloc
, p
->labelno
);
3047 deferred_constants
= 0;
3050 /* Output any constants which should appear after a function. */
3053 output_after_function_constants ()
3055 struct deferred_constant
*p
, *next
;
3057 for (p
= after_function_constants
; p
; p
= next
)
3059 output_constant_def_contents (p
->exp
, p
->reloc
, p
->labelno
);
3064 after_function_constants
= 0;
3067 /* Make a copy of the whole tree structure for a constant.
3068 This handles the same types of nodes that compare_constant
3069 and record_constant handle. */
3075 switch (TREE_CODE (exp
))
3078 /* For ADDR_EXPR, we do not want to copy the decl whose address
3079 is requested. We do want to copy constants though. */
3080 if (TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp
, 0))) == 'c')
3081 return build1 (TREE_CODE (exp
), TREE_TYPE (exp
),
3082 copy_constant (TREE_OPERAND (exp
, 0)));
3084 return copy_node (exp
);
3089 return copy_node (exp
);
3092 return build_complex (TREE_TYPE (exp
),
3093 copy_constant (TREE_REALPART (exp
)),
3094 copy_constant (TREE_IMAGPART (exp
)));
3098 return build (TREE_CODE (exp
), TREE_TYPE (exp
),
3099 copy_constant (TREE_OPERAND (exp
, 0)),
3100 copy_constant (TREE_OPERAND (exp
, 1)));
3104 case NON_LVALUE_EXPR
:
3105 return build1 (TREE_CODE (exp
), TREE_TYPE (exp
),
3106 copy_constant (TREE_OPERAND (exp
, 0)));
3110 tree copy
= copy_node (exp
);
3111 tree list
= copy_list (CONSTRUCTOR_ELTS (exp
));
3114 CONSTRUCTOR_ELTS (copy
) = list
;
3115 for (tail
= list
; tail
; tail
= TREE_CHAIN (tail
))
3116 TREE_VALUE (tail
) = copy_constant (TREE_VALUE (tail
));
3117 if (TREE_CODE (TREE_TYPE (exp
)) == SET_TYPE
)
3118 for (tail
= list
; tail
; tail
= TREE_CHAIN (tail
))
3119 TREE_PURPOSE (tail
) = copy_constant (TREE_PURPOSE (tail
));
3129 /* Return an rtx representing a reference to constant data in memory
3130 for the constant expression EXP.
3132 If assembler code for such a constant has already been output,
3133 return an rtx to refer to it.
3134 Otherwise, output such a constant in memory (or defer it for later)
3135 and generate an rtx for it.
3137 If DEFER is non-zero, the output of string constants can be deferred
3138 and output only if referenced in the function after all optimizations.
3140 The TREE_CST_RTL of EXP is set up to point to that rtx.
3141 The const_hash_table records which constants already have label strings. */
3144 output_constant_def (exp
, defer
)
3149 register struct constant_descriptor
*desc
;
3150 struct deferred_string
**defstr
;
3154 int after_function
= 0;
3157 if (TREE_CST_RTL (exp
))
3158 return TREE_CST_RTL (exp
);
3160 /* Make sure any other constants whose addresses appear in EXP
3161 are assigned label numbers. */
3163 reloc
= output_addressed_constants (exp
);
3165 /* Compute hash code of EXP. Search the descriptors for that hash code
3166 to see if any of them describes EXP. If yes, the descriptor records
3167 the label number already assigned. */
3169 hash
= const_hash (exp
) % MAX_HASH_TABLE
;
3171 for (desc
= const_hash_table
[hash
]; desc
; desc
= desc
->next
)
3172 if (compare_constant (exp
, desc
))
3177 /* No constant equal to EXP is known to have been output.
3178 Make a constant descriptor to enter EXP in the hash table.
3179 Assign the label number and record it in the descriptor for
3180 future calls to this function to find. */
3182 /* Create a string containing the label name, in LABEL. */
3183 labelno
= const_labelno
++;
3184 ASM_GENERATE_INTERNAL_LABEL (label
, "LC", labelno
);
3186 desc
= record_constant (exp
);
3187 desc
->next
= const_hash_table
[hash
];
3188 desc
->label
= ggc_strdup (label
);
3189 const_hash_table
[hash
] = desc
;
3191 /* We have a symbol name; construct the SYMBOL_REF and the MEM. */
3193 = gen_rtx_MEM (TYPE_MODE (TREE_TYPE (exp
)),
3194 gen_rtx_SYMBOL_REF (Pmode
, desc
->label
));
3196 set_mem_attributes (desc
->rtl
, exp
, 1);
3201 TREE_CST_RTL (exp
) = desc
->rtl
;
3203 /* Optionally set flags or add text to the name to record information
3204 such as that it is a function name. If the name is changed, the macro
3205 ASM_OUTPUT_LABELREF will have to know how to strip this information. */
3206 #ifdef ENCODE_SECTION_INFO
3207 /* A previously-processed constant would already have section info
3211 ENCODE_SECTION_INFO (exp
);
3212 desc
->rtl
= TREE_CST_RTL (exp
);
3213 desc
->label
= XSTR (XEXP (desc
->rtl
, 0), 0);
3217 #ifdef CONSTANT_AFTER_FUNCTION_P
3218 if (current_function_decl
!= 0
3219 && CONSTANT_AFTER_FUNCTION_P (exp
))
3224 && STRING_POOL_ADDRESS_P (XEXP (desc
->rtl
, 0))
3225 && (!defer
|| defer_addressed_constants_flag
|| after_function
))
3227 defstr
= (struct deferred_string
**)
3228 htab_find_slot_with_hash (const_str_htab
, desc
->label
,
3229 STRHASH (desc
->label
), NO_INSERT
);
3232 /* If the string is currently deferred but we need to output it now,
3233 remove it from deferred string hash table. */
3235 labelno
= (*defstr
)->labelno
;
3236 STRING_POOL_ADDRESS_P (XEXP (desc
->rtl
, 0)) = 0;
3237 htab_clear_slot (const_str_htab
, (void **) defstr
);
3241 /* If this is the first time we've seen this particular constant,
3242 output it (or defer its output for later). */
3245 if (defer_addressed_constants_flag
|| after_function
)
3247 struct deferred_constant
*p
;
3248 p
= (struct deferred_constant
*) xmalloc (sizeof (struct deferred_constant
));
3250 p
->exp
= copy_constant (exp
);
3252 p
->labelno
= labelno
;
3255 p
->next
= after_function_constants
;
3256 after_function_constants
= p
;
3260 p
->next
= deferred_constants
;
3261 deferred_constants
= p
;
3266 /* Do no output if -fsyntax-only. */
3267 if (! flag_syntax_only
)
3269 if (TREE_CODE (exp
) != STRING_CST
3271 || flag_writable_strings
3272 || (defstr
= (struct deferred_string
**)
3273 htab_find_slot_with_hash (const_str_htab
,
3275 STRHASH (desc
->label
),
3277 output_constant_def_contents (exp
, reloc
, labelno
);
3280 struct deferred_string
*p
;
3282 p
= (struct deferred_string
*)
3283 xmalloc (sizeof (struct deferred_string
));
3285 p
->exp
= copy_constant (exp
);
3286 p
->label
= desc
->label
;
3287 p
->labelno
= labelno
;
3289 STRING_POOL_ADDRESS_P (XEXP (desc
->rtl
, 0)) = 1;
3295 return TREE_CST_RTL (exp
);
3298 /* Now output assembler code to define the label for EXP,
3299 and follow it with the data of EXP. */
3302 output_constant_def_contents (exp
, reloc
, labelno
)
3309 if (IN_NAMED_SECTION (exp
))
3310 named_section (exp
, NULL
, reloc
);
3313 /* First switch to text section, except for writable strings. */
3314 #ifdef SELECT_SECTION
3315 SELECT_SECTION (exp
, reloc
);
3317 if (((TREE_CODE (exp
) == STRING_CST
) && flag_writable_strings
)
3318 || (flag_pic
&& reloc
))
3321 readonly_data_section ();
3325 /* Align the location counter as required by EXP's data type. */
3326 align
= TYPE_ALIGN (TREE_TYPE (exp
));
3327 #ifdef CONSTANT_ALIGNMENT
3328 align
= CONSTANT_ALIGNMENT (exp
, align
);
3331 if (align
> BITS_PER_UNIT
)
3332 ASM_OUTPUT_ALIGN (asm_out_file
, floor_log2 (align
/ BITS_PER_UNIT
));
3334 /* Output the label itself. */
3335 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, "LC", labelno
);
3337 /* Output the value of EXP. */
3338 output_constant (exp
,
3339 (TREE_CODE (exp
) == STRING_CST
3340 ? TREE_STRING_LENGTH (exp
)
3341 : int_size_in_bytes (TREE_TYPE (exp
))));
3345 /* Structure to represent sufficient information about a constant so that
3346 it can be output when the constant pool is output, so that function
3347 integration can be done, and to simplify handling on machines that reference
3348 constant pool as base+displacement. */
3350 struct pool_constant
3352 struct constant_descriptor
*desc
;
3353 struct pool_constant
*next
, *next_sym
;
3356 enum machine_mode mode
;
3363 /* Hash code for a SYMBOL_REF with CONSTANT_POOL_ADDRESS_P true.
3364 The argument is XSTR (... , 0) */
3366 #define SYMHASH(LABEL) \
3367 ((((unsigned long) (LABEL)) & ((1 << HASHBITS) - 1)) % MAX_RTX_HASH_TABLE)
3369 /* Initialize constant pool hashing for a new function. */
3372 init_varasm_status (f
)
3375 struct varasm_status
*p
;
3376 p
= (struct varasm_status
*) xmalloc (sizeof (struct varasm_status
));
3378 p
->x_const_rtx_hash_table
3379 = ((struct constant_descriptor
**)
3380 xcalloc (MAX_RTX_HASH_TABLE
, sizeof (struct constant_descriptor
*)));
3381 p
->x_const_rtx_sym_hash_table
3382 = ((struct pool_constant
**)
3383 xcalloc (MAX_RTX_HASH_TABLE
, sizeof (struct pool_constant
*)));
3385 p
->x_first_pool
= p
->x_last_pool
= 0;
3386 p
->x_pool_offset
= 0;
3387 p
->x_const_double_chain
= 0;
3390 /* Mark PC for GC. */
3393 mark_pool_constant (pc
)
3394 struct pool_constant
*pc
;
3399 ggc_mark_rtx (pc
->constant
);
3404 /* Mark P for GC. */
3407 mark_varasm_status (p
)
3408 struct varasm_status
*p
;
3413 mark_pool_constant (p
->x_first_pool
);
3414 ggc_mark_rtx (p
->x_const_double_chain
);
3417 /* Clear out all parts of the state in F that can safely be discarded
3418 after the function has been compiled, to let garbage collection
3419 reclaim the memory. */
3422 free_varasm_status (f
)
3425 struct varasm_status
*p
;
3430 /* Clear out the hash tables. */
3431 for (i
= 0; i
< MAX_RTX_HASH_TABLE
; ++i
)
3433 struct constant_descriptor
* cd
;
3435 cd
= p
->x_const_rtx_hash_table
[i
];
3437 struct constant_descriptor
* next
= cd
->next
;
3443 free (p
->x_const_rtx_hash_table
);
3444 free (p
->x_const_rtx_sym_hash_table
);
3449 enum kind
{ RTX_DOUBLE
, RTX_INT
};
3451 /* Express an rtx for a constant integer (perhaps symbolic)
3452 as the sum of a symbol or label plus an explicit integer.
3453 They are stored into VALUE. */
3456 decode_rtx_const (mode
, x
, value
)
3457 enum machine_mode mode
;
3459 struct rtx_const
*value
;
3461 /* Clear the whole structure, including any gaps. */
3462 memset (value
, 0, sizeof (struct rtx_const
));
3464 value
->kind
= RTX_INT
; /* Most usual kind. */
3467 switch (GET_CODE (x
))
3470 value
->kind
= RTX_DOUBLE
;
3471 if (GET_MODE (x
) != VOIDmode
)
3473 value
->mode
= GET_MODE (x
);
3474 memcpy ((char *) &value
->un
.du
,
3475 (char *) &CONST_DOUBLE_LOW (x
), sizeof value
->un
.du
);
3479 value
->un
.di
.low
= CONST_DOUBLE_LOW (x
);
3480 value
->un
.di
.high
= CONST_DOUBLE_HIGH (x
);
3485 value
->un
.addr
.offset
= INTVAL (x
);
3491 value
->un
.addr
.base
= x
;
3496 if (GET_CODE (x
) == PLUS
&& GET_CODE (XEXP (x
, 1)) == CONST_INT
)
3498 value
->un
.addr
.base
= XEXP (x
, 0);
3499 value
->un
.addr
.offset
= INTVAL (XEXP (x
, 1));
3501 else if (GET_CODE (x
) == MINUS
&& GET_CODE (XEXP (x
, 1)) == CONST_INT
)
3503 value
->un
.addr
.base
= XEXP (x
, 0);
3504 value
->un
.addr
.offset
= - INTVAL (XEXP (x
, 1));
3508 value
->un
.addr
.base
= x
;
3509 value
->un
.addr
.offset
= 0;
3517 if (value
->kind
== RTX_INT
&& value
->un
.addr
.base
!= 0)
3518 switch (GET_CODE (value
->un
.addr
.base
))
3521 /* Use the string's address, not the SYMBOL_REF's address,
3522 for the sake of addresses of library routines. */
3523 value
->un
.addr
.base
= (rtx
) XSTR (value
->un
.addr
.base
, 0);
3527 /* For a LABEL_REF, compare labels. */
3528 value
->un
.addr
.base
= XEXP (value
->un
.addr
.base
, 0);
3535 /* Given a MINUS expression, simplify it if both sides
3536 include the same symbol. */
3539 simplify_subtraction (x
)
3542 struct rtx_const val0
, val1
;
3544 decode_rtx_const (GET_MODE (x
), XEXP (x
, 0), &val0
);
3545 decode_rtx_const (GET_MODE (x
), XEXP (x
, 1), &val1
);
3547 if (val0
.un
.addr
.base
== val1
.un
.addr
.base
)
3548 return GEN_INT (val0
.un
.addr
.offset
- val1
.un
.addr
.offset
);
3552 /* Compute a hash code for a constant RTL expression. */
3555 const_hash_rtx (mode
, x
)
3556 enum machine_mode mode
;
3562 struct rtx_const value
;
3563 decode_rtx_const (mode
, x
, &value
);
3565 /* Compute hashing function */
3567 for (i
= 0; i
< sizeof value
/ sizeof (int); i
++)
3568 hi
+= ((int *) &value
)[i
];
3570 hi
&= (1 << HASHBITS
) - 1;
3571 hi
%= MAX_RTX_HASH_TABLE
;
3575 /* Compare a constant rtl object X with a constant-descriptor DESC.
3576 Return 1 if DESC describes a constant with the same value as X. */
3579 compare_constant_rtx (mode
, x
, desc
)
3580 enum machine_mode mode
;
3582 struct constant_descriptor
*desc
;
3584 register int *p
= (int *) desc
->u
.contents
;
3587 struct rtx_const value
;
3589 decode_rtx_const (mode
, x
, &value
);
3590 strp
= (int *) &value
;
3591 len
= sizeof value
/ sizeof (int);
3593 /* Compare constant contents. */
3595 if (*p
++ != *strp
++)
3601 /* Construct a constant descriptor for the rtl-expression X.
3602 It is up to the caller to enter the descriptor in the hash table. */
3604 static struct constant_descriptor
*
3605 record_constant_rtx (mode
, x
)
3606 enum machine_mode mode
;
3609 struct constant_descriptor
*ptr
;
3611 ptr
= ((struct constant_descriptor
*)
3612 xcalloc (1, (offsetof (struct constant_descriptor
, u
)
3613 + sizeof (struct rtx_const
))));
3614 decode_rtx_const (mode
, x
, (struct rtx_const
*) ptr
->u
.contents
);
3619 /* Given a constant rtx X, make (or find) a memory constant for its value
3620 and return a MEM rtx to refer to it in memory. */
3623 force_const_mem (mode
, x
)
3624 enum machine_mode mode
;
3628 register struct constant_descriptor
*desc
;
3630 const char *found
= 0;
3633 /* If we want this CONST_DOUBLE in the same mode as it is in memory
3634 (this will always be true for floating CONST_DOUBLEs that have been
3635 placed in memory, but not for VOIDmode (integer) CONST_DOUBLEs),
3636 use the previous copy. Otherwise, make a new one. Note that in
3637 the unlikely event that this same CONST_DOUBLE is used in two different
3638 modes in an alternating fashion, we will allocate a lot of different
3639 memory locations, but this should be extremely rare. */
3641 if (GET_CODE (x
) == CONST_DOUBLE
3642 && GET_CODE (CONST_DOUBLE_MEM (x
)) == MEM
3643 && GET_MODE (CONST_DOUBLE_MEM (x
)) == mode
)
3644 return CONST_DOUBLE_MEM (x
);
3646 /* Compute hash code of X. Search the descriptors for that hash code
3647 to see if any of them describes X. If yes, the descriptor records
3648 the label number already assigned. */
3650 hash
= const_hash_rtx (mode
, x
);
3652 for (desc
= const_rtx_hash_table
[hash
]; desc
; desc
= desc
->next
)
3653 if (compare_constant_rtx (mode
, x
, desc
))
3655 found
= desc
->label
;
3661 register struct pool_constant
*pool
;
3664 /* No constant equal to X is known to have been output.
3665 Make a constant descriptor to enter X in the hash table.
3666 Assign the label number and record it in the descriptor for
3667 future calls to this function to find. */
3669 desc
= record_constant_rtx (mode
, x
);
3670 desc
->next
= const_rtx_hash_table
[hash
];
3671 const_rtx_hash_table
[hash
] = desc
;
3673 /* Align the location counter as required by EXP's data type. */
3674 align
= (mode
== VOIDmode
) ? UNITS_PER_WORD
: GET_MODE_SIZE (mode
);
3675 if (align
> BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
)
3676 align
= BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
;
3677 #ifdef CONSTANT_ALIGNMENT
3678 align
= CONSTANT_ALIGNMENT (make_tree (type_for_mode (mode
, 0), x
),
3679 align
* BITS_PER_UNIT
) / BITS_PER_UNIT
;
3682 pool_offset
+= align
- 1;
3683 pool_offset
&= ~ (align
- 1);
3685 /* Allocate a pool constant descriptor, fill it in, and chain it in. */
3687 pool
= (struct pool_constant
*) ggc_alloc (sizeof (struct pool_constant
));
3691 pool
->labelno
= const_labelno
;
3692 pool
->align
= align
;
3693 pool
->offset
= pool_offset
;
3700 last_pool
->next
= pool
;
3703 pool_offset
+= GET_MODE_SIZE (mode
);
3705 /* Create a string containing the label name, in LABEL. */
3706 ASM_GENERATE_INTERNAL_LABEL (label
, "LC", const_labelno
);
3710 desc
->label
= found
= ggc_strdup (label
);
3712 /* Add label to symbol hash table. */
3713 hash
= SYMHASH (found
);
3714 pool
->label
= found
;
3715 pool
->next_sym
= const_rtx_sym_hash_table
[hash
];
3716 const_rtx_sym_hash_table
[hash
] = pool
;
3719 /* We have a symbol name; construct the SYMBOL_REF and the MEM. */
3721 def
= gen_rtx_MEM (mode
, gen_rtx_SYMBOL_REF (Pmode
, found
));
3722 set_mem_attributes (def
, type_for_mode (mode
, 0), 1);
3723 RTX_UNCHANGING_P (def
) = 1;
3725 /* Mark the symbol_ref as belonging to this constants pool. */
3726 CONSTANT_POOL_ADDRESS_P (XEXP (def
, 0)) = 1;
3727 current_function_uses_const_pool
= 1;
3729 if (GET_CODE (x
) == CONST_DOUBLE
)
3731 if (CONST_DOUBLE_MEM (x
) == cc0_rtx
)
3733 CONST_DOUBLE_CHAIN (x
) = const_double_chain
;
3734 const_double_chain
= x
;
3736 CONST_DOUBLE_MEM (x
) = def
;
3742 /* Given a SYMBOL_REF with CONSTANT_POOL_ADDRESS_P true, return a pointer to
3743 the corresponding pool_constant structure. */
3745 static struct pool_constant
*
3746 find_pool_constant (f
, addr
)
3750 struct pool_constant
*pool
;
3751 const char *label
= XSTR (addr
, 0);
3753 for (pool
= f
->varasm
->x_const_rtx_sym_hash_table
[SYMHASH (label
)]; pool
;
3754 pool
= pool
->next_sym
)
3755 if (pool
->label
== label
)
3761 /* Given a constant pool SYMBOL_REF, return the corresponding constant. */
3764 get_pool_constant (addr
)
3767 return (find_pool_constant (cfun
, addr
))->constant
;
3770 /* Likewise, but for the constant pool of a specific function. */
3773 get_pool_constant_for_function (f
, addr
)
3777 return (find_pool_constant (f
, addr
))->constant
;
3780 /* Similar, return the mode. */
3783 get_pool_mode (addr
)
3786 return (find_pool_constant (cfun
, addr
))->mode
;
3790 get_pool_mode_for_function (f
, addr
)
3794 return (find_pool_constant (f
, addr
))->mode
;
3797 /* Similar, return the offset in the constant pool. */
3800 get_pool_offset (addr
)
3803 return (find_pool_constant (cfun
, addr
))->offset
;
3806 /* Return the size of the constant pool. */
3814 /* Write all the constants in the constant pool. */
3817 output_constant_pool (fnname
, fndecl
)
3818 const char *fnname ATTRIBUTE_UNUSED
;
3819 tree fndecl ATTRIBUTE_UNUSED
;
3821 struct pool_constant
*pool
;
3823 union real_extract u
;
3825 /* It is possible for gcc to call force_const_mem and then to later
3826 discard the instructions which refer to the constant. In such a
3827 case we do not need to output the constant. */
3828 mark_constant_pool ();
3830 #ifdef ASM_OUTPUT_POOL_PROLOGUE
3831 ASM_OUTPUT_POOL_PROLOGUE (asm_out_file
, fnname
, fndecl
, pool_offset
);
3834 for (pool
= first_pool
; pool
; pool
= pool
->next
)
3843 /* See if X is a LABEL_REF (or a CONST referring to a LABEL_REF)
3844 whose CODE_LABEL has been deleted. This can occur if a jump table
3845 is eliminated by optimization. If so, write a constant of zero
3846 instead. Note that this can also happen by turning the
3847 CODE_LABEL into a NOTE. */
3848 /* ??? This seems completely and utterly wrong. Certainly it's
3849 not true for NOTE_INSN_DELETED_LABEL, but I disbelieve proper
3850 functioning even with INSN_DELETED_P and friends. */
3853 switch (GET_CODE (x
))
3856 if (GET_CODE (XEXP (x
, 0)) != PLUS
3857 || GET_CODE (XEXP (XEXP (x
, 0), 0)) != LABEL_REF
)
3859 tmp
= XEXP (XEXP (x
, 0), 0);
3864 if (INSN_DELETED_P (tmp
)
3865 || (GET_CODE (tmp
) == NOTE
3866 && NOTE_LINE_NUMBER (tmp
) == NOTE_INSN_DELETED
))
3877 /* First switch to correct section. */
3878 #ifdef SELECT_RTX_SECTION
3879 SELECT_RTX_SECTION (pool
->mode
, x
);
3881 readonly_data_section ();
3884 #ifdef ASM_OUTPUT_SPECIAL_POOL_ENTRY
3885 ASM_OUTPUT_SPECIAL_POOL_ENTRY (asm_out_file
, x
, pool
->mode
,
3886 pool
->align
, pool
->labelno
, done
);
3889 if (pool
->align
> 1)
3890 ASM_OUTPUT_ALIGN (asm_out_file
, floor_log2 (pool
->align
));
3892 /* Output the label. */
3893 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, "LC", pool
->labelno
);
3895 /* Output the value of the constant itself. */
3896 switch (GET_MODE_CLASS (pool
->mode
))
3899 if (GET_CODE (x
) != CONST_DOUBLE
)
3902 memcpy ((char *) &u
, (char *) &CONST_DOUBLE_LOW (x
), sizeof u
);
3903 assemble_real (u
.d
, pool
->mode
);
3907 case MODE_PARTIAL_INT
:
3908 assemble_integer (x
, GET_MODE_SIZE (pool
->mode
), 1);
3915 #ifdef ASM_OUTPUT_SPECIAL_POOL_ENTRY
3921 #ifdef ASM_OUTPUT_POOL_EPILOGUE
3922 ASM_OUTPUT_POOL_EPILOGUE (asm_out_file
, fnname
, fndecl
, pool_offset
);
3925 /* Done with this pool. */
3926 first_pool
= last_pool
= 0;
3929 /* Look through the instructions for this function, and mark all the
3930 entries in the constant pool which are actually being used. */
3933 mark_constant_pool ()
3936 struct pool_constant
*pool
;
3938 if (first_pool
== 0 && htab_elements (const_str_htab
) == 0)
3941 for (pool
= first_pool
; pool
; pool
= pool
->next
)
3944 for (insn
= get_insns (); insn
; insn
= NEXT_INSN (insn
))
3946 mark_constants (PATTERN (insn
));
3948 for (insn
= current_function_epilogue_delay_list
;
3950 insn
= XEXP (insn
, 1))
3952 mark_constants (PATTERN (insn
));
3954 /* It's possible that the only reference to a symbol is in a symbol
3955 that's in the constant pool. This happens in Fortran under some
3956 situations. (When the constant contains the address of another
3957 constant, and only the first is used directly in an insn.)
3958 This is potentially suboptimal if there's ever a possibility of
3959 backwards (in pool order) 2'd level references. However, it's
3960 not clear that 2'd level references can happen. */
3961 for (pool
= first_pool
; pool
; pool
= pool
->next
)
3963 struct pool_constant
*tem
;
3966 /* skip unmarked entries; no insn refers to them. */
3970 /* Skip everything except SYMBOL_REFs. */
3971 if (GET_CODE (pool
->constant
) != SYMBOL_REF
)
3973 label
= XSTR (pool
->constant
, 0);
3975 /* Be sure the symbol's value is marked. */
3976 for (tem
= const_rtx_sym_hash_table
[SYMHASH (label
)]; tem
;
3978 if (tem
->label
== label
)
3980 /* If we didn't find it, there's something truly wrong here, but it
3981 will be announced by the assembler. */
3990 register const char *format_ptr
;
3995 if (GET_CODE (x
) == SYMBOL_REF
)
3997 if (CONSTANT_POOL_ADDRESS_P (x
))
3998 find_pool_constant (cfun
, x
)->mark
= 1;
3999 else if (STRING_POOL_ADDRESS_P (x
))
4001 struct deferred_string
**defstr
;
4003 defstr
= (struct deferred_string
**)
4004 htab_find_slot_with_hash (const_str_htab
, XSTR (x
, 0),
4005 STRHASH (XSTR (x
, 0)), NO_INSERT
);
4008 struct deferred_string
*p
= *defstr
;
4010 STRING_POOL_ADDRESS_P (x
) = 0;
4011 output_constant_def_contents (p
->exp
, 0, p
->labelno
);
4012 htab_clear_slot (const_str_htab
, (void **) defstr
);
4017 /* Never search inside a CONST_DOUBLE, because CONST_DOUBLE_MEM may be
4018 a MEM, but does not constitute a use of that MEM. */
4019 else if (GET_CODE (x
) == CONST_DOUBLE
)
4022 /* Insns may appear inside a SEQUENCE. Only check the patterns of
4023 insns, not any notes that may be attached. We don't want to mark
4024 a constant just because it happens to appear in a REG_EQUIV note. */
4027 mark_constants (PATTERN (x
));
4031 format_ptr
= GET_RTX_FORMAT (GET_CODE (x
));
4033 for (i
= 0; i
< GET_RTX_LENGTH (GET_CODE (x
)); i
++)
4035 switch (*format_ptr
++)
4038 mark_constants (XEXP (x
, i
));
4042 if (XVEC (x
, i
) != 0)
4046 for (j
= 0; j
< XVECLEN (x
, i
); j
++)
4047 mark_constants (XVECEXP (x
, i
, j
));
4066 /* Find all the constants whose addresses are referenced inside of EXP,
4067 and make sure assembler code with a label has been output for each one.
4068 Indicate whether an ADDR_EXPR has been encountered. */
4071 output_addressed_constants (exp
)
4076 /* Give the front-end a chance to convert VALUE to something that
4077 looks more like a constant to the back-end. */
4078 if (lang_expand_constant
)
4079 exp
= (*lang_expand_constant
) (exp
);
4081 switch (TREE_CODE (exp
))
4085 register tree constant
= TREE_OPERAND (exp
, 0);
4087 while (TREE_CODE (constant
) == COMPONENT_REF
)
4089 constant
= TREE_OPERAND (constant
, 0);
4092 if (TREE_CODE_CLASS (TREE_CODE (constant
)) == 'c'
4093 || TREE_CODE (constant
) == CONSTRUCTOR
)
4094 /* No need to do anything here
4095 for addresses of variables or functions. */
4096 output_constant_def (constant
, 0);
4103 reloc
= output_addressed_constants (TREE_OPERAND (exp
, 0));
4104 reloc
|= output_addressed_constants (TREE_OPERAND (exp
, 1));
4109 case NON_LVALUE_EXPR
:
4110 reloc
= output_addressed_constants (TREE_OPERAND (exp
, 0));
4116 for (link
= CONSTRUCTOR_ELTS (exp
); link
; link
= TREE_CHAIN (link
))
4117 if (TREE_VALUE (link
) != 0)
4118 reloc
|= output_addressed_constants (TREE_VALUE (link
));
4128 /* Return nonzero if VALUE is a valid constant-valued expression
4129 for use in initializing a static variable; one that can be an
4130 element of a "constant" initializer.
4132 Return null_pointer_node if the value is absolute;
4133 if it is relocatable, return the variable that determines the relocation.
4134 We assume that VALUE has been folded as much as possible;
4135 therefore, we do not need to check for such things as
4136 arithmetic-combinations of integers. */
4139 initializer_constant_valid_p (value
, endtype
)
4143 /* Give the front-end a chance to convert VALUE to something that
4144 looks more like a constant to the back-end. */
4145 if (lang_expand_constant
)
4146 value
= (*lang_expand_constant
) (value
);
4148 switch (TREE_CODE (value
))
4151 if ((TREE_CODE (TREE_TYPE (value
)) == UNION_TYPE
4152 || TREE_CODE (TREE_TYPE (value
)) == RECORD_TYPE
)
4153 && TREE_CONSTANT (value
)
4154 && CONSTRUCTOR_ELTS (value
))
4156 initializer_constant_valid_p (TREE_VALUE (CONSTRUCTOR_ELTS (value
)),
4159 return TREE_STATIC (value
) ? null_pointer_node
: 0;
4165 return null_pointer_node
;
4168 return staticp (TREE_OPERAND (value
, 0)) ? TREE_OPERAND (value
, 0) : 0;
4170 case NON_LVALUE_EXPR
:
4171 return initializer_constant_valid_p (TREE_OPERAND (value
, 0), endtype
);
4175 /* Allow conversions between pointer types. */
4176 if (POINTER_TYPE_P (TREE_TYPE (value
))
4177 && POINTER_TYPE_P (TREE_TYPE (TREE_OPERAND (value
, 0))))
4178 return initializer_constant_valid_p (TREE_OPERAND (value
, 0), endtype
);
4180 /* Allow conversions between real types. */
4181 if (FLOAT_TYPE_P (TREE_TYPE (value
))
4182 && FLOAT_TYPE_P (TREE_TYPE (TREE_OPERAND (value
, 0))))
4183 return initializer_constant_valid_p (TREE_OPERAND (value
, 0), endtype
);
4185 /* Allow length-preserving conversions between integer types. */
4186 if (INTEGRAL_TYPE_P (TREE_TYPE (value
))
4187 && INTEGRAL_TYPE_P (TREE_TYPE (TREE_OPERAND (value
, 0)))
4188 && (TYPE_PRECISION (TREE_TYPE (value
))
4189 == TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (value
, 0)))))
4190 return initializer_constant_valid_p (TREE_OPERAND (value
, 0), endtype
);
4192 /* Allow conversions between other integer types only if
4194 if (INTEGRAL_TYPE_P (TREE_TYPE (value
))
4195 && INTEGRAL_TYPE_P (TREE_TYPE (TREE_OPERAND (value
, 0))))
4197 tree inner
= initializer_constant_valid_p (TREE_OPERAND (value
, 0),
4199 if (inner
== null_pointer_node
)
4200 return null_pointer_node
;
4204 /* Allow (int) &foo provided int is as wide as a pointer. */
4205 if (INTEGRAL_TYPE_P (TREE_TYPE (value
))
4206 && POINTER_TYPE_P (TREE_TYPE (TREE_OPERAND (value
, 0)))
4207 && (TYPE_PRECISION (TREE_TYPE (value
))
4208 >= TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (value
, 0)))))
4209 return initializer_constant_valid_p (TREE_OPERAND (value
, 0),
4212 /* Likewise conversions from int to pointers, but also allow
4213 conversions from 0. */
4214 if (POINTER_TYPE_P (TREE_TYPE (value
))
4215 && INTEGRAL_TYPE_P (TREE_TYPE (TREE_OPERAND (value
, 0))))
4217 if (integer_zerop (TREE_OPERAND (value
, 0)))
4218 return null_pointer_node
;
4219 else if (TYPE_PRECISION (TREE_TYPE (value
))
4220 <= TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (value
, 0))))
4221 return initializer_constant_valid_p (TREE_OPERAND (value
, 0),
4225 /* Allow conversions to union types if the value inside is okay. */
4226 if (TREE_CODE (TREE_TYPE (value
)) == UNION_TYPE
)
4227 return initializer_constant_valid_p (TREE_OPERAND (value
, 0),
4232 if (! INTEGRAL_TYPE_P (endtype
)
4233 || TYPE_PRECISION (endtype
) >= POINTER_SIZE
)
4235 tree valid0
= initializer_constant_valid_p (TREE_OPERAND (value
, 0),
4237 tree valid1
= initializer_constant_valid_p (TREE_OPERAND (value
, 1),
4239 /* If either term is absolute, use the other terms relocation. */
4240 if (valid0
== null_pointer_node
)
4242 if (valid1
== null_pointer_node
)
4248 if (! INTEGRAL_TYPE_P (endtype
)
4249 || TYPE_PRECISION (endtype
) >= POINTER_SIZE
)
4251 tree valid0
= initializer_constant_valid_p (TREE_OPERAND (value
, 0),
4253 tree valid1
= initializer_constant_valid_p (TREE_OPERAND (value
, 1),
4255 /* Win if second argument is absolute. */
4256 if (valid1
== null_pointer_node
)
4258 /* Win if both arguments have the same relocation.
4259 Then the value is absolute. */
4260 if (valid0
== valid1
&& valid0
!= 0)
4261 return null_pointer_node
;
4263 /* Since GCC guarantees that string constants are unique in the
4264 generated code, a subtraction between two copies of the same
4265 constant string is absolute. */
4266 if (valid0
&& TREE_CODE (valid0
) == STRING_CST
&&
4267 valid1
&& TREE_CODE (valid1
) == STRING_CST
&&
4268 TREE_STRING_POINTER (valid0
) == TREE_STRING_POINTER (valid1
))
4269 return null_pointer_node
;
4272 /* Support differences between labels. */
4273 if (INTEGRAL_TYPE_P (endtype
))
4276 op0
= TREE_OPERAND (value
, 0);
4277 op1
= TREE_OPERAND (value
, 1);
4281 if (TREE_CODE (op0
) == ADDR_EXPR
4282 && TREE_CODE (TREE_OPERAND (op0
, 0)) == LABEL_DECL
4283 && TREE_CODE (op1
) == ADDR_EXPR
4284 && TREE_CODE (TREE_OPERAND (op1
, 0)) == LABEL_DECL
)
4285 return null_pointer_node
;
4296 /* Output assembler code for constant EXP to FILE, with no label.
4297 This includes the pseudo-op such as ".int" or ".byte", and a newline.
4298 Assumes output_addressed_constants has been done on EXP already.
4300 Generate exactly SIZE bytes of assembler data, padding at the end
4301 with zeros if necessary. SIZE must always be specified.
4303 SIZE is important for structure constructors,
4304 since trailing members may have been omitted from the constructor.
4305 It is also important for initialization of arrays from string constants
4306 since the full length of the string constant might not be wanted.
4307 It is also needed for initialization of unions, where the initializer's
4308 type is just one member, and that may not be as long as the union.
4310 There a case in which we would fail to output exactly SIZE bytes:
4311 for a structure constructor that wants to produce more than SIZE bytes.
4312 But such constructors will never be generated for any possible input. */
4315 output_constant (exp
, size
)
4319 register enum tree_code code
= TREE_CODE (TREE_TYPE (exp
));
4321 /* Some front-ends use constants other than the standard
4322 language-indepdent varieties, but which may still be output
4323 directly. Give the front-end a chance to convert EXP to a
4324 language-independent representation. */
4325 if (lang_expand_constant
)
4326 exp
= (*lang_expand_constant
) (exp
);
4328 if (size
== 0 || flag_syntax_only
)
4331 /* Eliminate the NON_LVALUE_EXPR_EXPR that makes a cast not be an lvalue.
4332 That way we get the constant (we hope) inside it. Also, strip off any
4333 NOP_EXPR that converts between two record, union, array, or set types
4334 or a CONVERT_EXPR that converts to a union TYPE. */
4335 while ((TREE_CODE (exp
) == NOP_EXPR
4336 && (TREE_TYPE (exp
) == TREE_TYPE (TREE_OPERAND (exp
, 0))
4337 || AGGREGATE_TYPE_P (TREE_TYPE (exp
))))
4338 || (TREE_CODE (exp
) == CONVERT_EXPR
4339 && code
== UNION_TYPE
)
4340 || TREE_CODE (exp
) == NON_LVALUE_EXPR
)
4342 exp
= TREE_OPERAND (exp
, 0);
4343 code
= TREE_CODE (TREE_TYPE (exp
));
4346 /* Allow a constructor with no elements for any data type.
4347 This means to fill the space with zeros. */
4348 if (TREE_CODE (exp
) == CONSTRUCTOR
&& CONSTRUCTOR_ELTS (exp
) == 0)
4350 assemble_zeros (size
);
4361 case REFERENCE_TYPE
:
4362 /* ??? What about (int)((float)(int)&foo + 4) */
4363 while (TREE_CODE (exp
) == NOP_EXPR
|| TREE_CODE (exp
) == CONVERT_EXPR
4364 || TREE_CODE (exp
) == NON_LVALUE_EXPR
)
4365 exp
= TREE_OPERAND (exp
, 0);
4367 if (! assemble_integer (expand_expr (exp
, NULL_RTX
, VOIDmode
,
4368 EXPAND_INITIALIZER
),
4370 error ("initializer for integer value is too complicated");
4375 if (TREE_CODE (exp
) != REAL_CST
)
4376 error ("initializer for floating value is not a floating constant");
4378 assemble_real (TREE_REAL_CST (exp
),
4379 mode_for_size (size
* BITS_PER_UNIT
, MODE_FLOAT
, 0));
4384 output_constant (TREE_REALPART (exp
), size
/ 2);
4385 output_constant (TREE_IMAGPART (exp
), size
/ 2);
4386 size
-= (size
/ 2) * 2;
4390 if (TREE_CODE (exp
) == CONSTRUCTOR
)
4392 output_constructor (exp
, size
);
4395 else if (TREE_CODE (exp
) == STRING_CST
)
4399 if (size
> TREE_STRING_LENGTH (exp
))
4401 excess
= size
- TREE_STRING_LENGTH (exp
);
4402 size
= TREE_STRING_LENGTH (exp
);
4405 assemble_string (TREE_STRING_POINTER (exp
), size
);
4414 if (TREE_CODE (exp
) == CONSTRUCTOR
)
4415 output_constructor (exp
, size
);
4421 if (TREE_CODE (exp
) == INTEGER_CST
)
4422 assemble_integer (expand_expr (exp
, NULL_RTX
,
4423 VOIDmode
, EXPAND_INITIALIZER
),
4425 else if (TREE_CODE (exp
) == CONSTRUCTOR
)
4427 unsigned char *buffer
= (unsigned char *) alloca (size
);
4428 if (get_set_constructor_bytes (exp
, buffer
, size
))
4430 assemble_string ((char *) buffer
, size
);
4433 error ("unknown set constructor type");
4441 assemble_zeros (size
);
4445 /* Subroutine of output_constructor, used for computing the size of
4446 arrays of unspecified length. VAL must be a CONSTRUCTOR of an array
4447 type with an unspecified upper bound. */
4450 array_size_for_constructor (val
)
4455 if (!val
|| TREE_CODE (val
) != CONSTRUCTOR
4456 || TREE_CODE (TREE_TYPE (val
)) != ARRAY_TYPE
4457 || TYPE_DOMAIN (TREE_TYPE (val
)) == NULL_TREE
4458 || TYPE_MAX_VALUE (TYPE_DOMAIN (TREE_TYPE (val
))) != NULL_TREE
4459 || TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (val
))) == NULL_TREE
)
4462 max_index
= NULL_TREE
;
4463 for (i
= CONSTRUCTOR_ELTS (val
); i
; i
= TREE_CHAIN (i
))
4465 tree index
= TREE_PURPOSE (i
);
4467 if (TREE_CODE (index
) == RANGE_EXPR
)
4468 index
= TREE_OPERAND (index
, 1);
4469 if (max_index
== NULL_TREE
|| tree_int_cst_lt (max_index
, index
))
4473 /* ??? I'm fairly certain if there were no elements, we shouldn't have
4474 created the constructor in the first place. */
4475 if (max_index
== NULL_TREE
)
4478 /* Compute the total number of array elements. */
4479 i
= fold (build (MINUS_EXPR
, TREE_TYPE (max_index
), max_index
,
4480 TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (val
)))));
4481 i
= fold (build (PLUS_EXPR
, TREE_TYPE (i
), i
,
4482 convert (TREE_TYPE (i
), integer_one_node
)));
4484 /* Multiply by the array element unit size to find number of bytes. */
4485 i
= fold (build (MULT_EXPR
, TREE_TYPE (max_index
), i
,
4486 TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (val
)))));
4488 return tree_low_cst (i
, 1);
4491 /* Subroutine of output_constant, used for CONSTRUCTORs (aggregate constants).
4492 Generate at least SIZE bytes, padding if necessary. */
4495 output_constructor (exp
, size
)
4499 tree type
= TREE_TYPE (exp
);
4500 register tree link
, field
= 0;
4502 /* Number of bytes output or skipped so far.
4503 In other words, current position within the constructor. */
4504 HOST_WIDE_INT total_bytes
= 0;
4505 /* Non-zero means BYTE contains part of a byte, to be output. */
4506 int byte_buffer_in_use
= 0;
4507 register int byte
= 0;
4509 if (HOST_BITS_PER_WIDE_INT
< BITS_PER_UNIT
)
4512 if (TREE_CODE (type
) == RECORD_TYPE
)
4513 field
= TYPE_FIELDS (type
);
4515 if (TREE_CODE (type
) == ARRAY_TYPE
4516 && TYPE_DOMAIN (type
) != 0)
4517 min_index
= TYPE_MIN_VALUE (TYPE_DOMAIN (type
));
4519 /* As LINK goes through the elements of the constant,
4520 FIELD goes through the structure fields, if the constant is a structure.
4521 if the constant is a union, then we override this,
4522 by getting the field from the TREE_LIST element.
4523 But the constant could also be an array. Then FIELD is zero.
4525 There is always a maximum of one element in the chain LINK for unions
4526 (even if the initializer in a source program incorrectly contains
4528 for (link
= CONSTRUCTOR_ELTS (exp
);
4530 link
= TREE_CHAIN (link
),
4531 field
= field
? TREE_CHAIN (field
) : 0)
4533 tree val
= TREE_VALUE (link
);
4536 /* The element in a union constructor specifies the proper field
4538 if ((TREE_CODE (type
) == RECORD_TYPE
|| TREE_CODE (type
) == UNION_TYPE
4539 || TREE_CODE (type
) == QUAL_UNION_TYPE
)
4540 && TREE_PURPOSE (link
) != 0)
4541 field
= TREE_PURPOSE (link
);
4543 else if (TREE_CODE (type
) == ARRAY_TYPE
)
4544 index
= TREE_PURPOSE (link
);
4546 /* Eliminate the marker that makes a cast not be an lvalue. */
4550 if (index
&& TREE_CODE (index
) == RANGE_EXPR
)
4552 register int fieldsize
4553 = int_size_in_bytes (TREE_TYPE (type
));
4554 HOST_WIDE_INT lo_index
= tree_low_cst (TREE_OPERAND (index
, 0), 0);
4555 HOST_WIDE_INT hi_index
= tree_low_cst (TREE_OPERAND (index
, 1), 0);
4556 HOST_WIDE_INT index
;
4558 for (index
= lo_index
; index
<= hi_index
; index
++)
4560 /* Output the element's initial value. */
4562 assemble_zeros (fieldsize
);
4564 output_constant (val
, fieldsize
);
4566 /* Count its size. */
4567 total_bytes
+= fieldsize
;
4570 else if (field
== 0 || !DECL_BIT_FIELD (field
))
4572 /* An element that is not a bit-field. */
4574 register int fieldsize
;
4575 /* Since this structure is static,
4576 we know the positions are constant. */
4577 HOST_WIDE_INT pos
= field
? int_byte_position (field
) : 0;
4580 pos
= (tree_low_cst (TYPE_SIZE_UNIT (TREE_TYPE (val
)), 1)
4581 * (tree_low_cst (index
, 0) - tree_low_cst (min_index
, 0)));
4583 /* Output any buffered-up bit-fields preceding this element. */
4584 if (byte_buffer_in_use
)
4586 ASM_OUTPUT_BYTE (asm_out_file
, byte
);
4588 byte_buffer_in_use
= 0;
4591 /* Advance to offset of this element.
4592 Note no alignment needed in an array, since that is guaranteed
4593 if each element has the proper size. */
4594 if ((field
!= 0 || index
!= 0) && pos
!= total_bytes
)
4596 assemble_zeros (pos
- total_bytes
);
4600 else if (field
!= 0 && DECL_PACKED (field
))
4601 /* Some assemblers automaticallly align a datum according to its
4602 size if no align directive is specified. The datum, however,
4603 may be declared with 'packed' attribute, so we have to disable
4605 ASM_OUTPUT_ALIGN (asm_out_file
, 0);
4607 /* Determine size this element should occupy. */
4610 if (DECL_SIZE_UNIT (field
))
4611 fieldsize
= tree_low_cst (DECL_SIZE_UNIT (field
), 1);
4614 /* If DECL_SIZE is not set, then this must be an array
4615 of unspecified length. The initialized value must
4616 be a CONSTRUCTOR, and we take the length from the
4617 last initialized element. */
4618 fieldsize
= array_size_for_constructor (val
);
4622 fieldsize
= int_size_in_bytes (TREE_TYPE (type
));
4624 /* Output the element's initial value. */
4626 assemble_zeros (fieldsize
);
4628 output_constant (val
, fieldsize
);
4630 /* Count its size. */
4631 total_bytes
+= fieldsize
;
4633 else if (val
!= 0 && TREE_CODE (val
) != INTEGER_CST
)
4634 error ("invalid initial value for member `%s'",
4635 IDENTIFIER_POINTER (DECL_NAME (field
)));
4638 /* Element that is a bit-field. */
4640 HOST_WIDE_INT next_offset
= int_bit_position (field
);
4641 HOST_WIDE_INT end_offset
4642 = (next_offset
+ tree_low_cst (DECL_SIZE (field
), 1));
4645 val
= integer_zero_node
;
4647 /* If this field does not start in this (or, next) byte,
4649 if (next_offset
/ BITS_PER_UNIT
!= total_bytes
)
4651 /* Output remnant of any bit field in previous bytes. */
4652 if (byte_buffer_in_use
)
4654 ASM_OUTPUT_BYTE (asm_out_file
, byte
);
4656 byte_buffer_in_use
= 0;
4659 /* If still not at proper byte, advance to there. */
4660 if (next_offset
/ BITS_PER_UNIT
!= total_bytes
)
4662 assemble_zeros (next_offset
/ BITS_PER_UNIT
- total_bytes
);
4663 total_bytes
= next_offset
/ BITS_PER_UNIT
;
4667 if (! byte_buffer_in_use
)
4670 /* We must split the element into pieces that fall within
4671 separate bytes, and combine each byte with previous or
4672 following bit-fields. */
4674 /* next_offset is the offset n fbits from the beginning of
4675 the structure to the next bit of this element to be processed.
4676 end_offset is the offset of the first bit past the end of
4678 while (next_offset
< end_offset
)
4682 HOST_WIDE_INT value
;
4683 HOST_WIDE_INT next_byte
= next_offset
/ BITS_PER_UNIT
;
4684 HOST_WIDE_INT next_bit
= next_offset
% BITS_PER_UNIT
;
4686 /* Advance from byte to byte
4687 within this element when necessary. */
4688 while (next_byte
!= total_bytes
)
4690 ASM_OUTPUT_BYTE (asm_out_file
, byte
);
4695 /* Number of bits we can process at once
4696 (all part of the same byte). */
4697 this_time
= MIN (end_offset
- next_offset
,
4698 BITS_PER_UNIT
- next_bit
);
4699 if (BYTES_BIG_ENDIAN
)
4701 /* On big-endian machine, take the most significant bits
4702 first (of the bits that are significant)
4703 and put them into bytes from the most significant end. */
4704 shift
= end_offset
- next_offset
- this_time
;
4706 /* Don't try to take a bunch of bits that cross
4707 the word boundary in the INTEGER_CST. We can
4708 only select bits from the LOW or HIGH part
4710 if (shift
< HOST_BITS_PER_WIDE_INT
4711 && shift
+ this_time
> HOST_BITS_PER_WIDE_INT
)
4713 this_time
= shift
+ this_time
- HOST_BITS_PER_WIDE_INT
;
4714 shift
= HOST_BITS_PER_WIDE_INT
;
4717 /* Now get the bits from the appropriate constant word. */
4718 if (shift
< HOST_BITS_PER_WIDE_INT
)
4719 value
= TREE_INT_CST_LOW (val
);
4720 else if (shift
< 2 * HOST_BITS_PER_WIDE_INT
)
4722 value
= TREE_INT_CST_HIGH (val
);
4723 shift
-= HOST_BITS_PER_WIDE_INT
;
4728 /* Get the result. This works only when:
4729 1 <= this_time <= HOST_BITS_PER_WIDE_INT. */
4730 byte
|= (((value
>> shift
)
4731 & (((HOST_WIDE_INT
) 2 << (this_time
- 1)) - 1))
4732 << (BITS_PER_UNIT
- this_time
- next_bit
));
4736 /* On little-endian machines,
4737 take first the least significant bits of the value
4738 and pack them starting at the least significant
4739 bits of the bytes. */
4740 shift
= next_offset
- int_bit_position (field
);
4742 /* Don't try to take a bunch of bits that cross
4743 the word boundary in the INTEGER_CST. We can
4744 only select bits from the LOW or HIGH part
4746 if (shift
< HOST_BITS_PER_WIDE_INT
4747 && shift
+ this_time
> HOST_BITS_PER_WIDE_INT
)
4748 this_time
= (HOST_BITS_PER_WIDE_INT
- shift
);
4750 /* Now get the bits from the appropriate constant word. */
4751 if (shift
< HOST_BITS_PER_WIDE_INT
)
4752 value
= TREE_INT_CST_LOW (val
);
4753 else if (shift
< 2 * HOST_BITS_PER_WIDE_INT
)
4755 value
= TREE_INT_CST_HIGH (val
);
4756 shift
-= HOST_BITS_PER_WIDE_INT
;
4761 /* Get the result. This works only when:
4762 1 <= this_time <= HOST_BITS_PER_WIDE_INT. */
4763 byte
|= (((value
>> shift
)
4764 & (((HOST_WIDE_INT
) 2 << (this_time
- 1)) - 1))
4768 next_offset
+= this_time
;
4769 byte_buffer_in_use
= 1;
4774 if (byte_buffer_in_use
)
4776 ASM_OUTPUT_BYTE (asm_out_file
, byte
);
4780 if (total_bytes
< size
)
4781 assemble_zeros (size
- total_bytes
);
4784 #ifdef HANDLE_PRAGMA_WEAK
4785 /* Add function NAME to the weak symbols list. VALUE is a weak alias
4786 associatd with NAME. */
4789 add_weak (name
, value
)
4793 struct weak_syms
*weak
;
4795 weak
= (struct weak_syms
*) permalloc (sizeof (struct weak_syms
));
4800 weak
->next
= weak_decls
;
4802 weak
->value
= value
;
4807 #endif /* HANDLE_PRAGMA_WEAK */
4809 /* Declare DECL to be a weak symbol. */
4815 if (! TREE_PUBLIC (decl
))
4816 error_with_decl (decl
, "weak declaration of `%s' must be public");
4817 else if (TREE_ASM_WRITTEN (decl
))
4818 error_with_decl (decl
, "weak declaration of `%s' must precede definition");
4819 else if (SUPPORTS_WEAK
)
4820 DECL_WEAK (decl
) = 1;
4821 #ifdef HANDLE_PRAGMA_WEAK
4822 add_weak (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)), NULL
);
4826 /* Emit any pending weak declarations. */
4828 #ifdef HANDLE_PRAGMA_WEAK
4829 struct weak_syms
* weak_decls
;
4835 #ifdef HANDLE_PRAGMA_WEAK
4836 if (HANDLE_PRAGMA_WEAK
)
4838 struct weak_syms
*t
;
4839 for (t
= weak_decls
; t
; t
= t
->next
)
4843 ASM_WEAKEN_LABEL (asm_out_file
, t
->name
);
4845 ASM_OUTPUT_DEF (asm_out_file
, t
->name
, t
->value
);
4852 /* Remove NAME from the pending list of weak symbols. This prevents
4853 the compiler from emitting multiple .weak directives which confuses
4855 #ifdef ASM_WEAKEN_LABEL
4857 remove_from_pending_weak_list (name
)
4858 const char *name ATTRIBUTE_UNUSED
;
4860 #ifdef HANDLE_PRAGMA_WEAK
4861 if (HANDLE_PRAGMA_WEAK
)
4863 struct weak_syms
*t
;
4864 for (t
= weak_decls
; t
; t
= t
->next
)
4866 if (t
->name
&& strcmp (name
, t
->name
) == 0)
4875 assemble_alias (decl
, target
)
4876 tree decl
, target ATTRIBUTE_UNUSED
;
4880 make_decl_rtl (decl
, (char *) 0, 1);
4881 name
= XSTR (XEXP (DECL_RTL (decl
), 0), 0);
4883 #ifdef ASM_OUTPUT_DEF
4884 /* Make name accessible from other files, if appropriate. */
4886 if (TREE_PUBLIC (decl
))
4888 #ifdef ASM_WEAKEN_LABEL
4889 if (DECL_WEAK (decl
))
4891 ASM_WEAKEN_LABEL (asm_out_file
, name
);
4892 /* Remove this function from the pending weak list so that
4893 we do not emit multiple .weak directives for it. */
4894 remove_from_pending_weak_list
4895 (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)));
4899 ASM_GLOBALIZE_LABEL (asm_out_file
, name
);
4902 #ifdef ASM_OUTPUT_DEF_FROM_DECLS
4903 ASM_OUTPUT_DEF_FROM_DECLS (asm_out_file
, decl
, target
);
4905 ASM_OUTPUT_DEF (asm_out_file
, name
, IDENTIFIER_POINTER (target
));
4907 TREE_ASM_WRITTEN (decl
) = 1;
4909 #ifdef ASM_OUTPUT_WEAK_ALIAS
4910 if (! DECL_WEAK (decl
))
4911 warning ("only weak aliases are supported in this configuration");
4913 ASM_OUTPUT_WEAK_ALIAS (asm_out_file
, name
, IDENTIFIER_POINTER (target
));
4914 TREE_ASM_WRITTEN (decl
) = 1;
4916 warning ("alias definitions not supported in this configuration; ignored");
4921 /* This determines whether or not we support link-once semantics. */
4922 #ifndef SUPPORTS_ONE_ONLY
4923 #ifdef MAKE_DECL_ONE_ONLY
4924 #define SUPPORTS_ONE_ONLY 1
4926 #define SUPPORTS_ONE_ONLY 0
4930 /* Returns 1 if the target configuration supports defining public symbols
4931 so that one of them will be chosen at link time instead of generating a
4932 multiply-defined symbol error, whether through the use of weak symbols or
4933 a target-specific mechanism for having duplicates discarded. */
4936 supports_one_only ()
4938 if (SUPPORTS_ONE_ONLY
)
4940 return SUPPORTS_WEAK
;
4943 /* Set up DECL as a public symbol that can be defined in multiple
4944 translation units without generating a linker error. */
4947 make_decl_one_only (decl
)
4950 if (TREE_CODE (decl
) != VAR_DECL
&& TREE_CODE (decl
) != FUNCTION_DECL
)
4953 TREE_PUBLIC (decl
) = 1;
4955 if (TREE_CODE (decl
) == VAR_DECL
4956 && (DECL_INITIAL (decl
) == 0 || DECL_INITIAL (decl
) == error_mark_node
))
4957 DECL_COMMON (decl
) = 1;
4958 else if (SUPPORTS_ONE_ONLY
)
4960 #ifdef MAKE_DECL_ONE_ONLY
4961 MAKE_DECL_ONE_ONLY (decl
);
4963 DECL_ONE_ONLY (decl
) = 1;
4965 else if (SUPPORTS_WEAK
)
4966 DECL_WEAK (decl
) = 1;
4974 const_str_htab
= htab_create (128, const_str_htab_hash
, const_str_htab_eq
,
4975 const_str_htab_del
);
4976 ggc_add_root (const_hash_table
, MAX_HASH_TABLE
, sizeof const_hash_table
[0],
4977 mark_const_hash_entry
);
4978 ggc_add_root (&const_str_htab
, 1, sizeof const_str_htab
,
4979 mark_const_str_htab
);
4982 /* Extra support for EH values. */
4984 assemble_eh_label (name
)
4987 #ifdef ASM_OUTPUT_EH_LABEL
4988 ASM_OUTPUT_EH_LABEL (asm_out_file
, name
);
4990 assemble_label (name
);
4994 /* Assemble an alignment pseudo op for an ALIGN-bit boundary. */
4997 assemble_eh_align (align
)
5000 #ifdef ASM_OUTPUT_EH_ALIGN
5001 if (align
> BITS_PER_UNIT
)
5002 ASM_OUTPUT_EH_ALIGN (asm_out_file
, floor_log2 (align
/ BITS_PER_UNIT
));
5004 assemble_align (align
);
5009 /* On some platforms, we may want to specify a special mechansim to
5010 output EH data when generating with a function.. */
5012 assemble_eh_integer (x
, size
, force
)
5020 #ifdef ASM_OUTPUT_EH_CHAR
5022 ASM_OUTPUT_EH_CHAR (asm_out_file
, x
);
5026 #ifdef ASM_OUTPUT_EH_SHORT
5028 ASM_OUTPUT_EH_SHORT (asm_out_file
, x
);
5032 #ifdef ASM_OUTPUT_EH_INT
5034 ASM_OUTPUT_EH_INT (asm_out_file
, x
);
5038 #ifdef ASM_OUTPUT_EH_DOUBLE_INT
5040 ASM_OUTPUT_EH_DOUBLE_INT (asm_out_file
, x
);
5047 return (assemble_integer (x
, size
, force
));