OSDN Git Service

* calls.c (expand_call): Don't confuse member functions named
[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       /* Exclude functions not at the file scope, or not `extern',
856          since they are not the magic functions we would otherwise
857          think they are.  */
858       && DECL_CONTEXT (fndecl) == NULL_TREE && TREE_PUBLIC (fndecl))
859     {
860       char *tname = name;
861
862       /* Disregard prefix _, __ or __x.  */
863       if (name[0] == '_')
864         {
865           if (name[1] == '_' && name[2] == 'x')
866             tname += 3;
867           else if (name[1] == '_')
868             tname += 2;
869           else
870             tname += 1;
871         }
872
873       if (tname[0] == 's')
874         {
875           returns_twice
876             = ((tname[1] == 'e'
877                 && (! strcmp (tname, "setjmp")
878                     || ! strcmp (tname, "setjmp_syscall")))
879                || (tname[1] == 'i'
880                    && ! strcmp (tname, "sigsetjmp"))
881                || (tname[1] == 'a'
882                    && ! strcmp (tname, "savectx")));
883           if (tname[1] == 'i'
884               && ! strcmp (tname, "siglongjmp"))
885             is_longjmp = 1;
886         }
887       else if ((tname[0] == 'q' && tname[1] == 's'
888                 && ! strcmp (tname, "qsetjmp"))
889                || (tname[0] == 'v' && tname[1] == 'f'
890                    && ! strcmp (tname, "vfork")))
891         returns_twice = 1;
892
893       else if (tname[0] == 'l' && tname[1] == 'o'
894                && ! strcmp (tname, "longjmp"))
895         is_longjmp = 1;
896       /* XXX should have "malloc" attribute on functions instead
897          of recognizing them by name.  */
898       else if (! strcmp (tname, "malloc")
899                || ! strcmp (tname, "calloc")
900                || ! strcmp (tname, "realloc")
901                || ! strcmp (tname, "__builtin_new")
902                || ! strcmp (tname, "__builtin_vec_new"))
903         is_malloc = 1;
904     }
905
906   if (may_be_alloca)
907     current_function_calls_alloca = 1;
908
909   /* Don't let pending stack adjusts add up to too much.
910      Also, do all pending adjustments now
911      if there is any chance this might be a call to alloca.  */
912
913   if (pending_stack_adjust >= 32
914       || (pending_stack_adjust > 0 && may_be_alloca))
915     do_pending_stack_adjust ();
916
917   /* Operand 0 is a pointer-to-function; get the type of the function.  */
918   funtype = TREE_TYPE (TREE_OPERAND (exp, 0));
919   if (TREE_CODE (funtype) != POINTER_TYPE)
920     abort ();
921   funtype = TREE_TYPE (funtype);
922
923   /* Push the temporary stack slot level so that we can free any temporaries
924      we make.  */
925   push_temp_slots ();
926
927   /* Start updating where the next arg would go.
928
929      On some machines (such as the PA) indirect calls have a different
930      calling convention than normal calls.  The last argument in
931      INIT_CUMULATIVE_ARGS tells the backend if this is an indirect call
932      or not.  */
933   INIT_CUMULATIVE_ARGS (args_so_far, funtype, NULL_RTX, (fndecl == 0));
934
935   /* If struct_value_rtx is 0, it means pass the address
936      as if it were an extra parameter.  */
937   if (structure_value_addr && struct_value_rtx == 0)
938     {
939       /* If structure_value_addr is a REG other than
940          virtual_outgoing_args_rtx, we can use always use it.  If it
941          is not a REG, we must always copy it into a register.
942          If it is virtual_outgoing_args_rtx, we must copy it to another
943          register in some cases.  */
944       rtx temp = (GET_CODE (structure_value_addr) != REG
945 #ifdef ACCUMULATE_OUTGOING_ARGS
946                   || (stack_arg_under_construction
947                       && structure_value_addr == virtual_outgoing_args_rtx)
948 #endif
949                   ? copy_addr_to_reg (structure_value_addr)
950                   : structure_value_addr);
951
952       actparms
953         = tree_cons (error_mark_node,
954                      make_tree (build_pointer_type (TREE_TYPE (funtype)),
955                                 temp),
956                      actparms);
957       structure_value_addr_parm = 1;
958     }
959
960   /* Count the arguments and set NUM_ACTUALS.  */
961   for (p = actparms, i = 0; p; p = TREE_CHAIN (p)) i++;
962   num_actuals = i;
963
964   /* Compute number of named args.
965      Normally, don't include the last named arg if anonymous args follow.
966      We do include the last named arg if STRICT_ARGUMENT_NAMING is defined.
967      (If no anonymous args follow, the result of list_length is actually
968      one too large.  This is harmless.)
969
970      If SETUP_INCOMING_VARARGS is defined and STRICT_ARGUMENT_NAMING is not,
971      this machine will be able to place unnamed args that were passed in
972      registers into the stack.  So treat all args as named.  This allows the
973      insns emitting for a specific argument list to be independent of the
974      function declaration.
975
976      If SETUP_INCOMING_VARARGS is not defined, we do not have any reliable
977      way to pass unnamed args in registers, so we must force them into
978      memory.  */
979 #if !defined(SETUP_INCOMING_VARARGS) || defined(STRICT_ARGUMENT_NAMING)
980   if (TYPE_ARG_TYPES (funtype) != 0)
981     n_named_args
982       = (list_length (TYPE_ARG_TYPES (funtype))
983 #ifndef STRICT_ARGUMENT_NAMING
984          /* Don't include the last named arg.  */
985          - 1
986 #endif
987          /* Count the struct value address, if it is passed as a parm.  */
988          + structure_value_addr_parm);
989   else
990 #endif
991     /* If we know nothing, treat all args as named.  */
992     n_named_args = num_actuals;
993
994   /* Make a vector to hold all the information about each arg.  */
995   args = (struct arg_data *) alloca (num_actuals * sizeof (struct arg_data));
996   bzero ((char *) args, num_actuals * sizeof (struct arg_data));
997
998   args_size.constant = 0;
999   args_size.var = 0;
1000
1001   /* In this loop, we consider args in the order they are written.
1002      We fill up ARGS from the front or from the back if necessary
1003      so that in any case the first arg to be pushed ends up at the front.  */
1004
1005 #ifdef PUSH_ARGS_REVERSED
1006   i = num_actuals - 1, inc = -1;
1007   /* In this case, must reverse order of args
1008      so that we compute and push the last arg first.  */
1009 #else
1010   i = 0, inc = 1;
1011 #endif
1012
1013   /* I counts args in order (to be) pushed; ARGPOS counts in order written.  */
1014   for (p = actparms, argpos = 0; p; p = TREE_CHAIN (p), i += inc, argpos++)
1015     {
1016       tree type = TREE_TYPE (TREE_VALUE (p));
1017       int unsignedp;
1018       enum machine_mode mode;
1019
1020       args[i].tree_value = TREE_VALUE (p);
1021
1022       /* Replace erroneous argument with constant zero.  */
1023       if (type == error_mark_node || TYPE_SIZE (type) == 0)
1024         args[i].tree_value = integer_zero_node, type = integer_type_node;
1025
1026       /* If TYPE is a transparent union, pass things the way we would
1027          pass the first field of the union.  We have already verified that
1028          the modes are the same.  */
1029       if (TYPE_TRANSPARENT_UNION (type))
1030         type = TREE_TYPE (TYPE_FIELDS (type));
1031
1032       /* Decide where to pass this arg.
1033
1034          args[i].reg is nonzero if all or part is passed in registers.
1035
1036          args[i].partial is nonzero if part but not all is passed in registers,
1037          and the exact value says how many words are passed in registers.
1038
1039          args[i].pass_on_stack is nonzero if the argument must at least be
1040          computed on the stack.  It may then be loaded back into registers
1041          if args[i].reg is nonzero.
1042
1043          These decisions are driven by the FUNCTION_... macros and must agree
1044          with those made by function.c.  */
1045
1046       /* See if this argument should be passed by invisible reference.  */
1047       if ((TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST
1048            && contains_placeholder_p (TYPE_SIZE (type)))
1049           || TREE_ADDRESSABLE (type)
1050 #ifdef FUNCTION_ARG_PASS_BY_REFERENCE
1051           || FUNCTION_ARG_PASS_BY_REFERENCE (args_so_far, TYPE_MODE (type),
1052                                              type, argpos < n_named_args)
1053 #endif
1054           )
1055         {
1056           /* If we're compiling a thunk, pass through invisible
1057              references instead of making a copy.  */
1058           if (current_function_is_thunk
1059 #ifdef FUNCTION_ARG_CALLEE_COPIES
1060               || (FUNCTION_ARG_CALLEE_COPIES (args_so_far, TYPE_MODE (type),
1061                                              type, argpos < n_named_args)
1062                   /* If it's in a register, we must make a copy of it too.  */
1063                   /* ??? Is this a sufficient test?  Is there a better one? */
1064                   && !(TREE_CODE (args[i].tree_value) == VAR_DECL
1065                        && REG_P (DECL_RTL (args[i].tree_value)))
1066                   && ! TREE_ADDRESSABLE (type))
1067 #endif
1068               )
1069             {
1070               args[i].tree_value = build1 (ADDR_EXPR,
1071                                            build_pointer_type (type),
1072                                            args[i].tree_value);
1073               type = build_pointer_type (type);
1074             }
1075           else
1076             {
1077               /* We make a copy of the object and pass the address to the
1078                  function being called.  */
1079               rtx copy;
1080
1081               if (TYPE_SIZE (type) == 0
1082                   || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST
1083                   || (flag_stack_check && ! STACK_CHECK_BUILTIN
1084                       && (TREE_INT_CST_HIGH (TYPE_SIZE (type)) != 0
1085                           || (TREE_INT_CST_LOW (TYPE_SIZE (type))
1086                               > STACK_CHECK_MAX_VAR_SIZE * BITS_PER_UNIT))))
1087                 {
1088                   /* This is a variable-sized object.  Make space on the stack
1089                      for it.  */
1090                   rtx size_rtx = expr_size (TREE_VALUE (p));
1091
1092                   if (old_stack_level == 0)
1093                     {
1094                       emit_stack_save (SAVE_BLOCK, &old_stack_level, NULL_RTX);
1095                       old_pending_adj = pending_stack_adjust;
1096                       pending_stack_adjust = 0;
1097                     }
1098
1099                   copy = gen_rtx_MEM (BLKmode,
1100                                       allocate_dynamic_stack_space (size_rtx,
1101                                                                     NULL_RTX,
1102                                                                     TYPE_ALIGN (type)));
1103                 }
1104               else
1105                 {
1106                   int size = int_size_in_bytes (type);
1107                   copy = assign_stack_temp (TYPE_MODE (type), size, 0);
1108                 }
1109
1110               MEM_IN_STRUCT_P (copy) = AGGREGATE_TYPE_P (type);
1111
1112               store_expr (args[i].tree_value, copy, 0);
1113               is_const = 0;
1114
1115               args[i].tree_value = build1 (ADDR_EXPR,
1116                                            build_pointer_type (type),
1117                                            make_tree (type, copy));
1118               type = build_pointer_type (type);
1119             }
1120         }
1121
1122       mode = TYPE_MODE (type);
1123       unsignedp = TREE_UNSIGNED (type);
1124
1125 #ifdef PROMOTE_FUNCTION_ARGS
1126       mode = promote_mode (type, mode, &unsignedp, 1);
1127 #endif
1128
1129       args[i].unsignedp = unsignedp;
1130       args[i].mode = mode;
1131       args[i].reg = FUNCTION_ARG (args_so_far, mode, type,
1132                                   argpos < n_named_args);
1133 #ifdef FUNCTION_ARG_PARTIAL_NREGS
1134       if (args[i].reg)
1135         args[i].partial
1136           = FUNCTION_ARG_PARTIAL_NREGS (args_so_far, mode, type,
1137                                         argpos < n_named_args);
1138 #endif
1139
1140       args[i].pass_on_stack = MUST_PASS_IN_STACK (mode, type);
1141
1142       /* If FUNCTION_ARG returned a (parallel [(expr_list (nil) ...) ...]),
1143          it means that we are to pass this arg in the register(s) designated
1144          by the PARALLEL, but also to pass it in the stack.  */
1145       if (args[i].reg && GET_CODE (args[i].reg) == PARALLEL
1146           && XEXP (XVECEXP (args[i].reg, 0, 0), 0) == 0)
1147         args[i].pass_on_stack = 1;
1148
1149       /* If this is an addressable type, we must preallocate the stack
1150          since we must evaluate the object into its final location.
1151
1152          If this is to be passed in both registers and the stack, it is simpler
1153          to preallocate.  */
1154       if (TREE_ADDRESSABLE (type)
1155           || (args[i].pass_on_stack && args[i].reg != 0))
1156         must_preallocate = 1;
1157
1158       /* If this is an addressable type, we cannot pre-evaluate it.  Thus,
1159          we cannot consider this function call constant.  */
1160       if (TREE_ADDRESSABLE (type))
1161         is_const = 0;
1162
1163       /* Compute the stack-size of this argument.  */
1164       if (args[i].reg == 0 || args[i].partial != 0
1165 #ifdef REG_PARM_STACK_SPACE
1166           || reg_parm_stack_space > 0
1167 #endif
1168           || args[i].pass_on_stack)
1169         locate_and_pad_parm (mode, type,
1170 #ifdef STACK_PARMS_IN_REG_PARM_AREA
1171                              1,
1172 #else
1173                              args[i].reg != 0,
1174 #endif
1175                              fndecl, &args_size, &args[i].offset,
1176                              &args[i].size);
1177
1178 #ifndef ARGS_GROW_DOWNWARD
1179       args[i].slot_offset = args_size;
1180 #endif
1181
1182 #ifndef REG_PARM_STACK_SPACE
1183       /* If a part of the arg was put into registers,
1184          don't include that part in the amount pushed.  */
1185       if (! args[i].pass_on_stack)
1186         args[i].size.constant -= ((args[i].partial * UNITS_PER_WORD)
1187                                   / (PARM_BOUNDARY / BITS_PER_UNIT)
1188                                   * (PARM_BOUNDARY / BITS_PER_UNIT));
1189 #endif
1190       
1191       /* Update ARGS_SIZE, the total stack space for args so far.  */
1192
1193       args_size.constant += args[i].size.constant;
1194       if (args[i].size.var)
1195         {
1196           ADD_PARM_SIZE (args_size, args[i].size.var);
1197         }
1198
1199       /* Since the slot offset points to the bottom of the slot,
1200          we must record it after incrementing if the args grow down.  */
1201 #ifdef ARGS_GROW_DOWNWARD
1202       args[i].slot_offset = args_size;
1203
1204       args[i].slot_offset.constant = -args_size.constant;
1205       if (args_size.var)
1206         {
1207           SUB_PARM_SIZE (args[i].slot_offset, args_size.var);
1208         }
1209 #endif
1210
1211       /* Increment ARGS_SO_FAR, which has info about which arg-registers
1212          have been used, etc.  */
1213
1214       FUNCTION_ARG_ADVANCE (args_so_far, TYPE_MODE (type), type,
1215                             argpos < n_named_args);
1216     }
1217
1218 #ifdef FINAL_REG_PARM_STACK_SPACE
1219   reg_parm_stack_space = FINAL_REG_PARM_STACK_SPACE (args_size.constant,
1220                                                      args_size.var);
1221 #endif
1222       
1223   /* Compute the actual size of the argument block required.  The variable
1224      and constant sizes must be combined, the size may have to be rounded,
1225      and there may be a minimum required size.  */
1226
1227   original_args_size = args_size;
1228   if (args_size.var)
1229     {
1230       /* If this function requires a variable-sized argument list, don't try to
1231          make a cse'able block for this call.  We may be able to do this
1232          eventually, but it is too complicated to keep track of what insns go
1233          in the cse'able block and which don't.  */
1234
1235       is_const = 0;
1236       must_preallocate = 1;
1237
1238       args_size.var = ARGS_SIZE_TREE (args_size);
1239       args_size.constant = 0;
1240
1241 #ifdef STACK_BOUNDARY
1242       if (STACK_BOUNDARY != BITS_PER_UNIT)
1243         args_size.var = round_up (args_size.var, STACK_BYTES);
1244 #endif
1245
1246 #ifdef REG_PARM_STACK_SPACE
1247       if (reg_parm_stack_space > 0)
1248         {
1249           args_size.var
1250             = size_binop (MAX_EXPR, args_size.var,
1251                           size_int (REG_PARM_STACK_SPACE (fndecl)));
1252
1253 #ifndef OUTGOING_REG_PARM_STACK_SPACE
1254           /* The area corresponding to register parameters is not to count in
1255              the size of the block we need.  So make the adjustment.  */
1256           args_size.var
1257             = size_binop (MINUS_EXPR, args_size.var,
1258                           size_int (reg_parm_stack_space));
1259 #endif
1260         }
1261 #endif
1262     }
1263   else
1264     {
1265 #ifdef STACK_BOUNDARY
1266       args_size.constant = (((args_size.constant + (STACK_BYTES - 1))
1267                              / STACK_BYTES) * STACK_BYTES);
1268 #endif
1269
1270 #ifdef REG_PARM_STACK_SPACE
1271       args_size.constant = MAX (args_size.constant,
1272                                 reg_parm_stack_space);
1273 #ifdef MAYBE_REG_PARM_STACK_SPACE
1274       if (reg_parm_stack_space == 0)
1275         args_size.constant = 0;
1276 #endif
1277 #ifndef OUTGOING_REG_PARM_STACK_SPACE
1278       args_size.constant -= reg_parm_stack_space;
1279 #endif
1280 #endif
1281     }
1282
1283   /* See if we have or want to preallocate stack space.
1284
1285      If we would have to push a partially-in-regs parm
1286      before other stack parms, preallocate stack space instead.
1287
1288      If the size of some parm is not a multiple of the required stack
1289      alignment, we must preallocate.
1290
1291      If the total size of arguments that would otherwise create a copy in
1292      a temporary (such as a CALL) is more than half the total argument list
1293      size, preallocation is faster.
1294
1295      Another reason to preallocate is if we have a machine (like the m88k)
1296      where stack alignment is required to be maintained between every
1297      pair of insns, not just when the call is made.  However, we assume here
1298      that such machines either do not have push insns (and hence preallocation
1299      would occur anyway) or the problem is taken care of with
1300      PUSH_ROUNDING.  */
1301
1302   if (! must_preallocate)
1303     {
1304       int partial_seen = 0;
1305       int copy_to_evaluate_size = 0;
1306
1307       for (i = 0; i < num_actuals && ! must_preallocate; i++)
1308         {
1309           if (args[i].partial > 0 && ! args[i].pass_on_stack)
1310             partial_seen = 1;
1311           else if (partial_seen && args[i].reg == 0)
1312             must_preallocate = 1;
1313
1314           if (TYPE_MODE (TREE_TYPE (args[i].tree_value)) == BLKmode
1315               && (TREE_CODE (args[i].tree_value) == CALL_EXPR
1316                   || TREE_CODE (args[i].tree_value) == TARGET_EXPR
1317                   || TREE_CODE (args[i].tree_value) == COND_EXPR
1318                   || TREE_ADDRESSABLE (TREE_TYPE (args[i].tree_value))))
1319             copy_to_evaluate_size
1320               += int_size_in_bytes (TREE_TYPE (args[i].tree_value));
1321         }
1322
1323       if (copy_to_evaluate_size * 2 >= args_size.constant
1324           && args_size.constant > 0)
1325         must_preallocate = 1;
1326     }
1327
1328   /* If the structure value address will reference the stack pointer, we must
1329      stabilize it.  We don't need to do this if we know that we are not going
1330      to adjust the stack pointer in processing this call.  */
1331
1332   if (structure_value_addr
1333       && (reg_mentioned_p (virtual_stack_dynamic_rtx, structure_value_addr)
1334        || reg_mentioned_p (virtual_outgoing_args_rtx, structure_value_addr))
1335       && (args_size.var
1336 #ifndef ACCUMULATE_OUTGOING_ARGS
1337           || args_size.constant
1338 #endif
1339           ))
1340     structure_value_addr = copy_to_reg (structure_value_addr);
1341
1342   /* If this function call is cse'able, precompute all the parameters.
1343      Note that if the parameter is constructed into a temporary, this will
1344      cause an additional copy because the parameter will be constructed
1345      into a temporary location and then copied into the outgoing arguments.
1346      If a parameter contains a call to alloca and this function uses the
1347      stack, precompute the parameter.  */
1348
1349   /* If we preallocated the stack space, and some arguments must be passed
1350      on the stack, then we must precompute any parameter which contains a
1351      function call which will store arguments on the stack.
1352      Otherwise, evaluating the parameter may clobber previous parameters
1353      which have already been stored into the stack.  */
1354
1355   for (i = 0; i < num_actuals; i++)
1356     if (is_const
1357         || ((args_size.var != 0 || args_size.constant != 0)
1358             && calls_function (args[i].tree_value, 1))
1359         || (must_preallocate && (args_size.var != 0 || args_size.constant != 0)
1360             && calls_function (args[i].tree_value, 0)))
1361       {
1362         /* If this is an addressable type, we cannot pre-evaluate it.  */
1363         if (TREE_ADDRESSABLE (TREE_TYPE (args[i].tree_value)))
1364           abort ();
1365
1366         push_temp_slots ();
1367
1368         args[i].initial_value = args[i].value
1369           = expand_expr (args[i].tree_value, NULL_RTX, VOIDmode, 0);
1370
1371         preserve_temp_slots (args[i].value);
1372         pop_temp_slots ();
1373
1374         /* ANSI doesn't require a sequence point here,
1375            but PCC has one, so this will avoid some problems.  */
1376         emit_queue ();
1377
1378         args[i].initial_value = args[i].value
1379           = protect_from_queue (args[i].initial_value, 0);
1380
1381         if (TYPE_MODE (TREE_TYPE (args[i].tree_value)) != args[i].mode)
1382           args[i].value
1383             = convert_modes (args[i].mode, 
1384                              TYPE_MODE (TREE_TYPE (args[i].tree_value)),
1385                              args[i].value, args[i].unsignedp);
1386       }
1387
1388   /* Now we are about to start emitting insns that can be deleted
1389      if a libcall is deleted.  */
1390   if (is_const || is_malloc)
1391     start_sequence ();
1392
1393   /* If we have no actual push instructions, or shouldn't use them,
1394      make space for all args right now.  */
1395
1396   if (args_size.var != 0)
1397     {
1398       if (old_stack_level == 0)
1399         {
1400           emit_stack_save (SAVE_BLOCK, &old_stack_level, NULL_RTX);
1401           old_pending_adj = pending_stack_adjust;
1402           pending_stack_adjust = 0;
1403 #ifdef ACCUMULATE_OUTGOING_ARGS
1404           /* stack_arg_under_construction says whether a stack arg is
1405              being constructed at the old stack level.  Pushing the stack
1406              gets a clean outgoing argument block.  */
1407           old_stack_arg_under_construction = stack_arg_under_construction;
1408           stack_arg_under_construction = 0;
1409 #endif
1410         }
1411       argblock = push_block (ARGS_SIZE_RTX (args_size), 0, 0);
1412     }
1413   else
1414     {
1415       /* Note that we must go through the motions of allocating an argument
1416          block even if the size is zero because we may be storing args
1417          in the area reserved for register arguments, which may be part of
1418          the stack frame.  */
1419
1420       int needed = args_size.constant;
1421
1422       /* Store the maximum argument space used.  It will be pushed by
1423          the prologue (if ACCUMULATE_OUTGOING_ARGS, or stack overflow
1424          checking).  */
1425
1426       if (needed > current_function_outgoing_args_size)
1427         current_function_outgoing_args_size = needed;
1428
1429       if (must_preallocate)
1430         {
1431 #ifdef ACCUMULATE_OUTGOING_ARGS
1432           /* Since the stack pointer will never be pushed, it is possible for
1433              the evaluation of a parm to clobber something we have already
1434              written to the stack.  Since most function calls on RISC machines
1435              do not use the stack, this is uncommon, but must work correctly.
1436
1437              Therefore, we save any area of the stack that was already written
1438              and that we are using.  Here we set up to do this by making a new
1439              stack usage map from the old one.  The actual save will be done
1440              by store_one_arg. 
1441
1442              Another approach might be to try to reorder the argument
1443              evaluations to avoid this conflicting stack usage.  */
1444
1445 #if defined(REG_PARM_STACK_SPACE) && ! defined(OUTGOING_REG_PARM_STACK_SPACE)
1446           /* Since we will be writing into the entire argument area, the
1447              map must be allocated for its entire size, not just the part that
1448              is the responsibility of the caller.  */
1449           needed += reg_parm_stack_space;
1450 #endif
1451
1452 #ifdef ARGS_GROW_DOWNWARD
1453           highest_outgoing_arg_in_use = MAX (initial_highest_arg_in_use,
1454                                              needed + 1);
1455 #else
1456           highest_outgoing_arg_in_use = MAX (initial_highest_arg_in_use,
1457                                              needed);
1458 #endif
1459           stack_usage_map = (char *) alloca (highest_outgoing_arg_in_use);
1460
1461           if (initial_highest_arg_in_use)
1462             bcopy (initial_stack_usage_map, stack_usage_map,
1463                    initial_highest_arg_in_use);
1464
1465           if (initial_highest_arg_in_use != highest_outgoing_arg_in_use)
1466             bzero (&stack_usage_map[initial_highest_arg_in_use],
1467                    highest_outgoing_arg_in_use - initial_highest_arg_in_use);
1468           needed = 0;
1469
1470           /* The address of the outgoing argument list must not be copied to a
1471              register here, because argblock would be left pointing to the
1472              wrong place after the call to allocate_dynamic_stack_space below.
1473              */
1474
1475           argblock = virtual_outgoing_args_rtx;
1476
1477 #else /* not ACCUMULATE_OUTGOING_ARGS */
1478           if (inhibit_defer_pop == 0)
1479             {
1480               /* Try to reuse some or all of the pending_stack_adjust
1481                  to get this space.  Maybe we can avoid any pushing.  */
1482               if (needed > pending_stack_adjust)
1483                 {
1484                   needed -= pending_stack_adjust;
1485                   pending_stack_adjust = 0;
1486                 }
1487               else
1488                 {
1489                   pending_stack_adjust -= needed;
1490                   needed = 0;
1491                 }
1492             }
1493           /* Special case this because overhead of `push_block' in this
1494              case is non-trivial.  */
1495           if (needed == 0)
1496             argblock = virtual_outgoing_args_rtx;
1497           else
1498             argblock = push_block (GEN_INT (needed), 0, 0);
1499
1500           /* We only really need to call `copy_to_reg' in the case where push
1501              insns are going to be used to pass ARGBLOCK to a function
1502              call in ARGS.  In that case, the stack pointer changes value
1503              from the allocation point to the call point, and hence
1504              the value of VIRTUAL_OUTGOING_ARGS_RTX changes as well.
1505              But might as well always do it.  */
1506           argblock = copy_to_reg (argblock);
1507 #endif /* not ACCUMULATE_OUTGOING_ARGS */
1508         }
1509     }
1510
1511 #ifdef ACCUMULATE_OUTGOING_ARGS
1512   /* The save/restore code in store_one_arg handles all cases except one:
1513      a constructor call (including a C function returning a BLKmode struct)
1514      to initialize an argument.  */
1515   if (stack_arg_under_construction)
1516     {
1517 #if defined(REG_PARM_STACK_SPACE) && ! defined(OUTGOING_REG_PARM_STACK_SPACE)
1518       rtx push_size = GEN_INT (reg_parm_stack_space + args_size.constant);
1519 #else
1520       rtx push_size = GEN_INT (args_size.constant);
1521 #endif
1522       if (old_stack_level == 0)
1523         {
1524           emit_stack_save (SAVE_BLOCK, &old_stack_level, NULL_RTX);
1525           old_pending_adj = pending_stack_adjust;
1526           pending_stack_adjust = 0;
1527           /* stack_arg_under_construction says whether a stack arg is
1528              being constructed at the old stack level.  Pushing the stack
1529              gets a clean outgoing argument block.  */
1530           old_stack_arg_under_construction = stack_arg_under_construction;
1531           stack_arg_under_construction = 0;
1532           /* Make a new map for the new argument list.  */
1533           stack_usage_map = (char *)alloca (highest_outgoing_arg_in_use);
1534           bzero (stack_usage_map, highest_outgoing_arg_in_use);
1535           highest_outgoing_arg_in_use = 0;
1536         }
1537       allocate_dynamic_stack_space (push_size, NULL_RTX, BITS_PER_UNIT);
1538     }
1539   /* If argument evaluation might modify the stack pointer, copy the
1540      address of the argument list to a register.  */
1541   for (i = 0; i < num_actuals; i++)
1542     if (args[i].pass_on_stack)
1543       {
1544         argblock = copy_addr_to_reg (argblock);
1545         break;
1546       }
1547 #endif
1548
1549
1550   /* If we preallocated stack space, compute the address of each argument.
1551      We need not ensure it is a valid memory address here; it will be 
1552      validized when it is used.  */
1553   if (argblock)
1554     {
1555       rtx arg_reg = argblock;
1556       int arg_offset = 0;
1557
1558       if (GET_CODE (argblock) == PLUS)
1559         arg_reg = XEXP (argblock, 0), arg_offset = INTVAL (XEXP (argblock, 1));
1560
1561       for (i = 0; i < num_actuals; i++)
1562         {
1563           rtx offset = ARGS_SIZE_RTX (args[i].offset);
1564           rtx slot_offset = ARGS_SIZE_RTX (args[i].slot_offset);
1565           rtx addr;
1566
1567           /* Skip this parm if it will not be passed on the stack.  */
1568           if (! args[i].pass_on_stack && args[i].reg != 0)
1569             continue;
1570
1571           if (GET_CODE (offset) == CONST_INT)
1572             addr = plus_constant (arg_reg, INTVAL (offset));
1573           else
1574             addr = gen_rtx_PLUS (Pmode, arg_reg, offset);
1575
1576           addr = plus_constant (addr, arg_offset);
1577           args[i].stack = gen_rtx_MEM (args[i].mode, addr);
1578           MEM_IN_STRUCT_P (args[i].stack)
1579             = AGGREGATE_TYPE_P (TREE_TYPE (args[i].tree_value));
1580
1581           if (GET_CODE (slot_offset) == CONST_INT)
1582             addr = plus_constant (arg_reg, INTVAL (slot_offset));
1583           else
1584             addr = gen_rtx_PLUS (Pmode, arg_reg, slot_offset);
1585
1586           addr = plus_constant (addr, arg_offset);
1587           args[i].stack_slot = gen_rtx_MEM (args[i].mode, addr);
1588         }
1589     }
1590                                                
1591 #ifdef PUSH_ARGS_REVERSED
1592 #ifdef STACK_BOUNDARY
1593   /* If we push args individually in reverse order, perform stack alignment
1594      before the first push (the last arg).  */
1595   if (argblock == 0)
1596     anti_adjust_stack (GEN_INT (args_size.constant
1597                                 - original_args_size.constant));
1598 #endif
1599 #endif
1600
1601   /* Don't try to defer pops if preallocating, not even from the first arg,
1602      since ARGBLOCK probably refers to the SP.  */
1603   if (argblock)
1604     NO_DEFER_POP;
1605
1606   /* Get the function to call, in the form of RTL.  */
1607   if (fndecl)
1608     {
1609       /* If this is the first use of the function, see if we need to
1610          make an external definition for it.  */
1611       if (! TREE_USED (fndecl))
1612         {
1613           assemble_external (fndecl);
1614           TREE_USED (fndecl) = 1;
1615         }
1616
1617       /* Get a SYMBOL_REF rtx for the function address.  */
1618       funexp = XEXP (DECL_RTL (fndecl), 0);
1619     }
1620   else
1621     /* Generate an rtx (probably a pseudo-register) for the address.  */
1622     {
1623       push_temp_slots ();
1624       funexp = expand_expr (TREE_OPERAND (exp, 0), NULL_RTX, VOIDmode, 0);
1625       pop_temp_slots ();        /* FUNEXP can't be BLKmode */
1626
1627       /* Check the function is executable.  */
1628       if (flag_check_memory_usage)
1629         emit_library_call (chkr_check_exec_libfunc, 1,
1630                            VOIDmode, 1,
1631                            funexp, ptr_mode);
1632       emit_queue ();
1633     }
1634
1635   /* Figure out the register where the value, if any, will come back.  */
1636   valreg = 0;
1637   if (TYPE_MODE (TREE_TYPE (exp)) != VOIDmode
1638       && ! structure_value_addr)
1639     {
1640       if (pcc_struct_value)
1641         valreg = hard_function_value (build_pointer_type (TREE_TYPE (exp)),
1642                                       fndecl);
1643       else
1644         valreg = hard_function_value (TREE_TYPE (exp), fndecl);
1645     }
1646
1647   /* Precompute all register parameters.  It isn't safe to compute anything
1648      once we have started filling any specific hard regs.  */
1649   reg_parm_seen = 0;
1650   for (i = 0; i < num_actuals; i++)
1651     if (args[i].reg != 0 && ! args[i].pass_on_stack)
1652       {
1653         reg_parm_seen = 1;
1654
1655         if (args[i].value == 0)
1656           {
1657             push_temp_slots ();
1658             args[i].value = expand_expr (args[i].tree_value, NULL_RTX,
1659                                          VOIDmode, 0);
1660             preserve_temp_slots (args[i].value);
1661             pop_temp_slots ();
1662
1663             /* ANSI doesn't require a sequence point here,
1664                but PCC has one, so this will avoid some problems.  */
1665             emit_queue ();
1666           }
1667
1668         /* If we are to promote the function arg to a wider mode,
1669            do it now.  */
1670
1671         if (args[i].mode != TYPE_MODE (TREE_TYPE (args[i].tree_value)))
1672           args[i].value
1673             = convert_modes (args[i].mode,
1674                              TYPE_MODE (TREE_TYPE (args[i].tree_value)),
1675                              args[i].value, args[i].unsignedp);
1676
1677         /* If the value is expensive, and we are inside an appropriately 
1678            short loop, put the value into a pseudo and then put the pseudo
1679            into the hard reg.
1680
1681            For small register classes, also do this if this call uses
1682            register parameters.  This is to avoid reload conflicts while
1683            loading the parameters registers.  */
1684
1685         if ((! (GET_CODE (args[i].value) == REG
1686                 || (GET_CODE (args[i].value) == SUBREG
1687                     && GET_CODE (SUBREG_REG (args[i].value)) == REG)))
1688             && args[i].mode != BLKmode
1689             && rtx_cost (args[i].value, SET) > 2
1690             && ((SMALL_REGISTER_CLASSES && reg_parm_seen)
1691                 || preserve_subexpressions_p ()))
1692           args[i].value = copy_to_mode_reg (args[i].mode, args[i].value);
1693       }
1694
1695 #if defined(ACCUMULATE_OUTGOING_ARGS) && defined(REG_PARM_STACK_SPACE)
1696   /* The argument list is the property of the called routine and it
1697      may clobber it.  If the fixed area has been used for previous
1698      parameters, we must save and restore it.
1699
1700      Here we compute the boundary of the that needs to be saved, if any.  */
1701
1702 #ifdef ARGS_GROW_DOWNWARD
1703   for (i = 0; i < reg_parm_stack_space + 1; i++)
1704 #else
1705   for (i = 0; i < reg_parm_stack_space; i++)
1706 #endif
1707     {
1708       if (i >=  highest_outgoing_arg_in_use
1709           || stack_usage_map[i] == 0)
1710         continue;
1711
1712       if (low_to_save == -1)
1713         low_to_save = i;
1714
1715       high_to_save = i;
1716     }
1717
1718   if (low_to_save >= 0)
1719     {
1720       int num_to_save = high_to_save - low_to_save + 1;
1721       enum machine_mode save_mode
1722         = mode_for_size (num_to_save * BITS_PER_UNIT, MODE_INT, 1);
1723       rtx stack_area;
1724
1725       /* If we don't have the required alignment, must do this in BLKmode.  */
1726       if ((low_to_save & (MIN (GET_MODE_SIZE (save_mode),
1727                                BIGGEST_ALIGNMENT / UNITS_PER_WORD) - 1)))
1728         save_mode = BLKmode;
1729
1730 #ifdef ARGS_GROW_DOWNWARD
1731       stack_area = gen_rtx_MEM (save_mode,
1732                                 memory_address (save_mode,
1733                                                 plus_constant (argblock,
1734                                                                - high_to_save)));
1735 #else
1736       stack_area = gen_rtx_MEM (save_mode,
1737                                 memory_address (save_mode,
1738                                                 plus_constant (argblock,
1739                                                                low_to_save)));
1740 #endif
1741       if (save_mode == BLKmode)
1742         {
1743           save_area = assign_stack_temp (BLKmode, num_to_save, 0);
1744           MEM_IN_STRUCT_P (save_area) = 0;
1745           emit_block_move (validize_mem (save_area), stack_area,
1746                            GEN_INT (num_to_save),
1747                            PARM_BOUNDARY / BITS_PER_UNIT);
1748         }
1749       else
1750         {
1751           save_area = gen_reg_rtx (save_mode);
1752           emit_move_insn (save_area, stack_area);
1753         }
1754     }
1755 #endif
1756           
1757
1758   /* Now store (and compute if necessary) all non-register parms.
1759      These come before register parms, since they can require block-moves,
1760      which could clobber the registers used for register parms.
1761      Parms which have partial registers are not stored here,
1762      but we do preallocate space here if they want that.  */
1763
1764   for (i = 0; i < num_actuals; i++)
1765     if (args[i].reg == 0 || args[i].pass_on_stack)
1766       store_one_arg (&args[i], argblock, may_be_alloca,
1767                      args_size.var != 0, fndecl, reg_parm_stack_space);
1768
1769   /* If we have a parm that is passed in registers but not in memory
1770      and whose alignment does not permit a direct copy into registers,
1771      make a group of pseudos that correspond to each register that we
1772      will later fill.  */
1773
1774   if (STRICT_ALIGNMENT)
1775     for (i = 0; i < num_actuals; i++)
1776       if (args[i].reg != 0 && ! args[i].pass_on_stack
1777         && args[i].mode == BLKmode
1778           && (TYPE_ALIGN (TREE_TYPE (args[i].tree_value))
1779               < MIN (BIGGEST_ALIGNMENT, BITS_PER_WORD)))
1780         {
1781           int bytes = int_size_in_bytes (TREE_TYPE (args[i].tree_value));
1782           int big_endian_correction = 0;
1783
1784           args[i].n_aligned_regs
1785             = args[i].partial ? args[i].partial
1786               : (bytes + (UNITS_PER_WORD - 1)) / UNITS_PER_WORD;
1787
1788           args[i].aligned_regs = (rtx *) alloca (sizeof (rtx)
1789                                                  * args[i].n_aligned_regs);
1790
1791           /* Structures smaller than a word are aligned to the least
1792              significant byte (to the right).  On a BYTES_BIG_ENDIAN machine,
1793              this means we must skip the empty high order bytes when
1794              calculating the bit offset.  */
1795           if (BYTES_BIG_ENDIAN && bytes < UNITS_PER_WORD)
1796             big_endian_correction = (BITS_PER_WORD  - (bytes * BITS_PER_UNIT));
1797
1798           for (j = 0; j < args[i].n_aligned_regs; j++)
1799             {
1800               rtx reg = gen_reg_rtx (word_mode);
1801               rtx word = operand_subword_force (args[i].value, j, BLKmode);
1802               int bitsize = TYPE_ALIGN (TREE_TYPE (args[i].tree_value));
1803               int bitpos;
1804
1805               args[i].aligned_regs[j] = reg;
1806
1807               /* Clobber REG and move each partword into it.  Ensure we don't
1808                  go past the end of the structure.  Note that the loop below
1809                  works because we've already verified that padding
1810                  and endianness are compatible.
1811
1812                  We use to emit a clobber here but that doesn't let later
1813                  passes optimize the instructions we emit.  By storing 0 into
1814                  the register later passes know the first AND to zero out the
1815                  bitfield being set in the register is unnecessary.  The store
1816                  of 0 will be deleted as will at least the first AND.  */
1817
1818               emit_move_insn (reg, const0_rtx);
1819
1820               for (bitpos = 0;
1821                    bitpos < BITS_PER_WORD && bytes > 0;
1822                    bitpos += bitsize, bytes -= bitsize / BITS_PER_UNIT)
1823                 {
1824                   int xbitpos = bitpos + big_endian_correction;
1825
1826                   store_bit_field (reg, bitsize, xbitpos, word_mode,
1827                                    extract_bit_field (word, bitsize, bitpos, 1,
1828                                                       NULL_RTX, word_mode,
1829                                                       word_mode,
1830                                                       bitsize / BITS_PER_UNIT,
1831                                                       BITS_PER_WORD),
1832                                    bitsize / BITS_PER_UNIT, BITS_PER_WORD);
1833                 }
1834             }
1835         }
1836
1837   /* Now store any partially-in-registers parm.
1838      This is the last place a block-move can happen.  */
1839   if (reg_parm_seen)
1840     for (i = 0; i < num_actuals; i++)
1841       if (args[i].partial != 0 && ! args[i].pass_on_stack)
1842         store_one_arg (&args[i], argblock, may_be_alloca,
1843                        args_size.var != 0, fndecl, reg_parm_stack_space);
1844
1845 #ifndef PUSH_ARGS_REVERSED
1846 #ifdef STACK_BOUNDARY
1847   /* If we pushed args in forward order, perform stack alignment
1848      after pushing the last arg.  */
1849   if (argblock == 0)
1850     anti_adjust_stack (GEN_INT (args_size.constant
1851                                 - original_args_size.constant));
1852 #endif
1853 #endif
1854
1855   /* If register arguments require space on the stack and stack space
1856      was not preallocated, allocate stack space here for arguments
1857      passed in registers.  */
1858 #if ! defined(ACCUMULATE_OUTGOING_ARGS) && defined(OUTGOING_REG_PARM_STACK_SPACE)
1859   if (must_preallocate == 0 && reg_parm_stack_space > 0)
1860     anti_adjust_stack (GEN_INT (reg_parm_stack_space));
1861 #endif
1862
1863   /* Pass the function the address in which to return a structure value.  */
1864   if (structure_value_addr && ! structure_value_addr_parm)
1865     {
1866       emit_move_insn (struct_value_rtx,
1867                       force_reg (Pmode,
1868                                  force_operand (structure_value_addr,
1869                                                 NULL_RTX)));
1870
1871       /* Mark the memory for the aggregate as write-only.  */
1872       if (flag_check_memory_usage)
1873         emit_library_call (chkr_set_right_libfunc, 1,
1874                            VOIDmode, 3,
1875                            structure_value_addr, ptr_mode, 
1876                            GEN_INT (struct_value_size), TYPE_MODE (sizetype),
1877                            GEN_INT (MEMORY_USE_WO),
1878                            TYPE_MODE (integer_type_node));
1879
1880       if (GET_CODE (struct_value_rtx) == REG)
1881           use_reg (&call_fusage, struct_value_rtx);
1882     }
1883
1884   funexp = prepare_call_address (funexp, fndecl, &call_fusage, reg_parm_seen);
1885
1886   /* Now do the register loads required for any wholly-register parms or any
1887      parms which are passed both on the stack and in a register.  Their
1888      expressions were already evaluated. 
1889
1890      Mark all register-parms as living through the call, putting these USE
1891      insns in the CALL_INSN_FUNCTION_USAGE field.  */
1892
1893 #ifdef LOAD_ARGS_REVERSED
1894   for (i = num_actuals - 1; i >= 0; i--)
1895 #else
1896   for (i = 0; i < num_actuals; i++)
1897 #endif
1898     {
1899       rtx reg = args[i].reg;
1900       int partial = args[i].partial;
1901       int nregs;
1902
1903       if (reg)
1904         {
1905           /* Set to non-negative if must move a word at a time, even if just
1906              one word (e.g, partial == 1 && mode == DFmode).  Set to -1 if
1907              we just use a normal move insn.  This value can be zero if the
1908              argument is a zero size structure with no fields.  */
1909           nregs = (partial ? partial
1910                    : (TYPE_MODE (TREE_TYPE (args[i].tree_value)) == BLKmode
1911                       ? ((int_size_in_bytes (TREE_TYPE (args[i].tree_value))
1912                           + (UNITS_PER_WORD - 1)) / UNITS_PER_WORD)
1913                       : -1));
1914
1915           /* Handle calls that pass values in multiple non-contiguous
1916              locations.  The Irix 6 ABI has examples of this.  */
1917
1918           if (GET_CODE (reg) == PARALLEL)
1919             emit_group_load (reg, args[i].value);
1920
1921           /* If simple case, just do move.  If normal partial, store_one_arg
1922              has already loaded the register for us.  In all other cases,
1923              load the register(s) from memory.  */
1924
1925           else if (nregs == -1)
1926             emit_move_insn (reg, args[i].value);
1927
1928           /* If we have pre-computed the values to put in the registers in
1929              the case of non-aligned structures, copy them in now.  */
1930
1931           else if (args[i].n_aligned_regs != 0)
1932             for (j = 0; j < args[i].n_aligned_regs; j++)
1933               emit_move_insn (gen_rtx_REG (word_mode, REGNO (reg) + j),
1934                               args[i].aligned_regs[j]);
1935
1936           else if (partial == 0 || args[i].pass_on_stack)
1937             move_block_to_reg (REGNO (reg),
1938                                validize_mem (args[i].value), nregs,
1939                                args[i].mode);
1940
1941           /* Handle calls that pass values in multiple non-contiguous
1942              locations.  The Irix 6 ABI has examples of this.  */
1943           if (GET_CODE (reg) == PARALLEL)
1944             use_group_regs (&call_fusage, reg);
1945           else if (nregs == -1)
1946             use_reg (&call_fusage, reg);
1947           else
1948             use_regs (&call_fusage, REGNO (reg), nregs == 0 ? 1 : nregs);
1949         }
1950     }
1951
1952   /* Perform postincrements before actually calling the function.  */
1953   emit_queue ();
1954
1955   /* All arguments and registers used for the call must be set up by now!  */
1956
1957   /* Generate the actual call instruction.  */
1958   emit_call_1 (funexp, fndecl, funtype, args_size.constant, struct_value_size,
1959                FUNCTION_ARG (args_so_far, VOIDmode, void_type_node, 1),
1960                valreg, old_inhibit_defer_pop, call_fusage, is_const);
1961
1962   /* If call is cse'able, make appropriate pair of reg-notes around it.
1963      Test valreg so we don't crash; may safely ignore `const'
1964      if return type is void.  Disable for PARALLEL return values, because
1965      we have no way to move such values into a pseudo register.  */
1966   if (is_const && valreg != 0 && GET_CODE (valreg) != PARALLEL)
1967     {
1968       rtx note = 0;
1969       rtx temp = gen_reg_rtx (GET_MODE (valreg));
1970       rtx insns;
1971
1972       /* Mark the return value as a pointer if needed.  */
1973       if (TREE_CODE (TREE_TYPE (exp)) == POINTER_TYPE)
1974         {
1975           tree pointed_to = TREE_TYPE (TREE_TYPE (exp));
1976           mark_reg_pointer (temp, TYPE_ALIGN (pointed_to) / BITS_PER_UNIT);
1977         }
1978
1979       /* Construct an "equal form" for the value which mentions all the
1980          arguments in order as well as the function name.  */
1981 #ifdef PUSH_ARGS_REVERSED
1982       for (i = 0; i < num_actuals; i++)
1983         note = gen_rtx_EXPR_LIST (VOIDmode, args[i].initial_value, note);
1984 #else
1985       for (i = num_actuals - 1; i >= 0; i--)
1986         note = gen_rtx_EXPR_LIST (VOIDmode, args[i].initial_value, note);
1987 #endif
1988       note = gen_rtx_EXPR_LIST (VOIDmode, funexp, note);
1989
1990       insns = get_insns ();
1991       end_sequence ();
1992
1993       emit_libcall_block (insns, temp, valreg, note);
1994
1995       valreg = temp;
1996     }
1997   else if (is_const)
1998     {
1999       /* Otherwise, just write out the sequence without a note.  */
2000       rtx insns = get_insns ();
2001
2002       end_sequence ();
2003       emit_insns (insns);
2004     }
2005   else if (is_malloc)
2006     {
2007       rtx temp = gen_reg_rtx (GET_MODE (valreg));
2008       rtx last, insns;
2009
2010       /* The return value from a malloc-like function is a pointer. */
2011       if (TREE_CODE (TREE_TYPE (exp)) == POINTER_TYPE)
2012         mark_reg_pointer (temp, BIGGEST_ALIGNMENT / BITS_PER_UNIT);
2013
2014       emit_move_insn (temp, valreg);
2015
2016       /* The return value from a malloc-like function can not alias
2017          anything else.  */
2018       last = get_last_insn ();
2019       REG_NOTES (last) = 
2020         gen_rtx_EXPR_LIST (REG_NOALIAS, temp, REG_NOTES (last));
2021
2022       /* Write out the sequence.  */
2023       insns = get_insns ();
2024       end_sequence ();
2025       emit_insns (insns);
2026       valreg = temp;
2027     }
2028
2029   /* For calls to `setjmp', etc., inform flow.c it should complain
2030      if nonvolatile values are live.  */
2031
2032   if (returns_twice)
2033     {
2034       emit_note (name, NOTE_INSN_SETJMP);
2035       current_function_calls_setjmp = 1;
2036     }
2037
2038   if (is_longjmp)
2039     current_function_calls_longjmp = 1;
2040
2041   /* Notice functions that cannot return.
2042      If optimizing, insns emitted below will be dead.
2043      If not optimizing, they will exist, which is useful
2044      if the user uses the `return' command in the debugger.  */
2045
2046   if (is_volatile || is_longjmp)
2047     emit_barrier ();
2048
2049   /* If value type not void, return an rtx for the value.  */
2050
2051   /* If there are cleanups to be called, don't use a hard reg as target.
2052      We need to double check this and see if it matters anymore.  */
2053   if (any_pending_cleanups (1)
2054       && target && REG_P (target)
2055       && REGNO (target) < FIRST_PSEUDO_REGISTER)
2056     target = 0;
2057
2058   if (TYPE_MODE (TREE_TYPE (exp)) == VOIDmode
2059       || ignore)
2060     {
2061       target = const0_rtx;
2062     }
2063   else if (structure_value_addr)
2064     {
2065       if (target == 0 || GET_CODE (target) != MEM)
2066         {
2067           target = gen_rtx_MEM (TYPE_MODE (TREE_TYPE (exp)),
2068                                 memory_address (TYPE_MODE (TREE_TYPE (exp)),
2069                                                 structure_value_addr));
2070           MEM_IN_STRUCT_P (target) = AGGREGATE_TYPE_P (TREE_TYPE (exp));
2071         }
2072     }
2073   else if (pcc_struct_value)
2074     {
2075       /* This is the special C++ case where we need to
2076          know what the true target was.  We take care to
2077          never use this value more than once in one expression.  */
2078       target = gen_rtx_MEM (TYPE_MODE (TREE_TYPE (exp)),
2079                             copy_to_reg (valreg));
2080       MEM_IN_STRUCT_P (target) = AGGREGATE_TYPE_P (TREE_TYPE (exp));
2081     }
2082   /* Handle calls that return values in multiple non-contiguous locations.
2083      The Irix 6 ABI has examples of this.  */
2084   else if (GET_CODE (valreg) == PARALLEL)
2085     {
2086       if (target == 0)
2087         {
2088           int bytes = int_size_in_bytes (TREE_TYPE (exp));
2089           target = assign_stack_temp (TYPE_MODE (TREE_TYPE (exp)), bytes, 0);
2090           MEM_IN_STRUCT_P (target) = AGGREGATE_TYPE_P (TREE_TYPE (exp));
2091           preserve_temp_slots (target);
2092         }
2093
2094       emit_group_store (target, valreg);
2095     }
2096   else if (target && GET_MODE (target) == TYPE_MODE (TREE_TYPE (exp))
2097            && GET_MODE (target) == GET_MODE (valreg))
2098     /* TARGET and VALREG cannot be equal at this point because the latter
2099        would not have REG_FUNCTION_VALUE_P true, while the former would if
2100        it were referring to the same register.
2101
2102        If they refer to the same register, this move will be a no-op, except
2103        when function inlining is being done.  */
2104     emit_move_insn (target, valreg);
2105   else if (TYPE_MODE (TREE_TYPE (exp)) == BLKmode)
2106     {
2107       /* Some machines (the PA for example) want to return all small
2108          structures in registers regardless of the structure's alignment.
2109          
2110          Deal with them explicitly by copying from the return registers
2111          into the target MEM locations.  */
2112       int bytes = int_size_in_bytes (TREE_TYPE (exp));
2113       int n_regs = (bytes + UNITS_PER_WORD - 1) / UNITS_PER_WORD;
2114       int i;
2115       enum machine_mode tmpmode;
2116       rtx src, dst;
2117       int bitsize = MIN (TYPE_ALIGN (TREE_TYPE (exp)), BITS_PER_WORD);
2118       int bitpos, xbitpos, big_endian_correction = 0;
2119       
2120       if (target == 0)
2121         {
2122           target = assign_stack_temp (BLKmode, bytes, 0);
2123           MEM_IN_STRUCT_P (target) = AGGREGATE_TYPE_P (TREE_TYPE (exp));
2124           preserve_temp_slots (target);
2125         }
2126
2127       /* This code assumes valreg is at least a full word.  If it isn't,
2128          copy it into a new pseudo which is a full word.  */
2129       if (GET_MODE (valreg) != BLKmode
2130           && GET_MODE_SIZE (GET_MODE (valreg)) < UNITS_PER_WORD)
2131         valreg = convert_to_mode (word_mode, valreg,
2132                                   TREE_UNSIGNED (TREE_TYPE (exp)));
2133
2134       /* Structures whose size is not a multiple of a word are aligned
2135          to the least significant byte (to the right).  On a BYTES_BIG_ENDIAN
2136          machine, this means we must skip the empty high order bytes when
2137          calculating the bit offset.  */
2138       if (BYTES_BIG_ENDIAN && bytes % UNITS_PER_WORD)
2139         big_endian_correction = (BITS_PER_WORD - ((bytes % UNITS_PER_WORD)
2140                                                   * BITS_PER_UNIT));
2141
2142       /* Copy the structure BITSIZE bites at a time.
2143
2144          We could probably emit more efficient code for machines
2145          which do not use strict alignment, but it doesn't seem
2146          worth the effort at the current time.  */
2147       for (bitpos = 0, xbitpos = big_endian_correction;
2148            bitpos < bytes * BITS_PER_UNIT;
2149            bitpos += bitsize, xbitpos += bitsize)
2150         {
2151
2152           /* We need a new source operand each time xbitpos is on a 
2153              word boundary and when xbitpos == big_endian_correction
2154              (the first time through).  */
2155           if (xbitpos % BITS_PER_WORD == 0
2156               || xbitpos == big_endian_correction)
2157             src = operand_subword_force (valreg,
2158                                          xbitpos / BITS_PER_WORD, 
2159                                          BLKmode);
2160
2161           /* We need a new destination operand each time bitpos is on
2162              a word boundary.  */
2163           if (bitpos % BITS_PER_WORD == 0)
2164             dst = operand_subword (target, bitpos / BITS_PER_WORD, 1, BLKmode);
2165               
2166           /* Use xbitpos for the source extraction (right justified) and
2167              xbitpos for the destination store (left justified).  */
2168           store_bit_field (dst, bitsize, bitpos % BITS_PER_WORD, word_mode,
2169                            extract_bit_field (src, bitsize,
2170                                               xbitpos % BITS_PER_WORD, 1,
2171                                               NULL_RTX, word_mode,
2172                                               word_mode,
2173                                               bitsize / BITS_PER_UNIT,
2174                                               BITS_PER_WORD),
2175                            bitsize / BITS_PER_UNIT, BITS_PER_WORD);
2176         }
2177     }
2178   else
2179     target = copy_to_reg (valreg);
2180
2181 #ifdef PROMOTE_FUNCTION_RETURN
2182   /* If we promoted this return value, make the proper SUBREG.  TARGET
2183      might be const0_rtx here, so be careful.  */
2184   if (GET_CODE (target) == REG
2185       && TYPE_MODE (TREE_TYPE (exp)) != BLKmode
2186       && GET_MODE (target) != TYPE_MODE (TREE_TYPE (exp)))
2187     {
2188       tree type = TREE_TYPE (exp);
2189       int unsignedp = TREE_UNSIGNED (type);
2190
2191       /* If we don't promote as expected, something is wrong.  */
2192       if (GET_MODE (target)
2193           != promote_mode (type, TYPE_MODE (type), &unsignedp, 1))
2194         abort ();
2195
2196       target = gen_rtx_SUBREG (TYPE_MODE (type), target, 0);
2197       SUBREG_PROMOTED_VAR_P (target) = 1;
2198       SUBREG_PROMOTED_UNSIGNED_P (target) = unsignedp;
2199     }
2200 #endif
2201
2202   /* If size of args is variable or this was a constructor call for a stack
2203      argument, restore saved stack-pointer value.  */
2204
2205   if (old_stack_level)
2206     {
2207       emit_stack_restore (SAVE_BLOCK, old_stack_level, NULL_RTX);
2208       pending_stack_adjust = old_pending_adj;
2209 #ifdef ACCUMULATE_OUTGOING_ARGS
2210       stack_arg_under_construction = old_stack_arg_under_construction;
2211       highest_outgoing_arg_in_use = initial_highest_arg_in_use;
2212       stack_usage_map = initial_stack_usage_map;
2213 #endif
2214     }
2215 #ifdef ACCUMULATE_OUTGOING_ARGS
2216   else
2217     {
2218 #ifdef REG_PARM_STACK_SPACE
2219       if (save_area)
2220         {
2221           enum machine_mode save_mode = GET_MODE (save_area);
2222 #ifdef ARGS_GROW_DOWNWARD
2223           rtx stack_area
2224             = gen_rtx_MEM (save_mode,
2225                            memory_address (save_mode,
2226                                            plus_constant (argblock,
2227                                                           - high_to_save)));
2228 #else
2229           rtx stack_area
2230             = gen_rtx_MEM (save_mode,
2231                            memory_address (save_mode,
2232                                            plus_constant (argblock,
2233                                                           low_to_save)));
2234 #endif
2235
2236           if (save_mode != BLKmode)
2237             emit_move_insn (stack_area, save_area);
2238           else
2239             emit_block_move (stack_area, validize_mem (save_area),
2240                              GEN_INT (high_to_save - low_to_save + 1),
2241                              PARM_BOUNDARY / BITS_PER_UNIT);
2242         }
2243 #endif
2244           
2245       /* If we saved any argument areas, restore them.  */
2246       for (i = 0; i < num_actuals; i++)
2247         if (args[i].save_area)
2248           {
2249             enum machine_mode save_mode = GET_MODE (args[i].save_area);
2250             rtx stack_area
2251               = gen_rtx_MEM (save_mode,
2252                              memory_address (save_mode,
2253                                              XEXP (args[i].stack_slot, 0)));
2254
2255             if (save_mode != BLKmode)
2256               emit_move_insn (stack_area, args[i].save_area);
2257             else
2258               emit_block_move (stack_area, validize_mem (args[i].save_area),
2259                                GEN_INT (args[i].size.constant),
2260                                PARM_BOUNDARY / BITS_PER_UNIT);
2261           }
2262
2263       highest_outgoing_arg_in_use = initial_highest_arg_in_use;
2264       stack_usage_map = initial_stack_usage_map;
2265     }
2266 #endif
2267
2268   /* If this was alloca, record the new stack level for nonlocal gotos.  
2269      Check for the handler slots since we might not have a save area
2270      for non-local gotos.  */
2271
2272   if (may_be_alloca && nonlocal_goto_handler_slot != 0)
2273     emit_stack_save (SAVE_NONLOCAL, &nonlocal_goto_stack_level, NULL_RTX);
2274
2275   pop_temp_slots ();
2276
2277   return target;
2278 }
2279 \f
2280 /* Output a library call to function FUN (a SYMBOL_REF rtx)
2281    (emitting the queue unless NO_QUEUE is nonzero),
2282    for a value of mode OUTMODE,
2283    with NARGS different arguments, passed as alternating rtx values
2284    and machine_modes to convert them to.
2285    The rtx values should have been passed through protect_from_queue already.
2286
2287    NO_QUEUE will be true if and only if the library call is a `const' call
2288    which will be enclosed in REG_LIBCALL/REG_RETVAL notes; it is equivalent
2289    to the variable is_const in expand_call.
2290
2291    NO_QUEUE must be true for const calls, because if it isn't, then
2292    any pending increment will be emitted between REG_LIBCALL/REG_RETVAL notes,
2293    and will be lost if the libcall sequence is optimized away.
2294
2295    NO_QUEUE must be false for non-const calls, because if it isn't, the
2296    call insn will have its CONST_CALL_P bit set, and it will be incorrectly
2297    optimized.  For instance, the instruction scheduler may incorrectly
2298    move memory references across the non-const call.  */
2299
2300 void
2301 emit_library_call VPROTO((rtx orgfun, int no_queue, enum machine_mode outmode,
2302                           int nargs, ...))
2303 {
2304 #ifndef __STDC__
2305   rtx orgfun;
2306   int no_queue;
2307   enum machine_mode outmode;
2308   int nargs;
2309 #endif
2310   va_list p;
2311   /* Total size in bytes of all the stack-parms scanned so far.  */
2312   struct args_size args_size;
2313   /* Size of arguments before any adjustments (such as rounding).  */
2314   struct args_size original_args_size;
2315   register int argnum;
2316   rtx fun;
2317   int inc;
2318   int count;
2319   rtx argblock = 0;
2320   CUMULATIVE_ARGS args_so_far;
2321   struct arg { rtx value; enum machine_mode mode; rtx reg; int partial;
2322                struct args_size offset; struct args_size size; rtx save_area; };
2323   struct arg *argvec;
2324   int old_inhibit_defer_pop = inhibit_defer_pop;
2325   rtx call_fusage = 0;
2326   /* Size of the stack reserved for parameter registers.  */
2327   int reg_parm_stack_space = 0;
2328 #if defined(ACCUMULATE_OUTGOING_ARGS) && defined(REG_PARM_STACK_SPACE)
2329   /* Define the boundary of the register parm stack space that needs to be
2330      save, if any.  */
2331   int low_to_save = -1, high_to_save;
2332   rtx save_area = 0;            /* Place that it is saved */
2333 #endif
2334
2335 #ifdef ACCUMULATE_OUTGOING_ARGS
2336   int initial_highest_arg_in_use = highest_outgoing_arg_in_use;
2337   char *initial_stack_usage_map = stack_usage_map;
2338   int needed;
2339 #endif
2340
2341 #ifdef REG_PARM_STACK_SPACE
2342 #ifdef MAYBE_REG_PARM_STACK_SPACE
2343   reg_parm_stack_space = MAYBE_REG_PARM_STACK_SPACE;
2344 #else
2345   reg_parm_stack_space = REG_PARM_STACK_SPACE (fndecl);
2346 #endif
2347 #endif
2348
2349   VA_START (p, nargs);
2350
2351 #ifndef __STDC__
2352   orgfun = va_arg (p, rtx);
2353   no_queue = va_arg (p, int);
2354   outmode = va_arg (p, enum machine_mode);
2355   nargs = va_arg (p, int);
2356 #endif
2357
2358   fun = orgfun;
2359
2360   /* Copy all the libcall-arguments out of the varargs data
2361      and into a vector ARGVEC.
2362
2363      Compute how to pass each argument.  We only support a very small subset
2364      of the full argument passing conventions to limit complexity here since
2365      library functions shouldn't have many args.  */
2366
2367   argvec = (struct arg *) alloca (nargs * sizeof (struct arg));
2368   bzero ((char *) argvec, nargs * sizeof (struct arg));
2369
2370
2371   INIT_CUMULATIVE_ARGS (args_so_far, NULL_TREE, fun, 0);
2372
2373   args_size.constant = 0;
2374   args_size.var = 0;
2375
2376   push_temp_slots ();
2377
2378   for (count = 0; count < nargs; count++)
2379     {
2380       rtx val = va_arg (p, rtx);
2381       enum machine_mode mode = va_arg (p, enum machine_mode);
2382
2383       /* We cannot convert the arg value to the mode the library wants here;
2384          must do it earlier where we know the signedness of the arg.  */
2385       if (mode == BLKmode
2386           || (GET_MODE (val) != mode && GET_MODE (val) != VOIDmode))
2387         abort ();
2388
2389       /* On some machines, there's no way to pass a float to a library fcn.
2390          Pass it as a double instead.  */
2391 #ifdef LIBGCC_NEEDS_DOUBLE
2392       if (LIBGCC_NEEDS_DOUBLE && mode == SFmode)
2393         val = convert_modes (DFmode, SFmode, val, 0), mode = DFmode;
2394 #endif
2395
2396       /* There's no need to call protect_from_queue, because
2397          either emit_move_insn or emit_push_insn will do that.  */
2398
2399       /* Make sure it is a reasonable operand for a move or push insn.  */
2400       if (GET_CODE (val) != REG && GET_CODE (val) != MEM
2401           && ! (CONSTANT_P (val) && LEGITIMATE_CONSTANT_P (val)))
2402         val = force_operand (val, NULL_RTX);
2403
2404 #ifdef FUNCTION_ARG_PASS_BY_REFERENCE
2405       if (FUNCTION_ARG_PASS_BY_REFERENCE (args_so_far, mode, NULL_TREE, 1))
2406         {
2407           /* We do not support FUNCTION_ARG_CALLEE_COPIES here since it can
2408              be viewed as just an efficiency improvement.  */
2409           rtx slot = assign_stack_temp (mode, GET_MODE_SIZE (mode), 0);
2410           emit_move_insn (slot, val);
2411           val = force_operand (XEXP (slot, 0), NULL_RTX);
2412           mode = Pmode;
2413         }
2414 #endif
2415
2416       argvec[count].value = val;
2417       argvec[count].mode = mode;
2418
2419       argvec[count].reg = FUNCTION_ARG (args_so_far, mode, NULL_TREE, 1);
2420       if (argvec[count].reg && GET_CODE (argvec[count].reg) == PARALLEL)
2421         abort ();
2422 #ifdef FUNCTION_ARG_PARTIAL_NREGS
2423       argvec[count].partial
2424         = FUNCTION_ARG_PARTIAL_NREGS (args_so_far, mode, NULL_TREE, 1);
2425 #else
2426       argvec[count].partial = 0;
2427 #endif
2428
2429       locate_and_pad_parm (mode, NULL_TREE,
2430                            argvec[count].reg && argvec[count].partial == 0,
2431                            NULL_TREE, &args_size, &argvec[count].offset,
2432                            &argvec[count].size);
2433
2434       if (argvec[count].size.var)
2435         abort ();
2436
2437 #ifndef REG_PARM_STACK_SPACE
2438       if (argvec[count].partial)
2439         argvec[count].size.constant -= argvec[count].partial * UNITS_PER_WORD;
2440 #endif
2441
2442       if (argvec[count].reg == 0 || argvec[count].partial != 0
2443 #ifdef REG_PARM_STACK_SPACE
2444           || 1
2445 #endif
2446           )
2447         args_size.constant += argvec[count].size.constant;
2448
2449       FUNCTION_ARG_ADVANCE (args_so_far, mode, (tree) 0, 1);
2450     }
2451   va_end (p);
2452
2453 #ifdef FINAL_REG_PARM_STACK_SPACE
2454   reg_parm_stack_space = FINAL_REG_PARM_STACK_SPACE (args_size.constant,
2455                                                      args_size.var);
2456 #endif
2457       
2458   /* If this machine requires an external definition for library
2459      functions, write one out.  */
2460   assemble_external_libcall (fun);
2461
2462   original_args_size = args_size;
2463 #ifdef STACK_BOUNDARY
2464   args_size.constant = (((args_size.constant + (STACK_BYTES - 1))
2465                          / STACK_BYTES) * STACK_BYTES);
2466 #endif
2467
2468 #ifdef REG_PARM_STACK_SPACE
2469   args_size.constant = MAX (args_size.constant,
2470                             reg_parm_stack_space);
2471 #ifndef OUTGOING_REG_PARM_STACK_SPACE
2472   args_size.constant -= reg_parm_stack_space;
2473 #endif
2474 #endif
2475
2476   if (args_size.constant > current_function_outgoing_args_size)
2477     current_function_outgoing_args_size = args_size.constant;
2478
2479 #ifdef ACCUMULATE_OUTGOING_ARGS
2480   /* Since the stack pointer will never be pushed, it is possible for
2481      the evaluation of a parm to clobber something we have already
2482      written to the stack.  Since most function calls on RISC machines
2483      do not use the stack, this is uncommon, but must work correctly.
2484
2485      Therefore, we save any area of the stack that was already written
2486      and that we are using.  Here we set up to do this by making a new
2487      stack usage map from the old one.
2488
2489      Another approach might be to try to reorder the argument
2490      evaluations to avoid this conflicting stack usage.  */
2491
2492   needed = args_size.constant;
2493 #if defined(REG_PARM_STACK_SPACE) && ! defined(OUTGOING_REG_PARM_STACK_SPACE)
2494   /* Since we will be writing into the entire argument area, the
2495      map must be allocated for its entire size, not just the part that
2496      is the responsibility of the caller.  */
2497   needed += reg_parm_stack_space;
2498 #endif
2499
2500 #ifdef ARGS_GROW_DOWNWARD
2501   highest_outgoing_arg_in_use = MAX (initial_highest_arg_in_use,
2502                                      needed + 1);
2503 #else
2504   highest_outgoing_arg_in_use = MAX (initial_highest_arg_in_use,
2505                                      needed);
2506 #endif
2507   stack_usage_map = (char *) alloca (highest_outgoing_arg_in_use);
2508
2509   if (initial_highest_arg_in_use)
2510     bcopy (initial_stack_usage_map, stack_usage_map,
2511            initial_highest_arg_in_use);
2512
2513   if (initial_highest_arg_in_use != highest_outgoing_arg_in_use)
2514     bzero (&stack_usage_map[initial_highest_arg_in_use],
2515            highest_outgoing_arg_in_use - initial_highest_arg_in_use);
2516   needed = 0;
2517
2518   /* The address of the outgoing argument list must not be copied to a
2519      register here, because argblock would be left pointing to the
2520      wrong place after the call to allocate_dynamic_stack_space below.
2521      */
2522
2523   argblock = virtual_outgoing_args_rtx;
2524 #else /* not ACCUMULATE_OUTGOING_ARGS */
2525 #ifndef PUSH_ROUNDING
2526   argblock = push_block (GEN_INT (args_size.constant), 0, 0);
2527 #endif
2528 #endif
2529
2530 #ifdef PUSH_ARGS_REVERSED
2531 #ifdef STACK_BOUNDARY
2532   /* If we push args individually in reverse order, perform stack alignment
2533      before the first push (the last arg).  */
2534   if (argblock == 0)
2535     anti_adjust_stack (GEN_INT (args_size.constant
2536                                 - original_args_size.constant));
2537 #endif
2538 #endif
2539
2540 #ifdef PUSH_ARGS_REVERSED
2541   inc = -1;
2542   argnum = nargs - 1;
2543 #else
2544   inc = 1;
2545   argnum = 0;
2546 #endif
2547
2548 #if defined(ACCUMULATE_OUTGOING_ARGS) && defined(REG_PARM_STACK_SPACE)
2549   /* The argument list is the property of the called routine and it
2550      may clobber it.  If the fixed area has been used for previous
2551      parameters, we must save and restore it.
2552
2553      Here we compute the boundary of the that needs to be saved, if any.  */
2554
2555 #ifdef ARGS_GROW_DOWNWARD
2556   for (count = 0; count < reg_parm_stack_space + 1; count++)
2557 #else
2558   for (count = 0; count < reg_parm_stack_space; count++)
2559 #endif
2560     {
2561       if (count >=  highest_outgoing_arg_in_use
2562           || stack_usage_map[count] == 0)
2563         continue;
2564
2565       if (low_to_save == -1)
2566         low_to_save = count;
2567
2568       high_to_save = count;
2569     }
2570
2571   if (low_to_save >= 0)
2572     {
2573       int num_to_save = high_to_save - low_to_save + 1;
2574       enum machine_mode save_mode
2575         = mode_for_size (num_to_save * BITS_PER_UNIT, MODE_INT, 1);
2576       rtx stack_area;
2577
2578       /* If we don't have the required alignment, must do this in BLKmode.  */
2579       if ((low_to_save & (MIN (GET_MODE_SIZE (save_mode),
2580                                BIGGEST_ALIGNMENT / UNITS_PER_WORD) - 1)))
2581         save_mode = BLKmode;
2582
2583 #ifdef ARGS_GROW_DOWNWARD
2584       stack_area = gen_rtx_MEM (save_mode,
2585                                 memory_address (save_mode,
2586                                                 plus_constant (argblock,
2587                                                                - high_to_save)));
2588 #else
2589       stack_area = gen_rtx_MEM (save_mode,
2590                                 memory_address (save_mode,
2591                                                 plus_constant (argblock,
2592                                                                low_to_save)));
2593 #endif
2594       if (save_mode == BLKmode)
2595         {
2596           save_area = assign_stack_temp (BLKmode, num_to_save, 0);
2597           MEM_IN_STRUCT_P (save_area) = 0;
2598           emit_block_move (validize_mem (save_area), stack_area,
2599                            GEN_INT (num_to_save),
2600                            PARM_BOUNDARY / BITS_PER_UNIT);
2601         }
2602       else
2603         {
2604           save_area = gen_reg_rtx (save_mode);
2605           emit_move_insn (save_area, stack_area);
2606         }
2607     }
2608 #endif
2609           
2610   /* Push the args that need to be pushed.  */
2611
2612   /* ARGNUM indexes the ARGVEC array in the order in which the arguments
2613      are to be pushed.  */
2614   for (count = 0; count < nargs; count++, argnum += inc)
2615     {
2616       register enum machine_mode mode = argvec[argnum].mode;
2617       register rtx val = argvec[argnum].value;
2618       rtx reg = argvec[argnum].reg;
2619       int partial = argvec[argnum].partial;
2620       int lower_bound, upper_bound, i;
2621
2622       if (! (reg != 0 && partial == 0))
2623         {
2624 #ifdef ACCUMULATE_OUTGOING_ARGS
2625           /* If this is being stored into a pre-allocated, fixed-size, stack
2626              area, save any previous data at that location.  */
2627
2628 #ifdef ARGS_GROW_DOWNWARD
2629           /* stack_slot is negative, but we want to index stack_usage_map
2630              with positive values.  */
2631           upper_bound = -argvec[argnum].offset.constant + 1;
2632           lower_bound = upper_bound - argvec[argnum].size.constant;
2633 #else
2634           lower_bound = argvec[argnum].offset.constant;
2635           upper_bound = lower_bound + argvec[argnum].size.constant;
2636 #endif
2637
2638           for (i = lower_bound; i < upper_bound; i++)
2639             if (stack_usage_map[i]
2640 #ifdef REG_PARM_STACK_SPACE
2641                 /* Don't store things in the fixed argument area at this point;
2642                    it has already been saved.  */
2643                 && i > reg_parm_stack_space
2644 #endif
2645                 )
2646               break;
2647
2648           if (i != upper_bound)
2649             {
2650               /* We need to make a save area.  See what mode we can make it.  */
2651               enum machine_mode save_mode
2652                 = mode_for_size (argvec[argnum].size.constant * BITS_PER_UNIT,
2653                                  MODE_INT, 1);
2654               rtx stack_area
2655                 = gen_rtx_MEM (save_mode,
2656                                memory_address (save_mode,
2657                                                plus_constant (argblock, argvec[argnum].offset.constant)));
2658               argvec[argnum].save_area = gen_reg_rtx (save_mode);
2659               emit_move_insn (argvec[argnum].save_area, stack_area);
2660             }
2661 #endif
2662           emit_push_insn (val, mode, NULL_TREE, NULL_RTX, 0, partial, reg, 0,
2663                           argblock, GEN_INT (argvec[argnum].offset.constant));
2664
2665 #ifdef ACCUMULATE_OUTGOING_ARGS
2666           /* Now mark the segment we just used.  */
2667           for (i = lower_bound; i < upper_bound; i++)
2668             stack_usage_map[i] = 1;
2669 #endif
2670
2671           NO_DEFER_POP;
2672         }
2673     }
2674
2675 #ifndef PUSH_ARGS_REVERSED
2676 #ifdef STACK_BOUNDARY
2677   /* If we pushed args in forward order, perform stack alignment
2678      after pushing the last arg.  */
2679   if (argblock == 0)
2680     anti_adjust_stack (GEN_INT (args_size.constant
2681                                 - original_args_size.constant));
2682 #endif
2683 #endif
2684
2685 #ifdef PUSH_ARGS_REVERSED
2686   argnum = nargs - 1;
2687 #else
2688   argnum = 0;
2689 #endif
2690
2691   fun = prepare_call_address (fun, NULL_TREE, &call_fusage, 0);
2692
2693   /* Now load any reg parms into their regs.  */
2694
2695   /* ARGNUM indexes the ARGVEC array in the order in which the arguments
2696      are to be pushed.  */
2697   for (count = 0; count < nargs; count++, argnum += inc)
2698     {
2699       register enum machine_mode mode = argvec[argnum].mode;
2700       register rtx val = argvec[argnum].value;
2701       rtx reg = argvec[argnum].reg;
2702       int partial = argvec[argnum].partial;
2703
2704       if (reg != 0 && partial == 0)
2705         emit_move_insn (reg, val);
2706       NO_DEFER_POP;
2707     }
2708
2709   /* For version 1.37, try deleting this entirely.  */
2710   if (! no_queue)
2711     emit_queue ();
2712
2713   /* Any regs containing parms remain in use through the call.  */
2714   for (count = 0; count < nargs; count++)
2715     if (argvec[count].reg != 0)
2716        use_reg (&call_fusage, argvec[count].reg);
2717
2718   /* Don't allow popping to be deferred, since then
2719      cse'ing of library calls could delete a call and leave the pop.  */
2720   NO_DEFER_POP;
2721
2722   /* We pass the old value of inhibit_defer_pop + 1 to emit_call_1, which
2723      will set inhibit_defer_pop to that value.  */
2724
2725   /* The return type is needed to decide how many bytes the function pops.
2726      Signedness plays no role in that, so for simplicity, we pretend it's
2727      always signed.  We also assume that the list of arguments passed has
2728      no impact, so we pretend it is unknown.  */
2729
2730   emit_call_1 (fun, 
2731                get_identifier (XSTR (orgfun, 0)), 
2732                build_function_type (outmode == VOIDmode ? void_type_node
2733                                     : type_for_mode (outmode, 0), NULL_TREE),
2734                args_size.constant, 0,
2735                FUNCTION_ARG (args_so_far, VOIDmode, void_type_node, 1),
2736                outmode != VOIDmode ? hard_libcall_value (outmode) : NULL_RTX,
2737                old_inhibit_defer_pop + 1, call_fusage, no_queue);
2738
2739   pop_temp_slots ();
2740
2741   /* Now restore inhibit_defer_pop to its actual original value.  */
2742   OK_DEFER_POP;
2743
2744 #ifdef ACCUMULATE_OUTGOING_ARGS
2745 #ifdef REG_PARM_STACK_SPACE
2746   if (save_area)
2747     {
2748       enum machine_mode save_mode = GET_MODE (save_area);
2749 #ifdef ARGS_GROW_DOWNWARD
2750       rtx stack_area
2751         = gen_rtx_MEM (save_mode,
2752                        memory_address (save_mode,
2753                                        plus_constant (argblock,
2754                                                        - high_to_save)));
2755 #else
2756       rtx stack_area
2757         = gen_rtx_MEM (save_mode,
2758                        memory_address (save_mode,
2759                                        plus_constant (argblock, low_to_save)));
2760 #endif
2761
2762       if (save_mode != BLKmode)
2763         emit_move_insn (stack_area, save_area);
2764       else
2765         emit_block_move (stack_area, validize_mem (save_area),
2766                          GEN_INT (high_to_save - low_to_save + 1),
2767                          PARM_BOUNDARY / BITS_PER_UNIT);
2768     }
2769 #endif
2770           
2771   /* If we saved any argument areas, restore them.  */
2772   for (count = 0; count < nargs; count++)
2773     if (argvec[count].save_area)
2774       {
2775         enum machine_mode save_mode = GET_MODE (argvec[count].save_area);
2776         rtx stack_area
2777           = gen_rtx_MEM (save_mode,
2778                          memory_address (save_mode,
2779                                          plus_constant (argblock, argvec[count].offset.constant)));
2780
2781         emit_move_insn (stack_area, argvec[count].save_area);
2782       }
2783
2784   highest_outgoing_arg_in_use = initial_highest_arg_in_use;
2785   stack_usage_map = initial_stack_usage_map;
2786 #endif
2787 }
2788 \f
2789 /* Like emit_library_call except that an extra argument, VALUE,
2790    comes second and says where to store the result.
2791    (If VALUE is zero, this function chooses a convenient way
2792    to return the value.
2793
2794    This function returns an rtx for where the value is to be found.
2795    If VALUE is nonzero, VALUE is returned.  */
2796
2797 rtx
2798 emit_library_call_value VPROTO((rtx orgfun, rtx value, int no_queue,
2799                                 enum machine_mode outmode, int nargs, ...))
2800 {
2801 #ifndef __STDC__
2802   rtx orgfun;
2803   rtx value;
2804   int no_queue;
2805   enum machine_mode outmode;
2806   int nargs;
2807 #endif
2808   va_list p;
2809   /* Total size in bytes of all the stack-parms scanned so far.  */
2810   struct args_size args_size;
2811   /* Size of arguments before any adjustments (such as rounding).  */
2812   struct args_size original_args_size;
2813   register int argnum;
2814   rtx fun;
2815   int inc;
2816   int count;
2817   rtx argblock = 0;
2818   CUMULATIVE_ARGS args_so_far;
2819   struct arg { rtx value; enum machine_mode mode; rtx reg; int partial;
2820                struct args_size offset; struct args_size size; rtx save_area; };
2821   struct arg *argvec;
2822   int old_inhibit_defer_pop = inhibit_defer_pop;
2823   rtx call_fusage = 0;
2824   /* Size of the stack reserved for parameter registers.  */
2825   int reg_parm_stack_space = 0;
2826   rtx mem_value = 0;
2827   int pcc_struct_value = 0;
2828   int struct_value_size = 0;
2829   int is_const;
2830   int needed;
2831
2832 #if defined(ACCUMULATE_OUTGOING_ARGS) && defined(REG_PARM_STACK_SPACE)
2833   /* Define the boundary of the register parm stack space that needs to be
2834      save, if any.  */
2835   int low_to_save = -1, high_to_save;
2836   rtx save_area = 0;            /* Place that it is saved */
2837 #endif
2838
2839 #ifdef ACCUMULATE_OUTGOING_ARGS
2840   int initial_highest_arg_in_use = highest_outgoing_arg_in_use;
2841   char *initial_stack_usage_map = stack_usage_map;
2842 #endif
2843
2844 #ifdef REG_PARM_STACK_SPACE
2845 #ifdef MAYBE_REG_PARM_STACK_SPACE
2846   reg_parm_stack_space = MAYBE_REG_PARM_STACK_SPACE;
2847 #else
2848   reg_parm_stack_space = REG_PARM_STACK_SPACE (fndecl);
2849 #endif
2850 #endif
2851
2852   VA_START (p, nargs);
2853
2854 #ifndef __STDC__
2855   orgfun = va_arg (p, rtx);
2856   value = va_arg (p, rtx);
2857   no_queue = va_arg (p, int);
2858   outmode = va_arg (p, enum machine_mode);
2859   nargs = va_arg (p, int);
2860 #endif
2861
2862   is_const = no_queue;
2863   fun = orgfun;
2864
2865   /* If this kind of value comes back in memory,
2866      decide where in memory it should come back.  */
2867   if (aggregate_value_p (type_for_mode (outmode, 0)))
2868     {
2869 #ifdef PCC_STATIC_STRUCT_RETURN
2870       rtx pointer_reg
2871         = hard_function_value (build_pointer_type (type_for_mode (outmode, 0)),
2872                                0);
2873       mem_value = gen_rtx_MEM (outmode, pointer_reg);
2874       pcc_struct_value = 1;
2875       if (value == 0)
2876         value = gen_reg_rtx (outmode);
2877 #else /* not PCC_STATIC_STRUCT_RETURN */
2878       struct_value_size = GET_MODE_SIZE (outmode);
2879       if (value != 0 && GET_CODE (value) == MEM)
2880         mem_value = value;
2881       else
2882         mem_value = assign_stack_temp (outmode, GET_MODE_SIZE (outmode), 0);
2883 #endif
2884
2885       /* This call returns a big structure.  */
2886       is_const = 0;
2887     }
2888
2889   /* ??? Unfinished: must pass the memory address as an argument.  */
2890
2891   /* Copy all the libcall-arguments out of the varargs data
2892      and into a vector ARGVEC.
2893
2894      Compute how to pass each argument.  We only support a very small subset
2895      of the full argument passing conventions to limit complexity here since
2896      library functions shouldn't have many args.  */
2897
2898   argvec = (struct arg *) alloca ((nargs + 1) * sizeof (struct arg));
2899   bzero ((char *) argvec, (nargs + 1) * sizeof (struct arg));
2900
2901   INIT_CUMULATIVE_ARGS (args_so_far, NULL_TREE, fun, 0);
2902
2903   args_size.constant = 0;
2904   args_size.var = 0;
2905
2906   count = 0;
2907
2908   push_temp_slots ();
2909
2910   /* If there's a structure value address to be passed,
2911      either pass it in the special place, or pass it as an extra argument.  */
2912   if (mem_value && struct_value_rtx == 0 && ! pcc_struct_value)
2913     {
2914       rtx addr = XEXP (mem_value, 0);
2915       nargs++;
2916
2917       /* Make sure it is a reasonable operand for a move or push insn.  */
2918       if (GET_CODE (addr) != REG && GET_CODE (addr) != MEM
2919           && ! (CONSTANT_P (addr) && LEGITIMATE_CONSTANT_P (addr)))
2920         addr = force_operand (addr, NULL_RTX);
2921
2922       argvec[count].value = addr;
2923       argvec[count].mode = Pmode;
2924       argvec[count].partial = 0;
2925
2926       argvec[count].reg = FUNCTION_ARG (args_so_far, Pmode, NULL_TREE, 1);
2927 #ifdef FUNCTION_ARG_PARTIAL_NREGS
2928       if (FUNCTION_ARG_PARTIAL_NREGS (args_so_far, Pmode, NULL_TREE, 1))
2929         abort ();
2930 #endif
2931
2932       locate_and_pad_parm (Pmode, NULL_TREE,
2933                            argvec[count].reg && argvec[count].partial == 0,
2934                            NULL_TREE, &args_size, &argvec[count].offset,
2935                            &argvec[count].size);
2936
2937
2938       if (argvec[count].reg == 0 || argvec[count].partial != 0
2939 #ifdef REG_PARM_STACK_SPACE
2940           || 1
2941 #endif
2942           )
2943         args_size.constant += argvec[count].size.constant;
2944
2945       FUNCTION_ARG_ADVANCE (args_so_far, Pmode, (tree) 0, 1);
2946
2947       count++;
2948     }
2949
2950   for (; count < nargs; count++)
2951     {
2952       rtx val = va_arg (p, rtx);
2953       enum machine_mode mode = va_arg (p, enum machine_mode);
2954
2955       /* We cannot convert the arg value to the mode the library wants here;
2956          must do it earlier where we know the signedness of the arg.  */
2957       if (mode == BLKmode
2958           || (GET_MODE (val) != mode && GET_MODE (val) != VOIDmode))
2959         abort ();
2960
2961       /* On some machines, there's no way to pass a float to a library fcn.
2962          Pass it as a double instead.  */
2963 #ifdef LIBGCC_NEEDS_DOUBLE
2964       if (LIBGCC_NEEDS_DOUBLE && mode == SFmode)
2965         val = convert_modes (DFmode, SFmode, val, 0), mode = DFmode;
2966 #endif
2967
2968       /* There's no need to call protect_from_queue, because
2969          either emit_move_insn or emit_push_insn will do that.  */
2970
2971       /* Make sure it is a reasonable operand for a move or push insn.  */
2972       if (GET_CODE (val) != REG && GET_CODE (val) != MEM
2973           && ! (CONSTANT_P (val) && LEGITIMATE_CONSTANT_P (val)))
2974         val = force_operand (val, NULL_RTX);
2975
2976 #ifdef FUNCTION_ARG_PASS_BY_REFERENCE
2977       if (FUNCTION_ARG_PASS_BY_REFERENCE (args_so_far, mode, NULL_TREE, 1))
2978         {
2979           /* We do not support FUNCTION_ARG_CALLEE_COPIES here since it can
2980              be viewed as just an efficiency improvement.  */
2981           rtx slot = assign_stack_temp (mode, GET_MODE_SIZE (mode), 0);
2982           emit_move_insn (slot, val);
2983           val = XEXP (slot, 0);
2984           mode = Pmode;
2985         }
2986 #endif
2987
2988       argvec[count].value = val;
2989       argvec[count].mode = mode;
2990
2991       argvec[count].reg = FUNCTION_ARG (args_so_far, mode, NULL_TREE, 1);
2992       if (argvec[count].reg && GET_CODE (argvec[count].reg) == PARALLEL)
2993         abort ();
2994 #ifdef FUNCTION_ARG_PARTIAL_NREGS
2995       argvec[count].partial
2996         = FUNCTION_ARG_PARTIAL_NREGS (args_so_far, mode, NULL_TREE, 1);
2997 #else
2998       argvec[count].partial = 0;
2999 #endif
3000
3001       locate_and_pad_parm (mode, NULL_TREE,
3002                            argvec[count].reg && argvec[count].partial == 0,
3003                            NULL_TREE, &args_size, &argvec[count].offset,
3004                            &argvec[count].size);
3005
3006       if (argvec[count].size.var)
3007         abort ();
3008
3009 #ifndef REG_PARM_STACK_SPACE
3010       if (argvec[count].partial)
3011         argvec[count].size.constant -= argvec[count].partial * UNITS_PER_WORD;
3012 #endif
3013
3014       if (argvec[count].reg == 0 || argvec[count].partial != 0
3015 #ifdef REG_PARM_STACK_SPACE
3016           || 1
3017 #endif
3018           )
3019         args_size.constant += argvec[count].size.constant;
3020
3021       FUNCTION_ARG_ADVANCE (args_so_far, mode, (tree) 0, 1);
3022     }
3023   va_end (p);
3024
3025 #ifdef FINAL_REG_PARM_STACK_SPACE
3026   reg_parm_stack_space = FINAL_REG_PARM_STACK_SPACE (args_size.constant,
3027                                                      args_size.var);
3028 #endif
3029   /* If this machine requires an external definition for library
3030      functions, write one out.  */
3031   assemble_external_libcall (fun);
3032
3033   original_args_size = args_size;
3034 #ifdef STACK_BOUNDARY
3035   args_size.constant = (((args_size.constant + (STACK_BYTES - 1))
3036                          / STACK_BYTES) * STACK_BYTES);
3037 #endif
3038
3039 #ifdef REG_PARM_STACK_SPACE
3040   args_size.constant = MAX (args_size.constant,
3041                             reg_parm_stack_space);
3042 #ifndef OUTGOING_REG_PARM_STACK_SPACE
3043   args_size.constant -= reg_parm_stack_space;
3044 #endif
3045 #endif
3046
3047   if (args_size.constant > current_function_outgoing_args_size)
3048     current_function_outgoing_args_size = args_size.constant;
3049
3050 #ifdef ACCUMULATE_OUTGOING_ARGS
3051   /* Since the stack pointer will never be pushed, it is possible for
3052      the evaluation of a parm to clobber something we have already
3053      written to the stack.  Since most function calls on RISC machines
3054      do not use the stack, this is uncommon, but must work correctly.
3055
3056      Therefore, we save any area of the stack that was already written
3057      and that we are using.  Here we set up to do this by making a new
3058      stack usage map from the old one.
3059
3060      Another approach might be to try to reorder the argument
3061      evaluations to avoid this conflicting stack usage.  */
3062
3063   needed = args_size.constant;
3064 #if defined(REG_PARM_STACK_SPACE) && ! defined(OUTGOING_REG_PARM_STACK_SPACE)
3065   /* Since we will be writing into the entire argument area, the
3066      map must be allocated for its entire size, not just the part that
3067      is the responsibility of the caller.  */
3068   needed += reg_parm_stack_space;
3069 #endif
3070
3071 #ifdef ARGS_GROW_DOWNWARD
3072   highest_outgoing_arg_in_use = MAX (initial_highest_arg_in_use,
3073                                      needed + 1);
3074 #else
3075   highest_outgoing_arg_in_use = MAX (initial_highest_arg_in_use,
3076                                      needed);
3077 #endif
3078   stack_usage_map = (char *) alloca (highest_outgoing_arg_in_use);
3079
3080   if (initial_highest_arg_in_use)
3081     bcopy (initial_stack_usage_map, stack_usage_map,
3082            initial_highest_arg_in_use);
3083
3084   if (initial_highest_arg_in_use != highest_outgoing_arg_in_use)
3085     bzero (&stack_usage_map[initial_highest_arg_in_use],
3086            highest_outgoing_arg_in_use - initial_highest_arg_in_use);
3087   needed = 0;
3088
3089   /* The address of the outgoing argument list must not be copied to a
3090      register here, because argblock would be left pointing to the
3091      wrong place after the call to allocate_dynamic_stack_space below.
3092      */
3093
3094   argblock = virtual_outgoing_args_rtx;
3095 #else /* not ACCUMULATE_OUTGOING_ARGS */
3096 #ifndef PUSH_ROUNDING
3097   argblock = push_block (GEN_INT (args_size.constant), 0, 0);
3098 #endif
3099 #endif
3100
3101 #ifdef PUSH_ARGS_REVERSED
3102 #ifdef STACK_BOUNDARY
3103   /* If we push args individually in reverse order, perform stack alignment
3104      before the first push (the last arg).  */
3105   if (argblock == 0)
3106     anti_adjust_stack (GEN_INT (args_size.constant
3107                                 - original_args_size.constant));
3108 #endif
3109 #endif
3110
3111 #ifdef PUSH_ARGS_REVERSED
3112   inc = -1;
3113   argnum = nargs - 1;
3114 #else
3115   inc = 1;
3116   argnum = 0;
3117 #endif
3118
3119 #if defined(ACCUMULATE_OUTGOING_ARGS) && defined(REG_PARM_STACK_SPACE)
3120   /* The argument list is the property of the called routine and it
3121      may clobber it.  If the fixed area has been used for previous
3122      parameters, we must save and restore it.
3123
3124      Here we compute the boundary of the that needs to be saved, if any.  */
3125
3126 #ifdef ARGS_GROW_DOWNWARD
3127   for (count = 0; count < reg_parm_stack_space + 1; count++)
3128 #else
3129   for (count = 0; count < reg_parm_stack_space; count++)
3130 #endif
3131     {
3132       if (count >=  highest_outgoing_arg_in_use
3133           || stack_usage_map[count] == 0)
3134         continue;
3135
3136       if (low_to_save == -1)
3137         low_to_save = count;
3138
3139       high_to_save = count;
3140     }
3141
3142   if (low_to_save >= 0)
3143     {
3144       int num_to_save = high_to_save - low_to_save + 1;
3145       enum machine_mode save_mode
3146         = mode_for_size (num_to_save * BITS_PER_UNIT, MODE_INT, 1);
3147       rtx stack_area;
3148
3149       /* If we don't have the required alignment, must do this in BLKmode.  */
3150       if ((low_to_save & (MIN (GET_MODE_SIZE (save_mode),
3151                                BIGGEST_ALIGNMENT / UNITS_PER_WORD) - 1)))
3152         save_mode = BLKmode;
3153
3154 #ifdef ARGS_GROW_DOWNWARD
3155       stack_area = gen_rtx_MEM (save_mode,
3156                                 memory_address (save_mode,
3157                                                 plus_constant (argblock,
3158                                                                - high_to_save)));
3159 #else
3160       stack_area = gen_rtx_MEM (save_mode,
3161                                 memory_address (save_mode,
3162                                                 plus_constant (argblock,
3163                                                                low_to_save)));
3164 #endif
3165       if (save_mode == BLKmode)
3166         {
3167           save_area = assign_stack_temp (BLKmode, num_to_save, 0);
3168           MEM_IN_STRUCT_P (save_area) = 0;
3169           emit_block_move (validize_mem (save_area), stack_area,
3170                            GEN_INT (num_to_save),
3171                            PARM_BOUNDARY / BITS_PER_UNIT);
3172         }
3173       else
3174         {
3175           save_area = gen_reg_rtx (save_mode);
3176           emit_move_insn (save_area, stack_area);
3177         }
3178     }
3179 #endif
3180           
3181   /* Push the args that need to be pushed.  */
3182
3183   /* ARGNUM indexes the ARGVEC array in the order in which the arguments
3184      are to be pushed.  */
3185   for (count = 0; count < nargs; count++, argnum += inc)
3186     {
3187       register enum machine_mode mode = argvec[argnum].mode;
3188       register rtx val = argvec[argnum].value;
3189       rtx reg = argvec[argnum].reg;
3190       int partial = argvec[argnum].partial;
3191       int lower_bound, upper_bound, i;
3192
3193       if (! (reg != 0 && partial == 0))
3194         {
3195 #ifdef ACCUMULATE_OUTGOING_ARGS
3196           /* If this is being stored into a pre-allocated, fixed-size, stack
3197              area, save any previous data at that location.  */
3198
3199 #ifdef ARGS_GROW_DOWNWARD
3200           /* stack_slot is negative, but we want to index stack_usage_map
3201              with positive values.  */
3202           upper_bound = -argvec[argnum].offset.constant + 1;
3203           lower_bound = upper_bound - argvec[argnum].size.constant;
3204 #else
3205           lower_bound = argvec[argnum].offset.constant;
3206           upper_bound = lower_bound + argvec[argnum].size.constant;
3207 #endif
3208
3209           for (i = lower_bound; i < upper_bound; i++)
3210             if (stack_usage_map[i]
3211 #ifdef REG_PARM_STACK_SPACE
3212                 /* Don't store things in the fixed argument area at this point;
3213                    it has already been saved.  */
3214                 && i > reg_parm_stack_space
3215 #endif
3216                 )
3217               break;
3218
3219           if (i != upper_bound)
3220             {
3221               /* We need to make a save area.  See what mode we can make it.  */
3222               enum machine_mode save_mode
3223                 = mode_for_size (argvec[argnum].size.constant * BITS_PER_UNIT,
3224                                  MODE_INT, 1);
3225               rtx stack_area
3226                 = gen_rtx_MEM (save_mode,
3227                                memory_address (save_mode,
3228                                                plus_constant (argblock,
3229                                                               argvec[argnum].offset.constant)));
3230               argvec[argnum].save_area = gen_reg_rtx (save_mode);
3231               emit_move_insn (argvec[argnum].save_area, stack_area);
3232             }
3233 #endif
3234           emit_push_insn (val, mode, NULL_TREE, NULL_RTX, 0, partial, reg, 0,
3235                           argblock, GEN_INT (argvec[argnum].offset.constant));
3236
3237 #ifdef ACCUMULATE_OUTGOING_ARGS
3238           /* Now mark the segment we just used.  */
3239           for (i = lower_bound; i < upper_bound; i++)
3240             stack_usage_map[i] = 1;
3241 #endif
3242
3243           NO_DEFER_POP;
3244         }
3245     }
3246
3247 #ifndef PUSH_ARGS_REVERSED
3248 #ifdef STACK_BOUNDARY
3249   /* If we pushed args in forward order, perform stack alignment
3250      after pushing the last arg.  */
3251   if (argblock == 0)
3252     anti_adjust_stack (GEN_INT (args_size.constant
3253                                 - original_args_size.constant));
3254 #endif
3255 #endif
3256
3257 #ifdef PUSH_ARGS_REVERSED
3258   argnum = nargs - 1;
3259 #else
3260   argnum = 0;
3261 #endif
3262
3263   fun = prepare_call_address (fun, NULL_TREE, &call_fusage, 0);
3264
3265   /* Now load any reg parms into their regs.  */
3266
3267   /* ARGNUM indexes the ARGVEC array in the order in which the arguments
3268      are to be pushed.  */
3269   for (count = 0; count < nargs; count++, argnum += inc)
3270     {
3271       register enum machine_mode mode = argvec[argnum].mode;
3272       register rtx val = argvec[argnum].value;
3273       rtx reg = argvec[argnum].reg;
3274       int partial = argvec[argnum].partial;
3275
3276       if (reg != 0 && partial == 0)
3277         emit_move_insn (reg, val);
3278       NO_DEFER_POP;
3279     }
3280
3281 #if 0
3282   /* For version 1.37, try deleting this entirely.  */
3283   if (! no_queue)
3284     emit_queue ();
3285 #endif
3286
3287   /* Any regs containing parms remain in use through the call.  */
3288   for (count = 0; count < nargs; count++)
3289     if (argvec[count].reg != 0)
3290        use_reg (&call_fusage, argvec[count].reg);
3291
3292   /* Pass the function the address in which to return a structure value.  */
3293   if (mem_value != 0 && struct_value_rtx != 0 && ! pcc_struct_value)
3294     {
3295       emit_move_insn (struct_value_rtx,
3296                       force_reg (Pmode,
3297                                  force_operand (XEXP (mem_value, 0),
3298                                                 NULL_RTX)));
3299       if (GET_CODE (struct_value_rtx) == REG)
3300           use_reg (&call_fusage, struct_value_rtx);
3301     }
3302
3303   /* Don't allow popping to be deferred, since then
3304      cse'ing of library calls could delete a call and leave the pop.  */
3305   NO_DEFER_POP;
3306
3307   /* We pass the old value of inhibit_defer_pop + 1 to emit_call_1, which
3308      will set inhibit_defer_pop to that value.  */
3309   /* See the comment in emit_library_call about the function type we build
3310      and pass here.  */
3311
3312   emit_call_1 (fun, 
3313                get_identifier (XSTR (orgfun, 0)),
3314                build_function_type (type_for_mode (outmode, 0), NULL_TREE),
3315                args_size.constant, struct_value_size,
3316                FUNCTION_ARG (args_so_far, VOIDmode, void_type_node, 1),
3317                mem_value == 0 ? hard_libcall_value (outmode) : NULL_RTX,
3318                old_inhibit_defer_pop + 1, call_fusage, is_const);
3319
3320   /* Now restore inhibit_defer_pop to its actual original value.  */
3321   OK_DEFER_POP;
3322
3323   pop_temp_slots ();
3324
3325   /* Copy the value to the right place.  */
3326   if (outmode != VOIDmode)
3327     {
3328       if (mem_value)
3329         {
3330           if (value == 0)
3331             value = mem_value;
3332           if (value != mem_value)
3333             emit_move_insn (value, mem_value);
3334         }
3335       else if (value != 0)
3336         emit_move_insn (value, hard_libcall_value (outmode));
3337       else
3338         value = hard_libcall_value (outmode);
3339     }
3340
3341 #ifdef ACCUMULATE_OUTGOING_ARGS
3342 #ifdef REG_PARM_STACK_SPACE
3343   if (save_area)
3344     {
3345       enum machine_mode save_mode = GET_MODE (save_area);
3346 #ifdef ARGS_GROW_DOWNWARD
3347       rtx stack_area
3348         = gen_rtx_MEM (save_mode,
3349                        memory_address (save_mode,
3350                                        plus_constant (argblock,
3351                                                       - high_to_save)));
3352 #else
3353       rtx stack_area
3354         = gen_rtx_MEM (save_mode,
3355                        memory_address (save_mode,
3356                                        plus_constant (argblock, low_to_save)));
3357 #endif
3358       if (save_mode != BLKmode)
3359         emit_move_insn (stack_area, save_area);
3360       else
3361         emit_block_move (stack_area, validize_mem (save_area),
3362                          GEN_INT (high_to_save - low_to_save + 1),
3363                              PARM_BOUNDARY / BITS_PER_UNIT);
3364     }
3365 #endif
3366           
3367   /* If we saved any argument areas, restore them.  */
3368   for (count = 0; count < nargs; count++)
3369     if (argvec[count].save_area)
3370       {
3371         enum machine_mode save_mode = GET_MODE (argvec[count].save_area);
3372         rtx stack_area
3373           = gen_rtx_MEM (save_mode,
3374                      memory_address (save_mode, plus_constant (argblock,
3375                                      argvec[count].offset.constant)));
3376
3377         emit_move_insn (stack_area, argvec[count].save_area);
3378       }
3379
3380   highest_outgoing_arg_in_use = initial_highest_arg_in_use;
3381   stack_usage_map = initial_stack_usage_map;
3382 #endif
3383
3384   return value;
3385 }
3386 \f
3387 #if 0
3388 /* Return an rtx which represents a suitable home on the stack
3389    given TYPE, the type of the argument looking for a home.
3390    This is called only for BLKmode arguments.
3391
3392    SIZE is the size needed for this target.
3393    ARGS_ADDR is the address of the bottom of the argument block for this call.
3394    OFFSET describes this parameter's offset into ARGS_ADDR.  It is meaningless
3395    if this machine uses push insns.  */
3396
3397 static rtx
3398 target_for_arg (type, size, args_addr, offset)
3399      tree type;
3400      rtx size;
3401      rtx args_addr;
3402      struct args_size offset;
3403 {
3404   rtx target;
3405   rtx offset_rtx = ARGS_SIZE_RTX (offset);
3406
3407   /* We do not call memory_address if possible,
3408      because we want to address as close to the stack
3409      as possible.  For non-variable sized arguments,
3410      this will be stack-pointer relative addressing.  */
3411   if (GET_CODE (offset_rtx) == CONST_INT)
3412     target = plus_constant (args_addr, INTVAL (offset_rtx));
3413   else
3414     {
3415       /* I have no idea how to guarantee that this
3416          will work in the presence of register parameters.  */
3417       target = gen_rtx_PLUS (Pmode, args_addr, offset_rtx);
3418       target = memory_address (QImode, target);
3419     }
3420
3421   return gen_rtx_MEM (BLKmode, target);
3422 }
3423 #endif
3424 \f
3425 /* Store a single argument for a function call
3426    into the register or memory area where it must be passed.
3427    *ARG describes the argument value and where to pass it.
3428
3429    ARGBLOCK is the address of the stack-block for all the arguments,
3430    or 0 on a machine where arguments are pushed individually.
3431
3432    MAY_BE_ALLOCA nonzero says this could be a call to `alloca'
3433    so must be careful about how the stack is used. 
3434
3435    VARIABLE_SIZE nonzero says that this was a variable-sized outgoing
3436    argument stack.  This is used if ACCUMULATE_OUTGOING_ARGS to indicate
3437    that we need not worry about saving and restoring the stack.
3438
3439    FNDECL is the declaration of the function we are calling.  */
3440
3441 static void
3442 store_one_arg (arg, argblock, may_be_alloca, variable_size, fndecl,
3443                reg_parm_stack_space)
3444      struct arg_data *arg;
3445      rtx argblock;
3446      int may_be_alloca;
3447      int variable_size;
3448      tree fndecl;
3449      int reg_parm_stack_space;
3450 {
3451   register tree pval = arg->tree_value;
3452   rtx reg = 0;
3453   int partial = 0;
3454   int used = 0;
3455   int i, lower_bound, upper_bound;
3456
3457   if (TREE_CODE (pval) == ERROR_MARK)
3458     return;
3459
3460   /* Push a new temporary level for any temporaries we make for
3461      this argument.  */
3462   push_temp_slots ();
3463
3464 #ifdef ACCUMULATE_OUTGOING_ARGS
3465   /* If this is being stored into a pre-allocated, fixed-size, stack area,
3466      save any previous data at that location.  */
3467   if (argblock && ! variable_size && arg->stack)
3468     {
3469 #ifdef ARGS_GROW_DOWNWARD
3470       /* stack_slot is negative, but we want to index stack_usage_map
3471          with positive values.  */
3472       if (GET_CODE (XEXP (arg->stack_slot, 0)) == PLUS)
3473         upper_bound = -INTVAL (XEXP (XEXP (arg->stack_slot, 0), 1)) + 1;
3474       else
3475         upper_bound = 0;
3476
3477       lower_bound = upper_bound - arg->size.constant;
3478 #else
3479       if (GET_CODE (XEXP (arg->stack_slot, 0)) == PLUS)
3480         lower_bound = INTVAL (XEXP (XEXP (arg->stack_slot, 0), 1));
3481       else
3482         lower_bound = 0;
3483
3484       upper_bound = lower_bound + arg->size.constant;
3485 #endif
3486
3487       for (i = lower_bound; i < upper_bound; i++)
3488         if (stack_usage_map[i]
3489 #ifdef REG_PARM_STACK_SPACE
3490             /* Don't store things in the fixed argument area at this point;
3491                it has already been saved.  */
3492             && i > reg_parm_stack_space
3493 #endif
3494             )
3495           break;
3496
3497       if (i != upper_bound)
3498         {
3499           /* We need to make a save area.  See what mode we can make it.  */
3500           enum machine_mode save_mode
3501             = mode_for_size (arg->size.constant * BITS_PER_UNIT, MODE_INT, 1);
3502           rtx stack_area
3503             = gen_rtx_MEM (save_mode,
3504                            memory_address (save_mode,
3505                                            XEXP (arg->stack_slot, 0)));
3506
3507           if (save_mode == BLKmode)
3508             {
3509               arg->save_area = assign_stack_temp (BLKmode,
3510                                                   arg->size.constant, 0);
3511               MEM_IN_STRUCT_P (arg->save_area)
3512                 = AGGREGATE_TYPE_P (TREE_TYPE (arg->tree_value));
3513               preserve_temp_slots (arg->save_area);
3514               emit_block_move (validize_mem (arg->save_area), stack_area,
3515                                GEN_INT (arg->size.constant),
3516                                PARM_BOUNDARY / BITS_PER_UNIT);
3517             }
3518           else
3519             {
3520               arg->save_area = gen_reg_rtx (save_mode);
3521               emit_move_insn (arg->save_area, stack_area);
3522             }
3523         }
3524     }
3525 #endif
3526
3527   /* If this isn't going to be placed on both the stack and in registers,
3528      set up the register and number of words.  */
3529   if (! arg->pass_on_stack)
3530     reg = arg->reg, partial = arg->partial;
3531
3532   if (reg != 0 && partial == 0)
3533     /* Being passed entirely in a register.  We shouldn't be called in
3534        this case.   */
3535     abort ();
3536
3537   /* If this arg needs special alignment, don't load the registers
3538      here.  */
3539   if (arg->n_aligned_regs != 0)
3540     reg = 0;
3541   
3542   /* If this is being passed partially in a register, we can't evaluate
3543      it directly into its stack slot.  Otherwise, we can.  */
3544   if (arg->value == 0)
3545     {
3546 #ifdef ACCUMULATE_OUTGOING_ARGS
3547       /* stack_arg_under_construction is nonzero if a function argument is
3548          being evaluated directly into the outgoing argument list and
3549          expand_call must take special action to preserve the argument list
3550          if it is called recursively.
3551
3552          For scalar function arguments stack_usage_map is sufficient to
3553          determine which stack slots must be saved and restored.  Scalar
3554          arguments in general have pass_on_stack == 0.
3555
3556          If this argument is initialized by a function which takes the
3557          address of the argument (a C++ constructor or a C function
3558          returning a BLKmode structure), then stack_usage_map is
3559          insufficient and expand_call must push the stack around the
3560          function call.  Such arguments have pass_on_stack == 1.
3561
3562          Note that it is always safe to set stack_arg_under_construction,
3563          but this generates suboptimal code if set when not needed.  */
3564
3565       if (arg->pass_on_stack)
3566         stack_arg_under_construction++;
3567 #endif
3568       arg->value = expand_expr (pval,
3569                                 (partial
3570                                  || TYPE_MODE (TREE_TYPE (pval)) != arg->mode)
3571                                 ? NULL_RTX : arg->stack,
3572                                 VOIDmode, 0);
3573
3574       /* If we are promoting object (or for any other reason) the mode
3575          doesn't agree, convert the mode.  */
3576
3577       if (arg->mode != TYPE_MODE (TREE_TYPE (pval)))
3578         arg->value = convert_modes (arg->mode, TYPE_MODE (TREE_TYPE (pval)),
3579                                     arg->value, arg->unsignedp);
3580
3581 #ifdef ACCUMULATE_OUTGOING_ARGS
3582       if (arg->pass_on_stack)
3583         stack_arg_under_construction--;
3584 #endif
3585     }
3586
3587   /* Don't allow anything left on stack from computation
3588      of argument to alloca.  */
3589   if (may_be_alloca)
3590     do_pending_stack_adjust ();
3591
3592   if (arg->value == arg->stack)
3593     {
3594       /* If the value is already in the stack slot, we are done.  */
3595       if (flag_check_memory_usage && GET_CODE (arg->stack) == MEM)
3596         {
3597           if (arg->mode == BLKmode)
3598             abort ();
3599
3600           emit_library_call (chkr_set_right_libfunc, 1, VOIDmode, 3,
3601                              XEXP (arg->stack, 0), ptr_mode, 
3602                              GEN_INT (GET_MODE_SIZE (arg->mode)),
3603                              TYPE_MODE (sizetype),
3604                              GEN_INT (MEMORY_USE_RW),
3605                              TYPE_MODE (integer_type_node));
3606         }
3607     }
3608   else if (arg->mode != BLKmode)
3609     {
3610       register int size;
3611
3612       /* Argument is a scalar, not entirely passed in registers.
3613          (If part is passed in registers, arg->partial says how much
3614          and emit_push_insn will take care of putting it there.)
3615          
3616          Push it, and if its size is less than the
3617          amount of space allocated to it,
3618          also bump stack pointer by the additional space.
3619          Note that in C the default argument promotions
3620          will prevent such mismatches.  */
3621
3622       size = GET_MODE_SIZE (arg->mode);
3623       /* Compute how much space the push instruction will push.
3624          On many machines, pushing a byte will advance the stack
3625          pointer by a halfword.  */
3626 #ifdef PUSH_ROUNDING
3627       size = PUSH_ROUNDING (size);
3628 #endif
3629       used = size;
3630
3631       /* Compute how much space the argument should get:
3632          round up to a multiple of the alignment for arguments.  */
3633       if (none != FUNCTION_ARG_PADDING (arg->mode, TREE_TYPE (pval)))
3634         used = (((size + PARM_BOUNDARY / BITS_PER_UNIT - 1)
3635                  / (PARM_BOUNDARY / BITS_PER_UNIT))
3636                 * (PARM_BOUNDARY / BITS_PER_UNIT));
3637
3638       /* This isn't already where we want it on the stack, so put it there.
3639          This can either be done with push or copy insns.  */
3640       emit_push_insn (arg->value, arg->mode, TREE_TYPE (pval), NULL_RTX,
3641                       0, partial, reg, used - size,
3642                       argblock, ARGS_SIZE_RTX (arg->offset));
3643     }
3644   else
3645     {
3646       /* BLKmode, at least partly to be pushed.  */
3647
3648       register int excess;
3649       rtx size_rtx;
3650
3651       /* Pushing a nonscalar.
3652          If part is passed in registers, PARTIAL says how much
3653          and emit_push_insn will take care of putting it there.  */
3654
3655       /* Round its size up to a multiple
3656          of the allocation unit for arguments.  */
3657
3658       if (arg->size.var != 0)
3659         {
3660           excess = 0;
3661           size_rtx = ARGS_SIZE_RTX (arg->size);
3662         }
3663       else
3664         {
3665           /* PUSH_ROUNDING has no effect on us, because
3666              emit_push_insn for BLKmode is careful to avoid it.  */
3667           excess = (arg->size.constant - int_size_in_bytes (TREE_TYPE (pval))
3668                     + partial * UNITS_PER_WORD);
3669           size_rtx = expr_size (pval);
3670         }
3671
3672       emit_push_insn (arg->value, arg->mode, TREE_TYPE (pval), size_rtx,
3673                       TYPE_ALIGN (TREE_TYPE (pval)) / BITS_PER_UNIT, partial,
3674                       reg, excess, argblock, ARGS_SIZE_RTX (arg->offset));
3675     }
3676
3677
3678   /* Unless this is a partially-in-register argument, the argument is now
3679      in the stack. 
3680
3681      ??? Note that this can change arg->value from arg->stack to
3682      arg->stack_slot and it matters when they are not the same.
3683      It isn't totally clear that this is correct in all cases.  */
3684   if (partial == 0)
3685     arg->value = arg->stack_slot;
3686
3687   /* Once we have pushed something, pops can't safely
3688      be deferred during the rest of the arguments.  */
3689   NO_DEFER_POP;
3690
3691   /* ANSI doesn't require a sequence point here,
3692      but PCC has one, so this will avoid some problems.  */
3693   emit_queue ();
3694
3695   /* Free any temporary slots made in processing this argument.  Show
3696      that we might have taken the address of something and pushed that
3697      as an operand.  */
3698   preserve_temp_slots (NULL_RTX);
3699   free_temp_slots ();
3700   pop_temp_slots ();
3701
3702 #ifdef ACCUMULATE_OUTGOING_ARGS
3703   /* Now mark the segment we just used.  */
3704   if (argblock && ! variable_size && arg->stack)
3705     for (i = lower_bound; i < upper_bound; i++)
3706       stack_usage_map[i] = 1;
3707 #endif
3708 }