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.
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, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
31 #include "insn-flags.h"
33 /* Decide whether a function's arguments should be processed
34 from first to last or from last to first.
36 They should if the stack and args grow in opposite directions, but
37 only if we have push insns. */
41 #if defined (STACK_GROWS_DOWNWARD) != defined (ARGS_GROW_DOWNWARD)
42 #define PUSH_ARGS_REVERSED /* If it's last to first */
47 /* Like STACK_BOUNDARY but in units of bytes, not bits. */
48 #define STACK_BYTES (STACK_BOUNDARY / BITS_PER_UNIT)
50 /* Data structure and subroutines used within expand_call. */
54 /* Tree node for this argument. */
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. */
60 /* Initially-compute RTL value for argument; only for const functions. */
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
66 /* If REG was promoted from the actual mode of the argument expression,
67 indicates whether the promotion is sign- or zero-extended. */
69 /* Number of registers to use. 0 means put the whole arg in registers.
70 Also 0 if not passed in registers. */
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. */
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. */
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. */
94 #ifdef ACCUMULATE_OUTGOING_ARGS
95 /* Place that this stack area has been saved, if needed. */
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. */
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
;
113 /* Size of STACK_USAGE_MAP. */
114 static int highest_outgoing_arg_in_use
;
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
;
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
,
128 static void store_one_arg
PROTO ((struct arg_data
*, rtx
, int, int,
131 /* If WHICH is 1, return 1 if EXP contains a call to the built-in function
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. */
139 static tree calls_function_save_exprs
;
142 calls_function (exp
, which
)
147 calls_function_save_exprs
= 0;
148 val
= calls_function_1 (exp
, which
);
149 calls_function_save_exprs
= 0;
154 calls_function_1 (exp
, which
)
159 enum tree_code code
= TREE_CODE (exp
);
160 int type
= TREE_CODE_CLASS (code
);
161 int length
= tree_code_length
[(int) code
];
163 /* If this code is language-specific, we don't know what it will do. */
164 if ((int) code
>= NUM_TREE_CODES
)
167 /* Only expressions and references can contain calls. */
168 if (type
!= 'e' && type
!= '<' && type
!= '1' && type
!= '2' && type
!= 'r'
177 else if (TREE_CODE (TREE_OPERAND (exp
, 0)) == ADDR_EXPR
178 && (TREE_CODE (TREE_OPERAND (TREE_OPERAND (exp
, 0), 0))
181 tree fndecl
= TREE_OPERAND (TREE_OPERAND (exp
, 0), 0);
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
)))
191 /* Third operand is RTL. */
196 if (SAVE_EXPR_RTL (exp
) != 0)
198 if (value_member (exp
, calls_function_save_exprs
))
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
));
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
))
215 register tree subblock
;
217 for (subblock
= BLOCK_SUBBLOCKS (exp
);
219 subblock
= TREE_CHAIN (subblock
))
220 if (calls_function_1 (subblock
, which
))
225 case METHOD_CALL_EXPR
:
229 case WITH_CLEANUP_EXPR
:
237 for (i
= 0; i
< length
; i
++)
238 if (TREE_OPERAND (exp
, i
) != 0
239 && calls_function_1 (TREE_OPERAND (exp
, i
), which
))
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.
249 CALL_FUSAGE points to a variable holding the prospective
250 CALL_INSN_FUNCTION_USAGE information. */
253 prepare_call_address (funexp
, fndecl
, call_fusage
, reg_parm_seen
)
259 rtx static_chain_value
= 0;
261 funexp
= protect_from_queue (funexp
, 0);
264 /* Get possible static chain value for nested function in C. */
265 static_chain_value
= lookup_static_chain (fndecl
);
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
)
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
))
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 if (GET_CODE (static_chain_rtx
) == REG
)
295 use_reg (call_fusage
, static_chain_rtx
);
301 /* Generate instructions to call function FUNEXP,
302 and optionally pop the results.
303 The CALL_INSN is the first insn generated.
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.
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.
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.
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.
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.
330 VALREG is a hard register in which a value is returned,
331 or 0 if the call does not return a value.
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.
337 CALL_FUSAGE is either empty or an EXPR_LIST of USE expressions that
338 denote registers used by the called function.
340 IS_CONST is true if this is a `const' call. */
343 emit_call_1 (funexp
, fndecl
, funtype
, stack_size
, struct_value_size
,
344 next_arg_reg
, valreg
, old_inhibit_defer_pop
, call_fusage
,
350 int struct_value_size
;
353 int old_inhibit_defer_pop
;
357 rtx stack_size_rtx
= GEN_INT (stack_size
);
358 rtx struct_value_size_rtx
= GEN_INT (struct_value_size
);
360 int already_popped
= 0;
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
);
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
374 rtx n_pop
= GEN_INT (RETURN_POPS_ARGS (fndecl
, funtype
, stack_size
));
377 /* If this subroutine pops its own args, record that in the call insn
378 if possible, for the sake of frame pointer elimination. */
381 pat
= gen_call_value_pop (valreg
,
382 gen_rtx (MEM
, FUNCTION_MODE
, funexp
),
383 stack_size_rtx
, next_arg_reg
, n_pop
);
385 pat
= gen_call_pop (gen_rtx (MEM
, FUNCTION_MODE
, funexp
),
386 stack_size_rtx
, next_arg_reg
, n_pop
);
388 emit_call_insn (pat
);
395 #if defined (HAVE_call) && defined (HAVE_call_value)
396 if (HAVE_call
&& HAVE_call_value
)
399 emit_call_insn (gen_call_value (valreg
,
400 gen_rtx (MEM
, FUNCTION_MODE
, funexp
),
401 stack_size_rtx
, next_arg_reg
,
404 emit_call_insn (gen_call (gen_rtx (MEM
, FUNCTION_MODE
, funexp
),
405 stack_size_rtx
, next_arg_reg
,
406 struct_value_size_rtx
));
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
))
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
))
427 for (link
= CALL_INSN_FUNCTION_USAGE (call_insn
); XEXP (link
, 1) != 0;
428 link
= XEXP (link
, 1))
431 XEXP (link
, 1) = call_fusage
;
434 CALL_INSN_FUNCTION_USAGE (call_insn
) = call_fusage
;
436 /* If this is a const call, then set the insn's unchanging bit. */
438 CONST_CALL_P (call_insn
) = 1;
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
;
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.
449 If returning from the subroutine does pop the args, indicate that the
450 stack pointer will be changed. */
452 if (stack_size
!= 0 && RETURN_POPS_ARGS (fndecl
, funtype
, stack_size
) > 0)
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
);
465 if (flag_defer_pop
&& inhibit_defer_pop
== 0 && !is_const
)
466 pending_stack_adjust
+= stack_size
;
468 adjust_stack (stack_size_rtx
);
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. */
480 expand_call (exp
, target
, ignore
)
485 /* List of actual parameters. */
486 tree actparms
= TREE_OPERAND (exp
, 1);
487 /* RTX for the function to be called. */
489 /* Tree node for the function to be called (not the address!). */
491 /* Data type of the function. */
493 /* Declaration of the function being called,
494 or 0 if the function is computed (not known by name). */
498 /* Register in which non-BLKmode value will be returned,
499 or 0 if no value or if value is BLKmode. */
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;
516 /* Number of actual parameters in this call, including struct value addr. */
518 /* Number of named args. Args after this are anonymous ones
519 and they must all go on the stack. */
521 /* Count arg position in order args appear. */
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
;
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. */
537 /* Nonzero if this is an indirect function call. */
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). */
545 #if defined(REG_PARM_STACK_SPACE) && ! defined(OUTGOING_REG_PARM_STACK_SPACE)
546 int must_preallocate
= 1;
549 int must_preallocate
= 0;
551 int must_preallocate
= 1;
555 /* Size of the stack reserved for parameter registers. */
556 int reg_parm_stack_space
= 0;
558 /* 1 if scanning parms front to back, -1 if scanning back to front. */
560 /* Address of space preallocated for stack parms
561 (on machines that lack push insns), or 0 if space not preallocated. */
564 /* Nonzero if it is plausible that this is a call to alloca. */
566 /* Nonzero if this is a call to setjmp or a related function. */
568 /* Nonzero if this is a call to `longjmp'. */
570 /* Nonzero if this is a call to an inline function. */
571 int is_integrable
= 0;
572 /* Nonzero if this is a call to a `const' function.
573 Note that only explicitly named functions are handled as `const' here. */
575 /* Nonzero if this is a call to a `volatile' function. */
577 #if defined(ACCUMULATE_OUTGOING_ARGS) && defined(REG_PARM_STACK_SPACE)
578 /* Define the boundary of the register parm stack space that needs to be
580 int low_to_save
= -1, high_to_save
;
581 rtx save_area
= 0; /* Place that it is saved */
584 #ifdef ACCUMULATE_OUTGOING_ARGS
585 int initial_highest_arg_in_use
= highest_outgoing_arg_in_use
;
586 char *initial_stack_usage_map
= stack_usage_map
;
589 rtx old_stack_level
= 0;
590 int old_pending_adj
= 0;
591 int old_stack_arg_under_construction
;
592 int old_inhibit_defer_pop
= inhibit_defer_pop
;
597 /* See if we can find a DECL-node for the actual function.
598 As a result, decide whether this is a call to an integrable function. */
600 p
= TREE_OPERAND (exp
, 0);
601 if (TREE_CODE (p
) == ADDR_EXPR
)
603 fndecl
= TREE_OPERAND (p
, 0);
604 if (TREE_CODE (fndecl
) != FUNCTION_DECL
)
609 && fndecl
!= current_function_decl
610 && DECL_INLINE (fndecl
)
611 && DECL_SAVED_INSNS (fndecl
)
612 && RTX_INTEGRATED_P (DECL_SAVED_INSNS (fndecl
)))
614 else if (! TREE_ADDRESSABLE (fndecl
))
616 /* In case this function later becomes inlinable,
617 record that there was already a non-inline call to it.
619 Use abstraction instead of setting TREE_ADDRESSABLE
621 if (DECL_INLINE (fndecl
) && warn_inline
&& !flag_no_inline
624 warning_with_decl (fndecl
, "can't inline call to `%s'");
625 warning ("called from here");
627 mark_addressable (fndecl
);
630 if (TREE_READONLY (fndecl
) && ! TREE_THIS_VOLATILE (fndecl
)
631 && TYPE_MODE (TREE_TYPE (exp
)) != VOIDmode
)
634 if (TREE_THIS_VOLATILE (fndecl
))
639 /* If we don't have specific function to call, see if we have a
640 constant or `noreturn' function from the type. */
643 is_const
= TREE_READONLY (TREE_TYPE (TREE_TYPE (p
)));
644 is_volatile
= TREE_THIS_VOLATILE (TREE_TYPE (TREE_TYPE (p
)));
647 #ifdef REG_PARM_STACK_SPACE
648 #ifdef MAYBE_REG_PARM_STACK_SPACE
649 reg_parm_stack_space
= MAYBE_REG_PARM_STACK_SPACE
;
651 reg_parm_stack_space
= REG_PARM_STACK_SPACE (fndecl
);
655 /* Warn if this value is an aggregate type,
656 regardless of which calling convention we are using for it. */
657 if (warn_aggregate_return
&& AGGREGATE_TYPE_P (TREE_TYPE (exp
)))
658 warning ("function call has aggregate value");
660 /* Set up a place to return a structure. */
662 /* Cater to broken compilers. */
663 if (aggregate_value_p (exp
))
665 /* This call returns a big structure. */
668 #ifdef PCC_STATIC_STRUCT_RETURN
670 pcc_struct_value
= 1;
671 /* Easier than making that case work right. */
674 /* In case this is a static function, note that it has been
676 if (! TREE_ADDRESSABLE (fndecl
))
677 mark_addressable (fndecl
);
681 #else /* not PCC_STATIC_STRUCT_RETURN */
683 struct_value_size
= int_size_in_bytes (TREE_TYPE (exp
));
685 if (target
&& GET_CODE (target
) == MEM
)
686 structure_value_addr
= XEXP (target
, 0);
689 /* Assign a temporary on the stack to hold the value. */
691 /* For variable-sized objects, we must be called with a target
692 specified. If we were to allocate space on the stack here,
693 we would have no way of knowing when to free it. */
695 if (struct_value_size
< 0)
699 = XEXP (assign_stack_temp (BLKmode
, struct_value_size
, 1), 0);
700 MEM_IN_STRUCT_P (structure_value_addr
)
701 = AGGREGATE_TYPE_P (TREE_TYPE (exp
));
705 #endif /* not PCC_STATIC_STRUCT_RETURN */
708 /* If called function is inline, try to integrate it. */
713 rtx before_call
= get_last_insn ();
715 temp
= expand_inline_function (fndecl
, actparms
, target
,
716 ignore
, TREE_TYPE (exp
),
717 structure_value_addr
);
719 /* If inlining succeeded, return. */
720 if ((HOST_WIDE_INT
) temp
!= -1)
722 #ifdef ACCUMULATE_OUTGOING_ARGS
723 /* If the outgoing argument list must be preserved, push
724 the stack before executing the inlined function if it
727 for (i
= reg_parm_stack_space
- 1; i
>= 0; i
--)
728 if (i
< highest_outgoing_arg_in_use
&& stack_usage_map
[i
] != 0)
731 if (stack_arg_under_construction
|| i
>= 0)
734 = before_call
? NEXT_INSN (before_call
) : get_insns ();
737 /* Look for a call in the inline function code.
738 If OUTGOING_ARGS_SIZE (DECL_SAVED_INSNS (fndecl)) is
739 nonzero then there is a call and it is not necessary
740 to scan the insns. */
742 if (OUTGOING_ARGS_SIZE (DECL_SAVED_INSNS (fndecl
)) == 0)
743 for (insn
= first_insn
; insn
; insn
= NEXT_INSN (insn
))
744 if (GET_CODE (insn
) == CALL_INSN
)
749 /* Reserve enough stack space so that the largest
750 argument list of any function call in the inline
751 function does not overlap the argument list being
752 evaluated. This is usually an overestimate because
753 allocate_dynamic_stack_space reserves space for an
754 outgoing argument list in addition to the requested
755 space, but there is no way to ask for stack space such
756 that an argument list of a certain length can be
757 safely constructed. */
759 int adjust
= OUTGOING_ARGS_SIZE (DECL_SAVED_INSNS (fndecl
));
760 #ifdef REG_PARM_STACK_SPACE
761 /* Add the stack space reserved for register arguments
762 in the inline function. What is really needed is the
763 largest value of reg_parm_stack_space in the inline
764 function, but that is not available. Using the current
765 value of reg_parm_stack_space is wrong, but gives
766 correct results on all supported machines. */
767 adjust
+= reg_parm_stack_space
;
770 emit_stack_save (SAVE_BLOCK
, &old_stack_level
, NULL_RTX
);
771 allocate_dynamic_stack_space (GEN_INT (adjust
),
772 NULL_RTX
, BITS_PER_UNIT
);
775 emit_insns_before (seq
, first_insn
);
776 emit_stack_restore (SAVE_BLOCK
, old_stack_level
, NULL_RTX
);
781 /* If the result is equivalent to TARGET, return TARGET to simplify
782 checks in store_expr. They can be equivalent but not equal in the
783 case of a function that returns BLKmode. */
784 if (temp
!= target
&& rtx_equal_p (temp
, target
))
789 /* If inlining failed, mark FNDECL as needing to be compiled
790 separately after all. If function was declared inline,
792 if (DECL_INLINE (fndecl
) && warn_inline
&& !flag_no_inline
793 && optimize
> 0 && ! TREE_ADDRESSABLE (fndecl
))
795 warning_with_decl (fndecl
, "inlining failed in call to `%s'");
796 warning ("called from here");
798 mark_addressable (fndecl
);
801 /* When calling a const function, we must pop the stack args right away,
802 so that the pop is deleted or moved with the call. */
806 function_call_count
++;
808 if (fndecl
&& DECL_NAME (fndecl
))
809 name
= IDENTIFIER_POINTER (DECL_NAME (fndecl
));
812 /* Unless it's a call to a specific function that isn't alloca,
813 if it has one argument, we must assume it might be alloca. */
816 = (!(fndecl
!= 0 && strcmp (name
, "alloca"))
818 && TREE_CHAIN (actparms
) == 0);
820 /* We assume that alloca will always be called by name. It
821 makes no sense to pass it as a pointer-to-function to
822 anything that does not understand its behavior. */
824 = (name
&& ((IDENTIFIER_LENGTH (DECL_NAME (fndecl
)) == 6
826 && ! strcmp (name
, "alloca"))
827 || (IDENTIFIER_LENGTH (DECL_NAME (fndecl
)) == 16
829 && ! strcmp (name
, "__builtin_alloca"))));
832 /* See if this is a call to a function that can return more than once
833 or a call to longjmp. */
838 if (name
!= 0 && IDENTIFIER_LENGTH (DECL_NAME (fndecl
)) <= 15)
842 /* Disregard prefix _, __ or __x. */
845 if (name
[1] == '_' && name
[2] == 'x')
847 else if (name
[1] == '_')
857 && (! strcmp (tname
, "setjmp")
858 || ! strcmp (tname
, "setjmp_syscall")))
860 && ! strcmp (tname
, "sigsetjmp"))
862 && ! strcmp (tname
, "savectx")));
864 && ! strcmp (tname
, "siglongjmp"))
867 else if ((tname
[0] == 'q' && tname
[1] == 's'
868 && ! strcmp (tname
, "qsetjmp"))
869 || (tname
[0] == 'v' && tname
[1] == 'f'
870 && ! strcmp (tname
, "vfork")))
873 else if (tname
[0] == 'l' && tname
[1] == 'o'
874 && ! strcmp (tname
, "longjmp"))
879 current_function_calls_alloca
= 1;
881 /* Don't let pending stack adjusts add up to too much.
882 Also, do all pending adjustments now
883 if there is any chance this might be a call to alloca. */
885 if (pending_stack_adjust
>= 32
886 || (pending_stack_adjust
> 0 && may_be_alloca
))
887 do_pending_stack_adjust ();
889 /* Operand 0 is a pointer-to-function; get the type of the function. */
890 funtype
= TREE_TYPE (TREE_OPERAND (exp
, 0));
891 if (TREE_CODE (funtype
) != POINTER_TYPE
)
893 funtype
= TREE_TYPE (funtype
);
895 /* Push the temporary stack slot level so that we can free any temporaries
899 /* Start updating where the next arg would go.
901 On some machines (such as the PA) indirect calls have a different
902 calling convention than normal calls. The last argument in
903 INIT_CUMULATIVE_ARGS tells the backend if this is an indirect call
905 INIT_CUMULATIVE_ARGS (args_so_far
, funtype
, NULL_RTX
, (fndecl
== 0));
907 /* If struct_value_rtx is 0, it means pass the address
908 as if it were an extra parameter. */
909 if (structure_value_addr
&& struct_value_rtx
== 0)
911 /* If structure_value_addr is a REG other than
912 virtual_outgoing_args_rtx, we can use always use it. If it
913 is not a REG, we must always copy it into a register.
914 If it is virtual_outgoing_args_rtx, we must copy it to another
915 register in some cases. */
916 rtx temp
= (GET_CODE (structure_value_addr
) != REG
917 #ifdef ACCUMULATE_OUTGOING_ARGS
918 || (stack_arg_under_construction
919 && structure_value_addr
== virtual_outgoing_args_rtx
)
921 ? copy_addr_to_reg (structure_value_addr
)
922 : structure_value_addr
);
925 = tree_cons (error_mark_node
,
926 make_tree (build_pointer_type (TREE_TYPE (funtype
)),
929 structure_value_addr_parm
= 1;
932 /* Count the arguments and set NUM_ACTUALS. */
933 for (p
= actparms
, i
= 0; p
; p
= TREE_CHAIN (p
)) i
++;
936 /* Compute number of named args.
937 Normally, don't include the last named arg if anonymous args follow.
938 We do include the last named arg if STRICT_ARGUMENT_NAMING is defined.
939 (If no anonymous args follow, the result of list_length is actually
940 one too large. This is harmless.)
942 If SETUP_INCOMING_VARARGS is defined and STRICT_ARGUMENT_NAMING is not,
943 this machine will be able to place unnamed args that were passed in
944 registers into the stack. So treat all args as named. This allows the
945 insns emitting for a specific argument list to be independent of the
946 function declaration.
948 If SETUP_INCOMING_VARARGS is not defined, we do not have any reliable
949 way to pass unnamed args in registers, so we must force them into
951 #if !defined(SETUP_INCOMING_VARARGS) || defined(STRICT_ARGUMENT_NAMING)
952 if (TYPE_ARG_TYPES (funtype
) != 0)
954 = (list_length (TYPE_ARG_TYPES (funtype
))
955 #ifndef STRICT_ARGUMENT_NAMING
956 /* Don't include the last named arg. */
959 /* Count the struct value address, if it is passed as a parm. */
960 + structure_value_addr_parm
);
963 /* If we know nothing, treat all args as named. */
964 n_named_args
= num_actuals
;
966 /* Make a vector to hold all the information about each arg. */
967 args
= (struct arg_data
*) alloca (num_actuals
* sizeof (struct arg_data
));
968 bzero ((char *) args
, num_actuals
* sizeof (struct arg_data
));
970 args_size
.constant
= 0;
973 /* In this loop, we consider args in the order they are written.
974 We fill up ARGS from the front or from the back if necessary
975 so that in any case the first arg to be pushed ends up at the front. */
977 #ifdef PUSH_ARGS_REVERSED
978 i
= num_actuals
- 1, inc
= -1;
979 /* In this case, must reverse order of args
980 so that we compute and push the last arg first. */
985 /* I counts args in order (to be) pushed; ARGPOS counts in order written. */
986 for (p
= actparms
, argpos
= 0; p
; p
= TREE_CHAIN (p
), i
+= inc
, argpos
++)
988 tree type
= TREE_TYPE (TREE_VALUE (p
));
990 enum machine_mode mode
;
992 args
[i
].tree_value
= TREE_VALUE (p
);
994 /* Replace erroneous argument with constant zero. */
995 if (type
== error_mark_node
|| TYPE_SIZE (type
) == 0)
996 args
[i
].tree_value
= integer_zero_node
, type
= integer_type_node
;
998 /* If TYPE is a transparent union, pass things the way we would
999 pass the first field of the union. We have already verified that
1000 the modes are the same. */
1001 if (TYPE_TRANSPARENT_UNION (type
))
1002 type
= TREE_TYPE (TYPE_FIELDS (type
));
1004 /* Decide where to pass this arg.
1006 args[i].reg is nonzero if all or part is passed in registers.
1008 args[i].partial is nonzero if part but not all is passed in registers,
1009 and the exact value says how many words are passed in registers.
1011 args[i].pass_on_stack is nonzero if the argument must at least be
1012 computed on the stack. It may then be loaded back into registers
1013 if args[i].reg is nonzero.
1015 These decisions are driven by the FUNCTION_... macros and must agree
1016 with those made by function.c. */
1018 /* See if this argument should be passed by invisible reference. */
1019 if ((TREE_CODE (TYPE_SIZE (type
)) != INTEGER_CST
1020 && contains_placeholder_p (TYPE_SIZE (type
)))
1021 || TREE_ADDRESSABLE (type
)
1022 #ifdef FUNCTION_ARG_PASS_BY_REFERENCE
1023 || FUNCTION_ARG_PASS_BY_REFERENCE (args_so_far
, TYPE_MODE (type
),
1024 type
, argpos
< n_named_args
)
1028 /* If we're compiling a thunk, pass through invisible
1029 references instead of making a copy. */
1030 if (current_function_is_thunk
1031 #ifdef FUNCTION_ARG_CALLEE_COPIES
1032 || (FUNCTION_ARG_CALLEE_COPIES (args_so_far
, TYPE_MODE (type
),
1033 type
, argpos
< n_named_args
)
1034 /* If it's in a register, we must make a copy of it too. */
1035 /* ??? Is this a sufficient test? Is there a better one? */
1036 && !(TREE_CODE (args
[i
].tree_value
) == VAR_DECL
1037 && REG_P (DECL_RTL (args
[i
].tree_value
)))
1038 && ! TREE_ADDRESSABLE (type
))
1042 args
[i
].tree_value
= build1 (ADDR_EXPR
,
1043 build_pointer_type (type
),
1044 args
[i
].tree_value
);
1045 type
= build_pointer_type (type
);
1049 /* We make a copy of the object and pass the address to the
1050 function being called. */
1053 if (TYPE_SIZE (type
) == 0
1054 || TREE_CODE (TYPE_SIZE (type
)) != INTEGER_CST
)
1056 /* This is a variable-sized object. Make space on the stack
1058 rtx size_rtx
= expr_size (TREE_VALUE (p
));
1060 if (old_stack_level
== 0)
1062 emit_stack_save (SAVE_BLOCK
, &old_stack_level
, NULL_RTX
);
1063 old_pending_adj
= pending_stack_adjust
;
1064 pending_stack_adjust
= 0;
1067 copy
= gen_rtx (MEM
, BLKmode
,
1068 allocate_dynamic_stack_space (size_rtx
,
1070 TYPE_ALIGN (type
)));
1074 int size
= int_size_in_bytes (type
);
1075 copy
= assign_stack_temp (TYPE_MODE (type
), size
, 0);
1078 MEM_IN_STRUCT_P (copy
) = AGGREGATE_TYPE_P (type
);
1080 store_expr (args
[i
].tree_value
, copy
, 0);
1083 args
[i
].tree_value
= build1 (ADDR_EXPR
,
1084 build_pointer_type (type
),
1085 make_tree (type
, copy
));
1086 type
= build_pointer_type (type
);
1090 mode
= TYPE_MODE (type
);
1091 unsignedp
= TREE_UNSIGNED (type
);
1093 #ifdef PROMOTE_FUNCTION_ARGS
1094 mode
= promote_mode (type
, mode
, &unsignedp
, 1);
1097 args
[i
].unsignedp
= unsignedp
;
1098 args
[i
].mode
= mode
;
1099 args
[i
].reg
= FUNCTION_ARG (args_so_far
, mode
, type
,
1100 argpos
< n_named_args
);
1101 #ifdef FUNCTION_ARG_PARTIAL_NREGS
1104 = FUNCTION_ARG_PARTIAL_NREGS (args_so_far
, mode
, type
,
1105 argpos
< n_named_args
);
1108 args
[i
].pass_on_stack
= MUST_PASS_IN_STACK (mode
, type
);
1110 /* If FUNCTION_ARG returned a (parallel [(expr_list (nil) ...) ...]),
1111 it means that we are to pass this arg in the register(s) designated
1112 by the PARALLEL, but also to pass it in the stack. */
1113 if (args
[i
].reg
&& GET_CODE (args
[i
].reg
) == PARALLEL
1114 && XEXP (XVECEXP (args
[i
].reg
, 0, 0), 0) == 0)
1115 args
[i
].pass_on_stack
= 1;
1117 /* If this is an addressable type, we must preallocate the stack
1118 since we must evaluate the object into its final location.
1120 If this is to be passed in both registers and the stack, it is simpler
1122 if (TREE_ADDRESSABLE (type
)
1123 || (args
[i
].pass_on_stack
&& args
[i
].reg
!= 0))
1124 must_preallocate
= 1;
1126 /* If this is an addressable type, we cannot pre-evaluate it. Thus,
1127 we cannot consider this function call constant. */
1128 if (TREE_ADDRESSABLE (type
))
1131 /* Compute the stack-size of this argument. */
1132 if (args
[i
].reg
== 0 || args
[i
].partial
!= 0
1133 #ifdef REG_PARM_STACK_SPACE
1134 || reg_parm_stack_space
> 0
1136 || args
[i
].pass_on_stack
)
1137 locate_and_pad_parm (mode
, type
,
1138 #ifdef STACK_PARMS_IN_REG_PARM_AREA
1143 fndecl
, &args_size
, &args
[i
].offset
,
1146 #ifndef ARGS_GROW_DOWNWARD
1147 args
[i
].slot_offset
= args_size
;
1150 #ifndef REG_PARM_STACK_SPACE
1151 /* If a part of the arg was put into registers,
1152 don't include that part in the amount pushed. */
1153 if (! args
[i
].pass_on_stack
)
1154 args
[i
].size
.constant
-= ((args
[i
].partial
* UNITS_PER_WORD
)
1155 / (PARM_BOUNDARY
/ BITS_PER_UNIT
)
1156 * (PARM_BOUNDARY
/ BITS_PER_UNIT
));
1159 /* Update ARGS_SIZE, the total stack space for args so far. */
1161 args_size
.constant
+= args
[i
].size
.constant
;
1162 if (args
[i
].size
.var
)
1164 ADD_PARM_SIZE (args_size
, args
[i
].size
.var
);
1167 /* Since the slot offset points to the bottom of the slot,
1168 we must record it after incrementing if the args grow down. */
1169 #ifdef ARGS_GROW_DOWNWARD
1170 args
[i
].slot_offset
= args_size
;
1172 args
[i
].slot_offset
.constant
= -args_size
.constant
;
1175 SUB_PARM_SIZE (args
[i
].slot_offset
, args_size
.var
);
1179 /* Increment ARGS_SO_FAR, which has info about which arg-registers
1180 have been used, etc. */
1182 FUNCTION_ARG_ADVANCE (args_so_far
, TYPE_MODE (type
), type
,
1183 argpos
< n_named_args
);
1186 #ifdef FINAL_REG_PARM_STACK_SPACE
1187 reg_parm_stack_space
= FINAL_REG_PARM_STACK_SPACE (args_size
.constant
,
1191 /* Compute the actual size of the argument block required. The variable
1192 and constant sizes must be combined, the size may have to be rounded,
1193 and there may be a minimum required size. */
1195 original_args_size
= args_size
;
1198 /* If this function requires a variable-sized argument list, don't try to
1199 make a cse'able block for this call. We may be able to do this
1200 eventually, but it is too complicated to keep track of what insns go
1201 in the cse'able block and which don't. */
1204 must_preallocate
= 1;
1206 args_size
.var
= ARGS_SIZE_TREE (args_size
);
1207 args_size
.constant
= 0;
1209 #ifdef STACK_BOUNDARY
1210 if (STACK_BOUNDARY
!= BITS_PER_UNIT
)
1211 args_size
.var
= round_up (args_size
.var
, STACK_BYTES
);
1214 #ifdef REG_PARM_STACK_SPACE
1215 if (reg_parm_stack_space
> 0)
1218 = size_binop (MAX_EXPR
, args_size
.var
,
1219 size_int (REG_PARM_STACK_SPACE (fndecl
)));
1221 #ifndef OUTGOING_REG_PARM_STACK_SPACE
1222 /* The area corresponding to register parameters is not to count in
1223 the size of the block we need. So make the adjustment. */
1225 = size_binop (MINUS_EXPR
, args_size
.var
,
1226 size_int (reg_parm_stack_space
));
1233 #ifdef STACK_BOUNDARY
1234 args_size
.constant
= (((args_size
.constant
+ (STACK_BYTES
- 1))
1235 / STACK_BYTES
) * STACK_BYTES
);
1238 #ifdef REG_PARM_STACK_SPACE
1239 args_size
.constant
= MAX (args_size
.constant
,
1240 reg_parm_stack_space
);
1241 #ifdef MAYBE_REG_PARM_STACK_SPACE
1242 if (reg_parm_stack_space
== 0)
1243 args_size
.constant
= 0;
1245 #ifndef OUTGOING_REG_PARM_STACK_SPACE
1246 args_size
.constant
-= reg_parm_stack_space
;
1251 /* See if we have or want to preallocate stack space.
1253 If we would have to push a partially-in-regs parm
1254 before other stack parms, preallocate stack space instead.
1256 If the size of some parm is not a multiple of the required stack
1257 alignment, we must preallocate.
1259 If the total size of arguments that would otherwise create a copy in
1260 a temporary (such as a CALL) is more than half the total argument list
1261 size, preallocation is faster.
1263 Another reason to preallocate is if we have a machine (like the m88k)
1264 where stack alignment is required to be maintained between every
1265 pair of insns, not just when the call is made. However, we assume here
1266 that such machines either do not have push insns (and hence preallocation
1267 would occur anyway) or the problem is taken care of with
1270 if (! must_preallocate
)
1272 int partial_seen
= 0;
1273 int copy_to_evaluate_size
= 0;
1275 for (i
= 0; i
< num_actuals
&& ! must_preallocate
; i
++)
1277 if (args
[i
].partial
> 0 && ! args
[i
].pass_on_stack
)
1279 else if (partial_seen
&& args
[i
].reg
== 0)
1280 must_preallocate
= 1;
1282 if (TYPE_MODE (TREE_TYPE (args
[i
].tree_value
)) == BLKmode
1283 && (TREE_CODE (args
[i
].tree_value
) == CALL_EXPR
1284 || TREE_CODE (args
[i
].tree_value
) == TARGET_EXPR
1285 || TREE_CODE (args
[i
].tree_value
) == COND_EXPR
1286 || TREE_ADDRESSABLE (TREE_TYPE (args
[i
].tree_value
))))
1287 copy_to_evaluate_size
1288 += int_size_in_bytes (TREE_TYPE (args
[i
].tree_value
));
1291 if (copy_to_evaluate_size
* 2 >= args_size
.constant
1292 && args_size
.constant
> 0)
1293 must_preallocate
= 1;
1296 /* If the structure value address will reference the stack pointer, we must
1297 stabilize it. We don't need to do this if we know that we are not going
1298 to adjust the stack pointer in processing this call. */
1300 if (structure_value_addr
1301 && (reg_mentioned_p (virtual_stack_dynamic_rtx
, structure_value_addr
)
1302 || reg_mentioned_p (virtual_outgoing_args_rtx
, structure_value_addr
))
1304 #ifndef ACCUMULATE_OUTGOING_ARGS
1305 || args_size
.constant
1308 structure_value_addr
= copy_to_reg (structure_value_addr
);
1310 /* If this function call is cse'able, precompute all the parameters.
1311 Note that if the parameter is constructed into a temporary, this will
1312 cause an additional copy because the parameter will be constructed
1313 into a temporary location and then copied into the outgoing arguments.
1314 If a parameter contains a call to alloca and this function uses the
1315 stack, precompute the parameter. */
1317 /* If we preallocated the stack space, and some arguments must be passed
1318 on the stack, then we must precompute any parameter which contains a
1319 function call which will store arguments on the stack.
1320 Otherwise, evaluating the parameter may clobber previous parameters
1321 which have already been stored into the stack. */
1323 for (i
= 0; i
< num_actuals
; i
++)
1325 || ((args_size
.var
!= 0 || args_size
.constant
!= 0)
1326 && calls_function (args
[i
].tree_value
, 1))
1327 || (must_preallocate
&& (args_size
.var
!= 0 || args_size
.constant
!= 0)
1328 && calls_function (args
[i
].tree_value
, 0)))
1330 /* If this is an addressable type, we cannot pre-evaluate it. */
1331 if (TREE_ADDRESSABLE (TREE_TYPE (args
[i
].tree_value
)))
1336 args
[i
].initial_value
= args
[i
].value
1337 = expand_expr (args
[i
].tree_value
, NULL_RTX
, VOIDmode
, 0);
1339 preserve_temp_slots (args
[i
].value
);
1342 /* ANSI doesn't require a sequence point here,
1343 but PCC has one, so this will avoid some problems. */
1346 args
[i
].initial_value
= args
[i
].value
1347 = protect_from_queue (args
[i
].initial_value
, 0);
1349 if (TYPE_MODE (TREE_TYPE (args
[i
].tree_value
)) != args
[i
].mode
)
1351 = convert_modes (args
[i
].mode
,
1352 TYPE_MODE (TREE_TYPE (args
[i
].tree_value
)),
1353 args
[i
].value
, args
[i
].unsignedp
);
1356 /* Now we are about to start emitting insns that can be deleted
1357 if a libcall is deleted. */
1361 /* If we have no actual push instructions, or shouldn't use them,
1362 make space for all args right now. */
1364 if (args_size
.var
!= 0)
1366 if (old_stack_level
== 0)
1368 emit_stack_save (SAVE_BLOCK
, &old_stack_level
, NULL_RTX
);
1369 old_pending_adj
= pending_stack_adjust
;
1370 pending_stack_adjust
= 0;
1371 #ifdef ACCUMULATE_OUTGOING_ARGS
1372 /* stack_arg_under_construction says whether a stack arg is
1373 being constructed at the old stack level. Pushing the stack
1374 gets a clean outgoing argument block. */
1375 old_stack_arg_under_construction
= stack_arg_under_construction
;
1376 stack_arg_under_construction
= 0;
1379 argblock
= push_block (ARGS_SIZE_RTX (args_size
), 0, 0);
1383 /* Note that we must go through the motions of allocating an argument
1384 block even if the size is zero because we may be storing args
1385 in the area reserved for register arguments, which may be part of
1388 int needed
= args_size
.constant
;
1390 /* Store the maximum argument space used. It will be pushed by
1391 the prologue (if ACCUMULATE_OUTGOING_ARGS, or stack overflow
1394 if (needed
> current_function_outgoing_args_size
)
1395 current_function_outgoing_args_size
= needed
;
1397 if (must_preallocate
)
1399 #ifdef ACCUMULATE_OUTGOING_ARGS
1400 /* Since the stack pointer will never be pushed, it is possible for
1401 the evaluation of a parm to clobber something we have already
1402 written to the stack. Since most function calls on RISC machines
1403 do not use the stack, this is uncommon, but must work correctly.
1405 Therefore, we save any area of the stack that was already written
1406 and that we are using. Here we set up to do this by making a new
1407 stack usage map from the old one. The actual save will be done
1410 Another approach might be to try to reorder the argument
1411 evaluations to avoid this conflicting stack usage. */
1413 #if defined(REG_PARM_STACK_SPACE) && ! defined(OUTGOING_REG_PARM_STACK_SPACE)
1414 /* Since we will be writing into the entire argument area, the
1415 map must be allocated for its entire size, not just the part that
1416 is the responsibility of the caller. */
1417 needed
+= reg_parm_stack_space
;
1420 #ifdef ARGS_GROW_DOWNWARD
1421 highest_outgoing_arg_in_use
= MAX (initial_highest_arg_in_use
,
1424 highest_outgoing_arg_in_use
= MAX (initial_highest_arg_in_use
,
1427 stack_usage_map
= (char *) alloca (highest_outgoing_arg_in_use
);
1429 if (initial_highest_arg_in_use
)
1430 bcopy (initial_stack_usage_map
, stack_usage_map
,
1431 initial_highest_arg_in_use
);
1433 if (initial_highest_arg_in_use
!= highest_outgoing_arg_in_use
)
1434 bzero (&stack_usage_map
[initial_highest_arg_in_use
],
1435 highest_outgoing_arg_in_use
- initial_highest_arg_in_use
);
1438 /* The address of the outgoing argument list must not be copied to a
1439 register here, because argblock would be left pointing to the
1440 wrong place after the call to allocate_dynamic_stack_space below.
1443 argblock
= virtual_outgoing_args_rtx
;
1445 #else /* not ACCUMULATE_OUTGOING_ARGS */
1446 if (inhibit_defer_pop
== 0)
1448 /* Try to reuse some or all of the pending_stack_adjust
1449 to get this space. Maybe we can avoid any pushing. */
1450 if (needed
> pending_stack_adjust
)
1452 needed
-= pending_stack_adjust
;
1453 pending_stack_adjust
= 0;
1457 pending_stack_adjust
-= needed
;
1461 /* Special case this because overhead of `push_block' in this
1462 case is non-trivial. */
1464 argblock
= virtual_outgoing_args_rtx
;
1466 argblock
= push_block (GEN_INT (needed
), 0, 0);
1468 /* We only really need to call `copy_to_reg' in the case where push
1469 insns are going to be used to pass ARGBLOCK to a function
1470 call in ARGS. In that case, the stack pointer changes value
1471 from the allocation point to the call point, and hence
1472 the value of VIRTUAL_OUTGOING_ARGS_RTX changes as well.
1473 But might as well always do it. */
1474 argblock
= copy_to_reg (argblock
);
1475 #endif /* not ACCUMULATE_OUTGOING_ARGS */
1479 #ifdef ACCUMULATE_OUTGOING_ARGS
1480 /* The save/restore code in store_one_arg handles all cases except one:
1481 a constructor call (including a C function returning a BLKmode struct)
1482 to initialize an argument. */
1483 if (stack_arg_under_construction
)
1485 #if defined(REG_PARM_STACK_SPACE) && ! defined(OUTGOING_REG_PARM_STACK_SPACE)
1486 rtx push_size
= GEN_INT (reg_parm_stack_space
+ args_size
.constant
);
1488 rtx push_size
= GEN_INT (args_size
.constant
);
1490 if (old_stack_level
== 0)
1492 emit_stack_save (SAVE_BLOCK
, &old_stack_level
, NULL_RTX
);
1493 old_pending_adj
= pending_stack_adjust
;
1494 pending_stack_adjust
= 0;
1495 /* stack_arg_under_construction says whether a stack arg is
1496 being constructed at the old stack level. Pushing the stack
1497 gets a clean outgoing argument block. */
1498 old_stack_arg_under_construction
= stack_arg_under_construction
;
1499 stack_arg_under_construction
= 0;
1500 /* Make a new map for the new argument list. */
1501 stack_usage_map
= (char *)alloca (highest_outgoing_arg_in_use
);
1502 bzero (stack_usage_map
, highest_outgoing_arg_in_use
);
1503 highest_outgoing_arg_in_use
= 0;
1505 allocate_dynamic_stack_space (push_size
, NULL_RTX
, BITS_PER_UNIT
);
1507 /* If argument evaluation might modify the stack pointer, copy the
1508 address of the argument list to a register. */
1509 for (i
= 0; i
< num_actuals
; i
++)
1510 if (args
[i
].pass_on_stack
)
1512 argblock
= copy_addr_to_reg (argblock
);
1518 /* If we preallocated stack space, compute the address of each argument.
1519 We need not ensure it is a valid memory address here; it will be
1520 validized when it is used. */
1523 rtx arg_reg
= argblock
;
1526 if (GET_CODE (argblock
) == PLUS
)
1527 arg_reg
= XEXP (argblock
, 0), arg_offset
= INTVAL (XEXP (argblock
, 1));
1529 for (i
= 0; i
< num_actuals
; i
++)
1531 rtx offset
= ARGS_SIZE_RTX (args
[i
].offset
);
1532 rtx slot_offset
= ARGS_SIZE_RTX (args
[i
].slot_offset
);
1535 /* Skip this parm if it will not be passed on the stack. */
1536 if (! args
[i
].pass_on_stack
&& args
[i
].reg
!= 0)
1539 if (GET_CODE (offset
) == CONST_INT
)
1540 addr
= plus_constant (arg_reg
, INTVAL (offset
));
1542 addr
= gen_rtx (PLUS
, Pmode
, arg_reg
, offset
);
1544 addr
= plus_constant (addr
, arg_offset
);
1545 args
[i
].stack
= gen_rtx (MEM
, args
[i
].mode
, addr
);
1546 MEM_IN_STRUCT_P (args
[i
].stack
)
1547 = AGGREGATE_TYPE_P (TREE_TYPE (args
[i
].tree_value
));
1549 if (GET_CODE (slot_offset
) == CONST_INT
)
1550 addr
= plus_constant (arg_reg
, INTVAL (slot_offset
));
1552 addr
= gen_rtx (PLUS
, Pmode
, arg_reg
, slot_offset
);
1554 addr
= plus_constant (addr
, arg_offset
);
1555 args
[i
].stack_slot
= gen_rtx (MEM
, args
[i
].mode
, addr
);
1559 #ifdef PUSH_ARGS_REVERSED
1560 #ifdef STACK_BOUNDARY
1561 /* If we push args individually in reverse order, perform stack alignment
1562 before the first push (the last arg). */
1564 anti_adjust_stack (GEN_INT (args_size
.constant
1565 - original_args_size
.constant
));
1569 /* Don't try to defer pops if preallocating, not even from the first arg,
1570 since ARGBLOCK probably refers to the SP. */
1574 /* Get the function to call, in the form of RTL. */
1577 /* If this is the first use of the function, see if we need to
1578 make an external definition for it. */
1579 if (! TREE_USED (fndecl
))
1581 assemble_external (fndecl
);
1582 TREE_USED (fndecl
) = 1;
1585 /* Get a SYMBOL_REF rtx for the function address. */
1586 funexp
= XEXP (DECL_RTL (fndecl
), 0);
1589 /* Generate an rtx (probably a pseudo-register) for the address. */
1592 funexp
= expand_expr (TREE_OPERAND (exp
, 0), NULL_RTX
, VOIDmode
, 0);
1593 pop_temp_slots (); /* FUNEXP can't be BLKmode */
1597 /* Figure out the register where the value, if any, will come back. */
1599 if (TYPE_MODE (TREE_TYPE (exp
)) != VOIDmode
1600 && ! structure_value_addr
)
1602 if (pcc_struct_value
)
1603 valreg
= hard_function_value (build_pointer_type (TREE_TYPE (exp
)),
1606 valreg
= hard_function_value (TREE_TYPE (exp
), fndecl
);
1609 /* Precompute all register parameters. It isn't safe to compute anything
1610 once we have started filling any specific hard regs. */
1612 for (i
= 0; i
< num_actuals
; i
++)
1613 if (args
[i
].reg
!= 0 && ! args
[i
].pass_on_stack
)
1617 if (args
[i
].value
== 0)
1620 args
[i
].value
= expand_expr (args
[i
].tree_value
, NULL_RTX
,
1622 preserve_temp_slots (args
[i
].value
);
1625 /* ANSI doesn't require a sequence point here,
1626 but PCC has one, so this will avoid some problems. */
1630 /* If we are to promote the function arg to a wider mode,
1633 if (args
[i
].mode
!= TYPE_MODE (TREE_TYPE (args
[i
].tree_value
)))
1635 = convert_modes (args
[i
].mode
,
1636 TYPE_MODE (TREE_TYPE (args
[i
].tree_value
)),
1637 args
[i
].value
, args
[i
].unsignedp
);
1639 /* If the value is expensive, and we are inside an appropriately
1640 short loop, put the value into a pseudo and then put the pseudo
1643 For small register classes, also do this if this call uses
1644 register parameters. This is to avoid reload conflicts while
1645 loading the parameters registers. */
1647 if ((! (GET_CODE (args
[i
].value
) == REG
1648 || (GET_CODE (args
[i
].value
) == SUBREG
1649 && GET_CODE (SUBREG_REG (args
[i
].value
)) == REG
)))
1650 && args
[i
].mode
!= BLKmode
1651 && rtx_cost (args
[i
].value
, SET
) > 2
1652 #ifdef SMALL_REGISTER_CLASSES
1653 && ((SMALL_REGISTER_CLASSES
&& reg_parm_seen
)
1654 || preserve_subexpressions_p ())
1656 && preserve_subexpressions_p ()
1659 args
[i
].value
= copy_to_mode_reg (args
[i
].mode
, args
[i
].value
);
1662 #if defined(ACCUMULATE_OUTGOING_ARGS) && defined(REG_PARM_STACK_SPACE)
1663 /* The argument list is the property of the called routine and it
1664 may clobber it. If the fixed area has been used for previous
1665 parameters, we must save and restore it.
1667 Here we compute the boundary of the that needs to be saved, if any. */
1669 #ifdef ARGS_GROW_DOWNWARD
1670 for (i
= 0; i
< reg_parm_stack_space
+ 1; i
++)
1672 for (i
= 0; i
< reg_parm_stack_space
; i
++)
1675 if (i
>= highest_outgoing_arg_in_use
1676 || stack_usage_map
[i
] == 0)
1679 if (low_to_save
== -1)
1685 if (low_to_save
>= 0)
1687 int num_to_save
= high_to_save
- low_to_save
+ 1;
1688 enum machine_mode save_mode
1689 = mode_for_size (num_to_save
* BITS_PER_UNIT
, MODE_INT
, 1);
1692 /* If we don't have the required alignment, must do this in BLKmode. */
1693 if ((low_to_save
& (MIN (GET_MODE_SIZE (save_mode
),
1694 BIGGEST_ALIGNMENT
/ UNITS_PER_WORD
) - 1)))
1695 save_mode
= BLKmode
;
1697 stack_area
= gen_rtx (MEM
, save_mode
,
1698 memory_address (save_mode
,
1700 #ifdef ARGS_GROW_DOWNWARD
1701 plus_constant (argblock
,
1704 plus_constant (argblock
,
1708 if (save_mode
== BLKmode
)
1710 save_area
= assign_stack_temp (BLKmode
, num_to_save
, 0);
1711 MEM_IN_STRUCT_P (save_area
) = 0;
1712 emit_block_move (validize_mem (save_area
), stack_area
,
1713 GEN_INT (num_to_save
),
1714 PARM_BOUNDARY
/ BITS_PER_UNIT
);
1718 save_area
= gen_reg_rtx (save_mode
);
1719 emit_move_insn (save_area
, stack_area
);
1725 /* Now store (and compute if necessary) all non-register parms.
1726 These come before register parms, since they can require block-moves,
1727 which could clobber the registers used for register parms.
1728 Parms which have partial registers are not stored here,
1729 but we do preallocate space here if they want that. */
1731 for (i
= 0; i
< num_actuals
; i
++)
1732 if (args
[i
].reg
== 0 || args
[i
].pass_on_stack
)
1733 store_one_arg (&args
[i
], argblock
, may_be_alloca
,
1734 args_size
.var
!= 0, fndecl
, reg_parm_stack_space
);
1736 /* If we have a parm that is passed in registers but not in memory
1737 and whose alignment does not permit a direct copy into registers,
1738 make a group of pseudos that correspond to each register that we
1741 if (STRICT_ALIGNMENT
)
1742 for (i
= 0; i
< num_actuals
; i
++)
1743 if (args
[i
].reg
!= 0 && ! args
[i
].pass_on_stack
1744 && args
[i
].mode
== BLKmode
1745 && (TYPE_ALIGN (TREE_TYPE (args
[i
].tree_value
))
1746 < MIN (BIGGEST_ALIGNMENT
, BITS_PER_WORD
)))
1748 int bytes
= int_size_in_bytes (TREE_TYPE (args
[i
].tree_value
));
1749 int big_endian_correction
= 0;
1751 args
[i
].n_aligned_regs
1752 = args
[i
].partial
? args
[i
].partial
1753 : (bytes
+ (UNITS_PER_WORD
- 1)) / UNITS_PER_WORD
;
1755 args
[i
].aligned_regs
= (rtx
*) alloca (sizeof (rtx
)
1756 * args
[i
].n_aligned_regs
);
1758 /* Structures smaller than a word are aligned to the least
1759 significant byte (to the right). On a BYTES_BIG_ENDIAN machine,
1760 this means we must skip the empty high order bytes when
1761 calculating the bit offset. */
1762 if (BYTES_BIG_ENDIAN
&& bytes
< UNITS_PER_WORD
)
1763 big_endian_correction
= (BITS_PER_WORD
- (bytes
* BITS_PER_UNIT
));
1765 for (j
= 0; j
< args
[i
].n_aligned_regs
; j
++)
1767 rtx reg
= gen_reg_rtx (word_mode
);
1768 rtx word
= operand_subword_force (args
[i
].value
, j
, BLKmode
);
1769 int bitsize
= TYPE_ALIGN (TREE_TYPE (args
[i
].tree_value
));
1772 args
[i
].aligned_regs
[j
] = reg
;
1774 /* Clobber REG and move each partword into it. Ensure we don't
1775 go past the end of the structure. Note that the loop below
1776 works because we've already verified that padding
1777 and endianness are compatible.
1779 We use to emit a clobber here but that doesn't let later
1780 passes optimize the instructions we emit. By storing 0 into
1781 the register later passes know the first AND to zero out the
1782 bitfield being set in the register is unnecessary. The store
1783 of 0 will be deleted as will at least the first AND. */
1785 emit_move_insn (reg
, const0_rtx
);
1788 bitpos
< BITS_PER_WORD
&& bytes
> 0;
1789 bitpos
+= bitsize
, bytes
-= bitsize
/ BITS_PER_UNIT
)
1791 int xbitpos
= bitpos
+ big_endian_correction
;
1793 store_bit_field (reg
, bitsize
, xbitpos
, word_mode
,
1794 extract_bit_field (word
, bitsize
, bitpos
, 1,
1795 NULL_RTX
, word_mode
,
1797 bitsize
/ BITS_PER_UNIT
,
1799 bitsize
/ BITS_PER_UNIT
, BITS_PER_WORD
);
1804 /* Now store any partially-in-registers parm.
1805 This is the last place a block-move can happen. */
1807 for (i
= 0; i
< num_actuals
; i
++)
1808 if (args
[i
].partial
!= 0 && ! args
[i
].pass_on_stack
)
1809 store_one_arg (&args
[i
], argblock
, may_be_alloca
,
1810 args_size
.var
!= 0, fndecl
, reg_parm_stack_space
);
1812 #ifndef PUSH_ARGS_REVERSED
1813 #ifdef STACK_BOUNDARY
1814 /* If we pushed args in forward order, perform stack alignment
1815 after pushing the last arg. */
1817 anti_adjust_stack (GEN_INT (args_size
.constant
1818 - original_args_size
.constant
));
1822 /* If register arguments require space on the stack and stack space
1823 was not preallocated, allocate stack space here for arguments
1824 passed in registers. */
1825 #if ! defined(ACCUMULATE_OUTGOING_ARGS) && defined(OUTGOING_REG_PARM_STACK_SPACE)
1826 if (must_preallocate
== 0 && reg_parm_stack_space
> 0)
1827 anti_adjust_stack (GEN_INT (reg_parm_stack_space
));
1830 /* Pass the function the address in which to return a structure value. */
1831 if (structure_value_addr
&& ! structure_value_addr_parm
)
1833 emit_move_insn (struct_value_rtx
,
1835 force_operand (structure_value_addr
,
1837 if (GET_CODE (struct_value_rtx
) == REG
)
1838 use_reg (&call_fusage
, struct_value_rtx
);
1841 funexp
= prepare_call_address (funexp
, fndecl
, &call_fusage
, reg_parm_seen
);
1843 /* Now do the register loads required for any wholly-register parms or any
1844 parms which are passed both on the stack and in a register. Their
1845 expressions were already evaluated.
1847 Mark all register-parms as living through the call, putting these USE
1848 insns in the CALL_INSN_FUNCTION_USAGE field. */
1850 for (i
= 0; i
< num_actuals
; i
++)
1852 rtx reg
= args
[i
].reg
;
1853 int partial
= args
[i
].partial
;
1858 /* Set to non-negative if must move a word at a time, even if just
1859 one word (e.g, partial == 1 && mode == DFmode). Set to -1 if
1860 we just use a normal move insn. This value can be zero if the
1861 argument is a zero size structure with no fields. */
1862 nregs
= (partial
? partial
1863 : (TYPE_MODE (TREE_TYPE (args
[i
].tree_value
)) == BLKmode
1864 ? ((int_size_in_bytes (TREE_TYPE (args
[i
].tree_value
))
1865 + (UNITS_PER_WORD
- 1)) / UNITS_PER_WORD
)
1868 /* Handle calls that pass values in multiple non-contiguous
1869 locations. The Irix 6 ABI has examples of this. */
1871 if (GET_CODE (reg
) == PARALLEL
)
1872 emit_group_load (reg
, args
[i
].value
);
1874 /* If simple case, just do move. If normal partial, store_one_arg
1875 has already loaded the register for us. In all other cases,
1876 load the register(s) from memory. */
1878 else if (nregs
== -1)
1879 emit_move_insn (reg
, args
[i
].value
);
1881 /* If we have pre-computed the values to put in the registers in
1882 the case of non-aligned structures, copy them in now. */
1884 else if (args
[i
].n_aligned_regs
!= 0)
1885 for (j
= 0; j
< args
[i
].n_aligned_regs
; j
++)
1886 emit_move_insn (gen_rtx (REG
, word_mode
, REGNO (reg
) + j
),
1887 args
[i
].aligned_regs
[j
]);
1889 else if (partial
== 0 || args
[i
].pass_on_stack
)
1890 move_block_to_reg (REGNO (reg
),
1891 validize_mem (args
[i
].value
), nregs
,
1894 /* Handle calls that pass values in multiple non-contiguous
1895 locations. The Irix 6 ABI has examples of this. */
1896 if (GET_CODE (reg
) == PARALLEL
)
1897 use_group_regs (&call_fusage
, reg
);
1898 else if (nregs
== -1)
1899 use_reg (&call_fusage
, reg
);
1901 use_regs (&call_fusage
, REGNO (reg
), nregs
== 0 ? 1 : nregs
);
1905 /* Perform postincrements before actually calling the function. */
1908 /* All arguments and registers used for the call must be set up by now! */
1910 /* Generate the actual call instruction. */
1911 emit_call_1 (funexp
, fndecl
, funtype
, args_size
.constant
, struct_value_size
,
1912 FUNCTION_ARG (args_so_far
, VOIDmode
, void_type_node
, 1),
1913 valreg
, old_inhibit_defer_pop
, call_fusage
, is_const
);
1915 /* If call is cse'able, make appropriate pair of reg-notes around it.
1916 Test valreg so we don't crash; may safely ignore `const'
1917 if return type is void. Disable for PARALLEL return values, because
1918 we have no way to move such values into a pseudo register. */
1919 if (is_const
&& valreg
!= 0 && GET_CODE (valreg
) != PARALLEL
)
1922 rtx temp
= gen_reg_rtx (GET_MODE (valreg
));
1925 /* Construct an "equal form" for the value which mentions all the
1926 arguments in order as well as the function name. */
1927 #ifdef PUSH_ARGS_REVERSED
1928 for (i
= 0; i
< num_actuals
; i
++)
1929 note
= gen_rtx (EXPR_LIST
, VOIDmode
, args
[i
].initial_value
, note
);
1931 for (i
= num_actuals
- 1; i
>= 0; i
--)
1932 note
= gen_rtx (EXPR_LIST
, VOIDmode
, args
[i
].initial_value
, note
);
1934 note
= gen_rtx (EXPR_LIST
, VOIDmode
, funexp
, note
);
1936 insns
= get_insns ();
1939 emit_libcall_block (insns
, temp
, valreg
, note
);
1945 /* Otherwise, just write out the sequence without a note. */
1946 rtx insns
= get_insns ();
1952 /* For calls to `setjmp', etc., inform flow.c it should complain
1953 if nonvolatile values are live. */
1957 emit_note (name
, NOTE_INSN_SETJMP
);
1958 current_function_calls_setjmp
= 1;
1962 current_function_calls_longjmp
= 1;
1964 /* Notice functions that cannot return.
1965 If optimizing, insns emitted below will be dead.
1966 If not optimizing, they will exist, which is useful
1967 if the user uses the `return' command in the debugger. */
1969 if (is_volatile
|| is_longjmp
)
1972 /* If value type not void, return an rtx for the value. */
1974 /* If there are cleanups to be called, don't use a hard reg as target.
1975 We need to double check this and see if it matters anymore. */
1976 if (any_pending_cleanups ()
1977 && target
&& REG_P (target
)
1978 && REGNO (target
) < FIRST_PSEUDO_REGISTER
)
1981 if (TYPE_MODE (TREE_TYPE (exp
)) == VOIDmode
1984 target
= const0_rtx
;
1986 else if (structure_value_addr
)
1988 if (target
== 0 || GET_CODE (target
) != MEM
)
1990 target
= gen_rtx (MEM
, TYPE_MODE (TREE_TYPE (exp
)),
1991 memory_address (TYPE_MODE (TREE_TYPE (exp
)),
1992 structure_value_addr
));
1993 MEM_IN_STRUCT_P (target
) = AGGREGATE_TYPE_P (TREE_TYPE (exp
));
1996 else if (pcc_struct_value
)
2000 /* We used leave the value in the location that it is
2001 returned in, but that causes problems if it is used more
2002 than once in one expression. Rather than trying to track
2003 when a copy is required, we always copy when TARGET is
2004 not specified. This calling sequence is only used on
2005 a few machines and TARGET is usually nonzero. */
2006 if (TYPE_MODE (TREE_TYPE (exp
)) == BLKmode
)
2008 target
= assign_stack_temp (BLKmode
,
2009 int_size_in_bytes (TREE_TYPE (exp
)),
2012 MEM_IN_STRUCT_P (target
) = AGGREGATE_TYPE_P (TREE_TYPE (exp
));
2014 /* Save this temp slot around the pop below. */
2015 preserve_temp_slots (target
);
2018 target
= gen_reg_rtx (TYPE_MODE (TREE_TYPE (exp
)));
2021 if (TYPE_MODE (TREE_TYPE (exp
)) != BLKmode
)
2022 emit_move_insn (target
, gen_rtx (MEM
, TYPE_MODE (TREE_TYPE (exp
)),
2023 copy_to_reg (valreg
)));
2025 emit_block_move (target
, gen_rtx (MEM
, BLKmode
, copy_to_reg (valreg
)),
2027 TYPE_ALIGN (TREE_TYPE (exp
)) / BITS_PER_UNIT
);
2029 /* Handle calls that return values in multiple non-contiguous locations.
2030 The Irix 6 ABI has examples of this. */
2031 else if (GET_CODE (valreg
) == PARALLEL
)
2035 int bytes
= int_size_in_bytes (TREE_TYPE (exp
));
2036 target
= assign_stack_temp (TYPE_MODE (TREE_TYPE (exp
)), bytes
, 0);
2037 MEM_IN_STRUCT_P (target
) = AGGREGATE_TYPE_P (TREE_TYPE (exp
));
2038 preserve_temp_slots (target
);
2041 emit_group_store (target
, valreg
);
2043 else if (target
&& GET_MODE (target
) == TYPE_MODE (TREE_TYPE (exp
))
2044 && GET_MODE (target
) == GET_MODE (valreg
))
2045 /* TARGET and VALREG cannot be equal at this point because the latter
2046 would not have REG_FUNCTION_VALUE_P true, while the former would if
2047 it were referring to the same register.
2049 If they refer to the same register, this move will be a no-op, except
2050 when function inlining is being done. */
2051 emit_move_insn (target
, valreg
);
2052 else if (TYPE_MODE (TREE_TYPE (exp
)) == BLKmode
)
2054 /* Some machines (the PA for example) want to return all small
2055 structures in registers regardless of the structure's alignment.
2057 Deal with them explicitly by copying from the return registers
2058 into the target MEM locations. */
2059 int bytes
= int_size_in_bytes (TREE_TYPE (exp
));
2060 int n_regs
= (bytes
+ UNITS_PER_WORD
- 1) / UNITS_PER_WORD
;
2062 enum machine_mode tmpmode
;
2064 int bitsize
= MIN (TYPE_ALIGN (TREE_TYPE (exp
)), BITS_PER_WORD
);
2065 int bitpos
, xbitpos
, big_endian_correction
= 0;
2069 target
= assign_stack_temp (BLKmode
, bytes
, 0);
2070 MEM_IN_STRUCT_P (target
) = AGGREGATE_TYPE_P (TREE_TYPE (exp
));
2071 preserve_temp_slots (target
);
2074 /* This code assumes valreg is at least a full word. If it isn't,
2075 copy it into a new pseudo which is a full word. */
2076 if (GET_MODE (valreg
) != BLKmode
2077 && GET_MODE_SIZE (GET_MODE (valreg
)) < UNITS_PER_WORD
)
2078 valreg
= convert_to_mode (word_mode
, valreg
,
2079 TREE_UNSIGNED (TREE_TYPE (exp
)));
2081 /* Structures whose size is not a multiple of a word are aligned
2082 to the least significant byte (to the right). On a BYTES_BIG_ENDIAN
2083 machine, this means we must skip the empty high order bytes when
2084 calculating the bit offset. */
2085 if (BYTES_BIG_ENDIAN
&& bytes
% UNITS_PER_WORD
)
2086 big_endian_correction
= (BITS_PER_WORD
- ((bytes
% UNITS_PER_WORD
)
2089 /* Copy the structure BITSIZE bites at a time.
2091 We could probably emit more efficient code for machines
2092 which do not use strict alignment, but it doesn't seem
2093 worth the effort at the current time. */
2094 for (bitpos
= 0, xbitpos
= big_endian_correction
;
2095 bitpos
< bytes
* BITS_PER_UNIT
;
2096 bitpos
+= bitsize
, xbitpos
+= bitsize
)
2099 /* We need a new source operand each time xbitpos is on a
2100 word boundary and when xbitpos == big_endian_correction
2101 (the first time through). */
2102 if (xbitpos
% BITS_PER_WORD
== 0
2103 || xbitpos
== big_endian_correction
)
2104 src
= operand_subword_force (valreg
,
2105 xbitpos
/ BITS_PER_WORD
,
2108 /* We need a new destination operand each time bitpos is on
2110 if (bitpos
% BITS_PER_WORD
== 0)
2111 dst
= operand_subword (target
, bitpos
/ BITS_PER_WORD
, 1, BLKmode
);
2113 /* Use xbitpos for the source extraction (right justified) and
2114 xbitpos for the destination store (left justified). */
2115 store_bit_field (dst
, bitsize
, bitpos
% BITS_PER_WORD
, word_mode
,
2116 extract_bit_field (src
, bitsize
,
2117 xbitpos
% BITS_PER_WORD
, 1,
2118 NULL_RTX
, word_mode
,
2120 bitsize
/ BITS_PER_UNIT
,
2122 bitsize
/ BITS_PER_UNIT
, BITS_PER_WORD
);
2126 target
= copy_to_reg (valreg
);
2128 #ifdef PROMOTE_FUNCTION_RETURN
2129 /* If we promoted this return value, make the proper SUBREG. TARGET
2130 might be const0_rtx here, so be careful. */
2131 if (GET_CODE (target
) == REG
2132 && TYPE_MODE (TREE_TYPE (exp
)) != BLKmode
2133 && GET_MODE (target
) != TYPE_MODE (TREE_TYPE (exp
)))
2135 tree type
= TREE_TYPE (exp
);
2136 int unsignedp
= TREE_UNSIGNED (type
);
2138 /* If we don't promote as expected, something is wrong. */
2139 if (GET_MODE (target
)
2140 != promote_mode (type
, TYPE_MODE (type
), &unsignedp
, 1))
2143 target
= gen_rtx (SUBREG
, TYPE_MODE (type
), target
, 0);
2144 SUBREG_PROMOTED_VAR_P (target
) = 1;
2145 SUBREG_PROMOTED_UNSIGNED_P (target
) = unsignedp
;
2149 /* If size of args is variable or this was a constructor call for a stack
2150 argument, restore saved stack-pointer value. */
2152 if (old_stack_level
)
2154 emit_stack_restore (SAVE_BLOCK
, old_stack_level
, NULL_RTX
);
2155 pending_stack_adjust
= old_pending_adj
;
2156 #ifdef ACCUMULATE_OUTGOING_ARGS
2157 stack_arg_under_construction
= old_stack_arg_under_construction
;
2158 highest_outgoing_arg_in_use
= initial_highest_arg_in_use
;
2159 stack_usage_map
= initial_stack_usage_map
;
2162 #ifdef ACCUMULATE_OUTGOING_ARGS
2165 #ifdef REG_PARM_STACK_SPACE
2168 enum machine_mode save_mode
= GET_MODE (save_area
);
2170 = gen_rtx (MEM
, save_mode
,
2171 memory_address (save_mode
,
2172 #ifdef ARGS_GROW_DOWNWARD
2173 plus_constant (argblock
, - high_to_save
)
2175 plus_constant (argblock
, low_to_save
)
2179 if (save_mode
!= BLKmode
)
2180 emit_move_insn (stack_area
, save_area
);
2182 emit_block_move (stack_area
, validize_mem (save_area
),
2183 GEN_INT (high_to_save
- low_to_save
+ 1),
2184 PARM_BOUNDARY
/ BITS_PER_UNIT
);
2188 /* If we saved any argument areas, restore them. */
2189 for (i
= 0; i
< num_actuals
; i
++)
2190 if (args
[i
].save_area
)
2192 enum machine_mode save_mode
= GET_MODE (args
[i
].save_area
);
2194 = gen_rtx (MEM
, save_mode
,
2195 memory_address (save_mode
,
2196 XEXP (args
[i
].stack_slot
, 0)));
2198 if (save_mode
!= BLKmode
)
2199 emit_move_insn (stack_area
, args
[i
].save_area
);
2201 emit_block_move (stack_area
, validize_mem (args
[i
].save_area
),
2202 GEN_INT (args
[i
].size
.constant
),
2203 PARM_BOUNDARY
/ BITS_PER_UNIT
);
2206 highest_outgoing_arg_in_use
= initial_highest_arg_in_use
;
2207 stack_usage_map
= initial_stack_usage_map
;
2211 /* If this was alloca, record the new stack level for nonlocal gotos.
2212 Check for the handler slots since we might not have a save area
2213 for non-local gotos. */
2215 if (may_be_alloca
&& nonlocal_goto_handler_slot
!= 0)
2216 emit_stack_save (SAVE_NONLOCAL
, &nonlocal_goto_stack_level
, NULL_RTX
);
2223 /* Output a library call to function FUN (a SYMBOL_REF rtx)
2224 (emitting the queue unless NO_QUEUE is nonzero),
2225 for a value of mode OUTMODE,
2226 with NARGS different arguments, passed as alternating rtx values
2227 and machine_modes to convert them to.
2228 The rtx values should have been passed through protect_from_queue already.
2230 NO_QUEUE will be true if and only if the library call is a `const' call
2231 which will be enclosed in REG_LIBCALL/REG_RETVAL notes; it is equivalent
2232 to the variable is_const in expand_call.
2234 NO_QUEUE must be true for const calls, because if it isn't, then
2235 any pending increment will be emitted between REG_LIBCALL/REG_RETVAL notes,
2236 and will be lost if the libcall sequence is optimized away.
2238 NO_QUEUE must be false for non-const calls, because if it isn't, the
2239 call insn will have its CONST_CALL_P bit set, and it will be incorrectly
2240 optimized. For instance, the instruction scheduler may incorrectly
2241 move memory references across the non-const call. */
2244 emit_library_call
VPROTO((rtx orgfun
, int no_queue
, enum machine_mode outmode
,
2250 enum machine_mode outmode
;
2254 /* Total size in bytes of all the stack-parms scanned so far. */
2255 struct args_size args_size
;
2256 /* Size of arguments before any adjustments (such as rounding). */
2257 struct args_size original_args_size
;
2258 register int argnum
;
2263 CUMULATIVE_ARGS args_so_far
;
2264 struct arg
{ rtx value
; enum machine_mode mode
; rtx reg
; int partial
;
2265 struct args_size offset
; struct args_size size
; rtx save_area
; };
2267 int old_inhibit_defer_pop
= inhibit_defer_pop
;
2268 rtx call_fusage
= 0;
2269 /* Size of the stack reserved for parameter registers. */
2270 int reg_parm_stack_space
= 0;
2271 #if defined(ACCUMULATE_OUTGOING_ARGS) && defined(REG_PARM_STACK_SPACE)
2272 /* Define the boundary of the register parm stack space that needs to be
2274 int low_to_save
= -1, high_to_save
;
2275 rtx save_area
= 0; /* Place that it is saved */
2278 #ifdef ACCUMULATE_OUTGOING_ARGS
2279 int initial_highest_arg_in_use
= highest_outgoing_arg_in_use
;
2280 char *initial_stack_usage_map
= stack_usage_map
;
2284 #ifdef REG_PARM_STACK_SPACE
2285 #ifdef MAYBE_REG_PARM_STACK_SPACE
2286 reg_parm_stack_space
= MAYBE_REG_PARM_STACK_SPACE
;
2288 reg_parm_stack_space
= REG_PARM_STACK_SPACE (fndecl
);
2292 VA_START (p
, nargs
);
2295 orgfun
= va_arg (p
, rtx
);
2296 no_queue
= va_arg (p
, int);
2297 outmode
= va_arg (p
, enum machine_mode
);
2298 nargs
= va_arg (p
, int);
2303 /* Copy all the libcall-arguments out of the varargs data
2304 and into a vector ARGVEC.
2306 Compute how to pass each argument. We only support a very small subset
2307 of the full argument passing conventions to limit complexity here since
2308 library functions shouldn't have many args. */
2310 argvec
= (struct arg
*) alloca (nargs
* sizeof (struct arg
));
2311 bzero ((char *) argvec
, nargs
* sizeof (struct arg
));
2314 INIT_CUMULATIVE_ARGS (args_so_far
, NULL_TREE
, fun
, 0);
2316 args_size
.constant
= 0;
2321 for (count
= 0; count
< nargs
; count
++)
2323 rtx val
= va_arg (p
, rtx
);
2324 enum machine_mode mode
= va_arg (p
, enum machine_mode
);
2326 /* We cannot convert the arg value to the mode the library wants here;
2327 must do it earlier where we know the signedness of the arg. */
2329 || (GET_MODE (val
) != mode
&& GET_MODE (val
) != VOIDmode
))
2332 /* On some machines, there's no way to pass a float to a library fcn.
2333 Pass it as a double instead. */
2334 #ifdef LIBGCC_NEEDS_DOUBLE
2335 if (LIBGCC_NEEDS_DOUBLE
&& mode
== SFmode
)
2336 val
= convert_modes (DFmode
, SFmode
, val
, 0), mode
= DFmode
;
2339 /* There's no need to call protect_from_queue, because
2340 either emit_move_insn or emit_push_insn will do that. */
2342 /* Make sure it is a reasonable operand for a move or push insn. */
2343 if (GET_CODE (val
) != REG
&& GET_CODE (val
) != MEM
2344 && ! (CONSTANT_P (val
) && LEGITIMATE_CONSTANT_P (val
)))
2345 val
= force_operand (val
, NULL_RTX
);
2347 #ifdef FUNCTION_ARG_PASS_BY_REFERENCE
2348 if (FUNCTION_ARG_PASS_BY_REFERENCE (args_so_far
, mode
, NULL_TREE
, 1))
2350 /* We do not support FUNCTION_ARG_CALLEE_COPIES here since it can
2351 be viewed as just an efficiency improvement. */
2352 rtx slot
= assign_stack_temp (mode
, GET_MODE_SIZE (mode
), 0);
2353 emit_move_insn (slot
, val
);
2354 val
= force_operand (XEXP (slot
, 0), NULL_RTX
);
2359 argvec
[count
].value
= val
;
2360 argvec
[count
].mode
= mode
;
2362 argvec
[count
].reg
= FUNCTION_ARG (args_so_far
, mode
, NULL_TREE
, 1);
2363 if (argvec
[count
].reg
&& GET_CODE (argvec
[count
].reg
) == PARALLEL
)
2365 #ifdef FUNCTION_ARG_PARTIAL_NREGS
2366 argvec
[count
].partial
2367 = FUNCTION_ARG_PARTIAL_NREGS (args_so_far
, mode
, NULL_TREE
, 1);
2369 argvec
[count
].partial
= 0;
2372 locate_and_pad_parm (mode
, NULL_TREE
,
2373 argvec
[count
].reg
&& argvec
[count
].partial
== 0,
2374 NULL_TREE
, &args_size
, &argvec
[count
].offset
,
2375 &argvec
[count
].size
);
2377 if (argvec
[count
].size
.var
)
2380 #ifndef REG_PARM_STACK_SPACE
2381 if (argvec
[count
].partial
)
2382 argvec
[count
].size
.constant
-= argvec
[count
].partial
* UNITS_PER_WORD
;
2385 if (argvec
[count
].reg
== 0 || argvec
[count
].partial
!= 0
2386 #ifdef REG_PARM_STACK_SPACE
2390 args_size
.constant
+= argvec
[count
].size
.constant
;
2392 FUNCTION_ARG_ADVANCE (args_so_far
, mode
, (tree
) 0, 1);
2396 #ifdef FINAL_REG_PARM_STACK_SPACE
2397 reg_parm_stack_space
= FINAL_REG_PARM_STACK_SPACE (args_size
.constant
,
2401 /* If this machine requires an external definition for library
2402 functions, write one out. */
2403 assemble_external_libcall (fun
);
2405 original_args_size
= args_size
;
2406 #ifdef STACK_BOUNDARY
2407 args_size
.constant
= (((args_size
.constant
+ (STACK_BYTES
- 1))
2408 / STACK_BYTES
) * STACK_BYTES
);
2411 #ifdef REG_PARM_STACK_SPACE
2412 args_size
.constant
= MAX (args_size
.constant
,
2413 reg_parm_stack_space
);
2414 #ifndef OUTGOING_REG_PARM_STACK_SPACE
2415 args_size
.constant
-= reg_parm_stack_space
;
2419 if (args_size
.constant
> current_function_outgoing_args_size
)
2420 current_function_outgoing_args_size
= args_size
.constant
;
2422 #ifdef ACCUMULATE_OUTGOING_ARGS
2423 /* Since the stack pointer will never be pushed, it is possible for
2424 the evaluation of a parm to clobber something we have already
2425 written to the stack. Since most function calls on RISC machines
2426 do not use the stack, this is uncommon, but must work correctly.
2428 Therefore, we save any area of the stack that was already written
2429 and that we are using. Here we set up to do this by making a new
2430 stack usage map from the old one.
2432 Another approach might be to try to reorder the argument
2433 evaluations to avoid this conflicting stack usage. */
2435 needed
= args_size
.constant
;
2436 #if defined(REG_PARM_STACK_SPACE) && ! defined(OUTGOING_REG_PARM_STACK_SPACE)
2437 /* Since we will be writing into the entire argument area, the
2438 map must be allocated for its entire size, not just the part that
2439 is the responsibility of the caller. */
2440 needed
+= reg_parm_stack_space
;
2443 #ifdef ARGS_GROW_DOWNWARD
2444 highest_outgoing_arg_in_use
= MAX (initial_highest_arg_in_use
,
2447 highest_outgoing_arg_in_use
= MAX (initial_highest_arg_in_use
,
2450 stack_usage_map
= (char *) alloca (highest_outgoing_arg_in_use
);
2452 if (initial_highest_arg_in_use
)
2453 bcopy (initial_stack_usage_map
, stack_usage_map
,
2454 initial_highest_arg_in_use
);
2456 if (initial_highest_arg_in_use
!= highest_outgoing_arg_in_use
)
2457 bzero (&stack_usage_map
[initial_highest_arg_in_use
],
2458 highest_outgoing_arg_in_use
- initial_highest_arg_in_use
);
2461 /* The address of the outgoing argument list must not be copied to a
2462 register here, because argblock would be left pointing to the
2463 wrong place after the call to allocate_dynamic_stack_space below.
2466 argblock
= virtual_outgoing_args_rtx
;
2467 #else /* not ACCUMULATE_OUTGOING_ARGS */
2468 #ifndef PUSH_ROUNDING
2469 argblock
= push_block (GEN_INT (args_size
.constant
), 0, 0);
2473 #ifdef PUSH_ARGS_REVERSED
2474 #ifdef STACK_BOUNDARY
2475 /* If we push args individually in reverse order, perform stack alignment
2476 before the first push (the last arg). */
2478 anti_adjust_stack (GEN_INT (args_size
.constant
2479 - original_args_size
.constant
));
2483 #ifdef PUSH_ARGS_REVERSED
2491 #if defined(ACCUMULATE_OUTGOING_ARGS) && defined(REG_PARM_STACK_SPACE)
2492 /* The argument list is the property of the called routine and it
2493 may clobber it. If the fixed area has been used for previous
2494 parameters, we must save and restore it.
2496 Here we compute the boundary of the that needs to be saved, if any. */
2498 #ifdef ARGS_GROW_DOWNWARD
2499 for (count
= 0; count
< reg_parm_stack_space
+ 1; count
++)
2501 for (count
= 0; count
< reg_parm_stack_space
; count
++)
2504 if (count
>= highest_outgoing_arg_in_use
2505 || stack_usage_map
[count
] == 0)
2508 if (low_to_save
== -1)
2509 low_to_save
= count
;
2511 high_to_save
= count
;
2514 if (low_to_save
>= 0)
2516 int num_to_save
= high_to_save
- low_to_save
+ 1;
2517 enum machine_mode save_mode
2518 = mode_for_size (num_to_save
* BITS_PER_UNIT
, MODE_INT
, 1);
2521 /* If we don't have the required alignment, must do this in BLKmode. */
2522 if ((low_to_save
& (MIN (GET_MODE_SIZE (save_mode
),
2523 BIGGEST_ALIGNMENT
/ UNITS_PER_WORD
) - 1)))
2524 save_mode
= BLKmode
;
2526 stack_area
= gen_rtx (MEM
, save_mode
,
2527 memory_address (save_mode
,
2529 #ifdef ARGS_GROW_DOWNWARD
2530 plus_constant (argblock
,
2533 plus_constant (argblock
,
2537 if (save_mode
== BLKmode
)
2539 save_area
= assign_stack_temp (BLKmode
, num_to_save
, 0);
2540 MEM_IN_STRUCT_P (save_area
) = 0;
2541 emit_block_move (validize_mem (save_area
), stack_area
,
2542 GEN_INT (num_to_save
),
2543 PARM_BOUNDARY
/ BITS_PER_UNIT
);
2547 save_area
= gen_reg_rtx (save_mode
);
2548 emit_move_insn (save_area
, stack_area
);
2553 /* Push the args that need to be pushed. */
2555 for (count
= 0; count
< nargs
; count
++, argnum
+= inc
)
2557 register enum machine_mode mode
= argvec
[argnum
].mode
;
2558 register rtx val
= argvec
[argnum
].value
;
2559 rtx reg
= argvec
[argnum
].reg
;
2560 int partial
= argvec
[argnum
].partial
;
2561 int lower_bound
, upper_bound
, i
;
2563 if (! (reg
!= 0 && partial
== 0))
2565 #ifdef ACCUMULATE_OUTGOING_ARGS
2566 /* If this is being stored into a pre-allocated, fixed-size, stack
2567 area, save any previous data at that location. */
2569 #ifdef ARGS_GROW_DOWNWARD
2570 /* stack_slot is negative, but we want to index stack_usage_map
2571 with positive values. */
2572 upper_bound
= -argvec
[count
].offset
.constant
+ 1;
2573 lower_bound
= upper_bound
- argvec
[count
].size
.constant
;
2575 lower_bound
= argvec
[count
].offset
.constant
;
2576 upper_bound
= lower_bound
+ argvec
[count
].size
.constant
;
2579 for (i
= lower_bound
; i
< upper_bound
; i
++)
2580 if (stack_usage_map
[i
]
2581 #ifdef REG_PARM_STACK_SPACE
2582 /* Don't store things in the fixed argument area at this point;
2583 it has already been saved. */
2584 && i
> reg_parm_stack_space
2589 if (i
!= upper_bound
)
2591 /* We need to make a save area. See what mode we can make it. */
2592 enum machine_mode save_mode
2593 = mode_for_size (argvec
[count
].size
.constant
* BITS_PER_UNIT
,
2596 = gen_rtx (MEM
, save_mode
,
2597 memory_address (save_mode
, plus_constant (argblock
,
2598 argvec
[count
].offset
.constant
)));
2599 argvec
[count
].save_area
= gen_reg_rtx (save_mode
);
2600 emit_move_insn (argvec
[count
].save_area
, stack_area
);
2603 emit_push_insn (val
, mode
, NULL_TREE
, NULL_RTX
, 0, partial
, reg
, 0,
2604 argblock
, GEN_INT (argvec
[count
].offset
.constant
));
2606 #ifdef ACCUMULATE_OUTGOING_ARGS
2607 /* Now mark the segment we just used. */
2608 for (i
= lower_bound
; i
< upper_bound
; i
++)
2609 stack_usage_map
[i
] = 1;
2616 #ifndef PUSH_ARGS_REVERSED
2617 #ifdef STACK_BOUNDARY
2618 /* If we pushed args in forward order, perform stack alignment
2619 after pushing the last arg. */
2621 anti_adjust_stack (GEN_INT (args_size
.constant
2622 - original_args_size
.constant
));
2626 #ifdef PUSH_ARGS_REVERSED
2632 fun
= prepare_call_address (fun
, NULL_TREE
, &call_fusage
, 0);
2634 /* Now load any reg parms into their regs. */
2636 for (count
= 0; count
< nargs
; count
++, argnum
+= inc
)
2638 register enum machine_mode mode
= argvec
[argnum
].mode
;
2639 register rtx val
= argvec
[argnum
].value
;
2640 rtx reg
= argvec
[argnum
].reg
;
2641 int partial
= argvec
[argnum
].partial
;
2643 if (reg
!= 0 && partial
== 0)
2644 emit_move_insn (reg
, val
);
2648 /* For version 1.37, try deleting this entirely. */
2652 /* Any regs containing parms remain in use through the call. */
2653 for (count
= 0; count
< nargs
; count
++)
2654 if (argvec
[count
].reg
!= 0)
2655 use_reg (&call_fusage
, argvec
[count
].reg
);
2657 /* Don't allow popping to be deferred, since then
2658 cse'ing of library calls could delete a call and leave the pop. */
2661 /* We pass the old value of inhibit_defer_pop + 1 to emit_call_1, which
2662 will set inhibit_defer_pop to that value. */
2664 /* The return type is needed to decide how many bytes the function pops.
2665 Signedness plays no role in that, so for simplicity, we pretend it's
2666 always signed. We also assume that the list of arguments passed has
2667 no impact, so we pretend it is unknown. */
2670 get_identifier (XSTR (orgfun
, 0)),
2671 build_function_type (outmode
== VOIDmode
? void_type_node
2672 : type_for_mode (outmode
, 0), NULL_TREE
),
2673 args_size
.constant
, 0,
2674 FUNCTION_ARG (args_so_far
, VOIDmode
, void_type_node
, 1),
2675 outmode
!= VOIDmode
? hard_libcall_value (outmode
) : NULL_RTX
,
2676 old_inhibit_defer_pop
+ 1, call_fusage
, no_queue
);
2680 /* Now restore inhibit_defer_pop to its actual original value. */
2683 #ifdef ACCUMULATE_OUTGOING_ARGS
2684 #ifdef REG_PARM_STACK_SPACE
2687 enum machine_mode save_mode
= GET_MODE (save_area
);
2689 = gen_rtx (MEM
, save_mode
,
2690 memory_address (save_mode
,
2691 #ifdef ARGS_GROW_DOWNWARD
2692 plus_constant (argblock
, - high_to_save
)
2694 plus_constant (argblock
, low_to_save
)
2698 if (save_mode
!= BLKmode
)
2699 emit_move_insn (stack_area
, save_area
);
2701 emit_block_move (stack_area
, validize_mem (save_area
),
2702 GEN_INT (high_to_save
- low_to_save
+ 1),
2703 PARM_BOUNDARY
/ BITS_PER_UNIT
);
2707 /* If we saved any argument areas, restore them. */
2708 for (count
= 0; count
< nargs
; count
++)
2709 if (argvec
[count
].save_area
)
2711 enum machine_mode save_mode
= GET_MODE (argvec
[count
].save_area
);
2713 = gen_rtx (MEM
, save_mode
,
2714 memory_address (save_mode
, plus_constant (argblock
,
2715 argvec
[count
].offset
.constant
)));
2717 emit_move_insn (stack_area
, argvec
[count
].save_area
);
2720 highest_outgoing_arg_in_use
= initial_highest_arg_in_use
;
2721 stack_usage_map
= initial_stack_usage_map
;
2726 /* Like emit_library_call except that an extra argument, VALUE,
2727 comes second and says where to store the result.
2728 (If VALUE is zero, this function chooses a convenient way
2729 to return the value.
2731 This function returns an rtx for where the value is to be found.
2732 If VALUE is nonzero, VALUE is returned. */
2735 emit_library_call_value
VPROTO((rtx orgfun
, rtx value
, int no_queue
,
2736 enum machine_mode outmode
, int nargs
, ...))
2742 enum machine_mode outmode
;
2746 /* Total size in bytes of all the stack-parms scanned so far. */
2747 struct args_size args_size
;
2748 /* Size of arguments before any adjustments (such as rounding). */
2749 struct args_size original_args_size
;
2750 register int argnum
;
2755 CUMULATIVE_ARGS args_so_far
;
2756 struct arg
{ rtx value
; enum machine_mode mode
; rtx reg
; int partial
;
2757 struct args_size offset
; struct args_size size
; rtx save_area
; };
2759 int old_inhibit_defer_pop
= inhibit_defer_pop
;
2760 rtx call_fusage
= 0;
2761 /* Size of the stack reserved for parameter registers. */
2762 int reg_parm_stack_space
= 0;
2764 int pcc_struct_value
= 0;
2765 int struct_value_size
= 0;
2769 #if defined(ACCUMULATE_OUTGOING_ARGS) && defined(REG_PARM_STACK_SPACE)
2770 /* Define the boundary of the register parm stack space that needs to be
2772 int low_to_save
= -1, high_to_save
;
2773 rtx save_area
= 0; /* Place that it is saved */
2776 #ifdef ACCUMULATE_OUTGOING_ARGS
2777 int initial_highest_arg_in_use
= highest_outgoing_arg_in_use
;
2778 char *initial_stack_usage_map
= stack_usage_map
;
2781 #ifdef REG_PARM_STACK_SPACE
2782 #ifdef MAYBE_REG_PARM_STACK_SPACE
2783 reg_parm_stack_space
= MAYBE_REG_PARM_STACK_SPACE
;
2785 reg_parm_stack_space
= REG_PARM_STACK_SPACE (fndecl
);
2789 VA_START (p
, nargs
);
2792 orgfun
= va_arg (p
, rtx
);
2793 value
= va_arg (p
, rtx
);
2794 no_queue
= va_arg (p
, int);
2795 outmode
= va_arg (p
, enum machine_mode
);
2796 nargs
= va_arg (p
, int);
2799 is_const
= no_queue
;
2802 /* If this kind of value comes back in memory,
2803 decide where in memory it should come back. */
2804 if (aggregate_value_p (type_for_mode (outmode
, 0)))
2806 #ifdef PCC_STATIC_STRUCT_RETURN
2808 = hard_function_value (build_pointer_type (type_for_mode (outmode
, 0)),
2810 mem_value
= gen_rtx (MEM
, outmode
, pointer_reg
);
2811 pcc_struct_value
= 1;
2813 value
= gen_reg_rtx (outmode
);
2814 #else /* not PCC_STATIC_STRUCT_RETURN */
2815 struct_value_size
= GET_MODE_SIZE (outmode
);
2816 if (value
!= 0 && GET_CODE (value
) == MEM
)
2819 mem_value
= assign_stack_temp (outmode
, GET_MODE_SIZE (outmode
), 0);
2822 /* This call returns a big structure. */
2826 /* ??? Unfinished: must pass the memory address as an argument. */
2828 /* Copy all the libcall-arguments out of the varargs data
2829 and into a vector ARGVEC.
2831 Compute how to pass each argument. We only support a very small subset
2832 of the full argument passing conventions to limit complexity here since
2833 library functions shouldn't have many args. */
2835 argvec
= (struct arg
*) alloca ((nargs
+ 1) * sizeof (struct arg
));
2836 bzero ((char *) argvec
, nargs
* sizeof (struct arg
));
2838 INIT_CUMULATIVE_ARGS (args_so_far
, NULL_TREE
, fun
, 0);
2840 args_size
.constant
= 0;
2847 /* If there's a structure value address to be passed,
2848 either pass it in the special place, or pass it as an extra argument. */
2849 if (mem_value
&& struct_value_rtx
== 0 && ! pcc_struct_value
)
2851 rtx addr
= XEXP (mem_value
, 0);
2854 /* Make sure it is a reasonable operand for a move or push insn. */
2855 if (GET_CODE (addr
) != REG
&& GET_CODE (addr
) != MEM
2856 && ! (CONSTANT_P (addr
) && LEGITIMATE_CONSTANT_P (addr
)))
2857 addr
= force_operand (addr
, NULL_RTX
);
2859 argvec
[count
].value
= addr
;
2860 argvec
[count
].mode
= Pmode
;
2861 argvec
[count
].partial
= 0;
2863 argvec
[count
].reg
= FUNCTION_ARG (args_so_far
, Pmode
, NULL_TREE
, 1);
2864 #ifdef FUNCTION_ARG_PARTIAL_NREGS
2865 if (FUNCTION_ARG_PARTIAL_NREGS (args_so_far
, Pmode
, NULL_TREE
, 1))
2869 locate_and_pad_parm (Pmode
, NULL_TREE
,
2870 argvec
[count
].reg
&& argvec
[count
].partial
== 0,
2871 NULL_TREE
, &args_size
, &argvec
[count
].offset
,
2872 &argvec
[count
].size
);
2875 if (argvec
[count
].reg
== 0 || argvec
[count
].partial
!= 0
2876 #ifdef REG_PARM_STACK_SPACE
2880 args_size
.constant
+= argvec
[count
].size
.constant
;
2882 FUNCTION_ARG_ADVANCE (args_so_far
, Pmode
, (tree
) 0, 1);
2887 for (; count
< nargs
; count
++)
2889 rtx val
= va_arg (p
, rtx
);
2890 enum machine_mode mode
= va_arg (p
, enum machine_mode
);
2892 /* We cannot convert the arg value to the mode the library wants here;
2893 must do it earlier where we know the signedness of the arg. */
2895 || (GET_MODE (val
) != mode
&& GET_MODE (val
) != VOIDmode
))
2898 /* On some machines, there's no way to pass a float to a library fcn.
2899 Pass it as a double instead. */
2900 #ifdef LIBGCC_NEEDS_DOUBLE
2901 if (LIBGCC_NEEDS_DOUBLE
&& mode
== SFmode
)
2902 val
= convert_modes (DFmode
, SFmode
, val
, 0), mode
= DFmode
;
2905 /* There's no need to call protect_from_queue, because
2906 either emit_move_insn or emit_push_insn will do that. */
2908 /* Make sure it is a reasonable operand for a move or push insn. */
2909 if (GET_CODE (val
) != REG
&& GET_CODE (val
) != MEM
2910 && ! (CONSTANT_P (val
) && LEGITIMATE_CONSTANT_P (val
)))
2911 val
= force_operand (val
, NULL_RTX
);
2913 #ifdef FUNCTION_ARG_PASS_BY_REFERENCE
2914 if (FUNCTION_ARG_PASS_BY_REFERENCE (args_so_far
, mode
, NULL_TREE
, 1))
2916 /* We do not support FUNCTION_ARG_CALLEE_COPIES here since it can
2917 be viewed as just an efficiency improvement. */
2918 rtx slot
= assign_stack_temp (mode
, GET_MODE_SIZE (mode
), 0);
2919 emit_move_insn (slot
, val
);
2920 val
= XEXP (slot
, 0);
2925 argvec
[count
].value
= val
;
2926 argvec
[count
].mode
= mode
;
2928 argvec
[count
].reg
= FUNCTION_ARG (args_so_far
, mode
, NULL_TREE
, 1);
2929 if (argvec
[count
].reg
&& GET_CODE (argvec
[count
].reg
) == PARALLEL
)
2931 #ifdef FUNCTION_ARG_PARTIAL_NREGS
2932 argvec
[count
].partial
2933 = FUNCTION_ARG_PARTIAL_NREGS (args_so_far
, mode
, NULL_TREE
, 1);
2935 argvec
[count
].partial
= 0;
2938 locate_and_pad_parm (mode
, NULL_TREE
,
2939 argvec
[count
].reg
&& argvec
[count
].partial
== 0,
2940 NULL_TREE
, &args_size
, &argvec
[count
].offset
,
2941 &argvec
[count
].size
);
2943 if (argvec
[count
].size
.var
)
2946 #ifndef REG_PARM_STACK_SPACE
2947 if (argvec
[count
].partial
)
2948 argvec
[count
].size
.constant
-= argvec
[count
].partial
* UNITS_PER_WORD
;
2951 if (argvec
[count
].reg
== 0 || argvec
[count
].partial
!= 0
2952 #ifdef REG_PARM_STACK_SPACE
2956 args_size
.constant
+= argvec
[count
].size
.constant
;
2958 FUNCTION_ARG_ADVANCE (args_so_far
, mode
, (tree
) 0, 1);
2962 #ifdef FINAL_REG_PARM_STACK_SPACE
2963 reg_parm_stack_space
= FINAL_REG_PARM_STACK_SPACE (args_size
.constant
,
2966 /* If this machine requires an external definition for library
2967 functions, write one out. */
2968 assemble_external_libcall (fun
);
2970 original_args_size
= args_size
;
2971 #ifdef STACK_BOUNDARY
2972 args_size
.constant
= (((args_size
.constant
+ (STACK_BYTES
- 1))
2973 / STACK_BYTES
) * STACK_BYTES
);
2976 #ifdef REG_PARM_STACK_SPACE
2977 args_size
.constant
= MAX (args_size
.constant
,
2978 reg_parm_stack_space
);
2979 #ifndef OUTGOING_REG_PARM_STACK_SPACE
2980 args_size
.constant
-= reg_parm_stack_space
;
2984 if (args_size
.constant
> current_function_outgoing_args_size
)
2985 current_function_outgoing_args_size
= args_size
.constant
;
2987 #ifdef ACCUMULATE_OUTGOING_ARGS
2988 /* Since the stack pointer will never be pushed, it is possible for
2989 the evaluation of a parm to clobber something we have already
2990 written to the stack. Since most function calls on RISC machines
2991 do not use the stack, this is uncommon, but must work correctly.
2993 Therefore, we save any area of the stack that was already written
2994 and that we are using. Here we set up to do this by making a new
2995 stack usage map from the old one.
2997 Another approach might be to try to reorder the argument
2998 evaluations to avoid this conflicting stack usage. */
3000 needed
= args_size
.constant
;
3001 #if defined(REG_PARM_STACK_SPACE) && ! defined(OUTGOING_REG_PARM_STACK_SPACE)
3002 /* Since we will be writing into the entire argument area, the
3003 map must be allocated for its entire size, not just the part that
3004 is the responsibility of the caller. */
3005 needed
+= reg_parm_stack_space
;
3008 #ifdef ARGS_GROW_DOWNWARD
3009 highest_outgoing_arg_in_use
= MAX (initial_highest_arg_in_use
,
3012 highest_outgoing_arg_in_use
= MAX (initial_highest_arg_in_use
,
3015 stack_usage_map
= (char *) alloca (highest_outgoing_arg_in_use
);
3017 if (initial_highest_arg_in_use
)
3018 bcopy (initial_stack_usage_map
, stack_usage_map
,
3019 initial_highest_arg_in_use
);
3021 if (initial_highest_arg_in_use
!= highest_outgoing_arg_in_use
)
3022 bzero (&stack_usage_map
[initial_highest_arg_in_use
],
3023 highest_outgoing_arg_in_use
- initial_highest_arg_in_use
);
3026 /* The address of the outgoing argument list must not be copied to a
3027 register here, because argblock would be left pointing to the
3028 wrong place after the call to allocate_dynamic_stack_space below.
3031 argblock
= virtual_outgoing_args_rtx
;
3032 #else /* not ACCUMULATE_OUTGOING_ARGS */
3033 #ifndef PUSH_ROUNDING
3034 argblock
= push_block (GEN_INT (args_size
.constant
), 0, 0);
3038 #ifdef PUSH_ARGS_REVERSED
3039 #ifdef STACK_BOUNDARY
3040 /* If we push args individually in reverse order, perform stack alignment
3041 before the first push (the last arg). */
3043 anti_adjust_stack (GEN_INT (args_size
.constant
3044 - original_args_size
.constant
));
3048 #ifdef PUSH_ARGS_REVERSED
3056 #if defined(ACCUMULATE_OUTGOING_ARGS) && defined(REG_PARM_STACK_SPACE)
3057 /* The argument list is the property of the called routine and it
3058 may clobber it. If the fixed area has been used for previous
3059 parameters, we must save and restore it.
3061 Here we compute the boundary of the that needs to be saved, if any. */
3063 #ifdef ARGS_GROW_DOWNWARD
3064 for (count
= 0; count
< reg_parm_stack_space
+ 1; count
++)
3066 for (count
= 0; count
< reg_parm_stack_space
; count
++)
3069 if (count
>= highest_outgoing_arg_in_use
3070 || stack_usage_map
[count
] == 0)
3073 if (low_to_save
== -1)
3074 low_to_save
= count
;
3076 high_to_save
= count
;
3079 if (low_to_save
>= 0)
3081 int num_to_save
= high_to_save
- low_to_save
+ 1;
3082 enum machine_mode save_mode
3083 = mode_for_size (num_to_save
* BITS_PER_UNIT
, MODE_INT
, 1);
3086 /* If we don't have the required alignment, must do this in BLKmode. */
3087 if ((low_to_save
& (MIN (GET_MODE_SIZE (save_mode
),
3088 BIGGEST_ALIGNMENT
/ UNITS_PER_WORD
) - 1)))
3089 save_mode
= BLKmode
;
3091 stack_area
= gen_rtx (MEM
, save_mode
,
3092 memory_address (save_mode
,
3094 #ifdef ARGS_GROW_DOWNWARD
3095 plus_constant (argblock
,
3098 plus_constant (argblock
,
3102 if (save_mode
== BLKmode
)
3104 save_area
= assign_stack_temp (BLKmode
, num_to_save
, 0);
3105 MEM_IN_STRUCT_P (save_area
) = 0;
3106 emit_block_move (validize_mem (save_area
), stack_area
,
3107 GEN_INT (num_to_save
),
3108 PARM_BOUNDARY
/ BITS_PER_UNIT
);
3112 save_area
= gen_reg_rtx (save_mode
);
3113 emit_move_insn (save_area
, stack_area
);
3118 /* Push the args that need to be pushed. */
3120 for (count
= 0; count
< nargs
; count
++, argnum
+= inc
)
3122 register enum machine_mode mode
= argvec
[argnum
].mode
;
3123 register rtx val
= argvec
[argnum
].value
;
3124 rtx reg
= argvec
[argnum
].reg
;
3125 int partial
= argvec
[argnum
].partial
;
3126 int lower_bound
, upper_bound
, i
;
3128 if (! (reg
!= 0 && partial
== 0))
3130 #ifdef ACCUMULATE_OUTGOING_ARGS
3131 /* If this is being stored into a pre-allocated, fixed-size, stack
3132 area, save any previous data at that location. */
3134 #ifdef ARGS_GROW_DOWNWARD
3135 /* stack_slot is negative, but we want to index stack_usage_map
3136 with positive values. */
3137 upper_bound
= -argvec
[count
].offset
.constant
+ 1;
3138 lower_bound
= upper_bound
- argvec
[count
].size
.constant
;
3140 lower_bound
= argvec
[count
].offset
.constant
;
3141 upper_bound
= lower_bound
+ argvec
[count
].size
.constant
;
3144 for (i
= lower_bound
; i
< upper_bound
; i
++)
3145 if (stack_usage_map
[i
]
3146 #ifdef REG_PARM_STACK_SPACE
3147 /* Don't store things in the fixed argument area at this point;
3148 it has already been saved. */
3149 && i
> reg_parm_stack_space
3154 if (i
!= upper_bound
)
3156 /* We need to make a save area. See what mode we can make it. */
3157 enum machine_mode save_mode
3158 = mode_for_size (argvec
[count
].size
.constant
* BITS_PER_UNIT
,
3161 = gen_rtx (MEM
, save_mode
,
3162 memory_address (save_mode
, plus_constant (argblock
,
3163 argvec
[count
].offset
.constant
)));
3164 argvec
[count
].save_area
= gen_reg_rtx (save_mode
);
3165 emit_move_insn (argvec
[count
].save_area
, stack_area
);
3168 emit_push_insn (val
, mode
, NULL_TREE
, NULL_RTX
, 0, partial
, reg
, 0,
3169 argblock
, GEN_INT (argvec
[count
].offset
.constant
));
3171 #ifdef ACCUMULATE_OUTGOING_ARGS
3172 /* Now mark the segment we just used. */
3173 for (i
= lower_bound
; i
< upper_bound
; i
++)
3174 stack_usage_map
[i
] = 1;
3181 #ifndef PUSH_ARGS_REVERSED
3182 #ifdef STACK_BOUNDARY
3183 /* If we pushed args in forward order, perform stack alignment
3184 after pushing the last arg. */
3186 anti_adjust_stack (GEN_INT (args_size
.constant
3187 - original_args_size
.constant
));
3191 #ifdef PUSH_ARGS_REVERSED
3197 fun
= prepare_call_address (fun
, NULL_TREE
, &call_fusage
, 0);
3199 /* Now load any reg parms into their regs. */
3201 for (count
= 0; count
< nargs
; count
++, argnum
+= inc
)
3203 register enum machine_mode mode
= argvec
[argnum
].mode
;
3204 register rtx val
= argvec
[argnum
].value
;
3205 rtx reg
= argvec
[argnum
].reg
;
3206 int partial
= argvec
[argnum
].partial
;
3208 if (reg
!= 0 && partial
== 0)
3209 emit_move_insn (reg
, val
);
3214 /* For version 1.37, try deleting this entirely. */
3219 /* Any regs containing parms remain in use through the call. */
3220 for (count
= 0; count
< nargs
; count
++)
3221 if (argvec
[count
].reg
!= 0)
3222 use_reg (&call_fusage
, argvec
[count
].reg
);
3224 /* Pass the function the address in which to return a structure value. */
3225 if (mem_value
!= 0 && struct_value_rtx
!= 0 && ! pcc_struct_value
)
3227 emit_move_insn (struct_value_rtx
,
3229 force_operand (XEXP (mem_value
, 0),
3231 if (GET_CODE (struct_value_rtx
) == REG
)
3232 use_reg (&call_fusage
, struct_value_rtx
);
3235 /* Don't allow popping to be deferred, since then
3236 cse'ing of library calls could delete a call and leave the pop. */
3239 /* We pass the old value of inhibit_defer_pop + 1 to emit_call_1, which
3240 will set inhibit_defer_pop to that value. */
3241 /* See the comment in emit_library_call about the function type we build
3245 get_identifier (XSTR (orgfun
, 0)),
3246 build_function_type (type_for_mode (outmode
, 0), NULL_TREE
),
3247 args_size
.constant
, struct_value_size
,
3248 FUNCTION_ARG (args_so_far
, VOIDmode
, void_type_node
, 1),
3249 mem_value
== 0 ? hard_libcall_value (outmode
) : NULL_RTX
,
3250 old_inhibit_defer_pop
+ 1, call_fusage
, is_const
);
3252 /* Now restore inhibit_defer_pop to its actual original value. */
3257 /* Copy the value to the right place. */
3258 if (outmode
!= VOIDmode
)
3264 if (value
!= mem_value
)
3265 emit_move_insn (value
, mem_value
);
3267 else if (value
!= 0)
3268 emit_move_insn (value
, hard_libcall_value (outmode
));
3270 value
= hard_libcall_value (outmode
);
3273 #ifdef ACCUMULATE_OUTGOING_ARGS
3274 #ifdef REG_PARM_STACK_SPACE
3277 enum machine_mode save_mode
= GET_MODE (save_area
);
3279 = gen_rtx (MEM
, save_mode
,
3280 memory_address (save_mode
,
3281 #ifdef ARGS_GROW_DOWNWARD
3282 plus_constant (argblock
, - high_to_save
)
3284 plus_constant (argblock
, low_to_save
)
3288 if (save_mode
!= BLKmode
)
3289 emit_move_insn (stack_area
, save_area
);
3291 emit_block_move (stack_area
, validize_mem (save_area
),
3292 GEN_INT (high_to_save
- low_to_save
+ 1),
3293 PARM_BOUNDARY
/ BITS_PER_UNIT
);
3297 /* If we saved any argument areas, restore them. */
3298 for (count
= 0; count
< nargs
; count
++)
3299 if (argvec
[count
].save_area
)
3301 enum machine_mode save_mode
= GET_MODE (argvec
[count
].save_area
);
3303 = gen_rtx (MEM
, save_mode
,
3304 memory_address (save_mode
, plus_constant (argblock
,
3305 argvec
[count
].offset
.constant
)));
3307 emit_move_insn (stack_area
, argvec
[count
].save_area
);
3310 highest_outgoing_arg_in_use
= initial_highest_arg_in_use
;
3311 stack_usage_map
= initial_stack_usage_map
;
3318 /* Return an rtx which represents a suitable home on the stack
3319 given TYPE, the type of the argument looking for a home.
3320 This is called only for BLKmode arguments.
3322 SIZE is the size needed for this target.
3323 ARGS_ADDR is the address of the bottom of the argument block for this call.
3324 OFFSET describes this parameter's offset into ARGS_ADDR. It is meaningless
3325 if this machine uses push insns. */
3328 target_for_arg (type
, size
, args_addr
, offset
)
3332 struct args_size offset
;
3335 rtx offset_rtx
= ARGS_SIZE_RTX (offset
);
3337 /* We do not call memory_address if possible,
3338 because we want to address as close to the stack
3339 as possible. For non-variable sized arguments,
3340 this will be stack-pointer relative addressing. */
3341 if (GET_CODE (offset_rtx
) == CONST_INT
)
3342 target
= plus_constant (args_addr
, INTVAL (offset_rtx
));
3345 /* I have no idea how to guarantee that this
3346 will work in the presence of register parameters. */
3347 target
= gen_rtx (PLUS
, Pmode
, args_addr
, offset_rtx
);
3348 target
= memory_address (QImode
, target
);
3351 return gen_rtx (MEM
, BLKmode
, target
);
3355 /* Store a single argument for a function call
3356 into the register or memory area where it must be passed.
3357 *ARG describes the argument value and where to pass it.
3359 ARGBLOCK is the address of the stack-block for all the arguments,
3360 or 0 on a machine where arguments are pushed individually.
3362 MAY_BE_ALLOCA nonzero says this could be a call to `alloca'
3363 so must be careful about how the stack is used.
3365 VARIABLE_SIZE nonzero says that this was a variable-sized outgoing
3366 argument stack. This is used if ACCUMULATE_OUTGOING_ARGS to indicate
3367 that we need not worry about saving and restoring the stack.
3369 FNDECL is the declaration of the function we are calling. */
3372 store_one_arg (arg
, argblock
, may_be_alloca
, variable_size
, fndecl
,
3373 reg_parm_stack_space
)
3374 struct arg_data
*arg
;
3379 int reg_parm_stack_space
;
3381 register tree pval
= arg
->tree_value
;
3385 int i
, lower_bound
, upper_bound
;
3387 if (TREE_CODE (pval
) == ERROR_MARK
)
3390 /* Push a new temporary level for any temporaries we make for
3394 #ifdef ACCUMULATE_OUTGOING_ARGS
3395 /* If this is being stored into a pre-allocated, fixed-size, stack area,
3396 save any previous data at that location. */
3397 if (argblock
&& ! variable_size
&& arg
->stack
)
3399 #ifdef ARGS_GROW_DOWNWARD
3400 /* stack_slot is negative, but we want to index stack_usage_map
3401 with positive values. */
3402 if (GET_CODE (XEXP (arg
->stack_slot
, 0)) == PLUS
)
3403 upper_bound
= -INTVAL (XEXP (XEXP (arg
->stack_slot
, 0), 1)) + 1;
3407 lower_bound
= upper_bound
- arg
->size
.constant
;
3409 if (GET_CODE (XEXP (arg
->stack_slot
, 0)) == PLUS
)
3410 lower_bound
= INTVAL (XEXP (XEXP (arg
->stack_slot
, 0), 1));
3414 upper_bound
= lower_bound
+ arg
->size
.constant
;
3417 for (i
= lower_bound
; i
< upper_bound
; i
++)
3418 if (stack_usage_map
[i
]
3419 #ifdef REG_PARM_STACK_SPACE
3420 /* Don't store things in the fixed argument area at this point;
3421 it has already been saved. */
3422 && i
> reg_parm_stack_space
3427 if (i
!= upper_bound
)
3429 /* We need to make a save area. See what mode we can make it. */
3430 enum machine_mode save_mode
3431 = mode_for_size (arg
->size
.constant
* BITS_PER_UNIT
, MODE_INT
, 1);
3433 = gen_rtx (MEM
, save_mode
,
3434 memory_address (save_mode
, XEXP (arg
->stack_slot
, 0)));
3436 if (save_mode
== BLKmode
)
3438 arg
->save_area
= assign_stack_temp (BLKmode
,
3439 arg
->size
.constant
, 0);
3440 MEM_IN_STRUCT_P (arg
->save_area
)
3441 = AGGREGATE_TYPE_P (TREE_TYPE (arg
->tree_value
));
3442 preserve_temp_slots (arg
->save_area
);
3443 emit_block_move (validize_mem (arg
->save_area
), stack_area
,
3444 GEN_INT (arg
->size
.constant
),
3445 PARM_BOUNDARY
/ BITS_PER_UNIT
);
3449 arg
->save_area
= gen_reg_rtx (save_mode
);
3450 emit_move_insn (arg
->save_area
, stack_area
);
3456 /* If this isn't going to be placed on both the stack and in registers,
3457 set up the register and number of words. */
3458 if (! arg
->pass_on_stack
)
3459 reg
= arg
->reg
, partial
= arg
->partial
;
3461 if (reg
!= 0 && partial
== 0)
3462 /* Being passed entirely in a register. We shouldn't be called in
3466 /* If this arg needs special alignment, don't load the registers
3468 if (arg
->n_aligned_regs
!= 0)
3471 /* If this is being passed partially in a register, we can't evaluate
3472 it directly into its stack slot. Otherwise, we can. */
3473 if (arg
->value
== 0)
3475 #ifdef ACCUMULATE_OUTGOING_ARGS
3476 /* stack_arg_under_construction is nonzero if a function argument is
3477 being evaluated directly into the outgoing argument list and
3478 expand_call must take special action to preserve the argument list
3479 if it is called recursively.
3481 For scalar function arguments stack_usage_map is sufficient to
3482 determine which stack slots must be saved and restored. Scalar
3483 arguments in general have pass_on_stack == 0.
3485 If this argument is initialized by a function which takes the
3486 address of the argument (a C++ constructor or a C function
3487 returning a BLKmode structure), then stack_usage_map is
3488 insufficient and expand_call must push the stack around the
3489 function call. Such arguments have pass_on_stack == 1.
3491 Note that it is always safe to set stack_arg_under_construction,
3492 but this generates suboptimal code if set when not needed. */
3494 if (arg
->pass_on_stack
)
3495 stack_arg_under_construction
++;
3497 arg
->value
= expand_expr (pval
,
3499 || TYPE_MODE (TREE_TYPE (pval
)) != arg
->mode
)
3500 ? NULL_RTX
: arg
->stack
,
3503 /* If we are promoting object (or for any other reason) the mode
3504 doesn't agree, convert the mode. */
3506 if (arg
->mode
!= TYPE_MODE (TREE_TYPE (pval
)))
3507 arg
->value
= convert_modes (arg
->mode
, TYPE_MODE (TREE_TYPE (pval
)),
3508 arg
->value
, arg
->unsignedp
);
3510 #ifdef ACCUMULATE_OUTGOING_ARGS
3511 if (arg
->pass_on_stack
)
3512 stack_arg_under_construction
--;
3516 /* Don't allow anything left on stack from computation
3517 of argument to alloca. */
3519 do_pending_stack_adjust ();
3521 if (arg
->value
== arg
->stack
)
3522 /* If the value is already in the stack slot, we are done. */
3524 else if (arg
->mode
!= BLKmode
)
3528 /* Argument is a scalar, not entirely passed in registers.
3529 (If part is passed in registers, arg->partial says how much
3530 and emit_push_insn will take care of putting it there.)
3532 Push it, and if its size is less than the
3533 amount of space allocated to it,
3534 also bump stack pointer by the additional space.
3535 Note that in C the default argument promotions
3536 will prevent such mismatches. */
3538 size
= GET_MODE_SIZE (arg
->mode
);
3539 /* Compute how much space the push instruction will push.
3540 On many machines, pushing a byte will advance the stack
3541 pointer by a halfword. */
3542 #ifdef PUSH_ROUNDING
3543 size
= PUSH_ROUNDING (size
);
3547 /* Compute how much space the argument should get:
3548 round up to a multiple of the alignment for arguments. */
3549 if (none
!= FUNCTION_ARG_PADDING (arg
->mode
, TREE_TYPE (pval
)))
3550 used
= (((size
+ PARM_BOUNDARY
/ BITS_PER_UNIT
- 1)
3551 / (PARM_BOUNDARY
/ BITS_PER_UNIT
))
3552 * (PARM_BOUNDARY
/ BITS_PER_UNIT
));
3554 /* This isn't already where we want it on the stack, so put it there.
3555 This can either be done with push or copy insns. */
3556 emit_push_insn (arg
->value
, arg
->mode
, TREE_TYPE (pval
), NULL_RTX
,
3557 0, partial
, reg
, used
- size
,
3558 argblock
, ARGS_SIZE_RTX (arg
->offset
));
3562 /* BLKmode, at least partly to be pushed. */
3564 register int excess
;
3567 /* Pushing a nonscalar.
3568 If part is passed in registers, PARTIAL says how much
3569 and emit_push_insn will take care of putting it there. */
3571 /* Round its size up to a multiple
3572 of the allocation unit for arguments. */
3574 if (arg
->size
.var
!= 0)
3577 size_rtx
= ARGS_SIZE_RTX (arg
->size
);
3581 /* PUSH_ROUNDING has no effect on us, because
3582 emit_push_insn for BLKmode is careful to avoid it. */
3583 excess
= (arg
->size
.constant
- int_size_in_bytes (TREE_TYPE (pval
))
3584 + partial
* UNITS_PER_WORD
);
3585 size_rtx
= expr_size (pval
);
3588 emit_push_insn (arg
->value
, arg
->mode
, TREE_TYPE (pval
), size_rtx
,
3589 TYPE_ALIGN (TREE_TYPE (pval
)) / BITS_PER_UNIT
, partial
,
3590 reg
, excess
, argblock
, ARGS_SIZE_RTX (arg
->offset
));
3594 /* Unless this is a partially-in-register argument, the argument is now
3597 ??? Note that this can change arg->value from arg->stack to
3598 arg->stack_slot and it matters when they are not the same.
3599 It isn't totally clear that this is correct in all cases. */
3601 arg
->value
= arg
->stack_slot
;
3603 /* Once we have pushed something, pops can't safely
3604 be deferred during the rest of the arguments. */
3607 /* ANSI doesn't require a sequence point here,
3608 but PCC has one, so this will avoid some problems. */
3611 /* Free any temporary slots made in processing this argument. Show
3612 that we might have taken the address of something and pushed that
3614 preserve_temp_slots (NULL_RTX
);
3618 #ifdef ACCUMULATE_OUTGOING_ARGS
3619 /* Now mark the segment we just used. */
3620 if (argblock
&& ! variable_size
&& arg
->stack
)
3621 for (i
= lower_bound
; i
< upper_bound
; i
++)
3622 stack_usage_map
[i
] = 1;