Annotation of gcc/stmt.c, revision 1.1.1.16

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.