home *** CD-ROM | disk | FTP | other *** search
/ Education Sampler 1992 [NeXTSTEP] / Education_1992_Sampler.iso / NeXT / GnuSource / cplusplus-8 / stmt.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-02-07  |  150.4 KB  |  4,941 lines

  1. /* Expands front end tree to back end RTL for GNU C-Compiler
  2.    Copyright (C) 1987, 1988, 1989 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 1, 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 the generation of rtl code from tree structure
  22.    above the level of expressions, using subroutines in exp*.c and emit-rtl.c.
  23.    It also creates the rtl expressions for parameters and auto variables
  24.    and has full responsibility for allocating stack slots.
  25.  
  26.    The functions whose names start with `expand_' are called by the
  27.    parser to generate RTL instructions for various kinds of constructs.
  28.  
  29.    Some control and binding constructs require calling several such
  30.    functions at different times.  For example, a simple if-then
  31.    is expanded by calling `expand_start_cond' (with the condition-expression
  32.    as argument) before parsing the then-clause and calling `expand_end_cond'
  33.    after parsing the then-clause.
  34.  
  35.    `expand_function_start' is called at the beginning of a function,
  36.    before the function body is parsed, and `expand_function_end' is
  37.    called after parsing the body.
  38.  
  39.    Call `assign_stack_local' to allocate a stack slot for a local variable.
  40.    This is usually done during the RTL generation for the function body,
  41.    but it can also be done in the reload pass when a pseudo-register does
  42.    not get a hard register.
  43.  
  44.    Call `put_var_into_stack' when you learn, belatedly, that a variable
  45.    previously given a pseudo-register must in fact go in the stack.
  46.    This function changes the DECL_RTL to be a stack slot instead of a reg
  47.    then scans all the RTL instructions so far generated to correct them.  */
  48.  
  49. #include "config.h"
  50.  
  51. #include <stdio.h>
  52.  
  53. #include "rtl.h"
  54. #include "tree.h"
  55. #include "flags.h"
  56. #include "insn-flags.h"
  57. #include "insn-config.h"
  58. #include "insn-codes.h"
  59. #include "expr.h"
  60. #include "regs.h"
  61. #include "hard-reg-set.h"
  62. #include "recog.h"
  63. #include "obstack.h"
  64.  
  65. #define obstack_chunk_alloc xmalloc
  66. #define obstack_chunk_free free
  67. struct obstack stmt_obstack;
  68.  
  69. extern int xmalloc ();
  70. extern void free ();
  71.  
  72. #define MAX(x,y) (((x) > (y)) ? (x) : (y))
  73. #define MIN(x,y) (((x) < (y)) ? (x) : (y))
  74.  
  75. /* Nonzero if function being compiled pops its args on return.
  76.    May affect compilation of return insn or of function epilogue.  */
  77.  
  78. int current_function_pops_args;
  79.  
  80. /* Nonzero if function being compiled needs to be given an address
  81.    where the value should be stored.  */
  82.  
  83. int current_function_returns_struct;
  84.  
  85. /* Nonzero if function being compiled needs to
  86.    return the address of where it has put a structure value.  */
  87.  
  88. int current_function_returns_pcc_struct;
  89.  
  90. /* Nonzero if function being compiled needs to be passed a static chain.  */
  91.  
  92. int current_function_needs_context;
  93.  
  94. /* Nonzero if function being compiled can call setjmp.  */
  95.  
  96. int current_function_calls_setjmp;
  97.  
  98. /* Nonzero if function being compiled can call alloca,
  99.    either as a subroutine or builtin.  */
  100.  
  101. int current_function_calls_alloca;
  102.  
  103. /* Nonzero if the current function returns a pointer type */
  104.  
  105. int current_function_returns_pointer;
  106.  
  107. /* If function's args have a fixed size, this is that size, in bytes.
  108.    Otherwise, it is -1.
  109.    May affect compilation of return insn or of function epilogue.  */
  110.  
  111. int current_function_args_size;
  112.  
  113. /* # bytes the prologue should push and pretend that the caller pushed them.
  114.    The prologue must do this, but only if parms can be passed in registers.  */
  115.  
  116. int current_function_pretend_args_size;
  117.  
  118. #ifdef NeXT
  119. /* This is the offset from the arg pointer to the place where the first
  120.    anonymous arg can be found, if there is one.  */
  121. rtx current_function_arg_offset_rtx;
  122. #endif  /* NeXT */
  123.  
  124. /* Name of function now being compiled.  */
  125.  
  126. char *current_function_name;
  127.  
  128. /* Label that will go on parm cleanup code, if any.
  129.    Jumping to this label runs cleanup code for parameters, if
  130.    such code must be run.  Following this code is the logical return label.  */
  131.  
  132. rtx cleanup_label;
  133.  
  134. /* Label that will go on function epilogue.
  135.    Jumping to this label serves as a "return" instruction
  136.    on machines which require execution of the epilogue on all returns.  */
  137.  
  138. rtx return_label;
  139.  
  140. /* List (chain of EXPR_LISTs) of pseudo-regs of SAVE_EXPRs.
  141.    So we can mark them all live at the end of the function, if nonopt.  */
  142. rtx save_expr_regs;
  143.  
  144. /* List (chain of EXPR_LISTs) of all stack slots in this function.
  145.    Made for the sake of unshare_all_rtl.  */
  146. rtx stack_slot_list;
  147.  
  148. /* Filename and line number of last line-number note,
  149.    whether we actually emitted it or not.  */
  150. char *emit_filename;
  151. int emit_lineno;
  152.  
  153. /* Insn after which register parms and SAVE_EXPRs are born, if nonopt.  */
  154. static rtx parm_birth_insn;
  155.  
  156. /* The FUNCTION_DECL node for the function being compiled.  */
  157.  
  158. static tree this_function;
  159.  
  160. /* Offset to end of allocated area of stack frame.
  161.    If stack grows down, this is the address of the last stack slot allocated.
  162.    If stack grows up, this is the address for the next slot.  */
  163. static int frame_offset;
  164.  
  165. /* Nonzero if a stack slot has been generated whose address is not
  166.    actually valid.  It means that the generated rtl must all be scanned
  167.    to detect and correct the invalid addresses where they occur.  */
  168. static int invalid_stack_slot;
  169.  
  170. /* Label to jump back to for tail recursion, or 0 if we have
  171.    not yet needed one for this function.  */
  172. static rtx tail_recursion_label;
  173.  
  174. /* Place after which to insert the tail_recursion_label if we need one.  */
  175. static rtx tail_recursion_reentry;
  176.  
  177. /* Each time we expand an expression-statement,
  178.    record the expr's type and its RTL value here.  */
  179.  
  180. static tree last_expr_type;
  181. static rtx last_expr_value;
  182.  
  183. /* Number of binding contours started so far in this function.  */
  184.  
  185. int block_start_count;
  186.  
  187. /* Chain of all RTL_EXPRs that have insns in them.  */
  188. static tree rtl_expr_chain;
  189.  
  190. /* Last insn of those whose job was to put parms into their nominal homes.  */
  191. static rtx last_parm_insn;
  192.  
  193. /* Cleanup lists are required for binding levels regardless of whether
  194.    that binding level has cleanups or not.  This node satisfies that
  195.    need for all binding levels.  */
  196. static tree empty_cleanup_list;
  197.  
  198. /* Functions and data structures for expanding case statements.  */
  199.  
  200. /* Case label structure, used to hold info on labels within case
  201.    statements.  We handle "range" labels; for a single-value label
  202.    as in C, the high and low limits are the same.  */
  203.  
  204. struct case_node
  205. {
  206.   struct case_node    *left;
  207.   struct case_node    *right;
  208.   struct case_node    *parent;
  209.   tree            low;
  210.   tree            high;
  211.   tree            test_label;
  212.   tree            code_label;
  213. };
  214.  
  215. typedef struct case_node case_node;
  216. typedef struct case_node *case_node_ptr;
  217.  
  218. extern void balance_case_nodes ();
  219. extern void emit_case_nodes ();
  220. extern void group_case_nodes ();
  221. extern void emit_jump_if_reachable ();
  222.  
  223. /* Stack of control and binding constructs we are currently inside.
  224.  
  225.    These constructs begin when you call `expand_start_WHATEVER'
  226.    and end when you call `expand_end_WHATEVER'.  This stack records
  227.    info about how the construct began that tells the end-function
  228.    what to do.  It also may provide information about the construct
  229.    to alter the behavior of other constructs within the body.
  230.    For example, they may affect the behavior of C `break' and `continue'.
  231.  
  232.    Each construct gets one `struct nesting' object.
  233.    All of these objects are chained through the `all' field.
  234.    `nesting_stack' points to the first object (innermost construct).
  235.    The position of an entry on `nesting_stack' is in its `depth' field.
  236.  
  237.    Each type of construct has its own individual stack.
  238.    For example, loops have `loop_stack'.  Each object points to the
  239.    next object of the same type through the `next' field.
  240.  
  241.    Some constructs are visible to `break' exit-statements and others
  242.    are not.  Which constructs are visible depends on the language.
  243.    Therefore, the data structure allows each construct to be visible
  244.    or not, according to the args given when the construct is started.
  245.    The construct is visible if the `exit_label' field is non-null.
  246.    In that case, the value should be a CODE_LABEL rtx.  */
  247.  
  248. struct nesting
  249. {
  250.   struct nesting *all;
  251.   struct nesting *next;
  252.   int depth;
  253.   rtx exit_label;
  254.   union
  255.     {
  256.       /* For conds (if-then and if-then-else statements).  */
  257.       struct
  258.     {
  259.       /* Label on the else-part, if any, else 0.  */
  260.       rtx else_label;
  261.       /* Label at the end of the whole construct.  */
  262.       rtx after_label;
  263.     } cond;
  264.       /* For loops.  */
  265.       struct
  266.     {
  267.       /* Label at the top of the loop; place to loop back to.  */
  268.       rtx start_label;
  269.       /* Label at the end of the whole construct.  */
  270.       rtx end_label;
  271.       /* Label for `continue' statement to jump to;
  272.          this is in front of the stepper of the loop.  */
  273.       rtx continue_label;
  274.     } loop;
  275.       /* For variable binding contours.  */
  276.       struct
  277.     {
  278.       /* Sequence number of this binding contour within the function,
  279.          in order of entry.  */
  280.       int block_start_count;
  281.       /* Nonzero => value to restore stack to on exit.  */
  282.       rtx stack_level;
  283.       /* The NOTE that starts this contour.
  284.          Used by expand_goto to check whether the destination
  285.          is within each contour or not.  */
  286.       rtx first_insn;
  287.       /* Innermost containing binding contour that has a stack level.  */
  288.       struct nesting *innermost_stack_block;
  289.       /* List of cleanups to be run on exit from this contour.
  290.          This is a list of expressions to be evaluated.
  291.          The TREE_PURPOSE of each link is the ..._DECL node
  292.          which the cleanup pertains to.  */
  293.       tree cleanups;
  294.       /* List of cleanup-lists of blocks containing this block,
  295.          as they were at the locus where this block appears.
  296.          There is an element for each containing block,
  297.          ordered innermost containing block first, once there are
  298.          any cleanups at all.
  299.          The element's TREE_VALUE is the cleanup-list of that block,
  300.          which may be null.  */
  301.       tree outer_cleanups;
  302.       /* Chain of labels defined inside this binding contour.
  303.          For contours that have stack levels or cleanups.  */
  304.       struct label_chain *label_chain;
  305.     } block;
  306.       /* For switch (C) or case (Pascal) statements,
  307.      and also for dummies (see `expand_start_case_dummy').  */
  308.       struct
  309.     {
  310.       /* The insn after which the case dispatch should finally
  311.          be emitted.  Zero for a dummy.  */
  312.       rtx start;
  313.       /* A list of case labels, kept in ascending order by value
  314.          as the list is built.
  315.          During expand_end_case, this list may be rearranged into a
  316.          nearly balanced binary tree.  */
  317.       struct case_node *case_list;
  318.       /* Label to jump to if no case matches.  */
  319.       tree default_label;
  320.       /* The expression to be dispatched on.  */
  321.       tree index_expr;
  322.       /* Type that INDEX_EXPR should be converted to.  */
  323.       tree nominal_type;
  324.       /* Number of range exprs in case statement.  */
  325.       short num_ranges;
  326.     } case_stmt;
  327.       /* For exception contours.  */
  328.       struct
  329.     {
  330.       /* List of exceptions raised.  This is a TREE_LIST
  331.          of whatever you want.  */
  332.       tree raised;
  333.       /* List of exceptions caught.  This is also a TREE_LIST
  334.          of whatever you want.  As a special case, it has the
  335.          value `void_type_node' if it handles default exceptions.  */
  336.       tree handled;
  337.  
  338.       /* First insn of TRY block, in case resumptive model is needed.  */
  339.       rtx first_insn;
  340.       /* Label for the catch clauses.  */
  341.       rtx except_label;
  342.       /* Label for unhandled exceptions.  */
  343.       rtx unhandled_label;
  344.       /* Label at the end of whole construct.  */
  345.       rtx after_label;
  346.       /* Label which "escapes" the exception construct.
  347.          Like EXIT_LABEL for BREAK construct, but for exceptions.  */
  348.       rtx escape_label;
  349.     } except_stmt;
  350.     } data;
  351. };
  352.  
  353. /* Chain of all pending binding contours.  */
  354. struct nesting *block_stack;
  355.  
  356. /* Chain of all pending binding contours that restore stack levels
  357.    or have cleanups.  */
  358. struct nesting *stack_block_stack;
  359.  
  360. /* Chain of all pending conditional statements.  */
  361. struct nesting *cond_stack;
  362.  
  363. /* Chain of all pending loops.  */
  364. struct nesting *loop_stack;
  365.  
  366. /* Chain of all pending case or switch statements.  */
  367. struct nesting *case_stack;
  368.  
  369. /* Chain of all pending exception contours.  */
  370. struct nesting *except_stack;
  371.  
  372. /* Separate chain including all of the above,
  373.    chained through the `all' field.  */
  374. struct nesting *nesting_stack;
  375.  
  376. /* Number of entries on nesting_stack now.  */
  377. int nesting_depth;
  378.  
  379. /* Pop one of the sub-stacks, such as `loop_stack' or `cond_stack';
  380.    and pop off `nesting_stack' down to the same level.  */
  381.  
  382. #define POPSTACK(STACK)                    \
  383. do { int initial_depth = nesting_stack->depth;        \
  384.      do { struct nesting *this = STACK;            \
  385.       STACK = this->next;                \
  386.       nesting_stack = this->all;            \
  387.       nesting_depth = this->depth;            \
  388.       obstack_free (&stmt_obstack, this); }        \
  389.      while (nesting_depth > initial_depth); } while (0)
  390.  
  391. static int warn_if_unused_value ();
  392. static void expand_goto_internal ();
  393. static int expand_fixup ();
  394. static void fixup_gotos ();
  395. static void expand_cleanups ();
  396. static void fixup_cleanups ();
  397. static void expand_null_return_1 ();
  398. static int tail_recursion_args ();
  399. static void fixup_stack_slots ();
  400. static rtx fixup_stack_1 ();
  401. static rtx fixup_memory_subreg ();
  402. static rtx walk_fixup_memory_subreg ();
  403. static void fixup_var_refs ();
  404. static void fixup_var_refs_insns ();
  405. static rtx fixup_var_refs_1 ();
  406. static rtx parm_stack_loc ();
  407. static void optimize_bit_field ();
  408. static void do_jump_if_equal ();
  409.  
  410. /* Emit a no-op instruction.  */
  411.  
  412. rtx
  413. emit_nop ()
  414. {
  415.   rtx last_insn = get_last_insn ();
  416.   if (!optimize
  417.       && (GET_CODE (last_insn) == CODE_LABEL
  418.       || prev_real_insn (last_insn) == 0))
  419.     emit_insn (gen_nop ());
  420. }
  421.  
  422. /* Return the rtx-label that corresponds to a LABEL_DECL,
  423.    creating it if necessary.  */
  424.  
  425. rtx /* @@ non-static for case.c.  */
  426. label_rtx (label)
  427.      tree label;
  428. {
  429.   if (TREE_CODE (label) != LABEL_DECL)
  430.     abort ();
  431.  
  432.   if (DECL_RTL (label))
  433.     return DECL_RTL (label);
  434.  
  435.   return DECL_RTL (label) = gen_label_rtx ();
  436. }
  437.  
  438. /* Add an unconditional jump to LABEL as the next sequential instruction.  */
  439.  
  440. void
  441. emit_jump (label)
  442.      rtx label;
  443. {
  444.   do_pending_stack_adjust ();
  445.   emit_jump_insn (gen_jump (label));
  446.   emit_barrier ();
  447. }
  448.  
  449. /* Handle goto statements and the labels that they can go to.  */
  450.  
  451. /* In some cases it is impossible to generate code for a forward goto 
  452.    until the label definition is seen.  This happens when it may be necessary
  453.    for the goto to reset the stack pointer: we don't yet know how to do that.
  454.    So expand_goto puts an entry on this fixup list.
  455.    Each time a binding contour that resets the stack is exited,
  456.    we check each fixup.
  457.    If the target label has now been defined, we can insert the proper code.  */
  458.  
  459. struct goto_fixup
  460. {
  461.   /* Points to following fixup.  */
  462.   struct goto_fixup *next;
  463.   /* Points to the insn before the jump insn.
  464.      If more code must be inserted, it goes after this insn.  */
  465.   rtx before_jump;
  466.   /* The LABEL_DECL that this jump is jumping to, or 0
  467.      for break, continue or return.  */
  468.   tree target;
  469.   /* The CODE_LABEL rtx that this is jumping to.  */
  470.   rtx target_rtl;
  471.   /* Number of binding contours started in current function
  472.      before the label reference.  */
  473.   int block_start_count;
  474.   /* The outermost stack level that should be restored for this jump.
  475.      Each time a binding contour that resets the stack is exited,
  476.      if the target label is *not* yet defined, this slot is updated.  */
  477.   rtx stack_level;
  478.   /* List of lists of cleanup expressions to be run by this goto.
  479.      There is one element for each block that this goto is within,
  480.      once there are any cleanups at all.
  481.      The TREE_VALUE contains the cleanup list of that block as of the
  482.      time this goto was seen.
  483.      The TREE_ADDRESSABLE flag is 1 for a block that has been exited.  */
  484.   tree cleanup_list_list;
  485. };
  486.  
  487. static struct goto_fixup *goto_fixup_chain;
  488.  
  489. /* Within any binding contour that must restore a stack level,
  490.    all labels are recorded with a chain of these structures.  */
  491.  
  492. struct label_chain
  493. {
  494.   /* Points to following fixup.  */
  495.   struct label_chain *next;
  496.   tree label;
  497. };
  498.  
  499. /* Specify the location in the RTL code of a label BODY,
  500.    which is a LABEL_DECL tree node.
  501.  
  502.    This is used for the kind of label that the user can jump to with a
  503.    goto statement, and for alternatives of a switch or case statement.
  504.    RTL labels generated for loops and conditionals don't go through here;
  505.    they are generated directly at the RTL level, by other functions below.
  506.  
  507.    Note that this has nothing to do with defining label *names*.
  508.    Languages vary in how they do that and what that even means.  */
  509.  
  510. void
  511. expand_label (body)
  512.      tree body;
  513. {
  514.   struct label_chain *p;
  515.  
  516.   do_pending_stack_adjust ();
  517.   emit_label (label_rtx (body));
  518.  
  519.   if (stack_block_stack != 0)
  520.     {
  521.       p = (struct label_chain *) oballoc (sizeof (struct label_chain));
  522.       p->next = stack_block_stack->data.block.label_chain;
  523.       stack_block_stack->data.block.label_chain = p;
  524.       p->label = body;
  525.     }
  526. }
  527.  
  528. /* Generate RTL code for a `goto' statement with target label BODY.
  529.    BODY should be a LABEL_DECL tree node that was or will later be
  530.    defined with `expand_label'.  */
  531.  
  532. void
  533. expand_goto (body)
  534.      tree body;
  535. {
  536.   expand_goto_internal (body, label_rtx (body), 0);
  537. }
  538.  
  539. /* Generate RTL code for a `goto' statement with target label BODY.
  540.    LABEL should be a LABEL_REF.
  541.    LAST_INSN, if non-0, is the rtx we should consider as the last
  542.    insn emitted (for the purposes of cleaning up a return).  */
  543.  
  544. static void
  545. expand_goto_internal (body, label, last_insn)
  546.      tree body;
  547.      rtx label;
  548.      rtx last_insn;
  549. {
  550.   struct nesting *block;
  551.   rtx stack_level = 0;
  552.  
  553.   if (GET_CODE (label) != CODE_LABEL)
  554.     abort ();
  555.  
  556.   /* If label has already been defined, we can tell now
  557.      whether and how we must alter the stack level.  */
  558.  
  559.   if (PREV_INSN (label) != 0)
  560.     {
  561.       /* Find the innermost pending block that contains the label.
  562.      (Check containment by comparing insn-uids.)
  563.      Then restore the outermost stack level within that block,
  564.      and do cleanups of all blocks contained in it.  */
  565.       for (block = block_stack; block; block = block->next)
  566.     {
  567.       if (INSN_UID (block->data.block.first_insn) < INSN_UID (label))
  568.         break;
  569.       if (block->data.block.stack_level != 0)
  570.         stack_level = block->data.block.stack_level;
  571.       /* Execute the cleanups for blocks we are exiting.  */
  572.       if (block->data.block.cleanups != 0)
  573.         {
  574.           expand_cleanups (block->data.block.cleanups, 0);
  575.           do_pending_stack_adjust ();
  576.         }
  577.     }
  578.  
  579.       if (stack_level)
  580.     emit_move_insn (stack_pointer_rtx, stack_level);
  581.  
  582.       if (body != 0 && TREE_PACKED (body))
  583.     error ("jump to `%s' invalidly jumps into binding contour",
  584.            IDENTIFIER_POINTER (DECL_NAME (body)));
  585.     }
  586.   /* Label not yet defined: may need to put this goto
  587.      on the fixup list.  */
  588.   else if (! expand_fixup (body, label, last_insn))
  589.     {
  590.       /* No fixup needed.  Record that the label is the target
  591.      of at least one goto that has no fixup.  */
  592.       if (body != 0)
  593.     TREE_ADDRESSABLE (body) = 1;
  594.     }
  595.  
  596.   emit_jump (label);
  597. }
  598.  
  599. /* Return truth-value of whether there are any cleanups from
  600.    the current binding contour to the end of the current function's
  601.    binding contours.  */
  602. int
  603. any_pending_cleanups ()
  604. {
  605.   struct nesting *block;
  606.  
  607.   if (block_stack->data.block.cleanups == 0
  608.       || block_stack->data.block.outer_cleanups == empty_cleanup_list)
  609.     return 0;
  610.  
  611.   for (block = block_stack->next; block; block = block->next)
  612.     if (block->data.block.cleanups != 0)
  613.       break;
  614.  
  615.   return block != 0;
  616. }
  617.  
  618. /* Generate if necessary a fixup for a goto
  619.    whose target label in tree structure (if any) is TREE_LABEL
  620.    and whose target in rtl is RTL_LABEL.
  621.  
  622.    If LAST_INSN is nonzero, we pretend that the jump appears
  623.    after insn LAST_INSN instead of at the current point in the insn stream.
  624.  
  625.    The fixup will be used later to insert insns at this point
  626.    to restore the stack level as appropriate for the target label.
  627.  
  628.    Value is nonzero if a fixup is made.  */
  629.  
  630. static int
  631. expand_fixup (tree_label, rtl_label, last_insn)
  632.      tree tree_label;
  633.      rtx rtl_label;
  634.      rtx last_insn;
  635. {
  636.   struct nesting *block, *end_block;
  637.  
  638.   /* See if we can recognize which block the label will be output in.
  639.      This is possible in some very common cases.
  640.      If we succeed, set END_BLOCK to that block.
  641.      Otherwise, set it to 0.  */
  642.  
  643.   if (cond_stack
  644.       && (rtl_label == cond_stack->data.cond.else_label
  645.       || rtl_label == cond_stack->data.cond.after_label))
  646.     end_block = cond_stack;
  647.   /* If we are in a loop, recognize certain labels which
  648.      are likely targets.  This reduces the number of fixups
  649.      we need to create.  */
  650.   else if (loop_stack
  651.       && (rtl_label == loop_stack->data.loop.start_label
  652.       || rtl_label == loop_stack->data.loop.end_label
  653.       || rtl_label == loop_stack->data.loop.continue_label))
  654.     end_block = loop_stack;
  655.   else
  656.     end_block = 0;
  657.  
  658.   /* Now set END_BLOCK to the binding level to which we will return.  */
  659.  
  660.   if (end_block)
  661.     {
  662.       struct nesting *next_block = end_block->all;
  663.       block = block_stack;
  664.  
  665.       /* First see if the END_BLOCK is inside the innermost binding level.
  666.      If so, then no cleanups or stack levels are relevant.  */
  667.       while (next_block && next_block != block)
  668.     next_block = next_block->all;
  669.  
  670.       if (next_block)
  671.     return 0;
  672.  
  673.       /* Otherwise, set END_BLOCK to the innermost binding level
  674.      which is outside the relevant control-structure nesting.  */
  675.       next_block = block_stack->next;
  676.       for (block = block_stack; block != end_block; block = block->all)
  677.     if (block == next_block)
  678.       next_block = next_block->next;
  679.       end_block = next_block;
  680.     }
  681.  
  682.   /* Does any containing block have a stack level or cleanups?
  683.      If not, no fixup is needed, and that is the normal case
  684.      (the only case, for standard C).  */
  685.   for (block = block_stack; block != end_block; block = block->next)
  686.     if (block->data.block.stack_level != 0
  687.     || block->data.block.cleanups != 0)
  688.       break;
  689.  
  690.   if (block != end_block)
  691.     {
  692.       /* Ok, a fixup is needed.  Add a fixup to the list of such.  */
  693.       struct goto_fixup *fixup
  694.     = (struct goto_fixup *) oballoc (sizeof (struct goto_fixup));
  695.       /* In case an old stack level is restored, make sure that comes
  696.      after any pending stack adjust.  */
  697.       do_pending_stack_adjust ();
  698.       fixup->before_jump = last_insn ? last_insn : get_last_insn ();
  699.       fixup->target = tree_label;
  700.       fixup->target_rtl = rtl_label;
  701.       fixup->block_start_count = block_start_count;
  702.       fixup->stack_level = 0;
  703.       fixup->cleanup_list_list
  704.     = (((block->data.block.outer_cleanups
  705.          && block->data.block.outer_cleanups != empty_cleanup_list)
  706.         || block->data.block.cleanups)
  707.        ? tree_cons (0, block->data.block.cleanups,
  708.             block->data.block.outer_cleanups)
  709.        : 0);
  710.       fixup->next = goto_fixup_chain;
  711.       goto_fixup_chain = fixup;
  712.     }
  713.  
  714.   return block != 0;
  715. }
  716.  
  717. /* When exiting a binding contour, process all pending gotos requiring fixups.
  718.    THISBLOCK is the structure that describes the block being exited.
  719.    STACK_LEVEL is the rtx for the stack level to restore exiting this contour.
  720.    CLEANUP_LIST is a list of expressions to evaluate on exiting this contour.
  721.    FIRST_INSN is the insn that began this contour.
  722.  
  723.    Gotos that jump out of this contour must restore the
  724.    stack level and do the cleanups before actually jumping.
  725.  
  726.    DONT_JUMP_IN nonzero means report error there is a jump into this
  727.    contour from before the beginning of the contour.
  728.    This is also done if STACK_LEVEL is nonzero.  */
  729.  
  730. static void
  731. fixup_gotos (thisblock, stack_level, cleanup_list, first_insn, dont_jump_in)
  732.      struct nesting *thisblock;
  733.      rtx stack_level;
  734.      tree cleanup_list;
  735.      rtx first_insn;
  736.      int dont_jump_in;
  737. {
  738.   register struct goto_fixup *f, *prev;
  739.  
  740.   /* F is the fixup we are considering; PREV is the previous one.  */
  741.  
  742.   for (prev = 0, f = goto_fixup_chain; f; prev = f, f = f->next)
  743.     {
  744.       /* Test for a fixup that is inactive because it is already handled.  */
  745.       if (f->before_jump == 0)
  746.     {
  747.       /* Delete inactive fixup from the chain, if that is easy to do.  */
  748.       if (prev != 0)
  749.         prev->next = f->next;
  750.     }
  751.       /* Has this fixup's target label been defined?
  752.      If so, we can finalize it.  */
  753.       else if (PREV_INSN (f->target_rtl) != 0)
  754.     {
  755.       /* If this fixup jumped into this contour from before the beginning
  756.          of this contour, report an error.  */
  757.       /* ??? Bug: this does not detect jumping in through intermediate
  758.          blocks that have stack levels or cleanups.
  759.          It detects only a problem with the innermost block
  760.          around the label.  */
  761.       if (f->target != 0
  762.           && (dont_jump_in || stack_level || cleanup_list)
  763.           && INSN_UID (first_insn) > INSN_UID (f->before_jump)
  764.           && ! TREE_ADDRESSABLE (f->target))
  765.         {
  766.           error_with_decl (f->target,
  767.                    "label `%s' used before containing binding contour");
  768.           /* Prevent multiple errors for one label.  */
  769.           TREE_ADDRESSABLE (f->target) = 1;
  770.         }
  771.  
  772.       /* Execute cleanups for blocks this jump exits.  */
  773.       if (f->cleanup_list_list)
  774.         {
  775.           tree lists;
  776.           for (lists = f->cleanup_list_list; lists; lists = TREE_CHAIN (lists))
  777.         /* Marked elements correspond to blocks that have been closed.
  778.            Do their cleanups.  */
  779.         if (TREE_ADDRESSABLE (lists)
  780.             && TREE_VALUE (lists) != 0)
  781.           fixup_cleanups (TREE_VALUE (lists), &f->before_jump);
  782.         }
  783.  
  784.       /* Restore stack level for the biggest contour that this
  785.          jump jumps out of.  */
  786.       if (f->stack_level)
  787.         emit_insn_after (gen_move_insn (stack_pointer_rtx, f->stack_level),
  788.                  f->before_jump);
  789.       f->before_jump = 0;
  790.     }
  791.       /* Label has still not appeared.  If we are exiting a block with
  792.      a stack level to restore, that started before the fixup,
  793.      mark this stack level as needing restoration
  794.      when the fixup is later finalized.
  795.      Also mark the cleanup_list_list element for F
  796.      that corresponds to this block, so that ultimately
  797.      this block's cleanups will be executed by the code above.  */
  798.       /* Note: if THISBLOCK == 0 and we have a label that hasn't appeared,
  799.      it means the label is undefined.  That's erroneous, but possible.  */
  800.       else if (thisblock != 0
  801.            && (thisblock->data.block.block_start_count
  802.            < f->block_start_count))
  803.     {
  804.       tree lists = f->cleanup_list_list;
  805.       for (; lists; lists = TREE_CHAIN (lists))
  806.         /* If the following elt. corresponds to our containing block
  807.            then the elt. must be for this block.  */
  808.         if (TREE_CHAIN (lists) == thisblock->data.block.outer_cleanups)
  809.           TREE_ADDRESSABLE (lists) = 1;
  810.  
  811.       if (stack_level)
  812.         f->stack_level = stack_level;
  813.     }
  814.     }
  815. }
  816.  
  817. /* Generate RTL for an asm statement (explicit assembler code).
  818.    BODY is a STRING_CST node containing the assembler code text.  */
  819.  
  820. void
  821. expand_asm (body)
  822.      tree body;
  823. {
  824.   emit_insn (gen_rtx (ASM_INPUT, VOIDmode,
  825.               TREE_STRING_POINTER (body)));
  826.   last_expr_type = 0;
  827. }
  828.  
  829. /* Generate RTL for an asm statement with arguments.
  830.    STRING is the instruction template.
  831.    OUTPUTS is a list of output arguments (lvalues); INPUTS a list of inputs.
  832.    Each output or input has an expression in the TREE_VALUE and
  833.    a constraint-string in the TREE_PURPOSE.
  834.    CLOBBERS is a list of STRING_CST nodes each naming a hard register
  835.    that is clobbered by this insn.
  836.  
  837.    Not all kinds of lvalue that may appear in OUTPUTS can be stored directly.
  838.    Some elements of OUTPUTS may be replaced with trees representing temporary
  839.    values.  The caller should copy those temporary values to the originally
  840.    specified lvalues.
  841.  
  842.    VOL nonzero means the insn is volatile; don't optimize it.  */
  843.  
  844. void
  845. expand_asm_operands (string, outputs, inputs, clobbers, vol, filename, line)
  846.      tree string, outputs, inputs, clobbers;
  847.      int vol;
  848.      char *filename;
  849.      int line;
  850. {
  851.   rtvec argvec, constraints;
  852.   rtx body;
  853.   int ninputs = list_length (inputs);
  854.   int noutputs = list_length (outputs);
  855.   int nclobbers = list_length (clobbers);
  856.   tree tail;
  857.   register int i;
  858.   /* Vector of RTX's of evaluated output operands.  */
  859.   rtx *output_rtx = (rtx *) alloca (noutputs * sizeof (rtx));
  860.   /* The insn we have emitted.  */
  861.   rtx insn;
  862.  
  863.   last_expr_type = 0;
  864.  
  865.   for (i = 0, tail = outputs; tail; tail = TREE_CHAIN (tail), i++)
  866.     {
  867.       tree val = TREE_VALUE (tail);
  868.       int j;
  869.       int found_equal;
  870.  
  871.       /* If there's an erroneous arg, emit no insn.  */
  872.       if (TREE_TYPE (val) == error_mark_node)
  873.     return;
  874.  
  875.       /* Make sure constraint has `=' and does not have `+'.  */
  876.  
  877.       found_equal = 0;
  878.       for (j = 0; j < TREE_STRING_LENGTH (TREE_PURPOSE (tail)); j++)
  879.     {
  880.       if (TREE_STRING_POINTER (TREE_PURPOSE (tail))[j] == '+')
  881.         {
  882.           error ("output operand constraint contains `+'");
  883.           return;
  884.         }
  885.       if (TREE_STRING_POINTER (TREE_PURPOSE (tail))[j] == '=')
  886.         found_equal = 1;
  887.     }
  888.       if (! found_equal)
  889.     {
  890.       error ("output operand constraint lacks `='");
  891.       return;
  892.     }
  893.  
  894.       /* If an output operand is not a variable or indirect ref,
  895.      create a SAVE_EXPR which is a pseudo-reg
  896.      to act as an intermediate temporary.
  897.      Make the asm insn write into that, then copy it to
  898.      the real output operand.  */
  899.  
  900.       if (TREE_CODE (val) != VAR_DECL
  901.       && TREE_CODE (val) != PARM_DECL
  902.       && TREE_CODE (val) != INDIRECT_REF)
  903.     {
  904.       rtx reg = gen_reg_rtx (TYPE_MODE (TREE_TYPE (val)));
  905.       /* `build' isn't safe; it really expects args to be trees.  */
  906.       tree t = build_nt (SAVE_EXPR, val, reg);
  907.  
  908.       save_expr_regs = gen_rtx (EXPR_LIST, VOIDmode, reg, save_expr_regs);
  909.       TREE_VALUE (tail) = t;
  910.       TREE_TYPE (t) = TREE_TYPE (val);
  911.     }
  912.       output_rtx[i] = expand_expr (TREE_VALUE (tail), 0, VOIDmode, 0);
  913.     }
  914.  
  915.   if (ninputs + noutputs > MAX_RECOG_OPERANDS)
  916.     {
  917.       error ("more than %d operands in `asm'", MAX_RECOG_OPERANDS);
  918.       return;
  919.     }
  920.  
  921.   /* Make vectors for the expression-rtx and constraint strings.  */
  922.  
  923.   argvec = rtvec_alloc (ninputs);
  924.   constraints = rtvec_alloc (ninputs);
  925.  
  926.   body = gen_rtx (ASM_OPERANDS, VOIDmode,
  927.           TREE_STRING_POINTER (string), "", 0, argvec, constraints,
  928.           filename, line);
  929.   MEM_VOLATILE_P (body) = vol;
  930.  
  931.   /* Eval the inputs and put them into ARGVEC.
  932.      Put their constraints into ASM_INPUTs and store in CONSTRAINTS.  */
  933.  
  934.   i = 0;
  935.   for (tail = inputs; tail; tail = TREE_CHAIN (tail))
  936.     {
  937.       int j;
  938.  
  939.       /* If there's an erroneous arg, emit no insn,
  940.      because the ASM_INPUT would get VOIDmode
  941.      and that could cause a crash in reload.  */
  942.       if (TREE_TYPE (TREE_VALUE (tail)) == error_mark_node)
  943.     return;
  944.       if (TREE_PURPOSE (tail) == NULL_TREE)
  945.     {
  946.       error ("hard register `%s' listed as input operand to `asm'",
  947.          TREE_STRING_POINTER (TREE_VALUE (tail)) );
  948.       return;
  949.     }
  950.  
  951.       /* Make sure constraint has neither `=' nor `+'.  */
  952.  
  953.       for (j = 0; j < TREE_STRING_LENGTH (TREE_PURPOSE (tail)); j++)
  954.     if (TREE_STRING_POINTER (TREE_PURPOSE (tail))[j] == '='
  955.         || TREE_STRING_POINTER (TREE_PURPOSE (tail))[j] == '+')
  956.       {
  957.         error ("input operand constraint contains `%c'",
  958.            TREE_STRING_POINTER (TREE_PURPOSE (tail))[j]);
  959.         return;
  960.       }
  961.  
  962.       XVECEXP (body, 3, i)      /* argvec */
  963.     = expand_expr (TREE_VALUE (tail), 0, VOIDmode, 0);
  964.       XVECEXP (body, 4, i)      /* constraints */
  965.     = gen_rtx (ASM_INPUT, TYPE_MODE (TREE_TYPE (TREE_VALUE (tail))),
  966.            TREE_STRING_POINTER (TREE_PURPOSE (tail)));
  967.       i++;
  968.     }
  969.  
  970.   /* Protect all the operands from the queue,
  971.      now that they have all been evaluated.  */
  972.  
  973.   for (i = 0; i < ninputs; i++)
  974.     XVECEXP (body, 3, i) = protect_from_queue (XVECEXP (body, 3, i), 0);
  975.  
  976.   for (i = 0; i < noutputs; i++)
  977.     output_rtx[i] = protect_from_queue (output_rtx[i], 1);
  978.  
  979.   /* Now, for each output, construct an rtx
  980.      (set OUTPUT (asm_operands INSN OUTPUTNUMBER OUTPUTCONSTRAINT
  981.                    ARGVEC CONSTRAINTS))
  982.      If there is more than one, put them inside a PARALLEL.  */
  983.  
  984.   if (noutputs == 1 && nclobbers == 0)
  985.     {
  986.       XSTR (body, 1) = TREE_STRING_POINTER (TREE_PURPOSE (outputs));
  987.       insn = emit_insn (gen_rtx (SET, VOIDmode, output_rtx[0], body));
  988.     }
  989.   else if (noutputs == 0 && nclobbers == 0)
  990.     {
  991.       /* No output operands: put in a raw ASM_OPERANDS rtx.  */
  992.       insn = emit_insn (body);
  993.     }
  994.   else
  995.     {
  996.       rtx obody = body;
  997.       int num = noutputs;
  998.       if (num == 0) num = 1;
  999.       body = gen_rtx (PARALLEL, VOIDmode, rtvec_alloc (num + nclobbers));
  1000.  
  1001.       /* For each output operand, store a SET.  */
  1002.  
  1003.       for (i = 0, tail = outputs; tail; tail = TREE_CHAIN (tail), i++)
  1004.     {
  1005.       XVECEXP (body, 0, i)
  1006.         = gen_rtx (SET, VOIDmode,
  1007.                output_rtx[i],
  1008.                gen_rtx (ASM_OPERANDS, VOIDmode,
  1009.                 TREE_STRING_POINTER (string),
  1010.                 TREE_STRING_POINTER (TREE_PURPOSE (tail)),
  1011.                 i, argvec, constraints,
  1012.                 filename, line));
  1013.       MEM_VOLATILE_P (SET_SRC (XVECEXP (body, 0, i))) = vol;
  1014.     }
  1015.  
  1016.       /* If there are no outputs (but there are some clobbers)
  1017.      store the bare ASM_OPERANDS into the PARALLEL.  */
  1018.  
  1019.       if (i == 0)
  1020.     XVECEXP (body, 0, i++) = obody;
  1021.  
  1022.       /* Store (clobber REG) for each clobbered register specified.  */
  1023.  
  1024.       for (tail = clobbers; tail; tail = TREE_CHAIN (tail), i++)
  1025.     {
  1026.       int j;
  1027.       char *regname = TREE_STRING_POINTER (TREE_VALUE (tail));
  1028.       extern char *reg_names[];
  1029.           
  1030.       for (j = 0; j < FIRST_PSEUDO_REGISTER; j++)
  1031.         if (!strcmp (regname, reg_names[j]))
  1032.           break;
  1033.           
  1034.       if (j == FIRST_PSEUDO_REGISTER)
  1035.         {
  1036.           error ("unknown register name `%s' in `asm'", regname);
  1037.           return;
  1038.         }
  1039.  
  1040.       /* Use QImode since that's guaranteed to clobber just one reg.  */
  1041.       XVECEXP (body, 0, i)
  1042.         = gen_rtx (CLOBBER, VOIDmode, gen_rtx (REG, QImode, j));
  1043.     }
  1044.  
  1045.       insn = emit_insn (body);
  1046.     }
  1047.  
  1048.   last_expr_type = 0;
  1049. }
  1050.  
  1051. /* Nonzero if within a ({...}) grouping, in which case we must
  1052.    always compute a value for each expr-stmt in case it is the last one.  */
  1053.  
  1054. int expr_stmts_for_value;
  1055.  
  1056. /* Generate RTL to evaluate the expression EXP
  1057.    and remember it in case this is the VALUE in a ({... VALUE; }) constr.  */
  1058.  
  1059. void
  1060. expand_expr_stmt (exp)
  1061.      tree exp;
  1062. {
  1063.   /* If -W, warn about statements with no side effects,
  1064.      except for statements explicitly casted to void (e.g. for assert()), and
  1065.      except inside a ({...}) where they may be useful.  */
  1066.   if (expr_stmts_for_value == 0 && exp != error_mark_node)
  1067.     {
  1068.       if (! TREE_VOLATILE (exp)
  1069.       && !(TREE_CODE (exp) == CONVERT_EXPR
  1070.            && TREE_TYPE (exp) == void_type_node)
  1071.       && (extra_warnings || warn_unused))
  1072.     warning_with_file_and_line (emit_filename, emit_lineno,
  1073.                     "statement with no effect");
  1074.       else if (warn_unused)
  1075.     warn_if_unused_value (exp);
  1076.     }
  1077.   last_expr_type = TREE_TYPE (exp);
  1078.   if (! flag_syntax_only)
  1079.     last_expr_value = expand_expr (exp, expr_stmts_for_value ? 0 : const0_rtx,
  1080.                    VOIDmode, 0);
  1081.   emit_queue ();
  1082. }
  1083.  
  1084. /* Warn if EXP contains any computations whose results are not used.
  1085.    Return 1 if a warning is printed; 0 otherwise.  */
  1086.  
  1087. static int
  1088. warn_if_unused_value (exp)
  1089.      tree exp;
  1090. {
  1091.   switch (TREE_CODE (exp))
  1092.     {
  1093.     case PREINCREMENT_EXPR:
  1094.     case POSTINCREMENT_EXPR:
  1095.     case PREDECREMENT_EXPR:
  1096.     case POSTDECREMENT_EXPR:
  1097.     case MODIFY_EXPR:
  1098.     case INIT_EXPR:
  1099.     case NEW_EXPR:
  1100.     case CALL_EXPR:
  1101.     case METHOD_CALL_EXPR:
  1102.     case RTL_EXPR:
  1103.     case WRAPPER_EXPR:
  1104.     case ANTI_WRAPPER_EXPR:
  1105.     case WITH_CLEANUP_EXPR:
  1106.       /* We don't warn about COND_EXPR because it may be a useful
  1107.      construct if either arm contains a side effect.  */
  1108.     case COND_EXPR:
  1109.       return 0;
  1110.  
  1111.       /* These kinds of exprs are really stmts.  What to do?  */
  1112.     case LOOP_STMT:
  1113.     case LET_STMT:
  1114.     case IF_STMT:
  1115.       return 0;
  1116.  
  1117.     case TRUTH_ORIF_EXPR:
  1118.     case TRUTH_ANDIF_EXPR:
  1119.       /* In && or ||, warn if 2nd operand has no side effect.  */
  1120.       return warn_if_unused_value (TREE_OPERAND (exp, 1));
  1121.  
  1122.     case COMPOUND_EXPR:
  1123.       if (warn_if_unused_value (TREE_OPERAND (exp, 0)))
  1124.     return 1;
  1125.       return warn_if_unused_value (TREE_OPERAND (exp, 1));
  1126.  
  1127.     case NOP_EXPR:
  1128.     case CONVERT_EXPR:
  1129.       /* Don't warn about values cast to void.  */
  1130.       if (TREE_TYPE (exp) == void_type_node)
  1131.     return 0;
  1132.       /* Assignment to a cast results in a cast of a modify.
  1133.      Don't complain about that.  */
  1134.       if (TREE_CODE (TREE_OPERAND (exp, 0)) == MODIFY_EXPR)
  1135.     return 0;
  1136.  
  1137.     default:
  1138.       warning_with_file_and_line (emit_filename, emit_lineno,
  1139.                   "value computed is not used");
  1140.       return 1;
  1141.     }
  1142. }
  1143.  
  1144. /* Clear out the memory of the last expression evaluated.  */
  1145.  
  1146. void
  1147. clear_last_expr ()
  1148. {
  1149.   last_expr_type = 0;
  1150. }
  1151.  
  1152. /* Begin a statement which will return a value.
  1153.    Return the RTL_EXPR for this statement expr.
  1154.    The caller must save that value and pass it to expand_end_stmt_expr.  */
  1155.  
  1156. tree
  1157. expand_start_stmt_expr ()
  1158. {
  1159.   rtx save = start_sequence ();
  1160.   /* Make the RTL_EXPR node temporary, not momentary,
  1161.      so that rtl_expr_chain doesn't become garbage.  */
  1162.   int momentary = suspend_momentary ();
  1163.   tree t = make_node (RTL_EXPR);
  1164.   resume_momentary (momentary);
  1165.   RTL_EXPR_RTL (t) = save;
  1166.   NO_DEFER_POP;
  1167.   expr_stmts_for_value++;
  1168.   return t;
  1169. }
  1170.  
  1171. /* Restore the previous state at the end of a statement that returns a value.
  1172.    Returns a tree node representing the statement's value and the
  1173.    insns to compute the value.
  1174.  
  1175.    The nodes of that expression have been freed by now, so we cannot use them.
  1176.    But we don't want to do that anyway; the expression has already been
  1177.    evaluated and now we just want to use the value.  So generate a RTL_EXPR
  1178.    with the proper type and RTL value.
  1179.  
  1180.    If the last substatement was not an expression,
  1181.    return something with type `void'.  */
  1182.  
  1183. tree
  1184. expand_end_stmt_expr (t)
  1185.      tree t;
  1186. {
  1187.   rtx saved = RTL_EXPR_RTL (t);
  1188.  
  1189.   OK_DEFER_POP;
  1190.  
  1191.   if (last_expr_type == 0)
  1192.     {
  1193.       last_expr_type = void_type_node;
  1194.       last_expr_value = const0_rtx;
  1195.     }
  1196.   TREE_TYPE (t) = last_expr_type;
  1197.   RTL_EXPR_RTL (t) = last_expr_value;
  1198.   RTL_EXPR_SEQUENCE (t) = get_insns ();
  1199.  
  1200.   rtl_expr_chain = tree_cons (NULL_TREE, t, rtl_expr_chain);
  1201.  
  1202.   end_sequence (saved);
  1203.  
  1204.   /* Don't consider deleting this expr or containing exprs at tree level.  */
  1205.   TREE_VOLATILE (t) = 1;
  1206.   /* Propagate volatility of the actual RTL expr.  */
  1207.   TREE_THIS_VOLATILE (t) = volatile_refs_p (last_expr_value);
  1208.  
  1209.   last_expr_type = 0;
  1210.   expr_stmts_for_value--;
  1211.  
  1212.   return t;
  1213. }
  1214.  
  1215. int
  1216. in_try_block (level)
  1217.      int level;
  1218. {
  1219.   struct nesting *n = except_stack;
  1220.   while (1)
  1221.     {
  1222.       while (n && n->data.except_stmt.after_label != 0)
  1223.     n = n->next;
  1224.       if (n == 0)
  1225.     return 0;
  1226.       if (level == 0)
  1227.     return n != 0;
  1228.       level--;
  1229.       n = n->next;
  1230.     }
  1231. }
  1232.  
  1233. int
  1234. in_except_block (level)
  1235.      int level;
  1236. {
  1237.   struct nesting *n = except_stack;
  1238.   while (1)
  1239.     {
  1240.       while (n && n->data.except_stmt.after_label == 0)
  1241.     n = n->next;
  1242.       if (n == 0)
  1243.     return 0;
  1244.       if (level == 0)
  1245.     return n != 0;
  1246.       level--;
  1247.       n = n->next;
  1248.     }
  1249. }
  1250.  
  1251. int
  1252. in_exception_handler (level)
  1253.      int level;
  1254. {
  1255.   struct nesting *n = except_stack;
  1256.   while (n && level--)
  1257.     n = n->next;
  1258.   return n != 0;
  1259. }
  1260.  
  1261. int
  1262. expand_raise (ex)
  1263.      tree ex;
  1264. {
  1265.   tree *raises_ptr;
  1266.  
  1267.   if (except_stack == 0)
  1268.     return 0;
  1269.   raises_ptr = &except_stack->data.except_stmt.raised;
  1270.   if (! value_member (ex, *raises_ptr))
  1271.     *raises_ptr = tree_cons (NULL_TREE, ex, *raises_ptr);
  1272.   return 1;
  1273. }
  1274.  
  1275. /* Generate RTL for the start of a try block.
  1276.  
  1277.    TRY_CLAUSE is the condition to test to enter the try block.  */
  1278. void
  1279. expand_start_try (try_clause, exitflag, escapeflag)
  1280.      tree try_clause;
  1281.      int exitflag;
  1282.      int escapeflag;
  1283. {
  1284.   struct nesting *thishandler
  1285.     = (struct nesting *) obstack_alloc (&stmt_obstack, sizeof (struct nesting));
  1286.  
  1287.   /* Make an entry on cond_stack for the cond we are entering.  */
  1288.  
  1289.   thishandler->next = except_stack;
  1290.   thishandler->all = nesting_stack;
  1291.   thishandler->depth = ++nesting_depth;
  1292.   thishandler->data.except_stmt.raised = 0;
  1293.   thishandler->data.except_stmt.handled = 0;
  1294.   thishandler->data.except_stmt.first_insn = get_insns ();
  1295.   thishandler->data.except_stmt.except_label = gen_label_rtx ();
  1296.   thishandler->data.except_stmt.unhandled_label = 0;
  1297.   thishandler->data.except_stmt.after_label = 0;
  1298.   thishandler->data.except_stmt.escape_label
  1299.     = escapeflag ? thishandler->data.except_stmt.except_label : 0;
  1300.   thishandler->exit_label = exitflag ? gen_label_rtx () : 0;
  1301.   except_stack = thishandler;
  1302.   nesting_stack = thishandler;
  1303.  
  1304.   do_jump (try_clause, thishandler->data.except_stmt.except_label, NULL);
  1305. }
  1306.  
  1307. /* End of a TRY block.  Nothing to do for now.  */
  1308. void
  1309. expand_end_try ()
  1310. {
  1311.   except_stack->data.except_stmt.after_label = gen_label_rtx ();
  1312.   expand_goto_internal (NULL, except_stack->data.except_stmt.after_label, 0);
  1313. }
  1314.  
  1315. void
  1316. expand_start_except (exitflag, escapeflag)
  1317.      int exitflag;
  1318.      int escapeflag;
  1319. {
  1320.   if (exitflag)
  1321.     {
  1322.       struct nesting *n;
  1323.       /* An `exit' from catch clauses goes out to next exit level,
  1324.      if there is one.  Otherwise, it just goes to the end
  1325.      of the construct.  */
  1326.       for (n = except_stack->next; n; n = n->next)
  1327.     if (n->exit_label != 0)
  1328.       {
  1329.         except_stack->exit_label = n->exit_label;
  1330.         break;
  1331.       }
  1332.       if (n == 0)
  1333.     except_stack->exit_label = except_stack->data.except_stmt.after_label;
  1334.     }
  1335.   if (escapeflag)
  1336.     {
  1337.       struct nesting *n;
  1338.       /* An `escape' from catch clauses goes out to next escape level,
  1339.      if there is one.  Otherwise, it just goes to the end
  1340.      of the construct.  */
  1341.       for (n = except_stack->next; n; n = n->next)
  1342.     if (n->data.except_stmt.escape_label != 0)
  1343.       {
  1344.         except_stack->data.except_stmt.escape_label
  1345.           = n->data.except_stmt.escape_label;
  1346.         break;
  1347.       }
  1348.       if (n == 0)
  1349.     except_stack->data.except_stmt.escape_label
  1350.       = except_stack->data.except_stmt.after_label;
  1351.     }
  1352.   do_pending_stack_adjust ();
  1353.   emit_label (except_stack->data.except_stmt.except_label);
  1354. }
  1355.  
  1356. int
  1357. expand_escape_except ()
  1358. {
  1359.   struct nesting *n;
  1360.   last_expr_type = 0;
  1361.   for (n = except_stack; n; n = n->next)
  1362.     if (n->data.except_stmt.escape_label != 0)
  1363.       {
  1364.     expand_goto_internal (0, n->data.except_stmt.escape_label, 0);
  1365.     return 1;
  1366.       }
  1367.  
  1368.   return 0;
  1369. }
  1370.  
  1371. tree
  1372. expand_end_except ()
  1373. {
  1374.   struct nesting *n;
  1375.   tree raised = NULL_TREE;
  1376.  
  1377.   do_pending_stack_adjust ();
  1378.   emit_label (except_stack->data.except_stmt.after_label);
  1379.  
  1380.   n = except_stack->next;
  1381.   if (n)
  1382.     {
  1383.       /* Propagate exceptions raised but not handled to next
  1384.      highest level.  */
  1385.       tree handled = except_stack->data.except_stmt.raised;
  1386.       if (handled != void_type_node)
  1387.     {
  1388.       tree prev = NULL_TREE;
  1389.       raised = except_stack->data.except_stmt.raised;
  1390.       while (handled)
  1391.         {
  1392.           tree this_raise;
  1393.           for (this_raise = raised, prev = 0; this_raise;
  1394.            this_raise = TREE_CHAIN (this_raise))
  1395.         {
  1396.           if (value_member (TREE_VALUE (this_raise), handled))
  1397.             {
  1398.               if (prev)
  1399.             TREE_CHAIN (prev) = TREE_CHAIN (this_raise);
  1400.               else
  1401.             {
  1402.               raised = TREE_CHAIN (raised);
  1403.               if (raised == NULL_TREE)
  1404.                 goto nada;
  1405.             }
  1406.             }
  1407.           else
  1408.             prev = this_raise;
  1409.         }
  1410.           handled = TREE_CHAIN (handled);
  1411.         }
  1412.       if (prev == NULL_TREE)
  1413.         prev = raised;
  1414.       if (prev)
  1415.         TREE_CHAIN (prev) = n->data.except_stmt.raised;
  1416.     nada:
  1417.       n->data.except_stmt.raised = raised;
  1418.     }
  1419.     }
  1420.  
  1421.   POPSTACK (except_stack);
  1422.   last_expr_type = 0;
  1423.   return raised;
  1424. }
  1425.  
  1426. int
  1427. expand_catch (ex)
  1428.      tree ex;
  1429. {
  1430.   tree *raises_ptr;
  1431.  
  1432.   if (except_stack == 0)
  1433.     return 0;
  1434.   raises_ptr = &except_stack->data.except_stmt.handled;
  1435.   if (*raises_ptr != void_type_node
  1436.       && ex != NULL_TREE
  1437.       && ! value_member (ex, *raises_ptr))
  1438.     *raises_ptr = tree_cons (NULL_TREE, ex, *raises_ptr);
  1439.   return 1;
  1440. }
  1441.  
  1442. int
  1443. expand_catch_default ()
  1444. {
  1445.   if (except_stack == 0)
  1446.     return 0;
  1447.   except_stack->data.except_stmt.handled = void_type_node;
  1448. }
  1449.  
  1450. int
  1451. expand_end_catch ()
  1452. {
  1453.   if (except_stack == 0 || except_stack->data.except_stmt.after_label == 0)
  1454.     return 0;
  1455.   expand_goto_internal (0, except_stack->data.except_stmt.after_label, 0);
  1456.   return 1;
  1457. }
  1458.  
  1459. /* Generate RTL for the start of an if-then.  COND is the expression
  1460.    whose truth should be tested.
  1461.  
  1462.    If EXITFLAG is nonzero, this conditional is visible to
  1463.    `exit_something'.  */
  1464.  
  1465. void
  1466. expand_start_cond (cond, exitflag)
  1467.      tree cond;
  1468.      int exitflag;
  1469. {
  1470.   struct nesting *thiscond
  1471.     = (struct nesting *) obstack_alloc (&stmt_obstack, sizeof (struct nesting));
  1472.  
  1473.   /* Make an entry on cond_stack for the cond we are entering.  */
  1474.  
  1475.   thiscond->next = cond_stack;
  1476.   thiscond->all = nesting_stack;
  1477.   thiscond->depth = ++nesting_depth;
  1478.   thiscond->data.cond.after_label = 0;
  1479.   thiscond->data.cond.else_label = gen_label_rtx ();
  1480.   thiscond->exit_label = exitflag ? thiscond->data.cond.else_label : 0;
  1481.   cond_stack = thiscond;
  1482.   nesting_stack = thiscond;
  1483.  
  1484.   do_jump (cond, thiscond->data.cond.else_label, NULL);
  1485. }
  1486.  
  1487. /* Generate RTL for the end of an if-then with no else-clause.
  1488.    Pop the record for it off of cond_stack.  */
  1489.  
  1490. void
  1491. expand_end_cond ()
  1492. {
  1493.   struct nesting *thiscond = cond_stack;
  1494.  
  1495.   do_pending_stack_adjust ();
  1496.   emit_label (thiscond->data.cond.else_label);
  1497.  
  1498.   POPSTACK (cond_stack);
  1499.   last_expr_type = 0;
  1500. }
  1501.  
  1502. /* Generate RTL between the then-clause and the else-clause
  1503.    of an if-then-else.  */
  1504.  
  1505. void
  1506. expand_start_else ()
  1507. {
  1508.   cond_stack->data.cond.after_label = gen_label_rtx ();
  1509.   if (cond_stack->exit_label != 0)
  1510.     cond_stack->exit_label = cond_stack->data.cond.after_label;
  1511.   emit_jump (cond_stack->data.cond.after_label);
  1512.   if (cond_stack->data.cond.else_label)
  1513.     emit_label (cond_stack->data.cond.else_label);
  1514. }
  1515.  
  1516. /* Generate RTL for the end of an if-then-else.
  1517.    Pop the record for it off of cond_stack.  */
  1518.  
  1519. void
  1520. expand_end_else ()
  1521. {
  1522.   struct nesting *thiscond = cond_stack;
  1523.  
  1524.   do_pending_stack_adjust ();
  1525.   /* Note: a syntax error can cause this to be called
  1526.      without first calling `expand_start_else'.  */
  1527.   if (thiscond->data.cond.after_label)
  1528.     emit_label (thiscond->data.cond.after_label);
  1529.  
  1530.   POPSTACK (cond_stack);
  1531.   last_expr_type = 0;
  1532. }
  1533.  
  1534. /* Generate RTL for the start of a loop.  EXIT_FLAG is nonzero if this
  1535.    loop should be exited by `exit_something'.  This is a loop for which
  1536.    `expand_continue' will jump to the top of the loop.
  1537.  
  1538.    Make an entry on loop_stack to record the labels associated with
  1539.    this loop.  */
  1540.  
  1541. void
  1542. expand_start_loop (exit_flag)
  1543.      int exit_flag;
  1544. {
  1545.   register struct nesting *thisloop
  1546.     = (struct nesting *) obstack_alloc (&stmt_obstack, sizeof (struct nesting));
  1547.  
  1548.   /* Make an entry on loop_stack for the loop we are entering.  */
  1549.  
  1550.   thisloop->next = loop_stack;
  1551.   thisloop->all = nesting_stack;
  1552.   thisloop->depth = ++nesting_depth;
  1553.   thisloop->data.loop.start_label = gen_label_rtx ();
  1554.   thisloop->data.loop.end_label = gen_label_rtx ();
  1555.   thisloop->data.loop.continue_label = thisloop->data.loop.start_label;
  1556.   thisloop->exit_label = exit_flag ? thisloop->data.loop.end_label : 0;
  1557.   loop_stack = thisloop;
  1558.   nesting_stack = thisloop;
  1559.  
  1560.   do_pending_stack_adjust ();
  1561.   emit_queue ();
  1562.   emit_note (0, NOTE_INSN_LOOP_BEG);
  1563.   emit_label (thisloop->data.loop.start_label);
  1564. }
  1565.  
  1566. /* Like expand_start_loop but for a loop where the continuation point
  1567.    (for expand_continue_loop) will be specified explicitly.  */
  1568.  
  1569. void
  1570. expand_start_loop_continue_elsewhere (exit_flag)
  1571.      int exit_flag;
  1572. {
  1573.   expand_start_loop (exit_flag);
  1574.   loop_stack->data.loop.continue_label = gen_label_rtx ();
  1575. }
  1576.  
  1577. /* Specify the continuation point for a loop started with
  1578.    expand_start_loop_continue_elsewhere.
  1579.    Use this at the point in the code to which a continue statement
  1580.    should jump.  */
  1581.  
  1582. void
  1583. expand_loop_continue_here ()
  1584. {
  1585.   do_pending_stack_adjust ();
  1586.   emit_note (0, NOTE_INSN_LOOP_CONT);
  1587.   emit_label (loop_stack->data.loop.continue_label);
  1588. }
  1589.  
  1590. /* Finish a loop.  Generate a jump back to the top and the loop-exit label.
  1591.    Pop the block off of loop_stack.  */
  1592.  
  1593. void
  1594. expand_end_loop ()
  1595. {
  1596.   register rtx insn = get_last_insn ();
  1597.   register rtx start_label = loop_stack->data.loop.start_label;
  1598.  
  1599.   do_pending_stack_adjust ();
  1600.  
  1601.   /* If optimizing, perhaps reorder the loop.  If the loop
  1602.      starts with a conditional exit, roll that to the end
  1603.      where it will optimize together with the jump back.  */
  1604.   if (optimize
  1605.       &&
  1606.       ! (GET_CODE (insn) == JUMP_INSN
  1607.      && GET_CODE (PATTERN (insn)) == SET
  1608.      && SET_DEST (PATTERN (insn)) == pc_rtx
  1609.      && GET_CODE (SET_SRC (PATTERN (insn))) == IF_THEN_ELSE))
  1610.     {
  1611.       /* Scan insns from the top of the loop looking for a qualified
  1612.      conditional exit.  */
  1613.       for (insn = loop_stack->data.loop.start_label; insn; insn= NEXT_INSN (insn))
  1614.     if (GET_CODE (insn) == JUMP_INSN && GET_CODE (PATTERN (insn)) == SET
  1615.         && SET_DEST (PATTERN (insn)) == pc_rtx
  1616.         && GET_CODE (SET_SRC (PATTERN (insn))) == IF_THEN_ELSE
  1617.         &&
  1618.         ((GET_CODE (XEXP (SET_SRC (PATTERN (insn)), 1)) == LABEL_REF
  1619.           && (XEXP (XEXP (SET_SRC (PATTERN (insn)), 1), 0)
  1620.           == loop_stack->data.loop.end_label))
  1621.          ||
  1622.          (GET_CODE (XEXP (SET_SRC (PATTERN (insn)), 2)) == LABEL_REF
  1623.           && (XEXP (XEXP (SET_SRC (PATTERN (insn)), 2), 0)
  1624.           == loop_stack->data.loop.end_label))))
  1625.       break;
  1626.       if (insn != 0)
  1627.     {
  1628.       /* We found one.  Move everything from there up
  1629.          to the end of the loop, and add a jump into the loop
  1630.          to jump to there.  */
  1631.       register rtx newstart_label = gen_label_rtx ();
  1632.  
  1633.       emit_label_after (newstart_label, PREV_INSN (start_label));
  1634.       reorder_insns (start_label, insn, get_last_insn ());
  1635.       emit_jump_insn_after (gen_jump (start_label), PREV_INSN (newstart_label));
  1636.       emit_barrier_after (PREV_INSN (newstart_label));
  1637.       start_label = newstart_label;
  1638.     }
  1639.     }
  1640.  
  1641.   emit_jump (start_label);
  1642.   emit_note (0, NOTE_INSN_LOOP_END);
  1643.   emit_label (loop_stack->data.loop.end_label);
  1644.  
  1645.   POPSTACK (loop_stack);
  1646.  
  1647.   last_expr_type = 0;
  1648. }
  1649.  
  1650. /* Generate a jump to the current loop's continue-point.
  1651.    This is usually the top of the loop, but may be specified
  1652.    explicitly elsewhere.  If not currently inside a loop,
  1653.    return 0 and do nothing; caller will print an error message.  */
  1654.  
  1655. int
  1656. expand_continue_loop ()
  1657. {
  1658.   last_expr_type = 0;
  1659.   if (loop_stack == 0)
  1660.     return 0;
  1661.   expand_goto_internal (0, loop_stack->data.loop.continue_label, 0);
  1662.   return 1;
  1663. }
  1664.  
  1665. /* Generate a jump to exit the current loop.  If not currently inside a loop,
  1666.    return 0 and do nothing; caller will print an error message.  */
  1667.  
  1668. int
  1669. expand_exit_loop ()
  1670. {
  1671.   last_expr_type = 0;
  1672.   if (loop_stack == 0)
  1673.     return 0;
  1674.   expand_goto_internal (0, loop_stack->data.loop.end_label, 0);
  1675.   return 1;
  1676. }
  1677.  
  1678. /* Generate a conditional jump to exit the current loop if COND
  1679.    evaluates to zero.  If not currently inside a loop,
  1680.    return 0 and do nothing; caller will print an error message.  */
  1681.  
  1682. int
  1683. expand_exit_loop_if_false (cond)
  1684.      tree cond;
  1685. {
  1686.   last_expr_type = 0;
  1687.   if (loop_stack == 0)
  1688.     return 0;
  1689.   do_jump (cond, loop_stack->data.loop.end_label, NULL);
  1690.   return 1;
  1691. }
  1692.  
  1693. /* Return non-zero if currently inside a loop.  */
  1694.  
  1695. int
  1696. inside_loop ()
  1697. {
  1698.   return loop_stack != 0;
  1699. }
  1700.  
  1701. /* Generate a jump to exit the current loop, conditional, binding contour
  1702.    or case statement.  Not all such constructs are visible to this function,
  1703.    only those started with EXIT_FLAG nonzero.  Individual languages use
  1704.    the EXIT_FLAG parameter to control which kinds of constructs you can
  1705.    exit this way.
  1706.  
  1707.    If not currently inside anything that can be exited,
  1708.    return 0 and do nothing; caller will print an error message.  */
  1709.  
  1710. int
  1711. expand_exit_something ()
  1712. {
  1713.   struct nesting *n;
  1714.   last_expr_type = 0;
  1715.   for (n = nesting_stack; n; n = n->all)
  1716.     if (n->exit_label != 0)
  1717.       {
  1718.     expand_goto_internal (0, n->exit_label, 0);
  1719.     return 1;
  1720.       }
  1721.  
  1722.   return 0;
  1723. }
  1724.  
  1725. /* Generate RTL to return from the current function, with no value.
  1726.    (That is, we do not do anything about returning any value.)  */
  1727.  
  1728. void
  1729. expand_null_return ()
  1730. {
  1731.   struct nesting *block = block_stack;
  1732.   rtx last_insn = 0;
  1733.  
  1734.   /* Does any pending block have cleanups?  */
  1735.  
  1736.   while (block && block->data.block.cleanups == 0)
  1737.     block = block->next;
  1738.  
  1739.   /* If yes, use a goto to return, since that runs cleanups.  */
  1740.  
  1741.   expand_null_return_1 (last_insn, block != 0);
  1742. }
  1743.  
  1744. /* Output a return with no value.  If LAST_INSN is nonzero,
  1745.    pretend that the return takes place after LAST_INSN.
  1746.    If USE_GOTO is nonzero then don't use a return instruction;
  1747.    go to the return label instead.  This causes any cleanups
  1748.    of pending blocks to be executed normally.  */
  1749.  
  1750. static void
  1751. expand_null_return_1 (last_insn, use_goto)
  1752.      rtx last_insn;
  1753.      int use_goto;
  1754. {
  1755.   rtx end_label = cleanup_label ? cleanup_label : return_label;
  1756.  
  1757.   clear_pending_stack_adjust ();
  1758.   do_pending_stack_adjust ();
  1759.   last_expr_type = 0;
  1760.  
  1761.   /* PCC-struct return always uses an epilogue.  */
  1762.   if (current_function_returns_pcc_struct || use_goto)
  1763.     {
  1764.       if (end_label == 0)
  1765.     end_label = return_label = gen_label_rtx ();
  1766.       expand_goto_internal (0, end_label, last_insn);
  1767.       return;
  1768.     }
  1769.  
  1770.   /* Otherwise output a simple return-insn if one is available,
  1771.      unless it won't do the job.  */
  1772. #ifdef HAVE_return
  1773.   if (HAVE_return && cleanup_label == 0)
  1774.     {
  1775.       emit_jump_insn (gen_return ());
  1776.       emit_barrier ();
  1777.       return;
  1778.     }
  1779. #endif
  1780.  
  1781.   /* Otherwise jump to the epilogue.  */
  1782.   expand_goto_internal (0, end_label, last_insn);
  1783. }
  1784.  
  1785. /* Generate RTL to evaluate the expression RETVAL and return it
  1786.    from the current function.  */
  1787.  
  1788. void
  1789. expand_return (retval)
  1790.      tree retval;
  1791. {
  1792.   /* If there are any cleanups to be performed, then they will
  1793.      be inserted following LAST_INSN.  It is desirable
  1794.      that the last_insn, for such purposes, should be the
  1795.      last insn before computing the return value.  Otherwise, cleanups
  1796.      which call functions can clobber the return value.  */
  1797.   /* ??? rms: I think that is erroneous, because in C++ it would
  1798.      run destructors on variables that might be used in the subsequent
  1799.      computation of the return value.  */
  1800.   rtx last_insn = 0;
  1801.   register rtx val = 0;
  1802.   register rtx op0;
  1803.   tree retval_rhs;
  1804.   int cleanups;
  1805.   struct nesting *block;
  1806.  
  1807.   /* Are any cleanups needed?  E.g. C++ destructors to be run?  */
  1808.   cleanups = 0;
  1809.   for (block = block_stack; block; block = block->next)
  1810.     if (block->data.block.cleanups != 0)
  1811.       {
  1812.     cleanups = 1;
  1813.     break;
  1814.       }
  1815.  
  1816.   if (TREE_CODE (retval) == RESULT_DECL)
  1817.     retval_rhs = retval;
  1818.   else if ((TREE_CODE (retval) == MODIFY_EXPR || TREE_CODE (retval) == INIT_EXPR)
  1819.        && TREE_CODE (TREE_OPERAND (retval, 0)) == RESULT_DECL)
  1820.     retval_rhs = TREE_OPERAND (retval, 1);
  1821.   else if (TREE_TYPE (retval) == void_type_node)
  1822.     /* Recognize tail-recursive call to void function.  */
  1823.     retval_rhs = retval;
  1824.   else
  1825.     retval_rhs = NULL_TREE;
  1826.  
  1827.   /* Only use `last_insn' if there are cleanups which must be run.  */
  1828.   if (cleanups || cleanup_label != 0)
  1829.     last_insn = get_last_insn ();
  1830.  
  1831.   /* For tail-recursive call to current function,
  1832.      just jump back to the beginning.
  1833.      It's unsafe if any auto variable in this function
  1834.      has its address taken; for simplicity,
  1835.      require stack frame to be empty.  */
  1836.   if (optimize && retval_rhs != 0
  1837.       && frame_offset == STARTING_FRAME_OFFSET
  1838.       && TREE_CODE (retval_rhs) == CALL_EXPR
  1839.       && TREE_CODE (TREE_OPERAND (retval_rhs, 0)) == ADDR_EXPR
  1840.       && TREE_OPERAND (TREE_OPERAND (retval_rhs, 0), 0) == this_function
  1841.       /* Finish checking validity, and if valid emit code
  1842.      to set the argument variables for the new call.  */
  1843.       && tail_recursion_args (TREE_OPERAND (retval_rhs, 1),
  1844.                   DECL_ARGUMENTS (this_function)))
  1845.     {
  1846.       if (tail_recursion_label == 0)
  1847.     {
  1848.       tail_recursion_label = gen_label_rtx ();
  1849.       emit_label_after (tail_recursion_label,
  1850.                 tail_recursion_reentry);
  1851.     }
  1852.       expand_goto_internal (0, tail_recursion_label, last_insn);
  1853.       emit_barrier ();
  1854.       return;
  1855.     }
  1856. #ifdef HAVE_return
  1857.   /* This optimization is safe if there are local cleanups
  1858.      because expand_null_return takes care of them.
  1859.      ??? I think it should also be safe when there is a cleanup label,
  1860.      because expand_null_return takes care of them, too.
  1861.      Any reason why not?  */
  1862.   if (HAVE_return && cleanup_label == 0
  1863.       && ! current_function_returns_pcc_struct)
  1864.     {
  1865.       /* If this is  return x == y;  then generate
  1866.      if (x == y) return 1; else return 0;
  1867.      if we can do it with explicit return insns.  */
  1868.       if (retval_rhs)
  1869.     switch (TREE_CODE (retval_rhs))
  1870.       {
  1871.       case EQ_EXPR:
  1872.       case NE_EXPR:
  1873.       case GT_EXPR:
  1874.       case GE_EXPR:
  1875.       case LT_EXPR:
  1876.       case LE_EXPR:
  1877.       case TRUTH_ANDIF_EXPR:
  1878.       case TRUTH_ORIF_EXPR:
  1879.       case TRUTH_AND_EXPR:
  1880.       case TRUTH_OR_EXPR:
  1881.       case TRUTH_NOT_EXPR:
  1882.         op0 = gen_label_rtx ();
  1883.         val = DECL_RTL (DECL_RESULT (this_function));
  1884.         jumpifnot (retval_rhs, op0);
  1885.         emit_move_insn (val, const1_rtx);
  1886.         emit_insn (gen_rtx (USE, VOIDmode, val));
  1887.         expand_null_return ();
  1888.         emit_label (op0);
  1889.         emit_move_insn (val, const0_rtx);
  1890.         emit_insn (gen_rtx (USE, VOIDmode, val));
  1891.         expand_null_return ();
  1892.         return;
  1893.       }
  1894.     }
  1895. #endif /* HAVE_return */
  1896.  
  1897.   if (cleanups
  1898.       && retval_rhs != 0
  1899.       && TREE_TYPE (retval_rhs) != void_type_node
  1900.       && GET_CODE (DECL_RTL (DECL_RESULT (this_function))) == REG)
  1901.     {
  1902.       rtx last_insn;
  1903.       /* Calculate the return value into a pseudo reg.  */
  1904.       val = expand_expr (retval_rhs, 0, VOIDmode, 0);
  1905.       emit_queue ();
  1906.       /* Put the cleanups here.  */
  1907.       last_insn = get_last_insn ();
  1908.       /* Copy the value into hard return reg.  */
  1909.       emit_move_insn (DECL_RTL (DECL_RESULT (this_function)), val);
  1910.       val = DECL_RTL (DECL_RESULT (this_function));
  1911.  
  1912.       if (GET_CODE (val) == REG)
  1913.     emit_insn (gen_rtx (USE, VOIDmode, val));
  1914.       expand_null_return_1 (last_insn, cleanups);
  1915.     }
  1916.   else
  1917.     {
  1918.       /* No cleanups or no hard reg used;
  1919.      calculate value into hard return reg
  1920.      and let cleanups come after.  */
  1921.       val = expand_expr (retval, 0, VOIDmode, 0);
  1922.       emit_queue ();
  1923.  
  1924.       val = DECL_RTL (DECL_RESULT (this_function));
  1925.       if (val && GET_CODE (val) == REG)
  1926.     emit_insn (gen_rtx (USE, VOIDmode, val));
  1927.       expand_null_return ();
  1928.     }
  1929. }
  1930.  
  1931. /* Return 1 if the end of the generated RTX is not a barrier.
  1932.    This means code already compiled can drop through.  */
  1933.  
  1934. int
  1935. drop_through_at_end_p ()
  1936. {
  1937.   rtx insn = get_last_insn ();
  1938.   while (insn && GET_CODE (insn) == NOTE)
  1939.     insn = PREV_INSN (insn);
  1940.   return insn && GET_CODE (insn) != BARRIER;
  1941. }
  1942.  
  1943. /* Emit code to alter this function's formal parms for a tail-recursive call.
  1944.    ACTUALS is a list of actual parameter expressions (chain of TREE_LISTs).
  1945.    FORMALS is the chain of decls of formals.
  1946.    Return 1 if this can be done;
  1947.    otherwise return 0 and do not emit any code.  */
  1948.  
  1949. static int
  1950. tail_recursion_args (actuals, formals)
  1951.      tree actuals, formals;
  1952. {
  1953.   register tree a = actuals, f = formals;
  1954.   register int i;
  1955.   register rtx *argvec;
  1956.  
  1957.   /* Check that number and types of actuals are compatible
  1958.      with the formals.  This is not always true in valid C code.
  1959.      Also check that no formal needs to be addressable
  1960.      and that all formals are scalars.  */
  1961.  
  1962.   /* Also count the args.  */
  1963.  
  1964.   for (a = actuals, f = formals, i = 0; a && f; a = TREE_CHAIN (a), f = TREE_CHAIN (f), i++)
  1965.     {
  1966.       if (TREE_TYPE (TREE_VALUE (a)) != TREE_TYPE (f))
  1967.     return 0;
  1968.       if (GET_CODE (DECL_RTL (f)) != REG || DECL_MODE (f) == BLKmode)
  1969.     return 0;
  1970.     }
  1971.   if (a != 0 || f != 0)
  1972.     return 0;
  1973.  
  1974.   /* Compute all the actuals.  */
  1975.  
  1976.   argvec = (rtx *) alloca (i * sizeof (rtx));
  1977.  
  1978.   for (a = actuals, i = 0; a; a = TREE_CHAIN (a), i++)
  1979.     argvec[i] = expand_expr (TREE_VALUE (a), 0, VOIDmode, 0);
  1980.  
  1981.   /* Find which actual values refer to current values of previous formals.
  1982.      Copy each of them now, before any formal is changed.  */
  1983.  
  1984.   for (a = actuals, i = 0; a; a = TREE_CHAIN (a), i++)
  1985.     {
  1986.       int copy = 0;
  1987.       register int j;
  1988.       for (f = formals, j = 0; j < i; f = TREE_CHAIN (f), j++)
  1989.     if (reg_mentioned_p (DECL_RTL (f), argvec[i]))
  1990.       { copy = 1; break; }
  1991.       if (copy)
  1992.     argvec[i] = copy_to_reg (argvec[i]);
  1993.     }
  1994.  
  1995.   /* Store the values of the actuals into the formals.  */
  1996.  
  1997.   for (f = formals, a = actuals, i = 0; f;
  1998.        f = TREE_CHAIN (f), a = TREE_CHAIN (a), i++)
  1999.     {
  2000.       if (DECL_MODE (f) == GET_MODE (argvec[i]))
  2001.     emit_move_insn (DECL_RTL (f), argvec[i]);
  2002.       else
  2003.     convert_move (DECL_RTL (f), argvec[i],
  2004.               TREE_UNSIGNED (TREE_TYPE (TREE_VALUE (a))));
  2005.     }
  2006.  
  2007.   return 1;
  2008. }
  2009.  
  2010. /* Generate the RTL code for entering a binding contour.
  2011.    The variables are declared one by one, by calls to `expand_decl'.
  2012.  
  2013.    EXIT_FLAG is nonzero if this construct should be visible to
  2014.    `exit_something'.  */
  2015.  
  2016. void
  2017. expand_start_bindings (exit_flag)
  2018.      int exit_flag;
  2019. {
  2020.   struct nesting *thisblock
  2021.     = (struct nesting *) obstack_alloc (&stmt_obstack, sizeof (struct nesting));
  2022.  
  2023.   rtx note = emit_note (0, NOTE_INSN_BLOCK_BEG);
  2024.  
  2025.   /* Make an entry on block_stack for the block we are entering.  */
  2026.  
  2027.   thisblock->next = block_stack;
  2028.   thisblock->all = nesting_stack;
  2029.   thisblock->depth = ++nesting_depth;
  2030.   thisblock->data.block.stack_level = 0;
  2031.   thisblock->data.block.cleanups = 0;
  2032.   /* We build this even if the cleanups lists are empty
  2033.      because we rely on having an element in the chain
  2034.      for each block that is pending.  */
  2035.   if (block_stack)
  2036.     {
  2037.       if (block_stack->data.block.cleanups == NULL_TREE
  2038.       && (block_stack->data.block.outer_cleanups == NULL_TREE
  2039.           || block_stack->data.block.outer_cleanups == empty_cleanup_list))
  2040.     thisblock->data.block.outer_cleanups = empty_cleanup_list;
  2041.       else
  2042.     thisblock->data.block.outer_cleanups
  2043.       = tree_cons (NULL_TREE, block_stack->data.block.cleanups,
  2044.                block_stack->data.block.outer_cleanups);
  2045.     }
  2046.   else
  2047.     thisblock->data.block.outer_cleanups = 0;
  2048.   thisblock->data.block.label_chain = 0;
  2049.   thisblock->data.block.innermost_stack_block = stack_block_stack;
  2050.   thisblock->data.block.first_insn = note;
  2051.   thisblock->data.block.block_start_count = ++block_start_count;
  2052.   thisblock->exit_label = exit_flag ? gen_label_rtx () : 0;
  2053.   block_stack = thisblock;
  2054.   nesting_stack = thisblock;
  2055. }
  2056.  
  2057. /* Output a USE for any register use in RTL.
  2058.    This is used with -noreg to mark the extent of lifespan
  2059.    of any registers used in a user-visible variable's DECL_RTL.  */
  2060.  
  2061. void
  2062. use_variable (rtl)
  2063.      rtx rtl;
  2064. {
  2065.   if (GET_CODE (rtl) == REG)
  2066.     /* This is a register variable.  */
  2067.     emit_insn (gen_rtx (USE, VOIDmode, rtl));
  2068.   else if (GET_CODE (rtl) == MEM
  2069.        && GET_CODE (XEXP (rtl, 0)) == REG
  2070.        && XEXP (rtl, 0) != frame_pointer_rtx
  2071.        && XEXP (rtl, 0) != arg_pointer_rtx)
  2072.     /* This is a variable-sized structure.  */
  2073.     emit_insn (gen_rtx (USE, VOIDmode, XEXP (rtl, 0)));
  2074. }
  2075.  
  2076. /* Like use_variable except that it outputs the USEs after INSN
  2077.    instead of at the end of the insn-chain.  */
  2078.  
  2079. static void
  2080. use_variable_after (rtl, insn)
  2081.      rtx rtl, insn;
  2082. {
  2083.   if (GET_CODE (rtl) == REG)
  2084.     /* This is a register variable.  */
  2085.     emit_insn_after (gen_rtx (USE, VOIDmode, rtl), insn);
  2086.   else if (GET_CODE (rtl) == MEM
  2087.        && GET_CODE (XEXP (rtl, 0)) == REG
  2088.        && XEXP (rtl, 0) != frame_pointer_rtx
  2089.        && XEXP (rtl, 0) != arg_pointer_rtx)
  2090.     /* This is a variable-sized structure.  */
  2091.     emit_insn_after (gen_rtx (USE, VOIDmode, XEXP (rtl, 0)), insn);
  2092. }
  2093.  
  2094. /* Generate RTL code to terminate a binding contour.
  2095.    VARS is the chain of VAR_DECL nodes
  2096.    for the variables bound in this contour.
  2097.    MARK_ENDS is nonzero if we should put a note at the beginning
  2098.    and end of this binding contour.
  2099.  
  2100.    DONT_JUMP_IN is nonzero if it is not valid to jump into this contour.
  2101.    (That is true automatically if the contour has a saved stack level.)  */
  2102.  
  2103. void
  2104. expand_end_bindings (vars, mark_ends, dont_jump_in)
  2105.      tree vars;
  2106.      int mark_ends;
  2107.      int dont_jump_in;
  2108. {
  2109.   register struct nesting *thisblock = block_stack;
  2110.   register tree decl;
  2111.  
  2112.   if (warn_unused)
  2113.     for (decl = vars; decl; decl = TREE_CHAIN (decl))
  2114.       if (! TREE_USED (decl) && TREE_CODE (decl) == VAR_DECL)
  2115.     warning_with_decl (decl, "unused variable `%s'");
  2116.  
  2117.   /* Mark the beginning and end of the scope if requested.  */
  2118.  
  2119.   if (mark_ends)
  2120.     emit_note (0, NOTE_INSN_BLOCK_END);
  2121.   else
  2122.     /* Get rid of the beginning-mark if we don't make an end-mark.  */
  2123.     NOTE_LINE_NUMBER (thisblock->data.block.first_insn) = NOTE_INSN_DELETED;
  2124.  
  2125.   if (thisblock->exit_label)
  2126.     {
  2127.       do_pending_stack_adjust ();
  2128.       emit_label (thisblock->exit_label);
  2129.     }
  2130.  
  2131.   if (dont_jump_in
  2132.       || thisblock->data.block.stack_level != 0
  2133.       || thisblock->data.block.cleanups != 0)
  2134.     {
  2135.       struct label_chain *chain;
  2136.  
  2137.       /* Any labels in this block are no longer valid to go to.
  2138.      Mark them to cause an error message.  */
  2139.       for (chain = thisblock->data.block.label_chain; chain; chain = chain->next)
  2140.     {
  2141.       TREE_PACKED (chain->label) = 1;
  2142.       /* If any goto without a fixup came to this label,
  2143.          that must be an error, because gotos without fixups
  2144.          come from outside all saved stack-levels and all cleanups.  */
  2145.       if (TREE_ADDRESSABLE (chain->label))
  2146.         error_with_decl (chain->label,
  2147.                  "label `%s' used before containing binding contour");
  2148.     }
  2149.     }
  2150.  
  2151.   /* Restore stack level in effect before the block
  2152.      (only if variable-size objects allocated).  */
  2153.  
  2154.   if (thisblock->data.block.stack_level != 0
  2155.       || thisblock->data.block.cleanups != 0)
  2156.     {
  2157.       /* Perform any cleanups associated with the block.  */
  2158.       int old_expr_stmts_for_value = expr_stmts_for_value;
  2159.       rtx old_last_expr_value = last_expr_value;
  2160.       tree old_last_expr_type = last_expr_type;
  2161.  
  2162.       /* Don't let cleanups affect ({...}) constructs.  */
  2163.       expr_stmts_for_value = 0;
  2164.       expand_cleanups (thisblock->data.block.cleanups, 0);
  2165.       do_pending_stack_adjust ();
  2166.       expr_stmts_for_value = old_expr_stmts_for_value;
  2167.       last_expr_value = old_last_expr_value;
  2168.       last_expr_type = old_last_expr_type;
  2169.  
  2170.       /* Restore the stack level.  */
  2171.  
  2172.       if (thisblock->data.block.stack_level != 0)
  2173.     emit_move_insn (stack_pointer_rtx,
  2174.             thisblock->data.block.stack_level);
  2175.  
  2176.       /* Any gotos out of this block must also do these things.
  2177.      Also report any gotos with fixups that came to labels in this level.  */
  2178.       fixup_gotos (thisblock,
  2179.            thisblock->data.block.stack_level,
  2180.            thisblock->data.block.cleanups,
  2181.            thisblock->data.block.first_insn,
  2182.            dont_jump_in);
  2183.     }
  2184.  
  2185.   /* If doing stupid register allocation, make sure lives of all
  2186.      register variables declared here extend thru end of scope.  */
  2187.  
  2188.   if (obey_regdecls)
  2189.     for (decl = vars; decl; decl = TREE_CHAIN (decl))
  2190.       {
  2191.     rtx rtl = DECL_RTL (decl);
  2192.     if (TREE_CODE (decl) == VAR_DECL && rtl != 0)
  2193.       use_variable (rtl);
  2194.       }
  2195.  
  2196.   /* Restore block_stack level for containing block.  */
  2197.  
  2198.   stack_block_stack = thisblock->data.block.innermost_stack_block;
  2199.   POPSTACK (block_stack);
  2200. }
  2201.  
  2202. /* Generate RTL for the automatic variable declaration DECL.
  2203.    (Other kinds of declarations are simply ignored if seen here.)
  2204.    There is no special support here for C++ constructors.
  2205.    They should be handled by the proper code in DECL_INITIAL.  */
  2206.  
  2207. void
  2208. expand_decl (decl)
  2209.      register tree decl;
  2210. {
  2211.   struct nesting *thisblock = block_stack;
  2212.   tree type = TREE_TYPE (decl);
  2213.  
  2214.   /* Only automatic variables need any expansion done.
  2215.      Static and external variables, and external functions,
  2216.      will be handled by `assemble_variable' (called from finish_decl).
  2217.      TYPE_DECL and CONST_DECL require nothing.
  2218.      PARM_DECLs are handled in `assign_parms'.  */
  2219.  
  2220.   if (TREE_CODE (decl) != VAR_DECL)
  2221.     return;
  2222.   if (TREE_STATIC (decl) || TREE_EXTERNAL (decl))
  2223.     return;
  2224.  
  2225.   /* Create the RTL representation for the variable.  */
  2226.  
  2227.   if (type == error_mark_node)
  2228.     DECL_RTL (decl) = gen_rtx (MEM, BLKmode, const0_rtx);
  2229.   else if (DECL_SIZE (decl) == 0)
  2230.     /* Variable with incomplete type.  */
  2231.     {
  2232.       if (DECL_INITIAL (decl) == 0)
  2233.     /* Error message was already done; now avoid a crash.  */
  2234.     DECL_RTL (decl) = assign_stack_local (DECL_MODE (decl), 0);
  2235.       else
  2236.     /* An initializer is going to decide the size of this array.
  2237.        Until we know the size, represent its address with a reg.  */
  2238.     DECL_RTL (decl) = gen_rtx (MEM, BLKmode, gen_reg_rtx (Pmode));
  2239.     }
  2240.   else if (DECL_MODE (decl) != BLKmode
  2241.        /* If -ffloat-store, don't put explicit float vars
  2242.           into regs.  */
  2243.        && !(flag_float_store
  2244.         && TREE_CODE (type) == REAL_TYPE)
  2245.        && ! TREE_VOLATILE (decl)
  2246.        && ! TREE_ADDRESSABLE (decl)
  2247.        && (TREE_REGDECL (decl) || ! obey_regdecls))
  2248.     {
  2249.       /* Automatic variable that can go in a register.  */
  2250.       DECL_RTL (decl) = gen_reg_rtx (DECL_MODE (decl));
  2251.       if (TREE_CODE (type) == POINTER_TYPE)
  2252.     mark_reg_pointer (DECL_RTL (decl));
  2253.       REG_USERVAR_P (DECL_RTL (decl)) = 1;
  2254.     }
  2255.   else if (TREE_LITERAL (DECL_SIZE (decl)))
  2256.     {
  2257.       rtx oldaddr = 0;
  2258.       rtx addr;
  2259.  
  2260.       /* If we previously made RTL for this decl, it must be an array
  2261.      whose size was determined by the initializer.
  2262.      The old address was a register; set that register now
  2263.      to the proper address.  */
  2264.       if (DECL_RTL (decl) != 0)
  2265.     {
  2266.       if (GET_CODE (DECL_RTL (decl)) != MEM
  2267.           || GET_CODE (XEXP (DECL_RTL (decl), 0)) != REG)
  2268.         abort ();
  2269.       oldaddr = XEXP (DECL_RTL (decl), 0);
  2270.     }
  2271.  
  2272.       /* Variable of fixed size that goes on the stack.  */
  2273.       DECL_RTL (decl)
  2274.     = assign_stack_local (DECL_MODE (decl),
  2275.                   (TREE_INT_CST_LOW (DECL_SIZE (decl))
  2276.                    * DECL_SIZE_UNIT (decl)
  2277.                    + BITS_PER_UNIT - 1)
  2278.                   / BITS_PER_UNIT);
  2279.       if (oldaddr)
  2280.     {
  2281.       addr = force_operand (XEXP (DECL_RTL (decl), 0), oldaddr);
  2282.       emit_move_insn (oldaddr, addr);
  2283.     }
  2284.  
  2285.       /* If this is a memory ref that contains aggregate components,
  2286.      mark it as such for cse and loop optimize.  */
  2287.       MEM_IN_STRUCT_P (DECL_RTL (decl))
  2288.     = (TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE
  2289.        || TREE_CODE (TREE_TYPE (decl)) == RECORD_TYPE
  2290.        || TREE_CODE (TREE_TYPE (decl)) == UNION_TYPE);
  2291. #if 0
  2292.       /* If this is in memory because of -ffloat-store,
  2293.      set the volatile bit, to prevent optimizations from
  2294.      undoing the effects.  */
  2295.       if (flag_float_store && TREE_CODE (type) == REAL_TYPE)
  2296.     MEM_VOLATILE_P (DECL_RTL (decl)) = 1;
  2297. #endif
  2298.     }
  2299.   else
  2300.     /* Dynamic-size object: must push space on the stack.  */
  2301.     {
  2302.       rtx address, size;
  2303.  
  2304.       frame_pointer_needed = 1;
  2305.  
  2306.       /* Record the stack pointer on entry to block, if have
  2307.      not already done so.  */
  2308.       if (thisblock->data.block.stack_level == 0)
  2309.     {
  2310.       do_pending_stack_adjust ();
  2311.       thisblock->data.block.stack_level
  2312.         = copy_to_reg (stack_pointer_rtx);
  2313.       stack_block_stack = thisblock;
  2314.     }
  2315.  
  2316.       /* Compute the variable's size, in bytes.  */
  2317.       size = expand_expr (convert_units (DECL_SIZE (decl),
  2318.                      DECL_SIZE_UNIT (decl),
  2319.                      BITS_PER_UNIT),
  2320.               0, VOIDmode, 0);
  2321.  
  2322.       /* Round it up to this machine's required stack boundary.  */
  2323. #ifdef STACK_BOUNDARY
  2324.       /* Avoid extra code if we can prove it's a multiple already.  */
  2325.       if (DECL_SIZE_UNIT (decl) % STACK_BOUNDARY)
  2326.     {
  2327. #ifdef STACK_POINTER_OFFSET
  2328.       /* Avoid extra code if we can prove that adding STACK_POINTER_OFFSET
  2329.          will not give this address invalid alignment.  */
  2330.       if (DECL_ALIGN (decl) > ((STACK_POINTER_OFFSET * BITS_PER_UNIT) % STACK_BOUNDARY))
  2331.         size = plus_constant (size,
  2332.                   STACK_POINTER_OFFSET % (STACK_BOUNDARY / BITS_PER_UNIT));
  2333. #endif
  2334.       size = round_push (size);
  2335.     }
  2336. #endif /* STACK_BOUNDARY */
  2337.  
  2338.       /* Make space on the stack, and get an rtx for the address of it.  */
  2339. #ifdef STACK_GROWS_DOWNWARD
  2340.       anti_adjust_stack (size);
  2341. #endif
  2342.       address = copy_to_reg (stack_pointer_rtx);
  2343. #ifdef STACK_POINTER_OFFSET
  2344.       {
  2345.     /* If the contents of the stack pointer reg are offset from the
  2346.        actual top-of-stack address, add the offset here.  */
  2347.     rtx sp_offset = gen_rtx (CONST_INT, VOIDmode, STACK_POINTER_OFFSET);
  2348. #ifdef STACK_BOUNDARY
  2349. #ifdef STACK_GROWS_DOWNWARD
  2350.     int direction = 1;
  2351. #else /* not STACK_GROWS_DOWNWARD */
  2352.     int direction = 0;
  2353. #endif /* not STACK_GROWS_DOWNWARD */
  2354.     if (DECL_ALIGN (decl) > ((STACK_POINTER_OFFSET * BITS_PER_UNIT) % STACK_BOUNDARY))
  2355.       sp_offset = plus_constant (sp_offset,
  2356.                      (STACK_POINTER_OFFSET
  2357.                       % (STACK_BOUNDARY / BITS_PER_UNIT)
  2358.                       * direction));
  2359. #endif /* STACK_BOUNDARY */
  2360.     emit_insn (gen_add2_insn (address, sp_offset));
  2361.       }
  2362. #endif /* STACK_POINTER_OFFSET */
  2363. #ifndef STACK_GROWS_DOWNWARD
  2364.       anti_adjust_stack (size);
  2365. #endif
  2366.  
  2367.       /* Some systems require a particular insn to refer to the stack
  2368.      to make the pages exist.  */
  2369. #ifdef HAVE_probe
  2370.       if (HAVE_probe)
  2371.     emit_insn (gen_probe ());
  2372. #endif
  2373.  
  2374.       /* Reference the variable indirect through that rtx.  */
  2375.       DECL_RTL (decl) = gen_rtx (MEM, DECL_MODE (decl), address);
  2376.     }
  2377.  
  2378.   if (TREE_VOLATILE (decl))
  2379.     MEM_VOLATILE_P (DECL_RTL (decl)) = 1;
  2380.   if (TREE_READONLY (decl))
  2381.     RTX_UNCHANGING_P (DECL_RTL (decl)) = 1;
  2382.  
  2383.   /* If doing stupid register allocation, make sure life of any
  2384.      register variable starts here, at the start of its scope.  */
  2385.  
  2386.   if (obey_regdecls)
  2387.     use_variable (DECL_RTL (decl));
  2388. }
  2389.  
  2390. /* Emit code to perform the initialization of a declaration DECL.  */
  2391.  
  2392. void
  2393. expand_decl_init (decl)
  2394.      tree decl;
  2395. {
  2396.   if (TREE_STATIC (decl))
  2397.     return;
  2398.  
  2399.   /* Compute and store the initial value now.  */
  2400.  
  2401.   if (DECL_INITIAL (decl) == error_mark_node)
  2402.     {
  2403.       enum tree_code code = TREE_CODE (TREE_TYPE (decl));
  2404.       if (code == INTEGER_TYPE || code == REAL_TYPE || code == ENUMERAL_TYPE
  2405.       || code == POINTER_TYPE)
  2406.     expand_assignment (decl, convert (TREE_TYPE (decl), integer_zero_node),
  2407.                0, 0);
  2408.       emit_queue ();
  2409.     }
  2410.   else if (DECL_INITIAL (decl) && TREE_CODE (DECL_INITIAL (decl)) != TREE_LIST)
  2411.     {
  2412.       emit_line_note (DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
  2413.       expand_assignment (decl, DECL_INITIAL (decl), 0, 0);
  2414.       emit_queue ();
  2415.     }
  2416. }
  2417.  
  2418. /* CLEANUP is an expression to be executed at exit from this binding contour;
  2419.    for example, in C++, it might call the destructor for this variable.
  2420.  
  2421.    If CLEANUP contains any SAVE_EXPRs, then you must preevaluate them
  2422.    either before or after calling `expand_decl' but before compiling
  2423.    any subsequent expressions.  This is because CLEANUP may be expanded
  2424.    more than once, on different branches of execution.
  2425.    For the same reason, CLEANUP may not contain a CALL_EXPR
  2426.    except as its topmost node--else `preexpand_calls' would get confused.
  2427.  
  2428.    If CLEANUP is nonzero and DECL is zero, we record a cleanup
  2429.    that is not associated with any particular variable.
  2430.  
  2431.    Return 0 if such an expansion is invalid.  Otherwise, return 1.  */
  2432. int
  2433. expand_decl_cleanup (decl, cleanup)
  2434. {
  2435.   struct nesting *thisblock = block_stack;
  2436.  
  2437.   /* Record the cleanup if there is one.  */
  2438.  
  2439.   if (cleanup != 0)
  2440.     {
  2441.       if (thisblock == 0)
  2442.     return 0;
  2443.  
  2444.       thisblock->data.block.cleanups
  2445.     = temp_tree_cons (decl, cleanup, thisblock->data.block.cleanups);
  2446.       /* If this block has a cleanup, it belongs in stack_block_stack.  */
  2447.       stack_block_stack = thisblock;
  2448.     }
  2449.   return 1;
  2450. }
  2451.  
  2452. /* DECL is an anonymous union.  CLEANUP is a cleanup for DECL.
  2453.    DECL_ELTS is the list of elements that belong to DECL's type.
  2454.    In each, the TREE_VALUE is a VAR_DECL, and the TREE_PURPOSE a cleanup.  */
  2455.  
  2456. void
  2457. expand_anon_union_decl (decl, cleanup, decl_elts)
  2458.      tree decl, cleanup, decl_elts;
  2459. {
  2460.   struct nesting *thisblock = block_stack;
  2461.   rtx x;
  2462.  
  2463.   expand_decl (decl, cleanup);
  2464.   x = DECL_RTL (decl);
  2465.  
  2466.   while (decl_elts)
  2467.     {
  2468.       tree decl_elt = TREE_VALUE (decl_elts);
  2469.       tree cleanup_elt = TREE_PURPOSE (decl_elts);
  2470.       enum machine_mode tmode = TYPE_MODE (TREE_TYPE (decl_elt));
  2471.  
  2472.       if (GET_CODE (x) == MEM)
  2473.     {
  2474.       /* @@ calling `change_address' means that we cannot
  2475.          be at top-level, since `memory_address' might try
  2476.          to kick this address into a register, which won't
  2477.          work.  Will this work?  */
  2478.       rtx new = gen_rtx (MEM, tmode, XEXP (x, 0));
  2479.       DECL_RTL (decl_elt) = new;
  2480.       MEM_VOLATILE_P (new) = MEM_VOLATILE_P (x);
  2481.       RTX_UNCHANGING_P (new) = RTX_UNCHANGING_P (x);
  2482.       MEM_IN_STRUCT_P (new) = MEM_IN_STRUCT_P (x);
  2483.     }
  2484.       else
  2485.     DECL_RTL (decl_elt) = gen_rtx (SUBREG, tmode, x, 0);
  2486.  
  2487.       /* Record the cleanup if there is one.  */
  2488.  
  2489.       if (cleanup != 0)
  2490.     thisblock->data.block.cleanups
  2491.       = temp_tree_cons (decl_elt, cleanup_elt,
  2492.                 thisblock->data.block.cleanups);
  2493.  
  2494.       decl_elts = TREE_CHAIN (decl_elts);
  2495.     }
  2496. }
  2497.  
  2498. /* Expand a list of cleanups LIST.
  2499.    Elements may be expressions or may be nested lists.
  2500.  
  2501.    If DONT_DO is nonnull, then any list-element
  2502.    whose TREE_PURPOSE matches DONT_DO is omitted.
  2503.    This is sometimes used to avoid a cleanup associated with
  2504.    a value that is being returned out of the scope.  */
  2505.  
  2506. static void
  2507. expand_cleanups (list, dont_do)
  2508.      tree list;
  2509.      tree dont_do;
  2510. {
  2511.   tree tail;
  2512.   for (tail = list; tail; tail = TREE_CHAIN (tail))
  2513.     if (dont_do == 0 || TREE_PURPOSE (tail) != dont_do)
  2514.       {
  2515.     if (TREE_CODE (TREE_VALUE (tail)) == TREE_LIST)
  2516.       expand_cleanups (TREE_VALUE (tail), dont_do);
  2517.     else
  2518.       expand_expr (TREE_VALUE (tail), const0_rtx, VOIDmode, 0);
  2519.       }
  2520. }
  2521.  
  2522. /* Expand a list of cleanups for a goto fixup.
  2523.    The expansion is put into the insn chain after the insn *BEFORE_JUMP
  2524.    and *BEFORE_JUMP is set to the insn that now comes before the jump.  */
  2525.  
  2526. static void
  2527. fixup_cleanups (list, before_jump)
  2528.      tree list;
  2529.      rtx *before_jump;
  2530. {
  2531.   rtx beyond_jump = get_last_insn ();
  2532.   rtx new_before_jump;
  2533.  
  2534.   expand_cleanups (list, 0);
  2535.   do_pending_stack_adjust ();
  2536.  
  2537.   new_before_jump = get_last_insn ();
  2538.  
  2539.   if (beyond_jump != new_before_jump)
  2540.     /* If cleanups expand to nothing, don't reorder.  */
  2541.     reorder_insns (NEXT_INSN (beyond_jump), new_before_jump, *before_jump);
  2542.  
  2543.   *before_jump = new_before_jump;
  2544. }
  2545.  
  2546. /* Move all cleanups from the current block_stack
  2547.    to the containing block_stack, where they are assumed to
  2548.    have been created.  If anything can cause a temporary to
  2549.    be created, but not expanded for more than one level of
  2550.    block_stacks, then this code will have to change.  */
  2551.  
  2552. void
  2553. move_cleanups_up ()
  2554. {
  2555.   struct nesting *block = block_stack;
  2556.   struct nesting *outer = block->next;
  2557.  
  2558.   outer->data.block.cleanups
  2559.     = chainon (block->data.block.cleanups,
  2560.            outer->data.block.cleanups);
  2561.   block->data.block.cleanups = 0;
  2562. }
  2563.  
  2564. int
  2565. this_contour_has_cleanups_p ()
  2566. {
  2567.   return block_stack && block_stack->data.block.cleanups != 0;
  2568. }
  2569.  
  2570. /* Enter a case (Pascal) or switch (C) statement.
  2571.    Push a block onto case_stack and nesting_stack
  2572.    to accumulate the case-labels that are seen
  2573.    and to record the labels generated for the statement.
  2574.  
  2575.    EXIT_FLAG is nonzero if `exit_something' should exit this case stmt.
  2576.    Otherwise, this construct is transparent for `exit_something'.
  2577.  
  2578.    EXPR is the index-expression to be dispatched on.
  2579.    TYPE is its nominal type.  We could simply convert EXPR to this type,
  2580.    but instead we take short cuts.  */
  2581.  
  2582. void
  2583. expand_start_case (exit_flag, expr, type)
  2584.      int exit_flag;
  2585.      tree expr;
  2586.      tree type;
  2587. {
  2588.   register struct nesting *thiscase
  2589.     = (struct nesting *) obstack_alloc (&stmt_obstack, sizeof (struct nesting));
  2590.  
  2591.   /* Make an entry on case_stack for the case we are entering.  */
  2592.  
  2593.   thiscase->next = case_stack;
  2594.   thiscase->all = nesting_stack;
  2595.   thiscase->depth = ++nesting_depth;
  2596.   thiscase->exit_label = exit_flag ? gen_label_rtx () : 0;
  2597.   thiscase->data.case_stmt.case_list = 0;
  2598.   thiscase->data.case_stmt.index_expr = expr;
  2599.   thiscase->data.case_stmt.nominal_type = type;
  2600.   thiscase->data.case_stmt.default_label = 0;
  2601.   thiscase->data.case_stmt.num_ranges = 0;
  2602.   case_stack = thiscase;
  2603.   nesting_stack = thiscase;
  2604.  
  2605.   do_pending_stack_adjust ();
  2606.  
  2607.   /* Make sure case_stmt.start points to something that won't
  2608.      need any transformation before expand_end_case.  */
  2609.   emit_note (0, NOTE_INSN_DELETED);
  2610.  
  2611.   thiscase->data.case_stmt.start = get_last_insn ();
  2612. }
  2613.  
  2614. /* Start a "dummy case statement" within which case labels are invalid
  2615.    and are not connected to any larger real case statement.
  2616.    This can be used if you don't want to let a case statement jump
  2617.    into the middle of certain kinds of constructs.  */
  2618.  
  2619. void
  2620. expand_start_case_dummy ()
  2621. {
  2622.   register struct nesting *thiscase
  2623.     = (struct nesting *) obstack_alloc (&stmt_obstack, sizeof (struct nesting));
  2624.  
  2625.   /* Make an entry on case_stack for the dummy.  */
  2626.  
  2627.   thiscase->next = case_stack;
  2628.   thiscase->all = nesting_stack;
  2629.   thiscase->depth = ++nesting_depth;
  2630.   thiscase->exit_label = 0;
  2631.   thiscase->data.case_stmt.case_list = 0;
  2632.   thiscase->data.case_stmt.start = 0;
  2633.   thiscase->data.case_stmt.nominal_type = 0;
  2634.   thiscase->data.case_stmt.default_label = 0;
  2635.   thiscase->data.case_stmt.num_ranges = 0;
  2636.   case_stack = thiscase;
  2637.   nesting_stack = thiscase;
  2638. }
  2639.  
  2640. /* End a dummy case statement.  */
  2641.  
  2642. void
  2643. expand_end_case_dummy ()
  2644. {
  2645.   POPSTACK (case_stack);
  2646. }
  2647.  
  2648. /* Accumulate one case or default label inside a case or switch statement.
  2649.    VALUE is the value of the case (a null pointer, for a default label).
  2650.  
  2651.    If not currently inside a case or switch statement, return 1 and do
  2652.    nothing.  The caller will print a language-specific error message.
  2653.    If VALUE is a duplicate or overlaps, return 2 and do nothing.
  2654.    If VALUE is out of range, return 3 and do nothing.
  2655.    Return 0 on success.
  2656.  
  2657.    Extended to handle range statements, should they ever
  2658.    be adopted.  */
  2659.  
  2660. int
  2661. pushcase (value, label)
  2662.      register tree value;
  2663.      register tree label;
  2664. {
  2665.   register struct case_node **l;
  2666.   register struct case_node *n;
  2667.   tree index_type;
  2668.   tree nominal_type;
  2669.  
  2670.   /* Fail if not inside a real case statement.  */
  2671.   if (! (case_stack && case_stack->data.case_stmt.start))
  2672.     return 1;
  2673.  
  2674.   index_type = TREE_TYPE (case_stack->data.case_stmt.index_expr);
  2675.   nominal_type = case_stack->data.case_stmt.nominal_type;
  2676.  
  2677.   /* If the index is erroneous, avoid more problems: pretend to succeed.  */
  2678.   if (index_type == error_mark_node)
  2679.     return 0;
  2680.  
  2681.   /* Convert VALUE to the type in which the comparisons are nominally done.  */
  2682.   if (value != 0)
  2683.     value = convert (nominal_type, value);
  2684.  
  2685.   /* Fail if this value is out of range for the actual type of the index
  2686.      (which may be narrower than NOMINAL_TYPE).  */
  2687.   if (value != 0 && ! int_fits_type_p (value, index_type))
  2688.     return 3;
  2689.  
  2690.   /* Fail if this is a duplicate or overlaps another entry.  */
  2691.   if (value == 0)
  2692.     {
  2693.       if (case_stack->data.case_stmt.default_label != 0)
  2694.     return 2;
  2695.       case_stack->data.case_stmt.default_label = label;
  2696.     }
  2697.   else
  2698.     {
  2699.       /* Find the elt in the chain before which to insert the new value,
  2700.      to keep the chain sorted in increasing order.
  2701.      But report an error if this element is a duplicate.  */
  2702.       for (l = &case_stack->data.case_stmt.case_list;
  2703.        /* Keep going past elements distinctly less than VALUE.  */
  2704.        *l != 0 && tree_int_cst_lt ((*l)->high, value);
  2705.        l = &(*l)->right)
  2706.     ;
  2707.       if (*l)
  2708.     {
  2709.       /* Element we will insert before must be distinctly greater;
  2710.          overlap means error.  */
  2711.       if (! tree_int_cst_lt (value, (*l)->low))
  2712.         return 2;
  2713.     }
  2714.  
  2715.       /* Add this label to the chain, and succeed.
  2716.      Copy VALUE so it is on temporary rather than momentary
  2717.      obstack and will thus survive till the end of the case statement.  */
  2718.       n = (struct case_node *) oballoc (sizeof (struct case_node));
  2719.       n->left = 0;
  2720.       n->right = *l;
  2721.       n->high = n->low = copy_node (value);
  2722.       n->code_label = label;
  2723.       n->test_label = 0;
  2724.       *l = n;
  2725.     }
  2726.  
  2727.   expand_label (label);
  2728.   return 0;
  2729. }
  2730.  
  2731. /* Like pushcase but this case applies to all values
  2732.    between VALUE1 and VALUE2 (inclusive).
  2733.    The return value is the same as that of pushcase
  2734.    but there is one additional error code:
  2735.    4 means the specified range was empty.
  2736.  
  2737.    Note that this does not currently work, since expand_end_case
  2738.    has yet to be extended to handle RANGE_EXPRs.  */
  2739.  
  2740. int
  2741. pushcase_range (value1, value2, label)
  2742.      register tree value1, value2;
  2743.      register tree label;
  2744. {
  2745.   register struct case_node **l;
  2746.   register struct case_node *n;
  2747.   tree index_type;
  2748.   tree nominal_type;
  2749.  
  2750.   /* Fail if not inside a real case statement.  */
  2751.   if (! (case_stack && case_stack->data.case_stmt.start))
  2752.     return 1;
  2753.  
  2754.   index_type = TREE_TYPE (case_stack->data.case_stmt.index_expr);
  2755.   nominal_type = case_stack->data.case_stmt.nominal_type;
  2756.  
  2757.   /* If the index is erroneous, avoid more problems: pretend to succeed.  */
  2758.   if (index_type == error_mark_node)
  2759.     return 0;
  2760.  
  2761.   /* Convert VALUEs to type in which the comparisons are nominally done.  */
  2762.   if (value1 != 0)
  2763.     value1 = convert (nominal_type, value1);
  2764.   if (value2 != 0)
  2765.     value2 = convert (nominal_type, value2);
  2766.  
  2767.   /* Fail if these values are out of range.  */
  2768.   if (value1 != 0 && ! int_fits_type_p (value1, index_type))
  2769.     return 3;
  2770.  
  2771.   if (value2 != 0 && ! int_fits_type_p (value2, index_type))
  2772.     return 3;
  2773.  
  2774.   /* Fail if the range is empty.  */
  2775.   if (tree_int_cst_lt (value2, value1))
  2776.     return 4;
  2777.  
  2778.   /* If the bounds are equal, turn this into the one-value case.  */
  2779.   if (tree_int_cst_equal (value1, value2))
  2780.     return pushcase (value1, label);
  2781.  
  2782.   /* Find the elt in the chain before which to insert the new value,
  2783.      to keep the chain sorted in increasing order.
  2784.      But report an error if this element is a duplicate.  */
  2785.   for (l = &case_stack->data.case_stmt.case_list;
  2786.        /* Keep going past elements distinctly less than this range.  */
  2787.        *l != 0 && tree_int_cst_lt ((*l)->high, value1);
  2788.        l = &(*l)->right)
  2789.     ;
  2790.   if (*l)
  2791.     {
  2792.       /* Element we will insert before must be distinctly greater;
  2793.      overlap means error.  */
  2794.       if (! tree_int_cst_lt (value2, (*l)->low))
  2795.     return 2;
  2796.     }
  2797.  
  2798.   /* Add this label to the chain, and succeed.
  2799.      Copy VALUE1, VALUE2 so they are on temporary rather than momentary
  2800.      obstack and will thus survive till the end of the case statement.  */
  2801.  
  2802.   n = (struct case_node *) oballoc (sizeof (struct case_node));
  2803.   n->left = 0;
  2804.   n->right = *l;
  2805.   n->low = copy_node (value1);
  2806.   n->high = copy_node (value2);
  2807.   n->code_label = label;
  2808.   n->test_label = 0;
  2809.   *l = n;
  2810.  
  2811.   expand_label (label);
  2812.  
  2813.   case_stack->data.case_stmt.num_ranges++;
  2814.  
  2815.   return 0;
  2816. }
  2817.  
  2818. /* Check that all enumeration literals are covered by the case
  2819.    expressions of a switch.  Also, warn if there are any extra
  2820.    switch cases that are *not* elements of the enumerated type. */
  2821.  
  2822. void
  2823. check_for_full_enumeration_handling (type)
  2824.      tree type;
  2825. {
  2826.   register struct case_node *n;
  2827.   register tree chain;
  2828.  
  2829.   /* The time complexity of this loop is currently O(N * M), with
  2830.      N being the number of enumerals in the enumerated type, and 
  2831.      M being the number of case expressions in the switch. */
  2832.              
  2833.   for (chain = TYPE_VALUES (type);
  2834.        chain;
  2835.        chain = TREE_CHAIN (chain))
  2836.     {
  2837.       /* Find a match between enumeral and case expression, if possible.
  2838.      Quit looking when we've gone too far (since case expressions
  2839.      are kept sorted in ascending order).  Warn about enumerals not
  2840.      handled in the switch statement case expression list. */
  2841.  
  2842.       for (n = case_stack->data.case_stmt.case_list; 
  2843.        n && tree_int_cst_lt (n->high, TREE_VALUE (chain));
  2844.        n = n->right)
  2845.     ;
  2846.  
  2847.       if (!(n && tree_int_cst_equal (n->low, TREE_VALUE (chain))))
  2848.     warning ("enumerated value `%s' not handled in switch",
  2849.          IDENTIFIER_POINTER (TREE_PURPOSE (chain)));
  2850.     }
  2851.  
  2852.   /* Now we go the other way around; we warn if there are case 
  2853.      expressions that don't correspond to enumerals.  This can
  2854.      occur since C and C++ don't enforce type-checking of 
  2855.      assignments to enumeration variables. */
  2856.  
  2857.   for (n = case_stack->data.case_stmt.case_list; n; n = n->right)
  2858.     {
  2859.       for (chain = TYPE_VALUES (type);
  2860.        chain && !tree_int_cst_equal (n->low, TREE_VALUE (chain)); 
  2861.        chain = TREE_CHAIN (chain))
  2862.     ;
  2863.  
  2864.       if (!chain)
  2865.     warning ("case value `%d' not in enumerated type `%s'",
  2866.          TREE_INT_CST_LOW (n->low), 
  2867.          IDENTIFIER_POINTER (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE
  2868.                      ? TYPE_NAME (type)
  2869.                      : DECL_NAME (TYPE_NAME (type))));
  2870.     }
  2871. }
  2872.  
  2873. /* Terminate a case (Pascal) or switch (C) statement
  2874.    in which CASE_INDEX is the expression to be tested.
  2875.    Generate the code to test it and jump to the right place.  */
  2876.  
  2877. void
  2878. expand_end_case (orig_index)
  2879.      tree orig_index;
  2880. {
  2881.   tree minval, maxval, range;
  2882.   rtx default_label = 0;
  2883.   register struct case_node *n;
  2884.   int count;
  2885.   rtx index;
  2886.   rtx table_label = gen_label_rtx ();
  2887.   int ncases;
  2888.   rtx *labelvec;
  2889.   register int i;
  2890.   rtx before_case;
  2891.   register struct nesting *thiscase = case_stack;
  2892.   tree index_expr = thiscase->data.case_stmt.index_expr;
  2893.   int unsignedp = TREE_UNSIGNED (TREE_TYPE (index_expr));
  2894.  
  2895.   do_pending_stack_adjust ();
  2896.  
  2897.   /* An ERROR_MARK occurs for various reasons including invalid data type.  */
  2898.   if (TREE_TYPE (index_expr) != error_mark_node)
  2899.     {
  2900.       /* If switch expression was an enumerated type, check that all
  2901.      enumeration literals are covered by the cases.
  2902.      No sense trying this if there's a default case, however.  */
  2903.  
  2904.       if (!thiscase->data.case_stmt.default_label 
  2905.       && TREE_CODE (TREE_TYPE (orig_index)) == ENUMERAL_TYPE
  2906.       && TREE_CODE (index_expr) != INTEGER_CST
  2907.       && warn_switch)
  2908.     check_for_full_enumeration_handling (TREE_TYPE (orig_index));
  2909.  
  2910.       /* If we don't have a default-label, create one here,
  2911.      after the body of the switch.  */
  2912.       if (thiscase->data.case_stmt.default_label == 0)
  2913.     {
  2914.       thiscase->data.case_stmt.default_label
  2915.         = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
  2916.       expand_label (thiscase->data.case_stmt.default_label);
  2917.     }
  2918.       default_label = label_rtx (thiscase->data.case_stmt.default_label);
  2919.  
  2920.       before_case = get_last_insn ();
  2921.  
  2922.       /* Simplify the case-list before we count it.  */
  2923.       group_case_nodes (thiscase->data.case_stmt.case_list);
  2924.  
  2925.       /* Get upper and lower bounds of case values.
  2926.      Also convert all the case values to the index expr's data type.  */
  2927.  
  2928.       count = 0;
  2929.       for (n = thiscase->data.case_stmt.case_list; n; n = n->right)
  2930.     {
  2931.       /* Check low and high label values are integers.  */
  2932.       if (TREE_CODE (n->low) != INTEGER_CST)
  2933.         abort ();
  2934.       if (TREE_CODE (n->high) != INTEGER_CST)
  2935.         abort ();
  2936.  
  2937.       n->low = convert (TREE_TYPE (index_expr), n->low);
  2938.       n->high = convert (TREE_TYPE (index_expr), n->high);
  2939.  
  2940.       /* Count the elements and track the largest and smallest
  2941.          of them (treating them as signed even if they are not).  */
  2942.       if (count++ == 0)
  2943.         {
  2944.           minval = n->low;
  2945.           maxval = n->high;
  2946.         }
  2947.       else
  2948.         {
  2949.           if (INT_CST_LT (n->low, minval))
  2950.         minval = n->low;
  2951.           if (INT_CST_LT (maxval, n->high))
  2952.         maxval = n->high;
  2953.         }
  2954.       /* A range counts double, since it requires two compares.  */
  2955.       if (! tree_int_cst_equal (n->low, n->high))
  2956.         count++;
  2957.     }
  2958.  
  2959.       /* Compute span of values.  */
  2960.       if (count != 0)
  2961.     range = combine (MINUS_EXPR, maxval, minval);
  2962.  
  2963.       if (count == 0 || TREE_CODE (TREE_TYPE (index_expr)) == ERROR_MARK)
  2964.     {
  2965.       expand_expr (index_expr, const0_rtx, VOIDmode, 0);
  2966.       emit_queue ();
  2967.       emit_jump (default_label);
  2968.     }
  2969.       /* If range of values is much bigger than number of values,
  2970.      make a sequence of conditional branches instead of a dispatch.
  2971.      If the switch-index is a constant, do it this way
  2972.      because we can optimize it.  */
  2973.       else if (TREE_INT_CST_HIGH (range) != 0
  2974. #ifdef HAVE_casesi
  2975.            || count < 4
  2976. #else
  2977.            /* If machine does not have a case insn that compares the
  2978.           bounds, this means extra overhead for dispatch tables
  2979.           which raises the threshold for using them.  */
  2980.            || count < 5
  2981. #endif
  2982.            || (unsigned) (TREE_INT_CST_LOW (range)) > 10 * count
  2983.            || TREE_CODE (index_expr) == INTEGER_CST)
  2984.     {
  2985.       index = expand_expr (index_expr, 0, VOIDmode, 0);
  2986.  
  2987.       /* If the index is a short or char that we do not have
  2988.          an insn to handle comparisons directly, convert it to
  2989.          a full integer now, rather than letting each comparison
  2990.          generate the conversion.  */
  2991.  
  2992.       if ((GET_MODE (index) == QImode || GET_MODE (index) == HImode)
  2993.           && (cmp_optab->handlers[(int) GET_MODE(index)].insn_code
  2994.           == CODE_FOR_nothing))
  2995.         index = convert_to_mode (SImode, index, unsignedp);
  2996.       
  2997.       emit_queue ();
  2998.       do_pending_stack_adjust ();
  2999.  
  3000.       index = protect_from_queue (index, 0);
  3001.       if (GET_CODE (index) == MEM)
  3002.         index = copy_to_reg (index);
  3003.       if (GET_CODE (index) == CONST_INT
  3004.           || TREE_CODE (index_expr) == INTEGER_CST)
  3005.         {
  3006.           /* Make a tree node with the proper constant value
  3007.          if we don't already have one.  */
  3008.           if (TREE_CODE (index_expr) != INTEGER_CST)
  3009.         {
  3010.           index_expr
  3011.             = build_int_2 (INTVAL (index),
  3012.                    !unsignedp && INTVAL (index) >= 0 ? 0 : -1);
  3013.           index_expr = convert (TREE_TYPE (index_expr), index_expr);
  3014.         }
  3015.  
  3016.           /* For constant index expressions we need only
  3017.          issue a unconditional branch to the appropriate
  3018.          target code.  The job of removing any unreachable
  3019.          code is left to the optimisation phase if the
  3020.          "-O" option is specified.  */
  3021.           for (n = thiscase->data.case_stmt.case_list;
  3022.            n;
  3023.            n = n->right)
  3024.         {
  3025.           if (! tree_int_cst_lt (index_expr, n->low)
  3026.               && ! tree_int_cst_lt (n->high, index_expr))
  3027.             break;
  3028.         }
  3029.           if (n)
  3030.         emit_jump (label_rtx (n->code_label));
  3031.           else
  3032.         emit_jump (default_label);
  3033.         }
  3034.       else
  3035.         {
  3036.           /* If the index expression is not constant we generate
  3037.          a binary decision tree to select the appropriate
  3038.          target code.  This is done as follows:
  3039.  
  3040.          The list of cases is rearranged into a binary tree,
  3041.          nearly optimal assuming equal probability for each case.
  3042.  
  3043.          The tree is transformed into RTL, eliminating
  3044.          redundant test conditions at the same time.
  3045.  
  3046.          If program flow could reach the end of the
  3047.          decision tree an unconditional jump to the
  3048.          default code is emitted.  */
  3049.           if (optimize
  3050.           && TREE_CODE (TREE_TYPE (orig_index)) != ENUMERAL_TYPE)
  3051.         estimate_case_costs (thiscase->data.case_stmt.case_list,
  3052.                      default_label);
  3053.           balance_case_nodes (&thiscase->data.case_stmt.case_list, 0);
  3054.           emit_case_nodes (index, thiscase->data.case_stmt.case_list,
  3055.                    default_label, unsignedp);
  3056.           emit_jump_if_reachable (default_label);
  3057.         }
  3058.     }
  3059.       else
  3060.     {
  3061. #ifdef HAVE_casesi
  3062.       /* Convert the index to SImode.  */
  3063.       if (TYPE_MODE (TREE_TYPE (index_expr)) == DImode)
  3064.         {
  3065.           index_expr = build (MINUS_EXPR, TREE_TYPE (index_expr),
  3066.                   index_expr, minval);
  3067.           minval = integer_zero_node;
  3068.         }
  3069.       if (TYPE_MODE (TREE_TYPE (index_expr)) != SImode)
  3070.         index_expr = convert (type_for_size (GET_MODE_BITSIZE (SImode), 0),
  3071.                   index_expr);
  3072.       index = expand_expr (index_expr, 0, VOIDmode, 0);
  3073.       emit_queue ();
  3074.       index = protect_from_queue (index, 0);
  3075.       do_pending_stack_adjust ();
  3076.  
  3077.       emit_jump_insn (gen_casesi (index, expand_expr (minval, 0, VOIDmode, 0),
  3078.                       expand_expr (range, 0, VOIDmode, 0),
  3079.                       table_label, default_label));
  3080. #else
  3081. #ifdef HAVE_tablejump
  3082.       index_expr = convert (type_for_size (GET_MODE_BITSIZE (SImode), 0),
  3083.                 build (MINUS_EXPR, TREE_TYPE (index_expr),
  3084.                        index_expr, minval));
  3085.       index = expand_expr (index_expr, 0, VOIDmode, 0);
  3086.       emit_queue ();
  3087.       index = protect_from_queue (index, 0);
  3088.       do_pending_stack_adjust ();
  3089.  
  3090.       do_tablejump (index,
  3091.             gen_rtx (CONST_INT, VOIDmode, TREE_INT_CST_LOW (range)),
  3092.             table_label, default_label);
  3093. #else
  3094.       lossage;
  3095. #endif                /* not HAVE_tablejump */
  3096. #endif                /* not HAVE_casesi */
  3097.  
  3098.       /* Get table of labels to jump to, in order of case index.  */
  3099.  
  3100.       ncases = TREE_INT_CST_LOW (range) + 1;
  3101.       labelvec = (rtx *) alloca (ncases * sizeof (rtx));
  3102.       bzero (labelvec, ncases * sizeof (rtx));
  3103.  
  3104.       for (n = thiscase->data.case_stmt.case_list; n; n = n->right)
  3105.         {
  3106.           register int i
  3107.         = TREE_INT_CST_LOW (n->low) - TREE_INT_CST_LOW (minval);
  3108.  
  3109.           while (i + TREE_INT_CST_LOW (minval)
  3110.              <= TREE_INT_CST_LOW (n->high))
  3111.         labelvec[i++]
  3112.           = gen_rtx (LABEL_REF, Pmode, label_rtx (n->code_label));
  3113.         }
  3114.  
  3115.       /* Fill in the gaps with the default.  */
  3116.       for (i = 0; i < ncases; i++)
  3117.         if (labelvec[i] == 0)
  3118.           labelvec[i] = gen_rtx (LABEL_REF, Pmode, default_label);
  3119.  
  3120.       /* Output the table */
  3121.       emit_label (table_label);
  3122.  
  3123. #ifdef CASE_VECTOR_PC_RELATIVE
  3124.       emit_jump_insn (gen_rtx (ADDR_DIFF_VEC, CASE_VECTOR_MODE,
  3125.                    gen_rtx (LABEL_REF, Pmode, table_label),
  3126.                    gen_rtvec_v (ncases, labelvec)));
  3127. #else
  3128.       emit_jump_insn (gen_rtx (ADDR_VEC, CASE_VECTOR_MODE,
  3129.                    gen_rtvec_v (ncases, labelvec)));
  3130. #endif
  3131.       /* If the case insn drops through the table,
  3132.          after the table we must jump to the default-label.
  3133.          Otherwise record no drop-through after the table.  */
  3134. #ifdef CASE_DROPS_THROUGH
  3135.       emit_jump (default_label);
  3136. #else
  3137.       emit_barrier ();
  3138. #endif
  3139.     }
  3140.  
  3141.       reorder_insns (NEXT_INSN (before_case), get_last_insn (),
  3142.              thiscase->data.case_stmt.start);
  3143.     }
  3144.   if (thiscase->exit_label)
  3145.     emit_label (thiscase->exit_label);
  3146.  
  3147.   POPSTACK (case_stack);
  3148. }
  3149.  
  3150. /* See case.c for CASE-handling code.  */
  3151.  
  3152. /* Allocate fixed slots in the stack frame of the current function.  */
  3153.  
  3154. /* Return size needed for stack frame based on slots so far allocated.  */
  3155.  
  3156. int
  3157. get_frame_size ()
  3158. {
  3159. #ifdef FRAME_GROWS_DOWNWARD
  3160.   return -frame_offset + STARTING_FRAME_OFFSET;
  3161. #else
  3162.   return frame_offset - STARTING_FRAME_OFFSET;
  3163. #endif
  3164. }
  3165.  
  3166. /* Allocate a stack slot of SIZE bytes and return a MEM rtx for it
  3167.    with machine mode MODE.  */
  3168.  
  3169. rtx
  3170. assign_stack_local (mode, size)
  3171.      enum machine_mode mode;
  3172.      int size;
  3173. {
  3174.   register rtx x, addr;
  3175.   int bigend_correction = 0;
  3176.  
  3177.   frame_pointer_needed = 1;
  3178.  
  3179.   /* Make each stack slot a multiple of the main allocation unit.  */
  3180.   size = (((size + (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - 1)
  3181.        / (BIGGEST_ALIGNMENT / BITS_PER_UNIT))
  3182.       * (BIGGEST_ALIGNMENT / BITS_PER_UNIT));
  3183.  
  3184.   /* On a big-endian machine, if we are allocating more space than we will use,
  3185.      use the least significant bytes of those that are allocated.  */
  3186. #ifdef BYTES_BIG_ENDIAN
  3187.   if (mode != BLKmode)
  3188.     bigend_correction = size - GET_MODE_SIZE (mode);
  3189. #endif
  3190.  
  3191. #ifdef FRAME_GROWS_DOWNWARD
  3192.   frame_offset -= size;
  3193. #endif
  3194.   addr = gen_rtx (PLUS, Pmode, frame_pointer_rtx,
  3195.           gen_rtx (CONST_INT, VOIDmode,
  3196.                (frame_offset + bigend_correction)));
  3197. #ifndef FRAME_GROWS_DOWNWARD
  3198.   frame_offset += size;
  3199. #endif
  3200.  
  3201.   if (! memory_address_p (mode, addr))
  3202.     invalid_stack_slot = 1;
  3203.  
  3204.   x = gen_rtx (MEM, mode, addr);
  3205.  
  3206.   stack_slot_list = gen_rtx (EXPR_LIST, VOIDmode, x, stack_slot_list);
  3207.  
  3208.   return x;
  3209. }
  3210.  
  3211. /* Retroactively move an auto variable from a register to a stack slot.
  3212.    This is done when an address-reference to the variable is seen.  */
  3213.  
  3214. void
  3215. put_var_into_stack (decl)
  3216.      tree decl;
  3217. {
  3218.   register rtx reg = DECL_RTL (decl);
  3219.   register rtx new;
  3220.  
  3221.   /* No need to do anything if decl has no rtx yet
  3222.      since in that case caller is setting TREE_ADDRESSABLE
  3223.      and a stack slot will be assigned when the rtl is made.  */
  3224.   if (reg == 0)
  3225.     return;
  3226.   if (GET_CODE (reg) != REG)
  3227.     return;
  3228.  
  3229.   new = parm_stack_loc (reg);
  3230.   if (new == 0)
  3231.     new = assign_stack_local (GET_MODE (reg), GET_MODE_SIZE (GET_MODE (reg)));
  3232.  
  3233.   XEXP (reg, 0) = XEXP (new, 0);
  3234.   /* `volatil' bit means one thing for MEMs, another entirely for REGs.  */
  3235.   REG_USERVAR_P (reg) = 0;
  3236.   PUT_CODE (reg, MEM);
  3237.  
  3238.   /* If this is a memory ref that contains aggregate components,
  3239.      mark it as such for cse and loop optimize.  */
  3240.   MEM_IN_STRUCT_P (reg)
  3241.     = (TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE
  3242.        || TREE_CODE (TREE_TYPE (decl)) == RECORD_TYPE
  3243.        || TREE_CODE (TREE_TYPE (decl)) == UNION_TYPE);
  3244.  
  3245.   fixup_var_refs (reg);
  3246. }
  3247.  
  3248. static void
  3249. fixup_var_refs (var)
  3250.      rtx var;
  3251. {
  3252.   extern rtx sequence_stack;
  3253.   rtx stack = sequence_stack;
  3254.   tree pending;
  3255.  
  3256.   stack = sequence_stack;
  3257.  
  3258.   /* Must scan all insns for stack-refs that exceed the limit.  */
  3259.   fixup_var_refs_insns (var, get_insns (), stack == 0);
  3260.  
  3261.   /* Scan all pending sequences too.  */
  3262.   for (; stack; stack = XEXP (XEXP (stack, 1), 1))
  3263.     {
  3264.       push_to_sequence (XEXP (stack, 0));
  3265.       fixup_var_refs_insns (var, XEXP (stack, 0),
  3266.                 XEXP (XEXP (stack, 1), 1) == 0);
  3267.       /* Update remembered end of sequence
  3268.      in case we added an insn at the end.  */
  3269.       XEXP (XEXP (stack, 1), 0) = get_last_insn ();
  3270.       end_sequence ();
  3271.     }
  3272.  
  3273.   /* Scan all waiting RTL_EXPRs too.  */
  3274.   for (pending = rtl_expr_chain; pending; pending = TREE_CHAIN (pending))
  3275.     {
  3276.       rtx seq = RTL_EXPR_SEQUENCE (TREE_VALUE (pending));
  3277.       if (seq != const0_rtx && seq != 0)
  3278.     {
  3279.       push_to_sequence (seq);
  3280.       fixup_var_refs_insns (var, seq, 0);
  3281.       end_sequence ();
  3282.     }
  3283.     }
  3284. }
  3285.  
  3286. /* Scan the insn-chain starting with INSN for refs to VAR
  3287.    and fix them up.  TOPLEVEL is nonzero if this chain is the
  3288.    main chain of insns for the current function.  */
  3289.  
  3290. static void
  3291. fixup_var_refs_insns (var, insn, toplevel)
  3292.      rtx var;
  3293.      rtx insn;
  3294.      int toplevel;
  3295. {
  3296.   while (insn)
  3297.     {
  3298.       rtx next = NEXT_INSN (insn);
  3299.       rtx note;
  3300.       if (GET_CODE (insn) == INSN || GET_CODE (insn) == CALL_INSN
  3301.       || GET_CODE (insn) == JUMP_INSN)
  3302.     {
  3303.       /* The insn to load VAR from a home in the arglist
  3304.          is now a no-op.  When we see it, just delete it.  */
  3305.       if (toplevel
  3306.           && GET_CODE (PATTERN (insn)) == SET
  3307.           && SET_DEST (PATTERN (insn)) == var
  3308.           && rtx_equal_p (SET_SRC (PATTERN (insn)), var))
  3309.         {
  3310.           next = delete_insn (insn);
  3311.           if (insn == last_parm_insn)
  3312.         last_parm_insn = PREV_INSN (next);
  3313.         }
  3314.       else
  3315.         fixup_var_refs_1 (var, PATTERN (insn), insn);
  3316.       /* Also fix up any invalid exprs in the REG_NOTES of this insn.
  3317.          But don't touch other insns referred to by reg-notes;
  3318.          we will get them elsewhere.  */
  3319.       for (note = REG_NOTES (insn); note; note = XEXP (note, 1))
  3320.         if (GET_CODE (note) != INSN_LIST)
  3321.           XEXP (note, 0) = walk_fixup_memory_subreg (XEXP (note, 0), insn);
  3322.     }
  3323.       insn = next;
  3324.     }
  3325. }
  3326.  
  3327. static rtx
  3328. fixup_var_refs_1 (var, x, insn)
  3329.      register rtx var;
  3330.      register rtx x;
  3331.      rtx insn;
  3332. {
  3333.   register int i;
  3334.   RTX_CODE code = GET_CODE (x);
  3335.   register char *fmt;
  3336.   register rtx tem;
  3337.  
  3338.   switch (code)
  3339.     {
  3340.     case MEM:
  3341.       if (var == x)
  3342.     {
  3343.       x = fixup_stack_1 (x, insn);
  3344.       tem = gen_reg_rtx (GET_MODE (x));
  3345.       /* Put new insn before a CALL, before any USEs before it.  */
  3346.       if (GET_CODE (insn) == CALL_INSN)
  3347.         while (PREV_INSN (insn) != 0 && GET_CODE (PREV_INSN (insn)) == INSN
  3348.            && GET_CODE (PATTERN (PREV_INSN (insn))) == USE)
  3349.           insn = PREV_INSN (insn);
  3350.       emit_insn_before (gen_move_insn (tem, x), insn);
  3351.       return tem;
  3352.     }
  3353.       break;
  3354.  
  3355.     case REG:
  3356.     case CC0:
  3357.     case PC:
  3358.     case CONST_INT:
  3359.     case CONST:
  3360.     case SYMBOL_REF:
  3361.     case LABEL_REF:
  3362.     case CONST_DOUBLE:
  3363.       return x;
  3364.  
  3365.     case SIGN_EXTRACT:
  3366.     case ZERO_EXTRACT:
  3367.       /* Note that in some cases those types of expressions are altered
  3368.      by optimize_bit_field, and do not survive to get here.  */
  3369.     case SUBREG:
  3370.       tem = x;
  3371.       while (GET_CODE (tem) == SUBREG || GET_CODE (tem) == SIGN_EXTRACT
  3372.          || GET_CODE (tem) == ZERO_EXTRACT)
  3373.     tem = XEXP (tem, 0);
  3374.       if (tem == var)
  3375.     {
  3376.       x = fixup_stack_1 (x, insn);
  3377.       tem = gen_reg_rtx (GET_MODE (x));
  3378.       if (GET_CODE (x) == SUBREG)
  3379.         x = fixup_memory_subreg (x, insn);
  3380.       emit_insn_before (gen_move_insn (tem, x), insn);
  3381.       return tem;
  3382.     }
  3383.       break;
  3384.  
  3385.     case SET:
  3386.       /* First do special simplification of bit-field references.  */
  3387.       if (GET_CODE (SET_DEST (x)) == SIGN_EXTRACT
  3388.       || GET_CODE (SET_DEST (x)) == ZERO_EXTRACT)
  3389.     optimize_bit_field (x, insn, 0);
  3390.       if (GET_CODE (SET_SRC (x)) == SIGN_EXTRACT
  3391.       || GET_CODE (SET_SRC (x)) == ZERO_EXTRACT)
  3392.     optimize_bit_field (x, insn, 0);
  3393.  
  3394.       {
  3395.     rtx dest = SET_DEST (x);
  3396.     rtx src = SET_SRC (x);
  3397.     rtx outerdest = dest;
  3398.     rtx outersrc = src;
  3399.  
  3400.     while (GET_CODE (dest) == SUBREG || GET_CODE (dest) == STRICT_LOW_PART
  3401.            || GET_CODE (dest) == SIGN_EXTRACT
  3402.            || GET_CODE (dest) == ZERO_EXTRACT)
  3403.       dest = XEXP (dest, 0);
  3404.     while (GET_CODE (src) == SUBREG
  3405.            || GET_CODE (src) == SIGN_EXTRACT
  3406.            || GET_CODE (src) == ZERO_EXTRACT)
  3407.       src = XEXP (src, 0);
  3408.  
  3409.     /* If VAR does not appear at the top level of the SET
  3410.        just scan the lower levels of the tree.  */
  3411.  
  3412.         if (src != var && dest != var)
  3413.       break;
  3414.  
  3415.     /* Clean up (SUBREG:SI (MEM:mode ...) 0)
  3416.        that may appear inside a SIGN_EXTRACT or ZERO_EXTRACT.
  3417.        This was legitimate when the MEM was a REG.  */
  3418.  
  3419.     if ((GET_CODE (outerdest) == SIGN_EXTRACT
  3420.          || GET_CODE (outerdest) == ZERO_EXTRACT)
  3421.         && GET_CODE (XEXP (outerdest, 0)) == SUBREG
  3422.         && SUBREG_REG (XEXP (outerdest, 0)) == var)
  3423.       XEXP (outerdest, 0) = fixup_memory_subreg (XEXP (outerdest, 0), insn);
  3424.  
  3425.     if ((GET_CODE (outersrc) == SIGN_EXTRACT
  3426.          || GET_CODE (outersrc) == ZERO_EXTRACT)
  3427.         && GET_CODE (XEXP (outersrc, 0)) == SUBREG
  3428.         && SUBREG_REG (XEXP (outersrc, 0)) == var)
  3429.       XEXP (outersrc, 0) = fixup_memory_subreg (XEXP (outersrc, 0), insn);
  3430.  
  3431.     /* Make sure that the machine's SIGN_EXTRACT and ZERO_EXTRACT insns
  3432.        accept a memory operand.  */
  3433. #ifdef HAVE_extzv
  3434.     if (GET_CODE (outersrc) == ZERO_EXTRACT
  3435.         && ! ((*insn_operand_predicate[(int) CODE_FOR_extzv][0])
  3436.           (XEXP (outersrc, 0), VOIDmode)))
  3437.       XEXP (outersrc, 0) = src
  3438.         = fixup_var_refs_1 (var, XEXP (outersrc, 0), insn);
  3439. #endif
  3440. #ifdef HAVE_extv
  3441.     if (GET_CODE (outersrc) == SIGN_EXTRACT
  3442.         && ! ((*insn_operand_predicate[(int) CODE_FOR_extv][0])
  3443.           (XEXP (outersrc, 0), VOIDmode)))
  3444.       XEXP (outersrc, 0) = src
  3445.         = fixup_var_refs_1 (var, XEXP (outersrc, 0), insn);
  3446. #endif
  3447. #ifdef HAVE_insv
  3448.     if (GET_CODE (outerdest) == ZERO_EXTRACT
  3449.         && ! ((*insn_operand_predicate[(int) CODE_FOR_insv][0])
  3450.           (XEXP (outerdest, 0), VOIDmode)))
  3451.       {
  3452.         rtx tem = gen_reg_rtx (GET_MODE (XEXP (outerdest, 0)));
  3453.  
  3454.         emit_insn_before (gen_move_insn (tem, XEXP (outerdest, 0)), insn);
  3455.         emit_insn_after (gen_move_insn (XEXP (outerdest, 0), tem), insn);
  3456.         dest = XEXP (outerdest, 0) = tem;
  3457.       }
  3458. #endif
  3459.  
  3460.     /* Make sure a MEM inside a SIGN_EXTRACT has QImode
  3461.        since that's what bit-field insns want.  */
  3462.  
  3463.     if ((GET_CODE (outerdest) == SIGN_EXTRACT
  3464.          || GET_CODE (outerdest) == ZERO_EXTRACT)
  3465.         && GET_CODE (XEXP (outerdest, 0)) == MEM
  3466.         && GET_MODE (XEXP (outerdest, 0)) != QImode)
  3467.       {
  3468.         XEXP (outerdest, 0) = copy_rtx (XEXP (outerdest, 0));
  3469.         PUT_MODE (XEXP (outerdest, 0), QImode);
  3470.         /* Adjust the address so the bit field starts within the byte
  3471.            addressed.  This helps certain optimization patterns.  */
  3472.         if (GET_CODE (XEXP (outerdest, 2)) == CONST_INT
  3473.         && offsettable_memref_p (XEXP (outerdest, 0)))
  3474.           {
  3475.         int count = INTVAL (XEXP (outerdest, 2));
  3476.         XEXP (outerdest, 0)
  3477.           = adj_offsettable_operand (XEXP (outerdest, 0),
  3478.                          count / GET_MODE_BITSIZE (QImode));
  3479.         XEXP (outerdest, 2)
  3480.           = gen_rtx (CONST_INT, VOIDmode,
  3481.                  count % GET_MODE_BITSIZE (QImode));
  3482.           }
  3483.       }
  3484.  
  3485.     if ((GET_CODE (outersrc) == SIGN_EXTRACT
  3486.          || GET_CODE (outersrc) == ZERO_EXTRACT)
  3487.         && GET_CODE (XEXP (outersrc, 0)) == MEM
  3488.         && GET_MODE (XEXP (outersrc, 0)) != QImode)
  3489.       {
  3490.         XEXP (outersrc, 0) = copy_rtx (XEXP (outersrc, 0));
  3491.         PUT_MODE (XEXP (outersrc, 0), QImode);
  3492.         /* Adjust the address so the bit field starts within the byte
  3493.            addressed.  This helps certain optimization patterns.  */
  3494.         if (GET_CODE (XEXP (outersrc, 2)) == CONST_INT
  3495.         && offsettable_memref_p (XEXP (outersrc, 0)))
  3496.           {
  3497.         int count = INTVAL (XEXP (outersrc, 2));
  3498.         XEXP (outersrc, 0)
  3499.           = adj_offsettable_operand (XEXP (outersrc, 0),
  3500.                          count / GET_MODE_BITSIZE (QImode));
  3501.         XEXP (outersrc, 2)
  3502.           = gen_rtx (CONST_INT, VOIDmode,
  3503.                  count % GET_MODE_BITSIZE (QImode));
  3504.           }
  3505.       }
  3506.  
  3507.     /* STRICT_LOW_PART is a no-op on memory references
  3508.        and it can cause combinations to be unrecognizable,
  3509.        so eliminate it.  */
  3510.  
  3511.     if (dest == var && GET_CODE (SET_DEST (x)) == STRICT_LOW_PART)
  3512.       SET_DEST (x) = XEXP (SET_DEST (x), 0);
  3513.  
  3514.     /* An insn to copy VAR into or out of a register
  3515.        must be left alone, to avoid an infinite loop here.
  3516.        But do fix up the address of VAR's stack slot if nec,
  3517.        and fix up SUBREGs containing VAR
  3518.        (since they are now memory subregs).  */
  3519.  
  3520.     if (GET_CODE (SET_SRC (x)) == REG || GET_CODE (SET_DEST (x)) == REG
  3521.         || (GET_CODE (SET_SRC (x)) == SUBREG
  3522.         && GET_CODE (SUBREG_REG (SET_SRC (x))) == REG)
  3523.         || (GET_CODE (SET_DEST (x)) == SUBREG
  3524.         && GET_CODE (SUBREG_REG (SET_DEST (x))) == REG))
  3525.       {
  3526.         if (src == var && GET_CODE (SET_SRC (x)) == SUBREG)
  3527.           SET_SRC (x) = fixup_memory_subreg (SET_SRC (x), insn);
  3528.         if (dest == var && GET_CODE (SET_DEST (x)) == SUBREG)
  3529.           SET_DEST (x) = fixup_memory_subreg (SET_DEST (x), insn);
  3530.         return fixup_stack_1 (x, insn);
  3531.       }
  3532.  
  3533.     /* Otherwise, storing into VAR must be handled specially
  3534.        by storing into a temporary and copying that into VAR
  3535.        with a new insn after this one.  */
  3536.  
  3537.     if (dest == var)
  3538.       {
  3539.         rtx temp;
  3540.         rtx fixeddest;
  3541.         tem = SET_DEST (x);
  3542.         /* STRICT_LOW_PART can be discarded, around a MEM.  */
  3543.         if (GET_CODE (tem) == STRICT_LOW_PART)
  3544.           tem = XEXP (tem, 0);
  3545.         /* Convert (SUBREG (MEM)) to a MEM in a changed mode.  */
  3546.         if (GET_CODE (tem) == SUBREG)
  3547.           tem = fixup_memory_subreg (tem, insn);
  3548.         fixeddest = fixup_stack_1 (tem, insn);
  3549.         temp = gen_reg_rtx (GET_MODE (tem));
  3550.         emit_insn_after (gen_move_insn (fixeddest, temp), insn);
  3551.         SET_DEST (x) = temp;
  3552.       }
  3553.       }
  3554.     }
  3555.  
  3556.   /* Nothing special about this RTX; fix its operands.  */
  3557.  
  3558.   fmt = GET_RTX_FORMAT (code);
  3559.   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
  3560.     {
  3561.       if (fmt[i] == 'e')
  3562.     XEXP (x, i) = fixup_var_refs_1 (var, XEXP (x, i), insn);
  3563.       if (fmt[i] == 'E')
  3564.     {
  3565.       register int j;
  3566.       for (j = 0; j < XVECLEN (x, i); j++)
  3567.         XVECEXP (x, i, j)
  3568.           = fixup_var_refs_1 (var, XVECEXP (x, i, j), insn);
  3569.     }
  3570.     }
  3571.   return x;
  3572. }
  3573.  
  3574. /* Given X, an rtx of the form (SUBREG:m1 (MEM:m2 addr)),
  3575.    return an rtx (MEM:m1 newaddr) which is equivalent.
  3576.    If any insns must be emitted to compute NEWADDR, put them before INSN.  */
  3577.  
  3578. static rtx
  3579. fixup_memory_subreg (x, insn)
  3580.      rtx x;
  3581.      rtx insn;
  3582. {
  3583.   int offset = SUBREG_WORD (x) * UNITS_PER_WORD;
  3584.   rtx addr = XEXP (SUBREG_REG (x), 0);
  3585.   enum machine_mode mode = GET_MODE (x);
  3586.   rtx saved, result;
  3587.  
  3588. #ifdef BYTES_BIG_ENDIAN
  3589.   offset += (MIN (UNITS_PER_WORD, GET_MODE_SIZE (GET_MODE (SUBREG_REG (x))))
  3590.          - MIN (UNITS_PER_WORD, GET_MODE_SIZE (mode)));
  3591. #endif
  3592.   addr = plus_constant (addr, offset);
  3593.   if (memory_address_p (mode, addr))
  3594.     return change_address (SUBREG_REG (x), mode, addr);
  3595.   saved = start_sequence ();
  3596.   result = change_address (SUBREG_REG (x), mode, addr);
  3597.   emit_insn_before (gen_sequence (), insn);
  3598.   end_sequence (saved);
  3599.   return result;
  3600. }
  3601.  
  3602. /* Do fixup_memory_subreg on all (SUBREG (MEM ...) ...) contained in X.
  3603.    Replace subexpressions of X in place.
  3604.    If X itself is a (SUBREG (MEM ...) ...), return the replacement expression.
  3605.    Otherwise return X, with its contents possibly altered.
  3606.  
  3607.    If any insns must be emitted to compute NEWADDR, put them before INSN.  */
  3608.  
  3609. static rtx
  3610. walk_fixup_memory_subreg (x, insn)
  3611.      register rtx x;
  3612.      rtx insn;
  3613. {
  3614.   register enum rtx_code code;
  3615.   register char *fmt;
  3616.   register int i;
  3617.  
  3618.   if (x == 0)
  3619.     return 0;
  3620.  
  3621.   code = GET_CODE (x);
  3622.  
  3623.   if (code == SUBREG && GET_CODE (SUBREG_REG (x)) == MEM)
  3624.     return fixup_memory_subreg (x, insn);
  3625.  
  3626.   /* Nothing special about this RTX; fix its operands.  */
  3627.  
  3628.   fmt = GET_RTX_FORMAT (code);
  3629.   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
  3630.     {
  3631.       if (fmt[i] == 'e')
  3632.     XEXP (x, i) = walk_fixup_memory_subreg (XEXP (x, i), insn);
  3633.       if (fmt[i] == 'E')
  3634.     {
  3635.       register int j;
  3636.       for (j = 0; j < XVECLEN (x, i); j++)
  3637.         XVECEXP (x, i, j)
  3638.           = walk_fixup_memory_subreg (XVECEXP (x, i, j), insn);
  3639.     }
  3640.     }
  3641.   return x;
  3642. }
  3643.  
  3644. #if 0
  3645. /* Fix up any references to stack slots that are invalid memory addresses
  3646.    because they exceed the maximum range of a displacement.  */
  3647.  
  3648. void
  3649. fixup_stack_slots ()
  3650. {
  3651.   register rtx insn;
  3652.  
  3653.   /* Did we generate a stack slot that is out of range
  3654.      or otherwise has an invalid address?  */
  3655.   if (invalid_stack_slot)
  3656.     {
  3657.       /* Yes.  Must scan all insns for stack-refs that exceed the limit.  */
  3658.       for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
  3659.     if (GET_CODE (insn) == INSN || GET_CODE (insn) == CALL_INSN
  3660.         || GET_CODE (insn) == JUMP_INSN)
  3661.       fixup_stack_1 (PATTERN (insn), insn);
  3662.     }
  3663. }
  3664. #endif
  3665.  
  3666. /* For each memory ref within X, if it refers to a stack slot
  3667.    with an out of range displacement, put the address in a temp register
  3668.    (emitting new insns before INSN to load these registers)
  3669.    and alter the memory ref to use that register.
  3670.    Replace each such MEM rtx with a copy, to avoid clobberage.  */
  3671.  
  3672. static rtx
  3673. fixup_stack_1 (x, insn)
  3674.      rtx x;
  3675.      rtx insn;
  3676. {
  3677.   register int i;
  3678.   register RTX_CODE code = GET_CODE (x);
  3679.   register char *fmt;
  3680.  
  3681.   if (code == MEM)
  3682.     {
  3683.       register rtx ad = XEXP (x, 0);
  3684.       /* If we have address of a stack slot but it's not valid
  3685.      (displacement is too large), compute the sum in a register.  */
  3686.       if (GET_CODE (ad) == PLUS
  3687.       && XEXP (ad, 0) == frame_pointer_rtx
  3688.       && GET_CODE (XEXP (ad, 1)) == CONST_INT)
  3689.     {
  3690.       rtx temp;
  3691.       if (memory_address_p (GET_MODE (x), ad))
  3692.         return x;
  3693.       temp = gen_reg_rtx (GET_MODE (ad));
  3694.       emit_insn_before (gen_move_insn (temp, ad), insn);
  3695.       return change_address (x, VOIDmode, temp);
  3696.     }
  3697.       return x;
  3698.     }
  3699.  
  3700.   fmt = GET_RTX_FORMAT (code);
  3701.   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
  3702.     {
  3703.       if (fmt[i] == 'e')
  3704.     XEXP (x, i) = fixup_stack_1 (XEXP (x, i), insn);
  3705.       if (fmt[i] == 'E')
  3706.     {
  3707.       register int j;
  3708.       for (j = 0; j < XVECLEN (x, i); j++)
  3709.         XVECEXP (x, i, j) = fixup_stack_1 (XVECEXP (x, i, j), insn);
  3710.     }
  3711.     }
  3712.   return x;
  3713. }
  3714.  
  3715. /* Optimization: a bit-field instruction whose field
  3716.    happens to be a byte or halfword in memory
  3717.    can be changed to a move instruction.
  3718.  
  3719.    We call here when INSN is an insn to examine or store into a bit-field.
  3720.    BODY is the SET-rtx to be altered.
  3721.  
  3722.    EQUIV_MEM is the table `reg_equiv_mem' if that is available; else 0.
  3723.    (Currently this is called only from stmt.c, and EQUIV_MEM is always 0.)  */
  3724.  
  3725. static void
  3726. optimize_bit_field (body, insn, equiv_mem)
  3727.      rtx body;
  3728.      rtx insn;
  3729.      rtx *equiv_mem;
  3730. {
  3731.   register rtx bitfield;
  3732.   int destflag;
  3733.  
  3734.   if (GET_CODE (SET_DEST (body)) == SIGN_EXTRACT
  3735.       || GET_CODE (SET_DEST (body)) == ZERO_EXTRACT)
  3736.     bitfield = SET_DEST (body), destflag = 1;
  3737.   else
  3738.     bitfield = SET_SRC (body), destflag = 0;
  3739.  
  3740.   /* First check that the field being stored has constant size and position
  3741.      and is in fact a byte or halfword suitably aligned.  */
  3742.  
  3743.   if (GET_CODE (XEXP (bitfield, 1)) == CONST_INT
  3744.       && GET_CODE (XEXP (bitfield, 2)) == CONST_INT
  3745.       && (INTVAL (XEXP (bitfield, 1)) == GET_MODE_BITSIZE (QImode)
  3746.       || INTVAL (XEXP (bitfield, 1)) == GET_MODE_BITSIZE (HImode))
  3747.       && INTVAL (XEXP (bitfield, 2)) % INTVAL (XEXP (bitfield, 1)) == 0)
  3748.     {
  3749.       register rtx memref = 0;
  3750.  
  3751.       /* Now check that the containing word is memory, not a register,
  3752.      and that it is safe to change the machine mode and to
  3753.      add something to the address.  */
  3754.  
  3755.       if (GET_CODE (XEXP (bitfield, 0)) == MEM)
  3756.     memref = XEXP (bitfield, 0);
  3757.       else if (GET_CODE (XEXP (bitfield, 0)) == REG
  3758.            && equiv_mem != 0)
  3759.     memref = equiv_mem[REGNO (XEXP (bitfield, 0))];
  3760.       else if (GET_CODE (XEXP (bitfield, 0)) == SUBREG
  3761.            && GET_CODE (SUBREG_REG (XEXP (bitfield, 0))) == MEM)
  3762.     memref = SUBREG_REG (XEXP (bitfield, 0));
  3763.       else if (GET_CODE (XEXP (bitfield, 0)) == SUBREG
  3764.            && equiv_mem != 0
  3765.            && GET_CODE (SUBREG_REG (XEXP (bitfield, 0))) == REG)
  3766.     memref = equiv_mem[REGNO (SUBREG_REG (XEXP (bitfield, 0)))];
  3767.  
  3768.       if (memref
  3769.       && ! mode_dependent_address_p (XEXP (memref, 0))
  3770.       && offsettable_address_p (0, GET_MODE (bitfield), XEXP (memref, 0)))
  3771.     {
  3772.       /* Now adjust the address, first for any subreg'ing
  3773.          that we are now getting rid of,
  3774.          and then for which byte of the word is wanted.  */
  3775.  
  3776.       register int offset
  3777.         = INTVAL (XEXP (bitfield, 2)) / GET_MODE_BITSIZE (QImode);
  3778.       if (GET_CODE (XEXP (bitfield, 0)) == SUBREG)
  3779.         {
  3780.           offset += SUBREG_WORD (XEXP (bitfield, 0)) * UNITS_PER_WORD;
  3781. #ifdef BYTES_BIG_ENDIAN
  3782.           offset -= (MIN (UNITS_PER_WORD,
  3783.                   GET_MODE_SIZE (GET_MODE (XEXP (bitfield, 0))))
  3784.              - MIN (UNITS_PER_WORD,
  3785.                 GET_MODE_SIZE (GET_MODE (memref))));
  3786. #endif
  3787.         }
  3788.  
  3789.       memref = gen_rtx (MEM,
  3790.                 (INTVAL (XEXP (bitfield, 1)) == GET_MODE_BITSIZE (QImode)
  3791.                  ? QImode : HImode),
  3792.                 XEXP (memref, 0));
  3793.  
  3794.       /* Store this memory reference where
  3795.          we found the bit field reference.  */
  3796.  
  3797.       if (destflag)
  3798.         {
  3799.           SET_DEST (body)
  3800.         = adj_offsettable_operand (memref, offset);
  3801.           if (! CONSTANT_ADDRESS_P (SET_SRC (body)))
  3802.         {
  3803.           rtx src = SET_SRC (body);
  3804.           while (GET_CODE (src) == SUBREG
  3805.              && SUBREG_WORD (src) == 0)
  3806.             src = SUBREG_REG (src);
  3807.           if (GET_MODE (src) != GET_MODE (memref))
  3808.             src = gen_lowpart (GET_MODE (memref), SET_SRC (body));
  3809.           SET_SRC (body) = src;
  3810.         }
  3811.           else if (GET_MODE (SET_SRC (body)) != VOIDmode
  3812.                && GET_MODE (SET_SRC (body)) != GET_MODE (memref))
  3813.         /* This shouldn't happen because anything that didn't have
  3814.            one of these modes should have got converted explicitly
  3815.            and then referenced through a subreg.
  3816.            This is so because the original bit-field was
  3817.            handled by agg_mode and so its tree structure had
  3818.            the same mode that memref now has.  */
  3819.         abort ();
  3820.         }
  3821.       else
  3822.         {
  3823.           rtx dest = SET_DEST (body);
  3824.  
  3825.           while (GET_CODE (dest) == SUBREG
  3826.              && SUBREG_WORD (dest) == 0)
  3827.         dest = SUBREG_REG (dest);
  3828.           SET_DEST (body) = dest;
  3829.  
  3830.           memref = adj_offsettable_operand (memref, offset);
  3831.           if (GET_MODE (dest) == GET_MODE (memref))
  3832.         SET_SRC (body) = memref;
  3833.           else
  3834.         {
  3835.           /* Convert the mem ref to the destination mode.  */
  3836.           rtx last = get_last_insn ();
  3837.           rtx newreg = gen_reg_rtx (GET_MODE (dest));
  3838.           convert_move (newreg, memref,
  3839.                 GET_CODE (SET_SRC (body)) == ZERO_EXTRACT);
  3840.           /* Put the conversion before the insn being fixed.  */
  3841.           reorder_insns (NEXT_INSN (last), get_last_insn (),
  3842.                  PREV_INSN (insn));
  3843.           SET_SRC (body) = newreg;
  3844.         }
  3845.         }
  3846.  
  3847.       /* Cause the insn to be re-recognized.  */
  3848.  
  3849.       INSN_CODE (insn) = -1;
  3850.     }
  3851.     }
  3852. }
  3853.  
  3854. /* 1 + last pseudo register number used for loading a copy
  3855.    of a parameter of this function.  */
  3856.  
  3857. static int max_parm_reg;
  3858.  
  3859. /* Vector indexed by REGNO, containing location on stack in which
  3860.    to put the parm which is nominally in pseudo register REGNO,
  3861.    if we discover that that parm must go in the stack.  */
  3862. static rtx *parm_reg_stack_loc;
  3863.  
  3864. int
  3865. max_parm_reg_num ()
  3866. {
  3867.   return max_parm_reg;
  3868. }
  3869.  
  3870. /* Return the first insn following those generated by `assign_parms'.  */
  3871.  
  3872. rtx
  3873. get_first_nonparm_insn ()
  3874. {
  3875.   if (last_parm_insn)
  3876.     return NEXT_INSN (last_parm_insn);
  3877.   return get_insns ();
  3878. }
  3879.  
  3880. /* Get the stack home of a REG rtx that is one of this function's parameters.
  3881.    This is called rather than assign a new stack slot as a local.
  3882.    Return 0 if there is no existing stack home suitable for such use.  */
  3883.  
  3884. static rtx
  3885. parm_stack_loc (reg)
  3886.      rtx reg;
  3887. {
  3888.   if (REGNO (reg) < max_parm_reg)
  3889.     return parm_reg_stack_loc[REGNO (reg)];
  3890.   return 0;
  3891. }
  3892.  
  3893. /* Return 1 if EXP returns an aggregate value, for which an address
  3894.    must be passed to the function or returned by the function.  */
  3895.  
  3896. int
  3897. aggregate_value_p (exp)
  3898.      tree exp;
  3899. {
  3900.   if (TYPE_MODE (TREE_TYPE (exp)) == BLKmode)
  3901.     return 1;
  3902.   if (RETURN_IN_MEMORY (TREE_TYPE (exp)))
  3903.     return 1;
  3904.   if (flag_pcc_struct_return
  3905.       && (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE
  3906.       || TREE_CODE (TREE_TYPE (exp)) == UNION_TYPE))
  3907.     return 1;
  3908.   return 0;
  3909. }
  3910.  
  3911. /* Convert a mem ref into one with a valid memory address.
  3912.    Pass through anything else unchanged.  */
  3913.  
  3914. rtx
  3915. validize_mem (ref)
  3916.      rtx ref;
  3917. {
  3918.   if (GET_CODE (ref) != MEM)
  3919.     return ref;
  3920.   if (memory_address_p (GET_MODE (ref), XEXP (ref, 0)))
  3921.     return ref;
  3922.   return change_address (ref, VOIDmode,
  3923.              memory_address (GET_MODE (ref), XEXP (ref, 0)));
  3924. }
  3925.  
  3926. /* Assign RTL expressions to the function's parameters.
  3927.    This may involve copying them into registers and using
  3928.    those registers as the RTL for them.  */
  3929.  
  3930. void
  3931. assign_parms (fndecl)
  3932.      tree fndecl;
  3933. {
  3934.   register tree parm;
  3935.   register rtx entry_parm;
  3936.   register rtx stack_parm;
  3937.   register CUMULATIVE_ARGS args_so_far;
  3938.   enum machine_mode passed_mode, nominal_mode;
  3939.   /* Total space needed so far for args on the stack,
  3940.      given as a constant and a tree-expression.  */
  3941.   struct args_size stack_args_size;
  3942.   int first_parm_offset = FIRST_PARM_OFFSET (fndecl);
  3943.   tree fntype = TREE_TYPE (fndecl);
  3944.   /* This is used for the arg pointer when referring to stack args.  */
  3945.   rtx internal_arg_pointer;
  3946.  
  3947.   int nparmregs
  3948.     = list_length (DECL_ARGUMENTS (fndecl)) + FIRST_PSEUDO_REGISTER;
  3949.  
  3950.   /* Nonzero if function takes extra anonymous args.
  3951.      This means the last named arg must be on the stack
  3952.      right before the anonymous ones.
  3953.      Also nonzero if the first arg is named `__builtin_va_alist',
  3954.      which is used on some machines for old-fashioned non-ANSI varargs.h;
  3955.      this too should be stuck onto the stack as if it had arrived there.  */
  3956.   int vararg
  3957.     = ((DECL_ARGUMENTS (fndecl) != 0
  3958.     && DECL_NAME (DECL_ARGUMENTS (fndecl))
  3959.     && (! strcmp (IDENTIFIER_POINTER (DECL_NAME (DECL_ARGUMENTS (fndecl))),
  3960.               "__builtin_va_alist")))
  3961.        ||
  3962.        (TYPE_ARG_TYPES (fntype) != 0
  3963.     && (TREE_VALUE (tree_last (TYPE_ARG_TYPES (fntype)))
  3964.         != void_type_node)));
  3965.   int arg_pointer_copied = 0;
  3966.  
  3967. #if ARG_POINTER_REGNUM == FRAME_POINTER_REGNUM
  3968.   internal_arg_pointer = arg_pointer_rtx;
  3969. #else
  3970.   /* If the arg pointer reg is not a fixed reg,
  3971.      make a copy of it, and address parms via the copy.  */
  3972.   if (fixed_regs[ARG_POINTER_REGNUM])
  3973.     internal_arg_pointer = arg_pointer_rtx;
  3974.   else
  3975.     {
  3976.       internal_arg_pointer = copy_to_reg (arg_pointer_rtx);
  3977.       arg_pointer_copied = 1;
  3978.     }
  3979. #endif
  3980.  
  3981.   stack_args_size.constant = 0;
  3982.   stack_args_size.var = 0;
  3983.  
  3984.   /* If struct value address comes on the stack, count it in size of args.  */
  3985.   if (aggregate_value_p (DECL_RESULT (fndecl))
  3986.       && GET_CODE (struct_value_incoming_rtx) == MEM)
  3987.     stack_args_size.constant += GET_MODE_SIZE (Pmode);
  3988.  
  3989.   parm_reg_stack_loc = (rtx *) oballoc (nparmregs * sizeof (rtx));
  3990.   bzero (parm_reg_stack_loc, nparmregs * sizeof (rtx));
  3991.  
  3992.   INIT_CUMULATIVE_ARGS (args_so_far, fntype);
  3993.  
  3994.   for (parm = DECL_ARGUMENTS (fndecl); parm; parm = TREE_CHAIN (parm))
  3995.     {
  3996.       int aggregate
  3997.     = (TREE_CODE (TREE_TYPE (parm)) == ARRAY_TYPE
  3998.        || TREE_CODE (TREE_TYPE (parm)) == RECORD_TYPE
  3999.        || TREE_CODE (TREE_TYPE (parm)) == UNION_TYPE);
  4000.       struct args_size stack_offset;
  4001.       rtx stack_offset_rtx;
  4002.       enum direction where_pad;
  4003.       /* Extra bytes to add in after parameter is assigned, in
  4004.      case where argument cannot be assigned an offsetted
  4005.      location.  For example, BLKmode parameters cannot be
  4006.      other than on a word boundary (no matter the size)
  4007.      because `access_parm_map' does not know how to handle
  4008.      that case.  */
  4009.       int extra = 0;
  4010.  
  4011.       DECL_OFFSET (parm) = -1;
  4012.  
  4013.       if (TREE_TYPE (parm) == error_mark_node
  4014.       /* This can happen after weird syntax errors
  4015.          or if an enum type is defined among the parms.  */
  4016.       || TREE_CODE (parm) != PARM_DECL
  4017.       || DECL_ARG_TYPE (parm) == NULL)
  4018.     {
  4019.       DECL_RTL (parm) = gen_rtx (MEM, BLKmode, const0_rtx);
  4020.       TREE_USED (parm) = 1;
  4021.       continue;
  4022.     }
  4023.  
  4024.       /* Find mode of arg as it is passed, and mode of arg
  4025.      as it should be during execution of this function.  */
  4026.       passed_mode = TYPE_MODE (DECL_ARG_TYPE (parm));
  4027.       nominal_mode = TYPE_MODE (TREE_TYPE (parm));
  4028.  
  4029.       /* Get this parm's offset as an rtx.  */
  4030.       stack_offset = stack_args_size;
  4031.       stack_offset.constant += first_parm_offset;
  4032.  
  4033.       /* If this argument needs more than the usual parm alignment, do
  4034.      extrinsic padding to reach that alignment.  */
  4035.  
  4036. #ifdef MAX_PARM_BOUNDARY
  4037.       /* If MAX_PARM_BOUNDARY is not defined, it means that the usual
  4038.      alignment requirements are relaxed for parms, and that no parm
  4039.      needs more alignment than PARM_BOUNDARY, regardless of data type.  */
  4040.  
  4041.       if (PARM_BOUNDARY < TYPE_ALIGN (DECL_ARG_TYPE (parm)))
  4042.     {
  4043.       int boundary = PARM_BOUNDARY;
  4044.  
  4045.       /* Determine the boundary to pad up to.  */
  4046.       if (TYPE_ALIGN (DECL_ARG_TYPE (parm)) > boundary)
  4047.         boundary = TYPE_ALIGN (DECL_ARG_TYPE (parm));
  4048.       if (boundary > MAX_PARM_BOUNDARY)
  4049.         boundary = MAX_PARM_BOUNDARY;
  4050.  
  4051.       /* If the previous args don't reach such a boundary,
  4052.          advance to the next one.  */
  4053.       boundary /= BITS_PER_UNIT;
  4054.       stack_offset.constant += boundary - 1;
  4055.       stack_offset.constant &= ~(boundary - 1);
  4056.       stack_args_size.constant += boundary - 1;
  4057.       stack_args_size.constant &= ~(boundary - 1);
  4058.  
  4059.       if (stack_offset.var != 0)
  4060.         abort ();        /* This case not implemented yet */
  4061.     }
  4062. #endif /* MAX_PARM_BOUNDARY */
  4063.  
  4064.       /* Find out if the parm needs intrinsic padding (up to PARM_BOUNDARY),
  4065.      and whether above or below.  */
  4066.  
  4067.       where_pad
  4068.     = FUNCTION_ARG_PADDING (passed_mode,
  4069.                 expand_expr (size_in_bytes (DECL_ARG_TYPE (parm)),
  4070.                          0, VOIDmode, 0));
  4071.  
  4072.       /* If arg should be padded below, adjust the stack address upward.
  4073.      This padding is considered part of the space occupied by the
  4074.      argument.  It pads only up to PARM_BOUNDARY, and it does not
  4075.      depend on the previous arguments, since they are assumed to
  4076.      occupy a multiple of PARM_BOUNDARY.  */
  4077.  
  4078.       if (where_pad == downward)
  4079.     {
  4080.       if (passed_mode != BLKmode)
  4081.         {
  4082.           if (GET_MODE_BITSIZE (passed_mode) % PARM_BOUNDARY)
  4083.         stack_offset.constant
  4084.           += (((GET_MODE_BITSIZE (passed_mode) + PARM_BOUNDARY - 1)
  4085.                / PARM_BOUNDARY * PARM_BOUNDARY / BITS_PER_UNIT)
  4086.               - GET_MODE_SIZE (passed_mode));
  4087.         }
  4088.       else
  4089.         {
  4090.           tree sizetree = size_in_bytes (DECL_ARG_TYPE (parm));
  4091.           if (TREE_INT_CST_LOW (sizetree) * BITS_PER_UNIT != PARM_BOUNDARY)
  4092.         {
  4093.           /* Round the size up to multiple of PARM_BOUNDARY bits.  */
  4094.           tree s1 = convert_units (sizetree, BITS_PER_UNIT, PARM_BOUNDARY);
  4095.           tree s2 = convert_units (s1, PARM_BOUNDARY, BITS_PER_UNIT);
  4096.           /* Add it in.  */
  4097.           ADD_PARM_SIZE (stack_offset, s2);
  4098.           SUB_PARM_SIZE (stack_offset, sizetree);
  4099.           extra = stack_offset.constant % UNITS_PER_WORD;
  4100.           stack_offset.constant -= extra;
  4101.         }
  4102.         }
  4103.     }
  4104.  
  4105.       stack_offset_rtx = ARGS_SIZE_RTX (stack_offset);
  4106.  
  4107.       /* Determine parm's home in the stack,
  4108.      in case it arrives in the stack or we should pretend it did.  */
  4109.       stack_parm
  4110.     = gen_rtx (MEM, passed_mode,
  4111.            memory_address (passed_mode,
  4112.                    gen_rtx (PLUS, Pmode,
  4113.                         internal_arg_pointer,
  4114.                         stack_offset_rtx)));
  4115.  
  4116.       /* If this is a memory ref that contains aggregate components,
  4117.      mark it as such for cse and loop optimize.  */
  4118.       MEM_IN_STRUCT_P (stack_parm) = aggregate;
  4119.  
  4120.       /* Let machine desc say which reg (if any) the parm arrives in.
  4121.      0 means it arrives on the stack.  */
  4122.       entry_parm = 0;
  4123.       /* Variable-size args, and args following such, are never in regs.  */
  4124.       if (TREE_CODE (TYPE_SIZE (TREE_TYPE (parm))) == INTEGER_CST
  4125.       || stack_offset.var != 0)
  4126.     {
  4127.       /* Set LAST_NAMED if this is last named arg before some
  4128.          anonymous args.  We treat it as if it were anonymous too.  */
  4129.       int last_named = (TREE_CHAIN (parm) == 0 && vararg);
  4130. #ifdef FUNCTION_INCOMING_ARG
  4131.       entry_parm
  4132.         = FUNCTION_INCOMING_ARG (args_so_far, passed_mode,
  4133.                      DECL_ARG_TYPE (parm), ! last_named);
  4134. #else
  4135.       entry_parm
  4136.         = FUNCTION_ARG (args_so_far, passed_mode, DECL_ARG_TYPE (parm),
  4137.                 ! last_named);
  4138. #endif
  4139.     }
  4140.  
  4141.       /* If this parm was passed part in regs and part in memory,
  4142.      pretend it arrived entirely in memory
  4143.      by pushing the register-part onto the stack.
  4144.  
  4145.      In the special case of a DImode or DFmode that is split,
  4146.      we could put it together in a pseudoreg directly,
  4147.      but for now that's not worth bothering with.  */
  4148.  
  4149.       if (entry_parm)
  4150.     {
  4151.       int nregs = 0;
  4152.       int i;
  4153. #ifdef FUNCTION_ARG_PARTIAL_NREGS
  4154.       nregs = FUNCTION_ARG_PARTIAL_NREGS (args_so_far, passed_mode,
  4155.                           DECL_ARG_TYPE (parm), 1);
  4156. #endif
  4157.  
  4158. #if 0 /* Replaced by new calling convention
  4159.      which actually passes these args on the stack.  */
  4160.       /* If this is the last named arg and anonymous args follow,
  4161.          likewise pretend this arg arrived on the stack
  4162.          so varargs can find the anonymous args following it.  */
  4163.       if (TREE_CHAIN (parm) == 0 && vararg)
  4164.         {
  4165.           if (GET_MODE (entry_parm) == BLKmode)
  4166.         nregs = GET_MODE_SIZE (GET_MODE (entry_parm)) / UNITS_PER_WORD;
  4167.           else
  4168.         nregs = (int_size_in_bytes (DECL_ARG_TYPE (parm))
  4169.              / UNITS_PER_WORD);
  4170.         }
  4171. #endif /* 0 */
  4172.  
  4173.       if (nregs > 0)
  4174.         {
  4175.           current_function_pretend_args_size
  4176.         = (((nregs * UNITS_PER_WORD) + (PARM_BOUNDARY / BITS_PER_UNIT) - 1)
  4177.            / (PARM_BOUNDARY / BITS_PER_UNIT)
  4178.            * (PARM_BOUNDARY / BITS_PER_UNIT));
  4179.  
  4180.           i = nregs;
  4181.           while (--i >= 0)
  4182.         emit_move_insn (gen_rtx (MEM, SImode,
  4183.                      plus_constant (XEXP (stack_parm, 0),
  4184.                             i * GET_MODE_SIZE (SImode))),
  4185.                 gen_rtx (REG, SImode, REGNO (entry_parm) + i));
  4186.           entry_parm = stack_parm;
  4187.         }
  4188.     }
  4189.  
  4190.       /* If we didn't decide this parm came in a register,
  4191.      by default it came on the stack.  */
  4192.       if (entry_parm == 0)
  4193.     entry_parm = stack_parm;
  4194.  
  4195.       /* For a stack parm, record in DECL_OFFSET the arglist offset
  4196.      of the parm at the time it is passed (before conversion).  */
  4197.       if (entry_parm == stack_parm)
  4198.     DECL_OFFSET (parm) = stack_offset.constant * BITS_PER_UNIT;
  4199.  
  4200.       /* If there is actually space on the stack for this parm,
  4201.      count it in stack_args_size; otherwise set stack_parm to 0
  4202.      to indicate there is no preallocated stack slot for the parm.  */
  4203.  
  4204.       if (entry_parm == stack_parm
  4205. #ifdef REG_PARM_STACK_SPACE
  4206.       /* On some machines, even if a parm value arrives in a register
  4207.          there is still an (uninitialized) stack slot allocated for it.  */
  4208.       || 1
  4209. #endif
  4210.       )
  4211.     {
  4212.       tree sizetree = size_in_bytes (DECL_ARG_TYPE (parm));
  4213.       if (where_pad != none
  4214.           && TREE_INT_CST_LOW (sizetree) * BITS_PER_UNIT != PARM_BOUNDARY)
  4215.         {
  4216.           /* Round the size up to multiple of PARM_BOUNDARY bits.  */
  4217.           tree s1 = convert_units (sizetree, BITS_PER_UNIT, PARM_BOUNDARY);
  4218.           sizetree = convert_units (s1, PARM_BOUNDARY, BITS_PER_UNIT);
  4219.         }
  4220.       /* Add it in.  */
  4221.       ADD_PARM_SIZE (stack_args_size, sizetree);
  4222.     }
  4223.       else
  4224.     /* No stack slot was pushed for this parm.  */
  4225.     stack_parm = 0;
  4226.  
  4227.       /* Now adjust STACK_PARM to the mode and precise location
  4228.      where this parameter should live during execution,
  4229.      if we discover that it must live in the stack during execution.
  4230.      To make debuggers happier on big-endian machines, we store
  4231.      the value in the last bytes of the space available.  */
  4232.  
  4233.       if (nominal_mode != BLKmode && nominal_mode != passed_mode
  4234.       && stack_parm != 0)
  4235.     {
  4236. #ifdef BYTES_BIG_ENDIAN
  4237.       if (GET_MODE_SIZE (nominal_mode) < UNITS_PER_WORD)
  4238.         {
  4239.           stack_offset.constant
  4240.         += GET_MODE_SIZE (passed_mode)
  4241.           - GET_MODE_SIZE (nominal_mode);
  4242.           stack_offset_rtx = ARGS_SIZE_RTX (stack_offset);
  4243.         }
  4244. #endif
  4245.  
  4246.       stack_parm
  4247.         = gen_rtx (MEM, nominal_mode,
  4248.                memory_address (nominal_mode,
  4249.                        gen_rtx (PLUS, Pmode,
  4250.                         arg_pointer_rtx,
  4251.                         stack_offset_rtx)));
  4252.  
  4253.       /* If this is a memory ref that contains aggregate components,
  4254.          mark it as such for cse and loop optimize.  */
  4255.       MEM_IN_STRUCT_P (stack_parm) = aggregate;
  4256.     }
  4257.  
  4258.       /* If there is rounding to do for a BLKmode parameter,
  4259.      add it in here, since STACK_OFFSET is not used for the
  4260.      rest of this iteration.  */
  4261.       stack_offset.constant += extra;
  4262.  
  4263.       /* ENTRY_PARM is an RTX for the parameter as it arrives,
  4264.      in the mode in which it arrives.
  4265.      STACK_PARM is an RTX for a stack slot where the parameter can live
  4266.      during the function (in case we want to put it there).
  4267.      STACK_PARM is 0 if no stack slot was pushed for it.
  4268.  
  4269.      Now output code if necessary to convert ENTRY_PARM to
  4270.      the type in which this function declares it,
  4271.      and store that result in an appropriate place,
  4272.      which may be a pseudo reg, may be STACK_PARM,
  4273.      or may be a local stack slot if STACK_PARM is 0.
  4274.  
  4275.      Set DECL_RTL to that place.  */
  4276.  
  4277.       if (nominal_mode == BLKmode)
  4278.     {
  4279.       /* If a BLKmode arrives in registers, copy it to a stack slot.  */
  4280.       if (GET_CODE (entry_parm) == REG)
  4281.         {
  4282.           if (stack_parm == 0)
  4283.         stack_parm
  4284.           = assign_stack_local (GET_MODE (entry_parm),
  4285.                     int_size_in_bytes (TREE_TYPE (parm)));
  4286.  
  4287.           move_block_from_reg (REGNO (entry_parm), stack_parm,
  4288.                    ((int_size_in_bytes (TREE_TYPE (parm))
  4289.                      + UNITS_PER_WORD - 1)
  4290.                     / UNITS_PER_WORD));
  4291.         }
  4292.       else if (vararg)
  4293.         {
  4294.           /* If this function uses varargs, and `__builtin_saveregs'
  4295.          can clobber this stack location, then protect it.  */
  4296.           rtx pseudo_parm;
  4297. #ifdef FUNCTION_INCOMING_ARG
  4298.           pseudo_parm
  4299.         = FUNCTION_INCOMING_ARG (args_so_far, SImode,
  4300.                      integer_type_node, 1);
  4301. #else
  4302.           pseudo_parm
  4303.         = FUNCTION_ARG (args_so_far, SImode,
  4304.                 integer_type_node, 1);
  4305. #endif
  4306.           if (pseudo_parm && GET_CODE (pseudo_parm) == REG)
  4307.         {
  4308.           push_to_sequence (save_from_saveregs);
  4309.           move_block_to_reg (REGNO (pseudo_parm), stack_parm,
  4310.                      int_size_in_bytes (TREE_TYPE (parm))
  4311.                      / UNITS_PER_WORD);
  4312.           save_from_saveregs = get_insns ();
  4313.           end_sequence (0);
  4314.         }
  4315.         }
  4316.       DECL_RTL (parm) = stack_parm;
  4317.     }
  4318.       else if (! ((obey_regdecls && ! TREE_REGDECL (parm)
  4319.            && ! TREE_INLINE (fndecl))
  4320.           /* layout_decl may set this.  */
  4321.           || TREE_ADDRESSABLE (parm)
  4322.           || TREE_VOLATILE (parm)
  4323.           /* If -ffloat-store specified, don't put explicit
  4324.              float variables into registers.  */
  4325.           || (flag_float_store
  4326.               && TREE_CODE (TREE_TYPE (parm)) == REAL_TYPE)))
  4327.     {
  4328.       /* Store the parm in a pseudoregister during the function.  */
  4329.       register rtx parmreg = gen_reg_rtx (nominal_mode);
  4330.  
  4331.       REG_USERVAR_P (parmreg) = 1;
  4332.       DECL_RTL (parm) = parmreg;
  4333.  
  4334.       /* Copy the value into the register.  */
  4335.       if (GET_MODE (parmreg) != GET_MODE (entry_parm))
  4336.         convert_move (parmreg, validize_mem (entry_parm), 0);
  4337.       else
  4338.         emit_move_insn (parmreg, validize_mem (entry_parm));
  4339.  
  4340.       /* In any case, record the parm's desired stack location
  4341.          in case we later discover it must live in the stack.  */
  4342.       if (REGNO (parmreg) >= nparmregs)
  4343.         {
  4344.           rtx *new;
  4345.           nparmregs = REGNO (parmreg) + 5;
  4346.           new = (rtx *) oballoc (nparmregs * sizeof (rtx));
  4347.           bcopy (parm_reg_stack_loc, new, nparmregs * sizeof (rtx));
  4348.           parm_reg_stack_loc = new;
  4349.         }
  4350.       parm_reg_stack_loc[REGNO (parmreg)] = stack_parm;
  4351.  
  4352.       /* Mark the register as eliminable if we did no conversion
  4353.          and it was copied from memory at a fixed offset,
  4354.          and the arg pointer was not copied to a pseudo-reg.
  4355.          If the arg pointer is a pseudo reg, such memory-equivalences
  4356.          as we make here would screw up life analysis for it.  */
  4357.       if (nominal_mode == passed_mode
  4358.           && GET_CODE (entry_parm) == MEM
  4359.           && stack_offset.var == 0
  4360.           && ! arg_pointer_copied)
  4361.         REG_NOTES (get_last_insn ())
  4362.           = gen_rtx (EXPR_LIST, REG_EQUIV,
  4363.              entry_parm, REG_NOTES (get_last_insn ()));
  4364.  
  4365.       /* For pointer data type, suggest pointer register.  */
  4366.       if (TREE_CODE (TREE_TYPE (parm)) == POINTER_TYPE)
  4367.         mark_reg_pointer (parmreg);
  4368.     }
  4369.       else
  4370.     {
  4371.       /* Value must be stored in the stack slot STACK_PARM
  4372.          during function execution.  */
  4373.  
  4374.       if (passed_mode != nominal_mode)
  4375.         /* Conversion is required.  */
  4376.         entry_parm = convert_to_mode (nominal_mode, entry_parm, 0);
  4377.  
  4378.       if (entry_parm != stack_parm)
  4379.         {
  4380.           if (stack_parm == 0)
  4381.         stack_parm = assign_stack_local (GET_MODE (entry_parm),
  4382.                          GET_MODE_SIZE (GET_MODE (entry_parm)));
  4383.           emit_move_insn (validize_mem (stack_parm),
  4384.                   validize_mem (entry_parm));
  4385.         }
  4386.  
  4387.       DECL_RTL (parm) = stack_parm;
  4388.       frame_pointer_needed = 1;
  4389.     }
  4390.       
  4391.       if (TREE_VOLATILE (parm))
  4392.     MEM_VOLATILE_P (DECL_RTL (parm)) = 1;
  4393.       if (TREE_READONLY (parm))
  4394.     RTX_UNCHANGING_P (DECL_RTL (parm)) = 1;
  4395.  
  4396.       /* Update info on where next arg arrives in registers.  */
  4397.  
  4398.       FUNCTION_ARG_ADVANCE (args_so_far, passed_mode, DECL_ARG_TYPE (parm), 1);
  4399.     }
  4400.  
  4401.   max_parm_reg = max_reg_num ();
  4402.   last_parm_insn = get_last_insn ();
  4403.  
  4404.   current_function_args_size = stack_args_size.constant;
  4405.  
  4406. #ifdef NeXT
  4407.   stack_args_size.constant += first_parm_offset;
  4408.   current_function_arg_offset_rtx = ARGS_SIZE_RTX (stack_args_size);
  4409. #endif  /* NeXT */
  4410. }
  4411.  
  4412. /* Allocation of space for returned structure values.
  4413.    During the rtl generation pass, `get_structure_value_addr'
  4414.    is called from time to time to request the address of a block in our
  4415.    stack frame in which called functions will store the structures
  4416.    they are returning.  The same space is used for all of these blocks.  
  4417.  
  4418.    We allocate these blocks like stack locals.  We keep reusing
  4419.    the same block until a bigger one is needed.  */
  4420.  
  4421. /* Length in bytes of largest structure value returned by
  4422.    any function called so far in this function.  */
  4423. static int max_structure_value_size;
  4424.  
  4425. /* An rtx for the addr we are currently using for structure values.
  4426.    This is typically (PLUS (REG:SI stackptr) (CONST_INT...)).  */
  4427. static rtx structure_value;
  4428.  
  4429. rtx
  4430. get_structure_value_addr (sizex)
  4431.      rtx sizex;
  4432. {
  4433.   register int size;
  4434.   if (GET_CODE (sizex) != CONST_INT)
  4435.     abort ();
  4436.   size = INTVAL (sizex);
  4437.  
  4438.   /* Round up to a multiple of the main allocation unit.  */
  4439.   size = (((size + (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - 1)
  4440.        / (BIGGEST_ALIGNMENT / BITS_PER_UNIT))
  4441.       * (BIGGEST_ALIGNMENT / BITS_PER_UNIT));
  4442.  
  4443.   /* If this size is bigger than space we know to use,
  4444.      get a bigger piece of space.  */
  4445.   if (size > max_structure_value_size)
  4446.     {
  4447.       max_structure_value_size = size;
  4448.       structure_value = assign_stack_local (BLKmode, size);
  4449.       if (GET_CODE (structure_value) == MEM)
  4450.     structure_value = XEXP (structure_value, 0);
  4451.     }
  4452.  
  4453.   return structure_value;
  4454. }
  4455.  
  4456. /* Walk the tree of LET_STMTs describing the binding levels within a function
  4457.    and warn about uninitialized variables.
  4458.    This is done after calling flow_analysis and before global_alloc
  4459.    clobbers the pseudo-regs to hard regs.  */
  4460.  
  4461. void
  4462. uninitialized_vars_warning (block)
  4463.      tree block;
  4464. {
  4465.   register tree decl, sub;
  4466.   for (decl = STMT_VARS (block); decl; decl = TREE_CHAIN (decl))
  4467.     {
  4468.       if (TREE_CODE (decl) == VAR_DECL
  4469.       /* These warnings are unreliable for and aggregates
  4470.          because assigning the fields one by one can fail to convince
  4471.          flow.c that the entire aggregate was initialized.
  4472.          Unions are troublesome because members may be shorter.  */
  4473.       && TREE_CODE (TREE_TYPE (decl)) != RECORD_TYPE
  4474.       && TREE_CODE (TREE_TYPE (decl)) != UNION_TYPE
  4475.       && TREE_CODE (TREE_TYPE (decl)) != ARRAY_TYPE
  4476.       && DECL_RTL (decl) != 0
  4477.       && GET_CODE (DECL_RTL (decl)) == REG
  4478.       && regno_uninitialized (REGNO (DECL_RTL (decl))))
  4479.     warning_with_decl (decl,
  4480.                "`%s' may be used uninitialized in this function");
  4481.       if (TREE_CODE (decl) == VAR_DECL
  4482.       && DECL_RTL (decl) != 0
  4483.       && GET_CODE (DECL_RTL (decl)) == REG
  4484.       && regno_clobbered_at_setjmp (REGNO (DECL_RTL (decl))))
  4485.     warning_with_decl (decl,
  4486.                "variable `%s' may be clobbered by `longjmp'");
  4487.     }
  4488.   for (sub = STMT_SUBBLOCKS (block); sub; sub = TREE_CHAIN (sub))
  4489.     uninitialized_vars_warning (sub);
  4490. }
  4491.  
  4492. /* If this function call setjmp, put all vars into the stack
  4493.    unless they were declared `register'.  */
  4494.  
  4495. void
  4496. setjmp_protect (block)
  4497.      tree block;
  4498. {
  4499.   register tree decl, sub;
  4500.   for (decl = STMT_VARS (block); decl; decl = TREE_CHAIN (decl))
  4501.     if ((TREE_CODE (decl) == VAR_DECL
  4502.      || TREE_CODE (decl) == PARM_DECL)
  4503.     && DECL_RTL (decl) != 0
  4504.     && GET_CODE (DECL_RTL (decl)) == REG
  4505.     && ! TREE_REGDECL (decl))
  4506.       put_var_into_stack (decl);
  4507.   for (sub = STMT_SUBBLOCKS (block); sub; sub = TREE_CHAIN (sub))
  4508.     setjmp_protect (sub);
  4509. }
  4510.  
  4511. /* Generate RTL for the start of the function SUBR (a FUNCTION_DECL tree node)
  4512.    and initialize static variables for generating RTL for the statements
  4513.    of the function.  */
  4514.  
  4515. void
  4516. init_function_start (subr)
  4517.      tree subr;
  4518. {
  4519.   this_function = subr;
  4520.   cse_not_expected = ! optimize;
  4521.  
  4522.   /* We have not yet found a reason why a frame pointer cannot
  4523.      be omitted for this function in particular, but maybe we know
  4524.      a priori that it is required.
  4525.      `flag_omit_frame_pointer' has its main effect here.  */
  4526.   frame_pointer_needed = FRAME_POINTER_REQUIRED || ! flag_omit_frame_pointer;
  4527.  
  4528.   /* Caller save not needed yet.  */
  4529.   caller_save_needed = 0;
  4530.  
  4531.   /* No gotos have been expanded yet.  */
  4532.   goto_fixup_chain = 0;
  4533.  
  4534.   /* No stack slots have been made yet.  */
  4535.   stack_slot_list = 0;
  4536.  
  4537.   /* No invalid stack slots have been made yet.  */
  4538.   invalid_stack_slot = 0;
  4539.  
  4540.   /* No parm regs have been allocated.
  4541.      (This is important for output_inline_function.)  */
  4542.   max_parm_reg = FIRST_PSEUDO_REGISTER;
  4543.  
  4544.   /* Initialize the RTL mechanism.  */
  4545.   init_emit (write_symbols);
  4546.  
  4547.   /* Initialize the queue of pending postincrement and postdecrements,
  4548.      and some other info in expr.c.  */
  4549.   init_expr ();
  4550.  
  4551.   init_const_rtx_hash_table ();
  4552.  
  4553.   /* Decide whether function should try to pop its args on return.  */
  4554.  
  4555.   current_function_pops_args = RETURN_POPS_ARGS (TREE_TYPE (subr));
  4556.  
  4557.   current_function_name = (char *)lang_printable_name (subr);
  4558.  
  4559.   /* Nonzero if this is a nested function that uses a static chain.  */
  4560.  
  4561.   current_function_needs_context
  4562.     = (DECL_CONTEXT (current_function_decl) != 0
  4563.        && TREE_CODE (DECL_CONTEXT (current_function_decl)) == LET_STMT);
  4564.  
  4565.   /* Set if a call to setjmp is seen.  */
  4566.  
  4567.   current_function_calls_setjmp = 0;
  4568.   current_function_calls_alloca = 0;
  4569.  
  4570.   current_function_returns_pcc_struct = 0;
  4571.   current_function_returns_struct = 0;
  4572.  
  4573.   /* No space assigned yet for structure values.  */
  4574.   max_structure_value_size = 0;
  4575.   structure_value = 0;
  4576.  
  4577.   /* We are not currently within any block, conditional, loop or case.
  4578.      @@ No longer true.  We are within the block for the parms.  */
  4579.   block_stack = 0;
  4580.   loop_stack = 0;
  4581.   case_stack = 0;
  4582.   cond_stack = 0;
  4583.   nesting_stack = 0;
  4584.   nesting_depth = 0;
  4585.  
  4586.   block_start_count = 0;
  4587.  
  4588.   /* We have not yet needed to make a label to jump to for tail-recursion.  */
  4589.   tail_recursion_label = 0;
  4590.  
  4591.   /* No stack slots allocated yet.  */
  4592.   frame_offset = STARTING_FRAME_OFFSET;
  4593.  
  4594.   /* No SAVE_EXPRs in this function yet.  */
  4595.   save_expr_regs = 0;
  4596.  
  4597.   /* No parameters to protect from `__builtin_saveregs' yet.  */
  4598.   save_from_saveregs = 0;
  4599.  
  4600.   /* No RTL_EXPRs in this function yet.  */
  4601.   rtl_expr_chain = 0;
  4602.  
  4603.   /* Within function body, compute a type's size as soon it is laid out.  */
  4604.   immediate_size_expand++;
  4605.  
  4606.   init_pending_stack_adjust ();
  4607.   inhibit_defer_pop = 0;
  4608.   current_function_pretend_args_size = 0;
  4609.  
  4610.   /* Prevent ever trying to delete the first instruction of a function.
  4611.      Also tell final how to output a linenum before the function prologue.  */
  4612.   emit_line_note (DECL_SOURCE_FILE (subr), DECL_SOURCE_LINE (subr));
  4613.   /* Make sure first insn is a note even if we don't want linenums.
  4614.      This makes sure the first insn will never be deleted.
  4615.      Also, final expects a note to appear there.  */
  4616.   emit_note (0, NOTE_INSN_DELETED);
  4617.   /* Indicate the beginning of the function body,
  4618.      as opposed to parm setup.  */
  4619.   emit_note (0, NOTE_INSN_FUNCTION_BEG);
  4620.  
  4621.   /* Set flags used by final.c.  */
  4622.   if (aggregate_value_p (DECL_RESULT (subr)))
  4623.     {
  4624. #ifdef PCC_STATIC_STRUCT_RETURN
  4625.       if (flag_pcc_struct_return)
  4626.     current_function_returns_pcc_struct = 1;
  4627.       else
  4628. #endif
  4629.     current_function_returns_struct = 1;
  4630.     }
  4631. }
  4632.  
  4633. /* Start the RTL for a new function, and set variables used for
  4634.    emitting RTL.
  4635.    SUBR is the FUNCTION_DECL node.
  4636.    PARMS_HAVE_CLEANUPS is nonzero if there are cleanups associated with
  4637.    the function's parameters, which must be run at any return statement.  */
  4638.  
  4639. void
  4640. expand_function_start (subr, parms_have_cleanups)
  4641.      tree subr;
  4642.      int parms_have_cleanups;
  4643. {
  4644.   register int i;
  4645.   tree tem;
  4646.  
  4647.   /* Make sure volatile mem refs aren't considered
  4648.      valid operands of arithmetic insns.  */
  4649.   init_recog ();
  4650.  
  4651.   /* If the parameters of this function need cleaning up, get a label
  4652.      for the beginning of the code which executes those cleanups.  This must
  4653.      be done before doing anything with return_label.  */
  4654.   if (parms_have_cleanups)
  4655.     cleanup_label = gen_label_rtx ();
  4656.   else
  4657.     cleanup_label = 0;
  4658.  
  4659.   /* Make the label for return statements to jump to, if this machine
  4660.      does not have a one-instruction return and uses an epilogue,
  4661.      or if it returns a structure, or if it has parm cleanups.  */
  4662. #ifdef HAVE_return
  4663.   if (cleanup_label == 0 && HAVE_return
  4664.       && ! current_function_returns_pcc_struct
  4665.       && ! (current_function_returns_struct && ! optimize))
  4666.     return_label = 0;
  4667.   else
  4668.     return_label = gen_label_rtx ();
  4669. #else
  4670.   return_label = gen_label_rtx ();
  4671. #endif
  4672.  
  4673.   /* Initialize rtx used to return the value.  */
  4674.   /* Do this before assign_parms so that we copy the struct value address
  4675.      before any library calls that assign parms might generate.  */
  4676.  
  4677.   /* Decide whether to return the value in memory or in a register.  */
  4678.   if (aggregate_value_p (DECL_RESULT (subr)))
  4679.     {
  4680.       /* Returning something that won't go in a register.  */
  4681.       register rtx value_address;
  4682.  
  4683. #ifdef PCC_STATIC_STRUCT_RETURN
  4684.       if (flag_pcc_struct_return)
  4685.     {
  4686.       int size = int_size_in_bytes (TREE_TYPE (DECL_RESULT (subr)));
  4687.       value_address = assemble_static_space (size);
  4688.       current_function_returns_pcc_struct = 1;
  4689.     }
  4690.       else
  4691. #endif
  4692.     {
  4693.       /* Expect to be passed the address of a place to store the value.  */
  4694.       value_address = gen_reg_rtx (Pmode);
  4695.       emit_move_insn (value_address, struct_value_incoming_rtx);
  4696.       current_function_returns_struct = 1;
  4697.     }
  4698.       DECL_RTL (DECL_RESULT (subr))
  4699.     = gen_rtx (MEM, DECL_MODE (DECL_RESULT (subr)),
  4700.            value_address);
  4701.     }
  4702.   else if (DECL_MODE (DECL_RESULT (subr)) == VOIDmode)
  4703.     /* If return mode is void, this decl rtl should not be used.  */
  4704.     DECL_RTL (DECL_RESULT (subr)) = 0;
  4705.   else if (parms_have_cleanups)
  4706.     {
  4707.       /* If function will end with cleanup code for parms,
  4708.      compute the return values into a pseudo reg,
  4709.      which we will copy into the true return register
  4710.      after the cleanups are done.  */
  4711.       DECL_RTL (DECL_RESULT (subr))
  4712.     = gen_reg_rtx (DECL_MODE (DECL_RESULT (subr)));
  4713.       TREE_REGDECL (DECL_RESULT (subr)) = 1;
  4714.     }
  4715.   else
  4716.     /* Scalar, returned in a register.  */
  4717.     {
  4718. #ifdef FUNCTION_OUTGOING_VALUE
  4719.       DECL_RTL (DECL_RESULT (subr))
  4720.     = FUNCTION_OUTGOING_VALUE (TREE_TYPE (DECL_RESULT (subr)), subr);
  4721. #else
  4722.       DECL_RTL (DECL_RESULT (subr))
  4723.     = FUNCTION_VALUE (TREE_TYPE (DECL_RESULT (subr)), subr);
  4724. #endif
  4725.  
  4726.       current_function_returns_pointer 
  4727.     = (TREE_CODE (DECL_RESULT_TYPE (subr)) == POINTER_TYPE);
  4728.  
  4729.       /* Mark this reg as the function's return value.  */
  4730.       if (GET_CODE (DECL_RTL (DECL_RESULT (subr))) == REG)
  4731.     {
  4732.       REG_FUNCTION_VALUE_P (DECL_RTL (DECL_RESULT (subr))) = 1;
  4733.       TREE_REGDECL (DECL_RESULT (subr)) = 1;
  4734.     }
  4735.     }
  4736.  
  4737.   /* Initialize rtx for parameters and local variables.
  4738.      In some cases this requires emitting insns.  */
  4739.  
  4740.   assign_parms (subr);
  4741.  
  4742. #if 0
  4743.   /* Not yet defined in GCC 1.37.1.  */
  4744.  
  4745.   /* Tell final that the parameters are in the final places
  4746.      (either on the stack or in registers).  */
  4747.   emit_note ((char *) 0, NOTE_INSN_PARMS_HOMED);
  4748. #endif
  4749.  
  4750.   /* If doing stupid allocation, mark parms as born here.  */
  4751.  
  4752.   if (GET_CODE (get_last_insn ()) != NOTE)
  4753.     emit_note (0, NOTE_INSN_DELETED);
  4754.   parm_birth_insn = get_last_insn ();
  4755.  
  4756.   if (obey_regdecls)
  4757.     {
  4758.       for (i = FIRST_PSEUDO_REGISTER; i < max_parm_reg; i++)
  4759.     use_variable (regno_reg_rtx[i]);
  4760.     }
  4761.  
  4762.   /* After the parm initializations is where the tail-recursion label
  4763.      should go, if we end up needing one.  */
  4764.   tail_recursion_reentry = get_last_insn ();
  4765.  
  4766.   /* Evaluate now the sizes of any types declared among the arguments.  */
  4767.   for (tem = get_pending_sizes (); tem; tem = TREE_CHAIN (tem))
  4768.     expand_expr (TREE_VALUE (tem), 0, VOIDmode, 0);
  4769.  
  4770.   /* Make sure there is a line number after the function entry setup code.
  4771.      There normally is one anyway, from the following statement,
  4772.      but there could fail to be one if there is no newline here.  */
  4773.   force_next_line_note ();
  4774. }
  4775.  
  4776. /* Generate RTL for the end of the current function.
  4777.    FILENAME and LINE are the current position in the source file.  */
  4778.  
  4779. /* ??? Nobody seems to emit the cleanup_label and the cleanups themselves.
  4780.  
  4781.    !!! Not true.  finish_function does this is cplus-decl.c.  */
  4782.  
  4783. void
  4784. expand_function_end (filename, line)
  4785.      char *filename;
  4786.      int line;
  4787. {
  4788.   register int i;
  4789.   tree decl;
  4790.   extern rtx sequence_stack;
  4791.  
  4792. #if 0  /* I think unused parms are legitimate enough.  */
  4793.   /* Warn about unused parms.  */
  4794.   if (warn_unused)
  4795.     for (decl = DECL_ARGUMENTS (current_function_decl);
  4796.      decl; decl = TREE_CHAIN (decl))
  4797.       if (! TREE_USED (decl) && TREE_CODE (decl) == VAR_DECL)
  4798.     warning_with_decl (decl, "unused parameter `%s'");
  4799. #endif
  4800.  
  4801.   /* End any sequences that failed to be closed due to syntax errors.  */
  4802.   while (sequence_stack)
  4803.     end_sequence (0);
  4804.  
  4805.   /* Outside function body, can't compute type's actual size
  4806.      until next function's body starts.  */
  4807.   immediate_size_expand--;
  4808.  
  4809.   /* If doing stupid register allocation,
  4810.      mark register parms as dying here.  */
  4811.  
  4812.   if (obey_regdecls)
  4813.     {
  4814.       rtx tem;
  4815.       for (i = FIRST_PSEUDO_REGISTER; i < max_parm_reg; i++)
  4816.     use_variable (regno_reg_rtx[i]);
  4817.  
  4818.       /* Likewise for the regs of all the SAVE_EXPRs in the function.  */
  4819.  
  4820.       for (tem = save_expr_regs; tem; tem = XEXP (tem, 1))
  4821.     {
  4822.       use_variable (XEXP (tem, 0));
  4823.       use_variable_after (XEXP (tem, 0), parm_birth_insn);
  4824.     }
  4825.     }
  4826.  
  4827.   clear_pending_stack_adjust ();
  4828.   do_pending_stack_adjust ();
  4829.  
  4830.   /* Mark the end of the function body.
  4831.      If control reaches this insn, the function can drop through
  4832.      without returning a value.  */
  4833.   emit_note (0, NOTE_INSN_FUNCTION_END);
  4834.  
  4835.   /* Output a linenumber for the end of the function.
  4836.      SDB depends on this.  */
  4837.   emit_line_note_force (filename, line);
  4838.  
  4839.   /* Output the label for the actual return from the function,
  4840.      if one is expected.  This happens either because a function epilogue
  4841.      is used instead of a return instruction, or because a return was done
  4842.      with a goto in order to run local cleanups, or because of pcc-style
  4843.      structure returning.  */
  4844.  
  4845.   if (return_label)
  4846.     emit_label (return_label);
  4847.  
  4848.   /* If we had calls to alloca, and this machine needs
  4849.      an accurate stack pointer to exit the function,
  4850.      insert some code to save and restore the stack pointer.  */
  4851. #ifdef EXIT_IGNORE_STACK
  4852.   if (! EXIT_IGNORE_STACK)
  4853. #endif
  4854.     if (current_function_calls_alloca)
  4855.       {
  4856.     rtx tem = gen_reg_rtx (Pmode);
  4857.     emit_insn_after (gen_rtx (SET, VOIDmode, tem, stack_pointer_rtx),
  4858.              parm_birth_insn);
  4859.     emit_insn (gen_rtx (SET, VOIDmode, stack_pointer_rtx, tem));
  4860.       }
  4861.  
  4862.   /* If scalar return value was computed in a pseudo-reg,
  4863.      copy that to the hard return register.  */
  4864.   if (DECL_RTL (DECL_RESULT (current_function_decl)) != 0
  4865.       && GET_CODE (DECL_RTL (DECL_RESULT (current_function_decl))) == REG
  4866.       && (REGNO (DECL_RTL (DECL_RESULT (current_function_decl)))
  4867.       >= FIRST_PSEUDO_REGISTER))
  4868.     {
  4869.       rtx real_decl_result;
  4870.  
  4871. #ifdef FUNCTION_OUTGOING_VALUE
  4872.       real_decl_result
  4873.     = FUNCTION_OUTGOING_VALUE (TREE_TYPE (DECL_RESULT (current_function_decl)),
  4874.                    current_function_decl);
  4875. #else
  4876.       real_decl_result
  4877.     = FUNCTION_VALUE (TREE_TYPE (DECL_RESULT (current_function_decl)),
  4878.               current_function_decl);
  4879. #endif
  4880.       REG_FUNCTION_VALUE_P (real_decl_result) = 1;
  4881.       emit_move_insn (real_decl_result,
  4882.               DECL_RTL (DECL_RESULT (current_function_decl)));
  4883.       emit_insn (gen_rtx (USE, VOIDmode, real_decl_result));
  4884.     }
  4885.  
  4886.   /* If returning a structure, arrange to return the address of the value
  4887.      in a place where debuggers expect to find it.  */
  4888.   /* If returning a structure PCC style,
  4889.      the caller also depends on this value.
  4890.      And current_function_returns_pcc_struct is not necessarily set.  */
  4891.   if (current_function_returns_struct
  4892.       || current_function_returns_pcc_struct)
  4893.     {
  4894.       rtx value_address = XEXP (DECL_RTL (DECL_RESULT (current_function_decl)), 0);
  4895.       tree type = TREE_TYPE (DECL_RESULT (current_function_decl));
  4896. #ifdef FUNCTION_OUTGOING_VALUE
  4897.       rtx outgoing
  4898.     = FUNCTION_OUTGOING_VALUE (build_pointer_type (type),
  4899.                    current_function_decl);
  4900. #else
  4901.       rtx outgoing
  4902.     = hard_function_value (build_pointer_type (type),
  4903.                    current_function_decl);
  4904. #endif
  4905.  
  4906. #if 1
  4907.       /* If this works, leave it in.  */
  4908.       /* This is not really the function value,
  4909.      and it confuses integrate.c around line 1211.  */
  4910.       REG_FUNCTION_VALUE_P (outgoing) = 1;
  4911. #endif
  4912.  
  4913.       emit_move_insn (outgoing, value_address);
  4914.       use_variable (outgoing);
  4915.     }
  4916.  
  4917.   /* Output a return insn if we are using one.
  4918.      Otherwise, let the rtl chain end here, to drop through
  4919.      into the epilogue.  */
  4920.  
  4921. #ifdef HAVE_return
  4922.   if (HAVE_return)
  4923.     emit_jump_insn (gen_return ());
  4924. #endif
  4925.  
  4926.   /* Fix up any gotos that jumped out to the outermost
  4927.      binding level of the function.
  4928.      Must follow emitting RETURN_LABEL.  */
  4929.  
  4930.   /* If you have any cleanups to do at this point,
  4931.      and they need to create temporary variables,
  4932.      then you will lose.  */
  4933.   fixup_gotos (0, 0, 0, get_insns (), 0);
  4934. }
  4935.  
  4936. init_stmt ()
  4937. {
  4938.   obstack_init (&stmt_obstack);
  4939.   empty_cleanup_list = build_tree_list (NULL_TREE, NULL_TREE);
  4940. }
  4941.