varasm.c (struct varasm_status): Change x_const_rtx_sym_hash_table to array of pool_c...
[gcc.git] / gcc / varasm.c
1 /* Output variables, constants and external declarations, for GNU compiler.
2 Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997,
3 1998, 1999, 2000 Free Software Foundation, Inc.
4
5 This file is part of GNU CC.
6
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
21
22
23 /* This file handles generation of all the assembler code
24 *except* the instructions of a function.
25 This includes declarations of variables and their initial values.
26
27 We also output the assembler code for constants stored in memory
28 and are responsible for combining constants with the same value. */
29
30 #include "config.h"
31 #include "system.h"
32 #include <setjmp.h>
33 #include "rtl.h"
34 #include "tree.h"
35 #include "flags.h"
36 #include "function.h"
37 #include "expr.h"
38 #include "hard-reg-set.h"
39 #include "regs.h"
40 #include "defaults.h"
41 #include "output.h"
42 #include "real.h"
43 #include "toplev.h"
44 #include "dbxout.h"
45 #include "sdbout.h"
46 #include "obstack.h"
47 #include "c-pragma.h"
48 #include "ggc.h"
49 #include "tm_p.h"
50
51 #ifdef XCOFF_DEBUGGING_INFO
52 #include "xcoffout.h"
53 #endif
54
55 #ifndef TRAMPOLINE_ALIGNMENT
56 #define TRAMPOLINE_ALIGNMENT FUNCTION_BOUNDARY
57 #endif
58
59 #ifndef ASM_STABS_OP
60 #define ASM_STABS_OP "\t.stabs\t"
61 #endif
62
63 /* Define the prefix to use when check_memory_usage_flag is enable. */
64 #ifdef NO_DOLLAR_IN_LABEL
65 #ifdef NO_DOT_IN_LABEL
66 #define CHKR_PREFIX "chkr_prefix_"
67 #else /* !NO_DOT_IN_LABEL */
68 #define CHKR_PREFIX "chkr."
69 #endif
70 #else /* !NO_DOLLAR_IN_LABEL */
71 #define CHKR_PREFIX "chkr$"
72 #endif
73 #define CHKR_PREFIX_SIZE (sizeof (CHKR_PREFIX) - 1)
74
75 /* File in which assembler code is being written. */
76
77 extern FILE *asm_out_file;
78
79 /* The (assembler) name of the first globally-visible object output. */
80 const char *first_global_object_name;
81 const char *weak_global_object_name;
82
83 extern struct obstack permanent_obstack;
84 #define obstack_chunk_alloc xmalloc
85
86 struct addr_const;
87 struct constant_descriptor;
88 struct rtx_const;
89 struct pool_constant;
90
91 #define MAX_RTX_HASH_TABLE 61
92
93 struct varasm_status
94 {
95 /* Hash facility for making memory-constants
96 from constant rtl-expressions. It is used on RISC machines
97 where immediate integer arguments and constant addresses are restricted
98 so that such constants must be stored in memory.
99
100 This pool of constants is reinitialized for each function
101 so each function gets its own constants-pool that comes right before
102 it. */
103 struct constant_descriptor **x_const_rtx_hash_table;
104 struct pool_constant **x_const_rtx_sym_hash_table;
105
106 /* Pointers to first and last constant in pool. */
107 struct pool_constant *x_first_pool, *x_last_pool;
108
109 /* Current offset in constant pool (does not include any machine-specific
110 header. */
111 int x_pool_offset;
112
113 /* Chain of all CONST_DOUBLE rtx's constructed for the current function.
114 They are chained through the CONST_DOUBLE_CHAIN.
115 A CONST_DOUBLE rtx has CONST_DOUBLE_MEM != cc0_rtx iff it is on this chain.
116 In that case, CONST_DOUBLE_MEM is either a MEM,
117 or const0_rtx if no MEM has been made for this CONST_DOUBLE yet. */
118 rtx x_const_double_chain;
119 };
120
121 #define const_rtx_hash_table (cfun->varasm->x_const_rtx_hash_table)
122 #define const_rtx_sym_hash_table (cfun->varasm->x_const_rtx_sym_hash_table)
123 #define first_pool (cfun->varasm->x_first_pool)
124 #define last_pool (cfun->varasm->x_last_pool)
125 #define pool_offset (cfun->varasm->x_pool_offset)
126 #define const_double_chain (cfun->varasm->x_const_double_chain)
127
128 /* Number for making the label on the next
129 constant that is stored in memory. */
130
131 int const_labelno;
132
133 /* Number for making the label on the next
134 static variable internal to a function. */
135
136 int var_labelno;
137
138 /* Carry information from ASM_DECLARE_OBJECT_NAME
139 to ASM_FINISH_DECLARE_OBJECT. */
140
141 int size_directive_output;
142
143 /* The last decl for which assemble_variable was called,
144 if it did ASM_DECLARE_OBJECT_NAME.
145 If the last call to assemble_variable didn't do that,
146 this holds 0. */
147
148 tree last_assemble_variable_decl;
149
150 static const char *strip_reg_name PARAMS ((const char *));
151 static int contains_pointers_p PARAMS ((tree));
152 static void decode_addr_const PARAMS ((tree, struct addr_const *));
153 static int const_hash PARAMS ((tree));
154 static int compare_constant PARAMS ((tree,
155 struct constant_descriptor *));
156 static const unsigned char *compare_constant_1 PARAMS ((tree, const unsigned char *));
157 static struct constant_descriptor *record_constant PARAMS ((tree));
158 static void record_constant_1 PARAMS ((tree));
159 static tree copy_constant PARAMS ((tree));
160 static void output_constant_def_contents PARAMS ((tree, int, int));
161 static void decode_rtx_const PARAMS ((enum machine_mode, rtx,
162 struct rtx_const *));
163 static int const_hash_rtx PARAMS ((enum machine_mode, rtx));
164 static int compare_constant_rtx PARAMS ((enum machine_mode, rtx,
165 struct constant_descriptor *));
166 static struct constant_descriptor *record_constant_rtx PARAMS ((enum machine_mode,
167 rtx));
168 static struct pool_constant *find_pool_constant PARAMS ((struct function *, rtx));
169 static void mark_constant_pool PARAMS ((void));
170 static void mark_constants PARAMS ((rtx));
171 static int output_addressed_constants PARAMS ((tree));
172 static void output_after_function_constants PARAMS ((void));
173 static void output_constructor PARAMS ((tree, int));
174 #ifdef ASM_WEAKEN_LABEL
175 static void remove_from_pending_weak_list PARAMS ((const char *));
176 #endif
177 #ifdef ASM_OUTPUT_BSS
178 static void asm_output_bss PARAMS ((FILE *, tree, const char *, int, int));
179 #endif
180 #ifdef BSS_SECTION_ASM_OP
181 #ifdef ASM_OUTPUT_ALIGNED_BSS
182 static void asm_output_aligned_bss PARAMS ((FILE *, tree, const char *,
183 int, int));
184 #endif
185 #endif /* BSS_SECTION_ASM_OP */
186 static void mark_pool_constant PARAMS ((struct pool_constant *));
187 static void mark_const_hash_entry PARAMS ((void *));
188 static void asm_emit_uninitialised PARAMS ((tree, const char*, int, int));
189 \f
190 static enum in_section { no_section, in_text, in_data, in_named
191 #ifdef BSS_SECTION_ASM_OP
192 , in_bss
193 #endif
194 #ifdef EH_FRAME_SECTION_ASM_OP
195 , in_eh_frame
196 #endif
197 #ifdef EXTRA_SECTIONS
198 , EXTRA_SECTIONS
199 #endif
200 } in_section = no_section;
201
202 /* Return a non-zero value if DECL has a section attribute. */
203 #ifndef IN_NAMED_SECTION
204 #define IN_NAMED_SECTION(DECL) \
205 ((TREE_CODE (DECL) == FUNCTION_DECL || TREE_CODE (DECL) == VAR_DECL) \
206 && DECL_SECTION_NAME (DECL) != NULL_TREE)
207 #endif
208
209 /* Text of section name when in_section == in_named. */
210 static char *in_named_name;
211
212 /* Define functions like text_section for any extra sections. */
213 #ifdef EXTRA_SECTION_FUNCTIONS
214 EXTRA_SECTION_FUNCTIONS
215 #endif
216
217 /* Tell assembler to switch to text section. */
218
219 void
220 text_section ()
221 {
222 if (in_section != in_text)
223 {
224 fprintf (asm_out_file, "%s\n", TEXT_SECTION_ASM_OP);
225 in_section = in_text;
226 }
227 }
228
229 /* Tell assembler to switch to data section. */
230
231 void
232 data_section ()
233 {
234 if (in_section != in_data)
235 {
236 if (flag_shared_data)
237 {
238 #ifdef SHARED_SECTION_ASM_OP
239 fprintf (asm_out_file, "%s\n", SHARED_SECTION_ASM_OP);
240 #else
241 fprintf (asm_out_file, "%s\n", DATA_SECTION_ASM_OP);
242 #endif
243 }
244 else
245 fprintf (asm_out_file, "%s\n", DATA_SECTION_ASM_OP);
246
247 in_section = in_data;
248 }
249 }
250 /* Tell assembler to ALWAYS switch to data section, in case
251 it's not sure where it it. */
252
253 void
254 force_data_section ()
255 {
256 in_section = no_section;
257 data_section ();
258 }
259
260 /* Tell assembler to switch to read-only data section. This is normally
261 the text section. */
262
263 void
264 readonly_data_section ()
265 {
266 #ifdef READONLY_DATA_SECTION
267 READONLY_DATA_SECTION (); /* Note this can call data_section. */
268 #else
269 text_section ();
270 #endif
271 }
272
273 /* Determine if we're in the text section. */
274
275 int
276 in_text_section ()
277 {
278 return in_section == in_text;
279 }
280
281 /* Determine if we're in the data section. */
282
283 int
284 in_data_section ()
285 {
286 return in_section == in_data;
287 }
288
289 /* Tell assembler to change to section NAME for DECL.
290 If DECL is NULL, just switch to section NAME.
291 If NAME is NULL, get the name from DECL.
292 If RELOC is 1, the initializer for DECL contains relocs. */
293
294 void
295 named_section (decl, name, reloc)
296 tree decl;
297 const char *name;
298 int reloc ATTRIBUTE_UNUSED;
299 {
300 if (decl != NULL_TREE && !DECL_P (decl))
301 abort ();
302 if (name == NULL)
303 name = TREE_STRING_POINTER (DECL_SECTION_NAME (decl));
304
305 if (in_section != in_named || strcmp (name, in_named_name))
306 {
307 #ifdef ASM_OUTPUT_SECTION_NAME
308 ASM_OUTPUT_SECTION_NAME (asm_out_file, decl, name, reloc);
309 #else
310 /* Section attributes are not supported if this macro isn't provided -
311 some host formats don't support them at all. The front-end should
312 already have flagged this as an error. */
313 abort ();
314 #endif
315
316 in_named_name = ggc_alloc_string (name, -1);
317 in_section = in_named;
318 }
319 }
320
321 #ifdef ASM_OUTPUT_SECTION_NAME
322 #ifndef UNIQUE_SECTION
323 #define UNIQUE_SECTION(DECL,RELOC) \
324 do { \
325 int len; \
326 const char *name; \
327 char *string; \
328 \
329 name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL)); \
330 /* Strip off any encoding in name. */ \
331 STRIP_NAME_ENCODING (name, name); \
332 \
333 len = strlen (name) + 1; \
334 string = alloca (len + 1); \
335 sprintf (string, ".%s", name); \
336 \
337 DECL_SECTION_NAME (DECL) = build_string (len, string); \
338 } while (0)
339 #endif
340 #ifndef UNIQUE_SECTION_P
341 #define UNIQUE_SECTION_P(DECL) 0
342 #endif
343 #endif
344
345 #ifdef BSS_SECTION_ASM_OP
346
347 /* Tell the assembler to switch to the bss section. */
348
349 void
350 bss_section ()
351 {
352 if (in_section != in_bss)
353 {
354 #ifdef SHARED_BSS_SECTION_ASM_OP
355 if (flag_shared_data)
356 fprintf (asm_out_file, "%s\n", SHARED_BSS_SECTION_ASM_OP);
357 else
358 #endif
359 fprintf (asm_out_file, "%s\n", BSS_SECTION_ASM_OP);
360
361 in_section = in_bss;
362 }
363 }
364
365 #ifdef ASM_OUTPUT_BSS
366
367 /* Utility function for ASM_OUTPUT_BSS for targets to use if
368 they don't support alignments in .bss.
369 ??? It is believed that this function will work in most cases so such
370 support is localized here. */
371
372 static void
373 asm_output_bss (file, decl, name, size, rounded)
374 FILE *file;
375 tree decl ATTRIBUTE_UNUSED;
376 const char *name;
377 int size ATTRIBUTE_UNUSED, rounded;
378 {
379 ASM_GLOBALIZE_LABEL (file, name);
380 bss_section ();
381 #ifdef ASM_DECLARE_OBJECT_NAME
382 last_assemble_variable_decl = decl;
383 ASM_DECLARE_OBJECT_NAME (file, name, decl);
384 #else
385 /* Standard thing is just output label for the object. */
386 ASM_OUTPUT_LABEL (file, name);
387 #endif /* ASM_DECLARE_OBJECT_NAME */
388 ASM_OUTPUT_SKIP (file, rounded);
389 }
390
391 #endif
392
393 #ifdef ASM_OUTPUT_ALIGNED_BSS
394
395 /* Utility function for targets to use in implementing
396 ASM_OUTPUT_ALIGNED_BSS.
397 ??? It is believed that this function will work in most cases so such
398 support is localized here. */
399
400 static void
401 asm_output_aligned_bss (file, decl, name, size, align)
402 FILE *file;
403 tree decl;
404 const char *name;
405 int size, align;
406 {
407 ASM_GLOBALIZE_LABEL (file, name);
408 bss_section ();
409 ASM_OUTPUT_ALIGN (file, floor_log2 (align / BITS_PER_UNIT));
410 #ifdef ASM_DECLARE_OBJECT_NAME
411 last_assemble_variable_decl = decl;
412 ASM_DECLARE_OBJECT_NAME (file, name, decl);
413 #else
414 /* Standard thing is just output label for the object. */
415 ASM_OUTPUT_LABEL (file, name);
416 #endif /* ASM_DECLARE_OBJECT_NAME */
417 ASM_OUTPUT_SKIP (file, size ? size : 1);
418 }
419
420 #endif
421
422 #endif /* BSS_SECTION_ASM_OP */
423
424 #ifdef EH_FRAME_SECTION_ASM_OP
425 void
426 eh_frame_section ()
427 {
428 if (in_section != in_eh_frame)
429 {
430 fprintf (asm_out_file, "%s\n", EH_FRAME_SECTION_ASM_OP);
431 in_section = in_eh_frame;
432 }
433 }
434 #endif
435
436 /* Switch to the section for function DECL.
437
438 If DECL is NULL_TREE, switch to the text section.
439 ??? It's not clear that we will ever be passed NULL_TREE, but it's
440 safer to handle it. */
441
442 void
443 function_section (decl)
444 tree decl;
445 {
446 if (decl != NULL_TREE
447 && DECL_SECTION_NAME (decl) != NULL_TREE)
448 named_section (decl, (char *) 0, 0);
449 else
450 text_section ();
451 }
452
453 /* Switch to section for variable DECL.
454
455 RELOC is the `reloc' argument to SELECT_SECTION. */
456
457 void
458 variable_section (decl, reloc)
459 tree decl;
460 int reloc;
461 {
462 if (IN_NAMED_SECTION (decl))
463 named_section (decl, NULL, reloc);
464 else
465 {
466 /* C++ can have const variables that get initialized from constructors,
467 and thus can not be in a readonly section. We prevent this by
468 verifying that the initial value is constant for objects put in a
469 readonly section.
470
471 error_mark_node is used by the C front end to indicate that the
472 initializer has not been seen yet. In this case, we assume that
473 the initializer must be constant.
474
475 C++ uses error_mark_node for variables that have complicated
476 initializers, but these variables go in BSS so we won't be called
477 for them. */
478
479 #ifdef SELECT_SECTION
480 SELECT_SECTION (decl, reloc);
481 #else
482 if (DECL_READONLY_SECTION (decl, reloc))
483 readonly_data_section ();
484 else
485 data_section ();
486 #endif
487 }
488 }
489
490 /* Tell assembler to switch to the section for the exception handling
491 table. */
492
493 void
494 exception_section ()
495 {
496 #if defined (EXCEPTION_SECTION)
497 EXCEPTION_SECTION ();
498 #else
499 #ifdef ASM_OUTPUT_SECTION_NAME
500 named_section (NULL_TREE, ".gcc_except_table", 0);
501 #else
502 if (flag_pic)
503 data_section ();
504 else
505 readonly_data_section ();
506 #endif
507 #endif
508 }
509 \f
510 /* Create the rtl to represent a function, for a function definition.
511 DECL is a FUNCTION_DECL node which describes which function.
512 The rtl is stored into DECL. */
513
514 void
515 make_function_rtl (decl)
516 tree decl;
517 {
518 const char *name;
519 const char *new_name;
520
521 if (DECL_RTL (decl) != 0)
522 {
523 /* ??? Another way to do this would be to do what halfpic.c does
524 and maintain a hashed table of such critters. */
525 /* ??? Another way to do this would be to pass a flag bit to
526 ENCODE_SECTION_INFO saying whether this is a new decl or not. */
527 /* Let the target reassign the RTL if it wants.
528 This is necessary, for example, when one machine specific
529 decl attribute overrides another. */
530 #ifdef REDO_SECTION_INFO_P
531 if (REDO_SECTION_INFO_P (decl))
532 ENCODE_SECTION_INFO (decl);
533 #endif
534 return;
535 }
536
537 name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
538 new_name = name;
539
540 /* Rename a nested function to avoid conflicts, unless it's a member of
541 a local class, in which case the class name is already unique. */
542 if (decl_function_context (decl) != 0
543 && ! TYPE_P (DECL_CONTEXT (decl))
544 && DECL_INITIAL (decl) != 0
545 && DECL_RTL (decl) == 0)
546 {
547 char *label;
548 ASM_FORMAT_PRIVATE_NAME (label, name, var_labelno);
549 var_labelno++;
550 new_name = label;
551 }
552 /* When -fprefix-function-name is used, every function name is
553 prefixed. Even static functions are prefixed because they
554 could be declared latter. Note that a nested function name
555 is not prefixed. */
556 else if (flag_prefix_function_name)
557 {
558 size_t name_len = IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (decl));
559 char *pname;
560
561 pname = alloca (name_len + CHKR_PREFIX_SIZE + 1);
562 memcpy (pname, CHKR_PREFIX, CHKR_PREFIX_SIZE);
563 memcpy (pname + CHKR_PREFIX_SIZE, name, name_len + 1);
564 new_name = pname;
565 }
566
567 if (name != new_name)
568 {
569 DECL_ASSEMBLER_NAME (decl) = get_identifier (new_name);
570 name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
571 }
572
573 DECL_RTL (decl)
574 = gen_rtx_MEM (DECL_MODE (decl),
575 gen_rtx_SYMBOL_REF (Pmode, name));
576
577 /* Optionally set flags or add text to the name to record
578 information such as that it is a function name. If the name
579 is changed, the macro ASM_OUTPUT_LABELREF will have to know
580 how to strip this information. */
581 #ifdef ENCODE_SECTION_INFO
582 ENCODE_SECTION_INFO (decl);
583 #endif
584 }
585
586
587 /* Given NAME, a putative register name, discard any customary prefixes. */
588
589 static const char *
590 strip_reg_name (name)
591 const char *name;
592 {
593 #ifdef REGISTER_PREFIX
594 if (!strncmp (name, REGISTER_PREFIX, strlen (REGISTER_PREFIX)))
595 name += strlen (REGISTER_PREFIX);
596 #endif
597 if (name[0] == '%' || name[0] == '#')
598 name++;
599 return name;
600 }
601 \f
602 /* Decode an `asm' spec for a declaration as a register name.
603 Return the register number, or -1 if nothing specified,
604 or -2 if the ASMSPEC is not `cc' or `memory' and is not recognized,
605 or -3 if ASMSPEC is `cc' and is not recognized,
606 or -4 if ASMSPEC is `memory' and is not recognized.
607 Accept an exact spelling or a decimal number.
608 Prefixes such as % are optional. */
609
610 int
611 decode_reg_name (asmspec)
612 const char *asmspec;
613 {
614 if (asmspec != 0)
615 {
616 int i;
617
618 /* Get rid of confusing prefixes. */
619 asmspec = strip_reg_name (asmspec);
620
621 /* Allow a decimal number as a "register name". */
622 for (i = strlen (asmspec) - 1; i >= 0; i--)
623 if (! (asmspec[i] >= '0' && asmspec[i] <= '9'))
624 break;
625 if (asmspec[0] != 0 && i < 0)
626 {
627 i = atoi (asmspec);
628 if (i < FIRST_PSEUDO_REGISTER && i >= 0)
629 return i;
630 else
631 return -2;
632 }
633
634 for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
635 if (reg_names[i][0]
636 && ! strcmp (asmspec, strip_reg_name (reg_names[i])))
637 return i;
638
639 #ifdef ADDITIONAL_REGISTER_NAMES
640 {
641 static struct { const char *name; int number; } table[]
642 = ADDITIONAL_REGISTER_NAMES;
643
644 for (i = 0; i < (int) ARRAY_SIZE (table); i++)
645 if (! strcmp (asmspec, table[i].name))
646 return table[i].number;
647 }
648 #endif /* ADDITIONAL_REGISTER_NAMES */
649
650 if (!strcmp (asmspec, "memory"))
651 return -4;
652
653 if (!strcmp (asmspec, "cc"))
654 return -3;
655
656 return -2;
657 }
658
659 return -1;
660 }
661 \f
662 /* Create the DECL_RTL for a declaration for a static or external variable
663 or static or external function.
664 ASMSPEC, if not 0, is the string which the user specified
665 as the assembler symbol name.
666 TOP_LEVEL is nonzero if this is a file-scope variable.
667
668 This is never called for PARM_DECL nodes. */
669
670 void
671 make_decl_rtl (decl, asmspec, top_level)
672 tree decl;
673 const char *asmspec;
674 int top_level;
675 {
676 const char *name = 0;
677 const char *new_name = 0;
678 int reg_number;
679
680 /* For a duplicate declaration, we can be called twice on the
681 same DECL node. Don't discard the RTL already made. */
682 if (DECL_RTL (decl) != 0)
683 {
684 /* If the old RTL had the wrong mode, fix the mode. */
685 if (GET_MODE (DECL_RTL (decl)) != DECL_MODE (decl))
686 {
687 rtx rtl = DECL_RTL (decl);
688 PUT_MODE (rtl, DECL_MODE (decl));
689 }
690
691 /* ??? Another way to do this would be to do what halfpic.c does
692 and maintain a hashed table of such critters. */
693 /* ??? Another way to do this would be to pass a flag bit to
694 ENCODE_SECTION_INFO saying whether this is a new decl or not. */
695 /* Let the target reassign the RTL if it wants.
696 This is necessary, for example, when one machine specific
697 decl attribute overrides another. */
698 #ifdef REDO_SECTION_INFO_P
699 if (REDO_SECTION_INFO_P (decl))
700 ENCODE_SECTION_INFO (decl);
701 #endif
702 return;
703 }
704
705 new_name = name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
706
707 reg_number = decode_reg_name (asmspec);
708 if (reg_number == -2)
709 {
710 /* ASMSPEC is given, and not the name of a register. Mark the
711 name with a star so assemble_name won't munge it. */
712 char *starred = alloca (strlen (asmspec) + 2);
713 starred[0] = '*';
714 strcpy (starred + 1, asmspec);
715 new_name = starred;
716 }
717
718 if (TREE_CODE (decl) != FUNCTION_DECL && DECL_REGISTER (decl))
719 {
720 /* First detect errors in declaring global registers. */
721 if (reg_number == -1)
722 error_with_decl (decl, "register name not specified for `%s'");
723 else if (reg_number < 0)
724 error_with_decl (decl, "invalid register name for `%s'");
725 else if (TYPE_MODE (TREE_TYPE (decl)) == BLKmode)
726 error_with_decl (decl,
727 "data type of `%s' isn't suitable for a register");
728 else if (! HARD_REGNO_MODE_OK (reg_number, TYPE_MODE (TREE_TYPE (decl))))
729 error_with_decl (decl,
730 "register specified for `%s' isn't suitable for data type");
731 /* Now handle properly declared static register variables. */
732 else
733 {
734 int nregs;
735
736 if (DECL_INITIAL (decl) != 0 && top_level)
737 {
738 DECL_INITIAL (decl) = 0;
739 error ("global register variable has initial value");
740 }
741 if (TREE_THIS_VOLATILE (decl))
742 warning ("volatile register variables don't work as you might wish");
743
744 /* If the user specified one of the eliminables registers here,
745 e.g., FRAME_POINTER_REGNUM, we don't want to get this variable
746 confused with that register and be eliminated. Although this
747 usage is somewhat suspect, we nevertheless use the following
748 kludge to avoid setting DECL_RTL to frame_pointer_rtx. */
749
750 DECL_RTL (decl)
751 = gen_rtx_REG (DECL_MODE (decl), FIRST_PSEUDO_REGISTER);
752 REGNO (DECL_RTL (decl)) = reg_number;
753 REG_USERVAR_P (DECL_RTL (decl)) = 1;
754
755 if (top_level)
756 {
757 /* Make this register global, so not usable for anything
758 else. */
759 #ifdef ASM_DECLARE_REGISTER_GLOBAL
760 ASM_DECLARE_REGISTER_GLOBAL (asm_out_file, decl, reg_number, name);
761 #endif
762 nregs = HARD_REGNO_NREGS (reg_number, DECL_MODE (decl));
763 while (nregs > 0)
764 globalize_reg (reg_number + --nregs);
765 }
766
767 /* As a register variable, it has no section. */
768 return;
769 }
770 }
771
772 /* Now handle ordinary static variables and functions (in memory).
773 Also handle vars declared register invalidly. */
774
775 if (reg_number >= 0 || reg_number == -3)
776 error_with_decl (decl,
777 "register name given for non-register variable `%s'");
778
779 /* Specifying a section attribute on a variable forces it into a
780 non-.bss section, and thus it cannot be common. */
781 if (TREE_CODE (decl) == VAR_DECL
782 && DECL_SECTION_NAME (decl) != NULL_TREE
783 && DECL_INITIAL (decl) == NULL_TREE
784 && DECL_COMMON (decl))
785 DECL_COMMON (decl) = 0;
786
787 /* Can't use just the variable's own name for a variable
788 whose scope is less than the whole file, unless it's a member
789 of a local class (which will already be unambiguous).
790 Concatenate a distinguishing number. */
791 if (!top_level && !TREE_PUBLIC (decl)
792 && ! (DECL_CONTEXT (decl) && TYPE_P (DECL_CONTEXT (decl)))
793 && asmspec == 0)
794 {
795 char *label;
796 ASM_FORMAT_PRIVATE_NAME (label, name, var_labelno);
797 var_labelno++;
798 new_name = label;
799 }
800
801 /* When -fprefix-function-name is used, the functions
802 names are prefixed. Only nested function names are not
803 prefixed. */
804 else if (flag_prefix_function_name && TREE_CODE (decl) == FUNCTION_DECL)
805 {
806 size_t name_len = IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (decl));
807 char *pname;
808
809 pname = alloca (name_len + CHKR_PREFIX_SIZE + 1);
810 memcpy (pname, CHKR_PREFIX, CHKR_PREFIX_SIZE);
811 memcpy (pname + CHKR_PREFIX_SIZE, name, name_len + 1);
812 new_name = pname;
813 }
814
815 if (name != new_name)
816 {
817 DECL_ASSEMBLER_NAME (decl) = get_identifier (new_name);
818 name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
819 }
820
821 /* If this variable is to be treated as volatile, show its
822 tree node has side effects. */
823 if ((flag_volatile_global && TREE_CODE (decl) == VAR_DECL
824 && TREE_PUBLIC (decl))
825 || ((flag_volatile_static && TREE_CODE (decl) == VAR_DECL
826 && (TREE_PUBLIC (decl) || TREE_STATIC (decl)))))
827 TREE_SIDE_EFFECTS (decl) = 1;
828
829 DECL_RTL (decl) = gen_rtx_MEM (DECL_MODE (decl),
830 gen_rtx_SYMBOL_REF (Pmode, name));
831 if (TREE_CODE (decl) != FUNCTION_DECL)
832 set_mem_attributes (DECL_RTL (decl), decl, 1);
833
834 /* Optionally set flags or add text to the name to record information
835 such as that it is a function name.
836 If the name is changed, the macro ASM_OUTPUT_LABELREF
837 will have to know how to strip this information. */
838 #ifdef ENCODE_SECTION_INFO
839 ENCODE_SECTION_INFO (decl);
840 #endif
841 }
842
843 /* Make the rtl for variable VAR be volatile.
844 Use this only for static variables. */
845
846 void
847 make_var_volatile (var)
848 tree var;
849 {
850 if (GET_CODE (DECL_RTL (var)) != MEM)
851 abort ();
852
853 MEM_VOLATILE_P (DECL_RTL (var)) = 1;
854 }
855 \f
856 /* Output alignment directive to align for constant expression EXP. */
857
858 void
859 assemble_constant_align (exp)
860 tree exp;
861 {
862 int align;
863
864 /* Align the location counter as required by EXP's data type. */
865 align = TYPE_ALIGN (TREE_TYPE (exp));
866 #ifdef CONSTANT_ALIGNMENT
867 align = CONSTANT_ALIGNMENT (exp, align);
868 #endif
869
870 if (align > BITS_PER_UNIT)
871 ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT));
872 }
873
874 /* Output a string of literal assembler code
875 for an `asm' keyword used between functions. */
876
877 void
878 assemble_asm (string)
879 tree string;
880 {
881 app_enable ();
882
883 if (TREE_CODE (string) == ADDR_EXPR)
884 string = TREE_OPERAND (string, 0);
885
886 fprintf (asm_out_file, "\t%s\n", TREE_STRING_POINTER (string));
887 }
888
889 #if 0 /* This should no longer be needed, because
890 flag_gnu_linker should be 0 on these systems,
891 which should prevent any output
892 if ASM_OUTPUT_CONSTRUCTOR and ASM_OUTPUT_DESTRUCTOR are absent. */
893 #if !(defined(DBX_DEBUGGING_INFO) && !defined(FASCIST_ASSEMBLER))
894 #ifndef ASM_OUTPUT_CONSTRUCTOR
895 #define ASM_OUTPUT_CONSTRUCTOR(file, name)
896 #endif
897 #ifndef ASM_OUTPUT_DESTRUCTOR
898 #define ASM_OUTPUT_DESTRUCTOR(file, name)
899 #endif
900 #endif
901 #endif /* 0 */
902
903 /* Record an element in the table of global destructors.
904 How this is done depends on what sort of assembler and linker
905 are in use.
906
907 NAME should be the name of a global function to be called
908 at exit time. This name is output using assemble_name. */
909
910 void
911 assemble_destructor (name)
912 const char *name;
913 {
914 #ifdef ASM_OUTPUT_DESTRUCTOR
915 ASM_OUTPUT_DESTRUCTOR (asm_out_file, name);
916 #else
917 if (flag_gnu_linker)
918 {
919 /* Now tell GNU LD that this is part of the static destructor set. */
920 /* This code works for any machine provided you use GNU as/ld. */
921 fprintf (asm_out_file, "%s\"___DTOR_LIST__\",22,0,0,", ASM_STABS_OP);
922 assemble_name (asm_out_file, name);
923 fputc ('\n', asm_out_file);
924 }
925 #endif
926 }
927
928 /* Likewise for global constructors. */
929
930 void
931 assemble_constructor (name)
932 const char *name;
933 {
934 #ifdef ASM_OUTPUT_CONSTRUCTOR
935 ASM_OUTPUT_CONSTRUCTOR (asm_out_file, name);
936 #else
937 if (flag_gnu_linker)
938 {
939 /* Now tell GNU LD that this is part of the static constructor set. */
940 /* This code works for any machine provided you use GNU as/ld. */
941 fprintf (asm_out_file, "%s\"___CTOR_LIST__\",22,0,0,", ASM_STABS_OP);
942 assemble_name (asm_out_file, name);
943 fputc ('\n', asm_out_file);
944 }
945 #endif
946 }
947
948 /* Likewise for entries we want to record for garbage collection.
949 Garbage collection is still under development. */
950
951 void
952 assemble_gc_entry (name)
953 const char *name;
954 {
955 #ifdef ASM_OUTPUT_GC_ENTRY
956 ASM_OUTPUT_GC_ENTRY (asm_out_file, name);
957 #else
958 if (flag_gnu_linker)
959 {
960 /* Now tell GNU LD that this is part of the static constructor set. */
961 fprintf (asm_out_file, "%s\"___PTR_LIST__\",22,0,0,", ASM_STABS_OP);
962 assemble_name (asm_out_file, name);
963 fputc ('\n', asm_out_file);
964 }
965 #endif
966 }
967 \f
968 /* CONSTANT_POOL_BEFORE_FUNCTION may be defined as an expression with
969 a non-zero value if the constant pool should be output before the
970 start of the function, or a zero value if the pool should output
971 after the end of the function. The default is to put it before the
972 start. */
973
974 #ifndef CONSTANT_POOL_BEFORE_FUNCTION
975 #define CONSTANT_POOL_BEFORE_FUNCTION 1
976 #endif
977
978 /* Output assembler code for the constant pool of a function and associated
979 with defining the name of the function. DECL describes the function.
980 NAME is the function's name. For the constant pool, we use the current
981 constant pool data. */
982
983 void
984 assemble_start_function (decl, fnname)
985 tree decl;
986 const char *fnname;
987 {
988 int align;
989
990 /* The following code does not need preprocessing in the assembler. */
991
992 app_disable ();
993
994 if (CONSTANT_POOL_BEFORE_FUNCTION)
995 output_constant_pool (fnname, decl);
996
997 #ifdef ASM_OUTPUT_SECTION_NAME
998 /* If the function is to be put in its own section and it's not in a section
999 already, indicate so. */
1000 if ((flag_function_sections
1001 && DECL_SECTION_NAME (decl) == NULL_TREE)
1002 || UNIQUE_SECTION_P (decl))
1003 UNIQUE_SECTION (decl, 0);
1004 #endif
1005
1006 function_section (decl);
1007
1008 /* Tell assembler to move to target machine's alignment for functions. */
1009 align = floor_log2 (FUNCTION_BOUNDARY / BITS_PER_UNIT);
1010 if (align > 0)
1011 ASM_OUTPUT_ALIGN (asm_out_file, align);
1012
1013 /* Handle a user-specified function alignment.
1014 Note that we still need to align to FUNCTION_BOUNDARY, as above,
1015 because ASM_OUTPUT_MAX_SKIP_ALIGN might not do any alignment at all. */
1016 if (align_functions_log > align)
1017 {
1018 #ifdef ASM_OUTPUT_MAX_SKIP_ALIGN
1019 ASM_OUTPUT_MAX_SKIP_ALIGN (asm_out_file,
1020 align_functions_log, align_functions-1);
1021 #else
1022 ASM_OUTPUT_ALIGN (asm_out_file, align_functions_log);
1023 #endif
1024 }
1025
1026 #ifdef ASM_OUTPUT_FUNCTION_PREFIX
1027 ASM_OUTPUT_FUNCTION_PREFIX (asm_out_file, fnname);
1028 #endif
1029
1030 #ifdef SDB_DEBUGGING_INFO
1031 /* Output SDB definition of the function. */
1032 if (write_symbols == SDB_DEBUG)
1033 sdbout_mark_begin_function ();
1034 #endif
1035
1036 #ifdef DBX_DEBUGGING_INFO
1037 /* Output DBX definition of the function. */
1038 if (write_symbols == DBX_DEBUG)
1039 dbxout_begin_function (decl);
1040 #endif
1041
1042 /* Make function name accessible from other files, if appropriate. */
1043
1044 if (TREE_PUBLIC (decl))
1045 {
1046 if (! first_global_object_name)
1047 {
1048 const char *p;
1049 char *name;
1050
1051 STRIP_NAME_ENCODING (p, fnname);
1052 name = permalloc (strlen (p) + 1);
1053 strcpy (name, p);
1054
1055 if (! DECL_WEAK (decl) && ! DECL_ONE_ONLY (decl))
1056 first_global_object_name = name;
1057 else
1058 weak_global_object_name = name;
1059 }
1060
1061 #ifdef ASM_WEAKEN_LABEL
1062 if (DECL_WEAK (decl))
1063 {
1064 ASM_WEAKEN_LABEL (asm_out_file, fnname);
1065 /* Remove this function from the pending weak list so that
1066 we do not emit multiple .weak directives for it. */
1067 remove_from_pending_weak_list
1068 (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
1069 }
1070 else
1071 #endif
1072 ASM_GLOBALIZE_LABEL (asm_out_file, fnname);
1073 }
1074
1075 /* Do any machine/system dependent processing of the function name */
1076 #ifdef ASM_DECLARE_FUNCTION_NAME
1077 ASM_DECLARE_FUNCTION_NAME (asm_out_file, fnname, current_function_decl);
1078 #else
1079 /* Standard thing is just output label for the function. */
1080 ASM_OUTPUT_LABEL (asm_out_file, fnname);
1081 #endif /* ASM_DECLARE_FUNCTION_NAME */
1082 }
1083
1084 /* Output assembler code associated with defining the size of the
1085 function. DECL describes the function. NAME is the function's name. */
1086
1087 void
1088 assemble_end_function (decl, fnname)
1089 tree decl;
1090 const char *fnname;
1091 {
1092 #ifdef ASM_DECLARE_FUNCTION_SIZE
1093 ASM_DECLARE_FUNCTION_SIZE (asm_out_file, fnname, decl);
1094 #endif
1095 if (! CONSTANT_POOL_BEFORE_FUNCTION)
1096 {
1097 output_constant_pool (fnname, decl);
1098 function_section (decl); /* need to switch back */
1099 }
1100
1101 /* Output any constants which should appear after the function. */
1102 output_after_function_constants ();
1103 }
1104 \f
1105 /* Assemble code to leave SIZE bytes of zeros. */
1106
1107 void
1108 assemble_zeros (size)
1109 int size;
1110 {
1111 /* Do no output if -fsyntax-only. */
1112 if (flag_syntax_only)
1113 return;
1114
1115 #ifdef ASM_NO_SKIP_IN_TEXT
1116 /* The `space' pseudo in the text section outputs nop insns rather than 0s,
1117 so we must output 0s explicitly in the text section. */
1118 if (ASM_NO_SKIP_IN_TEXT && in_text_section ())
1119 {
1120 int i;
1121
1122 for (i = 0; i < size - 20; i += 20)
1123 {
1124 #ifdef ASM_BYTE_OP
1125 fprintf (asm_out_file,
1126 "%s0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n", ASM_BYTE_OP);
1127 #else
1128 fprintf (asm_out_file,
1129 "\tbyte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n");
1130 #endif
1131 }
1132 if (i < size)
1133 {
1134 #ifdef ASM_BYTE_OP
1135 fprintf (asm_out_file, "%s0", ASM_BYTE_OP);
1136 #else
1137 fprintf (asm_out_file, "\tbyte 0");
1138 #endif
1139 i++;
1140 for (; i < size; i++)
1141 fprintf (asm_out_file, ",0");
1142 fprintf (asm_out_file, "\n");
1143 }
1144 }
1145 else
1146 #endif
1147 if (size > 0)
1148 ASM_OUTPUT_SKIP (asm_out_file, size);
1149 }
1150
1151 /* Assemble an alignment pseudo op for an ALIGN-bit boundary. */
1152
1153 void
1154 assemble_align (align)
1155 int align;
1156 {
1157 if (align > BITS_PER_UNIT)
1158 ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT));
1159 }
1160
1161 /* Assemble a string constant with the specified C string as contents. */
1162
1163 void
1164 assemble_string (p, size)
1165 const char *p;
1166 int size;
1167 {
1168 int pos = 0;
1169 int maximum = 2000;
1170
1171 /* If the string is very long, split it up. */
1172
1173 while (pos < size)
1174 {
1175 int thissize = size - pos;
1176 if (thissize > maximum)
1177 thissize = maximum;
1178
1179 ASM_OUTPUT_ASCII (asm_out_file, p, thissize);
1180
1181 pos += thissize;
1182 p += thissize;
1183 }
1184 }
1185
1186 \f
1187 #if defined ASM_OUTPUT_ALIGNED_DECL_LOCAL
1188 #define ASM_EMIT_LOCAL(decl, name, size, rounded) \
1189 ASM_OUTPUT_ALIGNED_DECL_LOCAL (asm_out_file, decl, name, size, DECL_ALIGN (decl))
1190 #else
1191 #if defined ASM_OUTPUT_ALIGNED_LOCAL
1192 #define ASM_EMIT_LOCAL(decl, name, size, rounded) \
1193 ASM_OUTPUT_ALIGNED_LOCAL (asm_out_file, name, size, DECL_ALIGN (decl))
1194 #else
1195 #define ASM_EMIT_LOCAL(decl, name, size, rounded) \
1196 ASM_OUTPUT_LOCAL (asm_out_file, name, size, rounded)
1197 #endif
1198 #endif
1199
1200 #if defined ASM_OUTPUT_ALIGNED_BSS
1201 #define ASM_EMIT_BSS(decl, name, size, rounded) \
1202 ASM_OUTPUT_ALIGNED_BSS (asm_out_file, decl, name, size, DECL_ALIGN (decl))
1203 #else
1204 #if defined ASM_OUTPUT_BSS
1205 #define ASM_EMIT_BSS(decl, name, size, rounded) \
1206 ASM_OUTPUT_BSS (asm_out_file, decl, name, size, rounded)
1207 #else
1208 #undef ASM_EMIT_BSS
1209 #endif
1210 #endif
1211
1212 #if defined ASM_OUTPUT_ALIGNED_DECL_COMMON
1213 #define ASM_EMIT_COMMON(decl, name, size, rounded) \
1214 ASM_OUTPUT_ALIGNED_DECL_COMMON (asm_out_file, decl, name, size, DECL_ALIGN (decl))
1215 #else
1216 #if defined ASM_OUTPUT_ALIGNED_COMMON
1217 #define ASM_EMIT_COMMON(decl, name, size, rounded) \
1218 ASM_OUTPUT_ALIGNED_COMMON (asm_out_file, name, size, DECL_ALIGN (decl))
1219 #else
1220 #define ASM_EMIT_COMMON(decl, name, size, rounded) \
1221 ASM_OUTPUT_COMMON (asm_out_file, name, size, rounded)
1222 #endif
1223 #endif
1224
1225 static void
1226 asm_emit_uninitialised (decl, name, size, rounded)
1227 tree decl;
1228 const char * name;
1229 int size ATTRIBUTE_UNUSED;
1230 int rounded ATTRIBUTE_UNUSED;
1231 {
1232 enum
1233 {
1234 asm_dest_common,
1235 asm_dest_bss,
1236 asm_dest_local
1237 }
1238 destination = asm_dest_local;
1239
1240 if (TREE_PUBLIC (decl))
1241 {
1242 #if defined ASM_EMIT_BSS
1243 if (! DECL_COMMON (decl))
1244 destination = asm_dest_bss;
1245 else
1246 #endif
1247 destination = asm_dest_common;
1248 }
1249
1250 if (flag_shared_data)
1251 {
1252 switch (destination)
1253 {
1254 #ifdef ASM_OUTPUT_SHARED_BSS
1255 case asm_dest_bss:
1256 ASM_OUTPUT_SHARED_BSS (asm_out_file, decl, name, size, rounded);
1257 return;
1258 #endif
1259 #ifdef ASM_OUTPUT_SHARED_COMMON
1260 case asm_dest_common:
1261 ASM_OUTPUT_SHARED_COMMON (asm_out_file, name, size, rounded);
1262 return;
1263 #endif
1264 #ifdef ASM_OUTPUT_SHARED_LOCAL
1265 case asm_dest_local:
1266 ASM_OUTPUT_SHARED_LOCAL (asm_out_file, name, size, rounded);
1267 return;
1268 #endif
1269 default:
1270 break;
1271 }
1272 }
1273
1274 #ifdef ASM_OUTPUT_SECTION_NAME
1275 /* We already know that DECL_SECTION_NAME() == NULL. */
1276 if (flag_data_sections != 0 || UNIQUE_SECTION_P (decl))
1277 UNIQUE_SECTION (decl, 0);
1278 #endif
1279
1280 switch (destination)
1281 {
1282 #ifdef ASM_EMIT_BSS
1283 case asm_dest_bss:
1284 ASM_EMIT_BSS (decl, name, size, rounded);
1285 break;
1286 #endif
1287 case asm_dest_common:
1288 ASM_EMIT_COMMON (decl, name, size, rounded);
1289 break;
1290 case asm_dest_local:
1291 ASM_EMIT_LOCAL (decl, name, size, rounded);
1292 break;
1293 default:
1294 abort ();
1295 }
1296
1297 return;
1298 }
1299
1300 /* Assemble everything that is needed for a variable or function declaration.
1301 Not used for automatic variables, and not used for function definitions.
1302 Should not be called for variables of incomplete structure type.
1303
1304 TOP_LEVEL is nonzero if this variable has file scope.
1305 AT_END is nonzero if this is the special handling, at end of compilation,
1306 to define things that have had only tentative definitions.
1307 DONT_OUTPUT_DATA if nonzero means don't actually output the
1308 initial value (that will be done by the caller). */
1309
1310 void
1311 assemble_variable (decl, top_level, at_end, dont_output_data)
1312 tree decl;
1313 int top_level ATTRIBUTE_UNUSED;
1314 int at_end ATTRIBUTE_UNUSED;
1315 int dont_output_data;
1316 {
1317 register const char *name;
1318 unsigned int align;
1319 int reloc = 0;
1320 enum in_section saved_in_section;
1321
1322 last_assemble_variable_decl = 0;
1323
1324 if (GET_CODE (DECL_RTL (decl)) == REG)
1325 {
1326 /* Do output symbol info for global register variables, but do nothing
1327 else for them. */
1328
1329 if (TREE_ASM_WRITTEN (decl))
1330 return;
1331 TREE_ASM_WRITTEN (decl) = 1;
1332
1333 /* Do no output if -fsyntax-only. */
1334 if (flag_syntax_only)
1335 return;
1336
1337 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
1338 /* File-scope global variables are output here. */
1339 if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
1340 && top_level)
1341 dbxout_symbol (decl, 0);
1342 #endif
1343 #ifdef SDB_DEBUGGING_INFO
1344 if (write_symbols == SDB_DEBUG && top_level
1345 /* Leave initialized global vars for end of compilation;
1346 see comment in compile_file. */
1347 && (TREE_PUBLIC (decl) == 0 || DECL_INITIAL (decl) == 0))
1348 sdbout_symbol (decl, 0);
1349 #endif
1350
1351 /* Don't output any DWARF debugging information for variables here.
1352 In the case of local variables, the information for them is output
1353 when we do our recursive traversal of the tree representation for
1354 the entire containing function. In the case of file-scope variables,
1355 we output information for all of them at the very end of compilation
1356 while we are doing our final traversal of the chain of file-scope
1357 declarations. */
1358
1359 return;
1360 }
1361
1362 /* Normally no need to say anything here for external references,
1363 since assemble_external is called by the language-specific code
1364 when a declaration is first seen. */
1365
1366 if (DECL_EXTERNAL (decl))
1367 return;
1368
1369 /* Output no assembler code for a function declaration.
1370 Only definitions of functions output anything. */
1371
1372 if (TREE_CODE (decl) == FUNCTION_DECL)
1373 return;
1374
1375 /* If type was incomplete when the variable was declared,
1376 see if it is complete now. */
1377
1378 if (DECL_SIZE (decl) == 0)
1379 layout_decl (decl, 0);
1380
1381 /* Still incomplete => don't allocate it; treat the tentative defn
1382 (which is what it must have been) as an `extern' reference. */
1383
1384 if (!dont_output_data && DECL_SIZE (decl) == 0)
1385 {
1386 error_with_file_and_line (DECL_SOURCE_FILE (decl),
1387 DECL_SOURCE_LINE (decl),
1388 "storage size of `%s' isn't known",
1389 IDENTIFIER_POINTER (DECL_NAME (decl)));
1390 TREE_ASM_WRITTEN (decl) = 1;
1391 return;
1392 }
1393
1394 /* The first declaration of a variable that comes through this function
1395 decides whether it is global (in C, has external linkage)
1396 or local (in C, has internal linkage). So do nothing more
1397 if this function has already run. */
1398
1399 if (TREE_ASM_WRITTEN (decl))
1400 return;
1401
1402 TREE_ASM_WRITTEN (decl) = 1;
1403
1404 /* Do no output if -fsyntax-only. */
1405 if (flag_syntax_only)
1406 return;
1407
1408 app_disable ();
1409
1410 if (! dont_output_data
1411 && ! host_integerp (DECL_SIZE_UNIT (decl), 1))
1412 {
1413 error_with_decl (decl, "size of variable `%s' is too large");
1414 goto finish;
1415 }
1416
1417 name = XSTR (XEXP (DECL_RTL (decl), 0), 0);
1418 if (TREE_PUBLIC (decl) && DECL_NAME (decl)
1419 && ! first_global_object_name
1420 && ! (DECL_COMMON (decl) && (DECL_INITIAL (decl) == 0
1421 || DECL_INITIAL (decl) == error_mark_node))
1422 && ! DECL_WEAK (decl)
1423 && ! DECL_ONE_ONLY (decl))
1424 {
1425 const char *p;
1426 char *xname;
1427
1428 STRIP_NAME_ENCODING (p, name);
1429 xname = permalloc (strlen (p) + 1);
1430 strcpy (xname, p);
1431 first_global_object_name = xname;
1432 }
1433
1434 /* Compute the alignment of this data. */
1435
1436 align = DECL_ALIGN (decl);
1437
1438 /* In the case for initialing an array whose length isn't specified,
1439 where we have not yet been able to do the layout,
1440 figure out the proper alignment now. */
1441 if (dont_output_data && DECL_SIZE (decl) == 0
1442 && TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE)
1443 align = MAX (align, TYPE_ALIGN (TREE_TYPE (TREE_TYPE (decl))));
1444
1445 /* Some object file formats have a maximum alignment which they support.
1446 In particular, a.out format supports a maximum alignment of 4. */
1447 #ifndef MAX_OFILE_ALIGNMENT
1448 #define MAX_OFILE_ALIGNMENT BIGGEST_ALIGNMENT
1449 #endif
1450 if (align > MAX_OFILE_ALIGNMENT)
1451 {
1452 warning_with_decl (decl,
1453 "alignment of `%s' is greater than maximum object file alignment. Using %d.",
1454 MAX_OFILE_ALIGNMENT/BITS_PER_UNIT);
1455 align = MAX_OFILE_ALIGNMENT;
1456 }
1457
1458 /* On some machines, it is good to increase alignment sometimes. */
1459 #ifdef DATA_ALIGNMENT
1460 align = DATA_ALIGNMENT (TREE_TYPE (decl), align);
1461 #endif
1462 #ifdef CONSTANT_ALIGNMENT
1463 if (DECL_INITIAL (decl) != 0 && DECL_INITIAL (decl) != error_mark_node)
1464 align = CONSTANT_ALIGNMENT (DECL_INITIAL (decl), align);
1465 #endif
1466
1467 /* Reset the alignment in case we have made it tighter, so we can benefit
1468 from it in get_pointer_alignment. */
1469 DECL_ALIGN (decl) = align;
1470
1471 /* Handle uninitialized definitions. */
1472
1473 if ((DECL_INITIAL (decl) == 0 || DECL_INITIAL (decl) == error_mark_node)
1474 /* If the target can't output uninitialized but not common global data
1475 in .bss, then we have to use .data. */
1476 #if ! defined ASM_EMIT_BSS
1477 && DECL_COMMON (decl)
1478 #endif
1479 && DECL_SECTION_NAME (decl) == NULL_TREE
1480 && ! dont_output_data)
1481 {
1482 unsigned HOST_WIDE_INT size = tree_low_cst (DECL_SIZE_UNIT (decl), 1);
1483 unsigned HOST_WIDE_INT rounded = size;
1484
1485 /* Don't allocate zero bytes of common,
1486 since that means "undefined external" in the linker. */
1487 if (size == 0)
1488 rounded = 1;
1489
1490 /* Round size up to multiple of BIGGEST_ALIGNMENT bits
1491 so that each uninitialized object starts on such a boundary. */
1492 rounded += (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - 1;
1493 rounded = (rounded / (BIGGEST_ALIGNMENT / BITS_PER_UNIT)
1494 * (BIGGEST_ALIGNMENT / BITS_PER_UNIT));
1495
1496 /* Don't continue this line--convex cc version 4.1 would lose. */
1497 #if !defined(ASM_OUTPUT_ALIGNED_COMMON) && !defined(ASM_OUTPUT_ALIGNED_DECL_COMMON) && !defined(ASM_OUTPUT_ALIGNED_BSS)
1498 if ((unsigned HOST_WIDE_INT) DECL_ALIGN (decl) / BITS_PER_UNIT > rounded)
1499 warning_with_decl
1500 (decl, "requested alignment for %s is greater than implemented alignment of %d.",rounded);
1501 #endif
1502
1503 #ifdef DBX_DEBUGGING_INFO
1504 /* File-scope global variables are output here. */
1505 if (write_symbols == DBX_DEBUG && top_level)
1506 dbxout_symbol (decl, 0);
1507 #endif
1508 #ifdef SDB_DEBUGGING_INFO
1509 if (write_symbols == SDB_DEBUG && top_level
1510 /* Leave initialized global vars for end of compilation;
1511 see comment in compile_file. */
1512 && (TREE_PUBLIC (decl) == 0 || DECL_INITIAL (decl) == 0))
1513 sdbout_symbol (decl, 0);
1514 #endif
1515
1516 /* Don't output any DWARF debugging information for variables here.
1517 In the case of local variables, the information for them is output
1518 when we do our recursive traversal of the tree representation for
1519 the entire containing function. In the case of file-scope variables,
1520 we output information for all of them at the very end of compilation
1521 while we are doing our final traversal of the chain of file-scope
1522 declarations. */
1523
1524 #if 0 /* ??? We should either delete this or add a comment describing what
1525 it was intended to do and why we shouldn't delete it. */
1526 if (flag_shared_data)
1527 data_section ();
1528 #endif
1529 asm_emit_uninitialised (decl, name, size, rounded);
1530
1531 goto finish;
1532 }
1533
1534 /* Handle initialized definitions.
1535 Also handle uninitialized global definitions if -fno-common and the
1536 target doesn't support ASM_OUTPUT_BSS. */
1537
1538 /* First make the assembler name(s) global if appropriate. */
1539 if (TREE_PUBLIC (decl) && DECL_NAME (decl))
1540 {
1541 #ifdef ASM_WEAKEN_LABEL
1542 if (DECL_WEAK (decl))
1543 {
1544 ASM_WEAKEN_LABEL (asm_out_file, name);
1545 /* Remove this variable from the pending weak list so that
1546 we do not emit multiple .weak directives for it. */
1547 remove_from_pending_weak_list
1548 (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
1549 }
1550 else
1551 #endif
1552 ASM_GLOBALIZE_LABEL (asm_out_file, name);
1553 }
1554 #if 0
1555 for (d = equivalents; d; d = TREE_CHAIN (d))
1556 {
1557 tree e = TREE_VALUE (d);
1558 if (TREE_PUBLIC (e) && DECL_NAME (e))
1559 ASM_GLOBALIZE_LABEL (asm_out_file,
1560 XSTR (XEXP (DECL_RTL (e), 0), 0));
1561 }
1562 #endif
1563
1564 /* Output any data that we will need to use the address of. */
1565 if (DECL_INITIAL (decl) == error_mark_node)
1566 reloc = contains_pointers_p (TREE_TYPE (decl));
1567 else if (DECL_INITIAL (decl))
1568 reloc = output_addressed_constants (DECL_INITIAL (decl));
1569
1570 #ifdef ASM_OUTPUT_SECTION_NAME
1571 if ((flag_data_sections != 0 && DECL_SECTION_NAME (decl) == NULL_TREE)
1572 || UNIQUE_SECTION_P (decl))
1573 UNIQUE_SECTION (decl, reloc);
1574 #endif
1575
1576 /* Switch to the appropriate section. */
1577 variable_section (decl, reloc);
1578
1579 /* dbxout.c needs to know this. */
1580 if (in_text_section ())
1581 DECL_IN_TEXT_SECTION (decl) = 1;
1582
1583 /* Record current section so we can restore it if dbxout.c clobbers it. */
1584 saved_in_section = in_section;
1585
1586 /* Output the dbx info now that we have chosen the section. */
1587
1588 #ifdef DBX_DEBUGGING_INFO
1589 /* File-scope global variables are output here. */
1590 if (write_symbols == DBX_DEBUG && top_level)
1591 dbxout_symbol (decl, 0);
1592 #endif
1593 #ifdef SDB_DEBUGGING_INFO
1594 if (write_symbols == SDB_DEBUG && top_level
1595 /* Leave initialized global vars for end of compilation;
1596 see comment in compile_file. */
1597 && (TREE_PUBLIC (decl) == 0 || DECL_INITIAL (decl) == 0))
1598 sdbout_symbol (decl, 0);
1599 #endif
1600
1601 /* Don't output any DWARF debugging information for variables here.
1602 In the case of local variables, the information for them is output
1603 when we do our recursive traversal of the tree representation for
1604 the entire containing function. In the case of file-scope variables,
1605 we output information for all of them at the very end of compilation
1606 while we are doing our final traversal of the chain of file-scope
1607 declarations. */
1608
1609 /* If the debugging output changed sections, reselect the section
1610 that's supposed to be selected. */
1611 if (in_section != saved_in_section)
1612 variable_section (decl, reloc);
1613
1614 /* Output the alignment of this data. */
1615 if (align > BITS_PER_UNIT)
1616 ASM_OUTPUT_ALIGN (asm_out_file,
1617 floor_log2 (DECL_ALIGN (decl) / BITS_PER_UNIT));
1618
1619 /* Do any machine/system dependent processing of the object. */
1620 #ifdef ASM_DECLARE_OBJECT_NAME
1621 last_assemble_variable_decl = decl;
1622 ASM_DECLARE_OBJECT_NAME (asm_out_file, name, decl);
1623 #else
1624 /* Standard thing is just output label for the object. */
1625 ASM_OUTPUT_LABEL (asm_out_file, name);
1626 #endif /* ASM_DECLARE_OBJECT_NAME */
1627
1628 if (!dont_output_data)
1629 {
1630 if (DECL_INITIAL (decl))
1631 /* Output the actual data. */
1632 output_constant (DECL_INITIAL (decl),
1633 tree_low_cst (DECL_SIZE_UNIT (decl), 1));
1634 else
1635 /* Leave space for it. */
1636 assemble_zeros (tree_low_cst (DECL_SIZE_UNIT (decl), 1));
1637 }
1638
1639 finish:
1640 #ifdef XCOFF_DEBUGGING_INFO
1641 /* Unfortunately, the IBM assembler cannot handle stabx before the actual
1642 declaration. When something like ".stabx "aa:S-2",aa,133,0" is emitted
1643 and `aa' hasn't been output yet, the assembler generates a stab entry with
1644 a value of zero, in addition to creating an unnecessary external entry
1645 for `aa'. Hence, we must postpone dbxout_symbol to here at the end. */
1646
1647 /* File-scope global variables are output here. */
1648 if (write_symbols == XCOFF_DEBUG && top_level)
1649 {
1650 saved_in_section = in_section;
1651
1652 dbxout_symbol (decl, 0);
1653
1654 if (in_section != saved_in_section)
1655 variable_section (decl, reloc);
1656 }
1657 #else
1658 /* There must be a statement after a label. */
1659 ;
1660 #endif
1661 }
1662
1663 /* Return 1 if type TYPE contains any pointers. */
1664
1665 static int
1666 contains_pointers_p (type)
1667 tree type;
1668 {
1669 switch (TREE_CODE (type))
1670 {
1671 case POINTER_TYPE:
1672 case REFERENCE_TYPE:
1673 /* I'm not sure whether OFFSET_TYPE needs this treatment,
1674 so I'll play safe and return 1. */
1675 case OFFSET_TYPE:
1676 return 1;
1677
1678 case RECORD_TYPE:
1679 case UNION_TYPE:
1680 case QUAL_UNION_TYPE:
1681 {
1682 tree fields;
1683 /* For a type that has fields, see if the fields have pointers. */
1684 for (fields = TYPE_FIELDS (type); fields; fields = TREE_CHAIN (fields))
1685 if (TREE_CODE (fields) == FIELD_DECL
1686 && contains_pointers_p (TREE_TYPE (fields)))
1687 return 1;
1688 return 0;
1689 }
1690
1691 case ARRAY_TYPE:
1692 /* An array type contains pointers if its element type does. */
1693 return contains_pointers_p (TREE_TYPE (type));
1694
1695 default:
1696 return 0;
1697 }
1698 }
1699
1700 /* Output something to declare an external symbol to the assembler.
1701 (Most assemblers don't need this, so we normally output nothing.)
1702 Do nothing if DECL is not external. */
1703
1704 void
1705 assemble_external (decl)
1706 tree decl ATTRIBUTE_UNUSED;
1707 {
1708 #ifdef ASM_OUTPUT_EXTERNAL
1709 if (DECL_P (decl) && DECL_EXTERNAL (decl) && TREE_PUBLIC (decl))
1710 {
1711 rtx rtl = DECL_RTL (decl);
1712
1713 if (GET_CODE (rtl) == MEM && GET_CODE (XEXP (rtl, 0)) == SYMBOL_REF
1714 && ! SYMBOL_REF_USED (XEXP (rtl, 0)))
1715 {
1716 /* Some systems do require some output. */
1717 SYMBOL_REF_USED (XEXP (rtl, 0)) = 1;
1718 ASM_OUTPUT_EXTERNAL (asm_out_file, decl, XSTR (XEXP (rtl, 0), 0));
1719 }
1720 }
1721 #endif
1722 }
1723
1724 /* Similar, for calling a library function FUN. */
1725
1726 void
1727 assemble_external_libcall (fun)
1728 rtx fun ATTRIBUTE_UNUSED;
1729 {
1730 #ifdef ASM_OUTPUT_EXTERNAL_LIBCALL
1731 /* Declare library function name external when first used, if nec. */
1732 if (! SYMBOL_REF_USED (fun))
1733 {
1734 SYMBOL_REF_USED (fun) = 1;
1735 ASM_OUTPUT_EXTERNAL_LIBCALL (asm_out_file, fun);
1736 }
1737 #endif
1738 }
1739
1740 /* Declare the label NAME global. */
1741
1742 void
1743 assemble_global (name)
1744 const char *name;
1745 {
1746 ASM_GLOBALIZE_LABEL (asm_out_file, name);
1747 }
1748
1749 /* Assemble a label named NAME. */
1750
1751 void
1752 assemble_label (name)
1753 const char *name;
1754 {
1755 ASM_OUTPUT_LABEL (asm_out_file, name);
1756 }
1757
1758 /* Output to FILE a reference to the assembler name of a C-level name NAME.
1759 If NAME starts with a *, the rest of NAME is output verbatim.
1760 Otherwise NAME is transformed in an implementation-defined way
1761 (usually by the addition of an underscore).
1762 Many macros in the tm file are defined to call this function. */
1763
1764 void
1765 assemble_name (file, name)
1766 FILE *file;
1767 const char *name;
1768 {
1769 const char *real_name;
1770 tree id;
1771
1772 STRIP_NAME_ENCODING (real_name, name);
1773 if (flag_prefix_function_name
1774 && ! memcmp (real_name, CHKR_PREFIX, CHKR_PREFIX_SIZE))
1775 real_name = real_name + CHKR_PREFIX_SIZE;
1776
1777 id = maybe_get_identifier (real_name);
1778 if (id)
1779 TREE_SYMBOL_REFERENCED (id) = 1;
1780
1781 if (name[0] == '*')
1782 fputs (&name[1], file);
1783 else
1784 ASM_OUTPUT_LABELREF (file, name);
1785 }
1786
1787 /* Allocate SIZE bytes writable static space with a gensym name
1788 and return an RTX to refer to its address. */
1789
1790 rtx
1791 assemble_static_space (size)
1792 int size;
1793 {
1794 char name[12];
1795 char *namestring;
1796 rtx x;
1797
1798 #if 0
1799 if (flag_shared_data)
1800 data_section ();
1801 #endif
1802
1803 ASM_GENERATE_INTERNAL_LABEL (name, "LF", const_labelno);
1804 ++const_labelno;
1805 namestring = ggc_alloc_string (name, -1);
1806
1807 x = gen_rtx_SYMBOL_REF (Pmode, namestring);
1808
1809 #ifdef ASM_OUTPUT_ALIGNED_DECL_LOCAL
1810 ASM_OUTPUT_ALIGNED_DECL_LOCAL (asm_out_file, NULL_TREE, name, size,
1811 BIGGEST_ALIGNMENT);
1812 #else
1813 #ifdef ASM_OUTPUT_ALIGNED_LOCAL
1814 ASM_OUTPUT_ALIGNED_LOCAL (asm_out_file, name, size, BIGGEST_ALIGNMENT);
1815 #else
1816 {
1817 /* Round size up to multiple of BIGGEST_ALIGNMENT bits
1818 so that each uninitialized object starts on such a boundary. */
1819 /* Variable `rounded' might or might not be used in ASM_OUTPUT_LOCAL. */
1820 int rounded ATTRIBUTE_UNUSED
1821 = ((size + (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - 1)
1822 / (BIGGEST_ALIGNMENT / BITS_PER_UNIT)
1823 * (BIGGEST_ALIGNMENT / BITS_PER_UNIT));
1824 ASM_OUTPUT_LOCAL (asm_out_file, name, size, rounded);
1825 }
1826 #endif
1827 #endif
1828 return x;
1829 }
1830
1831 /* Assemble the static constant template for function entry trampolines.
1832 This is done at most once per compilation.
1833 Returns an RTX for the address of the template. */
1834
1835 #ifdef TRAMPOLINE_TEMPLATE
1836 rtx
1837 assemble_trampoline_template ()
1838 {
1839 char label[256];
1840 char *name;
1841 int align;
1842
1843 /* By default, put trampoline templates in read-only data section. */
1844
1845 #ifdef TRAMPOLINE_SECTION
1846 TRAMPOLINE_SECTION ();
1847 #else
1848 readonly_data_section ();
1849 #endif
1850
1851 /* Write the assembler code to define one. */
1852 align = floor_log2 (TRAMPOLINE_ALIGNMENT / BITS_PER_UNIT);
1853 if (align > 0)
1854 ASM_OUTPUT_ALIGN (asm_out_file, align);
1855
1856 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LTRAMP", 0);
1857 TRAMPOLINE_TEMPLATE (asm_out_file);
1858
1859 /* Record the rtl to refer to it. */
1860 ASM_GENERATE_INTERNAL_LABEL (label, "LTRAMP", 0);
1861 name = ggc_alloc_string (label, -1);
1862 return gen_rtx_SYMBOL_REF (Pmode, name);
1863 }
1864 #endif
1865 \f
1866 /* Assemble the integer constant X into an object of SIZE bytes.
1867 X must be either a CONST_INT or CONST_DOUBLE.
1868
1869 Return 1 if we were able to output the constant, otherwise 0. If FORCE is
1870 non-zero, abort if we can't output the constant. */
1871
1872 int
1873 assemble_integer (x, size, force)
1874 rtx x;
1875 int size;
1876 int force;
1877 {
1878 /* First try to use the standard 1, 2, 4, 8, and 16 byte
1879 ASM_OUTPUT... macros. */
1880
1881 switch (size)
1882 {
1883 #ifdef ASM_OUTPUT_CHAR
1884 case 1:
1885 ASM_OUTPUT_CHAR (asm_out_file, x);
1886 return 1;
1887 #endif
1888
1889 #ifdef ASM_OUTPUT_SHORT
1890 case 2:
1891 ASM_OUTPUT_SHORT (asm_out_file, x);
1892 return 1;
1893 #endif
1894
1895 #ifdef ASM_OUTPUT_INT
1896 case 4:
1897 ASM_OUTPUT_INT (asm_out_file, x);
1898 return 1;
1899 #endif
1900
1901 #ifdef ASM_OUTPUT_DOUBLE_INT
1902 case 8:
1903 ASM_OUTPUT_DOUBLE_INT (asm_out_file, x);
1904 return 1;
1905 #endif
1906
1907 #ifdef ASM_OUTPUT_QUADRUPLE_INT
1908 case 16:
1909 ASM_OUTPUT_QUADRUPLE_INT (asm_out_file, x);
1910 return 1;
1911 #endif
1912 }
1913
1914 /* If we couldn't do it that way, there are two other possibilities: First,
1915 if the machine can output an explicit byte and this is a 1 byte constant,
1916 we can use ASM_OUTPUT_BYTE. */
1917
1918 #ifdef ASM_OUTPUT_BYTE
1919 if (size == 1 && GET_CODE (x) == CONST_INT)
1920 {
1921 ASM_OUTPUT_BYTE (asm_out_file, INTVAL (x));
1922 return 1;
1923 }
1924 #endif
1925
1926 /* Finally, if SIZE is larger than a single word, try to output the constant
1927 one word at a time. */
1928
1929 if (size > UNITS_PER_WORD)
1930 {
1931 int i;
1932 enum machine_mode mode
1933 = mode_for_size (size * BITS_PER_UNIT, MODE_INT, 0);
1934 rtx word;
1935
1936 for (i = 0; i < size / UNITS_PER_WORD; i++)
1937 {
1938 word = operand_subword (x, i, 0, mode);
1939
1940 if (word == 0)
1941 break;
1942
1943 if (! assemble_integer (word, UNITS_PER_WORD, 0))
1944 break;
1945 }
1946
1947 if (i == size / UNITS_PER_WORD)
1948 return 1;
1949 /* If we output at least one word and then could not finish,
1950 there is no valid way to continue. */
1951 if (i > 0)
1952 abort ();
1953 }
1954
1955 if (force)
1956 abort ();
1957
1958 return 0;
1959 }
1960 \f
1961 /* Assemble the floating-point constant D into an object of size MODE. */
1962
1963 void
1964 assemble_real (d, mode)
1965 REAL_VALUE_TYPE d;
1966 enum machine_mode mode;
1967 {
1968 jmp_buf output_constant_handler;
1969
1970 if (setjmp (output_constant_handler))
1971 {
1972 error ("floating point trap outputting a constant");
1973 #ifdef REAL_IS_NOT_DOUBLE
1974 memset ((char *) &d, 0, sizeof d);
1975 d = dconst0;
1976 #else
1977 d = 0;
1978 #endif
1979 }
1980
1981 set_float_handler (output_constant_handler);
1982
1983 switch (mode)
1984 {
1985 #ifdef ASM_OUTPUT_BYTE_FLOAT
1986 case QFmode:
1987 ASM_OUTPUT_BYTE_FLOAT (asm_out_file, d);
1988 break;
1989 #endif
1990 #ifdef ASM_OUTPUT_SHORT_FLOAT
1991 case HFmode:
1992 ASM_OUTPUT_SHORT_FLOAT (asm_out_file, d);
1993 break;
1994 #endif
1995 #ifdef ASM_OUTPUT_THREE_QUARTER_FLOAT
1996 case TQFmode:
1997 ASM_OUTPUT_THREE_QUARTER_FLOAT (asm_out_file, d);
1998 break;
1999 #endif
2000 #ifdef ASM_OUTPUT_FLOAT
2001 case SFmode:
2002 ASM_OUTPUT_FLOAT (asm_out_file, d);
2003 break;
2004 #endif
2005
2006 #ifdef ASM_OUTPUT_DOUBLE
2007 case DFmode:
2008 ASM_OUTPUT_DOUBLE (asm_out_file, d);
2009 break;
2010 #endif
2011
2012 #ifdef ASM_OUTPUT_LONG_DOUBLE
2013 case XFmode:
2014 case TFmode:
2015 ASM_OUTPUT_LONG_DOUBLE (asm_out_file, d);
2016 break;
2017 #endif
2018
2019 default:
2020 abort ();
2021 }
2022
2023 set_float_handler (NULL_PTR);
2024 }
2025 \f
2026 /* Here we combine duplicate floating constants to make
2027 CONST_DOUBLE rtx's, and force those out to memory when necessary. */
2028
2029 /* Return a CONST_DOUBLE or CONST_INT for a value specified as a pair of ints.
2030 For an integer, I0 is the low-order word and I1 is the high-order word.
2031 For a real number, I0 is the word with the low address
2032 and I1 is the word with the high address. */
2033
2034 rtx
2035 immed_double_const (i0, i1, mode)
2036 HOST_WIDE_INT i0, i1;
2037 enum machine_mode mode;
2038 {
2039 register rtx r;
2040
2041 if (GET_MODE_CLASS (mode) == MODE_INT
2042 || GET_MODE_CLASS (mode) == MODE_PARTIAL_INT)
2043 {
2044 /* We clear out all bits that don't belong in MODE, unless they and our
2045 sign bit are all one. So we get either a reasonable negative value
2046 or a reasonable unsigned value for this mode. */
2047 int width = GET_MODE_BITSIZE (mode);
2048 if (width < HOST_BITS_PER_WIDE_INT
2049 && ((i0 & ((HOST_WIDE_INT) (-1) << (width - 1)))
2050 != ((HOST_WIDE_INT) (-1) << (width - 1))))
2051 i0 &= ((HOST_WIDE_INT) 1 << width) - 1, i1 = 0;
2052 else if (width == HOST_BITS_PER_WIDE_INT
2053 && ! (i1 == ~0 && i0 < 0))
2054 i1 = 0;
2055 else if (width > 2 * HOST_BITS_PER_WIDE_INT)
2056 /* We cannot represent this value as a constant. */
2057 abort ();
2058
2059 /* If this would be an entire word for the target, but is not for
2060 the host, then sign-extend on the host so that the number will look
2061 the same way on the host that it would on the target.
2062
2063 For example, when building a 64 bit alpha hosted 32 bit sparc
2064 targeted compiler, then we want the 32 bit unsigned value -1 to be
2065 represented as a 64 bit value -1, and not as 0x00000000ffffffff.
2066 The later confuses the sparc backend. */
2067
2068 if (BITS_PER_WORD < HOST_BITS_PER_WIDE_INT && BITS_PER_WORD == width
2069 && (i0 & ((HOST_WIDE_INT) 1 << (width - 1))))
2070 i0 |= ((HOST_WIDE_INT) (-1) << width);
2071
2072 /* If MODE fits within HOST_BITS_PER_WIDE_INT, always use a CONST_INT.
2073
2074 ??? Strictly speaking, this is wrong if we create a CONST_INT
2075 for a large unsigned constant with the size of MODE being
2076 HOST_BITS_PER_WIDE_INT and later try to interpret that constant in a
2077 wider mode. In that case we will mis-interpret it as a negative
2078 number.
2079
2080 Unfortunately, the only alternative is to make a CONST_DOUBLE
2081 for any constant in any mode if it is an unsigned constant larger
2082 than the maximum signed integer in an int on the host. However,
2083 doing this will break everyone that always expects to see a CONST_INT
2084 for SImode and smaller.
2085
2086 We have always been making CONST_INTs in this case, so nothing new
2087 is being broken. */
2088
2089 if (width <= HOST_BITS_PER_WIDE_INT)
2090 i1 = (i0 < 0) ? ~(HOST_WIDE_INT) 0 : 0;
2091
2092 /* If this integer fits in one word, return a CONST_INT. */
2093 if ((i1 == 0 && i0 >= 0)
2094 || (i1 == ~0 && i0 < 0))
2095 return GEN_INT (i0);
2096
2097 /* We use VOIDmode for integers. */
2098 mode = VOIDmode;
2099 }
2100
2101 /* Search the chain for an existing CONST_DOUBLE with the right value.
2102 If one is found, return it. */
2103 if (cfun != 0)
2104 for (r = const_double_chain; r; r = CONST_DOUBLE_CHAIN (r))
2105 if (CONST_DOUBLE_LOW (r) == i0 && CONST_DOUBLE_HIGH (r) == i1
2106 && GET_MODE (r) == mode)
2107 return r;
2108
2109 /* No; make a new one and add it to the chain. */
2110 r = gen_rtx_CONST_DOUBLE (mode, const0_rtx, i0, i1);
2111
2112 /* Don't touch const_double_chain if not inside any function. */
2113 if (current_function_decl != 0)
2114 {
2115 CONST_DOUBLE_CHAIN (r) = const_double_chain;
2116 const_double_chain = r;
2117 }
2118
2119 return r;
2120 }
2121
2122 /* Return a CONST_DOUBLE for a specified `double' value
2123 and machine mode. */
2124
2125 rtx
2126 immed_real_const_1 (d, mode)
2127 REAL_VALUE_TYPE d;
2128 enum machine_mode mode;
2129 {
2130 union real_extract u;
2131 register rtx r;
2132
2133 /* Get the desired `double' value as a sequence of ints
2134 since that is how they are stored in a CONST_DOUBLE. */
2135
2136 u.d = d;
2137
2138 /* Detect special cases. But be careful we don't use a CONST_DOUBLE
2139 that's from a parent function since it may be in its constant pool. */
2140 if (REAL_VALUES_IDENTICAL (dconst0, d)
2141 && (cfun == 0 || decl_function_context (current_function_decl) == 0))
2142 return CONST0_RTX (mode);
2143
2144 /* Check for NaN first, because some ports (specifically the i386) do not
2145 emit correct ieee-fp code by default, and thus will generate a core
2146 dump here if we pass a NaN to REAL_VALUES_EQUAL and if REAL_VALUES_EQUAL
2147 does a floating point comparison. */
2148 else if ((! REAL_VALUE_ISNAN (d) && REAL_VALUES_EQUAL (dconst1, d))
2149 && (cfun == 0
2150 || decl_function_context (current_function_decl) == 0))
2151 return CONST1_RTX (mode);
2152
2153 if (sizeof u == sizeof (HOST_WIDE_INT))
2154 return immed_double_const (u.i[0], 0, mode);
2155 if (sizeof u == 2 * sizeof (HOST_WIDE_INT))
2156 return immed_double_const (u.i[0], u.i[1], mode);
2157
2158 /* The rest of this function handles the case where
2159 a float value requires more than 2 ints of space.
2160 It will be deleted as dead code on machines that don't need it. */
2161
2162 /* Search the chain for an existing CONST_DOUBLE with the right value.
2163 If one is found, return it. */
2164 if (cfun != 0)
2165 for (r = const_double_chain; r; r = CONST_DOUBLE_CHAIN (r))
2166 if (! memcmp ((char *) &CONST_DOUBLE_LOW (r), (char *) &u, sizeof u)
2167 && GET_MODE (r) == mode)
2168 return r;
2169
2170 /* No; make a new one and add it to the chain.
2171
2172 We may be called by an optimizer which may be discarding any memory
2173 allocated during its processing (such as combine and loop). However,
2174 we will be leaving this constant on the chain, so we cannot tolerate
2175 freed memory. */
2176 r = rtx_alloc (CONST_DOUBLE);
2177 PUT_MODE (r, mode);
2178 memcpy ((char *) &CONST_DOUBLE_LOW (r), (char *) &u, sizeof u);
2179
2180 /* If we aren't inside a function, don't put r on the
2181 const_double_chain. */
2182 if (current_function_decl != 0)
2183 {
2184 CONST_DOUBLE_CHAIN (r) = const_double_chain;
2185 const_double_chain = r;
2186 }
2187 else
2188 CONST_DOUBLE_CHAIN (r) = NULL_RTX;
2189
2190 /* Store const0_rtx in CONST_DOUBLE_MEM since this CONST_DOUBLE is on the
2191 chain, but has not been allocated memory. Actual use of CONST_DOUBLE_MEM
2192 is only through force_const_mem. */
2193
2194 CONST_DOUBLE_MEM (r) = const0_rtx;
2195
2196 return r;
2197 }
2198
2199 /* Return a CONST_DOUBLE rtx for a value specified by EXP,
2200 which must be a REAL_CST tree node. */
2201
2202 rtx
2203 immed_real_const (exp)
2204 tree exp;
2205 {
2206 return immed_real_const_1 (TREE_REAL_CST (exp), TYPE_MODE (TREE_TYPE (exp)));
2207 }
2208
2209 /* At the end of a function, forget the memory-constants
2210 previously made for CONST_DOUBLEs. Mark them as not on real_constant_chain.
2211 Also clear out real_constant_chain and clear out all the chain-pointers. */
2212
2213 void
2214 clear_const_double_mem ()
2215 {
2216 register rtx r, next;
2217
2218 for (r = const_double_chain; r; r = next)
2219 {
2220 next = CONST_DOUBLE_CHAIN (r);
2221 CONST_DOUBLE_CHAIN (r) = 0;
2222 CONST_DOUBLE_MEM (r) = cc0_rtx;
2223 }
2224 const_double_chain = 0;
2225 }
2226 \f
2227 /* Given an expression EXP with a constant value,
2228 reduce it to the sum of an assembler symbol and an integer.
2229 Store them both in the structure *VALUE.
2230 Abort if EXP does not reduce. */
2231
2232 struct addr_const
2233 {
2234 rtx base;
2235 HOST_WIDE_INT offset;
2236 };
2237
2238 static void
2239 decode_addr_const (exp, value)
2240 tree exp;
2241 struct addr_const *value;
2242 {
2243 register tree target = TREE_OPERAND (exp, 0);
2244 register int offset = 0;
2245 register rtx x;
2246
2247 while (1)
2248 {
2249 if (TREE_CODE (target) == COMPONENT_REF
2250 && host_integerp (byte_position (TREE_OPERAND (target, 1)), 0))
2251
2252 {
2253 offset += int_byte_position (TREE_OPERAND (target, 1));
2254 target = TREE_OPERAND (target, 0);
2255 }
2256 else if (TREE_CODE (target) == ARRAY_REF)
2257 {
2258 offset += (tree_low_cst (TYPE_SIZE_UNIT (TREE_TYPE (target)), 1)
2259 * tree_low_cst (TREE_OPERAND (target, 1), 0));
2260 target = TREE_OPERAND (target, 0);
2261 }
2262 else
2263 break;
2264 }
2265
2266 switch (TREE_CODE (target))
2267 {
2268 case VAR_DECL:
2269 case FUNCTION_DECL:
2270 x = DECL_RTL (target);
2271 break;
2272
2273 case LABEL_DECL:
2274 x = gen_rtx_MEM (FUNCTION_MODE,
2275 gen_rtx_LABEL_REF (VOIDmode,
2276 label_rtx (TREE_OPERAND (exp, 0))));
2277 break;
2278
2279 case REAL_CST:
2280 case STRING_CST:
2281 case COMPLEX_CST:
2282 case CONSTRUCTOR:
2283 case INTEGER_CST:
2284 x = TREE_CST_RTL (target);
2285 break;
2286
2287 default:
2288 abort ();
2289 }
2290
2291 if (GET_CODE (x) != MEM)
2292 abort ();
2293 x = XEXP (x, 0);
2294
2295 value->base = x;
2296 value->offset = offset;
2297 }
2298 \f
2299 struct rtx_const
2300 {
2301 #ifdef ONLY_INT_FIELDS
2302 unsigned int kind : 16;
2303 unsigned int mode : 16;
2304 #else
2305 enum kind kind : 16;
2306 enum machine_mode mode : 16;
2307 #endif
2308 union {
2309 union real_extract du;
2310 struct addr_const addr;
2311 struct {HOST_WIDE_INT high, low;} di;
2312 } un;
2313 };
2314
2315 /* Uniquize all constants that appear in memory.
2316 Each constant in memory thus far output is recorded
2317 in `const_hash_table' with a `struct constant_descriptor'
2318 that contains a polish representation of the value of
2319 the constant.
2320
2321 We cannot store the trees in the hash table
2322 because the trees may be temporary. */
2323
2324 struct constant_descriptor
2325 {
2326 struct constant_descriptor *next;
2327 char *label;
2328 rtx rtl;
2329 /* Make sure the data is reasonably aligned. */
2330 union
2331 {
2332 unsigned char contents[1];
2333 #ifdef HAVE_LONG_DOUBLE
2334 long double d;
2335 #else
2336 double d;
2337 #endif
2338 } u;
2339 };
2340
2341 #define HASHBITS 30
2342 #define MAX_HASH_TABLE 1009
2343 static struct constant_descriptor *const_hash_table[MAX_HASH_TABLE];
2344
2345 /* Mark a const_hash_table descriptor for GC. */
2346
2347 static void
2348 mark_const_hash_entry (ptr)
2349 void *ptr;
2350 {
2351 struct constant_descriptor *desc = * (struct constant_descriptor **) ptr;
2352
2353 while (desc)
2354 {
2355 ggc_mark_string ((const char *)desc->label);
2356 ggc_mark_rtx (desc->rtl);
2357 desc = desc->next;
2358 }
2359 }
2360
2361 /* Compute a hash code for a constant expression. */
2362
2363 static int
2364 const_hash (exp)
2365 tree exp;
2366 {
2367 register const char *p;
2368 register int len, hi, i;
2369 register enum tree_code code = TREE_CODE (exp);
2370
2371 /* Either set P and LEN to the address and len of something to hash and
2372 exit the switch or return a value. */
2373
2374 switch (code)
2375 {
2376 case INTEGER_CST:
2377 p = (char *) &TREE_INT_CST (exp);
2378 len = sizeof TREE_INT_CST (exp);
2379 break;
2380
2381 case REAL_CST:
2382 p = (char *) &TREE_REAL_CST (exp);
2383 len = sizeof TREE_REAL_CST (exp);
2384 break;
2385
2386 case STRING_CST:
2387 p = TREE_STRING_POINTER (exp);
2388 len = TREE_STRING_LENGTH (exp);
2389 break;
2390
2391 case COMPLEX_CST:
2392 return (const_hash (TREE_REALPART (exp)) * 5
2393 + const_hash (TREE_IMAGPART (exp)));
2394
2395 case CONSTRUCTOR:
2396 if (TREE_CODE (TREE_TYPE (exp)) == SET_TYPE)
2397 {
2398 char *tmp;
2399
2400 len = int_size_in_bytes (TREE_TYPE (exp));
2401 tmp = (char *) alloca (len);
2402 get_set_constructor_bytes (exp, (unsigned char *) tmp, len);
2403 p = tmp;
2404 break;
2405 }
2406 else
2407 {
2408 register tree link;
2409
2410 /* For record type, include the type in the hashing.
2411 We do not do so for array types
2412 because (1) the sizes of the elements are sufficient
2413 and (2) distinct array types can have the same constructor.
2414 Instead, we include the array size because the constructor could
2415 be shorter. */
2416 if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE)
2417 hi = ((unsigned long) TREE_TYPE (exp) & ((1 << HASHBITS) - 1))
2418 % MAX_HASH_TABLE;
2419 else
2420 hi = ((5 + int_size_in_bytes (TREE_TYPE (exp)))
2421 & ((1 << HASHBITS) - 1)) % MAX_HASH_TABLE;
2422
2423 for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link))
2424 if (TREE_VALUE (link))
2425 hi
2426 = (hi * 603 + const_hash (TREE_VALUE (link))) % MAX_HASH_TABLE;
2427
2428 return hi;
2429 }
2430
2431 case ADDR_EXPR:
2432 {
2433 struct addr_const value;
2434
2435 decode_addr_const (exp, &value);
2436 if (GET_CODE (value.base) == SYMBOL_REF)
2437 {
2438 /* Don't hash the address of the SYMBOL_REF;
2439 only use the offset and the symbol name. */
2440 hi = value.offset;
2441 p = XSTR (value.base, 0);
2442 for (i = 0; p[i] != 0; i++)
2443 hi = ((hi * 613) + (unsigned) (p[i]));
2444 }
2445 else if (GET_CODE (value.base) == LABEL_REF)
2446 hi = value.offset + CODE_LABEL_NUMBER (XEXP (value.base, 0)) * 13;
2447 else
2448 abort();
2449
2450 hi &= (1 << HASHBITS) - 1;
2451 hi %= MAX_HASH_TABLE;
2452 }
2453 return hi;
2454
2455 case PLUS_EXPR:
2456 case MINUS_EXPR:
2457 return (const_hash (TREE_OPERAND (exp, 0)) * 9
2458 + const_hash (TREE_OPERAND (exp, 1)));
2459
2460 case NOP_EXPR:
2461 case CONVERT_EXPR:
2462 case NON_LVALUE_EXPR:
2463 return const_hash (TREE_OPERAND (exp, 0)) * 7 + 2;
2464
2465 default:
2466 /* A language specific constant. Just hash the code. */
2467 return code % MAX_HASH_TABLE;
2468 }
2469
2470 /* Compute hashing function */
2471 hi = len;
2472 for (i = 0; i < len; i++)
2473 hi = ((hi * 613) + (unsigned) (p[i]));
2474
2475 hi &= (1 << HASHBITS) - 1;
2476 hi %= MAX_HASH_TABLE;
2477 return hi;
2478 }
2479 \f
2480 /* Compare a constant expression EXP with a constant-descriptor DESC.
2481 Return 1 if DESC describes a constant with the same value as EXP. */
2482
2483 static int
2484 compare_constant (exp, desc)
2485 tree exp;
2486 struct constant_descriptor *desc;
2487 {
2488 return 0 != compare_constant_1 (exp, desc->u.contents);
2489 }
2490
2491 /* Compare constant expression EXP with a substring P of a constant descriptor.
2492 If they match, return a pointer to the end of the substring matched.
2493 If they do not match, return 0.
2494
2495 Since descriptors are written in polish prefix notation,
2496 this function can be used recursively to test one operand of EXP
2497 against a subdescriptor, and if it succeeds it returns the
2498 address of the subdescriptor for the next operand. */
2499
2500 static const unsigned char *
2501 compare_constant_1 (exp, p)
2502 tree exp;
2503 const unsigned char *p;
2504 {
2505 register const unsigned char *strp;
2506 register int len;
2507 register enum tree_code code = TREE_CODE (exp);
2508
2509 if (code != (enum tree_code) *p++)
2510 return 0;
2511
2512 /* Either set STRP, P and LEN to pointers and length to compare and exit the
2513 switch, or return the result of the comparison. */
2514
2515 switch (code)
2516 {
2517 case INTEGER_CST:
2518 /* Integer constants are the same only if the same width of type. */
2519 if (*p++ != TYPE_PRECISION (TREE_TYPE (exp)))
2520 return 0;
2521
2522 strp = (unsigned char *) &TREE_INT_CST (exp);
2523 len = sizeof TREE_INT_CST (exp);
2524 break;
2525
2526 case REAL_CST:
2527 /* Real constants are the same only if the same width of type. */
2528 if (*p++ != TYPE_PRECISION (TREE_TYPE (exp)))
2529 return 0;
2530
2531 strp = (unsigned char *) &TREE_REAL_CST (exp);
2532 len = sizeof TREE_REAL_CST (exp);
2533 break;
2534
2535 case STRING_CST:
2536 if (flag_writable_strings)
2537 return 0;
2538
2539 if ((enum machine_mode) *p++ != TYPE_MODE (TREE_TYPE (exp)))
2540 return 0;
2541
2542 strp = (unsigned char *)TREE_STRING_POINTER (exp);
2543 len = TREE_STRING_LENGTH (exp);
2544 if (memcmp ((char *) &TREE_STRING_LENGTH (exp), p,
2545 sizeof TREE_STRING_LENGTH (exp)))
2546 return 0;
2547
2548 p += sizeof TREE_STRING_LENGTH (exp);
2549 break;
2550
2551 case COMPLEX_CST:
2552 p = compare_constant_1 (TREE_REALPART (exp), p);
2553 if (p == 0)
2554 return 0;
2555
2556 return compare_constant_1 (TREE_IMAGPART (exp), p);
2557
2558 case CONSTRUCTOR:
2559 if (TREE_CODE (TREE_TYPE (exp)) == SET_TYPE)
2560 {
2561 int xlen = len = int_size_in_bytes (TREE_TYPE (exp));
2562 unsigned char *tmp = (unsigned char *) alloca (len);
2563
2564 get_set_constructor_bytes (exp, tmp, len);
2565 strp = (unsigned char *) tmp;
2566 if (memcmp ((char *) &xlen, p, sizeof xlen))
2567 return 0;
2568
2569 p += sizeof xlen;
2570 break;
2571 }
2572 else
2573 {
2574 register tree link;
2575 int length = list_length (CONSTRUCTOR_ELTS (exp));
2576 tree type;
2577 enum machine_mode mode = TYPE_MODE (TREE_TYPE (exp));
2578 int have_purpose = 0;
2579
2580 for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link))
2581 if (TREE_PURPOSE (link))
2582 have_purpose = 1;
2583
2584 if (memcmp ((char *) &length, p, sizeof length))
2585 return 0;
2586
2587 p += sizeof length;
2588
2589 /* For record constructors, insist that the types match.
2590 For arrays, just verify both constructors are for arrays.
2591 Then insist that either both or none have any TREE_PURPOSE
2592 values. */
2593 if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE)
2594 type = TREE_TYPE (exp);
2595 else
2596 type = 0;
2597
2598 if (memcmp ((char *) &type, p, sizeof type))
2599 return 0;
2600
2601 if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE)
2602 {
2603 if (memcmp ((char *) &mode, p, sizeof mode))
2604 return 0;
2605
2606 p += sizeof mode;
2607 }
2608
2609 p += sizeof type;
2610
2611 if (memcmp ((char *) &have_purpose, p, sizeof have_purpose))
2612 return 0;
2613
2614 p += sizeof have_purpose;
2615
2616 /* For arrays, insist that the size in bytes match. */
2617 if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE)
2618 {
2619 HOST_WIDE_INT size = int_size_in_bytes (TREE_TYPE (exp));
2620
2621 if (memcmp ((char *) &size, p, sizeof size))
2622 return 0;
2623
2624 p += sizeof size;
2625 }
2626
2627 for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link))
2628 {
2629 if (TREE_VALUE (link))
2630 {
2631 if ((p = compare_constant_1 (TREE_VALUE (link), p)) == 0)
2632 return 0;
2633 }
2634 else
2635 {
2636 tree zero = 0;
2637
2638 if (memcmp ((char *) &zero, p, sizeof zero))
2639 return 0;
2640
2641 p += sizeof zero;
2642 }
2643
2644 if (TREE_PURPOSE (link)
2645 && TREE_CODE (TREE_PURPOSE (link)) == FIELD_DECL)
2646 {
2647 if (memcmp ((char *) &TREE_PURPOSE (link), p,
2648 sizeof TREE_PURPOSE (link)))
2649 return 0;
2650
2651 p += sizeof TREE_PURPOSE (link);
2652 }
2653 else if (TREE_PURPOSE (link))
2654 {
2655 if ((p = compare_constant_1 (TREE_PURPOSE (link), p)) == 0)
2656 return 0;
2657 }
2658 else if (have_purpose)
2659 {
2660 int zero = 0;
2661
2662 if (memcmp ((char *) &zero, p, sizeof zero))
2663 return 0;
2664
2665 p += sizeof zero;
2666 }
2667 }
2668
2669 return p;
2670 }
2671
2672 case ADDR_EXPR:
2673 {
2674 struct addr_const value;
2675
2676 decode_addr_const (exp, &value);
2677 strp = (unsigned char *) &value.offset;
2678 len = sizeof value.offset;
2679 /* Compare the offset. */
2680 while (--len >= 0)
2681 if (*p++ != *strp++)
2682 return 0;
2683
2684 /* Compare symbol name. */
2685 strp = (unsigned char *) XSTR (value.base, 0);
2686 len = strlen ((char *) strp) + 1;
2687 }
2688 break;
2689
2690 case PLUS_EXPR:
2691 case MINUS_EXPR:
2692 case RANGE_EXPR:
2693 p = compare_constant_1 (TREE_OPERAND (exp, 0), p);
2694 if (p == 0)
2695 return 0;
2696
2697 return compare_constant_1 (TREE_OPERAND (exp, 1), p);
2698
2699 case NOP_EXPR:
2700 case CONVERT_EXPR:
2701 case NON_LVALUE_EXPR:
2702 return compare_constant_1 (TREE_OPERAND (exp, 0), p);
2703
2704 default:
2705 if (lang_expand_constant)
2706 {
2707 exp = (*lang_expand_constant) (exp);
2708 return compare_constant_1 (exp, p);
2709 }
2710 return 0;
2711 }
2712
2713 /* Compare constant contents. */
2714 while (--len >= 0)
2715 if (*p++ != *strp++)
2716 return 0;
2717
2718 return p;
2719 }
2720 \f
2721 /* Construct a constant descriptor for the expression EXP.
2722 It is up to the caller to enter the descriptor in the hash table. */
2723
2724 static struct constant_descriptor *
2725 record_constant (exp)
2726 tree exp;
2727 {
2728 struct constant_descriptor *next = 0;
2729 char *label = 0;
2730 rtx rtl = 0;
2731
2732 /* Make a struct constant_descriptor. The first three pointers will
2733 be filled in later. Here we just leave space for them. */
2734
2735 obstack_grow (&permanent_obstack, (char *) &next, sizeof next);
2736 obstack_grow (&permanent_obstack, (char *) &label, sizeof label);
2737 obstack_grow (&permanent_obstack, (char *) &rtl, sizeof rtl);
2738 record_constant_1 (exp);
2739 return (struct constant_descriptor *) obstack_finish (&permanent_obstack);
2740 }
2741
2742 /* Add a description of constant expression EXP
2743 to the object growing in `permanent_obstack'.
2744 No need to return its address; the caller will get that
2745 from the obstack when the object is complete. */
2746
2747 static void
2748 record_constant_1 (exp)
2749 tree exp;
2750 {
2751 register unsigned char *strp;
2752 register int len;
2753 register enum tree_code code = TREE_CODE (exp);
2754
2755 obstack_1grow (&permanent_obstack, (unsigned int) code);
2756
2757 switch (code)
2758 {
2759 case INTEGER_CST:
2760 obstack_1grow (&permanent_obstack, TYPE_PRECISION (TREE_TYPE (exp)));
2761 strp = (unsigned char *) &TREE_INT_CST (exp);
2762 len = sizeof TREE_INT_CST (exp);
2763 break;
2764
2765 case REAL_CST:
2766 obstack_1grow (&permanent_obstack, TYPE_PRECISION (TREE_TYPE (exp)));
2767 strp = (unsigned char *) &TREE_REAL_CST (exp);
2768 len = sizeof TREE_REAL_CST (exp);
2769 break;
2770
2771 case STRING_CST:
2772 if (flag_writable_strings)
2773 return;
2774
2775 obstack_1grow (&permanent_obstack, TYPE_MODE (TREE_TYPE (exp)));
2776 strp = (unsigned char *) TREE_STRING_POINTER (exp);
2777 len = TREE_STRING_LENGTH (exp);
2778 obstack_grow (&permanent_obstack, (char *) &TREE_STRING_LENGTH (exp),
2779 sizeof TREE_STRING_LENGTH (exp));
2780 break;
2781
2782 case COMPLEX_CST:
2783 record_constant_1 (TREE_REALPART (exp));
2784 record_constant_1 (TREE_IMAGPART (exp));
2785 return;
2786
2787 case CONSTRUCTOR:
2788 if (TREE_CODE (TREE_TYPE (exp)) == SET_TYPE)
2789 {
2790 int nbytes = int_size_in_bytes (TREE_TYPE (exp));
2791 obstack_grow (&permanent_obstack, &nbytes, sizeof (nbytes));
2792 obstack_blank (&permanent_obstack, nbytes);
2793 get_set_constructor_bytes
2794 (exp, (unsigned char *) permanent_obstack.next_free-nbytes,
2795 nbytes);
2796 return;
2797 }
2798 else
2799 {
2800 register tree link;
2801 int length = list_length (CONSTRUCTOR_ELTS (exp));
2802 enum machine_mode mode = TYPE_MODE (TREE_TYPE (exp));
2803 tree type;
2804 int have_purpose = 0;
2805
2806 for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link))
2807 if (TREE_PURPOSE (link))
2808 have_purpose = 1;
2809
2810 obstack_grow (&permanent_obstack, (char *) &length, sizeof length);
2811
2812 /* For record constructors, insist that the types match.
2813 For arrays, just verify both constructors are for arrays
2814 of the same mode. Then insist that either both or none
2815 have any TREE_PURPOSE values. */
2816 if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE)
2817 type = TREE_TYPE (exp);
2818 else
2819 type = 0;
2820
2821 obstack_grow (&permanent_obstack, (char *) &type, sizeof type);
2822 if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE)
2823 obstack_grow (&permanent_obstack, &mode, sizeof mode);
2824
2825 obstack_grow (&permanent_obstack, (char *) &have_purpose,
2826 sizeof have_purpose);
2827
2828 /* For arrays, insist that the size in bytes match. */
2829 if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE)
2830 {
2831 HOST_WIDE_INT size = int_size_in_bytes (TREE_TYPE (exp));
2832 obstack_grow (&permanent_obstack, (char *) &size, sizeof size);
2833 }
2834
2835 for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link))
2836 {
2837 if (TREE_VALUE (link))
2838 record_constant_1 (TREE_VALUE (link));
2839 else
2840 {
2841 tree zero = 0;
2842
2843 obstack_grow (&permanent_obstack,
2844 (char *) &zero, sizeof zero);
2845 }
2846
2847 if (TREE_PURPOSE (link)
2848 && TREE_CODE (TREE_PURPOSE (link)) == FIELD_DECL)
2849 obstack_grow (&permanent_obstack,
2850 (char *) &TREE_PURPOSE (link),
2851 sizeof TREE_PURPOSE (link));
2852 else if (TREE_PURPOSE (link))
2853 record_constant_1 (TREE_PURPOSE (link));
2854 else if (have_purpose)
2855 {
2856 int zero = 0;
2857
2858 obstack_grow (&permanent_obstack,
2859 (char *) &zero, sizeof zero);
2860 }
2861 }
2862 }
2863 return;
2864
2865 case ADDR_EXPR:
2866 {
2867 struct addr_const value;
2868
2869 decode_addr_const (exp, &value);
2870 /* Record the offset. */
2871 obstack_grow (&permanent_obstack,
2872 (char *) &value.offset, sizeof value.offset);
2873
2874 switch (GET_CODE (value.base))
2875 {
2876 case SYMBOL_REF:
2877 /* Record the symbol name. */
2878 obstack_grow (&permanent_obstack, XSTR (value.base, 0),
2879 strlen (XSTR (value.base, 0)) + 1);
2880 break;
2881 case LABEL_REF:
2882 /* Record the address of the CODE_LABEL. It may not have
2883 been emitted yet, so it's UID may be zero. But pointer
2884 identity is good enough. */
2885 obstack_grow (&permanent_obstack, &XEXP (value.base, 0),
2886 sizeof (rtx));
2887 break;
2888 default:
2889 abort ();
2890 }
2891 }
2892 return;
2893
2894 case PLUS_EXPR:
2895 case MINUS_EXPR:
2896 case RANGE_EXPR:
2897 record_constant_1 (TREE_OPERAND (exp, 0));
2898 record_constant_1 (TREE_OPERAND (exp, 1));
2899 return;
2900
2901 case NOP_EXPR:
2902 case CONVERT_EXPR:
2903 case NON_LVALUE_EXPR:
2904 record_constant_1 (TREE_OPERAND (exp, 0));
2905 return;
2906
2907 default:
2908 if (lang_expand_constant)
2909 {
2910 exp = (*lang_expand_constant) (exp);
2911 record_constant_1 (exp);
2912 }
2913 return;
2914 }
2915
2916 /* Record constant contents. */
2917 obstack_grow (&permanent_obstack, strp, len);
2918 }
2919 \f
2920 /* Record a list of constant expressions that were passed to
2921 output_constant_def but that could not be output right away. */
2922
2923 struct deferred_constant
2924 {
2925 struct deferred_constant *next;
2926 tree exp;
2927 int reloc;
2928 int labelno;
2929 };
2930
2931 static struct deferred_constant *deferred_constants;
2932
2933 /* Another list of constants which should be output after the
2934 function. */
2935 static struct deferred_constant *after_function_constants;
2936
2937 /* Nonzero means defer output of addressed subconstants
2938 (i.e., those for which output_constant_def is called.) */
2939 static int defer_addressed_constants_flag;
2940
2941 /* Start deferring output of subconstants. */
2942
2943 void
2944 defer_addressed_constants ()
2945 {
2946 defer_addressed_constants_flag++;
2947 }
2948
2949 /* Stop deferring output of subconstants,
2950 and output now all those that have been deferred. */
2951
2952 void
2953 output_deferred_addressed_constants ()
2954 {
2955 struct deferred_constant *p, *next;
2956
2957 defer_addressed_constants_flag--;
2958
2959 if (defer_addressed_constants_flag > 0)
2960 return;
2961
2962 for (p = deferred_constants; p; p = next)
2963 {
2964 output_constant_def_contents (p->exp, p->reloc, p->labelno);
2965 next = p->next;
2966 free (p);
2967 }
2968
2969 deferred_constants = 0;
2970 }
2971
2972 /* Output any constants which should appear after a function. */
2973
2974 static void
2975 output_after_function_constants ()
2976 {
2977 struct deferred_constant *p, *next;
2978
2979 for (p = after_function_constants; p; p = next)
2980 {
2981 output_constant_def_contents (p->exp, p->reloc, p->labelno);
2982 next = p->next;
2983 free (p);
2984 }
2985
2986 after_function_constants = 0;
2987 }
2988
2989 /* Make a copy of the whole tree structure for a constant.
2990 This handles the same types of nodes that compare_constant
2991 and record_constant handle. */
2992
2993 static tree
2994 copy_constant (exp)
2995 tree exp;
2996 {
2997 switch (TREE_CODE (exp))
2998 {
2999 case ADDR_EXPR:
3000 /* For ADDR_EXPR, we do not want to copy the decl whose address
3001 is requested. We do want to copy constants though. */
3002 if (TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp, 0))) == 'c')
3003 return build1 (TREE_CODE (exp), TREE_TYPE (exp),
3004 copy_constant (TREE_OPERAND (exp, 0)));
3005 else
3006 return copy_node (exp);
3007
3008 case INTEGER_CST:
3009 case REAL_CST:
3010 case STRING_CST:
3011 return copy_node (exp);
3012
3013 case COMPLEX_CST:
3014 return build_complex (TREE_TYPE (exp),
3015 copy_constant (TREE_REALPART (exp)),
3016 copy_constant (TREE_IMAGPART (exp)));
3017
3018 case PLUS_EXPR:
3019 case MINUS_EXPR:
3020 return build (TREE_CODE (exp), TREE_TYPE (exp),
3021 copy_constant (TREE_OPERAND (exp, 0)),
3022 copy_constant (TREE_OPERAND (exp, 1)));
3023
3024 case NOP_EXPR:
3025 case CONVERT_EXPR:
3026 case NON_LVALUE_EXPR:
3027 return build1 (TREE_CODE (exp), TREE_TYPE (exp),
3028 copy_constant (TREE_OPERAND (exp, 0)));
3029
3030 case CONSTRUCTOR:
3031 {
3032 tree copy = copy_node (exp);
3033 tree list = copy_list (CONSTRUCTOR_ELTS (exp));
3034 tree tail;
3035
3036 CONSTRUCTOR_ELTS (copy) = list;
3037 for (tail = list; tail; tail = TREE_CHAIN (tail))
3038 TREE_VALUE (tail) = copy_constant (TREE_VALUE (tail));
3039 if (TREE_CODE (TREE_TYPE (exp)) == SET_TYPE)
3040 for (tail = list; tail; tail = TREE_CHAIN (tail))
3041 TREE_PURPOSE (tail) = copy_constant (TREE_PURPOSE (tail));
3042
3043 return copy;
3044 }
3045
3046 default:
3047 abort ();
3048 }
3049 }
3050 \f
3051 /* Return an rtx representing a reference to constant data in memory
3052 for the constant expression EXP.
3053
3054 If assembler code for such a constant has already been output,
3055 return an rtx to refer to it.
3056 Otherwise, output such a constant in memory (or defer it for later)
3057 and generate an rtx for it.
3058
3059 The TREE_CST_RTL of EXP is set up to point to that rtx.
3060 The const_hash_table records which constants already have label strings. */
3061
3062 rtx
3063 output_constant_def (exp)
3064 tree exp;
3065 {
3066 register int hash;
3067 register struct constant_descriptor *desc;
3068 char label[256];
3069 int reloc;
3070 int found = 1;
3071
3072 if (TREE_CST_RTL (exp))
3073 return TREE_CST_RTL (exp);
3074
3075 /* Make sure any other constants whose addresses appear in EXP
3076 are assigned label numbers. */
3077
3078 reloc = output_addressed_constants (exp);
3079
3080 /* Compute hash code of EXP. Search the descriptors for that hash code
3081 to see if any of them describes EXP. If yes, the descriptor records
3082 the label number already assigned. */
3083
3084 hash = const_hash (exp) % MAX_HASH_TABLE;
3085
3086 for (desc = const_hash_table[hash]; desc; desc = desc->next)
3087 if (compare_constant (exp, desc))
3088 break;
3089
3090 if (desc == 0)
3091 {
3092 /* No constant equal to EXP is known to have been output.
3093 Make a constant descriptor to enter EXP in the hash table.
3094 Assign the label number and record it in the descriptor for
3095 future calls to this function to find. */
3096
3097 /* Create a string containing the label name, in LABEL. */
3098 ASM_GENERATE_INTERNAL_LABEL (label, "LC", const_labelno);
3099
3100 desc = record_constant (exp);
3101 desc->next = const_hash_table[hash];
3102 desc->label = ggc_alloc_string (label, -1);
3103 const_hash_table[hash] = desc;
3104
3105 /* We have a symbol name; construct the SYMBOL_REF and the MEM. */
3106 desc->rtl
3107 = gen_rtx_MEM (TYPE_MODE (TREE_TYPE (exp)),
3108 gen_rtx_SYMBOL_REF (Pmode, desc->label));
3109
3110 set_mem_attributes (desc->rtl, exp, 1);
3111
3112 found = 0;
3113 }
3114
3115 TREE_CST_RTL (exp) = desc->rtl;
3116
3117 /* Optionally set flags or add text to the name to record information
3118 such as that it is a function name. If the name is changed, the macro
3119 ASM_OUTPUT_LABELREF will have to know how to strip this information. */
3120 #ifdef ENCODE_SECTION_INFO
3121 ENCODE_SECTION_INFO (exp);
3122 #endif
3123
3124 /* If this is the first time we've seen this particular constant,
3125 output it (or defer its output for later). */
3126 if (! found)
3127 {
3128 int after_function = 0;
3129
3130 #ifdef CONSTANT_AFTER_FUNCTION_P
3131 if (current_function_decl != 0
3132 && CONSTANT_AFTER_FUNCTION_P (exp))
3133 after_function = 1;
3134 #endif
3135
3136 if (defer_addressed_constants_flag || after_function)
3137 {
3138 struct deferred_constant *p;
3139 p = (struct deferred_constant *) xmalloc (sizeof (struct deferred_constant));
3140
3141 p->exp = copy_constant (exp);
3142 p->reloc = reloc;
3143 p->labelno = const_labelno++;
3144 if (after_function)
3145 {
3146 p->next = after_function_constants;
3147 after_function_constants = p;
3148 }
3149 else
3150 {
3151 p->next = deferred_constants;
3152 deferred_constants = p;
3153 }
3154 }
3155 else
3156 {
3157 /* Do no output if -fsyntax-only. */
3158 if (! flag_syntax_only)
3159 output_constant_def_contents (exp, reloc, const_labelno);
3160 ++const_labelno;
3161 }
3162 }
3163
3164 return TREE_CST_RTL (exp);
3165 }
3166
3167 /* Now output assembler code to define the label for EXP,
3168 and follow it with the data of EXP. */
3169
3170 static void
3171 output_constant_def_contents (exp, reloc, labelno)
3172 tree exp;
3173 int reloc;
3174 int labelno;
3175 {
3176 int align;
3177
3178 if (IN_NAMED_SECTION (exp))
3179 named_section (exp, NULL, reloc);
3180 else
3181 {
3182 /* First switch to text section, except for writable strings. */
3183 #ifdef SELECT_SECTION
3184 SELECT_SECTION (exp, reloc);
3185 #else
3186 if (((TREE_CODE (exp) == STRING_CST) && flag_writable_strings)
3187 || (flag_pic && reloc))
3188 data_section ();
3189 else
3190 readonly_data_section ();
3191 #endif
3192 }
3193
3194 /* Align the location counter as required by EXP's data type. */
3195 align = TYPE_ALIGN (TREE_TYPE (exp));
3196 #ifdef CONSTANT_ALIGNMENT
3197 align = CONSTANT_ALIGNMENT (exp, align);
3198 #endif
3199
3200 if (align > BITS_PER_UNIT)
3201 ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT));
3202
3203 /* Output the label itself. */
3204 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LC", labelno);
3205
3206 /* Output the value of EXP. */
3207 output_constant (exp,
3208 (TREE_CODE (exp) == STRING_CST
3209 ? TREE_STRING_LENGTH (exp)
3210 : int_size_in_bytes (TREE_TYPE (exp))));
3211
3212 }
3213 \f
3214 /* Structure to represent sufficient information about a constant so that
3215 it can be output when the constant pool is output, so that function
3216 integration can be done, and to simplify handling on machines that reference
3217 constant pool as base+displacement. */
3218
3219 struct pool_constant
3220 {
3221 struct constant_descriptor *desc;
3222 struct pool_constant *next, *next_sym;
3223 char *label;
3224 rtx constant;
3225 enum machine_mode mode;
3226 int labelno;
3227 int align;
3228 int offset;
3229 int mark;
3230 };
3231
3232 /* Hash code for a SYMBOL_REF with CONSTANT_POOL_ADDRESS_P true.
3233 The argument is XSTR (... , 0) */
3234
3235 #define SYMHASH(LABEL) \
3236 ((((unsigned long) (LABEL)) & ((1 << HASHBITS) - 1)) % MAX_RTX_HASH_TABLE)
3237 \f
3238 /* Initialize constant pool hashing for a new function. */
3239
3240 void
3241 init_varasm_status (f)
3242 struct function *f;
3243 {
3244 struct varasm_status *p;
3245 p = (struct varasm_status *) xmalloc (sizeof (struct varasm_status));
3246 f->varasm = p;
3247 p->x_const_rtx_hash_table
3248 = ((struct constant_descriptor **)
3249 xcalloc (MAX_RTX_HASH_TABLE, sizeof (struct constant_descriptor *)));
3250 p->x_const_rtx_sym_hash_table
3251 = ((struct pool_constant **)
3252 xcalloc (MAX_RTX_HASH_TABLE, sizeof (struct pool_constant *)));
3253
3254 p->x_first_pool = p->x_last_pool = 0;
3255 p->x_pool_offset = 0;
3256 p->x_const_double_chain = 0;
3257 }
3258
3259 /* Mark PC for GC. */
3260
3261 static void
3262 mark_pool_constant (pc)
3263 struct pool_constant *pc;
3264 {
3265 while (pc)
3266 {
3267 ggc_mark (pc);
3268 ggc_mark_rtx (pc->constant);
3269 ggc_mark_string (pc->label);
3270 pc = pc->next;
3271 }
3272 }
3273
3274 /* Mark P for GC. */
3275
3276 void
3277 mark_varasm_status (p)
3278 struct varasm_status *p;
3279 {
3280 if (p == NULL)
3281 return;
3282
3283 mark_pool_constant (p->x_first_pool);
3284 ggc_mark_rtx (p->x_const_double_chain);
3285 }
3286
3287 /* Clear out all parts of the state in F that can safely be discarded
3288 after the function has been compiled, to let garbage collection
3289 reclaim the memory. */
3290
3291 void
3292 free_varasm_status (f)
3293 struct function *f;
3294 {
3295 struct varasm_status *p;
3296 int i;
3297
3298 p = f->varasm;
3299
3300 /* Clear out the hash tables. */
3301 for (i = 0; i < MAX_RTX_HASH_TABLE; ++i)
3302 {
3303 struct constant_descriptor* cd;
3304
3305 cd = p->x_const_rtx_hash_table[i];
3306 while (cd) {
3307 struct constant_descriptor* next = cd->next;
3308 free (cd);
3309 cd = next;
3310 }
3311 }
3312
3313 free (p->x_const_rtx_hash_table);
3314 free (p->x_const_rtx_sym_hash_table);
3315 free (p);
3316 f->varasm = NULL;
3317 }
3318 \f
3319 enum kind { RTX_DOUBLE, RTX_INT };
3320
3321 /* Express an rtx for a constant integer (perhaps symbolic)
3322 as the sum of a symbol or label plus an explicit integer.
3323 They are stored into VALUE. */
3324
3325 static void
3326 decode_rtx_const (mode, x, value)
3327 enum machine_mode mode;
3328 rtx x;
3329 struct rtx_const *value;
3330 {
3331 /* Clear the whole structure, including any gaps. */
3332 memset (value, 0, sizeof (struct rtx_const));
3333
3334 value->kind = RTX_INT; /* Most usual kind. */
3335 value->mode = mode;
3336
3337 switch (GET_CODE (x))
3338 {
3339 case CONST_DOUBLE:
3340 value->kind = RTX_DOUBLE;
3341 if (GET_MODE (x) != VOIDmode)
3342 {
3343 value->mode = GET_MODE (x);
3344 memcpy ((char *) &value->un.du,
3345 (char *) &CONST_DOUBLE_LOW (x), sizeof value->un.du);
3346 }
3347 else
3348 {
3349 value->un.di.low = CONST_DOUBLE_LOW (x);
3350 value->un.di.high = CONST_DOUBLE_HIGH (x);
3351 }
3352 break;
3353
3354 case CONST_INT:
3355 value->un.addr.offset = INTVAL (x);
3356 break;
3357
3358 case SYMBOL_REF:
3359 case LABEL_REF:
3360 case PC:
3361 value->un.addr.base = x;
3362 break;
3363
3364 case CONST:
3365 x = XEXP (x, 0);
3366 if (GET_CODE (x) == PLUS)
3367 {
3368 value->un.addr.base = XEXP (x, 0);
3369 if (GET_CODE (XEXP (x, 1)) != CONST_INT)
3370 abort ();
3371 value->un.addr.offset = INTVAL (XEXP (x, 1));
3372 }
3373 else if (GET_CODE (x) == MINUS)
3374 {
3375 value->un.addr.base = XEXP (x, 0);
3376 if (GET_CODE (XEXP (x, 1)) != CONST_INT)
3377 abort ();
3378 value->un.addr.offset = - INTVAL (XEXP (x, 1));
3379 }
3380 else
3381 abort ();
3382 break;
3383
3384 default:
3385 abort ();
3386 }
3387
3388 if (value->kind == RTX_INT && value->un.addr.base != 0)
3389 switch (GET_CODE (value->un.addr.base))
3390 {
3391 case SYMBOL_REF:
3392 /* Use the string's address, not the SYMBOL_REF's address,
3393 for the sake of addresses of library routines. */
3394 value->un.addr.base = (rtx) XSTR (value->un.addr.base, 0);
3395 break;
3396
3397 case LABEL_REF:
3398 /* For a LABEL_REF, compare labels. */
3399 value->un.addr.base = XEXP (value->un.addr.base, 0);
3400
3401 default:
3402 break;
3403 }
3404 }
3405
3406 /* Given a MINUS expression, simplify it if both sides
3407 include the same symbol. */
3408
3409 rtx
3410 simplify_subtraction (x)
3411 rtx x;
3412 {
3413 struct rtx_const val0, val1;
3414
3415 decode_rtx_const (GET_MODE (x), XEXP (x, 0), &val0);
3416 decode_rtx_const (GET_MODE (x), XEXP (x, 1), &val1);
3417
3418 if (val0.un.addr.base == val1.un.addr.base)
3419 return GEN_INT (val0.un.addr.offset - val1.un.addr.offset);
3420 return x;
3421 }
3422
3423 /* Compute a hash code for a constant RTL expression. */
3424
3425 static int
3426 const_hash_rtx (mode, x)
3427 enum machine_mode mode;
3428 rtx x;
3429 {
3430 register int hi;
3431 register size_t i;
3432
3433 struct rtx_const value;
3434 decode_rtx_const (mode, x, &value);
3435
3436 /* Compute hashing function */
3437 hi = 0;
3438 for (i = 0; i < sizeof value / sizeof (int); i++)
3439 hi += ((int *) &value)[i];
3440
3441 hi &= (1 << HASHBITS) - 1;
3442 hi %= MAX_RTX_HASH_TABLE;
3443 return hi;
3444 }
3445
3446 /* Compare a constant rtl object X with a constant-descriptor DESC.
3447 Return 1 if DESC describes a constant with the same value as X. */
3448
3449 static int
3450 compare_constant_rtx (mode, x, desc)
3451 enum machine_mode mode;
3452 rtx x;
3453 struct constant_descriptor *desc;
3454 {
3455 register int *p = (int *) desc->u.contents;
3456 register int *strp;
3457 register int len;
3458 struct rtx_const value;
3459
3460 decode_rtx_const (mode, x, &value);
3461 strp = (int *) &value;
3462 len = sizeof value / sizeof (int);
3463
3464 /* Compare constant contents. */
3465 while (--len >= 0)
3466 if (*p++ != *strp++)
3467 return 0;
3468
3469 return 1;
3470 }
3471
3472 /* Construct a constant descriptor for the rtl-expression X.
3473 It is up to the caller to enter the descriptor in the hash table. */
3474
3475 static struct constant_descriptor *
3476 record_constant_rtx (mode, x)
3477 enum machine_mode mode;
3478 rtx x;
3479 {
3480 struct constant_descriptor *ptr;
3481
3482 ptr = ((struct constant_descriptor *)
3483 xcalloc (1, (offsetof (struct constant_descriptor, u)
3484 + sizeof (struct rtx_const))));
3485 decode_rtx_const (mode, x, (struct rtx_const *) ptr->u.contents);
3486
3487 return ptr;
3488 }
3489 \f
3490 /* Given a constant rtx X, make (or find) a memory constant for its value
3491 and return a MEM rtx to refer to it in memory. */
3492
3493 rtx
3494 force_const_mem (mode, x)
3495 enum machine_mode mode;
3496 rtx x;
3497 {
3498 register int hash;
3499 register struct constant_descriptor *desc;
3500 char label[256];
3501 char *found = 0;
3502 rtx def;
3503
3504 /* If we want this CONST_DOUBLE in the same mode as it is in memory
3505 (this will always be true for floating CONST_DOUBLEs that have been
3506 placed in memory, but not for VOIDmode (integer) CONST_DOUBLEs),
3507 use the previous copy. Otherwise, make a new one. Note that in
3508 the unlikely event that this same CONST_DOUBLE is used in two different
3509 modes in an alternating fashion, we will allocate a lot of different
3510 memory locations, but this should be extremely rare. */
3511
3512 if (GET_CODE (x) == CONST_DOUBLE
3513 && GET_CODE (CONST_DOUBLE_MEM (x)) == MEM
3514 && GET_MODE (CONST_DOUBLE_MEM (x)) == mode)
3515 return CONST_DOUBLE_MEM (x);
3516
3517 /* Compute hash code of X. Search the descriptors for that hash code
3518 to see if any of them describes X. If yes, the descriptor records
3519 the label number already assigned. */
3520
3521 hash = const_hash_rtx (mode, x);
3522
3523 for (desc = const_rtx_hash_table[hash]; desc; desc = desc->next)
3524 if (compare_constant_rtx (mode, x, desc))
3525 {
3526 found = desc->label;
3527 break;
3528 }
3529
3530 if (found == 0)
3531 {
3532 register struct pool_constant *pool;
3533 int align;
3534
3535 /* No constant equal to X is known to have been output.
3536 Make a constant descriptor to enter X in the hash table.
3537 Assign the label number and record it in the descriptor for
3538 future calls to this function to find. */
3539
3540 desc = record_constant_rtx (mode, x);
3541 desc->next = const_rtx_hash_table[hash];
3542 const_rtx_hash_table[hash] = desc;
3543
3544 /* Align the location counter as required by EXP's data type. */
3545 align = (mode == VOIDmode) ? UNITS_PER_WORD : GET_MODE_SIZE (mode);
3546 if (align > BIGGEST_ALIGNMENT / BITS_PER_UNIT)
3547 align = BIGGEST_ALIGNMENT / BITS_PER_UNIT;
3548 #ifdef CONSTANT_ALIGNMENT
3549 align = CONSTANT_ALIGNMENT (make_tree (type_for_mode (mode, 0), x),
3550 align * BITS_PER_UNIT) / BITS_PER_UNIT;
3551 #endif
3552
3553 pool_offset += align - 1;
3554 pool_offset &= ~ (align - 1);
3555
3556 /* Allocate a pool constant descriptor, fill it in, and chain it in. */
3557
3558 pool = (struct pool_constant *) ggc_alloc (sizeof (struct pool_constant));
3559 pool->desc = desc;
3560 pool->constant = x;
3561 pool->mode = mode;
3562 pool->labelno = const_labelno;
3563 pool->align = align;
3564 pool->offset = pool_offset;
3565 pool->mark = 1;
3566 pool->next = 0;
3567
3568 if (last_pool == 0)
3569 first_pool = pool;
3570 else
3571 last_pool->next = pool;
3572
3573 last_pool = pool;
3574 pool_offset += GET_MODE_SIZE (mode);
3575
3576 /* Create a string containing the label name, in LABEL. */
3577 ASM_GENERATE_INTERNAL_LABEL (label, "LC", const_labelno);
3578
3579 ++const_labelno;
3580
3581 desc->label = found = ggc_alloc_string (label, -1);
3582
3583 /* Add label to symbol hash table. */
3584 hash = SYMHASH (found);
3585 pool->label = found;
3586 pool->next_sym = const_rtx_sym_hash_table[hash];
3587 const_rtx_sym_hash_table[hash] = pool;
3588 }
3589
3590 /* We have a symbol name; construct the SYMBOL_REF and the MEM. */
3591
3592 def = gen_rtx_MEM (mode, gen_rtx_SYMBOL_REF (Pmode, found));
3593 set_mem_attributes (def, type_for_mode (mode, 0), 1);
3594 RTX_UNCHANGING_P (def) = 1;
3595
3596 /* Mark the symbol_ref as belonging to this constants pool. */
3597 CONSTANT_POOL_ADDRESS_P (XEXP (def, 0)) = 1;
3598 current_function_uses_const_pool = 1;
3599
3600 if (GET_CODE (x) == CONST_DOUBLE)
3601 {
3602 if (CONST_DOUBLE_MEM (x) == cc0_rtx)
3603 {
3604 CONST_DOUBLE_CHAIN (x) = const_double_chain;
3605 const_double_chain = x;
3606 }
3607 CONST_DOUBLE_MEM (x) = def;
3608 }
3609
3610 return def;
3611 }
3612 \f
3613 /* Given a SYMBOL_REF with CONSTANT_POOL_ADDRESS_P true, return a pointer to
3614 the corresponding pool_constant structure. */
3615
3616 static struct pool_constant *
3617 find_pool_constant (f, addr)
3618 struct function *f;
3619 rtx addr;
3620 {
3621 struct pool_constant *pool;
3622 const char *label = XSTR (addr, 0);
3623
3624 for (pool = f->varasm->x_const_rtx_sym_hash_table[SYMHASH (label)]; pool;
3625 pool = pool->next_sym)
3626 if (pool->label == label)
3627 return pool;
3628
3629 abort ();
3630 }
3631
3632 /* Given a constant pool SYMBOL_REF, return the corresponding constant. */
3633
3634 rtx
3635 get_pool_constant (addr)
3636 rtx addr;
3637 {
3638 return (find_pool_constant (cfun, addr))->constant;
3639 }
3640
3641 /* Likewise, but for the constant pool of a specific function. */
3642
3643 rtx
3644 get_pool_constant_for_function (f, addr)
3645 struct function *f;
3646 rtx addr;
3647 {
3648 return (find_pool_constant (f, addr))->constant;
3649 }
3650
3651 /* Similar, return the mode. */
3652
3653 enum machine_mode
3654 get_pool_mode (addr)
3655 rtx addr;
3656 {
3657 return (find_pool_constant (cfun, addr))->mode;
3658 }
3659
3660 enum machine_mode
3661 get_pool_mode_for_function (f, addr)
3662 struct function *f;
3663 rtx addr;
3664 {
3665 return (find_pool_constant (f, addr))->mode;
3666 }
3667
3668 /* Similar, return the offset in the constant pool. */
3669
3670 int
3671 get_pool_offset (addr)
3672 rtx addr;
3673 {
3674 return (find_pool_constant (cfun, addr))->offset;
3675 }
3676
3677 /* Return the size of the constant pool. */
3678
3679 int
3680 get_pool_size ()
3681 {
3682 return pool_offset;
3683 }
3684 \f
3685 /* Write all the constants in the constant pool. */
3686
3687 void
3688 output_constant_pool (fnname, fndecl)
3689 const char *fnname ATTRIBUTE_UNUSED;
3690 tree fndecl ATTRIBUTE_UNUSED;
3691 {
3692 struct pool_constant *pool;
3693 rtx x;
3694 union real_extract u;
3695
3696 /* It is possible for gcc to call force_const_mem and then to later
3697 discard the instructions which refer to the constant. In such a
3698 case we do not need to output the constant. */
3699 mark_constant_pool ();
3700
3701 #ifdef ASM_OUTPUT_POOL_PROLOGUE
3702 ASM_OUTPUT_POOL_PROLOGUE (asm_out_file, fnname, fndecl, pool_offset);
3703 #endif
3704
3705 for (pool = first_pool; pool; pool = pool->next)
3706 {
3707 rtx tmp;
3708
3709 x = pool->constant;
3710
3711 if (! pool->mark)
3712 continue;
3713
3714 /* See if X is a LABEL_REF (or a CONST referring to a LABEL_REF)
3715 whose CODE_LABEL has been deleted. This can occur if a jump table
3716 is eliminated by optimization. If so, write a constant of zero
3717 instead. Note that this can also happen by turning the
3718 CODE_LABEL into a NOTE. */
3719 /* ??? This seems completely and utterly wrong. Certainly it's
3720 not true for NOTE_INSN_DELETED_LABEL, but I disbelieve proper
3721 functioning even with INSN_DELETED_P and friends. */
3722
3723 tmp = x;
3724 switch (GET_CODE (x))
3725 {
3726 case CONST:
3727 if (GET_CODE (XEXP (x, 0)) != PLUS
3728 || GET_CODE (XEXP (XEXP (x, 0), 0)) != LABEL_REF)
3729 break;
3730 tmp = XEXP (XEXP (x, 0), 0);
3731 /* FALLTHRU */
3732
3733 case LABEL_REF:
3734 tmp = XEXP (x, 0);
3735 if (INSN_DELETED_P (tmp)
3736 || (GET_CODE (tmp) == NOTE
3737 && NOTE_LINE_NUMBER (tmp) == NOTE_INSN_DELETED))
3738 {
3739 abort ();
3740 x = const0_rtx;
3741 }
3742 break;
3743
3744 default:
3745 break;
3746 }
3747
3748 /* First switch to correct section. */
3749 #ifdef SELECT_RTX_SECTION
3750 SELECT_RTX_SECTION (pool->mode, x);
3751 #else
3752 readonly_data_section ();
3753 #endif
3754
3755 #ifdef ASM_OUTPUT_SPECIAL_POOL_ENTRY
3756 ASM_OUTPUT_SPECIAL_POOL_ENTRY (asm_out_file, x, pool->mode,
3757 pool->align, pool->labelno, done);
3758 #endif
3759
3760 if (pool->align > 1)
3761 ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (pool->align));
3762
3763 /* Output the label. */
3764 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LC", pool->labelno);
3765
3766 /* Output the value of the constant itself. */
3767 switch (GET_MODE_CLASS (pool->mode))
3768 {
3769 case MODE_FLOAT:
3770 if (GET_CODE (x) != CONST_DOUBLE)
3771 abort ();
3772
3773 memcpy ((char *) &u, (char *) &CONST_DOUBLE_LOW (x), sizeof u);
3774 assemble_real (u.d, pool->mode);
3775 break;
3776
3777 case MODE_INT:
3778 case MODE_PARTIAL_INT:
3779 assemble_integer (x, GET_MODE_SIZE (pool->mode), 1);
3780 break;
3781
3782 default:
3783 abort ();
3784 }
3785
3786 #ifdef ASM_OUTPUT_SPECIAL_POOL_ENTRY
3787 done: ;
3788 #endif
3789
3790 }
3791
3792 #ifdef ASM_OUTPUT_POOL_EPILOGUE
3793 ASM_OUTPUT_POOL_EPILOGUE (asm_out_file, fnname, fndecl, pool_offset);
3794 #endif
3795
3796 /* Done with this pool. */
3797 first_pool = last_pool = 0;
3798 }
3799
3800 /* Look through the instructions for this function, and mark all the
3801 entries in the constant pool which are actually being used. */
3802
3803 static void
3804 mark_constant_pool ()
3805 {
3806 register rtx insn;
3807 struct pool_constant *pool;
3808
3809 if (first_pool == 0)
3810 return;
3811
3812 for (pool = first_pool; pool; pool = pool->next)
3813 pool->mark = 0;
3814
3815 for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
3816 if (INSN_P (insn))
3817 mark_constants (PATTERN (insn));
3818
3819 for (insn = current_function_epilogue_delay_list;
3820 insn;
3821 insn = XEXP (insn, 1))
3822 if (INSN_P (insn))
3823 mark_constants (PATTERN (insn));
3824
3825 /* It's possible that the only reference to a symbol is in a symbol
3826 that's in the constant pool. This happens in Fortran under some
3827 situations. (When the constant contains the address of another
3828 constant, and only the first is used directly in an insn.)
3829 This is potentially suboptimal if there's ever a possibility of
3830 backwards (in pool order) 2'd level references. However, it's
3831 not clear that 2'd level references can happen. */
3832 for (pool = first_pool; pool; pool = pool->next)
3833 {
3834 struct pool_constant *tem;
3835 const char *label;
3836
3837 /* skip unmarked entries; no insn refers to them. */
3838 if (!pool->mark)
3839 continue;
3840
3841 /* Skip everything except SYMBOL_REFs. */
3842 if (GET_CODE (pool->constant) != SYMBOL_REF)
3843 continue;
3844 label = XSTR (pool->constant, 0);
3845
3846 /* Be sure the symbol's value is marked. */
3847 for (tem = const_rtx_sym_hash_table[SYMHASH (label)]; tem;
3848 tem = tem->next)
3849 if (tem->label == label)
3850 tem->mark = 1;
3851 /* If we didn't find it, there's something truly wrong here, but it
3852 will be announced by the assembler. */
3853 }
3854 }
3855
3856 static void
3857 mark_constants (x)
3858 register rtx x;
3859 {
3860 register int i;
3861 register const char *format_ptr;
3862
3863 if (x == 0)
3864 return;
3865
3866 if (GET_CODE (x) == SYMBOL_REF)
3867 {
3868 if (CONSTANT_POOL_ADDRESS_P (x))
3869 find_pool_constant (cfun, x)->mark = 1;
3870 return;
3871 }
3872 /* Never search inside a CONST_DOUBLE, because CONST_DOUBLE_MEM may be
3873 a MEM, but does not constitute a use of that MEM. */
3874 else if (GET_CODE (x) == CONST_DOUBLE)
3875 return;
3876
3877 /* Insns may appear inside a SEQUENCE. Only check the patterns of
3878 insns, not any notes that may be attached. We don't want to mark
3879 a constant just because it happens to appear in a REG_EQUIV note. */
3880 if (INSN_P (x))
3881 {
3882 mark_constants (PATTERN (x));
3883 return;
3884 }
3885
3886 format_ptr = GET_RTX_FORMAT (GET_CODE (x));
3887
3888 for (i = 0; i < GET_RTX_LENGTH (GET_CODE (x)); i++)
3889 {
3890 switch (*format_ptr++)
3891 {
3892 case 'e':
3893 mark_constants (XEXP (x, i));
3894 break;
3895
3896 case 'E':
3897 if (XVEC (x, i) != 0)
3898 {
3899 register int j;
3900
3901 for (j = 0; j < XVECLEN (x, i); j++)
3902 mark_constants (XVECEXP (x, i, j));
3903 }
3904 break;
3905
3906 case 'S':
3907 case 's':
3908 case '0':
3909 case 'i':
3910 case 'w':
3911 case 'n':
3912 case 'u':
3913 break;
3914
3915 default:
3916 abort ();
3917 }
3918 }
3919 }
3920 \f
3921 /* Find all the constants whose addresses are referenced inside of EXP,
3922 and make sure assembler code with a label has been output for each one.
3923 Indicate whether an ADDR_EXPR has been encountered. */
3924
3925 static int
3926 output_addressed_constants (exp)
3927 tree exp;
3928 {
3929 int reloc = 0;
3930
3931 switch (TREE_CODE (exp))
3932 {
3933 case ADDR_EXPR:
3934 {
3935 register tree constant = TREE_OPERAND (exp, 0);
3936
3937 while (TREE_CODE (constant) == COMPONENT_REF)
3938 {
3939 constant = TREE_OPERAND (constant, 0);
3940 }
3941
3942 if (TREE_CODE_CLASS (TREE_CODE (constant)) == 'c'
3943 || TREE_CODE (constant) == CONSTRUCTOR)
3944 /* No need to do anything here
3945 for addresses of variables or functions. */
3946 output_constant_def (constant);
3947 }
3948 reloc = 1;
3949 break;
3950
3951 case PLUS_EXPR:
3952 case MINUS_EXPR:
3953 reloc = output_addressed_constants (TREE_OPERAND (exp, 0));
3954 reloc |= output_addressed_constants (TREE_OPERAND (exp, 1));
3955 break;
3956
3957 case NOP_EXPR:
3958 case CONVERT_EXPR:
3959 case NON_LVALUE_EXPR:
3960 reloc = output_addressed_constants (TREE_OPERAND (exp, 0));
3961 break;
3962
3963 case CONSTRUCTOR:
3964 {
3965 register tree link;
3966 for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link))
3967 if (TREE_VALUE (link) != 0)
3968 reloc |= output_addressed_constants (TREE_VALUE (link));
3969 }
3970 break;
3971
3972 default:
3973 break;
3974 }
3975 return reloc;
3976 }
3977 \f
3978 /* Return nonzero if VALUE is a valid constant-valued expression
3979 for use in initializing a static variable; one that can be an
3980 element of a "constant" initializer.
3981
3982 Return null_pointer_node if the value is absolute;
3983 if it is relocatable, return the variable that determines the relocation.
3984 We assume that VALUE has been folded as much as possible;
3985 therefore, we do not need to check for such things as
3986 arithmetic-combinations of integers. */
3987
3988 tree
3989 initializer_constant_valid_p (value, endtype)
3990 tree value;
3991 tree endtype;
3992 {
3993 /* Give the front-end a chance to convert VALUE to something that
3994 looks more like a constant to the back-end. */
3995 if (lang_expand_constant)
3996 value = (*lang_expand_constant) (value);
3997
3998 switch (TREE_CODE (value))
3999 {
4000 case CONSTRUCTOR:
4001 if ((TREE_CODE (TREE_TYPE (value)) == UNION_TYPE
4002 || TREE_CODE (TREE_TYPE (value)) == RECORD_TYPE)
4003 && TREE_CONSTANT (value)
4004 && CONSTRUCTOR_ELTS (value))
4005 return
4006 initializer_constant_valid_p (TREE_VALUE (CONSTRUCTOR_ELTS (value)),
4007 endtype);
4008
4009 return TREE_STATIC (value) ? null_pointer_node : 0;
4010
4011 case INTEGER_CST:
4012 case REAL_CST:
4013 case STRING_CST:
4014 case COMPLEX_CST:
4015 return null_pointer_node;
4016
4017 case ADDR_EXPR:
4018 return staticp (TREE_OPERAND (value, 0)) ? TREE_OPERAND (value, 0) : 0;
4019
4020 case NON_LVALUE_EXPR:
4021 return initializer_constant_valid_p (TREE_OPERAND (value, 0), endtype);
4022
4023 case CONVERT_EXPR:
4024 case NOP_EXPR:
4025 /* Allow conversions between pointer types. */
4026 if (POINTER_TYPE_P (TREE_TYPE (value))
4027 && POINTER_TYPE_P (TREE_TYPE (TREE_OPERAND (value, 0))))
4028 return initializer_constant_valid_p (TREE_OPERAND (value, 0), endtype);
4029
4030 /* Allow conversions between real types. */
4031 if (FLOAT_TYPE_P (TREE_TYPE (value))
4032 && FLOAT_TYPE_P (TREE_TYPE (TREE_OPERAND (value, 0))))
4033 return initializer_constant_valid_p (TREE_OPERAND (value, 0), endtype);
4034
4035 /* Allow length-preserving conversions between integer types. */
4036 if (INTEGRAL_TYPE_P (TREE_TYPE (value))
4037 && INTEGRAL_TYPE_P (TREE_TYPE (TREE_OPERAND (value, 0)))
4038 && (TYPE_PRECISION (TREE_TYPE (value))
4039 == TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (value, 0)))))
4040 return initializer_constant_valid_p (TREE_OPERAND (value, 0), endtype);
4041
4042 /* Allow conversions between other integer types only if
4043 explicit value. */
4044 if (INTEGRAL_TYPE_P (TREE_TYPE (value))
4045 && INTEGRAL_TYPE_P (TREE_TYPE (TREE_OPERAND (value, 0))))
4046 {
4047 tree inner = initializer_constant_valid_p (TREE_OPERAND (value, 0),
4048 endtype);
4049 if (inner == null_pointer_node)
4050 return null_pointer_node;
4051 break;
4052 }
4053
4054 /* Allow (int) &foo provided int is as wide as a pointer. */
4055 if (INTEGRAL_TYPE_P (TREE_TYPE (value))
4056 && POINTER_TYPE_P (TREE_TYPE (TREE_OPERAND (value, 0)))
4057 && (TYPE_PRECISION (TREE_TYPE (value))
4058 >= TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (value, 0)))))
4059 return initializer_constant_valid_p (TREE_OPERAND (value, 0),
4060 endtype);
4061
4062 /* Likewise conversions from int to pointers, but also allow
4063 conversions from 0. */
4064 if (POINTER_TYPE_P (TREE_TYPE (value))
4065 && INTEGRAL_TYPE_P (TREE_TYPE (TREE_OPERAND (value, 0))))
4066 {
4067 if (integer_zerop (TREE_OPERAND (value, 0)))
4068 return null_pointer_node;
4069 else if (TYPE_PRECISION (TREE_TYPE (value))
4070 <= TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (value, 0))))
4071 return initializer_constant_valid_p (TREE_OPERAND (value, 0),
4072 endtype);
4073 }
4074
4075 /* Allow conversions to union types if the value inside is okay. */
4076 if (TREE_CODE (TREE_TYPE (value)) == UNION_TYPE)
4077 return initializer_constant_valid_p (TREE_OPERAND (value, 0),
4078 endtype);
4079 break;
4080
4081 case PLUS_EXPR:
4082 if (! INTEGRAL_TYPE_P (endtype)
4083 || TYPE_PRECISION (endtype) >= POINTER_SIZE)
4084 {
4085 tree valid0 = initializer_constant_valid_p (TREE_OPERAND (value, 0),
4086 endtype);
4087 tree valid1 = initializer_constant_valid_p (TREE_OPERAND (value, 1),
4088 endtype);
4089 /* If either term is absolute, use the other terms relocation. */
4090 if (valid0 == null_pointer_node)
4091 return valid1;
4092 if (valid1 == null_pointer_node)
4093 return valid0;
4094 }
4095 break;
4096
4097 case MINUS_EXPR:
4098 if (! INTEGRAL_TYPE_P (endtype)
4099 || TYPE_PRECISION (endtype) >= POINTER_SIZE)
4100 {
4101 tree valid0 = initializer_constant_valid_p (TREE_OPERAND (value, 0),
4102 endtype);
4103 tree valid1 = initializer_constant_valid_p (TREE_OPERAND (value, 1),
4104 endtype);
4105 /* Win if second argument is absolute. */
4106 if (valid1 == null_pointer_node)
4107 return valid0;
4108 /* Win if both arguments have the same relocation.
4109 Then the value is absolute. */
4110 if (valid0 == valid1 && valid0 != 0)
4111 return null_pointer_node;
4112 }
4113
4114 /* Support differences between labels. */
4115 if (INTEGRAL_TYPE_P (endtype))
4116 {
4117 tree op0, op1;
4118 op0 = TREE_OPERAND (value, 0);
4119 op1 = TREE_OPERAND (value, 1);
4120 STRIP_NOPS (op0);
4121 STRIP_NOPS (op1);
4122
4123 if (TREE_CODE (op0) == ADDR_EXPR
4124 && TREE_CODE (TREE_OPERAND (op0, 0)) == LABEL_DECL
4125 && TREE_CODE (op1) == ADDR_EXPR
4126 && TREE_CODE (TREE_OPERAND (op1, 0)) == LABEL_DECL)
4127 return null_pointer_node;
4128 }
4129 break;
4130
4131 default:
4132 break;
4133 }
4134
4135 return 0;
4136 }
4137 \f
4138 /* Output assembler code for constant EXP to FILE, with no label.
4139 This includes the pseudo-op such as ".int" or ".byte", and a newline.
4140 Assumes output_addressed_constants has been done on EXP already.
4141
4142 Generate exactly SIZE bytes of assembler data, padding at the end
4143 with zeros if necessary. SIZE must always be specified.
4144
4145 SIZE is important for structure constructors,
4146 since trailing members may have been omitted from the constructor.
4147 It is also important for initialization of arrays from string constants
4148 since the full length of the string constant might not be wanted.
4149 It is also needed for initialization of unions, where the initializer's
4150 type is just one member, and that may not be as long as the union.
4151
4152 There a case in which we would fail to output exactly SIZE bytes:
4153 for a structure constructor that wants to produce more than SIZE bytes.
4154 But such constructors will never be generated for any possible input. */
4155
4156 void
4157 output_constant (exp, size)
4158 register tree exp;
4159 register int size;
4160 {
4161 register enum tree_code code = TREE_CODE (TREE_TYPE (exp));
4162
4163 /* Some front-ends use constants other than the standard
4164 language-indepdent varieties, but which may still be output
4165 directly. Give the front-end a chance to convert EXP to a
4166 language-independent representation. */
4167 if (lang_expand_constant)
4168 exp = (*lang_expand_constant) (exp);
4169
4170 if (size == 0 || flag_syntax_only)
4171 return;
4172
4173 /* Eliminate the NON_LVALUE_EXPR_EXPR that makes a cast not be an lvalue.
4174 That way we get the constant (we hope) inside it. Also, strip off any
4175 NOP_EXPR that converts between two record, union, array, or set types
4176 or a CONVERT_EXPR that converts to a union TYPE. */
4177 while ((TREE_CODE (exp) == NOP_EXPR
4178 && (TREE_TYPE (exp) == TREE_TYPE (TREE_OPERAND (exp, 0))
4179 || AGGREGATE_TYPE_P (TREE_TYPE (exp))))
4180 || (TREE_CODE (exp) == CONVERT_EXPR
4181 && code == UNION_TYPE)
4182 || TREE_CODE (exp) == NON_LVALUE_EXPR)
4183 {
4184 exp = TREE_OPERAND (exp, 0);
4185 code = TREE_CODE (TREE_TYPE (exp));
4186 }
4187
4188 /* Allow a constructor with no elements for any data type.
4189 This means to fill the space with zeros. */
4190 if (TREE_CODE (exp) == CONSTRUCTOR && CONSTRUCTOR_ELTS (exp) == 0)
4191 {
4192 assemble_zeros (size);
4193 return;
4194 }
4195
4196 switch (code)
4197 {
4198 case CHAR_TYPE:
4199 case BOOLEAN_TYPE:
4200 case INTEGER_TYPE:
4201 case ENUMERAL_TYPE:
4202 case POINTER_TYPE:
4203 case REFERENCE_TYPE:
4204 /* ??? What about (int)((float)(int)&foo + 4) */
4205 while (TREE_CODE (exp) == NOP_EXPR || TREE_CODE (exp) == CONVERT_EXPR
4206 || TREE_CODE (exp) == NON_LVALUE_EXPR)
4207 exp = TREE_OPERAND (exp, 0);
4208
4209 if (! assemble_integer (expand_expr (exp, NULL_RTX, VOIDmode,
4210 EXPAND_INITIALIZER),
4211 size, 0))
4212 error ("initializer for integer value is too complicated");
4213 size = 0;
4214 break;
4215
4216 case REAL_TYPE:
4217 if (TREE_CODE (exp) != REAL_CST)
4218 error ("initializer for floating value is not a floating constant");
4219
4220 assemble_real (TREE_REAL_CST (exp),
4221 mode_for_size (size * BITS_PER_UNIT, MODE_FLOAT, 0));
4222 size = 0;
4223 break;
4224
4225 case COMPLEX_TYPE:
4226 output_constant (TREE_REALPART (exp), size / 2);
4227 output_constant (TREE_IMAGPART (exp), size / 2);
4228 size -= (size / 2) * 2;
4229 break;
4230
4231 case ARRAY_TYPE:
4232 if (TREE_CODE (exp) == CONSTRUCTOR)
4233 {
4234 output_constructor (exp, size);
4235 return;
4236 }
4237 else if (TREE_CODE (exp) == STRING_CST)
4238 {
4239 int excess = 0;
4240
4241 if (size > TREE_STRING_LENGTH (exp))
4242 {
4243 excess = size - TREE_STRING_LENGTH (exp);
4244 size = TREE_STRING_LENGTH (exp);
4245 }
4246
4247 assemble_string (TREE_STRING_POINTER (exp), size);
4248 size = excess;
4249 }
4250 else
4251 abort ();
4252 break;
4253
4254 case RECORD_TYPE:
4255 case UNION_TYPE:
4256 if (TREE_CODE (exp) == CONSTRUCTOR)
4257 output_constructor (exp, size);
4258 else
4259 abort ();
4260 return;
4261
4262 case SET_TYPE:
4263 if (TREE_CODE (exp) == INTEGER_CST)
4264 assemble_integer (expand_expr (exp, NULL_RTX,
4265 VOIDmode, EXPAND_INITIALIZER),
4266 size, 1);
4267 else if (TREE_CODE (exp) == CONSTRUCTOR)
4268 {
4269 unsigned char *buffer = (unsigned char *) alloca (size);
4270 if (get_set_constructor_bytes (exp, buffer, size))
4271 abort ();
4272 assemble_string ((char *) buffer, size);
4273 }
4274 else
4275 error ("unknown set constructor type");
4276 return;
4277
4278 default:
4279 break; /* ??? */
4280 }
4281
4282 if (size > 0)
4283 assemble_zeros (size);
4284 }
4285
4286 \f
4287 /* Subroutine of output_constant, used for CONSTRUCTORs
4288 (aggregate constants).
4289 Generate at least SIZE bytes, padding if necessary. */
4290
4291 static void
4292 output_constructor (exp, size)
4293 tree exp;
4294 int size;
4295 {
4296 tree type = TREE_TYPE (exp);
4297 register tree link, field = 0;
4298 tree min_index = 0;
4299 /* Number of bytes output or skipped so far.
4300 In other words, current position within the constructor. */
4301 HOST_WIDE_INT total_bytes = 0;
4302 /* Non-zero means BYTE contains part of a byte, to be output. */
4303 int byte_buffer_in_use = 0;
4304 register int byte = 0;
4305
4306 if (HOST_BITS_PER_WIDE_INT < BITS_PER_UNIT)
4307 abort ();
4308
4309 if (TREE_CODE (type) == RECORD_TYPE)
4310 field = TYPE_FIELDS (type);
4311
4312 if (TREE_CODE (type) == ARRAY_TYPE
4313 && TYPE_DOMAIN (type) != 0)
4314 min_index = TYPE_MIN_VALUE (TYPE_DOMAIN (type));
4315
4316 /* As LINK goes through the elements of the constant,
4317 FIELD goes through the structure fields, if the constant is a structure.
4318 if the constant is a union, then we override this,
4319 by getting the field from the TREE_LIST element.
4320 But the constant could also be an array. Then FIELD is zero.
4321
4322 There is always a maximum of one element in the chain LINK for unions
4323 (even if the initializer in a source program incorrectly contains
4324 more one). */
4325 for (link = CONSTRUCTOR_ELTS (exp);
4326 link;
4327 link = TREE_CHAIN (link),
4328 field = field ? TREE_CHAIN (field) : 0)
4329 {
4330 tree val = TREE_VALUE (link);
4331 tree index = 0;
4332
4333 /* The element in a union constructor specifies the proper field
4334 or index. */
4335 if ((TREE_CODE (type) == RECORD_TYPE || TREE_CODE (type) == UNION_TYPE
4336 || TREE_CODE (type) == QUAL_UNION_TYPE)
4337 && TREE_PURPOSE (link) != 0)
4338 field = TREE_PURPOSE (link);
4339
4340 else if (TREE_CODE (type) == ARRAY_TYPE)
4341 index = TREE_PURPOSE (link);
4342
4343 /* Eliminate the marker that makes a cast not be an lvalue. */
4344 if (val != 0)
4345 STRIP_NOPS (val);
4346
4347 if (index && TREE_CODE (index) == RANGE_EXPR)
4348 {
4349 register int fieldsize
4350 = int_size_in_bytes (TREE_TYPE (type));
4351 HOST_WIDE_INT lo_index = tree_low_cst (TREE_OPERAND (index, 0), 0);
4352 HOST_WIDE_INT hi_index = tree_low_cst (TREE_OPERAND (index, 1), 0);
4353 HOST_WIDE_INT index;
4354
4355 for (index = lo_index; index <= hi_index; index++)
4356 {
4357 /* Output the element's initial value. */
4358 if (val == 0)
4359 assemble_zeros (fieldsize);
4360 else
4361 output_constant (val, fieldsize);
4362
4363 /* Count its size. */
4364 total_bytes += fieldsize;
4365 }
4366 }
4367 else if (field == 0 || !DECL_BIT_FIELD (field))
4368 {
4369 /* An element that is not a bit-field. */
4370
4371 register int fieldsize;
4372 /* Since this structure is static,
4373 we know the positions are constant. */
4374 HOST_WIDE_INT pos = field ? int_byte_position (field) : 0;
4375
4376 if (index != 0)
4377 pos = (tree_low_cst (TYPE_SIZE_UNIT (TREE_TYPE (val)), 1)
4378 * (tree_low_cst (index, 0) - tree_low_cst (min_index, 0)));
4379
4380 /* Output any buffered-up bit-fields preceding this element. */
4381 if (byte_buffer_in_use)
4382 {
4383 ASM_OUTPUT_BYTE (asm_out_file, byte);
4384 total_bytes++;
4385 byte_buffer_in_use = 0;
4386 }
4387
4388 /* Advance to offset of this element.
4389 Note no alignment needed in an array, since that is guaranteed
4390 if each element has the proper size. */
4391 if ((field != 0 || index != 0) && pos != total_bytes)
4392 {
4393 assemble_zeros (pos - total_bytes);
4394 total_bytes = pos;
4395 }
4396
4397 else if (field != 0 && DECL_PACKED (field))
4398 /* Some assemblers automaticallly align a datum according to its
4399 size if no align directive is specified. The datum, however,
4400 may be declared with 'packed' attribute, so we have to disable
4401 such a feature. */
4402 ASM_OUTPUT_ALIGN (asm_out_file, 0);
4403
4404 /* Determine size this element should occupy. */
4405 if (field)
4406 fieldsize = tree_low_cst (DECL_SIZE_UNIT (field), 1);
4407 else
4408 fieldsize = int_size_in_bytes (TREE_TYPE (type));
4409
4410 /* Output the element's initial value. */
4411 if (val == 0)
4412 assemble_zeros (fieldsize);
4413 else
4414 output_constant (val, fieldsize);
4415
4416 /* Count its size. */
4417 total_bytes += fieldsize;
4418 }
4419 else if (val != 0 && TREE_CODE (val) != INTEGER_CST)
4420 error ("invalid initial value for member `%s'",
4421 IDENTIFIER_POINTER (DECL_NAME (field)));
4422 else
4423 {
4424 /* Element that is a bit-field. */
4425
4426 HOST_WIDE_INT next_offset = int_bit_position (field);
4427 HOST_WIDE_INT end_offset
4428 = (next_offset + tree_low_cst (DECL_SIZE (field), 1));
4429
4430 if (val == 0)
4431 val = integer_zero_node;
4432
4433 /* If this field does not start in this (or, next) byte,
4434 skip some bytes. */
4435 if (next_offset / BITS_PER_UNIT != total_bytes)
4436 {
4437 /* Output remnant of any bit field in previous bytes. */
4438 if (byte_buffer_in_use)
4439 {
4440 ASM_OUTPUT_BYTE (asm_out_file, byte);
4441 total_bytes++;
4442 byte_buffer_in_use = 0;
4443 }
4444
4445 /* If still not at proper byte, advance to there. */
4446 if (next_offset / BITS_PER_UNIT != total_bytes)
4447 {
4448 assemble_zeros (next_offset / BITS_PER_UNIT - total_bytes);
4449 total_bytes = next_offset / BITS_PER_UNIT;
4450 }
4451 }
4452
4453 if (! byte_buffer_in_use)
4454 byte = 0;
4455
4456 /* We must split the element into pieces that fall within
4457 separate bytes, and combine each byte with previous or
4458 following bit-fields. */
4459
4460 /* next_offset is the offset n fbits from the beginning of
4461 the structure to the next bit of this element to be processed.
4462 end_offset is the offset of the first bit past the end of
4463 this element. */
4464 while (next_offset < end_offset)
4465 {
4466 int this_time;
4467 int shift;
4468 HOST_WIDE_INT value;
4469 HOST_WIDE_INT next_byte = next_offset / BITS_PER_UNIT;
4470 HOST_WIDE_INT next_bit = next_offset % BITS_PER_UNIT;
4471
4472 /* Advance from byte to byte
4473 within this element when necessary. */
4474 while (next_byte != total_bytes)
4475 {
4476 ASM_OUTPUT_BYTE (asm_out_file, byte);
4477 total_bytes++;
4478 byte = 0;
4479 }
4480
4481 /* Number of bits we can process at once
4482 (all part of the same byte). */
4483 this_time = MIN (end_offset - next_offset,
4484 BITS_PER_UNIT - next_bit);
4485 if (BYTES_BIG_ENDIAN)
4486 {
4487 /* On big-endian machine, take the most significant bits
4488 first (of the bits that are significant)
4489 and put them into bytes from the most significant end. */
4490 shift = end_offset - next_offset - this_time;
4491
4492 /* Don't try to take a bunch of bits that cross
4493 the word boundary in the INTEGER_CST. We can
4494 only select bits from the LOW or HIGH part
4495 not from both. */
4496 if (shift < HOST_BITS_PER_WIDE_INT
4497 && shift + this_time > HOST_BITS_PER_WIDE_INT)
4498 {
4499 this_time = shift + this_time - HOST_BITS_PER_WIDE_INT;
4500 shift = HOST_BITS_PER_WIDE_INT;
4501 }
4502
4503 /* Now get the bits from the appropriate constant word. */
4504 if (shift < HOST_BITS_PER_WIDE_INT)
4505 value = TREE_INT_CST_LOW (val);
4506 else if (shift < 2 * HOST_BITS_PER_WIDE_INT)
4507 {
4508 value = TREE_INT_CST_HIGH (val);
4509 shift -= HOST_BITS_PER_WIDE_INT;
4510 }
4511 else
4512 abort ();
4513
4514 /* Get the result. This works only when:
4515 1 <= this_time <= HOST_BITS_PER_WIDE_INT. */
4516 byte |= (((value >> shift)
4517 & (((HOST_WIDE_INT) 2 << (this_time - 1)) - 1))
4518 << (BITS_PER_UNIT - this_time - next_bit));
4519 }
4520 else
4521 {
4522 /* On little-endian machines,
4523 take first the least significant bits of the value
4524 and pack them starting at the least significant
4525 bits of the bytes. */
4526 shift = next_offset - int_bit_position (field);
4527
4528 /* Don't try to take a bunch of bits that cross
4529 the word boundary in the INTEGER_CST. We can
4530 only select bits from the LOW or HIGH part
4531 not from both. */
4532 if (shift < HOST_BITS_PER_WIDE_INT
4533 && shift + this_time > HOST_BITS_PER_WIDE_INT)
4534 this_time = (HOST_BITS_PER_WIDE_INT - shift);
4535
4536 /* Now get the bits from the appropriate constant word. */
4537 if (shift < HOST_BITS_PER_WIDE_INT)
4538 value = TREE_INT_CST_LOW (val);
4539 else if (shift < 2 * HOST_BITS_PER_WIDE_INT)
4540 {
4541 value = TREE_INT_CST_HIGH (val);
4542 shift -= HOST_BITS_PER_WIDE_INT;
4543 }
4544 else
4545 abort ();
4546
4547 /* Get the result. This works only when:
4548 1 <= this_time <= HOST_BITS_PER_WIDE_INT. */
4549 byte |= (((value >> shift)
4550 & (((HOST_WIDE_INT) 2 << (this_time - 1)) - 1))
4551 << next_bit);
4552 }
4553
4554 next_offset += this_time;
4555 byte_buffer_in_use = 1;
4556 }
4557 }
4558 }
4559
4560 if (byte_buffer_in_use)
4561 {
4562 ASM_OUTPUT_BYTE (asm_out_file, byte);
4563 total_bytes++;
4564 }
4565
4566 if (total_bytes < size)
4567 assemble_zeros (size - total_bytes);
4568 }
4569
4570 #ifdef HANDLE_PRAGMA_WEAK
4571 /* Add function NAME to the weak symbols list. VALUE is a weak alias
4572 associatd with NAME. */
4573
4574 int
4575 add_weak (name, value)
4576 const char *name;
4577 const char *value;
4578 {
4579 struct weak_syms *weak;
4580
4581 weak = (struct weak_syms *) permalloc (sizeof (struct weak_syms));
4582
4583 if (weak == NULL)
4584 return 0;
4585
4586 weak->next = weak_decls;
4587 weak->name = name;
4588 weak->value = value;
4589 weak_decls = weak;
4590
4591 return 1;
4592 }
4593 #endif /* HANDLE_PRAGMA_WEAK */
4594
4595 /* Declare DECL to be a weak symbol. */
4596
4597 void
4598 declare_weak (decl)
4599 tree decl;
4600 {
4601 if (! TREE_PUBLIC (decl))
4602 error_with_decl (decl, "weak declaration of `%s' must be public");
4603 else if (TREE_ASM_WRITTEN (decl))
4604 error_with_decl (decl, "weak declaration of `%s' must precede definition");
4605 else if (SUPPORTS_WEAK)
4606 DECL_WEAK (decl) = 1;
4607 #ifdef HANDLE_PRAGMA_WEAK
4608 add_weak (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)), NULL);
4609 #endif
4610 }
4611
4612 /* Emit any pending weak declarations. */
4613
4614 #ifdef HANDLE_PRAGMA_WEAK
4615 struct weak_syms * weak_decls;
4616 #endif
4617
4618 void
4619 weak_finish ()
4620 {
4621 #ifdef HANDLE_PRAGMA_WEAK
4622 if (HANDLE_PRAGMA_WEAK)
4623 {
4624 struct weak_syms *t;
4625 for (t = weak_decls; t; t = t->next)
4626 {
4627 if (t->name)
4628 {
4629 ASM_WEAKEN_LABEL (asm_out_file, t->name);
4630 if (t->value)
4631 ASM_OUTPUT_DEF (asm_out_file, t->name, t->value);
4632 }
4633 }
4634 }
4635 #endif
4636 }
4637
4638 /* Remove NAME from the pending list of weak symbols. This prevents
4639 the compiler from emitting multiple .weak directives which confuses
4640 some assemblers. */
4641 #ifdef ASM_WEAKEN_LABEL
4642 static void
4643 remove_from_pending_weak_list (name)
4644 const char *name ATTRIBUTE_UNUSED;
4645 {
4646 #ifdef HANDLE_PRAGMA_WEAK
4647 if (HANDLE_PRAGMA_WEAK)
4648 {
4649 struct weak_syms *t;
4650 for (t = weak_decls; t; t = t->next)
4651 {
4652 if (t->name && strcmp (name, t->name) == 0)
4653 t->name = NULL;
4654 }
4655 }
4656 #endif
4657 }
4658 #endif
4659
4660 void
4661 assemble_alias (decl, target)
4662 tree decl, target ATTRIBUTE_UNUSED;
4663 {
4664 const char *name;
4665
4666 make_decl_rtl (decl, (char *) 0, 1);
4667 name = XSTR (XEXP (DECL_RTL (decl), 0), 0);
4668
4669 #ifdef ASM_OUTPUT_DEF
4670 /* Make name accessible from other files, if appropriate. */
4671
4672 if (TREE_PUBLIC (decl))
4673 {
4674 #ifdef ASM_WEAKEN_LABEL
4675 if (DECL_WEAK (decl))
4676 {
4677 ASM_WEAKEN_LABEL (asm_out_file, name);
4678 /* Remove this function from the pending weak list so that
4679 we do not emit multiple .weak directives for it. */
4680 remove_from_pending_weak_list
4681 (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
4682 }
4683 else
4684 #endif
4685 ASM_GLOBALIZE_LABEL (asm_out_file, name);
4686 }
4687
4688 #ifdef ASM_OUTPUT_DEF_FROM_DECLS
4689 ASM_OUTPUT_DEF_FROM_DECLS (asm_out_file, decl, target);
4690 #else
4691 ASM_OUTPUT_DEF (asm_out_file, name, IDENTIFIER_POINTER (target));
4692 #endif
4693 TREE_ASM_WRITTEN (decl) = 1;
4694 #else
4695 #ifdef ASM_OUTPUT_WEAK_ALIAS
4696 if (! DECL_WEAK (decl))
4697 warning ("only weak aliases are supported in this configuration");
4698
4699 ASM_OUTPUT_WEAK_ALIAS (asm_out_file, name, IDENTIFIER_POINTER (target));
4700 TREE_ASM_WRITTEN (decl) = 1;
4701 #else
4702 warning ("alias definitions not supported in this configuration; ignored");
4703 #endif
4704 #endif
4705 }
4706
4707 /* This determines whether or not we support link-once semantics. */
4708 #ifndef SUPPORTS_ONE_ONLY
4709 #ifdef MAKE_DECL_ONE_ONLY
4710 #define SUPPORTS_ONE_ONLY 1
4711 #else
4712 #define SUPPORTS_ONE_ONLY 0
4713 #endif
4714 #endif
4715
4716 /* Returns 1 if the target configuration supports defining public symbols
4717 so that one of them will be chosen at link time instead of generating a
4718 multiply-defined symbol error, whether through the use of weak symbols or
4719 a target-specific mechanism for having duplicates discarded. */
4720
4721 int
4722 supports_one_only ()
4723 {
4724 if (SUPPORTS_ONE_ONLY)
4725 return 1;
4726 return SUPPORTS_WEAK;
4727 }
4728
4729 /* Set up DECL as a public symbol that can be defined in multiple
4730 translation units without generating a linker error. */
4731
4732 void
4733 make_decl_one_only (decl)
4734 tree decl;
4735 {
4736 if (TREE_CODE (decl) != VAR_DECL && TREE_CODE (decl) != FUNCTION_DECL)
4737 abort ();
4738
4739 TREE_PUBLIC (decl) = 1;
4740
4741 if (TREE_CODE (decl) == VAR_DECL
4742 && (DECL_INITIAL (decl) == 0 || DECL_INITIAL (decl) == error_mark_node))
4743 DECL_COMMON (decl) = 1;
4744 else if (SUPPORTS_ONE_ONLY)
4745 {
4746 #ifdef MAKE_DECL_ONE_ONLY
4747 MAKE_DECL_ONE_ONLY (decl);
4748 #endif
4749 DECL_ONE_ONLY (decl) = 1;
4750 }
4751 else if (SUPPORTS_WEAK)
4752 DECL_WEAK (decl) = 1;
4753 else
4754 abort ();
4755 }
4756
4757 void
4758 init_varasm_once ()
4759 {
4760 ggc_add_root (const_hash_table, MAX_HASH_TABLE, sizeof const_hash_table[0],
4761 mark_const_hash_entry);
4762 ggc_add_string_root (&in_named_name, 1);
4763 }
4764
4765 /* Extra support for EH values. */
4766 void
4767 assemble_eh_label (name)
4768 const char *name;
4769 {
4770 #ifdef ASM_OUTPUT_EH_LABEL
4771 ASM_OUTPUT_EH_LABEL (asm_out_file, name);
4772 #else
4773 assemble_label (name);
4774 #endif
4775 }
4776
4777 /* Assemble an alignment pseudo op for an ALIGN-bit boundary. */
4778
4779 void
4780 assemble_eh_align (align)
4781 int align;
4782 {
4783 #ifdef ASM_OUTPUT_EH_ALIGN
4784 if (align > BITS_PER_UNIT)
4785 ASM_OUTPUT_EH_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT));
4786 #else
4787 assemble_align (align);
4788 #endif
4789 }
4790
4791
4792 /* On some platforms, we may want to specify a special mechansim to
4793 output EH data when generating with a function.. */
4794 int
4795 assemble_eh_integer (x, size, force)
4796 rtx x;
4797 int size;
4798 int force;
4799 {
4800
4801 switch (size)
4802 {
4803 #ifdef ASM_OUTPUT_EH_CHAR
4804 case 1:
4805 ASM_OUTPUT_EH_CHAR (asm_out_file, x);
4806 return 1;
4807 #endif
4808
4809 #ifdef ASM_OUTPUT_EH_SHORT
4810 case 2:
4811 ASM_OUTPUT_EH_SHORT (asm_out_file, x);
4812 return 1;
4813 #endif
4814
4815 #ifdef ASM_OUTPUT_EH_INT
4816 case 4:
4817 ASM_OUTPUT_EH_INT (asm_out_file, x);
4818 return 1;
4819 #endif
4820
4821 #ifdef ASM_OUTPUT_EH_DOUBLE_INT
4822 case 8:
4823 ASM_OUTPUT_EH_DOUBLE_INT (asm_out_file, x);
4824 return 1;
4825 #endif
4826
4827 default:
4828 break;
4829 }
4830 return (assemble_integer (x, size, force));
4831 }
4832
4833
4834