OSDN Git Service

(make_decl_rtl): If a variable has an asm operand that refers to,
[pf3gnuchains/gcc-fork.git] / gcc / varasm.c
1 /* Output variables, constants and external declarations, for GNU compiler.
2    Copyright (C) 1987, 1988, 1989, 1992 Free Software Foundation, Inc.
3
4 This file is part of GNU CC.
5
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING.  If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
19
20
21 /* This file handles generation of all the assembler code
22    *except* the instructions of a function.
23    This includes declarations of variables and their initial values.
24
25    We also output the assembler code for constants stored in memory
26    and are responsible for combining constants with the same value.  */
27
28 #include <stdio.h>
29 #include <setjmp.h>
30 /* #include <stab.h> */
31 #include "config.h"
32 #include "rtl.h"
33 #include "tree.h"
34 #include "flags.h"
35 #include "function.h"
36 #include "expr.h"
37 #include "hard-reg-set.h"
38 #include "regs.h"
39 #include "defaults.h"
40 #include "real.h"
41
42 #include "obstack.h"
43
44 #ifdef XCOFF_DEBUGGING_INFO
45 #include "xcoffout.h"
46 #endif
47
48 #ifndef ASM_STABS_OP
49 #define ASM_STABS_OP ".stabs"
50 #endif
51
52 /* This macro gets just the user-specified name
53    out of the string in a SYMBOL_REF.  On most machines,
54    we discard the * if any and that's all.  */
55 #ifndef STRIP_NAME_ENCODING
56 #define STRIP_NAME_ENCODING(VAR,SYMBOL_NAME) \
57   (VAR) = ((SYMBOL_NAME) + ((SYMBOL_NAME)[0] == '*'))
58 #endif
59
60 /* File in which assembler code is being written.  */
61
62 extern FILE *asm_out_file;
63
64 /* The (assembler) name of the first globally-visible object output.  */
65 char *first_global_object_name;
66
67 extern struct obstack *current_obstack;
68 extern struct obstack *saveable_obstack;
69 extern struct obstack permanent_obstack;
70 #define obstack_chunk_alloc xmalloc
71
72 /* Number for making the label on the next
73    constant that is stored in memory.  */
74
75 int const_labelno;
76
77 /* Number for making the label on the next
78    static variable internal to a function.  */
79
80 int var_labelno;
81
82 /* Nonzero if at least one function definition has been seen.  */
83 static int function_defined;
84
85 extern FILE *asm_out_file;
86
87 static char *compare_constant_1 ();
88 static void record_constant_1 ();
89 void output_constant_pool ();
90 void assemble_name ();
91 int output_addressed_constants ();
92 void output_constant ();
93 void output_constructor ();
94 void text_section ();
95 void readonly_data_section ();
96 void data_section ();
97 \f
98 #ifdef EXTRA_SECTIONS
99 static enum in_section {no_section, in_text, in_data, EXTRA_SECTIONS} in_section
100   = no_section;
101 #else
102 static enum in_section {no_section, in_text, in_data} in_section
103   = no_section;
104 #endif
105
106 /* Define functions like text_section for any extra sections.  */
107 #ifdef EXTRA_SECTION_FUNCTIONS
108 EXTRA_SECTION_FUNCTIONS
109 #endif
110
111 /* Tell assembler to switch to text section.  */
112
113 void
114 text_section ()
115 {
116   if (in_section != in_text)
117     {
118       fprintf (asm_out_file, "%s\n", TEXT_SECTION_ASM_OP);
119       in_section = in_text;
120     }
121 }
122
123 /* Tell assembler to switch to data section.  */
124
125 void
126 data_section ()
127 {
128   if (in_section != in_data)
129     {
130       if (flag_shared_data)
131         {
132 #ifdef SHARED_SECTION_ASM_OP
133           fprintf (asm_out_file, "%s\n", SHARED_SECTION_ASM_OP);
134 #else
135           fprintf (asm_out_file, "%s\n", DATA_SECTION_ASM_OP);
136 #endif
137         }
138       else
139         fprintf (asm_out_file, "%s\n", DATA_SECTION_ASM_OP);
140
141       in_section = in_data;
142     }
143 }
144
145 /* Tell assembler to switch to read-only data section.  This is normally
146    the text section.  */
147
148 void
149 readonly_data_section ()
150 {
151 #ifdef READONLY_DATA_SECTION
152   READONLY_DATA_SECTION ();  /* Note this can call data_section.  */
153 #else
154   text_section ();
155 #endif
156 }
157
158 /* Determine if we're in the text section. */
159
160 int
161 in_text_section ()
162 {
163   return in_section == in_text;
164 }
165 \f
166 /* Create the rtl to represent a function, for a function definition.
167    DECL is a FUNCTION_DECL node which describes which function.
168    The rtl is stored into DECL.  */
169
170 void
171 make_function_rtl (decl)
172      tree decl;
173 {
174   char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
175
176   /* Rename a nested function to avoid conflicts.  */
177   if (decl_function_context (decl) != 0
178       && DECL_INITIAL (decl) != 0
179       && DECL_RTL (decl) == 0)
180     {
181       char *label;
182
183       name = IDENTIFIER_POINTER (DECL_NAME (decl));
184       ASM_FORMAT_PRIVATE_NAME (label, name, var_labelno);
185       name = obstack_copy0 (saveable_obstack, label, strlen (label));
186       var_labelno++;
187     }
188
189   if (DECL_RTL (decl) == 0)
190     {
191       DECL_RTL (decl)
192         = gen_rtx (MEM, DECL_MODE (decl),
193                    gen_rtx (SYMBOL_REF, Pmode, name));
194
195       /* Optionally set flags or add text to the name to record information
196          such as that it is a function name.  If the name is changed, the macro
197          ASM_OUTPUT_LABELREF will have to know how to strip this information.
198          And if it finds a * at the beginning after doing so, it must handle
199          that too.  */
200 #ifdef ENCODE_SECTION_INFO
201       ENCODE_SECTION_INFO (decl);
202 #endif
203     }
204
205   /* Record at least one function has been defined.  */
206   function_defined = 1;
207 }
208
209 /* Given NAME, a putative register name, discard any customary prefixes.  */
210
211 static char *
212 strip_reg_name (name)
213      char *name;
214 {
215 #ifdef REGISTER_PREFIX
216   if (!strncmp (name, REGISTER_PREFIX, strlen (REGISTER_PREFIX)))
217     name += strlen (REGISTER_PREFIX);
218 #endif
219   if (name[0] == '%' || name[0] == '#')
220     name++;
221   return name;
222 }
223 \f
224 /* Decode an `asm' spec for a declaration as a register name.
225    Return the register number, or -1 if nothing specified,
226    or -2 if the ASMSPEC is not `cc' or `memory' and is not recognized,
227    or -3 if ASMSPEC is `cc' and is not recognized,
228    or -4 if ASMSPEC is `memory' and is not recognized.
229    Accept an exact spelling or a decimal number.
230    Prefixes such as % are optional.  */
231
232 int
233 decode_reg_name (asmspec)
234      char *asmspec;
235 {
236   if (asmspec != 0)
237     {
238       int i;
239
240       /* Get rid of confusing prefixes.  */
241       asmspec = strip_reg_name (asmspec);
242         
243       /* Allow a decimal number as a "register name".  */
244       for (i = strlen (asmspec) - 1; i >= 0; i--)
245         if (! (asmspec[i] >= '0' && asmspec[i] <= '9'))
246           break;
247       if (asmspec[0] != 0 && i < 0)
248         {
249           i = atoi (asmspec);
250           if (i < FIRST_PSEUDO_REGISTER && i >= 0)
251             return i;
252           else
253             return -2;
254         }
255
256       for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
257         if (reg_names[i][0]
258             && ! strcmp (asmspec, strip_reg_name (reg_names[i])))
259           return i;
260
261 #ifdef ADDITIONAL_REGISTER_NAMES
262       {
263         static struct { char *name; int number; } table[]
264           = ADDITIONAL_REGISTER_NAMES;
265
266         for (i = 0; i < sizeof (table) / sizeof (table[0]); i++)
267           if (! strcmp (asmspec, table[i].name))
268             return table[i].number;
269       }
270 #endif /* ADDITIONAL_REGISTER_NAMES */
271
272       if (!strcmp (asmspec, "memory"))
273         return -4;
274
275       if (!strcmp (asmspec, "cc"))
276         return -3;
277
278       return -2;
279     }
280
281   return -1;
282 }
283 \f
284 /* Create the DECL_RTL for a declaration for a static or external variable
285    or static or external function.
286    ASMSPEC, if not 0, is the string which the user specified
287    as the assembler symbol name.
288    TOP_LEVEL is nonzero if this is a file-scope variable.
289
290    This is never called for PARM_DECL nodes.  */
291
292 void
293 make_decl_rtl (decl, asmspec, top_level)
294      tree decl;
295      char *asmspec;
296      int top_level;
297 {
298   register char *name;
299   int reg_number = decode_reg_name (asmspec);
300
301   if (DECL_ASSEMBLER_NAME (decl) != NULL_TREE)
302     name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
303
304   if (reg_number == -2)
305     {
306       /* ASMSPEC is given, and not the name of a register.  */
307       name = (char *) obstack_alloc (saveable_obstack,
308                                      strlen (asmspec) + 2);
309       name[0] = '*';
310       strcpy (&name[1], asmspec);
311     }
312
313   /* For a duplicate declaration, we can be called twice on the
314      same DECL node.  Don't alter the RTL already made
315      unless the old mode is wrong (which can happen when
316      the previous rtl was made when the type was incomplete).  */
317   if (DECL_RTL (decl) == 0
318       || GET_MODE (DECL_RTL (decl)) != DECL_MODE (decl))
319     {
320       DECL_RTL (decl) = 0;
321
322       /* First detect errors in declaring global registers.  */
323       if (DECL_REGISTER (decl) && reg_number == -1)
324         error_with_decl (decl,
325                          "register name not specified for `%s'");
326       else if (DECL_REGISTER (decl) && reg_number < 0)
327         error_with_decl (decl,
328                          "invalid register name for `%s'");
329       else if ((reg_number >= 0 || reg_number == -3) && ! DECL_REGISTER (decl))
330         error_with_decl (decl,
331                          "register name given for non-register variable `%s'");
332       else if (DECL_REGISTER (decl) && TREE_CODE (decl) == FUNCTION_DECL)
333         error ("function declared `register'");
334       else if (DECL_REGISTER (decl) && TYPE_MODE (TREE_TYPE (decl)) == BLKmode)
335         error_with_decl (decl, "data type of `%s' isn't suitable for a register");
336       else if (DECL_REGISTER (decl)
337                && ! HARD_REGNO_MODE_OK (reg_number, TYPE_MODE (TREE_TYPE (decl))))
338         error_with_decl (decl, "register number for `%s' isn't suitable for the data type");
339       /* Now handle properly declared static register variables.  */
340       else if (DECL_REGISTER (decl))
341         {
342           int nregs;
343 #if 0 /* yylex should print the warning for this */
344           if (pedantic)
345             pedwarn ("ANSI C forbids global register variables");
346 #endif
347           if (DECL_INITIAL (decl) != 0 && top_level)
348             {
349               DECL_INITIAL (decl) = 0;
350               error ("global register variable has initial value");
351             }
352           if (fixed_regs[reg_number] == 0
353               && function_defined && top_level)
354             error ("global register variable follows a function definition");
355           if (TREE_THIS_VOLATILE (decl))
356             warning ("volatile register variables don't work as you might wish");
357
358           /* If the user specified one of the eliminables registers here,
359              e.g., FRAME_POINTER_REGNUM, we don't want to get this variable
360              confused with that register and be eliminated.  Although this
361              usage is somewhat suspect, we nevertheless use the following
362              kludge to avoid setting DECL_RTL to frame_pointer_rtx.  */
363
364           DECL_RTL (decl)
365             = gen_rtx (REG, DECL_MODE (decl), FIRST_PSEUDO_REGISTER);
366           REGNO (DECL_RTL (decl)) = reg_number;
367           REG_USERVAR_P (DECL_RTL (decl)) = 1;
368
369           if (top_level)
370             {
371               /* Make this register fixed, so not usable for anything else.  */
372               nregs = HARD_REGNO_NREGS (reg_number, DECL_MODE (decl));
373               while (nregs > 0)
374                 global_regs[reg_number + --nregs] = 1;
375               init_reg_sets_1 ();
376             }
377         }
378
379       /* Now handle ordinary static variables and functions (in memory).
380          Also handle vars declared register invalidly.  */
381       if (DECL_RTL (decl) == 0)
382         {
383           /* Can't use just the variable's own name for a variable
384              whose scope is less than the whole file.
385              Concatenate a distinguishing number.  */
386           if (!top_level && !DECL_EXTERNAL (decl) && asmspec == 0)
387             {
388               char *label;
389
390               ASM_FORMAT_PRIVATE_NAME (label, name, var_labelno);
391               name = obstack_copy0 (saveable_obstack, label, strlen (label));
392               var_labelno++;
393             }
394
395           DECL_RTL (decl) = gen_rtx (MEM, DECL_MODE (decl),
396                                      gen_rtx (SYMBOL_REF, Pmode, name));
397           if (TREE_THIS_VOLATILE (decl)
398             || (flag_volatile_global && TREE_CODE (decl) == VAR_DECL
399                 && TREE_PUBLIC (decl)))
400             MEM_VOLATILE_P (DECL_RTL (decl)) = 1;
401           if (TREE_READONLY (decl))
402             RTX_UNCHANGING_P (DECL_RTL (decl)) = 1;
403           MEM_IN_STRUCT_P (DECL_RTL (decl))
404             = (TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE
405                || TREE_CODE (TREE_TYPE (decl)) == RECORD_TYPE
406                || TREE_CODE (TREE_TYPE (decl)) == UNION_TYPE
407                || TREE_CODE (TREE_TYPE (decl)) == QUAL_UNION_TYPE);
408
409           /* Optionally set flags or add text to the name to record information
410              such as that it is a function name.
411              If the name is changed, the macro ASM_OUTPUT_LABELREF
412              will have to know how to strip this information.
413              And if it finds a * at the beginning after doing so,
414              it must handle that too.  */
415 #ifdef ENCODE_SECTION_INFO
416           ENCODE_SECTION_INFO (decl);
417 #endif
418         }
419     }
420 }
421
422 /* Make the rtl for variable VAR be volatile.
423    Use this only for static variables.  */
424
425 void
426 make_var_volatile (var)
427      tree var;
428 {
429   if (GET_CODE (DECL_RTL (var)) != MEM)
430     abort ();
431
432   MEM_VOLATILE_P (DECL_RTL (var)) = 1;
433 }
434 \f
435 /* Output a string of literal assembler code
436    for an `asm' keyword used between functions.  */
437
438 void
439 assemble_asm (string)
440      tree string;
441 {
442   app_enable ();
443
444   if (TREE_CODE (string) == ADDR_EXPR)
445     string = TREE_OPERAND (string, 0);
446
447   fprintf (asm_out_file, "\t%s\n", TREE_STRING_POINTER (string));
448 }
449
450 #if 0 /* This should no longer be needed, because
451          flag_gnu_linker should be 0 on these systems,
452          which should prevent any output
453          if ASM_OUTPUT_CONSTRUCTOR and ASM_OUTPUT_DESTRUCTOR are absent.  */
454 #if !(defined(DBX_DEBUGGING_INFO) && !defined(FASCIST_ASSEMBLER))
455 #ifndef ASM_OUTPUT_CONSTRUCTOR
456 #define ASM_OUTPUT_CONSTRUCTOR(file, name)
457 #endif
458 #ifndef ASM_OUTPUT_DESTRUCTOR
459 #define ASM_OUTPUT_DESTRUCTOR(file, name)
460 #endif
461 #endif
462 #endif /* 0 */
463
464 /* Record an element in the table of global destructors.
465    How this is done depends on what sort of assembler and linker
466    are in use.
467
468    NAME should be the name of a global function to be called
469    at exit time.  This name is output using assemble_name.  */
470
471 void
472 assemble_destructor (name)
473      char *name;
474 {
475 #ifdef ASM_OUTPUT_DESTRUCTOR
476   ASM_OUTPUT_DESTRUCTOR (asm_out_file, name);
477 #else
478   if (flag_gnu_linker)
479     {
480       /* Now tell GNU LD that this is part of the static destructor set.  */
481       /* This code works for any machine provided you use GNU as/ld.  */
482       fprintf (asm_out_file, "%s \"___DTOR_LIST__\",22,0,0,", ASM_STABS_OP);
483       assemble_name (asm_out_file, name);
484       fputc ('\n', asm_out_file);
485     }
486 #endif
487 }
488
489 /* Likewise for global constructors.  */
490
491 void
492 assemble_constructor (name)
493      char *name;
494 {
495 #ifdef ASM_OUTPUT_CONSTRUCTOR
496   ASM_OUTPUT_CONSTRUCTOR (asm_out_file, name);
497 #else
498   if (flag_gnu_linker)
499     {
500       /* Now tell GNU LD that this is part of the static constructor set.  */
501       /* This code works for any machine provided you use GNU as/ld.  */
502       fprintf (asm_out_file, "%s \"___CTOR_LIST__\",22,0,0,", ASM_STABS_OP);
503       assemble_name (asm_out_file, name);
504       fputc ('\n', asm_out_file);
505     }
506 #endif
507 }
508
509 /* Likewise for entries we want to record for garbage collection.
510    Garbage collection is still under development.  */
511
512 void
513 assemble_gc_entry (name)
514      char *name;
515 {
516 #ifdef ASM_OUTPUT_GC_ENTRY
517   ASM_OUTPUT_GC_ENTRY (asm_out_file, name);
518 #else
519   if (flag_gnu_linker)
520     {
521       /* Now tell GNU LD that this is part of the static constructor set.  */
522       fprintf (asm_out_file, "%s \"___PTR_LIST__\",22,0,0,", ASM_STABS_OP);
523       assemble_name (asm_out_file, name);
524       fputc ('\n', asm_out_file);
525     }
526 #endif
527 }
528 \f
529 /* Output assembler code for the constant pool of a function and associated
530    with defining the name of the function.  DECL describes the function.
531    NAME is the function's name.  For the constant pool, we use the current
532    constant pool data.  */
533
534 void
535 assemble_start_function (decl, fnname)
536      tree decl;
537      char *fnname;
538 {
539   int align;
540
541   /* The following code does not need preprocessing in the assembler.  */
542
543   app_disable ();
544
545   output_constant_pool (fnname, decl);
546
547   text_section ();
548
549
550   /* Tell assembler to move to target machine's alignment for functions.  */
551   align = floor_log2 (FUNCTION_BOUNDARY / BITS_PER_UNIT);
552   if (align > 0)
553     ASM_OUTPUT_ALIGN (asm_out_file, align);
554
555 #ifdef ASM_OUTPUT_FUNCTION_PREFIX
556   ASM_OUTPUT_FUNCTION_PREFIX (asm_out_file, fnname);
557 #endif
558
559 #ifdef SDB_DEBUGGING_INFO
560   /* Output SDB definition of the function.  */
561   if (write_symbols == SDB_DEBUG)
562     sdbout_mark_begin_function ();
563 #endif
564
565 #ifdef DBX_DEBUGGING_INFO
566   /* Output DBX definition of the function.  */
567   if (write_symbols == DBX_DEBUG)
568     dbxout_begin_function (decl);
569 #endif
570
571   /* Make function name accessible from other files, if appropriate.  */
572
573   if (TREE_PUBLIC (decl))
574     {
575       if (!first_global_object_name)
576         STRIP_NAME_ENCODING (first_global_object_name, fnname);
577       ASM_GLOBALIZE_LABEL (asm_out_file, fnname);
578     }
579
580   /* Do any machine/system dependent processing of the function name */
581 #ifdef ASM_DECLARE_FUNCTION_NAME
582   ASM_DECLARE_FUNCTION_NAME (asm_out_file, fnname, current_function_decl);
583 #else
584   /* Standard thing is just output label for the function.  */
585   ASM_OUTPUT_LABEL (asm_out_file, fnname);
586 #endif /* ASM_DECLARE_FUNCTION_NAME */
587 }
588
589 /* Output assembler code associated with defining the size of the
590    function.  DECL describes the function.  NAME is the function's name.  */
591
592 void
593 assemble_end_function (decl, fnname)
594      tree decl;
595      char *fnname;
596 {
597 #ifdef ASM_DECLARE_FUNCTION_SIZE
598   ASM_DECLARE_FUNCTION_SIZE (asm_out_file, fnname, decl);
599 #endif
600 }
601 \f
602 /* Assemble code to leave SIZE bytes of zeros.  */
603
604 void
605 assemble_zeros (size)
606      int size;
607 {
608 #ifdef ASM_NO_SKIP_IN_TEXT
609   /* The `space' pseudo in the text section outputs nop insns rather than 0s,
610      so we must output 0s explicitly in the text section.  */
611   if (ASM_NO_SKIP_IN_TEXT && in_text_section ())
612     {
613       int i;
614
615       for (i = 0; i < size - 20; i += 20)
616         {
617 #ifdef ASM_BYTE_OP
618           fprintf (asm_out_file,
619                    "%s 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n", ASM_BYTE_OP);
620 #else
621           fprintf (asm_out_file,
622                    "\tbyte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n");
623 #endif
624         }
625       if (i < size)
626         {
627 #ifdef ASM_BYTE_OP
628           fprintf (asm_out_file, "%s 0", ASM_BYTE_OP);
629 #else
630           fprintf (asm_out_file, "\tbyte 0");
631 #endif
632           i++;
633           for (; i < size; i++)
634             fprintf (asm_out_file, ",0");
635           fprintf (asm_out_file, "\n");
636         }
637     }
638   else
639 #endif
640     if (size > 0)
641       ASM_OUTPUT_SKIP (asm_out_file, size);
642 }
643
644 /* Assemble a string constant with the specified C string as contents.  */
645
646 void
647 assemble_string (p, size)
648      char *p;
649      int size;
650 {
651   register int i;
652   int pos = 0;
653   int maximum = 2000;
654
655   /* If the string is very long, split it up.  */
656
657   while (pos < size)
658     {
659       int thissize = size - pos;
660       if (thissize > maximum)
661         thissize = maximum;
662
663       ASM_OUTPUT_ASCII (asm_out_file, p, thissize);
664
665       pos += thissize;
666       p += thissize;
667     }
668 }
669 \f
670 /* Assemble everything that is needed for a variable or function declaration.
671    Not used for automatic variables, and not used for function definitions.
672    Should not be called for variables of incomplete structure type.
673
674    TOP_LEVEL is nonzero if this variable has file scope.
675    AT_END is nonzero if this is the special handling, at end of compilation,
676    to define things that have had only tentative definitions.  */
677
678 void
679 assemble_variable (decl, top_level, at_end)
680      tree decl;
681      int top_level;
682      int at_end;
683 {
684   register char *name;
685   int align;
686   tree size_tree;
687   int reloc = 0;
688
689   if (GET_CODE (DECL_RTL (decl)) == REG)
690     {
691       /* Do output symbol info for global register variables, but do nothing
692          else for them.  */
693
694       if (TREE_ASM_WRITTEN (decl))
695         return;
696       TREE_ASM_WRITTEN (decl) = 1;
697
698 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
699       /* File-scope global variables are output here.  */
700       if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
701           && top_level)
702         dbxout_symbol (decl, 0);
703 #endif
704 #ifdef SDB_DEBUGGING_INFO
705       if (write_symbols == SDB_DEBUG && top_level
706           /* Leave initialized global vars for end of compilation;
707              see comment in compile_file.  */
708           && (TREE_PUBLIC (decl) == 0 || DECL_INITIAL (decl) == 0))
709         sdbout_symbol (decl, 0);
710 #endif
711
712       /* Don't output any DWARF debugging information for variables here.
713          In the case of local variables, the information for them is output
714          when we do our recursive traversal of the tree representation for
715          the entire containing function.  In the case of file-scope variables,
716          we output information for all of them at the very end of compilation
717          while we are doing our final traversal of the chain of file-scope
718          declarations.  */
719
720       return;
721     }
722
723   /* Normally no need to say anything here for external references,
724      since assemble_external is called by the langauge-specific code
725      when a declaration is first seen.  */
726
727   if (DECL_EXTERNAL (decl))
728     return;
729
730   /* Output no assembler code for a function declaration.
731      Only definitions of functions output anything.  */
732
733   if (TREE_CODE (decl) == FUNCTION_DECL)
734     return;
735
736   /* If type was incomplete when the variable was declared,
737      see if it is complete now.  */
738
739   if (DECL_SIZE (decl) == 0)
740     layout_decl (decl, 0);
741
742   /* Still incomplete => don't allocate it; treat the tentative defn
743      (which is what it must have been) as an `extern' reference.  */
744
745   if (DECL_SIZE (decl) == 0)
746     {
747       error_with_file_and_line (DECL_SOURCE_FILE (decl),
748                                 DECL_SOURCE_LINE (decl),
749                                 "storage size of `%s' isn't known",
750                                 IDENTIFIER_POINTER (DECL_NAME (decl)));
751       return;
752     }
753
754   /* The first declaration of a variable that comes through this function
755      decides whether it is global (in C, has external linkage)
756      or local (in C, has internal linkage).  So do nothing more
757      if this function has already run.  */
758
759   if (TREE_ASM_WRITTEN (decl))
760     return;
761
762   TREE_ASM_WRITTEN (decl) = 1;
763
764 #ifdef DBX_DEBUGGING_INFO
765   /* File-scope global variables are output here.  */
766   if (write_symbols == DBX_DEBUG && top_level)
767     dbxout_symbol (decl, 0);
768 #endif
769 #ifdef SDB_DEBUGGING_INFO
770   if (write_symbols == SDB_DEBUG && top_level
771       /* Leave initialized global vars for end of compilation;
772          see comment in compile_file.  */
773       && (TREE_PUBLIC (decl) == 0 || DECL_INITIAL (decl) == 0))
774     sdbout_symbol (decl, 0);
775 #endif
776
777   /* Don't output any DWARF debugging information for variables here.
778      In the case of local variables, the information for them is output
779      when we do our recursive traversal of the tree representation for
780      the entire containing function.  In the case of file-scope variables,
781      we output information for all of them at the very end of compilation
782      while we are doing our final traversal of the chain of file-scope
783      declarations.  */
784
785   /* If storage size is erroneously variable, just continue.
786      Error message was already made.  */
787
788   if (TREE_CODE (DECL_SIZE (decl)) != INTEGER_CST)
789     goto finish;
790
791   app_disable ();
792
793   /* This is better than explicit arithmetic, since it avoids overflow.  */
794   size_tree = size_binop (CEIL_DIV_EXPR,
795                           DECL_SIZE (decl), size_int (BITS_PER_UNIT));
796
797   if (TREE_INT_CST_HIGH (size_tree) != 0)
798     {
799       error_with_decl (decl, "size of variable `%s' is too large");
800       goto finish;
801     }
802
803   name = XSTR (XEXP (DECL_RTL (decl), 0), 0);
804
805   /* Handle uninitialized definitions.  */
806
807   /* ANSI specifies that a tentative definition which is not merged with
808      a non-tentative definition behaves exactly like a definition with an
809      initializer equal to zero.  (Section 3.7.2)
810      -fno-common gives strict ANSI behavior.  Usually you don't want it.  */
811   if (! flag_no_common
812       && (DECL_INITIAL (decl) == 0 || DECL_INITIAL (decl) == error_mark_node))
813     {
814       int size = TREE_INT_CST_LOW (size_tree);
815       int rounded = size;
816
817       if (TREE_INT_CST_HIGH (size_tree) != 0)
818         error_with_decl (decl, "size of variable `%s' is too large");
819       /* Don't allocate zero bytes of common,
820          since that means "undefined external" in the linker.  */
821       if (size == 0) rounded = 1;
822       /* Round size up to multiple of BIGGEST_ALIGNMENT bits
823          so that each uninitialized object starts on such a boundary.  */
824       rounded += (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - 1;
825       rounded = (rounded / (BIGGEST_ALIGNMENT / BITS_PER_UNIT)
826                  * (BIGGEST_ALIGNMENT / BITS_PER_UNIT));
827 #if 0
828       if (flag_shared_data)
829         data_section ();
830 #endif
831       if (TREE_PUBLIC (decl))
832         {
833 #ifdef ASM_OUTPUT_SHARED_COMMON
834           if (flag_shared_data)
835             ASM_OUTPUT_SHARED_COMMON (asm_out_file, name, size, rounded);
836           else
837 #endif
838 #ifdef ASM_OUTPUT_ALIGNED_COMMON
839             ASM_OUTPUT_ALIGNED_COMMON (asm_out_file, name, size,
840                                        DECL_ALIGN (decl));
841 #else
842             ASM_OUTPUT_COMMON (asm_out_file, name, size, rounded);
843 #endif
844         }
845       else
846         {
847 #ifdef ASM_OUTPUT_SHARED_LOCAL
848           if (flag_shared_data)
849             ASM_OUTPUT_SHARED_LOCAL (asm_out_file, name, size, rounded);
850           else
851 #endif
852 #ifdef ASM_OUTPUT_ALIGNED_LOCAL
853             ASM_OUTPUT_ALIGNED_LOCAL (asm_out_file, name, size,
854                                       DECL_ALIGN (decl));
855 #else
856             ASM_OUTPUT_LOCAL (asm_out_file, name, size, rounded);
857 #endif
858         }
859       goto finish;
860     }
861
862   /* Handle initialized definitions.  */
863
864   /* First make the assembler name(s) global if appropriate.  */
865   if (TREE_PUBLIC (decl) && DECL_NAME (decl))
866     {
867       if (!first_global_object_name)
868         STRIP_NAME_ENCODING(first_global_object_name, name);
869       ASM_GLOBALIZE_LABEL (asm_out_file, name);
870     }
871 #if 0
872   for (d = equivalents; d; d = TREE_CHAIN (d))
873     {
874       tree e = TREE_VALUE (d);
875       if (TREE_PUBLIC (e) && DECL_NAME (e))
876         ASM_GLOBALIZE_LABEL (asm_out_file,
877                              XSTR (XEXP (DECL_RTL (e), 0), 0));
878     }
879 #endif
880
881   /* Output any data that we will need to use the address of.  */
882   if (DECL_INITIAL (decl))
883     reloc = output_addressed_constants (DECL_INITIAL (decl));
884
885   /* Switch to the proper section for this data.  */
886 #ifdef SELECT_SECTION
887   SELECT_SECTION (decl, reloc);
888 #else
889   if (TREE_READONLY (decl)
890       && ! TREE_THIS_VOLATILE (decl)
891       && ! (flag_pic && reloc))
892     readonly_data_section ();
893   else
894     data_section ();
895 #endif
896
897   /* Compute and output the alignment of this data.  */
898
899   align = DECL_ALIGN (decl);
900   /* Some object file formats have a maximum alignment which they support.
901      In particular, a.out format supports a maximum alignment of 4.  */
902 #ifndef MAX_OFILE_ALIGNMENT
903 #define MAX_OFILE_ALIGNMENT BIGGEST_ALIGNMENT
904 #endif
905   if (align > MAX_OFILE_ALIGNMENT)
906     {
907       warning_with_decl (decl,
908           "alignment of `%s' is greater than maximum object file alignment");
909       align = MAX_OFILE_ALIGNMENT;
910     }
911 #ifdef DATA_ALIGNMENT
912   /* On some machines, it is good to increase alignment sometimes.  */
913   align = DATA_ALIGNMENT (TREE_TYPE (decl), align);
914 #endif
915 #ifdef CONSTANT_ALIGNMENT
916   if (DECL_INITIAL (decl))
917     align = CONSTANT_ALIGNMENT (DECL_INITIAL (decl), align);
918 #endif
919
920   /* Reset the alignment in case we have made it tighter, so we can benefit
921      from it in get_pointer_alignment.  */
922   DECL_ALIGN (decl) = align;
923
924   if (align > BITS_PER_UNIT)
925     ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT));
926
927   /* Do any machine/system dependent processing of the object.  */
928 #ifdef ASM_DECLARE_OBJECT_NAME
929   ASM_DECLARE_OBJECT_NAME (asm_out_file, name, decl);
930 #else
931   /* Standard thing is just output label for the object.  */
932   ASM_OUTPUT_LABEL (asm_out_file, name);
933 #endif /* ASM_DECLARE_OBJECT_NAME */
934
935 #if 0
936   for (d = equivalents; d; d = TREE_CHAIN (d))
937     {
938       tree e = TREE_VALUE (d);
939       ASM_OUTPUT_LABEL (asm_out_file, XSTR (XEXP (DECL_RTL (e), 0), 0));
940     }
941 #endif
942
943   if (DECL_INITIAL (decl))
944     /* Output the actual data.  */
945     output_constant (DECL_INITIAL (decl),
946                      int_size_in_bytes (TREE_TYPE (decl)));
947   else
948     /* Leave space for it.  */
949     assemble_zeros (int_size_in_bytes (TREE_TYPE (decl)));
950
951  finish:
952 #ifdef XCOFF_DEBUGGING_INFO
953   /* Unfortunately, the IBM assembler cannot handle stabx before the actual
954      declaration.  When something like ".stabx  "aa:S-2",aa,133,0" is emitted 
955      and `aa' hasn't been output yet, the assembler generates a stab entry with
956      a value of zero, in addition to creating an unnecessary external entry
957      for `aa'.  Hence, we must postpone dbxout_symbol to here at the end.  */
958
959   /* File-scope global variables are output here.  */
960   if (write_symbols == XCOFF_DEBUG && top_level)
961     dbxout_symbol (decl, 0);
962 #else
963   /* There must be a statement after a label.  */
964   ;
965 #endif
966 }
967
968 /* Output something to declare an external symbol to the assembler.
969    (Most assemblers don't need this, so we normally output nothing.)
970    Do nothing if DECL is not external.  */
971
972 void
973 assemble_external (decl)
974      tree decl;
975 {
976 #ifdef ASM_OUTPUT_EXTERNAL
977   if (TREE_CODE_CLASS (TREE_CODE (decl)) == 'd'
978       && DECL_EXTERNAL (decl) && TREE_PUBLIC (decl))
979     {
980       rtx rtl = DECL_RTL (decl);
981
982       if (GET_CODE (rtl) == MEM && GET_CODE (XEXP (rtl, 0)) == SYMBOL_REF
983           && ! SYMBOL_REF_USED (XEXP (rtl, 0)))
984         {
985           /* Some systems do require some output.  */
986           SYMBOL_REF_USED (XEXP (rtl, 0)) = 1;
987           ASM_OUTPUT_EXTERNAL (asm_out_file, decl, XSTR (XEXP (rtl, 0), 0));
988         }
989     }
990 #endif
991 }
992
993 /* Similar, for calling a library function FUN.  */
994
995 void
996 assemble_external_libcall (fun)
997      rtx fun;
998 {
999 #ifdef ASM_OUTPUT_EXTERNAL_LIBCALL
1000   /* Declare library function name external when first used, if nec.  */
1001   if (! SYMBOL_REF_USED (fun))
1002     {
1003       SYMBOL_REF_USED (fun) = 1;
1004       ASM_OUTPUT_EXTERNAL_LIBCALL (asm_out_file, fun);
1005     }
1006 #endif
1007 }
1008
1009 /* Declare the label NAME global.  */
1010
1011 void
1012 assemble_global (name)
1013      char *name;
1014 {
1015   ASM_GLOBALIZE_LABEL (asm_out_file, name);
1016 }
1017
1018 /* Assemble a label named NAME.  */
1019
1020 void
1021 assemble_label (name)
1022      char *name;
1023 {
1024   ASM_OUTPUT_LABEL (asm_out_file, name);
1025 }
1026
1027 /* Output to FILE a reference to the assembler name of a C-level name NAME.
1028    If NAME starts with a *, the rest of NAME is output verbatim.
1029    Otherwise NAME is transformed in an implementation-defined way
1030    (usually by the addition of an underscore).
1031    Many macros in the tm file are defined to call this function.  */
1032
1033 void
1034 assemble_name (file, name)
1035      FILE *file;
1036      char *name;
1037 {
1038   if (name[0] == '*')
1039     fputs (&name[1], file);
1040   else
1041     ASM_OUTPUT_LABELREF (file, name);
1042 }
1043
1044 /* Allocate SIZE bytes writable static space with a gensym name
1045    and return an RTX to refer to its address.  */
1046
1047 rtx
1048 assemble_static_space (size)
1049      int size;
1050 {
1051   char name[12];
1052   char *namestring;
1053   rtx x;
1054   /* Round size up to multiple of BIGGEST_ALIGNMENT bits
1055      so that each uninitialized object starts on such a boundary.  */
1056   int rounded = ((size + (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - 1)
1057                  / (BIGGEST_ALIGNMENT / BITS_PER_UNIT)
1058                  * (BIGGEST_ALIGNMENT / BITS_PER_UNIT));
1059
1060 #if 0
1061   if (flag_shared_data)
1062     data_section ();
1063 #endif
1064
1065   ASM_GENERATE_INTERNAL_LABEL (name, "LF", const_labelno);
1066   ++const_labelno;
1067
1068   namestring = (char *) obstack_alloc (saveable_obstack,
1069                                        strlen (name) + 2);
1070   strcpy (namestring, name);
1071
1072   x = gen_rtx (SYMBOL_REF, Pmode, namestring);
1073 #ifdef ASM_OUTPUT_ALIGNED_LOCAL
1074   ASM_OUTPUT_ALIGNED_LOCAL (asm_out_file, name, size, BIGGEST_ALIGNMENT);
1075 #else
1076   ASM_OUTPUT_LOCAL (asm_out_file, name, size, rounded);
1077 #endif
1078   return x;
1079 }
1080
1081 /* Assemble the static constant template for function entry trampolines.
1082    This is done at most once per compilation.
1083    Returns an RTX for the address of the template.  */
1084
1085 rtx
1086 assemble_trampoline_template ()
1087 {
1088   char label[256];
1089   char *name;
1090   int align;
1091
1092   /* By default, put trampoline templates in read-only data section.  */
1093
1094 #ifdef TRAMPOLINE_SECTION
1095   TRAMPOLINE_SECTION ();
1096 #else
1097   readonly_data_section ();
1098 #endif
1099
1100   /* Write the assembler code to define one.  */
1101   align = floor_log2 (FUNCTION_BOUNDARY / BITS_PER_UNIT);
1102   if (align > 0)
1103     ASM_OUTPUT_ALIGN (asm_out_file, align);
1104
1105   ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LTRAMP", 0);
1106   TRAMPOLINE_TEMPLATE (asm_out_file);
1107
1108   /* Record the rtl to refer to it.  */
1109   ASM_GENERATE_INTERNAL_LABEL (label, "LTRAMP", 0);
1110   name
1111     = (char *) obstack_copy0 (&permanent_obstack, label, strlen (label));
1112   return gen_rtx (SYMBOL_REF, Pmode, name);
1113 }
1114 \f
1115 /* Assemble the integer constant X into an object of SIZE bytes.
1116    X must be either a CONST_INT or CONST_DOUBLE.
1117
1118    Return 1 if we were able to output the constant, otherwise 0.  If FORCE is
1119    non-zero, abort if we can't output the constant.  */
1120
1121 int
1122 assemble_integer (x, size, force)
1123      rtx x;
1124      int size;
1125      int force;
1126 {
1127   /* First try to use the standard 1, 2, 4, 8, and 16 byte
1128      ASM_OUTPUT... macros. */
1129
1130   switch (size)
1131     {
1132 #ifdef ASM_OUTPUT_CHAR
1133     case 1:
1134       ASM_OUTPUT_CHAR (asm_out_file, x);
1135       return 1;
1136 #endif
1137
1138 #ifdef ASM_OUTPUT_SHORT
1139     case 2:
1140       ASM_OUTPUT_SHORT (asm_out_file, x);
1141       return 1;
1142 #endif
1143
1144 #ifdef ASM_OUTPUT_INT
1145     case 4:
1146       ASM_OUTPUT_INT (asm_out_file, x);
1147       return 1;
1148 #endif
1149
1150 #ifdef ASM_OUTPUT_DOUBLE_INT
1151     case 8:
1152       ASM_OUTPUT_DOUBLE_INT (asm_out_file, x);
1153       return 1;
1154 #endif
1155
1156 #ifdef ASM_OUTPUT_QUADRUPLE_INT
1157     case 16:
1158       ASM_OUTPUT_QUADRUPLE_INT (asm_out_file, x);
1159       return 1;
1160 #endif
1161     }
1162
1163   /* If we couldn't do it that way, there are two other possibilities: First,
1164      if the machine can output an explicit byte and this is a 1 byte constant,
1165      we can use ASM_OUTPUT_BYTE.  */
1166
1167 #ifdef ASM_OUTPUT_BYTE
1168   if (size == 1 && GET_CODE (x) == CONST_INT)
1169     {
1170       ASM_OUTPUT_BYTE (asm_out_file, INTVAL (x));
1171       return 1;
1172     }
1173 #endif
1174
1175   /* Finally, if SIZE is larger than a single word, try to output the constant
1176      one word at a time.  */
1177
1178   if (size > UNITS_PER_WORD)
1179     {
1180       int i;
1181       enum machine_mode mode
1182         = mode_for_size (size * BITS_PER_UNIT, MODE_INT, 0);
1183       rtx word;
1184
1185       for (i = 0; i < size / UNITS_PER_WORD; i++)
1186         {
1187           word = operand_subword (x, i, 0, mode);
1188
1189           if (word == 0)
1190             break;
1191
1192           if (! assemble_integer (word, UNITS_PER_WORD, 0))
1193             break;
1194         }
1195
1196       if (i == size / UNITS_PER_WORD)
1197         return 1;
1198       /* If we output at least one word and then could not finish,
1199          there is no valid way to continue.  */
1200       if (i > 0)
1201         abort ();
1202     }
1203
1204   if (force)
1205     abort ();
1206
1207   return 0;
1208 }
1209 \f
1210 /* Assemble the floating-point constant D into an object of size MODE.  */
1211
1212 void
1213 assemble_real (d, mode)
1214      REAL_VALUE_TYPE d;
1215      enum machine_mode mode;
1216 {
1217   jmp_buf output_constant_handler;
1218
1219   if (setjmp (output_constant_handler))
1220     {
1221       error ("floating point trap outputting a constant");
1222 #ifdef REAL_IS_NOT_DOUBLE
1223       bzero (&d, sizeof d);
1224       d = dconst0;
1225 #else
1226       d = 0;
1227 #endif
1228     }
1229
1230   set_float_handler (output_constant_handler);
1231
1232   switch (mode)
1233     {
1234 #ifdef ASM_OUTPUT_BYTE_FLOAT
1235     case QFmode:
1236       ASM_OUTPUT_BYTE_FLOAT (asm_out_file, d);
1237       break;
1238 #endif
1239 #ifdef ASM_OUTPUT_SHORT_FLOAT
1240     case HFmode:
1241       ASM_OUTPUT_SHORT_FLOAT (asm_out_file, d);
1242       break;
1243 #endif
1244 #ifdef ASM_OUTPUT_FLOAT
1245     case SFmode:
1246       ASM_OUTPUT_FLOAT (asm_out_file, d);
1247       break;
1248 #endif
1249
1250 #ifdef ASM_OUTPUT_DOUBLE
1251     case DFmode:
1252       ASM_OUTPUT_DOUBLE (asm_out_file, d);
1253       break;
1254 #endif
1255
1256 #ifdef ASM_OUTPUT_LONG_DOUBLE
1257     case XFmode:
1258     case TFmode:
1259       ASM_OUTPUT_LONG_DOUBLE (asm_out_file, d);
1260       break;
1261 #endif
1262
1263     default:
1264       abort ();
1265     }
1266
1267   set_float_handler (NULL_PTR);
1268 }
1269 \f
1270 /* Here we combine duplicate floating constants to make
1271    CONST_DOUBLE rtx's, and force those out to memory when necessary.  */
1272
1273 /* Chain of all CONST_DOUBLE rtx's constructed for the current function.
1274    They are chained through the CONST_DOUBLE_CHAIN.
1275    A CONST_DOUBLE rtx has CONST_DOUBLE_MEM != cc0_rtx iff it is on this chain.
1276    In that case, CONST_DOUBLE_MEM is either a MEM,
1277    or const0_rtx if no MEM has been made for this CONST_DOUBLE yet.
1278
1279    (CONST_DOUBLE_MEM is used only for top-level functions.
1280    See force_const_mem for explanation.)  */
1281
1282 static rtx const_double_chain;
1283
1284 /* Return a CONST_DOUBLE for a value specified as a pair of ints.
1285    For an integer, I0 is the low-order word and I1 is the high-order word.
1286    For a real number, I0 is the word with the low address
1287    and I1 is the word with the high address.  */
1288
1289 rtx
1290 immed_double_const (i0, i1, mode)
1291      HOST_WIDE_INT i0, i1;
1292      enum machine_mode mode;
1293 {
1294   register rtx r;
1295   int in_current_obstack;
1296
1297   if (GET_MODE_CLASS (mode) == MODE_INT
1298       || GET_MODE_CLASS (mode) == MODE_PARTIAL_INT)
1299     {
1300       /* We clear out all bits that don't belong in MODE, unless they and our
1301          sign bit are all one.  So we get either a reasonable negative value
1302          or a reasonable unsigned value for this mode.  */
1303       int width = GET_MODE_BITSIZE (mode);
1304       if (width < HOST_BITS_PER_WIDE_INT
1305           && ((i0 & ((HOST_WIDE_INT) (-1) << (width - 1)))
1306               != ((HOST_WIDE_INT) (-1) << (width - 1))))
1307         i0 &= ((HOST_WIDE_INT) 1 << width) - 1, i1 = 0;
1308       else if (width == HOST_BITS_PER_WIDE_INT
1309                && ! (i1 == ~0 && i0 < 0))
1310         i1 = 0;
1311       else if (width > 2 * HOST_BITS_PER_WIDE_INT)
1312         /* We cannot represent this value as a constant.  */
1313         abort ();
1314
1315       /* If MODE fits within HOST_BITS_PER_WIDE_INT, always use a CONST_INT.
1316
1317          ??? Strictly speaking, this is wrong if we create a CONST_INT
1318          for a large unsigned constant with the size of MODE being
1319          HOST_BITS_PER_WIDE_INT and later try to interpret that constant in a
1320          wider mode.  In that case we will mis-interpret it as a negative
1321          number.
1322
1323          Unfortunately, the only alternative is to make a CONST_DOUBLE
1324          for any constant in any mode if it is an unsigned constant larger
1325          than the maximum signed integer in an int on the host.  However,
1326          doing this will break everyone that always expects to see a CONST_INT
1327          for SImode and smaller.
1328
1329          We have always been making CONST_INTs in this case, so nothing new
1330          is being broken.  */
1331
1332       if (width <= HOST_BITS_PER_WIDE_INT)
1333         i1 = (i0 < 0) ? ~0 : 0;
1334
1335       /* If this integer fits in one word, return a CONST_INT.  */
1336       if ((i1 == 0 && i0 >= 0)
1337           || (i1 == ~0 && i0 < 0))
1338         return GEN_INT (i0);
1339
1340       /* We use VOIDmode for integers.  */
1341       mode = VOIDmode;
1342     }
1343
1344   /* Search the chain for an existing CONST_DOUBLE with the right value.
1345      If one is found, return it.  */
1346
1347   for (r = const_double_chain; r; r = CONST_DOUBLE_CHAIN (r))
1348     if (CONST_DOUBLE_LOW (r) == i0 && CONST_DOUBLE_HIGH (r) == i1
1349         && GET_MODE (r) == mode)
1350       return r;
1351
1352   /* No; make a new one and add it to the chain.
1353
1354      We may be called by an optimizer which may be discarding any memory
1355      allocated during its processing (such as combine and loop).  However,
1356      we will be leaving this constant on the chain, so we cannot tolerate
1357      freed memory.  So switch to saveable_obstack for this allocation
1358      and then switch back if we were in current_obstack.  */
1359
1360   push_obstacks_nochange ();
1361   rtl_in_saveable_obstack ();
1362   r = gen_rtx (CONST_DOUBLE, mode, 0, i0, i1);
1363   pop_obstacks ();
1364
1365   /* Don't touch const_double_chain in nested function;
1366      see force_const_mem.  */
1367   if (outer_function_chain == 0)
1368     {
1369       CONST_DOUBLE_CHAIN (r) = const_double_chain;
1370       const_double_chain = r;
1371     }
1372
1373   /* Store const0_rtx in mem-slot since this CONST_DOUBLE is on the chain.
1374      Actual use of mem-slot is only through force_const_mem.  */
1375
1376   CONST_DOUBLE_MEM (r) = const0_rtx;
1377
1378   return r;
1379 }
1380
1381 /* Return a CONST_DOUBLE for a specified `double' value
1382    and machine mode.  */
1383
1384 rtx
1385 immed_real_const_1 (d, mode)
1386      REAL_VALUE_TYPE d;
1387      enum machine_mode mode;
1388 {
1389   union real_extract u;
1390   register rtx r;
1391   int in_current_obstack;
1392
1393   /* Get the desired `double' value as a sequence of ints
1394      since that is how they are stored in a CONST_DOUBLE.  */
1395
1396   u.d = d;
1397
1398   /* Detect special cases.  */
1399
1400   /* Avoid REAL_VALUES_EQUAL here in order to distinguish minus zero.  */
1401   if (!bcmp (&dconst0, &d, sizeof d))
1402     return CONST0_RTX (mode);
1403   else if (REAL_VALUES_EQUAL (dconst1, d))
1404     return CONST1_RTX (mode);
1405
1406   if (sizeof u == 2 * sizeof (HOST_WIDE_INT))
1407     return immed_double_const (u.i[0], u.i[1], mode);
1408
1409   /* The rest of this function handles the case where
1410      a float value requires more than 2 ints of space.
1411      It will be deleted as dead code on machines that don't need it.  */
1412
1413   /* Search the chain for an existing CONST_DOUBLE with the right value.
1414      If one is found, return it.  */
1415
1416   for (r = const_double_chain; r; r = CONST_DOUBLE_CHAIN (r))
1417     if (! bcmp (&CONST_DOUBLE_LOW (r), &u, sizeof u)
1418         && GET_MODE (r) == mode)
1419       return r;
1420
1421   /* No; make a new one and add it to the chain.
1422
1423      We may be called by an optimizer which may be discarding any memory
1424      allocated during its processing (such as combine and loop).  However,
1425      we will be leaving this constant on the chain, so we cannot tolerate
1426      freed memory.  So switch to saveable_obstack for this allocation
1427      and then switch back if we were in current_obstack.  */
1428
1429   push_obstacks_nochange ();
1430   rtl_in_saveable_obstack ();
1431   r = rtx_alloc (CONST_DOUBLE);
1432   PUT_MODE (r, mode);
1433   bcopy (&u, &CONST_DOUBLE_LOW (r), sizeof u);
1434   pop_obstacks ();
1435
1436   /* Don't touch const_double_chain in nested function;
1437      see force_const_mem.  */
1438   if (outer_function_chain == 0)
1439     {
1440       CONST_DOUBLE_CHAIN (r) = const_double_chain;
1441       const_double_chain = r;
1442     }
1443
1444   /* Store const0_rtx in CONST_DOUBLE_MEM since this CONST_DOUBLE is on the
1445      chain, but has not been allocated memory.  Actual use of CONST_DOUBLE_MEM
1446      is only through force_const_mem.  */
1447
1448   CONST_DOUBLE_MEM (r) = const0_rtx;
1449
1450   return r;
1451 }
1452
1453 /* Return a CONST_DOUBLE rtx for a value specified by EXP,
1454    which must be a REAL_CST tree node.  */
1455
1456 rtx
1457 immed_real_const (exp)
1458      tree exp;
1459 {
1460   return immed_real_const_1 (TREE_REAL_CST (exp), TYPE_MODE (TREE_TYPE (exp)));
1461 }
1462
1463 /* At the end of a function, forget the memory-constants
1464    previously made for CONST_DOUBLEs.  Mark them as not on real_constant_chain.
1465    Also clear out real_constant_chain and clear out all the chain-pointers.  */
1466
1467 void
1468 clear_const_double_mem ()
1469 {
1470   register rtx r, next;
1471
1472   /* Don't touch CONST_DOUBLE_MEM for nested functions.
1473      See force_const_mem for explanation.  */
1474   if (outer_function_chain != 0)
1475     return;
1476
1477   for (r = const_double_chain; r; r = next)
1478     {
1479       next = CONST_DOUBLE_CHAIN (r);
1480       CONST_DOUBLE_CHAIN (r) = 0;
1481       CONST_DOUBLE_MEM (r) = cc0_rtx;
1482     }
1483   const_double_chain = 0;
1484 }
1485 \f
1486 /* Given an expression EXP with a constant value,
1487    reduce it to the sum of an assembler symbol and an integer.
1488    Store them both in the structure *VALUE.
1489    Abort if EXP does not reduce.  */
1490
1491 struct addr_const
1492 {
1493   rtx base;
1494   HOST_WIDE_INT offset;
1495 };
1496
1497 static void
1498 decode_addr_const (exp, value)
1499      tree exp;
1500      struct addr_const *value;
1501 {
1502   register tree target = TREE_OPERAND (exp, 0);
1503   register int offset = 0;
1504   register rtx x;
1505
1506   while (1)
1507     {
1508       if (TREE_CODE (target) == COMPONENT_REF
1509           && (TREE_CODE (DECL_FIELD_BITPOS (TREE_OPERAND (target, 1)))
1510               == INTEGER_CST))
1511         {
1512           offset += TREE_INT_CST_LOW (DECL_FIELD_BITPOS (TREE_OPERAND (target, 1))) / BITS_PER_UNIT;
1513           target = TREE_OPERAND (target, 0);
1514         }
1515       else if (TREE_CODE (target) == ARRAY_REF)
1516         {
1517           if (TREE_CODE (TREE_OPERAND (target, 1)) != INTEGER_CST
1518               || TREE_CODE (TYPE_SIZE (TREE_TYPE (target))) != INTEGER_CST)
1519             abort ();
1520           offset += ((TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (target)))
1521                       * TREE_INT_CST_LOW (TREE_OPERAND (target, 1)))
1522                      / BITS_PER_UNIT);
1523           target = TREE_OPERAND (target, 0);
1524         }
1525       else
1526         break;
1527     }
1528
1529   switch (TREE_CODE (target))
1530     {
1531     case VAR_DECL:
1532     case FUNCTION_DECL:
1533       x = DECL_RTL (target);
1534       break;
1535
1536     case LABEL_DECL:
1537       x = gen_rtx (MEM, FUNCTION_MODE,
1538                    gen_rtx (LABEL_REF, VOIDmode,
1539                             label_rtx (TREE_OPERAND (exp, 0))));
1540       break;
1541
1542     case REAL_CST:
1543     case STRING_CST:
1544     case COMPLEX_CST:
1545     case CONSTRUCTOR:
1546       x = TREE_CST_RTL (target);
1547       break;
1548
1549     default:
1550       abort ();
1551     }
1552
1553   if (GET_CODE (x) != MEM)
1554     abort ();
1555   x = XEXP (x, 0);
1556
1557   value->base = x;
1558   value->offset = offset;
1559 }
1560 \f
1561 /* Uniquize all constants that appear in memory.
1562    Each constant in memory thus far output is recorded
1563    in `const_hash_table' with a `struct constant_descriptor'
1564    that contains a polish representation of the value of
1565    the constant.
1566
1567    We cannot store the trees in the hash table
1568    because the trees may be temporary.  */
1569
1570 struct constant_descriptor
1571 {
1572   struct constant_descriptor *next;
1573   char *label;
1574   char contents[1];
1575 };
1576
1577 #define HASHBITS 30
1578 #define MAX_HASH_TABLE 1009
1579 static struct constant_descriptor *const_hash_table[MAX_HASH_TABLE];
1580
1581 /* Compute a hash code for a constant expression.  */
1582
1583 int
1584 const_hash (exp)
1585      tree exp;
1586 {
1587   register char *p;
1588   register int len, hi, i;
1589   register enum tree_code code = TREE_CODE (exp);
1590
1591   if (code == INTEGER_CST)
1592     {
1593       p = (char *) &TREE_INT_CST_LOW (exp);
1594       len = 2 * sizeof TREE_INT_CST_LOW (exp);
1595     }
1596   else if (code == REAL_CST)
1597     {
1598       p = (char *) &TREE_REAL_CST (exp);
1599       len = sizeof TREE_REAL_CST (exp);
1600     }
1601   else if (code == STRING_CST)
1602     p = TREE_STRING_POINTER (exp), len = TREE_STRING_LENGTH (exp);
1603   else if (code == COMPLEX_CST)
1604     return const_hash (TREE_REALPART (exp)) * 5
1605       + const_hash (TREE_IMAGPART (exp));
1606   else if (code == CONSTRUCTOR)
1607     {
1608       register tree link;
1609
1610       /* For record type, include the type in the hashing.
1611          We do not do so for array types
1612          because (1) the sizes of the elements are sufficient
1613          and (2) distinct array types can have the same constructor.
1614          Instead, we include the array size because the constructor could
1615          be shorter.  */
1616       if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE)
1617         hi = ((HOST_WIDE_INT) TREE_TYPE (exp) & ((1 << HASHBITS) - 1))
1618           % MAX_HASH_TABLE;
1619       else
1620         hi = ((5 + int_size_in_bytes (TREE_TYPE (exp)))
1621                & ((1 << HASHBITS) - 1)) % MAX_HASH_TABLE;
1622
1623       for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link))
1624         if (TREE_VALUE (link))
1625           hi = (hi * 603 + const_hash (TREE_VALUE (link))) % MAX_HASH_TABLE;
1626
1627       return hi;
1628     }
1629   else if (code == ADDR_EXPR)
1630     {
1631       struct addr_const value;
1632       decode_addr_const (exp, &value);
1633       if (GET_CODE (value.base) == SYMBOL_REF)
1634         {
1635           /* Don't hash the address of the SYMBOL_REF;
1636              only use the offset and the symbol name.  */
1637           hi = value.offset;
1638           p = XSTR (value.base, 0);
1639           for (i = 0; p[i] != 0; i++)
1640             hi = ((hi * 613) + (unsigned)(p[i]));
1641         }
1642       else if (GET_CODE (value.base) == LABEL_REF)
1643         hi = value.offset + CODE_LABEL_NUMBER (XEXP (value.base, 0)) * 13;
1644
1645       hi &= (1 << HASHBITS) - 1;
1646       hi %= MAX_HASH_TABLE;
1647       return hi;
1648     }
1649   else if (code == PLUS_EXPR || code == MINUS_EXPR)
1650     return const_hash (TREE_OPERAND (exp, 0)) * 9
1651       +  const_hash (TREE_OPERAND (exp, 1));
1652   else if (code == NOP_EXPR || code == CONVERT_EXPR)
1653     return const_hash (TREE_OPERAND (exp, 0)) * 7 + 2;
1654
1655   /* Compute hashing function */
1656   hi = len;
1657   for (i = 0; i < len; i++)
1658     hi = ((hi * 613) + (unsigned)(p[i]));
1659
1660   hi &= (1 << HASHBITS) - 1;
1661   hi %= MAX_HASH_TABLE;
1662   return hi;
1663 }
1664 \f
1665 /* Compare a constant expression EXP with a constant-descriptor DESC.
1666    Return 1 if DESC describes a constant with the same value as EXP.  */
1667
1668 static int
1669 compare_constant (exp, desc)
1670      tree exp;
1671      struct constant_descriptor *desc;
1672 {
1673   return 0 != compare_constant_1 (exp, desc->contents);
1674 }
1675
1676 /* Compare constant expression EXP with a substring P of a constant descriptor.
1677    If they match, return a pointer to the end of the substring matched.
1678    If they do not match, return 0.
1679
1680    Since descriptors are written in polish prefix notation,
1681    this function can be used recursively to test one operand of EXP
1682    against a subdescriptor, and if it succeeds it returns the
1683    address of the subdescriptor for the next operand.  */
1684
1685 static char *
1686 compare_constant_1 (exp, p)
1687      tree exp;
1688      char *p;
1689 {
1690   register char *strp;
1691   register int len;
1692   register enum tree_code code = TREE_CODE (exp);
1693
1694   if (code != (enum tree_code) *p++)
1695     return 0;
1696
1697   if (code == INTEGER_CST)
1698     {
1699       /* Integer constants are the same only if the same width of type.  */
1700       if (*p++ != TYPE_PRECISION (TREE_TYPE (exp)))
1701         return 0;
1702       strp = (char *) &TREE_INT_CST_LOW (exp);
1703       len = 2 * sizeof TREE_INT_CST_LOW (exp);
1704     }
1705   else if (code == REAL_CST)
1706     {
1707       /* Real constants are the same only if the same width of type.  */
1708       if (*p++ != TYPE_PRECISION (TREE_TYPE (exp)))
1709         return 0;
1710       strp = (char *) &TREE_REAL_CST (exp);
1711       len = sizeof TREE_REAL_CST (exp);
1712     }
1713   else if (code == STRING_CST)
1714     {
1715       if (flag_writable_strings)
1716         return 0;
1717       strp = TREE_STRING_POINTER (exp);
1718       len = TREE_STRING_LENGTH (exp);
1719       if (bcmp (&TREE_STRING_LENGTH (exp), p,
1720                 sizeof TREE_STRING_LENGTH (exp)))
1721         return 0;
1722       p += sizeof TREE_STRING_LENGTH (exp);
1723     }
1724   else if (code == COMPLEX_CST)
1725     {
1726       p = compare_constant_1 (TREE_REALPART (exp), p);
1727       if (p == 0) return 0;
1728       p = compare_constant_1 (TREE_IMAGPART (exp), p);
1729       return p;
1730     }
1731   else if (code == CONSTRUCTOR)
1732     {
1733       register tree link;
1734       int length = list_length (CONSTRUCTOR_ELTS (exp));
1735       tree type;
1736
1737       if (bcmp (&length, p, sizeof length))
1738         return 0;
1739       p += sizeof length;
1740
1741       /* For record constructors, insist that the types match.
1742          For arrays, just verify both constructors are for arrays.  */
1743       if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE)
1744         type = TREE_TYPE (exp);
1745       else
1746         type = 0;
1747       if (bcmp (&type, p, sizeof type))
1748         return 0;
1749       p += sizeof type;
1750
1751       /* For arrays, insist that the size in bytes match.  */
1752       if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE)
1753         {
1754           int size = int_size_in_bytes (TREE_TYPE (exp));
1755           if (bcmp (&size, p, sizeof size))
1756             return 0;
1757           p += sizeof size;
1758         }
1759
1760       for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link))
1761         {
1762           if (TREE_VALUE (link))
1763             {
1764               if ((p = compare_constant_1 (TREE_VALUE (link), p)) == 0)
1765                 return 0;
1766             }
1767           else
1768             {
1769               tree zero = 0;
1770
1771               if (bcmp (&zero, p, sizeof zero))
1772                 return 0;
1773               p += sizeof zero;
1774             }
1775         }
1776
1777       return p;
1778     }
1779   else if (code == ADDR_EXPR)
1780     {
1781       struct addr_const value;
1782       decode_addr_const (exp, &value);
1783       strp = (char *) &value.offset;
1784       len = sizeof value.offset;
1785       /* Compare the offset.  */
1786       while (--len >= 0)
1787         if (*p++ != *strp++)
1788           return 0;
1789       /* Compare symbol name.  */
1790       strp = XSTR (value.base, 0);
1791       len = strlen (strp) + 1;
1792     }
1793   else if (code == PLUS_EXPR || code == MINUS_EXPR)
1794     {
1795       p = compare_constant_1 (TREE_OPERAND (exp, 0), p);
1796       if (p == 0) return 0;
1797       p = compare_constant_1 (TREE_OPERAND (exp, 1), p);
1798       return p;
1799     }
1800   else if (code == NOP_EXPR || code == CONVERT_EXPR)
1801     {
1802       p = compare_constant_1 (TREE_OPERAND (exp, 0), p);
1803       return p;
1804     }
1805
1806   /* Compare constant contents.  */
1807   while (--len >= 0)
1808     if (*p++ != *strp++)
1809       return 0;
1810
1811   return p;
1812 }
1813 \f
1814 /* Construct a constant descriptor for the expression EXP.
1815    It is up to the caller to enter the descriptor in the hash table.  */
1816
1817 static struct constant_descriptor *
1818 record_constant (exp)
1819      tree exp;
1820 {
1821   struct constant_descriptor *ptr = 0;
1822   int buf;
1823
1824   obstack_grow (&permanent_obstack, &ptr, sizeof ptr);
1825   obstack_grow (&permanent_obstack, &buf, sizeof buf);
1826   record_constant_1 (exp);
1827   return (struct constant_descriptor *) obstack_finish (&permanent_obstack);
1828 }
1829
1830 /* Add a description of constant expression EXP
1831    to the object growing in `permanent_obstack'.
1832    No need to return its address; the caller will get that
1833    from the obstack when the object is complete.  */
1834
1835 static void
1836 record_constant_1 (exp)
1837      tree exp;
1838 {
1839   register char *strp;
1840   register int len;
1841   register enum tree_code code = TREE_CODE (exp);
1842
1843   obstack_1grow (&permanent_obstack, (unsigned int) code);
1844
1845   if (code == INTEGER_CST)
1846     {
1847       obstack_1grow (&permanent_obstack, TYPE_PRECISION (TREE_TYPE (exp)));
1848       strp = (char *) &TREE_INT_CST_LOW (exp);
1849       len = 2 * sizeof TREE_INT_CST_LOW (exp);
1850     }
1851   else if (code == REAL_CST)
1852     {
1853       obstack_1grow (&permanent_obstack, TYPE_PRECISION (TREE_TYPE (exp)));
1854       strp = (char *) &TREE_REAL_CST (exp);
1855       len = sizeof TREE_REAL_CST (exp);
1856     }
1857   else if (code == STRING_CST)
1858     {
1859       if (flag_writable_strings)
1860         return;
1861       strp = TREE_STRING_POINTER (exp);
1862       len = TREE_STRING_LENGTH (exp);
1863       obstack_grow (&permanent_obstack, (char *) &TREE_STRING_LENGTH (exp),
1864                     sizeof TREE_STRING_LENGTH (exp));
1865     }
1866   else if (code == COMPLEX_CST)
1867     {
1868       record_constant_1 (TREE_REALPART (exp));
1869       record_constant_1 (TREE_IMAGPART (exp));
1870       return;
1871     }
1872   else if (code == CONSTRUCTOR)
1873     {
1874       register tree link;
1875       int length = list_length (CONSTRUCTOR_ELTS (exp));
1876       tree type;
1877
1878       obstack_grow (&permanent_obstack, (char *) &length, sizeof length);
1879
1880       /* For record constructors, insist that the types match.
1881          For arrays, just verify both constructors are for arrays.  */
1882       if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE)
1883         type = TREE_TYPE (exp);
1884       else
1885         type = 0;
1886       obstack_grow (&permanent_obstack, (char *) &type, sizeof type);
1887
1888       /* For arrays, insist that the size in bytes match.  */
1889       if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE)
1890         {
1891           int size = int_size_in_bytes (TREE_TYPE (exp));
1892           obstack_grow (&permanent_obstack, (char *) &size, sizeof size);
1893         }
1894
1895       for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link))
1896         {
1897           if (TREE_VALUE (link))
1898             record_constant_1 (TREE_VALUE (link));
1899           else
1900             {
1901               tree zero = 0;
1902
1903               obstack_grow (&permanent_obstack, (char *) &zero, sizeof zero);
1904             }
1905         }
1906
1907       return;
1908     }
1909   else if (code == ADDR_EXPR)
1910     {
1911       struct addr_const value;
1912       decode_addr_const (exp, &value);
1913       /* Record the offset.  */
1914       obstack_grow (&permanent_obstack,
1915                     (char *) &value.offset, sizeof value.offset);
1916       /* Record the symbol name.  */
1917       obstack_grow (&permanent_obstack, XSTR (value.base, 0),
1918                     strlen (XSTR (value.base, 0)) + 1);
1919       return;
1920     }
1921   else if (code == PLUS_EXPR || code == MINUS_EXPR)
1922     {
1923       record_constant_1 (TREE_OPERAND (exp, 0));
1924       record_constant_1 (TREE_OPERAND (exp, 1));
1925       return;
1926     }
1927   else if (code == NOP_EXPR || code == CONVERT_EXPR)
1928     {
1929       record_constant_1 (TREE_OPERAND (exp, 0));
1930       return;
1931     }
1932
1933   /* Record constant contents.  */
1934   obstack_grow (&permanent_obstack, strp, len);
1935 }
1936 \f
1937 /* Return an rtx representing a reference to constant data in memory
1938    for the constant expression EXP.
1939    If assembler code for such a constant has already been output,
1940    return an rtx to refer to it.
1941    Otherwise, output such a constant in memory and generate
1942    an rtx for it.  The TREE_CST_RTL of EXP is set up to point to that rtx.
1943    The const_hash_table records which constants already have label strings.  */
1944
1945 rtx
1946 output_constant_def (exp)
1947      tree exp;
1948 {
1949   register int hash, align;
1950   register struct constant_descriptor *desc;
1951   char label[256];
1952   char *found = 0;
1953   int reloc;
1954   register rtx def;
1955
1956   if (TREE_CODE (exp) == INTEGER_CST)
1957     abort ();                   /* No TREE_CST_RTL slot in these.  */
1958
1959   if (TREE_CST_RTL (exp))
1960     return TREE_CST_RTL (exp);
1961
1962   /* Make sure any other constants whose addresses appear in EXP
1963      are assigned label numbers.  */
1964
1965   reloc = output_addressed_constants (exp);
1966
1967   /* Compute hash code of EXP.  Search the descriptors for that hash code
1968      to see if any of them describes EXP.  If yes, the descriptor records
1969      the label number already assigned.  */
1970
1971   hash = const_hash (exp) % MAX_HASH_TABLE;
1972
1973   for (desc = const_hash_table[hash]; desc; desc = desc->next)
1974     if (compare_constant (exp, desc))
1975       {
1976         found = desc->label;
1977         break;
1978       }
1979
1980   if (found == 0)
1981     {
1982       /* No constant equal to EXP is known to have been output.
1983          Make a constant descriptor to enter EXP in the hash table.
1984          Assign the label number and record it in the descriptor for
1985          future calls to this function to find.  */
1986
1987       /* Create a string containing the label name, in LABEL.  */
1988       ASM_GENERATE_INTERNAL_LABEL (label, "LC", const_labelno);
1989
1990       desc = record_constant (exp);
1991       desc->next = const_hash_table[hash];
1992       desc->label
1993         = (char *) obstack_copy0 (&permanent_obstack, label, strlen (label));
1994       const_hash_table[hash] = desc;
1995     }
1996
1997   /* We have a symbol name; construct the SYMBOL_REF and the MEM.  */
1998
1999   push_obstacks_nochange ();
2000   if (TREE_PERMANENT (exp))
2001     end_temporary_allocation ();
2002
2003   def = gen_rtx (SYMBOL_REF, Pmode, desc->label);
2004
2005   TREE_CST_RTL (exp)
2006     = gen_rtx (MEM, TYPE_MODE (TREE_TYPE (exp)), def);
2007   RTX_UNCHANGING_P (TREE_CST_RTL (exp)) = 1;
2008   if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE
2009       || TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE)
2010     MEM_IN_STRUCT_P (TREE_CST_RTL (exp)) = 1;
2011
2012   pop_obstacks ();
2013
2014   /* Optionally set flags or add text to the name to record information
2015      such as that it is a function name.  If the name is changed, the macro
2016      ASM_OUTPUT_LABELREF will have to know how to strip this information.
2017      And if it finds a * at the beginning after doing so, it must handle
2018      that too.  */
2019 #ifdef ENCODE_SECTION_INFO
2020   ENCODE_SECTION_INFO (exp);
2021 #endif
2022
2023   if (found == 0)
2024     {
2025       /* Now output assembler code to define that label
2026          and follow it with the data of EXP.  */
2027
2028       /* First switch to text section, except for writable strings.  */
2029 #ifdef SELECT_SECTION
2030       SELECT_SECTION (exp, reloc);
2031 #else
2032       if (((TREE_CODE (exp) == STRING_CST) && flag_writable_strings)
2033           || (flag_pic && reloc))
2034         data_section ();
2035       else
2036         readonly_data_section ();
2037 #endif
2038
2039       /* Align the location counter as required by EXP's data type.  */
2040       align = TYPE_ALIGN (TREE_TYPE (exp));
2041 #ifdef CONSTANT_ALIGNMENT
2042       align = CONSTANT_ALIGNMENT (exp, align);
2043 #endif
2044
2045       if (align > BITS_PER_UNIT)
2046         ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT));
2047
2048       /* Output the label itself.  */
2049       ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LC", const_labelno);
2050
2051       /* Output the value of EXP.  */
2052       output_constant (exp,
2053                        (TREE_CODE (exp) == STRING_CST
2054                         ? TREE_STRING_LENGTH (exp)
2055                         : int_size_in_bytes (TREE_TYPE (exp))));
2056
2057       ++const_labelno;
2058     }
2059
2060   return TREE_CST_RTL (exp);
2061 }
2062 \f
2063 /* Similar hash facility for making memory-constants
2064    from constant rtl-expressions.  It is used on RISC machines
2065    where immediate integer arguments and constant addresses are restricted
2066    so that such constants must be stored in memory.
2067
2068    This pool of constants is reinitialized for each function
2069    so each function gets its own constants-pool that comes right before it.
2070
2071    All structures allocated here are discarded when functions are saved for
2072    inlining, so they do not need to be allocated permanently.  */
2073
2074 #define MAX_RTX_HASH_TABLE 61
2075 static struct constant_descriptor **const_rtx_hash_table;
2076
2077 /* Structure to represent sufficient information about a constant so that
2078    it can be output when the constant pool is output, so that function
2079    integration can be done, and to simplify handling on machines that reference
2080    constant pool as base+displacement.  */
2081
2082 struct pool_constant
2083 {
2084   struct constant_descriptor *desc;
2085   struct pool_constant *next;
2086   enum machine_mode mode;
2087   rtx constant;
2088   int labelno;
2089   int align;
2090   int offset;
2091 };
2092
2093 /* Pointers to first and last constant in pool.  */
2094
2095 static struct pool_constant *first_pool, *last_pool;
2096
2097 /* Current offset in constant pool (does not include any machine-specific
2098    header.  */
2099
2100 static int pool_offset;
2101
2102 /* Structure used to maintain hash table mapping symbols used to their
2103    corresponding constants.  */
2104
2105 struct pool_sym
2106 {
2107   char *label;
2108   struct pool_constant *pool;
2109   struct pool_sym *next;
2110 };
2111
2112 static struct pool_sym **const_rtx_sym_hash_table;
2113
2114 /* Hash code for a SYMBOL_REF with CONSTANT_POOL_ADDRESS_P true.
2115    The argument is XSTR (... , 0)  */
2116
2117 #define SYMHASH(LABEL)  \
2118   ((((HOST_WIDE_INT) (LABEL)) & ((1 << HASHBITS) - 1))  % MAX_RTX_HASH_TABLE)
2119 \f
2120 /* Initialize constant pool hashing for next function.  */
2121
2122 void
2123 init_const_rtx_hash_table ()
2124 {
2125   const_rtx_hash_table
2126     = ((struct constant_descriptor **)
2127        oballoc (MAX_RTX_HASH_TABLE * sizeof (struct constant_descriptor *)));
2128   const_rtx_sym_hash_table
2129     = ((struct pool_sym **)
2130        oballoc (MAX_RTX_HASH_TABLE * sizeof (struct pool_sym *)));
2131   bzero (const_rtx_hash_table,
2132          MAX_RTX_HASH_TABLE * sizeof (struct constant_descriptor *));
2133   bzero (const_rtx_sym_hash_table,
2134          MAX_RTX_HASH_TABLE * sizeof (struct pool_sym *));
2135
2136   first_pool = last_pool = 0;
2137   pool_offset = 0;
2138 }
2139
2140 /* Save and restore it for a nested function.  */
2141
2142 void
2143 save_varasm_status (p)
2144      struct function *p;
2145 {
2146   p->const_rtx_hash_table = const_rtx_hash_table;
2147   p->const_rtx_sym_hash_table = const_rtx_sym_hash_table;
2148   p->first_pool = first_pool;
2149   p->last_pool = last_pool;
2150   p->pool_offset = pool_offset;
2151 }
2152
2153 void
2154 restore_varasm_status (p)
2155      struct function *p;
2156 {
2157   const_rtx_hash_table = p->const_rtx_hash_table;
2158   const_rtx_sym_hash_table = p->const_rtx_sym_hash_table;
2159   first_pool = p->first_pool;
2160   last_pool = p->last_pool;
2161   pool_offset = p->pool_offset;
2162 }
2163 \f
2164 enum kind { RTX_DOUBLE, RTX_INT };
2165
2166 struct rtx_const
2167 {
2168 #ifdef ONLY_INT_FIELDS
2169   unsigned int kind : 16;
2170   unsigned int mode : 16;
2171 #else
2172   enum kind kind : 16;
2173   enum machine_mode mode : 16;
2174 #endif
2175   union {
2176     union real_extract du;
2177     struct addr_const addr;
2178   } un;
2179 };
2180
2181 /* Express an rtx for a constant integer (perhaps symbolic)
2182    as the sum of a symbol or label plus an explicit integer.
2183    They are stored into VALUE.  */
2184
2185 static void
2186 decode_rtx_const (mode, x, value)
2187      enum machine_mode mode;
2188      rtx x;
2189      struct rtx_const *value;
2190 {
2191   /* Clear the whole structure, including any gaps.  */
2192
2193   {
2194     int *p = (int *) value;
2195     int *end = (int *) (value + 1);
2196     while (p < end)
2197       *p++ = 0;
2198   }
2199
2200   value->kind = RTX_INT;        /* Most usual kind. */
2201   value->mode = mode;
2202
2203   switch (GET_CODE (x))
2204     {
2205     case CONST_DOUBLE:
2206       value->kind = RTX_DOUBLE;
2207       value->mode = GET_MODE (x);
2208       bcopy (&CONST_DOUBLE_LOW (x), &value->un.du, sizeof value->un.du);
2209       break;
2210
2211     case CONST_INT:
2212       value->un.addr.offset = INTVAL (x);
2213       break;
2214
2215     case SYMBOL_REF:
2216     case LABEL_REF:
2217     case PC:
2218       value->un.addr.base = x;
2219       break;
2220
2221     case CONST:
2222       x = XEXP (x, 0);
2223       if (GET_CODE (x) == PLUS)
2224         {
2225           value->un.addr.base = XEXP (x, 0);
2226           if (GET_CODE (XEXP (x, 1)) != CONST_INT)
2227             abort ();
2228           value->un.addr.offset = INTVAL (XEXP (x, 1));
2229         }
2230       else if (GET_CODE (x) == MINUS)
2231         {
2232           value->un.addr.base = XEXP (x, 0);
2233           if (GET_CODE (XEXP (x, 1)) != CONST_INT)
2234             abort ();
2235           value->un.addr.offset = - INTVAL (XEXP (x, 1));
2236         }
2237       else
2238         abort ();
2239       break;
2240
2241     default:
2242       abort ();
2243     }
2244
2245   if (value->kind == RTX_INT && value->un.addr.base != 0)
2246     switch (GET_CODE (value->un.addr.base))
2247       {
2248       case SYMBOL_REF:
2249       case LABEL_REF:
2250         /* Use the string's address, not the SYMBOL_REF's address,
2251            for the sake of addresses of library routines.
2252            For a LABEL_REF, compare labels.  */
2253         value->un.addr.base = XEXP (value->un.addr.base, 0);
2254       }
2255 }
2256
2257 /* Given a MINUS expression, simplify it if both sides
2258    include the same symbol.  */
2259
2260 rtx
2261 simplify_subtraction (x)
2262      rtx x;
2263 {
2264   struct rtx_const val0, val1;
2265
2266   decode_rtx_const (GET_MODE (x), XEXP (x, 0), &val0);
2267   decode_rtx_const (GET_MODE (x), XEXP (x, 1), &val1);
2268
2269   if (val0.un.addr.base == val1.un.addr.base)
2270     return GEN_INT (val0.un.addr.offset - val1.un.addr.offset);
2271   return x;
2272 }
2273
2274 /* Compute a hash code for a constant RTL expression.  */
2275
2276 int
2277 const_hash_rtx (mode, x)
2278      enum machine_mode mode;
2279      rtx x;
2280 {
2281   register int hi, i;
2282
2283   struct rtx_const value;
2284   decode_rtx_const (mode, x, &value);
2285
2286   /* Compute hashing function */
2287   hi = 0;
2288   for (i = 0; i < sizeof value / sizeof (int); i++)
2289     hi += ((int *) &value)[i];
2290
2291   hi &= (1 << HASHBITS) - 1;
2292   hi %= MAX_RTX_HASH_TABLE;
2293   return hi;
2294 }
2295
2296 /* Compare a constant rtl object X with a constant-descriptor DESC.
2297    Return 1 if DESC describes a constant with the same value as X.  */
2298
2299 static int
2300 compare_constant_rtx (mode, x, desc)
2301      enum machine_mode mode;
2302      rtx x;
2303      struct constant_descriptor *desc;
2304 {
2305   register int *p = (int *) desc->contents;
2306   register int *strp;
2307   register int len;
2308   struct rtx_const value;
2309
2310   decode_rtx_const (mode, x, &value);
2311   strp = (int *) &value;
2312   len = sizeof value / sizeof (int);
2313
2314   /* Compare constant contents.  */
2315   while (--len >= 0)
2316     if (*p++ != *strp++)
2317       return 0;
2318
2319   return 1;
2320 }
2321
2322 /* Construct a constant descriptor for the rtl-expression X.
2323    It is up to the caller to enter the descriptor in the hash table.  */
2324
2325 static struct constant_descriptor *
2326 record_constant_rtx (mode, x)
2327      enum machine_mode mode;
2328      rtx x;
2329 {
2330   struct constant_descriptor *ptr;
2331   char *label;
2332   struct rtx_const value;
2333
2334   decode_rtx_const (mode, x, &value);
2335
2336   obstack_grow (current_obstack, &ptr, sizeof ptr);
2337   obstack_grow (current_obstack, &label, sizeof label);
2338
2339   /* Record constant contents.  */
2340   obstack_grow (current_obstack, &value, sizeof value);
2341
2342   return (struct constant_descriptor *) obstack_finish (current_obstack);
2343 }
2344 \f
2345 /* Given a constant rtx X, make (or find) a memory constant for its value
2346    and return a MEM rtx to refer to it in memory.  */
2347
2348 rtx
2349 force_const_mem (mode, x)
2350      enum machine_mode mode;
2351      rtx x;
2352 {
2353   register int hash;
2354   register struct constant_descriptor *desc;
2355   char label[256];
2356   char *found = 0;
2357   rtx def;
2358
2359   /* If we want this CONST_DOUBLE in the same mode as it is in memory
2360      (this will always be true for floating CONST_DOUBLEs that have been
2361      placed in memory, but not for VOIDmode (integer) CONST_DOUBLEs),
2362      use the previous copy.  Otherwise, make a new one.  Note that in
2363      the unlikely event that this same CONST_DOUBLE is used in two different
2364      modes in an alternating fashion, we will allocate a lot of different
2365      memory locations, but this should be extremely rare.  */
2366
2367   /* Don't use CONST_DOUBLE_MEM in a nested function.
2368      Nested functions have their own constant pools,
2369      so they can't share the same values in CONST_DOUBLE_MEM
2370      with the containing function.  */
2371   if (outer_function_chain == 0)
2372     if (GET_CODE (x) == CONST_DOUBLE
2373         && GET_CODE (CONST_DOUBLE_MEM (x)) == MEM
2374         && GET_MODE (CONST_DOUBLE_MEM (x)) == mode)
2375       return CONST_DOUBLE_MEM (x);
2376
2377   /* Compute hash code of X.  Search the descriptors for that hash code
2378      to see if any of them describes X.  If yes, the descriptor records
2379      the label number already assigned.  */
2380
2381   hash = const_hash_rtx (mode, x);
2382
2383   for (desc = const_rtx_hash_table[hash]; desc; desc = desc->next)
2384     if (compare_constant_rtx (mode, x, desc))
2385       {
2386         found = desc->label;
2387         break;
2388       }
2389
2390   if (found == 0)
2391     {
2392       register struct pool_constant *pool;
2393       register struct pool_sym *sym;
2394       int align;
2395
2396       /* No constant equal to X is known to have been output.
2397          Make a constant descriptor to enter X in the hash table.
2398          Assign the label number and record it in the descriptor for
2399          future calls to this function to find.  */
2400
2401       desc = record_constant_rtx (mode, x);
2402       desc->next = const_rtx_hash_table[hash];
2403       const_rtx_hash_table[hash] = desc;
2404
2405       /* Align the location counter as required by EXP's data type.  */
2406       align = (mode == VOIDmode) ? UNITS_PER_WORD : GET_MODE_SIZE (mode);
2407       if (align > BIGGEST_ALIGNMENT / BITS_PER_UNIT)
2408         align = BIGGEST_ALIGNMENT / BITS_PER_UNIT;
2409
2410       pool_offset += align - 1;
2411       pool_offset &= ~ (align - 1);
2412
2413       /* Allocate a pool constant descriptor, fill it in, and chain it in.  */
2414
2415       pool = (struct pool_constant *) oballoc (sizeof (struct pool_constant));
2416       pool->desc = desc;
2417       pool->constant = x;
2418       pool->mode = mode;
2419       pool->labelno = const_labelno;
2420       pool->align = align;
2421       pool->offset = pool_offset;
2422       pool->next = 0;
2423
2424       if (last_pool == 0)
2425         first_pool = pool;
2426       else
2427         last_pool->next = pool;
2428
2429       last_pool = pool;
2430       pool_offset += GET_MODE_SIZE (mode);
2431
2432       /* Create a string containing the label name, in LABEL.  */
2433       ASM_GENERATE_INTERNAL_LABEL (label, "LC", const_labelno);
2434
2435       ++const_labelno;
2436
2437       desc->label = found
2438         = (char *) obstack_copy0 (saveable_obstack, label, strlen (label));
2439
2440       /* Add label to symbol hash table.  */
2441       hash = SYMHASH (found);
2442       sym = (struct pool_sym *) oballoc (sizeof (struct pool_sym));
2443       sym->label = found;
2444       sym->pool = pool;
2445       sym->next = const_rtx_sym_hash_table[hash];
2446       const_rtx_sym_hash_table[hash] = sym;
2447     }
2448
2449   /* We have a symbol name; construct the SYMBOL_REF and the MEM.  */
2450
2451   def = gen_rtx (MEM, mode, gen_rtx (SYMBOL_REF, Pmode, found));
2452
2453   RTX_UNCHANGING_P (def) = 1;
2454   /* Mark the symbol_ref as belonging to this constants pool.  */
2455   CONSTANT_POOL_ADDRESS_P (XEXP (def, 0)) = 1;
2456   current_function_uses_const_pool = 1;
2457
2458   if (outer_function_chain == 0)
2459     if (GET_CODE (x) == CONST_DOUBLE)
2460       {
2461         if (CONST_DOUBLE_MEM (x) == cc0_rtx)
2462           {
2463             CONST_DOUBLE_CHAIN (x) = const_double_chain;
2464             const_double_chain = x;
2465           }
2466         CONST_DOUBLE_MEM (x) = def;
2467       }
2468
2469   return def;
2470 }
2471 \f
2472 /* Given a SYMBOL_REF with CONSTANT_POOL_ADDRESS_P true, return a pointer to
2473    the corresponding pool_constant structure.  */
2474
2475 static struct pool_constant *
2476 find_pool_constant (addr)
2477      rtx addr;
2478 {
2479   struct pool_sym *sym;
2480   char *label = XSTR (addr, 0);
2481
2482   for (sym = const_rtx_sym_hash_table[SYMHASH (label)]; sym; sym = sym->next)
2483     if (sym->label == label)
2484       return sym->pool;
2485
2486   abort ();
2487 }
2488
2489 /* Given a constant pool SYMBOL_REF, return the corresponding constant.  */
2490
2491 rtx
2492 get_pool_constant (addr)
2493      rtx addr;
2494 {
2495   return (find_pool_constant (addr))->constant;
2496 }
2497
2498 /* Similar, return the mode.  */
2499
2500 enum machine_mode
2501 get_pool_mode (addr)
2502      rtx addr;
2503 {
2504   return (find_pool_constant (addr))->mode;
2505 }
2506
2507 /* Similar, return the offset in the constant pool.  */
2508
2509 int
2510 get_pool_offset (addr)
2511      rtx addr;
2512 {
2513   return (find_pool_constant (addr))->offset;
2514 }
2515
2516 /* Return the size of the constant pool.  */
2517
2518 int
2519 get_pool_size ()
2520 {
2521   return pool_offset;
2522 }
2523 \f
2524 /* Write all the constants in the constant pool.  */
2525
2526 void
2527 output_constant_pool (fnname, fndecl)
2528      char *fnname;
2529      tree fndecl;
2530 {
2531   struct pool_constant *pool;
2532   rtx x;
2533   union real_extract u;
2534
2535 #ifdef ASM_OUTPUT_POOL_PROLOGUE
2536   ASM_OUTPUT_POOL_PROLOGUE (asm_out_file, fnname, fndecl, pool_offset);
2537 #endif
2538
2539   for (pool = first_pool; pool; pool = pool->next)
2540     {
2541       x = pool->constant;
2542
2543       /* See if X is a LABEL_REF (or a CONST referring to a LABEL_REF)
2544          whose CODE_LABEL has been deleted.  This can occur if a jump table
2545          is eliminated by optimization.  If so, write a constant of zero
2546          instead.  Note that this can also happen by turning the
2547          CODE_LABEL into a NOTE.  */
2548       if (((GET_CODE (x) == LABEL_REF
2549             && (INSN_DELETED_P (XEXP (x, 0))
2550                 || GET_CODE (XEXP (x, 0)) == NOTE)))
2551           || (GET_CODE (x) == CONST && GET_CODE (XEXP (x, 0)) == PLUS
2552               && GET_CODE (XEXP (XEXP (x, 0), 0)) == LABEL_REF
2553               && (INSN_DELETED_P (XEXP (XEXP (XEXP (x, 0), 0), 0))
2554                   || GET_CODE (XEXP (XEXP (XEXP (x, 0), 0), 0)) == NOTE)))
2555         x = const0_rtx;
2556
2557       /* First switch to correct section.  */
2558 #ifdef SELECT_RTX_SECTION
2559       SELECT_RTX_SECTION (pool->mode, x);
2560 #else
2561       readonly_data_section ();
2562 #endif
2563
2564 #ifdef ASM_OUTPUT_SPECIAL_POOL_ENTRY
2565       ASM_OUTPUT_SPECIAL_POOL_ENTRY (asm_out_file, x, pool->mode,
2566                                      pool->align, pool->labelno, done);
2567 #endif
2568
2569       if (pool->align > 1)
2570         ASM_OUTPUT_ALIGN (asm_out_file, exact_log2 (pool->align));
2571
2572       /* Output the label.  */
2573       ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LC", pool->labelno);
2574
2575       /* Output the value of the constant itself.  */
2576       switch (GET_MODE_CLASS (pool->mode))
2577         {
2578         case MODE_FLOAT:
2579           if (GET_CODE (x) != CONST_DOUBLE)
2580             abort ();
2581
2582           bcopy (&CONST_DOUBLE_LOW (x), &u, sizeof u);
2583           assemble_real (u.d, pool->mode);
2584           break;
2585
2586         case MODE_INT:
2587         case MODE_PARTIAL_INT:
2588           assemble_integer (x, GET_MODE_SIZE (pool->mode), 1);
2589           break;
2590
2591         default:
2592           abort ();
2593         }
2594
2595     done: ;
2596     }
2597
2598   /* Done with this pool.  */
2599   first_pool = last_pool = 0;
2600 }
2601 \f
2602 /* Find all the constants whose addresses are referenced inside of EXP,
2603    and make sure assembler code with a label has been output for each one.
2604    Indicate whether an ADDR_EXPR has been encountered.  */
2605
2606 int
2607 output_addressed_constants (exp)
2608      tree exp;
2609 {
2610   int reloc = 0;
2611
2612   switch (TREE_CODE (exp))
2613     {
2614     case ADDR_EXPR:
2615       {
2616         register tree constant = TREE_OPERAND (exp, 0);
2617
2618         while (TREE_CODE (constant) == COMPONENT_REF)
2619           {
2620             constant = TREE_OPERAND (constant, 0);
2621           }
2622
2623         if (TREE_CODE_CLASS (TREE_CODE (constant)) == 'c'
2624             || TREE_CODE (constant) == CONSTRUCTOR)
2625           /* No need to do anything here
2626              for addresses of variables or functions.  */
2627           output_constant_def (constant);
2628       }
2629       reloc = 1;
2630       break;
2631
2632     case PLUS_EXPR:
2633     case MINUS_EXPR:
2634       reloc = output_addressed_constants (TREE_OPERAND (exp, 0));
2635       reloc |= output_addressed_constants (TREE_OPERAND (exp, 1));
2636       break;
2637
2638     case NOP_EXPR:
2639     case CONVERT_EXPR:
2640     case NON_LVALUE_EXPR:
2641       reloc = output_addressed_constants (TREE_OPERAND (exp, 0));
2642       break;
2643
2644     case CONSTRUCTOR:
2645       {
2646         register tree link;
2647         for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link))
2648           if (TREE_VALUE (link) != 0)
2649             reloc |= output_addressed_constants (TREE_VALUE (link));
2650       }
2651       break;
2652
2653     case ERROR_MARK:
2654       break;
2655     }
2656   return reloc;
2657 }
2658 \f
2659 /* Output assembler code for constant EXP to FILE, with no label.
2660    This includes the pseudo-op such as ".int" or ".byte", and a newline.
2661    Assumes output_addressed_constants has been done on EXP already.
2662
2663    Generate exactly SIZE bytes of assembler data, padding at the end
2664    with zeros if necessary.  SIZE must always be specified.
2665
2666    SIZE is important for structure constructors,
2667    since trailing members may have been omitted from the constructor.
2668    It is also important for initialization of arrays from string constants
2669    since the full length of the string constant might not be wanted.
2670    It is also needed for initialization of unions, where the initializer's
2671    type is just one member, and that may not be as long as the union.
2672
2673    There a case in which we would fail to output exactly SIZE bytes:
2674    for a structure constructor that wants to produce more than SIZE bytes.
2675    But such constructors will never be generated for any possible input.  */
2676
2677 void
2678 output_constant (exp, size)
2679      register tree exp;
2680      register int size;
2681 {
2682   register enum tree_code code = TREE_CODE (TREE_TYPE (exp));
2683   rtx x;
2684
2685   if (size == 0)
2686     return;
2687
2688   /* Allow a constructor with no elements for any data type.
2689      This means to fill the space with zeros.  */
2690   if (TREE_CODE (exp) == CONSTRUCTOR && CONSTRUCTOR_ELTS (exp) == 0)
2691     {
2692       assemble_zeros (size);
2693       return;
2694     }
2695
2696   /* Eliminate the NOP_EXPR that makes a cast not be an lvalue.
2697      That way we get the constant (we hope) inside it.  */
2698   if (TREE_CODE (exp) == NOP_EXPR
2699       && TREE_TYPE (exp) == TREE_TYPE (TREE_OPERAND (exp, 0)))
2700     exp = TREE_OPERAND (exp, 0);
2701
2702   switch (code)
2703     {
2704     case CHAR_TYPE:
2705     case BOOLEAN_TYPE:
2706     case INTEGER_TYPE:
2707     case ENUMERAL_TYPE:
2708     case POINTER_TYPE:
2709     case REFERENCE_TYPE:
2710       /* ??? What about       (int)((float)(int)&foo + 4)    */
2711       while (TREE_CODE (exp) == NOP_EXPR || TREE_CODE (exp) == CONVERT_EXPR
2712              || TREE_CODE (exp) == NON_LVALUE_EXPR)
2713         exp = TREE_OPERAND (exp, 0);
2714
2715       if (! assemble_integer (expand_expr (exp, NULL_RTX, VOIDmode,
2716                                            EXPAND_INITIALIZER),
2717                               size, 0))
2718         error ("initializer for integer value is too complicated");
2719       size = 0;
2720       break;
2721
2722     case REAL_TYPE:
2723       if (TREE_CODE (exp) != REAL_CST)
2724         error ("initializer for floating value is not a floating constant");
2725
2726       assemble_real (TREE_REAL_CST (exp),
2727                      mode_for_size (size * BITS_PER_UNIT, MODE_FLOAT, 0));
2728       size = 0;
2729       break;
2730
2731     case COMPLEX_TYPE:
2732       output_constant (TREE_REALPART (exp), size / 2);
2733       output_constant (TREE_IMAGPART (exp), size / 2);
2734       size -= (size / 2) * 2;
2735       break;
2736
2737     case ARRAY_TYPE:
2738       if (TREE_CODE (exp) == CONSTRUCTOR)
2739         {
2740           output_constructor (exp, size);
2741           return;
2742         }
2743       else if (TREE_CODE (exp) == STRING_CST)
2744         {
2745           int excess = 0;
2746
2747           if (size > TREE_STRING_LENGTH (exp))
2748             {
2749               excess = size - TREE_STRING_LENGTH (exp);
2750               size = TREE_STRING_LENGTH (exp);
2751             }
2752
2753           assemble_string (TREE_STRING_POINTER (exp), size);
2754           size = excess;
2755         }
2756       else
2757         abort ();
2758       break;
2759
2760     case RECORD_TYPE:
2761     case UNION_TYPE:
2762       if (TREE_CODE (exp) == CONSTRUCTOR)
2763         output_constructor (exp, size);
2764       else
2765         abort ();
2766       return;
2767     }
2768
2769   if (size > 0)
2770     assemble_zeros (size);
2771 }
2772 \f
2773 /* Subroutine of output_constant, used for CONSTRUCTORs
2774    (aggregate constants).
2775    Generate at least SIZE bytes, padding if necessary.  */
2776
2777 void
2778 output_constructor (exp, size)
2779      tree exp;
2780      int size;
2781 {
2782   register tree link, field = 0;
2783   /* Number of bytes output or skipped so far.
2784      In other words, current position within the constructor.  */
2785   int total_bytes = 0;
2786   /* Non-zero means BYTE contains part of a byte, to be output.  */
2787   int byte_buffer_in_use = 0;
2788   register int byte;
2789
2790   if (HOST_BITS_PER_WIDE_INT < BITS_PER_UNIT)
2791     abort ();
2792
2793   if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE)
2794     field = TYPE_FIELDS (TREE_TYPE (exp));
2795
2796   /* As LINK goes through the elements of the constant,
2797      FIELD goes through the structure fields, if the constant is a structure.
2798      if the constant is a union, then we override this,
2799      by getting the field from the TREE_LIST element.
2800      But the constant could also be an array.  Then FIELD is zero.  */
2801   for (link = CONSTRUCTOR_ELTS (exp);
2802        link;
2803        link = TREE_CHAIN (link),
2804        field = field ? TREE_CHAIN (field) : 0)
2805     {
2806       tree val = TREE_VALUE (link);
2807       /* the element in a union constructor specifies the proper field.  */
2808       if (TREE_PURPOSE (link) != 0)
2809         field = TREE_PURPOSE (link);
2810
2811       /* Eliminate the marker that makes a cast not be an lvalue.  */
2812       if (val != 0)
2813         STRIP_NOPS (val);
2814
2815       if (field == 0 || !DECL_BIT_FIELD (field))
2816         {
2817           register int fieldsize;
2818           /* Since this structure is static,
2819              we know the positions are constant.  */
2820           int bitpos = (field ? (TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field))
2821                                  / BITS_PER_UNIT)
2822                         : 0);
2823
2824           /* An element that is not a bit-field.
2825              Output any buffered-up bit-fields preceding it.  */
2826           if (byte_buffer_in_use)
2827             {
2828               ASM_OUTPUT_BYTE (asm_out_file, byte);
2829               total_bytes++;
2830               byte_buffer_in_use = 0;
2831             }
2832
2833           /* Advance to offset of this element.
2834              Note no alignment needed in an array, since that is guaranteed
2835              if each element has the proper size.  */
2836           if (field != 0 && bitpos != total_bytes)
2837             {
2838               assemble_zeros (bitpos - total_bytes);
2839               total_bytes = bitpos;
2840             }
2841
2842           /* Determine size this element should occupy.  */
2843           if (field)
2844             {
2845               if (TREE_CODE (DECL_SIZE (field)) != INTEGER_CST)
2846                 abort ();
2847               if (TREE_INT_CST_LOW (DECL_SIZE (field)) > 100000)
2848                 {
2849                   /* This avoids overflow trouble.  */
2850                   tree size_tree = size_binop (CEIL_DIV_EXPR,
2851                                                DECL_SIZE (field),
2852                                                size_int (BITS_PER_UNIT));
2853                   fieldsize = TREE_INT_CST_LOW (size_tree);
2854                 }
2855               else
2856                 {
2857                   fieldsize = TREE_INT_CST_LOW (DECL_SIZE (field));
2858                   fieldsize = (fieldsize + BITS_PER_UNIT - 1) / BITS_PER_UNIT;
2859                 }
2860             }
2861           else
2862             fieldsize = int_size_in_bytes (TREE_TYPE (TREE_TYPE (exp)));
2863
2864           /* Output the element's initial value.  */
2865           if (val == 0)
2866             assemble_zeros (fieldsize);
2867           else
2868             output_constant (val, fieldsize);
2869
2870           /* Count its size.  */
2871           total_bytes += fieldsize;
2872         }
2873       else if (val != 0 && TREE_CODE (val) != INTEGER_CST)
2874         error ("invalid initial value for member `%s'",
2875                IDENTIFIER_POINTER (DECL_NAME (field)));
2876       else
2877         {
2878           /* Element that is a bit-field.  */
2879
2880           int next_offset = TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field));
2881           int end_offset
2882             = (next_offset + TREE_INT_CST_LOW (DECL_SIZE (field)));
2883
2884           if (val == 0)
2885             val = integer_zero_node;
2886
2887           /* If this field does not start in this (or, next) byte,
2888              skip some bytes.  */
2889           if (next_offset / BITS_PER_UNIT != total_bytes)
2890             {
2891               /* Output remnant of any bit field in previous bytes.  */
2892               if (byte_buffer_in_use)
2893                 {
2894                   ASM_OUTPUT_BYTE (asm_out_file, byte);
2895                   total_bytes++;
2896                   byte_buffer_in_use = 0;
2897                 }
2898
2899               /* If still not at proper byte, advance to there.  */
2900               if (next_offset / BITS_PER_UNIT != total_bytes)
2901                 {
2902                   assemble_zeros (next_offset / BITS_PER_UNIT - total_bytes);
2903                   total_bytes = next_offset / BITS_PER_UNIT;
2904                 }
2905             }
2906
2907           if (! byte_buffer_in_use)
2908             byte = 0;
2909
2910           /* We must split the element into pieces that fall within
2911              separate bytes, and combine each byte with previous or
2912              following bit-fields.  */
2913
2914           /* next_offset is the offset n fbits from the beginning of
2915              the structure to the next bit of this element to be processed.
2916              end_offset is the offset of the first bit past the end of
2917              this element.  */
2918           while (next_offset < end_offset)
2919             {
2920               int this_time;
2921               int shift, value;
2922               int next_byte = next_offset / BITS_PER_UNIT;
2923               int next_bit = next_offset % BITS_PER_UNIT;
2924
2925               /* Advance from byte to byte
2926                  within this element when necessary.  */
2927               while (next_byte != total_bytes)
2928                 {
2929                   ASM_OUTPUT_BYTE (asm_out_file, byte);
2930                   total_bytes++;
2931                   byte = 0;
2932                 }
2933
2934               /* Number of bits we can process at once
2935                  (all part of the same byte).  */
2936               this_time = MIN (end_offset - next_offset,
2937                                BITS_PER_UNIT - next_bit);
2938 #if BYTES_BIG_ENDIAN
2939               /* On big-endian machine, take the most significant bits
2940                  first (of the bits that are significant)
2941                  and put them into bytes from the most significant end.  */
2942               shift = end_offset - next_offset - this_time;
2943               /* Don't try to take a bunch of bits that cross
2944                  the word boundary in the INTEGER_CST.  */
2945               if (shift < HOST_BITS_PER_WIDE_INT
2946                   && shift + this_time > HOST_BITS_PER_WIDE_INT)
2947                 {
2948                   this_time -= (HOST_BITS_PER_WIDE_INT - shift);
2949                   shift = HOST_BITS_PER_WIDE_INT;
2950                 }
2951
2952               /* Now get the bits from the appropriate constant word.  */
2953               if (shift < HOST_BITS_PER_WIDE_INT)
2954                 {
2955                   value = TREE_INT_CST_LOW (val);
2956                 }
2957               else if (shift < 2 * HOST_BITS_PER_WIDE_INT)
2958                 {
2959                   value = TREE_INT_CST_HIGH (val);
2960                   shift -= HOST_BITS_PER_WIDE_INT;
2961                 }
2962               else
2963                 abort ();
2964               byte |= (((value >> shift)
2965                         & (((HOST_WIDE_INT) 1 << this_time) - 1))
2966                        << (BITS_PER_UNIT - this_time - next_bit));
2967 #else
2968               /* On little-endian machines,
2969                  take first the least significant bits of the value
2970                  and pack them starting at the least significant
2971                  bits of the bytes.  */
2972               shift = (next_offset
2973                        - TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field)));
2974               /* Don't try to take a bunch of bits that cross
2975                  the word boundary in the INTEGER_CST.  */
2976               if (shift < HOST_BITS_PER_WIDE_INT
2977                   && shift + this_time > HOST_BITS_PER_WIDE_INT)
2978                 {
2979                   this_time -= (HOST_BITS_PER_WIDE_INT - shift);
2980                   shift = HOST_BITS_PER_WIDE_INT;
2981                 }
2982
2983               /* Now get the bits from the appropriate constant word.  */
2984               if (shift < HOST_BITS_PER_INT)
2985                 value = TREE_INT_CST_LOW (val);
2986               else if (shift < 2 * HOST_BITS_PER_WIDE_INT)
2987                 {
2988                   value = TREE_INT_CST_HIGH (val);
2989                   shift -= HOST_BITS_PER_WIDE_INT;
2990                 }
2991               else
2992                 abort ();
2993               byte |= ((value >> shift)
2994                        & (((HOST_WIDE_INT) 1 << this_time) - 1)) << next_bit;
2995 #endif
2996               next_offset += this_time;
2997               byte_buffer_in_use = 1;
2998             }
2999         }
3000     }
3001   if (byte_buffer_in_use)
3002     {
3003       ASM_OUTPUT_BYTE (asm_out_file, byte);
3004       total_bytes++;
3005     }
3006   if (total_bytes < size)
3007     assemble_zeros (size - total_bytes);
3008 }