OSDN Git Service

(store_one_arg): Fix typo in previous change.
[pf3gnuchains/gcc-fork.git] / gcc / calls.c
1 /* Convert function calls to rtl insns, for GNU C compiler.
2    Copyright (C) 1989, 1992 Free Software Foundation, Inc.
3
4 This file is part of GNU CC.
5
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING.  If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
19
20 #include "config.h"
21 #include "rtl.h"
22 #include "tree.h"
23 #include "flags.h"
24 #include "expr.h"
25 #include "gvarargs.h"
26 #include "insn-flags.h"
27
28 /* Decide whether a function's arguments should be processed
29    from first to last or from last to first.
30
31    They should if the stack and args grow in opposite directions, but
32    only if we have push insns.  */
33
34 #ifdef PUSH_ROUNDING
35
36 #if defined (STACK_GROWS_DOWNWARD) != defined (ARGS_GROW_DOWNARD)
37 #define PUSH_ARGS_REVERSED      /* If it's last to first */
38 #endif
39
40 #endif
41
42 /* Like STACK_BOUNDARY but in units of bytes, not bits.  */
43 #define STACK_BYTES (STACK_BOUNDARY / BITS_PER_UNIT)
44
45 /* Data structure and subroutines used within expand_call.  */
46
47 struct arg_data
48 {
49   /* Tree node for this argument.  */
50   tree tree_value;
51   /* Mode for value; TYPE_MODE unless promoted.  */
52   enum machine_mode mode;
53   /* Current RTL value for argument, or 0 if it isn't precomputed.  */
54   rtx value;
55   /* Initially-compute RTL value for argument; only for const functions.  */
56   rtx initial_value;
57   /* Register to pass this argument in, 0 if passed on stack, or an
58      EXPR_LIST if the arg is to be copied into multiple different
59      registers.  */
60   rtx reg;
61   /* If REG was promoted from the actual mode of the argument expression,
62      indicates whether the promotion is sign- or zero-extended.  */
63   int unsignedp;
64   /* Number of registers to use.  0 means put the whole arg in registers.
65      Also 0 if not passed in registers.  */
66   int partial;
67   /* Non-zero if argument must be passed on stack.
68      Note that some arguments may be passed on the stack
69      even though pass_on_stack is zero, just because FUNCTION_ARG says so.
70      pass_on_stack identifies arguments that *cannot* go in registers.  */
71   int pass_on_stack;
72   /* Offset of this argument from beginning of stack-args.  */
73   struct args_size offset;
74   /* Similar, but offset to the start of the stack slot.  Different from
75      OFFSET if this arg pads downward.  */
76   struct args_size slot_offset;
77   /* Size of this argument on the stack, rounded up for any padding it gets,
78      parts of the argument passed in registers do not count.
79      If REG_PARM_STACK_SPACE is defined, then register parms
80      are counted here as well.  */
81   struct args_size size;
82   /* Location on the stack at which parameter should be stored.  The store
83      has already been done if STACK == VALUE.  */
84   rtx stack;
85   /* Location on the stack of the start of this argument slot.  This can
86      differ from STACK if this arg pads downward.  This location is known
87      to be aligned to FUNCTION_ARG_BOUNDARY.  */
88   rtx stack_slot;
89 #ifdef ACCUMULATE_OUTGOING_ARGS
90   /* Place that this stack area has been saved, if needed.  */
91   rtx save_area;
92 #endif
93 #ifdef STRICT_ALIGNMENT
94   /* If an argument's alignment does not permit direct copying into registers,
95      copy in smaller-sized pieces into pseudos.  These are stored in a
96      block pointed to by this field.  The next field says how many
97      word-sized pseudos we made.  */
98   rtx *aligned_regs;
99   int n_aligned_regs;
100 #endif
101 };
102
103 #ifdef ACCUMULATE_OUTGOING_ARGS
104 /* A vector of one char per byte of stack space.  A byte if non-zero if
105    the corresponding stack location has been used.
106    This vector is used to prevent a function call within an argument from
107    clobbering any stack already set up.  */
108 static char *stack_usage_map;
109
110 /* Size of STACK_USAGE_MAP.  */
111 static int highest_outgoing_arg_in_use;
112
113 /* stack_arg_under_construction is nonzero when an argument may be
114    initialized with a constructor call (including a C function that
115    returns a BLKmode struct) and expand_call must take special action
116    to make sure the object being constructed does not overlap the
117    argument list for the constructor call.  */
118 int stack_arg_under_construction;
119 #endif
120
121 static int calls_function       PROTO((tree, int));
122 static void emit_call_1         PROTO((rtx, tree, int, int, rtx, rtx, int,
123                                        rtx, int));
124 static void store_one_arg       PROTO ((struct arg_data *, rtx, int, int,
125                                         tree, int));
126 \f
127 /* If WHICH is 1, return 1 if EXP contains a call to the built-in function
128    `alloca'.
129
130    If WHICH is 0, return 1 if EXP contains a call to any function.
131    Actually, we only need return 1 if evaluating EXP would require pushing
132    arguments on the stack, but that is too difficult to compute, so we just
133    assume any function call might require the stack.  */
134
135 static int
136 calls_function (exp, which)
137      tree exp;
138      int which;
139 {
140   register int i;
141   int type = TREE_CODE_CLASS (TREE_CODE (exp));
142   int length = tree_code_length[(int) TREE_CODE (exp)];
143
144   /* Only expressions and references can contain calls.  */
145
146   if (type != 'e' && type != '<' && type != '1' && type != '2' && type != 'r'
147       && type != 'b')
148     return 0;
149
150   switch (TREE_CODE (exp))
151     {
152     case CALL_EXPR:
153       if (which == 0)
154         return 1;
155       else if (TREE_CODE (TREE_OPERAND (exp, 0)) == ADDR_EXPR
156                && (TREE_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0))
157                    == FUNCTION_DECL)
158                && DECL_BUILT_IN (TREE_OPERAND (TREE_OPERAND (exp, 0), 0))
159                && (DECL_FUNCTION_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0))
160                    == BUILT_IN_ALLOCA))
161         return 1;
162
163       /* Third operand is RTL.  */
164       length = 2;
165       break;
166
167     case SAVE_EXPR:
168       if (SAVE_EXPR_RTL (exp) != 0)
169         return 0;
170       break;
171
172     case BLOCK:
173       {
174         register tree local;
175
176         for (local = BLOCK_VARS (exp); local; local = TREE_CHAIN (local))
177           if (DECL_INITIAL (local) != 0
178               && calls_function (DECL_INITIAL (local), which))
179             return 1;
180       }
181       {
182         register tree subblock;
183
184         for (subblock = BLOCK_SUBBLOCKS (exp);
185              subblock;
186              subblock = TREE_CHAIN (subblock))
187           if (calls_function (subblock, which))
188             return 1;
189       }
190       return 0;
191
192     case METHOD_CALL_EXPR:
193       length = 3;
194       break;
195
196     case WITH_CLEANUP_EXPR:
197       length = 1;
198       break;
199
200     case RTL_EXPR:
201       return 0;
202     }
203
204   for (i = 0; i < length; i++)
205     if (TREE_OPERAND (exp, i) != 0
206         && calls_function (TREE_OPERAND (exp, i), which))
207       return 1;
208
209   return 0;
210 }
211 \f
212 /* Force FUNEXP into a form suitable for the address of a CALL,
213    and return that as an rtx.  Also load the static chain register
214    if FNDECL is a nested function.
215
216    USE_INSNS points to a variable holding a chain of USE insns
217    to which a USE of the static chain
218    register should be added, if required.  */
219
220 rtx
221 prepare_call_address (funexp, fndecl, use_insns)
222      rtx funexp;
223      tree fndecl;
224      rtx *use_insns;
225 {
226   rtx static_chain_value = 0;
227
228   funexp = protect_from_queue (funexp, 0);
229
230   if (fndecl != 0)
231     /* Get possible static chain value for nested function in C. */
232     static_chain_value = lookup_static_chain (fndecl);
233
234   /* Make a valid memory address and copy constants thru pseudo-regs,
235      but not for a constant address if -fno-function-cse.  */
236   if (GET_CODE (funexp) != SYMBOL_REF)
237     funexp = memory_address (FUNCTION_MODE, funexp);
238   else
239     {
240 #ifndef NO_FUNCTION_CSE
241       if (optimize && ! flag_no_function_cse)
242 #ifdef NO_RECURSIVE_FUNCTION_CSE
243         if (fndecl != current_function_decl)
244 #endif
245           funexp = force_reg (Pmode, funexp);
246 #endif
247     }
248
249   if (static_chain_value != 0)
250     {
251       emit_move_insn (static_chain_rtx, static_chain_value);
252
253       /* Put the USE insn in the chain we were passed.  It will later be
254          output immediately in front of the CALL insn.  */
255       push_to_sequence (*use_insns);
256       emit_insn (gen_rtx (USE, VOIDmode, static_chain_rtx));
257       *use_insns = get_insns ();
258       end_sequence ();
259     }
260
261   return funexp;
262 }
263
264 /* Generate instructions to call function FUNEXP,
265    and optionally pop the results.
266    The CALL_INSN is the first insn generated.
267
268    FUNTYPE is the data type of the function, or, for a library call,
269    the identifier for the name of the call.  This is given to the
270    macro RETURN_POPS_ARGS to determine whether this function pops its own args.
271
272    STACK_SIZE is the number of bytes of arguments on the stack,
273    rounded up to STACK_BOUNDARY; zero if the size is variable.
274    This is both to put into the call insn and
275    to generate explicit popping code if necessary.
276
277    STRUCT_VALUE_SIZE is the number of bytes wanted in a structure value.
278    It is zero if this call doesn't want a structure value.
279
280    NEXT_ARG_REG is the rtx that results from executing
281      FUNCTION_ARG (args_so_far, VOIDmode, void_type_node, 1)
282    just after all the args have had their registers assigned.
283    This could be whatever you like, but normally it is the first
284    arg-register beyond those used for args in this call,
285    or 0 if all the arg-registers are used in this call.
286    It is passed on to `gen_call' so you can put this info in the call insn.
287
288    VALREG is a hard register in which a value is returned,
289    or 0 if the call does not return a value.
290
291    OLD_INHIBIT_DEFER_POP is the value that `inhibit_defer_pop' had before
292    the args to this call were processed.
293    We restore `inhibit_defer_pop' to that value.
294
295    USE_INSNS is a chain of USE insns to be emitted immediately before
296    the actual CALL insn.
297
298    IS_CONST is true if this is a `const' call.  */
299
300 static void
301 emit_call_1 (funexp, funtype, stack_size, struct_value_size, next_arg_reg,
302              valreg, old_inhibit_defer_pop, use_insns, is_const)
303      rtx funexp;
304      tree funtype;
305      int stack_size;
306      int struct_value_size;
307      rtx next_arg_reg;
308      rtx valreg;
309      int old_inhibit_defer_pop;
310      rtx use_insns;
311      int is_const;
312 {
313   rtx stack_size_rtx = GEN_INT (stack_size);
314   rtx struct_value_size_rtx = GEN_INT (struct_value_size);
315   rtx call_insn;
316   int already_popped = 0;
317
318   /* Ensure address is valid.  SYMBOL_REF is already valid, so no need,
319      and we don't want to load it into a register as an optimization,
320      because prepare_call_address already did it if it should be done.  */
321   if (GET_CODE (funexp) != SYMBOL_REF)
322     funexp = memory_address (FUNCTION_MODE, funexp);
323
324 #ifndef ACCUMULATE_OUTGOING_ARGS
325 #if defined (HAVE_call_pop) && defined (HAVE_call_value_pop)
326   if (HAVE_call_pop && HAVE_call_value_pop
327       && (RETURN_POPS_ARGS (funtype, stack_size) > 0 || stack_size == 0))
328     {
329       rtx n_pop = GEN_INT (RETURN_POPS_ARGS (funtype, stack_size));
330       rtx pat;
331
332       /* If this subroutine pops its own args, record that in the call insn
333          if possible, for the sake of frame pointer elimination.  */
334       if (valreg)
335         pat = gen_call_value_pop (valreg,
336                                   gen_rtx (MEM, FUNCTION_MODE, funexp),
337                                   stack_size_rtx, next_arg_reg, n_pop);
338       else
339         pat = gen_call_pop (gen_rtx (MEM, FUNCTION_MODE, funexp),
340                             stack_size_rtx, next_arg_reg, n_pop);
341
342       emit_call_insn (pat);
343       already_popped = 1;
344     }
345   else
346 #endif
347 #endif
348
349 #if defined (HAVE_call) && defined (HAVE_call_value)
350   if (HAVE_call && HAVE_call_value)
351     {
352       if (valreg)
353         emit_call_insn (gen_call_value (valreg,
354                                         gen_rtx (MEM, FUNCTION_MODE, funexp),
355                                         stack_size_rtx, next_arg_reg,
356                                         NULL_RTX));
357       else
358         emit_call_insn (gen_call (gen_rtx (MEM, FUNCTION_MODE, funexp),
359                                   stack_size_rtx, next_arg_reg,
360                                   struct_value_size_rtx));
361     }
362   else
363 #endif
364     abort ();
365
366   /* Find the CALL insn we just emitted and write the USE insns before it.  */
367   for (call_insn = get_last_insn ();
368        call_insn && GET_CODE (call_insn) != CALL_INSN;
369        call_insn = PREV_INSN (call_insn))
370     ;
371
372   if (! call_insn)
373     abort ();
374
375   /* Put the USE insns before the CALL.  */
376   emit_insns_before (use_insns, call_insn);
377
378   /* If this is a const call, then set the insn's unchanging bit.  */
379   if (is_const)
380     CONST_CALL_P (call_insn) = 1;
381
382   /* Restore this now, so that we do defer pops for this call's args
383      if the context of the call as a whole permits.  */
384   inhibit_defer_pop = old_inhibit_defer_pop;
385
386 #ifndef ACCUMULATE_OUTGOING_ARGS
387   /* If returning from the subroutine does not automatically pop the args,
388      we need an instruction to pop them sooner or later.
389      Perhaps do it now; perhaps just record how much space to pop later.
390
391      If returning from the subroutine does pop the args, indicate that the
392      stack pointer will be changed.  */
393
394   if (stack_size != 0 && RETURN_POPS_ARGS (funtype, stack_size) > 0)
395     {
396       if (!already_popped)
397         emit_insn (gen_rtx (CLOBBER, VOIDmode, stack_pointer_rtx));
398       stack_size -= RETURN_POPS_ARGS (funtype, stack_size);
399       stack_size_rtx = GEN_INT (stack_size);
400     }
401
402   if (stack_size != 0)
403     {
404       if (flag_defer_pop && inhibit_defer_pop == 0 && !is_const)
405         pending_stack_adjust += stack_size;
406       else
407         adjust_stack (stack_size_rtx);
408     }
409 #endif
410 }
411
412 /* Generate all the code for a function call
413    and return an rtx for its value.
414    Store the value in TARGET (specified as an rtx) if convenient.
415    If the value is stored in TARGET then TARGET is returned.
416    If IGNORE is nonzero, then we ignore the value of the function call.  */
417
418 rtx
419 expand_call (exp, target, ignore)
420      tree exp;
421      rtx target;
422      int ignore;
423 {
424   /* List of actual parameters.  */
425   tree actparms = TREE_OPERAND (exp, 1);
426   /* RTX for the function to be called.  */
427   rtx funexp;
428   /* Tree node for the function to be called (not the address!).  */
429   tree funtree;
430   /* Data type of the function.  */
431   tree funtype;
432   /* Declaration of the function being called,
433      or 0 if the function is computed (not known by name).  */
434   tree fndecl = 0;
435   char *name = 0;
436
437   /* Register in which non-BLKmode value will be returned,
438      or 0 if no value or if value is BLKmode.  */
439   rtx valreg;
440   /* Address where we should return a BLKmode value;
441      0 if value not BLKmode.  */
442   rtx structure_value_addr = 0;
443   /* Nonzero if that address is being passed by treating it as
444      an extra, implicit first parameter.  Otherwise,
445      it is passed by being copied directly into struct_value_rtx.  */
446   int structure_value_addr_parm = 0;
447   /* Size of aggregate value wanted, or zero if none wanted
448      or if we are using the non-reentrant PCC calling convention
449      or expecting the value in registers.  */
450   int struct_value_size = 0;
451   /* Nonzero if called function returns an aggregate in memory PCC style,
452      by returning the address of where to find it.  */
453   int pcc_struct_value = 0;
454
455   /* Number of actual parameters in this call, including struct value addr.  */
456   int num_actuals;
457   /* Number of named args.  Args after this are anonymous ones
458      and they must all go on the stack.  */
459   int n_named_args;
460   /* Count arg position in order args appear.  */
461   int argpos;
462
463   /* Vector of information about each argument.
464      Arguments are numbered in the order they will be pushed,
465      not the order they are written.  */
466   struct arg_data *args;
467
468   /* Total size in bytes of all the stack-parms scanned so far.  */
469   struct args_size args_size;
470   /* Size of arguments before any adjustments (such as rounding).  */
471   struct args_size original_args_size;
472   /* Data on reg parms scanned so far.  */
473   CUMULATIVE_ARGS args_so_far;
474   /* Nonzero if a reg parm has been scanned.  */
475   int reg_parm_seen;
476
477   /* Nonzero if we must avoid push-insns in the args for this call. 
478      If stack space is allocated for register parameters, but not by the
479      caller, then it is preallocated in the fixed part of the stack frame.
480      So the entire argument block must then be preallocated (i.e., we
481      ignore PUSH_ROUNDING in that case).  */
482
483 #if defined(REG_PARM_STACK_SPACE) && ! defined(OUTGOING_REG_PARM_STACK_SPACE)
484   int must_preallocate = 1;
485 #else
486 #ifdef PUSH_ROUNDING
487   int must_preallocate = 0;
488 #else
489   int must_preallocate = 1;
490 #endif
491 #endif
492
493   /* Size of the stack reserved for parameter registers.  */
494   int reg_parm_stack_space = 0;
495
496   /* 1 if scanning parms front to back, -1 if scanning back to front.  */
497   int inc;
498   /* Address of space preallocated for stack parms
499      (on machines that lack push insns), or 0 if space not preallocated.  */
500   rtx argblock = 0;
501
502   /* Nonzero if it is plausible that this is a call to alloca.  */
503   int may_be_alloca;
504   /* Nonzero if this is a call to setjmp or a related function.  */
505   int returns_twice;
506   /* Nonzero if this is a call to `longjmp'.  */
507   int is_longjmp;
508   /* Nonzero if this is a call to an inline function.  */
509   int is_integrable = 0;
510   /* Nonzero if this is a call to a `const' function.
511      Note that only explicitly named functions are handled as `const' here.  */
512   int is_const = 0;
513   /* Nonzero if this is a call to a `volatile' function.  */
514   int is_volatile = 0;
515 #if defined(ACCUMULATE_OUTGOING_ARGS) && defined(REG_PARM_STACK_SPACE)
516   /* Define the boundary of the register parm stack space that needs to be
517      save, if any.  */
518   int low_to_save = -1, high_to_save;
519   rtx save_area = 0;            /* Place that it is saved */
520 #endif
521
522 #ifdef ACCUMULATE_OUTGOING_ARGS
523   int initial_highest_arg_in_use = highest_outgoing_arg_in_use;
524   char *initial_stack_usage_map = stack_usage_map;
525 #endif
526
527   rtx old_stack_level = 0;
528   int old_pending_adj;
529   int old_stack_arg_under_construction;
530   int old_inhibit_defer_pop = inhibit_defer_pop;
531   tree old_cleanups = cleanups_this_call;
532
533   rtx use_insns = 0;
534
535   register tree p;
536   register int i, j;
537
538   /* See if we can find a DECL-node for the actual function.
539      As a result, decide whether this is a call to an integrable function.  */
540
541   p = TREE_OPERAND (exp, 0);
542   if (TREE_CODE (p) == ADDR_EXPR)
543     {
544       fndecl = TREE_OPERAND (p, 0);
545       if (TREE_CODE (fndecl) != FUNCTION_DECL)
546         {
547           /* May still be a `const' function if it is
548              a call through a pointer-to-const.
549              But we don't handle that.  */
550           fndecl = 0;
551         }
552       else
553         {
554           if (!flag_no_inline
555               && fndecl != current_function_decl
556               && DECL_SAVED_INSNS (fndecl))
557             is_integrable = 1;
558           else if (! TREE_ADDRESSABLE (fndecl))
559             {
560               /* In case this function later becomes inlinable,
561                  record that there was already a non-inline call to it.
562
563                  Use abstraction instead of setting TREE_ADDRESSABLE
564                  directly.  */
565               if (DECL_INLINE (fndecl) && extra_warnings && !flag_no_inline)
566                 warning_with_decl (fndecl, "can't inline call to `%s' which was declared inline");
567               mark_addressable (fndecl);
568             }
569
570           if (TREE_READONLY (fndecl) && ! TREE_THIS_VOLATILE (fndecl)
571               && TYPE_MODE (TREE_TYPE (exp)) != VOIDmode)
572             is_const = 1;
573         }
574     }
575
576   is_volatile = TYPE_VOLATILE (TREE_TYPE (TREE_TYPE (p)));
577
578 #ifdef REG_PARM_STACK_SPACE
579 #ifdef MAYBE_REG_PARM_STACK_SPACE
580   reg_parm_stack_space = MAYBE_REG_PARM_STACK_SPACE;
581 #else
582   reg_parm_stack_space = REG_PARM_STACK_SPACE (fndecl);
583 #endif
584 #endif
585
586   /* Warn if this value is an aggregate type,
587      regardless of which calling convention we are using for it.  */
588   if (warn_aggregate_return
589       && (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE
590           || TREE_CODE (TREE_TYPE (exp)) == UNION_TYPE
591           || TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE))
592     warning ("function call has aggregate value");
593
594   /* Set up a place to return a structure.  */
595
596   /* Cater to broken compilers.  */
597   if (aggregate_value_p (exp))
598     {
599       /* This call returns a big structure.  */
600       is_const = 0;
601
602 #ifdef PCC_STATIC_STRUCT_RETURN
603       if (flag_pcc_struct_return)
604         {
605           pcc_struct_value = 1;
606           is_integrable = 0;  /* Easier than making that case work right.  */
607         }
608       else
609 #endif
610         {
611           struct_value_size = int_size_in_bytes (TREE_TYPE (exp));
612
613           if (struct_value_size < 0)
614             abort ();
615
616           if (target && GET_CODE (target) == MEM)
617             structure_value_addr = XEXP (target, 0);
618           else
619             {
620               /* Assign a temporary on the stack to hold the value.  */
621
622               /* For variable-sized objects, we must be called with a target
623                  specified.  If we were to allocate space on the stack here,
624                  we would have no way of knowing when to free it.  */
625
626               structure_value_addr
627                 = XEXP (assign_stack_temp (BLKmode, struct_value_size, 1), 0);
628               target = 0;
629             }
630         }
631     }
632
633   /* If called function is inline, try to integrate it.  */
634
635   if (is_integrable)
636     {
637       rtx temp;
638       rtx before_call = get_last_insn ();
639
640       temp = expand_inline_function (fndecl, actparms, target,
641                                      ignore, TREE_TYPE (exp),
642                                      structure_value_addr);
643
644       /* If inlining succeeded, return.  */
645       if ((HOST_WIDE_INT) temp != -1)
646         {
647           /* Perform all cleanups needed for the arguments of this call
648              (i.e. destructors in C++).  It is ok if these destructors
649              clobber RETURN_VALUE_REG, because the only time we care about
650              this is when TARGET is that register.  But in C++, we take
651              care to never return that register directly.  */
652           expand_cleanups_to (old_cleanups);
653
654 #ifdef ACCUMULATE_OUTGOING_ARGS
655           /* If the outgoing argument list must be preserved, push
656              the stack before executing the inlined function if it
657              makes any calls.  */
658
659           for (i = reg_parm_stack_space - 1; i >= 0; i--)
660             if (i < highest_outgoing_arg_in_use && stack_usage_map[i] != 0)
661               break;
662
663           if (stack_arg_under_construction || i >= 0)
664             {
665               rtx insn = NEXT_INSN (before_call), seq;
666
667               /* Look for a call in the inline function code.
668                  If OUTGOING_ARGS_SIZE (DECL_SAVED_INSNS (fndecl)) is
669                  nonzero then there is a call and it is not necessary
670                  to scan the insns.  */
671
672               if (OUTGOING_ARGS_SIZE (DECL_SAVED_INSNS (fndecl)) == 0)
673                 for (; insn; insn = NEXT_INSN (insn))
674                   if (GET_CODE (insn) == CALL_INSN)
675                     break;
676
677               if (insn)
678                 {
679                   /* Reserve enough stack space so that the largest
680                      argument list of any function call in the inline
681                      function does not overlap the argument list being
682                      evaluated.  This is usually an overestimate because
683                      allocate_dynamic_stack_space reserves space for an
684                      outgoing argument list in addition to the requested
685                      space, but there is no way to ask for stack space such
686                      that an argument list of a certain length can be
687                      safely constructed.  */
688
689                   int adjust = OUTGOING_ARGS_SIZE (DECL_SAVED_INSNS (fndecl));
690 #ifdef REG_PARM_STACK_SPACE
691                   /* Add the stack space reserved for register arguments
692                      in the inline function.  What is really needed is the
693                      largest value of reg_parm_stack_space in the inline
694                      function, but that is not available.  Using the current
695                      value of reg_parm_stack_space is wrong, but gives
696                      correct results on all supported machines.  */
697                   adjust += reg_parm_stack_space;
698 #endif
699                   start_sequence ();
700                   emit_stack_save (SAVE_BLOCK, &old_stack_level, 0);
701                   allocate_dynamic_stack_space (GEN_INT (adjust),
702                                                 NULL_RTX, BITS_PER_UNIT);
703                   seq = get_insns ();
704                   end_sequence ();
705                   emit_insns_before (seq, NEXT_INSN (before_call));
706                   emit_stack_restore (SAVE_BLOCK, old_stack_level, NULL_RTX);
707                 }
708             }
709 #endif
710
711           /* If the result is equivalent to TARGET, return TARGET to simplify
712              checks in store_expr.  They can be equivalent but not equal in the
713              case of a function that returns BLKmode.  */
714           if (temp != target && rtx_equal_p (temp, target))
715             return target;
716           return temp;
717         }
718
719       /* If inlining failed, mark FNDECL as needing to be compiled
720          separately after all.  */
721       mark_addressable (fndecl);
722     }
723
724   /* When calling a const function, we must pop the stack args right away,
725      so that the pop is deleted or moved with the call.  */
726   if (is_const)
727     NO_DEFER_POP;
728
729   function_call_count++;
730
731   if (fndecl && DECL_NAME (fndecl))
732     name = IDENTIFIER_POINTER (DECL_NAME (fndecl));
733
734 #if 0
735   /* Unless it's a call to a specific function that isn't alloca,
736      if it has one argument, we must assume it might be alloca.  */
737
738   may_be_alloca =
739     (!(fndecl != 0 && strcmp (name, "alloca"))
740      && actparms != 0
741      && TREE_CHAIN (actparms) == 0);
742 #else
743   /* We assume that alloca will always be called by name.  It
744      makes no sense to pass it as a pointer-to-function to
745      anything that does not understand its behavior.  */
746   may_be_alloca =
747     (name && ((IDENTIFIER_LENGTH (DECL_NAME (fndecl)) == 6
748                  && name[0] == 'a'
749                  && ! strcmp (name, "alloca"))
750                 || (IDENTIFIER_LENGTH (DECL_NAME (fndecl)) == 16
751                     && name[0] == '_'
752                     && ! strcmp (name, "__builtin_alloca"))));
753 #endif
754
755   /* See if this is a call to a function that can return more than once
756      or a call to longjmp.  */
757
758   returns_twice = 0;
759   is_longjmp = 0;
760
761   if (name != 0 && IDENTIFIER_LENGTH (DECL_NAME (fndecl)) <= 15)
762     {
763       char *tname = name;
764
765       if (name[0] == '_')
766         tname += ((name[1] == '_' && name[2] == 'x') ? 3 : 1);
767
768       if (tname[0] == 's')
769         {
770           returns_twice
771             = ((tname[1] == 'e'
772                 && (! strcmp (tname, "setjmp")
773                     || ! strcmp (tname, "setjmp_syscall")))
774                || (tname[1] == 'i'
775                    && ! strcmp (tname, "sigsetjmp"))
776                || (tname[1] == 'a'
777                    && ! strcmp (tname, "savectx")));
778           if (tname[1] == 'i'
779               && ! strcmp (tname, "siglongjmp"))
780             is_longjmp = 1;
781         }
782       else if ((tname[0] == 'q' && tname[1] == 's'
783                 && ! strcmp (tname, "qsetjmp"))
784                || (tname[0] == 'v' && tname[1] == 'f'
785                    && ! strcmp (tname, "vfork")))
786         returns_twice = 1;
787
788       else if (tname[0] == 'l' && tname[1] == 'o'
789                && ! strcmp (tname, "longjmp"))
790         is_longjmp = 1;
791     }
792
793   if (may_be_alloca)
794     current_function_calls_alloca = 1;
795
796   /* Don't let pending stack adjusts add up to too much.
797      Also, do all pending adjustments now
798      if there is any chance this might be a call to alloca.  */
799
800   if (pending_stack_adjust >= 32
801       || (pending_stack_adjust > 0 && may_be_alloca))
802     do_pending_stack_adjust ();
803
804   /* Operand 0 is a pointer-to-function; get the type of the function.  */
805   funtype = TREE_TYPE (TREE_OPERAND (exp, 0));
806   if (TREE_CODE (funtype) != POINTER_TYPE)
807     abort ();
808   funtype = TREE_TYPE (funtype);
809
810   /* Push the temporary stack slot level so that we can free temporaries used
811      by each of the arguments separately.  */
812   push_temp_slots ();
813
814   /* Start updating where the next arg would go.  */
815   INIT_CUMULATIVE_ARGS (args_so_far, funtype, NULL_RTX);
816
817   /* If struct_value_rtx is 0, it means pass the address
818      as if it were an extra parameter.  */
819   if (structure_value_addr && struct_value_rtx == 0)
820     {
821 #ifdef ACCUMULATE_OUTGOING_ARGS
822       /* If the stack will be adjusted, make sure the structure address
823          does not refer to virtual_outgoing_args_rtx.  */
824       rtx temp = (stack_arg_under_construction
825                   ? copy_addr_to_reg (structure_value_addr)
826                   : force_reg (Pmode, structure_value_addr));
827 #else
828       rtx temp = force_reg (Pmode, structure_value_addr);
829 #endif
830
831       actparms
832         = tree_cons (error_mark_node,
833                      make_tree (build_pointer_type (TREE_TYPE (funtype)),
834                                 temp),
835                      actparms);
836       structure_value_addr_parm = 1;
837     }
838
839   /* Count the arguments and set NUM_ACTUALS.  */
840   for (p = actparms, i = 0; p; p = TREE_CHAIN (p)) i++;
841   num_actuals = i;
842
843   /* Compute number of named args.
844      Normally, don't include the last named arg if anonymous args follow.
845      (If no anonymous args follow, the result of list_length
846      is actually one too large.)
847
848      If SETUP_INCOMING_VARARGS is defined, this machine will be able to
849      place unnamed args that were passed in registers into the stack.  So
850      treat all args as named.  This allows the insns emitting for a specific
851      argument list to be independent of the function declaration.
852
853      If SETUP_INCOMING_VARARGS is not defined, we do not have any reliable
854      way to pass unnamed args in registers, so we must force them into
855      memory.  */
856 #ifndef SETUP_INCOMING_VARARGS
857   if (TYPE_ARG_TYPES (funtype) != 0)
858     n_named_args
859       = list_length (TYPE_ARG_TYPES (funtype)) - 1
860         /* Count the struct value address, if it is passed as a parm.  */
861         + structure_value_addr_parm;
862   else
863 #endif
864     /* If we know nothing, treat all args as named.  */
865     n_named_args = num_actuals;
866
867   /* Make a vector to hold all the information about each arg.  */
868   args = (struct arg_data *) alloca (num_actuals * sizeof (struct arg_data));
869   bzero (args, num_actuals * sizeof (struct arg_data));
870
871   args_size.constant = 0;
872   args_size.var = 0;
873
874   /* In this loop, we consider args in the order they are written.
875      We fill up ARGS from the front of from the back if necessary
876      so that in any case the first arg to be pushed ends up at the front.  */
877
878 #ifdef PUSH_ARGS_REVERSED
879   i = num_actuals - 1, inc = -1;
880   /* In this case, must reverse order of args
881      so that we compute and push the last arg first.  */
882 #else
883   i = 0, inc = 1;
884 #endif
885
886   /* I counts args in order (to be) pushed; ARGPOS counts in order written.  */
887   for (p = actparms, argpos = 0; p; p = TREE_CHAIN (p), i += inc, argpos++)
888     {
889       tree type = TREE_TYPE (TREE_VALUE (p));
890       enum machine_mode mode;
891
892       args[i].tree_value = TREE_VALUE (p);
893
894       /* Replace erroneous argument with constant zero.  */
895       if (type == error_mark_node || TYPE_SIZE (type) == 0)
896         args[i].tree_value = integer_zero_node, type = integer_type_node;
897
898       /* Decide where to pass this arg.
899
900          args[i].reg is nonzero if all or part is passed in registers.
901
902          args[i].partial is nonzero if part but not all is passed in registers,
903          and the exact value says how many words are passed in registers.
904
905          args[i].pass_on_stack is nonzero if the argument must at least be
906          computed on the stack.  It may then be loaded back into registers
907          if args[i].reg is nonzero.
908
909          These decisions are driven by the FUNCTION_... macros and must agree
910          with those made by function.c.  */
911
912 #ifdef FUNCTION_ARG_PASS_BY_REFERENCE
913       /* See if this argument should be passed by invisible reference.  */
914       if (FUNCTION_ARG_PASS_BY_REFERENCE (args_so_far, TYPE_MODE (type), type,
915                                           argpos < n_named_args))
916         {
917           /* We make a copy of the object and pass the address to the function
918              being called.  */
919           rtx copy;
920
921           if (TYPE_SIZE (type) == 0
922               || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
923             {
924               /* This is a variable-sized object.  Make space on the stack
925                  for it.  */
926               rtx size_rtx = expr_size (TREE_VALUE (p));
927
928               if (old_stack_level == 0)
929                 {
930                   emit_stack_save (SAVE_BLOCK, &old_stack_level, NULL_RTX);
931                   old_pending_adj = pending_stack_adjust;
932                   pending_stack_adjust = 0;
933                 }
934
935               copy = gen_rtx (MEM, BLKmode,
936                               allocate_dynamic_stack_space (size_rtx, NULL_RTX,
937                                                             TYPE_ALIGN (type)));
938             }
939           else
940             {
941               int size = int_size_in_bytes (type);
942               copy = assign_stack_temp (TYPE_MODE (type), size, 1);
943             }
944
945           store_expr (args[i].tree_value, copy, 0);
946
947           args[i].tree_value = build1 (ADDR_EXPR, build_pointer_type (type),
948                                        make_tree (type, copy));
949           type = build_pointer_type (type);
950         }
951 #endif
952
953       mode = TYPE_MODE (type);
954
955 #ifdef PROMOTE_FUNCTION_ARGS
956       /* Compute the mode in which the arg is actually to be extended to.  */
957       if (TREE_CODE (type) == INTEGER_TYPE || TREE_CODE (type) == ENUMERAL_TYPE
958           || TREE_CODE (type) == BOOLEAN_TYPE || TREE_CODE (type) == CHAR_TYPE
959           || TREE_CODE (type) == REAL_TYPE || TREE_CODE (type) == POINTER_TYPE
960           || TREE_CODE (type) == OFFSET_TYPE)
961         {
962           int unsignedp = TREE_UNSIGNED (type);
963           PROMOTE_MODE (mode, unsignedp, type);
964           args[i].unsignedp = unsignedp;
965         }
966 #endif
967
968       args[i].mode = mode;
969       args[i].reg = FUNCTION_ARG (args_so_far, mode, type,
970                                   argpos < n_named_args);
971 #ifdef FUNCTION_ARG_PARTIAL_NREGS
972       if (args[i].reg)
973         args[i].partial
974           = FUNCTION_ARG_PARTIAL_NREGS (args_so_far, mode, type,
975                                         argpos < n_named_args);
976 #endif
977
978       args[i].pass_on_stack = MUST_PASS_IN_STACK (mode, type);
979
980       /* If FUNCTION_ARG returned an (expr_list (nil) FOO), it means that
981          we are to pass this arg in the register(s) designated by FOO, but
982          also to pass it in the stack.  */
983       if (args[i].reg && GET_CODE (args[i].reg) == EXPR_LIST
984           && XEXP (args[i].reg, 0) == 0)
985         args[i].pass_on_stack = 1, args[i].reg = XEXP (args[i].reg, 1);
986
987       /* If this is an addressable type, we must preallocate the stack
988          since we must evaluate the object into its final location.
989
990          If this is to be passed in both registers and the stack, it is simpler
991          to preallocate.  */
992       if (TREE_ADDRESSABLE (type)
993           || (args[i].pass_on_stack && args[i].reg != 0))
994         must_preallocate = 1;
995
996       /* If this is an addressable type, we cannot pre-evaluate it.  Thus,
997          we cannot consider this function call constant.  */
998       if (TREE_ADDRESSABLE (type))
999         is_const = 0;
1000
1001       /* Compute the stack-size of this argument.  */
1002       if (args[i].reg == 0 || args[i].partial != 0
1003 #ifdef REG_PARM_STACK_SPACE
1004           || reg_parm_stack_space > 0
1005 #endif
1006           || args[i].pass_on_stack)
1007         locate_and_pad_parm (mode, type,
1008 #ifdef STACK_PARMS_IN_REG_PARM_AREA
1009                              1,
1010 #else
1011                              args[i].reg != 0,
1012 #endif
1013                              fndecl, &args_size, &args[i].offset,
1014                              &args[i].size);
1015
1016 #ifndef ARGS_GROW_DOWNWARD
1017       args[i].slot_offset = args_size;
1018 #endif
1019
1020 #ifndef REG_PARM_STACK_SPACE
1021       /* If a part of the arg was put into registers,
1022          don't include that part in the amount pushed.  */
1023       if (! args[i].pass_on_stack)
1024         args[i].size.constant -= ((args[i].partial * UNITS_PER_WORD)
1025                                   / (PARM_BOUNDARY / BITS_PER_UNIT)
1026                                   * (PARM_BOUNDARY / BITS_PER_UNIT));
1027 #endif
1028       
1029       /* Update ARGS_SIZE, the total stack space for args so far.  */
1030
1031       args_size.constant += args[i].size.constant;
1032       if (args[i].size.var)
1033         {
1034           ADD_PARM_SIZE (args_size, args[i].size.var);
1035         }
1036
1037       /* Since the slot offset points to the bottom of the slot,
1038          we must record it after incrementing if the args grow down.  */
1039 #ifdef ARGS_GROW_DOWNWARD
1040       args[i].slot_offset = args_size;
1041
1042       args[i].slot_offset.constant = -args_size.constant;
1043       if (args_size.var)
1044         {
1045           SUB_PARM_SIZE (args[i].slot_offset, args_size.var);
1046         }
1047 #endif
1048
1049       /* Increment ARGS_SO_FAR, which has info about which arg-registers
1050          have been used, etc.  */
1051
1052       FUNCTION_ARG_ADVANCE (args_so_far, TYPE_MODE (type), type,
1053                             argpos < n_named_args);
1054     }
1055
1056 #ifdef FINAL_REG_PARM_STACK_SPACE
1057   reg_parm_stack_space = FINAL_REG_PARM_STACK_SPACE (args_size.constant,
1058                                                      args_size.var);
1059 #endif
1060       
1061   /* Compute the actual size of the argument block required.  The variable
1062      and constant sizes must be combined, the size may have to be rounded,
1063      and there may be a minimum required size.  */
1064
1065   original_args_size = args_size;
1066   if (args_size.var)
1067     {
1068       /* If this function requires a variable-sized argument list, don't try to
1069          make a cse'able block for this call.  We may be able to do this
1070          eventually, but it is too complicated to keep track of what insns go
1071          in the cse'able block and which don't.  */
1072
1073       is_const = 0;
1074       must_preallocate = 1;
1075
1076       args_size.var = ARGS_SIZE_TREE (args_size);
1077       args_size.constant = 0;
1078
1079 #ifdef STACK_BOUNDARY
1080       if (STACK_BOUNDARY != BITS_PER_UNIT)
1081         args_size.var = round_up (args_size.var, STACK_BYTES);
1082 #endif
1083
1084 #ifdef REG_PARM_STACK_SPACE
1085       if (reg_parm_stack_space > 0)
1086         {
1087           args_size.var
1088             = size_binop (MAX_EXPR, args_size.var,
1089                           size_int (REG_PARM_STACK_SPACE (fndecl)));
1090
1091 #ifndef OUTGOING_REG_PARM_STACK_SPACE
1092           /* The area corresponding to register parameters is not to count in
1093              the size of the block we need.  So make the adjustment.  */
1094           args_size.var
1095             = size_binop (MINUS_EXPR, args_size.var,
1096                           size_int (reg_parm_stack_space));
1097 #endif
1098         }
1099 #endif
1100     }
1101   else
1102     {
1103 #ifdef STACK_BOUNDARY
1104       args_size.constant = (((args_size.constant + (STACK_BYTES - 1))
1105                              / STACK_BYTES) * STACK_BYTES);
1106 #endif
1107
1108 #ifdef REG_PARM_STACK_SPACE
1109       args_size.constant = MAX (args_size.constant,
1110                                 reg_parm_stack_space);
1111 #ifdef MAYBE_REG_PARM_STACK_SPACE
1112       if (reg_parm_stack_space == 0)
1113         args_size.constant = 0;
1114 #endif
1115 #ifndef OUTGOING_REG_PARM_STACK_SPACE
1116       args_size.constant -= reg_parm_stack_space;
1117 #endif
1118 #endif
1119     }
1120
1121   /* See if we have or want to preallocate stack space.
1122
1123      If we would have to push a partially-in-regs parm
1124      before other stack parms, preallocate stack space instead.
1125
1126      If the size of some parm is not a multiple of the required stack
1127      alignment, we must preallocate.
1128
1129      If the total size of arguments that would otherwise create a copy in
1130      a temporary (such as a CALL) is more than half the total argument list
1131      size, preallocation is faster.
1132
1133      Another reason to preallocate is if we have a machine (like the m88k)
1134      where stack alignment is required to be maintained between every
1135      pair of insns, not just when the call is made.  However, we assume here
1136      that such machines either do not have push insns (and hence preallocation
1137      would occur anyway) or the problem is taken care of with
1138      PUSH_ROUNDING.  */
1139
1140   if (! must_preallocate)
1141     {
1142       int partial_seen = 0;
1143       int copy_to_evaluate_size = 0;
1144
1145       for (i = 0; i < num_actuals && ! must_preallocate; i++)
1146         {
1147           if (args[i].partial > 0 && ! args[i].pass_on_stack)
1148             partial_seen = 1;
1149           else if (partial_seen && args[i].reg == 0)
1150             must_preallocate = 1;
1151
1152           if (TYPE_MODE (TREE_TYPE (args[i].tree_value)) == BLKmode
1153               && (TREE_CODE (args[i].tree_value) == CALL_EXPR
1154                   || TREE_CODE (args[i].tree_value) == TARGET_EXPR
1155                   || TREE_CODE (args[i].tree_value) == COND_EXPR
1156                   || TREE_ADDRESSABLE (TREE_TYPE (args[i].tree_value))))
1157             copy_to_evaluate_size
1158               += int_size_in_bytes (TREE_TYPE (args[i].tree_value));
1159         }
1160
1161       if (copy_to_evaluate_size * 2 >= args_size.constant
1162           && args_size.constant > 0)
1163         must_preallocate = 1;
1164     }
1165
1166   /* If the structure value address will reference the stack pointer, we must
1167      stabilize it.  We don't need to do this if we know that we are not going
1168      to adjust the stack pointer in processing this call.  */
1169
1170   if (structure_value_addr
1171       && (reg_mentioned_p (virtual_stack_dynamic_rtx, structure_value_addr)
1172        || reg_mentioned_p (virtual_outgoing_args_rtx, structure_value_addr))
1173       && (args_size.var
1174 #ifndef ACCUMULATE_OUTGOING_ARGS
1175           || args_size.constant
1176 #endif
1177           ))
1178     structure_value_addr = copy_to_reg (structure_value_addr);
1179
1180   /* If this function call is cse'able, precompute all the parameters.
1181      Note that if the parameter is constructed into a temporary, this will
1182      cause an additional copy because the parameter will be constructed
1183      into a temporary location and then copied into the outgoing arguments.
1184      If a parameter contains a call to alloca and this function uses the
1185      stack, precompute the parameter.  */
1186
1187   /* If we preallocated the stack space, and some arguments must be passed
1188      on the stack, then we must precompute any parameter which contains a
1189      function call which will store arguments on the stack.
1190      Otherwise, evaluating the parameter may clobber previous parameters
1191      which have already been stored into the stack.  */
1192
1193   for (i = 0; i < num_actuals; i++)
1194     if (is_const
1195         || ((args_size.var != 0 || args_size.constant != 0)
1196             && calls_function (args[i].tree_value, 1))
1197         || (must_preallocate && (args_size.var != 0 || args_size.constant != 0)
1198             && calls_function (args[i].tree_value, 0)))
1199       {
1200         args[i].initial_value = args[i].value
1201           = expand_expr (args[i].tree_value, NULL_RTX, VOIDmode, 0);
1202
1203         if (GET_MODE (args[i].value ) != VOIDmode
1204             && GET_MODE (args[i].value) != args[i].mode)
1205           args[i].value = convert_to_mode (args[i].mode, args[i].value,
1206                                            args[i].unsignedp);
1207         preserve_temp_slots (args[i].value);
1208
1209         free_temp_slots ();
1210
1211         /* ANSI doesn't require a sequence point here,
1212            but PCC has one, so this will avoid some problems.  */
1213         emit_queue ();
1214       }
1215
1216   /* Now we are about to start emitting insns that can be deleted
1217      if a libcall is deleted.  */
1218   if (is_const)
1219     start_sequence ();
1220
1221   /* If we have no actual push instructions, or shouldn't use them,
1222      make space for all args right now.  */
1223
1224   if (args_size.var != 0)
1225     {
1226       if (old_stack_level == 0)
1227         {
1228           emit_stack_save (SAVE_BLOCK, &old_stack_level, NULL_RTX);
1229           old_pending_adj = pending_stack_adjust;
1230           pending_stack_adjust = 0;
1231 #ifdef ACCUMULATE_OUTGOING_ARGS
1232           /* stack_arg_under_construction says whether a stack arg is
1233              being constructed at the old stack level.  Pushing the stack
1234              gets a clean outgoing argument block.  */
1235           old_stack_arg_under_construction = stack_arg_under_construction;
1236           stack_arg_under_construction = 0;
1237 #endif
1238         }
1239       argblock = push_block (ARGS_SIZE_RTX (args_size), 0, 0);
1240     }
1241   else if (must_preallocate)
1242     {
1243       /* Note that we must go through the motions of allocating an argument
1244          block even if the size is zero because we may be storing args
1245          in the area reserved for register arguments, which may be part of
1246          the stack frame.  */
1247       int needed = args_size.constant;
1248
1249 #ifdef ACCUMULATE_OUTGOING_ARGS
1250       /* Store the maximum argument space used.  It will be pushed by the
1251          prologue.
1252
1253          Since the stack pointer will never be pushed, it is possible for
1254          the evaluation of a parm to clobber something we have already
1255          written to the stack.  Since most function calls on RISC machines
1256          do not use the stack, this is uncommon, but must work correctly.
1257          
1258          Therefore, we save any area of the stack that was already written
1259          and that we are using.  Here we set up to do this by making a new
1260          stack usage map from the old one.  The actual save will be done
1261          by store_one_arg. 
1262
1263          Another approach might be to try to reorder the argument
1264          evaluations to avoid this conflicting stack usage.  */
1265
1266       if (needed > current_function_outgoing_args_size)
1267         current_function_outgoing_args_size = needed;
1268
1269 #if defined(REG_PARM_STACK_SPACE) && ! defined(OUTGOING_REG_PARM_STACK_SPACE)
1270       /* Since we will be writing into the entire argument area, the
1271          map must be allocated for its entire size, not just the part that
1272          is the responsibility of the caller.  */
1273       needed += reg_parm_stack_space;
1274 #endif
1275
1276 #ifdef ARGS_GROW_DOWNWARD
1277       highest_outgoing_arg_in_use = MAX (initial_highest_arg_in_use,
1278                                          needed + 1);
1279 #else
1280       highest_outgoing_arg_in_use = MAX (initial_highest_arg_in_use, needed);
1281 #endif
1282       stack_usage_map = (char *) alloca (highest_outgoing_arg_in_use);
1283
1284       if (initial_highest_arg_in_use)
1285         bcopy (initial_stack_usage_map, stack_usage_map,
1286                initial_highest_arg_in_use);
1287
1288       if (initial_highest_arg_in_use != highest_outgoing_arg_in_use)
1289         bzero (&stack_usage_map[initial_highest_arg_in_use],
1290                highest_outgoing_arg_in_use - initial_highest_arg_in_use);
1291       needed = 0;
1292
1293       /* The address of the outgoing argument list must not be copied to a
1294          register here, because argblock would be left pointing to the
1295          wrong place after the call to allocate_dynamic_stack_space below. */
1296
1297       argblock = virtual_outgoing_args_rtx;
1298
1299 #else /* not ACCUMULATE_OUTGOING_ARGS */
1300       if (inhibit_defer_pop == 0)
1301         {
1302           /* Try to reuse some or all of the pending_stack_adjust
1303              to get this space.  Maybe we can avoid any pushing.  */
1304           if (needed > pending_stack_adjust)
1305             {
1306               needed -= pending_stack_adjust;
1307               pending_stack_adjust = 0;
1308             }
1309           else
1310             {
1311               pending_stack_adjust -= needed;
1312               needed = 0;
1313             }
1314         }
1315       /* Special case this because overhead of `push_block' in this
1316          case is non-trivial.  */
1317       if (needed == 0)
1318         argblock = virtual_outgoing_args_rtx;
1319       else
1320         argblock = push_block (GEN_INT (needed), 0, 0);
1321
1322       /* We only really need to call `copy_to_reg' in the case where push
1323          insns are going to be used to pass ARGBLOCK to a function
1324          call in ARGS.  In that case, the stack pointer changes value
1325          from the allocation point to the call point, and hence
1326          the value of VIRTUAL_OUTGOING_ARGS_RTX changes as well.
1327          But might as well always do it.  */
1328       argblock = copy_to_reg (argblock);
1329 #endif /* not ACCUMULATE_OUTGOING_ARGS */
1330     }
1331
1332
1333 #ifdef ACCUMULATE_OUTGOING_ARGS
1334   /* The save/restore code in store_one_arg handles all cases except one:
1335      a constructor call (including a C function returning a BLKmode struct)
1336      to initialize an argument.  */
1337   if (stack_arg_under_construction)
1338     {
1339 #if defined(REG_PARM_STACK_SPACE) && ! defined(OUTGOING_REG_PARM_STACK_SPACE)
1340       rtx push_size = GEN_INT (reg_parm_stack_space + args_size.constant);
1341 #else
1342       rtx push_size = GEN_INT (args_size.constant);
1343 #endif
1344       if (old_stack_level == 0)
1345         {
1346           emit_stack_save (SAVE_BLOCK, &old_stack_level, NULL_RTX);
1347           old_pending_adj = pending_stack_adjust;
1348           pending_stack_adjust = 0;
1349           /* stack_arg_under_construction says whether a stack arg is
1350              being constructed at the old stack level.  Pushing the stack
1351              gets a clean outgoing argument block.  */
1352           old_stack_arg_under_construction = stack_arg_under_construction;
1353           stack_arg_under_construction = 0;
1354           /* Make a new map for the new argument list.  */
1355           stack_usage_map = (char *)alloca (highest_outgoing_arg_in_use);
1356           bzero (stack_usage_map, highest_outgoing_arg_in_use);
1357           highest_outgoing_arg_in_use = 0;
1358         }
1359       allocate_dynamic_stack_space (push_size, NULL_RTX, BITS_PER_UNIT);
1360     }
1361   /* If argument evaluation might modify the stack pointer, copy the
1362      address of the argument list to a register.  */
1363   for (i = 0; i < num_actuals; i++)
1364     if (args[i].pass_on_stack)
1365       {
1366         argblock = copy_addr_to_reg (argblock);
1367         break;
1368       }
1369 #endif
1370
1371
1372   /* If we preallocated stack space, compute the address of each argument.
1373      We need not ensure it is a valid memory address here; it will be 
1374      validized when it is used.  */
1375   if (argblock)
1376     {
1377       rtx arg_reg = argblock;
1378       int arg_offset = 0;
1379
1380       if (GET_CODE (argblock) == PLUS)
1381         arg_reg = XEXP (argblock, 0), arg_offset = INTVAL (XEXP (argblock, 1));
1382
1383       for (i = 0; i < num_actuals; i++)
1384         {
1385           rtx offset = ARGS_SIZE_RTX (args[i].offset);
1386           rtx slot_offset = ARGS_SIZE_RTX (args[i].slot_offset);
1387           rtx addr;
1388
1389           /* Skip this parm if it will not be passed on the stack.  */
1390           if (! args[i].pass_on_stack && args[i].reg != 0)
1391             continue;
1392
1393           if (GET_CODE (offset) == CONST_INT)
1394             addr = plus_constant (arg_reg, INTVAL (offset));
1395           else
1396             addr = gen_rtx (PLUS, Pmode, arg_reg, offset);
1397
1398           addr = plus_constant (addr, arg_offset);
1399           args[i].stack = gen_rtx (MEM, args[i].mode, addr);
1400
1401           if (GET_CODE (slot_offset) == CONST_INT)
1402             addr = plus_constant (arg_reg, INTVAL (slot_offset));
1403           else
1404             addr = gen_rtx (PLUS, Pmode, arg_reg, slot_offset);
1405
1406           addr = plus_constant (addr, arg_offset);
1407           args[i].stack_slot = gen_rtx (MEM, args[i].mode, addr);
1408         }
1409     }
1410                                                
1411 #ifdef PUSH_ARGS_REVERSED
1412 #ifdef STACK_BOUNDARY
1413   /* If we push args individually in reverse order, perform stack alignment
1414      before the first push (the last arg).  */
1415   if (argblock == 0)
1416     anti_adjust_stack (GEN_INT (args_size.constant
1417                                 - original_args_size.constant));
1418 #endif
1419 #endif
1420
1421   /* Don't try to defer pops if preallocating, not even from the first arg,
1422      since ARGBLOCK probably refers to the SP.  */
1423   if (argblock)
1424     NO_DEFER_POP;
1425
1426   /* Get the function to call, in the form of RTL.  */
1427   if (fndecl)
1428     /* Get a SYMBOL_REF rtx for the function address.  */
1429     funexp = XEXP (DECL_RTL (fndecl), 0);
1430   else
1431     /* Generate an rtx (probably a pseudo-register) for the address.  */
1432     {
1433       funexp = expand_expr (TREE_OPERAND (exp, 0), NULL_RTX, VOIDmode, 0);
1434       free_temp_slots ();       /* FUNEXP can't be BLKmode */
1435       emit_queue ();
1436     }
1437
1438   /* Figure out the register where the value, if any, will come back.  */
1439   valreg = 0;
1440   if (TYPE_MODE (TREE_TYPE (exp)) != VOIDmode
1441       && ! structure_value_addr)
1442     {
1443       if (pcc_struct_value)
1444         valreg = hard_function_value (build_pointer_type (TREE_TYPE (exp)),
1445                                       fndecl);
1446       else
1447         valreg = hard_function_value (TREE_TYPE (exp), fndecl);
1448     }
1449
1450   /* Precompute all register parameters.  It isn't safe to compute anything
1451      once we have started filling any specific hard regs. */
1452   reg_parm_seen = 0;
1453   for (i = 0; i < num_actuals; i++)
1454     if (args[i].reg != 0 && ! args[i].pass_on_stack)
1455       {
1456         reg_parm_seen = 1;
1457
1458         if (args[i].value == 0)
1459           {
1460             args[i].value = expand_expr (args[i].tree_value, NULL_RTX,
1461                                          VOIDmode, 0);
1462             preserve_temp_slots (args[i].value);
1463             free_temp_slots ();
1464
1465             /* ANSI doesn't require a sequence point here,
1466                but PCC has one, so this will avoid some problems.  */
1467             emit_queue ();
1468           }
1469
1470         /* If we are to promote the function arg to a wider mode,
1471            do it now.  */
1472
1473         if (GET_MODE (args[i].value) != VOIDmode
1474             && GET_MODE (args[i].value) != args[i].mode)
1475           args[i].value = convert_to_mode (args[i].mode, args[i].value,
1476                                            args[i].unsignedp);
1477       }
1478
1479 #if defined(ACCUMULATE_OUTGOING_ARGS) && defined(REG_PARM_STACK_SPACE)
1480   /* The argument list is the property of the called routine and it
1481      may clobber it.  If the fixed area has been used for previous
1482      parameters, we must save and restore it.
1483
1484      Here we compute the boundary of the that needs to be saved, if any.  */
1485
1486 #ifdef ARGS_GROW_DOWNWARD
1487   for (i = 0; i < reg_parm_stack_space + 1; i++)
1488 #else
1489   for (i = 0; i < reg_parm_stack_space; i++)
1490 #endif
1491     {
1492       if (i >=  highest_outgoing_arg_in_use
1493           || stack_usage_map[i] == 0)
1494         continue;
1495
1496       if (low_to_save == -1)
1497         low_to_save = i;
1498
1499       high_to_save = i;
1500     }
1501
1502   if (low_to_save >= 0)
1503     {
1504       int num_to_save = high_to_save - low_to_save + 1;
1505       enum machine_mode save_mode
1506         = mode_for_size (num_to_save * BITS_PER_UNIT, MODE_INT, 1);
1507       rtx stack_area;
1508
1509       /* If we don't have the required alignment, must do this in BLKmode.  */
1510       if ((low_to_save & (MIN (GET_MODE_SIZE (save_mode),
1511                                BIGGEST_ALIGNMENT / UNITS_PER_WORD) - 1)))
1512         save_mode = BLKmode;
1513
1514       stack_area = gen_rtx (MEM, save_mode,
1515                             memory_address (save_mode,
1516                                             
1517 #ifdef ARGS_GROW_DOWNWARD
1518                                             plus_constant (argblock,
1519                                                            - high_to_save)
1520 #else
1521                                             plus_constant (argblock,
1522                                                            low_to_save)
1523 #endif
1524                                             ));
1525       if (save_mode == BLKmode)
1526         {
1527           save_area = assign_stack_temp (BLKmode, num_to_save, 1);
1528           emit_block_move (validize_mem (save_area), stack_area,
1529                            GEN_INT (num_to_save),
1530                            PARM_BOUNDARY / BITS_PER_UNIT);
1531         }
1532       else
1533         {
1534           save_area = gen_reg_rtx (save_mode);
1535           emit_move_insn (save_area, stack_area);
1536         }
1537     }
1538 #endif
1539           
1540
1541   /* Now store (and compute if necessary) all non-register parms.
1542      These come before register parms, since they can require block-moves,
1543      which could clobber the registers used for register parms.
1544      Parms which have partial registers are not stored here,
1545      but we do preallocate space here if they want that.  */
1546
1547   for (i = 0; i < num_actuals; i++)
1548     if (args[i].reg == 0 || args[i].pass_on_stack)
1549       store_one_arg (&args[i], argblock, may_be_alloca,
1550                      args_size.var != 0, fndecl, reg_parm_stack_space);
1551
1552 #ifdef STRICT_ALIGNMENT
1553   /* If we have a parm that is passed in registers but not in memory
1554      and whose alignment does not permit a direct copy into registers,
1555      make a group of pseudos that correspond to each register that we
1556      will later fill.  */
1557
1558   for (i = 0; i < num_actuals; i++)
1559     if (args[i].reg != 0 && ! args[i].pass_on_stack
1560         && args[i].mode == BLKmode
1561         && (TYPE_ALIGN (TREE_TYPE (args[i].tree_value))
1562             < MIN (BIGGEST_ALIGNMENT, BITS_PER_WORD)))
1563       {
1564         int bytes = int_size_in_bytes (TREE_TYPE (args[i].tree_value));
1565
1566         args[i].n_aligned_regs
1567           = args[i].partial ? args[i].partial
1568             : (bytes + (UNITS_PER_WORD - 1)) / UNITS_PER_WORD;
1569
1570         args[i].aligned_regs = (rtx *) alloca (sizeof (rtx)
1571                                                * args[i].n_aligned_regs);
1572
1573         for (j = 0; j < args[i].n_aligned_regs; j++)
1574           {
1575             rtx reg = gen_reg_rtx (word_mode);
1576             rtx word = operand_subword_force (args[i].value, j, BLKmode);
1577             int bitsize = TYPE_ALIGN (TREE_TYPE (args[i].tree_value));
1578             int bitpos;
1579
1580             args[i].aligned_regs[j] = reg;
1581
1582             /* Clobber REG and move each partword into it.  Ensure we don't
1583                go past the end of the structure.  Note that the loop below
1584                works because we've already verified that padding
1585                and endianness are compatible.  */
1586
1587             emit_insn (gen_rtx (CLOBBER, VOIDmode, reg));
1588
1589             for (bitpos = 0;
1590                  bitpos < BITS_PER_WORD && bytes > 0;
1591                  bitpos += bitsize, bytes -= bitsize / BITS_PER_UNIT)
1592               {
1593                 int xbitpos = (BYTES_BIG_ENDIAN
1594                                ? BITS_PER_WORD - bitpos - bitsize
1595                                : bitpos);
1596
1597                 store_bit_field (reg, bitsize, xbitpos, word_mode,
1598                                  extract_bit_field (word, bitsize, xbitpos, 1,
1599                                                     NULL_RTX, word_mode,
1600                                                     word_mode,
1601                                                     bitsize / BITS_PER_UNIT,
1602                                                     BITS_PER_WORD),
1603                                  bitsize / BITS_PER_UNIT, BITS_PER_WORD);
1604               }
1605           }
1606       }
1607 #endif
1608
1609   /* Now store any partially-in-registers parm.
1610      This is the last place a block-move can happen.  */
1611   if (reg_parm_seen)
1612     for (i = 0; i < num_actuals; i++)
1613       if (args[i].partial != 0 && ! args[i].pass_on_stack)
1614         store_one_arg (&args[i], argblock, may_be_alloca,
1615                        args_size.var != 0, fndecl, reg_parm_stack_space);
1616
1617 #ifndef PUSH_ARGS_REVERSED
1618 #ifdef STACK_BOUNDARY
1619   /* If we pushed args in forward order, perform stack alignment
1620      after pushing the last arg.  */
1621   if (argblock == 0)
1622     anti_adjust_stack (GEN_INT (args_size.constant
1623                                 - original_args_size.constant));
1624 #endif
1625 #endif
1626
1627   /* If register arguments require space on the stack and stack space
1628      was not preallocated, allocate stack space here for arguments
1629      passed in registers.  */
1630 #if ! defined(ALLOCATE_OUTGOING_ARGS) && defined(OUTGOING_REG_PARM_STACK_SPACE)
1631   if (must_preallocate == 0 && reg_parm_stack_space > 0)
1632     anti_adjust_stack (GEN_INT (reg_parm_stack_space));
1633 #endif
1634
1635   /* Pass the function the address in which to return a structure value.  */
1636   if (structure_value_addr && ! structure_value_addr_parm)
1637     {
1638       emit_move_insn (struct_value_rtx,
1639                       force_reg (Pmode,
1640                                  force_operand (structure_value_addr,
1641                                                 NULL_RTX)));
1642       if (GET_CODE (struct_value_rtx) == REG)
1643         {
1644           push_to_sequence (use_insns);
1645           emit_insn (gen_rtx (USE, VOIDmode, struct_value_rtx));
1646           use_insns = get_insns ();
1647           end_sequence ();
1648         }
1649     }
1650
1651   /* Now do the register loads required for any wholly-register parms or any
1652      parms which are passed both on the stack and in a register.  Their
1653      expressions were already evaluated. 
1654
1655      Mark all register-parms as living through the call, putting these USE
1656      insns in a list headed by USE_INSNS.  */
1657
1658   for (i = 0; i < num_actuals; i++)
1659     {
1660       rtx list = args[i].reg;
1661       int partial = args[i].partial;
1662
1663       while (list)
1664         {
1665           rtx reg;
1666           int nregs;
1667
1668           /* Process each register that needs to get this arg.  */
1669           if (GET_CODE (list) == EXPR_LIST)
1670             reg = XEXP (list, 0), list = XEXP (list, 1);
1671           else
1672             reg = list, list = 0;
1673
1674           /* Set to non-zero if must move a word at a time, even if just one
1675              word (e.g, partial == 1 && mode == DFmode).  Set to zero if
1676              we just use a normal move insn.  */
1677           nregs = (partial ? partial
1678                    : (TYPE_MODE (TREE_TYPE (args[i].tree_value)) == BLKmode
1679                       ? ((int_size_in_bytes (TREE_TYPE (args[i].tree_value))
1680                           + (UNITS_PER_WORD - 1)) / UNITS_PER_WORD)
1681                       : 0));
1682
1683           /* If simple case, just do move.  If normal partial, store_one_arg
1684              has already loaded the register for us.  In all other cases,
1685              load the register(s) from memory.  */
1686
1687           if (nregs == 0)
1688             emit_move_insn (reg, args[i].value);
1689
1690 #ifdef STRICT_ALIGNMENT
1691           /* If we have pre-computed the values to put in the registers in
1692              the case of non-aligned structures, copy them in now.  */
1693
1694           else if (args[i].n_aligned_regs != 0)
1695             for (j = 0; j < args[i].n_aligned_regs; j++)
1696               emit_move_insn (gen_rtx (REG, word_mode, REGNO (reg) + j),
1697                               args[i].aligned_regs[j]);
1698 #endif
1699
1700           else if (args[i].partial == 0 || args[i].pass_on_stack)
1701             move_block_to_reg (REGNO (reg),
1702                                validize_mem (args[i].value), nregs,
1703                                args[i].mode);
1704         
1705           push_to_sequence (use_insns);
1706           if (nregs == 0)
1707             emit_insn (gen_rtx (USE, VOIDmode, reg));
1708           else
1709             use_regs (REGNO (reg), nregs);
1710           use_insns = get_insns ();
1711           end_sequence ();
1712
1713           /* PARTIAL referred only to the first register, so clear it for the
1714              next time.  */
1715           partial = 0;
1716         }
1717     }
1718
1719   /* Perform postincrements before actually calling the function.  */
1720   emit_queue ();
1721
1722   /* All arguments and registers used for the call must be set up by now!  */
1723
1724   funexp = prepare_call_address (funexp, fndecl, &use_insns);
1725
1726   /* Generate the actual call instruction.  */
1727   emit_call_1 (funexp, funtype, args_size.constant, struct_value_size,
1728                FUNCTION_ARG (args_so_far, VOIDmode, void_type_node, 1),
1729                valreg, old_inhibit_defer_pop, use_insns, is_const);
1730
1731   /* If call is cse'able, make appropriate pair of reg-notes around it.
1732      Test valreg so we don't crash; may safely ignore `const'
1733      if return type is void.  */
1734   if (is_const && valreg != 0)
1735     {
1736       rtx note = 0;
1737       rtx temp = gen_reg_rtx (GET_MODE (valreg));
1738       rtx insns;
1739
1740       /* Construct an "equal form" for the value which mentions all the
1741          arguments in order as well as the function name.  */
1742 #ifdef PUSH_ARGS_REVERSED
1743       for (i = 0; i < num_actuals; i++)
1744         note = gen_rtx (EXPR_LIST, VOIDmode, args[i].initial_value, note);
1745 #else
1746       for (i = num_actuals - 1; i >= 0; i--)
1747         note = gen_rtx (EXPR_LIST, VOIDmode, args[i].initial_value, note);
1748 #endif
1749       note = gen_rtx (EXPR_LIST, VOIDmode, funexp, note);
1750
1751       insns = get_insns ();
1752       end_sequence ();
1753
1754       emit_libcall_block (insns, temp, valreg, note);
1755
1756       valreg = temp;
1757     }
1758
1759   /* For calls to `setjmp', etc., inform flow.c it should complain
1760      if nonvolatile values are live.  */
1761
1762   if (returns_twice)
1763     {
1764       emit_note (name, NOTE_INSN_SETJMP);
1765       current_function_calls_setjmp = 1;
1766     }
1767
1768   if (is_longjmp)
1769     current_function_calls_longjmp = 1;
1770
1771   /* Notice functions that cannot return.
1772      If optimizing, insns emitted below will be dead.
1773      If not optimizing, they will exist, which is useful
1774      if the user uses the `return' command in the debugger.  */
1775
1776   if (is_volatile || is_longjmp)
1777     emit_barrier ();
1778
1779   /* If value type not void, return an rtx for the value.  */
1780
1781   /* If there are cleanups to be called, don't use a hard reg as target.  */
1782   if (cleanups_this_call != old_cleanups
1783       && target && REG_P (target)
1784       && REGNO (target) < FIRST_PSEUDO_REGISTER)
1785     target = 0;
1786
1787   if (TYPE_MODE (TREE_TYPE (exp)) == VOIDmode
1788       || ignore)
1789     {
1790       target = const0_rtx;
1791     }
1792   else if (structure_value_addr)
1793     {
1794       if (target == 0 || GET_CODE (target) != MEM)
1795         {
1796           target = gen_rtx (MEM, TYPE_MODE (TREE_TYPE (exp)),
1797                             memory_address (TYPE_MODE (TREE_TYPE (exp)),
1798                                             structure_value_addr));
1799           MEM_IN_STRUCT_P (target)
1800             = (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE
1801                || TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE
1802                || TREE_CODE (TREE_TYPE (exp)) == UNION_TYPE);
1803         }
1804     }
1805   else if (pcc_struct_value)
1806     {
1807       if (target == 0)
1808         {
1809           target = gen_rtx (MEM, TYPE_MODE (TREE_TYPE (exp)),
1810                             copy_to_reg (valreg));
1811           MEM_IN_STRUCT_P (target)
1812             = (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE
1813                || TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE
1814                || TREE_CODE (TREE_TYPE (exp)) == UNION_TYPE);
1815         }
1816       else if (TYPE_MODE (TREE_TYPE (exp)) != BLKmode)
1817         emit_move_insn (target, gen_rtx (MEM, TYPE_MODE (TREE_TYPE (exp)),
1818                                          copy_to_reg (valreg)));
1819       else
1820         emit_block_move (target, gen_rtx (MEM, BLKmode, copy_to_reg (valreg)),
1821                          expr_size (exp),
1822                          TYPE_ALIGN (TREE_TYPE (exp)) / BITS_PER_UNIT);
1823     }
1824   else if (target && GET_MODE (target) == TYPE_MODE (TREE_TYPE (exp))
1825            && GET_MODE (target) == GET_MODE (valreg))
1826     /* TARGET and VALREG cannot be equal at this point because the latter
1827        would not have REG_FUNCTION_VALUE_P true, while the former would if
1828        it were referring to the same register.
1829
1830        If they refer to the same register, this move will be a no-op, except
1831        when function inlining is being done.  */
1832     emit_move_insn (target, valreg);
1833   else
1834     target = copy_to_reg (valreg);
1835
1836 #ifdef PROMOTE_FUNCTION_RETURN
1837   /* If we promoted this return value, make the proper SUBREG.  */
1838   if (GET_MODE (target) != TYPE_MODE (TREE_TYPE (exp)))
1839     {
1840       enum machine_mode mode = GET_MODE (target);
1841       int unsignedp = TREE_UNSIGNED (TREE_TYPE (exp));
1842
1843       if (TREE_CODE (TREE_TYPE (exp)) == INTEGER_TYPE
1844           || TREE_CODE (TREE_TYPE (exp)) == ENUMERAL_TYPE
1845           || TREE_CODE (TREE_TYPE (exp)) == BOOLEAN_TYPE
1846           || TREE_CODE (TREE_TYPE (exp)) == CHAR_TYPE
1847           || TREE_CODE (TREE_TYPE (exp)) == REAL_TYPE
1848           || TREE_CODE (TREE_TYPE (exp)) == POINTER_TYPE
1849           || TREE_CODE (TREE_TYPE (exp)) == OFFSET_TYPE)
1850         {
1851           PROMOTE_MODE (mode, unsignedp, TREE_TYPE (exp));
1852         }
1853
1854       target = gen_rtx (SUBREG, TYPE_MODE (TREE_TYPE (exp)), target, 0);
1855       SUBREG_PROMOTED_VAR_P (target) = 1;
1856       SUBREG_PROMOTED_UNSIGNED_P (target) = unsignedp;
1857     }
1858 #endif
1859
1860   /* Perform all cleanups needed for the arguments of this call
1861      (i.e. destructors in C++).  */
1862   expand_cleanups_to (old_cleanups);
1863
1864   /* If size of args is variable or this was a constructor call for a stack
1865      argument, restore saved stack-pointer value.  */
1866
1867   if (old_stack_level)
1868     {
1869       emit_stack_restore (SAVE_BLOCK, old_stack_level, NULL_RTX);
1870       pending_stack_adjust = old_pending_adj;
1871 #ifdef ACCUMULATE_OUTGOING_ARGS
1872       stack_arg_under_construction = old_stack_arg_under_construction;
1873       highest_outgoing_arg_in_use = initial_highest_arg_in_use;
1874       stack_usage_map = initial_stack_usage_map;
1875 #endif
1876     }
1877 #ifdef ACCUMULATE_OUTGOING_ARGS
1878   else
1879     {
1880 #ifdef REG_PARM_STACK_SPACE
1881       if (save_area)
1882         {
1883           enum machine_mode save_mode = GET_MODE (save_area);
1884           rtx stack_area
1885             = gen_rtx (MEM, save_mode,
1886                        memory_address (save_mode,
1887 #ifdef ARGS_GROW_DOWNWARD
1888                                        plus_constant (argblock, - high_to_save)
1889 #else
1890                                        plus_constant (argblock, low_to_save)
1891 #endif
1892                                        ));
1893
1894           if (save_mode != BLKmode)
1895             emit_move_insn (stack_area, save_area);
1896           else
1897             emit_block_move (stack_area, validize_mem (save_area),
1898                              GEN_INT (high_to_save - low_to_save + 1),
1899                              PARM_BOUNDARY / BITS_PER_UNIT);
1900         }
1901 #endif
1902           
1903       /* If we saved any argument areas, restore them.  */
1904       for (i = 0; i < num_actuals; i++)
1905         if (args[i].save_area)
1906           {
1907             enum machine_mode save_mode = GET_MODE (args[i].save_area);
1908             rtx stack_area
1909               = gen_rtx (MEM, save_mode,
1910                          memory_address (save_mode,
1911                                          XEXP (args[i].stack_slot, 0)));
1912
1913             if (save_mode != BLKmode)
1914               emit_move_insn (stack_area, args[i].save_area);
1915             else
1916               emit_block_move (stack_area, validize_mem (args[i].save_area),
1917                                GEN_INT (args[i].size.constant),
1918                                PARM_BOUNDARY / BITS_PER_UNIT);
1919           }
1920
1921       highest_outgoing_arg_in_use = initial_highest_arg_in_use;
1922       stack_usage_map = initial_stack_usage_map;
1923     }
1924 #endif
1925
1926   /* If this was alloca, record the new stack level for nonlocal gotos.  
1927      Check for the handler slots since we might not have a save area
1928      for non-local gotos. */
1929
1930   if (may_be_alloca && nonlocal_goto_handler_slot != 0)
1931     emit_stack_save (SAVE_NONLOCAL, &nonlocal_goto_stack_level, NULL_RTX);
1932
1933   pop_temp_slots ();
1934
1935   return target;
1936 }
1937 \f
1938 /* Output a library call to function FUN (a SYMBOL_REF rtx)
1939    (emitting the queue unless NO_QUEUE is nonzero),
1940    for a value of mode OUTMODE,
1941    with NARGS different arguments, passed as alternating rtx values
1942    and machine_modes to convert them to.
1943    The rtx values should have been passed through protect_from_queue already.
1944
1945    NO_QUEUE will be true if and only if the library call is a `const' call
1946    which will be enclosed in REG_LIBCALL/REG_RETVAL notes; it is equivalent
1947    to the variable is_const in expand_call.
1948
1949    NO_QUEUE must be true for const calls, because if it isn't, then
1950    any pending increment will be emitted between REG_LIBCALL/REG_RETVAL notes,
1951    and will be lost if the libcall sequence is optimized away.
1952
1953    NO_QUEUE must be false for non-const calls, because if it isn't, the
1954    call insn will have its CONST_CALL_P bit set, and it will be incorrectly
1955    optimized.  For instance, the instruction scheduler may incorrectly
1956    move memory references across the non-const call.  */
1957
1958 void
1959 emit_library_call (va_alist)
1960      va_dcl
1961 {
1962   va_list p;
1963   /* Total size in bytes of all the stack-parms scanned so far.  */
1964   struct args_size args_size;
1965   /* Size of arguments before any adjustments (such as rounding).  */
1966   struct args_size original_args_size;
1967   register int argnum;
1968   enum machine_mode outmode;
1969   int nargs;
1970   rtx fun;
1971   rtx orgfun;
1972   int inc;
1973   int count;
1974   rtx argblock = 0;
1975   CUMULATIVE_ARGS args_so_far;
1976   struct arg { rtx value; enum machine_mode mode; rtx reg; int partial;
1977                struct args_size offset; struct args_size size; };
1978   struct arg *argvec;
1979   int old_inhibit_defer_pop = inhibit_defer_pop;
1980   int no_queue = 0;
1981   rtx use_insns;
1982
1983   va_start (p);
1984   orgfun = fun = va_arg (p, rtx);
1985   no_queue = va_arg (p, int);
1986   outmode = va_arg (p, enum machine_mode);
1987   nargs = va_arg (p, int);
1988
1989   /* Copy all the libcall-arguments out of the varargs data
1990      and into a vector ARGVEC.
1991
1992      Compute how to pass each argument.  We only support a very small subset
1993      of the full argument passing conventions to limit complexity here since
1994      library functions shouldn't have many args.  */
1995
1996   argvec = (struct arg *) alloca (nargs * sizeof (struct arg));
1997
1998   INIT_CUMULATIVE_ARGS (args_so_far, NULL_TREE, fun);
1999
2000   args_size.constant = 0;
2001   args_size.var = 0;
2002
2003   for (count = 0; count < nargs; count++)
2004     {
2005       rtx val = va_arg (p, rtx);
2006       enum machine_mode mode = va_arg (p, enum machine_mode);
2007
2008       /* We cannot convert the arg value to the mode the library wants here;
2009          must do it earlier where we know the signedness of the arg.  */
2010       if (mode == BLKmode
2011           || (GET_MODE (val) != mode && GET_MODE (val) != VOIDmode))
2012         abort ();
2013
2014       /* On some machines, there's no way to pass a float to a library fcn.
2015          Pass it as a double instead.  */
2016 #ifdef LIBGCC_NEEDS_DOUBLE
2017       if (LIBGCC_NEEDS_DOUBLE && mode == SFmode)
2018         val = convert_to_mode (DFmode, val, 0), mode = DFmode;
2019 #endif
2020
2021       /* There's no need to call protect_from_queue, because
2022          either emit_move_insn or emit_push_insn will do that.  */
2023
2024       /* Make sure it is a reasonable operand for a move or push insn.  */
2025       if (GET_CODE (val) != REG && GET_CODE (val) != MEM
2026           && ! (CONSTANT_P (val) && LEGITIMATE_CONSTANT_P (val)))
2027         val = force_operand (val, NULL_RTX);
2028
2029       argvec[count].value = val;
2030       argvec[count].mode = mode;
2031
2032 #ifdef FUNCTION_ARG_PASS_BY_REFERENCE
2033       if (FUNCTION_ARG_PASS_BY_REFERENCE (args_so_far, mode, NULL_TREE, 1))
2034         abort ();
2035 #endif
2036
2037       argvec[count].reg = FUNCTION_ARG (args_so_far, mode, NULL_TREE, 1);
2038       if (argvec[count].reg && GET_CODE (argvec[count].reg) == EXPR_LIST)
2039         abort ();
2040 #ifdef FUNCTION_ARG_PARTIAL_NREGS
2041       argvec[count].partial
2042         = FUNCTION_ARG_PARTIAL_NREGS (args_so_far, mode, NULL_TREE, 1);
2043 #else
2044       argvec[count].partial = 0;
2045 #endif
2046
2047       locate_and_pad_parm (mode, NULL_TREE,
2048                            argvec[count].reg && argvec[count].partial == 0,
2049                            NULL_TREE, &args_size, &argvec[count].offset,
2050                            &argvec[count].size);
2051
2052       if (argvec[count].size.var)
2053         abort ();
2054
2055 #ifndef REG_PARM_STACK_SPACE
2056       if (argvec[count].partial)
2057         argvec[count].size.constant -= argvec[count].partial * UNITS_PER_WORD;
2058 #endif
2059
2060       if (argvec[count].reg == 0 || argvec[count].partial != 0
2061 #ifdef REG_PARM_STACK_SPACE
2062           || 1
2063 #endif
2064           )
2065         args_size.constant += argvec[count].size.constant;
2066
2067 #ifdef ACCUMULATE_OUTGOING_ARGS
2068       /* If this arg is actually passed on the stack, it might be
2069          clobbering something we already put there (this library call might
2070          be inside the evaluation of an argument to a function whose call
2071          requires the stack).  This will only occur when the library call
2072          has sufficient args to run out of argument registers.  Abort in
2073          this case; if this ever occurs, code must be added to save and
2074          restore the arg slot.  */
2075
2076       if (argvec[count].reg == 0 || argvec[count].partial != 0)
2077         abort ();
2078 #endif
2079
2080       FUNCTION_ARG_ADVANCE (args_so_far, mode, (tree)0, 1);
2081     }
2082   va_end (p);
2083
2084   /* If this machine requires an external definition for library
2085      functions, write one out.  */
2086   assemble_external_libcall (fun);
2087
2088   original_args_size = args_size;
2089 #ifdef STACK_BOUNDARY
2090   args_size.constant = (((args_size.constant + (STACK_BYTES - 1))
2091                          / STACK_BYTES) * STACK_BYTES);
2092 #endif
2093
2094 #ifdef REG_PARM_STACK_SPACE
2095   args_size.constant = MAX (args_size.constant,
2096                             REG_PARM_STACK_SPACE (NULL_TREE));
2097 #ifndef OUTGOING_REG_PARM_STACK_SPACE
2098   args_size.constant -= REG_PARM_STACK_SPACE (NULL_TREE);
2099 #endif
2100 #endif
2101
2102 #ifdef ACCUMULATE_OUTGOING_ARGS
2103   if (args_size.constant > current_function_outgoing_args_size)
2104     current_function_outgoing_args_size = args_size.constant;
2105   args_size.constant = 0;
2106 #endif
2107
2108 #ifndef PUSH_ROUNDING
2109   argblock = push_block (GEN_INT (args_size.constant), 0, 0);
2110 #endif
2111
2112 #ifdef PUSH_ARGS_REVERSED
2113 #ifdef STACK_BOUNDARY
2114   /* If we push args individually in reverse order, perform stack alignment
2115      before the first push (the last arg).  */
2116   if (argblock == 0)
2117     anti_adjust_stack (GEN_INT (args_size.constant
2118                                 - original_args_size.constant));
2119 #endif
2120 #endif
2121
2122 #ifdef PUSH_ARGS_REVERSED
2123   inc = -1;
2124   argnum = nargs - 1;
2125 #else
2126   inc = 1;
2127   argnum = 0;
2128 #endif
2129
2130   /* Push the args that need to be pushed.  */
2131
2132   for (count = 0; count < nargs; count++, argnum += inc)
2133     {
2134       register enum machine_mode mode = argvec[argnum].mode;
2135       register rtx val = argvec[argnum].value;
2136       rtx reg = argvec[argnum].reg;
2137       int partial = argvec[argnum].partial;
2138
2139       if (! (reg != 0 && partial == 0))
2140         emit_push_insn (val, mode, NULL_TREE, NULL_RTX, 0, partial, reg, 0,
2141                         argblock, GEN_INT (argvec[count].offset.constant));
2142       NO_DEFER_POP;
2143     }
2144
2145 #ifndef PUSH_ARGS_REVERSED
2146 #ifdef STACK_BOUNDARY
2147   /* If we pushed args in forward order, perform stack alignment
2148      after pushing the last arg.  */
2149   if (argblock == 0)
2150     anti_adjust_stack (GEN_INT (args_size.constant
2151                                 - original_args_size.constant));
2152 #endif
2153 #endif
2154
2155 #ifdef PUSH_ARGS_REVERSED
2156   argnum = nargs - 1;
2157 #else
2158   argnum = 0;
2159 #endif
2160
2161   /* Now load any reg parms into their regs.  */
2162
2163   for (count = 0; count < nargs; count++, argnum += inc)
2164     {
2165       register enum machine_mode mode = argvec[argnum].mode;
2166       register rtx val = argvec[argnum].value;
2167       rtx reg = argvec[argnum].reg;
2168       int partial = argvec[argnum].partial;
2169
2170       if (reg != 0 && partial == 0)
2171         emit_move_insn (reg, val);
2172       NO_DEFER_POP;
2173     }
2174
2175   /* For version 1.37, try deleting this entirely.  */
2176   if (! no_queue)
2177     emit_queue ();
2178
2179   /* Any regs containing parms remain in use through the call.  */
2180   start_sequence ();
2181   for (count = 0; count < nargs; count++)
2182     if (argvec[count].reg != 0)
2183       emit_insn (gen_rtx (USE, VOIDmode, argvec[count].reg));
2184
2185   use_insns = get_insns ();
2186   end_sequence ();
2187
2188   fun = prepare_call_address (fun, NULL_TREE, &use_insns);
2189
2190   /* Don't allow popping to be deferred, since then
2191      cse'ing of library calls could delete a call and leave the pop.  */
2192   NO_DEFER_POP;
2193
2194   /* We pass the old value of inhibit_defer_pop + 1 to emit_call_1, which
2195      will set inhibit_defer_pop to that value.  */
2196
2197   emit_call_1 (fun, get_identifier (XSTR (orgfun, 0)), args_size.constant, 0,
2198                FUNCTION_ARG (args_so_far, VOIDmode, void_type_node, 1),
2199                outmode != VOIDmode ? hard_libcall_value (outmode) : NULL_RTX,
2200                old_inhibit_defer_pop + 1, use_insns, no_queue);
2201
2202   /* Now restore inhibit_defer_pop to its actual original value.  */
2203   OK_DEFER_POP;
2204 }
2205 \f
2206 /* Like emit_library_call except that an extra argument, VALUE,
2207    comes second and says where to store the result.
2208    (If VALUE is zero, the result comes in the function value register.)  */
2209
2210 void
2211 emit_library_call_value (va_alist)
2212      va_dcl
2213 {
2214   va_list p;
2215   /* Total size in bytes of all the stack-parms scanned so far.  */
2216   struct args_size args_size;
2217   /* Size of arguments before any adjustments (such as rounding).  */
2218   struct args_size original_args_size;
2219   register int argnum;
2220   enum machine_mode outmode;
2221   int nargs;
2222   rtx fun;
2223   rtx orgfun;
2224   int inc;
2225   int count;
2226   rtx argblock = 0;
2227   CUMULATIVE_ARGS args_so_far;
2228   struct arg { rtx value; enum machine_mode mode; rtx reg; int partial;
2229                struct args_size offset; struct args_size size; };
2230   struct arg *argvec;
2231   int old_inhibit_defer_pop = inhibit_defer_pop;
2232   int no_queue = 0;
2233   rtx use_insns;
2234   rtx value;
2235   rtx mem_value = 0;
2236
2237   va_start (p);
2238   orgfun = fun = va_arg (p, rtx);
2239   value = va_arg (p, rtx);
2240   no_queue = va_arg (p, int);
2241   outmode = va_arg (p, enum machine_mode);
2242   nargs = va_arg (p, int);
2243
2244   /* If this kind of value comes back in memory,
2245      decide where in memory it should come back.  */
2246   if (RETURN_IN_MEMORY (type_for_mode (outmode, 0)))
2247     {
2248       if (GET_CODE (value) == MEM)
2249         mem_value = value;
2250       else
2251         mem_value = assign_stack_temp (outmode, GET_MODE_SIZE (outmode), 0);
2252     }
2253
2254   /* ??? Unfinished: must pass the memory address as an argument.  */
2255
2256   /* Copy all the libcall-arguments out of the varargs data
2257      and into a vector ARGVEC.
2258
2259      Compute how to pass each argument.  We only support a very small subset
2260      of the full argument passing conventions to limit complexity here since
2261      library functions shouldn't have many args.  */
2262
2263   argvec = (struct arg *) alloca ((nargs + 1) * sizeof (struct arg));
2264
2265   INIT_CUMULATIVE_ARGS (args_so_far, NULL_TREE, fun);
2266
2267   args_size.constant = 0;
2268   args_size.var = 0;
2269
2270   count = 0;
2271
2272   /* If there's a structure value address to be passed,
2273      either pass it in the special place, or pass it as an extra argument.  */
2274   if (mem_value)
2275     {
2276       rtx addr = XEXP (mem_value, 0);
2277
2278       if (! struct_value_rtx)
2279         {
2280           nargs++;
2281
2282           /* Make sure it is a reasonable operand for a move or push insn.  */
2283           if (GET_CODE (addr) != REG && GET_CODE (addr) != MEM
2284               && ! (CONSTANT_P (addr) && LEGITIMATE_CONSTANT_P (addr)))
2285             addr = force_operand (addr, NULL_RTX);
2286
2287           argvec[count].value = addr;
2288           argvec[count].mode = outmode;
2289           argvec[count].partial = 0;
2290
2291           argvec[count].reg = FUNCTION_ARG (args_so_far, outmode, NULL_TREE, 1);
2292 #ifdef FUNCTION_ARG_PARTIAL_NREGS
2293           if (FUNCTION_ARG_PARTIAL_NREGS (args_so_far, outmode, NULL_TREE, 1))
2294             abort ();
2295 #endif
2296
2297           locate_and_pad_parm (outmode, NULL_TREE,
2298                                argvec[count].reg && argvec[count].partial == 0,
2299                                NULL_TREE, &args_size, &argvec[count].offset,
2300                                &argvec[count].size);
2301
2302
2303           if (argvec[count].reg == 0 || argvec[count].partial != 0
2304 #ifdef REG_PARM_STACK_SPACE
2305               || 1
2306 #endif
2307               )
2308             args_size.constant += argvec[count].size.constant;
2309
2310           FUNCTION_ARG_ADVANCE (args_so_far, outmode, (tree)0, 1);
2311         }
2312     }
2313
2314   for (; count < nargs; count++)
2315     {
2316       rtx val = va_arg (p, rtx);
2317       enum machine_mode mode = va_arg (p, enum machine_mode);
2318
2319       /* We cannot convert the arg value to the mode the library wants here;
2320          must do it earlier where we know the signedness of the arg.  */
2321       if (mode == BLKmode
2322           || (GET_MODE (val) != mode && GET_MODE (val) != VOIDmode))
2323         abort ();
2324
2325       /* On some machines, there's no way to pass a float to a library fcn.
2326          Pass it as a double instead.  */
2327 #ifdef LIBGCC_NEEDS_DOUBLE
2328       if (LIBGCC_NEEDS_DOUBLE && mode == SFmode)
2329         val = convert_to_mode (DFmode, val, 0), mode = DFmode;
2330 #endif
2331
2332       /* There's no need to call protect_from_queue, because
2333          either emit_move_insn or emit_push_insn will do that.  */
2334
2335       /* Make sure it is a reasonable operand for a move or push insn.  */
2336       if (GET_CODE (val) != REG && GET_CODE (val) != MEM
2337           && ! (CONSTANT_P (val) && LEGITIMATE_CONSTANT_P (val)))
2338         val = force_operand (val, NULL_RTX);
2339
2340       argvec[count].value = val;
2341       argvec[count].mode = mode;
2342
2343 #ifdef FUNCTION_ARG_PASS_BY_REFERENCE
2344       if (FUNCTION_ARG_PASS_BY_REFERENCE (args_so_far, mode, NULL_TREE, 1))
2345         abort ();
2346 #endif
2347
2348       argvec[count].reg = FUNCTION_ARG (args_so_far, mode, NULL_TREE, 1);
2349       if (argvec[count].reg && GET_CODE (argvec[count].reg) == EXPR_LIST)
2350         abort ();
2351 #ifdef FUNCTION_ARG_PARTIAL_NREGS
2352       argvec[count].partial
2353         = FUNCTION_ARG_PARTIAL_NREGS (args_so_far, mode, NULL_TREE, 1);
2354 #else
2355       argvec[count].partial = 0;
2356 #endif
2357
2358       locate_and_pad_parm (mode, NULL_TREE,
2359                            argvec[count].reg && argvec[count].partial == 0,
2360                            NULL_TREE, &args_size, &argvec[count].offset,
2361                            &argvec[count].size);
2362
2363       if (argvec[count].size.var)
2364         abort ();
2365
2366 #ifndef REG_PARM_STACK_SPACE
2367       if (argvec[count].partial)
2368         argvec[count].size.constant -= argvec[count].partial * UNITS_PER_WORD;
2369 #endif
2370
2371       if (argvec[count].reg == 0 || argvec[count].partial != 0
2372 #ifdef REG_PARM_STACK_SPACE
2373           || 1
2374 #endif
2375           )
2376         args_size.constant += argvec[count].size.constant;
2377
2378 #ifdef ACCUMULATE_OUTGOING_ARGS
2379       /* If this arg is actually passed on the stack, it might be
2380          clobbering something we already put there (this library call might
2381          be inside the evaluation of an argument to a function whose call
2382          requires the stack).  This will only occur when the library call
2383          has sufficient args to run out of argument registers.  Abort in
2384          this case; if this ever occurs, code must be added to save and
2385          restore the arg slot.  */
2386
2387       if (argvec[count].reg == 0 || argvec[count].partial != 0)
2388         abort ();
2389 #endif
2390
2391       FUNCTION_ARG_ADVANCE (args_so_far, mode, (tree)0, 1);
2392     }
2393   va_end (p);
2394
2395   /* If this machine requires an external definition for library
2396      functions, write one out.  */
2397   assemble_external_libcall (fun);
2398
2399   original_args_size = args_size;
2400 #ifdef STACK_BOUNDARY
2401   args_size.constant = (((args_size.constant + (STACK_BYTES - 1))
2402                          / STACK_BYTES) * STACK_BYTES);
2403 #endif
2404
2405 #ifdef REG_PARM_STACK_SPACE
2406   args_size.constant = MAX (args_size.constant,
2407                             REG_PARM_STACK_SPACE (NULL_TREE));
2408 #ifndef OUTGOING_REG_PARM_STACK_SPACE
2409   args_size.constant -= REG_PARM_STACK_SPACE (NULL_TREE);
2410 #endif
2411 #endif
2412
2413 #ifdef ACCUMULATE_OUTGOING_ARGS
2414   if (args_size.constant > current_function_outgoing_args_size)
2415     current_function_outgoing_args_size = args_size.constant;
2416   args_size.constant = 0;
2417 #endif
2418
2419 #ifndef PUSH_ROUNDING
2420   argblock = push_block (GEN_INT (args_size.constant), 0, 0);
2421 #endif
2422
2423 #ifdef PUSH_ARGS_REVERSED
2424 #ifdef STACK_BOUNDARY
2425   /* If we push args individually in reverse order, perform stack alignment
2426      before the first push (the last arg).  */
2427   if (argblock == 0)
2428     anti_adjust_stack (GEN_INT (args_size.constant
2429                                 - original_args_size.constant));
2430 #endif
2431 #endif
2432
2433 #ifdef PUSH_ARGS_REVERSED
2434   inc = -1;
2435   argnum = nargs - 1;
2436 #else
2437   inc = 1;
2438   argnum = 0;
2439 #endif
2440
2441   /* Push the args that need to be pushed.  */
2442
2443   for (count = 0; count < nargs; count++, argnum += inc)
2444     {
2445       register enum machine_mode mode = argvec[argnum].mode;
2446       register rtx val = argvec[argnum].value;
2447       rtx reg = argvec[argnum].reg;
2448       int partial = argvec[argnum].partial;
2449
2450       if (! (reg != 0 && partial == 0))
2451         emit_push_insn (val, mode, NULL_TREE, NULL_RTX, 0, partial, reg, 0,
2452                         argblock, GEN_INT (argvec[count].offset.constant));
2453       NO_DEFER_POP;
2454     }
2455
2456 #ifndef PUSH_ARGS_REVERSED
2457 #ifdef STACK_BOUNDARY
2458   /* If we pushed args in forward order, perform stack alignment
2459      after pushing the last arg.  */
2460   if (argblock == 0)
2461     anti_adjust_stack (GEN_INT (args_size.constant
2462                                 - original_args_size.constant));
2463 #endif
2464 #endif
2465
2466 #ifdef PUSH_ARGS_REVERSED
2467   argnum = nargs - 1;
2468 #else
2469   argnum = 0;
2470 #endif
2471
2472   /* Now load any reg parms into their regs.  */
2473
2474   if (mem_value != 0 && struct_value_rtx != 0)
2475     emit_move_insn (struct_value_rtx, XEXP (mem_value, 0));
2476
2477   for (count = 0; count < nargs; count++, argnum += inc)
2478     {
2479       register enum machine_mode mode = argvec[argnum].mode;
2480       register rtx val = argvec[argnum].value;
2481       rtx reg = argvec[argnum].reg;
2482       int partial = argvec[argnum].partial;
2483
2484       if (reg != 0 && partial == 0)
2485         emit_move_insn (reg, val);
2486       NO_DEFER_POP;
2487     }
2488
2489 #if 0
2490   /* For version 1.37, try deleting this entirely.  */
2491   if (! no_queue)
2492     emit_queue ();
2493 #endif
2494
2495   /* Any regs containing parms remain in use through the call.  */
2496   start_sequence ();
2497   for (count = 0; count < nargs; count++)
2498     if (argvec[count].reg != 0)
2499       emit_insn (gen_rtx (USE, VOIDmode, argvec[count].reg));
2500
2501   use_insns = get_insns ();
2502   end_sequence ();
2503
2504   fun = prepare_call_address (fun, NULL_TREE, &use_insns);
2505
2506   /* Don't allow popping to be deferred, since then
2507      cse'ing of library calls could delete a call and leave the pop.  */
2508   NO_DEFER_POP;
2509
2510   /* We pass the old value of inhibit_defer_pop + 1 to emit_call_1, which
2511      will set inhibit_defer_pop to that value.  */
2512
2513   emit_call_1 (fun, get_identifier (XSTR (orgfun, 0)), args_size.constant, 0,
2514                FUNCTION_ARG (args_so_far, VOIDmode, void_type_node, 1),
2515                outmode != VOIDmode ? hard_libcall_value (outmode) : NULL_RTX,
2516                old_inhibit_defer_pop + 1, use_insns, no_queue);
2517
2518   /* Now restore inhibit_defer_pop to its actual original value.  */
2519   OK_DEFER_POP;
2520
2521   /* Copy the value to the right place.  */
2522   if (outmode != VOIDmode)
2523     {
2524       if (mem_value)
2525         {
2526           if (value == 0)
2527             value = hard_libcall_value (outmode);
2528           if (value != mem_value)
2529             emit_move_insn (value, mem_value);
2530         }
2531       else if (value != 0)
2532         emit_move_insn (value, hard_libcall_value (outmode));
2533     }
2534 }
2535 \f
2536 #if 0
2537 /* Return an rtx which represents a suitable home on the stack
2538    given TYPE, the type of the argument looking for a home.
2539    This is called only for BLKmode arguments.
2540
2541    SIZE is the size needed for this target.
2542    ARGS_ADDR is the address of the bottom of the argument block for this call.
2543    OFFSET describes this parameter's offset into ARGS_ADDR.  It is meaningless
2544    if this machine uses push insns.  */
2545
2546 static rtx
2547 target_for_arg (type, size, args_addr, offset)
2548      tree type;
2549      rtx size;
2550      rtx args_addr;
2551      struct args_size offset;
2552 {
2553   rtx target;
2554   rtx offset_rtx = ARGS_SIZE_RTX (offset);
2555
2556   /* We do not call memory_address if possible,
2557      because we want to address as close to the stack
2558      as possible.  For non-variable sized arguments,
2559      this will be stack-pointer relative addressing.  */
2560   if (GET_CODE (offset_rtx) == CONST_INT)
2561     target = plus_constant (args_addr, INTVAL (offset_rtx));
2562   else
2563     {
2564       /* I have no idea how to guarantee that this
2565          will work in the presence of register parameters.  */
2566       target = gen_rtx (PLUS, Pmode, args_addr, offset_rtx);
2567       target = memory_address (QImode, target);
2568     }
2569
2570   return gen_rtx (MEM, BLKmode, target);
2571 }
2572 #endif
2573 \f
2574 /* Store a single argument for a function call
2575    into the register or memory area where it must be passed.
2576    *ARG describes the argument value and where to pass it.
2577
2578    ARGBLOCK is the address of the stack-block for all the arguments,
2579    or 0 on a machine where arguments are pushed individually.
2580
2581    MAY_BE_ALLOCA nonzero says this could be a call to `alloca'
2582    so must be careful about how the stack is used. 
2583
2584    VARIABLE_SIZE nonzero says that this was a variable-sized outgoing
2585    argument stack.  This is used if ACCUMULATE_OUTGOING_ARGS to indicate
2586    that we need not worry about saving and restoring the stack.
2587
2588    FNDECL is the declaration of the function we are calling.  */
2589
2590 static void
2591 store_one_arg (arg, argblock, may_be_alloca, variable_size, fndecl,
2592                reg_parm_stack_space)
2593      struct arg_data *arg;
2594      rtx argblock;
2595      int may_be_alloca;
2596      int variable_size;
2597      tree fndecl;
2598      int reg_parm_stack_space;
2599 {
2600   register tree pval = arg->tree_value;
2601   rtx reg = 0;
2602   int partial = 0;
2603   int used = 0;
2604   int i, lower_bound, upper_bound;
2605
2606   if (TREE_CODE (pval) == ERROR_MARK)
2607     return;
2608
2609 #ifdef ACCUMULATE_OUTGOING_ARGS
2610   /* If this is being stored into a pre-allocated, fixed-size, stack area,
2611      save any previous data at that location.  */
2612   if (argblock && ! variable_size && arg->stack)
2613     {
2614 #ifdef ARGS_GROW_DOWNWARD
2615       /* stack_slot is negative, but we want to index stack_usage_map */
2616       /* with positive values. */
2617       if (GET_CODE (XEXP (arg->stack_slot, 0)) == PLUS)
2618         upper_bound = -INTVAL (XEXP (XEXP (arg->stack_slot, 0), 1)) + 1;
2619       else
2620         abort ();
2621
2622       lower_bound = upper_bound - arg->size.constant;
2623 #else
2624       if (GET_CODE (XEXP (arg->stack_slot, 0)) == PLUS)
2625         lower_bound = INTVAL (XEXP (XEXP (arg->stack_slot, 0), 1));
2626       else
2627         lower_bound = 0;
2628
2629       upper_bound = lower_bound + arg->size.constant;
2630 #endif
2631
2632       for (i = lower_bound; i < upper_bound; i++)
2633         if (stack_usage_map[i]
2634 #ifdef REG_PARM_STACK_SPACE
2635             /* Don't store things in the fixed argument area at this point;
2636                it has already been saved.  */
2637             && i > reg_parm_stack_space
2638 #endif
2639             )
2640           break;
2641
2642       if (i != upper_bound)
2643         {
2644           /* We need to make a save area.  See what mode we can make it.  */
2645           enum machine_mode save_mode
2646             = mode_for_size (arg->size.constant * BITS_PER_UNIT, MODE_INT, 1);
2647           rtx stack_area
2648             = gen_rtx (MEM, save_mode,
2649                        memory_address (save_mode, XEXP (arg->stack_slot, 0)));
2650
2651           if (save_mode == BLKmode)
2652             {
2653               arg->save_area = assign_stack_temp (BLKmode,
2654                                                   arg->size.constant, 1);
2655               emit_block_move (validize_mem (arg->save_area), stack_area,
2656                                GEN_INT (arg->size.constant),
2657                                PARM_BOUNDARY / BITS_PER_UNIT);
2658             }
2659           else
2660             {
2661               arg->save_area = gen_reg_rtx (save_mode);
2662               emit_move_insn (arg->save_area, stack_area);
2663             }
2664         }
2665     }
2666 #endif
2667
2668   /* If this isn't going to be placed on both the stack and in registers,
2669      set up the register and number of words.  */
2670   if (! arg->pass_on_stack)
2671     reg = arg->reg, partial = arg->partial;
2672
2673   if (reg != 0 && partial == 0)
2674     /* Being passed entirely in a register.  We shouldn't be called in
2675        this case.   */
2676     abort ();
2677
2678 #ifdef STRICT_ALIGNMENT
2679   /* If this arg needs special alignment, don't load the registers
2680      here.  */
2681   if (arg->n_aligned_regs != 0)
2682     reg = 0;
2683 #endif
2684   
2685   /* If this is being partially passed in a register, but multiple locations
2686      are specified, we assume that the one partially used is the one that is
2687      listed first.  */
2688   if (reg && GET_CODE (reg) == EXPR_LIST)
2689     reg = XEXP (reg, 0);
2690
2691   /* If this is being passed partially in a register, we can't evaluate
2692      it directly into its stack slot.  Otherwise, we can.  */
2693   if (arg->value == 0)
2694     {
2695 #ifdef ACCUMULATE_OUTGOING_ARGS
2696       /* stack_arg_under_construction is nonzero if a function argument is
2697          being evaluated directly into the outgoing argument list and
2698          expand_call must take special action to preserve the argument list
2699          if it is called recursively.
2700
2701          For scalar function arguments stack_usage_map is sufficient to
2702          determine which stack slots must be saved and restored.  Scalar
2703          arguments in general have pass_on_stack == 0.
2704
2705          If this argument is initialized by a function which takes the
2706          address of the argument (a C++ constructor or a C function
2707          returning a BLKmode structure), then stack_usage_map is
2708          insufficient and expand_call must push the stack around the
2709          function call.  Such arguments have pass_on_stack == 1.
2710
2711          Note that it is always safe to set stack_arg_under_construction,
2712          but this generates suboptimal code if set when not needed.  */
2713
2714       if (arg->pass_on_stack)
2715         stack_arg_under_construction++;
2716 #endif
2717       arg->value = expand_expr (pval, partial ? NULL_RTX : arg->stack,
2718                                 VOIDmode, 0);
2719
2720       /* If we are promoting object (or for any other reason) the mode
2721          doesn't agree, convert the mode.  */
2722
2723       if (GET_MODE (arg->value) != VOIDmode
2724           && GET_MODE (arg->value) != arg->mode)
2725         arg->value = convert_to_mode (arg->mode, arg->value, arg->unsignedp);
2726
2727 #ifdef ACCUMULATE_OUTGOING_ARGS
2728       if (arg->pass_on_stack)
2729         stack_arg_under_construction--;
2730 #endif
2731     }
2732
2733   /* Don't allow anything left on stack from computation
2734      of argument to alloca.  */
2735   if (may_be_alloca)
2736     do_pending_stack_adjust ();
2737
2738   if (arg->value == arg->stack)
2739     /* If the value is already in the stack slot, we are done.  */
2740     ;
2741   else if (arg->mode != BLKmode)
2742     {
2743       register int size;
2744
2745       /* Argument is a scalar, not entirely passed in registers.
2746          (If part is passed in registers, arg->partial says how much
2747          and emit_push_insn will take care of putting it there.)
2748          
2749          Push it, and if its size is less than the
2750          amount of space allocated to it,
2751          also bump stack pointer by the additional space.
2752          Note that in C the default argument promotions
2753          will prevent such mismatches.  */
2754
2755       size = GET_MODE_SIZE (arg->mode);
2756       /* Compute how much space the push instruction will push.
2757          On many machines, pushing a byte will advance the stack
2758          pointer by a halfword.  */
2759 #ifdef PUSH_ROUNDING
2760       size = PUSH_ROUNDING (size);
2761 #endif
2762       used = size;
2763
2764       /* Compute how much space the argument should get:
2765          round up to a multiple of the alignment for arguments.  */
2766       if (none != FUNCTION_ARG_PADDING (arg->mode, TREE_TYPE (pval)))
2767         used = (((size + PARM_BOUNDARY / BITS_PER_UNIT - 1)
2768                  / (PARM_BOUNDARY / BITS_PER_UNIT))
2769                 * (PARM_BOUNDARY / BITS_PER_UNIT));
2770
2771       /* This isn't already where we want it on the stack, so put it there.
2772          This can either be done with push or copy insns.  */
2773       emit_push_insn (arg->value, arg->mode, TREE_TYPE (pval), 0, 0, partial,
2774                       reg, used - size, argblock, ARGS_SIZE_RTX (arg->offset));
2775     }
2776   else
2777     {
2778       /* BLKmode, at least partly to be pushed.  */
2779
2780       register int excess;
2781       rtx size_rtx;
2782
2783       /* Pushing a nonscalar.
2784          If part is passed in registers, PARTIAL says how much
2785          and emit_push_insn will take care of putting it there.  */
2786
2787       /* Round its size up to a multiple
2788          of the allocation unit for arguments.  */
2789
2790       if (arg->size.var != 0)
2791         {
2792           excess = 0;
2793           size_rtx = ARGS_SIZE_RTX (arg->size);
2794         }
2795       else
2796         {
2797           /* PUSH_ROUNDING has no effect on us, because
2798              emit_push_insn for BLKmode is careful to avoid it.  */
2799           excess = (arg->size.constant - int_size_in_bytes (TREE_TYPE (pval))
2800                     + partial * UNITS_PER_WORD);
2801           size_rtx = expr_size (pval);
2802         }
2803
2804       emit_push_insn (arg->value, arg->mode, TREE_TYPE (pval), size_rtx,
2805                       TYPE_ALIGN (TREE_TYPE (pval)) / BITS_PER_UNIT, partial,
2806                       reg, excess, argblock, ARGS_SIZE_RTX (arg->offset));
2807     }
2808
2809
2810   /* Unless this is a partially-in-register argument, the argument is now
2811      in the stack. 
2812
2813      ??? Note that this can change arg->value from arg->stack to
2814      arg->stack_slot and it matters when they are not the same.
2815      It isn't totally clear that this is correct in all cases.  */
2816   if (partial == 0)
2817     arg->value = arg->stack_slot;
2818
2819   /* Once we have pushed something, pops can't safely
2820      be deferred during the rest of the arguments.  */
2821   NO_DEFER_POP;
2822
2823   /* ANSI doesn't require a sequence point here,
2824      but PCC has one, so this will avoid some problems.  */
2825   emit_queue ();
2826
2827   /* Free any temporary slots made in processing this argument.  */
2828   free_temp_slots ();
2829
2830 #ifdef ACCUMULATE_OUTGOING_ARGS
2831   /* Now mark the segment we just used.  */
2832   if (argblock && ! variable_size && arg->stack)
2833     for (i = lower_bound; i < upper_bound; i++)
2834       stack_usage_map[i] = 1;
2835 #endif
2836 }