Annotation of gcc/stmt.c, revision 1.1.1.12

1.1       root        1: /* Expands front end tree to back end RTL for GNU C-Compiler
1.1.1.2   root        2:    Copyright (C) 1987,1988 Free Software Foundation, Inc.
1.1       root        3: 
                      4: This file is part of GNU CC.
                      5: 
                      6: GNU CC is distributed in the hope that it will be useful,
                      7: but WITHOUT ANY WARRANTY.  No author or distributor
                      8: accepts responsibility to anyone for the consequences of using it
                      9: or for whether it serves any particular purpose or works at all,
                     10: unless he says so in writing.  Refer to the GNU CC General Public
                     11: License for full details.
                     12: 
                     13: Everyone is granted permission to copy, modify and redistribute
                     14: GNU CC, but only under the conditions described in the
                     15: GNU CC General Public License.   A copy of this license is
                     16: supposed to have been given to you along with GNU CC so you
                     17: can know your rights and responsibilities.  It should be in a
                     18: file named COPYING.  Among other things, the copyright notice
                     19: and this notice must be preserved on all copies.  */
                     20: 
                     21: 
                     22: /* This file handles the generation of rtl code from tree structure
1.1.1.2   root       23:    above the level of expressions, using subroutines in exp*.c and emit-rtl.c.
1.1       root       24:    It also creates the rtl expressions for parameters and auto variables
                     25:    and has full responsibility for allocating stack slots.
                     26: 
1.1.1.2   root       27:    The functions whose names start with `expand_' are called by the
                     28:    parser to generate RTL instructions for various kinds of constructs.
                     29: 
                     30:    Some control and binding constructs require calling several such
                     31:    functions at different times.  For example, a simple if-then
                     32:    is expanded by calling `expand_start_cond' (with the condition-expression
                     33:    as argument) before parsing the then-clause and calling `expand_end_cond'
                     34:    after parsing the then-clause.
                     35: 
1.1.1.10  root       36:    `expand_function_start' is called at the beginning of a function,
                     37:    before the function body is parsed, and `expand_function_end' is
1.1.1.2   root       38:    called after parsing the body.
                     39: 
                     40:    Call `assign_stack_local' to allocate a stack slot for a local variable.
                     41:    This is usually done during the RTL generation for the function body,
                     42:    but it can also be done in the reload pass when a pseudo-register does
                     43:    not get a hard register.
                     44: 
                     45:    Call `put_var_into_stack' when you learn, belatedly, that a variable
                     46:    previously given a pseudo-register must in fact go in the stack.
                     47:    This function changes the DECL_RTL to be a stack slot instead of a reg
                     48:    then scans all the RTL instructions so far generated to correct them.  */
1.1       root       49: 
                     50: #include "config.h"
                     51: 
                     52: #include <stdio.h>
                     53: 
                     54: #include "rtl.h"
                     55: #include "tree.h"
1.1.1.2   root       56: #include "flags.h"
1.1       root       57: #include "insn-flags.h"
1.1.1.2   root       58: #include "insn-config.h"
1.1       root       59: #include "expr.h"
1.1.1.2   root       60: #include "regs.h"
1.1       root       61: 
                     62: #define MAX(x,y) (((x) > (y)) ? (x) : (y))
                     63: #define MIN(x,y) (((x) < (y)) ? (x) : (y))
                     64: 
1.1.1.2   root       65: /* Nonzero if function being compiled pops its args on return.
                     66:    May affect compilation of return insn or of function epilogue.  */
                     67: 
                     68: int current_function_pops_args;
                     69: 
1.1.1.10  root       70: /* Nonzero if function being compiled needs to be given an address
                     71:    where the value should be stored.  */
                     72: 
                     73: int current_function_returns_struct;
                     74: 
                     75: /* Nonzero if function being compiled needs to be passed a static chain.  */
                     76: 
                     77: int current_function_needs_context;
                     78: 
1.1.1.11  root       79: /* Nonzero if function being compiled can call setjmp.  */
                     80: 
                     81: int current_function_calls_setjmp;
                     82: 
1.1.1.2   root       83: /* If function's args have a fixed size, this is that size, in bytes.
                     84:    Otherwise, it is -1.
                     85:    May affect compilation of return insn or of function epilogue.  */
                     86: 
                     87: int current_function_args_size;
                     88: 
                     89: /* # bytes the prologue should push and pretend that the caller pushed them.
                     90:    The prologue must do this, but only if parms can be passed in registers.  */
                     91: 
                     92: int current_function_pretend_args_size;
                     93: 
                     94: /* Name of function now being compiled.  */
                     95: 
                     96: char *current_function_name;
                     97: 
1.1       root       98: /* Label that will go on function epilogue.
                     99:    Jumping to this label serves as a "return" instruction
                    100:    on machines which require execution of the epilogue on all returns.  */
                    101: 
1.1.1.2   root      102: rtx return_label;
1.1       root      103: 
1.1.1.5   root      104: /* List (chain of EXPR_LISTs) of pseudo-regs of SAVE_EXPRs.
                    105:    So we can mark them all live at the end of the function, if nonopt.  */
                    106: rtx save_expr_regs;
                    107: 
                    108: /* Insn after which register parms and SAVE_EXPRs are born, if nonopt.  */
                    109: static rtx parm_birth_insn;
                    110: 
1.1       root      111: /* The FUNCTION_DECL node for the function being compiled.  */
                    112: 
                    113: static tree this_function;
                    114: 
                    115: /* Offset to end of allocated area of stack frame.
                    116:    If stack grows down, this is the address of the last stack slot allocated.
                    117:    If stack grows up, this is the address for the next slot.  */
                    118: static int frame_offset;
                    119: 
1.1.1.2   root      120: /* Nonzero if a stack slot has been generated whose address is not
                    121:    actually valid.  It means that the generated rtl must all be scanned
                    122:    to detect and correct the invalid addresses where they occur.  */
                    123: static int invalid_stack_slot;
1.1       root      124: 
                    125: /* Label to jump back to for tail recursion, or 0 if we have
                    126:    not yet needed one for this function.  */
                    127: static rtx tail_recursion_label;
                    128: 
                    129: /* Place after which to insert the tail_recursion_label if we need one.  */
                    130: static rtx tail_recursion_reentry;
                    131: 
1.1.1.2   root      132: /* Each time we expand an expression-statement,
                    133:    record the expr's type and its RTL value here.  */
                    134: 
                    135: static tree last_expr_type;
                    136: static rtx last_expr_value;
                    137: 
1.1.1.10  root      138: /* Chain of all RTL_EXPRs that have insns in them.  */
                    139: static tree rtl_expr_chain;
                    140: 
1.1.1.8   root      141: /* Last insn of those whose job was to put parms into their nominal homes.  */
                    142: static rtx last_parm_insn;
                    143: 
1.1.1.6   root      144: static void expand_goto_internal ();
                    145: static int expand_fixup ();
1.1.1.2   root      146: static void fixup_gotos ();
1.1.1.7   root      147: static void expand_cleanups ();
                    148: static void fixup_cleanups ();
1.1.1.8   root      149: static void expand_null_return_1 ();
1.1       root      150: static int tail_recursion_args ();
1.1.1.8   root      151: static void fixup_stack_slots ();
1.1.1.2   root      152: static rtx fixup_stack_1 ();
                    153: static rtx fixup_memory_subreg ();
                    154: static void fixup_var_refs ();
1.1.1.10  root      155: static void fixup_var_refs_insns ();
1.1.1.2   root      156: static rtx fixup_var_refs_1 ();
                    157: static rtx parm_stack_loc ();
                    158: static void optimize_bit_field ();
                    159: void do_jump_if_equal ();
1.1       root      160: 
1.1.1.2   root      161: /* Stack of control and binding constructs we are currently inside.
1.1       root      162: 
1.1.1.2   root      163:    These constructs begin when you call `expand_start_WHATEVER'
                    164:    and end when you call `expand_end_WHATEVER'.  This stack records
                    165:    info about how the construct began that tells the end-function
                    166:    what to do.  It also may provide information about the construct
                    167:    to alter the behavior of other constructs within the body.
                    168:    For example, they may affect the behavior of C `break' and `continue'.
                    169: 
                    170:    Each construct gets one `struct nesting' object.
                    171:    All of these objects are chained through the `all' field.
                    172:    `nesting_stack' points to the first object (innermost construct).
                    173:    The position of an entry on `nesting_stack' is in its `depth' field.
                    174: 
                    175:    Each type of construct has its own individual stack.
                    176:    For example, loops have `loop_stack'.  Each object points to the
                    177:    next object of the same type through the `next' field.
                    178: 
                    179:    Some constructs are visible to `break' exit-statements and others
                    180:    are not.  Which constructs are visible depends on the language.
                    181:    Therefore, the data structure allows each construct to be visible
                    182:    or not, according to the args given when the construct is started.
                    183:    The construct is visible if the `exit_label' field is non-null.
                    184:    In that case, the value should be a CODE_LABEL rtx.  */
                    185: 
                    186: struct nesting
1.1       root      187: {
1.1.1.2   root      188:   struct nesting *all;
                    189:   struct nesting *next;
                    190:   int depth;
                    191:   rtx exit_label;
                    192:   union
                    193:     {
                    194:       /* For conds (if-then and if-then-else statements).  */
                    195:       struct
                    196:        {
                    197:          /* Label on the else-part, if any, else 0.  */
                    198:          rtx else_label;
                    199:          /* Label at the end of the whole construct.  */
                    200:          rtx after_label;
                    201:        } cond;
                    202:       /* For loops.  */
                    203:       struct
                    204:        {
                    205:          /* Label at the top of the loop; place to loop back to.  */
                    206:          rtx start_label;
                    207:          /* Label at the end of the whole construct.  */
                    208:          rtx end_label;
                    209:          /* Label for `continue' statement to jump to;
                    210:             this is in front of the stepper of the loop.  */
                    211:          rtx continue_label;
                    212:        } loop;
                    213:       /* For variable binding contours.  */
                    214:       struct
                    215:        {
                    216:          /* Nonzero => value to restore stack to on exit.  */
                    217:          rtx stack_level;
                    218:          /* The NOTE that starts this contour.
                    219:             Used by expand_goto to check whether the destination
                    220:             is within each contour or not.  */
                    221:          rtx first_insn;
                    222:          /* Innermost containing binding contour that has a stack level.  */
                    223:          struct nesting *innermost_stack_block;
1.1.1.7   root      224:          /* List of cleanups to be run on exit from this contour.
                    225:             This is a list of expressions to be evaluated.
                    226:             The TREE_PURPOSE of each link is the ..._DECL node
                    227:             which the cleanup pertains to.  */
                    228:          tree cleanups;
1.1.1.2   root      229:          /* Chain of labels defined inside this binding contour.
1.1.1.8   root      230:             For contours that have stack levels or cleanups.  */
1.1.1.2   root      231:          struct label_chain *label_chain;
                    232:        } block;
                    233:       /* For switch (C) or case (Pascal) statements,
                    234:         and also for dummies (see `expand_start_case_dummy').  */
                    235:       struct
                    236:        {
                    237:          /* The insn after which the case dispatch should finally
                    238:             be emitted.  Zero for a dummy.  */
                    239:          rtx start;
                    240:          /* A list of the case-values and their labels.
                    241:             A chain of TREE_LIST nodes with the value to test for
                    242:             (a constant node) in the TREE_PURPOSE and the
                    243:             label (a LABEL_DECL) in the TREE_VALUE.  */
                    244:          tree case_list;
                    245:          /* The expression to be dispatched on.  */
                    246:          tree index_expr;
                    247:          /* Type that INDEX_EXPR should be converted to.  */
                    248:          tree nominal_type;
1.1.1.7   root      249:          /* Nonzero: a `default' has been seen.  */
                    250:          short has_default;
1.1.1.2   root      251:        } case_stmt;
                    252:     } data;
                    253: };
1.1       root      254: 
1.1.1.2   root      255: /* Chain of all pending binding contours.  */
                    256: struct nesting *block_stack;
1.1       root      257: 
1.1.1.7   root      258: /* Chain of all pending binding contours that restore stack levels
                    259:    or have cleanups.  */
1.1.1.2   root      260: struct nesting *stack_block_stack;
1.1       root      261: 
1.1.1.2   root      262: /* Chain of all pending conditional statements.  */
                    263: struct nesting *cond_stack;
1.1       root      264: 
1.1.1.2   root      265: /* Chain of all pending loops.  */
                    266: struct nesting *loop_stack;
                    267: 
                    268: /* Chain of all pending case or switch statements.  */
                    269: struct nesting *case_stack;
                    270: 
                    271: /* Separate chain including all of the above,
                    272:    chained through the `all' field.  */
                    273: struct nesting *nesting_stack;
                    274: 
                    275: /* Number of entries on nesting_stack now.  */
                    276: int nesting_depth;
                    277: 
                    278: /* Pop one of the sub-stacks, such as `loop_stack' or `cond_stack';
                    279:    and pop off `nesting_stack' down to the same level.  */
                    280: 
                    281: #define POPSTACK(STACK)                                        \
                    282: do { int initial_depth = nesting_stack->depth;         \
                    283:      do { struct nesting *this = STACK;                        \
                    284:          STACK = this->next;                           \
                    285:          nesting_stack = this->all;                    \
                    286:          nesting_depth = this->depth;                  \
                    287:          free (this); }                                \
                    288:      while (nesting_depth > initial_depth); } while (0)
                    289: 
1.1       root      290: /* Return the rtx-label that corresponds to a LABEL_DECL,
                    291:    creating it if necessary.  */
                    292: 
                    293: static rtx
                    294: label_rtx (label)
                    295:      tree label;
                    296: {
1.1.1.2   root      297:   if (TREE_CODE (label) != LABEL_DECL)
                    298:     abort ();
                    299: 
1.1       root      300:   if (DECL_RTL (label))
                    301:     return DECL_RTL (label);
                    302: 
                    303:   return DECL_RTL (label) = gen_label_rtx ();
                    304: }
                    305: 
                    306: /* Add an unconditional jump to LABEL as the next sequential instruction.  */
                    307: 
                    308: void
                    309: emit_jump (label)
                    310:      rtx label;
                    311: {
                    312:   do_pending_stack_adjust ();
                    313:   emit_jump_insn (gen_jump (label));
                    314:   emit_barrier ();
                    315: }
1.1.1.2   root      316: 
                    317: /* Handle goto statements and the labels that they can go to.  */
1.1       root      318: 
1.1.1.2   root      319: /* In some cases it is impossible to generate code for a forward goto 
                    320:    until the label definition is seen.  This happens when it may be necessary
                    321:    for the goto to reset the stack pointer: we don't yet know how to do that.
                    322:    So expand_goto puts an entry on this fixup list.
                    323:    Each time a binding contour that resets the stack is exited,
                    324:    we check each fixup.
                    325:    If the target label has now been defined, we can insert the proper code.  */
1.1       root      326: 
1.1.1.2   root      327: struct goto_fixup
1.1       root      328: {
1.1.1.2   root      329:   /* Points to following fixup.  */
                    330:   struct goto_fixup *next;
                    331:   /* Points to the insn before the jump insn.
                    332:      If more code must be inserted, it goes after this insn.  */
                    333:   rtx before_jump;
1.1.1.6   root      334:   /* The LABEL_DECL that this jump is jumping to, or 0
                    335:      for break, continue or return.  */
1.1.1.2   root      336:   tree target;
1.1.1.6   root      337:   /* The CODE_LABEL rtx that this is jumping to.  */
                    338:   rtx target_rtl;
1.1.1.2   root      339:   /* The outermost stack level that should be restored for this jump.
                    340:      Each time a binding contour that resets the stack is exited,
                    341:      if the target label is *not* yet defined, this slot is updated.  */
                    342:   rtx stack_level;
1.1.1.7   root      343:   /* List of lists of cleanup expressions to be run by this goto.  */
                    344:   tree cleanup_list_list;
1.1.1.2   root      345: };
                    346: 
                    347: static struct goto_fixup *goto_fixup_chain;
                    348: 
                    349: /* Within any binding contour that must restore a stack level,
                    350:    all labels are recorded with a chain of these structures.  */
                    351: 
                    352: struct label_chain
                    353: {
                    354:   /* Points to following fixup.  */
                    355:   struct label_chain *next;
                    356:   tree label;
                    357: };
                    358: 
                    359: /* Specify the location in the RTL code of a label BODY,
                    360:    which is a LABEL_DECL tree node.
                    361: 
                    362:    This is used for the kind of label that the user can jump to with a
                    363:    goto statement, and for alternatives of a switch or case statement.
                    364:    RTL labels generated for loops and conditionals don't go through here;
                    365:    they are generated directly at the RTL level, by other functions below.
                    366: 
                    367:    Note that this has nothing to do with defining label *names*.
                    368:    Languages vary in how they do that and what that even means.  */
                    369: 
                    370: void
                    371: expand_label (body)
                    372:      tree body;
                    373: {
                    374:   struct label_chain *p;
                    375: 
                    376:   do_pending_stack_adjust ();
                    377:   emit_label (label_rtx (body));
                    378: 
1.1.1.7   root      379:   if (stack_block_stack != 0)
1.1.1.2   root      380:     {
                    381:       p = (struct label_chain *) oballoc (sizeof (struct label_chain));
                    382:       p->next = stack_block_stack->data.block.label_chain;
                    383:       stack_block_stack->data.block.label_chain = p;
                    384:       p->label = body;
                    385:     }
1.1       root      386: }
                    387: 
1.1.1.2   root      388: /* Generate RTL code for a `goto' statement with target label BODY.
                    389:    BODY should be a LABEL_DECL tree node that was or will later be
                    390:    defined with `expand_label'.  */
                    391: 
                    392: void
                    393: expand_goto (body)
                    394:      tree body;
1.1       root      395: {
1.1.1.8   root      396:   expand_goto_internal (body, label_rtx (body), 0);
1.1.1.6   root      397: }
                    398: 
1.1.1.8   root      399: /* Generate RTL code for a `goto' statement with target label BODY.
                    400:    LABEL should be a LABEL_REF.
                    401:    LAST_INSN, if non-0, is the rtx we should consider as the last
1.1.1.9   root      402:    insn emitted (for the purposes of cleaning up a return).  */
1.1.1.8   root      403: 
1.1.1.6   root      404: static void
1.1.1.8   root      405: expand_goto_internal (body, label, last_insn)
1.1.1.6   root      406:      tree body;
                    407:      rtx label;
1.1.1.8   root      408:      rtx last_insn;
1.1.1.6   root      409: {
1.1.1.2   root      410:   struct nesting *block;
                    411:   rtx stack_level = 0;
                    412: 
                    413:   if (GET_CODE (label) != CODE_LABEL)
                    414:     abort ();
                    415: 
                    416:   /* If label has already been defined, we can tell now
                    417:      whether and how we must alter the stack level.  */
                    418: 
1.1.1.6   root      419:   if (PREV_INSN (label) != 0)
1.1.1.2   root      420:     {
                    421:       /* Find the outermost pending block that contains the label.
                    422:         (Check containment by comparing insn-uids.)
                    423:         Then restore the outermost stack level within that block.  */
                    424:       for (block = block_stack; block; block = block->next)
                    425:        {
                    426:          if (INSN_UID (block->data.block.first_insn) < INSN_UID (label))
                    427:            break;
                    428:          if (block->data.block.stack_level != 0)
                    429:            stack_level = block->data.block.stack_level;
1.1.1.7   root      430:          /* Execute the cleanups for blocks we are exiting.  */
                    431:          if (block->data.block.cleanups != 0)
                    432:            expand_cleanups (block->data.block.cleanups, 0);
1.1.1.2   root      433:        }
                    434: 
                    435:       if (stack_level)
                    436:        emit_move_insn (stack_pointer_rtx, stack_level);
                    437: 
1.1.1.6   root      438:       if (body != 0 && TREE_PACKED (body))
1.1.1.2   root      439:        error ("goto \"%s\" invalidly jumps into binding contour",
                    440:               IDENTIFIER_POINTER (DECL_NAME (body)));
                    441:     }
                    442:   /* Label not yet defined: may need to put this goto
                    443:      on the fixup list.  */
1.1.1.8   root      444:   else if (! expand_fixup (body, label, last_insn))
1.1.1.6   root      445:     /* No fixup needed.  Record that the label is the target
                    446:        of at least one goto that has no fixup.  */
                    447:     if (body != 0)
                    448:       TREE_ADDRESSABLE (body) = 1;
1.1.1.2   root      449: 
1.1.1.6   root      450:   emit_jump (label);
                    451: }
                    452: 
                    453: /* Generate if necessary a fixup for a goto
                    454:    whose target label in tree structure (if any) is TREE_LABEL
                    455:    and whose target in rtl is RTL_LABEL.
                    456: 
1.1.1.8   root      457:    If LAST_INSN is nonzero, we pretend that the jump appears
                    458:    after insn LAST_INSN instead of at the current point in the insn stream.
                    459: 
1.1.1.6   root      460:    The fixup will be used later to insert insns at this point
                    461:    to restore the stack level as appropriate for the target label.
                    462: 
                    463:    Value is nonzero if a fixup is made.  */
                    464: 
                    465: static int
1.1.1.8   root      466: expand_fixup (tree_label, rtl_label, last_insn)
1.1.1.6   root      467:      tree tree_label;
                    468:      rtx rtl_label;
1.1.1.8   root      469:      rtx last_insn;
1.1.1.6   root      470: {
                    471:   struct nesting *block;
1.1.1.7   root      472:   /* Does any containing block have a stack level or cleanups?
1.1.1.6   root      473:      If not, no fixup is needed, and that is the normal case
                    474:      (the only case, for standard C).  */
                    475:   for (block = block_stack; block; block = block->next)
1.1.1.7   root      476:     if (block->data.block.stack_level != 0
                    477:        || block->data.block.cleanups != 0)
1.1.1.6   root      478:       break;
                    479: 
                    480:   if (block)
                    481:     {
                    482:       /* Ok, a fixup is needed.  Add a fixup to the list of such.  */
                    483:       struct goto_fixup *fixup
                    484:        = (struct goto_fixup *) oballoc (sizeof (struct goto_fixup));
                    485:       /* In case an old stack level is restored, make sure that comes
                    486:         after any pending stack adjust.  */
                    487:       do_pending_stack_adjust ();
1.1.1.8   root      488:       fixup->before_jump = last_insn ? last_insn : get_last_insn ();
1.1.1.6   root      489:       fixup->target = tree_label;
                    490:       fixup->target_rtl = rtl_label;
                    491:       fixup->stack_level = 0;
1.1.1.7   root      492:       fixup->cleanup_list_list = NULL_TREE;
1.1.1.6   root      493:       fixup->next = goto_fixup_chain;
                    494:       goto_fixup_chain = fixup;
1.1.1.2   root      495:     }
                    496: 
1.1.1.6   root      497:   return block != 0;
1.1       root      498: }
                    499: 
1.1.1.2   root      500: /* When exiting a binding contour, process all pending gotos requiring fixups.
1.1.1.7   root      501:    STACK_LEVEL is the rtx for the stack level to restore exiting this contour.
                    502:    CLEANUPS is a list of expressions to evaluate on exiting this contour.
                    503:    FIRST_INSN is the insn that begain this contour.
                    504: 
1.1.1.2   root      505:    Gotos that jump out of this contour must restore the
1.1.1.7   root      506:    stack level and do the cleanups before actually jumping.
1.1       root      507: 
1.1.1.7   root      508:    DONT_JUMP_IN nonzero means report error there is a jump into this
                    509:    contour from before the beginning of the contour.
                    510:    This is also done if STACK_LEVEL is nonzero.  */
1.1       root      511: 
1.1.1.2   root      512: static void
1.1.1.7   root      513: fixup_gotos (stack_level, cleanup_list, first_insn, dont_jump_in)
1.1.1.2   root      514:      rtx stack_level;
1.1.1.7   root      515:      tree cleanup_list;
1.1.1.2   root      516:      rtx first_insn;
1.1.1.7   root      517:      int dont_jump_in;
1.1       root      518: {
1.1.1.2   root      519:   register struct goto_fixup *f;
1.1       root      520: 
1.1.1.2   root      521:   for (f = goto_fixup_chain; f; f = f->next)
                    522:     {
                    523:       /* Test for a fixup that is inactive because it is already handled.  */
                    524:       if (f->before_jump == 0)
                    525:        ;
                    526:       /* Has this fixup's target label been defined?
                    527:         If so, we can finalize it.  */
1.1.1.6   root      528:       else if (PREV_INSN (f->target_rtl) != 0)
1.1.1.2   root      529:        {
                    530:          /* If this fixup jumped into this contour from before the beginning
                    531:             of this contour, report an error.  */
1.1.1.6   root      532:          if (f->target != 0
1.1.1.7   root      533:              && (dont_jump_in || stack_level)
1.1.1.6   root      534:              && INSN_UID (first_insn) > INSN_UID (f->before_jump)
1.1.1.2   root      535:              && ! TREE_ADDRESSABLE (f->target))
                    536:            {
                    537:              error_with_file_and_line (DECL_SOURCE_FILE (f->target),
                    538:                                        DECL_SOURCE_LINE (f->target),
                    539:                                        "label \"%s\" was used \
                    540: before containing binding contour",
                    541:                                        IDENTIFIER_POINTER (DECL_NAME (f->target)));
                    542:              /* Prevent multiple errors for one label.  */
                    543:              TREE_ADDRESSABLE (f->target) = 1;
                    544:            }
1.1       root      545: 
1.1.1.7   root      546:          /* Execute cleanups for blocks this jump exits.  */
                    547:          if (f->cleanup_list_list)
                    548:            fixup_cleanups (f->cleanup_list_list, &f->before_jump);
                    549: 
1.1.1.2   root      550:          /* Restore stack level for the biggest contour that this
                    551:             jump jumps out of.  */
                    552:          if (f->stack_level)
                    553:            emit_insn_after (gen_move_insn (stack_pointer_rtx, f->stack_level),
                    554:                             f->before_jump);
                    555:          f->before_jump = 0;
                    556:        }
                    557:       /* Label has still not appeared.  If we are exiting a block with
                    558:         a stack level to restore, mark this stack level as needing
                    559:         restoration when the fixup is later finalized.  */
1.1.1.7   root      560:       else
                    561:        {
                    562:          if (stack_level)
                    563:            f->stack_level = stack_level;
                    564:          if (cleanup_list)
                    565:            f->cleanup_list_list
                    566:              = chainon (f->cleanup_list_list,
                    567:                         build_tree_list (NULL, cleanup_list));
                    568:        }
1.1.1.2   root      569:     }
                    570: }
                    571: 
                    572: /* Generate RTL for an asm statement (explicit assembler code).
                    573:    BODY is a STRING_CST node containing the assembler code text.  */
                    574: 
                    575: void
                    576: expand_asm (body)
                    577:      tree body;
1.1       root      578: {
1.1.1.2   root      579:   emit_insn (gen_rtx (ASM_INPUT, VOIDmode,
                    580:                      TREE_STRING_POINTER (body)));
                    581:   last_expr_type = 0;
                    582: }
                    583: 
                    584: /* Generate RTL for an asm statement with arguments.
                    585:    STRING is the instruction template.
                    586:    OUTPUTS is a list of output arguments (lvalues); INPUTS a list of inputs.
                    587:    Each output or input has an expression in the TREE_VALUE and
                    588:    a constraint-string in the TREE_PURPOSE.
1.1.1.8   root      589:    CLOBBERS is a list of STRING_CST nodes each naming a hard register
                    590:    that is clobbered by this insn.
1.1.1.2   root      591: 
                    592:    Not all kinds of lvalue that may appear in OUTPUTS can be stored directly.
                    593:    Some elements of OUTPUTS may be replaced with trees representing temporary
                    594:    values.  The caller should copy those temporary values to the originally
                    595:    specified lvalues.
1.1       root      596: 
1.1.1.2   root      597:    VOL nonzero means the insn is volatile; don't optimize it.  */
1.1       root      598: 
1.1.1.2   root      599: void
1.1.1.8   root      600: expand_asm_operands (string, outputs, inputs, clobbers, vol)
                    601:      tree string, outputs, inputs, clobbers;
1.1.1.2   root      602:      int vol;
                    603: {
                    604:   rtvec argvec, constraints;
                    605:   rtx body;
                    606:   int ninputs = list_length (inputs);
                    607:   int noutputs = list_length (outputs);
1.1.1.8   root      608:   int nclobbers = list_length (clobbers);
1.1.1.2   root      609:   tree tail;
                    610:   int i;
                    611: 
1.1.1.4   root      612:   last_expr_type = 0;
                    613: 
1.1.1.2   root      614:   for (i = 0, tail = outputs; tail; tail = TREE_CHAIN (tail), i++)
                    615:     {
                    616:       tree val = TREE_VALUE (tail);
1.1       root      617: 
1.1.1.4   root      618:       /* If there's an erroneous arg, emit no insn.  */
                    619:       if (TREE_TYPE (val) == error_mark_node)
                    620:        return;
                    621: 
1.1.1.2   root      622:       /* If an output operand is not a variable or indirect ref,
                    623:         create a SAVE_EXPR which is a pseudo-reg
                    624:         to act as an intermediate temporary.
                    625:         Make the asm insn write into that, then copy it to
                    626:         the real output operand.  */
                    627: 
                    628:       if (TREE_CODE (val) != VAR_DECL
                    629:          && TREE_CODE (val) != PARM_DECL
                    630:          && TREE_CODE (val) != INDIRECT_REF)
1.1.1.10  root      631:        {
                    632:          rtx reg = gen_reg_rtx (TYPE_MODE (TREE_TYPE (val)));
                    633:          /* `build' isn't safe; it really expects args to be trees.  */
                    634:          tree t = build_nt (SAVE_EXPR, val, reg);
                    635: 
                    636:          save_expr_regs = gen_rtx (EXPR_LIST, VOIDmode, reg, save_expr_regs);
                    637:          TREE_VALUE (tail) = t;
                    638:          TREE_TYPE (t) = TREE_TYPE (val);
                    639:        }
1.1.1.2   root      640:     }
1.1       root      641: 
1.1.1.8   root      642:   if (ninputs + noutputs > MAX_RECOG_OPERANDS)
                    643:     {
                    644:       error ("more than %d operands in `asm'", MAX_RECOG_OPERANDS);
                    645:       return;
                    646:     }
                    647: 
1.1.1.2   root      648:   /* Make vectors for the expression-rtx and constraint strings.  */
1.1       root      649: 
1.1.1.4   root      650:   argvec = rtvec_alloc (ninputs);
                    651:   constraints = rtvec_alloc (ninputs);
1.1       root      652: 
1.1.1.2   root      653:   body = gen_rtx (ASM_OPERANDS, VOIDmode,
                    654:                  TREE_STRING_POINTER (string), "", 0, argvec, constraints);
1.1.1.10  root      655:   MEM_VOLATILE_P (body) = vol;
1.1       root      656: 
1.1.1.2   root      657:   /* Eval the inputs and put them into ARGVEC.
                    658:      Put their constraints into ASM_INPUTs and store in CONSTRAINTS.  */
1.1       root      659: 
1.1.1.2   root      660:   i = 0;
                    661:   for (tail = inputs; tail; tail = TREE_CHAIN (tail))
                    662:     {
1.1.1.4   root      663:       /* If there's an erroneous arg, emit no insn,
                    664:         because the ASM_INPUT would get VOIDmode
                    665:         and that could cause a crash in reload.  */
                    666:       if (TREE_TYPE (TREE_VALUE (tail)) == error_mark_node)
                    667:        return;
1.1.1.8   root      668:       if (TREE_PURPOSE (tail) == NULL_TREE)
                    669:        {
                    670:          error ("hard register %s listed as input operand to `asm'",
                    671:                 TREE_STRING_POINTER (TREE_VALUE (tail)) );
                    672:          return;
                    673:        }
1.1.1.4   root      674: 
1.1.1.2   root      675:       XVECEXP (body, 3, i)      /* argvec */
                    676:        = expand_expr (TREE_VALUE (tail), 0, VOIDmode, 0);
                    677:       XVECEXP (body, 4, i)      /* constraints */
                    678:        = gen_rtx (ASM_INPUT, TYPE_MODE (TREE_TYPE (TREE_VALUE (tail))),
                    679:                   TREE_STRING_POINTER (TREE_PURPOSE (tail)));
                    680:       i++;
                    681:     }
1.1       root      682: 
1.1.1.2   root      683:   /* Now, for each output, construct an rtx
                    684:      (set OUTPUT (asm_operands INSN OUTPUTNUMBER OUTPUTCONSTRAINT
                    685:                               ARGVEC CONSTRAINTS))
                    686:      If there is more than one, put them inside a PARALLEL.  */
1.1       root      687: 
1.1.1.8   root      688:   if (noutputs == 1 && nclobbers == 0)
1.1.1.2   root      689:     {
                    690:       tree val = TREE_VALUE (outputs);
1.1       root      691: 
1.1.1.2   root      692:       XSTR (body, 1) = TREE_STRING_POINTER (TREE_PURPOSE (outputs));
                    693:       emit_insn (gen_rtx (SET, VOIDmode,
                    694:                          expand_expr (val, 0, VOIDmode, 0),
                    695:                          body));
                    696:     }
1.1.1.8   root      697:   else if (noutputs == 0 && nclobbers == 0)
1.1.1.5   root      698:     {
                    699:       /* No output operands: put in a raw ASM_OPERANDS rtx.  */
                    700:       emit_insn (body);
                    701:     }
1.1.1.2   root      702:   else
                    703:     {
1.1.1.12! root      704:       rtx obody = body;
        !           705:       int num = noutputs;
        !           706:       if (num == 0) num = 1;
        !           707:       body = gen_rtx (PARALLEL, VOIDmode, rtvec_alloc (num + nclobbers));
1.1.1.8   root      708: 
                    709:       /* For each output operand, store a SET.  */
1.1.1.2   root      710: 
                    711:       for (i = 0, tail = outputs; tail; tail = TREE_CHAIN (tail), i++)
1.1       root      712:        {
1.1.1.2   root      713:          tree val = TREE_VALUE (tail);
                    714: 
                    715:          XVECEXP (body, 0, i)
                    716:            = gen_rtx (SET, VOIDmode,
                    717:                       expand_expr (val, 0, VOIDmode, 0),
                    718:                       gen_rtx (ASM_OPERANDS, VOIDmode,
                    719:                                TREE_STRING_POINTER (string),
                    720:                                TREE_STRING_POINTER (TREE_PURPOSE (tail)),
                    721:                                i, argvec, constraints));
1.1.1.10  root      722:          MEM_VOLATILE_P (SET_SRC (XVECEXP (body, 0, i))) = vol;
1.1       root      723:        }
                    724: 
1.1.1.12! root      725:       /* If there are no outputs (but there are some clobbers)
        !           726:         store the bare ASM_OPERANDS into the PARALLEL.  */
        !           727: 
        !           728:       if (i == 0)
        !           729:        XVECEXP (body, 0, i++) = obody;
        !           730: 
1.1.1.8   root      731:       /* Store (clobber REG) for each clobbered register specified.  */
                    732: 
                    733:       for (tail = clobbers; tail; tail = TREE_CHAIN (tail), i++)
                    734:        {
                    735:          int j;
                    736:          char *regname = TREE_STRING_POINTER (TREE_VALUE (tail));
                    737:          extern char *reg_names[];
                    738:              
                    739:          for (j = 0; j < FIRST_PSEUDO_REGISTER; j++)
                    740:            if (!strcmp (regname, reg_names[j]))
                    741:              break;
                    742:              
                    743:          if (j == FIRST_PSEUDO_REGISTER)
                    744:            {
                    745:              error ("unknown register name %s in `asm'", regname);
                    746:              return;
                    747:            }
                    748: 
1.1.1.12! root      749:          /* Use QImode since that's guaranteed to clobber just one reg.  */
1.1.1.8   root      750:          XVECEXP (body, 0, i)
1.1.1.12! root      751:            = gen_rtx (CLOBBER, VOIDmode, gen_rtx (REG, QImode, j));
1.1.1.8   root      752:        }
                    753: 
1.1.1.2   root      754:       emit_insn (body);
                    755:     }
                    756:   last_expr_type = 0;
                    757: }
1.1       root      758: 
1.1.1.2   root      759: /* Nonzero if within a ({...}) grouping, in which case we must
                    760:    always compute a value for each expr-stmt in case it is the last one.  */
1.1       root      761: 
1.1.1.2   root      762: int expr_stmts_for_value;
1.1       root      763: 
1.1.1.2   root      764: /* Generate RTL to evaluate the expression EXP
                    765:    and remember it in case this is the VALUE in a ({... VALUE; }) constr.  */
1.1       root      766: 
1.1.1.2   root      767: void
                    768: expand_expr_stmt (exp)
                    769:      tree exp;
                    770: {
                    771:   last_expr_type = TREE_TYPE (exp);
                    772:   last_expr_value = expand_expr (exp, expr_stmts_for_value ? 0 : const0_rtx,
                    773:                                 VOIDmode, 0);
                    774:   emit_queue ();
                    775: }
1.1       root      776: 
1.1.1.2   root      777: /* Clear out the memory of the last expression evaluated.  */
1.1       root      778: 
1.1.1.2   root      779: void
                    780: clear_last_expr ()
                    781: {
                    782:   last_expr_type = 0;
                    783: }
1.1       root      784: 
1.1.1.7   root      785: /* Begin a statement which will return a value.
1.1.1.10  root      786:    Return the RTL_EXPR for this statement expr.
                    787:    The caller must save that value and pass it to expand_end_stmt_expr.  */
1.1.1.7   root      788: 
                    789: tree
                    790: expand_start_stmt_expr ()
                    791: {
                    792:   rtx save = start_sequence ();
1.1.1.10  root      793:   /* Make the RTL_EXPR node temporary, not momentary,
                    794:      so that rtl_expr_chain doesn't become garbage.  */
                    795:   int momentary = suspend_momentary ();
1.1.1.7   root      796:   tree t = make_node (RTL_EXPR);
1.1.1.10  root      797:   resume_momentary (momentary);
1.1.1.7   root      798:   RTL_EXPR_RTL (t) = save;
1.1.1.10  root      799:   expr_stmts_for_value++;
1.1.1.7   root      800:   return t;
                    801: }
                    802: 
                    803: /* Restore the previous state at the end of a statement that returns a value.
                    804:    Returns a tree node representing the statement's value and the
                    805:    insns to compute the value.
                    806: 
1.1.1.2   root      807:    The nodes of that expression have been freed by now, so we cannot use them.
                    808:    But we don't want to do that anyway; the expression has already been
1.1.1.10  root      809:    evaluated and now we just want to use the value.  So generate a RTL_EXPR
1.1.1.2   root      810:    with the proper type and RTL value.
1.1       root      811: 
1.1.1.7   root      812:    If the last substatement was not an expression,
1.1.1.2   root      813:    return something with type `void'.  */
1.1       root      814: 
1.1.1.2   root      815: tree
1.1.1.7   root      816: expand_end_stmt_expr (t)
                    817:      tree t;
1.1.1.2   root      818: {
1.1.1.7   root      819:   rtx saved = RTL_EXPR_RTL (t);
1.1       root      820: 
1.1.1.2   root      821:   if (last_expr_type == 0)
                    822:     {
                    823:       last_expr_type = void_type_node;
                    824:       last_expr_value = const0_rtx;
                    825:     }
1.1.1.7   root      826:   TREE_TYPE (t) = last_expr_type;
1.1.1.2   root      827:   RTL_EXPR_RTL (t) = last_expr_value;
1.1.1.10  root      828:   RTL_EXPR_SEQUENCE (t) = get_insns ();
                    829: 
                    830:   rtl_expr_chain = tree_cons (NULL_TREE, t, rtl_expr_chain);
1.1       root      831: 
1.1.1.7   root      832:   end_sequence (saved);
1.1.1.10  root      833: 
                    834:   /* Don't consider deleting this expr or containing exprs at tree level.  */
                    835:   TREE_VOLATILE (t) = 1;
                    836:   /* Propagate volatility of the actual RTL expr.  */
                    837:   TREE_THIS_VOLATILE (t) = volatile_refs_p (last_expr_value);
                    838: 
                    839:   last_expr_type = 0;
1.1.1.2   root      840:   expr_stmts_for_value--;
1.1.1.7   root      841: 
                    842:   return t;
1.1.1.2   root      843: }
                    844: 
                    845: /* Generate RTL for the start of an if-then.  COND is the expression
                    846:    whose truth should be tested.
1.1       root      847: 
1.1.1.2   root      848:    If EXITFLAG is nonzero, this conditional is visible to
                    849:    `exit_something'.  */
1.1       root      850: 
1.1.1.2   root      851: void
                    852: expand_start_cond (cond, exitflag)
                    853:      tree cond;
                    854:      int exitflag;
                    855: {
                    856:   struct nesting *thiscond
                    857:     = (struct nesting *) xmalloc (sizeof (struct nesting));
1.1       root      858: 
1.1.1.2   root      859:   /* Make an entry on cond_stack for the cond we are entering.  */
1.1       root      860: 
1.1.1.2   root      861:   thiscond->next = cond_stack;
                    862:   thiscond->all = nesting_stack;
                    863:   thiscond->depth = ++nesting_depth;
                    864:   thiscond->data.cond.after_label = 0;
                    865:   thiscond->data.cond.else_label = gen_label_rtx ();
                    866:   thiscond->exit_label = exitflag ? thiscond->data.cond.else_label : 0;
                    867:   cond_stack = thiscond;
                    868:   nesting_stack = thiscond;
1.1       root      869: 
1.1.1.2   root      870:   do_jump (cond, thiscond->data.cond.else_label, NULL);
                    871: }
1.1       root      872: 
1.1.1.2   root      873: /* Generate RTL for the end of an if-then with no else-clause.
                    874:    Pop the record for it off of cond_stack.  */
1.1       root      875: 
1.1.1.2   root      876: void
                    877: expand_end_cond ()
                    878: {
                    879:   struct nesting *thiscond = cond_stack;
1.1       root      880: 
1.1.1.2   root      881:   do_pending_stack_adjust ();
                    882:   emit_label (thiscond->data.cond.else_label);
1.1       root      883: 
1.1.1.2   root      884:   POPSTACK (cond_stack);
                    885:   last_expr_type = 0;
                    886: }
1.1       root      887: 
1.1.1.2   root      888: /* Generate RTL between the then-clause and the else-clause
                    889:    of an if-then-else.  */
1.1       root      890: 
1.1.1.2   root      891: void
                    892: expand_start_else ()
                    893: {
                    894:   cond_stack->data.cond.after_label = gen_label_rtx ();
                    895:   if (cond_stack->exit_label != 0)
                    896:     cond_stack->exit_label = cond_stack->data.cond.after_label;
                    897:   emit_jump (cond_stack->data.cond.after_label);
                    898:   if (cond_stack->data.cond.else_label)
                    899:     emit_label (cond_stack->data.cond.else_label);
                    900: }
1.1       root      901: 
1.1.1.2   root      902: /* Generate RTL for the end of an if-then-else.
                    903:    Pop the record for it off of cond_stack.  */
                    904: 
                    905: void
                    906: expand_end_else ()
                    907: {
                    908:   struct nesting *thiscond = cond_stack;
                    909: 
                    910:   do_pending_stack_adjust ();
                    911:   /* Note: a syntax error can cause this to be called
                    912:      without first calling `expand_start_else'.  */
                    913:   if (thiscond->data.cond.after_label)
                    914:     emit_label (thiscond->data.cond.after_label);
                    915: 
                    916:   POPSTACK (cond_stack);
                    917:   last_expr_type = 0;
                    918: }
                    919: 
                    920: /* Generate RTL for the start of a loop.  EXIT_FLAG is nonzero if this
                    921:    loop should be exited by `exit_something'.  This is a loop for which
                    922:    `expand_continue' will jump to the top of the loop.
                    923: 
                    924:    Make an entry on loop_stack to record the labels associated with
                    925:    this loop.  */
                    926: 
                    927: void
                    928: expand_start_loop (exit_flag)
                    929:      int exit_flag;
                    930: {
                    931:   register struct nesting *thisloop
                    932:     = (struct nesting *) xmalloc (sizeof (struct nesting));
                    933: 
                    934:   /* Make an entry on loop_stack for the loop we are entering.  */
                    935: 
                    936:   thisloop->next = loop_stack;
                    937:   thisloop->all = nesting_stack;
                    938:   thisloop->depth = ++nesting_depth;
                    939:   thisloop->data.loop.start_label = gen_label_rtx ();
                    940:   thisloop->data.loop.end_label = gen_label_rtx ();
                    941:   thisloop->data.loop.continue_label = thisloop->data.loop.start_label;
                    942:   thisloop->exit_label = exit_flag ? thisloop->data.loop.end_label : 0;
                    943:   loop_stack = thisloop;
                    944:   nesting_stack = thisloop;
                    945: 
                    946:   do_pending_stack_adjust ();
                    947:   emit_queue ();
                    948:   emit_note (0, NOTE_INSN_LOOP_BEG);
                    949:   emit_label (thisloop->data.loop.start_label);
                    950: }
                    951: 
                    952: /* Like expand_start_loop but for a loop where the continuation point
                    953:    (for expand_continue_loop) will be specified explicitly.  */
1.1       root      954: 
1.1.1.2   root      955: void
                    956: expand_start_loop_continue_elsewhere (exit_flag)
                    957:      int exit_flag;
                    958: {
                    959:   expand_start_loop (exit_flag);
                    960:   loop_stack->data.loop.continue_label = gen_label_rtx ();
                    961: }
                    962: 
                    963: /* Specify the continuation point for a loop started with
                    964:    expand_start_loop_continue_elsewhere.
                    965:    Use this at the point in the code to which a continue statement
                    966:    should jump.  */
                    967: 
                    968: void
                    969: expand_loop_continue_here ()
                    970: {
                    971:   do_pending_stack_adjust ();
                    972:   emit_label (loop_stack->data.loop.continue_label);
                    973: }
                    974: 
                    975: /* Finish a loop.  Generate a jump back to the top and the loop-exit label.
                    976:    Pop the block off of loop_stack.  */
                    977: 
                    978: void
                    979: expand_end_loop ()
                    980: {
                    981:   register rtx insn = get_last_insn ();
                    982:   register rtx start_label = loop_stack->data.loop.start_label;
                    983: 
                    984:   do_pending_stack_adjust ();
                    985: 
                    986:   /* If optimizing, perhaps reorder the loop.  If the loop
                    987:      starts with a conditional exit, roll that to the end
                    988:      where it will optimize together with the jump back.  */
                    989:   if (optimize
                    990:       &&
                    991:       ! (GET_CODE (insn) == JUMP_INSN
                    992:         && GET_CODE (PATTERN (insn)) == SET
                    993:         && SET_DEST (PATTERN (insn)) == pc_rtx
                    994:         && GET_CODE (SET_SRC (PATTERN (insn))) == IF_THEN_ELSE))
                    995:     {
                    996:       /* Scan insns from the top of the loop looking for a qualified
                    997:         conditional exit.  */
                    998:       for (insn = loop_stack->data.loop.start_label; insn; insn= NEXT_INSN (insn))
                    999:        if (GET_CODE (insn) == JUMP_INSN && GET_CODE (PATTERN (insn)) == SET
                   1000:            && SET_DEST (PATTERN (insn)) == pc_rtx
                   1001:            && GET_CODE (SET_SRC (PATTERN (insn))) == IF_THEN_ELSE
                   1002:            &&
                   1003:            ((GET_CODE (XEXP (SET_SRC (PATTERN (insn)), 1)) == LABEL_REF
                   1004:              && (XEXP (XEXP (SET_SRC (PATTERN (insn)), 1), 0)
                   1005:                  == loop_stack->data.loop.end_label))
                   1006:             ||
                   1007:             (GET_CODE (XEXP (SET_SRC (PATTERN (insn)), 2)) == LABEL_REF
                   1008:              && (XEXP (XEXP (SET_SRC (PATTERN (insn)), 2), 0)
                   1009:                  == loop_stack->data.loop.end_label))))
                   1010:          break;
                   1011:       if (insn != 0)
                   1012:        {
                   1013:          /* We found one.  Move everything from there up
                   1014:             to the end of the loop, and add a jump into the loop
                   1015:             to jump to there.  */
                   1016:          register rtx newstart_label = gen_label_rtx ();
                   1017: 
                   1018:          emit_label_after (newstart_label, PREV_INSN (start_label));
                   1019:          reorder_insns (start_label, insn, get_last_insn ());
                   1020:          emit_jump_insn_after (gen_jump (start_label), PREV_INSN (newstart_label));
                   1021:          emit_barrier_after (PREV_INSN (newstart_label));
                   1022:          start_label = newstart_label;
                   1023:        }
                   1024:     }
                   1025: 
                   1026:   emit_jump (start_label);
                   1027:   emit_note (0, NOTE_INSN_LOOP_END);
                   1028:   emit_label (loop_stack->data.loop.end_label);
                   1029: 
                   1030:   POPSTACK (loop_stack);
                   1031: 
                   1032:   last_expr_type = 0;
                   1033: }
                   1034: 
                   1035: /* Generate a jump to the current loop's continue-point.
                   1036:    This is usually the top of the loop, but may be specified
                   1037:    explicitly elsewhere.  If not currently inside a loop,
                   1038:    return 0 and do nothing; caller will print an error message.  */
                   1039: 
                   1040: int
                   1041: expand_continue_loop ()
                   1042: {
                   1043:   last_expr_type = 0;
                   1044:   if (loop_stack == 0)
                   1045:     return 0;
1.1.1.8   root     1046:   expand_goto_internal (0, loop_stack->data.loop.continue_label, 0);
1.1.1.2   root     1047:   return 1;
                   1048: }
                   1049: 
                   1050: /* Generate a jump to exit the current loop.  If not currently inside a loop,
                   1051:    return 0 and do nothing; caller will print an error message.  */
                   1052: 
                   1053: int
                   1054: expand_exit_loop ()
                   1055: {
                   1056:   last_expr_type = 0;
                   1057:   if (loop_stack == 0)
                   1058:     return 0;
1.1.1.8   root     1059:   expand_goto_internal (0, loop_stack->data.loop.end_label, 0);
1.1.1.2   root     1060:   return 1;
                   1061: }
                   1062: 
                   1063: /* Generate a conditional jump to exit the current loop if COND
                   1064:    evaluates to zero.  If not currently inside a loop,
                   1065:    return 0 and do nothing; caller will print an error message.  */
                   1066: 
                   1067: int
                   1068: expand_exit_loop_if_false (cond)
                   1069:      tree cond;
                   1070: {
                   1071:   last_expr_type = 0;
                   1072:   if (loop_stack == 0)
                   1073:     return 0;
                   1074:   do_jump (cond, loop_stack->data.loop.end_label, NULL);
                   1075:   return 1;
                   1076: }
                   1077: 
                   1078: /* Generate a jump to exit the current loop, conditional, binding contour
                   1079:    or case statement.  Not all such constructs are visible to this function,
                   1080:    only those started with EXIT_FLAG nonzero.  Individual languages use
                   1081:    the EXIT_FLAG parameter to control which kinds of constructs you can
                   1082:    exit this way.
                   1083: 
                   1084:    If not currently inside anything that can be exited,
                   1085:    return 0 and do nothing; caller will print an error message.  */
                   1086: 
                   1087: int
                   1088: expand_exit_something ()
                   1089: {
                   1090:   struct nesting *n;
                   1091:   last_expr_type = 0;
                   1092:   for (n = nesting_stack; n; n = n->all)
1.1.1.7   root     1093:     if (n->exit_label != 0)
                   1094:       {
1.1.1.8   root     1095:        expand_goto_internal (0, n->exit_label, 0);
1.1.1.7   root     1096:        return 1;
                   1097:       }
                   1098: 
1.1.1.2   root     1099:   return 0;
                   1100: }
                   1101: 
                   1102: /* Generate RTL to return from the current function, with no value.
                   1103:    (That is, we do not do anything about returning any value.)  */
                   1104: 
                   1105: void
                   1106: expand_null_return ()
                   1107: {
1.1.1.8   root     1108:   expand_null_return_1 (0);
                   1109: }
                   1110: 
                   1111: /* Output a return with no value.  If LAST_INSN is nonzero,
                   1112:    pretend that the return takes place after LAST_INSN.  */
                   1113: 
                   1114: static void
                   1115: expand_null_return_1 (last_insn)
                   1116:      rtx last_insn;
                   1117: {
1.1.1.2   root     1118:   clear_pending_stack_adjust ();
1.1.1.10  root     1119:   do_pending_stack_adjust ();
1.1.1.2   root     1120: #ifdef FUNCTION_EPILOGUE
1.1.1.8   root     1121: #ifdef HAVE_return
                   1122:   if (! HAVE_return)
                   1123:     expand_goto_internal (0, return_label, last_insn);
                   1124:   else
                   1125:     {
                   1126:       emit_jump_insn (gen_return ());
                   1127:       emit_barrier ();
                   1128:     }
1.1.1.2   root     1129: #else
1.1.1.8   root     1130:   expand_goto_internal (0, return_label, last_insn);
                   1131: #endif
                   1132: #else /* no FUNCTION_EPILOGUE */
1.1.1.2   root     1133:   emit_jump_insn (gen_return ());
                   1134:   emit_barrier ();
                   1135: #endif
                   1136:   last_expr_type = 0;
                   1137: }
1.1       root     1138: 
1.1.1.2   root     1139: /* Generate RTL to evaluate the expression RETVAL and return it
                   1140:    from the current function.  */
1.1       root     1141: 
1.1.1.2   root     1142: void
                   1143: expand_return (retval)
                   1144:      tree retval;
                   1145: {
1.1.1.8   root     1146:   /* If there are any cleanups to be performed, then they will
                   1147:      be inserted in front of our `last_insn'.  It is desirable
                   1148:      that the last_insn, for such purposes, should be the
                   1149:      last insn before computing the return value.  Otherwise, cleanups
                   1150:      which call functions can clobber the return value.  */
                   1151:   rtx last_insn = get_last_insn ();
1.1.1.2   root     1152:   register rtx val = 0;
                   1153:   register rtx op0;
1.1.1.7   root     1154:   tree retval_rhs;
                   1155: 
                   1156:   if (TREE_CODE (retval) == RESULT_DECL)
                   1157:     retval_rhs = retval;
                   1158:   else if ((TREE_CODE (retval) == MODIFY_EXPR || TREE_CODE (retval) == INIT_EXPR)
                   1159:           && TREE_CODE (TREE_OPERAND (retval, 0)) == RESULT_DECL)
                   1160:     retval_rhs = TREE_OPERAND (retval, 1);
                   1161:   else
                   1162:     retval_rhs = NULL_TREE;
1.1.1.2   root     1163: 
                   1164:   /* For tail-recursive call to current function,
                   1165:      just jump back to the beginning.
                   1166:      It's unsafe if any auto variable in this function
                   1167:      has its address taken; for simplicity,
                   1168:      require stack frame to be empty.  */
1.1.1.7   root     1169:   if (optimize && retval_rhs != 0
1.1.1.3   root     1170:       && frame_offset == STARTING_FRAME_OFFSET
1.1.1.7   root     1171:       && TREE_CODE (retval_rhs) == CALL_EXPR
                   1172:       && TREE_CODE (TREE_OPERAND (retval_rhs, 0)) == ADDR_EXPR
                   1173:       && TREE_OPERAND (TREE_OPERAND (retval_rhs, 0), 0) == this_function
1.1.1.2   root     1174:       /* Finish checking validity, and if valid emit code
                   1175:         to set the argument variables for the new call.  */
1.1.1.8   root     1176:       && tail_recursion_args (TREE_OPERAND (retval_rhs, 1),
1.1.1.2   root     1177:                              DECL_ARGUMENTS (this_function)))
                   1178:     {
                   1179:       ;
                   1180:       if (tail_recursion_label == 0)
                   1181:        {
                   1182:          tail_recursion_label = gen_label_rtx ();
                   1183:          emit_label_after (tail_recursion_label,
                   1184:                            tail_recursion_reentry);
                   1185:        }
1.1.1.8   root     1186:       expand_goto_internal (0, tail_recursion_label, last_insn);
1.1.1.2   root     1187:       emit_barrier ();
                   1188:       return;
                   1189:     }
1.1.1.8   root     1190: #ifdef HAVE_return
                   1191:   if (HAVE_return)
                   1192:     {
                   1193:       /* If this is  return x == y;  then generate
                   1194:         if (x == y) return 1; else return 0;
                   1195:         if we can do it with explicit return insns.  */
                   1196:       if (retval_rhs)
                   1197:        switch (TREE_CODE (retval_rhs))
                   1198:          {
                   1199:          case EQ_EXPR:
                   1200:          case NE_EXPR:
                   1201:          case GT_EXPR:
                   1202:          case GE_EXPR:
                   1203:          case LT_EXPR:
                   1204:          case LE_EXPR:
                   1205:          case TRUTH_ANDIF_EXPR:
                   1206:          case TRUTH_ORIF_EXPR:
1.1.1.10  root     1207:          case TRUTH_AND_EXPR:
                   1208:          case TRUTH_OR_EXPR:
1.1.1.8   root     1209:          case TRUTH_NOT_EXPR:
                   1210:            op0 = gen_label_rtx ();
                   1211:            val = DECL_RTL (DECL_RESULT (this_function));
                   1212:            jumpifnot (retval_rhs, op0);
                   1213:            emit_move_insn (val, const1_rtx);
                   1214:            emit_insn (gen_rtx (USE, VOIDmode, val));
                   1215:            expand_null_return ();
                   1216:            emit_label (op0);
                   1217:            emit_move_insn (val, const0_rtx);
                   1218:            emit_insn (gen_rtx (USE, VOIDmode, val));
                   1219:            expand_null_return ();
                   1220:            return;
                   1221:          }
                   1222:     }
                   1223: #endif /* HAVE_return */
1.1.1.2   root     1224:   val = expand_expr (retval, 0, VOIDmode, 0);
1.1       root     1225:   emit_queue ();
1.1.1.2   root     1226: 
1.1.1.7   root     1227:   if (retval_rhs && GET_CODE (val) == REG)
1.1.1.2   root     1228:     emit_insn (gen_rtx (USE, VOIDmode, val));
                   1229: 
1.1.1.8   root     1230:   expand_null_return_1 (last_insn);
1.1.1.2   root     1231: }
                   1232: 
                   1233: /* Return 1 if the end of the generated RTX is not a barrier.
                   1234:    This means code already compiled can drop through.  */
                   1235: 
                   1236: int
                   1237: drop_through_at_end_p ()
                   1238: {
                   1239:   rtx insn = get_last_insn ();
                   1240:   while (insn && GET_CODE (insn) == NOTE)
                   1241:     insn = PREV_INSN (insn);
                   1242:   return insn && GET_CODE (insn) != BARRIER;
1.1       root     1243: }
                   1244: 
                   1245: /* Emit code to alter this function's formal parms for a tail-recursive call.
                   1246:    ACTUALS is a list of actual parameter expressions (chain of TREE_LISTs).
                   1247:    FORMALS is the chain of decls of formals.
                   1248:    Return 1 if this can be done;
                   1249:    otherwise return 0 and do not emit any code.  */
                   1250: 
                   1251: static int
                   1252: tail_recursion_args (actuals, formals)
                   1253:      tree actuals, formals;
                   1254: {
                   1255:   register tree a = actuals, f = formals;
                   1256:   register int i;
                   1257:   register rtx *argvec;
                   1258: 
                   1259:   /* Check that number and types of actuals are compatible
                   1260:      with the formals.  This is not always true in valid C code.
                   1261:      Also check that no formal needs to be addressable
                   1262:      and that all formals are scalars.  */
                   1263: 
                   1264:   /* Also count the args.  */
                   1265: 
                   1266:   for (a = actuals, f = formals, i = 0; a && f; a = TREE_CHAIN (a), f = TREE_CHAIN (f), i++)
                   1267:     {
                   1268:       if (TREE_TYPE (TREE_VALUE (a)) != TREE_TYPE (f))
                   1269:        return 0;
                   1270:       if (GET_CODE (DECL_RTL (f)) != REG || DECL_MODE (f) == BLKmode)
                   1271:        return 0;
                   1272:     }
                   1273:   if (a != 0 || f != 0)
                   1274:     return 0;
                   1275: 
                   1276:   /* Compute all the actuals.  */
                   1277: 
                   1278:   argvec = (rtx *) alloca (i * sizeof (rtx));
                   1279: 
                   1280:   for (a = actuals, i = 0; a; a = TREE_CHAIN (a), i++)
                   1281:     argvec[i] = expand_expr (TREE_VALUE (a), 0, VOIDmode, 0);
                   1282: 
                   1283:   /* Find which actual values refer to current values of previous formals.
                   1284:      Copy each of them now, before any formal is changed.  */
                   1285: 
                   1286:   for (a = actuals, i = 0; a; a = TREE_CHAIN (a), i++)
                   1287:     {
                   1288:       int copy = 0;
                   1289:       register int j;
                   1290:       for (f = formals, j = 0; j < i; f = TREE_CHAIN (f), j++)
                   1291:        if (reg_mentioned_p (DECL_RTL (f), argvec[i]))
                   1292:          { copy = 1; break; }
                   1293:       if (copy)
                   1294:        argvec[i] = copy_to_reg (argvec[i]);
                   1295:     }
                   1296: 
                   1297:   /* Store the values of the actuals into the formals.  */
                   1298: 
1.1.1.2   root     1299:   for (f = formals, a = actuals, i = 0; f;
                   1300:        f = TREE_CHAIN (f), a = TREE_CHAIN (a), i++)
1.1       root     1301:     {
                   1302:       if (DECL_MODE (f) == GET_MODE (argvec[i]))
                   1303:        emit_move_insn (DECL_RTL (f), argvec[i]);
                   1304:       else
1.1.1.2   root     1305:        convert_move (DECL_RTL (f), argvec[i],
                   1306:                      TREE_UNSIGNED (TREE_TYPE (TREE_VALUE (a))));
1.1       root     1307:     }
                   1308: 
                   1309:   return 1;
                   1310: }
                   1311: 
1.1.1.2   root     1312: /* Generate the RTL code for entering a binding contour.
                   1313:    The variables are declared one by one, by calls to `expand_decl'.
1.1       root     1314: 
1.1.1.2   root     1315:    EXIT_FLAG is nonzero if this construct should be visible to
                   1316:    `exit_something'.  */
                   1317: 
                   1318: void
                   1319: expand_start_bindings (exit_flag)
                   1320:      int exit_flag;
1.1       root     1321: {
1.1.1.2   root     1322:   struct nesting *thisblock
                   1323:     = (struct nesting *) xmalloc (sizeof (struct nesting));
                   1324: 
                   1325:   rtx note = emit_note (0, NOTE_INSN_BLOCK_BEG);
                   1326: 
                   1327:   /* Make an entry on block_stack for the block we are entering.  */
                   1328: 
                   1329:   thisblock->next = block_stack;
                   1330:   thisblock->all = nesting_stack;
                   1331:   thisblock->depth = ++nesting_depth;
                   1332:   thisblock->data.block.stack_level = 0;
1.1.1.7   root     1333:   thisblock->data.block.cleanups = 0;
1.1.1.2   root     1334:   thisblock->data.block.label_chain = 0;
                   1335:   thisblock->data.block.innermost_stack_block = stack_block_stack;
                   1336:   thisblock->data.block.first_insn = note;
                   1337:   thisblock->exit_label = exit_flag ? gen_label_rtx () : 0;
                   1338:   block_stack = thisblock;
                   1339:   nesting_stack = thisblock;
                   1340: }
                   1341: 
1.1.1.3   root     1342: /* Output a USE for any register use in RTL.
                   1343:    This is used with -noreg to mark the extent of lifespan
                   1344:    of any registers used in a user-visible variable's DECL_RTL.  */
                   1345: 
                   1346: static void
                   1347: use_variable (rtl)
                   1348:      rtx rtl;
                   1349: {
                   1350:   if (GET_CODE (rtl) == REG)
                   1351:     /* This is a register variable.  */
                   1352:     emit_insn (gen_rtx (USE, VOIDmode, rtl));
                   1353:   else if (GET_CODE (rtl) == MEM
                   1354:           && GET_CODE (XEXP (rtl, 0)) == REG
                   1355:           && XEXP (rtl, 0) != frame_pointer_rtx
                   1356:           && XEXP (rtl, 0) != arg_pointer_rtx)
                   1357:     /* This is a variable-sized structure.  */
                   1358:     emit_insn (gen_rtx (USE, VOIDmode, XEXP (rtl, 0)));
                   1359: }
                   1360: 
1.1.1.2   root     1361: /* Generate RTL code to terminate a binding contour.
                   1362:    VARS is the chain of VAR_DECL nodes
                   1363:    for the variables bound in this contour.
1.1.1.7   root     1364:    MARK_ENDS is nonzero if we should put a note at the beginning
                   1365:    and end of this binding contour.
                   1366: 
                   1367:    DONT_JUMP_IN is nonzero if it is not valid to jump into this contour.
                   1368:    (That is true automatically if the contour has a saved stack level.)  */
1.1.1.2   root     1369: 
                   1370: void
1.1.1.7   root     1371: expand_end_bindings (vars, mark_ends, dont_jump_in)
1.1.1.2   root     1372:      tree vars;
                   1373:      int mark_ends;
1.1.1.7   root     1374:      int dont_jump_in;
1.1.1.2   root     1375: {
                   1376:   register struct nesting *thisblock = block_stack;
                   1377:   register tree decl;
                   1378: 
1.1.1.10  root     1379:   if (warn_unused)
                   1380:     for (decl = vars; decl; decl = TREE_CHAIN (decl))
                   1381:       if (! TREE_USED (decl) && TREE_CODE (decl) == VAR_DECL)
                   1382:        warning_with_decl (decl, "unused variable `%s'");
                   1383: 
1.1.1.2   root     1384:   /* Mark the beginning and end of the scope if requested.  */
                   1385: 
                   1386:   if (mark_ends)
                   1387:     emit_note (0, NOTE_INSN_BLOCK_END);
                   1388:   else
                   1389:     /* Get rid of the beginning-mark if we don't make an end-mark.  */
                   1390:     NOTE_LINE_NUMBER (thisblock->data.block.first_insn) = NOTE_INSN_DELETED;
                   1391: 
                   1392:   if (thisblock->exit_label)
                   1393:     {
                   1394:       do_pending_stack_adjust ();
                   1395:       emit_label (thisblock->exit_label);
                   1396:     }
                   1397: 
1.1.1.7   root     1398:   if (dont_jump_in || thisblock->data.block.stack_level != 0)
1.1.1.2   root     1399:     {
                   1400:       struct label_chain *chain;
                   1401: 
                   1402:       /* Any labels in this block are no longer valid to go to.
                   1403:         Mark them to cause an error message.  */
                   1404:       for (chain = thisblock->data.block.label_chain; chain; chain = chain->next)
                   1405:        {
                   1406:          TREE_PACKED (chain->label) = 1;
                   1407:          /* If any goto without a fixup came to this label,
                   1408:             that must be an error, because gotos without fixups
                   1409:             come from outside all saved stack-levels.  */
                   1410:          if (TREE_ADDRESSABLE (chain->label))
                   1411:            error_with_file_and_line (DECL_SOURCE_FILE (chain->label),
                   1412:                                      DECL_SOURCE_LINE (chain->label),
                   1413:                                      "label \"%s\" was used \
                   1414: before containing binding contour",
                   1415:                                      IDENTIFIER_POINTER (DECL_NAME (chain->label)));
                   1416:        }
1.1.1.7   root     1417:     }
                   1418: 
                   1419:   /* Restore stack level in effect before the block
                   1420:      (only if variable-size objects allocated).  */
                   1421: 
                   1422:   if (thisblock->data.block.stack_level != 0
                   1423:       || thisblock->data.block.cleanups != 0)
                   1424:     {
                   1425:       /* Perform any cleanups associated with the block.  */
                   1426: 
                   1427:       expand_cleanups (thisblock->data.block.cleanups, 0);
                   1428: 
                   1429:       /* Restore the stack level.  */
                   1430: 
                   1431:       if (thisblock->data.block.stack_level != 0)
                   1432:        {
                   1433:          do_pending_stack_adjust ();
                   1434:          emit_move_insn (stack_pointer_rtx,
                   1435:                          thisblock->data.block.stack_level);
                   1436:        }
1.1.1.2   root     1437: 
1.1.1.7   root     1438:       /* Any gotos out of this block must also do these things.
1.1.1.2   root     1439:         Also report any gotos with fixups that came to labels in this level.  */
                   1440:       fixup_gotos (thisblock->data.block.stack_level,
1.1.1.7   root     1441:                   thisblock->data.block.cleanups,
                   1442:                   thisblock->data.block.first_insn,
                   1443:                   dont_jump_in);
1.1.1.2   root     1444:     }
                   1445: 
                   1446:   /* If doing stupid register allocation, make sure lives of all
                   1447:      register variables declared here extend thru end of scope.  */
                   1448: 
                   1449:   if (obey_regdecls)
                   1450:     for (decl = vars; decl; decl = TREE_CHAIN (decl))
                   1451:       {
1.1.1.3   root     1452:        rtx rtl = DECL_RTL (decl);
                   1453:        if (TREE_CODE (decl) == VAR_DECL && rtl != 0)
                   1454:          use_variable (rtl);
1.1.1.2   root     1455:       }
                   1456: 
                   1457:   /* Restore block_stack level for containing block.  */
                   1458: 
                   1459:   stack_block_stack = thisblock->data.block.innermost_stack_block;
                   1460:   POPSTACK (block_stack);
                   1461: }
                   1462: 
                   1463: /* Generate RTL for the automatic variable declaration DECL.
1.1.1.7   root     1464:    (Other kinds of declarations are simply ignored if seen here.)
                   1465:    CLEANUP is an expression to be executed at exit from this binding contour;
                   1466:    for example, in C++, it might call the destructor for this variable.
                   1467: 
                   1468:    If CLEANUP contains any SAVE_EXPRs, then you must preevaluate them
                   1469:    either before or after calling `expand_decl' but before compiling
                   1470:    any subsequent expressions.  This is because CLEANUP may be expanded
                   1471:    more than once, on different branches of execution.
                   1472:    For the same reason, CLEANUP may not contain a CALL_EXPR
                   1473:    except as its topmost node--else `preexpand_calls' would get confused.
                   1474: 
                   1475:    There is no special support here for C++ constructors.
                   1476:    They should be handled by the proper code in DECL_INITIAL.  */
1.1.1.2   root     1477: 
                   1478: void
1.1.1.7   root     1479: expand_decl (decl, cleanup)
1.1.1.2   root     1480:      register tree decl;
1.1.1.7   root     1481:      tree cleanup;
1.1.1.2   root     1482: {
                   1483:   struct nesting *thisblock = block_stack;
                   1484:   tree type = TREE_TYPE (decl);
                   1485: 
                   1486:   /* External function declarations are supposed to have been
                   1487:      handled in assemble_variable.  Verify this.  */
1.1.1.7   root     1488: 
1.1.1.2   root     1489:   if (TREE_CODE (decl) == FUNCTION_DECL)
                   1490:     {
                   1491:       if (DECL_RTL (decl) == 0)
                   1492:        abort ();
                   1493:       return;
                   1494:     }
                   1495: 
1.1.1.7   root     1496:   /* Record the cleanup if there is one.  */
                   1497: 
                   1498:   if (cleanup != 0)
                   1499:     thisblock->data.block.cleanups
                   1500:       = temp_tree_cons (decl, cleanup, thisblock->data.block.cleanups);
                   1501: 
1.1.1.2   root     1502:   /* Aside from that, only automatic variables need any expansion done.
                   1503:      Static and external variables were handled by `assemble_variable'
                   1504:      (called from finish_decl).  TYPE_DECL and CONST_DECL require nothing;
                   1505:      PARM_DECLs are handled in `assign_parms'.  */
                   1506: 
                   1507:   if (TREE_CODE (decl) != VAR_DECL)
                   1508:     return;
                   1509:   if (TREE_STATIC (decl) || TREE_EXTERNAL (decl))
                   1510:     return;
                   1511: 
                   1512:   /* Create the RTL representation for the variable.  */
                   1513: 
                   1514:   if (type == error_mark_node)
                   1515:     DECL_RTL (decl) = gen_rtx (MEM, BLKmode, const0_rtx);
                   1516:   else if (DECL_MODE (decl) != BLKmode
                   1517:           /* If -ffloat-store, don't put explicit float vars
                   1518:              into regs.  */
                   1519:           && !(flag_float_store
                   1520:                && TREE_CODE (type) == REAL_TYPE)
                   1521:           && ! TREE_VOLATILE (decl)
                   1522:           && ! TREE_ADDRESSABLE (decl)
                   1523:           && (TREE_REGDECL (decl) || ! obey_regdecls))
                   1524:     {
                   1525:       /* Automatic variable that can go in a register.  */
                   1526:       DECL_RTL (decl) = gen_reg_rtx (DECL_MODE (decl));
                   1527:       if (TREE_CODE (type) == POINTER_TYPE)
                   1528:        mark_reg_pointer (DECL_RTL (decl));
1.1.1.10  root     1529:       REG_USERVAR_P (DECL_RTL (decl)) = 1;
1.1.1.2   root     1530:     }
                   1531:   else if (DECL_SIZE (decl) == 0)
                   1532:     /* Variable with incomplete type.  */
                   1533:     /* Error message was already done; now avoid a crash.  */
                   1534:     DECL_RTL (decl) = assign_stack_local (DECL_MODE (decl), 0);
                   1535:   else if (TREE_LITERAL (DECL_SIZE (decl)))
                   1536:     {
                   1537:       /* Variable of fixed size that goes on the stack.  */
                   1538:       DECL_RTL (decl)
                   1539:        = assign_stack_local (DECL_MODE (decl),
                   1540:                              (TREE_INT_CST_LOW (DECL_SIZE (decl))
                   1541:                               * DECL_SIZE_UNIT (decl)
                   1542:                               + BITS_PER_UNIT - 1)
                   1543:                              / BITS_PER_UNIT);
                   1544:       /* If this is a memory ref that contains aggregate components,
                   1545:         mark it as such for cse and loop optimize.  */
1.1.1.10  root     1546:       MEM_IN_STRUCT_P (DECL_RTL (decl))
1.1.1.2   root     1547:        = (TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE
                   1548:           || TREE_CODE (TREE_TYPE (decl)) == RECORD_TYPE
                   1549:           || TREE_CODE (TREE_TYPE (decl)) == UNION_TYPE);
1.1.1.8   root     1550: #if 0
                   1551:       /* If this is in memory because of -ffloat-store,
                   1552:         set the volatile bit, to prevent optimizations from
                   1553:         undoing the effects.  */
                   1554:       if (flag_float_store && TREE_CODE (type) == REAL_TYPE)
1.1.1.10  root     1555:        MEM_VOLATILE_P (DECL_RTL (decl)) = 1;
1.1.1.8   root     1556: #endif
1.1.1.2   root     1557:     }
                   1558:   else
                   1559:     /* Dynamic-size object: must push space on the stack.  */
                   1560:     {
                   1561:       rtx address, size;
                   1562: 
                   1563:       frame_pointer_needed = 1;
                   1564: 
                   1565:       /* Record the stack pointer on entry to block, if have
                   1566:         not already done so.  */
                   1567:       if (thisblock->data.block.stack_level == 0)
                   1568:        {
                   1569:          do_pending_stack_adjust ();
                   1570:          thisblock->data.block.stack_level
                   1571:            = copy_to_reg (stack_pointer_rtx);
                   1572:          stack_block_stack = thisblock;
                   1573:        }
                   1574: 
                   1575:       /* Compute the variable's size, in bytes.  */
                   1576:       size = expand_expr (convert_units (DECL_SIZE (decl),
                   1577:                                         DECL_SIZE_UNIT (decl),
                   1578:                                         BITS_PER_UNIT),
                   1579:                          0, VOIDmode, 0);
                   1580: 
                   1581:       /* Round it up to this machine's required stack boundary.  */
                   1582: #ifdef STACK_BOUNDARY
                   1583:       /* Avoid extra code if we can prove it's a multiple already.  */
                   1584:       if (DECL_SIZE_UNIT (decl) % STACK_BOUNDARY)
                   1585:        size = round_push (size);
                   1586: #endif
                   1587: 
                   1588:       /* Make space on the stack, and get an rtx for the address of it.  */
                   1589: #ifdef STACK_GROWS_DOWNWARD
                   1590:       anti_adjust_stack (size);
                   1591: #endif
                   1592:       address = copy_to_reg (stack_pointer_rtx);
1.1.1.4   root     1593: #ifdef STACK_POINTER_OFFSET
                   1594:       /* If the contents of the stack pointer reg are offset from the
                   1595:         actual top-of-stack address, add the offset here.  */
                   1596:       emit_insn (gen_add2_insn (address, gen_rtx (CONST_INT, VOIDmode,
                   1597:                                                  STACK_POINTER_OFFSET)));
                   1598: #endif
1.1.1.2   root     1599: #ifndef STACK_GROWS_DOWNWARD
                   1600:       anti_adjust_stack (size);
                   1601: #endif
                   1602: 
                   1603:       /* Reference the variable indirect through that rtx.  */
                   1604:       DECL_RTL (decl) = gen_rtx (MEM, DECL_MODE (decl), address);
                   1605:     }
                   1606: 
                   1607:   if (TREE_VOLATILE (decl))
1.1.1.10  root     1608:     MEM_VOLATILE_P (DECL_RTL (decl)) = 1;
1.1.1.2   root     1609:   if (TREE_READONLY (decl))
1.1.1.10  root     1610:     RTX_UNCHANGING_P (DECL_RTL (decl)) = 1;
1.1.1.2   root     1611: 
                   1612:   /* If doing stupid register allocation, make sure life of any
                   1613:      register variable starts here, at the start of its scope.  */
                   1614: 
                   1615:   if (obey_regdecls
                   1616:       && TREE_CODE (decl) == VAR_DECL
1.1.1.3   root     1617:       && DECL_RTL (decl) != 0)
                   1618:     use_variable (DECL_RTL (decl));
1.1.1.2   root     1619: 
                   1620:   /* Compute and store the initial value now.  */
                   1621: 
1.1.1.3   root     1622:   if (DECL_INITIAL (decl) == error_mark_node)
                   1623:     {
                   1624:       enum tree_code code = TREE_CODE (TREE_TYPE (decl));
                   1625:       if (code == INTEGER_TYPE || code == REAL_TYPE || code == ENUMERAL_TYPE
                   1626:          || code == POINTER_TYPE)
                   1627:        expand_assignment (decl, convert (TREE_TYPE (decl), integer_zero_node),
                   1628:                           0, 0);
                   1629:       emit_queue ();
                   1630:     }
1.1.1.7   root     1631:   else if (DECL_INITIAL (decl) && TREE_CODE (DECL_INITIAL (decl)) != TREE_LIST)
1.1.1.2   root     1632:     {
1.1.1.12! root     1633:       emit_line_note (DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
1.1.1.2   root     1634:       expand_assignment (decl, DECL_INITIAL (decl), 0, 0);
                   1635:       emit_queue ();
                   1636:     }
                   1637: }
                   1638: 
1.1.1.7   root     1639: /* Expand a list of cleanups LIST.
                   1640:    Elements may be expressions or may be nested lists.
                   1641: 
                   1642:    If DONT_DO is nonnull, then any list-element
                   1643:    whose TREE_PURPOSE matches DONT_DO is omitted.
                   1644:    This is sometimes used to avoid a cleanup associated with
                   1645:    a value that is being returned out of the scope.  */
                   1646: 
                   1647: static void
                   1648: expand_cleanups (list, dont_do)
                   1649:      tree list;
                   1650:      tree dont_do;
                   1651: {
                   1652:   tree tail;
                   1653:   for (tail = list; tail; tail = TREE_CHAIN (tail))
                   1654:     if (dont_do == 0 || TREE_PURPOSE (tail) != dont_do)
                   1655:       {
                   1656:        if (TREE_CODE (TREE_VALUE (tail)) == TREE_LIST)
1.1.1.8   root     1657:          expand_cleanups (TREE_VALUE (tail), dont_do);
1.1.1.7   root     1658:        else
                   1659:          expand_expr (TREE_VALUE (tail), const0_rtx, VOIDmode, 0);
                   1660:       }
                   1661: }
                   1662: 
                   1663: /* Expand a list of cleanups for a goto fixup.
                   1664:    The expansion is put into the insn chain after the insn *BEFORE_JUMP
                   1665:    and *BEFORE_JUMP is set to the insn that now comes before the jump.  */
                   1666: 
                   1667: static void
                   1668: fixup_cleanups (list, before_jump)
                   1669:      tree list;
                   1670:      rtx *before_jump;
                   1671: {
                   1672:   rtx beyond_jump = get_last_insn ();
                   1673:   rtx new_before_jump;
                   1674: 
                   1675:   expand_cleanups (list, 0);
                   1676:   new_before_jump = get_last_insn ();
                   1677: 
                   1678:   reorder_insns (NEXT_INSN (beyond_jump), new_before_jump, *before_jump);
                   1679:   *before_jump = new_before_jump;
                   1680: }
1.1.1.8   root     1681: 
                   1682: /* Move all cleanups from the current block_stack
                   1683:    to the containing block_stack, where they are assumed to
                   1684:    have been created.  If anything can cause a temporary to
                   1685:    be created, but not expanded for more than one level of
                   1686:    block_stacks, then this code will have to change.  */
                   1687: 
                   1688: void
                   1689: move_cleanups_up ()
                   1690: {
                   1691:   struct nesting *block = block_stack;
                   1692:   struct nesting *outer = block->next;
                   1693: 
                   1694:   outer->data.block.cleanups
                   1695:     = chainon (outer->data.block.cleanups,
                   1696:               block->data.block.cleanups);
                   1697:   block->data.block.cleanups = 0;
                   1698: }
1.1.1.7   root     1699: 
1.1.1.2   root     1700: /* Enter a case (Pascal) or switch (C) statement.
                   1701:    Push a block onto case_stack and nesting_stack
                   1702:    to accumulate the case-labels that are seen
                   1703:    and to record the labels generated for the statement.
                   1704: 
                   1705:    EXIT_FLAG is nonzero if `exit_something' should exit this case stmt.
                   1706:    Otherwise, this construct is transparent for `exit_something'.
                   1707: 
                   1708:    EXPR is the index-expression to be dispatched on.
                   1709:    TYPE is its nominal type.  We could simply convert EXPR to this type,
                   1710:    but instead we take short cuts.  */
                   1711: 
                   1712: void
                   1713: expand_start_case (exit_flag, expr, type)
                   1714:      int exit_flag;
                   1715:      tree expr;
                   1716:      tree type;
                   1717: {
                   1718:   register struct nesting *thiscase
                   1719:     = (struct nesting *) xmalloc (sizeof (struct nesting));
                   1720: 
                   1721:   /* Make an entry on case_stack for the case we are entering.  */
                   1722: 
                   1723:   thiscase->next = case_stack;
                   1724:   thiscase->all = nesting_stack;
                   1725:   thiscase->depth = ++nesting_depth;
                   1726:   thiscase->exit_label = exit_flag ? gen_label_rtx () : 0;
                   1727:   thiscase->data.case_stmt.case_list = 0;
                   1728:   thiscase->data.case_stmt.index_expr = expr;
                   1729:   thiscase->data.case_stmt.nominal_type = type;
1.1.1.7   root     1730:   thiscase->data.case_stmt.has_default = 0;
1.1.1.2   root     1731:   case_stack = thiscase;
                   1732:   nesting_stack = thiscase;
                   1733: 
                   1734:   do_pending_stack_adjust ();
                   1735: 
1.1.1.6   root     1736:   /* Make sure case_stmt.start points to something that won't
                   1737:      need any transformation before expand_end_case.  */
                   1738:   if (GET_CODE (get_last_insn ()) != NOTE)
                   1739:     emit_note (0, NOTE_INSN_DELETED);
                   1740: 
1.1.1.2   root     1741:   thiscase->data.case_stmt.start = get_last_insn ();
                   1742: }
                   1743: 
                   1744: /* Start a "dummy case statement" within which case labels are invalid
                   1745:    and are not connected to any larger real case statement.
                   1746:    This can be used if you don't want to let a case statement jump
                   1747:    into the middle of certain kinds of constructs.  */
                   1748: 
                   1749: void
                   1750: expand_start_case_dummy ()
                   1751: {
                   1752:   register struct nesting *thiscase
                   1753:     = (struct nesting *) xmalloc (sizeof (struct nesting));
                   1754: 
                   1755:   /* Make an entry on case_stack for the dummy.  */
                   1756: 
                   1757:   thiscase->next = case_stack;
                   1758:   thiscase->all = nesting_stack;
                   1759:   thiscase->depth = ++nesting_depth;
                   1760:   thiscase->exit_label = 0;
                   1761:   thiscase->data.case_stmt.case_list = 0;
                   1762:   thiscase->data.case_stmt.start = 0;
                   1763:   thiscase->data.case_stmt.nominal_type = 0;
1.1.1.7   root     1764:   thiscase->data.case_stmt.has_default = 0;
1.1.1.2   root     1765:   case_stack = thiscase;
                   1766:   nesting_stack = thiscase;
                   1767: }
                   1768: 
                   1769: /* End a dummy case statement.  */
                   1770: 
                   1771: void
                   1772: expand_end_case_dummy ()
                   1773: {
                   1774:   POPSTACK (case_stack);
                   1775: }
1.1.1.7   root     1776: 
1.1.1.2   root     1777: /* Accumulate one case or default label inside a case or switch statement.
                   1778:    VALUE is the value of the case (a null pointer, for a default label).
                   1779: 
                   1780:    If not currently inside a case or switch statement, return 1 and do
                   1781:    nothing.  The caller will print a language-specific error message.
1.1.1.7   root     1782:    If VALUE is a duplicate or overlaps, return 2 and do nothing.
1.1.1.2   root     1783:    If VALUE is out of range, return 3 and do nothing.
                   1784:    Return 0 on success.  */
                   1785: 
                   1786: int
                   1787: pushcase (value, label)
                   1788:      register tree value;
                   1789:      register tree label;
                   1790: {
                   1791:   register tree l;
                   1792:   tree index_type;
                   1793:   tree nominal_type;
                   1794: 
                   1795:   /* Fail if not inside a real case statement.  */
                   1796:   if (! (case_stack && case_stack->data.case_stmt.start))
                   1797:     return 1;
                   1798: 
                   1799:   index_type = TREE_TYPE (case_stack->data.case_stmt.index_expr);
                   1800:   nominal_type = case_stack->data.case_stmt.nominal_type;
                   1801: 
                   1802:   /* If the index is erroneous, avoid more problems: pretend to succeed.  */
                   1803:   if (index_type == error_mark_node)
                   1804:     return 0;
                   1805: 
                   1806:   /* Convert VALUE to the type in which the comparisons are nominally done.  */
                   1807:   if (value != 0)
                   1808:     value = convert (nominal_type, value);
                   1809: 
1.1.1.7   root     1810:   /* Fail if this value is out of range for the actual type of the index
                   1811:      (which may be narrower than NOMINAL_TYPE).  */
                   1812:   if (value != 0 && ! int_fits_type_p (value, index_type))
                   1813:     return 3;
                   1814: 
                   1815:   /* Fail if this is a duplicate or overlaps another entry.  */
                   1816:   if (value == 0)
1.1.1.2   root     1817:     {
1.1.1.7   root     1818:       if (case_stack->data.case_stmt.has_default)
1.1.1.2   root     1819:        return 2;
1.1.1.7   root     1820:       case_stack->data.case_stmt.has_default = 1;
1.1.1.2   root     1821:     }
1.1.1.7   root     1822:   else
                   1823:     {
                   1824:       for (l = case_stack->data.case_stmt.case_list; l; l = TREE_CHAIN (l))
                   1825:        {
                   1826:          tree elem = TREE_PURPOSE (l);
1.1.1.2   root     1827: 
1.1.1.7   root     1828:          if (elem == 0)
                   1829:            ;
                   1830:          else if (TREE_CODE (elem) == INTEGER_CST)
                   1831:            {
                   1832:              if (tree_int_cst_equal (value, elem))
                   1833:                return 2;
                   1834:            }
                   1835:          else if (TREE_CODE (elem) == RANGE_EXPR)
                   1836:            {
                   1837:              if (! tree_int_cst_lt (value, TREE_OPERAND (elem, 0))
                   1838:                  && ! tree_int_cst_lt (TREE_OPERAND (elem, 1), value))
                   1839:                return 2;
                   1840:            }
                   1841:          else abort ();
                   1842:        }
                   1843:     }
                   1844: 
                   1845:   /* Add this label to the list, and succeed.
                   1846:      Copy VALUE so it is temporary rather than momentary.  */
                   1847:   case_stack->data.case_stmt.case_list
                   1848:     = tree_cons (value ? copy_node (value) : 0, label,
                   1849:                 case_stack->data.case_stmt.case_list);
                   1850:   expand_label (label);
                   1851:   return 0;
                   1852: }
                   1853: 
                   1854: #if 0
                   1855: /* Like pushcase but this case applies to all values
                   1856:    between VALUE1 and VALUE2 (inclusive).
                   1857:    The return value is the same as that of pushcase
                   1858:    but there is one additional error code:
                   1859:    4 means the specified range was empty.
                   1860: 
                   1861:    Note that this does not currently work, since expand_end_case
                   1862:    has yet to be extended to handle RANGE_EXPRs.  */
                   1863: 
                   1864: int
                   1865: pushcase_range (value1, value2, label)
                   1866:      register tree value1, value2;
                   1867:      register tree label;
                   1868: {
                   1869:   register tree l;
                   1870:   tree index_type;
                   1871:   tree nominal_type;
                   1872:   tree value;
                   1873: 
                   1874:   /* Fail if not inside a real case statement.  */
                   1875:   if (! (case_stack && case_stack->data.case_stmt.start))
                   1876:     return 1;
                   1877: 
                   1878:   index_type = TREE_TYPE (case_stack->data.case_stmt.index_expr);
                   1879:   nominal_type = case_stack->data.case_stmt.nominal_type;
                   1880: 
                   1881:   /* If the index is erroneous, avoid more problems: pretend to succeed.  */
                   1882:   if (index_type == error_mark_node)
                   1883:     return 0;
                   1884: 
                   1885:   /* Convert VALUEs to type in which the comparisons are nominally done.  */
                   1886:   if (value1 != 0)
                   1887:     value1 = convert (nominal_type, value1);
                   1888:   if (value2 != 0)
                   1889:     value2 = convert (nominal_type, value2);
                   1890: 
                   1891:   /* Fail if these values are out of range.  */
                   1892:   if (value1 != 0 && ! int_fits_type_p (value1, index_type))
                   1893:     return 3;
                   1894: 
                   1895:   if (value2 != 0 && ! int_fits_type_p (value2, index_type))
1.1.1.2   root     1896:     return 3;
                   1897: 
1.1.1.7   root     1898:   /* Fail if the range is empty.  */
                   1899:   if (tree_int_cst_lt (value2, value1))
                   1900:     return 4;
                   1901: 
1.1.1.8   root     1902:   /* If the bounds are equal, turn this into the one-value case.  */
                   1903:   if (tree_int_cst_equal (value1, value2))
                   1904:     return pushcase (value1, label);
                   1905: 
1.1.1.7   root     1906:   /* Construct the RANGE_EXPR that represents this range.  */
                   1907:   value = build_nt (RANGE_EXPR, value1, value2);
                   1908: 
                   1909:   /* Fail if this duplicates or overlaps another entry.  */
                   1910:   for (l = case_stack->data.case_stmt.case_list; l; l = TREE_CHAIN (l))
                   1911:     {
                   1912:       tree elem = TREE_PURPOSE (l);
                   1913: 
                   1914:       if (elem == 0)
                   1915:        ;
                   1916:       else if (TREE_CODE (elem) == INTEGER_CST)
                   1917:        {
                   1918:          if (! tree_int_cst_lt (elem, value1)
                   1919:              && ! tree_int_cst_lt (value2, elem))
                   1920:            return 2;
                   1921:        }
                   1922:       else if (TREE_CODE (elem) == RANGE_EXPR)
                   1923:        {
                   1924:          if (! tree_int_cst_lt (TREE_OPERAND (elem, 1), value1)
                   1925:              && ! tree_int_cst_lt (value2, TREE_OPERAND (elem, 0)))
                   1926:            return 2;
                   1927:        }
                   1928:       else abort ();
                   1929:     }
                   1930: 
1.1.1.2   root     1931:   /* Add this label to the list, and succeed.
                   1932:      Copy VALUE so it is temporary rather than momentary.  */
                   1933:   case_stack->data.case_stmt.case_list
                   1934:     = tree_cons (value ? copy_node (value) : 0, label,
                   1935:                 case_stack->data.case_stmt.case_list);
                   1936:   expand_label (label);
1.1.1.7   root     1937: 
1.1.1.2   root     1938:   return 0;
                   1939: }
1.1.1.7   root     1940: #endif /* 0 */
1.1.1.2   root     1941: 
                   1942: /* Terminate a case (Pascal) or switch (C) statement
                   1943:    in which CASE_INDEX is the expression to be tested.
                   1944:    Generate the code to test it and jump to the right place.  */
                   1945: 
                   1946: void
                   1947: expand_end_case ()
                   1948: {
                   1949:   tree minval, maxval, range;
                   1950:   rtx default_label = 0;
                   1951:   register tree elt;
                   1952:   register tree c;
                   1953:   int count;
                   1954:   rtx index;
                   1955:   rtx table_label = gen_label_rtx ();
                   1956:   int ncases;
                   1957:   rtx *labelvec;
                   1958:   register int i;
                   1959:   rtx before_case;
                   1960:   register struct nesting *thiscase = case_stack;
                   1961:   tree index_expr = thiscase->data.case_stmt.index_expr;
                   1962: 
                   1963:   do_pending_stack_adjust ();
                   1964: 
1.1.1.6   root     1965:   /* An ERROR_MARK occurs for various reasons including invalid data type.  */
                   1966:   if (TREE_TYPE (index_expr) != error_mark_node)
1.1.1.2   root     1967:     {
                   1968:       /* If we don't have a default-label, create one here,
                   1969:         after the body of the switch.  */
1.1.1.7   root     1970:       if (thiscase->data.case_stmt.has_default == 0)
1.1.1.2   root     1971:        pushcase (0, build_decl (LABEL_DECL, NULL_TREE, NULL_TREE));
                   1972: 
                   1973:       before_case = get_last_insn ();
                   1974: 
                   1975:       /* Get upper and lower bounds of case values.
                   1976:         Also convert all the case values to the index expr's data type.  */
                   1977:       count = 0;
                   1978:       for (c = thiscase->data.case_stmt.case_list; c; c = TREE_CHAIN (c))
                   1979:        if (elt = TREE_PURPOSE (c))
                   1980:          {
                   1981:            /* Note that in Pascal it will be possible
                   1982:               to have a RANGE_EXPR here as long as both
                   1983:               ends of the range are constant.
                   1984:               It will be necessary to extend this function
                   1985:               to handle them.  */
                   1986:            if (TREE_CODE (elt) != INTEGER_CST)
                   1987:              abort ();
                   1988: 
                   1989:            TREE_PURPOSE (c) = elt = convert (TREE_TYPE (index_expr), elt);
                   1990: 
                   1991:            /* Count the elements and track the largest and
                   1992:               smallest of them
                   1993:               (treating them as signed even if they are not).  */
                   1994:            if (count++ == 0)
                   1995:              {
                   1996:                minval = maxval = elt;
                   1997:              }
                   1998:            else
                   1999:              {
                   2000:                if (INT_CST_LT (elt, minval))
                   2001:                  minval = elt;
                   2002:                if (INT_CST_LT (maxval, elt))
                   2003:                  maxval = elt;
                   2004:              }
                   2005:          }
                   2006:        else
                   2007:          default_label = label_rtx (TREE_VALUE (c));
                   2008: 
                   2009:       if (default_label == 0)
                   2010:        abort ();
                   2011: 
                   2012:       /* Compute span of values.  */
                   2013:       if (count != 0)
                   2014:        range = combine (MINUS_EXPR, maxval, minval);
                   2015: 
                   2016:       if (count == 0 || TREE_CODE (TREE_TYPE (index_expr)) == ERROR_MARK)
                   2017:        {
                   2018:          expand_expr (index_expr, const0_rtx, VOIDmode, 0);
                   2019:          emit_queue ();
                   2020:          emit_jump (default_label);
                   2021:        }
                   2022:       /* If range of values is much bigger than number of values,
                   2023:         make a sequence of conditional branches instead of a dispatch.
                   2024:         If the switch-index is a constant, do it this way
                   2025:         because we can optimize it.  */
                   2026:       else if (TREE_INT_CST_HIGH (range) != 0
1.1       root     2027: #ifdef HAVE_casesi
1.1.1.2   root     2028:               || count < 4
1.1       root     2029: #else
1.1.1.2   root     2030:               /* If machine does not have a case insn that compares the
                   2031:                  bounds, this means extra overhead for dispatch tables
                   2032:                  which raises the threshold for using them.  */
                   2033:               || count < 5
1.1       root     2034: #endif
1.1.1.2   root     2035:               || (unsigned) (TREE_INT_CST_LOW (range)) > 10 * count
                   2036:               || TREE_CODE (index_expr) == INTEGER_CST)
                   2037:        {
                   2038:          index = expand_expr (index_expr, 0, VOIDmode, 0);
                   2039:          emit_queue ();
1.1       root     2040: 
1.1.1.2   root     2041:          index = protect_from_queue (index, 0);
                   2042:          if (GET_CODE (index) == MEM)
                   2043:            index = copy_to_reg (index);
                   2044:          do_pending_stack_adjust ();
1.1       root     2045: 
1.1.1.2   root     2046:          for (c = thiscase->data.case_stmt.case_list; c; c = TREE_CHAIN (c))
                   2047:            {
                   2048:              elt = TREE_PURPOSE (c);
                   2049:              if (elt && TREE_VALUE (c))
1.1.1.6   root     2050:                do_jump_if_equal (index, expand_expr (elt, 0, VOIDmode, 0),
1.1.1.2   root     2051:                                  label_rtx (TREE_VALUE (c)));
                   2052:            }
                   2053: 
                   2054:          emit_jump (default_label);
                   2055:        }
                   2056:       else
                   2057:        {
1.1       root     2058: #ifdef HAVE_casesi
1.1.1.3   root     2059:          /* Convert the index to SImode.  */
1.1.1.2   root     2060:          if (TYPE_MODE (TREE_TYPE (index_expr)) == DImode)
                   2061:            {
1.1.1.3   root     2062:              index_expr = build (MINUS_EXPR, TREE_TYPE (index_expr),
                   2063:                                  index_expr, minval);
1.1.1.2   root     2064:              minval = integer_zero_node;
                   2065:            }
1.1.1.3   root     2066:          if (TYPE_MODE (TREE_TYPE (index_expr)) != SImode)
                   2067:            index_expr = convert (type_for_size (GET_MODE_BITSIZE (SImode), 0),
                   2068:                                  index_expr);
1.1.1.2   root     2069:          index = expand_expr (index_expr, 0, VOIDmode, 0);
                   2070:          emit_queue ();
                   2071:          index = protect_from_queue (index, 0);
                   2072:          do_pending_stack_adjust ();
                   2073: 
                   2074:          emit_jump_insn (gen_casesi (index, expand_expr (minval, 0, VOIDmode, 0),
                   2075:                                      expand_expr (range, 0, VOIDmode, 0),
                   2076:                                      table_label, default_label));
1.1       root     2077: #else
                   2078: #ifdef HAVE_tablejump
1.1.1.3   root     2079:          index_expr = convert (type_for_size (GET_MODE_BITSIZE (SImode), 0),
1.1.1.2   root     2080:                                build (MINUS_EXPR, TREE_TYPE (index_expr),
                   2081:                                       index_expr, minval));
                   2082:          index = expand_expr (index_expr, 0, VOIDmode, 0);
                   2083:          emit_queue ();
                   2084:          index = protect_from_queue (index, 0);
                   2085:          do_pending_stack_adjust ();
                   2086: 
                   2087:          do_tablejump (index,
                   2088:                        gen_rtx (CONST_INT, VOIDmode, TREE_INT_CST_LOW (range)),
                   2089:                        table_label, default_label);
1.1       root     2090: #else
1.1.1.2   root     2091:          lossage;
                   2092: #endif                         /* not HAVE_tablejump */
                   2093: #endif                         /* not HAVE_casesi */
                   2094: 
                   2095:          /* Get table of labels to jump to, in order of case index.  */
                   2096: 
                   2097:          ncases = TREE_INT_CST_LOW (range) + 1;
                   2098:          labelvec = (rtx *) alloca (ncases * sizeof (rtx));
                   2099:          bzero (labelvec, ncases * sizeof (rtx));
1.1       root     2100: 
1.1.1.2   root     2101:          for (c = thiscase->data.case_stmt.case_list; c; c = TREE_CHAIN (c))
                   2102:            if (TREE_VALUE (c) && (elt = TREE_PURPOSE (c)))
                   2103:              {
                   2104:                register int i
                   2105:                  = TREE_INT_CST_LOW (elt) - TREE_INT_CST_LOW (minval);
                   2106:                labelvec[i]
                   2107:                  = gen_rtx (LABEL_REF, Pmode, label_rtx (TREE_VALUE (c)));
                   2108:              }
                   2109: 
                   2110:          /* Fill in the gaps with the default.  */
                   2111:          for (i = 0; i < ncases; i++)
                   2112:            if (labelvec[i] == 0)
                   2113:              labelvec[i] = gen_rtx (LABEL_REF, Pmode, default_label);
                   2114: 
                   2115:          /* Output the table */
                   2116:          emit_label (table_label);
1.1       root     2117: 
                   2118: #ifdef CASE_VECTOR_PC_RELATIVE
1.1.1.2   root     2119:          emit_jump_insn (gen_rtx (ADDR_DIFF_VEC, CASE_VECTOR_MODE,
                   2120:                                   gen_rtx (LABEL_REF, Pmode, table_label),
                   2121:                                   gen_rtvec_v (ncases, labelvec)));
1.1       root     2122: #else
1.1.1.2   root     2123:          emit_jump_insn (gen_rtx (ADDR_VEC, CASE_VECTOR_MODE,
                   2124:                                   gen_rtvec_v (ncases, labelvec)));
1.1       root     2125: #endif
1.1.1.2   root     2126:          /* If the case insn drops through the table,
                   2127:             after the table we must jump to the default-label.
                   2128:             Otherwise record no drop-through after the table.  */
                   2129: #ifdef CASE_DROPS_THROUGH
                   2130:          emit_jump (default_label);
                   2131: #else
                   2132:          emit_barrier ();
                   2133: #endif
                   2134:        }
                   2135: 
                   2136:       reorder_insns (NEXT_INSN (before_case), get_last_insn (),
                   2137:                     thiscase->data.case_stmt.start);
                   2138:     }
                   2139:   if (thiscase->exit_label)
                   2140:     emit_label (thiscase->exit_label);
                   2141: 
                   2142:   POPSTACK (case_stack);
                   2143: }
                   2144: 
                   2145: /* Generate code to jump to LABEL if OP1 and OP2 are equal.  */
                   2146: /* ??? This may need an UNSIGNEDP argument to work properly ??? */
                   2147: 
                   2148: void
                   2149: do_jump_if_equal (op1, op2, label)
                   2150:      rtx op1, op2, label;
                   2151: {
                   2152:   if (GET_CODE (op1) == CONST_INT
                   2153:       && GET_CODE (op2) == CONST_INT)
                   2154:     {
                   2155:       if (INTVAL (op1) == INTVAL (op2))
                   2156:        emit_jump (label);
                   2157:     }
                   2158:   else
                   2159:     {
                   2160:       emit_cmp_insn (op1, op2, 0, 0);
                   2161:       emit_jump_insn (gen_beq (label));
                   2162:     }
1.1       root     2163: }
                   2164: 
1.1.1.2   root     2165: /* Allocate fixed slots in the stack frame of the current function.  */
1.1       root     2166: 
                   2167: /* Return size needed for stack frame based on slots so far allocated.  */
                   2168: 
                   2169: int
                   2170: get_frame_size ()
                   2171: {
1.1.1.2   root     2172: #ifdef FRAME_GROWS_DOWNWARD
                   2173:   return -frame_offset;
                   2174: #else
1.1       root     2175:   return frame_offset;
1.1.1.2   root     2176: #endif
1.1       root     2177: }
                   2178: 
                   2179: /* Allocate a stack slot of SIZE bytes and return a MEM rtx for it
                   2180:    with machine mode MODE.  */
                   2181: 
                   2182: rtx
                   2183: assign_stack_local (mode, size)
                   2184:      enum machine_mode mode;
                   2185:      int size;
                   2186: {
1.1.1.2   root     2187:   register rtx x, addr;
1.1.1.4   root     2188:   int bigend_correction = 0;
1.1       root     2189: 
1.1.1.2   root     2190:   frame_pointer_needed = 1;
1.1       root     2191: 
                   2192:   /* Make each stack slot a multiple of the main allocation unit.  */
                   2193:   size = (((size + (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - 1)
                   2194:           / (BIGGEST_ALIGNMENT / BITS_PER_UNIT))
                   2195:          * (BIGGEST_ALIGNMENT / BITS_PER_UNIT));
                   2196: 
1.1.1.4   root     2197:   /* On a big-endian machine, if we are allocating more space than we will use,
                   2198:      use the least significant bytes of those that are allocated.  */
                   2199: #ifdef BYTES_BIG_ENDIAN
                   2200:   if (mode != BLKmode)
                   2201:     bigend_correction = size - GET_MODE_SIZE (mode);
                   2202: #endif
                   2203: 
1.1       root     2204: #ifdef FRAME_GROWS_DOWNWARD
                   2205:   frame_offset -= size;
                   2206: #endif
1.1.1.2   root     2207:   addr = gen_rtx (PLUS, Pmode, frame_pointer_rtx,
1.1.1.4   root     2208:                  gen_rtx (CONST_INT, VOIDmode,
                   2209:                           (frame_offset + bigend_correction)));
1.1       root     2210: #ifndef FRAME_GROWS_DOWNWARD
                   2211:   frame_offset += size;
                   2212: #endif
                   2213: 
1.1.1.2   root     2214:   if (! memory_address_p (mode, addr))
                   2215:     invalid_stack_slot = 1;
                   2216: 
                   2217:   x = gen_rtx (MEM, mode, addr);
                   2218: 
                   2219:   return x;
1.1       root     2220: }
                   2221: 
1.1.1.2   root     2222: /* Retroactively move an auto variable from a register to a stack slot.
                   2223:    This is done when an address-reference to the variable is seen.  */
1.1       root     2224: 
1.1.1.2   root     2225: void
                   2226: put_var_into_stack (decl)
                   2227:      tree decl;
                   2228: {
                   2229:   register rtx reg = DECL_RTL (decl);
                   2230:   register rtx new;
1.1       root     2231: 
1.1.1.2   root     2232:   /* No need to do anything if decl has no rtx yet
                   2233:      since in that case caller is setting TREE_ADDRESSABLE
                   2234:      and a stack slot will be assigned when the rtl is made.  */
                   2235:   if (reg == 0)
                   2236:     return;
                   2237:   if (GET_CODE (reg) != REG)
                   2238:     return;
                   2239: 
                   2240:   new = parm_stack_loc (reg);
                   2241:   if (new == 0)
                   2242:     new = assign_stack_local (GET_MODE (reg), GET_MODE_SIZE (GET_MODE (reg)));
                   2243: 
1.1.1.10  root     2244:   XEXP (reg, 0) = XEXP (new, 0);
                   2245:   /* `volatil' bit means one thing for MEMs, another entirely for REGs.  */
                   2246:   REG_USERVAR_P (reg) = 0;
                   2247:   PUT_CODE (reg, MEM);
                   2248: 
1.1.1.2   root     2249:   /* If this is a memory ref that contains aggregate components,
                   2250:      mark it as such for cse and loop optimize.  */
1.1.1.10  root     2251:   MEM_IN_STRUCT_P (reg)
1.1.1.2   root     2252:     = (TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE
                   2253:        || TREE_CODE (TREE_TYPE (decl)) == RECORD_TYPE
                   2254:        || TREE_CODE (TREE_TYPE (decl)) == UNION_TYPE);
                   2255: 
                   2256:   fixup_var_refs (reg);
                   2257: }
                   2258: 
1.1       root     2259: static void
1.1.1.2   root     2260: fixup_var_refs (var)
                   2261:      rtx var;
1.1       root     2262: {
1.1.1.2   root     2263:   register rtx insn;
1.1.1.10  root     2264:   extern rtx sequence_stack;
                   2265:   rtx stack = sequence_stack;
                   2266:   tree pending;
                   2267: 
                   2268:   stack = sequence_stack;
                   2269: 
                   2270:   /* Must scan all insns for stack-refs that exceed the limit.  */
                   2271:   fixup_var_refs_insns (var, get_insns (), stack == 0);
                   2272: 
                   2273:   /* Scan all pending sequences too.  */
                   2274:   for (; stack; stack = XEXP (XEXP (stack, 1), 1))
                   2275:     {
                   2276:       push_to_sequence (XEXP (stack, 0));
                   2277:       fixup_var_refs_insns (var, XEXP (stack, 0),
                   2278:                            XEXP (XEXP (stack, 1), 1) == 0);
                   2279:       end_sequence ();
                   2280:     }
                   2281: 
                   2282:   /* Scan all waiting RTL_EXPRs too.  */
                   2283:   for (pending = rtl_expr_chain; pending; pending = TREE_CHAIN (pending))
                   2284:     {
                   2285:       rtx seq = RTL_EXPR_SEQUENCE (TREE_VALUE (pending));
                   2286:       if (seq != const0_rtx && seq != 0)
                   2287:        {
                   2288:          push_to_sequence (seq);
                   2289:          fixup_var_refs_insns (var, seq, 0);
                   2290:          end_sequence ();
                   2291:        }
                   2292:     }
                   2293: }
1.1.1.2   root     2294: 
1.1.1.10  root     2295: /* Scan the insn-chain starting with INSN for refs to VAR
                   2296:    and fix them up.  TOPLEVEL is nonzero if this chain is the
                   2297:    main chain of insns for the current function.  */
                   2298: 
                   2299: static void
                   2300: fixup_var_refs_insns (var, insn, toplevel)
                   2301:      rtx var;
                   2302:      rtx insn;
                   2303:      int toplevel;
                   2304: {
                   2305:   while (insn)
1.1.1.2   root     2306:     {
                   2307:       rtx next = NEXT_INSN (insn);
                   2308:       if (GET_CODE (insn) == INSN || GET_CODE (insn) == CALL_INSN
                   2309:          || GET_CODE (insn) == JUMP_INSN)
                   2310:        {
                   2311:          /* The insn to load VAR from a home in the arglist
                   2312:             is now a no-op.  When we see it, just delete it.  */
1.1.1.10  root     2313:          if (toplevel
                   2314:              && GET_CODE (PATTERN (insn)) == SET
1.1.1.2   root     2315:              && SET_DEST (PATTERN (insn)) == var
                   2316:              && rtx_equal_p (SET_SRC (PATTERN (insn)), var))
1.1.1.8   root     2317:            {
                   2318:              next = delete_insn (insn);
                   2319:              if (insn == last_parm_insn)
                   2320:                last_parm_insn = PREV_INSN (next);
                   2321:            }
1.1.1.2   root     2322:          else
                   2323:            fixup_var_refs_1 (var, PATTERN (insn), insn);
                   2324:        }
                   2325:       insn = next;
                   2326:     }
                   2327: }
                   2328: 
                   2329: static rtx
                   2330: fixup_var_refs_1 (var, x, insn)
                   2331:      register rtx var;
                   2332:      register rtx x;
                   2333:      rtx insn;
                   2334: {
                   2335:   register int i;
                   2336:   RTX_CODE code = GET_CODE (x);
                   2337:   register char *fmt;
                   2338:   register rtx tem;
                   2339: 
                   2340:   switch (code)
                   2341:     {
                   2342:     case MEM:
                   2343:       if (var == x)
                   2344:        {
                   2345:          x = fixup_stack_1 (x, insn);
                   2346:          tem = gen_reg_rtx (GET_MODE (x));
                   2347:          emit_insn_before (gen_move_insn (tem, x), insn);
                   2348:          return tem;
                   2349:        }
                   2350:       break;
                   2351: 
                   2352:     case REG:
                   2353:     case CC0:
                   2354:     case PC:
                   2355:     case CONST_INT:
                   2356:     case CONST:
                   2357:     case SYMBOL_REF:
                   2358:     case LABEL_REF:
                   2359:     case CONST_DOUBLE:
                   2360:       return x;
                   2361: 
                   2362:     case SIGN_EXTRACT:
                   2363:     case ZERO_EXTRACT:
                   2364:       /* Note that in some cases those types of expressions are altered
                   2365:         by optimize_bit_field, and do not survive to get here.  */
                   2366:     case SUBREG:
                   2367:       tem = x;
                   2368:       while (GET_CODE (tem) == SUBREG || GET_CODE (tem) == SIGN_EXTRACT
                   2369:             || GET_CODE (tem) == ZERO_EXTRACT)
                   2370:        tem = XEXP (tem, 0);
                   2371:       if (tem == var)
                   2372:        {
                   2373:          x = fixup_stack_1 (x, insn);
                   2374:          tem = gen_reg_rtx (GET_MODE (x));
1.1.1.7   root     2375:          if (GET_CODE (x) == SUBREG)
                   2376:            x = fixup_memory_subreg (x);
1.1.1.2   root     2377:          emit_insn_before (gen_move_insn (tem, x), insn);
                   2378:          return tem;
                   2379:        }
                   2380:       break;
                   2381: 
                   2382:     case SET:
                   2383:       /* First do special simplification of bit-field references.  */
                   2384:       if (GET_CODE (SET_DEST (x)) == SIGN_EXTRACT
                   2385:          || GET_CODE (SET_DEST (x)) == ZERO_EXTRACT)
                   2386:        optimize_bit_field (x, insn, 0);
                   2387:       if (GET_CODE (SET_SRC (x)) == SIGN_EXTRACT
                   2388:          || GET_CODE (SET_SRC (x)) == ZERO_EXTRACT)
                   2389:        optimize_bit_field (x, insn, 0);
                   2390: 
                   2391:       {
                   2392:        rtx dest = SET_DEST (x);
                   2393:        rtx src = SET_SRC (x);
                   2394:        rtx outerdest = dest;
                   2395:        rtx outersrc = src;
                   2396: 
                   2397:        while (GET_CODE (dest) == SUBREG || GET_CODE (dest) == STRICT_LOW_PART
                   2398:               || GET_CODE (dest) == SIGN_EXTRACT
                   2399:               || GET_CODE (dest) == ZERO_EXTRACT)
                   2400:          dest = XEXP (dest, 0);
                   2401:        while (GET_CODE (src) == SUBREG
                   2402:               || GET_CODE (src) == SIGN_EXTRACT
                   2403:               || GET_CODE (src) == ZERO_EXTRACT)
                   2404:          src = XEXP (src, 0);
                   2405: 
                   2406:        /* If VAR does not appear at the top level of the SET
                   2407:           just scan the lower levels of the tree.  */
                   2408: 
                   2409:         if (src != var && dest != var)
                   2410:          break;
                   2411: 
                   2412:        /* Clean up (SUBREG:SI (MEM:mode ...) 0)
                   2413:           that may appear inside a SIGN_EXTRACT or ZERO_EXTRACT.
                   2414:           This was legitimate when the MEM was a REG.  */
                   2415: 
                   2416:        if ((GET_CODE (outerdest) == SIGN_EXTRACT
                   2417:             || GET_CODE (outerdest) == ZERO_EXTRACT)
                   2418:            && GET_CODE (XEXP (outerdest, 0)) == SUBREG
                   2419:            && SUBREG_REG (XEXP (outerdest, 0)) == var)
                   2420:          XEXP (outerdest, 0) = fixup_memory_subreg (XEXP (outerdest, 0));
                   2421: 
                   2422:        if ((GET_CODE (outersrc) == SIGN_EXTRACT
                   2423:             || GET_CODE (outersrc) == ZERO_EXTRACT)
                   2424:            && GET_CODE (XEXP (outersrc, 0)) == SUBREG
                   2425:            && SUBREG_REG (XEXP (outersrc, 0)) == var)
                   2426:          XEXP (outersrc, 0) = fixup_memory_subreg (XEXP (outersrc, 0));
                   2427: 
                   2428:        /* Make sure a MEM inside a SIGN_EXTRACT has QImode
                   2429:           since that's what bit-field insns want.  */
                   2430: 
                   2431:        if ((GET_CODE (outerdest) == SIGN_EXTRACT
                   2432:             || GET_CODE (outerdest) == ZERO_EXTRACT)
                   2433:            && GET_CODE (XEXP (outerdest, 0)) == MEM
                   2434:            && GET_MODE (XEXP (outerdest, 0)) != QImode)
                   2435:          {
                   2436:            XEXP (outerdest, 0) = copy_rtx (XEXP (outerdest, 0));
                   2437:            PUT_MODE (XEXP (outerdest, 0), QImode);
                   2438:          }
                   2439: 
                   2440:        if ((GET_CODE (outersrc) == SIGN_EXTRACT
                   2441:             || GET_CODE (outersrc) == ZERO_EXTRACT)
                   2442:            && GET_CODE (XEXP (outersrc, 0)) == MEM
                   2443:            && GET_MODE (XEXP (outersrc, 0)) != QImode)
                   2444:          {
                   2445:            XEXP (outersrc, 0) = copy_rtx (XEXP (outersrc, 0));
                   2446:            PUT_MODE (XEXP (outersrc, 0), QImode);
                   2447:          }
                   2448: 
                   2449:        /* STRICT_LOW_PART is a no-op on memory references
                   2450:           and it can cause combinations to be unrecognizable,
                   2451:           so eliminate it.  */
                   2452: 
                   2453:        if (dest == var && GET_CODE (SET_DEST (x)) == STRICT_LOW_PART)
                   2454:          SET_DEST (x) = XEXP (SET_DEST (x), 0);
                   2455: 
                   2456:        /* An insn to copy VAR into or out of a register
                   2457:           must be left alone, to avoid an infinite loop here.
1.1.1.9   root     2458:           But do fix up the address of VAR's stack slot if nec,
                   2459:           and fix up SUBREGs containing VAR
                   2460:           (since they are now memory subregs).  */
                   2461: 
                   2462:        if (GET_CODE (SET_SRC (x)) == REG || GET_CODE (SET_DEST (x)) == REG
                   2463:            || (GET_CODE (SET_SRC (x)) == SUBREG
                   2464:                && GET_CODE (SUBREG_REG (SET_SRC (x))) == REG)
1.1.1.2   root     2465:            || (GET_CODE (SET_DEST (x)) == SUBREG
                   2466:                && GET_CODE (SUBREG_REG (SET_DEST (x))) == REG))
1.1.1.9   root     2467:          {
                   2468:            if (src == var && GET_CODE (SET_SRC (x)) == SUBREG)
                   2469:              SET_SRC (x) = fixup_memory_subreg (SET_SRC (x));
                   2470:            if (dest == var && GET_CODE (SET_DEST (x)) == SUBREG)
                   2471:              SET_DEST (x) = fixup_memory_subreg (SET_DEST (x));
                   2472:            return fixup_stack_1 (x, insn);
                   2473:          }
1.1.1.2   root     2474: 
                   2475:        /* Otherwise, storing into VAR must be handled specially
                   2476:           by storing into a temporary and copying that into VAR
                   2477:           with a new insn after this one.  */
                   2478: 
                   2479:        if (dest == var)
                   2480:          {
                   2481:            rtx temp;
                   2482:            rtx fixeddest;
                   2483:            tem = SET_DEST (x);
1.1.1.12! root     2484:            /* STRICT_LOW_PART can be discarded, around a MEM.  */
1.1.1.2   root     2485:            if (GET_CODE (tem) == STRICT_LOW_PART)
                   2486:              tem = XEXP (tem, 0);
1.1.1.12! root     2487:            /* Convert (SUBREG (MEM)) to a MEM in a changed mode.  */
        !          2488:            if (GET_CODE (tem) == SUBREG)
        !          2489:              tem = fixup_memory_subreg (tem);
        !          2490:            fixeddest = fixup_stack_1 (tem, insn);
1.1.1.2   root     2491:            temp = gen_reg_rtx (GET_MODE (tem));
                   2492:            emit_insn_after (gen_move_insn (fixeddest, temp), insn);
                   2493:            SET_DEST (x) = temp;
                   2494:          }
                   2495:       }
                   2496:     }
                   2497: 
                   2498:   /* Nothing special about this RTX; fix its operands.  */
                   2499: 
                   2500:   fmt = GET_RTX_FORMAT (code);
                   2501:   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
                   2502:     {
                   2503:       if (fmt[i] == 'e')
                   2504:        XEXP (x, i) = fixup_var_refs_1 (var, XEXP (x, i), insn);
                   2505:       if (fmt[i] == 'E')
                   2506:        {
                   2507:          register int j;
                   2508:          for (j = 0; j < XVECLEN (x, i); j++)
                   2509:            XVECEXP (x, i, j)
                   2510:              = fixup_var_refs_1 (var, XVECEXP (x, i, j), insn);
                   2511:        }
                   2512:     }
                   2513:   return x;
                   2514: }
                   2515: 
                   2516: /* Given X, an rtx of the form (SUBREG:m1 (MEM:m2 addr)),
                   2517:    return an rtx (MEM:m1 newaddr) which is equivalent.  */
                   2518: 
                   2519: static rtx
                   2520: fixup_memory_subreg (x)
                   2521:      rtx x;
                   2522: {
                   2523:   int offset = SUBREG_WORD (x) * UNITS_PER_WORD;
                   2524:   rtx addr = XEXP (SUBREG_REG (x), 0);
1.1.1.7   root     2525:   enum machine_mode mode = GET_MODE (x);
1.1.1.2   root     2526: 
                   2527: #ifdef BYTES_BIG_ENDIAN
1.1.1.8   root     2528:   offset += (MIN (UNITS_PER_WORD, GET_MODE_SIZE (GET_MODE (SUBREG_REG (x))))
1.1.1.2   root     2529:             - MIN (UNITS_PER_WORD, GET_MODE_SIZE (GET_MODE (x))));
                   2530: #endif
                   2531:   return change_address (SUBREG_REG (x), mode,
                   2532:                         plus_constant (addr, offset));
                   2533: }
                   2534: 
                   2535: #if 0
                   2536: /* Fix up any references to stack slots that are invalid memory addresses
                   2537:    because they exceed the maximum range of a displacement.  */
                   2538: 
                   2539: void
                   2540: fixup_stack_slots ()
                   2541: {
                   2542:   register rtx insn;
                   2543: 
                   2544:   /* Did we generate a stack slot that is out of range
                   2545:      or otherwise has an invalid address?  */
                   2546:   if (invalid_stack_slot)
                   2547:     {
                   2548:       /* Yes.  Must scan all insns for stack-refs that exceed the limit.  */
                   2549:       for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
                   2550:        if (GET_CODE (insn) == INSN || GET_CODE (insn) == CALL_INSN
                   2551:            || GET_CODE (insn) == JUMP_INSN)
                   2552:          fixup_stack_1 (PATTERN (insn), insn);
                   2553:     }
                   2554: }
                   2555: #endif
                   2556: 
                   2557: /* For each memory ref within X, if it refers to a stack slot
                   2558:    with an out of range displacement, put the address in a temp register
                   2559:    (emitting new insns before INSN to load these registers)
                   2560:    and alter the memory ref to use that register.
                   2561:    Replace each such MEM rtx with a copy, to avoid clobberage.  */
                   2562: 
                   2563: static rtx
                   2564: fixup_stack_1 (x, insn)
                   2565:      rtx x;
                   2566:      rtx insn;
                   2567: {
                   2568:   register int i;
                   2569:   register RTX_CODE code = GET_CODE (x);
                   2570:   register char *fmt;
                   2571: 
                   2572:   if (code == MEM)
                   2573:     {
                   2574:       register rtx ad = XEXP (x, 0);
                   2575:       /* If we have address of a stack slot but it's not valid
                   2576:         (displacement is too large), compute the sum in a register.  */
                   2577:       if (GET_CODE (ad) == PLUS
                   2578:          && XEXP (ad, 0) == frame_pointer_rtx
                   2579:          && GET_CODE (XEXP (ad, 1)) == CONST_INT)
                   2580:        {
                   2581:          rtx temp;
                   2582:          if (memory_address_p (GET_MODE (x), ad))
                   2583:            return x;
                   2584:          temp = gen_reg_rtx (GET_MODE (ad));
                   2585:          emit_insn_before (gen_move_insn (temp, ad), insn);
                   2586:          return change_address (x, VOIDmode, temp);
                   2587:        }
                   2588:       return x;
                   2589:     }
                   2590: 
                   2591:   fmt = GET_RTX_FORMAT (code);
                   2592:   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
                   2593:     {
                   2594:       if (fmt[i] == 'e')
                   2595:        XEXP (x, i) = fixup_stack_1 (XEXP (x, i), insn);
                   2596:       if (fmt[i] == 'E')
                   2597:        {
                   2598:          register int j;
                   2599:          for (j = 0; j < XVECLEN (x, i); j++)
                   2600:            XVECEXP (x, i, j) = fixup_stack_1 (XVECEXP (x, i, j), insn);
                   2601:        }
                   2602:     }
                   2603:   return x;
1.1       root     2604: }
1.1.1.2   root     2605: 
                   2606: /* Optimization: a bit-field instruction whose field
                   2607:    happens to be a byte or halfword in memory
                   2608:    can be changed to a move instruction.
1.1       root     2609: 
1.1.1.2   root     2610:    We call here when INSN is an insn to examine or store into a bit-field.
                   2611:    BODY is the SET-rtx to be altered.
                   2612: 
                   2613:    EQUIV_MEM is the table `reg_equiv_mem' if that is available; else 0.
                   2614:    (Currently this is called only from stmt.c, and EQUIV_MEM is always 0.)  */
1.1       root     2615: 
                   2616: static void
1.1.1.2   root     2617: optimize_bit_field (body, insn, equiv_mem)
                   2618:      rtx body;
                   2619:      rtx insn;
                   2620:      rtx *equiv_mem;
1.1       root     2621: {
1.1.1.2   root     2622:   register rtx bitfield;
                   2623:   int destflag;
1.1       root     2624: 
1.1.1.2   root     2625:   if (GET_CODE (SET_DEST (body)) == SIGN_EXTRACT
                   2626:       || GET_CODE (SET_DEST (body)) == ZERO_EXTRACT)
                   2627:     bitfield = SET_DEST (body), destflag = 1;
                   2628:   else
                   2629:     bitfield = SET_SRC (body), destflag = 0;
                   2630: 
                   2631:   /* First check that the field being stored has constant size and position
                   2632:      and is in fact a byte or halfword suitably aligned.  */
                   2633: 
                   2634:   if (GET_CODE (XEXP (bitfield, 1)) == CONST_INT
                   2635:       && GET_CODE (XEXP (bitfield, 2)) == CONST_INT
                   2636:       && (INTVAL (XEXP (bitfield, 1)) == GET_MODE_BITSIZE (QImode)
                   2637:          || INTVAL (XEXP (bitfield, 1)) == GET_MODE_BITSIZE (HImode))
                   2638:       && INTVAL (XEXP (bitfield, 2)) % INTVAL (XEXP (bitfield, 1)) == 0)
1.1       root     2639:     {
1.1.1.2   root     2640:       register rtx memref = 0;
                   2641: 
1.1.1.10  root     2642:       /* Now check that the containing word is memory, not a register,
1.1.1.2   root     2643:         and that it is safe to change the machine mode and to
                   2644:         add something to the address.  */
                   2645: 
                   2646:       if (GET_CODE (XEXP (bitfield, 0)) == MEM)
                   2647:        memref = XEXP (bitfield, 0);
                   2648:       else if (GET_CODE (XEXP (bitfield, 0)) == REG
1.1.1.8   root     2649:               && equiv_mem != 0)
                   2650:        memref = equiv_mem[REGNO (XEXP (bitfield, 0))];
1.1.1.2   root     2651:       else if (GET_CODE (XEXP (bitfield, 0)) == SUBREG
                   2652:               && GET_CODE (SUBREG_REG (XEXP (bitfield, 0))) == MEM)
                   2653:        memref = SUBREG_REG (XEXP (bitfield, 0));
                   2654:       else if (GET_CODE (XEXP (bitfield, 0)) == SUBREG
                   2655:               && equiv_mem != 0
1.1.1.8   root     2656:               && GET_CODE (SUBREG_REG (XEXP (bitfield, 0))) == REG)
                   2657:        memref = equiv_mem[REGNO (SUBREG_REG (XEXP (bitfield, 0)))];
1.1.1.2   root     2658: 
                   2659:       if (memref
                   2660:          && ! mode_dependent_address_p (XEXP (memref, 0))
                   2661:          && offsetable_address_p (GET_MODE (bitfield), XEXP (memref, 0)))
1.1       root     2662:        {
1.1.1.2   root     2663:          /* Now adjust the address, first for any subreg'ing
                   2664:             that we are now getting rid of,
                   2665:             and then for which byte of the word is wanted.  */
                   2666: 
                   2667:          register int offset
                   2668:            = INTVAL (XEXP (bitfield, 2)) / GET_MODE_BITSIZE (QImode);
                   2669:          if (GET_CODE (XEXP (bitfield, 0)) == SUBREG)
                   2670:            {
                   2671:              offset += SUBREG_WORD (XEXP (bitfield, 0)) * UNITS_PER_WORD;
                   2672: #ifdef BYTES_BIG_ENDIAN
                   2673:              offset -= (MIN (UNITS_PER_WORD,
                   2674:                              GET_MODE_SIZE (GET_MODE (XEXP (bitfield, 0))))
                   2675:                         - MIN (UNITS_PER_WORD,
                   2676:                                GET_MODE_SIZE (GET_MODE (memref))));
                   2677: #endif
                   2678:            }
1.1.1.8   root     2679: 
1.1.1.2   root     2680:          memref = gen_rtx (MEM,
                   2681:                            (INTVAL (XEXP (bitfield, 1)) == GET_MODE_BITSIZE (QImode)
                   2682:                             ? QImode : HImode),
                   2683:                            XEXP (memref, 0));
1.1       root     2684: 
1.1.1.2   root     2685:          /* Store this memory reference where
                   2686:             we found the bit field reference.  */
1.1       root     2687: 
1.1.1.2   root     2688:          if (destflag)
1.1       root     2689:            {
1.1.1.2   root     2690:              SET_DEST (body)
                   2691:                = adj_offsetable_operand (memref, offset);
                   2692:              if (! CONSTANT_ADDRESS_P (SET_SRC (body)))
1.1       root     2693:                {
1.1.1.2   root     2694:                  rtx src = SET_SRC (body);
                   2695:                  while (GET_CODE (src) == SUBREG
                   2696:                         && SUBREG_WORD (src) == 0)
                   2697:                    src = SUBREG_REG (src);
                   2698:                  if (GET_MODE (src) != GET_MODE (memref))
1.1.1.10  root     2699:                    src = gen_lowpart (GET_MODE (memref), SET_SRC (body));
1.1.1.2   root     2700:                  SET_SRC (body) = src;
1.1       root     2701:                }
1.1.1.2   root     2702:              else if (GET_MODE (SET_SRC (body)) != VOIDmode
                   2703:                       && GET_MODE (SET_SRC (body)) != GET_MODE (memref))
                   2704:                /* This shouldn't happen because anything that didn't have
                   2705:                   one of these modes should have got converted explicitly
                   2706:                   and then referenced through a subreg.
                   2707:                   This is so because the original bit-field was
                   2708:                   handled by agg_mode and so its tree structure had
                   2709:                   the same mode that memref now has.  */
                   2710:                abort ();
                   2711:            }
                   2712:          else
                   2713:            {
1.1.1.8   root     2714:              rtx dest = SET_DEST (body);
                   2715: 
                   2716:              while (GET_CODE (dest) == SUBREG
                   2717:                     && SUBREG_WORD (dest) == 0)
                   2718:                dest = SUBREG_REG (dest);
                   2719:              SET_DEST (body) = dest;
                   2720: 
                   2721:              memref = adj_offsetable_operand (memref, offset);
                   2722:              if (GET_MODE (dest) == GET_MODE (memref))
                   2723:                SET_SRC (body) = memref;
                   2724:              else
                   2725:                {
1.1.1.10  root     2726:                  /* Convert the mem ref to the destination mode.  */
                   2727:                  rtx last = get_last_insn ();
1.1.1.8   root     2728:                  rtx newreg = gen_reg_rtx (GET_MODE (dest));
1.1.1.10  root     2729:                  convert_move (newreg, memref,
                   2730:                                GET_CODE (SET_SRC (body)) == ZERO_EXTRACT);
                   2731:                  /* Put the conversion before the insn being fixed.  */
                   2732:                  reorder_insns (NEXT_INSN (last), get_last_insn (),
                   2733:                                 PREV_INSN (insn));
1.1.1.8   root     2734:                  SET_SRC (body) = newreg;
                   2735:                }
1.1       root     2736:            }
1.1.1.2   root     2737: 
                   2738:          /* Cause the insn to be re-recognized.  */
                   2739: 
                   2740:          INSN_CODE (insn) = -1;
1.1       root     2741:        }
                   2742:     }
                   2743: }
                   2744: 
                   2745: /* 1 + last pseudo register number used for loading a copy
                   2746:    of a parameter of this function.  */
                   2747: 
                   2748: static int max_parm_reg;
                   2749: 
1.1.1.2   root     2750: /* Vector indexed by REGNO, containing location on stack in which
                   2751:    to put the parm which is nominally in pseudo register REGNO,
                   2752:    if we discover that that parm must go in the stack.  */
                   2753: static rtx *parm_reg_stack_loc;
                   2754: 
                   2755: int
                   2756: max_parm_reg_num ()
                   2757: {
                   2758:   return max_parm_reg;
                   2759: }
                   2760: 
                   2761: /* Return the first insn following those generated by `assign_parms'.  */
                   2762: 
                   2763: rtx
                   2764: get_first_nonparm_insn ()
                   2765: {
                   2766:   if (last_parm_insn)
                   2767:     return NEXT_INSN (last_parm_insn);
                   2768:   return get_insns ();
                   2769: }
                   2770: 
                   2771: /* Get the stack home of a REG rtx that is one of this function's parameters.
                   2772:    This is called rather than assign a new stack slot as a local.
                   2773:    Return 0 if there is no existing stack home suitable for such use.  */
                   2774: 
                   2775: static rtx
                   2776: parm_stack_loc (reg)
                   2777:      rtx reg;
                   2778: {
                   2779:   if (REGNO (reg) < max_parm_reg)
                   2780:     return parm_reg_stack_loc[REGNO (reg)];
                   2781:   return 0;
                   2782: }
                   2783: 
1.1       root     2784: /* Assign RTL expressions to the function's parameters.
                   2785:    This may involve copying them into registers and using
                   2786:    those registers as the RTL for them.  */
                   2787: 
                   2788: static void
                   2789: assign_parms (fndecl)
                   2790:      tree fndecl;
                   2791: {
                   2792:   register tree parm;
1.1.1.2   root     2793:   register rtx entry_parm;
                   2794:   register rtx stack_parm;
                   2795:   register CUMULATIVE_ARGS args_so_far;
                   2796:   enum machine_mode passed_mode, nominal_mode;
                   2797:   /* Total space needed so far for args on the stack,
                   2798:      given as a constant and a tree-expression.  */
                   2799:   struct args_size stack_args_size;
1.1.1.8   root     2800:   int first_parm_offset = FIRST_PARM_OFFSET (fndecl);
1.1.1.2   root     2801: 
                   2802:   int nparmregs
                   2803:     = list_length (DECL_ARGUMENTS (fndecl)) + FIRST_PSEUDO_REGISTER;
                   2804: 
                   2805:   /* Nonzero if function takes extra anonymous args.
                   2806:      This means the last named arg must be on the stack
1.1.1.4   root     2807:      right before the anonymous ones.
                   2808:      Also nonzero if the first arg is named `__builtin_va_alist',
                   2809:      which is used on some machines for old-fashioned non-ANSI varargs.h;
                   2810:      this too should be stuck onto the stack as if it had arrived there.  */
1.1.1.2   root     2811:   int vararg
1.1.1.4   root     2812:     = ((DECL_ARGUMENTS (fndecl) != 0
                   2813:        && (! strcmp (IDENTIFIER_POINTER (DECL_NAME (DECL_ARGUMENTS (fndecl))),
                   2814:                      "__builtin_va_alist")))
                   2815:        ||
                   2816:        (TYPE_ARG_TYPES (TREE_TYPE (fndecl)) != 0
                   2817:        && (TREE_VALUE (tree_last (TYPE_ARG_TYPES (TREE_TYPE (fndecl))))
                   2818:            != void_type_node)));
1.1.1.2   root     2819: 
                   2820:   stack_args_size.constant = 0;
                   2821:   stack_args_size.var = 0;
                   2822: 
1.1.1.6   root     2823:   /* If struct value address comes on the stack, count it in size of args.  */
                   2824:   if (DECL_MODE (DECL_RESULT (fndecl)) == BLKmode
                   2825:       && GET_CODE (struct_value_incoming_rtx) == MEM)
                   2826:     stack_args_size.constant += GET_MODE_SIZE (Pmode);
                   2827: 
1.1.1.2   root     2828:   parm_reg_stack_loc = (rtx *) oballoc (nparmregs * sizeof (rtx));
                   2829:   bzero (parm_reg_stack_loc, nparmregs * sizeof (rtx));
                   2830: 
                   2831:   INIT_CUMULATIVE_ARGS (args_so_far, TREE_TYPE (fndecl));
1.1       root     2832: 
1.1.1.2   root     2833:   for (parm = DECL_ARGUMENTS (fndecl); parm; parm = TREE_CHAIN (parm))
1.1       root     2834:     {
1.1.1.2   root     2835:       int aggregate
                   2836:        = (TREE_CODE (TREE_TYPE (parm)) == ARRAY_TYPE
                   2837:           || TREE_CODE (TREE_TYPE (parm)) == RECORD_TYPE
                   2838:           || TREE_CODE (TREE_TYPE (parm)) == UNION_TYPE);
                   2839:       struct args_size stack_offset;
                   2840:       rtx stack_offset_rtx;
1.1.1.6   root     2841:       enum direction where_pad;
1.1.1.2   root     2842: 
                   2843:       DECL_OFFSET (parm) = -1;
                   2844: 
1.1.1.8   root     2845:       if (TREE_TYPE (parm) == error_mark_node
1.1.1.10  root     2846:          /* This can happen after weird syntax errors
                   2847:             or if an enum type is defined among the parms.  */
1.1.1.8   root     2848:          || TREE_CODE (parm) != PARM_DECL
                   2849:          || DECL_ARG_TYPE (parm) == NULL)
1.1.1.2   root     2850:        {
                   2851:          DECL_RTL (parm) = gen_rtx (MEM, BLKmode, const0_rtx);
                   2852:          continue;
                   2853:        }
                   2854: 
                   2855:       /* Find mode of arg as it is passed, and mode of arg
                   2856:         as it should be during execution of this function.  */
                   2857:       passed_mode = TYPE_MODE (DECL_ARG_TYPE (parm));
                   2858:       nominal_mode = TYPE_MODE (TREE_TYPE (parm));
                   2859: 
1.1.1.6   root     2860:       /* Get this parm's offset as an rtx.  */
                   2861:       stack_offset = stack_args_size;
1.1.1.8   root     2862:       stack_offset.constant += first_parm_offset;
1.1.1.6   root     2863: 
                   2864:       /* Find out if the parm needs padding, and whether above or below.  */
                   2865:       where_pad
                   2866:        = FUNCTION_ARG_PADDING (passed_mode,
                   2867:                                expand_expr (size_in_bytes (DECL_ARG_TYPE (parm)),
                   2868:                                             0, VOIDmode, 0));
                   2869: 
                   2870:       /* If it is padded below, adjust the stack address
                   2871:         upward over the padding.  */
                   2872:       if (where_pad == downward)
                   2873:        {
                   2874:          if (passed_mode != BLKmode)
                   2875:            {
                   2876:              if (GET_MODE_BITSIZE (passed_mode) % PARM_BOUNDARY)
                   2877:                stack_offset.constant
                   2878:                  += (((GET_MODE_BITSIZE (passed_mode) + PARM_BOUNDARY - 1)
                   2879:                       / PARM_BOUNDARY * PARM_BOUNDARY / BITS_PER_UNIT)
                   2880:                      - GET_MODE_SIZE (passed_mode));
                   2881:            }
                   2882:          else
                   2883:            {
                   2884:              tree sizetree = size_in_bytes (DECL_ARG_TYPE (parm));
                   2885:              /* Round the size up to multiple of PARM_BOUNDARY bits.  */
                   2886:              tree s1 = convert_units (sizetree, BITS_PER_UNIT, PARM_BOUNDARY);
                   2887:              tree s2 = convert_units (s1, PARM_BOUNDARY, BITS_PER_UNIT);
                   2888:              /* Add it in.  */
                   2889:              ADD_PARM_SIZE (stack_offset, s2);
                   2890:              SUB_PARM_SIZE (stack_offset, sizetree);
                   2891:            }
                   2892:        }
                   2893: 
                   2894:       stack_offset_rtx = ARGS_SIZE_RTX (stack_offset);
                   2895: 
1.1.1.2   root     2896:       /* Determine parm's home in the stack,
                   2897:         in case it arrives in the stack or we should pretend it did.  */
                   2898:       stack_parm
                   2899:        = gen_rtx (MEM, passed_mode,
                   2900:                   memory_address (passed_mode,
                   2901:                                   gen_rtx (PLUS, Pmode,
                   2902:                                            arg_pointer_rtx, stack_offset_rtx)));
                   2903: 
                   2904:       /* If this is a memory ref that contains aggregate components,
                   2905:         mark it as such for cse and loop optimize.  */
1.1.1.10  root     2906:       MEM_IN_STRUCT_P (stack_parm) = aggregate;
1.1.1.2   root     2907: 
                   2908:       /* Let machine desc say which reg (if any) the parm arrives in.
                   2909:         0 means it arrives on the stack.  */
                   2910:       entry_parm = 0;
                   2911:       /* Variable-size args, and args following such, are never in regs.  */
                   2912:       if (TREE_CODE (TYPE_SIZE (TREE_TYPE (parm))) == INTEGER_CST
                   2913:          || stack_offset.var != 0)
                   2914:        {
                   2915: #ifdef FUNCTION_INCOMING_ARG
                   2916:          entry_parm
                   2917:            = FUNCTION_INCOMING_ARG (args_so_far, passed_mode,
                   2918:                                     DECL_ARG_TYPE (parm), 1);
                   2919: #else
                   2920:          entry_parm
                   2921:            = FUNCTION_ARG (args_so_far, passed_mode, DECL_ARG_TYPE (parm), 1);
                   2922: #endif
                   2923:        }
                   2924:       /* If this parm was passed part in regs and part in memory,
                   2925:         pretend it arrived entirely in memory
                   2926:         by pushing the register-part onto the stack.
                   2927: 
                   2928:         In the special case of a DImode or DFmode that is split,
                   2929:         we could put it together in a pseudoreg directly,
                   2930:         but for now that's not worth bothering with.  */
                   2931: 
                   2932:       /* If this is the last named arg and anonymous args follow,
                   2933:         likewise pretend this arg arrived on the stack
                   2934:         so varargs can find the anonymous args following it.  */
                   2935:       {
                   2936:        int nregs = 0;
                   2937:        int i;
                   2938: #ifdef FUNCTION_ARG_PARTIAL_NREGS
                   2939:        nregs = FUNCTION_ARG_PARTIAL_NREGS (args_so_far, passed_mode,
                   2940:                                            DECL_ARG_TYPE (parm), 1);
                   2941: #endif
                   2942:        if (TREE_CHAIN (parm) == 0 && vararg && entry_parm != 0)
1.1.1.4   root     2943:          {
                   2944:            if (GET_MODE (entry_parm) == BLKmode)
                   2945:              nregs = GET_MODE_SIZE (GET_MODE (entry_parm)) / UNITS_PER_WORD;
                   2946:            else
                   2947:              nregs = (int_size_in_bytes (DECL_ARG_TYPE (parm))
                   2948:                       / UNITS_PER_WORD);
                   2949:          }
1.1.1.2   root     2950: 
                   2951:        if (nregs > 0)
1.1.1.4   root     2952:          {
                   2953:            current_function_pretend_args_size
                   2954:              = (((nregs * UNITS_PER_WORD) + (PARM_BOUNDARY / BITS_PER_UNIT) - 1)
                   2955:                 / (PARM_BOUNDARY / BITS_PER_UNIT)
                   2956:                 * (PARM_BOUNDARY / BITS_PER_UNIT));
                   2957: 
                   2958:            i = nregs;
                   2959:            while (--i >= 0)
                   2960:              emit_move_insn (gen_rtx (MEM, SImode,
                   2961:                                       plus_constant (XEXP (stack_parm, 0),
                   2962:                                                      i * GET_MODE_SIZE (SImode))),
                   2963:                              gen_rtx (REG, SImode, REGNO (entry_parm) + i));
                   2964:            entry_parm = stack_parm;
                   2965:          }
1.1.1.2   root     2966:       }
                   2967: 
1.1.1.4   root     2968:       /* If we didn't decide this parm came in a register,
                   2969:         by default it came on the stack.  */
1.1.1.2   root     2970:       if (entry_parm == 0)
                   2971:        entry_parm = stack_parm;
                   2972: 
1.1.1.4   root     2973:       /* For a stack parm, record in DECL_OFFSET the arglist offset
                   2974:         of the parm at the time it is passed (before conversion).  */
1.1.1.2   root     2975:       if (entry_parm == stack_parm)
1.1.1.4   root     2976:        DECL_OFFSET (parm) = stack_offset.constant * BITS_PER_UNIT;
                   2977: 
                   2978:       /* If there is actually space on the stack for this parm,
                   2979:         count it in stack_args_size; otherwise set stack_parm to 0
                   2980:         to indicate there is no preallocated stack slot for the parm.  */
                   2981: 
                   2982:       if (entry_parm == stack_parm
                   2983: #ifdef REG_PARM_STACK_SPACE
                   2984:          /* On some machines, even if a parm value arrives in a register
                   2985:             there is still an (uninitialized) stack slot allocated for it.  */
                   2986:          || 1
                   2987: #endif
                   2988:          )
1.1.1.2   root     2989:        {
                   2990:          tree sizetree = size_in_bytes (DECL_ARG_TYPE (parm));
1.1.1.6   root     2991:          if (where_pad != none)
                   2992:            {
                   2993:              /* Round the size up to multiple of PARM_BOUNDARY bits.  */
                   2994:              tree s1 = convert_units (sizetree, BITS_PER_UNIT, PARM_BOUNDARY);
                   2995:              sizetree = convert_units (s1, PARM_BOUNDARY, BITS_PER_UNIT);
                   2996:            }
1.1.1.2   root     2997:          /* Add it in.  */
1.1.1.6   root     2998:          ADD_PARM_SIZE (stack_args_size, sizetree);
1.1.1.2   root     2999:        }
1.1.1.4   root     3000:       else
                   3001:        /* No stack slot was pushed for this parm.  */
                   3002:        stack_parm = 0;
1.1.1.2   root     3003: 
1.1.1.4   root     3004:       /* Now adjust STACK_PARM to the mode and precise location
1.1.1.2   root     3005:         where this parameter should live during execution,
                   3006:         if we discover that it must live in the stack during execution.
                   3007:         To make debuggers happier on big-endian machines, we store
                   3008:         the value in the last bytes of the space available.  */
                   3009: 
1.1.1.4   root     3010:       if (nominal_mode != BLKmode && nominal_mode != passed_mode
                   3011:          && stack_parm != 0)
1.1.1.2   root     3012:        {
                   3013: #ifdef BYTES_BIG_ENDIAN
1.1.1.6   root     3014:          if (GET_MODE_SIZE (nominal_mode) < UNITS_PER_WORD)
                   3015:            {
                   3016:              stack_offset.constant
                   3017:                += GET_MODE_SIZE (passed_mode)
                   3018:                  - GET_MODE_SIZE (nominal_mode);
                   3019:              stack_offset_rtx = ARGS_SIZE_RTX (stack_offset);
                   3020:            }
1.1.1.2   root     3021: #endif
                   3022: 
                   3023:          stack_parm
                   3024:            = gen_rtx (MEM, nominal_mode,
                   3025:                       memory_address (nominal_mode,
                   3026:                                       gen_rtx (PLUS, Pmode,
                   3027:                                                arg_pointer_rtx,
                   3028:                                                stack_offset_rtx)));
                   3029: 
                   3030:          /* If this is a memory ref that contains aggregate components,
                   3031:             mark it as such for cse and loop optimize.  */
1.1.1.10  root     3032:          MEM_IN_STRUCT_P (stack_parm) = aggregate;
1.1.1.2   root     3033:        }
                   3034: 
                   3035:       /* ENTRY_PARM is an RTX for the parameter as it arrives,
                   3036:         in the mode in which it arrives.
1.1.1.4   root     3037:         STACK_PARM is an RTX for a stack slot where the parameter can live
                   3038:         during the function (in case we want to put it there).
                   3039:         STACK_PARM is 0 if no stack slot was pushed for it.
1.1       root     3040: 
1.1.1.4   root     3041:         Now output code if necessary to convert ENTRY_PARM to
1.1       root     3042:         the type in which this function declares it,
1.1.1.4   root     3043:         and store that result in an appropriate place,
                   3044:         which may be a pseudo reg, may be STACK_PARM,
                   3045:         or may be a local stack slot if STACK_PARM is 0.
                   3046: 
                   3047:         Set DECL_RTL to that place.  */
1.1.1.2   root     3048: 
                   3049:       if (nominal_mode == BLKmode)
                   3050:        {
                   3051:          /* If a BLKmode arrives in registers, copy it to a stack slot.  */
1.1.1.4   root     3052:          if (GET_CODE (entry_parm) == REG)
1.1.1.2   root     3053:            {
1.1.1.4   root     3054:              if (stack_parm == 0)
                   3055:                stack_parm
                   3056:                  = assign_stack_local (GET_MODE (entry_parm),
                   3057:                                        int_size_in_bytes (TREE_TYPE (parm)));
1.1.1.2   root     3058: 
                   3059:              move_block_from_reg (REGNO (entry_parm), stack_parm,
                   3060:                                   int_size_in_bytes (TREE_TYPE (parm))
                   3061:                                   / UNITS_PER_WORD);
                   3062:            }
                   3063:          DECL_RTL (parm) = stack_parm;
                   3064:        }
1.1.1.10  root     3065:       else if (! ((obey_regdecls && ! TREE_REGDECL (parm)
                   3066:                   && ! TREE_INLINE (fndecl))
1.1.1.2   root     3067:                  /* If -ffloat-store specified, don't put explicit
                   3068:                     float variables into registers.  */
                   3069:                  || (flag_float_store
                   3070:                      && TREE_CODE (TREE_TYPE (parm)) == REAL_TYPE)))
1.1       root     3071:        {
1.1.1.2   root     3072:          /* Store the parm in a pseudoregister during the function.  */
                   3073:          register rtx parmreg = gen_reg_rtx (nominal_mode);
1.1       root     3074: 
1.1.1.10  root     3075:          REG_USERVAR_P (parmreg) = 1;
1.1       root     3076:          DECL_RTL (parm) = parmreg;
                   3077: 
                   3078:          /* Copy the value into the register.  */
1.1.1.2   root     3079:          if (GET_MODE (parmreg) != GET_MODE (entry_parm))
                   3080:            convert_move (parmreg, entry_parm, 0);
1.1       root     3081:          else
1.1.1.2   root     3082:            emit_move_insn (parmreg, entry_parm);
                   3083: 
                   3084:          /* In any case, record the parm's desired stack location
                   3085:             in case we later discover it must live in the stack.  */
                   3086:          if (REGNO (parmreg) >= nparmregs)
                   3087:            {
                   3088:              rtx *new;
                   3089:              nparmregs = REGNO (parmreg) + 5;
                   3090:              new = (rtx *) oballoc (nparmregs * sizeof (rtx));
                   3091:              bcopy (parm_reg_stack_loc, new, nparmregs * sizeof (rtx));
                   3092:              parm_reg_stack_loc = new;
                   3093:            }
                   3094:          parm_reg_stack_loc[REGNO (parmreg)] = stack_parm;
1.1       root     3095: 
1.1.1.2   root     3096:          /* Mark the register as eliminable if we did no conversion
                   3097:             and it was copied from memory at a fixed offset.  */
                   3098:          if (nominal_mode == passed_mode
                   3099:              && GET_CODE (entry_parm) == MEM
                   3100:              && stack_offset.var == 0)
1.1.1.10  root     3101:            REG_NOTES (get_last_insn ())
                   3102:              = gen_rtx (EXPR_LIST, REG_EQUIV,
                   3103:                         entry_parm, REG_NOTES (get_last_insn ()));
1.1       root     3104: 
                   3105:          /* For pointer data type, suggest pointer register.  */
                   3106:          if (TREE_CODE (TREE_TYPE (parm)) == POINTER_TYPE)
                   3107:            mark_reg_pointer (parmreg);
                   3108:        }
1.1.1.2   root     3109:       else
1.1       root     3110:        {
1.1.1.2   root     3111:          /* Value must be stored in the stack slot STACK_PARM
                   3112:             during function execution.  */
                   3113: 
                   3114:          if (passed_mode != nominal_mode)
                   3115:            /* Conversion is required.  */
                   3116:            entry_parm = convert_to_mode (nominal_mode, entry_parm, 0);
                   3117: 
                   3118:          if (entry_parm != stack_parm)
                   3119:            {
                   3120:              if (stack_parm == 0)
                   3121:                stack_parm = assign_stack_local (GET_MODE (entry_parm),
                   3122:                                                 GET_MODE_SIZE (GET_MODE (entry_parm)));
                   3123:              emit_move_insn (stack_parm, entry_parm);
                   3124:            }
                   3125: 
                   3126:          DECL_RTL (parm) = stack_parm;
                   3127:          frame_pointer_needed = 1;
1.1       root     3128:        }
1.1.1.2   root     3129:       
                   3130:       if (TREE_VOLATILE (parm))
1.1.1.10  root     3131:        MEM_VOLATILE_P (DECL_RTL (parm)) = 1;
1.1.1.2   root     3132:       if (TREE_READONLY (parm))
1.1.1.10  root     3133:        RTX_UNCHANGING_P (DECL_RTL (parm)) = 1;
1.1.1.2   root     3134: 
                   3135:       /* Update info on where next arg arrives in registers.  */
                   3136: 
                   3137:       FUNCTION_ARG_ADVANCE (args_so_far, passed_mode, DECL_ARG_TYPE (parm), 1);
1.1       root     3138:     }
1.1.1.4   root     3139: 
1.1       root     3140:   max_parm_reg = max_reg_num ();
1.1.1.2   root     3141:   last_parm_insn = get_last_insn ();
                   3142: 
                   3143:   current_function_args_size = stack_args_size.constant;
1.1       root     3144: }
                   3145: 
                   3146: /* Allocation of space for returned structure values.
                   3147:    During the rtl generation pass, `get_structure_value_addr'
                   3148:    is called from time to time to request the address of a block in our
                   3149:    stack frame in which called functions will store the structures
                   3150:    they are returning.  The same space is used for all of these blocks.  
                   3151: 
1.1.1.2   root     3152:    We allocate these blocks like stack locals.  We keep reusing
                   3153:    the same block until a bigger one is needed.  */
                   3154: 
                   3155: /* Length in bytes of largest structure value returned by
                   3156:    any function called so far in this function.  */
                   3157: static int max_structure_value_size;
1.1       root     3158: 
1.1.1.2   root     3159: /* An rtx for the addr we are currently using for structure values.
                   3160:    This is typically (PLUS (REG:SI stackptr) (CONST_INT...)).  */
                   3161: static rtx structure_value;
1.1       root     3162: 
                   3163: rtx
                   3164: get_structure_value_addr (sizex)
                   3165:      rtx sizex;
                   3166: {
                   3167:   register int size;
                   3168:   if (GET_CODE (sizex) != CONST_INT)
                   3169:     abort ();
                   3170:   size = INTVAL (sizex);
                   3171: 
                   3172:   /* Round up to a multiple of the main allocation unit.  */
                   3173:   size = (((size + (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - 1)
                   3174:           / (BIGGEST_ALIGNMENT / BITS_PER_UNIT))
                   3175:          * (BIGGEST_ALIGNMENT / BITS_PER_UNIT));
                   3176: 
1.1.1.2   root     3177:   /* If this size is bigger than space we know to use,
                   3178:      get a bigger piece of space.  */
1.1       root     3179:   if (size > max_structure_value_size)
                   3180:     {
                   3181:       max_structure_value_size = size;
1.1.1.2   root     3182:       structure_value = assign_stack_local (BLKmode, size);
                   3183:       if (GET_CODE (structure_value) == MEM)
                   3184:        structure_value = XEXP (structure_value, 0);
1.1       root     3185:     }
1.1.1.2   root     3186: 
                   3187:   return structure_value;
1.1       root     3188: }
1.1.1.2   root     3189: 
                   3190: /* Walk the tree of LET_STMTs describing the binding levels within a function
                   3191:    and warn about uninitialized variables.
                   3192:    This is done after calling flow_analysis and before global_alloc
                   3193:    clobbers the pseudo-regs to hard regs.  */
1.1       root     3194: 
1.1.1.2   root     3195: void
                   3196: uninitialized_vars_warning (block)
                   3197:      tree block;
1.1       root     3198: {
1.1.1.2   root     3199:   register tree decl, sub;
                   3200:   for (decl = STMT_VARS (block); decl; decl = TREE_CHAIN (decl))
                   3201:     {
                   3202:       if (TREE_CODE (decl) == VAR_DECL
                   3203:          /* These warnings are unreliable for and aggregates
                   3204:             because assigning the fields one by one can fail to convince
                   3205:             flow.c that the entire aggregate was initialized.
                   3206:             Unions are troublesome because members may be shorter.  */
                   3207:          && TREE_CODE (TREE_TYPE (decl)) != RECORD_TYPE
                   3208:          && TREE_CODE (TREE_TYPE (decl)) != UNION_TYPE
                   3209:          && TREE_CODE (TREE_TYPE (decl)) != ARRAY_TYPE
                   3210:          && GET_CODE (DECL_RTL (decl)) == REG
                   3211:          && regno_uninitialized (REGNO (DECL_RTL (decl))))
                   3212:        warning_with_decl (decl,
                   3213:                           "variable `%s' used uninitialized in this function");
                   3214:       if (TREE_CODE (decl) == VAR_DECL
                   3215:          && GET_CODE (DECL_RTL (decl)) == REG
                   3216:          && regno_clobbered_at_setjmp (REGNO (DECL_RTL (decl))))
                   3217:        warning_with_decl (decl,
                   3218:                           "variable `%s' may be clobbered by `longjmp'");
                   3219:     }
                   3220:   for (sub = STMT_BODY (block); sub; sub = TREE_CHAIN (sub))
                   3221:     uninitialized_vars_warning (sub);
1.1       root     3222: }
1.1.1.11  root     3223: 
                   3224: /* If this function call setjmp, put all vars into the stack
                   3225:    unless they were declared `register'.  */
                   3226: 
                   3227: void
                   3228: setjmp_protect (block)
                   3229:      tree block;
                   3230: {
                   3231:   register tree decl, sub;
                   3232:   for (decl = STMT_VARS (block); decl; decl = TREE_CHAIN (decl))
                   3233:     if ((TREE_CODE (decl) == VAR_DECL
                   3234:         || TREE_CODE (decl) == PARM_DECL)
                   3235:        && DECL_RTL (decl) != 0
                   3236:        && GET_CODE (DECL_RTL (decl)) == REG
                   3237:        && ! TREE_REGDECL (decl))
                   3238:       put_var_into_stack (decl);
                   3239:   for (sub = STMT_BODY (block); sub; sub = TREE_CHAIN (sub))
                   3240:     setjmp_protect (sub);
                   3241: }
1.1       root     3242: 
1.1.1.2   root     3243: /* Generate RTL for the start of the function FUNC (a FUNCTION_DECL tree node)
                   3244:    and initialize static variables for generating RTL for the statements
                   3245:    of the function.  */
1.1       root     3246: 
1.1.1.2   root     3247: void
                   3248: expand_function_start (subr)
1.1       root     3249:      tree subr;
                   3250: {
                   3251:   register int i;
1.1.1.2   root     3252:   tree tem;
1.1       root     3253: 
                   3254:   this_function = subr;
1.1.1.2   root     3255:   cse_not_expected = ! optimize;
                   3256: 
                   3257:   /* We have not yet found a reason why a frame pointer cannot
                   3258:      be omitted for this function in particular, but maybe we know
                   3259:      a priori that it is required.
                   3260:      `flag_omit_frame_pointer' has its main effect here.  */
                   3261:   frame_pointer_needed = FRAME_POINTER_REQUIRED || ! flag_omit_frame_pointer;
1.1       root     3262: 
1.1.1.2   root     3263:   /* No gotos have been expanded yet.  */
                   3264:   goto_fixup_chain = 0;
1.1       root     3265: 
1.1.1.2   root     3266:   /* No invalid stack slots have been made yet.  */
                   3267:   invalid_stack_slot = 0;
                   3268: 
                   3269:   /* Initialize the RTL mechanism.  */
                   3270:   init_emit (write_symbols);
                   3271: 
                   3272:   /* Initialize the queue of pending postincrement and postdecrements,
                   3273:      and some other info in expr.c.  */
                   3274:   init_expr ();
                   3275: 
                   3276:   init_const_rtx_hash_table ();
                   3277: 
                   3278:   /* Decide whether function should try to pop its args on return.  */
                   3279: 
                   3280:   current_function_pops_args = RETURN_POPS_ARGS (TREE_TYPE (subr));
                   3281: 
                   3282:   current_function_name = IDENTIFIER_POINTER (DECL_NAME (subr));
                   3283: 
1.1.1.10  root     3284:   /* Nonzero if this is a nested function that uses a static chain.  */
                   3285: 
                   3286:   current_function_needs_context = (DECL_CONTEXT (current_function_decl) != 0);
                   3287: 
1.1.1.11  root     3288:   /* Set if a call to setjmp is seen.  */
                   3289: 
                   3290:   current_function_calls_setjmp = 0;
                   3291: 
1.1.1.10  root     3292:   /* Nonzero if this function needs an arg saying where to store value.  */
                   3293:   current_function_returns_struct
                   3294:     = (DECL_MODE (DECL_RESULT (current_function_decl)) == BLKmode);
                   3295: 
1.1.1.2   root     3296:   /* Make the label for return statements to jump to, if this machine
                   3297:      does not have a one-instruction return.  */
1.1.1.8   root     3298: #ifdef HAVE_return
                   3299:   if (HAVE_return)
                   3300:     return_label = 0;
                   3301:   else
                   3302:     return_label = gen_label_rtx ();
1.1.1.2   root     3303: #else
1.1.1.8   root     3304:   return_label = gen_label_rtx ();
1.1       root     3305: #endif
                   3306: 
1.1.1.2   root     3307:   /* No space assigned yet for structure values.  */
1.1       root     3308:   max_structure_value_size = 0;
1.1.1.2   root     3309:   structure_value = 0;
1.1       root     3310: 
1.1.1.2   root     3311:   /* We are not currently within any block, conditional, loop or case.  */
1.1       root     3312:   block_stack = 0;
1.1.1.2   root     3313:   loop_stack = 0;
                   3314:   case_stack = 0;
                   3315:   cond_stack = 0;
                   3316:   nesting_stack = 0;
                   3317:   nesting_depth = 0;
                   3318: 
                   3319:   /* We have not yet needed to make a label to jump to for tail-recursion.  */
1.1       root     3320:   tail_recursion_label = 0;
                   3321: 
1.1.1.2   root     3322:   /* No stack slots allocated yet.  */
                   3323:   frame_offset = STARTING_FRAME_OFFSET;
                   3324: 
1.1.1.5   root     3325:   /* No SAVE_EXPRs in this function yet.  */
                   3326:   save_expr_regs = 0;
                   3327: 
1.1.1.10  root     3328:   /* No RTL_EXPRs in this function yet.  */
                   3329:   rtl_expr_chain = 0;
                   3330: 
1.1.1.4   root     3331:   /* Within function body, compute a type's size as soon it is laid out.  */
                   3332:   immediate_size_expand++;
                   3333: 
1.1.1.2   root     3334:   init_pending_stack_adjust ();
1.1       root     3335:   clear_current_args_size ();
1.1.1.7   root     3336:   current_function_pretend_args_size = 0;
1.1       root     3337: 
                   3338:   /* Prevent ever trying to delete the first instruction of a function.
                   3339:      Also tell final how to output a linenum before the function prologue.  */
1.1.1.12! root     3340:   emit_line_note (DECL_SOURCE_FILE (subr), DECL_SOURCE_LINE (subr));
1.1       root     3341:   /* Make sure first insn is a note even if we don't want linenums.
                   3342:      This makes sure the first insn will never be deleted.
                   3343:      Also, final expects a note to appear there.  */
                   3344:   emit_note (0, NOTE_INSN_DELETED);
                   3345: 
                   3346:   /* Initialize rtx for parameters and local variables.
                   3347:      In some cases this requires emitting insns.  */
                   3348: 
                   3349:   assign_parms (subr);
1.1.1.2   root     3350: 
1.1       root     3351:   /* Initialize rtx used to return the value.  */
                   3352: 
                   3353:   if (DECL_MODE (DECL_RESULT (subr)) == BLKmode)
                   3354:     {
                   3355:       /* Returning something that won't go in a register.  */
                   3356:       register rtx value_address;
                   3357: 
1.1.1.2   root     3358:       /* Expect to be passed the address of a place to store the value.  */
1.1       root     3359:       value_address = gen_reg_rtx (Pmode);
1.1.1.2   root     3360:       emit_move_insn (value_address, struct_value_incoming_rtx);
1.1       root     3361:       DECL_RTL (DECL_RESULT (subr))
                   3362:        = gen_rtx (MEM, DECL_MODE (DECL_RESULT (subr)),
                   3363:                   value_address);
                   3364:     }
                   3365:   else
1.1.1.2   root     3366: #ifdef FUNCTION_OUTGOING_VALUE
1.1       root     3367:     DECL_RTL (DECL_RESULT (subr))
1.1.1.2   root     3368:       = FUNCTION_OUTGOING_VALUE (TREE_TYPE (DECL_RESULT (subr)), subr);
                   3369: #else
                   3370:     DECL_RTL (DECL_RESULT (subr))
                   3371:       = FUNCTION_VALUE (TREE_TYPE (DECL_RESULT (subr)), subr);
                   3372: #endif
1.1.1.6   root     3373: 
                   3374:   /* Mark this reg as the function's return value.  */
                   3375:   if (GET_CODE (DECL_RTL (DECL_RESULT (subr))) == REG)
                   3376:     REG_FUNCTION_VALUE_P (DECL_RTL (DECL_RESULT (subr))) = 1;
1.1.1.8   root     3377: 
1.1.1.10  root     3378:   /* If doing stupid allocation, mark parms as born here.  */
                   3379: 
                   3380:   if (obey_regdecls)
                   3381:     {
                   3382:       parm_birth_insn = get_last_insn ();
                   3383:       for (i = FIRST_PSEUDO_REGISTER; i < max_parm_reg; i++)
                   3384:        use_variable (regno_reg_rtx[i]);
                   3385:     }
                   3386: 
1.1.1.8   root     3387:   /* After the parm initializations is where the tail-recursion label
                   3388:      should go, if we end up needing one.  */
                   3389:   tail_recursion_reentry = get_last_insn ();
                   3390: 
                   3391:   /* Evaluate now the sizes of any types declared among the arguments.  */
                   3392:   for (tem = get_pending_sizes (); tem; tem = TREE_CHAIN (tem))
                   3393:     expand_expr (TREE_VALUE (tem), 0, VOIDmode, 0);
1.1.1.2   root     3394: }
1.1       root     3395: 
1.1.1.6   root     3396: /* Generate RTL for the end of the current function.
                   3397:    LINE is the line number.  */
1.1       root     3398: 
1.1.1.2   root     3399: void
1.1.1.6   root     3400: expand_function_end (filename, line)
                   3401:      char *filename;
                   3402:      int line;
1.1.1.2   root     3403: {
                   3404:   register int i;
1.1       root     3405: 
1.1.1.4   root     3406:   /* Outside function body, can't compute type's actual size
                   3407:      until next function's body starts.  */
                   3408:   immediate_size_expand--;
                   3409: 
1.1       root     3410:   /* If doing stupid register allocation,
1.1.1.2   root     3411:      mark register parms as dying here.  */
                   3412: 
1.1       root     3413:   if (obey_regdecls)
1.1.1.5   root     3414:     {
                   3415:       rtx tem;
                   3416:       for (i = FIRST_PSEUDO_REGISTER; i < max_parm_reg; i++)
                   3417:        use_variable (regno_reg_rtx[i]);
                   3418: 
                   3419:       /* Likewise for the regs of all the SAVE_EXPRs in the function.  */
                   3420: 
                   3421:       for (tem = save_expr_regs; tem; tem = XEXP (tem, 1))
1.1.1.10  root     3422:        use_variable (XEXP (tem, 0));
1.1.1.5   root     3423: 
                   3424:       /* Also mark those as borm at the beginning of the function.
                   3425:         (This was done in expand_function_start for parms).  */
                   3426:       for (tem = save_expr_regs; tem; tem = XEXP (tem, 1))
                   3427:        emit_insn_after (gen_rtx (USE, VOIDmode, XEXP (tem, 0)),
                   3428:                         parm_birth_insn);
                   3429:     }
1.1       root     3430: 
                   3431:   clear_pending_stack_adjust ();
1.1.1.2   root     3432:   do_pending_stack_adjust ();
1.1       root     3433: 
1.1.1.2   root     3434:   /* Mark the end of the function body.
                   3435:      If control reaches this insn, the function can drop through
                   3436:      without returning a value.  */
                   3437:   emit_note (0, NOTE_INSN_FUNCTION_END);
                   3438: 
1.1.1.6   root     3439:   /* Output a linenumber for the end of the function.
                   3440:      SDB depends on this.  */
1.1.1.12! root     3441:   emit_line_note_force (input_filename, line);
1.1.1.6   root     3442: 
1.1.1.2   root     3443:   /* If we require a true epilogue,
                   3444:      put here the label that return statements jump to.
                   3445:      If there will be no epilogue, write a return instruction.  */
1.1.1.8   root     3446: #ifdef HAVE_return
                   3447:   if (HAVE_return)
                   3448:     emit_jump_insn (gen_return ());
                   3449:   else
1.1       root     3450: #endif
1.1.1.8   root     3451:     emit_label (return_label);
1.1.1.6   root     3452: 
                   3453:   /* Fix up any gotos that jumped out to the outermost
                   3454:      binding level of the function.
                   3455:      Must follow emitting RETURN_LABEL.  */
1.1.1.8   root     3456: 
                   3457:   /* If you have any cleanups to do at this point,
                   3458:      and they need to create temporary variables,
                   3459:      then you will lose.  */
1.1.1.7   root     3460:   fixup_gotos (0, 0, get_insns (), 0);
1.1       root     3461: }
1.1.1.6   root     3462: 
                   3463: 

unix.superglobalmegacorp.com

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