OSDN Git Service

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