OSDN Git Service

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