1 /* Output variables, constants and external declarations, for GNU compiler.
2 Copyright (C) 1987, 88, 89, 92-6, 1997 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. */
31 /* #include <stab.h> */
40 #include "hard-reg-set.h"
49 #ifdef XCOFF_DEBUGGING_INFO
55 #ifndef TRAMPOLINE_ALIGNMENT
56 #define TRAMPOLINE_ALIGNMENT FUNCTION_BOUNDARY
60 #define ASM_STABS_OP ".stabs"
63 /* Define the prefix to use when check_memory_usage_flag is enable. */
64 #ifdef NO_DOLLAR_IN_LABEL
65 #ifdef NO_DOT_IN_LABEL
66 #define CHKR_PREFIX "chkr_prefix_"
67 #else /* !NO_DOT_IN_LABEL */
68 #define CHKR_PREFIX "chkr."
70 #else /* !NO_DOLLAR_IN_LABLE */
71 #define CHKR_PREFIX "chkr$"
73 #define CHKR_PREFIX_SIZE (sizeof (CHKR_PREFIX) - 1)
75 /* This macro gets just the user-specified name
76 out of the string in a SYMBOL_REF. On most machines,
77 we discard the * if any and that's all. */
78 #ifndef STRIP_NAME_ENCODING
79 #define STRIP_NAME_ENCODING(VAR,SYMBOL_NAME) \
80 (VAR) = ((SYMBOL_NAME) + ((SYMBOL_NAME)[0] == '*'))
83 /* File in which assembler code is being written. */
85 extern FILE *asm_out_file;
87 /* The (assembler) name of the first globally-visible object output. */
88 char *first_global_object_name;
90 extern struct obstack *current_obstack;
91 extern struct obstack *saveable_obstack;
92 extern struct obstack *rtl_obstack;
93 extern struct obstack permanent_obstack;
94 #define obstack_chunk_alloc xmalloc
96 /* Number for making the label on the next
97 constant that is stored in memory. */
101 /* Number for making the label on the next
102 static variable internal to a function. */
106 /* Carry information from ASM_DECLARE_OBJECT_NAME
107 to ASM_FINISH_DECLARE_OBJECT. */
109 int size_directive_output;
111 /* The last decl for which assemble_variable was called,
112 if it did ASM_DECLARE_OBJECT_NAME.
113 If the last call to assemble_variable didn't do that,
116 tree last_assemble_variable_decl;
119 #ifdef HANDLE_PRAGMA_WEAK
120 /* Any weak symbol declarations waiting to be emitted. */
124 struct weak_syms *next;
129 static struct weak_syms *weak_decls;
132 /* Nonzero if at least one function definition has been seen. */
134 static int function_defined;
137 struct constant_descriptor;
139 struct pool_constant;
141 static void bc_make_decl_rtl PROTO((tree, char *, int));
142 static char *strip_reg_name PROTO((char *));
143 static void bc_output_ascii PROTO((FILE *, char *, int));
144 static int contains_pointers_p PROTO((tree));
145 static void decode_addr_const PROTO((tree, struct addr_const *));
146 static int const_hash PROTO((tree));
147 static int compare_constant PROTO((tree,
148 struct constant_descriptor *));
149 static char *compare_constant_1 PROTO((tree, char *));
150 static struct constant_descriptor *record_constant PROTO((tree));
151 static void record_constant_1 PROTO((tree));
152 static tree copy_constant PROTO((tree));
153 static void output_constant_def_contents PROTO((tree, int, int));
154 static void decode_rtx_const PROTO((enum machine_mode, rtx,
155 struct rtx_const *));
156 static int const_hash_rtx PROTO((enum machine_mode, rtx));
157 static int compare_constant_rtx PROTO((enum machine_mode, rtx,
158 struct constant_descriptor *));
159 static struct constant_descriptor *record_constant_rtx PROTO((enum machine_mode,
161 static struct pool_constant *find_pool_constant PROTO((rtx));
162 static void mark_constant_pool PROTO((void));
163 static void mark_constants PROTO((rtx));
164 static int output_addressed_constants PROTO((tree));
165 static void output_after_function_constants PROTO((void));
166 static void bc_assemble_integer PROTO((tree, int));
167 static void output_constructor PROTO((tree, int));
169 static enum in_section { no_section, in_text, in_data, in_named
170 #ifdef BSS_SECTION_ASM_OP
173 #ifdef EH_FRAME_SECTION_ASM_OP
176 #ifdef EXTRA_SECTIONS
179 } in_section = no_section;
181 /* Return a non-zero value if DECL has a section attribute. */
182 #define IN_NAMED_SECTION(DECL) \
183 ((TREE_CODE (DECL) == FUNCTION_DECL || TREE_CODE (DECL) == VAR_DECL) \
184 && DECL_SECTION_NAME (DECL) != NULL_TREE)
186 /* Text of section name when in_section == in_named. */
187 static char *in_named_name;
189 /* Define functions like text_section for any extra sections. */
190 #ifdef EXTRA_SECTION_FUNCTIONS
191 EXTRA_SECTION_FUNCTIONS
194 /* Tell assembler to switch to text section. */
199 if (in_section != in_text)
204 fprintf (asm_out_file, "%s\n", TEXT_SECTION_ASM_OP);
206 in_section = in_text;
210 /* Tell assembler to switch to data section. */
215 if (in_section != in_data)
221 if (flag_shared_data)
223 #ifdef SHARED_SECTION_ASM_OP
224 fprintf (asm_out_file, "%s\n", SHARED_SECTION_ASM_OP);
226 fprintf (asm_out_file, "%s\n", DATA_SECTION_ASM_OP);
230 fprintf (asm_out_file, "%s\n", DATA_SECTION_ASM_OP);
233 in_section = in_data;
237 /* Tell assembler to switch to read-only data section. This is normally
241 readonly_data_section ()
243 #ifdef READONLY_DATA_SECTION
244 READONLY_DATA_SECTION (); /* Note this can call data_section. */
250 /* Determine if we're in the text section. */
255 return in_section == in_text;
258 /* Determine if we're in the data section. */
263 return in_section == in_data;
266 /* Tell assembler to change to section NAME for DECL.
267 If DECL is NULL, just switch to section NAME.
268 If NAME is NULL, get the name from DECL.
269 If RELOC is 1, the initializer for DECL contains relocs. */
272 named_section (decl, name, reloc)
277 if (decl != NULL_TREE
278 && TREE_CODE_CLASS (TREE_CODE (decl)) != 'd')
281 name = TREE_STRING_POINTER (DECL_SECTION_NAME (decl));
283 if (in_section != in_named || strcmp (name, in_named_name))
285 in_named_name = obstack_alloc (&permanent_obstack, strlen (name) + 1);
286 strcpy (in_named_name, name);
287 in_section = in_named;
289 #ifdef ASM_OUTPUT_SECTION_NAME
290 ASM_OUTPUT_SECTION_NAME (asm_out_file, decl, name, reloc);
292 /* Section attributes are not supported if this macro isn't provided -
293 some host formats don't support them at all. The front-end should
294 already have flagged this as an error. */
300 #ifdef ASM_OUTPUT_SECTION_NAME
301 #ifndef UNIQUE_SECTION
302 #define UNIQUE_SECTION(DECL,RELOC) \
305 char *name, *string; \
307 name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL)); \
308 /* Strip off any encoding in name. */ \
309 STRIP_NAME_ENCODING (name, name); \
311 len = strlen (name) + 1; \
312 string = alloca (len + 1); \
313 sprintf (string, ".%s", name); \
315 DECL_SECTION_NAME (DECL) = build_string (len, string); \
318 #ifndef UNIQUE_SECTION_P
319 #define UNIQUE_SECTION_P(DECL) 0
323 #ifdef BSS_SECTION_ASM_OP
325 /* Tell the assembler to switch to the bss section. */
330 if (in_section != in_bss)
336 #ifdef SHARED_BSS_SECTION_ASM_OP
337 if (flag_shared_data)
338 fprintf (asm_out_file, "%s\n", SHARED_BSS_SECTION_ASM_OP);
341 fprintf (asm_out_file, "%s\n", BSS_SECTION_ASM_OP);
348 #ifdef ASM_OUTPUT_BSS
350 /* Utility function for ASM_OUTPUT_BSS for targets to use if
351 they don't support alignments in .bss.
352 ??? It is believed that this function will work in most cases so such
353 support is localized here. */
356 asm_output_bss (file, decl, name, size, rounded)
362 ASM_GLOBALIZE_LABEL (file, name);
364 #ifdef ASM_DECLARE_OBJECT_NAME
365 last_assemble_variable_decl = decl;
366 ASM_DECLARE_OBJECT_NAME (file, name, decl);
368 /* Standard thing is just output label for the object. */
369 ASM_OUTPUT_LABEL (file, name);
370 #endif /* ASM_DECLARE_OBJECT_NAME */
371 ASM_OUTPUT_SKIP (file, rounded);
376 #ifdef ASM_OUTPUT_ALIGNED_BSS
378 /* Utility function for targets to use in implementing
379 ASM_OUTPUT_ALIGNED_BSS.
380 ??? It is believed that this function will work in most cases so such
381 support is localized here. */
384 asm_output_aligned_bss (file, decl, name, size, align)
390 ASM_GLOBALIZE_LABEL (file, name);
392 ASM_OUTPUT_ALIGN (file, floor_log2 (align / BITS_PER_UNIT));
393 #ifdef ASM_DECLARE_OBJECT_NAME
394 last_assemble_variable_decl = decl;
395 ASM_DECLARE_OBJECT_NAME (file, name, decl);
397 /* Standard thing is just output label for the object. */
398 ASM_OUTPUT_LABEL (file, name);
399 #endif /* ASM_DECLARE_OBJECT_NAME */
400 ASM_OUTPUT_SKIP (file, size ? size : 1);
405 #endif /* BSS_SECTION_ASM_OP */
407 #ifdef EH_FRAME_SECTION_ASM_OP
411 if (in_section != in_eh_frame)
413 fprintf (asm_out_file, "%s\n", EH_FRAME_SECTION_ASM_OP);
414 in_section = in_eh_frame;
419 /* Switch to the section for function DECL.
421 If DECL is NULL_TREE, switch to the text section.
422 ??? It's not clear that we will ever be passed NULL_TREE, but it's
423 safer to handle it. */
426 function_section (decl)
429 if (decl != NULL_TREE
430 && DECL_SECTION_NAME (decl) != NULL_TREE)
431 named_section (decl, (char *) 0, 0);
436 /* Switch to section for variable DECL.
438 RELOC is the `reloc' argument to SELECT_SECTION. */
441 variable_section (decl, reloc)
445 if (IN_NAMED_SECTION (decl))
446 named_section (decl, NULL, reloc);
449 /* C++ can have const variables that get initialized from constructors,
450 and thus can not be in a readonly section. We prevent this by
451 verifying that the initial value is constant for objects put in a
454 error_mark_node is used by the C front end to indicate that the
455 initializer has not been seen yet. In this case, we assume that
456 the initializer must be constant.
458 C++ uses error_mark_node for variables that have complicated
459 initializers, but these variables go in BSS so we won't be called
462 #ifdef SELECT_SECTION
463 SELECT_SECTION (decl, reloc);
465 if (DECL_READONLY_SECTION (decl, reloc))
466 readonly_data_section ();
473 /* Tell assembler to switch to the section for the exception handling
479 #if defined (EXCEPTION_SECTION)
480 EXCEPTION_SECTION ();
482 #ifdef ASM_OUTPUT_SECTION_NAME
483 named_section (NULL_TREE, ".gcc_except_table", 0);
488 readonly_data_section ();
493 /* Create the rtl to represent a function, for a function definition.
494 DECL is a FUNCTION_DECL node which describes which function.
495 The rtl is stored into DECL. */
498 make_function_rtl (decl)
501 char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
502 char *new_name = name;
506 if (DECL_RTL (decl) == 0)
507 DECL_RTL (decl) = bc_gen_rtx (name, 0, (struct bc_label *) 0);
509 /* Record that at least one function has been defined. */
510 function_defined = 1;
514 /* Rename a nested function to avoid conflicts. */
515 if (decl_function_context (decl) != 0
516 && DECL_INITIAL (decl) != 0
517 && DECL_RTL (decl) == 0)
521 name = IDENTIFIER_POINTER (DECL_NAME (decl));
522 ASM_FORMAT_PRIVATE_NAME (label, name, var_labelno);
523 name = obstack_copy0 (saveable_obstack, label, strlen (label));
528 /* When -fprefix-function-name is used, every function name is
529 prefixed. Even static functions are prefixed because they
530 could be declared latter. Note that a nested function name
532 if (flag_prefix_function_name)
534 new_name = (char *) alloca (strlen (name) + CHKR_PREFIX_SIZE + 1);
535 strcpy (new_name, CHKR_PREFIX);
536 strcpy (new_name + CHKR_PREFIX_SIZE, name);
537 name = obstack_copy0 (saveable_obstack, new_name, strlen (new_name));
541 if (DECL_RTL (decl) == 0)
544 = gen_rtx (MEM, DECL_MODE (decl),
545 gen_rtx (SYMBOL_REF, Pmode, name));
547 /* Optionally set flags or add text to the name to record information
548 such as that it is a function name. If the name is changed, the macro
549 ASM_OUTPUT_LABELREF will have to know how to strip this information. */
550 #ifdef ENCODE_SECTION_INFO
551 ENCODE_SECTION_INFO (decl);
555 /* Record at least one function has been defined. */
556 function_defined = 1;
559 /* Create the DECL_RTL for a declaration for a static or external
560 variable or static or external function.
561 ASMSPEC, if not 0, is the string which the user specified
562 as the assembler symbol name.
563 TOP_LEVEL is nonzero if this is a file-scope variable.
564 This is never called for PARM_DECLs. */
567 bc_make_decl_rtl (decl, asmspec, top_level)
572 register char *name = TREE_STRING_POINTER (DECL_ASSEMBLER_NAME (decl));
574 if (DECL_RTL (decl) == 0)
576 /* Print an error message for register variables. */
577 if (DECL_REGISTER (decl))
578 error ("global register variables not supported in the interpreter");
580 /* Handle ordinary static variables and functions. */
581 if (DECL_RTL (decl) == 0)
583 /* Can't use just the variable's own name for a variable
584 whose scope is less than the whole file.
585 Concatenate a distinguishing number. */
586 if (!top_level && !TREE_PUBLIC (decl) && asmspec == 0)
590 ASM_FORMAT_PRIVATE_NAME (label, name, var_labelno);
591 name = obstack_copy0 (saveable_obstack, label, strlen (label));
595 DECL_RTL (decl) = bc_gen_rtx (name, 0, (struct bc_label *) 0);
600 /* Given NAME, a putative register name, discard any customary prefixes. */
603 strip_reg_name (name)
606 #ifdef REGISTER_PREFIX
607 if (!strncmp (name, REGISTER_PREFIX, strlen (REGISTER_PREFIX)))
608 name += strlen (REGISTER_PREFIX);
610 if (name[0] == '%' || name[0] == '#')
615 /* Decode an `asm' spec for a declaration as a register name.
616 Return the register number, or -1 if nothing specified,
617 or -2 if the ASMSPEC is not `cc' or `memory' and is not recognized,
618 or -3 if ASMSPEC is `cc' and is not recognized,
619 or -4 if ASMSPEC is `memory' and is not recognized.
620 Accept an exact spelling or a decimal number.
621 Prefixes such as % are optional. */
624 decode_reg_name (asmspec)
631 /* Get rid of confusing prefixes. */
632 asmspec = strip_reg_name (asmspec);
634 /* Allow a decimal number as a "register name". */
635 for (i = strlen (asmspec) - 1; i >= 0; i--)
636 if (! (asmspec[i] >= '0' && asmspec[i] <= '9'))
638 if (asmspec[0] != 0 && i < 0)
641 if (i < FIRST_PSEUDO_REGISTER && i >= 0)
647 for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
649 && ! strcmp (asmspec, strip_reg_name (reg_names[i])))
652 #ifdef ADDITIONAL_REGISTER_NAMES
654 static struct { char *name; int number; } table[]
655 = ADDITIONAL_REGISTER_NAMES;
657 for (i = 0; i < sizeof (table) / sizeof (table[0]); i++)
658 if (! strcmp (asmspec, table[i].name))
659 return table[i].number;
661 #endif /* ADDITIONAL_REGISTER_NAMES */
663 if (!strcmp (asmspec, "memory"))
666 if (!strcmp (asmspec, "cc"))
675 /* Create the DECL_RTL for a declaration for a static or external variable
676 or static or external function.
677 ASMSPEC, if not 0, is the string which the user specified
678 as the assembler symbol name.
679 TOP_LEVEL is nonzero if this is a file-scope variable.
681 This is never called for PARM_DECL nodes. */
684 make_decl_rtl (decl, asmspec, top_level)
689 register char *name = 0;
694 bc_make_decl_rtl (decl, asmspec, top_level);
698 reg_number = decode_reg_name (asmspec);
700 if (DECL_ASSEMBLER_NAME (decl) != NULL_TREE)
701 name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
703 if (reg_number == -2)
705 /* ASMSPEC is given, and not the name of a register. */
706 name = (char *) obstack_alloc (saveable_obstack,
707 strlen (asmspec) + 2);
709 strcpy (&name[1], asmspec);
712 /* For a duplicate declaration, we can be called twice on the
713 same DECL node. Don't discard the RTL already made. */
714 if (DECL_RTL (decl) == 0)
718 /* First detect errors in declaring global registers. */
719 if (TREE_CODE (decl) != FUNCTION_DECL
720 && DECL_REGISTER (decl) && reg_number == -1)
721 error_with_decl (decl,
722 "register name not specified for `%s'");
723 else if (TREE_CODE (decl) != FUNCTION_DECL
724 && DECL_REGISTER (decl) && reg_number < 0)
725 error_with_decl (decl,
726 "invalid register name for `%s'");
727 else if ((reg_number >= 0 || reg_number == -3)
728 && (TREE_CODE (decl) == FUNCTION_DECL
729 && ! DECL_REGISTER (decl)))
730 error_with_decl (decl,
731 "register name given for non-register variable `%s'");
732 else if (TREE_CODE (decl) != FUNCTION_DECL
733 && DECL_REGISTER (decl)
734 && TYPE_MODE (TREE_TYPE (decl)) == BLKmode)
735 error_with_decl (decl,
736 "data type of `%s' isn't suitable for a register");
737 else if (TREE_CODE (decl) != FUNCTION_DECL && DECL_REGISTER (decl)
738 && ! HARD_REGNO_MODE_OK (reg_number,
739 TYPE_MODE (TREE_TYPE (decl))))
740 error_with_decl (decl,
741 "register number for `%s' isn't suitable for data type");
742 /* Now handle properly declared static register variables. */
743 else if (TREE_CODE (decl) != FUNCTION_DECL && DECL_REGISTER (decl))
747 if (DECL_INITIAL (decl) != 0 && top_level)
749 DECL_INITIAL (decl) = 0;
750 error ("global register variable has initial value");
752 if (fixed_regs[reg_number] == 0
753 && function_defined && top_level)
754 error ("global register variable follows a function definition");
755 if (TREE_THIS_VOLATILE (decl))
756 warning ("volatile register variables don't work as you might wish");
758 /* If the user specified one of the eliminables registers here,
759 e.g., FRAME_POINTER_REGNUM, we don't want to get this variable
760 confused with that register and be eliminated. Although this
761 usage is somewhat suspect, we nevertheless use the following
762 kludge to avoid setting DECL_RTL to frame_pointer_rtx. */
765 = gen_rtx (REG, DECL_MODE (decl), FIRST_PSEUDO_REGISTER);
766 REGNO (DECL_RTL (decl)) = reg_number;
767 REG_USERVAR_P (DECL_RTL (decl)) = 1;
771 /* Make this register global, so not usable for anything
773 nregs = HARD_REGNO_NREGS (reg_number, DECL_MODE (decl));
775 globalize_reg (reg_number + --nregs);
778 /* Specifying a section attribute on a variable forces it into a
779 non-.bss section, and thus it cannot be common. */
780 else if (TREE_CODE (decl) == VAR_DECL
781 && DECL_SECTION_NAME (decl) != NULL_TREE
782 && DECL_INITIAL (decl) == NULL_TREE
783 && DECL_COMMON (decl))
784 DECL_COMMON (decl) = 0;
786 /* Now handle ordinary static variables and functions (in memory).
787 Also handle vars declared register invalidly. */
788 if (DECL_RTL (decl) == 0)
790 /* Can't use just the variable's own name for a variable
791 whose scope is less than the whole file.
792 Concatenate a distinguishing number. */
793 if (!top_level && !TREE_PUBLIC (decl) && asmspec == 0)
797 ASM_FORMAT_PRIVATE_NAME (label, name, var_labelno);
798 name = obstack_copy0 (saveable_obstack, label, strlen (label));
805 /* When -fprefix-function-name is used, the functions
806 names are prefixed. Only nested function names are not
808 if (flag_prefix_function_name && TREE_CODE (decl) == FUNCTION_DECL)
811 new_name = (char *) alloca (strlen (name) + CHKR_PREFIX_SIZE
813 strcpy (new_name, CHKR_PREFIX);
814 strcpy (new_name + CHKR_PREFIX_SIZE, name);
815 name = obstack_copy0 (saveable_obstack,
816 new_name, strlen (new_name));
819 DECL_RTL (decl) = gen_rtx (MEM, DECL_MODE (decl),
820 gen_rtx (SYMBOL_REF, Pmode, name));
822 /* If this variable is to be treated as volatile, show its
823 tree node has side effects. If it has side effects, either
824 because of this test or from TREE_THIS_VOLATILE also
825 being set, show the MEM is volatile. */
826 if (flag_volatile_global && TREE_CODE (decl) == VAR_DECL
827 && TREE_PUBLIC (decl))
828 TREE_SIDE_EFFECTS (decl) = 1;
829 if (TREE_SIDE_EFFECTS (decl))
830 MEM_VOLATILE_P (DECL_RTL (decl)) = 1;
832 if (TREE_READONLY (decl))
833 RTX_UNCHANGING_P (DECL_RTL (decl)) = 1;
834 MEM_IN_STRUCT_P (DECL_RTL (decl))
835 = AGGREGATE_TYPE_P (TREE_TYPE (decl));
837 /* Optionally set flags or add text to the name to record information
838 such as that it is a function name.
839 If the name is changed, the macro ASM_OUTPUT_LABELREF
840 will have to know how to strip this information. */
841 #ifdef ENCODE_SECTION_INFO
842 ENCODE_SECTION_INFO (decl);
846 /* If the old RTL had the wrong mode, fix the mode. */
847 else if (GET_MODE (DECL_RTL (decl)) != DECL_MODE (decl))
849 rtx rtl = DECL_RTL (decl);
850 PUT_MODE (rtl, DECL_MODE (decl));
854 /* Make the rtl for variable VAR be volatile.
855 Use this only for static variables. */
858 make_var_volatile (var)
861 if (GET_CODE (DECL_RTL (var)) != MEM)
864 MEM_VOLATILE_P (DECL_RTL (var)) = 1;
867 /* Output alignment directive to align for constant expression EXP. */
870 assemble_constant_align (exp)
875 /* Align the location counter as required by EXP's data type. */
876 align = TYPE_ALIGN (TREE_TYPE (exp));
877 #ifdef CONSTANT_ALIGNMENT
878 align = CONSTANT_ALIGNMENT (exp, align);
881 if (align > BITS_PER_UNIT)
882 ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT));
885 /* Output a string of literal assembler code
886 for an `asm' keyword used between functions. */
889 assemble_asm (string)
894 error ("asm statements not allowed in interpreter");
900 if (TREE_CODE (string) == ADDR_EXPR)
901 string = TREE_OPERAND (string, 0);
903 fprintf (asm_out_file, "\t%s\n", TREE_STRING_POINTER (string));
906 #if 0 /* This should no longer be needed, because
907 flag_gnu_linker should be 0 on these systems,
908 which should prevent any output
909 if ASM_OUTPUT_CONSTRUCTOR and ASM_OUTPUT_DESTRUCTOR are absent. */
910 #if !(defined(DBX_DEBUGGING_INFO) && !defined(FASCIST_ASSEMBLER))
911 #ifndef ASM_OUTPUT_CONSTRUCTOR
912 #define ASM_OUTPUT_CONSTRUCTOR(file, name)
914 #ifndef ASM_OUTPUT_DESTRUCTOR
915 #define ASM_OUTPUT_DESTRUCTOR(file, name)
920 /* Record an element in the table of global destructors.
921 How this is done depends on what sort of assembler and linker
924 NAME should be the name of a global function to be called
925 at exit time. This name is output using assemble_name. */
928 assemble_destructor (name)
931 #ifdef ASM_OUTPUT_DESTRUCTOR
932 ASM_OUTPUT_DESTRUCTOR (asm_out_file, name);
936 /* Now tell GNU LD that this is part of the static destructor set. */
937 /* This code works for any machine provided you use GNU as/ld. */
938 fprintf (asm_out_file, "%s \"___DTOR_LIST__\",22,0,0,", ASM_STABS_OP);
939 assemble_name (asm_out_file, name);
940 fputc ('\n', asm_out_file);
945 /* Likewise for global constructors. */
948 assemble_constructor (name)
951 #ifdef ASM_OUTPUT_CONSTRUCTOR
952 ASM_OUTPUT_CONSTRUCTOR (asm_out_file, name);
956 /* Now tell GNU LD that this is part of the static constructor set. */
957 /* This code works for any machine provided you use GNU as/ld. */
958 fprintf (asm_out_file, "%s \"___CTOR_LIST__\",22,0,0,", ASM_STABS_OP);
959 assemble_name (asm_out_file, name);
960 fputc ('\n', asm_out_file);
965 /* Likewise for entries we want to record for garbage collection.
966 Garbage collection is still under development. */
969 assemble_gc_entry (name)
972 #ifdef ASM_OUTPUT_GC_ENTRY
973 ASM_OUTPUT_GC_ENTRY (asm_out_file, name);
977 /* Now tell GNU LD that this is part of the static constructor set. */
978 fprintf (asm_out_file, "%s \"___PTR_LIST__\",22,0,0,", ASM_STABS_OP);
979 assemble_name (asm_out_file, name);
980 fputc ('\n', asm_out_file);
985 /* CONSTANT_POOL_BEFORE_FUNCTION may be defined as an expression with
986 a non-zero value if the constant pool should be output before the
987 start of the function, or a zero value if the pool should output
988 after the end of the function. The default is to put it before the
991 #ifndef CONSTANT_POOL_BEFORE_FUNCTION
992 #define CONSTANT_POOL_BEFORE_FUNCTION 1
995 /* Output assembler code for the constant pool of a function and associated
996 with defining the name of the function. DECL describes the function.
997 NAME is the function's name. For the constant pool, we use the current
998 constant pool data. */
1001 assemble_start_function (decl, fnname)
1007 /* The following code does not need preprocessing in the assembler. */
1011 if (CONSTANT_POOL_BEFORE_FUNCTION)
1012 output_constant_pool (fnname, decl);
1014 #ifdef ASM_OUTPUT_SECTION_NAME
1015 /* If the function is to be put in its own section and it's not in a section
1016 already, indicate so. */
1017 if ((flag_function_sections
1018 && DECL_SECTION_NAME (decl) == NULL_TREE)
1019 || UNIQUE_SECTION_P (decl))
1020 UNIQUE_SECTION (decl, 0);
1023 function_section (decl);
1025 /* Tell assembler to move to target machine's alignment for functions. */
1026 align = floor_log2 (FUNCTION_BOUNDARY / BITS_PER_UNIT);
1029 if (output_bytecode)
1030 BC_OUTPUT_ALIGN (asm_out_file, align);
1032 ASM_OUTPUT_ALIGN (asm_out_file, align);
1035 #ifdef ASM_OUTPUT_FUNCTION_PREFIX
1036 ASM_OUTPUT_FUNCTION_PREFIX (asm_out_file, fnname);
1039 #ifdef SDB_DEBUGGING_INFO
1040 /* Output SDB definition of the function. */
1041 if (write_symbols == SDB_DEBUG)
1042 sdbout_mark_begin_function ();
1045 #ifdef DBX_DEBUGGING_INFO
1046 /* Output DBX definition of the function. */
1047 if (write_symbols == DBX_DEBUG)
1048 dbxout_begin_function (decl);
1051 /* Make function name accessible from other files, if appropriate. */
1053 if (TREE_PUBLIC (decl))
1055 if (!first_global_object_name && ! DECL_WEAK (decl)
1056 && ! DECL_ONE_ONLY (decl))
1060 STRIP_NAME_ENCODING (p, fnname);
1061 first_global_object_name = permalloc (strlen (p) + 1);
1062 strcpy (first_global_object_name, p);
1065 #ifdef ASM_WEAKEN_LABEL
1066 if (DECL_WEAK (decl))
1067 ASM_WEAKEN_LABEL (asm_out_file, fnname);
1070 if (output_bytecode)
1071 BC_GLOBALIZE_LABEL (asm_out_file, fnname);
1073 ASM_GLOBALIZE_LABEL (asm_out_file, fnname);
1076 /* Do any machine/system dependent processing of the function name */
1077 if (output_bytecode)
1078 BC_OUTPUT_LABEL (asm_out_file, fnname);
1081 #ifdef ASM_DECLARE_FUNCTION_NAME
1082 ASM_DECLARE_FUNCTION_NAME (asm_out_file, fnname, current_function_decl);
1084 /* Standard thing is just output label for the function. */
1085 ASM_OUTPUT_LABEL (asm_out_file, fnname);
1086 #endif /* ASM_DECLARE_FUNCTION_NAME */
1090 /* Output assembler code associated with defining the size of the
1091 function. DECL describes the function. NAME is the function's name. */
1094 assemble_end_function (decl, fnname)
1098 #ifdef ASM_DECLARE_FUNCTION_SIZE
1099 ASM_DECLARE_FUNCTION_SIZE (asm_out_file, fnname, decl);
1101 if (! CONSTANT_POOL_BEFORE_FUNCTION)
1103 output_constant_pool (fnname, decl);
1104 function_section (decl); /* need to switch back */
1107 /* Output any constants which should appear after the function. */
1108 output_after_function_constants ();
1111 /* Assemble code to leave SIZE bytes of zeros. */
1114 assemble_zeros (size)
1117 if (output_bytecode)
1119 bc_emit_const_skip (size);
1123 #ifdef ASM_NO_SKIP_IN_TEXT
1124 /* The `space' pseudo in the text section outputs nop insns rather than 0s,
1125 so we must output 0s explicitly in the text section. */
1126 if (ASM_NO_SKIP_IN_TEXT && in_text_section ())
1130 for (i = 0; i < size - 20; i += 20)
1133 fprintf (asm_out_file,
1134 "%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);
1136 fprintf (asm_out_file,
1137 "\tbyte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n");
1143 fprintf (asm_out_file, "%s 0", ASM_BYTE_OP);
1145 fprintf (asm_out_file, "\tbyte 0");
1148 for (; i < size; i++)
1149 fprintf (asm_out_file, ",0");
1150 fprintf (asm_out_file, "\n");
1157 if (output_bytecode)
1158 BC_OUTPUT_SKIP (asm_out_file, size);
1160 ASM_OUTPUT_SKIP (asm_out_file, size);
1164 /* Assemble an alignment pseudo op for an ALIGN-bit boundary. */
1167 assemble_align (align)
1170 if (align > BITS_PER_UNIT)
1171 ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT));
1174 /* Assemble a string constant with the specified C string as contents. */
1177 assemble_string (p, size)
1185 if (output_bytecode)
1191 /* If the string is very long, split it up. */
1195 int thissize = size - pos;
1196 if (thissize > maximum)
1199 if (output_bytecode)
1200 bc_output_ascii (asm_out_file, p, thissize);
1203 ASM_OUTPUT_ASCII (asm_out_file, p, thissize);
1212 bc_output_ascii (file, p, size)
1217 BC_OUTPUT_ASCII (file, p, size);
1220 /* Assemble everything that is needed for a variable or function declaration.
1221 Not used for automatic variables, and not used for function definitions.
1222 Should not be called for variables of incomplete structure type.
1224 TOP_LEVEL is nonzero if this variable has file scope.
1225 AT_END is nonzero if this is the special handling, at end of compilation,
1226 to define things that have had only tentative definitions.
1227 DONT_OUTPUT_DATA if nonzero means don't actually output the
1228 initial value (that will be done by the caller). */
1231 assemble_variable (decl, top_level, at_end, dont_output_data)
1235 int dont_output_data;
1237 register char *name;
1241 enum in_section saved_in_section;
1243 last_assemble_variable_decl = 0;
1245 if (output_bytecode)
1248 if (GET_CODE (DECL_RTL (decl)) == REG)
1250 /* Do output symbol info for global register variables, but do nothing
1253 if (TREE_ASM_WRITTEN (decl))
1255 TREE_ASM_WRITTEN (decl) = 1;
1257 if (!output_bytecode)
1259 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
1260 /* File-scope global variables are output here. */
1261 if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
1263 dbxout_symbol (decl, 0);
1265 #ifdef SDB_DEBUGGING_INFO
1266 if (write_symbols == SDB_DEBUG && top_level
1267 /* Leave initialized global vars for end of compilation;
1268 see comment in compile_file. */
1269 && (TREE_PUBLIC (decl) == 0 || DECL_INITIAL (decl) == 0))
1270 sdbout_symbol (decl, 0);
1274 /* Don't output any DWARF debugging information for variables here.
1275 In the case of local variables, the information for them is output
1276 when we do our recursive traversal of the tree representation for
1277 the entire containing function. In the case of file-scope variables,
1278 we output information for all of them at the very end of compilation
1279 while we are doing our final traversal of the chain of file-scope
1285 /* Normally no need to say anything here for external references,
1286 since assemble_external is called by the language-specific code
1287 when a declaration is first seen. */
1289 if (DECL_EXTERNAL (decl))
1292 /* Output no assembler code for a function declaration.
1293 Only definitions of functions output anything. */
1295 if (TREE_CODE (decl) == FUNCTION_DECL)
1298 /* If type was incomplete when the variable was declared,
1299 see if it is complete now. */
1301 if (DECL_SIZE (decl) == 0)
1302 layout_decl (decl, 0);
1304 /* Still incomplete => don't allocate it; treat the tentative defn
1305 (which is what it must have been) as an `extern' reference. */
1307 if (!dont_output_data && DECL_SIZE (decl) == 0)
1309 error_with_file_and_line (DECL_SOURCE_FILE (decl),
1310 DECL_SOURCE_LINE (decl),
1311 "storage size of `%s' isn't known",
1312 IDENTIFIER_POINTER (DECL_NAME (decl)));
1313 TREE_ASM_WRITTEN (decl) = 1;
1317 /* The first declaration of a variable that comes through this function
1318 decides whether it is global (in C, has external linkage)
1319 or local (in C, has internal linkage). So do nothing more
1320 if this function has already run. */
1322 if (TREE_ASM_WRITTEN (decl))
1325 TREE_ASM_WRITTEN (decl) = 1;
1329 if (! dont_output_data)
1333 if (TREE_CODE (DECL_SIZE (decl)) != INTEGER_CST)
1336 /* This is better than explicit arithmetic, since it avoids overflow. */
1337 size_tree = size_binop (CEIL_DIV_EXPR,
1338 DECL_SIZE (decl), size_int (BITS_PER_UNIT));
1340 size = TREE_INT_CST_LOW (size_tree);
1341 if (TREE_INT_CST_HIGH (size_tree) != 0
1342 || size != TREE_INT_CST_LOW (size_tree))
1344 error_with_decl (decl, "size of variable `%s' is too large");
1349 name = XSTR (XEXP (DECL_RTL (decl), 0), 0);
1351 if (TREE_PUBLIC (decl) && DECL_NAME (decl)
1352 && ! first_global_object_name
1353 && ! (DECL_COMMON (decl) && (DECL_INITIAL (decl) == 0
1354 || DECL_INITIAL (decl) == error_mark_node))
1355 && ! DECL_WEAK (decl)
1356 && ! DECL_ONE_ONLY (decl))
1360 STRIP_NAME_ENCODING (p, name);
1361 first_global_object_name = permalloc (strlen (p) + 1);
1362 strcpy (first_global_object_name, p);
1365 /* Handle uninitialized definitions. */
1367 if ((DECL_INITIAL (decl) == 0 || DECL_INITIAL (decl) == error_mark_node)
1368 /* If the target can't output uninitialized but not common global data
1369 in .bss, then we have to use .data. */
1370 #if ! defined (ASM_OUTPUT_BSS) && ! defined (ASM_OUTPUT_ALIGNED_BSS)
1371 && DECL_COMMON (decl)
1373 && ! dont_output_data)
1375 int size = TREE_INT_CST_LOW (size_tree);
1378 /* Don't allocate zero bytes of common,
1379 since that means "undefined external" in the linker. */
1380 if (size == 0) rounded = 1;
1381 /* Round size up to multiple of BIGGEST_ALIGNMENT bits
1382 so that each uninitialized object starts on such a boundary. */
1383 rounded += (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - 1;
1384 rounded = (rounded / (BIGGEST_ALIGNMENT / BITS_PER_UNIT)
1385 * (BIGGEST_ALIGNMENT / BITS_PER_UNIT));
1387 #ifdef DBX_DEBUGGING_INFO
1388 /* File-scope global variables are output here. */
1389 if (write_symbols == DBX_DEBUG && top_level)
1390 dbxout_symbol (decl, 0);
1392 #ifdef SDB_DEBUGGING_INFO
1393 if (write_symbols == SDB_DEBUG && top_level
1394 /* Leave initialized global vars for end of compilation;
1395 see comment in compile_file. */
1396 && (TREE_PUBLIC (decl) == 0 || DECL_INITIAL (decl) == 0))
1397 sdbout_symbol (decl, 0);
1400 /* Don't output any DWARF debugging information for variables here.
1401 In the case of local variables, the information for them is output
1402 when we do our recursive traversal of the tree representation for
1403 the entire containing function. In the case of file-scope variables,
1404 we output information for all of them at the very end of compilation
1405 while we are doing our final traversal of the chain of file-scope
1408 #if 0 /* ??? We should either delete this or add a comment describing what
1409 it was intended to do and why we shouldn't delete it. */
1410 if (flag_shared_data)
1414 if (TREE_PUBLIC (decl)
1415 #if defined (ASM_OUTPUT_BSS) || defined (ASM_OUTPUT_ALIGNED_BSS)
1416 && DECL_COMMON (decl)
1420 #ifdef ASM_OUTPUT_SHARED_COMMON
1421 if (flag_shared_data)
1422 ASM_OUTPUT_SHARED_COMMON (asm_out_file, name, size, rounded);
1425 if (output_bytecode)
1427 BC_OUTPUT_COMMON (asm_out_file, name, size, rounded);
1431 #ifdef ASM_OUTPUT_ALIGNED_COMMON
1432 ASM_OUTPUT_ALIGNED_COMMON (asm_out_file, name, size,
1435 ASM_OUTPUT_COMMON (asm_out_file, name, size, rounded);
1439 #if defined (ASM_OUTPUT_BSS) || defined (ASM_OUTPUT_ALIGNED_BSS)
1440 else if (TREE_PUBLIC (decl))
1442 #ifdef ASM_OUTPUT_SHARED_BSS
1443 if (flag_shared_data)
1444 ASM_OUTPUT_SHARED_BSS (asm_out_file, decl, name, size, rounded);
1447 if (output_bytecode)
1449 BC_OUTPUT_BSS (asm_out_file, name, size, rounded);
1453 #ifdef ASM_OUTPUT_ALIGNED_BSS
1454 ASM_OUTPUT_ALIGNED_BSS (asm_out_file, decl, name, size,
1457 ASM_OUTPUT_BSS (asm_out_file, decl, name, size, rounded);
1461 #endif /* ASM_OUTPUT_BSS || ASM_OUTPUT_ALIGNED_BSS */
1464 #ifdef ASM_OUTPUT_SHARED_LOCAL
1465 if (flag_shared_data)
1466 ASM_OUTPUT_SHARED_LOCAL (asm_out_file, name, size, rounded);
1469 if (output_bytecode)
1471 BC_OUTPUT_LOCAL (asm_out_file, name, size, rounded);
1475 #ifdef ASM_OUTPUT_ALIGNED_LOCAL
1476 ASM_OUTPUT_ALIGNED_LOCAL (asm_out_file, name, size,
1479 ASM_OUTPUT_LOCAL (asm_out_file, name, size, rounded);
1486 /* Handle initialized definitions.
1487 Also handle uninitialized global definitions if -fno-common and the
1488 target doesn't support ASM_OUTPUT_BSS. */
1490 /* First make the assembler name(s) global if appropriate. */
1491 if (TREE_PUBLIC (decl) && DECL_NAME (decl))
1493 #ifdef ASM_WEAKEN_LABEL
1494 if (DECL_WEAK (decl))
1495 ASM_WEAKEN_LABEL (asm_out_file, name);
1498 ASM_GLOBALIZE_LABEL (asm_out_file, name);
1501 for (d = equivalents; d; d = TREE_CHAIN (d))
1503 tree e = TREE_VALUE (d);
1504 if (TREE_PUBLIC (e) && DECL_NAME (e))
1505 ASM_GLOBALIZE_LABEL (asm_out_file,
1506 XSTR (XEXP (DECL_RTL (e), 0), 0));
1510 /* Output any data that we will need to use the address of. */
1511 if (DECL_INITIAL (decl) == error_mark_node)
1512 reloc = contains_pointers_p (TREE_TYPE (decl));
1513 else if (DECL_INITIAL (decl))
1514 reloc = output_addressed_constants (DECL_INITIAL (decl));
1516 #ifdef ASM_OUTPUT_SECTION_NAME
1517 if (UNIQUE_SECTION_P (decl))
1518 UNIQUE_SECTION (decl, reloc);
1521 /* Switch to the appropriate section. */
1522 variable_section (decl, reloc);
1524 /* dbxout.c needs to know this. */
1525 if (in_text_section ())
1526 DECL_IN_TEXT_SECTION (decl) = 1;
1528 /* Record current section so we can restore it if dbxout.c clobbers it. */
1529 saved_in_section = in_section;
1531 /* Output the dbx info now that we have chosen the section. */
1533 #ifdef DBX_DEBUGGING_INFO
1534 /* File-scope global variables are output here. */
1535 if (write_symbols == DBX_DEBUG && top_level)
1536 dbxout_symbol (decl, 0);
1538 #ifdef SDB_DEBUGGING_INFO
1539 if (write_symbols == SDB_DEBUG && top_level
1540 /* Leave initialized global vars for end of compilation;
1541 see comment in compile_file. */
1542 && (TREE_PUBLIC (decl) == 0 || DECL_INITIAL (decl) == 0))
1543 sdbout_symbol (decl, 0);
1546 /* Don't output any DWARF debugging information for variables here.
1547 In the case of local variables, the information for them is output
1548 when we do our recursive traversal of the tree representation for
1549 the entire containing function. In the case of file-scope variables,
1550 we output information for all of them at the very end of compilation
1551 while we are doing our final traversal of the chain of file-scope
1554 /* If the debugging output changed sections, reselect the section
1555 that's supposed to be selected. */
1556 if (in_section != saved_in_section)
1557 variable_section (decl, reloc);
1559 /* Compute and output the alignment of this data. */
1561 align = DECL_ALIGN (decl);
1562 /* In the case for initialing an array whose length isn't specified,
1563 where we have not yet been able to do the layout,
1564 figure out the proper alignment now. */
1565 if (dont_output_data && DECL_SIZE (decl) == 0
1566 && TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE)
1567 align = MAX (align, TYPE_ALIGN (TREE_TYPE (TREE_TYPE (decl))));
1569 /* Some object file formats have a maximum alignment which they support.
1570 In particular, a.out format supports a maximum alignment of 4. */
1571 #ifndef MAX_OFILE_ALIGNMENT
1572 #define MAX_OFILE_ALIGNMENT BIGGEST_ALIGNMENT
1574 if (align > MAX_OFILE_ALIGNMENT)
1576 warning_with_decl (decl,
1577 "alignment of `%s' is greater than maximum object file alignment");
1578 align = MAX_OFILE_ALIGNMENT;
1580 #ifdef DATA_ALIGNMENT
1581 /* On some machines, it is good to increase alignment sometimes. */
1582 align = DATA_ALIGNMENT (TREE_TYPE (decl), align);
1584 #ifdef CONSTANT_ALIGNMENT
1585 if (DECL_INITIAL (decl))
1586 align = CONSTANT_ALIGNMENT (DECL_INITIAL (decl), align);
1589 /* Reset the alignment in case we have made it tighter, so we can benefit
1590 from it in get_pointer_alignment. */
1591 DECL_ALIGN (decl) = align;
1593 if (align > BITS_PER_UNIT)
1595 if (output_bytecode)
1596 BC_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT));
1598 ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT));
1601 /* Do any machine/system dependent processing of the object. */
1602 if (output_bytecode)
1603 BC_OUTPUT_LABEL (asm_out_file, name);
1606 #ifdef ASM_DECLARE_OBJECT_NAME
1607 last_assemble_variable_decl = decl;
1608 ASM_DECLARE_OBJECT_NAME (asm_out_file, name, decl);
1610 /* Standard thing is just output label for the object. */
1611 ASM_OUTPUT_LABEL (asm_out_file, name);
1612 #endif /* ASM_DECLARE_OBJECT_NAME */
1615 if (!dont_output_data)
1617 if (DECL_INITIAL (decl))
1618 /* Output the actual data. */
1619 output_constant (DECL_INITIAL (decl), TREE_INT_CST_LOW (size_tree));
1621 /* Leave space for it. */
1622 assemble_zeros (TREE_INT_CST_LOW (size_tree));
1626 #ifdef XCOFF_DEBUGGING_INFO
1627 /* Unfortunately, the IBM assembler cannot handle stabx before the actual
1628 declaration. When something like ".stabx "aa:S-2",aa,133,0" is emitted
1629 and `aa' hasn't been output yet, the assembler generates a stab entry with
1630 a value of zero, in addition to creating an unnecessary external entry
1631 for `aa'. Hence, we must postpone dbxout_symbol to here at the end. */
1633 /* File-scope global variables are output here. */
1634 if (write_symbols == XCOFF_DEBUG && top_level)
1636 saved_in_section = in_section;
1638 dbxout_symbol (decl, 0);
1640 if (in_section != saved_in_section)
1641 variable_section (decl, reloc);
1644 /* There must be a statement after a label. */
1649 /* Return 1 if type TYPE contains any pointers. */
1652 contains_pointers_p (type)
1655 switch (TREE_CODE (type))
1658 case REFERENCE_TYPE:
1659 /* I'm not sure whether OFFSET_TYPE needs this treatment,
1660 so I'll play safe and return 1. */
1666 case QUAL_UNION_TYPE:
1669 /* For a type that has fields, see if the fields have pointers. */
1670 for (fields = TYPE_FIELDS (type); fields; fields = TREE_CHAIN (fields))
1671 if (TREE_CODE (fields) == FIELD_DECL
1672 && contains_pointers_p (TREE_TYPE (fields)))
1678 /* An array type contains pointers if its element type does. */
1679 return contains_pointers_p (TREE_TYPE (type));
1686 /* Output text storage for constructor CONSTR. */
1689 bc_output_constructor (constr, size)
1695 /* Must always be a literal; non-literal constructors are handled
1698 if (!TREE_CONSTANT (constr))
1705 for (i = 0; TYPE_ALIGN (constr) >= BITS_PER_UNIT << (i + 1); i++)
1709 BC_OUTPUT_ALIGN (asm_out_file, i);
1712 output_constant (constr, size);
1715 /* Create storage for constructor CONSTR. */
1718 bc_output_data_constructor (constr)
1723 /* Put in data section */
1727 for (i = 0; TYPE_ALIGN (constr) >= BITS_PER_UNIT << (i + 1); i++);
1729 BC_OUTPUT_ALIGN (asm_out_file, i);
1731 /* The constructor is filled in at runtime. */
1732 BC_OUTPUT_SKIP (asm_out_file, int_size_in_bytes (TREE_TYPE (constr)));
1735 /* Output something to declare an external symbol to the assembler.
1736 (Most assemblers don't need this, so we normally output nothing.)
1737 Do nothing if DECL is not external. */
1740 assemble_external (decl)
1743 if (output_bytecode)
1746 #ifdef ASM_OUTPUT_EXTERNAL
1747 if (TREE_CODE_CLASS (TREE_CODE (decl)) == 'd'
1748 && DECL_EXTERNAL (decl) && TREE_PUBLIC (decl))
1750 rtx rtl = DECL_RTL (decl);
1752 if (GET_CODE (rtl) == MEM && GET_CODE (XEXP (rtl, 0)) == SYMBOL_REF
1753 && ! SYMBOL_REF_USED (XEXP (rtl, 0)))
1755 /* Some systems do require some output. */
1756 SYMBOL_REF_USED (XEXP (rtl, 0)) = 1;
1757 ASM_OUTPUT_EXTERNAL (asm_out_file, decl, XSTR (XEXP (rtl, 0), 0));
1763 /* Similar, for calling a library function FUN. */
1766 assemble_external_libcall (fun)
1769 #ifdef ASM_OUTPUT_EXTERNAL_LIBCALL
1770 if (!output_bytecode)
1772 /* Declare library function name external when first used, if nec. */
1773 if (! SYMBOL_REF_USED (fun))
1775 SYMBOL_REF_USED (fun) = 1;
1776 ASM_OUTPUT_EXTERNAL_LIBCALL (asm_out_file, fun);
1782 /* Declare the label NAME global. */
1785 assemble_global (name)
1788 ASM_GLOBALIZE_LABEL (asm_out_file, name);
1791 /* Assemble a label named NAME. */
1794 assemble_label (name)
1797 if (output_bytecode)
1798 BC_OUTPUT_LABEL (asm_out_file, name);
1800 ASM_OUTPUT_LABEL (asm_out_file, name);
1803 /* Output to FILE a reference to the assembler name of a C-level name NAME.
1804 If NAME starts with a *, the rest of NAME is output verbatim.
1805 Otherwise NAME is transformed in an implementation-defined way
1806 (usually by the addition of an underscore).
1807 Many macros in the tm file are defined to call this function. */
1810 assemble_name (file, name)
1817 STRIP_NAME_ENCODING (real_name, name);
1818 if (flag_prefix_function_name
1819 && ! bcmp (real_name, CHKR_PREFIX, CHKR_PREFIX_SIZE))
1820 real_name = real_name + CHKR_PREFIX_SIZE;
1822 id = maybe_get_identifier (real_name);
1824 TREE_SYMBOL_REFERENCED (id) = 1;
1828 if (output_bytecode)
1829 bc_emit_labelref (name, 0);
1831 fputs (&name[1], file);
1835 if (output_bytecode)
1836 BC_OUTPUT_LABELREF (file, name);
1838 ASM_OUTPUT_LABELREF (file, name);
1842 /* Allocate SIZE bytes writable static space with a gensym name
1843 and return an RTX to refer to its address. */
1846 assemble_static_space (size)
1852 /* Round size up to multiple of BIGGEST_ALIGNMENT bits
1853 so that each uninitialized object starts on such a boundary. */
1854 int rounded = ((size + (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - 1)
1855 / (BIGGEST_ALIGNMENT / BITS_PER_UNIT)
1856 * (BIGGEST_ALIGNMENT / BITS_PER_UNIT));
1859 if (flag_shared_data)
1863 ASM_GENERATE_INTERNAL_LABEL (name, "LF", const_labelno);
1866 namestring = (char *) obstack_alloc (saveable_obstack,
1868 strcpy (namestring, name);
1870 if (output_bytecode)
1871 x = bc_gen_rtx (namestring, 0, (struct bc_label *) 0);
1873 x = gen_rtx (SYMBOL_REF, Pmode, namestring);
1875 if (output_bytecode)
1877 BC_OUTPUT_LOCAL (asm_out_file, name, size, rounded);
1881 #ifdef ASM_OUTPUT_ALIGNED_LOCAL
1882 ASM_OUTPUT_ALIGNED_LOCAL (asm_out_file, name, size, BIGGEST_ALIGNMENT);
1884 ASM_OUTPUT_LOCAL (asm_out_file, name, size, rounded);
1890 /* Assemble the static constant template for function entry trampolines.
1891 This is done at most once per compilation.
1892 Returns an RTX for the address of the template. */
1894 #ifdef TRAMPOLINE_TEMPLATE
1896 assemble_trampoline_template ()
1902 /* Shouldn't get here */
1903 if (output_bytecode)
1906 /* By default, put trampoline templates in read-only data section. */
1908 #ifdef TRAMPOLINE_SECTION
1909 TRAMPOLINE_SECTION ();
1911 readonly_data_section ();
1914 /* Write the assembler code to define one. */
1915 align = floor_log2 (TRAMPOLINE_ALIGNMENT / BITS_PER_UNIT);
1917 ASM_OUTPUT_ALIGN (asm_out_file, align);
1919 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LTRAMP", 0);
1920 TRAMPOLINE_TEMPLATE (asm_out_file);
1922 /* Record the rtl to refer to it. */
1923 ASM_GENERATE_INTERNAL_LABEL (label, "LTRAMP", 0);
1925 = (char *) obstack_copy0 (&permanent_obstack, label, strlen (label));
1926 return gen_rtx (SYMBOL_REF, Pmode, name);
1930 /* Assemble the integer constant X into an object of SIZE bytes.
1931 X must be either a CONST_INT or CONST_DOUBLE.
1933 Return 1 if we were able to output the constant, otherwise 0. If FORCE is
1934 non-zero, abort if we can't output the constant. */
1937 assemble_integer (x, size, force)
1942 /* First try to use the standard 1, 2, 4, 8, and 16 byte
1943 ASM_OUTPUT... macros. */
1947 #ifdef ASM_OUTPUT_CHAR
1949 ASM_OUTPUT_CHAR (asm_out_file, x);
1953 #ifdef ASM_OUTPUT_SHORT
1955 ASM_OUTPUT_SHORT (asm_out_file, x);
1959 #ifdef ASM_OUTPUT_INT
1961 ASM_OUTPUT_INT (asm_out_file, x);
1965 #ifdef ASM_OUTPUT_DOUBLE_INT
1967 ASM_OUTPUT_DOUBLE_INT (asm_out_file, x);
1971 #ifdef ASM_OUTPUT_QUADRUPLE_INT
1973 ASM_OUTPUT_QUADRUPLE_INT (asm_out_file, x);
1978 /* If we couldn't do it that way, there are two other possibilities: First,
1979 if the machine can output an explicit byte and this is a 1 byte constant,
1980 we can use ASM_OUTPUT_BYTE. */
1982 #ifdef ASM_OUTPUT_BYTE
1983 if (size == 1 && GET_CODE (x) == CONST_INT)
1985 ASM_OUTPUT_BYTE (asm_out_file, INTVAL (x));
1990 /* Finally, if SIZE is larger than a single word, try to output the constant
1991 one word at a time. */
1993 if (size > UNITS_PER_WORD)
1996 enum machine_mode mode
1997 = mode_for_size (size * BITS_PER_UNIT, MODE_INT, 0);
2000 for (i = 0; i < size / UNITS_PER_WORD; i++)
2002 word = operand_subword (x, i, 0, mode);
2007 if (! assemble_integer (word, UNITS_PER_WORD, 0))
2011 if (i == size / UNITS_PER_WORD)
2013 /* If we output at least one word and then could not finish,
2014 there is no valid way to continue. */
2025 /* Assemble the floating-point constant D into an object of size MODE. */
2028 assemble_real (d, mode)
2030 enum machine_mode mode;
2032 jmp_buf output_constant_handler;
2034 if (setjmp (output_constant_handler))
2036 error ("floating point trap outputting a constant");
2037 #ifdef REAL_IS_NOT_DOUBLE
2038 bzero ((char *) &d, sizeof d);
2045 set_float_handler (output_constant_handler);
2049 #ifdef ASM_OUTPUT_BYTE_FLOAT
2051 ASM_OUTPUT_BYTE_FLOAT (asm_out_file, d);
2054 #ifdef ASM_OUTPUT_SHORT_FLOAT
2056 ASM_OUTPUT_SHORT_FLOAT (asm_out_file, d);
2059 #ifdef ASM_OUTPUT_THREE_QUARTER_FLOAT
2061 ASM_OUTPUT_THREE_QUARTER_FLOAT (asm_out_file, d);
2064 #ifdef ASM_OUTPUT_FLOAT
2066 ASM_OUTPUT_FLOAT (asm_out_file, d);
2070 #ifdef ASM_OUTPUT_DOUBLE
2072 ASM_OUTPUT_DOUBLE (asm_out_file, d);
2076 #ifdef ASM_OUTPUT_LONG_DOUBLE
2079 ASM_OUTPUT_LONG_DOUBLE (asm_out_file, d);
2087 set_float_handler (NULL_PTR);
2090 /* Here we combine duplicate floating constants to make
2091 CONST_DOUBLE rtx's, and force those out to memory when necessary. */
2093 /* Chain of all CONST_DOUBLE rtx's constructed for the current function.
2094 They are chained through the CONST_DOUBLE_CHAIN.
2095 A CONST_DOUBLE rtx has CONST_DOUBLE_MEM != cc0_rtx iff it is on this chain.
2096 In that case, CONST_DOUBLE_MEM is either a MEM,
2097 or const0_rtx if no MEM has been made for this CONST_DOUBLE yet.
2099 (CONST_DOUBLE_MEM is used only for top-level functions.
2100 See force_const_mem for explanation.) */
2102 static rtx const_double_chain;
2104 /* Return a CONST_DOUBLE or CONST_INT for a value specified as a pair of ints.
2105 For an integer, I0 is the low-order word and I1 is the high-order word.
2106 For a real number, I0 is the word with the low address
2107 and I1 is the word with the high address. */
2110 immed_double_const (i0, i1, mode)
2111 HOST_WIDE_INT i0, i1;
2112 enum machine_mode mode;
2115 int in_current_obstack;
2117 if (GET_MODE_CLASS (mode) == MODE_INT
2118 || GET_MODE_CLASS (mode) == MODE_PARTIAL_INT)
2120 /* We clear out all bits that don't belong in MODE, unless they and our
2121 sign bit are all one. So we get either a reasonable negative value
2122 or a reasonable unsigned value for this mode. */
2123 int width = GET_MODE_BITSIZE (mode);
2124 if (width < HOST_BITS_PER_WIDE_INT
2125 && ((i0 & ((HOST_WIDE_INT) (-1) << (width - 1)))
2126 != ((HOST_WIDE_INT) (-1) << (width - 1))))
2127 i0 &= ((HOST_WIDE_INT) 1 << width) - 1, i1 = 0;
2128 else if (width == HOST_BITS_PER_WIDE_INT
2129 && ! (i1 == ~0 && i0 < 0))
2131 else if (width > 2 * HOST_BITS_PER_WIDE_INT)
2132 /* We cannot represent this value as a constant. */
2135 /* If this would be an entire word for the target, but is not for
2136 the host, then sign-extend on the host so that the number will look
2137 the same way on the host that it would on the target.
2139 For example, when building a 64 bit alpha hosted 32 bit sparc
2140 targeted compiler, then we want the 32 bit unsigned value -1 to be
2141 represented as a 64 bit value -1, and not as 0x00000000ffffffff.
2142 The later confuses the sparc backend. */
2144 if (BITS_PER_WORD < HOST_BITS_PER_WIDE_INT && BITS_PER_WORD == width
2145 && (i0 & ((HOST_WIDE_INT) 1 << (width - 1))))
2146 i0 |= ((HOST_WIDE_INT) (-1) << width);
2148 /* If MODE fits within HOST_BITS_PER_WIDE_INT, always use a CONST_INT.
2150 ??? Strictly speaking, this is wrong if we create a CONST_INT
2151 for a large unsigned constant with the size of MODE being
2152 HOST_BITS_PER_WIDE_INT and later try to interpret that constant in a
2153 wider mode. In that case we will mis-interpret it as a negative
2156 Unfortunately, the only alternative is to make a CONST_DOUBLE
2157 for any constant in any mode if it is an unsigned constant larger
2158 than the maximum signed integer in an int on the host. However,
2159 doing this will break everyone that always expects to see a CONST_INT
2160 for SImode and smaller.
2162 We have always been making CONST_INTs in this case, so nothing new
2165 if (width <= HOST_BITS_PER_WIDE_INT)
2166 i1 = (i0 < 0) ? ~0 : 0;
2168 /* If this integer fits in one word, return a CONST_INT. */
2169 if ((i1 == 0 && i0 >= 0)
2170 || (i1 == ~0 && i0 < 0))
2171 return GEN_INT (i0);
2173 /* We use VOIDmode for integers. */
2177 /* Search the chain for an existing CONST_DOUBLE with the right value.
2178 If one is found, return it. */
2180 for (r = const_double_chain; r; r = CONST_DOUBLE_CHAIN (r))
2181 if (CONST_DOUBLE_LOW (r) == i0 && CONST_DOUBLE_HIGH (r) == i1
2182 && GET_MODE (r) == mode)
2185 /* No; make a new one and add it to the chain.
2187 We may be called by an optimizer which may be discarding any memory
2188 allocated during its processing (such as combine and loop). However,
2189 we will be leaving this constant on the chain, so we cannot tolerate
2190 freed memory. So switch to saveable_obstack for this allocation
2191 and then switch back if we were in current_obstack. */
2193 push_obstacks_nochange ();
2194 rtl_in_saveable_obstack ();
2195 r = gen_rtx (CONST_DOUBLE, mode, NULL_RTX, i0, i1);
2198 /* Don't touch const_double_chain in nested function; see force_const_mem.
2199 Also, don't touch it if not inside any function. */
2200 if (outer_function_chain == 0 && current_function_decl != 0)
2202 CONST_DOUBLE_CHAIN (r) = const_double_chain;
2203 const_double_chain = r;
2206 /* Store const0_rtx in mem-slot since this CONST_DOUBLE is on the chain.
2207 Actual use of mem-slot is only through force_const_mem. */
2209 CONST_DOUBLE_MEM (r) = const0_rtx;
2214 /* Return a CONST_DOUBLE for a specified `double' value
2215 and machine mode. */
2218 immed_real_const_1 (d, mode)
2220 enum machine_mode mode;
2222 union real_extract u;
2224 int in_current_obstack;
2226 /* Get the desired `double' value as a sequence of ints
2227 since that is how they are stored in a CONST_DOUBLE. */
2231 /* Detect special cases. */
2233 /* Avoid REAL_VALUES_EQUAL here in order to distinguish minus zero. */
2234 if (!bcmp ((char *) &dconst0, (char *) &d, sizeof d))
2235 return CONST0_RTX (mode);
2236 /* Check for NaN first, because some ports (specifically the i386) do not
2237 emit correct ieee-fp code by default, and thus will generate a core
2238 dump here if we pass a NaN to REAL_VALUES_EQUAL and if REAL_VALUES_EQUAL
2239 does a floating point comparison. */
2240 else if (! REAL_VALUE_ISNAN (d) && REAL_VALUES_EQUAL (dconst1, d))
2241 return CONST1_RTX (mode);
2243 if (sizeof u == 2 * sizeof (HOST_WIDE_INT))
2244 return immed_double_const (u.i[0], u.i[1], mode);
2246 /* The rest of this function handles the case where
2247 a float value requires more than 2 ints of space.
2248 It will be deleted as dead code on machines that don't need it. */
2250 /* Search the chain for an existing CONST_DOUBLE with the right value.
2251 If one is found, return it. */
2253 for (r = const_double_chain; r; r = CONST_DOUBLE_CHAIN (r))
2254 if (! bcmp ((char *) &CONST_DOUBLE_LOW (r), (char *) &u, sizeof u)
2255 && GET_MODE (r) == mode)
2258 /* No; make a new one and add it to the chain.
2260 We may be called by an optimizer which may be discarding any memory
2261 allocated during its processing (such as combine and loop). However,
2262 we will be leaving this constant on the chain, so we cannot tolerate
2263 freed memory. So switch to saveable_obstack for this allocation
2264 and then switch back if we were in current_obstack. */
2266 push_obstacks_nochange ();
2267 rtl_in_saveable_obstack ();
2268 r = rtx_alloc (CONST_DOUBLE);
2270 bcopy ((char *) &u, (char *) &CONST_DOUBLE_LOW (r), sizeof u);
2273 /* Don't touch const_double_chain in nested function; see force_const_mem.
2274 Also, don't touch it if not inside any function. */
2275 if (outer_function_chain == 0 && current_function_decl != 0)
2277 CONST_DOUBLE_CHAIN (r) = const_double_chain;
2278 const_double_chain = r;
2281 /* Store const0_rtx in CONST_DOUBLE_MEM since this CONST_DOUBLE is on the
2282 chain, but has not been allocated memory. Actual use of CONST_DOUBLE_MEM
2283 is only through force_const_mem. */
2285 CONST_DOUBLE_MEM (r) = const0_rtx;
2290 /* Return a CONST_DOUBLE rtx for a value specified by EXP,
2291 which must be a REAL_CST tree node. */
2294 immed_real_const (exp)
2297 return immed_real_const_1 (TREE_REAL_CST (exp), TYPE_MODE (TREE_TYPE (exp)));
2300 /* At the end of a function, forget the memory-constants
2301 previously made for CONST_DOUBLEs. Mark them as not on real_constant_chain.
2302 Also clear out real_constant_chain and clear out all the chain-pointers. */
2305 clear_const_double_mem ()
2307 register rtx r, next;
2309 /* Don't touch CONST_DOUBLE_MEM for nested functions.
2310 See force_const_mem for explanation. */
2311 if (outer_function_chain != 0)
2314 for (r = const_double_chain; r; r = next)
2316 next = CONST_DOUBLE_CHAIN (r);
2317 CONST_DOUBLE_CHAIN (r) = 0;
2318 CONST_DOUBLE_MEM (r) = cc0_rtx;
2320 const_double_chain = 0;
2323 /* Given an expression EXP with a constant value,
2324 reduce it to the sum of an assembler symbol and an integer.
2325 Store them both in the structure *VALUE.
2326 Abort if EXP does not reduce. */
2331 HOST_WIDE_INT offset;
2335 decode_addr_const (exp, value)
2337 struct addr_const *value;
2339 register tree target = TREE_OPERAND (exp, 0);
2340 register int offset = 0;
2345 if (TREE_CODE (target) == COMPONENT_REF
2346 && (TREE_CODE (DECL_FIELD_BITPOS (TREE_OPERAND (target, 1)))
2349 offset += TREE_INT_CST_LOW (DECL_FIELD_BITPOS (TREE_OPERAND (target, 1))) / BITS_PER_UNIT;
2350 target = TREE_OPERAND (target, 0);
2352 else if (TREE_CODE (target) == ARRAY_REF)
2354 if (TREE_CODE (TREE_OPERAND (target, 1)) != INTEGER_CST
2355 || TREE_CODE (TYPE_SIZE (TREE_TYPE (target))) != INTEGER_CST)
2357 offset += ((TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (target)))
2358 * TREE_INT_CST_LOW (TREE_OPERAND (target, 1)))
2360 target = TREE_OPERAND (target, 0);
2366 switch (TREE_CODE (target))
2370 x = DECL_RTL (target);
2374 if (output_bytecode)
2375 /* FIXME: this may not be correct, check it */
2376 x = bc_gen_rtx (TREE_STRING_POINTER (target), 0, (struct bc_label *) 0);
2378 x = gen_rtx (MEM, FUNCTION_MODE,
2379 gen_rtx (LABEL_REF, VOIDmode,
2380 label_rtx (TREE_OPERAND (exp, 0))));
2388 x = TREE_CST_RTL (target);
2395 if (!output_bytecode)
2397 if (GET_CODE (x) != MEM)
2403 value->offset = offset;
2406 /* Uniquize all constants that appear in memory.
2407 Each constant in memory thus far output is recorded
2408 in `const_hash_table' with a `struct constant_descriptor'
2409 that contains a polish representation of the value of
2412 We cannot store the trees in the hash table
2413 because the trees may be temporary. */
2415 struct constant_descriptor
2417 struct constant_descriptor *next;
2423 #define MAX_HASH_TABLE 1009
2424 static struct constant_descriptor *const_hash_table[MAX_HASH_TABLE];
2426 /* Compute a hash code for a constant expression. */
2433 register int len, hi, i;
2434 register enum tree_code code = TREE_CODE (exp);
2436 /* Either set P and LEN to the address and len of something to hash and
2437 exit the switch or return a value. */
2442 p = (char *) &TREE_INT_CST_LOW (exp);
2443 len = 2 * sizeof TREE_INT_CST_LOW (exp);
2447 p = (char *) &TREE_REAL_CST (exp);
2448 len = sizeof TREE_REAL_CST (exp);
2452 p = TREE_STRING_POINTER (exp);
2453 len = TREE_STRING_LENGTH (exp);
2457 return (const_hash (TREE_REALPART (exp)) * 5
2458 + const_hash (TREE_IMAGPART (exp)));
2461 if (TREE_CODE (TREE_TYPE (exp)) == SET_TYPE)
2463 len = int_size_in_bytes (TREE_TYPE (exp));
2464 p = (char *) alloca (len);
2465 get_set_constructor_bytes (exp, (unsigned char *) p, len);
2472 /* For record type, include the type in the hashing.
2473 We do not do so for array types
2474 because (1) the sizes of the elements are sufficient
2475 and (2) distinct array types can have the same constructor.
2476 Instead, we include the array size because the constructor could
2478 if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE)
2479 hi = ((HOST_WIDE_INT) TREE_TYPE (exp) & ((1 << HASHBITS) - 1))
2482 hi = ((5 + int_size_in_bytes (TREE_TYPE (exp)))
2483 & ((1 << HASHBITS) - 1)) % MAX_HASH_TABLE;
2485 for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link))
2486 if (TREE_VALUE (link))
2488 = (hi * 603 + const_hash (TREE_VALUE (link))) % MAX_HASH_TABLE;
2495 struct addr_const value;
2497 decode_addr_const (exp, &value);
2498 if (GET_CODE (value.base) == SYMBOL_REF)
2500 /* Don't hash the address of the SYMBOL_REF;
2501 only use the offset and the symbol name. */
2503 p = XSTR (value.base, 0);
2504 for (i = 0; p[i] != 0; i++)
2505 hi = ((hi * 613) + (unsigned) (p[i]));
2507 else if (GET_CODE (value.base) == LABEL_REF)
2508 hi = value.offset + CODE_LABEL_NUMBER (XEXP (value.base, 0)) * 13;
2510 hi &= (1 << HASHBITS) - 1;
2511 hi %= MAX_HASH_TABLE;
2517 return (const_hash (TREE_OPERAND (exp, 0)) * 9
2518 + const_hash (TREE_OPERAND (exp, 1)));
2522 case NON_LVALUE_EXPR:
2523 return const_hash (TREE_OPERAND (exp, 0)) * 7 + 2;
2526 /* Compute hashing function */
2528 for (i = 0; i < len; i++)
2529 hi = ((hi * 613) + (unsigned) (p[i]));
2531 hi &= (1 << HASHBITS) - 1;
2532 hi %= MAX_HASH_TABLE;
2536 /* Compare a constant expression EXP with a constant-descriptor DESC.
2537 Return 1 if DESC describes a constant with the same value as EXP. */
2540 compare_constant (exp, desc)
2542 struct constant_descriptor *desc;
2544 return 0 != compare_constant_1 (exp, desc->contents);
2547 /* Compare constant expression EXP with a substring P of a constant descriptor.
2548 If they match, return a pointer to the end of the substring matched.
2549 If they do not match, return 0.
2551 Since descriptors are written in polish prefix notation,
2552 this function can be used recursively to test one operand of EXP
2553 against a subdescriptor, and if it succeeds it returns the
2554 address of the subdescriptor for the next operand. */
2557 compare_constant_1 (exp, p)
2561 register char *strp;
2563 register enum tree_code code = TREE_CODE (exp);
2565 if (code != (enum tree_code) *p++)
2568 /* Either set STRP, P and LEN to pointers and length to compare and exit the
2569 switch, or return the result of the comparison. */
2574 /* Integer constants are the same only if the same width of type. */
2575 if (*p++ != TYPE_PRECISION (TREE_TYPE (exp)))
2578 strp = (char *) &TREE_INT_CST_LOW (exp);
2579 len = 2 * sizeof TREE_INT_CST_LOW (exp);
2583 /* Real constants are the same only if the same width of type. */
2584 if (*p++ != TYPE_PRECISION (TREE_TYPE (exp)))
2587 strp = (char *) &TREE_REAL_CST (exp);
2588 len = sizeof TREE_REAL_CST (exp);
2592 if (flag_writable_strings)
2595 if (*p++ != TYPE_MODE (TREE_TYPE (exp)))
2598 strp = TREE_STRING_POINTER (exp);
2599 len = TREE_STRING_LENGTH (exp);
2600 if (bcmp ((char *) &TREE_STRING_LENGTH (exp), p,
2601 sizeof TREE_STRING_LENGTH (exp)))
2604 p += sizeof TREE_STRING_LENGTH (exp);
2608 p = compare_constant_1 (TREE_REALPART (exp), p);
2612 return compare_constant_1 (TREE_IMAGPART (exp), p);
2615 if (TREE_CODE (TREE_TYPE (exp)) == SET_TYPE)
2617 int xlen = len = int_size_in_bytes (TREE_TYPE (exp));
2619 strp = (char *) alloca (len);
2620 get_set_constructor_bytes (exp, (unsigned char *) strp, len);
2621 if (bcmp ((char *) &xlen, p, sizeof xlen))
2630 int length = list_length (CONSTRUCTOR_ELTS (exp));
2633 if (bcmp ((char *) &length, p, sizeof length))
2638 /* For record constructors, insist that the types match.
2639 For arrays, just verify both constructors are for arrays. */
2640 if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE)
2641 type = TREE_TYPE (exp);
2645 if (bcmp ((char *) &type, p, sizeof type))
2650 /* For arrays, insist that the size in bytes match. */
2651 if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE)
2653 int size = int_size_in_bytes (TREE_TYPE (exp));
2654 if (bcmp ((char *) &size, p, sizeof size))
2660 for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link))
2662 if (TREE_VALUE (link))
2664 if ((p = compare_constant_1 (TREE_VALUE (link), p)) == 0)
2671 if (bcmp ((char *) &zero, p, sizeof zero))
2683 struct addr_const value;
2685 decode_addr_const (exp, &value);
2686 strp = (char *) &value.offset;
2687 len = sizeof value.offset;
2688 /* Compare the offset. */
2690 if (*p++ != *strp++)
2693 /* Compare symbol name. */
2694 strp = XSTR (value.base, 0);
2695 len = strlen (strp) + 1;
2701 p = compare_constant_1 (TREE_OPERAND (exp, 0), p);
2705 return compare_constant_1 (TREE_OPERAND (exp, 1), p);
2709 case NON_LVALUE_EXPR:
2710 return compare_constant_1 (TREE_OPERAND (exp, 0), p);
2713 /* Compare constant contents. */
2715 if (*p++ != *strp++)
2721 /* Construct a constant descriptor for the expression EXP.
2722 It is up to the caller to enter the descriptor in the hash table. */
2724 static struct constant_descriptor *
2725 record_constant (exp)
2728 struct constant_descriptor *next = 0;
2731 /* Make a struct constant_descriptor. The first two pointers will
2732 be filled in later. Here we just leave space for them. */
2734 obstack_grow (&permanent_obstack, (char *) &next, sizeof next);
2735 obstack_grow (&permanent_obstack, (char *) &label, sizeof label);
2736 record_constant_1 (exp);
2737 return (struct constant_descriptor *) obstack_finish (&permanent_obstack);
2740 /* Add a description of constant expression EXP
2741 to the object growing in `permanent_obstack'.
2742 No need to return its address; the caller will get that
2743 from the obstack when the object is complete. */
2746 record_constant_1 (exp)
2749 register char *strp;
2751 register enum tree_code code = TREE_CODE (exp);
2753 obstack_1grow (&permanent_obstack, (unsigned int) code);
2758 obstack_1grow (&permanent_obstack, TYPE_PRECISION (TREE_TYPE (exp)));
2759 strp = (char *) &TREE_INT_CST_LOW (exp);
2760 len = 2 * sizeof TREE_INT_CST_LOW (exp);
2764 obstack_1grow (&permanent_obstack, TYPE_PRECISION (TREE_TYPE (exp)));
2765 strp = (char *) &TREE_REAL_CST (exp);
2766 len = sizeof TREE_REAL_CST (exp);
2770 if (flag_writable_strings)
2773 obstack_1grow (&permanent_obstack, TYPE_MODE (TREE_TYPE (exp)));
2774 strp = TREE_STRING_POINTER (exp);
2775 len = TREE_STRING_LENGTH (exp);
2776 obstack_grow (&permanent_obstack, (char *) &TREE_STRING_LENGTH (exp),
2777 sizeof TREE_STRING_LENGTH (exp));
2781 record_constant_1 (TREE_REALPART (exp));
2782 record_constant_1 (TREE_IMAGPART (exp));
2786 if (TREE_CODE (TREE_TYPE (exp)) == SET_TYPE)
2788 int nbytes = int_size_in_bytes (TREE_TYPE (exp));
2789 obstack_grow (&permanent_obstack, &nbytes, sizeof (nbytes));
2790 obstack_blank (&permanent_obstack, nbytes);
2791 get_set_constructor_bytes
2792 (exp, (unsigned char *) permanent_obstack.next_free-nbytes,
2799 int length = list_length (CONSTRUCTOR_ELTS (exp));
2802 obstack_grow (&permanent_obstack, (char *) &length, sizeof length);
2804 /* For record constructors, insist that the types match.
2805 For arrays, just verify both constructors are for arrays. */
2806 if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE)
2807 type = TREE_TYPE (exp);
2810 obstack_grow (&permanent_obstack, (char *) &type, sizeof type);
2812 /* For arrays, insist that the size in bytes match. */
2813 if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE)
2815 int size = int_size_in_bytes (TREE_TYPE (exp));
2816 obstack_grow (&permanent_obstack, (char *) &size, sizeof size);
2819 for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link))
2821 if (TREE_VALUE (link))
2822 record_constant_1 (TREE_VALUE (link));
2827 obstack_grow (&permanent_obstack,
2828 (char *) &zero, sizeof zero);
2836 struct addr_const value;
2838 decode_addr_const (exp, &value);
2839 /* Record the offset. */
2840 obstack_grow (&permanent_obstack,
2841 (char *) &value.offset, sizeof value.offset);
2842 /* Record the symbol name. */
2843 obstack_grow (&permanent_obstack, XSTR (value.base, 0),
2844 strlen (XSTR (value.base, 0)) + 1);
2850 record_constant_1 (TREE_OPERAND (exp, 0));
2851 record_constant_1 (TREE_OPERAND (exp, 1));
2856 case NON_LVALUE_EXPR:
2857 record_constant_1 (TREE_OPERAND (exp, 0));
2864 /* Record constant contents. */
2865 obstack_grow (&permanent_obstack, strp, len);
2868 /* Record a list of constant expressions that were passed to
2869 output_constant_def but that could not be output right away. */
2871 struct deferred_constant
2873 struct deferred_constant *next;
2879 static struct deferred_constant *deferred_constants;
2881 /* Another list of constants which should be output after the
2883 static struct deferred_constant *after_function_constants;
2885 /* Nonzero means defer output of addressed subconstants
2886 (i.e., those for which output_constant_def is called.) */
2887 static int defer_addressed_constants_flag;
2889 /* Start deferring output of subconstants. */
2892 defer_addressed_constants ()
2894 defer_addressed_constants_flag++;
2897 /* Stop deferring output of subconstants,
2898 and output now all those that have been deferred. */
2901 output_deferred_addressed_constants ()
2903 struct deferred_constant *p, *next;
2905 defer_addressed_constants_flag--;
2907 if (defer_addressed_constants_flag > 0)
2910 for (p = deferred_constants; p; p = next)
2912 output_constant_def_contents (p->exp, p->reloc, p->labelno);
2917 deferred_constants = 0;
2920 /* Output any constants which should appear after a function. */
2923 output_after_function_constants ()
2925 struct deferred_constant *p, *next;
2927 for (p = after_function_constants; p; p = next)
2929 output_constant_def_contents (p->exp, p->reloc, p->labelno);
2934 after_function_constants = 0;
2937 /* Make a copy of the whole tree structure for a constant.
2938 This handles the same types of nodes that compare_constant
2939 and record_constant handle. */
2945 switch (TREE_CODE (exp))
2948 /* For ADDR_EXPR, we do not want to copy the decl whose address
2949 is requested. We do want to copy constants though. */
2950 if (TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp, 0))) == 'c')
2951 return build1 (TREE_CODE (exp), TREE_TYPE (exp),
2952 copy_constant (TREE_OPERAND (exp, 0)));
2954 return copy_node (exp);
2959 return copy_node (exp);
2962 return build_complex (TREE_TYPE (exp),
2963 copy_constant (TREE_REALPART (exp)),
2964 copy_constant (TREE_IMAGPART (exp)));
2968 return build (TREE_CODE (exp), TREE_TYPE (exp),
2969 copy_constant (TREE_OPERAND (exp, 0)),
2970 copy_constant (TREE_OPERAND (exp, 1)));
2974 case NON_LVALUE_EXPR:
2975 return build1 (TREE_CODE (exp), TREE_TYPE (exp),
2976 copy_constant (TREE_OPERAND (exp, 0)));
2980 tree copy = copy_node (exp);
2981 tree list = copy_list (CONSTRUCTOR_ELTS (exp));
2984 CONSTRUCTOR_ELTS (copy) = list;
2985 for (tail = list; tail; tail = TREE_CHAIN (tail))
2986 TREE_VALUE (tail) = copy_constant (TREE_VALUE (tail));
2987 if (TREE_CODE (TREE_TYPE (exp)) == SET_TYPE)
2988 for (tail = list; tail; tail = TREE_CHAIN (tail))
2989 TREE_PURPOSE (tail) = copy_constant (TREE_PURPOSE (tail));
2999 /* Return an rtx representing a reference to constant data in memory
3000 for the constant expression EXP.
3002 If assembler code for such a constant has already been output,
3003 return an rtx to refer to it.
3004 Otherwise, output such a constant in memory (or defer it for later)
3005 and generate an rtx for it.
3007 The TREE_CST_RTL of EXP is set up to point to that rtx.
3008 The const_hash_table records which constants already have label strings. */
3011 output_constant_def (exp)
3015 register struct constant_descriptor *desc;
3021 if (TREE_CST_RTL (exp))
3022 return TREE_CST_RTL (exp);
3024 /* Make sure any other constants whose addresses appear in EXP
3025 are assigned label numbers. */
3027 reloc = output_addressed_constants (exp);
3029 /* Compute hash code of EXP. Search the descriptors for that hash code
3030 to see if any of them describes EXP. If yes, the descriptor records
3031 the label number already assigned. */
3033 hash = const_hash (exp) % MAX_HASH_TABLE;
3035 for (desc = const_hash_table[hash]; desc; desc = desc->next)
3036 if (compare_constant (exp, desc))
3038 found = desc->label;
3044 /* No constant equal to EXP is known to have been output.
3045 Make a constant descriptor to enter EXP in the hash table.
3046 Assign the label number and record it in the descriptor for
3047 future calls to this function to find. */
3049 /* Create a string containing the label name, in LABEL. */
3050 ASM_GENERATE_INTERNAL_LABEL (label, "LC", const_labelno);
3052 desc = record_constant (exp);
3053 desc->next = const_hash_table[hash];
3055 = (char *) obstack_copy0 (&permanent_obstack, label, strlen (label));
3056 const_hash_table[hash] = desc;
3060 /* Create a string containing the label name, in LABEL. */
3061 ASM_GENERATE_INTERNAL_LABEL (label, "LC", const_labelno);
3064 /* We have a symbol name; construct the SYMBOL_REF and the MEM. */
3066 push_obstacks_nochange ();
3067 if (TREE_PERMANENT (exp))
3068 end_temporary_allocation ();
3070 def = gen_rtx (SYMBOL_REF, Pmode, desc->label);
3073 = gen_rtx (MEM, TYPE_MODE (TREE_TYPE (exp)), def);
3074 RTX_UNCHANGING_P (TREE_CST_RTL (exp)) = 1;
3075 if (AGGREGATE_TYPE_P (TREE_TYPE (exp)))
3076 MEM_IN_STRUCT_P (TREE_CST_RTL (exp)) = 1;
3080 /* Optionally set flags or add text to the name to record information
3081 such as that it is a function name. If the name is changed, the macro
3082 ASM_OUTPUT_LABELREF will have to know how to strip this information. */
3083 #ifdef ENCODE_SECTION_INFO
3084 ENCODE_SECTION_INFO (exp);
3087 /* If this is the first time we've seen this particular constant,
3088 output it (or defer its output for later). */
3091 int after_function = 0;
3093 #ifdef CONSTANT_AFTER_FUNCTION_P
3094 if (current_function_decl != 0
3095 && CONSTANT_AFTER_FUNCTION_P (exp))
3099 if (defer_addressed_constants_flag || after_function)
3101 struct deferred_constant *p;
3102 p = (struct deferred_constant *) xmalloc (sizeof (struct deferred_constant));
3104 push_obstacks_nochange ();
3105 suspend_momentary ();
3106 p->exp = copy_constant (exp);
3109 p->labelno = const_labelno++;
3112 p->next = after_function_constants;
3113 after_function_constants = p;
3117 p->next = deferred_constants;
3118 deferred_constants = p;
3122 output_constant_def_contents (exp, reloc, const_labelno++);
3125 return TREE_CST_RTL (exp);
3128 /* Now output assembler code to define the label for EXP,
3129 and follow it with the data of EXP. */
3132 output_constant_def_contents (exp, reloc, labelno)
3139 if (IN_NAMED_SECTION (exp))
3140 named_section (exp, NULL, reloc);
3143 /* First switch to text section, except for writable strings. */
3144 #ifdef SELECT_SECTION
3145 SELECT_SECTION (exp, reloc);
3147 if (((TREE_CODE (exp) == STRING_CST) && flag_writable_strings)
3148 || (flag_pic && reloc))
3151 readonly_data_section ();
3155 /* Align the location counter as required by EXP's data type. */
3156 align = TYPE_ALIGN (TREE_TYPE (exp));
3157 #ifdef CONSTANT_ALIGNMENT
3158 align = CONSTANT_ALIGNMENT (exp, align);
3161 if (align > BITS_PER_UNIT)
3163 if (!output_bytecode)
3165 ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT));
3169 BC_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT));
3173 /* Output the label itself. */
3174 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LC", labelno);
3176 /* Output the value of EXP. */
3177 output_constant (exp,
3178 (TREE_CODE (exp) == STRING_CST
3179 ? TREE_STRING_LENGTH (exp)
3180 : int_size_in_bytes (TREE_TYPE (exp))));
3184 /* Similar hash facility for making memory-constants
3185 from constant rtl-expressions. It is used on RISC machines
3186 where immediate integer arguments and constant addresses are restricted
3187 so that such constants must be stored in memory.
3189 This pool of constants is reinitialized for each function
3190 so each function gets its own constants-pool that comes right before it.
3192 All structures allocated here are discarded when functions are saved for
3193 inlining, so they do not need to be allocated permanently. */
3195 #define MAX_RTX_HASH_TABLE 61
3196 static struct constant_descriptor **const_rtx_hash_table;
3198 /* Structure to represent sufficient information about a constant so that
3199 it can be output when the constant pool is output, so that function
3200 integration can be done, and to simplify handling on machines that reference
3201 constant pool as base+displacement. */
3203 struct pool_constant
3205 struct constant_descriptor *desc;
3206 struct pool_constant *next;
3207 enum machine_mode mode;
3215 /* Pointers to first and last constant in pool. */
3217 static struct pool_constant *first_pool, *last_pool;
3219 /* Current offset in constant pool (does not include any machine-specific
3222 static int pool_offset;
3224 /* Structure used to maintain hash table mapping symbols used to their
3225 corresponding constants. */
3230 struct pool_constant *pool;
3231 struct pool_sym *next;
3234 static struct pool_sym **const_rtx_sym_hash_table;
3236 /* Hash code for a SYMBOL_REF with CONSTANT_POOL_ADDRESS_P true.
3237 The argument is XSTR (... , 0) */
3239 #define SYMHASH(LABEL) \
3240 ((((HOST_WIDE_INT) (LABEL)) & ((1 << HASHBITS) - 1)) % MAX_RTX_HASH_TABLE)
3242 /* Initialize constant pool hashing for next function. */
3245 init_const_rtx_hash_table ()
3247 const_rtx_hash_table
3248 = ((struct constant_descriptor **)
3249 oballoc (MAX_RTX_HASH_TABLE * sizeof (struct constant_descriptor *)));
3250 const_rtx_sym_hash_table
3251 = ((struct pool_sym **)
3252 oballoc (MAX_RTX_HASH_TABLE * sizeof (struct pool_sym *)));
3253 bzero ((char *) const_rtx_hash_table,
3254 MAX_RTX_HASH_TABLE * sizeof (struct constant_descriptor *));
3255 bzero ((char *) const_rtx_sym_hash_table,
3256 MAX_RTX_HASH_TABLE * sizeof (struct pool_sym *));
3258 first_pool = last_pool = 0;
3262 /* Save and restore status for a nested function. */
3265 save_varasm_status (p)
3268 p->const_rtx_hash_table = const_rtx_hash_table;
3269 p->const_rtx_sym_hash_table = const_rtx_sym_hash_table;
3270 p->first_pool = first_pool;
3271 p->last_pool = last_pool;
3272 p->pool_offset = pool_offset;
3276 restore_varasm_status (p)
3279 const_rtx_hash_table = p->const_rtx_hash_table;
3280 const_rtx_sym_hash_table = p->const_rtx_sym_hash_table;
3281 first_pool = p->first_pool;
3282 last_pool = p->last_pool;
3283 pool_offset = p->pool_offset;
3286 enum kind { RTX_DOUBLE, RTX_INT };
3290 #ifdef ONLY_INT_FIELDS
3291 unsigned int kind : 16;
3292 unsigned int mode : 16;
3294 enum kind kind : 16;
3295 enum machine_mode mode : 16;
3298 union real_extract du;
3299 struct addr_const addr;
3300 struct {HOST_WIDE_INT high, low;} di;
3304 /* Express an rtx for a constant integer (perhaps symbolic)
3305 as the sum of a symbol or label plus an explicit integer.
3306 They are stored into VALUE. */
3309 decode_rtx_const (mode, x, value)
3310 enum machine_mode mode;
3312 struct rtx_const *value;
3314 /* Clear the whole structure, including any gaps. */
3317 int *p = (int *) value;
3318 int *end = (int *) (value + 1);
3323 value->kind = RTX_INT; /* Most usual kind. */
3326 switch (GET_CODE (x))
3329 value->kind = RTX_DOUBLE;
3330 if (GET_MODE (x) != VOIDmode)
3332 value->mode = GET_MODE (x);
3333 bcopy ((char *) &CONST_DOUBLE_LOW (x),
3334 (char *) &value->un.du, sizeof value->un.du);
3338 value->un.di.low = CONST_DOUBLE_LOW (x);
3339 value->un.di.high = CONST_DOUBLE_HIGH (x);
3344 value->un.addr.offset = INTVAL (x);
3350 value->un.addr.base = x;
3355 if (GET_CODE (x) == PLUS)
3357 value->un.addr.base = XEXP (x, 0);
3358 if (GET_CODE (XEXP (x, 1)) != CONST_INT)
3360 value->un.addr.offset = INTVAL (XEXP (x, 1));
3362 else if (GET_CODE (x) == MINUS)
3364 value->un.addr.base = XEXP (x, 0);
3365 if (GET_CODE (XEXP (x, 1)) != CONST_INT)
3367 value->un.addr.offset = - INTVAL (XEXP (x, 1));
3377 if (value->kind == RTX_INT && value->un.addr.base != 0)
3378 switch (GET_CODE (value->un.addr.base))
3382 /* Use the string's address, not the SYMBOL_REF's address,
3383 for the sake of addresses of library routines.
3384 For a LABEL_REF, compare labels. */
3385 value->un.addr.base = XEXP (value->un.addr.base, 0);
3389 /* Given a MINUS expression, simplify it if both sides
3390 include the same symbol. */
3393 simplify_subtraction (x)
3396 struct rtx_const val0, val1;
3398 decode_rtx_const (GET_MODE (x), XEXP (x, 0), &val0);
3399 decode_rtx_const (GET_MODE (x), XEXP (x, 1), &val1);
3401 if (val0.un.addr.base == val1.un.addr.base)
3402 return GEN_INT (val0.un.addr.offset - val1.un.addr.offset);
3406 /* Compute a hash code for a constant RTL expression. */
3409 const_hash_rtx (mode, x)
3410 enum machine_mode mode;
3415 struct rtx_const value;
3416 decode_rtx_const (mode, x, &value);
3418 /* Compute hashing function */
3420 for (i = 0; i < sizeof value / sizeof (int); i++)
3421 hi += ((int *) &value)[i];
3423 hi &= (1 << HASHBITS) - 1;
3424 hi %= MAX_RTX_HASH_TABLE;
3428 /* Compare a constant rtl object X with a constant-descriptor DESC.
3429 Return 1 if DESC describes a constant with the same value as X. */
3432 compare_constant_rtx (mode, x, desc)
3433 enum machine_mode mode;
3435 struct constant_descriptor *desc;
3437 register int *p = (int *) desc->contents;
3440 struct rtx_const value;
3442 decode_rtx_const (mode, x, &value);
3443 strp = (int *) &value;
3444 len = sizeof value / sizeof (int);
3446 /* Compare constant contents. */
3448 if (*p++ != *strp++)
3454 /* Construct a constant descriptor for the rtl-expression X.
3455 It is up to the caller to enter the descriptor in the hash table. */
3457 static struct constant_descriptor *
3458 record_constant_rtx (mode, x)
3459 enum machine_mode mode;
3462 struct constant_descriptor *ptr;
3464 struct rtx_const value;
3466 decode_rtx_const (mode, x, &value);
3468 /* Put these things in the saveable obstack so we can ensure it won't
3469 be freed if we are called from combine or some other phase that discards
3470 memory allocated from function_obstack (current_obstack). */
3471 obstack_grow (saveable_obstack, &ptr, sizeof ptr);
3472 obstack_grow (saveable_obstack, &label, sizeof label);
3474 /* Record constant contents. */
3475 obstack_grow (saveable_obstack, &value, sizeof value);
3477 return (struct constant_descriptor *) obstack_finish (saveable_obstack);
3480 /* Given a constant rtx X, make (or find) a memory constant for its value
3481 and return a MEM rtx to refer to it in memory. */
3484 force_const_mem (mode, x)
3485 enum machine_mode mode;
3489 register struct constant_descriptor *desc;
3494 /* If we want this CONST_DOUBLE in the same mode as it is in memory
3495 (this will always be true for floating CONST_DOUBLEs that have been
3496 placed in memory, but not for VOIDmode (integer) CONST_DOUBLEs),
3497 use the previous copy. Otherwise, make a new one. Note that in
3498 the unlikely event that this same CONST_DOUBLE is used in two different
3499 modes in an alternating fashion, we will allocate a lot of different
3500 memory locations, but this should be extremely rare. */
3502 /* Don't use CONST_DOUBLE_MEM in a nested function.
3503 Nested functions have their own constant pools,
3504 so they can't share the same values in CONST_DOUBLE_MEM
3505 with the containing function. */
3506 if (outer_function_chain == 0)
3507 if (GET_CODE (x) == CONST_DOUBLE
3508 && GET_CODE (CONST_DOUBLE_MEM (x)) == MEM
3509 && GET_MODE (CONST_DOUBLE_MEM (x)) == mode)
3510 return CONST_DOUBLE_MEM (x);
3512 /* Compute hash code of X. Search the descriptors for that hash code
3513 to see if any of them describes X. If yes, the descriptor records
3514 the label number already assigned. */
3516 hash = const_hash_rtx (mode, x);
3518 for (desc = const_rtx_hash_table[hash]; desc; desc = desc->next)
3519 if (compare_constant_rtx (mode, x, desc))
3521 found = desc->label;
3527 register struct pool_constant *pool;
3528 register struct pool_sym *sym;
3531 /* No constant equal to X is known to have been output.
3532 Make a constant descriptor to enter X in the hash table.
3533 Assign the label number and record it in the descriptor for
3534 future calls to this function to find. */
3536 desc = record_constant_rtx (mode, x);
3537 desc->next = const_rtx_hash_table[hash];
3538 const_rtx_hash_table[hash] = desc;
3540 /* Align the location counter as required by EXP's data type. */
3541 align = (mode == VOIDmode) ? UNITS_PER_WORD : GET_MODE_SIZE (mode);
3542 if (align > BIGGEST_ALIGNMENT / BITS_PER_UNIT)
3543 align = BIGGEST_ALIGNMENT / BITS_PER_UNIT;
3545 pool_offset += align - 1;
3546 pool_offset &= ~ (align - 1);
3548 /* If RTL is not being placed into the saveable obstack, make a
3549 copy of X that is in the saveable obstack in case we are
3550 being called from combine or some other phase that discards
3551 memory it allocates. We used to only do this if it is a
3552 CONST; however, reload can allocate a CONST_INT when
3553 eliminating registers. */
3554 if (rtl_obstack != saveable_obstack
3555 && (GET_CODE (x) == CONST || GET_CODE (x) == CONST_INT))
3557 push_obstacks_nochange ();
3558 rtl_in_saveable_obstack ();
3560 if (GET_CODE (x) == CONST)
3561 x = gen_rtx (CONST, GET_MODE (x),
3562 gen_rtx (PLUS, GET_MODE (x),
3563 XEXP (XEXP (x, 0), 0),
3564 XEXP (XEXP (x, 0), 1)));
3566 x = GEN_INT (INTVAL (x));
3571 /* Allocate a pool constant descriptor, fill it in, and chain it in. */
3573 pool = (struct pool_constant *) savealloc (sizeof (struct pool_constant));
3577 pool->labelno = const_labelno;
3578 pool->align = align;
3579 pool->offset = pool_offset;
3586 last_pool->next = pool;
3589 pool_offset += GET_MODE_SIZE (mode);
3591 /* Create a string containing the label name, in LABEL. */
3592 ASM_GENERATE_INTERNAL_LABEL (label, "LC", const_labelno);
3597 = (char *) obstack_copy0 (saveable_obstack, label, strlen (label));
3599 /* Add label to symbol hash table. */
3600 hash = SYMHASH (found);
3601 sym = (struct pool_sym *) savealloc (sizeof (struct pool_sym));
3604 sym->next = const_rtx_sym_hash_table[hash];
3605 const_rtx_sym_hash_table[hash] = sym;
3608 /* We have a symbol name; construct the SYMBOL_REF and the MEM. */
3610 def = gen_rtx (MEM, mode, gen_rtx (SYMBOL_REF, Pmode, found));
3612 RTX_UNCHANGING_P (def) = 1;
3613 /* Mark the symbol_ref as belonging to this constants pool. */
3614 CONSTANT_POOL_ADDRESS_P (XEXP (def, 0)) = 1;
3615 current_function_uses_const_pool = 1;
3617 if (outer_function_chain == 0)
3618 if (GET_CODE (x) == CONST_DOUBLE)
3620 if (CONST_DOUBLE_MEM (x) == cc0_rtx)
3622 CONST_DOUBLE_CHAIN (x) = const_double_chain;
3623 const_double_chain = x;
3625 CONST_DOUBLE_MEM (x) = def;
3631 /* Given a SYMBOL_REF with CONSTANT_POOL_ADDRESS_P true, return a pointer to
3632 the corresponding pool_constant structure. */
3634 static struct pool_constant *
3635 find_pool_constant (addr)
3638 struct pool_sym *sym;
3639 char *label = XSTR (addr, 0);
3641 for (sym = const_rtx_sym_hash_table[SYMHASH (label)]; sym; sym = sym->next)
3642 if (sym->label == label)
3648 /* Given a constant pool SYMBOL_REF, return the corresponding constant. */
3651 get_pool_constant (addr)
3654 return (find_pool_constant (addr))->constant;
3657 /* Similar, return the mode. */
3660 get_pool_mode (addr)
3663 return (find_pool_constant (addr))->mode;
3666 /* Similar, return the offset in the constant pool. */
3669 get_pool_offset (addr)
3672 return (find_pool_constant (addr))->offset;
3675 /* Return the size of the constant pool. */
3683 /* Write all the constants in the constant pool. */
3686 output_constant_pool (fnname, fndecl)
3690 struct pool_constant *pool;
3692 union real_extract u;
3694 /* It is possible for gcc to call force_const_mem and then to later
3695 discard the instructions which refer to the constant. In such a
3696 case we do not need to output the constant. */
3697 if (optimize >= 0 && flag_expensive_optimizations)
3698 mark_constant_pool ();
3700 #ifdef ASM_OUTPUT_POOL_PROLOGUE
3701 ASM_OUTPUT_POOL_PROLOGUE (asm_out_file, fnname, fndecl, pool_offset);
3704 for (pool = first_pool; pool; pool = pool->next)
3711 /* See if X is a LABEL_REF (or a CONST referring to a LABEL_REF)
3712 whose CODE_LABEL has been deleted. This can occur if a jump table
3713 is eliminated by optimization. If so, write a constant of zero
3714 instead. Note that this can also happen by turning the
3715 CODE_LABEL into a NOTE. */
3716 if (((GET_CODE (x) == LABEL_REF
3717 && (INSN_DELETED_P (XEXP (x, 0))
3718 || GET_CODE (XEXP (x, 0)) == NOTE)))
3719 || (GET_CODE (x) == CONST && GET_CODE (XEXP (x, 0)) == PLUS
3720 && GET_CODE (XEXP (XEXP (x, 0), 0)) == LABEL_REF
3721 && (INSN_DELETED_P (XEXP (XEXP (XEXP (x, 0), 0), 0))
3722 || GET_CODE (XEXP (XEXP (XEXP (x, 0), 0), 0)) == NOTE)))
3725 /* First switch to correct section. */
3726 #ifdef SELECT_RTX_SECTION
3727 SELECT_RTX_SECTION (pool->mode, x);
3729 readonly_data_section ();
3732 #ifdef ASM_OUTPUT_SPECIAL_POOL_ENTRY
3733 ASM_OUTPUT_SPECIAL_POOL_ENTRY (asm_out_file, x, pool->mode,
3734 pool->align, pool->labelno, done);
3737 if (pool->align > 1)
3738 ASM_OUTPUT_ALIGN (asm_out_file, exact_log2 (pool->align));
3740 /* Output the label. */
3741 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LC", pool->labelno);
3743 /* Output the value of the constant itself. */
3744 switch (GET_MODE_CLASS (pool->mode))
3747 if (GET_CODE (x) != CONST_DOUBLE)
3750 bcopy ((char *) &CONST_DOUBLE_LOW (x), (char *) &u, sizeof u);
3751 assemble_real (u.d, pool->mode);
3755 case MODE_PARTIAL_INT:
3756 assemble_integer (x, GET_MODE_SIZE (pool->mode), 1);
3766 #ifdef ASM_OUTPUT_POOL_EPILOGUE
3767 ASM_OUTPUT_POOL_EPILOGUE (asm_out_file, fnname, fndecl, pool_offset);
3770 /* Done with this pool. */
3771 first_pool = last_pool = 0;
3774 /* Look through the instructions for this function, and mark all the
3775 entries in the constant pool which are actually being used. */
3778 mark_constant_pool ()
3781 struct pool_constant *pool;
3783 if (first_pool == 0)
3786 for (pool = first_pool; pool; pool = pool->next)
3789 for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
3790 if (GET_RTX_CLASS (GET_CODE (insn)) == 'i')
3791 mark_constants (PATTERN (insn));
3793 for (insn = current_function_epilogue_delay_list;
3795 insn = XEXP (insn, 1))
3796 if (GET_RTX_CLASS (GET_CODE (insn)) == 'i')
3797 mark_constants (PATTERN (insn));
3805 register char *format_ptr;
3810 if (GET_CODE (x) == SYMBOL_REF)
3812 if (CONSTANT_POOL_ADDRESS_P (x))
3813 find_pool_constant (x)->mark = 1;
3816 /* Never search inside a CONST_DOUBLE, because CONST_DOUBLE_MEM may be
3817 a MEM, but does not constitute a use of that MEM. This is particularly
3818 important inside a nested function, because CONST_DOUBLE_MEM may be
3819 a reference to a MEM in the parent's constant pool. See the comment
3820 in force_const_mem. */
3821 else if (GET_CODE (x) == CONST_DOUBLE)
3824 /* Insns may appear inside a SEQUENCE. Only check the patterns of
3825 insns, not any notes that may be attached. We don't want to mark
3826 a constant just because it happens to appear in a REG_EQUIV note. */
3827 if (GET_RTX_CLASS (GET_CODE (x)) == 'i')
3829 mark_constants (PATTERN (x));
3833 format_ptr = GET_RTX_FORMAT (GET_CODE (x));
3835 for (i = 0; i < GET_RTX_LENGTH (GET_CODE (x)); i++)
3837 switch (*format_ptr++)
3840 mark_constants (XEXP (x, i));
3844 if (XVEC (x, i) != 0)
3848 for (j = 0; j < XVECLEN (x, i); j++)
3849 mark_constants (XVECEXP (x, i, j));
3868 /* Find all the constants whose addresses are referenced inside of EXP,
3869 and make sure assembler code with a label has been output for each one.
3870 Indicate whether an ADDR_EXPR has been encountered. */
3873 output_addressed_constants (exp)
3878 switch (TREE_CODE (exp))
3882 register tree constant = TREE_OPERAND (exp, 0);
3884 while (TREE_CODE (constant) == COMPONENT_REF)
3886 constant = TREE_OPERAND (constant, 0);
3889 if (TREE_CODE_CLASS (TREE_CODE (constant)) == 'c'
3890 || TREE_CODE (constant) == CONSTRUCTOR)
3891 /* No need to do anything here
3892 for addresses of variables or functions. */
3893 output_constant_def (constant);
3900 reloc = output_addressed_constants (TREE_OPERAND (exp, 0));
3901 reloc |= output_addressed_constants (TREE_OPERAND (exp, 1));
3906 case NON_LVALUE_EXPR:
3907 reloc = output_addressed_constants (TREE_OPERAND (exp, 0));
3913 for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link))
3914 if (TREE_VALUE (link) != 0)
3915 reloc |= output_addressed_constants (TREE_VALUE (link));
3925 /* Output assembler code for constant EXP to FILE, with no label.
3926 This includes the pseudo-op such as ".int" or ".byte", and a newline.
3927 Assumes output_addressed_constants has been done on EXP already.
3929 Generate exactly SIZE bytes of assembler data, padding at the end
3930 with zeros if necessary. SIZE must always be specified.
3932 SIZE is important for structure constructors,
3933 since trailing members may have been omitted from the constructor.
3934 It is also important for initialization of arrays from string constants
3935 since the full length of the string constant might not be wanted.
3936 It is also needed for initialization of unions, where the initializer's
3937 type is just one member, and that may not be as long as the union.
3939 There a case in which we would fail to output exactly SIZE bytes:
3940 for a structure constructor that wants to produce more than SIZE bytes.
3941 But such constructors will never be generated for any possible input. */
3944 output_constant (exp, size)
3948 register enum tree_code code = TREE_CODE (TREE_TYPE (exp));
3954 /* Eliminate the NON_LVALUE_EXPR_EXPR that makes a cast not be an lvalue.
3955 That way we get the constant (we hope) inside it. Also, strip off any
3956 NOP_EXPR that converts between two record, union, array, or set types. */
3957 while ((TREE_CODE (exp) == NOP_EXPR
3958 && (TREE_TYPE (exp) == TREE_TYPE (TREE_OPERAND (exp, 0))
3959 || AGGREGATE_TYPE_P (TREE_TYPE (exp))))
3960 || TREE_CODE (exp) == NON_LVALUE_EXPR)
3961 exp = TREE_OPERAND (exp, 0);
3963 /* Allow a constructor with no elements for any data type.
3964 This means to fill the space with zeros. */
3965 if (TREE_CODE (exp) == CONSTRUCTOR && CONSTRUCTOR_ELTS (exp) == 0)
3967 if (output_bytecode)
3968 bc_emit_const_skip (size);
3970 assemble_zeros (size);
3981 case REFERENCE_TYPE:
3982 /* ??? What about (int)((float)(int)&foo + 4) */
3983 while (TREE_CODE (exp) == NOP_EXPR || TREE_CODE (exp) == CONVERT_EXPR
3984 || TREE_CODE (exp) == NON_LVALUE_EXPR)
3985 exp = TREE_OPERAND (exp, 0);
3987 if (! assemble_integer (expand_expr (exp, NULL_RTX, VOIDmode,
3988 EXPAND_INITIALIZER),
3990 error ("initializer for integer value is too complicated");
3995 if (TREE_CODE (exp) != REAL_CST)
3996 error ("initializer for floating value is not a floating constant");
3998 assemble_real (TREE_REAL_CST (exp),
3999 mode_for_size (size * BITS_PER_UNIT, MODE_FLOAT, 0));
4004 output_constant (TREE_REALPART (exp), size / 2);
4005 output_constant (TREE_IMAGPART (exp), size / 2);
4006 size -= (size / 2) * 2;
4010 if (TREE_CODE (exp) == CONSTRUCTOR)
4012 output_constructor (exp, size);
4015 else if (TREE_CODE (exp) == STRING_CST)
4019 if (size > TREE_STRING_LENGTH (exp))
4021 excess = size - TREE_STRING_LENGTH (exp);
4022 size = TREE_STRING_LENGTH (exp);
4025 assemble_string (TREE_STRING_POINTER (exp), size);
4034 if (TREE_CODE (exp) == CONSTRUCTOR)
4035 output_constructor (exp, size);
4041 if (TREE_CODE (exp) == INTEGER_CST)
4042 assemble_integer (expand_expr (exp, NULL_RTX,
4043 VOIDmode, EXPAND_INITIALIZER),
4045 else if (TREE_CODE (exp) == CONSTRUCTOR)
4047 unsigned char *buffer = (unsigned char *) alloca (size);
4048 if (get_set_constructor_bytes (exp, buffer, size))
4050 assemble_string ((char *) buffer, size);
4053 error ("unknown set constructor type");
4058 assemble_zeros (size);
4061 /* Bytecode specific code to output assembler for integer. */
4064 bc_assemble_integer (exp, size)
4072 /* FIXME: is this fold() business going to be as good as the
4073 expand_expr() using EXPAND_SUM above in the RTL case? I
4075 FIXME: Copied as is from BC-GCC1; may need work. Don't hate. -bson */
4079 while (TREE_CODE (exp) == NOP_EXPR || TREE_CODE (exp) == CONVERT_EXPR
4080 || TREE_CODE (exp) == NON_LVALUE_EXPR)
4081 exp = TREE_OPERAND (exp, 0);
4082 if (TREE_CODE (exp) == INTEGER_CST)
4087 else if (TREE_CODE (exp) == PLUS_EXPR)
4089 const_part = TREE_OPERAND (exp, 0);
4090 while (TREE_CODE (const_part) == NOP_EXPR
4091 || TREE_CODE (const_part) == CONVERT_EXPR
4092 || TREE_CODE (const_part) == NON_LVALUE_EXPR)
4093 const_part = TREE_OPERAND (const_part, 0);
4094 addr_part = TREE_OPERAND (exp, 1);
4095 while (TREE_CODE (addr_part) == NOP_EXPR
4096 || TREE_CODE (addr_part) == CONVERT_EXPR
4097 || TREE_CODE (addr_part) == NON_LVALUE_EXPR)
4098 addr_part = TREE_OPERAND (addr_part, 0);
4099 if (TREE_CODE (const_part) != INTEGER_CST)
4100 tmp = const_part, const_part = addr_part, addr_part = tmp;
4101 if (TREE_CODE (const_part) != INTEGER_CST
4102 || TREE_CODE (addr_part) != ADDR_EXPR)
4103 abort (); /* FIXME: we really haven't considered
4104 all the possible cases here. */
4106 else if (TREE_CODE (exp) == ADDR_EXPR)
4108 const_part = integer_zero_node;
4112 abort (); /* FIXME: ditto previous. */
4118 char c = TREE_INT_CST_LOW (const_part);
4124 short s = TREE_INT_CST_LOW (const_part);
4125 bc_emit ((char *) &s, 2);
4130 int i = TREE_INT_CST_LOW (const_part);
4131 bc_emit ((char *) &i, 4);
4136 if (WORDS_BIG_ENDIAN)
4138 int i = TREE_INT_CST_HIGH (const_part);
4139 bc_emit ((char *) &i, 4);
4140 i = TREE_INT_CST_LOW (const_part);
4141 bc_emit ((char *) &i, 4);
4145 int i = TREE_INT_CST_LOW (const_part);
4146 bc_emit ((char *) &i, 4);
4147 i = TREE_INT_CST_HIGH (const_part);
4148 bc_emit ((char *) &i, 4);
4155 && TREE_CODE (TREE_OPERAND (addr_part, 0)) == VAR_DECL)
4156 bc_emit_labelref (IDENTIFIER_POINTER
4157 (DECL_ASSEMBLER_NAME (TREE_OPERAND (addr_part, 0))),
4158 TREE_INT_CST_LOW (const_part));
4160 abort (); /* FIXME: there may be more cases. */
4163 /* Subroutine of output_constant, used for CONSTRUCTORs
4164 (aggregate constants).
4165 Generate at least SIZE bytes, padding if necessary. */
4168 output_constructor (exp, size)
4172 register tree link, field = 0;
4173 HOST_WIDE_INT min_index = 0;
4174 /* Number of bytes output or skipped so far.
4175 In other words, current position within the constructor. */
4176 int total_bytes = 0;
4177 /* Non-zero means BYTE contains part of a byte, to be output. */
4178 int byte_buffer_in_use = 0;
4181 if (HOST_BITS_PER_WIDE_INT < BITS_PER_UNIT)
4184 if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE)
4185 field = TYPE_FIELDS (TREE_TYPE (exp));
4187 if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE
4188 && TYPE_DOMAIN (TREE_TYPE (exp)) != 0)
4190 = TREE_INT_CST_LOW (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (exp))));
4192 /* As LINK goes through the elements of the constant,
4193 FIELD goes through the structure fields, if the constant is a structure.
4194 if the constant is a union, then we override this,
4195 by getting the field from the TREE_LIST element.
4196 But the constant could also be an array. Then FIELD is zero. */
4197 for (link = CONSTRUCTOR_ELTS (exp);
4199 link = TREE_CHAIN (link),
4200 field = field ? TREE_CHAIN (field) : 0)
4202 tree val = TREE_VALUE (link);
4205 /* the element in a union constructor specifies the proper field. */
4207 if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE
4208 || TREE_CODE (TREE_TYPE (exp)) == UNION_TYPE)
4210 /* if available, use the type given by link */
4211 if (TREE_PURPOSE (link) != 0)
4212 field = TREE_PURPOSE (link);
4215 if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE)
4216 index = TREE_PURPOSE (link);
4218 /* Eliminate the marker that makes a cast not be an lvalue. */
4222 if (index && TREE_CODE (index) == RANGE_EXPR)
4224 register int fieldsize
4225 = int_size_in_bytes (TREE_TYPE (TREE_TYPE (exp)));
4226 HOST_WIDE_INT lo_index = TREE_INT_CST_LOW (TREE_OPERAND (index, 0));
4227 HOST_WIDE_INT hi_index = TREE_INT_CST_LOW (TREE_OPERAND (index, 1));
4228 HOST_WIDE_INT index;
4229 for (index = lo_index; index <= hi_index; index++)
4231 /* Output the element's initial value. */
4233 assemble_zeros (fieldsize);
4235 output_constant (val, fieldsize);
4237 /* Count its size. */
4238 total_bytes += fieldsize;
4241 else if (field == 0 || !DECL_BIT_FIELD (field))
4243 /* An element that is not a bit-field. */
4245 register int fieldsize;
4246 /* Since this structure is static,
4247 we know the positions are constant. */
4248 int bitpos = (field ? (TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field))
4252 bitpos = (TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (val)))
4254 * (TREE_INT_CST_LOW (index) - min_index));
4256 /* Output any buffered-up bit-fields preceding this element. */
4257 if (byte_buffer_in_use)
4259 ASM_OUTPUT_BYTE (asm_out_file, byte);
4261 byte_buffer_in_use = 0;
4264 /* Advance to offset of this element.
4265 Note no alignment needed in an array, since that is guaranteed
4266 if each element has the proper size. */
4267 if ((field != 0 || index != 0) && bitpos != total_bytes)
4269 if (!output_bytecode)
4270 assemble_zeros (bitpos - total_bytes);
4272 bc_emit_const_skip (bitpos - total_bytes);
4273 total_bytes = bitpos;
4276 /* Determine size this element should occupy. */
4279 if (TREE_CODE (DECL_SIZE (field)) != INTEGER_CST)
4281 if (TREE_INT_CST_LOW (DECL_SIZE (field)) > 100000)
4283 /* This avoids overflow trouble. */
4284 tree size_tree = size_binop (CEIL_DIV_EXPR,
4286 size_int (BITS_PER_UNIT));
4287 fieldsize = TREE_INT_CST_LOW (size_tree);
4291 fieldsize = TREE_INT_CST_LOW (DECL_SIZE (field));
4292 fieldsize = (fieldsize + BITS_PER_UNIT - 1) / BITS_PER_UNIT;
4296 fieldsize = int_size_in_bytes (TREE_TYPE (TREE_TYPE (exp)));
4298 /* Output the element's initial value. */
4300 assemble_zeros (fieldsize);
4302 output_constant (val, fieldsize);
4304 /* Count its size. */
4305 total_bytes += fieldsize;
4307 else if (val != 0 && TREE_CODE (val) != INTEGER_CST)
4308 error ("invalid initial value for member `%s'",
4309 IDENTIFIER_POINTER (DECL_NAME (field)));
4312 /* Element that is a bit-field. */
4314 int next_offset = TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field));
4316 = (next_offset + TREE_INT_CST_LOW (DECL_SIZE (field)));
4319 val = integer_zero_node;
4321 /* If this field does not start in this (or, next) byte,
4323 if (next_offset / BITS_PER_UNIT != total_bytes)
4325 /* Output remnant of any bit field in previous bytes. */
4326 if (byte_buffer_in_use)
4328 ASM_OUTPUT_BYTE (asm_out_file, byte);
4330 byte_buffer_in_use = 0;
4333 /* If still not at proper byte, advance to there. */
4334 if (next_offset / BITS_PER_UNIT != total_bytes)
4336 assemble_zeros (next_offset / BITS_PER_UNIT - total_bytes);
4337 total_bytes = next_offset / BITS_PER_UNIT;
4341 if (! byte_buffer_in_use)
4344 /* We must split the element into pieces that fall within
4345 separate bytes, and combine each byte with previous or
4346 following bit-fields. */
4348 /* next_offset is the offset n fbits from the beginning of
4349 the structure to the next bit of this element to be processed.
4350 end_offset is the offset of the first bit past the end of
4352 while (next_offset < end_offset)
4356 HOST_WIDE_INT value;
4357 int next_byte = next_offset / BITS_PER_UNIT;
4358 int next_bit = next_offset % BITS_PER_UNIT;
4360 /* Advance from byte to byte
4361 within this element when necessary. */
4362 while (next_byte != total_bytes)
4364 ASM_OUTPUT_BYTE (asm_out_file, byte);
4369 /* Number of bits we can process at once
4370 (all part of the same byte). */
4371 this_time = MIN (end_offset - next_offset,
4372 BITS_PER_UNIT - next_bit);
4373 if (BYTES_BIG_ENDIAN)
4375 /* On big-endian machine, take the most significant bits
4376 first (of the bits that are significant)
4377 and put them into bytes from the most significant end. */
4378 shift = end_offset - next_offset - this_time;
4379 /* Don't try to take a bunch of bits that cross
4380 the word boundary in the INTEGER_CST. */
4381 if (shift < HOST_BITS_PER_WIDE_INT
4382 && shift + this_time > HOST_BITS_PER_WIDE_INT)
4384 this_time -= (HOST_BITS_PER_WIDE_INT - shift);
4385 shift = HOST_BITS_PER_WIDE_INT;
4388 /* Now get the bits from the appropriate constant word. */
4389 if (shift < HOST_BITS_PER_WIDE_INT)
4391 value = TREE_INT_CST_LOW (val);
4393 else if (shift < 2 * HOST_BITS_PER_WIDE_INT)
4395 value = TREE_INT_CST_HIGH (val);
4396 shift -= HOST_BITS_PER_WIDE_INT;
4400 byte |= (((value >> shift)
4401 & (((HOST_WIDE_INT) 1 << this_time) - 1))
4402 << (BITS_PER_UNIT - this_time - next_bit));
4406 /* On little-endian machines,
4407 take first the least significant bits of the value
4408 and pack them starting at the least significant
4409 bits of the bytes. */
4410 shift = (next_offset
4411 - TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field)));
4412 /* Don't try to take a bunch of bits that cross
4413 the word boundary in the INTEGER_CST. */
4414 if (shift < HOST_BITS_PER_WIDE_INT
4415 && shift + this_time > HOST_BITS_PER_WIDE_INT)
4417 this_time -= (HOST_BITS_PER_WIDE_INT - shift);
4418 shift = HOST_BITS_PER_WIDE_INT;
4421 /* Now get the bits from the appropriate constant word. */
4422 if (shift < HOST_BITS_PER_INT)
4423 value = TREE_INT_CST_LOW (val);
4424 else if (shift < 2 * HOST_BITS_PER_WIDE_INT)
4426 value = TREE_INT_CST_HIGH (val);
4427 shift -= HOST_BITS_PER_WIDE_INT;
4431 byte |= (((value >> shift)
4432 & (((HOST_WIDE_INT) 1 << this_time) - 1))
4435 next_offset += this_time;
4436 byte_buffer_in_use = 1;
4440 if (byte_buffer_in_use)
4442 ASM_OUTPUT_BYTE (asm_out_file, byte);
4445 if (total_bytes < size)
4446 assemble_zeros (size - total_bytes);
4449 /* Output asm to handle ``#pragma weak'' */
4452 handle_pragma_weak (what, name, value)
4453 enum pragma_state what;
4456 #ifdef HANDLE_PRAGMA_WEAK
4457 if (what == ps_name || what == ps_value)
4459 struct weak_syms *weak =
4460 (struct weak_syms *)permalloc (sizeof (struct weak_syms));
4461 weak->next = weak_decls;
4462 weak->name = permalloc (strlen (name) + 1);
4463 strcpy (weak->name, name);
4465 if (what != ps_value)
4466 weak->value = NULL_PTR;
4470 weak->value = permalloc (strlen (value) + 1);
4471 strcpy (weak->value, value);
4476 else if (! (what == ps_done || what == ps_start))
4477 warning ("malformed `#pragma weak'");
4478 #endif /* HANDLE_PRAGMA_WEAK */
4481 /* Declare DECL to be a weak symbol. */
4487 if (! TREE_PUBLIC (decl))
4488 error_with_decl (decl, "weak declaration of `%s' must be public");
4489 else if (TREE_ASM_WRITTEN (decl))
4490 error_with_decl (decl, "weak declaration of `%s' must precede definition");
4491 else if (SUPPORTS_WEAK)
4492 DECL_WEAK (decl) = 1;
4495 /* Emit any pending weak declarations. */
4500 #ifdef HANDLE_PRAGMA_WEAK
4501 if (HANDLE_PRAGMA_WEAK)
4503 struct weak_syms *t;
4504 for (t = weak_decls; t; t = t->next)
4506 ASM_WEAKEN_LABEL (asm_out_file, t->name);
4508 ASM_OUTPUT_DEF (asm_out_file, t->name, t->value);
4515 assemble_alias (decl, target)
4520 make_decl_rtl (decl, (char *) 0, 1);
4521 name = XSTR (XEXP (DECL_RTL (decl), 0), 0);
4523 #ifdef ASM_OUTPUT_DEF
4524 /* Make name accessible from other files, if appropriate. */
4526 if (TREE_PUBLIC (decl))
4528 #ifdef ASM_WEAKEN_LABEL
4529 if (DECL_WEAK (decl))
4530 ASM_WEAKEN_LABEL (asm_out_file, name);
4533 if (output_bytecode)
4534 BC_GLOBALIZE_LABEL (asm_out_file, name);
4536 ASM_GLOBALIZE_LABEL (asm_out_file, name);
4539 ASM_OUTPUT_DEF (asm_out_file, name, IDENTIFIER_POINTER (target));
4540 TREE_ASM_WRITTEN (decl) = 1;
4542 #ifdef ASM_OUTPUT_WEAK_ALIAS
4543 if (! DECL_WEAK (decl))
4544 warning ("only weak aliases are supported in this configuration");
4546 ASM_OUTPUT_WEAK_ALIAS (asm_out_file, name, IDENTIFIER_POINTER (target));
4547 TREE_ASM_WRITTEN (decl) = 1;
4549 warning ("alias definitions not supported in this configuration; ignored");
4554 /* This determines whether or not we support link-once semantics. */
4555 #ifndef SUPPORTS_ONE_ONLY
4556 #ifdef MAKE_DECL_ONE_ONLY
4557 #define SUPPORTS_ONE_ONLY 1
4559 #define SUPPORTS_ONE_ONLY 0
4563 /* Returns 1 if the target configuration supports defining public symbols
4564 so that one of them will be chosen at link time instead of generating a
4565 multiply-defined symbol error, whether through the use of weak symbols or
4566 a target-specific mechanism for having duplicates discarded. */
4569 supports_one_only ()
4571 if (SUPPORTS_ONE_ONLY)
4573 return SUPPORTS_WEAK;
4576 /* Set up DECL as a public symbol that can be defined in multiple
4577 translation units without generating a linker error. */
4580 make_decl_one_only (decl)
4583 if (TREE_CODE (decl) != VAR_DECL && TREE_CODE (decl) != FUNCTION_DECL)
4586 TREE_PUBLIC (decl) = 1;
4588 if (TREE_CODE (decl) == VAR_DECL
4589 && (DECL_INITIAL (decl) == 0 || DECL_INITIAL (decl) == error_mark_node))
4590 DECL_COMMON (decl) = 1;
4591 else if (SUPPORTS_ONE_ONLY)
4593 #ifdef MAKE_DECL_ONE_ONLY
4594 MAKE_DECL_ONE_ONLY (decl);
4596 DECL_ONE_ONLY (decl) = 1;
4598 else if (SUPPORTS_WEAK)
4599 DECL_WEAK (decl) = 1;