1 /* Output variables, constants and external declarations, for GNU compiler.
2 Copyright (C) 1987, 88, 89, 92-7, 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"
48 #ifdef XCOFF_DEBUGGING_INFO
52 #ifndef TRAMPOLINE_ALIGNMENT
53 #define TRAMPOLINE_ALIGNMENT FUNCTION_BOUNDARY
57 #define ASM_STABS_OP ".stabs"
60 /* Define the prefix to use when check_memory_usage_flag is enable. */
61 #ifdef NO_DOLLAR_IN_LABEL
62 #ifdef NO_DOT_IN_LABEL
63 #define CHKR_PREFIX "chkr_prefix_"
64 #else /* !NO_DOT_IN_LABEL */
65 #define CHKR_PREFIX "chkr."
67 #else /* !NO_DOLLAR_IN_LABEL */
68 #define CHKR_PREFIX "chkr$"
70 #define CHKR_PREFIX_SIZE (sizeof (CHKR_PREFIX) - 1)
72 /* This macro gets just the user-specified name
73 out of the string in a SYMBOL_REF. On most machines,
74 we discard the * if any and that's all. */
75 #ifndef STRIP_NAME_ENCODING
76 #define STRIP_NAME_ENCODING(VAR,SYMBOL_NAME) \
77 (VAR) = ((SYMBOL_NAME) + ((SYMBOL_NAME)[0] == '*'))
80 /* File in which assembler code is being written. */
82 extern FILE *asm_out_file
;
84 /* The (assembler) name of the first globally-visible object output. */
85 char *first_global_object_name
;
87 extern struct obstack
*current_obstack
;
88 extern struct obstack
*saveable_obstack
;
89 extern struct obstack
*rtl_obstack
;
90 extern struct obstack permanent_obstack
;
91 #define obstack_chunk_alloc xmalloc
93 /* Number for making the label on the next
94 constant that is stored in memory. */
98 /* Number for making the label on the next
99 static variable internal to a function. */
103 /* Carry information from ASM_DECLARE_OBJECT_NAME
104 to ASM_FINISH_DECLARE_OBJECT. */
106 int size_directive_output
;
108 /* The last decl for which assemble_variable was called,
109 if it did ASM_DECLARE_OBJECT_NAME.
110 If the last call to assemble_variable didn't do that,
113 tree last_assemble_variable_decl
;
116 #ifdef HANDLE_PRAGMA_WEAK
117 /* Any weak symbol declarations waiting to be emitted. */
121 struct weak_syms
*next
;
126 static struct weak_syms
*weak_decls
;
129 /* Nonzero if at least one function definition has been seen. */
131 static int function_defined
;
134 struct constant_descriptor
;
136 struct pool_constant
;
138 static char *strip_reg_name
PROTO((char *));
139 static int contains_pointers_p
PROTO((tree
));
140 static void decode_addr_const
PROTO((tree
, struct addr_const
*));
141 static int const_hash
PROTO((tree
));
142 static int compare_constant
PROTO((tree
,
143 struct constant_descriptor
*));
144 static char *compare_constant_1
PROTO((tree
, char *));
145 static struct constant_descriptor
*record_constant
PROTO((tree
));
146 static void record_constant_1
PROTO((tree
));
147 static tree copy_constant
PROTO((tree
));
148 static void output_constant_def_contents
PROTO((tree
, int, int));
149 static void decode_rtx_const
PROTO((enum machine_mode
, rtx
,
150 struct rtx_const
*));
151 static int const_hash_rtx
PROTO((enum machine_mode
, rtx
));
152 static int compare_constant_rtx
PROTO((enum machine_mode
, rtx
,
153 struct constant_descriptor
*));
154 static struct constant_descriptor
*record_constant_rtx
PROTO((enum machine_mode
,
156 static struct pool_constant
*find_pool_constant
PROTO((rtx
));
157 static void mark_constant_pool
PROTO((void));
158 static void mark_constants
PROTO((rtx
));
159 static int output_addressed_constants
PROTO((tree
));
160 static void output_after_function_constants
PROTO((void));
161 static void output_constructor
PROTO((tree
, int));
163 static enum in_section
{ no_section
, in_text
, in_data
, in_named
164 #ifdef BSS_SECTION_ASM_OP
167 #ifdef EH_FRAME_SECTION_ASM_OP
170 #ifdef EXTRA_SECTIONS
173 } in_section
= no_section
;
175 /* Return a non-zero value if DECL has a section attribute. */
176 #define IN_NAMED_SECTION(DECL) \
177 ((TREE_CODE (DECL) == FUNCTION_DECL || TREE_CODE (DECL) == VAR_DECL) \
178 && DECL_SECTION_NAME (DECL) != NULL_TREE)
180 /* Text of section name when in_section == in_named. */
181 static char *in_named_name
;
183 /* Define functions like text_section for any extra sections. */
184 #ifdef EXTRA_SECTION_FUNCTIONS
185 EXTRA_SECTION_FUNCTIONS
188 /* Tell assembler to switch to text section. */
193 if (in_section
!= in_text
)
195 fprintf (asm_out_file
, "%s\n", TEXT_SECTION_ASM_OP
);
196 in_section
= in_text
;
200 /* Tell assembler to switch to data section. */
205 if (in_section
!= in_data
)
207 if (flag_shared_data
)
209 #ifdef SHARED_SECTION_ASM_OP
210 fprintf (asm_out_file
, "%s\n", SHARED_SECTION_ASM_OP
);
212 fprintf (asm_out_file
, "%s\n", DATA_SECTION_ASM_OP
);
216 fprintf (asm_out_file
, "%s\n", DATA_SECTION_ASM_OP
);
218 in_section
= in_data
;
222 /* Tell assembler to switch to read-only data section. This is normally
226 readonly_data_section ()
228 #ifdef READONLY_DATA_SECTION
229 READONLY_DATA_SECTION (); /* Note this can call data_section. */
235 /* Determine if we're in the text section. */
240 return in_section
== in_text
;
243 /* Determine if we're in the data section. */
248 return in_section
== in_data
;
251 /* Tell assembler to change to section NAME for DECL.
252 If DECL is NULL, just switch to section NAME.
253 If NAME is NULL, get the name from DECL.
254 If RELOC is 1, the initializer for DECL contains relocs. */
257 named_section (decl
, name
, reloc
)
262 if (decl
!= NULL_TREE
263 && TREE_CODE_CLASS (TREE_CODE (decl
)) != 'd')
266 name
= TREE_STRING_POINTER (DECL_SECTION_NAME (decl
));
268 if (in_section
!= in_named
|| strcmp (name
, in_named_name
))
270 #ifdef ASM_OUTPUT_SECTION_NAME
271 ASM_OUTPUT_SECTION_NAME (asm_out_file
, decl
, name
, reloc
);
273 /* Section attributes are not supported if this macro isn't provided -
274 some host formats don't support them at all. The front-end should
275 already have flagged this as an error. */
279 in_named_name
= obstack_alloc (&permanent_obstack
, strlen (name
) + 1);
280 strcpy (in_named_name
, name
);
281 in_section
= in_named
;
285 #ifdef ASM_OUTPUT_SECTION_NAME
286 #ifndef UNIQUE_SECTION
287 #define UNIQUE_SECTION(DECL,RELOC) \
290 char *name, *string; \
292 name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL)); \
293 /* Strip off any encoding in name. */ \
294 STRIP_NAME_ENCODING (name, name); \
296 len = strlen (name) + 1; \
297 string = alloca (len + 1); \
298 sprintf (string, ".%s", name); \
300 DECL_SECTION_NAME (DECL) = build_string (len, string); \
303 #ifndef UNIQUE_SECTION_P
304 #define UNIQUE_SECTION_P(DECL) 0
308 #ifdef BSS_SECTION_ASM_OP
310 /* Tell the assembler to switch to the bss section. */
315 if (in_section
!= in_bss
)
317 #ifdef SHARED_BSS_SECTION_ASM_OP
318 if (flag_shared_data
)
319 fprintf (asm_out_file
, "%s\n", SHARED_BSS_SECTION_ASM_OP
);
322 fprintf (asm_out_file
, "%s\n", BSS_SECTION_ASM_OP
);
328 #ifdef ASM_OUTPUT_BSS
330 /* Utility function for ASM_OUTPUT_BSS for targets to use if
331 they don't support alignments in .bss.
332 ??? It is believed that this function will work in most cases so such
333 support is localized here. */
336 asm_output_bss (file
, decl
, name
, size
, rounded
)
342 ASM_GLOBALIZE_LABEL (file
, name
);
344 #ifdef ASM_DECLARE_OBJECT_NAME
345 last_assemble_variable_decl
= decl
;
346 ASM_DECLARE_OBJECT_NAME (file
, name
, decl
);
348 /* Standard thing is just output label for the object. */
349 ASM_OUTPUT_LABEL (file
, name
);
350 #endif /* ASM_DECLARE_OBJECT_NAME */
351 ASM_OUTPUT_SKIP (file
, rounded
);
356 #ifdef ASM_OUTPUT_ALIGNED_BSS
358 /* Utility function for targets to use in implementing
359 ASM_OUTPUT_ALIGNED_BSS.
360 ??? It is believed that this function will work in most cases so such
361 support is localized here. */
364 asm_output_aligned_bss (file
, decl
, name
, size
, align
)
370 ASM_GLOBALIZE_LABEL (file
, name
);
372 ASM_OUTPUT_ALIGN (file
, floor_log2 (align
/ BITS_PER_UNIT
));
373 #ifdef ASM_DECLARE_OBJECT_NAME
374 last_assemble_variable_decl
= decl
;
375 ASM_DECLARE_OBJECT_NAME (file
, name
, decl
);
377 /* Standard thing is just output label for the object. */
378 ASM_OUTPUT_LABEL (file
, name
);
379 #endif /* ASM_DECLARE_OBJECT_NAME */
380 ASM_OUTPUT_SKIP (file
, size
? size
: 1);
385 #endif /* BSS_SECTION_ASM_OP */
387 #ifdef EH_FRAME_SECTION_ASM_OP
391 if (in_section
!= in_eh_frame
)
393 fprintf (asm_out_file
, "%s\n", EH_FRAME_SECTION_ASM_OP
);
394 in_section
= in_eh_frame
;
399 /* Switch to the section for function DECL.
401 If DECL is NULL_TREE, switch to the text section.
402 ??? It's not clear that we will ever be passed NULL_TREE, but it's
403 safer to handle it. */
406 function_section (decl
)
409 if (decl
!= NULL_TREE
410 && DECL_SECTION_NAME (decl
) != NULL_TREE
)
411 named_section (decl
, (char *) 0, 0);
416 /* Switch to section for variable DECL.
418 RELOC is the `reloc' argument to SELECT_SECTION. */
421 variable_section (decl
, reloc
)
425 if (IN_NAMED_SECTION (decl
))
426 named_section (decl
, NULL
, reloc
);
429 /* C++ can have const variables that get initialized from constructors,
430 and thus can not be in a readonly section. We prevent this by
431 verifying that the initial value is constant for objects put in a
434 error_mark_node is used by the C front end to indicate that the
435 initializer has not been seen yet. In this case, we assume that
436 the initializer must be constant.
438 C++ uses error_mark_node for variables that have complicated
439 initializers, but these variables go in BSS so we won't be called
442 #ifdef SELECT_SECTION
443 SELECT_SECTION (decl
, reloc
);
445 if (DECL_READONLY_SECTION (decl
, reloc
))
446 readonly_data_section ();
453 /* Tell assembler to switch to the section for the exception handling
459 #if defined (EXCEPTION_SECTION)
460 EXCEPTION_SECTION ();
462 #ifdef ASM_OUTPUT_SECTION_NAME
463 named_section (NULL_TREE
, ".gcc_except_table", 0);
468 readonly_data_section ();
473 /* Create the rtl to represent a function, for a function definition.
474 DECL is a FUNCTION_DECL node which describes which function.
475 The rtl is stored into DECL. */
478 make_function_rtl (decl
)
481 char *name
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
));
482 char *new_name
= name
;
484 /* Rename a nested function to avoid conflicts. */
485 if (decl_function_context (decl
) != 0
486 && DECL_INITIAL (decl
) != 0
487 && DECL_RTL (decl
) == 0)
491 name
= IDENTIFIER_POINTER (DECL_NAME (decl
));
492 ASM_FORMAT_PRIVATE_NAME (label
, name
, var_labelno
);
493 name
= obstack_copy0 (saveable_obstack
, label
, strlen (label
));
498 /* When -fprefix-function-name is used, every function name is
499 prefixed. Even static functions are prefixed because they
500 could be declared latter. Note that a nested function name
502 if (flag_prefix_function_name
)
504 new_name
= (char *) alloca (strlen (name
) + CHKR_PREFIX_SIZE
+ 1);
505 strcpy (new_name
, CHKR_PREFIX
);
506 strcpy (new_name
+ CHKR_PREFIX_SIZE
, name
);
507 name
= obstack_copy0 (saveable_obstack
, new_name
, strlen (new_name
));
511 if (DECL_RTL (decl
) == 0)
514 = gen_rtx_MEM (DECL_MODE (decl
),
515 gen_rtx_SYMBOL_REF (Pmode
, name
));
517 /* Optionally set flags or add text to the name to record information
518 such as that it is a function name. If the name is changed, the macro
519 ASM_OUTPUT_LABELREF will have to know how to strip this information. */
520 #ifdef ENCODE_SECTION_INFO
521 ENCODE_SECTION_INFO (decl
);
526 /* ??? Another way to do this would be to do what halfpic.c does
527 and maintain a hashed table of such critters. */
528 /* ??? Another way to do this would be to pass a flag bit to
529 ENCODE_SECTION_INFO saying whether this is a new decl or not. */
530 /* Let the target reassign the RTL if it wants.
531 This is necessary, for example, when one machine specific
532 decl attribute overrides another. */
533 #ifdef REDO_SECTION_INFO_P
534 if (REDO_SECTION_INFO_P (decl
))
535 ENCODE_SECTION_INFO (decl
);
539 /* Record at least one function has been defined. */
540 function_defined
= 1;
543 /* Given NAME, a putative register name, discard any customary prefixes. */
546 strip_reg_name (name
)
549 #ifdef REGISTER_PREFIX
550 if (!strncmp (name
, REGISTER_PREFIX
, strlen (REGISTER_PREFIX
)))
551 name
+= strlen (REGISTER_PREFIX
);
553 if (name
[0] == '%' || name
[0] == '#')
558 /* Decode an `asm' spec for a declaration as a register name.
559 Return the register number, or -1 if nothing specified,
560 or -2 if the ASMSPEC is not `cc' or `memory' and is not recognized,
561 or -3 if ASMSPEC is `cc' and is not recognized,
562 or -4 if ASMSPEC is `memory' and is not recognized.
563 Accept an exact spelling or a decimal number.
564 Prefixes such as % are optional. */
567 decode_reg_name (asmspec
)
574 /* Get rid of confusing prefixes. */
575 asmspec
= strip_reg_name (asmspec
);
577 /* Allow a decimal number as a "register name". */
578 for (i
= strlen (asmspec
) - 1; i
>= 0; i
--)
579 if (! (asmspec
[i
] >= '0' && asmspec
[i
] <= '9'))
581 if (asmspec
[0] != 0 && i
< 0)
584 if (i
< FIRST_PSEUDO_REGISTER
&& i
>= 0)
590 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; i
++)
592 && ! strcmp (asmspec
, strip_reg_name (reg_names
[i
])))
595 #ifdef ADDITIONAL_REGISTER_NAMES
597 static struct { char *name
; int number
; } table
[]
598 = ADDITIONAL_REGISTER_NAMES
;
600 for (i
= 0; i
< sizeof (table
) / sizeof (table
[0]); i
++)
601 if (! strcmp (asmspec
, table
[i
].name
))
602 return table
[i
].number
;
604 #endif /* ADDITIONAL_REGISTER_NAMES */
606 if (!strcmp (asmspec
, "memory"))
609 if (!strcmp (asmspec
, "cc"))
618 /* Create the DECL_RTL for a declaration for a static or external variable
619 or static or external function.
620 ASMSPEC, if not 0, is the string which the user specified
621 as the assembler symbol name.
622 TOP_LEVEL is nonzero if this is a file-scope variable.
624 This is never called for PARM_DECL nodes. */
627 make_decl_rtl (decl
, asmspec
, top_level
)
632 register char *name
= 0;
635 reg_number
= decode_reg_name (asmspec
);
637 if (DECL_ASSEMBLER_NAME (decl
) != NULL_TREE
)
638 name
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
));
640 if (reg_number
== -2)
642 /* ASMSPEC is given, and not the name of a register. */
643 name
= (char *) obstack_alloc (saveable_obstack
,
644 strlen (asmspec
) + 2);
646 strcpy (&name
[1], asmspec
);
649 /* For a duplicate declaration, we can be called twice on the
650 same DECL node. Don't discard the RTL already made. */
651 if (DECL_RTL (decl
) == 0)
655 /* First detect errors in declaring global registers. */
656 if (TREE_CODE (decl
) != FUNCTION_DECL
657 && DECL_REGISTER (decl
) && reg_number
== -1)
658 error_with_decl (decl
,
659 "register name not specified for `%s'");
660 else if (TREE_CODE (decl
) != FUNCTION_DECL
661 && DECL_REGISTER (decl
) && reg_number
< 0)
662 error_with_decl (decl
,
663 "invalid register name for `%s'");
664 else if ((reg_number
>= 0 || reg_number
== -3)
665 && (TREE_CODE (decl
) == FUNCTION_DECL
666 && ! DECL_REGISTER (decl
)))
667 error_with_decl (decl
,
668 "register name given for non-register variable `%s'");
669 else if (TREE_CODE (decl
) != FUNCTION_DECL
670 && DECL_REGISTER (decl
)
671 && TYPE_MODE (TREE_TYPE (decl
)) == BLKmode
)
672 error_with_decl (decl
,
673 "data type of `%s' isn't suitable for a register");
674 else if (TREE_CODE (decl
) != FUNCTION_DECL
&& DECL_REGISTER (decl
)
675 && ! HARD_REGNO_MODE_OK (reg_number
,
676 TYPE_MODE (TREE_TYPE (decl
))))
677 error_with_decl (decl
,
678 "register number for `%s' isn't suitable for data type");
679 /* Now handle properly declared static register variables. */
680 else if (TREE_CODE (decl
) != FUNCTION_DECL
&& DECL_REGISTER (decl
))
684 if (DECL_INITIAL (decl
) != 0 && top_level
)
686 DECL_INITIAL (decl
) = 0;
687 error ("global register variable has initial value");
689 if (fixed_regs
[reg_number
] == 0
690 && function_defined
&& top_level
)
691 error ("global register variable follows a function definition");
692 if (TREE_THIS_VOLATILE (decl
))
693 warning ("volatile register variables don't work as you might wish");
695 /* If the user specified one of the eliminables registers here,
696 e.g., FRAME_POINTER_REGNUM, we don't want to get this variable
697 confused with that register and be eliminated. Although this
698 usage is somewhat suspect, we nevertheless use the following
699 kludge to avoid setting DECL_RTL to frame_pointer_rtx. */
702 = gen_rtx_REG (DECL_MODE (decl
), FIRST_PSEUDO_REGISTER
);
703 REGNO (DECL_RTL (decl
)) = reg_number
;
704 REG_USERVAR_P (DECL_RTL (decl
)) = 1;
708 /* Make this register global, so not usable for anything
710 nregs
= HARD_REGNO_NREGS (reg_number
, DECL_MODE (decl
));
712 globalize_reg (reg_number
+ --nregs
);
715 /* Specifying a section attribute on a variable forces it into a
716 non-.bss section, and thus it cannot be common. */
717 else if (TREE_CODE (decl
) == VAR_DECL
718 && DECL_SECTION_NAME (decl
) != NULL_TREE
719 && DECL_INITIAL (decl
) == NULL_TREE
720 && DECL_COMMON (decl
))
721 DECL_COMMON (decl
) = 0;
723 /* Now handle ordinary static variables and functions (in memory).
724 Also handle vars declared register invalidly. */
725 if (DECL_RTL (decl
) == 0)
727 /* Can't use just the variable's own name for a variable
728 whose scope is less than the whole file.
729 Concatenate a distinguishing number. */
730 if (!top_level
&& !TREE_PUBLIC (decl
) && asmspec
== 0)
734 ASM_FORMAT_PRIVATE_NAME (label
, name
, var_labelno
);
735 name
= obstack_copy0 (saveable_obstack
, label
, strlen (label
));
738 /* We've changed the name by which this entity is
739 known. In order that we can generate
740 correct references to it, we update its
741 DECL_ASSEMBLER_NAME. */
742 DECL_ASSEMBLER_NAME (decl
) = get_identifier (name
);
748 /* When -fprefix-function-name is used, the functions
749 names are prefixed. Only nested function names are not
751 if (flag_prefix_function_name
&& TREE_CODE (decl
) == FUNCTION_DECL
)
754 new_name
= (char *) alloca (strlen (name
) + CHKR_PREFIX_SIZE
756 strcpy (new_name
, CHKR_PREFIX
);
757 strcpy (new_name
+ CHKR_PREFIX_SIZE
, name
);
758 name
= obstack_copy0 (saveable_obstack
,
759 new_name
, strlen (new_name
));
762 DECL_RTL (decl
) = gen_rtx_MEM (DECL_MODE (decl
),
763 gen_rtx_SYMBOL_REF (Pmode
, name
));
765 /* If this variable is to be treated as volatile, show its
766 tree node has side effects. If it has side effects, either
767 because of this test or from TREE_THIS_VOLATILE also
768 being set, show the MEM is volatile. */
769 if (flag_volatile_global
&& TREE_CODE (decl
) == VAR_DECL
770 && TREE_PUBLIC (decl
))
771 TREE_SIDE_EFFECTS (decl
) = 1;
772 if (TREE_SIDE_EFFECTS (decl
))
773 MEM_VOLATILE_P (DECL_RTL (decl
)) = 1;
775 if (TREE_READONLY (decl
))
776 RTX_UNCHANGING_P (DECL_RTL (decl
)) = 1;
777 MEM_IN_STRUCT_P (DECL_RTL (decl
))
778 = AGGREGATE_TYPE_P (TREE_TYPE (decl
));
780 /* Optionally set flags or add text to the name to record information
781 such as that it is a function name.
782 If the name is changed, the macro ASM_OUTPUT_LABELREF
783 will have to know how to strip this information. */
784 #ifdef ENCODE_SECTION_INFO
785 ENCODE_SECTION_INFO (decl
);
791 /* If the old RTL had the wrong mode, fix the mode. */
792 if (GET_MODE (DECL_RTL (decl
)) != DECL_MODE (decl
))
794 rtx rtl
= DECL_RTL (decl
);
795 PUT_MODE (rtl
, DECL_MODE (decl
));
798 /* ??? Another way to do this would be to do what halfpic.c does
799 and maintain a hashed table of such critters. */
800 /* ??? Another way to do this would be to pass a flag bit to
801 ENCODE_SECTION_INFO saying whether this is a new decl or not. */
802 /* Let the target reassign the RTL if it wants.
803 This is necessary, for example, when one machine specific
804 decl attribute overrides another. */
805 #ifdef REDO_SECTION_INFO_P
806 if (REDO_SECTION_INFO_P (decl
))
807 ENCODE_SECTION_INFO (decl
);
812 /* Make the rtl for variable VAR be volatile.
813 Use this only for static variables. */
816 make_var_volatile (var
)
819 if (GET_CODE (DECL_RTL (var
)) != MEM
)
822 MEM_VOLATILE_P (DECL_RTL (var
)) = 1;
825 /* Output alignment directive to align for constant expression EXP. */
828 assemble_constant_align (exp
)
833 /* Align the location counter as required by EXP's data type. */
834 align
= TYPE_ALIGN (TREE_TYPE (exp
));
835 #ifdef CONSTANT_ALIGNMENT
836 align
= CONSTANT_ALIGNMENT (exp
, align
);
839 if (align
> BITS_PER_UNIT
)
840 ASM_OUTPUT_ALIGN (asm_out_file
, floor_log2 (align
/ BITS_PER_UNIT
));
843 /* Output a string of literal assembler code
844 for an `asm' keyword used between functions. */
847 assemble_asm (string
)
852 if (TREE_CODE (string
) == ADDR_EXPR
)
853 string
= TREE_OPERAND (string
, 0);
855 fprintf (asm_out_file
, "\t%s\n", TREE_STRING_POINTER (string
));
858 #if 0 /* This should no longer be needed, because
859 flag_gnu_linker should be 0 on these systems,
860 which should prevent any output
861 if ASM_OUTPUT_CONSTRUCTOR and ASM_OUTPUT_DESTRUCTOR are absent. */
862 #if !(defined(DBX_DEBUGGING_INFO) && !defined(FASCIST_ASSEMBLER))
863 #ifndef ASM_OUTPUT_CONSTRUCTOR
864 #define ASM_OUTPUT_CONSTRUCTOR(file, name)
866 #ifndef ASM_OUTPUT_DESTRUCTOR
867 #define ASM_OUTPUT_DESTRUCTOR(file, name)
872 /* Record an element in the table of global destructors.
873 How this is done depends on what sort of assembler and linker
876 NAME should be the name of a global function to be called
877 at exit time. This name is output using assemble_name. */
880 assemble_destructor (name
)
883 #ifdef ASM_OUTPUT_DESTRUCTOR
884 ASM_OUTPUT_DESTRUCTOR (asm_out_file
, name
);
888 /* Now tell GNU LD that this is part of the static destructor set. */
889 /* This code works for any machine provided you use GNU as/ld. */
890 fprintf (asm_out_file
, "%s \"___DTOR_LIST__\",22,0,0,", ASM_STABS_OP
);
891 assemble_name (asm_out_file
, name
);
892 fputc ('\n', asm_out_file
);
897 /* Likewise for global constructors. */
900 assemble_constructor (name
)
903 #ifdef ASM_OUTPUT_CONSTRUCTOR
904 ASM_OUTPUT_CONSTRUCTOR (asm_out_file
, name
);
908 /* Now tell GNU LD that this is part of the static constructor set. */
909 /* This code works for any machine provided you use GNU as/ld. */
910 fprintf (asm_out_file
, "%s \"___CTOR_LIST__\",22,0,0,", ASM_STABS_OP
);
911 assemble_name (asm_out_file
, name
);
912 fputc ('\n', asm_out_file
);
917 /* Likewise for entries we want to record for garbage collection.
918 Garbage collection is still under development. */
921 assemble_gc_entry (name
)
924 #ifdef ASM_OUTPUT_GC_ENTRY
925 ASM_OUTPUT_GC_ENTRY (asm_out_file
, name
);
929 /* Now tell GNU LD that this is part of the static constructor set. */
930 fprintf (asm_out_file
, "%s \"___PTR_LIST__\",22,0,0,", ASM_STABS_OP
);
931 assemble_name (asm_out_file
, name
);
932 fputc ('\n', asm_out_file
);
937 /* CONSTANT_POOL_BEFORE_FUNCTION may be defined as an expression with
938 a non-zero value if the constant pool should be output before the
939 start of the function, or a zero value if the pool should output
940 after the end of the function. The default is to put it before the
943 #ifndef CONSTANT_POOL_BEFORE_FUNCTION
944 #define CONSTANT_POOL_BEFORE_FUNCTION 1
947 /* Output assembler code for the constant pool of a function and associated
948 with defining the name of the function. DECL describes the function.
949 NAME is the function's name. For the constant pool, we use the current
950 constant pool data. */
953 assemble_start_function (decl
, fnname
)
959 /* The following code does not need preprocessing in the assembler. */
963 if (CONSTANT_POOL_BEFORE_FUNCTION
)
964 output_constant_pool (fnname
, decl
);
966 #ifdef ASM_OUTPUT_SECTION_NAME
967 /* If the function is to be put in its own section and it's not in a section
968 already, indicate so. */
969 if ((flag_function_sections
970 && DECL_SECTION_NAME (decl
) == NULL_TREE
)
971 || UNIQUE_SECTION_P (decl
))
972 UNIQUE_SECTION (decl
, 0);
975 function_section (decl
);
977 /* Tell assembler to move to target machine's alignment for functions. */
978 align
= floor_log2 (FUNCTION_BOUNDARY
/ BITS_PER_UNIT
);
980 ASM_OUTPUT_ALIGN (asm_out_file
, align
);
982 #ifdef ASM_OUTPUT_FUNCTION_PREFIX
983 ASM_OUTPUT_FUNCTION_PREFIX (asm_out_file
, fnname
);
986 #ifdef SDB_DEBUGGING_INFO
987 /* Output SDB definition of the function. */
988 if (write_symbols
== SDB_DEBUG
)
989 sdbout_mark_begin_function ();
992 #ifdef DBX_DEBUGGING_INFO
993 /* Output DBX definition of the function. */
994 if (write_symbols
== DBX_DEBUG
)
995 dbxout_begin_function (decl
);
998 /* Make function name accessible from other files, if appropriate. */
1000 if (TREE_PUBLIC (decl
))
1002 if (!first_global_object_name
&& ! DECL_WEAK (decl
)
1003 && ! DECL_ONE_ONLY (decl
))
1007 STRIP_NAME_ENCODING (p
, fnname
);
1008 first_global_object_name
= permalloc (strlen (p
) + 1);
1009 strcpy (first_global_object_name
, p
);
1012 #ifdef ASM_WEAKEN_LABEL
1013 if (DECL_WEAK (decl
))
1014 ASM_WEAKEN_LABEL (asm_out_file
, fnname
);
1017 ASM_GLOBALIZE_LABEL (asm_out_file
, fnname
);
1020 /* Do any machine/system dependent processing of the function name */
1021 #ifdef ASM_DECLARE_FUNCTION_NAME
1022 ASM_DECLARE_FUNCTION_NAME (asm_out_file
, fnname
, current_function_decl
);
1024 /* Standard thing is just output label for the function. */
1025 ASM_OUTPUT_LABEL (asm_out_file
, fnname
);
1026 #endif /* ASM_DECLARE_FUNCTION_NAME */
1029 /* Output assembler code associated with defining the size of the
1030 function. DECL describes the function. NAME is the function's name. */
1033 assemble_end_function (decl
, fnname
)
1037 #ifdef ASM_DECLARE_FUNCTION_SIZE
1038 ASM_DECLARE_FUNCTION_SIZE (asm_out_file
, fnname
, decl
);
1040 if (! CONSTANT_POOL_BEFORE_FUNCTION
)
1042 output_constant_pool (fnname
, decl
);
1043 function_section (decl
); /* need to switch back */
1046 /* Output any constants which should appear after the function. */
1047 output_after_function_constants ();
1050 /* Assemble code to leave SIZE bytes of zeros. */
1053 assemble_zeros (size
)
1056 #ifdef ASM_NO_SKIP_IN_TEXT
1057 /* The `space' pseudo in the text section outputs nop insns rather than 0s,
1058 so we must output 0s explicitly in the text section. */
1059 if (ASM_NO_SKIP_IN_TEXT
&& in_text_section ())
1063 for (i
= 0; i
< size
- 20; i
+= 20)
1066 fprintf (asm_out_file
,
1067 "%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
);
1069 fprintf (asm_out_file
,
1070 "\tbyte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n");
1076 fprintf (asm_out_file
, "%s 0", ASM_BYTE_OP
);
1078 fprintf (asm_out_file
, "\tbyte 0");
1081 for (; i
< size
; i
++)
1082 fprintf (asm_out_file
, ",0");
1083 fprintf (asm_out_file
, "\n");
1089 ASM_OUTPUT_SKIP (asm_out_file
, size
);
1092 /* Assemble an alignment pseudo op for an ALIGN-bit boundary. */
1095 assemble_align (align
)
1098 if (align
> BITS_PER_UNIT
)
1099 ASM_OUTPUT_ALIGN (asm_out_file
, floor_log2 (align
/ BITS_PER_UNIT
));
1102 /* Assemble a string constant with the specified C string as contents. */
1105 assemble_string (p
, size
)
1112 /* If the string is very long, split it up. */
1116 int thissize
= size
- pos
;
1117 if (thissize
> maximum
)
1120 ASM_OUTPUT_ASCII (asm_out_file
, p
, thissize
);
1128 /* Assemble everything that is needed for a variable or function declaration.
1129 Not used for automatic variables, and not used for function definitions.
1130 Should not be called for variables of incomplete structure type.
1132 TOP_LEVEL is nonzero if this variable has file scope.
1133 AT_END is nonzero if this is the special handling, at end of compilation,
1134 to define things that have had only tentative definitions.
1135 DONT_OUTPUT_DATA if nonzero means don't actually output the
1136 initial value (that will be done by the caller). */
1139 assemble_variable (decl
, top_level
, at_end
, dont_output_data
)
1143 int dont_output_data
;
1145 register char *name
;
1149 enum in_section saved_in_section
;
1151 last_assemble_variable_decl
= 0;
1153 if (GET_CODE (DECL_RTL (decl
)) == REG
)
1155 /* Do output symbol info for global register variables, but do nothing
1158 if (TREE_ASM_WRITTEN (decl
))
1160 TREE_ASM_WRITTEN (decl
) = 1;
1162 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
1163 /* File-scope global variables are output here. */
1164 if ((write_symbols
== DBX_DEBUG
|| write_symbols
== XCOFF_DEBUG
)
1166 dbxout_symbol (decl
, 0);
1168 #ifdef SDB_DEBUGGING_INFO
1169 if (write_symbols
== SDB_DEBUG
&& top_level
1170 /* Leave initialized global vars for end of compilation;
1171 see comment in compile_file. */
1172 && (TREE_PUBLIC (decl
) == 0 || DECL_INITIAL (decl
) == 0))
1173 sdbout_symbol (decl
, 0);
1176 /* Don't output any DWARF debugging information for variables here.
1177 In the case of local variables, the information for them is output
1178 when we do our recursive traversal of the tree representation for
1179 the entire containing function. In the case of file-scope variables,
1180 we output information for all of them at the very end of compilation
1181 while we are doing our final traversal of the chain of file-scope
1187 /* Normally no need to say anything here for external references,
1188 since assemble_external is called by the language-specific code
1189 when a declaration is first seen. */
1191 if (DECL_EXTERNAL (decl
))
1194 /* Output no assembler code for a function declaration.
1195 Only definitions of functions output anything. */
1197 if (TREE_CODE (decl
) == FUNCTION_DECL
)
1200 /* If type was incomplete when the variable was declared,
1201 see if it is complete now. */
1203 if (DECL_SIZE (decl
) == 0)
1204 layout_decl (decl
, 0);
1206 /* Still incomplete => don't allocate it; treat the tentative defn
1207 (which is what it must have been) as an `extern' reference. */
1209 if (!dont_output_data
&& DECL_SIZE (decl
) == 0)
1211 error_with_file_and_line (DECL_SOURCE_FILE (decl
),
1212 DECL_SOURCE_LINE (decl
),
1213 "storage size of `%s' isn't known",
1214 IDENTIFIER_POINTER (DECL_NAME (decl
)));
1215 TREE_ASM_WRITTEN (decl
) = 1;
1219 /* The first declaration of a variable that comes through this function
1220 decides whether it is global (in C, has external linkage)
1221 or local (in C, has internal linkage). So do nothing more
1222 if this function has already run. */
1224 if (TREE_ASM_WRITTEN (decl
))
1227 TREE_ASM_WRITTEN (decl
) = 1;
1231 if (! dont_output_data
)
1235 if (TREE_CODE (DECL_SIZE (decl
)) != INTEGER_CST
)
1238 /* This is better than explicit arithmetic, since it avoids overflow. */
1239 size_tree
= size_binop (CEIL_DIV_EXPR
,
1240 DECL_SIZE (decl
), size_int (BITS_PER_UNIT
));
1242 size
= TREE_INT_CST_LOW (size_tree
);
1243 if (TREE_INT_CST_HIGH (size_tree
) != 0
1244 || size
!= TREE_INT_CST_LOW (size_tree
))
1246 error_with_decl (decl
, "size of variable `%s' is too large");
1251 name
= XSTR (XEXP (DECL_RTL (decl
), 0), 0);
1253 if (TREE_PUBLIC (decl
) && DECL_NAME (decl
)
1254 && ! first_global_object_name
1255 && ! (DECL_COMMON (decl
) && (DECL_INITIAL (decl
) == 0
1256 || DECL_INITIAL (decl
) == error_mark_node
))
1257 && ! DECL_WEAK (decl
)
1258 && ! DECL_ONE_ONLY (decl
))
1262 STRIP_NAME_ENCODING (p
, name
);
1263 first_global_object_name
= permalloc (strlen (p
) + 1);
1264 strcpy (first_global_object_name
, p
);
1267 /* Handle uninitialized definitions. */
1269 if ((DECL_INITIAL (decl
) == 0 || DECL_INITIAL (decl
) == error_mark_node
)
1270 /* If the target can't output uninitialized but not common global data
1271 in .bss, then we have to use .data. */
1272 #if ! defined (ASM_OUTPUT_BSS) && ! defined (ASM_OUTPUT_ALIGNED_BSS)
1273 && DECL_COMMON (decl
)
1275 && ! dont_output_data
)
1277 int size
= TREE_INT_CST_LOW (size_tree
);
1280 /* Don't allocate zero bytes of common,
1281 since that means "undefined external" in the linker. */
1282 if (size
== 0) rounded
= 1;
1283 /* Round size up to multiple of BIGGEST_ALIGNMENT bits
1284 so that each uninitialized object starts on such a boundary. */
1285 rounded
+= (BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
) - 1;
1286 rounded
= (rounded
/ (BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
)
1287 * (BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
));
1289 #ifdef DBX_DEBUGGING_INFO
1290 /* File-scope global variables are output here. */
1291 if (write_symbols
== DBX_DEBUG
&& top_level
)
1292 dbxout_symbol (decl
, 0);
1294 #ifdef SDB_DEBUGGING_INFO
1295 if (write_symbols
== SDB_DEBUG
&& top_level
1296 /* Leave initialized global vars for end of compilation;
1297 see comment in compile_file. */
1298 && (TREE_PUBLIC (decl
) == 0 || DECL_INITIAL (decl
) == 0))
1299 sdbout_symbol (decl
, 0);
1302 /* Don't output any DWARF debugging information for variables here.
1303 In the case of local variables, the information for them is output
1304 when we do our recursive traversal of the tree representation for
1305 the entire containing function. In the case of file-scope variables,
1306 we output information for all of them at the very end of compilation
1307 while we are doing our final traversal of the chain of file-scope
1310 #if 0 /* ??? We should either delete this or add a comment describing what
1311 it was intended to do and why we shouldn't delete it. */
1312 if (flag_shared_data
)
1316 if (TREE_PUBLIC (decl
)
1317 #if defined (ASM_OUTPUT_BSS) || defined (ASM_OUTPUT_ALIGNED_BSS)
1318 && DECL_COMMON (decl
)
1322 #ifdef ASM_OUTPUT_SHARED_COMMON
1323 if (flag_shared_data
)
1324 ASM_OUTPUT_SHARED_COMMON (asm_out_file
, name
, size
, rounded
);
1328 #ifdef ASM_OUTPUT_ALIGNED_DECL_COMMON
1329 ASM_OUTPUT_ALIGNED_DECL_COMMON (asm_out_file
, decl
, name
, size
,
1332 #ifdef ASM_OUTPUT_ALIGNED_COMMON
1333 ASM_OUTPUT_ALIGNED_COMMON (asm_out_file
, name
, size
,
1336 ASM_OUTPUT_COMMON (asm_out_file
, name
, size
, rounded
);
1341 #if defined (ASM_OUTPUT_BSS) || defined (ASM_OUTPUT_ALIGNED_BSS)
1342 else if (TREE_PUBLIC (decl
))
1344 #ifdef ASM_OUTPUT_SHARED_BSS
1345 if (flag_shared_data
)
1346 ASM_OUTPUT_SHARED_BSS (asm_out_file
, decl
, name
, size
, rounded
);
1350 #ifdef ASM_OUTPUT_ALIGNED_BSS
1351 ASM_OUTPUT_ALIGNED_BSS (asm_out_file
, decl
, name
, size
,
1354 ASM_OUTPUT_BSS (asm_out_file
, decl
, name
, size
, rounded
);
1358 #endif /* ASM_OUTPUT_BSS || ASM_OUTPUT_ALIGNED_BSS */
1361 #ifdef ASM_OUTPUT_SHARED_LOCAL
1362 if (flag_shared_data
)
1363 ASM_OUTPUT_SHARED_LOCAL (asm_out_file
, name
, size
, rounded
);
1367 #ifdef ASM_OUTPUT_ALIGNED_DECL_LOCAL
1368 ASM_OUTPUT_ALIGNED_DECL_LOCAL (asm_out_file
, decl
, name
, size
,
1371 #ifdef ASM_OUTPUT_ALIGNED_LOCAL
1372 ASM_OUTPUT_ALIGNED_LOCAL (asm_out_file
, name
, size
,
1375 ASM_OUTPUT_LOCAL (asm_out_file
, name
, size
, rounded
);
1383 /* Handle initialized definitions.
1384 Also handle uninitialized global definitions if -fno-common and the
1385 target doesn't support ASM_OUTPUT_BSS. */
1387 /* First make the assembler name(s) global if appropriate. */
1388 if (TREE_PUBLIC (decl
) && DECL_NAME (decl
))
1390 #ifdef ASM_WEAKEN_LABEL
1391 if (DECL_WEAK (decl
))
1392 ASM_WEAKEN_LABEL (asm_out_file
, name
);
1395 ASM_GLOBALIZE_LABEL (asm_out_file
, name
);
1398 for (d
= equivalents
; d
; d
= TREE_CHAIN (d
))
1400 tree e
= TREE_VALUE (d
);
1401 if (TREE_PUBLIC (e
) && DECL_NAME (e
))
1402 ASM_GLOBALIZE_LABEL (asm_out_file
,
1403 XSTR (XEXP (DECL_RTL (e
), 0), 0));
1407 /* Output any data that we will need to use the address of. */
1408 if (DECL_INITIAL (decl
) == error_mark_node
)
1409 reloc
= contains_pointers_p (TREE_TYPE (decl
));
1410 else if (DECL_INITIAL (decl
))
1411 reloc
= output_addressed_constants (DECL_INITIAL (decl
));
1413 #ifdef ASM_OUTPUT_SECTION_NAME
1414 if (UNIQUE_SECTION_P (decl
))
1415 UNIQUE_SECTION (decl
, reloc
);
1418 /* Switch to the appropriate section. */
1419 variable_section (decl
, reloc
);
1421 /* dbxout.c needs to know this. */
1422 if (in_text_section ())
1423 DECL_IN_TEXT_SECTION (decl
) = 1;
1425 /* Record current section so we can restore it if dbxout.c clobbers it. */
1426 saved_in_section
= in_section
;
1428 /* Output the dbx info now that we have chosen the section. */
1430 #ifdef DBX_DEBUGGING_INFO
1431 /* File-scope global variables are output here. */
1432 if (write_symbols
== DBX_DEBUG
&& top_level
)
1433 dbxout_symbol (decl
, 0);
1435 #ifdef SDB_DEBUGGING_INFO
1436 if (write_symbols
== SDB_DEBUG
&& top_level
1437 /* Leave initialized global vars for end of compilation;
1438 see comment in compile_file. */
1439 && (TREE_PUBLIC (decl
) == 0 || DECL_INITIAL (decl
) == 0))
1440 sdbout_symbol (decl
, 0);
1443 /* Don't output any DWARF debugging information for variables here.
1444 In the case of local variables, the information for them is output
1445 when we do our recursive traversal of the tree representation for
1446 the entire containing function. In the case of file-scope variables,
1447 we output information for all of them at the very end of compilation
1448 while we are doing our final traversal of the chain of file-scope
1451 /* If the debugging output changed sections, reselect the section
1452 that's supposed to be selected. */
1453 if (in_section
!= saved_in_section
)
1454 variable_section (decl
, reloc
);
1456 /* Compute and output the alignment of this data. */
1458 align
= DECL_ALIGN (decl
);
1459 /* In the case for initialing an array whose length isn't specified,
1460 where we have not yet been able to do the layout,
1461 figure out the proper alignment now. */
1462 if (dont_output_data
&& DECL_SIZE (decl
) == 0
1463 && TREE_CODE (TREE_TYPE (decl
)) == ARRAY_TYPE
)
1464 align
= MAX (align
, TYPE_ALIGN (TREE_TYPE (TREE_TYPE (decl
))));
1466 /* Some object file formats have a maximum alignment which they support.
1467 In particular, a.out format supports a maximum alignment of 4. */
1468 #ifndef MAX_OFILE_ALIGNMENT
1469 #define MAX_OFILE_ALIGNMENT BIGGEST_ALIGNMENT
1471 if (align
> MAX_OFILE_ALIGNMENT
)
1473 warning_with_decl (decl
,
1474 "alignment of `%s' is greater than maximum object file alignment");
1475 align
= MAX_OFILE_ALIGNMENT
;
1477 #ifdef DATA_ALIGNMENT
1478 /* On some machines, it is good to increase alignment sometimes. */
1479 align
= DATA_ALIGNMENT (TREE_TYPE (decl
), align
);
1481 #ifdef CONSTANT_ALIGNMENT
1482 if (DECL_INITIAL (decl
))
1483 align
= CONSTANT_ALIGNMENT (DECL_INITIAL (decl
), align
);
1486 /* Reset the alignment in case we have made it tighter, so we can benefit
1487 from it in get_pointer_alignment. */
1488 DECL_ALIGN (decl
) = align
;
1490 if (align
> BITS_PER_UNIT
)
1491 ASM_OUTPUT_ALIGN (asm_out_file
, floor_log2 (align
/ BITS_PER_UNIT
));
1493 /* Do any machine/system dependent processing of the object. */
1494 #ifdef ASM_DECLARE_OBJECT_NAME
1495 last_assemble_variable_decl
= decl
;
1496 ASM_DECLARE_OBJECT_NAME (asm_out_file
, name
, decl
);
1498 /* Standard thing is just output label for the object. */
1499 ASM_OUTPUT_LABEL (asm_out_file
, name
);
1500 #endif /* ASM_DECLARE_OBJECT_NAME */
1502 if (!dont_output_data
)
1504 if (DECL_INITIAL (decl
))
1505 /* Output the actual data. */
1506 output_constant (DECL_INITIAL (decl
), TREE_INT_CST_LOW (size_tree
));
1508 /* Leave space for it. */
1509 assemble_zeros (TREE_INT_CST_LOW (size_tree
));
1513 #ifdef XCOFF_DEBUGGING_INFO
1514 /* Unfortunately, the IBM assembler cannot handle stabx before the actual
1515 declaration. When something like ".stabx "aa:S-2",aa,133,0" is emitted
1516 and `aa' hasn't been output yet, the assembler generates a stab entry with
1517 a value of zero, in addition to creating an unnecessary external entry
1518 for `aa'. Hence, we must postpone dbxout_symbol to here at the end. */
1520 /* File-scope global variables are output here. */
1521 if (write_symbols
== XCOFF_DEBUG
&& top_level
)
1523 saved_in_section
= in_section
;
1525 dbxout_symbol (decl
, 0);
1527 if (in_section
!= saved_in_section
)
1528 variable_section (decl
, reloc
);
1531 /* There must be a statement after a label. */
1536 /* Return 1 if type TYPE contains any pointers. */
1539 contains_pointers_p (type
)
1542 switch (TREE_CODE (type
))
1545 case REFERENCE_TYPE
:
1546 /* I'm not sure whether OFFSET_TYPE needs this treatment,
1547 so I'll play safe and return 1. */
1553 case QUAL_UNION_TYPE
:
1556 /* For a type that has fields, see if the fields have pointers. */
1557 for (fields
= TYPE_FIELDS (type
); fields
; fields
= TREE_CHAIN (fields
))
1558 if (TREE_CODE (fields
) == FIELD_DECL
1559 && contains_pointers_p (TREE_TYPE (fields
)))
1565 /* An array type contains pointers if its element type does. */
1566 return contains_pointers_p (TREE_TYPE (type
));
1573 /* Output something to declare an external symbol to the assembler.
1574 (Most assemblers don't need this, so we normally output nothing.)
1575 Do nothing if DECL is not external. */
1578 assemble_external (decl
)
1581 #ifdef ASM_OUTPUT_EXTERNAL
1582 if (TREE_CODE_CLASS (TREE_CODE (decl
)) == 'd'
1583 && DECL_EXTERNAL (decl
) && TREE_PUBLIC (decl
))
1585 rtx rtl
= DECL_RTL (decl
);
1587 if (GET_CODE (rtl
) == MEM
&& GET_CODE (XEXP (rtl
, 0)) == SYMBOL_REF
1588 && ! SYMBOL_REF_USED (XEXP (rtl
, 0)))
1590 /* Some systems do require some output. */
1591 SYMBOL_REF_USED (XEXP (rtl
, 0)) = 1;
1592 ASM_OUTPUT_EXTERNAL (asm_out_file
, decl
, XSTR (XEXP (rtl
, 0), 0));
1598 /* Similar, for calling a library function FUN. */
1601 assemble_external_libcall (fun
)
1604 #ifdef ASM_OUTPUT_EXTERNAL_LIBCALL
1605 /* Declare library function name external when first used, if nec. */
1606 if (! SYMBOL_REF_USED (fun
))
1608 SYMBOL_REF_USED (fun
) = 1;
1609 ASM_OUTPUT_EXTERNAL_LIBCALL (asm_out_file
, fun
);
1614 /* Declare the label NAME global. */
1617 assemble_global (name
)
1620 ASM_GLOBALIZE_LABEL (asm_out_file
, name
);
1623 /* Assemble a label named NAME. */
1626 assemble_label (name
)
1629 ASM_OUTPUT_LABEL (asm_out_file
, name
);
1632 /* Output to FILE a reference to the assembler name of a C-level name NAME.
1633 If NAME starts with a *, the rest of NAME is output verbatim.
1634 Otherwise NAME is transformed in an implementation-defined way
1635 (usually by the addition of an underscore).
1636 Many macros in the tm file are defined to call this function. */
1639 assemble_name (file
, name
)
1646 STRIP_NAME_ENCODING (real_name
, name
);
1647 if (flag_prefix_function_name
1648 && ! bcmp (real_name
, CHKR_PREFIX
, CHKR_PREFIX_SIZE
))
1649 real_name
= real_name
+ CHKR_PREFIX_SIZE
;
1651 id
= maybe_get_identifier (real_name
);
1653 TREE_SYMBOL_REFERENCED (id
) = 1;
1656 fputs (&name
[1], file
);
1658 ASM_OUTPUT_LABELREF (file
, name
);
1661 /* Allocate SIZE bytes writable static space with a gensym name
1662 and return an RTX to refer to its address. */
1665 assemble_static_space (size
)
1671 #ifndef ASM_OUTPUT_ALIGNED_LOCAL
1672 /* Round size up to multiple of BIGGEST_ALIGNMENT bits
1673 so that each uninitialized object starts on such a boundary. */
1674 int rounded
= ((size
+ (BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
) - 1)
1675 / (BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
)
1676 * (BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
));
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
);
1700 ASM_OUTPUT_LOCAL (asm_out_file
, name
, size
, rounded
);
1706 /* Assemble the static constant template for function entry trampolines.
1707 This is done at most once per compilation.
1708 Returns an RTX for the address of the template. */
1710 #ifdef TRAMPOLINE_TEMPLATE
1712 assemble_trampoline_template ()
1718 /* By default, put trampoline templates in read-only data section. */
1720 #ifdef TRAMPOLINE_SECTION
1721 TRAMPOLINE_SECTION ();
1723 readonly_data_section ();
1726 /* Write the assembler code to define one. */
1727 align
= floor_log2 (TRAMPOLINE_ALIGNMENT
/ BITS_PER_UNIT
);
1729 ASM_OUTPUT_ALIGN (asm_out_file
, align
);
1731 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, "LTRAMP", 0);
1732 TRAMPOLINE_TEMPLATE (asm_out_file
);
1734 /* Record the rtl to refer to it. */
1735 ASM_GENERATE_INTERNAL_LABEL (label
, "LTRAMP", 0);
1737 = (char *) obstack_copy0 (&permanent_obstack
, label
, strlen (label
));
1738 return gen_rtx_SYMBOL_REF (Pmode
, name
);
1742 /* Assemble the integer constant X into an object of SIZE bytes.
1743 X must be either a CONST_INT or CONST_DOUBLE.
1745 Return 1 if we were able to output the constant, otherwise 0. If FORCE is
1746 non-zero, abort if we can't output the constant. */
1749 assemble_integer (x
, size
, force
)
1754 /* First try to use the standard 1, 2, 4, 8, and 16 byte
1755 ASM_OUTPUT... macros. */
1759 #ifdef ASM_OUTPUT_CHAR
1761 ASM_OUTPUT_CHAR (asm_out_file
, x
);
1765 #ifdef ASM_OUTPUT_SHORT
1767 ASM_OUTPUT_SHORT (asm_out_file
, x
);
1771 #ifdef ASM_OUTPUT_INT
1773 ASM_OUTPUT_INT (asm_out_file
, x
);
1777 #ifdef ASM_OUTPUT_DOUBLE_INT
1779 ASM_OUTPUT_DOUBLE_INT (asm_out_file
, x
);
1783 #ifdef ASM_OUTPUT_QUADRUPLE_INT
1785 ASM_OUTPUT_QUADRUPLE_INT (asm_out_file
, x
);
1790 /* If we couldn't do it that way, there are two other possibilities: First,
1791 if the machine can output an explicit byte and this is a 1 byte constant,
1792 we can use ASM_OUTPUT_BYTE. */
1794 #ifdef ASM_OUTPUT_BYTE
1795 if (size
== 1 && GET_CODE (x
) == CONST_INT
)
1797 ASM_OUTPUT_BYTE (asm_out_file
, INTVAL (x
));
1802 /* Finally, if SIZE is larger than a single word, try to output the constant
1803 one word at a time. */
1805 if (size
> UNITS_PER_WORD
)
1808 enum machine_mode mode
1809 = mode_for_size (size
* BITS_PER_UNIT
, MODE_INT
, 0);
1812 for (i
= 0; i
< size
/ UNITS_PER_WORD
; i
++)
1814 word
= operand_subword (x
, i
, 0, mode
);
1819 if (! assemble_integer (word
, UNITS_PER_WORD
, 0))
1823 if (i
== size
/ UNITS_PER_WORD
)
1825 /* If we output at least one word and then could not finish,
1826 there is no valid way to continue. */
1837 /* Assemble the floating-point constant D into an object of size MODE. */
1840 assemble_real (d
, mode
)
1842 enum machine_mode mode
;
1844 jmp_buf output_constant_handler
;
1846 if (setjmp (output_constant_handler
))
1848 error ("floating point trap outputting a constant");
1849 #ifdef REAL_IS_NOT_DOUBLE
1850 bzero ((char *) &d
, sizeof d
);
1857 set_float_handler (output_constant_handler
);
1861 #ifdef ASM_OUTPUT_BYTE_FLOAT
1863 ASM_OUTPUT_BYTE_FLOAT (asm_out_file
, d
);
1866 #ifdef ASM_OUTPUT_SHORT_FLOAT
1868 ASM_OUTPUT_SHORT_FLOAT (asm_out_file
, d
);
1871 #ifdef ASM_OUTPUT_THREE_QUARTER_FLOAT
1873 ASM_OUTPUT_THREE_QUARTER_FLOAT (asm_out_file
, d
);
1876 #ifdef ASM_OUTPUT_FLOAT
1878 ASM_OUTPUT_FLOAT (asm_out_file
, d
);
1882 #ifdef ASM_OUTPUT_DOUBLE
1884 ASM_OUTPUT_DOUBLE (asm_out_file
, d
);
1888 #ifdef ASM_OUTPUT_LONG_DOUBLE
1891 ASM_OUTPUT_LONG_DOUBLE (asm_out_file
, d
);
1899 set_float_handler (NULL_PTR
);
1902 /* Here we combine duplicate floating constants to make
1903 CONST_DOUBLE rtx's, and force those out to memory when necessary. */
1905 /* Chain of all CONST_DOUBLE rtx's constructed for the current function.
1906 They are chained through the CONST_DOUBLE_CHAIN.
1907 A CONST_DOUBLE rtx has CONST_DOUBLE_MEM != cc0_rtx iff it is on this chain.
1908 In that case, CONST_DOUBLE_MEM is either a MEM,
1909 or const0_rtx if no MEM has been made for this CONST_DOUBLE yet.
1911 (CONST_DOUBLE_MEM is used only for top-level functions.
1912 See force_const_mem for explanation.) */
1914 static rtx const_double_chain
;
1916 /* Return a CONST_DOUBLE or CONST_INT for a value specified as a pair of ints.
1917 For an integer, I0 is the low-order word and I1 is the high-order word.
1918 For a real number, I0 is the word with the low address
1919 and I1 is the word with the high address. */
1922 immed_double_const (i0
, i1
, mode
)
1923 HOST_WIDE_INT i0
, i1
;
1924 enum machine_mode mode
;
1928 if (GET_MODE_CLASS (mode
) == MODE_INT
1929 || GET_MODE_CLASS (mode
) == MODE_PARTIAL_INT
)
1931 /* We clear out all bits that don't belong in MODE, unless they and our
1932 sign bit are all one. So we get either a reasonable negative value
1933 or a reasonable unsigned value for this mode. */
1934 int width
= GET_MODE_BITSIZE (mode
);
1935 if (width
< HOST_BITS_PER_WIDE_INT
1936 && ((i0
& ((HOST_WIDE_INT
) (-1) << (width
- 1)))
1937 != ((HOST_WIDE_INT
) (-1) << (width
- 1))))
1938 i0
&= ((HOST_WIDE_INT
) 1 << width
) - 1, i1
= 0;
1939 else if (width
== HOST_BITS_PER_WIDE_INT
1940 && ! (i1
== ~0 && i0
< 0))
1942 else if (width
> 2 * HOST_BITS_PER_WIDE_INT
)
1943 /* We cannot represent this value as a constant. */
1946 /* If this would be an entire word for the target, but is not for
1947 the host, then sign-extend on the host so that the number will look
1948 the same way on the host that it would on the target.
1950 For example, when building a 64 bit alpha hosted 32 bit sparc
1951 targeted compiler, then we want the 32 bit unsigned value -1 to be
1952 represented as a 64 bit value -1, and not as 0x00000000ffffffff.
1953 The later confuses the sparc backend. */
1955 if (BITS_PER_WORD
< HOST_BITS_PER_WIDE_INT
&& BITS_PER_WORD
== width
1956 && (i0
& ((HOST_WIDE_INT
) 1 << (width
- 1))))
1957 i0
|= ((HOST_WIDE_INT
) (-1) << width
);
1959 /* If MODE fits within HOST_BITS_PER_WIDE_INT, always use a CONST_INT.
1961 ??? Strictly speaking, this is wrong if we create a CONST_INT
1962 for a large unsigned constant with the size of MODE being
1963 HOST_BITS_PER_WIDE_INT and later try to interpret that constant in a
1964 wider mode. In that case we will mis-interpret it as a negative
1967 Unfortunately, the only alternative is to make a CONST_DOUBLE
1968 for any constant in any mode if it is an unsigned constant larger
1969 than the maximum signed integer in an int on the host. However,
1970 doing this will break everyone that always expects to see a CONST_INT
1971 for SImode and smaller.
1973 We have always been making CONST_INTs in this case, so nothing new
1976 if (width
<= HOST_BITS_PER_WIDE_INT
)
1977 i1
= (i0
< 0) ? ~(HOST_WIDE_INT
) 0 : 0;
1979 /* If this integer fits in one word, return a CONST_INT. */
1980 if ((i1
== 0 && i0
>= 0)
1981 || (i1
== ~0 && i0
< 0))
1982 return GEN_INT (i0
);
1984 /* We use VOIDmode for integers. */
1988 /* Search the chain for an existing CONST_DOUBLE with the right value.
1989 If one is found, return it. */
1991 for (r
= const_double_chain
; r
; r
= CONST_DOUBLE_CHAIN (r
))
1992 if (CONST_DOUBLE_LOW (r
) == i0
&& CONST_DOUBLE_HIGH (r
) == i1
1993 && GET_MODE (r
) == mode
)
1996 /* No; make a new one and add it to the chain.
1998 We may be called by an optimizer which may be discarding any memory
1999 allocated during its processing (such as combine and loop). However,
2000 we will be leaving this constant on the chain, so we cannot tolerate
2001 freed memory. So switch to saveable_obstack for this allocation
2002 and then switch back if we were in current_obstack. */
2004 push_obstacks_nochange ();
2005 rtl_in_saveable_obstack ();
2006 r
= gen_rtx_CONST_DOUBLE (mode
, NULL_RTX
, i0
, i1
);
2009 /* Don't touch const_double_chain in nested function; see force_const_mem.
2010 Also, don't touch it if not inside any function. */
2011 if (outer_function_chain
== 0 && current_function_decl
!= 0)
2013 CONST_DOUBLE_CHAIN (r
) = const_double_chain
;
2014 const_double_chain
= r
;
2017 /* Store const0_rtx in mem-slot since this CONST_DOUBLE is on the chain.
2018 Actual use of mem-slot is only through force_const_mem. */
2020 CONST_DOUBLE_MEM (r
) = const0_rtx
;
2025 /* Return a CONST_DOUBLE for a specified `double' value
2026 and machine mode. */
2029 immed_real_const_1 (d
, mode
)
2031 enum machine_mode mode
;
2033 union real_extract u
;
2036 /* Get the desired `double' value as a sequence of ints
2037 since that is how they are stored in a CONST_DOUBLE. */
2041 /* Detect special cases. */
2043 if (REAL_VALUES_IDENTICAL (dconst0
, d
))
2044 return CONST0_RTX (mode
);
2045 /* Check for NaN first, because some ports (specifically the i386) do not
2046 emit correct ieee-fp code by default, and thus will generate a core
2047 dump here if we pass a NaN to REAL_VALUES_EQUAL and if REAL_VALUES_EQUAL
2048 does a floating point comparison. */
2049 else if (! REAL_VALUE_ISNAN (d
) && REAL_VALUES_EQUAL (dconst1
, d
))
2050 return CONST1_RTX (mode
);
2052 if (sizeof u
== 2 * sizeof (HOST_WIDE_INT
))
2053 return immed_double_const (u
.i
[0], u
.i
[1], mode
);
2055 /* The rest of this function handles the case where
2056 a float value requires more than 2 ints of space.
2057 It will be deleted as dead code on machines that don't need it. */
2059 /* Search the chain for an existing CONST_DOUBLE with the right value.
2060 If one is found, return it. */
2062 for (r
= const_double_chain
; r
; r
= CONST_DOUBLE_CHAIN (r
))
2063 if (! bcmp ((char *) &CONST_DOUBLE_LOW (r
), (char *) &u
, sizeof u
)
2064 && GET_MODE (r
) == mode
)
2067 /* No; make a new one and add it to the chain.
2069 We may be called by an optimizer which may be discarding any memory
2070 allocated during its processing (such as combine and loop). However,
2071 we will be leaving this constant on the chain, so we cannot tolerate
2072 freed memory. So switch to saveable_obstack for this allocation
2073 and then switch back if we were in current_obstack. */
2075 push_obstacks_nochange ();
2076 rtl_in_saveable_obstack ();
2077 r
= rtx_alloc (CONST_DOUBLE
);
2079 bcopy ((char *) &u
, (char *) &CONST_DOUBLE_LOW (r
), sizeof u
);
2082 /* Don't touch const_double_chain in nested function; see force_const_mem.
2083 Also, don't touch it if not inside any function. */
2084 if (outer_function_chain
== 0 && current_function_decl
!= 0)
2086 CONST_DOUBLE_CHAIN (r
) = const_double_chain
;
2087 const_double_chain
= r
;
2090 /* Store const0_rtx in CONST_DOUBLE_MEM since this CONST_DOUBLE is on the
2091 chain, but has not been allocated memory. Actual use of CONST_DOUBLE_MEM
2092 is only through force_const_mem. */
2094 CONST_DOUBLE_MEM (r
) = const0_rtx
;
2099 /* Return a CONST_DOUBLE rtx for a value specified by EXP,
2100 which must be a REAL_CST tree node. */
2103 immed_real_const (exp
)
2106 return immed_real_const_1 (TREE_REAL_CST (exp
), TYPE_MODE (TREE_TYPE (exp
)));
2109 /* At the end of a function, forget the memory-constants
2110 previously made for CONST_DOUBLEs. Mark them as not on real_constant_chain.
2111 Also clear out real_constant_chain and clear out all the chain-pointers. */
2114 clear_const_double_mem ()
2116 register rtx r
, next
;
2118 /* Don't touch CONST_DOUBLE_MEM for nested functions.
2119 See force_const_mem for explanation. */
2120 if (outer_function_chain
!= 0)
2123 for (r
= const_double_chain
; r
; r
= next
)
2125 next
= CONST_DOUBLE_CHAIN (r
);
2126 CONST_DOUBLE_CHAIN (r
) = 0;
2127 CONST_DOUBLE_MEM (r
) = cc0_rtx
;
2129 const_double_chain
= 0;
2132 /* Given an expression EXP with a constant value,
2133 reduce it to the sum of an assembler symbol and an integer.
2134 Store them both in the structure *VALUE.
2135 Abort if EXP does not reduce. */
2140 HOST_WIDE_INT offset
;
2144 decode_addr_const (exp
, value
)
2146 struct addr_const
*value
;
2148 register tree target
= TREE_OPERAND (exp
, 0);
2149 register int offset
= 0;
2154 if (TREE_CODE (target
) == COMPONENT_REF
2155 && (TREE_CODE (DECL_FIELD_BITPOS (TREE_OPERAND (target
, 1)))
2158 offset
+= TREE_INT_CST_LOW (DECL_FIELD_BITPOS (TREE_OPERAND (target
, 1))) / BITS_PER_UNIT
;
2159 target
= TREE_OPERAND (target
, 0);
2161 else if (TREE_CODE (target
) == ARRAY_REF
)
2163 if (TREE_CODE (TREE_OPERAND (target
, 1)) != INTEGER_CST
2164 || TREE_CODE (TYPE_SIZE (TREE_TYPE (target
))) != INTEGER_CST
)
2166 offset
+= ((TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (target
)))
2167 * TREE_INT_CST_LOW (TREE_OPERAND (target
, 1)))
2169 target
= TREE_OPERAND (target
, 0);
2175 switch (TREE_CODE (target
))
2179 x
= DECL_RTL (target
);
2183 x
= gen_rtx_MEM (FUNCTION_MODE
,
2184 gen_rtx_LABEL_REF (VOIDmode
,
2185 label_rtx (TREE_OPERAND (exp
, 0))));
2193 x
= TREE_CST_RTL (target
);
2200 if (GET_CODE (x
) != MEM
)
2205 value
->offset
= offset
;
2208 /* Uniquize all constants that appear in memory.
2209 Each constant in memory thus far output is recorded
2210 in `const_hash_table' with a `struct constant_descriptor'
2211 that contains a polish representation of the value of
2214 We cannot store the trees in the hash table
2215 because the trees may be temporary. */
2217 struct constant_descriptor
2219 struct constant_descriptor
*next
;
2225 #define MAX_HASH_TABLE 1009
2226 static struct constant_descriptor
*const_hash_table
[MAX_HASH_TABLE
];
2228 /* Compute a hash code for a constant expression. */
2235 register int len
, hi
, i
;
2236 register enum tree_code code
= TREE_CODE (exp
);
2238 /* Either set P and LEN to the address and len of something to hash and
2239 exit the switch or return a value. */
2244 p
= (char *) &TREE_INT_CST_LOW (exp
);
2245 len
= 2 * sizeof TREE_INT_CST_LOW (exp
);
2249 p
= (char *) &TREE_REAL_CST (exp
);
2250 len
= sizeof TREE_REAL_CST (exp
);
2254 p
= TREE_STRING_POINTER (exp
);
2255 len
= TREE_STRING_LENGTH (exp
);
2259 return (const_hash (TREE_REALPART (exp
)) * 5
2260 + const_hash (TREE_IMAGPART (exp
)));
2263 if (TREE_CODE (TREE_TYPE (exp
)) == SET_TYPE
)
2265 len
= int_size_in_bytes (TREE_TYPE (exp
));
2266 p
= (char *) alloca (len
);
2267 get_set_constructor_bytes (exp
, (unsigned char *) p
, len
);
2274 /* For record type, include the type in the hashing.
2275 We do not do so for array types
2276 because (1) the sizes of the elements are sufficient
2277 and (2) distinct array types can have the same constructor.
2278 Instead, we include the array size because the constructor could
2280 if (TREE_CODE (TREE_TYPE (exp
)) == RECORD_TYPE
)
2281 hi
= ((unsigned long) TREE_TYPE (exp
) & ((1 << HASHBITS
) - 1))
2284 hi
= ((5 + int_size_in_bytes (TREE_TYPE (exp
)))
2285 & ((1 << HASHBITS
) - 1)) % MAX_HASH_TABLE
;
2287 for (link
= CONSTRUCTOR_ELTS (exp
); link
; link
= TREE_CHAIN (link
))
2288 if (TREE_VALUE (link
))
2290 = (hi
* 603 + const_hash (TREE_VALUE (link
))) % MAX_HASH_TABLE
;
2297 struct addr_const value
;
2299 decode_addr_const (exp
, &value
);
2300 if (GET_CODE (value
.base
) == SYMBOL_REF
)
2302 /* Don't hash the address of the SYMBOL_REF;
2303 only use the offset and the symbol name. */
2305 p
= XSTR (value
.base
, 0);
2306 for (i
= 0; p
[i
] != 0; i
++)
2307 hi
= ((hi
* 613) + (unsigned) (p
[i
]));
2309 else if (GET_CODE (value
.base
) == LABEL_REF
)
2310 hi
= value
.offset
+ CODE_LABEL_NUMBER (XEXP (value
.base
, 0)) * 13;
2312 hi
&= (1 << HASHBITS
) - 1;
2313 hi
%= MAX_HASH_TABLE
;
2319 return (const_hash (TREE_OPERAND (exp
, 0)) * 9
2320 + const_hash (TREE_OPERAND (exp
, 1)));
2324 case NON_LVALUE_EXPR
:
2325 return const_hash (TREE_OPERAND (exp
, 0)) * 7 + 2;
2331 /* Compute hashing function */
2333 for (i
= 0; i
< len
; i
++)
2334 hi
= ((hi
* 613) + (unsigned) (p
[i
]));
2336 hi
&= (1 << HASHBITS
) - 1;
2337 hi
%= MAX_HASH_TABLE
;
2341 /* Compare a constant expression EXP with a constant-descriptor DESC.
2342 Return 1 if DESC describes a constant with the same value as EXP. */
2345 compare_constant (exp
, desc
)
2347 struct constant_descriptor
*desc
;
2349 return 0 != compare_constant_1 (exp
, desc
->contents
);
2352 /* Compare constant expression EXP with a substring P of a constant descriptor.
2353 If they match, return a pointer to the end of the substring matched.
2354 If they do not match, return 0.
2356 Since descriptors are written in polish prefix notation,
2357 this function can be used recursively to test one operand of EXP
2358 against a subdescriptor, and if it succeeds it returns the
2359 address of the subdescriptor for the next operand. */
2362 compare_constant_1 (exp
, p
)
2366 register char *strp
;
2368 register enum tree_code code
= TREE_CODE (exp
);
2370 if (code
!= (enum tree_code
) *p
++)
2373 /* Either set STRP, P and LEN to pointers and length to compare and exit the
2374 switch, or return the result of the comparison. */
2379 /* Integer constants are the same only if the same width of type. */
2380 if (*p
++ != TYPE_PRECISION (TREE_TYPE (exp
)))
2383 strp
= (char *) &TREE_INT_CST_LOW (exp
);
2384 len
= 2 * sizeof TREE_INT_CST_LOW (exp
);
2388 /* Real constants are the same only if the same width of type. */
2389 if (*p
++ != TYPE_PRECISION (TREE_TYPE (exp
)))
2392 strp
= (char *) &TREE_REAL_CST (exp
);
2393 len
= sizeof TREE_REAL_CST (exp
);
2397 if (flag_writable_strings
)
2400 if (*p
++ != TYPE_MODE (TREE_TYPE (exp
)))
2403 strp
= TREE_STRING_POINTER (exp
);
2404 len
= TREE_STRING_LENGTH (exp
);
2405 if (bcmp ((char *) &TREE_STRING_LENGTH (exp
), p
,
2406 sizeof TREE_STRING_LENGTH (exp
)))
2409 p
+= sizeof TREE_STRING_LENGTH (exp
);
2413 p
= compare_constant_1 (TREE_REALPART (exp
), p
);
2417 return compare_constant_1 (TREE_IMAGPART (exp
), p
);
2420 if (TREE_CODE (TREE_TYPE (exp
)) == SET_TYPE
)
2422 int xlen
= len
= int_size_in_bytes (TREE_TYPE (exp
));
2424 strp
= (char *) alloca (len
);
2425 get_set_constructor_bytes (exp
, (unsigned char *) strp
, len
);
2426 if (bcmp ((char *) &xlen
, p
, sizeof xlen
))
2435 int length
= list_length (CONSTRUCTOR_ELTS (exp
));
2438 if (bcmp ((char *) &length
, p
, sizeof length
))
2443 /* For record constructors, insist that the types match.
2444 For arrays, just verify both constructors are for arrays. */
2445 if (TREE_CODE (TREE_TYPE (exp
)) == RECORD_TYPE
)
2446 type
= TREE_TYPE (exp
);
2450 if (bcmp ((char *) &type
, p
, sizeof type
))
2455 /* For arrays, insist that the size in bytes match. */
2456 if (TREE_CODE (TREE_TYPE (exp
)) == ARRAY_TYPE
)
2458 int size
= int_size_in_bytes (TREE_TYPE (exp
));
2459 if (bcmp ((char *) &size
, p
, sizeof size
))
2465 for (link
= CONSTRUCTOR_ELTS (exp
); link
; link
= TREE_CHAIN (link
))
2467 if (TREE_VALUE (link
))
2469 if ((p
= compare_constant_1 (TREE_VALUE (link
), p
)) == 0)
2476 if (bcmp ((char *) &zero
, p
, sizeof zero
))
2488 struct addr_const value
;
2490 decode_addr_const (exp
, &value
);
2491 strp
= (char *) &value
.offset
;
2492 len
= sizeof value
.offset
;
2493 /* Compare the offset. */
2495 if (*p
++ != *strp
++)
2498 /* Compare symbol name. */
2499 strp
= XSTR (value
.base
, 0);
2500 len
= strlen (strp
) + 1;
2506 p
= compare_constant_1 (TREE_OPERAND (exp
, 0), p
);
2510 return compare_constant_1 (TREE_OPERAND (exp
, 1), p
);
2514 case NON_LVALUE_EXPR
:
2515 return compare_constant_1 (TREE_OPERAND (exp
, 0), p
);
2521 /* Compare constant contents. */
2523 if (*p
++ != *strp
++)
2529 /* Construct a constant descriptor for the expression EXP.
2530 It is up to the caller to enter the descriptor in the hash table. */
2532 static struct constant_descriptor
*
2533 record_constant (exp
)
2536 struct constant_descriptor
*next
= 0;
2539 /* Make a struct constant_descriptor. The first two pointers will
2540 be filled in later. Here we just leave space for them. */
2542 obstack_grow (&permanent_obstack
, (char *) &next
, sizeof next
);
2543 obstack_grow (&permanent_obstack
, (char *) &label
, sizeof label
);
2544 record_constant_1 (exp
);
2545 return (struct constant_descriptor
*) obstack_finish (&permanent_obstack
);
2548 /* Add a description of constant expression EXP
2549 to the object growing in `permanent_obstack'.
2550 No need to return its address; the caller will get that
2551 from the obstack when the object is complete. */
2554 record_constant_1 (exp
)
2557 register char *strp
;
2559 register enum tree_code code
= TREE_CODE (exp
);
2561 obstack_1grow (&permanent_obstack
, (unsigned int) code
);
2566 obstack_1grow (&permanent_obstack
, TYPE_PRECISION (TREE_TYPE (exp
)));
2567 strp
= (char *) &TREE_INT_CST_LOW (exp
);
2568 len
= 2 * sizeof TREE_INT_CST_LOW (exp
);
2572 obstack_1grow (&permanent_obstack
, TYPE_PRECISION (TREE_TYPE (exp
)));
2573 strp
= (char *) &TREE_REAL_CST (exp
);
2574 len
= sizeof TREE_REAL_CST (exp
);
2578 if (flag_writable_strings
)
2581 obstack_1grow (&permanent_obstack
, TYPE_MODE (TREE_TYPE (exp
)));
2582 strp
= TREE_STRING_POINTER (exp
);
2583 len
= TREE_STRING_LENGTH (exp
);
2584 obstack_grow (&permanent_obstack
, (char *) &TREE_STRING_LENGTH (exp
),
2585 sizeof TREE_STRING_LENGTH (exp
));
2589 record_constant_1 (TREE_REALPART (exp
));
2590 record_constant_1 (TREE_IMAGPART (exp
));
2594 if (TREE_CODE (TREE_TYPE (exp
)) == SET_TYPE
)
2596 int nbytes
= int_size_in_bytes (TREE_TYPE (exp
));
2597 obstack_grow (&permanent_obstack
, &nbytes
, sizeof (nbytes
));
2598 obstack_blank (&permanent_obstack
, nbytes
);
2599 get_set_constructor_bytes
2600 (exp
, (unsigned char *) permanent_obstack
.next_free
-nbytes
,
2607 int length
= list_length (CONSTRUCTOR_ELTS (exp
));
2610 obstack_grow (&permanent_obstack
, (char *) &length
, sizeof length
);
2612 /* For record constructors, insist that the types match.
2613 For arrays, just verify both constructors are for arrays. */
2614 if (TREE_CODE (TREE_TYPE (exp
)) == RECORD_TYPE
)
2615 type
= TREE_TYPE (exp
);
2618 obstack_grow (&permanent_obstack
, (char *) &type
, sizeof type
);
2620 /* For arrays, insist that the size in bytes match. */
2621 if (TREE_CODE (TREE_TYPE (exp
)) == ARRAY_TYPE
)
2623 int size
= int_size_in_bytes (TREE_TYPE (exp
));
2624 obstack_grow (&permanent_obstack
, (char *) &size
, sizeof size
);
2627 for (link
= CONSTRUCTOR_ELTS (exp
); link
; link
= TREE_CHAIN (link
))
2629 if (TREE_VALUE (link
))
2630 record_constant_1 (TREE_VALUE (link
));
2635 obstack_grow (&permanent_obstack
,
2636 (char *) &zero
, sizeof zero
);
2644 struct addr_const value
;
2646 decode_addr_const (exp
, &value
);
2647 /* Record the offset. */
2648 obstack_grow (&permanent_obstack
,
2649 (char *) &value
.offset
, sizeof value
.offset
);
2650 /* Record the symbol name. */
2651 obstack_grow (&permanent_obstack
, XSTR (value
.base
, 0),
2652 strlen (XSTR (value
.base
, 0)) + 1);
2658 record_constant_1 (TREE_OPERAND (exp
, 0));
2659 record_constant_1 (TREE_OPERAND (exp
, 1));
2664 case NON_LVALUE_EXPR
:
2665 record_constant_1 (TREE_OPERAND (exp
, 0));
2672 /* Record constant contents. */
2673 obstack_grow (&permanent_obstack
, strp
, len
);
2676 /* Record a list of constant expressions that were passed to
2677 output_constant_def but that could not be output right away. */
2679 struct deferred_constant
2681 struct deferred_constant
*next
;
2687 static struct deferred_constant
*deferred_constants
;
2689 /* Another list of constants which should be output after the
2691 static struct deferred_constant
*after_function_constants
;
2693 /* Nonzero means defer output of addressed subconstants
2694 (i.e., those for which output_constant_def is called.) */
2695 static int defer_addressed_constants_flag
;
2697 /* Start deferring output of subconstants. */
2700 defer_addressed_constants ()
2702 defer_addressed_constants_flag
++;
2705 /* Stop deferring output of subconstants,
2706 and output now all those that have been deferred. */
2709 output_deferred_addressed_constants ()
2711 struct deferred_constant
*p
, *next
;
2713 defer_addressed_constants_flag
--;
2715 if (defer_addressed_constants_flag
> 0)
2718 for (p
= deferred_constants
; p
; p
= next
)
2720 output_constant_def_contents (p
->exp
, p
->reloc
, p
->labelno
);
2725 deferred_constants
= 0;
2728 /* Output any constants which should appear after a function. */
2731 output_after_function_constants ()
2733 struct deferred_constant
*p
, *next
;
2735 for (p
= after_function_constants
; p
; p
= next
)
2737 output_constant_def_contents (p
->exp
, p
->reloc
, p
->labelno
);
2742 after_function_constants
= 0;
2745 /* Make a copy of the whole tree structure for a constant.
2746 This handles the same types of nodes that compare_constant
2747 and record_constant handle. */
2753 switch (TREE_CODE (exp
))
2756 /* For ADDR_EXPR, we do not want to copy the decl whose address
2757 is requested. We do want to copy constants though. */
2758 if (TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp
, 0))) == 'c')
2759 return build1 (TREE_CODE (exp
), TREE_TYPE (exp
),
2760 copy_constant (TREE_OPERAND (exp
, 0)));
2762 return copy_node (exp
);
2767 return copy_node (exp
);
2770 return build_complex (TREE_TYPE (exp
),
2771 copy_constant (TREE_REALPART (exp
)),
2772 copy_constant (TREE_IMAGPART (exp
)));
2776 return build (TREE_CODE (exp
), TREE_TYPE (exp
),
2777 copy_constant (TREE_OPERAND (exp
, 0)),
2778 copy_constant (TREE_OPERAND (exp
, 1)));
2782 case NON_LVALUE_EXPR
:
2783 return build1 (TREE_CODE (exp
), TREE_TYPE (exp
),
2784 copy_constant (TREE_OPERAND (exp
, 0)));
2788 tree copy
= copy_node (exp
);
2789 tree list
= copy_list (CONSTRUCTOR_ELTS (exp
));
2792 CONSTRUCTOR_ELTS (copy
) = list
;
2793 for (tail
= list
; tail
; tail
= TREE_CHAIN (tail
))
2794 TREE_VALUE (tail
) = copy_constant (TREE_VALUE (tail
));
2795 if (TREE_CODE (TREE_TYPE (exp
)) == SET_TYPE
)
2796 for (tail
= list
; tail
; tail
= TREE_CHAIN (tail
))
2797 TREE_PURPOSE (tail
) = copy_constant (TREE_PURPOSE (tail
));
2807 /* Return an rtx representing a reference to constant data in memory
2808 for the constant expression EXP.
2810 If assembler code for such a constant has already been output,
2811 return an rtx to refer to it.
2812 Otherwise, output such a constant in memory (or defer it for later)
2813 and generate an rtx for it.
2815 The TREE_CST_RTL of EXP is set up to point to that rtx.
2816 The const_hash_table records which constants already have label strings. */
2819 output_constant_def (exp
)
2823 register struct constant_descriptor
*desc
;
2829 if (TREE_CST_RTL (exp
))
2830 return TREE_CST_RTL (exp
);
2832 /* Make sure any other constants whose addresses appear in EXP
2833 are assigned label numbers. */
2835 reloc
= output_addressed_constants (exp
);
2837 /* Compute hash code of EXP. Search the descriptors for that hash code
2838 to see if any of them describes EXP. If yes, the descriptor records
2839 the label number already assigned. */
2841 hash
= const_hash (exp
) % MAX_HASH_TABLE
;
2843 for (desc
= const_hash_table
[hash
]; desc
; desc
= desc
->next
)
2844 if (compare_constant (exp
, desc
))
2846 found
= desc
->label
;
2852 /* No constant equal to EXP is known to have been output.
2853 Make a constant descriptor to enter EXP in the hash table.
2854 Assign the label number and record it in the descriptor for
2855 future calls to this function to find. */
2857 /* Create a string containing the label name, in LABEL. */
2858 ASM_GENERATE_INTERNAL_LABEL (label
, "LC", const_labelno
);
2860 desc
= record_constant (exp
);
2861 desc
->next
= const_hash_table
[hash
];
2863 = (char *) obstack_copy0 (&permanent_obstack
, label
, strlen (label
));
2864 const_hash_table
[hash
] = desc
;
2868 /* Create a string containing the label name, in LABEL. */
2869 ASM_GENERATE_INTERNAL_LABEL (label
, "LC", const_labelno
);
2872 /* We have a symbol name; construct the SYMBOL_REF and the MEM. */
2874 push_obstacks_nochange ();
2875 if (TREE_PERMANENT (exp
))
2876 end_temporary_allocation ();
2878 def
= gen_rtx_SYMBOL_REF (Pmode
, desc
->label
);
2881 = gen_rtx_MEM (TYPE_MODE (TREE_TYPE (exp
)), def
);
2882 RTX_UNCHANGING_P (TREE_CST_RTL (exp
)) = 1;
2883 if (AGGREGATE_TYPE_P (TREE_TYPE (exp
)))
2884 MEM_IN_STRUCT_P (TREE_CST_RTL (exp
)) = 1;
2888 /* Optionally set flags or add text to the name to record information
2889 such as that it is a function name. If the name is changed, the macro
2890 ASM_OUTPUT_LABELREF will have to know how to strip this information. */
2891 #ifdef ENCODE_SECTION_INFO
2892 ENCODE_SECTION_INFO (exp
);
2895 /* If this is the first time we've seen this particular constant,
2896 output it (or defer its output for later). */
2899 int after_function
= 0;
2901 #ifdef CONSTANT_AFTER_FUNCTION_P
2902 if (current_function_decl
!= 0
2903 && CONSTANT_AFTER_FUNCTION_P (exp
))
2907 if (defer_addressed_constants_flag
|| after_function
)
2909 struct deferred_constant
*p
;
2910 p
= (struct deferred_constant
*) xmalloc (sizeof (struct deferred_constant
));
2912 push_obstacks_nochange ();
2913 suspend_momentary ();
2914 p
->exp
= copy_constant (exp
);
2917 p
->labelno
= const_labelno
++;
2920 p
->next
= after_function_constants
;
2921 after_function_constants
= p
;
2925 p
->next
= deferred_constants
;
2926 deferred_constants
= p
;
2930 output_constant_def_contents (exp
, reloc
, const_labelno
++);
2933 return TREE_CST_RTL (exp
);
2936 /* Now output assembler code to define the label for EXP,
2937 and follow it with the data of EXP. */
2940 output_constant_def_contents (exp
, reloc
, labelno
)
2947 if (IN_NAMED_SECTION (exp
))
2948 named_section (exp
, NULL
, reloc
);
2951 /* First switch to text section, except for writable strings. */
2952 #ifdef SELECT_SECTION
2953 SELECT_SECTION (exp
, reloc
);
2955 if (((TREE_CODE (exp
) == STRING_CST
) && flag_writable_strings
)
2956 || (flag_pic
&& reloc
))
2959 readonly_data_section ();
2963 /* Align the location counter as required by EXP's data type. */
2964 align
= TYPE_ALIGN (TREE_TYPE (exp
));
2965 #ifdef CONSTANT_ALIGNMENT
2966 align
= CONSTANT_ALIGNMENT (exp
, align
);
2969 if (align
> BITS_PER_UNIT
)
2970 ASM_OUTPUT_ALIGN (asm_out_file
, floor_log2 (align
/ BITS_PER_UNIT
));
2972 /* Output the label itself. */
2973 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, "LC", labelno
);
2975 /* Output the value of EXP. */
2976 output_constant (exp
,
2977 (TREE_CODE (exp
) == STRING_CST
2978 ? TREE_STRING_LENGTH (exp
)
2979 : int_size_in_bytes (TREE_TYPE (exp
))));
2983 /* Similar hash facility for making memory-constants
2984 from constant rtl-expressions. It is used on RISC machines
2985 where immediate integer arguments and constant addresses are restricted
2986 so that such constants must be stored in memory.
2988 This pool of constants is reinitialized for each function
2989 so each function gets its own constants-pool that comes right before it.
2991 All structures allocated here are discarded when functions are saved for
2992 inlining, so they do not need to be allocated permanently. */
2994 #define MAX_RTX_HASH_TABLE 61
2995 static struct constant_descriptor
**const_rtx_hash_table
;
2997 /* Structure to represent sufficient information about a constant so that
2998 it can be output when the constant pool is output, so that function
2999 integration can be done, and to simplify handling on machines that reference
3000 constant pool as base+displacement. */
3002 struct pool_constant
3004 struct constant_descriptor
*desc
;
3005 struct pool_constant
*next
;
3006 enum machine_mode mode
;
3014 /* Pointers to first and last constant in pool. */
3016 static struct pool_constant
*first_pool
, *last_pool
;
3018 /* Current offset in constant pool (does not include any machine-specific
3021 static int pool_offset
;
3023 /* Structure used to maintain hash table mapping symbols used to their
3024 corresponding constants. */
3029 struct pool_constant
*pool
;
3030 struct pool_sym
*next
;
3033 static struct pool_sym
**const_rtx_sym_hash_table
;
3035 /* Hash code for a SYMBOL_REF with CONSTANT_POOL_ADDRESS_P true.
3036 The argument is XSTR (... , 0) */
3038 #define SYMHASH(LABEL) \
3039 ((((unsigned long) (LABEL)) & ((1 << HASHBITS) - 1)) % MAX_RTX_HASH_TABLE)
3041 /* Initialize constant pool hashing for next function. */
3044 init_const_rtx_hash_table ()
3046 const_rtx_hash_table
3047 = ((struct constant_descriptor
**)
3048 oballoc (MAX_RTX_HASH_TABLE
* sizeof (struct constant_descriptor
*)));
3049 const_rtx_sym_hash_table
3050 = ((struct pool_sym
**)
3051 oballoc (MAX_RTX_HASH_TABLE
* sizeof (struct pool_sym
*)));
3052 bzero ((char *) const_rtx_hash_table
,
3053 MAX_RTX_HASH_TABLE
* sizeof (struct constant_descriptor
*));
3054 bzero ((char *) const_rtx_sym_hash_table
,
3055 MAX_RTX_HASH_TABLE
* sizeof (struct pool_sym
*));
3057 first_pool
= last_pool
= 0;
3061 /* Save and restore status for a nested function. */
3064 save_varasm_status (p
, context
)
3068 p
->const_rtx_hash_table
= const_rtx_hash_table
;
3069 p
->const_rtx_sym_hash_table
= const_rtx_sym_hash_table
;
3070 p
->first_pool
= first_pool
;
3071 p
->last_pool
= last_pool
;
3072 p
->pool_offset
= pool_offset
;
3073 p
->const_double_chain
= const_double_chain
;
3075 /* If we are pushing to toplevel, we can't reuse const_double_chain. */
3076 if (context
== NULL_TREE
)
3077 const_double_chain
= 0;
3081 restore_varasm_status (p
)
3084 const_rtx_hash_table
= p
->const_rtx_hash_table
;
3085 const_rtx_sym_hash_table
= p
->const_rtx_sym_hash_table
;
3086 first_pool
= p
->first_pool
;
3087 last_pool
= p
->last_pool
;
3088 pool_offset
= p
->pool_offset
;
3089 const_double_chain
= p
->const_double_chain
;
3092 enum kind
{ RTX_DOUBLE
, RTX_INT
};
3096 #ifdef ONLY_INT_FIELDS
3097 unsigned int kind
: 16;
3098 unsigned int mode
: 16;
3100 enum kind kind
: 16;
3101 enum machine_mode mode
: 16;
3104 union real_extract du
;
3105 struct addr_const addr
;
3106 struct {HOST_WIDE_INT high
, low
;} di
;
3110 /* Express an rtx for a constant integer (perhaps symbolic)
3111 as the sum of a symbol or label plus an explicit integer.
3112 They are stored into VALUE. */
3115 decode_rtx_const (mode
, x
, value
)
3116 enum machine_mode mode
;
3118 struct rtx_const
*value
;
3120 /* Clear the whole structure, including any gaps. */
3123 int *p
= (int *) value
;
3124 int *end
= (int *) (value
+ 1);
3129 value
->kind
= RTX_INT
; /* Most usual kind. */
3132 switch (GET_CODE (x
))
3135 value
->kind
= RTX_DOUBLE
;
3136 if (GET_MODE (x
) != VOIDmode
)
3138 value
->mode
= GET_MODE (x
);
3139 bcopy ((char *) &CONST_DOUBLE_LOW (x
),
3140 (char *) &value
->un
.du
, sizeof value
->un
.du
);
3144 value
->un
.di
.low
= CONST_DOUBLE_LOW (x
);
3145 value
->un
.di
.high
= CONST_DOUBLE_HIGH (x
);
3150 value
->un
.addr
.offset
= INTVAL (x
);
3156 value
->un
.addr
.base
= x
;
3161 if (GET_CODE (x
) == PLUS
)
3163 value
->un
.addr
.base
= XEXP (x
, 0);
3164 if (GET_CODE (XEXP (x
, 1)) != CONST_INT
)
3166 value
->un
.addr
.offset
= INTVAL (XEXP (x
, 1));
3168 else if (GET_CODE (x
) == MINUS
)
3170 value
->un
.addr
.base
= XEXP (x
, 0);
3171 if (GET_CODE (XEXP (x
, 1)) != CONST_INT
)
3173 value
->un
.addr
.offset
= - INTVAL (XEXP (x
, 1));
3183 if (value
->kind
== RTX_INT
&& value
->un
.addr
.base
!= 0)
3184 switch (GET_CODE (value
->un
.addr
.base
))
3188 /* Use the string's address, not the SYMBOL_REF's address,
3189 for the sake of addresses of library routines.
3190 For a LABEL_REF, compare labels. */
3191 value
->un
.addr
.base
= XEXP (value
->un
.addr
.base
, 0);
3198 /* Given a MINUS expression, simplify it if both sides
3199 include the same symbol. */
3202 simplify_subtraction (x
)
3205 struct rtx_const val0
, val1
;
3207 decode_rtx_const (GET_MODE (x
), XEXP (x
, 0), &val0
);
3208 decode_rtx_const (GET_MODE (x
), XEXP (x
, 1), &val1
);
3210 if (val0
.un
.addr
.base
== val1
.un
.addr
.base
)
3211 return GEN_INT (val0
.un
.addr
.offset
- val1
.un
.addr
.offset
);
3215 /* Compute a hash code for a constant RTL expression. */
3218 const_hash_rtx (mode
, x
)
3219 enum machine_mode mode
;
3225 struct rtx_const value
;
3226 decode_rtx_const (mode
, x
, &value
);
3228 /* Compute hashing function */
3230 for (i
= 0; i
< sizeof value
/ sizeof (int); i
++)
3231 hi
+= ((int *) &value
)[i
];
3233 hi
&= (1 << HASHBITS
) - 1;
3234 hi
%= MAX_RTX_HASH_TABLE
;
3238 /* Compare a constant rtl object X with a constant-descriptor DESC.
3239 Return 1 if DESC describes a constant with the same value as X. */
3242 compare_constant_rtx (mode
, x
, desc
)
3243 enum machine_mode mode
;
3245 struct constant_descriptor
*desc
;
3247 register int *p
= (int *) desc
->contents
;
3250 struct rtx_const value
;
3252 decode_rtx_const (mode
, x
, &value
);
3253 strp
= (int *) &value
;
3254 len
= sizeof value
/ sizeof (int);
3256 /* Compare constant contents. */
3258 if (*p
++ != *strp
++)
3264 /* Construct a constant descriptor for the rtl-expression X.
3265 It is up to the caller to enter the descriptor in the hash table. */
3267 static struct constant_descriptor
*
3268 record_constant_rtx (mode
, x
)
3269 enum machine_mode mode
;
3272 struct constant_descriptor
*ptr
;
3274 struct rtx_const value
;
3276 decode_rtx_const (mode
, x
, &value
);
3278 /* Put these things in the saveable obstack so we can ensure it won't
3279 be freed if we are called from combine or some other phase that discards
3280 memory allocated from function_obstack (current_obstack). */
3281 obstack_grow (saveable_obstack
, &ptr
, sizeof ptr
);
3282 obstack_grow (saveable_obstack
, &label
, sizeof label
);
3284 /* Record constant contents. */
3285 obstack_grow (saveable_obstack
, &value
, sizeof value
);
3287 return (struct constant_descriptor
*) obstack_finish (saveable_obstack
);
3290 /* Given a constant rtx X, make (or find) a memory constant for its value
3291 and return a MEM rtx to refer to it in memory. */
3294 force_const_mem (mode
, x
)
3295 enum machine_mode mode
;
3299 register struct constant_descriptor
*desc
;
3304 /* If we want this CONST_DOUBLE in the same mode as it is in memory
3305 (this will always be true for floating CONST_DOUBLEs that have been
3306 placed in memory, but not for VOIDmode (integer) CONST_DOUBLEs),
3307 use the previous copy. Otherwise, make a new one. Note that in
3308 the unlikely event that this same CONST_DOUBLE is used in two different
3309 modes in an alternating fashion, we will allocate a lot of different
3310 memory locations, but this should be extremely rare. */
3312 /* Don't use CONST_DOUBLE_MEM in a nested function.
3313 Nested functions have their own constant pools,
3314 so they can't share the same values in CONST_DOUBLE_MEM
3315 with the containing function. */
3316 if (outer_function_chain
== 0)
3317 if (GET_CODE (x
) == CONST_DOUBLE
3318 && GET_CODE (CONST_DOUBLE_MEM (x
)) == MEM
3319 && GET_MODE (CONST_DOUBLE_MEM (x
)) == mode
)
3320 return CONST_DOUBLE_MEM (x
);
3322 /* Compute hash code of X. Search the descriptors for that hash code
3323 to see if any of them describes X. If yes, the descriptor records
3324 the label number already assigned. */
3326 hash
= const_hash_rtx (mode
, x
);
3328 for (desc
= const_rtx_hash_table
[hash
]; desc
; desc
= desc
->next
)
3329 if (compare_constant_rtx (mode
, x
, desc
))
3331 found
= desc
->label
;
3337 register struct pool_constant
*pool
;
3338 register struct pool_sym
*sym
;
3341 /* No constant equal to X is known to have been output.
3342 Make a constant descriptor to enter X in the hash table.
3343 Assign the label number and record it in the descriptor for
3344 future calls to this function to find. */
3346 desc
= record_constant_rtx (mode
, x
);
3347 desc
->next
= const_rtx_hash_table
[hash
];
3348 const_rtx_hash_table
[hash
] = desc
;
3350 /* Align the location counter as required by EXP's data type. */
3351 align
= (mode
== VOIDmode
) ? UNITS_PER_WORD
: GET_MODE_SIZE (mode
);
3352 if (align
> BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
)
3353 align
= BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
;
3355 pool_offset
+= align
- 1;
3356 pool_offset
&= ~ (align
- 1);
3358 /* If RTL is not being placed into the saveable obstack, make a
3359 copy of X that is in the saveable obstack in case we are
3360 being called from combine or some other phase that discards
3361 memory it allocates. We used to only do this if it is a
3362 CONST; however, reload can allocate a CONST_INT when
3363 eliminating registers. */
3364 if (rtl_obstack
!= saveable_obstack
3365 && (GET_CODE (x
) == CONST
|| GET_CODE (x
) == CONST_INT
))
3367 push_obstacks_nochange ();
3368 rtl_in_saveable_obstack ();
3370 if (GET_CODE (x
) == CONST
)
3371 x
= gen_rtx_CONST (GET_MODE (x
),
3372 gen_rtx_PLUS (GET_MODE (x
),
3373 XEXP (XEXP (x
, 0), 0),
3374 XEXP (XEXP (x
, 0), 1)));
3376 x
= GEN_INT (INTVAL (x
));
3381 /* Allocate a pool constant descriptor, fill it in, and chain it in. */
3383 pool
= (struct pool_constant
*) savealloc (sizeof (struct pool_constant
));
3387 pool
->labelno
= const_labelno
;
3388 pool
->align
= align
;
3389 pool
->offset
= pool_offset
;
3396 last_pool
->next
= pool
;
3399 pool_offset
+= GET_MODE_SIZE (mode
);
3401 /* Create a string containing the label name, in LABEL. */
3402 ASM_GENERATE_INTERNAL_LABEL (label
, "LC", const_labelno
);
3407 = (char *) obstack_copy0 (saveable_obstack
, label
, strlen (label
));
3409 /* Add label to symbol hash table. */
3410 hash
= SYMHASH (found
);
3411 sym
= (struct pool_sym
*) savealloc (sizeof (struct pool_sym
));
3414 sym
->next
= const_rtx_sym_hash_table
[hash
];
3415 const_rtx_sym_hash_table
[hash
] = sym
;
3418 /* We have a symbol name; construct the SYMBOL_REF and the MEM. */
3420 def
= gen_rtx_MEM (mode
, gen_rtx_SYMBOL_REF (Pmode
, found
));
3422 RTX_UNCHANGING_P (def
) = 1;
3423 /* Mark the symbol_ref as belonging to this constants pool. */
3424 CONSTANT_POOL_ADDRESS_P (XEXP (def
, 0)) = 1;
3425 current_function_uses_const_pool
= 1;
3427 if (outer_function_chain
== 0)
3428 if (GET_CODE (x
) == CONST_DOUBLE
)
3430 if (CONST_DOUBLE_MEM (x
) == cc0_rtx
)
3432 CONST_DOUBLE_CHAIN (x
) = const_double_chain
;
3433 const_double_chain
= x
;
3435 CONST_DOUBLE_MEM (x
) = def
;
3441 /* Given a SYMBOL_REF with CONSTANT_POOL_ADDRESS_P true, return a pointer to
3442 the corresponding pool_constant structure. */
3444 static struct pool_constant
*
3445 find_pool_constant (addr
)
3448 struct pool_sym
*sym
;
3449 char *label
= XSTR (addr
, 0);
3451 for (sym
= const_rtx_sym_hash_table
[SYMHASH (label
)]; sym
; sym
= sym
->next
)
3452 if (sym
->label
== label
)
3458 /* Given a constant pool SYMBOL_REF, return the corresponding constant. */
3461 get_pool_constant (addr
)
3464 return (find_pool_constant (addr
))->constant
;
3467 /* Similar, return the mode. */
3470 get_pool_mode (addr
)
3473 return (find_pool_constant (addr
))->mode
;
3476 /* Similar, return the offset in the constant pool. */
3479 get_pool_offset (addr
)
3482 return (find_pool_constant (addr
))->offset
;
3485 /* Return the size of the constant pool. */
3493 /* Write all the constants in the constant pool. */
3496 output_constant_pool (fnname
, fndecl
)
3500 struct pool_constant
*pool
;
3502 union real_extract u
;
3504 /* It is possible for gcc to call force_const_mem and then to later
3505 discard the instructions which refer to the constant. In such a
3506 case we do not need to output the constant. */
3507 if (optimize
>= 0 && flag_expensive_optimizations
)
3508 mark_constant_pool ();
3510 #ifdef ASM_OUTPUT_POOL_PROLOGUE
3511 ASM_OUTPUT_POOL_PROLOGUE (asm_out_file
, fnname
, fndecl
, pool_offset
);
3514 for (pool
= first_pool
; pool
; pool
= pool
->next
)
3521 /* See if X is a LABEL_REF (or a CONST referring to a LABEL_REF)
3522 whose CODE_LABEL has been deleted. This can occur if a jump table
3523 is eliminated by optimization. If so, write a constant of zero
3524 instead. Note that this can also happen by turning the
3525 CODE_LABEL into a NOTE. */
3526 if (((GET_CODE (x
) == LABEL_REF
3527 && (INSN_DELETED_P (XEXP (x
, 0))
3528 || GET_CODE (XEXP (x
, 0)) == NOTE
)))
3529 || (GET_CODE (x
) == CONST
&& GET_CODE (XEXP (x
, 0)) == PLUS
3530 && GET_CODE (XEXP (XEXP (x
, 0), 0)) == LABEL_REF
3531 && (INSN_DELETED_P (XEXP (XEXP (XEXP (x
, 0), 0), 0))
3532 || GET_CODE (XEXP (XEXP (XEXP (x
, 0), 0), 0)) == NOTE
)))
3535 /* First switch to correct section. */
3536 #ifdef SELECT_RTX_SECTION
3537 SELECT_RTX_SECTION (pool
->mode
, x
);
3539 readonly_data_section ();
3542 #ifdef ASM_OUTPUT_SPECIAL_POOL_ENTRY
3543 ASM_OUTPUT_SPECIAL_POOL_ENTRY (asm_out_file
, x
, pool
->mode
,
3544 pool
->align
, pool
->labelno
, done
);
3547 if (pool
->align
> 1)
3548 ASM_OUTPUT_ALIGN (asm_out_file
, exact_log2 (pool
->align
));
3550 /* Output the label. */
3551 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, "LC", pool
->labelno
);
3553 /* Output the value of the constant itself. */
3554 switch (GET_MODE_CLASS (pool
->mode
))
3557 if (GET_CODE (x
) != CONST_DOUBLE
)
3560 bcopy ((char *) &CONST_DOUBLE_LOW (x
), (char *) &u
, sizeof u
);
3561 assemble_real (u
.d
, pool
->mode
);
3565 case MODE_PARTIAL_INT
:
3566 assemble_integer (x
, GET_MODE_SIZE (pool
->mode
), 1);
3573 #ifdef ASM_OUTPUT_SPECIAL_POOL_ENTRY
3579 #ifdef ASM_OUTPUT_POOL_EPILOGUE
3580 ASM_OUTPUT_POOL_EPILOGUE (asm_out_file
, fnname
, fndecl
, pool_offset
);
3583 /* Done with this pool. */
3584 first_pool
= last_pool
= 0;
3587 /* Look through the instructions for this function, and mark all the
3588 entries in the constant pool which are actually being used. */
3591 mark_constant_pool ()
3594 struct pool_constant
*pool
;
3596 if (first_pool
== 0)
3599 for (pool
= first_pool
; pool
; pool
= pool
->next
)
3602 for (insn
= get_insns (); insn
; insn
= NEXT_INSN (insn
))
3603 if (GET_RTX_CLASS (GET_CODE (insn
)) == 'i')
3604 mark_constants (PATTERN (insn
));
3606 for (insn
= current_function_epilogue_delay_list
;
3608 insn
= XEXP (insn
, 1))
3609 if (GET_RTX_CLASS (GET_CODE (insn
)) == 'i')
3610 mark_constants (PATTERN (insn
));
3618 register char *format_ptr
;
3623 if (GET_CODE (x
) == SYMBOL_REF
)
3625 if (CONSTANT_POOL_ADDRESS_P (x
))
3626 find_pool_constant (x
)->mark
= 1;
3629 /* Never search inside a CONST_DOUBLE, because CONST_DOUBLE_MEM may be
3630 a MEM, but does not constitute a use of that MEM. This is particularly
3631 important inside a nested function, because CONST_DOUBLE_MEM may be
3632 a reference to a MEM in the parent's constant pool. See the comment
3633 in force_const_mem. */
3634 else if (GET_CODE (x
) == CONST_DOUBLE
)
3637 /* Insns may appear inside a SEQUENCE. Only check the patterns of
3638 insns, not any notes that may be attached. We don't want to mark
3639 a constant just because it happens to appear in a REG_EQUIV note. */
3640 if (GET_RTX_CLASS (GET_CODE (x
)) == 'i')
3642 mark_constants (PATTERN (x
));
3646 format_ptr
= GET_RTX_FORMAT (GET_CODE (x
));
3648 for (i
= 0; i
< GET_RTX_LENGTH (GET_CODE (x
)); i
++)
3650 switch (*format_ptr
++)
3653 mark_constants (XEXP (x
, i
));
3657 if (XVEC (x
, i
) != 0)
3661 for (j
= 0; j
< XVECLEN (x
, i
); j
++)
3662 mark_constants (XVECEXP (x
, i
, j
));
3681 /* Find all the constants whose addresses are referenced inside of EXP,
3682 and make sure assembler code with a label has been output for each one.
3683 Indicate whether an ADDR_EXPR has been encountered. */
3686 output_addressed_constants (exp
)
3691 switch (TREE_CODE (exp
))
3695 register tree constant
= TREE_OPERAND (exp
, 0);
3697 while (TREE_CODE (constant
) == COMPONENT_REF
)
3699 constant
= TREE_OPERAND (constant
, 0);
3702 if (TREE_CODE_CLASS (TREE_CODE (constant
)) == 'c'
3703 || TREE_CODE (constant
) == CONSTRUCTOR
)
3704 /* No need to do anything here
3705 for addresses of variables or functions. */
3706 output_constant_def (constant
);
3713 reloc
= output_addressed_constants (TREE_OPERAND (exp
, 0));
3714 reloc
|= output_addressed_constants (TREE_OPERAND (exp
, 1));
3719 case NON_LVALUE_EXPR
:
3720 reloc
= output_addressed_constants (TREE_OPERAND (exp
, 0));
3726 for (link
= CONSTRUCTOR_ELTS (exp
); link
; link
= TREE_CHAIN (link
))
3727 if (TREE_VALUE (link
) != 0)
3728 reloc
|= output_addressed_constants (TREE_VALUE (link
));
3738 /* Output assembler code for constant EXP to FILE, with no label.
3739 This includes the pseudo-op such as ".int" or ".byte", and a newline.
3740 Assumes output_addressed_constants has been done on EXP already.
3742 Generate exactly SIZE bytes of assembler data, padding at the end
3743 with zeros if necessary. SIZE must always be specified.
3745 SIZE is important for structure constructors,
3746 since trailing members may have been omitted from the constructor.
3747 It is also important for initialization of arrays from string constants
3748 since the full length of the string constant might not be wanted.
3749 It is also needed for initialization of unions, where the initializer's
3750 type is just one member, and that may not be as long as the union.
3752 There a case in which we would fail to output exactly SIZE bytes:
3753 for a structure constructor that wants to produce more than SIZE bytes.
3754 But such constructors will never be generated for any possible input. */
3757 output_constant (exp
, size
)
3761 register enum tree_code code
= TREE_CODE (TREE_TYPE (exp
));
3766 /* Eliminate the NON_LVALUE_EXPR_EXPR that makes a cast not be an lvalue.
3767 That way we get the constant (we hope) inside it. Also, strip off any
3768 NOP_EXPR that converts between two record, union, array, or set types. */
3769 while ((TREE_CODE (exp
) == NOP_EXPR
3770 && (TREE_TYPE (exp
) == TREE_TYPE (TREE_OPERAND (exp
, 0))
3771 || AGGREGATE_TYPE_P (TREE_TYPE (exp
))))
3772 || TREE_CODE (exp
) == NON_LVALUE_EXPR
)
3773 exp
= TREE_OPERAND (exp
, 0);
3775 /* Allow a constructor with no elements for any data type.
3776 This means to fill the space with zeros. */
3777 if (TREE_CODE (exp
) == CONSTRUCTOR
&& CONSTRUCTOR_ELTS (exp
) == 0)
3779 assemble_zeros (size
);
3790 case REFERENCE_TYPE
:
3791 /* ??? What about (int)((float)(int)&foo + 4) */
3792 while (TREE_CODE (exp
) == NOP_EXPR
|| TREE_CODE (exp
) == CONVERT_EXPR
3793 || TREE_CODE (exp
) == NON_LVALUE_EXPR
)
3794 exp
= TREE_OPERAND (exp
, 0);
3796 if (! assemble_integer (expand_expr (exp
, NULL_RTX
, VOIDmode
,
3797 EXPAND_INITIALIZER
),
3799 error ("initializer for integer value is too complicated");
3804 if (TREE_CODE (exp
) != REAL_CST
)
3805 error ("initializer for floating value is not a floating constant");
3807 assemble_real (TREE_REAL_CST (exp
),
3808 mode_for_size (size
* BITS_PER_UNIT
, MODE_FLOAT
, 0));
3813 output_constant (TREE_REALPART (exp
), size
/ 2);
3814 output_constant (TREE_IMAGPART (exp
), size
/ 2);
3815 size
-= (size
/ 2) * 2;
3819 if (TREE_CODE (exp
) == CONSTRUCTOR
)
3821 output_constructor (exp
, size
);
3824 else if (TREE_CODE (exp
) == STRING_CST
)
3828 if (size
> TREE_STRING_LENGTH (exp
))
3830 excess
= size
- TREE_STRING_LENGTH (exp
);
3831 size
= TREE_STRING_LENGTH (exp
);
3834 assemble_string (TREE_STRING_POINTER (exp
), size
);
3843 if (TREE_CODE (exp
) == CONSTRUCTOR
)
3844 output_constructor (exp
, size
);
3850 if (TREE_CODE (exp
) == INTEGER_CST
)
3851 assemble_integer (expand_expr (exp
, NULL_RTX
,
3852 VOIDmode
, EXPAND_INITIALIZER
),
3854 else if (TREE_CODE (exp
) == CONSTRUCTOR
)
3856 unsigned char *buffer
= (unsigned char *) alloca (size
);
3857 if (get_set_constructor_bytes (exp
, buffer
, size
))
3859 assemble_string ((char *) buffer
, size
);
3862 error ("unknown set constructor type");
3870 assemble_zeros (size
);
3874 /* Subroutine of output_constant, used for CONSTRUCTORs
3875 (aggregate constants).
3876 Generate at least SIZE bytes, padding if necessary. */
3879 output_constructor (exp
, size
)
3883 register tree link
, field
= 0;
3884 HOST_WIDE_INT min_index
= 0;
3885 /* Number of bytes output or skipped so far.
3886 In other words, current position within the constructor. */
3887 int total_bytes
= 0;
3888 /* Non-zero means BYTE contains part of a byte, to be output. */
3889 int byte_buffer_in_use
= 0;
3892 if (HOST_BITS_PER_WIDE_INT
< BITS_PER_UNIT
)
3895 if (TREE_CODE (TREE_TYPE (exp
)) == RECORD_TYPE
)
3896 field
= TYPE_FIELDS (TREE_TYPE (exp
));
3898 if (TREE_CODE (TREE_TYPE (exp
)) == ARRAY_TYPE
3899 && TYPE_DOMAIN (TREE_TYPE (exp
)) != 0)
3901 = TREE_INT_CST_LOW (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (exp
))));
3903 /* As LINK goes through the elements of the constant,
3904 FIELD goes through the structure fields, if the constant is a structure.
3905 if the constant is a union, then we override this,
3906 by getting the field from the TREE_LIST element.
3907 But the constant could also be an array. Then FIELD is zero. */
3908 for (link
= CONSTRUCTOR_ELTS (exp
);
3910 link
= TREE_CHAIN (link
),
3911 field
= field
? TREE_CHAIN (field
) : 0)
3913 tree val
= TREE_VALUE (link
);
3916 /* the element in a union constructor specifies the proper field. */
3918 if (TREE_CODE (TREE_TYPE (exp
)) == RECORD_TYPE
3919 || TREE_CODE (TREE_TYPE (exp
)) == UNION_TYPE
)
3921 /* if available, use the type given by link */
3922 if (TREE_PURPOSE (link
) != 0)
3923 field
= TREE_PURPOSE (link
);
3926 if (TREE_CODE (TREE_TYPE (exp
)) == ARRAY_TYPE
)
3927 index
= TREE_PURPOSE (link
);
3929 /* Eliminate the marker that makes a cast not be an lvalue. */
3933 if (index
&& TREE_CODE (index
) == RANGE_EXPR
)
3935 register int fieldsize
3936 = int_size_in_bytes (TREE_TYPE (TREE_TYPE (exp
)));
3937 HOST_WIDE_INT lo_index
= TREE_INT_CST_LOW (TREE_OPERAND (index
, 0));
3938 HOST_WIDE_INT hi_index
= TREE_INT_CST_LOW (TREE_OPERAND (index
, 1));
3939 HOST_WIDE_INT index
;
3940 for (index
= lo_index
; index
<= hi_index
; index
++)
3942 /* Output the element's initial value. */
3944 assemble_zeros (fieldsize
);
3946 output_constant (val
, fieldsize
);
3948 /* Count its size. */
3949 total_bytes
+= fieldsize
;
3952 else if (field
== 0 || !DECL_BIT_FIELD (field
))
3954 /* An element that is not a bit-field. */
3956 register int fieldsize
;
3957 /* Since this structure is static,
3958 we know the positions are constant. */
3959 int bitpos
= (field
? (TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field
))
3963 bitpos
= (TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (val
)))
3965 * (TREE_INT_CST_LOW (index
) - min_index
));
3967 /* Output any buffered-up bit-fields preceding this element. */
3968 if (byte_buffer_in_use
)
3970 ASM_OUTPUT_BYTE (asm_out_file
, byte
);
3972 byte_buffer_in_use
= 0;
3975 /* Advance to offset of this element.
3976 Note no alignment needed in an array, since that is guaranteed
3977 if each element has the proper size. */
3978 if ((field
!= 0 || index
!= 0) && bitpos
!= total_bytes
)
3980 assemble_zeros (bitpos
- total_bytes
);
3981 total_bytes
= bitpos
;
3984 /* Determine size this element should occupy. */
3987 if (TREE_CODE (DECL_SIZE (field
)) != INTEGER_CST
)
3989 if (TREE_INT_CST_LOW (DECL_SIZE (field
)) > 100000)
3991 /* This avoids overflow trouble. */
3992 tree size_tree
= size_binop (CEIL_DIV_EXPR
,
3994 size_int (BITS_PER_UNIT
));
3995 fieldsize
= TREE_INT_CST_LOW (size_tree
);
3999 fieldsize
= TREE_INT_CST_LOW (DECL_SIZE (field
));
4000 fieldsize
= (fieldsize
+ BITS_PER_UNIT
- 1) / BITS_PER_UNIT
;
4004 fieldsize
= int_size_in_bytes (TREE_TYPE (TREE_TYPE (exp
)));
4006 /* Output the element's initial value. */
4008 assemble_zeros (fieldsize
);
4010 output_constant (val
, fieldsize
);
4012 /* Count its size. */
4013 total_bytes
+= fieldsize
;
4015 else if (val
!= 0 && TREE_CODE (val
) != INTEGER_CST
)
4016 error ("invalid initial value for member `%s'",
4017 IDENTIFIER_POINTER (DECL_NAME (field
)));
4020 /* Element that is a bit-field. */
4022 int next_offset
= TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field
));
4024 = (next_offset
+ TREE_INT_CST_LOW (DECL_SIZE (field
)));
4027 val
= integer_zero_node
;
4029 /* If this field does not start in this (or, next) byte,
4031 if (next_offset
/ BITS_PER_UNIT
!= total_bytes
)
4033 /* Output remnant of any bit field in previous bytes. */
4034 if (byte_buffer_in_use
)
4036 ASM_OUTPUT_BYTE (asm_out_file
, byte
);
4038 byte_buffer_in_use
= 0;
4041 /* If still not at proper byte, advance to there. */
4042 if (next_offset
/ BITS_PER_UNIT
!= total_bytes
)
4044 assemble_zeros (next_offset
/ BITS_PER_UNIT
- total_bytes
);
4045 total_bytes
= next_offset
/ BITS_PER_UNIT
;
4049 if (! byte_buffer_in_use
)
4052 /* We must split the element into pieces that fall within
4053 separate bytes, and combine each byte with previous or
4054 following bit-fields. */
4056 /* next_offset is the offset n fbits from the beginning of
4057 the structure to the next bit of this element to be processed.
4058 end_offset is the offset of the first bit past the end of
4060 while (next_offset
< end_offset
)
4064 HOST_WIDE_INT value
;
4065 int next_byte
= next_offset
/ BITS_PER_UNIT
;
4066 int next_bit
= next_offset
% BITS_PER_UNIT
;
4068 /* Advance from byte to byte
4069 within this element when necessary. */
4070 while (next_byte
!= total_bytes
)
4072 ASM_OUTPUT_BYTE (asm_out_file
, byte
);
4077 /* Number of bits we can process at once
4078 (all part of the same byte). */
4079 this_time
= MIN (end_offset
- next_offset
,
4080 BITS_PER_UNIT
- next_bit
);
4081 if (BYTES_BIG_ENDIAN
)
4083 /* On big-endian machine, take the most significant bits
4084 first (of the bits that are significant)
4085 and put them into bytes from the most significant end. */
4086 shift
= end_offset
- next_offset
- this_time
;
4087 /* Don't try to take a bunch of bits that cross
4088 the word boundary in the INTEGER_CST. */
4089 if (shift
< HOST_BITS_PER_WIDE_INT
4090 && shift
+ this_time
> HOST_BITS_PER_WIDE_INT
)
4092 this_time
-= (HOST_BITS_PER_WIDE_INT
- shift
);
4093 shift
= HOST_BITS_PER_WIDE_INT
;
4096 /* Now get the bits from the appropriate constant word. */
4097 if (shift
< HOST_BITS_PER_WIDE_INT
)
4099 value
= TREE_INT_CST_LOW (val
);
4101 else if (shift
< 2 * HOST_BITS_PER_WIDE_INT
)
4103 value
= TREE_INT_CST_HIGH (val
);
4104 shift
-= HOST_BITS_PER_WIDE_INT
;
4108 byte
|= (((value
>> shift
)
4109 & (((HOST_WIDE_INT
) 1 << this_time
) - 1))
4110 << (BITS_PER_UNIT
- this_time
- next_bit
));
4114 /* On little-endian machines,
4115 take first the least significant bits of the value
4116 and pack them starting at the least significant
4117 bits of the bytes. */
4118 shift
= (next_offset
4119 - TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field
)));
4120 /* Don't try to take a bunch of bits that cross
4121 the word boundary in the INTEGER_CST. */
4122 if (shift
< HOST_BITS_PER_WIDE_INT
4123 && shift
+ this_time
> HOST_BITS_PER_WIDE_INT
)
4125 this_time
-= (HOST_BITS_PER_WIDE_INT
- shift
);
4126 shift
= HOST_BITS_PER_WIDE_INT
;
4129 /* Now get the bits from the appropriate constant word. */
4130 if (shift
< HOST_BITS_PER_WIDE_INT
)
4131 value
= TREE_INT_CST_LOW (val
);
4132 else if (shift
< 2 * HOST_BITS_PER_WIDE_INT
)
4134 value
= TREE_INT_CST_HIGH (val
);
4135 shift
-= HOST_BITS_PER_WIDE_INT
;
4139 byte
|= (((value
>> shift
)
4140 & (((HOST_WIDE_INT
) 1 << this_time
) - 1))
4143 next_offset
+= this_time
;
4144 byte_buffer_in_use
= 1;
4148 if (byte_buffer_in_use
)
4150 ASM_OUTPUT_BYTE (asm_out_file
, byte
);
4153 if (total_bytes
< size
)
4154 assemble_zeros (size
- total_bytes
);
4157 /* Output asm to handle ``#pragma weak'' */
4160 handle_pragma_weak (what
, name
, value
)
4161 enum pragma_state what
;
4164 #ifdef HANDLE_PRAGMA_WEAK
4165 if (what
== ps_name
|| what
== ps_value
)
4167 struct weak_syms
*weak
=
4168 (struct weak_syms
*)permalloc (sizeof (struct weak_syms
));
4169 weak
->next
= weak_decls
;
4170 weak
->name
= permalloc (strlen (name
) + 1);
4171 strcpy (weak
->name
, name
);
4173 if (what
!= ps_value
)
4174 weak
->value
= NULL_PTR
;
4178 weak
->value
= permalloc (strlen (value
) + 1);
4179 strcpy (weak
->value
, value
);
4184 else if (! (what
== ps_done
|| what
== ps_start
))
4185 warning ("malformed `#pragma weak'");
4186 #endif /* HANDLE_PRAGMA_WEAK */
4189 /* Declare DECL to be a weak symbol. */
4195 if (! TREE_PUBLIC (decl
))
4196 error_with_decl (decl
, "weak declaration of `%s' must be public");
4197 else if (TREE_ASM_WRITTEN (decl
))
4198 error_with_decl (decl
, "weak declaration of `%s' must precede definition");
4199 else if (SUPPORTS_WEAK
)
4200 DECL_WEAK (decl
) = 1;
4203 /* Emit any pending weak declarations. */
4208 #ifdef HANDLE_PRAGMA_WEAK
4209 if (HANDLE_PRAGMA_WEAK
)
4211 struct weak_syms
*t
;
4212 for (t
= weak_decls
; t
; t
= t
->next
)
4214 ASM_WEAKEN_LABEL (asm_out_file
, t
->name
);
4216 ASM_OUTPUT_DEF (asm_out_file
, t
->name
, t
->value
);
4223 assemble_alias (decl
, target
)
4228 make_decl_rtl (decl
, (char *) 0, 1);
4229 name
= XSTR (XEXP (DECL_RTL (decl
), 0), 0);
4231 #ifdef ASM_OUTPUT_DEF
4232 /* Make name accessible from other files, if appropriate. */
4234 if (TREE_PUBLIC (decl
))
4236 #ifdef ASM_WEAKEN_LABEL
4237 if (DECL_WEAK (decl
))
4238 ASM_WEAKEN_LABEL (asm_out_file
, name
);
4241 ASM_GLOBALIZE_LABEL (asm_out_file
, name
);
4244 ASM_OUTPUT_DEF (asm_out_file
, name
, IDENTIFIER_POINTER (target
));
4245 TREE_ASM_WRITTEN (decl
) = 1;
4247 #ifdef ASM_OUTPUT_WEAK_ALIAS
4248 if (! DECL_WEAK (decl
))
4249 warning ("only weak aliases are supported in this configuration");
4251 ASM_OUTPUT_WEAK_ALIAS (asm_out_file
, name
, IDENTIFIER_POINTER (target
));
4252 TREE_ASM_WRITTEN (decl
) = 1;
4254 warning ("alias definitions not supported in this configuration; ignored");
4259 /* This determines whether or not we support link-once semantics. */
4260 #ifndef SUPPORTS_ONE_ONLY
4261 #ifdef MAKE_DECL_ONE_ONLY
4262 #define SUPPORTS_ONE_ONLY 1
4264 #define SUPPORTS_ONE_ONLY 0
4268 /* Returns 1 if the target configuration supports defining public symbols
4269 so that one of them will be chosen at link time instead of generating a
4270 multiply-defined symbol error, whether through the use of weak symbols or
4271 a target-specific mechanism for having duplicates discarded. */
4274 supports_one_only ()
4276 if (SUPPORTS_ONE_ONLY
)
4278 return SUPPORTS_WEAK
;
4281 /* Set up DECL as a public symbol that can be defined in multiple
4282 translation units without generating a linker error. */
4285 make_decl_one_only (decl
)
4288 if (TREE_CODE (decl
) != VAR_DECL
&& TREE_CODE (decl
) != FUNCTION_DECL
)
4291 TREE_PUBLIC (decl
) = 1;
4293 if (TREE_CODE (decl
) == VAR_DECL
4294 && (DECL_INITIAL (decl
) == 0 || DECL_INITIAL (decl
) == error_mark_node
))
4295 DECL_COMMON (decl
) = 1;
4296 else if (SUPPORTS_ONE_ONLY
)
4298 #ifdef MAKE_DECL_ONE_ONLY
4299 MAKE_DECL_ONE_ONLY (decl
);
4301 DECL_ONE_ONLY (decl
) = 1;
4303 else if (SUPPORTS_WEAK
)
4304 DECL_WEAK (decl
) = 1;