home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / Source / GNU / gcc / varasm.c < prev    next >
C/C++ Source or Header  |  1996-10-04  |  115KB  |  4,162 lines

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