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
< 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 ASM_GLOBALIZE_LABEL (asm_out_file
, fnname
);
1009 #ifdef ASM_WEAKEN_LABEL
1010 if (DECL_WEAK (decl
))
1011 ASM_WEAKEN_LABEL (asm_out_file
, fnname
);
1015 /* Do any machine/system dependent processing of the function name */
1016 #ifdef ASM_DECLARE_FUNCTION_NAME
1017 ASM_DECLARE_FUNCTION_NAME (asm_out_file
, fnname
, current_function_decl
);
1019 /* Standard thing is just output label for the function. */
1020 ASM_OUTPUT_LABEL (asm_out_file
, fnname
);
1021 #endif /* ASM_DECLARE_FUNCTION_NAME */
1024 /* Output assembler code associated with defining the size of the
1025 function. DECL describes the function. NAME is the function's name. */
1028 assemble_end_function (decl
, fnname
)
1032 #ifdef ASM_DECLARE_FUNCTION_SIZE
1033 ASM_DECLARE_FUNCTION_SIZE (asm_out_file
, fnname
, decl
);
1035 if (! CONSTANT_POOL_BEFORE_FUNCTION
)
1037 output_constant_pool (fnname
, decl
);
1038 function_section (decl
); /* need to switch back */
1041 /* Output any constants which should appear after the function. */
1042 output_after_function_constants ();
1045 /* Assemble code to leave SIZE bytes of zeros. */
1048 assemble_zeros (size
)
1051 #ifdef ASM_NO_SKIP_IN_TEXT
1052 /* The `space' pseudo in the text section outputs nop insns rather than 0s,
1053 so we must output 0s explicitly in the text section. */
1054 if (ASM_NO_SKIP_IN_TEXT
&& in_text_section ())
1058 for (i
= 0; i
< size
- 20; i
+= 20)
1061 fprintf (asm_out_file
,
1062 "%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
);
1064 fprintf (asm_out_file
,
1065 "\tbyte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n");
1071 fprintf (asm_out_file
, "%s 0", ASM_BYTE_OP
);
1073 fprintf (asm_out_file
, "\tbyte 0");
1076 for (; i
< size
; i
++)
1077 fprintf (asm_out_file
, ",0");
1078 fprintf (asm_out_file
, "\n");
1084 ASM_OUTPUT_SKIP (asm_out_file
, size
);
1087 /* Assemble an alignment pseudo op for an ALIGN-bit boundary. */
1090 assemble_align (align
)
1093 if (align
> BITS_PER_UNIT
)
1094 ASM_OUTPUT_ALIGN (asm_out_file
, floor_log2 (align
/ BITS_PER_UNIT
));
1097 /* Assemble a string constant with the specified C string as contents. */
1100 assemble_string (p
, size
)
1107 /* If the string is very long, split it up. */
1111 int thissize
= size
- pos
;
1112 if (thissize
> maximum
)
1115 ASM_OUTPUT_ASCII (asm_out_file
, p
, thissize
);
1123 /* Assemble everything that is needed for a variable or function declaration.
1124 Not used for automatic variables, and not used for function definitions.
1125 Should not be called for variables of incomplete structure type.
1127 TOP_LEVEL is nonzero if this variable has file scope.
1128 AT_END is nonzero if this is the special handling, at end of compilation,
1129 to define things that have had only tentative definitions.
1130 DONT_OUTPUT_DATA if nonzero means don't actually output the
1131 initial value (that will be done by the caller). */
1134 assemble_variable (decl
, top_level
, at_end
, dont_output_data
)
1138 int dont_output_data
;
1140 register char *name
;
1144 enum in_section saved_in_section
;
1146 last_assemble_variable_decl
= 0;
1148 if (GET_CODE (DECL_RTL (decl
)) == REG
)
1150 /* Do output symbol info for global register variables, but do nothing
1153 if (TREE_ASM_WRITTEN (decl
))
1155 TREE_ASM_WRITTEN (decl
) = 1;
1157 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
1158 /* File-scope global variables are output here. */
1159 if ((write_symbols
== DBX_DEBUG
|| write_symbols
== XCOFF_DEBUG
)
1161 dbxout_symbol (decl
, 0);
1163 #ifdef SDB_DEBUGGING_INFO
1164 if (write_symbols
== SDB_DEBUG
&& top_level
1165 /* Leave initialized global vars for end of compilation;
1166 see comment in compile_file. */
1167 && (TREE_PUBLIC (decl
) == 0 || DECL_INITIAL (decl
) == 0))
1168 sdbout_symbol (decl
, 0);
1171 /* Don't output any DWARF debugging information for variables here.
1172 In the case of local variables, the information for them is output
1173 when we do our recursive traversal of the tree representation for
1174 the entire containing function. In the case of file-scope variables,
1175 we output information for all of them at the very end of compilation
1176 while we are doing our final traversal of the chain of file-scope
1182 /* Normally no need to say anything here for external references,
1183 since assemble_external is called by the language-specific code
1184 when a declaration is first seen. */
1186 if (DECL_EXTERNAL (decl
))
1189 /* Output no assembler code for a function declaration.
1190 Only definitions of functions output anything. */
1192 if (TREE_CODE (decl
) == FUNCTION_DECL
)
1195 /* If type was incomplete when the variable was declared,
1196 see if it is complete now. */
1198 if (DECL_SIZE (decl
) == 0)
1199 layout_decl (decl
, 0);
1201 /* Still incomplete => don't allocate it; treat the tentative defn
1202 (which is what it must have been) as an `extern' reference. */
1204 if (!dont_output_data
&& DECL_SIZE (decl
) == 0)
1206 error_with_file_and_line (DECL_SOURCE_FILE (decl
),
1207 DECL_SOURCE_LINE (decl
),
1208 "storage size of `%s' isn't known",
1209 IDENTIFIER_POINTER (DECL_NAME (decl
)));
1210 TREE_ASM_WRITTEN (decl
) = 1;
1214 /* The first declaration of a variable that comes through this function
1215 decides whether it is global (in C, has external linkage)
1216 or local (in C, has internal linkage). So do nothing more
1217 if this function has already run. */
1219 if (TREE_ASM_WRITTEN (decl
))
1222 TREE_ASM_WRITTEN (decl
) = 1;
1226 if (! dont_output_data
)
1230 if (TREE_CODE (DECL_SIZE (decl
)) != INTEGER_CST
)
1233 /* This is better than explicit arithmetic, since it avoids overflow. */
1234 size_tree
= size_binop (CEIL_DIV_EXPR
,
1235 DECL_SIZE (decl
), size_int (BITS_PER_UNIT
));
1237 size
= TREE_INT_CST_LOW (size_tree
);
1238 if (TREE_INT_CST_HIGH (size_tree
) != 0
1239 || size
!= TREE_INT_CST_LOW (size_tree
))
1241 error_with_decl (decl
, "size of variable `%s' is too large");
1246 name
= XSTR (XEXP (DECL_RTL (decl
), 0), 0);
1248 if (TREE_PUBLIC (decl
) && DECL_NAME (decl
)
1249 && ! first_global_object_name
1250 && ! (DECL_COMMON (decl
) && (DECL_INITIAL (decl
) == 0
1251 || DECL_INITIAL (decl
) == error_mark_node
))
1252 && ! DECL_WEAK (decl
)
1253 && ! DECL_ONE_ONLY (decl
))
1257 STRIP_NAME_ENCODING (p
, name
);
1258 first_global_object_name
= permalloc (strlen (p
) + 1);
1259 strcpy (first_global_object_name
, p
);
1262 /* Compute the alignment of this data. */
1264 align
= DECL_ALIGN (decl
);
1266 /* In the case for initialing an array whose length isn't specified,
1267 where we have not yet been able to do the layout,
1268 figure out the proper alignment now. */
1269 if (dont_output_data
&& DECL_SIZE (decl
) == 0
1270 && TREE_CODE (TREE_TYPE (decl
)) == ARRAY_TYPE
)
1271 align
= MAX (align
, TYPE_ALIGN (TREE_TYPE (TREE_TYPE (decl
))));
1273 /* Some object file formats have a maximum alignment which they support.
1274 In particular, a.out format supports a maximum alignment of 4. */
1275 #ifndef MAX_OFILE_ALIGNMENT
1276 #define MAX_OFILE_ALIGNMENT BIGGEST_ALIGNMENT
1278 if (align
> MAX_OFILE_ALIGNMENT
)
1280 warning_with_decl (decl
,
1281 "alignment of `%s' is greater than maximum object file alignment. Using %d.",
1282 MAX_OFILE_ALIGNMENT
/BITS_PER_UNIT
);
1283 align
= MAX_OFILE_ALIGNMENT
;
1286 /* On some machines, it is good to increase alignment sometimes. */
1287 #ifdef DATA_ALIGNMENT
1288 align
= DATA_ALIGNMENT (TREE_TYPE (decl
), align
);
1290 #ifdef CONSTANT_ALIGNMENT
1291 if (DECL_INITIAL (decl
) != 0 && DECL_INITIAL (decl
) != error_mark_node
)
1292 align
= CONSTANT_ALIGNMENT (DECL_INITIAL (decl
), align
);
1295 /* Reset the alignment in case we have made it tighter, so we can benefit
1296 from it in get_pointer_alignment. */
1297 DECL_ALIGN (decl
) = align
;
1299 /* Handle uninitialized definitions. */
1301 if ((DECL_INITIAL (decl
) == 0 || DECL_INITIAL (decl
) == error_mark_node
)
1302 /* If the target can't output uninitialized but not common global data
1303 in .bss, then we have to use .data. */
1304 #if ! defined (ASM_OUTPUT_BSS) && ! defined (ASM_OUTPUT_ALIGNED_BSS)
1305 && DECL_COMMON (decl
)
1307 && ! dont_output_data
)
1309 int size
= TREE_INT_CST_LOW (size_tree
);
1312 /* Don't allocate zero bytes of common,
1313 since that means "undefined external" in the linker. */
1314 if (size
== 0) rounded
= 1;
1315 /* Round size up to multiple of BIGGEST_ALIGNMENT bits
1316 so that each uninitialized object starts on such a boundary. */
1317 rounded
+= (BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
) - 1;
1318 rounded
= (rounded
/ (BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
)
1319 * (BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
));
1321 #if !defined(ASM_OUTPUT_ALIGNED_COMMON) && !defined(ASM_OUTPUT_ALIGNED_BSS)
1322 if ( (DECL_ALIGN (decl
) / BITS_PER_UNIT
) > rounded
)
1324 (decl
, "requested alignment for %s is greater than implemented alignment of %d.",rounded
);
1327 #ifdef DBX_DEBUGGING_INFO
1328 /* File-scope global variables are output here. */
1329 if (write_symbols
== DBX_DEBUG
&& top_level
)
1330 dbxout_symbol (decl
, 0);
1332 #ifdef SDB_DEBUGGING_INFO
1333 if (write_symbols
== SDB_DEBUG
&& top_level
1334 /* Leave initialized global vars for end of compilation;
1335 see comment in compile_file. */
1336 && (TREE_PUBLIC (decl
) == 0 || DECL_INITIAL (decl
) == 0))
1337 sdbout_symbol (decl
, 0);
1340 /* Don't output any DWARF debugging information for variables here.
1341 In the case of local variables, the information for them is output
1342 when we do our recursive traversal of the tree representation for
1343 the entire containing function. In the case of file-scope variables,
1344 we output information for all of them at the very end of compilation
1345 while we are doing our final traversal of the chain of file-scope
1348 #if 0 /* ??? We should either delete this or add a comment describing what
1349 it was intended to do and why we shouldn't delete it. */
1350 if (flag_shared_data
)
1354 if (TREE_PUBLIC (decl
)
1355 #if defined (ASM_OUTPUT_BSS) || defined (ASM_OUTPUT_ALIGNED_BSS)
1356 && DECL_COMMON (decl
)
1360 #ifdef ASM_OUTPUT_SHARED_COMMON
1361 if (flag_shared_data
)
1362 ASM_OUTPUT_SHARED_COMMON (asm_out_file
, name
, size
, rounded
);
1366 #ifdef ASM_OUTPUT_ALIGNED_DECL_COMMON
1367 ASM_OUTPUT_ALIGNED_DECL_COMMON (asm_out_file
, decl
, name
, size
,
1370 #ifdef ASM_OUTPUT_ALIGNED_COMMON
1371 ASM_OUTPUT_ALIGNED_COMMON (asm_out_file
, name
, size
,
1374 ASM_OUTPUT_COMMON (asm_out_file
, name
, size
, rounded
);
1379 #if defined (ASM_OUTPUT_BSS) || defined (ASM_OUTPUT_ALIGNED_BSS)
1380 else if (TREE_PUBLIC (decl
))
1382 #ifdef ASM_OUTPUT_SHARED_BSS
1383 if (flag_shared_data
)
1384 ASM_OUTPUT_SHARED_BSS (asm_out_file
, decl
, name
, size
, rounded
);
1388 #ifdef ASM_OUTPUT_ALIGNED_BSS
1389 ASM_OUTPUT_ALIGNED_BSS (asm_out_file
, decl
, name
, size
,
1392 ASM_OUTPUT_BSS (asm_out_file
, decl
, name
, size
, rounded
);
1396 #endif /* ASM_OUTPUT_BSS || ASM_OUTPUT_ALIGNED_BSS */
1399 #ifdef ASM_OUTPUT_SHARED_LOCAL
1400 if (flag_shared_data
)
1401 ASM_OUTPUT_SHARED_LOCAL (asm_out_file
, name
, size
, rounded
);
1405 #ifdef ASM_OUTPUT_ALIGNED_DECL_LOCAL
1406 ASM_OUTPUT_ALIGNED_DECL_LOCAL (asm_out_file
, decl
, name
, size
,
1409 #ifdef ASM_OUTPUT_ALIGNED_LOCAL
1410 ASM_OUTPUT_ALIGNED_LOCAL (asm_out_file
, name
, size
,
1413 ASM_OUTPUT_LOCAL (asm_out_file
, name
, size
, rounded
);
1421 /* Handle initialized definitions.
1422 Also handle uninitialized global definitions if -fno-common and the
1423 target doesn't support ASM_OUTPUT_BSS. */
1425 /* First make the assembler name(s) global if appropriate. */
1426 if (TREE_PUBLIC (decl
) && DECL_NAME (decl
))
1428 ASM_GLOBALIZE_LABEL (asm_out_file
, name
);
1429 #ifdef ASM_WEAKEN_LABEL
1430 if (DECL_WEAK (decl
))
1431 ASM_WEAKEN_LABEL (asm_out_file
, name
);
1435 for (d
= equivalents
; d
; d
= TREE_CHAIN (d
))
1437 tree e
= TREE_VALUE (d
);
1438 if (TREE_PUBLIC (e
) && DECL_NAME (e
))
1439 ASM_GLOBALIZE_LABEL (asm_out_file
,
1440 XSTR (XEXP (DECL_RTL (e
), 0), 0));
1444 /* Output any data that we will need to use the address of. */
1445 if (DECL_INITIAL (decl
) == error_mark_node
)
1446 reloc
= contains_pointers_p (TREE_TYPE (decl
));
1447 else if (DECL_INITIAL (decl
))
1448 reloc
= output_addressed_constants (DECL_INITIAL (decl
));
1450 #ifdef ASM_OUTPUT_SECTION_NAME
1451 if ((flag_data_sections
!= 0
1452 && DECL_SECTION_NAME (decl
) == NULL_TREE
)
1453 || UNIQUE_SECTION_P (decl
))
1454 UNIQUE_SECTION (decl
, reloc
);
1457 /* Switch to the appropriate section. */
1458 variable_section (decl
, reloc
);
1460 /* dbxout.c needs to know this. */
1461 if (in_text_section ())
1462 DECL_IN_TEXT_SECTION (decl
) = 1;
1464 /* Record current section so we can restore it if dbxout.c clobbers it. */
1465 saved_in_section
= in_section
;
1467 /* Output the dbx info now that we have chosen the section. */
1469 #ifdef DBX_DEBUGGING_INFO
1470 /* File-scope global variables are output here. */
1471 if (write_symbols
== DBX_DEBUG
&& top_level
)
1472 dbxout_symbol (decl
, 0);
1474 #ifdef SDB_DEBUGGING_INFO
1475 if (write_symbols
== SDB_DEBUG
&& top_level
1476 /* Leave initialized global vars for end of compilation;
1477 see comment in compile_file. */
1478 && (TREE_PUBLIC (decl
) == 0 || DECL_INITIAL (decl
) == 0))
1479 sdbout_symbol (decl
, 0);
1482 /* Don't output any DWARF debugging information for variables here.
1483 In the case of local variables, the information for them is output
1484 when we do our recursive traversal of the tree representation for
1485 the entire containing function. In the case of file-scope variables,
1486 we output information for all of them at the very end of compilation
1487 while we are doing our final traversal of the chain of file-scope
1490 /* If the debugging output changed sections, reselect the section
1491 that's supposed to be selected. */
1492 if (in_section
!= saved_in_section
)
1493 variable_section (decl
, reloc
);
1495 /* Output the alignment of this data. */
1496 if (align
> BITS_PER_UNIT
)
1497 ASM_OUTPUT_ALIGN (asm_out_file
,
1498 floor_log2 (DECL_ALIGN (decl
) / BITS_PER_UNIT
));
1500 /* Do any machine/system dependent processing of the object. */
1501 #ifdef ASM_DECLARE_OBJECT_NAME
1502 last_assemble_variable_decl
= decl
;
1503 ASM_DECLARE_OBJECT_NAME (asm_out_file
, name
, decl
);
1505 /* Standard thing is just output label for the object. */
1506 ASM_OUTPUT_LABEL (asm_out_file
, name
);
1507 #endif /* ASM_DECLARE_OBJECT_NAME */
1509 if (!dont_output_data
)
1511 if (DECL_INITIAL (decl
))
1512 /* Output the actual data. */
1513 output_constant (DECL_INITIAL (decl
), TREE_INT_CST_LOW (size_tree
));
1515 /* Leave space for it. */
1516 assemble_zeros (TREE_INT_CST_LOW (size_tree
));
1520 #ifdef XCOFF_DEBUGGING_INFO
1521 /* Unfortunately, the IBM assembler cannot handle stabx before the actual
1522 declaration. When something like ".stabx "aa:S-2",aa,133,0" is emitted
1523 and `aa' hasn't been output yet, the assembler generates a stab entry with
1524 a value of zero, in addition to creating an unnecessary external entry
1525 for `aa'. Hence, we must postpone dbxout_symbol to here at the end. */
1527 /* File-scope global variables are output here. */
1528 if (write_symbols
== XCOFF_DEBUG
&& top_level
)
1530 saved_in_section
= in_section
;
1532 dbxout_symbol (decl
, 0);
1534 if (in_section
!= saved_in_section
)
1535 variable_section (decl
, reloc
);
1538 /* There must be a statement after a label. */
1543 /* Return 1 if type TYPE contains any pointers. */
1546 contains_pointers_p (type
)
1549 switch (TREE_CODE (type
))
1552 case REFERENCE_TYPE
:
1553 /* I'm not sure whether OFFSET_TYPE needs this treatment,
1554 so I'll play safe and return 1. */
1560 case QUAL_UNION_TYPE
:
1563 /* For a type that has fields, see if the fields have pointers. */
1564 for (fields
= TYPE_FIELDS (type
); fields
; fields
= TREE_CHAIN (fields
))
1565 if (TREE_CODE (fields
) == FIELD_DECL
1566 && contains_pointers_p (TREE_TYPE (fields
)))
1572 /* An array type contains pointers if its element type does. */
1573 return contains_pointers_p (TREE_TYPE (type
));
1580 /* Output something to declare an external symbol to the assembler.
1581 (Most assemblers don't need this, so we normally output nothing.)
1582 Do nothing if DECL is not external. */
1585 assemble_external (decl
)
1588 #ifdef ASM_OUTPUT_EXTERNAL
1589 if (TREE_CODE_CLASS (TREE_CODE (decl
)) == 'd'
1590 && DECL_EXTERNAL (decl
) && TREE_PUBLIC (decl
))
1592 rtx rtl
= DECL_RTL (decl
);
1594 if (GET_CODE (rtl
) == MEM
&& GET_CODE (XEXP (rtl
, 0)) == SYMBOL_REF
1595 && ! SYMBOL_REF_USED (XEXP (rtl
, 0)))
1597 /* Some systems do require some output. */
1598 SYMBOL_REF_USED (XEXP (rtl
, 0)) = 1;
1599 ASM_OUTPUT_EXTERNAL (asm_out_file
, decl
, XSTR (XEXP (rtl
, 0), 0));
1605 /* Similar, for calling a library function FUN. */
1608 assemble_external_libcall (fun
)
1611 #ifdef ASM_OUTPUT_EXTERNAL_LIBCALL
1612 /* Declare library function name external when first used, if nec. */
1613 if (! SYMBOL_REF_USED (fun
))
1615 SYMBOL_REF_USED (fun
) = 1;
1616 ASM_OUTPUT_EXTERNAL_LIBCALL (asm_out_file
, fun
);
1621 /* Declare the label NAME global. */
1624 assemble_global (name
)
1627 ASM_GLOBALIZE_LABEL (asm_out_file
, name
);
1630 /* Assemble a label named NAME. */
1633 assemble_label (name
)
1636 ASM_OUTPUT_LABEL (asm_out_file
, name
);
1639 /* Output to FILE a reference to the assembler name of a C-level name NAME.
1640 If NAME starts with a *, the rest of NAME is output verbatim.
1641 Otherwise NAME is transformed in an implementation-defined way
1642 (usually by the addition of an underscore).
1643 Many macros in the tm file are defined to call this function. */
1646 assemble_name (file
, name
)
1653 STRIP_NAME_ENCODING (real_name
, name
);
1654 if (flag_prefix_function_name
1655 && ! bcmp (real_name
, CHKR_PREFIX
, CHKR_PREFIX_SIZE
))
1656 real_name
= real_name
+ CHKR_PREFIX_SIZE
;
1658 id
= maybe_get_identifier (real_name
);
1660 TREE_SYMBOL_REFERENCED (id
) = 1;
1663 fputs (&name
[1], file
);
1665 ASM_OUTPUT_LABELREF (file
, name
);
1668 /* Allocate SIZE bytes writable static space with a gensym name
1669 and return an RTX to refer to its address. */
1672 assemble_static_space (size
)
1680 if (flag_shared_data
)
1684 ASM_GENERATE_INTERNAL_LABEL (name
, "LF", const_labelno
);
1687 namestring
= (char *) obstack_alloc (saveable_obstack
,
1689 strcpy (namestring
, name
);
1691 x
= gen_rtx_SYMBOL_REF (Pmode
, namestring
);
1693 #ifdef ASM_OUTPUT_ALIGNED_DECL_LOCAL
1694 ASM_OUTPUT_ALIGNED_DECL_LOCAL (asm_out_file
, NULL_TREE
, name
, size
,
1697 #ifdef ASM_OUTPUT_ALIGNED_LOCAL
1698 ASM_OUTPUT_ALIGNED_LOCAL (asm_out_file
, name
, size
, BIGGEST_ALIGNMENT
);
1701 /* Round size up to multiple of BIGGEST_ALIGNMENT bits
1702 so that each uninitialized object starts on such a boundary. */
1703 int rounded
= ((size
+ (BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
) - 1)
1704 / (BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
)
1705 * (BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
));
1706 ASM_OUTPUT_LOCAL (asm_out_file
, name
, size
, rounded
);
1713 /* Assemble the static constant template for function entry trampolines.
1714 This is done at most once per compilation.
1715 Returns an RTX for the address of the template. */
1717 #ifdef TRAMPOLINE_TEMPLATE
1719 assemble_trampoline_template ()
1725 /* By default, put trampoline templates in read-only data section. */
1727 #ifdef TRAMPOLINE_SECTION
1728 TRAMPOLINE_SECTION ();
1730 readonly_data_section ();
1733 /* Write the assembler code to define one. */
1734 align
= floor_log2 (TRAMPOLINE_ALIGNMENT
/ BITS_PER_UNIT
);
1736 ASM_OUTPUT_ALIGN (asm_out_file
, align
);
1738 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, "LTRAMP", 0);
1739 TRAMPOLINE_TEMPLATE (asm_out_file
);
1741 /* Record the rtl to refer to it. */
1742 ASM_GENERATE_INTERNAL_LABEL (label
, "LTRAMP", 0);
1744 = (char *) obstack_copy0 (&permanent_obstack
, label
, strlen (label
));
1745 return gen_rtx_SYMBOL_REF (Pmode
, name
);
1749 /* Assemble the integer constant X into an object of SIZE bytes.
1750 X must be either a CONST_INT or CONST_DOUBLE.
1752 Return 1 if we were able to output the constant, otherwise 0. If FORCE is
1753 non-zero, abort if we can't output the constant. */
1756 assemble_integer (x
, size
, force
)
1761 /* First try to use the standard 1, 2, 4, 8, and 16 byte
1762 ASM_OUTPUT... macros. */
1766 #ifdef ASM_OUTPUT_CHAR
1768 ASM_OUTPUT_CHAR (asm_out_file
, x
);
1772 #ifdef ASM_OUTPUT_SHORT
1774 ASM_OUTPUT_SHORT (asm_out_file
, x
);
1778 #ifdef ASM_OUTPUT_INT
1780 ASM_OUTPUT_INT (asm_out_file
, x
);
1784 #ifdef ASM_OUTPUT_DOUBLE_INT
1786 ASM_OUTPUT_DOUBLE_INT (asm_out_file
, x
);
1790 #ifdef ASM_OUTPUT_QUADRUPLE_INT
1792 ASM_OUTPUT_QUADRUPLE_INT (asm_out_file
, x
);
1797 /* If we couldn't do it that way, there are two other possibilities: First,
1798 if the machine can output an explicit byte and this is a 1 byte constant,
1799 we can use ASM_OUTPUT_BYTE. */
1801 #ifdef ASM_OUTPUT_BYTE
1802 if (size
== 1 && GET_CODE (x
) == CONST_INT
)
1804 ASM_OUTPUT_BYTE (asm_out_file
, INTVAL (x
));
1809 /* Finally, if SIZE is larger than a single word, try to output the constant
1810 one word at a time. */
1812 if (size
> UNITS_PER_WORD
)
1815 enum machine_mode mode
1816 = mode_for_size (size
* BITS_PER_UNIT
, MODE_INT
, 0);
1819 for (i
= 0; i
< size
/ UNITS_PER_WORD
; i
++)
1821 word
= operand_subword (x
, i
, 0, mode
);
1826 if (! assemble_integer (word
, UNITS_PER_WORD
, 0))
1830 if (i
== size
/ UNITS_PER_WORD
)
1832 /* If we output at least one word and then could not finish,
1833 there is no valid way to continue. */
1844 /* Assemble the floating-point constant D into an object of size MODE. */
1847 assemble_real (d
, mode
)
1849 enum machine_mode mode
;
1851 jmp_buf output_constant_handler
;
1853 if (setjmp (output_constant_handler
))
1855 error ("floating point trap outputting a constant");
1856 #ifdef REAL_IS_NOT_DOUBLE
1857 bzero ((char *) &d
, sizeof d
);
1864 set_float_handler (output_constant_handler
);
1868 #ifdef ASM_OUTPUT_BYTE_FLOAT
1870 ASM_OUTPUT_BYTE_FLOAT (asm_out_file
, d
);
1873 #ifdef ASM_OUTPUT_SHORT_FLOAT
1875 ASM_OUTPUT_SHORT_FLOAT (asm_out_file
, d
);
1878 #ifdef ASM_OUTPUT_THREE_QUARTER_FLOAT
1880 ASM_OUTPUT_THREE_QUARTER_FLOAT (asm_out_file
, d
);
1883 #ifdef ASM_OUTPUT_FLOAT
1885 ASM_OUTPUT_FLOAT (asm_out_file
, d
);
1889 #ifdef ASM_OUTPUT_DOUBLE
1891 ASM_OUTPUT_DOUBLE (asm_out_file
, d
);
1895 #ifdef ASM_OUTPUT_LONG_DOUBLE
1898 ASM_OUTPUT_LONG_DOUBLE (asm_out_file
, d
);
1906 set_float_handler (NULL_PTR
);
1909 /* Here we combine duplicate floating constants to make
1910 CONST_DOUBLE rtx's, and force those out to memory when necessary. */
1912 /* Chain of all CONST_DOUBLE rtx's constructed for the current function.
1913 They are chained through the CONST_DOUBLE_CHAIN.
1914 A CONST_DOUBLE rtx has CONST_DOUBLE_MEM != cc0_rtx iff it is on this chain.
1915 In that case, CONST_DOUBLE_MEM is either a MEM,
1916 or const0_rtx if no MEM has been made for this CONST_DOUBLE yet.
1918 (CONST_DOUBLE_MEM is used only for top-level functions.
1919 See force_const_mem for explanation.) */
1921 static rtx const_double_chain
;
1923 /* Return a CONST_DOUBLE or CONST_INT for a value specified as a pair of ints.
1924 For an integer, I0 is the low-order word and I1 is the high-order word.
1925 For a real number, I0 is the word with the low address
1926 and I1 is the word with the high address. */
1929 immed_double_const (i0
, i1
, mode
)
1930 HOST_WIDE_INT i0
, i1
;
1931 enum machine_mode mode
;
1935 if (GET_MODE_CLASS (mode
) == MODE_INT
1936 || GET_MODE_CLASS (mode
) == MODE_PARTIAL_INT
)
1938 /* We clear out all bits that don't belong in MODE, unless they and our
1939 sign bit are all one. So we get either a reasonable negative value
1940 or a reasonable unsigned value for this mode. */
1941 int width
= GET_MODE_BITSIZE (mode
);
1942 if (width
< HOST_BITS_PER_WIDE_INT
1943 && ((i0
& ((HOST_WIDE_INT
) (-1) << (width
- 1)))
1944 != ((HOST_WIDE_INT
) (-1) << (width
- 1))))
1945 i0
&= ((HOST_WIDE_INT
) 1 << width
) - 1, i1
= 0;
1946 else if (width
== HOST_BITS_PER_WIDE_INT
1947 && ! (i1
== ~0 && i0
< 0))
1949 else if (width
> 2 * HOST_BITS_PER_WIDE_INT
)
1950 /* We cannot represent this value as a constant. */
1953 /* If this would be an entire word for the target, but is not for
1954 the host, then sign-extend on the host so that the number will look
1955 the same way on the host that it would on the target.
1957 For example, when building a 64 bit alpha hosted 32 bit sparc
1958 targeted compiler, then we want the 32 bit unsigned value -1 to be
1959 represented as a 64 bit value -1, and not as 0x00000000ffffffff.
1960 The later confuses the sparc backend. */
1962 if (BITS_PER_WORD
< HOST_BITS_PER_WIDE_INT
&& BITS_PER_WORD
== width
1963 && (i0
& ((HOST_WIDE_INT
) 1 << (width
- 1))))
1964 i0
|= ((HOST_WIDE_INT
) (-1) << width
);
1966 /* If MODE fits within HOST_BITS_PER_WIDE_INT, always use a CONST_INT.
1968 ??? Strictly speaking, this is wrong if we create a CONST_INT
1969 for a large unsigned constant with the size of MODE being
1970 HOST_BITS_PER_WIDE_INT and later try to interpret that constant in a
1971 wider mode. In that case we will mis-interpret it as a negative
1974 Unfortunately, the only alternative is to make a CONST_DOUBLE
1975 for any constant in any mode if it is an unsigned constant larger
1976 than the maximum signed integer in an int on the host. However,
1977 doing this will break everyone that always expects to see a CONST_INT
1978 for SImode and smaller.
1980 We have always been making CONST_INTs in this case, so nothing new
1983 if (width
<= HOST_BITS_PER_WIDE_INT
)
1984 i1
= (i0
< 0) ? ~(HOST_WIDE_INT
) 0 : 0;
1986 /* If this integer fits in one word, return a CONST_INT. */
1987 if ((i1
== 0 && i0
>= 0)
1988 || (i1
== ~0 && i0
< 0))
1989 return GEN_INT (i0
);
1991 /* We use VOIDmode for integers. */
1995 /* Search the chain for an existing CONST_DOUBLE with the right value.
1996 If one is found, return it. */
1998 for (r
= const_double_chain
; r
; r
= CONST_DOUBLE_CHAIN (r
))
1999 if (CONST_DOUBLE_LOW (r
) == i0
&& CONST_DOUBLE_HIGH (r
) == i1
2000 && GET_MODE (r
) == mode
)
2003 /* No; make a new one and add it to the chain.
2005 We may be called by an optimizer which may be discarding any memory
2006 allocated during its processing (such as combine and loop). However,
2007 we will be leaving this constant on the chain, so we cannot tolerate
2008 freed memory. So switch to saveable_obstack for this allocation
2009 and then switch back if we were in current_obstack. */
2011 push_obstacks_nochange ();
2012 rtl_in_saveable_obstack ();
2013 r
= gen_rtx_CONST_DOUBLE (mode
, NULL_RTX
, i0
, i1
);
2016 /* Don't touch const_double_chain in nested function; see force_const_mem.
2017 Also, don't touch it if not inside any function. */
2018 if (outer_function_chain
== 0 && current_function_decl
!= 0)
2020 CONST_DOUBLE_CHAIN (r
) = const_double_chain
;
2021 const_double_chain
= r
;
2024 /* Store const0_rtx in mem-slot since this CONST_DOUBLE is on the chain.
2025 Actual use of mem-slot is only through force_const_mem. */
2027 CONST_DOUBLE_MEM (r
) = const0_rtx
;
2032 /* Return a CONST_DOUBLE for a specified `double' value
2033 and machine mode. */
2036 immed_real_const_1 (d
, mode
)
2038 enum machine_mode mode
;
2040 union real_extract u
;
2043 /* Get the desired `double' value as a sequence of ints
2044 since that is how they are stored in a CONST_DOUBLE. */
2048 /* Detect special cases. */
2050 if (REAL_VALUES_IDENTICAL (dconst0
, d
))
2051 return CONST0_RTX (mode
);
2052 /* Check for NaN first, because some ports (specifically the i386) do not
2053 emit correct ieee-fp code by default, and thus will generate a core
2054 dump here if we pass a NaN to REAL_VALUES_EQUAL and if REAL_VALUES_EQUAL
2055 does a floating point comparison. */
2056 else if (! REAL_VALUE_ISNAN (d
) && REAL_VALUES_EQUAL (dconst1
, d
))
2057 return CONST1_RTX (mode
);
2059 if (sizeof u
== sizeof (HOST_WIDE_INT
))
2060 return immed_double_const (u
.i
[0], 0, mode
);
2061 if (sizeof u
== 2 * sizeof (HOST_WIDE_INT
))
2062 return immed_double_const (u
.i
[0], u
.i
[1], mode
);
2064 /* The rest of this function handles the case where
2065 a float value requires more than 2 ints of space.
2066 It will be deleted as dead code on machines that don't need it. */
2068 /* Search the chain for an existing CONST_DOUBLE with the right value.
2069 If one is found, return it. */
2071 for (r
= const_double_chain
; r
; r
= CONST_DOUBLE_CHAIN (r
))
2072 if (! bcmp ((char *) &CONST_DOUBLE_LOW (r
), (char *) &u
, sizeof u
)
2073 && GET_MODE (r
) == mode
)
2076 /* No; make a new one and add it to the chain.
2078 We may be called by an optimizer which may be discarding any memory
2079 allocated during its processing (such as combine and loop). However,
2080 we will be leaving this constant on the chain, so we cannot tolerate
2081 freed memory. So switch to saveable_obstack for this allocation
2082 and then switch back if we were in current_obstack. */
2084 push_obstacks_nochange ();
2085 rtl_in_saveable_obstack ();
2086 r
= rtx_alloc (CONST_DOUBLE
);
2088 bcopy ((char *) &u
, (char *) &CONST_DOUBLE_LOW (r
), sizeof u
);
2091 /* Don't touch const_double_chain in nested function; see force_const_mem.
2092 Also, don't touch it if not inside any function. */
2093 if (outer_function_chain
== 0 && current_function_decl
!= 0)
2095 CONST_DOUBLE_CHAIN (r
) = const_double_chain
;
2096 const_double_chain
= r
;
2099 /* Store const0_rtx in CONST_DOUBLE_MEM since this CONST_DOUBLE is on the
2100 chain, but has not been allocated memory. Actual use of CONST_DOUBLE_MEM
2101 is only through force_const_mem. */
2103 CONST_DOUBLE_MEM (r
) = const0_rtx
;
2108 /* Return a CONST_DOUBLE rtx for a value specified by EXP,
2109 which must be a REAL_CST tree node. */
2112 immed_real_const (exp
)
2115 return immed_real_const_1 (TREE_REAL_CST (exp
), TYPE_MODE (TREE_TYPE (exp
)));
2118 /* At the end of a function, forget the memory-constants
2119 previously made for CONST_DOUBLEs. Mark them as not on real_constant_chain.
2120 Also clear out real_constant_chain and clear out all the chain-pointers. */
2123 clear_const_double_mem ()
2125 register rtx r
, next
;
2127 /* Don't touch CONST_DOUBLE_MEM for nested functions.
2128 See force_const_mem for explanation. */
2129 if (outer_function_chain
!= 0)
2132 for (r
= const_double_chain
; r
; r
= next
)
2134 next
= CONST_DOUBLE_CHAIN (r
);
2135 CONST_DOUBLE_CHAIN (r
) = 0;
2136 CONST_DOUBLE_MEM (r
) = cc0_rtx
;
2138 const_double_chain
= 0;
2141 /* Given an expression EXP with a constant value,
2142 reduce it to the sum of an assembler symbol and an integer.
2143 Store them both in the structure *VALUE.
2144 Abort if EXP does not reduce. */
2149 HOST_WIDE_INT offset
;
2153 decode_addr_const (exp
, value
)
2155 struct addr_const
*value
;
2157 register tree target
= TREE_OPERAND (exp
, 0);
2158 register int offset
= 0;
2163 if (TREE_CODE (target
) == COMPONENT_REF
2164 && (TREE_CODE (DECL_FIELD_BITPOS (TREE_OPERAND (target
, 1)))
2167 offset
+= TREE_INT_CST_LOW (DECL_FIELD_BITPOS (TREE_OPERAND (target
, 1))) / BITS_PER_UNIT
;
2168 target
= TREE_OPERAND (target
, 0);
2170 else if (TREE_CODE (target
) == ARRAY_REF
)
2172 if (TREE_CODE (TREE_OPERAND (target
, 1)) != INTEGER_CST
2173 || TREE_CODE (TYPE_SIZE (TREE_TYPE (target
))) != INTEGER_CST
)
2175 offset
+= ((TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (target
)))
2176 * TREE_INT_CST_LOW (TREE_OPERAND (target
, 1)))
2178 target
= TREE_OPERAND (target
, 0);
2184 switch (TREE_CODE (target
))
2188 x
= DECL_RTL (target
);
2192 x
= gen_rtx_MEM (FUNCTION_MODE
,
2193 gen_rtx_LABEL_REF (VOIDmode
,
2194 label_rtx (TREE_OPERAND (exp
, 0))));
2202 x
= TREE_CST_RTL (target
);
2209 if (GET_CODE (x
) != MEM
)
2214 value
->offset
= offset
;
2217 /* Uniquize all constants that appear in memory.
2218 Each constant in memory thus far output is recorded
2219 in `const_hash_table' with a `struct constant_descriptor'
2220 that contains a polish representation of the value of
2223 We cannot store the trees in the hash table
2224 because the trees may be temporary. */
2226 struct constant_descriptor
2228 struct constant_descriptor
*next
;
2234 #define MAX_HASH_TABLE 1009
2235 static struct constant_descriptor
*const_hash_table
[MAX_HASH_TABLE
];
2237 /* Compute a hash code for a constant expression. */
2244 register int len
, hi
, i
;
2245 register enum tree_code code
= TREE_CODE (exp
);
2247 /* Either set P and LEN to the address and len of something to hash and
2248 exit the switch or return a value. */
2253 p
= (char *) &TREE_INT_CST_LOW (exp
);
2254 len
= 2 * sizeof TREE_INT_CST_LOW (exp
);
2258 p
= (char *) &TREE_REAL_CST (exp
);
2259 len
= sizeof TREE_REAL_CST (exp
);
2263 p
= TREE_STRING_POINTER (exp
);
2264 len
= TREE_STRING_LENGTH (exp
);
2268 return (const_hash (TREE_REALPART (exp
)) * 5
2269 + const_hash (TREE_IMAGPART (exp
)));
2272 if (TREE_CODE (TREE_TYPE (exp
)) == SET_TYPE
)
2274 len
= int_size_in_bytes (TREE_TYPE (exp
));
2275 p
= (char *) alloca (len
);
2276 get_set_constructor_bytes (exp
, (unsigned char *) p
, len
);
2283 /* For record type, include the type in the hashing.
2284 We do not do so for array types
2285 because (1) the sizes of the elements are sufficient
2286 and (2) distinct array types can have the same constructor.
2287 Instead, we include the array size because the constructor could
2289 if (TREE_CODE (TREE_TYPE (exp
)) == RECORD_TYPE
)
2290 hi
= ((unsigned long) TREE_TYPE (exp
) & ((1 << HASHBITS
) - 1))
2293 hi
= ((5 + int_size_in_bytes (TREE_TYPE (exp
)))
2294 & ((1 << HASHBITS
) - 1)) % MAX_HASH_TABLE
;
2296 for (link
= CONSTRUCTOR_ELTS (exp
); link
; link
= TREE_CHAIN (link
))
2297 if (TREE_VALUE (link
))
2299 = (hi
* 603 + const_hash (TREE_VALUE (link
))) % MAX_HASH_TABLE
;
2306 struct addr_const value
;
2308 decode_addr_const (exp
, &value
);
2309 if (GET_CODE (value
.base
) == SYMBOL_REF
)
2311 /* Don't hash the address of the SYMBOL_REF;
2312 only use the offset and the symbol name. */
2314 p
= XSTR (value
.base
, 0);
2315 for (i
= 0; p
[i
] != 0; i
++)
2316 hi
= ((hi
* 613) + (unsigned) (p
[i
]));
2318 else if (GET_CODE (value
.base
) == LABEL_REF
)
2319 hi
= value
.offset
+ CODE_LABEL_NUMBER (XEXP (value
.base
, 0)) * 13;
2321 hi
&= (1 << HASHBITS
) - 1;
2322 hi
%= MAX_HASH_TABLE
;
2328 return (const_hash (TREE_OPERAND (exp
, 0)) * 9
2329 + const_hash (TREE_OPERAND (exp
, 1)));
2333 case NON_LVALUE_EXPR
:
2334 return const_hash (TREE_OPERAND (exp
, 0)) * 7 + 2;
2340 /* Compute hashing function */
2342 for (i
= 0; i
< len
; i
++)
2343 hi
= ((hi
* 613) + (unsigned) (p
[i
]));
2345 hi
&= (1 << HASHBITS
) - 1;
2346 hi
%= MAX_HASH_TABLE
;
2350 /* Compare a constant expression EXP with a constant-descriptor DESC.
2351 Return 1 if DESC describes a constant with the same value as EXP. */
2354 compare_constant (exp
, desc
)
2356 struct constant_descriptor
*desc
;
2358 return 0 != compare_constant_1 (exp
, desc
->contents
);
2361 /* Compare constant expression EXP with a substring P of a constant descriptor.
2362 If they match, return a pointer to the end of the substring matched.
2363 If they do not match, return 0.
2365 Since descriptors are written in polish prefix notation,
2366 this function can be used recursively to test one operand of EXP
2367 against a subdescriptor, and if it succeeds it returns the
2368 address of the subdescriptor for the next operand. */
2371 compare_constant_1 (exp
, p
)
2375 register char *strp
;
2377 register enum tree_code code
= TREE_CODE (exp
);
2379 if (code
!= (enum tree_code
) *p
++)
2382 /* Either set STRP, P and LEN to pointers and length to compare and exit the
2383 switch, or return the result of the comparison. */
2388 /* Integer constants are the same only if the same width of type. */
2389 if (*p
++ != TYPE_PRECISION (TREE_TYPE (exp
)))
2392 strp
= (char *) &TREE_INT_CST_LOW (exp
);
2393 len
= 2 * sizeof TREE_INT_CST_LOW (exp
);
2397 /* Real constants are the same only if the same width of type. */
2398 if (*p
++ != TYPE_PRECISION (TREE_TYPE (exp
)))
2401 strp
= (char *) &TREE_REAL_CST (exp
);
2402 len
= sizeof TREE_REAL_CST (exp
);
2406 if (flag_writable_strings
)
2409 if (*p
++ != TYPE_MODE (TREE_TYPE (exp
)))
2412 strp
= TREE_STRING_POINTER (exp
);
2413 len
= TREE_STRING_LENGTH (exp
);
2414 if (bcmp ((char *) &TREE_STRING_LENGTH (exp
), p
,
2415 sizeof TREE_STRING_LENGTH (exp
)))
2418 p
+= sizeof TREE_STRING_LENGTH (exp
);
2422 p
= compare_constant_1 (TREE_REALPART (exp
), p
);
2426 return compare_constant_1 (TREE_IMAGPART (exp
), p
);
2429 if (TREE_CODE (TREE_TYPE (exp
)) == SET_TYPE
)
2431 int xlen
= len
= int_size_in_bytes (TREE_TYPE (exp
));
2433 strp
= (char *) alloca (len
);
2434 get_set_constructor_bytes (exp
, (unsigned char *) strp
, len
);
2435 if (bcmp ((char *) &xlen
, p
, sizeof xlen
))
2444 int length
= list_length (CONSTRUCTOR_ELTS (exp
));
2446 int have_purpose
= 0;
2448 for (link
= CONSTRUCTOR_ELTS (exp
); link
; link
= TREE_CHAIN (link
))
2449 if (TREE_PURPOSE (link
))
2452 if (bcmp ((char *) &length
, p
, sizeof length
))
2457 /* For record constructors, insist that the types match.
2458 For arrays, just verify both constructors are for arrays.
2459 Then insist that either both or none have any TREE_PURPOSE
2461 if (TREE_CODE (TREE_TYPE (exp
)) == RECORD_TYPE
)
2462 type
= TREE_TYPE (exp
);
2466 if (bcmp ((char *) &type
, p
, sizeof type
))
2471 if (bcmp ((char *) &have_purpose
, p
, sizeof have_purpose
))
2474 p
+= sizeof have_purpose
;
2476 /* For arrays, insist that the size in bytes match. */
2477 if (TREE_CODE (TREE_TYPE (exp
)) == ARRAY_TYPE
)
2479 HOST_WIDE_INT size
= int_size_in_bytes (TREE_TYPE (exp
));
2481 if (bcmp ((char *) &size
, p
, sizeof size
))
2487 for (link
= CONSTRUCTOR_ELTS (exp
); link
; link
= TREE_CHAIN (link
))
2489 if (TREE_VALUE (link
))
2491 if ((p
= compare_constant_1 (TREE_VALUE (link
), p
)) == 0)
2498 if (bcmp ((char *) &zero
, p
, sizeof zero
))
2504 if (TREE_PURPOSE (link
)
2505 && TREE_CODE (TREE_PURPOSE (link
)) == FIELD_DECL
)
2507 if (bcmp ((char *) &TREE_PURPOSE (link
), p
,
2508 sizeof TREE_PURPOSE (link
)))
2511 p
+= sizeof TREE_PURPOSE (link
);
2513 else if (TREE_PURPOSE (link
))
2515 if ((p
= compare_constant_1 (TREE_PURPOSE (link
), p
)) == 0)
2518 else if (have_purpose
)
2522 if (bcmp ((char *) &zero
, p
, sizeof zero
))
2534 struct addr_const value
;
2536 decode_addr_const (exp
, &value
);
2537 strp
= (char *) &value
.offset
;
2538 len
= sizeof value
.offset
;
2539 /* Compare the offset. */
2541 if (*p
++ != *strp
++)
2544 /* Compare symbol name. */
2545 strp
= XSTR (value
.base
, 0);
2546 len
= strlen (strp
) + 1;
2553 p
= compare_constant_1 (TREE_OPERAND (exp
, 0), p
);
2557 return compare_constant_1 (TREE_OPERAND (exp
, 1), p
);
2561 case NON_LVALUE_EXPR
:
2562 return compare_constant_1 (TREE_OPERAND (exp
, 0), p
);
2568 /* Compare constant contents. */
2570 if (*p
++ != *strp
++)
2576 /* Construct a constant descriptor for the expression EXP.
2577 It is up to the caller to enter the descriptor in the hash table. */
2579 static struct constant_descriptor
*
2580 record_constant (exp
)
2583 struct constant_descriptor
*next
= 0;
2586 /* Make a struct constant_descriptor. The first two pointers will
2587 be filled in later. Here we just leave space for them. */
2589 obstack_grow (&permanent_obstack
, (char *) &next
, sizeof next
);
2590 obstack_grow (&permanent_obstack
, (char *) &label
, sizeof label
);
2591 record_constant_1 (exp
);
2592 return (struct constant_descriptor
*) obstack_finish (&permanent_obstack
);
2595 /* Add a description of constant expression EXP
2596 to the object growing in `permanent_obstack'.
2597 No need to return its address; the caller will get that
2598 from the obstack when the object is complete. */
2601 record_constant_1 (exp
)
2604 register char *strp
;
2606 register enum tree_code code
= TREE_CODE (exp
);
2608 obstack_1grow (&permanent_obstack
, (unsigned int) code
);
2613 obstack_1grow (&permanent_obstack
, TYPE_PRECISION (TREE_TYPE (exp
)));
2614 strp
= (char *) &TREE_INT_CST_LOW (exp
);
2615 len
= 2 * sizeof TREE_INT_CST_LOW (exp
);
2619 obstack_1grow (&permanent_obstack
, TYPE_PRECISION (TREE_TYPE (exp
)));
2620 strp
= (char *) &TREE_REAL_CST (exp
);
2621 len
= sizeof TREE_REAL_CST (exp
);
2625 if (flag_writable_strings
)
2628 obstack_1grow (&permanent_obstack
, TYPE_MODE (TREE_TYPE (exp
)));
2629 strp
= TREE_STRING_POINTER (exp
);
2630 len
= TREE_STRING_LENGTH (exp
);
2631 obstack_grow (&permanent_obstack
, (char *) &TREE_STRING_LENGTH (exp
),
2632 sizeof TREE_STRING_LENGTH (exp
));
2636 record_constant_1 (TREE_REALPART (exp
));
2637 record_constant_1 (TREE_IMAGPART (exp
));
2641 if (TREE_CODE (TREE_TYPE (exp
)) == SET_TYPE
)
2643 int nbytes
= int_size_in_bytes (TREE_TYPE (exp
));
2644 obstack_grow (&permanent_obstack
, &nbytes
, sizeof (nbytes
));
2645 obstack_blank (&permanent_obstack
, nbytes
);
2646 get_set_constructor_bytes
2647 (exp
, (unsigned char *) permanent_obstack
.next_free
-nbytes
,
2654 int length
= list_length (CONSTRUCTOR_ELTS (exp
));
2656 int have_purpose
= 0;
2658 for (link
= CONSTRUCTOR_ELTS (exp
); link
; link
= TREE_CHAIN (link
))
2659 if (TREE_PURPOSE (link
))
2662 obstack_grow (&permanent_obstack
, (char *) &length
, sizeof length
);
2664 /* For record constructors, insist that the types match.
2665 For arrays, just verify both constructors are for arrays.
2666 Then insist that either both or none have any TREE_PURPOSE
2668 if (TREE_CODE (TREE_TYPE (exp
)) == RECORD_TYPE
)
2669 type
= TREE_TYPE (exp
);
2672 obstack_grow (&permanent_obstack
, (char *) &type
, sizeof type
);
2673 obstack_grow (&permanent_obstack
, (char *) &have_purpose
,
2674 sizeof have_purpose
);
2676 /* For arrays, insist that the size in bytes match. */
2677 if (TREE_CODE (TREE_TYPE (exp
)) == ARRAY_TYPE
)
2679 HOST_WIDE_INT size
= int_size_in_bytes (TREE_TYPE (exp
));
2680 obstack_grow (&permanent_obstack
, (char *) &size
, sizeof size
);
2683 for (link
= CONSTRUCTOR_ELTS (exp
); link
; link
= TREE_CHAIN (link
))
2685 if (TREE_VALUE (link
))
2686 record_constant_1 (TREE_VALUE (link
));
2691 obstack_grow (&permanent_obstack
,
2692 (char *) &zero
, sizeof zero
);
2695 if (TREE_PURPOSE (link
)
2696 && TREE_CODE (TREE_PURPOSE (link
)) == FIELD_DECL
)
2697 obstack_grow (&permanent_obstack
,
2698 (char *) &TREE_PURPOSE (link
),
2699 sizeof TREE_PURPOSE (link
));
2700 else if (TREE_PURPOSE (link
))
2701 record_constant_1 (TREE_PURPOSE (link
));
2702 else if (have_purpose
)
2706 obstack_grow (&permanent_obstack
,
2707 (char *) &zero
, sizeof zero
);
2715 struct addr_const value
;
2717 decode_addr_const (exp
, &value
);
2718 /* Record the offset. */
2719 obstack_grow (&permanent_obstack
,
2720 (char *) &value
.offset
, sizeof value
.offset
);
2721 /* Record the symbol name. */
2722 obstack_grow (&permanent_obstack
, XSTR (value
.base
, 0),
2723 strlen (XSTR (value
.base
, 0)) + 1);
2730 record_constant_1 (TREE_OPERAND (exp
, 0));
2731 record_constant_1 (TREE_OPERAND (exp
, 1));
2736 case NON_LVALUE_EXPR
:
2737 record_constant_1 (TREE_OPERAND (exp
, 0));
2744 /* Record constant contents. */
2745 obstack_grow (&permanent_obstack
, strp
, len
);
2748 /* Record a list of constant expressions that were passed to
2749 output_constant_def but that could not be output right away. */
2751 struct deferred_constant
2753 struct deferred_constant
*next
;
2759 static struct deferred_constant
*deferred_constants
;
2761 /* Another list of constants which should be output after the
2763 static struct deferred_constant
*after_function_constants
;
2765 /* Nonzero means defer output of addressed subconstants
2766 (i.e., those for which output_constant_def is called.) */
2767 static int defer_addressed_constants_flag
;
2769 /* Start deferring output of subconstants. */
2772 defer_addressed_constants ()
2774 defer_addressed_constants_flag
++;
2777 /* Stop deferring output of subconstants,
2778 and output now all those that have been deferred. */
2781 output_deferred_addressed_constants ()
2783 struct deferred_constant
*p
, *next
;
2785 defer_addressed_constants_flag
--;
2787 if (defer_addressed_constants_flag
> 0)
2790 for (p
= deferred_constants
; p
; p
= next
)
2792 output_constant_def_contents (p
->exp
, p
->reloc
, p
->labelno
);
2797 deferred_constants
= 0;
2800 /* Output any constants which should appear after a function. */
2803 output_after_function_constants ()
2805 struct deferred_constant
*p
, *next
;
2807 for (p
= after_function_constants
; p
; p
= next
)
2809 output_constant_def_contents (p
->exp
, p
->reloc
, p
->labelno
);
2814 after_function_constants
= 0;
2817 /* Make a copy of the whole tree structure for a constant.
2818 This handles the same types of nodes that compare_constant
2819 and record_constant handle. */
2825 switch (TREE_CODE (exp
))
2828 /* For ADDR_EXPR, we do not want to copy the decl whose address
2829 is requested. We do want to copy constants though. */
2830 if (TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp
, 0))) == 'c')
2831 return build1 (TREE_CODE (exp
), TREE_TYPE (exp
),
2832 copy_constant (TREE_OPERAND (exp
, 0)));
2834 return copy_node (exp
);
2839 return copy_node (exp
);
2842 return build_complex (TREE_TYPE (exp
),
2843 copy_constant (TREE_REALPART (exp
)),
2844 copy_constant (TREE_IMAGPART (exp
)));
2848 return build (TREE_CODE (exp
), TREE_TYPE (exp
),
2849 copy_constant (TREE_OPERAND (exp
, 0)),
2850 copy_constant (TREE_OPERAND (exp
, 1)));
2854 case NON_LVALUE_EXPR
:
2855 return build1 (TREE_CODE (exp
), TREE_TYPE (exp
),
2856 copy_constant (TREE_OPERAND (exp
, 0)));
2860 tree copy
= copy_node (exp
);
2861 tree list
= copy_list (CONSTRUCTOR_ELTS (exp
));
2864 CONSTRUCTOR_ELTS (copy
) = list
;
2865 for (tail
= list
; tail
; tail
= TREE_CHAIN (tail
))
2866 TREE_VALUE (tail
) = copy_constant (TREE_VALUE (tail
));
2867 if (TREE_CODE (TREE_TYPE (exp
)) == SET_TYPE
)
2868 for (tail
= list
; tail
; tail
= TREE_CHAIN (tail
))
2869 TREE_PURPOSE (tail
) = copy_constant (TREE_PURPOSE (tail
));
2879 /* Return an rtx representing a reference to constant data in memory
2880 for the constant expression EXP.
2882 If assembler code for such a constant has already been output,
2883 return an rtx to refer to it.
2884 Otherwise, output such a constant in memory (or defer it for later)
2885 and generate an rtx for it.
2887 The TREE_CST_RTL of EXP is set up to point to that rtx.
2888 The const_hash_table records which constants already have label strings. */
2891 output_constant_def (exp
)
2895 register struct constant_descriptor
*desc
;
2901 if (TREE_CST_RTL (exp
))
2902 return TREE_CST_RTL (exp
);
2904 /* Make sure any other constants whose addresses appear in EXP
2905 are assigned label numbers. */
2907 reloc
= output_addressed_constants (exp
);
2909 /* Compute hash code of EXP. Search the descriptors for that hash code
2910 to see if any of them describes EXP. If yes, the descriptor records
2911 the label number already assigned. */
2913 hash
= const_hash (exp
) % MAX_HASH_TABLE
;
2915 for (desc
= const_hash_table
[hash
]; desc
; desc
= desc
->next
)
2916 if (compare_constant (exp
, desc
))
2918 found
= desc
->label
;
2924 /* No constant equal to EXP is known to have been output.
2925 Make a constant descriptor to enter EXP in the hash table.
2926 Assign the label number and record it in the descriptor for
2927 future calls to this function to find. */
2929 /* Create a string containing the label name, in LABEL. */
2930 ASM_GENERATE_INTERNAL_LABEL (label
, "LC", const_labelno
);
2932 desc
= record_constant (exp
);
2933 desc
->next
= const_hash_table
[hash
];
2935 = (char *) obstack_copy0 (&permanent_obstack
, label
, strlen (label
));
2936 const_hash_table
[hash
] = desc
;
2940 /* Create a string containing the label name, in LABEL. */
2941 ASM_GENERATE_INTERNAL_LABEL (label
, "LC", const_labelno
);
2944 /* We have a symbol name; construct the SYMBOL_REF and the MEM. */
2946 push_obstacks_nochange ();
2947 if (TREE_PERMANENT (exp
))
2948 end_temporary_allocation ();
2950 def
= gen_rtx_SYMBOL_REF (Pmode
, desc
->label
);
2953 = gen_rtx_MEM (TYPE_MODE (TREE_TYPE (exp
)), def
);
2954 RTX_UNCHANGING_P (TREE_CST_RTL (exp
)) = 1;
2955 if (AGGREGATE_TYPE_P (TREE_TYPE (exp
)))
2956 MEM_IN_STRUCT_P (TREE_CST_RTL (exp
)) = 1;
2960 /* Optionally set flags or add text to the name to record information
2961 such as that it is a function name. If the name is changed, the macro
2962 ASM_OUTPUT_LABELREF will have to know how to strip this information. */
2963 #ifdef ENCODE_SECTION_INFO
2964 ENCODE_SECTION_INFO (exp
);
2967 /* If this is the first time we've seen this particular constant,
2968 output it (or defer its output for later). */
2971 int after_function
= 0;
2973 #ifdef CONSTANT_AFTER_FUNCTION_P
2974 if (current_function_decl
!= 0
2975 && CONSTANT_AFTER_FUNCTION_P (exp
))
2979 if (defer_addressed_constants_flag
|| after_function
)
2981 struct deferred_constant
*p
;
2982 p
= (struct deferred_constant
*) xmalloc (sizeof (struct deferred_constant
));
2984 push_obstacks_nochange ();
2985 suspend_momentary ();
2986 p
->exp
= copy_constant (exp
);
2989 p
->labelno
= const_labelno
++;
2992 p
->next
= after_function_constants
;
2993 after_function_constants
= p
;
2997 p
->next
= deferred_constants
;
2998 deferred_constants
= p
;
3002 output_constant_def_contents (exp
, reloc
, const_labelno
++);
3005 return TREE_CST_RTL (exp
);
3008 /* Now output assembler code to define the label for EXP,
3009 and follow it with the data of EXP. */
3012 output_constant_def_contents (exp
, reloc
, labelno
)
3019 if (IN_NAMED_SECTION (exp
))
3020 named_section (exp
, NULL
, reloc
);
3023 /* First switch to text section, except for writable strings. */
3024 #ifdef SELECT_SECTION
3025 SELECT_SECTION (exp
, reloc
);
3027 if (((TREE_CODE (exp
) == STRING_CST
) && flag_writable_strings
)
3028 || (flag_pic
&& reloc
))
3031 readonly_data_section ();
3035 /* Align the location counter as required by EXP's data type. */
3036 align
= TYPE_ALIGN (TREE_TYPE (exp
));
3037 #ifdef CONSTANT_ALIGNMENT
3038 align
= CONSTANT_ALIGNMENT (exp
, align
);
3041 if (align
> BITS_PER_UNIT
)
3042 ASM_OUTPUT_ALIGN (asm_out_file
, floor_log2 (align
/ BITS_PER_UNIT
));
3044 /* Output the label itself. */
3045 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, "LC", labelno
);
3047 /* Output the value of EXP. */
3048 output_constant (exp
,
3049 (TREE_CODE (exp
) == STRING_CST
3050 ? TREE_STRING_LENGTH (exp
)
3051 : int_size_in_bytes (TREE_TYPE (exp
))));
3055 /* Similar hash facility for making memory-constants
3056 from constant rtl-expressions. It is used on RISC machines
3057 where immediate integer arguments and constant addresses are restricted
3058 so that such constants must be stored in memory.
3060 This pool of constants is reinitialized for each function
3061 so each function gets its own constants-pool that comes right before it.
3063 All structures allocated here are discarded when functions are saved for
3064 inlining, so they do not need to be allocated permanently. */
3066 #define MAX_RTX_HASH_TABLE 61
3067 static struct constant_descriptor
**const_rtx_hash_table
;
3069 /* Structure to represent sufficient information about a constant so that
3070 it can be output when the constant pool is output, so that function
3071 integration can be done, and to simplify handling on machines that reference
3072 constant pool as base+displacement. */
3074 struct pool_constant
3076 struct constant_descriptor
*desc
;
3077 struct pool_constant
*next
;
3078 enum machine_mode mode
;
3086 /* Pointers to first and last constant in pool. */
3088 static struct pool_constant
*first_pool
, *last_pool
;
3090 /* Current offset in constant pool (does not include any machine-specific
3093 static int pool_offset
;
3095 /* Structure used to maintain hash table mapping symbols used to their
3096 corresponding constants. */
3101 struct pool_constant
*pool
;
3102 struct pool_sym
*next
;
3105 static struct pool_sym
**const_rtx_sym_hash_table
;
3107 /* Hash code for a SYMBOL_REF with CONSTANT_POOL_ADDRESS_P true.
3108 The argument is XSTR (... , 0) */
3110 #define SYMHASH(LABEL) \
3111 ((((unsigned long) (LABEL)) & ((1 << HASHBITS) - 1)) % MAX_RTX_HASH_TABLE)
3113 /* Initialize constant pool hashing for next function. */
3116 init_const_rtx_hash_table ()
3118 const_rtx_hash_table
3119 = ((struct constant_descriptor
**)
3120 oballoc (MAX_RTX_HASH_TABLE
* sizeof (struct constant_descriptor
*)));
3121 const_rtx_sym_hash_table
3122 = ((struct pool_sym
**)
3123 oballoc (MAX_RTX_HASH_TABLE
* sizeof (struct pool_sym
*)));
3124 bzero ((char *) const_rtx_hash_table
,
3125 MAX_RTX_HASH_TABLE
* sizeof (struct constant_descriptor
*));
3126 bzero ((char *) const_rtx_sym_hash_table
,
3127 MAX_RTX_HASH_TABLE
* sizeof (struct pool_sym
*));
3129 first_pool
= last_pool
= 0;
3133 /* Save and restore status for a nested function. */
3136 save_varasm_status (p
, context
)
3140 p
->const_rtx_hash_table
= const_rtx_hash_table
;
3141 p
->const_rtx_sym_hash_table
= const_rtx_sym_hash_table
;
3142 p
->first_pool
= first_pool
;
3143 p
->last_pool
= last_pool
;
3144 p
->pool_offset
= pool_offset
;
3145 p
->const_double_chain
= const_double_chain
;
3147 /* If we are pushing to toplevel, we can't reuse const_double_chain. */
3148 if (context
== NULL_TREE
)
3149 const_double_chain
= 0;
3153 restore_varasm_status (p
)
3156 const_rtx_hash_table
= p
->const_rtx_hash_table
;
3157 const_rtx_sym_hash_table
= p
->const_rtx_sym_hash_table
;
3158 first_pool
= p
->first_pool
;
3159 last_pool
= p
->last_pool
;
3160 pool_offset
= p
->pool_offset
;
3161 const_double_chain
= p
->const_double_chain
;
3164 enum kind
{ RTX_DOUBLE
, RTX_INT
};
3168 #ifdef ONLY_INT_FIELDS
3169 unsigned int kind
: 16;
3170 unsigned int mode
: 16;
3172 enum kind kind
: 16;
3173 enum machine_mode mode
: 16;
3176 union real_extract du
;
3177 struct addr_const addr
;
3178 struct {HOST_WIDE_INT high
, low
;} di
;
3182 /* Express an rtx for a constant integer (perhaps symbolic)
3183 as the sum of a symbol or label plus an explicit integer.
3184 They are stored into VALUE. */
3187 decode_rtx_const (mode
, x
, value
)
3188 enum machine_mode mode
;
3190 struct rtx_const
*value
;
3192 /* Clear the whole structure, including any gaps. */
3195 int *p
= (int *) value
;
3196 int *end
= (int *) (value
+ 1);
3201 value
->kind
= RTX_INT
; /* Most usual kind. */
3204 switch (GET_CODE (x
))
3207 value
->kind
= RTX_DOUBLE
;
3208 if (GET_MODE (x
) != VOIDmode
)
3210 value
->mode
= GET_MODE (x
);
3211 bcopy ((char *) &CONST_DOUBLE_LOW (x
),
3212 (char *) &value
->un
.du
, sizeof value
->un
.du
);
3216 value
->un
.di
.low
= CONST_DOUBLE_LOW (x
);
3217 value
->un
.di
.high
= CONST_DOUBLE_HIGH (x
);
3222 value
->un
.addr
.offset
= INTVAL (x
);
3228 value
->un
.addr
.base
= x
;
3233 if (GET_CODE (x
) == PLUS
)
3235 value
->un
.addr
.base
= XEXP (x
, 0);
3236 if (GET_CODE (XEXP (x
, 1)) != CONST_INT
)
3238 value
->un
.addr
.offset
= INTVAL (XEXP (x
, 1));
3240 else if (GET_CODE (x
) == MINUS
)
3242 value
->un
.addr
.base
= XEXP (x
, 0);
3243 if (GET_CODE (XEXP (x
, 1)) != CONST_INT
)
3245 value
->un
.addr
.offset
= - INTVAL (XEXP (x
, 1));
3255 if (value
->kind
== RTX_INT
&& value
->un
.addr
.base
!= 0)
3256 switch (GET_CODE (value
->un
.addr
.base
))
3260 /* Use the string's address, not the SYMBOL_REF's address,
3261 for the sake of addresses of library routines.
3262 For a LABEL_REF, compare labels. */
3263 value
->un
.addr
.base
= XEXP (value
->un
.addr
.base
, 0);
3270 /* Given a MINUS expression, simplify it if both sides
3271 include the same symbol. */
3274 simplify_subtraction (x
)
3277 struct rtx_const val0
, val1
;
3279 decode_rtx_const (GET_MODE (x
), XEXP (x
, 0), &val0
);
3280 decode_rtx_const (GET_MODE (x
), XEXP (x
, 1), &val1
);
3282 if (val0
.un
.addr
.base
== val1
.un
.addr
.base
)
3283 return GEN_INT (val0
.un
.addr
.offset
- val1
.un
.addr
.offset
);
3287 /* Compute a hash code for a constant RTL expression. */
3290 const_hash_rtx (mode
, x
)
3291 enum machine_mode mode
;
3297 struct rtx_const value
;
3298 decode_rtx_const (mode
, x
, &value
);
3300 /* Compute hashing function */
3302 for (i
= 0; i
< sizeof value
/ sizeof (int); i
++)
3303 hi
+= ((int *) &value
)[i
];
3305 hi
&= (1 << HASHBITS
) - 1;
3306 hi
%= MAX_RTX_HASH_TABLE
;
3310 /* Compare a constant rtl object X with a constant-descriptor DESC.
3311 Return 1 if DESC describes a constant with the same value as X. */
3314 compare_constant_rtx (mode
, x
, desc
)
3315 enum machine_mode mode
;
3317 struct constant_descriptor
*desc
;
3319 register int *p
= (int *) desc
->contents
;
3322 struct rtx_const value
;
3324 decode_rtx_const (mode
, x
, &value
);
3325 strp
= (int *) &value
;
3326 len
= sizeof value
/ sizeof (int);
3328 /* Compare constant contents. */
3330 if (*p
++ != *strp
++)
3336 /* Construct a constant descriptor for the rtl-expression X.
3337 It is up to the caller to enter the descriptor in the hash table. */
3339 static struct constant_descriptor
*
3340 record_constant_rtx (mode
, x
)
3341 enum machine_mode mode
;
3344 struct constant_descriptor
*ptr
;
3346 struct rtx_const value
;
3348 decode_rtx_const (mode
, x
, &value
);
3350 /* Put these things in the saveable obstack so we can ensure it won't
3351 be freed if we are called from combine or some other phase that discards
3352 memory allocated from function_obstack (current_obstack). */
3353 obstack_grow (saveable_obstack
, &ptr
, sizeof ptr
);
3354 obstack_grow (saveable_obstack
, &label
, sizeof label
);
3356 /* Record constant contents. */
3357 obstack_grow (saveable_obstack
, &value
, sizeof value
);
3359 return (struct constant_descriptor
*) obstack_finish (saveable_obstack
);
3362 /* Given a constant rtx X, make (or find) a memory constant for its value
3363 and return a MEM rtx to refer to it in memory. */
3366 force_const_mem (mode
, x
)
3367 enum machine_mode mode
;
3371 register struct constant_descriptor
*desc
;
3376 /* If we want this CONST_DOUBLE in the same mode as it is in memory
3377 (this will always be true for floating CONST_DOUBLEs that have been
3378 placed in memory, but not for VOIDmode (integer) CONST_DOUBLEs),
3379 use the previous copy. Otherwise, make a new one. Note that in
3380 the unlikely event that this same CONST_DOUBLE is used in two different
3381 modes in an alternating fashion, we will allocate a lot of different
3382 memory locations, but this should be extremely rare. */
3384 /* Don't use CONST_DOUBLE_MEM in a nested function.
3385 Nested functions have their own constant pools,
3386 so they can't share the same values in CONST_DOUBLE_MEM
3387 with the containing function. */
3388 if (outer_function_chain
== 0)
3389 if (GET_CODE (x
) == CONST_DOUBLE
3390 && GET_CODE (CONST_DOUBLE_MEM (x
)) == MEM
3391 && GET_MODE (CONST_DOUBLE_MEM (x
)) == mode
)
3392 return CONST_DOUBLE_MEM (x
);
3394 /* Compute hash code of X. Search the descriptors for that hash code
3395 to see if any of them describes X. If yes, the descriptor records
3396 the label number already assigned. */
3398 hash
= const_hash_rtx (mode
, x
);
3400 for (desc
= const_rtx_hash_table
[hash
]; desc
; desc
= desc
->next
)
3401 if (compare_constant_rtx (mode
, x
, desc
))
3403 found
= desc
->label
;
3409 register struct pool_constant
*pool
;
3410 register struct pool_sym
*sym
;
3413 /* No constant equal to X is known to have been output.
3414 Make a constant descriptor to enter X in the hash table.
3415 Assign the label number and record it in the descriptor for
3416 future calls to this function to find. */
3418 desc
= record_constant_rtx (mode
, x
);
3419 desc
->next
= const_rtx_hash_table
[hash
];
3420 const_rtx_hash_table
[hash
] = desc
;
3422 /* Align the location counter as required by EXP's data type. */
3423 align
= (mode
== VOIDmode
) ? UNITS_PER_WORD
: GET_MODE_SIZE (mode
);
3424 if (align
> BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
)
3425 align
= BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
;
3426 #ifdef CONSTANT_ALIGNMENT
3427 align
= CONSTANT_ALIGNMENT (make_tree (type_for_mode (mode
, 0), x
),
3428 align
* BITS_PER_UNIT
) / BITS_PER_UNIT
;
3431 pool_offset
+= align
- 1;
3432 pool_offset
&= ~ (align
- 1);
3434 /* If RTL is not being placed into the saveable obstack, make a
3435 copy of X that is in the saveable obstack in case we are
3436 being called from combine or some other phase that discards
3437 memory it allocates. We used to only do this if it is a
3438 CONST; however, reload can allocate a CONST_INT when
3439 eliminating registers. */
3440 if (rtl_obstack
!= saveable_obstack
3441 && (GET_CODE (x
) == CONST
|| GET_CODE (x
) == CONST_INT
))
3443 push_obstacks_nochange ();
3444 rtl_in_saveable_obstack ();
3446 if (GET_CODE (x
) == CONST
)
3447 x
= gen_rtx_CONST (GET_MODE (x
),
3448 gen_rtx_PLUS (GET_MODE (x
),
3449 XEXP (XEXP (x
, 0), 0),
3450 XEXP (XEXP (x
, 0), 1)));
3452 x
= GEN_INT (INTVAL (x
));
3457 /* Allocate a pool constant descriptor, fill it in, and chain it in. */
3459 pool
= (struct pool_constant
*) savealloc (sizeof (struct pool_constant
));
3463 pool
->labelno
= const_labelno
;
3464 pool
->align
= align
;
3465 pool
->offset
= pool_offset
;
3472 last_pool
->next
= pool
;
3475 pool_offset
+= GET_MODE_SIZE (mode
);
3477 /* Create a string containing the label name, in LABEL. */
3478 ASM_GENERATE_INTERNAL_LABEL (label
, "LC", const_labelno
);
3483 = (char *) obstack_copy0 (saveable_obstack
, label
, strlen (label
));
3485 /* Add label to symbol hash table. */
3486 hash
= SYMHASH (found
);
3487 sym
= (struct pool_sym
*) savealloc (sizeof (struct pool_sym
));
3490 sym
->next
= const_rtx_sym_hash_table
[hash
];
3491 const_rtx_sym_hash_table
[hash
] = sym
;
3494 /* We have a symbol name; construct the SYMBOL_REF and the MEM. */
3496 def
= gen_rtx_MEM (mode
, gen_rtx_SYMBOL_REF (Pmode
, found
));
3498 RTX_UNCHANGING_P (def
) = 1;
3499 /* Mark the symbol_ref as belonging to this constants pool. */
3500 CONSTANT_POOL_ADDRESS_P (XEXP (def
, 0)) = 1;
3501 current_function_uses_const_pool
= 1;
3503 if (outer_function_chain
== 0)
3504 if (GET_CODE (x
) == CONST_DOUBLE
)
3506 if (CONST_DOUBLE_MEM (x
) == cc0_rtx
)
3508 CONST_DOUBLE_CHAIN (x
) = const_double_chain
;
3509 const_double_chain
= x
;
3511 CONST_DOUBLE_MEM (x
) = def
;
3517 /* Given a SYMBOL_REF with CONSTANT_POOL_ADDRESS_P true, return a pointer to
3518 the corresponding pool_constant structure. */
3520 static struct pool_constant
*
3521 find_pool_constant (addr
)
3524 struct pool_sym
*sym
;
3525 char *label
= XSTR (addr
, 0);
3527 for (sym
= const_rtx_sym_hash_table
[SYMHASH (label
)]; sym
; sym
= sym
->next
)
3528 if (sym
->label
== label
)
3534 /* Given a constant pool SYMBOL_REF, return the corresponding constant. */
3537 get_pool_constant (addr
)
3540 return (find_pool_constant (addr
))->constant
;
3543 /* Similar, return the mode. */
3546 get_pool_mode (addr
)
3549 return (find_pool_constant (addr
))->mode
;
3552 /* Similar, return the offset in the constant pool. */
3555 get_pool_offset (addr
)
3558 return (find_pool_constant (addr
))->offset
;
3561 /* Return the size of the constant pool. */
3569 /* Write all the constants in the constant pool. */
3572 output_constant_pool (fnname
, fndecl
)
3576 struct pool_constant
*pool
;
3578 union real_extract u
;
3580 /* It is possible for gcc to call force_const_mem and then to later
3581 discard the instructions which refer to the constant. In such a
3582 case we do not need to output the constant. */
3583 if (optimize
>= 0 && flag_expensive_optimizations
)
3584 mark_constant_pool ();
3586 #ifdef ASM_OUTPUT_POOL_PROLOGUE
3587 ASM_OUTPUT_POOL_PROLOGUE (asm_out_file
, fnname
, fndecl
, pool_offset
);
3590 for (pool
= first_pool
; pool
; pool
= pool
->next
)
3597 /* See if X is a LABEL_REF (or a CONST referring to a LABEL_REF)
3598 whose CODE_LABEL has been deleted. This can occur if a jump table
3599 is eliminated by optimization. If so, write a constant of zero
3600 instead. Note that this can also happen by turning the
3601 CODE_LABEL into a NOTE. */
3602 if (((GET_CODE (x
) == LABEL_REF
3603 && (INSN_DELETED_P (XEXP (x
, 0))
3604 || GET_CODE (XEXP (x
, 0)) == NOTE
)))
3605 || (GET_CODE (x
) == CONST
&& GET_CODE (XEXP (x
, 0)) == PLUS
3606 && GET_CODE (XEXP (XEXP (x
, 0), 0)) == LABEL_REF
3607 && (INSN_DELETED_P (XEXP (XEXP (XEXP (x
, 0), 0), 0))
3608 || GET_CODE (XEXP (XEXP (XEXP (x
, 0), 0), 0)) == NOTE
)))
3611 /* First switch to correct section. */
3612 #ifdef SELECT_RTX_SECTION
3613 SELECT_RTX_SECTION (pool
->mode
, x
);
3615 readonly_data_section ();
3618 #ifdef ASM_OUTPUT_SPECIAL_POOL_ENTRY
3619 ASM_OUTPUT_SPECIAL_POOL_ENTRY (asm_out_file
, x
, pool
->mode
,
3620 pool
->align
, pool
->labelno
, done
);
3623 if (pool
->align
> 1)
3624 ASM_OUTPUT_ALIGN (asm_out_file
, exact_log2 (pool
->align
));
3626 /* Output the label. */
3627 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, "LC", pool
->labelno
);
3629 /* Output the value of the constant itself. */
3630 switch (GET_MODE_CLASS (pool
->mode
))
3633 if (GET_CODE (x
) != CONST_DOUBLE
)
3636 bcopy ((char *) &CONST_DOUBLE_LOW (x
), (char *) &u
, sizeof u
);
3637 assemble_real (u
.d
, pool
->mode
);
3641 case MODE_PARTIAL_INT
:
3642 assemble_integer (x
, GET_MODE_SIZE (pool
->mode
), 1);
3649 #ifdef ASM_OUTPUT_SPECIAL_POOL_ENTRY
3655 #ifdef ASM_OUTPUT_POOL_EPILOGUE
3656 ASM_OUTPUT_POOL_EPILOGUE (asm_out_file
, fnname
, fndecl
, pool_offset
);
3659 /* Done with this pool. */
3660 first_pool
= last_pool
= 0;
3663 /* Look through the instructions for this function, and mark all the
3664 entries in the constant pool which are actually being used. */
3667 mark_constant_pool ()
3670 struct pool_constant
*pool
;
3672 if (first_pool
== 0)
3675 for (pool
= first_pool
; pool
; pool
= pool
->next
)
3678 for (insn
= get_insns (); insn
; insn
= NEXT_INSN (insn
))
3679 if (GET_RTX_CLASS (GET_CODE (insn
)) == 'i')
3680 mark_constants (PATTERN (insn
));
3682 for (insn
= current_function_epilogue_delay_list
;
3684 insn
= XEXP (insn
, 1))
3685 if (GET_RTX_CLASS (GET_CODE (insn
)) == 'i')
3686 mark_constants (PATTERN (insn
));
3694 register char *format_ptr
;
3699 if (GET_CODE (x
) == SYMBOL_REF
)
3701 if (CONSTANT_POOL_ADDRESS_P (x
))
3702 find_pool_constant (x
)->mark
= 1;
3705 /* Never search inside a CONST_DOUBLE, because CONST_DOUBLE_MEM may be
3706 a MEM, but does not constitute a use of that MEM. This is particularly
3707 important inside a nested function, because CONST_DOUBLE_MEM may be
3708 a reference to a MEM in the parent's constant pool. See the comment
3709 in force_const_mem. */
3710 else if (GET_CODE (x
) == CONST_DOUBLE
)
3713 /* Insns may appear inside a SEQUENCE. Only check the patterns of
3714 insns, not any notes that may be attached. We don't want to mark
3715 a constant just because it happens to appear in a REG_EQUIV note. */
3716 if (GET_RTX_CLASS (GET_CODE (x
)) == 'i')
3718 mark_constants (PATTERN (x
));
3722 format_ptr
= GET_RTX_FORMAT (GET_CODE (x
));
3724 for (i
= 0; i
< GET_RTX_LENGTH (GET_CODE (x
)); i
++)
3726 switch (*format_ptr
++)
3729 mark_constants (XEXP (x
, i
));
3733 if (XVEC (x
, i
) != 0)
3737 for (j
= 0; j
< XVECLEN (x
, i
); j
++)
3738 mark_constants (XVECEXP (x
, i
, j
));
3757 /* Find all the constants whose addresses are referenced inside of EXP,
3758 and make sure assembler code with a label has been output for each one.
3759 Indicate whether an ADDR_EXPR has been encountered. */
3762 output_addressed_constants (exp
)
3767 switch (TREE_CODE (exp
))
3771 register tree constant
= TREE_OPERAND (exp
, 0);
3773 while (TREE_CODE (constant
) == COMPONENT_REF
)
3775 constant
= TREE_OPERAND (constant
, 0);
3778 if (TREE_CODE_CLASS (TREE_CODE (constant
)) == 'c'
3779 || TREE_CODE (constant
) == CONSTRUCTOR
)
3780 /* No need to do anything here
3781 for addresses of variables or functions. */
3782 output_constant_def (constant
);
3789 reloc
= output_addressed_constants (TREE_OPERAND (exp
, 0));
3790 reloc
|= output_addressed_constants (TREE_OPERAND (exp
, 1));
3795 case NON_LVALUE_EXPR
:
3796 reloc
= output_addressed_constants (TREE_OPERAND (exp
, 0));
3802 for (link
= CONSTRUCTOR_ELTS (exp
); link
; link
= TREE_CHAIN (link
))
3803 if (TREE_VALUE (link
) != 0)
3804 reloc
|= output_addressed_constants (TREE_VALUE (link
));
3814 /* Output assembler code for constant EXP to FILE, with no label.
3815 This includes the pseudo-op such as ".int" or ".byte", and a newline.
3816 Assumes output_addressed_constants has been done on EXP already.
3818 Generate exactly SIZE bytes of assembler data, padding at the end
3819 with zeros if necessary. SIZE must always be specified.
3821 SIZE is important for structure constructors,
3822 since trailing members may have been omitted from the constructor.
3823 It is also important for initialization of arrays from string constants
3824 since the full length of the string constant might not be wanted.
3825 It is also needed for initialization of unions, where the initializer's
3826 type is just one member, and that may not be as long as the union.
3828 There a case in which we would fail to output exactly SIZE bytes:
3829 for a structure constructor that wants to produce more than SIZE bytes.
3830 But such constructors will never be generated for any possible input. */
3833 output_constant (exp
, size
)
3837 register enum tree_code code
= TREE_CODE (TREE_TYPE (exp
));
3842 /* Eliminate the NON_LVALUE_EXPR_EXPR that makes a cast not be an lvalue.
3843 That way we get the constant (we hope) inside it. Also, strip off any
3844 NOP_EXPR that converts between two record, union, array, or set types. */
3845 while ((TREE_CODE (exp
) == NOP_EXPR
3846 && (TREE_TYPE (exp
) == TREE_TYPE (TREE_OPERAND (exp
, 0))
3847 || AGGREGATE_TYPE_P (TREE_TYPE (exp
))))
3848 || TREE_CODE (exp
) == NON_LVALUE_EXPR
)
3849 exp
= TREE_OPERAND (exp
, 0);
3851 /* Allow a constructor with no elements for any data type.
3852 This means to fill the space with zeros. */
3853 if (TREE_CODE (exp
) == CONSTRUCTOR
&& CONSTRUCTOR_ELTS (exp
) == 0)
3855 assemble_zeros (size
);
3866 case REFERENCE_TYPE
:
3867 /* ??? What about (int)((float)(int)&foo + 4) */
3868 while (TREE_CODE (exp
) == NOP_EXPR
|| TREE_CODE (exp
) == CONVERT_EXPR
3869 || TREE_CODE (exp
) == NON_LVALUE_EXPR
)
3870 exp
= TREE_OPERAND (exp
, 0);
3872 if (! assemble_integer (expand_expr (exp
, NULL_RTX
, VOIDmode
,
3873 EXPAND_INITIALIZER
),
3875 error ("initializer for integer value is too complicated");
3880 if (TREE_CODE (exp
) != REAL_CST
)
3881 error ("initializer for floating value is not a floating constant");
3883 assemble_real (TREE_REAL_CST (exp
),
3884 mode_for_size (size
* BITS_PER_UNIT
, MODE_FLOAT
, 0));
3889 output_constant (TREE_REALPART (exp
), size
/ 2);
3890 output_constant (TREE_IMAGPART (exp
), size
/ 2);
3891 size
-= (size
/ 2) * 2;
3895 if (TREE_CODE (exp
) == CONSTRUCTOR
)
3897 output_constructor (exp
, size
);
3900 else if (TREE_CODE (exp
) == STRING_CST
)
3904 if (size
> TREE_STRING_LENGTH (exp
))
3906 excess
= size
- TREE_STRING_LENGTH (exp
);
3907 size
= TREE_STRING_LENGTH (exp
);
3910 assemble_string (TREE_STRING_POINTER (exp
), size
);
3919 if (TREE_CODE (exp
) == CONSTRUCTOR
)
3920 output_constructor (exp
, size
);
3926 if (TREE_CODE (exp
) == INTEGER_CST
)
3927 assemble_integer (expand_expr (exp
, NULL_RTX
,
3928 VOIDmode
, EXPAND_INITIALIZER
),
3930 else if (TREE_CODE (exp
) == CONSTRUCTOR
)
3932 unsigned char *buffer
= (unsigned char *) alloca (size
);
3933 if (get_set_constructor_bytes (exp
, buffer
, size
))
3935 assemble_string ((char *) buffer
, size
);
3938 error ("unknown set constructor type");
3946 assemble_zeros (size
);
3950 /* Subroutine of output_constant, used for CONSTRUCTORs
3951 (aggregate constants).
3952 Generate at least SIZE bytes, padding if necessary. */
3955 output_constructor (exp
, size
)
3959 register tree link
, field
= 0;
3960 HOST_WIDE_INT min_index
= 0;
3961 /* Number of bytes output or skipped so far.
3962 In other words, current position within the constructor. */
3963 int total_bytes
= 0;
3964 /* Non-zero means BYTE contains part of a byte, to be output. */
3965 int byte_buffer_in_use
= 0;
3968 if (HOST_BITS_PER_WIDE_INT
< BITS_PER_UNIT
)
3971 if (TREE_CODE (TREE_TYPE (exp
)) == RECORD_TYPE
)
3972 field
= TYPE_FIELDS (TREE_TYPE (exp
));
3974 if (TREE_CODE (TREE_TYPE (exp
)) == ARRAY_TYPE
3975 && TYPE_DOMAIN (TREE_TYPE (exp
)) != 0)
3977 = TREE_INT_CST_LOW (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (exp
))));
3979 /* As LINK goes through the elements of the constant,
3980 FIELD goes through the structure fields, if the constant is a structure.
3981 if the constant is a union, then we override this,
3982 by getting the field from the TREE_LIST element.
3983 But the constant could also be an array. Then FIELD is zero. */
3984 for (link
= CONSTRUCTOR_ELTS (exp
);
3986 link
= TREE_CHAIN (link
),
3987 field
= field
? TREE_CHAIN (field
) : 0)
3989 tree val
= TREE_VALUE (link
);
3992 /* the element in a union constructor specifies the proper field. */
3994 if (TREE_CODE (TREE_TYPE (exp
)) == RECORD_TYPE
3995 || TREE_CODE (TREE_TYPE (exp
)) == UNION_TYPE
)
3997 /* if available, use the type given by link */
3998 if (TREE_PURPOSE (link
) != 0)
3999 field
= TREE_PURPOSE (link
);
4002 if (TREE_CODE (TREE_TYPE (exp
)) == ARRAY_TYPE
)
4003 index
= TREE_PURPOSE (link
);
4005 /* Eliminate the marker that makes a cast not be an lvalue. */
4009 if (index
&& TREE_CODE (index
) == RANGE_EXPR
)
4011 register int fieldsize
4012 = int_size_in_bytes (TREE_TYPE (TREE_TYPE (exp
)));
4013 HOST_WIDE_INT lo_index
= TREE_INT_CST_LOW (TREE_OPERAND (index
, 0));
4014 HOST_WIDE_INT hi_index
= TREE_INT_CST_LOW (TREE_OPERAND (index
, 1));
4015 HOST_WIDE_INT index
;
4016 for (index
= lo_index
; index
<= hi_index
; index
++)
4018 /* Output the element's initial value. */
4020 assemble_zeros (fieldsize
);
4022 output_constant (val
, fieldsize
);
4024 /* Count its size. */
4025 total_bytes
+= fieldsize
;
4028 else if (field
== 0 || !DECL_BIT_FIELD (field
))
4030 /* An element that is not a bit-field. */
4032 register int fieldsize
;
4033 /* Since this structure is static,
4034 we know the positions are constant. */
4035 int bitpos
= (field
? (TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field
))
4039 bitpos
= (TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (val
)))
4041 * (TREE_INT_CST_LOW (index
) - min_index
));
4043 /* Output any buffered-up bit-fields preceding this element. */
4044 if (byte_buffer_in_use
)
4046 ASM_OUTPUT_BYTE (asm_out_file
, byte
);
4048 byte_buffer_in_use
= 0;
4051 /* Advance to offset of this element.
4052 Note no alignment needed in an array, since that is guaranteed
4053 if each element has the proper size. */
4054 if ((field
!= 0 || index
!= 0) && bitpos
!= total_bytes
)
4056 assemble_zeros (bitpos
- total_bytes
);
4057 total_bytes
= bitpos
;
4060 /* Determine size this element should occupy. */
4063 if (TREE_CODE (DECL_SIZE (field
)) != INTEGER_CST
)
4065 if (TREE_INT_CST_LOW (DECL_SIZE (field
)) > 100000)
4067 /* This avoids overflow trouble. */
4068 tree size_tree
= size_binop (CEIL_DIV_EXPR
,
4070 size_int (BITS_PER_UNIT
));
4071 fieldsize
= TREE_INT_CST_LOW (size_tree
);
4075 fieldsize
= TREE_INT_CST_LOW (DECL_SIZE (field
));
4076 fieldsize
= (fieldsize
+ BITS_PER_UNIT
- 1) / BITS_PER_UNIT
;
4080 fieldsize
= int_size_in_bytes (TREE_TYPE (TREE_TYPE (exp
)));
4082 /* Output the element's initial value. */
4084 assemble_zeros (fieldsize
);
4086 output_constant (val
, fieldsize
);
4088 /* Count its size. */
4089 total_bytes
+= fieldsize
;
4091 else if (val
!= 0 && TREE_CODE (val
) != INTEGER_CST
)
4092 error ("invalid initial value for member `%s'",
4093 IDENTIFIER_POINTER (DECL_NAME (field
)));
4096 /* Element that is a bit-field. */
4098 int next_offset
= TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field
));
4100 = (next_offset
+ TREE_INT_CST_LOW (DECL_SIZE (field
)));
4103 val
= integer_zero_node
;
4105 /* If this field does not start in this (or, next) byte,
4107 if (next_offset
/ BITS_PER_UNIT
!= total_bytes
)
4109 /* Output remnant of any bit field in previous bytes. */
4110 if (byte_buffer_in_use
)
4112 ASM_OUTPUT_BYTE (asm_out_file
, byte
);
4114 byte_buffer_in_use
= 0;
4117 /* If still not at proper byte, advance to there. */
4118 if (next_offset
/ BITS_PER_UNIT
!= total_bytes
)
4120 assemble_zeros (next_offset
/ BITS_PER_UNIT
- total_bytes
);
4121 total_bytes
= next_offset
/ BITS_PER_UNIT
;
4125 if (! byte_buffer_in_use
)
4128 /* We must split the element into pieces that fall within
4129 separate bytes, and combine each byte with previous or
4130 following bit-fields. */
4132 /* next_offset is the offset n fbits from the beginning of
4133 the structure to the next bit of this element to be processed.
4134 end_offset is the offset of the first bit past the end of
4136 while (next_offset
< end_offset
)
4140 HOST_WIDE_INT value
;
4141 int next_byte
= next_offset
/ BITS_PER_UNIT
;
4142 int next_bit
= next_offset
% BITS_PER_UNIT
;
4144 /* Advance from byte to byte
4145 within this element when necessary. */
4146 while (next_byte
!= total_bytes
)
4148 ASM_OUTPUT_BYTE (asm_out_file
, byte
);
4153 /* Number of bits we can process at once
4154 (all part of the same byte). */
4155 this_time
= MIN (end_offset
- next_offset
,
4156 BITS_PER_UNIT
- next_bit
);
4157 if (BYTES_BIG_ENDIAN
)
4159 /* On big-endian machine, take the most significant bits
4160 first (of the bits that are significant)
4161 and put them into bytes from the most significant end. */
4162 shift
= end_offset
- next_offset
- this_time
;
4163 /* Don't try to take a bunch of bits that cross
4164 the word boundary in the INTEGER_CST. */
4165 if (shift
< HOST_BITS_PER_WIDE_INT
4166 && shift
+ this_time
> HOST_BITS_PER_WIDE_INT
)
4168 this_time
-= (HOST_BITS_PER_WIDE_INT
- shift
);
4169 shift
= HOST_BITS_PER_WIDE_INT
;
4172 /* Now get the bits from the appropriate constant word. */
4173 if (shift
< HOST_BITS_PER_WIDE_INT
)
4175 value
= TREE_INT_CST_LOW (val
);
4177 else if (shift
< 2 * HOST_BITS_PER_WIDE_INT
)
4179 value
= TREE_INT_CST_HIGH (val
);
4180 shift
-= HOST_BITS_PER_WIDE_INT
;
4184 byte
|= (((value
>> shift
)
4185 & (((HOST_WIDE_INT
) 1 << this_time
) - 1))
4186 << (BITS_PER_UNIT
- this_time
- next_bit
));
4190 /* On little-endian machines,
4191 take first the least significant bits of the value
4192 and pack them starting at the least significant
4193 bits of the bytes. */
4194 shift
= (next_offset
4195 - TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field
)));
4196 /* Don't try to take a bunch of bits that cross
4197 the word boundary in the INTEGER_CST. */
4198 if (shift
< HOST_BITS_PER_WIDE_INT
4199 && shift
+ this_time
> HOST_BITS_PER_WIDE_INT
)
4201 this_time
-= (HOST_BITS_PER_WIDE_INT
- shift
);
4202 shift
= HOST_BITS_PER_WIDE_INT
;
4205 /* Now get the bits from the appropriate constant word. */
4206 if (shift
< HOST_BITS_PER_WIDE_INT
)
4207 value
= TREE_INT_CST_LOW (val
);
4208 else if (shift
< 2 * HOST_BITS_PER_WIDE_INT
)
4210 value
= TREE_INT_CST_HIGH (val
);
4211 shift
-= HOST_BITS_PER_WIDE_INT
;
4215 byte
|= (((value
>> shift
)
4216 & (((HOST_WIDE_INT
) 1 << this_time
) - 1))
4219 next_offset
+= this_time
;
4220 byte_buffer_in_use
= 1;
4224 if (byte_buffer_in_use
)
4226 ASM_OUTPUT_BYTE (asm_out_file
, byte
);
4229 if (total_bytes
< size
)
4230 assemble_zeros (size
- total_bytes
);
4233 /* Declare DECL to be a weak symbol. */
4239 if (! TREE_PUBLIC (decl
))
4240 error_with_decl (decl
, "weak declaration of `%s' must be public");
4241 else if (TREE_ASM_WRITTEN (decl
))
4242 error_with_decl (decl
, "weak declaration of `%s' must precede definition");
4243 else if (SUPPORTS_WEAK
)
4244 DECL_WEAK (decl
) = 1;
4247 /* Emit any pending weak declarations. */
4249 #ifdef HANDLE_PRAGMA_WEAK
4250 struct weak_syms
* weak_decls
;
4256 #ifdef HANDLE_PRAGMA_WEAK
4257 if (HANDLE_PRAGMA_WEAK
)
4259 struct weak_syms
*t
;
4260 for (t
= weak_decls
; t
; t
= t
->next
)
4262 ASM_GLOBALIZE_LABEL (asm_out_file
, t
->name
);
4263 ASM_WEAKEN_LABEL (asm_out_file
, t
->name
);
4265 ASM_OUTPUT_DEF (asm_out_file
, t
->name
, t
->value
);
4272 assemble_alias (decl
, target
)
4277 make_decl_rtl (decl
, (char *) 0, 1);
4278 name
= XSTR (XEXP (DECL_RTL (decl
), 0), 0);
4280 #ifdef ASM_OUTPUT_DEF
4281 /* Make name accessible from other files, if appropriate. */
4283 if (TREE_PUBLIC (decl
))
4285 ASM_GLOBALIZE_LABEL (asm_out_file
, name
);
4286 #ifdef ASM_WEAKEN_LABEL
4287 if (DECL_WEAK (decl
))
4288 ASM_WEAKEN_LABEL (asm_out_file
, name
);
4292 ASM_OUTPUT_DEF (asm_out_file
, name
, IDENTIFIER_POINTER (target
));
4293 TREE_ASM_WRITTEN (decl
) = 1;
4295 #ifdef ASM_OUTPUT_WEAK_ALIAS
4296 if (! DECL_WEAK (decl
))
4297 warning ("only weak aliases are supported in this configuration");
4299 ASM_OUTPUT_WEAK_ALIAS (asm_out_file
, name
, IDENTIFIER_POINTER (target
));
4300 TREE_ASM_WRITTEN (decl
) = 1;
4302 warning ("alias definitions not supported in this configuration; ignored");
4307 /* This determines whether or not we support link-once semantics. */
4308 #ifndef SUPPORTS_ONE_ONLY
4309 #ifdef MAKE_DECL_ONE_ONLY
4310 #define SUPPORTS_ONE_ONLY 1
4312 #define SUPPORTS_ONE_ONLY 0
4316 /* Returns 1 if the target configuration supports defining public symbols
4317 so that one of them will be chosen at link time instead of generating a
4318 multiply-defined symbol error, whether through the use of weak symbols or
4319 a target-specific mechanism for having duplicates discarded. */
4322 supports_one_only ()
4324 if (SUPPORTS_ONE_ONLY
)
4326 return SUPPORTS_WEAK
;
4329 /* Set up DECL as a public symbol that can be defined in multiple
4330 translation units without generating a linker error. */
4333 make_decl_one_only (decl
)
4336 if (TREE_CODE (decl
) != VAR_DECL
&& TREE_CODE (decl
) != FUNCTION_DECL
)
4339 TREE_PUBLIC (decl
) = 1;
4341 if (TREE_CODE (decl
) == VAR_DECL
4342 && (DECL_INITIAL (decl
) == 0 || DECL_INITIAL (decl
) == error_mark_node
))
4343 DECL_COMMON (decl
) = 1;
4344 else if (SUPPORTS_ONE_ONLY
)
4346 #ifdef MAKE_DECL_ONE_ONLY
4347 MAKE_DECL_ONE_ONLY (decl
);
4349 DECL_ONE_ONLY (decl
) = 1;
4351 else if (SUPPORTS_WEAK
)
4352 DECL_WEAK (decl
) = 1;