1 /* Output variables, constants and external declarations, for GNU compiler.
2 Copyright (C) 1987, 88, 89, 92-5, 1996 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> */
39 #include "hard-reg-set.h"
48 #ifdef XCOFF_DEBUGGING_INFO
55 #define ASM_STABS_OP ".stabs"
58 /* This macro gets just the user-specified name
59 out of the string in a SYMBOL_REF. On most machines,
60 we discard the * if any and that's all. */
61 #ifndef STRIP_NAME_ENCODING
62 #define STRIP_NAME_ENCODING(VAR,SYMBOL_NAME) \
63 (VAR) = ((SYMBOL_NAME) + ((SYMBOL_NAME)[0] == '*'))
66 /* File in which assembler code is being written. */
68 extern FILE *asm_out_file;
70 /* The (assembler) name of the first globally-visible object output. */
71 char *first_global_object_name;
73 extern struct obstack *current_obstack;
74 extern struct obstack *saveable_obstack;
75 extern struct obstack *rtl_obstack;
76 extern struct obstack permanent_obstack;
77 #define obstack_chunk_alloc xmalloc
79 /* Number for making the label on the next
80 constant that is stored in memory. */
84 /* Number for making the label on the next
85 static variable internal to a function. */
89 /* Carry information from ASM_DECLARE_OBJECT_NAME
90 to ASM_FINISH_DECLARE_OBJECT. */
92 int size_directive_output;
94 /* The last decl for which assemble_variable was called,
95 if it did ASM_DECLARE_OBJECT_NAME.
96 If the last call to assemble_variable didn't do that,
99 tree last_assemble_variable_decl;
102 #ifdef HANDLE_PRAGMA_WEAK
103 /* Any weak symbol declarations waiting to be emitted. */
107 struct weak_syms *next;
112 static struct weak_syms *weak_decls;
115 /* Nonzero if at least one function definition has been seen. */
117 static int function_defined;
120 struct constant_descriptor;
122 struct pool_constant;
124 static void bc_make_decl_rtl PROTO((tree, char *, int));
125 static char *strip_reg_name PROTO((char *));
126 static void bc_output_ascii PROTO((FILE *, char *, int));
127 static int contains_pointers_p PROTO((tree));
128 static void decode_addr_const PROTO((tree, struct addr_const *));
129 static int const_hash PROTO((tree));
130 static int compare_constant PROTO((tree,
131 struct constant_descriptor *));
132 static char *compare_constant_1 PROTO((tree, char *));
133 static struct constant_descriptor *record_constant PROTO((tree));
134 static void record_constant_1 PROTO((tree));
135 static tree copy_constant PROTO((tree));
136 static void output_constant_def_contents PROTO((tree, int, int));
137 static void decode_rtx_const PROTO((enum machine_mode, rtx,
138 struct rtx_const *));
139 static int const_hash_rtx PROTO((enum machine_mode, rtx));
140 static int compare_constant_rtx PROTO((enum machine_mode, rtx,
141 struct constant_descriptor *));
142 static struct constant_descriptor *record_constant_rtx PROTO((enum machine_mode,
144 static struct pool_constant *find_pool_constant PROTO((rtx));
145 static int output_addressed_constants PROTO((tree));
146 static void bc_assemble_integer PROTO((tree, int));
147 static void output_constructor PROTO((tree, int));
149 static enum in_section { no_section, in_text, in_data, in_named
150 #ifdef BSS_SECTION_ASM_OP
153 #ifdef EXTRA_SECTIONS
156 } in_section = no_section;
158 /* Return a non-zero value if DECL has a section attribute. */
159 #define IN_NAMED_SECTION(DECL) \
160 ((TREE_CODE (DECL) == FUNCTION_DECL || TREE_CODE (DECL) == VAR_DECL) \
161 && DECL_SECTION_NAME (DECL) != NULL_TREE)
163 /* Text of section name when in_section == in_named. */
164 static char *in_named_name;
166 /* Define functions like text_section for any extra sections. */
167 #ifdef EXTRA_SECTION_FUNCTIONS
168 EXTRA_SECTION_FUNCTIONS
171 /* Tell assembler to switch to text section. */
176 if (in_section != in_text)
181 fprintf (asm_out_file, "%s\n", TEXT_SECTION_ASM_OP);
183 in_section = in_text;
187 /* Tell assembler to switch to data section. */
192 if (in_section != in_data)
198 if (flag_shared_data)
200 #ifdef SHARED_SECTION_ASM_OP
201 fprintf (asm_out_file, "%s\n", SHARED_SECTION_ASM_OP);
203 fprintf (asm_out_file, "%s\n", DATA_SECTION_ASM_OP);
207 fprintf (asm_out_file, "%s\n", DATA_SECTION_ASM_OP);
210 in_section = in_data;
214 /* Tell assembler to switch to read-only data section. This is normally
218 readonly_data_section ()
220 #ifdef READONLY_DATA_SECTION
221 READONLY_DATA_SECTION (); /* Note this can call data_section. */
227 /* Determine if we're in the text section. */
232 return in_section == in_text;
235 /* Determine if we're in the data section. */
240 return in_section == in_data;
243 /* Tell assembler to change to section NAME for DECL.
244 If DECL is NULL, just switch to section NAME.
245 If NAME is NULL, get the name from DECL. */
248 named_section (decl, name)
252 if (decl != NULL_TREE
253 && TREE_CODE_CLASS (TREE_CODE (decl)) != 'd')
256 name = TREE_STRING_POINTER (DECL_SECTION_NAME (decl));
258 if (in_section != in_named || strcmp (name, in_named_name))
260 in_named_name = obstack_alloc (&permanent_obstack, strlen (name) + 1);
261 strcpy (in_named_name, name);
262 in_section = in_named;
264 #ifdef ASM_OUTPUT_SECTION_NAME
265 ASM_OUTPUT_SECTION_NAME (asm_out_file, decl, name);
267 /* Section attributes are not supported if this macro isn't provided -
268 some host formats don't support them at all. The front-end should
269 already have flagged this as an error. */
275 #ifdef BSS_SECTION_ASM_OP
277 /* Tell the assembler to switch to the bss section. */
280 bss_section (decl, name)
282 if (in_section != in_bss)
288 #ifdef SHARED_BSS_SECTION_ASM_OP
289 if (flag_shared_data)
290 fprintf (asm_out_file, "%s\n", SHARED_BSS_SECTION_ASM_OP);
293 fprintf (asm_out_file, "%s\n", BSS_SECTION_ASM_OP);
300 #ifdef ASM_OUTPUT_BSS
302 /* Utility function for ASM_OUTPUT_BSS for targets to use if
303 they don't support alignments in .bss.
304 ??? It is believed that this function will work in most cases so such
305 support is localized here. */
308 asm_output_bss (file, decl, name, size, rounded)
314 ASM_GLOBALIZE_LABEL (file, name);
316 #ifdef ASM_DECLARE_OBJECT_NAME
317 last_assemble_variable_decl = decl;
318 ASM_DECLARE_OBJECT_NAME (file, name, decl);
320 /* Standard thing is just output label for the object. */
321 ASM_OUTPUT_LABEL (file, name);
322 #endif /* ASM_DECLARE_OBJECT_NAME */
323 ASM_OUTPUT_SKIP (file, rounded);
328 #ifdef ASM_OUTPUT_ALIGNED_BSS
330 /* Utility function for targets to use in implementing
331 ASM_OUTPUT_ALIGNED_BSS.
332 ??? It is believed that this function will work in most cases so such
333 support is localized here. */
336 asm_output_aligned_bss (file, decl, name, size, align)
342 ASM_GLOBALIZE_LABEL (file, name);
344 ASM_OUTPUT_ALIGN (file, floor_log2 (align / BITS_PER_UNIT));
345 #ifdef ASM_DECLARE_OBJECT_NAME
346 last_assemble_variable_decl = decl;
347 ASM_DECLARE_OBJECT_NAME (file, name, decl);
349 /* Standard thing is just output label for the object. */
350 ASM_OUTPUT_LABEL (file, name);
351 #endif /* ASM_DECLARE_OBJECT_NAME */
352 ASM_OUTPUT_SKIP (file, size);
357 #endif /* BSS_SECTION_ASM_OP */
359 /* Switch to the section for function DECL.
361 If DECL is NULL_TREE, switch to the text section.
362 ??? It's not clear that we will ever be passed NULL_TREE, but it's
363 safer to handle it. */
366 function_section (decl)
369 if (decl != NULL_TREE
370 && DECL_SECTION_NAME (decl) != NULL_TREE)
371 named_section (decl, (char *) 0);
376 /* Switch to section for variable DECL.
378 RELOC is the `reloc' argument to SELECT_SECTION. */
381 variable_section (decl, reloc)
385 if (IN_NAMED_SECTION (decl))
386 named_section (decl, NULL);
389 /* C++ can have const variables that get initialized from constructors,
390 and thus can not be in a readonly section. We prevent this by
391 verifying that the initial value is constant for objects put in a
394 error_mark_node is used by the C front end to indicate that the
395 initializer has not been seen yet. In this case, we assume that
396 the initializer must be constant.
398 C++ uses error_mark_node for variables that have complicated
399 initializers, but these variables go in BSS so we won't be called
402 #ifdef SELECT_SECTION
403 SELECT_SECTION (decl, reloc);
405 if (TREE_READONLY (decl)
406 && ! TREE_THIS_VOLATILE (decl)
407 && DECL_INITIAL (decl)
408 && (DECL_INITIAL (decl) == error_mark_node
409 || TREE_CONSTANT (DECL_INITIAL (decl)))
410 && ! (flag_pic && reloc))
411 readonly_data_section ();
418 /* Create the rtl to represent a function, for a function definition.
419 DECL is a FUNCTION_DECL node which describes which function.
420 The rtl is stored into DECL. */
423 make_function_rtl (decl)
426 char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
430 if (DECL_RTL (decl) == 0)
431 DECL_RTL (decl) = bc_gen_rtx (name, 0, (struct bc_label *) 0);
433 /* Record that at least one function has been defined. */
434 function_defined = 1;
438 /* Rename a nested function to avoid conflicts. */
439 if (decl_function_context (decl) != 0
440 && DECL_INITIAL (decl) != 0
441 && DECL_RTL (decl) == 0)
445 name = IDENTIFIER_POINTER (DECL_NAME (decl));
446 ASM_FORMAT_PRIVATE_NAME (label, name, var_labelno);
447 name = obstack_copy0 (saveable_obstack, label, strlen (label));
451 if (DECL_RTL (decl) == 0)
454 = gen_rtx (MEM, DECL_MODE (decl),
455 gen_rtx (SYMBOL_REF, Pmode, name));
457 /* Optionally set flags or add text to the name to record information
458 such as that it is a function name. If the name is changed, the macro
459 ASM_OUTPUT_LABELREF will have to know how to strip this information. */
460 #ifdef ENCODE_SECTION_INFO
461 ENCODE_SECTION_INFO (decl);
465 /* Record at least one function has been defined. */
466 function_defined = 1;
469 /* Create the DECL_RTL for a declaration for a static or external
470 variable or static or external function.
471 ASMSPEC, if not 0, is the string which the user specified
472 as the assembler symbol name.
473 TOP_LEVEL is nonzero if this is a file-scope variable.
474 This is never called for PARM_DECLs. */
477 bc_make_decl_rtl (decl, asmspec, top_level)
482 register char *name = TREE_STRING_POINTER (DECL_ASSEMBLER_NAME (decl));
484 if (DECL_RTL (decl) == 0)
486 /* Print an error message for register variables. */
487 if (DECL_REGISTER (decl))
488 error ("global register variables not supported in the interpreter");
490 /* Handle ordinary static variables and functions. */
491 if (DECL_RTL (decl) == 0)
493 /* Can't use just the variable's own name for a variable
494 whose scope is less than the whole file.
495 Concatenate a distinguishing number. */
496 if (!top_level && !DECL_EXTERNAL (decl) && asmspec == 0)
500 ASM_FORMAT_PRIVATE_NAME (label, name, var_labelno);
501 name = obstack_copy0 (saveable_obstack, label, strlen (label));
505 DECL_RTL (decl) = bc_gen_rtx (name, 0, (struct bc_label *) 0);
510 /* Given NAME, a putative register name, discard any customary prefixes. */
513 strip_reg_name (name)
516 #ifdef REGISTER_PREFIX
517 if (!strncmp (name, REGISTER_PREFIX, strlen (REGISTER_PREFIX)))
518 name += strlen (REGISTER_PREFIX);
520 if (name[0] == '%' || name[0] == '#')
525 /* Decode an `asm' spec for a declaration as a register name.
526 Return the register number, or -1 if nothing specified,
527 or -2 if the ASMSPEC is not `cc' or `memory' and is not recognized,
528 or -3 if ASMSPEC is `cc' and is not recognized,
529 or -4 if ASMSPEC is `memory' and is not recognized.
530 Accept an exact spelling or a decimal number.
531 Prefixes such as % are optional. */
534 decode_reg_name (asmspec)
541 /* Get rid of confusing prefixes. */
542 asmspec = strip_reg_name (asmspec);
544 /* Allow a decimal number as a "register name". */
545 for (i = strlen (asmspec) - 1; i >= 0; i--)
546 if (! (asmspec[i] >= '0' && asmspec[i] <= '9'))
548 if (asmspec[0] != 0 && i < 0)
551 if (i < FIRST_PSEUDO_REGISTER && i >= 0)
557 for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
559 && ! strcmp (asmspec, strip_reg_name (reg_names[i])))
562 #ifdef ADDITIONAL_REGISTER_NAMES
564 static struct { char *name; int number; } table[]
565 = ADDITIONAL_REGISTER_NAMES;
567 for (i = 0; i < sizeof (table) / sizeof (table[0]); i++)
568 if (! strcmp (asmspec, table[i].name))
569 return table[i].number;
571 #endif /* ADDITIONAL_REGISTER_NAMES */
573 if (!strcmp (asmspec, "memory"))
576 if (!strcmp (asmspec, "cc"))
585 /* Create the DECL_RTL for a declaration for a static or external variable
586 or static or external function.
587 ASMSPEC, if not 0, is the string which the user specified
588 as the assembler symbol name.
589 TOP_LEVEL is nonzero if this is a file-scope variable.
591 This is never called for PARM_DECL nodes. */
594 make_decl_rtl (decl, asmspec, top_level)
599 register char *name = 0;
604 bc_make_decl_rtl (decl, asmspec, top_level);
608 reg_number = decode_reg_name (asmspec);
610 if (DECL_ASSEMBLER_NAME (decl) != NULL_TREE)
611 name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
613 if (reg_number == -2)
615 /* ASMSPEC is given, and not the name of a register. */
616 name = (char *) obstack_alloc (saveable_obstack,
617 strlen (asmspec) + 2);
619 strcpy (&name[1], asmspec);
622 /* For a duplicate declaration, we can be called twice on the
623 same DECL node. Don't discard the RTL already made. */
624 if (DECL_RTL (decl) == 0)
628 /* First detect errors in declaring global registers. */
629 if (TREE_CODE (decl) != FUNCTION_DECL
630 && DECL_REGISTER (decl) && reg_number == -1)
631 error_with_decl (decl,
632 "register name not specified for `%s'");
633 else if (TREE_CODE (decl) != FUNCTION_DECL
634 && DECL_REGISTER (decl) && reg_number < 0)
635 error_with_decl (decl,
636 "invalid register name for `%s'");
637 else if ((reg_number >= 0 || reg_number == -3)
638 && (TREE_CODE (decl) == FUNCTION_DECL
639 && ! DECL_REGISTER (decl)))
640 error_with_decl (decl,
641 "register name given for non-register variable `%s'");
642 else if (TREE_CODE (decl) != FUNCTION_DECL
643 && DECL_REGISTER (decl)
644 && TYPE_MODE (TREE_TYPE (decl)) == BLKmode)
645 error_with_decl (decl,
646 "data type of `%s' isn't suitable for a register");
647 else if (TREE_CODE (decl) != FUNCTION_DECL && DECL_REGISTER (decl)
648 && ! HARD_REGNO_MODE_OK (reg_number,
649 TYPE_MODE (TREE_TYPE (decl))))
650 error_with_decl (decl,
651 "register number for `%s' isn't suitable for data type");
652 /* Now handle properly declared static register variables. */
653 else if (TREE_CODE (decl) != FUNCTION_DECL && DECL_REGISTER (decl))
657 if (DECL_INITIAL (decl) != 0 && top_level)
659 DECL_INITIAL (decl) = 0;
660 error ("global register variable has initial value");
662 if (fixed_regs[reg_number] == 0
663 && function_defined && top_level)
664 error ("global register variable follows a function definition");
665 if (TREE_THIS_VOLATILE (decl))
666 warning ("volatile register variables don't work as you might wish");
668 /* If the user specified one of the eliminables registers here,
669 e.g., FRAME_POINTER_REGNUM, we don't want to get this variable
670 confused with that register and be eliminated. Although this
671 usage is somewhat suspect, we nevertheless use the following
672 kludge to avoid setting DECL_RTL to frame_pointer_rtx. */
675 = gen_rtx (REG, DECL_MODE (decl), FIRST_PSEUDO_REGISTER);
676 REGNO (DECL_RTL (decl)) = reg_number;
677 REG_USERVAR_P (DECL_RTL (decl)) = 1;
681 /* Make this register global, so not usable for anything
683 nregs = HARD_REGNO_NREGS (reg_number, DECL_MODE (decl));
685 globalize_reg (reg_number + --nregs);
688 /* Specifying a section attribute on an uninitialized variable does not
689 (and cannot) cause it to be put in the given section. The linker
690 can only put initialized objects in specific sections, everything
691 else goes in bss for the linker to sort out later (otherwise the
692 linker would give a duplicate definition error for each compilation
693 unit that behaved thusly). So warn the user. */
694 else if (TREE_CODE (decl) == VAR_DECL
695 && DECL_SECTION_NAME (decl) != NULL_TREE
696 && DECL_INITIAL (decl) == NULL_TREE
697 && DECL_COMMON (decl))
699 warning_with_decl (decl,
700 "section attribute ignored for uninitialized variable `%s'");
701 /* Remove the section name so subsequent declarations won't see it.
702 We are ignoring it, remember. */
703 DECL_SECTION_NAME (decl) = NULL_TREE;
706 /* Now handle ordinary static variables and functions (in memory).
707 Also handle vars declared register invalidly. */
708 if (DECL_RTL (decl) == 0)
710 /* Can't use just the variable's own name for a variable
711 whose scope is less than the whole file.
712 Concatenate a distinguishing number. */
713 if (!top_level && !DECL_EXTERNAL (decl) && asmspec == 0)
717 ASM_FORMAT_PRIVATE_NAME (label, name, var_labelno);
718 name = obstack_copy0 (saveable_obstack, label, strlen (label));
725 DECL_RTL (decl) = gen_rtx (MEM, DECL_MODE (decl),
726 gen_rtx (SYMBOL_REF, Pmode, name));
727 DECL_ASSEMBLER_NAME (decl) = get_identifier (name);
729 /* If this variable is to be treated as volatile, show its
730 tree node has side effects. If it has side effects, either
731 because of this test or from TREE_THIS_VOLATILE also
732 being set, show the MEM is volatile. */
733 if (flag_volatile_global && TREE_CODE (decl) == VAR_DECL
734 && TREE_PUBLIC (decl))
735 TREE_SIDE_EFFECTS (decl) = 1;
736 if (TREE_SIDE_EFFECTS (decl))
737 MEM_VOLATILE_P (DECL_RTL (decl)) = 1;
739 if (TREE_READONLY (decl))
740 RTX_UNCHANGING_P (DECL_RTL (decl)) = 1;
741 MEM_IN_STRUCT_P (DECL_RTL (decl))
742 = AGGREGATE_TYPE_P (TREE_TYPE (decl));
744 /* Optionally set flags or add text to the name to record information
745 such as that it is a function name.
746 If the name is changed, the macro ASM_OUTPUT_LABELREF
747 will have to know how to strip this information. */
748 #ifdef ENCODE_SECTION_INFO
749 ENCODE_SECTION_INFO (decl);
753 /* If the old RTL had the wrong mode, fix the mode. */
754 else if (GET_MODE (DECL_RTL (decl)) != DECL_MODE (decl))
756 rtx rtl = DECL_RTL (decl);
757 PUT_MODE (rtl, DECL_MODE (decl));
761 /* Make the rtl for variable VAR be volatile.
762 Use this only for static variables. */
765 make_var_volatile (var)
768 if (GET_CODE (DECL_RTL (var)) != MEM)
771 MEM_VOLATILE_P (DECL_RTL (var)) = 1;
774 /* Output alignment directive to align for constant expression EXP. */
777 assemble_constant_align (exp)
782 /* Align the location counter as required by EXP's data type. */
783 align = TYPE_ALIGN (TREE_TYPE (exp));
784 #ifdef CONSTANT_ALIGNMENT
785 align = CONSTANT_ALIGNMENT (exp, align);
788 if (align > BITS_PER_UNIT)
789 ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT));
792 /* Output a string of literal assembler code
793 for an `asm' keyword used between functions. */
796 assemble_asm (string)
801 error ("asm statements not allowed in interpreter");
807 if (TREE_CODE (string) == ADDR_EXPR)
808 string = TREE_OPERAND (string, 0);
810 fprintf (asm_out_file, "\t%s\n", TREE_STRING_POINTER (string));
813 #if 0 /* This should no longer be needed, because
814 flag_gnu_linker should be 0 on these systems,
815 which should prevent any output
816 if ASM_OUTPUT_CONSTRUCTOR and ASM_OUTPUT_DESTRUCTOR are absent. */
817 #if !(defined(DBX_DEBUGGING_INFO) && !defined(FASCIST_ASSEMBLER))
818 #ifndef ASM_OUTPUT_CONSTRUCTOR
819 #define ASM_OUTPUT_CONSTRUCTOR(file, name)
821 #ifndef ASM_OUTPUT_DESTRUCTOR
822 #define ASM_OUTPUT_DESTRUCTOR(file, name)
827 /* Record an element in the table of global destructors.
828 How this is done depends on what sort of assembler and linker
831 NAME should be the name of a global function to be called
832 at exit time. This name is output using assemble_name. */
835 assemble_destructor (name)
838 #ifdef ASM_OUTPUT_DESTRUCTOR
839 ASM_OUTPUT_DESTRUCTOR (asm_out_file, name);
843 /* Now tell GNU LD that this is part of the static destructor set. */
844 /* This code works for any machine provided you use GNU as/ld. */
845 fprintf (asm_out_file, "%s \"___DTOR_LIST__\",22,0,0,", ASM_STABS_OP);
846 assemble_name (asm_out_file, name);
847 fputc ('\n', asm_out_file);
852 /* Likewise for global constructors. */
855 assemble_constructor (name)
858 #ifdef ASM_OUTPUT_CONSTRUCTOR
859 ASM_OUTPUT_CONSTRUCTOR (asm_out_file, name);
863 /* Now tell GNU LD that this is part of the static constructor set. */
864 /* This code works for any machine provided you use GNU as/ld. */
865 fprintf (asm_out_file, "%s \"___CTOR_LIST__\",22,0,0,", ASM_STABS_OP);
866 assemble_name (asm_out_file, name);
867 fputc ('\n', asm_out_file);
872 /* Likewise for entries we want to record for garbage collection.
873 Garbage collection is still under development. */
876 assemble_gc_entry (name)
879 #ifdef ASM_OUTPUT_GC_ENTRY
880 ASM_OUTPUT_GC_ENTRY (asm_out_file, name);
884 /* Now tell GNU LD that this is part of the static constructor set. */
885 fprintf (asm_out_file, "%s \"___PTR_LIST__\",22,0,0,", ASM_STABS_OP);
886 assemble_name (asm_out_file, name);
887 fputc ('\n', asm_out_file);
892 /* Output assembler code for the constant pool of a function and associated
893 with defining the name of the function. DECL describes the function.
894 NAME is the function's name. For the constant pool, we use the current
895 constant pool data. */
898 assemble_start_function (decl, fnname)
904 /* The following code does not need preprocessing in the assembler. */
908 output_constant_pool (fnname, decl);
910 #ifdef ASM_OUTPUT_SECTION_NAME
911 /* If the function is to be put in its own section and it's not in a section
912 already, indicate so. */
913 if (flag_function_sections
914 && DECL_SECTION_NAME (decl) == NULL_TREE)
916 #ifdef UNIQUE_SECTION
917 DECL_SECTION_NAME(decl) = UNIQUE_SECTION (decl);
919 char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
920 /* Strip off any encoding in name. */
921 STRIP_NAME_ENCODING (name, name);
922 DECL_SECTION_NAME (decl) = build_string (strlen (name), name);
927 function_section (decl);
929 /* Tell assembler to move to target machine's alignment for functions. */
930 align = floor_log2 (FUNCTION_BOUNDARY / BITS_PER_UNIT);
934 BC_OUTPUT_ALIGN (asm_out_file, align);
936 ASM_OUTPUT_ALIGN (asm_out_file, align);
939 #ifdef ASM_OUTPUT_FUNCTION_PREFIX
940 ASM_OUTPUT_FUNCTION_PREFIX (asm_out_file, fnname);
943 #ifdef SDB_DEBUGGING_INFO
944 /* Output SDB definition of the function. */
945 if (write_symbols == SDB_DEBUG)
946 sdbout_mark_begin_function ();
949 #ifdef DBX_DEBUGGING_INFO
950 /* Output DBX definition of the function. */
951 if (write_symbols == DBX_DEBUG)
952 dbxout_begin_function (decl);
955 /* Make function name accessible from other files, if appropriate. */
957 if (TREE_PUBLIC (decl))
959 if (!first_global_object_name)
963 STRIP_NAME_ENCODING (p, fnname);
964 first_global_object_name = permalloc (strlen (p) + 1);
965 strcpy (first_global_object_name, p);
968 #ifdef ASM_WEAKEN_LABEL
969 if (DECL_WEAK (decl))
970 ASM_WEAKEN_LABEL (asm_out_file, fnname);
974 BC_GLOBALIZE_LABEL (asm_out_file, fnname);
976 ASM_GLOBALIZE_LABEL (asm_out_file, fnname);
979 /* Do any machine/system dependent processing of the function name */
981 BC_OUTPUT_LABEL (asm_out_file, fnname);
984 #ifdef ASM_DECLARE_FUNCTION_NAME
985 ASM_DECLARE_FUNCTION_NAME (asm_out_file, fnname, current_function_decl);
987 /* Standard thing is just output label for the function. */
988 ASM_OUTPUT_LABEL (asm_out_file, fnname);
989 #endif /* ASM_DECLARE_FUNCTION_NAME */
993 /* Output assembler code associated with defining the size of the
994 function. DECL describes the function. NAME is the function's name. */
997 assemble_end_function (decl, fnname)
1001 #ifdef ASM_DECLARE_FUNCTION_SIZE
1002 ASM_DECLARE_FUNCTION_SIZE (asm_out_file, fnname, decl);
1006 /* Assemble code to leave SIZE bytes of zeros. */
1009 assemble_zeros (size)
1012 if (output_bytecode)
1014 bc_emit_const_skip (size);
1018 #ifdef ASM_NO_SKIP_IN_TEXT
1019 /* The `space' pseudo in the text section outputs nop insns rather than 0s,
1020 so we must output 0s explicitly in the text section. */
1021 if (ASM_NO_SKIP_IN_TEXT && in_text_section ())
1025 for (i = 0; i < size - 20; i += 20)
1028 fprintf (asm_out_file,
1029 "%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);
1031 fprintf (asm_out_file,
1032 "\tbyte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n");
1038 fprintf (asm_out_file, "%s 0", ASM_BYTE_OP);
1040 fprintf (asm_out_file, "\tbyte 0");
1043 for (; i < size; i++)
1044 fprintf (asm_out_file, ",0");
1045 fprintf (asm_out_file, "\n");
1052 if (output_bytecode)
1053 BC_OUTPUT_SKIP (asm_out_file, size);
1055 ASM_OUTPUT_SKIP (asm_out_file, size);
1059 /* Assemble an alignment pseudo op for an ALIGN-bit boundary. */
1062 assemble_align (align)
1065 if (align > BITS_PER_UNIT)
1066 ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT));
1069 /* Assemble a string constant with the specified C string as contents. */
1072 assemble_string (p, size)
1080 if (output_bytecode)
1086 /* If the string is very long, split it up. */
1090 int thissize = size - pos;
1091 if (thissize > maximum)
1094 if (output_bytecode)
1095 bc_output_ascii (asm_out_file, p, thissize);
1098 ASM_OUTPUT_ASCII (asm_out_file, p, thissize);
1107 bc_output_ascii (file, p, size)
1112 BC_OUTPUT_ASCII (file, p, size);
1115 /* Assemble everything that is needed for a variable or function declaration.
1116 Not used for automatic variables, and not used for function definitions.
1117 Should not be called for variables of incomplete structure type.
1119 TOP_LEVEL is nonzero if this variable has file scope.
1120 AT_END is nonzero if this is the special handling, at end of compilation,
1121 to define things that have had only tentative definitions.
1122 DONT_OUTPUT_DATA if nonzero means don't actually output the
1123 initial value (that will be done by the caller). */
1126 assemble_variable (decl, top_level, at_end, dont_output_data)
1130 int dont_output_data;
1132 register char *name;
1136 enum in_section saved_in_section;
1138 last_assemble_variable_decl = 0;
1140 if (output_bytecode)
1143 if (GET_CODE (DECL_RTL (decl)) == REG)
1145 /* Do output symbol info for global register variables, but do nothing
1148 if (TREE_ASM_WRITTEN (decl))
1150 TREE_ASM_WRITTEN (decl) = 1;
1152 if (!output_bytecode)
1154 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
1155 /* File-scope global variables are output here. */
1156 if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
1158 dbxout_symbol (decl, 0);
1160 #ifdef SDB_DEBUGGING_INFO
1161 if (write_symbols == SDB_DEBUG && top_level
1162 /* Leave initialized global vars for end of compilation;
1163 see comment in compile_file. */
1164 && (TREE_PUBLIC (decl) == 0 || DECL_INITIAL (decl) == 0))
1165 sdbout_symbol (decl, 0);
1169 /* Don't output any DWARF debugging information for variables here.
1170 In the case of local variables, the information for them is output
1171 when we do our recursive traversal of the tree representation for
1172 the entire containing function. In the case of file-scope variables,
1173 we output information for all of them at the very end of compilation
1174 while we are doing our final traversal of the chain of file-scope
1180 /* Normally no need to say anything here for external references,
1181 since assemble_external is called by the language-specific code
1182 when a declaration is first seen. */
1184 if (DECL_EXTERNAL (decl))
1187 /* Output no assembler code for a function declaration.
1188 Only definitions of functions output anything. */
1190 if (TREE_CODE (decl) == FUNCTION_DECL)
1193 /* If type was incomplete when the variable was declared,
1194 see if it is complete now. */
1196 if (DECL_SIZE (decl) == 0)
1197 layout_decl (decl, 0);
1199 /* Still incomplete => don't allocate it; treat the tentative defn
1200 (which is what it must have been) as an `extern' reference. */
1202 if (!dont_output_data && DECL_SIZE (decl) == 0)
1204 error_with_file_and_line (DECL_SOURCE_FILE (decl),
1205 DECL_SOURCE_LINE (decl),
1206 "storage size of `%s' isn't known",
1207 IDENTIFIER_POINTER (DECL_NAME (decl)));
1208 TREE_ASM_WRITTEN (decl) = 1;
1212 /* The first declaration of a variable that comes through this function
1213 decides whether it is global (in C, has external linkage)
1214 or local (in C, has internal linkage). So do nothing more
1215 if this function has already run. */
1217 if (TREE_ASM_WRITTEN (decl))
1220 TREE_ASM_WRITTEN (decl) = 1;
1224 if (! dont_output_data)
1226 if (TREE_CODE (DECL_SIZE (decl)) != INTEGER_CST)
1229 /* This is better than explicit arithmetic, since it avoids overflow. */
1230 size_tree = size_binop (CEIL_DIV_EXPR,
1231 DECL_SIZE (decl), size_int (BITS_PER_UNIT));
1233 if (TREE_INT_CST_HIGH (size_tree) != 0)
1235 error_with_decl (decl, "size of variable `%s' is too large");
1240 name = XSTR (XEXP (DECL_RTL (decl), 0), 0);
1242 /* Handle uninitialized definitions. */
1244 if ((DECL_INITIAL (decl) == 0 || DECL_INITIAL (decl) == error_mark_node)
1245 /* If the target can't output uninitialized but not common global data
1246 in .bss, then we have to use .data. */
1247 #if ! defined (ASM_OUTPUT_BSS) && ! defined (ASM_OUTPUT_ALIGNED_BSS)
1248 && DECL_COMMON (decl)
1250 && ! dont_output_data)
1252 int size = TREE_INT_CST_LOW (size_tree);
1255 /* Don't allocate zero bytes of common,
1256 since that means "undefined external" in the linker. */
1257 if (size == 0) rounded = 1;
1258 /* Round size up to multiple of BIGGEST_ALIGNMENT bits
1259 so that each uninitialized object starts on such a boundary. */
1260 rounded += (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - 1;
1261 rounded = (rounded / (BIGGEST_ALIGNMENT / BITS_PER_UNIT)
1262 * (BIGGEST_ALIGNMENT / BITS_PER_UNIT));
1264 #ifdef DBX_DEBUGGING_INFO
1265 /* File-scope global variables are output here. */
1266 if (write_symbols == DBX_DEBUG && top_level)
1267 dbxout_symbol (decl, 0);
1269 #ifdef SDB_DEBUGGING_INFO
1270 if (write_symbols == SDB_DEBUG && top_level
1271 /* Leave initialized global vars for end of compilation;
1272 see comment in compile_file. */
1273 && (TREE_PUBLIC (decl) == 0 || DECL_INITIAL (decl) == 0))
1274 sdbout_symbol (decl, 0);
1277 /* Don't output any DWARF debugging information for variables here.
1278 In the case of local variables, the information for them is output
1279 when we do our recursive traversal of the tree representation for
1280 the entire containing function. In the case of file-scope variables,
1281 we output information for all of them at the very end of compilation
1282 while we are doing our final traversal of the chain of file-scope
1285 #if 0 /* ??? We should either delete this or add a comment describing what
1286 it was intended to do and why we shouldn't delete it. */
1287 if (flag_shared_data)
1291 if (TREE_PUBLIC (decl)
1292 #if defined (ASM_OUTPUT_BSS) || defined (ASM_OUTPUT_ALIGNED_BSS)
1293 && DECL_COMMON (decl)
1297 #ifdef ASM_OUTPUT_SHARED_COMMON
1298 if (flag_shared_data)
1299 ASM_OUTPUT_SHARED_COMMON (asm_out_file, name, size, rounded);
1302 if (output_bytecode)
1304 BC_OUTPUT_COMMON (asm_out_file, name, size, rounded);
1308 #ifdef ASM_OUTPUT_ALIGNED_COMMON
1309 ASM_OUTPUT_ALIGNED_COMMON (asm_out_file, name, size,
1312 ASM_OUTPUT_COMMON (asm_out_file, name, size, rounded);
1316 #if defined (ASM_OUTPUT_BSS) || defined (ASM_OUTPUT_ALIGNED_BSS)
1317 else if (TREE_PUBLIC (decl))
1319 #ifdef ASM_OUTPUT_SHARED_BSS
1320 if (flag_shared_data)
1321 ASM_OUTPUT_SHARED_BSS (asm_out_file, decl, name, size, rounded);
1324 if (output_bytecode)
1326 BC_OUTPUT_BSS (asm_out_file, name, size, rounded);
1330 #ifdef ASM_OUTPUT_ALIGNED_BSS
1331 ASM_OUTPUT_ALIGNED_BSS (asm_out_file, decl, name, size,
1334 ASM_OUTPUT_BSS (asm_out_file, decl, name, size, rounded);
1338 #endif /* ASM_OUTPUT_BSS || ASM_OUTPUT_ALIGNED_BSS */
1341 #ifdef ASM_OUTPUT_SHARED_LOCAL
1342 if (flag_shared_data)
1343 ASM_OUTPUT_SHARED_LOCAL (asm_out_file, name, size, rounded);
1346 if (output_bytecode)
1348 BC_OUTPUT_LOCAL (asm_out_file, name, size, rounded);
1352 #ifdef ASM_OUTPUT_ALIGNED_LOCAL
1353 ASM_OUTPUT_ALIGNED_LOCAL (asm_out_file, name, size,
1356 ASM_OUTPUT_LOCAL (asm_out_file, name, size, rounded);
1363 /* Handle initialized definitions.
1364 Also handle uninitialized global definitions if -fno-common and the
1365 target doesn't support ASM_OUTPUT_BSS. */
1367 /* First make the assembler name(s) global if appropriate. */
1368 if (TREE_PUBLIC (decl) && DECL_NAME (decl))
1370 if (!first_global_object_name)
1374 STRIP_NAME_ENCODING (p, name);
1375 first_global_object_name = permalloc (strlen (p) + 1);
1376 strcpy (first_global_object_name, p);
1379 #ifdef ASM_WEAKEN_LABEL
1380 if (DECL_WEAK (decl))
1381 ASM_WEAKEN_LABEL (asm_out_file, name);
1384 ASM_GLOBALIZE_LABEL (asm_out_file, name);
1387 for (d = equivalents; d; d = TREE_CHAIN (d))
1389 tree e = TREE_VALUE (d);
1390 if (TREE_PUBLIC (e) && DECL_NAME (e))
1391 ASM_GLOBALIZE_LABEL (asm_out_file,
1392 XSTR (XEXP (DECL_RTL (e), 0), 0));
1396 /* Output any data that we will need to use the address of. */
1397 if (DECL_INITIAL (decl) == error_mark_node)
1398 reloc = contains_pointers_p (TREE_TYPE (decl));
1399 else if (DECL_INITIAL (decl))
1400 reloc = output_addressed_constants (DECL_INITIAL (decl));
1402 /* Switch to the appropriate section. */
1403 variable_section (decl, reloc);
1405 /* dbxout.c needs to know this. */
1406 if (in_text_section ())
1407 DECL_IN_TEXT_SECTION (decl) = 1;
1409 /* Record current section so we can restore it if dbxout.c clobbers it. */
1410 saved_in_section = in_section;
1412 /* Output the dbx info now that we have chosen the section. */
1414 #ifdef DBX_DEBUGGING_INFO
1415 /* File-scope global variables are output here. */
1416 if (write_symbols == DBX_DEBUG && top_level)
1417 dbxout_symbol (decl, 0);
1419 #ifdef SDB_DEBUGGING_INFO
1420 if (write_symbols == SDB_DEBUG && top_level
1421 /* Leave initialized global vars for end of compilation;
1422 see comment in compile_file. */
1423 && (TREE_PUBLIC (decl) == 0 || DECL_INITIAL (decl) == 0))
1424 sdbout_symbol (decl, 0);
1427 /* Don't output any DWARF debugging information for variables here.
1428 In the case of local variables, the information for them is output
1429 when we do our recursive traversal of the tree representation for
1430 the entire containing function. In the case of file-scope variables,
1431 we output information for all of them at the very end of compilation
1432 while we are doing our final traversal of the chain of file-scope
1435 /* If the debugging output changed sections, reselect the section
1436 that's supposed to be selected. */
1437 if (in_section != saved_in_section)
1438 variable_section (decl, reloc);
1440 /* Compute and output the alignment of this data. */
1442 align = DECL_ALIGN (decl);
1443 /* In the case for initialing an array whose length isn't specified,
1444 where we have not yet been able to do the layout,
1445 figure out the proper alignment now. */
1446 if (dont_output_data && DECL_SIZE (decl) == 0
1447 && TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE)
1448 align = MAX (align, TYPE_ALIGN (TREE_TYPE (TREE_TYPE (decl))));
1450 /* Some object file formats have a maximum alignment which they support.
1451 In particular, a.out format supports a maximum alignment of 4. */
1452 #ifndef MAX_OFILE_ALIGNMENT
1453 #define MAX_OFILE_ALIGNMENT BIGGEST_ALIGNMENT
1455 if (align > MAX_OFILE_ALIGNMENT)
1457 warning_with_decl (decl,
1458 "alignment of `%s' is greater than maximum object file alignment");
1459 align = MAX_OFILE_ALIGNMENT;
1461 #ifdef DATA_ALIGNMENT
1462 /* On some machines, it is good to increase alignment sometimes. */
1463 align = DATA_ALIGNMENT (TREE_TYPE (decl), align);
1465 #ifdef CONSTANT_ALIGNMENT
1466 if (DECL_INITIAL (decl))
1467 align = CONSTANT_ALIGNMENT (DECL_INITIAL (decl), align);
1470 /* Reset the alignment in case we have made it tighter, so we can benefit
1471 from it in get_pointer_alignment. */
1472 DECL_ALIGN (decl) = align;
1474 if (align > BITS_PER_UNIT)
1476 if (output_bytecode)
1477 BC_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT));
1479 ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT));
1482 /* Do any machine/system dependent processing of the object. */
1483 if (output_bytecode)
1484 BC_OUTPUT_LABEL (asm_out_file, name);
1487 #ifdef ASM_DECLARE_OBJECT_NAME
1488 last_assemble_variable_decl = decl;
1489 ASM_DECLARE_OBJECT_NAME (asm_out_file, name, decl);
1491 /* Standard thing is just output label for the object. */
1492 ASM_OUTPUT_LABEL (asm_out_file, name);
1493 #endif /* ASM_DECLARE_OBJECT_NAME */
1496 if (!dont_output_data)
1498 if (DECL_INITIAL (decl))
1499 /* Output the actual data. */
1500 output_constant (DECL_INITIAL (decl), TREE_INT_CST_LOW (size_tree));
1502 /* Leave space for it. */
1503 assemble_zeros (TREE_INT_CST_LOW (size_tree));
1507 #ifdef XCOFF_DEBUGGING_INFO
1508 /* Unfortunately, the IBM assembler cannot handle stabx before the actual
1509 declaration. When something like ".stabx "aa:S-2",aa,133,0" is emitted
1510 and `aa' hasn't been output yet, the assembler generates a stab entry with
1511 a value of zero, in addition to creating an unnecessary external entry
1512 for `aa'. Hence, we must postpone dbxout_symbol to here at the end. */
1514 /* File-scope global variables are output here. */
1515 if (write_symbols == XCOFF_DEBUG && top_level)
1517 saved_in_section = in_section;
1519 dbxout_symbol (decl, 0);
1521 if (in_section != saved_in_section)
1522 variable_section (decl, reloc);
1525 /* There must be a statement after a label. */
1530 /* Return 1 if type TYPE contains any pointers. */
1533 contains_pointers_p (type)
1536 switch (TREE_CODE (type))
1539 case REFERENCE_TYPE:
1540 /* I'm not sure whether OFFSET_TYPE needs this treatment,
1541 so I'll play safe and return 1. */
1547 case QUAL_UNION_TYPE:
1550 /* For a type that has fields, see if the fields have pointers. */
1551 for (fields = TYPE_FIELDS (type); fields; fields = TREE_CHAIN (fields))
1552 if (TREE_CODE (fields) == FIELD_DECL
1553 && contains_pointers_p (TREE_TYPE (fields)))
1559 /* An array type contains pointers if its element type does. */
1560 return contains_pointers_p (TREE_TYPE (type));
1567 /* Output text storage for constructor CONSTR. */
1570 bc_output_constructor (constr, size)
1576 /* Must always be a literal; non-literal constructors are handled
1579 if (!TREE_CONSTANT (constr))
1586 for (i = 0; TYPE_ALIGN (constr) >= BITS_PER_UNIT << (i + 1); i++)
1590 BC_OUTPUT_ALIGN (asm_out_file, i);
1593 output_constant (constr, size);
1596 /* Create storage for constructor CONSTR. */
1599 bc_output_data_constructor (constr)
1604 /* Put in data section */
1608 for (i = 0; TYPE_ALIGN (constr) >= BITS_PER_UNIT << (i + 1); i++);
1610 BC_OUTPUT_ALIGN (asm_out_file, i);
1612 /* The constructor is filled in at runtime. */
1613 BC_OUTPUT_SKIP (asm_out_file, int_size_in_bytes (TREE_TYPE (constr)));
1616 /* Output something to declare an external symbol to the assembler.
1617 (Most assemblers don't need this, so we normally output nothing.)
1618 Do nothing if DECL is not external. */
1621 assemble_external (decl)
1624 if (output_bytecode)
1627 #ifdef ASM_OUTPUT_EXTERNAL
1628 if (TREE_CODE_CLASS (TREE_CODE (decl)) == 'd'
1629 && DECL_EXTERNAL (decl) && TREE_PUBLIC (decl))
1631 rtx rtl = DECL_RTL (decl);
1633 if (GET_CODE (rtl) == MEM && GET_CODE (XEXP (rtl, 0)) == SYMBOL_REF
1634 && ! SYMBOL_REF_USED (XEXP (rtl, 0)))
1636 /* Some systems do require some output. */
1637 SYMBOL_REF_USED (XEXP (rtl, 0)) = 1;
1638 ASM_OUTPUT_EXTERNAL (asm_out_file, decl, XSTR (XEXP (rtl, 0), 0));
1644 /* Similar, for calling a library function FUN. */
1647 assemble_external_libcall (fun)
1650 #ifdef ASM_OUTPUT_EXTERNAL_LIBCALL
1651 if (!output_bytecode)
1653 /* Declare library function name external when first used, if nec. */
1654 if (! SYMBOL_REF_USED (fun))
1656 SYMBOL_REF_USED (fun) = 1;
1657 ASM_OUTPUT_EXTERNAL_LIBCALL (asm_out_file, fun);
1663 /* Declare the label NAME global. */
1666 assemble_global (name)
1669 ASM_GLOBALIZE_LABEL (asm_out_file, name);
1672 /* Assemble a label named NAME. */
1675 assemble_label (name)
1678 if (output_bytecode)
1679 BC_OUTPUT_LABEL (asm_out_file, name);
1681 ASM_OUTPUT_LABEL (asm_out_file, name);
1684 /* Output to FILE a reference to the assembler name of a C-level name NAME.
1685 If NAME starts with a *, the rest of NAME is output verbatim.
1686 Otherwise NAME is transformed in an implementation-defined way
1687 (usually by the addition of an underscore).
1688 Many macros in the tm file are defined to call this function. */
1691 assemble_name (file, name)
1696 int save_warn_id_clash = warn_id_clash;
1698 STRIP_NAME_ENCODING (real_name, name);
1700 /* Don't warn about an identifier name length clash on this name, since
1701 it can be a user symbol suffixed by a number. */
1703 TREE_SYMBOL_REFERENCED (get_identifier (real_name)) = 1;
1704 warn_id_clash = save_warn_id_clash;
1708 if (output_bytecode)
1709 bc_emit_labelref (name, 0);
1711 fputs (&name[1], file);
1715 if (output_bytecode)
1716 BC_OUTPUT_LABELREF (file, name);
1718 ASM_OUTPUT_LABELREF (file, name);
1722 /* Allocate SIZE bytes writable static space with a gensym name
1723 and return an RTX to refer to its address. */
1726 assemble_static_space (size)
1732 /* Round size up to multiple of BIGGEST_ALIGNMENT bits
1733 so that each uninitialized object starts on such a boundary. */
1734 int rounded = ((size + (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - 1)
1735 / (BIGGEST_ALIGNMENT / BITS_PER_UNIT)
1736 * (BIGGEST_ALIGNMENT / BITS_PER_UNIT));
1739 if (flag_shared_data)
1743 ASM_GENERATE_INTERNAL_LABEL (name, "LF", const_labelno);
1746 namestring = (char *) obstack_alloc (saveable_obstack,
1748 strcpy (namestring, name);
1750 if (output_bytecode)
1751 x = bc_gen_rtx (namestring, 0, (struct bc_label *) 0);
1753 x = gen_rtx (SYMBOL_REF, Pmode, namestring);
1755 if (output_bytecode)
1757 BC_OUTPUT_LOCAL (asm_out_file, name, size, rounded);
1761 #ifdef ASM_OUTPUT_ALIGNED_LOCAL
1762 ASM_OUTPUT_ALIGNED_LOCAL (asm_out_file, name, size, BIGGEST_ALIGNMENT);
1764 ASM_OUTPUT_LOCAL (asm_out_file, name, size, rounded);
1770 /* Assemble the static constant template for function entry trampolines.
1771 This is done at most once per compilation.
1772 Returns an RTX for the address of the template. */
1774 #ifdef TRAMPOLINE_TEMPLATE
1776 assemble_trampoline_template ()
1782 /* Shouldn't get here */
1783 if (output_bytecode)
1786 /* By default, put trampoline templates in read-only data section. */
1788 #ifdef TRAMPOLINE_SECTION
1789 TRAMPOLINE_SECTION ();
1791 readonly_data_section ();
1794 /* Write the assembler code to define one. */
1795 align = floor_log2 (FUNCTION_BOUNDARY / BITS_PER_UNIT);
1797 ASM_OUTPUT_ALIGN (asm_out_file, align);
1799 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LTRAMP", 0);
1800 TRAMPOLINE_TEMPLATE (asm_out_file);
1802 /* Record the rtl to refer to it. */
1803 ASM_GENERATE_INTERNAL_LABEL (label, "LTRAMP", 0);
1805 = (char *) obstack_copy0 (&permanent_obstack, label, strlen (label));
1806 return gen_rtx (SYMBOL_REF, Pmode, name);
1810 /* Assemble the integer constant X into an object of SIZE bytes.
1811 X must be either a CONST_INT or CONST_DOUBLE.
1813 Return 1 if we were able to output the constant, otherwise 0. If FORCE is
1814 non-zero, abort if we can't output the constant. */
1817 assemble_integer (x, size, force)
1822 /* First try to use the standard 1, 2, 4, 8, and 16 byte
1823 ASM_OUTPUT... macros. */
1827 #ifdef ASM_OUTPUT_CHAR
1829 ASM_OUTPUT_CHAR (asm_out_file, x);
1833 #ifdef ASM_OUTPUT_SHORT
1835 ASM_OUTPUT_SHORT (asm_out_file, x);
1839 #ifdef ASM_OUTPUT_INT
1841 ASM_OUTPUT_INT (asm_out_file, x);
1845 #ifdef ASM_OUTPUT_DOUBLE_INT
1847 ASM_OUTPUT_DOUBLE_INT (asm_out_file, x);
1851 #ifdef ASM_OUTPUT_QUADRUPLE_INT
1853 ASM_OUTPUT_QUADRUPLE_INT (asm_out_file, x);
1858 /* If we couldn't do it that way, there are two other possibilities: First,
1859 if the machine can output an explicit byte and this is a 1 byte constant,
1860 we can use ASM_OUTPUT_BYTE. */
1862 #ifdef ASM_OUTPUT_BYTE
1863 if (size == 1 && GET_CODE (x) == CONST_INT)
1865 ASM_OUTPUT_BYTE (asm_out_file, INTVAL (x));
1870 /* Finally, if SIZE is larger than a single word, try to output the constant
1871 one word at a time. */
1873 if (size > UNITS_PER_WORD)
1876 enum machine_mode mode
1877 = mode_for_size (size * BITS_PER_UNIT, MODE_INT, 0);
1880 for (i = 0; i < size / UNITS_PER_WORD; i++)
1882 word = operand_subword (x, i, 0, mode);
1887 if (! assemble_integer (word, UNITS_PER_WORD, 0))
1891 if (i == size / UNITS_PER_WORD)
1893 /* If we output at least one word and then could not finish,
1894 there is no valid way to continue. */
1905 /* Assemble the floating-point constant D into an object of size MODE. */
1908 assemble_real (d, mode)
1910 enum machine_mode mode;
1912 jmp_buf output_constant_handler;
1914 if (setjmp (output_constant_handler))
1916 error ("floating point trap outputting a constant");
1917 #ifdef REAL_IS_NOT_DOUBLE
1918 bzero ((char *) &d, sizeof d);
1925 set_float_handler (output_constant_handler);
1929 #ifdef ASM_OUTPUT_BYTE_FLOAT
1931 ASM_OUTPUT_BYTE_FLOAT (asm_out_file, d);
1934 #ifdef ASM_OUTPUT_SHORT_FLOAT
1936 ASM_OUTPUT_SHORT_FLOAT (asm_out_file, d);
1939 #ifdef ASM_OUTPUT_THREE_QUARTER_FLOAT
1941 ASM_OUTPUT_THREE_QUARTER_FLOAT (asm_out_file, d);
1944 #ifdef ASM_OUTPUT_FLOAT
1946 ASM_OUTPUT_FLOAT (asm_out_file, d);
1950 #ifdef ASM_OUTPUT_DOUBLE
1952 ASM_OUTPUT_DOUBLE (asm_out_file, d);
1956 #ifdef ASM_OUTPUT_LONG_DOUBLE
1959 ASM_OUTPUT_LONG_DOUBLE (asm_out_file, d);
1967 set_float_handler (NULL_PTR);
1970 /* Here we combine duplicate floating constants to make
1971 CONST_DOUBLE rtx's, and force those out to memory when necessary. */
1973 /* Chain of all CONST_DOUBLE rtx's constructed for the current function.
1974 They are chained through the CONST_DOUBLE_CHAIN.
1975 A CONST_DOUBLE rtx has CONST_DOUBLE_MEM != cc0_rtx iff it is on this chain.
1976 In that case, CONST_DOUBLE_MEM is either a MEM,
1977 or const0_rtx if no MEM has been made for this CONST_DOUBLE yet.
1979 (CONST_DOUBLE_MEM is used only for top-level functions.
1980 See force_const_mem for explanation.) */
1982 static rtx const_double_chain;
1984 /* Return a CONST_DOUBLE or CONST_INT for a value specified as a pair of ints.
1985 For an integer, I0 is the low-order word and I1 is the high-order word.
1986 For a real number, I0 is the word with the low address
1987 and I1 is the word with the high address. */
1990 immed_double_const (i0, i1, mode)
1991 HOST_WIDE_INT i0, i1;
1992 enum machine_mode mode;
1995 int in_current_obstack;
1997 if (GET_MODE_CLASS (mode) == MODE_INT
1998 || GET_MODE_CLASS (mode) == MODE_PARTIAL_INT)
2000 /* We clear out all bits that don't belong in MODE, unless they and our
2001 sign bit are all one. So we get either a reasonable negative value
2002 or a reasonable unsigned value for this mode. */
2003 int width = GET_MODE_BITSIZE (mode);
2004 if (width < HOST_BITS_PER_WIDE_INT
2005 && ((i0 & ((HOST_WIDE_INT) (-1) << (width - 1)))
2006 != ((HOST_WIDE_INT) (-1) << (width - 1))))
2007 i0 &= ((HOST_WIDE_INT) 1 << width) - 1, i1 = 0;
2008 else if (width == HOST_BITS_PER_WIDE_INT
2009 && ! (i1 == ~0 && i0 < 0))
2011 else if (width > 2 * HOST_BITS_PER_WIDE_INT)
2012 /* We cannot represent this value as a constant. */
2015 /* If this would be an entire word for the target, but is not for
2016 the host, then sign-extend on the host so that the number will look
2017 the same way on the host that it would on the target.
2019 For example, when building a 64 bit alpha hosted 32 bit sparc
2020 targeted compiler, then we want the 32 bit unsigned value -1 to be
2021 represented as a 64 bit value -1, and not as 0x00000000ffffffff.
2022 The later confuses the sparc backend. */
2024 if (BITS_PER_WORD < HOST_BITS_PER_WIDE_INT && BITS_PER_WORD == width
2025 && (i0 & ((HOST_WIDE_INT) 1 << (width - 1))))
2026 i0 |= ((HOST_WIDE_INT) (-1) << width);
2028 /* If MODE fits within HOST_BITS_PER_WIDE_INT, always use a CONST_INT.
2030 ??? Strictly speaking, this is wrong if we create a CONST_INT
2031 for a large unsigned constant with the size of MODE being
2032 HOST_BITS_PER_WIDE_INT and later try to interpret that constant in a
2033 wider mode. In that case we will mis-interpret it as a negative
2036 Unfortunately, the only alternative is to make a CONST_DOUBLE
2037 for any constant in any mode if it is an unsigned constant larger
2038 than the maximum signed integer in an int on the host. However,
2039 doing this will break everyone that always expects to see a CONST_INT
2040 for SImode and smaller.
2042 We have always been making CONST_INTs in this case, so nothing new
2045 if (width <= HOST_BITS_PER_WIDE_INT)
2046 i1 = (i0 < 0) ? ~0 : 0;
2048 /* If this integer fits in one word, return a CONST_INT. */
2049 if ((i1 == 0 && i0 >= 0)
2050 || (i1 == ~0 && i0 < 0))
2051 return GEN_INT (i0);
2053 /* We use VOIDmode for integers. */
2057 /* Search the chain for an existing CONST_DOUBLE with the right value.
2058 If one is found, return it. */
2060 for (r = const_double_chain; r; r = CONST_DOUBLE_CHAIN (r))
2061 if (CONST_DOUBLE_LOW (r) == i0 && CONST_DOUBLE_HIGH (r) == i1
2062 && GET_MODE (r) == mode)
2065 /* No; make a new one and add it to the chain.
2067 We may be called by an optimizer which may be discarding any memory
2068 allocated during its processing (such as combine and loop). However,
2069 we will be leaving this constant on the chain, so we cannot tolerate
2070 freed memory. So switch to saveable_obstack for this allocation
2071 and then switch back if we were in current_obstack. */
2073 push_obstacks_nochange ();
2074 rtl_in_saveable_obstack ();
2075 r = gen_rtx (CONST_DOUBLE, mode, 0, i0, i1);
2078 /* Don't touch const_double_chain in nested function; see force_const_mem.
2079 Also, don't touch it if not inside any function. */
2080 if (outer_function_chain == 0 && current_function_decl != 0)
2082 CONST_DOUBLE_CHAIN (r) = const_double_chain;
2083 const_double_chain = r;
2086 /* Store const0_rtx in mem-slot since this CONST_DOUBLE is on the chain.
2087 Actual use of mem-slot is only through force_const_mem. */
2089 CONST_DOUBLE_MEM (r) = const0_rtx;
2094 /* Return a CONST_DOUBLE for a specified `double' value
2095 and machine mode. */
2098 immed_real_const_1 (d, mode)
2100 enum machine_mode mode;
2102 union real_extract u;
2104 int in_current_obstack;
2106 /* Get the desired `double' value as a sequence of ints
2107 since that is how they are stored in a CONST_DOUBLE. */
2111 /* Detect special cases. */
2113 /* Avoid REAL_VALUES_EQUAL here in order to distinguish minus zero. */
2114 if (!bcmp ((char *) &dconst0, (char *) &d, sizeof d))
2115 return CONST0_RTX (mode);
2116 /* Check for NaN first, because some ports (specifically the i386) do not
2117 emit correct ieee-fp code by default, and thus will generate a core
2118 dump here if we pass a NaN to REAL_VALUES_EQUAL and if REAL_VALUES_EQUAL
2119 does a floating point comparison. */
2120 else if (! REAL_VALUE_ISNAN (d) && REAL_VALUES_EQUAL (dconst1, d))
2121 return CONST1_RTX (mode);
2123 if (sizeof u == 2 * sizeof (HOST_WIDE_INT))
2124 return immed_double_const (u.i[0], u.i[1], mode);
2126 /* The rest of this function handles the case where
2127 a float value requires more than 2 ints of space.
2128 It will be deleted as dead code on machines that don't need it. */
2130 /* Search the chain for an existing CONST_DOUBLE with the right value.
2131 If one is found, return it. */
2133 for (r = const_double_chain; r; r = CONST_DOUBLE_CHAIN (r))
2134 if (! bcmp ((char *) &CONST_DOUBLE_LOW (r), (char *) &u, sizeof u)
2135 && GET_MODE (r) == mode)
2138 /* No; make a new one and add it to the chain.
2140 We may be called by an optimizer which may be discarding any memory
2141 allocated during its processing (such as combine and loop). However,
2142 we will be leaving this constant on the chain, so we cannot tolerate
2143 freed memory. So switch to saveable_obstack for this allocation
2144 and then switch back if we were in current_obstack. */
2146 push_obstacks_nochange ();
2147 rtl_in_saveable_obstack ();
2148 r = rtx_alloc (CONST_DOUBLE);
2150 bcopy ((char *) &u, (char *) &CONST_DOUBLE_LOW (r), sizeof u);
2153 /* Don't touch const_double_chain in nested function; see force_const_mem.
2154 Also, don't touch it if not inside any function. */
2155 if (outer_function_chain == 0 && current_function_decl != 0)
2157 CONST_DOUBLE_CHAIN (r) = const_double_chain;
2158 const_double_chain = r;
2161 /* Store const0_rtx in CONST_DOUBLE_MEM since this CONST_DOUBLE is on the
2162 chain, but has not been allocated memory. Actual use of CONST_DOUBLE_MEM
2163 is only through force_const_mem. */
2165 CONST_DOUBLE_MEM (r) = const0_rtx;
2170 /* Return a CONST_DOUBLE rtx for a value specified by EXP,
2171 which must be a REAL_CST tree node. */
2174 immed_real_const (exp)
2177 return immed_real_const_1 (TREE_REAL_CST (exp), TYPE_MODE (TREE_TYPE (exp)));
2180 /* At the end of a function, forget the memory-constants
2181 previously made for CONST_DOUBLEs. Mark them as not on real_constant_chain.
2182 Also clear out real_constant_chain and clear out all the chain-pointers. */
2185 clear_const_double_mem ()
2187 register rtx r, next;
2189 /* Don't touch CONST_DOUBLE_MEM for nested functions.
2190 See force_const_mem for explanation. */
2191 if (outer_function_chain != 0)
2194 for (r = const_double_chain; r; r = next)
2196 next = CONST_DOUBLE_CHAIN (r);
2197 CONST_DOUBLE_CHAIN (r) = 0;
2198 CONST_DOUBLE_MEM (r) = cc0_rtx;
2200 const_double_chain = 0;
2203 /* Given an expression EXP with a constant value,
2204 reduce it to the sum of an assembler symbol and an integer.
2205 Store them both in the structure *VALUE.
2206 Abort if EXP does not reduce. */
2211 HOST_WIDE_INT offset;
2215 decode_addr_const (exp, value)
2217 struct addr_const *value;
2219 register tree target = TREE_OPERAND (exp, 0);
2220 register int offset = 0;
2225 if (TREE_CODE (target) == COMPONENT_REF
2226 && (TREE_CODE (DECL_FIELD_BITPOS (TREE_OPERAND (target, 1)))
2229 offset += TREE_INT_CST_LOW (DECL_FIELD_BITPOS (TREE_OPERAND (target, 1))) / BITS_PER_UNIT;
2230 target = TREE_OPERAND (target, 0);
2232 else if (TREE_CODE (target) == ARRAY_REF)
2234 if (TREE_CODE (TREE_OPERAND (target, 1)) != INTEGER_CST
2235 || TREE_CODE (TYPE_SIZE (TREE_TYPE (target))) != INTEGER_CST)
2237 offset += ((TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (target)))
2238 * TREE_INT_CST_LOW (TREE_OPERAND (target, 1)))
2240 target = TREE_OPERAND (target, 0);
2246 switch (TREE_CODE (target))
2250 x = DECL_RTL (target);
2254 if (output_bytecode)
2255 /* FIXME: this may not be correct, check it */
2256 x = bc_gen_rtx (TREE_STRING_POINTER (target), 0, (struct bc_label *) 0);
2258 x = gen_rtx (MEM, FUNCTION_MODE,
2259 gen_rtx (LABEL_REF, VOIDmode,
2260 label_rtx (TREE_OPERAND (exp, 0))));
2267 x = TREE_CST_RTL (target);
2274 if (!output_bytecode)
2276 if (GET_CODE (x) != MEM)
2282 value->offset = offset;
2285 /* Uniquize all constants that appear in memory.
2286 Each constant in memory thus far output is recorded
2287 in `const_hash_table' with a `struct constant_descriptor'
2288 that contains a polish representation of the value of
2291 We cannot store the trees in the hash table
2292 because the trees may be temporary. */
2294 struct constant_descriptor
2296 struct constant_descriptor *next;
2302 #define MAX_HASH_TABLE 1009
2303 static struct constant_descriptor *const_hash_table[MAX_HASH_TABLE];
2305 /* Compute a hash code for a constant expression. */
2312 register int len, hi, i;
2313 register enum tree_code code = TREE_CODE (exp);
2315 if (code == INTEGER_CST)
2317 p = (char *) &TREE_INT_CST_LOW (exp);
2318 len = 2 * sizeof TREE_INT_CST_LOW (exp);
2320 else if (code == REAL_CST)
2322 p = (char *) &TREE_REAL_CST (exp);
2323 len = sizeof TREE_REAL_CST (exp);
2325 else if (code == STRING_CST)
2326 p = TREE_STRING_POINTER (exp), len = TREE_STRING_LENGTH (exp);
2327 else if (code == COMPLEX_CST)
2328 return const_hash (TREE_REALPART (exp)) * 5
2329 + const_hash (TREE_IMAGPART (exp));
2330 else if (code == CONSTRUCTOR && TREE_CODE (TREE_TYPE (exp)) == SET_TYPE)
2332 len = int_size_in_bytes (TREE_TYPE (exp));
2333 p = (char*) alloca (len);
2334 get_set_constructor_bytes (exp, (unsigned char *) p, len);
2336 else if (code == CONSTRUCTOR)
2340 /* For record type, include the type in the hashing.
2341 We do not do so for array types
2342 because (1) the sizes of the elements are sufficient
2343 and (2) distinct array types can have the same constructor.
2344 Instead, we include the array size because the constructor could
2346 if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE)
2347 hi = ((HOST_WIDE_INT) TREE_TYPE (exp) & ((1 << HASHBITS) - 1))
2350 hi = ((5 + int_size_in_bytes (TREE_TYPE (exp)))
2351 & ((1 << HASHBITS) - 1)) % MAX_HASH_TABLE;
2353 for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link))
2354 if (TREE_VALUE (link))
2355 hi = (hi * 603 + const_hash (TREE_VALUE (link))) % MAX_HASH_TABLE;
2359 else if (code == ADDR_EXPR)
2361 struct addr_const value;
2362 decode_addr_const (exp, &value);
2363 if (GET_CODE (value.base) == SYMBOL_REF)
2365 /* Don't hash the address of the SYMBOL_REF;
2366 only use the offset and the symbol name. */
2368 p = XSTR (value.base, 0);
2369 for (i = 0; p[i] != 0; i++)
2370 hi = ((hi * 613) + (unsigned)(p[i]));
2372 else if (GET_CODE (value.base) == LABEL_REF)
2373 hi = value.offset + CODE_LABEL_NUMBER (XEXP (value.base, 0)) * 13;
2375 hi &= (1 << HASHBITS) - 1;
2376 hi %= MAX_HASH_TABLE;
2379 else if (code == PLUS_EXPR || code == MINUS_EXPR)
2380 return const_hash (TREE_OPERAND (exp, 0)) * 9
2381 + const_hash (TREE_OPERAND (exp, 1));
2382 else if (code == NOP_EXPR || code == CONVERT_EXPR)
2383 return const_hash (TREE_OPERAND (exp, 0)) * 7 + 2;
2385 /* Compute hashing function */
2387 for (i = 0; i < len; i++)
2388 hi = ((hi * 613) + (unsigned)(p[i]));
2390 hi &= (1 << HASHBITS) - 1;
2391 hi %= MAX_HASH_TABLE;
2395 /* Compare a constant expression EXP with a constant-descriptor DESC.
2396 Return 1 if DESC describes a constant with the same value as EXP. */
2399 compare_constant (exp, desc)
2401 struct constant_descriptor *desc;
2403 return 0 != compare_constant_1 (exp, desc->contents);
2406 /* Compare constant expression EXP with a substring P of a constant descriptor.
2407 If they match, return a pointer to the end of the substring matched.
2408 If they do not match, return 0.
2410 Since descriptors are written in polish prefix notation,
2411 this function can be used recursively to test one operand of EXP
2412 against a subdescriptor, and if it succeeds it returns the
2413 address of the subdescriptor for the next operand. */
2416 compare_constant_1 (exp, p)
2420 register char *strp;
2422 register enum tree_code code = TREE_CODE (exp);
2424 if (code != (enum tree_code) *p++)
2427 if (code == INTEGER_CST)
2429 /* Integer constants are the same only if the same width of type. */
2430 if (*p++ != TYPE_PRECISION (TREE_TYPE (exp)))
2432 strp = (char *) &TREE_INT_CST_LOW (exp);
2433 len = 2 * sizeof TREE_INT_CST_LOW (exp);
2435 else if (code == REAL_CST)
2437 /* Real constants are the same only if the same width of type. */
2438 if (*p++ != TYPE_PRECISION (TREE_TYPE (exp)))
2440 strp = (char *) &TREE_REAL_CST (exp);
2441 len = sizeof TREE_REAL_CST (exp);
2443 else if (code == STRING_CST)
2445 if (flag_writable_strings)
2447 strp = TREE_STRING_POINTER (exp);
2448 len = TREE_STRING_LENGTH (exp);
2449 if (bcmp ((char *) &TREE_STRING_LENGTH (exp), p,
2450 sizeof TREE_STRING_LENGTH (exp)))
2452 p += sizeof TREE_STRING_LENGTH (exp);
2454 else if (code == COMPLEX_CST)
2456 p = compare_constant_1 (TREE_REALPART (exp), p);
2457 if (p == 0) return 0;
2458 p = compare_constant_1 (TREE_IMAGPART (exp), p);
2461 else if (code == CONSTRUCTOR && TREE_CODE (TREE_TYPE (exp)) == SET_TYPE)
2463 int xlen = len = int_size_in_bytes (TREE_TYPE (exp));
2464 strp = (char*) alloca (len);
2465 get_set_constructor_bytes (exp, (unsigned char *) strp, len);
2466 if (bcmp ((char *) &xlen, p, sizeof xlen))
2470 else if (code == CONSTRUCTOR)
2473 int length = list_length (CONSTRUCTOR_ELTS (exp));
2476 if (bcmp ((char *) &length, p, sizeof length))
2480 /* For record constructors, insist that the types match.
2481 For arrays, just verify both constructors are for arrays. */
2482 if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE)
2483 type = TREE_TYPE (exp);
2486 if (bcmp ((char *) &type, p, sizeof type))
2490 /* For arrays, insist that the size in bytes match. */
2491 if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE)
2493 int size = int_size_in_bytes (TREE_TYPE (exp));
2494 if (bcmp ((char *) &size, p, sizeof size))
2499 for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link))
2501 if (TREE_VALUE (link))
2503 if ((p = compare_constant_1 (TREE_VALUE (link), p)) == 0)
2510 if (bcmp ((char *) &zero, p, sizeof zero))
2518 else if (code == ADDR_EXPR)
2520 struct addr_const value;
2521 decode_addr_const (exp, &value);
2522 strp = (char *) &value.offset;
2523 len = sizeof value.offset;
2524 /* Compare the offset. */
2526 if (*p++ != *strp++)
2528 /* Compare symbol name. */
2529 strp = XSTR (value.base, 0);
2530 len = strlen (strp) + 1;
2532 else if (code == PLUS_EXPR || code == MINUS_EXPR)
2534 p = compare_constant_1 (TREE_OPERAND (exp, 0), p);
2535 if (p == 0) return 0;
2536 p = compare_constant_1 (TREE_OPERAND (exp, 1), p);
2539 else if (code == NOP_EXPR || code == CONVERT_EXPR)
2541 p = compare_constant_1 (TREE_OPERAND (exp, 0), p);
2545 /* Compare constant contents. */
2547 if (*p++ != *strp++)
2553 /* Construct a constant descriptor for the expression EXP.
2554 It is up to the caller to enter the descriptor in the hash table. */
2556 static struct constant_descriptor *
2557 record_constant (exp)
2560 struct constant_descriptor *next = 0;
2563 /* Make a struct constant_descriptor. The first two pointers will
2564 be filled in later. Here we just leave space for them. */
2566 obstack_grow (&permanent_obstack, (char *) &next, sizeof next);
2567 obstack_grow (&permanent_obstack, (char *) &label, sizeof label);
2568 record_constant_1 (exp);
2569 return (struct constant_descriptor *) obstack_finish (&permanent_obstack);
2572 /* Add a description of constant expression EXP
2573 to the object growing in `permanent_obstack'.
2574 No need to return its address; the caller will get that
2575 from the obstack when the object is complete. */
2578 record_constant_1 (exp)
2581 register char *strp;
2583 register enum tree_code code = TREE_CODE (exp);
2585 obstack_1grow (&permanent_obstack, (unsigned int) code);
2590 obstack_1grow (&permanent_obstack, TYPE_PRECISION (TREE_TYPE (exp)));
2591 strp = (char *) &TREE_INT_CST_LOW (exp);
2592 len = 2 * sizeof TREE_INT_CST_LOW (exp);
2596 obstack_1grow (&permanent_obstack, TYPE_PRECISION (TREE_TYPE (exp)));
2597 strp = (char *) &TREE_REAL_CST (exp);
2598 len = sizeof TREE_REAL_CST (exp);
2602 if (flag_writable_strings)
2605 strp = TREE_STRING_POINTER (exp);
2606 len = TREE_STRING_LENGTH (exp);
2607 obstack_grow (&permanent_obstack, (char *) &TREE_STRING_LENGTH (exp),
2608 sizeof TREE_STRING_LENGTH (exp));
2612 record_constant_1 (TREE_REALPART (exp));
2613 record_constant_1 (TREE_IMAGPART (exp));
2617 if (TREE_CODE (TREE_TYPE (exp)) == SET_TYPE)
2619 int nbytes = int_size_in_bytes (TREE_TYPE (exp));
2620 obstack_grow (&permanent_obstack, &nbytes, sizeof (nbytes));
2621 obstack_blank (&permanent_obstack, nbytes);
2622 get_set_constructor_bytes
2623 (exp, (unsigned char *) permanent_obstack.next_free-nbytes,
2630 int length = list_length (CONSTRUCTOR_ELTS (exp));
2633 obstack_grow (&permanent_obstack, (char *) &length, sizeof length);
2635 /* For record constructors, insist that the types match.
2636 For arrays, just verify both constructors are for arrays. */
2637 if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE)
2638 type = TREE_TYPE (exp);
2641 obstack_grow (&permanent_obstack, (char *) &type, sizeof type);
2643 /* For arrays, insist that the size in bytes match. */
2644 if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE)
2646 int size = int_size_in_bytes (TREE_TYPE (exp));
2647 obstack_grow (&permanent_obstack, (char *) &size, sizeof size);
2650 for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link))
2652 if (TREE_VALUE (link))
2653 record_constant_1 (TREE_VALUE (link));
2658 obstack_grow (&permanent_obstack,
2659 (char *) &zero, sizeof zero);
2667 struct addr_const value;
2669 decode_addr_const (exp, &value);
2670 /* Record the offset. */
2671 obstack_grow (&permanent_obstack,
2672 (char *) &value.offset, sizeof value.offset);
2673 /* Record the symbol name. */
2674 obstack_grow (&permanent_obstack, XSTR (value.base, 0),
2675 strlen (XSTR (value.base, 0)) + 1);
2681 record_constant_1 (TREE_OPERAND (exp, 0));
2682 record_constant_1 (TREE_OPERAND (exp, 1));
2687 case NON_LVALUE_EXPR:
2688 record_constant_1 (TREE_OPERAND (exp, 0));
2695 /* Record constant contents. */
2696 obstack_grow (&permanent_obstack, strp, len);
2699 /* Record a list of constant expressions that were passed to
2700 output_constant_def but that could not be output right away. */
2702 struct deferred_constant
2704 struct deferred_constant *next;
2710 static struct deferred_constant *deferred_constants;
2712 /* Nonzero means defer output of addressed subconstants
2713 (i.e., those for which output_constant_def is called.) */
2714 static int defer_addressed_constants_flag;
2716 /* Start deferring output of subconstants. */
2719 defer_addressed_constants ()
2721 defer_addressed_constants_flag++;
2724 /* Stop deferring output of subconstants,
2725 and output now all those that have been deferred. */
2728 output_deferred_addressed_constants ()
2730 struct deferred_constant *p, *next;
2732 defer_addressed_constants_flag--;
2734 if (defer_addressed_constants_flag > 0)
2737 for (p = deferred_constants; p; p = next)
2739 output_constant_def_contents (p->exp, p->reloc, p->labelno);
2744 deferred_constants = 0;
2747 /* Make a copy of the whole tree structure for a constant.
2748 This handles the same types of nodes that compare_constant
2749 and record_constant handle. */
2755 switch (TREE_CODE (exp))
2758 /* For ADDR_EXPR, we do not want to copy the decl whose address
2759 is requested. We do want to copy constants though. */
2760 if (TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp, 0))) == 'c')
2761 return build1 (TREE_CODE (exp), TREE_TYPE (exp),
2762 copy_constant (TREE_OPERAND (exp, 0)));
2764 return copy_node (exp);
2769 return copy_node (exp);
2772 return build_complex (copy_constant (TREE_REALPART (exp)),
2773 copy_constant (TREE_IMAGPART (exp)));
2777 return build (TREE_CODE (exp), TREE_TYPE (exp),
2778 copy_constant (TREE_OPERAND (exp, 0)),
2779 copy_constant (TREE_OPERAND (exp, 1)));
2783 return build1 (TREE_CODE (exp), TREE_TYPE (exp),
2784 copy_constant (TREE_OPERAND (exp, 0)));
2788 tree copy = copy_node (exp);
2789 tree list = copy_list (CONSTRUCTOR_ELTS (exp));
2792 CONSTRUCTOR_ELTS (copy) = list;
2793 for (tail = list; tail; tail = TREE_CHAIN (tail))
2794 TREE_VALUE (tail) = copy_constant (TREE_VALUE (tail));
2795 if (TREE_CODE (TREE_TYPE (exp)) == SET_TYPE)
2796 for (tail = list; tail; tail = TREE_CHAIN (tail))
2797 TREE_PURPOSE (tail) = copy_constant (TREE_PURPOSE (tail));
2807 /* Return an rtx representing a reference to constant data in memory
2808 for the constant expression EXP.
2810 If assembler code for such a constant has already been output,
2811 return an rtx to refer to it.
2812 Otherwise, output such a constant in memory (or defer it for later)
2813 and generate an rtx for it.
2815 The TREE_CST_RTL of EXP is set up to point to that rtx.
2816 The const_hash_table records which constants already have label strings. */
2819 output_constant_def (exp)
2823 register struct constant_descriptor *desc;
2829 if (TREE_CODE (exp) == INTEGER_CST)
2830 abort (); /* No TREE_CST_RTL slot in these. */
2832 if (TREE_CST_RTL (exp))
2833 return TREE_CST_RTL (exp);
2835 /* Make sure any other constants whose addresses appear in EXP
2836 are assigned label numbers. */
2838 reloc = output_addressed_constants (exp);
2840 /* Compute hash code of EXP. Search the descriptors for that hash code
2841 to see if any of them describes EXP. If yes, the descriptor records
2842 the label number already assigned. */
2844 hash = const_hash (exp) % MAX_HASH_TABLE;
2846 for (desc = const_hash_table[hash]; desc; desc = desc->next)
2847 if (compare_constant (exp, desc))
2849 found = desc->label;
2855 /* No constant equal to EXP is known to have been output.
2856 Make a constant descriptor to enter EXP in the hash table.
2857 Assign the label number and record it in the descriptor for
2858 future calls to this function to find. */
2860 /* Create a string containing the label name, in LABEL. */
2861 ASM_GENERATE_INTERNAL_LABEL (label, "LC", const_labelno);
2863 desc = record_constant (exp);
2864 desc->next = const_hash_table[hash];
2866 = (char *) obstack_copy0 (&permanent_obstack, label, strlen (label));
2867 const_hash_table[hash] = desc;
2871 /* Create a string containing the label name, in LABEL. */
2872 ASM_GENERATE_INTERNAL_LABEL (label, "LC", const_labelno);
2875 /* We have a symbol name; construct the SYMBOL_REF and the MEM. */
2877 push_obstacks_nochange ();
2878 if (TREE_PERMANENT (exp))
2879 end_temporary_allocation ();
2881 def = gen_rtx (SYMBOL_REF, Pmode, desc->label);
2884 = gen_rtx (MEM, TYPE_MODE (TREE_TYPE (exp)), def);
2885 RTX_UNCHANGING_P (TREE_CST_RTL (exp)) = 1;
2886 if (AGGREGATE_TYPE_P (TREE_TYPE (exp)))
2887 MEM_IN_STRUCT_P (TREE_CST_RTL (exp)) = 1;
2891 /* Optionally set flags or add text to the name to record information
2892 such as that it is a function name. If the name is changed, the macro
2893 ASM_OUTPUT_LABELREF will have to know how to strip this information. */
2894 #ifdef ENCODE_SECTION_INFO
2895 ENCODE_SECTION_INFO (exp);
2898 /* If this is the first time we've seen this particular constant,
2899 output it (or defer its output for later). */
2902 if (defer_addressed_constants_flag)
2904 struct deferred_constant *p;
2905 p = (struct deferred_constant *) xmalloc (sizeof (struct deferred_constant));
2907 push_obstacks_nochange ();
2908 suspend_momentary ();
2909 p->exp = copy_constant (exp);
2912 p->labelno = const_labelno++;
2913 p->next = deferred_constants;
2914 deferred_constants = p;
2917 output_constant_def_contents (exp, reloc, const_labelno++);
2920 return TREE_CST_RTL (exp);
2923 /* Now output assembler code to define the label for EXP,
2924 and follow it with the data of EXP. */
2927 output_constant_def_contents (exp, reloc, labelno)
2934 if (IN_NAMED_SECTION (exp))
2935 named_section (exp, NULL);
2938 /* First switch to text section, except for writable strings. */
2939 #ifdef SELECT_SECTION
2940 SELECT_SECTION (exp, reloc);
2942 if (((TREE_CODE (exp) == STRING_CST) && flag_writable_strings)
2943 || (flag_pic && reloc))
2946 readonly_data_section ();
2950 /* Align the location counter as required by EXP's data type. */
2951 align = TYPE_ALIGN (TREE_TYPE (exp));
2952 #ifdef CONSTANT_ALIGNMENT
2953 align = CONSTANT_ALIGNMENT (exp, align);
2956 if (align > BITS_PER_UNIT)
2958 if (!output_bytecode)
2960 ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT));
2964 BC_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT));
2968 /* Output the label itself. */
2969 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LC", labelno);
2971 /* Output the value of EXP. */
2972 output_constant (exp,
2973 (TREE_CODE (exp) == STRING_CST
2974 ? TREE_STRING_LENGTH (exp)
2975 : int_size_in_bytes (TREE_TYPE (exp))));
2979 /* Similar hash facility for making memory-constants
2980 from constant rtl-expressions. It is used on RISC machines
2981 where immediate integer arguments and constant addresses are restricted
2982 so that such constants must be stored in memory.
2984 This pool of constants is reinitialized for each function
2985 so each function gets its own constants-pool that comes right before it.
2987 All structures allocated here are discarded when functions are saved for
2988 inlining, so they do not need to be allocated permanently. */
2990 #define MAX_RTX_HASH_TABLE 61
2991 static struct constant_descriptor **const_rtx_hash_table;
2993 /* Structure to represent sufficient information about a constant so that
2994 it can be output when the constant pool is output, so that function
2995 integration can be done, and to simplify handling on machines that reference
2996 constant pool as base+displacement. */
2998 struct pool_constant
3000 struct constant_descriptor *desc;
3001 struct pool_constant *next;
3002 enum machine_mode mode;
3009 /* Pointers to first and last constant in pool. */
3011 static struct pool_constant *first_pool, *last_pool;
3013 /* Current offset in constant pool (does not include any machine-specific
3016 static int pool_offset;
3018 /* Structure used to maintain hash table mapping symbols used to their
3019 corresponding constants. */
3024 struct pool_constant *pool;
3025 struct pool_sym *next;
3028 static struct pool_sym **const_rtx_sym_hash_table;
3030 /* Hash code for a SYMBOL_REF with CONSTANT_POOL_ADDRESS_P true.
3031 The argument is XSTR (... , 0) */
3033 #define SYMHASH(LABEL) \
3034 ((((HOST_WIDE_INT) (LABEL)) & ((1 << HASHBITS) - 1)) % MAX_RTX_HASH_TABLE)
3036 /* Initialize constant pool hashing for next function. */
3039 init_const_rtx_hash_table ()
3041 const_rtx_hash_table
3042 = ((struct constant_descriptor **)
3043 oballoc (MAX_RTX_HASH_TABLE * sizeof (struct constant_descriptor *)));
3044 const_rtx_sym_hash_table
3045 = ((struct pool_sym **)
3046 oballoc (MAX_RTX_HASH_TABLE * sizeof (struct pool_sym *)));
3047 bzero ((char *) const_rtx_hash_table,
3048 MAX_RTX_HASH_TABLE * sizeof (struct constant_descriptor *));
3049 bzero ((char *) const_rtx_sym_hash_table,
3050 MAX_RTX_HASH_TABLE * sizeof (struct pool_sym *));
3052 first_pool = last_pool = 0;
3056 /* Save and restore status for a nested function. */
3059 save_varasm_status (p)
3062 p->const_rtx_hash_table = const_rtx_hash_table;
3063 p->const_rtx_sym_hash_table = const_rtx_sym_hash_table;
3064 p->first_pool = first_pool;
3065 p->last_pool = last_pool;
3066 p->pool_offset = pool_offset;
3070 restore_varasm_status (p)
3073 const_rtx_hash_table = p->const_rtx_hash_table;
3074 const_rtx_sym_hash_table = p->const_rtx_sym_hash_table;
3075 first_pool = p->first_pool;
3076 last_pool = p->last_pool;
3077 pool_offset = p->pool_offset;
3080 enum kind { RTX_DOUBLE, RTX_INT };
3084 #ifdef ONLY_INT_FIELDS
3085 unsigned int kind : 16;
3086 unsigned int mode : 16;
3088 enum kind kind : 16;
3089 enum machine_mode mode : 16;
3092 union real_extract du;
3093 struct addr_const addr;
3094 struct {HOST_WIDE_INT high, low;} di;
3098 /* Express an rtx for a constant integer (perhaps symbolic)
3099 as the sum of a symbol or label plus an explicit integer.
3100 They are stored into VALUE. */
3103 decode_rtx_const (mode, x, value)
3104 enum machine_mode mode;
3106 struct rtx_const *value;
3108 /* Clear the whole structure, including any gaps. */
3111 int *p = (int *) value;
3112 int *end = (int *) (value + 1);
3117 value->kind = RTX_INT; /* Most usual kind. */
3120 switch (GET_CODE (x))
3123 value->kind = RTX_DOUBLE;
3124 if (GET_MODE (x) != VOIDmode)
3126 value->mode = GET_MODE (x);
3127 bcopy ((char *) &CONST_DOUBLE_LOW (x),
3128 (char *) &value->un.du, sizeof value->un.du);
3132 value->un.di.low = CONST_DOUBLE_LOW (x);
3133 value->un.di.high = CONST_DOUBLE_HIGH (x);
3138 value->un.addr.offset = INTVAL (x);
3144 value->un.addr.base = x;
3149 if (GET_CODE (x) == PLUS)
3151 value->un.addr.base = XEXP (x, 0);
3152 if (GET_CODE (XEXP (x, 1)) != CONST_INT)
3154 value->un.addr.offset = INTVAL (XEXP (x, 1));
3156 else if (GET_CODE (x) == MINUS)
3158 value->un.addr.base = XEXP (x, 0);
3159 if (GET_CODE (XEXP (x, 1)) != CONST_INT)
3161 value->un.addr.offset = - INTVAL (XEXP (x, 1));
3171 if (value->kind == RTX_INT && value->un.addr.base != 0)
3172 switch (GET_CODE (value->un.addr.base))
3176 /* Use the string's address, not the SYMBOL_REF's address,
3177 for the sake of addresses of library routines.
3178 For a LABEL_REF, compare labels. */
3179 value->un.addr.base = XEXP (value->un.addr.base, 0);
3183 /* Given a MINUS expression, simplify it if both sides
3184 include the same symbol. */
3187 simplify_subtraction (x)
3190 struct rtx_const val0, val1;
3192 decode_rtx_const (GET_MODE (x), XEXP (x, 0), &val0);
3193 decode_rtx_const (GET_MODE (x), XEXP (x, 1), &val1);
3195 if (val0.un.addr.base == val1.un.addr.base)
3196 return GEN_INT (val0.un.addr.offset - val1.un.addr.offset);
3200 /* Compute a hash code for a constant RTL expression. */
3203 const_hash_rtx (mode, x)
3204 enum machine_mode mode;
3209 struct rtx_const value;
3210 decode_rtx_const (mode, x, &value);
3212 /* Compute hashing function */
3214 for (i = 0; i < sizeof value / sizeof (int); i++)
3215 hi += ((int *) &value)[i];
3217 hi &= (1 << HASHBITS) - 1;
3218 hi %= MAX_RTX_HASH_TABLE;
3222 /* Compare a constant rtl object X with a constant-descriptor DESC.
3223 Return 1 if DESC describes a constant with the same value as X. */
3226 compare_constant_rtx (mode, x, desc)
3227 enum machine_mode mode;
3229 struct constant_descriptor *desc;
3231 register int *p = (int *) desc->contents;
3234 struct rtx_const value;
3236 decode_rtx_const (mode, x, &value);
3237 strp = (int *) &value;
3238 len = sizeof value / sizeof (int);
3240 /* Compare constant contents. */
3242 if (*p++ != *strp++)
3248 /* Construct a constant descriptor for the rtl-expression X.
3249 It is up to the caller to enter the descriptor in the hash table. */
3251 static struct constant_descriptor *
3252 record_constant_rtx (mode, x)
3253 enum machine_mode mode;
3256 struct constant_descriptor *ptr;
3258 struct rtx_const value;
3260 decode_rtx_const (mode, x, &value);
3262 /* Put these things in the saveable obstack so we can ensure it won't
3263 be freed if we are called from combine or some other phase that discards
3264 memory allocated from function_obstack (current_obstack). */
3265 obstack_grow (saveable_obstack, &ptr, sizeof ptr);
3266 obstack_grow (saveable_obstack, &label, sizeof label);
3268 /* Record constant contents. */
3269 obstack_grow (saveable_obstack, &value, sizeof value);
3271 return (struct constant_descriptor *) obstack_finish (saveable_obstack);
3274 /* Given a constant rtx X, make (or find) a memory constant for its value
3275 and return a MEM rtx to refer to it in memory. */
3278 force_const_mem (mode, x)
3279 enum machine_mode mode;
3283 register struct constant_descriptor *desc;
3288 /* If we want this CONST_DOUBLE in the same mode as it is in memory
3289 (this will always be true for floating CONST_DOUBLEs that have been
3290 placed in memory, but not for VOIDmode (integer) CONST_DOUBLEs),
3291 use the previous copy. Otherwise, make a new one. Note that in
3292 the unlikely event that this same CONST_DOUBLE is used in two different
3293 modes in an alternating fashion, we will allocate a lot of different
3294 memory locations, but this should be extremely rare. */
3296 /* Don't use CONST_DOUBLE_MEM in a nested function.
3297 Nested functions have their own constant pools,
3298 so they can't share the same values in CONST_DOUBLE_MEM
3299 with the containing function. */
3300 if (outer_function_chain == 0)
3301 if (GET_CODE (x) == CONST_DOUBLE
3302 && GET_CODE (CONST_DOUBLE_MEM (x)) == MEM
3303 && GET_MODE (CONST_DOUBLE_MEM (x)) == mode)
3304 return CONST_DOUBLE_MEM (x);
3306 /* Compute hash code of X. Search the descriptors for that hash code
3307 to see if any of them describes X. If yes, the descriptor records
3308 the label number already assigned. */
3310 hash = const_hash_rtx (mode, x);
3312 for (desc = const_rtx_hash_table[hash]; desc; desc = desc->next)
3313 if (compare_constant_rtx (mode, x, desc))
3315 found = desc->label;
3321 register struct pool_constant *pool;
3322 register struct pool_sym *sym;
3325 /* No constant equal to X is known to have been output.
3326 Make a constant descriptor to enter X in the hash table.
3327 Assign the label number and record it in the descriptor for
3328 future calls to this function to find. */
3330 desc = record_constant_rtx (mode, x);
3331 desc->next = const_rtx_hash_table[hash];
3332 const_rtx_hash_table[hash] = desc;
3334 /* Align the location counter as required by EXP's data type. */
3335 align = (mode == VOIDmode) ? UNITS_PER_WORD : GET_MODE_SIZE (mode);
3336 if (align > BIGGEST_ALIGNMENT / BITS_PER_UNIT)
3337 align = BIGGEST_ALIGNMENT / BITS_PER_UNIT;
3339 pool_offset += align - 1;
3340 pool_offset &= ~ (align - 1);
3342 /* If RTL is not being placed into the saveable obstack, make a
3343 copy of X that is in the saveable obstack in case we are being
3344 called from combine or some other phase that discards memory
3345 it allocates. We need only do this if it is a CONST, since
3346 no other RTX should be allocated in this situation. */
3347 if (rtl_obstack != saveable_obstack
3348 && GET_CODE (x) == CONST)
3350 push_obstacks_nochange ();
3351 rtl_in_saveable_obstack ();
3353 x = gen_rtx (CONST, GET_MODE (x),
3354 gen_rtx (PLUS, GET_MODE (x),
3355 XEXP (XEXP (x, 0), 0), XEXP (XEXP (x, 0), 1)));
3359 /* Allocate a pool constant descriptor, fill it in, and chain it in. */
3361 pool = (struct pool_constant *) savealloc (sizeof (struct pool_constant));
3365 pool->labelno = const_labelno;
3366 pool->align = align;
3367 pool->offset = pool_offset;
3373 last_pool->next = pool;
3376 pool_offset += GET_MODE_SIZE (mode);
3378 /* Create a string containing the label name, in LABEL. */
3379 ASM_GENERATE_INTERNAL_LABEL (label, "LC", const_labelno);
3384 = (char *) obstack_copy0 (saveable_obstack, label, strlen (label));
3386 /* Add label to symbol hash table. */
3387 hash = SYMHASH (found);
3388 sym = (struct pool_sym *) savealloc (sizeof (struct pool_sym));
3391 sym->next = const_rtx_sym_hash_table[hash];
3392 const_rtx_sym_hash_table[hash] = sym;
3395 /* We have a symbol name; construct the SYMBOL_REF and the MEM. */
3397 def = gen_rtx (MEM, mode, gen_rtx (SYMBOL_REF, Pmode, found));
3399 RTX_UNCHANGING_P (def) = 1;
3400 /* Mark the symbol_ref as belonging to this constants pool. */
3401 CONSTANT_POOL_ADDRESS_P (XEXP (def, 0)) = 1;
3402 current_function_uses_const_pool = 1;
3404 if (outer_function_chain == 0)
3405 if (GET_CODE (x) == CONST_DOUBLE)
3407 if (CONST_DOUBLE_MEM (x) == cc0_rtx)
3409 CONST_DOUBLE_CHAIN (x) = const_double_chain;
3410 const_double_chain = x;
3412 CONST_DOUBLE_MEM (x) = def;
3418 /* Given a SYMBOL_REF with CONSTANT_POOL_ADDRESS_P true, return a pointer to
3419 the corresponding pool_constant structure. */
3421 static struct pool_constant *
3422 find_pool_constant (addr)
3425 struct pool_sym *sym;
3426 char *label = XSTR (addr, 0);
3428 for (sym = const_rtx_sym_hash_table[SYMHASH (label)]; sym; sym = sym->next)
3429 if (sym->label == label)
3435 /* Given a constant pool SYMBOL_REF, return the corresponding constant. */
3438 get_pool_constant (addr)
3441 return (find_pool_constant (addr))->constant;
3444 /* Similar, return the mode. */
3447 get_pool_mode (addr)
3450 return (find_pool_constant (addr))->mode;
3453 /* Similar, return the offset in the constant pool. */
3456 get_pool_offset (addr)
3459 return (find_pool_constant (addr))->offset;
3462 /* Return the size of the constant pool. */
3470 /* Write all the constants in the constant pool. */
3473 output_constant_pool (fnname, fndecl)
3477 struct pool_constant *pool;
3479 union real_extract u;
3481 #ifdef ASM_OUTPUT_POOL_PROLOGUE
3482 ASM_OUTPUT_POOL_PROLOGUE (asm_out_file, fnname, fndecl, pool_offset);
3485 for (pool = first_pool; pool; pool = pool->next)
3489 /* See if X is a LABEL_REF (or a CONST referring to a LABEL_REF)
3490 whose CODE_LABEL has been deleted. This can occur if a jump table
3491 is eliminated by optimization. If so, write a constant of zero
3492 instead. Note that this can also happen by turning the
3493 CODE_LABEL into a NOTE. */
3494 if (((GET_CODE (x) == LABEL_REF
3495 && (INSN_DELETED_P (XEXP (x, 0))
3496 || GET_CODE (XEXP (x, 0)) == NOTE)))
3497 || (GET_CODE (x) == CONST && GET_CODE (XEXP (x, 0)) == PLUS
3498 && GET_CODE (XEXP (XEXP (x, 0), 0)) == LABEL_REF
3499 && (INSN_DELETED_P (XEXP (XEXP (XEXP (x, 0), 0), 0))
3500 || GET_CODE (XEXP (XEXP (XEXP (x, 0), 0), 0)) == NOTE)))
3503 /* First switch to correct section. */
3504 #ifdef SELECT_RTX_SECTION
3505 SELECT_RTX_SECTION (pool->mode, x);
3507 readonly_data_section ();
3510 #ifdef ASM_OUTPUT_SPECIAL_POOL_ENTRY
3511 ASM_OUTPUT_SPECIAL_POOL_ENTRY (asm_out_file, x, pool->mode,
3512 pool->align, pool->labelno, done);
3515 if (pool->align > 1)
3516 ASM_OUTPUT_ALIGN (asm_out_file, exact_log2 (pool->align));
3518 /* Output the label. */
3519 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LC", pool->labelno);
3521 /* Output the value of the constant itself. */
3522 switch (GET_MODE_CLASS (pool->mode))
3525 if (GET_CODE (x) != CONST_DOUBLE)
3528 bcopy ((char *) &CONST_DOUBLE_LOW (x), (char *) &u, sizeof u);
3529 assemble_real (u.d, pool->mode);
3533 case MODE_PARTIAL_INT:
3534 assemble_integer (x, GET_MODE_SIZE (pool->mode), 1);
3544 /* Done with this pool. */
3545 first_pool = last_pool = 0;
3548 /* Find all the constants whose addresses are referenced inside of EXP,
3549 and make sure assembler code with a label has been output for each one.
3550 Indicate whether an ADDR_EXPR has been encountered. */
3553 output_addressed_constants (exp)
3558 switch (TREE_CODE (exp))
3562 register tree constant = TREE_OPERAND (exp, 0);
3564 while (TREE_CODE (constant) == COMPONENT_REF)
3566 constant = TREE_OPERAND (constant, 0);
3569 if (TREE_CODE_CLASS (TREE_CODE (constant)) == 'c'
3570 || TREE_CODE (constant) == CONSTRUCTOR)
3571 /* No need to do anything here
3572 for addresses of variables or functions. */
3573 output_constant_def (constant);
3580 reloc = output_addressed_constants (TREE_OPERAND (exp, 0));
3581 reloc |= output_addressed_constants (TREE_OPERAND (exp, 1));
3586 case NON_LVALUE_EXPR:
3587 reloc = output_addressed_constants (TREE_OPERAND (exp, 0));
3593 for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link))
3594 if (TREE_VALUE (link) != 0)
3595 reloc |= output_addressed_constants (TREE_VALUE (link));
3605 /* Output assembler code for constant EXP to FILE, with no label.
3606 This includes the pseudo-op such as ".int" or ".byte", and a newline.
3607 Assumes output_addressed_constants has been done on EXP already.
3609 Generate exactly SIZE bytes of assembler data, padding at the end
3610 with zeros if necessary. SIZE must always be specified.
3612 SIZE is important for structure constructors,
3613 since trailing members may have been omitted from the constructor.
3614 It is also important for initialization of arrays from string constants
3615 since the full length of the string constant might not be wanted.
3616 It is also needed for initialization of unions, where the initializer's
3617 type is just one member, and that may not be as long as the union.
3619 There a case in which we would fail to output exactly SIZE bytes:
3620 for a structure constructor that wants to produce more than SIZE bytes.
3621 But such constructors will never be generated for any possible input. */
3624 output_constant (exp, size)
3628 register enum tree_code code = TREE_CODE (TREE_TYPE (exp));
3634 /* Eliminate the NON_LVALUE_EXPR_EXPR that makes a cast not be an lvalue.
3635 That way we get the constant (we hope) inside it. Also, strip off any
3636 NOP_EXPR that converts between two record, union, array, or set types. */
3637 while ((TREE_CODE (exp) == NOP_EXPR
3638 && (TREE_TYPE (exp) == TREE_TYPE (TREE_OPERAND (exp, 0))
3639 || AGGREGATE_TYPE_P (TREE_TYPE (exp))))
3640 || TREE_CODE (exp) == NON_LVALUE_EXPR)
3641 exp = TREE_OPERAND (exp, 0);
3643 /* Allow a constructor with no elements for any data type.
3644 This means to fill the space with zeros. */
3645 if (TREE_CODE (exp) == CONSTRUCTOR && CONSTRUCTOR_ELTS (exp) == 0)
3647 if (output_bytecode)
3648 bc_emit_const_skip (size);
3650 assemble_zeros (size);
3661 case REFERENCE_TYPE:
3662 /* ??? What about (int)((float)(int)&foo + 4) */
3663 while (TREE_CODE (exp) == NOP_EXPR || TREE_CODE (exp) == CONVERT_EXPR
3664 || TREE_CODE (exp) == NON_LVALUE_EXPR)
3665 exp = TREE_OPERAND (exp, 0);
3667 if (! assemble_integer (expand_expr (exp, NULL_RTX, VOIDmode,
3668 EXPAND_INITIALIZER),
3670 error ("initializer for integer value is too complicated");
3675 if (TREE_CODE (exp) != REAL_CST)
3676 error ("initializer for floating value is not a floating constant");
3678 assemble_real (TREE_REAL_CST (exp),
3679 mode_for_size (size * BITS_PER_UNIT, MODE_FLOAT, 0));
3684 output_constant (TREE_REALPART (exp), size / 2);
3685 output_constant (TREE_IMAGPART (exp), size / 2);
3686 size -= (size / 2) * 2;
3690 if (TREE_CODE (exp) == CONSTRUCTOR)
3692 output_constructor (exp, size);
3695 else if (TREE_CODE (exp) == STRING_CST)
3699 if (size > TREE_STRING_LENGTH (exp))
3701 excess = size - TREE_STRING_LENGTH (exp);
3702 size = TREE_STRING_LENGTH (exp);
3705 assemble_string (TREE_STRING_POINTER (exp), size);
3714 if (TREE_CODE (exp) == CONSTRUCTOR)
3715 output_constructor (exp, size);
3721 if (TREE_CODE (exp) == INTEGER_CST)
3722 assemble_integer (expand_expr (exp, NULL_RTX,
3723 VOIDmode, EXPAND_INITIALIZER),
3725 else if (TREE_CODE (exp) == CONSTRUCTOR)
3727 unsigned char *buffer = (unsigned char *) alloca (size);
3728 if (get_set_constructor_bytes (exp, buffer, size))
3730 assemble_string ((char *) buffer, size);
3733 error ("unknown set constructor type");
3738 assemble_zeros (size);
3741 /* Bytecode specific code to output assembler for integer. */
3744 bc_assemble_integer (exp, size)
3752 /* FIXME: is this fold() business going to be as good as the
3753 expand_expr() using EXPAND_SUM above in the RTL case? I
3755 FIXME: Copied as is from BC-GCC1; may need work. Don't hate. -bson */
3759 while (TREE_CODE (exp) == NOP_EXPR || TREE_CODE (exp) == CONVERT_EXPR)
3760 exp = TREE_OPERAND (exp, 0);
3761 if (TREE_CODE (exp) == INTEGER_CST)
3766 else if (TREE_CODE (exp) == PLUS_EXPR)
3768 const_part = TREE_OPERAND (exp, 0);
3769 while (TREE_CODE (const_part) == NOP_EXPR
3770 || TREE_CODE (const_part) == CONVERT_EXPR)
3771 const_part = TREE_OPERAND (const_part, 0);
3772 addr_part = TREE_OPERAND (exp, 1);
3773 while (TREE_CODE (addr_part) == NOP_EXPR
3774 || TREE_CODE (addr_part) == CONVERT_EXPR)
3775 addr_part = TREE_OPERAND (addr_part, 0);
3776 if (TREE_CODE (const_part) != INTEGER_CST)
3777 tmp = const_part, const_part = addr_part, addr_part = tmp;
3778 if (TREE_CODE (const_part) != INTEGER_CST
3779 || TREE_CODE (addr_part) != ADDR_EXPR)
3780 abort (); /* FIXME: we really haven't considered
3781 all the possible cases here. */
3783 else if (TREE_CODE (exp) == ADDR_EXPR)
3785 const_part = integer_zero_node;
3789 abort (); /* FIXME: ditto previous. */
3795 char c = TREE_INT_CST_LOW (const_part);
3801 short s = TREE_INT_CST_LOW (const_part);
3802 bc_emit ((char *) &s, 2);
3807 int i = TREE_INT_CST_LOW (const_part);
3808 bc_emit ((char *) &i, 4);
3813 if (WORDS_BIG_ENDIAN)
3815 int i = TREE_INT_CST_HIGH (const_part);
3816 bc_emit ((char *) &i, 4);
3817 i = TREE_INT_CST_LOW (const_part);
3818 bc_emit ((char *) &i, 4);
3822 int i = TREE_INT_CST_LOW (const_part);
3823 bc_emit ((char *) &i, 4);
3824 i = TREE_INT_CST_HIGH (const_part);
3825 bc_emit ((char *) &i, 4);
3832 && TREE_CODE (TREE_OPERAND (addr_part, 0)) == VAR_DECL)
3833 bc_emit_labelref (IDENTIFIER_POINTER
3834 (DECL_ASSEMBLER_NAME (TREE_OPERAND (addr_part, 0))),
3835 TREE_INT_CST_LOW (const_part));
3837 abort (); /* FIXME: there may be more cases. */
3840 /* Subroutine of output_constant, used for CONSTRUCTORs
3841 (aggregate constants).
3842 Generate at least SIZE bytes, padding if necessary. */
3845 output_constructor (exp, size)
3849 register tree link, field = 0;
3850 HOST_WIDE_INT min_index = 0;
3851 /* Number of bytes output or skipped so far.
3852 In other words, current position within the constructor. */
3853 int total_bytes = 0;
3854 /* Non-zero means BYTE contains part of a byte, to be output. */
3855 int byte_buffer_in_use = 0;
3858 if (HOST_BITS_PER_WIDE_INT < BITS_PER_UNIT)
3861 if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE)
3862 field = TYPE_FIELDS (TREE_TYPE (exp));
3864 if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE
3865 && TYPE_DOMAIN (TREE_TYPE (exp)) != 0)
3867 = TREE_INT_CST_LOW (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (exp))));
3869 /* As LINK goes through the elements of the constant,
3870 FIELD goes through the structure fields, if the constant is a structure.
3871 if the constant is a union, then we override this,
3872 by getting the field from the TREE_LIST element.
3873 But the constant could also be an array. Then FIELD is zero. */
3874 for (link = CONSTRUCTOR_ELTS (exp);
3876 link = TREE_CHAIN (link),
3877 field = field ? TREE_CHAIN (field) : 0)
3879 tree val = TREE_VALUE (link);
3882 /* the element in a union constructor specifies the proper field. */
3884 if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE
3885 || TREE_CODE (TREE_TYPE (exp)) == UNION_TYPE)
3887 /* if available, use the type given by link */
3888 if (TREE_PURPOSE (link) != 0)
3889 field = TREE_PURPOSE (link);
3892 if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE)
3893 index = TREE_PURPOSE (link);
3895 /* Eliminate the marker that makes a cast not be an lvalue. */
3899 if (field == 0 || !DECL_BIT_FIELD (field))
3901 /* An element that is not a bit-field. */
3903 register int fieldsize;
3904 /* Since this structure is static,
3905 we know the positions are constant. */
3906 int bitpos = (field ? (TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field))
3910 bitpos = (TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (val)))
3912 * (TREE_INT_CST_LOW (index) - min_index));
3914 /* Output any buffered-up bit-fields preceding this element. */
3915 if (byte_buffer_in_use)
3917 ASM_OUTPUT_BYTE (asm_out_file, byte);
3919 byte_buffer_in_use = 0;
3922 /* Advance to offset of this element.
3923 Note no alignment needed in an array, since that is guaranteed
3924 if each element has the proper size. */
3925 if ((field != 0 || index != 0) && bitpos != total_bytes)
3927 if (!output_bytecode)
3928 assemble_zeros (bitpos - total_bytes);
3930 bc_emit_const_skip (bitpos - total_bytes);
3931 total_bytes = bitpos;
3934 /* Determine size this element should occupy. */
3937 if (TREE_CODE (DECL_SIZE (field)) != INTEGER_CST)
3939 if (TREE_INT_CST_LOW (DECL_SIZE (field)) > 100000)
3941 /* This avoids overflow trouble. */
3942 tree size_tree = size_binop (CEIL_DIV_EXPR,
3944 size_int (BITS_PER_UNIT));
3945 fieldsize = TREE_INT_CST_LOW (size_tree);
3949 fieldsize = TREE_INT_CST_LOW (DECL_SIZE (field));
3950 fieldsize = (fieldsize + BITS_PER_UNIT - 1) / BITS_PER_UNIT;
3954 fieldsize = int_size_in_bytes (TREE_TYPE (TREE_TYPE (exp)));
3956 /* Output the element's initial value. */
3958 assemble_zeros (fieldsize);
3960 output_constant (val, fieldsize);
3962 /* Count its size. */
3963 total_bytes += fieldsize;
3965 else if (val != 0 && TREE_CODE (val) != INTEGER_CST)
3966 error ("invalid initial value for member `%s'",
3967 IDENTIFIER_POINTER (DECL_NAME (field)));
3970 /* Element that is a bit-field. */
3972 int next_offset = TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field));
3974 = (next_offset + TREE_INT_CST_LOW (DECL_SIZE (field)));
3977 val = integer_zero_node;
3979 /* If this field does not start in this (or, next) byte,
3981 if (next_offset / BITS_PER_UNIT != total_bytes)
3983 /* Output remnant of any bit field in previous bytes. */
3984 if (byte_buffer_in_use)
3986 ASM_OUTPUT_BYTE (asm_out_file, byte);
3988 byte_buffer_in_use = 0;
3991 /* If still not at proper byte, advance to there. */
3992 if (next_offset / BITS_PER_UNIT != total_bytes)
3994 assemble_zeros (next_offset / BITS_PER_UNIT - total_bytes);
3995 total_bytes = next_offset / BITS_PER_UNIT;
3999 if (! byte_buffer_in_use)
4002 /* We must split the element into pieces that fall within
4003 separate bytes, and combine each byte with previous or
4004 following bit-fields. */
4006 /* next_offset is the offset n fbits from the beginning of
4007 the structure to the next bit of this element to be processed.
4008 end_offset is the offset of the first bit past the end of
4010 while (next_offset < end_offset)
4014 HOST_WIDE_INT value;
4015 int next_byte = next_offset / BITS_PER_UNIT;
4016 int next_bit = next_offset % BITS_PER_UNIT;
4018 /* Advance from byte to byte
4019 within this element when necessary. */
4020 while (next_byte != total_bytes)
4022 ASM_OUTPUT_BYTE (asm_out_file, byte);
4027 /* Number of bits we can process at once
4028 (all part of the same byte). */
4029 this_time = MIN (end_offset - next_offset,
4030 BITS_PER_UNIT - next_bit);
4031 if (BYTES_BIG_ENDIAN)
4033 /* On big-endian machine, take the most significant bits
4034 first (of the bits that are significant)
4035 and put them into bytes from the most significant end. */
4036 shift = end_offset - next_offset - this_time;
4037 /* Don't try to take a bunch of bits that cross
4038 the word boundary in the INTEGER_CST. */
4039 if (shift < HOST_BITS_PER_WIDE_INT
4040 && shift + this_time > HOST_BITS_PER_WIDE_INT)
4042 this_time -= (HOST_BITS_PER_WIDE_INT - shift);
4043 shift = HOST_BITS_PER_WIDE_INT;
4046 /* Now get the bits from the appropriate constant word. */
4047 if (shift < HOST_BITS_PER_WIDE_INT)
4049 value = TREE_INT_CST_LOW (val);
4051 else if (shift < 2 * HOST_BITS_PER_WIDE_INT)
4053 value = TREE_INT_CST_HIGH (val);
4054 shift -= HOST_BITS_PER_WIDE_INT;
4058 byte |= (((value >> shift)
4059 & (((HOST_WIDE_INT) 1 << this_time) - 1))
4060 << (BITS_PER_UNIT - this_time - next_bit));
4064 /* On little-endian machines,
4065 take first the least significant bits of the value
4066 and pack them starting at the least significant
4067 bits of the bytes. */
4068 shift = (next_offset
4069 - TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field)));
4070 /* Don't try to take a bunch of bits that cross
4071 the word boundary in the INTEGER_CST. */
4072 if (shift < HOST_BITS_PER_WIDE_INT
4073 && shift + this_time > HOST_BITS_PER_WIDE_INT)
4075 this_time -= (HOST_BITS_PER_WIDE_INT - shift);
4076 shift = HOST_BITS_PER_WIDE_INT;
4079 /* Now get the bits from the appropriate constant word. */
4080 if (shift < HOST_BITS_PER_INT)
4081 value = TREE_INT_CST_LOW (val);
4082 else if (shift < 2 * HOST_BITS_PER_WIDE_INT)
4084 value = TREE_INT_CST_HIGH (val);
4085 shift -= HOST_BITS_PER_WIDE_INT;
4089 byte |= (((value >> shift)
4090 & (((HOST_WIDE_INT) 1 << this_time) - 1))
4093 next_offset += this_time;
4094 byte_buffer_in_use = 1;
4098 if (byte_buffer_in_use)
4100 ASM_OUTPUT_BYTE (asm_out_file, byte);
4103 if (total_bytes < size)
4104 assemble_zeros (size - total_bytes);
4107 /* Output asm to handle ``#pragma weak'' */
4109 handle_pragma_weak (what, name, value)
4110 enum pragma_state what;
4113 #ifdef HANDLE_PRAGMA_WEAK
4114 if (what == ps_name || what == ps_value)
4116 struct weak_syms *weak =
4117 (struct weak_syms *)permalloc (sizeof (struct weak_syms));
4118 weak->next = weak_decls;
4119 weak->name = permalloc (strlen (name) + 1);
4120 strcpy (weak->name, name);
4122 if (what != ps_value)
4123 weak->value = NULL_PTR;
4127 weak->value = permalloc (strlen (value) + 1);
4128 strcpy (weak->value, value);
4133 else if (! (what == ps_done || what == ps_start))
4134 warning ("malformed `#pragma weak'");
4135 #endif /* HANDLE_PRAGMA_WEAK */
4138 /* Declare DECL to be a weak symbol. */
4144 if (! TREE_PUBLIC (decl))
4145 error_with_decl (decl, "weak declaration of `%s' must be public");
4146 else if (TREE_ASM_WRITTEN (decl))
4147 error_with_decl (decl, "weak declaration of `%s' must precede definition");
4148 else if (SUPPORTS_WEAK)
4149 DECL_WEAK (decl) = 1;
4152 /* Emit any pending weak declarations. */
4157 #ifdef HANDLE_PRAGMA_WEAK
4158 if (HANDLE_PRAGMA_WEAK)
4160 struct weak_syms *t;
4161 for (t = weak_decls; t; t = t->next)
4163 ASM_WEAKEN_LABEL (asm_out_file, t->name);
4165 ASM_OUTPUT_DEF (asm_out_file, t->name, t->value);
4172 assemble_alias (decl, target)
4175 #ifdef ASM_OUTPUT_DEF
4178 make_decl_rtl (decl, (char*)0, 1);
4179 name = XSTR (XEXP (DECL_RTL (decl), 0), 0);
4181 /* Make name accessible from other files, if appropriate. */
4183 if (TREE_PUBLIC (decl))
4185 #ifdef ASM_WEAKEN_LABEL
4186 if (DECL_WEAK (decl))
4187 ASM_WEAKEN_LABEL (asm_out_file, name);
4190 if (output_bytecode)
4191 BC_GLOBALIZE_LABEL (asm_out_file, name);
4193 ASM_GLOBALIZE_LABEL (asm_out_file, name);
4196 ASM_OUTPUT_DEF (asm_out_file, name, IDENTIFIER_POINTER (target));
4197 TREE_ASM_WRITTEN (decl) = 1;
4199 warning ("alias definitions not supported in this configuration");