1 /* Output variables, constants and external declarations, for GNU compiler.
2 Copyright (C) 1987, 88, 89, 92, 93, 94, 1995 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> */
38 #include "hard-reg-set.h"
47 #ifdef XCOFF_DEBUGGING_INFO
54 #define ASM_STABS_OP ".stabs"
57 /* This macro gets just the user-specified name
58 out of the string in a SYMBOL_REF. On most machines,
59 we discard the * if any and that's all. */
60 #ifndef STRIP_NAME_ENCODING
61 #define STRIP_NAME_ENCODING(VAR,SYMBOL_NAME) \
62 (VAR) = ((SYMBOL_NAME) + ((SYMBOL_NAME)[0] == '*'))
65 /* File in which assembler code is being written. */
67 extern FILE *asm_out_file;
69 /* The (assembler) name of the first globally-visible object output. */
70 char *first_global_object_name;
72 extern struct obstack *current_obstack;
73 extern struct obstack *saveable_obstack;
74 extern struct obstack *rtl_obstack;
75 extern struct obstack permanent_obstack;
76 #define obstack_chunk_alloc xmalloc
78 /* Number for making the label on the next
79 constant that is stored in memory. */
83 /* Number for making the label on the next
84 static variable internal to a function. */
88 /* Carry information from ASM_DECLARE_OBJECT_NAME
89 to ASM_FINISH_DECLARE_OBJECT. */
91 int size_directive_output;
93 /* The last decl for which assemble_variable was called,
94 if it did ASM_DECLARE_OBJECT_NAME.
95 If the last call to assemble_variable didn't do that,
98 tree last_assemble_variable_decl;
101 #ifdef HANDLE_PRAGMA_WEAK
102 /* Any weak symbol declarations waiting to be emitted. */
106 struct weak_syms *next;
111 static struct weak_syms *weak_decls;
114 /* Nonzero if at least one function definition has been seen. */
116 static int function_defined;
119 struct constant_descriptor;
121 struct pool_constant;
123 static void bc_make_decl_rtl PROTO((tree, char *, int));
124 static char *strip_reg_name PROTO((char *));
125 static void bc_output_ascii PROTO((FILE *, char *, int));
126 static int contains_pointers_p PROTO((tree));
127 static void decode_addr_const PROTO((tree, struct addr_const *));
128 static int const_hash PROTO((tree));
129 static int compare_constant PROTO((tree,
130 struct constant_descriptor *));
131 static char *compare_constant_1 PROTO((tree, char *));
132 static struct constant_descriptor *record_constant PROTO((tree));
133 static void record_constant_1 PROTO((tree));
134 static tree copy_constant PROTO((tree));
135 static void output_constant_def_contents PROTO((tree, int, int));
136 static void decode_rtx_const PROTO((enum machine_mode, rtx,
137 struct rtx_const *));
138 static int const_hash_rtx PROTO((enum machine_mode, rtx));
139 static int compare_constant_rtx PROTO((enum machine_mode, rtx,
140 struct constant_descriptor *));
141 static struct constant_descriptor *record_constant_rtx PROTO((enum machine_mode,
143 static struct pool_constant *find_pool_constant PROTO((rtx));
144 static int output_addressed_constants PROTO((tree));
145 static void bc_assemble_integer PROTO((tree, int));
146 static void output_constructor PROTO((tree, int));
148 #ifdef EXTRA_SECTIONS
149 static enum in_section {no_section, in_text, in_data, in_named, EXTRA_SECTIONS} in_section
152 static enum in_section {no_section, in_text, in_data, in_named} in_section
156 /* Return a non-zero value if DECL has a section attribute. */
157 #define IN_NAMED_SECTION(DECL) \
158 ((TREE_CODE (DECL) == FUNCTION_DECL || TREE_CODE (DECL) == VAR_DECL) \
159 && DECL_SECTION_NAME (DECL) != NULL_TREE)
161 /* Text of section name when in_section == in_named. */
162 static char *in_named_name;
164 /* Define functions like text_section for any extra sections. */
165 #ifdef EXTRA_SECTION_FUNCTIONS
166 EXTRA_SECTION_FUNCTIONS
169 /* Tell assembler to switch to text section. */
174 if (in_section != in_text)
179 fprintf (asm_out_file, "%s\n", TEXT_SECTION_ASM_OP);
181 in_section = in_text;
185 /* Tell assembler to switch to data section. */
190 if (in_section != in_data)
196 if (flag_shared_data)
198 #ifdef SHARED_SECTION_ASM_OP
199 fprintf (asm_out_file, "%s\n", SHARED_SECTION_ASM_OP);
201 fprintf (asm_out_file, "%s\n", DATA_SECTION_ASM_OP);
205 fprintf (asm_out_file, "%s\n", DATA_SECTION_ASM_OP);
208 in_section = in_data;
212 /* Tell assembler to switch to read-only data section. This is normally
216 readonly_data_section ()
218 #ifdef READONLY_DATA_SECTION
219 READONLY_DATA_SECTION (); /* Note this can call data_section. */
225 /* Determine if we're in the text section. */
230 return in_section == in_text;
233 /* Tell assembler to change to section NAME for DECL.
234 If DECL is NULL, just switch to section NAME.
235 If NAME is NULL, get the name from DECL. */
238 named_section (decl, name)
242 if (decl != NULL_TREE
243 && (TREE_CODE (decl) != FUNCTION_DECL && TREE_CODE (decl) != VAR_DECL))
246 name = TREE_STRING_POINTER (DECL_SECTION_NAME (decl));
248 if (in_section != in_named || strcmp (name, in_named_name))
250 in_named_name = name;
251 in_section = in_named;
253 #ifdef ASM_OUTPUT_SECTION_NAME
254 ASM_OUTPUT_SECTION_NAME (asm_out_file, decl, name);
256 /* Section attributes are not supported if this macro isn't provided -
257 some host formats don't support them at all. The front-end should
258 already have flagged this as an error. */
264 /* Switch to the section for function DECL.
266 If DECL is NULL_TREE, switch to the text section.
267 ??? It's not clear that we will ever be passed NULL_TREE, but it's
268 safer to handle it. */
271 function_section (decl)
274 if (decl != NULL_TREE
275 && DECL_SECTION_NAME (decl) != NULL_TREE)
276 named_section (decl, (char *) 0);
281 /* Create the rtl to represent a function, for a function definition.
282 DECL is a FUNCTION_DECL node which describes which function.
283 The rtl is stored into DECL. */
286 make_function_rtl (decl)
289 char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
293 if (DECL_RTL (decl) == 0)
294 DECL_RTL (decl) = bc_gen_rtx (name, 0, (struct bc_label *) 0);
296 /* Record that at least one function has been defined. */
297 function_defined = 1;
301 /* Rename a nested function to avoid conflicts. */
302 if (decl_function_context (decl) != 0
303 && DECL_INITIAL (decl) != 0
304 && DECL_RTL (decl) == 0)
308 name = IDENTIFIER_POINTER (DECL_NAME (decl));
309 ASM_FORMAT_PRIVATE_NAME (label, name, var_labelno);
310 name = obstack_copy0 (saveable_obstack, label, strlen (label));
314 if (DECL_RTL (decl) == 0)
317 = gen_rtx (MEM, DECL_MODE (decl),
318 gen_rtx (SYMBOL_REF, Pmode, name));
320 /* Optionally set flags or add text to the name to record information
321 such as that it is a function name. If the name is changed, the macro
322 ASM_OUTPUT_LABELREF will have to know how to strip this information. */
323 #ifdef ENCODE_SECTION_INFO
324 ENCODE_SECTION_INFO (decl);
328 /* Record at least one function has been defined. */
329 function_defined = 1;
332 /* Create the DECL_RTL for a declaration for a static or external
333 variable or static or external function.
334 ASMSPEC, if not 0, is the string which the user specified
335 as the assembler symbol name.
336 TOP_LEVEL is nonzero if this is a file-scope variable.
337 This is never called for PARM_DECLs. */
340 bc_make_decl_rtl (decl, asmspec, top_level)
345 register char *name = TREE_STRING_POINTER (DECL_ASSEMBLER_NAME (decl));
347 if (DECL_RTL (decl) == 0)
349 /* Print an error message for register variables. */
350 if (DECL_REGISTER (decl) && TREE_CODE (decl) == FUNCTION_DECL)
351 error ("function declared `register'");
352 else if (DECL_REGISTER (decl))
353 error ("global register variables not supported in the interpreter");
355 /* Handle ordinary static variables and functions. */
356 if (DECL_RTL (decl) == 0)
358 /* Can't use just the variable's own name for a variable
359 whose scope is less than the whole file.
360 Concatenate a distinguishing number. */
361 if (!top_level && !DECL_EXTERNAL (decl) && asmspec == 0)
365 ASM_FORMAT_PRIVATE_NAME (label, name, var_labelno);
366 name = obstack_copy0 (saveable_obstack, label, strlen (label));
370 DECL_RTL (decl) = bc_gen_rtx (name, 0, (struct bc_label *) 0);
375 /* Given NAME, a putative register name, discard any customary prefixes. */
378 strip_reg_name (name)
381 #ifdef REGISTER_PREFIX
382 if (!strncmp (name, REGISTER_PREFIX, strlen (REGISTER_PREFIX)))
383 name += strlen (REGISTER_PREFIX);
385 if (name[0] == '%' || name[0] == '#')
390 /* Decode an `asm' spec for a declaration as a register name.
391 Return the register number, or -1 if nothing specified,
392 or -2 if the ASMSPEC is not `cc' or `memory' and is not recognized,
393 or -3 if ASMSPEC is `cc' and is not recognized,
394 or -4 if ASMSPEC is `memory' and is not recognized.
395 Accept an exact spelling or a decimal number.
396 Prefixes such as % are optional. */
399 decode_reg_name (asmspec)
406 /* Get rid of confusing prefixes. */
407 asmspec = strip_reg_name (asmspec);
409 /* Allow a decimal number as a "register name". */
410 for (i = strlen (asmspec) - 1; i >= 0; i--)
411 if (! (asmspec[i] >= '0' && asmspec[i] <= '9'))
413 if (asmspec[0] != 0 && i < 0)
416 if (i < FIRST_PSEUDO_REGISTER && i >= 0)
422 for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
424 && ! strcmp (asmspec, strip_reg_name (reg_names[i])))
427 #ifdef ADDITIONAL_REGISTER_NAMES
429 static struct { char *name; int number; } table[]
430 = ADDITIONAL_REGISTER_NAMES;
432 for (i = 0; i < sizeof (table) / sizeof (table[0]); i++)
433 if (! strcmp (asmspec, table[i].name))
434 return table[i].number;
436 #endif /* ADDITIONAL_REGISTER_NAMES */
438 if (!strcmp (asmspec, "memory"))
441 if (!strcmp (asmspec, "cc"))
450 /* Create the DECL_RTL for a declaration for a static or external variable
451 or static or external function.
452 ASMSPEC, if not 0, is the string which the user specified
453 as the assembler symbol name.
454 TOP_LEVEL is nonzero if this is a file-scope variable.
456 This is never called for PARM_DECL nodes. */
459 make_decl_rtl (decl, asmspec, top_level)
464 register char *name = 0;
469 bc_make_decl_rtl (decl, asmspec, top_level);
473 reg_number = decode_reg_name (asmspec);
475 if (DECL_ASSEMBLER_NAME (decl) != NULL_TREE)
476 name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
478 if (reg_number == -2)
480 /* ASMSPEC is given, and not the name of a register. */
481 name = (char *) obstack_alloc (saveable_obstack,
482 strlen (asmspec) + 2);
484 strcpy (&name[1], asmspec);
487 /* For a duplicate declaration, we can be called twice on the
488 same DECL node. Don't discard the RTL already made. */
489 if (DECL_RTL (decl) == 0)
493 /* First detect errors in declaring global registers. */
494 if (DECL_REGISTER (decl) && reg_number == -1)
495 error_with_decl (decl,
496 "register name not specified for `%s'");
497 else if (DECL_REGISTER (decl) && reg_number < 0)
498 error_with_decl (decl,
499 "invalid register name for `%s'");
500 else if ((reg_number >= 0 || reg_number == -3) && ! DECL_REGISTER (decl))
501 error_with_decl (decl,
502 "register name given for non-register variable `%s'");
503 else if (DECL_REGISTER (decl) && TREE_CODE (decl) == FUNCTION_DECL)
504 error ("function declared `register'");
505 else if (DECL_REGISTER (decl) && TYPE_MODE (TREE_TYPE (decl)) == BLKmode)
506 error_with_decl (decl, "data type of `%s' isn't suitable for a register");
507 else if (DECL_REGISTER (decl)
508 && ! HARD_REGNO_MODE_OK (reg_number, TYPE_MODE (TREE_TYPE (decl))))
509 error_with_decl (decl, "register number for `%s' isn't suitable for the data type");
510 /* Now handle properly declared static register variables. */
511 else if (DECL_REGISTER (decl))
514 #if 0 /* yylex should print the warning for this */
516 pedwarn ("ANSI C forbids global register variables");
518 if (DECL_INITIAL (decl) != 0 && top_level)
520 DECL_INITIAL (decl) = 0;
521 error ("global register variable has initial value");
523 if (fixed_regs[reg_number] == 0
524 && function_defined && top_level)
525 error ("global register variable follows a function definition");
526 if (TREE_THIS_VOLATILE (decl))
527 warning ("volatile register variables don't work as you might wish");
529 /* If the user specified one of the eliminables registers here,
530 e.g., FRAME_POINTER_REGNUM, we don't want to get this variable
531 confused with that register and be eliminated. Although this
532 usage is somewhat suspect, we nevertheless use the following
533 kludge to avoid setting DECL_RTL to frame_pointer_rtx. */
536 = gen_rtx (REG, DECL_MODE (decl), FIRST_PSEUDO_REGISTER);
537 REGNO (DECL_RTL (decl)) = reg_number;
538 REG_USERVAR_P (DECL_RTL (decl)) = 1;
542 /* Make this register global, so not usable for anything
544 nregs = HARD_REGNO_NREGS (reg_number, DECL_MODE (decl));
546 globalize_reg (reg_number + --nregs);
549 /* Specifying a section attribute on an uninitialized variable does not
550 (and cannot) cause it to be put in the given section. The linker
551 can only put initialized objects in specific sections, everything
552 else goes in bss for the linker to sort out later (otherwise the
553 linker would give a duplicate definition error for each compilation
554 unit that behaved thusly). So warn the user. */
555 else if (TREE_CODE (decl) == VAR_DECL
556 && DECL_SECTION_NAME (decl) != NULL_TREE
557 && DECL_INITIAL (decl) == NULL_TREE
558 && DECL_COMMON (decl)
561 warning_with_decl (decl,
562 "section attribute ignored for uninitialized variable `%s'");
563 /* Remove the section name so subsequent declarations won't see it.
564 We are ignoring it, remember. */
565 DECL_SECTION_NAME (decl) = NULL_TREE;
568 /* Now handle ordinary static variables and functions (in memory).
569 Also handle vars declared register invalidly. */
570 if (DECL_RTL (decl) == 0)
572 /* Can't use just the variable's own name for a variable
573 whose scope is less than the whole file.
574 Concatenate a distinguishing number. */
575 if (!top_level && !DECL_EXTERNAL (decl) && asmspec == 0)
579 ASM_FORMAT_PRIVATE_NAME (label, name, var_labelno);
580 name = obstack_copy0 (saveable_obstack, label, strlen (label));
587 DECL_RTL (decl) = gen_rtx (MEM, DECL_MODE (decl),
588 gen_rtx (SYMBOL_REF, Pmode, name));
590 /* If this variable is to be treated as volatile, show its
591 tree node has side effects. If it has side effects, either
592 because of this test or from TREE_THIS_VOLATILE also
593 being set, show the MEM is volatile. */
594 if (flag_volatile_global && TREE_CODE (decl) == VAR_DECL
595 && TREE_PUBLIC (decl))
596 TREE_SIDE_EFFECTS (decl) = 1;
597 if (TREE_SIDE_EFFECTS (decl))
598 MEM_VOLATILE_P (DECL_RTL (decl)) = 1;
600 if (TREE_READONLY (decl))
601 RTX_UNCHANGING_P (DECL_RTL (decl)) = 1;
602 MEM_IN_STRUCT_P (DECL_RTL (decl))
603 = AGGREGATE_TYPE_P (TREE_TYPE (decl));
605 /* Optionally set flags or add text to the name to record information
606 such as that it is a function name.
607 If the name is changed, the macro ASM_OUTPUT_LABELREF
608 will have to know how to strip this information. */
609 #ifdef ENCODE_SECTION_INFO
610 ENCODE_SECTION_INFO (decl);
614 /* If the old RTL had the wrong mode, fix the mode. */
615 else if (GET_MODE (DECL_RTL (decl)) != DECL_MODE (decl))
617 rtx rtl = DECL_RTL (decl);
618 PUT_MODE (rtl, DECL_MODE (decl));
622 /* Make the rtl for variable VAR be volatile.
623 Use this only for static variables. */
626 make_var_volatile (var)
629 if (GET_CODE (DECL_RTL (var)) != MEM)
632 MEM_VOLATILE_P (DECL_RTL (var)) = 1;
635 /* Output alignment directive to align for constant expression EXP. */
638 assemble_constant_align (exp)
643 /* Align the location counter as required by EXP's data type. */
644 align = TYPE_ALIGN (TREE_TYPE (exp));
645 #ifdef CONSTANT_ALIGNMENT
646 align = CONSTANT_ALIGNMENT (exp, align);
649 if (align > BITS_PER_UNIT)
650 ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT));
653 /* Output a string of literal assembler code
654 for an `asm' keyword used between functions. */
657 assemble_asm (string)
662 error ("asm statements not allowed in interpreter");
668 if (TREE_CODE (string) == ADDR_EXPR)
669 string = TREE_OPERAND (string, 0);
671 fprintf (asm_out_file, "\t%s\n", TREE_STRING_POINTER (string));
674 #if 0 /* This should no longer be needed, because
675 flag_gnu_linker should be 0 on these systems,
676 which should prevent any output
677 if ASM_OUTPUT_CONSTRUCTOR and ASM_OUTPUT_DESTRUCTOR are absent. */
678 #if !(defined(DBX_DEBUGGING_INFO) && !defined(FASCIST_ASSEMBLER))
679 #ifndef ASM_OUTPUT_CONSTRUCTOR
680 #define ASM_OUTPUT_CONSTRUCTOR(file, name)
682 #ifndef ASM_OUTPUT_DESTRUCTOR
683 #define ASM_OUTPUT_DESTRUCTOR(file, name)
688 /* Record an element in the table of global destructors.
689 How this is done depends on what sort of assembler and linker
692 NAME should be the name of a global function to be called
693 at exit time. This name is output using assemble_name. */
696 assemble_destructor (name)
699 #ifdef ASM_OUTPUT_DESTRUCTOR
700 ASM_OUTPUT_DESTRUCTOR (asm_out_file, name);
704 /* Now tell GNU LD that this is part of the static destructor set. */
705 /* This code works for any machine provided you use GNU as/ld. */
706 fprintf (asm_out_file, "%s \"___DTOR_LIST__\",22,0,0,", ASM_STABS_OP);
707 assemble_name (asm_out_file, name);
708 fputc ('\n', asm_out_file);
713 /* Likewise for global constructors. */
716 assemble_constructor (name)
719 #ifdef ASM_OUTPUT_CONSTRUCTOR
720 ASM_OUTPUT_CONSTRUCTOR (asm_out_file, name);
724 /* Now tell GNU LD that this is part of the static constructor set. */
725 /* This code works for any machine provided you use GNU as/ld. */
726 fprintf (asm_out_file, "%s \"___CTOR_LIST__\",22,0,0,", ASM_STABS_OP);
727 assemble_name (asm_out_file, name);
728 fputc ('\n', asm_out_file);
733 /* Likewise for entries we want to record for garbage collection.
734 Garbage collection is still under development. */
737 assemble_gc_entry (name)
740 #ifdef ASM_OUTPUT_GC_ENTRY
741 ASM_OUTPUT_GC_ENTRY (asm_out_file, name);
745 /* Now tell GNU LD that this is part of the static constructor set. */
746 fprintf (asm_out_file, "%s \"___PTR_LIST__\",22,0,0,", ASM_STABS_OP);
747 assemble_name (asm_out_file, name);
748 fputc ('\n', asm_out_file);
753 /* Output assembler code for the constant pool of a function and associated
754 with defining the name of the function. DECL describes the function.
755 NAME is the function's name. For the constant pool, we use the current
756 constant pool data. */
759 assemble_start_function (decl, fnname)
765 /* The following code does not need preprocessing in the assembler. */
769 output_constant_pool (fnname, decl);
771 function_section (decl);
773 /* Tell assembler to move to target machine's alignment for functions. */
774 align = floor_log2 (FUNCTION_BOUNDARY / BITS_PER_UNIT);
778 BC_OUTPUT_ALIGN (asm_out_file, align);
780 ASM_OUTPUT_ALIGN (asm_out_file, align);
783 #ifdef ASM_OUTPUT_FUNCTION_PREFIX
784 ASM_OUTPUT_FUNCTION_PREFIX (asm_out_file, fnname);
787 #ifdef SDB_DEBUGGING_INFO
788 /* Output SDB definition of the function. */
789 if (write_symbols == SDB_DEBUG)
790 sdbout_mark_begin_function ();
793 #ifdef DBX_DEBUGGING_INFO
794 /* Output DBX definition of the function. */
795 if (write_symbols == DBX_DEBUG)
796 dbxout_begin_function (decl);
799 /* Make function name accessible from other files, if appropriate. */
801 if (TREE_PUBLIC (decl))
803 if (!first_global_object_name)
807 STRIP_NAME_ENCODING (p, fnname);
808 first_global_object_name = permalloc (strlen (p) + 1);
809 strcpy (first_global_object_name, p);
812 #ifdef ASM_WEAKEN_LABEL
813 if (DECL_WEAK (decl))
814 ASM_WEAKEN_LABEL (asm_out_file, fnname);
818 BC_GLOBALIZE_LABEL (asm_out_file, fnname);
820 ASM_GLOBALIZE_LABEL (asm_out_file, fnname);
823 /* Do any machine/system dependent processing of the function name */
824 #ifdef ASM_DECLARE_FUNCTION_NAME
825 ASM_DECLARE_FUNCTION_NAME (asm_out_file, fnname, current_function_decl);
827 /* Standard thing is just output label for the function. */
829 BC_OUTPUT_LABEL (asm_out_file, fnname);
831 ASM_OUTPUT_LABEL (asm_out_file, fnname);
832 #endif /* ASM_DECLARE_FUNCTION_NAME */
835 /* Output assembler code associated with defining the size of the
836 function. DECL describes the function. NAME is the function's name. */
839 assemble_end_function (decl, fnname)
843 #ifdef ASM_DECLARE_FUNCTION_SIZE
844 ASM_DECLARE_FUNCTION_SIZE (asm_out_file, fnname, decl);
848 /* Assemble code to leave SIZE bytes of zeros. */
851 assemble_zeros (size)
856 bc_emit_const_skip (size);
860 #ifdef ASM_NO_SKIP_IN_TEXT
861 /* The `space' pseudo in the text section outputs nop insns rather than 0s,
862 so we must output 0s explicitly in the text section. */
863 if (ASM_NO_SKIP_IN_TEXT && in_text_section ())
867 for (i = 0; i < size - 20; i += 20)
870 fprintf (asm_out_file,
871 "%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);
873 fprintf (asm_out_file,
874 "\tbyte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n");
880 fprintf (asm_out_file, "%s 0", ASM_BYTE_OP);
882 fprintf (asm_out_file, "\tbyte 0");
885 for (; i < size; i++)
886 fprintf (asm_out_file, ",0");
887 fprintf (asm_out_file, "\n");
895 BC_OUTPUT_SKIP (asm_out_file, size);
897 ASM_OUTPUT_SKIP (asm_out_file, size);
901 /* Assemble an alignment pseudo op for an ALIGN-bit boundary. */
904 assemble_align (align)
907 if (align > BITS_PER_UNIT)
908 ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT));
911 /* Assemble a string constant with the specified C string as contents. */
914 assemble_string (p, size)
928 /* If the string is very long, split it up. */
932 int thissize = size - pos;
933 if (thissize > maximum)
937 bc_output_ascii (asm_out_file, p, thissize);
940 ASM_OUTPUT_ASCII (asm_out_file, p, thissize);
949 bc_output_ascii (file, p, size)
954 BC_OUTPUT_ASCII (file, p, size);
957 /* Assemble everything that is needed for a variable or function declaration.
958 Not used for automatic variables, and not used for function definitions.
959 Should not be called for variables of incomplete structure type.
961 TOP_LEVEL is nonzero if this variable has file scope.
962 AT_END is nonzero if this is the special handling, at end of compilation,
963 to define things that have had only tentative definitions.
964 DONT_OUTPUT_DATA if nonzero means don't actually output the
965 initial value (that will be done by the caller). */
968 assemble_variable (decl, top_level, at_end, dont_output_data)
972 int dont_output_data;
978 enum in_section saved_in_section;
980 last_assemble_variable_decl = 0;
985 if (GET_CODE (DECL_RTL (decl)) == REG)
987 /* Do output symbol info for global register variables, but do nothing
990 if (TREE_ASM_WRITTEN (decl))
992 TREE_ASM_WRITTEN (decl) = 1;
994 if (!output_bytecode)
996 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
997 /* File-scope global variables are output here. */
998 if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
1000 dbxout_symbol (decl, 0);
1002 #ifdef SDB_DEBUGGING_INFO
1003 if (write_symbols == SDB_DEBUG && top_level
1004 /* Leave initialized global vars for end of compilation;
1005 see comment in compile_file. */
1006 && (TREE_PUBLIC (decl) == 0 || DECL_INITIAL (decl) == 0))
1007 sdbout_symbol (decl, 0);
1011 /* Don't output any DWARF debugging information for variables here.
1012 In the case of local variables, the information for them is output
1013 when we do our recursive traversal of the tree representation for
1014 the entire containing function. In the case of file-scope variables,
1015 we output information for all of them at the very end of compilation
1016 while we are doing our final traversal of the chain of file-scope
1022 /* Normally no need to say anything here for external references,
1023 since assemble_external is called by the language-specific code
1024 when a declaration is first seen. */
1026 if (DECL_EXTERNAL (decl))
1029 /* Output no assembler code for a function declaration.
1030 Only definitions of functions output anything. */
1032 if (TREE_CODE (decl) == FUNCTION_DECL)
1035 /* If type was incomplete when the variable was declared,
1036 see if it is complete now. */
1038 if (DECL_SIZE (decl) == 0)
1039 layout_decl (decl, 0);
1041 /* Still incomplete => don't allocate it; treat the tentative defn
1042 (which is what it must have been) as an `extern' reference. */
1044 if (!dont_output_data && DECL_SIZE (decl) == 0)
1046 error_with_file_and_line (DECL_SOURCE_FILE (decl),
1047 DECL_SOURCE_LINE (decl),
1048 "storage size of `%s' isn't known",
1049 IDENTIFIER_POINTER (DECL_NAME (decl)));
1050 TREE_ASM_WRITTEN (decl) = 1;
1054 /* The first declaration of a variable that comes through this function
1055 decides whether it is global (in C, has external linkage)
1056 or local (in C, has internal linkage). So do nothing more
1057 if this function has already run. */
1059 if (TREE_ASM_WRITTEN (decl))
1062 TREE_ASM_WRITTEN (decl) = 1;
1066 if (! dont_output_data)
1068 if (TREE_CODE (DECL_SIZE (decl)) != INTEGER_CST)
1071 /* This is better than explicit arithmetic, since it avoids overflow. */
1072 size_tree = size_binop (CEIL_DIV_EXPR,
1073 DECL_SIZE (decl), size_int (BITS_PER_UNIT));
1075 if (TREE_INT_CST_HIGH (size_tree) != 0)
1077 error_with_decl (decl, "size of variable `%s' is too large");
1082 name = XSTR (XEXP (DECL_RTL (decl), 0), 0);
1084 /* Handle uninitialized definitions. */
1086 /* ANSI specifies that a tentative definition which is not merged with
1087 a non-tentative definition behaves exactly like a definition with an
1088 initializer equal to zero. (Section 3.7.2)
1089 -fno-common gives strict ANSI behavior. Usually you don't want it.
1090 This matters only for variables with external linkage. */
1091 if ((! flag_no_common || ! TREE_PUBLIC (decl))
1092 && DECL_COMMON (decl)
1093 && ! dont_output_data
1094 && (DECL_INITIAL (decl) == 0 || DECL_INITIAL (decl) == error_mark_node))
1096 int size = TREE_INT_CST_LOW (size_tree);
1099 if (TREE_INT_CST_HIGH (size_tree) != 0)
1100 error_with_decl (decl, "size of variable `%s' is too large");
1101 /* Don't allocate zero bytes of common,
1102 since that means "undefined external" in the linker. */
1103 if (size == 0) rounded = 1;
1104 /* Round size up to multiple of BIGGEST_ALIGNMENT bits
1105 so that each uninitialized object starts on such a boundary. */
1106 rounded += (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - 1;
1107 rounded = (rounded / (BIGGEST_ALIGNMENT / BITS_PER_UNIT)
1108 * (BIGGEST_ALIGNMENT / BITS_PER_UNIT));
1110 #ifdef DBX_DEBUGGING_INFO
1111 /* File-scope global variables are output here. */
1112 if (write_symbols == DBX_DEBUG && top_level)
1113 dbxout_symbol (decl, 0);
1115 #ifdef SDB_DEBUGGING_INFO
1116 if (write_symbols == SDB_DEBUG && top_level
1117 /* Leave initialized global vars for end of compilation;
1118 see comment in compile_file. */
1119 && (TREE_PUBLIC (decl) == 0 || DECL_INITIAL (decl) == 0))
1120 sdbout_symbol (decl, 0);
1123 /* Don't output any DWARF debugging information for variables here.
1124 In the case of local variables, the information for them is output
1125 when we do our recursive traversal of the tree representation for
1126 the entire containing function. In the case of file-scope variables,
1127 we output information for all of them at the very end of compilation
1128 while we are doing our final traversal of the chain of file-scope
1132 if (flag_shared_data)
1135 if (TREE_PUBLIC (decl))
1137 #ifdef ASM_OUTPUT_SHARED_COMMON
1138 if (flag_shared_data)
1139 ASM_OUTPUT_SHARED_COMMON (asm_out_file, name, size, rounded);
1142 if (output_bytecode)
1144 BC_OUTPUT_COMMON (asm_out_file, name, size, rounded);
1148 #ifdef ASM_OUTPUT_ALIGNED_COMMON
1149 ASM_OUTPUT_ALIGNED_COMMON (asm_out_file, name, size,
1152 ASM_OUTPUT_COMMON (asm_out_file, name, size, rounded);
1158 #ifdef ASM_OUTPUT_SHARED_LOCAL
1159 if (flag_shared_data)
1160 ASM_OUTPUT_SHARED_LOCAL (asm_out_file, name, size, rounded);
1163 if (output_bytecode)
1165 BC_OUTPUT_LOCAL (asm_out_file, name, size, rounded);
1169 #ifdef ASM_OUTPUT_ALIGNED_LOCAL
1170 ASM_OUTPUT_ALIGNED_LOCAL (asm_out_file, name, size,
1173 ASM_OUTPUT_LOCAL (asm_out_file, name, size, rounded);
1180 /* Handle initialized definitions. */
1182 /* First make the assembler name(s) global if appropriate. */
1183 if (TREE_PUBLIC (decl) && DECL_NAME (decl))
1185 if (!first_global_object_name)
1189 STRIP_NAME_ENCODING (p, name);
1190 first_global_object_name = permalloc (strlen (p) + 1);
1191 strcpy (first_global_object_name, p);
1194 #ifdef ASM_WEAKEN_LABEL
1195 if (DECL_WEAK (decl))
1196 ASM_WEAKEN_LABEL (asm_out_file, name);
1199 ASM_GLOBALIZE_LABEL (asm_out_file, name);
1202 for (d = equivalents; d; d = TREE_CHAIN (d))
1204 tree e = TREE_VALUE (d);
1205 if (TREE_PUBLIC (e) && DECL_NAME (e))
1206 ASM_GLOBALIZE_LABEL (asm_out_file,
1207 XSTR (XEXP (DECL_RTL (e), 0), 0));
1211 /* Output any data that we will need to use the address of. */
1212 if (DECL_INITIAL (decl) == error_mark_node)
1213 reloc = contains_pointers_p (TREE_TYPE (decl));
1214 else if (DECL_INITIAL (decl))
1215 reloc = output_addressed_constants (DECL_INITIAL (decl));
1217 /* Switch to the proper section for this data. */
1218 if (IN_NAMED_SECTION (decl))
1219 named_section (decl, NULL);
1222 /* C++ can have const variables that get initialized from constructors,
1223 and thus can not be in a readonly section. We prevent this by
1224 verifying that the initial value is constant for objects put in a
1227 error_mark_node is used by the C front end to indicate that the
1228 initializer has not been seen yet. In this case, we assume that
1229 the initializer must be constant. */
1230 #ifdef SELECT_SECTION
1231 SELECT_SECTION (decl, reloc);
1233 if (TREE_READONLY (decl)
1234 && ! TREE_THIS_VOLATILE (decl)
1235 && DECL_INITIAL (decl)
1236 && (DECL_INITIAL (decl) == error_mark_node
1237 || TREE_CONSTANT (DECL_INITIAL (decl)))
1238 && ! (flag_pic && reloc))
1239 readonly_data_section ();
1245 /* dbxout.c needs to know this. */
1246 if (in_text_section ())
1247 DECL_IN_TEXT_SECTION (decl) = 1;
1249 /* Record current section so we can restore it if dbxout.c clobbers it. */
1250 saved_in_section = in_section;
1252 /* Output the dbx info now that we have chosen the section. */
1254 #ifdef DBX_DEBUGGING_INFO
1255 /* File-scope global variables are output here. */
1256 if (write_symbols == DBX_DEBUG && top_level)
1257 dbxout_symbol (decl, 0);
1259 #ifdef SDB_DEBUGGING_INFO
1260 if (write_symbols == SDB_DEBUG && top_level
1261 /* Leave initialized global vars for end of compilation;
1262 see comment in compile_file. */
1263 && (TREE_PUBLIC (decl) == 0 || DECL_INITIAL (decl) == 0))
1264 sdbout_symbol (decl, 0);
1267 /* Don't output any DWARF debugging information for variables here.
1268 In the case of local variables, the information for them is output
1269 when we do our recursive traversal of the tree representation for
1270 the entire containing function. In the case of file-scope variables,
1271 we output information for all of them at the very end of compilation
1272 while we are doing our final traversal of the chain of file-scope
1275 /* If the debugging output changed sections, reselect the section
1276 that's supposed to be selected. */
1277 if (in_section != saved_in_section)
1279 /* Switch to the proper section for this data. */
1280 #ifdef SELECT_SECTION
1281 SELECT_SECTION (decl, reloc);
1283 if (TREE_READONLY (decl)
1284 && ! TREE_THIS_VOLATILE (decl)
1285 && DECL_INITIAL (decl)
1286 && (DECL_INITIAL (decl) == error_mark_node
1287 || TREE_CONSTANT (DECL_INITIAL (decl)))
1288 && ! (flag_pic && reloc))
1289 readonly_data_section ();
1295 /* Compute and output the alignment of this data. */
1297 align = DECL_ALIGN (decl);
1298 /* In the case for initialing an array whose length isn't specified,
1299 where we have not yet been able to do the layout,
1300 figure out the proper alignment now. */
1301 if (dont_output_data && DECL_SIZE (decl) == 0
1302 && TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE)
1303 align = MAX (align, TYPE_ALIGN (TREE_TYPE (TREE_TYPE (decl))));
1305 /* Some object file formats have a maximum alignment which they support.
1306 In particular, a.out format supports a maximum alignment of 4. */
1307 #ifndef MAX_OFILE_ALIGNMENT
1308 #define MAX_OFILE_ALIGNMENT BIGGEST_ALIGNMENT
1310 if (align > MAX_OFILE_ALIGNMENT)
1312 warning_with_decl (decl,
1313 "alignment of `%s' is greater than maximum object file alignment");
1314 align = MAX_OFILE_ALIGNMENT;
1316 #ifdef DATA_ALIGNMENT
1317 /* On some machines, it is good to increase alignment sometimes. */
1318 align = DATA_ALIGNMENT (TREE_TYPE (decl), align);
1320 #ifdef CONSTANT_ALIGNMENT
1321 if (DECL_INITIAL (decl))
1322 align = CONSTANT_ALIGNMENT (DECL_INITIAL (decl), align);
1325 /* Reset the alignment in case we have made it tighter, so we can benefit
1326 from it in get_pointer_alignment. */
1327 DECL_ALIGN (decl) = align;
1329 if (align > BITS_PER_UNIT)
1331 if (output_bytecode)
1332 BC_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT));
1334 ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT));
1337 /* Do any machine/system dependent processing of the object. */
1338 #ifdef ASM_DECLARE_OBJECT_NAME
1339 last_assemble_variable_decl = decl;
1340 ASM_DECLARE_OBJECT_NAME (asm_out_file, name, decl);
1342 /* Standard thing is just output label for the object. */
1343 if (output_bytecode)
1344 BC_OUTPUT_LABEL (asm_out_file, name);
1346 ASM_OUTPUT_LABEL (asm_out_file, name);
1347 #endif /* ASM_DECLARE_OBJECT_NAME */
1349 if (!dont_output_data)
1351 if (DECL_INITIAL (decl))
1352 /* Output the actual data. */
1353 output_constant (DECL_INITIAL (decl), TREE_INT_CST_LOW (size_tree));
1355 /* Leave space for it. */
1356 assemble_zeros (TREE_INT_CST_LOW (size_tree));
1360 #ifdef XCOFF_DEBUGGING_INFO
1361 /* Unfortunately, the IBM assembler cannot handle stabx before the actual
1362 declaration. When something like ".stabx "aa:S-2",aa,133,0" is emitted
1363 and `aa' hasn't been output yet, the assembler generates a stab entry with
1364 a value of zero, in addition to creating an unnecessary external entry
1365 for `aa'. Hence, we must postpone dbxout_symbol to here at the end. */
1367 /* File-scope global variables are output here. */
1368 if (write_symbols == XCOFF_DEBUG && top_level)
1370 saved_in_section = in_section;
1372 dbxout_symbol (decl, 0);
1374 if (in_section != saved_in_section)
1376 /* Switch to the proper section for this data. */
1377 #ifdef SELECT_SECTION
1378 SELECT_SECTION (decl, reloc);
1380 if (TREE_READONLY (decl)
1381 && ! TREE_THIS_VOLATILE (decl)
1382 && DECL_INITIAL (decl)
1383 && (DECL_INITIAL (decl) == error_mark_node
1384 || TREE_CONSTANT (DECL_INITIAL (decl)))
1385 && ! (flag_pic && reloc))
1386 readonly_data_section ();
1393 /* There must be a statement after a label. */
1398 /* Return 1 if type TYPE contains any pointers. */
1401 contains_pointers_p (type)
1404 switch (TREE_CODE (type))
1407 case REFERENCE_TYPE:
1408 /* I'm not sure whether OFFSET_TYPE needs this treatment,
1409 so I'll play safe and return 1. */
1415 case QUAL_UNION_TYPE:
1418 /* For a type that has fields, see if the fields have pointers. */
1419 for (fields = TYPE_FIELDS (type); fields; fields = TREE_CHAIN (fields))
1420 if (TREE_CODE (fields) == FIELD_DECL
1421 && contains_pointers_p (TREE_TYPE (fields)))
1427 /* An array type contains pointers if its element type does. */
1428 return contains_pointers_p (TREE_TYPE (type));
1435 /* Output text storage for constructor CONSTR. */
1438 bc_output_constructor (constr, size)
1444 /* Must always be a literal; non-literal constructors are handled
1447 if (!TREE_CONSTANT (constr))
1454 for (i = 0; TYPE_ALIGN (constr) >= BITS_PER_UNIT << (i + 1); i++)
1458 BC_OUTPUT_ALIGN (asm_out_file, i);
1461 output_constant (constr, size);
1464 /* Create storage for constructor CONSTR. */
1467 bc_output_data_constructor (constr)
1472 /* Put in data section */
1476 for (i = 0; TYPE_ALIGN (constr) >= BITS_PER_UNIT << (i + 1); i++);
1478 BC_OUTPUT_ALIGN (asm_out_file, i);
1480 /* The constructor is filled in at runtime. */
1481 BC_OUTPUT_SKIP (asm_out_file, int_size_in_bytes (TREE_TYPE (constr)));
1484 /* Output something to declare an external symbol to the assembler.
1485 (Most assemblers don't need this, so we normally output nothing.)
1486 Do nothing if DECL is not external. */
1489 assemble_external (decl)
1492 if (output_bytecode)
1495 #ifdef ASM_OUTPUT_EXTERNAL
1496 if (TREE_CODE_CLASS (TREE_CODE (decl)) == 'd'
1497 && DECL_EXTERNAL (decl) && TREE_PUBLIC (decl))
1499 rtx rtl = DECL_RTL (decl);
1501 if (GET_CODE (rtl) == MEM && GET_CODE (XEXP (rtl, 0)) == SYMBOL_REF
1502 && ! SYMBOL_REF_USED (XEXP (rtl, 0)))
1504 /* Some systems do require some output. */
1505 SYMBOL_REF_USED (XEXP (rtl, 0)) = 1;
1506 ASM_OUTPUT_EXTERNAL (asm_out_file, decl, XSTR (XEXP (rtl, 0), 0));
1512 /* Similar, for calling a library function FUN. */
1515 assemble_external_libcall (fun)
1518 #ifdef ASM_OUTPUT_EXTERNAL_LIBCALL
1519 if (!output_bytecode)
1521 /* Declare library function name external when first used, if nec. */
1522 if (! SYMBOL_REF_USED (fun))
1524 SYMBOL_REF_USED (fun) = 1;
1525 ASM_OUTPUT_EXTERNAL_LIBCALL (asm_out_file, fun);
1531 /* Declare the label NAME global. */
1534 assemble_global (name)
1537 ASM_GLOBALIZE_LABEL (asm_out_file, name);
1540 /* Assemble a label named NAME. */
1543 assemble_label (name)
1546 if (output_bytecode)
1547 BC_OUTPUT_LABEL (asm_out_file, name);
1549 ASM_OUTPUT_LABEL (asm_out_file, name);
1552 /* Output to FILE a reference to the assembler name of a C-level name NAME.
1553 If NAME starts with a *, the rest of NAME is output verbatim.
1554 Otherwise NAME is transformed in an implementation-defined way
1555 (usually by the addition of an underscore).
1556 Many macros in the tm file are defined to call this function. */
1559 assemble_name (file, name)
1565 STRIP_NAME_ENCODING (real_name, name);
1566 TREE_SYMBOL_REFERENCED (get_identifier (real_name)) = 1;
1570 if (output_bytecode)
1571 bc_emit_labelref (name);
1573 fputs (&name[1], file);
1577 if (output_bytecode)
1578 BC_OUTPUT_LABELREF (file, name);
1580 ASM_OUTPUT_LABELREF (file, name);
1584 /* Allocate SIZE bytes writable static space with a gensym name
1585 and return an RTX to refer to its address. */
1588 assemble_static_space (size)
1594 /* Round size up to multiple of BIGGEST_ALIGNMENT bits
1595 so that each uninitialized object starts on such a boundary. */
1596 int rounded = ((size + (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - 1)
1597 / (BIGGEST_ALIGNMENT / BITS_PER_UNIT)
1598 * (BIGGEST_ALIGNMENT / BITS_PER_UNIT));
1601 if (flag_shared_data)
1605 ASM_GENERATE_INTERNAL_LABEL (name, "LF", const_labelno);
1608 namestring = (char *) obstack_alloc (saveable_obstack,
1610 strcpy (namestring, name);
1612 if (output_bytecode)
1613 x = bc_gen_rtx (namestring, 0, (struct bc_label *) 0);
1615 x = gen_rtx (SYMBOL_REF, Pmode, namestring);
1617 if (output_bytecode)
1619 BC_OUTPUT_LOCAL (asm_out_file, name, size, rounded);
1623 #ifdef ASM_OUTPUT_ALIGNED_LOCAL
1624 ASM_OUTPUT_ALIGNED_LOCAL (asm_out_file, name, size, BIGGEST_ALIGNMENT);
1626 ASM_OUTPUT_LOCAL (asm_out_file, name, size, rounded);
1632 /* Assemble the static constant template for function entry trampolines.
1633 This is done at most once per compilation.
1634 Returns an RTX for the address of the template. */
1637 assemble_trampoline_template ()
1643 /* Shouldn't get here */
1644 if (output_bytecode)
1647 /* By default, put trampoline templates in read-only data section. */
1649 #ifdef TRAMPOLINE_SECTION
1650 TRAMPOLINE_SECTION ();
1652 readonly_data_section ();
1655 /* Write the assembler code to define one. */
1656 align = floor_log2 (FUNCTION_BOUNDARY / BITS_PER_UNIT);
1658 ASM_OUTPUT_ALIGN (asm_out_file, align);
1660 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LTRAMP", 0);
1661 TRAMPOLINE_TEMPLATE (asm_out_file);
1663 /* Record the rtl to refer to it. */
1664 ASM_GENERATE_INTERNAL_LABEL (label, "LTRAMP", 0);
1666 = (char *) obstack_copy0 (&permanent_obstack, label, strlen (label));
1667 return gen_rtx (SYMBOL_REF, Pmode, name);
1670 /* Assemble the integer constant X into an object of SIZE bytes.
1671 X must be either a CONST_INT or CONST_DOUBLE.
1673 Return 1 if we were able to output the constant, otherwise 0. If FORCE is
1674 non-zero, abort if we can't output the constant. */
1677 assemble_integer (x, size, force)
1682 /* First try to use the standard 1, 2, 4, 8, and 16 byte
1683 ASM_OUTPUT... macros. */
1687 #ifdef ASM_OUTPUT_CHAR
1689 ASM_OUTPUT_CHAR (asm_out_file, x);
1693 #ifdef ASM_OUTPUT_SHORT
1695 ASM_OUTPUT_SHORT (asm_out_file, x);
1699 #ifdef ASM_OUTPUT_INT
1701 ASM_OUTPUT_INT (asm_out_file, x);
1705 #ifdef ASM_OUTPUT_DOUBLE_INT
1707 ASM_OUTPUT_DOUBLE_INT (asm_out_file, x);
1711 #ifdef ASM_OUTPUT_QUADRUPLE_INT
1713 ASM_OUTPUT_QUADRUPLE_INT (asm_out_file, x);
1718 /* If we couldn't do it that way, there are two other possibilities: First,
1719 if the machine can output an explicit byte and this is a 1 byte constant,
1720 we can use ASM_OUTPUT_BYTE. */
1722 #ifdef ASM_OUTPUT_BYTE
1723 if (size == 1 && GET_CODE (x) == CONST_INT)
1725 ASM_OUTPUT_BYTE (asm_out_file, INTVAL (x));
1730 /* Finally, if SIZE is larger than a single word, try to output the constant
1731 one word at a time. */
1733 if (size > UNITS_PER_WORD)
1736 enum machine_mode mode
1737 = mode_for_size (size * BITS_PER_UNIT, MODE_INT, 0);
1740 for (i = 0; i < size / UNITS_PER_WORD; i++)
1742 word = operand_subword (x, i, 0, mode);
1747 if (! assemble_integer (word, UNITS_PER_WORD, 0))
1751 if (i == size / UNITS_PER_WORD)
1753 /* If we output at least one word and then could not finish,
1754 there is no valid way to continue. */
1765 /* Assemble the floating-point constant D into an object of size MODE. */
1768 assemble_real (d, mode)
1770 enum machine_mode mode;
1772 jmp_buf output_constant_handler;
1774 if (setjmp (output_constant_handler))
1776 error ("floating point trap outputting a constant");
1777 #ifdef REAL_IS_NOT_DOUBLE
1778 bzero ((char *) &d, sizeof d);
1785 set_float_handler (output_constant_handler);
1789 #ifdef ASM_OUTPUT_BYTE_FLOAT
1791 ASM_OUTPUT_BYTE_FLOAT (asm_out_file, d);
1794 #ifdef ASM_OUTPUT_SHORT_FLOAT
1796 ASM_OUTPUT_SHORT_FLOAT (asm_out_file, d);
1799 #ifdef ASM_OUTPUT_THREE_QUARTER_FLOAT
1801 ASM_OUTPUT_THREE_QUARTER_FLOAT (asm_out_file, d);
1804 #ifdef ASM_OUTPUT_FLOAT
1806 ASM_OUTPUT_FLOAT (asm_out_file, d);
1810 #ifdef ASM_OUTPUT_DOUBLE
1812 ASM_OUTPUT_DOUBLE (asm_out_file, d);
1816 #ifdef ASM_OUTPUT_LONG_DOUBLE
1819 ASM_OUTPUT_LONG_DOUBLE (asm_out_file, d);
1827 set_float_handler (NULL_PTR);
1830 /* Here we combine duplicate floating constants to make
1831 CONST_DOUBLE rtx's, and force those out to memory when necessary. */
1833 /* Chain of all CONST_DOUBLE rtx's constructed for the current function.
1834 They are chained through the CONST_DOUBLE_CHAIN.
1835 A CONST_DOUBLE rtx has CONST_DOUBLE_MEM != cc0_rtx iff it is on this chain.
1836 In that case, CONST_DOUBLE_MEM is either a MEM,
1837 or const0_rtx if no MEM has been made for this CONST_DOUBLE yet.
1839 (CONST_DOUBLE_MEM is used only for top-level functions.
1840 See force_const_mem for explanation.) */
1842 static rtx const_double_chain;
1844 /* Return a CONST_DOUBLE or CONST_INT for a value specified as a pair of ints.
1845 For an integer, I0 is the low-order word and I1 is the high-order word.
1846 For a real number, I0 is the word with the low address
1847 and I1 is the word with the high address. */
1850 immed_double_const (i0, i1, mode)
1851 HOST_WIDE_INT i0, i1;
1852 enum machine_mode mode;
1855 int in_current_obstack;
1857 if (GET_MODE_CLASS (mode) == MODE_INT
1858 || GET_MODE_CLASS (mode) == MODE_PARTIAL_INT)
1860 /* We clear out all bits that don't belong in MODE, unless they and our
1861 sign bit are all one. So we get either a reasonable negative value
1862 or a reasonable unsigned value for this mode. */
1863 int width = GET_MODE_BITSIZE (mode);
1864 if (width < HOST_BITS_PER_WIDE_INT
1865 && ((i0 & ((HOST_WIDE_INT) (-1) << (width - 1)))
1866 != ((HOST_WIDE_INT) (-1) << (width - 1))))
1867 i0 &= ((HOST_WIDE_INT) 1 << width) - 1, i1 = 0;
1868 else if (width == HOST_BITS_PER_WIDE_INT
1869 && ! (i1 == ~0 && i0 < 0))
1871 else if (width > 2 * HOST_BITS_PER_WIDE_INT)
1872 /* We cannot represent this value as a constant. */
1875 /* If this would be an entire word for the target, but is not for
1876 the host, then sign-extend on the host so that the number will look
1877 the same way on the host that it would on the target.
1879 For example, when building a 64 bit alpha hosted 32 bit sparc
1880 targeted compiler, then we want the 32 bit unsigned value -1 to be
1881 represented as a 64 bit value -1, and not as 0x00000000ffffffff.
1882 The later confuses the sparc backend. */
1884 if (BITS_PER_WORD < HOST_BITS_PER_WIDE_INT && BITS_PER_WORD == width
1885 && (i0 & ((HOST_WIDE_INT) 1 << (width - 1))))
1886 i0 |= ((HOST_WIDE_INT) (-1) << width);
1888 /* If MODE fits within HOST_BITS_PER_WIDE_INT, always use a CONST_INT.
1890 ??? Strictly speaking, this is wrong if we create a CONST_INT
1891 for a large unsigned constant with the size of MODE being
1892 HOST_BITS_PER_WIDE_INT and later try to interpret that constant in a
1893 wider mode. In that case we will mis-interpret it as a negative
1896 Unfortunately, the only alternative is to make a CONST_DOUBLE
1897 for any constant in any mode if it is an unsigned constant larger
1898 than the maximum signed integer in an int on the host. However,
1899 doing this will break everyone that always expects to see a CONST_INT
1900 for SImode and smaller.
1902 We have always been making CONST_INTs in this case, so nothing new
1905 if (width <= HOST_BITS_PER_WIDE_INT)
1906 i1 = (i0 < 0) ? ~0 : 0;
1908 /* If this integer fits in one word, return a CONST_INT. */
1909 if ((i1 == 0 && i0 >= 0)
1910 || (i1 == ~0 && i0 < 0))
1911 return GEN_INT (i0);
1913 /* We use VOIDmode for integers. */
1917 /* Search the chain for an existing CONST_DOUBLE with the right value.
1918 If one is found, return it. */
1920 for (r = const_double_chain; r; r = CONST_DOUBLE_CHAIN (r))
1921 if (CONST_DOUBLE_LOW (r) == i0 && CONST_DOUBLE_HIGH (r) == i1
1922 && GET_MODE (r) == mode)
1925 /* No; make a new one and add it to the chain.
1927 We may be called by an optimizer which may be discarding any memory
1928 allocated during its processing (such as combine and loop). However,
1929 we will be leaving this constant on the chain, so we cannot tolerate
1930 freed memory. So switch to saveable_obstack for this allocation
1931 and then switch back if we were in current_obstack. */
1933 push_obstacks_nochange ();
1934 rtl_in_saveable_obstack ();
1935 r = gen_rtx (CONST_DOUBLE, mode, 0, i0, i1);
1938 /* Don't touch const_double_chain in nested function; see force_const_mem.
1939 Also, don't touch it if not inside any function. */
1940 if (outer_function_chain == 0 && current_function_decl != 0)
1942 CONST_DOUBLE_CHAIN (r) = const_double_chain;
1943 const_double_chain = r;
1946 /* Store const0_rtx in mem-slot since this CONST_DOUBLE is on the chain.
1947 Actual use of mem-slot is only through force_const_mem. */
1949 CONST_DOUBLE_MEM (r) = const0_rtx;
1954 /* Return a CONST_DOUBLE for a specified `double' value
1955 and machine mode. */
1958 immed_real_const_1 (d, mode)
1960 enum machine_mode mode;
1962 union real_extract u;
1964 int in_current_obstack;
1966 /* Get the desired `double' value as a sequence of ints
1967 since that is how they are stored in a CONST_DOUBLE. */
1971 /* Detect special cases. */
1973 /* Avoid REAL_VALUES_EQUAL here in order to distinguish minus zero. */
1974 if (!bcmp ((char *) &dconst0, (char *) &d, sizeof d))
1975 return CONST0_RTX (mode);
1976 /* Check for NaN first, because some ports (specifically the i386) do not
1977 emit correct ieee-fp code by default, and thus will generate a core
1978 dump here if we pass a NaN to REAL_VALUES_EQUAL and if REAL_VALUES_EQUAL
1979 does a floating point comparison. */
1980 else if (! REAL_VALUE_ISNAN (d) && REAL_VALUES_EQUAL (dconst1, d))
1981 return CONST1_RTX (mode);
1983 if (sizeof u == 2 * sizeof (HOST_WIDE_INT))
1984 return immed_double_const (u.i[0], u.i[1], mode);
1986 /* The rest of this function handles the case where
1987 a float value requires more than 2 ints of space.
1988 It will be deleted as dead code on machines that don't need it. */
1990 /* Search the chain for an existing CONST_DOUBLE with the right value.
1991 If one is found, return it. */
1993 for (r = const_double_chain; r; r = CONST_DOUBLE_CHAIN (r))
1994 if (! bcmp ((char *) &CONST_DOUBLE_LOW (r), (char *) &u, sizeof u)
1995 && GET_MODE (r) == mode)
1998 /* No; make a new one and add it to the chain.
2000 We may be called by an optimizer which may be discarding any memory
2001 allocated during its processing (such as combine and loop). However,
2002 we will be leaving this constant on the chain, so we cannot tolerate
2003 freed memory. So switch to saveable_obstack for this allocation
2004 and then switch back if we were in current_obstack. */
2006 push_obstacks_nochange ();
2007 rtl_in_saveable_obstack ();
2008 r = rtx_alloc (CONST_DOUBLE);
2010 bcopy ((char *) &u, (char *) &CONST_DOUBLE_LOW (r), sizeof u);
2013 /* Don't touch const_double_chain in nested function; see force_const_mem.
2014 Also, don't touch it if not inside any function. */
2015 if (outer_function_chain == 0 && current_function_decl != 0)
2017 CONST_DOUBLE_CHAIN (r) = const_double_chain;
2018 const_double_chain = r;
2021 /* Store const0_rtx in CONST_DOUBLE_MEM since this CONST_DOUBLE is on the
2022 chain, but has not been allocated memory. Actual use of CONST_DOUBLE_MEM
2023 is only through force_const_mem. */
2025 CONST_DOUBLE_MEM (r) = const0_rtx;
2030 /* Return a CONST_DOUBLE rtx for a value specified by EXP,
2031 which must be a REAL_CST tree node. */
2034 immed_real_const (exp)
2037 return immed_real_const_1 (TREE_REAL_CST (exp), TYPE_MODE (TREE_TYPE (exp)));
2040 /* At the end of a function, forget the memory-constants
2041 previously made for CONST_DOUBLEs. Mark them as not on real_constant_chain.
2042 Also clear out real_constant_chain and clear out all the chain-pointers. */
2045 clear_const_double_mem ()
2047 register rtx r, next;
2049 /* Don't touch CONST_DOUBLE_MEM for nested functions.
2050 See force_const_mem for explanation. */
2051 if (outer_function_chain != 0)
2054 for (r = const_double_chain; r; r = next)
2056 next = CONST_DOUBLE_CHAIN (r);
2057 CONST_DOUBLE_CHAIN (r) = 0;
2058 CONST_DOUBLE_MEM (r) = cc0_rtx;
2060 const_double_chain = 0;
2063 /* Given an expression EXP with a constant value,
2064 reduce it to the sum of an assembler symbol and an integer.
2065 Store them both in the structure *VALUE.
2066 Abort if EXP does not reduce. */
2071 HOST_WIDE_INT offset;
2075 decode_addr_const (exp, value)
2077 struct addr_const *value;
2079 register tree target = TREE_OPERAND (exp, 0);
2080 register int offset = 0;
2085 if (TREE_CODE (target) == COMPONENT_REF
2086 && (TREE_CODE (DECL_FIELD_BITPOS (TREE_OPERAND (target, 1)))
2089 offset += TREE_INT_CST_LOW (DECL_FIELD_BITPOS (TREE_OPERAND (target, 1))) / BITS_PER_UNIT;
2090 target = TREE_OPERAND (target, 0);
2092 else if (TREE_CODE (target) == ARRAY_REF)
2094 if (TREE_CODE (TREE_OPERAND (target, 1)) != INTEGER_CST
2095 || TREE_CODE (TYPE_SIZE (TREE_TYPE (target))) != INTEGER_CST)
2097 offset += ((TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (target)))
2098 * TREE_INT_CST_LOW (TREE_OPERAND (target, 1)))
2100 target = TREE_OPERAND (target, 0);
2106 switch (TREE_CODE (target))
2110 x = DECL_RTL (target);
2114 if (output_bytecode)
2115 /* FIXME: this may not be correct, check it */
2116 x = bc_gen_rtx (TREE_STRING_POINTER (target), 0, (struct bc_label *) 0);
2118 x = gen_rtx (MEM, FUNCTION_MODE,
2119 gen_rtx (LABEL_REF, VOIDmode,
2120 label_rtx (TREE_OPERAND (exp, 0))));
2127 x = TREE_CST_RTL (target);
2134 if (!output_bytecode)
2136 if (GET_CODE (x) != MEM)
2142 value->offset = offset;
2145 /* Uniquize all constants that appear in memory.
2146 Each constant in memory thus far output is recorded
2147 in `const_hash_table' with a `struct constant_descriptor'
2148 that contains a polish representation of the value of
2151 We cannot store the trees in the hash table
2152 because the trees may be temporary. */
2154 struct constant_descriptor
2156 struct constant_descriptor *next;
2162 #define MAX_HASH_TABLE 1009
2163 static struct constant_descriptor *const_hash_table[MAX_HASH_TABLE];
2165 /* Compute a hash code for a constant expression. */
2172 register int len, hi, i;
2173 register enum tree_code code = TREE_CODE (exp);
2175 if (code == INTEGER_CST)
2177 p = (char *) &TREE_INT_CST_LOW (exp);
2178 len = 2 * sizeof TREE_INT_CST_LOW (exp);
2180 else if (code == REAL_CST)
2182 p = (char *) &TREE_REAL_CST (exp);
2183 len = sizeof TREE_REAL_CST (exp);
2185 else if (code == STRING_CST)
2186 p = TREE_STRING_POINTER (exp), len = TREE_STRING_LENGTH (exp);
2187 else if (code == COMPLEX_CST)
2188 return const_hash (TREE_REALPART (exp)) * 5
2189 + const_hash (TREE_IMAGPART (exp));
2190 else if (code == CONSTRUCTOR && TREE_CODE (TREE_TYPE (exp)) == SET_TYPE)
2192 len = int_size_in_bytes (TREE_TYPE (exp));
2193 p = (char*) alloca (len);
2194 get_set_constructor_bytes (exp, (unsigned char *) p, len);
2196 else if (code == CONSTRUCTOR)
2200 /* For record type, include the type in the hashing.
2201 We do not do so for array types
2202 because (1) the sizes of the elements are sufficient
2203 and (2) distinct array types can have the same constructor.
2204 Instead, we include the array size because the constructor could
2206 if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE)
2207 hi = ((HOST_WIDE_INT) TREE_TYPE (exp) & ((1 << HASHBITS) - 1))
2210 hi = ((5 + int_size_in_bytes (TREE_TYPE (exp)))
2211 & ((1 << HASHBITS) - 1)) % MAX_HASH_TABLE;
2213 for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link))
2214 if (TREE_VALUE (link))
2215 hi = (hi * 603 + const_hash (TREE_VALUE (link))) % MAX_HASH_TABLE;
2219 else if (code == ADDR_EXPR)
2221 struct addr_const value;
2222 decode_addr_const (exp, &value);
2223 if (GET_CODE (value.base) == SYMBOL_REF)
2225 /* Don't hash the address of the SYMBOL_REF;
2226 only use the offset and the symbol name. */
2228 p = XSTR (value.base, 0);
2229 for (i = 0; p[i] != 0; i++)
2230 hi = ((hi * 613) + (unsigned)(p[i]));
2232 else if (GET_CODE (value.base) == LABEL_REF)
2233 hi = value.offset + CODE_LABEL_NUMBER (XEXP (value.base, 0)) * 13;
2235 hi &= (1 << HASHBITS) - 1;
2236 hi %= MAX_HASH_TABLE;
2239 else if (code == PLUS_EXPR || code == MINUS_EXPR)
2240 return const_hash (TREE_OPERAND (exp, 0)) * 9
2241 + const_hash (TREE_OPERAND (exp, 1));
2242 else if (code == NOP_EXPR || code == CONVERT_EXPR)
2243 return const_hash (TREE_OPERAND (exp, 0)) * 7 + 2;
2245 /* Compute hashing function */
2247 for (i = 0; i < len; i++)
2248 hi = ((hi * 613) + (unsigned)(p[i]));
2250 hi &= (1 << HASHBITS) - 1;
2251 hi %= MAX_HASH_TABLE;
2255 /* Compare a constant expression EXP with a constant-descriptor DESC.
2256 Return 1 if DESC describes a constant with the same value as EXP. */
2259 compare_constant (exp, desc)
2261 struct constant_descriptor *desc;
2263 return 0 != compare_constant_1 (exp, desc->contents);
2266 /* Compare constant expression EXP with a substring P of a constant descriptor.
2267 If they match, return a pointer to the end of the substring matched.
2268 If they do not match, return 0.
2270 Since descriptors are written in polish prefix notation,
2271 this function can be used recursively to test one operand of EXP
2272 against a subdescriptor, and if it succeeds it returns the
2273 address of the subdescriptor for the next operand. */
2276 compare_constant_1 (exp, p)
2280 register char *strp;
2282 register enum tree_code code = TREE_CODE (exp);
2284 if (code != (enum tree_code) *p++)
2287 if (code == INTEGER_CST)
2289 /* Integer constants are the same only if the same width of type. */
2290 if (*p++ != TYPE_PRECISION (TREE_TYPE (exp)))
2292 strp = (char *) &TREE_INT_CST_LOW (exp);
2293 len = 2 * sizeof TREE_INT_CST_LOW (exp);
2295 else if (code == REAL_CST)
2297 /* Real constants are the same only if the same width of type. */
2298 if (*p++ != TYPE_PRECISION (TREE_TYPE (exp)))
2300 strp = (char *) &TREE_REAL_CST (exp);
2301 len = sizeof TREE_REAL_CST (exp);
2303 else if (code == STRING_CST)
2305 if (flag_writable_strings)
2307 strp = TREE_STRING_POINTER (exp);
2308 len = TREE_STRING_LENGTH (exp);
2309 if (bcmp ((char *) &TREE_STRING_LENGTH (exp), p,
2310 sizeof TREE_STRING_LENGTH (exp)))
2312 p += sizeof TREE_STRING_LENGTH (exp);
2314 else if (code == COMPLEX_CST)
2316 p = compare_constant_1 (TREE_REALPART (exp), p);
2317 if (p == 0) return 0;
2318 p = compare_constant_1 (TREE_IMAGPART (exp), p);
2321 else if (code == CONSTRUCTOR && TREE_CODE (TREE_TYPE (exp)) == SET_TYPE)
2323 len = int_size_in_bytes (TREE_TYPE (exp));
2324 strp = (char*) alloca (len);
2325 get_set_constructor_bytes (exp, (unsigned char *) strp, len);
2327 else if (code == CONSTRUCTOR)
2330 int length = list_length (CONSTRUCTOR_ELTS (exp));
2333 if (bcmp ((char *) &length, p, sizeof length))
2337 /* For record constructors, insist that the types match.
2338 For arrays, just verify both constructors are for arrays. */
2339 if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE)
2340 type = TREE_TYPE (exp);
2343 if (bcmp ((char *) &type, p, sizeof type))
2347 /* For arrays, insist that the size in bytes match. */
2348 if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE)
2350 int size = int_size_in_bytes (TREE_TYPE (exp));
2351 if (bcmp ((char *) &size, p, sizeof size))
2356 for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link))
2358 if (TREE_VALUE (link))
2360 if ((p = compare_constant_1 (TREE_VALUE (link), p)) == 0)
2367 if (bcmp ((char *) &zero, p, sizeof zero))
2375 else if (code == ADDR_EXPR)
2377 struct addr_const value;
2378 decode_addr_const (exp, &value);
2379 strp = (char *) &value.offset;
2380 len = sizeof value.offset;
2381 /* Compare the offset. */
2383 if (*p++ != *strp++)
2385 /* Compare symbol name. */
2386 strp = XSTR (value.base, 0);
2387 len = strlen (strp) + 1;
2389 else if (code == PLUS_EXPR || code == MINUS_EXPR)
2391 p = compare_constant_1 (TREE_OPERAND (exp, 0), p);
2392 if (p == 0) return 0;
2393 p = compare_constant_1 (TREE_OPERAND (exp, 1), p);
2396 else if (code == NOP_EXPR || code == CONVERT_EXPR)
2398 p = compare_constant_1 (TREE_OPERAND (exp, 0), p);
2402 /* Compare constant contents. */
2404 if (*p++ != *strp++)
2410 /* Construct a constant descriptor for the expression EXP.
2411 It is up to the caller to enter the descriptor in the hash table. */
2413 static struct constant_descriptor *
2414 record_constant (exp)
2417 struct constant_descriptor *next = 0;
2420 /* Make a struct constant_descriptor. The first two pointers will
2421 be filled in later. Here we just leave space for them. */
2423 obstack_grow (&permanent_obstack, (char *) &next, sizeof next);
2424 obstack_grow (&permanent_obstack, (char *) &label, sizeof label);
2425 record_constant_1 (exp);
2426 return (struct constant_descriptor *) obstack_finish (&permanent_obstack);
2429 /* Add a description of constant expression EXP
2430 to the object growing in `permanent_obstack'.
2431 No need to return its address; the caller will get that
2432 from the obstack when the object is complete. */
2435 record_constant_1 (exp)
2438 register char *strp;
2440 register enum tree_code code = TREE_CODE (exp);
2442 obstack_1grow (&permanent_obstack, (unsigned int) code);
2447 obstack_1grow (&permanent_obstack, TYPE_PRECISION (TREE_TYPE (exp)));
2448 strp = (char *) &TREE_INT_CST_LOW (exp);
2449 len = 2 * sizeof TREE_INT_CST_LOW (exp);
2453 obstack_1grow (&permanent_obstack, TYPE_PRECISION (TREE_TYPE (exp)));
2454 strp = (char *) &TREE_REAL_CST (exp);
2455 len = sizeof TREE_REAL_CST (exp);
2459 if (flag_writable_strings)
2462 strp = TREE_STRING_POINTER (exp);
2463 len = TREE_STRING_LENGTH (exp);
2464 obstack_grow (&permanent_obstack, (char *) &TREE_STRING_LENGTH (exp),
2465 sizeof TREE_STRING_LENGTH (exp));
2469 record_constant_1 (TREE_REALPART (exp));
2470 record_constant_1 (TREE_IMAGPART (exp));
2474 if (TREE_CODE (TREE_TYPE (exp)) == SET_TYPE)
2476 int nbytes = int_size_in_bytes (TREE_TYPE (exp));
2477 obstack_grow (&permanent_obstack, &nbytes, sizeof (nbytes));
2478 obstack_blank (&permanent_obstack, nbytes);
2479 get_set_constructor_bytes
2480 (exp, (unsigned char *) permanent_obstack.next_free, nbytes);
2486 int length = list_length (CONSTRUCTOR_ELTS (exp));
2489 obstack_grow (&permanent_obstack, (char *) &length, sizeof length);
2491 /* For record constructors, insist that the types match.
2492 For arrays, just verify both constructors are for arrays. */
2493 if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE)
2494 type = TREE_TYPE (exp);
2497 obstack_grow (&permanent_obstack, (char *) &type, sizeof type);
2499 /* For arrays, insist that the size in bytes match. */
2500 if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE)
2502 int size = int_size_in_bytes (TREE_TYPE (exp));
2503 obstack_grow (&permanent_obstack, (char *) &size, sizeof size);
2506 for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link))
2508 if (TREE_VALUE (link))
2509 record_constant_1 (TREE_VALUE (link));
2514 obstack_grow (&permanent_obstack,
2515 (char *) &zero, sizeof zero);
2523 struct addr_const value;
2525 decode_addr_const (exp, &value);
2526 /* Record the offset. */
2527 obstack_grow (&permanent_obstack,
2528 (char *) &value.offset, sizeof value.offset);
2529 /* Record the symbol name. */
2530 obstack_grow (&permanent_obstack, XSTR (value.base, 0),
2531 strlen (XSTR (value.base, 0)) + 1);
2537 record_constant_1 (TREE_OPERAND (exp, 0));
2538 record_constant_1 (TREE_OPERAND (exp, 1));
2543 case NON_LVALUE_EXPR:
2544 record_constant_1 (TREE_OPERAND (exp, 0));
2551 /* Record constant contents. */
2552 obstack_grow (&permanent_obstack, strp, len);
2555 /* Record a list of constant expressions that were passed to
2556 output_constant_def but that could not be output right away. */
2558 struct deferred_constant
2560 struct deferred_constant *next;
2566 static struct deferred_constant *deferred_constants;
2568 /* Nonzero means defer output of addressed subconstants
2569 (i.e., those for which output_constant_def is called.) */
2570 static int defer_addressed_constants_flag;
2572 /* Start deferring output of subconstants. */
2575 defer_addressed_constants ()
2577 defer_addressed_constants_flag++;
2580 /* Stop deferring output of subconstants,
2581 and output now all those that have been deferred. */
2584 output_deferred_addressed_constants ()
2586 struct deferred_constant *p, *next;
2588 defer_addressed_constants_flag--;
2590 if (defer_addressed_constants_flag > 0)
2593 for (p = deferred_constants; p; p = next)
2595 output_constant_def_contents (p->exp, p->reloc, p->labelno);
2600 deferred_constants = 0;
2603 /* Make a copy of the whole tree structure for a constant.
2604 This handles the same types of nodes that compare_constant
2605 and record_constant handle. */
2611 switch (TREE_CODE (exp))
2614 /* For ADDR_EXPR, we do not want to copy the decl whose address
2615 is requested. We do want to copy constants though. */
2616 if (TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp, 0))) == 'c')
2617 return build1 (TREE_CODE (exp), TREE_TYPE (exp),
2618 copy_constant (TREE_OPERAND (exp, 0)));
2620 return copy_node (exp);
2625 return copy_node (exp);
2628 return build_complex (copy_constant (TREE_REALPART (exp)),
2629 copy_constant (TREE_IMAGPART (exp)));
2633 return build (TREE_CODE (exp), TREE_TYPE (exp),
2634 copy_constant (TREE_OPERAND (exp, 0)),
2635 copy_constant (TREE_OPERAND (exp, 1)));
2639 return build1 (TREE_CODE (exp), TREE_TYPE (exp),
2640 copy_constant (TREE_OPERAND (exp, 0)));
2644 tree copy = copy_node (exp);
2645 tree list = copy_list (CONSTRUCTOR_ELTS (exp));
2648 CONSTRUCTOR_ELTS (copy) = list;
2649 for (tail = list; tail; tail = TREE_CHAIN (tail))
2650 TREE_VALUE (tail) = copy_constant (TREE_VALUE (tail));
2651 if (TREE_CODE (TREE_TYPE (exp)) == SET_TYPE)
2652 for (tail = list; tail; tail = TREE_CHAIN (tail))
2653 TREE_PURPOSE (tail) = copy_constant (TREE_PURPOSE (tail));
2663 /* Return an rtx representing a reference to constant data in memory
2664 for the constant expression EXP.
2666 If assembler code for such a constant has already been output,
2667 return an rtx to refer to it.
2668 Otherwise, output such a constant in memory (or defer it for later)
2669 and generate an rtx for it.
2671 The TREE_CST_RTL of EXP is set up to point to that rtx.
2672 The const_hash_table records which constants already have label strings. */
2675 output_constant_def (exp)
2679 register struct constant_descriptor *desc;
2685 if (TREE_CODE (exp) == INTEGER_CST)
2686 abort (); /* No TREE_CST_RTL slot in these. */
2688 if (TREE_CST_RTL (exp))
2689 return TREE_CST_RTL (exp);
2691 /* Make sure any other constants whose addresses appear in EXP
2692 are assigned label numbers. */
2694 reloc = output_addressed_constants (exp);
2696 /* Compute hash code of EXP. Search the descriptors for that hash code
2697 to see if any of them describes EXP. If yes, the descriptor records
2698 the label number already assigned. */
2700 hash = const_hash (exp) % MAX_HASH_TABLE;
2702 for (desc = const_hash_table[hash]; desc; desc = desc->next)
2703 if (compare_constant (exp, desc))
2705 found = desc->label;
2711 /* No constant equal to EXP is known to have been output.
2712 Make a constant descriptor to enter EXP in the hash table.
2713 Assign the label number and record it in the descriptor for
2714 future calls to this function to find. */
2716 /* Create a string containing the label name, in LABEL. */
2717 ASM_GENERATE_INTERNAL_LABEL (label, "LC", const_labelno);
2719 desc = record_constant (exp);
2720 desc->next = const_hash_table[hash];
2722 = (char *) obstack_copy0 (&permanent_obstack, label, strlen (label));
2723 const_hash_table[hash] = desc;
2727 /* Create a string containing the label name, in LABEL. */
2728 ASM_GENERATE_INTERNAL_LABEL (label, "LC", const_labelno);
2731 /* We have a symbol name; construct the SYMBOL_REF and the MEM. */
2733 push_obstacks_nochange ();
2734 if (TREE_PERMANENT (exp))
2735 end_temporary_allocation ();
2737 def = gen_rtx (SYMBOL_REF, Pmode, desc->label);
2740 = gen_rtx (MEM, TYPE_MODE (TREE_TYPE (exp)), def);
2741 RTX_UNCHANGING_P (TREE_CST_RTL (exp)) = 1;
2742 if (AGGREGATE_TYPE_P (TREE_TYPE (exp)))
2743 MEM_IN_STRUCT_P (TREE_CST_RTL (exp)) = 1;
2747 /* Optionally set flags or add text to the name to record information
2748 such as that it is a function name. If the name is changed, the macro
2749 ASM_OUTPUT_LABELREF will have to know how to strip this information. */
2750 #ifdef ENCODE_SECTION_INFO
2751 ENCODE_SECTION_INFO (exp);
2754 /* If this is the first time we've seen this particular constant,
2755 output it (or defer its output for later). */
2758 if (defer_addressed_constants_flag)
2760 struct deferred_constant *p;
2761 p = (struct deferred_constant *) xmalloc (sizeof (struct deferred_constant));
2763 push_obstacks_nochange ();
2764 suspend_momentary ();
2765 p->exp = copy_constant (exp);
2768 p->labelno = const_labelno++;
2769 p->next = deferred_constants;
2770 deferred_constants = p;
2773 output_constant_def_contents (exp, reloc, const_labelno++);
2776 return TREE_CST_RTL (exp);
2779 /* Now output assembler code to define the label for EXP,
2780 and follow it with the data of EXP. */
2783 output_constant_def_contents (exp, reloc, labelno)
2790 if (IN_NAMED_SECTION (exp))
2791 named_section (exp, NULL);
2794 /* First switch to text section, except for writable strings. */
2795 #ifdef SELECT_SECTION
2796 SELECT_SECTION (exp, reloc);
2798 if (((TREE_CODE (exp) == STRING_CST) && flag_writable_strings)
2799 || (flag_pic && reloc))
2802 readonly_data_section ();
2806 /* Align the location counter as required by EXP's data type. */
2807 align = TYPE_ALIGN (TREE_TYPE (exp));
2808 #ifdef CONSTANT_ALIGNMENT
2809 align = CONSTANT_ALIGNMENT (exp, align);
2812 if (align > BITS_PER_UNIT)
2814 if (!output_bytecode)
2816 ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT));
2820 BC_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT));
2824 /* Output the label itself. */
2825 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LC", labelno);
2827 /* Output the value of EXP. */
2828 output_constant (exp,
2829 (TREE_CODE (exp) == STRING_CST
2830 ? TREE_STRING_LENGTH (exp)
2831 : int_size_in_bytes (TREE_TYPE (exp))));
2835 /* Similar hash facility for making memory-constants
2836 from constant rtl-expressions. It is used on RISC machines
2837 where immediate integer arguments and constant addresses are restricted
2838 so that such constants must be stored in memory.
2840 This pool of constants is reinitialized for each function
2841 so each function gets its own constants-pool that comes right before it.
2843 All structures allocated here are discarded when functions are saved for
2844 inlining, so they do not need to be allocated permanently. */
2846 #define MAX_RTX_HASH_TABLE 61
2847 static struct constant_descriptor **const_rtx_hash_table;
2849 /* Structure to represent sufficient information about a constant so that
2850 it can be output when the constant pool is output, so that function
2851 integration can be done, and to simplify handling on machines that reference
2852 constant pool as base+displacement. */
2854 struct pool_constant
2856 struct constant_descriptor *desc;
2857 struct pool_constant *next;
2858 enum machine_mode mode;
2865 /* Pointers to first and last constant in pool. */
2867 static struct pool_constant *first_pool, *last_pool;
2869 /* Current offset in constant pool (does not include any machine-specific
2872 static int pool_offset;
2874 /* Structure used to maintain hash table mapping symbols used to their
2875 corresponding constants. */
2880 struct pool_constant *pool;
2881 struct pool_sym *next;
2884 static struct pool_sym **const_rtx_sym_hash_table;
2886 /* Hash code for a SYMBOL_REF with CONSTANT_POOL_ADDRESS_P true.
2887 The argument is XSTR (... , 0) */
2889 #define SYMHASH(LABEL) \
2890 ((((HOST_WIDE_INT) (LABEL)) & ((1 << HASHBITS) - 1)) % MAX_RTX_HASH_TABLE)
2892 /* Initialize constant pool hashing for next function. */
2895 init_const_rtx_hash_table ()
2897 const_rtx_hash_table
2898 = ((struct constant_descriptor **)
2899 oballoc (MAX_RTX_HASH_TABLE * sizeof (struct constant_descriptor *)));
2900 const_rtx_sym_hash_table
2901 = ((struct pool_sym **)
2902 oballoc (MAX_RTX_HASH_TABLE * sizeof (struct pool_sym *)));
2903 bzero ((char *) const_rtx_hash_table,
2904 MAX_RTX_HASH_TABLE * sizeof (struct constant_descriptor *));
2905 bzero ((char *) const_rtx_sym_hash_table,
2906 MAX_RTX_HASH_TABLE * sizeof (struct pool_sym *));
2908 first_pool = last_pool = 0;
2912 /* Save and restore status for a nested function. */
2915 save_varasm_status (p)
2918 p->const_rtx_hash_table = const_rtx_hash_table;
2919 p->const_rtx_sym_hash_table = const_rtx_sym_hash_table;
2920 p->first_pool = first_pool;
2921 p->last_pool = last_pool;
2922 p->pool_offset = pool_offset;
2926 restore_varasm_status (p)
2929 const_rtx_hash_table = p->const_rtx_hash_table;
2930 const_rtx_sym_hash_table = p->const_rtx_sym_hash_table;
2931 first_pool = p->first_pool;
2932 last_pool = p->last_pool;
2933 pool_offset = p->pool_offset;
2936 enum kind { RTX_DOUBLE, RTX_INT };
2940 #ifdef ONLY_INT_FIELDS
2941 unsigned int kind : 16;
2942 unsigned int mode : 16;
2944 enum kind kind : 16;
2945 enum machine_mode mode : 16;
2948 union real_extract du;
2949 struct addr_const addr;
2953 /* Express an rtx for a constant integer (perhaps symbolic)
2954 as the sum of a symbol or label plus an explicit integer.
2955 They are stored into VALUE. */
2958 decode_rtx_const (mode, x, value)
2959 enum machine_mode mode;
2961 struct rtx_const *value;
2963 /* Clear the whole structure, including any gaps. */
2966 int *p = (int *) value;
2967 int *end = (int *) (value + 1);
2972 value->kind = RTX_INT; /* Most usual kind. */
2975 switch (GET_CODE (x))
2978 value->kind = RTX_DOUBLE;
2979 if (GET_MODE (x) != VOIDmode)
2980 value->mode = GET_MODE (x);
2981 bcopy ((char *) &CONST_DOUBLE_LOW (x),
2982 (char *) &value->un.du, sizeof value->un.du);
2986 value->un.addr.offset = INTVAL (x);
2992 value->un.addr.base = x;
2997 if (GET_CODE (x) == PLUS)
2999 value->un.addr.base = XEXP (x, 0);
3000 if (GET_CODE (XEXP (x, 1)) != CONST_INT)
3002 value->un.addr.offset = INTVAL (XEXP (x, 1));
3004 else if (GET_CODE (x) == MINUS)
3006 value->un.addr.base = XEXP (x, 0);
3007 if (GET_CODE (XEXP (x, 1)) != CONST_INT)
3009 value->un.addr.offset = - INTVAL (XEXP (x, 1));
3019 if (value->kind == RTX_INT && value->un.addr.base != 0)
3020 switch (GET_CODE (value->un.addr.base))
3024 /* Use the string's address, not the SYMBOL_REF's address,
3025 for the sake of addresses of library routines.
3026 For a LABEL_REF, compare labels. */
3027 value->un.addr.base = XEXP (value->un.addr.base, 0);
3031 /* Given a MINUS expression, simplify it if both sides
3032 include the same symbol. */
3035 simplify_subtraction (x)
3038 struct rtx_const val0, val1;
3040 decode_rtx_const (GET_MODE (x), XEXP (x, 0), &val0);
3041 decode_rtx_const (GET_MODE (x), XEXP (x, 1), &val1);
3043 if (val0.un.addr.base == val1.un.addr.base)
3044 return GEN_INT (val0.un.addr.offset - val1.un.addr.offset);
3048 /* Compute a hash code for a constant RTL expression. */
3051 const_hash_rtx (mode, x)
3052 enum machine_mode mode;
3057 struct rtx_const value;
3058 decode_rtx_const (mode, x, &value);
3060 /* Compute hashing function */
3062 for (i = 0; i < sizeof value / sizeof (int); i++)
3063 hi += ((int *) &value)[i];
3065 hi &= (1 << HASHBITS) - 1;
3066 hi %= MAX_RTX_HASH_TABLE;
3070 /* Compare a constant rtl object X with a constant-descriptor DESC.
3071 Return 1 if DESC describes a constant with the same value as X. */
3074 compare_constant_rtx (mode, x, desc)
3075 enum machine_mode mode;
3077 struct constant_descriptor *desc;
3079 register int *p = (int *) desc->contents;
3082 struct rtx_const value;
3084 decode_rtx_const (mode, x, &value);
3085 strp = (int *) &value;
3086 len = sizeof value / sizeof (int);
3088 /* Compare constant contents. */
3090 if (*p++ != *strp++)
3096 /* Construct a constant descriptor for the rtl-expression X.
3097 It is up to the caller to enter the descriptor in the hash table. */
3099 static struct constant_descriptor *
3100 record_constant_rtx (mode, x)
3101 enum machine_mode mode;
3104 struct constant_descriptor *ptr;
3106 struct rtx_const value;
3108 decode_rtx_const (mode, x, &value);
3110 /* Put these things in the saveable obstack so we can ensure it won't
3111 be freed if we are called from combine or some other phase that discards
3112 memory allocated from function_obstack (current_obstack). */
3113 obstack_grow (saveable_obstack, &ptr, sizeof ptr);
3114 obstack_grow (saveable_obstack, &label, sizeof label);
3116 /* Record constant contents. */
3117 obstack_grow (saveable_obstack, &value, sizeof value);
3119 return (struct constant_descriptor *) obstack_finish (saveable_obstack);
3122 /* Given a constant rtx X, make (or find) a memory constant for its value
3123 and return a MEM rtx to refer to it in memory. */
3126 force_const_mem (mode, x)
3127 enum machine_mode mode;
3131 register struct constant_descriptor *desc;
3136 /* If we want this CONST_DOUBLE in the same mode as it is in memory
3137 (this will always be true for floating CONST_DOUBLEs that have been
3138 placed in memory, but not for VOIDmode (integer) CONST_DOUBLEs),
3139 use the previous copy. Otherwise, make a new one. Note that in
3140 the unlikely event that this same CONST_DOUBLE is used in two different
3141 modes in an alternating fashion, we will allocate a lot of different
3142 memory locations, but this should be extremely rare. */
3144 /* Don't use CONST_DOUBLE_MEM in a nested function.
3145 Nested functions have their own constant pools,
3146 so they can't share the same values in CONST_DOUBLE_MEM
3147 with the containing function. */
3148 if (outer_function_chain == 0)
3149 if (GET_CODE (x) == CONST_DOUBLE
3150 && GET_CODE (CONST_DOUBLE_MEM (x)) == MEM
3151 && GET_MODE (CONST_DOUBLE_MEM (x)) == mode)
3152 return CONST_DOUBLE_MEM (x);
3154 /* Compute hash code of X. Search the descriptors for that hash code
3155 to see if any of them describes X. If yes, the descriptor records
3156 the label number already assigned. */
3158 hash = const_hash_rtx (mode, x);
3160 for (desc = const_rtx_hash_table[hash]; desc; desc = desc->next)
3161 if (compare_constant_rtx (mode, x, desc))
3163 found = desc->label;
3169 register struct pool_constant *pool;
3170 register struct pool_sym *sym;
3173 /* No constant equal to X is known to have been output.
3174 Make a constant descriptor to enter X in the hash table.
3175 Assign the label number and record it in the descriptor for
3176 future calls to this function to find. */
3178 desc = record_constant_rtx (mode, x);
3179 desc->next = const_rtx_hash_table[hash];
3180 const_rtx_hash_table[hash] = desc;
3182 /* Align the location counter as required by EXP's data type. */
3183 align = (mode == VOIDmode) ? UNITS_PER_WORD : GET_MODE_SIZE (mode);
3184 if (align > BIGGEST_ALIGNMENT / BITS_PER_UNIT)
3185 align = BIGGEST_ALIGNMENT / BITS_PER_UNIT;
3187 pool_offset += align - 1;
3188 pool_offset &= ~ (align - 1);
3190 /* If RTL is not being placed into the saveable obstack, make a
3191 copy of X that is in the saveable obstack in case we are being
3192 called from combine or some other phase that discards memory
3193 it allocates. We need only do this if it is a CONST, since
3194 no other RTX should be allocated in this situation. */
3195 if (rtl_obstack != saveable_obstack
3196 && GET_CODE (x) == CONST)
3198 push_obstacks_nochange ();
3199 rtl_in_saveable_obstack ();
3201 x = gen_rtx (CONST, GET_MODE (x),
3202 gen_rtx (PLUS, GET_MODE (x),
3203 XEXP (XEXP (x, 0), 0), XEXP (XEXP (x, 0), 1)));
3207 /* Allocate a pool constant descriptor, fill it in, and chain it in. */
3209 pool = (struct pool_constant *) savealloc (sizeof (struct pool_constant));
3213 pool->labelno = const_labelno;
3214 pool->align = align;
3215 pool->offset = pool_offset;
3221 last_pool->next = pool;
3224 pool_offset += GET_MODE_SIZE (mode);
3226 /* Create a string containing the label name, in LABEL. */
3227 ASM_GENERATE_INTERNAL_LABEL (label, "LC", const_labelno);
3232 = (char *) obstack_copy0 (saveable_obstack, label, strlen (label));
3234 /* Add label to symbol hash table. */
3235 hash = SYMHASH (found);
3236 sym = (struct pool_sym *) savealloc (sizeof (struct pool_sym));
3239 sym->next = const_rtx_sym_hash_table[hash];
3240 const_rtx_sym_hash_table[hash] = sym;
3243 /* We have a symbol name; construct the SYMBOL_REF and the MEM. */
3245 def = gen_rtx (MEM, mode, gen_rtx (SYMBOL_REF, Pmode, found));
3247 RTX_UNCHANGING_P (def) = 1;
3248 /* Mark the symbol_ref as belonging to this constants pool. */
3249 CONSTANT_POOL_ADDRESS_P (XEXP (def, 0)) = 1;
3250 current_function_uses_const_pool = 1;
3252 if (outer_function_chain == 0)
3253 if (GET_CODE (x) == CONST_DOUBLE)
3255 if (CONST_DOUBLE_MEM (x) == cc0_rtx)
3257 CONST_DOUBLE_CHAIN (x) = const_double_chain;
3258 const_double_chain = x;
3260 CONST_DOUBLE_MEM (x) = def;
3266 /* Given a SYMBOL_REF with CONSTANT_POOL_ADDRESS_P true, return a pointer to
3267 the corresponding pool_constant structure. */
3269 static struct pool_constant *
3270 find_pool_constant (addr)
3273 struct pool_sym *sym;
3274 char *label = XSTR (addr, 0);
3276 for (sym = const_rtx_sym_hash_table[SYMHASH (label)]; sym; sym = sym->next)
3277 if (sym->label == label)
3283 /* Given a constant pool SYMBOL_REF, return the corresponding constant. */
3286 get_pool_constant (addr)
3289 return (find_pool_constant (addr))->constant;
3292 /* Similar, return the mode. */
3295 get_pool_mode (addr)
3298 return (find_pool_constant (addr))->mode;
3301 /* Similar, return the offset in the constant pool. */
3304 get_pool_offset (addr)
3307 return (find_pool_constant (addr))->offset;
3310 /* Return the size of the constant pool. */
3318 /* Write all the constants in the constant pool. */
3321 output_constant_pool (fnname, fndecl)
3325 struct pool_constant *pool;
3327 union real_extract u;
3329 #ifdef ASM_OUTPUT_POOL_PROLOGUE
3330 ASM_OUTPUT_POOL_PROLOGUE (asm_out_file, fnname, fndecl, pool_offset);
3333 for (pool = first_pool; pool; pool = pool->next)
3337 /* See if X is a LABEL_REF (or a CONST referring to a LABEL_REF)
3338 whose CODE_LABEL has been deleted. This can occur if a jump table
3339 is eliminated by optimization. If so, write a constant of zero
3340 instead. Note that this can also happen by turning the
3341 CODE_LABEL into a NOTE. */
3342 if (((GET_CODE (x) == LABEL_REF
3343 && (INSN_DELETED_P (XEXP (x, 0))
3344 || GET_CODE (XEXP (x, 0)) == NOTE)))
3345 || (GET_CODE (x) == CONST && GET_CODE (XEXP (x, 0)) == PLUS
3346 && GET_CODE (XEXP (XEXP (x, 0), 0)) == LABEL_REF
3347 && (INSN_DELETED_P (XEXP (XEXP (XEXP (x, 0), 0), 0))
3348 || GET_CODE (XEXP (XEXP (XEXP (x, 0), 0), 0)) == NOTE)))
3351 /* First switch to correct section. */
3352 #ifdef SELECT_RTX_SECTION
3353 SELECT_RTX_SECTION (pool->mode, x);
3355 readonly_data_section ();
3358 #ifdef ASM_OUTPUT_SPECIAL_POOL_ENTRY
3359 ASM_OUTPUT_SPECIAL_POOL_ENTRY (asm_out_file, x, pool->mode,
3360 pool->align, pool->labelno, done);
3363 if (pool->align > 1)
3364 ASM_OUTPUT_ALIGN (asm_out_file, exact_log2 (pool->align));
3366 /* Output the label. */
3367 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LC", pool->labelno);
3369 /* Output the value of the constant itself. */
3370 switch (GET_MODE_CLASS (pool->mode))
3373 if (GET_CODE (x) != CONST_DOUBLE)
3376 bcopy ((char *) &CONST_DOUBLE_LOW (x), (char *) &u, sizeof u);
3377 assemble_real (u.d, pool->mode);
3381 case MODE_PARTIAL_INT:
3382 assemble_integer (x, GET_MODE_SIZE (pool->mode), 1);
3392 /* Done with this pool. */
3393 first_pool = last_pool = 0;
3396 /* Find all the constants whose addresses are referenced inside of EXP,
3397 and make sure assembler code with a label has been output for each one.
3398 Indicate whether an ADDR_EXPR has been encountered. */
3401 output_addressed_constants (exp)
3406 switch (TREE_CODE (exp))
3410 register tree constant = TREE_OPERAND (exp, 0);
3412 while (TREE_CODE (constant) == COMPONENT_REF)
3414 constant = TREE_OPERAND (constant, 0);
3417 if (TREE_CODE_CLASS (TREE_CODE (constant)) == 'c'
3418 || TREE_CODE (constant) == CONSTRUCTOR)
3419 /* No need to do anything here
3420 for addresses of variables or functions. */
3421 output_constant_def (constant);
3428 reloc = output_addressed_constants (TREE_OPERAND (exp, 0));
3429 reloc |= output_addressed_constants (TREE_OPERAND (exp, 1));
3434 case NON_LVALUE_EXPR:
3435 reloc = output_addressed_constants (TREE_OPERAND (exp, 0));
3441 for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link))
3442 if (TREE_VALUE (link) != 0)
3443 reloc |= output_addressed_constants (TREE_VALUE (link));
3453 /* Output assembler code for constant EXP to FILE, with no label.
3454 This includes the pseudo-op such as ".int" or ".byte", and a newline.
3455 Assumes output_addressed_constants has been done on EXP already.
3457 Generate exactly SIZE bytes of assembler data, padding at the end
3458 with zeros if necessary. SIZE must always be specified.
3460 SIZE is important for structure constructors,
3461 since trailing members may have been omitted from the constructor.
3462 It is also important for initialization of arrays from string constants
3463 since the full length of the string constant might not be wanted.
3464 It is also needed for initialization of unions, where the initializer's
3465 type is just one member, and that may not be as long as the union.
3467 There a case in which we would fail to output exactly SIZE bytes:
3468 for a structure constructor that wants to produce more than SIZE bytes.
3469 But such constructors will never be generated for any possible input. */
3472 output_constant (exp, size)
3476 register enum tree_code code = TREE_CODE (TREE_TYPE (exp));
3482 /* Eliminate the NON_LVALUE_EXPR_EXPR that makes a cast not be an lvalue.
3483 That way we get the constant (we hope) inside it. Also, strip off any
3484 NOP_EXPR that converts between two record, union, array, or set types. */
3485 while ((TREE_CODE (exp) == NOP_EXPR
3486 && (TREE_TYPE (exp) == TREE_TYPE (TREE_OPERAND (exp, 0))
3487 || AGGREGATE_TYPE_P (TREE_TYPE (exp))))
3488 || TREE_CODE (exp) == NON_LVALUE_EXPR)
3489 exp = TREE_OPERAND (exp, 0);
3491 /* Allow a constructor with no elements for any data type.
3492 This means to fill the space with zeros. */
3493 if (TREE_CODE (exp) == CONSTRUCTOR && CONSTRUCTOR_ELTS (exp) == 0)
3495 if (output_bytecode)
3496 bc_emit_const_skip (size);
3498 assemble_zeros (size);
3509 case REFERENCE_TYPE:
3510 /* ??? What about (int)((float)(int)&foo + 4) */
3511 while (TREE_CODE (exp) == NOP_EXPR || TREE_CODE (exp) == CONVERT_EXPR
3512 || TREE_CODE (exp) == NON_LVALUE_EXPR)
3513 exp = TREE_OPERAND (exp, 0);
3515 if (! assemble_integer (expand_expr (exp, NULL_RTX, VOIDmode,
3516 EXPAND_INITIALIZER),
3518 error ("initializer for integer value is too complicated");
3523 if (TREE_CODE (exp) != REAL_CST)
3524 error ("initializer for floating value is not a floating constant");
3526 assemble_real (TREE_REAL_CST (exp),
3527 mode_for_size (size * BITS_PER_UNIT, MODE_FLOAT, 0));
3532 output_constant (TREE_REALPART (exp), size / 2);
3533 output_constant (TREE_IMAGPART (exp), size / 2);
3534 size -= (size / 2) * 2;
3538 if (TREE_CODE (exp) == CONSTRUCTOR)
3540 output_constructor (exp, size);
3543 else if (TREE_CODE (exp) == STRING_CST)
3547 if (size > TREE_STRING_LENGTH (exp))
3549 excess = size - TREE_STRING_LENGTH (exp);
3550 size = TREE_STRING_LENGTH (exp);
3553 assemble_string (TREE_STRING_POINTER (exp), size);
3562 if (TREE_CODE (exp) == CONSTRUCTOR)
3563 output_constructor (exp, size);
3569 if (TREE_CODE (exp) == INTEGER_CST)
3570 assemble_integer (expand_expr (exp, NULL_RTX,
3571 VOIDmode, EXPAND_INITIALIZER),
3573 else if (TREE_CODE (exp) == CONSTRUCTOR)
3575 unsigned char *buffer = (unsigned char *) alloca (size);
3576 if (get_set_constructor_bytes (exp, buffer, size))
3578 assemble_string ((char *) buffer, size);
3581 error ("unknown set constructor type");
3586 assemble_zeros (size);
3589 /* Bytecode specific code to output assembler for integer. */
3592 bc_assemble_integer (exp, size)
3600 /* FIXME: is this fold() business going to be as good as the
3601 expand_expr() using EXPAND_SUM above in the RTL case? I
3603 FIXME: Copied as is from BC-GCC1; may need work. Don't hate. -bson */
3607 while (TREE_CODE (exp) == NOP_EXPR || TREE_CODE (exp) == CONVERT_EXPR)
3608 exp = TREE_OPERAND (exp, 0);
3609 if (TREE_CODE (exp) == INTEGER_CST)
3614 else if (TREE_CODE (exp) == PLUS_EXPR)
3616 const_part = TREE_OPERAND (exp, 0);
3617 while (TREE_CODE (const_part) == NOP_EXPR
3618 || TREE_CODE (const_part) == CONVERT_EXPR)
3619 const_part = TREE_OPERAND (const_part, 0);
3620 addr_part = TREE_OPERAND (exp, 1);
3621 while (TREE_CODE (addr_part) == NOP_EXPR
3622 || TREE_CODE (addr_part) == CONVERT_EXPR)
3623 addr_part = TREE_OPERAND (addr_part, 0);
3624 if (TREE_CODE (const_part) != INTEGER_CST)
3625 tmp = const_part, const_part = addr_part, addr_part = tmp;
3626 if (TREE_CODE (const_part) != INTEGER_CST
3627 || TREE_CODE (addr_part) != ADDR_EXPR)
3628 abort (); /* FIXME: we really haven't considered
3629 all the possible cases here. */
3631 else if (TREE_CODE (exp) == ADDR_EXPR)
3633 const_part = integer_zero_node;
3637 abort (); /* FIXME: ditto previous. */
3643 char c = TREE_INT_CST_LOW (const_part);
3649 short s = TREE_INT_CST_LOW (const_part);
3650 bc_emit ((char *) &s, 2);
3655 int i = TREE_INT_CST_LOW (const_part);
3656 bc_emit ((char *) &i, 4);
3661 if (WORDS_BIG_ENDIAN)
3663 int i = TREE_INT_CST_HIGH (const_part);
3664 bc_emit ((char *) &i, 4);
3665 i = TREE_INT_CST_LOW (const_part);
3666 bc_emit ((char *) &i, 4);
3670 int i = TREE_INT_CST_LOW (const_part);
3671 bc_emit ((char *) &i, 4);
3672 i = TREE_INT_CST_HIGH (const_part);
3673 bc_emit ((char *) &i, 4);
3680 && TREE_CODE (TREE_OPERAND (addr_part, 0)) == VAR_DECL)
3681 bc_emit_labelref (DECL_ASSEMBLER_NAME (TREE_OPERAND (addr_part, 0)),
3682 TREE_INT_CST_LOW (const_part));
3684 abort (); /* FIXME: there may be more cases. */
3687 /* Subroutine of output_constant, used for CONSTRUCTORs
3688 (aggregate constants).
3689 Generate at least SIZE bytes, padding if necessary. */
3692 output_constructor (exp, size)
3696 register tree link, field = 0;
3697 HOST_WIDE_INT min_index = 0;
3698 /* Number of bytes output or skipped so far.
3699 In other words, current position within the constructor. */
3700 int total_bytes = 0;
3701 /* Non-zero means BYTE contains part of a byte, to be output. */
3702 int byte_buffer_in_use = 0;
3705 if (HOST_BITS_PER_WIDE_INT < BITS_PER_UNIT)
3708 if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE)
3709 field = TYPE_FIELDS (TREE_TYPE (exp));
3711 if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE
3712 && TYPE_DOMAIN (TREE_TYPE (exp)) != 0)
3714 = TREE_INT_CST_LOW (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (exp))));
3716 /* As LINK goes through the elements of the constant,
3717 FIELD goes through the structure fields, if the constant is a structure.
3718 if the constant is a union, then we override this,
3719 by getting the field from the TREE_LIST element.
3720 But the constant could also be an array. Then FIELD is zero. */
3721 for (link = CONSTRUCTOR_ELTS (exp);
3723 link = TREE_CHAIN (link),
3724 field = field ? TREE_CHAIN (field) : 0)
3726 tree val = TREE_VALUE (link);
3729 /* the element in a union constructor specifies the proper field. */
3731 if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE
3732 || TREE_CODE (TREE_TYPE (exp)) == UNION_TYPE)
3734 /* if available, use the type given by link */
3735 if (TREE_PURPOSE (link) != 0)
3736 field = TREE_PURPOSE (link);
3739 if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE)
3740 index = TREE_PURPOSE (link);
3742 /* Eliminate the marker that makes a cast not be an lvalue. */
3746 if (field == 0 || !DECL_BIT_FIELD (field))
3748 /* An element that is not a bit-field. */
3750 register int fieldsize;
3751 /* Since this structure is static,
3752 we know the positions are constant. */
3753 int bitpos = (field ? (TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field))
3757 bitpos = (TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (val)))
3759 * (TREE_INT_CST_LOW (index) - min_index));
3761 /* Output any buffered-up bit-fields preceding this element. */
3762 if (byte_buffer_in_use)
3764 ASM_OUTPUT_BYTE (asm_out_file, byte);
3766 byte_buffer_in_use = 0;
3769 /* Advance to offset of this element.
3770 Note no alignment needed in an array, since that is guaranteed
3771 if each element has the proper size. */
3772 if ((field != 0 || index != 0) && bitpos != total_bytes)
3774 if (!output_bytecode)
3775 assemble_zeros (bitpos - total_bytes);
3777 bc_emit_const_skip (bitpos - total_bytes);
3778 total_bytes = bitpos;
3781 /* Determine size this element should occupy. */
3784 if (TREE_CODE (DECL_SIZE (field)) != INTEGER_CST)
3786 if (TREE_INT_CST_LOW (DECL_SIZE (field)) > 100000)
3788 /* This avoids overflow trouble. */
3789 tree size_tree = size_binop (CEIL_DIV_EXPR,
3791 size_int (BITS_PER_UNIT));
3792 fieldsize = TREE_INT_CST_LOW (size_tree);
3796 fieldsize = TREE_INT_CST_LOW (DECL_SIZE (field));
3797 fieldsize = (fieldsize + BITS_PER_UNIT - 1) / BITS_PER_UNIT;
3801 fieldsize = int_size_in_bytes (TREE_TYPE (TREE_TYPE (exp)));
3803 /* Output the element's initial value. */
3805 assemble_zeros (fieldsize);
3807 output_constant (val, fieldsize);
3809 /* Count its size. */
3810 total_bytes += fieldsize;
3812 else if (val != 0 && TREE_CODE (val) != INTEGER_CST)
3813 error ("invalid initial value for member `%s'",
3814 IDENTIFIER_POINTER (DECL_NAME (field)));
3817 /* Element that is a bit-field. */
3819 int next_offset = TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field));
3821 = (next_offset + TREE_INT_CST_LOW (DECL_SIZE (field)));
3824 val = integer_zero_node;
3826 /* If this field does not start in this (or, next) byte,
3828 if (next_offset / BITS_PER_UNIT != total_bytes)
3830 /* Output remnant of any bit field in previous bytes. */
3831 if (byte_buffer_in_use)
3833 ASM_OUTPUT_BYTE (asm_out_file, byte);
3835 byte_buffer_in_use = 0;
3838 /* If still not at proper byte, advance to there. */
3839 if (next_offset / BITS_PER_UNIT != total_bytes)
3841 assemble_zeros (next_offset / BITS_PER_UNIT - total_bytes);
3842 total_bytes = next_offset / BITS_PER_UNIT;
3846 if (! byte_buffer_in_use)
3849 /* We must split the element into pieces that fall within
3850 separate bytes, and combine each byte with previous or
3851 following bit-fields. */
3853 /* next_offset is the offset n fbits from the beginning of
3854 the structure to the next bit of this element to be processed.
3855 end_offset is the offset of the first bit past the end of
3857 while (next_offset < end_offset)
3861 HOST_WIDE_INT value;
3862 int next_byte = next_offset / BITS_PER_UNIT;
3863 int next_bit = next_offset % BITS_PER_UNIT;
3865 /* Advance from byte to byte
3866 within this element when necessary. */
3867 while (next_byte != total_bytes)
3869 ASM_OUTPUT_BYTE (asm_out_file, byte);
3874 /* Number of bits we can process at once
3875 (all part of the same byte). */
3876 this_time = MIN (end_offset - next_offset,
3877 BITS_PER_UNIT - next_bit);
3878 if (BYTES_BIG_ENDIAN)
3880 /* On big-endian machine, take the most significant bits
3881 first (of the bits that are significant)
3882 and put them into bytes from the most significant end. */
3883 shift = end_offset - next_offset - this_time;
3884 /* Don't try to take a bunch of bits that cross
3885 the word boundary in the INTEGER_CST. */
3886 if (shift < HOST_BITS_PER_WIDE_INT
3887 && shift + this_time > HOST_BITS_PER_WIDE_INT)
3889 this_time -= (HOST_BITS_PER_WIDE_INT - shift);
3890 shift = HOST_BITS_PER_WIDE_INT;
3893 /* Now get the bits from the appropriate constant word. */
3894 if (shift < HOST_BITS_PER_WIDE_INT)
3896 value = TREE_INT_CST_LOW (val);
3898 else if (shift < 2 * HOST_BITS_PER_WIDE_INT)
3900 value = TREE_INT_CST_HIGH (val);
3901 shift -= HOST_BITS_PER_WIDE_INT;
3905 byte |= (((value >> shift)
3906 & (((HOST_WIDE_INT) 1 << this_time) - 1))
3907 << (BITS_PER_UNIT - this_time - next_bit));
3911 /* On little-endian machines,
3912 take first the least significant bits of the value
3913 and pack them starting at the least significant
3914 bits of the bytes. */
3915 shift = (next_offset
3916 - TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field)));
3917 /* Don't try to take a bunch of bits that cross
3918 the word boundary in the INTEGER_CST. */
3919 if (shift < HOST_BITS_PER_WIDE_INT
3920 && shift + this_time > HOST_BITS_PER_WIDE_INT)
3922 this_time -= (HOST_BITS_PER_WIDE_INT - shift);
3923 shift = HOST_BITS_PER_WIDE_INT;
3926 /* Now get the bits from the appropriate constant word. */
3927 if (shift < HOST_BITS_PER_INT)
3928 value = TREE_INT_CST_LOW (val);
3929 else if (shift < 2 * HOST_BITS_PER_WIDE_INT)
3931 value = TREE_INT_CST_HIGH (val);
3932 shift -= HOST_BITS_PER_WIDE_INT;
3936 byte |= (((value >> shift)
3937 & (((HOST_WIDE_INT) 1 << this_time) - 1))
3940 next_offset += this_time;
3941 byte_buffer_in_use = 1;
3945 if (byte_buffer_in_use)
3947 ASM_OUTPUT_BYTE (asm_out_file, byte);
3950 if (total_bytes < size)
3951 assemble_zeros (size - total_bytes);
3954 /* Output asm to handle ``#pragma weak'' */
3956 handle_pragma_weak (what, name, value)
3957 enum pragma_state what;
3960 #ifdef HANDLE_PRAGMA_WEAK
3961 if (what == ps_name || what == ps_value)
3963 struct weak_syms *weak =
3964 (struct weak_syms *)permalloc (sizeof (struct weak_syms));
3965 weak->next = weak_decls;
3966 weak->name = permalloc (strlen (name) + 1);
3967 strcpy (weak->name, name);
3969 if (what != ps_value)
3970 weak->value = NULL_PTR;
3974 weak->value = permalloc (strlen (value) + 1);
3975 strcpy (weak->value, value);
3980 else if (! (what == ps_done || what == ps_start))
3981 warning ("malformed `#pragma weak'");
3982 #endif /* HANDLE_PRAGMA_WEAK */
3985 /* Declare DECL to be a weak symbol. */
3991 if (! TREE_PUBLIC (decl))
3992 error_with_decl (decl, "weak declaration of `%s' must be public");
3993 else if (TREE_ASM_WRITTEN (decl))
3994 error_with_decl (decl, "weak declaration of `%s' must precede definition");
3995 else if (SUPPORTS_WEAK)
3996 DECL_WEAK (decl) = 1;
3999 /* Emit any pending weak declarations. */
4004 #ifdef HANDLE_PRAGMA_WEAK
4005 if (HANDLE_PRAGMA_WEAK)
4007 struct weak_syms *t;
4008 for (t = weak_decls; t; t = t->next)
4010 ASM_WEAKEN_LABEL (asm_out_file, t->name);
4012 ASM_OUTPUT_DEF (asm_out_file, t->name, t->value);
4019 assemble_alias (decl, target)
4022 #ifdef ASM_OUTPUT_DEF
4025 make_decl_rtl (decl, (char*)0, 1);
4026 name = XSTR (XEXP (DECL_RTL (decl), 0), 0);
4028 /* Make name accessible from other files, if appropriate. */
4030 if (TREE_PUBLIC (decl))
4032 #ifdef ASM_WEAKEN_LABEL
4033 if (DECL_WEAK (decl))
4034 ASM_WEAKEN_LABEL (asm_out_file, name);
4037 if (output_bytecode)
4038 BC_GLOBALIZE_LABEL (asm_out_file, name);
4040 ASM_GLOBALIZE_LABEL (asm_out_file, name);
4043 ASM_OUTPUT_DEF (asm_out_file, name, IDENTIFIER_POINTER (target));
4044 TREE_ASM_WRITTEN (decl) = 1;
4046 warning ("alias definitions not supported in this configuration");