Annotation of gcc/calls.c, revision 1.1.1.2

1.1       root        1: /* Convert function calls to rtl insns, for GNU C compiler.
                      2:    Copyright (C) 1989, 1992 Free Software Foundation, Inc.
                      3: 
                      4: This file is part of GNU CC.
                      5: 
                      6: GNU CC is free software; you can redistribute it and/or modify
                      7: it under the terms of the GNU General Public License as published by
                      8: the Free Software Foundation; either version 2, or (at your option)
                      9: any later version.
                     10: 
                     11: GNU CC is distributed in the hope that it will be useful,
                     12: but WITHOUT ANY WARRANTY; without even the implied warranty of
                     13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     14: GNU General Public License for more details.
                     15: 
                     16: You should have received a copy of the GNU General Public License
                     17: along with GNU CC; see the file COPYING.  If not, write to
                     18: the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
                     19: 
                     20: #include "config.h"
                     21: #include "rtl.h"
                     22: #include "tree.h"
                     23: #include "flags.h"
                     24: #include "expr.h"
                     25: #include "insn-flags.h"
                     26: 
                     27: /* Decide whether a function's arguments should be processed
                     28:    from first to last or from last to first.  */
                     29: 
                     30: #ifdef STACK_GROWS_DOWNWARD
                     31: #ifdef PUSH_ROUNDING
                     32: #define PUSH_ARGS_REVERSED     /* If it's last to first */
                     33: #endif
                     34: #endif
                     35: 
                     36: /* Like STACK_BOUNDARY but in units of bytes, not bits.  */
                     37: #define STACK_BYTES (STACK_BOUNDARY / BITS_PER_UNIT)
                     38: 
                     39: /* Data structure and subroutines used within expand_call.  */
                     40: 
                     41: struct arg_data
                     42: {
                     43:   /* Tree node for this argument.  */
                     44:   tree tree_value;
                     45:   /* Current RTL value for argument, or 0 if it isn't precomputed.  */
                     46:   rtx value;
                     47:   /* Initially-compute RTL value for argument; only for const functions.  */
                     48:   rtx initial_value;
                     49:   /* Register to pass this argument in, 0 if passed on stack, or an
                     50:      EXPR_LIST if the arg is to be copied into multiple different
                     51:      registers.  */
                     52:   rtx reg;
                     53:   /* Number of registers to use.  0 means put the whole arg in registers.
                     54:      Also 0 if not passed in registers.  */
                     55:   int partial;
                     56:   /* Non-zero if argument must be passed on stack.  */
                     57:   int pass_on_stack;
                     58:   /* Offset of this argument from beginning of stack-args.  */
                     59:   struct args_size offset;
                     60:   /* Similar, but offset to the start of the stack slot.  Different from
                     61:      OFFSET if this arg pads downward.  */
                     62:   struct args_size slot_offset;
                     63:   /* Size of this argument on the stack, rounded up for any padding it gets,
                     64:      parts of the argument passed in registers do not count.
                     65:      If REG_PARM_STACK_SPACE is defined, then register parms
                     66:      are counted here as well.  */
                     67:   struct args_size size;
                     68:   /* Location on the stack at which parameter should be stored.  The store
                     69:      has already been done if STACK == VALUE.  */
                     70:   rtx stack;
                     71:   /* Location on the stack of the start of this argument slot.  This can
                     72:      differ from STACK if this arg pads downward.  This location is known
                     73:      to be aligned to FUNCTION_ARG_BOUNDARY.  */
                     74:   rtx stack_slot;
                     75: #ifdef ACCUMULATE_OUTGOING_ARGS
                     76:   /* Place that this stack area has been saved, if needed.  */
                     77:   rtx save_area;
                     78: #endif
                     79: };
                     80: 
                     81: #ifdef ACCUMULATE_OUTGOING_ARGS
                     82: /* A vector of one char per word of stack space.  A byte if non-zero if
                     83:    the corresponding stack location has been used.
                     84:    This vector is used to prevent a function call within an argument from
                     85:    clobbering any stack already set up.  */
                     86: static char *stack_usage_map;
                     87: 
                     88: /* Size of STACK_USAGE_MAP.  */
                     89: static int highest_outgoing_arg_in_use;
                     90: #endif
                     91: 
                     92: static void store_one_arg ();
                     93: extern enum machine_mode mode_for_size ();
                     94: 
                     95: /* Return 1 if EXP contains a call to the built-in function `alloca'.  */
                     96: 
                     97: static int
                     98: calls_alloca (exp)
                     99:      tree exp;
                    100: {
                    101:   register int i;
                    102:   int type = TREE_CODE_CLASS (TREE_CODE (exp));
                    103:   int length = tree_code_length[(int) TREE_CODE (exp)];
                    104: 
                    105:   /* Only expressions and references can contain calls.  */
                    106: 
                    107:   if (type != 'e' && type != '<' && type != '1' && type != '2' && type != 'r')
                    108:     return 0;
                    109: 
                    110:   switch (TREE_CODE (exp))
                    111:     {
                    112:     case CALL_EXPR:
                    113:       if (TREE_CODE (TREE_OPERAND (exp, 0)) == ADDR_EXPR
                    114:          && (TREE_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0))
                    115:              == FUNCTION_DECL)
                    116:          && DECL_BUILT_IN (TREE_OPERAND (TREE_OPERAND (exp, 0), 0))
                    117:          && (DECL_FUNCTION_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0))
                    118:              == BUILT_IN_ALLOCA))
                    119:        return 1;
                    120: 
                    121:       /* Third operand is RTL.  */
                    122:       length = 2;
                    123:       break;
                    124: 
                    125:     case SAVE_EXPR:
                    126:       if (SAVE_EXPR_RTL (exp) != 0)
                    127:        return 0;
                    128:       break;
                    129: 
                    130:     case BLOCK:
                    131:       /* Must not look at BLOCK_SUPERCONTEXT since it will point back to
                    132:         us.  */
                    133:       length = 3;
                    134:       break;
                    135: 
                    136:     case METHOD_CALL_EXPR:
                    137:       length = 3;
                    138:       break;
                    139: 
                    140:     case WITH_CLEANUP_EXPR:
                    141:       length = 1;
                    142:       break;
                    143: 
                    144:     case RTL_EXPR:
                    145:       return 0;
                    146:     }
                    147: 
                    148:   for (i = 0; i < length; i++)
                    149:     if (TREE_OPERAND (exp, i) != 0
                    150:        && calls_alloca (TREE_OPERAND (exp, i)))
                    151:       return 1;
                    152: 
                    153:   return 0;
                    154: }
                    155: 
                    156: /* Force FUNEXP into a form suitable for the address of a CALL,
                    157:    and return that as an rtx.  Also load the static chain register
                    158:    if FNDECL is a nested function.
                    159: 
                    160:    USE_INSNS points to a variable holding a chain of USE insns
                    161:    to which a USE of the static chain
                    162:    register should be added, if required.  */
                    163: 
                    164: rtx
                    165: prepare_call_address (funexp, fndecl, use_insns)
                    166:      rtx funexp;
                    167:      tree fndecl;
                    168:      rtx *use_insns;
                    169: {
                    170:   rtx static_chain_value = 0;
                    171: 
                    172:   funexp = protect_from_queue (funexp, 0);
                    173: 
                    174:   if (fndecl != 0)
                    175:     /* Get possible static chain value for nested function in C. */
                    176:     static_chain_value = lookup_static_chain (fndecl);
                    177: 
                    178:   /* Make a valid memory address and copy constants thru pseudo-regs,
                    179:      but not for a constant address if -fno-function-cse.  */
                    180:   if (GET_CODE (funexp) != SYMBOL_REF)
                    181:     funexp = memory_address (FUNCTION_MODE, funexp);
                    182:   else
                    183:     {
                    184: #ifndef NO_FUNCTION_CSE
                    185:       if (optimize && ! flag_no_function_cse)
                    186: #ifdef NO_RECURSIVE_FUNCTION_CSE
                    187:        if (fndecl != current_function_decl)
                    188: #endif
                    189:          funexp = force_reg (Pmode, funexp);
                    190: #endif
                    191:     }
                    192: 
                    193:   if (static_chain_value != 0)
                    194:     {
                    195:       emit_move_insn (static_chain_rtx, static_chain_value);
                    196: 
                    197:       /* Put the USE insn in the chain we were passed.  It will later be
                    198:         output immediately in front of the CALL insn.  */
                    199:       push_to_sequence (*use_insns);
                    200:       emit_insn (gen_rtx (USE, VOIDmode, static_chain_rtx));
                    201:       *use_insns = get_insns ();
                    202:       end_sequence ();
                    203:     }
                    204: 
                    205:   return funexp;
                    206: }
                    207: 
                    208: /* Generate instructions to call function FUNEXP,
                    209:    and optionally pop the results.
                    210:    The CALL_INSN is the first insn generated.
                    211: 
                    212:    FUNTYPE is the data type of the function, or, for a library call,
                    213:    the identifier for the name of the call.  This is given to the
                    214:    macro RETURN_POPS_ARGS to determine whether this function pops its own args.
                    215: 
                    216:    STACK_SIZE is the number of bytes of arguments on the stack,
                    217:    rounded up to STACK_BOUNDARY; zero if the size is variable.
                    218:    This is both to put into the call insn and
                    219:    to generate explicit popping code if necessary.
                    220: 
                    221:    STRUCT_VALUE_SIZE is the number of bytes wanted in a structure value.
                    222:    It is zero if this call doesn't want a structure value.
                    223: 
                    224:    NEXT_ARG_REG is the rtx that results from executing
                    225:      FUNCTION_ARG (args_so_far, VOIDmode, void_type_node, 1)
                    226:    just after all the args have had their registers assigned.
                    227:    This could be whatever you like, but normally it is the first
                    228:    arg-register beyond those used for args in this call,
                    229:    or 0 if all the arg-registers are used in this call.
                    230:    It is passed on to `gen_call' so you can put this info in the call insn.
                    231: 
                    232:    VALREG is a hard register in which a value is returned,
                    233:    or 0 if the call does not return a value.
                    234: 
                    235:    OLD_INHIBIT_DEFER_POP is the value that `inhibit_defer_pop' had before
                    236:    the args to this call were processed.
                    237:    We restore `inhibit_defer_pop' to that value.
                    238: 
                    239:    USE_INSNS is a chain of USE insns to be emitted immediately before
                    240:    the actual CALL insn.
                    241: 
                    242:    IS_CONST is true if this is a `const' call.  */
                    243: 
                    244: void
                    245: emit_call_1 (funexp, funtype, stack_size, struct_value_size, next_arg_reg,
                    246:             valreg, old_inhibit_defer_pop, use_insns, is_const)
                    247:      rtx funexp;
                    248:      tree funtype;
                    249:      int stack_size;
                    250:      int struct_value_size;
                    251:      rtx next_arg_reg;
                    252:      rtx valreg;
                    253:      int old_inhibit_defer_pop;
                    254:      rtx use_insns;
                    255:      int is_const;
                    256: {
                    257:   rtx stack_size_rtx = gen_rtx (CONST_INT, VOIDmode, stack_size);
                    258:   rtx struct_value_size_rtx = gen_rtx (CONST_INT, VOIDmode, struct_value_size);
                    259:   rtx call_insn;
                    260:   int already_popped = 0;
                    261: 
                    262:   /* Ensure address is valid.  SYMBOL_REF is already valid, so no need,
                    263:      and we don't want to load it into a register as an optimization,
                    264:      because prepare_call_address already did it if it should be done.  */
                    265:   if (GET_CODE (funexp) != SYMBOL_REF)
                    266:     funexp = memory_address (FUNCTION_MODE, funexp);
                    267: 
                    268: #ifndef ACCUMULATE_OUTGOING_ARGS
                    269: #if defined (HAVE_call_pop) && defined (HAVE_call_value_pop)
                    270:   if (HAVE_call_pop && HAVE_call_value_pop
                    271:       && (RETURN_POPS_ARGS (funtype, stack_size) > 0 || stack_size == 0))
                    272:     {
                    273:       rtx n_pop = gen_rtx (CONST_INT, VOIDmode, 
                    274:                           RETURN_POPS_ARGS (funtype, stack_size));
                    275:       rtx pat;
                    276: 
                    277:       /* If this subroutine pops its own args, record that in the call insn
                    278:         if possible, for the sake of frame pointer elimination.  */
                    279:       if (valreg)
                    280:        pat = gen_call_value_pop (valreg,
                    281:                                  gen_rtx (MEM, FUNCTION_MODE, funexp),
                    282:                                  stack_size_rtx, next_arg_reg, n_pop);
                    283:       else
                    284:        pat = gen_call_pop (gen_rtx (MEM, FUNCTION_MODE, funexp),
                    285:                            stack_size_rtx, next_arg_reg, n_pop);
                    286: 
                    287:       emit_call_insn (pat);
                    288:       already_popped = 1;
                    289:     }
                    290:   else
                    291: #endif
                    292: #endif
                    293: 
                    294: #if defined (HAVE_call) && defined (HAVE_call_value)
                    295:   if (HAVE_call && HAVE_call_value)
                    296:     {
                    297:       if (valreg)
                    298:        emit_call_insn (gen_call_value (valreg,
                    299:                                        gen_rtx (MEM, FUNCTION_MODE, funexp),
                    300:                                        stack_size_rtx, next_arg_reg));
                    301:       else
                    302:        emit_call_insn (gen_call (gen_rtx (MEM, FUNCTION_MODE, funexp),
                    303:                                  stack_size_rtx, next_arg_reg,
                    304:                                  struct_value_size_rtx));
                    305:     }
                    306:   else
                    307: #endif
                    308:     abort ();
                    309: 
                    310:   /* Find the CALL insn we just emitted and write the USE insns before it.  */
                    311:   for (call_insn = get_last_insn ();
                    312:        call_insn && GET_CODE (call_insn) != CALL_INSN;
                    313:        call_insn = PREV_INSN (call_insn))
                    314:     ;
                    315: 
                    316:   if (! call_insn)
                    317:     abort ();
                    318: 
                    319:   /* Put the USE insns before the CALL.  */
                    320:   emit_insns_before (use_insns, call_insn);
                    321: 
                    322:   /* If this is a const call, then set the insn's unchanging bit.  */
                    323:   if (is_const)
                    324:     CONST_CALL_P (call_insn) = 1;
                    325: 
                    326:   inhibit_defer_pop = old_inhibit_defer_pop;
                    327: 
                    328: #ifndef ACCUMULATE_OUTGOING_ARGS
                    329:   /* If returning from the subroutine does not automatically pop the args,
                    330:      we need an instruction to pop them sooner or later.
                    331:      Perhaps do it now; perhaps just record how much space to pop later.
                    332: 
                    333:      If returning from the subroutine does pop the args, indicate that the
                    334:      stack pointer will be changed.  */
                    335: 
                    336:   if (stack_size != 0 && RETURN_POPS_ARGS (funtype, stack_size) > 0)
                    337:     {
                    338:       if (!already_popped)
                    339:        emit_insn (gen_rtx (CLOBBER, VOIDmode, stack_pointer_rtx));
                    340:       stack_size -= RETURN_POPS_ARGS (funtype, stack_size);
                    341:       stack_size_rtx = gen_rtx (CONST_INT, VOIDmode, stack_size);
                    342:     }
                    343: 
                    344:   if (stack_size != 0)
                    345:     {
                    346:       if (flag_defer_pop && inhibit_defer_pop == 0)
                    347:        pending_stack_adjust += stack_size;
                    348:       else
                    349:        adjust_stack (stack_size_rtx);
                    350:     }
                    351: #endif
                    352: }
                    353: 
                    354: /* Generate all the code for a function call
                    355:    and return an rtx for its value.
                    356:    Store the value in TARGET (specified as an rtx) if convenient.
                    357:    If the value is stored in TARGET then TARGET is returned.
                    358:    If IGNORE is nonzero, then we ignore the value of the function call.  */
                    359: 
                    360: rtx
                    361: expand_call (exp, target, ignore, modifier)
                    362:      tree exp;
                    363:      rtx target;
                    364:      int ignore;
                    365:      enum expand_modifier modifier;
                    366: {
                    367:   /* List of actual parameters.  */
                    368:   tree actparms = TREE_OPERAND (exp, 1);
                    369:   /* RTX for the function to be called.  */
                    370:   rtx funexp;
                    371:   /* Tree node for the function to be called (not the address!).  */
                    372:   tree funtree;
                    373:   /* Data type of the function.  */
                    374:   tree funtype;
                    375:   /* Declaration of the function being called,
                    376:      or 0 if the function is computed (not known by name).  */
                    377:   tree fndecl = 0;
                    378:   char *name = 0;
                    379: 
                    380:   /* Register in which non-BLKmode value will be returned,
                    381:      or 0 if no value or if value is BLKmode.  */
                    382:   rtx valreg;
                    383:   /* Address where we should return a BLKmode value;
                    384:      0 if value not BLKmode.  */
                    385:   rtx structure_value_addr = 0;
                    386:   /* Nonzero if that address is being passed by treating it as
                    387:      an extra, implicit first parameter.  Otherwise,
                    388:      it is passed by being copied directly into struct_value_rtx.  */
                    389:   int structure_value_addr_parm = 0;
                    390:   /* Size of aggregate value wanted, or zero if none wanted
                    391:      or if we are using the non-reentrant PCC calling convention
                    392:      or expecting the value in registers.  */
                    393:   int struct_value_size = 0;
                    394:   /* Nonzero if called function returns an aggregate in memory PCC style,
                    395:      by returning the address of where to find it.  */
                    396:   int pcc_struct_value = 0;
                    397: 
                    398:   /* Number of actual parameters in this call, including struct value addr.  */
                    399:   int num_actuals;
                    400:   /* Number of named args.  Args after this are anonymous ones
                    401:      and they must all go on the stack.  */
                    402:   int n_named_args;
                    403:   /* Count arg position in order args appear.  */
                    404:   int argpos;
                    405: 
                    406:   /* Vector of information about each argument.
                    407:      Arguments are numbered in the order they will be pushed,
                    408:      not the order they are written.  */
                    409:   struct arg_data *args;
                    410: 
                    411:   /* Total size in bytes of all the stack-parms scanned so far.  */
                    412:   struct args_size args_size;
                    413:   /* Size of arguments before any adjustments (such as rounding).  */
                    414:   struct args_size original_args_size;
                    415:   /* Data on reg parms scanned so far.  */
                    416:   CUMULATIVE_ARGS args_so_far;
                    417:   /* Nonzero if a reg parm has been scanned.  */
                    418:   int reg_parm_seen;
                    419: 
                    420:   /* Nonzero if we must avoid push-insns in the args for this call. 
                    421:      If stack space is allocated for register parameters, but not by the
                    422:      caller, then it is preallocated in the fixed part of the stack frame.
                    423:      So the entire argument block must then be preallocated (i.e., we
                    424:      ignore PUSH_ROUNDING in that case).  */
                    425: 
                    426: #if defined(REG_PARM_STACK_SPACE) && ! defined(OUTGOING_REG_PARM_STACK_SPACE)
                    427:   int must_preallocate = 1;
                    428: #else
                    429: #ifdef PUSH_ROUNDING
                    430:   int must_preallocate = 0;
                    431: #else
                    432:   int must_preallocate = 1;
                    433: #endif
                    434: #endif
                    435: 
                    436:   /* 1 if scanning parms front to back, -1 if scanning back to front.  */
                    437:   int inc;
                    438:   /* Address of space preallocated for stack parms
                    439:      (on machines that lack push insns), or 0 if space not preallocated.  */
                    440:   rtx argblock = 0;
                    441: 
                    442:   /* Nonzero if it is plausible that this is a call to alloca.  */
                    443:   int may_be_alloca;
                    444:   /* Nonzero if this is a call to setjmp or a related function.  */
                    445:   int returns_twice;
                    446:   /* Nonzero if this is a call to `longjmp'.  */
                    447:   int is_longjmp;
                    448:   /* Nonzero if this is a call to an inline function.  */
                    449:   int is_integrable = 0;
                    450:   /* Nonzero if this is a call to __builtin_new.  */
                    451:   int is_builtin_new;
                    452:   /* Nonzero if this is a call to a `const' function.
                    453:      Note that only explicitly named functions are handled as `const' here.  */
                    454:   int is_const = 0;
                    455:   /* Nonzero if this is a call to a `volatile' function.  */
                    456:   int is_volatile = 0;
                    457: #if defined(ACCUMULATE_OUTGOING_ARGS) && defined(REG_PARM_STACK_SPACE)
                    458:   /* Define the boundary of the register parm stack space that needs to be
                    459:      save, if any.  */
                    460:   int low_to_save = -1, high_to_save;
                    461:   rtx save_area = 0;           /* Place that it is saved */
                    462: #endif
                    463: 
                    464: #ifdef ACCUMULATE_OUTGOING_ARGS
                    465:   int initial_highest_arg_in_use = highest_outgoing_arg_in_use;
                    466:   char *initial_stack_usage_map = stack_usage_map;
                    467: #endif
                    468: 
                    469:   rtx old_stack_level = 0;
                    470:   int old_pending_adj;
                    471:   int old_inhibit_defer_pop = inhibit_defer_pop;
                    472:   tree old_cleanups = cleanups_this_call;
                    473: 
                    474:   rtx use_insns = 0;
                    475: 
                    476:   register tree p;
                    477:   register int i;
                    478: 
                    479:   /* See if we can find a DECL-node for the actual function.
                    480:      As a result, decide whether this is a call to an integrable function.  */
                    481: 
                    482:   p = TREE_OPERAND (exp, 0);
                    483:   if (TREE_CODE (p) == ADDR_EXPR)
                    484:     {
                    485:       fndecl = TREE_OPERAND (p, 0);
                    486:       if (TREE_CODE (fndecl) != FUNCTION_DECL)
                    487:        {
                    488:          /* May still be a `const' function if it is
                    489:             a call through a pointer-to-const.
                    490:             But we don't handle that.  */
                    491:          fndecl = 0;
                    492:        }
                    493:       else
                    494:        {
                    495:          if (!flag_no_inline
                    496:              && fndecl != current_function_decl
                    497:              && DECL_SAVED_INSNS (fndecl))
                    498:            is_integrable = 1;
                    499:          else if (! TREE_ADDRESSABLE (fndecl))
                    500:            {
                    501:              /* In case this function later becomes inlineable,
                    502:                 record that there was already a non-inline call to it.
                    503: 
                    504:                 Use abstraction instead of setting TREE_ADDRESSABLE
                    505:                 directly.  */
                    506:              if (TREE_INLINE (fndecl) && extra_warnings && !flag_no_inline)
                    507:                warning_with_decl (fndecl, "can't inline call to `%s' which was declared inline");
                    508:              mark_addressable (fndecl);
                    509:            }
                    510: 
                    511:          if (TREE_READONLY (fndecl) && ! TREE_THIS_VOLATILE (fndecl)
                    512:              && TYPE_MODE (TREE_TYPE (exp)) != VOIDmode)
                    513:            is_const = 1;
                    514:        }
                    515:     }
                    516: 
                    517:   is_volatile = TYPE_VOLATILE (TREE_TYPE (TREE_TYPE (p)));
                    518: 
                    519:   /* Warn if this value is an aggregate type,
                    520:      regardless of which calling convention we are using for it.  */
                    521:   if (warn_aggregate_return
                    522:       && (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE
                    523:          || TREE_CODE (TREE_TYPE (exp)) == UNION_TYPE
                    524:          || TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE))
                    525:     warning ("function call has aggregate value");
                    526: 
                    527:   /* Set up a place to return a structure.  */
                    528: 
                    529:   /* Cater to broken compilers.  */
                    530:   if (aggregate_value_p (exp))
                    531:     {
                    532:       /* This call returns a big structure.  */
                    533:       is_const = 0;
                    534: 
                    535: #ifdef PCC_STATIC_STRUCT_RETURN
                    536:       if (flag_pcc_struct_return)
                    537:        {
                    538:          pcc_struct_value = 1;
                    539:          is_integrable = 0;  /* Easier than making that case work right.  */
                    540:        }
                    541:       else
                    542: #endif
                    543:        {
                    544:          struct_value_size = int_size_in_bytes (TREE_TYPE (exp));
                    545: 
                    546:          if (struct_value_size < 0)
                    547:            abort ();
                    548: 
                    549:          if (target && GET_CODE (target) == MEM)
                    550:            structure_value_addr = XEXP (target, 0);
                    551:          else
                    552:            {
                    553:              /* Assign a temporary on the stack to hold the value.  */
                    554: 
                    555:              /* For variable-sized objects, we must be called with a target
                    556:                 specified.  If we were to allocate space on the stack here,
                    557:                 we would have no way of knowing when to free it.  */
                    558: 
                    559:              structure_value_addr
                    560:                = XEXP (assign_stack_temp (BLKmode, struct_value_size, 1), 0);
                    561:              target = 0;
                    562:            }
                    563:        }
                    564:     }
                    565: 
                    566:   /* If called function is inline, try to integrate it.  */
                    567: 
                    568:   if (is_integrable)
                    569:     {
                    570:       rtx temp;
                    571: 
                    572:       temp = expand_inline_function (fndecl, actparms, target,
                    573:                                     ignore, TREE_TYPE (exp),
                    574:                                     structure_value_addr);
                    575: 
                    576:       /* If inlining succeeded, return.  */
                    577:       if ((int) temp != -1)
                    578:        {
                    579:          /* Perform all cleanups needed for the arguments of this call
                    580:             (i.e. destructors in C++).  It is ok if these destructors
                    581:             clobber RETURN_VALUE_REG, because the only time we care about
                    582:             this is when TARGET is that register.  But in C++, we take
                    583:             care to never return that register directly.  */
                    584:          expand_cleanups_to (old_cleanups);
                    585: 
                    586:          /* If the result is equivalent to TARGET, return TARGET to simplify
                    587:             checks in store_expr.  They can be equivalent but not equal in the
                    588:             case of a function that returns BLKmode.  */
                    589:          if (temp != target && rtx_equal_p (temp, target))
                    590:            return target;
                    591:          return temp;
                    592:        }
                    593: 
                    594:       /* If inlining failed, mark FNDECL as needing to be compiled
                    595:         separately after all.  */
                    596:       mark_addressable (fndecl);
                    597:     }
                    598: 
                    599:   /* When calling a const function, we must pop the stack args right away,
                    600:      so that the pop is deleted or moved with the call.  */
                    601:   if (is_const)
                    602:     NO_DEFER_POP;
                    603: 
                    604:   function_call_count++;
                    605: 
                    606:   if (fndecl && DECL_NAME (fndecl))
                    607:     name = IDENTIFIER_POINTER (DECL_NAME (fndecl));
                    608: 
                    609: #if 0
                    610:   /* Unless it's a call to a specific function that isn't alloca,
                    611:      if it has one argument, we must assume it might be alloca.  */
                    612: 
                    613:   may_be_alloca =
                    614:     (!(fndecl != 0 && strcmp (name, "alloca"))
                    615:      && actparms != 0
                    616:      && TREE_CHAIN (actparms) == 0);
                    617: #else
                    618:   /* We assume that alloca will always be called by name.  It
                    619:      makes no sense to pass it as a pointer-to-function to
                    620:      anything that does not understand its behavior.  */
                    621:   may_be_alloca =
                    622:     (name && ((IDENTIFIER_LENGTH (DECL_NAME (fndecl)) == 6
                    623:                 && name[0] == 'a'
                    624:                 && ! strcmp (name, "alloca"))
                    625:                || (IDENTIFIER_LENGTH (DECL_NAME (fndecl)) == 16
                    626:                    && name[0] == '_'
                    627:                    && ! strcmp (name, "__builtin_alloca"))));
                    628: #endif
                    629: 
                    630:   /* See if this is a call to a function that can return more than once
                    631:      or a call to longjmp.  */
                    632: 
                    633:   returns_twice = 0;
                    634:   is_longjmp = 0;
                    635: 
                    636:   if (name != 0 && IDENTIFIER_LENGTH (DECL_NAME (fndecl)) <= 15)
                    637:     {
                    638:       char *tname = name;
                    639: 
                    640:       if (name[0] == '_')
                    641:        tname += ((name[1] == '_' && name[2] == 'x') ? 3 : 1);
                    642: 
                    643:       if (tname[0] == 's')
                    644:        {
                    645:          returns_twice
                    646:            = ((tname[1] == 'e'
                    647:                && (! strcmp (tname, "setjmp")
                    648:                    || ! strcmp (tname, "setjmp_syscall")))
                    649:               || (tname[1] == 'i'
                    650:                   && ! strcmp (tname, "sigsetjmp"))
                    651:               || (tname[1] == 'a'
                    652:                   && ! strcmp (tname, "savectx")));
                    653:          if (tname[1] == 'i'
                    654:              && ! strcmp (tname, "siglongjmp"))
                    655:            is_longjmp = 1;
                    656:        }
                    657:       else if ((tname[0] == 'q' && tname[1] == 's'
                    658:                && ! strcmp (tname, "qsetjmp"))
                    659:               || (tname[0] == 'v' && tname[1] == 'f'
                    660:                   && ! strcmp (tname, "vfork")))
                    661:        returns_twice = 1;
                    662: 
                    663:       else if (tname[0] == 'l' && tname[1] == 'o'
                    664:               && ! strcmp (tname, "longjmp"))
                    665:        is_longjmp = 1;
                    666:     }
                    667: 
                    668:   is_builtin_new
                    669:     = (name != 0
                    670:        && IDENTIFIER_LENGTH (DECL_NAME (fndecl)) == 13
                    671:        && (!strcmp (name, "__builtin_new")));
                    672: 
                    673:   if (may_be_alloca)
                    674:     current_function_calls_alloca = 1;
                    675: 
                    676:   /* Don't let pending stack adjusts add up to too much.
                    677:      Also, do all pending adjustments now
                    678:      if there is any chance this might be a call to alloca.  */
                    679: 
                    680:   if (pending_stack_adjust >= 32
                    681:       || (pending_stack_adjust > 0 && may_be_alloca))
                    682:     do_pending_stack_adjust ();
                    683: 
                    684:   /* Operand 0 is a pointer-to-function; get the type of the function.  */
                    685:   funtype = TREE_TYPE (TREE_OPERAND (exp, 0));
                    686:   if (TREE_CODE (funtype) != POINTER_TYPE)
                    687:     abort ();
                    688:   funtype = TREE_TYPE (funtype);
                    689: 
                    690:   /* Push the temporary stack slot level so that we can free temporaries used
                    691:      by each of the arguments separately.  */
                    692:   push_temp_slots ();
                    693: 
                    694:   /* Start updating where the next arg would go.  */
                    695:   INIT_CUMULATIVE_ARGS (args_so_far, funtype, 0);
                    696: 
                    697:   /* If struct_value_rtx is 0, it means pass the address
                    698:      as if it were an extra parameter.  */
                    699:   if (structure_value_addr && struct_value_rtx == 0)
                    700:     {
                    701:       actparms
                    702:        = tree_cons (error_mark_node,
                    703:                     make_tree (build_pointer_type (TREE_TYPE (funtype)),
                    704:                                force_reg (Pmode, structure_value_addr)),
                    705:                     actparms);
                    706:       structure_value_addr_parm = 1;
                    707:     }
                    708: 
                    709:   /* Count the arguments and set NUM_ACTUALS.  */
                    710:   for (p = actparms, i = 0; p; p = TREE_CHAIN (p)) i++;
                    711:   num_actuals = i;
                    712: 
                    713:   /* Compute number of named args.
                    714:      Normally, don't include the last named arg if anonymous args follow.
                    715:      (If no anonymous args follow, the result of list_length
                    716:      is actually one too large.)
                    717: 
                    718:      If SETUP_INCOMING_VARARGS is defined, this machine will be able to
                    719:      place unnamed args that were passed in registers into the stack.  So
                    720:      treat all args as named.  This allows the insns emitting for a specific
1.1.1.2 ! root      721:      argument list to be independent of the function declaration.
1.1       root      722: 
                    723:      If SETUP_INCOMING_VARARGS is not defined, we do not have any reliable
                    724:      way to pass unnamed args in registers, so we must force them into
                    725:      memory.  */
                    726: #ifndef SETUP_INCOMING_VARARGS
                    727:   if (TYPE_ARG_TYPES (funtype) != 0)
                    728:     n_named_args
                    729:       = list_length (TYPE_ARG_TYPES (funtype)) - 1
                    730:        /* Count the struct value address, if it is passed as a parm.  */
                    731:        + structure_value_addr_parm;
                    732:   else
                    733: #endif
                    734:     /* If we know nothing, treat all args as named.  */
                    735:     n_named_args = num_actuals;
                    736: 
                    737:   /* Make a vector to hold all the information about each arg.  */
                    738:   args = (struct arg_data *) alloca (num_actuals * sizeof (struct arg_data));
                    739:   bzero (args, num_actuals * sizeof (struct arg_data));
                    740: 
                    741:   args_size.constant = 0;
                    742:   args_size.var = 0;
                    743: 
                    744:   /* In this loop, we consider args in the order they are written.
                    745:      We fill up ARGS from the front of from the back if necessary
                    746:      so that in any case the first arg to be pushed ends up at the front.  */
                    747: 
                    748: #ifdef PUSH_ARGS_REVERSED
                    749:   i = num_actuals - 1, inc = -1;
                    750:   /* In this case, must reverse order of args
                    751:      so that we compute and push the last arg first.  */
                    752: #else
                    753:   i = 0, inc = 1;
                    754: #endif
                    755: 
                    756:   /* I counts args in order (to be) pushed; ARGPOS counts in order written.  */
                    757:   for (p = actparms, argpos = 0; p; p = TREE_CHAIN (p), i += inc, argpos++)
                    758:     {
                    759:       tree type = TREE_TYPE (TREE_VALUE (p));
                    760: 
                    761:       args[i].tree_value = TREE_VALUE (p);
                    762: 
                    763:       /* Replace erroneous argument with constant zero.  */
                    764:       if (type == error_mark_node || TYPE_SIZE (type) == 0)
                    765:        args[i].tree_value = integer_zero_node, type = integer_type_node;
                    766: 
                    767:       /* Decide where to pass this arg.
                    768: 
                    769:         args[i].reg is nonzero if all or part is passed in registers.
                    770: 
                    771:         args[i].partial is nonzero if part but not all is passed in registers,
                    772:         and the exact value says how many words are passed in registers.
                    773: 
                    774:         args[i].pass_on_stack is nonzero if the argument must at least be
                    775:         computed on the stack.  It may then be loaded back into registers
                    776:         if args[i].reg is nonzero.
                    777: 
                    778:         These decisions are driven by the FUNCTION_... macros and must agree
                    779:         with those made by function.c.  */
                    780: 
                    781: #ifdef FUNCTION_ARG_PASS_BY_REFERENCE
                    782:       /* See if this argument should be passed by invisible reference.  */
                    783:       if (FUNCTION_ARG_PASS_BY_REFERENCE (args_so_far, TYPE_MODE (type), type,
                    784:                                          argpos < n_named_args))
                    785:        {
                    786:          /* We make a copy of the object and pass the address to the function
                    787:             being called.  */
                    788:          int size = int_size_in_bytes (type);
                    789:          rtx copy;
                    790: 
                    791:          if (size < 0)
                    792:            {
                    793:              /* This is a variable-sized object.  Make space on the stack
                    794:                 for it.  */
                    795:              rtx size_rtx = expand_expr (size_in_bytes (type), 0,
                    796:                                          VOIDmode, 0);
                    797: 
                    798:              if (old_stack_level == 0)
                    799:                {
                    800:                  old_stack_level = copy_to_mode_reg (Pmode, stack_pointer_rtx);
                    801:                  old_pending_adj = pending_stack_adjust;
                    802:                  pending_stack_adjust = 0;
                    803:                }
                    804: 
                    805:              copy = gen_rtx (MEM, BLKmode,
                    806:                              allocate_dynamic_stack_space (size_rtx, 0));
                    807:            }
                    808:          else
                    809:            copy = assign_stack_temp (TYPE_MODE (type), size, 1);
                    810: 
                    811:          store_expr (args[i].tree_value, copy, 0);
                    812: 
                    813:          args[i].tree_value = build1 (ADDR_EXPR, build_pointer_type (type),
                    814:                                       make_tree (type, copy));
                    815:          type = build_pointer_type (type);
                    816:        }
                    817: #endif
                    818: 
                    819:       args[i].reg = FUNCTION_ARG (args_so_far, TYPE_MODE (type), type,
                    820:                                  argpos < n_named_args);
                    821: #ifdef FUNCTION_ARG_PARTIAL_NREGS
                    822:       if (args[i].reg)
                    823:        args[i].partial
                    824:          = FUNCTION_ARG_PARTIAL_NREGS (args_so_far, TYPE_MODE (type), type,
                    825:                                        argpos < n_named_args);
                    826: #endif
                    827: 
                    828:       args[i].pass_on_stack = MUST_PASS_IN_STACK (TYPE_MODE (type), type);
                    829: 
                    830:       /* If FUNCTION_ARG returned an (expr_list (nil) FOO), it means that
                    831:         we are to pass this arg in the register(s) designated by FOO, but
                    832:         also to pass it in the stack.  */
                    833:       if (args[i].reg && GET_CODE (args[i].reg) == EXPR_LIST
                    834:          && XEXP (args[i].reg, 0) == 0)
                    835:        args[i].pass_on_stack = 1, args[i].reg = XEXP (args[i].reg, 1);
                    836: 
                    837:       /* If this is an addressable type, we must preallocate the stack
                    838:         since we must evaluate the object into its final location.
                    839: 
                    840:         If this is to be passed in both registers and the stack, it is simpler
                    841:         to preallocate.  */
                    842:       if (TREE_ADDRESSABLE (type)
                    843:          || (args[i].pass_on_stack && args[i].reg != 0))
                    844:        must_preallocate = 1;
                    845: 
                    846:       /* If this is an addressable type, we cannot pre-evaluate it.  Thus,
                    847:         we cannot consider this function call constant.  */
                    848:       if (TREE_ADDRESSABLE (type))
                    849:        is_const = 0;
                    850: 
                    851:       /* Compute the stack-size of this argument.  */
                    852:       if (args[i].reg == 0 || args[i].partial != 0
                    853: #ifdef REG_PARM_STACK_SPACE
                    854:          || REG_PARM_STACK_SPACE (fndecl) > 0
                    855: #endif
                    856:          || args[i].pass_on_stack)
                    857:        locate_and_pad_parm (TYPE_MODE (type), type,
                    858: #ifdef STACK_PARMS_IN_REG_PARM_AREA
                    859:                             1,
                    860: #else
                    861:                             args[i].reg != 0,
                    862: #endif
                    863:                             fndecl, &args_size, &args[i].offset,
                    864:                             &args[i].size);
                    865: 
                    866: #ifndef ARGS_GROW_DOWNWARD
                    867:       args[i].slot_offset = args_size;
                    868: #endif
                    869: 
                    870: #ifndef REG_PARM_STACK_SPACE
                    871:       /* If a part of the arg was put into registers,
                    872:         don't include that part in the amount pushed.  */
                    873:       if (! args[i].pass_on_stack)
                    874:        args[i].size.constant -= ((args[i].partial * UNITS_PER_WORD)
                    875:                                  / (PARM_BOUNDARY / BITS_PER_UNIT)
                    876:                                  * (PARM_BOUNDARY / BITS_PER_UNIT));
                    877: #endif
                    878:       
                    879:       /* Update ARGS_SIZE, the total stack space for args so far.  */
                    880: 
                    881:       args_size.constant += args[i].size.constant;
                    882:       if (args[i].size.var)
                    883:        {
                    884:          ADD_PARM_SIZE (args_size, args[i].size.var);
                    885:        }
                    886: 
                    887:       /* Since the slot offset points to the bottom of the slot,
                    888:         we must record it after incrementing if the args grow down.  */
                    889: #ifdef ARGS_GROW_DOWNWARD
                    890:       args[i].slot_offset = args_size;
                    891: 
                    892:       args[i].slot_offset.constant = -args_size.constant;
                    893:       if (args_size.var)
                    894:        {
                    895:          SUB_PARM_SIZE (args[i].slot_offset, args_size.var);
                    896:        }
                    897: #endif
                    898: 
                    899:       /* Increment ARGS_SO_FAR, which has info about which arg-registers
                    900:         have been used, etc.  */
                    901: 
                    902:       FUNCTION_ARG_ADVANCE (args_so_far, TYPE_MODE (type), type,
                    903:                            argpos < n_named_args);
                    904:     }
                    905: 
                    906:   /* Compute the actual size of the argument block required.  The variable
                    907:      and constant sizes must be combined, the size may have to be rounded,
                    908:      and there may be a minimum required size.  */
                    909: 
                    910:   original_args_size = args_size;
                    911:   if (args_size.var)
                    912:     {
                    913:       /* If this function requires a variable-sized argument list, don't try to
                    914:         make a cse'able block for this call.  We may be able to do this
                    915:         eventually, but it is too complicated to keep track of what insns go
                    916:         in the cse'able block and which don't.  */
                    917: 
                    918:       is_const = 0;
                    919:       must_preallocate = 1;
                    920: 
                    921:       args_size.var = ARGS_SIZE_TREE (args_size);
                    922:       args_size.constant = 0;
                    923: 
                    924: #ifdef STACK_BOUNDARY
                    925:       if (STACK_BOUNDARY != BITS_PER_UNIT)
                    926:        args_size.var = round_up (args_size.var, STACK_BYTES);
                    927: #endif
                    928: 
                    929: #ifdef REG_PARM_STACK_SPACE
                    930:       if (REG_PARM_STACK_SPACE (fndecl) > 0)
                    931:        {
                    932:          args_size.var
                    933:            = size_binop (MAX_EXPR, args_size.var,
                    934:                          size_int (REG_PARM_STACK_SPACE (fndecl)));
                    935: 
                    936: #ifndef OUTGOING_REG_PARM_STACK_SPACE
                    937:          /* The area corresponding to register parameters is not to count in
                    938:             the size of the block we need.  So make the adjustment.  */
                    939:          args_size.var
                    940:            = size_binop (MINUS_EXPR, args_size.var,
                    941:                          size_int (REG_PARM_STACK_SPACE (fndecl)));
                    942: #endif
                    943:        }
                    944: #endif
                    945:     }
                    946:   else
                    947:     {
                    948: #ifdef STACK_BOUNDARY
                    949:       args_size.constant = (((args_size.constant + (STACK_BYTES - 1))
                    950:                             / STACK_BYTES) * STACK_BYTES);
                    951: #endif
                    952: 
                    953: #ifdef REG_PARM_STACK_SPACE
                    954:       args_size.constant = MAX (args_size.constant,
                    955:                                REG_PARM_STACK_SPACE (fndecl));
                    956: #ifndef OUTGOING_REG_PARM_STACK_SPACE
                    957:       args_size.constant -= REG_PARM_STACK_SPACE (fndecl);
                    958: #endif
                    959: #endif
                    960:     }
                    961: 
                    962:   /* See if we have or want to preallocate stack space.
                    963: 
                    964:      If we would have to push a partially-in-regs parm
                    965:      before other stack parms, preallocate stack space instead.
                    966: 
                    967:      If the size of some parm is not a multiple of the required stack
                    968:      alignment, we must preallocate.
                    969: 
                    970:      If the total size of arguments that would otherwise create a copy in
                    971:      a temporary (such as a CALL) is more than half the total argument list
                    972:      size, preallocation is faster.
                    973: 
                    974:      Another reason to preallocate is if we have a machine (like the m88k)
                    975:      where stack alignment is required to be maintained between every
                    976:      pair of insns, not just when the call is made.  However, we assume here
                    977:      that such machines either do not have push insns (and hence preallocation
                    978:      would occur anyway) or the problem is taken care of with
                    979:      PUSH_ROUNDING.  */
                    980: 
                    981:   if (! must_preallocate)
                    982:     {
                    983:       int partial_seen = 0;
                    984:       int copy_to_evaluate_size = 0;
                    985: 
                    986:       for (i = 0; i < num_actuals && ! must_preallocate; i++)
                    987:        {
                    988:          if (args[i].partial > 0 && ! args[i].pass_on_stack)
                    989:            partial_seen = 1;
                    990:          else if (partial_seen && args[i].reg == 0)
                    991:            must_preallocate = 1;
                    992: 
                    993:          if (TYPE_MODE (TREE_TYPE (args[i].tree_value)) == BLKmode
                    994:              && (TREE_CODE (args[i].tree_value) == CALL_EXPR
                    995:                  || TREE_CODE (args[i].tree_value) == TARGET_EXPR
                    996:                  || TREE_CODE (args[i].tree_value) == COND_EXPR
                    997:                  || TREE_ADDRESSABLE (TREE_TYPE (args[i].tree_value))))
                    998:            copy_to_evaluate_size
                    999:              += int_size_in_bytes (TREE_TYPE (args[i].tree_value));
                   1000:        }
                   1001: 
                   1002:       if (copy_to_evaluate_size >= args_size.constant / 2)
                   1003:        must_preallocate = 1;
                   1004:     }
                   1005: 
                   1006:   /* If the structure value address will reference the stack pointer, we must
                   1007:      stabilize it.  We don't need to do this if we know that we are not going
                   1008:      to adjust the stack pointer in processing this call.  */
                   1009: 
                   1010:   if (structure_value_addr
                   1011:       && (reg_mentioned_p (virtual_stack_dynamic_rtx, structure_value_addr)
                   1012:        || reg_mentioned_p (virtual_outgoing_args_rtx, structure_value_addr))
                   1013:       && (args_size.var
                   1014: #ifndef ACCUMULATE_OUTGOING_ARGS
                   1015:          || args_size.constant
                   1016: #endif
                   1017:          ))
                   1018:     structure_value_addr = copy_to_reg (structure_value_addr);
                   1019: 
                   1020:   /* If this function call is cse'able, precompute all the parameters.
                   1021:      Note that if the parameter is constructed into a temporary, this will
                   1022:      cause an additional copy because the parameter will be constructed
                   1023:      into a temporary location and then copied into the outgoing arguments.
                   1024:      If a parameter contains a call to alloca and this function uses the
                   1025:      stack, precompute the parameter.  */
                   1026: 
                   1027:   for (i = 0; i < num_actuals; i++)
                   1028:     if (is_const
                   1029:        || ((args_size.var != 0 || args_size.constant != 0)
                   1030:            && calls_alloca (args[i].tree_value)))
                   1031:       {
                   1032:        args[i].initial_value = args[i].value
                   1033:          = expand_expr (args[i].tree_value, 0, VOIDmode, 0);
                   1034:        preserve_temp_slots (args[i].value);
                   1035:        free_temp_slots ();
                   1036: 
                   1037:        /* ANSI doesn't require a sequence point here,
                   1038:           but PCC has one, so this will avoid some problems.  */
                   1039:        emit_queue ();
                   1040:       }
                   1041: 
                   1042:   /* Now we are about to start emitting insns that can be deleted
                   1043:      if a libcall is deleted.  */
                   1044:   if (is_const)
                   1045:     start_sequence ();
                   1046: 
                   1047:   /* If we have no actual push instructions, or shouldn't use them,
                   1048:      make space for all args right now.  */
                   1049: 
                   1050:   if (args_size.var != 0)
                   1051:     {
                   1052:       if (old_stack_level == 0)
                   1053:        {
                   1054:          old_stack_level = copy_to_mode_reg (Pmode, stack_pointer_rtx);
                   1055:          old_pending_adj = pending_stack_adjust;
                   1056:          pending_stack_adjust = 0;
                   1057:        }
                   1058:       argblock = push_block (ARGS_SIZE_RTX (args_size), 0, 0);
                   1059:     }
                   1060:   else if (must_preallocate)
                   1061:     {
                   1062:       /* Note that we must go through the motions of allocating an argument
                   1063:         block even if the size is zero because we may be storing args
                   1064:         in the area reserved for register arguments, which may be part of
                   1065:         the stack frame.  */
                   1066:       int needed = args_size.constant;
                   1067: 
                   1068: #ifdef ACCUMULATE_OUTGOING_ARGS
                   1069:       /* Store the maximum argument space used.  It will be pushed by the
                   1070:         prologue.
                   1071: 
                   1072:         Since the stack pointer will never be pushed, it is possible for
                   1073:         the evaluation of a parm to clobber something we have already
                   1074:         written to the stack.  Since most function calls on RISC machines
                   1075:         do not use the stack, this is uncommon, but must work correctly.
                   1076:         
                   1077:         Therefore, we save any area of the stack that was already written
                   1078:         and that we are using.  Here we set up to do this by making a new
                   1079:         stack usage map from the old one.  The actual save will be done
                   1080:         by store_one_arg. 
                   1081: 
                   1082:         Another approach might be to try to reorder the argument
                   1083:         evaluations to avoid this conflicting stack usage.  */
                   1084: 
                   1085:       if (needed > current_function_outgoing_args_size)
                   1086:        current_function_outgoing_args_size = needed;
                   1087: 
                   1088: #if defined(REG_PARM_STACK_SPACE) && ! defined(OUTGOING_REG_PARM_STACK_SPACE)
                   1089:       /* Since we will be writing into the entire argument area, the
                   1090:         map must be allocated for its entire size, not just the part that
                   1091:         is the responsibility of the caller.  */
                   1092:       needed += REG_PARM_STACK_SPACE (fndecl);
                   1093: #endif
                   1094: 
                   1095: #ifdef ARGS_GROW_DOWNWARD
                   1096:       highest_outgoing_arg_in_use = MAX (initial_highest_arg_in_use,
                   1097:                                         needed + 1);
                   1098: #else
                   1099:       highest_outgoing_arg_in_use = MAX (initial_highest_arg_in_use, needed);
                   1100: #endif
                   1101:       stack_usage_map = (char *) alloca (highest_outgoing_arg_in_use);
                   1102: 
                   1103:       if (initial_highest_arg_in_use)
                   1104:        bcopy (initial_stack_usage_map, stack_usage_map,
                   1105:               initial_highest_arg_in_use);
                   1106: 
                   1107:       if (initial_highest_arg_in_use != highest_outgoing_arg_in_use)
                   1108:        bzero (&stack_usage_map[initial_highest_arg_in_use],
                   1109:               highest_outgoing_arg_in_use - initial_highest_arg_in_use);
                   1110:       needed = 0;
                   1111:       /* No need to copy this virtual register; the space we're
                   1112:         using gets preallocated at the start of the function
                   1113:         so the stack pointer won't change here.  */
                   1114:       argblock = virtual_outgoing_args_rtx;
                   1115: #else /* not ACCUMULATE_OUTGOING_ARGS */
                   1116:       if (inhibit_defer_pop == 0)
                   1117:        {
                   1118:          /* Try to reuse some or all of the pending_stack_adjust
                   1119:             to get this space.  Maybe we can avoid any pushing.  */
                   1120:          if (needed > pending_stack_adjust)
                   1121:            {
                   1122:              needed -= pending_stack_adjust;
                   1123:              pending_stack_adjust = 0;
                   1124:            }
                   1125:          else
                   1126:            {
                   1127:              pending_stack_adjust -= needed;
                   1128:              needed = 0;
                   1129:            }
                   1130:        }
                   1131:       /* Special case this because overhead of `push_block' in this
                   1132:         case is non-trivial.  */
                   1133:       if (needed == 0)
                   1134:        argblock = virtual_outgoing_args_rtx;
                   1135:       else
                   1136:        argblock = push_block (gen_rtx (CONST_INT, VOIDmode, needed), 0, 0);
                   1137: 
                   1138:       /* We only really need to call `copy_to_reg' in the case where push
                   1139:         insns are going to be used to pass ARGBLOCK to a function
                   1140:         call in ARGS.  In that case, the stack pointer changes value
                   1141:         from the allocation point to the call point, and hence
                   1142:         the value of VIRTUAL_OUTGOING_ARGS_RTX changes as well.
                   1143:         But might as well always do it.  */
                   1144:       argblock = copy_to_reg (argblock);
                   1145: #endif /* not ACCUMULATE_OUTGOING_ARGS */
                   1146:     }
                   1147: 
                   1148:   /* If we preallocated stack space, compute the address of each argument.
                   1149:      We need not ensure it is a valid memory address here; it will be 
                   1150:      validized when it is used.  */
                   1151:   if (argblock)
                   1152:     {
                   1153:       rtx arg_reg = argblock;
                   1154:       int arg_offset = 0;
                   1155: 
                   1156:       if (GET_CODE (argblock) == PLUS)
                   1157:        arg_reg = XEXP (argblock, 0), arg_offset = INTVAL (XEXP (argblock, 1));
                   1158: 
                   1159:       for (i = 0; i < num_actuals; i++)
                   1160:        {
                   1161:          rtx offset = ARGS_SIZE_RTX (args[i].offset);
                   1162:          rtx slot_offset = ARGS_SIZE_RTX (args[i].slot_offset);
                   1163:          rtx addr;
                   1164: 
                   1165:          /* Skip this parm if it will not be passed on the stack.  */
                   1166:          if (! args[i].pass_on_stack && args[i].reg != 0)
                   1167:            continue;
                   1168: 
                   1169:          if (GET_CODE (offset) == CONST_INT)
                   1170:            addr = plus_constant (arg_reg, INTVAL (offset));
                   1171:          else
                   1172:            addr = gen_rtx (PLUS, Pmode, arg_reg, offset);
                   1173: 
                   1174:          addr = plus_constant (addr, arg_offset);
                   1175:          args[i].stack
                   1176:            = gen_rtx (MEM, TYPE_MODE (TREE_TYPE (args[i].tree_value)), addr);
                   1177: 
                   1178:          if (GET_CODE (slot_offset) == CONST_INT)
                   1179:            addr = plus_constant (arg_reg, INTVAL (slot_offset));
                   1180:          else
                   1181:            addr = gen_rtx (PLUS, Pmode, arg_reg, slot_offset);
                   1182: 
                   1183:          addr = plus_constant (addr, arg_offset);
                   1184:          args[i].stack_slot
                   1185:            = gen_rtx (MEM, TYPE_MODE (TREE_TYPE (args[i].tree_value)), addr);
                   1186:        }
                   1187:     }
                   1188:                                               
                   1189: #ifdef PUSH_ARGS_REVERSED
                   1190: #ifdef STACK_BOUNDARY
                   1191:   /* If we push args individually in reverse order, perform stack alignment
                   1192:      before the first push (the last arg).  */
                   1193:   if (argblock == 0)
                   1194:     anti_adjust_stack (gen_rtx (CONST_INT, VOIDmode,
                   1195:                                (args_size.constant
                   1196:                                 - original_args_size.constant)));
                   1197: #endif
                   1198: #endif
                   1199: 
                   1200:   /* Don't try to defer pops if preallocating, not even from the first arg,
                   1201:      since ARGBLOCK probably refers to the SP.  */
                   1202:   if (argblock)
                   1203:     NO_DEFER_POP;
                   1204: 
                   1205:   /* Get the function to call, in the form of RTL.  */
                   1206:   if (fndecl)
                   1207:     /* Get a SYMBOL_REF rtx for the function address.  */
                   1208:     funexp = XEXP (DECL_RTL (fndecl), 0);
                   1209:   else
                   1210:     /* Generate an rtx (probably a pseudo-register) for the address.  */
                   1211:     {
                   1212:       funexp = expand_expr (TREE_OPERAND (exp, 0), 0, VOIDmode, 0);
                   1213:       free_temp_slots ();      /* FUNEXP can't be BLKmode */
                   1214:       emit_queue ();
                   1215:     }
                   1216: 
                   1217:   /* Figure out the register where the value, if any, will come back.  */
                   1218:   valreg = 0;
                   1219:   if (TYPE_MODE (TREE_TYPE (exp)) != VOIDmode
                   1220:       && ! structure_value_addr)
                   1221:     {
                   1222:       if (pcc_struct_value)
                   1223:        valreg = hard_function_value (build_pointer_type (TREE_TYPE (exp)),
                   1224:                                      fndecl);
                   1225:       else
                   1226:        valreg = hard_function_value (TREE_TYPE (exp), fndecl);
                   1227:     }
                   1228: 
                   1229:   /* Precompute all register parameters.  It isn't safe to compute anything
                   1230:      once we have started filling any specific hard regs. */
                   1231:   reg_parm_seen = 0;
                   1232:   for (i = 0; i < num_actuals; i++)
                   1233:     if (args[i].reg != 0 && ! args[i].pass_on_stack)
                   1234:       {
                   1235:        reg_parm_seen = 1;
                   1236: 
                   1237:        if (args[i].value == 0)
                   1238:          {
                   1239:            args[i].value = expand_expr (args[i].tree_value, 0, VOIDmode, 0);
                   1240:            preserve_temp_slots (args[i].value);
                   1241:            free_temp_slots ();
                   1242: 
                   1243:            /* ANSI doesn't require a sequence point here,
                   1244:               but PCC has one, so this will avoid some problems.  */
                   1245:            emit_queue ();
                   1246:          }
                   1247:       }
                   1248: 
                   1249: #if defined(ACCUMULATE_OUTGOING_ARGS) && defined(REG_PARM_STACK_SPACE)
                   1250:   /* The argument list is the property of the called routine and it
                   1251:      may clobber it.  If the fixed area has been used for previous
                   1252:      parameters, we must save and restore it.
                   1253: 
                   1254:      Here we compute the boundary of the that needs to be saved, if any.  */
                   1255: 
                   1256:   for (i = 0; i < REG_PARM_STACK_SPACE (fndecl); i++)
                   1257:     {
                   1258:       if (i >=  highest_outgoing_arg_in_use
                   1259:          || stack_usage_map[i] == 0)
                   1260:        continue;
                   1261: 
                   1262:       if (low_to_save == -1)
                   1263:        low_to_save = i;
                   1264: 
                   1265:       high_to_save = i;
                   1266:     }
                   1267: 
                   1268:   if (low_to_save >= 0)
                   1269:     {
                   1270:       int num_to_save = high_to_save - low_to_save + 1;
                   1271:       enum machine_mode save_mode
                   1272:        = mode_for_size (num_to_save * BITS_PER_UNIT, MODE_INT, 1);
                   1273:       rtx stack_area;
                   1274: 
                   1275:       /* If we don't have the required alignment, must do this in BLKmode.  */
                   1276:       if ((low_to_save & (MIN (GET_MODE_SIZE (save_mode),
                   1277:                               BIGGEST_ALIGNMENT / UNITS_PER_WORD) - 1)))
                   1278:        save_mode = BLKmode;
                   1279: 
                   1280:       stack_area = gen_rtx (MEM, save_mode,
                   1281:                            memory_address (save_mode,
                   1282:                                            plus_constant (argblock,
                   1283:                                                           low_to_save)));
                   1284:       if (save_mode == BLKmode)
                   1285:        {
                   1286:          save_area = assign_stack_temp (BLKmode, num_to_save, 1);
                   1287:          emit_block_move (validize_mem (save_area), stack_area,
                   1288:                           gen_rtx (CONST_INT, VOIDmode, num_to_save),
                   1289:                           PARM_BOUNDARY / BITS_PER_UNIT);
                   1290:        }
                   1291:       else
                   1292:        {
                   1293:          save_area = gen_reg_rtx (save_mode);
                   1294:          emit_move_insn (save_area, stack_area);
                   1295:        }
                   1296:     }
                   1297: #endif
                   1298:          
                   1299: 
                   1300:   /* Now store (and compute if necessary) all non-register parms.
                   1301:      These come before register parms, since they can require block-moves,
                   1302:      which could clobber the registers used for register parms.
                   1303:      Parms which have partial registers are not stored here,
                   1304:      but we do preallocate space here if they want that.  */
                   1305: 
                   1306:   for (i = 0; i < num_actuals; i++)
                   1307:     if (args[i].reg == 0 || args[i].pass_on_stack)
                   1308:       store_one_arg (&args[i], argblock, may_be_alloca,
                   1309:                     args_size.var != 0, fndecl);
                   1310: 
                   1311:   /* Now store any partially-in-registers parm.
                   1312:      This is the last place a block-move can happen.  */
                   1313:   if (reg_parm_seen)
                   1314:     for (i = 0; i < num_actuals; i++)
                   1315:       if (args[i].partial != 0 && ! args[i].pass_on_stack)
                   1316:        store_one_arg (&args[i], argblock, may_be_alloca,
                   1317:                       args_size.var != 0, fndecl);
                   1318: 
                   1319: #ifndef PUSH_ARGS_REVERSED
                   1320: #ifdef STACK_BOUNDARY
                   1321:   /* If we pushed args in forward order, perform stack alignment
                   1322:      after pushing the last arg.  */
                   1323:   if (argblock == 0)
                   1324:     anti_adjust_stack (gen_rtx (CONST_INT, VOIDmode,
                   1325:                                (args_size.constant
                   1326:                                 - original_args_size.constant)));
                   1327: #endif
                   1328: #endif
                   1329: 
                   1330:   /* Pass the function the address in which to return a structure value.  */
                   1331:   if (structure_value_addr && ! structure_value_addr_parm)
                   1332:     {
                   1333:       emit_move_insn (struct_value_rtx,
                   1334:                      force_reg (Pmode,
                   1335:                                 force_operand (structure_value_addr, 0)));
                   1336:       if (GET_CODE (struct_value_rtx) == REG)
                   1337:        {
                   1338:          push_to_sequence (use_insns);
                   1339:          emit_insn (gen_rtx (USE, VOIDmode, struct_value_rtx));
                   1340:          use_insns = get_insns ();
                   1341:          end_sequence ();
                   1342:        }
                   1343:     }
                   1344: 
                   1345:   /* Now do the register loads required for any wholly-register parms or any
                   1346:      parms which are passed both on the stack and in a register.  Their
                   1347:      expressions were already evaluated. 
                   1348: 
                   1349:      Mark all register-parms as living through the call, putting these USE
                   1350:      insns in a list headed by USE_INSNS.  */
                   1351: 
                   1352:   for (i = 0; i < num_actuals; i++)
                   1353:     {
                   1354:       rtx list = args[i].reg;
                   1355:       int partial = args[i].partial;
                   1356: 
                   1357:       while (list)
                   1358:        {
                   1359:          rtx reg;
                   1360:          int nregs;
                   1361: 
                   1362:          /* Process each register that needs to get this arg.  */
                   1363:          if (GET_CODE (list) == EXPR_LIST)
                   1364:            reg = XEXP (list, 0), list = XEXP (list, 1);
                   1365:          else
                   1366:            reg = list, list = 0;
                   1367: 
                   1368:          /* Set to non-zero if must move a word at a time, even if just one
                   1369:             word (e.g, partial == 1 && mode == DFmode).  Set to zero if
                   1370:             we just use a normal move insn.  */
                   1371:          nregs = (partial ? partial
                   1372:                   : (TYPE_MODE (TREE_TYPE (args[i].tree_value)) == BLKmode
                   1373:                      ? ((int_size_in_bytes (TREE_TYPE (args[i].tree_value))
                   1374:                          + (UNITS_PER_WORD - 1)) / UNITS_PER_WORD)
                   1375:                      : 0));
                   1376: 
                   1377:          /* If simple case, just do move.  If normal partial, store_one_arg
                   1378:             has already loaded the register for us.  In all other cases,
                   1379:             load the register(s) from memory.  */
                   1380: 
                   1381:          if (nregs == 0)
                   1382:            emit_move_insn (reg, args[i].value);
                   1383:          else if (args[i].partial == 0 || args[i].pass_on_stack)
                   1384:            move_block_to_reg (REGNO (reg),
                   1385:                               validize_mem (args[i].value), nregs,
                   1386:                               TYPE_MODE (TREE_TYPE (args[i].tree_value)));
                   1387:        
                   1388:          push_to_sequence (use_insns);
                   1389:          if (nregs == 0)
                   1390:            emit_insn (gen_rtx (USE, VOIDmode, reg));
                   1391:          else
                   1392:            use_regs (REGNO (reg), nregs);
                   1393:          use_insns = get_insns ();
                   1394:          end_sequence ();
                   1395: 
                   1396:          /* PARTIAL referred only to the first register, so clear it for the
                   1397:             next time.  */
                   1398:          partial = 0;
                   1399:        }
                   1400:     }
                   1401: 
                   1402:   /* Perform postincrements before actually calling the function.  */
                   1403:   emit_queue ();
                   1404: 
                   1405:   /* All arguments and registers used for the call must be set up by now!  */
                   1406: 
                   1407:   funexp = prepare_call_address (funexp, fndecl, &use_insns);
                   1408: 
                   1409:   /* Generate the actual call instruction.  */
                   1410:   emit_call_1 (funexp, funtype, args_size.constant, struct_value_size,
                   1411:               FUNCTION_ARG (args_so_far, VOIDmode, void_type_node, 1),
                   1412:               valreg, old_inhibit_defer_pop, use_insns, is_const);
                   1413: 
                   1414:   /* If call is cse'able, make appropriate pair of reg-notes around it.
                   1415:      Test valreg so we don't crash; may safely ignore `const'
                   1416:      if return type is void.  */
                   1417:   if (is_const && valreg != 0)
                   1418:     {
                   1419:       rtx note = 0;
                   1420:       rtx temp = gen_reg_rtx (GET_MODE (valreg));
                   1421:       rtx insns;
                   1422: 
                   1423:       /* Construct an "equal form" for the value which mentions all the
                   1424:         arguments in order as well as the function name.  */
                   1425: #ifdef PUSH_ARGS_REVERSED
                   1426:       for (i = 0; i < num_actuals; i++)
                   1427:        note = gen_rtx (EXPR_LIST, VOIDmode, args[i].initial_value, note);
                   1428: #else
                   1429:       for (i = num_actuals - 1; i >= 0; i--)
                   1430:        note = gen_rtx (EXPR_LIST, VOIDmode, args[i].initial_value, note);
                   1431: #endif
                   1432:       note = gen_rtx (EXPR_LIST, VOIDmode, funexp, note);
                   1433: 
                   1434:       insns = get_insns ();
                   1435:       end_sequence ();
                   1436: 
                   1437:       emit_libcall_block (insns, temp, valreg, note);
                   1438: 
                   1439:       valreg = temp;
                   1440:     }
                   1441: 
                   1442:   /* For calls to `setjmp', etc., inform flow.c it should complain
                   1443:      if nonvolatile values are live.  */
                   1444: 
                   1445:   if (returns_twice)
                   1446:     {
                   1447:       emit_note (name, NOTE_INSN_SETJMP);
                   1448:       current_function_calls_setjmp = 1;
                   1449:     }
                   1450: 
                   1451:   if (is_longjmp)
                   1452:     current_function_calls_longjmp = 1;
                   1453: 
                   1454:   /* Notice functions that cannot return.
                   1455:      If optimizing, insns emitted below will be dead.
                   1456:      If not optimizing, they will exist, which is useful
                   1457:      if the user uses the `return' command in the debugger.  */
                   1458: 
                   1459:   if (is_volatile || is_longjmp)
                   1460:     emit_barrier ();
                   1461: 
                   1462:   /* For calls to __builtin_new, note that it can never return 0.
                   1463:      This is because a new handler will be called, and 0 it not
                   1464:      among the numbers it is supposed to return.  */
                   1465: #if 0
                   1466:   if (is_builtin_new)
                   1467:     emit_note (name, NOTE_INSN_BUILTIN_NEW);
                   1468: #endif
                   1469: 
                   1470:   /* If value type not void, return an rtx for the value.  */
                   1471: 
                   1472:   /* If there are cleanups to be called, don't use a hard reg as target.  */
                   1473:   if (cleanups_this_call != old_cleanups
                   1474:       && target && REG_P (target)
                   1475:       && REGNO (target) < FIRST_PSEUDO_REGISTER)
                   1476:     target = 0;
                   1477: 
                   1478:   if (TYPE_MODE (TREE_TYPE (exp)) == VOIDmode
                   1479:       || ignore)
                   1480:     {
                   1481:       target = const0_rtx;
                   1482:     }
                   1483:   else if (structure_value_addr)
                   1484:     {
                   1485:       if (target == 0 || GET_CODE (target) != MEM)
                   1486:        target = gen_rtx (MEM, TYPE_MODE (TREE_TYPE (exp)),
                   1487:                          memory_address (TYPE_MODE (TREE_TYPE (exp)),
                   1488:                                          structure_value_addr));
                   1489:     }
                   1490:   else if (pcc_struct_value)
                   1491:     {
                   1492:       if (target == 0)
                   1493:        target = gen_rtx (MEM, TYPE_MODE (TREE_TYPE (exp)),
                   1494:                          copy_to_reg (valreg));
                   1495:       else if (TYPE_MODE (TREE_TYPE (exp)) != BLKmode)
                   1496:        emit_move_insn (target, gen_rtx (MEM, TYPE_MODE (TREE_TYPE (exp)),
                   1497:                                         copy_to_reg (valreg)));
                   1498:       else
                   1499:        emit_block_move (target, gen_rtx (MEM, BLKmode, copy_to_reg (valreg)),
                   1500:                         expr_size (exp),
                   1501:                         TYPE_ALIGN (TREE_TYPE (exp)) / BITS_PER_UNIT);
                   1502:     }
                   1503:   else if (target && GET_MODE (target) == TYPE_MODE (TREE_TYPE (exp)))
                   1504:     /* TARGET and VALREG cannot be equal at this point because the latter
                   1505:        would not have REG_FUNCTION_VALUE_P true, while the former would if
                   1506:        it were referring to the same register.
                   1507: 
                   1508:        If they refer to the same register, this move will be a no-op, except
                   1509:        when function inlining is being done.  */
                   1510:     emit_move_insn (target, valreg);
                   1511:   else
                   1512:     target = copy_to_reg (valreg);
                   1513: 
                   1514:   /* Perform all cleanups needed for the arguments of this call
                   1515:      (i.e. destructors in C++).  */
                   1516:   expand_cleanups_to (old_cleanups);
                   1517: 
                   1518:   /* If size of args is variable, restore saved stack-pointer value.  */
                   1519: 
                   1520:   if (old_stack_level)
                   1521:     {
                   1522:       emit_move_insn (stack_pointer_rtx, old_stack_level);
                   1523:       pending_stack_adjust = old_pending_adj;
                   1524:     }
                   1525: 
                   1526: #ifdef ACCUMULATE_OUTGOING_ARGS
                   1527:   else
                   1528:     {
                   1529: #ifdef REG_PARM_STACK_SPACE
                   1530:       if (save_area)
                   1531:        {
                   1532:          enum machine_mode save_mode = GET_MODE (save_area);
                   1533:          rtx stack_area
                   1534:            = gen_rtx (MEM, save_mode,
                   1535:                       memory_address (save_mode,
                   1536:                                       plus_constant (argblock, low_to_save)));
                   1537: 
                   1538:          if (save_mode != BLKmode)
                   1539:            emit_move_insn (stack_area, save_area);
                   1540:          else
                   1541:            emit_block_move (stack_area, validize_mem (save_area),
                   1542:                             gen_rtx (CONST_INT, VOIDmode,
                   1543:                                      high_to_save - low_to_save + 1,
                   1544:                                      PARM_BOUNDARY / BITS_PER_UNIT));
                   1545:        }
                   1546: #endif
                   1547:          
                   1548:       /* If we saved any argument areas, restore them.  */
                   1549:       for (i = 0; i < num_actuals; i++)
                   1550:        if (args[i].save_area)
                   1551:          {
                   1552:            enum machine_mode save_mode = GET_MODE (args[i].save_area);
                   1553:            rtx stack_area
                   1554:              = gen_rtx (MEM, save_mode,
                   1555:                         memory_address (save_mode,
                   1556:                                         XEXP (args[i].stack_slot, 0)));
                   1557: 
                   1558:            if (save_mode != BLKmode)
                   1559:              emit_move_insn (stack_area, args[i].save_area);
                   1560:            else
                   1561:              emit_block_move (stack_area, validize_mem (args[i].save_area),
                   1562:                               gen_rtx (CONST_INT, VOIDmode,
                   1563:                                        args[i].size.constant),
                   1564:                               PARM_BOUNDARY / BITS_PER_UNIT);
                   1565:          }
                   1566: 
                   1567:       highest_outgoing_arg_in_use = initial_highest_arg_in_use;
                   1568:       stack_usage_map = initial_stack_usage_map;
                   1569:     }
                   1570: #endif
                   1571: 
                   1572:   /* If this was alloca, record the new stack level for nonlocal gotos.  */
                   1573:   if (may_be_alloca && nonlocal_goto_stack_level != 0)
                   1574:     emit_move_insn (nonlocal_goto_stack_level, stack_pointer_rtx);
                   1575: 
                   1576:   pop_temp_slots ();
                   1577: 
                   1578:   return target;
                   1579: }
                   1580: 
                   1581: #if 0
                   1582: /* Return an rtx which represents a suitable home on the stack
                   1583:    given TYPE, the type of the argument looking for a home.
                   1584:    This is called only for BLKmode arguments.
                   1585: 
                   1586:    SIZE is the size needed for this target.
                   1587:    ARGS_ADDR is the address of the bottom of the argument block for this call.
                   1588:    OFFSET describes this parameter's offset into ARGS_ADDR.  It is meaningless
                   1589:    if this machine uses push insns.  */
                   1590: 
                   1591: static rtx
                   1592: target_for_arg (type, size, args_addr, offset)
                   1593:      tree type;
                   1594:      rtx size;
                   1595:      rtx args_addr;
                   1596:      struct args_size offset;
                   1597: {
                   1598:   rtx target;
                   1599:   rtx offset_rtx = ARGS_SIZE_RTX (offset);
                   1600: 
                   1601:   /* We do not call memory_address if possible,
                   1602:      because we want to address as close to the stack
                   1603:      as possible.  For non-variable sized arguments,
                   1604:      this will be stack-pointer relative addressing.  */
                   1605:   if (GET_CODE (offset_rtx) == CONST_INT)
                   1606:     target = plus_constant (args_addr, INTVAL (offset_rtx));
                   1607:   else
                   1608:     {
                   1609:       /* I have no idea how to guarantee that this
                   1610:         will work in the presence of register parameters.  */
                   1611:       target = gen_rtx (PLUS, Pmode, args_addr, offset_rtx);
                   1612:       target = memory_address (QImode, target);
                   1613:     }
                   1614: 
                   1615:   return gen_rtx (MEM, BLKmode, target);
                   1616: }
                   1617: #endif
                   1618: 
                   1619: /* Store a single argument for a function call
                   1620:    into the register or memory area where it must be passed.
                   1621:    *ARG describes the argument value and where to pass it.
                   1622: 
                   1623:    ARGBLOCK is the address of the stack-block for all the arguments,
1.1.1.2 ! root     1624:    or 0 on a machine where arguments are pushed individually.
1.1       root     1625: 
                   1626:    MAY_BE_ALLOCA nonzero says this could be a call to `alloca'
                   1627:    so must be careful about how the stack is used. 
                   1628: 
                   1629:    VARIABLE_SIZE nonzero says that this was a variable-sized outgoing
                   1630:    argument stack.  This is used if ACCUMULATE_OUTGOING_ARGS to indicate
                   1631:    that we need not worry about saving and restoring the stack.
                   1632: 
                   1633:    FNDECL is the declaration of the function we are calling.  */
                   1634: 
                   1635: static void
                   1636: store_one_arg (arg, argblock, may_be_alloca, variable_size, fndecl)
                   1637:      struct arg_data *arg;
                   1638:      rtx argblock;
                   1639:      int may_be_alloca;
                   1640:      int variable_size;
                   1641:      tree fndecl;
                   1642: {
                   1643:   register tree pval = arg->tree_value;
                   1644:   rtx reg = 0;
                   1645:   int partial = 0;
                   1646:   int used = 0;
                   1647:   int i, lower_bound, upper_bound;
                   1648: 
                   1649:   if (TREE_CODE (pval) == ERROR_MARK)
                   1650:     return;
                   1651: 
                   1652: #ifdef ACCUMULATE_OUTGOING_ARGS
                   1653:   /* If this is being stored into a pre-allocated, fixed-size, stack area,
                   1654:      save any previous data at that location.  */
                   1655:   if (argblock && ! variable_size && arg->stack)
                   1656:     {
                   1657: #ifdef ARGS_GROW_DOWNWARD
                   1658:       /* stack_slot is negative, but we want to index stack_usage_map */
                   1659:       /* with positive values. */
                   1660:       if (GET_CODE (XEXP (arg->stack_slot, 0)) == PLUS)
                   1661:        upper_bound = -INTVAL (XEXP (XEXP (arg->stack_slot, 0), 1)) + 1;
                   1662:       else
                   1663:        abort ();
                   1664: 
                   1665:       lower_bound = upper_bound - arg->size.constant;
                   1666: #else
                   1667:       if (GET_CODE (XEXP (arg->stack_slot, 0)) == PLUS)
                   1668:        lower_bound = INTVAL (XEXP (XEXP (arg->stack_slot, 0), 1));
                   1669:       else
                   1670:        lower_bound = 0;
                   1671: 
                   1672:       upper_bound = lower_bound + arg->size.constant;
                   1673: #endif
                   1674: 
                   1675:       for (i = lower_bound; i < upper_bound; i++)
                   1676:        if (stack_usage_map[i]
                   1677: #ifdef REG_PARM_STACK_SPACE
                   1678:            /* Don't store things in the fixed argument area at this point;
                   1679:               it has already been saved.  */
                   1680:            && i > REG_PARM_STACK_SPACE (fndecl)
                   1681: #endif
                   1682:            )
                   1683:          break;
                   1684: 
                   1685:       if (i != upper_bound)
                   1686:        {
                   1687:          /* We need to make a save area.  See what mode we can make it.  */
                   1688:          enum machine_mode save_mode
                   1689:            = mode_for_size (arg->size.constant * BITS_PER_UNIT, MODE_INT, 1);
                   1690:          rtx stack_area
                   1691:            = gen_rtx (MEM, save_mode,
                   1692:                       memory_address (save_mode, XEXP (arg->stack_slot, 0)));
                   1693: 
                   1694:          if (save_mode == BLKmode)
                   1695:            {
                   1696:              arg->save_area = assign_stack_temp (BLKmode,
                   1697:                                                  arg->size.constant, 1);
                   1698:              emit_block_move (validize_mem (arg->save_area), stack_area,
                   1699:                               gen_rtx (CONST_INT, VOIDmode,
                   1700:                                        arg->size.constant),
                   1701:                               PARM_BOUNDARY / BITS_PER_UNIT);
                   1702:            }
                   1703:          else
                   1704:            {
                   1705:              arg->save_area = gen_reg_rtx (save_mode);
                   1706:              emit_move_insn (arg->save_area, stack_area);
                   1707:            }
                   1708:        }
                   1709:     }
                   1710: #endif
                   1711: 
                   1712:   /* If this isn't going to be placed on both the stack and in registers,
                   1713:      set up the register and number of words.  */
                   1714:   if (! arg->pass_on_stack)
                   1715:     reg = arg->reg, partial = arg->partial;
                   1716: 
                   1717:   if (reg != 0 && partial == 0)
                   1718:     /* Being passed entirely in a register.  We shouldn't be called in
                   1719:        this case.   */
                   1720:     abort ();
                   1721: 
                   1722:   /* If this is being partially passed in a register, but multiple locations
                   1723:      are specified, we assume that the one partially used is the one that is
                   1724:      listed first.  */
                   1725:   if (reg && GET_CODE (reg) == EXPR_LIST)
                   1726:     reg = XEXP (reg, 0);
                   1727: 
                   1728:   /* If this is being passes partially in a register, we can't evaluate
                   1729:      it directly into its stack slot.  Otherwise, we can.  */
                   1730:   if (arg->value == 0)
                   1731:     arg->value = expand_expr (pval, partial ? 0 : arg->stack, VOIDmode, 0);
                   1732: 
                   1733:   /* Don't allow anything left on stack from computation
                   1734:      of argument to alloca.  */
                   1735:   if (may_be_alloca)
                   1736:     do_pending_stack_adjust ();
                   1737: 
                   1738:   if (arg->value == arg->stack)
                   1739:     /* If the value is already in the stack slot, we are done.  */
                   1740:     ;
                   1741:   else if (TYPE_MODE (TREE_TYPE (pval)) != BLKmode)
                   1742:     {
                   1743:       register int size;
                   1744: 
                   1745:       /* Argument is a scalar, not entirely passed in registers.
                   1746:         (If part is passed in registers, arg->partial says how much
                   1747:         and emit_push_insn will take care of putting it there.)
                   1748:         
                   1749:         Push it, and if its size is less than the
                   1750:         amount of space allocated to it,
                   1751:         also bump stack pointer by the additional space.
                   1752:         Note that in C the default argument promotions
                   1753:         will prevent such mismatches.  */
                   1754: 
                   1755:       size = GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (pval)));
                   1756:       /* Compute how much space the push instruction will push.
                   1757:         On many machines, pushing a byte will advance the stack
                   1758:         pointer by a halfword.  */
                   1759: #ifdef PUSH_ROUNDING
                   1760:       size = PUSH_ROUNDING (size);
                   1761: #endif
                   1762:       used = size;
                   1763: 
                   1764:       /* Compute how much space the argument should get:
                   1765:         round up to a multiple of the alignment for arguments.  */
                   1766:       if (none != FUNCTION_ARG_PADDING (TYPE_MODE (TREE_TYPE (pval)),
                   1767:                                        TREE_TYPE (pval)))
                   1768:        used = (((size + PARM_BOUNDARY / BITS_PER_UNIT - 1)
                   1769:                 / (PARM_BOUNDARY / BITS_PER_UNIT))
                   1770:                * (PARM_BOUNDARY / BITS_PER_UNIT));
                   1771: 
                   1772:       /* This isn't already where we want it on the stack, so put it there.
                   1773:         This can either be done with push or copy insns.  */
                   1774:       emit_push_insn (arg->value, TYPE_MODE (TREE_TYPE (pval)),
                   1775:                      TREE_TYPE (pval), 0, 0, partial, reg,
                   1776:                      used - size, argblock, ARGS_SIZE_RTX (arg->offset));
                   1777:     }
                   1778:   else
                   1779:     {
                   1780:       /* BLKmode, at least partly to be pushed.  */
                   1781: 
                   1782:       register int excess;
                   1783:       rtx size_rtx;
                   1784: 
                   1785:       /* Pushing a nonscalar.
                   1786:         If part is passed in registers, PARTIAL says how much
                   1787:         and emit_push_insn will take care of putting it there.  */
                   1788: 
                   1789:       /* Round its size up to a multiple
                   1790:         of the allocation unit for arguments.  */
                   1791: 
                   1792:       if (arg->size.var != 0)
                   1793:        {
                   1794:          excess = 0;
                   1795:          size_rtx = ARGS_SIZE_RTX (arg->size);
                   1796:        }
                   1797:       else
                   1798:        {
                   1799:          register tree size = size_in_bytes (TREE_TYPE (pval));
                   1800:          /* PUSH_ROUNDING has no effect on us, because
                   1801:             emit_push_insn for BLKmode is careful to avoid it.  */
                   1802:          excess = (arg->size.constant - TREE_INT_CST_LOW (size)
                   1803:                    + partial * UNITS_PER_WORD);
                   1804:          size_rtx = expand_expr (size, 0, VOIDmode, 0);
                   1805:        }
                   1806: 
                   1807:       emit_push_insn (arg->value, TYPE_MODE (TREE_TYPE (pval)),
                   1808:                      TREE_TYPE (pval), size_rtx,
                   1809:                      TYPE_ALIGN (TREE_TYPE (pval)) / BITS_PER_UNIT, partial,
                   1810:                      reg, excess, argblock, ARGS_SIZE_RTX (arg->offset));
                   1811:     }
                   1812: 
                   1813: 
                   1814:   /* Unless this is a partially-in-register argument, the argument is now
                   1815:      in the stack. 
                   1816: 
                   1817:      ??? Note that this can change arg->value from arg->stack to
                   1818:      arg->stack_slot and it matters when they are not the same.
                   1819:      It isn't totally clear that this is correct in all cases.  */
                   1820:   if (partial == 0)
                   1821:     arg->value = arg->stack_slot;
                   1822: 
                   1823:   /* Once we have pushed something, pops can't safely
                   1824:      be deferred during the rest of the arguments.  */
                   1825:   NO_DEFER_POP;
                   1826: 
                   1827:   /* ANSI doesn't require a sequence point here,
                   1828:      but PCC has one, so this will avoid some problems.  */
                   1829:   emit_queue ();
                   1830: 
                   1831:   /* Free any temporary slots made in processing this argument.  */
                   1832:   free_temp_slots ();
                   1833: 
                   1834: #ifdef ACCUMULATE_OUTGOING_ARGS
                   1835:   /* Now mark the segment we just used.  */
                   1836:   if (argblock && ! variable_size && arg->stack)
                   1837:     for (i = lower_bound; i < upper_bound; i++)
                   1838:       stack_usage_map[i] = 1;
                   1839: #endif
                   1840: }

unix.superglobalmegacorp.com

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