1 /* Output variables, constants and external declarations, for GNU compiler.
2 Copyright (C) 1987, 1988, 1989, 1992, 1993 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, 675 Mass Ave, Cambridge, MA 02139, USA. */
21 /* This file handles generation of all the assembler code
22 *except* the instructions of a function.
23 This includes declarations of variables and their initial values.
25 We also output the assembler code for constants stored in memory
26 and are responsible for combining constants with the same value. */
30 /* #include <stab.h> */
37 #include "hard-reg-set.h"
44 #ifdef XCOFF_DEBUGGING_INFO
51 #define ASM_STABS_OP ".stabs"
54 /* This macro gets just the user-specified name
55 out of the string in a SYMBOL_REF. On most machines,
56 we discard the * if any and that's all. */
57 #ifndef STRIP_NAME_ENCODING
58 #define STRIP_NAME_ENCODING(VAR,SYMBOL_NAME) \
59 (VAR) = ((SYMBOL_NAME) + ((SYMBOL_NAME)[0] == '*'))
62 /* File in which assembler code is being written. */
64 extern FILE *asm_out_file;
66 /* The (assembler) name of the first globally-visible object output. */
67 char *first_global_object_name;
69 extern struct obstack *current_obstack;
70 extern struct obstack *saveable_obstack;
71 extern struct obstack permanent_obstack;
72 #define obstack_chunk_alloc xmalloc
74 /* Number for making the label on the next
75 constant that is stored in memory. */
79 /* Number for making the label on the next
80 static variable internal to a function. */
84 /* Nonzero if at least one function definition has been seen. */
85 static int function_defined;
87 extern FILE *asm_out_file;
89 static char *compare_constant_1 ();
90 static void record_constant_1 ();
91 void output_constant_pool ();
92 void assemble_name ();
93 int output_addressed_constants ();
94 void output_constant ();
95 void output_constructor ();
97 void readonly_data_section ();
100 #ifdef EXTRA_SECTIONS
101 static enum in_section {no_section, in_text, in_data, EXTRA_SECTIONS} in_section
104 static enum in_section {no_section, in_text, in_data} in_section
108 /* Define functions like text_section for any extra sections. */
109 #ifdef EXTRA_SECTION_FUNCTIONS
110 EXTRA_SECTION_FUNCTIONS
113 /* Tell assembler to switch to text section. */
118 if (in_section != in_text)
120 fprintf (asm_out_file, "%s\n", TEXT_SECTION_ASM_OP);
121 in_section = in_text;
125 /* Tell assembler to switch to data section. */
130 if (in_section != in_data)
132 if (flag_shared_data)
134 #ifdef SHARED_SECTION_ASM_OP
135 fprintf (asm_out_file, "%s\n", SHARED_SECTION_ASM_OP);
137 fprintf (asm_out_file, "%s\n", DATA_SECTION_ASM_OP);
141 fprintf (asm_out_file, "%s\n", DATA_SECTION_ASM_OP);
143 in_section = in_data;
147 /* Tell assembler to switch to read-only data section. This is normally
151 readonly_data_section ()
153 #ifdef READONLY_DATA_SECTION
154 READONLY_DATA_SECTION (); /* Note this can call data_section. */
160 /* Determine if we're in the text section. */
165 return in_section == in_text;
168 /* Create the rtl to represent a function, for a function definition.
169 DECL is a FUNCTION_DECL node which describes which function.
170 The rtl is stored into DECL. */
173 make_function_rtl (decl)
176 char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
178 /* Rename a nested function to avoid conflicts. */
179 if (decl_function_context (decl) != 0
180 && DECL_INITIAL (decl) != 0
181 && DECL_RTL (decl) == 0)
185 name = IDENTIFIER_POINTER (DECL_NAME (decl));
186 ASM_FORMAT_PRIVATE_NAME (label, name, var_labelno);
187 name = obstack_copy0 (saveable_obstack, label, strlen (label));
191 if (DECL_RTL (decl) == 0)
194 = gen_rtx (MEM, DECL_MODE (decl),
195 gen_rtx (SYMBOL_REF, Pmode, name));
197 /* Optionally set flags or add text to the name to record information
198 such as that it is a function name. If the name is changed, the macro
199 ASM_OUTPUT_LABELREF will have to know how to strip this information.
200 And if it finds a * at the beginning after doing so, it must handle
202 #ifdef ENCODE_SECTION_INFO
203 ENCODE_SECTION_INFO (decl);
207 /* Record at least one function has been defined. */
208 function_defined = 1;
211 /* Given NAME, a putative register name, discard any customary prefixes. */
214 strip_reg_name (name)
217 #ifdef REGISTER_PREFIX
218 if (!strncmp (name, REGISTER_PREFIX, strlen (REGISTER_PREFIX)))
219 name += strlen (REGISTER_PREFIX);
221 if (name[0] == '%' || name[0] == '#')
226 /* Decode an `asm' spec for a declaration as a register name.
227 Return the register number, or -1 if nothing specified,
228 or -2 if the ASMSPEC is not `cc' or `memory' and is not recognized,
229 or -3 if ASMSPEC is `cc' and is not recognized,
230 or -4 if ASMSPEC is `memory' and is not recognized.
231 Accept an exact spelling or a decimal number.
232 Prefixes such as % are optional. */
235 decode_reg_name (asmspec)
242 /* Get rid of confusing prefixes. */
243 asmspec = strip_reg_name (asmspec);
245 /* Allow a decimal number as a "register name". */
246 for (i = strlen (asmspec) - 1; i >= 0; i--)
247 if (! (asmspec[i] >= '0' && asmspec[i] <= '9'))
249 if (asmspec[0] != 0 && i < 0)
252 if (i < FIRST_PSEUDO_REGISTER && i >= 0)
258 for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
260 && ! strcmp (asmspec, strip_reg_name (reg_names[i])))
263 #ifdef ADDITIONAL_REGISTER_NAMES
265 static struct { char *name; int number; } table[]
266 = ADDITIONAL_REGISTER_NAMES;
268 for (i = 0; i < sizeof (table) / sizeof (table[0]); i++)
269 if (! strcmp (asmspec, table[i].name))
270 return table[i].number;
272 #endif /* ADDITIONAL_REGISTER_NAMES */
274 if (!strcmp (asmspec, "memory"))
277 if (!strcmp (asmspec, "cc"))
286 /* Create the DECL_RTL for a declaration for a static or external variable
287 or static or external function.
288 ASMSPEC, if not 0, is the string which the user specified
289 as the assembler symbol name.
290 TOP_LEVEL is nonzero if this is a file-scope variable.
292 This is never called for PARM_DECL nodes. */
295 make_decl_rtl (decl, asmspec, top_level)
301 int reg_number = decode_reg_name (asmspec);
303 if (DECL_ASSEMBLER_NAME (decl) != NULL_TREE)
304 name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
306 if (reg_number == -2)
308 /* ASMSPEC is given, and not the name of a register. */
309 name = (char *) obstack_alloc (saveable_obstack,
310 strlen (asmspec) + 2);
312 strcpy (&name[1], asmspec);
315 /* For a duplicate declaration, we can be called twice on the
316 same DECL node. Don't alter the RTL already made
317 unless the old mode is wrong (which can happen when
318 the previous rtl was made when the type was incomplete). */
319 if (DECL_RTL (decl) == 0
320 || GET_MODE (DECL_RTL (decl)) != DECL_MODE (decl))
324 /* First detect errors in declaring global registers. */
325 if (DECL_REGISTER (decl) && reg_number == -1)
326 error_with_decl (decl,
327 "register name not specified for `%s'");
328 else if (DECL_REGISTER (decl) && reg_number < 0)
329 error_with_decl (decl,
330 "invalid register name for `%s'");
331 else if ((reg_number >= 0 || reg_number == -3) && ! DECL_REGISTER (decl))
332 error_with_decl (decl,
333 "register name given for non-register variable `%s'");
334 else if (DECL_REGISTER (decl) && TREE_CODE (decl) == FUNCTION_DECL)
335 error ("function declared `register'");
336 else if (DECL_REGISTER (decl) && TYPE_MODE (TREE_TYPE (decl)) == BLKmode)
337 error_with_decl (decl, "data type of `%s' isn't suitable for a register");
338 else if (DECL_REGISTER (decl)
339 && ! HARD_REGNO_MODE_OK (reg_number, TYPE_MODE (TREE_TYPE (decl))))
340 error_with_decl (decl, "register number for `%s' isn't suitable for the data type");
341 /* Now handle properly declared static register variables. */
342 else if (DECL_REGISTER (decl))
345 #if 0 /* yylex should print the warning for this */
347 pedwarn ("ANSI C forbids global register variables");
349 if (DECL_INITIAL (decl) != 0 && top_level)
351 DECL_INITIAL (decl) = 0;
352 error ("global register variable has initial value");
354 if (fixed_regs[reg_number] == 0
355 && function_defined && top_level)
356 error ("global register variable follows a function definition");
357 if (TREE_THIS_VOLATILE (decl))
358 warning ("volatile register variables don't work as you might wish");
360 /* If the user specified one of the eliminables registers here,
361 e.g., FRAME_POINTER_REGNUM, we don't want to get this variable
362 confused with that register and be eliminated. Although this
363 usage is somewhat suspect, we nevertheless use the following
364 kludge to avoid setting DECL_RTL to frame_pointer_rtx. */
367 = gen_rtx (REG, DECL_MODE (decl), FIRST_PSEUDO_REGISTER);
368 REGNO (DECL_RTL (decl)) = reg_number;
369 REG_USERVAR_P (DECL_RTL (decl)) = 1;
373 /* Make this register fixed, so not usable for anything else. */
374 nregs = HARD_REGNO_NREGS (reg_number, DECL_MODE (decl));
376 global_regs[reg_number + --nregs] = 1;
381 /* Now handle ordinary static variables and functions (in memory).
382 Also handle vars declared register invalidly. */
383 if (DECL_RTL (decl) == 0)
385 /* Can't use just the variable's own name for a variable
386 whose scope is less than the whole file.
387 Concatenate a distinguishing number. */
388 if (!top_level && !DECL_EXTERNAL (decl) && asmspec == 0)
392 ASM_FORMAT_PRIVATE_NAME (label, name, var_labelno);
393 name = obstack_copy0 (saveable_obstack, label, strlen (label));
397 DECL_RTL (decl) = gen_rtx (MEM, DECL_MODE (decl),
398 gen_rtx (SYMBOL_REF, Pmode, name));
399 if (TREE_THIS_VOLATILE (decl)
400 || (flag_volatile_global && TREE_CODE (decl) == VAR_DECL
401 && TREE_PUBLIC (decl)))
402 MEM_VOLATILE_P (DECL_RTL (decl)) = 1;
403 if (TREE_READONLY (decl))
404 RTX_UNCHANGING_P (DECL_RTL (decl)) = 1;
405 MEM_IN_STRUCT_P (DECL_RTL (decl))
406 = (TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE
407 || TREE_CODE (TREE_TYPE (decl)) == RECORD_TYPE
408 || TREE_CODE (TREE_TYPE (decl)) == UNION_TYPE
409 || TREE_CODE (TREE_TYPE (decl)) == QUAL_UNION_TYPE);
411 /* Optionally set flags or add text to the name to record information
412 such as that it is a function name.
413 If the name is changed, the macro ASM_OUTPUT_LABELREF
414 will have to know how to strip this information.
415 And if it finds a * at the beginning after doing so,
416 it must handle that too. */
417 #ifdef ENCODE_SECTION_INFO
418 ENCODE_SECTION_INFO (decl);
424 /* Make the rtl for variable VAR be volatile.
425 Use this only for static variables. */
428 make_var_volatile (var)
431 if (GET_CODE (DECL_RTL (var)) != MEM)
434 MEM_VOLATILE_P (DECL_RTL (var)) = 1;
437 /* Output alignment directive to align for constant expression EXP. */
440 assemble_constant_align (exp)
445 /* Align the location counter as required by EXP's data type. */
446 align = TYPE_ALIGN (TREE_TYPE (exp));
447 #ifdef CONSTANT_ALIGNMENT
448 align = CONSTANT_ALIGNMENT (exp, align);
451 if (align > BITS_PER_UNIT)
452 ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT));
455 /* Output a string of literal assembler code
456 for an `asm' keyword used between functions. */
459 assemble_asm (string)
464 if (TREE_CODE (string) == ADDR_EXPR)
465 string = TREE_OPERAND (string, 0);
467 fprintf (asm_out_file, "\t%s\n", TREE_STRING_POINTER (string));
470 #if 0 /* This should no longer be needed, because
471 flag_gnu_linker should be 0 on these systems,
472 which should prevent any output
473 if ASM_OUTPUT_CONSTRUCTOR and ASM_OUTPUT_DESTRUCTOR are absent. */
474 #if !(defined(DBX_DEBUGGING_INFO) && !defined(FASCIST_ASSEMBLER))
475 #ifndef ASM_OUTPUT_CONSTRUCTOR
476 #define ASM_OUTPUT_CONSTRUCTOR(file, name)
478 #ifndef ASM_OUTPUT_DESTRUCTOR
479 #define ASM_OUTPUT_DESTRUCTOR(file, name)
484 /* Record an element in the table of global destructors.
485 How this is done depends on what sort of assembler and linker
488 NAME should be the name of a global function to be called
489 at exit time. This name is output using assemble_name. */
492 assemble_destructor (name)
495 #ifdef ASM_OUTPUT_DESTRUCTOR
496 ASM_OUTPUT_DESTRUCTOR (asm_out_file, name);
500 /* Now tell GNU LD that this is part of the static destructor set. */
501 /* This code works for any machine provided you use GNU as/ld. */
502 fprintf (asm_out_file, "%s \"___DTOR_LIST__\",22,0,0,", ASM_STABS_OP);
503 assemble_name (asm_out_file, name);
504 fputc ('\n', asm_out_file);
509 /* Likewise for global constructors. */
512 assemble_constructor (name)
515 #ifdef ASM_OUTPUT_CONSTRUCTOR
516 ASM_OUTPUT_CONSTRUCTOR (asm_out_file, name);
520 /* Now tell GNU LD that this is part of the static constructor set. */
521 /* This code works for any machine provided you use GNU as/ld. */
522 fprintf (asm_out_file, "%s \"___CTOR_LIST__\",22,0,0,", ASM_STABS_OP);
523 assemble_name (asm_out_file, name);
524 fputc ('\n', asm_out_file);
529 /* Likewise for entries we want to record for garbage collection.
530 Garbage collection is still under development. */
533 assemble_gc_entry (name)
536 #ifdef ASM_OUTPUT_GC_ENTRY
537 ASM_OUTPUT_GC_ENTRY (asm_out_file, name);
541 /* Now tell GNU LD that this is part of the static constructor set. */
542 fprintf (asm_out_file, "%s \"___PTR_LIST__\",22,0,0,", ASM_STABS_OP);
543 assemble_name (asm_out_file, name);
544 fputc ('\n', asm_out_file);
549 /* Output assembler code for the constant pool of a function and associated
550 with defining the name of the function. DECL describes the function.
551 NAME is the function's name. For the constant pool, we use the current
552 constant pool data. */
555 assemble_start_function (decl, fnname)
561 /* The following code does not need preprocessing in the assembler. */
565 output_constant_pool (fnname, decl);
570 /* Tell assembler to move to target machine's alignment for functions. */
571 align = floor_log2 (FUNCTION_BOUNDARY / BITS_PER_UNIT);
573 ASM_OUTPUT_ALIGN (asm_out_file, align);
575 #ifdef ASM_OUTPUT_FUNCTION_PREFIX
576 ASM_OUTPUT_FUNCTION_PREFIX (asm_out_file, fnname);
579 #ifdef SDB_DEBUGGING_INFO
580 /* Output SDB definition of the function. */
581 if (write_symbols == SDB_DEBUG)
582 sdbout_mark_begin_function ();
585 #ifdef DBX_DEBUGGING_INFO
586 /* Output DBX definition of the function. */
587 if (write_symbols == DBX_DEBUG)
588 dbxout_begin_function (decl);
591 /* Make function name accessible from other files, if appropriate. */
593 if (TREE_PUBLIC (decl))
595 if (!first_global_object_name)
596 STRIP_NAME_ENCODING (first_global_object_name, fnname);
597 ASM_GLOBALIZE_LABEL (asm_out_file, fnname);
600 /* Do any machine/system dependent processing of the function name */
601 #ifdef ASM_DECLARE_FUNCTION_NAME
602 ASM_DECLARE_FUNCTION_NAME (asm_out_file, fnname, current_function_decl);
604 /* Standard thing is just output label for the function. */
605 ASM_OUTPUT_LABEL (asm_out_file, fnname);
606 #endif /* ASM_DECLARE_FUNCTION_NAME */
609 /* Output assembler code associated with defining the size of the
610 function. DECL describes the function. NAME is the function's name. */
613 assemble_end_function (decl, fnname)
617 #ifdef ASM_DECLARE_FUNCTION_SIZE
618 ASM_DECLARE_FUNCTION_SIZE (asm_out_file, fnname, decl);
622 /* Assemble code to leave SIZE bytes of zeros. */
625 assemble_zeros (size)
628 #ifdef ASM_NO_SKIP_IN_TEXT
629 /* The `space' pseudo in the text section outputs nop insns rather than 0s,
630 so we must output 0s explicitly in the text section. */
631 if (ASM_NO_SKIP_IN_TEXT && in_text_section ())
635 for (i = 0; i < size - 20; i += 20)
638 fprintf (asm_out_file,
639 "%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);
641 fprintf (asm_out_file,
642 "\tbyte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n");
648 fprintf (asm_out_file, "%s 0", ASM_BYTE_OP);
650 fprintf (asm_out_file, "\tbyte 0");
653 for (; i < size; i++)
654 fprintf (asm_out_file, ",0");
655 fprintf (asm_out_file, "\n");
661 ASM_OUTPUT_SKIP (asm_out_file, size);
664 /* Assemble a string constant with the specified C string as contents. */
667 assemble_string (p, size)
675 /* If the string is very long, split it up. */
679 int thissize = size - pos;
680 if (thissize > maximum)
683 ASM_OUTPUT_ASCII (asm_out_file, p, thissize);
690 /* Assemble everything that is needed for a variable or function declaration.
691 Not used for automatic variables, and not used for function definitions.
692 Should not be called for variables of incomplete structure type.
694 TOP_LEVEL is nonzero if this variable has file scope.
695 AT_END is nonzero if this is the special handling, at end of compilation,
696 to define things that have had only tentative definitions. */
699 assemble_variable (decl, top_level, at_end)
709 if (GET_CODE (DECL_RTL (decl)) == REG)
711 /* Do output symbol info for global register variables, but do nothing
714 if (TREE_ASM_WRITTEN (decl))
716 TREE_ASM_WRITTEN (decl) = 1;
718 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
719 /* File-scope global variables are output here. */
720 if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
722 dbxout_symbol (decl, 0);
724 #ifdef SDB_DEBUGGING_INFO
725 if (write_symbols == SDB_DEBUG && top_level
726 /* Leave initialized global vars for end of compilation;
727 see comment in compile_file. */
728 && (TREE_PUBLIC (decl) == 0 || DECL_INITIAL (decl) == 0))
729 sdbout_symbol (decl, 0);
732 /* Don't output any DWARF debugging information for variables here.
733 In the case of local variables, the information for them is output
734 when we do our recursive traversal of the tree representation for
735 the entire containing function. In the case of file-scope variables,
736 we output information for all of them at the very end of compilation
737 while we are doing our final traversal of the chain of file-scope
743 /* Normally no need to say anything here for external references,
744 since assemble_external is called by the langauge-specific code
745 when a declaration is first seen. */
747 if (DECL_EXTERNAL (decl))
750 /* Output no assembler code for a function declaration.
751 Only definitions of functions output anything. */
753 if (TREE_CODE (decl) == FUNCTION_DECL)
756 /* If type was incomplete when the variable was declared,
757 see if it is complete now. */
759 if (DECL_SIZE (decl) == 0)
760 layout_decl (decl, 0);
762 /* Still incomplete => don't allocate it; treat the tentative defn
763 (which is what it must have been) as an `extern' reference. */
765 if (DECL_SIZE (decl) == 0)
767 error_with_file_and_line (DECL_SOURCE_FILE (decl),
768 DECL_SOURCE_LINE (decl),
769 "storage size of `%s' isn't known",
770 IDENTIFIER_POINTER (DECL_NAME (decl)));
774 /* The first declaration of a variable that comes through this function
775 decides whether it is global (in C, has external linkage)
776 or local (in C, has internal linkage). So do nothing more
777 if this function has already run. */
779 if (TREE_ASM_WRITTEN (decl))
782 TREE_ASM_WRITTEN (decl) = 1;
784 #ifdef DBX_DEBUGGING_INFO
785 /* File-scope global variables are output here. */
786 if (write_symbols == DBX_DEBUG && top_level)
787 dbxout_symbol (decl, 0);
789 #ifdef SDB_DEBUGGING_INFO
790 if (write_symbols == SDB_DEBUG && top_level
791 /* Leave initialized global vars for end of compilation;
792 see comment in compile_file. */
793 && (TREE_PUBLIC (decl) == 0 || DECL_INITIAL (decl) == 0))
794 sdbout_symbol (decl, 0);
797 /* Don't output any DWARF debugging information for variables here.
798 In the case of local variables, the information for them is output
799 when we do our recursive traversal of the tree representation for
800 the entire containing function. In the case of file-scope variables,
801 we output information for all of them at the very end of compilation
802 while we are doing our final traversal of the chain of file-scope
805 /* If storage size is erroneously variable, just continue.
806 Error message was already made. */
808 if (TREE_CODE (DECL_SIZE (decl)) != INTEGER_CST)
813 /* This is better than explicit arithmetic, since it avoids overflow. */
814 size_tree = size_binop (CEIL_DIV_EXPR,
815 DECL_SIZE (decl), size_int (BITS_PER_UNIT));
817 if (TREE_INT_CST_HIGH (size_tree) != 0)
819 error_with_decl (decl, "size of variable `%s' is too large");
823 name = XSTR (XEXP (DECL_RTL (decl), 0), 0);
825 /* Handle uninitialized definitions. */
827 /* ANSI specifies that a tentative definition which is not merged with
828 a non-tentative definition behaves exactly like a definition with an
829 initializer equal to zero. (Section 3.7.2)
830 -fno-common gives strict ANSI behavior. Usually you don't want it. */
832 && (DECL_INITIAL (decl) == 0 || DECL_INITIAL (decl) == error_mark_node))
834 int size = TREE_INT_CST_LOW (size_tree);
837 if (TREE_INT_CST_HIGH (size_tree) != 0)
838 error_with_decl (decl, "size of variable `%s' is too large");
839 /* Don't allocate zero bytes of common,
840 since that means "undefined external" in the linker. */
841 if (size == 0) rounded = 1;
842 /* Round size up to multiple of BIGGEST_ALIGNMENT bits
843 so that each uninitialized object starts on such a boundary. */
844 rounded += (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - 1;
845 rounded = (rounded / (BIGGEST_ALIGNMENT / BITS_PER_UNIT)
846 * (BIGGEST_ALIGNMENT / BITS_PER_UNIT));
848 if (flag_shared_data)
851 if (TREE_PUBLIC (decl))
853 #ifdef ASM_OUTPUT_SHARED_COMMON
854 if (flag_shared_data)
855 ASM_OUTPUT_SHARED_COMMON (asm_out_file, name, size, rounded);
858 #ifdef ASM_OUTPUT_ALIGNED_COMMON
859 ASM_OUTPUT_ALIGNED_COMMON (asm_out_file, name, size,
862 ASM_OUTPUT_COMMON (asm_out_file, name, size, rounded);
867 #ifdef ASM_OUTPUT_SHARED_LOCAL
868 if (flag_shared_data)
869 ASM_OUTPUT_SHARED_LOCAL (asm_out_file, name, size, rounded);
872 #ifdef ASM_OUTPUT_ALIGNED_LOCAL
873 ASM_OUTPUT_ALIGNED_LOCAL (asm_out_file, name, size,
876 ASM_OUTPUT_LOCAL (asm_out_file, name, size, rounded);
882 /* Handle initialized definitions. */
884 /* First make the assembler name(s) global if appropriate. */
885 if (TREE_PUBLIC (decl) && DECL_NAME (decl))
887 if (!first_global_object_name)
888 STRIP_NAME_ENCODING(first_global_object_name, name);
889 ASM_GLOBALIZE_LABEL (asm_out_file, name);
892 for (d = equivalents; d; d = TREE_CHAIN (d))
894 tree e = TREE_VALUE (d);
895 if (TREE_PUBLIC (e) && DECL_NAME (e))
896 ASM_GLOBALIZE_LABEL (asm_out_file,
897 XSTR (XEXP (DECL_RTL (e), 0), 0));
901 /* Output any data that we will need to use the address of. */
902 if (DECL_INITIAL (decl))
903 reloc = output_addressed_constants (DECL_INITIAL (decl));
905 /* Switch to the proper section for this data. */
906 #ifdef SELECT_SECTION
907 SELECT_SECTION (decl, reloc);
909 if (TREE_READONLY (decl)
910 && ! TREE_THIS_VOLATILE (decl)
911 && ! (flag_pic && reloc))
912 readonly_data_section ();
917 /* Compute and output the alignment of this data. */
919 align = DECL_ALIGN (decl);
920 /* Some object file formats have a maximum alignment which they support.
921 In particular, a.out format supports a maximum alignment of 4. */
922 #ifndef MAX_OFILE_ALIGNMENT
923 #define MAX_OFILE_ALIGNMENT BIGGEST_ALIGNMENT
925 if (align > MAX_OFILE_ALIGNMENT)
927 warning_with_decl (decl,
928 "alignment of `%s' is greater than maximum object file alignment");
929 align = MAX_OFILE_ALIGNMENT;
931 #ifdef DATA_ALIGNMENT
932 /* On some machines, it is good to increase alignment sometimes. */
933 align = DATA_ALIGNMENT (TREE_TYPE (decl), align);
935 #ifdef CONSTANT_ALIGNMENT
936 if (DECL_INITIAL (decl))
937 align = CONSTANT_ALIGNMENT (DECL_INITIAL (decl), align);
940 /* Reset the alignment in case we have made it tighter, so we can benefit
941 from it in get_pointer_alignment. */
942 DECL_ALIGN (decl) = align;
944 if (align > BITS_PER_UNIT)
945 ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT));
947 /* Do any machine/system dependent processing of the object. */
948 #ifdef ASM_DECLARE_OBJECT_NAME
949 ASM_DECLARE_OBJECT_NAME (asm_out_file, name, decl);
951 /* Standard thing is just output label for the object. */
952 ASM_OUTPUT_LABEL (asm_out_file, name);
953 #endif /* ASM_DECLARE_OBJECT_NAME */
956 for (d = equivalents; d; d = TREE_CHAIN (d))
958 tree e = TREE_VALUE (d);
959 ASM_OUTPUT_LABEL (asm_out_file, XSTR (XEXP (DECL_RTL (e), 0), 0));
963 if (DECL_INITIAL (decl))
964 /* Output the actual data. */
965 output_constant (DECL_INITIAL (decl),
966 int_size_in_bytes (TREE_TYPE (decl)));
968 /* Leave space for it. */
969 assemble_zeros (int_size_in_bytes (TREE_TYPE (decl)));
972 #ifdef XCOFF_DEBUGGING_INFO
973 /* Unfortunately, the IBM assembler cannot handle stabx before the actual
974 declaration. When something like ".stabx "aa:S-2",aa,133,0" is emitted
975 and `aa' hasn't been output yet, the assembler generates a stab entry with
976 a value of zero, in addition to creating an unnecessary external entry
977 for `aa'. Hence, we must postpone dbxout_symbol to here at the end. */
979 /* File-scope global variables are output here. */
980 if (write_symbols == XCOFF_DEBUG && top_level)
981 dbxout_symbol (decl, 0);
983 /* There must be a statement after a label. */
988 /* Output something to declare an external symbol to the assembler.
989 (Most assemblers don't need this, so we normally output nothing.)
990 Do nothing if DECL is not external. */
993 assemble_external (decl)
996 #ifdef ASM_OUTPUT_EXTERNAL
997 if (TREE_CODE_CLASS (TREE_CODE (decl)) == 'd'
998 && DECL_EXTERNAL (decl) && TREE_PUBLIC (decl))
1000 rtx rtl = DECL_RTL (decl);
1002 if (GET_CODE (rtl) == MEM && GET_CODE (XEXP (rtl, 0)) == SYMBOL_REF
1003 && ! SYMBOL_REF_USED (XEXP (rtl, 0)))
1005 /* Some systems do require some output. */
1006 SYMBOL_REF_USED (XEXP (rtl, 0)) = 1;
1007 ASM_OUTPUT_EXTERNAL (asm_out_file, decl, XSTR (XEXP (rtl, 0), 0));
1013 /* Similar, for calling a library function FUN. */
1016 assemble_external_libcall (fun)
1019 #ifdef ASM_OUTPUT_EXTERNAL_LIBCALL
1020 /* Declare library function name external when first used, if nec. */
1021 if (! SYMBOL_REF_USED (fun))
1023 SYMBOL_REF_USED (fun) = 1;
1024 ASM_OUTPUT_EXTERNAL_LIBCALL (asm_out_file, fun);
1029 /* Declare the label NAME global. */
1032 assemble_global (name)
1035 ASM_GLOBALIZE_LABEL (asm_out_file, name);
1038 /* Assemble a label named NAME. */
1041 assemble_label (name)
1044 ASM_OUTPUT_LABEL (asm_out_file, name);
1047 /* Output to FILE a reference to the assembler name of a C-level name NAME.
1048 If NAME starts with a *, the rest of NAME is output verbatim.
1049 Otherwise NAME is transformed in an implementation-defined way
1050 (usually by the addition of an underscore).
1051 Many macros in the tm file are defined to call this function. */
1054 assemble_name (file, name)
1059 fputs (&name[1], file);
1061 ASM_OUTPUT_LABELREF (file, name);
1064 /* Allocate SIZE bytes writable static space with a gensym name
1065 and return an RTX to refer to its address. */
1068 assemble_static_space (size)
1074 /* Round size up to multiple of BIGGEST_ALIGNMENT bits
1075 so that each uninitialized object starts on such a boundary. */
1076 int rounded = ((size + (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - 1)
1077 / (BIGGEST_ALIGNMENT / BITS_PER_UNIT)
1078 * (BIGGEST_ALIGNMENT / BITS_PER_UNIT));
1081 if (flag_shared_data)
1085 ASM_GENERATE_INTERNAL_LABEL (name, "LF", const_labelno);
1088 namestring = (char *) obstack_alloc (saveable_obstack,
1090 strcpy (namestring, name);
1092 x = gen_rtx (SYMBOL_REF, Pmode, namestring);
1093 #ifdef ASM_OUTPUT_ALIGNED_LOCAL
1094 ASM_OUTPUT_ALIGNED_LOCAL (asm_out_file, name, size, BIGGEST_ALIGNMENT);
1096 ASM_OUTPUT_LOCAL (asm_out_file, name, size, rounded);
1101 /* Assemble the static constant template for function entry trampolines.
1102 This is done at most once per compilation.
1103 Returns an RTX for the address of the template. */
1106 assemble_trampoline_template ()
1112 /* By default, put trampoline templates in read-only data section. */
1114 #ifdef TRAMPOLINE_SECTION
1115 TRAMPOLINE_SECTION ();
1117 readonly_data_section ();
1120 /* Write the assembler code to define one. */
1121 align = floor_log2 (FUNCTION_BOUNDARY / BITS_PER_UNIT);
1123 ASM_OUTPUT_ALIGN (asm_out_file, align);
1125 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LTRAMP", 0);
1126 TRAMPOLINE_TEMPLATE (asm_out_file);
1128 /* Record the rtl to refer to it. */
1129 ASM_GENERATE_INTERNAL_LABEL (label, "LTRAMP", 0);
1131 = (char *) obstack_copy0 (&permanent_obstack, label, strlen (label));
1132 return gen_rtx (SYMBOL_REF, Pmode, name);
1135 /* Assemble the integer constant X into an object of SIZE bytes.
1136 X must be either a CONST_INT or CONST_DOUBLE.
1138 Return 1 if we were able to output the constant, otherwise 0. If FORCE is
1139 non-zero, abort if we can't output the constant. */
1142 assemble_integer (x, size, force)
1147 /* First try to use the standard 1, 2, 4, 8, and 16 byte
1148 ASM_OUTPUT... macros. */
1152 #ifdef ASM_OUTPUT_CHAR
1154 ASM_OUTPUT_CHAR (asm_out_file, x);
1158 #ifdef ASM_OUTPUT_SHORT
1160 ASM_OUTPUT_SHORT (asm_out_file, x);
1164 #ifdef ASM_OUTPUT_INT
1166 ASM_OUTPUT_INT (asm_out_file, x);
1170 #ifdef ASM_OUTPUT_DOUBLE_INT
1172 ASM_OUTPUT_DOUBLE_INT (asm_out_file, x);
1176 #ifdef ASM_OUTPUT_QUADRUPLE_INT
1178 ASM_OUTPUT_QUADRUPLE_INT (asm_out_file, x);
1183 /* If we couldn't do it that way, there are two other possibilities: First,
1184 if the machine can output an explicit byte and this is a 1 byte constant,
1185 we can use ASM_OUTPUT_BYTE. */
1187 #ifdef ASM_OUTPUT_BYTE
1188 if (size == 1 && GET_CODE (x) == CONST_INT)
1190 ASM_OUTPUT_BYTE (asm_out_file, INTVAL (x));
1195 /* Finally, if SIZE is larger than a single word, try to output the constant
1196 one word at a time. */
1198 if (size > UNITS_PER_WORD)
1201 enum machine_mode mode
1202 = mode_for_size (size * BITS_PER_UNIT, MODE_INT, 0);
1205 for (i = 0; i < size / UNITS_PER_WORD; i++)
1207 word = operand_subword (x, i, 0, mode);
1212 if (! assemble_integer (word, UNITS_PER_WORD, 0))
1216 if (i == size / UNITS_PER_WORD)
1218 /* If we output at least one word and then could not finish,
1219 there is no valid way to continue. */
1230 /* Assemble the floating-point constant D into an object of size MODE. */
1233 assemble_real (d, mode)
1235 enum machine_mode mode;
1237 jmp_buf output_constant_handler;
1239 if (setjmp (output_constant_handler))
1241 error ("floating point trap outputting a constant");
1242 #ifdef REAL_IS_NOT_DOUBLE
1243 bzero (&d, sizeof d);
1250 set_float_handler (output_constant_handler);
1254 #ifdef ASM_OUTPUT_BYTE_FLOAT
1256 ASM_OUTPUT_BYTE_FLOAT (asm_out_file, d);
1259 #ifdef ASM_OUTPUT_SHORT_FLOAT
1261 ASM_OUTPUT_SHORT_FLOAT (asm_out_file, d);
1264 #ifdef ASM_OUTPUT_FLOAT
1266 ASM_OUTPUT_FLOAT (asm_out_file, d);
1270 #ifdef ASM_OUTPUT_DOUBLE
1272 ASM_OUTPUT_DOUBLE (asm_out_file, d);
1276 #ifdef ASM_OUTPUT_LONG_DOUBLE
1279 ASM_OUTPUT_LONG_DOUBLE (asm_out_file, d);
1287 set_float_handler (NULL_PTR);
1290 /* Here we combine duplicate floating constants to make
1291 CONST_DOUBLE rtx's, and force those out to memory when necessary. */
1293 /* Chain of all CONST_DOUBLE rtx's constructed for the current function.
1294 They are chained through the CONST_DOUBLE_CHAIN.
1295 A CONST_DOUBLE rtx has CONST_DOUBLE_MEM != cc0_rtx iff it is on this chain.
1296 In that case, CONST_DOUBLE_MEM is either a MEM,
1297 or const0_rtx if no MEM has been made for this CONST_DOUBLE yet.
1299 (CONST_DOUBLE_MEM is used only for top-level functions.
1300 See force_const_mem for explanation.) */
1302 static rtx const_double_chain;
1304 /* Return a CONST_DOUBLE for a value specified as a pair of ints.
1305 For an integer, I0 is the low-order word and I1 is the high-order word.
1306 For a real number, I0 is the word with the low address
1307 and I1 is the word with the high address. */
1310 immed_double_const (i0, i1, mode)
1311 HOST_WIDE_INT i0, i1;
1312 enum machine_mode mode;
1315 int in_current_obstack;
1317 if (GET_MODE_CLASS (mode) == MODE_INT
1318 || GET_MODE_CLASS (mode) == MODE_PARTIAL_INT)
1320 /* We clear out all bits that don't belong in MODE, unless they and our
1321 sign bit are all one. So we get either a reasonable negative value
1322 or a reasonable unsigned value for this mode. */
1323 int width = GET_MODE_BITSIZE (mode);
1324 if (width < HOST_BITS_PER_WIDE_INT
1325 && ((i0 & ((HOST_WIDE_INT) (-1) << (width - 1)))
1326 != ((HOST_WIDE_INT) (-1) << (width - 1))))
1327 i0 &= ((HOST_WIDE_INT) 1 << width) - 1, i1 = 0;
1328 else if (width == HOST_BITS_PER_WIDE_INT
1329 && ! (i1 == ~0 && i0 < 0))
1331 else if (width > 2 * HOST_BITS_PER_WIDE_INT)
1332 /* We cannot represent this value as a constant. */
1335 /* If MODE fits within HOST_BITS_PER_WIDE_INT, always use a CONST_INT.
1337 ??? Strictly speaking, this is wrong if we create a CONST_INT
1338 for a large unsigned constant with the size of MODE being
1339 HOST_BITS_PER_WIDE_INT and later try to interpret that constant in a
1340 wider mode. In that case we will mis-interpret it as a negative
1343 Unfortunately, the only alternative is to make a CONST_DOUBLE
1344 for any constant in any mode if it is an unsigned constant larger
1345 than the maximum signed integer in an int on the host. However,
1346 doing this will break everyone that always expects to see a CONST_INT
1347 for SImode and smaller.
1349 We have always been making CONST_INTs in this case, so nothing new
1352 if (width <= HOST_BITS_PER_WIDE_INT)
1353 i1 = (i0 < 0) ? ~0 : 0;
1355 /* If this integer fits in one word, return a CONST_INT. */
1356 if ((i1 == 0 && i0 >= 0)
1357 || (i1 == ~0 && i0 < 0))
1358 return GEN_INT (i0);
1360 /* We use VOIDmode for integers. */
1364 /* Search the chain for an existing CONST_DOUBLE with the right value.
1365 If one is found, return it. */
1367 for (r = const_double_chain; r; r = CONST_DOUBLE_CHAIN (r))
1368 if (CONST_DOUBLE_LOW (r) == i0 && CONST_DOUBLE_HIGH (r) == i1
1369 && GET_MODE (r) == mode)
1372 /* No; make a new one and add it to the chain.
1374 We may be called by an optimizer which may be discarding any memory
1375 allocated during its processing (such as combine and loop). However,
1376 we will be leaving this constant on the chain, so we cannot tolerate
1377 freed memory. So switch to saveable_obstack for this allocation
1378 and then switch back if we were in current_obstack. */
1380 push_obstacks_nochange ();
1381 rtl_in_saveable_obstack ();
1382 r = gen_rtx (CONST_DOUBLE, mode, 0, i0, i1);
1385 /* Don't touch const_double_chain in nested function;
1386 see force_const_mem. */
1387 if (outer_function_chain == 0)
1389 CONST_DOUBLE_CHAIN (r) = const_double_chain;
1390 const_double_chain = r;
1393 /* Store const0_rtx in mem-slot since this CONST_DOUBLE is on the chain.
1394 Actual use of mem-slot is only through force_const_mem. */
1396 CONST_DOUBLE_MEM (r) = const0_rtx;
1401 /* Return a CONST_DOUBLE for a specified `double' value
1402 and machine mode. */
1405 immed_real_const_1 (d, mode)
1407 enum machine_mode mode;
1409 union real_extract u;
1411 int in_current_obstack;
1413 /* Get the desired `double' value as a sequence of ints
1414 since that is how they are stored in a CONST_DOUBLE. */
1418 /* Detect special cases. */
1420 /* Avoid REAL_VALUES_EQUAL here in order to distinguish minus zero. */
1421 if (!bcmp (&dconst0, &d, sizeof d))
1422 return CONST0_RTX (mode);
1423 /* Check for NaN first, because some ports (specifically the i386) do not
1424 emit correct ieee-fp code by default, and thus will generate a core
1425 dump here if we pass a NaN to REAL_VALUES_EQUAL and if REAL_VALUES_EQUAL
1426 does a floating point comparison. */
1427 else if (! REAL_VALUE_ISNAN (d) && REAL_VALUES_EQUAL (dconst1, d))
1428 return CONST1_RTX (mode);
1430 if (sizeof u == 2 * sizeof (HOST_WIDE_INT))
1431 return immed_double_const (u.i[0], u.i[1], mode);
1433 /* The rest of this function handles the case where
1434 a float value requires more than 2 ints of space.
1435 It will be deleted as dead code on machines that don't need it. */
1437 /* Search the chain for an existing CONST_DOUBLE with the right value.
1438 If one is found, return it. */
1440 for (r = const_double_chain; r; r = CONST_DOUBLE_CHAIN (r))
1441 if (! bcmp (&CONST_DOUBLE_LOW (r), &u, sizeof u)
1442 && GET_MODE (r) == mode)
1445 /* No; make a new one and add it to the chain.
1447 We may be called by an optimizer which may be discarding any memory
1448 allocated during its processing (such as combine and loop). However,
1449 we will be leaving this constant on the chain, so we cannot tolerate
1450 freed memory. So switch to saveable_obstack for this allocation
1451 and then switch back if we were in current_obstack. */
1453 push_obstacks_nochange ();
1454 rtl_in_saveable_obstack ();
1455 r = rtx_alloc (CONST_DOUBLE);
1457 bcopy (&u, &CONST_DOUBLE_LOW (r), sizeof u);
1460 /* Don't touch const_double_chain in nested function;
1461 see force_const_mem. */
1462 if (outer_function_chain == 0)
1464 CONST_DOUBLE_CHAIN (r) = const_double_chain;
1465 const_double_chain = r;
1468 /* Store const0_rtx in CONST_DOUBLE_MEM since this CONST_DOUBLE is on the
1469 chain, but has not been allocated memory. Actual use of CONST_DOUBLE_MEM
1470 is only through force_const_mem. */
1472 CONST_DOUBLE_MEM (r) = const0_rtx;
1477 /* Return a CONST_DOUBLE rtx for a value specified by EXP,
1478 which must be a REAL_CST tree node. */
1481 immed_real_const (exp)
1484 return immed_real_const_1 (TREE_REAL_CST (exp), TYPE_MODE (TREE_TYPE (exp)));
1487 /* At the end of a function, forget the memory-constants
1488 previously made for CONST_DOUBLEs. Mark them as not on real_constant_chain.
1489 Also clear out real_constant_chain and clear out all the chain-pointers. */
1492 clear_const_double_mem ()
1494 register rtx r, next;
1496 /* Don't touch CONST_DOUBLE_MEM for nested functions.
1497 See force_const_mem for explanation. */
1498 if (outer_function_chain != 0)
1501 for (r = const_double_chain; r; r = next)
1503 next = CONST_DOUBLE_CHAIN (r);
1504 CONST_DOUBLE_CHAIN (r) = 0;
1505 CONST_DOUBLE_MEM (r) = cc0_rtx;
1507 const_double_chain = 0;
1510 /* Given an expression EXP with a constant value,
1511 reduce it to the sum of an assembler symbol and an integer.
1512 Store them both in the structure *VALUE.
1513 Abort if EXP does not reduce. */
1518 HOST_WIDE_INT offset;
1522 decode_addr_const (exp, value)
1524 struct addr_const *value;
1526 register tree target = TREE_OPERAND (exp, 0);
1527 register int offset = 0;
1532 if (TREE_CODE (target) == COMPONENT_REF
1533 && (TREE_CODE (DECL_FIELD_BITPOS (TREE_OPERAND (target, 1)))
1536 offset += TREE_INT_CST_LOW (DECL_FIELD_BITPOS (TREE_OPERAND (target, 1))) / BITS_PER_UNIT;
1537 target = TREE_OPERAND (target, 0);
1539 else if (TREE_CODE (target) == ARRAY_REF)
1541 if (TREE_CODE (TREE_OPERAND (target, 1)) != INTEGER_CST
1542 || TREE_CODE (TYPE_SIZE (TREE_TYPE (target))) != INTEGER_CST)
1544 offset += ((TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (target)))
1545 * TREE_INT_CST_LOW (TREE_OPERAND (target, 1)))
1547 target = TREE_OPERAND (target, 0);
1553 switch (TREE_CODE (target))
1557 x = DECL_RTL (target);
1561 x = gen_rtx (MEM, FUNCTION_MODE,
1562 gen_rtx (LABEL_REF, VOIDmode,
1563 label_rtx (TREE_OPERAND (exp, 0))));
1570 x = TREE_CST_RTL (target);
1577 if (GET_CODE (x) != MEM)
1582 value->offset = offset;
1585 /* Uniquize all constants that appear in memory.
1586 Each constant in memory thus far output is recorded
1587 in `const_hash_table' with a `struct constant_descriptor'
1588 that contains a polish representation of the value of
1591 We cannot store the trees in the hash table
1592 because the trees may be temporary. */
1594 struct constant_descriptor
1596 struct constant_descriptor *next;
1602 #define MAX_HASH_TABLE 1009
1603 static struct constant_descriptor *const_hash_table[MAX_HASH_TABLE];
1605 /* Compute a hash code for a constant expression. */
1612 register int len, hi, i;
1613 register enum tree_code code = TREE_CODE (exp);
1615 if (code == INTEGER_CST)
1617 p = (char *) &TREE_INT_CST_LOW (exp);
1618 len = 2 * sizeof TREE_INT_CST_LOW (exp);
1620 else if (code == REAL_CST)
1622 p = (char *) &TREE_REAL_CST (exp);
1623 len = sizeof TREE_REAL_CST (exp);
1625 else if (code == STRING_CST)
1626 p = TREE_STRING_POINTER (exp), len = TREE_STRING_LENGTH (exp);
1627 else if (code == COMPLEX_CST)
1628 return const_hash (TREE_REALPART (exp)) * 5
1629 + const_hash (TREE_IMAGPART (exp));
1630 else if (code == CONSTRUCTOR)
1634 /* For record type, include the type in the hashing.
1635 We do not do so for array types
1636 because (1) the sizes of the elements are sufficient
1637 and (2) distinct array types can have the same constructor.
1638 Instead, we include the array size because the constructor could
1640 if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE)
1641 hi = ((HOST_WIDE_INT) TREE_TYPE (exp) & ((1 << HASHBITS) - 1))
1644 hi = ((5 + int_size_in_bytes (TREE_TYPE (exp)))
1645 & ((1 << HASHBITS) - 1)) % MAX_HASH_TABLE;
1647 for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link))
1648 if (TREE_VALUE (link))
1649 hi = (hi * 603 + const_hash (TREE_VALUE (link))) % MAX_HASH_TABLE;
1653 else if (code == ADDR_EXPR)
1655 struct addr_const value;
1656 decode_addr_const (exp, &value);
1657 if (GET_CODE (value.base) == SYMBOL_REF)
1659 /* Don't hash the address of the SYMBOL_REF;
1660 only use the offset and the symbol name. */
1662 p = XSTR (value.base, 0);
1663 for (i = 0; p[i] != 0; i++)
1664 hi = ((hi * 613) + (unsigned)(p[i]));
1666 else if (GET_CODE (value.base) == LABEL_REF)
1667 hi = value.offset + CODE_LABEL_NUMBER (XEXP (value.base, 0)) * 13;
1669 hi &= (1 << HASHBITS) - 1;
1670 hi %= MAX_HASH_TABLE;
1673 else if (code == PLUS_EXPR || code == MINUS_EXPR)
1674 return const_hash (TREE_OPERAND (exp, 0)) * 9
1675 + const_hash (TREE_OPERAND (exp, 1));
1676 else if (code == NOP_EXPR || code == CONVERT_EXPR)
1677 return const_hash (TREE_OPERAND (exp, 0)) * 7 + 2;
1679 /* Compute hashing function */
1681 for (i = 0; i < len; i++)
1682 hi = ((hi * 613) + (unsigned)(p[i]));
1684 hi &= (1 << HASHBITS) - 1;
1685 hi %= MAX_HASH_TABLE;
1689 /* Compare a constant expression EXP with a constant-descriptor DESC.
1690 Return 1 if DESC describes a constant with the same value as EXP. */
1693 compare_constant (exp, desc)
1695 struct constant_descriptor *desc;
1697 return 0 != compare_constant_1 (exp, desc->contents);
1700 /* Compare constant expression EXP with a substring P of a constant descriptor.
1701 If they match, return a pointer to the end of the substring matched.
1702 If they do not match, return 0.
1704 Since descriptors are written in polish prefix notation,
1705 this function can be used recursively to test one operand of EXP
1706 against a subdescriptor, and if it succeeds it returns the
1707 address of the subdescriptor for the next operand. */
1710 compare_constant_1 (exp, p)
1714 register char *strp;
1716 register enum tree_code code = TREE_CODE (exp);
1718 if (code != (enum tree_code) *p++)
1721 if (code == INTEGER_CST)
1723 /* Integer constants are the same only if the same width of type. */
1724 if (*p++ != TYPE_PRECISION (TREE_TYPE (exp)))
1726 strp = (char *) &TREE_INT_CST_LOW (exp);
1727 len = 2 * sizeof TREE_INT_CST_LOW (exp);
1729 else if (code == REAL_CST)
1731 /* Real constants are the same only if the same width of type. */
1732 if (*p++ != TYPE_PRECISION (TREE_TYPE (exp)))
1734 strp = (char *) &TREE_REAL_CST (exp);
1735 len = sizeof TREE_REAL_CST (exp);
1737 else if (code == STRING_CST)
1739 if (flag_writable_strings)
1741 strp = TREE_STRING_POINTER (exp);
1742 len = TREE_STRING_LENGTH (exp);
1743 if (bcmp (&TREE_STRING_LENGTH (exp), p,
1744 sizeof TREE_STRING_LENGTH (exp)))
1746 p += sizeof TREE_STRING_LENGTH (exp);
1748 else if (code == COMPLEX_CST)
1750 p = compare_constant_1 (TREE_REALPART (exp), p);
1751 if (p == 0) return 0;
1752 p = compare_constant_1 (TREE_IMAGPART (exp), p);
1755 else if (code == CONSTRUCTOR)
1758 int length = list_length (CONSTRUCTOR_ELTS (exp));
1761 if (bcmp (&length, p, sizeof length))
1765 /* For record constructors, insist that the types match.
1766 For arrays, just verify both constructors are for arrays. */
1767 if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE)
1768 type = TREE_TYPE (exp);
1771 if (bcmp (&type, p, sizeof type))
1775 /* For arrays, insist that the size in bytes match. */
1776 if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE)
1778 int size = int_size_in_bytes (TREE_TYPE (exp));
1779 if (bcmp (&size, p, sizeof size))
1784 for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link))
1786 if (TREE_VALUE (link))
1788 if ((p = compare_constant_1 (TREE_VALUE (link), p)) == 0)
1795 if (bcmp (&zero, p, sizeof zero))
1803 else if (code == ADDR_EXPR)
1805 struct addr_const value;
1806 decode_addr_const (exp, &value);
1807 strp = (char *) &value.offset;
1808 len = sizeof value.offset;
1809 /* Compare the offset. */
1811 if (*p++ != *strp++)
1813 /* Compare symbol name. */
1814 strp = XSTR (value.base, 0);
1815 len = strlen (strp) + 1;
1817 else if (code == PLUS_EXPR || code == MINUS_EXPR)
1819 p = compare_constant_1 (TREE_OPERAND (exp, 0), p);
1820 if (p == 0) return 0;
1821 p = compare_constant_1 (TREE_OPERAND (exp, 1), p);
1824 else if (code == NOP_EXPR || code == CONVERT_EXPR)
1826 p = compare_constant_1 (TREE_OPERAND (exp, 0), p);
1830 /* Compare constant contents. */
1832 if (*p++ != *strp++)
1838 /* Construct a constant descriptor for the expression EXP.
1839 It is up to the caller to enter the descriptor in the hash table. */
1841 static struct constant_descriptor *
1842 record_constant (exp)
1845 struct constant_descriptor *next = 0;
1848 /* Make a struct constant_descriptor. The first two pointers will
1849 be filled in later. Here we just leave space for them. */
1851 obstack_grow (&permanent_obstack, (char *) &next, sizeof next);
1852 obstack_grow (&permanent_obstack, (char *) &label, sizeof label);
1853 record_constant_1 (exp);
1854 return (struct constant_descriptor *) obstack_finish (&permanent_obstack);
1857 /* Add a description of constant expression EXP
1858 to the object growing in `permanent_obstack'.
1859 No need to return its address; the caller will get that
1860 from the obstack when the object is complete. */
1863 record_constant_1 (exp)
1866 register char *strp;
1868 register enum tree_code code = TREE_CODE (exp);
1870 obstack_1grow (&permanent_obstack, (unsigned int) code);
1872 if (code == INTEGER_CST)
1874 obstack_1grow (&permanent_obstack, TYPE_PRECISION (TREE_TYPE (exp)));
1875 strp = (char *) &TREE_INT_CST_LOW (exp);
1876 len = 2 * sizeof TREE_INT_CST_LOW (exp);
1878 else if (code == REAL_CST)
1880 obstack_1grow (&permanent_obstack, TYPE_PRECISION (TREE_TYPE (exp)));
1881 strp = (char *) &TREE_REAL_CST (exp);
1882 len = sizeof TREE_REAL_CST (exp);
1884 else if (code == STRING_CST)
1886 if (flag_writable_strings)
1888 strp = TREE_STRING_POINTER (exp);
1889 len = TREE_STRING_LENGTH (exp);
1890 obstack_grow (&permanent_obstack, (char *) &TREE_STRING_LENGTH (exp),
1891 sizeof TREE_STRING_LENGTH (exp));
1893 else if (code == COMPLEX_CST)
1895 record_constant_1 (TREE_REALPART (exp));
1896 record_constant_1 (TREE_IMAGPART (exp));
1899 else if (code == CONSTRUCTOR)
1902 int length = list_length (CONSTRUCTOR_ELTS (exp));
1905 obstack_grow (&permanent_obstack, (char *) &length, sizeof length);
1907 /* For record constructors, insist that the types match.
1908 For arrays, just verify both constructors are for arrays. */
1909 if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE)
1910 type = TREE_TYPE (exp);
1913 obstack_grow (&permanent_obstack, (char *) &type, sizeof type);
1915 /* For arrays, insist that the size in bytes match. */
1916 if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE)
1918 int size = int_size_in_bytes (TREE_TYPE (exp));
1919 obstack_grow (&permanent_obstack, (char *) &size, sizeof size);
1922 for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link))
1924 if (TREE_VALUE (link))
1925 record_constant_1 (TREE_VALUE (link));
1930 obstack_grow (&permanent_obstack, (char *) &zero, sizeof zero);
1936 else if (code == ADDR_EXPR)
1938 struct addr_const value;
1939 decode_addr_const (exp, &value);
1940 /* Record the offset. */
1941 obstack_grow (&permanent_obstack,
1942 (char *) &value.offset, sizeof value.offset);
1943 /* Record the symbol name. */
1944 obstack_grow (&permanent_obstack, XSTR (value.base, 0),
1945 strlen (XSTR (value.base, 0)) + 1);
1948 else if (code == PLUS_EXPR || code == MINUS_EXPR)
1950 record_constant_1 (TREE_OPERAND (exp, 0));
1951 record_constant_1 (TREE_OPERAND (exp, 1));
1954 else if (code == NOP_EXPR || code == CONVERT_EXPR)
1956 record_constant_1 (TREE_OPERAND (exp, 0));
1960 /* Record constant contents. */
1961 obstack_grow (&permanent_obstack, strp, len);
1964 /* Return an rtx representing a reference to constant data in memory
1965 for the constant expression EXP.
1966 If assembler code for such a constant has already been output,
1967 return an rtx to refer to it.
1968 Otherwise, output such a constant in memory and generate
1969 an rtx for it. The TREE_CST_RTL of EXP is set up to point to that rtx.
1970 The const_hash_table records which constants already have label strings. */
1973 output_constant_def (exp)
1976 register int hash, align;
1977 register struct constant_descriptor *desc;
1983 if (TREE_CODE (exp) == INTEGER_CST)
1984 abort (); /* No TREE_CST_RTL slot in these. */
1986 if (TREE_CST_RTL (exp))
1987 return TREE_CST_RTL (exp);
1989 /* Make sure any other constants whose addresses appear in EXP
1990 are assigned label numbers. */
1992 reloc = output_addressed_constants (exp);
1994 /* Compute hash code of EXP. Search the descriptors for that hash code
1995 to see if any of them describes EXP. If yes, the descriptor records
1996 the label number already assigned. */
1998 hash = const_hash (exp) % MAX_HASH_TABLE;
2000 for (desc = const_hash_table[hash]; desc; desc = desc->next)
2001 if (compare_constant (exp, desc))
2003 found = desc->label;
2009 /* No constant equal to EXP is known to have been output.
2010 Make a constant descriptor to enter EXP in the hash table.
2011 Assign the label number and record it in the descriptor for
2012 future calls to this function to find. */
2014 /* Create a string containing the label name, in LABEL. */
2015 ASM_GENERATE_INTERNAL_LABEL (label, "LC", const_labelno);
2017 desc = record_constant (exp);
2018 desc->next = const_hash_table[hash];
2020 = (char *) obstack_copy0 (&permanent_obstack, label, strlen (label));
2021 const_hash_table[hash] = desc;
2024 /* We have a symbol name; construct the SYMBOL_REF and the MEM. */
2026 push_obstacks_nochange ();
2027 if (TREE_PERMANENT (exp))
2028 end_temporary_allocation ();
2030 def = gen_rtx (SYMBOL_REF, Pmode, desc->label);
2033 = gen_rtx (MEM, TYPE_MODE (TREE_TYPE (exp)), def);
2034 RTX_UNCHANGING_P (TREE_CST_RTL (exp)) = 1;
2035 if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE
2036 || TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE)
2037 MEM_IN_STRUCT_P (TREE_CST_RTL (exp)) = 1;
2041 /* Optionally set flags or add text to the name to record information
2042 such as that it is a function name. If the name is changed, the macro
2043 ASM_OUTPUT_LABELREF will have to know how to strip this information.
2044 And if it finds a * at the beginning after doing so, it must handle
2046 #ifdef ENCODE_SECTION_INFO
2047 ENCODE_SECTION_INFO (exp);
2052 /* Now output assembler code to define that label
2053 and follow it with the data of EXP. */
2055 /* First switch to text section, except for writable strings. */
2056 #ifdef SELECT_SECTION
2057 SELECT_SECTION (exp, reloc);
2059 if (((TREE_CODE (exp) == STRING_CST) && flag_writable_strings)
2060 || (flag_pic && reloc))
2063 readonly_data_section ();
2066 /* Align the location counter as required by EXP's data type. */
2067 align = TYPE_ALIGN (TREE_TYPE (exp));
2068 #ifdef CONSTANT_ALIGNMENT
2069 align = CONSTANT_ALIGNMENT (exp, align);
2072 if (align > BITS_PER_UNIT)
2073 ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT));
2075 /* Output the label itself. */
2076 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LC", const_labelno);
2078 /* Output the value of EXP. */
2079 output_constant (exp,
2080 (TREE_CODE (exp) == STRING_CST
2081 ? TREE_STRING_LENGTH (exp)
2082 : int_size_in_bytes (TREE_TYPE (exp))));
2087 return TREE_CST_RTL (exp);
2090 /* Similar hash facility for making memory-constants
2091 from constant rtl-expressions. It is used on RISC machines
2092 where immediate integer arguments and constant addresses are restricted
2093 so that such constants must be stored in memory.
2095 This pool of constants is reinitialized for each function
2096 so each function gets its own constants-pool that comes right before it.
2098 All structures allocated here are discarded when functions are saved for
2099 inlining, so they do not need to be allocated permanently. */
2101 #define MAX_RTX_HASH_TABLE 61
2102 static struct constant_descriptor **const_rtx_hash_table;
2104 /* Structure to represent sufficient information about a constant so that
2105 it can be output when the constant pool is output, so that function
2106 integration can be done, and to simplify handling on machines that reference
2107 constant pool as base+displacement. */
2109 struct pool_constant
2111 struct constant_descriptor *desc;
2112 struct pool_constant *next;
2113 enum machine_mode mode;
2120 /* Pointers to first and last constant in pool. */
2122 static struct pool_constant *first_pool, *last_pool;
2124 /* Current offset in constant pool (does not include any machine-specific
2127 static int pool_offset;
2129 /* Structure used to maintain hash table mapping symbols used to their
2130 corresponding constants. */
2135 struct pool_constant *pool;
2136 struct pool_sym *next;
2139 static struct pool_sym **const_rtx_sym_hash_table;
2141 /* Hash code for a SYMBOL_REF with CONSTANT_POOL_ADDRESS_P true.
2142 The argument is XSTR (... , 0) */
2144 #define SYMHASH(LABEL) \
2145 ((((HOST_WIDE_INT) (LABEL)) & ((1 << HASHBITS) - 1)) % MAX_RTX_HASH_TABLE)
2147 /* Initialize constant pool hashing for next function. */
2150 init_const_rtx_hash_table ()
2152 const_rtx_hash_table
2153 = ((struct constant_descriptor **)
2154 oballoc (MAX_RTX_HASH_TABLE * sizeof (struct constant_descriptor *)));
2155 const_rtx_sym_hash_table
2156 = ((struct pool_sym **)
2157 oballoc (MAX_RTX_HASH_TABLE * sizeof (struct pool_sym *)));
2158 bzero (const_rtx_hash_table,
2159 MAX_RTX_HASH_TABLE * sizeof (struct constant_descriptor *));
2160 bzero (const_rtx_sym_hash_table,
2161 MAX_RTX_HASH_TABLE * sizeof (struct pool_sym *));
2163 first_pool = last_pool = 0;
2167 /* Save and restore it for a nested function. */
2170 save_varasm_status (p)
2173 p->const_rtx_hash_table = const_rtx_hash_table;
2174 p->const_rtx_sym_hash_table = const_rtx_sym_hash_table;
2175 p->first_pool = first_pool;
2176 p->last_pool = last_pool;
2177 p->pool_offset = pool_offset;
2181 restore_varasm_status (p)
2184 const_rtx_hash_table = p->const_rtx_hash_table;
2185 const_rtx_sym_hash_table = p->const_rtx_sym_hash_table;
2186 first_pool = p->first_pool;
2187 last_pool = p->last_pool;
2188 pool_offset = p->pool_offset;
2191 enum kind { RTX_DOUBLE, RTX_INT };
2195 #ifdef ONLY_INT_FIELDS
2196 unsigned int kind : 16;
2197 unsigned int mode : 16;
2199 enum kind kind : 16;
2200 enum machine_mode mode : 16;
2203 union real_extract du;
2204 struct addr_const addr;
2208 /* Express an rtx for a constant integer (perhaps symbolic)
2209 as the sum of a symbol or label plus an explicit integer.
2210 They are stored into VALUE. */
2213 decode_rtx_const (mode, x, value)
2214 enum machine_mode mode;
2216 struct rtx_const *value;
2218 /* Clear the whole structure, including any gaps. */
2221 int *p = (int *) value;
2222 int *end = (int *) (value + 1);
2227 value->kind = RTX_INT; /* Most usual kind. */
2230 switch (GET_CODE (x))
2233 value->kind = RTX_DOUBLE;
2234 value->mode = GET_MODE (x);
2235 bcopy (&CONST_DOUBLE_LOW (x), &value->un.du, sizeof value->un.du);
2239 value->un.addr.offset = INTVAL (x);
2245 value->un.addr.base = x;
2250 if (GET_CODE (x) == PLUS)
2252 value->un.addr.base = XEXP (x, 0);
2253 if (GET_CODE (XEXP (x, 1)) != CONST_INT)
2255 value->un.addr.offset = INTVAL (XEXP (x, 1));
2257 else if (GET_CODE (x) == MINUS)
2259 value->un.addr.base = XEXP (x, 0);
2260 if (GET_CODE (XEXP (x, 1)) != CONST_INT)
2262 value->un.addr.offset = - INTVAL (XEXP (x, 1));
2272 if (value->kind == RTX_INT && value->un.addr.base != 0)
2273 switch (GET_CODE (value->un.addr.base))
2277 /* Use the string's address, not the SYMBOL_REF's address,
2278 for the sake of addresses of library routines.
2279 For a LABEL_REF, compare labels. */
2280 value->un.addr.base = XEXP (value->un.addr.base, 0);
2284 /* Given a MINUS expression, simplify it if both sides
2285 include the same symbol. */
2288 simplify_subtraction (x)
2291 struct rtx_const val0, val1;
2293 decode_rtx_const (GET_MODE (x), XEXP (x, 0), &val0);
2294 decode_rtx_const (GET_MODE (x), XEXP (x, 1), &val1);
2296 if (val0.un.addr.base == val1.un.addr.base)
2297 return GEN_INT (val0.un.addr.offset - val1.un.addr.offset);
2301 /* Compute a hash code for a constant RTL expression. */
2304 const_hash_rtx (mode, x)
2305 enum machine_mode mode;
2310 struct rtx_const value;
2311 decode_rtx_const (mode, x, &value);
2313 /* Compute hashing function */
2315 for (i = 0; i < sizeof value / sizeof (int); i++)
2316 hi += ((int *) &value)[i];
2318 hi &= (1 << HASHBITS) - 1;
2319 hi %= MAX_RTX_HASH_TABLE;
2323 /* Compare a constant rtl object X with a constant-descriptor DESC.
2324 Return 1 if DESC describes a constant with the same value as X. */
2327 compare_constant_rtx (mode, x, desc)
2328 enum machine_mode mode;
2330 struct constant_descriptor *desc;
2332 register int *p = (int *) desc->contents;
2335 struct rtx_const value;
2337 decode_rtx_const (mode, x, &value);
2338 strp = (int *) &value;
2339 len = sizeof value / sizeof (int);
2341 /* Compare constant contents. */
2343 if (*p++ != *strp++)
2349 /* Construct a constant descriptor for the rtl-expression X.
2350 It is up to the caller to enter the descriptor in the hash table. */
2352 static struct constant_descriptor *
2353 record_constant_rtx (mode, x)
2354 enum machine_mode mode;
2357 struct constant_descriptor *ptr;
2359 struct rtx_const value;
2361 decode_rtx_const (mode, x, &value);
2363 obstack_grow (current_obstack, &ptr, sizeof ptr);
2364 obstack_grow (current_obstack, &label, sizeof label);
2366 /* Record constant contents. */
2367 obstack_grow (current_obstack, &value, sizeof value);
2369 return (struct constant_descriptor *) obstack_finish (current_obstack);
2372 /* Given a constant rtx X, make (or find) a memory constant for its value
2373 and return a MEM rtx to refer to it in memory. */
2376 force_const_mem (mode, x)
2377 enum machine_mode mode;
2381 register struct constant_descriptor *desc;
2386 /* If we want this CONST_DOUBLE in the same mode as it is in memory
2387 (this will always be true for floating CONST_DOUBLEs that have been
2388 placed in memory, but not for VOIDmode (integer) CONST_DOUBLEs),
2389 use the previous copy. Otherwise, make a new one. Note that in
2390 the unlikely event that this same CONST_DOUBLE is used in two different
2391 modes in an alternating fashion, we will allocate a lot of different
2392 memory locations, but this should be extremely rare. */
2394 /* Don't use CONST_DOUBLE_MEM in a nested function.
2395 Nested functions have their own constant pools,
2396 so they can't share the same values in CONST_DOUBLE_MEM
2397 with the containing function. */
2398 if (outer_function_chain == 0)
2399 if (GET_CODE (x) == CONST_DOUBLE
2400 && GET_CODE (CONST_DOUBLE_MEM (x)) == MEM
2401 && GET_MODE (CONST_DOUBLE_MEM (x)) == mode)
2402 return CONST_DOUBLE_MEM (x);
2404 /* Compute hash code of X. Search the descriptors for that hash code
2405 to see if any of them describes X. If yes, the descriptor records
2406 the label number already assigned. */
2408 hash = const_hash_rtx (mode, x);
2410 for (desc = const_rtx_hash_table[hash]; desc; desc = desc->next)
2411 if (compare_constant_rtx (mode, x, desc))
2413 found = desc->label;
2419 register struct pool_constant *pool;
2420 register struct pool_sym *sym;
2423 /* No constant equal to X is known to have been output.
2424 Make a constant descriptor to enter X in the hash table.
2425 Assign the label number and record it in the descriptor for
2426 future calls to this function to find. */
2428 desc = record_constant_rtx (mode, x);
2429 desc->next = const_rtx_hash_table[hash];
2430 const_rtx_hash_table[hash] = desc;
2432 /* Align the location counter as required by EXP's data type. */
2433 align = (mode == VOIDmode) ? UNITS_PER_WORD : GET_MODE_SIZE (mode);
2434 if (align > BIGGEST_ALIGNMENT / BITS_PER_UNIT)
2435 align = BIGGEST_ALIGNMENT / BITS_PER_UNIT;
2437 pool_offset += align - 1;
2438 pool_offset &= ~ (align - 1);
2440 /* Allocate a pool constant descriptor, fill it in, and chain it in. */
2442 pool = (struct pool_constant *) oballoc (sizeof (struct pool_constant));
2446 pool->labelno = const_labelno;
2447 pool->align = align;
2448 pool->offset = pool_offset;
2454 last_pool->next = pool;
2457 pool_offset += GET_MODE_SIZE (mode);
2459 /* Create a string containing the label name, in LABEL. */
2460 ASM_GENERATE_INTERNAL_LABEL (label, "LC", const_labelno);
2465 = (char *) obstack_copy0 (saveable_obstack, label, strlen (label));
2467 /* Add label to symbol hash table. */
2468 hash = SYMHASH (found);
2469 sym = (struct pool_sym *) oballoc (sizeof (struct pool_sym));
2472 sym->next = const_rtx_sym_hash_table[hash];
2473 const_rtx_sym_hash_table[hash] = sym;
2476 /* We have a symbol name; construct the SYMBOL_REF and the MEM. */
2478 def = gen_rtx (MEM, mode, gen_rtx (SYMBOL_REF, Pmode, found));
2480 RTX_UNCHANGING_P (def) = 1;
2481 /* Mark the symbol_ref as belonging to this constants pool. */
2482 CONSTANT_POOL_ADDRESS_P (XEXP (def, 0)) = 1;
2483 current_function_uses_const_pool = 1;
2485 if (outer_function_chain == 0)
2486 if (GET_CODE (x) == CONST_DOUBLE)
2488 if (CONST_DOUBLE_MEM (x) == cc0_rtx)
2490 CONST_DOUBLE_CHAIN (x) = const_double_chain;
2491 const_double_chain = x;
2493 CONST_DOUBLE_MEM (x) = def;
2499 /* Given a SYMBOL_REF with CONSTANT_POOL_ADDRESS_P true, return a pointer to
2500 the corresponding pool_constant structure. */
2502 static struct pool_constant *
2503 find_pool_constant (addr)
2506 struct pool_sym *sym;
2507 char *label = XSTR (addr, 0);
2509 for (sym = const_rtx_sym_hash_table[SYMHASH (label)]; sym; sym = sym->next)
2510 if (sym->label == label)
2516 /* Given a constant pool SYMBOL_REF, return the corresponding constant. */
2519 get_pool_constant (addr)
2522 return (find_pool_constant (addr))->constant;
2525 /* Similar, return the mode. */
2528 get_pool_mode (addr)
2531 return (find_pool_constant (addr))->mode;
2534 /* Similar, return the offset in the constant pool. */
2537 get_pool_offset (addr)
2540 return (find_pool_constant (addr))->offset;
2543 /* Return the size of the constant pool. */
2551 /* Write all the constants in the constant pool. */
2554 output_constant_pool (fnname, fndecl)
2558 struct pool_constant *pool;
2560 union real_extract u;
2562 #ifdef ASM_OUTPUT_POOL_PROLOGUE
2563 ASM_OUTPUT_POOL_PROLOGUE (asm_out_file, fnname, fndecl, pool_offset);
2566 for (pool = first_pool; pool; pool = pool->next)
2570 /* See if X is a LABEL_REF (or a CONST referring to a LABEL_REF)
2571 whose CODE_LABEL has been deleted. This can occur if a jump table
2572 is eliminated by optimization. If so, write a constant of zero
2573 instead. Note that this can also happen by turning the
2574 CODE_LABEL into a NOTE. */
2575 if (((GET_CODE (x) == LABEL_REF
2576 && (INSN_DELETED_P (XEXP (x, 0))
2577 || GET_CODE (XEXP (x, 0)) == NOTE)))
2578 || (GET_CODE (x) == CONST && GET_CODE (XEXP (x, 0)) == PLUS
2579 && GET_CODE (XEXP (XEXP (x, 0), 0)) == LABEL_REF
2580 && (INSN_DELETED_P (XEXP (XEXP (XEXP (x, 0), 0), 0))
2581 || GET_CODE (XEXP (XEXP (XEXP (x, 0), 0), 0)) == NOTE)))
2584 /* First switch to correct section. */
2585 #ifdef SELECT_RTX_SECTION
2586 SELECT_RTX_SECTION (pool->mode, x);
2588 readonly_data_section ();
2591 #ifdef ASM_OUTPUT_SPECIAL_POOL_ENTRY
2592 ASM_OUTPUT_SPECIAL_POOL_ENTRY (asm_out_file, x, pool->mode,
2593 pool->align, pool->labelno, done);
2596 if (pool->align > 1)
2597 ASM_OUTPUT_ALIGN (asm_out_file, exact_log2 (pool->align));
2599 /* Output the label. */
2600 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LC", pool->labelno);
2602 /* Output the value of the constant itself. */
2603 switch (GET_MODE_CLASS (pool->mode))
2606 if (GET_CODE (x) != CONST_DOUBLE)
2609 bcopy (&CONST_DOUBLE_LOW (x), &u, sizeof u);
2610 assemble_real (u.d, pool->mode);
2614 case MODE_PARTIAL_INT:
2615 assemble_integer (x, GET_MODE_SIZE (pool->mode), 1);
2625 /* Done with this pool. */
2626 first_pool = last_pool = 0;
2629 /* Find all the constants whose addresses are referenced inside of EXP,
2630 and make sure assembler code with a label has been output for each one.
2631 Indicate whether an ADDR_EXPR has been encountered. */
2634 output_addressed_constants (exp)
2639 switch (TREE_CODE (exp))
2643 register tree constant = TREE_OPERAND (exp, 0);
2645 while (TREE_CODE (constant) == COMPONENT_REF)
2647 constant = TREE_OPERAND (constant, 0);
2650 if (TREE_CODE_CLASS (TREE_CODE (constant)) == 'c'
2651 || TREE_CODE (constant) == CONSTRUCTOR)
2652 /* No need to do anything here
2653 for addresses of variables or functions. */
2654 output_constant_def (constant);
2661 reloc = output_addressed_constants (TREE_OPERAND (exp, 0));
2662 reloc |= output_addressed_constants (TREE_OPERAND (exp, 1));
2667 case NON_LVALUE_EXPR:
2668 reloc = output_addressed_constants (TREE_OPERAND (exp, 0));
2674 for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link))
2675 if (TREE_VALUE (link) != 0)
2676 reloc |= output_addressed_constants (TREE_VALUE (link));
2686 /* Output assembler code for constant EXP to FILE, with no label.
2687 This includes the pseudo-op such as ".int" or ".byte", and a newline.
2688 Assumes output_addressed_constants has been done on EXP already.
2690 Generate exactly SIZE bytes of assembler data, padding at the end
2691 with zeros if necessary. SIZE must always be specified.
2693 SIZE is important for structure constructors,
2694 since trailing members may have been omitted from the constructor.
2695 It is also important for initialization of arrays from string constants
2696 since the full length of the string constant might not be wanted.
2697 It is also needed for initialization of unions, where the initializer's
2698 type is just one member, and that may not be as long as the union.
2700 There a case in which we would fail to output exactly SIZE bytes:
2701 for a structure constructor that wants to produce more than SIZE bytes.
2702 But such constructors will never be generated for any possible input. */
2705 output_constant (exp, size)
2709 register enum tree_code code = TREE_CODE (TREE_TYPE (exp));
2715 /* Allow a constructor with no elements for any data type.
2716 This means to fill the space with zeros. */
2717 if (TREE_CODE (exp) == CONSTRUCTOR && CONSTRUCTOR_ELTS (exp) == 0)
2719 assemble_zeros (size);
2723 /* Eliminate the NOP_EXPR that makes a cast not be an lvalue.
2724 That way we get the constant (we hope) inside it. */
2725 if (TREE_CODE (exp) == NOP_EXPR
2726 && TREE_TYPE (exp) == TREE_TYPE (TREE_OPERAND (exp, 0)))
2727 exp = TREE_OPERAND (exp, 0);
2736 case REFERENCE_TYPE:
2737 /* ??? What about (int)((float)(int)&foo + 4) */
2738 while (TREE_CODE (exp) == NOP_EXPR || TREE_CODE (exp) == CONVERT_EXPR
2739 || TREE_CODE (exp) == NON_LVALUE_EXPR)
2740 exp = TREE_OPERAND (exp, 0);
2742 if (! assemble_integer (expand_expr (exp, NULL_RTX, VOIDmode,
2743 EXPAND_INITIALIZER),
2745 error ("initializer for integer value is too complicated");
2750 if (TREE_CODE (exp) != REAL_CST)
2751 error ("initializer for floating value is not a floating constant");
2753 assemble_real (TREE_REAL_CST (exp),
2754 mode_for_size (size * BITS_PER_UNIT, MODE_FLOAT, 0));
2759 output_constant (TREE_REALPART (exp), size / 2);
2760 output_constant (TREE_IMAGPART (exp), size / 2);
2761 size -= (size / 2) * 2;
2765 if (TREE_CODE (exp) == CONSTRUCTOR)
2767 output_constructor (exp, size);
2770 else if (TREE_CODE (exp) == STRING_CST)
2774 if (size > TREE_STRING_LENGTH (exp))
2776 excess = size - TREE_STRING_LENGTH (exp);
2777 size = TREE_STRING_LENGTH (exp);
2780 assemble_string (TREE_STRING_POINTER (exp), size);
2789 if (TREE_CODE (exp) == CONSTRUCTOR)
2790 output_constructor (exp, size);
2797 assemble_zeros (size);
2800 /* Subroutine of output_constant, used for CONSTRUCTORs
2801 (aggregate constants).
2802 Generate at least SIZE bytes, padding if necessary. */
2805 output_constructor (exp, size)
2809 register tree link, field = 0;
2810 /* Number of bytes output or skipped so far.
2811 In other words, current position within the constructor. */
2812 int total_bytes = 0;
2813 /* Non-zero means BYTE contains part of a byte, to be output. */
2814 int byte_buffer_in_use = 0;
2817 if (HOST_BITS_PER_WIDE_INT < BITS_PER_UNIT)
2820 if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE)
2821 field = TYPE_FIELDS (TREE_TYPE (exp));
2823 /* As LINK goes through the elements of the constant,
2824 FIELD goes through the structure fields, if the constant is a structure.
2825 if the constant is a union, then we override this,
2826 by getting the field from the TREE_LIST element.
2827 But the constant could also be an array. Then FIELD is zero. */
2828 for (link = CONSTRUCTOR_ELTS (exp);
2830 link = TREE_CHAIN (link),
2831 field = field ? TREE_CHAIN (field) : 0)
2833 tree val = TREE_VALUE (link);
2834 /* the element in a union constructor specifies the proper field. */
2835 if (TREE_PURPOSE (link) != 0)
2836 field = TREE_PURPOSE (link);
2838 /* Eliminate the marker that makes a cast not be an lvalue. */
2842 if (field == 0 || !DECL_BIT_FIELD (field))
2844 register int fieldsize;
2845 /* Since this structure is static,
2846 we know the positions are constant. */
2847 int bitpos = (field ? (TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field))
2851 /* An element that is not a bit-field.
2852 Output any buffered-up bit-fields preceding it. */
2853 if (byte_buffer_in_use)
2855 ASM_OUTPUT_BYTE (asm_out_file, byte);
2857 byte_buffer_in_use = 0;
2860 /* Advance to offset of this element.
2861 Note no alignment needed in an array, since that is guaranteed
2862 if each element has the proper size. */
2863 if (field != 0 && bitpos != total_bytes)
2865 assemble_zeros (bitpos - total_bytes);
2866 total_bytes = bitpos;
2869 /* Determine size this element should occupy. */
2872 if (TREE_CODE (DECL_SIZE (field)) != INTEGER_CST)
2874 if (TREE_INT_CST_LOW (DECL_SIZE (field)) > 100000)
2876 /* This avoids overflow trouble. */
2877 tree size_tree = size_binop (CEIL_DIV_EXPR,
2879 size_int (BITS_PER_UNIT));
2880 fieldsize = TREE_INT_CST_LOW (size_tree);
2884 fieldsize = TREE_INT_CST_LOW (DECL_SIZE (field));
2885 fieldsize = (fieldsize + BITS_PER_UNIT - 1) / BITS_PER_UNIT;
2889 fieldsize = int_size_in_bytes (TREE_TYPE (TREE_TYPE (exp)));
2891 /* Output the element's initial value. */
2893 assemble_zeros (fieldsize);
2895 output_constant (val, fieldsize);
2897 /* Count its size. */
2898 total_bytes += fieldsize;
2900 else if (val != 0 && TREE_CODE (val) != INTEGER_CST)
2901 error ("invalid initial value for member `%s'",
2902 IDENTIFIER_POINTER (DECL_NAME (field)));
2905 /* Element that is a bit-field. */
2907 int next_offset = TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field));
2909 = (next_offset + TREE_INT_CST_LOW (DECL_SIZE (field)));
2912 val = integer_zero_node;
2914 /* If this field does not start in this (or, next) byte,
2916 if (next_offset / BITS_PER_UNIT != total_bytes)
2918 /* Output remnant of any bit field in previous bytes. */
2919 if (byte_buffer_in_use)
2921 ASM_OUTPUT_BYTE (asm_out_file, byte);
2923 byte_buffer_in_use = 0;
2926 /* If still not at proper byte, advance to there. */
2927 if (next_offset / BITS_PER_UNIT != total_bytes)
2929 assemble_zeros (next_offset / BITS_PER_UNIT - total_bytes);
2930 total_bytes = next_offset / BITS_PER_UNIT;
2934 if (! byte_buffer_in_use)
2937 /* We must split the element into pieces that fall within
2938 separate bytes, and combine each byte with previous or
2939 following bit-fields. */
2941 /* next_offset is the offset n fbits from the beginning of
2942 the structure to the next bit of this element to be processed.
2943 end_offset is the offset of the first bit past the end of
2945 while (next_offset < end_offset)
2949 int next_byte = next_offset / BITS_PER_UNIT;
2950 int next_bit = next_offset % BITS_PER_UNIT;
2952 /* Advance from byte to byte
2953 within this element when necessary. */
2954 while (next_byte != total_bytes)
2956 ASM_OUTPUT_BYTE (asm_out_file, byte);
2961 /* Number of bits we can process at once
2962 (all part of the same byte). */
2963 this_time = MIN (end_offset - next_offset,
2964 BITS_PER_UNIT - next_bit);
2965 #if BYTES_BIG_ENDIAN
2966 /* On big-endian machine, take the most significant bits
2967 first (of the bits that are significant)
2968 and put them into bytes from the most significant end. */
2969 shift = end_offset - next_offset - this_time;
2970 /* Don't try to take a bunch of bits that cross
2971 the word boundary in the INTEGER_CST. */
2972 if (shift < HOST_BITS_PER_WIDE_INT
2973 && shift + this_time > HOST_BITS_PER_WIDE_INT)
2975 this_time -= (HOST_BITS_PER_WIDE_INT - shift);
2976 shift = HOST_BITS_PER_WIDE_INT;
2979 /* Now get the bits from the appropriate constant word. */
2980 if (shift < HOST_BITS_PER_WIDE_INT)
2982 value = TREE_INT_CST_LOW (val);
2984 else if (shift < 2 * HOST_BITS_PER_WIDE_INT)
2986 value = TREE_INT_CST_HIGH (val);
2987 shift -= HOST_BITS_PER_WIDE_INT;
2991 byte |= (((value >> shift)
2992 & (((HOST_WIDE_INT) 1 << this_time) - 1))
2993 << (BITS_PER_UNIT - this_time - next_bit));
2995 /* On little-endian machines,
2996 take first the least significant bits of the value
2997 and pack them starting at the least significant
2998 bits of the bytes. */
2999 shift = (next_offset
3000 - TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field)));
3001 /* Don't try to take a bunch of bits that cross
3002 the word boundary in the INTEGER_CST. */
3003 if (shift < HOST_BITS_PER_WIDE_INT
3004 && shift + this_time > HOST_BITS_PER_WIDE_INT)
3006 this_time -= (HOST_BITS_PER_WIDE_INT - shift);
3007 shift = HOST_BITS_PER_WIDE_INT;
3010 /* Now get the bits from the appropriate constant word. */
3011 if (shift < HOST_BITS_PER_INT)
3012 value = TREE_INT_CST_LOW (val);
3013 else if (shift < 2 * HOST_BITS_PER_WIDE_INT)
3015 value = TREE_INT_CST_HIGH (val);
3016 shift -= HOST_BITS_PER_WIDE_INT;
3020 byte |= ((value >> shift)
3021 & (((HOST_WIDE_INT) 1 << this_time) - 1)) << next_bit;
3023 next_offset += this_time;
3024 byte_buffer_in_use = 1;
3028 if (byte_buffer_in_use)
3030 ASM_OUTPUT_BYTE (asm_out_file, byte);
3033 if (total_bytes < size)
3034 assemble_zeros (size - total_bytes);