OSDN Git Service

* alias.c: Change all uses of gen_rtx(FOO...) to gen_rtx_FOO;
[pf3gnuchains/gcc-fork.git] / gcc / calls.c
1 /* Convert function calls to rtl insns, for GNU C compiler.
2    Copyright (C) 1989, 92, 93, 94, 95, 96, 1997 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, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA.  */
20
21 #include "config.h"
22 #include <stdio.h>
23 #include "rtl.h"
24 #include "tree.h"
25 #include "flags.h"
26 #include "expr.h"
27 #include "regs.h"
28 #ifdef __STDC__
29 #include <stdarg.h>
30 #else
31 #include <varargs.h>
32 #endif
33 #include "insn-flags.h"
34
35 /* Decide whether a function's arguments should be processed
36    from first to last or from last to first.
37
38    They should if the stack and args grow in opposite directions, but
39    only if we have push insns.  */
40
41 #ifdef PUSH_ROUNDING
42
43 #if defined (STACK_GROWS_DOWNWARD) != defined (ARGS_GROW_DOWNWARD)
44 #define PUSH_ARGS_REVERSED      /* If it's last to first */
45 #endif
46
47 #endif
48
49 /* Like STACK_BOUNDARY but in units of bytes, not bits.  */
50 #define STACK_BYTES (STACK_BOUNDARY / BITS_PER_UNIT)
51
52 /* Data structure and subroutines used within expand_call.  */
53
54 struct arg_data
55 {
56   /* Tree node for this argument.  */
57   tree tree_value;
58   /* Mode for value; TYPE_MODE unless promoted.  */
59   enum machine_mode mode;
60   /* Current RTL value for argument, or 0 if it isn't precomputed.  */
61   rtx value;
62   /* Initially-compute RTL value for argument; only for const functions.  */
63   rtx initial_value;
64   /* Register to pass this argument in, 0 if passed on stack, or an
65      PARALLEL if the arg is to be copied into multiple non-contiguous
66      registers.  */
67   rtx reg;
68   /* If REG was promoted from the actual mode of the argument expression,
69      indicates whether the promotion is sign- or zero-extended.  */
70   int unsignedp;
71   /* Number of registers to use.  0 means put the whole arg in registers.
72      Also 0 if not passed in registers.  */
73   int partial;
74   /* Non-zero if argument must be passed on stack.
75      Note that some arguments may be passed on the stack
76      even though pass_on_stack is zero, just because FUNCTION_ARG says so.
77      pass_on_stack identifies arguments that *cannot* go in registers.  */
78   int pass_on_stack;
79   /* Offset of this argument from beginning of stack-args.  */
80   struct args_size offset;
81   /* Similar, but offset to the start of the stack slot.  Different from
82      OFFSET if this arg pads downward.  */
83   struct args_size slot_offset;
84   /* Size of this argument on the stack, rounded up for any padding it gets,
85      parts of the argument passed in registers do not count.
86      If REG_PARM_STACK_SPACE is defined, then register parms
87      are counted here as well.  */
88   struct args_size size;
89   /* Location on the stack at which parameter should be stored.  The store
90      has already been done if STACK == VALUE.  */
91   rtx stack;
92   /* Location on the stack of the start of this argument slot.  This can
93      differ from STACK if this arg pads downward.  This location is known
94      to be aligned to FUNCTION_ARG_BOUNDARY.  */
95   rtx stack_slot;
96 #ifdef ACCUMULATE_OUTGOING_ARGS
97   /* Place that this stack area has been saved, if needed.  */
98   rtx save_area;
99 #endif
100   /* If an argument's alignment does not permit direct copying into registers,
101      copy in smaller-sized pieces into pseudos.  These are stored in a
102      block pointed to by this field.  The next field says how many
103      word-sized pseudos we made.  */
104   rtx *aligned_regs;
105   int n_aligned_regs;
106 };
107
108 #ifdef ACCUMULATE_OUTGOING_ARGS
109 /* A vector of one char per byte of stack space.  A byte if non-zero if
110    the corresponding stack location has been used.
111    This vector is used to prevent a function call within an argument from
112    clobbering any stack already set up.  */
113 static char *stack_usage_map;
114
115 /* Size of STACK_USAGE_MAP.  */
116 static int highest_outgoing_arg_in_use;
117
118 /* stack_arg_under_construction is nonzero when an argument may be
119    initialized with a constructor call (including a C function that
120    returns a BLKmode struct) and expand_call must take special action
121    to make sure the object being constructed does not overlap the
122    argument list for the constructor call.  */
123 int stack_arg_under_construction;
124 #endif
125
126 static int calls_function       PROTO((tree, int));
127 static int calls_function_1     PROTO((tree, int));
128 static void emit_call_1         PROTO((rtx, tree, tree, int, int, rtx, rtx,
129                                        int, rtx, int));
130 static void store_one_arg       PROTO ((struct arg_data *, rtx, int, int,
131                                         tree, int));
132 \f
133 /* If WHICH is 1, return 1 if EXP contains a call to the built-in function
134    `alloca'.
135
136    If WHICH is 0, return 1 if EXP contains a call to any function.
137    Actually, we only need return 1 if evaluating EXP would require pushing
138    arguments on the stack, but that is too difficult to compute, so we just
139    assume any function call might require the stack.  */
140
141 static tree calls_function_save_exprs;
142
143 static int
144 calls_function (exp, which)
145      tree exp;
146      int which;
147 {
148   int val;
149   calls_function_save_exprs = 0;
150   val = calls_function_1 (exp, which);
151   calls_function_save_exprs = 0;
152   return val;
153 }
154
155 static int
156 calls_function_1 (exp, which)
157      tree exp;
158      int which;
159 {
160   register int i;
161   enum tree_code code = TREE_CODE (exp);
162   int type = TREE_CODE_CLASS (code);
163   int length = tree_code_length[(int) code];
164
165   /* If this code is language-specific, we don't know what it will do.  */
166   if ((int) code >= NUM_TREE_CODES)
167     return 1;
168
169   /* Only expressions and references can contain calls.  */
170   if (type != 'e' && type != '<' && type != '1' && type != '2' && type != 'r'
171       && type != 'b')
172     return 0;
173
174   switch (code)
175     {
176     case CALL_EXPR:
177       if (which == 0)
178         return 1;
179       else if (TREE_CODE (TREE_OPERAND (exp, 0)) == ADDR_EXPR
180                && (TREE_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0))
181                    == FUNCTION_DECL))
182         {
183           tree fndecl = TREE_OPERAND (TREE_OPERAND (exp, 0), 0);
184
185           if ((DECL_BUILT_IN (fndecl)
186                && DECL_FUNCTION_CODE (fndecl) == BUILT_IN_ALLOCA)
187               || (DECL_SAVED_INSNS (fndecl)
188                   && (FUNCTION_FLAGS (DECL_SAVED_INSNS (fndecl))
189                       & FUNCTION_FLAGS_CALLS_ALLOCA)))
190             return 1;
191         }
192
193       /* Third operand is RTL.  */
194       length = 2;
195       break;
196
197     case SAVE_EXPR:
198       if (SAVE_EXPR_RTL (exp) != 0)
199         return 0;
200       if (value_member (exp, calls_function_save_exprs))
201         return 0;
202       calls_function_save_exprs = tree_cons (NULL_TREE, exp,
203                                              calls_function_save_exprs);
204       return (TREE_OPERAND (exp, 0) != 0
205               && calls_function_1 (TREE_OPERAND (exp, 0), which));
206
207     case BLOCK:
208       {
209         register tree local;
210
211         for (local = BLOCK_VARS (exp); local; local = TREE_CHAIN (local))
212           if (DECL_INITIAL (local) != 0
213               && calls_function_1 (DECL_INITIAL (local), which))
214             return 1;
215       }
216       {
217         register tree subblock;
218
219         for (subblock = BLOCK_SUBBLOCKS (exp);
220              subblock;
221              subblock = TREE_CHAIN (subblock))
222           if (calls_function_1 (subblock, which))
223             return 1;
224       }
225       return 0;
226
227     case METHOD_CALL_EXPR:
228       length = 3;
229       break;
230
231     case WITH_CLEANUP_EXPR:
232       length = 1;
233       break;
234
235     case RTL_EXPR:
236       return 0;
237       
238     default:
239       break;
240     }
241
242   for (i = 0; i < length; i++)
243     if (TREE_OPERAND (exp, i) != 0
244         && calls_function_1 (TREE_OPERAND (exp, i), which))
245       return 1;
246
247   return 0;
248 }
249 \f
250 /* Force FUNEXP into a form suitable for the address of a CALL,
251    and return that as an rtx.  Also load the static chain register
252    if FNDECL is a nested function.
253
254    CALL_FUSAGE points to a variable holding the prospective
255    CALL_INSN_FUNCTION_USAGE information.  */
256
257 rtx
258 prepare_call_address (funexp, fndecl, call_fusage, reg_parm_seen)
259      rtx funexp;
260      tree fndecl;
261      rtx *call_fusage;
262      int reg_parm_seen;
263 {
264   rtx static_chain_value = 0;
265
266   funexp = protect_from_queue (funexp, 0);
267
268   if (fndecl != 0)
269     /* Get possible static chain value for nested function in C.  */
270     static_chain_value = lookup_static_chain (fndecl);
271
272   /* Make a valid memory address and copy constants thru pseudo-regs,
273      but not for a constant address if -fno-function-cse.  */
274   if (GET_CODE (funexp) != SYMBOL_REF)
275     /* If we are using registers for parameters, force the
276        function address into a register now.  */
277     funexp = ((SMALL_REGISTER_CLASSES && reg_parm_seen)
278               ? force_not_mem (memory_address (FUNCTION_MODE, funexp))
279               : memory_address (FUNCTION_MODE, funexp));
280   else
281     {
282 #ifndef NO_FUNCTION_CSE
283       if (optimize && ! flag_no_function_cse)
284 #ifdef NO_RECURSIVE_FUNCTION_CSE
285         if (fndecl != current_function_decl)
286 #endif
287           funexp = force_reg (Pmode, funexp);
288 #endif
289     }
290
291   if (static_chain_value != 0)
292     {
293       emit_move_insn (static_chain_rtx, static_chain_value);
294
295       if (GET_CODE (static_chain_rtx) == REG)
296         use_reg (call_fusage, static_chain_rtx);
297     }
298
299   return funexp;
300 }
301
302 /* Generate instructions to call function FUNEXP,
303    and optionally pop the results.
304    The CALL_INSN is the first insn generated.
305
306    FNDECL is the declaration node of the function.  This is given to the
307    macro RETURN_POPS_ARGS to determine whether this function pops its own args.
308
309    FUNTYPE is the data type of the function.  This is given to the macro
310    RETURN_POPS_ARGS to determine whether this function pops its own args.
311    We used to allow an identifier for library functions, but that doesn't
312    work when the return type is an aggregate type and the calling convention
313    says that the pointer to this aggregate is to be popped by the callee.
314
315    STACK_SIZE is the number of bytes of arguments on the stack,
316    rounded up to STACK_BOUNDARY; zero if the size is variable.
317    This is both to put into the call insn and
318    to generate explicit popping code if necessary.
319
320    STRUCT_VALUE_SIZE is the number of bytes wanted in a structure value.
321    It is zero if this call doesn't want a structure value.
322
323    NEXT_ARG_REG is the rtx that results from executing
324      FUNCTION_ARG (args_so_far, VOIDmode, void_type_node, 1)
325    just after all the args have had their registers assigned.
326    This could be whatever you like, but normally it is the first
327    arg-register beyond those used for args in this call,
328    or 0 if all the arg-registers are used in this call.
329    It is passed on to `gen_call' so you can put this info in the call insn.
330
331    VALREG is a hard register in which a value is returned,
332    or 0 if the call does not return a value.
333
334    OLD_INHIBIT_DEFER_POP is the value that `inhibit_defer_pop' had before
335    the args to this call were processed.
336    We restore `inhibit_defer_pop' to that value.
337
338    CALL_FUSAGE is either empty or an EXPR_LIST of USE expressions that
339    denote registers used by the called function.
340
341    IS_CONST is true if this is a `const' call.  */
342
343 static void
344 emit_call_1 (funexp, fndecl, funtype, stack_size, struct_value_size, 
345              next_arg_reg, valreg, old_inhibit_defer_pop, call_fusage,
346              is_const)
347      rtx funexp;
348      tree fndecl;
349      tree funtype;
350      int stack_size;
351      int struct_value_size;
352      rtx next_arg_reg;
353      rtx valreg;
354      int old_inhibit_defer_pop;
355      rtx call_fusage;
356      int is_const;
357 {
358   rtx stack_size_rtx = GEN_INT (stack_size);
359   rtx struct_value_size_rtx = GEN_INT (struct_value_size);
360   rtx call_insn;
361   int already_popped = 0;
362
363   /* Ensure address is valid.  SYMBOL_REF is already valid, so no need,
364      and we don't want to load it into a register as an optimization,
365      because prepare_call_address already did it if it should be done.  */
366   if (GET_CODE (funexp) != SYMBOL_REF)
367     funexp = memory_address (FUNCTION_MODE, funexp);
368
369 #ifndef ACCUMULATE_OUTGOING_ARGS
370 #if defined (HAVE_call_pop) && defined (HAVE_call_value_pop)
371   if (HAVE_call_pop && HAVE_call_value_pop
372       && (RETURN_POPS_ARGS (fndecl, funtype, stack_size) > 0 
373           || stack_size == 0))
374     {
375       rtx n_pop = GEN_INT (RETURN_POPS_ARGS (fndecl, funtype, stack_size));
376       rtx pat;
377
378       /* If this subroutine pops its own args, record that in the call insn
379          if possible, for the sake of frame pointer elimination.  */
380
381       if (valreg)
382         pat = gen_call_value_pop (valreg,
383                                   gen_rtx_MEM (FUNCTION_MODE, funexp),
384                                   stack_size_rtx, next_arg_reg, n_pop);
385       else
386         pat = gen_call_pop (gen_rtx_MEM (FUNCTION_MODE, funexp),
387                             stack_size_rtx, next_arg_reg, n_pop);
388
389       emit_call_insn (pat);
390       already_popped = 1;
391     }
392   else
393 #endif
394 #endif
395
396 #if defined (HAVE_call) && defined (HAVE_call_value)
397   if (HAVE_call && HAVE_call_value)
398     {
399       if (valreg)
400         emit_call_insn (gen_call_value (valreg,
401                                         gen_rtx_MEM (FUNCTION_MODE, funexp),
402                                         stack_size_rtx, next_arg_reg,
403                                         NULL_RTX));
404       else
405         emit_call_insn (gen_call (gen_rtx_MEM (FUNCTION_MODE, funexp),
406                                   stack_size_rtx, next_arg_reg,
407                                   struct_value_size_rtx));
408     }
409   else
410 #endif
411     abort ();
412
413   /* Find the CALL insn we just emitted.  */
414   for (call_insn = get_last_insn ();
415        call_insn && GET_CODE (call_insn) != CALL_INSN;
416        call_insn = PREV_INSN (call_insn))
417     ;
418
419   if (! call_insn)
420     abort ();
421
422   /* Put the register usage information on the CALL.  If there is already
423      some usage information, put ours at the end.  */
424   if (CALL_INSN_FUNCTION_USAGE (call_insn))
425     {
426       rtx link;
427
428       for (link = CALL_INSN_FUNCTION_USAGE (call_insn); XEXP (link, 1) != 0;
429            link = XEXP (link, 1))
430         ;
431
432       XEXP (link, 1) = call_fusage;
433     }
434   else
435     CALL_INSN_FUNCTION_USAGE (call_insn) = call_fusage;
436
437   /* If this is a const call, then set the insn's unchanging bit.  */
438   if (is_const)
439     CONST_CALL_P (call_insn) = 1;
440
441   /* Restore this now, so that we do defer pops for this call's args
442      if the context of the call as a whole permits.  */
443   inhibit_defer_pop = old_inhibit_defer_pop;
444
445 #ifndef ACCUMULATE_OUTGOING_ARGS
446   /* If returning from the subroutine does not automatically pop the args,
447      we need an instruction to pop them sooner or later.
448      Perhaps do it now; perhaps just record how much space to pop later.
449
450      If returning from the subroutine does pop the args, indicate that the
451      stack pointer will be changed.  */
452
453   if (stack_size != 0 && RETURN_POPS_ARGS (fndecl, funtype, stack_size) > 0)
454     {
455       if (!already_popped)
456         CALL_INSN_FUNCTION_USAGE (call_insn)
457           = gen_rtx_EXPR_LIST (VOIDmode,
458                                gen_rtx_CLOBBER (VOIDmode, stack_pointer_rtx),
459                                CALL_INSN_FUNCTION_USAGE (call_insn));
460       stack_size -= RETURN_POPS_ARGS (fndecl, funtype, stack_size);
461       stack_size_rtx = GEN_INT (stack_size);
462     }
463
464   if (stack_size != 0)
465     {
466       if (flag_defer_pop && inhibit_defer_pop == 0 && !is_const)
467         pending_stack_adjust += stack_size;
468       else
469         adjust_stack (stack_size_rtx);
470     }
471 #endif
472 }
473
474 /* Generate all the code for a function call
475    and return an rtx for its value.
476    Store the value in TARGET (specified as an rtx) if convenient.
477    If the value is stored in TARGET then TARGET is returned.
478    If IGNORE is nonzero, then we ignore the value of the function call.  */
479
480 rtx
481 expand_call (exp, target, ignore)
482      tree exp;
483      rtx target;
484      int ignore;
485 {
486   /* List of actual parameters.  */
487   tree actparms = TREE_OPERAND (exp, 1);
488   /* RTX for the function to be called.  */
489   rtx funexp;
490   /* Tree node for the function to be called (not the address!).  */
491   tree funtree;
492   /* Data type of the function.  */
493   tree funtype;
494   /* Declaration of the function being called,
495      or 0 if the function is computed (not known by name).  */
496   tree fndecl = 0;
497   char *name = 0;
498
499   /* Register in which non-BLKmode value will be returned,
500      or 0 if no value or if value is BLKmode.  */
501   rtx valreg;
502   /* Address where we should return a BLKmode value;
503      0 if value not BLKmode.  */
504   rtx structure_value_addr = 0;
505   /* Nonzero if that address is being passed by treating it as
506      an extra, implicit first parameter.  Otherwise,
507      it is passed by being copied directly into struct_value_rtx.  */
508   int structure_value_addr_parm = 0;
509   /* Size of aggregate value wanted, or zero if none wanted
510      or if we are using the non-reentrant PCC calling convention
511      or expecting the value in registers.  */
512   int struct_value_size = 0;
513   /* Nonzero if called function returns an aggregate in memory PCC style,
514      by returning the address of where to find it.  */
515   int pcc_struct_value = 0;
516
517   /* Number of actual parameters in this call, including struct value addr.  */
518   int num_actuals;
519   /* Number of named args.  Args after this are anonymous ones
520      and they must all go on the stack.  */
521   int n_named_args;
522   /* Count arg position in order args appear.  */
523   int argpos;
524
525   /* Vector of information about each argument.
526      Arguments are numbered in the order they will be pushed,
527      not the order they are written.  */
528   struct arg_data *args;
529
530   /* Total size in bytes of all the stack-parms scanned so far.  */
531   struct args_size args_size;
532   /* Size of arguments before any adjustments (such as rounding).  */
533   struct args_size original_args_size;
534   /* Data on reg parms scanned so far.  */
535   CUMULATIVE_ARGS args_so_far;
536   /* Nonzero if a reg parm has been scanned.  */
537   int reg_parm_seen;
538   /* Nonzero if this is an indirect function call.  */
539
540   /* Nonzero if we must avoid push-insns in the args for this call. 
541      If stack space is allocated for register parameters, but not by the
542      caller, then it is preallocated in the fixed part of the stack frame.
543      So the entire argument block must then be preallocated (i.e., we
544      ignore PUSH_ROUNDING in that case).  */
545
546 #if defined(REG_PARM_STACK_SPACE) && ! defined(OUTGOING_REG_PARM_STACK_SPACE)
547   int must_preallocate = 1;
548 #else
549 #ifdef PUSH_ROUNDING
550   int must_preallocate = 0;
551 #else
552   int must_preallocate = 1;
553 #endif
554 #endif
555
556   /* Size of the stack reserved for parameter registers.  */
557   int reg_parm_stack_space = 0;
558
559   /* 1 if scanning parms front to back, -1 if scanning back to front.  */
560   int inc;
561   /* Address of space preallocated for stack parms
562      (on machines that lack push insns), or 0 if space not preallocated.  */
563   rtx argblock = 0;
564
565   /* Nonzero if it is plausible that this is a call to alloca.  */
566   int may_be_alloca;
567   /* Nonzero if this is a call to malloc or a related function. */
568   int is_malloc;
569   /* Nonzero if this is a call to setjmp or a related function.  */
570   int returns_twice;
571   /* Nonzero if this is a call to `longjmp'.  */
572   int is_longjmp;
573   /* Nonzero if this is a call to an inline function.  */
574   int is_integrable = 0;
575   /* Nonzero if this is a call to a `const' function.
576      Note that only explicitly named functions are handled as `const' here.  */
577   int is_const = 0;
578   /* Nonzero if this is a call to a `volatile' function.  */
579   int is_volatile = 0;
580 #if defined(ACCUMULATE_OUTGOING_ARGS) && defined(REG_PARM_STACK_SPACE)
581   /* Define the boundary of the register parm stack space that needs to be
582      save, if any.  */
583   int low_to_save = -1, high_to_save;
584   rtx save_area = 0;            /* Place that it is saved */
585 #endif
586
587 #ifdef ACCUMULATE_OUTGOING_ARGS
588   int initial_highest_arg_in_use = highest_outgoing_arg_in_use;
589   char *initial_stack_usage_map = stack_usage_map;
590 #endif
591
592   rtx old_stack_level = 0;
593   int old_pending_adj = 0;
594   int old_stack_arg_under_construction;
595   int old_inhibit_defer_pop = inhibit_defer_pop;
596   rtx call_fusage = 0;
597   register tree p;
598   register int i, j;
599
600   /* The value of the function call can be put in a hard register.  But
601      if -fcheck-memory-usage, code which invokes functions (and thus
602      damages some hard registers) can be inserted before using the value.
603      So, target is always a pseudo-register in that case.  */
604   if (flag_check_memory_usage)
605     target = 0;
606
607   /* See if we can find a DECL-node for the actual function.
608      As a result, decide whether this is a call to an integrable function.  */
609
610   p = TREE_OPERAND (exp, 0);
611   if (TREE_CODE (p) == ADDR_EXPR)
612     {
613       fndecl = TREE_OPERAND (p, 0);
614       if (TREE_CODE (fndecl) != FUNCTION_DECL)
615         fndecl = 0;
616       else
617         {
618           if (!flag_no_inline
619               && fndecl != current_function_decl
620               && DECL_INLINE (fndecl)
621               && DECL_SAVED_INSNS (fndecl)
622               && RTX_INTEGRATED_P (DECL_SAVED_INSNS (fndecl)))
623             is_integrable = 1;
624           else if (! TREE_ADDRESSABLE (fndecl))
625             {
626               /* In case this function later becomes inlinable,
627                  record that there was already a non-inline call to it.
628
629                  Use abstraction instead of setting TREE_ADDRESSABLE
630                  directly.  */
631               if (DECL_INLINE (fndecl) && warn_inline && !flag_no_inline
632                   && optimize > 0)
633                 {
634                   warning_with_decl (fndecl, "can't inline call to `%s'");
635                   warning ("called from here");
636                 }
637               mark_addressable (fndecl);
638             }
639
640           if (TREE_READONLY (fndecl) && ! TREE_THIS_VOLATILE (fndecl)
641               && TYPE_MODE (TREE_TYPE (exp)) != VOIDmode)
642             is_const = 1;
643
644           if (TREE_THIS_VOLATILE (fndecl))
645             is_volatile = 1;
646         }
647     }
648
649   /* If we don't have specific function to call, see if we have a 
650      constant or `noreturn' function from the type.  */
651   if (fndecl == 0)
652     {
653       is_const = TREE_READONLY (TREE_TYPE (TREE_TYPE (p)));
654       is_volatile = TREE_THIS_VOLATILE (TREE_TYPE (TREE_TYPE (p)));
655     }
656
657 #ifdef REG_PARM_STACK_SPACE
658 #ifdef MAYBE_REG_PARM_STACK_SPACE
659   reg_parm_stack_space = MAYBE_REG_PARM_STACK_SPACE;
660 #else
661   reg_parm_stack_space = REG_PARM_STACK_SPACE (fndecl);
662 #endif
663 #endif
664
665   /* Warn if this value is an aggregate type,
666      regardless of which calling convention we are using for it.  */
667   if (warn_aggregate_return && AGGREGATE_TYPE_P (TREE_TYPE (exp)))
668     warning ("function call has aggregate value");
669
670   /* Set up a place to return a structure.  */
671
672   /* Cater to broken compilers.  */
673   if (aggregate_value_p (exp))
674     {
675       /* This call returns a big structure.  */
676       is_const = 0;
677
678 #ifdef PCC_STATIC_STRUCT_RETURN
679       {
680         pcc_struct_value = 1;
681         /* Easier than making that case work right.  */
682         if (is_integrable)
683           {
684             /* In case this is a static function, note that it has been
685                used.  */
686             if (! TREE_ADDRESSABLE (fndecl))
687               mark_addressable (fndecl);
688             is_integrable = 0;
689           }
690       }
691 #else /* not PCC_STATIC_STRUCT_RETURN */
692       {
693         struct_value_size = int_size_in_bytes (TREE_TYPE (exp));
694
695         if (target && GET_CODE (target) == MEM)
696           structure_value_addr = XEXP (target, 0);
697         else
698           {
699             /* Assign a temporary to hold the value.  */
700             tree d;
701
702             /* For variable-sized objects, we must be called with a target
703                specified.  If we were to allocate space on the stack here,
704                we would have no way of knowing when to free it.  */
705
706             if (struct_value_size < 0)
707               abort ();
708
709             /* This DECL is just something to feed to mark_addressable;
710                it doesn't get pushed.  */
711             d = build_decl (VAR_DECL, NULL_TREE, TREE_TYPE (exp));
712             DECL_RTL (d) = assign_temp (TREE_TYPE (exp), 1, 0, 1);
713             mark_addressable (d);
714             structure_value_addr = XEXP (DECL_RTL (d), 0);
715             MEM_IN_STRUCT_P (structure_value_addr)
716               = AGGREGATE_TYPE_P (TREE_TYPE (exp));
717             target = 0;
718           }
719       }
720 #endif /* not PCC_STATIC_STRUCT_RETURN */
721     }
722
723   /* If called function is inline, try to integrate it.  */
724
725   if (is_integrable)
726     {
727       rtx temp;
728       rtx before_call = get_last_insn ();
729
730       temp = expand_inline_function (fndecl, actparms, target,
731                                      ignore, TREE_TYPE (exp),
732                                      structure_value_addr);
733
734       /* If inlining succeeded, return.  */
735       if ((HOST_WIDE_INT) temp != -1)
736         {
737 #ifdef ACCUMULATE_OUTGOING_ARGS
738           /* If the outgoing argument list must be preserved, push
739              the stack before executing the inlined function if it
740              makes any calls.  */
741
742           for (i = reg_parm_stack_space - 1; i >= 0; i--)
743             if (i < highest_outgoing_arg_in_use && stack_usage_map[i] != 0)
744               break;
745
746           if (stack_arg_under_construction || i >= 0)
747             {
748               rtx first_insn
749                 = before_call ? NEXT_INSN (before_call) : get_insns ();
750               rtx insn, seq;
751
752               /* Look for a call in the inline function code.
753                  If OUTGOING_ARGS_SIZE (DECL_SAVED_INSNS (fndecl)) is
754                  nonzero then there is a call and it is not necessary
755                  to scan the insns.  */
756
757               if (OUTGOING_ARGS_SIZE (DECL_SAVED_INSNS (fndecl)) == 0)
758                 for (insn = first_insn; insn; insn = NEXT_INSN (insn))
759                   if (GET_CODE (insn) == CALL_INSN)
760                     break;
761
762               if (insn)
763                 {
764                   /* Reserve enough stack space so that the largest
765                      argument list of any function call in the inline
766                      function does not overlap the argument list being
767                      evaluated.  This is usually an overestimate because
768                      allocate_dynamic_stack_space reserves space for an
769                      outgoing argument list in addition to the requested
770                      space, but there is no way to ask for stack space such
771                      that an argument list of a certain length can be
772                      safely constructed.  */
773
774                   int adjust = OUTGOING_ARGS_SIZE (DECL_SAVED_INSNS (fndecl));
775 #ifdef REG_PARM_STACK_SPACE
776                   /* Add the stack space reserved for register arguments
777                      in the inline function.  What is really needed is the
778                      largest value of reg_parm_stack_space in the inline
779                      function, but that is not available.  Using the current
780                      value of reg_parm_stack_space is wrong, but gives
781                      correct results on all supported machines.  */
782                   adjust += reg_parm_stack_space;
783 #endif
784                   start_sequence ();
785                   emit_stack_save (SAVE_BLOCK, &old_stack_level, NULL_RTX);
786                   allocate_dynamic_stack_space (GEN_INT (adjust),
787                                                 NULL_RTX, BITS_PER_UNIT);
788                   seq = get_insns ();
789                   end_sequence ();
790                   emit_insns_before (seq, first_insn);
791                   emit_stack_restore (SAVE_BLOCK, old_stack_level, NULL_RTX);
792                 }
793             }
794 #endif
795
796           /* If the result is equivalent to TARGET, return TARGET to simplify
797              checks in store_expr.  They can be equivalent but not equal in the
798              case of a function that returns BLKmode.  */
799           if (temp != target && rtx_equal_p (temp, target))
800             return target;
801           return temp;
802         }
803
804       /* If inlining failed, mark FNDECL as needing to be compiled
805          separately after all.  If function was declared inline,
806          give a warning.  */
807       if (DECL_INLINE (fndecl) && warn_inline && !flag_no_inline
808           && optimize > 0 && ! TREE_ADDRESSABLE (fndecl))
809         {
810           warning_with_decl (fndecl, "inlining failed in call to `%s'");
811           warning ("called from here");
812         }
813       mark_addressable (fndecl);
814     }
815
816   /* When calling a const function, we must pop the stack args right away,
817      so that the pop is deleted or moved with the call.  */
818   if (is_const)
819     NO_DEFER_POP;
820
821   function_call_count++;
822
823   if (fndecl && DECL_NAME (fndecl))
824     name = IDENTIFIER_POINTER (DECL_NAME (fndecl));
825
826 #if 0
827   /* Unless it's a call to a specific function that isn't alloca,
828      if it has one argument, we must assume it might be alloca.  */
829
830   may_be_alloca
831     = (!(fndecl != 0 && strcmp (name, "alloca"))
832        && actparms != 0
833        && TREE_CHAIN (actparms) == 0);
834 #else
835   /* We assume that alloca will always be called by name.  It
836      makes no sense to pass it as a pointer-to-function to
837      anything that does not understand its behavior.  */
838   may_be_alloca
839     = (name && ((IDENTIFIER_LENGTH (DECL_NAME (fndecl)) == 6
840                  && name[0] == 'a'
841                  && ! strcmp (name, "alloca"))
842                 || (IDENTIFIER_LENGTH (DECL_NAME (fndecl)) == 16
843                     && name[0] == '_'
844                     && ! strcmp (name, "__builtin_alloca"))));
845 #endif
846
847   /* See if this is a call to a function that can return more than once
848      or a call to longjmp.  */
849
850   returns_twice = 0;
851   is_longjmp = 0;
852   is_malloc = 0;
853
854   if (name != 0 && IDENTIFIER_LENGTH (DECL_NAME (fndecl)) <= 15)
855     {
856       char *tname = name;
857
858       /* Disregard prefix _, __ or __x.  */
859       if (name[0] == '_')
860         {
861           if (name[1] == '_' && name[2] == 'x')
862             tname += 3;
863           else if (name[1] == '_')
864             tname += 2;
865           else
866             tname += 1;
867         }
868
869       if (tname[0] == 's')
870         {
871           returns_twice
872             = ((tname[1] == 'e'
873                 && (! strcmp (tname, "setjmp")
874                     || ! strcmp (tname, "setjmp_syscall")))
875                || (tname[1] == 'i'
876                    && ! strcmp (tname, "sigsetjmp"))
877                || (tname[1] == 'a'
878                    && ! strcmp (tname, "savectx")));
879           if (tname[1] == 'i'
880               && ! strcmp (tname, "siglongjmp"))
881             is_longjmp = 1;
882         }
883       else if ((tname[0] == 'q' && tname[1] == 's'
884                 && ! strcmp (tname, "qsetjmp"))
885                || (tname[0] == 'v' && tname[1] == 'f'
886                    && ! strcmp (tname, "vfork")))
887         returns_twice = 1;
888
889       else if (tname[0] == 'l' && tname[1] == 'o'
890                && ! strcmp (tname, "longjmp"))
891         is_longjmp = 1;
892       /* XXX should have "malloc" attribute on functions instead
893          of recognizing them by name.  */
894       else if (! strcmp (tname, "malloc")
895                || ! strcmp (tname, "calloc")
896                || ! strcmp (tname, "realloc")
897                || ! strcmp (tname, "__builtin_new")
898                || ! strcmp (tname, "__builtin_vec_new"))
899         is_malloc = 1;
900     }
901
902   if (may_be_alloca)
903     current_function_calls_alloca = 1;
904
905   /* Don't let pending stack adjusts add up to too much.
906      Also, do all pending adjustments now
907      if there is any chance this might be a call to alloca.  */
908
909   if (pending_stack_adjust >= 32
910       || (pending_stack_adjust > 0 && may_be_alloca))
911     do_pending_stack_adjust ();
912
913   /* Operand 0 is a pointer-to-function; get the type of the function.  */
914   funtype = TREE_TYPE (TREE_OPERAND (exp, 0));
915   if (TREE_CODE (funtype) != POINTER_TYPE)
916     abort ();
917   funtype = TREE_TYPE (funtype);
918
919   /* Push the temporary stack slot level so that we can free any temporaries
920      we make.  */
921   push_temp_slots ();
922
923   /* Start updating where the next arg would go.
924
925      On some machines (such as the PA) indirect calls have a different
926      calling convention than normal calls.  The last argument in
927      INIT_CUMULATIVE_ARGS tells the backend if this is an indirect call
928      or not.  */
929   INIT_CUMULATIVE_ARGS (args_so_far, funtype, NULL_RTX, (fndecl == 0));
930
931   /* If struct_value_rtx is 0, it means pass the address
932      as if it were an extra parameter.  */
933   if (structure_value_addr && struct_value_rtx == 0)
934     {
935       /* If structure_value_addr is a REG other than
936          virtual_outgoing_args_rtx, we can use always use it.  If it
937          is not a REG, we must always copy it into a register.
938          If it is virtual_outgoing_args_rtx, we must copy it to another
939          register in some cases.  */
940       rtx temp = (GET_CODE (structure_value_addr) != REG
941 #ifdef ACCUMULATE_OUTGOING_ARGS
942                   || (stack_arg_under_construction
943                       && structure_value_addr == virtual_outgoing_args_rtx)
944 #endif
945                   ? copy_addr_to_reg (structure_value_addr)
946                   : structure_value_addr);
947
948       actparms
949         = tree_cons (error_mark_node,
950                      make_tree (build_pointer_type (TREE_TYPE (funtype)),
951                                 temp),
952                      actparms);
953       structure_value_addr_parm = 1;
954     }
955
956   /* Count the arguments and set NUM_ACTUALS.  */
957   for (p = actparms, i = 0; p; p = TREE_CHAIN (p)) i++;
958   num_actuals = i;
959
960   /* Compute number of named args.
961      Normally, don't include the last named arg if anonymous args follow.
962      We do include the last named arg if STRICT_ARGUMENT_NAMING is defined.
963      (If no anonymous args follow, the result of list_length is actually
964      one too large.  This is harmless.)
965
966      If SETUP_INCOMING_VARARGS is defined and STRICT_ARGUMENT_NAMING is not,
967      this machine will be able to place unnamed args that were passed in
968      registers into the stack.  So treat all args as named.  This allows the
969      insns emitting for a specific argument list to be independent of the
970      function declaration.
971
972      If SETUP_INCOMING_VARARGS is not defined, we do not have any reliable
973      way to pass unnamed args in registers, so we must force them into
974      memory.  */
975 #if !defined(SETUP_INCOMING_VARARGS) || defined(STRICT_ARGUMENT_NAMING)
976   if (TYPE_ARG_TYPES (funtype) != 0)
977     n_named_args
978       = (list_length (TYPE_ARG_TYPES (funtype))
979 #ifndef STRICT_ARGUMENT_NAMING
980          /* Don't include the last named arg.  */
981          - 1
982 #endif
983          /* Count the struct value address, if it is passed as a parm.  */
984          + structure_value_addr_parm);
985   else
986 #endif
987     /* If we know nothing, treat all args as named.  */
988     n_named_args = num_actuals;
989
990   /* Make a vector to hold all the information about each arg.  */
991   args = (struct arg_data *) alloca (num_actuals * sizeof (struct arg_data));
992   bzero ((char *) args, num_actuals * sizeof (struct arg_data));
993
994   args_size.constant = 0;
995   args_size.var = 0;
996
997   /* In this loop, we consider args in the order they are written.
998      We fill up ARGS from the front or from the back if necessary
999      so that in any case the first arg to be pushed ends up at the front.  */
1000
1001 #ifdef PUSH_ARGS_REVERSED
1002   i = num_actuals - 1, inc = -1;
1003   /* In this case, must reverse order of args
1004      so that we compute and push the last arg first.  */
1005 #else
1006   i = 0, inc = 1;
1007 #endif
1008
1009   /* I counts args in order (to be) pushed; ARGPOS counts in order written.  */
1010   for (p = actparms, argpos = 0; p; p = TREE_CHAIN (p), i += inc, argpos++)
1011     {
1012       tree type = TREE_TYPE (TREE_VALUE (p));
1013       int unsignedp;
1014       enum machine_mode mode;
1015
1016       args[i].tree_value = TREE_VALUE (p);
1017
1018       /* Replace erroneous argument with constant zero.  */
1019       if (type == error_mark_node || TYPE_SIZE (type) == 0)
1020         args[i].tree_value = integer_zero_node, type = integer_type_node;
1021
1022       /* If TYPE is a transparent union, pass things the way we would
1023          pass the first field of the union.  We have already verified that
1024          the modes are the same.  */
1025       if (TYPE_TRANSPARENT_UNION (type))
1026         type = TREE_TYPE (TYPE_FIELDS (type));
1027
1028       /* Decide where to pass this arg.
1029
1030          args[i].reg is nonzero if all or part is passed in registers.
1031
1032          args[i].partial is nonzero if part but not all is passed in registers,
1033          and the exact value says how many words are passed in registers.
1034
1035          args[i].pass_on_stack is nonzero if the argument must at least be
1036          computed on the stack.  It may then be loaded back into registers
1037          if args[i].reg is nonzero.
1038
1039          These decisions are driven by the FUNCTION_... macros and must agree
1040          with those made by function.c.  */
1041
1042       /* See if this argument should be passed by invisible reference.  */
1043       if ((TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST
1044            && contains_placeholder_p (TYPE_SIZE (type)))
1045           || TREE_ADDRESSABLE (type)
1046 #ifdef FUNCTION_ARG_PASS_BY_REFERENCE
1047           || FUNCTION_ARG_PASS_BY_REFERENCE (args_so_far, TYPE_MODE (type),
1048                                              type, argpos < n_named_args)
1049 #endif
1050           )
1051         {
1052           /* If we're compiling a thunk, pass through invisible
1053              references instead of making a copy.  */
1054           if (current_function_is_thunk
1055 #ifdef FUNCTION_ARG_CALLEE_COPIES
1056               || (FUNCTION_ARG_CALLEE_COPIES (args_so_far, TYPE_MODE (type),
1057                                              type, argpos < n_named_args)
1058                   /* If it's in a register, we must make a copy of it too.  */
1059                   /* ??? Is this a sufficient test?  Is there a better one? */
1060                   && !(TREE_CODE (args[i].tree_value) == VAR_DECL
1061                        && REG_P (DECL_RTL (args[i].tree_value)))
1062                   && ! TREE_ADDRESSABLE (type))
1063 #endif
1064               )
1065             {
1066               args[i].tree_value = build1 (ADDR_EXPR,
1067                                            build_pointer_type (type),
1068                                            args[i].tree_value);
1069               type = build_pointer_type (type);
1070             }
1071           else
1072             {
1073               /* We make a copy of the object and pass the address to the
1074                  function being called.  */
1075               rtx copy;
1076
1077               if (TYPE_SIZE (type) == 0
1078                   || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST
1079                   || (flag_stack_check && ! STACK_CHECK_BUILTIN
1080                       && (TREE_INT_CST_HIGH (TYPE_SIZE (type)) != 0
1081                           || (TREE_INT_CST_LOW (TYPE_SIZE (type))
1082                               > STACK_CHECK_MAX_VAR_SIZE * BITS_PER_UNIT))))
1083                 {
1084                   /* This is a variable-sized object.  Make space on the stack
1085                      for it.  */
1086                   rtx size_rtx = expr_size (TREE_VALUE (p));
1087
1088                   if (old_stack_level == 0)
1089                     {
1090                       emit_stack_save (SAVE_BLOCK, &old_stack_level, NULL_RTX);
1091                       old_pending_adj = pending_stack_adjust;
1092                       pending_stack_adjust = 0;
1093                     }
1094
1095                   copy = gen_rtx_MEM (BLKmode,
1096                                       allocate_dynamic_stack_space (size_rtx,
1097                                                                     NULL_RTX,
1098                                                                     TYPE_ALIGN (type)));
1099                 }
1100               else
1101                 {
1102                   int size = int_size_in_bytes (type);
1103                   copy = assign_stack_temp (TYPE_MODE (type), size, 0);
1104                 }
1105
1106               MEM_IN_STRUCT_P (copy) = AGGREGATE_TYPE_P (type);
1107
1108               store_expr (args[i].tree_value, copy, 0);
1109               is_const = 0;
1110
1111               args[i].tree_value = build1 (ADDR_EXPR,
1112                                            build_pointer_type (type),
1113                                            make_tree (type, copy));
1114               type = build_pointer_type (type);
1115             }
1116         }
1117
1118       mode = TYPE_MODE (type);
1119       unsignedp = TREE_UNSIGNED (type);
1120
1121 #ifdef PROMOTE_FUNCTION_ARGS
1122       mode = promote_mode (type, mode, &unsignedp, 1);
1123 #endif
1124
1125       args[i].unsignedp = unsignedp;
1126       args[i].mode = mode;
1127       args[i].reg = FUNCTION_ARG (args_so_far, mode, type,
1128                                   argpos < n_named_args);
1129 #ifdef FUNCTION_ARG_PARTIAL_NREGS
1130       if (args[i].reg)
1131         args[i].partial
1132           = FUNCTION_ARG_PARTIAL_NREGS (args_so_far, mode, type,
1133                                         argpos < n_named_args);
1134 #endif
1135
1136       args[i].pass_on_stack = MUST_PASS_IN_STACK (mode, type);
1137
1138       /* If FUNCTION_ARG returned a (parallel [(expr_list (nil) ...) ...]),
1139          it means that we are to pass this arg in the register(s) designated
1140          by the PARALLEL, but also to pass it in the stack.  */
1141       if (args[i].reg && GET_CODE (args[i].reg) == PARALLEL
1142           && XEXP (XVECEXP (args[i].reg, 0, 0), 0) == 0)
1143         args[i].pass_on_stack = 1;
1144
1145       /* If this is an addressable type, we must preallocate the stack
1146          since we must evaluate the object into its final location.
1147
1148          If this is to be passed in both registers and the stack, it is simpler
1149          to preallocate.  */
1150       if (TREE_ADDRESSABLE (type)
1151           || (args[i].pass_on_stack && args[i].reg != 0))
1152         must_preallocate = 1;
1153
1154       /* If this is an addressable type, we cannot pre-evaluate it.  Thus,
1155          we cannot consider this function call constant.  */
1156       if (TREE_ADDRESSABLE (type))
1157         is_const = 0;
1158
1159       /* Compute the stack-size of this argument.  */
1160       if (args[i].reg == 0 || args[i].partial != 0
1161 #ifdef REG_PARM_STACK_SPACE
1162           || reg_parm_stack_space > 0
1163 #endif
1164           || args[i].pass_on_stack)
1165         locate_and_pad_parm (mode, type,
1166 #ifdef STACK_PARMS_IN_REG_PARM_AREA
1167                              1,
1168 #else
1169                              args[i].reg != 0,
1170 #endif
1171                              fndecl, &args_size, &args[i].offset,
1172                              &args[i].size);
1173
1174 #ifndef ARGS_GROW_DOWNWARD
1175       args[i].slot_offset = args_size;
1176 #endif
1177
1178 #ifndef REG_PARM_STACK_SPACE
1179       /* If a part of the arg was put into registers,
1180          don't include that part in the amount pushed.  */
1181       if (! args[i].pass_on_stack)
1182         args[i].size.constant -= ((args[i].partial * UNITS_PER_WORD)
1183                                   / (PARM_BOUNDARY / BITS_PER_UNIT)
1184                                   * (PARM_BOUNDARY / BITS_PER_UNIT));
1185 #endif
1186       
1187       /* Update ARGS_SIZE, the total stack space for args so far.  */
1188
1189       args_size.constant += args[i].size.constant;
1190       if (args[i].size.var)
1191         {
1192           ADD_PARM_SIZE (args_size, args[i].size.var);
1193         }
1194
1195       /* Since the slot offset points to the bottom of the slot,
1196          we must record it after incrementing if the args grow down.  */
1197 #ifdef ARGS_GROW_DOWNWARD
1198       args[i].slot_offset = args_size;
1199
1200       args[i].slot_offset.constant = -args_size.constant;
1201       if (args_size.var)
1202         {
1203           SUB_PARM_SIZE (args[i].slot_offset, args_size.var);
1204         }
1205 #endif
1206
1207       /* Increment ARGS_SO_FAR, which has info about which arg-registers
1208          have been used, etc.  */
1209
1210       FUNCTION_ARG_ADVANCE (args_so_far, TYPE_MODE (type), type,
1211                             argpos < n_named_args);
1212     }
1213
1214 #ifdef FINAL_REG_PARM_STACK_SPACE
1215   reg_parm_stack_space = FINAL_REG_PARM_STACK_SPACE (args_size.constant,
1216                                                      args_size.var);
1217 #endif
1218       
1219   /* Compute the actual size of the argument block required.  The variable
1220      and constant sizes must be combined, the size may have to be rounded,
1221      and there may be a minimum required size.  */
1222
1223   original_args_size = args_size;
1224   if (args_size.var)
1225     {
1226       /* If this function requires a variable-sized argument list, don't try to
1227          make a cse'able block for this call.  We may be able to do this
1228          eventually, but it is too complicated to keep track of what insns go
1229          in the cse'able block and which don't.  */
1230
1231       is_const = 0;
1232       must_preallocate = 1;
1233
1234       args_size.var = ARGS_SIZE_TREE (args_size);
1235       args_size.constant = 0;
1236
1237 #ifdef STACK_BOUNDARY
1238       if (STACK_BOUNDARY != BITS_PER_UNIT)
1239         args_size.var = round_up (args_size.var, STACK_BYTES);
1240 #endif
1241
1242 #ifdef REG_PARM_STACK_SPACE
1243       if (reg_parm_stack_space > 0)
1244         {
1245           args_size.var
1246             = size_binop (MAX_EXPR, args_size.var,
1247                           size_int (REG_PARM_STACK_SPACE (fndecl)));
1248
1249 #ifndef OUTGOING_REG_PARM_STACK_SPACE
1250           /* The area corresponding to register parameters is not to count in
1251              the size of the block we need.  So make the adjustment.  */
1252           args_size.var
1253             = size_binop (MINUS_EXPR, args_size.var,
1254                           size_int (reg_parm_stack_space));
1255 #endif
1256         }
1257 #endif
1258     }
1259   else
1260     {
1261 #ifdef STACK_BOUNDARY
1262       args_size.constant = (((args_size.constant + (STACK_BYTES - 1))
1263                              / STACK_BYTES) * STACK_BYTES);
1264 #endif
1265
1266 #ifdef REG_PARM_STACK_SPACE
1267       args_size.constant = MAX (args_size.constant,
1268                                 reg_parm_stack_space);
1269 #ifdef MAYBE_REG_PARM_STACK_SPACE
1270       if (reg_parm_stack_space == 0)
1271         args_size.constant = 0;
1272 #endif
1273 #ifndef OUTGOING_REG_PARM_STACK_SPACE
1274       args_size.constant -= reg_parm_stack_space;
1275 #endif
1276 #endif
1277     }
1278
1279   /* See if we have or want to preallocate stack space.
1280
1281      If we would have to push a partially-in-regs parm
1282      before other stack parms, preallocate stack space instead.
1283
1284      If the size of some parm is not a multiple of the required stack
1285      alignment, we must preallocate.
1286
1287      If the total size of arguments that would otherwise create a copy in
1288      a temporary (such as a CALL) is more than half the total argument list
1289      size, preallocation is faster.
1290
1291      Another reason to preallocate is if we have a machine (like the m88k)
1292      where stack alignment is required to be maintained between every
1293      pair of insns, not just when the call is made.  However, we assume here
1294      that such machines either do not have push insns (and hence preallocation
1295      would occur anyway) or the problem is taken care of with
1296      PUSH_ROUNDING.  */
1297
1298   if (! must_preallocate)
1299     {
1300       int partial_seen = 0;
1301       int copy_to_evaluate_size = 0;
1302
1303       for (i = 0; i < num_actuals && ! must_preallocate; i++)
1304         {
1305           if (args[i].partial > 0 && ! args[i].pass_on_stack)
1306             partial_seen = 1;
1307           else if (partial_seen && args[i].reg == 0)
1308             must_preallocate = 1;
1309
1310           if (TYPE_MODE (TREE_TYPE (args[i].tree_value)) == BLKmode
1311               && (TREE_CODE (args[i].tree_value) == CALL_EXPR
1312                   || TREE_CODE (args[i].tree_value) == TARGET_EXPR
1313                   || TREE_CODE (args[i].tree_value) == COND_EXPR
1314                   || TREE_ADDRESSABLE (TREE_TYPE (args[i].tree_value))))
1315             copy_to_evaluate_size
1316               += int_size_in_bytes (TREE_TYPE (args[i].tree_value));
1317         }
1318
1319       if (copy_to_evaluate_size * 2 >= args_size.constant
1320           && args_size.constant > 0)
1321         must_preallocate = 1;
1322     }
1323
1324   /* If the structure value address will reference the stack pointer, we must
1325      stabilize it.  We don't need to do this if we know that we are not going
1326      to adjust the stack pointer in processing this call.  */
1327
1328   if (structure_value_addr
1329       && (reg_mentioned_p (virtual_stack_dynamic_rtx, structure_value_addr)
1330        || reg_mentioned_p (virtual_outgoing_args_rtx, structure_value_addr))
1331       && (args_size.var
1332 #ifndef ACCUMULATE_OUTGOING_ARGS
1333           || args_size.constant
1334 #endif
1335           ))
1336     structure_value_addr = copy_to_reg (structure_value_addr);
1337
1338   /* If this function call is cse'able, precompute all the parameters.
1339      Note that if the parameter is constructed into a temporary, this will
1340      cause an additional copy because the parameter will be constructed
1341      into a temporary location and then copied into the outgoing arguments.
1342      If a parameter contains a call to alloca and this function uses the
1343      stack, precompute the parameter.  */
1344
1345   /* If we preallocated the stack space, and some arguments must be passed
1346      on the stack, then we must precompute any parameter which contains a
1347      function call which will store arguments on the stack.
1348      Otherwise, evaluating the parameter may clobber previous parameters
1349      which have already been stored into the stack.  */
1350
1351   for (i = 0; i < num_actuals; i++)
1352     if (is_const
1353         || ((args_size.var != 0 || args_size.constant != 0)
1354             && calls_function (args[i].tree_value, 1))
1355         || (must_preallocate && (args_size.var != 0 || args_size.constant != 0)
1356             && calls_function (args[i].tree_value, 0)))
1357       {
1358         /* If this is an addressable type, we cannot pre-evaluate it.  */
1359         if (TREE_ADDRESSABLE (TREE_TYPE (args[i].tree_value)))
1360           abort ();
1361
1362         push_temp_slots ();
1363
1364         args[i].initial_value = args[i].value
1365           = expand_expr (args[i].tree_value, NULL_RTX, VOIDmode, 0);
1366
1367         preserve_temp_slots (args[i].value);
1368         pop_temp_slots ();
1369
1370         /* ANSI doesn't require a sequence point here,
1371            but PCC has one, so this will avoid some problems.  */
1372         emit_queue ();
1373
1374         args[i].initial_value = args[i].value
1375           = protect_from_queue (args[i].initial_value, 0);
1376
1377         if (TYPE_MODE (TREE_TYPE (args[i].tree_value)) != args[i].mode)
1378           args[i].value
1379             = convert_modes (args[i].mode, 
1380                              TYPE_MODE (TREE_TYPE (args[i].tree_value)),
1381                              args[i].value, args[i].unsignedp);
1382       }
1383
1384   /* Now we are about to start emitting insns that can be deleted
1385      if a libcall is deleted.  */
1386   if (is_const || is_malloc)
1387     start_sequence ();
1388
1389   /* If we have no actual push instructions, or shouldn't use them,
1390      make space for all args right now.  */
1391
1392   if (args_size.var != 0)
1393     {
1394       if (old_stack_level == 0)
1395         {
1396           emit_stack_save (SAVE_BLOCK, &old_stack_level, NULL_RTX);
1397           old_pending_adj = pending_stack_adjust;
1398           pending_stack_adjust = 0;
1399 #ifdef ACCUMULATE_OUTGOING_ARGS
1400           /* stack_arg_under_construction says whether a stack arg is
1401              being constructed at the old stack level.  Pushing the stack
1402              gets a clean outgoing argument block.  */
1403           old_stack_arg_under_construction = stack_arg_under_construction;
1404           stack_arg_under_construction = 0;
1405 #endif
1406         }
1407       argblock = push_block (ARGS_SIZE_RTX (args_size), 0, 0);
1408     }
1409   else
1410     {
1411       /* Note that we must go through the motions of allocating an argument
1412          block even if the size is zero because we may be storing args
1413          in the area reserved for register arguments, which may be part of
1414          the stack frame.  */
1415
1416       int needed = args_size.constant;
1417
1418       /* Store the maximum argument space used.  It will be pushed by
1419          the prologue (if ACCUMULATE_OUTGOING_ARGS, or stack overflow
1420          checking).  */
1421
1422       if (needed > current_function_outgoing_args_size)
1423         current_function_outgoing_args_size = needed;
1424
1425       if (must_preallocate)
1426         {
1427 #ifdef ACCUMULATE_OUTGOING_ARGS
1428           /* Since the stack pointer will never be pushed, it is possible for
1429              the evaluation of a parm to clobber something we have already
1430              written to the stack.  Since most function calls on RISC machines
1431              do not use the stack, this is uncommon, but must work correctly.
1432
1433              Therefore, we save any area of the stack that was already written
1434              and that we are using.  Here we set up to do this by making a new
1435              stack usage map from the old one.  The actual save will be done
1436              by store_one_arg. 
1437
1438              Another approach might be to try to reorder the argument
1439              evaluations to avoid this conflicting stack usage.  */
1440
1441 #if defined(REG_PARM_STACK_SPACE) && ! defined(OUTGOING_REG_PARM_STACK_SPACE)
1442           /* Since we will be writing into the entire argument area, the
1443              map must be allocated for its entire size, not just the part that
1444              is the responsibility of the caller.  */
1445           needed += reg_parm_stack_space;
1446 #endif
1447
1448 #ifdef ARGS_GROW_DOWNWARD
1449           highest_outgoing_arg_in_use = MAX (initial_highest_arg_in_use,
1450                                              needed + 1);
1451 #else
1452           highest_outgoing_arg_in_use = MAX (initial_highest_arg_in_use,
1453                                              needed);
1454 #endif
1455           stack_usage_map = (char *) alloca (highest_outgoing_arg_in_use);
1456
1457           if (initial_highest_arg_in_use)
1458             bcopy (initial_stack_usage_map, stack_usage_map,
1459                    initial_highest_arg_in_use);
1460
1461           if (initial_highest_arg_in_use != highest_outgoing_arg_in_use)
1462             bzero (&stack_usage_map[initial_highest_arg_in_use],
1463                    highest_outgoing_arg_in_use - initial_highest_arg_in_use);
1464           needed = 0;
1465
1466           /* The address of the outgoing argument list must not be copied to a
1467              register here, because argblock would be left pointing to the
1468              wrong place after the call to allocate_dynamic_stack_space below.
1469              */
1470
1471           argblock = virtual_outgoing_args_rtx;
1472
1473 #else /* not ACCUMULATE_OUTGOING_ARGS */
1474           if (inhibit_defer_pop == 0)
1475             {
1476               /* Try to reuse some or all of the pending_stack_adjust
1477                  to get this space.  Maybe we can avoid any pushing.  */
1478               if (needed > pending_stack_adjust)
1479                 {
1480                   needed -= pending_stack_adjust;
1481                   pending_stack_adjust = 0;
1482                 }
1483               else
1484                 {
1485                   pending_stack_adjust -= needed;
1486                   needed = 0;
1487                 }
1488             }
1489           /* Special case this because overhead of `push_block' in this
1490              case is non-trivial.  */
1491           if (needed == 0)
1492             argblock = virtual_outgoing_args_rtx;
1493           else
1494             argblock = push_block (GEN_INT (needed), 0, 0);
1495
1496           /* We only really need to call `copy_to_reg' in the case where push
1497              insns are going to be used to pass ARGBLOCK to a function
1498              call in ARGS.  In that case, the stack pointer changes value
1499              from the allocation point to the call point, and hence
1500              the value of VIRTUAL_OUTGOING_ARGS_RTX changes as well.
1501              But might as well always do it.  */
1502           argblock = copy_to_reg (argblock);
1503 #endif /* not ACCUMULATE_OUTGOING_ARGS */
1504         }
1505     }
1506
1507 #ifdef ACCUMULATE_OUTGOING_ARGS
1508   /* The save/restore code in store_one_arg handles all cases except one:
1509      a constructor call (including a C function returning a BLKmode struct)
1510      to initialize an argument.  */
1511   if (stack_arg_under_construction)
1512     {
1513 #if defined(REG_PARM_STACK_SPACE) && ! defined(OUTGOING_REG_PARM_STACK_SPACE)
1514       rtx push_size = GEN_INT (reg_parm_stack_space + args_size.constant);
1515 #else
1516       rtx push_size = GEN_INT (args_size.constant);
1517 #endif
1518       if (old_stack_level == 0)
1519         {
1520           emit_stack_save (SAVE_BLOCK, &old_stack_level, NULL_RTX);
1521           old_pending_adj = pending_stack_adjust;
1522           pending_stack_adjust = 0;
1523           /* stack_arg_under_construction says whether a stack arg is
1524              being constructed at the old stack level.  Pushing the stack
1525              gets a clean outgoing argument block.  */
1526           old_stack_arg_under_construction = stack_arg_under_construction;
1527           stack_arg_under_construction = 0;
1528           /* Make a new map for the new argument list.  */
1529           stack_usage_map = (char *)alloca (highest_outgoing_arg_in_use);
1530           bzero (stack_usage_map, highest_outgoing_arg_in_use);
1531           highest_outgoing_arg_in_use = 0;
1532         }
1533       allocate_dynamic_stack_space (push_size, NULL_RTX, BITS_PER_UNIT);
1534     }
1535   /* If argument evaluation might modify the stack pointer, copy the
1536      address of the argument list to a register.  */
1537   for (i = 0; i < num_actuals; i++)
1538     if (args[i].pass_on_stack)
1539       {
1540         argblock = copy_addr_to_reg (argblock);
1541         break;
1542       }
1543 #endif
1544
1545
1546   /* If we preallocated stack space, compute the address of each argument.
1547      We need not ensure it is a valid memory address here; it will be 
1548      validized when it is used.  */
1549   if (argblock)
1550     {
1551       rtx arg_reg = argblock;
1552       int arg_offset = 0;
1553
1554       if (GET_CODE (argblock) == PLUS)
1555         arg_reg = XEXP (argblock, 0), arg_offset = INTVAL (XEXP (argblock, 1));
1556
1557       for (i = 0; i < num_actuals; i++)
1558         {
1559           rtx offset = ARGS_SIZE_RTX (args[i].offset);
1560           rtx slot_offset = ARGS_SIZE_RTX (args[i].slot_offset);
1561           rtx addr;
1562
1563           /* Skip this parm if it will not be passed on the stack.  */
1564           if (! args[i].pass_on_stack && args[i].reg != 0)
1565             continue;
1566
1567           if (GET_CODE (offset) == CONST_INT)
1568             addr = plus_constant (arg_reg, INTVAL (offset));
1569           else
1570             addr = gen_rtx_PLUS (Pmode, arg_reg, offset);
1571
1572           addr = plus_constant (addr, arg_offset);
1573           args[i].stack = gen_rtx_MEM (args[i].mode, addr);
1574           MEM_IN_STRUCT_P (args[i].stack)
1575             = AGGREGATE_TYPE_P (TREE_TYPE (args[i].tree_value));
1576
1577           if (GET_CODE (slot_offset) == CONST_INT)
1578             addr = plus_constant (arg_reg, INTVAL (slot_offset));
1579           else
1580             addr = gen_rtx_PLUS (Pmode, arg_reg, slot_offset);
1581
1582           addr = plus_constant (addr, arg_offset);
1583           args[i].stack_slot = gen_rtx_MEM (args[i].mode, addr);
1584         }
1585     }
1586                                                
1587 #ifdef PUSH_ARGS_REVERSED
1588 #ifdef STACK_BOUNDARY
1589   /* If we push args individually in reverse order, perform stack alignment
1590      before the first push (the last arg).  */
1591   if (argblock == 0)
1592     anti_adjust_stack (GEN_INT (args_size.constant
1593                                 - original_args_size.constant));
1594 #endif
1595 #endif
1596
1597   /* Don't try to defer pops if preallocating, not even from the first arg,
1598      since ARGBLOCK probably refers to the SP.  */
1599   if (argblock)
1600     NO_DEFER_POP;
1601
1602   /* Get the function to call, in the form of RTL.  */
1603   if (fndecl)
1604     {
1605       /* If this is the first use of the function, see if we need to
1606          make an external definition for it.  */
1607       if (! TREE_USED (fndecl))
1608         {
1609           assemble_external (fndecl);
1610           TREE_USED (fndecl) = 1;
1611         }
1612
1613       /* Get a SYMBOL_REF rtx for the function address.  */
1614       funexp = XEXP (DECL_RTL (fndecl), 0);
1615     }
1616   else
1617     /* Generate an rtx (probably a pseudo-register) for the address.  */
1618     {
1619       push_temp_slots ();
1620       funexp = expand_expr (TREE_OPERAND (exp, 0), NULL_RTX, VOIDmode, 0);
1621       pop_temp_slots ();        /* FUNEXP can't be BLKmode */
1622
1623       /* Check the function is executable.  */
1624       if (flag_check_memory_usage)
1625         emit_library_call (chkr_check_exec_libfunc, 1,
1626                            VOIDmode, 1,
1627                            funexp, ptr_mode);
1628       emit_queue ();
1629     }
1630
1631   /* Figure out the register where the value, if any, will come back.  */
1632   valreg = 0;
1633   if (TYPE_MODE (TREE_TYPE (exp)) != VOIDmode
1634       && ! structure_value_addr)
1635     {
1636       if (pcc_struct_value)
1637         valreg = hard_function_value (build_pointer_type (TREE_TYPE (exp)),
1638                                       fndecl);
1639       else
1640         valreg = hard_function_value (TREE_TYPE (exp), fndecl);
1641     }
1642
1643   /* Precompute all register parameters.  It isn't safe to compute anything
1644      once we have started filling any specific hard regs.  */
1645   reg_parm_seen = 0;
1646   for (i = 0; i < num_actuals; i++)
1647     if (args[i].reg != 0 && ! args[i].pass_on_stack)
1648       {
1649         reg_parm_seen = 1;
1650
1651         if (args[i].value == 0)
1652           {
1653             push_temp_slots ();
1654             args[i].value = expand_expr (args[i].tree_value, NULL_RTX,
1655                                          VOIDmode, 0);
1656             preserve_temp_slots (args[i].value);
1657             pop_temp_slots ();
1658
1659             /* ANSI doesn't require a sequence point here,
1660                but PCC has one, so this will avoid some problems.  */
1661             emit_queue ();
1662           }
1663
1664         /* If we are to promote the function arg to a wider mode,
1665            do it now.  */
1666
1667         if (args[i].mode != TYPE_MODE (TREE_TYPE (args[i].tree_value)))
1668           args[i].value
1669             = convert_modes (args[i].mode,
1670                              TYPE_MODE (TREE_TYPE (args[i].tree_value)),
1671                              args[i].value, args[i].unsignedp);
1672
1673         /* If the value is expensive, and we are inside an appropriately 
1674            short loop, put the value into a pseudo and then put the pseudo
1675            into the hard reg.
1676
1677            For small register classes, also do this if this call uses
1678            register parameters.  This is to avoid reload conflicts while
1679            loading the parameters registers.  */
1680
1681         if ((! (GET_CODE (args[i].value) == REG
1682                 || (GET_CODE (args[i].value) == SUBREG
1683                     && GET_CODE (SUBREG_REG (args[i].value)) == REG)))
1684             && args[i].mode != BLKmode
1685             && rtx_cost (args[i].value, SET) > 2
1686             && ((SMALL_REGISTER_CLASSES && reg_parm_seen)
1687                 || preserve_subexpressions_p ()))
1688           args[i].value = copy_to_mode_reg (args[i].mode, args[i].value);
1689       }
1690
1691 #if defined(ACCUMULATE_OUTGOING_ARGS) && defined(REG_PARM_STACK_SPACE)
1692   /* The argument list is the property of the called routine and it
1693      may clobber it.  If the fixed area has been used for previous
1694      parameters, we must save and restore it.
1695
1696      Here we compute the boundary of the that needs to be saved, if any.  */
1697
1698 #ifdef ARGS_GROW_DOWNWARD
1699   for (i = 0; i < reg_parm_stack_space + 1; i++)
1700 #else
1701   for (i = 0; i < reg_parm_stack_space; i++)
1702 #endif
1703     {
1704       if (i >=  highest_outgoing_arg_in_use
1705           || stack_usage_map[i] == 0)
1706         continue;
1707
1708       if (low_to_save == -1)
1709         low_to_save = i;
1710
1711       high_to_save = i;
1712     }
1713
1714   if (low_to_save >= 0)
1715     {
1716       int num_to_save = high_to_save - low_to_save + 1;
1717       enum machine_mode save_mode
1718         = mode_for_size (num_to_save * BITS_PER_UNIT, MODE_INT, 1);
1719       rtx stack_area;
1720
1721       /* If we don't have the required alignment, must do this in BLKmode.  */
1722       if ((low_to_save & (MIN (GET_MODE_SIZE (save_mode),
1723                                BIGGEST_ALIGNMENT / UNITS_PER_WORD) - 1)))
1724         save_mode = BLKmode;
1725
1726       stack_area = gen_rtx_MEM (save_mode,
1727                                 memory_address (save_mode,
1728                                             
1729 #ifdef ARGS_GROW_DOWNWARD
1730                                                 plus_constant (argblock,
1731                                                                - high_to_save)
1732 #else
1733                                                 plus_constant (argblock,
1734                                                                low_to_save)
1735 #endif
1736                                                 ));
1737       if (save_mode == BLKmode)
1738         {
1739           save_area = assign_stack_temp (BLKmode, num_to_save, 0);
1740           MEM_IN_STRUCT_P (save_area) = 0;
1741           emit_block_move (validize_mem (save_area), stack_area,
1742                            GEN_INT (num_to_save),
1743                            PARM_BOUNDARY / BITS_PER_UNIT);
1744         }
1745       else
1746         {
1747           save_area = gen_reg_rtx (save_mode);
1748           emit_move_insn (save_area, stack_area);
1749         }
1750     }
1751 #endif
1752           
1753
1754   /* Now store (and compute if necessary) all non-register parms.
1755      These come before register parms, since they can require block-moves,
1756      which could clobber the registers used for register parms.
1757      Parms which have partial registers are not stored here,
1758      but we do preallocate space here if they want that.  */
1759
1760   for (i = 0; i < num_actuals; i++)
1761     if (args[i].reg == 0 || args[i].pass_on_stack)
1762       store_one_arg (&args[i], argblock, may_be_alloca,
1763                      args_size.var != 0, fndecl, reg_parm_stack_space);
1764
1765   /* If we have a parm that is passed in registers but not in memory
1766      and whose alignment does not permit a direct copy into registers,
1767      make a group of pseudos that correspond to each register that we
1768      will later fill.  */
1769
1770   if (STRICT_ALIGNMENT)
1771     for (i = 0; i < num_actuals; i++)
1772       if (args[i].reg != 0 && ! args[i].pass_on_stack
1773         && args[i].mode == BLKmode
1774           && (TYPE_ALIGN (TREE_TYPE (args[i].tree_value))
1775               < MIN (BIGGEST_ALIGNMENT, BITS_PER_WORD)))
1776         {
1777           int bytes = int_size_in_bytes (TREE_TYPE (args[i].tree_value));
1778           int big_endian_correction = 0;
1779
1780           args[i].n_aligned_regs
1781             = args[i].partial ? args[i].partial
1782               : (bytes + (UNITS_PER_WORD - 1)) / UNITS_PER_WORD;
1783
1784           args[i].aligned_regs = (rtx *) alloca (sizeof (rtx)
1785                                                  * args[i].n_aligned_regs);
1786
1787           /* Structures smaller than a word are aligned to the least
1788              significant byte (to the right).  On a BYTES_BIG_ENDIAN machine,
1789              this means we must skip the empty high order bytes when
1790              calculating the bit offset.  */
1791           if (BYTES_BIG_ENDIAN && bytes < UNITS_PER_WORD)
1792             big_endian_correction = (BITS_PER_WORD  - (bytes * BITS_PER_UNIT));
1793
1794           for (j = 0; j < args[i].n_aligned_regs; j++)
1795             {
1796               rtx reg = gen_reg_rtx (word_mode);
1797               rtx word = operand_subword_force (args[i].value, j, BLKmode);
1798               int bitsize = TYPE_ALIGN (TREE_TYPE (args[i].tree_value));
1799               int bitpos;
1800
1801               args[i].aligned_regs[j] = reg;
1802
1803               /* Clobber REG and move each partword into it.  Ensure we don't
1804                  go past the end of the structure.  Note that the loop below
1805                  works because we've already verified that padding
1806                  and endianness are compatible.
1807
1808                  We use to emit a clobber here but that doesn't let later
1809                  passes optimize the instructions we emit.  By storing 0 into
1810                  the register later passes know the first AND to zero out the
1811                  bitfield being set in the register is unnecessary.  The store
1812                  of 0 will be deleted as will at least the first AND.  */
1813
1814               emit_move_insn (reg, const0_rtx);
1815
1816               for (bitpos = 0;
1817                    bitpos < BITS_PER_WORD && bytes > 0;
1818                    bitpos += bitsize, bytes -= bitsize / BITS_PER_UNIT)
1819                 {
1820                   int xbitpos = bitpos + big_endian_correction;
1821
1822                   store_bit_field (reg, bitsize, xbitpos, word_mode,
1823                                    extract_bit_field (word, bitsize, bitpos, 1,
1824                                                       NULL_RTX, word_mode,
1825                                                       word_mode,
1826                                                       bitsize / BITS_PER_UNIT,
1827                                                       BITS_PER_WORD),
1828                                    bitsize / BITS_PER_UNIT, BITS_PER_WORD);
1829                 }
1830             }
1831         }
1832
1833   /* Now store any partially-in-registers parm.
1834      This is the last place a block-move can happen.  */
1835   if (reg_parm_seen)
1836     for (i = 0; i < num_actuals; i++)
1837       if (args[i].partial != 0 && ! args[i].pass_on_stack)
1838         store_one_arg (&args[i], argblock, may_be_alloca,
1839                        args_size.var != 0, fndecl, reg_parm_stack_space);
1840
1841 #ifndef PUSH_ARGS_REVERSED
1842 #ifdef STACK_BOUNDARY
1843   /* If we pushed args in forward order, perform stack alignment
1844      after pushing the last arg.  */
1845   if (argblock == 0)
1846     anti_adjust_stack (GEN_INT (args_size.constant
1847                                 - original_args_size.constant));
1848 #endif
1849 #endif
1850
1851   /* If register arguments require space on the stack and stack space
1852      was not preallocated, allocate stack space here for arguments
1853      passed in registers.  */
1854 #if ! defined(ACCUMULATE_OUTGOING_ARGS) && defined(OUTGOING_REG_PARM_STACK_SPACE)
1855   if (must_preallocate == 0 && reg_parm_stack_space > 0)
1856     anti_adjust_stack (GEN_INT (reg_parm_stack_space));
1857 #endif
1858
1859   /* Pass the function the address in which to return a structure value.  */
1860   if (structure_value_addr && ! structure_value_addr_parm)
1861     {
1862       emit_move_insn (struct_value_rtx,
1863                       force_reg (Pmode,
1864                                  force_operand (structure_value_addr,
1865                                                 NULL_RTX)));
1866
1867       /* Mark the memory for the aggregate as write-only.  */
1868       if (flag_check_memory_usage)
1869         emit_library_call (chkr_set_right_libfunc, 1,
1870                            VOIDmode, 3,
1871                            structure_value_addr, ptr_mode, 
1872                            GEN_INT (struct_value_size), TYPE_MODE (sizetype),
1873                            GEN_INT (MEMORY_USE_WO),
1874                            TYPE_MODE (integer_type_node));
1875
1876       if (GET_CODE (struct_value_rtx) == REG)
1877           use_reg (&call_fusage, struct_value_rtx);
1878     }
1879
1880   funexp = prepare_call_address (funexp, fndecl, &call_fusage, reg_parm_seen);
1881
1882   /* Now do the register loads required for any wholly-register parms or any
1883      parms which are passed both on the stack and in a register.  Their
1884      expressions were already evaluated. 
1885
1886      Mark all register-parms as living through the call, putting these USE
1887      insns in the CALL_INSN_FUNCTION_USAGE field.  */
1888
1889 #ifdef LOAD_ARGS_REVERSED
1890   for (i = num_actuals - 1; i >= 0; i--)
1891 #else
1892   for (i = 0; i < num_actuals; i++)
1893 #endif
1894     {
1895       rtx reg = args[i].reg;
1896       int partial = args[i].partial;
1897       int nregs;
1898
1899       if (reg)
1900         {
1901           /* Set to non-negative if must move a word at a time, even if just
1902              one word (e.g, partial == 1 && mode == DFmode).  Set to -1 if
1903              we just use a normal move insn.  This value can be zero if the
1904              argument is a zero size structure with no fields.  */
1905           nregs = (partial ? partial
1906                    : (TYPE_MODE (TREE_TYPE (args[i].tree_value)) == BLKmode
1907                       ? ((int_size_in_bytes (TREE_TYPE (args[i].tree_value))
1908                           + (UNITS_PER_WORD - 1)) / UNITS_PER_WORD)
1909                       : -1));
1910
1911           /* Handle calls that pass values in multiple non-contiguous
1912              locations.  The Irix 6 ABI has examples of this.  */
1913
1914           if (GET_CODE (reg) == PARALLEL)
1915             emit_group_load (reg, args[i].value);
1916
1917           /* If simple case, just do move.  If normal partial, store_one_arg
1918              has already loaded the register for us.  In all other cases,
1919              load the register(s) from memory.  */
1920
1921           else if (nregs == -1)
1922             emit_move_insn (reg, args[i].value);
1923
1924           /* If we have pre-computed the values to put in the registers in
1925              the case of non-aligned structures, copy them in now.  */
1926
1927           else if (args[i].n_aligned_regs != 0)
1928             for (j = 0; j < args[i].n_aligned_regs; j++)
1929               emit_move_insn (gen_rtx_REG (word_mode, REGNO (reg) + j),
1930                               args[i].aligned_regs[j]);
1931
1932           else if (partial == 0 || args[i].pass_on_stack)
1933             move_block_to_reg (REGNO (reg),
1934                                validize_mem (args[i].value), nregs,
1935                                args[i].mode);
1936
1937           /* Handle calls that pass values in multiple non-contiguous
1938              locations.  The Irix 6 ABI has examples of this.  */
1939           if (GET_CODE (reg) == PARALLEL)
1940             use_group_regs (&call_fusage, reg);
1941           else if (nregs == -1)
1942             use_reg (&call_fusage, reg);
1943           else
1944             use_regs (&call_fusage, REGNO (reg), nregs == 0 ? 1 : nregs);
1945         }
1946     }
1947
1948   /* Perform postincrements before actually calling the function.  */
1949   emit_queue ();
1950
1951   /* All arguments and registers used for the call must be set up by now!  */
1952
1953   /* Generate the actual call instruction.  */
1954   emit_call_1 (funexp, fndecl, funtype, args_size.constant, struct_value_size,
1955                FUNCTION_ARG (args_so_far, VOIDmode, void_type_node, 1),
1956                valreg, old_inhibit_defer_pop, call_fusage, is_const);
1957
1958   /* If call is cse'able, make appropriate pair of reg-notes around it.
1959      Test valreg so we don't crash; may safely ignore `const'
1960      if return type is void.  Disable for PARALLEL return values, because
1961      we have no way to move such values into a pseudo register.  */
1962   if (is_const && valreg != 0 && GET_CODE (valreg) != PARALLEL)
1963     {
1964       rtx note = 0;
1965       rtx temp = gen_reg_rtx (GET_MODE (valreg));
1966       rtx insns;
1967
1968       /* Mark the return value as a pointer if needed.  */
1969       if (TREE_CODE (TREE_TYPE (exp)) == POINTER_TYPE)
1970         {
1971           tree pointed_to = TREE_TYPE (TREE_TYPE (exp));
1972           mark_reg_pointer (temp, TYPE_ALIGN (pointed_to) / BITS_PER_UNIT);
1973         }
1974
1975       /* Construct an "equal form" for the value which mentions all the
1976          arguments in order as well as the function name.  */
1977 #ifdef PUSH_ARGS_REVERSED
1978       for (i = 0; i < num_actuals; i++)
1979         note = gen_rtx_EXPR_LIST (VOIDmode, args[i].initial_value, note);
1980 #else
1981       for (i = num_actuals - 1; i >= 0; i--)
1982         note = gen_rtx_EXPR_LIST (VOIDmode, args[i].initial_value, note);
1983 #endif
1984       note = gen_rtx_EXPR_LIST (VOIDmode, funexp, note);
1985
1986       insns = get_insns ();
1987       end_sequence ();
1988
1989       emit_libcall_block (insns, temp, valreg, note);
1990
1991       valreg = temp;
1992     }
1993   else if (is_const)
1994     {
1995       /* Otherwise, just write out the sequence without a note.  */
1996       rtx insns = get_insns ();
1997
1998       end_sequence ();
1999       emit_insns (insns);
2000     }
2001   else if (is_malloc)
2002     {
2003       rtx temp = gen_reg_rtx (GET_MODE (valreg));
2004       rtx last, insns;
2005
2006       /* The return value from a malloc-like function is a pointer. */
2007       if (TREE_CODE (TREE_TYPE (exp)) == POINTER_TYPE)
2008         mark_reg_pointer (temp, BIGGEST_ALIGNMENT / BITS_PER_UNIT);
2009
2010       emit_move_insn (temp, valreg);
2011
2012       /* The return value from a malloc-like function can not alias
2013          anything else.  */
2014       last = get_last_insn ();
2015       REG_NOTES (last) = 
2016         gen_rtx_EXPR_LIST (REG_NOALIAS, temp, REG_NOTES (last));
2017
2018       /* Write out the sequence.  */
2019       insns = get_insns ();
2020       end_sequence ();
2021       emit_insns (insns);
2022       valreg = temp;
2023     }
2024
2025   /* For calls to `setjmp', etc., inform flow.c it should complain
2026      if nonvolatile values are live.  */
2027
2028   if (returns_twice)
2029     {
2030       emit_note (name, NOTE_INSN_SETJMP);
2031       current_function_calls_setjmp = 1;
2032     }
2033
2034   if (is_longjmp)
2035     current_function_calls_longjmp = 1;
2036
2037   /* Notice functions that cannot return.
2038      If optimizing, insns emitted below will be dead.
2039      If not optimizing, they will exist, which is useful
2040      if the user uses the `return' command in the debugger.  */
2041
2042   if (is_volatile || is_longjmp)
2043     emit_barrier ();
2044
2045   /* If value type not void, return an rtx for the value.  */
2046
2047   /* If there are cleanups to be called, don't use a hard reg as target.
2048      We need to double check this and see if it matters anymore.  */
2049   if (any_pending_cleanups (1)
2050       && target && REG_P (target)
2051       && REGNO (target) < FIRST_PSEUDO_REGISTER)
2052     target = 0;
2053
2054   if (TYPE_MODE (TREE_TYPE (exp)) == VOIDmode
2055       || ignore)
2056     {
2057       target = const0_rtx;
2058     }
2059   else if (structure_value_addr)
2060     {
2061       if (target == 0 || GET_CODE (target) != MEM)
2062         {
2063           target = gen_rtx_MEM (TYPE_MODE (TREE_TYPE (exp)),
2064                                 memory_address (TYPE_MODE (TREE_TYPE (exp)),
2065                                                 structure_value_addr));
2066           MEM_IN_STRUCT_P (target) = AGGREGATE_TYPE_P (TREE_TYPE (exp));
2067         }
2068     }
2069   else if (pcc_struct_value)
2070     {
2071       /* This is the special C++ case where we need to
2072          know what the true target was.  We take care to
2073          never use this value more than once in one expression.  */
2074       target = gen_rtx_MEM (TYPE_MODE (TREE_TYPE (exp)),
2075                             copy_to_reg (valreg));
2076       MEM_IN_STRUCT_P (target) = AGGREGATE_TYPE_P (TREE_TYPE (exp));
2077     }
2078   /* Handle calls that return values in multiple non-contiguous locations.
2079      The Irix 6 ABI has examples of this.  */
2080   else if (GET_CODE (valreg) == PARALLEL)
2081     {
2082       if (target == 0)
2083         {
2084           int bytes = int_size_in_bytes (TREE_TYPE (exp));
2085           target = assign_stack_temp (TYPE_MODE (TREE_TYPE (exp)), bytes, 0);
2086           MEM_IN_STRUCT_P (target) = AGGREGATE_TYPE_P (TREE_TYPE (exp));
2087           preserve_temp_slots (target);
2088         }
2089
2090       emit_group_store (target, valreg);
2091     }
2092   else if (target && GET_MODE (target) == TYPE_MODE (TREE_TYPE (exp))
2093            && GET_MODE (target) == GET_MODE (valreg))
2094     /* TARGET and VALREG cannot be equal at this point because the latter
2095        would not have REG_FUNCTION_VALUE_P true, while the former would if
2096        it were referring to the same register.
2097
2098        If they refer to the same register, this move will be a no-op, except
2099        when function inlining is being done.  */
2100     emit_move_insn (target, valreg);
2101   else if (TYPE_MODE (TREE_TYPE (exp)) == BLKmode)
2102     {
2103       /* Some machines (the PA for example) want to return all small
2104          structures in registers regardless of the structure's alignment.
2105          
2106          Deal with them explicitly by copying from the return registers
2107          into the target MEM locations.  */
2108       int bytes = int_size_in_bytes (TREE_TYPE (exp));
2109       int n_regs = (bytes + UNITS_PER_WORD - 1) / UNITS_PER_WORD;
2110       int i;
2111       enum machine_mode tmpmode;
2112       rtx src, dst;
2113       int bitsize = MIN (TYPE_ALIGN (TREE_TYPE (exp)), BITS_PER_WORD);
2114       int bitpos, xbitpos, big_endian_correction = 0;
2115       
2116       if (target == 0)
2117         {
2118           target = assign_stack_temp (BLKmode, bytes, 0);
2119           MEM_IN_STRUCT_P (target) = AGGREGATE_TYPE_P (TREE_TYPE (exp));
2120           preserve_temp_slots (target);
2121         }
2122
2123       /* This code assumes valreg is at least a full word.  If it isn't,
2124          copy it into a new pseudo which is a full word.  */
2125       if (GET_MODE (valreg) != BLKmode
2126           && GET_MODE_SIZE (GET_MODE (valreg)) < UNITS_PER_WORD)
2127         valreg = convert_to_mode (word_mode, valreg,
2128                                   TREE_UNSIGNED (TREE_TYPE (exp)));
2129
2130       /* Structures whose size is not a multiple of a word are aligned
2131          to the least significant byte (to the right).  On a BYTES_BIG_ENDIAN
2132          machine, this means we must skip the empty high order bytes when
2133          calculating the bit offset.  */
2134       if (BYTES_BIG_ENDIAN && bytes % UNITS_PER_WORD)
2135         big_endian_correction = (BITS_PER_WORD - ((bytes % UNITS_PER_WORD)
2136                                                   * BITS_PER_UNIT));
2137
2138       /* Copy the structure BITSIZE bites at a time.
2139
2140          We could probably emit more efficient code for machines
2141          which do not use strict alignment, but it doesn't seem
2142          worth the effort at the current time.  */
2143       for (bitpos = 0, xbitpos = big_endian_correction;
2144            bitpos < bytes * BITS_PER_UNIT;
2145            bitpos += bitsize, xbitpos += bitsize)
2146         {
2147
2148           /* We need a new source operand each time xbitpos is on a 
2149              word boundary and when xbitpos == big_endian_correction
2150              (the first time through).  */
2151           if (xbitpos % BITS_PER_WORD == 0
2152               || xbitpos == big_endian_correction)
2153             src = operand_subword_force (valreg,
2154                                          xbitpos / BITS_PER_WORD, 
2155                                          BLKmode);
2156
2157           /* We need a new destination operand each time bitpos is on
2158              a word boundary.  */
2159           if (bitpos % BITS_PER_WORD == 0)
2160             dst = operand_subword (target, bitpos / BITS_PER_WORD, 1, BLKmode);
2161               
2162           /* Use xbitpos for the source extraction (right justified) and
2163              xbitpos for the destination store (left justified).  */
2164           store_bit_field (dst, bitsize, bitpos % BITS_PER_WORD, word_mode,
2165                            extract_bit_field (src, bitsize,
2166                                               xbitpos % BITS_PER_WORD, 1,
2167                                               NULL_RTX, word_mode,
2168                                               word_mode,
2169                                               bitsize / BITS_PER_UNIT,
2170                                               BITS_PER_WORD),
2171                            bitsize / BITS_PER_UNIT, BITS_PER_WORD);
2172         }
2173     }
2174   else
2175     target = copy_to_reg (valreg);
2176
2177 #ifdef PROMOTE_FUNCTION_RETURN
2178   /* If we promoted this return value, make the proper SUBREG.  TARGET
2179      might be const0_rtx here, so be careful.  */
2180   if (GET_CODE (target) == REG
2181       && TYPE_MODE (TREE_TYPE (exp)) != BLKmode
2182       && GET_MODE (target) != TYPE_MODE (TREE_TYPE (exp)))
2183     {
2184       tree type = TREE_TYPE (exp);
2185       int unsignedp = TREE_UNSIGNED (type);
2186
2187       /* If we don't promote as expected, something is wrong.  */
2188       if (GET_MODE (target)
2189           != promote_mode (type, TYPE_MODE (type), &unsignedp, 1))
2190         abort ();
2191
2192       target = gen_rtx_SUBREG (TYPE_MODE (type), target, 0);
2193       SUBREG_PROMOTED_VAR_P (target) = 1;
2194       SUBREG_PROMOTED_UNSIGNED_P (target) = unsignedp;
2195     }
2196 #endif
2197
2198   /* If size of args is variable or this was a constructor call for a stack
2199      argument, restore saved stack-pointer value.  */
2200
2201   if (old_stack_level)
2202     {
2203       emit_stack_restore (SAVE_BLOCK, old_stack_level, NULL_RTX);
2204       pending_stack_adjust = old_pending_adj;
2205 #ifdef ACCUMULATE_OUTGOING_ARGS
2206       stack_arg_under_construction = old_stack_arg_under_construction;
2207       highest_outgoing_arg_in_use = initial_highest_arg_in_use;
2208       stack_usage_map = initial_stack_usage_map;
2209 #endif
2210     }
2211 #ifdef ACCUMULATE_OUTGOING_ARGS
2212   else
2213     {
2214 #ifdef REG_PARM_STACK_SPACE
2215       if (save_area)
2216         {
2217           enum machine_mode save_mode = GET_MODE (save_area);
2218           rtx stack_area
2219             = gen_rtx_MEM (save_mode,
2220                            memory_address (save_mode,
2221 #ifdef ARGS_GROW_DOWNWARD
2222                                            plus_constant (argblock,
2223                                                           - high_to_save)
2224 #else
2225                                            plus_constant (argblock,
2226                                                           low_to_save)
2227 #endif
2228                                            ));
2229
2230           if (save_mode != BLKmode)
2231             emit_move_insn (stack_area, save_area);
2232           else
2233             emit_block_move (stack_area, validize_mem (save_area),
2234                              GEN_INT (high_to_save - low_to_save + 1),
2235                              PARM_BOUNDARY / BITS_PER_UNIT);
2236         }
2237 #endif
2238           
2239       /* If we saved any argument areas, restore them.  */
2240       for (i = 0; i < num_actuals; i++)
2241         if (args[i].save_area)
2242           {
2243             enum machine_mode save_mode = GET_MODE (args[i].save_area);
2244             rtx stack_area
2245               = gen_rtx_MEM (save_mode,
2246                              memory_address (save_mode,
2247                                              XEXP (args[i].stack_slot, 0)));
2248
2249             if (save_mode != BLKmode)
2250               emit_move_insn (stack_area, args[i].save_area);
2251             else
2252               emit_block_move (stack_area, validize_mem (args[i].save_area),
2253                                GEN_INT (args[i].size.constant),
2254                                PARM_BOUNDARY / BITS_PER_UNIT);
2255           }
2256
2257       highest_outgoing_arg_in_use = initial_highest_arg_in_use;
2258       stack_usage_map = initial_stack_usage_map;
2259     }
2260 #endif
2261
2262   /* If this was alloca, record the new stack level for nonlocal gotos.  
2263      Check for the handler slots since we might not have a save area
2264      for non-local gotos.  */
2265
2266   if (may_be_alloca && nonlocal_goto_handler_slot != 0)
2267     emit_stack_save (SAVE_NONLOCAL, &nonlocal_goto_stack_level, NULL_RTX);
2268
2269   pop_temp_slots ();
2270
2271   return target;
2272 }
2273 \f
2274 /* Output a library call to function FUN (a SYMBOL_REF rtx)
2275    (emitting the queue unless NO_QUEUE is nonzero),
2276    for a value of mode OUTMODE,
2277    with NARGS different arguments, passed as alternating rtx values
2278    and machine_modes to convert them to.
2279    The rtx values should have been passed through protect_from_queue already.
2280
2281    NO_QUEUE will be true if and only if the library call is a `const' call
2282    which will be enclosed in REG_LIBCALL/REG_RETVAL notes; it is equivalent
2283    to the variable is_const in expand_call.
2284
2285    NO_QUEUE must be true for const calls, because if it isn't, then
2286    any pending increment will be emitted between REG_LIBCALL/REG_RETVAL notes,
2287    and will be lost if the libcall sequence is optimized away.
2288
2289    NO_QUEUE must be false for non-const calls, because if it isn't, the
2290    call insn will have its CONST_CALL_P bit set, and it will be incorrectly
2291    optimized.  For instance, the instruction scheduler may incorrectly
2292    move memory references across the non-const call.  */
2293
2294 void
2295 emit_library_call VPROTO((rtx orgfun, int no_queue, enum machine_mode outmode,
2296                           int nargs, ...))
2297 {
2298 #ifndef __STDC__
2299   rtx orgfun;
2300   int no_queue;
2301   enum machine_mode outmode;
2302   int nargs;
2303 #endif
2304   va_list p;
2305   /* Total size in bytes of all the stack-parms scanned so far.  */
2306   struct args_size args_size;
2307   /* Size of arguments before any adjustments (such as rounding).  */
2308   struct args_size original_args_size;
2309   register int argnum;
2310   rtx fun;
2311   int inc;
2312   int count;
2313   rtx argblock = 0;
2314   CUMULATIVE_ARGS args_so_far;
2315   struct arg { rtx value; enum machine_mode mode; rtx reg; int partial;
2316                struct args_size offset; struct args_size size; rtx save_area; };
2317   struct arg *argvec;
2318   int old_inhibit_defer_pop = inhibit_defer_pop;
2319   rtx call_fusage = 0;
2320   /* Size of the stack reserved for parameter registers.  */
2321   int reg_parm_stack_space = 0;
2322 #if defined(ACCUMULATE_OUTGOING_ARGS) && defined(REG_PARM_STACK_SPACE)
2323   /* Define the boundary of the register parm stack space that needs to be
2324      save, if any.  */
2325   int low_to_save = -1, high_to_save;
2326   rtx save_area = 0;            /* Place that it is saved */
2327 #endif
2328
2329 #ifdef ACCUMULATE_OUTGOING_ARGS
2330   int initial_highest_arg_in_use = highest_outgoing_arg_in_use;
2331   char *initial_stack_usage_map = stack_usage_map;
2332   int needed;
2333 #endif
2334
2335 #ifdef REG_PARM_STACK_SPACE
2336 #ifdef MAYBE_REG_PARM_STACK_SPACE
2337   reg_parm_stack_space = MAYBE_REG_PARM_STACK_SPACE;
2338 #else
2339   reg_parm_stack_space = REG_PARM_STACK_SPACE (fndecl);
2340 #endif
2341 #endif
2342
2343   VA_START (p, nargs);
2344
2345 #ifndef __STDC__
2346   orgfun = va_arg (p, rtx);
2347   no_queue = va_arg (p, int);
2348   outmode = va_arg (p, enum machine_mode);
2349   nargs = va_arg (p, int);
2350 #endif
2351
2352   fun = orgfun;
2353
2354   /* Copy all the libcall-arguments out of the varargs data
2355      and into a vector ARGVEC.
2356
2357      Compute how to pass each argument.  We only support a very small subset
2358      of the full argument passing conventions to limit complexity here since
2359      library functions shouldn't have many args.  */
2360
2361   argvec = (struct arg *) alloca (nargs * sizeof (struct arg));
2362   bzero ((char *) argvec, nargs * sizeof (struct arg));
2363
2364
2365   INIT_CUMULATIVE_ARGS (args_so_far, NULL_TREE, fun, 0);
2366
2367   args_size.constant = 0;
2368   args_size.var = 0;
2369
2370   push_temp_slots ();
2371
2372   for (count = 0; count < nargs; count++)
2373     {
2374       rtx val = va_arg (p, rtx);
2375       enum machine_mode mode = va_arg (p, enum machine_mode);
2376
2377       /* We cannot convert the arg value to the mode the library wants here;
2378          must do it earlier where we know the signedness of the arg.  */
2379       if (mode == BLKmode
2380           || (GET_MODE (val) != mode && GET_MODE (val) != VOIDmode))
2381         abort ();
2382
2383       /* On some machines, there's no way to pass a float to a library fcn.
2384          Pass it as a double instead.  */
2385 #ifdef LIBGCC_NEEDS_DOUBLE
2386       if (LIBGCC_NEEDS_DOUBLE && mode == SFmode)
2387         val = convert_modes (DFmode, SFmode, val, 0), mode = DFmode;
2388 #endif
2389
2390       /* There's no need to call protect_from_queue, because
2391          either emit_move_insn or emit_push_insn will do that.  */
2392
2393       /* Make sure it is a reasonable operand for a move or push insn.  */
2394       if (GET_CODE (val) != REG && GET_CODE (val) != MEM
2395           && ! (CONSTANT_P (val) && LEGITIMATE_CONSTANT_P (val)))
2396         val = force_operand (val, NULL_RTX);
2397
2398 #ifdef FUNCTION_ARG_PASS_BY_REFERENCE
2399       if (FUNCTION_ARG_PASS_BY_REFERENCE (args_so_far, mode, NULL_TREE, 1))
2400         {
2401           /* We do not support FUNCTION_ARG_CALLEE_COPIES here since it can
2402              be viewed as just an efficiency improvement.  */
2403           rtx slot = assign_stack_temp (mode, GET_MODE_SIZE (mode), 0);
2404           emit_move_insn (slot, val);
2405           val = force_operand (XEXP (slot, 0), NULL_RTX);
2406           mode = Pmode;
2407         }
2408 #endif
2409
2410       argvec[count].value = val;
2411       argvec[count].mode = mode;
2412
2413       argvec[count].reg = FUNCTION_ARG (args_so_far, mode, NULL_TREE, 1);
2414       if (argvec[count].reg && GET_CODE (argvec[count].reg) == PARALLEL)
2415         abort ();
2416 #ifdef FUNCTION_ARG_PARTIAL_NREGS
2417       argvec[count].partial
2418         = FUNCTION_ARG_PARTIAL_NREGS (args_so_far, mode, NULL_TREE, 1);
2419 #else
2420       argvec[count].partial = 0;
2421 #endif
2422
2423       locate_and_pad_parm (mode, NULL_TREE,
2424                            argvec[count].reg && argvec[count].partial == 0,
2425                            NULL_TREE, &args_size, &argvec[count].offset,
2426                            &argvec[count].size);
2427
2428       if (argvec[count].size.var)
2429         abort ();
2430
2431 #ifndef REG_PARM_STACK_SPACE
2432       if (argvec[count].partial)
2433         argvec[count].size.constant -= argvec[count].partial * UNITS_PER_WORD;
2434 #endif
2435
2436       if (argvec[count].reg == 0 || argvec[count].partial != 0
2437 #ifdef REG_PARM_STACK_SPACE
2438           || 1
2439 #endif
2440           )
2441         args_size.constant += argvec[count].size.constant;
2442
2443       FUNCTION_ARG_ADVANCE (args_so_far, mode, (tree) 0, 1);
2444     }
2445   va_end (p);
2446
2447 #ifdef FINAL_REG_PARM_STACK_SPACE
2448   reg_parm_stack_space = FINAL_REG_PARM_STACK_SPACE (args_size.constant,
2449                                                      args_size.var);
2450 #endif
2451       
2452   /* If this machine requires an external definition for library
2453      functions, write one out.  */
2454   assemble_external_libcall (fun);
2455
2456   original_args_size = args_size;
2457 #ifdef STACK_BOUNDARY
2458   args_size.constant = (((args_size.constant + (STACK_BYTES - 1))
2459                          / STACK_BYTES) * STACK_BYTES);
2460 #endif
2461
2462 #ifdef REG_PARM_STACK_SPACE
2463   args_size.constant = MAX (args_size.constant,
2464                             reg_parm_stack_space);
2465 #ifndef OUTGOING_REG_PARM_STACK_SPACE
2466   args_size.constant -= reg_parm_stack_space;
2467 #endif
2468 #endif
2469
2470   if (args_size.constant > current_function_outgoing_args_size)
2471     current_function_outgoing_args_size = args_size.constant;
2472
2473 #ifdef ACCUMULATE_OUTGOING_ARGS
2474   /* Since the stack pointer will never be pushed, it is possible for
2475      the evaluation of a parm to clobber something we have already
2476      written to the stack.  Since most function calls on RISC machines
2477      do not use the stack, this is uncommon, but must work correctly.
2478
2479      Therefore, we save any area of the stack that was already written
2480      and that we are using.  Here we set up to do this by making a new
2481      stack usage map from the old one.
2482
2483      Another approach might be to try to reorder the argument
2484      evaluations to avoid this conflicting stack usage.  */
2485
2486   needed = args_size.constant;
2487 #if defined(REG_PARM_STACK_SPACE) && ! defined(OUTGOING_REG_PARM_STACK_SPACE)
2488   /* Since we will be writing into the entire argument area, the
2489      map must be allocated for its entire size, not just the part that
2490      is the responsibility of the caller.  */
2491   needed += reg_parm_stack_space;
2492 #endif
2493
2494 #ifdef ARGS_GROW_DOWNWARD
2495   highest_outgoing_arg_in_use = MAX (initial_highest_arg_in_use,
2496                                      needed + 1);
2497 #else
2498   highest_outgoing_arg_in_use = MAX (initial_highest_arg_in_use,
2499                                      needed);
2500 #endif
2501   stack_usage_map = (char *) alloca (highest_outgoing_arg_in_use);
2502
2503   if (initial_highest_arg_in_use)
2504     bcopy (initial_stack_usage_map, stack_usage_map,
2505            initial_highest_arg_in_use);
2506
2507   if (initial_highest_arg_in_use != highest_outgoing_arg_in_use)
2508     bzero (&stack_usage_map[initial_highest_arg_in_use],
2509            highest_outgoing_arg_in_use - initial_highest_arg_in_use);
2510   needed = 0;
2511
2512   /* The address of the outgoing argument list must not be copied to a
2513      register here, because argblock would be left pointing to the
2514      wrong place after the call to allocate_dynamic_stack_space below.
2515      */
2516
2517   argblock = virtual_outgoing_args_rtx;
2518 #else /* not ACCUMULATE_OUTGOING_ARGS */
2519 #ifndef PUSH_ROUNDING
2520   argblock = push_block (GEN_INT (args_size.constant), 0, 0);
2521 #endif
2522 #endif
2523
2524 #ifdef PUSH_ARGS_REVERSED
2525 #ifdef STACK_BOUNDARY
2526   /* If we push args individually in reverse order, perform stack alignment
2527      before the first push (the last arg).  */
2528   if (argblock == 0)
2529     anti_adjust_stack (GEN_INT (args_size.constant
2530                                 - original_args_size.constant));
2531 #endif
2532 #endif
2533
2534 #ifdef PUSH_ARGS_REVERSED
2535   inc = -1;
2536   argnum = nargs - 1;
2537 #else
2538   inc = 1;
2539   argnum = 0;
2540 #endif
2541
2542 #if defined(ACCUMULATE_OUTGOING_ARGS) && defined(REG_PARM_STACK_SPACE)
2543   /* The argument list is the property of the called routine and it
2544      may clobber it.  If the fixed area has been used for previous
2545      parameters, we must save and restore it.
2546
2547      Here we compute the boundary of the that needs to be saved, if any.  */
2548
2549 #ifdef ARGS_GROW_DOWNWARD
2550   for (count = 0; count < reg_parm_stack_space + 1; count++)
2551 #else
2552   for (count = 0; count < reg_parm_stack_space; count++)
2553 #endif
2554     {
2555       if (count >=  highest_outgoing_arg_in_use
2556           || stack_usage_map[count] == 0)
2557         continue;
2558
2559       if (low_to_save == -1)
2560         low_to_save = count;
2561
2562       high_to_save = count;
2563     }
2564
2565   if (low_to_save >= 0)
2566     {
2567       int num_to_save = high_to_save - low_to_save + 1;
2568       enum machine_mode save_mode
2569         = mode_for_size (num_to_save * BITS_PER_UNIT, MODE_INT, 1);
2570       rtx stack_area;
2571
2572       /* If we don't have the required alignment, must do this in BLKmode.  */
2573       if ((low_to_save & (MIN (GET_MODE_SIZE (save_mode),
2574                                BIGGEST_ALIGNMENT / UNITS_PER_WORD) - 1)))
2575         save_mode = BLKmode;
2576
2577       stack_area = gen_rtx_MEM (save_mode,
2578                                 memory_address (save_mode,
2579                                             
2580 #ifdef ARGS_GROW_DOWNWARD
2581                                                 plus_constant (argblock,
2582                                                                - high_to_save)
2583 #else
2584                                                 plus_constant (argblock,
2585                                                                low_to_save)
2586 #endif
2587                                                 ));
2588       if (save_mode == BLKmode)
2589         {
2590           save_area = assign_stack_temp (BLKmode, num_to_save, 0);
2591           MEM_IN_STRUCT_P (save_area) = 0;
2592           emit_block_move (validize_mem (save_area), stack_area,
2593                            GEN_INT (num_to_save),
2594                            PARM_BOUNDARY / BITS_PER_UNIT);
2595         }
2596       else
2597         {
2598           save_area = gen_reg_rtx (save_mode);
2599           emit_move_insn (save_area, stack_area);
2600         }
2601     }
2602 #endif
2603           
2604   /* Push the args that need to be pushed.  */
2605
2606   /* ARGNUM indexes the ARGVEC array in the order in which the arguments
2607      are to be pushed.  */
2608   for (count = 0; count < nargs; count++, argnum += inc)
2609     {
2610       register enum machine_mode mode = argvec[argnum].mode;
2611       register rtx val = argvec[argnum].value;
2612       rtx reg = argvec[argnum].reg;
2613       int partial = argvec[argnum].partial;
2614       int lower_bound, upper_bound, i;
2615
2616       if (! (reg != 0 && partial == 0))
2617         {
2618 #ifdef ACCUMULATE_OUTGOING_ARGS
2619           /* If this is being stored into a pre-allocated, fixed-size, stack
2620              area, save any previous data at that location.  */
2621
2622 #ifdef ARGS_GROW_DOWNWARD
2623           /* stack_slot is negative, but we want to index stack_usage_map
2624              with positive values.  */
2625           upper_bound = -argvec[argnum].offset.constant + 1;
2626           lower_bound = upper_bound - argvec[argnum].size.constant;
2627 #else
2628           lower_bound = argvec[argnum].offset.constant;
2629           upper_bound = lower_bound + argvec[argnum].size.constant;
2630 #endif
2631
2632           for (i = lower_bound; i < upper_bound; i++)
2633             if (stack_usage_map[i]
2634 #ifdef REG_PARM_STACK_SPACE
2635                 /* Don't store things in the fixed argument area at this point;
2636                    it has already been saved.  */
2637                 && i > reg_parm_stack_space
2638 #endif
2639                 )
2640               break;
2641
2642           if (i != upper_bound)
2643             {
2644               /* We need to make a save area.  See what mode we can make it.  */
2645               enum machine_mode save_mode
2646                 = mode_for_size (argvec[argnum].size.constant * BITS_PER_UNIT,
2647                                  MODE_INT, 1);
2648               rtx stack_area
2649                 = gen_rtx_MEM (save_mode,
2650                                memory_address (save_mode,
2651                                                plus_constant (argblock, argvec[argnum].offset.constant)));
2652               argvec[argnum].save_area = gen_reg_rtx (save_mode);
2653               emit_move_insn (argvec[argnum].save_area, stack_area);
2654             }
2655 #endif
2656           emit_push_insn (val, mode, NULL_TREE, NULL_RTX, 0, partial, reg, 0,
2657                           argblock, GEN_INT (argvec[argnum].offset.constant));
2658
2659 #ifdef ACCUMULATE_OUTGOING_ARGS
2660           /* Now mark the segment we just used.  */
2661           for (i = lower_bound; i < upper_bound; i++)
2662             stack_usage_map[i] = 1;
2663 #endif
2664
2665           NO_DEFER_POP;
2666         }
2667     }
2668
2669 #ifndef PUSH_ARGS_REVERSED
2670 #ifdef STACK_BOUNDARY
2671   /* If we pushed args in forward order, perform stack alignment
2672      after pushing the last arg.  */
2673   if (argblock == 0)
2674     anti_adjust_stack (GEN_INT (args_size.constant
2675                                 - original_args_size.constant));
2676 #endif
2677 #endif
2678
2679 #ifdef PUSH_ARGS_REVERSED
2680   argnum = nargs - 1;
2681 #else
2682   argnum = 0;
2683 #endif
2684
2685   fun = prepare_call_address (fun, NULL_TREE, &call_fusage, 0);
2686
2687   /* Now load any reg parms into their regs.  */
2688
2689   /* ARGNUM indexes the ARGVEC array in the order in which the arguments
2690      are to be pushed.  */
2691   for (count = 0; count < nargs; count++, argnum += inc)
2692     {
2693       register enum machine_mode mode = argvec[argnum].mode;
2694       register rtx val = argvec[argnum].value;
2695       rtx reg = argvec[argnum].reg;
2696       int partial = argvec[argnum].partial;
2697
2698       if (reg != 0 && partial == 0)
2699         emit_move_insn (reg, val);
2700       NO_DEFER_POP;
2701     }
2702
2703   /* For version 1.37, try deleting this entirely.  */
2704   if (! no_queue)
2705     emit_queue ();
2706
2707   /* Any regs containing parms remain in use through the call.  */
2708   for (count = 0; count < nargs; count++)
2709     if (argvec[count].reg != 0)
2710        use_reg (&call_fusage, argvec[count].reg);
2711
2712   /* Don't allow popping to be deferred, since then
2713      cse'ing of library calls could delete a call and leave the pop.  */
2714   NO_DEFER_POP;
2715
2716   /* We pass the old value of inhibit_defer_pop + 1 to emit_call_1, which
2717      will set inhibit_defer_pop to that value.  */
2718
2719   /* The return type is needed to decide how many bytes the function pops.
2720      Signedness plays no role in that, so for simplicity, we pretend it's
2721      always signed.  We also assume that the list of arguments passed has
2722      no impact, so we pretend it is unknown.  */
2723
2724   emit_call_1 (fun, 
2725                get_identifier (XSTR (orgfun, 0)), 
2726                build_function_type (outmode == VOIDmode ? void_type_node
2727                                     : type_for_mode (outmode, 0), NULL_TREE),
2728                args_size.constant, 0,
2729                FUNCTION_ARG (args_so_far, VOIDmode, void_type_node, 1),
2730                outmode != VOIDmode ? hard_libcall_value (outmode) : NULL_RTX,
2731                old_inhibit_defer_pop + 1, call_fusage, no_queue);
2732
2733   pop_temp_slots ();
2734
2735   /* Now restore inhibit_defer_pop to its actual original value.  */
2736   OK_DEFER_POP;
2737
2738 #ifdef ACCUMULATE_OUTGOING_ARGS
2739 #ifdef REG_PARM_STACK_SPACE
2740   if (save_area)
2741     {
2742       enum machine_mode save_mode = GET_MODE (save_area);
2743       rtx stack_area
2744         = gen_rtx_MEM (save_mode,
2745                        memory_address (save_mode,
2746 #ifdef ARGS_GROW_DOWNWARD
2747                                        plus_constant (argblock, - high_to_save)
2748 #else
2749                                        plus_constant (argblock, low_to_save)
2750 #endif
2751                                        ));
2752
2753       if (save_mode != BLKmode)
2754         emit_move_insn (stack_area, save_area);
2755       else
2756         emit_block_move (stack_area, validize_mem (save_area),
2757                          GEN_INT (high_to_save - low_to_save + 1),
2758                          PARM_BOUNDARY / BITS_PER_UNIT);
2759     }
2760 #endif
2761           
2762   /* If we saved any argument areas, restore them.  */
2763   for (count = 0; count < nargs; count++)
2764     if (argvec[count].save_area)
2765       {
2766         enum machine_mode save_mode = GET_MODE (argvec[count].save_area);
2767         rtx stack_area
2768           = gen_rtx_MEM (save_mode,
2769                          memory_address (save_mode,
2770                                          plus_constant (argblock, argvec[count].offset.constant)));
2771
2772         emit_move_insn (stack_area, argvec[count].save_area);
2773       }
2774
2775   highest_outgoing_arg_in_use = initial_highest_arg_in_use;
2776   stack_usage_map = initial_stack_usage_map;
2777 #endif
2778 }
2779 \f
2780 /* Like emit_library_call except that an extra argument, VALUE,
2781    comes second and says where to store the result.
2782    (If VALUE is zero, this function chooses a convenient way
2783    to return the value.
2784
2785    This function returns an rtx for where the value is to be found.
2786    If VALUE is nonzero, VALUE is returned.  */
2787
2788 rtx
2789 emit_library_call_value VPROTO((rtx orgfun, rtx value, int no_queue,
2790                                 enum machine_mode outmode, int nargs, ...))
2791 {
2792 #ifndef __STDC__
2793   rtx orgfun;
2794   rtx value;
2795   int no_queue;
2796   enum machine_mode outmode;
2797   int nargs;
2798 #endif
2799   va_list p;
2800   /* Total size in bytes of all the stack-parms scanned so far.  */
2801   struct args_size args_size;
2802   /* Size of arguments before any adjustments (such as rounding).  */
2803   struct args_size original_args_size;
2804   register int argnum;
2805   rtx fun;
2806   int inc;
2807   int count;
2808   rtx argblock = 0;
2809   CUMULATIVE_ARGS args_so_far;
2810   struct arg { rtx value; enum machine_mode mode; rtx reg; int partial;
2811                struct args_size offset; struct args_size size; rtx save_area; };
2812   struct arg *argvec;
2813   int old_inhibit_defer_pop = inhibit_defer_pop;
2814   rtx call_fusage = 0;
2815   /* Size of the stack reserved for parameter registers.  */
2816   int reg_parm_stack_space = 0;
2817   rtx mem_value = 0;
2818   int pcc_struct_value = 0;
2819   int struct_value_size = 0;
2820   int is_const;
2821   int needed;
2822
2823 #if defined(ACCUMULATE_OUTGOING_ARGS) && defined(REG_PARM_STACK_SPACE)
2824   /* Define the boundary of the register parm stack space that needs to be
2825      save, if any.  */
2826   int low_to_save = -1, high_to_save;
2827   rtx save_area = 0;            /* Place that it is saved */
2828 #endif
2829
2830 #ifdef ACCUMULATE_OUTGOING_ARGS
2831   int initial_highest_arg_in_use = highest_outgoing_arg_in_use;
2832   char *initial_stack_usage_map = stack_usage_map;
2833 #endif
2834
2835 #ifdef REG_PARM_STACK_SPACE
2836 #ifdef MAYBE_REG_PARM_STACK_SPACE
2837   reg_parm_stack_space = MAYBE_REG_PARM_STACK_SPACE;
2838 #else
2839   reg_parm_stack_space = REG_PARM_STACK_SPACE (fndecl);
2840 #endif
2841 #endif
2842
2843   VA_START (p, nargs);
2844
2845 #ifndef __STDC__
2846   orgfun = va_arg (p, rtx);
2847   value = va_arg (p, rtx);
2848   no_queue = va_arg (p, int);
2849   outmode = va_arg (p, enum machine_mode);
2850   nargs = va_arg (p, int);
2851 #endif
2852
2853   is_const = no_queue;
2854   fun = orgfun;
2855
2856   /* If this kind of value comes back in memory,
2857      decide where in memory it should come back.  */
2858   if (aggregate_value_p (type_for_mode (outmode, 0)))
2859     {
2860 #ifdef PCC_STATIC_STRUCT_RETURN
2861       rtx pointer_reg
2862         = hard_function_value (build_pointer_type (type_for_mode (outmode, 0)),
2863                                0);
2864       mem_value = gen_rtx_MEM (outmode, pointer_reg);
2865       pcc_struct_value = 1;
2866       if (value == 0)
2867         value = gen_reg_rtx (outmode);
2868 #else /* not PCC_STATIC_STRUCT_RETURN */
2869       struct_value_size = GET_MODE_SIZE (outmode);
2870       if (value != 0 && GET_CODE (value) == MEM)
2871         mem_value = value;
2872       else
2873         mem_value = assign_stack_temp (outmode, GET_MODE_SIZE (outmode), 0);
2874 #endif
2875
2876       /* This call returns a big structure.  */
2877       is_const = 0;
2878     }
2879
2880   /* ??? Unfinished: must pass the memory address as an argument.  */
2881
2882   /* Copy all the libcall-arguments out of the varargs data
2883      and into a vector ARGVEC.
2884
2885      Compute how to pass each argument.  We only support a very small subset
2886      of the full argument passing conventions to limit complexity here since
2887      library functions shouldn't have many args.  */
2888
2889   argvec = (struct arg *) alloca ((nargs + 1) * sizeof (struct arg));
2890   bzero ((char *) argvec, (nargs + 1) * sizeof (struct arg));
2891
2892   INIT_CUMULATIVE_ARGS (args_so_far, NULL_TREE, fun, 0);
2893
2894   args_size.constant = 0;
2895   args_size.var = 0;
2896
2897   count = 0;
2898
2899   push_temp_slots ();
2900
2901   /* If there's a structure value address to be passed,
2902      either pass it in the special place, or pass it as an extra argument.  */
2903   if (mem_value && struct_value_rtx == 0 && ! pcc_struct_value)
2904     {
2905       rtx addr = XEXP (mem_value, 0);
2906       nargs++;
2907
2908       /* Make sure it is a reasonable operand for a move or push insn.  */
2909       if (GET_CODE (addr) != REG && GET_CODE (addr) != MEM
2910           && ! (CONSTANT_P (addr) && LEGITIMATE_CONSTANT_P (addr)))
2911         addr = force_operand (addr, NULL_RTX);
2912
2913       argvec[count].value = addr;
2914       argvec[count].mode = Pmode;
2915       argvec[count].partial = 0;
2916
2917       argvec[count].reg = FUNCTION_ARG (args_so_far, Pmode, NULL_TREE, 1);
2918 #ifdef FUNCTION_ARG_PARTIAL_NREGS
2919       if (FUNCTION_ARG_PARTIAL_NREGS (args_so_far, Pmode, NULL_TREE, 1))
2920         abort ();
2921 #endif
2922
2923       locate_and_pad_parm (Pmode, NULL_TREE,
2924                            argvec[count].reg && argvec[count].partial == 0,
2925                            NULL_TREE, &args_size, &argvec[count].offset,
2926                            &argvec[count].size);
2927
2928
2929       if (argvec[count].reg == 0 || argvec[count].partial != 0
2930 #ifdef REG_PARM_STACK_SPACE
2931           || 1
2932 #endif
2933           )
2934         args_size.constant += argvec[count].size.constant;
2935
2936       FUNCTION_ARG_ADVANCE (args_so_far, Pmode, (tree) 0, 1);
2937
2938       count++;
2939     }
2940
2941   for (; count < nargs; count++)
2942     {
2943       rtx val = va_arg (p, rtx);
2944       enum machine_mode mode = va_arg (p, enum machine_mode);
2945
2946       /* We cannot convert the arg value to the mode the library wants here;
2947          must do it earlier where we know the signedness of the arg.  */
2948       if (mode == BLKmode
2949           || (GET_MODE (val) != mode && GET_MODE (val) != VOIDmode))
2950         abort ();
2951
2952       /* On some machines, there's no way to pass a float to a library fcn.
2953          Pass it as a double instead.  */
2954 #ifdef LIBGCC_NEEDS_DOUBLE
2955       if (LIBGCC_NEEDS_DOUBLE && mode == SFmode)
2956         val = convert_modes (DFmode, SFmode, val, 0), mode = DFmode;
2957 #endif
2958
2959       /* There's no need to call protect_from_queue, because
2960          either emit_move_insn or emit_push_insn will do that.  */
2961
2962       /* Make sure it is a reasonable operand for a move or push insn.  */
2963       if (GET_CODE (val) != REG && GET_CODE (val) != MEM
2964           && ! (CONSTANT_P (val) && LEGITIMATE_CONSTANT_P (val)))
2965         val = force_operand (val, NULL_RTX);
2966
2967 #ifdef FUNCTION_ARG_PASS_BY_REFERENCE
2968       if (FUNCTION_ARG_PASS_BY_REFERENCE (args_so_far, mode, NULL_TREE, 1))
2969         {
2970           /* We do not support FUNCTION_ARG_CALLEE_COPIES here since it can
2971              be viewed as just an efficiency improvement.  */
2972           rtx slot = assign_stack_temp (mode, GET_MODE_SIZE (mode), 0);
2973           emit_move_insn (slot, val);
2974           val = XEXP (slot, 0);
2975           mode = Pmode;
2976         }
2977 #endif
2978
2979       argvec[count].value = val;
2980       argvec[count].mode = mode;
2981
2982       argvec[count].reg = FUNCTION_ARG (args_so_far, mode, NULL_TREE, 1);
2983       if (argvec[count].reg && GET_CODE (argvec[count].reg) == PARALLEL)
2984         abort ();
2985 #ifdef FUNCTION_ARG_PARTIAL_NREGS
2986       argvec[count].partial
2987         = FUNCTION_ARG_PARTIAL_NREGS (args_so_far, mode, NULL_TREE, 1);
2988 #else
2989       argvec[count].partial = 0;
2990 #endif
2991
2992       locate_and_pad_parm (mode, NULL_TREE,
2993                            argvec[count].reg && argvec[count].partial == 0,
2994                            NULL_TREE, &args_size, &argvec[count].offset,
2995                            &argvec[count].size);
2996
2997       if (argvec[count].size.var)
2998         abort ();
2999
3000 #ifndef REG_PARM_STACK_SPACE
3001       if (argvec[count].partial)
3002         argvec[count].size.constant -= argvec[count].partial * UNITS_PER_WORD;
3003 #endif
3004
3005       if (argvec[count].reg == 0 || argvec[count].partial != 0
3006 #ifdef REG_PARM_STACK_SPACE
3007           || 1
3008 #endif
3009           )
3010         args_size.constant += argvec[count].size.constant;
3011
3012       FUNCTION_ARG_ADVANCE (args_so_far, mode, (tree) 0, 1);
3013     }
3014   va_end (p);
3015
3016 #ifdef FINAL_REG_PARM_STACK_SPACE
3017   reg_parm_stack_space = FINAL_REG_PARM_STACK_SPACE (args_size.constant,
3018                                                      args_size.var);
3019 #endif
3020   /* If this machine requires an external definition for library
3021      functions, write one out.  */
3022   assemble_external_libcall (fun);
3023
3024   original_args_size = args_size;
3025 #ifdef STACK_BOUNDARY
3026   args_size.constant = (((args_size.constant + (STACK_BYTES - 1))
3027                          / STACK_BYTES) * STACK_BYTES);
3028 #endif
3029
3030 #ifdef REG_PARM_STACK_SPACE
3031   args_size.constant = MAX (args_size.constant,
3032                             reg_parm_stack_space);
3033 #ifndef OUTGOING_REG_PARM_STACK_SPACE
3034   args_size.constant -= reg_parm_stack_space;
3035 #endif
3036 #endif
3037
3038   if (args_size.constant > current_function_outgoing_args_size)
3039     current_function_outgoing_args_size = args_size.constant;
3040
3041 #ifdef ACCUMULATE_OUTGOING_ARGS
3042   /* Since the stack pointer will never be pushed, it is possible for
3043      the evaluation of a parm to clobber something we have already
3044      written to the stack.  Since most function calls on RISC machines
3045      do not use the stack, this is uncommon, but must work correctly.
3046
3047      Therefore, we save any area of the stack that was already written
3048      and that we are using.  Here we set up to do this by making a new
3049      stack usage map from the old one.
3050
3051      Another approach might be to try to reorder the argument
3052      evaluations to avoid this conflicting stack usage.  */
3053
3054   needed = args_size.constant;
3055 #if defined(REG_PARM_STACK_SPACE) && ! defined(OUTGOING_REG_PARM_STACK_SPACE)
3056   /* Since we will be writing into the entire argument area, the
3057      map must be allocated for its entire size, not just the part that
3058      is the responsibility of the caller.  */
3059   needed += reg_parm_stack_space;
3060 #endif
3061
3062 #ifdef ARGS_GROW_DOWNWARD
3063   highest_outgoing_arg_in_use = MAX (initial_highest_arg_in_use,
3064                                      needed + 1);
3065 #else
3066   highest_outgoing_arg_in_use = MAX (initial_highest_arg_in_use,
3067                                      needed);
3068 #endif
3069   stack_usage_map = (char *) alloca (highest_outgoing_arg_in_use);
3070
3071   if (initial_highest_arg_in_use)
3072     bcopy (initial_stack_usage_map, stack_usage_map,
3073            initial_highest_arg_in_use);
3074
3075   if (initial_highest_arg_in_use != highest_outgoing_arg_in_use)
3076     bzero (&stack_usage_map[initial_highest_arg_in_use],
3077            highest_outgoing_arg_in_use - initial_highest_arg_in_use);
3078   needed = 0;
3079
3080   /* The address of the outgoing argument list must not be copied to a
3081      register here, because argblock would be left pointing to the
3082      wrong place after the call to allocate_dynamic_stack_space below.
3083      */
3084
3085   argblock = virtual_outgoing_args_rtx;
3086 #else /* not ACCUMULATE_OUTGOING_ARGS */
3087 #ifndef PUSH_ROUNDING
3088   argblock = push_block (GEN_INT (args_size.constant), 0, 0);
3089 #endif
3090 #endif
3091
3092 #ifdef PUSH_ARGS_REVERSED
3093 #ifdef STACK_BOUNDARY
3094   /* If we push args individually in reverse order, perform stack alignment
3095      before the first push (the last arg).  */
3096   if (argblock == 0)
3097     anti_adjust_stack (GEN_INT (args_size.constant
3098                                 - original_args_size.constant));
3099 #endif
3100 #endif
3101
3102 #ifdef PUSH_ARGS_REVERSED
3103   inc = -1;
3104   argnum = nargs - 1;
3105 #else
3106   inc = 1;
3107   argnum = 0;
3108 #endif
3109
3110 #if defined(ACCUMULATE_OUTGOING_ARGS) && defined(REG_PARM_STACK_SPACE)
3111   /* The argument list is the property of the called routine and it
3112      may clobber it.  If the fixed area has been used for previous
3113      parameters, we must save and restore it.
3114
3115      Here we compute the boundary of the that needs to be saved, if any.  */
3116
3117 #ifdef ARGS_GROW_DOWNWARD
3118   for (count = 0; count < reg_parm_stack_space + 1; count++)
3119 #else
3120   for (count = 0; count < reg_parm_stack_space; count++)
3121 #endif
3122     {
3123       if (count >=  highest_outgoing_arg_in_use
3124           || stack_usage_map[count] == 0)
3125         continue;
3126
3127       if (low_to_save == -1)
3128         low_to_save = count;
3129
3130       high_to_save = count;
3131     }
3132
3133   if (low_to_save >= 0)
3134     {
3135       int num_to_save = high_to_save - low_to_save + 1;
3136       enum machine_mode save_mode
3137         = mode_for_size (num_to_save * BITS_PER_UNIT, MODE_INT, 1);
3138       rtx stack_area;
3139
3140       /* If we don't have the required alignment, must do this in BLKmode.  */
3141       if ((low_to_save & (MIN (GET_MODE_SIZE (save_mode),
3142                                BIGGEST_ALIGNMENT / UNITS_PER_WORD) - 1)))
3143         save_mode = BLKmode;
3144
3145       stack_area = gen_rtx_MEM (save_mode,
3146                                 memory_address (save_mode,
3147                                             
3148 #ifdef ARGS_GROW_DOWNWARD
3149                                                 plus_constant (argblock,
3150                                                                - high_to_save)
3151 #else
3152                                                 plus_constant (argblock,
3153                                                                low_to_save)
3154 #endif
3155                                                 ));
3156       if (save_mode == BLKmode)
3157         {
3158           save_area = assign_stack_temp (BLKmode, num_to_save, 0);
3159           MEM_IN_STRUCT_P (save_area) = 0;
3160           emit_block_move (validize_mem (save_area), stack_area,
3161                            GEN_INT (num_to_save),
3162                            PARM_BOUNDARY / BITS_PER_UNIT);
3163         }
3164       else
3165         {
3166           save_area = gen_reg_rtx (save_mode);
3167           emit_move_insn (save_area, stack_area);
3168         }
3169     }
3170 #endif
3171           
3172   /* Push the args that need to be pushed.  */
3173
3174   /* ARGNUM indexes the ARGVEC array in the order in which the arguments
3175      are to be pushed.  */
3176   for (count = 0; count < nargs; count++, argnum += inc)
3177     {
3178       register enum machine_mode mode = argvec[argnum].mode;
3179       register rtx val = argvec[argnum].value;
3180       rtx reg = argvec[argnum].reg;
3181       int partial = argvec[argnum].partial;
3182       int lower_bound, upper_bound, i;
3183
3184       if (! (reg != 0 && partial == 0))
3185         {
3186 #ifdef ACCUMULATE_OUTGOING_ARGS
3187           /* If this is being stored into a pre-allocated, fixed-size, stack
3188              area, save any previous data at that location.  */
3189
3190 #ifdef ARGS_GROW_DOWNWARD
3191           /* stack_slot is negative, but we want to index stack_usage_map
3192              with positive values.  */
3193           upper_bound = -argvec[argnum].offset.constant + 1;
3194           lower_bound = upper_bound - argvec[argnum].size.constant;
3195 #else
3196           lower_bound = argvec[argnum].offset.constant;
3197           upper_bound = lower_bound + argvec[argnum].size.constant;
3198 #endif
3199
3200           for (i = lower_bound; i < upper_bound; i++)
3201             if (stack_usage_map[i]
3202 #ifdef REG_PARM_STACK_SPACE
3203                 /* Don't store things in the fixed argument area at this point;
3204                    it has already been saved.  */
3205                 && i > reg_parm_stack_space
3206 #endif
3207                 )
3208               break;
3209
3210           if (i != upper_bound)
3211             {
3212               /* We need to make a save area.  See what mode we can make it.  */
3213               enum machine_mode save_mode
3214                 = mode_for_size (argvec[argnum].size.constant * BITS_PER_UNIT,
3215                                  MODE_INT, 1);
3216               rtx stack_area
3217                 = gen_rtx_MEM (save_mode,
3218                                memory_address (save_mode,
3219                                                plus_constant (argblock,
3220                                                               argvec[argnum].offset.constant)));
3221               argvec[argnum].save_area = gen_reg_rtx (save_mode);
3222               emit_move_insn (argvec[argnum].save_area, stack_area);
3223             }
3224 #endif
3225           emit_push_insn (val, mode, NULL_TREE, NULL_RTX, 0, partial, reg, 0,
3226                           argblock, GEN_INT (argvec[argnum].offset.constant));
3227
3228 #ifdef ACCUMULATE_OUTGOING_ARGS
3229           /* Now mark the segment we just used.  */
3230           for (i = lower_bound; i < upper_bound; i++)
3231             stack_usage_map[i] = 1;
3232 #endif
3233
3234           NO_DEFER_POP;
3235         }
3236     }
3237
3238 #ifndef PUSH_ARGS_REVERSED
3239 #ifdef STACK_BOUNDARY
3240   /* If we pushed args in forward order, perform stack alignment
3241      after pushing the last arg.  */
3242   if (argblock == 0)
3243     anti_adjust_stack (GEN_INT (args_size.constant
3244                                 - original_args_size.constant));
3245 #endif
3246 #endif
3247
3248 #ifdef PUSH_ARGS_REVERSED
3249   argnum = nargs - 1;
3250 #else
3251   argnum = 0;
3252 #endif
3253
3254   fun = prepare_call_address (fun, NULL_TREE, &call_fusage, 0);
3255
3256   /* Now load any reg parms into their regs.  */
3257
3258   /* ARGNUM indexes the ARGVEC array in the order in which the arguments
3259      are to be pushed.  */
3260   for (count = 0; count < nargs; count++, argnum += inc)
3261     {
3262       register enum machine_mode mode = argvec[argnum].mode;
3263       register rtx val = argvec[argnum].value;
3264       rtx reg = argvec[argnum].reg;
3265       int partial = argvec[argnum].partial;
3266
3267       if (reg != 0 && partial == 0)
3268         emit_move_insn (reg, val);
3269       NO_DEFER_POP;
3270     }
3271
3272 #if 0
3273   /* For version 1.37, try deleting this entirely.  */
3274   if (! no_queue)
3275     emit_queue ();
3276 #endif
3277
3278   /* Any regs containing parms remain in use through the call.  */
3279   for (count = 0; count < nargs; count++)
3280     if (argvec[count].reg != 0)
3281        use_reg (&call_fusage, argvec[count].reg);
3282
3283   /* Pass the function the address in which to return a structure value.  */
3284   if (mem_value != 0 && struct_value_rtx != 0 && ! pcc_struct_value)
3285     {
3286       emit_move_insn (struct_value_rtx,
3287                       force_reg (Pmode,
3288                                  force_operand (XEXP (mem_value, 0),
3289                                                 NULL_RTX)));
3290       if (GET_CODE (struct_value_rtx) == REG)
3291           use_reg (&call_fusage, struct_value_rtx);
3292     }
3293
3294   /* Don't allow popping to be deferred, since then
3295      cse'ing of library calls could delete a call and leave the pop.  */
3296   NO_DEFER_POP;
3297
3298   /* We pass the old value of inhibit_defer_pop + 1 to emit_call_1, which
3299      will set inhibit_defer_pop to that value.  */
3300   /* See the comment in emit_library_call about the function type we build
3301      and pass here.  */
3302
3303   emit_call_1 (fun, 
3304                get_identifier (XSTR (orgfun, 0)),
3305                build_function_type (type_for_mode (outmode, 0), NULL_TREE),
3306                args_size.constant, struct_value_size,
3307                FUNCTION_ARG (args_so_far, VOIDmode, void_type_node, 1),
3308                mem_value == 0 ? hard_libcall_value (outmode) : NULL_RTX,
3309                old_inhibit_defer_pop + 1, call_fusage, is_const);
3310
3311   /* Now restore inhibit_defer_pop to its actual original value.  */
3312   OK_DEFER_POP;
3313
3314   pop_temp_slots ();
3315
3316   /* Copy the value to the right place.  */
3317   if (outmode != VOIDmode)
3318     {
3319       if (mem_value)
3320         {
3321           if (value == 0)
3322             value = mem_value;
3323           if (value != mem_value)
3324             emit_move_insn (value, mem_value);
3325         }
3326       else if (value != 0)
3327         emit_move_insn (value, hard_libcall_value (outmode));
3328       else
3329         value = hard_libcall_value (outmode);
3330     }
3331
3332 #ifdef ACCUMULATE_OUTGOING_ARGS
3333 #ifdef REG_PARM_STACK_SPACE
3334   if (save_area)
3335     {
3336       enum machine_mode save_mode = GET_MODE (save_area);
3337       rtx stack_area
3338         = gen_rtx_MEM (save_mode,
3339                        memory_address (save_mode,
3340 #ifdef ARGS_GROW_DOWNWARD
3341                                        plus_constant (argblock, - high_to_save)
3342 #else
3343                                        plus_constant (argblock, low_to_save)
3344 #endif
3345                                        ));
3346       if (save_mode != BLKmode)
3347         emit_move_insn (stack_area, save_area);
3348       else
3349         emit_block_move (stack_area, validize_mem (save_area),
3350                          GEN_INT (high_to_save - low_to_save + 1),
3351                              PARM_BOUNDARY / BITS_PER_UNIT);
3352     }
3353 #endif
3354           
3355   /* If we saved any argument areas, restore them.  */
3356   for (count = 0; count < nargs; count++)
3357     if (argvec[count].save_area)
3358       {
3359         enum machine_mode save_mode = GET_MODE (argvec[count].save_area);
3360         rtx stack_area
3361           = gen_rtx_MEM (save_mode,
3362                      memory_address (save_mode, plus_constant (argblock,
3363                                      argvec[count].offset.constant)));
3364
3365         emit_move_insn (stack_area, argvec[count].save_area);
3366       }
3367
3368   highest_outgoing_arg_in_use = initial_highest_arg_in_use;
3369   stack_usage_map = initial_stack_usage_map;
3370 #endif
3371
3372   return value;
3373 }
3374 \f
3375 #if 0
3376 /* Return an rtx which represents a suitable home on the stack
3377    given TYPE, the type of the argument looking for a home.
3378    This is called only for BLKmode arguments.
3379
3380    SIZE is the size needed for this target.
3381    ARGS_ADDR is the address of the bottom of the argument block for this call.
3382    OFFSET describes this parameter's offset into ARGS_ADDR.  It is meaningless
3383    if this machine uses push insns.  */
3384
3385 static rtx
3386 target_for_arg (type, size, args_addr, offset)
3387      tree type;
3388      rtx size;
3389      rtx args_addr;
3390      struct args_size offset;
3391 {
3392   rtx target;
3393   rtx offset_rtx = ARGS_SIZE_RTX (offset);
3394
3395   /* We do not call memory_address if possible,
3396      because we want to address as close to the stack
3397      as possible.  For non-variable sized arguments,
3398      this will be stack-pointer relative addressing.  */
3399   if (GET_CODE (offset_rtx) == CONST_INT)
3400     target = plus_constant (args_addr, INTVAL (offset_rtx));
3401   else
3402     {
3403       /* I have no idea how to guarantee that this
3404          will work in the presence of register parameters.  */
3405       target = gen_rtx_PLUS (Pmode, args_addr, offset_rtx);
3406       target = memory_address (QImode, target);
3407     }
3408
3409   return gen_rtx_MEM (BLKmode, target);
3410 }
3411 #endif
3412 \f
3413 /* Store a single argument for a function call
3414    into the register or memory area where it must be passed.
3415    *ARG describes the argument value and where to pass it.
3416
3417    ARGBLOCK is the address of the stack-block for all the arguments,
3418    or 0 on a machine where arguments are pushed individually.
3419
3420    MAY_BE_ALLOCA nonzero says this could be a call to `alloca'
3421    so must be careful about how the stack is used. 
3422
3423    VARIABLE_SIZE nonzero says that this was a variable-sized outgoing
3424    argument stack.  This is used if ACCUMULATE_OUTGOING_ARGS to indicate
3425    that we need not worry about saving and restoring the stack.
3426
3427    FNDECL is the declaration of the function we are calling.  */
3428
3429 static void
3430 store_one_arg (arg, argblock, may_be_alloca, variable_size, fndecl,
3431                reg_parm_stack_space)
3432      struct arg_data *arg;
3433      rtx argblock;
3434      int may_be_alloca;
3435      int variable_size;
3436      tree fndecl;
3437      int reg_parm_stack_space;
3438 {
3439   register tree pval = arg->tree_value;
3440   rtx reg = 0;
3441   int partial = 0;
3442   int used = 0;
3443   int i, lower_bound, upper_bound;
3444
3445   if (TREE_CODE (pval) == ERROR_MARK)
3446     return;
3447
3448   /* Push a new temporary level for any temporaries we make for
3449      this argument.  */
3450   push_temp_slots ();
3451
3452 #ifdef ACCUMULATE_OUTGOING_ARGS
3453   /* If this is being stored into a pre-allocated, fixed-size, stack area,
3454      save any previous data at that location.  */
3455   if (argblock && ! variable_size && arg->stack)
3456     {
3457 #ifdef ARGS_GROW_DOWNWARD
3458       /* stack_slot is negative, but we want to index stack_usage_map
3459          with positive values.  */
3460       if (GET_CODE (XEXP (arg->stack_slot, 0)) == PLUS)
3461         upper_bound = -INTVAL (XEXP (XEXP (arg->stack_slot, 0), 1)) + 1;
3462       else
3463         upper_bound = 0;
3464
3465       lower_bound = upper_bound - arg->size.constant;
3466 #else
3467       if (GET_CODE (XEXP (arg->stack_slot, 0)) == PLUS)
3468         lower_bound = INTVAL (XEXP (XEXP (arg->stack_slot, 0), 1));
3469       else
3470         lower_bound = 0;
3471
3472       upper_bound = lower_bound + arg->size.constant;
3473 #endif
3474
3475       for (i = lower_bound; i < upper_bound; i++)
3476         if (stack_usage_map[i]
3477 #ifdef REG_PARM_STACK_SPACE
3478             /* Don't store things in the fixed argument area at this point;
3479                it has already been saved.  */
3480             && i > reg_parm_stack_space
3481 #endif
3482             )
3483           break;
3484
3485       if (i != upper_bound)
3486         {
3487           /* We need to make a save area.  See what mode we can make it.  */
3488           enum machine_mode save_mode
3489             = mode_for_size (arg->size.constant * BITS_PER_UNIT, MODE_INT, 1);
3490           rtx stack_area
3491             = gen_rtx_MEM (save_mode,
3492                            memory_address (save_mode,
3493                                            XEXP (arg->stack_slot, 0)));
3494
3495           if (save_mode == BLKmode)
3496             {
3497               arg->save_area = assign_stack_temp (BLKmode,
3498                                                   arg->size.constant, 0);
3499               MEM_IN_STRUCT_P (arg->save_area)
3500                 = AGGREGATE_TYPE_P (TREE_TYPE (arg->tree_value));
3501               preserve_temp_slots (arg->save_area);
3502               emit_block_move (validize_mem (arg->save_area), stack_area,
3503                                GEN_INT (arg->size.constant),
3504                                PARM_BOUNDARY / BITS_PER_UNIT);
3505             }
3506           else
3507             {
3508               arg->save_area = gen_reg_rtx (save_mode);
3509               emit_move_insn (arg->save_area, stack_area);
3510             }
3511         }
3512     }
3513 #endif
3514
3515   /* If this isn't going to be placed on both the stack and in registers,
3516      set up the register and number of words.  */
3517   if (! arg->pass_on_stack)
3518     reg = arg->reg, partial = arg->partial;
3519
3520   if (reg != 0 && partial == 0)
3521     /* Being passed entirely in a register.  We shouldn't be called in
3522        this case.   */
3523     abort ();
3524
3525   /* If this arg needs special alignment, don't load the registers
3526      here.  */
3527   if (arg->n_aligned_regs != 0)
3528     reg = 0;
3529   
3530   /* If this is being passed partially in a register, we can't evaluate
3531      it directly into its stack slot.  Otherwise, we can.  */
3532   if (arg->value == 0)
3533     {
3534 #ifdef ACCUMULATE_OUTGOING_ARGS
3535       /* stack_arg_under_construction is nonzero if a function argument is
3536          being evaluated directly into the outgoing argument list and
3537          expand_call must take special action to preserve the argument list
3538          if it is called recursively.
3539
3540          For scalar function arguments stack_usage_map is sufficient to
3541          determine which stack slots must be saved and restored.  Scalar
3542          arguments in general have pass_on_stack == 0.
3543
3544          If this argument is initialized by a function which takes the
3545          address of the argument (a C++ constructor or a C function
3546          returning a BLKmode structure), then stack_usage_map is
3547          insufficient and expand_call must push the stack around the
3548          function call.  Such arguments have pass_on_stack == 1.
3549
3550          Note that it is always safe to set stack_arg_under_construction,
3551          but this generates suboptimal code if set when not needed.  */
3552
3553       if (arg->pass_on_stack)
3554         stack_arg_under_construction++;
3555 #endif
3556       arg->value = expand_expr (pval,
3557                                 (partial
3558                                  || TYPE_MODE (TREE_TYPE (pval)) != arg->mode)
3559                                 ? NULL_RTX : arg->stack,
3560                                 VOIDmode, 0);
3561
3562       /* If we are promoting object (or for any other reason) the mode
3563          doesn't agree, convert the mode.  */
3564
3565       if (arg->mode != TYPE_MODE (TREE_TYPE (pval)))
3566         arg->value = convert_modes (arg->mode, TYPE_MODE (TREE_TYPE (pval)),
3567                                     arg->value, arg->unsignedp);
3568
3569 #ifdef ACCUMULATE_OUTGOING_ARGS
3570       if (arg->pass_on_stack)
3571         stack_arg_under_construction--;
3572 #endif
3573     }
3574
3575   /* Don't allow anything left on stack from computation
3576      of argument to alloca.  */
3577   if (may_be_alloca)
3578     do_pending_stack_adjust ();
3579
3580   if (arg->value == arg->stack)
3581     {
3582       /* If the value is already in the stack slot, we are done.  */
3583       if (flag_check_memory_usage && GET_CODE (arg->stack) == MEM)
3584         {
3585           if (arg->mode == BLKmode)
3586             abort ();
3587
3588           emit_library_call (chkr_set_right_libfunc, 1, VOIDmode, 3,
3589                              XEXP (arg->stack, 0), ptr_mode, 
3590                              GEN_INT (GET_MODE_SIZE (arg->mode)),
3591                              TYPE_MODE (sizetype),
3592                              GEN_INT (MEMORY_USE_RW),
3593                              TYPE_MODE (integer_type_node));
3594         }
3595     }
3596   else if (arg->mode != BLKmode)
3597     {
3598       register int size;
3599
3600       /* Argument is a scalar, not entirely passed in registers.
3601          (If part is passed in registers, arg->partial says how much
3602          and emit_push_insn will take care of putting it there.)
3603          
3604          Push it, and if its size is less than the
3605          amount of space allocated to it,
3606          also bump stack pointer by the additional space.
3607          Note that in C the default argument promotions
3608          will prevent such mismatches.  */
3609
3610       size = GET_MODE_SIZE (arg->mode);
3611       /* Compute how much space the push instruction will push.
3612          On many machines, pushing a byte will advance the stack
3613          pointer by a halfword.  */
3614 #ifdef PUSH_ROUNDING
3615       size = PUSH_ROUNDING (size);
3616 #endif
3617       used = size;
3618
3619       /* Compute how much space the argument should get:
3620          round up to a multiple of the alignment for arguments.  */
3621       if (none != FUNCTION_ARG_PADDING (arg->mode, TREE_TYPE (pval)))
3622         used = (((size + PARM_BOUNDARY / BITS_PER_UNIT - 1)
3623                  / (PARM_BOUNDARY / BITS_PER_UNIT))
3624                 * (PARM_BOUNDARY / BITS_PER_UNIT));
3625
3626       /* This isn't already where we want it on the stack, so put it there.
3627          This can either be done with push or copy insns.  */
3628       emit_push_insn (arg->value, arg->mode, TREE_TYPE (pval), NULL_RTX,
3629                       0, partial, reg, used - size,
3630                       argblock, ARGS_SIZE_RTX (arg->offset));
3631     }
3632   else
3633     {
3634       /* BLKmode, at least partly to be pushed.  */
3635
3636       register int excess;
3637       rtx size_rtx;
3638
3639       /* Pushing a nonscalar.
3640          If part is passed in registers, PARTIAL says how much
3641          and emit_push_insn will take care of putting it there.  */
3642
3643       /* Round its size up to a multiple
3644          of the allocation unit for arguments.  */
3645
3646       if (arg->size.var != 0)
3647         {
3648           excess = 0;
3649           size_rtx = ARGS_SIZE_RTX (arg->size);
3650         }
3651       else
3652         {
3653           /* PUSH_ROUNDING has no effect on us, because
3654              emit_push_insn for BLKmode is careful to avoid it.  */
3655           excess = (arg->size.constant - int_size_in_bytes (TREE_TYPE (pval))
3656                     + partial * UNITS_PER_WORD);
3657           size_rtx = expr_size (pval);
3658         }
3659
3660       emit_push_insn (arg->value, arg->mode, TREE_TYPE (pval), size_rtx,
3661                       TYPE_ALIGN (TREE_TYPE (pval)) / BITS_PER_UNIT, partial,
3662                       reg, excess, argblock, ARGS_SIZE_RTX (arg->offset));
3663     }
3664
3665
3666   /* Unless this is a partially-in-register argument, the argument is now
3667      in the stack. 
3668
3669      ??? Note that this can change arg->value from arg->stack to
3670      arg->stack_slot and it matters when they are not the same.
3671      It isn't totally clear that this is correct in all cases.  */
3672   if (partial == 0)
3673     arg->value = arg->stack_slot;
3674
3675   /* Once we have pushed something, pops can't safely
3676      be deferred during the rest of the arguments.  */
3677   NO_DEFER_POP;
3678
3679   /* ANSI doesn't require a sequence point here,
3680      but PCC has one, so this will avoid some problems.  */
3681   emit_queue ();
3682
3683   /* Free any temporary slots made in processing this argument.  Show
3684      that we might have taken the address of something and pushed that
3685      as an operand.  */
3686   preserve_temp_slots (NULL_RTX);
3687   free_temp_slots ();
3688   pop_temp_slots ();
3689
3690 #ifdef ACCUMULATE_OUTGOING_ARGS
3691   /* Now mark the segment we just used.  */
3692   if (argblock && ! variable_size && arg->stack)
3693     for (i = lower_bound; i < upper_bound; i++)
3694       stack_usage_map[i] = 1;
3695 #endif
3696 }