OSDN Git Service

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