Annotation of gcc/stmt.c, revision 1.1.1.11

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

unix.superglobalmegacorp.com

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