1 /* Convert function calls to rtl insns, for GNU C compiler.
2 Copyright (C) 1989, 1992, 1993, 1994 Free Software Foundation, Inc.
4 This file is part of GNU CC.
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)
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.
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING. If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
30 #include "insn-flags.h"
32 /* Decide whether a function's arguments should be processed
33 from first to last or from last to first.
35 They should if the stack and args grow in opposite directions, but
36 only if we have push insns. */
40 #if defined (STACK_GROWS_DOWNWARD) != defined (ARGS_GROW_DOWNWARD)
41 #define PUSH_ARGS_REVERSED /* If it's last to first */
46 /* Like STACK_BOUNDARY but in units of bytes, not bits. */
47 #define STACK_BYTES (STACK_BOUNDARY / BITS_PER_UNIT)
49 /* Data structure and subroutines used within expand_call. */
53 /* Tree node for this argument. */
55 /* Mode for value; TYPE_MODE unless promoted. */
56 enum machine_mode mode;
57 /* Current RTL value for argument, or 0 if it isn't precomputed. */
59 /* Initially-compute RTL value for argument; only for const functions. */
61 /* Register to pass this argument in, 0 if passed on stack, or an
62 EXPR_LIST if the arg is to be copied into multiple different
65 /* If REG was promoted from the actual mode of the argument expression,
66 indicates whether the promotion is sign- or zero-extended. */
68 /* Number of registers to use. 0 means put the whole arg in registers.
69 Also 0 if not passed in registers. */
71 /* Non-zero if argument must be passed on stack.
72 Note that some arguments may be passed on the stack
73 even though pass_on_stack is zero, just because FUNCTION_ARG says so.
74 pass_on_stack identifies arguments that *cannot* go in registers. */
76 /* Offset of this argument from beginning of stack-args. */
77 struct args_size offset;
78 /* Similar, but offset to the start of the stack slot. Different from
79 OFFSET if this arg pads downward. */
80 struct args_size slot_offset;
81 /* Size of this argument on the stack, rounded up for any padding it gets,
82 parts of the argument passed in registers do not count.
83 If REG_PARM_STACK_SPACE is defined, then register parms
84 are counted here as well. */
85 struct args_size size;
86 /* Location on the stack at which parameter should be stored. The store
87 has already been done if STACK == VALUE. */
89 /* Location on the stack of the start of this argument slot. This can
90 differ from STACK if this arg pads downward. This location is known
91 to be aligned to FUNCTION_ARG_BOUNDARY. */
93 #ifdef ACCUMULATE_OUTGOING_ARGS
94 /* Place that this stack area has been saved, if needed. */
97 #ifdef STRICT_ALIGNMENT
98 /* If an argument's alignment does not permit direct copying into registers,
99 copy in smaller-sized pieces into pseudos. These are stored in a
100 block pointed to by this field. The next field says how many
101 word-sized pseudos we made. */
107 #ifdef ACCUMULATE_OUTGOING_ARGS
108 /* A vector of one char per byte of stack space. A byte if non-zero if
109 the corresponding stack location has been used.
110 This vector is used to prevent a function call within an argument from
111 clobbering any stack already set up. */
112 static char *stack_usage_map;
114 /* Size of STACK_USAGE_MAP. */
115 static int highest_outgoing_arg_in_use;
117 /* stack_arg_under_construction is nonzero when an argument may be
118 initialized with a constructor call (including a C function that
119 returns a BLKmode struct) and expand_call must take special action
120 to make sure the object being constructed does not overlap the
121 argument list for the constructor call. */
122 int stack_arg_under_construction;
125 static int calls_function PROTO((tree, int));
126 static int calls_function_1 PROTO((tree, int));
127 static void emit_call_1 PROTO((rtx, tree, int, int, rtx, rtx, int,
129 static void store_one_arg PROTO ((struct arg_data *, rtx, int, int,
132 /* If WHICH is 1, return 1 if EXP contains a call to the built-in function
135 If WHICH is 0, return 1 if EXP contains a call to any function.
136 Actually, we only need return 1 if evaluating EXP would require pushing
137 arguments on the stack, but that is too difficult to compute, so we just
138 assume any function call might require the stack. */
140 static tree calls_function_save_exprs;
143 calls_function (exp, which)
148 calls_function_save_exprs = 0;
149 val = calls_function_1 (exp, which);
150 calls_function_save_exprs = 0;
155 calls_function_1 (exp, which)
160 enum tree_code code = TREE_CODE (exp);
161 int type = TREE_CODE_CLASS (code);
162 int length = tree_code_length[(int) code];
164 /* If this code is langauge-specific, we don't know what it will do. */
165 if ((int) code >= NUM_TREE_CODES)
168 /* Only expressions and references can contain calls. */
169 if (type != 'e' && type != '<' && type != '1' && type != '2' && type != 'r'
178 else if (TREE_CODE (TREE_OPERAND (exp, 0)) == ADDR_EXPR
179 && (TREE_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0))
182 tree fndecl = TREE_OPERAND (TREE_OPERAND (exp, 0), 0);
184 if ((DECL_BUILT_IN (fndecl)
185 && DECL_FUNCTION_CODE (fndecl) == BUILT_IN_ALLOCA)
186 || (DECL_SAVED_INSNS (fndecl)
187 && (FUNCTION_FLAGS (DECL_SAVED_INSNS (fndecl))
188 & FUNCTION_FLAGS_CALLS_ALLOCA)))
192 /* Third operand is RTL. */
197 if (SAVE_EXPR_RTL (exp) != 0)
199 if (value_member (exp, calls_function_save_exprs))
201 calls_function_save_exprs = tree_cons (NULL_TREE, exp,
202 calls_function_save_exprs);
203 return (TREE_OPERAND (exp, 0) != 0
204 && calls_function_1 (TREE_OPERAND (exp, 0), which));
210 for (local = BLOCK_VARS (exp); local; local = TREE_CHAIN (local))
211 if (DECL_INITIAL (local) != 0
212 && calls_function_1 (DECL_INITIAL (local), which))
216 register tree subblock;
218 for (subblock = BLOCK_SUBBLOCKS (exp);
220 subblock = TREE_CHAIN (subblock))
221 if (calls_function_1 (subblock, which))
226 case METHOD_CALL_EXPR:
230 case WITH_CLEANUP_EXPR:
238 for (i = 0; i < length; i++)
239 if (TREE_OPERAND (exp, i) != 0
240 && calls_function_1 (TREE_OPERAND (exp, i), which))
246 /* Force FUNEXP into a form suitable for the address of a CALL,
247 and return that as an rtx. Also load the static chain register
248 if FNDECL is a nested function.
250 CALL_FUSAGE points to a variable holding the prospective
251 CALL_INSN_FUNCTION_USAGE information. */
254 prepare_call_address (funexp, fndecl, call_fusage, reg_parm_seen)
260 rtx static_chain_value = 0;
262 funexp = protect_from_queue (funexp, 0);
265 /* Get possible static chain value for nested function in C. */
266 static_chain_value = lookup_static_chain (fndecl);
268 /* Make a valid memory address and copy constants thru pseudo-regs,
269 but not for a constant address if -fno-function-cse. */
270 if (GET_CODE (funexp) != SYMBOL_REF)
272 #ifdef SMALL_REGISTER_CLASSES
273 /* If we are using registers for parameters, force the
274 function address into a register now. */
275 reg_parm_seen ? force_not_mem (memory_address (FUNCTION_MODE, funexp))
278 memory_address (FUNCTION_MODE, funexp);
281 #ifndef NO_FUNCTION_CSE
282 if (optimize && ! flag_no_function_cse)
283 #ifdef NO_RECURSIVE_FUNCTION_CSE
284 if (fndecl != current_function_decl)
286 funexp = force_reg (Pmode, funexp);
290 if (static_chain_value != 0)
292 emit_move_insn (static_chain_rtx, static_chain_value);
294 use_reg (call_fusage, static_chain_rtx);
300 /* Generate instructions to call function FUNEXP,
301 and optionally pop the results.
302 The CALL_INSN is the first insn generated.
304 FUNTYPE is the data type of the function, or, for a library call,
305 the identifier for the name of the call. This is given to the
306 macro RETURN_POPS_ARGS to determine whether this function pops its own args.
308 STACK_SIZE is the number of bytes of arguments on the stack,
309 rounded up to STACK_BOUNDARY; zero if the size is variable.
310 This is both to put into the call insn and
311 to generate explicit popping code if necessary.
313 STRUCT_VALUE_SIZE is the number of bytes wanted in a structure value.
314 It is zero if this call doesn't want a structure value.
316 NEXT_ARG_REG is the rtx that results from executing
317 FUNCTION_ARG (args_so_far, VOIDmode, void_type_node, 1)
318 just after all the args have had their registers assigned.
319 This could be whatever you like, but normally it is the first
320 arg-register beyond those used for args in this call,
321 or 0 if all the arg-registers are used in this call.
322 It is passed on to `gen_call' so you can put this info in the call insn.
324 VALREG is a hard register in which a value is returned,
325 or 0 if the call does not return a value.
327 OLD_INHIBIT_DEFER_POP is the value that `inhibit_defer_pop' had before
328 the args to this call were processed.
329 We restore `inhibit_defer_pop' to that value.
331 CALL_FUSAGE is either empty or an EXPR_LIST of USE expressions that
332 denote registers used by the called function.
334 IS_CONST is true if this is a `const' call. */
337 emit_call_1 (funexp, funtype, stack_size, struct_value_size, next_arg_reg,
338 valreg, old_inhibit_defer_pop, call_fusage, is_const)
342 int struct_value_size;
345 int old_inhibit_defer_pop;
349 rtx stack_size_rtx = GEN_INT (stack_size);
350 rtx struct_value_size_rtx = GEN_INT (struct_value_size);
352 int already_popped = 0;
354 /* Ensure address is valid. SYMBOL_REF is already valid, so no need,
355 and we don't want to load it into a register as an optimization,
356 because prepare_call_address already did it if it should be done. */
357 if (GET_CODE (funexp) != SYMBOL_REF)
358 funexp = memory_address (FUNCTION_MODE, funexp);
360 #ifndef ACCUMULATE_OUTGOING_ARGS
361 #if defined (HAVE_call_pop) && defined (HAVE_call_value_pop)
362 if (HAVE_call_pop && HAVE_call_value_pop
363 && (RETURN_POPS_ARGS (funtype, stack_size) > 0 || stack_size == 0))
365 rtx n_pop = GEN_INT (RETURN_POPS_ARGS (funtype, stack_size));
368 /* If this subroutine pops its own args, record that in the call insn
369 if possible, for the sake of frame pointer elimination. */
371 pat = gen_call_value_pop (valreg,
372 gen_rtx (MEM, FUNCTION_MODE, funexp),
373 stack_size_rtx, next_arg_reg, n_pop);
375 pat = gen_call_pop (gen_rtx (MEM, FUNCTION_MODE, funexp),
376 stack_size_rtx, next_arg_reg, n_pop);
378 emit_call_insn (pat);
385 #if defined (HAVE_call) && defined (HAVE_call_value)
386 if (HAVE_call && HAVE_call_value)
389 emit_call_insn (gen_call_value (valreg,
390 gen_rtx (MEM, FUNCTION_MODE, funexp),
391 stack_size_rtx, next_arg_reg,
394 emit_call_insn (gen_call (gen_rtx (MEM, FUNCTION_MODE, funexp),
395 stack_size_rtx, next_arg_reg,
396 struct_value_size_rtx));
402 /* Find the CALL insn we just emitted. */
403 for (call_insn = get_last_insn ();
404 call_insn && GET_CODE (call_insn) != CALL_INSN;
405 call_insn = PREV_INSN (call_insn))
411 /* Put the register usage information on the CALL. If there is already
412 some usage information, put ours at the end. */
413 if (CALL_INSN_FUNCTION_USAGE (call_insn))
417 for (link = CALL_INSN_FUNCTION_USAGE (call_insn); XEXP (link, 1) != 0;
418 link = XEXP (link, 1))
421 XEXP (link, 1) = call_fusage;
424 CALL_INSN_FUNCTION_USAGE (call_insn) = call_fusage;
426 /* If this is a const call, then set the insn's unchanging bit. */
428 CONST_CALL_P (call_insn) = 1;
430 /* Restore this now, so that we do defer pops for this call's args
431 if the context of the call as a whole permits. */
432 inhibit_defer_pop = old_inhibit_defer_pop;
434 #ifndef ACCUMULATE_OUTGOING_ARGS
435 /* If returning from the subroutine does not automatically pop the args,
436 we need an instruction to pop them sooner or later.
437 Perhaps do it now; perhaps just record how much space to pop later.
439 If returning from the subroutine does pop the args, indicate that the
440 stack pointer will be changed. */
442 if (stack_size != 0 && RETURN_POPS_ARGS (funtype, stack_size) > 0)
445 CALL_INSN_FUNCTION_USAGE (call_insn) =
446 gen_rtx (EXPR_LIST, CLOBBER, stack_pointer_rtx,
447 CALL_INSN_FUNCTION_USAGE (call_insn));
448 stack_size -= RETURN_POPS_ARGS (funtype, stack_size);
449 stack_size_rtx = GEN_INT (stack_size);
454 if (flag_defer_pop && inhibit_defer_pop == 0 && !is_const)
455 pending_stack_adjust += stack_size;
457 adjust_stack (stack_size_rtx);
462 /* Generate all the code for a function call
463 and return an rtx for its value.
464 Store the value in TARGET (specified as an rtx) if convenient.
465 If the value is stored in TARGET then TARGET is returned.
466 If IGNORE is nonzero, then we ignore the value of the function call. */
469 expand_call (exp, target, ignore)
474 /* List of actual parameters. */
475 tree actparms = TREE_OPERAND (exp, 1);
476 /* RTX for the function to be called. */
478 /* Tree node for the function to be called (not the address!). */
480 /* Data type of the function. */
482 /* Declaration of the function being called,
483 or 0 if the function is computed (not known by name). */
487 /* Register in which non-BLKmode value will be returned,
488 or 0 if no value or if value is BLKmode. */
490 /* Address where we should return a BLKmode value;
491 0 if value not BLKmode. */
492 rtx structure_value_addr = 0;
493 /* Nonzero if that address is being passed by treating it as
494 an extra, implicit first parameter. Otherwise,
495 it is passed by being copied directly into struct_value_rtx. */
496 int structure_value_addr_parm = 0;
497 /* Size of aggregate value wanted, or zero if none wanted
498 or if we are using the non-reentrant PCC calling convention
499 or expecting the value in registers. */
500 int struct_value_size = 0;
501 /* Nonzero if called function returns an aggregate in memory PCC style,
502 by returning the address of where to find it. */
503 int pcc_struct_value = 0;
505 /* Number of actual parameters in this call, including struct value addr. */
507 /* Number of named args. Args after this are anonymous ones
508 and they must all go on the stack. */
510 /* Count arg position in order args appear. */
513 /* Vector of information about each argument.
514 Arguments are numbered in the order they will be pushed,
515 not the order they are written. */
516 struct arg_data *args;
518 /* Total size in bytes of all the stack-parms scanned so far. */
519 struct args_size args_size;
520 /* Size of arguments before any adjustments (such as rounding). */
521 struct args_size original_args_size;
522 /* Data on reg parms scanned so far. */
523 CUMULATIVE_ARGS args_so_far;
524 /* Nonzero if a reg parm has been scanned. */
526 /* Nonzero if this is an indirect function call. */
527 int current_call_is_indirect = 0;
529 /* Nonzero if we must avoid push-insns in the args for this call.
530 If stack space is allocated for register parameters, but not by the
531 caller, then it is preallocated in the fixed part of the stack frame.
532 So the entire argument block must then be preallocated (i.e., we
533 ignore PUSH_ROUNDING in that case). */
535 #if defined(REG_PARM_STACK_SPACE) && ! defined(OUTGOING_REG_PARM_STACK_SPACE)
536 int must_preallocate = 1;
539 int must_preallocate = 0;
541 int must_preallocate = 1;
545 /* Size of the stack reserved for parameter registers. */
546 int reg_parm_stack_space = 0;
548 /* 1 if scanning parms front to back, -1 if scanning back to front. */
550 /* Address of space preallocated for stack parms
551 (on machines that lack push insns), or 0 if space not preallocated. */
554 /* Nonzero if it is plausible that this is a call to alloca. */
556 /* Nonzero if this is a call to setjmp or a related function. */
558 /* Nonzero if this is a call to `longjmp'. */
560 /* Nonzero if this is a call to an inline function. */
561 int is_integrable = 0;
562 /* Nonzero if this is a call to a `const' function.
563 Note that only explicitly named functions are handled as `const' here. */
565 /* Nonzero if this is a call to a `volatile' function. */
567 #if defined(ACCUMULATE_OUTGOING_ARGS) && defined(REG_PARM_STACK_SPACE)
568 /* Define the boundary of the register parm stack space that needs to be
570 int low_to_save = -1, high_to_save;
571 rtx save_area = 0; /* Place that it is saved */
574 #ifdef ACCUMULATE_OUTGOING_ARGS
575 int initial_highest_arg_in_use = highest_outgoing_arg_in_use;
576 char *initial_stack_usage_map = stack_usage_map;
579 rtx old_stack_level = 0;
580 int old_pending_adj = 0;
581 int old_stack_arg_under_construction;
582 int old_inhibit_defer_pop = inhibit_defer_pop;
583 tree old_cleanups = cleanups_this_call;
588 /* See if we can find a DECL-node for the actual function.
589 As a result, decide whether this is a call to an integrable function. */
591 p = TREE_OPERAND (exp, 0);
592 if (TREE_CODE (p) == ADDR_EXPR)
594 fndecl = TREE_OPERAND (p, 0);
595 if (TREE_CODE (fndecl) != FUNCTION_DECL)
600 && fndecl != current_function_decl
601 && DECL_SAVED_INSNS (fndecl))
603 else if (! TREE_ADDRESSABLE (fndecl))
605 /* In case this function later becomes inlinable,
606 record that there was already a non-inline call to it.
608 Use abstraction instead of setting TREE_ADDRESSABLE
610 if (DECL_INLINE (fndecl) && warn_inline && !flag_no_inline)
611 warning_with_decl (fndecl, "can't inline call to `%s'");
612 mark_addressable (fndecl);
615 if (TREE_READONLY (fndecl) && ! TREE_THIS_VOLATILE (fndecl)
616 && TYPE_MODE (TREE_TYPE (exp)) != VOIDmode)
619 if (TREE_THIS_VOLATILE (fndecl))
624 /* If we don't have specific function to call, see if we have a
625 constant or `noreturn' function from the type. */
628 is_const = TREE_READONLY (TREE_TYPE (TREE_TYPE (p)));
629 is_volatile = TREE_THIS_VOLATILE (TREE_TYPE (TREE_TYPE (p)));
632 #ifdef REG_PARM_STACK_SPACE
633 #ifdef MAYBE_REG_PARM_STACK_SPACE
634 reg_parm_stack_space = MAYBE_REG_PARM_STACK_SPACE;
636 reg_parm_stack_space = REG_PARM_STACK_SPACE (fndecl);
640 /* Warn if this value is an aggregate type,
641 regardless of which calling convention we are using for it. */
642 if (warn_aggregate_return && AGGREGATE_TYPE_P (TREE_TYPE (exp)))
643 warning ("function call has aggregate value");
645 /* Set up a place to return a structure. */
647 /* Cater to broken compilers. */
648 if (aggregate_value_p (exp))
650 /* This call returns a big structure. */
653 #ifdef PCC_STATIC_STRUCT_RETURN
655 pcc_struct_value = 1;
656 /* Easier than making that case work right. */
659 /* In case this is a static function, note that it has been
661 if (! TREE_ADDRESSABLE (fndecl))
662 mark_addressable (fndecl);
666 #else /* not PCC_STATIC_STRUCT_RETURN */
668 struct_value_size = int_size_in_bytes (TREE_TYPE (exp));
670 if (target && GET_CODE (target) == MEM)
671 structure_value_addr = XEXP (target, 0);
674 /* Assign a temporary on the stack to hold the value. */
676 /* For variable-sized objects, we must be called with a target
677 specified. If we were to allocate space on the stack here,
678 we would have no way of knowing when to free it. */
680 if (struct_value_size < 0)
684 = XEXP (assign_stack_temp (BLKmode, struct_value_size, 1), 0);
688 #endif /* not PCC_STATIC_STRUCT_RETURN */
691 /* If called function is inline, try to integrate it. */
696 rtx before_call = get_last_insn ();
698 temp = expand_inline_function (fndecl, actparms, target,
699 ignore, TREE_TYPE (exp),
700 structure_value_addr);
702 /* If inlining succeeded, return. */
703 if ((HOST_WIDE_INT) temp != -1)
705 if (flag_short_temps)
707 /* Perform all cleanups needed for the arguments of this
708 call (i.e. destructors in C++). It is ok if these
709 destructors clobber RETURN_VALUE_REG, because the
710 only time we care about this is when TARGET is that
711 register. But in C++, we take care to never return
712 that register directly. */
713 expand_cleanups_to (old_cleanups);
716 #ifdef ACCUMULATE_OUTGOING_ARGS
717 /* If the outgoing argument list must be preserved, push
718 the stack before executing the inlined function if it
721 for (i = reg_parm_stack_space - 1; i >= 0; i--)
722 if (i < highest_outgoing_arg_in_use && stack_usage_map[i] != 0)
725 if (stack_arg_under_construction || i >= 0)
727 rtx insn = NEXT_INSN (before_call), seq;
729 /* Look for a call in the inline function code.
730 If OUTGOING_ARGS_SIZE (DECL_SAVED_INSNS (fndecl)) is
731 nonzero then there is a call and it is not necessary
732 to scan the insns. */
734 if (OUTGOING_ARGS_SIZE (DECL_SAVED_INSNS (fndecl)) == 0)
735 for (; insn; insn = NEXT_INSN (insn))
736 if (GET_CODE (insn) == CALL_INSN)
741 /* Reserve enough stack space so that the largest
742 argument list of any function call in the inline
743 function does not overlap the argument list being
744 evaluated. This is usually an overestimate because
745 allocate_dynamic_stack_space reserves space for an
746 outgoing argument list in addition to the requested
747 space, but there is no way to ask for stack space such
748 that an argument list of a certain length can be
749 safely constructed. */
751 int adjust = OUTGOING_ARGS_SIZE (DECL_SAVED_INSNS (fndecl));
752 #ifdef REG_PARM_STACK_SPACE
753 /* Add the stack space reserved for register arguments
754 in the inline function. What is really needed is the
755 largest value of reg_parm_stack_space in the inline
756 function, but that is not available. Using the current
757 value of reg_parm_stack_space is wrong, but gives
758 correct results on all supported machines. */
759 adjust += reg_parm_stack_space;
762 emit_stack_save (SAVE_BLOCK, &old_stack_level, NULL_RTX);
763 allocate_dynamic_stack_space (GEN_INT (adjust),
764 NULL_RTX, BITS_PER_UNIT);
767 emit_insns_before (seq, NEXT_INSN (before_call));
768 emit_stack_restore (SAVE_BLOCK, old_stack_level, NULL_RTX);
773 /* If the result is equivalent to TARGET, return TARGET to simplify
774 checks in store_expr. They can be equivalent but not equal in the
775 case of a function that returns BLKmode. */
776 if (temp != target && rtx_equal_p (temp, target))
781 /* If inlining failed, mark FNDECL as needing to be compiled
782 separately after all. If function was declared inline,
784 if (DECL_INLINE (fndecl) && warn_inline && !flag_no_inline
785 && ! TREE_ADDRESSABLE (fndecl))
786 warning_with_decl (fndecl, "can't inline call to `%s'");
787 mark_addressable (fndecl);
790 /* When calling a const function, we must pop the stack args right away,
791 so that the pop is deleted or moved with the call. */
795 function_call_count++;
797 if (fndecl && DECL_NAME (fndecl))
798 name = IDENTIFIER_POINTER (DECL_NAME (fndecl));
800 /* On some machines (such as the PA) indirect calls have a different
801 calling convention than normal calls. FUNCTION_ARG in the target
802 description can look at current_call_is_indirect to determine which
803 calling convention to use. */
804 current_call_is_indirect = (fndecl == 0);
806 = TREE_CODE (TREE_OPERAND (exp, 0)) == NON_LVALUE_EXPR ? 1 : 0;
810 /* Unless it's a call to a specific function that isn't alloca,
811 if it has one argument, we must assume it might be alloca. */
814 (!(fndecl != 0 && strcmp (name, "alloca"))
816 && TREE_CHAIN (actparms) == 0);
818 /* We assume that alloca will always be called by name. It
819 makes no sense to pass it as a pointer-to-function to
820 anything that does not understand its behavior. */
822 (name && ((IDENTIFIER_LENGTH (DECL_NAME (fndecl)) == 6
824 && ! strcmp (name, "alloca"))
825 || (IDENTIFIER_LENGTH (DECL_NAME (fndecl)) == 16
827 && ! strcmp (name, "__builtin_alloca"))));
830 /* See if this is a call to a function that can return more than once
831 or a call to longjmp. */
836 if (name != 0 && IDENTIFIER_LENGTH (DECL_NAME (fndecl)) <= 15)
840 /* Disregard prefix _, __ or __x. */
843 if (name[1] == '_' && name[2] == 'x')
845 else if (name[1] == '_')
855 && (! strcmp (tname, "setjmp")
856 || ! strcmp (tname, "setjmp_syscall")))
858 && ! strcmp (tname, "sigsetjmp"))
860 && ! strcmp (tname, "savectx")));
862 && ! strcmp (tname, "siglongjmp"))
865 else if ((tname[0] == 'q' && tname[1] == 's'
866 && ! strcmp (tname, "qsetjmp"))
867 || (tname[0] == 'v' && tname[1] == 'f'
868 && ! strcmp (tname, "vfork")))
871 else if (tname[0] == 'l' && tname[1] == 'o'
872 && ! strcmp (tname, "longjmp"))
877 current_function_calls_alloca = 1;
879 /* Don't let pending stack adjusts add up to too much.
880 Also, do all pending adjustments now
881 if there is any chance this might be a call to alloca. */
883 if (pending_stack_adjust >= 32
884 || (pending_stack_adjust > 0 && may_be_alloca))
885 do_pending_stack_adjust ();
887 /* Operand 0 is a pointer-to-function; get the type of the function. */
888 funtype = TREE_TYPE (TREE_OPERAND (exp, 0));
889 if (TREE_CODE (funtype) != POINTER_TYPE)
891 funtype = TREE_TYPE (funtype);
893 /* Push the temporary stack slot level so that we can free any temporaries
897 /* Start updating where the next arg would go. */
898 INIT_CUMULATIVE_ARGS (args_so_far, funtype, NULL_RTX);
900 /* If struct_value_rtx is 0, it means pass the address
901 as if it were an extra parameter. */
902 if (structure_value_addr && struct_value_rtx == 0)
904 /* If structure_value_addr is a REG other than
905 virtual_outgoing_args_rtx, we can use always use it. If it
906 is not a REG, we must always copy it into a register.
907 If it is virtual_outgoing_args_rtx, we must copy it to another
908 register in some cases. */
909 rtx temp = (GET_CODE (structure_value_addr) != REG
910 #ifdef ACCUMULATE_OUTGOING_ARGS
911 || (stack_arg_under_construction
912 && structure_value_addr == virtual_outgoing_args_rtx)
914 ? copy_addr_to_reg (structure_value_addr)
915 : structure_value_addr);
918 = tree_cons (error_mark_node,
919 make_tree (build_pointer_type (TREE_TYPE (funtype)),
922 structure_value_addr_parm = 1;
925 /* Count the arguments and set NUM_ACTUALS. */
926 for (p = actparms, i = 0; p; p = TREE_CHAIN (p)) i++;
929 /* Compute number of named args.
930 Normally, don't include the last named arg if anonymous args follow.
931 (If no anonymous args follow, the result of list_length
932 is actually one too large.)
934 If SETUP_INCOMING_VARARGS is defined, this machine will be able to
935 place unnamed args that were passed in registers into the stack. So
936 treat all args as named. This allows the insns emitting for a specific
937 argument list to be independent of the function declaration.
939 If SETUP_INCOMING_VARARGS is not defined, we do not have any reliable
940 way to pass unnamed args in registers, so we must force them into
942 #ifndef SETUP_INCOMING_VARARGS
943 if (TYPE_ARG_TYPES (funtype) != 0)
945 = list_length (TYPE_ARG_TYPES (funtype)) - 1
946 /* Count the struct value address, if it is passed as a parm. */
947 + structure_value_addr_parm;
950 /* If we know nothing, treat all args as named. */
951 n_named_args = num_actuals;
953 /* Make a vector to hold all the information about each arg. */
954 args = (struct arg_data *) alloca (num_actuals * sizeof (struct arg_data));
955 bzero ((char *) args, num_actuals * sizeof (struct arg_data));
957 args_size.constant = 0;
960 /* In this loop, we consider args in the order they are written.
961 We fill up ARGS from the front of from the back if necessary
962 so that in any case the first arg to be pushed ends up at the front. */
964 #ifdef PUSH_ARGS_REVERSED
965 i = num_actuals - 1, inc = -1;
966 /* In this case, must reverse order of args
967 so that we compute and push the last arg first. */
972 /* I counts args in order (to be) pushed; ARGPOS counts in order written. */
973 for (p = actparms, argpos = 0; p; p = TREE_CHAIN (p), i += inc, argpos++)
975 tree type = TREE_TYPE (TREE_VALUE (p));
977 enum machine_mode mode;
979 args[i].tree_value = TREE_VALUE (p);
981 /* Replace erroneous argument with constant zero. */
982 if (type == error_mark_node || TYPE_SIZE (type) == 0)
983 args[i].tree_value = integer_zero_node, type = integer_type_node;
985 /* If TYPE is a transparent union, pass things the way we would
986 pass the first field of the union. We have already verified that
987 the modes are the same. */
988 if (TYPE_TRANSPARENT_UNION (type))
989 type = TREE_TYPE (TYPE_FIELDS (type));
991 /* Decide where to pass this arg.
993 args[i].reg is nonzero if all or part is passed in registers.
995 args[i].partial is nonzero if part but not all is passed in registers,
996 and the exact value says how many words are passed in registers.
998 args[i].pass_on_stack is nonzero if the argument must at least be
999 computed on the stack. It may then be loaded back into registers
1000 if args[i].reg is nonzero.
1002 These decisions are driven by the FUNCTION_... macros and must agree
1003 with those made by function.c. */
1005 /* See if this argument should be passed by invisible reference. */
1006 if ((TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST
1007 && contains_placeholder_p (TYPE_SIZE (type)))
1008 || TYPE_NEEDS_CONSTRUCTING (type)
1009 #ifdef FUNCTION_ARG_PASS_BY_REFERENCE
1010 || FUNCTION_ARG_PASS_BY_REFERENCE (args_so_far, TYPE_MODE (type),
1011 type, argpos < n_named_args)
1015 #ifdef FUNCTION_ARG_CALLEE_COPIES
1016 if (FUNCTION_ARG_CALLEE_COPIES (args_so_far, TYPE_MODE (type), type,
1017 argpos < n_named_args)
1018 /* If it's in a register, we must make a copy of it too. */
1019 /* ??? Is this a sufficient test? Is there a better one? */
1020 && !(TREE_CODE (args[i].tree_value) == VAR_DECL
1021 && REG_P (DECL_RTL (args[i].tree_value))))
1023 args[i].tree_value = build1 (ADDR_EXPR,
1024 build_pointer_type (type),
1025 args[i].tree_value);
1026 type = build_pointer_type (type);
1031 /* We make a copy of the object and pass the address to the
1032 function being called. */
1035 if (TYPE_SIZE (type) == 0
1036 || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
1038 /* This is a variable-sized object. Make space on the stack
1040 rtx size_rtx = expr_size (TREE_VALUE (p));
1042 if (old_stack_level == 0)
1044 emit_stack_save (SAVE_BLOCK, &old_stack_level, NULL_RTX);
1045 old_pending_adj = pending_stack_adjust;
1046 pending_stack_adjust = 0;
1049 copy = gen_rtx (MEM, BLKmode,
1050 allocate_dynamic_stack_space (size_rtx,
1052 TYPE_ALIGN (type)));
1056 int size = int_size_in_bytes (type);
1057 copy = assign_stack_temp (TYPE_MODE (type), size, 1);
1060 MEM_IN_STRUCT_P (copy) = AGGREGATE_TYPE_P (type);
1062 store_expr (args[i].tree_value, copy, 0);
1064 args[i].tree_value = build1 (ADDR_EXPR,
1065 build_pointer_type (type),
1066 make_tree (type, copy));
1067 type = build_pointer_type (type);
1071 mode = TYPE_MODE (type);
1072 unsignedp = TREE_UNSIGNED (type);
1074 #ifdef PROMOTE_FUNCTION_ARGS
1075 mode = promote_mode (type, mode, &unsignedp, 1);
1078 args[i].unsignedp = unsignedp;
1079 args[i].mode = mode;
1080 args[i].reg = FUNCTION_ARG (args_so_far, mode, type,
1081 argpos < n_named_args);
1082 #ifdef FUNCTION_ARG_PARTIAL_NREGS
1085 = FUNCTION_ARG_PARTIAL_NREGS (args_so_far, mode, type,
1086 argpos < n_named_args);
1089 args[i].pass_on_stack = MUST_PASS_IN_STACK (mode, type);
1091 /* If FUNCTION_ARG returned an (expr_list (nil) FOO), it means that
1092 we are to pass this arg in the register(s) designated by FOO, but
1093 also to pass it in the stack. */
1094 if (args[i].reg && GET_CODE (args[i].reg) == EXPR_LIST
1095 && XEXP (args[i].reg, 0) == 0)
1096 args[i].pass_on_stack = 1, args[i].reg = XEXP (args[i].reg, 1);
1098 /* If this is an addressable type, we must preallocate the stack
1099 since we must evaluate the object into its final location.
1101 If this is to be passed in both registers and the stack, it is simpler
1103 if (TREE_ADDRESSABLE (type)
1104 || (args[i].pass_on_stack && args[i].reg != 0))
1105 must_preallocate = 1;
1107 /* If this is an addressable type, we cannot pre-evaluate it. Thus,
1108 we cannot consider this function call constant. */
1109 if (TREE_ADDRESSABLE (type))
1112 /* Compute the stack-size of this argument. */
1113 if (args[i].reg == 0 || args[i].partial != 0
1114 #ifdef REG_PARM_STACK_SPACE
1115 || reg_parm_stack_space > 0
1117 || args[i].pass_on_stack)
1118 locate_and_pad_parm (mode, type,
1119 #ifdef STACK_PARMS_IN_REG_PARM_AREA
1124 fndecl, &args_size, &args[i].offset,
1127 #ifndef ARGS_GROW_DOWNWARD
1128 args[i].slot_offset = args_size;
1131 #ifndef REG_PARM_STACK_SPACE
1132 /* If a part of the arg was put into registers,
1133 don't include that part in the amount pushed. */
1134 if (! args[i].pass_on_stack)
1135 args[i].size.constant -= ((args[i].partial * UNITS_PER_WORD)
1136 / (PARM_BOUNDARY / BITS_PER_UNIT)
1137 * (PARM_BOUNDARY / BITS_PER_UNIT));
1140 /* Update ARGS_SIZE, the total stack space for args so far. */
1142 args_size.constant += args[i].size.constant;
1143 if (args[i].size.var)
1145 ADD_PARM_SIZE (args_size, args[i].size.var);
1148 /* Since the slot offset points to the bottom of the slot,
1149 we must record it after incrementing if the args grow down. */
1150 #ifdef ARGS_GROW_DOWNWARD
1151 args[i].slot_offset = args_size;
1153 args[i].slot_offset.constant = -args_size.constant;
1156 SUB_PARM_SIZE (args[i].slot_offset, args_size.var);
1160 /* Increment ARGS_SO_FAR, which has info about which arg-registers
1161 have been used, etc. */
1163 FUNCTION_ARG_ADVANCE (args_so_far, TYPE_MODE (type), type,
1164 argpos < n_named_args);
1167 #ifdef FINAL_REG_PARM_STACK_SPACE
1168 reg_parm_stack_space = FINAL_REG_PARM_STACK_SPACE (args_size.constant,
1172 /* Compute the actual size of the argument block required. The variable
1173 and constant sizes must be combined, the size may have to be rounded,
1174 and there may be a minimum required size. */
1176 original_args_size = args_size;
1179 /* If this function requires a variable-sized argument list, don't try to
1180 make a cse'able block for this call. We may be able to do this
1181 eventually, but it is too complicated to keep track of what insns go
1182 in the cse'able block and which don't. */
1185 must_preallocate = 1;
1187 args_size.var = ARGS_SIZE_TREE (args_size);
1188 args_size.constant = 0;
1190 #ifdef STACK_BOUNDARY
1191 if (STACK_BOUNDARY != BITS_PER_UNIT)
1192 args_size.var = round_up (args_size.var, STACK_BYTES);
1195 #ifdef REG_PARM_STACK_SPACE
1196 if (reg_parm_stack_space > 0)
1199 = size_binop (MAX_EXPR, args_size.var,
1200 size_int (REG_PARM_STACK_SPACE (fndecl)));
1202 #ifndef OUTGOING_REG_PARM_STACK_SPACE
1203 /* The area corresponding to register parameters is not to count in
1204 the size of the block we need. So make the adjustment. */
1206 = size_binop (MINUS_EXPR, args_size.var,
1207 size_int (reg_parm_stack_space));
1214 #ifdef STACK_BOUNDARY
1215 args_size.constant = (((args_size.constant + (STACK_BYTES - 1))
1216 / STACK_BYTES) * STACK_BYTES);
1219 #ifdef REG_PARM_STACK_SPACE
1220 args_size.constant = MAX (args_size.constant,
1221 reg_parm_stack_space);
1222 #ifdef MAYBE_REG_PARM_STACK_SPACE
1223 if (reg_parm_stack_space == 0)
1224 args_size.constant = 0;
1226 #ifndef OUTGOING_REG_PARM_STACK_SPACE
1227 args_size.constant -= reg_parm_stack_space;
1232 /* See if we have or want to preallocate stack space.
1234 If we would have to push a partially-in-regs parm
1235 before other stack parms, preallocate stack space instead.
1237 If the size of some parm is not a multiple of the required stack
1238 alignment, we must preallocate.
1240 If the total size of arguments that would otherwise create a copy in
1241 a temporary (such as a CALL) is more than half the total argument list
1242 size, preallocation is faster.
1244 Another reason to preallocate is if we have a machine (like the m88k)
1245 where stack alignment is required to be maintained between every
1246 pair of insns, not just when the call is made. However, we assume here
1247 that such machines either do not have push insns (and hence preallocation
1248 would occur anyway) or the problem is taken care of with
1251 if (! must_preallocate)
1253 int partial_seen = 0;
1254 int copy_to_evaluate_size = 0;
1256 for (i = 0; i < num_actuals && ! must_preallocate; i++)
1258 if (args[i].partial > 0 && ! args[i].pass_on_stack)
1260 else if (partial_seen && args[i].reg == 0)
1261 must_preallocate = 1;
1263 if (TYPE_MODE (TREE_TYPE (args[i].tree_value)) == BLKmode
1264 && (TREE_CODE (args[i].tree_value) == CALL_EXPR
1265 || TREE_CODE (args[i].tree_value) == TARGET_EXPR
1266 || TREE_CODE (args[i].tree_value) == COND_EXPR
1267 || TREE_ADDRESSABLE (TREE_TYPE (args[i].tree_value))))
1268 copy_to_evaluate_size
1269 += int_size_in_bytes (TREE_TYPE (args[i].tree_value));
1272 if (copy_to_evaluate_size * 2 >= args_size.constant
1273 && args_size.constant > 0)
1274 must_preallocate = 1;
1277 /* If the structure value address will reference the stack pointer, we must
1278 stabilize it. We don't need to do this if we know that we are not going
1279 to adjust the stack pointer in processing this call. */
1281 if (structure_value_addr
1282 && (reg_mentioned_p (virtual_stack_dynamic_rtx, structure_value_addr)
1283 || reg_mentioned_p (virtual_outgoing_args_rtx, structure_value_addr))
1285 #ifndef ACCUMULATE_OUTGOING_ARGS
1286 || args_size.constant
1289 structure_value_addr = copy_to_reg (structure_value_addr);
1291 /* If this function call is cse'able, precompute all the parameters.
1292 Note that if the parameter is constructed into a temporary, this will
1293 cause an additional copy because the parameter will be constructed
1294 into a temporary location and then copied into the outgoing arguments.
1295 If a parameter contains a call to alloca and this function uses the
1296 stack, precompute the parameter. */
1298 /* If we preallocated the stack space, and some arguments must be passed
1299 on the stack, then we must precompute any parameter which contains a
1300 function call which will store arguments on the stack.
1301 Otherwise, evaluating the parameter may clobber previous parameters
1302 which have already been stored into the stack. */
1304 for (i = 0; i < num_actuals; i++)
1306 || ((args_size.var != 0 || args_size.constant != 0)
1307 && calls_function (args[i].tree_value, 1))
1308 || (must_preallocate && (args_size.var != 0 || args_size.constant != 0)
1309 && calls_function (args[i].tree_value, 0)))
1313 args[i].initial_value = args[i].value
1314 = expand_expr (args[i].tree_value, NULL_RTX, VOIDmode, 0);
1316 if (TYPE_MODE (TREE_TYPE (args[i].tree_value)) != args[i].mode)
1318 = convert_modes (args[i].mode,
1319 TYPE_MODE (TREE_TYPE (args[i].tree_value)),
1320 args[i].value, args[i].unsignedp);
1322 preserve_temp_slots (args[i].value);
1325 /* ANSI doesn't require a sequence point here,
1326 but PCC has one, so this will avoid some problems. */
1330 /* Now we are about to start emitting insns that can be deleted
1331 if a libcall is deleted. */
1335 /* If we have no actual push instructions, or shouldn't use them,
1336 make space for all args right now. */
1338 if (args_size.var != 0)
1340 if (old_stack_level == 0)
1342 emit_stack_save (SAVE_BLOCK, &old_stack_level, NULL_RTX);
1343 old_pending_adj = pending_stack_adjust;
1344 pending_stack_adjust = 0;
1345 #ifdef ACCUMULATE_OUTGOING_ARGS
1346 /* stack_arg_under_construction says whether a stack arg is
1347 being constructed at the old stack level. Pushing the stack
1348 gets a clean outgoing argument block. */
1349 old_stack_arg_under_construction = stack_arg_under_construction;
1350 stack_arg_under_construction = 0;
1353 argblock = push_block (ARGS_SIZE_RTX (args_size), 0, 0);
1355 else if (must_preallocate)
1357 /* Note that we must go through the motions of allocating an argument
1358 block even if the size is zero because we may be storing args
1359 in the area reserved for register arguments, which may be part of
1361 int needed = args_size.constant;
1363 #ifdef ACCUMULATE_OUTGOING_ARGS
1364 /* Store the maximum argument space used. It will be pushed by the
1367 Since the stack pointer will never be pushed, it is possible for
1368 the evaluation of a parm to clobber something we have already
1369 written to the stack. Since most function calls on RISC machines
1370 do not use the stack, this is uncommon, but must work correctly.
1372 Therefore, we save any area of the stack that was already written
1373 and that we are using. Here we set up to do this by making a new
1374 stack usage map from the old one. The actual save will be done
1377 Another approach might be to try to reorder the argument
1378 evaluations to avoid this conflicting stack usage. */
1380 if (needed > current_function_outgoing_args_size)
1381 current_function_outgoing_args_size = needed;
1383 #if defined(REG_PARM_STACK_SPACE) && ! defined(OUTGOING_REG_PARM_STACK_SPACE)
1384 /* Since we will be writing into the entire argument area, the
1385 map must be allocated for its entire size, not just the part that
1386 is the responsibility of the caller. */
1387 needed += reg_parm_stack_space;
1390 #ifdef ARGS_GROW_DOWNWARD
1391 highest_outgoing_arg_in_use = MAX (initial_highest_arg_in_use,
1394 highest_outgoing_arg_in_use = MAX (initial_highest_arg_in_use, needed);
1396 stack_usage_map = (char *) alloca (highest_outgoing_arg_in_use);
1398 if (initial_highest_arg_in_use)
1399 bcopy (initial_stack_usage_map, stack_usage_map,
1400 initial_highest_arg_in_use);
1402 if (initial_highest_arg_in_use != highest_outgoing_arg_in_use)
1403 bzero (&stack_usage_map[initial_highest_arg_in_use],
1404 highest_outgoing_arg_in_use - initial_highest_arg_in_use);
1407 /* The address of the outgoing argument list must not be copied to a
1408 register here, because argblock would be left pointing to the
1409 wrong place after the call to allocate_dynamic_stack_space below. */
1411 argblock = virtual_outgoing_args_rtx;
1413 #else /* not ACCUMULATE_OUTGOING_ARGS */
1414 if (inhibit_defer_pop == 0)
1416 /* Try to reuse some or all of the pending_stack_adjust
1417 to get this space. Maybe we can avoid any pushing. */
1418 if (needed > pending_stack_adjust)
1420 needed -= pending_stack_adjust;
1421 pending_stack_adjust = 0;
1425 pending_stack_adjust -= needed;
1429 /* Special case this because overhead of `push_block' in this
1430 case is non-trivial. */
1432 argblock = virtual_outgoing_args_rtx;
1434 argblock = push_block (GEN_INT (needed), 0, 0);
1436 /* We only really need to call `copy_to_reg' in the case where push
1437 insns are going to be used to pass ARGBLOCK to a function
1438 call in ARGS. In that case, the stack pointer changes value
1439 from the allocation point to the call point, and hence
1440 the value of VIRTUAL_OUTGOING_ARGS_RTX changes as well.
1441 But might as well always do it. */
1442 argblock = copy_to_reg (argblock);
1443 #endif /* not ACCUMULATE_OUTGOING_ARGS */
1447 #ifdef ACCUMULATE_OUTGOING_ARGS
1448 /* The save/restore code in store_one_arg handles all cases except one:
1449 a constructor call (including a C function returning a BLKmode struct)
1450 to initialize an argument. */
1451 if (stack_arg_under_construction)
1453 #if defined(REG_PARM_STACK_SPACE) && ! defined(OUTGOING_REG_PARM_STACK_SPACE)
1454 rtx push_size = GEN_INT (reg_parm_stack_space + args_size.constant);
1456 rtx push_size = GEN_INT (args_size.constant);
1458 if (old_stack_level == 0)
1460 emit_stack_save (SAVE_BLOCK, &old_stack_level, NULL_RTX);
1461 old_pending_adj = pending_stack_adjust;
1462 pending_stack_adjust = 0;
1463 /* stack_arg_under_construction says whether a stack arg is
1464 being constructed at the old stack level. Pushing the stack
1465 gets a clean outgoing argument block. */
1466 old_stack_arg_under_construction = stack_arg_under_construction;
1467 stack_arg_under_construction = 0;
1468 /* Make a new map for the new argument list. */
1469 stack_usage_map = (char *)alloca (highest_outgoing_arg_in_use);
1470 bzero (stack_usage_map, highest_outgoing_arg_in_use);
1471 highest_outgoing_arg_in_use = 0;
1473 allocate_dynamic_stack_space (push_size, NULL_RTX, BITS_PER_UNIT);
1475 /* If argument evaluation might modify the stack pointer, copy the
1476 address of the argument list to a register. */
1477 for (i = 0; i < num_actuals; i++)
1478 if (args[i].pass_on_stack)
1480 argblock = copy_addr_to_reg (argblock);
1486 /* If we preallocated stack space, compute the address of each argument.
1487 We need not ensure it is a valid memory address here; it will be
1488 validized when it is used. */
1491 rtx arg_reg = argblock;
1494 if (GET_CODE (argblock) == PLUS)
1495 arg_reg = XEXP (argblock, 0), arg_offset = INTVAL (XEXP (argblock, 1));
1497 for (i = 0; i < num_actuals; i++)
1499 rtx offset = ARGS_SIZE_RTX (args[i].offset);
1500 rtx slot_offset = ARGS_SIZE_RTX (args[i].slot_offset);
1503 /* Skip this parm if it will not be passed on the stack. */
1504 if (! args[i].pass_on_stack && args[i].reg != 0)
1507 if (GET_CODE (offset) == CONST_INT)
1508 addr = plus_constant (arg_reg, INTVAL (offset));
1510 addr = gen_rtx (PLUS, Pmode, arg_reg, offset);
1512 addr = plus_constant (addr, arg_offset);
1513 args[i].stack = gen_rtx (MEM, args[i].mode, addr);
1514 MEM_IN_STRUCT_P (args[i].stack)
1515 = AGGREGATE_TYPE_P (TREE_TYPE (args[i].tree_value));
1517 if (GET_CODE (slot_offset) == CONST_INT)
1518 addr = plus_constant (arg_reg, INTVAL (slot_offset));
1520 addr = gen_rtx (PLUS, Pmode, arg_reg, slot_offset);
1522 addr = plus_constant (addr, arg_offset);
1523 args[i].stack_slot = gen_rtx (MEM, args[i].mode, addr);
1527 #ifdef PUSH_ARGS_REVERSED
1528 #ifdef STACK_BOUNDARY
1529 /* If we push args individually in reverse order, perform stack alignment
1530 before the first push (the last arg). */
1532 anti_adjust_stack (GEN_INT (args_size.constant
1533 - original_args_size.constant));
1537 /* Don't try to defer pops if preallocating, not even from the first arg,
1538 since ARGBLOCK probably refers to the SP. */
1542 /* Get the function to call, in the form of RTL. */
1545 /* If this is the first use of the function, see if we need to
1546 make an external definition for it. */
1547 if (! TREE_USED (fndecl))
1549 assemble_external (fndecl);
1550 TREE_USED (fndecl) = 1;
1553 /* Get a SYMBOL_REF rtx for the function address. */
1554 funexp = XEXP (DECL_RTL (fndecl), 0);
1557 /* Generate an rtx (probably a pseudo-register) for the address. */
1560 funexp = expand_expr (TREE_OPERAND (exp, 0), NULL_RTX, VOIDmode, 0);
1561 pop_temp_slots (); /* FUNEXP can't be BLKmode */
1565 /* Figure out the register where the value, if any, will come back. */
1567 if (TYPE_MODE (TREE_TYPE (exp)) != VOIDmode
1568 && ! structure_value_addr)
1570 if (pcc_struct_value)
1571 valreg = hard_function_value (build_pointer_type (TREE_TYPE (exp)),
1574 valreg = hard_function_value (TREE_TYPE (exp), fndecl);
1577 /* Precompute all register parameters. It isn't safe to compute anything
1578 once we have started filling any specific hard regs. */
1580 for (i = 0; i < num_actuals; i++)
1581 if (args[i].reg != 0 && ! args[i].pass_on_stack)
1585 if (args[i].value == 0)
1588 args[i].value = expand_expr (args[i].tree_value, NULL_RTX,
1590 preserve_temp_slots (args[i].value);
1593 /* ANSI doesn't require a sequence point here,
1594 but PCC has one, so this will avoid some problems. */
1598 /* If we are to promote the function arg to a wider mode,
1601 if (args[i].mode != TYPE_MODE (TREE_TYPE (args[i].tree_value)))
1603 = convert_modes (args[i].mode,
1604 TYPE_MODE (TREE_TYPE (args[i].tree_value)),
1605 args[i].value, args[i].unsignedp);
1607 /* If the value is expensive, and we are inside an appropriately
1608 short loop, put the value into a pseudo and then put the pseudo
1611 For small register classes, also do this if this call uses
1612 register parameters. This is to avoid reload conflicts while
1613 loading the parameters registers. */
1615 if ((! (GET_CODE (args[i].value) == REG
1616 || (GET_CODE (args[i].value) == SUBREG
1617 && GET_CODE (SUBREG_REG (args[i].value)) == REG)))
1618 && args[i].mode != BLKmode
1619 && rtx_cost (args[i].value, SET) > 2
1620 #ifdef SMALL_REGISTER_CLASSES
1621 && (reg_parm_seen || preserve_subexpressions_p ()))
1623 && preserve_subexpressions_p ())
1625 args[i].value = copy_to_mode_reg (args[i].mode, args[i].value);
1628 #if defined(ACCUMULATE_OUTGOING_ARGS) && defined(REG_PARM_STACK_SPACE)
1629 /* The argument list is the property of the called routine and it
1630 may clobber it. If the fixed area has been used for previous
1631 parameters, we must save and restore it.
1633 Here we compute the boundary of the that needs to be saved, if any. */
1635 #ifdef ARGS_GROW_DOWNWARD
1636 for (i = 0; i < reg_parm_stack_space + 1; i++)
1638 for (i = 0; i < reg_parm_stack_space; i++)
1641 if (i >= highest_outgoing_arg_in_use
1642 || stack_usage_map[i] == 0)
1645 if (low_to_save == -1)
1651 if (low_to_save >= 0)
1653 int num_to_save = high_to_save - low_to_save + 1;
1654 enum machine_mode save_mode
1655 = mode_for_size (num_to_save * BITS_PER_UNIT, MODE_INT, 1);
1658 /* If we don't have the required alignment, must do this in BLKmode. */
1659 if ((low_to_save & (MIN (GET_MODE_SIZE (save_mode),
1660 BIGGEST_ALIGNMENT / UNITS_PER_WORD) - 1)))
1661 save_mode = BLKmode;
1663 stack_area = gen_rtx (MEM, save_mode,
1664 memory_address (save_mode,
1666 #ifdef ARGS_GROW_DOWNWARD
1667 plus_constant (argblock,
1670 plus_constant (argblock,
1674 if (save_mode == BLKmode)
1676 save_area = assign_stack_temp (BLKmode, num_to_save, 1);
1677 emit_block_move (validize_mem (save_area), stack_area,
1678 GEN_INT (num_to_save),
1679 PARM_BOUNDARY / BITS_PER_UNIT);
1683 save_area = gen_reg_rtx (save_mode);
1684 emit_move_insn (save_area, stack_area);
1690 /* Now store (and compute if necessary) all non-register parms.
1691 These come before register parms, since they can require block-moves,
1692 which could clobber the registers used for register parms.
1693 Parms which have partial registers are not stored here,
1694 but we do preallocate space here if they want that. */
1696 for (i = 0; i < num_actuals; i++)
1697 if (args[i].reg == 0 || args[i].pass_on_stack)
1698 store_one_arg (&args[i], argblock, may_be_alloca,
1699 args_size.var != 0, fndecl, reg_parm_stack_space);
1701 #ifdef STRICT_ALIGNMENT
1702 /* If we have a parm that is passed in registers but not in memory
1703 and whose alignment does not permit a direct copy into registers,
1704 make a group of pseudos that correspond to each register that we
1707 for (i = 0; i < num_actuals; i++)
1708 if (args[i].reg != 0 && ! args[i].pass_on_stack
1709 && args[i].mode == BLKmode
1710 && (TYPE_ALIGN (TREE_TYPE (args[i].tree_value))
1711 < MIN (BIGGEST_ALIGNMENT, BITS_PER_WORD)))
1713 int bytes = int_size_in_bytes (TREE_TYPE (args[i].tree_value));
1714 int big_endian_correction = 0;
1716 args[i].n_aligned_regs
1717 = args[i].partial ? args[i].partial
1718 : (bytes + (UNITS_PER_WORD - 1)) / UNITS_PER_WORD;
1720 args[i].aligned_regs = (rtx *) alloca (sizeof (rtx)
1721 * args[i].n_aligned_regs);
1723 /* Structures smaller than a word are aligned to the least signifcant
1724 byte (to the right). On a BYTES_BIG_ENDIAN machine, this means we
1725 must skip the empty high order bytes when calculating the bit
1727 if (BYTES_BIG_ENDIAN && bytes < UNITS_PER_WORD)
1728 big_endian_correction = (BITS_PER_WORD - (bytes * BITS_PER_UNIT));
1730 for (j = 0; j < args[i].n_aligned_regs; j++)
1732 rtx reg = gen_reg_rtx (word_mode);
1733 rtx word = operand_subword_force (args[i].value, j, BLKmode);
1734 int bitsize = TYPE_ALIGN (TREE_TYPE (args[i].tree_value));
1737 args[i].aligned_regs[j] = reg;
1739 /* Clobber REG and move each partword into it. Ensure we don't
1740 go past the end of the structure. Note that the loop below
1741 works because we've already verified that padding
1742 and endianness are compatible. */
1744 emit_insn (gen_rtx (CLOBBER, VOIDmode, reg));
1747 bitpos < BITS_PER_WORD && bytes > 0;
1748 bitpos += bitsize, bytes -= bitsize / BITS_PER_UNIT)
1750 int xbitpos = bitpos + big_endian_correction;
1752 store_bit_field (reg, bitsize, xbitpos, word_mode,
1753 extract_bit_field (word, bitsize, bitpos, 1,
1754 NULL_RTX, word_mode,
1756 bitsize / BITS_PER_UNIT,
1758 bitsize / BITS_PER_UNIT, BITS_PER_WORD);
1764 /* Now store any partially-in-registers parm.
1765 This is the last place a block-move can happen. */
1767 for (i = 0; i < num_actuals; i++)
1768 if (args[i].partial != 0 && ! args[i].pass_on_stack)
1769 store_one_arg (&args[i], argblock, may_be_alloca,
1770 args_size.var != 0, fndecl, reg_parm_stack_space);
1772 #ifndef PUSH_ARGS_REVERSED
1773 #ifdef STACK_BOUNDARY
1774 /* If we pushed args in forward order, perform stack alignment
1775 after pushing the last arg. */
1777 anti_adjust_stack (GEN_INT (args_size.constant
1778 - original_args_size.constant));
1782 /* If register arguments require space on the stack and stack space
1783 was not preallocated, allocate stack space here for arguments
1784 passed in registers. */
1785 #if ! defined(ACCUMULATE_OUTGOING_ARGS) && defined(OUTGOING_REG_PARM_STACK_SPACE)
1786 if (must_preallocate == 0 && reg_parm_stack_space > 0)
1787 anti_adjust_stack (GEN_INT (reg_parm_stack_space));
1790 /* Pass the function the address in which to return a structure value. */
1791 if (structure_value_addr && ! structure_value_addr_parm)
1793 emit_move_insn (struct_value_rtx,
1795 force_operand (structure_value_addr,
1797 if (GET_CODE (struct_value_rtx) == REG)
1798 use_reg (&call_fusage, struct_value_rtx);
1801 funexp = prepare_call_address (funexp, fndecl, &call_fusage, reg_parm_seen);
1803 /* Now do the register loads required for any wholly-register parms or any
1804 parms which are passed both on the stack and in a register. Their
1805 expressions were already evaluated.
1807 Mark all register-parms as living through the call, putting these USE
1808 insns in the CALL_INSN_FUNCTION_USAGE field. */
1810 for (i = 0; i < num_actuals; i++)
1812 rtx list = args[i].reg;
1813 int partial = args[i].partial;
1820 /* Process each register that needs to get this arg. */
1821 if (GET_CODE (list) == EXPR_LIST)
1822 reg = XEXP (list, 0), list = XEXP (list, 1);
1824 reg = list, list = 0;
1826 /* Set to non-negative if must move a word at a time, even if just
1827 one word (e.g, partial == 1 && mode == DFmode). Set to -1 if
1828 we just use a normal move insn. This value can be zero if the
1829 argument is a zero size structure with no fields. */
1830 nregs = (partial ? partial
1831 : (TYPE_MODE (TREE_TYPE (args[i].tree_value)) == BLKmode
1832 ? ((int_size_in_bytes (TREE_TYPE (args[i].tree_value))
1833 + (UNITS_PER_WORD - 1)) / UNITS_PER_WORD)
1836 /* If simple case, just do move. If normal partial, store_one_arg
1837 has already loaded the register for us. In all other cases,
1838 load the register(s) from memory. */
1841 emit_move_insn (reg, args[i].value);
1843 #ifdef STRICT_ALIGNMENT
1844 /* If we have pre-computed the values to put in the registers in
1845 the case of non-aligned structures, copy them in now. */
1847 else if (args[i].n_aligned_regs != 0)
1848 for (j = 0; j < args[i].n_aligned_regs; j++)
1849 emit_move_insn (gen_rtx (REG, word_mode, REGNO (reg) + j),
1850 args[i].aligned_regs[j]);
1853 else if (args[i].partial == 0 || args[i].pass_on_stack)
1854 move_block_to_reg (REGNO (reg),
1855 validize_mem (args[i].value), nregs,
1859 use_reg (&call_fusage, reg);
1861 use_regs (&call_fusage, REGNO (reg), nregs == 0 ? 1 : nregs);
1863 /* PARTIAL referred only to the first register, so clear it for the
1869 /* Perform postincrements before actually calling the function. */
1872 /* All arguments and registers used for the call must be set up by now! */
1874 /* Generate the actual call instruction. */
1875 emit_call_1 (funexp, funtype, args_size.constant, struct_value_size,
1876 FUNCTION_ARG (args_so_far, VOIDmode, void_type_node, 1),
1877 valreg, old_inhibit_defer_pop, call_fusage, is_const);
1879 /* If call is cse'able, make appropriate pair of reg-notes around it.
1880 Test valreg so we don't crash; may safely ignore `const'
1881 if return type is void. */
1882 if (is_const && valreg != 0)
1885 rtx temp = gen_reg_rtx (GET_MODE (valreg));
1888 /* Construct an "equal form" for the value which mentions all the
1889 arguments in order as well as the function name. */
1890 #ifdef PUSH_ARGS_REVERSED
1891 for (i = 0; i < num_actuals; i++)
1892 note = gen_rtx (EXPR_LIST, VOIDmode, args[i].initial_value, note);
1894 for (i = num_actuals - 1; i >= 0; i--)
1895 note = gen_rtx (EXPR_LIST, VOIDmode, args[i].initial_value, note);
1897 note = gen_rtx (EXPR_LIST, VOIDmode, funexp, note);
1899 insns = get_insns ();
1902 emit_libcall_block (insns, temp, valreg, note);
1907 /* For calls to `setjmp', etc., inform flow.c it should complain
1908 if nonvolatile values are live. */
1912 emit_note (name, NOTE_INSN_SETJMP);
1913 current_function_calls_setjmp = 1;
1917 current_function_calls_longjmp = 1;
1919 /* Notice functions that cannot return.
1920 If optimizing, insns emitted below will be dead.
1921 If not optimizing, they will exist, which is useful
1922 if the user uses the `return' command in the debugger. */
1924 if (is_volatile || is_longjmp)
1927 /* If value type not void, return an rtx for the value. */
1929 /* If there are cleanups to be called, don't use a hard reg as target. */
1930 if (cleanups_this_call != old_cleanups
1931 && target && REG_P (target)
1932 && REGNO (target) < FIRST_PSEUDO_REGISTER)
1935 if (TYPE_MODE (TREE_TYPE (exp)) == VOIDmode
1938 target = const0_rtx;
1940 else if (structure_value_addr)
1942 if (target == 0 || GET_CODE (target) != MEM)
1944 target = gen_rtx (MEM, TYPE_MODE (TREE_TYPE (exp)),
1945 memory_address (TYPE_MODE (TREE_TYPE (exp)),
1946 structure_value_addr));
1947 MEM_IN_STRUCT_P (target) = AGGREGATE_TYPE_P (TREE_TYPE (exp));
1950 else if (pcc_struct_value)
1954 /* We used leave the value in the location that it is
1955 returned in, but that causes problems if it is used more
1956 than once in one expression. Rather than trying to track
1957 when a copy is required, we always copy when TARGET is
1958 not specified. This calling sequence is only used on
1959 a few machines and TARGET is usually nonzero. */
1960 if (TYPE_MODE (TREE_TYPE (exp)) == BLKmode)
1962 target = assign_stack_temp (BLKmode,
1963 int_size_in_bytes (TREE_TYPE (exp)),
1966 MEM_IN_STRUCT_P (target) = AGGREGATE_TYPE_P (TREE_TYPE (exp));
1968 /* Save this temp slot around the pop below. */
1969 preserve_temp_slots (target);
1972 target = gen_reg_rtx (TYPE_MODE (TREE_TYPE (exp)));
1975 if (TYPE_MODE (TREE_TYPE (exp)) != BLKmode)
1976 emit_move_insn (target, gen_rtx (MEM, TYPE_MODE (TREE_TYPE (exp)),
1977 copy_to_reg (valreg)));
1979 emit_block_move (target, gen_rtx (MEM, BLKmode, copy_to_reg (valreg)),
1981 TYPE_ALIGN (TREE_TYPE (exp)) / BITS_PER_UNIT);
1983 else if (target && GET_MODE (target) == TYPE_MODE (TREE_TYPE (exp))
1984 && GET_MODE (target) == GET_MODE (valreg))
1985 /* TARGET and VALREG cannot be equal at this point because the latter
1986 would not have REG_FUNCTION_VALUE_P true, while the former would if
1987 it were referring to the same register.
1989 If they refer to the same register, this move will be a no-op, except
1990 when function inlining is being done. */
1991 emit_move_insn (target, valreg);
1993 target = copy_to_reg (valreg);
1995 #ifdef PROMOTE_FUNCTION_RETURN
1996 /* If we promoted this return value, make the proper SUBREG. TARGET
1997 might be const0_rtx here, so be careful. */
1998 if (GET_CODE (target) == REG
1999 && GET_MODE (target) != TYPE_MODE (TREE_TYPE (exp)))
2001 tree type = TREE_TYPE (exp);
2002 int unsignedp = TREE_UNSIGNED (type);
2004 /* If we don't promote as expected, something is wrong. */
2005 if (GET_MODE (target)
2006 != promote_mode (type, TYPE_MODE (type), &unsignedp, 1))
2009 target = gen_rtx (SUBREG, TYPE_MODE (type), target, 0);
2010 SUBREG_PROMOTED_VAR_P (target) = 1;
2011 SUBREG_PROMOTED_UNSIGNED_P (target) = unsignedp;
2015 if (flag_short_temps)
2017 /* Perform all cleanups needed for the arguments of this call
2018 (i.e. destructors in C++). */
2019 expand_cleanups_to (old_cleanups);
2022 /* If size of args is variable or this was a constructor call for a stack
2023 argument, restore saved stack-pointer value. */
2025 if (old_stack_level)
2027 emit_stack_restore (SAVE_BLOCK, old_stack_level, NULL_RTX);
2028 pending_stack_adjust = old_pending_adj;
2029 #ifdef ACCUMULATE_OUTGOING_ARGS
2030 stack_arg_under_construction = old_stack_arg_under_construction;
2031 highest_outgoing_arg_in_use = initial_highest_arg_in_use;
2032 stack_usage_map = initial_stack_usage_map;
2035 #ifdef ACCUMULATE_OUTGOING_ARGS
2038 #ifdef REG_PARM_STACK_SPACE
2041 enum machine_mode save_mode = GET_MODE (save_area);
2043 = gen_rtx (MEM, save_mode,
2044 memory_address (save_mode,
2045 #ifdef ARGS_GROW_DOWNWARD
2046 plus_constant (argblock, - high_to_save)
2048 plus_constant (argblock, low_to_save)
2052 if (save_mode != BLKmode)
2053 emit_move_insn (stack_area, save_area);
2055 emit_block_move (stack_area, validize_mem (save_area),
2056 GEN_INT (high_to_save - low_to_save + 1),
2057 PARM_BOUNDARY / BITS_PER_UNIT);
2061 /* If we saved any argument areas, restore them. */
2062 for (i = 0; i < num_actuals; i++)
2063 if (args[i].save_area)
2065 enum machine_mode save_mode = GET_MODE (args[i].save_area);
2067 = gen_rtx (MEM, save_mode,
2068 memory_address (save_mode,
2069 XEXP (args[i].stack_slot, 0)));
2071 if (save_mode != BLKmode)
2072 emit_move_insn (stack_area, args[i].save_area);
2074 emit_block_move (stack_area, validize_mem (args[i].save_area),
2075 GEN_INT (args[i].size.constant),
2076 PARM_BOUNDARY / BITS_PER_UNIT);
2079 highest_outgoing_arg_in_use = initial_highest_arg_in_use;
2080 stack_usage_map = initial_stack_usage_map;
2084 /* If this was alloca, record the new stack level for nonlocal gotos.
2085 Check for the handler slots since we might not have a save area
2086 for non-local gotos. */
2088 if (may_be_alloca && nonlocal_goto_handler_slot != 0)
2089 emit_stack_save (SAVE_NONLOCAL, &nonlocal_goto_stack_level, NULL_RTX);
2096 /* Output a library call to function FUN (a SYMBOL_REF rtx)
2097 (emitting the queue unless NO_QUEUE is nonzero),
2098 for a value of mode OUTMODE,
2099 with NARGS different arguments, passed as alternating rtx values
2100 and machine_modes to convert them to.
2101 The rtx values should have been passed through protect_from_queue already.
2103 NO_QUEUE will be true if and only if the library call is a `const' call
2104 which will be enclosed in REG_LIBCALL/REG_RETVAL notes; it is equivalent
2105 to the variable is_const in expand_call.
2107 NO_QUEUE must be true for const calls, because if it isn't, then
2108 any pending increment will be emitted between REG_LIBCALL/REG_RETVAL notes,
2109 and will be lost if the libcall sequence is optimized away.
2111 NO_QUEUE must be false for non-const calls, because if it isn't, the
2112 call insn will have its CONST_CALL_P bit set, and it will be incorrectly
2113 optimized. For instance, the instruction scheduler may incorrectly
2114 move memory references across the non-const call. */
2117 emit_library_call VPROTO((rtx orgfun, int no_queue, enum machine_mode outmode,
2123 enum machine_mode outmode;
2127 /* Total size in bytes of all the stack-parms scanned so far. */
2128 struct args_size args_size;
2129 /* Size of arguments before any adjustments (such as rounding). */
2130 struct args_size original_args_size;
2131 register int argnum;
2136 CUMULATIVE_ARGS args_so_far;
2137 struct arg { rtx value; enum machine_mode mode; rtx reg; int partial;
2138 struct args_size offset; struct args_size size; };
2140 int old_inhibit_defer_pop = inhibit_defer_pop;
2141 rtx call_fusage = 0;
2142 /* library calls are never indirect calls. */
2143 int current_call_is_indirect = 0;
2145 VA_START (p, nargs);
2148 orgfun = va_arg (p, rtx);
2149 no_queue = va_arg (p, int);
2150 outmode = va_arg (p, enum machine_mode);
2151 nargs = va_arg (p, int);
2156 /* Copy all the libcall-arguments out of the varargs data
2157 and into a vector ARGVEC.
2159 Compute how to pass each argument. We only support a very small subset
2160 of the full argument passing conventions to limit complexity here since
2161 library functions shouldn't have many args. */
2163 argvec = (struct arg *) alloca (nargs * sizeof (struct arg));
2165 INIT_CUMULATIVE_ARGS (args_so_far, NULL_TREE, fun);
2167 args_size.constant = 0;
2172 for (count = 0; count < nargs; count++)
2174 rtx val = va_arg (p, rtx);
2175 enum machine_mode mode = va_arg (p, enum machine_mode);
2177 /* We cannot convert the arg value to the mode the library wants here;
2178 must do it earlier where we know the signedness of the arg. */
2180 || (GET_MODE (val) != mode && GET_MODE (val) != VOIDmode))
2183 /* On some machines, there's no way to pass a float to a library fcn.
2184 Pass it as a double instead. */
2185 #ifdef LIBGCC_NEEDS_DOUBLE
2186 if (LIBGCC_NEEDS_DOUBLE && mode == SFmode)
2187 val = convert_modes (DFmode, SFmode, val, 0), mode = DFmode;
2190 /* There's no need to call protect_from_queue, because
2191 either emit_move_insn or emit_push_insn will do that. */
2193 /* Make sure it is a reasonable operand for a move or push insn. */
2194 if (GET_CODE (val) != REG && GET_CODE (val) != MEM
2195 && ! (CONSTANT_P (val) && LEGITIMATE_CONSTANT_P (val)))
2196 val = force_operand (val, NULL_RTX);
2198 #ifdef FUNCTION_ARG_PASS_BY_REFERENCE
2199 if (FUNCTION_ARG_PASS_BY_REFERENCE (args_so_far, mode, NULL_TREE, 1))
2201 /* We do not support FUNCTION_ARG_CALLEE_COPIES here since it can
2202 be viewed as just an efficiency improvement. */
2203 rtx slot = assign_stack_temp (mode, GET_MODE_SIZE (mode), 0);
2204 emit_move_insn (slot, val);
2205 val = XEXP (slot, 0);
2210 argvec[count].value = val;
2211 argvec[count].mode = mode;
2213 argvec[count].reg = FUNCTION_ARG (args_so_far, mode, NULL_TREE, 1);
2214 if (argvec[count].reg && GET_CODE (argvec[count].reg) == EXPR_LIST)
2216 #ifdef FUNCTION_ARG_PARTIAL_NREGS
2217 argvec[count].partial
2218 = FUNCTION_ARG_PARTIAL_NREGS (args_so_far, mode, NULL_TREE, 1);
2220 argvec[count].partial = 0;
2223 locate_and_pad_parm (mode, NULL_TREE,
2224 argvec[count].reg && argvec[count].partial == 0,
2225 NULL_TREE, &args_size, &argvec[count].offset,
2226 &argvec[count].size);
2228 if (argvec[count].size.var)
2231 #ifndef REG_PARM_STACK_SPACE
2232 if (argvec[count].partial)
2233 argvec[count].size.constant -= argvec[count].partial * UNITS_PER_WORD;
2236 if (argvec[count].reg == 0 || argvec[count].partial != 0
2237 #ifdef REG_PARM_STACK_SPACE
2241 args_size.constant += argvec[count].size.constant;
2243 #ifdef ACCUMULATE_OUTGOING_ARGS
2244 /* If this arg is actually passed on the stack, it might be
2245 clobbering something we already put there (this library call might
2246 be inside the evaluation of an argument to a function whose call
2247 requires the stack). This will only occur when the library call
2248 has sufficient args to run out of argument registers. Abort in
2249 this case; if this ever occurs, code must be added to save and
2250 restore the arg slot. */
2252 if (argvec[count].reg == 0 || argvec[count].partial != 0)
2256 FUNCTION_ARG_ADVANCE (args_so_far, mode, (tree)0, 1);
2260 /* If this machine requires an external definition for library
2261 functions, write one out. */
2262 assemble_external_libcall (fun);
2264 original_args_size = args_size;
2265 #ifdef STACK_BOUNDARY
2266 args_size.constant = (((args_size.constant + (STACK_BYTES - 1))
2267 / STACK_BYTES) * STACK_BYTES);
2270 #ifdef REG_PARM_STACK_SPACE
2271 args_size.constant = MAX (args_size.constant,
2272 REG_PARM_STACK_SPACE (NULL_TREE));
2273 #ifndef OUTGOING_REG_PARM_STACK_SPACE
2274 args_size.constant -= REG_PARM_STACK_SPACE (NULL_TREE);
2278 #ifdef ACCUMULATE_OUTGOING_ARGS
2279 if (args_size.constant > current_function_outgoing_args_size)
2280 current_function_outgoing_args_size = args_size.constant;
2281 args_size.constant = 0;
2284 #ifndef PUSH_ROUNDING
2285 argblock = push_block (GEN_INT (args_size.constant), 0, 0);
2288 #ifdef PUSH_ARGS_REVERSED
2289 #ifdef STACK_BOUNDARY
2290 /* If we push args individually in reverse order, perform stack alignment
2291 before the first push (the last arg). */
2293 anti_adjust_stack (GEN_INT (args_size.constant
2294 - original_args_size.constant));
2298 #ifdef PUSH_ARGS_REVERSED
2306 /* Push the args that need to be pushed. */
2308 for (count = 0; count < nargs; count++, argnum += inc)
2310 register enum machine_mode mode = argvec[argnum].mode;
2311 register rtx val = argvec[argnum].value;
2312 rtx reg = argvec[argnum].reg;
2313 int partial = argvec[argnum].partial;
2315 if (! (reg != 0 && partial == 0))
2316 emit_push_insn (val, mode, NULL_TREE, NULL_RTX, 0, partial, reg, 0,
2317 argblock, GEN_INT (argvec[count].offset.constant));
2321 #ifndef PUSH_ARGS_REVERSED
2322 #ifdef STACK_BOUNDARY
2323 /* If we pushed args in forward order, perform stack alignment
2324 after pushing the last arg. */
2326 anti_adjust_stack (GEN_INT (args_size.constant
2327 - original_args_size.constant));
2331 #ifdef PUSH_ARGS_REVERSED
2337 fun = prepare_call_address (fun, NULL_TREE, &call_fusage, 0);
2339 /* Now load any reg parms into their regs. */
2341 for (count = 0; count < nargs; count++, argnum += inc)
2343 register enum machine_mode mode = argvec[argnum].mode;
2344 register rtx val = argvec[argnum].value;
2345 rtx reg = argvec[argnum].reg;
2346 int partial = argvec[argnum].partial;
2348 if (reg != 0 && partial == 0)
2349 emit_move_insn (reg, val);
2353 /* For version 1.37, try deleting this entirely. */
2357 /* Any regs containing parms remain in use through the call. */
2358 for (count = 0; count < nargs; count++)
2359 if (argvec[count].reg != 0)
2360 use_reg (&call_fusage, argvec[count].reg);
2362 /* Don't allow popping to be deferred, since then
2363 cse'ing of library calls could delete a call and leave the pop. */
2366 /* We pass the old value of inhibit_defer_pop + 1 to emit_call_1, which
2367 will set inhibit_defer_pop to that value. */
2369 emit_call_1 (fun, get_identifier (XSTR (orgfun, 0)), args_size.constant, 0,
2370 FUNCTION_ARG (args_so_far, VOIDmode, void_type_node, 1),
2371 outmode != VOIDmode ? hard_libcall_value (outmode) : NULL_RTX,
2372 old_inhibit_defer_pop + 1, call_fusage, no_queue);
2376 /* Now restore inhibit_defer_pop to its actual original value. */
2380 /* Like emit_library_call except that an extra argument, VALUE,
2381 comes second and says where to store the result.
2382 (If VALUE is zero, this function chooses a convenient way
2383 to return the value.
2385 This function returns an rtx for where the value is to be found.
2386 If VALUE is nonzero, VALUE is returned. */
2389 emit_library_call_value VPROTO((rtx orgfun, rtx value, int no_queue,
2390 enum machine_mode outmode, int nargs, ...))
2396 enum machine_mode outmode;
2400 /* Total size in bytes of all the stack-parms scanned so far. */
2401 struct args_size args_size;
2402 /* Size of arguments before any adjustments (such as rounding). */
2403 struct args_size original_args_size;
2404 register int argnum;
2409 CUMULATIVE_ARGS args_so_far;
2410 struct arg { rtx value; enum machine_mode mode; rtx reg; int partial;
2411 struct args_size offset; struct args_size size; };
2413 int old_inhibit_defer_pop = inhibit_defer_pop;
2414 rtx call_fusage = 0;
2416 int pcc_struct_value = 0;
2417 int struct_value_size = 0;
2418 /* library calls are never indirect calls. */
2419 int current_call_is_indirect = 0;
2422 VA_START (p, nargs);
2425 orgfun = va_arg (p, rtx);
2426 value = va_arg (p, rtx);
2427 no_queue = va_arg (p, int);
2428 outmode = va_arg (p, enum machine_mode);
2429 nargs = va_arg (p, int);
2432 is_const = no_queue;
2435 /* If this kind of value comes back in memory,
2436 decide where in memory it should come back. */
2437 if (aggregate_value_p (type_for_mode (outmode, 0)))
2439 #ifdef PCC_STATIC_STRUCT_RETURN
2441 = hard_function_value (build_pointer_type (type_for_mode (outmode, 0)),
2443 mem_value = gen_rtx (MEM, outmode, pointer_reg);
2444 pcc_struct_value = 1;
2446 value = gen_reg_rtx (outmode);
2447 #else /* not PCC_STATIC_STRUCT_RETURN */
2448 struct_value_size = GET_MODE_SIZE (outmode);
2449 if (value != 0 && GET_CODE (value) == MEM)
2452 mem_value = assign_stack_temp (outmode, GET_MODE_SIZE (outmode), 0);
2455 /* This call returns a big structure. */
2459 /* ??? Unfinished: must pass the memory address as an argument. */
2461 /* Copy all the libcall-arguments out of the varargs data
2462 and into a vector ARGVEC.
2464 Compute how to pass each argument. We only support a very small subset
2465 of the full argument passing conventions to limit complexity here since
2466 library functions shouldn't have many args. */
2468 argvec = (struct arg *) alloca ((nargs + 1) * sizeof (struct arg));
2470 INIT_CUMULATIVE_ARGS (args_so_far, NULL_TREE, fun);
2472 args_size.constant = 0;
2479 /* If there's a structure value address to be passed,
2480 either pass it in the special place, or pass it as an extra argument. */
2481 if (mem_value && struct_value_rtx == 0 && ! pcc_struct_value)
2483 rtx addr = XEXP (mem_value, 0);
2486 /* Make sure it is a reasonable operand for a move or push insn. */
2487 if (GET_CODE (addr) != REG && GET_CODE (addr) != MEM
2488 && ! (CONSTANT_P (addr) && LEGITIMATE_CONSTANT_P (addr)))
2489 addr = force_operand (addr, NULL_RTX);
2491 argvec[count].value = addr;
2492 argvec[count].mode = Pmode;
2493 argvec[count].partial = 0;
2495 argvec[count].reg = FUNCTION_ARG (args_so_far, Pmode, NULL_TREE, 1);
2496 #ifdef FUNCTION_ARG_PARTIAL_NREGS
2497 if (FUNCTION_ARG_PARTIAL_NREGS (args_so_far, Pmode, NULL_TREE, 1))
2501 locate_and_pad_parm (Pmode, NULL_TREE,
2502 argvec[count].reg && argvec[count].partial == 0,
2503 NULL_TREE, &args_size, &argvec[count].offset,
2504 &argvec[count].size);
2507 if (argvec[count].reg == 0 || argvec[count].partial != 0
2508 #ifdef REG_PARM_STACK_SPACE
2512 args_size.constant += argvec[count].size.constant;
2514 FUNCTION_ARG_ADVANCE (args_so_far, Pmode, (tree)0, 1);
2519 for (; count < nargs; count++)
2521 rtx val = va_arg (p, rtx);
2522 enum machine_mode mode = va_arg (p, enum machine_mode);
2524 /* We cannot convert the arg value to the mode the library wants here;
2525 must do it earlier where we know the signedness of the arg. */
2527 || (GET_MODE (val) != mode && GET_MODE (val) != VOIDmode))
2530 /* On some machines, there's no way to pass a float to a library fcn.
2531 Pass it as a double instead. */
2532 #ifdef LIBGCC_NEEDS_DOUBLE
2533 if (LIBGCC_NEEDS_DOUBLE && mode == SFmode)
2534 val = convert_modes (DFmode, SFmode, val, 0), mode = DFmode;
2537 /* There's no need to call protect_from_queue, because
2538 either emit_move_insn or emit_push_insn will do that. */
2540 /* Make sure it is a reasonable operand for a move or push insn. */
2541 if (GET_CODE (val) != REG && GET_CODE (val) != MEM
2542 && ! (CONSTANT_P (val) && LEGITIMATE_CONSTANT_P (val)))
2543 val = force_operand (val, NULL_RTX);
2545 #ifdef FUNCTION_ARG_PASS_BY_REFERENCE
2546 if (FUNCTION_ARG_PASS_BY_REFERENCE (args_so_far, mode, NULL_TREE, 1))
2548 /* We do not support FUNCTION_ARG_CALLEE_COPIES here since it can
2549 be viewed as just an efficiency improvement. */
2550 rtx slot = assign_stack_temp (mode, GET_MODE_SIZE (mode), 0);
2551 emit_move_insn (slot, val);
2552 val = XEXP (slot, 0);
2557 argvec[count].value = val;
2558 argvec[count].mode = mode;
2560 argvec[count].reg = FUNCTION_ARG (args_so_far, mode, NULL_TREE, 1);
2561 if (argvec[count].reg && GET_CODE (argvec[count].reg) == EXPR_LIST)
2563 #ifdef FUNCTION_ARG_PARTIAL_NREGS
2564 argvec[count].partial
2565 = FUNCTION_ARG_PARTIAL_NREGS (args_so_far, mode, NULL_TREE, 1);
2567 argvec[count].partial = 0;
2570 locate_and_pad_parm (mode, NULL_TREE,
2571 argvec[count].reg && argvec[count].partial == 0,
2572 NULL_TREE, &args_size, &argvec[count].offset,
2573 &argvec[count].size);
2575 if (argvec[count].size.var)
2578 #ifndef REG_PARM_STACK_SPACE
2579 if (argvec[count].partial)
2580 argvec[count].size.constant -= argvec[count].partial * UNITS_PER_WORD;
2583 if (argvec[count].reg == 0 || argvec[count].partial != 0
2584 #ifdef REG_PARM_STACK_SPACE
2588 args_size.constant += argvec[count].size.constant;
2590 #ifdef ACCUMULATE_OUTGOING_ARGS
2591 /* If this arg is actually passed on the stack, it might be
2592 clobbering something we already put there (this library call might
2593 be inside the evaluation of an argument to a function whose call
2594 requires the stack). This will only occur when the library call
2595 has sufficient args to run out of argument registers. Abort in
2596 this case; if this ever occurs, code must be added to save and
2597 restore the arg slot. */
2599 if (argvec[count].reg == 0 || argvec[count].partial != 0)
2603 FUNCTION_ARG_ADVANCE (args_so_far, mode, (tree)0, 1);
2607 /* If this machine requires an external definition for library
2608 functions, write one out. */
2609 assemble_external_libcall (fun);
2611 original_args_size = args_size;
2612 #ifdef STACK_BOUNDARY
2613 args_size.constant = (((args_size.constant + (STACK_BYTES - 1))
2614 / STACK_BYTES) * STACK_BYTES);
2617 #ifdef REG_PARM_STACK_SPACE
2618 args_size.constant = MAX (args_size.constant,
2619 REG_PARM_STACK_SPACE (NULL_TREE));
2620 #ifndef OUTGOING_REG_PARM_STACK_SPACE
2621 args_size.constant -= REG_PARM_STACK_SPACE (NULL_TREE);
2625 #ifdef ACCUMULATE_OUTGOING_ARGS
2626 if (args_size.constant > current_function_outgoing_args_size)
2627 current_function_outgoing_args_size = args_size.constant;
2628 args_size.constant = 0;
2631 #ifndef PUSH_ROUNDING
2632 argblock = push_block (GEN_INT (args_size.constant), 0, 0);
2635 #ifdef PUSH_ARGS_REVERSED
2636 #ifdef STACK_BOUNDARY
2637 /* If we push args individually in reverse order, perform stack alignment
2638 before the first push (the last arg). */
2640 anti_adjust_stack (GEN_INT (args_size.constant
2641 - original_args_size.constant));
2645 #ifdef PUSH_ARGS_REVERSED
2653 /* Push the args that need to be pushed. */
2655 for (count = 0; count < nargs; count++, argnum += inc)
2657 register enum machine_mode mode = argvec[argnum].mode;
2658 register rtx val = argvec[argnum].value;
2659 rtx reg = argvec[argnum].reg;
2660 int partial = argvec[argnum].partial;
2662 if (! (reg != 0 && partial == 0))
2663 emit_push_insn (val, mode, NULL_TREE, NULL_RTX, 0, partial, reg, 0,
2664 argblock, GEN_INT (argvec[count].offset.constant));
2668 #ifndef PUSH_ARGS_REVERSED
2669 #ifdef STACK_BOUNDARY
2670 /* If we pushed args in forward order, perform stack alignment
2671 after pushing the last arg. */
2673 anti_adjust_stack (GEN_INT (args_size.constant
2674 - original_args_size.constant));
2678 #ifdef PUSH_ARGS_REVERSED
2684 fun = prepare_call_address (fun, NULL_TREE, &call_fusage, 0);
2686 /* Now load any reg parms into their regs. */
2688 for (count = 0; count < nargs; count++, argnum += inc)
2690 register enum machine_mode mode = argvec[argnum].mode;
2691 register rtx val = argvec[argnum].value;
2692 rtx reg = argvec[argnum].reg;
2693 int partial = argvec[argnum].partial;
2695 if (reg != 0 && partial == 0)
2696 emit_move_insn (reg, val);
2701 /* For version 1.37, try deleting this entirely. */
2706 /* Any regs containing parms remain in use through the call. */
2707 for (count = 0; count < nargs; count++)
2708 if (argvec[count].reg != 0)
2709 use_reg (&call_fusage, argvec[count].reg);
2711 /* Pass the function the address in which to return a structure value. */
2712 if (mem_value != 0 && struct_value_rtx != 0 && ! pcc_struct_value)
2714 emit_move_insn (struct_value_rtx,
2716 force_operand (XEXP (mem_value, 0),
2718 if (GET_CODE (struct_value_rtx) == REG)
2719 use_reg (&call_fusage, struct_value_rtx);
2722 /* Don't allow popping to be deferred, since then
2723 cse'ing of library calls could delete a call and leave the pop. */
2726 /* We pass the old value of inhibit_defer_pop + 1 to emit_call_1, which
2727 will set inhibit_defer_pop to that value. */
2729 emit_call_1 (fun, get_identifier (XSTR (orgfun, 0)), args_size.constant,
2731 FUNCTION_ARG (args_so_far, VOIDmode, void_type_node, 1),
2732 (outmode != VOIDmode && mem_value == 0
2733 ? hard_libcall_value (outmode) : NULL_RTX),
2734 old_inhibit_defer_pop + 1, call_fusage, is_const);
2736 /* Now restore inhibit_defer_pop to its actual original value. */
2741 /* Copy the value to the right place. */
2742 if (outmode != VOIDmode)
2748 if (value != mem_value)
2749 emit_move_insn (value, mem_value);
2751 else if (value != 0)
2752 emit_move_insn (value, hard_libcall_value (outmode));
2754 value = hard_libcall_value (outmode);
2761 /* Return an rtx which represents a suitable home on the stack
2762 given TYPE, the type of the argument looking for a home.
2763 This is called only for BLKmode arguments.
2765 SIZE is the size needed for this target.
2766 ARGS_ADDR is the address of the bottom of the argument block for this call.
2767 OFFSET describes this parameter's offset into ARGS_ADDR. It is meaningless
2768 if this machine uses push insns. */
2771 target_for_arg (type, size, args_addr, offset)
2775 struct args_size offset;
2778 rtx offset_rtx = ARGS_SIZE_RTX (offset);
2780 /* We do not call memory_address if possible,
2781 because we want to address as close to the stack
2782 as possible. For non-variable sized arguments,
2783 this will be stack-pointer relative addressing. */
2784 if (GET_CODE (offset_rtx) == CONST_INT)
2785 target = plus_constant (args_addr, INTVAL (offset_rtx));
2788 /* I have no idea how to guarantee that this
2789 will work in the presence of register parameters. */
2790 target = gen_rtx (PLUS, Pmode, args_addr, offset_rtx);
2791 target = memory_address (QImode, target);
2794 return gen_rtx (MEM, BLKmode, target);
2798 /* Store a single argument for a function call
2799 into the register or memory area where it must be passed.
2800 *ARG describes the argument value and where to pass it.
2802 ARGBLOCK is the address of the stack-block for all the arguments,
2803 or 0 on a machine where arguments are pushed individually.
2805 MAY_BE_ALLOCA nonzero says this could be a call to `alloca'
2806 so must be careful about how the stack is used.
2808 VARIABLE_SIZE nonzero says that this was a variable-sized outgoing
2809 argument stack. This is used if ACCUMULATE_OUTGOING_ARGS to indicate
2810 that we need not worry about saving and restoring the stack.
2812 FNDECL is the declaration of the function we are calling. */
2815 store_one_arg (arg, argblock, may_be_alloca, variable_size, fndecl,
2816 reg_parm_stack_space)
2817 struct arg_data *arg;
2822 int reg_parm_stack_space;
2824 register tree pval = arg->tree_value;
2828 int i, lower_bound, upper_bound;
2830 if (TREE_CODE (pval) == ERROR_MARK)
2833 /* Push a new temporary level for any temporaries we make for
2837 #ifdef ACCUMULATE_OUTGOING_ARGS
2838 /* If this is being stored into a pre-allocated, fixed-size, stack area,
2839 save any previous data at that location. */
2840 if (argblock && ! variable_size && arg->stack)
2842 #ifdef ARGS_GROW_DOWNWARD
2843 /* stack_slot is negative, but we want to index stack_usage_map */
2844 /* with positive values. */
2845 if (GET_CODE (XEXP (arg->stack_slot, 0)) == PLUS)
2846 upper_bound = -INTVAL (XEXP (XEXP (arg->stack_slot, 0), 1)) + 1;
2850 lower_bound = upper_bound - arg->size.constant;
2852 if (GET_CODE (XEXP (arg->stack_slot, 0)) == PLUS)
2853 lower_bound = INTVAL (XEXP (XEXP (arg->stack_slot, 0), 1));
2857 upper_bound = lower_bound + arg->size.constant;
2860 for (i = lower_bound; i < upper_bound; i++)
2861 if (stack_usage_map[i]
2862 #ifdef REG_PARM_STACK_SPACE
2863 /* Don't store things in the fixed argument area at this point;
2864 it has already been saved. */
2865 && i > reg_parm_stack_space
2870 if (i != upper_bound)
2872 /* We need to make a save area. See what mode we can make it. */
2873 enum machine_mode save_mode
2874 = mode_for_size (arg->size.constant * BITS_PER_UNIT, MODE_INT, 1);
2876 = gen_rtx (MEM, save_mode,
2877 memory_address (save_mode, XEXP (arg->stack_slot, 0)));
2879 if (save_mode == BLKmode)
2881 arg->save_area = assign_stack_temp (BLKmode,
2882 arg->size.constant, 1);
2883 preserve_temp_slots (arg->save_area);
2884 emit_block_move (validize_mem (arg->save_area), stack_area,
2885 GEN_INT (arg->size.constant),
2886 PARM_BOUNDARY / BITS_PER_UNIT);
2890 arg->save_area = gen_reg_rtx (save_mode);
2891 emit_move_insn (arg->save_area, stack_area);
2897 /* If this isn't going to be placed on both the stack and in registers,
2898 set up the register and number of words. */
2899 if (! arg->pass_on_stack)
2900 reg = arg->reg, partial = arg->partial;
2902 if (reg != 0 && partial == 0)
2903 /* Being passed entirely in a register. We shouldn't be called in
2907 #ifdef STRICT_ALIGNMENT
2908 /* If this arg needs special alignment, don't load the registers
2910 if (arg->n_aligned_regs != 0)
2914 /* If this is being partially passed in a register, but multiple locations
2915 are specified, we assume that the one partially used is the one that is
2917 if (reg && GET_CODE (reg) == EXPR_LIST)
2918 reg = XEXP (reg, 0);
2920 /* If this is being passed partially in a register, we can't evaluate
2921 it directly into its stack slot. Otherwise, we can. */
2922 if (arg->value == 0)
2924 #ifdef ACCUMULATE_OUTGOING_ARGS
2925 /* stack_arg_under_construction is nonzero if a function argument is
2926 being evaluated directly into the outgoing argument list and
2927 expand_call must take special action to preserve the argument list
2928 if it is called recursively.
2930 For scalar function arguments stack_usage_map is sufficient to
2931 determine which stack slots must be saved and restored. Scalar
2932 arguments in general have pass_on_stack == 0.
2934 If this argument is initialized by a function which takes the
2935 address of the argument (a C++ constructor or a C function
2936 returning a BLKmode structure), then stack_usage_map is
2937 insufficient and expand_call must push the stack around the
2938 function call. Such arguments have pass_on_stack == 1.
2940 Note that it is always safe to set stack_arg_under_construction,
2941 but this generates suboptimal code if set when not needed. */
2943 if (arg->pass_on_stack)
2944 stack_arg_under_construction++;
2946 arg->value = expand_expr (pval,
2948 || TYPE_MODE (TREE_TYPE (pval)) != arg->mode)
2949 ? NULL_RTX : arg->stack,
2952 /* If we are promoting object (or for any other reason) the mode
2953 doesn't agree, convert the mode. */
2955 if (arg->mode != TYPE_MODE (TREE_TYPE (pval)))
2956 arg->value = convert_modes (arg->mode, TYPE_MODE (TREE_TYPE (pval)),
2957 arg->value, arg->unsignedp);
2959 #ifdef ACCUMULATE_OUTGOING_ARGS
2960 if (arg->pass_on_stack)
2961 stack_arg_under_construction--;
2965 /* Don't allow anything left on stack from computation
2966 of argument to alloca. */
2968 do_pending_stack_adjust ();
2970 if (arg->value == arg->stack)
2971 /* If the value is already in the stack slot, we are done. */
2973 else if (arg->mode != BLKmode)
2977 /* Argument is a scalar, not entirely passed in registers.
2978 (If part is passed in registers, arg->partial says how much
2979 and emit_push_insn will take care of putting it there.)
2981 Push it, and if its size is less than the
2982 amount of space allocated to it,
2983 also bump stack pointer by the additional space.
2984 Note that in C the default argument promotions
2985 will prevent such mismatches. */
2987 size = GET_MODE_SIZE (arg->mode);
2988 /* Compute how much space the push instruction will push.
2989 On many machines, pushing a byte will advance the stack
2990 pointer by a halfword. */
2991 #ifdef PUSH_ROUNDING
2992 size = PUSH_ROUNDING (size);
2996 /* Compute how much space the argument should get:
2997 round up to a multiple of the alignment for arguments. */
2998 if (none != FUNCTION_ARG_PADDING (arg->mode, TREE_TYPE (pval)))
2999 used = (((size + PARM_BOUNDARY / BITS_PER_UNIT - 1)
3000 / (PARM_BOUNDARY / BITS_PER_UNIT))
3001 * (PARM_BOUNDARY / BITS_PER_UNIT));
3003 /* This isn't already where we want it on the stack, so put it there.
3004 This can either be done with push or copy insns. */
3005 emit_push_insn (arg->value, arg->mode, TREE_TYPE (pval), NULL_RTX,
3006 0, partial, reg, used - size,
3007 argblock, ARGS_SIZE_RTX (arg->offset));
3011 /* BLKmode, at least partly to be pushed. */
3013 register int excess;
3016 /* Pushing a nonscalar.
3017 If part is passed in registers, PARTIAL says how much
3018 and emit_push_insn will take care of putting it there. */
3020 /* Round its size up to a multiple
3021 of the allocation unit for arguments. */
3023 if (arg->size.var != 0)
3026 size_rtx = ARGS_SIZE_RTX (arg->size);
3030 /* PUSH_ROUNDING has no effect on us, because
3031 emit_push_insn for BLKmode is careful to avoid it. */
3032 excess = (arg->size.constant - int_size_in_bytes (TREE_TYPE (pval))
3033 + partial * UNITS_PER_WORD);
3034 size_rtx = expr_size (pval);
3037 emit_push_insn (arg->value, arg->mode, TREE_TYPE (pval), size_rtx,
3038 TYPE_ALIGN (TREE_TYPE (pval)) / BITS_PER_UNIT, partial,
3039 reg, excess, argblock, ARGS_SIZE_RTX (arg->offset));
3043 /* Unless this is a partially-in-register argument, the argument is now
3046 ??? Note that this can change arg->value from arg->stack to
3047 arg->stack_slot and it matters when they are not the same.
3048 It isn't totally clear that this is correct in all cases. */
3050 arg->value = arg->stack_slot;
3052 /* Once we have pushed something, pops can't safely
3053 be deferred during the rest of the arguments. */
3056 /* ANSI doesn't require a sequence point here,
3057 but PCC has one, so this will avoid some problems. */
3060 /* Free any temporary slots made in processing this argument. */
3064 #ifdef ACCUMULATE_OUTGOING_ARGS
3065 /* Now mark the segment we just used. */
3066 if (argblock && ! variable_size && arg->stack)
3067 for (i = lower_bound; i < upper_bound; i++)
3068 stack_usage_map[i] = 1;