OSDN Git Service

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