home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / gnat-2.06-src.tgz / tar.out / fsf / gnat / varasm.c < prev    next >
C/C++ Source or Header  |  1996-09-28  |  107KB  |  3,880 lines

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