1 /* Output variables, constants and external declarations, for GNU compiler.
2 Copyright (C) 1987, 88, 89, 92-7, 1998 Free Software Foundation, Inc.
4 This file is part of GNU CC.
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING. If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
22 /* This file handles generation of all the assembler code
23 *except* the instructions of a function.
24 This includes declarations of variables and their initial values.
26 We also output the assembler code for constants stored in memory
27 and are responsible for combining constants with the same value. */
32 /* #include <stab.h> */
40 #include "hard-reg-set.h"
48 #ifdef XCOFF_DEBUGGING_INFO
54 #ifndef TRAMPOLINE_ALIGNMENT
55 #define TRAMPOLINE_ALIGNMENT FUNCTION_BOUNDARY
59 #define ASM_STABS_OP ".stabs"
62 /* Define the prefix to use when check_memory_usage_flag is enable. */
63 #ifdef NO_DOLLAR_IN_LABEL
64 #ifdef NO_DOT_IN_LABEL
65 #define CHKR_PREFIX "chkr_prefix_"
66 #else /* !NO_DOT_IN_LABEL */
67 #define CHKR_PREFIX "chkr."
69 #else /* !NO_DOLLAR_IN_LABEL */
70 #define CHKR_PREFIX "chkr$"
72 #define CHKR_PREFIX_SIZE (sizeof (CHKR_PREFIX) - 1)
74 /* This macro gets just the user-specified name
75 out of the string in a SYMBOL_REF. On most machines,
76 we discard the * if any and that's all. */
77 #ifndef STRIP_NAME_ENCODING
78 #define STRIP_NAME_ENCODING(VAR,SYMBOL_NAME) \
79 (VAR) = ((SYMBOL_NAME) + ((SYMBOL_NAME)[0] == '*'))
82 /* File in which assembler code is being written. */
84 extern FILE *asm_out_file
;
86 /* The (assembler) name of the first globally-visible object output. */
87 char *first_global_object_name
;
89 extern struct obstack
*current_obstack
;
90 extern struct obstack
*saveable_obstack
;
91 extern struct obstack
*rtl_obstack
;
92 extern struct obstack permanent_obstack
;
93 #define obstack_chunk_alloc xmalloc
95 /* Number for making the label on the next
96 constant that is stored in memory. */
100 /* Number for making the label on the next
101 static variable internal to a function. */
105 /* Carry information from ASM_DECLARE_OBJECT_NAME
106 to ASM_FINISH_DECLARE_OBJECT. */
108 int size_directive_output
;
110 /* The last decl for which assemble_variable was called,
111 if it did ASM_DECLARE_OBJECT_NAME.
112 If the last call to assemble_variable didn't do that,
115 tree last_assemble_variable_decl
;
118 #ifdef HANDLE_PRAGMA_WEAK
119 /* Any weak symbol declarations waiting to be emitted. */
123 struct weak_syms
*next
;
128 static struct weak_syms
*weak_decls
;
131 /* Nonzero if at least one function definition has been seen. */
133 static int function_defined
;
136 struct constant_descriptor
;
138 struct pool_constant
;
140 static char *strip_reg_name
PROTO((char *));
141 static int contains_pointers_p
PROTO((tree
));
142 static void decode_addr_const
PROTO((tree
, struct addr_const
*));
143 static int const_hash
PROTO((tree
));
144 static int compare_constant
PROTO((tree
,
145 struct constant_descriptor
*));
146 static char *compare_constant_1
PROTO((tree
, char *));
147 static struct constant_descriptor
*record_constant
PROTO((tree
));
148 static void record_constant_1
PROTO((tree
));
149 static tree copy_constant
PROTO((tree
));
150 static void output_constant_def_contents
PROTO((tree
, int, int));
151 static void decode_rtx_const
PROTO((enum machine_mode
, rtx
,
152 struct rtx_const
*));
153 static int const_hash_rtx
PROTO((enum machine_mode
, rtx
));
154 static int compare_constant_rtx
PROTO((enum machine_mode
, rtx
,
155 struct constant_descriptor
*));
156 static struct constant_descriptor
*record_constant_rtx
PROTO((enum machine_mode
,
158 static struct pool_constant
*find_pool_constant
PROTO((rtx
));
159 static void mark_constant_pool
PROTO((void));
160 static void mark_constants
PROTO((rtx
));
161 static int output_addressed_constants
PROTO((tree
));
162 static void output_after_function_constants
PROTO((void));
163 static void output_constructor
PROTO((tree
, int));
165 static enum in_section
{ no_section
, in_text
, in_data
, in_named
166 #ifdef BSS_SECTION_ASM_OP
169 #ifdef EH_FRAME_SECTION_ASM_OP
172 #ifdef EXTRA_SECTIONS
175 } in_section
= no_section
;
177 /* Return a non-zero value if DECL has a section attribute. */
178 #define IN_NAMED_SECTION(DECL) \
179 ((TREE_CODE (DECL) == FUNCTION_DECL || TREE_CODE (DECL) == VAR_DECL) \
180 && DECL_SECTION_NAME (DECL) != NULL_TREE)
182 /* Text of section name when in_section == in_named. */
183 static char *in_named_name
;
185 /* Define functions like text_section for any extra sections. */
186 #ifdef EXTRA_SECTION_FUNCTIONS
187 EXTRA_SECTION_FUNCTIONS
190 /* Tell assembler to switch to text section. */
195 if (in_section
!= in_text
)
197 fprintf (asm_out_file
, "%s\n", TEXT_SECTION_ASM_OP
);
198 in_section
= in_text
;
202 /* Tell assembler to switch to data section. */
207 if (in_section
!= in_data
)
209 if (flag_shared_data
)
211 #ifdef SHARED_SECTION_ASM_OP
212 fprintf (asm_out_file
, "%s\n", SHARED_SECTION_ASM_OP
);
214 fprintf (asm_out_file
, "%s\n", DATA_SECTION_ASM_OP
);
218 fprintf (asm_out_file
, "%s\n", DATA_SECTION_ASM_OP
);
220 in_section
= in_data
;
224 /* Tell assembler to switch to read-only data section. This is normally
228 readonly_data_section ()
230 #ifdef READONLY_DATA_SECTION
231 READONLY_DATA_SECTION (); /* Note this can call data_section. */
237 /* Determine if we're in the text section. */
242 return in_section
== in_text
;
245 /* Determine if we're in the data section. */
250 return in_section
== in_data
;
253 /* Tell assembler to change to section NAME for DECL.
254 If DECL is NULL, just switch to section NAME.
255 If NAME is NULL, get the name from DECL.
256 If RELOC is 1, the initializer for DECL contains relocs. */
259 named_section (decl
, name
, reloc
)
264 if (decl
!= NULL_TREE
265 && TREE_CODE_CLASS (TREE_CODE (decl
)) != 'd')
268 name
= TREE_STRING_POINTER (DECL_SECTION_NAME (decl
));
270 if (in_section
!= in_named
|| strcmp (name
, in_named_name
))
272 #ifdef ASM_OUTPUT_SECTION_NAME
273 ASM_OUTPUT_SECTION_NAME (asm_out_file
, decl
, name
, reloc
);
275 /* Section attributes are not supported if this macro isn't provided -
276 some host formats don't support them at all. The front-end should
277 already have flagged this as an error. */
281 in_named_name
= obstack_alloc (&permanent_obstack
, strlen (name
) + 1);
282 strcpy (in_named_name
, name
);
283 in_section
= in_named
;
287 #ifdef ASM_OUTPUT_SECTION_NAME
288 #ifndef UNIQUE_SECTION
289 #define UNIQUE_SECTION(DECL,RELOC) \
292 char *name, *string; \
294 name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL)); \
295 /* Strip off any encoding in name. */ \
296 STRIP_NAME_ENCODING (name, name); \
298 len = strlen (name) + 1; \
299 string = alloca (len + 1); \
300 sprintf (string, ".%s", name); \
302 DECL_SECTION_NAME (DECL) = build_string (len, string); \
305 #ifndef UNIQUE_SECTION_P
306 #define UNIQUE_SECTION_P(DECL) 0
310 #ifdef BSS_SECTION_ASM_OP
312 /* Tell the assembler to switch to the bss section. */
317 if (in_section
!= in_bss
)
319 #ifdef SHARED_BSS_SECTION_ASM_OP
320 if (flag_shared_data
)
321 fprintf (asm_out_file
, "%s\n", SHARED_BSS_SECTION_ASM_OP
);
324 fprintf (asm_out_file
, "%s\n", BSS_SECTION_ASM_OP
);
330 #ifdef ASM_OUTPUT_BSS
332 /* Utility function for ASM_OUTPUT_BSS for targets to use if
333 they don't support alignments in .bss.
334 ??? It is believed that this function will work in most cases so such
335 support is localized here. */
338 asm_output_bss (file
, decl
, name
, size
, rounded
)
344 ASM_GLOBALIZE_LABEL (file
, name
);
346 #ifdef ASM_DECLARE_OBJECT_NAME
347 last_assemble_variable_decl
= decl
;
348 ASM_DECLARE_OBJECT_NAME (file
, name
, decl
);
350 /* Standard thing is just output label for the object. */
351 ASM_OUTPUT_LABEL (file
, name
);
352 #endif /* ASM_DECLARE_OBJECT_NAME */
353 ASM_OUTPUT_SKIP (file
, rounded
);
358 #ifdef ASM_OUTPUT_ALIGNED_BSS
360 /* Utility function for targets to use in implementing
361 ASM_OUTPUT_ALIGNED_BSS.
362 ??? It is believed that this function will work in most cases so such
363 support is localized here. */
366 asm_output_aligned_bss (file
, decl
, name
, size
, align
)
372 ASM_GLOBALIZE_LABEL (file
, name
);
374 ASM_OUTPUT_ALIGN (file
, floor_log2 (align
/ BITS_PER_UNIT
));
375 #ifdef ASM_DECLARE_OBJECT_NAME
376 last_assemble_variable_decl
= decl
;
377 ASM_DECLARE_OBJECT_NAME (file
, name
, decl
);
379 /* Standard thing is just output label for the object. */
380 ASM_OUTPUT_LABEL (file
, name
);
381 #endif /* ASM_DECLARE_OBJECT_NAME */
382 ASM_OUTPUT_SKIP (file
, size
? size
: 1);
387 #endif /* BSS_SECTION_ASM_OP */
389 #ifdef EH_FRAME_SECTION_ASM_OP
393 if (in_section
!= in_eh_frame
)
395 fprintf (asm_out_file
, "%s\n", EH_FRAME_SECTION_ASM_OP
);
396 in_section
= in_eh_frame
;
401 /* Switch to the section for function DECL.
403 If DECL is NULL_TREE, switch to the text section.
404 ??? It's not clear that we will ever be passed NULL_TREE, but it's
405 safer to handle it. */
408 function_section (decl
)
411 if (decl
!= NULL_TREE
412 && DECL_SECTION_NAME (decl
) != NULL_TREE
)
413 named_section (decl
, (char *) 0, 0);
418 /* Switch to section for variable DECL.
420 RELOC is the `reloc' argument to SELECT_SECTION. */
423 variable_section (decl
, reloc
)
427 if (IN_NAMED_SECTION (decl
))
428 named_section (decl
, NULL
, reloc
);
431 /* C++ can have const variables that get initialized from constructors,
432 and thus can not be in a readonly section. We prevent this by
433 verifying that the initial value is constant for objects put in a
436 error_mark_node is used by the C front end to indicate that the
437 initializer has not been seen yet. In this case, we assume that
438 the initializer must be constant.
440 C++ uses error_mark_node for variables that have complicated
441 initializers, but these variables go in BSS so we won't be called
444 #ifdef SELECT_SECTION
445 SELECT_SECTION (decl
, reloc
);
447 if (DECL_READONLY_SECTION (decl
, reloc
))
448 readonly_data_section ();
455 /* Tell assembler to switch to the section for the exception handling
461 #if defined (EXCEPTION_SECTION)
462 EXCEPTION_SECTION ();
464 #ifdef ASM_OUTPUT_SECTION_NAME
465 named_section (NULL_TREE
, ".gcc_except_table", 0);
470 readonly_data_section ();
475 /* Create the rtl to represent a function, for a function definition.
476 DECL is a FUNCTION_DECL node which describes which function.
477 The rtl is stored into DECL. */
480 make_function_rtl (decl
)
483 char *name
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
));
484 char *new_name
= name
;
486 /* Rename a nested function to avoid conflicts. */
487 if (decl_function_context (decl
) != 0
488 && DECL_INITIAL (decl
) != 0
489 && DECL_RTL (decl
) == 0)
493 name
= IDENTIFIER_POINTER (DECL_NAME (decl
));
494 ASM_FORMAT_PRIVATE_NAME (label
, name
, var_labelno
);
495 name
= obstack_copy0 (saveable_obstack
, label
, strlen (label
));
500 /* When -fprefix-function-name is used, every function name is
501 prefixed. Even static functions are prefixed because they
502 could be declared latter. Note that a nested function name
504 if (flag_prefix_function_name
)
506 new_name
= (char *) alloca (strlen (name
) + CHKR_PREFIX_SIZE
+ 1);
507 strcpy (new_name
, CHKR_PREFIX
);
508 strcpy (new_name
+ CHKR_PREFIX_SIZE
, name
);
509 name
= obstack_copy0 (saveable_obstack
, new_name
, strlen (new_name
));
513 if (DECL_RTL (decl
) == 0)
516 = gen_rtx_MEM (DECL_MODE (decl
),
517 gen_rtx_SYMBOL_REF (Pmode
, name
));
519 /* Optionally set flags or add text to the name to record information
520 such as that it is a function name. If the name is changed, the macro
521 ASM_OUTPUT_LABELREF will have to know how to strip this information. */
522 #ifdef ENCODE_SECTION_INFO
523 ENCODE_SECTION_INFO (decl
);
527 /* Record at least one function has been defined. */
528 function_defined
= 1;
531 /* Given NAME, a putative register name, discard any customary prefixes. */
534 strip_reg_name (name
)
537 #ifdef REGISTER_PREFIX
538 if (!strncmp (name
, REGISTER_PREFIX
, strlen (REGISTER_PREFIX
)))
539 name
+= strlen (REGISTER_PREFIX
);
541 if (name
[0] == '%' || name
[0] == '#')
546 /* Decode an `asm' spec for a declaration as a register name.
547 Return the register number, or -1 if nothing specified,
548 or -2 if the ASMSPEC is not `cc' or `memory' and is not recognized,
549 or -3 if ASMSPEC is `cc' and is not recognized,
550 or -4 if ASMSPEC is `memory' and is not recognized.
551 Accept an exact spelling or a decimal number.
552 Prefixes such as % are optional. */
555 decode_reg_name (asmspec
)
562 /* Get rid of confusing prefixes. */
563 asmspec
= strip_reg_name (asmspec
);
565 /* Allow a decimal number as a "register name". */
566 for (i
= strlen (asmspec
) - 1; i
>= 0; i
--)
567 if (! (asmspec
[i
] >= '0' && asmspec
[i
] <= '9'))
569 if (asmspec
[0] != 0 && i
< 0)
572 if (i
< FIRST_PSEUDO_REGISTER
&& i
>= 0)
578 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; i
++)
580 && ! strcmp (asmspec
, strip_reg_name (reg_names
[i
])))
583 #ifdef ADDITIONAL_REGISTER_NAMES
585 static struct { char *name
; int number
; } table
[]
586 = ADDITIONAL_REGISTER_NAMES
;
588 for (i
= 0; i
< sizeof (table
) / sizeof (table
[0]); i
++)
589 if (! strcmp (asmspec
, table
[i
].name
))
590 return table
[i
].number
;
592 #endif /* ADDITIONAL_REGISTER_NAMES */
594 if (!strcmp (asmspec
, "memory"))
597 if (!strcmp (asmspec
, "cc"))
606 /* Create the DECL_RTL for a declaration for a static or external variable
607 or static or external function.
608 ASMSPEC, if not 0, is the string which the user specified
609 as the assembler symbol name.
610 TOP_LEVEL is nonzero if this is a file-scope variable.
612 This is never called for PARM_DECL nodes. */
615 make_decl_rtl (decl
, asmspec
, top_level
)
620 register char *name
= 0;
623 reg_number
= decode_reg_name (asmspec
);
625 if (DECL_ASSEMBLER_NAME (decl
) != NULL_TREE
)
626 name
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
));
628 if (reg_number
== -2)
630 /* ASMSPEC is given, and not the name of a register. */
631 name
= (char *) obstack_alloc (saveable_obstack
,
632 strlen (asmspec
) + 2);
634 strcpy (&name
[1], asmspec
);
637 /* For a duplicate declaration, we can be called twice on the
638 same DECL node. Don't discard the RTL already made. */
639 if (DECL_RTL (decl
) == 0)
643 /* First detect errors in declaring global registers. */
644 if (TREE_CODE (decl
) != FUNCTION_DECL
645 && DECL_REGISTER (decl
) && reg_number
== -1)
646 error_with_decl (decl
,
647 "register name not specified for `%s'");
648 else if (TREE_CODE (decl
) != FUNCTION_DECL
649 && DECL_REGISTER (decl
) && reg_number
< 0)
650 error_with_decl (decl
,
651 "invalid register name for `%s'");
652 else if ((reg_number
>= 0 || reg_number
== -3)
653 && (TREE_CODE (decl
) == FUNCTION_DECL
654 && ! DECL_REGISTER (decl
)))
655 error_with_decl (decl
,
656 "register name given for non-register variable `%s'");
657 else if (TREE_CODE (decl
) != FUNCTION_DECL
658 && DECL_REGISTER (decl
)
659 && TYPE_MODE (TREE_TYPE (decl
)) == BLKmode
)
660 error_with_decl (decl
,
661 "data type of `%s' isn't suitable for a register");
662 else if (TREE_CODE (decl
) != FUNCTION_DECL
&& DECL_REGISTER (decl
)
663 && ! HARD_REGNO_MODE_OK (reg_number
,
664 TYPE_MODE (TREE_TYPE (decl
))))
665 error_with_decl (decl
,
666 "register number for `%s' isn't suitable for data type");
667 /* Now handle properly declared static register variables. */
668 else if (TREE_CODE (decl
) != FUNCTION_DECL
&& DECL_REGISTER (decl
))
672 if (DECL_INITIAL (decl
) != 0 && top_level
)
674 DECL_INITIAL (decl
) = 0;
675 error ("global register variable has initial value");
677 if (fixed_regs
[reg_number
] == 0
678 && function_defined
&& top_level
)
679 error ("global register variable follows a function definition");
680 if (TREE_THIS_VOLATILE (decl
))
681 warning ("volatile register variables don't work as you might wish");
683 /* If the user specified one of the eliminables registers here,
684 e.g., FRAME_POINTER_REGNUM, we don't want to get this variable
685 confused with that register and be eliminated. Although this
686 usage is somewhat suspect, we nevertheless use the following
687 kludge to avoid setting DECL_RTL to frame_pointer_rtx. */
690 = gen_rtx_REG (DECL_MODE (decl
), FIRST_PSEUDO_REGISTER
);
691 REGNO (DECL_RTL (decl
)) = reg_number
;
692 REG_USERVAR_P (DECL_RTL (decl
)) = 1;
696 /* Make this register global, so not usable for anything
698 nregs
= HARD_REGNO_NREGS (reg_number
, DECL_MODE (decl
));
700 globalize_reg (reg_number
+ --nregs
);
703 /* Specifying a section attribute on a variable forces it into a
704 non-.bss section, and thus it cannot be common. */
705 else if (TREE_CODE (decl
) == VAR_DECL
706 && DECL_SECTION_NAME (decl
) != NULL_TREE
707 && DECL_INITIAL (decl
) == NULL_TREE
708 && DECL_COMMON (decl
))
709 DECL_COMMON (decl
) = 0;
711 /* Now handle ordinary static variables and functions (in memory).
712 Also handle vars declared register invalidly. */
713 if (DECL_RTL (decl
) == 0)
715 /* Can't use just the variable's own name for a variable
716 whose scope is less than the whole file.
717 Concatenate a distinguishing number. */
718 if (!top_level
&& !TREE_PUBLIC (decl
) && asmspec
== 0)
722 ASM_FORMAT_PRIVATE_NAME (label
, name
, var_labelno
);
723 name
= obstack_copy0 (saveable_obstack
, label
, strlen (label
));
730 /* When -fprefix-function-name is used, the functions
731 names are prefixed. Only nested function names are not
733 if (flag_prefix_function_name
&& TREE_CODE (decl
) == FUNCTION_DECL
)
736 new_name
= (char *) alloca (strlen (name
) + CHKR_PREFIX_SIZE
738 strcpy (new_name
, CHKR_PREFIX
);
739 strcpy (new_name
+ CHKR_PREFIX_SIZE
, name
);
740 name
= obstack_copy0 (saveable_obstack
,
741 new_name
, strlen (new_name
));
744 DECL_RTL (decl
) = gen_rtx_MEM (DECL_MODE (decl
),
745 gen_rtx_SYMBOL_REF (Pmode
, name
));
747 /* If this variable is to be treated as volatile, show its
748 tree node has side effects. If it has side effects, either
749 because of this test or from TREE_THIS_VOLATILE also
750 being set, show the MEM is volatile. */
751 if (flag_volatile_global
&& TREE_CODE (decl
) == VAR_DECL
752 && TREE_PUBLIC (decl
))
753 TREE_SIDE_EFFECTS (decl
) = 1;
754 if (TREE_SIDE_EFFECTS (decl
))
755 MEM_VOLATILE_P (DECL_RTL (decl
)) = 1;
757 if (TREE_READONLY (decl
))
758 RTX_UNCHANGING_P (DECL_RTL (decl
)) = 1;
759 MEM_IN_STRUCT_P (DECL_RTL (decl
))
760 = AGGREGATE_TYPE_P (TREE_TYPE (decl
));
762 /* Optionally set flags or add text to the name to record information
763 such as that it is a function name.
764 If the name is changed, the macro ASM_OUTPUT_LABELREF
765 will have to know how to strip this information. */
766 #ifdef ENCODE_SECTION_INFO
767 ENCODE_SECTION_INFO (decl
);
771 /* If the old RTL had the wrong mode, fix the mode. */
772 else if (GET_MODE (DECL_RTL (decl
)) != DECL_MODE (decl
))
774 rtx rtl
= DECL_RTL (decl
);
775 PUT_MODE (rtl
, DECL_MODE (decl
));
779 /* Make the rtl for variable VAR be volatile.
780 Use this only for static variables. */
783 make_var_volatile (var
)
786 if (GET_CODE (DECL_RTL (var
)) != MEM
)
789 MEM_VOLATILE_P (DECL_RTL (var
)) = 1;
792 /* Output alignment directive to align for constant expression EXP. */
795 assemble_constant_align (exp
)
800 /* Align the location counter as required by EXP's data type. */
801 align
= TYPE_ALIGN (TREE_TYPE (exp
));
802 #ifdef CONSTANT_ALIGNMENT
803 align
= CONSTANT_ALIGNMENT (exp
, align
);
806 if (align
> BITS_PER_UNIT
)
807 ASM_OUTPUT_ALIGN (asm_out_file
, floor_log2 (align
/ BITS_PER_UNIT
));
810 /* Output a string of literal assembler code
811 for an `asm' keyword used between functions. */
814 assemble_asm (string
)
819 if (TREE_CODE (string
) == ADDR_EXPR
)
820 string
= TREE_OPERAND (string
, 0);
822 fprintf (asm_out_file
, "\t%s\n", TREE_STRING_POINTER (string
));
825 #if 0 /* This should no longer be needed, because
826 flag_gnu_linker should be 0 on these systems,
827 which should prevent any output
828 if ASM_OUTPUT_CONSTRUCTOR and ASM_OUTPUT_DESTRUCTOR are absent. */
829 #if !(defined(DBX_DEBUGGING_INFO) && !defined(FASCIST_ASSEMBLER))
830 #ifndef ASM_OUTPUT_CONSTRUCTOR
831 #define ASM_OUTPUT_CONSTRUCTOR(file, name)
833 #ifndef ASM_OUTPUT_DESTRUCTOR
834 #define ASM_OUTPUT_DESTRUCTOR(file, name)
839 /* Record an element in the table of global destructors.
840 How this is done depends on what sort of assembler and linker
843 NAME should be the name of a global function to be called
844 at exit time. This name is output using assemble_name. */
847 assemble_destructor (name
)
850 #ifdef ASM_OUTPUT_DESTRUCTOR
851 ASM_OUTPUT_DESTRUCTOR (asm_out_file
, name
);
855 /* Now tell GNU LD that this is part of the static destructor set. */
856 /* This code works for any machine provided you use GNU as/ld. */
857 fprintf (asm_out_file
, "%s \"___DTOR_LIST__\",22,0,0,", ASM_STABS_OP
);
858 assemble_name (asm_out_file
, name
);
859 fputc ('\n', asm_out_file
);
864 /* Likewise for global constructors. */
867 assemble_constructor (name
)
870 #ifdef ASM_OUTPUT_CONSTRUCTOR
871 ASM_OUTPUT_CONSTRUCTOR (asm_out_file
, name
);
875 /* Now tell GNU LD that this is part of the static constructor set. */
876 /* This code works for any machine provided you use GNU as/ld. */
877 fprintf (asm_out_file
, "%s \"___CTOR_LIST__\",22,0,0,", ASM_STABS_OP
);
878 assemble_name (asm_out_file
, name
);
879 fputc ('\n', asm_out_file
);
884 /* Likewise for entries we want to record for garbage collection.
885 Garbage collection is still under development. */
888 assemble_gc_entry (name
)
891 #ifdef ASM_OUTPUT_GC_ENTRY
892 ASM_OUTPUT_GC_ENTRY (asm_out_file
, name
);
896 /* Now tell GNU LD that this is part of the static constructor set. */
897 fprintf (asm_out_file
, "%s \"___PTR_LIST__\",22,0,0,", ASM_STABS_OP
);
898 assemble_name (asm_out_file
, name
);
899 fputc ('\n', asm_out_file
);
904 /* CONSTANT_POOL_BEFORE_FUNCTION may be defined as an expression with
905 a non-zero value if the constant pool should be output before the
906 start of the function, or a zero value if the pool should output
907 after the end of the function. The default is to put it before the
910 #ifndef CONSTANT_POOL_BEFORE_FUNCTION
911 #define CONSTANT_POOL_BEFORE_FUNCTION 1
914 /* Output assembler code for the constant pool of a function and associated
915 with defining the name of the function. DECL describes the function.
916 NAME is the function's name. For the constant pool, we use the current
917 constant pool data. */
920 assemble_start_function (decl
, fnname
)
926 /* The following code does not need preprocessing in the assembler. */
930 if (CONSTANT_POOL_BEFORE_FUNCTION
)
931 output_constant_pool (fnname
, decl
);
933 #ifdef ASM_OUTPUT_SECTION_NAME
934 /* If the function is to be put in its own section and it's not in a section
935 already, indicate so. */
936 if ((flag_function_sections
937 && DECL_SECTION_NAME (decl
) == NULL_TREE
)
938 || UNIQUE_SECTION_P (decl
))
939 UNIQUE_SECTION (decl
, 0);
942 function_section (decl
);
944 /* Tell assembler to move to target machine's alignment for functions. */
945 align
= floor_log2 (FUNCTION_BOUNDARY
/ BITS_PER_UNIT
);
947 ASM_OUTPUT_ALIGN (asm_out_file
, align
);
949 #ifdef ASM_OUTPUT_FUNCTION_PREFIX
950 ASM_OUTPUT_FUNCTION_PREFIX (asm_out_file
, fnname
);
953 #ifdef SDB_DEBUGGING_INFO
954 /* Output SDB definition of the function. */
955 if (write_symbols
== SDB_DEBUG
)
956 sdbout_mark_begin_function ();
959 #ifdef DBX_DEBUGGING_INFO
960 /* Output DBX definition of the function. */
961 if (write_symbols
== DBX_DEBUG
)
962 dbxout_begin_function (decl
);
965 /* Make function name accessible from other files, if appropriate. */
967 if (TREE_PUBLIC (decl
))
969 if (!first_global_object_name
&& ! DECL_WEAK (decl
)
970 && ! DECL_ONE_ONLY (decl
))
974 STRIP_NAME_ENCODING (p
, fnname
);
975 first_global_object_name
= permalloc (strlen (p
) + 1);
976 strcpy (first_global_object_name
, p
);
979 #ifdef ASM_WEAKEN_LABEL
980 if (DECL_WEAK (decl
))
981 ASM_WEAKEN_LABEL (asm_out_file
, fnname
);
984 ASM_GLOBALIZE_LABEL (asm_out_file
, fnname
);
987 /* Do any machine/system dependent processing of the function name */
988 #ifdef ASM_DECLARE_FUNCTION_NAME
989 ASM_DECLARE_FUNCTION_NAME (asm_out_file
, fnname
, current_function_decl
);
991 /* Standard thing is just output label for the function. */
992 ASM_OUTPUT_LABEL (asm_out_file
, fnname
);
993 #endif /* ASM_DECLARE_FUNCTION_NAME */
996 /* Output assembler code associated with defining the size of the
997 function. DECL describes the function. NAME is the function's name. */
1000 assemble_end_function (decl
, fnname
)
1004 #ifdef ASM_DECLARE_FUNCTION_SIZE
1005 ASM_DECLARE_FUNCTION_SIZE (asm_out_file
, fnname
, decl
);
1007 if (! CONSTANT_POOL_BEFORE_FUNCTION
)
1009 output_constant_pool (fnname
, decl
);
1010 function_section (decl
); /* need to switch back */
1013 /* Output any constants which should appear after the function. */
1014 output_after_function_constants ();
1017 /* Assemble code to leave SIZE bytes of zeros. */
1020 assemble_zeros (size
)
1023 #ifdef ASM_NO_SKIP_IN_TEXT
1024 /* The `space' pseudo in the text section outputs nop insns rather than 0s,
1025 so we must output 0s explicitly in the text section. */
1026 if (ASM_NO_SKIP_IN_TEXT
&& in_text_section ())
1030 for (i
= 0; i
< size
- 20; i
+= 20)
1033 fprintf (asm_out_file
,
1034 "%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
);
1036 fprintf (asm_out_file
,
1037 "\tbyte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n");
1043 fprintf (asm_out_file
, "%s 0", ASM_BYTE_OP
);
1045 fprintf (asm_out_file
, "\tbyte 0");
1048 for (; i
< size
; i
++)
1049 fprintf (asm_out_file
, ",0");
1050 fprintf (asm_out_file
, "\n");
1056 ASM_OUTPUT_SKIP (asm_out_file
, size
);
1059 /* Assemble an alignment pseudo op for an ALIGN-bit boundary. */
1062 assemble_align (align
)
1065 if (align
> BITS_PER_UNIT
)
1066 ASM_OUTPUT_ALIGN (asm_out_file
, floor_log2 (align
/ BITS_PER_UNIT
));
1069 /* Assemble a string constant with the specified C string as contents. */
1072 assemble_string (p
, size
)
1079 /* If the string is very long, split it up. */
1083 int thissize
= size
- pos
;
1084 if (thissize
> maximum
)
1087 ASM_OUTPUT_ASCII (asm_out_file
, p
, thissize
);
1095 /* Assemble everything that is needed for a variable or function declaration.
1096 Not used for automatic variables, and not used for function definitions.
1097 Should not be called for variables of incomplete structure type.
1099 TOP_LEVEL is nonzero if this variable has file scope.
1100 AT_END is nonzero if this is the special handling, at end of compilation,
1101 to define things that have had only tentative definitions.
1102 DONT_OUTPUT_DATA if nonzero means don't actually output the
1103 initial value (that will be done by the caller). */
1106 assemble_variable (decl
, top_level
, at_end
, dont_output_data
)
1110 int dont_output_data
;
1112 register char *name
;
1116 enum in_section saved_in_section
;
1118 last_assemble_variable_decl
= 0;
1120 if (GET_CODE (DECL_RTL (decl
)) == REG
)
1122 /* Do output symbol info for global register variables, but do nothing
1125 if (TREE_ASM_WRITTEN (decl
))
1127 TREE_ASM_WRITTEN (decl
) = 1;
1129 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
1130 /* File-scope global variables are output here. */
1131 if ((write_symbols
== DBX_DEBUG
|| write_symbols
== XCOFF_DEBUG
)
1133 dbxout_symbol (decl
, 0);
1135 #ifdef SDB_DEBUGGING_INFO
1136 if (write_symbols
== SDB_DEBUG
&& top_level
1137 /* Leave initialized global vars for end of compilation;
1138 see comment in compile_file. */
1139 && (TREE_PUBLIC (decl
) == 0 || DECL_INITIAL (decl
) == 0))
1140 sdbout_symbol (decl
, 0);
1143 /* Don't output any DWARF debugging information for variables here.
1144 In the case of local variables, the information for them is output
1145 when we do our recursive traversal of the tree representation for
1146 the entire containing function. In the case of file-scope variables,
1147 we output information for all of them at the very end of compilation
1148 while we are doing our final traversal of the chain of file-scope
1154 /* Normally no need to say anything here for external references,
1155 since assemble_external is called by the language-specific code
1156 when a declaration is first seen. */
1158 if (DECL_EXTERNAL (decl
))
1161 /* Output no assembler code for a function declaration.
1162 Only definitions of functions output anything. */
1164 if (TREE_CODE (decl
) == FUNCTION_DECL
)
1167 /* If type was incomplete when the variable was declared,
1168 see if it is complete now. */
1170 if (DECL_SIZE (decl
) == 0)
1171 layout_decl (decl
, 0);
1173 /* Still incomplete => don't allocate it; treat the tentative defn
1174 (which is what it must have been) as an `extern' reference. */
1176 if (!dont_output_data
&& DECL_SIZE (decl
) == 0)
1178 error_with_file_and_line (DECL_SOURCE_FILE (decl
),
1179 DECL_SOURCE_LINE (decl
),
1180 "storage size of `%s' isn't known",
1181 IDENTIFIER_POINTER (DECL_NAME (decl
)));
1182 TREE_ASM_WRITTEN (decl
) = 1;
1186 /* The first declaration of a variable that comes through this function
1187 decides whether it is global (in C, has external linkage)
1188 or local (in C, has internal linkage). So do nothing more
1189 if this function has already run. */
1191 if (TREE_ASM_WRITTEN (decl
))
1194 TREE_ASM_WRITTEN (decl
) = 1;
1198 if (! dont_output_data
)
1202 if (TREE_CODE (DECL_SIZE (decl
)) != INTEGER_CST
)
1205 /* This is better than explicit arithmetic, since it avoids overflow. */
1206 size_tree
= size_binop (CEIL_DIV_EXPR
,
1207 DECL_SIZE (decl
), size_int (BITS_PER_UNIT
));
1209 size
= TREE_INT_CST_LOW (size_tree
);
1210 if (TREE_INT_CST_HIGH (size_tree
) != 0
1211 || size
!= TREE_INT_CST_LOW (size_tree
))
1213 error_with_decl (decl
, "size of variable `%s' is too large");
1218 name
= XSTR (XEXP (DECL_RTL (decl
), 0), 0);
1220 if (TREE_PUBLIC (decl
) && DECL_NAME (decl
)
1221 && ! first_global_object_name
1222 && ! (DECL_COMMON (decl
) && (DECL_INITIAL (decl
) == 0
1223 || DECL_INITIAL (decl
) == error_mark_node
))
1224 && ! DECL_WEAK (decl
)
1225 && ! DECL_ONE_ONLY (decl
))
1229 STRIP_NAME_ENCODING (p
, name
);
1230 first_global_object_name
= permalloc (strlen (p
) + 1);
1231 strcpy (first_global_object_name
, p
);
1234 /* Handle uninitialized definitions. */
1236 if ((DECL_INITIAL (decl
) == 0 || DECL_INITIAL (decl
) == error_mark_node
)
1237 /* If the target can't output uninitialized but not common global data
1238 in .bss, then we have to use .data. */
1239 #if ! defined (ASM_OUTPUT_BSS) && ! defined (ASM_OUTPUT_ALIGNED_BSS)
1240 && DECL_COMMON (decl
)
1242 && ! dont_output_data
)
1244 int size
= TREE_INT_CST_LOW (size_tree
);
1247 /* Don't allocate zero bytes of common,
1248 since that means "undefined external" in the linker. */
1249 if (size
== 0) rounded
= 1;
1250 /* Round size up to multiple of BIGGEST_ALIGNMENT bits
1251 so that each uninitialized object starts on such a boundary. */
1252 rounded
+= (BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
) - 1;
1253 rounded
= (rounded
/ (BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
)
1254 * (BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
));
1256 #ifdef DBX_DEBUGGING_INFO
1257 /* File-scope global variables are output here. */
1258 if (write_symbols
== DBX_DEBUG
&& top_level
)
1259 dbxout_symbol (decl
, 0);
1261 #ifdef SDB_DEBUGGING_INFO
1262 if (write_symbols
== SDB_DEBUG
&& top_level
1263 /* Leave initialized global vars for end of compilation;
1264 see comment in compile_file. */
1265 && (TREE_PUBLIC (decl
) == 0 || DECL_INITIAL (decl
) == 0))
1266 sdbout_symbol (decl
, 0);
1269 /* Don't output any DWARF debugging information for variables here.
1270 In the case of local variables, the information for them is output
1271 when we do our recursive traversal of the tree representation for
1272 the entire containing function. In the case of file-scope variables,
1273 we output information for all of them at the very end of compilation
1274 while we are doing our final traversal of the chain of file-scope
1277 #if 0 /* ??? We should either delete this or add a comment describing what
1278 it was intended to do and why we shouldn't delete it. */
1279 if (flag_shared_data
)
1283 if (TREE_PUBLIC (decl
)
1284 #if defined (ASM_OUTPUT_BSS) || defined (ASM_OUTPUT_ALIGNED_BSS)
1285 && DECL_COMMON (decl
)
1289 #ifdef ASM_OUTPUT_SHARED_COMMON
1290 if (flag_shared_data
)
1291 ASM_OUTPUT_SHARED_COMMON (asm_out_file
, name
, size
, rounded
);
1295 #ifdef ASM_OUTPUT_ALIGNED_DECL_COMMON
1296 ASM_OUTPUT_ALIGNED_DECL_COMMON (asm_out_file
, decl
, name
, size
,
1299 #ifdef ASM_OUTPUT_ALIGNED_COMMON
1300 ASM_OUTPUT_ALIGNED_COMMON (asm_out_file
, name
, size
,
1303 ASM_OUTPUT_COMMON (asm_out_file
, name
, size
, rounded
);
1308 #if defined (ASM_OUTPUT_BSS) || defined (ASM_OUTPUT_ALIGNED_BSS)
1309 else if (TREE_PUBLIC (decl
))
1311 #ifdef ASM_OUTPUT_SHARED_BSS
1312 if (flag_shared_data
)
1313 ASM_OUTPUT_SHARED_BSS (asm_out_file
, decl
, name
, size
, rounded
);
1317 #ifdef ASM_OUTPUT_ALIGNED_BSS
1318 ASM_OUTPUT_ALIGNED_BSS (asm_out_file
, decl
, name
, size
,
1321 ASM_OUTPUT_BSS (asm_out_file
, decl
, name
, size
, rounded
);
1325 #endif /* ASM_OUTPUT_BSS || ASM_OUTPUT_ALIGNED_BSS */
1328 #ifdef ASM_OUTPUT_SHARED_LOCAL
1329 if (flag_shared_data
)
1330 ASM_OUTPUT_SHARED_LOCAL (asm_out_file
, name
, size
, rounded
);
1334 #ifdef ASM_OUTPUT_ALIGNED_DECL_LOCAL
1335 ASM_OUTPUT_ALIGNED_DECL_LOCAL (asm_out_file
, decl
, name
, size
,
1338 #ifdef ASM_OUTPUT_ALIGNED_LOCAL
1339 ASM_OUTPUT_ALIGNED_LOCAL (asm_out_file
, name
, size
,
1342 ASM_OUTPUT_LOCAL (asm_out_file
, name
, size
, rounded
);
1350 /* Handle initialized definitions.
1351 Also handle uninitialized global definitions if -fno-common and the
1352 target doesn't support ASM_OUTPUT_BSS. */
1354 /* First make the assembler name(s) global if appropriate. */
1355 if (TREE_PUBLIC (decl
) && DECL_NAME (decl
))
1357 #ifdef ASM_WEAKEN_LABEL
1358 if (DECL_WEAK (decl
))
1359 ASM_WEAKEN_LABEL (asm_out_file
, name
);
1362 ASM_GLOBALIZE_LABEL (asm_out_file
, name
);
1365 for (d
= equivalents
; d
; d
= TREE_CHAIN (d
))
1367 tree e
= TREE_VALUE (d
);
1368 if (TREE_PUBLIC (e
) && DECL_NAME (e
))
1369 ASM_GLOBALIZE_LABEL (asm_out_file
,
1370 XSTR (XEXP (DECL_RTL (e
), 0), 0));
1374 /* Output any data that we will need to use the address of. */
1375 if (DECL_INITIAL (decl
) == error_mark_node
)
1376 reloc
= contains_pointers_p (TREE_TYPE (decl
));
1377 else if (DECL_INITIAL (decl
))
1378 reloc
= output_addressed_constants (DECL_INITIAL (decl
));
1380 #ifdef ASM_OUTPUT_SECTION_NAME
1381 if (UNIQUE_SECTION_P (decl
))
1382 UNIQUE_SECTION (decl
, reloc
);
1385 /* Switch to the appropriate section. */
1386 variable_section (decl
, reloc
);
1388 /* dbxout.c needs to know this. */
1389 if (in_text_section ())
1390 DECL_IN_TEXT_SECTION (decl
) = 1;
1392 /* Record current section so we can restore it if dbxout.c clobbers it. */
1393 saved_in_section
= in_section
;
1395 /* Output the dbx info now that we have chosen the section. */
1397 #ifdef DBX_DEBUGGING_INFO
1398 /* File-scope global variables are output here. */
1399 if (write_symbols
== DBX_DEBUG
&& top_level
)
1400 dbxout_symbol (decl
, 0);
1402 #ifdef SDB_DEBUGGING_INFO
1403 if (write_symbols
== SDB_DEBUG
&& top_level
1404 /* Leave initialized global vars for end of compilation;
1405 see comment in compile_file. */
1406 && (TREE_PUBLIC (decl
) == 0 || DECL_INITIAL (decl
) == 0))
1407 sdbout_symbol (decl
, 0);
1410 /* Don't output any DWARF debugging information for variables here.
1411 In the case of local variables, the information for them is output
1412 when we do our recursive traversal of the tree representation for
1413 the entire containing function. In the case of file-scope variables,
1414 we output information for all of them at the very end of compilation
1415 while we are doing our final traversal of the chain of file-scope
1418 /* If the debugging output changed sections, reselect the section
1419 that's supposed to be selected. */
1420 if (in_section
!= saved_in_section
)
1421 variable_section (decl
, reloc
);
1423 /* Compute and output the alignment of this data. */
1425 align
= DECL_ALIGN (decl
);
1426 /* In the case for initialing an array whose length isn't specified,
1427 where we have not yet been able to do the layout,
1428 figure out the proper alignment now. */
1429 if (dont_output_data
&& DECL_SIZE (decl
) == 0
1430 && TREE_CODE (TREE_TYPE (decl
)) == ARRAY_TYPE
)
1431 align
= MAX (align
, TYPE_ALIGN (TREE_TYPE (TREE_TYPE (decl
))));
1433 /* Some object file formats have a maximum alignment which they support.
1434 In particular, a.out format supports a maximum alignment of 4. */
1435 #ifndef MAX_OFILE_ALIGNMENT
1436 #define MAX_OFILE_ALIGNMENT BIGGEST_ALIGNMENT
1438 if (align
> MAX_OFILE_ALIGNMENT
)
1440 warning_with_decl (decl
,
1441 "alignment of `%s' is greater than maximum object file alignment");
1442 align
= MAX_OFILE_ALIGNMENT
;
1444 #ifdef DATA_ALIGNMENT
1445 /* On some machines, it is good to increase alignment sometimes. */
1446 align
= DATA_ALIGNMENT (TREE_TYPE (decl
), align
);
1448 #ifdef CONSTANT_ALIGNMENT
1449 if (DECL_INITIAL (decl
))
1450 align
= CONSTANT_ALIGNMENT (DECL_INITIAL (decl
), align
);
1453 /* Reset the alignment in case we have made it tighter, so we can benefit
1454 from it in get_pointer_alignment. */
1455 DECL_ALIGN (decl
) = align
;
1457 if (align
> BITS_PER_UNIT
)
1458 ASM_OUTPUT_ALIGN (asm_out_file
, floor_log2 (align
/ BITS_PER_UNIT
));
1460 /* Do any machine/system dependent processing of the object. */
1461 #ifdef ASM_DECLARE_OBJECT_NAME
1462 last_assemble_variable_decl
= decl
;
1463 ASM_DECLARE_OBJECT_NAME (asm_out_file
, name
, decl
);
1465 /* Standard thing is just output label for the object. */
1466 ASM_OUTPUT_LABEL (asm_out_file
, name
);
1467 #endif /* ASM_DECLARE_OBJECT_NAME */
1469 if (!dont_output_data
)
1471 if (DECL_INITIAL (decl
))
1472 /* Output the actual data. */
1473 output_constant (DECL_INITIAL (decl
), TREE_INT_CST_LOW (size_tree
));
1475 /* Leave space for it. */
1476 assemble_zeros (TREE_INT_CST_LOW (size_tree
));
1480 #ifdef XCOFF_DEBUGGING_INFO
1481 /* Unfortunately, the IBM assembler cannot handle stabx before the actual
1482 declaration. When something like ".stabx "aa:S-2",aa,133,0" is emitted
1483 and `aa' hasn't been output yet, the assembler generates a stab entry with
1484 a value of zero, in addition to creating an unnecessary external entry
1485 for `aa'. Hence, we must postpone dbxout_symbol to here at the end. */
1487 /* File-scope global variables are output here. */
1488 if (write_symbols
== XCOFF_DEBUG
&& top_level
)
1490 saved_in_section
= in_section
;
1492 dbxout_symbol (decl
, 0);
1494 if (in_section
!= saved_in_section
)
1495 variable_section (decl
, reloc
);
1498 /* There must be a statement after a label. */
1503 /* Return 1 if type TYPE contains any pointers. */
1506 contains_pointers_p (type
)
1509 switch (TREE_CODE (type
))
1512 case REFERENCE_TYPE
:
1513 /* I'm not sure whether OFFSET_TYPE needs this treatment,
1514 so I'll play safe and return 1. */
1520 case QUAL_UNION_TYPE
:
1523 /* For a type that has fields, see if the fields have pointers. */
1524 for (fields
= TYPE_FIELDS (type
); fields
; fields
= TREE_CHAIN (fields
))
1525 if (TREE_CODE (fields
) == FIELD_DECL
1526 && contains_pointers_p (TREE_TYPE (fields
)))
1532 /* An array type contains pointers if its element type does. */
1533 return contains_pointers_p (TREE_TYPE (type
));
1540 /* Output something to declare an external symbol to the assembler.
1541 (Most assemblers don't need this, so we normally output nothing.)
1542 Do nothing if DECL is not external. */
1545 assemble_external (decl
)
1548 #ifdef ASM_OUTPUT_EXTERNAL
1549 if (TREE_CODE_CLASS (TREE_CODE (decl
)) == 'd'
1550 && DECL_EXTERNAL (decl
) && TREE_PUBLIC (decl
))
1552 rtx rtl
= DECL_RTL (decl
);
1554 if (GET_CODE (rtl
) == MEM
&& GET_CODE (XEXP (rtl
, 0)) == SYMBOL_REF
1555 && ! SYMBOL_REF_USED (XEXP (rtl
, 0)))
1557 /* Some systems do require some output. */
1558 SYMBOL_REF_USED (XEXP (rtl
, 0)) = 1;
1559 ASM_OUTPUT_EXTERNAL (asm_out_file
, decl
, XSTR (XEXP (rtl
, 0), 0));
1565 /* Similar, for calling a library function FUN. */
1568 assemble_external_libcall (fun
)
1571 #ifdef ASM_OUTPUT_EXTERNAL_LIBCALL
1572 /* Declare library function name external when first used, if nec. */
1573 if (! SYMBOL_REF_USED (fun
))
1575 SYMBOL_REF_USED (fun
) = 1;
1576 ASM_OUTPUT_EXTERNAL_LIBCALL (asm_out_file
, fun
);
1581 /* Declare the label NAME global. */
1584 assemble_global (name
)
1587 ASM_GLOBALIZE_LABEL (asm_out_file
, name
);
1590 /* Assemble a label named NAME. */
1593 assemble_label (name
)
1596 ASM_OUTPUT_LABEL (asm_out_file
, name
);
1599 /* Output to FILE a reference to the assembler name of a C-level name NAME.
1600 If NAME starts with a *, the rest of NAME is output verbatim.
1601 Otherwise NAME is transformed in an implementation-defined way
1602 (usually by the addition of an underscore).
1603 Many macros in the tm file are defined to call this function. */
1606 assemble_name (file
, name
)
1613 STRIP_NAME_ENCODING (real_name
, name
);
1614 if (flag_prefix_function_name
1615 && ! bcmp (real_name
, CHKR_PREFIX
, CHKR_PREFIX_SIZE
))
1616 real_name
= real_name
+ CHKR_PREFIX_SIZE
;
1618 id
= maybe_get_identifier (real_name
);
1620 TREE_SYMBOL_REFERENCED (id
) = 1;
1623 fputs (&name
[1], file
);
1625 ASM_OUTPUT_LABELREF (file
, name
);
1628 /* Allocate SIZE bytes writable static space with a gensym name
1629 and return an RTX to refer to its address. */
1632 assemble_static_space (size
)
1638 /* Round size up to multiple of BIGGEST_ALIGNMENT bits
1639 so that each uninitialized object starts on such a boundary. */
1640 int rounded
= ((size
+ (BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
) - 1)
1641 / (BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
)
1642 * (BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
));
1645 if (flag_shared_data
)
1649 ASM_GENERATE_INTERNAL_LABEL (name
, "LF", const_labelno
);
1652 namestring
= (char *) obstack_alloc (saveable_obstack
,
1654 strcpy (namestring
, name
);
1656 x
= gen_rtx_SYMBOL_REF (Pmode
, namestring
);
1658 #ifdef ASM_OUTPUT_ALIGNED_DECL_LOCAL
1659 ASM_OUTPUT_ALIGNED_DECL_LOCAL (asm_out_file
, NULL_TREE
, name
, size
,
1662 #ifdef ASM_OUTPUT_ALIGNED_LOCAL
1663 ASM_OUTPUT_ALIGNED_LOCAL (asm_out_file
, name
, size
, BIGGEST_ALIGNMENT
);
1665 ASM_OUTPUT_LOCAL (asm_out_file
, name
, size
, rounded
);
1671 /* Assemble the static constant template for function entry trampolines.
1672 This is done at most once per compilation.
1673 Returns an RTX for the address of the template. */
1675 #ifdef TRAMPOLINE_TEMPLATE
1677 assemble_trampoline_template ()
1683 /* By default, put trampoline templates in read-only data section. */
1685 #ifdef TRAMPOLINE_SECTION
1686 TRAMPOLINE_SECTION ();
1688 readonly_data_section ();
1691 /* Write the assembler code to define one. */
1692 align
= floor_log2 (TRAMPOLINE_ALIGNMENT
/ BITS_PER_UNIT
);
1694 ASM_OUTPUT_ALIGN (asm_out_file
, align
);
1696 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, "LTRAMP", 0);
1697 TRAMPOLINE_TEMPLATE (asm_out_file
);
1699 /* Record the rtl to refer to it. */
1700 ASM_GENERATE_INTERNAL_LABEL (label
, "LTRAMP", 0);
1702 = (char *) obstack_copy0 (&permanent_obstack
, label
, strlen (label
));
1703 return gen_rtx_SYMBOL_REF (Pmode
, name
);
1707 /* Assemble the integer constant X into an object of SIZE bytes.
1708 X must be either a CONST_INT or CONST_DOUBLE.
1710 Return 1 if we were able to output the constant, otherwise 0. If FORCE is
1711 non-zero, abort if we can't output the constant. */
1714 assemble_integer (x
, size
, force
)
1719 /* First try to use the standard 1, 2, 4, 8, and 16 byte
1720 ASM_OUTPUT... macros. */
1724 #ifdef ASM_OUTPUT_CHAR
1726 ASM_OUTPUT_CHAR (asm_out_file
, x
);
1730 #ifdef ASM_OUTPUT_SHORT
1732 ASM_OUTPUT_SHORT (asm_out_file
, x
);
1736 #ifdef ASM_OUTPUT_INT
1738 ASM_OUTPUT_INT (asm_out_file
, x
);
1742 #ifdef ASM_OUTPUT_DOUBLE_INT
1744 ASM_OUTPUT_DOUBLE_INT (asm_out_file
, x
);
1748 #ifdef ASM_OUTPUT_QUADRUPLE_INT
1750 ASM_OUTPUT_QUADRUPLE_INT (asm_out_file
, x
);
1755 /* If we couldn't do it that way, there are two other possibilities: First,
1756 if the machine can output an explicit byte and this is a 1 byte constant,
1757 we can use ASM_OUTPUT_BYTE. */
1759 #ifdef ASM_OUTPUT_BYTE
1760 if (size
== 1 && GET_CODE (x
) == CONST_INT
)
1762 ASM_OUTPUT_BYTE (asm_out_file
, INTVAL (x
));
1767 /* Finally, if SIZE is larger than a single word, try to output the constant
1768 one word at a time. */
1770 if (size
> UNITS_PER_WORD
)
1773 enum machine_mode mode
1774 = mode_for_size (size
* BITS_PER_UNIT
, MODE_INT
, 0);
1777 for (i
= 0; i
< size
/ UNITS_PER_WORD
; i
++)
1779 word
= operand_subword (x
, i
, 0, mode
);
1784 if (! assemble_integer (word
, UNITS_PER_WORD
, 0))
1788 if (i
== size
/ UNITS_PER_WORD
)
1790 /* If we output at least one word and then could not finish,
1791 there is no valid way to continue. */
1802 /* Assemble the floating-point constant D into an object of size MODE. */
1805 assemble_real (d
, mode
)
1807 enum machine_mode mode
;
1809 jmp_buf output_constant_handler
;
1811 if (setjmp (output_constant_handler
))
1813 error ("floating point trap outputting a constant");
1814 #ifdef REAL_IS_NOT_DOUBLE
1815 bzero ((char *) &d
, sizeof d
);
1822 set_float_handler (output_constant_handler
);
1826 #ifdef ASM_OUTPUT_BYTE_FLOAT
1828 ASM_OUTPUT_BYTE_FLOAT (asm_out_file
, d
);
1831 #ifdef ASM_OUTPUT_SHORT_FLOAT
1833 ASM_OUTPUT_SHORT_FLOAT (asm_out_file
, d
);
1836 #ifdef ASM_OUTPUT_THREE_QUARTER_FLOAT
1838 ASM_OUTPUT_THREE_QUARTER_FLOAT (asm_out_file
, d
);
1841 #ifdef ASM_OUTPUT_FLOAT
1843 ASM_OUTPUT_FLOAT (asm_out_file
, d
);
1847 #ifdef ASM_OUTPUT_DOUBLE
1849 ASM_OUTPUT_DOUBLE (asm_out_file
, d
);
1853 #ifdef ASM_OUTPUT_LONG_DOUBLE
1856 ASM_OUTPUT_LONG_DOUBLE (asm_out_file
, d
);
1864 set_float_handler (NULL_PTR
);
1867 /* Here we combine duplicate floating constants to make
1868 CONST_DOUBLE rtx's, and force those out to memory when necessary. */
1870 /* Chain of all CONST_DOUBLE rtx's constructed for the current function.
1871 They are chained through the CONST_DOUBLE_CHAIN.
1872 A CONST_DOUBLE rtx has CONST_DOUBLE_MEM != cc0_rtx iff it is on this chain.
1873 In that case, CONST_DOUBLE_MEM is either a MEM,
1874 or const0_rtx if no MEM has been made for this CONST_DOUBLE yet.
1876 (CONST_DOUBLE_MEM is used only for top-level functions.
1877 See force_const_mem for explanation.) */
1879 static rtx const_double_chain
;
1881 /* Return a CONST_DOUBLE or CONST_INT for a value specified as a pair of ints.
1882 For an integer, I0 is the low-order word and I1 is the high-order word.
1883 For a real number, I0 is the word with the low address
1884 and I1 is the word with the high address. */
1887 immed_double_const (i0
, i1
, mode
)
1888 HOST_WIDE_INT i0
, i1
;
1889 enum machine_mode mode
;
1893 if (GET_MODE_CLASS (mode
) == MODE_INT
1894 || GET_MODE_CLASS (mode
) == MODE_PARTIAL_INT
)
1896 /* We clear out all bits that don't belong in MODE, unless they and our
1897 sign bit are all one. So we get either a reasonable negative value
1898 or a reasonable unsigned value for this mode. */
1899 int width
= GET_MODE_BITSIZE (mode
);
1900 if (width
< HOST_BITS_PER_WIDE_INT
1901 && ((i0
& ((HOST_WIDE_INT
) (-1) << (width
- 1)))
1902 != ((HOST_WIDE_INT
) (-1) << (width
- 1))))
1903 i0
&= ((HOST_WIDE_INT
) 1 << width
) - 1, i1
= 0;
1904 else if (width
== HOST_BITS_PER_WIDE_INT
1905 && ! (i1
== ~0 && i0
< 0))
1907 else if (width
> 2 * HOST_BITS_PER_WIDE_INT
)
1908 /* We cannot represent this value as a constant. */
1911 /* If this would be an entire word for the target, but is not for
1912 the host, then sign-extend on the host so that the number will look
1913 the same way on the host that it would on the target.
1915 For example, when building a 64 bit alpha hosted 32 bit sparc
1916 targeted compiler, then we want the 32 bit unsigned value -1 to be
1917 represented as a 64 bit value -1, and not as 0x00000000ffffffff.
1918 The later confuses the sparc backend. */
1920 if (BITS_PER_WORD
< HOST_BITS_PER_WIDE_INT
&& BITS_PER_WORD
== width
1921 && (i0
& ((HOST_WIDE_INT
) 1 << (width
- 1))))
1922 i0
|= ((HOST_WIDE_INT
) (-1) << width
);
1924 /* If MODE fits within HOST_BITS_PER_WIDE_INT, always use a CONST_INT.
1926 ??? Strictly speaking, this is wrong if we create a CONST_INT
1927 for a large unsigned constant with the size of MODE being
1928 HOST_BITS_PER_WIDE_INT and later try to interpret that constant in a
1929 wider mode. In that case we will mis-interpret it as a negative
1932 Unfortunately, the only alternative is to make a CONST_DOUBLE
1933 for any constant in any mode if it is an unsigned constant larger
1934 than the maximum signed integer in an int on the host. However,
1935 doing this will break everyone that always expects to see a CONST_INT
1936 for SImode and smaller.
1938 We have always been making CONST_INTs in this case, so nothing new
1941 if (width
<= HOST_BITS_PER_WIDE_INT
)
1942 i1
= (i0
< 0) ? ~(HOST_WIDE_INT
) 0 : 0;
1944 /* If this integer fits in one word, return a CONST_INT. */
1945 if ((i1
== 0 && i0
>= 0)
1946 || (i1
== ~0 && i0
< 0))
1947 return GEN_INT (i0
);
1949 /* We use VOIDmode for integers. */
1953 /* Search the chain for an existing CONST_DOUBLE with the right value.
1954 If one is found, return it. */
1956 for (r
= const_double_chain
; r
; r
= CONST_DOUBLE_CHAIN (r
))
1957 if (CONST_DOUBLE_LOW (r
) == i0
&& CONST_DOUBLE_HIGH (r
) == i1
1958 && GET_MODE (r
) == mode
)
1961 /* No; make a new one and add it to the chain.
1963 We may be called by an optimizer which may be discarding any memory
1964 allocated during its processing (such as combine and loop). However,
1965 we will be leaving this constant on the chain, so we cannot tolerate
1966 freed memory. So switch to saveable_obstack for this allocation
1967 and then switch back if we were in current_obstack. */
1969 push_obstacks_nochange ();
1970 rtl_in_saveable_obstack ();
1971 r
= gen_rtx_CONST_DOUBLE (mode
, NULL_RTX
, i0
, i1
);
1974 /* Don't touch const_double_chain in nested function; see force_const_mem.
1975 Also, don't touch it if not inside any function. */
1976 if (outer_function_chain
== 0 && current_function_decl
!= 0)
1978 CONST_DOUBLE_CHAIN (r
) = const_double_chain
;
1979 const_double_chain
= r
;
1982 /* Store const0_rtx in mem-slot since this CONST_DOUBLE is on the chain.
1983 Actual use of mem-slot is only through force_const_mem. */
1985 CONST_DOUBLE_MEM (r
) = const0_rtx
;
1990 /* Return a CONST_DOUBLE for a specified `double' value
1991 and machine mode. */
1994 immed_real_const_1 (d
, mode
)
1996 enum machine_mode mode
;
1998 union real_extract u
;
2001 /* Get the desired `double' value as a sequence of ints
2002 since that is how they are stored in a CONST_DOUBLE. */
2006 /* Detect special cases. */
2008 if (REAL_VALUES_IDENTICAL (dconst0
, d
))
2009 return CONST0_RTX (mode
);
2010 /* Check for NaN first, because some ports (specifically the i386) do not
2011 emit correct ieee-fp code by default, and thus will generate a core
2012 dump here if we pass a NaN to REAL_VALUES_EQUAL and if REAL_VALUES_EQUAL
2013 does a floating point comparison. */
2014 else if (! REAL_VALUE_ISNAN (d
) && REAL_VALUES_EQUAL (dconst1
, d
))
2015 return CONST1_RTX (mode
);
2017 if (sizeof u
== 2 * sizeof (HOST_WIDE_INT
))
2018 return immed_double_const (u
.i
[0], u
.i
[1], mode
);
2020 /* The rest of this function handles the case where
2021 a float value requires more than 2 ints of space.
2022 It will be deleted as dead code on machines that don't need it. */
2024 /* Search the chain for an existing CONST_DOUBLE with the right value.
2025 If one is found, return it. */
2027 for (r
= const_double_chain
; r
; r
= CONST_DOUBLE_CHAIN (r
))
2028 if (! bcmp ((char *) &CONST_DOUBLE_LOW (r
), (char *) &u
, sizeof u
)
2029 && GET_MODE (r
) == mode
)
2032 /* No; make a new one and add it to the chain.
2034 We may be called by an optimizer which may be discarding any memory
2035 allocated during its processing (such as combine and loop). However,
2036 we will be leaving this constant on the chain, so we cannot tolerate
2037 freed memory. So switch to saveable_obstack for this allocation
2038 and then switch back if we were in current_obstack. */
2040 push_obstacks_nochange ();
2041 rtl_in_saveable_obstack ();
2042 r
= rtx_alloc (CONST_DOUBLE
);
2044 bcopy ((char *) &u
, (char *) &CONST_DOUBLE_LOW (r
), sizeof u
);
2047 /* Don't touch const_double_chain in nested function; see force_const_mem.
2048 Also, don't touch it if not inside any function. */
2049 if (outer_function_chain
== 0 && current_function_decl
!= 0)
2051 CONST_DOUBLE_CHAIN (r
) = const_double_chain
;
2052 const_double_chain
= r
;
2055 /* Store const0_rtx in CONST_DOUBLE_MEM since this CONST_DOUBLE is on the
2056 chain, but has not been allocated memory. Actual use of CONST_DOUBLE_MEM
2057 is only through force_const_mem. */
2059 CONST_DOUBLE_MEM (r
) = const0_rtx
;
2064 /* Return a CONST_DOUBLE rtx for a value specified by EXP,
2065 which must be a REAL_CST tree node. */
2068 immed_real_const (exp
)
2071 return immed_real_const_1 (TREE_REAL_CST (exp
), TYPE_MODE (TREE_TYPE (exp
)));
2074 /* At the end of a function, forget the memory-constants
2075 previously made for CONST_DOUBLEs. Mark them as not on real_constant_chain.
2076 Also clear out real_constant_chain and clear out all the chain-pointers. */
2079 clear_const_double_mem ()
2081 register rtx r
, next
;
2083 /* Don't touch CONST_DOUBLE_MEM for nested functions.
2084 See force_const_mem for explanation. */
2085 if (outer_function_chain
!= 0)
2088 for (r
= const_double_chain
; r
; r
= next
)
2090 next
= CONST_DOUBLE_CHAIN (r
);
2091 CONST_DOUBLE_CHAIN (r
) = 0;
2092 CONST_DOUBLE_MEM (r
) = cc0_rtx
;
2094 const_double_chain
= 0;
2097 /* Given an expression EXP with a constant value,
2098 reduce it to the sum of an assembler symbol and an integer.
2099 Store them both in the structure *VALUE.
2100 Abort if EXP does not reduce. */
2105 HOST_WIDE_INT offset
;
2109 decode_addr_const (exp
, value
)
2111 struct addr_const
*value
;
2113 register tree target
= TREE_OPERAND (exp
, 0);
2114 register int offset
= 0;
2119 if (TREE_CODE (target
) == COMPONENT_REF
2120 && (TREE_CODE (DECL_FIELD_BITPOS (TREE_OPERAND (target
, 1)))
2123 offset
+= TREE_INT_CST_LOW (DECL_FIELD_BITPOS (TREE_OPERAND (target
, 1))) / BITS_PER_UNIT
;
2124 target
= TREE_OPERAND (target
, 0);
2126 else if (TREE_CODE (target
) == ARRAY_REF
)
2128 if (TREE_CODE (TREE_OPERAND (target
, 1)) != INTEGER_CST
2129 || TREE_CODE (TYPE_SIZE (TREE_TYPE (target
))) != INTEGER_CST
)
2131 offset
+= ((TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (target
)))
2132 * TREE_INT_CST_LOW (TREE_OPERAND (target
, 1)))
2134 target
= TREE_OPERAND (target
, 0);
2140 switch (TREE_CODE (target
))
2144 x
= DECL_RTL (target
);
2148 x
= gen_rtx_MEM (FUNCTION_MODE
,
2149 gen_rtx_LABEL_REF (VOIDmode
,
2150 label_rtx (TREE_OPERAND (exp
, 0))));
2158 x
= TREE_CST_RTL (target
);
2165 if (GET_CODE (x
) != MEM
)
2170 value
->offset
= offset
;
2173 /* Uniquize all constants that appear in memory.
2174 Each constant in memory thus far output is recorded
2175 in `const_hash_table' with a `struct constant_descriptor'
2176 that contains a polish representation of the value of
2179 We cannot store the trees in the hash table
2180 because the trees may be temporary. */
2182 struct constant_descriptor
2184 struct constant_descriptor
*next
;
2190 #define MAX_HASH_TABLE 1009
2191 static struct constant_descriptor
*const_hash_table
[MAX_HASH_TABLE
];
2193 /* Compute a hash code for a constant expression. */
2200 register int len
, hi
, i
;
2201 register enum tree_code code
= TREE_CODE (exp
);
2203 /* Either set P and LEN to the address and len of something to hash and
2204 exit the switch or return a value. */
2209 p
= (char *) &TREE_INT_CST_LOW (exp
);
2210 len
= 2 * sizeof TREE_INT_CST_LOW (exp
);
2214 p
= (char *) &TREE_REAL_CST (exp
);
2215 len
= sizeof TREE_REAL_CST (exp
);
2219 p
= TREE_STRING_POINTER (exp
);
2220 len
= TREE_STRING_LENGTH (exp
);
2224 return (const_hash (TREE_REALPART (exp
)) * 5
2225 + const_hash (TREE_IMAGPART (exp
)));
2228 if (TREE_CODE (TREE_TYPE (exp
)) == SET_TYPE
)
2230 len
= int_size_in_bytes (TREE_TYPE (exp
));
2231 p
= (char *) alloca (len
);
2232 get_set_constructor_bytes (exp
, (unsigned char *) p
, len
);
2239 /* For record type, include the type in the hashing.
2240 We do not do so for array types
2241 because (1) the sizes of the elements are sufficient
2242 and (2) distinct array types can have the same constructor.
2243 Instead, we include the array size because the constructor could
2245 if (TREE_CODE (TREE_TYPE (exp
)) == RECORD_TYPE
)
2246 hi
= ((unsigned long) TREE_TYPE (exp
) & ((1 << HASHBITS
) - 1))
2249 hi
= ((5 + int_size_in_bytes (TREE_TYPE (exp
)))
2250 & ((1 << HASHBITS
) - 1)) % MAX_HASH_TABLE
;
2252 for (link
= CONSTRUCTOR_ELTS (exp
); link
; link
= TREE_CHAIN (link
))
2253 if (TREE_VALUE (link
))
2255 = (hi
* 603 + const_hash (TREE_VALUE (link
))) % MAX_HASH_TABLE
;
2262 struct addr_const value
;
2264 decode_addr_const (exp
, &value
);
2265 if (GET_CODE (value
.base
) == SYMBOL_REF
)
2267 /* Don't hash the address of the SYMBOL_REF;
2268 only use the offset and the symbol name. */
2270 p
= XSTR (value
.base
, 0);
2271 for (i
= 0; p
[i
] != 0; i
++)
2272 hi
= ((hi
* 613) + (unsigned) (p
[i
]));
2274 else if (GET_CODE (value
.base
) == LABEL_REF
)
2275 hi
= value
.offset
+ CODE_LABEL_NUMBER (XEXP (value
.base
, 0)) * 13;
2277 hi
&= (1 << HASHBITS
) - 1;
2278 hi
%= MAX_HASH_TABLE
;
2284 return (const_hash (TREE_OPERAND (exp
, 0)) * 9
2285 + const_hash (TREE_OPERAND (exp
, 1)));
2289 case NON_LVALUE_EXPR
:
2290 return const_hash (TREE_OPERAND (exp
, 0)) * 7 + 2;
2296 /* Compute hashing function */
2298 for (i
= 0; i
< len
; i
++)
2299 hi
= ((hi
* 613) + (unsigned) (p
[i
]));
2301 hi
&= (1 << HASHBITS
) - 1;
2302 hi
%= MAX_HASH_TABLE
;
2306 /* Compare a constant expression EXP with a constant-descriptor DESC.
2307 Return 1 if DESC describes a constant with the same value as EXP. */
2310 compare_constant (exp
, desc
)
2312 struct constant_descriptor
*desc
;
2314 return 0 != compare_constant_1 (exp
, desc
->contents
);
2317 /* Compare constant expression EXP with a substring P of a constant descriptor.
2318 If they match, return a pointer to the end of the substring matched.
2319 If they do not match, return 0.
2321 Since descriptors are written in polish prefix notation,
2322 this function can be used recursively to test one operand of EXP
2323 against a subdescriptor, and if it succeeds it returns the
2324 address of the subdescriptor for the next operand. */
2327 compare_constant_1 (exp
, p
)
2331 register char *strp
;
2333 register enum tree_code code
= TREE_CODE (exp
);
2335 if (code
!= (enum tree_code
) *p
++)
2338 /* Either set STRP, P and LEN to pointers and length to compare and exit the
2339 switch, or return the result of the comparison. */
2344 /* Integer constants are the same only if the same width of type. */
2345 if (*p
++ != TYPE_PRECISION (TREE_TYPE (exp
)))
2348 strp
= (char *) &TREE_INT_CST_LOW (exp
);
2349 len
= 2 * sizeof TREE_INT_CST_LOW (exp
);
2353 /* Real constants are the same only if the same width of type. */
2354 if (*p
++ != TYPE_PRECISION (TREE_TYPE (exp
)))
2357 strp
= (char *) &TREE_REAL_CST (exp
);
2358 len
= sizeof TREE_REAL_CST (exp
);
2362 if (flag_writable_strings
)
2365 if (*p
++ != TYPE_MODE (TREE_TYPE (exp
)))
2368 strp
= TREE_STRING_POINTER (exp
);
2369 len
= TREE_STRING_LENGTH (exp
);
2370 if (bcmp ((char *) &TREE_STRING_LENGTH (exp
), p
,
2371 sizeof TREE_STRING_LENGTH (exp
)))
2374 p
+= sizeof TREE_STRING_LENGTH (exp
);
2378 p
= compare_constant_1 (TREE_REALPART (exp
), p
);
2382 return compare_constant_1 (TREE_IMAGPART (exp
), p
);
2385 if (TREE_CODE (TREE_TYPE (exp
)) == SET_TYPE
)
2387 int xlen
= len
= int_size_in_bytes (TREE_TYPE (exp
));
2389 strp
= (char *) alloca (len
);
2390 get_set_constructor_bytes (exp
, (unsigned char *) strp
, len
);
2391 if (bcmp ((char *) &xlen
, p
, sizeof xlen
))
2400 int length
= list_length (CONSTRUCTOR_ELTS (exp
));
2403 if (bcmp ((char *) &length
, p
, sizeof length
))
2408 /* For record constructors, insist that the types match.
2409 For arrays, just verify both constructors are for arrays. */
2410 if (TREE_CODE (TREE_TYPE (exp
)) == RECORD_TYPE
)
2411 type
= TREE_TYPE (exp
);
2415 if (bcmp ((char *) &type
, p
, sizeof type
))
2420 /* For arrays, insist that the size in bytes match. */
2421 if (TREE_CODE (TREE_TYPE (exp
)) == ARRAY_TYPE
)
2423 int size
= int_size_in_bytes (TREE_TYPE (exp
));
2424 if (bcmp ((char *) &size
, p
, sizeof size
))
2430 for (link
= CONSTRUCTOR_ELTS (exp
); link
; link
= TREE_CHAIN (link
))
2432 if (TREE_VALUE (link
))
2434 if ((p
= compare_constant_1 (TREE_VALUE (link
), p
)) == 0)
2441 if (bcmp ((char *) &zero
, p
, sizeof zero
))
2453 struct addr_const value
;
2455 decode_addr_const (exp
, &value
);
2456 strp
= (char *) &value
.offset
;
2457 len
= sizeof value
.offset
;
2458 /* Compare the offset. */
2460 if (*p
++ != *strp
++)
2463 /* Compare symbol name. */
2464 strp
= XSTR (value
.base
, 0);
2465 len
= strlen (strp
) + 1;
2471 p
= compare_constant_1 (TREE_OPERAND (exp
, 0), p
);
2475 return compare_constant_1 (TREE_OPERAND (exp
, 1), p
);
2479 case NON_LVALUE_EXPR
:
2480 return compare_constant_1 (TREE_OPERAND (exp
, 0), p
);
2486 /* Compare constant contents. */
2488 if (*p
++ != *strp
++)
2494 /* Construct a constant descriptor for the expression EXP.
2495 It is up to the caller to enter the descriptor in the hash table. */
2497 static struct constant_descriptor
*
2498 record_constant (exp
)
2501 struct constant_descriptor
*next
= 0;
2504 /* Make a struct constant_descriptor. The first two pointers will
2505 be filled in later. Here we just leave space for them. */
2507 obstack_grow (&permanent_obstack
, (char *) &next
, sizeof next
);
2508 obstack_grow (&permanent_obstack
, (char *) &label
, sizeof label
);
2509 record_constant_1 (exp
);
2510 return (struct constant_descriptor
*) obstack_finish (&permanent_obstack
);
2513 /* Add a description of constant expression EXP
2514 to the object growing in `permanent_obstack'.
2515 No need to return its address; the caller will get that
2516 from the obstack when the object is complete. */
2519 record_constant_1 (exp
)
2522 register char *strp
;
2524 register enum tree_code code
= TREE_CODE (exp
);
2526 obstack_1grow (&permanent_obstack
, (unsigned int) code
);
2531 obstack_1grow (&permanent_obstack
, TYPE_PRECISION (TREE_TYPE (exp
)));
2532 strp
= (char *) &TREE_INT_CST_LOW (exp
);
2533 len
= 2 * sizeof TREE_INT_CST_LOW (exp
);
2537 obstack_1grow (&permanent_obstack
, TYPE_PRECISION (TREE_TYPE (exp
)));
2538 strp
= (char *) &TREE_REAL_CST (exp
);
2539 len
= sizeof TREE_REAL_CST (exp
);
2543 if (flag_writable_strings
)
2546 obstack_1grow (&permanent_obstack
, TYPE_MODE (TREE_TYPE (exp
)));
2547 strp
= TREE_STRING_POINTER (exp
);
2548 len
= TREE_STRING_LENGTH (exp
);
2549 obstack_grow (&permanent_obstack
, (char *) &TREE_STRING_LENGTH (exp
),
2550 sizeof TREE_STRING_LENGTH (exp
));
2554 record_constant_1 (TREE_REALPART (exp
));
2555 record_constant_1 (TREE_IMAGPART (exp
));
2559 if (TREE_CODE (TREE_TYPE (exp
)) == SET_TYPE
)
2561 int nbytes
= int_size_in_bytes (TREE_TYPE (exp
));
2562 obstack_grow (&permanent_obstack
, &nbytes
, sizeof (nbytes
));
2563 obstack_blank (&permanent_obstack
, nbytes
);
2564 get_set_constructor_bytes
2565 (exp
, (unsigned char *) permanent_obstack
.next_free
-nbytes
,
2572 int length
= list_length (CONSTRUCTOR_ELTS (exp
));
2575 obstack_grow (&permanent_obstack
, (char *) &length
, sizeof length
);
2577 /* For record constructors, insist that the types match.
2578 For arrays, just verify both constructors are for arrays. */
2579 if (TREE_CODE (TREE_TYPE (exp
)) == RECORD_TYPE
)
2580 type
= TREE_TYPE (exp
);
2583 obstack_grow (&permanent_obstack
, (char *) &type
, sizeof type
);
2585 /* For arrays, insist that the size in bytes match. */
2586 if (TREE_CODE (TREE_TYPE (exp
)) == ARRAY_TYPE
)
2588 int size
= int_size_in_bytes (TREE_TYPE (exp
));
2589 obstack_grow (&permanent_obstack
, (char *) &size
, sizeof size
);
2592 for (link
= CONSTRUCTOR_ELTS (exp
); link
; link
= TREE_CHAIN (link
))
2594 if (TREE_VALUE (link
))
2595 record_constant_1 (TREE_VALUE (link
));
2600 obstack_grow (&permanent_obstack
,
2601 (char *) &zero
, sizeof zero
);
2609 struct addr_const value
;
2611 decode_addr_const (exp
, &value
);
2612 /* Record the offset. */
2613 obstack_grow (&permanent_obstack
,
2614 (char *) &value
.offset
, sizeof value
.offset
);
2615 /* Record the symbol name. */
2616 obstack_grow (&permanent_obstack
, XSTR (value
.base
, 0),
2617 strlen (XSTR (value
.base
, 0)) + 1);
2623 record_constant_1 (TREE_OPERAND (exp
, 0));
2624 record_constant_1 (TREE_OPERAND (exp
, 1));
2629 case NON_LVALUE_EXPR
:
2630 record_constant_1 (TREE_OPERAND (exp
, 0));
2637 /* Record constant contents. */
2638 obstack_grow (&permanent_obstack
, strp
, len
);
2641 /* Record a list of constant expressions that were passed to
2642 output_constant_def but that could not be output right away. */
2644 struct deferred_constant
2646 struct deferred_constant
*next
;
2652 static struct deferred_constant
*deferred_constants
;
2654 /* Another list of constants which should be output after the
2656 static struct deferred_constant
*after_function_constants
;
2658 /* Nonzero means defer output of addressed subconstants
2659 (i.e., those for which output_constant_def is called.) */
2660 static int defer_addressed_constants_flag
;
2662 /* Start deferring output of subconstants. */
2665 defer_addressed_constants ()
2667 defer_addressed_constants_flag
++;
2670 /* Stop deferring output of subconstants,
2671 and output now all those that have been deferred. */
2674 output_deferred_addressed_constants ()
2676 struct deferred_constant
*p
, *next
;
2678 defer_addressed_constants_flag
--;
2680 if (defer_addressed_constants_flag
> 0)
2683 for (p
= deferred_constants
; p
; p
= next
)
2685 output_constant_def_contents (p
->exp
, p
->reloc
, p
->labelno
);
2690 deferred_constants
= 0;
2693 /* Output any constants which should appear after a function. */
2696 output_after_function_constants ()
2698 struct deferred_constant
*p
, *next
;
2700 for (p
= after_function_constants
; p
; p
= next
)
2702 output_constant_def_contents (p
->exp
, p
->reloc
, p
->labelno
);
2707 after_function_constants
= 0;
2710 /* Make a copy of the whole tree structure for a constant.
2711 This handles the same types of nodes that compare_constant
2712 and record_constant handle. */
2718 switch (TREE_CODE (exp
))
2721 /* For ADDR_EXPR, we do not want to copy the decl whose address
2722 is requested. We do want to copy constants though. */
2723 if (TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp
, 0))) == 'c')
2724 return build1 (TREE_CODE (exp
), TREE_TYPE (exp
),
2725 copy_constant (TREE_OPERAND (exp
, 0)));
2727 return copy_node (exp
);
2732 return copy_node (exp
);
2735 return build_complex (TREE_TYPE (exp
),
2736 copy_constant (TREE_REALPART (exp
)),
2737 copy_constant (TREE_IMAGPART (exp
)));
2741 return build (TREE_CODE (exp
), TREE_TYPE (exp
),
2742 copy_constant (TREE_OPERAND (exp
, 0)),
2743 copy_constant (TREE_OPERAND (exp
, 1)));
2747 case NON_LVALUE_EXPR
:
2748 return build1 (TREE_CODE (exp
), TREE_TYPE (exp
),
2749 copy_constant (TREE_OPERAND (exp
, 0)));
2753 tree copy
= copy_node (exp
);
2754 tree list
= copy_list (CONSTRUCTOR_ELTS (exp
));
2757 CONSTRUCTOR_ELTS (copy
) = list
;
2758 for (tail
= list
; tail
; tail
= TREE_CHAIN (tail
))
2759 TREE_VALUE (tail
) = copy_constant (TREE_VALUE (tail
));
2760 if (TREE_CODE (TREE_TYPE (exp
)) == SET_TYPE
)
2761 for (tail
= list
; tail
; tail
= TREE_CHAIN (tail
))
2762 TREE_PURPOSE (tail
) = copy_constant (TREE_PURPOSE (tail
));
2772 /* Return an rtx representing a reference to constant data in memory
2773 for the constant expression EXP.
2775 If assembler code for such a constant has already been output,
2776 return an rtx to refer to it.
2777 Otherwise, output such a constant in memory (or defer it for later)
2778 and generate an rtx for it.
2780 The TREE_CST_RTL of EXP is set up to point to that rtx.
2781 The const_hash_table records which constants already have label strings. */
2784 output_constant_def (exp
)
2788 register struct constant_descriptor
*desc
;
2794 if (TREE_CST_RTL (exp
))
2795 return TREE_CST_RTL (exp
);
2797 /* Make sure any other constants whose addresses appear in EXP
2798 are assigned label numbers. */
2800 reloc
= output_addressed_constants (exp
);
2802 /* Compute hash code of EXP. Search the descriptors for that hash code
2803 to see if any of them describes EXP. If yes, the descriptor records
2804 the label number already assigned. */
2806 hash
= const_hash (exp
) % MAX_HASH_TABLE
;
2808 for (desc
= const_hash_table
[hash
]; desc
; desc
= desc
->next
)
2809 if (compare_constant (exp
, desc
))
2811 found
= desc
->label
;
2817 /* No constant equal to EXP is known to have been output.
2818 Make a constant descriptor to enter EXP in the hash table.
2819 Assign the label number and record it in the descriptor for
2820 future calls to this function to find. */
2822 /* Create a string containing the label name, in LABEL. */
2823 ASM_GENERATE_INTERNAL_LABEL (label
, "LC", const_labelno
);
2825 desc
= record_constant (exp
);
2826 desc
->next
= const_hash_table
[hash
];
2828 = (char *) obstack_copy0 (&permanent_obstack
, label
, strlen (label
));
2829 const_hash_table
[hash
] = desc
;
2833 /* Create a string containing the label name, in LABEL. */
2834 ASM_GENERATE_INTERNAL_LABEL (label
, "LC", const_labelno
);
2837 /* We have a symbol name; construct the SYMBOL_REF and the MEM. */
2839 push_obstacks_nochange ();
2840 if (TREE_PERMANENT (exp
))
2841 end_temporary_allocation ();
2843 def
= gen_rtx_SYMBOL_REF (Pmode
, desc
->label
);
2846 = gen_rtx_MEM (TYPE_MODE (TREE_TYPE (exp
)), def
);
2847 RTX_UNCHANGING_P (TREE_CST_RTL (exp
)) = 1;
2848 if (AGGREGATE_TYPE_P (TREE_TYPE (exp
)))
2849 MEM_IN_STRUCT_P (TREE_CST_RTL (exp
)) = 1;
2853 /* Optionally set flags or add text to the name to record information
2854 such as that it is a function name. If the name is changed, the macro
2855 ASM_OUTPUT_LABELREF will have to know how to strip this information. */
2856 #ifdef ENCODE_SECTION_INFO
2857 ENCODE_SECTION_INFO (exp
);
2860 /* If this is the first time we've seen this particular constant,
2861 output it (or defer its output for later). */
2864 int after_function
= 0;
2866 #ifdef CONSTANT_AFTER_FUNCTION_P
2867 if (current_function_decl
!= 0
2868 && CONSTANT_AFTER_FUNCTION_P (exp
))
2872 if (defer_addressed_constants_flag
|| after_function
)
2874 struct deferred_constant
*p
;
2875 p
= (struct deferred_constant
*) xmalloc (sizeof (struct deferred_constant
));
2877 push_obstacks_nochange ();
2878 suspend_momentary ();
2879 p
->exp
= copy_constant (exp
);
2882 p
->labelno
= const_labelno
++;
2885 p
->next
= after_function_constants
;
2886 after_function_constants
= p
;
2890 p
->next
= deferred_constants
;
2891 deferred_constants
= p
;
2895 output_constant_def_contents (exp
, reloc
, const_labelno
++);
2898 return TREE_CST_RTL (exp
);
2901 /* Now output assembler code to define the label for EXP,
2902 and follow it with the data of EXP. */
2905 output_constant_def_contents (exp
, reloc
, labelno
)
2912 if (IN_NAMED_SECTION (exp
))
2913 named_section (exp
, NULL
, reloc
);
2916 /* First switch to text section, except for writable strings. */
2917 #ifdef SELECT_SECTION
2918 SELECT_SECTION (exp
, reloc
);
2920 if (((TREE_CODE (exp
) == STRING_CST
) && flag_writable_strings
)
2921 || (flag_pic
&& reloc
))
2924 readonly_data_section ();
2928 /* Align the location counter as required by EXP's data type. */
2929 align
= TYPE_ALIGN (TREE_TYPE (exp
));
2930 #ifdef CONSTANT_ALIGNMENT
2931 align
= CONSTANT_ALIGNMENT (exp
, align
);
2934 if (align
> BITS_PER_UNIT
)
2935 ASM_OUTPUT_ALIGN (asm_out_file
, floor_log2 (align
/ BITS_PER_UNIT
));
2937 /* Output the label itself. */
2938 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, "LC", labelno
);
2940 /* Output the value of EXP. */
2941 output_constant (exp
,
2942 (TREE_CODE (exp
) == STRING_CST
2943 ? TREE_STRING_LENGTH (exp
)
2944 : int_size_in_bytes (TREE_TYPE (exp
))));
2948 /* Similar hash facility for making memory-constants
2949 from constant rtl-expressions. It is used on RISC machines
2950 where immediate integer arguments and constant addresses are restricted
2951 so that such constants must be stored in memory.
2953 This pool of constants is reinitialized for each function
2954 so each function gets its own constants-pool that comes right before it.
2956 All structures allocated here are discarded when functions are saved for
2957 inlining, so they do not need to be allocated permanently. */
2959 #define MAX_RTX_HASH_TABLE 61
2960 static struct constant_descriptor
**const_rtx_hash_table
;
2962 /* Structure to represent sufficient information about a constant so that
2963 it can be output when the constant pool is output, so that function
2964 integration can be done, and to simplify handling on machines that reference
2965 constant pool as base+displacement. */
2967 struct pool_constant
2969 struct constant_descriptor
*desc
;
2970 struct pool_constant
*next
;
2971 enum machine_mode mode
;
2979 /* Pointers to first and last constant in pool. */
2981 static struct pool_constant
*first_pool
, *last_pool
;
2983 /* Current offset in constant pool (does not include any machine-specific
2986 static int pool_offset
;
2988 /* Structure used to maintain hash table mapping symbols used to their
2989 corresponding constants. */
2994 struct pool_constant
*pool
;
2995 struct pool_sym
*next
;
2998 static struct pool_sym
**const_rtx_sym_hash_table
;
3000 /* Hash code for a SYMBOL_REF with CONSTANT_POOL_ADDRESS_P true.
3001 The argument is XSTR (... , 0) */
3003 #define SYMHASH(LABEL) \
3004 ((((unsigned long) (LABEL)) & ((1 << HASHBITS) - 1)) % MAX_RTX_HASH_TABLE)
3006 /* Initialize constant pool hashing for next function. */
3009 init_const_rtx_hash_table ()
3011 const_rtx_hash_table
3012 = ((struct constant_descriptor
**)
3013 oballoc (MAX_RTX_HASH_TABLE
* sizeof (struct constant_descriptor
*)));
3014 const_rtx_sym_hash_table
3015 = ((struct pool_sym
**)
3016 oballoc (MAX_RTX_HASH_TABLE
* sizeof (struct pool_sym
*)));
3017 bzero ((char *) const_rtx_hash_table
,
3018 MAX_RTX_HASH_TABLE
* sizeof (struct constant_descriptor
*));
3019 bzero ((char *) const_rtx_sym_hash_table
,
3020 MAX_RTX_HASH_TABLE
* sizeof (struct pool_sym
*));
3022 first_pool
= last_pool
= 0;
3026 /* Save and restore status for a nested function. */
3029 save_varasm_status (p
, context
)
3033 p
->const_rtx_hash_table
= const_rtx_hash_table
;
3034 p
->const_rtx_sym_hash_table
= const_rtx_sym_hash_table
;
3035 p
->first_pool
= first_pool
;
3036 p
->last_pool
= last_pool
;
3037 p
->pool_offset
= pool_offset
;
3038 p
->const_double_chain
= const_double_chain
;
3040 /* If we are pushing to toplevel, we can't reuse const_double_chain. */
3041 if (context
== NULL_TREE
)
3042 const_double_chain
= 0;
3046 restore_varasm_status (p
)
3049 const_rtx_hash_table
= p
->const_rtx_hash_table
;
3050 const_rtx_sym_hash_table
= p
->const_rtx_sym_hash_table
;
3051 first_pool
= p
->first_pool
;
3052 last_pool
= p
->last_pool
;
3053 pool_offset
= p
->pool_offset
;
3054 const_double_chain
= p
->const_double_chain
;
3057 enum kind
{ RTX_DOUBLE
, RTX_INT
};
3061 #ifdef ONLY_INT_FIELDS
3062 unsigned int kind
: 16;
3063 unsigned int mode
: 16;
3065 enum kind kind
: 16;
3066 enum machine_mode mode
: 16;
3069 union real_extract du
;
3070 struct addr_const addr
;
3071 struct {HOST_WIDE_INT high
, low
;} di
;
3075 /* Express an rtx for a constant integer (perhaps symbolic)
3076 as the sum of a symbol or label plus an explicit integer.
3077 They are stored into VALUE. */
3080 decode_rtx_const (mode
, x
, value
)
3081 enum machine_mode mode
;
3083 struct rtx_const
*value
;
3085 /* Clear the whole structure, including any gaps. */
3088 int *p
= (int *) value
;
3089 int *end
= (int *) (value
+ 1);
3094 value
->kind
= RTX_INT
; /* Most usual kind. */
3097 switch (GET_CODE (x
))
3100 value
->kind
= RTX_DOUBLE
;
3101 if (GET_MODE (x
) != VOIDmode
)
3103 value
->mode
= GET_MODE (x
);
3104 bcopy ((char *) &CONST_DOUBLE_LOW (x
),
3105 (char *) &value
->un
.du
, sizeof value
->un
.du
);
3109 value
->un
.di
.low
= CONST_DOUBLE_LOW (x
);
3110 value
->un
.di
.high
= CONST_DOUBLE_HIGH (x
);
3115 value
->un
.addr
.offset
= INTVAL (x
);
3121 value
->un
.addr
.base
= x
;
3126 if (GET_CODE (x
) == PLUS
)
3128 value
->un
.addr
.base
= XEXP (x
, 0);
3129 if (GET_CODE (XEXP (x
, 1)) != CONST_INT
)
3131 value
->un
.addr
.offset
= INTVAL (XEXP (x
, 1));
3133 else if (GET_CODE (x
) == MINUS
)
3135 value
->un
.addr
.base
= XEXP (x
, 0);
3136 if (GET_CODE (XEXP (x
, 1)) != CONST_INT
)
3138 value
->un
.addr
.offset
= - INTVAL (XEXP (x
, 1));
3148 if (value
->kind
== RTX_INT
&& value
->un
.addr
.base
!= 0)
3149 switch (GET_CODE (value
->un
.addr
.base
))
3153 /* Use the string's address, not the SYMBOL_REF's address,
3154 for the sake of addresses of library routines.
3155 For a LABEL_REF, compare labels. */
3156 value
->un
.addr
.base
= XEXP (value
->un
.addr
.base
, 0);
3163 /* Given a MINUS expression, simplify it if both sides
3164 include the same symbol. */
3167 simplify_subtraction (x
)
3170 struct rtx_const val0
, val1
;
3172 decode_rtx_const (GET_MODE (x
), XEXP (x
, 0), &val0
);
3173 decode_rtx_const (GET_MODE (x
), XEXP (x
, 1), &val1
);
3175 if (val0
.un
.addr
.base
== val1
.un
.addr
.base
)
3176 return GEN_INT (val0
.un
.addr
.offset
- val1
.un
.addr
.offset
);
3180 /* Compute a hash code for a constant RTL expression. */
3183 const_hash_rtx (mode
, x
)
3184 enum machine_mode mode
;
3189 struct rtx_const value
;
3190 decode_rtx_const (mode
, x
, &value
);
3192 /* Compute hashing function */
3194 for (i
= 0; i
< sizeof value
/ sizeof (int); i
++)
3195 hi
+= ((int *) &value
)[i
];
3197 hi
&= (1 << HASHBITS
) - 1;
3198 hi
%= MAX_RTX_HASH_TABLE
;
3202 /* Compare a constant rtl object X with a constant-descriptor DESC.
3203 Return 1 if DESC describes a constant with the same value as X. */
3206 compare_constant_rtx (mode
, x
, desc
)
3207 enum machine_mode mode
;
3209 struct constant_descriptor
*desc
;
3211 register int *p
= (int *) desc
->contents
;
3214 struct rtx_const value
;
3216 decode_rtx_const (mode
, x
, &value
);
3217 strp
= (int *) &value
;
3218 len
= sizeof value
/ sizeof (int);
3220 /* Compare constant contents. */
3222 if (*p
++ != *strp
++)
3228 /* Construct a constant descriptor for the rtl-expression X.
3229 It is up to the caller to enter the descriptor in the hash table. */
3231 static struct constant_descriptor
*
3232 record_constant_rtx (mode
, x
)
3233 enum machine_mode mode
;
3236 struct constant_descriptor
*ptr
;
3238 struct rtx_const value
;
3240 decode_rtx_const (mode
, x
, &value
);
3242 /* Put these things in the saveable obstack so we can ensure it won't
3243 be freed if we are called from combine or some other phase that discards
3244 memory allocated from function_obstack (current_obstack). */
3245 obstack_grow (saveable_obstack
, &ptr
, sizeof ptr
);
3246 obstack_grow (saveable_obstack
, &label
, sizeof label
);
3248 /* Record constant contents. */
3249 obstack_grow (saveable_obstack
, &value
, sizeof value
);
3251 return (struct constant_descriptor
*) obstack_finish (saveable_obstack
);
3254 /* Given a constant rtx X, make (or find) a memory constant for its value
3255 and return a MEM rtx to refer to it in memory. */
3258 force_const_mem (mode
, x
)
3259 enum machine_mode mode
;
3263 register struct constant_descriptor
*desc
;
3268 /* If we want this CONST_DOUBLE in the same mode as it is in memory
3269 (this will always be true for floating CONST_DOUBLEs that have been
3270 placed in memory, but not for VOIDmode (integer) CONST_DOUBLEs),
3271 use the previous copy. Otherwise, make a new one. Note that in
3272 the unlikely event that this same CONST_DOUBLE is used in two different
3273 modes in an alternating fashion, we will allocate a lot of different
3274 memory locations, but this should be extremely rare. */
3276 /* Don't use CONST_DOUBLE_MEM in a nested function.
3277 Nested functions have their own constant pools,
3278 so they can't share the same values in CONST_DOUBLE_MEM
3279 with the containing function. */
3280 if (outer_function_chain
== 0)
3281 if (GET_CODE (x
) == CONST_DOUBLE
3282 && GET_CODE (CONST_DOUBLE_MEM (x
)) == MEM
3283 && GET_MODE (CONST_DOUBLE_MEM (x
)) == mode
)
3284 return CONST_DOUBLE_MEM (x
);
3286 /* Compute hash code of X. Search the descriptors for that hash code
3287 to see if any of them describes X. If yes, the descriptor records
3288 the label number already assigned. */
3290 hash
= const_hash_rtx (mode
, x
);
3292 for (desc
= const_rtx_hash_table
[hash
]; desc
; desc
= desc
->next
)
3293 if (compare_constant_rtx (mode
, x
, desc
))
3295 found
= desc
->label
;
3301 register struct pool_constant
*pool
;
3302 register struct pool_sym
*sym
;
3305 /* No constant equal to X is known to have been output.
3306 Make a constant descriptor to enter X in the hash table.
3307 Assign the label number and record it in the descriptor for
3308 future calls to this function to find. */
3310 desc
= record_constant_rtx (mode
, x
);
3311 desc
->next
= const_rtx_hash_table
[hash
];
3312 const_rtx_hash_table
[hash
] = desc
;
3314 /* Align the location counter as required by EXP's data type. */
3315 align
= (mode
== VOIDmode
) ? UNITS_PER_WORD
: GET_MODE_SIZE (mode
);
3316 if (align
> BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
)
3317 align
= BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
;
3319 pool_offset
+= align
- 1;
3320 pool_offset
&= ~ (align
- 1);
3322 /* If RTL is not being placed into the saveable obstack, make a
3323 copy of X that is in the saveable obstack in case we are
3324 being called from combine or some other phase that discards
3325 memory it allocates. We used to only do this if it is a
3326 CONST; however, reload can allocate a CONST_INT when
3327 eliminating registers. */
3328 if (rtl_obstack
!= saveable_obstack
3329 && (GET_CODE (x
) == CONST
|| GET_CODE (x
) == CONST_INT
))
3331 push_obstacks_nochange ();
3332 rtl_in_saveable_obstack ();
3334 if (GET_CODE (x
) == CONST
)
3335 x
= gen_rtx_CONST (GET_MODE (x
),
3336 gen_rtx_PLUS (GET_MODE (x
),
3337 XEXP (XEXP (x
, 0), 0),
3338 XEXP (XEXP (x
, 0), 1)));
3340 x
= GEN_INT (INTVAL (x
));
3345 /* Allocate a pool constant descriptor, fill it in, and chain it in. */
3347 pool
= (struct pool_constant
*) savealloc (sizeof (struct pool_constant
));
3351 pool
->labelno
= const_labelno
;
3352 pool
->align
= align
;
3353 pool
->offset
= pool_offset
;
3360 last_pool
->next
= pool
;
3363 pool_offset
+= GET_MODE_SIZE (mode
);
3365 /* Create a string containing the label name, in LABEL. */
3366 ASM_GENERATE_INTERNAL_LABEL (label
, "LC", const_labelno
);
3371 = (char *) obstack_copy0 (saveable_obstack
, label
, strlen (label
));
3373 /* Add label to symbol hash table. */
3374 hash
= SYMHASH (found
);
3375 sym
= (struct pool_sym
*) savealloc (sizeof (struct pool_sym
));
3378 sym
->next
= const_rtx_sym_hash_table
[hash
];
3379 const_rtx_sym_hash_table
[hash
] = sym
;
3382 /* We have a symbol name; construct the SYMBOL_REF and the MEM. */
3384 def
= gen_rtx_MEM (mode
, gen_rtx_SYMBOL_REF (Pmode
, found
));
3386 RTX_UNCHANGING_P (def
) = 1;
3387 /* Mark the symbol_ref as belonging to this constants pool. */
3388 CONSTANT_POOL_ADDRESS_P (XEXP (def
, 0)) = 1;
3389 current_function_uses_const_pool
= 1;
3391 if (outer_function_chain
== 0)
3392 if (GET_CODE (x
) == CONST_DOUBLE
)
3394 if (CONST_DOUBLE_MEM (x
) == cc0_rtx
)
3396 CONST_DOUBLE_CHAIN (x
) = const_double_chain
;
3397 const_double_chain
= x
;
3399 CONST_DOUBLE_MEM (x
) = def
;
3405 /* Given a SYMBOL_REF with CONSTANT_POOL_ADDRESS_P true, return a pointer to
3406 the corresponding pool_constant structure. */
3408 static struct pool_constant
*
3409 find_pool_constant (addr
)
3412 struct pool_sym
*sym
;
3413 char *label
= XSTR (addr
, 0);
3415 for (sym
= const_rtx_sym_hash_table
[SYMHASH (label
)]; sym
; sym
= sym
->next
)
3416 if (sym
->label
== label
)
3422 /* Given a constant pool SYMBOL_REF, return the corresponding constant. */
3425 get_pool_constant (addr
)
3428 return (find_pool_constant (addr
))->constant
;
3431 /* Similar, return the mode. */
3434 get_pool_mode (addr
)
3437 return (find_pool_constant (addr
))->mode
;
3440 /* Similar, return the offset in the constant pool. */
3443 get_pool_offset (addr
)
3446 return (find_pool_constant (addr
))->offset
;
3449 /* Return the size of the constant pool. */
3457 /* Write all the constants in the constant pool. */
3460 output_constant_pool (fnname
, fndecl
)
3464 struct pool_constant
*pool
;
3466 union real_extract u
;
3468 /* It is possible for gcc to call force_const_mem and then to later
3469 discard the instructions which refer to the constant. In such a
3470 case we do not need to output the constant. */
3471 if (optimize
>= 0 && flag_expensive_optimizations
)
3472 mark_constant_pool ();
3474 #ifdef ASM_OUTPUT_POOL_PROLOGUE
3475 ASM_OUTPUT_POOL_PROLOGUE (asm_out_file
, fnname
, fndecl
, pool_offset
);
3478 for (pool
= first_pool
; pool
; pool
= pool
->next
)
3485 /* See if X is a LABEL_REF (or a CONST referring to a LABEL_REF)
3486 whose CODE_LABEL has been deleted. This can occur if a jump table
3487 is eliminated by optimization. If so, write a constant of zero
3488 instead. Note that this can also happen by turning the
3489 CODE_LABEL into a NOTE. */
3490 if (((GET_CODE (x
) == LABEL_REF
3491 && (INSN_DELETED_P (XEXP (x
, 0))
3492 || GET_CODE (XEXP (x
, 0)) == NOTE
)))
3493 || (GET_CODE (x
) == CONST
&& GET_CODE (XEXP (x
, 0)) == PLUS
3494 && GET_CODE (XEXP (XEXP (x
, 0), 0)) == LABEL_REF
3495 && (INSN_DELETED_P (XEXP (XEXP (XEXP (x
, 0), 0), 0))
3496 || GET_CODE (XEXP (XEXP (XEXP (x
, 0), 0), 0)) == NOTE
)))
3499 /* First switch to correct section. */
3500 #ifdef SELECT_RTX_SECTION
3501 SELECT_RTX_SECTION (pool
->mode
, x
);
3503 readonly_data_section ();
3506 #ifdef ASM_OUTPUT_SPECIAL_POOL_ENTRY
3507 ASM_OUTPUT_SPECIAL_POOL_ENTRY (asm_out_file
, x
, pool
->mode
,
3508 pool
->align
, pool
->labelno
, done
);
3511 if (pool
->align
> 1)
3512 ASM_OUTPUT_ALIGN (asm_out_file
, exact_log2 (pool
->align
));
3514 /* Output the label. */
3515 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, "LC", pool
->labelno
);
3517 /* Output the value of the constant itself. */
3518 switch (GET_MODE_CLASS (pool
->mode
))
3521 if (GET_CODE (x
) != CONST_DOUBLE
)
3524 bcopy ((char *) &CONST_DOUBLE_LOW (x
), (char *) &u
, sizeof u
);
3525 assemble_real (u
.d
, pool
->mode
);
3529 case MODE_PARTIAL_INT
:
3530 assemble_integer (x
, GET_MODE_SIZE (pool
->mode
), 1);
3539 #ifdef ASM_OUTPUT_SPECIAL_POOL_ENTRY
3543 #ifdef ASM_OUTPUT_POOL_EPILOGUE
3544 ASM_OUTPUT_POOL_EPILOGUE (asm_out_file
, fnname
, fndecl
, pool_offset
);
3547 /* Done with this pool. */
3548 first_pool
= last_pool
= 0;
3551 /* Look through the instructions for this function, and mark all the
3552 entries in the constant pool which are actually being used. */
3555 mark_constant_pool ()
3558 struct pool_constant
*pool
;
3560 if (first_pool
== 0)
3563 for (pool
= first_pool
; pool
; pool
= pool
->next
)
3566 for (insn
= get_insns (); insn
; insn
= NEXT_INSN (insn
))
3567 if (GET_RTX_CLASS (GET_CODE (insn
)) == 'i')
3568 mark_constants (PATTERN (insn
));
3570 for (insn
= current_function_epilogue_delay_list
;
3572 insn
= XEXP (insn
, 1))
3573 if (GET_RTX_CLASS (GET_CODE (insn
)) == 'i')
3574 mark_constants (PATTERN (insn
));
3582 register char *format_ptr
;
3587 if (GET_CODE (x
) == SYMBOL_REF
)
3589 if (CONSTANT_POOL_ADDRESS_P (x
))
3590 find_pool_constant (x
)->mark
= 1;
3593 /* Never search inside a CONST_DOUBLE, because CONST_DOUBLE_MEM may be
3594 a MEM, but does not constitute a use of that MEM. This is particularly
3595 important inside a nested function, because CONST_DOUBLE_MEM may be
3596 a reference to a MEM in the parent's constant pool. See the comment
3597 in force_const_mem. */
3598 else if (GET_CODE (x
) == CONST_DOUBLE
)
3601 /* Insns may appear inside a SEQUENCE. Only check the patterns of
3602 insns, not any notes that may be attached. We don't want to mark
3603 a constant just because it happens to appear in a REG_EQUIV note. */
3604 if (GET_RTX_CLASS (GET_CODE (x
)) == 'i')
3606 mark_constants (PATTERN (x
));
3610 format_ptr
= GET_RTX_FORMAT (GET_CODE (x
));
3612 for (i
= 0; i
< GET_RTX_LENGTH (GET_CODE (x
)); i
++)
3614 switch (*format_ptr
++)
3617 mark_constants (XEXP (x
, i
));
3621 if (XVEC (x
, i
) != 0)
3625 for (j
= 0; j
< XVECLEN (x
, i
); j
++)
3626 mark_constants (XVECEXP (x
, i
, j
));
3645 /* Find all the constants whose addresses are referenced inside of EXP,
3646 and make sure assembler code with a label has been output for each one.
3647 Indicate whether an ADDR_EXPR has been encountered. */
3650 output_addressed_constants (exp
)
3655 switch (TREE_CODE (exp
))
3659 register tree constant
= TREE_OPERAND (exp
, 0);
3661 while (TREE_CODE (constant
) == COMPONENT_REF
)
3663 constant
= TREE_OPERAND (constant
, 0);
3666 if (TREE_CODE_CLASS (TREE_CODE (constant
)) == 'c'
3667 || TREE_CODE (constant
) == CONSTRUCTOR
)
3668 /* No need to do anything here
3669 for addresses of variables or functions. */
3670 output_constant_def (constant
);
3677 reloc
= output_addressed_constants (TREE_OPERAND (exp
, 0));
3678 reloc
|= output_addressed_constants (TREE_OPERAND (exp
, 1));
3683 case NON_LVALUE_EXPR
:
3684 reloc
= output_addressed_constants (TREE_OPERAND (exp
, 0));
3690 for (link
= CONSTRUCTOR_ELTS (exp
); link
; link
= TREE_CHAIN (link
))
3691 if (TREE_VALUE (link
) != 0)
3692 reloc
|= output_addressed_constants (TREE_VALUE (link
));
3702 /* Output assembler code for constant EXP to FILE, with no label.
3703 This includes the pseudo-op such as ".int" or ".byte", and a newline.
3704 Assumes output_addressed_constants has been done on EXP already.
3706 Generate exactly SIZE bytes of assembler data, padding at the end
3707 with zeros if necessary. SIZE must always be specified.
3709 SIZE is important for structure constructors,
3710 since trailing members may have been omitted from the constructor.
3711 It is also important for initialization of arrays from string constants
3712 since the full length of the string constant might not be wanted.
3713 It is also needed for initialization of unions, where the initializer's
3714 type is just one member, and that may not be as long as the union.
3716 There a case in which we would fail to output exactly SIZE bytes:
3717 for a structure constructor that wants to produce more than SIZE bytes.
3718 But such constructors will never be generated for any possible input. */
3721 output_constant (exp
, size
)
3725 register enum tree_code code
= TREE_CODE (TREE_TYPE (exp
));
3730 /* Eliminate the NON_LVALUE_EXPR_EXPR that makes a cast not be an lvalue.
3731 That way we get the constant (we hope) inside it. Also, strip off any
3732 NOP_EXPR that converts between two record, union, array, or set types. */
3733 while ((TREE_CODE (exp
) == NOP_EXPR
3734 && (TREE_TYPE (exp
) == TREE_TYPE (TREE_OPERAND (exp
, 0))
3735 || AGGREGATE_TYPE_P (TREE_TYPE (exp
))))
3736 || TREE_CODE (exp
) == NON_LVALUE_EXPR
)
3737 exp
= TREE_OPERAND (exp
, 0);
3739 /* Allow a constructor with no elements for any data type.
3740 This means to fill the space with zeros. */
3741 if (TREE_CODE (exp
) == CONSTRUCTOR
&& CONSTRUCTOR_ELTS (exp
) == 0)
3743 assemble_zeros (size
);
3754 case REFERENCE_TYPE
:
3755 /* ??? What about (int)((float)(int)&foo + 4) */
3756 while (TREE_CODE (exp
) == NOP_EXPR
|| TREE_CODE (exp
) == CONVERT_EXPR
3757 || TREE_CODE (exp
) == NON_LVALUE_EXPR
)
3758 exp
= TREE_OPERAND (exp
, 0);
3760 if (! assemble_integer (expand_expr (exp
, NULL_RTX
, VOIDmode
,
3761 EXPAND_INITIALIZER
),
3763 error ("initializer for integer value is too complicated");
3768 if (TREE_CODE (exp
) != REAL_CST
)
3769 error ("initializer for floating value is not a floating constant");
3771 assemble_real (TREE_REAL_CST (exp
),
3772 mode_for_size (size
* BITS_PER_UNIT
, MODE_FLOAT
, 0));
3777 output_constant (TREE_REALPART (exp
), size
/ 2);
3778 output_constant (TREE_IMAGPART (exp
), size
/ 2);
3779 size
-= (size
/ 2) * 2;
3783 if (TREE_CODE (exp
) == CONSTRUCTOR
)
3785 output_constructor (exp
, size
);
3788 else if (TREE_CODE (exp
) == STRING_CST
)
3792 if (size
> TREE_STRING_LENGTH (exp
))
3794 excess
= size
- TREE_STRING_LENGTH (exp
);
3795 size
= TREE_STRING_LENGTH (exp
);
3798 assemble_string (TREE_STRING_POINTER (exp
), size
);
3807 if (TREE_CODE (exp
) == CONSTRUCTOR
)
3808 output_constructor (exp
, size
);
3814 if (TREE_CODE (exp
) == INTEGER_CST
)
3815 assemble_integer (expand_expr (exp
, NULL_RTX
,
3816 VOIDmode
, EXPAND_INITIALIZER
),
3818 else if (TREE_CODE (exp
) == CONSTRUCTOR
)
3820 unsigned char *buffer
= (unsigned char *) alloca (size
);
3821 if (get_set_constructor_bytes (exp
, buffer
, size
))
3823 assemble_string ((char *) buffer
, size
);
3826 error ("unknown set constructor type");
3834 assemble_zeros (size
);
3838 /* Subroutine of output_constant, used for CONSTRUCTORs
3839 (aggregate constants).
3840 Generate at least SIZE bytes, padding if necessary. */
3843 output_constructor (exp
, size
)
3847 register tree link
, field
= 0;
3848 HOST_WIDE_INT min_index
= 0;
3849 /* Number of bytes output or skipped so far.
3850 In other words, current position within the constructor. */
3851 int total_bytes
= 0;
3852 /* Non-zero means BYTE contains part of a byte, to be output. */
3853 int byte_buffer_in_use
= 0;
3856 if (HOST_BITS_PER_WIDE_INT
< BITS_PER_UNIT
)
3859 if (TREE_CODE (TREE_TYPE (exp
)) == RECORD_TYPE
)
3860 field
= TYPE_FIELDS (TREE_TYPE (exp
));
3862 if (TREE_CODE (TREE_TYPE (exp
)) == ARRAY_TYPE
3863 && TYPE_DOMAIN (TREE_TYPE (exp
)) != 0)
3865 = TREE_INT_CST_LOW (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (exp
))));
3867 /* As LINK goes through the elements of the constant,
3868 FIELD goes through the structure fields, if the constant is a structure.
3869 if the constant is a union, then we override this,
3870 by getting the field from the TREE_LIST element.
3871 But the constant could also be an array. Then FIELD is zero. */
3872 for (link
= CONSTRUCTOR_ELTS (exp
);
3874 link
= TREE_CHAIN (link
),
3875 field
= field
? TREE_CHAIN (field
) : 0)
3877 tree val
= TREE_VALUE (link
);
3880 /* the element in a union constructor specifies the proper field. */
3882 if (TREE_CODE (TREE_TYPE (exp
)) == RECORD_TYPE
3883 || TREE_CODE (TREE_TYPE (exp
)) == UNION_TYPE
)
3885 /* if available, use the type given by link */
3886 if (TREE_PURPOSE (link
) != 0)
3887 field
= TREE_PURPOSE (link
);
3890 if (TREE_CODE (TREE_TYPE (exp
)) == ARRAY_TYPE
)
3891 index
= TREE_PURPOSE (link
);
3893 /* Eliminate the marker that makes a cast not be an lvalue. */
3897 if (index
&& TREE_CODE (index
) == RANGE_EXPR
)
3899 register int fieldsize
3900 = int_size_in_bytes (TREE_TYPE (TREE_TYPE (exp
)));
3901 HOST_WIDE_INT lo_index
= TREE_INT_CST_LOW (TREE_OPERAND (index
, 0));
3902 HOST_WIDE_INT hi_index
= TREE_INT_CST_LOW (TREE_OPERAND (index
, 1));
3903 HOST_WIDE_INT index
;
3904 for (index
= lo_index
; index
<= hi_index
; index
++)
3906 /* Output the element's initial value. */
3908 assemble_zeros (fieldsize
);
3910 output_constant (val
, fieldsize
);
3912 /* Count its size. */
3913 total_bytes
+= fieldsize
;
3916 else if (field
== 0 || !DECL_BIT_FIELD (field
))
3918 /* An element that is not a bit-field. */
3920 register int fieldsize
;
3921 /* Since this structure is static,
3922 we know the positions are constant. */
3923 int bitpos
= (field
? (TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field
))
3927 bitpos
= (TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (val
)))
3929 * (TREE_INT_CST_LOW (index
) - min_index
));
3931 /* Output any buffered-up bit-fields preceding this element. */
3932 if (byte_buffer_in_use
)
3934 ASM_OUTPUT_BYTE (asm_out_file
, byte
);
3936 byte_buffer_in_use
= 0;
3939 /* Advance to offset of this element.
3940 Note no alignment needed in an array, since that is guaranteed
3941 if each element has the proper size. */
3942 if ((field
!= 0 || index
!= 0) && bitpos
!= total_bytes
)
3944 assemble_zeros (bitpos
- total_bytes
);
3945 total_bytes
= bitpos
;
3948 /* Determine size this element should occupy. */
3951 if (TREE_CODE (DECL_SIZE (field
)) != INTEGER_CST
)
3953 if (TREE_INT_CST_LOW (DECL_SIZE (field
)) > 100000)
3955 /* This avoids overflow trouble. */
3956 tree size_tree
= size_binop (CEIL_DIV_EXPR
,
3958 size_int (BITS_PER_UNIT
));
3959 fieldsize
= TREE_INT_CST_LOW (size_tree
);
3963 fieldsize
= TREE_INT_CST_LOW (DECL_SIZE (field
));
3964 fieldsize
= (fieldsize
+ BITS_PER_UNIT
- 1) / BITS_PER_UNIT
;
3968 fieldsize
= int_size_in_bytes (TREE_TYPE (TREE_TYPE (exp
)));
3970 /* Output the element's initial value. */
3972 assemble_zeros (fieldsize
);
3974 output_constant (val
, fieldsize
);
3976 /* Count its size. */
3977 total_bytes
+= fieldsize
;
3979 else if (val
!= 0 && TREE_CODE (val
) != INTEGER_CST
)
3980 error ("invalid initial value for member `%s'",
3981 IDENTIFIER_POINTER (DECL_NAME (field
)));
3984 /* Element that is a bit-field. */
3986 int next_offset
= TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field
));
3988 = (next_offset
+ TREE_INT_CST_LOW (DECL_SIZE (field
)));
3991 val
= integer_zero_node
;
3993 /* If this field does not start in this (or, next) byte,
3995 if (next_offset
/ BITS_PER_UNIT
!= total_bytes
)
3997 /* Output remnant of any bit field in previous bytes. */
3998 if (byte_buffer_in_use
)
4000 ASM_OUTPUT_BYTE (asm_out_file
, byte
);
4002 byte_buffer_in_use
= 0;
4005 /* If still not at proper byte, advance to there. */
4006 if (next_offset
/ BITS_PER_UNIT
!= total_bytes
)
4008 assemble_zeros (next_offset
/ BITS_PER_UNIT
- total_bytes
);
4009 total_bytes
= next_offset
/ BITS_PER_UNIT
;
4013 if (! byte_buffer_in_use
)
4016 /* We must split the element into pieces that fall within
4017 separate bytes, and combine each byte with previous or
4018 following bit-fields. */
4020 /* next_offset is the offset n fbits from the beginning of
4021 the structure to the next bit of this element to be processed.
4022 end_offset is the offset of the first bit past the end of
4024 while (next_offset
< end_offset
)
4028 HOST_WIDE_INT value
;
4029 int next_byte
= next_offset
/ BITS_PER_UNIT
;
4030 int next_bit
= next_offset
% BITS_PER_UNIT
;
4032 /* Advance from byte to byte
4033 within this element when necessary. */
4034 while (next_byte
!= total_bytes
)
4036 ASM_OUTPUT_BYTE (asm_out_file
, byte
);
4041 /* Number of bits we can process at once
4042 (all part of the same byte). */
4043 this_time
= MIN (end_offset
- next_offset
,
4044 BITS_PER_UNIT
- next_bit
);
4045 if (BYTES_BIG_ENDIAN
)
4047 /* On big-endian machine, take the most significant bits
4048 first (of the bits that are significant)
4049 and put them into bytes from the most significant end. */
4050 shift
= end_offset
- next_offset
- this_time
;
4051 /* Don't try to take a bunch of bits that cross
4052 the word boundary in the INTEGER_CST. */
4053 if (shift
< HOST_BITS_PER_WIDE_INT
4054 && shift
+ this_time
> HOST_BITS_PER_WIDE_INT
)
4056 this_time
-= (HOST_BITS_PER_WIDE_INT
- shift
);
4057 shift
= HOST_BITS_PER_WIDE_INT
;
4060 /* Now get the bits from the appropriate constant word. */
4061 if (shift
< HOST_BITS_PER_WIDE_INT
)
4063 value
= TREE_INT_CST_LOW (val
);
4065 else if (shift
< 2 * HOST_BITS_PER_WIDE_INT
)
4067 value
= TREE_INT_CST_HIGH (val
);
4068 shift
-= HOST_BITS_PER_WIDE_INT
;
4072 byte
|= (((value
>> shift
)
4073 & (((HOST_WIDE_INT
) 1 << this_time
) - 1))
4074 << (BITS_PER_UNIT
- this_time
- next_bit
));
4078 /* On little-endian machines,
4079 take first the least significant bits of the value
4080 and pack them starting at the least significant
4081 bits of the bytes. */
4082 shift
= (next_offset
4083 - TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field
)));
4084 /* Don't try to take a bunch of bits that cross
4085 the word boundary in the INTEGER_CST. */
4086 if (shift
< HOST_BITS_PER_WIDE_INT
4087 && shift
+ this_time
> HOST_BITS_PER_WIDE_INT
)
4089 this_time
-= (HOST_BITS_PER_WIDE_INT
- shift
);
4090 shift
= HOST_BITS_PER_WIDE_INT
;
4093 /* Now get the bits from the appropriate constant word. */
4094 if (shift
< HOST_BITS_PER_WIDE_INT
)
4095 value
= TREE_INT_CST_LOW (val
);
4096 else if (shift
< 2 * HOST_BITS_PER_WIDE_INT
)
4098 value
= TREE_INT_CST_HIGH (val
);
4099 shift
-= HOST_BITS_PER_WIDE_INT
;
4103 byte
|= (((value
>> shift
)
4104 & (((HOST_WIDE_INT
) 1 << this_time
) - 1))
4107 next_offset
+= this_time
;
4108 byte_buffer_in_use
= 1;
4112 if (byte_buffer_in_use
)
4114 ASM_OUTPUT_BYTE (asm_out_file
, byte
);
4117 if (total_bytes
< size
)
4118 assemble_zeros (size
- total_bytes
);
4121 /* Output asm to handle ``#pragma weak'' */
4124 handle_pragma_weak (what
, name
, value
)
4125 enum pragma_state what
;
4128 #ifdef HANDLE_PRAGMA_WEAK
4129 if (what
== ps_name
|| what
== ps_value
)
4131 struct weak_syms
*weak
=
4132 (struct weak_syms
*)permalloc (sizeof (struct weak_syms
));
4133 weak
->next
= weak_decls
;
4134 weak
->name
= permalloc (strlen (name
) + 1);
4135 strcpy (weak
->name
, name
);
4137 if (what
!= ps_value
)
4138 weak
->value
= NULL_PTR
;
4142 weak
->value
= permalloc (strlen (value
) + 1);
4143 strcpy (weak
->value
, value
);
4148 else if (! (what
== ps_done
|| what
== ps_start
))
4149 warning ("malformed `#pragma weak'");
4150 #endif /* HANDLE_PRAGMA_WEAK */
4153 /* Declare DECL to be a weak symbol. */
4159 if (! TREE_PUBLIC (decl
))
4160 error_with_decl (decl
, "weak declaration of `%s' must be public");
4161 else if (TREE_ASM_WRITTEN (decl
))
4162 error_with_decl (decl
, "weak declaration of `%s' must precede definition");
4163 else if (SUPPORTS_WEAK
)
4164 DECL_WEAK (decl
) = 1;
4167 /* Emit any pending weak declarations. */
4172 #ifdef HANDLE_PRAGMA_WEAK
4173 if (HANDLE_PRAGMA_WEAK
)
4175 struct weak_syms
*t
;
4176 for (t
= weak_decls
; t
; t
= t
->next
)
4178 ASM_WEAKEN_LABEL (asm_out_file
, t
->name
);
4180 ASM_OUTPUT_DEF (asm_out_file
, t
->name
, t
->value
);
4187 assemble_alias (decl
, target
)
4192 make_decl_rtl (decl
, (char *) 0, 1);
4193 name
= XSTR (XEXP (DECL_RTL (decl
), 0), 0);
4195 #ifdef ASM_OUTPUT_DEF
4196 /* Make name accessible from other files, if appropriate. */
4198 if (TREE_PUBLIC (decl
))
4200 #ifdef ASM_WEAKEN_LABEL
4201 if (DECL_WEAK (decl
))
4202 ASM_WEAKEN_LABEL (asm_out_file
, name
);
4205 ASM_GLOBALIZE_LABEL (asm_out_file
, name
);
4208 ASM_OUTPUT_DEF (asm_out_file
, name
, IDENTIFIER_POINTER (target
));
4209 TREE_ASM_WRITTEN (decl
) = 1;
4211 #ifdef ASM_OUTPUT_WEAK_ALIAS
4212 if (! DECL_WEAK (decl
))
4213 warning ("only weak aliases are supported in this configuration");
4215 ASM_OUTPUT_WEAK_ALIAS (asm_out_file
, name
, IDENTIFIER_POINTER (target
));
4216 TREE_ASM_WRITTEN (decl
) = 1;
4218 warning ("alias definitions not supported in this configuration; ignored");
4223 /* This determines whether or not we support link-once semantics. */
4224 #ifndef SUPPORTS_ONE_ONLY
4225 #ifdef MAKE_DECL_ONE_ONLY
4226 #define SUPPORTS_ONE_ONLY 1
4228 #define SUPPORTS_ONE_ONLY 0
4232 /* Returns 1 if the target configuration supports defining public symbols
4233 so that one of them will be chosen at link time instead of generating a
4234 multiply-defined symbol error, whether through the use of weak symbols or
4235 a target-specific mechanism for having duplicates discarded. */
4238 supports_one_only ()
4240 if (SUPPORTS_ONE_ONLY
)
4242 return SUPPORTS_WEAK
;
4245 /* Set up DECL as a public symbol that can be defined in multiple
4246 translation units without generating a linker error. */
4249 make_decl_one_only (decl
)
4252 if (TREE_CODE (decl
) != VAR_DECL
&& TREE_CODE (decl
) != FUNCTION_DECL
)
4255 TREE_PUBLIC (decl
) = 1;
4257 if (TREE_CODE (decl
) == VAR_DECL
4258 && (DECL_INITIAL (decl
) == 0 || DECL_INITIAL (decl
) == error_mark_node
))
4259 DECL_COMMON (decl
) = 1;
4260 else if (SUPPORTS_ONE_ONLY
)
4262 #ifdef MAKE_DECL_ONE_ONLY
4263 MAKE_DECL_ONE_ONLY (decl
);
4265 DECL_ONE_ONLY (decl
) = 1;
4267 else if (SUPPORTS_WEAK
)
4268 DECL_WEAK (decl
) = 1;