1 /* Convert function calls to rtl insns, for GNU C compiler.
2 Copyright (C) 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998
3 1999, 2000 Free Software Foundation, Inc.
5 This file is part of GNU CC.
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
30 #include "insn-flags.h"
37 #ifndef ACCUMULATE_OUTGOING_ARGS
38 #define ACCUMULATE_OUTGOING_ARGS 0
41 /* Supply a default definition for PUSH_ARGS. */
44 #define PUSH_ARGS !ACCUMULATE_OUTGOING_ARGS
50 #if !defined FUNCTION_OK_FOR_SIBCALL
51 #define FUNCTION_OK_FOR_SIBCALL(DECL) 1
54 #if !defined PREFERRED_STACK_BOUNDARY && defined STACK_BOUNDARY
55 #define PREFERRED_STACK_BOUNDARY STACK_BOUNDARY
58 /* Decide whether a function's arguments should be processed
59 from first to last or from last to first.
61 They should if the stack and args grow in opposite directions, but
62 only if we have push insns. */
66 #if defined (STACK_GROWS_DOWNWARD) != defined (ARGS_GROW_DOWNWARD)
67 #define PUSH_ARGS_REVERSED PUSH_ARGS
72 #ifndef PUSH_ARGS_REVERSED
73 #define PUSH_ARGS_REVERSED 0
76 /* Like PREFERRED_STACK_BOUNDARY but in units of bytes, not bits. */
77 #define STACK_BYTES (PREFERRED_STACK_BOUNDARY / BITS_PER_UNIT)
79 /* Data structure and subroutines used within expand_call. */
83 /* Tree node for this argument. */
85 /* Mode for value; TYPE_MODE unless promoted. */
86 enum machine_mode mode;
87 /* Current RTL value for argument, or 0 if it isn't precomputed. */
89 /* Initially-compute RTL value for argument; only for const functions. */
91 /* Register to pass this argument in, 0 if passed on stack, or an
92 PARALLEL if the arg is to be copied into multiple non-contiguous
95 /* Register to pass this argument in when generating tail call sequence.
96 This is not the same register as for normal calls on machines with
99 /* If REG was promoted from the actual mode of the argument expression,
100 indicates whether the promotion is sign- or zero-extended. */
102 /* Number of registers to use. 0 means put the whole arg in registers.
103 Also 0 if not passed in registers. */
105 /* Non-zero if argument must be passed on stack.
106 Note that some arguments may be passed on the stack
107 even though pass_on_stack is zero, just because FUNCTION_ARG says so.
108 pass_on_stack identifies arguments that *cannot* go in registers. */
110 /* Offset of this argument from beginning of stack-args. */
111 struct args_size offset;
112 /* Similar, but offset to the start of the stack slot. Different from
113 OFFSET if this arg pads downward. */
114 struct args_size slot_offset;
115 /* Size of this argument on the stack, rounded up for any padding it gets,
116 parts of the argument passed in registers do not count.
117 If REG_PARM_STACK_SPACE is defined, then register parms
118 are counted here as well. */
119 struct args_size size;
120 /* Location on the stack at which parameter should be stored. The store
121 has already been done if STACK == VALUE. */
123 /* Location on the stack of the start of this argument slot. This can
124 differ from STACK if this arg pads downward. This location is known
125 to be aligned to FUNCTION_ARG_BOUNDARY. */
127 /* Place that this stack area has been saved, if needed. */
129 /* If an argument's alignment does not permit direct copying into registers,
130 copy in smaller-sized pieces into pseudos. These are stored in a
131 block pointed to by this field. The next field says how many
132 word-sized pseudos we made. */
135 /* The amount that the stack pointer needs to be adjusted to
136 force alignment for the next argument. */
137 struct args_size alignment_pad;
140 /* A vector of one char per byte of stack space. A byte if non-zero if
141 the corresponding stack location has been used.
142 This vector is used to prevent a function call within an argument from
143 clobbering any stack already set up. */
144 static char *stack_usage_map;
146 /* Size of STACK_USAGE_MAP. */
147 static int highest_outgoing_arg_in_use;
149 /* A bitmap of virtual-incoming stack space. Bit is set if the corresponding
150 stack location's tail call argument has been already stored into the stack.
151 This bitmap is used to prevent sibling call optimization if function tries
152 to use parent's incoming argument slots when they have been already
153 overwritten with tail call arguments. */
154 static sbitmap stored_args_map;
156 /* stack_arg_under_construction is nonzero when an argument may be
157 initialized with a constructor call (including a C function that
158 returns a BLKmode struct) and expand_call must take special action
159 to make sure the object being constructed does not overlap the
160 argument list for the constructor call. */
161 int stack_arg_under_construction;
163 static int calls_function PARAMS ((tree, int));
164 static int calls_function_1 PARAMS ((tree, int));
166 /* Nonzero if this is a call to a `const' function. */
168 /* Nonzero if this is a call to a `volatile' function. */
169 #define ECF_NORETURN 2
170 /* Nonzero if this is a call to malloc or a related function. */
172 /* Nonzero if it is plausible that this is a call to alloca. */
173 #define ECF_MAY_BE_ALLOCA 8
174 /* Nonzero if this is a call to a function that won't throw an exception. */
175 #define ECF_NOTHROW 16
176 /* Nonzero if this is a call to setjmp or a related function. */
177 #define ECF_RETURNS_TWICE 32
178 /* Nonzero if this is a call to `longjmp'. */
179 #define ECF_LONGJMP 64
180 /* Nonzero if this is a syscall that makes a new process in the image of
182 #define ECF_FORK_OR_EXEC 128
183 #define ECF_SIBCALL 256
184 /* Nonzero if this is a call to "pure" function (like const function,
185 but may read memory. */
188 static void emit_call_1 PARAMS ((rtx, tree, tree, HOST_WIDE_INT,
189 HOST_WIDE_INT, HOST_WIDE_INT, rtx,
190 rtx, int, rtx, int));
191 static void precompute_register_parameters PARAMS ((int,
194 static int store_one_arg PARAMS ((struct arg_data *, rtx, int, int,
196 static void store_unaligned_arguments_into_pseudos PARAMS ((struct arg_data *,
198 static int finalize_must_preallocate PARAMS ((int, int,
200 struct args_size *));
201 static void precompute_arguments PARAMS ((int, int,
203 static int compute_argument_block_size PARAMS ((int,
206 static void initialize_argument_information PARAMS ((int,
213 static void compute_argument_addresses PARAMS ((struct arg_data *,
215 static rtx rtx_for_function_call PARAMS ((tree, tree));
216 static void load_register_parameters PARAMS ((struct arg_data *,
218 static int libfunc_nothrow PARAMS ((rtx));
219 static rtx emit_library_call_value_1 PARAMS ((int, rtx, rtx, int,
222 static int special_function_p PARAMS ((tree, int));
223 static int flags_from_decl_or_type PARAMS ((tree));
224 static rtx try_to_integrate PARAMS ((tree, tree, rtx,
226 static int check_sibcall_argument_overlap_1 PARAMS ((rtx));
227 static int check_sibcall_argument_overlap PARAMS ((rtx, struct arg_data *));
229 static int combine_pending_stack_adjustment_and_call
230 PARAMS ((int, struct args_size *, int));
232 #ifdef REG_PARM_STACK_SPACE
233 static rtx save_fixed_argument_area PARAMS ((int, rtx, int *, int *));
234 static void restore_fixed_argument_area PARAMS ((rtx, rtx, int, int));
237 /* If WHICH is 1, return 1 if EXP contains a call to the built-in function
240 If WHICH is 0, return 1 if EXP contains a call to any function.
241 Actually, we only need return 1 if evaluating EXP would require pushing
242 arguments on the stack, but that is too difficult to compute, so we just
243 assume any function call might require the stack. */
245 static tree calls_function_save_exprs;
248 calls_function (exp, which)
254 calls_function_save_exprs = 0;
255 val = calls_function_1 (exp, which);
256 calls_function_save_exprs = 0;
260 /* Recursive function to do the work of above function. */
263 calls_function_1 (exp, which)
268 enum tree_code code = TREE_CODE (exp);
269 int class = TREE_CODE_CLASS (code);
270 int length = first_rtl_op (code);
272 /* If this code is language-specific, we don't know what it will do. */
273 if ((int) code >= NUM_TREE_CODES)
281 else if (TREE_CODE (TREE_OPERAND (exp, 0)) == ADDR_EXPR
282 && (TREE_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0))
284 && (special_function_p (TREE_OPERAND (TREE_OPERAND (exp, 0), 0),
286 & ECF_MAY_BE_ALLOCA))
292 if (SAVE_EXPR_RTL (exp) != 0)
294 if (value_member (exp, calls_function_save_exprs))
296 calls_function_save_exprs = tree_cons (NULL_TREE, exp,
297 calls_function_save_exprs);
298 return (TREE_OPERAND (exp, 0) != 0
299 && calls_function_1 (TREE_OPERAND (exp, 0), which));
304 register tree subblock;
306 for (local = BLOCK_VARS (exp); local; local = TREE_CHAIN (local))
307 if (DECL_INITIAL (local) != 0
308 && calls_function_1 (DECL_INITIAL (local), which))
311 for (subblock = BLOCK_SUBBLOCKS (exp);
313 subblock = TREE_CHAIN (subblock))
314 if (calls_function_1 (subblock, which))
320 for (; exp != 0; exp = TREE_CHAIN (exp))
321 if (calls_function_1 (TREE_VALUE (exp), which))
329 /* Only expressions, references, and blocks can contain calls. */
330 if (! IS_EXPR_CODE_CLASS (class) && class != 'r' && class != 'b')
333 for (i = 0; i < length; i++)
334 if (TREE_OPERAND (exp, i) != 0
335 && calls_function_1 (TREE_OPERAND (exp, i), which))
341 /* Force FUNEXP into a form suitable for the address of a CALL,
342 and return that as an rtx. Also load the static chain register
343 if FNDECL is a nested function.
345 CALL_FUSAGE points to a variable holding the prospective
346 CALL_INSN_FUNCTION_USAGE information. */
349 prepare_call_address (funexp, fndecl, call_fusage, reg_parm_seen)
355 rtx static_chain_value = 0;
357 funexp = protect_from_queue (funexp, 0);
360 /* Get possible static chain value for nested function in C. */
361 static_chain_value = lookup_static_chain (fndecl);
363 /* Make a valid memory address and copy constants thru pseudo-regs,
364 but not for a constant address if -fno-function-cse. */
365 if (GET_CODE (funexp) != SYMBOL_REF)
366 /* If we are using registers for parameters, force the
367 function address into a register now. */
368 funexp = ((SMALL_REGISTER_CLASSES && reg_parm_seen)
369 ? force_not_mem (memory_address (FUNCTION_MODE, funexp))
370 : memory_address (FUNCTION_MODE, funexp));
373 #ifndef NO_FUNCTION_CSE
374 if (optimize && ! flag_no_function_cse)
375 #ifdef NO_RECURSIVE_FUNCTION_CSE
376 if (fndecl != current_function_decl)
378 funexp = force_reg (Pmode, funexp);
382 if (static_chain_value != 0)
384 emit_move_insn (static_chain_rtx, static_chain_value);
386 if (GET_CODE (static_chain_rtx) == REG)
387 use_reg (call_fusage, static_chain_rtx);
393 /* Generate instructions to call function FUNEXP,
394 and optionally pop the results.
395 The CALL_INSN is the first insn generated.
397 FNDECL is the declaration node of the function. This is given to the
398 macro RETURN_POPS_ARGS to determine whether this function pops its own args.
400 FUNTYPE is the data type of the function. This is given to the macro
401 RETURN_POPS_ARGS to determine whether this function pops its own args.
402 We used to allow an identifier for library functions, but that doesn't
403 work when the return type is an aggregate type and the calling convention
404 says that the pointer to this aggregate is to be popped by the callee.
406 STACK_SIZE is the number of bytes of arguments on the stack,
407 ROUNDED_STACK_SIZE is that number rounded up to
408 PREFERRED_STACK_BOUNDARY; zero if the size is variable. This is
409 both to put into the call insn and to generate explicit popping
412 STRUCT_VALUE_SIZE is the number of bytes wanted in a structure value.
413 It is zero if this call doesn't want a structure value.
415 NEXT_ARG_REG is the rtx that results from executing
416 FUNCTION_ARG (args_so_far, VOIDmode, void_type_node, 1)
417 just after all the args have had their registers assigned.
418 This could be whatever you like, but normally it is the first
419 arg-register beyond those used for args in this call,
420 or 0 if all the arg-registers are used in this call.
421 It is passed on to `gen_call' so you can put this info in the call insn.
423 VALREG is a hard register in which a value is returned,
424 or 0 if the call does not return a value.
426 OLD_INHIBIT_DEFER_POP is the value that `inhibit_defer_pop' had before
427 the args to this call were processed.
428 We restore `inhibit_defer_pop' to that value.
430 CALL_FUSAGE is either empty or an EXPR_LIST of USE expressions that
431 denote registers used by the called function. */
434 emit_call_1 (funexp, fndecl, funtype, stack_size, rounded_stack_size,
435 struct_value_size, next_arg_reg, valreg, old_inhibit_defer_pop,
436 call_fusage, ecf_flags)
438 tree fndecl ATTRIBUTE_UNUSED;
439 tree funtype ATTRIBUTE_UNUSED;
440 HOST_WIDE_INT stack_size ATTRIBUTE_UNUSED;
441 HOST_WIDE_INT rounded_stack_size;
442 HOST_WIDE_INT struct_value_size ATTRIBUTE_UNUSED;
445 int old_inhibit_defer_pop;
449 rtx rounded_stack_size_rtx = GEN_INT (rounded_stack_size);
451 int already_popped = 0;
452 HOST_WIDE_INT n_popped = RETURN_POPS_ARGS (fndecl, funtype, stack_size);
453 #if defined (HAVE_call) && defined (HAVE_call_value)
454 rtx struct_value_size_rtx;
455 struct_value_size_rtx = GEN_INT (struct_value_size);
458 /* Ensure address is valid. SYMBOL_REF is already valid, so no need,
459 and we don't want to load it into a register as an optimization,
460 because prepare_call_address already did it if it should be done. */
461 if (GET_CODE (funexp) != SYMBOL_REF)
462 funexp = memory_address (FUNCTION_MODE, funexp);
464 #if defined (HAVE_sibcall_pop) && defined (HAVE_sibcall_value_pop)
465 if ((ecf_flags & ECF_SIBCALL)
466 && HAVE_sibcall_pop && HAVE_sibcall_value_pop
467 && (RETURN_POPS_ARGS (fndecl, funtype, stack_size) > 0
470 rtx n_pop = GEN_INT (RETURN_POPS_ARGS (fndecl, funtype, stack_size));
473 /* If this subroutine pops its own args, record that in the call insn
474 if possible, for the sake of frame pointer elimination. */
477 pat = GEN_SIBCALL_VALUE_POP (valreg,
478 gen_rtx_MEM (FUNCTION_MODE, funexp),
479 rounded_stack_size_rtx, next_arg_reg,
482 pat = GEN_SIBCALL_POP (gen_rtx_MEM (FUNCTION_MODE, funexp),
483 rounded_stack_size_rtx, next_arg_reg, n_pop);
485 emit_call_insn (pat);
491 #if defined (HAVE_call_pop) && defined (HAVE_call_value_pop)
492 /* If the target has "call" or "call_value" insns, then prefer them
493 if no arguments are actually popped. If the target does not have
494 "call" or "call_value" insns, then we must use the popping versions
495 even if the call has no arguments to pop. */
496 #if defined (HAVE_call) && defined (HAVE_call_value)
497 if (HAVE_call && HAVE_call_value && HAVE_call_pop && HAVE_call_value_pop
500 if (HAVE_call_pop && HAVE_call_value_pop)
503 rtx n_pop = GEN_INT (n_popped);
506 /* If this subroutine pops its own args, record that in the call insn
507 if possible, for the sake of frame pointer elimination. */
510 pat = GEN_CALL_VALUE_POP (valreg,
511 gen_rtx_MEM (FUNCTION_MODE, funexp),
512 rounded_stack_size_rtx, next_arg_reg, n_pop);
514 pat = GEN_CALL_POP (gen_rtx_MEM (FUNCTION_MODE, funexp),
515 rounded_stack_size_rtx, next_arg_reg, n_pop);
517 emit_call_insn (pat);
523 #if defined (HAVE_sibcall) && defined (HAVE_sibcall_value)
524 if ((ecf_flags & ECF_SIBCALL)
525 && HAVE_sibcall && HAVE_sibcall_value)
528 emit_call_insn (GEN_SIBCALL_VALUE (valreg,
529 gen_rtx_MEM (FUNCTION_MODE, funexp),
530 rounded_stack_size_rtx,
531 next_arg_reg, NULL_RTX));
533 emit_call_insn (GEN_SIBCALL (gen_rtx_MEM (FUNCTION_MODE, funexp),
534 rounded_stack_size_rtx, next_arg_reg,
535 struct_value_size_rtx));
540 #if defined (HAVE_call) && defined (HAVE_call_value)
541 if (HAVE_call && HAVE_call_value)
544 emit_call_insn (GEN_CALL_VALUE (valreg,
545 gen_rtx_MEM (FUNCTION_MODE, funexp),
546 rounded_stack_size_rtx, next_arg_reg,
549 emit_call_insn (GEN_CALL (gen_rtx_MEM (FUNCTION_MODE, funexp),
550 rounded_stack_size_rtx, next_arg_reg,
551 struct_value_size_rtx));
557 /* Find the CALL insn we just emitted. */
558 for (call_insn = get_last_insn ();
559 call_insn && GET_CODE (call_insn) != CALL_INSN;
560 call_insn = PREV_INSN (call_insn))
566 /* Mark memory as used for "pure" function call. */
567 if (ecf_flags & ECF_PURE)
569 call_fusage = gen_rtx_EXPR_LIST (VOIDmode,
570 gen_rtx_USE (VOIDmode,
571 gen_rtx_MEM (BLKmode,
572 gen_rtx_SCRATCH (VOIDmode))), call_fusage);
575 /* Put the register usage information on the CALL. If there is already
576 some usage information, put ours at the end. */
577 if (CALL_INSN_FUNCTION_USAGE (call_insn))
581 for (link = CALL_INSN_FUNCTION_USAGE (call_insn); XEXP (link, 1) != 0;
582 link = XEXP (link, 1))
585 XEXP (link, 1) = call_fusage;
588 CALL_INSN_FUNCTION_USAGE (call_insn) = call_fusage;
590 /* If this is a const call, then set the insn's unchanging bit. */
591 if (ecf_flags & (ECF_CONST | ECF_PURE))
592 CONST_CALL_P (call_insn) = 1;
594 /* If this call can't throw, attach a REG_EH_REGION reg note to that
596 if (ecf_flags & ECF_NOTHROW)
597 REG_NOTES (call_insn) = gen_rtx_EXPR_LIST (REG_EH_REGION, const0_rtx,
598 REG_NOTES (call_insn));
600 SIBLING_CALL_P (call_insn) = ((ecf_flags & ECF_SIBCALL) != 0);
602 /* Restore this now, so that we do defer pops for this call's args
603 if the context of the call as a whole permits. */
604 inhibit_defer_pop = old_inhibit_defer_pop;
609 CALL_INSN_FUNCTION_USAGE (call_insn)
610 = gen_rtx_EXPR_LIST (VOIDmode,
611 gen_rtx_CLOBBER (VOIDmode, stack_pointer_rtx),
612 CALL_INSN_FUNCTION_USAGE (call_insn));
613 rounded_stack_size -= n_popped;
614 rounded_stack_size_rtx = GEN_INT (rounded_stack_size);
615 stack_pointer_delta -= n_popped;
618 if (!ACCUMULATE_OUTGOING_ARGS)
620 /* If returning from the subroutine does not automatically pop the args,
621 we need an instruction to pop them sooner or later.
622 Perhaps do it now; perhaps just record how much space to pop later.
624 If returning from the subroutine does pop the args, indicate that the
625 stack pointer will be changed. */
627 if (rounded_stack_size != 0)
629 if (flag_defer_pop && inhibit_defer_pop == 0
630 && !(ecf_flags & (ECF_CONST | ECF_PURE)))
631 pending_stack_adjust += rounded_stack_size;
633 adjust_stack (rounded_stack_size_rtx);
636 /* When we accumulate outgoing args, we must avoid any stack manipulations.
637 Restore the stack pointer to its original value now. Usually
638 ACCUMULATE_OUTGOING_ARGS targets don't get here, but there are exceptions.
639 On i386 ACCUMULATE_OUTGOING_ARGS can be enabled on demand, and
640 popping variants of functions exist as well.
642 ??? We may optimize similar to defer_pop above, but it is
643 probably not worthwhile.
645 ??? It will be worthwhile to enable combine_stack_adjustments even for
648 anti_adjust_stack (GEN_INT (n_popped));
651 /* Determine if the function identified by NAME and FNDECL is one with
652 special properties we wish to know about.
654 For example, if the function might return more than one time (setjmp), then
655 set RETURNS_TWICE to a nonzero value.
657 Similarly set LONGJMP for if the function is in the longjmp family.
659 Set MALLOC for any of the standard memory allocation functions which
660 allocate from the heap.
662 Set MAY_BE_ALLOCA for any memory allocation function that might allocate
663 space from the stack such as alloca. */
666 special_function_p (fndecl, flags)
670 if (! (flags & ECF_MALLOC)
671 && fndecl && DECL_NAME (fndecl)
672 && IDENTIFIER_LENGTH (DECL_NAME (fndecl)) <= 17
673 /* Exclude functions not at the file scope, or not `extern',
674 since they are not the magic functions we would otherwise
676 && DECL_CONTEXT (fndecl) == NULL_TREE && TREE_PUBLIC (fndecl))
678 char *name = IDENTIFIER_POINTER (DECL_NAME (fndecl));
681 /* We assume that alloca will always be called by name. It
682 makes no sense to pass it as a pointer-to-function to
683 anything that does not understand its behavior. */
684 if (((IDENTIFIER_LENGTH (DECL_NAME (fndecl)) == 6
686 && ! strcmp (name, "alloca"))
687 || (IDENTIFIER_LENGTH (DECL_NAME (fndecl)) == 16
689 && ! strcmp (name, "__builtin_alloca"))))
690 flags |= ECF_MAY_BE_ALLOCA;
692 /* Disregard prefix _, __ or __x. */
695 if (name[1] == '_' && name[2] == 'x')
697 else if (name[1] == '_')
706 && (! strcmp (tname, "setjmp")
707 || ! strcmp (tname, "setjmp_syscall")))
709 && ! strcmp (tname, "sigsetjmp"))
711 && ! strcmp (tname, "savectx")))
712 flags |= ECF_RETURNS_TWICE;
715 && ! strcmp (tname, "siglongjmp"))
716 flags |= ECF_LONGJMP;
718 else if ((tname[0] == 'q' && tname[1] == 's'
719 && ! strcmp (tname, "qsetjmp"))
720 || (tname[0] == 'v' && tname[1] == 'f'
721 && ! strcmp (tname, "vfork")))
722 flags |= ECF_RETURNS_TWICE;
724 else if (tname[0] == 'l' && tname[1] == 'o'
725 && ! strcmp (tname, "longjmp"))
726 flags |= ECF_LONGJMP;
728 else if ((tname[0] == 'f' && tname[1] == 'o'
729 && ! strcmp (tname, "fork"))
730 /* Linux specific: __clone. check NAME to insist on the
731 leading underscores, to avoid polluting the ISO / POSIX
733 || (name[0] == '_' && name[1] == '_'
734 && ! strcmp (tname, "clone"))
735 || (tname[0] == 'e' && tname[1] == 'x' && tname[2] == 'e'
736 && tname[3] == 'c' && (tname[4] == 'l' || tname[4] == 'v')
738 || ((tname[5] == 'p' || tname[5] == 'e')
739 && tname[6] == '\0'))))
740 flags |= ECF_FORK_OR_EXEC;
742 /* Do not add any more malloc-like functions to this list,
743 instead mark them as malloc functions using the malloc attribute.
744 Note, realloc is not suitable for attribute malloc since
745 it may return the same address across multiple calls.
746 C++ operator new is not suitable because it is not required
747 to return a unique pointer; indeed, the standard placement new
748 just returns its argument. */
749 else if (TYPE_MODE (TREE_TYPE (TREE_TYPE (fndecl))) == Pmode
750 && (! strcmp (tname, "malloc")
751 || ! strcmp (tname, "calloc")
752 || ! strcmp (tname, "strdup")))
758 /* Return nonzero when tree represent call to longjmp. */
760 setjmp_call_p (fndecl)
763 return special_function_p (fndecl, 0) & ECF_RETURNS_TWICE;
766 /* Detect flags (function attributes) from the function type node. */
768 flags_from_decl_or_type (exp)
772 /* ??? We can't set IS_MALLOC for function types? */
775 /* The function exp may have the `malloc' attribute. */
776 if (DECL_P (exp) && DECL_IS_MALLOC (exp))
779 /* The function exp may have the `pure' attribute. */
780 if (DECL_P (exp) && DECL_IS_PURE (exp))
783 if (TREE_NOTHROW (exp))
784 flags |= ECF_NOTHROW;
787 if (TREE_READONLY (exp) && !TREE_THIS_VOLATILE (exp))
790 if (TREE_THIS_VOLATILE (exp))
791 flags |= ECF_NORETURN;
797 /* Precompute all register parameters as described by ARGS, storing values
798 into fields within the ARGS array.
800 NUM_ACTUALS indicates the total number elements in the ARGS array.
802 Set REG_PARM_SEEN if we encounter a register parameter. */
805 precompute_register_parameters (num_actuals, args, reg_parm_seen)
807 struct arg_data *args;
814 for (i = 0; i < num_actuals; i++)
815 if (args[i].reg != 0 && ! args[i].pass_on_stack)
819 if (args[i].value == 0)
822 args[i].value = expand_expr (args[i].tree_value, NULL_RTX,
824 preserve_temp_slots (args[i].value);
827 /* ANSI doesn't require a sequence point here,
828 but PCC has one, so this will avoid some problems. */
832 /* If we are to promote the function arg to a wider mode,
835 if (args[i].mode != TYPE_MODE (TREE_TYPE (args[i].tree_value)))
837 = convert_modes (args[i].mode,
838 TYPE_MODE (TREE_TYPE (args[i].tree_value)),
839 args[i].value, args[i].unsignedp);
841 /* If the value is expensive, and we are inside an appropriately
842 short loop, put the value into a pseudo and then put the pseudo
845 For small register classes, also do this if this call uses
846 register parameters. This is to avoid reload conflicts while
847 loading the parameters registers. */
849 if ((! (GET_CODE (args[i].value) == REG
850 || (GET_CODE (args[i].value) == SUBREG
851 && GET_CODE (SUBREG_REG (args[i].value)) == REG)))
852 && args[i].mode != BLKmode
853 && rtx_cost (args[i].value, SET) > 2
854 && ((SMALL_REGISTER_CLASSES && *reg_parm_seen)
855 || preserve_subexpressions_p ()))
856 args[i].value = copy_to_mode_reg (args[i].mode, args[i].value);
860 #ifdef REG_PARM_STACK_SPACE
862 /* The argument list is the property of the called routine and it
863 may clobber it. If the fixed area has been used for previous
864 parameters, we must save and restore it. */
867 save_fixed_argument_area (reg_parm_stack_space, argblock,
868 low_to_save, high_to_save)
869 int reg_parm_stack_space;
875 rtx save_area = NULL_RTX;
877 /* Compute the boundary of the that needs to be saved, if any. */
878 #ifdef ARGS_GROW_DOWNWARD
879 for (i = 0; i < reg_parm_stack_space + 1; i++)
881 for (i = 0; i < reg_parm_stack_space; i++)
884 if (i >= highest_outgoing_arg_in_use
885 || stack_usage_map[i] == 0)
888 if (*low_to_save == -1)
894 if (*low_to_save >= 0)
896 int num_to_save = *high_to_save - *low_to_save + 1;
897 enum machine_mode save_mode
898 = mode_for_size (num_to_save * BITS_PER_UNIT, MODE_INT, 1);
901 /* If we don't have the required alignment, must do this in BLKmode. */
902 if ((*low_to_save & (MIN (GET_MODE_SIZE (save_mode),
903 BIGGEST_ALIGNMENT / UNITS_PER_WORD) - 1)))
906 #ifdef ARGS_GROW_DOWNWARD
908 = gen_rtx_MEM (save_mode,
909 memory_address (save_mode,
910 plus_constant (argblock,
913 stack_area = gen_rtx_MEM (save_mode,
914 memory_address (save_mode,
915 plus_constant (argblock,
918 if (save_mode == BLKmode)
920 save_area = assign_stack_temp (BLKmode, num_to_save, 0);
921 /* Cannot use emit_block_move here because it can be done by a
922 library call which in turn gets into this place again and deadly
923 infinite recursion happens. */
924 move_by_pieces (validize_mem (save_area), stack_area, num_to_save,
929 save_area = gen_reg_rtx (save_mode);
930 emit_move_insn (save_area, stack_area);
937 restore_fixed_argument_area (save_area, argblock, high_to_save, low_to_save)
943 enum machine_mode save_mode = GET_MODE (save_area);
944 #ifdef ARGS_GROW_DOWNWARD
946 = gen_rtx_MEM (save_mode,
947 memory_address (save_mode,
948 plus_constant (argblock,
952 = gen_rtx_MEM (save_mode,
953 memory_address (save_mode,
954 plus_constant (argblock,
958 if (save_mode != BLKmode)
959 emit_move_insn (stack_area, save_area);
961 /* Cannot use emit_block_move here because it can be done by a library
962 call which in turn gets into this place again and deadly infinite
963 recursion happens. */
964 move_by_pieces (stack_area, validize_mem (save_area),
965 high_to_save - low_to_save + 1, PARM_BOUNDARY);
969 /* If any elements in ARGS refer to parameters that are to be passed in
970 registers, but not in memory, and whose alignment does not permit a
971 direct copy into registers. Copy the values into a group of pseudos
972 which we will later copy into the appropriate hard registers.
974 Pseudos for each unaligned argument will be stored into the array
975 args[argnum].aligned_regs. The caller is responsible for deallocating
976 the aligned_regs array if it is nonzero. */
979 store_unaligned_arguments_into_pseudos (args, num_actuals)
980 struct arg_data *args;
985 for (i = 0; i < num_actuals; i++)
986 if (args[i].reg != 0 && ! args[i].pass_on_stack
987 && args[i].mode == BLKmode
988 && (TYPE_ALIGN (TREE_TYPE (args[i].tree_value))
989 < (unsigned int) MIN (BIGGEST_ALIGNMENT, BITS_PER_WORD)))
991 int bytes = int_size_in_bytes (TREE_TYPE (args[i].tree_value));
992 int big_endian_correction = 0;
994 args[i].n_aligned_regs
995 = args[i].partial ? args[i].partial
996 : (bytes + (UNITS_PER_WORD - 1)) / UNITS_PER_WORD;
998 args[i].aligned_regs = (rtx *) xmalloc (sizeof (rtx)
999 * args[i].n_aligned_regs);
1001 /* Structures smaller than a word are aligned to the least
1002 significant byte (to the right). On a BYTES_BIG_ENDIAN machine,
1003 this means we must skip the empty high order bytes when
1004 calculating the bit offset. */
1005 if (BYTES_BIG_ENDIAN && bytes < UNITS_PER_WORD)
1006 big_endian_correction = (BITS_PER_WORD - (bytes * BITS_PER_UNIT));
1008 for (j = 0; j < args[i].n_aligned_regs; j++)
1010 rtx reg = gen_reg_rtx (word_mode);
1011 rtx word = operand_subword_force (args[i].value, j, BLKmode);
1012 int bitsize = MIN (bytes * BITS_PER_UNIT, BITS_PER_WORD);
1013 int bitalign = TYPE_ALIGN (TREE_TYPE (args[i].tree_value));
1015 args[i].aligned_regs[j] = reg;
1017 /* There is no need to restrict this code to loading items
1018 in TYPE_ALIGN sized hunks. The bitfield instructions can
1019 load up entire word sized registers efficiently.
1021 ??? This may not be needed anymore.
1022 We use to emit a clobber here but that doesn't let later
1023 passes optimize the instructions we emit. By storing 0 into
1024 the register later passes know the first AND to zero out the
1025 bitfield being set in the register is unnecessary. The store
1026 of 0 will be deleted as will at least the first AND. */
1028 emit_move_insn (reg, const0_rtx);
1030 bytes -= bitsize / BITS_PER_UNIT;
1031 store_bit_field (reg, bitsize, big_endian_correction, word_mode,
1032 extract_bit_field (word, bitsize, 0, 1, NULL_RTX,
1033 word_mode, word_mode, bitalign,
1035 bitalign, BITS_PER_WORD);
1040 /* Fill in ARGS_SIZE and ARGS array based on the parameters found in
1043 NUM_ACTUALS is the total number of parameters.
1045 N_NAMED_ARGS is the total number of named arguments.
1047 FNDECL is the tree code for the target of this call (if known)
1049 ARGS_SO_FAR holds state needed by the target to know where to place
1052 REG_PARM_STACK_SPACE is the number of bytes of stack space reserved
1053 for arguments which are passed in registers.
1055 OLD_STACK_LEVEL is a pointer to an rtx which olds the old stack level
1056 and may be modified by this routine.
1058 OLD_PENDING_ADJ, MUST_PREALLOCATE and FLAGS are pointers to integer
1059 flags which may may be modified by this routine. */
1062 initialize_argument_information (num_actuals, args, args_size, n_named_args,
1063 actparms, fndecl, args_so_far,
1064 reg_parm_stack_space, old_stack_level,
1065 old_pending_adj, must_preallocate,
1067 int num_actuals ATTRIBUTE_UNUSED;
1068 struct arg_data *args;
1069 struct args_size *args_size;
1070 int n_named_args ATTRIBUTE_UNUSED;
1073 CUMULATIVE_ARGS *args_so_far;
1074 int reg_parm_stack_space;
1075 rtx *old_stack_level;
1076 int *old_pending_adj;
1077 int *must_preallocate;
1080 /* 1 if scanning parms front to back, -1 if scanning back to front. */
1083 /* Count arg position in order args appear. */
1086 struct args_size alignment_pad;
1090 args_size->constant = 0;
1093 /* In this loop, we consider args in the order they are written.
1094 We fill up ARGS from the front or from the back if necessary
1095 so that in any case the first arg to be pushed ends up at the front. */
1097 if (PUSH_ARGS_REVERSED)
1099 i = num_actuals - 1, inc = -1;
1100 /* In this case, must reverse order of args
1101 so that we compute and push the last arg first. */
1108 /* I counts args in order (to be) pushed; ARGPOS counts in order written. */
1109 for (p = actparms, argpos = 0; p; p = TREE_CHAIN (p), i += inc, argpos++)
1111 tree type = TREE_TYPE (TREE_VALUE (p));
1113 enum machine_mode mode;
1115 args[i].tree_value = TREE_VALUE (p);
1117 /* Replace erroneous argument with constant zero. */
1118 if (type == error_mark_node || !COMPLETE_TYPE_P (type))
1119 args[i].tree_value = integer_zero_node, type = integer_type_node;
1121 /* If TYPE is a transparent union, pass things the way we would
1122 pass the first field of the union. We have already verified that
1123 the modes are the same. */
1124 if (TREE_CODE (type) == UNION_TYPE && TYPE_TRANSPARENT_UNION (type))
1125 type = TREE_TYPE (TYPE_FIELDS (type));
1127 /* Decide where to pass this arg.
1129 args[i].reg is nonzero if all or part is passed in registers.
1131 args[i].partial is nonzero if part but not all is passed in registers,
1132 and the exact value says how many words are passed in registers.
1134 args[i].pass_on_stack is nonzero if the argument must at least be
1135 computed on the stack. It may then be loaded back into registers
1136 if args[i].reg is nonzero.
1138 These decisions are driven by the FUNCTION_... macros and must agree
1139 with those made by function.c. */
1141 /* See if this argument should be passed by invisible reference. */
1142 if ((TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST
1143 && contains_placeholder_p (TYPE_SIZE (type)))
1144 || TREE_ADDRESSABLE (type)
1145 #ifdef FUNCTION_ARG_PASS_BY_REFERENCE
1146 || FUNCTION_ARG_PASS_BY_REFERENCE (*args_so_far, TYPE_MODE (type),
1147 type, argpos < n_named_args)
1151 /* If we're compiling a thunk, pass through invisible
1152 references instead of making a copy. */
1153 if (current_function_is_thunk
1154 #ifdef FUNCTION_ARG_CALLEE_COPIES
1155 || (FUNCTION_ARG_CALLEE_COPIES (*args_so_far, TYPE_MODE (type),
1156 type, argpos < n_named_args)
1157 /* If it's in a register, we must make a copy of it too. */
1158 /* ??? Is this a sufficient test? Is there a better one? */
1159 && !(TREE_CODE (args[i].tree_value) == VAR_DECL
1160 && REG_P (DECL_RTL (args[i].tree_value)))
1161 && ! TREE_ADDRESSABLE (type))
1165 /* C++ uses a TARGET_EXPR to indicate that we want to make a
1166 new object from the argument. If we are passing by
1167 invisible reference, the callee will do that for us, so we
1168 can strip off the TARGET_EXPR. This is not always safe,
1169 but it is safe in the only case where this is a useful
1170 optimization; namely, when the argument is a plain object.
1171 In that case, the frontend is just asking the backend to
1172 make a bitwise copy of the argument. */
1174 if (TREE_CODE (args[i].tree_value) == TARGET_EXPR
1175 && (DECL_P (TREE_OPERAND (args[i].tree_value, 1)))
1176 && ! REG_P (DECL_RTL (TREE_OPERAND (args[i].tree_value, 1))))
1177 args[i].tree_value = TREE_OPERAND (args[i].tree_value, 1);
1179 args[i].tree_value = build1 (ADDR_EXPR,
1180 build_pointer_type (type),
1181 args[i].tree_value);
1182 type = build_pointer_type (type);
1186 /* We make a copy of the object and pass the address to the
1187 function being called. */
1190 if (!COMPLETE_TYPE_P (type)
1191 || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST
1192 || (flag_stack_check && ! STACK_CHECK_BUILTIN
1193 && (0 < compare_tree_int (TYPE_SIZE_UNIT (type),
1194 STACK_CHECK_MAX_VAR_SIZE))))
1196 /* This is a variable-sized object. Make space on the stack
1198 rtx size_rtx = expr_size (TREE_VALUE (p));
1200 if (*old_stack_level == 0)
1202 emit_stack_save (SAVE_BLOCK, old_stack_level, NULL_RTX);
1203 *old_pending_adj = pending_stack_adjust;
1204 pending_stack_adjust = 0;
1207 copy = gen_rtx_MEM (BLKmode,
1208 allocate_dynamic_stack_space
1209 (size_rtx, NULL_RTX, TYPE_ALIGN (type)));
1210 set_mem_attributes (copy, type, 1);
1213 copy = assign_temp (type, 0, 1, 0);
1215 store_expr (args[i].tree_value, copy, 0);
1216 *ecf_flags &= ~(ECF_CONST | ECF_PURE);
1218 args[i].tree_value = build1 (ADDR_EXPR,
1219 build_pointer_type (type),
1220 make_tree (type, copy));
1221 type = build_pointer_type (type);
1225 mode = TYPE_MODE (type);
1226 unsignedp = TREE_UNSIGNED (type);
1228 #ifdef PROMOTE_FUNCTION_ARGS
1229 mode = promote_mode (type, mode, &unsignedp, 1);
1232 args[i].unsignedp = unsignedp;
1233 args[i].mode = mode;
1235 args[i].reg = FUNCTION_ARG (*args_so_far, mode, type,
1236 argpos < n_named_args);
1237 #ifdef FUNCTION_INCOMING_ARG
1238 /* If this is a sibling call and the machine has register windows, the
1239 register window has to be unwinded before calling the routine, so
1240 arguments have to go into the incoming registers. */
1241 args[i].tail_call_reg = FUNCTION_INCOMING_ARG (*args_so_far, mode, type,
1242 argpos < n_named_args);
1244 args[i].tail_call_reg = args[i].reg;
1247 #ifdef FUNCTION_ARG_PARTIAL_NREGS
1250 = FUNCTION_ARG_PARTIAL_NREGS (*args_so_far, mode, type,
1251 argpos < n_named_args);
1254 args[i].pass_on_stack = MUST_PASS_IN_STACK (mode, type);
1256 /* If FUNCTION_ARG returned a (parallel [(expr_list (nil) ...) ...]),
1257 it means that we are to pass this arg in the register(s) designated
1258 by the PARALLEL, but also to pass it in the stack. */
1259 if (args[i].reg && GET_CODE (args[i].reg) == PARALLEL
1260 && XEXP (XVECEXP (args[i].reg, 0, 0), 0) == 0)
1261 args[i].pass_on_stack = 1;
1263 /* If this is an addressable type, we must preallocate the stack
1264 since we must evaluate the object into its final location.
1266 If this is to be passed in both registers and the stack, it is simpler
1268 if (TREE_ADDRESSABLE (type)
1269 || (args[i].pass_on_stack && args[i].reg != 0))
1270 *must_preallocate = 1;
1272 /* If this is an addressable type, we cannot pre-evaluate it. Thus,
1273 we cannot consider this function call constant. */
1274 if (TREE_ADDRESSABLE (type))
1275 *ecf_flags &= ~(ECF_CONST | ECF_PURE);
1277 /* Compute the stack-size of this argument. */
1278 if (args[i].reg == 0 || args[i].partial != 0
1279 || reg_parm_stack_space > 0
1280 || args[i].pass_on_stack)
1281 locate_and_pad_parm (mode, type,
1282 #ifdef STACK_PARMS_IN_REG_PARM_AREA
1287 fndecl, args_size, &args[i].offset,
1288 &args[i].size, &alignment_pad);
1290 #ifndef ARGS_GROW_DOWNWARD
1291 args[i].slot_offset = *args_size;
1294 args[i].alignment_pad = alignment_pad;
1296 /* If a part of the arg was put into registers,
1297 don't include that part in the amount pushed. */
1298 if (reg_parm_stack_space == 0 && ! args[i].pass_on_stack)
1299 args[i].size.constant -= ((args[i].partial * UNITS_PER_WORD)
1300 / (PARM_BOUNDARY / BITS_PER_UNIT)
1301 * (PARM_BOUNDARY / BITS_PER_UNIT));
1303 /* Update ARGS_SIZE, the total stack space for args so far. */
1305 args_size->constant += args[i].size.constant;
1306 if (args[i].size.var)
1308 ADD_PARM_SIZE (*args_size, args[i].size.var);
1311 /* Since the slot offset points to the bottom of the slot,
1312 we must record it after incrementing if the args grow down. */
1313 #ifdef ARGS_GROW_DOWNWARD
1314 args[i].slot_offset = *args_size;
1316 args[i].slot_offset.constant = -args_size->constant;
1318 SUB_PARM_SIZE (args[i].slot_offset, args_size->var);
1321 /* Increment ARGS_SO_FAR, which has info about which arg-registers
1322 have been used, etc. */
1324 FUNCTION_ARG_ADVANCE (*args_so_far, TYPE_MODE (type), type,
1325 argpos < n_named_args);
1329 /* Update ARGS_SIZE to contain the total size for the argument block.
1330 Return the original constant component of the argument block's size.
1332 REG_PARM_STACK_SPACE holds the number of bytes of stack space reserved
1333 for arguments passed in registers. */
1336 compute_argument_block_size (reg_parm_stack_space, args_size,
1337 preferred_stack_boundary)
1338 int reg_parm_stack_space;
1339 struct args_size *args_size;
1340 int preferred_stack_boundary ATTRIBUTE_UNUSED;
1342 int unadjusted_args_size = args_size->constant;
1344 /* For accumulate outgoing args mode we don't need to align, since the frame
1345 will be already aligned. Align to STACK_BOUNDARY in order to prevent
1346 backends from generating missaligned frame sizes. */
1347 #ifdef STACK_BOUNDARY
1348 if (ACCUMULATE_OUTGOING_ARGS && preferred_stack_boundary > STACK_BOUNDARY)
1349 preferred_stack_boundary = STACK_BOUNDARY;
1352 /* Compute the actual size of the argument block required. The variable
1353 and constant sizes must be combined, the size may have to be rounded,
1354 and there may be a minimum required size. */
1358 args_size->var = ARGS_SIZE_TREE (*args_size);
1359 args_size->constant = 0;
1361 #ifdef PREFERRED_STACK_BOUNDARY
1362 preferred_stack_boundary /= BITS_PER_UNIT;
1363 if (preferred_stack_boundary > 1)
1365 /* We don't handle this case yet. To handle it correctly we have
1366 to add the delta, round and substract the delta.
1367 Currently no machine description requires this support. */
1368 if (stack_pointer_delta & (preferred_stack_boundary - 1))
1370 args_size->var = round_up (args_size->var, preferred_stack_boundary);
1374 if (reg_parm_stack_space > 0)
1377 = size_binop (MAX_EXPR, args_size->var,
1378 ssize_int (reg_parm_stack_space));
1380 #ifndef OUTGOING_REG_PARM_STACK_SPACE
1381 /* The area corresponding to register parameters is not to count in
1382 the size of the block we need. So make the adjustment. */
1384 = size_binop (MINUS_EXPR, args_size->var,
1385 ssize_int (reg_parm_stack_space));
1391 #ifdef PREFERRED_STACK_BOUNDARY
1392 preferred_stack_boundary /= BITS_PER_UNIT;
1393 if (preferred_stack_boundary < 1)
1394 preferred_stack_boundary = 1;
1395 args_size->constant = (((args_size->constant
1396 + stack_pointer_delta
1397 + preferred_stack_boundary - 1)
1398 / preferred_stack_boundary
1399 * preferred_stack_boundary)
1400 - stack_pointer_delta);
1403 args_size->constant = MAX (args_size->constant,
1404 reg_parm_stack_space);
1406 #ifdef MAYBE_REG_PARM_STACK_SPACE
1407 if (reg_parm_stack_space == 0)
1408 args_size->constant = 0;
1411 #ifndef OUTGOING_REG_PARM_STACK_SPACE
1412 args_size->constant -= reg_parm_stack_space;
1415 return unadjusted_args_size;
1418 /* Precompute parameters as needed for a function call.
1420 FLAGS is mask of ECF_* constants.
1422 NUM_ACTUALS is the number of arguments.
1424 ARGS is an array containing information for each argument; this routine
1425 fills in the INITIAL_VALUE and VALUE fields for each precomputed argument.
1429 precompute_arguments (flags, num_actuals, args)
1432 struct arg_data *args;
1436 /* If this function call is cse'able, precompute all the parameters.
1437 Note that if the parameter is constructed into a temporary, this will
1438 cause an additional copy because the parameter will be constructed
1439 into a temporary location and then copied into the outgoing arguments.
1440 If a parameter contains a call to alloca and this function uses the
1441 stack, precompute the parameter. */
1443 /* If we preallocated the stack space, and some arguments must be passed
1444 on the stack, then we must precompute any parameter which contains a
1445 function call which will store arguments on the stack.
1446 Otherwise, evaluating the parameter may clobber previous parameters
1447 which have already been stored into the stack. (we have code to avoid
1448 such case by saving the ougoing stack arguments, but it results in
1451 for (i = 0; i < num_actuals; i++)
1452 if ((flags & (ECF_CONST | ECF_PURE))
1453 || calls_function (args[i].tree_value, !ACCUMULATE_OUTGOING_ARGS))
1455 /* If this is an addressable type, we cannot pre-evaluate it. */
1456 if (TREE_ADDRESSABLE (TREE_TYPE (args[i].tree_value)))
1462 = expand_expr (args[i].tree_value, NULL_RTX, VOIDmode, 0);
1464 preserve_temp_slots (args[i].value);
1467 /* ANSI doesn't require a sequence point here,
1468 but PCC has one, so this will avoid some problems. */
1471 args[i].initial_value = args[i].value
1472 = protect_from_queue (args[i].value, 0);
1474 if (TYPE_MODE (TREE_TYPE (args[i].tree_value)) != args[i].mode)
1477 = convert_modes (args[i].mode,
1478 TYPE_MODE (TREE_TYPE (args[i].tree_value)),
1479 args[i].value, args[i].unsignedp);
1480 #ifdef PROMOTE_FOR_CALL_ONLY
1481 /* CSE will replace this only if it contains args[i].value
1482 pseudo, so convert it down to the declared mode using
1484 if (GET_CODE (args[i].value) == REG
1485 && GET_MODE_CLASS (args[i].mode) == MODE_INT)
1487 args[i].initial_value
1488 = gen_rtx_SUBREG (TYPE_MODE (TREE_TYPE (args[i].tree_value)),
1490 SUBREG_PROMOTED_VAR_P (args[i].initial_value) = 1;
1491 SUBREG_PROMOTED_UNSIGNED_P (args[i].initial_value)
1492 = args[i].unsignedp;
1499 /* Given the current state of MUST_PREALLOCATE and information about
1500 arguments to a function call in NUM_ACTUALS, ARGS and ARGS_SIZE,
1501 compute and return the final value for MUST_PREALLOCATE. */
1504 finalize_must_preallocate (must_preallocate, num_actuals, args, args_size)
1505 int must_preallocate;
1507 struct arg_data *args;
1508 struct args_size *args_size;
1510 /* See if we have or want to preallocate stack space.
1512 If we would have to push a partially-in-regs parm
1513 before other stack parms, preallocate stack space instead.
1515 If the size of some parm is not a multiple of the required stack
1516 alignment, we must preallocate.
1518 If the total size of arguments that would otherwise create a copy in
1519 a temporary (such as a CALL) is more than half the total argument list
1520 size, preallocation is faster.
1522 Another reason to preallocate is if we have a machine (like the m88k)
1523 where stack alignment is required to be maintained between every
1524 pair of insns, not just when the call is made. However, we assume here
1525 that such machines either do not have push insns (and hence preallocation
1526 would occur anyway) or the problem is taken care of with
1529 if (! must_preallocate)
1531 int partial_seen = 0;
1532 int copy_to_evaluate_size = 0;
1535 for (i = 0; i < num_actuals && ! must_preallocate; i++)
1537 if (args[i].partial > 0 && ! args[i].pass_on_stack)
1539 else if (partial_seen && args[i].reg == 0)
1540 must_preallocate = 1;
1542 if (TYPE_MODE (TREE_TYPE (args[i].tree_value)) == BLKmode
1543 && (TREE_CODE (args[i].tree_value) == CALL_EXPR
1544 || TREE_CODE (args[i].tree_value) == TARGET_EXPR
1545 || TREE_CODE (args[i].tree_value) == COND_EXPR
1546 || TREE_ADDRESSABLE (TREE_TYPE (args[i].tree_value))))
1547 copy_to_evaluate_size
1548 += int_size_in_bytes (TREE_TYPE (args[i].tree_value));
1551 if (copy_to_evaluate_size * 2 >= args_size->constant
1552 && args_size->constant > 0)
1553 must_preallocate = 1;
1555 return must_preallocate;
1558 /* If we preallocated stack space, compute the address of each argument
1559 and store it into the ARGS array.
1561 We need not ensure it is a valid memory address here; it will be
1562 validized when it is used.
1564 ARGBLOCK is an rtx for the address of the outgoing arguments. */
1567 compute_argument_addresses (args, argblock, num_actuals)
1568 struct arg_data *args;
1574 rtx arg_reg = argblock;
1575 int i, arg_offset = 0;
1577 if (GET_CODE (argblock) == PLUS)
1578 arg_reg = XEXP (argblock, 0), arg_offset = INTVAL (XEXP (argblock, 1));
1580 for (i = 0; i < num_actuals; i++)
1582 rtx offset = ARGS_SIZE_RTX (args[i].offset);
1583 rtx slot_offset = ARGS_SIZE_RTX (args[i].slot_offset);
1586 /* Skip this parm if it will not be passed on the stack. */
1587 if (! args[i].pass_on_stack && args[i].reg != 0)
1590 if (GET_CODE (offset) == CONST_INT)
1591 addr = plus_constant (arg_reg, INTVAL (offset));
1593 addr = gen_rtx_PLUS (Pmode, arg_reg, offset);
1595 addr = plus_constant (addr, arg_offset);
1596 args[i].stack = gen_rtx_MEM (args[i].mode, addr);
1597 set_mem_attributes (args[i].stack,
1598 TREE_TYPE (args[i].tree_value), 1);
1600 if (GET_CODE (slot_offset) == CONST_INT)
1601 addr = plus_constant (arg_reg, INTVAL (slot_offset));
1603 addr = gen_rtx_PLUS (Pmode, arg_reg, slot_offset);
1605 addr = plus_constant (addr, arg_offset);
1606 args[i].stack_slot = gen_rtx_MEM (args[i].mode, addr);
1607 set_mem_attributes (args[i].stack_slot,
1608 TREE_TYPE (args[i].tree_value), 1);
1610 /* Function incoming arguments may overlap with sibling call
1611 outgoing arguments and we cannot allow reordering of reads
1612 from function arguments with stores to outgoing arguments
1613 of sibling calls. */
1614 MEM_ALIAS_SET (args[i].stack) = 0;
1615 MEM_ALIAS_SET (args[i].stack_slot) = 0;
1620 /* Given a FNDECL and EXP, return an rtx suitable for use as a target address
1621 in a call instruction.
1623 FNDECL is the tree node for the target function. For an indirect call
1624 FNDECL will be NULL_TREE.
1626 EXP is the CALL_EXPR for this call. */
1629 rtx_for_function_call (fndecl, exp)
1635 /* Get the function to call, in the form of RTL. */
1638 /* If this is the first use of the function, see if we need to
1639 make an external definition for it. */
1640 if (! TREE_USED (fndecl))
1642 assemble_external (fndecl);
1643 TREE_USED (fndecl) = 1;
1646 /* Get a SYMBOL_REF rtx for the function address. */
1647 funexp = XEXP (DECL_RTL (fndecl), 0);
1650 /* Generate an rtx (probably a pseudo-register) for the address. */
1655 expand_expr (TREE_OPERAND (exp, 0), NULL_RTX, VOIDmode, 0);
1656 pop_temp_slots (); /* FUNEXP can't be BLKmode */
1658 /* Check the function is executable. */
1659 if (current_function_check_memory_usage)
1661 #ifdef POINTERS_EXTEND_UNSIGNED
1662 /* It might be OK to convert funexp in place, but there's
1663 a lot going on between here and when it happens naturally
1664 that this seems safer. */
1665 funaddr = convert_memory_address (Pmode, funexp);
1667 emit_library_call (chkr_check_exec_libfunc, 1,
1676 /* Do the register loads required for any wholly-register parms or any
1677 parms which are passed both on the stack and in a register. Their
1678 expressions were already evaluated.
1680 Mark all register-parms as living through the call, putting these USE
1681 insns in the CALL_INSN_FUNCTION_USAGE field. */
1684 load_register_parameters (args, num_actuals, call_fusage, flags)
1685 struct arg_data *args;
1692 #ifdef LOAD_ARGS_REVERSED
1693 for (i = num_actuals - 1; i >= 0; i--)
1695 for (i = 0; i < num_actuals; i++)
1698 rtx reg = ((flags & ECF_SIBCALL)
1699 ? args[i].tail_call_reg : args[i].reg);
1700 int partial = args[i].partial;
1705 /* Set to non-negative if must move a word at a time, even if just
1706 one word (e.g, partial == 1 && mode == DFmode). Set to -1 if
1707 we just use a normal move insn. This value can be zero if the
1708 argument is a zero size structure with no fields. */
1709 nregs = (partial ? partial
1710 : (TYPE_MODE (TREE_TYPE (args[i].tree_value)) == BLKmode
1711 ? ((int_size_in_bytes (TREE_TYPE (args[i].tree_value))
1712 + (UNITS_PER_WORD - 1)) / UNITS_PER_WORD)
1715 /* Handle calls that pass values in multiple non-contiguous
1716 locations. The Irix 6 ABI has examples of this. */
1718 if (GET_CODE (reg) == PARALLEL)
1719 emit_group_load (reg, args[i].value,
1720 int_size_in_bytes (TREE_TYPE (args[i].tree_value)),
1721 TYPE_ALIGN (TREE_TYPE (args[i].tree_value)));
1723 /* If simple case, just do move. If normal partial, store_one_arg
1724 has already loaded the register for us. In all other cases,
1725 load the register(s) from memory. */
1727 else if (nregs == -1)
1728 emit_move_insn (reg, args[i].value);
1730 /* If we have pre-computed the values to put in the registers in
1731 the case of non-aligned structures, copy them in now. */
1733 else if (args[i].n_aligned_regs != 0)
1734 for (j = 0; j < args[i].n_aligned_regs; j++)
1735 emit_move_insn (gen_rtx_REG (word_mode, REGNO (reg) + j),
1736 args[i].aligned_regs[j]);
1738 else if (partial == 0 || args[i].pass_on_stack)
1739 move_block_to_reg (REGNO (reg),
1740 validize_mem (args[i].value), nregs,
1743 /* Handle calls that pass values in multiple non-contiguous
1744 locations. The Irix 6 ABI has examples of this. */
1745 if (GET_CODE (reg) == PARALLEL)
1746 use_group_regs (call_fusage, reg);
1747 else if (nregs == -1)
1748 use_reg (call_fusage, reg);
1750 use_regs (call_fusage, REGNO (reg), nregs == 0 ? 1 : nregs);
1755 /* Try to integrate function. See expand_inline_function for documentation
1756 about the parameters. */
1759 try_to_integrate (fndecl, actparms, target, ignore, type, structure_value_addr)
1765 rtx structure_value_addr;
1770 rtx old_stack_level = 0;
1771 int reg_parm_stack_space = 0;
1773 #ifdef REG_PARM_STACK_SPACE
1774 #ifdef MAYBE_REG_PARM_STACK_SPACE
1775 reg_parm_stack_space = MAYBE_REG_PARM_STACK_SPACE;
1777 reg_parm_stack_space = REG_PARM_STACK_SPACE (fndecl);
1781 before_call = get_last_insn ();
1783 timevar_push (TV_INTEGRATION);
1785 temp = expand_inline_function (fndecl, actparms, target,
1787 structure_value_addr);
1789 timevar_pop (TV_INTEGRATION);
1791 /* If inlining succeeded, return. */
1792 if (temp != (rtx) (HOST_WIDE_INT) - 1)
1794 if (ACCUMULATE_OUTGOING_ARGS)
1796 /* If the outgoing argument list must be preserved, push
1797 the stack before executing the inlined function if it
1800 for (i = reg_parm_stack_space - 1; i >= 0; i--)
1801 if (i < highest_outgoing_arg_in_use && stack_usage_map[i] != 0)
1804 if (stack_arg_under_construction || i >= 0)
1807 = before_call ? NEXT_INSN (before_call) : get_insns ();
1808 rtx insn = NULL_RTX, seq;
1810 /* Look for a call in the inline function code.
1811 If DECL_SAVED_INSNS (fndecl)->outgoing_args_size is
1812 nonzero then there is a call and it is not necessary
1813 to scan the insns. */
1815 if (DECL_SAVED_INSNS (fndecl)->outgoing_args_size == 0)
1816 for (insn = first_insn; insn; insn = NEXT_INSN (insn))
1817 if (GET_CODE (insn) == CALL_INSN)
1822 /* Reserve enough stack space so that the largest
1823 argument list of any function call in the inline
1824 function does not overlap the argument list being
1825 evaluated. This is usually an overestimate because
1826 allocate_dynamic_stack_space reserves space for an
1827 outgoing argument list in addition to the requested
1828 space, but there is no way to ask for stack space such
1829 that an argument list of a certain length can be
1832 Add the stack space reserved for register arguments, if
1833 any, in the inline function. What is really needed is the
1834 largest value of reg_parm_stack_space in the inline
1835 function, but that is not available. Using the current
1836 value of reg_parm_stack_space is wrong, but gives
1837 correct results on all supported machines. */
1839 int adjust = (DECL_SAVED_INSNS (fndecl)->outgoing_args_size
1840 + reg_parm_stack_space);
1843 emit_stack_save (SAVE_BLOCK, &old_stack_level, NULL_RTX);
1844 allocate_dynamic_stack_space (GEN_INT (adjust),
1845 NULL_RTX, BITS_PER_UNIT);
1848 emit_insns_before (seq, first_insn);
1849 emit_stack_restore (SAVE_BLOCK, old_stack_level, NULL_RTX);
1854 /* If the result is equivalent to TARGET, return TARGET to simplify
1855 checks in store_expr. They can be equivalent but not equal in the
1856 case of a function that returns BLKmode. */
1857 if (temp != target && rtx_equal_p (temp, target))
1862 /* If inlining failed, mark FNDECL as needing to be compiled
1863 separately after all. If function was declared inline,
1865 if (DECL_INLINE (fndecl) && warn_inline && !flag_no_inline
1866 && optimize > 0 && !TREE_ADDRESSABLE (fndecl))
1868 warning_with_decl (fndecl, "inlining failed in call to `%s'");
1869 warning ("called from here");
1871 mark_addressable (fndecl);
1872 return (rtx) (HOST_WIDE_INT) - 1;
1875 /* We need to pop PENDING_STACK_ADJUST bytes. But, if the arguments
1876 wouldn't fill up an even multiple of PREFERRED_UNIT_STACK_BOUNDARY
1877 bytes, then we would need to push some additional bytes to pad the
1878 arguments. So, we compute an adjust to the stack pointer for an
1879 amount that will leave the stack under-aligned by UNADJUSTED_ARGS_SIZE
1880 bytes. Then, when the arguments are pushed the stack will be perfectly
1881 aligned. ARGS_SIZE->CONSTANT is set to the number of bytes that should
1882 be popped after the call. Returns the adjustment. */
1885 combine_pending_stack_adjustment_and_call (unadjusted_args_size,
1887 preferred_unit_stack_boundary)
1888 int unadjusted_args_size;
1889 struct args_size *args_size;
1890 int preferred_unit_stack_boundary;
1892 /* The number of bytes to pop so that the stack will be
1893 under-aligned by UNADJUSTED_ARGS_SIZE bytes. */
1894 HOST_WIDE_INT adjustment;
1895 /* The alignment of the stack after the arguments are pushed, if we
1896 just pushed the arguments without adjust the stack here. */
1897 HOST_WIDE_INT unadjusted_alignment;
1899 unadjusted_alignment
1900 = ((stack_pointer_delta + unadjusted_args_size)
1901 % preferred_unit_stack_boundary);
1903 /* We want to get rid of as many of the PENDING_STACK_ADJUST bytes
1904 as possible -- leaving just enough left to cancel out the
1905 UNADJUSTED_ALIGNMENT. In other words, we want to ensure that the
1906 PENDING_STACK_ADJUST is non-negative, and congruent to
1907 -UNADJUSTED_ALIGNMENT modulo the PREFERRED_UNIT_STACK_BOUNDARY. */
1909 /* Begin by trying to pop all the bytes. */
1910 unadjusted_alignment
1911 = (unadjusted_alignment
1912 - (pending_stack_adjust % preferred_unit_stack_boundary));
1913 adjustment = pending_stack_adjust;
1914 /* Push enough additional bytes that the stack will be aligned
1915 after the arguments are pushed. */
1916 if (preferred_unit_stack_boundary > 1)
1918 if (unadjusted_alignment >= 0)
1919 adjustment -= preferred_unit_stack_boundary - unadjusted_alignment;
1921 adjustment += unadjusted_alignment;
1924 /* Now, sets ARGS_SIZE->CONSTANT so that we pop the right number of
1925 bytes after the call. The right number is the entire
1926 PENDING_STACK_ADJUST less our ADJUSTMENT plus the amount required
1927 by the arguments in the first place. */
1929 = pending_stack_adjust - adjustment + unadjusted_args_size;
1934 /* Scan X expression if it does not dereference any argument slots
1935 we already clobbered by tail call arguments (as noted in stored_args_map
1937 Return non-zero if X expression dereferences such argument slots,
1941 check_sibcall_argument_overlap_1 (x)
1952 code = GET_CODE (x);
1956 if (XEXP (x, 0) == current_function_internal_arg_pointer)
1958 else if (GET_CODE (XEXP (x, 0)) == PLUS
1959 && XEXP (XEXP (x, 0), 0) ==
1960 current_function_internal_arg_pointer
1961 && GET_CODE (XEXP (XEXP (x, 0), 1)) == CONST_INT)
1962 i = INTVAL (XEXP (XEXP (x, 0), 1));
1966 for (k = 0; k < GET_MODE_SIZE (GET_MODE (x)); k++)
1967 if (i + k < stored_args_map->n_bits
1968 && TEST_BIT (stored_args_map, i + k))
1974 /* Scan all subexpressions. */
1975 fmt = GET_RTX_FORMAT (code);
1976 for (i = 0; i < GET_RTX_LENGTH (code); i++, fmt++)
1980 if (check_sibcall_argument_overlap_1 (XEXP (x, i)))
1983 else if (*fmt == 'E')
1985 for (j = 0; j < XVECLEN (x, i); j++)
1986 if (check_sibcall_argument_overlap_1 (XVECEXP (x, i, j)))
1994 /* Scan sequence after INSN if it does not dereference any argument slots
1995 we already clobbered by tail call arguments (as noted in stored_args_map
1996 bitmap). Add stack slots for ARG to stored_args_map bitmap afterwards.
1997 Return non-zero if sequence after INSN dereferences such argument slots,
2001 check_sibcall_argument_overlap (insn, arg)
2003 struct arg_data *arg;
2007 if (insn == NULL_RTX)
2008 insn = get_insns ();
2010 insn = NEXT_INSN (insn);
2012 for (; insn; insn = NEXT_INSN (insn))
2013 if (INSN_P (insn) &&
2014 check_sibcall_argument_overlap_1 (PATTERN (insn)))
2017 low = arg->offset.constant;
2018 for (high = low + arg->size.constant; low < high; low++)
2019 SET_BIT (stored_args_map, low);
2020 return insn != NULL_RTX;
2023 /* Generate all the code for a function call
2024 and return an rtx for its value.
2025 Store the value in TARGET (specified as an rtx) if convenient.
2026 If the value is stored in TARGET then TARGET is returned.
2027 If IGNORE is nonzero, then we ignore the value of the function call. */
2030 expand_call (exp, target, ignore)
2035 /* Nonzero if we are currently expanding a call. */
2036 static int currently_expanding_call = 0;
2038 /* List of actual parameters. */
2039 tree actparms = TREE_OPERAND (exp, 1);
2040 /* RTX for the function to be called. */
2042 /* Sequence of insns to perform a tail recursive "call". */
2043 rtx tail_recursion_insns = NULL_RTX;
2044 /* Sequence of insns to perform a normal "call". */
2045 rtx normal_call_insns = NULL_RTX;
2046 /* Sequence of insns to perform a tail recursive "call". */
2047 rtx tail_call_insns = NULL_RTX;
2048 /* Data type of the function. */
2050 /* Declaration of the function being called,
2051 or 0 if the function is computed (not known by name). */
2055 int try_tail_call = 1;
2056 int try_tail_recursion = 1;
2059 /* Register in which non-BLKmode value will be returned,
2060 or 0 if no value or if value is BLKmode. */
2062 /* Address where we should return a BLKmode value;
2063 0 if value not BLKmode. */
2064 rtx structure_value_addr = 0;
2065 /* Nonzero if that address is being passed by treating it as
2066 an extra, implicit first parameter. Otherwise,
2067 it is passed by being copied directly into struct_value_rtx. */
2068 int structure_value_addr_parm = 0;
2069 /* Size of aggregate value wanted, or zero if none wanted
2070 or if we are using the non-reentrant PCC calling convention
2071 or expecting the value in registers. */
2072 HOST_WIDE_INT struct_value_size = 0;
2073 /* Nonzero if called function returns an aggregate in memory PCC style,
2074 by returning the address of where to find it. */
2075 int pcc_struct_value = 0;
2077 /* Number of actual parameters in this call, including struct value addr. */
2079 /* Number of named args. Args after this are anonymous ones
2080 and they must all go on the stack. */
2083 /* Vector of information about each argument.
2084 Arguments are numbered in the order they will be pushed,
2085 not the order they are written. */
2086 struct arg_data *args;
2088 /* Total size in bytes of all the stack-parms scanned so far. */
2089 struct args_size args_size;
2090 struct args_size adjusted_args_size;
2091 /* Size of arguments before any adjustments (such as rounding). */
2092 int unadjusted_args_size;
2093 /* Data on reg parms scanned so far. */
2094 CUMULATIVE_ARGS args_so_far;
2095 /* Nonzero if a reg parm has been scanned. */
2097 /* Nonzero if this is an indirect function call. */
2099 /* Nonzero if we must avoid push-insns in the args for this call.
2100 If stack space is allocated for register parameters, but not by the
2101 caller, then it is preallocated in the fixed part of the stack frame.
2102 So the entire argument block must then be preallocated (i.e., we
2103 ignore PUSH_ROUNDING in that case). */
2105 int must_preallocate = !PUSH_ARGS;
2107 /* Size of the stack reserved for parameter registers. */
2108 int reg_parm_stack_space = 0;
2110 /* Address of space preallocated for stack parms
2111 (on machines that lack push insns), or 0 if space not preallocated. */
2114 /* Mask of ECF_ flags. */
2116 /* Nonzero if this is a call to an inline function. */
2117 int is_integrable = 0;
2118 #ifdef REG_PARM_STACK_SPACE
2119 /* Define the boundary of the register parm stack space that needs to be
2121 int low_to_save = -1, high_to_save;
2122 rtx save_area = 0; /* Place that it is saved */
2125 int initial_highest_arg_in_use = highest_outgoing_arg_in_use;
2126 char *initial_stack_usage_map = stack_usage_map;
2127 int old_stack_arg_under_construction = 0;
2129 rtx old_stack_level = 0;
2130 int old_pending_adj = 0;
2131 int old_inhibit_defer_pop = inhibit_defer_pop;
2132 int old_stack_allocated;
2136 /* The alignment of the stack, in bits. */
2137 HOST_WIDE_INT preferred_stack_boundary;
2138 /* The alignment of the stack, in bytes. */
2139 HOST_WIDE_INT preferred_unit_stack_boundary;
2141 /* The value of the function call can be put in a hard register. But
2142 if -fcheck-memory-usage, code which invokes functions (and thus
2143 damages some hard registers) can be inserted before using the value.
2144 So, target is always a pseudo-register in that case. */
2145 if (current_function_check_memory_usage)
2148 /* See if this is "nothrow" function call. */
2149 if (TREE_NOTHROW (exp))
2150 flags |= ECF_NOTHROW;
2152 /* See if we can find a DECL-node for the actual function.
2153 As a result, decide whether this is a call to an integrable function. */
2155 fndecl = get_callee_fndecl (exp);
2159 && fndecl != current_function_decl
2160 && DECL_INLINE (fndecl)
2161 && DECL_SAVED_INSNS (fndecl)
2162 && DECL_SAVED_INSNS (fndecl)->inlinable)
2164 else if (! TREE_ADDRESSABLE (fndecl))
2166 /* In case this function later becomes inlinable,
2167 record that there was already a non-inline call to it.
2169 Use abstraction instead of setting TREE_ADDRESSABLE
2171 if (DECL_INLINE (fndecl) && warn_inline && !flag_no_inline
2174 warning_with_decl (fndecl, "can't inline call to `%s'");
2175 warning ("called from here");
2177 mark_addressable (fndecl);
2180 flags |= flags_from_decl_or_type (fndecl);
2183 /* If we don't have specific function to call, see if we have a
2184 attributes set in the type. */
2187 p = TREE_OPERAND (exp, 0);
2188 flags |= flags_from_decl_or_type (TREE_TYPE (TREE_TYPE (p)));
2191 #ifdef REG_PARM_STACK_SPACE
2192 #ifdef MAYBE_REG_PARM_STACK_SPACE
2193 reg_parm_stack_space = MAYBE_REG_PARM_STACK_SPACE;
2195 reg_parm_stack_space = REG_PARM_STACK_SPACE (fndecl);
2199 #ifndef OUTGOING_REG_PARM_STACK_SPACE
2200 if (reg_parm_stack_space > 0 && PUSH_ARGS)
2201 must_preallocate = 1;
2204 /* Warn if this value is an aggregate type,
2205 regardless of which calling convention we are using for it. */
2206 if (warn_aggregate_return && AGGREGATE_TYPE_P (TREE_TYPE (exp)))
2207 warning ("function call has aggregate value");
2209 /* Set up a place to return a structure. */
2211 /* Cater to broken compilers. */
2212 if (aggregate_value_p (exp))
2214 /* This call returns a big structure. */
2215 flags &= ~(ECF_CONST | ECF_PURE);
2217 #ifdef PCC_STATIC_STRUCT_RETURN
2219 pcc_struct_value = 1;
2220 /* Easier than making that case work right. */
2223 /* In case this is a static function, note that it has been
2225 if (! TREE_ADDRESSABLE (fndecl))
2226 mark_addressable (fndecl);
2230 #else /* not PCC_STATIC_STRUCT_RETURN */
2232 struct_value_size = int_size_in_bytes (TREE_TYPE (exp));
2234 if (target && GET_CODE (target) == MEM)
2235 structure_value_addr = XEXP (target, 0);
2238 /* Assign a temporary to hold the value. */
2241 /* For variable-sized objects, we must be called with a target
2242 specified. If we were to allocate space on the stack here,
2243 we would have no way of knowing when to free it. */
2245 if (struct_value_size < 0)
2248 /* This DECL is just something to feed to mark_addressable;
2249 it doesn't get pushed. */
2250 d = build_decl (VAR_DECL, NULL_TREE, TREE_TYPE (exp));
2251 DECL_RTL (d) = assign_temp (TREE_TYPE (exp), 1, 0, 1);
2252 mark_addressable (d);
2253 mark_temp_addr_taken (DECL_RTL (d));
2254 structure_value_addr = XEXP (DECL_RTL (d), 0);
2259 #endif /* not PCC_STATIC_STRUCT_RETURN */
2262 /* If called function is inline, try to integrate it. */
2266 rtx temp = try_to_integrate (fndecl, actparms, target,
2267 ignore, TREE_TYPE (exp),
2268 structure_value_addr);
2269 if (temp != (rtx) (HOST_WIDE_INT) - 1)
2273 if (fndecl && DECL_NAME (fndecl))
2274 name = IDENTIFIER_POINTER (DECL_NAME (fndecl));
2276 /* Figure out the amount to which the stack should be aligned. */
2277 #ifdef PREFERRED_STACK_BOUNDARY
2278 preferred_stack_boundary = PREFERRED_STACK_BOUNDARY;
2280 preferred_stack_boundary = STACK_BOUNDARY;
2283 /* Operand 0 is a pointer-to-function; get the type of the function. */
2284 funtype = TREE_TYPE (TREE_OPERAND (exp, 0));
2285 if (! POINTER_TYPE_P (funtype))
2287 funtype = TREE_TYPE (funtype);
2289 /* See if this is a call to a function that can return more than once
2290 or a call to longjmp or malloc. */
2291 flags |= special_function_p (fndecl, flags);
2293 if (flags & ECF_MAY_BE_ALLOCA)
2294 current_function_calls_alloca = 1;
2296 /* If struct_value_rtx is 0, it means pass the address
2297 as if it were an extra parameter. */
2298 if (structure_value_addr && struct_value_rtx == 0)
2300 /* If structure_value_addr is a REG other than
2301 virtual_outgoing_args_rtx, we can use always use it. If it
2302 is not a REG, we must always copy it into a register.
2303 If it is virtual_outgoing_args_rtx, we must copy it to another
2304 register in some cases. */
2305 rtx temp = (GET_CODE (structure_value_addr) != REG
2306 || (ACCUMULATE_OUTGOING_ARGS
2307 && stack_arg_under_construction
2308 && structure_value_addr == virtual_outgoing_args_rtx)
2309 ? copy_addr_to_reg (structure_value_addr)
2310 : structure_value_addr);
2313 = tree_cons (error_mark_node,
2314 make_tree (build_pointer_type (TREE_TYPE (funtype)),
2317 structure_value_addr_parm = 1;
2320 /* Count the arguments and set NUM_ACTUALS. */
2321 for (p = actparms, num_actuals = 0; p; p = TREE_CHAIN (p))
2324 /* Compute number of named args.
2325 Normally, don't include the last named arg if anonymous args follow.
2326 We do include the last named arg if STRICT_ARGUMENT_NAMING is nonzero.
2327 (If no anonymous args follow, the result of list_length is actually
2328 one too large. This is harmless.)
2330 If PRETEND_OUTGOING_VARARGS_NAMED is set and STRICT_ARGUMENT_NAMING is
2331 zero, this machine will be able to place unnamed args that were
2332 passed in registers into the stack. So treat all args as named.
2333 This allows the insns emitting for a specific argument list to be
2334 independent of the function declaration.
2336 If PRETEND_OUTGOING_VARARGS_NAMED is not set, we do not have any
2337 reliable way to pass unnamed args in registers, so we must force
2338 them into memory. */
2340 if ((STRICT_ARGUMENT_NAMING
2341 || ! PRETEND_OUTGOING_VARARGS_NAMED)
2342 && TYPE_ARG_TYPES (funtype) != 0)
2344 = (list_length (TYPE_ARG_TYPES (funtype))
2345 /* Don't include the last named arg. */
2346 - (STRICT_ARGUMENT_NAMING ? 0 : 1)
2347 /* Count the struct value address, if it is passed as a parm. */
2348 + structure_value_addr_parm);
2350 /* If we know nothing, treat all args as named. */
2351 n_named_args = num_actuals;
2353 /* Start updating where the next arg would go.
2355 On some machines (such as the PA) indirect calls have a different
2356 calling convention than normal calls. The last argument in
2357 INIT_CUMULATIVE_ARGS tells the backend if this is an indirect call
2359 INIT_CUMULATIVE_ARGS (args_so_far, funtype, NULL_RTX, (fndecl == 0));
2362 /* Make a vector to hold all the information about each arg. */
2363 args = (struct arg_data *) alloca (num_actuals
2364 * sizeof (struct arg_data));
2365 bzero ((char *) args, num_actuals * sizeof (struct arg_data));
2367 /* Build up entries inthe ARGS array, compute the size of the arguments
2368 into ARGS_SIZE, etc. */
2369 initialize_argument_information (num_actuals, args, &args_size,
2370 n_named_args, actparms, fndecl,
2371 &args_so_far, reg_parm_stack_space,
2372 &old_stack_level, &old_pending_adj,
2373 &must_preallocate, &flags);
2377 /* If this function requires a variable-sized argument list, don't
2378 try to make a cse'able block for this call. We may be able to
2379 do this eventually, but it is too complicated to keep track of
2380 what insns go in the cse'able block and which don't. */
2382 flags &= ~(ECF_CONST | ECF_PURE);
2383 must_preallocate = 1;
2386 /* Now make final decision about preallocating stack space. */
2387 must_preallocate = finalize_must_preallocate (must_preallocate,
2391 /* If the structure value address will reference the stack pointer, we
2392 must stabilize it. We don't need to do this if we know that we are
2393 not going to adjust the stack pointer in processing this call. */
2395 if (structure_value_addr
2396 && (reg_mentioned_p (virtual_stack_dynamic_rtx, structure_value_addr)
2397 || reg_mentioned_p (virtual_outgoing_args_rtx,
2398 structure_value_addr))
2400 || (!ACCUMULATE_OUTGOING_ARGS && args_size.constant)))
2401 structure_value_addr = copy_to_reg (structure_value_addr);
2403 /* Tail calls can make things harder to debug, and we're traditionally
2404 pushed these optimizations into -O2. Don't try if we're already
2405 expanding a call, as that means we're an argument. Similarly, if
2406 there's pending loops or cleanups we know there's code to follow
2409 If rtx_equal_function_value_matters is false, that means we've
2410 finished with regular parsing. Which means that some of the
2411 machinery we use to generate tail-calls is no longer in place.
2412 This is most often true of sjlj-exceptions, which we couldn't
2413 tail-call to anyway. */
2415 if (currently_expanding_call++ != 0
2416 || !flag_optimize_sibling_calls
2417 || !rtx_equal_function_value_matters
2418 || !stmt_loop_nest_empty ()
2419 || any_pending_cleanups (1)
2421 try_tail_call = try_tail_recursion = 0;
2423 /* Tail recursion fails, when we are not dealing with recursive calls. */
2424 if (!try_tail_recursion
2425 || TREE_CODE (TREE_OPERAND (exp, 0)) != ADDR_EXPR
2426 || TREE_OPERAND (TREE_OPERAND (exp, 0), 0) != current_function_decl)
2427 try_tail_recursion = 0;
2429 /* Rest of purposes for tail call optimizations to fail. */
2431 #ifdef HAVE_sibcall_epilogue
2432 !HAVE_sibcall_epilogue
2437 /* Doing sibling call optimization needs some work, since
2438 structure_value_addr can be allocated on the stack.
2439 It does not seem worth the effort since few optimizable
2440 sibling calls will return a structure. */
2441 || structure_value_addr != NULL_RTX
2442 /* If the register holding the address is a callee saved
2443 register, then we lose. We have no way to prevent that,
2444 so we only allow calls to named functions. */
2445 /* ??? This could be done by having the insn constraints
2446 use a register class that is all call-clobbered. Any
2447 reload insns generated to fix things up would appear
2448 before the sibcall_epilogue. */
2449 || fndecl == NULL_TREE
2450 || (flags & (ECF_RETURNS_TWICE | ECF_LONGJMP))
2451 || !FUNCTION_OK_FOR_SIBCALL (fndecl)
2452 /* If this function requires more stack slots than the current
2453 function, we cannot change it into a sibling call. */
2454 || args_size.constant > current_function_args_size
2455 /* If the callee pops its own arguments, then it must pop exactly
2456 the same number of arguments as the current function. */
2457 || RETURN_POPS_ARGS (fndecl, funtype, args_size.constant)
2458 != RETURN_POPS_ARGS (current_function_decl,
2459 TREE_TYPE (current_function_decl),
2460 current_function_args_size))
2463 if (try_tail_call || try_tail_recursion)
2466 actparms = NULL_TREE;
2467 /* Ok, we're going to give the tail call the old college try.
2468 This means we're going to evaluate the function arguments
2469 up to three times. There are two degrees of badness we can
2470 encounter, those that can be unsaved and those that can't.
2471 (See unsafe_for_reeval commentary for details.)
2473 Generate a new argument list. Pass safe arguments through
2474 unchanged. For the easy badness wrap them in UNSAVE_EXPRs.
2475 For hard badness, evaluate them now and put their resulting
2476 rtx in a temporary VAR_DECL.
2478 initialize_argument_information has ordered the array for the
2479 order to be pushed, and we must remember this when reconstructing
2480 the original argument orde. */
2482 if (PUSH_ARGS_REVERSED)
2491 i = num_actuals - 1;
2495 for (; i != end; i += inc)
2497 switch (unsafe_for_reeval (args[i].tree_value))
2502 case 1: /* Mildly unsafe. */
2503 args[i].tree_value = unsave_expr (args[i].tree_value);
2506 case 2: /* Wildly unsafe. */
2508 tree var = build_decl (VAR_DECL, NULL_TREE,
2509 TREE_TYPE (args[i].tree_value));
2510 DECL_RTL (var) = expand_expr (args[i].tree_value, NULL_RTX,
2511 VOIDmode, EXPAND_NORMAL);
2512 args[i].tree_value = var;
2519 /* We need to build actparms for optimize_tail_recursion. We can
2520 safely trash away TREE_PURPOSE, since it is unused by this
2522 if (try_tail_recursion)
2523 actparms = tree_cons (NULL_TREE, args[i].tree_value, actparms);
2525 /* Expanding one of those dangerous arguments could have added
2526 cleanups, but otherwise give it a whirl. */
2527 if (any_pending_cleanups (1))
2528 try_tail_call = try_tail_recursion = 0;
2531 /* Generate a tail recursion sequence when calling ourselves. */
2533 if (try_tail_recursion)
2535 /* We want to emit any pending stack adjustments before the tail
2536 recursion "call". That way we know any adjustment after the tail
2537 recursion call can be ignored if we indeed use the tail recursion
2539 int save_pending_stack_adjust = pending_stack_adjust;
2540 int save_stack_pointer_delta = stack_pointer_delta;
2542 /* Use a new sequence to hold any RTL we generate. We do not even
2543 know if we will use this RTL yet. The final decision can not be
2544 made until after RTL generation for the entire function is
2547 /* If expanding any of the arguments creates cleanups, we can't
2548 do a tailcall. So, we'll need to pop the pending cleanups
2549 list. If, however, all goes well, and there are no cleanups
2550 then the call to expand_start_target_temps will have no
2552 expand_start_target_temps ();
2553 if (optimize_tail_recursion (actparms, get_last_insn ()))
2555 if (any_pending_cleanups (1))
2556 try_tail_call = try_tail_recursion = 0;
2558 tail_recursion_insns = get_insns ();
2560 expand_end_target_temps ();
2563 /* Restore the original pending stack adjustment for the sibling and
2564 normal call cases below. */
2565 pending_stack_adjust = save_pending_stack_adjust;
2566 stack_pointer_delta = save_stack_pointer_delta;
2569 if (profile_arc_flag && (flags & ECF_FORK_OR_EXEC))
2571 /* A fork duplicates the profile information, and an exec discards
2572 it. We can't rely on fork/exec to be paired. So write out the
2573 profile information we have gathered so far, and clear it. */
2574 /* ??? When Linux's __clone is called with CLONE_VM set, profiling
2575 is subject to race conditions, just as with multithreaded
2578 emit_library_call (gen_rtx_SYMBOL_REF (Pmode, "__bb_fork_func"), 0,
2582 /* Ensure current function's preferred stack boundary is at least
2583 what we need. We don't have to increase alignment for recursive
2585 if (cfun->preferred_stack_boundary < preferred_stack_boundary
2586 && fndecl != current_function_decl)
2587 cfun->preferred_stack_boundary = preferred_stack_boundary;
2589 preferred_unit_stack_boundary = preferred_stack_boundary / BITS_PER_UNIT;
2591 function_call_count++;
2593 /* We want to make two insn chains; one for a sibling call, the other
2594 for a normal call. We will select one of the two chains after
2595 initial RTL generation is complete. */
2596 for (pass = 0; pass < 2; pass++)
2598 int sibcall_failure = 0;
2599 /* We want to emit ay pending stack adjustments before the tail
2600 recursion "call". That way we know any adjustment after the tail
2601 recursion call can be ignored if we indeed use the tail recursion
2603 int save_pending_stack_adjust = 0;
2604 int save_stack_pointer_delta = 0;
2606 rtx before_call, next_arg_reg;
2610 if (! try_tail_call)
2613 /* Emit any queued insns now; otherwise they would end up in
2614 only one of the alternates. */
2617 /* State variables we need to save and restore between
2619 save_pending_stack_adjust = pending_stack_adjust;
2620 save_stack_pointer_delta = stack_pointer_delta;
2623 flags &= ~ECF_SIBCALL;
2625 flags |= ECF_SIBCALL;
2627 /* Other state variables that we must reinitialize each time
2628 through the loop (that are not initialized by the loop itself). */
2632 /* Start a new sequence for the normal call case.
2634 From this point on, if the sibling call fails, we want to set
2635 sibcall_failure instead of continuing the loop. */
2640 /* We know at this point that there are not currently any
2641 pending cleanups. If, however, in the process of evaluating
2642 the arguments we were to create some, we'll need to be
2643 able to get rid of them. */
2644 expand_start_target_temps ();
2647 /* When calling a const function, we must pop the stack args right away,
2648 so that the pop is deleted or moved with the call. */
2649 if (flags & (ECF_CONST | ECF_PURE))
2652 /* Don't let pending stack adjusts add up to too much.
2653 Also, do all pending adjustments now if there is any chance
2654 this might be a call to alloca or if we are expanding a sibling
2656 if (pending_stack_adjust >= 32
2657 || (pending_stack_adjust > 0 && (flags & ECF_MAY_BE_ALLOCA))
2659 do_pending_stack_adjust ();
2661 /* Push the temporary stack slot level so that we can free any
2662 temporaries we make. */
2666 #ifdef FINAL_REG_PARM_STACK_SPACE
2667 reg_parm_stack_space = FINAL_REG_PARM_STACK_SPACE (args_size.constant,
2670 /* Precompute any arguments as needed. */
2672 precompute_arguments (flags, num_actuals, args);
2674 /* Now we are about to start emitting insns that can be deleted
2675 if a libcall is deleted. */
2676 if (flags & (ECF_CONST | ECF_PURE | ECF_MALLOC))
2679 adjusted_args_size = args_size;
2680 /* Compute the actual size of the argument block required. The variable
2681 and constant sizes must be combined, the size may have to be rounded,
2682 and there may be a minimum required size. When generating a sibcall
2683 pattern, do not round up, since we'll be re-using whatever space our
2685 unadjusted_args_size
2686 = compute_argument_block_size (reg_parm_stack_space, &adjusted_args_size,
2688 : preferred_stack_boundary));
2690 old_stack_allocated = stack_pointer_delta - pending_stack_adjust;
2692 /* The argument block when performing a sibling call is the
2693 incoming argument block. */
2696 argblock = virtual_incoming_args_rtx;
2697 stored_args_map = sbitmap_alloc (args_size.constant);
2698 sbitmap_zero (stored_args_map);
2701 /* If we have no actual push instructions, or shouldn't use them,
2702 make space for all args right now. */
2703 else if (adjusted_args_size.var != 0)
2705 if (old_stack_level == 0)
2707 emit_stack_save (SAVE_BLOCK, &old_stack_level, NULL_RTX);
2708 old_pending_adj = pending_stack_adjust;
2709 pending_stack_adjust = 0;
2710 /* stack_arg_under_construction says whether a stack arg is
2711 being constructed at the old stack level. Pushing the stack
2712 gets a clean outgoing argument block. */
2713 old_stack_arg_under_construction = stack_arg_under_construction;
2714 stack_arg_under_construction = 0;
2716 argblock = push_block (ARGS_SIZE_RTX (adjusted_args_size), 0, 0);
2720 /* Note that we must go through the motions of allocating an argument
2721 block even if the size is zero because we may be storing args
2722 in the area reserved for register arguments, which may be part of
2725 int needed = adjusted_args_size.constant;
2727 /* Store the maximum argument space used. It will be pushed by
2728 the prologue (if ACCUMULATE_OUTGOING_ARGS, or stack overflow
2731 if (needed > current_function_outgoing_args_size)
2732 current_function_outgoing_args_size = needed;
2734 if (must_preallocate)
2736 if (ACCUMULATE_OUTGOING_ARGS)
2738 /* Since the stack pointer will never be pushed, it is
2739 possible for the evaluation of a parm to clobber
2740 something we have already written to the stack.
2741 Since most function calls on RISC machines do not use
2742 the stack, this is uncommon, but must work correctly.
2744 Therefore, we save any area of the stack that was already
2745 written and that we are using. Here we set up to do this
2746 by making a new stack usage map from the old one. The
2747 actual save will be done by store_one_arg.
2749 Another approach might be to try to reorder the argument
2750 evaluations to avoid this conflicting stack usage. */
2752 #ifndef OUTGOING_REG_PARM_STACK_SPACE
2753 /* Since we will be writing into the entire argument area,
2754 the map must be allocated for its entire size, not just
2755 the part that is the responsibility of the caller. */
2756 needed += reg_parm_stack_space;
2759 #ifdef ARGS_GROW_DOWNWARD
2760 highest_outgoing_arg_in_use = MAX (initial_highest_arg_in_use,
2763 highest_outgoing_arg_in_use = MAX (initial_highest_arg_in_use,
2767 = (char *) alloca (highest_outgoing_arg_in_use);
2769 if (initial_highest_arg_in_use)
2770 bcopy (initial_stack_usage_map, stack_usage_map,
2771 initial_highest_arg_in_use);
2773 if (initial_highest_arg_in_use != highest_outgoing_arg_in_use)
2774 bzero (&stack_usage_map[initial_highest_arg_in_use],
2775 (highest_outgoing_arg_in_use
2776 - initial_highest_arg_in_use));
2779 /* The address of the outgoing argument list must not be
2780 copied to a register here, because argblock would be left
2781 pointing to the wrong place after the call to
2782 allocate_dynamic_stack_space below. */
2784 argblock = virtual_outgoing_args_rtx;
2788 if (inhibit_defer_pop == 0)
2790 /* Try to reuse some or all of the pending_stack_adjust
2791 to get this space. */
2793 = (combine_pending_stack_adjustment_and_call
2794 (unadjusted_args_size,
2795 &adjusted_args_size,
2796 preferred_unit_stack_boundary));
2798 /* combine_pending_stack_adjustment_and_call computes
2799 an adjustment before the arguments are allocated.
2800 Account for them and see whether or not the stack
2801 needs to go up or down. */
2802 needed = unadjusted_args_size - needed;
2806 /* We're releasing stack space. */
2807 /* ??? We can avoid any adjustment at all if we're
2808 already aligned. FIXME. */
2809 pending_stack_adjust = -needed;
2810 do_pending_stack_adjust ();
2814 /* We need to allocate space. We'll do that in
2815 push_block below. */
2816 pending_stack_adjust = 0;
2819 /* Special case this because overhead of `push_block' in
2820 this case is non-trivial. */
2822 argblock = virtual_outgoing_args_rtx;
2824 argblock = push_block (GEN_INT (needed), 0, 0);
2826 /* We only really need to call `copy_to_reg' in the case
2827 where push insns are going to be used to pass ARGBLOCK
2828 to a function call in ARGS. In that case, the stack
2829 pointer changes value from the allocation point to the
2830 call point, and hence the value of
2831 VIRTUAL_OUTGOING_ARGS_RTX changes as well. But might
2832 as well always do it. */
2833 argblock = copy_to_reg (argblock);
2835 /* The save/restore code in store_one_arg handles all
2836 cases except one: a constructor call (including a C
2837 function returning a BLKmode struct) to initialize
2839 if (stack_arg_under_construction)
2841 #ifndef OUTGOING_REG_PARM_STACK_SPACE
2842 rtx push_size = GEN_INT (reg_parm_stack_space
2843 + adjusted_args_size.constant);
2845 rtx push_size = GEN_INT (adjusted_args_size.constant);
2847 if (old_stack_level == 0)
2849 emit_stack_save (SAVE_BLOCK, &old_stack_level,
2851 old_pending_adj = pending_stack_adjust;
2852 pending_stack_adjust = 0;
2853 /* stack_arg_under_construction says whether a stack
2854 arg is being constructed at the old stack level.
2855 Pushing the stack gets a clean outgoing argument
2857 old_stack_arg_under_construction
2858 = stack_arg_under_construction;
2859 stack_arg_under_construction = 0;
2860 /* Make a new map for the new argument list. */
2861 stack_usage_map = (char *)
2862 alloca (highest_outgoing_arg_in_use);
2863 bzero (stack_usage_map, highest_outgoing_arg_in_use);
2864 highest_outgoing_arg_in_use = 0;
2866 allocate_dynamic_stack_space (push_size, NULL_RTX,
2869 /* If argument evaluation might modify the stack pointer,
2870 copy the address of the argument list to a register. */
2871 for (i = 0; i < num_actuals; i++)
2872 if (args[i].pass_on_stack)
2874 argblock = copy_addr_to_reg (argblock);
2881 compute_argument_addresses (args, argblock, num_actuals);
2883 #ifdef PREFERRED_STACK_BOUNDARY
2884 /* If we push args individually in reverse order, perform stack alignment
2885 before the first push (the last arg). */
2886 if (PUSH_ARGS_REVERSED && argblock == 0
2887 && adjusted_args_size.constant != unadjusted_args_size)
2889 /* When the stack adjustment is pending, we get better code
2890 by combining the adjustments. */
2891 if (pending_stack_adjust
2892 && ! (flags & (ECF_CONST | ECF_PURE))
2893 && ! inhibit_defer_pop)
2895 pending_stack_adjust
2896 = (combine_pending_stack_adjustment_and_call
2897 (unadjusted_args_size,
2898 &adjusted_args_size,
2899 preferred_unit_stack_boundary));
2900 do_pending_stack_adjust ();
2902 else if (argblock == 0)
2903 anti_adjust_stack (GEN_INT (adjusted_args_size.constant
2904 - unadjusted_args_size));
2906 /* Now that the stack is properly aligned, pops can't safely
2907 be deferred during the evaluation of the arguments. */
2911 /* Don't try to defer pops if preallocating, not even from the first arg,
2912 since ARGBLOCK probably refers to the SP. */
2916 funexp = rtx_for_function_call (fndecl, exp);
2918 /* Figure out the register where the value, if any, will come back. */
2920 if (TYPE_MODE (TREE_TYPE (exp)) != VOIDmode
2921 && ! structure_value_addr)
2923 if (pcc_struct_value)
2924 valreg = hard_function_value (build_pointer_type (TREE_TYPE (exp)),
2925 fndecl, (pass == 0));
2927 valreg = hard_function_value (TREE_TYPE (exp), fndecl, (pass == 0));
2930 /* Precompute all register parameters. It isn't safe to compute anything
2931 once we have started filling any specific hard regs. */
2932 precompute_register_parameters (num_actuals, args, ®_parm_seen);
2934 #ifdef REG_PARM_STACK_SPACE
2935 /* Save the fixed argument area if it's part of the caller's frame and
2936 is clobbered by argument setup for this call. */
2937 if (ACCUMULATE_OUTGOING_ARGS && pass)
2938 save_area = save_fixed_argument_area (reg_parm_stack_space, argblock,
2939 &low_to_save, &high_to_save);
2942 /* Now store (and compute if necessary) all non-register parms.
2943 These come before register parms, since they can require block-moves,
2944 which could clobber the registers used for register parms.
2945 Parms which have partial registers are not stored here,
2946 but we do preallocate space here if they want that. */
2948 for (i = 0; i < num_actuals; i++)
2949 if (args[i].reg == 0 || args[i].pass_on_stack)
2951 rtx before_arg = get_last_insn ();
2953 if (store_one_arg (&args[i], argblock, flags,
2954 adjusted_args_size.var != 0,
2955 reg_parm_stack_space)
2957 && check_sibcall_argument_overlap (before_arg,
2959 sibcall_failure = 1;
2962 /* If we have a parm that is passed in registers but not in memory
2963 and whose alignment does not permit a direct copy into registers,
2964 make a group of pseudos that correspond to each register that we
2966 if (STRICT_ALIGNMENT)
2967 store_unaligned_arguments_into_pseudos (args, num_actuals);
2969 /* Now store any partially-in-registers parm.
2970 This is the last place a block-move can happen. */
2972 for (i = 0; i < num_actuals; i++)
2973 if (args[i].partial != 0 && ! args[i].pass_on_stack)
2975 rtx before_arg = get_last_insn ();
2977 if (store_one_arg (&args[i], argblock, flags,
2978 adjusted_args_size.var != 0,
2979 reg_parm_stack_space)
2981 && check_sibcall_argument_overlap (before_arg,
2983 sibcall_failure = 1;
2986 #ifdef PREFERRED_STACK_BOUNDARY
2987 /* If we pushed args in forward order, perform stack alignment
2988 after pushing the last arg. */
2989 if (!PUSH_ARGS_REVERSED && argblock == 0)
2990 anti_adjust_stack (GEN_INT (adjusted_args_size.constant
2991 - unadjusted_args_size));
2994 /* If register arguments require space on the stack and stack space
2995 was not preallocated, allocate stack space here for arguments
2996 passed in registers. */
2997 #ifdef OUTGOING_REG_PARM_STACK_SPACE
2998 if (!ACCUMULATE_OUTGOING_ARGS
2999 && must_preallocate == 0 && reg_parm_stack_space > 0)
3000 anti_adjust_stack (GEN_INT (reg_parm_stack_space));
3003 /* Pass the function the address in which to return a
3005 if (pass != 0 && structure_value_addr && ! structure_value_addr_parm)
3007 emit_move_insn (struct_value_rtx,
3009 force_operand (structure_value_addr,
3012 /* Mark the memory for the aggregate as write-only. */
3013 if (current_function_check_memory_usage)
3014 emit_library_call (chkr_set_right_libfunc, 1,
3016 structure_value_addr, ptr_mode,
3017 GEN_INT (struct_value_size),
3018 TYPE_MODE (sizetype),
3019 GEN_INT (MEMORY_USE_WO),
3020 TYPE_MODE (integer_type_node));
3022 if (GET_CODE (struct_value_rtx) == REG)
3023 use_reg (&call_fusage, struct_value_rtx);
3026 funexp = prepare_call_address (funexp, fndecl, &call_fusage,
3029 load_register_parameters (args, num_actuals, &call_fusage, flags);
3031 /* Perform postincrements before actually calling the function. */
3034 /* Save a pointer to the last insn before the call, so that we can
3035 later safely search backwards to find the CALL_INSN. */
3036 before_call = get_last_insn ();
3038 /* Set up next argument register. For sibling calls on machines
3039 with register windows this should be the incoming register. */
3040 #ifdef FUNCTION_INCOMING_ARG
3042 next_arg_reg = FUNCTION_INCOMING_ARG (args_so_far, VOIDmode,
3046 next_arg_reg = FUNCTION_ARG (args_so_far, VOIDmode,
3049 /* All arguments and registers used for the call must be set up by
3052 #ifdef PREFERRED_STACK_BOUNDARY
3053 /* Stack must be properly aligned now. */
3054 if (pass && stack_pointer_delta % preferred_unit_stack_boundary)
3058 /* Generate the actual call instruction. */
3059 emit_call_1 (funexp, fndecl, funtype, unadjusted_args_size,
3060 adjusted_args_size.constant, struct_value_size,
3061 next_arg_reg, valreg, old_inhibit_defer_pop, call_fusage,
3064 /* Verify that we've deallocated all the stack we used. */
3066 && old_stack_allocated != stack_pointer_delta - pending_stack_adjust)
3069 /* If call is cse'able, make appropriate pair of reg-notes around it.
3070 Test valreg so we don't crash; may safely ignore `const'
3071 if return type is void. Disable for PARALLEL return values, because
3072 we have no way to move such values into a pseudo register. */
3074 && (flags & (ECF_CONST | ECF_PURE))
3075 && valreg != 0 && GET_CODE (valreg) != PARALLEL)
3078 rtx temp = gen_reg_rtx (GET_MODE (valreg));
3081 /* Mark the return value as a pointer if needed. */
3082 if (TREE_CODE (TREE_TYPE (exp)) == POINTER_TYPE)
3083 mark_reg_pointer (temp, TYPE_ALIGN (TREE_TYPE (TREE_TYPE (exp))));
3085 /* Construct an "equal form" for the value which mentions all the
3086 arguments in order as well as the function name. */
3087 for (i = 0; i < num_actuals; i++)
3088 note = gen_rtx_EXPR_LIST (VOIDmode, args[i].initial_value, note);
3089 note = gen_rtx_EXPR_LIST (VOIDmode, funexp, note);
3091 insns = get_insns ();
3094 if (flags & ECF_PURE)
3095 note = gen_rtx_EXPR_LIST (VOIDmode,
3096 gen_rtx_USE (VOIDmode,
3097 gen_rtx_MEM (BLKmode,
3098 gen_rtx_SCRATCH (VOIDmode))), note);
3100 emit_libcall_block (insns, temp, valreg, note);
3104 else if (flags & (ECF_CONST | ECF_PURE))
3106 /* Otherwise, just write out the sequence without a note. */
3107 rtx insns = get_insns ();
3112 else if (flags & ECF_MALLOC)
3114 rtx temp = gen_reg_rtx (GET_MODE (valreg));
3117 /* The return value from a malloc-like function is a pointer. */
3118 if (TREE_CODE (TREE_TYPE (exp)) == POINTER_TYPE)
3119 mark_reg_pointer (temp, BIGGEST_ALIGNMENT);
3121 emit_move_insn (temp, valreg);
3123 /* The return value from a malloc-like function can not alias
3125 last = get_last_insn ();
3127 gen_rtx_EXPR_LIST (REG_NOALIAS, temp, REG_NOTES (last));
3129 /* Write out the sequence. */
3130 insns = get_insns ();
3136 /* For calls to `setjmp', etc., inform flow.c it should complain
3137 if nonvolatile values are live. For functions that cannot return,
3138 inform flow that control does not fall through. */
3140 if ((flags & (ECF_RETURNS_TWICE | ECF_NORETURN | ECF_LONGJMP)) || pass == 0)
3142 /* The barrier or NOTE_INSN_SETJMP note must be emitted
3143 immediately after the CALL_INSN. Some ports emit more
3144 than just a CALL_INSN above, so we must search for it here. */
3146 rtx last = get_last_insn ();
3147 while (GET_CODE (last) != CALL_INSN)
3149 last = PREV_INSN (last);
3150 /* There was no CALL_INSN? */
3151 if (last == before_call)
3155 if (flags & ECF_RETURNS_TWICE)
3157 emit_note_after (NOTE_INSN_SETJMP, last);
3158 current_function_calls_setjmp = 1;
3161 emit_barrier_after (last);
3164 if (flags & ECF_LONGJMP)
3165 current_function_calls_longjmp = 1;
3167 /* If this function is returning into a memory location marked as
3168 readonly, it means it is initializing that location. But we normally
3169 treat functions as not clobbering such locations, so we need to
3170 specify that this one does. */
3171 if (target != 0 && GET_CODE (target) == MEM
3172 && structure_value_addr != 0 && RTX_UNCHANGING_P (target))
3173 emit_insn (gen_rtx_CLOBBER (VOIDmode, target));
3175 /* If value type not void, return an rtx for the value. */
3177 /* If there are cleanups to be called, don't use a hard reg as target.
3178 We need to double check this and see if it matters anymore. */
3179 if (any_pending_cleanups (1))
3181 if (target && REG_P (target)
3182 && REGNO (target) < FIRST_PSEUDO_REGISTER)
3184 sibcall_failure = 1;
3187 if (TYPE_MODE (TREE_TYPE (exp)) == VOIDmode
3190 target = const0_rtx;
3192 else if (structure_value_addr)
3194 if (target == 0 || GET_CODE (target) != MEM)
3197 = gen_rtx_MEM (TYPE_MODE (TREE_TYPE (exp)),
3198 memory_address (TYPE_MODE (TREE_TYPE (exp)),
3199 structure_value_addr));
3200 set_mem_attributes (target, exp, 1);
3203 else if (pcc_struct_value)
3205 /* This is the special C++ case where we need to
3206 know what the true target was. We take care to
3207 never use this value more than once in one expression. */
3208 target = gen_rtx_MEM (TYPE_MODE (TREE_TYPE (exp)),
3209 copy_to_reg (valreg));
3210 set_mem_attributes (target, exp, 1);
3212 /* Handle calls that return values in multiple non-contiguous locations.
3213 The Irix 6 ABI has examples of this. */
3214 else if (GET_CODE (valreg) == PARALLEL)
3216 int bytes = int_size_in_bytes (TREE_TYPE (exp));
3220 target = assign_stack_temp (TYPE_MODE (TREE_TYPE (exp)),
3222 MEM_SET_IN_STRUCT_P (target, AGGREGATE_TYPE_P (TREE_TYPE (exp)));
3223 preserve_temp_slots (target);
3226 if (! rtx_equal_p (target, valreg))
3227 emit_group_store (target, valreg, bytes,
3228 TYPE_ALIGN (TREE_TYPE (exp)));
3230 /* We can not support sibling calls for this case. */
3231 sibcall_failure = 1;
3234 && GET_MODE (target) == TYPE_MODE (TREE_TYPE (exp))
3235 && GET_MODE (target) == GET_MODE (valreg))
3237 /* TARGET and VALREG cannot be equal at this point because the
3238 latter would not have REG_FUNCTION_VALUE_P true, while the
3239 former would if it were referring to the same register.
3241 If they refer to the same register, this move will be a no-op,
3242 except when function inlining is being done. */
3243 emit_move_insn (target, valreg);
3245 else if (TYPE_MODE (TREE_TYPE (exp)) == BLKmode)
3246 target = copy_blkmode_from_reg (target, valreg, TREE_TYPE (exp));
3248 target = copy_to_reg (valreg);
3250 #ifdef PROMOTE_FUNCTION_RETURN
3251 /* If we promoted this return value, make the proper SUBREG. TARGET
3252 might be const0_rtx here, so be careful. */
3253 if (GET_CODE (target) == REG
3254 && TYPE_MODE (TREE_TYPE (exp)) != BLKmode
3255 && GET_MODE (target) != TYPE_MODE (TREE_TYPE (exp)))
3257 tree type = TREE_TYPE (exp);
3258 int unsignedp = TREE_UNSIGNED (type);
3260 /* If we don't promote as expected, something is wrong. */
3261 if (GET_MODE (target)
3262 != promote_mode (type, TYPE_MODE (type), &unsignedp, 1))
3265 target = gen_rtx_SUBREG (TYPE_MODE (type), target, 0);
3266 SUBREG_PROMOTED_VAR_P (target) = 1;
3267 SUBREG_PROMOTED_UNSIGNED_P (target) = unsignedp;
3271 /* If size of args is variable or this was a constructor call for a stack
3272 argument, restore saved stack-pointer value. */
3274 if (old_stack_level)
3276 emit_stack_restore (SAVE_BLOCK, old_stack_level, NULL_RTX);
3277 pending_stack_adjust = old_pending_adj;
3278 stack_arg_under_construction = old_stack_arg_under_construction;
3279 highest_outgoing_arg_in_use = initial_highest_arg_in_use;
3280 stack_usage_map = initial_stack_usage_map;
3281 sibcall_failure = 1;
3283 else if (ACCUMULATE_OUTGOING_ARGS && pass)
3285 #ifdef REG_PARM_STACK_SPACE
3288 restore_fixed_argument_area (save_area, argblock,
3289 high_to_save, low_to_save);
3293 /* If we saved any argument areas, restore them. */
3294 for (i = 0; i < num_actuals; i++)
3295 if (args[i].save_area)
3297 enum machine_mode save_mode = GET_MODE (args[i].save_area);
3299 = gen_rtx_MEM (save_mode,
3300 memory_address (save_mode,
3301 XEXP (args[i].stack_slot, 0)));
3303 if (save_mode != BLKmode)
3304 emit_move_insn (stack_area, args[i].save_area);
3306 emit_block_move (stack_area,
3307 validize_mem (args[i].save_area),
3308 GEN_INT (args[i].size.constant),
3312 highest_outgoing_arg_in_use = initial_highest_arg_in_use;
3313 stack_usage_map = initial_stack_usage_map;
3316 /* If this was alloca, record the new stack level for nonlocal gotos.
3317 Check for the handler slots since we might not have a save area
3318 for non-local gotos. */
3320 if ((flags & ECF_MAY_BE_ALLOCA) && nonlocal_goto_handler_slots != 0)
3321 emit_stack_save (SAVE_NONLOCAL, &nonlocal_goto_stack_level, NULL_RTX);
3325 /* Free up storage we no longer need. */
3326 for (i = 0; i < num_actuals; ++i)
3327 if (args[i].aligned_regs)
3328 free (args[i].aligned_regs);
3332 /* Undo the fake expand_start_target_temps we did earlier. If
3333 there had been any cleanups created, we've already set
3335 expand_end_target_temps ();
3338 insns = get_insns ();
3343 tail_call_insns = insns;
3345 /* If something prevents making this a sibling call,
3346 zero out the sequence. */
3347 if (sibcall_failure)
3348 tail_call_insns = NULL_RTX;
3349 /* Restore the pending stack adjustment now that we have
3350 finished generating the sibling call sequence. */
3352 pending_stack_adjust = save_pending_stack_adjust;
3353 stack_pointer_delta = save_stack_pointer_delta;
3355 /* Prepare arg structure for next iteration. */
3356 for (i = 0 ; i < num_actuals ; i++)
3359 args[i].aligned_regs = 0;
3363 sbitmap_free (stored_args_map);
3366 normal_call_insns = insns;
3369 /* The function optimize_sibling_and_tail_recursive_calls doesn't
3370 handle CALL_PLACEHOLDERs inside other CALL_PLACEHOLDERs. This
3371 can happen if the arguments to this function call an inline
3372 function who's expansion contains another CALL_PLACEHOLDER.
3374 If there are any C_Ps in any of these sequences, replace them
3375 with their normal call. */
3377 for (insn = normal_call_insns; insn; insn = NEXT_INSN (insn))
3378 if (GET_CODE (insn) == CALL_INSN
3379 && GET_CODE (PATTERN (insn)) == CALL_PLACEHOLDER)
3380 replace_call_placeholder (insn, sibcall_use_normal);
3382 for (insn = tail_call_insns; insn; insn = NEXT_INSN (insn))
3383 if (GET_CODE (insn) == CALL_INSN
3384 && GET_CODE (PATTERN (insn)) == CALL_PLACEHOLDER)
3385 replace_call_placeholder (insn, sibcall_use_normal);
3387 for (insn = tail_recursion_insns; insn; insn = NEXT_INSN (insn))
3388 if (GET_CODE (insn) == CALL_INSN
3389 && GET_CODE (PATTERN (insn)) == CALL_PLACEHOLDER)
3390 replace_call_placeholder (insn, sibcall_use_normal);
3392 /* If this was a potential tail recursion site, then emit a
3393 CALL_PLACEHOLDER with the normal and the tail recursion streams.
3394 One of them will be selected later. */
3395 if (tail_recursion_insns || tail_call_insns)
3397 /* The tail recursion label must be kept around. We could expose
3398 its use in the CALL_PLACEHOLDER, but that creates unwanted edges
3399 and makes determining true tail recursion sites difficult.
3401 So we set LABEL_PRESERVE_P here, then clear it when we select
3402 one of the call sequences after rtl generation is complete. */
3403 if (tail_recursion_insns)
3404 LABEL_PRESERVE_P (tail_recursion_label) = 1;
3405 emit_call_insn (gen_rtx_CALL_PLACEHOLDER (VOIDmode, normal_call_insns,
3407 tail_recursion_insns,
3408 tail_recursion_label));
3411 emit_insns (normal_call_insns);
3413 currently_expanding_call--;
3418 /* Returns nonzero if FUN is the symbol for a library function which can
3422 libfunc_nothrow (fun)
3425 if (fun == throw_libfunc
3426 || fun == rethrow_libfunc
3427 || fun == sjthrow_libfunc
3428 || fun == sjpopnthrow_libfunc)
3434 /* Output a library call to function FUN (a SYMBOL_REF rtx).
3435 The RETVAL parameter specifies whether return value needs to be saved, other
3436 parameters are documented in the emit_library_call function bellow. */
3438 emit_library_call_value_1 (retval, orgfun, value, fn_type, outmode, nargs, p)
3443 enum machine_mode outmode;
3447 /* Total size in bytes of all the stack-parms scanned so far. */
3448 struct args_size args_size;
3449 /* Size of arguments before any adjustments (such as rounding). */
3450 struct args_size original_args_size;
3451 register int argnum;
3455 struct args_size alignment_pad;
3457 CUMULATIVE_ARGS args_so_far;
3458 struct arg { rtx value; enum machine_mode mode; rtx reg; int partial;
3459 struct args_size offset; struct args_size size; rtx save_area; };
3461 int old_inhibit_defer_pop = inhibit_defer_pop;
3462 rtx call_fusage = 0;
3465 int pcc_struct_value = 0;
3466 int struct_value_size = 0;
3468 int reg_parm_stack_space = 0;
3471 #ifdef REG_PARM_STACK_SPACE
3472 /* Define the boundary of the register parm stack space that needs to be
3474 int low_to_save = -1, high_to_save = 0;
3475 rtx save_area = 0; /* Place that it is saved */
3478 /* Size of the stack reserved for parameter registers. */
3479 int initial_highest_arg_in_use = highest_outgoing_arg_in_use;
3480 char *initial_stack_usage_map = stack_usage_map;
3482 #ifdef REG_PARM_STACK_SPACE
3483 #ifdef MAYBE_REG_PARM_STACK_SPACE
3484 reg_parm_stack_space = MAYBE_REG_PARM_STACK_SPACE;
3486 reg_parm_stack_space = REG_PARM_STACK_SPACE ((tree) 0);
3492 else if (fn_type == 2)
3496 if (libfunc_nothrow (fun))
3497 flags |= ECF_NOTHROW;
3499 #ifdef PREFERRED_STACK_BOUNDARY
3500 /* Ensure current function's preferred stack boundary is at least
3502 if (cfun->preferred_stack_boundary < PREFERRED_STACK_BOUNDARY)
3503 cfun->preferred_stack_boundary = PREFERRED_STACK_BOUNDARY;
3506 /* If this kind of value comes back in memory,
3507 decide where in memory it should come back. */
3508 if (outmode != VOIDmode && aggregate_value_p (type_for_mode (outmode, 0)))
3510 #ifdef PCC_STATIC_STRUCT_RETURN
3512 = hard_function_value (build_pointer_type (type_for_mode (outmode, 0)),
3514 mem_value = gen_rtx_MEM (outmode, pointer_reg);
3515 pcc_struct_value = 1;
3517 value = gen_reg_rtx (outmode);
3518 #else /* not PCC_STATIC_STRUCT_RETURN */
3519 struct_value_size = GET_MODE_SIZE (outmode);
3520 if (value != 0 && GET_CODE (value) == MEM)
3523 mem_value = assign_stack_temp (outmode, GET_MODE_SIZE (outmode), 0);
3526 /* This call returns a big structure. */
3527 flags &= ~(ECF_CONST | ECF_PURE);
3530 /* ??? Unfinished: must pass the memory address as an argument. */
3532 /* Copy all the libcall-arguments out of the varargs data
3533 and into a vector ARGVEC.
3535 Compute how to pass each argument. We only support a very small subset
3536 of the full argument passing conventions to limit complexity here since
3537 library functions shouldn't have many args. */
3539 argvec = (struct arg *) alloca ((nargs + 1) * sizeof (struct arg));
3540 bzero ((char *) argvec, (nargs + 1) * sizeof (struct arg));
3542 INIT_CUMULATIVE_ARGS (args_so_far, NULL_TREE, fun, 0);
3544 args_size.constant = 0;
3549 /* Now we are about to start emitting insns that can be deleted
3550 if a libcall is deleted. */
3551 if (flags & (ECF_CONST | ECF_PURE))
3556 /* If there's a structure value address to be passed,
3557 either pass it in the special place, or pass it as an extra argument. */
3558 if (mem_value && struct_value_rtx == 0 && ! pcc_struct_value)
3560 rtx addr = XEXP (mem_value, 0);
3563 /* Make sure it is a reasonable operand for a move or push insn. */
3564 if (GET_CODE (addr) != REG && GET_CODE (addr) != MEM
3565 && ! (CONSTANT_P (addr) && LEGITIMATE_CONSTANT_P (addr)))
3566 addr = force_operand (addr, NULL_RTX);
3568 argvec[count].value = addr;
3569 argvec[count].mode = Pmode;
3570 argvec[count].partial = 0;
3572 argvec[count].reg = FUNCTION_ARG (args_so_far, Pmode, NULL_TREE, 1);
3573 #ifdef FUNCTION_ARG_PARTIAL_NREGS
3574 if (FUNCTION_ARG_PARTIAL_NREGS (args_so_far, Pmode, NULL_TREE, 1))
3578 locate_and_pad_parm (Pmode, NULL_TREE,
3579 #ifdef STACK_PARMS_IN_REG_PARM_AREA
3582 argvec[count].reg != 0,
3584 NULL_TREE, &args_size, &argvec[count].offset,
3585 &argvec[count].size, &alignment_pad);
3588 if (argvec[count].reg == 0 || argvec[count].partial != 0
3589 || reg_parm_stack_space > 0)
3590 args_size.constant += argvec[count].size.constant;
3592 FUNCTION_ARG_ADVANCE (args_so_far, Pmode, (tree) 0, 1);
3597 for (; count < nargs; count++)
3599 rtx val = va_arg (p, rtx);
3600 enum machine_mode mode = va_arg (p, enum machine_mode);
3602 /* We cannot convert the arg value to the mode the library wants here;
3603 must do it earlier where we know the signedness of the arg. */
3605 || (GET_MODE (val) != mode && GET_MODE (val) != VOIDmode))
3608 /* On some machines, there's no way to pass a float to a library fcn.
3609 Pass it as a double instead. */
3610 #ifdef LIBGCC_NEEDS_DOUBLE
3611 if (LIBGCC_NEEDS_DOUBLE && mode == SFmode)
3612 val = convert_modes (DFmode, SFmode, val, 0), mode = DFmode;
3615 /* There's no need to call protect_from_queue, because
3616 either emit_move_insn or emit_push_insn will do that. */
3618 /* Make sure it is a reasonable operand for a move or push insn. */
3619 if (GET_CODE (val) != REG && GET_CODE (val) != MEM
3620 && ! (CONSTANT_P (val) && LEGITIMATE_CONSTANT_P (val)))
3621 val = force_operand (val, NULL_RTX);
3623 #ifdef FUNCTION_ARG_PASS_BY_REFERENCE
3624 if (FUNCTION_ARG_PASS_BY_REFERENCE (args_so_far, mode, NULL_TREE, 1))
3626 /* We do not support FUNCTION_ARG_CALLEE_COPIES here since it can
3627 be viewed as just an efficiency improvement. */
3628 rtx slot = assign_stack_temp (mode, GET_MODE_SIZE (mode), 0);
3629 emit_move_insn (slot, val);
3630 val = force_operand (XEXP (slot, 0), NULL_RTX);
3635 argvec[count].value = val;
3636 argvec[count].mode = mode;
3638 argvec[count].reg = FUNCTION_ARG (args_so_far, mode, NULL_TREE, 1);
3640 #ifdef FUNCTION_ARG_PARTIAL_NREGS
3641 argvec[count].partial
3642 = FUNCTION_ARG_PARTIAL_NREGS (args_so_far, mode, NULL_TREE, 1);
3644 argvec[count].partial = 0;
3647 locate_and_pad_parm (mode, NULL_TREE,
3648 #ifdef STACK_PARMS_IN_REG_PARM_AREA
3651 argvec[count].reg != 0,
3653 NULL_TREE, &args_size, &argvec[count].offset,
3654 &argvec[count].size, &alignment_pad);
3656 if (argvec[count].size.var)
3659 if (reg_parm_stack_space == 0 && argvec[count].partial)
3660 argvec[count].size.constant -= argvec[count].partial * UNITS_PER_WORD;
3662 if (argvec[count].reg == 0 || argvec[count].partial != 0
3663 || reg_parm_stack_space > 0)
3664 args_size.constant += argvec[count].size.constant;
3666 FUNCTION_ARG_ADVANCE (args_so_far, mode, (tree) 0, 1);
3669 #ifdef FINAL_REG_PARM_STACK_SPACE
3670 reg_parm_stack_space = FINAL_REG_PARM_STACK_SPACE (args_size.constant,
3673 /* If this machine requires an external definition for library
3674 functions, write one out. */
3675 assemble_external_libcall (fun);
3677 original_args_size = args_size;
3678 #ifdef PREFERRED_STACK_BOUNDARY
3679 args_size.constant = (((args_size.constant
3680 + stack_pointer_delta
3684 - stack_pointer_delta);
3687 args_size.constant = MAX (args_size.constant,
3688 reg_parm_stack_space);
3690 #ifndef OUTGOING_REG_PARM_STACK_SPACE
3691 args_size.constant -= reg_parm_stack_space;
3694 if (args_size.constant > current_function_outgoing_args_size)
3695 current_function_outgoing_args_size = args_size.constant;
3697 if (ACCUMULATE_OUTGOING_ARGS)
3699 /* Since the stack pointer will never be pushed, it is possible for
3700 the evaluation of a parm to clobber something we have already
3701 written to the stack. Since most function calls on RISC machines
3702 do not use the stack, this is uncommon, but must work correctly.
3704 Therefore, we save any area of the stack that was already written
3705 and that we are using. Here we set up to do this by making a new
3706 stack usage map from the old one.
3708 Another approach might be to try to reorder the argument
3709 evaluations to avoid this conflicting stack usage. */
3711 needed = args_size.constant;
3713 #ifndef OUTGOING_REG_PARM_STACK_SPACE
3714 /* Since we will be writing into the entire argument area, the
3715 map must be allocated for its entire size, not just the part that
3716 is the responsibility of the caller. */
3717 needed += reg_parm_stack_space;
3720 #ifdef ARGS_GROW_DOWNWARD
3721 highest_outgoing_arg_in_use = MAX (initial_highest_arg_in_use,
3724 highest_outgoing_arg_in_use = MAX (initial_highest_arg_in_use,
3727 stack_usage_map = (char *) alloca (highest_outgoing_arg_in_use);
3729 if (initial_highest_arg_in_use)
3730 bcopy (initial_stack_usage_map, stack_usage_map,
3731 initial_highest_arg_in_use);
3733 if (initial_highest_arg_in_use != highest_outgoing_arg_in_use)
3734 bzero (&stack_usage_map[initial_highest_arg_in_use],
3735 highest_outgoing_arg_in_use - initial_highest_arg_in_use);
3738 /* The address of the outgoing argument list must not be copied to a
3739 register here, because argblock would be left pointing to the
3740 wrong place after the call to allocate_dynamic_stack_space below.
3743 argblock = virtual_outgoing_args_rtx;
3748 argblock = push_block (GEN_INT (args_size.constant), 0, 0);
3751 #ifdef PREFERRED_STACK_BOUNDARY
3752 /* If we push args individually in reverse order, perform stack alignment
3753 before the first push (the last arg). */
3754 if (argblock == 0 && PUSH_ARGS_REVERSED)
3755 anti_adjust_stack (GEN_INT (args_size.constant
3756 - original_args_size.constant));
3759 if (PUSH_ARGS_REVERSED)
3770 #ifdef REG_PARM_STACK_SPACE
3771 if (ACCUMULATE_OUTGOING_ARGS)
3773 /* The argument list is the property of the called routine and it
3774 may clobber it. If the fixed area has been used for previous
3775 parameters, we must save and restore it.
3777 Here we compute the boundary of the that needs to be saved, if any. */
3779 #ifdef ARGS_GROW_DOWNWARD
3780 for (count = 0; count < reg_parm_stack_space + 1; count++)
3782 for (count = 0; count < reg_parm_stack_space; count++)
3785 if (count >= highest_outgoing_arg_in_use
3786 || stack_usage_map[count] == 0)
3789 if (low_to_save == -1)
3790 low_to_save = count;
3792 high_to_save = count;
3795 if (low_to_save >= 0)
3797 int num_to_save = high_to_save - low_to_save + 1;
3798 enum machine_mode save_mode
3799 = mode_for_size (num_to_save * BITS_PER_UNIT, MODE_INT, 1);
3802 /* If we don't have the required alignment, must do this in BLKmode. */
3803 if ((low_to_save & (MIN (GET_MODE_SIZE (save_mode),
3804 BIGGEST_ALIGNMENT / UNITS_PER_WORD) - 1)))
3805 save_mode = BLKmode;
3807 #ifdef ARGS_GROW_DOWNWARD
3808 stack_area = gen_rtx_MEM (save_mode,
3809 memory_address (save_mode,
3810 plus_constant (argblock,
3813 stack_area = gen_rtx_MEM (save_mode,
3814 memory_address (save_mode,
3815 plus_constant (argblock,
3818 if (save_mode == BLKmode)
3820 save_area = assign_stack_temp (BLKmode, num_to_save, 0);
3821 emit_block_move (validize_mem (save_area), stack_area,
3822 GEN_INT (num_to_save), PARM_BOUNDARY);
3826 save_area = gen_reg_rtx (save_mode);
3827 emit_move_insn (save_area, stack_area);
3833 /* Push the args that need to be pushed. */
3835 /* ARGNUM indexes the ARGVEC array in the order in which the arguments
3836 are to be pushed. */
3837 for (count = 0; count < nargs; count++, argnum += inc)
3839 register enum machine_mode mode = argvec[argnum].mode;
3840 register rtx val = argvec[argnum].value;
3841 rtx reg = argvec[argnum].reg;
3842 int partial = argvec[argnum].partial;
3843 int lower_bound = 0, upper_bound = 0, i;
3845 if (! (reg != 0 && partial == 0))
3847 if (ACCUMULATE_OUTGOING_ARGS)
3849 /* If this is being stored into a pre-allocated, fixed-size,
3850 stack area, save any previous data at that location. */
3852 #ifdef ARGS_GROW_DOWNWARD
3853 /* stack_slot is negative, but we want to index stack_usage_map
3854 with positive values. */
3855 upper_bound = -argvec[argnum].offset.constant + 1;
3856 lower_bound = upper_bound - argvec[argnum].size.constant;
3858 lower_bound = argvec[argnum].offset.constant;
3859 upper_bound = lower_bound + argvec[argnum].size.constant;
3862 for (i = lower_bound; i < upper_bound; i++)
3863 if (stack_usage_map[i]
3864 /* Don't store things in the fixed argument area at this
3865 point; it has already been saved. */
3866 && i > reg_parm_stack_space)
3869 if (i != upper_bound)
3871 /* We need to make a save area. See what mode we can make
3873 enum machine_mode save_mode
3874 = mode_for_size (argvec[argnum].size.constant
3882 plus_constant (argblock,
3883 argvec[argnum].offset.constant)));
3884 argvec[argnum].save_area = gen_reg_rtx (save_mode);
3886 emit_move_insn (argvec[argnum].save_area, stack_area);
3890 emit_push_insn (val, mode, NULL_TREE, NULL_RTX, 0, partial, reg, 0,
3891 argblock, GEN_INT (argvec[argnum].offset.constant),
3892 reg_parm_stack_space, ARGS_SIZE_RTX (alignment_pad));
3894 /* Now mark the segment we just used. */
3895 if (ACCUMULATE_OUTGOING_ARGS)
3896 for (i = lower_bound; i < upper_bound; i++)
3897 stack_usage_map[i] = 1;
3903 #ifdef PREFERRED_STACK_BOUNDARY
3904 /* If we pushed args in forward order, perform stack alignment
3905 after pushing the last arg. */
3906 if (argblock == 0 && !PUSH_ARGS_REVERSED)
3907 anti_adjust_stack (GEN_INT (args_size.constant
3908 - original_args_size.constant));
3911 if (PUSH_ARGS_REVERSED)
3916 fun = prepare_call_address (fun, NULL_TREE, &call_fusage, 0);
3918 /* Now load any reg parms into their regs. */
3920 /* ARGNUM indexes the ARGVEC array in the order in which the arguments
3921 are to be pushed. */
3922 for (count = 0; count < nargs; count++, argnum += inc)
3924 register rtx val = argvec[argnum].value;
3925 rtx reg = argvec[argnum].reg;
3926 int partial = argvec[argnum].partial;
3928 /* Handle calls that pass values in multiple non-contiguous
3929 locations. The PA64 has examples of this for library calls. */
3930 if (reg != 0 && GET_CODE (reg) == PARALLEL)
3931 emit_group_load (reg, val,
3932 GET_MODE_SIZE (GET_MODE (val)),
3933 GET_MODE_ALIGNMENT (GET_MODE (val)));
3934 else if (reg != 0 && partial == 0)
3935 emit_move_insn (reg, val);
3940 /* Any regs containing parms remain in use through the call. */
3941 for (count = 0; count < nargs; count++)
3943 rtx reg = argvec[count].reg;
3944 if (reg != 0 && GET_CODE (reg) == PARALLEL)
3945 use_group_regs (&call_fusage, reg);
3947 use_reg (&call_fusage, reg);
3950 /* Pass the function the address in which to return a structure value. */
3951 if (mem_value != 0 && struct_value_rtx != 0 && ! pcc_struct_value)
3953 emit_move_insn (struct_value_rtx,
3955 force_operand (XEXP (mem_value, 0),
3957 if (GET_CODE (struct_value_rtx) == REG)
3958 use_reg (&call_fusage, struct_value_rtx);
3961 /* Don't allow popping to be deferred, since then
3962 cse'ing of library calls could delete a call and leave the pop. */
3964 valreg = (mem_value == 0 && outmode != VOIDmode
3965 ? hard_libcall_value (outmode) : NULL_RTX);
3967 #ifdef PREFERRED_STACK_BOUNDARY
3968 /* Stack must be properly aligned now. */
3969 if (stack_pointer_delta & (PREFERRED_STACK_BOUNDARY / BITS_PER_UNIT - 1))
3973 /* We pass the old value of inhibit_defer_pop + 1 to emit_call_1, which
3974 will set inhibit_defer_pop to that value. */
3975 /* The return type is needed to decide how many bytes the function pops.
3976 Signedness plays no role in that, so for simplicity, we pretend it's
3977 always signed. We also assume that the list of arguments passed has
3978 no impact, so we pretend it is unknown. */
3981 get_identifier (XSTR (orgfun, 0)),
3982 build_function_type (outmode == VOIDmode ? void_type_node
3983 : type_for_mode (outmode, 0), NULL_TREE),
3984 original_args_size.constant, args_size.constant,
3986 FUNCTION_ARG (args_so_far, VOIDmode, void_type_node, 1),
3988 old_inhibit_defer_pop + 1, call_fusage, flags);
3990 /* Now restore inhibit_defer_pop to its actual original value. */
3993 /* If call is cse'able, make appropriate pair of reg-notes around it.
3994 Test valreg so we don't crash; may safely ignore `const'
3995 if return type is void. Disable for PARALLEL return values, because
3996 we have no way to move such values into a pseudo register. */
3997 if ((flags & (ECF_CONST | ECF_PURE))
3998 && valreg != 0 && GET_CODE (valreg) != PARALLEL)
4001 rtx temp = gen_reg_rtx (GET_MODE (valreg));
4005 /* Construct an "equal form" for the value which mentions all the
4006 arguments in order as well as the function name. */
4007 for (i = 0; i < nargs; i++)
4008 note = gen_rtx_EXPR_LIST (VOIDmode, argvec[i].value, note);
4009 note = gen_rtx_EXPR_LIST (VOIDmode, fun, note);
4011 insns = get_insns ();
4014 if (flags & ECF_PURE)
4015 note = gen_rtx_EXPR_LIST (VOIDmode,
4016 gen_rtx_USE (VOIDmode,
4017 gen_rtx_MEM (BLKmode,
4018 gen_rtx_SCRATCH (VOIDmode))), note);
4020 emit_libcall_block (insns, temp, valreg, note);
4024 else if (flags & (ECF_CONST | ECF_PURE))
4026 /* Otherwise, just write out the sequence without a note. */
4027 rtx insns = get_insns ();
4034 /* Copy the value to the right place. */
4035 if (outmode != VOIDmode && retval)
4041 if (value != mem_value)
4042 emit_move_insn (value, mem_value);
4044 else if (value != 0)
4045 emit_move_insn (value, hard_libcall_value (outmode));
4047 value = hard_libcall_value (outmode);
4050 if (ACCUMULATE_OUTGOING_ARGS)
4052 #ifdef REG_PARM_STACK_SPACE
4055 enum machine_mode save_mode = GET_MODE (save_area);
4056 #ifdef ARGS_GROW_DOWNWARD
4058 = gen_rtx_MEM (save_mode,
4059 memory_address (save_mode,
4060 plus_constant (argblock,
4064 = gen_rtx_MEM (save_mode,
4065 memory_address (save_mode,
4066 plus_constant (argblock, low_to_save)));
4068 if (save_mode != BLKmode)
4069 emit_move_insn (stack_area, save_area);
4071 emit_block_move (stack_area, validize_mem (save_area),
4072 GEN_INT (high_to_save - low_to_save + 1),
4077 /* If we saved any argument areas, restore them. */
4078 for (count = 0; count < nargs; count++)
4079 if (argvec[count].save_area)
4081 enum machine_mode save_mode = GET_MODE (argvec[count].save_area);
4083 = gen_rtx_MEM (save_mode,
4086 plus_constant (argblock,
4087 argvec[count].offset.constant)));
4089 emit_move_insn (stack_area, argvec[count].save_area);
4092 highest_outgoing_arg_in_use = initial_highest_arg_in_use;
4093 stack_usage_map = initial_stack_usage_map;
4100 /* Output a library call to function FUN (a SYMBOL_REF rtx)
4101 (emitting the queue unless NO_QUEUE is nonzero),
4102 for a value of mode OUTMODE,
4103 with NARGS different arguments, passed as alternating rtx values
4104 and machine_modes to convert them to.
4105 The rtx values should have been passed through protect_from_queue already.
4107 FN_TYPE will is zero for `normal' calls, one for `const' calls, wich
4108 which will be enclosed in REG_LIBCALL/REG_RETVAL notes and two for `pure'
4109 calls, that are handled like `const' calls with extra
4110 (use (memory (scratch)). */
4113 emit_library_call VPARAMS((rtx orgfun, int fn_type, enum machine_mode outmode,
4116 #ifndef ANSI_PROTOTYPES
4119 enum machine_mode outmode;
4124 VA_START (p, nargs);
4126 #ifndef ANSI_PROTOTYPES
4127 orgfun = va_arg (p, rtx);
4128 fn_type = va_arg (p, int);
4129 outmode = va_arg (p, enum machine_mode);
4130 nargs = va_arg (p, int);
4133 emit_library_call_value_1 (0, orgfun, NULL_RTX, fn_type, outmode, nargs, p);
4138 /* Like emit_library_call except that an extra argument, VALUE,
4139 comes second and says where to store the result.
4140 (If VALUE is zero, this function chooses a convenient way
4141 to return the value.
4143 This function returns an rtx for where the value is to be found.
4144 If VALUE is nonzero, VALUE is returned. */
4147 emit_library_call_value VPARAMS((rtx orgfun, rtx value, int fn_type,
4148 enum machine_mode outmode, int nargs, ...))
4150 #ifndef ANSI_PROTOTYPES
4154 enum machine_mode outmode;
4159 VA_START (p, nargs);
4161 #ifndef ANSI_PROTOTYPES
4162 orgfun = va_arg (p, rtx);
4163 value = va_arg (p, rtx);
4164 fn_type = va_arg (p, int);
4165 outmode = va_arg (p, enum machine_mode);
4166 nargs = va_arg (p, int);
4169 value = emit_library_call_value_1 (1, orgfun, value, fn_type, outmode, nargs, p);
4177 /* Return an rtx which represents a suitable home on the stack
4178 given TYPE, the type of the argument looking for a home.
4179 This is called only for BLKmode arguments.
4181 SIZE is the size needed for this target.
4182 ARGS_ADDR is the address of the bottom of the argument block for this call.
4183 OFFSET describes this parameter's offset into ARGS_ADDR. It is meaningless
4184 if this machine uses push insns. */
4187 target_for_arg (type, size, args_addr, offset)
4191 struct args_size offset;
4194 rtx offset_rtx = ARGS_SIZE_RTX (offset);
4196 /* We do not call memory_address if possible,
4197 because we want to address as close to the stack
4198 as possible. For non-variable sized arguments,
4199 this will be stack-pointer relative addressing. */
4200 if (GET_CODE (offset_rtx) == CONST_INT)
4201 target = plus_constant (args_addr, INTVAL (offset_rtx));
4204 /* I have no idea how to guarantee that this
4205 will work in the presence of register parameters. */
4206 target = gen_rtx_PLUS (Pmode, args_addr, offset_rtx);
4207 target = memory_address (QImode, target);
4210 return gen_rtx_MEM (BLKmode, target);
4214 /* Store a single argument for a function call
4215 into the register or memory area where it must be passed.
4216 *ARG describes the argument value and where to pass it.
4218 ARGBLOCK is the address of the stack-block for all the arguments,
4219 or 0 on a machine where arguments are pushed individually.
4221 MAY_BE_ALLOCA nonzero says this could be a call to `alloca'
4222 so must be careful about how the stack is used.
4224 VARIABLE_SIZE nonzero says that this was a variable-sized outgoing
4225 argument stack. This is used if ACCUMULATE_OUTGOING_ARGS to indicate
4226 that we need not worry about saving and restoring the stack.
4228 FNDECL is the declaration of the function we are calling.
4230 Return non-zero if this arg should cause sibcall failure,
4234 store_one_arg (arg, argblock, flags, variable_size,
4235 reg_parm_stack_space)
4236 struct arg_data *arg;
4239 int variable_size ATTRIBUTE_UNUSED;
4240 int reg_parm_stack_space;
4242 register tree pval = arg->tree_value;
4246 int i, lower_bound = 0, upper_bound = 0;
4247 int sibcall_failure = 0;
4249 if (TREE_CODE (pval) == ERROR_MARK)
4252 /* Push a new temporary level for any temporaries we make for
4256 if (ACCUMULATE_OUTGOING_ARGS && !(flags & ECF_SIBCALL))
4258 /* If this is being stored into a pre-allocated, fixed-size, stack area,
4259 save any previous data at that location. */
4260 if (argblock && ! variable_size && arg->stack)
4262 #ifdef ARGS_GROW_DOWNWARD
4263 /* stack_slot is negative, but we want to index stack_usage_map
4264 with positive values. */
4265 if (GET_CODE (XEXP (arg->stack_slot, 0)) == PLUS)
4266 upper_bound = -INTVAL (XEXP (XEXP (arg->stack_slot, 0), 1)) + 1;
4270 lower_bound = upper_bound - arg->size.constant;
4272 if (GET_CODE (XEXP (arg->stack_slot, 0)) == PLUS)
4273 lower_bound = INTVAL (XEXP (XEXP (arg->stack_slot, 0), 1));
4277 upper_bound = lower_bound + arg->size.constant;
4280 for (i = lower_bound; i < upper_bound; i++)
4281 if (stack_usage_map[i]
4282 /* Don't store things in the fixed argument area at this point;
4283 it has already been saved. */
4284 && i > reg_parm_stack_space)
4287 if (i != upper_bound)
4289 /* We need to make a save area. See what mode we can make it. */
4290 enum machine_mode save_mode
4291 = mode_for_size (arg->size.constant * BITS_PER_UNIT, MODE_INT, 1);
4293 = gen_rtx_MEM (save_mode,
4294 memory_address (save_mode,
4295 XEXP (arg->stack_slot, 0)));
4297 if (save_mode == BLKmode)
4299 arg->save_area = assign_stack_temp (BLKmode,
4300 arg->size.constant, 0);
4301 MEM_SET_IN_STRUCT_P (arg->save_area,
4302 AGGREGATE_TYPE_P (TREE_TYPE
4303 (arg->tree_value)));
4304 preserve_temp_slots (arg->save_area);
4305 emit_block_move (validize_mem (arg->save_area), stack_area,
4306 GEN_INT (arg->size.constant),
4311 arg->save_area = gen_reg_rtx (save_mode);
4312 emit_move_insn (arg->save_area, stack_area);
4316 /* Now that we have saved any slots that will be overwritten by this
4317 store, mark all slots this store will use. We must do this before
4318 we actually expand the argument since the expansion itself may
4319 trigger library calls which might need to use the same stack slot. */
4320 if (argblock && ! variable_size && arg->stack)
4321 for (i = lower_bound; i < upper_bound; i++)
4322 stack_usage_map[i] = 1;
4325 /* If this isn't going to be placed on both the stack and in registers,
4326 set up the register and number of words. */
4327 if (! arg->pass_on_stack)
4328 reg = arg->reg, partial = arg->partial;
4330 if (reg != 0 && partial == 0)
4331 /* Being passed entirely in a register. We shouldn't be called in
4335 /* If this arg needs special alignment, don't load the registers
4337 if (arg->n_aligned_regs != 0)
4340 /* If this is being passed partially in a register, we can't evaluate
4341 it directly into its stack slot. Otherwise, we can. */
4342 if (arg->value == 0)
4344 /* stack_arg_under_construction is nonzero if a function argument is
4345 being evaluated directly into the outgoing argument list and
4346 expand_call must take special action to preserve the argument list
4347 if it is called recursively.
4349 For scalar function arguments stack_usage_map is sufficient to
4350 determine which stack slots must be saved and restored. Scalar
4351 arguments in general have pass_on_stack == 0.
4353 If this argument is initialized by a function which takes the
4354 address of the argument (a C++ constructor or a C function
4355 returning a BLKmode structure), then stack_usage_map is
4356 insufficient and expand_call must push the stack around the
4357 function call. Such arguments have pass_on_stack == 1.
4359 Note that it is always safe to set stack_arg_under_construction,
4360 but this generates suboptimal code if set when not needed. */
4362 if (arg->pass_on_stack)
4363 stack_arg_under_construction++;
4365 arg->value = expand_expr (pval,
4367 || TYPE_MODE (TREE_TYPE (pval)) != arg->mode)
4368 ? NULL_RTX : arg->stack,
4371 /* If we are promoting object (or for any other reason) the mode
4372 doesn't agree, convert the mode. */
4374 if (arg->mode != TYPE_MODE (TREE_TYPE (pval)))
4375 arg->value = convert_modes (arg->mode, TYPE_MODE (TREE_TYPE (pval)),
4376 arg->value, arg->unsignedp);
4378 if (arg->pass_on_stack)
4379 stack_arg_under_construction--;
4382 /* Don't allow anything left on stack from computation
4383 of argument to alloca. */
4384 if (flags & ECF_MAY_BE_ALLOCA)
4385 do_pending_stack_adjust ();
4387 if (arg->value == arg->stack)
4389 /* If the value is already in the stack slot, we are done. */
4390 if (current_function_check_memory_usage && GET_CODE (arg->stack) == MEM)
4392 emit_library_call (chkr_set_right_libfunc, 1, VOIDmode, 3,
4393 XEXP (arg->stack, 0), Pmode,
4394 ARGS_SIZE_RTX (arg->size),
4395 TYPE_MODE (sizetype),
4396 GEN_INT (MEMORY_USE_RW),
4397 TYPE_MODE (integer_type_node));
4400 else if (arg->mode != BLKmode)
4404 /* Argument is a scalar, not entirely passed in registers.
4405 (If part is passed in registers, arg->partial says how much
4406 and emit_push_insn will take care of putting it there.)
4408 Push it, and if its size is less than the
4409 amount of space allocated to it,
4410 also bump stack pointer by the additional space.
4411 Note that in C the default argument promotions
4412 will prevent such mismatches. */
4414 size = GET_MODE_SIZE (arg->mode);
4415 /* Compute how much space the push instruction will push.
4416 On many machines, pushing a byte will advance the stack
4417 pointer by a halfword. */
4418 #ifdef PUSH_ROUNDING
4419 size = PUSH_ROUNDING (size);
4423 /* Compute how much space the argument should get:
4424 round up to a multiple of the alignment for arguments. */
4425 if (none != FUNCTION_ARG_PADDING (arg->mode, TREE_TYPE (pval)))
4426 used = (((size + PARM_BOUNDARY / BITS_PER_UNIT - 1)
4427 / (PARM_BOUNDARY / BITS_PER_UNIT))
4428 * (PARM_BOUNDARY / BITS_PER_UNIT));
4430 /* This isn't already where we want it on the stack, so put it there.
4431 This can either be done with push or copy insns. */
4432 emit_push_insn (arg->value, arg->mode, TREE_TYPE (pval), NULL_RTX, 0,
4433 partial, reg, used - size, argblock,
4434 ARGS_SIZE_RTX (arg->offset), reg_parm_stack_space,
4435 ARGS_SIZE_RTX (arg->alignment_pad));
4439 /* BLKmode, at least partly to be pushed. */
4441 register int excess;
4444 /* Pushing a nonscalar.
4445 If part is passed in registers, PARTIAL says how much
4446 and emit_push_insn will take care of putting it there. */
4448 /* Round its size up to a multiple
4449 of the allocation unit for arguments. */
4451 if (arg->size.var != 0)
4454 size_rtx = ARGS_SIZE_RTX (arg->size);
4458 /* PUSH_ROUNDING has no effect on us, because
4459 emit_push_insn for BLKmode is careful to avoid it. */
4460 excess = (arg->size.constant - int_size_in_bytes (TREE_TYPE (pval))
4461 + partial * UNITS_PER_WORD);
4462 size_rtx = expr_size (pval);
4465 if ((flags & ECF_SIBCALL) && GET_CODE (arg->value) == MEM)
4467 /* emit_push_insn might not work properly if arg->value and
4468 argblock + arg->offset areas overlap. */
4472 if (XEXP (x, 0) == current_function_internal_arg_pointer
4473 || (GET_CODE (XEXP (x, 0)) == PLUS
4474 && XEXP (XEXP (x, 0), 0) ==
4475 current_function_internal_arg_pointer
4476 && GET_CODE (XEXP (XEXP (x, 0), 1)) == CONST_INT))
4478 if (XEXP (x, 0) != current_function_internal_arg_pointer)
4479 i = INTVAL (XEXP (XEXP (x, 0), 1));
4481 /* expand_call should ensure this */
4482 if (arg->offset.var || GET_CODE (size_rtx) != CONST_INT)
4485 if (arg->offset.constant > i)
4487 if (arg->offset.constant < i + INTVAL (size_rtx))
4488 sibcall_failure = 1;
4490 else if (arg->offset.constant < i)
4492 if (i < arg->offset.constant + INTVAL (size_rtx))
4493 sibcall_failure = 1;
4498 emit_push_insn (arg->value, arg->mode, TREE_TYPE (pval), size_rtx,
4499 TYPE_ALIGN (TREE_TYPE (pval)), partial, reg, excess,
4500 argblock, ARGS_SIZE_RTX (arg->offset),
4501 reg_parm_stack_space,
4502 ARGS_SIZE_RTX (arg->alignment_pad));
4506 /* Unless this is a partially-in-register argument, the argument is now
4509 ??? Note that this can change arg->value from arg->stack to
4510 arg->stack_slot and it matters when they are not the same.
4511 It isn't totally clear that this is correct in all cases. */
4513 arg->value = arg->stack_slot;
4515 /* Once we have pushed something, pops can't safely
4516 be deferred during the rest of the arguments. */
4519 /* ANSI doesn't require a sequence point here,
4520 but PCC has one, so this will avoid some problems. */
4523 /* Free any temporary slots made in processing this argument. Show
4524 that we might have taken the address of something and pushed that
4526 preserve_temp_slots (NULL_RTX);
4530 return sibcall_failure;