1 /* Output variables, constants and external declarations, for GNU compiler.
2 Copyright (C) 1987, 88, 89, 92-97, 1998 Free Software Foundation, Inc.
4 This file is part of GNU CC.
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING. If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
22 /* This file handles generation of all the assembler code
23 *except* the instructions of a function.
24 This includes declarations of variables and their initial values.
26 We also output the assembler code for constants stored in memory
27 and are responsible for combining constants with the same value. */
32 /* #include <stab.h> */
40 #include "hard-reg-set.h"
51 #ifdef XCOFF_DEBUGGING_INFO
55 #ifndef TRAMPOLINE_ALIGNMENT
56 #define TRAMPOLINE_ALIGNMENT FUNCTION_BOUNDARY
60 #define ASM_STABS_OP ".stabs"
63 /* Define the prefix to use when check_memory_usage_flag is enable. */
64 #ifdef NO_DOLLAR_IN_LABEL
65 #ifdef NO_DOT_IN_LABEL
66 #define CHKR_PREFIX "chkr_prefix_"
67 #else /* !NO_DOT_IN_LABEL */
68 #define CHKR_PREFIX "chkr."
70 #else /* !NO_DOLLAR_IN_LABEL */
71 #define CHKR_PREFIX "chkr$"
73 #define CHKR_PREFIX_SIZE (sizeof (CHKR_PREFIX) - 1)
75 /* This macro gets just the user-specified name
76 out of the string in a SYMBOL_REF. On most machines,
77 we discard the * if any and that's all. */
78 #ifndef STRIP_NAME_ENCODING
79 #define STRIP_NAME_ENCODING(VAR,SYMBOL_NAME) \
80 (VAR) = ((SYMBOL_NAME) + ((SYMBOL_NAME)[0] == '*'))
83 /* File in which assembler code is being written. */
85 extern FILE *asm_out_file
;
87 /* The (assembler) name of the first globally-visible object output. */
88 char *first_global_object_name
;
89 char *weak_global_object_name
;
91 extern struct obstack
*current_obstack
;
92 extern struct obstack
*saveable_obstack
;
93 extern struct obstack
*rtl_obstack
;
94 extern struct obstack permanent_obstack
;
95 #define obstack_chunk_alloc xmalloc
97 /* Number for making the label on the next
98 constant that is stored in memory. */
102 /* Number for making the label on the next
103 static variable internal to a function. */
107 /* Carry information from ASM_DECLARE_OBJECT_NAME
108 to ASM_FINISH_DECLARE_OBJECT. */
110 int size_directive_output
;
112 /* The last decl for which assemble_variable was called,
113 if it did ASM_DECLARE_OBJECT_NAME.
114 If the last call to assemble_variable didn't do that,
117 tree last_assemble_variable_decl
;
119 /* Nonzero if at least one function definition has been seen. */
121 static int function_defined
;
124 struct constant_descriptor
;
126 struct pool_constant
;
128 static char *strip_reg_name
PROTO((char *));
129 static int contains_pointers_p
PROTO((tree
));
130 static void decode_addr_const
PROTO((tree
, struct addr_const
*));
131 static int const_hash
PROTO((tree
));
132 static int compare_constant
PROTO((tree
,
133 struct constant_descriptor
*));
134 static char *compare_constant_1
PROTO((tree
, char *));
135 static struct constant_descriptor
*record_constant
PROTO((tree
));
136 static void record_constant_1
PROTO((tree
));
137 static tree copy_constant
PROTO((tree
));
138 static void output_constant_def_contents
PROTO((tree
, int, int));
139 static void decode_rtx_const
PROTO((enum machine_mode
, rtx
,
140 struct rtx_const
*));
141 static int const_hash_rtx
PROTO((enum machine_mode
, rtx
));
142 static int compare_constant_rtx
PROTO((enum machine_mode
, rtx
,
143 struct constant_descriptor
*));
144 static struct constant_descriptor
*record_constant_rtx
PROTO((enum machine_mode
,
146 static struct pool_constant
*find_pool_constant
PROTO((rtx
));
147 static void mark_constant_pool
PROTO((void));
148 static void mark_constants
PROTO((rtx
));
149 static int output_addressed_constants
PROTO((tree
));
150 static void output_after_function_constants
PROTO((void));
151 static void output_constructor
PROTO((tree
, int));
152 #ifdef ASM_OUTPUT_BSS
153 static void asm_output_bss
PROTO((FILE *, tree
, char *, int, int));
155 #ifdef BSS_SECTION_ASM_OP
156 #ifdef ASM_OUTPUT_ALIGNED_BSS
157 static void asm_output_aligned_bss
PROTO((FILE *, tree
, char *, int, int));
159 #endif /* BSS_SECTION_ASM_OP */
161 static enum in_section
{ no_section
, in_text
, in_data
, in_named
162 #ifdef BSS_SECTION_ASM_OP
165 #ifdef EH_FRAME_SECTION_ASM_OP
168 #ifdef EXTRA_SECTIONS
171 } in_section
= no_section
;
173 /* Return a non-zero value if DECL has a section attribute. */
174 #define IN_NAMED_SECTION(DECL) \
175 ((TREE_CODE (DECL) == FUNCTION_DECL || TREE_CODE (DECL) == VAR_DECL) \
176 && DECL_SECTION_NAME (DECL) != NULL_TREE)
178 /* Text of section name when in_section == in_named. */
179 static char *in_named_name
;
181 /* Define functions like text_section for any extra sections. */
182 #ifdef EXTRA_SECTION_FUNCTIONS
183 EXTRA_SECTION_FUNCTIONS
186 /* Tell assembler to switch to text section. */
191 if (in_section
!= in_text
)
193 fprintf (asm_out_file
, "%s\n", TEXT_SECTION_ASM_OP
);
194 in_section
= in_text
;
198 /* Tell assembler to switch to data section. */
203 if (in_section
!= in_data
)
205 if (flag_shared_data
)
207 #ifdef SHARED_SECTION_ASM_OP
208 fprintf (asm_out_file
, "%s\n", SHARED_SECTION_ASM_OP
);
210 fprintf (asm_out_file
, "%s\n", DATA_SECTION_ASM_OP
);
214 fprintf (asm_out_file
, "%s\n", DATA_SECTION_ASM_OP
);
216 in_section
= in_data
;
220 /* Tell assembler to switch to read-only data section. This is normally
224 readonly_data_section ()
226 #ifdef READONLY_DATA_SECTION
227 READONLY_DATA_SECTION (); /* Note this can call data_section. */
233 /* Determine if we're in the text section. */
238 return in_section
== in_text
;
241 /* Determine if we're in the data section. */
246 return in_section
== in_data
;
249 /* Tell assembler to change to section NAME for DECL.
250 If DECL is NULL, just switch to section NAME.
251 If NAME is NULL, get the name from DECL.
252 If RELOC is 1, the initializer for DECL contains relocs. */
255 named_section (decl
, name
, reloc
)
260 if (decl
!= NULL_TREE
261 && TREE_CODE_CLASS (TREE_CODE (decl
)) != 'd')
264 name
= TREE_STRING_POINTER (DECL_SECTION_NAME (decl
));
266 if (in_section
!= in_named
|| strcmp (name
, in_named_name
))
268 #ifdef ASM_OUTPUT_SECTION_NAME
269 ASM_OUTPUT_SECTION_NAME (asm_out_file
, decl
, name
, reloc
);
271 /* Section attributes are not supported if this macro isn't provided -
272 some host formats don't support them at all. The front-end should
273 already have flagged this as an error. */
277 in_named_name
= obstack_alloc (&permanent_obstack
, strlen (name
) + 1);
278 strcpy (in_named_name
, name
);
279 in_section
= in_named
;
283 #ifdef ASM_OUTPUT_SECTION_NAME
284 #ifndef UNIQUE_SECTION
285 #define UNIQUE_SECTION(DECL,RELOC) \
288 char *name, *string; \
290 name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL)); \
291 /* Strip off any encoding in name. */ \
292 STRIP_NAME_ENCODING (name, name); \
294 len = strlen (name) + 1; \
295 string = alloca (len + 1); \
296 sprintf (string, ".%s", name); \
298 DECL_SECTION_NAME (DECL) = build_string (len, string); \
301 #ifndef UNIQUE_SECTION_P
302 #define UNIQUE_SECTION_P(DECL) 0
306 #ifdef BSS_SECTION_ASM_OP
308 /* Tell the assembler to switch to the bss section. */
313 if (in_section
!= in_bss
)
315 #ifdef SHARED_BSS_SECTION_ASM_OP
316 if (flag_shared_data
)
317 fprintf (asm_out_file
, "%s\n", SHARED_BSS_SECTION_ASM_OP
);
320 fprintf (asm_out_file
, "%s\n", BSS_SECTION_ASM_OP
);
326 #ifdef ASM_OUTPUT_BSS
328 /* Utility function for ASM_OUTPUT_BSS for targets to use if
329 they don't support alignments in .bss.
330 ??? It is believed that this function will work in most cases so such
331 support is localized here. */
334 asm_output_bss (file
, decl
, name
, size
, rounded
)
340 ASM_GLOBALIZE_LABEL (file
, name
);
342 #ifdef ASM_DECLARE_OBJECT_NAME
343 last_assemble_variable_decl
= decl
;
344 ASM_DECLARE_OBJECT_NAME (file
, name
, decl
);
346 /* Standard thing is just output label for the object. */
347 ASM_OUTPUT_LABEL (file
, name
);
348 #endif /* ASM_DECLARE_OBJECT_NAME */
349 ASM_OUTPUT_SKIP (file
, rounded
);
354 #ifdef ASM_OUTPUT_ALIGNED_BSS
356 /* Utility function for targets to use in implementing
357 ASM_OUTPUT_ALIGNED_BSS.
358 ??? It is believed that this function will work in most cases so such
359 support is localized here. */
362 asm_output_aligned_bss (file
, decl
, name
, size
, align
)
368 ASM_GLOBALIZE_LABEL (file
, name
);
370 ASM_OUTPUT_ALIGN (file
, floor_log2 (align
/ BITS_PER_UNIT
));
371 #ifdef ASM_DECLARE_OBJECT_NAME
372 last_assemble_variable_decl
= decl
;
373 ASM_DECLARE_OBJECT_NAME (file
, name
, decl
);
375 /* Standard thing is just output label for the object. */
376 ASM_OUTPUT_LABEL (file
, name
);
377 #endif /* ASM_DECLARE_OBJECT_NAME */
378 ASM_OUTPUT_SKIP (file
, size
? size
: 1);
383 #endif /* BSS_SECTION_ASM_OP */
385 #ifdef EH_FRAME_SECTION_ASM_OP
389 if (in_section
!= in_eh_frame
)
391 fprintf (asm_out_file
, "%s\n", EH_FRAME_SECTION_ASM_OP
);
392 in_section
= in_eh_frame
;
397 /* Switch to the section for function DECL.
399 If DECL is NULL_TREE, switch to the text section.
400 ??? It's not clear that we will ever be passed NULL_TREE, but it's
401 safer to handle it. */
404 function_section (decl
)
407 if (decl
!= NULL_TREE
408 && DECL_SECTION_NAME (decl
) != NULL_TREE
)
409 named_section (decl
, (char *) 0, 0);
414 /* Switch to section for variable DECL.
416 RELOC is the `reloc' argument to SELECT_SECTION. */
419 variable_section (decl
, reloc
)
423 if (IN_NAMED_SECTION (decl
))
424 named_section (decl
, NULL
, reloc
);
427 /* C++ can have const variables that get initialized from constructors,
428 and thus can not be in a readonly section. We prevent this by
429 verifying that the initial value is constant for objects put in a
432 error_mark_node is used by the C front end to indicate that the
433 initializer has not been seen yet. In this case, we assume that
434 the initializer must be constant.
436 C++ uses error_mark_node for variables that have complicated
437 initializers, but these variables go in BSS so we won't be called
440 #ifdef SELECT_SECTION
441 SELECT_SECTION (decl
, reloc
);
443 if (DECL_READONLY_SECTION (decl
, reloc
))
444 readonly_data_section ();
451 /* Tell assembler to switch to the section for the exception handling
457 #if defined (EXCEPTION_SECTION)
458 EXCEPTION_SECTION ();
460 #ifdef ASM_OUTPUT_SECTION_NAME
461 named_section (NULL_TREE
, ".gcc_except_table", 0);
466 readonly_data_section ();
471 /* Create the rtl to represent a function, for a function definition.
472 DECL is a FUNCTION_DECL node which describes which function.
473 The rtl is stored into DECL. */
476 make_function_rtl (decl
)
479 char *name
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
));
480 char *new_name
= name
;
482 /* Rename a nested function to avoid conflicts. */
483 if (decl_function_context (decl
) != 0
484 && DECL_INITIAL (decl
) != 0
485 && DECL_RTL (decl
) == 0)
489 name
= IDENTIFIER_POINTER (DECL_NAME (decl
));
490 ASM_FORMAT_PRIVATE_NAME (label
, name
, var_labelno
);
491 name
= obstack_copy0 (saveable_obstack
, label
, strlen (label
));
496 /* When -fprefix-function-name is used, every function name is
497 prefixed. Even static functions are prefixed because they
498 could be declared latter. Note that a nested function name
500 if (flag_prefix_function_name
)
502 new_name
= (char *) alloca (strlen (name
) + CHKR_PREFIX_SIZE
+ 1);
503 strcpy (new_name
, CHKR_PREFIX
);
504 strcpy (new_name
+ CHKR_PREFIX_SIZE
, name
);
505 name
= obstack_copy0 (saveable_obstack
, new_name
, strlen (new_name
));
509 if (DECL_RTL (decl
) == 0)
512 = gen_rtx_MEM (DECL_MODE (decl
),
513 gen_rtx_SYMBOL_REF (Pmode
, name
));
515 /* Optionally set flags or add text to the name to record information
516 such as that it is a function name. If the name is changed, the macro
517 ASM_OUTPUT_LABELREF will have to know how to strip this information. */
518 #ifdef ENCODE_SECTION_INFO
519 ENCODE_SECTION_INFO (decl
);
524 /* ??? Another way to do this would be to do what halfpic.c does
525 and maintain a hashed table of such critters. */
526 /* ??? Another way to do this would be to pass a flag bit to
527 ENCODE_SECTION_INFO saying whether this is a new decl or not. */
528 /* Let the target reassign the RTL if it wants.
529 This is necessary, for example, when one machine specific
530 decl attribute overrides another. */
531 #ifdef REDO_SECTION_INFO_P
532 if (REDO_SECTION_INFO_P (decl
))
533 ENCODE_SECTION_INFO (decl
);
537 /* Record at least one function has been defined. */
538 function_defined
= 1;
541 /* Given NAME, a putative register name, discard any customary prefixes. */
544 strip_reg_name (name
)
547 #ifdef REGISTER_PREFIX
548 if (!strncmp (name
, REGISTER_PREFIX
, strlen (REGISTER_PREFIX
)))
549 name
+= strlen (REGISTER_PREFIX
);
551 if (name
[0] == '%' || name
[0] == '#')
556 /* Decode an `asm' spec for a declaration as a register name.
557 Return the register number, or -1 if nothing specified,
558 or -2 if the ASMSPEC is not `cc' or `memory' and is not recognized,
559 or -3 if ASMSPEC is `cc' and is not recognized,
560 or -4 if ASMSPEC is `memory' and is not recognized.
561 Accept an exact spelling or a decimal number.
562 Prefixes such as % are optional. */
565 decode_reg_name (asmspec
)
572 /* Get rid of confusing prefixes. */
573 asmspec
= strip_reg_name (asmspec
);
575 /* Allow a decimal number as a "register name". */
576 for (i
= strlen (asmspec
) - 1; i
>= 0; i
--)
577 if (! (asmspec
[i
] >= '0' && asmspec
[i
] <= '9'))
579 if (asmspec
[0] != 0 && i
< 0)
582 if (i
< FIRST_PSEUDO_REGISTER
&& i
>= 0)
588 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; i
++)
590 && ! strcmp (asmspec
, strip_reg_name (reg_names
[i
])))
593 #ifdef ADDITIONAL_REGISTER_NAMES
595 static struct { char *name
; int number
; } table
[]
596 = ADDITIONAL_REGISTER_NAMES
;
598 for (i
= 0; i
< (int)(sizeof (table
) / sizeof (table
[0])); i
++)
599 if (! strcmp (asmspec
, table
[i
].name
))
600 return table
[i
].number
;
602 #endif /* ADDITIONAL_REGISTER_NAMES */
604 if (!strcmp (asmspec
, "memory"))
607 if (!strcmp (asmspec
, "cc"))
616 /* Create the DECL_RTL for a declaration for a static or external variable
617 or static or external function.
618 ASMSPEC, if not 0, is the string which the user specified
619 as the assembler symbol name.
620 TOP_LEVEL is nonzero if this is a file-scope variable.
622 This is never called for PARM_DECL nodes. */
625 make_decl_rtl (decl
, asmspec
, top_level
)
630 register char *name
= 0;
633 reg_number
= decode_reg_name (asmspec
);
635 if (DECL_ASSEMBLER_NAME (decl
) != NULL_TREE
)
636 name
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
));
638 if (reg_number
== -2)
640 /* ASMSPEC is given, and not the name of a register. */
641 name
= (char *) obstack_alloc (saveable_obstack
,
642 strlen (asmspec
) + 2);
644 strcpy (&name
[1], asmspec
);
647 /* For a duplicate declaration, we can be called twice on the
648 same DECL node. Don't discard the RTL already made. */
649 if (DECL_RTL (decl
) == 0)
651 /* First detect errors in declaring global registers. */
652 if (TREE_CODE (decl
) != FUNCTION_DECL
653 && DECL_REGISTER (decl
) && reg_number
== -1)
654 error_with_decl (decl
,
655 "register name not specified for `%s'");
656 else if (TREE_CODE (decl
) != FUNCTION_DECL
657 && DECL_REGISTER (decl
) && reg_number
< 0)
658 error_with_decl (decl
,
659 "invalid register name for `%s'");
660 else if ((reg_number
>= 0 || reg_number
== -3)
661 && (TREE_CODE (decl
) == FUNCTION_DECL
662 && ! DECL_REGISTER (decl
)))
663 error_with_decl (decl
,
664 "register name given for non-register variable `%s'");
665 else if (TREE_CODE (decl
) != FUNCTION_DECL
666 && DECL_REGISTER (decl
)
667 && TYPE_MODE (TREE_TYPE (decl
)) == BLKmode
)
668 error_with_decl (decl
,
669 "data type of `%s' isn't suitable for a register");
670 else if (TREE_CODE (decl
) != FUNCTION_DECL
&& DECL_REGISTER (decl
)
671 && ! HARD_REGNO_MODE_OK (reg_number
,
672 TYPE_MODE (TREE_TYPE (decl
))))
673 error_with_decl (decl
,
674 "register number for `%s' isn't suitable for data type");
675 /* Now handle properly declared static register variables. */
676 else if (TREE_CODE (decl
) != FUNCTION_DECL
&& DECL_REGISTER (decl
))
680 if (DECL_INITIAL (decl
) != 0 && top_level
)
682 DECL_INITIAL (decl
) = 0;
683 error ("global register variable has initial value");
685 if (fixed_regs
[reg_number
] == 0
686 && function_defined
&& top_level
)
687 error ("global register variable follows a function definition");
688 if (TREE_THIS_VOLATILE (decl
))
689 warning ("volatile register variables don't work as you might wish");
691 /* If the user specified one of the eliminables registers here,
692 e.g., FRAME_POINTER_REGNUM, we don't want to get this variable
693 confused with that register and be eliminated. Although this
694 usage is somewhat suspect, we nevertheless use the following
695 kludge to avoid setting DECL_RTL to frame_pointer_rtx. */
698 = gen_rtx_REG (DECL_MODE (decl
), FIRST_PSEUDO_REGISTER
);
699 REGNO (DECL_RTL (decl
)) = reg_number
;
700 REG_USERVAR_P (DECL_RTL (decl
)) = 1;
704 /* Make this register global, so not usable for anything
706 nregs
= HARD_REGNO_NREGS (reg_number
, DECL_MODE (decl
));
708 globalize_reg (reg_number
+ --nregs
);
711 /* Specifying a section attribute on a variable forces it into a
712 non-.bss section, and thus it cannot be common. */
713 else if (TREE_CODE (decl
) == VAR_DECL
714 && DECL_SECTION_NAME (decl
) != NULL_TREE
715 && DECL_INITIAL (decl
) == NULL_TREE
716 && DECL_COMMON (decl
))
717 DECL_COMMON (decl
) = 0;
719 /* Now handle ordinary static variables and functions (in memory).
720 Also handle vars declared register invalidly. */
721 if (DECL_RTL (decl
) == 0)
723 /* Can't use just the variable's own name for a variable
724 whose scope is less than the whole file.
725 Concatenate a distinguishing number. */
726 if (!top_level
&& !TREE_PUBLIC (decl
) && asmspec
== 0)
730 ASM_FORMAT_PRIVATE_NAME (label
, name
, var_labelno
);
731 name
= obstack_copy0 (saveable_obstack
, label
, strlen (label
));
738 /* When -fprefix-function-name is used, the functions
739 names are prefixed. Only nested function names are not
741 if (flag_prefix_function_name
&& TREE_CODE (decl
) == FUNCTION_DECL
)
744 new_name
= (char *) alloca (strlen (name
) + CHKR_PREFIX_SIZE
746 strcpy (new_name
, CHKR_PREFIX
);
747 strcpy (new_name
+ CHKR_PREFIX_SIZE
, name
);
748 name
= obstack_copy0 (saveable_obstack
,
749 new_name
, strlen (new_name
));
752 DECL_RTL (decl
) = gen_rtx_MEM (DECL_MODE (decl
),
753 gen_rtx_SYMBOL_REF (Pmode
, name
));
754 MEM_ALIAS_SET (DECL_RTL (decl
)) = get_alias_set (decl
);
756 /* If this variable is to be treated as volatile, show its
757 tree node has side effects. If it has side effects, either
758 because of this test or from TREE_THIS_VOLATILE also
759 being set, show the MEM is volatile. */
760 if (flag_volatile_global
&& TREE_CODE (decl
) == VAR_DECL
761 && TREE_PUBLIC (decl
))
762 TREE_SIDE_EFFECTS (decl
) = 1;
763 if (TREE_SIDE_EFFECTS (decl
))
764 MEM_VOLATILE_P (DECL_RTL (decl
)) = 1;
766 if (TREE_READONLY (decl
))
767 RTX_UNCHANGING_P (DECL_RTL (decl
)) = 1;
768 MEM_IN_STRUCT_P (DECL_RTL (decl
))
769 = AGGREGATE_TYPE_P (TREE_TYPE (decl
));
771 /* Optionally set flags or add text to the name to record information
772 such as that it is a function name.
773 If the name is changed, the macro ASM_OUTPUT_LABELREF
774 will have to know how to strip this information. */
775 #ifdef ENCODE_SECTION_INFO
776 ENCODE_SECTION_INFO (decl
);
782 /* If the old RTL had the wrong mode, fix the mode. */
783 if (GET_MODE (DECL_RTL (decl
)) != DECL_MODE (decl
))
785 rtx rtl
= DECL_RTL (decl
);
786 PUT_MODE (rtl
, DECL_MODE (decl
));
789 /* ??? Another way to do this would be to do what halfpic.c does
790 and maintain a hashed table of such critters. */
791 /* ??? Another way to do this would be to pass a flag bit to
792 ENCODE_SECTION_INFO saying whether this is a new decl or not. */
793 /* Let the target reassign the RTL if it wants.
794 This is necessary, for example, when one machine specific
795 decl attribute overrides another. */
796 #ifdef REDO_SECTION_INFO_P
797 if (REDO_SECTION_INFO_P (decl
))
798 ENCODE_SECTION_INFO (decl
);
803 /* Make the rtl for variable VAR be volatile.
804 Use this only for static variables. */
807 make_var_volatile (var
)
810 if (GET_CODE (DECL_RTL (var
)) != MEM
)
813 MEM_VOLATILE_P (DECL_RTL (var
)) = 1;
816 /* Output alignment directive to align for constant expression EXP. */
819 assemble_constant_align (exp
)
824 /* Align the location counter as required by EXP's data type. */
825 align
= TYPE_ALIGN (TREE_TYPE (exp
));
826 #ifdef CONSTANT_ALIGNMENT
827 align
= CONSTANT_ALIGNMENT (exp
, align
);
830 if (align
> BITS_PER_UNIT
)
831 ASM_OUTPUT_ALIGN (asm_out_file
, floor_log2 (align
/ BITS_PER_UNIT
));
834 /* Output a string of literal assembler code
835 for an `asm' keyword used between functions. */
838 assemble_asm (string
)
843 if (TREE_CODE (string
) == ADDR_EXPR
)
844 string
= TREE_OPERAND (string
, 0);
846 fprintf (asm_out_file
, "\t%s\n", TREE_STRING_POINTER (string
));
849 #if 0 /* This should no longer be needed, because
850 flag_gnu_linker should be 0 on these systems,
851 which should prevent any output
852 if ASM_OUTPUT_CONSTRUCTOR and ASM_OUTPUT_DESTRUCTOR are absent. */
853 #if !(defined(DBX_DEBUGGING_INFO) && !defined(FASCIST_ASSEMBLER))
854 #ifndef ASM_OUTPUT_CONSTRUCTOR
855 #define ASM_OUTPUT_CONSTRUCTOR(file, name)
857 #ifndef ASM_OUTPUT_DESTRUCTOR
858 #define ASM_OUTPUT_DESTRUCTOR(file, name)
863 /* Record an element in the table of global destructors.
864 How this is done depends on what sort of assembler and linker
867 NAME should be the name of a global function to be called
868 at exit time. This name is output using assemble_name. */
871 assemble_destructor (name
)
874 #ifdef ASM_OUTPUT_DESTRUCTOR
875 ASM_OUTPUT_DESTRUCTOR (asm_out_file
, name
);
879 /* Now tell GNU LD that this is part of the static destructor set. */
880 /* This code works for any machine provided you use GNU as/ld. */
881 fprintf (asm_out_file
, "%s \"___DTOR_LIST__\",22,0,0,", ASM_STABS_OP
);
882 assemble_name (asm_out_file
, name
);
883 fputc ('\n', asm_out_file
);
888 /* Likewise for global constructors. */
891 assemble_constructor (name
)
894 #ifdef ASM_OUTPUT_CONSTRUCTOR
895 ASM_OUTPUT_CONSTRUCTOR (asm_out_file
, name
);
899 /* Now tell GNU LD that this is part of the static constructor set. */
900 /* This code works for any machine provided you use GNU as/ld. */
901 fprintf (asm_out_file
, "%s \"___CTOR_LIST__\",22,0,0,", ASM_STABS_OP
);
902 assemble_name (asm_out_file
, name
);
903 fputc ('\n', asm_out_file
);
908 /* Likewise for entries we want to record for garbage collection.
909 Garbage collection is still under development. */
912 assemble_gc_entry (name
)
915 #ifdef ASM_OUTPUT_GC_ENTRY
916 ASM_OUTPUT_GC_ENTRY (asm_out_file
, name
);
920 /* Now tell GNU LD that this is part of the static constructor set. */
921 fprintf (asm_out_file
, "%s \"___PTR_LIST__\",22,0,0,", ASM_STABS_OP
);
922 assemble_name (asm_out_file
, name
);
923 fputc ('\n', asm_out_file
);
928 /* CONSTANT_POOL_BEFORE_FUNCTION may be defined as an expression with
929 a non-zero value if the constant pool should be output before the
930 start of the function, or a zero value if the pool should output
931 after the end of the function. The default is to put it before the
934 #ifndef CONSTANT_POOL_BEFORE_FUNCTION
935 #define CONSTANT_POOL_BEFORE_FUNCTION 1
938 /* Output assembler code for the constant pool of a function and associated
939 with defining the name of the function. DECL describes the function.
940 NAME is the function's name. For the constant pool, we use the current
941 constant pool data. */
944 assemble_start_function (decl
, fnname
)
950 /* The following code does not need preprocessing in the assembler. */
954 if (CONSTANT_POOL_BEFORE_FUNCTION
)
955 output_constant_pool (fnname
, decl
);
957 #ifdef ASM_OUTPUT_SECTION_NAME
958 /* If the function is to be put in its own section and it's not in a section
959 already, indicate so. */
960 if ((flag_function_sections
961 && DECL_SECTION_NAME (decl
) == NULL_TREE
)
962 || UNIQUE_SECTION_P (decl
))
963 UNIQUE_SECTION (decl
, 0);
966 function_section (decl
);
968 /* Tell assembler to move to target machine's alignment for functions. */
969 align
= floor_log2 (FUNCTION_BOUNDARY
/ BITS_PER_UNIT
);
971 ASM_OUTPUT_ALIGN (asm_out_file
, align
);
973 #ifdef ASM_OUTPUT_FUNCTION_PREFIX
974 ASM_OUTPUT_FUNCTION_PREFIX (asm_out_file
, fnname
);
977 #ifdef SDB_DEBUGGING_INFO
978 /* Output SDB definition of the function. */
979 if (write_symbols
== SDB_DEBUG
)
980 sdbout_mark_begin_function ();
983 #ifdef DBX_DEBUGGING_INFO
984 /* Output DBX definition of the function. */
985 if (write_symbols
== DBX_DEBUG
)
986 dbxout_begin_function (decl
);
989 /* Make function name accessible from other files, if appropriate. */
991 if (TREE_PUBLIC (decl
))
993 if (! first_global_object_name
)
998 if (! DECL_WEAK (decl
) && ! DECL_ONE_ONLY (decl
))
999 name
= &first_global_object_name
;
1001 name
= &weak_global_object_name
;
1003 STRIP_NAME_ENCODING (p
, fnname
);
1004 *name
= permalloc (strlen (p
) + 1);
1008 #ifdef ASM_WEAKEN_LABEL
1009 if (DECL_WEAK (decl
))
1010 ASM_WEAKEN_LABEL (asm_out_file
, fnname
);
1013 ASM_GLOBALIZE_LABEL (asm_out_file
, fnname
);
1016 /* Do any machine/system dependent processing of the function name */
1017 #ifdef ASM_DECLARE_FUNCTION_NAME
1018 ASM_DECLARE_FUNCTION_NAME (asm_out_file
, fnname
, current_function_decl
);
1020 /* Standard thing is just output label for the function. */
1021 ASM_OUTPUT_LABEL (asm_out_file
, fnname
);
1022 #endif /* ASM_DECLARE_FUNCTION_NAME */
1025 /* Output assembler code associated with defining the size of the
1026 function. DECL describes the function. NAME is the function's name. */
1029 assemble_end_function (decl
, fnname
)
1033 #ifdef ASM_DECLARE_FUNCTION_SIZE
1034 ASM_DECLARE_FUNCTION_SIZE (asm_out_file
, fnname
, decl
);
1036 if (! CONSTANT_POOL_BEFORE_FUNCTION
)
1038 output_constant_pool (fnname
, decl
);
1039 function_section (decl
); /* need to switch back */
1042 /* Output any constants which should appear after the function. */
1043 output_after_function_constants ();
1046 /* Assemble code to leave SIZE bytes of zeros. */
1049 assemble_zeros (size
)
1052 #ifdef ASM_NO_SKIP_IN_TEXT
1053 /* The `space' pseudo in the text section outputs nop insns rather than 0s,
1054 so we must output 0s explicitly in the text section. */
1055 if (ASM_NO_SKIP_IN_TEXT
&& in_text_section ())
1059 for (i
= 0; i
< size
- 20; i
+= 20)
1062 fprintf (asm_out_file
,
1063 "%s 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n", ASM_BYTE_OP
);
1065 fprintf (asm_out_file
,
1066 "\tbyte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n");
1072 fprintf (asm_out_file
, "%s 0", ASM_BYTE_OP
);
1074 fprintf (asm_out_file
, "\tbyte 0");
1077 for (; i
< size
; i
++)
1078 fprintf (asm_out_file
, ",0");
1079 fprintf (asm_out_file
, "\n");
1085 ASM_OUTPUT_SKIP (asm_out_file
, size
);
1088 /* Assemble an alignment pseudo op for an ALIGN-bit boundary. */
1091 assemble_align (align
)
1094 if (align
> BITS_PER_UNIT
)
1095 ASM_OUTPUT_ALIGN (asm_out_file
, floor_log2 (align
/ BITS_PER_UNIT
));
1098 /* Assemble a string constant with the specified C string as contents. */
1101 assemble_string (p
, size
)
1108 /* If the string is very long, split it up. */
1112 int thissize
= size
- pos
;
1113 if (thissize
> maximum
)
1116 ASM_OUTPUT_ASCII (asm_out_file
, p
, thissize
);
1124 /* Assemble everything that is needed for a variable or function declaration.
1125 Not used for automatic variables, and not used for function definitions.
1126 Should not be called for variables of incomplete structure type.
1128 TOP_LEVEL is nonzero if this variable has file scope.
1129 AT_END is nonzero if this is the special handling, at end of compilation,
1130 to define things that have had only tentative definitions.
1131 DONT_OUTPUT_DATA if nonzero means don't actually output the
1132 initial value (that will be done by the caller). */
1135 assemble_variable (decl
, top_level
, at_end
, dont_output_data
)
1137 int top_level ATTRIBUTE_UNUSED
;
1139 int dont_output_data
;
1141 register char *name
;
1145 enum in_section saved_in_section
;
1147 last_assemble_variable_decl
= 0;
1149 if (GET_CODE (DECL_RTL (decl
)) == REG
)
1151 /* Do output symbol info for global register variables, but do nothing
1154 if (TREE_ASM_WRITTEN (decl
))
1156 TREE_ASM_WRITTEN (decl
) = 1;
1158 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
1159 /* File-scope global variables are output here. */
1160 if ((write_symbols
== DBX_DEBUG
|| write_symbols
== XCOFF_DEBUG
)
1162 dbxout_symbol (decl
, 0);
1164 #ifdef SDB_DEBUGGING_INFO
1165 if (write_symbols
== SDB_DEBUG
&& top_level
1166 /* Leave initialized global vars for end of compilation;
1167 see comment in compile_file. */
1168 && (TREE_PUBLIC (decl
) == 0 || DECL_INITIAL (decl
) == 0))
1169 sdbout_symbol (decl
, 0);
1172 /* Don't output any DWARF debugging information for variables here.
1173 In the case of local variables, the information for them is output
1174 when we do our recursive traversal of the tree representation for
1175 the entire containing function. In the case of file-scope variables,
1176 we output information for all of them at the very end of compilation
1177 while we are doing our final traversal of the chain of file-scope
1183 /* Normally no need to say anything here for external references,
1184 since assemble_external is called by the language-specific code
1185 when a declaration is first seen. */
1187 if (DECL_EXTERNAL (decl
))
1190 /* Output no assembler code for a function declaration.
1191 Only definitions of functions output anything. */
1193 if (TREE_CODE (decl
) == FUNCTION_DECL
)
1196 /* If type was incomplete when the variable was declared,
1197 see if it is complete now. */
1199 if (DECL_SIZE (decl
) == 0)
1200 layout_decl (decl
, 0);
1202 /* Still incomplete => don't allocate it; treat the tentative defn
1203 (which is what it must have been) as an `extern' reference. */
1205 if (!dont_output_data
&& DECL_SIZE (decl
) == 0)
1207 error_with_file_and_line (DECL_SOURCE_FILE (decl
),
1208 DECL_SOURCE_LINE (decl
),
1209 "storage size of `%s' isn't known",
1210 IDENTIFIER_POINTER (DECL_NAME (decl
)));
1211 TREE_ASM_WRITTEN (decl
) = 1;
1215 /* The first declaration of a variable that comes through this function
1216 decides whether it is global (in C, has external linkage)
1217 or local (in C, has internal linkage). So do nothing more
1218 if this function has already run. */
1220 if (TREE_ASM_WRITTEN (decl
))
1223 TREE_ASM_WRITTEN (decl
) = 1;
1227 if (! dont_output_data
)
1231 if (TREE_CODE (DECL_SIZE (decl
)) != INTEGER_CST
)
1234 /* This is better than explicit arithmetic, since it avoids overflow. */
1235 size_tree
= size_binop (CEIL_DIV_EXPR
,
1236 DECL_SIZE (decl
), size_int (BITS_PER_UNIT
));
1238 size
= TREE_INT_CST_LOW (size_tree
);
1239 if (TREE_INT_CST_HIGH (size_tree
) != 0
1240 || size
!= TREE_INT_CST_LOW (size_tree
))
1242 error_with_decl (decl
, "size of variable `%s' is too large");
1247 name
= XSTR (XEXP (DECL_RTL (decl
), 0), 0);
1249 if (TREE_PUBLIC (decl
) && DECL_NAME (decl
)
1250 && ! first_global_object_name
1251 && ! (DECL_COMMON (decl
) && (DECL_INITIAL (decl
) == 0
1252 || DECL_INITIAL (decl
) == error_mark_node
))
1253 && ! DECL_WEAK (decl
)
1254 && ! DECL_ONE_ONLY (decl
))
1258 STRIP_NAME_ENCODING (p
, name
);
1259 first_global_object_name
= permalloc (strlen (p
) + 1);
1260 strcpy (first_global_object_name
, p
);
1263 /* Compute the alignment of this data. */
1265 align
= DECL_ALIGN (decl
);
1267 /* In the case for initialing an array whose length isn't specified,
1268 where we have not yet been able to do the layout,
1269 figure out the proper alignment now. */
1270 if (dont_output_data
&& DECL_SIZE (decl
) == 0
1271 && TREE_CODE (TREE_TYPE (decl
)) == ARRAY_TYPE
)
1272 align
= MAX (align
, TYPE_ALIGN (TREE_TYPE (TREE_TYPE (decl
))));
1274 /* Some object file formats have a maximum alignment which they support.
1275 In particular, a.out format supports a maximum alignment of 4. */
1276 #ifndef MAX_OFILE_ALIGNMENT
1277 #define MAX_OFILE_ALIGNMENT BIGGEST_ALIGNMENT
1279 if (align
> MAX_OFILE_ALIGNMENT
)
1281 warning_with_decl (decl
,
1282 "alignment of `%s' is greater than maximum object file alignment. Using %d.",
1283 MAX_OFILE_ALIGNMENT
/BITS_PER_UNIT
);
1284 align
= MAX_OFILE_ALIGNMENT
;
1287 /* On some machines, it is good to increase alignment sometimes. */
1288 #ifdef DATA_ALIGNMENT
1289 align
= DATA_ALIGNMENT (TREE_TYPE (decl
), align
);
1291 #ifdef CONSTANT_ALIGNMENT
1292 if (DECL_INITIAL (decl
) != 0 && DECL_INITIAL (decl
) != error_mark_node
)
1293 align
= CONSTANT_ALIGNMENT (DECL_INITIAL (decl
), align
);
1296 /* Reset the alignment in case we have made it tighter, so we can benefit
1297 from it in get_pointer_alignment. */
1298 DECL_ALIGN (decl
) = align
;
1300 /* Handle uninitialized definitions. */
1302 if ((DECL_INITIAL (decl
) == 0 || DECL_INITIAL (decl
) == error_mark_node
)
1303 /* If the target can't output uninitialized but not common global data
1304 in .bss, then we have to use .data. */
1305 #if ! defined (ASM_OUTPUT_BSS) && ! defined (ASM_OUTPUT_ALIGNED_BSS)
1306 && DECL_COMMON (decl
)
1308 && ! dont_output_data
)
1310 int size
= TREE_INT_CST_LOW (size_tree
);
1313 /* Don't allocate zero bytes of common,
1314 since that means "undefined external" in the linker. */
1315 if (size
== 0) rounded
= 1;
1316 /* Round size up to multiple of BIGGEST_ALIGNMENT bits
1317 so that each uninitialized object starts on such a boundary. */
1318 rounded
+= (BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
) - 1;
1319 rounded
= (rounded
/ (BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
)
1320 * (BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
));
1322 #if !defined(ASM_OUTPUT_ALIGNED_COMMON) && !defined(ASM_OUTPUT_ALIGNED_BSS)
1323 if ( (DECL_ALIGN (decl
) / BITS_PER_UNIT
) > rounded
)
1325 (decl
, "requested alignment for %s is greater than implemented alignment of %d.",rounded
);
1328 #ifdef DBX_DEBUGGING_INFO
1329 /* File-scope global variables are output here. */
1330 if (write_symbols
== DBX_DEBUG
&& top_level
)
1331 dbxout_symbol (decl
, 0);
1333 #ifdef SDB_DEBUGGING_INFO
1334 if (write_symbols
== SDB_DEBUG
&& top_level
1335 /* Leave initialized global vars for end of compilation;
1336 see comment in compile_file. */
1337 && (TREE_PUBLIC (decl
) == 0 || DECL_INITIAL (decl
) == 0))
1338 sdbout_symbol (decl
, 0);
1341 /* Don't output any DWARF debugging information for variables here.
1342 In the case of local variables, the information for them is output
1343 when we do our recursive traversal of the tree representation for
1344 the entire containing function. In the case of file-scope variables,
1345 we output information for all of them at the very end of compilation
1346 while we are doing our final traversal of the chain of file-scope
1349 #if 0 /* ??? We should either delete this or add a comment describing what
1350 it was intended to do and why we shouldn't delete it. */
1351 if (flag_shared_data
)
1355 if (TREE_PUBLIC (decl
)
1356 #if defined (ASM_OUTPUT_BSS) || defined (ASM_OUTPUT_ALIGNED_BSS)
1357 && DECL_COMMON (decl
)
1361 #ifdef ASM_OUTPUT_SHARED_COMMON
1362 if (flag_shared_data
)
1363 ASM_OUTPUT_SHARED_COMMON (asm_out_file
, name
, size
, rounded
);
1367 #ifdef ASM_OUTPUT_ALIGNED_DECL_COMMON
1368 ASM_OUTPUT_ALIGNED_DECL_COMMON (asm_out_file
, decl
, name
, size
,
1371 #ifdef ASM_OUTPUT_ALIGNED_COMMON
1372 ASM_OUTPUT_ALIGNED_COMMON (asm_out_file
, name
, size
,
1375 ASM_OUTPUT_COMMON (asm_out_file
, name
, size
, rounded
);
1380 #if defined (ASM_OUTPUT_BSS) || defined (ASM_OUTPUT_ALIGNED_BSS)
1381 else if (TREE_PUBLIC (decl
))
1383 #ifdef ASM_OUTPUT_SHARED_BSS
1384 if (flag_shared_data
)
1385 ASM_OUTPUT_SHARED_BSS (asm_out_file
, decl
, name
, size
, rounded
);
1389 #ifdef ASM_OUTPUT_ALIGNED_BSS
1390 ASM_OUTPUT_ALIGNED_BSS (asm_out_file
, decl
, name
, size
,
1393 ASM_OUTPUT_BSS (asm_out_file
, decl
, name
, size
, rounded
);
1397 #endif /* ASM_OUTPUT_BSS || ASM_OUTPUT_ALIGNED_BSS */
1400 #ifdef ASM_OUTPUT_SHARED_LOCAL
1401 if (flag_shared_data
)
1402 ASM_OUTPUT_SHARED_LOCAL (asm_out_file
, name
, size
, rounded
);
1406 #ifdef ASM_OUTPUT_ALIGNED_DECL_LOCAL
1407 ASM_OUTPUT_ALIGNED_DECL_LOCAL (asm_out_file
, decl
, name
, size
,
1410 #ifdef ASM_OUTPUT_ALIGNED_LOCAL
1411 ASM_OUTPUT_ALIGNED_LOCAL (asm_out_file
, name
, size
,
1414 ASM_OUTPUT_LOCAL (asm_out_file
, name
, size
, rounded
);
1422 /* Handle initialized definitions.
1423 Also handle uninitialized global definitions if -fno-common and the
1424 target doesn't support ASM_OUTPUT_BSS. */
1426 /* First make the assembler name(s) global if appropriate. */
1427 if (TREE_PUBLIC (decl
) && DECL_NAME (decl
))
1429 #ifdef ASM_WEAKEN_LABEL
1430 if (DECL_WEAK (decl
))
1431 ASM_WEAKEN_LABEL (asm_out_file
, name
);
1434 ASM_GLOBALIZE_LABEL (asm_out_file
, name
);
1437 for (d
= equivalents
; d
; d
= TREE_CHAIN (d
))
1439 tree e
= TREE_VALUE (d
);
1440 if (TREE_PUBLIC (e
) && DECL_NAME (e
))
1441 ASM_GLOBALIZE_LABEL (asm_out_file
,
1442 XSTR (XEXP (DECL_RTL (e
), 0), 0));
1446 /* Output any data that we will need to use the address of. */
1447 if (DECL_INITIAL (decl
) == error_mark_node
)
1448 reloc
= contains_pointers_p (TREE_TYPE (decl
));
1449 else if (DECL_INITIAL (decl
))
1450 reloc
= output_addressed_constants (DECL_INITIAL (decl
));
1452 #ifdef ASM_OUTPUT_SECTION_NAME
1453 if ((flag_data_sections
!= 0
1454 && DECL_SECTION_NAME (decl
) == NULL_TREE
)
1455 || UNIQUE_SECTION_P (decl
))
1456 UNIQUE_SECTION (decl
, reloc
);
1459 /* Switch to the appropriate section. */
1460 variable_section (decl
, reloc
);
1462 /* dbxout.c needs to know this. */
1463 if (in_text_section ())
1464 DECL_IN_TEXT_SECTION (decl
) = 1;
1466 /* Record current section so we can restore it if dbxout.c clobbers it. */
1467 saved_in_section
= in_section
;
1469 /* Output the dbx info now that we have chosen the section. */
1471 #ifdef DBX_DEBUGGING_INFO
1472 /* File-scope global variables are output here. */
1473 if (write_symbols
== DBX_DEBUG
&& top_level
)
1474 dbxout_symbol (decl
, 0);
1476 #ifdef SDB_DEBUGGING_INFO
1477 if (write_symbols
== SDB_DEBUG
&& top_level
1478 /* Leave initialized global vars for end of compilation;
1479 see comment in compile_file. */
1480 && (TREE_PUBLIC (decl
) == 0 || DECL_INITIAL (decl
) == 0))
1481 sdbout_symbol (decl
, 0);
1484 /* Don't output any DWARF debugging information for variables here.
1485 In the case of local variables, the information for them is output
1486 when we do our recursive traversal of the tree representation for
1487 the entire containing function. In the case of file-scope variables,
1488 we output information for all of them at the very end of compilation
1489 while we are doing our final traversal of the chain of file-scope
1492 /* If the debugging output changed sections, reselect the section
1493 that's supposed to be selected. */
1494 if (in_section
!= saved_in_section
)
1495 variable_section (decl
, reloc
);
1497 /* Output the alignment of this data. */
1498 if (align
> BITS_PER_UNIT
)
1499 ASM_OUTPUT_ALIGN (asm_out_file
,
1500 floor_log2 (DECL_ALIGN (decl
) / BITS_PER_UNIT
));
1502 /* Do any machine/system dependent processing of the object. */
1503 #ifdef ASM_DECLARE_OBJECT_NAME
1504 last_assemble_variable_decl
= decl
;
1505 ASM_DECLARE_OBJECT_NAME (asm_out_file
, name
, decl
);
1507 /* Standard thing is just output label for the object. */
1508 ASM_OUTPUT_LABEL (asm_out_file
, name
);
1509 #endif /* ASM_DECLARE_OBJECT_NAME */
1511 if (!dont_output_data
)
1513 if (DECL_INITIAL (decl
))
1514 /* Output the actual data. */
1515 output_constant (DECL_INITIAL (decl
), TREE_INT_CST_LOW (size_tree
));
1517 /* Leave space for it. */
1518 assemble_zeros (TREE_INT_CST_LOW (size_tree
));
1522 #ifdef XCOFF_DEBUGGING_INFO
1523 /* Unfortunately, the IBM assembler cannot handle stabx before the actual
1524 declaration. When something like ".stabx "aa:S-2",aa,133,0" is emitted
1525 and `aa' hasn't been output yet, the assembler generates a stab entry with
1526 a value of zero, in addition to creating an unnecessary external entry
1527 for `aa'. Hence, we must postpone dbxout_symbol to here at the end. */
1529 /* File-scope global variables are output here. */
1530 if (write_symbols
== XCOFF_DEBUG
&& top_level
)
1532 saved_in_section
= in_section
;
1534 dbxout_symbol (decl
, 0);
1536 if (in_section
!= saved_in_section
)
1537 variable_section (decl
, reloc
);
1540 /* There must be a statement after a label. */
1545 /* Return 1 if type TYPE contains any pointers. */
1548 contains_pointers_p (type
)
1551 switch (TREE_CODE (type
))
1554 case REFERENCE_TYPE
:
1555 /* I'm not sure whether OFFSET_TYPE needs this treatment,
1556 so I'll play safe and return 1. */
1562 case QUAL_UNION_TYPE
:
1565 /* For a type that has fields, see if the fields have pointers. */
1566 for (fields
= TYPE_FIELDS (type
); fields
; fields
= TREE_CHAIN (fields
))
1567 if (TREE_CODE (fields
) == FIELD_DECL
1568 && contains_pointers_p (TREE_TYPE (fields
)))
1574 /* An array type contains pointers if its element type does. */
1575 return contains_pointers_p (TREE_TYPE (type
));
1582 /* Output something to declare an external symbol to the assembler.
1583 (Most assemblers don't need this, so we normally output nothing.)
1584 Do nothing if DECL is not external. */
1587 assemble_external (decl
)
1590 #ifdef ASM_OUTPUT_EXTERNAL
1591 if (TREE_CODE_CLASS (TREE_CODE (decl
)) == 'd'
1592 && DECL_EXTERNAL (decl
) && TREE_PUBLIC (decl
))
1594 rtx rtl
= DECL_RTL (decl
);
1596 if (GET_CODE (rtl
) == MEM
&& GET_CODE (XEXP (rtl
, 0)) == SYMBOL_REF
1597 && ! SYMBOL_REF_USED (XEXP (rtl
, 0)))
1599 /* Some systems do require some output. */
1600 SYMBOL_REF_USED (XEXP (rtl
, 0)) = 1;
1601 ASM_OUTPUT_EXTERNAL (asm_out_file
, decl
, XSTR (XEXP (rtl
, 0), 0));
1607 /* Similar, for calling a library function FUN. */
1610 assemble_external_libcall (fun
)
1611 rtx fun ATTRIBUTE_UNUSED
;
1613 #ifdef ASM_OUTPUT_EXTERNAL_LIBCALL
1614 /* Declare library function name external when first used, if nec. */
1615 if (! SYMBOL_REF_USED (fun
))
1617 SYMBOL_REF_USED (fun
) = 1;
1618 ASM_OUTPUT_EXTERNAL_LIBCALL (asm_out_file
, fun
);
1623 /* Declare the label NAME global. */
1626 assemble_global (name
)
1629 ASM_GLOBALIZE_LABEL (asm_out_file
, name
);
1632 /* Assemble a label named NAME. */
1635 assemble_label (name
)
1638 ASM_OUTPUT_LABEL (asm_out_file
, name
);
1641 /* Output to FILE a reference to the assembler name of a C-level name NAME.
1642 If NAME starts with a *, the rest of NAME is output verbatim.
1643 Otherwise NAME is transformed in an implementation-defined way
1644 (usually by the addition of an underscore).
1645 Many macros in the tm file are defined to call this function. */
1648 assemble_name (file
, name
)
1655 STRIP_NAME_ENCODING (real_name
, name
);
1656 if (flag_prefix_function_name
1657 && ! bcmp (real_name
, CHKR_PREFIX
, CHKR_PREFIX_SIZE
))
1658 real_name
= real_name
+ CHKR_PREFIX_SIZE
;
1660 id
= maybe_get_identifier (real_name
);
1662 TREE_SYMBOL_REFERENCED (id
) = 1;
1665 fputs (&name
[1], file
);
1667 ASM_OUTPUT_LABELREF (file
, name
);
1670 /* Allocate SIZE bytes writable static space with a gensym name
1671 and return an RTX to refer to its address. */
1674 assemble_static_space (size
)
1682 if (flag_shared_data
)
1686 ASM_GENERATE_INTERNAL_LABEL (name
, "LF", const_labelno
);
1689 namestring
= (char *) obstack_alloc (saveable_obstack
,
1691 strcpy (namestring
, name
);
1693 x
= gen_rtx_SYMBOL_REF (Pmode
, namestring
);
1695 #ifdef ASM_OUTPUT_ALIGNED_DECL_LOCAL
1696 ASM_OUTPUT_ALIGNED_DECL_LOCAL (asm_out_file
, NULL_TREE
, name
, size
,
1699 #ifdef ASM_OUTPUT_ALIGNED_LOCAL
1700 ASM_OUTPUT_ALIGNED_LOCAL (asm_out_file
, name
, size
, BIGGEST_ALIGNMENT
);
1703 /* Round size up to multiple of BIGGEST_ALIGNMENT bits
1704 so that each uninitialized object starts on such a boundary. */
1705 int rounded
= ((size
+ (BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
) - 1)
1706 / (BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
)
1707 * (BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
));
1708 ASM_OUTPUT_LOCAL (asm_out_file
, name
, size
, rounded
);
1715 /* Assemble the static constant template for function entry trampolines.
1716 This is done at most once per compilation.
1717 Returns an RTX for the address of the template. */
1719 #ifdef TRAMPOLINE_TEMPLATE
1721 assemble_trampoline_template ()
1727 /* By default, put trampoline templates in read-only data section. */
1729 #ifdef TRAMPOLINE_SECTION
1730 TRAMPOLINE_SECTION ();
1732 readonly_data_section ();
1735 /* Write the assembler code to define one. */
1736 align
= floor_log2 (TRAMPOLINE_ALIGNMENT
/ BITS_PER_UNIT
);
1738 ASM_OUTPUT_ALIGN (asm_out_file
, align
);
1740 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, "LTRAMP", 0);
1741 TRAMPOLINE_TEMPLATE (asm_out_file
);
1743 /* Record the rtl to refer to it. */
1744 ASM_GENERATE_INTERNAL_LABEL (label
, "LTRAMP", 0);
1746 = (char *) obstack_copy0 (&permanent_obstack
, label
, strlen (label
));
1747 return gen_rtx_SYMBOL_REF (Pmode
, name
);
1751 /* Assemble the integer constant X into an object of SIZE bytes.
1752 X must be either a CONST_INT or CONST_DOUBLE.
1754 Return 1 if we were able to output the constant, otherwise 0. If FORCE is
1755 non-zero, abort if we can't output the constant. */
1758 assemble_integer (x
, size
, force
)
1763 /* First try to use the standard 1, 2, 4, 8, and 16 byte
1764 ASM_OUTPUT... macros. */
1768 #ifdef ASM_OUTPUT_CHAR
1770 ASM_OUTPUT_CHAR (asm_out_file
, x
);
1774 #ifdef ASM_OUTPUT_SHORT
1776 ASM_OUTPUT_SHORT (asm_out_file
, x
);
1780 #ifdef ASM_OUTPUT_INT
1782 ASM_OUTPUT_INT (asm_out_file
, x
);
1786 #ifdef ASM_OUTPUT_DOUBLE_INT
1788 ASM_OUTPUT_DOUBLE_INT (asm_out_file
, x
);
1792 #ifdef ASM_OUTPUT_QUADRUPLE_INT
1794 ASM_OUTPUT_QUADRUPLE_INT (asm_out_file
, x
);
1799 /* If we couldn't do it that way, there are two other possibilities: First,
1800 if the machine can output an explicit byte and this is a 1 byte constant,
1801 we can use ASM_OUTPUT_BYTE. */
1803 #ifdef ASM_OUTPUT_BYTE
1804 if (size
== 1 && GET_CODE (x
) == CONST_INT
)
1806 ASM_OUTPUT_BYTE (asm_out_file
, INTVAL (x
));
1811 /* Finally, if SIZE is larger than a single word, try to output the constant
1812 one word at a time. */
1814 if (size
> UNITS_PER_WORD
)
1817 enum machine_mode mode
1818 = mode_for_size (size
* BITS_PER_UNIT
, MODE_INT
, 0);
1821 for (i
= 0; i
< size
/ UNITS_PER_WORD
; i
++)
1823 word
= operand_subword (x
, i
, 0, mode
);
1828 if (! assemble_integer (word
, UNITS_PER_WORD
, 0))
1832 if (i
== size
/ UNITS_PER_WORD
)
1834 /* If we output at least one word and then could not finish,
1835 there is no valid way to continue. */
1846 /* Assemble the floating-point constant D into an object of size MODE. */
1849 assemble_real (d
, mode
)
1851 enum machine_mode mode
;
1853 jmp_buf output_constant_handler
;
1855 if (setjmp (output_constant_handler
))
1857 error ("floating point trap outputting a constant");
1858 #ifdef REAL_IS_NOT_DOUBLE
1859 bzero ((char *) &d
, sizeof d
);
1866 set_float_handler (output_constant_handler
);
1870 #ifdef ASM_OUTPUT_BYTE_FLOAT
1872 ASM_OUTPUT_BYTE_FLOAT (asm_out_file
, d
);
1875 #ifdef ASM_OUTPUT_SHORT_FLOAT
1877 ASM_OUTPUT_SHORT_FLOAT (asm_out_file
, d
);
1880 #ifdef ASM_OUTPUT_THREE_QUARTER_FLOAT
1882 ASM_OUTPUT_THREE_QUARTER_FLOAT (asm_out_file
, d
);
1885 #ifdef ASM_OUTPUT_FLOAT
1887 ASM_OUTPUT_FLOAT (asm_out_file
, d
);
1891 #ifdef ASM_OUTPUT_DOUBLE
1893 ASM_OUTPUT_DOUBLE (asm_out_file
, d
);
1897 #ifdef ASM_OUTPUT_LONG_DOUBLE
1900 ASM_OUTPUT_LONG_DOUBLE (asm_out_file
, d
);
1908 set_float_handler (NULL_PTR
);
1911 /* Here we combine duplicate floating constants to make
1912 CONST_DOUBLE rtx's, and force those out to memory when necessary. */
1914 /* Chain of all CONST_DOUBLE rtx's constructed for the current function.
1915 They are chained through the CONST_DOUBLE_CHAIN.
1916 A CONST_DOUBLE rtx has CONST_DOUBLE_MEM != cc0_rtx iff it is on this chain.
1917 In that case, CONST_DOUBLE_MEM is either a MEM,
1918 or const0_rtx if no MEM has been made for this CONST_DOUBLE yet.
1920 (CONST_DOUBLE_MEM is used only for top-level functions.
1921 See force_const_mem for explanation.) */
1923 static rtx const_double_chain
;
1925 /* Return a CONST_DOUBLE or CONST_INT for a value specified as a pair of ints.
1926 For an integer, I0 is the low-order word and I1 is the high-order word.
1927 For a real number, I0 is the word with the low address
1928 and I1 is the word with the high address. */
1931 immed_double_const (i0
, i1
, mode
)
1932 HOST_WIDE_INT i0
, i1
;
1933 enum machine_mode mode
;
1937 if (GET_MODE_CLASS (mode
) == MODE_INT
1938 || GET_MODE_CLASS (mode
) == MODE_PARTIAL_INT
)
1940 /* We clear out all bits that don't belong in MODE, unless they and our
1941 sign bit are all one. So we get either a reasonable negative value
1942 or a reasonable unsigned value for this mode. */
1943 int width
= GET_MODE_BITSIZE (mode
);
1944 if (width
< HOST_BITS_PER_WIDE_INT
1945 && ((i0
& ((HOST_WIDE_INT
) (-1) << (width
- 1)))
1946 != ((HOST_WIDE_INT
) (-1) << (width
- 1))))
1947 i0
&= ((HOST_WIDE_INT
) 1 << width
) - 1, i1
= 0;
1948 else if (width
== HOST_BITS_PER_WIDE_INT
1949 && ! (i1
== ~0 && i0
< 0))
1951 else if (width
> 2 * HOST_BITS_PER_WIDE_INT
)
1952 /* We cannot represent this value as a constant. */
1955 /* If this would be an entire word for the target, but is not for
1956 the host, then sign-extend on the host so that the number will look
1957 the same way on the host that it would on the target.
1959 For example, when building a 64 bit alpha hosted 32 bit sparc
1960 targeted compiler, then we want the 32 bit unsigned value -1 to be
1961 represented as a 64 bit value -1, and not as 0x00000000ffffffff.
1962 The later confuses the sparc backend. */
1964 if (BITS_PER_WORD
< HOST_BITS_PER_WIDE_INT
&& BITS_PER_WORD
== width
1965 && (i0
& ((HOST_WIDE_INT
) 1 << (width
- 1))))
1966 i0
|= ((HOST_WIDE_INT
) (-1) << width
);
1968 /* If MODE fits within HOST_BITS_PER_WIDE_INT, always use a CONST_INT.
1970 ??? Strictly speaking, this is wrong if we create a CONST_INT
1971 for a large unsigned constant with the size of MODE being
1972 HOST_BITS_PER_WIDE_INT and later try to interpret that constant in a
1973 wider mode. In that case we will mis-interpret it as a negative
1976 Unfortunately, the only alternative is to make a CONST_DOUBLE
1977 for any constant in any mode if it is an unsigned constant larger
1978 than the maximum signed integer in an int on the host. However,
1979 doing this will break everyone that always expects to see a CONST_INT
1980 for SImode and smaller.
1982 We have always been making CONST_INTs in this case, so nothing new
1985 if (width
<= HOST_BITS_PER_WIDE_INT
)
1986 i1
= (i0
< 0) ? ~(HOST_WIDE_INT
) 0 : 0;
1988 /* If this integer fits in one word, return a CONST_INT. */
1989 if ((i1
== 0 && i0
>= 0)
1990 || (i1
== ~0 && i0
< 0))
1991 return GEN_INT (i0
);
1993 /* We use VOIDmode for integers. */
1997 /* Search the chain for an existing CONST_DOUBLE with the right value.
1998 If one is found, return it. */
2000 for (r
= const_double_chain
; r
; r
= CONST_DOUBLE_CHAIN (r
))
2001 if (CONST_DOUBLE_LOW (r
) == i0
&& CONST_DOUBLE_HIGH (r
) == i1
2002 && GET_MODE (r
) == mode
)
2005 /* No; make a new one and add it to the chain.
2007 We may be called by an optimizer which may be discarding any memory
2008 allocated during its processing (such as combine and loop). However,
2009 we will be leaving this constant on the chain, so we cannot tolerate
2010 freed memory. So switch to saveable_obstack for this allocation
2011 and then switch back if we were in current_obstack. */
2013 push_obstacks_nochange ();
2014 rtl_in_saveable_obstack ();
2015 r
= gen_rtx_CONST_DOUBLE (mode
, NULL_RTX
, i0
, i1
);
2018 /* Don't touch const_double_chain in nested function; see force_const_mem.
2019 Also, don't touch it if not inside any function. */
2020 if (outer_function_chain
== 0 && current_function_decl
!= 0)
2022 CONST_DOUBLE_CHAIN (r
) = const_double_chain
;
2023 const_double_chain
= r
;
2026 /* Store const0_rtx in mem-slot since this CONST_DOUBLE is on the chain.
2027 Actual use of mem-slot is only through force_const_mem. */
2029 CONST_DOUBLE_MEM (r
) = const0_rtx
;
2034 /* Return a CONST_DOUBLE for a specified `double' value
2035 and machine mode. */
2038 immed_real_const_1 (d
, mode
)
2040 enum machine_mode mode
;
2042 union real_extract u
;
2045 /* Get the desired `double' value as a sequence of ints
2046 since that is how they are stored in a CONST_DOUBLE. */
2050 /* Detect special cases. */
2052 if (REAL_VALUES_IDENTICAL (dconst0
, d
))
2053 return CONST0_RTX (mode
);
2054 /* Check for NaN first, because some ports (specifically the i386) do not
2055 emit correct ieee-fp code by default, and thus will generate a core
2056 dump here if we pass a NaN to REAL_VALUES_EQUAL and if REAL_VALUES_EQUAL
2057 does a floating point comparison. */
2058 else if (! REAL_VALUE_ISNAN (d
) && REAL_VALUES_EQUAL (dconst1
, d
))
2059 return CONST1_RTX (mode
);
2061 if (sizeof u
== sizeof (HOST_WIDE_INT
))
2062 return immed_double_const (u
.i
[0], 0, mode
);
2063 if (sizeof u
== 2 * sizeof (HOST_WIDE_INT
))
2064 return immed_double_const (u
.i
[0], u
.i
[1], mode
);
2066 /* The rest of this function handles the case where
2067 a float value requires more than 2 ints of space.
2068 It will be deleted as dead code on machines that don't need it. */
2070 /* Search the chain for an existing CONST_DOUBLE with the right value.
2071 If one is found, return it. */
2073 for (r
= const_double_chain
; r
; r
= CONST_DOUBLE_CHAIN (r
))
2074 if (! bcmp ((char *) &CONST_DOUBLE_LOW (r
), (char *) &u
, sizeof u
)
2075 && GET_MODE (r
) == mode
)
2078 /* No; make a new one and add it to the chain.
2080 We may be called by an optimizer which may be discarding any memory
2081 allocated during its processing (such as combine and loop). However,
2082 we will be leaving this constant on the chain, so we cannot tolerate
2083 freed memory. So switch to saveable_obstack for this allocation
2084 and then switch back if we were in current_obstack. */
2086 push_obstacks_nochange ();
2087 rtl_in_saveable_obstack ();
2088 r
= rtx_alloc (CONST_DOUBLE
);
2090 bcopy ((char *) &u
, (char *) &CONST_DOUBLE_LOW (r
), sizeof u
);
2093 /* Don't touch const_double_chain in nested function; see force_const_mem.
2094 Also, don't touch it if not inside any function. */
2095 if (outer_function_chain
== 0 && current_function_decl
!= 0)
2097 CONST_DOUBLE_CHAIN (r
) = const_double_chain
;
2098 const_double_chain
= r
;
2101 /* Store const0_rtx in CONST_DOUBLE_MEM since this CONST_DOUBLE is on the
2102 chain, but has not been allocated memory. Actual use of CONST_DOUBLE_MEM
2103 is only through force_const_mem. */
2105 CONST_DOUBLE_MEM (r
) = const0_rtx
;
2110 /* Return a CONST_DOUBLE rtx for a value specified by EXP,
2111 which must be a REAL_CST tree node. */
2114 immed_real_const (exp
)
2117 return immed_real_const_1 (TREE_REAL_CST (exp
), TYPE_MODE (TREE_TYPE (exp
)));
2120 /* At the end of a function, forget the memory-constants
2121 previously made for CONST_DOUBLEs. Mark them as not on real_constant_chain.
2122 Also clear out real_constant_chain and clear out all the chain-pointers. */
2125 clear_const_double_mem ()
2127 register rtx r
, next
;
2129 /* Don't touch CONST_DOUBLE_MEM for nested functions.
2130 See force_const_mem for explanation. */
2131 if (outer_function_chain
!= 0)
2134 for (r
= const_double_chain
; r
; r
= next
)
2136 next
= CONST_DOUBLE_CHAIN (r
);
2137 CONST_DOUBLE_CHAIN (r
) = 0;
2138 CONST_DOUBLE_MEM (r
) = cc0_rtx
;
2140 const_double_chain
= 0;
2143 /* Given an expression EXP with a constant value,
2144 reduce it to the sum of an assembler symbol and an integer.
2145 Store them both in the structure *VALUE.
2146 Abort if EXP does not reduce. */
2151 HOST_WIDE_INT offset
;
2155 decode_addr_const (exp
, value
)
2157 struct addr_const
*value
;
2159 register tree target
= TREE_OPERAND (exp
, 0);
2160 register int offset
= 0;
2165 if (TREE_CODE (target
) == COMPONENT_REF
2166 && (TREE_CODE (DECL_FIELD_BITPOS (TREE_OPERAND (target
, 1)))
2169 offset
+= TREE_INT_CST_LOW (DECL_FIELD_BITPOS (TREE_OPERAND (target
, 1))) / BITS_PER_UNIT
;
2170 target
= TREE_OPERAND (target
, 0);
2172 else if (TREE_CODE (target
) == ARRAY_REF
)
2174 if (TREE_CODE (TREE_OPERAND (target
, 1)) != INTEGER_CST
2175 || TREE_CODE (TYPE_SIZE (TREE_TYPE (target
))) != INTEGER_CST
)
2177 offset
+= ((TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (target
)))
2178 * TREE_INT_CST_LOW (TREE_OPERAND (target
, 1)))
2180 target
= TREE_OPERAND (target
, 0);
2186 switch (TREE_CODE (target
))
2190 x
= DECL_RTL (target
);
2194 x
= gen_rtx_MEM (FUNCTION_MODE
,
2195 gen_rtx_LABEL_REF (VOIDmode
,
2196 label_rtx (TREE_OPERAND (exp
, 0))));
2204 x
= TREE_CST_RTL (target
);
2211 if (GET_CODE (x
) != MEM
)
2216 value
->offset
= offset
;
2219 /* Uniquize all constants that appear in memory.
2220 Each constant in memory thus far output is recorded
2221 in `const_hash_table' with a `struct constant_descriptor'
2222 that contains a polish representation of the value of
2225 We cannot store the trees in the hash table
2226 because the trees may be temporary. */
2228 struct constant_descriptor
2230 struct constant_descriptor
*next
;
2236 #define MAX_HASH_TABLE 1009
2237 static struct constant_descriptor
*const_hash_table
[MAX_HASH_TABLE
];
2239 /* Compute a hash code for a constant expression. */
2246 register int len
, hi
, i
;
2247 register enum tree_code code
= TREE_CODE (exp
);
2249 /* Either set P and LEN to the address and len of something to hash and
2250 exit the switch or return a value. */
2255 p
= (char *) &TREE_INT_CST_LOW (exp
);
2256 len
= 2 * sizeof TREE_INT_CST_LOW (exp
);
2260 p
= (char *) &TREE_REAL_CST (exp
);
2261 len
= sizeof TREE_REAL_CST (exp
);
2265 p
= TREE_STRING_POINTER (exp
);
2266 len
= TREE_STRING_LENGTH (exp
);
2270 return (const_hash (TREE_REALPART (exp
)) * 5
2271 + const_hash (TREE_IMAGPART (exp
)));
2274 if (TREE_CODE (TREE_TYPE (exp
)) == SET_TYPE
)
2276 len
= int_size_in_bytes (TREE_TYPE (exp
));
2277 p
= (char *) alloca (len
);
2278 get_set_constructor_bytes (exp
, (unsigned char *) p
, len
);
2285 /* For record type, include the type in the hashing.
2286 We do not do so for array types
2287 because (1) the sizes of the elements are sufficient
2288 and (2) distinct array types can have the same constructor.
2289 Instead, we include the array size because the constructor could
2291 if (TREE_CODE (TREE_TYPE (exp
)) == RECORD_TYPE
)
2292 hi
= ((unsigned long) TREE_TYPE (exp
) & ((1 << HASHBITS
) - 1))
2295 hi
= ((5 + int_size_in_bytes (TREE_TYPE (exp
)))
2296 & ((1 << HASHBITS
) - 1)) % MAX_HASH_TABLE
;
2298 for (link
= CONSTRUCTOR_ELTS (exp
); link
; link
= TREE_CHAIN (link
))
2299 if (TREE_VALUE (link
))
2301 = (hi
* 603 + const_hash (TREE_VALUE (link
))) % MAX_HASH_TABLE
;
2308 struct addr_const value
;
2310 decode_addr_const (exp
, &value
);
2311 if (GET_CODE (value
.base
) == SYMBOL_REF
)
2313 /* Don't hash the address of the SYMBOL_REF;
2314 only use the offset and the symbol name. */
2316 p
= XSTR (value
.base
, 0);
2317 for (i
= 0; p
[i
] != 0; i
++)
2318 hi
= ((hi
* 613) + (unsigned) (p
[i
]));
2320 else if (GET_CODE (value
.base
) == LABEL_REF
)
2321 hi
= value
.offset
+ CODE_LABEL_NUMBER (XEXP (value
.base
, 0)) * 13;
2323 hi
&= (1 << HASHBITS
) - 1;
2324 hi
%= MAX_HASH_TABLE
;
2330 return (const_hash (TREE_OPERAND (exp
, 0)) * 9
2331 + const_hash (TREE_OPERAND (exp
, 1)));
2335 case NON_LVALUE_EXPR
:
2336 return const_hash (TREE_OPERAND (exp
, 0)) * 7 + 2;
2342 /* Compute hashing function */
2344 for (i
= 0; i
< len
; i
++)
2345 hi
= ((hi
* 613) + (unsigned) (p
[i
]));
2347 hi
&= (1 << HASHBITS
) - 1;
2348 hi
%= MAX_HASH_TABLE
;
2352 /* Compare a constant expression EXP with a constant-descriptor DESC.
2353 Return 1 if DESC describes a constant with the same value as EXP. */
2356 compare_constant (exp
, desc
)
2358 struct constant_descriptor
*desc
;
2360 return 0 != compare_constant_1 (exp
, desc
->contents
);
2363 /* Compare constant expression EXP with a substring P of a constant descriptor.
2364 If they match, return a pointer to the end of the substring matched.
2365 If they do not match, return 0.
2367 Since descriptors are written in polish prefix notation,
2368 this function can be used recursively to test one operand of EXP
2369 against a subdescriptor, and if it succeeds it returns the
2370 address of the subdescriptor for the next operand. */
2373 compare_constant_1 (exp
, p
)
2377 register char *strp
;
2379 register enum tree_code code
= TREE_CODE (exp
);
2381 if (code
!= (enum tree_code
) *p
++)
2384 /* Either set STRP, P and LEN to pointers and length to compare and exit the
2385 switch, or return the result of the comparison. */
2390 /* Integer constants are the same only if the same width of type. */
2391 if (*p
++ != TYPE_PRECISION (TREE_TYPE (exp
)))
2394 strp
= (char *) &TREE_INT_CST_LOW (exp
);
2395 len
= 2 * sizeof TREE_INT_CST_LOW (exp
);
2399 /* Real constants are the same only if the same width of type. */
2400 if (*p
++ != TYPE_PRECISION (TREE_TYPE (exp
)))
2403 strp
= (char *) &TREE_REAL_CST (exp
);
2404 len
= sizeof TREE_REAL_CST (exp
);
2408 if (flag_writable_strings
)
2411 if (*p
++ != TYPE_MODE (TREE_TYPE (exp
)))
2414 strp
= TREE_STRING_POINTER (exp
);
2415 len
= TREE_STRING_LENGTH (exp
);
2416 if (bcmp ((char *) &TREE_STRING_LENGTH (exp
), p
,
2417 sizeof TREE_STRING_LENGTH (exp
)))
2420 p
+= sizeof TREE_STRING_LENGTH (exp
);
2424 p
= compare_constant_1 (TREE_REALPART (exp
), p
);
2428 return compare_constant_1 (TREE_IMAGPART (exp
), p
);
2431 if (TREE_CODE (TREE_TYPE (exp
)) == SET_TYPE
)
2433 int xlen
= len
= int_size_in_bytes (TREE_TYPE (exp
));
2435 strp
= (char *) alloca (len
);
2436 get_set_constructor_bytes (exp
, (unsigned char *) strp
, len
);
2437 if (bcmp ((char *) &xlen
, p
, sizeof xlen
))
2446 int length
= list_length (CONSTRUCTOR_ELTS (exp
));
2448 int have_purpose
= 0;
2450 for (link
= CONSTRUCTOR_ELTS (exp
); link
; link
= TREE_CHAIN (link
))
2451 if (TREE_PURPOSE (link
))
2454 if (bcmp ((char *) &length
, p
, sizeof length
))
2459 /* For record constructors, insist that the types match.
2460 For arrays, just verify both constructors are for arrays.
2461 Then insist that either both or none have any TREE_PURPOSE
2463 if (TREE_CODE (TREE_TYPE (exp
)) == RECORD_TYPE
)
2464 type
= TREE_TYPE (exp
);
2468 if (bcmp ((char *) &type
, p
, sizeof type
))
2473 if (bcmp ((char *) &have_purpose
, p
, sizeof have_purpose
))
2476 p
+= sizeof have_purpose
;
2478 /* For arrays, insist that the size in bytes match. */
2479 if (TREE_CODE (TREE_TYPE (exp
)) == ARRAY_TYPE
)
2481 HOST_WIDE_INT size
= int_size_in_bytes (TREE_TYPE (exp
));
2483 if (bcmp ((char *) &size
, p
, sizeof size
))
2489 for (link
= CONSTRUCTOR_ELTS (exp
); link
; link
= TREE_CHAIN (link
))
2491 if (TREE_VALUE (link
))
2493 if ((p
= compare_constant_1 (TREE_VALUE (link
), p
)) == 0)
2500 if (bcmp ((char *) &zero
, p
, sizeof zero
))
2506 if (TREE_PURPOSE (link
)
2507 && TREE_CODE (TREE_PURPOSE (link
)) == FIELD_DECL
)
2509 if (bcmp ((char *) &TREE_PURPOSE (link
), p
,
2510 sizeof TREE_PURPOSE (link
)))
2513 p
+= sizeof TREE_PURPOSE (link
);
2515 else if (TREE_PURPOSE (link
))
2517 if ((p
= compare_constant_1 (TREE_PURPOSE (link
), p
)) == 0)
2520 else if (have_purpose
)
2524 if (bcmp ((char *) &zero
, p
, sizeof zero
))
2536 struct addr_const value
;
2538 decode_addr_const (exp
, &value
);
2539 strp
= (char *) &value
.offset
;
2540 len
= sizeof value
.offset
;
2541 /* Compare the offset. */
2543 if (*p
++ != *strp
++)
2546 /* Compare symbol name. */
2547 strp
= XSTR (value
.base
, 0);
2548 len
= strlen (strp
) + 1;
2555 p
= compare_constant_1 (TREE_OPERAND (exp
, 0), p
);
2559 return compare_constant_1 (TREE_OPERAND (exp
, 1), p
);
2563 case NON_LVALUE_EXPR
:
2564 return compare_constant_1 (TREE_OPERAND (exp
, 0), p
);
2570 /* Compare constant contents. */
2572 if (*p
++ != *strp
++)
2578 /* Construct a constant descriptor for the expression EXP.
2579 It is up to the caller to enter the descriptor in the hash table. */
2581 static struct constant_descriptor
*
2582 record_constant (exp
)
2585 struct constant_descriptor
*next
= 0;
2588 /* Make a struct constant_descriptor. The first two pointers will
2589 be filled in later. Here we just leave space for them. */
2591 obstack_grow (&permanent_obstack
, (char *) &next
, sizeof next
);
2592 obstack_grow (&permanent_obstack
, (char *) &label
, sizeof label
);
2593 record_constant_1 (exp
);
2594 return (struct constant_descriptor
*) obstack_finish (&permanent_obstack
);
2597 /* Add a description of constant expression EXP
2598 to the object growing in `permanent_obstack'.
2599 No need to return its address; the caller will get that
2600 from the obstack when the object is complete. */
2603 record_constant_1 (exp
)
2606 register char *strp
;
2608 register enum tree_code code
= TREE_CODE (exp
);
2610 obstack_1grow (&permanent_obstack
, (unsigned int) code
);
2615 obstack_1grow (&permanent_obstack
, TYPE_PRECISION (TREE_TYPE (exp
)));
2616 strp
= (char *) &TREE_INT_CST_LOW (exp
);
2617 len
= 2 * sizeof TREE_INT_CST_LOW (exp
);
2621 obstack_1grow (&permanent_obstack
, TYPE_PRECISION (TREE_TYPE (exp
)));
2622 strp
= (char *) &TREE_REAL_CST (exp
);
2623 len
= sizeof TREE_REAL_CST (exp
);
2627 if (flag_writable_strings
)
2630 obstack_1grow (&permanent_obstack
, TYPE_MODE (TREE_TYPE (exp
)));
2631 strp
= TREE_STRING_POINTER (exp
);
2632 len
= TREE_STRING_LENGTH (exp
);
2633 obstack_grow (&permanent_obstack
, (char *) &TREE_STRING_LENGTH (exp
),
2634 sizeof TREE_STRING_LENGTH (exp
));
2638 record_constant_1 (TREE_REALPART (exp
));
2639 record_constant_1 (TREE_IMAGPART (exp
));
2643 if (TREE_CODE (TREE_TYPE (exp
)) == SET_TYPE
)
2645 int nbytes
= int_size_in_bytes (TREE_TYPE (exp
));
2646 obstack_grow (&permanent_obstack
, &nbytes
, sizeof (nbytes
));
2647 obstack_blank (&permanent_obstack
, nbytes
);
2648 get_set_constructor_bytes
2649 (exp
, (unsigned char *) permanent_obstack
.next_free
-nbytes
,
2656 int length
= list_length (CONSTRUCTOR_ELTS (exp
));
2658 int have_purpose
= 0;
2660 for (link
= CONSTRUCTOR_ELTS (exp
); link
; link
= TREE_CHAIN (link
))
2661 if (TREE_PURPOSE (link
))
2664 obstack_grow (&permanent_obstack
, (char *) &length
, sizeof length
);
2666 /* For record constructors, insist that the types match.
2667 For arrays, just verify both constructors are for arrays.
2668 Then insist that either both or none have any TREE_PURPOSE
2670 if (TREE_CODE (TREE_TYPE (exp
)) == RECORD_TYPE
)
2671 type
= TREE_TYPE (exp
);
2674 obstack_grow (&permanent_obstack
, (char *) &type
, sizeof type
);
2675 obstack_grow (&permanent_obstack
, (char *) &have_purpose
,
2676 sizeof have_purpose
);
2678 /* For arrays, insist that the size in bytes match. */
2679 if (TREE_CODE (TREE_TYPE (exp
)) == ARRAY_TYPE
)
2681 HOST_WIDE_INT size
= int_size_in_bytes (TREE_TYPE (exp
));
2682 obstack_grow (&permanent_obstack
, (char *) &size
, sizeof size
);
2685 for (link
= CONSTRUCTOR_ELTS (exp
); link
; link
= TREE_CHAIN (link
))
2687 if (TREE_VALUE (link
))
2688 record_constant_1 (TREE_VALUE (link
));
2693 obstack_grow (&permanent_obstack
,
2694 (char *) &zero
, sizeof zero
);
2697 if (TREE_PURPOSE (link
)
2698 && TREE_CODE (TREE_PURPOSE (link
)) == FIELD_DECL
)
2699 obstack_grow (&permanent_obstack
,
2700 (char *) &TREE_PURPOSE (link
),
2701 sizeof TREE_PURPOSE (link
));
2702 else if (TREE_PURPOSE (link
))
2703 record_constant_1 (TREE_PURPOSE (link
));
2704 else if (have_purpose
)
2708 obstack_grow (&permanent_obstack
,
2709 (char *) &zero
, sizeof zero
);
2717 struct addr_const value
;
2719 decode_addr_const (exp
, &value
);
2720 /* Record the offset. */
2721 obstack_grow (&permanent_obstack
,
2722 (char *) &value
.offset
, sizeof value
.offset
);
2723 /* Record the symbol name. */
2724 obstack_grow (&permanent_obstack
, XSTR (value
.base
, 0),
2725 strlen (XSTR (value
.base
, 0)) + 1);
2732 record_constant_1 (TREE_OPERAND (exp
, 0));
2733 record_constant_1 (TREE_OPERAND (exp
, 1));
2738 case NON_LVALUE_EXPR
:
2739 record_constant_1 (TREE_OPERAND (exp
, 0));
2746 /* Record constant contents. */
2747 obstack_grow (&permanent_obstack
, strp
, len
);
2750 /* Record a list of constant expressions that were passed to
2751 output_constant_def but that could not be output right away. */
2753 struct deferred_constant
2755 struct deferred_constant
*next
;
2761 static struct deferred_constant
*deferred_constants
;
2763 /* Another list of constants which should be output after the
2765 static struct deferred_constant
*after_function_constants
;
2767 /* Nonzero means defer output of addressed subconstants
2768 (i.e., those for which output_constant_def is called.) */
2769 static int defer_addressed_constants_flag
;
2771 /* Start deferring output of subconstants. */
2774 defer_addressed_constants ()
2776 defer_addressed_constants_flag
++;
2779 /* Stop deferring output of subconstants,
2780 and output now all those that have been deferred. */
2783 output_deferred_addressed_constants ()
2785 struct deferred_constant
*p
, *next
;
2787 defer_addressed_constants_flag
--;
2789 if (defer_addressed_constants_flag
> 0)
2792 for (p
= deferred_constants
; p
; p
= next
)
2794 output_constant_def_contents (p
->exp
, p
->reloc
, p
->labelno
);
2799 deferred_constants
= 0;
2802 /* Output any constants which should appear after a function. */
2805 output_after_function_constants ()
2807 struct deferred_constant
*p
, *next
;
2809 for (p
= after_function_constants
; p
; p
= next
)
2811 output_constant_def_contents (p
->exp
, p
->reloc
, p
->labelno
);
2816 after_function_constants
= 0;
2819 /* Make a copy of the whole tree structure for a constant.
2820 This handles the same types of nodes that compare_constant
2821 and record_constant handle. */
2827 switch (TREE_CODE (exp
))
2830 /* For ADDR_EXPR, we do not want to copy the decl whose address
2831 is requested. We do want to copy constants though. */
2832 if (TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp
, 0))) == 'c')
2833 return build1 (TREE_CODE (exp
), TREE_TYPE (exp
),
2834 copy_constant (TREE_OPERAND (exp
, 0)));
2836 return copy_node (exp
);
2841 return copy_node (exp
);
2844 return build_complex (TREE_TYPE (exp
),
2845 copy_constant (TREE_REALPART (exp
)),
2846 copy_constant (TREE_IMAGPART (exp
)));
2850 return build (TREE_CODE (exp
), TREE_TYPE (exp
),
2851 copy_constant (TREE_OPERAND (exp
, 0)),
2852 copy_constant (TREE_OPERAND (exp
, 1)));
2856 case NON_LVALUE_EXPR
:
2857 return build1 (TREE_CODE (exp
), TREE_TYPE (exp
),
2858 copy_constant (TREE_OPERAND (exp
, 0)));
2862 tree copy
= copy_node (exp
);
2863 tree list
= copy_list (CONSTRUCTOR_ELTS (exp
));
2866 CONSTRUCTOR_ELTS (copy
) = list
;
2867 for (tail
= list
; tail
; tail
= TREE_CHAIN (tail
))
2868 TREE_VALUE (tail
) = copy_constant (TREE_VALUE (tail
));
2869 if (TREE_CODE (TREE_TYPE (exp
)) == SET_TYPE
)
2870 for (tail
= list
; tail
; tail
= TREE_CHAIN (tail
))
2871 TREE_PURPOSE (tail
) = copy_constant (TREE_PURPOSE (tail
));
2881 /* Return an rtx representing a reference to constant data in memory
2882 for the constant expression EXP.
2884 If assembler code for such a constant has already been output,
2885 return an rtx to refer to it.
2886 Otherwise, output such a constant in memory (or defer it for later)
2887 and generate an rtx for it.
2889 The TREE_CST_RTL of EXP is set up to point to that rtx.
2890 The const_hash_table records which constants already have label strings. */
2893 output_constant_def (exp
)
2897 register struct constant_descriptor
*desc
;
2903 if (TREE_CST_RTL (exp
))
2904 return TREE_CST_RTL (exp
);
2906 /* Make sure any other constants whose addresses appear in EXP
2907 are assigned label numbers. */
2909 reloc
= output_addressed_constants (exp
);
2911 /* Compute hash code of EXP. Search the descriptors for that hash code
2912 to see if any of them describes EXP. If yes, the descriptor records
2913 the label number already assigned. */
2915 hash
= const_hash (exp
) % MAX_HASH_TABLE
;
2917 for (desc
= const_hash_table
[hash
]; desc
; desc
= desc
->next
)
2918 if (compare_constant (exp
, desc
))
2920 found
= desc
->label
;
2926 /* No constant equal to EXP is known to have been output.
2927 Make a constant descriptor to enter EXP in the hash table.
2928 Assign the label number and record it in the descriptor for
2929 future calls to this function to find. */
2931 /* Create a string containing the label name, in LABEL. */
2932 ASM_GENERATE_INTERNAL_LABEL (label
, "LC", const_labelno
);
2934 desc
= record_constant (exp
);
2935 desc
->next
= const_hash_table
[hash
];
2937 = (char *) obstack_copy0 (&permanent_obstack
, label
, strlen (label
));
2938 const_hash_table
[hash
] = desc
;
2942 /* Create a string containing the label name, in LABEL. */
2943 ASM_GENERATE_INTERNAL_LABEL (label
, "LC", const_labelno
);
2946 /* We have a symbol name; construct the SYMBOL_REF and the MEM. */
2948 push_obstacks_nochange ();
2949 if (TREE_PERMANENT (exp
))
2950 end_temporary_allocation ();
2952 def
= gen_rtx_SYMBOL_REF (Pmode
, desc
->label
);
2955 = gen_rtx_MEM (TYPE_MODE (TREE_TYPE (exp
)), def
);
2956 RTX_UNCHANGING_P (TREE_CST_RTL (exp
)) = 1;
2957 if (AGGREGATE_TYPE_P (TREE_TYPE (exp
)))
2958 MEM_IN_STRUCT_P (TREE_CST_RTL (exp
)) = 1;
2962 /* Optionally set flags or add text to the name to record information
2963 such as that it is a function name. If the name is changed, the macro
2964 ASM_OUTPUT_LABELREF will have to know how to strip this information. */
2965 #ifdef ENCODE_SECTION_INFO
2966 ENCODE_SECTION_INFO (exp
);
2969 /* If this is the first time we've seen this particular constant,
2970 output it (or defer its output for later). */
2973 int after_function
= 0;
2975 #ifdef CONSTANT_AFTER_FUNCTION_P
2976 if (current_function_decl
!= 0
2977 && CONSTANT_AFTER_FUNCTION_P (exp
))
2981 if (defer_addressed_constants_flag
|| after_function
)
2983 struct deferred_constant
*p
;
2984 p
= (struct deferred_constant
*) xmalloc (sizeof (struct deferred_constant
));
2986 push_obstacks_nochange ();
2987 suspend_momentary ();
2988 p
->exp
= copy_constant (exp
);
2991 p
->labelno
= const_labelno
++;
2994 p
->next
= after_function_constants
;
2995 after_function_constants
= p
;
2999 p
->next
= deferred_constants
;
3000 deferred_constants
= p
;
3004 output_constant_def_contents (exp
, reloc
, const_labelno
++);
3007 return TREE_CST_RTL (exp
);
3010 /* Now output assembler code to define the label for EXP,
3011 and follow it with the data of EXP. */
3014 output_constant_def_contents (exp
, reloc
, labelno
)
3021 if (IN_NAMED_SECTION (exp
))
3022 named_section (exp
, NULL
, reloc
);
3025 /* First switch to text section, except for writable strings. */
3026 #ifdef SELECT_SECTION
3027 SELECT_SECTION (exp
, reloc
);
3029 if (((TREE_CODE (exp
) == STRING_CST
) && flag_writable_strings
)
3030 || (flag_pic
&& reloc
))
3033 readonly_data_section ();
3037 /* Align the location counter as required by EXP's data type. */
3038 align
= TYPE_ALIGN (TREE_TYPE (exp
));
3039 #ifdef CONSTANT_ALIGNMENT
3040 align
= CONSTANT_ALIGNMENT (exp
, align
);
3043 if (align
> BITS_PER_UNIT
)
3044 ASM_OUTPUT_ALIGN (asm_out_file
, floor_log2 (align
/ BITS_PER_UNIT
));
3046 /* Output the label itself. */
3047 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, "LC", labelno
);
3049 /* Output the value of EXP. */
3050 output_constant (exp
,
3051 (TREE_CODE (exp
) == STRING_CST
3052 ? TREE_STRING_LENGTH (exp
)
3053 : int_size_in_bytes (TREE_TYPE (exp
))));
3057 /* Similar hash facility for making memory-constants
3058 from constant rtl-expressions. It is used on RISC machines
3059 where immediate integer arguments and constant addresses are restricted
3060 so that such constants must be stored in memory.
3062 This pool of constants is reinitialized for each function
3063 so each function gets its own constants-pool that comes right before it.
3065 All structures allocated here are discarded when functions are saved for
3066 inlining, so they do not need to be allocated permanently. */
3068 #define MAX_RTX_HASH_TABLE 61
3069 static struct constant_descriptor
**const_rtx_hash_table
;
3071 /* Structure to represent sufficient information about a constant so that
3072 it can be output when the constant pool is output, so that function
3073 integration can be done, and to simplify handling on machines that reference
3074 constant pool as base+displacement. */
3076 struct pool_constant
3078 struct constant_descriptor
*desc
;
3079 struct pool_constant
*next
;
3080 enum machine_mode mode
;
3088 /* Pointers to first and last constant in pool. */
3090 static struct pool_constant
*first_pool
, *last_pool
;
3092 /* Current offset in constant pool (does not include any machine-specific
3095 static int pool_offset
;
3097 /* Structure used to maintain hash table mapping symbols used to their
3098 corresponding constants. */
3103 struct pool_constant
*pool
;
3104 struct pool_sym
*next
;
3107 static struct pool_sym
**const_rtx_sym_hash_table
;
3109 /* Hash code for a SYMBOL_REF with CONSTANT_POOL_ADDRESS_P true.
3110 The argument is XSTR (... , 0) */
3112 #define SYMHASH(LABEL) \
3113 ((((unsigned long) (LABEL)) & ((1 << HASHBITS) - 1)) % MAX_RTX_HASH_TABLE)
3115 /* Initialize constant pool hashing for next function. */
3118 init_const_rtx_hash_table ()
3120 const_rtx_hash_table
3121 = ((struct constant_descriptor
**)
3122 oballoc (MAX_RTX_HASH_TABLE
* sizeof (struct constant_descriptor
*)));
3123 const_rtx_sym_hash_table
3124 = ((struct pool_sym
**)
3125 oballoc (MAX_RTX_HASH_TABLE
* sizeof (struct pool_sym
*)));
3126 bzero ((char *) const_rtx_hash_table
,
3127 MAX_RTX_HASH_TABLE
* sizeof (struct constant_descriptor
*));
3128 bzero ((char *) const_rtx_sym_hash_table
,
3129 MAX_RTX_HASH_TABLE
* sizeof (struct pool_sym
*));
3131 first_pool
= last_pool
= 0;
3135 /* Save and restore status for a nested function. */
3138 save_varasm_status (p
, context
)
3142 p
->const_rtx_hash_table
= const_rtx_hash_table
;
3143 p
->const_rtx_sym_hash_table
= const_rtx_sym_hash_table
;
3144 p
->first_pool
= first_pool
;
3145 p
->last_pool
= last_pool
;
3146 p
->pool_offset
= pool_offset
;
3147 p
->const_double_chain
= const_double_chain
;
3149 /* If we are pushing to toplevel, we can't reuse const_double_chain. */
3150 if (context
== NULL_TREE
)
3151 const_double_chain
= 0;
3155 restore_varasm_status (p
)
3158 const_rtx_hash_table
= p
->const_rtx_hash_table
;
3159 const_rtx_sym_hash_table
= p
->const_rtx_sym_hash_table
;
3160 first_pool
= p
->first_pool
;
3161 last_pool
= p
->last_pool
;
3162 pool_offset
= p
->pool_offset
;
3163 const_double_chain
= p
->const_double_chain
;
3166 enum kind
{ RTX_DOUBLE
, RTX_INT
};
3170 #ifdef ONLY_INT_FIELDS
3171 unsigned int kind
: 16;
3172 unsigned int mode
: 16;
3174 enum kind kind
: 16;
3175 enum machine_mode mode
: 16;
3178 union real_extract du
;
3179 struct addr_const addr
;
3180 struct {HOST_WIDE_INT high
, low
;} di
;
3184 /* Express an rtx for a constant integer (perhaps symbolic)
3185 as the sum of a symbol or label plus an explicit integer.
3186 They are stored into VALUE. */
3189 decode_rtx_const (mode
, x
, value
)
3190 enum machine_mode mode
;
3192 struct rtx_const
*value
;
3194 /* Clear the whole structure, including any gaps. */
3197 int *p
= (int *) value
;
3198 int *end
= (int *) (value
+ 1);
3203 value
->kind
= RTX_INT
; /* Most usual kind. */
3206 switch (GET_CODE (x
))
3209 value
->kind
= RTX_DOUBLE
;
3210 if (GET_MODE (x
) != VOIDmode
)
3212 value
->mode
= GET_MODE (x
);
3213 bcopy ((char *) &CONST_DOUBLE_LOW (x
),
3214 (char *) &value
->un
.du
, sizeof value
->un
.du
);
3218 value
->un
.di
.low
= CONST_DOUBLE_LOW (x
);
3219 value
->un
.di
.high
= CONST_DOUBLE_HIGH (x
);
3224 value
->un
.addr
.offset
= INTVAL (x
);
3230 value
->un
.addr
.base
= x
;
3235 if (GET_CODE (x
) == PLUS
)
3237 value
->un
.addr
.base
= XEXP (x
, 0);
3238 if (GET_CODE (XEXP (x
, 1)) != CONST_INT
)
3240 value
->un
.addr
.offset
= INTVAL (XEXP (x
, 1));
3242 else if (GET_CODE (x
) == MINUS
)
3244 value
->un
.addr
.base
= XEXP (x
, 0);
3245 if (GET_CODE (XEXP (x
, 1)) != CONST_INT
)
3247 value
->un
.addr
.offset
= - INTVAL (XEXP (x
, 1));
3257 if (value
->kind
== RTX_INT
&& value
->un
.addr
.base
!= 0)
3258 switch (GET_CODE (value
->un
.addr
.base
))
3262 /* Use the string's address, not the SYMBOL_REF's address,
3263 for the sake of addresses of library routines.
3264 For a LABEL_REF, compare labels. */
3265 value
->un
.addr
.base
= XEXP (value
->un
.addr
.base
, 0);
3272 /* Given a MINUS expression, simplify it if both sides
3273 include the same symbol. */
3276 simplify_subtraction (x
)
3279 struct rtx_const val0
, val1
;
3281 decode_rtx_const (GET_MODE (x
), XEXP (x
, 0), &val0
);
3282 decode_rtx_const (GET_MODE (x
), XEXP (x
, 1), &val1
);
3284 if (val0
.un
.addr
.base
== val1
.un
.addr
.base
)
3285 return GEN_INT (val0
.un
.addr
.offset
- val1
.un
.addr
.offset
);
3289 /* Compute a hash code for a constant RTL expression. */
3292 const_hash_rtx (mode
, x
)
3293 enum machine_mode mode
;
3299 struct rtx_const value
;
3300 decode_rtx_const (mode
, x
, &value
);
3302 /* Compute hashing function */
3304 for (i
= 0; i
< sizeof value
/ sizeof (int); i
++)
3305 hi
+= ((int *) &value
)[i
];
3307 hi
&= (1 << HASHBITS
) - 1;
3308 hi
%= MAX_RTX_HASH_TABLE
;
3312 /* Compare a constant rtl object X with a constant-descriptor DESC.
3313 Return 1 if DESC describes a constant with the same value as X. */
3316 compare_constant_rtx (mode
, x
, desc
)
3317 enum machine_mode mode
;
3319 struct constant_descriptor
*desc
;
3321 register int *p
= (int *) desc
->contents
;
3324 struct rtx_const value
;
3326 decode_rtx_const (mode
, x
, &value
);
3327 strp
= (int *) &value
;
3328 len
= sizeof value
/ sizeof (int);
3330 /* Compare constant contents. */
3332 if (*p
++ != *strp
++)
3338 /* Construct a constant descriptor for the rtl-expression X.
3339 It is up to the caller to enter the descriptor in the hash table. */
3341 static struct constant_descriptor
*
3342 record_constant_rtx (mode
, x
)
3343 enum machine_mode mode
;
3346 struct constant_descriptor
*ptr
;
3348 struct rtx_const value
;
3350 decode_rtx_const (mode
, x
, &value
);
3352 /* Put these things in the saveable obstack so we can ensure it won't
3353 be freed if we are called from combine or some other phase that discards
3354 memory allocated from function_obstack (current_obstack). */
3355 obstack_grow (saveable_obstack
, &ptr
, sizeof ptr
);
3356 obstack_grow (saveable_obstack
, &label
, sizeof label
);
3358 /* Record constant contents. */
3359 obstack_grow (saveable_obstack
, &value
, sizeof value
);
3361 return (struct constant_descriptor
*) obstack_finish (saveable_obstack
);
3364 /* Given a constant rtx X, make (or find) a memory constant for its value
3365 and return a MEM rtx to refer to it in memory. */
3368 force_const_mem (mode
, x
)
3369 enum machine_mode mode
;
3373 register struct constant_descriptor
*desc
;
3378 /* If we want this CONST_DOUBLE in the same mode as it is in memory
3379 (this will always be true for floating CONST_DOUBLEs that have been
3380 placed in memory, but not for VOIDmode (integer) CONST_DOUBLEs),
3381 use the previous copy. Otherwise, make a new one. Note that in
3382 the unlikely event that this same CONST_DOUBLE is used in two different
3383 modes in an alternating fashion, we will allocate a lot of different
3384 memory locations, but this should be extremely rare. */
3386 /* Don't use CONST_DOUBLE_MEM in a nested function.
3387 Nested functions have their own constant pools,
3388 so they can't share the same values in CONST_DOUBLE_MEM
3389 with the containing function. */
3390 if (outer_function_chain
== 0)
3391 if (GET_CODE (x
) == CONST_DOUBLE
3392 && GET_CODE (CONST_DOUBLE_MEM (x
)) == MEM
3393 && GET_MODE (CONST_DOUBLE_MEM (x
)) == mode
)
3394 return CONST_DOUBLE_MEM (x
);
3396 /* Compute hash code of X. Search the descriptors for that hash code
3397 to see if any of them describes X. If yes, the descriptor records
3398 the label number already assigned. */
3400 hash
= const_hash_rtx (mode
, x
);
3402 for (desc
= const_rtx_hash_table
[hash
]; desc
; desc
= desc
->next
)
3403 if (compare_constant_rtx (mode
, x
, desc
))
3405 found
= desc
->label
;
3411 register struct pool_constant
*pool
;
3412 register struct pool_sym
*sym
;
3415 /* No constant equal to X is known to have been output.
3416 Make a constant descriptor to enter X in the hash table.
3417 Assign the label number and record it in the descriptor for
3418 future calls to this function to find. */
3420 desc
= record_constant_rtx (mode
, x
);
3421 desc
->next
= const_rtx_hash_table
[hash
];
3422 const_rtx_hash_table
[hash
] = desc
;
3424 /* Align the location counter as required by EXP's data type. */
3425 align
= (mode
== VOIDmode
) ? UNITS_PER_WORD
: GET_MODE_SIZE (mode
);
3426 if (align
> BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
)
3427 align
= BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
;
3428 #ifdef CONSTANT_ALIGNMENT
3429 align
= CONSTANT_ALIGNMENT (make_tree (type_for_mode (mode
, 0), x
),
3430 align
* BITS_PER_UNIT
) / BITS_PER_UNIT
;
3433 pool_offset
+= align
- 1;
3434 pool_offset
&= ~ (align
- 1);
3436 /* If RTL is not being placed into the saveable obstack, make a
3437 copy of X that is in the saveable obstack in case we are
3438 being called from combine or some other phase that discards
3439 memory it allocates. We used to only do this if it is a
3440 CONST; however, reload can allocate a CONST_INT when
3441 eliminating registers. */
3442 if (rtl_obstack
!= saveable_obstack
3443 && (GET_CODE (x
) == CONST
|| GET_CODE (x
) == CONST_INT
))
3445 push_obstacks_nochange ();
3446 rtl_in_saveable_obstack ();
3448 if (GET_CODE (x
) == CONST
)
3449 x
= gen_rtx_CONST (GET_MODE (x
),
3450 gen_rtx_PLUS (GET_MODE (x
),
3451 XEXP (XEXP (x
, 0), 0),
3452 XEXP (XEXP (x
, 0), 1)));
3454 x
= GEN_INT (INTVAL (x
));
3459 /* Allocate a pool constant descriptor, fill it in, and chain it in. */
3461 pool
= (struct pool_constant
*) savealloc (sizeof (struct pool_constant
));
3465 pool
->labelno
= const_labelno
;
3466 pool
->align
= align
;
3467 pool
->offset
= pool_offset
;
3474 last_pool
->next
= pool
;
3477 pool_offset
+= GET_MODE_SIZE (mode
);
3479 /* Create a string containing the label name, in LABEL. */
3480 ASM_GENERATE_INTERNAL_LABEL (label
, "LC", const_labelno
);
3485 = (char *) obstack_copy0 (saveable_obstack
, label
, strlen (label
));
3487 /* Add label to symbol hash table. */
3488 hash
= SYMHASH (found
);
3489 sym
= (struct pool_sym
*) savealloc (sizeof (struct pool_sym
));
3492 sym
->next
= const_rtx_sym_hash_table
[hash
];
3493 const_rtx_sym_hash_table
[hash
] = sym
;
3496 /* We have a symbol name; construct the SYMBOL_REF and the MEM. */
3498 def
= gen_rtx_MEM (mode
, gen_rtx_SYMBOL_REF (Pmode
, found
));
3500 RTX_UNCHANGING_P (def
) = 1;
3501 /* Mark the symbol_ref as belonging to this constants pool. */
3502 CONSTANT_POOL_ADDRESS_P (XEXP (def
, 0)) = 1;
3503 current_function_uses_const_pool
= 1;
3505 if (outer_function_chain
== 0)
3506 if (GET_CODE (x
) == CONST_DOUBLE
)
3508 if (CONST_DOUBLE_MEM (x
) == cc0_rtx
)
3510 CONST_DOUBLE_CHAIN (x
) = const_double_chain
;
3511 const_double_chain
= x
;
3513 CONST_DOUBLE_MEM (x
) = def
;
3519 /* Given a SYMBOL_REF with CONSTANT_POOL_ADDRESS_P true, return a pointer to
3520 the corresponding pool_constant structure. */
3522 static struct pool_constant
*
3523 find_pool_constant (addr
)
3526 struct pool_sym
*sym
;
3527 char *label
= XSTR (addr
, 0);
3529 for (sym
= const_rtx_sym_hash_table
[SYMHASH (label
)]; sym
; sym
= sym
->next
)
3530 if (sym
->label
== label
)
3536 /* Given a constant pool SYMBOL_REF, return the corresponding constant. */
3539 get_pool_constant (addr
)
3542 return (find_pool_constant (addr
))->constant
;
3545 /* Similar, return the mode. */
3548 get_pool_mode (addr
)
3551 return (find_pool_constant (addr
))->mode
;
3554 /* Similar, return the offset in the constant pool. */
3557 get_pool_offset (addr
)
3560 return (find_pool_constant (addr
))->offset
;
3563 /* Return the size of the constant pool. */
3571 /* Write all the constants in the constant pool. */
3574 output_constant_pool (fnname
, fndecl
)
3575 char *fnname ATTRIBUTE_UNUSED
;
3576 tree fndecl ATTRIBUTE_UNUSED
;
3578 struct pool_constant
*pool
;
3580 union real_extract u
;
3582 /* It is possible for gcc to call force_const_mem and then to later
3583 discard the instructions which refer to the constant. In such a
3584 case we do not need to output the constant. */
3585 if (optimize
>= 0 && flag_expensive_optimizations
)
3586 mark_constant_pool ();
3588 #ifdef ASM_OUTPUT_POOL_PROLOGUE
3589 ASM_OUTPUT_POOL_PROLOGUE (asm_out_file
, fnname
, fndecl
, pool_offset
);
3592 for (pool
= first_pool
; pool
; pool
= pool
->next
)
3599 /* See if X is a LABEL_REF (or a CONST referring to a LABEL_REF)
3600 whose CODE_LABEL has been deleted. This can occur if a jump table
3601 is eliminated by optimization. If so, write a constant of zero
3602 instead. Note that this can also happen by turning the
3603 CODE_LABEL into a NOTE. */
3604 if (((GET_CODE (x
) == LABEL_REF
3605 && (INSN_DELETED_P (XEXP (x
, 0))
3606 || GET_CODE (XEXP (x
, 0)) == NOTE
)))
3607 || (GET_CODE (x
) == CONST
&& GET_CODE (XEXP (x
, 0)) == PLUS
3608 && GET_CODE (XEXP (XEXP (x
, 0), 0)) == LABEL_REF
3609 && (INSN_DELETED_P (XEXP (XEXP (XEXP (x
, 0), 0), 0))
3610 || GET_CODE (XEXP (XEXP (XEXP (x
, 0), 0), 0)) == NOTE
)))
3613 /* First switch to correct section. */
3614 #ifdef SELECT_RTX_SECTION
3615 SELECT_RTX_SECTION (pool
->mode
, x
);
3617 readonly_data_section ();
3620 #ifdef ASM_OUTPUT_SPECIAL_POOL_ENTRY
3621 ASM_OUTPUT_SPECIAL_POOL_ENTRY (asm_out_file
, x
, pool
->mode
,
3622 pool
->align
, pool
->labelno
, done
);
3625 if (pool
->align
> 1)
3626 ASM_OUTPUT_ALIGN (asm_out_file
, exact_log2 (pool
->align
));
3628 /* Output the label. */
3629 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, "LC", pool
->labelno
);
3631 /* Output the value of the constant itself. */
3632 switch (GET_MODE_CLASS (pool
->mode
))
3635 if (GET_CODE (x
) != CONST_DOUBLE
)
3638 bcopy ((char *) &CONST_DOUBLE_LOW (x
), (char *) &u
, sizeof u
);
3639 assemble_real (u
.d
, pool
->mode
);
3643 case MODE_PARTIAL_INT
:
3644 assemble_integer (x
, GET_MODE_SIZE (pool
->mode
), 1);
3651 #ifdef ASM_OUTPUT_SPECIAL_POOL_ENTRY
3657 #ifdef ASM_OUTPUT_POOL_EPILOGUE
3658 ASM_OUTPUT_POOL_EPILOGUE (asm_out_file
, fnname
, fndecl
, pool_offset
);
3661 /* Done with this pool. */
3662 first_pool
= last_pool
= 0;
3665 /* Look through the instructions for this function, and mark all the
3666 entries in the constant pool which are actually being used. */
3669 mark_constant_pool ()
3672 struct pool_constant
*pool
;
3674 if (first_pool
== 0)
3677 for (pool
= first_pool
; pool
; pool
= pool
->next
)
3680 for (insn
= get_insns (); insn
; insn
= NEXT_INSN (insn
))
3681 if (GET_RTX_CLASS (GET_CODE (insn
)) == 'i')
3682 mark_constants (PATTERN (insn
));
3684 for (insn
= current_function_epilogue_delay_list
;
3686 insn
= XEXP (insn
, 1))
3687 if (GET_RTX_CLASS (GET_CODE (insn
)) == 'i')
3688 mark_constants (PATTERN (insn
));
3696 register char *format_ptr
;
3701 if (GET_CODE (x
) == SYMBOL_REF
)
3703 if (CONSTANT_POOL_ADDRESS_P (x
))
3704 find_pool_constant (x
)->mark
= 1;
3707 /* Never search inside a CONST_DOUBLE, because CONST_DOUBLE_MEM may be
3708 a MEM, but does not constitute a use of that MEM. This is particularly
3709 important inside a nested function, because CONST_DOUBLE_MEM may be
3710 a reference to a MEM in the parent's constant pool. See the comment
3711 in force_const_mem. */
3712 else if (GET_CODE (x
) == CONST_DOUBLE
)
3715 /* Insns may appear inside a SEQUENCE. Only check the patterns of
3716 insns, not any notes that may be attached. We don't want to mark
3717 a constant just because it happens to appear in a REG_EQUIV note. */
3718 if (GET_RTX_CLASS (GET_CODE (x
)) == 'i')
3720 mark_constants (PATTERN (x
));
3724 format_ptr
= GET_RTX_FORMAT (GET_CODE (x
));
3726 for (i
= 0; i
< GET_RTX_LENGTH (GET_CODE (x
)); i
++)
3728 switch (*format_ptr
++)
3731 mark_constants (XEXP (x
, i
));
3735 if (XVEC (x
, i
) != 0)
3739 for (j
= 0; j
< XVECLEN (x
, i
); j
++)
3740 mark_constants (XVECEXP (x
, i
, j
));
3759 /* Find all the constants whose addresses are referenced inside of EXP,
3760 and make sure assembler code with a label has been output for each one.
3761 Indicate whether an ADDR_EXPR has been encountered. */
3764 output_addressed_constants (exp
)
3769 switch (TREE_CODE (exp
))
3773 register tree constant
= TREE_OPERAND (exp
, 0);
3775 while (TREE_CODE (constant
) == COMPONENT_REF
)
3777 constant
= TREE_OPERAND (constant
, 0);
3780 if (TREE_CODE_CLASS (TREE_CODE (constant
)) == 'c'
3781 || TREE_CODE (constant
) == CONSTRUCTOR
)
3782 /* No need to do anything here
3783 for addresses of variables or functions. */
3784 output_constant_def (constant
);
3791 reloc
= output_addressed_constants (TREE_OPERAND (exp
, 0));
3792 reloc
|= output_addressed_constants (TREE_OPERAND (exp
, 1));
3797 case NON_LVALUE_EXPR
:
3798 reloc
= output_addressed_constants (TREE_OPERAND (exp
, 0));
3804 for (link
= CONSTRUCTOR_ELTS (exp
); link
; link
= TREE_CHAIN (link
))
3805 if (TREE_VALUE (link
) != 0)
3806 reloc
|= output_addressed_constants (TREE_VALUE (link
));
3816 /* Output assembler code for constant EXP to FILE, with no label.
3817 This includes the pseudo-op such as ".int" or ".byte", and a newline.
3818 Assumes output_addressed_constants has been done on EXP already.
3820 Generate exactly SIZE bytes of assembler data, padding at the end
3821 with zeros if necessary. SIZE must always be specified.
3823 SIZE is important for structure constructors,
3824 since trailing members may have been omitted from the constructor.
3825 It is also important for initialization of arrays from string constants
3826 since the full length of the string constant might not be wanted.
3827 It is also needed for initialization of unions, where the initializer's
3828 type is just one member, and that may not be as long as the union.
3830 There a case in which we would fail to output exactly SIZE bytes:
3831 for a structure constructor that wants to produce more than SIZE bytes.
3832 But such constructors will never be generated for any possible input. */
3835 output_constant (exp
, size
)
3839 register enum tree_code code
= TREE_CODE (TREE_TYPE (exp
));
3844 /* Eliminate the NON_LVALUE_EXPR_EXPR that makes a cast not be an lvalue.
3845 That way we get the constant (we hope) inside it. Also, strip off any
3846 NOP_EXPR that converts between two record, union, array, or set types. */
3847 while ((TREE_CODE (exp
) == NOP_EXPR
3848 && (TREE_TYPE (exp
) == TREE_TYPE (TREE_OPERAND (exp
, 0))
3849 || AGGREGATE_TYPE_P (TREE_TYPE (exp
))))
3850 || TREE_CODE (exp
) == NON_LVALUE_EXPR
)
3851 exp
= TREE_OPERAND (exp
, 0);
3853 /* Allow a constructor with no elements for any data type.
3854 This means to fill the space with zeros. */
3855 if (TREE_CODE (exp
) == CONSTRUCTOR
&& CONSTRUCTOR_ELTS (exp
) == 0)
3857 assemble_zeros (size
);
3868 case REFERENCE_TYPE
:
3869 /* ??? What about (int)((float)(int)&foo + 4) */
3870 while (TREE_CODE (exp
) == NOP_EXPR
|| TREE_CODE (exp
) == CONVERT_EXPR
3871 || TREE_CODE (exp
) == NON_LVALUE_EXPR
)
3872 exp
= TREE_OPERAND (exp
, 0);
3874 if (! assemble_integer (expand_expr (exp
, NULL_RTX
, VOIDmode
,
3875 EXPAND_INITIALIZER
),
3877 error ("initializer for integer value is too complicated");
3882 if (TREE_CODE (exp
) != REAL_CST
)
3883 error ("initializer for floating value is not a floating constant");
3885 assemble_real (TREE_REAL_CST (exp
),
3886 mode_for_size (size
* BITS_PER_UNIT
, MODE_FLOAT
, 0));
3891 output_constant (TREE_REALPART (exp
), size
/ 2);
3892 output_constant (TREE_IMAGPART (exp
), size
/ 2);
3893 size
-= (size
/ 2) * 2;
3897 if (TREE_CODE (exp
) == CONSTRUCTOR
)
3899 output_constructor (exp
, size
);
3902 else if (TREE_CODE (exp
) == STRING_CST
)
3906 if (size
> TREE_STRING_LENGTH (exp
))
3908 excess
= size
- TREE_STRING_LENGTH (exp
);
3909 size
= TREE_STRING_LENGTH (exp
);
3912 assemble_string (TREE_STRING_POINTER (exp
), size
);
3921 if (TREE_CODE (exp
) == CONSTRUCTOR
)
3922 output_constructor (exp
, size
);
3928 if (TREE_CODE (exp
) == INTEGER_CST
)
3929 assemble_integer (expand_expr (exp
, NULL_RTX
,
3930 VOIDmode
, EXPAND_INITIALIZER
),
3932 else if (TREE_CODE (exp
) == CONSTRUCTOR
)
3934 unsigned char *buffer
= (unsigned char *) alloca (size
);
3935 if (get_set_constructor_bytes (exp
, buffer
, size
))
3937 assemble_string ((char *) buffer
, size
);
3940 error ("unknown set constructor type");
3948 assemble_zeros (size
);
3952 /* Subroutine of output_constant, used for CONSTRUCTORs
3953 (aggregate constants).
3954 Generate at least SIZE bytes, padding if necessary. */
3957 output_constructor (exp
, size
)
3961 register tree link
, field
= 0;
3962 HOST_WIDE_INT min_index
= 0;
3963 /* Number of bytes output or skipped so far.
3964 In other words, current position within the constructor. */
3965 int total_bytes
= 0;
3966 /* Non-zero means BYTE contains part of a byte, to be output. */
3967 int byte_buffer_in_use
= 0;
3970 if (HOST_BITS_PER_WIDE_INT
< BITS_PER_UNIT
)
3973 if (TREE_CODE (TREE_TYPE (exp
)) == RECORD_TYPE
)
3974 field
= TYPE_FIELDS (TREE_TYPE (exp
));
3976 if (TREE_CODE (TREE_TYPE (exp
)) == ARRAY_TYPE
3977 && TYPE_DOMAIN (TREE_TYPE (exp
)) != 0)
3979 = TREE_INT_CST_LOW (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (exp
))));
3981 /* As LINK goes through the elements of the constant,
3982 FIELD goes through the structure fields, if the constant is a structure.
3983 if the constant is a union, then we override this,
3984 by getting the field from the TREE_LIST element.
3985 But the constant could also be an array. Then FIELD is zero. */
3986 for (link
= CONSTRUCTOR_ELTS (exp
);
3988 link
= TREE_CHAIN (link
),
3989 field
= field
? TREE_CHAIN (field
) : 0)
3991 tree val
= TREE_VALUE (link
);
3994 /* the element in a union constructor specifies the proper field. */
3996 if (TREE_CODE (TREE_TYPE (exp
)) == RECORD_TYPE
3997 || TREE_CODE (TREE_TYPE (exp
)) == UNION_TYPE
)
3999 /* if available, use the type given by link */
4000 if (TREE_PURPOSE (link
) != 0)
4001 field
= TREE_PURPOSE (link
);
4004 if (TREE_CODE (TREE_TYPE (exp
)) == ARRAY_TYPE
)
4005 index
= TREE_PURPOSE (link
);
4007 /* Eliminate the marker that makes a cast not be an lvalue. */
4011 if (index
&& TREE_CODE (index
) == RANGE_EXPR
)
4013 register int fieldsize
4014 = int_size_in_bytes (TREE_TYPE (TREE_TYPE (exp
)));
4015 HOST_WIDE_INT lo_index
= TREE_INT_CST_LOW (TREE_OPERAND (index
, 0));
4016 HOST_WIDE_INT hi_index
= TREE_INT_CST_LOW (TREE_OPERAND (index
, 1));
4017 HOST_WIDE_INT index
;
4018 for (index
= lo_index
; index
<= hi_index
; index
++)
4020 /* Output the element's initial value. */
4022 assemble_zeros (fieldsize
);
4024 output_constant (val
, fieldsize
);
4026 /* Count its size. */
4027 total_bytes
+= fieldsize
;
4030 else if (field
== 0 || !DECL_BIT_FIELD (field
))
4032 /* An element that is not a bit-field. */
4034 register int fieldsize
;
4035 /* Since this structure is static,
4036 we know the positions are constant. */
4037 int bitpos
= (field
? (TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field
))
4041 bitpos
= (TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (val
)))
4043 * (TREE_INT_CST_LOW (index
) - min_index
));
4045 /* Output any buffered-up bit-fields preceding this element. */
4046 if (byte_buffer_in_use
)
4048 ASM_OUTPUT_BYTE (asm_out_file
, byte
);
4050 byte_buffer_in_use
= 0;
4053 /* Advance to offset of this element.
4054 Note no alignment needed in an array, since that is guaranteed
4055 if each element has the proper size. */
4056 if ((field
!= 0 || index
!= 0) && bitpos
!= total_bytes
)
4058 assemble_zeros (bitpos
- total_bytes
);
4059 total_bytes
= bitpos
;
4062 /* Determine size this element should occupy. */
4065 if (TREE_CODE (DECL_SIZE (field
)) != INTEGER_CST
)
4067 if (TREE_INT_CST_LOW (DECL_SIZE (field
)) > 100000)
4069 /* This avoids overflow trouble. */
4070 tree size_tree
= size_binop (CEIL_DIV_EXPR
,
4072 size_int (BITS_PER_UNIT
));
4073 fieldsize
= TREE_INT_CST_LOW (size_tree
);
4077 fieldsize
= TREE_INT_CST_LOW (DECL_SIZE (field
));
4078 fieldsize
= (fieldsize
+ BITS_PER_UNIT
- 1) / BITS_PER_UNIT
;
4082 fieldsize
= int_size_in_bytes (TREE_TYPE (TREE_TYPE (exp
)));
4084 /* Output the element's initial value. */
4086 assemble_zeros (fieldsize
);
4088 output_constant (val
, fieldsize
);
4090 /* Count its size. */
4091 total_bytes
+= fieldsize
;
4093 else if (val
!= 0 && TREE_CODE (val
) != INTEGER_CST
)
4094 error ("invalid initial value for member `%s'",
4095 IDENTIFIER_POINTER (DECL_NAME (field
)));
4098 /* Element that is a bit-field. */
4100 int next_offset
= TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field
));
4102 = (next_offset
+ TREE_INT_CST_LOW (DECL_SIZE (field
)));
4105 val
= integer_zero_node
;
4107 /* If this field does not start in this (or, next) byte,
4109 if (next_offset
/ BITS_PER_UNIT
!= total_bytes
)
4111 /* Output remnant of any bit field in previous bytes. */
4112 if (byte_buffer_in_use
)
4114 ASM_OUTPUT_BYTE (asm_out_file
, byte
);
4116 byte_buffer_in_use
= 0;
4119 /* If still not at proper byte, advance to there. */
4120 if (next_offset
/ BITS_PER_UNIT
!= total_bytes
)
4122 assemble_zeros (next_offset
/ BITS_PER_UNIT
- total_bytes
);
4123 total_bytes
= next_offset
/ BITS_PER_UNIT
;
4127 if (! byte_buffer_in_use
)
4130 /* We must split the element into pieces that fall within
4131 separate bytes, and combine each byte with previous or
4132 following bit-fields. */
4134 /* next_offset is the offset n fbits from the beginning of
4135 the structure to the next bit of this element to be processed.
4136 end_offset is the offset of the first bit past the end of
4138 while (next_offset
< end_offset
)
4142 HOST_WIDE_INT value
;
4143 int next_byte
= next_offset
/ BITS_PER_UNIT
;
4144 int next_bit
= next_offset
% BITS_PER_UNIT
;
4146 /* Advance from byte to byte
4147 within this element when necessary. */
4148 while (next_byte
!= total_bytes
)
4150 ASM_OUTPUT_BYTE (asm_out_file
, byte
);
4155 /* Number of bits we can process at once
4156 (all part of the same byte). */
4157 this_time
= MIN (end_offset
- next_offset
,
4158 BITS_PER_UNIT
- next_bit
);
4159 if (BYTES_BIG_ENDIAN
)
4161 /* On big-endian machine, take the most significant bits
4162 first (of the bits that are significant)
4163 and put them into bytes from the most significant end. */
4164 shift
= end_offset
- next_offset
- this_time
;
4165 /* Don't try to take a bunch of bits that cross
4166 the word boundary in the INTEGER_CST. */
4167 if (shift
< HOST_BITS_PER_WIDE_INT
4168 && shift
+ this_time
> HOST_BITS_PER_WIDE_INT
)
4170 this_time
-= (HOST_BITS_PER_WIDE_INT
- shift
);
4171 shift
= HOST_BITS_PER_WIDE_INT
;
4174 /* Now get the bits from the appropriate constant word. */
4175 if (shift
< HOST_BITS_PER_WIDE_INT
)
4177 value
= TREE_INT_CST_LOW (val
);
4179 else if (shift
< 2 * HOST_BITS_PER_WIDE_INT
)
4181 value
= TREE_INT_CST_HIGH (val
);
4182 shift
-= HOST_BITS_PER_WIDE_INT
;
4186 byte
|= (((value
>> shift
)
4187 & (((HOST_WIDE_INT
) 1 << this_time
) - 1))
4188 << (BITS_PER_UNIT
- this_time
- next_bit
));
4192 /* On little-endian machines,
4193 take first the least significant bits of the value
4194 and pack them starting at the least significant
4195 bits of the bytes. */
4196 shift
= (next_offset
4197 - TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field
)));
4198 /* Don't try to take a bunch of bits that cross
4199 the word boundary in the INTEGER_CST. */
4200 if (shift
< HOST_BITS_PER_WIDE_INT
4201 && shift
+ this_time
> HOST_BITS_PER_WIDE_INT
)
4203 this_time
-= (HOST_BITS_PER_WIDE_INT
- shift
);
4204 shift
= HOST_BITS_PER_WIDE_INT
;
4207 /* Now get the bits from the appropriate constant word. */
4208 if (shift
< HOST_BITS_PER_WIDE_INT
)
4209 value
= TREE_INT_CST_LOW (val
);
4210 else if (shift
< 2 * HOST_BITS_PER_WIDE_INT
)
4212 value
= TREE_INT_CST_HIGH (val
);
4213 shift
-= HOST_BITS_PER_WIDE_INT
;
4217 byte
|= (((value
>> shift
)
4218 & (((HOST_WIDE_INT
) 1 << this_time
) - 1))
4221 next_offset
+= this_time
;
4222 byte_buffer_in_use
= 1;
4226 if (byte_buffer_in_use
)
4228 ASM_OUTPUT_BYTE (asm_out_file
, byte
);
4231 if (total_bytes
< size
)
4232 assemble_zeros (size
- total_bytes
);
4235 /* Declare DECL to be a weak symbol. */
4241 if (! TREE_PUBLIC (decl
))
4242 error_with_decl (decl
, "weak declaration of `%s' must be public");
4243 else if (TREE_ASM_WRITTEN (decl
))
4244 error_with_decl (decl
, "weak declaration of `%s' must precede definition");
4245 else if (SUPPORTS_WEAK
)
4246 DECL_WEAK (decl
) = 1;
4249 /* Emit any pending weak declarations. */
4251 #ifdef HANDLE_PRAGMA_WEAK
4252 struct weak_syms
* weak_decls
;
4258 #ifdef HANDLE_PRAGMA_WEAK
4259 if (HANDLE_PRAGMA_WEAK
)
4261 struct weak_syms
*t
;
4262 for (t
= weak_decls
; t
; t
= t
->next
)
4264 ASM_WEAKEN_LABEL (asm_out_file
, t
->name
);
4266 ASM_OUTPUT_DEF (asm_out_file
, t
->name
, t
->value
);
4273 assemble_alias (decl
, target
)
4278 make_decl_rtl (decl
, (char *) 0, 1);
4279 name
= XSTR (XEXP (DECL_RTL (decl
), 0), 0);
4281 #ifdef ASM_OUTPUT_DEF
4282 /* Make name accessible from other files, if appropriate. */
4284 if (TREE_PUBLIC (decl
))
4286 #ifdef ASM_WEAKEN_LABEL
4287 if (DECL_WEAK (decl
))
4288 ASM_WEAKEN_LABEL (asm_out_file
, name
);
4291 ASM_GLOBALIZE_LABEL (asm_out_file
, name
);
4294 ASM_OUTPUT_DEF (asm_out_file
, name
, IDENTIFIER_POINTER (target
));
4295 TREE_ASM_WRITTEN (decl
) = 1;
4297 #ifdef ASM_OUTPUT_WEAK_ALIAS
4298 if (! DECL_WEAK (decl
))
4299 warning ("only weak aliases are supported in this configuration");
4301 ASM_OUTPUT_WEAK_ALIAS (asm_out_file
, name
, IDENTIFIER_POINTER (target
));
4302 TREE_ASM_WRITTEN (decl
) = 1;
4304 warning ("alias definitions not supported in this configuration; ignored");
4309 /* This determines whether or not we support link-once semantics. */
4310 #ifndef SUPPORTS_ONE_ONLY
4311 #ifdef MAKE_DECL_ONE_ONLY
4312 #define SUPPORTS_ONE_ONLY 1
4314 #define SUPPORTS_ONE_ONLY 0
4318 /* Returns 1 if the target configuration supports defining public symbols
4319 so that one of them will be chosen at link time instead of generating a
4320 multiply-defined symbol error, whether through the use of weak symbols or
4321 a target-specific mechanism for having duplicates discarded. */
4324 supports_one_only ()
4326 if (SUPPORTS_ONE_ONLY
)
4328 return SUPPORTS_WEAK
;
4331 /* Set up DECL as a public symbol that can be defined in multiple
4332 translation units without generating a linker error. */
4335 make_decl_one_only (decl
)
4338 if (TREE_CODE (decl
) != VAR_DECL
&& TREE_CODE (decl
) != FUNCTION_DECL
)
4341 TREE_PUBLIC (decl
) = 1;
4343 if (TREE_CODE (decl
) == VAR_DECL
4344 && (DECL_INITIAL (decl
) == 0 || DECL_INITIAL (decl
) == error_mark_node
))
4345 DECL_COMMON (decl
) = 1;
4346 else if (SUPPORTS_ONE_ONLY
)
4348 #ifdef MAKE_DECL_ONE_ONLY
4349 MAKE_DECL_ONE_ONLY (decl
);
4351 DECL_ONE_ONLY (decl
) = 1;
4353 else if (SUPPORTS_WEAK
)
4354 DECL_WEAK (decl
) = 1;