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