OSDN Git Service

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