1 /* Output variables, constants and external declarations, for GNU compiler.
2 Copyright (C) 1987, 88, 89, 92, 93, 1994 Free Software Foundation, Inc.
4 This file is part of GNU CC.
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING. If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
21 /* This file handles generation of all the assembler code
22 *except* the instructions of a function.
23 This includes declarations of variables and their initial values.
25 We also output the assembler code for constants stored in memory
26 and are responsible for combining constants with the same value. */
30 /* #include <stab.h> */
37 #include "hard-reg-set.h"
45 #ifdef XCOFF_DEBUGGING_INFO
52 #define ASM_STABS_OP ".stabs"
55 /* This macro gets just the user-specified name
56 out of the string in a SYMBOL_REF. On most machines,
57 we discard the * if any and that's all. */
58 #ifndef STRIP_NAME_ENCODING
59 #define STRIP_NAME_ENCODING(VAR,SYMBOL_NAME) \
60 (VAR) = ((SYMBOL_NAME) + ((SYMBOL_NAME)[0] == '*'))
63 /* File in which assembler code is being written. */
65 extern FILE *asm_out_file;
67 /* The (assembler) name of the first globally-visible object output. */
68 char *first_global_object_name;
70 extern struct obstack *current_obstack;
71 extern struct obstack *saveable_obstack;
72 extern struct obstack permanent_obstack;
73 #define obstack_chunk_alloc xmalloc
75 /* Number for making the label on the next
76 constant that is stored in memory. */
80 /* Number for making the label on the next
81 static variable internal to a function. */
85 /* Carry information from ASM_DECLARE_OBJECT_NAME
86 to ASM_FINISH_DECLARE_OBJECT. */
88 int size_directive_output;
90 /* The last decl for which assemble_variable was called,
91 if it did ASM_DECLARE_OBJECT_NAME.
92 If the last call to assemble_variable didn't do that,
95 tree last_assemble_variable_decl;
97 /* Nonzero if at least one function definition has been seen. */
98 static int function_defined;
100 extern FILE *asm_out_file;
102 static char *compare_constant_1 ();
103 static void record_constant_1 ();
104 static void output_constant_def_contents ();
105 static int contains_pointers_p ();
106 static void bc_output_ascii ();
108 void output_constant_pool ();
109 void assemble_name ();
110 int output_addressed_constants ();
111 void output_constant ();
112 void output_constructor ();
113 void output_byte_asm ();
114 void text_section ();
115 void readonly_data_section ();
116 void data_section ();
117 void named_section ();
118 static void bc_assemble_integer ();
120 #ifdef EXTRA_SECTIONS
121 static enum in_section {no_section, in_text, in_data, in_named, EXTRA_SECTIONS} in_section
124 static enum in_section {no_section, in_text, in_data, in_named} in_section
128 /* Return a non-zero value if DECL has a section attribute. */
129 #define IN_NAMED_SECTION(DECL) \
130 ((TREE_CODE (DECL) == FUNCTION_DECL || TREE_CODE (DECL) == VAR_DECL) \
131 && DECL_SECTION_NAME (DECL) != NULL_TREE)
133 /* Text of section name when in_section == in_named. */
134 static char *in_named_name;
136 /* Define functions like text_section for any extra sections. */
137 #ifdef EXTRA_SECTION_FUNCTIONS
138 EXTRA_SECTION_FUNCTIONS
141 /* Tell assembler to switch to text section. */
146 if (in_section != in_text)
151 fprintf (asm_out_file, "%s\n", TEXT_SECTION_ASM_OP);
153 in_section = in_text;
157 /* Tell assembler to switch to data section. */
162 if (in_section != in_data)
168 if (flag_shared_data)
170 #ifdef SHARED_SECTION_ASM_OP
171 fprintf (asm_out_file, "%s\n", SHARED_SECTION_ASM_OP);
173 fprintf (asm_out_file, "%s\n", DATA_SECTION_ASM_OP);
177 fprintf (asm_out_file, "%s\n", DATA_SECTION_ASM_OP);
180 in_section = in_data;
184 /* Tell assembler to switch to read-only data section. This is normally
188 readonly_data_section ()
190 #ifdef READONLY_DATA_SECTION
191 READONLY_DATA_SECTION (); /* Note this can call data_section. */
197 /* Determine if we're in the text section. */
202 return in_section == in_text;
205 /* Tell assembler to change to named section. */
211 if (in_section != in_named || strcmp (name, in_named_name))
213 in_named_name = name;
214 in_section = in_named;
216 #ifdef ASM_OUTPUT_SECTION_NAME
217 ASM_OUTPUT_SECTION_NAME (asm_out_file, name);
219 /* Section attributes are not supported if this macro isn't provided -
220 some host formats don't support them at all. The front-end should
221 already have flagged this as an error. */
227 /* Create the rtl to represent a function, for a function definition.
228 DECL is a FUNCTION_DECL node which describes which function.
229 The rtl is stored into DECL. */
232 make_function_rtl (decl)
235 char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
239 if (DECL_RTL (decl) == 0)
240 DECL_RTL (decl) = bc_gen_rtx (name, 0, (struct bc_label *) 0);
242 /* Record that at least one function has been defined. */
243 function_defined = 1;
247 /* Rename a nested function to avoid conflicts. */
248 if (decl_function_context (decl) != 0
249 && DECL_INITIAL (decl) != 0
250 && DECL_RTL (decl) == 0)
254 name = IDENTIFIER_POINTER (DECL_NAME (decl));
255 ASM_FORMAT_PRIVATE_NAME (label, name, var_labelno);
256 name = obstack_copy0 (saveable_obstack, label, strlen (label));
260 if (DECL_RTL (decl) == 0)
263 = gen_rtx (MEM, DECL_MODE (decl),
264 gen_rtx (SYMBOL_REF, Pmode, name));
266 /* Optionally set flags or add text to the name to record information
267 such as that it is a function name. If the name is changed, the macro
268 ASM_OUTPUT_LABELREF will have to know how to strip this information. */
269 #ifdef ENCODE_SECTION_INFO
270 ENCODE_SECTION_INFO (decl);
274 /* Record at least one function has been defined. */
275 function_defined = 1;
278 /* Create the DECL_RTL for a declaration for a static or external
279 variable or static or external function.
280 ASMSPEC, if not 0, is the string which the user specified
281 as the assembler symbol name.
282 TOP_LEVEL is nonzero if this is a file-scope variable.
283 This is never called for PARM_DECLs. */
285 bc_make_decl_rtl (decl, asmspec, top_level)
290 register char *name = TREE_STRING_POINTER (DECL_ASSEMBLER_NAME (decl));
292 if (DECL_RTL (decl) == 0)
294 /* Print an error message for register variables. */
295 if (DECL_REGISTER (decl) && TREE_CODE (decl) == FUNCTION_DECL)
296 error ("function declared `register'");
297 else if (DECL_REGISTER (decl))
298 error ("global register variables not supported in the interpreter");
300 /* Handle ordinary static variables and functions. */
301 if (DECL_RTL (decl) == 0)
303 /* Can't use just the variable's own name for a variable
304 whose scope is less than the whole file.
305 Concatenate a distinguishing number. */
306 if (!top_level && !DECL_EXTERNAL (decl) && asmspec == 0)
310 ASM_FORMAT_PRIVATE_NAME (label, name, var_labelno);
311 name = obstack_copy0 (saveable_obstack, label, strlen (label));
315 DECL_RTL (decl) = bc_gen_rtx (name, 0, (struct bc_label *) 0);
320 /* Given NAME, a putative register name, discard any customary prefixes. */
323 strip_reg_name (name)
326 #ifdef REGISTER_PREFIX
327 if (!strncmp (name, REGISTER_PREFIX, strlen (REGISTER_PREFIX)))
328 name += strlen (REGISTER_PREFIX);
330 if (name[0] == '%' || name[0] == '#')
335 /* Decode an `asm' spec for a declaration as a register name.
336 Return the register number, or -1 if nothing specified,
337 or -2 if the ASMSPEC is not `cc' or `memory' and is not recognized,
338 or -3 if ASMSPEC is `cc' and is not recognized,
339 or -4 if ASMSPEC is `memory' and is not recognized.
340 Accept an exact spelling or a decimal number.
341 Prefixes such as % are optional. */
344 decode_reg_name (asmspec)
351 /* Get rid of confusing prefixes. */
352 asmspec = strip_reg_name (asmspec);
354 /* Allow a decimal number as a "register name". */
355 for (i = strlen (asmspec) - 1; i >= 0; i--)
356 if (! (asmspec[i] >= '0' && asmspec[i] <= '9'))
358 if (asmspec[0] != 0 && i < 0)
361 if (i < FIRST_PSEUDO_REGISTER && i >= 0)
367 for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
369 && ! strcmp (asmspec, strip_reg_name (reg_names[i])))
372 #ifdef ADDITIONAL_REGISTER_NAMES
374 static struct { char *name; int number; } table[]
375 = ADDITIONAL_REGISTER_NAMES;
377 for (i = 0; i < sizeof (table) / sizeof (table[0]); i++)
378 if (! strcmp (asmspec, table[i].name))
379 return table[i].number;
381 #endif /* ADDITIONAL_REGISTER_NAMES */
383 if (!strcmp (asmspec, "memory"))
386 if (!strcmp (asmspec, "cc"))
395 /* Create the DECL_RTL for a declaration for a static or external variable
396 or static or external function.
397 ASMSPEC, if not 0, is the string which the user specified
398 as the assembler symbol name.
399 TOP_LEVEL is nonzero if this is a file-scope variable.
401 This is never called for PARM_DECL nodes. */
404 make_decl_rtl (decl, asmspec, top_level)
414 bc_make_decl_rtl (decl, asmspec, top_level);
418 reg_number = decode_reg_name (asmspec);
420 if (DECL_ASSEMBLER_NAME (decl) != NULL_TREE)
421 name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
423 if (reg_number == -2)
425 /* ASMSPEC is given, and not the name of a register. */
426 name = (char *) obstack_alloc (saveable_obstack,
427 strlen (asmspec) + 2);
429 strcpy (&name[1], asmspec);
432 /* For a duplicate declaration, we can be called twice on the
433 same DECL node. Don't discard the RTL already made. */
434 if (DECL_RTL (decl) == 0)
438 /* First detect errors in declaring global registers. */
439 if (DECL_REGISTER (decl) && reg_number == -1)
440 error_with_decl (decl,
441 "register name not specified for `%s'");
442 else if (DECL_REGISTER (decl) && reg_number < 0)
443 error_with_decl (decl,
444 "invalid register name for `%s'");
445 else if ((reg_number >= 0 || reg_number == -3) && ! DECL_REGISTER (decl))
446 error_with_decl (decl,
447 "register name given for non-register variable `%s'");
448 else if (DECL_REGISTER (decl) && TREE_CODE (decl) == FUNCTION_DECL)
449 error ("function declared `register'");
450 else if (DECL_REGISTER (decl) && TYPE_MODE (TREE_TYPE (decl)) == BLKmode)
451 error_with_decl (decl, "data type of `%s' isn't suitable for a register");
452 else if (DECL_REGISTER (decl)
453 && ! HARD_REGNO_MODE_OK (reg_number, TYPE_MODE (TREE_TYPE (decl))))
454 error_with_decl (decl, "register number for `%s' isn't suitable for the data type");
455 /* Now handle properly declared static register variables. */
456 else if (DECL_REGISTER (decl))
459 #if 0 /* yylex should print the warning for this */
461 pedwarn ("ANSI C forbids global register variables");
463 if (DECL_INITIAL (decl) != 0 && top_level)
465 DECL_INITIAL (decl) = 0;
466 error ("global register variable has initial value");
468 if (fixed_regs[reg_number] == 0
469 && function_defined && top_level)
470 error ("global register variable follows a function definition");
471 if (TREE_THIS_VOLATILE (decl))
472 warning ("volatile register variables don't work as you might wish");
474 /* If the user specified one of the eliminables registers here,
475 e.g., FRAME_POINTER_REGNUM, we don't want to get this variable
476 confused with that register and be eliminated. Although this
477 usage is somewhat suspect, we nevertheless use the following
478 kludge to avoid setting DECL_RTL to frame_pointer_rtx. */
481 = gen_rtx (REG, DECL_MODE (decl), FIRST_PSEUDO_REGISTER);
482 REGNO (DECL_RTL (decl)) = reg_number;
483 REG_USERVAR_P (DECL_RTL (decl)) = 1;
487 /* Make this register global, so not usable for anything
489 nregs = HARD_REGNO_NREGS (reg_number, DECL_MODE (decl));
491 globalize_reg (reg_number + --nregs);
494 /* Specifying a section attribute on an uninitialized variable does not
495 (and cannot) cause it to be put in the given section. The linker
496 can only put initialized objects in specific sections, everything
497 else goes in bss for the linker to sort out later (otherwise the
498 linker would give a duplicate definition error for each compilation
499 unit that behaved thusly). So warn the user. */
500 else if (TREE_CODE (decl) == VAR_DECL
501 && DECL_SECTION_NAME (decl) != NULL_TREE
502 && DECL_INITIAL (decl) == NULL_TREE)
504 warning_with_decl (decl,
505 "section attribute ignored for uninitialized variable `%s'");
508 /* Now handle ordinary static variables and functions (in memory).
509 Also handle vars declared register invalidly. */
510 if (DECL_RTL (decl) == 0)
512 /* Can't use just the variable's own name for a variable
513 whose scope is less than the whole file.
514 Concatenate a distinguishing number. */
515 if (!top_level && !DECL_EXTERNAL (decl) && asmspec == 0)
519 ASM_FORMAT_PRIVATE_NAME (label, name, var_labelno);
520 name = obstack_copy0 (saveable_obstack, label, strlen (label));
524 DECL_RTL (decl) = gen_rtx (MEM, DECL_MODE (decl),
525 gen_rtx (SYMBOL_REF, Pmode, name));
527 /* If this variable is to be treated as volatile, show its
528 tree node has side effects. If it has side effects, either
529 because of this test or from TREE_THIS_VOLATILE also
530 being set, show the MEM is volatile. */
531 if (flag_volatile_global && TREE_CODE (decl) == VAR_DECL
532 && TREE_PUBLIC (decl))
533 TREE_SIDE_EFFECTS (decl) = 1;
534 if (TREE_SIDE_EFFECTS (decl))
535 MEM_VOLATILE_P (DECL_RTL (decl)) = 1;
537 if (TREE_READONLY (decl))
538 RTX_UNCHANGING_P (DECL_RTL (decl)) = 1;
539 MEM_IN_STRUCT_P (DECL_RTL (decl))
540 = (TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE
541 || TREE_CODE (TREE_TYPE (decl)) == RECORD_TYPE
542 || TREE_CODE (TREE_TYPE (decl)) == UNION_TYPE
543 || TREE_CODE (TREE_TYPE (decl)) == QUAL_UNION_TYPE);
545 /* Optionally set flags or add text to the name to record information
546 such as that it is a function name.
547 If the name is changed, the macro ASM_OUTPUT_LABELREF
548 will have to know how to strip this information. */
549 #ifdef ENCODE_SECTION_INFO
550 ENCODE_SECTION_INFO (decl);
554 /* If the old RTL had the wrong mode, fix the mode. */
555 else if (GET_MODE (DECL_RTL (decl)) != DECL_MODE (decl))
557 rtx rtl = DECL_RTL (decl);
558 PUT_MODE (rtl, DECL_MODE (decl));
562 /* Make the rtl for variable VAR be volatile.
563 Use this only for static variables. */
566 make_var_volatile (var)
569 if (GET_CODE (DECL_RTL (var)) != MEM)
572 MEM_VOLATILE_P (DECL_RTL (var)) = 1;
575 /* Output alignment directive to align for constant expression EXP. */
578 assemble_constant_align (exp)
583 /* Align the location counter as required by EXP's data type. */
584 align = TYPE_ALIGN (TREE_TYPE (exp));
585 #ifdef CONSTANT_ALIGNMENT
586 align = CONSTANT_ALIGNMENT (exp, align);
589 if (align > BITS_PER_UNIT)
590 ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT));
593 /* Output a string of literal assembler code
594 for an `asm' keyword used between functions. */
597 assemble_asm (string)
602 error ("asm statements not allowed in interpreter");
608 if (TREE_CODE (string) == ADDR_EXPR)
609 string = TREE_OPERAND (string, 0);
611 fprintf (asm_out_file, "\t%s\n", TREE_STRING_POINTER (string));
614 #if 0 /* This should no longer be needed, because
615 flag_gnu_linker should be 0 on these systems,
616 which should prevent any output
617 if ASM_OUTPUT_CONSTRUCTOR and ASM_OUTPUT_DESTRUCTOR are absent. */
618 #if !(defined(DBX_DEBUGGING_INFO) && !defined(FASCIST_ASSEMBLER))
619 #ifndef ASM_OUTPUT_CONSTRUCTOR
620 #define ASM_OUTPUT_CONSTRUCTOR(file, name)
622 #ifndef ASM_OUTPUT_DESTRUCTOR
623 #define ASM_OUTPUT_DESTRUCTOR(file, name)
628 /* Record an element in the table of global destructors.
629 How this is done depends on what sort of assembler and linker
632 NAME should be the name of a global function to be called
633 at exit time. This name is output using assemble_name. */
636 assemble_destructor (name)
639 #ifdef ASM_OUTPUT_DESTRUCTOR
640 ASM_OUTPUT_DESTRUCTOR (asm_out_file, name);
644 /* Now tell GNU LD that this is part of the static destructor set. */
645 /* This code works for any machine provided you use GNU as/ld. */
646 fprintf (asm_out_file, "%s \"___DTOR_LIST__\",22,0,0,", ASM_STABS_OP);
647 assemble_name (asm_out_file, name);
648 fputc ('\n', asm_out_file);
653 /* Likewise for global constructors. */
656 assemble_constructor (name)
659 #ifdef ASM_OUTPUT_CONSTRUCTOR
660 ASM_OUTPUT_CONSTRUCTOR (asm_out_file, name);
664 /* Now tell GNU LD that this is part of the static constructor set. */
665 /* This code works for any machine provided you use GNU as/ld. */
666 fprintf (asm_out_file, "%s \"___CTOR_LIST__\",22,0,0,", ASM_STABS_OP);
667 assemble_name (asm_out_file, name);
668 fputc ('\n', asm_out_file);
673 /* Likewise for entries we want to record for garbage collection.
674 Garbage collection is still under development. */
677 assemble_gc_entry (name)
680 #ifdef ASM_OUTPUT_GC_ENTRY
681 ASM_OUTPUT_GC_ENTRY (asm_out_file, name);
685 /* Now tell GNU LD that this is part of the static constructor set. */
686 fprintf (asm_out_file, "%s \"___PTR_LIST__\",22,0,0,", ASM_STABS_OP);
687 assemble_name (asm_out_file, name);
688 fputc ('\n', asm_out_file);
693 /* Output assembler code for the constant pool of a function and associated
694 with defining the name of the function. DECL describes the function.
695 NAME is the function's name. For the constant pool, we use the current
696 constant pool data. */
699 assemble_start_function (decl, fnname)
705 /* The following code does not need preprocessing in the assembler. */
709 output_constant_pool (fnname, decl);
711 if (IN_NAMED_SECTION (decl))
712 named_section (TREE_STRING_POINTER (DECL_SECTION_NAME (decl)));
716 /* Tell assembler to move to target machine's alignment for functions. */
717 align = floor_log2 (FUNCTION_BOUNDARY / BITS_PER_UNIT);
721 BC_OUTPUT_ALIGN (asm_out_file, align);
723 ASM_OUTPUT_ALIGN (asm_out_file, align);
726 #ifdef ASM_OUTPUT_FUNCTION_PREFIX
727 ASM_OUTPUT_FUNCTION_PREFIX (asm_out_file, fnname);
730 #ifdef SDB_DEBUGGING_INFO
731 /* Output SDB definition of the function. */
732 if (write_symbols == SDB_DEBUG)
733 sdbout_mark_begin_function ();
736 #ifdef DBX_DEBUGGING_INFO
737 /* Output DBX definition of the function. */
738 if (write_symbols == DBX_DEBUG)
739 dbxout_begin_function (decl);
742 /* Make function name accessible from other files, if appropriate. */
744 if (TREE_PUBLIC (decl))
746 if (!first_global_object_name)
747 STRIP_NAME_ENCODING (first_global_object_name, fnname);
749 BC_GLOBALIZE_LABEL (asm_out_file, fnname);
751 ASM_GLOBALIZE_LABEL (asm_out_file, fnname);
754 /* Do any machine/system dependent processing of the function name */
755 #ifdef ASM_DECLARE_FUNCTION_NAME
756 ASM_DECLARE_FUNCTION_NAME (asm_out_file, fnname, current_function_decl);
758 /* Standard thing is just output label for the function. */
760 BC_OUTPUT_LABEL (asm_out_file, fnname);
762 ASM_OUTPUT_LABEL (asm_out_file, fnname);
763 #endif /* ASM_DECLARE_FUNCTION_NAME */
766 /* Output assembler code associated with defining the size of the
767 function. DECL describes the function. NAME is the function's name. */
770 assemble_end_function (decl, fnname)
774 #ifdef ASM_DECLARE_FUNCTION_SIZE
775 ASM_DECLARE_FUNCTION_SIZE (asm_out_file, fnname, decl);
779 /* Assemble code to leave SIZE bytes of zeros. */
782 assemble_zeros (size)
787 bc_emit_const_skip (size);
791 #ifdef ASM_NO_SKIP_IN_TEXT
792 /* The `space' pseudo in the text section outputs nop insns rather than 0s,
793 so we must output 0s explicitly in the text section. */
794 if (ASM_NO_SKIP_IN_TEXT && in_text_section ())
798 for (i = 0; i < size - 20; i += 20)
801 fprintf (asm_out_file,
802 "%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);
804 fprintf (asm_out_file,
805 "\tbyte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n");
811 fprintf (asm_out_file, "%s 0", ASM_BYTE_OP);
813 fprintf (asm_out_file, "\tbyte 0");
816 for (; i < size; i++)
817 fprintf (asm_out_file, ",0");
818 fprintf (asm_out_file, "\n");
826 BC_OUTPUT_SKIP (asm_out_file, size);
828 ASM_OUTPUT_SKIP (asm_out_file, size);
832 /* Assemble an alignment pseudo op for an ALIGN-bit boundary. */
835 assemble_align (align)
838 if (align > BITS_PER_UNIT)
839 ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT));
842 /* Assemble a string constant with the specified C string as contents. */
845 assemble_string (p, size)
859 /* If the string is very long, split it up. */
863 int thissize = size - pos;
864 if (thissize > maximum)
868 bc_output_ascii (asm_out_file, p, thissize);
871 ASM_OUTPUT_ASCII (asm_out_file, p, thissize);
880 bc_output_ascii (file, p, size)
885 BC_OUTPUT_ASCII (file, p, size);
888 /* Assemble everything that is needed for a variable or function declaration.
889 Not used for automatic variables, and not used for function definitions.
890 Should not be called for variables of incomplete structure type.
892 TOP_LEVEL is nonzero if this variable has file scope.
893 AT_END is nonzero if this is the special handling, at end of compilation,
894 to define things that have had only tentative definitions.
895 DONT_OUTPUT_DATA if nonzero means don't actually output the
896 initial value (that will be done by the caller). */
899 assemble_variable (decl, top_level, at_end, dont_output_data)
908 enum in_section saved_in_section;
910 last_assemble_variable_decl = 0;
915 if (GET_CODE (DECL_RTL (decl)) == REG)
917 /* Do output symbol info for global register variables, but do nothing
920 if (TREE_ASM_WRITTEN (decl))
922 TREE_ASM_WRITTEN (decl) = 1;
924 if (!output_bytecode)
926 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
927 /* File-scope global variables are output here. */
928 if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
930 dbxout_symbol (decl, 0);
932 #ifdef SDB_DEBUGGING_INFO
933 if (write_symbols == SDB_DEBUG && top_level
934 /* Leave initialized global vars for end of compilation;
935 see comment in compile_file. */
936 && (TREE_PUBLIC (decl) == 0 || DECL_INITIAL (decl) == 0))
937 sdbout_symbol (decl, 0);
941 /* Don't output any DWARF debugging information for variables here.
942 In the case of local variables, the information for them is output
943 when we do our recursive traversal of the tree representation for
944 the entire containing function. In the case of file-scope variables,
945 we output information for all of them at the very end of compilation
946 while we are doing our final traversal of the chain of file-scope
952 /* Normally no need to say anything here for external references,
953 since assemble_external is called by the langauge-specific code
954 when a declaration is first seen. */
956 if (DECL_EXTERNAL (decl))
959 /* Output no assembler code for a function declaration.
960 Only definitions of functions output anything. */
962 if (TREE_CODE (decl) == FUNCTION_DECL)
965 /* If type was incomplete when the variable was declared,
966 see if it is complete now. */
968 if (DECL_SIZE (decl) == 0)
969 layout_decl (decl, 0);
971 /* Still incomplete => don't allocate it; treat the tentative defn
972 (which is what it must have been) as an `extern' reference. */
974 if (!dont_output_data && DECL_SIZE (decl) == 0)
976 error_with_file_and_line (DECL_SOURCE_FILE (decl),
977 DECL_SOURCE_LINE (decl),
978 "storage size of `%s' isn't known",
979 IDENTIFIER_POINTER (DECL_NAME (decl)));
983 /* The first declaration of a variable that comes through this function
984 decides whether it is global (in C, has external linkage)
985 or local (in C, has internal linkage). So do nothing more
986 if this function has already run. */
988 if (TREE_ASM_WRITTEN (decl))
991 TREE_ASM_WRITTEN (decl) = 1;
993 /* If storage size is erroneously variable, just continue.
994 Error message was already made. */
996 if (DECL_SIZE (decl))
998 if (TREE_CODE (DECL_SIZE (decl)) != INTEGER_CST)
1003 /* This is better than explicit arithmetic, since it avoids overflow. */
1004 size_tree = size_binop (CEIL_DIV_EXPR,
1005 DECL_SIZE (decl), size_int (BITS_PER_UNIT));
1007 if (TREE_INT_CST_HIGH (size_tree) != 0)
1009 error_with_decl (decl, "size of variable `%s' is too large");
1014 name = XSTR (XEXP (DECL_RTL (decl), 0), 0);
1016 /* Handle uninitialized definitions. */
1018 /* ANSI specifies that a tentative definition which is not merged with
1019 a non-tentative definition behaves exactly like a definition with an
1020 initializer equal to zero. (Section 3.7.2)
1021 -fno-common gives strict ANSI behavior. Usually you don't want it.
1022 This matters only for variables with external linkage. */
1023 if ((! flag_no_common || ! TREE_PUBLIC (decl))
1024 && DECL_COMMON (decl)
1025 && ! dont_output_data
1026 && (DECL_INITIAL (decl) == 0 || DECL_INITIAL (decl) == error_mark_node))
1028 int size = TREE_INT_CST_LOW (size_tree);
1031 if (TREE_INT_CST_HIGH (size_tree) != 0)
1032 error_with_decl (decl, "size of variable `%s' is too large");
1033 /* Don't allocate zero bytes of common,
1034 since that means "undefined external" in the linker. */
1035 if (size == 0) rounded = 1;
1036 /* Round size up to multiple of BIGGEST_ALIGNMENT bits
1037 so that each uninitialized object starts on such a boundary. */
1038 rounded += (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - 1;
1039 rounded = (rounded / (BIGGEST_ALIGNMENT / BITS_PER_UNIT)
1040 * (BIGGEST_ALIGNMENT / BITS_PER_UNIT));
1042 #ifdef DBX_DEBUGGING_INFO
1043 /* File-scope global variables are output here. */
1044 if (write_symbols == DBX_DEBUG && top_level)
1045 dbxout_symbol (decl, 0);
1047 #ifdef SDB_DEBUGGING_INFO
1048 if (write_symbols == SDB_DEBUG && top_level
1049 /* Leave initialized global vars for end of compilation;
1050 see comment in compile_file. */
1051 && (TREE_PUBLIC (decl) == 0 || DECL_INITIAL (decl) == 0))
1052 sdbout_symbol (decl, 0);
1055 /* Don't output any DWARF debugging information for variables here.
1056 In the case of local variables, the information for them is output
1057 when we do our recursive traversal of the tree representation for
1058 the entire containing function. In the case of file-scope variables,
1059 we output information for all of them at the very end of compilation
1060 while we are doing our final traversal of the chain of file-scope
1064 if (flag_shared_data)
1067 if (TREE_PUBLIC (decl))
1069 #ifdef ASM_OUTPUT_SHARED_COMMON
1070 if (flag_shared_data)
1071 ASM_OUTPUT_SHARED_COMMON (asm_out_file, name, size, rounded);
1074 if (output_bytecode)
1076 BC_OUTPUT_COMMON (asm_out_file, name, size, rounded);
1080 #ifdef ASM_OUTPUT_ALIGNED_COMMON
1081 ASM_OUTPUT_ALIGNED_COMMON (asm_out_file, name, size,
1084 ASM_OUTPUT_COMMON (asm_out_file, name, size, rounded);
1090 #ifdef ASM_OUTPUT_SHARED_LOCAL
1091 if (flag_shared_data)
1092 ASM_OUTPUT_SHARED_LOCAL (asm_out_file, name, size, rounded);
1095 if (output_bytecode)
1097 BC_OUTPUT_LOCAL (asm_out_file, name, size, rounded);
1101 #ifdef ASM_OUTPUT_ALIGNED_LOCAL
1102 ASM_OUTPUT_ALIGNED_LOCAL (asm_out_file, name, size,
1105 ASM_OUTPUT_LOCAL (asm_out_file, name, size, rounded);
1112 /* Handle initialized definitions. */
1114 /* First make the assembler name(s) global if appropriate. */
1115 if (TREE_PUBLIC (decl) && DECL_NAME (decl))
1117 if (!first_global_object_name)
1118 STRIP_NAME_ENCODING(first_global_object_name, name);
1119 ASM_GLOBALIZE_LABEL (asm_out_file, name);
1122 for (d = equivalents; d; d = TREE_CHAIN (d))
1124 tree e = TREE_VALUE (d);
1125 if (TREE_PUBLIC (e) && DECL_NAME (e))
1126 ASM_GLOBALIZE_LABEL (asm_out_file,
1127 XSTR (XEXP (DECL_RTL (e), 0), 0));
1131 /* Output any data that we will need to use the address of. */
1132 if (DECL_INITIAL (decl) == error_mark_node)
1133 reloc = contains_pointers_p (TREE_TYPE (decl));
1134 else if (DECL_INITIAL (decl))
1135 reloc = output_addressed_constants (DECL_INITIAL (decl));
1137 /* Switch to the proper section for this data. */
1138 if (IN_NAMED_SECTION (decl))
1139 named_section (TREE_STRING_POINTER (DECL_SECTION_NAME (decl)));
1142 #ifdef SELECT_SECTION
1143 SELECT_SECTION (decl, reloc);
1145 if (TREE_READONLY (decl)
1146 && ! TREE_THIS_VOLATILE (decl)
1147 && ! (flag_pic && reloc))
1148 readonly_data_section ();
1154 /* dbxout.c needs to know this. */
1155 if (in_text_section ())
1156 DECL_IN_TEXT_SECTION (decl) = 1;
1158 /* Record current section so we can restore it if dbxout.c clobbers it. */
1159 saved_in_section = in_section;
1161 /* Output the dbx info now that we have chosen the section. */
1163 #ifdef DBX_DEBUGGING_INFO
1164 /* File-scope global variables are output here. */
1165 if (write_symbols == DBX_DEBUG && top_level)
1166 dbxout_symbol (decl, 0);
1168 #ifdef SDB_DEBUGGING_INFO
1169 if (write_symbols == SDB_DEBUG && top_level
1170 /* Leave initialized global vars for end of compilation;
1171 see comment in compile_file. */
1172 && (TREE_PUBLIC (decl) == 0 || DECL_INITIAL (decl) == 0))
1173 sdbout_symbol (decl, 0);
1176 /* Don't output any DWARF debugging information for variables here.
1177 In the case of local variables, the information for them is output
1178 when we do our recursive traversal of the tree representation for
1179 the entire containing function. In the case of file-scope variables,
1180 we output information for all of them at the very end of compilation
1181 while we are doing our final traversal of the chain of file-scope
1184 /* If the debugging output changed sections, reselect the section
1185 that's supposed to be selected. */
1186 if (in_section != saved_in_section)
1188 /* Switch to the proper section for this data. */
1189 #ifdef SELECT_SECTION
1190 SELECT_SECTION (decl, reloc);
1192 if (TREE_READONLY (decl)
1193 && ! TREE_THIS_VOLATILE (decl)
1194 && ! (flag_pic && reloc))
1195 readonly_data_section ();
1201 /* Compute and output the alignment of this data. */
1203 align = DECL_ALIGN (decl);
1204 /* In the case for initialing an array whose length isn't specified,
1205 where we have not yet been able to do the layout,
1206 figure out the proper alignment now. */
1207 if (dont_output_data && DECL_SIZE (decl) == 0
1208 && TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE)
1209 align = MAX (align, TYPE_ALIGN (TREE_TYPE (TREE_TYPE (decl))));
1211 /* Some object file formats have a maximum alignment which they support.
1212 In particular, a.out format supports a maximum alignment of 4. */
1213 #ifndef MAX_OFILE_ALIGNMENT
1214 #define MAX_OFILE_ALIGNMENT BIGGEST_ALIGNMENT
1216 if (align > MAX_OFILE_ALIGNMENT)
1218 warning_with_decl (decl,
1219 "alignment of `%s' is greater than maximum object file alignment");
1220 align = MAX_OFILE_ALIGNMENT;
1222 #ifdef DATA_ALIGNMENT
1223 /* On some machines, it is good to increase alignment sometimes. */
1224 align = DATA_ALIGNMENT (TREE_TYPE (decl), align);
1226 #ifdef CONSTANT_ALIGNMENT
1227 if (DECL_INITIAL (decl))
1228 align = CONSTANT_ALIGNMENT (DECL_INITIAL (decl), align);
1231 /* Reset the alignment in case we have made it tighter, so we can benefit
1232 from it in get_pointer_alignment. */
1233 DECL_ALIGN (decl) = align;
1235 if (align > BITS_PER_UNIT)
1237 if (output_bytecode)
1238 BC_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT));
1240 ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT));
1243 /* Do any machine/system dependent processing of the object. */
1244 #ifdef ASM_DECLARE_OBJECT_NAME
1245 last_assemble_variable_decl = decl;
1246 ASM_DECLARE_OBJECT_NAME (asm_out_file, name, decl);
1248 /* Standard thing is just output label for the object. */
1249 if (output_bytecode)
1250 BC_OUTPUT_LABEL (asm_out_file, name);
1252 ASM_OUTPUT_LABEL (asm_out_file, name);
1253 #endif /* ASM_DECLARE_OBJECT_NAME */
1255 if (!dont_output_data)
1257 if (DECL_INITIAL (decl))
1258 /* Output the actual data. */
1259 output_constant (DECL_INITIAL (decl),
1260 int_size_in_bytes (TREE_TYPE (decl)));
1262 /* Leave space for it. */
1263 assemble_zeros (int_size_in_bytes (TREE_TYPE (decl)));
1267 #ifdef XCOFF_DEBUGGING_INFO
1268 /* Unfortunately, the IBM assembler cannot handle stabx before the actual
1269 declaration. When something like ".stabx "aa:S-2",aa,133,0" is emitted
1270 and `aa' hasn't been output yet, the assembler generates a stab entry with
1271 a value of zero, in addition to creating an unnecessary external entry
1272 for `aa'. Hence, we must postpone dbxout_symbol to here at the end. */
1274 /* File-scope global variables are output here. */
1275 if (write_symbols == XCOFF_DEBUG && top_level)
1277 saved_in_section = in_section;
1279 dbxout_symbol (decl, 0);
1281 if (in_section != saved_in_section)
1283 /* Switch to the proper section for this data. */
1284 #ifdef SELECT_SECTION
1285 SELECT_SECTION (decl, reloc);
1287 if (TREE_READONLY (decl)
1288 && ! TREE_THIS_VOLATILE (decl)
1289 && ! (flag_pic && reloc))
1290 readonly_data_section ();
1297 /* There must be a statement after a label. */
1302 /* Return 1 if type TYPE contains any pointers. */
1305 contains_pointers_p (type)
1308 switch (TREE_CODE (type))
1311 case REFERENCE_TYPE:
1312 /* I'm not sure whether OFFSET_TYPE needs this treatment,
1313 so I'll play safe and return 1. */
1319 case QUAL_UNION_TYPE:
1322 /* For a type that has fields, see if the fields have pointers. */
1323 for (fields = TYPE_FIELDS (type); fields; fields = TREE_CHAIN (fields))
1324 if (contains_pointers_p (TREE_TYPE (fields)))
1330 /* An array type contains pointers if its element type does. */
1331 return contains_pointers_p (TREE_TYPE (type));
1338 /* Output text storage for constructor CONSTR. Returns rtx of
1342 bc_output_constructor (constr)
1347 /* Must always be a literal; non-literal constructors are handled
1350 if (!TREE_CONSTANT (constr))
1357 for (i = 0; TYPE_ALIGN (constr) >= BITS_PER_UNIT << (i + 1); i++);
1359 BC_OUTPUT_ALIGN (asm_out_file, i);
1362 output_constant (constr, int_size_in_bytes (TREE_TYPE (constr)));
1366 /* Create storage for constructor CONSTR. */
1369 bc_output_data_constructor (constr)
1374 /* Put in data section */
1378 for (i = 0; TYPE_ALIGN (constr) >= BITS_PER_UNIT << (i + 1); i++);
1380 BC_OUTPUT_ALIGN (asm_out_file, i);
1382 /* The constructor is filled in at runtime. */
1383 BC_OUTPUT_SKIP (asm_out_file, int_size_in_bytes (TREE_TYPE (constr)));
1387 /* Output something to declare an external symbol to the assembler.
1388 (Most assemblers don't need this, so we normally output nothing.)
1389 Do nothing if DECL is not external. */
1392 assemble_external (decl)
1395 if (output_bytecode)
1398 #ifdef ASM_OUTPUT_EXTERNAL
1399 if (TREE_CODE_CLASS (TREE_CODE (decl)) == 'd'
1400 && DECL_EXTERNAL (decl) && TREE_PUBLIC (decl))
1402 rtx rtl = DECL_RTL (decl);
1404 if (GET_CODE (rtl) == MEM && GET_CODE (XEXP (rtl, 0)) == SYMBOL_REF
1405 && ! SYMBOL_REF_USED (XEXP (rtl, 0)))
1407 /* Some systems do require some output. */
1408 SYMBOL_REF_USED (XEXP (rtl, 0)) = 1;
1409 ASM_OUTPUT_EXTERNAL (asm_out_file, decl, XSTR (XEXP (rtl, 0), 0));
1415 /* Similar, for calling a library function FUN. */
1418 assemble_external_libcall (fun)
1421 #ifdef ASM_OUTPUT_EXTERNAL_LIBCALL
1422 if (!output_bytecode)
1424 /* Declare library function name external when first used, if nec. */
1425 if (! SYMBOL_REF_USED (fun))
1427 SYMBOL_REF_USED (fun) = 1;
1428 ASM_OUTPUT_EXTERNAL_LIBCALL (asm_out_file, fun);
1434 /* Declare the label NAME global. */
1437 assemble_global (name)
1440 ASM_GLOBALIZE_LABEL (asm_out_file, name);
1443 /* Assemble a label named NAME. */
1446 assemble_label (name)
1449 if (output_bytecode)
1450 BC_OUTPUT_LABEL (asm_out_file, name);
1452 ASM_OUTPUT_LABEL (asm_out_file, name);
1455 /* Output to FILE a reference to the assembler name of a C-level name NAME.
1456 If NAME starts with a *, the rest of NAME is output verbatim.
1457 Otherwise NAME is transformed in an implementation-defined way
1458 (usually by the addition of an underscore).
1459 Many macros in the tm file are defined to call this function. */
1462 assemble_name (file, name)
1468 if (output_bytecode)
1469 bc_emit_labelref (name);
1471 fputs (&name[1], file);
1475 if (output_bytecode)
1476 BC_OUTPUT_LABELREF (file, name);
1478 ASM_OUTPUT_LABELREF (file, name);
1482 /* Allocate SIZE bytes writable static space with a gensym name
1483 and return an RTX to refer to its address. */
1486 assemble_static_space (size)
1492 /* Round size up to multiple of BIGGEST_ALIGNMENT bits
1493 so that each uninitialized object starts on such a boundary. */
1494 int rounded = ((size + (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - 1)
1495 / (BIGGEST_ALIGNMENT / BITS_PER_UNIT)
1496 * (BIGGEST_ALIGNMENT / BITS_PER_UNIT));
1499 if (flag_shared_data)
1503 ASM_GENERATE_INTERNAL_LABEL (name, "LF", const_labelno);
1506 namestring = (char *) obstack_alloc (saveable_obstack,
1508 strcpy (namestring, name);
1510 if (output_bytecode)
1511 x = bc_gen_rtx (namestring, 0, (struct bc_label *) 0);
1513 x = gen_rtx (SYMBOL_REF, Pmode, namestring);
1515 if (output_bytecode)
1517 BC_OUTPUT_LOCAL (asm_out_file, name, size, rounded);
1521 #ifdef ASM_OUTPUT_ALIGNED_LOCAL
1522 ASM_OUTPUT_ALIGNED_LOCAL (asm_out_file, name, size, BIGGEST_ALIGNMENT);
1524 ASM_OUTPUT_LOCAL (asm_out_file, name, size, rounded);
1530 /* Assemble the static constant template for function entry trampolines.
1531 This is done at most once per compilation.
1532 Returns an RTX for the address of the template. */
1535 assemble_trampoline_template ()
1541 /* Shouldn't get here */
1542 if (output_bytecode)
1545 /* By default, put trampoline templates in read-only data section. */
1547 #ifdef TRAMPOLINE_SECTION
1548 TRAMPOLINE_SECTION ();
1550 readonly_data_section ();
1553 /* Write the assembler code to define one. */
1554 align = floor_log2 (FUNCTION_BOUNDARY / BITS_PER_UNIT);
1556 ASM_OUTPUT_ALIGN (asm_out_file, align);
1558 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LTRAMP", 0);
1559 TRAMPOLINE_TEMPLATE (asm_out_file);
1561 /* Record the rtl to refer to it. */
1562 ASM_GENERATE_INTERNAL_LABEL (label, "LTRAMP", 0);
1564 = (char *) obstack_copy0 (&permanent_obstack, label, strlen (label));
1565 return gen_rtx (SYMBOL_REF, Pmode, name);
1568 /* Assemble the integer constant X into an object of SIZE bytes.
1569 X must be either a CONST_INT or CONST_DOUBLE.
1571 Return 1 if we were able to output the constant, otherwise 0. If FORCE is
1572 non-zero, abort if we can't output the constant. */
1575 assemble_integer (x, size, force)
1580 /* First try to use the standard 1, 2, 4, 8, and 16 byte
1581 ASM_OUTPUT... macros. */
1585 #ifdef ASM_OUTPUT_CHAR
1587 ASM_OUTPUT_CHAR (asm_out_file, x);
1591 #ifdef ASM_OUTPUT_SHORT
1593 ASM_OUTPUT_SHORT (asm_out_file, x);
1597 #ifdef ASM_OUTPUT_INT
1599 ASM_OUTPUT_INT (asm_out_file, x);
1603 #ifdef ASM_OUTPUT_DOUBLE_INT
1605 ASM_OUTPUT_DOUBLE_INT (asm_out_file, x);
1609 #ifdef ASM_OUTPUT_QUADRUPLE_INT
1611 ASM_OUTPUT_QUADRUPLE_INT (asm_out_file, x);
1616 /* If we couldn't do it that way, there are two other possibilities: First,
1617 if the machine can output an explicit byte and this is a 1 byte constant,
1618 we can use ASM_OUTPUT_BYTE. */
1620 #ifdef ASM_OUTPUT_BYTE
1621 if (size == 1 && GET_CODE (x) == CONST_INT)
1623 ASM_OUTPUT_BYTE (asm_out_file, INTVAL (x));
1628 /* Finally, if SIZE is larger than a single word, try to output the constant
1629 one word at a time. */
1631 if (size > UNITS_PER_WORD)
1634 enum machine_mode mode
1635 = mode_for_size (size * BITS_PER_UNIT, MODE_INT, 0);
1638 for (i = 0; i < size / UNITS_PER_WORD; i++)
1640 word = operand_subword (x, i, 0, mode);
1645 if (! assemble_integer (word, UNITS_PER_WORD, 0))
1649 if (i == size / UNITS_PER_WORD)
1651 /* If we output at least one word and then could not finish,
1652 there is no valid way to continue. */
1663 /* Assemble the floating-point constant D into an object of size MODE. */
1666 assemble_real (d, mode)
1668 enum machine_mode mode;
1670 jmp_buf output_constant_handler;
1672 if (setjmp (output_constant_handler))
1674 error ("floating point trap outputting a constant");
1675 #ifdef REAL_IS_NOT_DOUBLE
1676 bzero (&d, sizeof d);
1683 set_float_handler (output_constant_handler);
1687 #ifdef ASM_OUTPUT_BYTE_FLOAT
1689 ASM_OUTPUT_BYTE_FLOAT (asm_out_file, d);
1692 #ifdef ASM_OUTPUT_SHORT_FLOAT
1694 ASM_OUTPUT_SHORT_FLOAT (asm_out_file, d);
1697 #ifdef ASM_OUTPUT_FLOAT
1699 ASM_OUTPUT_FLOAT (asm_out_file, d);
1703 #ifdef ASM_OUTPUT_DOUBLE
1705 ASM_OUTPUT_DOUBLE (asm_out_file, d);
1709 #ifdef ASM_OUTPUT_LONG_DOUBLE
1712 ASM_OUTPUT_LONG_DOUBLE (asm_out_file, d);
1720 set_float_handler (NULL_PTR);
1723 /* Here we combine duplicate floating constants to make
1724 CONST_DOUBLE rtx's, and force those out to memory when necessary. */
1726 /* Chain of all CONST_DOUBLE rtx's constructed for the current function.
1727 They are chained through the CONST_DOUBLE_CHAIN.
1728 A CONST_DOUBLE rtx has CONST_DOUBLE_MEM != cc0_rtx iff it is on this chain.
1729 In that case, CONST_DOUBLE_MEM is either a MEM,
1730 or const0_rtx if no MEM has been made for this CONST_DOUBLE yet.
1732 (CONST_DOUBLE_MEM is used only for top-level functions.
1733 See force_const_mem for explanation.) */
1735 static rtx const_double_chain;
1737 /* Return a CONST_DOUBLE or CONST_INT for a value specified as a pair of ints.
1738 For an integer, I0 is the low-order word and I1 is the high-order word.
1739 For a real number, I0 is the word with the low address
1740 and I1 is the word with the high address. */
1743 immed_double_const (i0, i1, mode)
1744 HOST_WIDE_INT i0, i1;
1745 enum machine_mode mode;
1748 int in_current_obstack;
1750 if (GET_MODE_CLASS (mode) == MODE_INT
1751 || GET_MODE_CLASS (mode) == MODE_PARTIAL_INT)
1753 /* We clear out all bits that don't belong in MODE, unless they and our
1754 sign bit are all one. So we get either a reasonable negative value
1755 or a reasonable unsigned value for this mode. */
1756 int width = GET_MODE_BITSIZE (mode);
1757 if (width < HOST_BITS_PER_WIDE_INT
1758 && ((i0 & ((HOST_WIDE_INT) (-1) << (width - 1)))
1759 != ((HOST_WIDE_INT) (-1) << (width - 1))))
1760 i0 &= ((HOST_WIDE_INT) 1 << width) - 1, i1 = 0;
1761 else if (width == HOST_BITS_PER_WIDE_INT
1762 && ! (i1 == ~0 && i0 < 0))
1764 else if (width > 2 * HOST_BITS_PER_WIDE_INT)
1765 /* We cannot represent this value as a constant. */
1768 /* If MODE fits within HOST_BITS_PER_WIDE_INT, always use a CONST_INT.
1770 ??? Strictly speaking, this is wrong if we create a CONST_INT
1771 for a large unsigned constant with the size of MODE being
1772 HOST_BITS_PER_WIDE_INT and later try to interpret that constant in a
1773 wider mode. In that case we will mis-interpret it as a negative
1776 Unfortunately, the only alternative is to make a CONST_DOUBLE
1777 for any constant in any mode if it is an unsigned constant larger
1778 than the maximum signed integer in an int on the host. However,
1779 doing this will break everyone that always expects to see a CONST_INT
1780 for SImode and smaller.
1782 We have always been making CONST_INTs in this case, so nothing new
1785 if (width <= HOST_BITS_PER_WIDE_INT)
1786 i1 = (i0 < 0) ? ~0 : 0;
1788 /* If this integer fits in one word, return a CONST_INT. */
1789 if ((i1 == 0 && i0 >= 0)
1790 || (i1 == ~0 && i0 < 0))
1791 return GEN_INT (i0);
1793 /* We use VOIDmode for integers. */
1797 /* Search the chain for an existing CONST_DOUBLE with the right value.
1798 If one is found, return it. */
1800 for (r = const_double_chain; r; r = CONST_DOUBLE_CHAIN (r))
1801 if (CONST_DOUBLE_LOW (r) == i0 && CONST_DOUBLE_HIGH (r) == i1
1802 && GET_MODE (r) == mode)
1805 /* No; make a new one and add it to the chain.
1807 We may be called by an optimizer which may be discarding any memory
1808 allocated during its processing (such as combine and loop). However,
1809 we will be leaving this constant on the chain, so we cannot tolerate
1810 freed memory. So switch to saveable_obstack for this allocation
1811 and then switch back if we were in current_obstack. */
1813 push_obstacks_nochange ();
1814 rtl_in_saveable_obstack ();
1815 r = gen_rtx (CONST_DOUBLE, mode, 0, i0, i1);
1818 /* Don't touch const_double_chain in nested function; see force_const_mem.
1819 Also, don't touch it if not inside any function. */
1820 if (outer_function_chain == 0 && current_function_decl != 0)
1822 CONST_DOUBLE_CHAIN (r) = const_double_chain;
1823 const_double_chain = r;
1826 /* Store const0_rtx in mem-slot since this CONST_DOUBLE is on the chain.
1827 Actual use of mem-slot is only through force_const_mem. */
1829 CONST_DOUBLE_MEM (r) = const0_rtx;
1834 /* Return a CONST_DOUBLE for a specified `double' value
1835 and machine mode. */
1838 immed_real_const_1 (d, mode)
1840 enum machine_mode mode;
1842 union real_extract u;
1844 int in_current_obstack;
1846 /* Get the desired `double' value as a sequence of ints
1847 since that is how they are stored in a CONST_DOUBLE. */
1851 /* Detect special cases. */
1853 /* Avoid REAL_VALUES_EQUAL here in order to distinguish minus zero. */
1854 if (!bcmp (&dconst0, &d, sizeof d))
1855 return CONST0_RTX (mode);
1856 /* Check for NaN first, because some ports (specifically the i386) do not
1857 emit correct ieee-fp code by default, and thus will generate a core
1858 dump here if we pass a NaN to REAL_VALUES_EQUAL and if REAL_VALUES_EQUAL
1859 does a floating point comparison. */
1860 else if (! REAL_VALUE_ISNAN (d) && REAL_VALUES_EQUAL (dconst1, d))
1861 return CONST1_RTX (mode);
1863 if (sizeof u == 2 * sizeof (HOST_WIDE_INT))
1864 return immed_double_const (u.i[0], u.i[1], mode);
1866 /* The rest of this function handles the case where
1867 a float value requires more than 2 ints of space.
1868 It will be deleted as dead code on machines that don't need it. */
1870 /* Search the chain for an existing CONST_DOUBLE with the right value.
1871 If one is found, return it. */
1873 for (r = const_double_chain; r; r = CONST_DOUBLE_CHAIN (r))
1874 if (! bcmp (&CONST_DOUBLE_LOW (r), &u, sizeof u)
1875 && GET_MODE (r) == mode)
1878 /* No; make a new one and add it to the chain.
1880 We may be called by an optimizer which may be discarding any memory
1881 allocated during its processing (such as combine and loop). However,
1882 we will be leaving this constant on the chain, so we cannot tolerate
1883 freed memory. So switch to saveable_obstack for this allocation
1884 and then switch back if we were in current_obstack. */
1886 push_obstacks_nochange ();
1887 rtl_in_saveable_obstack ();
1888 r = rtx_alloc (CONST_DOUBLE);
1890 bcopy (&u, &CONST_DOUBLE_LOW (r), sizeof u);
1893 /* Don't touch const_double_chain in nested function; see force_const_mem.
1894 Also, don't touch it if not inside any function. */
1895 if (outer_function_chain == 0 && current_function_decl != 0)
1897 CONST_DOUBLE_CHAIN (r) = const_double_chain;
1898 const_double_chain = r;
1901 /* Store const0_rtx in CONST_DOUBLE_MEM since this CONST_DOUBLE is on the
1902 chain, but has not been allocated memory. Actual use of CONST_DOUBLE_MEM
1903 is only through force_const_mem. */
1905 CONST_DOUBLE_MEM (r) = const0_rtx;
1910 /* Return a CONST_DOUBLE rtx for a value specified by EXP,
1911 which must be a REAL_CST tree node. */
1914 immed_real_const (exp)
1917 return immed_real_const_1 (TREE_REAL_CST (exp), TYPE_MODE (TREE_TYPE (exp)));
1920 /* At the end of a function, forget the memory-constants
1921 previously made for CONST_DOUBLEs. Mark them as not on real_constant_chain.
1922 Also clear out real_constant_chain and clear out all the chain-pointers. */
1925 clear_const_double_mem ()
1927 register rtx r, next;
1929 /* Don't touch CONST_DOUBLE_MEM for nested functions.
1930 See force_const_mem for explanation. */
1931 if (outer_function_chain != 0)
1934 for (r = const_double_chain; r; r = next)
1936 next = CONST_DOUBLE_CHAIN (r);
1937 CONST_DOUBLE_CHAIN (r) = 0;
1938 CONST_DOUBLE_MEM (r) = cc0_rtx;
1940 const_double_chain = 0;
1943 /* Given an expression EXP with a constant value,
1944 reduce it to the sum of an assembler symbol and an integer.
1945 Store them both in the structure *VALUE.
1946 Abort if EXP does not reduce. */
1951 HOST_WIDE_INT offset;
1955 decode_addr_const (exp, value)
1957 struct addr_const *value;
1959 register tree target = TREE_OPERAND (exp, 0);
1960 register int offset = 0;
1965 if (TREE_CODE (target) == COMPONENT_REF
1966 && (TREE_CODE (DECL_FIELD_BITPOS (TREE_OPERAND (target, 1)))
1969 offset += TREE_INT_CST_LOW (DECL_FIELD_BITPOS (TREE_OPERAND (target, 1))) / BITS_PER_UNIT;
1970 target = TREE_OPERAND (target, 0);
1972 else if (TREE_CODE (target) == ARRAY_REF)
1974 if (TREE_CODE (TREE_OPERAND (target, 1)) != INTEGER_CST
1975 || TREE_CODE (TYPE_SIZE (TREE_TYPE (target))) != INTEGER_CST)
1977 offset += ((TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (target)))
1978 * TREE_INT_CST_LOW (TREE_OPERAND (target, 1)))
1980 target = TREE_OPERAND (target, 0);
1986 switch (TREE_CODE (target))
1990 x = DECL_RTL (target);
1994 if (output_bytecode)
1995 /* FIXME: this may not be correct, check it */
1996 x = bc_gen_rtx (TREE_STRING_POINTER (target), 0, (struct bc_label *) 0);
1998 x = gen_rtx (MEM, FUNCTION_MODE,
1999 gen_rtx (LABEL_REF, VOIDmode,
2000 label_rtx (TREE_OPERAND (exp, 0))));
2007 x = TREE_CST_RTL (target);
2014 if (!output_bytecode)
2016 if (GET_CODE (x) != MEM)
2022 value->offset = offset;
2025 /* Uniquize all constants that appear in memory.
2026 Each constant in memory thus far output is recorded
2027 in `const_hash_table' with a `struct constant_descriptor'
2028 that contains a polish representation of the value of
2031 We cannot store the trees in the hash table
2032 because the trees may be temporary. */
2034 struct constant_descriptor
2036 struct constant_descriptor *next;
2042 #define MAX_HASH_TABLE 1009
2043 static struct constant_descriptor *const_hash_table[MAX_HASH_TABLE];
2045 /* Compute a hash code for a constant expression. */
2052 register int len, hi, i;
2053 register enum tree_code code = TREE_CODE (exp);
2055 if (code == INTEGER_CST)
2057 p = (char *) &TREE_INT_CST_LOW (exp);
2058 len = 2 * sizeof TREE_INT_CST_LOW (exp);
2060 else if (code == REAL_CST)
2062 p = (char *) &TREE_REAL_CST (exp);
2063 len = sizeof TREE_REAL_CST (exp);
2065 else if (code == STRING_CST)
2066 p = TREE_STRING_POINTER (exp), len = TREE_STRING_LENGTH (exp);
2067 else if (code == COMPLEX_CST)
2068 return const_hash (TREE_REALPART (exp)) * 5
2069 + const_hash (TREE_IMAGPART (exp));
2070 else if (code == CONSTRUCTOR)
2074 /* For record type, include the type in the hashing.
2075 We do not do so for array types
2076 because (1) the sizes of the elements are sufficient
2077 and (2) distinct array types can have the same constructor.
2078 Instead, we include the array size because the constructor could
2080 if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE)
2081 hi = ((HOST_WIDE_INT) TREE_TYPE (exp) & ((1 << HASHBITS) - 1))
2084 hi = ((5 + int_size_in_bytes (TREE_TYPE (exp)))
2085 & ((1 << HASHBITS) - 1)) % MAX_HASH_TABLE;
2087 for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link))
2088 if (TREE_VALUE (link))
2089 hi = (hi * 603 + const_hash (TREE_VALUE (link))) % MAX_HASH_TABLE;
2093 else if (code == ADDR_EXPR)
2095 struct addr_const value;
2096 decode_addr_const (exp, &value);
2097 if (GET_CODE (value.base) == SYMBOL_REF)
2099 /* Don't hash the address of the SYMBOL_REF;
2100 only use the offset and the symbol name. */
2102 p = XSTR (value.base, 0);
2103 for (i = 0; p[i] != 0; i++)
2104 hi = ((hi * 613) + (unsigned)(p[i]));
2106 else if (GET_CODE (value.base) == LABEL_REF)
2107 hi = value.offset + CODE_LABEL_NUMBER (XEXP (value.base, 0)) * 13;
2109 hi &= (1 << HASHBITS) - 1;
2110 hi %= MAX_HASH_TABLE;
2113 else if (code == PLUS_EXPR || code == MINUS_EXPR)
2114 return const_hash (TREE_OPERAND (exp, 0)) * 9
2115 + const_hash (TREE_OPERAND (exp, 1));
2116 else if (code == NOP_EXPR || code == CONVERT_EXPR)
2117 return const_hash (TREE_OPERAND (exp, 0)) * 7 + 2;
2119 /* Compute hashing function */
2121 for (i = 0; i < len; i++)
2122 hi = ((hi * 613) + (unsigned)(p[i]));
2124 hi &= (1 << HASHBITS) - 1;
2125 hi %= MAX_HASH_TABLE;
2129 /* Compare a constant expression EXP with a constant-descriptor DESC.
2130 Return 1 if DESC describes a constant with the same value as EXP. */
2133 compare_constant (exp, desc)
2135 struct constant_descriptor *desc;
2137 return 0 != compare_constant_1 (exp, desc->contents);
2140 /* Compare constant expression EXP with a substring P of a constant descriptor.
2141 If they match, return a pointer to the end of the substring matched.
2142 If they do not match, return 0.
2144 Since descriptors are written in polish prefix notation,
2145 this function can be used recursively to test one operand of EXP
2146 against a subdescriptor, and if it succeeds it returns the
2147 address of the subdescriptor for the next operand. */
2150 compare_constant_1 (exp, p)
2154 register char *strp;
2156 register enum tree_code code = TREE_CODE (exp);
2158 if (code != (enum tree_code) *p++)
2161 if (code == INTEGER_CST)
2163 /* Integer constants are the same only if the same width of type. */
2164 if (*p++ != TYPE_PRECISION (TREE_TYPE (exp)))
2166 strp = (char *) &TREE_INT_CST_LOW (exp);
2167 len = 2 * sizeof TREE_INT_CST_LOW (exp);
2169 else if (code == REAL_CST)
2171 /* Real constants are the same only if the same width of type. */
2172 if (*p++ != TYPE_PRECISION (TREE_TYPE (exp)))
2174 strp = (char *) &TREE_REAL_CST (exp);
2175 len = sizeof TREE_REAL_CST (exp);
2177 else if (code == STRING_CST)
2179 if (flag_writable_strings)
2181 strp = TREE_STRING_POINTER (exp);
2182 len = TREE_STRING_LENGTH (exp);
2183 if (bcmp (&TREE_STRING_LENGTH (exp), p,
2184 sizeof TREE_STRING_LENGTH (exp)))
2186 p += sizeof TREE_STRING_LENGTH (exp);
2188 else if (code == COMPLEX_CST)
2190 p = compare_constant_1 (TREE_REALPART (exp), p);
2191 if (p == 0) return 0;
2192 p = compare_constant_1 (TREE_IMAGPART (exp), p);
2195 else if (code == CONSTRUCTOR)
2198 int length = list_length (CONSTRUCTOR_ELTS (exp));
2201 if (bcmp (&length, p, sizeof length))
2205 /* For record constructors, insist that the types match.
2206 For arrays, just verify both constructors are for arrays. */
2207 if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE)
2208 type = TREE_TYPE (exp);
2211 if (bcmp (&type, p, sizeof type))
2215 /* For arrays, insist that the size in bytes match. */
2216 if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE)
2218 int size = int_size_in_bytes (TREE_TYPE (exp));
2219 if (bcmp (&size, p, sizeof size))
2224 for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link))
2226 if (TREE_VALUE (link))
2228 if ((p = compare_constant_1 (TREE_VALUE (link), p)) == 0)
2235 if (bcmp (&zero, p, sizeof zero))
2243 else if (code == ADDR_EXPR)
2245 struct addr_const value;
2246 decode_addr_const (exp, &value);
2247 strp = (char *) &value.offset;
2248 len = sizeof value.offset;
2249 /* Compare the offset. */
2251 if (*p++ != *strp++)
2253 /* Compare symbol name. */
2254 strp = XSTR (value.base, 0);
2255 len = strlen (strp) + 1;
2257 else if (code == PLUS_EXPR || code == MINUS_EXPR)
2259 p = compare_constant_1 (TREE_OPERAND (exp, 0), p);
2260 if (p == 0) return 0;
2261 p = compare_constant_1 (TREE_OPERAND (exp, 1), p);
2264 else if (code == NOP_EXPR || code == CONVERT_EXPR)
2266 p = compare_constant_1 (TREE_OPERAND (exp, 0), p);
2270 /* Compare constant contents. */
2272 if (*p++ != *strp++)
2278 /* Construct a constant descriptor for the expression EXP.
2279 It is up to the caller to enter the descriptor in the hash table. */
2281 static struct constant_descriptor *
2282 record_constant (exp)
2285 struct constant_descriptor *next = 0;
2288 /* Make a struct constant_descriptor. The first two pointers will
2289 be filled in later. Here we just leave space for them. */
2291 obstack_grow (&permanent_obstack, (char *) &next, sizeof next);
2292 obstack_grow (&permanent_obstack, (char *) &label, sizeof label);
2293 record_constant_1 (exp);
2294 return (struct constant_descriptor *) obstack_finish (&permanent_obstack);
2297 /* Add a description of constant expression EXP
2298 to the object growing in `permanent_obstack'.
2299 No need to return its address; the caller will get that
2300 from the obstack when the object is complete. */
2303 record_constant_1 (exp)
2306 register char *strp;
2308 register enum tree_code code = TREE_CODE (exp);
2310 obstack_1grow (&permanent_obstack, (unsigned int) code);
2312 if (code == INTEGER_CST)
2314 obstack_1grow (&permanent_obstack, TYPE_PRECISION (TREE_TYPE (exp)));
2315 strp = (char *) &TREE_INT_CST_LOW (exp);
2316 len = 2 * sizeof TREE_INT_CST_LOW (exp);
2318 else if (code == REAL_CST)
2320 obstack_1grow (&permanent_obstack, TYPE_PRECISION (TREE_TYPE (exp)));
2321 strp = (char *) &TREE_REAL_CST (exp);
2322 len = sizeof TREE_REAL_CST (exp);
2324 else if (code == STRING_CST)
2326 if (flag_writable_strings)
2328 strp = TREE_STRING_POINTER (exp);
2329 len = TREE_STRING_LENGTH (exp);
2330 obstack_grow (&permanent_obstack, (char *) &TREE_STRING_LENGTH (exp),
2331 sizeof TREE_STRING_LENGTH (exp));
2333 else if (code == COMPLEX_CST)
2335 record_constant_1 (TREE_REALPART (exp));
2336 record_constant_1 (TREE_IMAGPART (exp));
2339 else if (code == CONSTRUCTOR)
2342 int length = list_length (CONSTRUCTOR_ELTS (exp));
2345 obstack_grow (&permanent_obstack, (char *) &length, sizeof length);
2347 /* For record constructors, insist that the types match.
2348 For arrays, just verify both constructors are for arrays. */
2349 if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE)
2350 type = TREE_TYPE (exp);
2353 obstack_grow (&permanent_obstack, (char *) &type, sizeof type);
2355 /* For arrays, insist that the size in bytes match. */
2356 if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE)
2358 int size = int_size_in_bytes (TREE_TYPE (exp));
2359 obstack_grow (&permanent_obstack, (char *) &size, sizeof size);
2362 for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link))
2364 if (TREE_VALUE (link))
2365 record_constant_1 (TREE_VALUE (link));
2370 obstack_grow (&permanent_obstack, (char *) &zero, sizeof zero);
2376 else if (code == ADDR_EXPR)
2378 struct addr_const value;
2379 decode_addr_const (exp, &value);
2380 /* Record the offset. */
2381 obstack_grow (&permanent_obstack,
2382 (char *) &value.offset, sizeof value.offset);
2383 /* Record the symbol name. */
2384 obstack_grow (&permanent_obstack, XSTR (value.base, 0),
2385 strlen (XSTR (value.base, 0)) + 1);
2388 else if (code == PLUS_EXPR || code == MINUS_EXPR)
2390 record_constant_1 (TREE_OPERAND (exp, 0));
2391 record_constant_1 (TREE_OPERAND (exp, 1));
2394 else if (code == NOP_EXPR || code == CONVERT_EXPR)
2396 record_constant_1 (TREE_OPERAND (exp, 0));
2400 /* Record constant contents. */
2401 obstack_grow (&permanent_obstack, strp, len);
2404 /* Record a list of constant expressions that were passed to
2405 output_constant_def but that could not be output right away. */
2407 struct deferred_constant
2409 struct deferred_constant *next;
2415 static struct deferred_constant *deferred_constants;
2417 /* Nonzero means defer output of addressed subconstants
2418 (i.e., those for which output_constant_def is called.) */
2419 static int defer_addressed_constants_flag;
2421 /* Start deferring output of subconstants. */
2424 defer_addressed_constants ()
2426 defer_addressed_constants_flag++;
2429 /* Stop deferring output of subconstants,
2430 and output now all those that have been deferred. */
2433 output_deferred_addressed_constants ()
2435 struct deferred_constant *p, *next;
2437 defer_addressed_constants_flag--;
2439 if (defer_addressed_constants_flag > 0)
2442 for (p = deferred_constants; p; p = next)
2444 output_constant_def_contents (p->exp, p->reloc, p->labelno);
2449 deferred_constants = 0;
2452 /* Make a copy of the whole tree structure for a constant.
2453 This handles the same types of nodes that compare_constant
2454 and record_constant handle. */
2460 switch (TREE_CODE (exp))
2466 /* For ADDR_EXPR, we do not want to copy the decl
2467 whose address is requested. */
2468 return copy_node (exp);
2471 return build_complex (copy_constant (TREE_REALPART (exp)),
2472 copy_constant (TREE_IMAGPART (exp)));
2476 return build (TREE_CODE (exp), TREE_TYPE (exp),
2477 copy_constant (TREE_OPERAND (exp, 0)),
2478 copy_constant (TREE_OPERAND (exp, 1)));
2482 return build1 (TREE_CODE (exp), TREE_TYPE (exp),
2483 copy_constant (TREE_OPERAND (exp, 0)));
2487 tree copy = copy_node (exp);
2488 tree list = copy_list (CONSTRUCTOR_ELTS (exp));
2491 CONSTRUCTOR_ELTS (exp) = list;
2492 for (tail = list; tail; tail = TREE_CHAIN (tail))
2493 TREE_VALUE (tail) = copy_constant (TREE_VALUE (tail));
2503 /* Return an rtx representing a reference to constant data in memory
2504 for the constant expression EXP.
2506 If assembler code for such a constant has already been output,
2507 return an rtx to refer to it.
2508 Otherwise, output such a constant in memory (or defer it for later)
2509 and generate an rtx for it.
2511 The TREE_CST_RTL of EXP is set up to point to that rtx.
2512 The const_hash_table records which constants already have label strings. */
2515 output_constant_def (exp)
2519 register struct constant_descriptor *desc;
2525 if (TREE_CODE (exp) == INTEGER_CST)
2526 abort (); /* No TREE_CST_RTL slot in these. */
2528 if (TREE_CST_RTL (exp))
2529 return TREE_CST_RTL (exp);
2531 /* Make sure any other constants whose addresses appear in EXP
2532 are assigned label numbers. */
2534 reloc = output_addressed_constants (exp);
2536 /* Compute hash code of EXP. Search the descriptors for that hash code
2537 to see if any of them describes EXP. If yes, the descriptor records
2538 the label number already assigned. */
2540 if (!output_bytecode)
2542 hash = const_hash (exp) % MAX_HASH_TABLE;
2544 for (desc = const_hash_table[hash]; desc; desc = desc->next)
2545 if (compare_constant (exp, desc))
2547 found = desc->label;
2553 /* No constant equal to EXP is known to have been output.
2554 Make a constant descriptor to enter EXP in the hash table.
2555 Assign the label number and record it in the descriptor for
2556 future calls to this function to find. */
2558 /* Create a string containing the label name, in LABEL. */
2559 ASM_GENERATE_INTERNAL_LABEL (label, "LC", const_labelno);
2561 desc = record_constant (exp);
2562 desc->next = const_hash_table[hash];
2564 = (char *) obstack_copy0 (&permanent_obstack, label, strlen (label));
2565 const_hash_table[hash] = desc;
2569 /* Create a string containing the label name, in LABEL. */
2570 ASM_GENERATE_INTERNAL_LABEL (label, "LC", const_labelno);
2574 /* We have a symbol name; construct the SYMBOL_REF and the MEM. */
2576 push_obstacks_nochange ();
2577 if (TREE_PERMANENT (exp))
2578 end_temporary_allocation ();
2580 if (!output_bytecode)
2582 def = gen_rtx (SYMBOL_REF, Pmode, desc->label);
2585 = gen_rtx (MEM, TYPE_MODE (TREE_TYPE (exp)), def);
2586 RTX_UNCHANGING_P (TREE_CST_RTL (exp)) = 1;
2587 if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE
2588 || TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE)
2589 MEM_IN_STRUCT_P (TREE_CST_RTL (exp)) = 1;
2593 /* Optionally set flags or add text to the name to record information
2594 such as that it is a function name. If the name is changed, the macro
2595 ASM_OUTPUT_LABELREF will have to know how to strip this information. */
2596 #ifdef ENCODE_SECTION_INFO
2597 ENCODE_SECTION_INFO (exp);
2600 /* If this is the first time we've seen this particular constant,
2601 output it (or defer its output for later). */
2604 if (defer_addressed_constants_flag)
2606 struct deferred_constant *p;
2607 p = (struct deferred_constant *) xmalloc (sizeof (struct deferred_constant));
2609 push_obstacks_nochange ();
2610 suspend_momentary ();
2611 p->exp = copy_constant (exp);
2614 p->labelno = const_labelno++;
2615 p->next = deferred_constants;
2616 deferred_constants = p;
2619 output_constant_def_contents (exp, reloc, const_labelno++);
2622 return TREE_CST_RTL (exp);
2625 /* Now output assembler code to define the label for EXP,
2626 and follow it with the data of EXP. */
2629 output_constant_def_contents (exp, reloc, labelno)
2636 if (IN_NAMED_SECTION (exp))
2637 named_section (TREE_STRING_POINTER (DECL_SECTION_NAME (exp)));
2640 /* First switch to text section, except for writable strings. */
2641 #ifdef SELECT_SECTION
2642 SELECT_SECTION (exp, reloc);
2644 if (((TREE_CODE (exp) == STRING_CST) && flag_writable_strings)
2645 || (flag_pic && reloc))
2648 readonly_data_section ();
2652 /* Align the location counter as required by EXP's data type. */
2653 align = TYPE_ALIGN (TREE_TYPE (exp));
2654 #ifdef CONSTANT_ALIGNMENT
2655 align = CONSTANT_ALIGNMENT (exp, align);
2658 if (align > BITS_PER_UNIT)
2660 if (!output_bytecode)
2662 ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT));
2666 BC_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT));
2670 /* Output the label itself. */
2671 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LC", labelno);
2673 /* Output the value of EXP. */
2674 output_constant (exp,
2675 (TREE_CODE (exp) == STRING_CST
2676 ? TREE_STRING_LENGTH (exp)
2677 : int_size_in_bytes (TREE_TYPE (exp))));
2681 /* Similar hash facility for making memory-constants
2682 from constant rtl-expressions. It is used on RISC machines
2683 where immediate integer arguments and constant addresses are restricted
2684 so that such constants must be stored in memory.
2686 This pool of constants is reinitialized for each function
2687 so each function gets its own constants-pool that comes right before it.
2689 All structures allocated here are discarded when functions are saved for
2690 inlining, so they do not need to be allocated permanently. */
2692 #define MAX_RTX_HASH_TABLE 61
2693 static struct constant_descriptor **const_rtx_hash_table;
2695 /* Structure to represent sufficient information about a constant so that
2696 it can be output when the constant pool is output, so that function
2697 integration can be done, and to simplify handling on machines that reference
2698 constant pool as base+displacement. */
2700 struct pool_constant
2702 struct constant_descriptor *desc;
2703 struct pool_constant *next;
2704 enum machine_mode mode;
2711 /* Pointers to first and last constant in pool. */
2713 static struct pool_constant *first_pool, *last_pool;
2715 /* Current offset in constant pool (does not include any machine-specific
2718 static int pool_offset;
2720 /* Structure used to maintain hash table mapping symbols used to their
2721 corresponding constants. */
2726 struct pool_constant *pool;
2727 struct pool_sym *next;
2730 static struct pool_sym **const_rtx_sym_hash_table;
2732 /* Hash code for a SYMBOL_REF with CONSTANT_POOL_ADDRESS_P true.
2733 The argument is XSTR (... , 0) */
2735 #define SYMHASH(LABEL) \
2736 ((((HOST_WIDE_INT) (LABEL)) & ((1 << HASHBITS) - 1)) % MAX_RTX_HASH_TABLE)
2738 /* Initialize constant pool hashing for next function. */
2741 init_const_rtx_hash_table ()
2743 const_rtx_hash_table
2744 = ((struct constant_descriptor **)
2745 oballoc (MAX_RTX_HASH_TABLE * sizeof (struct constant_descriptor *)));
2746 const_rtx_sym_hash_table
2747 = ((struct pool_sym **)
2748 oballoc (MAX_RTX_HASH_TABLE * sizeof (struct pool_sym *)));
2749 bzero (const_rtx_hash_table,
2750 MAX_RTX_HASH_TABLE * sizeof (struct constant_descriptor *));
2751 bzero (const_rtx_sym_hash_table,
2752 MAX_RTX_HASH_TABLE * sizeof (struct pool_sym *));
2754 first_pool = last_pool = 0;
2758 /* Save and restore it for a nested function. */
2761 save_varasm_status (p)
2764 p->const_rtx_hash_table = const_rtx_hash_table;
2765 p->const_rtx_sym_hash_table = const_rtx_sym_hash_table;
2766 p->first_pool = first_pool;
2767 p->last_pool = last_pool;
2768 p->pool_offset = pool_offset;
2772 restore_varasm_status (p)
2775 const_rtx_hash_table = p->const_rtx_hash_table;
2776 const_rtx_sym_hash_table = p->const_rtx_sym_hash_table;
2777 first_pool = p->first_pool;
2778 last_pool = p->last_pool;
2779 pool_offset = p->pool_offset;
2782 enum kind { RTX_DOUBLE, RTX_INT };
2786 #ifdef ONLY_INT_FIELDS
2787 unsigned int kind : 16;
2788 unsigned int mode : 16;
2790 enum kind kind : 16;
2791 enum machine_mode mode : 16;
2794 union real_extract du;
2795 struct addr_const addr;
2799 /* Express an rtx for a constant integer (perhaps symbolic)
2800 as the sum of a symbol or label plus an explicit integer.
2801 They are stored into VALUE. */
2804 decode_rtx_const (mode, x, value)
2805 enum machine_mode mode;
2807 struct rtx_const *value;
2809 /* Clear the whole structure, including any gaps. */
2812 int *p = (int *) value;
2813 int *end = (int *) (value + 1);
2818 value->kind = RTX_INT; /* Most usual kind. */
2821 switch (GET_CODE (x))
2824 value->kind = RTX_DOUBLE;
2825 if (GET_MODE (x) != VOIDmode)
2826 value->mode = GET_MODE (x);
2827 bcopy (&CONST_DOUBLE_LOW (x), &value->un.du, sizeof value->un.du);
2831 value->un.addr.offset = INTVAL (x);
2837 value->un.addr.base = x;
2842 if (GET_CODE (x) == PLUS)
2844 value->un.addr.base = XEXP (x, 0);
2845 if (GET_CODE (XEXP (x, 1)) != CONST_INT)
2847 value->un.addr.offset = INTVAL (XEXP (x, 1));
2849 else if (GET_CODE (x) == MINUS)
2851 value->un.addr.base = XEXP (x, 0);
2852 if (GET_CODE (XEXP (x, 1)) != CONST_INT)
2854 value->un.addr.offset = - INTVAL (XEXP (x, 1));
2864 if (value->kind == RTX_INT && value->un.addr.base != 0)
2865 switch (GET_CODE (value->un.addr.base))
2869 /* Use the string's address, not the SYMBOL_REF's address,
2870 for the sake of addresses of library routines.
2871 For a LABEL_REF, compare labels. */
2872 value->un.addr.base = XEXP (value->un.addr.base, 0);
2876 /* Given a MINUS expression, simplify it if both sides
2877 include the same symbol. */
2880 simplify_subtraction (x)
2883 struct rtx_const val0, val1;
2885 decode_rtx_const (GET_MODE (x), XEXP (x, 0), &val0);
2886 decode_rtx_const (GET_MODE (x), XEXP (x, 1), &val1);
2888 if (val0.un.addr.base == val1.un.addr.base)
2889 return GEN_INT (val0.un.addr.offset - val1.un.addr.offset);
2893 /* Compute a hash code for a constant RTL expression. */
2896 const_hash_rtx (mode, x)
2897 enum machine_mode mode;
2902 struct rtx_const value;
2903 decode_rtx_const (mode, x, &value);
2905 /* Compute hashing function */
2907 for (i = 0; i < sizeof value / sizeof (int); i++)
2908 hi += ((int *) &value)[i];
2910 hi &= (1 << HASHBITS) - 1;
2911 hi %= MAX_RTX_HASH_TABLE;
2915 /* Compare a constant rtl object X with a constant-descriptor DESC.
2916 Return 1 if DESC describes a constant with the same value as X. */
2919 compare_constant_rtx (mode, x, desc)
2920 enum machine_mode mode;
2922 struct constant_descriptor *desc;
2924 register int *p = (int *) desc->contents;
2927 struct rtx_const value;
2929 decode_rtx_const (mode, x, &value);
2930 strp = (int *) &value;
2931 len = sizeof value / sizeof (int);
2933 /* Compare constant contents. */
2935 if (*p++ != *strp++)
2941 /* Construct a constant descriptor for the rtl-expression X.
2942 It is up to the caller to enter the descriptor in the hash table. */
2944 static struct constant_descriptor *
2945 record_constant_rtx (mode, x)
2946 enum machine_mode mode;
2949 struct constant_descriptor *ptr;
2951 struct rtx_const value;
2953 decode_rtx_const (mode, x, &value);
2955 obstack_grow (current_obstack, &ptr, sizeof ptr);
2956 obstack_grow (current_obstack, &label, sizeof label);
2958 /* Record constant contents. */
2959 obstack_grow (current_obstack, &value, sizeof value);
2961 return (struct constant_descriptor *) obstack_finish (current_obstack);
2964 /* Given a constant rtx X, make (or find) a memory constant for its value
2965 and return a MEM rtx to refer to it in memory. */
2968 force_const_mem (mode, x)
2969 enum machine_mode mode;
2973 register struct constant_descriptor *desc;
2978 /* If we want this CONST_DOUBLE in the same mode as it is in memory
2979 (this will always be true for floating CONST_DOUBLEs that have been
2980 placed in memory, but not for VOIDmode (integer) CONST_DOUBLEs),
2981 use the previous copy. Otherwise, make a new one. Note that in
2982 the unlikely event that this same CONST_DOUBLE is used in two different
2983 modes in an alternating fashion, we will allocate a lot of different
2984 memory locations, but this should be extremely rare. */
2986 /* Don't use CONST_DOUBLE_MEM in a nested function.
2987 Nested functions have their own constant pools,
2988 so they can't share the same values in CONST_DOUBLE_MEM
2989 with the containing function. */
2990 if (outer_function_chain == 0)
2991 if (GET_CODE (x) == CONST_DOUBLE
2992 && GET_CODE (CONST_DOUBLE_MEM (x)) == MEM
2993 && GET_MODE (CONST_DOUBLE_MEM (x)) == mode)
2994 return CONST_DOUBLE_MEM (x);
2996 /* Compute hash code of X. Search the descriptors for that hash code
2997 to see if any of them describes X. If yes, the descriptor records
2998 the label number already assigned. */
3000 hash = const_hash_rtx (mode, x);
3002 for (desc = const_rtx_hash_table[hash]; desc; desc = desc->next)
3003 if (compare_constant_rtx (mode, x, desc))
3005 found = desc->label;
3011 register struct pool_constant *pool;
3012 register struct pool_sym *sym;
3015 /* No constant equal to X is known to have been output.
3016 Make a constant descriptor to enter X in the hash table.
3017 Assign the label number and record it in the descriptor for
3018 future calls to this function to find. */
3020 desc = record_constant_rtx (mode, x);
3021 desc->next = const_rtx_hash_table[hash];
3022 const_rtx_hash_table[hash] = desc;
3024 /* Align the location counter as required by EXP's data type. */
3025 align = (mode == VOIDmode) ? UNITS_PER_WORD : GET_MODE_SIZE (mode);
3026 if (align > BIGGEST_ALIGNMENT / BITS_PER_UNIT)
3027 align = BIGGEST_ALIGNMENT / BITS_PER_UNIT;
3029 pool_offset += align - 1;
3030 pool_offset &= ~ (align - 1);
3032 /* Allocate a pool constant descriptor, fill it in, and chain it in. */
3034 pool = (struct pool_constant *) oballoc (sizeof (struct pool_constant));
3038 pool->labelno = const_labelno;
3039 pool->align = align;
3040 pool->offset = pool_offset;
3046 last_pool->next = pool;
3049 pool_offset += GET_MODE_SIZE (mode);
3051 /* Create a string containing the label name, in LABEL. */
3052 ASM_GENERATE_INTERNAL_LABEL (label, "LC", const_labelno);
3057 = (char *) obstack_copy0 (saveable_obstack, label, strlen (label));
3059 /* Add label to symbol hash table. */
3060 hash = SYMHASH (found);
3061 sym = (struct pool_sym *) oballoc (sizeof (struct pool_sym));
3064 sym->next = const_rtx_sym_hash_table[hash];
3065 const_rtx_sym_hash_table[hash] = sym;
3068 /* We have a symbol name; construct the SYMBOL_REF and the MEM. */
3070 def = gen_rtx (MEM, mode, gen_rtx (SYMBOL_REF, Pmode, found));
3072 RTX_UNCHANGING_P (def) = 1;
3073 /* Mark the symbol_ref as belonging to this constants pool. */
3074 CONSTANT_POOL_ADDRESS_P (XEXP (def, 0)) = 1;
3075 current_function_uses_const_pool = 1;
3077 if (outer_function_chain == 0)
3078 if (GET_CODE (x) == CONST_DOUBLE)
3080 if (CONST_DOUBLE_MEM (x) == cc0_rtx)
3082 CONST_DOUBLE_CHAIN (x) = const_double_chain;
3083 const_double_chain = x;
3085 CONST_DOUBLE_MEM (x) = def;
3091 /* Given a SYMBOL_REF with CONSTANT_POOL_ADDRESS_P true, return a pointer to
3092 the corresponding pool_constant structure. */
3094 static struct pool_constant *
3095 find_pool_constant (addr)
3098 struct pool_sym *sym;
3099 char *label = XSTR (addr, 0);
3101 for (sym = const_rtx_sym_hash_table[SYMHASH (label)]; sym; sym = sym->next)
3102 if (sym->label == label)
3108 /* Given a constant pool SYMBOL_REF, return the corresponding constant. */
3111 get_pool_constant (addr)
3114 return (find_pool_constant (addr))->constant;
3117 /* Similar, return the mode. */
3120 get_pool_mode (addr)
3123 return (find_pool_constant (addr))->mode;
3126 /* Similar, return the offset in the constant pool. */
3129 get_pool_offset (addr)
3132 return (find_pool_constant (addr))->offset;
3135 /* Return the size of the constant pool. */
3143 /* Write all the constants in the constant pool. */
3146 output_constant_pool (fnname, fndecl)
3150 struct pool_constant *pool;
3152 union real_extract u;
3154 #ifdef ASM_OUTPUT_POOL_PROLOGUE
3155 ASM_OUTPUT_POOL_PROLOGUE (asm_out_file, fnname, fndecl, pool_offset);
3158 for (pool = first_pool; pool; pool = pool->next)
3162 /* See if X is a LABEL_REF (or a CONST referring to a LABEL_REF)
3163 whose CODE_LABEL has been deleted. This can occur if a jump table
3164 is eliminated by optimization. If so, write a constant of zero
3165 instead. Note that this can also happen by turning the
3166 CODE_LABEL into a NOTE. */
3167 if (((GET_CODE (x) == LABEL_REF
3168 && (INSN_DELETED_P (XEXP (x, 0))
3169 || GET_CODE (XEXP (x, 0)) == NOTE)))
3170 || (GET_CODE (x) == CONST && GET_CODE (XEXP (x, 0)) == PLUS
3171 && GET_CODE (XEXP (XEXP (x, 0), 0)) == LABEL_REF
3172 && (INSN_DELETED_P (XEXP (XEXP (XEXP (x, 0), 0), 0))
3173 || GET_CODE (XEXP (XEXP (XEXP (x, 0), 0), 0)) == NOTE)))
3176 /* First switch to correct section. */
3177 #ifdef SELECT_RTX_SECTION
3178 SELECT_RTX_SECTION (pool->mode, x);
3180 readonly_data_section ();
3183 #ifdef ASM_OUTPUT_SPECIAL_POOL_ENTRY
3184 ASM_OUTPUT_SPECIAL_POOL_ENTRY (asm_out_file, x, pool->mode,
3185 pool->align, pool->labelno, done);
3188 if (pool->align > 1)
3189 ASM_OUTPUT_ALIGN (asm_out_file, exact_log2 (pool->align));
3191 /* Output the label. */
3192 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LC", pool->labelno);
3194 /* Output the value of the constant itself. */
3195 switch (GET_MODE_CLASS (pool->mode))
3198 if (GET_CODE (x) != CONST_DOUBLE)
3201 bcopy (&CONST_DOUBLE_LOW (x), &u, sizeof u);
3202 assemble_real (u.d, pool->mode);
3206 case MODE_PARTIAL_INT:
3207 assemble_integer (x, GET_MODE_SIZE (pool->mode), 1);
3217 /* Done with this pool. */
3218 first_pool = last_pool = 0;
3221 /* Find all the constants whose addresses are referenced inside of EXP,
3222 and make sure assembler code with a label has been output for each one.
3223 Indicate whether an ADDR_EXPR has been encountered. */
3226 output_addressed_constants (exp)
3231 switch (TREE_CODE (exp))
3235 register tree constant = TREE_OPERAND (exp, 0);
3237 while (TREE_CODE (constant) == COMPONENT_REF)
3239 constant = TREE_OPERAND (constant, 0);
3242 if (TREE_CODE_CLASS (TREE_CODE (constant)) == 'c'
3243 || TREE_CODE (constant) == CONSTRUCTOR)
3244 /* No need to do anything here
3245 for addresses of variables or functions. */
3246 output_constant_def (constant);
3253 reloc = output_addressed_constants (TREE_OPERAND (exp, 0));
3254 reloc |= output_addressed_constants (TREE_OPERAND (exp, 1));
3259 case NON_LVALUE_EXPR:
3260 reloc = output_addressed_constants (TREE_OPERAND (exp, 0));
3266 for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link))
3267 if (TREE_VALUE (link) != 0)
3268 reloc |= output_addressed_constants (TREE_VALUE (link));
3279 /* Output assembler for byte constant */
3281 output_byte_asm (byte)
3284 if (output_bytecode)
3285 bc_emit_const ((char *) &byte, sizeof (char));
3286 #ifdef ASM_OUTPUT_BYTE
3289 ASM_OUTPUT_BYTE (asm_out_file, byte);
3294 /* Output assembler code for constant EXP to FILE, with no label.
3295 This includes the pseudo-op such as ".int" or ".byte", and a newline.
3296 Assumes output_addressed_constants has been done on EXP already.
3298 Generate exactly SIZE bytes of assembler data, padding at the end
3299 with zeros if necessary. SIZE must always be specified.
3301 SIZE is important for structure constructors,
3302 since trailing members may have been omitted from the constructor.
3303 It is also important for initialization of arrays from string constants
3304 since the full length of the string constant might not be wanted.
3305 It is also needed for initialization of unions, where the initializer's
3306 type is just one member, and that may not be as long as the union.
3308 There a case in which we would fail to output exactly SIZE bytes:
3309 for a structure constructor that wants to produce more than SIZE bytes.
3310 But such constructors will never be generated for any possible input. */
3313 output_constant (exp, size)
3317 register enum tree_code code = TREE_CODE (TREE_TYPE (exp));
3323 /* Allow a constructor with no elements for any data type.
3324 This means to fill the space with zeros. */
3325 if (TREE_CODE (exp) == CONSTRUCTOR && CONSTRUCTOR_ELTS (exp) == 0)
3327 if (output_bytecode)
3328 bc_emit_const_skip (size);
3330 assemble_zeros (size);
3334 /* Eliminate the NOP_EXPR that makes a cast not be an lvalue.
3335 That way we get the constant (we hope) inside it. */
3336 if (TREE_CODE (exp) == NOP_EXPR
3337 && TREE_TYPE (exp) == TREE_TYPE (TREE_OPERAND (exp, 0)))
3338 exp = TREE_OPERAND (exp, 0);
3347 case REFERENCE_TYPE:
3348 /* ??? What about (int)((float)(int)&foo + 4) */
3349 while (TREE_CODE (exp) == NOP_EXPR || TREE_CODE (exp) == CONVERT_EXPR
3350 || TREE_CODE (exp) == NON_LVALUE_EXPR)
3351 exp = TREE_OPERAND (exp, 0);
3353 if (! assemble_integer (expand_expr (exp, NULL_RTX, VOIDmode,
3354 EXPAND_INITIALIZER),
3356 error ("initializer for integer value is too complicated");
3361 if (TREE_CODE (exp) != REAL_CST)
3362 error ("initializer for floating value is not a floating constant");
3364 assemble_real (TREE_REAL_CST (exp),
3365 mode_for_size (size * BITS_PER_UNIT, MODE_FLOAT, 0));
3370 output_constant (TREE_REALPART (exp), size / 2);
3371 output_constant (TREE_IMAGPART (exp), size / 2);
3372 size -= (size / 2) * 2;
3376 if (TREE_CODE (exp) == CONSTRUCTOR)
3378 output_constructor (exp, size);
3381 else if (TREE_CODE (exp) == STRING_CST)
3385 if (size > TREE_STRING_LENGTH (exp))
3387 excess = size - TREE_STRING_LENGTH (exp);
3388 size = TREE_STRING_LENGTH (exp);
3391 assemble_string (TREE_STRING_POINTER (exp), size);
3400 if (TREE_CODE (exp) == CONSTRUCTOR)
3401 output_constructor (exp, size);
3408 assemble_zeros (size);
3412 /* Bytecode specific code to output assembler for integer. */
3414 bc_assemble_integer (exp, size)
3422 /* FIXME: is this fold() business going to be as good as the
3423 expand_expr() using EXPAND_SUM above in the RTL case? I
3425 FIXME: Copied as is from BC-GCC1; may need work. Don't hate. -bson */
3429 while (TREE_CODE (exp) == NOP_EXPR || TREE_CODE (exp) == CONVERT_EXPR)
3430 exp = TREE_OPERAND (exp, 0);
3431 if (TREE_CODE (exp) == INTEGER_CST)
3436 else if (TREE_CODE (exp) == PLUS_EXPR)
3438 const_part = TREE_OPERAND (exp, 0);
3439 while (TREE_CODE (const_part) == NOP_EXPR
3440 || TREE_CODE (const_part) == CONVERT_EXPR)
3441 const_part = TREE_OPERAND (const_part, 0);
3442 addr_part = TREE_OPERAND (exp, 1);
3443 while (TREE_CODE (addr_part) == NOP_EXPR
3444 || TREE_CODE (addr_part) == CONVERT_EXPR)
3445 addr_part = TREE_OPERAND (addr_part, 0);
3446 if (TREE_CODE (const_part) != INTEGER_CST)
3447 tmp = const_part, const_part = addr_part, addr_part = tmp;
3448 if (TREE_CODE (const_part) != INTEGER_CST
3449 || TREE_CODE (addr_part) != ADDR_EXPR)
3450 abort (); /* FIXME: we really haven't considered
3451 all the possible cases here. */
3453 else if (TREE_CODE (exp) == ADDR_EXPR)
3455 const_part = integer_zero_node;
3459 abort (); /* FIXME: ditto previous. */
3465 char c = TREE_INT_CST_LOW (const_part);
3471 short s = TREE_INT_CST_LOW (const_part);
3472 bc_emit ((char *) &s, 2);
3477 int i = TREE_INT_CST_LOW (const_part);
3478 bc_emit ((char *) &i, 4);
3483 #if WORDS_BIG_ENDIAN
3484 int i = TREE_INT_CST_HIGH (const_part);
3485 bc_emit ((char *) &i, 4);
3486 i = TREE_INT_CST_LOW (const_part);
3487 bc_emit ((char *) &i, 4);
3489 int i = TREE_INT_CST_LOW (const_part);
3490 bc_emit ((char *) &i, 4);
3491 i = TREE_INT_CST_HIGH (const_part);
3492 bc_emit ((char *) &i, 4);
3499 && TREE_CODE (TREE_OPERAND (addr_part, 0)) == VAR_DECL)
3500 bc_emit_labelref (DECL_ASSEMBLER_NAME (TREE_OPERAND (addr_part, 0)),
3501 TREE_INT_CST_LOW (const_part));
3503 abort (); /* FIXME: there may be more cases. */
3506 /* Subroutine of output_constant, used for CONSTRUCTORs
3507 (aggregate constants).
3508 Generate at least SIZE bytes, padding if necessary. */
3511 output_constructor (exp, size)
3515 register tree link, field = 0;
3516 HOST_WIDE_INT min_index = 0;
3517 /* Number of bytes output or skipped so far.
3518 In other words, current position within the constructor. */
3519 int total_bytes = 0;
3520 /* Non-zero means BYTE contains part of a byte, to be output. */
3521 int byte_buffer_in_use = 0;
3524 if (HOST_BITS_PER_WIDE_INT < BITS_PER_UNIT)
3527 if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE)
3528 field = TYPE_FIELDS (TREE_TYPE (exp));
3530 if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE
3531 && TYPE_DOMAIN (TREE_TYPE (exp)) != 0)
3533 = TREE_INT_CST_LOW (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (exp))));
3535 /* As LINK goes through the elements of the constant,
3536 FIELD goes through the structure fields, if the constant is a structure.
3537 if the constant is a union, then we override this,
3538 by getting the field from the TREE_LIST element.
3539 But the constant could also be an array. Then FIELD is zero. */
3540 for (link = CONSTRUCTOR_ELTS (exp);
3542 link = TREE_CHAIN (link),
3543 field = field ? TREE_CHAIN (field) : 0)
3545 tree val = TREE_VALUE (link);
3548 /* the element in a union constructor specifies the proper field. */
3550 if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE
3551 || TREE_CODE (TREE_TYPE (exp)) == UNION_TYPE)
3553 /* if available, use the type given by link */
3554 if (TREE_PURPOSE (link) != 0)
3555 field = TREE_PURPOSE (link);
3558 if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE)
3559 index = TREE_PURPOSE (link);
3561 /* Eliminate the marker that makes a cast not be an lvalue. */
3565 if (field == 0 || !DECL_BIT_FIELD (field))
3567 /* An element that is not a bit-field. */
3569 register int fieldsize;
3570 /* Since this structure is static,
3571 we know the positions are constant. */
3572 int bitpos = (field ? (TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field))
3576 bitpos = (TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (val)))
3578 * (TREE_INT_CST_LOW (index) - min_index));
3580 /* Output any buffered-up bit-fields preceding this element. */
3581 if (byte_buffer_in_use)
3583 ASM_OUTPUT_BYTE (asm_out_file, byte);
3585 byte_buffer_in_use = 0;
3588 /* Advance to offset of this element.
3589 Note no alignment needed in an array, since that is guaranteed
3590 if each element has the proper size. */
3591 if ((field != 0 || index != 0) && bitpos != total_bytes)
3593 if (!output_bytecode)
3594 assemble_zeros (bitpos - total_bytes);
3596 bc_emit_const_skip (bitpos - total_bytes);
3597 total_bytes = bitpos;
3600 /* Determine size this element should occupy. */
3603 if (TREE_CODE (DECL_SIZE (field)) != INTEGER_CST)
3605 if (TREE_INT_CST_LOW (DECL_SIZE (field)) > 100000)
3607 /* This avoids overflow trouble. */
3608 tree size_tree = size_binop (CEIL_DIV_EXPR,
3610 size_int (BITS_PER_UNIT));
3611 fieldsize = TREE_INT_CST_LOW (size_tree);
3615 fieldsize = TREE_INT_CST_LOW (DECL_SIZE (field));
3616 fieldsize = (fieldsize + BITS_PER_UNIT - 1) / BITS_PER_UNIT;
3620 fieldsize = int_size_in_bytes (TREE_TYPE (TREE_TYPE (exp)));
3622 /* Output the element's initial value. */
3624 assemble_zeros (fieldsize);
3626 output_constant (val, fieldsize);
3628 /* Count its size. */
3629 total_bytes += fieldsize;
3631 else if (val != 0 && TREE_CODE (val) != INTEGER_CST)
3632 error ("invalid initial value for member `%s'",
3633 IDENTIFIER_POINTER (DECL_NAME (field)));
3636 /* Element that is a bit-field. */
3638 int next_offset = TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field));
3640 = (next_offset + TREE_INT_CST_LOW (DECL_SIZE (field)));
3643 val = integer_zero_node;
3645 /* If this field does not start in this (or, next) byte,
3647 if (next_offset / BITS_PER_UNIT != total_bytes)
3649 /* Output remnant of any bit field in previous bytes. */
3650 if (byte_buffer_in_use)
3652 ASM_OUTPUT_BYTE (asm_out_file, byte);
3654 byte_buffer_in_use = 0;
3657 /* If still not at proper byte, advance to there. */
3658 if (next_offset / BITS_PER_UNIT != total_bytes)
3660 assemble_zeros (next_offset / BITS_PER_UNIT - total_bytes);
3661 total_bytes = next_offset / BITS_PER_UNIT;
3665 if (! byte_buffer_in_use)
3668 /* We must split the element into pieces that fall within
3669 separate bytes, and combine each byte with previous or
3670 following bit-fields. */
3672 /* next_offset is the offset n fbits from the beginning of
3673 the structure to the next bit of this element to be processed.
3674 end_offset is the offset of the first bit past the end of
3676 while (next_offset < end_offset)
3680 int next_byte = next_offset / BITS_PER_UNIT;
3681 int next_bit = next_offset % BITS_PER_UNIT;
3683 /* Advance from byte to byte
3684 within this element when necessary. */
3685 while (next_byte != total_bytes)
3687 ASM_OUTPUT_BYTE (asm_out_file, byte);
3692 /* Number of bits we can process at once
3693 (all part of the same byte). */
3694 this_time = MIN (end_offset - next_offset,
3695 BITS_PER_UNIT - next_bit);
3696 #if BYTES_BIG_ENDIAN
3697 /* On big-endian machine, take the most significant bits
3698 first (of the bits that are significant)
3699 and put them into bytes from the most significant end. */
3700 shift = end_offset - next_offset - this_time;
3701 /* Don't try to take a bunch of bits that cross
3702 the word boundary in the INTEGER_CST. */
3703 if (shift < HOST_BITS_PER_WIDE_INT
3704 && shift + this_time > HOST_BITS_PER_WIDE_INT)
3706 this_time -= (HOST_BITS_PER_WIDE_INT - shift);
3707 shift = HOST_BITS_PER_WIDE_INT;
3710 /* Now get the bits from the appropriate constant word. */
3711 if (shift < HOST_BITS_PER_WIDE_INT)
3713 value = TREE_INT_CST_LOW (val);
3715 else if (shift < 2 * HOST_BITS_PER_WIDE_INT)
3717 value = TREE_INT_CST_HIGH (val);
3718 shift -= HOST_BITS_PER_WIDE_INT;
3722 byte |= (((value >> shift)
3723 & (((HOST_WIDE_INT) 1 << this_time) - 1))
3724 << (BITS_PER_UNIT - this_time - next_bit));
3726 /* On little-endian machines,
3727 take first the least significant bits of the value
3728 and pack them starting at the least significant
3729 bits of the bytes. */
3730 shift = (next_offset
3731 - TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field)));
3732 /* Don't try to take a bunch of bits that cross
3733 the word boundary in the INTEGER_CST. */
3734 if (shift < HOST_BITS_PER_WIDE_INT
3735 && shift + this_time > HOST_BITS_PER_WIDE_INT)
3737 this_time -= (HOST_BITS_PER_WIDE_INT - shift);
3738 shift = HOST_BITS_PER_WIDE_INT;
3741 /* Now get the bits from the appropriate constant word. */
3742 if (shift < HOST_BITS_PER_INT)
3743 value = TREE_INT_CST_LOW (val);
3744 else if (shift < 2 * HOST_BITS_PER_WIDE_INT)
3746 value = TREE_INT_CST_HIGH (val);
3747 shift -= HOST_BITS_PER_WIDE_INT;
3751 byte |= ((value >> shift)
3752 & (((HOST_WIDE_INT) 1 << this_time) - 1)) << next_bit;
3754 next_offset += this_time;
3755 byte_buffer_in_use = 1;
3759 if (byte_buffer_in_use)
3761 ASM_OUTPUT_BYTE (asm_out_file, byte);
3764 if (total_bytes < size)
3765 assemble_zeros (size - total_bytes);
3769 #ifdef HANDLE_SYSV_PRAGMA
3771 /* Support #pragma weak by default if WEAK_ASM_OP is defined. */
3772 #if defined (HANDLE_PRAGMA_WEAK) || (defined (WEAK_ASM_OP) && defined (SET_ASM_OP))
3774 /* See c-pragma.c for an identical definition. */
3790 /* Output asm to handle ``#pragma weak'' */
3792 handle_pragma_weak (what, asm_out_file, name, value)
3793 enum pragma_state what;
3797 if (what == ps_name || what == ps_value)
3799 fprintf (asm_out_file, "\t%s\t", WEAK_ASM_OP);
3801 if (output_bytecode)
3802 BC_OUTPUT_LABELREF (asm_out_file, name);
3804 ASM_OUTPUT_LABELREF (asm_out_file, name);
3806 fputc ('\n', asm_out_file);
3807 if (what == ps_value)
3809 fprintf (asm_out_file, "\t%s\t", SET_ASM_OP);
3810 if (output_bytecode)
3811 BC_OUTPUT_LABELREF (asm_out_file, name);
3813 ASM_OUTPUT_LABELREF (asm_out_file, name);
3815 fputc (',', asm_out_file);
3816 if (output_bytecode)
3817 BC_OUTPUT_LABELREF (asm_out_file, value);
3819 ASM_OUTPUT_LABELREF (asm_out_file, value);
3821 fputc ('\n', asm_out_file);
3824 else if (! (what == ps_done || what == ps_start))
3825 warning ("malformed `#pragma weak'");
3828 #endif /* HANDLE_PRAGMA_WEAK or (WEAK_ASM_OP and SET_ASM_OP) */
3830 #endif /* HANDLE_SYSV_PRAGMA */