OSDN Git Service

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